--------------------------------------------------------- || .PCV (PCVIC SYSTEM SNAPSHOT) FORMAT SPECIFICATIONS || || || || Version 1.00 || || || || as generated & used by PCVIC 1.0 - 1.14 || || || || (C) Copyright 16 jan 1998 by B.W. van Schooten || --------------------------------------------------------- These specifications should include this file PCVHEAD.DOC and the C source PCVDUMP.C which decodes a PCV image and provides some diagnostic information. Care has been taken to make sure these specifications are clear and correct, though the author cannot guarantee that they are. If you find any bugs or inconsistencies, please report them to me (my current email address is vicman@dds.nl). If you are interested in additions to the snapshot format, please report them to me, so we can make sure the format stays consistent. The PCVIC system snapshot (.PCV) A system snapshot stores the complete state of the emulated Vic-20, and can be used to save and restore any program at any point within its execution. Offset $ 0 --- 'PCVIC system snapshot',0 $16 --- Version number (minor, major) $18 --- Size of register state block $1a --- Register state block: System register values and memory expansion setting. mmm --- Byterun compressed image of the Vic's memory. The areas where the system ROMs are, $8000..$8FFF and $C000..$FFFF, are excluded. nnn --- Two-byte checksum of the data starting from offset $16 but excluding the checksum itself All words described here are little-endian (low byte first) encoded. ----------------------------------------- $16 --- Version number (minor, major) ----------------------------------------- 0 (BYTE) MINORVERSION Value between 0 .. 99. Examples: V1.12 -> minor version=12, V1.01 -> minor version=1 1 (BYTE) MAJORVERSION Value between 0 .. 255. ---------------------------------------- $18 --- Size of register state block ---------------------------------------- 0 (WORD) RSBSIZE Size of the register state block, not including the size field itself. ----------------------------------------------------------------------------- $1A --- Register state block: System register values and memory expansion setting. ----------------------------------------------------------------------------- 0 (WORD) X Low byte = 6502 X register High byte must be set to 0 2 (WORD) Y Low byte = 6502 Y register High byte must be set to 0 4 (WORD) S Low byte = 6502 S register High byte must be set to 1 6 (BYTE) OLDSCANCOUNT Scrap register; don't care 7 (BYTE) AUXFLAGS Little-used 6502 flags: Bit2..Bit5 are Bit2..Bit5 (1,B,D,I) of P register. The other bits should be set to 0. 8 (WORD) SCANLINE ScanLine nr. 0..263(NTSC) or 0..311(PAL) Values up to 32767 are possible. 10 (4 BYTES) IFRIER Exact copies of the IFR and IER registers. (Order is same as in the vic's memory) 10 (BYTE) IFR1 VIA1: IFR register 11 (BYTE) IER1 VIA1: IER register 12 (BYTE) IFR2 VIA2: IFR register 13 (BYTE) IER2 VIA2: IER register 14 (8 BYTES) PORTDATA Values as found in the IRA/ORA & IRB/ORB latches. Order is the same as in memory. var.name chip reg.name 14 (BYTE) PERIP1B VIA1 IRB 15 (BYTE) LATCH1B VIA1 ORB 16 (BYTE) PERIP1A VIA1 IRA 17 (BYTE) LATCH1A VIA1 ORA 18 (BYTE) PERIP2B VIA2 IRB 19 (BYTE) LATCH2B VIA2 ORB 20 (BYTE) PERIP2A VIA2 IRA 21 (BYTE) LATCH2A VIA2 ORA 22 (BYTE) TIMERSTATUS Lower 4 bits correspond to status of VIA timers: bit0 1 = VIA1 Timer1 running bit1 1 = VIA1 Timer2 running bit2 1 = VIA2 Timer1 running bit3 1 = VIA2 Timer2 running High 4 bits are future expansion: set these to 0. 23 (4 BYTES) TIMERDATA A copy of the low bytes of the VIAs' latches and timers. These must be kept consistent with the values found in the memory area $9110-$912F. 23 (BYTE) V1T2LATCHL 24 (BYTE) V2T2LATCHL 25 (BYTE) V1T2TIMERL 26 (BYTE) V2T2TIMERL 27 (BYTE) NMIFLANK This variable is used to detect NMI flanks. 0 = NMI was low since last time the NMI pin was sampled. Other = NMI high since last time sampled. 28 (BYTE) MEMCONFIG Each bit corresponds to the presence of an 8k block. Bit=1 => area is RAM Bit=0 => area is write-protected (for ROM areas or unused addressing space) Bit: 7 6 5 4 3 2 1 0 8K-Block start: xxxx xxxx A000 xxxx 6000 4000 2000 0000 xxxx means: Unavailable. (the system ROMs and I/O space are situated here) Always set these bits to 0. Note that the areas 0000..03ff and 1000..2000 are considered to be always occupied by RAM. For an unexpanded Vic, all blocks are set to 0. Setting only the low block (bit0) it to 1 results in 3K RAM expansion. 29 (WORD) PC 6502 PC register 31 (WORD) MAINFLAGS Much-used 6502 flags. Note that: '.' means: 'don't care'. '0' means: always set to 0. Bit: 7654 3210 Low byte = SZ.. .... High byte = 0V00 000C 33 (BYTE) A 6502 A register 34 (BYTE) SCANCOUNT CPU cycle count within scan line. 0 = End of scan line 129(NTSC) or 131(PAL) = Start of scan line 35 END ------------------------------------------------------------------------------- mmm --- Byterun compressed image of the Vic's memory. The areas where the system ROMs are, $8000..$8FFF and $C000..$FFFF, are excluded. ------------------------------------------------------------------------------- Byterun (as is also used in ILBM images) achieves compression by replacing a row of bytes with equal values by a count and a value byte. See the procedure 'decompress' in the C source 'PCVDUMP.C' for a detailed description of how to decompress byterun-encoded data. There are two noncontiguous memory blocks in the image, $0000..$7FFF and $9000..$BFFF, which are compressed separately. $0000..$7FFF Memory data This complete area is always included, regardless of the value of MEMCONFIG; some of it could be occupied by ROMs. $9000..$93FF I/O Space Only the areas $9000..$900F and $9110..$912F are defined. These should contain the values as found when reading from the corresponding VIC and VIA registers. The port addresses on a real Vic are shadowed multiple times across this area, though current versions of PCVIC do not support this. This means PCVIC will fill the rest of the area with '$FF' bytes. The values found in these shadow areas are 'don't care'. The remaining values are undefined. $9400..$97FF Colour memory Only the low nybbles are defined. $9800..$9FFF Free I/O Space In PCV version 1.0, there is no room in the register state block for optional special hardware which could have their I/O space here. However, it is possible to map ROM to this area, and probably RAM as well. $A000..$CFFF Memory data This complete area is always included, regardless of the value of MEMCONFIG; some of it could be occupied by ROMs. ------------------------------------------------------------------------------ nnn --- Two-byte checksum of the data starting from offset $16 but (of course) excluding the checksum itself ------------------------------------------------------------------------------ The checksum in initialised with value $7ffb. The checksum is then updated with each byte read from the PCV file. See the procedure 'addtochecksum' in the C source 'PCVDUMP.C' for the checksum update algorithm.