M20 Olivetti M20

Emulating the M20 with MAME

by Benjamin Eberhardt, originally published here, reproduced with permission

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 9th 2019).

m20clock

Running M20 floppy images

After installing MAME, one needs to separately download the M20’s ROM contents (e.g. m20.zip from wowroms3). For legal reasons, most ROMs are not included in MAME 4.

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.

Disk images can also be (converted to) MAME-mfi format image (e.g. system disk or games disk). In MAME < v0.212, only mfi-images are writable.

To get started right away, download ROM data and floppy images into a local directory and run:

$ mame m20 -bios <0, 1, 2> -rompath . -flop1 <image1> [-flop2 <image2>] [-cfg_directory ~/.mame/cfg] [-window]

MAME currently supports the following M20 bios versions:

  • 1.0 (-bios 0)
  • 2.0d (-bios 1)
  • 2.0f (-bios 2)

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:

$ dd conv=notrunc pcos102.img of=startrek_en.img bs=4096 count=1

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:

$ hexdump startrek_en.img |head -n 1
0000000 0000 0000 0000 0000 0000 0000 0000 0000
$ hexdump pcos102.img |head -n 1
0000000 0401 2300 1002 0001 0a00 c400 8600 001e

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:

mfi m20 imd td0
Yes since v0.2125 No No

MAME supplies a tool6 for converting between these different formats, with the same limitations for write support, e.g.:

$ floptool convert IMD MFI floppy1.imd floppy1.mfi

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 linux:

$ mame m20 -rompath . -flop1 pcos20german.mfi -flop2 startrek_en.img

On PCOS, copy flop2 (1:) over flop1 (0:):

0> vc 1: 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 the latest github master7.

$ floptool convert MFI M20 floppy.mfi floppy.img

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:

# SAVE "0:<filename>",A

Connecting to the M20 serial interface

Run mame with the following extra arguments:

$ mame m20 -rs232 null_modem -bitb socket.127.0.0.1:4321

In PCOS:

0> rs232
0> +scom:
0> +dcom:

Then connect to the socket with e.g. telnet

$ telnet 127.0.0.1 4321

Keyboard

The keyboard layout depends on the language of the loaded PCOS. M20 special keys are usually:

  • reset: esc
  • hard reset: strg + esc
  • yellow/ command: tab
  • blue/ ctrl: left_ctrl
  • S1: (German keyboard: #, US keyboard: backslash)
  • S2: backspace

ScrollLock toggles between emulated keyboard and MAME keyboard. ScrollLock + Tab8 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:

$ mame [-cfg_directory ~/.mame/cfg] [-window]

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.

0 REM return decimal and hexadecimal values of pressed keys
10 CLEAR
20 G$=INKEY$: IF G$="" THEN GOTO 20
30 PRINT ASC(G$) HEX$(ASC(G$))
40 GOTO 20

Notes and open questions

  • Input from telnet to the M20 works, terminal output from the M20 to telnet did not work. Wrong options?
  • All Teledisk and ImageDisk images on this website were usable right away with the emulator, and so probably all have correct Track0 information. Hence I did not test if transplanting Track0 data between two of those respective image types would work as well and if in this format, the Track0 would also be the first 4096 bytes.

  1. https://www.mamedev.org/ ↩︎

  2. https://forums.bannister.org/ubbthreads.php?ubb=showflat&Number=78739 ↩︎

  3. https://wowroms.com/en/roms/mame/olivetti-l1-m20/89051.html ↩︎

  4. https://wiki.mamedev.org/index.php/FAQ:ROMs ↩︎

  5. https://github.com/mamedev/mame/pull/5445 ↩︎

  6. https://docs.mamedev.org/tools/floptool.html ↩︎

  7. https://github.com/mamedev/mame ↩︎

  8. https://docs.mamedev.org/usingmame/defaultkeys.html ↩︎




RSS feedsRSS feeds

Google
Search in the M20 site
Search in the Internet