fengb / fundude

Gameboy emulator: Zig -> wasm
https://fengb.github.io/fundude/
MIT License
181 stars 8 forks source link

Explore page based MMU #56

Open fengb opened 4 years ago

fengb commented 4 years ago

We are currently representing memory as fully linear, which makes it fast for reading. However, setRom is a non-negligible amount of logic.

What if we had distinct pages of memory instead?

mem: [8]*[1000]u8,

In this scheme, setRom can be a simple pointer swap and we can still get away with fast lookup. The biggest challenge would be exposing this to the memory debugger.

fengb commented 4 years ago

Coarse memory map (block size = 0x1000):

Start Name
0x0000 ROM Bank 0
0x1000 ROM Bank 0
0x2000 ROM Bank 0
0x3000 ROM Bank 0
0x4000 ROM Bank [N]
0x5000 ROM Bank [N]
0x6000 ROM Bank [N]
0x7000 ROM Bank [N]
0x8000 VRAM
0x9000 VRAM
0xA000 External RAM Bank [N]
0xB000 External RAM Bank [N]
0xC000 Work RAM
0xD000 Work RAM (Bank [N] CGB)
0xE000 Echo RAM / OAM
0xF000 IO

Disadvantages:

fengb commented 2 years ago

Block size = 256:

Another consideration — storing block number instead of pointers: