Hi, my emulator is currently only supporting mapper 0, so the PRG-ROM is just a 32 kB chunk that gets loaded at ROM load and that's it.
So mappers that switch entire 32 kB PRG banks are trivial, but for mapper 2-UNROM, for example, that uses one switchable 16 kB bank and another one fixed, I've thought of these options:
1) Just switch the switchable bank, using a pointer to the selected bank, in which case I have to modify my CPU code because if the PC crosses the bank boundary, I'll have to point to a different chunk in memory, cause they won't be next to each other.
2) I could instead of switching pointers just copy over the whole switchable bank on each bank switch so both banks are always next to each other in memory and PC movement is transparent. It looks unefficient, but moving 16 kB in a modern computer should be near cost zero.
3) I also could create whole 32 kB chunks in memory, one for each switchable 16 kB bank, all with copies of the fixed 16 kB bank so I could just switch between them transparently.
Any ideas? a better solution?
My emulator is made in C.
So mappers that switch entire 32 kB PRG banks are trivial, but for mapper 2-UNROM, for example, that uses one switchable 16 kB bank and another one fixed, I've thought of these options:
1) Just switch the switchable bank, using a pointer to the selected bank, in which case I have to modify my CPU code because if the PC crosses the bank boundary, I'll have to point to a different chunk in memory, cause they won't be next to each other.
2) I could instead of switching pointers just copy over the whole switchable bank on each bank switch so both banks are always next to each other in memory and PC movement is transparent. It looks unefficient, but moving 16 kB in a modern computer should be near cost zero.
3) I also could create whole 32 kB chunks in memory, one for each switchable 16 kB bank, all with copies of the fixed 16 kB bank so I could just switch between them transparently.
Any ideas? a better solution?
My emulator is made in C.