Guides

Version:
1.0
Author:
Mike Halliday
Coding
Advanced
Download Guide Files

MSX ROM file porting to Tatung Einstein ...................................................................1

What is ROM porting? ..................................................................................................2

What you need for porting ROM files. ........................................................................3

Step by step guide ........................................................................................................4

Things to consider and look out for (Gotcha’s) ........................................................16

AY Register Patching. ..................................................................................................17

MSX ROM file porting to Tatung Einstein

Step by step guide

Written by Mike Halliday 2025

For Windows machines (Tested on Win 11)

What is ROM porting?

Rom porting is a process of taking a .ROM file from one Z80 based computer system and making it work on another Z80 based computer system.

The MSX and Tatung Einstein home computers from the early to mid 1980s shared almost identical hardware.

Converting or Porting the ROM file from the MSX to the Tatung Einstein is not an easy task, but with time and perseverance, it is possible to make any 32KB .ROM file from an MSX 1 computer run on the Tatung Einstein (TC01) computer.

This guide shows you the basic principles of ROM porting, but due to the diverse programming techniques used on the MSX1, it is impossible to show how to port every available ROM file.

So far, at the time of writing this document, 8 ROM files (all games) have been ported to work on the Tatung Einstein.

As Joe Blade is the newest ported ROM, it will be used as an example in this document.

What you need for porting ROM files.

These files are available in the archive accompanying this document.

DZ80W – A Windows based Z80 disassembler – Used to convert the .ROM file to .ASM to allow for the checking of I/O port usage in the MSX rom.

SJASM – A Windows based command line Z80 assembler and linker. Used to recompile the .ROM file into a .COM file that can be run on a Tatung Einstein.

msxROM.src - A Z80 source file containing modifications needed to get the MSX .ROM file running on the Tatung Einstein.

libstdc++-6.dll - Windows Dynamic Link Library

epcompress.exe - Windows based command line program to compress the compiled files ready for linking.

<rom to convert>.src - A Z80 source code file containing routines needed to bypass certain MSX rom calls and allow the ROM file to work on the Tatung Einstein.

<rom to convert>_pack.src - Z80 ‘pack’ file for this ROM.

_compile.bat - Batch file containing all the commands needed to recompile the files.

MSX .rom file of your choice – All Roms used for porting MUST be 32KB in size. It is possible to port 64KB rom files, but that is beyond the scope of this document.

MSX ROM files can be found here: https://download.file-hunter.com/Games/MSX1/ROM/

When initially running the above _compile.bat I received an error about missing runtime

files. These errors were fixed by installing Z88DK – A “C” compiler for Z80 target machines.

Z88DK can be downloaded from here: https://z88dk.org/site/

Step by step guide

1. Download and install DZ80W - Windows GUI version

2. Download and install Z88DK (Needs "<install>\bin" folder to be in the system path) - Only needed to fix any runtime DLL errors.

3. Download your MSX1 rom (32K max file size, otherwise it will be too big to run)

4. Run DZ80w and use these options

Tick: opcodes, addresses, auto name output, relative comments and auto blank lines

Set Start to 16384

Set End to 49152 (32kb rom or 32768 for 16kb rom)

Set File Start to 16384

Set Radix to: Hex

References: Tick Input and output to generate files where in/out IO is used

(Optional).

Click OK

5. Browse for you 32Kb .ROM file

Click Open

6. Click Disassemble.

The disassembly file and/or reference files are saved to the source folder.

7. Edit the .ASM file - Lines should start at 4000.

8. Update _compile.bat with the name of your game. Search and replace [game name] with the actual name of the game. Make sure you rename the other files exactly the same as in the _compile.bat file.

_compile.bat

sjasm [game name].src [game name].bin epcompress -raw -m6 [game name].bin [game name].m6 sjasm [game name]_pck.src [game name].COM

9. Rename [game name].src and [game name]_pack.src to the name of the file in

_compile.bat

10. Edit your renamed [game name].src file and change the very last line (incbin) to be

the name of the downloaded 32KB MSX rom file. Save the file.

11. Edit your renamed [game name]_pack.src file and change the second to last line

(packed incbin) to your renamed [game name].m6

12. Edit the disassembled .asm file. It will be used to check if the game contains IN/OUT instructions. except ROM page in IN/OUT's in the beginning of the rom, and VDP IN/OUT's if the VDP port address is either 0007h or 0006h.

You may find some header lines, then a blank line or a list of NOP (No operations).

This is usually the MSX memory paging and can be ignored.

14. Open your renamed [game name].src file, then open the .ASM file making sure you are at the top (line 1). Tip: I use Visual Studio Code and have both files open side by side.

In your .SRC file, the first 7 lines always stay the same. This is the memory entry point address when loading the Rom on the Tatung Einstein.

Your Rom modifications should be added after the “;game specific code start” comment.

For Joe Blade, there were a lot of VDP calls on the MSX that need to be converted to VDP calls on the Tatung Einstein.

In the .ASM file, search for “out (98h),a” [The spaces are needed]

As you can see, there are 76 occurrences of writing to the VDP port on the MSX.

Luckily we do not need to take action against all of them.

In your .SRC file add the following line.

ld a,08h

You have now loaded value 08h into accumulator register a.

In your .ASM file, the first column shows the memory address of the ROM file where the VDP write takes place.

Add the following line to your .SRC file

ld (7248h+01h),a

You have now loaded 08h into the memory address 7248h+01h.

Search for the next occurrence of “out (98h),a” in your .ASM file.

Add the next memory address line into your .SRC file.

ld (808eh+01h),a

Repeat this process 7 more times until you reach 8ab0 in your .ASM file.

From 8ab0 to 8bac can be ignored for the moment as there are over 60 of these calls and adding a line for each is over kill. (See later on in this document)

There should be 3 more occurrences of “out (98h),a” left in the .ASM file.

Add these to your .SRC file

I also documented each line for future reference.

Address 8aac in the .ASM file needs updating from 20h on the MSX to 40h on the Tatung Einstein.

Add this line next in your .SRC file.

ld b,40h

Now, remember the large block of “out (98h),a” calls in the .ASM file.

We can address these now with a loop so minimal code is used in the .SRC file.

In your .SRC file, add the following lines;

ld hl,8ab0h+01h this sets the address to be 8ab0h (Line 16752 in .asm)

instead of 0e966h (Line 16748 in .asm)

fillvdp ld (hl),a

inc hl

inc hl

inc hl

inc hl

djnz fillvdp

Fillvdp creates a label for the next block of code and the start of the loop block.

ld (hl),a writes the 8-bit value currently held in the Accumulator register (A) into the memory address specified by the 16-bit contents of the HL register pair.

Inc hl increments the 16-bit value currently stored in the HL register pair by 1. (Repeat 3 more times to make 4 increments in total)

Djnz fillvdp Decrement B register, if B!= 0, jump back to FILLVDP

The above loop block has eliminated 60+ separate “ld” lines of code.

At the start of your .ASM file you will see a block of code that loads the ROM into memory pages before executing. On the Tatung Einstein this is not available, so not needed.

In your .SRC file, add the following;

ld hl,4010h

This replaces the source memory address on the MSX (line 23 in .asm) with a Tatung Einstein friendly memory start address.

ld de,4011h

This adds the destination memory address (next free memory address)

ld bc,401eh-4010h-1

This calculates the length of the memory block to load (line 28 - line 23 -1)

ld (hl),00h

Now, write a 00h byte to the starting address (4010h).

ldir

Load, increment and repeat.

The remaining lines need to be added to clear down any music in memory.

;clear music work area

ld hl,0fa00h

ld de,0fa01h

ld bc,00ffh

ld (hl),l

ldir ; Load, increment and repeat

The remaining code in your .SRC file should be left alone as the code is none game specific and used for all Roms.

15. Save your changes.

16. Run _compile.bat from an elevated/Admin command prompt and your converted rom should compile.

17. If you get 0 errors, use EDIP to write the .COM file to an Einstein compatible .DSK image for use in Mame. You can use the XTAL205_40TSS.DSK file in this folder as the basis of your blank disk image, ready to inject your new .COM file.

18. Insert your .DSK image into MAME under the Einstein TC01 floppy and run the Einstein emulator.

If your game crashes, you will need to do some debugging of your code and update where necessary.

If your game runs, CONGRATULATIONS, you have created some new software for the Tatung Einstein!

If you have the physical hardware, you can transfer the .DSK image to a real floppy or a Gotek drive and try it out.

Things to consider and look out for (Gotcha’s)

Some MSX Roms have copy protection in them which will immediately stop the Rom from working on the Tatung Einstein.

An example of this is Double Dragon.

Search your .ASM file for “im 1”

The first column is the memory address of the MSX Rom where the protection exists.

In your .SRC file add the following lines

ld (50cbh),a ;remove game protection

I am not sure this line is needed, but it was in the file provided to me for the Double Dragon

port, so I have left it in here just in case.

ld hl,0000h

ld (4011h),hl ;remove im 1

Above, you are writing 0000h to the address where the “IM 1” occurs. This effectively

renders the protection inoperative.

AY Register Patching.

Double Dragon also requires additional code to make it work.

In the .SRC file for Double Dragon, after the VDP patching, the following was added.

;patch AY register value 03h instead of MSX AY register 0a1h call

ld a,0cdh

ld hl,AYwrite_C

ld (6c2fh),a

ld (6c30h),hl

ld a,3eh

ld (50cbh),a ;remove game protection

ld hl,0000h

ld (4011h),hl ;remove im 1

ld a,0c3h

ld hl,dragret

ld (824eh),a

ld (824fh),hl ;patch pop hl, ei, ret to jump to pop hl, ei, reti in ROM

AYWrite_C and dragnet labels can be found in the msxROM.src file and contain additional Z80 code to perform the required operations on the Tatung Einstein. You need to understand Z80 programming to fully understand what is being performed.