|
> MAME's code actually does something extremely smart for a processor as complex > as the 68000: it's a generator. Meaning you write a program that outputs the > actual emulator source in your desired language. That means you can generate > the emulator in various configurations without ugly #ifdefs or the like, and it > also reduces the chance of things like copy/paste typos. >
Yes, that is smart :-) I think STonX does something like that too. What I'm trying to do is using OOP to create objects that will execute the instructions (from classes implementing an 'Instruction' interface, which is basically nothing more that 'void exec()'). The constructor of the Instruction classes will define how they will actually behave at runtime, ie it will set the size of a move, the istruction mode, the affected registers etc. In the end, the created objects will have no or almost no branches in their 'exec()' method. Then I create an array (of I think 1024) of all instruction objects at initialization, and do something like the following at runtime:
while (cyclesLeft > 0) { int iw = fetchInstructionWord(); Instruction i = instructionArray[iw]; i.exec(); // do the rest here... }
I think (hope) it's going to work out.
|