I’ve been doing more digging on functions that make calls to the CD system and decided to explore the two functions that were remaining in main as they reference memory used by CD API functions. I named these two functions game_setup_asset_load and game_asset_load for now. Below are my preliminary findings.
To begin, in memory we have two tables which I called the game asset table and the game asset group pointer table. It seems that the game asset table is divided into irregular groups, each separated by an entry that has -1 as the value for the type field. The entries in the game asset table also contain an index into the CD file table and the load address of where to load the file into memory as members. The game asset group pointer table contains structs whose members point to the first entry in a group as well as an unknown value. So far I have only been able to confirm that the assets in the game asset able are sound samples or TIMs. I do not know if models, animations, and other assets are referenced in this table, if they are it doesnt look like we do any processing and leave them where loaded for right now.
Now depending on the parameters passed to game_setup_asset_load by the caller, the function uses either the game asset table if the first parameter, which I call source select, is 0 or the pointer table instead for anything else. I think source select 0 is used when we need to start from an arbitrary point in the game asset table or maybe if we dont have an entry of where to start in the group pointer table? Now for source select 1, the index passed is used to select the right group of assets to load as it indexes the asset group pointer table instead.
Regardless of which source is used, game_setup_asset_load assigns some global variables to keep track from where the last asset was loaded. These vars are typically used by the asset loader to process the last loaded asset (E.g load into vram or spu ram) and continue loading assets from the group. In both the functions the members of a game asset entry are used to call cdlib_queue_file_load to load an asset file to memory.
To summarize, game_setup_asset_load does the necessary setup to continue loading assets later as well as queues the first asset load while game_asset_load processes the last asset load, as well as queuing the next one.
I also dumped the header file in ram and wrote a script to parse it and give me a csv of each index, the location of the file it represents in LBA, and the size of the file in sectors. Then I wrote another script to take an entire dump of the CD and parse it to extract each and every file pointed to by the archive then name the file according to the index that its pointed to so I can quickly reference any file from the pcsx-redux disc activity log or the asset table when I start tracing what each file is.