52.How to install vForth Next on MAME for the Spectrum Next - mattsteeldue/vforth-next GitHub Wiki
Introduction
You need to add vForth to the SD card image used by MAME to run the Spectrum Next.
Download and Setup MAME
Follow these instructions here to install MAME, add the boot ROMs and NextZXOS Images: https://wiki.specnext.dev/MAME:Installing
You should make sure the MAME image runs.
Download vForth
Get vForth-Next ... either by getting a zip of the latest (use the green Code button and select Download ZIP or by cloning the repo with Git. Get it from https://github.com/mattsteeldue/vforth-next
Alternatively the latest download vForth is here: https://github.com/mattsteeldue/vforth-next/tree/master/download - Download the zip, and extract it to a local folder. (This is in the download directory of the GitHub repository.)
Working with the Image
During installation of MAME, you will have got an image file named something like cspect-next-2gb.img maybe from https://zxnext.uk/hosted/
These files are disk images. This should have enough space to add vForth without increasing the size.
You can get most operating systems to mount the disk image. However I prefer to use hdfmonkey to edit it from the command line.
You can get HDFMonkey from Git, but I notice that the MAME install page above uses the hdfmonkey "jjjs build" which is a variant of hdfmonkey tool. https://www.specnext.com/forum/viewtopic.php?t=2604 - You should be able to use either.
Once install, first list the file:
path/to/hdfmonkey ls path/to/cspect-next-2gb.img
Replace the path/to with the actual path of the files. I'm going to assume they are both in the current directory (or in your search path) in the following commands.
The output of ls will be something like:
5186 LICENSE.md
[DIR] apps
[DIR] demos
[DIR] docs
812 .gitignore
146 version.txt
286720 TBBLUE.FW
[DIR] sys
1722 README.md
10256896 TBBLUE.TBU
9662 CONTRIBUTING.md
[DIR] games
[DIR] dot
[DIR] machines
[DIR] home
[DIR] tmp
[DIR] nextzxos
I think there is no tools directory by default, so we are going to create one:
hdfmonkey mkdir cspect-next-2gb.img /tools
If you do an ls you will see it at the bottom
hdfmonkey ls cspect-next-2gb.img
5186 LICENSE.md
[DIR] apps
[DIR] demos
[DIR] docs
812 .gitignore
146 version.txt
286720 TBBLUE.FW
[DIR] sys
1722 README.md
10256896 TBBLUE.TBU
9662 CONTRIBUTING.md
[DIR] games
[DIR] dot
[DIR] machines
[DIR] home
[DIR] tmp
[DIR] nextzxos
[DIR] tools
Update Directory with vForth
We then copy the from zip file contents to SD image - the summary of this section is:
- the whole "vForth" directory to C:/tools/vForth, and
- the dot commands into C:/dot
If you use vForth_18_NextZXOS_20260101.zip, then unzip it, and see:
- tools directory with vForth directory inside
- dot directory with two files inside
If you cloned (or get a ZIP) of the whole vForth directory then these folders are inside the SD/ directory.
I will assume the SD directory, but modify the source directories as appropriate to your case.
Copying
To copy the vForth directory:
hdfmonkey putdir cspect-next-2gb.img vforth-next/SD/tools /tools/
To copy the dot files:
hdfmonkey putdir cspect-next-2gb.img vforth-next/SD/dot /dot/
Check the files are there:
hdfmonkey ls cspect-next-2gb.img dot
hdfmonkey ls cspect-next-2gb.img tools
Use SD/MMC Card in the Emulator
You should have run this when originally install MAME...
On Linux or Mac, this would look like:
./mame tbblue -window -mouse_device none -hard1 cspect-next-2gb.img
Run vForth
Forth System is loaded and activated by the Basic program C:/tools/vForth/forth18_loader.bas or via dot command .vforth.
-
Using the browser: Navigate to C:/TOOLS/VFORTH and select “Forth18_loader.bas”.
-
Using dot comment: After this and restarting MAME then you should be able to launch vforth by typing .vforth in the “Command Line” of Spectrum Next.
Editing code
There are some tips about editing code when using an emulator on the page Editing Forth code
Mounting the disk image as a drive (ImDisk)
A very useful technique when working with the ZX Spectrum Next is to mount the .img file as a real drive letter in Windows. This allows easy file copying, massive updates, and editing of the SD card image without having to constantly uncompress/recompress files.
Download ImDisk ToolkitOfficial repository: https://sourceforge.net/projects/imdisk-toolkit/files/Download the latest 64-bit version (ImDiskTk-x64-....zip).
Example command (mount)bat
imdisk -a -t file -m W: -o rem -f cspect-next-2gb.img -v 1
Example command (unmount)bat
imdisk -D -m W:
Recommended .bat files
You can create two small batch files for convenience:
Mount_Next.bat
@echo off
imdisk -a -t file -m W: -o rem -f "cspect-next-2gb.img" -v 1
echo.
echo Image mounted as W:\
pause
Unmount_Next.bat
@echo off
imdisk -D -m W:
echo.
echo Image unmounted.
pause
Important: Always unmount the image properly before using it with MAME, CSpect or writing it to a real SD card.