Difference between revisions of "Subsystem"

From Crash Bandicoot Hacking Wiki
Jump to navigation Jump to search
(Subsystem Table)
Line 1: Line 1:
A subsystem is a self-contained system within a larger system. In each of the Crash games, there exist a number of different subsystems. Each subsystem handles a different aspect of the game's function. Many of these subsystems are associated with the type of entry that they primarily operate upon. In fact, an entry's type is just the ID of the subsystem that operates upon its data.
+
A subsystem is a self-contained system within a larger system. In each of the Crash games, there exist a number of different subsystems. Each subsystem handles a different aspect of the game's function. Many of these subsystems are associated with the type of entry that they primarily operate upon. In fact, an entry's type is just the ID of the subsystem that operates upon its data; thus, both terms entry type and subsystem ID are inclusively interchangeable with subsystem type.
  
 
== Subsystem Table ==
 
== Subsystem Table ==
{| border="1" cellspacing="0" cols="3" rules="NONE"
+
Each of the Crash games has a subsystem table. Each entry in the subsystem table contains a 4 character acronym or identifier string, and a number of callback functions specific to the subsystem with that identifier.
| align="LEFT" height="47" width="69"|Subsystem ID/Entry Type
+
 
| align="LEFT" width="67"|Subsystem Acronym
+
=== Location ===
| align="LEFT" width="215"|Proposed Subsystem Name/Entry Content Description
+
The subsystem table is located at the following addresses in each of the Crash games:
 +
* Crash 1 - <code>0x514DC</code>
 +
 
 +
=== Structure ===
 +
The subsystem table has the following structure in each of the Crash games, with the exception that Crash 2 (and 3?) omit the last callback, <code>(*deinit)()</code>:
 +
 
 +
<syntaxhighlight lang="cpp">
 +
struct subsystem
 +
{
 +
  char name[4];
 +
  unsigned long pad;
 +
  void (*init)();
 +
  void (*postinit)();
 +
  void (*onload)(entry*);
 +
  void (*onfree)(entry*);
 +
  void (*deinit)();
 +
} subsystems[NS_COUNT_SUBSYSTEMS];
 +
</syntaxhighlight>
 +
 
 +
==== Subsystem name ====
 +
Each subsystem specifies a 4 character acronym as its name. See below for a list of the subsystem names in each game.
 +
 
 +
==== Callbacks ====
 +
Each entry in the subsystem table may or may not specify the following callbacks:
 +
* <code>init</code> - Called during subsystem initialization to initialize this subsystem
 +
* <code>postinit</code> - Called during subsystem initialization after...
 +
* <code>onload</code> - Called after an entry of this subsystem type is paged into memory
 +
* <code>onfree</code> - Called after an entry of this subsystem type is loaded out of memory
 +
* <code>deinit</code> - Called during subsystem deinitialization (Crash 1 only)
 +
The <code>init</code> and <code>postinit</code> callbacks of each subsystem are called during Paging and Subsystem Initialization; each of these callbacks refers to a routine that initializes its associated subsystem.
 +
...
 +
All together, a subsystem's callbacks simulate 5 polymorphic functions that would otherwise override a subsystem base class's virtual functions of the same name.
 +
 
 +
== Subsystem names ==
 +
 
 +
=== Crash 1 ===
 +
There are a total of 21 subsystems in Crash 1.
 +
 
 +
Note that entries of type 0 do not exist. For this reason, the first subsystem has the name NONE.
 +
{| class="article-table" border="1" cellspacing="0" rules="NONE" cols="3"
 +
! align="LEFT" height="47" width="69" |ID        
 +
! align="LEFT" width="67" |Name
 +
! align="LEFT" width="215" |Proposed Unabbreviated Name/Entry Content Description
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="0"|0
+
| align="RIGHT" height="17" sdnum="1033;" sdval="0" |'''0'''
| align="LEFT"|NONE
+
| align="LEFT" |'''NONE'''
| align="LEFT"|None
+
| align="LEFT" |'''None'''
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="1"|1
+
| align="RIGHT" height="17" sdnum="1033;" sdval="1" |1
| align="LEFT"|SVTX
+
| align="LEFT" |SVTX
| align="LEFT"|Object Model Vertices/Animation
+
| align="LEFT" |Object Model Vertices/Animation
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="2"|2
+
| align="RIGHT" height="17" sdnum="1033;" sdval="2" |2
| align="LEFT"|TGEO
+
| align="LEFT" |TGEO
| align="LEFT"|Object Model Polygons
+
| align="LEFT" |Object Model Polygons
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="3"|3
+
| align="RIGHT" height="17" sdnum="1033;" sdval="3" |3
| align="LEFT"|WGEO
+
| align="LEFT" |WGEO
| align="LEFT"|World Geometry
+
| align="LEFT" |World Geometry
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="4"|4
+
| align="RIGHT" height="17" sdnum="1033;" sdval="4" |4
| align="LEFT"|SLST
+
| align="LEFT" |SLST
| align="LEFT"|Display List
+
| align="LEFT" |Display List
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="5"|5
+
| align="RIGHT" height="17" sdnum="1033;" sdval="5" |5
| align="LEFT"|TPAG
+
| align="LEFT" |TPAG
| align="LEFT"|Texture Page
+
| align="LEFT" |Texture Page
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="6"|6
+
| align="RIGHT" height="17" sdnum="1033;" sdval="6" |6
| align="LEFT"|LDAT
+
| align="LEFT" |LDAT
| align="LEFT"|Level Data
+
| align="LEFT" |Level Data
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="7"|7
+
| align="RIGHT" height="17" sdnum="1033;" sdval="7" |7
| align="LEFT"|ZDAT
+
| align="LEFT" |ZDAT
| align="LEFT"|Zone Data
+
| align="LEFT" |Zone Data
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="8"|8
+
| align="RIGHT" height="17" sdnum="1033;" sdval="8" |'''8'''
| align="LEFT"|CPAT
+
| align="LEFT" |'''CPAT'''
| align="LEFT"|Color Palette
+
| align="LEFT" |'''Color Palette'''
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="9"|9
+
| align="RIGHT" height="17" sdnum="1033;" sdval="9" |'''9'''
| align="LEFT"|BINF
+
| align="LEFT" |'''BINF'''
| align="LEFT"|Binary File
+
| align="LEFT" |'''Binary File'''
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="10"|10
+
| align="RIGHT" height="17" sdnum="1033;" sdval="10" |'''10'''
| align="LEFT"|OPAT
+
| align="LEFT" |'''OPAT'''
| align="LEFT"|Object/Process Allocation Table
+
| align="LEFT" |'''Object/Process Allocation Table'''
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="11"|11
+
| align="RIGHT" height="17" sdnum="1033;" sdval="11" |11
| align="LEFT"|GOOL
+
| align="LEFT" |GOOL
| align="LEFT"|GOOL Executable
+
| align="LEFT" |GOOL Executable
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="12"|12
+
| align="RIGHT" height="17" sdnum="1033;" sdval="12" |12
| align="LEFT"|ADIO
+
| align="LEFT" |ADIO
| align="LEFT"|Audio
+
| align="LEFT" |Audio
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="13"|13
+
| align="RIGHT" height="17" sdnum="1033;" sdval="13" |13
| align="LEFT"|MIDI
+
| align="LEFT" |MIDI
| align="LEFT"|MIDI
+
| align="LEFT" |MIDI
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="14"|14
+
| align="RIGHT" height="17" sdnum="1033;" sdval="14" |14
| align="LEFT"|INST
+
| align="LEFT" |INST
| align="LEFT"|Instruments
+
| align="LEFT" |Instruments
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="15"|15
+
| align="RIGHT" height="17" sdnum="1033;" sdval="15" |15
| align="LEFT"|IMAG
+
| align="LEFT" |IMAG
| align="LEFT"|Image Data
+
| align="LEFT" |Image Data
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="16"|16
+
| align="RIGHT" height="17" sdnum="1033;" sdval="16" |'''16'''
| align="LEFT"|LINK
+
| align="LEFT" |'''LINK'''
| align="LEFT"|Link to another entry?
+
| align="LEFT" |'''Link to another entry?'''
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="17"|17
+
| align="RIGHT" height="17" sdnum="1033;" sdval="17" |17
| align="LEFT"|MDAT
+
| align="LEFT" |MDAT
| align="LEFT"|Map Data
+
| align="LEFT" |Map Data
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="18"|18
+
| align="RIGHT" height="17" sdnum="1033;" sdval="18" |18
| align="LEFT"|IPAL
+
| align="LEFT" |IPAL
| align="LEFT"|Palettes for fading transitions
+
| align="LEFT" |Palettes for fading transitions
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="19"|19
+
| align="RIGHT" height="17" sdnum="1033;" sdval="19" |19
| align="LEFT"|PBAK
+
| align="LEFT" |PBAK
| align="LEFT"|Demo playback
+
| align="LEFT" |Demo playback
 
|-
 
|-
| align="RIGHT" height="17" sdnum="1033;" sdval="20"|20
+
| align="RIGHT" height="17" sdnum="1033;" sdval="20" |20
| align="LEFT"|CVTX
+
| align="LEFT" |CVTX
| align="LEFT"|Cutscene Model Vertices/Animation
+
| align="LEFT" |Cutscene Model Vertices/Animation
 
|}
 
|}

Revision as of 02:29, 27 July 2015

A subsystem is a self-contained system within a larger system. In each of the Crash games, there exist a number of different subsystems. Each subsystem handles a different aspect of the game's function. Many of these subsystems are associated with the type of entry that they primarily operate upon. In fact, an entry's type is just the ID of the subsystem that operates upon its data; thus, both terms entry type and subsystem ID are inclusively interchangeable with subsystem type.

Subsystem Table

Each of the Crash games has a subsystem table. Each entry in the subsystem table contains a 4 character acronym or identifier string, and a number of callback functions specific to the subsystem with that identifier.

Location

The subsystem table is located at the following addresses in each of the Crash games:

  • Crash 1 - 0x514DC

Structure

The subsystem table has the following structure in each of the Crash games, with the exception that Crash 2 (and 3?) omit the last callback, (*deinit)():

struct subsystem
{
  char name[4];
  unsigned long pad;
  void (*init)();
  void (*postinit)();
  void (*onload)(entry*);
  void (*onfree)(entry*);
  void (*deinit)();
} subsystems[NS_COUNT_SUBSYSTEMS];

Subsystem name

Each subsystem specifies a 4 character acronym as its name. See below for a list of the subsystem names in each game.

Callbacks

Each entry in the subsystem table may or may not specify the following callbacks:

  • init - Called during subsystem initialization to initialize this subsystem
  • postinit - Called during subsystem initialization after...
  • onload - Called after an entry of this subsystem type is paged into memory
  • onfree - Called after an entry of this subsystem type is loaded out of memory
  • deinit - Called during subsystem deinitialization (Crash 1 only)

The init and postinit callbacks of each subsystem are called during Paging and Subsystem Initialization; each of these callbacks refers to a routine that initializes its associated subsystem. ... All together, a subsystem's callbacks simulate 5 polymorphic functions that would otherwise override a subsystem base class's virtual functions of the same name.

Subsystem names

Crash 1

There are a total of 21 subsystems in Crash 1.

Note that entries of type 0 do not exist. For this reason, the first subsystem has the name NONE.

ID Name Proposed Unabbreviated Name/Entry Content Description
0 NONE None
1 SVTX Object Model Vertices/Animation
2 TGEO Object Model Polygons
3 WGEO World Geometry
4 SLST Display List
5 TPAG Texture Page
6 LDAT Level Data
7 ZDAT Zone Data
8 CPAT Color Palette
9 BINF Binary File
10 OPAT Object/Process Allocation Table
11 GOOL GOOL Executable
12 ADIO Audio
13 MIDI MIDI
14 INST Instruments
15 IMAG Image Data
16 LINK Link to another entry?
17 MDAT Map Data
18 IPAL Palettes for fading transitions
19 PBAK Demo playback
20 CVTX Cutscene Model Vertices/Animation