Spectrum Next
Like many, many people I have backed the Kick Stater for the Spectrum Next and I'm planning on once again half finishing a bunch of projects that will never see light of day. That said it keeps me out of trouble so I thought I'd document a few of my adventures.
For my first steps I need to set up a development environment and as usual this will be on my Mac, though much of this will apply to Windows users too. In fact most of the tools I'm using here are .NET tools running under mono. Mono a Mac project that simply allow .NET application to run on a Mac.
If you are using a Mac you will need to download and install Mono Framework before starting. This is available free from https://www.mono-project.com/docs/getting-started/install/mac/
I've chosen to go with CSpect as my emulator, from what I've read in the forums and generally in the community this is a well regarded product and so far it's worked very well for me. It can be downloaded from https://mdf200.itch.io/cspect for free but personally I always give a few quid to the devs, these things don't write with themselves.
CSpect also includes a copy of SNasm which is my assembler of choice for this project. Both products have been developed by Mike Dailly who is not only a great dev but seem like a totally awesome guy too so thanks for your work Mike. It seems only fair to give Mike's web site a plug too so here it is https://lemmings.info
Ok now for the editor, Sublime text is my go to code editor, has been for years. But this is probably personal choice and if you want to use notepad++ or even worse VSCode it makes no difference.
Once you have downloaded all the components its time to install them, if you're using a Mac run the mono installer package and just take the defaults.
To simplify all the relative paths for building, covered later, I made a very simple file structure. Again this will make sense later.
spectrum
-CSpect
-gameName
-bin
-src
-assets
These are all relative but their placement is important later on.
First job is to copy CSpect directory from download to the spectrum folder. There will be a version tagged onto the filename, remove the version number and just call the folder CSpect. This make the path names in build script much easer to troubleshoot later on.
The SNasm assembler is already in this folder.
Also under the spectrum folder create a sub directory for each new project.
The structure of folders in the project folders just help to keep files organised and isn't essential, I just get a bit anal about code being in the "right" place.
In the project folder create a text file named build.sh and give it execute permissions, for windows this would be build.bat and you won't need to set execute permission.
Use chmod +x build.sh to make the file executable.
Edit the build.sh file and paste the following:
#!/bin/bash
echo
echo " Doing some assembling "
mono ../../CSpect/SNasm.exe -map ./main.s ../bin/main.dat
echo " Assemble done "
mono ../../CSPect/CSpect.exe -map=../projectName/bin/main.dat.map -zxnext -w5 -mmc=.i/ ../bin/main.nex
The echo statements are optional but it lets you see how things are progressing. This file can be copied to any project just edit the projectName in the last line.
I always use the main.s file as my core code file for all projects, just habit. if you start file is called something different just edit the file. Remember too that on the Mac case is important so just check that first if there are any issues.
For windows users remove the mono command at the start of the lines.
Unfortunately the mono command does not pass through any return codes from the applications so if the assemble fails there is no way to detect it and stop the script, the emulator just fires up and runs the last version of program that did assemble.
There are also a number of additional parameters you can pass to emulator, there are detailed in the readme file in the CSpect directory. This basic command line seems to do the job for me.
Now all that's left to do is setup a hot key in the editor to assemble and run. Again this is editor dependant but for Sublime I created a new build system and named it SpectrumNext using the following settings.
{
"shell_cmd": "build.sh"
}
Now when you open the base directory of the project and him apple-b the program assembles and fires up the emulator.