*** VSF (Vice Snapshot File, saved-session file)
*** Document revision: 1.1
*** Last updated: March 11, 2004
*** Contributors/sources: VICE documentation

  These files are the saved-session files, similar to  C64s  FRZ  and  PC64
saved-session files, which contains the entire state of the CPU,  RAM,  ROM
and I/O of the current emulator session.  The  typical  file  extension  is
".VSF"

  The internal structure of a VICE snapshot is a signature, followed  by  a
series of modules, where the module types are determined by the  CPU  which
VICE is emulating. That is, if you are running the  VICE  VIC-20  emulator,
the modules will not all be the same as the C64 emulator.

  The modules contain individual chip or device states,  not  the  complete
state  of  the  emulator.  The  snapshot  format  was  designed  to  be  as
implementation-independent as possible, to  allow  reuse  of  snapshots  in
later versions of the VICE emulator, or even in other emulators. 

  The VICE signature is the simple text string...

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 56 49 43 45 20 53 6E 61 70 73 68 6F 74 20 46 69   VICE?Snapshot?Fi
0010: 6C 65 1A 00 00 43 31 32 38 00 00 00 00 00 00 00   le???C128???????
0020: 00 00 00 00 00 .. .. .. .. .. .. .. .. .. .. ..   ?????...........

      Bytes: $00-12 - VICE signature "VICE Snapshot File" in ASCII followed
                      by a $1A (and padded with $00 if necessary)
              13-14 - Snapshot version $00/$00 (major/minor)
              15-24 - Name of emulated machine in ASCII (padded with  $00).
                      The current machines emulated are  (not  stored  with
                      quotes):
                        "PET"
                        "CBM-II"
                        "VIC20"
                        "C64"
                        "C128"


  From now on, the snapshot file contains MODULES,  with  the  module  name
stored in ASCII. As stated earlier, each  emulated  machine  type  contains
certain modules. Note that each HEX dump which follows will be starting  as
though it is at offset $0000, which means  that  each  one  is  treated  as
though it was its own file. This makes it easier to break down the module.

  The list below shows what modules belong to what machines:

    C64 - MAINCPU, C64MEM, C64ROM, VIC-II, CIA1, CIA2, SID, REU, ACIA1, TPI

   C128 - MAINCPU, C128MEM, C128ROM, VIC-II, CIA1, CIA2, SID, ACIA1, TPI
          (Not yet supported are the 80 column video chip,  cartridges  and
           RAM expansion unit.)

  VIC20 - MAINCPU, VIC20MEM, VIC20ROM, VIC-I, VIA1, VIA2

    PET - MAINCPU, PETMEM, PETROM, CRTC, PIA1, PIA2, VIA, ACIA1

 CBM-II - MAINCPU, CBM2MEM, CBM2ROM, CRTC, VIC-II, CIA1, TPI1, TPI2, ACIA1,
          SID


  There were certain  modules  which  were  either  under  construction  or
included no description at all at the time of writing this document.  These
include:

  MAINCPU (under construction)
  DRIVE module layout (no description)
  RIOT module (no description)
  SID, VIC-I & VIC-II modules (no breakdown)
  REU module(s) (no breakdown)


---------------------------------------------------------------------------


The MAINCPU Module:

Chip type: 6502 (6509 for CBM-II) (still under construction)

  Although usually the CPU is a 6510 (6509 on CBM-II, 6502 on VIC-20), only
the 6502 core is saved here. You will also find a  clock  value  here.  All
other modules save their own clock values relative to this value. The drive
modules save their clocks relative to their appropriate CPUs.

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 4D 41 49 4E 43 50 55 00 00 00 00 00 00 00 00 00   MAINCPU?????????
0010: 01 00 35 00 00 00 F8 0E AA 00 00 00 00 F3 5E C2   ??5???°???????^+
0020: 22 F0 01 00 00 F1 00 AA 00 32 15 09 00 2B 00 00   "????????2???+??
0030: 00 33 FE A9 00 .. .. .. .. .. .. .. .. .. .. ..   ?3???...........

      Bytes: $0000-000F - Module type ("MAINCPU"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-0019 - CPU clock value (lo/hi)
                   001A - A register (accumulator)
                   001B - X register
                   001C - Y register
                   001D - Stack pointer
              001E-001F - Program counter
                   0020 - Status register
              0021-0024 - Last opcode
              0025-0028 - Clock value when IRQ line active
              0029-002C - Clock value when NMI line active
              002D-0030 - ???
              0031-0034 - ???


---------------------------------------------------------------------------


The C64MEM Module:

Chip type: Memory - Holds the RAM contents of the C64.  Also  the  CPU  I/O
                    register  contents  are  saved  here.  This  module  is
                    mandatory.

  The size of the C64 memory modules differs  with  each  different  memory
configuration. The RAM configuration is saved in the snapshot, and restored
when the snapshot is loaded. The attached cartridges are not yet saved  and
not yet restored upon load. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 43 36 34 4D 45 4D 00 00 00 00 00 00 00 00 00 00   C64MEM??????????
0010: 00 00 1A 00 01 00 37 2F 00 00 2F 37 00 AA B1 91   ??????7/??/7????
0020: B3 22 22 00 00 00 00 FF 00 00 00 00 00 00 00 00   |""?????????????
0030: 19 16 00 0A 76 A3 00 00 00 00 00 00 76 A3 B3 BD   ????v???????v?|?
0040: 00 00 00 00 00 01 08 03 08 03 08 03 08 00 A0 00   ????????????????

      Bytes: $0000-000F - Module type ("C64MEM"), padded with $00
              0010-0011 - Module version $00/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - CPU Port data byte (RAM location $01)
                   0017 - CPU Port direction byte (RAM location $00)
                   0018 - State of the EXROM cartridge line
                   0019 - State of the GAME cartridge line
             001A-10019 - 64K RAM dump


---------------------------------------------------------------------------


The C64ROM Module:

Chip type: ROMs - A dump of the system ROMs (optional)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F         ASCII
      -----------------------------------------------   ----------------
0000: 43 36 34 52 4F 4D 00 00 00 00 00 00 00 00 00 00   C64ROM??????????
0010: 00 00 16 50 00 00 85 56 20 0F BC A5 61 C9 88 90   ???P???V????a???
0020: 03 20 D4 BA 20 CC BC A5 07 18 69 81 F0 F3 38 E9   ???|??????i???8?
0030: 01 48 A2 05 B5 69 B4 61 95 61 94 69 CA 10 F5 A5   ?H??+i+a?a?i????
0040: 56 85 70 20 53 B8 20 B4 BF A9 C4 A0 BF 20 59 E0   V?p?S??++?-?+?Y?
0050: A9 00 85 6F 68 20 B9 BA 60 85 71 84 72 20 CA BB   ???oh??|`?q?r???

      Bytes: $0000-000F - Module type ("C64ROM"), padded with $00
              0010-0011 - Module version $00/00 (major/minor)
              0012-0015 - Module size (lo/hi), not including this header
              0016-2015 - KERNAL ROM dump ($E000-FFFF)
              2016-4015 - BASIC ROM dump ($A000-BFFF)
              4016-5015 - CHARGEN ROM cump ($D000-DFFF)


---------------------------------------------------------------------------


The VIC-II Module:

Chip type: 656x - The contents of the VIC-II (C64, C128, or  C500).  Either
                  the VIC-II or the CRTC exists, not both in one snapshot.

Breakdown not available as this module is still under construction.

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 56 49 43 2D 49 49 00 00 00 00 00 00 00 00 00 00   VIC-II??????????
0010: 01 00 DD 04 00 00 01 00 01 0E 0E 0E 0E 0E 0E 0E   ????????????????
0020: 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E   ????????????????
0030: 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E   ????????????????

      Bytes: $0000-000F - Module type ("VIC-II"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-04DC - VIC-II register contents


---------------------------------------------------------------------------


The CIA1 Module:

Chip type: 6526 (the CIA for the interrupts and the keyboard)

  The CIA 6526 is an I/O  port  chip  with  2  8-bit  I/O  ports,  a  shift
register, two timers, a Time of Day clock and interrupts.

  
      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 43 49 41 31 00 00 00 00 00 00 00 00 00 00 00 00   CIA1????????????
0010: 01 02 41 00 00 00 7F 00 FF 00 09 2C FF FF 00 00   ??A???????,????
0020: 00 01 00 01 01 08 25 40 FF FF 00 40 00 00 00 00   ??????%@???@????
0030: 00 00 02 00 00 00 00 2B 1C 00 00 63 08 28 11 00   ???????+???c?(??
0040: 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..   ?...............

      Bytes: $0000-000F - Module type ("CIA1"), padded with $00
              0010-0011 - Module version $01/02 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - Output register A (ORA)
                   0017 - Output register B (ORB)
                   0018 - Data direction register A (DDRA)
                   0019 - Data direction register B (DDRB)
              001A-001B - Timer A Counter (TAC)
              001C-001D - Timer B Counter (TBC)
                   001E - Time-of-day current 10'th of a second (TOD_TEN)
                   001F - Time-of-day current seconds (TOD_SEC)
                   0020 - Time-of-day current minutes (TOD_MIN)
                   0021 - Time-of-day current hours (TOD_HR)
                   0022 - Shift register contents (SDR)
                   0023 - Mask of enabled interrupts (IER)
                   0024 - Control register A (CRA)
                   0025 - Control register B (CRB)
              0026-0027 - Timer A latch value (TAL)
              0028-0029 - Timer B latch value (TBL)
                   002A - Mask of currently active interrupts (IFR)
                   002B - Bit 6/7 reflect the PB6/7 toggle bit  state.  Bit
                          2/3 reflect  the  corresponding  port  bit  state
                          (PBSTATE)
                   002C - Number of half-bits to still shift in/out of  SDR
                          (SRHBITS)
                   002D - Time-of-day alarm 10'th of a second (ALARM_TEN)
                   002E - Time-of-day alarm seconds (ALARM_SEC)
                   002F - Time-of-day alarm minutes (ALARM_MIN)
                   0030 - Time-of-day alarm hours (ALARM_HR)
                   0031 - Current clock minus the clock when ICR  was  read
                          last plus 128 (READICR)
                   0032 - Bit 0: 1= latched for reading, Bit  1:  2=stopped
                          for writing (TODLATCHED)
                   0033 - Time-of-day latched 10'th of a second (TODL_TEN)
                   0034 - Time-of-day latched seconds (TODL_SEC)
                   0035 - Time-of-day latched minutes (TODL_MIN)
                   0036 - Time-of-day latched hours (TODL_HR)
              0037-003A - Clock  ticks  till  next  10'th  of  a   second
                          (TOD_TICKS)
              003B-003C - The state bits of the CIA timer A  (TASTATE,  new
                          from revision 1.1)
              003D-003E - The state bits of the CIA timer B  (TBSTATE,  new
                          from revision 1.1)

  The last two items have been added in CIA snapshot version 1.1 due to the
improved CIA  emulation  in  the  newer  VICE  versions.  Some  state  bits
correspond to the CIA state as described in the "A Software  Model  of  the
CIA 6526" document by Wolfgang Lorenz, some are delayed versions. For  more
read the source file ciatimer.h. 


---------------------------------------------------------------------------


The CIA2 Module:

Chip type: 6526 (the CIA for the userport, IEC-bus and RS232)

(See the CIA1 module for details)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 43 49 41 32 00 00 00 00 00 00 00 00 00 00 00 00   CIA2????????????
0010: 01 02 41 00 00 00 97 00 3F 00 FF FF FF FF 00 00   ??A?????????????
0020: 00 01 00 00 08 08 FF FF FF FF 00 00 00 00 00 00   ????????????????
0030: 00 00 02 00 00 00 00 2B 1C 00 00 28 11 28 11 00   ???????+???(?(??
0040: 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..   ?...............

      Bytes: $0000-000F - Module type ("CIA2"), padded with $00
              0010-0011 - Module version $01/02 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-xxxx - See the CIA1 breakdown for details


---------------------------------------------------------------------------


The SID Module:

Chip type: 6581 (SID sound chip of the C64/C128)

Breakdown not available yet, as module is still under construction.

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 53 49 44 00 00 00 00 00 00 00 00 00 00 00 00 00   SID?????????????
0010: 01 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00   ??6?????????????
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ????????????????
0030: 00 00 00 00 00 00 .. .. .. .. .. .. .. .. .. ..   ??????..........

      Bytes: $0000-000F - Module type ("SID"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-0035 - SID register contents


---------------------------------------------------------------------------


The REU Module:

Chip type: None - The RAM Extension Unit state (optional)

Breakdown not available yet.

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 52 45 55 31 37 36 34 00 00 00 00 00 00 00 00 00   REU1764?????????
0010: 00 00 2A 00 08 00 00 02 00 00 50 4A 00 00 00 00   ??*???????PJ????
0020: 00 00 00 00 00 00 00 00 00 00 0C 00 76 00 D4 BE   ????????????v???
0030: 81 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ????????????????

      Bytes: $000000-00000F - Module type ("REU1764"), padded with $00
              000010-000011 - Module version $00/00 (major/minor)
              000012-000015 - Module size (lo/hi), including this header
              000016-080029 - REU contents


--------------------------------------------------------------------------


The C128MEM Module:

Chip type: RAM - Holds the RAM contents  of  the  C64.  Also  the  CPU  I/O
                 register  contents  are  saved  here.   This   module   is
                 mandatory.

       00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 43 31 32 38 4D 45 4D 00 00 00 00 00 00 00 00 00   C128MEM?????????
0010: 00 00 21 00 02 00 00 3F 7F 01 41 B7 04 00 00 01   ??!??????A?????
0020: 00 2F C3 00 00 00 00 00 00 00 00 00 00 00 9B 00   ?/+?????????????
0030: 00 00 00 00 00 00 00 FF FF 1B 00 00 00 00 00 00   ????????????????
0040: 00 00 00 00 00 03 02 00 00 00 00 00 00 00 01 1C   ????????????????

      Bytes: $000000-00000F - Module type ("C128MEM"), padded with $00
              000010-000011 - Module version $00/00 (major/minor)
              000012-000015 - Module size (lo/hi), including this header
              000016-000021 - MMU registers (MMU)
              000022-020020 - 128K RAM dump (banks 0 and 1)
  

---------------------------------------------------------------------------


The C128ROM Module:

Chip type: ROMs - Dump of the system ROMs (optional)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 43 31 32 38 52 4F 4D 00 00 00 00 00 00 00 00 00   C128ROM?????????
0010: 00 00 16 C0 00 00 A2 FF 78 9A D8 A9 00 8D 00 FF   ???+????x???????
0020: A2 0A BD 4B E0 9D 00 D5 CA 10 F7 8D 04 0A 20 CD   ???K???????????-
0030: E0 20 F0 E1 20 42 E2 20 09 E1 20 3D F6 48 30 07   ?????B?????=?H0?
0040: A9 A5 CD 02 0A F0 03 20 93 E0 20 56 E0 20 00 C0   ??-????????V???+

      Bytes: $000000-00000F - Module type ("C128ROM"), padded with $00
              000010-000011 - Module version $00/00 (major/minor)
              000012-000015 - Module size (lo/hi), including this header
              000016-002015 - KERNAL ROM dump
              002016-00A015 - BASIC ROM dump
              00A016-00B015 - EDITOR ROM dump
              00B016-00C016 - CHARGEN ROM dump


---------------------------------------------------------------------------


The VIC20MEM Module:

Chip type: RAM - Holds the RAM  contents  of  the  VIC20.  This  module  is
                 mandatory.

  The size of the VIC20 memory modules differs with each  different  memory
configuration. The RAM configuration is saved in the snapshot, and restored
when the snapshot is loaded. The attached cartridges are also restored upon
load if they have been saved in the snapshot. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 56 49 43 32 30 4D 45 4D 00 00 00 00 00 00 00 00   VIC20MEM????????
0010: 01 00 17 A8 00 00 2F 4C 48 D2 AA D1 91 D3 22 22   ??????/LH?????""
0020: 00 00 00 00 FF 00 00 00 00 00 00 00 00 19 16 00   ????????????????
0030: 0A 76 C3 00 00 00 00 00 00 76 C3 B3 DD 00 00 00   ?v+??????v+|????
0040: 00 00 01 12 03 12 03 12 03 12 00 80 00 00 00 80   ????????????????

      Bytes: $0000-000F - Module type ("VIC20MEM"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - Configuration register: (CONFIG)
                            Bit 0 set: 3K RAM block present at $0400-0FFF
                            Bit 1 set: 8K RAM block present at $2000-3FFF
                            Bit 2 set: 8K RAM block present at $4000-5FFF
                            Bit 3 set: 8K RAM block present at $6000-7FFF
                            Bit 5 set: 8K RAM block present at $A000-BFFF
              0017-0416 - 1K RAM dump ($0000-03FF)
              0417-1416 - 4K RAM dump ($1000-1FFF)
              1417-1B16 - 2K Color RAM ($9400-9BFF)
              1B17-2816 - 3K RAM dump ($0400-0FFF, if CONFIG bit 0 set)
              2817-4816 - 8K RAM dump ($2000-3FFF, if CONFIG bit 1 set)
              4817-6816 - 8K RAM dump ($4000-5FFF, if CONFIG bit 2 set)
              6817-8816 - 8K RAM dump ($6000-7FFF, if CONFIG bit 3 set)
              8817-A816 - 8K RAM dump ($A000-BFFF, if CONFIG bit 5 set)


---------------------------------------------------------------------------


The VIC20ROM Module:

Chip type: ROMs - Holds the ROM of the VIC20, including  possibly  attached
                  cartridges (optional)

  The size of the VIC20 memory modules differs with each  different  memory
configuration. The RAM configuration is saved in the snapshot, and restored
when the snapshot is loaded. The attached cartridges are also restored upon
load if they have been saved in the snapshot. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 56 49 43 32 30 52 4F 4D 00 00 00 00 00 00 00 00   VIC20ROM????????
0010: 01 00 17 50 00 00 00 0F DC A5 61 C9 88 90 03 20   ???P??????a?????
0020: D4 DA 20 CC DC A5 07 18 69 81 F0 F3 38 E9 01 48   ?+??????i???8??H
0030: A2 05 B5 69 B4 61 95 61 94 69 CA 10 F5 A5 56 85   ??+i+a?a?i????V?
0040: 70 20 53 D8 20 B4 DF A9 C4 A0 DF 20 56 E0 A9 00   p?S??+??-???V???
0050: 85 6F 68 20 B9 DA 60 85 71 84 72 20 CA DB A9 57   ?oh??+`?q?r????W

      Bytes: $0000-000F - Module type ("VIC20ROM"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - ROM configuration byte (CONFIG)
                            Bit 0: 1= ROM block $2xxx enabled.
                            Bit 1: 1= ROM block $3xxx enabled. 
                            Bit 4: 1= ROM block $6xxx enabled.
                            Bit 5: 1= ROM block $7xxx enabled.
                            Bit 6: 1= ROM block $Axxx enabled.
                            Bit 7: 1= ROM block $Bxxx enabled.
              0017-2016 - 8K KERNAL ROM dump ($E000-FFFF)
              2017-4016 - 8K BASIC ROM dump ($C000-DFFF)
              4017-5016 - 4K Character ROM dump
              5017-6016 - 4K ROM image of $2xxx (if CONFIG Bit 0 set)
              6017-7016 - 4K ROM image of $3xxx (if CONFIG Bit 1 set)
              7017-8016 - 4K ROM image of $6xxx (if CONFIG Bit 4 set)
              8017-9016 - 4K ROM image of $7xxx (if CONFIG Bit 5 set)
              9017-A016 - 4K ROM image of $Axxx (if CONFIG Bit 6 set)
              A017-B016 - 4K ROM image of $Bxxx (if CONFIG Bit 7 set)


---------------------------------------------------------------------------


The VIC-I Module:

Chip type: 656x - The VIC-I of the VIC20

(Breakdown not available as this module is still under contruction.)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 56 49 43 2D 49 00 00 00 00 00 00 00 00 00 00 00   VIC-I???????????
0010: 00 00 2B 08 00 00 01 00 00 00 00 06 06 06 06 06   ??+?????????????
0020: 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06   ????????????????
0030: 06 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ????????????????
0040: 01 01 01 01 01 01 01 06 06 06 06 06 06 06 06 06   ????????????????

      Bytes: $0000-000F - Module type ("VIC-I"), padded with $00
              0010-0011 - Module version $00/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-xxxx - VIC-I register contents


---------------------------------------------------------------------------


The VIA1 Module:

Chip type: 6522 (the VIA for the interrupts and the keyboard)

  The VIA 6522 is the predecessor of the CIA and also an I/O port chip with
2 8-bit I/O ports, a shift register, two timers and interrupts.

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 56 49 41 31 00 00 00 00 00 00 00 00 00 00 00 00   VIA1????????????
0010: 01 00 2C 00 00 00 00 00 F7 FF 26 48 05 2C FF AB   ??,???????&H?,??
0020: F9 80 00 40 DE 00 40 00 00 80 FF 00 .. .. .. ..   ???@??@?????....

      Bytes: $0000-000F - Module type ("VIA1"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - Output register A (ORA)
                   0017 - Data direction register A (DDRA)
                   0018 - Output register B (ORB)
                   0019 - Data direction register B (DDRB)
              001A-001B - Timer 1 Latch value (T1L)
              001C-001D - Timer 1 counter value (T1C)
                   001E - Timer 2 latch (T2L)
                          (8 bit as only lower byte is used)
              001F-0020 - Timer 2 counter value (T2C)
                   0021 - RUNFL
                          bit 7: timer 1 will generate IRQ on underflow
                          bit 6: timer 2 will generate IRQ on underflow
                   0022 - Shift register value (SR)
                   0023 - Auxiliary control register (ACR)
                   0024 - Peripheral control register (PCR)
                   0025 - active interrupts (IFR)
                   0026 - interrupt mask (IER)
                   0027 - PB7 - bit 7 = pb7 state
                   0028 - number of half-bits to shift out on SR (SRHBITS)
                   0029 - CABSTATE
                          bit 7: state of CA2 pin
                          bit 6: state of CB2 pin
                   002A - Port A Input Latch (see ACR bit 0) (ILA)
                   002B - Port B Input Latch (see ACR bit 1) (ILB)


---------------------------------------------------------------------------


The VIA2 Module:

Chip type: 6522 (the VIA for the userport, IEC-bus and RS232)

(see the VIA1 module for details)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 56 49 41 32 00 00 00 00 00 00 00 00 00 00 00 00   VIA2????????????
0010: 01 00 2C 00 00 00 00 80 00 00 FF FF CE 66 FF AB   ??,??????????f??
0020: F9 00 00 40 FE 00 02 80 00 C0 7C 00 .. .. .. ..   ???@?????+|?....

      Bytes: $0000-000F - Module type ("VIA2"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-002B - See the VIA1 breakdown for details


--------------------------------------------------------------------------


The PETMEM Module:

Chip type: RAM - Holds  the  RAM  contents  of  the  PET.  This  module  is
                 mandatory.

  The size of the PET memory modules differs  with  each  different  memory
configuration. The RAM configuration is saved in the snapshot, and restored
when the snapshot is loaded. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 50 45 54 4D 45 4D 00 00 00 00 00 00 00 00 00 00   PETMEM??????????
0010: 01 02 1D 88 00 00 02 00 20 00 07 4C 73 C3 22 22   ???????????Ls+""
0020: 5B 00 FF 00 01 00 00 00 00 00 00 00 FF FF 16 13   [???????????????
0030: 00 08 12 B3 00 00 00 00 00 00 12 B3 E9 CE 00 00   ???|???????|????
0040: 00 00 00 01 04 03 04 03 04 03 04 00 80 00 00 00   ????????????????

      Bytes: $0000-000F - Module type ("PETMEM"), padded with $00
              0010-0011 - Module version $01/02 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - Configuration value.
                          Bits 0-3: 0 = 40 col PET without CRTC
                                    1 = 40 col PET with CRTC
                                    2 = 80 col PET (with CRTC)
                                    3 = SuperPET
                                    4 = 8096
                                    5 = 8296
                             Bit 6: 1= RAM at $9***
                             Bit 7: 1= RAM at $A***
                   0017 - Keyboard type.
                           0 = UK business
                           1 = Graphics
                           2 = German business
                   0018 - memory size of low 32k in k
                            (possible values 4, 8, 16, 32)
                   0019 - Value of the 8x96 configuration register
                           (CONF8X96)
                   001A - SuperPET config
                              Bit 0: 1 = $9*** RAM enabled
                              Bit 1: 1 = RAM write protected
                              Bit 2: 1 = CTRL register write protected
                              Bit 3: 0 = DIAG pin active
                           Bits 4-7: RAM block in use
              001B-xxxx - 4-32k RAM (not 8296, size depends on MEMSIZE)
              xxxx-xxxx - 2/4k VRAM (not 8296, size depends on CONFIG)
              xxxx-xxxx - 64k expansion RAM (SuperPET and 8096 only)
              xxxx-xxxx - 128k RAM (8296 only)
                   xxxx - POSITIONAL
                           bit 0: 0 = symbolic keyboard mapping
                           bit 0: 1 = positional mapping

The last item has been added in PETMEM snapshot version 1.1. It is  ignored
by earlier restore routines (V1.0) and the V1.1  restore  routines  do  not
change the current setting when reading a V1.0 snapshot. 


--------------------------------------------------------------------------


The PETROM Module:

Chip type: ROMs - Holds the ROM of the  PET,  including  possibly  attached
                  cartridges (optional)

  The size of the PET memory modules differs  with  each  different  memory
configuration. The RAM configuration is saved in the snapshot, and restored
when the snapshot is loaded. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 50 45 54 52 4F 4D 00 00 00 00 00 00 00 00 00 00   PETROM??????????
0010: 01 00 17 50 00 00 04 54 4F 4F 20 4D 41 4E 59 20   ???P???TOO?MANY?
0020: 46 49 4C 45 D3 46 49 4C 45 20 4F 50 45 CE 46 49   FILE?FILE?OPE?FI
0030: 4C 45 20 4E 4F 54 20 4F 50 45 CE 46 49 4C 45 20   LE?NOT?OPE?FILE?
0040: 4E 4F 54 20 46 4F 55 4E C4 0D 53 45 41 52 43 48   NOT?FOUN-?SEARCH

      Bytes: $0000-000F - Module type ("PETROM"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - CONFIG
                           Bit 0: 1 = $9*** ROM included
                           Bit 1: 1 = $A*** ROM included
                           Bit 2: 1 = $B*** ROM included
                           Bit 3: 1 = $e900-$efff ROM included
              0017-xxxx - 4k KERNAL ROM image $f000-$ffff
              xxxx-xxxx - 2k EDITOR ROM image $e000-$e7ff
              xxxx-xxxx - 2k CHARGEN ROM image
              xxxx-xxxx - 4k $9*** ROM image (if CONFIG & 1)
              xxxx-xxxx - 4k $A*** ROM image (if CONFIG & 2)
              xxxx-xxxx - 4k $B*** ROM image (if CONFIG & 4)
              xxxx-xxxx - 4k $C*** ROM image
              xxxx-xxxx - 4k $D*** ROM image
              xxxx-xxxx - 7 blocks $e900-$efff ROM image (if CONFIG & 8)


--------------------------------------------------------------------------


The CRTC Module:

Chip type: 6545 - The CRTC of the PET, C6x0 and  C7x0.  This  can  even  be
                  included if it is a dump of a PET without CRTC.

This module is  still  under  construction.  The  values  for  RASTERY  and
RASTERLINE might be bogus. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 43 52 54 43 00 00 00 00 00 00 00 00 00 00 00 00   CRTC????????????
0010: 01 00 55 00 00 00 FF 07 00 08 00 20 00 10 FF 1F   ??U?????????????
0020: 00 10 00 02 00 3F 28 32 08 20 10 19 1D 00 08 00   ??????(2????????
0030: 00 10 00 00 00 00 00 00 00 00 00 1F 06 00 00 00   ????????????????
0040: 00 10 B0 09 00 00 00 C0 02 1A 01 00 00 00 00 1C   ???????+????????
0050: 00 39 01 1D 01 .. .. .. .. .. .. .. .. .. .. ..   ?9???...........

      Bytes: $0000-000F - Module type ("CRTC"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-0054 - ????


--------------------------------------------------------------------------


The PIA1 Module:

Chip type: 6520 (the PIA for the interrupts, tape and the keyboard)

  The PIA 6520 is a chip with two I/O ports  (Parallel  Interface  Adapter)
and four additional handshake lines. The chip is much the same for  Port  A
and B, only that Port A implements handshaking on read operation and port B
on the write operation. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 50 49 41 31 00 00 00 00 00 00 00 00 00 00 00 00   PIA1????????????
0010: 01 00 1D 00 00 00 F9 0F 3C FF 00 3D C0 .. .. ..   ????????<??=+...

      Bytes: $0000-000F - Module type ("PIA1"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - Output register A (ORA)
                   0017 - Data Direction Register A (DDRA)
                   0018 - Control Register A (CTRLA)
                   0019 - Output register B (ORB)
                   001A - Data Direction Register B (DDRB)
                   001B - Control Register B (CTRLB)
                   001C - Bit 7:state of CA2, Bit 6:state of CB2 (CABSTATE)


--------------------------------------------------------------------------


The PIA2 Module:

Chip type: 6520 (the PIA for the IEEE488-bus)

(see the PIA1 module for details)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 50 49 41 32 00 00 00 00 00 00 00 00 00 00 00 00   PIA2????????????
0010: 01 00 1D 00 00 00 FF 00 3C FF FF 3C C0 .. .. ..   ????????<??<+...

      Bytes: $0000-000F - Module type ("PIA2"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-001C - See the PIA1 breakdown for details


--------------------------------------------------------------------------


The VIA Module:

Chip type: 6522 (the VIA for IEEE488, userport, sound)

(see the VIA1 module for details)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F         ASCII
      -----------------------------------------------    ----------------
0000: 56 49 41 00 00 00 00 00 00 00 00 00 00 00 00 00    VIA?????????????
0010: 01 00 2C 00 00 00 00 00 DF 1E FF FF CE 7B 0E 58    ??,??????????{?X
0020: 77 00 00 00 0E 40 00 80 00 C0 00 DF .. .. .. ..    w????@???+??....

      Bytes: $0000-000F - Module type ("VIA"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-002B - See the VIA1 breakdown for details


--------------------------------------------------------------------------


The CBM2MEM Module:

Chip type: RAM - Holds the RAM contents of the CBM-II  models.  Also  holds
                 the exec-bank and indirection bank registers. This  module
                 is mandatory.

  The size of the CBM-II memory modules differs with each different  memory
configuration. The RAM configuration is saved in the snapshot, and restored
when the snapshot is loaded. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 43 42 4D 32 4D 45 4D 00 00 00 00 00 00 00 00 00   CBM2MEM?????????
0010: 01 00 1B 10 02 00 01 00 02 0F 01 0F 01 4C A7 9B   ?????????????L??
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00   ????????????????
0030: 00 00 D4 FA 02 00 FF FF 00 FF FF C8 FA 5E FA 01   ?????????????^??
0040: 00 00 00 00 00 00 00 00 03 00 05 00 02 00 00 00   ????????????????
0050: 02 00 00 00 02 00 BD FA 00 00 BD FA 02 00 FF 00   ????????????????
0060: 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00   ????????????????

      Bytes: $0000-000F - Module type ("CBM2MEM"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - Memory size in 128k blocks (MEMSIZE)
                           (1=128k, 2=256k, 4=512k, 8=1024k)
                   0017 - MEMCONFIG
                           Bit 0 = $f0800-$f0fff RAM
                           Bit 1 = $f1000-$f1fff RAM
                           Bit 2 = $f2000-$f3fff RAM
                           Bit 3 = $f4000-$f5fff RAM
                           Bit 4 = $f6000-$f7fff RAM
                           Bit 5 = $fc000-$fcfff RAM
                   0018 - HWCONFIG
                           Bit 0: 0 = CRTC
                                  1 = VIC-II video chip
                                       (Basically the destinction between
                                        C500 and C600/700)
                   0019 - CPUs execution bank register (EXECBANK)
                   001A - CPUs indirection bank register (INDBANK)
              001B-xxxx - 2k system RAM $f0000-$f07ff
              xxxx-xxxx - 2k video RAM $fd000-$fd7ff
              xxxx-xxxx - RAM dump, size according to MEMSIZE
              xxxx-xxxx - if memsize < 1M and CONFIG & 1 then
                            2k RAM $f0800-$f0fff
              xxxx-xxxx - if memsize < 1M and CONFIG & 2 then
                            4k RAM $f1000-$f1fff
              xxxx-xxxx - if memsize < 1M and CONFIG & 4 then
                            8k RAM $f2000-$f3fff
              xxxx-xxxx - if memsize < 1M and CONFIG & 8 then
                            8k RAM $f4000-$f5fff
              xxxx-xxxx - if memsize < 1M and CONFIG & 16 then
                            8k RAM $f6000-$f7fff
              xxxx-xxxx - if memsize < 1M and CONFIG & 32 then
                            4k RAM $fc000-$fcfff

The RAM arrays are only saved if the RAM itself is less  than  1M.  If  the
memory size is 1M then those areas are taken from the bank 15 area  of  the
normal RAM. 


--------------------------------------------------------------------------


The CBM2ROM Module:

Chip type: ROMs - Holds the ROM images (optional)

  The size of the CBM-II memory modules differs with each different  memory
configuration. The RAM configuration is saved in the snapshot, and restored
when the snapshot is loaded. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 43 42 4D 32 52 4F 4D 00 00 00 00 00 00 00 00 00   CBM2ROM?????????
0010: 01 00 17 70 00 00 00 4C 09 EE EA 4C 44 E0 4C FE   ???p???L???LD?L?
0020: E0 4C 79 E1 4C 99 E2 4C 3F E0 4C 65 E8 4C DA E0   ?Ly?L??L??Le?L+?
0030: 4C 25 E0 4C 3A E0 4C 70 E9 4C F8 E6 B0 0E 86 CA   L%?L:?Lp?L°?????
0040: 86 CF 84 CB 84 CE 20 CD E0 20 DA E0 A6 CA A4 CB   ???????-??+?????
0050: 60 A2 00 A0 DC 60 A2 50 A0 19 60 A9 00 A2 23 95   `????`?P??`???#?

      Bytes: $0000-000F - Module type ("CBM2ROM"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - CONFIG
                           Bit 1: 1 = $1*** ROM image included
                           Bit 2: 1 = $2000-$3fff ROM image included
                           Bit 3: 1 = $4000-$5fff ROM image included
                           Bit 4: 1 = $6000-$7fff ROM image included
              0017-xxxx - 8k KERNAL ROM image ($e000-$efff)
              xxxx-xxxx - xK BASIC ROM image
              xxxx-xxxx - 4k CHARGEN ROM image
              xxxx-xxxx - 4k cartridge ROM image for $1***
                           (if CONFIG & 2)
              xxxx-xxxx - 8k cartridge ROM image for $2000-$3fff
                           (if CONFIG & 4)
              xxxx-xxxx - 8k cartridge ROM image for $4000-$5fff
                           (if CONFIG & 8)
              xxxx-xxxx - 8k cartridge ROM image for $6000-$7fff
                           (if CONFIG & 16)


--------------------------------------------------------------------------


The TPI1 Module:

Chip type: 6525 (TPI 1 for IEEE488)

  The TPI 6525 is a chip with three I/O ports (Tri-Port-Interface). One  of
the ports can double as an interrupt prioritizer. Therefore we also have to
save the states of the interrupt stack etc. 

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 54 50 49 31 00 00 00 00 00 00 00 00 00 00 00 00   TPI1????????????
0010: 01 00 20 00 00 00 38 3F 00 3F 7D FF E3 00 00 40   ??????8???}????@

      Bytes: $0000-000F - Module type ("TPI1"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - Port A output register (PRA)
                   0017 - Port B output register (PRB)
                   0018 - Port C output register (PRC)  -  Doubles  as  IRQ
                          latch register
                   0019 - Port A data direction register (DDRA)
                   001A - Port B data direction register (DDRB)
                   001B - Port C data direction register (DDRC)  -  Doubles
                          as IRQ mask register
                   001C - Control Register (CR)
                   001D - Active interrupt register
                   001E - Interrupt stack, the interrupt bits that are  not
                          yet saved (STACK)
                   001F - State of the CA/CB pins... (CABSTATE)
                            Bit 7: State of CA
                            Bit 6: State of CB


--------------------------------------------------------------------------


The TPI2 Module:

Chip type: 6525 (TPI 2 for interrupts and keyboard)

(see the TPI1 module for details)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 54 50 49 32 00 00 00 00 00 00 00 00 00 00 00 00   TPI2????????????
0010: 01 00 20 00 00 00 7F FF 00 FF FF 00 00 00 00 00   ???????????????

      Bytes: $0000-000F - Module type ("TPI2"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-001F - See the TPI1 breakdown for details


--------------------------------------------------------------------------


The ACIA1 Module:

Chip type: 6551 - An ACIA (RS232 interface) at $DE00 (C64,  optional)  (or)
                  The ACIA for the SuperPET or CBM-II (optional)

  The ACIA 6551 is an RS232 interface chip. VICE emulates RS232 connections
via /dev/ttyS* (Unix) or COM: (DOS/WIN - not yet?). When saving a snapshot,
those connections are of course lost. The state  of  the  ACIA  however  is
restored if possible. I.e. if a connection is already open  when  restoring
the snapshot, this connection is used instead. If no connection is open,  a
carrier/DTR drop is emulated.

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 41 63 69 61 31 00 00 00 00 00 00 00 00 00 00 00   Acia1???????????
0010: 01 00 20 00 00 00 00 00 10 00 00 00 00 00 00 00   ????????????????

      Bytes: $0000-000F - Module type ("ACIA1"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
                   0016 - Transmit data register (TDR)
                   0017 - Receiver data register (RDR)
                   0018 - Status register (SR)
                   0019 - Command register (CMD)
                   001A - Control register (CTRL)
                   001B -   0 = no data to tx
                            1 = Data is being transmitted
                            2 = Data is being transmitted while data in TDR
                                waiting to  be  put  to  internal  transmit
                                register
              001C-001F - Clock ticks till the next TDR empty interrupt


--------------------------------------------------------------------------


The TPI Module:

Chip type: 6525 (TPI at $DF00 for a parallel  IEEE488  interface,  optional
           module on the C64)

(see the TPI1 module for details)

      00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F        ASCII
      -----------------------------------------------   ----------------
0000: 54 50 49 00 00 00 00 00 00 00 00 00 00 00 00 00   TPI?????????????
0010: 01 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00   ????????????????

      Bytes: $0000-000F - Module type ("TPI"), padded with $00
              0010-0011 - Module version $01/00 (major/minor)
              0012-0015 - Module size (lo/hi), including this header
              0016-001F - See the TPI1 breakdown for details


--------------------------------------------------------------------------