.COM to .mtx


Back in the days of Continental Software, there was a BASIC program which displayed the Continental Software logo, and then loaded a game, which immediately followed it. The game was a chunk of assembler, intented to run at an address above 04000H (probably 04100H, but I forget).

This package includes Loader.mtx, which does something similar, for .COM files (assembled to run at 00100H), and without the logo. It should be good for files upto 46KB or so.

Using Paul Daniels mtx2bas program, we can see how it does it :-

$ mtx2bas Loader.mtx
mtx2bas v0.4. Options: . File Loader.mtx.

MTX Filename: Loader          STKLIM: 0xF8F2. SYSTOP: 0xFB4B.


10 GOSUB 30

0x400F  31 00 F8             LD SP,#F800
0x4012  AF                   XOR A,A
0x4013  32 D2 FA             LD (#FAD2),A
0x4016  D3 00                OUT A,(#0)
0x4018  3C                   INC A
0x4019  32 68 FD             LD (#FD68),A
0x401C  21 80 40             LD HL,#4080
0x401F  11 0E 00             LD DE,#E
0x4022  CD AE 0A             CALL #AAE
0x4025  21 00 41             LD HL,#4100
0x4028  ED 5B 8C 40          LD DE,(#408C)
0x402C  D5                   PUSH DE
0x402D  CD AE 0A             CALL #AAE
0x4030  F3                   DI
0x4031  21 41 40             LD HL,COPY
0x4034  11 00 F8             LD DE,#F800
0x4037  01 0E 00             LD BC,#E
0x403A  ED B0                LDIR
0x403C  3E 80                LD A,#80
0x403E  C3 00 F8             JP #F800
0x4041  D3 00       COPY:    OUT A,(#0)
0x4043  21 00 41             LD HL,#4100
0x4046  11 00 01             LD DE,#0100
0x4049  C1                   POP BC
0x404A  ED B0                LDIR
0x404C  C3 00 01             JP #100
0x404F  C9                   RET

COPY          4041  
30 VS 4:INK 12:PAPER 1:COLOUR 4,1:CLS 
40 CSR 2,20:PRINT "Please wait, Program LOADing"
1000 SAVE "Loader":RUN


Back in the days of Continental Software, there was a program called CSAVE.COM. It would be used to save the chunk of assembler in Memotech tape format.

It would save a 14 byte header comprised of

8 bytes filename
3 bytes extension
2 byte length

This was then followed by the file content.


If you have a game in CP/M .COM file format, you should be able to use the COM2mtx.sh in this package to prepend Loader.mtx to make an .mtx file for it. It writes the game content in the same format that CSAVE.COM did.

eg: assuming you start with SMG.COM (36KB)

$ ./COM2mtx.sh SMG
$ memu -s -v SMG.mtx

Note that the game must not assume anything about the initial state of the system, such as interrupts being disabled, or not configured at the CTC. ALPHA.COM is an example of a game that fails because it assumes the CTC is not configured.


COM2MTX can be downloaded from http://www.nyangau.org/com2mtx/com2mtx.zip.

Copying of this program is encouraged, as it is fully public domain. Even the source code is included in the package. It was created on the authors time and equipment. Caveat Emptor.

The author of COM2MTX and this documentation is Andy Key (email andy.z.key@googlemail.com).

{{{ Andy