Emulating the M20 with MAMEBy Benjamin Eberhardt
Since a while, the Multiple Arcade Machine Emulator (MAME) 1 has a driver for the Olivetti L1 M20, enabling MAME to run M20 floppy images, boot PCOS and execute programs2, almost like on the original machine. This article is based on MAME v0.212 on Linux Mint 19.2 (Aug 27th 2019).
Running M20 floppy images
Floppy disk images can be sdd/ rdm20-img (M20 floppy-sector-dumps), Teledisk-td0, or ImageDisk-imd files, as found in the disk images section. Most of these images will run right away.
To get started right away, download ROM data and floppy images into a local directory and run:
MAME currently supports the following M20 bios versions:
The floppy track0 problem
Not all images are running with MAME right away. When imaging real M20 floppies, the first 4096 bytes (Track 0/ Head 0) are not readable by many PC floppy controllers and then need to be skipped. This is the case with most rdm20 disk images in the disc images section. It is however possible to transfer Track 0 information from one image to another, to make the image usable with the M20 emulator. The file pcos102.img for example has Track0 data which can be used. Transfering it to another image using dd:
After this, startrek_en.img can be loaded as flop1 into MAME and will boot and run.
Use e.g. hexdump to find out if an image has a missing Track0. The first bytes of the file would then be all zero, and the image would need a transplant:
Make floppy images writable
MAME supports reading multiple floppy image formats: mfi (MAME floppy image), img (M20 floppy sector dumps, we will also call this format “M20”), imd (Image Disk), td0 (Teledisk). Only some of these images are writable in MAME:
MAME supplies a tool6 for converting between these different formats, with the same limitations for write support, e.g.:
will convert an ImageDisk floppy image into a writable MAME floppy image.
Alternatively, load the image to be converted and an existing mfi image into the emulator. If you want to create an new mfi image, boot from your existing image, then open the file manager (Scrl-Lock, TAB) and chose “create” in the second drive. One of the two images needs to be a system disk in slot0, be able to boot into PCOS, and contain the vcopy tool (see M20 PCOS and BASIC command reference). The source image needs a correct Track0 as described above. When in doubt, use the provided system disk in slot0 and copy over it. Then boot PCOS and copy the source image over to the target .mfi image.
On PCOS, copy flop2 (1:) over flop1 (0:):
Read files from images
In order to retrieve files written to floppy images, the image needs to be converted back into the M20-format. Again you can use floptool (>= 0.212). If your OS ships with an older version of MAME, consider compiling it from source.
A regular M20-img file can then be read with m20floppy.
Note that BASIC files are usually saved in a compressed (big endian) binary format. In order to save them as ASCII files, which can be exported to a PC, save files under PCOS BASIC with the “A” option:
Compiling MAME from source
The latest version of MAME is the github master branch7. On Linux just type “make” in the checked out tree. To compile floptool etc. as well, type “make TOOLS=1”.
Christian Groessler has a fork of MAME on github8 which only compiles the M20 driver and hence compiles significantly faster. Compile it with “make SUBTARGET=m20”.
On a real M20, with the 8086 addon board, you can boot MSDOS. This also works with MAME, by selecting bios >=1 and the msdos floppy image from the disk images section.
When asked if you want to boot the alternative CPU (8086), press “y” to boot into MSDOS.
Connecting to the M20 serial interface
Run mame with the follwing extra arguments:
Then connect to the socket with e.g. telnet
The keyboard layout depends on the language of the loaded PCOS. M20 special keys are usually:
ScrollLock toggles between emulated keyboard and MAME keyboard. ScrollLock + Tab9 opens the MAME in-game settings menu and can be used to modify the key mappings. If you don’t have a Scroll-Lock key (e.g. laptop) you can change the “UI toggle” to another key by opening MAME:
and selecting -> Configure Options -> General Inputs -> User Interface -> UI Toggle. It makes sense to specify a consistent config directory, as MAME might decide to pick different config locations when called with different options.
While you are at it, look into other useful options, like recording screenshots (F12) and recording video (LSHIFT + F12).
This little BASIC program can be used to compare different key combinations with the key code tables in the command reference manual.
Notes and open questions
Olivetti is a registered trademark of Telecom Italia. This site is not related to Olivetti nor to Telecom Italia. The material presented is meant for personal use only and is shared in a "fair use" spirit. If you own the copyright of some of the stuff presented here and you think it should be removed, please contact the webmaster.