Emulating the M20 with RetroArch
By Benjamin Eberhardt
This guide highlights the particularities of running the M20 MAME driver on RetroArch with the examples of setting it up on Android and Retropie. For a general overview of running the M20 with MAME itself refer to the M20 emulation with MAME article.
Above is the iconic game "Mauerschießen", a pong clone from the German demo floppy running on Android RetroArch, playable entirely by gamepad. The necessary keyboard keys have been mapped to the controller.
Running the M20 on Retroarch can be useful for a number of reasons: Retroach is being built for a vast number of platforms (like Android, the Nintendo Switch, and even Win95) for which there is no pre-compiled Mame option. RetroArch also offers some additional features, like slow down, speed up, and snapshots, effectively introducing a "save game" function. While RetroArch is just the frame, it contains MAME as a "core".
The goal of this article is to get M20 emulation running on RetroArch, and map some keys of simple 1D and 2D games to the RetroArch virtual gamepad "RetroPad", so they can be played without a keyboard. Data provided with this article:
Description | File | Size | CRC |
---|---|---|---|
Olivetti M20 - games, thumbnails, MAME hash table | m20_games.zip | 7182871 | c8e858bf |
Retropad controller mapping configs | m20_retropad_mapping.zip | 1089744 | fdde389c |
Loading floppy images in a non-keyboard environment
On a PC one can call MAME with a number of custom arguments from a console. In RetroArch, we need to supply a single argument to the emulator, in form of a file that the user can tap on. Therefore floppies/ images can be loaded by MAME in two additional ways, that only require a single argument when calling the emulator:
- Loading a known (softlisted) image by just specifying its name. MAME will load this image automatically from a defined input folder and tell MAME that it is a floppy. Softlisted images must be zipped, and named exactly in the way they are listed.
- Specifying the image location and floppy-type manually in a .cmd file, which is then passed as an argument itself to MAME instead of the image itself. This also allows one to pass additional options by adding them to the .cmd file.
The M20 softlist in MAME
In order to use the softlist loading method, add entries to the hash table/ softlist. When placing the file in the local installation, the listed images can be started directly from the app, without having to create a *.cmd file. A few notes about the xml:
- "software name" is the name of the zipped image
- "rom name" is the name of the image file inside the zip
- size and checksums can be wrong, mame will throw an error into the log, but should still start the image
Structure of CMD files
CMD files need to contain at least the following information:
- Driver:
mame m20
- Location of the M20 bios:
-rompath <location>
- Image (type) to be loaded:
-flop1 <image.zip>
Additional MAME commandline-arguments:
- M20 Bios version: e.g.
-bios 1
- Second floppy drive:
-flop2 <image>
- System config directory:
-cfg_directory <location>
- Controller- config/ directory:
-ctrlrpath <location> -ctrlr <config-name>
- Execute after launch:
-autoboot_delay 15 -autoboot_command "<cmd>"
- Emulation speed:
-speed <factor>
An example could look like this:
mame m20 -speed 1.1 -ctrlrpath /storage/emulated/0/RetroArch/roms/m20/cfg/ -ctrlr othello -rompath /storage/emulated/0/RetroArch/roms/m20 -flop1 /storage/emulated/0/RetroArch/roms/m20/othello.zip
Mapping M20 keys to the RetroPad
Using the retropad (on-screen) gamepad instead of a keyboard (e.g. on a phone) is a bit more difficult, but possible. In order to make this work one needs to map some of retropad buttons to the M20 keyboard. Since every game has different input, we create a dedicated controller config on a per image basis, by adding the -ctrlrpath
and -ctrlr
arguments to the *.cmd launch file. Custom configs will be placed inside a "cfg" directory with the M20 roms, e.g.:
"-ctrlrpath <RetroArch>/roms/m20/cfg/ -ctrlr <game>"
This will make mame expect a "\
<input>
<keyboard tag=":kbd:m20" enabled="1" />
<port tag=":kbd:m20:LINE6" type="KEYBOARD" mask="1" defvalue="0">
<newseq type="standard">KEYCODE_SPACE OR JOYCODE_1_BUTTON2</newseq></port>
</input>
Similar key mappings can be defined for other keys. Taking e.g. the pong clone "Mauerschießen" as an example, we need the keys "0", "2" (down, up), and "space" (start), and "j" (restart), which is the minimum requirement. For a complete overview of M20 key names in MAME scroll to the bottom of this file.
Examples for some games are provided in m20_retropad_mapping.zip
. A python script is provided to create/ change mappings: create_retropad_mapping.py.
When modifying the keys in-game through the MAME menu, the mapping will be saved in a system config file called m20.cfg
. If one wants to keep those settings on a per game basis, instead of the ctrlrpath and ctrlr arguments, one can supply the cfg_directory argument, to have the system-config stored in a separate location e.g.:
"-cfg_directory <RetroArch>/roms/m20/cfg/<game>/"
The syntax of the m20.cfg system config file inside this folder is identical to the controller config and can be edited both in-game or with a text editor.
RetroArch on Android
This guide is based on RetroArch Arm64 v1.14. The current version of the "Multi (MESS - Current)" core is based on MAME v0.251 and available from the online core downloader. Note that it is best to install the (linked) buildbot version of the app, since the PlayStore version tends to be out of date (and e.g. not list the MESS core).
The RetroArch directory on the Android device is assumed to be under: "/storage/emulated/0/RetroArch" After setup, the basic structure inside the RetroArch folder should look like this1:
./roms/m20/m20.zip (bios)
./roms/m20/<game>.zip (rom)
./roms/m20/cfg/<game>.cfg (ctrlr-cfg)
./system/mame/hash/m20.xml (softlist)
./thumbnails/m20/[Named_Boxarts, Named_Snaps, Named_Titles]/<game>.png
./playlists/m20.lpl
./saves/mame/cfg/m20.cfg (default-sys-cfg)
./logs
Setup
1) Start by installing Retroarch 64 bit for Android. Once downloaded, refresh/ update the "Core Info Files".
2) Download the "Multi (MESS - Current)" via the core downloader either directly or by downloading from buildbot into the RetroArch/download folder.
3) Create a subfolder "roms/m20" and put (zipped) floppy images and M20 bios/ rom inside. Make sure the images have a working/ non-empty track0.
4) Make sure the roms are softlisted in hash/m20.xml or alternatively create a *.cmd launch file pointing at the zip file, and also place into "roms/m20" folder:
mame m20 -rompath /storage/emulated/0/RetroArch/roms/m20 -flop1 /storage/emulated/0/RetroArch/roms/m20/maus.zip
5) Now it is time to start up the RetroArch app and change a few settings: - Activate file logging into "logs" directory, so that we know why things fail/ crash if they do: Settings -> Logging -> Log to File & Timestamp Log Files
6) Choose input device. There are two options:
- Connect a keyboard to the Android device e.g. use an Android tablet with a bluetooth keyboard.
- Use the RetroPad (either on-screen, or via a real gamepad):
- For the mapping between RetroPad and MAME add a custom controller config to the *.cmd file:
-ctrlrpath <RetroArch>/roms/m20/cfg/ -ctrlr <game>
- Then edit the file
<RetroArch>/roms/m20/cfg/<game>.cfg
and add all the needed M20 keyboard mappings for the game - The mapping between a physical gamepad and RetroPad can additionally be configured via Settings -> Input -> Port 1 Controls
- For the mapping between RetroPad and MAME add a custom controller config to the *.cmd file:
7) Launch the emulation by: - Load content -> (select the *.cmd launch file) - When prompted, select "Arcade (MAME - Current)" core
Optional steps
- A few more helpful RetroArch settings:
- Activate "game focus" mode, to deactivate RetroArch hotkeys and pass keyboard inputs directly to the core:
- Settings -> Input -> Auto enable Game Focus (disables all hotkeys but Game Focus Toggle)
- Settings -> Input -> Hotkeys -> Game Focus (Toggle)
-
Activate slow motion mode (if the game is too fast)
- Define speed factor under: Settings -> Frame Throttle -> Slow-Motion Rate
- Assign to hotkey: Settings -> Input -> Hotkeys -> Slow-Motion (Toggle) -
-
Create a playlist to automatically associate .zip and .cmd files in the m20 roms folder with the mame-current core via Playlists -> Import Content -> Manual Scan:
- Content directory: roms/m20
- System name: "Content directory" or "Custom -> m20"
- Default core: "Multi (MESS - Current)"
- File extensions: "zip cmd"
- It possibly makes sense to add two different playlists for plain
zip
files and customcmd
files, so one can distinguish between the two if they have the same filename.
-
Add artwork under the "thumbnails" folder:
- Create a subfolder with the name "m20" or, if it differs, with the name of the created playlist
- Inside, place the thumbnails into subfolders: Named_Boxarts, Named_Snaps, and/ or Named_Titles
- Name thumbnails by game (image file-) name
-
Add a modified hash table.
- Add new roms/ games, to enable loading them directly/ without the need to create a cmd file.
- Place modified hash file under "system/mame/hash/m20.xml"
-
Use autoboot to perform actions automatically (e.g. start a game on a multi-game floppy). While this is possible, it is quite fiddly and depends on a few things:
- The floppy needs to autoboot into an Italian PCOS (for more details, see the main MAME article)
- For me, the autoboot_command string needed to be in double quotes itself, single quotes did not work. This makes it difficult if the command one wants to pass also contains double quotes. Escaping and triple quotes as suggested in some forums also did not work. Eventually I was using different (unicode) types of double quotes:
- U+0022 : quotation mark (as the outer quotes)
- U+201C : left double quotation mark (as inner double quotes)
Related work
- Create Android64 MESS core and related info file
- Suggest adding a Mame-Mess core for Switch
- Improving/ Cleaning up the current MAME rom list for the M20
The M20 keyboard in MAME and RetroArch
Retropad Numbering
Prefix: JOYCODE_1_*
BUTTON1: A | RZAXIS_NEG_SWITCH: L2 | HAT1UP : UP
BUTTON2: B | ZAXIS_NEG_SWITCH : R2 | HAT1LEFT : LEFT
BUTTON3: X | SELECT : Select | HAT1RIGHT : RIGHT
BUTTON4: Y | START : Start | HAT1DOWN : DOWN
BUTTON5: L1 | BUTTON9 : L3 | YAXIS_UP_SWITCH : Analog UP switch
BUTTON6: R1 | BUTTON10 : R3 | XAXIS_LEFT_SWITCH: Analog LEFT switch
Mame M20 key mapping
Issues: KEYCODE_STOP buttons not found/ gets deleted from cfg. Maybe a bug in v0.226 that STOP cannot be used? The period/ stop key also does not work when attaching a physical keyboard.
Key IT M20 - KEYCODE_* - Port - Mask - Comment
RESET - ESC - :kbd:m20:LINE0 - 1
< > - LALT - :kbd:m20:LINE0 - 2
a A - A - :kbd:m20:LINE0 - 4
b B - B - :kbd:m20:LINE0 - 8
c C - C - :kbd:m20:LINE0 - 16
d D - D - :kbd:m20:LINE0 - 32
e E - E - :kbd:m20:LINE0 - 64
f F - F - :kbd:m20:LINE0 - 128
g G - G - :kbd:m20:LINE1 - 1
h H - H - :kbd:m20:LINE1 - 2
i I - I - :kbd:m20:LINE1 - 4
j J - J - :kbd:m20:LINE1 - 8
k K - K - :kbd:m20:LINE1 - 16
l L - L - :kbd:m20:LINE1 - 32
, ? - M - :kbd:m20:LINE1 - 64
n N - N - :kbd:m20:LINE1 - 128
o O - O - :kbd:m20:LINE2 - 1
p P - P - :kbd:m20:LINE2 - 2
q Q - Q - :kbd:m20:LINE2 - 4
r R - R - :kbd:m20:LINE2 - 8
s S - S - :kbd:m20:LINE2 - 16
t T - T - :kbd:m20:LINE2 - 32
u U - U - :kbd:m20:LINE2 - 64
v V - V - :kbd:m20:LINE2 - 128
z Z - W - :kbd:m20:LINE3 - 1
x X - X - :kbd:m20:LINE3 - 2
y Y - Y - :kbd:m20:LINE3 - 4
w W - Z - :kbd:m20:LINE3 - 8
à 0 - 0 - :kbd:m20:LINE3 - 16
£ 1 - 1 - :kbd:m20:LINE3 - 32
é 2 - 2 - :kbd:m20:LINE3 - 64
" 3 - 3 - :kbd:m20:LINE3 - 128
' 4 - 4 - :kbd:m20:LINE4 - 1
( 5 - 5 - :kbd:m20:LINE4 - 2
_ 6 - 6 - :kbd:m20:LINE4 - 4
è 7 - 7 - :kbd:m20:LINE4 - 8
^ 8 - 8 - :kbd:m20:LINE4 - 16
ç 9 - 9 - :kbd:m20:LINE4 - 32
) ° - MINUS - :kbd:m20:LINE4 - 64
- + - EQUALS - :kbd:m20:LINE4 - 128
ì = - OPENBRACE - :kbd:m20:LINE5 - 1
$ & - CLOSEBRACE - :kbd:m20:LINE5 - 2
m M - COLON - :kbd:m20:LINE5 - 4
ù % - QUOTE - :kbd:m20:LINE5 - 8
* § - TILDE - :kbd:m20:LINE5 - 16
; . - COMMA - :kbd:m20:LINE5 - 32
: / - STOP - :kbd:m20:LINE5 - 64
ò ! - SLASH - :kbd:m20:LINE5 - 128
Space - SPACE - :kbd:m20:LINE6 - 1
Enter - ENTER - :kbd:m20:LINE6 - 2
S1 - BACKSLASH - :kbd:m20:LINE6 - 4
S2 - BACKSPACE - :kbd:m20:LINE6 - 8
Keypad . - DEL_PAD - :kbd:m20:LINE6 - 16
Keypad 0 - 0_PAD - :kbd:m20:LINE6 - 32
Keypad 00 - ENTER_PAD - :kbd:m20:LINE6 - 64
Keypad 1 - 1_PAD - :kbd:m20:LINE6 - 128
Keypad 2 - 2_PAD - :kbd:m20:LINE7 - 1 - (DOWN)
Keypad 3 - 3_PAD - :kbd:m20:LINE7 - 2
Keypad 4 - 4_PAD - :kbd:m20:LINE7 - 4 - (LEFT)
Keypad 5 - 5_PAD - :kbd:m20:LINE7 - 8
Keypad 6 - 6_PAD - :kbd:m20:LINE7 - 16 - (RIGHT)
Keypad 7 - 7_PAD - :kbd:m20:LINE7 - 32
Keypad 8 - 8_PAD - :kbd:m20:LINE7 - 64 - (UP)
Keypad 9 - 9_PAD - :kbd:m20:LINE7 - 128
Keypad + - PLUS_PAD - :kbd:m20:LINE8 - 1
Keypad - - MINUS_PAD - :kbd:m20:LINE8 - 2
Keypad * - ASTERISK - :kbd:m20:LINE8 - 4
Keypad / - SLASH_PAD - :kbd:m20:LINE8 - 8
COMMAND - TAB - :kbd:m20:MODIFIERS - 1
CTRL - LCONTROL - :kbd:m20:MODIFIERS - 2
R SHIFT - RSHIFT - :kbd:m20:MODIFIERS - 4
L SHIFT - LSHIFT - :kbd:m20:MODIFIERS - 8
-
https://forums.libretro.com/t/guide-play-non-arcade-systems-with-mame-or-mess/17728 ↩
Page log
- July 18, 2023 - Put online.
- May 27, 2023 - First version of the page.
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.