Subsystem

From Crash Bandicoot Hacking Wiki
Revision as of 03:12, 30 July 2015 by Wikia>Thaswordster (Subsystem names: Not always limited to just MIDI.)
Jump to navigation Jump to search

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.

Bolded entries in the table indicate that (while the subsystem exists) there do not exist entries of that subsystem type in any NSF file.

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 Music
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