Oh! to be honest I saw that article and also in every doc i´ve consulted they´ve splited the memory as a real gameboy hardware does it, but for the life of me I can´t figure how to manage the memory while decoding an opcode. I´ve been toying around with the idea of having a huge 64K array and assigning memory locations using if greater than, smaller than statements, but it feels like cheating... I guess i could rework my instructions template functions to include memory assignments on read and write
You won't get around some 'cheating' because not all locations in the address space behave the same. The MBCs for example are controlled by writing to addresses in the low 32K so you have to catch them and perform some actions instead of overwriting some of the ROM. Similarly, the region from 0xFF00 to 0xFF7F contains special hardware registers and for some of them you will want to trigger actions on access.
For example, writing to 0xFF46 will start a DMA transfer or 0xFF4D is used to switch between normal and double speed mode on the GBC.
I would suggest to put read/write in their own functions and do the special handling there, be it a cascade of if-statements or storing memory pointers and callback functions in a lookup table or whatever.
Last edited: