Legacy Windows emulator
Archived documentation for my original Microtan 65 emulator for Windows 95, 98, NT 4 and 2000.
This is a full-featured Microtan 65 emulator designed to run on an IBM-compatible PC running Windows 95, 98, NT 4 or 2000. It is preserved as historic software and is not the same project as the current Linux/WSL2 emulator.
It emulates a Microtan with the following specification:
- 6502 at 0.75 MHz, 1.5 MHz and 3 MHz.
- 44 KB of RAM.
- XBUG.
- BASIC.
- Dual AY-3-8910 sound card, giving six sound channels and two noise channels.
- Space Invasion sound hardware.
- Two 6522 VIAs.
- Basic serial-port support through a built-in terminal emulator, rather than full serial-hardware emulation.
- Hexadecimal keypad or full ASCII keyboard.
- Full backplane providing paged memory.
- Three high-resolution 256×256 graphics cards giving an eight-colour display.
It can also load files generated using a two-pass assembler. The system is fully emulated, including interrupts and the Microtan’s single-step facility. Program trace, memory-access breakpoint and memory-access table facilities aid program development.
The emulator, games and two-pass assembler are preserved on the software and downloads page.
Why bother?
My first experience with computers was in 1978, when I used a Commodore PET at school. I managed to persuade my parents to buy me a computer for Christmas a year later. I wanted a Microtan because I had been using BASIC until then and had decided it was too slow, so I wanted to learn machine code. At the time, the only alternative was a Sinclair ZX80, which had BASIC on it. I realised that if I had a machine with BASIC on it, I’d never get around to learning machine code—so Microtan it was!
During the early 1980s, I wrote around 20 games and other programs for the system, which I was quite proud of. Before starting the emulator, I attempted to get it all working after a couple of years in a cupboard—the Microtan, not me. Unfortunately, the keyboard interface had failed. Although I got it working again, I realised that the machine wouldn’t last forever. As I was quite fond of it—it is probably directly responsible for the fact that I now spend most of my time sitting in front of a PC screen; did I say “fond”? Hmm—I decided to (almost) immortalise it in an emulator.
How it all went
I started by writing the 6502 emulator. This is an incredibly tedious task requiring much patience and coffee. It took quite a while because I kept getting bored.
When I’d done that, I wrote the display emulator. This didn’t take very long and wasn’t too dull. The first version drew the characters into the window as required and scaled the display to fit the window. I realised that this was going to be far too slow, so I created all the characters in advance and copied them to the window as necessary. Although much faster, it does mean that the “screen” doesn’t continuously scale to fill the window—you get jumps in character size.
Once I’d done that, I dumped the Microtan ROM images into it and was amazed to see “TANBUG” on my screen! I really hadn’t expected that. I added ASCII keyboard and hexadecimal keypad emulation. I needed to emulate the hexadecimal keypad because the ASCII keyboard only sends the ASCII code of the key pressed; it is not possible to determine when the key is released or whether several keys are pressed. The hexadecimal keypad is scanned and is therefore more suited to playing games.
Then I loaded a couple of the Games Pack games into it. These had already been converted from tapes by Fabrice Frances. They mostly worked, but they did reveal an error in the 6502 emulation involving ADC and SBC in decimal mode.
Next, I wrote a program to convert my old tapes into binary images. This had to work for both 300-baud and 2,400-baud dumps, as not all my 300-baud copies had survived. The 2,400-baud decoder still needed work, although I did manage to convert quite a few tapes.
I sent the emulator to Fabrice, and it took his machine out! This was a bit upsetting because I couldn’t reproduce the problem. After some searching, I found a machine that did behave a little oddly. The cause of the problem was eventually located and fixed, and I was off again.
During this time, I added emulation for the AY-3-8910 sound card. This required DirectX 5 or later to work properly. Although it tried to do something with versions earlier than 5, it was not very good. I also added emulation for the 6522s on the Tanex board, as I used the timers to generate “random” numbers and at least one game used a timed interrupt to play a tune.
The ability to load standard Intel HEX files was then added so that a PC-based 6502 two-pass assembler could be used for program development. Several debugging utilities were added to aid in writing and converting programs.
Emulation for the sound hardware of the Space Invasion machine was then added. This hardware worked by taking bits on the keypad column select at BFF2 high—one bit for each sound type. This is not truly authentic emulation for two reasons:
- I’ve never built the real hardware, so I have no idea what it really sounded like.
- As the hardware used the keypad scan lines, it was a bit noisy with a normal Microtan, so I moved it from address
BFF2to addressBC04.
When the Space Invasion hardware is used, the AY-3-8910 emulation automatically stops, and vice versa.
Finally, I modified my games—and Space Invasion—to use a “joystick” plugged into the first 6522 VIA, so the user did not have to switch back and forth between keyboards. Some of the games were originally written to use this; I made an adaptor socket for an Atari joystick. When I decided to pass them on to Microtanic, I rewrote them to use the standard keypad.
Work recorded as remaining at the time
- Convert more games to use the joystick instead of the hexadecimal keypad.
- Convert the remaining tapes.
- Improve sound emulation for versions of DirectX earlier than 5.
- Improve the speed of display updating.
- Speed up the 6502 emulation.
- Fix reported bugs.
- Add high-resolution graphics emulation. This was initially omitted because it would be slow; it was subsequently included in the March 2004 version.
Using the emulator
System requirements
- A Pentium 120 running Windows 95, 98, NT 4 or 2000.
- DirectX 3 or later for sound emulation; version 5 or later is preferred, principally for NT 4.
It will run on slower machines, but screen refresh and emulator speed may be reduced. Without DirectX, the emulator will still run but has no sound other than Space Invasion sound.
The emulator was tested on machines from a Pentium 120 to a Pentium III 500 under Windows 95, 98, NT 4 and 2000.
Known issues
- The hunchback game, Hells Bells, seems to corrupt itself occasionally.
- Sound emulation on versions of DirectX earlier than 5 does not work properly.
- The 6522 input ports are not fully emulated.
Quick-start guide
Extract all the files to a directory on your hard drive. The two .ROM files must be in the same directory as Microtan.exe, although the games may be placed elsewhere.
Run the program. A window of random characters appears with “TANBUG” at the bottom. The hatched square underneath it is the cursor. A “Could not load … file” message means that the .ROM files are not in the same directory as the executable.
To play a game, use the Load tool or File → Load menu, then select the game. It starts automatically. The Microtan is reset when a game is loaded, so there should be no problem loading one while another is running. Most games use the cursor keys to move and the left Ctrl and Shift keys to fire; see the notes supplied with each game.
Menu options
Most menu options are also available from the toolbar.
File → Load
Loads a file from disk, then resets the emulated CPU.
File → Save
Saves the lower 8 KB to disk as an .M65 file using the original filename.
File → Save As
Prompts for a filename, then saves the lower 8 KB as an .M65 file.
Emulator → 0.75 MHz Processor
Uses the original Microtan processor speed.
Emulator → 1.5 MHz Processor
Uses twice the original Microtan processor speed.
Emulator → 3 MHz Processor
Uses four times the original Microtan processor speed.
Emulator → Full ASCII Keyboard
Uses a full ASCII keyboard with joystick control on the cursor keys.
Emulator → Hex Keypad
Uses a hexadecimal keypad, with the cursor keys mapped to some keypad keys.
Emulator → Reset Processor
Resets the Microtan.
Emulator → Memory Access Breakpoint
Sets a breakpoint when a chosen memory location is read and/or written. It can emulate a BRK instruction, display a trace of the last 2 KB of instructions, or do both.
Emulator → Show Trace
Pauses the processor and displays a trace of the last 2 KB of instructions. All or part of the trace may be copied to the clipboard.
Emulator → View Memory Access
Pauses the processor and displays a table showing which memory has been read, written or both since the last reset or table clear.
Display → White, Green or Amber Monitor
Changes the character colour.
Display → Choose Monitor Colour
Displays a colour picker for the character colour.
Help → About Microtan Emulator
Displays the program version information.
Supported file formats
.M65
Memory, device and processor dumps. Programs run automatically when loaded. For compatibility, a file of 8,263 bytes is loaded as a .DMP file. Otherwise the format is:
- 2 bytes: file version.
- 2 bytes: RAM size.
- RAM from
0000to the selected RAM size. - 16 bytes: first 6522,
BFC0toBFCF. - 16 bytes: second 6522,
BFE0toBFEF. - 16 bytes: Microtan I/O,
BFF0toBFFF. - 1 byte: Space Invasion sound,
BC04. - 1 byte: chunky-graphics state, 0 for off or 1 for on.
- 16 bytes: first AY-3-8910 registers.
- 16 bytes: second AY-3-8910 registers.
- 64 bytes: chunky-graphics bits; the first byte’s bit 0 is for the character at
0200, bit 1 for0201, and so on. - 7 bytes: CPU registers in the order PCL, PCH, PSW, A, IX, IY and SP.
.DMP
Used by Fabrice Frances’ emulator for memory and processor dumps. Programs run automatically when loaded:
- Lower 8 KB of RAM,
0000to1FFF. - 64 bytes of chunky-graphics bits.
- 7 bytes of CPU registers in the order PCL, PCH, PSW, A, IX, IY and SP.
.TAP
Direct dumps of Microtan tapes. They can be loaded anywhere in RAM, but do not run automatically. After loading, the original filename and the loaded address range are shown:
- 8-byte filename.
- 2-byte end address, high byte first.
- 2-byte start address, high byte first.
- Program data.
.HEX
There are two possible .HEX formats: Intel HEX and Zillion HEX. If a file does not appear to be Intel HEX, the emulator asks whether it is a Zillion HEX file and, if confirmed, attempts to load it.
Standard Intel HEX files, as output by a two-pass assembler, can be loaded anywhere in RAM and do not run automatically. After loading, the address range is shown. Unlike .M65 and .TAP files, these are ASCII text:
- A starting colon.
- 1 count byte.
- 2 address bytes.
- 1 null byte.
- Data bytes.
- 1 checksum byte. The checksum makes the sum of all bytes, modulo 256, equal to zero.
The file terminates with an end record, either :0000000000 or :00000001FF.
Zillion HEX files comprise header text, displayed after loading, followed by any number of code blocks enclosed in braces. Within the braces, the beginning of a line is a four-digit address followed by a space and any number of two-digit hexadecimal bytes separated by spaces. After a tab character, the rest of the line is treated as a comment. Text outside braces is also treated as comments.
Historic work in progress
At the time this page was written, I was recreating a Scramble clone because I could not find the original tape. It had been around 15 years since I had written any 6502 code, so I needed some luck!
Acknowledgements
- Fabrice Frances, for running the many versions that stopped his machine working, and for help and ideas about why.
- Dean Hickingbottom, for encouragement and beta testing.