Software - Utilities

ZX ROM Cartridge Creator

The ZX ROM Cartridge Creator is a Windows based utility originally created to allow the generation of Spectrum ZX Interface 2 ROM cartridge files, but has been extended to allow the creation of multi-program ROM cartridge files for use on the ZX81. It provides support for the ZXC2, ZXC3 and ZXC4 ROM cartridges.

The utility allows a compilation of up to 254 program (.P, .P81) and ROM (.BIN, .ROM) files to be constructed, and will automatically generate a menu system that will allow the selection of the program to run when the ROM cartridge is powered on. For the ZXC3 and ZXC4, the compilation can be sent via RS232 at 57600 baud to the ZX81 and the ZX81 will then program the compilation into the ROM. For the ZXC2, a binary file can be created but must be programmed into an EPROM using an EPROM programmer.

Each program file in a compilation can be assigned a colourisation file, which specifies the ink and paper colours for each displayable character. When the program is selected from the ROM cartridge menu, the user is presented with the choice of running the program colourised or in black and white. If colourisation is selected then Chroma will be configured using these colour definitions before the program is copied into RAM and run.

Each program file in a compilation can also be assigned a character file, which specifies an alternate character set to display the program with. When the program is selected from the ROM cartridge menu, the user is presented with the choice of running the program using the alternate character set or the standard Sinclair character set. If the alternate set is selected then Chroma will be configured using to show these before the program is copied into RAM and run.

A screenshot of the Cartridge Creator showing a ZX81 compilation can be seen below:

ZX ROM Cartridge Creator


Program Files

Emulator program files (nameless .P and named .P81) allow the majority of ZX81 programs to be converted into ROM cartridges.

To convert a program, a few bytes of RAM are required and the safest place to attempt to obtain these from is the stack. Although this will work fine for the majority of programs, some might become corrupted if there is not enough stack space spare.

Note that programs that load in multiple parts, e.g. Software Farm's Z-Xtricator, are not directly supported. To incorporate these programs into a compilation it is necessary to load all parts into an emulator, then save the RAM contents up to the stack, and then modify the e_line system variable so that it points to the end location. I have successfully applied this technique to Software Farm's Z-Xtricator.


ROM Files

ROM image files (.ROM and .BIN) can be incorporated into a multi-program cartridge, thereby allowing alternate ROMs such as the FORTH ROM from Skywave Software or the ASZMIC ROM from Comprocsys Ltd to be run.



Creating a Program Compilation

To create a compilation, select the target as 'ZX81' and choose the desired ROM cartridge type. The Memory Type field is populated with the choice of applicable ROM types for the chosen cartridge. The Include Programmer option allows selection of whether to embed the Flash Programmer utility in the ROM image being created (applies to ZXC3 and ZXC4 only). The Flash Programmer utility is the means by which the ZX81 can program the FLASH ROM and including it means that it can be invoked at any time to allow the ROM to be re-programmed. The Flash Programmer utility is described later on.


Select Programs

Once the target type has been chosen, programs can be selected via the Add button located on the toolbar (or from the Edit menu). It is also possible to drag-and-drop files from Windows Explorer into the compilation list area. A range of sub-options allow direct selection of a particular program type, e.g. ROM images only. Programs can also be adding by pressing the Insert key. Programs can be removed via the Remove button in the toolbar, from the Edit menu, or by pressing the Delete key. When Add is clicked, a dialog window is displayed which allows selection of the programs to insert and allows only files of the chosen type to be shown. The utility remembers the file type selected and will default to this next time the dialog is invoked.

Once one or more programs have been selected, they are added to the compilation list within the middle area of the utility's window. This area shows a summary of details for each program. Fields show the file name of the program, the size the program occupies within the ROM image, the RAM required to run it, its type, and the text to use for the program within the automatically generated menu system (the default text is based on the program's file name). The remaining fields allow the name of the publisher, the year of release and reference information (such as a version number, catalogue number, or hardware requirements such as WRX support) to be set. These details will be displayed by the menu system produced for the cartridge compilation. The menu entry text and the other fields shown for the program can be set via the options presented in the Program Details area, as described later.

The Cartridge Creator utility also provides functions to re-arrange the order that the programs appear within the menu. This is done by selecting the program to move and then either clicking the Move Up and Move Down buttons from the tool bar or by pressing keys Ctrl+7 and Ctrl+6. Re-arranging the programs does not affect how they are actually stored within the PROM. All variable length programs are packed into the PROM space first, i.e. programs files, and then after this appear all ROM image programs. This is because ROM image programs always need to begin in their own bank and are deemed to be multiples of 16K, and hence can be placed in adjacent banks without leaving any voids. The utility also provides functions on the toolbar for sorting the list of programs based on one of the fields: Title, Program Type, RAM, Publisher, Reference or Year.


Assign Colourisation Files

The Cartridge Creator supports the colourisation mechanism provided by the Chroma 81 interface. Every program (excluding ROM images) can have a colourisation file assigned to it. A colourisation file uses XML formatting to specify the ink and paper colours that each character should be displayed in. Colourisation files can be created using a standard text editor and can be associated with more than one program if desired. Programs that have a colourisation file assigned will appear in the compilation list in red.

When a program with a colourisation file assigned to it is selected from the ROM cartridge menu, a choice is presented to run the program colourised or in black and white. If the colour facilities provided by the Chroma 81 interface are disabled via configuration switch 6 then a message is displayed to indicate this.

A detailed description of the colourisation file format can be found here, with a selection of colourisation files available here.

A program file and colourisation file data must all fit within a 16K block of the ROM cartridge, and so it might not be possible to assign a colourisation file if a program is very large.

Note that a colourisation file designed for use with a ZX80 4K ROM program can be assigned to a ZX81 program. This allows the potential for sharing a single colourisation file between the two computers.


Assign Character Files

The Cartridge Creator supports the QS Character Board emulation provided by the Chroma 81 interface. Every program (excluding ROM images) can have a character file assigned to it. A character file uses XML formatting to specify the bit patterns for each character. Character files can be created using a standard text editor and can be associated with more than one program if desired. Programs that have a character file assigned will appear in the compilation list in blue, and those that also have a colourisation file assigned will appear in magenta.

When a program with a character file assigned to it is selected from the ROM cartridge menu, a choice is presented to run the program with the defined character set or with the standard Sinclair character set. If the QS Character Board emulation facility provided by the Chroma 81 interface is disabled via configuration switch 4 then a message is displayed to indicate this.

A detailed description of the character file format can be found here, with a selection of character files available here.

A program file, colourisation file data and character file data must all fit within a 16K block of the ROM cartridge, and so it might not be possible to assign a colour and / or character file to a program if it is very large.


Generated Menu

When more than one program is included in a compilation then a start-up menu will always be created and embedded within the cartridge image. The menu will be displayed when the cartridge is powered on and provides a method for selecting which program to run. If only a single program is included in a compilation then it is optional whether to create and embed a menu. A delay will occur at power on while the program waits for the Chroma hardware to stabilise. If the colour facilites are enabled via configuration switch 6 then the border will turn black once the menu is ready for use.

Example ROM Cartridge Menu

The menu displays the title of the cartridge, followed by a list of all programs within the cartridge. The title text can be set via the entry in the Cartridge Details area in the Cartridge Creator (as described later). Keys 7 and 6 are used to navigate the menu items and NEWLINE (or 0) is used to run the highlighted program. If there are more programs than can fit on the screen then indicators will be displayed to show that the menu can be scrolled. Scrolling past the end or beginning of the compilation list will cause a wrap around. To aid navigation, the up and down keys will auto-repeat if held down. The menu system also supports page up and page down controls, accessed using 5 and 8 respectively. When navigating the menu, details about the currently selected program are displayed at the bottom of the screen. This consists of the text specified for the Publisher, Year and Reference fields for the program within the Cartridge Creator.

The menu system always contains a Disable ROM Cartridge entry, which allows the internal ZX81 ROM to be run. The cartridge will be completely disabled and avoids the need to physically remove the cartridge in order to use the ZX81 without it.


Short-cut Key

Holding down the SHIFT key as the ZX81 is powered on causes the cartridge to be disabled and passes control to the ZX81's internal ROM.


Create Data File

Once a list of programs has been defined, the compilation can be written to a file by selecting the Create button. Two output file formats are supported, with the format to produce selected by choosing the appropriate file type from the save dialog.

Selecting .BIN format produces a binary ROM image suitable for direct programming into a PROM of the minimum size stated (or larger) using an EPROM programmer. It also creates an archive of the compilation output, which can subsequently be added to a blank compilation (with the Flash Programmer omitted) and downloaded to the ZXC3 or ZXC4 for programming into a FLASH ROM. This avoids the need to regenerate the compilation from the input files.

Selecting .PRG format produces a file that contains the data formatted for transfer over RS232, which can subsequently be sent from a terminal program. This can be useful if running the Cartridge Creator within a virtual machine since some virtualisation software packages do not appear to respond rapidly to the serial handshaking lines.


Send Data via RS232

The Send button can be used to transmit the compilation to the ZX81 via an RS232 link. The serial port to use can be selected via the drop down list next to the Send button, which will show all serial ports detected on the PC. Communications to the ZXC3 and ZXC4 occurs at 57600 baud with 8 data bits, no parity, 1 stop bit, and hardware handshaking.


Compilation Functions

The Cartridge Creator utility provides functions for saving the current program compilation, loading a previously saved compilation, and for creating a new blank compilation. A compilation can also be loaded by dragging it in to the file list area of the Cartridge Creator, or by double clicking a .zxc compilation file.


Cartridge Details Area

The Cartridge Details area contains a number of fields relating to the current compilation:

Field Description
Title This field allows the text to use as the cartridge title within the menu to be specified.
Memory Type This field allows the ROM type to be selected for the target ROM cartridge. For a ZXC2 it is fixed at PROM, and for a ZXC4 it is fixed at FLASH.
Include Programmer This field allows selection of whether to embed a copy of the Flash Programmer utility within the ROM image. The advantage of embedding it is that it can be invoked at any time in the future to allow the cartridge to be re-programmed. However, it may be desirable to omit it if additional space if required for a larger program compilation. In such a case, it would be necessary to load the Flash Programmer utility from a back-up, e.g. cassette, in order to re-program the cartridge. This option applies to the ZXC3 and ZXC4 only.
Start-up Type By default a menu is only included within a cartridge compilation if there is more than one program included. For a compilation consisting of a single program, a smaller block of start-up code is used instead of the menu. This start-up code checks the SHIFT key and will disable the ROM cartridge if it is being pressed, else it will performs any initialisation required in order to run the program. However, it may be desired that the menu system is included even when there is only a single program in the compilation so that the Disable ROM Cartridge option is available. If so then this can be achieved by changing the Start-up Type field from 'Auto' to 'Menu'.
Programs This read-only field displays the number of programs included within the compilation.
Required Memory This read-only field shows the smallest capacity ROM required to contain the compilation. For the ZXC4 this field is fixed at 29F032B.
Program Data This read-only field displays how much space is being occupied by all of the inserted programs.
Menu Code This read-only field shows how much menu or start-up code is required.
Programmer Code This read-only field displays much space is occupied by the Flash Programmer utilty.
Free Space This read-only field shows how much space is available for further programs.


Program Details Area

The Program Details area contains a number of fields related to the program currently highlighted within the compilation list. This information will appear at bottom of the screen when a program is highlighted in the menu.

Field Description
Name This mandatory field allows the text that is used in the menu system for the program to be specified. There are no formatting requirements for this field.
Publisher This optional field allows the name of the publisher of the program to be set. There are no formatting requirements for this field.
Year This field allows the year the program was released to be specified. The field only allows entry of values between 1980 and the current year, either selected from the drop down list or by direct typing.
Ref This optional field allows additional reference information about the program to be set, e.g. version number, catalogue number, requires WRX graphics, etc. There are no formatting requirements for this field.
RAM This field is mandatory and is used to specify the amount of RAM to run the program with. It will default to 1K if the program is small enough, else it will be set to 4K if appropriate, else 16K. Its effect is to simply set the location of the stack and the system variable RAMTOP. A larger RAM size can always be selected if desired.
Type This read-only field indicates the nature of the program, e.g. 'ROM image' or 'ZX81 program'.
File This read-only field displays the full path and file name of the program.
Chars This read-only field displays the full path and file name of the associated characters file. A characters file can be disassociated by clicking the 'X' button that appears next to the field.
Colour This read-only field displays the full path and file name of the associated colourisation file. A colourisation file can be disassociated by clicking the 'X' button that appears next to the field.
Data This read-only field shows how much space the program occupies within the PROM, taking into account any compression that has occurred.
Menu This read-only field displays the amount of space taken to add the program into the menu, and so this figure will vary with the lengths of text entered into the Title, Publisher, Ref and Year fields.
Paging This read-only field indicates how much space within the span of the program's storage area is unavailable due to the ZXC memory mapped paging mechanism. The paging mechanism utilises the last 64 bytes of each 16K bank of the PROM and so is unavailable for programs (with the exception of ROM images that fit within a single bank and do not require use of the paging facilities).
Padding This read-only field shows the amount of other space contained within the program's span in the PROM that could not be used for storing the program. Padding can occur due to the following reasons:
  • Each program is stored within its own 16K bank, along with any associate colour and character files. This will typically leave unused space at the end of the bank.
  • A void area may be caused to avoid accidentally invoking the hardware 'fix' Sinclair fitted to some ZX81s to correct the infamous floating point bug present in the first edition ROM. The fix only partially decodes the instruction fetch address and so actually traps 8 addresses ($0335, $0735, $1335, $1735, $2335, $2735, $3335 and $3735), but the only address that will be intercepted when using a first edition ZX81 ROM is $1735 (the other locations contain the operand for an instruction and not the opcode). However, the Cartridge Creator must ensure that instructions do not occur at any of the eight locations.
  • A void area will be introduced by inserting ROM images that are not exactly multiples of 16K. For example, the Skywave FORTH ROM is only 8K is size and so padding will be inserted until the next 16K bank is reached.
Auto-Run Line This field displays the line number that the program will start running from when loaded, or 'None' if the program is not configured to automatically run. The field consists of a drop down list containing all the BASIC line numbers detected within the program and can be used to specify the line that the program should start running from when loaded. The field will be disabled for ZX81 programs that already have an auto-run line number set.
Paging Locked This field indicates whether the ZX Cartridge paging mechanism will be locked. It will be set to locked for a program file but can be altered for a ROM image. Leaving a ROM image unlocked allows it to page back and forth to the ZX81 ROM or to the other banks of the ROM cartridge. Locking a ROM image allows it access the full 16K of the ROM address space, but does require the inclusion of a small start up routine to perform the locking prior to running the ROM.


Flash Programmer Utility

The Flash Programmer utility is used to program a ZXC3 or ZXC4 directly from the ZX81 without the need for an EPROM programmer. It runs from the ZX81's RAM and provides functions for accepting data via RS232 from the Cartridge Creator utility and then writing this data into the FLASH ROM. The Flash Programmer utility will usually be stored in the FLASH ROM alongside any programs written to it. This allows the utility to be invoked at any time to allow the ROM to be re-programmed. Initially, only the Flash Programmer utility is present in the ROM and so it will automatically run when the ZX81 is powered on. Specific versions of the Flash Programmer exist for the ZXC3 and the ZXC4.

Four menu options are presented by the Flash Programmer utility:

ZXC4 Flash Programmer Utility Screenshot

The FLASH ROM can be considered to consist of multiple banks of 16K. Only one bank can be programmed at a time and so data for each bank is transferred separately. The data for a bank may be sent as multiple blocks, thereby avoiding sending regions of 'blank' data ($FFs). However, typically there will only be two blocks per bank since the maximum block size is 8K. Prior to loading data each block, the utility displays information on how many blocks there are to be transferred and which block is due to be received. For the block being received, the utility shows the bank number, the address within it and the length of the data. The ZXC3 is not capable of programming the last 64 bytes of each 16K bank, whereas the ZXC4 can program all bytes.

After a block has been loaded it is programmed into the FLASH ROM, and then the utility proceeds to load the next block. The screen display cannot be maintained while data is received via RS232 and so will show a pattern similar to that which appears when loading from cassette. While the FLASH ROM is being programmed, the screen will most be black with occasional white streaks.

Once all blocks have been loaded and programmed, the utility provides the option to run the installed ROM compilation image. Pressing the BREAK key (SHIFT and SPACE) will return to the Flash Programmer menu, or pressing any other key will run the installed ROM compilation image. If the menu is returned to then the ROM compilation image can be run by selecting the RUN INSTALLED APPLICATION option. Alternatively, it can be run by restarting the computer using the reset button provide by the Chroma 81 interface.

If the option to embed the Flash Programmer utility was selected when generating the cartridge image, then a small bootloader routine will be present in the FLASH ROM and is run first when the ZX81 starts up. This routine performs the following actions:


Re-instating the Utility

The Flash Programmer utility can be omitted when producing the ROM compilation image thereby freeing up additional space for more programs. However, to reprogram the cartridge requires loading the Flash Programmer from a cassette (or alternate) backup.

To re-program a FLASH ROM that does not contain a copy of the Flash Programmer utility, the following procedure can be used:

It is strongly recommended to keep a backup of the Flash Programmer on cassette just in case the FLASH ROM become corrupted and the Flash Programmer will no load from it. To create a backup of the Flash Programmer, select the 'BACKUP PROGRAMMER TO CASSETTE' option. Start the cassette recording when prompted and then press any key.


Communications Format

The ZX81 uses the same ZXC3 RS232 communications protocol and ZXC4 RS232 communications protocol as used by the ZX80 and Spectrum. This means that a ROM cartridge containing the Flash Programmer utility for the ZX80 or Spectrum can receive a ZX81 compilation and hence can program the FLASH ROM for subsequent use on the ZX81. Likewise, the Flash Programmer utility for the ZX81 can receive a ZX80 or Spectrum compilation and program the FLASH ROM for subsequent use on the ZX80 or Spectrum. The communication protocols used for the ZXC3 and ZXC4 are different to ensure that a compilation can only be programmed into the appropriate FLASH ROM.


Downloads

Click here to download the ZX ROM Cartridge Creator [V3.8.0] utility.