Found at 800112E4
Summary
Prepares and submits a cd file load request. Uses the caller passed file lookup table index to find the file location on the cd and size of the file, takes a load address to determine where in RAM the file should be placed. It then issues the commands necessary to load the file.
Behavior
Checks the cdIoState to see if we are errored or streaming. If we are abort the stream or recovery then flush the command buffer by executing all pending commands. Proceed by getting the file cd position and size using the index passed by the caller. After getting those values put them in the CdArgs union with the load address which for this operation will take the shape of a CdLdFile struct.
Enqueue cd commands that will load the file. The commands do as follows:
- Set the bit for double speed all other bits to 0
- Set the seek target position (set loc)
- Execute a nop (probably to wait?)
- Read the file from the Cd
Return
Notes
- The file size is in sector count hence why we bit shift by 11 to the right (divide by 2048).
- The first command we enqueue always uses the defaultCdSetMode which is 10000000b
Unknowns
cdlib_abort_stream_or_recovery does the same check for the IO state and calls cdlib_flush_cmds, so I’m wondering why we flush commands here as well. Maybe to make sure it was indeed flushed?
Function Signature
Parameters: 2
index: The index of the cd file table as an integer loadAddress: The address where we want to load the file into RAM
Returns
Always 0