Availability

ROM cartridge available:
ROM cartridge released: 27th July 2014


Description

The ZXC4 introduces 4 functional improvements over the ZXC3:

  1. An increased FLASH ROM capacity from the 128K of the ZXC3 to a whopping 4096K (i.e. 4MB) - a 32 fold increase! The ZXC4 effectively consists of 256 banks of 16K compared to the ZXC3ís 8 banks of 16K.
  2. The ZXC4 can program all 16384 bytes per bank. The ZXC3 could only program 16320 bytes out of every 16384 byte bank.
  3. Support for the Interface 1 paging mechanism (interception of error handler and CLOSE command handler routines). This allows shadow ROMs to be created to extend Spectrum BASIC, and opens the possibility to use the 4MB FLASH ROM as a Microdrive emulator.
  4. Interception of the LOAD and SAVE routines in the Spectrum ROM, opening the possibility to use the 4MB FLASH ROM as a Cassette Recorder emulator.

The 4MB FLASH ROM of the ZXC4 can be programmed, erased and re-programmed directly from a Spectrum, and so there is no need for an EPROM programmer. The cartridge extends the programmable software bank paging ROM Cartridge mechanism by allowing software to dynamically change the address range used for memory mapped control of the ROM cartridge hardware. At power on the ZXC4 will intercept accesses to the top 64 address locations just as the ZXC3 does ($3FC0-$3FFF), but it can be switched to intercept accesses to the lower 8192 address locations ($0000-$1FFF) instead. Thus when the upper control area is selected it is possible to program bytes $0000-$3FBF, and when the lower control area is selected it is possible to program bytes $2000-$3FFF.

The PCB can be seen below:

ZXC4 ROM Cartridge PCB - Front ZXC4 ROM Cartridge PCB - Back

The ZX ROM Cartridge Creator utility (for Microsoft Windows) allows cassette games in PC emulator snapshot files (.Z80, .SNA, .SZX) to be converted into ROM cartridges, as well as binary files (.ROM, .BIN). The resultant compilation can be transmitted via RS232 to the Spectrum at a baud rate of 57600, and the Spectrum then programs it into a FLASH ROM.

I have a number of ZXC4 ROM cartridges available. If you are interested in obtaining a ready assembled and cased cartridge (supplied with front and rear labels, with the front one intended for noting the cartridge's contents) then please feel free to contact me.

Assembled ZXC4 ROM Cartridge Cased ZXC4 ROM Cartridge PCB

Although the edge connector of the ZXC4 is gold plated, it might still tarnish over time. This can be minimised by occasional application of a small amount of electrical lubricant or polish.


Cost

The ZXC4 ROM cartridge can be purchased directly from me at the following prices:

The RS232 cable is suitable for programming the ZXC4 using the ZX ROM Cartridge Creator utility. It can also be used to connect to a printer (when controlled from a ZX Interface 1 or a copy of the ZX Interface 1 ROM fitted onboard the SPECTRA interface).

Please email me for full payment details, postage costs for multiple items and to check current availability.



Paging Control

The following information will be useful should you wish to write your own assembly language programs to control the ZXC4.

The ZXC4's 4MB FLASH ROM is treated as 256 banks of 16K. To maintain compatibility with the ZXC3, these 256 banks are handled as 32 bank sets of 8 banks each. Therefore the upper control region only allows selection of the 8 banks within the currently active bank set.

At power on the ZXC4 operates in a ZXC3 compatibility mode, intercepting accesses to the top 64 ROM locations ($3FC0-$3FFF) and interpreting them as follows:

ZXC4 PCB Upper Region Memory Mapped Control
Bank Selects between the 8 banks available within the active bank set.
Write Set to 1 to assert the /WR line to the FLASH ROM. Set 0 to return to read mode.
Page Out Set to 1 to page out the ROM cartridge, thereby allowing access to the Spectrum ROM (or Interface 1 ROM if paged in). Set to 0 to page the ROM cartridge back in.
Lock Set to 1 to prevent further paging. This can therefore be used to permanently make a bank of the ROM cartridge visible to the Spectrum, or to permanently page out the ROM cartridge.

The lower control region is selected by accessing an address with the Write and Page Out bits both set to 1 and the Lock bit reset, e.g. $3FD8. The states of the other control bits are ignored. The ZXC4 will subsequently intercept accesses to the lower 8192 ROM locations ($0000-$1FFF), interpreting them as follows:

ZXC4 PCB Lower Region Memory Mapped Control
Bank Selects between the 8 banks available within the active bank set.
Write Set to 1 to assert the /WR line to the FLASH ROM. Set 0 to return to read mode.
Page Out Set to 1 to page out the ROM cartridge, thereby allowing access to the Spectrum ROM (or Interface 1 ROM if paged in). Set to 0 to page the ROM cartridge back in.
Lock Set to 1 to prevent further paging. This can therefore be used to permanently make a bank of the ROM cartridge visible to the Spectrum, or to permanently page out the ROM cartridge.
Bank Set Selects between the 32 bank sets available.
Cassette Paging Set to 1 to enable interception of the LOAD and SAVE routines within the Spectrum ROM. At the end of the first byte of an instruction fetch from address $04C2 (SAVE_BYTES) or $0556 (LOAD-BYTES), the ZXC4 switches to bank 3 within the current bank set. If the instruction at $04C2 or $0556 is a multi-byte instruction (which it may be if the Spectrum ROM is active) then it is necessary to replicate the instruction within bank 3 so that the remaining instruction bytes are still available after paging in the ROM cartridge. The ROM cartridge pages out at the end of the first byte of an instruction fetch from address $04C2, $0556 or $0555. Addresses $04C2 and $0556 allow the ROM cartridge to return control to the Spectrum SAVE and LOAD ROM routines respectively, and address $0555 allows a single byte RET instruction to return control to the routine that called LOAD or SAVE originally. The ROM cartridge pages out after reading the RET instruction but prior to executing it and hence the return will occur within the Spectrum ROM. Note that the Cassette Paging mechanism overrides the ZXC4 Lock function. This means the ZXC4 can be paged out and locked, thereby allowing full access to the Spectrum ROM. When an access to location $04C2 or $0556 occurs, the ZXC4 pages in bank 3 of the currently selected bank set. It is important that the ZXC4 was previously locked with the upper control area active because $04C2 and $0556 lie within the range of the lower control area. Once the ROM cartridge has been paged in via the Cassette paging mechanism, it becomes possible to reset the Lock bit and thus gain access to the other banks of the 4MB ROM. To return to the Spectrum ROM, the Lock bit and bank 3 should be re-selected before paging out the ROM cartridge by executing an instruction at $0555, $0556 or $04C2.
Interface 1 Paging Set to 1 to enable the ZX Interface 1 compatible paging mechanism. At the end of the first byte of an instruction fetch from address $0008 (the error handler routine) or $1708 (the CLOSE command handler routine), the ZXC4 switches to bank 2 within the current bank set. If the instruction at $0008 or $1708 is a multi-byte instruction (which it may be if the Spectrum ROM is active) then it is necessary to replicate the instruction within bank 2 so that the remaining instruction bytes are still available after paging in the ROM cartridge. The ROM cartridge pages out at the end of the first byte of an instruction fetch from address $0700, and a RET instruction is typically placed here and jumped to to make a return to the original calling routine within the Spectrum ROM. The ROM cartridge pages out after reading the RET instruction but prior to executing it and hence the return will occur within the Spectrum ROM. Note that the Interface 1 Paging mechanism overrides the ZXC4 Lock function. This means the ZXC4 can be paged out and locked, thereby allowing full access to the Spectrum ROM. When an error occurs or a CLOSE command is executed, the ZXC4 pages in bank 2 of the currently selected bank set. It is important that the ZXC4 was previously locked with the upper control area active because $0008 and $1708 lie within the range of the lower control area. Once the ROM cartridge has been paged in via the Interface 1 paging mechanism, it becomes possible to reset the Lock bit and thus gain access to the other banks of the 4MB ROM. To return to the Spectrum ROM, the Lock bit and bank 2 should be re-selected before paging out the ROM cartridge by executing an instruction at $0700. For further details on the ZX Interface 1 paging mechanism, refer to the ZX Interface 1 ROM disassembly.

The upper control region can be re-selected by accessing an address with the Lock and Write bits both set to 1 and the Page Out bit reset, e.g. $0028. The states of the other control bits are ignored.

It is possible to enable both the Interface 1 and Cassette paging mechanisms at the same time. If the Interface 1 bank has been paged in then an accesses to the Cassette paging addresses will not cause the Cassette bank to override the Interface 1 bank, and vice versa.

Note that the ZX Interface 2 ROM cartridge mechanism does not allow the differentiation between an instruction fetch and a memory access (read, write or refresh). As a result, any access to an address used by the Interface 1 or Cassette paging mechanisms is sufficient to invoke it. This is a deviation from the real paging mechanism used by the ZX Interface 1 which only intercepts instruction fetches. This means it is not possible to PEEK these paging addresses locations but the impact of this limitation is very minor. A bigger issue is that when the paging mechanisms are enabled when using a Spectrum 128, reads from these paging addresses by the Editor ROM will also cause the ROM cartridge to be paged in. It is therefore necessary for the paged in bank to perform checks to determine whether it was correctly paged in by the 48 BASIC ROM or by the 128 or +2 Editor ROMs.

To use the paging control mechanism from your own assembly language programs, care should be taken to ensure the I and R registers do not contain values that would inadvertently invoke the paging mechanism. Setting the I register to a value between $80 and $BF ensures maximum compatibility on 48K and 128K Spectrums.



Disable Jumper

The top left corner of the ZXC4 contains a 3 way jumper, which is used to enable/disable the cartridge. Should the contents of the FLASH ROM become corrupt or does not include a copy of the ZXC4 Flash Programmer utility then the cartridge must be disabled by placing the jumper across positions 2-3. The ZXC4 Flash Programmer utility can now be loaded into the Spectrum, the jumper moved back to positions 1-2, and then it is possible to reprogram the FLASH ROM.

With the jumper set to disable the cartridge, the current paging configuration is not reset and will become active once the cartridge is re-enabled. This information is not relevant when re-instating the ZXC4 Flash Programmer but might be of use if developing your own custom FLASH programmer utility for the ZXC4.



Compatibility

The ZXC4 is fully compatible with the ROM cartridge socket of the SPECTRA SCART interface for the 48K Spectrum and the Chroma SCART interface for the ZX81.



Downloads

I have produced a set of reference design routines for programming and erasing the ZXC4's 29F032B FLASH ROM, and these can be downloaded for use in your own ROM cartridge programs.

Click here to download the reference design FLASH programming routines for the ZXC4 ROM cartridge.
Click here to download the 29F032B FLASH ROM datasheet.

I have also produced source code examples showing how to use the Interface 1 and Cassette paging facilities, and how to make them compatible with the Spectrum 128 or +2. The ZX Interface 2 ROM cartridge mechanism does not expose the /M1 control line and therefore does not allow a ROM cartridge to differentiate between an instruction fetch and a simple memory read. The Editor ROM of the Spectrum 128 or +2 will therefore inadvertently cause the ZXC4 to page to a shadow ROM if one has been enabled. It is necessary to trap these erroneous page ins and return control back to the Editor ROM. Note that it is possible to combine the techniques demonstrated to allow construction of a ROM program that utilises both the Interface 1 and Cassette paging mechanisms.

Click here to download the example Interface 1 shadow ROM code for the ZXC4 ROM cartridge.
Click here to download the example Cassette shadow ROM code for the ZXC4 ROM cartridge.

I've created a program to allow a ZXC4 ROM cartridge to be tested. The program must run from the first 16K bank of a ROM cartridge. The ZX ROM Cartridge Creator can be used to download the program to the Spectrum for programming into the ZXC4 (note that the Flash Programmer must not be included in the compilation and the paging setting for the test program should be set to 'none'). When the Spectrum is powered on, the test program will automatically run and will execute a sequence of tests. At the end of the test sequence, the ZXC4 locks its paging mechanism. Resetting the Spectrum (using a reset button) should cause the ZXC4 to unlock its paging mechanism and so allow the tests to run again. If the tests run successfully for two consecutive passes then the ZXC4 is working correctly.

ZXC4 Unit Test

NOTE: Running the tests will erase the contents of the ROM, including the Flash Programmer if present. The Flash Programmer will need to be re-instated from a backup afterwards before the cartridge can be re-programmed, so make sure you have a means available to restore it (ZX Interface 1 RS232 or Cassette). The test utility should only be used if you suspect there is a problem with the ZXC4.

Click here to download the ZXC4 Unit Test.