I’ve been going through the cd functions to write the proper documentation for them. With the biggest being cd_process_state. Based on some print strings I feel like this was actually called the cd_manager so I renamed it to that. This one was a super busy one to go through and took me about half a day to properly parse through the control flow and behavior in a way that made sense. Originally it had taken me quite a bit of dynamic analysis to figure out so im not surprised.
The ghidra decomp for this was kind of messy due to all the branching so this is one of the few functions where for my notes I completely ignored the decomp and based them purely off the assembly. Its actually a pretty straight forward function, either we take an action based on the IO state or we change the IO state of the CD based on its status in order to handle that new state in a following call. Typically this function is called inside a loop in a way that I like to describe as a pump that will repeatedly call this function until the CD has nothing to do.
No mysteries are left for this function. I should also have most of the pieces to begin writing about the CD architecture. However more function level documentation still needs to be done. The only architectural piece left to analyze for what I believe is the CD system API is cd_xa_manage. All other cd functions are higher level used by the game state itself to request data, stream audio/video etc but those are close to done as well. I believe doing the two remaining functions in main will help as i see overlapping memory address ranges with those other functions.
Why am I spending so much time in documentation? I realized after taking a long hiatus how important it is. While I still remember a lot of the high level stuff, I struggled with the lower level details. My goal for the documentation is that if I decide to take another break I can jump right back to where I left.