Login
Search for:


Previous | Next

From: Ettore Perazzoli
Date: 1998-09-16
Subject: Re: Snapshot files for emulators
Hi!

Marko> Also, you could have some conversation and cooperation with
Marko> the VICE development team. The same basic format could be
Marko> used for storing the state of all emulators, and also the
Marko> states of attached devices (e.g. drive states).

We are developing a snapshot format for the various VICE emulators right now. We have not decided all the details yet, but it would be nice if we could agree on the basic structure at least.

On the top of the file, we have the main header which looks like this:

Offset Size Description
----------------------------------------------------------
0 19 "VICE Snapshot File"
19 1 Major version number
20 1 Minor version number
21 16 Machine ID

After the main header, we have a sequence of "modules"; every module contains the snapshot information of a certain section of the emulator, e.g. the VIC-II, the CIA, the CPU and so on.

Every module has a 16-byte long signature which is unique to that type of module (e.g. `MAINCPU', `1541CPU', `CIA1', `CIA2' etc.); for now,
order does matter (so the signature is just used as a safety check),
but we might as well make it independent of ordering if necessary.
Moreover, we also put a version number and a size field. The size field is useful as a safety check, and in case some new information is added at the end of the module without breaking older versions; for example, if version 1.3 introduces a new field, older emulators implementing version 1.2 can just ignore it while still being able to read the snapshot, using the size field.

Basically, a module looks like this:

Offset Size Description
----------------------------------------------------
0 16 Signature
16 1 Major version number
17 1 Minor version number
18 4 Module size
22 (any) Module data

The data depends on what the module decides to put in it. I have no idea about what is needed on the Plus/4 or the C16, so I won't discuss this. Instead, I'll illustrate the main CPU module as an example as it is the one that might be re-used by the Plus/4 and C16 emulators.
(This is not our "official" decision, though the current code works like this.)

Offset Size Description
-----------------------------------------------------------
0 16 Signature (`MAINCPU'), padded with zeroes
16 1 Major version number
17 1 Minor version number
18 4 Module size
22 4 Current clock counter
26 1 A
27 1 X
28 1 Y
29 1 SP
30 1 PC
31 1 P (status flags)
32 4 info about the last opcode
33 1 IRQ status
34 1 NMI status
35 4 clk for the last IRQ
36 4 clk for the last NMI
37 4 number of BA cycles of the last fetch
38 4 starting BA cycle for the last fetch

`clk' is just a counter that is incremented at every clock cycle. The
"information about the last opcode" is a 32-bit integer which currently only contains the opcode number and a bit flag that specifies whether it delayed IRQs or NMIs by one cycle. The other non-trivial information is necessary to emulate the CPU timing correctly (how does the BA line behave on the Plus/4?).

Well, this is a rough and preliminary explanation, but I it might be a good starting point for discussion. What do you think?

--
Ettore

Copyright © Plus/4 World Team, 2001-2024