MAME:Installing: Difference between revisions
Added debugger key |
|||
| (10 intermediate revisions by 2 users not shown) | |||
| Line 89: | Line 89: | ||
* Return to the previous menu twice, then choose Save Settings | * Return to the previous menu twice, then choose Save Settings | ||
= | = Creating a NextZXOS SD card image under Linux = | ||
Most users wanting to emulate the Next using MAME will be fine using a pre-built SD card image downloaded from the specnext website. The following guide is provided for anyone wanting to create a NextZXOS SD card image from scratch. | |||
Download the [https://www.specnext.com/latestdistro/ latest NextZXOS distribution zip file] (named something like sn-complete-WX.YZ.zip) and extract it into a new, empty directory. | |||
== Creating and populating a SD card image using hdfmonkey == | |||
If you extracted sn-complete-WX.YZ.zip into a subdirectory named <code>snWXYZ</code>, and you want to create a 1GB image called <code>NextZXOS.img</code> and you have a [[Development_Tools:Linux_setup#hdfmonkey_tool | "jjjs build" of hdfmonkey]], then it's enough to do: | |||
<pre> | |||
hdfmonkey create NextZXOS.img 1G | |||
hdfmonkey putdir NextZXOS.img snWXYZ / | |||
</pre> | |||
The first line creates an empty 1GB image and formats it with the best FAT parameters suited to the size of the image. | |||
The second line recursively copies all the content of the directory <code>snWXYZ</code> to the image, preserving the directory structure inside, starting from the <code>/</code> in the image. | |||
< | One of the advantages of this method is that even if the image has a capacity of 1GB, it will use much less space on your hard drive until you fill up the image. A command <code>du -h NextZXOS.img</code> shows the actual amount of disk space used by the image. | ||
The fastest way to transfer a file or a directory (including its content, recursively) into an image is by using a single <code>put</code> (or <code>putdir</code>, if it's to transfer the directory file content to an existing directory) command of hdfmonkey. | |||
The most convenient tool to [[Development_Tools:Linux_setup#Extracting_all_files_from_the_SD_image | copy of all the content from the image to a folder outside of the image]] is 7-zip. | |||
== Creating and populating a SD card image using other tools == | |||
Create a disk image of at least 256 MB. The current complete NextZXOS distro requires at least 130 MB of disk space. This command will create a 256 MB SD card image; change the <code>count</code> value to make the image file as big as you want in megabytes: | Create a disk image of at least 256 MB. The current complete NextZXOS distro requires at least 130 MB of disk space. This command will create a 256 MB SD card image; change the <code>count</code> value to make the image file as big as you want in megabytes: | ||
| Line 136: | Line 143: | ||
After copying the files, unmount and detach the loopback device (the SD card image): | After copying the files, unmount and detach the loopback device (the SD card image): | ||
<pre>umount /mnt/ | |||
losetup -D</pre> | |||
Warning: the resulting image of this method, if the parameters of different steps aren't carefully chosen and matched, could be out of the official FAT specifications and/or the expectations of some of the existing programs or systems. | |||
= Mounting SD card images under Linux = | |||
Under Linux, you can use <code>losetup</code> to mount SD card images as loop devices. This lets you copy files to and from the image and perform other file management tasks as you would using any other filesystem. | |||
Run the following commands as the root user to mount an image called sn-emulator-22.10a.img under the /mnt directory: | |||
<pre>losetup --partscan --show --find cspect-next-2gb.img | |||
mount /dev/loop0p1 /mnt/</pre> | |||
After you are finished modifying the SD card image, cd out of /mnt, then unmount and detach the loopback device: | |||
<pre>umount /mnt/ | <pre>umount /mnt/ | ||
| Line 142: | Line 165: | ||
=MAME Plugins and Scripts= | =MAME Plugins and Scripts= | ||
Some MAME plugins and scripts that may be useful for Next developers and end users are listed [[MAME:Plugins_and_Scripts|here | Some MAME plugins and scripts that may be useful for Next developers and end users are listed [[MAME:Plugins_and_Scripts|here]]. They let you speed up the Next boot time, profile your NextBASIC or assembler code, and more. | ||
=Continuous Integration MAME Builds= | =Continuous Integration MAME Builds= | ||
| Line 150: | Line 173: | ||
Continuous Integration (CI) builds are available from both the [https://github.com/mamedev/mame/actions primary MAME repo] and [https://github.com/holub/mame/actions holub's GitHub repo]. Both are considered bleeding-edge, with the primary MAME repo slightly less so. MAME CI builds are available for Windows, Linux, and macOS and are updated automatically whenever code is committed by a maintainer or pushed to the primary repo. | Continuous Integration (CI) builds are available from both the [https://github.com/mamedev/mame/actions primary MAME repo] and [https://github.com/holub/mame/actions holub's GitHub repo]. Both are considered bleeding-edge, with the primary MAME repo slightly less so. MAME CI builds are available for Windows, Linux, and macOS and are updated automatically whenever code is committed by a maintainer or pushed to the primary repo. | ||
To try out a CI build, first do a full MAME install from the [https://www.mamedev.org/release.html latest release] if you have not already done so. Then back up your main binary from its installation location - these are called something like <code>mame.exe</code> | To try out a CI build, first do a full MAME install from the [https://www.mamedev.org/release.html latest release] if you have not already done so. Then back up your main binary from its installation location - these are called something like <code>mame.exe</code> or <code>mame</code>. You can always restore these if the CI build doesn't work, or if you don't like how it behaves. | ||
Then visit one of the links above and find a workflow run item for your platform - these are flagged as <code>CI (Windows)</code>, <code>CI (Linux)</code>, or <code>CI (macOS)</code>. Click on it and find the Artifacts section at the bottom, then click the Download button. Unzip the downloaded file and find the main binary (with the same name as above). Copy the main binary to the install location, overwriting the original one, and run MAME the same way you were running it before. On Windows and macOS, you may need to take an additional step to trust the binary ("Run Anyway" on Windows; "System Preferences -> Privacy & Security -> Allow mame to Run" on macOS). | Then visit one of the links above and find a workflow run item for your platform - these are flagged as <code>CI (Windows)</code>, <code>CI (Linux)</code>, or <code>CI (macOS)</code>. Click on it and find the Artifacts section at the bottom, then click the Download button. Unzip the downloaded file and find the main binary (with the same name as above). Copy the main binary to the install location, overwriting the original one, and run MAME the same way you were running it before. On Windows and macOS, you may need to take an additional step to trust the binary ("Run Anyway" on Windows; "System Preferences -> Privacy & Security -> Allow mame to Run" on macOS). | ||
Latest revision as of 15:09, 4 December 2025
MAME (formerly an acronym of Multiple Arcade Machine Emulator) is a free and open-source emulator designed to emulate the hardware of arcade games, later expanded to include video game consoles, old computers and other systems in software on modern personal computers and other platforms.
MAME supports the ZX Spectrum Next since version 0.267. The existing implementation is based on the v3.02.01 core and implements most of the features.
Get
The latest MAME version for Windows is available here, and macOS builds can be downloaded from here. For the MAME platform as a whole, check your package manager, or build from sources.
Linux users can also install the latest stable version of MAME from the flatpak repositories by running:
sudo flatpak install org.mamedev.MAME
Put the ROM dump zip of the ZX Next tbblue.zip into MAME's roms folder (don't extract it; MAME will look for the zip file when the "tbblue" machine is selected).
Prepare an SD card image file of NextZXOS. Some published images do not work with some emulators, but all images from https://zxnext.uk/hosted/#sd are now confirmed to work with both MAME and CSpect, including the official ones like this one (the SD card image is the cspect-next-2gb.img file inside the zip archive). You will point MAME to the desired SD card image with the -hard1 or -hard2 options (or select the files from the menu inside the emulator).
Use
MAME looks for its configuration and helper files in specific (configurable) folders. By default, these are relative to the current working directory (cwd), ie., from where you launched the executable. The mame.ini file and folders like roms, bgfx, plugins, language, ... are expected there, unless the mame.ini file specifies other paths. When launching through a desktop icon or menu, depending on the OS, the working directory is often defined by the properties of that launch shortcut. When launching MAME from the command line, the current directory is "cwd" (doh). On Linux, MAME will look for mame.ini first in the ~/.mame folder. You can use the option -inipath to point MAME to a different path for the mame.ini file.
The fastest way to run a machine with a desired configuration is from the command prompt. Most of the features are also available through MAME's UI, but that takes more time to configure.
Let's cover some useful options:
-
Run inside a window and with no mouse support, until you get familiar with the UI keys:
> mame tbblue -window -mouse_device none -hard1 /path/to/next-distribution.img
To launch the Linux flatpak version using the same options:
> flatpak run org.mamedev.MAME tbblue -window -mouse_device none -hard1 /path/to/next-distribution.img
-
Activate UI keys on startup:
> ... -ui_active
-
Don't show the info popup on startup:
> ... -skip_gameinfo
- Run with debugger. If you don't request this on startup, you won't have access to it:
> ... -debug
- Use "crisp" pixels:
> ... -nounevenstretch -aspect 2:1 -video bgfx -bgfx_screen_chains unfiltered
- No joystick connected to PC (may slightly speed up MAME's startup):
> ... -joystickprovider none
- Ask for confirmation when exiting MAME (otherwise it's easy to exit MAME accidentally by hitting ESC, especially when playing games or navigating menus):
> ... -confirm_quit
Check the official MAME documentation for more advanced usage.
As an example, this invocation enables the UI, uses "crisp pixels", starts in a window, doesn't display the starting gameinfo window (it can still be displayed interactively from the UI), disables the mouse, confirms before exiting MAME, and specifies the disk image:
mame -ui_active -nounevenstretch -aspect 2:1 -video bgfx -bgfx_screen_chains unfiltered -window -skip_gameinfo -mouse_device none -confirm_quit tbblue -hard1 /path/to/next-distribution.img
Keys
Keys are emulated in two modes: either to control the MAME emulator or completely dedicated to the emulated system (the Next). You can toggle between these two keyboard modes with ScrLk (on Win and Linux) or fn+delete (on Mac).
Some UI keys:
- F3 - soft reset
- Shift+F3 - hard reset
- F4 - sprites/tiles/font viewer (Enter, ], [)
- F5 - pause emulation
- F6 - save state
- F7 - load state
- Tab - emulator settings
- ~ - menu
- ` (backtick) - debugger (when enabled by starting MAME with
-debugor-don the command line) - PgDwn (Linux/Mac), fn-Downarrow (MacBooks) or Insert (Win) - hold down to fast-forward emulation at maximum speed, e.g., to speed up booting the Next
- Esc - exit (exits menus but also the entire emulator - see
-confirm_quitoption above) - F11 - DivMMC NMI
- F12 - Multiface NMI
Changing the UI toggle key
Some laptops don't have a Scroll Lock key, so you may not be able to exit MAME if you run it in full-screen mode. In these cases, you can change the UI toggle key as follows:
- Run MAME without any command line arguments (except maybe -window) to open its GUI.
- Push TAB and enter the General Settings menu.
- Go to Input Assignments -> User Interface -> Toggle UI controls and select a new key. I use Right Alt / Alt GR.
- Return to the previous menu twice, then choose Save Settings
Creating a NextZXOS SD card image under Linux
Most users wanting to emulate the Next using MAME will be fine using a pre-built SD card image downloaded from the specnext website. The following guide is provided for anyone wanting to create a NextZXOS SD card image from scratch.
Download the latest NextZXOS distribution zip file (named something like sn-complete-WX.YZ.zip) and extract it into a new, empty directory.
Creating and populating a SD card image using hdfmonkey
If you extracted sn-complete-WX.YZ.zip into a subdirectory named snWXYZ, and you want to create a 1GB image called NextZXOS.img and you have a "jjjs build" of hdfmonkey, then it's enough to do:
hdfmonkey create NextZXOS.img 1G hdfmonkey putdir NextZXOS.img snWXYZ /
The first line creates an empty 1GB image and formats it with the best FAT parameters suited to the size of the image.
The second line recursively copies all the content of the directory snWXYZ to the image, preserving the directory structure inside, starting from the / in the image.
One of the advantages of this method is that even if the image has a capacity of 1GB, it will use much less space on your hard drive until you fill up the image. A command du -h NextZXOS.img shows the actual amount of disk space used by the image.
The fastest way to transfer a file or a directory (including its content, recursively) into an image is by using a single put (or putdir, if it's to transfer the directory file content to an existing directory) command of hdfmonkey.
The most convenient tool to copy of all the content from the image to a folder outside of the image is 7-zip.
Creating and populating a SD card image using other tools
Create a disk image of at least 256 MB. The current complete NextZXOS distro requires at least 130 MB of disk space. This command will create a 256 MB SD card image; change the count value to make the image file as big as you want in megabytes:
dd if=/dev/zero of=NextZXOS.img bs=1M count=256
The rest of the commands in this guide must be run as the root user or using sudo.
You will need to install the dosfstools and parted packages if they are not already installed. Debian and Ubuntu Linux users can install these using this apt command:
apt install dosfstools parted
Mount the SD card image loopback device:
losetup --partscan --show --find NextZXOS.img
Create a FAT32 partition:
parted /dev/loop0 mklabel msdos parted /dev/loop0 mkpart primary fat32 1MB 100%
Format and mount the partition under /mnt:
mkfs.vfat -F 32 /dev/loop0p1 mount /dev/loop0p1 /mnt
You can now copy all of the files you extracted from sn-complete-WX.YZ.zip into /mnt.
After copying the files, unmount and detach the loopback device (the SD card image):
umount /mnt/ losetup -D
Warning: the resulting image of this method, if the parameters of different steps aren't carefully chosen and matched, could be out of the official FAT specifications and/or the expectations of some of the existing programs or systems.
Mounting SD card images under Linux
Under Linux, you can use losetup to mount SD card images as loop devices. This lets you copy files to and from the image and perform other file management tasks as you would using any other filesystem.
Run the following commands as the root user to mount an image called sn-emulator-22.10a.img under the /mnt directory:
losetup --partscan --show --find cspect-next-2gb.img mount /dev/loop0p1 /mnt/
After you are finished modifying the SD card image, cd out of /mnt, then unmount and detach the loopback device:
umount /mnt/ losetup -D
MAME Plugins and Scripts
Some MAME plugins and scripts that may be useful for Next developers and end users are listed here. They let you speed up the Next boot time, profile your NextBASIC or assembler code, and more.
Continuous Integration MAME Builds
MAME is updated on a release schedule, but due to the ongoing nature of development, including for the MAME Next machine, it can sometimes be useful to install a more recent build if it contains a new feature or bugfix you are interested in. Sometimes, this ongoing work is discussed on social media, such as the Next Developer Discord.
Continuous Integration (CI) builds are available from both the primary MAME repo and holub's GitHub repo. Both are considered bleeding-edge, with the primary MAME repo slightly less so. MAME CI builds are available for Windows, Linux, and macOS and are updated automatically whenever code is committed by a maintainer or pushed to the primary repo.
To try out a CI build, first do a full MAME install from the latest release if you have not already done so. Then back up your main binary from its installation location - these are called something like mame.exe or mame. You can always restore these if the CI build doesn't work, or if you don't like how it behaves.
Then visit one of the links above and find a workflow run item for your platform - these are flagged as CI (Windows), CI (Linux), or CI (macOS). Click on it and find the Artifacts section at the bottom, then click the Download button. Unzip the downloaded file and find the main binary (with the same name as above). Copy the main binary to the install location, overwriting the original one, and run MAME the same way you were running it before. On Windows and macOS, you may need to take an additional step to trust the binary ("Run Anyway" on Windows; "System Preferences -> Privacy & Security -> Allow mame to Run" on macOS).
More MAME links
The official MAME source code repository is available here.
holub, the author of the Next emulation, maintains a fork here that may contain new fixes and features before they are merged into the official repository.
MAME documentation.
Report any issues with MAME on the bugtracker.