ZX-State format: Difference between revisions

From Sinclair Wiki
Jump to navigation Jump to search
(→‎ZXSTDIVIDE: Finish documenting block.)
(→‎ZXSTDIVIDE: Document ZXSTDIVIDERAMPAGE block.)
Line 51: Line 51:
&nbsp;&nbsp; '''chData'''<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The compressed or uncompressed contents of the DivIDE's EPROM. When uncompressed, this member is exactly 16KB (16,384) bytes in size. When loading [http://www.zlib.org/ Zlib] compressed pages, the compressed size can be obtained by:
&nbsp;&nbsp; '''chData'''<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The compressed or uncompressed contents of the DivIDE's EPROM. When uncompressed, this member is exactly 16KB (16,384) bytes in size. When loading [http://www.zlib.org/ Zlib] compressed pages, the compressed size can be obtained by:
  compressedSize = blk.dwSize - ( sizeof( ZXSTDIVIDEBLOCK ) - sizeof( ZXSTBLOCK ) - 1 );
  compressedSize = blk.dwSize - ( sizeof( ZXSTDIVIDEBLOCK ) - sizeof( ZXSTBLOCK ) - 1 );
=== ZXSTDIVIDERAMPAGE ===
This block is used to save and restore the contents of the DivIDE's built-in RAM.
A zx-state file will contain a number of these blocks, normally 4 for the 32KB DivIDE. A [[#ZXSTDIVIDE|ZXSTDIVIDE]] block will proceed the first of these blocks.
// Ram pages are compressed using Zlib
#define ZXSTDRF_COMPRESSED 1
// DivIDE RAM page
typedef struct _tagZXSTDIVIDERAMPAGEBLOCK
{
  ZXSTBLOCK blk;
  WORD wFlags;
  BYTE chPageNo;
  BYTE chData[1];
} ZXSTDIVIDERAMPAGEBLOCK, *LPZXSTDIVIDERAMPAGEBLOCK;
==== Members ====
&nbsp;&nbsp; '''blk'''<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The block header. The block id is ZXSTBID_DIVIDERAMPAGE ('D', 'I', 'R', 'P').<br />
&nbsp;&nbsp; '''wFlags'''<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Various flags. This can be any combination of:
{|cellspacing="1" cellpadding="1" border="1" width="100%"
|'''Flag'''
|'''Meaning'''
|-
|ZXSTDRF_COMPRESSED
|If set, the RAM page data (beginning from '''chData''') will be compressed using the [http://www.zlib.org/ Zlib] compression library.
|}
&nbsp;&nbsp; '''chPageNo'''<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Page number of this 8KB RAM page. For the 32KB version of the DivIDE interface, this is 0 - 3.<br />
&nbsp;&nbsp; '''chData'''<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The compressed or uncompressed contents of the RAM page. When uncompressed, this member is exactly 8KB (8,192) bytes in size. When loading [http://www.zlib.org/ Zlib] compressed pages, the compressed size can be obtained by:
compressedSize = blk.dwSize - ( sizeof( ZXSTDIVIDERAMPAGEBLOCK ) - sizeof( ZXSTBLOCK ) - 1 );


=== ZXSTLEC ===
=== ZXSTLEC ===

Revision as of 21:02, 13 August 2017

ZX-State (SZX) format

ZX-State is the preferred snapshot format for Spectaculator and Fuse. It is usually used with the extension .SZX. Fuse unofficially uses the mimetype x-spectrum-szx for the format (although this could potentially change to x-spectrum-zxstate or x-spectrum-zx-state).

See the official ZX-State documentation and also the draft of the next version.

Support for the format is implemented in libspectrum (used by Fuse), Zero, ZXDS, SpecEmu and Spin.

Early versions of libspectrum (prior to 1.0.0) contained a bug which caused the A and A' registers to be swapped with F and F', respectively, when loading or saving in the SZX format. Current versions of libspectrum detect "libspectrum: 0.5.0" and earlier versions strings and correct for this.

Format extensions

With the official specification being somewhat stalled, some emulators have added unofficial extensions to the format. These include:

ZXSTDIVIDE

The state of the DivIDE IDE hard disk and CompactFlash card interface.

// DivIDE flags
#define ZXSTDIVIDE_EPROM_WRITEPROTECT 1
#define ZXSTDIVIDE_PAGED 2
#define ZXSTDIVIDE_COMPRESSED 4

// DivIDE IDE settings
typedef struct _tagZXSTDIVIDEBLOCK
{
  ZXSTBLOCK blk;
  WORD wFlags;
  BYTE chMemCtrl;
  BYTE chNumRamPages;
  BYTE chData[1];
} ZXSTDIVIDEBLOCK, *LPZXSTDIVIDEBLOCK;

Members

   blk
      The block header. The block id is ZXSTBID_DIVIDE ('D', 'I', 'D', 'E').
   wFlags
      Various flags. This can be any combination of:

Flag Meaning
ZXSTDIVIDE_EPROM_WRITEPROTECT The DivIDE's EPROM is write protected.
ZXSTDIVIDE_PAGED The DivIDE is currently paged in.
ZXSTDIVIDE_COMPRESSED If set, the EPROM data (beginning from chData) will be compressed using the Zlib compression library.

   chMemCtrl
      The current value of the DivIDE's memory control register.
   chNumRamPages
      The amount of RAM installed in this DivIDE interface, in units of 8KB. Normally 4, representing a 32KB DivIDE interface.
   chData
      The compressed or uncompressed contents of the DivIDE's EPROM. When uncompressed, this member is exactly 16KB (16,384) bytes in size. When loading Zlib compressed pages, the compressed size can be obtained by:

compressedSize = blk.dwSize - ( sizeof( ZXSTDIVIDEBLOCK ) - sizeof( ZXSTBLOCK ) - 1 );

ZXSTDIVIDERAMPAGE

This block is used to save and restore the contents of the DivIDE's built-in RAM.

A zx-state file will contain a number of these blocks, normally 4 for the 32KB DivIDE. A ZXSTDIVIDE block will proceed the first of these blocks.

// Ram pages are compressed using Zlib
#define ZXSTDRF_COMPRESSED 1

// DivIDE RAM page
typedef struct _tagZXSTDIVIDERAMPAGEBLOCK
{
  ZXSTBLOCK blk;
  WORD wFlags;
  BYTE chPageNo;
  BYTE chData[1];
} ZXSTDIVIDERAMPAGEBLOCK, *LPZXSTDIVIDERAMPAGEBLOCK;

Members

   blk
      The block header. The block id is ZXSTBID_DIVIDERAMPAGE ('D', 'I', 'R', 'P').
   wFlags
      Various flags. This can be any combination of:

Flag Meaning
ZXSTDRF_COMPRESSED If set, the RAM page data (beginning from chData) will be compressed using the Zlib compression library.

   chPageNo
      Page number of this 8KB RAM page. For the 32KB version of the DivIDE interface, this is 0 - 3.
   chData
      The compressed or uncompressed contents of the RAM page. When uncompressed, this member is exactly 8KB (8,192) bytes in size. When loading Zlib compressed pages, the compressed size can be obtained by:

compressedSize = blk.dwSize - ( sizeof( ZXSTDIVIDERAMPAGEBLOCK ) - sizeof( ZXSTBLOCK ) - 1 );

ZXSTLEC

This is documented in the draft of the next version of the SZX format.

ZXSTLECRAMPAGE

This is documented in the draft of the next version of the SZX format.

ZXSTPALETTE

The state of the ULA registers found in the 64 colour replacement ULA. This block may be present for any machine.

// Palette Block flags
#define ZXSTPALETTE_DISABLED 0
#define ZXSTPALETTE_ENABLED 1

// Palette Block. Contains the palette register values
typedef struct _tagZXSTPALETTEBLOCK
{
  ZXSTBLOCK blk;
  BYTE chFlags;
  BYTE chCurrentRegister;
  BYTE chPaletteRegs[64];
} ZXSTPALETTEBLOCK, *LPZXSTPALETTEBLOCK;

Members

   blk
      The block header. The block id is ZXSTBID_PALETTE ('P', 'L', 'T', 'T').
   chFlags
      A flags that indicates if the palette is enabled or if the normal display mode is in use. This can be one of:

Flag Meaning
ZXSTPALETTE_DISABLED Normal palette mode with BRIGHT and FLASH
ZXSTPALETTE_ENABLED 64 colour palette mode


    chCurrentRegister
      The currently selected palette register (0-63).
    chPaletteRegs
      The current values of the palette registers.