LLBoy icon indicating copy to clipboard operation
LLBoy copied to clipboard

Consider using dispatch tables for memory reading and writing

Open ghost opened this issue 13 years ago • 6 comments

Essentially you can make a table that holds pointers to handling sub-routines for addresses being requested. The GameBoy/GameBoy Color memory map is only 16-bit (albeit with ROM and RAM banking), so it can easily be mapped. This is faster than if/else'ing like a mad-man for address decoding.

ghost avatar Dec 30 '11 21:12 ghost

Looks like a good idea. I'll give it a try further down the line.

NTmatter avatar Dec 30 '11 22:12 NTmatter

Also the games can execute instructions from the their RAM, and often do for waiting out OAM DMA, so make sure you can successfully cover invalidation of the code cache.

ghost avatar Dec 31 '11 18:12 ghost

That's a definite chunk of complexity right there. Odds are that I'll just avoid caching any executable instructions in RAM. The real focus of this project is fiddling around with LLVM to produce a mostly native binary of the ROM. It might be worth using the JIT to handle "live" code, though :)

NTmatter avatar Dec 31 '11 18:12 NTmatter

Yeah, still might be worth it to JIT the busy-wait loops that are often found in RAM in many games.

ghost avatar Dec 31 '11 19:12 ghost

It'll be interesting to do some profiling on the effects of JIT with cache invalidation compared to interpreted execution.

NTmatter avatar Dec 31 '11 19:12 NTmatter

The cases of busy-wait are busy enough to hard-code optimizations upon.

ghost avatar Dec 31 '11 22:12 ghost