Just how common is it... (coding question)
Posted: Wed Sep 18, 2013 2:43 am
Just how common is it for an MD game to do all of its processing in the vblank interrupt?
I am disassembling the Japanese version of Rocket Knight Adventures and (thanks to IDA and Exodus's active disassembly feature! Thanks Nemesis!) made good progress at separating code from data with the exception of a few jump tables and pre-calculated address register jumps that I'm working backwards to solve. That's neither here nor there, however.
You guys may well know some of this already but here's what I've picked apart that struck me as a little strange:
The main code path ends with:
0003C6 bra $3c6
It just spins here, all the game code is called from the vblank interrupt. Doesn't this have a HUGE execution time cost in terms of wasted cycles? Isn't there more available time outside of vblank?
The H-interrupt vector is a pointer into RAM, I'm guessing so it can quickly switch pointers for horizontal interrupt routines, the game does a lot of linescroll FX & mid frame palette stuff as you probably know. What is weird to me is so far I can't see any pointers at that RAM location (in Regen).
The entire code path is apparently based on a huge jump table with smaller tables sprouting from that. It looks well engineered from that perspective, I get the feeling they actually engineered the code flow rather than just sitting down and banging out a game. Konami seems pretty professional.
The game loads small bits of code into RAM and jumps to them. Most of the time from what I'm able to observe it just loads the RTS opcode in there and comes right back out of the code in RAM. The game appears to have reserved a small RAM bank just for code but don't quote me on that yet. Is there any real benefit to this? I know in theory you could self modify code but that seems kind of both difficult and not really necessary on the 68k.
To me (and I'm not as experienced in 68k as many of you guys I'm sure) a lot of the attempts at streamlining and optimization seem silly when they are intentionally avoiding doing any processing outside vblank. What do you guys think?
I am disassembling the Japanese version of Rocket Knight Adventures and (thanks to IDA and Exodus's active disassembly feature! Thanks Nemesis!) made good progress at separating code from data with the exception of a few jump tables and pre-calculated address register jumps that I'm working backwards to solve. That's neither here nor there, however.
You guys may well know some of this already but here's what I've picked apart that struck me as a little strange:
The main code path ends with:
0003C6 bra $3c6
It just spins here, all the game code is called from the vblank interrupt. Doesn't this have a HUGE execution time cost in terms of wasted cycles? Isn't there more available time outside of vblank?
The H-interrupt vector is a pointer into RAM, I'm guessing so it can quickly switch pointers for horizontal interrupt routines, the game does a lot of linescroll FX & mid frame palette stuff as you probably know. What is weird to me is so far I can't see any pointers at that RAM location (in Regen).
The entire code path is apparently based on a huge jump table with smaller tables sprouting from that. It looks well engineered from that perspective, I get the feeling they actually engineered the code flow rather than just sitting down and banging out a game. Konami seems pretty professional.
The game loads small bits of code into RAM and jumps to them. Most of the time from what I'm able to observe it just loads the RTS opcode in there and comes right back out of the code in RAM. The game appears to have reserved a small RAM bank just for code but don't quote me on that yet. Is there any real benefit to this? I know in theory you could self modify code but that seems kind of both difficult and not really necessary on the 68k.
To me (and I'm not as experienced in 68k as many of you guys I'm sure) a lot of the attempts at streamlining and optimization seem silly when they are intentionally avoiding doing any processing outside vblank. What do you guys think?