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

Save/load state #41

Open
fengb opened this issue Apr 27, 2020 · 3 comments
Open

Save/load state #41

fengb opened this issue Apr 27, 2020 · 3 comments
Labels
enhancement New feature or request savestate

Comments

@fengb
Copy link
Owner

fengb commented Apr 27, 2020

Every other emulator does this. Why can't we?

Questions:

  • Which format? This should probably be a compressed binary, but there's still a lot to choose from:

    cpu: [mode, interrupt_master, registers]
    mmu: [0x8000-0xffff, mbc state]
    video: [screen, caches?]
    inputs: *
    timer: *
    • manual
    • json probably not due to needing binary data
    • protobuf
    • cap'n'proto
  • What memory needs to be copied? At the minimum registers, MMU, and possibly the screen, but we might need a bunch of other internal states. Should we simply copy everything?

  • Should we consider rewind semantics?

@fengb fengb mentioned this issue Apr 27, 2020
@fengb fengb added the enhancement New feature or request label May 14, 2020
@fengb
Copy link
Owner Author

fengb commented Jun 2, 2020

Format ideas:

  1. Custom binary dump. Let's do a simple "size: u16 - payload: []u8 — size: u16 - payload: []u8" for now. This is intentionally not standardized because Zig doesn't have a prebuilt one and I don't want to build one (yet)
  2. Header magic number:
    • 0xDC — busts ascii (high bit) + unicode (0xDC00 - 0xDC7F is illegal as first char for both UTF8 and UTF16)
    • 0x00 — version (increment this when the format changes)
    • 0x46F
    • 0x44D
    • the following are shamelessly stolen from PNG
    • 0x0D — CR
    • 0x0A — LF (DOS line)
    • 0x1A — DOS EOF
    • 0x0A — LF (Unix line)
  3. Cart checksum — copy of cartridge cart[0x134..][0..0x18] (24 bytes)
  4. Footer trailing checksum decided this is out of scope:
    • we have some simple redundancies already
    • adds a fair bit of complexity
    • compression will have its own (possibly better) checksum

@fengb
Copy link
Owner Author

fengb commented Jun 2, 2020

Note: first pass will not do compression because Zig doesn't have a standard implementation yet.

@fengb fengb added the savestate label Jun 2, 2020
@fengb
Copy link
Owner Author

fengb commented Jun 24, 2020

Implemented via 053e8dc

Still iterating super quickly so maybe we shouldn't expose this to the frontend yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request savestate
Projects
None yet
Development

No branches or pull requests

1 participant