Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore page based MMU #56

Open
fengb opened this issue May 29, 2020 · 2 comments
Open

Explore page based MMU #56

fengb opened this issue May 29, 2020 · 2 comments

Comments

@fengb
Copy link
Owner

fengb commented May 29, 2020

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
Copy link
Owner Author

fengb commented Jun 15, 2020

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:

  • OAM is awkwardly stuck next to echo RAM
    1. Manual mirror means we can't take advantage of banking
    2. Automatic mirror means we have a bizarre escape for OAM
  • Bootloader hangs out separately

@fengb
Copy link
Owner Author

fengb commented Nov 6, 2021

Block size = 256:

  • + OAM can be split from Echo
  • + Bootloader can be separate
  • - A lot more updates per bank switch (32 - 64 updates)

Another consideration — storing block number instead of pointers:

  • + smaller memory usage
  • + easier serialization
  • ? how to differentiate between cart and dynamic:
    1. Separate enum(u8) { bootloader, cart, dynamic }
    2. Implicit by largest bit (0 = cart, 1 = dynamic). This takes no additional storage space, but bootloader becomes a manual problem again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant