UEF [Unified Emulator Format] FILE FORMAT

Originally by Thomas Harte. Suggestions and additions to tape functionality by Fraser Ross and Greg Cook.
DRAFT file format version 0.10 / document draft 28 (revised 10/1/2006)

Chunk list

Introduction

The UEF file format is designed to store accurate images of the common media types associated with the BBC Micro, Acorn Electron and Atom. Tape storage is compatible with the CUTS/BYTE/Kansas City Format, and hence the format is also capable of storing software for non-Acorn systems such as the Altair 8800, PT SOL-20, Ohio Scientific, Compukit UK101, Nascom 1/2/3, Motorola MEK D1 6800 and SWTPC 6800 kit based computers.

UEF files are chunk based and optionally compressed.

If you spot any errors or omissions in this spec, or have any comments, then please e-mail me.

Header and Chunk Template

All chunks conform to a common template:

2 bytes: chunk id
4 bytes: chunk length, not counting the 6 bytes that make up this header
<chunk data>

Files begin with a 12 byte file header:

10 bytes: Null terminated string "UEF File!"
1 byte: minor version number
1 byte: major version number

Any changes that would require separate code paths in implementing software will result in a major version number increase. Changes that introduce a substantial new variation in the way media may be described will result in a minor version number increase.

If most existing software could still utilise most existing and potential UEFs as though the specification had not changed then the version number is not affected.

Covered Types of Media

The following varieties of media are supported:

  • Tape images
  • Disc images
  • ROM images
  • State snapshots

There are a number of control chunks to give target machine hints but parsing of these is optional. There are also a small number of archive content chunks for information such as tape inlay transcriptions.

Tape data chunks are ordered. UEF processing should begin at the start of the file, then proceed according to the tape hardware to the end.

Any non-tape chunks encountered whilst dealing with a tape UEF should only be processed when they are crossed by tape processing mechanisms. So, for example, a tape image may include a memory snapshot of a previously stored high score table stored straight after the end of the game data.

Conventions

UEF files may and commonly will be be gzip compressed, but the suffix remains unchanged. The gzip compressed version has the normal gzip 'magic number' as its first two bytes, so the well known ZLib can be used to work with either type seemlessly.

All data is little endian unless stated otherwise.

Floating point numbers are stored in IEEE 754 format, with intel 8087 byte ordering, giving 7 figure accuracy. Example C code to read a float and convert it into a floating point number in a platform neutral manner:

	/* assume a four byte array named Float exists, where Float[0]
	was the first byte read from the UEF, Float[1] the second, etc */

	/* decode mantissa */
	int Mantissa;
	Mantissa = Float[0] | (Float[1] << 8) | ((Float[2]&0x7f)|0x80) << 16;

	float Result = (float)Mantissa;
	Result = (float)ldexp(Result, -23);

	/* decode exponent */
	int Exponent;
	Exponent = ((Float[2]&0x80) >> 7) | (Float[3]&0x7f) << 1;
	Exponent -= 127;
	Result = (float)ldexp(Result, Exponent);

	/* flip sign if necessary */
	if(Float[3]&0x80)
		Result = -Result;

	/* floating point number is now in 'Result' */

To write:

	/* assume that the floating point number 'Value' is to be stored */
	unsigned char Float[4];

	/* sign bit */
	if(Value < 0)
	{
		Value = -Value;
		Float[3] = 0x80;
	}
	else
		Float[3] = 0;

	/* decode mantissa and exponent */
	float mantissa;
	int exponent;
	mantissa = (float)frexp(Value, &exponent);
	exponent += 126;

	/* store mantissa */
	Uint32 IMantissa = (Uint32)(mantissa * (1 << 24));
	Float[0] = IMantissa&0xff;
	Float[1] = (IMantissa >> 8)&0xff;
	Float[2] = (IMantissa >> 16)&0x7f;

	/* store exponent */
	Float[3] |= exponent >> 1;
	Float[2] |= (exponent&1) << 7;

	/* now output Float[0], then Float[1], etc */

All strings are ASCII and NULL terminated, and the linefeed character, ASCII code 10 (decimal) is used to deliminate new lines. The only other ASCII control character (i.e. with decimal values less than 32) recognised is 'tab', value 9. Others should be completely ignored.

Notes on pseudo-code and understanding the tape data chunks

This document contains pseudo-code for every tape chunk that outputs anything other than a silent wave. Several conventions of language are observed.

Non-silent audio is composed from segments of a sine wave.

A pulse is a 180 degree segment of sine wave. This will normally appear to be a single loop of wave output - a signal starting at zero, then arching in one direction away from zero before returning there.

Phase, which is initially 180 degrees, dictates the region of sine wave used for pulses.

There are two named varieties of pulse - high pulse and low pulse, named after the way they appear when phase remains at the default setting. A high pulse is the region between 180+phase and 360+phase degrees (appearing as a 'groove' if phase is 180). A low pulse is the region between 0+phase and 180+phase degrees (appearing as a 'pit' if phase is 180).

A cycle is a low pulse followed by a high pulse, i.e. a complete sine cycle from 0+phase to phase+360 degrees.

The (modal) base frequency determines the frequencies at which the sine wave should be generated. Base tone is composed of repeated cycles at the base frequency. Carrier tone is composed of repeated cycles at twice the base frequency.

The data encoding format dictates how bits are encoded as patterns of sine wave.

In the ordinary ("1200 baud") data encoding format, a zero bit is encoded as one complete cycle at the base frequency. A one bit is two complete cycles at twice the base frequency.

In the alternate ("300 baud") data encoding format, a zero bit is encoded as four complete cycles at the base frequency. A one bit is eight complete cycles at twice the base frequency.

Note: when encoded with the same data encoding format, zero and one bits always take the same amount of time to output.

When UEF files are initially opened, default values are a base frequency of 1200Hz, a data encoding format of 1200 baud and a phase of 180 degrees. This produces the most common 1200 baud data storage scheme used by the BBC Micro and Acorn Electron.

Simplified Usage

Emulator authors seeking simplicity may ignore any chunk that deals with the tape wave form at pulse or cycle level and rationalise chunk &0104 to a whole number of stop bits while retaining 99.9% compatibility with real world UEFs.

Those looking to implement 80% compatibility with UEF files without a detailed emulation of the underlying tape hardware are recommended to implement of chunks &0100, &0110 and &0111 and may otherwise assume 1200 baud (i.e. 1200Hz base wave, 1200 baud data encoding, phase 180).

Colour Spaces

With all greyscale images, the colour values simply represent colour intensity, but for colour images, one of the following conventions applies:

  • 8 bpp: colours are paletted
  • 16 bpp: the 16 bit word is split into four nibbles, and is intended to be decoded so as to produce an r:g:b value with each component described in 8 bits. The most significant nibble is the high nibble of the red byte. The second most significant nibble (the other nibble of the high byte) is the high nibble of the green byte. The third most significant nibble is the high nibble blue byte. The least significant nibble is the 'offset' part, as it should used as the low nibble of the red, green and blue bytes. So, for example, the value &abcd describes the RGB colour (0xad, 0xbd, 0xcd).
  • 24 bpp: again an r:g:b triplet is formed, with each colour being represented by a byte value. The most significant byte is the red byte, the middle-most significant byte is the green byte, and the least significant byte is the blue byte. Hence the value &abcdef describes the RGB colour (0xab, 0xcd, 0xef).

Bit Multiplexing

This file format has support for the special emulator feature I have badly named 'bit multiplexing' until a better name can be found. Bit multiplexing supplies the emulator with additional information so that old programs may be run to produce a greater quality of output.

This feature is really only for emulation use of UEF files and ignoring bit multiplexing will have no effect on the accuracy of your tool to original hardware. This feature is expected to be ignored by most authors.

A separate document on multiplexing is in preparation.

All Defined Chunks

&00xx set - Content information
&01xx set - Tape chunks
&02xx set - Disc chunks
&03xx set - ROM chunks
&04xx set - State snapshots
&FFxx set - reserved / non-emulator portable

&00xx set - Content information

Back to chunk index

Chunk &0000 - origin information chunk

This chunk holds a few lines of text describing where the file came from, or naming the utility that created it. Text should be automatically formatted by any tool utilising this information, so new lines should only be used for breaking paragraphs.

Chunk &0001 - game instructions / manual or URL

Text holding a copy of the game manual, or some notes on the game generally. Alternatively, this may contain a URL to a more meaningful resource, such as a local or internet based web site, in which case the first five characters should be "URL: " ("URL:" followed by a single space) followed by the URL.

Chunk &0003 - inlay scan

A scan of the inlay image.

Byte Offset Length Description
0 2 Width of image
2 2 Height of image
4 1 BPP of image in low 7 bits, high bit set if image is grey scale.
[5 if 8bpp paletted, non-existant otherwise] 768 If intended for display at 8bpp other than grayscale, then a 256 colour palette follows here, arranged in b, g, r triplets (bytewise you see the b value, then the g, then the r) each representing a linear scale from 0 (no quantity of this colour present) to 255, with the first palette entry coming first in the list.
[773 if 8bpp paletted, 5 otherwise] Width*Height*(bits per pixel) The image data itself, stored in English reading order and following the usual UEF space conventions.

This chunk is intended for small, low quality scans, suitable for display within an emulator.

Chunk &0005 - target machine chunk

Describes a type of hardware for which this file is targetted. Multiple chunks may be present - e.g. some tapes contain a BBC and Electron version of their game, the only difference being which file is loaded last. In general, this sets a 'minimum' required hardware level, so that emulators can alert a user when a UEF requires hardware that isn't emulated.

This chunk is exactly 1 byte long. In that byte, the most significant nibble holds one of the following values:

0 - this file is aimed at a BBC Model A
1 - this file is aimed at an Electron
2 - this file is aimed at a BBC Model B
3 - this file is aimed at a BBC Master
4 - this file is aimed at an Atom

The least significant nibble holds one of the following values:

0 - this file will work well with any keyboard layout, or a layout preference is not specified
1 - this file will work best if all keys are left in the same places relative to each other as on the emulated machine (e.g. the IBM PC key physically above '/' produces ':' as per theoriginal hardware, even though it has a ' on it on UK keyboards)
2 - this file will work best with a keyboard mapped as per the emulating computer's (e.g. on a UK keyboard pressing shift+0 on a keyboard will produce ')', rather than '@' as on a BBC or Electron)

Chunk &0006 - bit multiplexing information

Contains one bytes, for determining what, if any, bit multiplexing information is provided by this UEF.

This byte is known as the 'bit multiplier'. Take the value of this byte and multiply it by 4 to get the number of bits that are stored for every bit that the original machine had. For 32bit platforms such as wintel, this byte will normally have the value '1' - indicating that 1*4 bits are available for every single in the original - i.e. every 8bit value is shadowed by a 32bit value.

Older UEF definitions had a second byte defined for this chunk, but it is no longer used and need not be present.

Chunk &0007 - extra palette

This chunk holds the palette for multiplexed modes with colour depths of less than 16bit. Contains (chunk length / 3) entries, where each entry is a red byte followed by a green byte, followed by a blue byte, each specifying a level in the full byte range of 0->255. If the chunk length has a remainder when divided by three, the last 'remainder' bytes should be ignored.

The first value you read is the r,g,b value of colour 0 is the palette. The second value is colour 1, and so on. The values for entries referred to in software but not described here are undefined.

Chunk &0008 - ROM hint

This chunk can be used to specifically say whether a particular ROM or class of ROM is required or not.

If the lsb of the first byte is 0, the chunk is requesting a ROM or set of ROMs be absent. If it is 1, the chunk is instead requesting presence.

If the second byte has value 0, a specific ROM is being named. In which case a NULL terminated string follows, which should be matched with the ROM encoded ROM name. For information on how to decipher the ROM name from a ROM file, see the BBC AUG. Another byte then follows the NULL terminator. If its lsb is 0, the string given is exactly equivalent to the ROM name. If the lsb is instead 1, then instead the string, if length n, names only the first n characters of the ROM it is thinking of. In this case it is sufficient for the emulator to find any ROM with those first n characters.

Otherwise, if the lsb of the second byte was 0, a ROM type follows in the third byte. It has one of the following values:

  • 0 - all ROMs [*]
  • 1 - all ROMs except BASIC [*]
  • 2 - any DFS ROM
  • 3 - any ADFS ROM
  • 4 - any filing system ROM [*]
  • 5 - any language ROM [*]

Of course if this chunk requests the presence 'any ADFS ROM', it means just one, whereas if it wants them absent it means the absence of any. Requests for ensuring presence of types marked with a * above is ignored - those types are included purely for the purpose of requesting absence.

There may be multiple ROM hints, in which case the order of these chunks is important. They are followed like a list of instructions. So if the first chunk says to remove any ADFS ROM's, and then a second one says to install any ADFS ROM's, then the UEF is in total requesting the presence of exactly one ADFS ROM. However an emulator need not take action if it finds a constraint is already satisfied, so it is meaningless to request more than one ADFS ROMs.

Chunk &0009 - short title

A short title, in ASCII, suitable for use as the title bar to an emulator, or display in a file selector.

Chunk &000a - visible area

For UEFs which use only a portion of the output screen, this chunk allows the total visible area to be restricted to a particular rectangle. Contents are:

Byte Offset Length Description
0 2 Lowest visible x value - i.e. 'left' of visible rectangle
2 2 Lowest visible y value - i.e. 'top' of visible rectangle
4 2 Highest visible x value - i.e. 'right' of visible rectangle
6 2 Highest visible y value - i.e. 'bottom' of visible rectangle

For the BBC/Electron, all coordinates are assumed to be measured on a mode 0 style 640x256 output, regardless of the display mode in use at any particular time. Atom displays are assumed always to be measured per the native display mode.

&01xx set - Tape chunks

Back to chunk index
Chunk &0100 - implicit start/stop bit tape data block

This chunk represents byte data stored on a cassette with Acorn's default start/stop bits (which are not reproduced).

The least significant bit of the first byte is the first bit to appear on the tape, the most significant the 8th, and so on. Hence bytewise values are the same as the bytes stored on cassette.

PSEUDO-CODE

  • while bytes remain in UEF chunk
    • output a zero bit (the start bit)
    • read a byte from the UEF chunk, store it to NewByte
    • let InternalBitCount = 8
    • while InternalBitCount > 0
      • output least significant bit of NewByte
      • shift NewByte right one position
      • decrement InternalBitCount
    • output a one bit (the stop bit)
Chunk &0101 - multiplexed data block

The chunks that store meaningful tape data that may be multiplexed are &0100 and &0102. If either of these is immediately followed by a &0101 chunk then that chunk contains exactly the same information as its predecessor, except that the data fields are expanded to contain multiplexed data.

If this chunk appears after any chunk that is neither &0100 nor &0102 then it has no meaning and should be ignored.

Older UEFs may use &0103 as a synonym for &0101.

Chunk &0102 - explicit tape data block

Chunk &0102 is a raw representation of data bits stored on cassette. Unlike chunk &0100 there are no implicit start/stop bits.

The first byte of this chunk is used to calculate chunk length at the bit level. Only the first (chunk length * 8) - (value of first byte) bits are used in this chunk.

Bit ordering is as per &0100, so the least significant bit of any byte is the first bit on the tape.

PSEUDO-CODE

  • compute bit count for chunk - get chunk length, multiply it by 8 and subtract the value of the first byte. Store it to BitCount
  • store zero to CurrentBit
  • while CurrentBit < BitCount
    • if (CurrentBit mod 8) = 0, read a new data byte from the chunk to NewByte
    • output the least significant bit of NewByte
    • shift NewByte right one position
    • increment CurrentBit
Chunk &0104 - defined tape format data block

This chunk holds byte data with specified non-standard start/stop/parity bits. It is analogous to &0100 in that bytes of data are read from the UEF then packaged to produce the tape signal. Unlike &0100, block packaging may include arbitrary stop and parity bits. Like &0100 blocks always have an implicit start bit.

While processing this chunk, bytes are read from the source UEF and packaged into packets. The packet format is defined by the first three bytes in the chunk.

The first byte holds the number of data bits per packet, not counting start/stop/parity bits.

The second byte holds the ascii code for 'N', 'E' or 'O', which specifies that parity is not present, even or odd.

The third byte holds information concerning stop bits. If it is a positive number then it is a count of stop bits. If it is a negative number then it is a negatived count of stop bits to which an extra short wave should be added.

Positive numbers should be used wherever possible. Reproductions of original BBC and Electron material should only produce positive numbers if correctly encoded.

The total number of packets is equal to the chunk's length minus three. Bits in bytes are stored as in block &0100, i.e. the least significant bit should appear on cassette first.

Data blocks are always stored in the chunk as whole byte quantities. If the number of data bits is seven then the most significant bits of all bytes in the chunk are unused and should be zero.

Normal start bits should always be inserted into data, as per the implicit data chunk, &0100.

For the BBC/Electron, the following formats may be encountered: 7E1, 7E2, 7O1, 7O2, 8E1, 8N2, 8O1. Format 8N1 would produce the same output as chunk &0100.

For the Atom, data format will usually be 8N-1.

PSEUDO-CODE (NB: see phase notes at head of document)

  • let NumBitsPerPacket = number of data bits, per first byte in chunk
  • make a note of parity, per second byte in chunk
  • let StopBitCount = number of stop bits, per third byte in chunk
  • if StopBitCount < 0 then negative StopBitCount (making it positive), make a note to incorporate an extra short wave
  • while bytes remain in UEF chunk
    • output start bit - always a zero
    • read a byte from the UEF chunk, store it to NewByte
    • let InternalBitCount = NumBitsPerPacket
    • while InternalBitCount > 0
      • output least significant bit of NewByte
      • shift NewByte right one position
      • decrement InternalBitCount
    • if parity is required, output parity bit
    • let InternalStopCount = StopBitCount
    • while InternalStopCount > 0
      • output a stop bit - always a one
      • decrement InternalStopCount
    • if StopCycleCount was negative when first read then output a single wave (i.e. low pulse, then high pulse) at twice the base frequency
Chunk &0110 - carrier tone (previously referred to as 'high tone')

A run of carrier tone (i.e. cycles with a frequency of twice the base frequency), with a running length described in cycles by the first two bytes.

PSEUDO-CODE (NB: see phase notes at head of document)

  • read cycle count for chunk - first two bytes, store to CycleCount
  • while CycleCount > 0
    • output a single cycle at twice the current base frequency
    • decrement WaveCount
Chunk &0111 - carrier tone (previously 'high tone') with dummy byte

This chunk represents a run of carrier tone followed by 10 bits of data and then a second run of carrier tone.

This four byte chunk is composed of two sets of two bytes - the first two describe the number of cycles in the tone before the dummy byte, and the second two describe the number of cycles in the tone after the dummy byte. The dummy byte always has value &AA.

PSEUDO-CODE (NB: see phase notes at head of document)

  • read 'before' cycle count for chunk - first two bytes, store to CycleCount
  • while CycleCount > 0
    • output a single cycle at twice the current base frequency
    • decrement CycleCount
  • output the folowing bit sequence (in English reading order): 0, 0, 1, 0, 1, 0, 1, 0, 1, 1
  • read 'after' cycle count for chunk - final two bytes, store to CycleCount
  • while CycleCount > 0
    • output a single cycle at twice the current base frequency
    • decrement CycleCount
Chunk &0112 - integer gap

A gap in the tape - a length of time for which no sound is on the source audio casette. This chunk holds a two byte rest length counted relative to the base frequency. A value of n indicates a gap of 1/(2n*base frequency) seconds.

Chunk &0116 - floating point gap

As per 0112, but the gap length is a floating point number measured in seconds.

Chunk &0113 - change of base frequency

The base frequency is a modal value, which is assumed to be 1200Hz when a UEF is open. If this chunk is encountered, the base frequency changes.

This chunks contains a single floating point number, stating the new base frequency.

Chunk &0114 - security cycles

Security cycles are mainly found at the start of a run of carrier tone as an identification feature. Rarely they are at the end of a run of carrier tone. They consist of cycles of the base frequency and twice the base frequency and sometimes have a leading and/or trailing pulse.

The first three bytes of this chunk (a 24 bit value) denote the number of 'cycles'. It is possible that the first and last may be only pulses.

The fourth byte holds the ASCII code for 'P' or 'W'. If it is 'P', the first cycle is replaced by a single high pulse.

The fifth byte again holds the ASCII code 'P' or 'W' which, if it is 'P' signifies that the last cycle is replaced by a low pulse.

If the fifth byte is 'P' the fourth byte must be 'W' but has no relevance.

If the 'cycles' follow a gap then the fourth byte can logically be 'P' or 'W'. If the 'cycles' follow other cycles then the fourth byte will logically be 'W'.

This chunk never offends the general rule that the stored waveform consists only of gaps and pulses joined at zero crossings, and never creates an external or internal phase change.

The UEF is encoded with eight 'cycles' per byte.
Slow cycles (at the base frequency) are denoted by 0 bits.
Fast cycles (at twice the base frequency) are denoted by 1 bits.
Bits are ordered such that the most significant bit represents the first cycle on the tape.
Spare bits in the last byte should preferably be 0 bits.
When the number of cycles is 1:

  • Only one of the fourth and fifth bytes may be 'P'
  • If the fourth byte is 'P' the fifth byte must be 'W' but has no relevance

Examples:

The sequence of cycles LSLLLSSLSSLLSL will be stored as &0E, &00, &00, 'W', 'W', &9D, &2C. A sequence following other cycles having only 1 short pulse will be stored as &01, &00, &00, 'W', 'P', &00. A sequence following a gap having only 1 short pulse followed by 3 long waves will be stored as &04, &00, &00, 'P', 'W', &0E.

PSEUDO-CODE (NB: see phase notes at head of document)

  • let NumCycles = number of stored cycles, the first three bytes in chunk
  • read the first bit from the chunk
  • if fourth byte of the chunk is an ASCII 'P' then output a single high pulse of the frequency implied by the bit just read, read new bit from chunk, decrement NumWaves
  • while NumWaves > 1
    • read next bit from chunk
    • if it is a zero, output a single cycle at the base frequency
    • if it is a one, output a single cycle at twice the base frequency
    • decrement NumWaves
  • if NumWaves is equal to 1
    • if fifth byte of chunk is an ASCII 'P' then output a single low pulse of the frequency implied by the final bit
    • else fifth byte of chunk must be an ASCII 'W' so output a single cycle of the frequency implied by the final bit
Chunk &0115 - phase change

This chunk contains a 16 bit unsigned value between 0 and 359, which determines the new phase.

The majority of professional cassettes have waves shifted 0 or 180 degrees. Before one of these chunks is met (i.e. immediately after opening a UEF) the phase shift should be taken to be 180 degrees.

If accurately representing a real life source tape, this chunk will only be found neighbouring a gap.

See the section entitled 'Notes on phase' towards the top of this document for a proper discussion of the effect of phase on the output waveform.

Chunk &0117 - data encoding format change

This chunk contains a 16 bit unsigned value and is used to select the new data encoding format. Upon opening a UEF, the "1200 baud" data encoding format described below should be adopted.

If the value is 300 then the "300 baud" data encoding format is selected. From henceforth a '0' bit should be encoded as 4 cycles at the base frequency and a '1' bit as 8 cycles at twice the base frequency.

If the value is 1200 then the "1200 baud" data encoding format is selected. From henceforth a '0' bit should be encoded as 1 cycle at the base frequency and a '1' bit as 2 cycles at twice the base frequency.

All other values have undefined effect.

Chunk &0120 - position marker

This chunk contains a string offering a textual description of the significance of the location it sits at within the file purely for the benefit of human beings.

For example, Repton 3 contains the game followed by a level editor, so this chunk could be used to mark the start of the editor files - allowing an emulator user can easily skip straight to those if desired.

Chunk &0130 - tape set info

This chunk allows the tape data mechanisms in UEF to be applied to a wide range of non-tape media, and sets the correct vocabulary and geometry for such use. All are modal values and UEF files are assumed to relate to single track, single sided tapes unless stated otherwise.

Byte Offset Length Description
0 1 Unsigned char - a byte that selects the appropriate vocabulary for the media. This does not place restrictions on the geometry of the media. Defined values are:
  • 0: 'unit', 'position' (generic)
  • 1: 'tape', 'channel' (the most common setting; channels are rarely used as most tapes are mono)
  • 2: 'disc', 'track' (a record, CD or Minidisc)
  • 3: 'tape', 'cue' (DAT, modern VHS soundtrack)
  • 4: 'cartridge', 'track' (8-Track)
1 1 Unsigned char - number of tapes. Maximum 127 tapes.
2 1 Unsigned char - Number of independent channels. Most cassettes are mono and this value will be 1. For disc media this byte contains the greatest number of audio tracks on any of the discs.

Chunk &0131 - start of tape side

This chunk deliminates the start position of a new tape side

Byte Offset Length Description
0 1 Unsigned char - Tape ID (0..126) and side bit. The maximum value of bits 0 to 6 is given by chunk &0130. Bit 7 signifies the side: 0 for side A, 1 for side B.
1 1 Unsigned char - Channel number, starting from 0 each side. The maximum is given by chunk &0130. For disc media this is the track number. For the sake of consistency the left channel of a stereo cassette is 0, the right channel 1.
2 *

NULL terminated ASCII string - Side description. See chunk &0120. This is a space to record the version on this particular side (e.g. 'Electron' or 'Infinite Lives'), or the side itself in the manufacturer's preferred style (e.g. 'Side A', 'Side 1', 'Label side'). For Minidiscs this can record the track title.

For compatibility purposes, string length should be restrained to a maximum of 255 characters.

&02xx set - Disc chunks

Back to chunk index

Chunk &0200 - disc info

Gives an overview of the included disc thusly:
Byte Offset Length Description
0 1 number of heads minus one. Values greater than 127 are invalid. Notice that since each head is considered to potentially read two sides of a disc platter, this value will be 0 for single sided and double sided disc images alike.
1 2 sector length in bytes of implicitly defined disc sides
3 1 number of sectors per track within implicitly defined disc sides
4 1 number of tracks within implicitly defined disc sides
5 1 a one byte filing system identifier, one of:
  • 0: Undefined or not specified
  • 1: Acorn 8271 DFS
  • 2: Watford DFS 62
  • 3: Acorn ADFS
  • 4: Acorn 1770 DFS
  • 5: Solidisk
  • 6: OPUS DDOS

The value of this is intended to tell you the catalogue type of the disc, and therefore if applicable which filing system ROM to 'recommend' to the user. This should be interesting to emulators that like to be vocal towards their users, but may also be used by those which like to implement their own filing systems compatible with the originals but without the hassle of a working hardware emulation.

If a UEF wants to 'force' an emulator to adopt a particular ROM, it should use the ROM hint chunk &0008.

Chunk &0201 - single implicit disc side

First comes a one byte side/head id, in which the top bit represents the disc side - not set implies side 1, set implies side 2. The low 7 bits form the disc head id.

Then following are (length of chunk - 1) bytes, stored such that the first byte is the first byte on the first sector of the first track, the (sector length)th byte is the first byte of the second sector, and so on.

The stuff that is not normally seen by any component above the drive controller - the sector headers, (M)FM syncs, etc are left implicit. This chunk correlates directly to the SSD/DSD/ADF style of disc image.

In many cases, there will not be as many bytes stored here as calculating (bytes per sector)*(sectors per track)*(tracks per side) seems to imply. This situation indicates that the value of the remaining bytes on the disc is not important, although the remaining sectors and tracks were formatted.

Chunk &0202 - multiplexed disc side

As above but the disc data (after the side id) is multiplexed.

&03xx set - ROM chunks

Back to chunk index

Chunk &0300 - standard machine rom

Contains some sort of ROM, which are usually 16kb in size. The first byte is a type byte. It can contain one of the following values:

  • 0 - type unspecified
  • 1 - this is the OS ROM
  • 2 - this is the BASIC ROM
  • 3 - this is a language ROM
  • 4 - this is a utility ROM
  • 5 - a filing system ROM
  • 6 - a hardware driver
  • 7 - a game ROM

The second byte is a slot recommendation, in which the high four bits should be zero. It is useful as on some hardware inserting a language or utility ROM in a slot above BASIC will cause it to boot instead, which may be the desired effect. For the OS ROM, this value is undefined, as it does not appear in a slot.

It should be noted that a slot recommendation is only a hint - it may be ignored by software if required. E.g. Electron emulators will have difficulty honuring a slot recommendation for the BASIC ROM because on that hardware the BASIC ROM is a special case, occupying more than one slot, and similarly they may not allow any ROM to occupy slots 8 or 9 since they are reserved for the keyboard.

The final part of this chunk is the ROM itself. As it will occupy a 16kb hole in the memory space, it shouldn't be larger than 16kb, however some ROMs are smaller (e.g. the Electron Plus 1 ROM is only 4kb), and should be considered to 'repeat' over the 16kb memory address range in that case.

Chunk &0301 - multiplexed machine rom

As above, but the ROM data is multiplexed.

&04xx set - State snapshots

Back to chunk index

Chunk &0400 - 6502 standard state

Contains 8 bytes. The first is the 'update byte'. Common to all the snapshot chunks, the 'update byte' contains a non-zero value if the emulator is supposed to update this chunk when closed.

The next five bytes are the a, p (status), x, y and s registers in that order. Then the two byte program counter follows.

Chunk &0401 - Electron ULA state

For Electron emulators, this chunk contains the entire state of the ULA (the video circuits, cassette interface, sound generator and ROM pager). Format is:

Byte Offset Length Description
0 1 'Update byte'. Contains a non-zero value if the emulator should update this chunk when closed.
1 2 Interrupt control, followed by interrupt status (SHEILA &FE00). Should be used to determine which interrupts are currently active as well as which are enabled.
3 2 SHEILA &FE02, followed by SHEILA &FE03 - in total screen start address
5 1 SHEILA &FE04 - cassette shift register
6 2 First byte: value of &FE05, principly for determining the value of the page enable bit. Second byte: ROM currently paged in (low 4 bits). High 4 bits are undefined.
8 10 Remainder of SHEILA bytes, in ascending order (i.e. FE06, then FE07...)
18 4 Number of 16Mhz cycles since last 'end of display' interrupt signal (regardless of whether this interrupt was actually enabled at the time).

Chunk &0402 - WD1770 state

The assumption is made that a snapshot cannot be saved while the WD1770 is in the middle of an operation. The first byte, as with all other state snapshots, the 'update byte' - containing a non-zero value if the emulator should update this chunk when closed.

The next four bytes are, in order : the status byte, the track byte, the sector byte, and the data byte.

The final byte stores the disc drive status. As this varies from machine to machine, it is in a standard form. Bits 0->2 are the current drive number, in the range 0..7, bit 3 is the side select bit (high = side 2), and bit 4 is the double density select bit (high = double density).

Chunk &0403 - JIM paging register state

A two byte chunk - the usual 'update byte' followed by the last value written to the JIM paging register.

Chunk &0410 - standard memory data

Following the usual 'update byte', a second describes which memory is stored. It has one of the following values:

  • 0 - this memory data comes from the standard RAM, located from location &0000 in the 6502 memory map upwards
  • 1 - this memory data comes from shadow RAM
  • 2 - this memory data is from the JIM page
  • 255 - 'patch memory'

Upon encountering 'patch memory', the next three bytes should be read. The first is a base address, with a value equivalent to one in the above table other than 255. The next two are an offset into that area to which the following data should be loaded.

For example, suppose the chunk started &ff, &00, &12, &34 - then the following data should be loaded at position &3412 in normal RAM.

Chunk &0411 - multiplexed memory data

As above, but with multiplexed data.

Chunk &0412 - multiplexed (partial) 6502 state

Intended to coexist with chunk &0400. After the 'update byte', contains multiplexed entries for A, P, X and Y in that order.

Chunk &0420 - Slogger Master RAM Board State

After the 'update byte', this chunk contains one other byte indicating the mode of a Slogger Master RAM board. That byte may have value zero to indicate that the board is disabled, one to indicate that it is in turbo mode or two to indicate that it is in shadow mode.

FFxx set - reserved / non-emulator portable

Back to chunk index

Chunks &FF01 -> &FFFF - reserved / non-emulator portable

These chunks are reserved for you to do anything you like with. For example, my emulator stores a nice picture for its 'about' box, a GUI font and other small things in these chunks. An emulator should not assume it can understand these chunks unless it recognise the value of chunk &FF00.

Chunk &FF00 - emulator identification string

This chunk is a NULL terminated string. It dictates which emulator output these FF?? chunks, and therefore allow your emulator to decide whether it knows their meaning.

To ensure this doesn't clash with anyone else's chosen identification string, I suppose something like the name of your emulator is a good choice.

Valid HTML 4.0!