CD File Archive Lookup Table

An array at address 800B7E50 contains the look up table for all files in the KKIIDDZZ.DAT and KKIIDDZZ.BNS file archives as well 20 of the .STR files in the CD. The look up table is built using KKIIDDZZ.HED in cdlib_init_lookup_tables. Each entry in this table encodes the location of a file in absolute LBA encoded by the lower 20 bits while the upper 12 bits encode the file size in sector count. While the array is large enough for 448 entries, there are 400 unique entries in the North American release.

CD XA Stream Table

A lookup table at address 800A8530 used for audio streams. A .STR file has multiple streams which are interleaved on the CD. This look up table is used to find a specific stream and consists of a struct I call CdXaStream, the shape of the struct is given below and is 12 bytes big:

offsetfieldmeaning
0hfileLBAabsolute LBA of the .STR file
4hextentSectorshow many sectors a stream spans
8hxaFileIdfile number for CdlSetfilter
9hxaChannelchannel number for CdlSetfilter
Ahstream flagssee below
Bhpadpad
The stream flags is a value that encodes different properties for the stream.
bitmeaning
0drive speed bit. If set the stream should be played at double speed. see cdlib_queue_adpcm_play.
1loop bit. When set cdlib_xa_manager requeues the stream when it ends.
2–3when I tried out fable 5 in July it seems to think its a volume source selector where the flag sets the volume level at the spu level independent of the CD. This will be explored and confirmed when I get to work on the sound engine, but plausible as the function called with the param based on these values seems to call an audio function.

I have not parsed the table to determine the exact size of the table and the number of streams but each stream can be listened to through utilities like jpsxdec. The table is already present in the executable however the fileLBA member for each entry is left blank and filled out at runtime by cdlib_state_init. The table contains entries for the following .STR Files: TALK.STR, STEXP.STR, WEBGET.STR, LAB.STR, GOV1.STR, and GOV2.STR. These are probably the six remaining .STR files that are not in the file archive look up table.

The Asset Lookup Tables

The asset lookup tables are used figure out where an asset file lives on the CD. This is accomplished through the two look up tables below. The entries contain metadata about how to find a file and what properties they have so the engine knows what to do with them.

Asset Table

An array of game asset entries that starts at address 800A7120. The array has 530 entries and seems to be divided into groups. Each group is separated by an entry where the type member has a value of -1. More details of what a group is can be found in architecture section of the asset loading system. A GameAssetEntry struct is a struct with the following shape and is 8 bytes in size:

offsetfieldmeaning
0hcdFileTableIndexindex to the file archive table of where to find the asset file on the CD
2htypethe type of asset file, audio related, textures or other are the currently known types. These are 2,3,4 for audio, 1 for textures and 0 for everything else
4hloadAddressthe address of where to load the file into ram, a void pointer

Asset Pointer Table

An array of structs where each struct holds a pointer to the start of a group in the game asset table. I call the struct GameAssetGroupEntry and it has the following shape and has a size of 8 bytes:

offsetfieldmeaning
0hGameAssetEntrya pointer to a GameAssetEntry in the Asset Table, always the first entry in a group.
4haValue1Unknown
6haValue2Unknown