MAME:Installing: Difference between revisions

From SpecNext Wiki
Jump to: navigation, search
SevenFFF (talk | contribs)
No edit summary
Johnnyo (talk | contribs)
 
(56 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[https://www.mamedev.org/ 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.
[https://www.mamedev.org/ 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. Existing implementation is based on v3.02.01 core and implements most of the features.
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 =
= Get =
Latest version for Windows is available [https://www.mamedev.org/release.html here]. For the MAME platform as a whole, check your package manager or [https://docs.mamedev.org/initialsetup/compilingmame.html build from sources].
The latest MAME version for Windows is available [https://www.mamedev.org/release.html here], and macOS builds can be downloaded from [https://sdlmame.lngn.net/ here.] For the MAME platform as a whole, check your package manager, or [https://docs.mamedev.org/initialsetup/compilingmame.html build from sources].
 
Linux users can also install the latest stable version of MAME from the flatpak repositories by running:
<pre>sudo flatpak install org.mamedev.MAME</pre>
 
Put the ROM dump zip of the ZX Next [https://github.com/Threetwosevensixseven/NexCreator/raw/master/bootroms/tbblue.zip tbblue.zip] into MAME's <code>roms</code> 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 [https://www.specnext.com/system-next22-10/ 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 [https://zxnext.uk/hosted/index_files/hdfimages/cspect-next-2gb.zip this one] (the SD card image is the <code>cspect-next-2gb.img</code> file inside the zip archive). You will point MAME to the desired SD card image with the <code>-hard1</code> or <code>-hard2</code> options (or select the files from the menu inside the emulator).


= Use =
= Use =
In order to run the Next (and any others) you need to acquire rom dumps for the system.
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 <code>mame.ini</code> file and folders like <code>roms, bgfx, plugins, language, ...</code> are expected there, unless the <code>mame.ini</code> 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 <code>mame.ini</code> first in the <code>~/.mame</code> folder. You can use the option <code>-inipath</code> to point MAME to a different path for the <code>mame.ini</code> file.
In case of the Next download [[tbblue.zip]] and put in roms folder.
 
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.


The fastest way to run a machine with desired configuration is command prompt (most of the feature available from UI, but that's take more time).
Let's cover some useful options:
Let's discover some useful options:


<ol start="1">
<ol start="1">


<li>
<li>
Use window and no mouse more till you get familiar with UI keys:
Run inside a window and with no mouse support, until you get familiar with the UI keys:
<pre>> mame tbblue -window -mouse_device none -hard /path/to/next-distribution.img</pre>
<pre>> mame tbblue -window -mouse_device none -hard1 /path/to/next-distribution.img</pre>
To launch the Linux flatpak version using the same options:
<pre>> flatpak run org.mamedev.MAME tbblue -window -mouse_device none -hard1 /path/to/next-distribution.img</pre>
</li>
</li>


Line 26: Line 35:


<li>
<li>
Don't show info popup on startup:
Don't show the info popup on startup:
<pre>> ...-skip_gameinfo</pre>
<pre>> ... -skip_gameinfo</pre>
</li>
</li>


<li>Run with debugger. If not requested on startup, you won't have access to it:
<li>Run with debugger. If you don't request this on startup, you won't have access to it:
<pre>> ... -debug</pre>
<pre>> ... -debug</pre>
</li>
</li>


<li>Use "crisp" pixels:
<pre>> ... -nounevenstretch -aspect 2:1 -video bgfx -bgfx_screen_chains unfiltered</pre>
</li>
<li>No joystick connected to PC (may slightly speed up MAME's startup):
<pre>> ... -joystickprovider none</pre>
</li>
<li>Ask for confirmation when exiting MAME (otherwise it's easy to exit MAME accidentally by hitting ESC, especially when playing games or navigating menus):
<pre>> ... -confirm_quit</pre>
</ol>
</ol>


Check [https://docs.mamedev.org/ official docs] for more advanced usage.
Check the [https://docs.mamedev.org/commandline/commandline-all.html#mame-commandline-universal official MAME documentation] for more advanced usage.


== Keys ==
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:


Keys are emulated in two modes (toggled with ScrLk): with internal UI or completely dedicated to emulated system.
<pre>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</pre>
 
= 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:
Some UI keys:
Line 46: Line 69:
* Shift+F3 - hard reset
* Shift+F3 - hard reset
* F4 - sprites/tiles/font viewer (Enter, ], [)
* F4 - sprites/tiles/font viewer (Enter, ], [)
* F5 - pause emulation
* F6 - save state
* F7 - load state
* Tab - emulator settings
* ~ - menu
* ~ - menu
* PgDwn (hold) - max speed
* ` (backtick) - debugger (when enabled by starting MAME with <code>-debug</code> or <code>-d</code> on the command line)
* Esc - exit
* 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
* F12 - MF NMI
* Esc - exit (exits menus but also the entire emulator - see <code>-confirm_quit</code> option above)
* F11 - DivMMC NMI
* 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 [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:
<pre>dd if=/dev/zero of=NextZXOS.img bs=1M count=256</pre>
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:
<pre>apt install dosfstools parted</pre>
Mount the SD card image loopback device:
<pre>losetup --partscan --show --find NextZXOS.img</pre>
Create a FAT32 partition:
<pre>parted /dev/loop0 mklabel msdos
parted /dev/loop0 mkpart primary fat32 1MB 100%</pre>
Format and mount the partition under /mnt:
<pre>mkfs.vfat -F 32 /dev/loop0p1
mount /dev/loop0p1 /mnt</pre>
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):
<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/
losetup -D</pre>
=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]]. 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 [https://discordapp.com/channels/556228195767156758/752197165891321886 Next Developer Discord].
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> 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).
= More MAME links =
The official MAME source code repository is available [https://github.com/mamedev/mame/blob/master/src/mame/sinclair/specnext.cpp here].
holub, the author of the Next emulation, maintains a fork [https://github.com/holub/mame here] that may contain new fixes and features before they are merged into the official repository.
MAME [https://docs.mamedev.org/ documentation].


= Next =
Report any issues with MAME on the [https://mametesters.org/ bugtracker].
Check [https://github.com/mamedev/mame/blob/master/src/mame/sinclair/specnext.cpp sources ] and find the way to contribute if you aware of missing pieces.
Report any issues on the [https://mametesters.org/ bugtracker].

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:

  1. 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
  2. Activate UI keys on startup:
    > ... -ui_active
  3. Don't show the info popup on startup:
    > ... -skip_gameinfo
  4. Run with debugger. If you don't request this on startup, you won't have access to it:
    > ... -debug
  5. Use "crisp" pixels:
    > ... -nounevenstretch -aspect 2:1 -video bgfx -bgfx_screen_chains unfiltered
  6. No joystick connected to PC (may slightly speed up MAME's startup):
    > ... -joystickprovider none
  7. 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 -debug or -d on 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_quit option 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.