Computers Overview
Commodore PET
Sinclair ZX80
Sinclair ZX81
BBC Micro
Sinclair Spectrum
Memotech MTX
      Hardware Hacks
      Legacy (1980s)
          Special Fit
          Version 1.1
      PAL Reader
      PC Keyboard I/F
    User Groups
    Video Wall
Memotech CP/M
Atari ST
DEC 3000 AXP
Raspberry Pi



The Memotech MTX Series

Martin Allcorn's Games ROM

512KB, 38 Game ROM

512KB, 19 Game ROM

Version 1 (MTX500 / 512) Version 2 (MTX512 only)


(Do you want one ?)

Version 2 ROM Description

The original MAGROM included 38 games, the games included had a number of things in common:

  •  They were all 100% machine code
  • They all ran on the MTX500
  • They were all loaded in one single block of code  

The idea of the 2nd version of the ROM was to expand the range of games available by loading them from .MTX tape image files.

Loading the image files adds a number of complications:

BASIC needs to be set up, and some method needs to be chosen to intercept calls to the OS routine “inout” at &0AAE which most multi stage loaders use to load in additional blocks of code/data. The OS calls paged ROM very early in the start-up sequence. Since the controller software cannot hand control back, it has to duplicate what normally happens once the page ROM returns control to the OS.

The MAGROM V2 ROM therefor does its usual check for the space bar, if it’s not pressed control is passed back to the OS. If it is pressed then the replacement “inout” routine is poked into a safe place in memory, and a check is made for the location on the data ROM. At this point the MAGROM specific setup is complete and the duplicate BASIC setup begins.

Once the VDP is initialised, Graphic 2 mode is selected instead of text mode, and the MAGROM welcome screen and 2 tone beep played. The next section of code is a direct copy from the BASIC source code which sets up BASIC. Some of the routines called are entirely contained in the lower 8k and so can be called as usual. Some are in the lower 8k but call further routines that are now no longer visible, as the MAGROM control ROM is occupying the 8-16k area instead of the expected BASIC or Assem paged ROM. Some routines are located in the unavailable upper ROM.

To get round this a number of additional parts of the OS source have been used to duplicate all the upper ROM parts of the OS that get called directly, or indirectly. These are scattered all through the control ROM, as they have to occupy exactly the same place as their originals, otherwise the indirect calls would fail and crash the system. Once BASIC is set up, instead of printing “Ready” and awaiting a command, the rom waits for a single key press in the same way as the 38 game ROM.

Once a valid key is pressed the internal pointer is set to the start of the .MTX file where it’s been inserted into the 512k data ROM. Control is then passed to a duplicate of the “load” routine from the OS ROM.


The replacement LOAD routine has been modified slightly in that it always performs a LOAD””, and instead of calling the tape based “inout” routine, it calls the ROM based replacement. The final step of the loading sequence also had to be modified in order to give control of the loaded game to BASIC.


The tape loader sets up the stack on exit, and resumes the loaded program with a simple RET return from subroutine instruction. The MAGROM control ROM can’t do this as it needs to page itself out and the correct system ROM back in before BASIC can take over. Fortunately there is a section of code in the low ROM that does this and so that is jumped to instead of the RET. On exit from that routine BASIC begins running the newly loaded program


I had 2 options as to how to intercept and 2nd (or 3rd) stage loaders that call the OS to load additional chunks of code. The data block loaded could be patched “on the fly” or the program could be scanned and patched before being included in the ROM. I chose to use the 2nd method for speed, the game image only needed to be scanned once, instead of every time it’s loaded.


The games included in the new ROM that have multi part loaders all use one of 2 code sequences to call “inout” either CALL #0AAE or JP #0AAE. The scanning software therefore looks for one of the following 3 byte sequences #C3 #AE #0A or #CD #AE #0A and replaces the #0A with #FC.


This put the replacement of “inout” at #FCAE. This address is in the system variables at the bottom of the area allocated to the system stack. It is far enough away from the top of the stack that Basic doesn’t ever reach it. It’s also in an area that is not saved to tape, and so will not be overwritten by the incoming program.


The short piece of code that’s poked in to #FCAE pages in the MAGROM data ROM and calls the ROM loader, and on exit restores the original ROM before returning control to the game.


This has enabled the new ROM to include games that contain sections of BASIC as well as machine code, and also allow games written for the MTX512 to run, as well as those for the MTX500. In fact enough of the games included are MTX512 only, that I called this the MTX512 collection.


The ROM based replacement for “inout” has a lot more work to do that the original MAGROM loader. For each byte that is “loaded” the data ROM needs to be paged in, one byte located within the 512k ROM and then the original memory map restored for the byte to be poked into the correct place.


Re-arranging the memory map twice for each byte loaded does mean this ROM loads slower than the original MAGROM, however at around 4 seconds to load a 40k program it’s still considerably faster than tape!


With chunks of the original ROM scattered all through the controller ROM, there is no room for the data for the welcome screen, instead the first 8k of the data ROM is used for that, meaning “only” 496k is available for program storage. Of that 496k 494 1/2k is used for programs, which is actually more than the MAGROM 1 used out of the 504k it has available.  This is because it’s optimised to emulate the tape, the new loading system is more efficient in its use of the space available.


Martin's Games ROM Menu running on an MTX500

Running the "finished" version of the software, version 1.00, with 38 games loaded, this requires a 512k ROM.

Version 2 of the Games ROM - The MTX512 Collection




mailto: Webmaster

 Terms & Conditions