When it comes to understanding the code, we could just run the ROM files which contain code through a disassembler and try to read it, but it's easier if we can follow the code while it is executing instead of just reading it. That's one thing debuggers can do. Luckily MAME already has a built-in debugger that can do that. You just need to invoke it with the -debug command line option, so mame.exe shinobi -debug At the command line is enough. It will open the game and a debugger window, like this: In the debug window you can see the register values on the left, a disassemble of the code at the center top panel, and the command window on the bottom right corner. The debugger includes the usual functions like execute the code instruction by instruction, set breakpoints, examine memory locations, and so on. Though it's hard to analyze the code just by watching it execute on a debugger. Typically there are thousands of instructions executed for each frame , so ...
To get an idea of the complexity of code executing during one frame of the game, we can calculate an estimate of how many instructions are executed for each frame. The main CPU is the Motorola 68000 running at a 10MHz clock. 10MHz means each clock cycle takes 100 ns or 0.1μs. The game runs at 60Hz or 60 frames per second so each frame takes 16.6667ms. So in each frame there are 166,667 cycles. The M68k is a CISC processor and its simplest instructions take 4 cycles, but there are instructions that take more. An upper bound to the number of instructions executed per frame is thus 166,667 / 4 = 41,666.75 or just about 42 thousand instructions per frame. The real number varies per frame depending on the mix of instructions that are executed on it, and it probably never reaches this value of 42k instructions per frame because you don't expect to execute only instructions of 4 cycles, but something in the order of tens of thousands of instructions per frame seems right....
Comments
Post a Comment