Skip to content

Instantly share code, notes, and snippets.

@fizzyade
Last active September 20, 2020 22:04
Show Gist options
  • Save fizzyade/787582b77329ac045dca94ecc09635e7 to your computer and use it in GitHub Desktop.
Save fizzyade/787582b77329ac045dca94ecc09635e7 to your computer and use it in GitHub Desktop.
simple script to assemble, insert executable into mmc image and then start the emulator for ZX Spectrum Next development
#!/usr/bin/env sh
# this script has only been tested on macOS.
# (C) 2020 Adrian Carpenter
#
# This script will assemble and then launch an application in CSpect. The assembly file should be named the same as the
# folder, for example if the folder "mygame" holds the source code, then inside that folder should be a file named "mygame.asm",
#
# This negates the need to modify the script for a new project, you just have the have the folder and the main assembly file
# named the same.
projectName=${PWD##*/}
which sjasmplus
if [ $? -ne 0 ]; then
echo "Error: sjasmplus needs to be in the path. See https://github.com/z00m128/sjasmplus"
exit 1
fi
which mono
if [ $? -ne 0 ]; then
echo "Error: mono needs to be in the path. See https://www.mono-project.com/download/stable/"
exit 1
fi
which hdfmonkey
if [ $? -ne 0 ]; then
echo "Error: hdfmonkey needs to be in the path. See https://github.com/gasman/hdfmonkey"
exit 1
fi
which txt2bas
if [ $? -ne 0 ]; then
echo "Error: txt2bas needs to be in the path. See https://www.npmjs.com/package/txt2bas"
exit 1
fi
if [ ! -f /usr/local/CSpect/CSpect.exe ]; then
echo "Error: CSpect needs to be installed in /usr/local/CSpect. See http://dailly.blogspot.com"
exit 1
fi
sjasmplus --zxnext=cspect $projectName.asm
if [ $? -ne 0 ]; then
exit 1
fi
if [ ! -f ./$projectName.mmc ]; then
echo "Error: $projectName.mmc not found. See http://www.zxspectrumnext.online/cspect/"
exit 1
fi
hdfmonkey put $projectName.mmc $projectName.nex
if [ $? -ne 0 ]; then
echo "Error: failed to add application to disk image."
exit 1
fi
echo "10 CD \"C:/\":.nexload $projectName.nex" >autoexec.bas.source
txt2bas -f 3dos -i autoexec.bas.source -o /tmp/autoexec.bas
if [ $? -ne 0 ]; then
echo "Error: failed to convert autoexec source file to tokenised file."
exit 1
fi
hdfmonkey put $projectName.mmc /tmp/autoexec.bas NextZXOS/autoexec.bas
if [ $? -ne 0 ]; then
echo "Error: failed to add autoexec.bas to disk image."
exit 1
fi
if [ ! -f ./enNextZX.rom ]; then
ln -s /usr/local/CSpect/enNextZX.rom ./enNextZX.rom
if [ $? -ne 0 ]; then
echo "Error: Unable to symlink enNextZX.rom."
exit 1
fi
fi
if [ ! -f ./enNextMF.rom ]; then
ln -s /usr/local/CSpect/enNextMF.rom ./enNextMF.rom
if [ $? -ne 0 ]; then
echo "Error: Unable to symlink enNextMF.rom."
exit 1
fi
fi
if [ ! -f ./enNxtmmc.rom ]; then
ln -s /usr/local/CSpect/enNxtmmc.rom ./enNxtmmc.rom
if [ $? -ne 0 ]; then
echo "Error: Unable to symlink enNxtmmc.rom."
exit 1
fi
fi
mono /usr/local/CSpect/CSpect.exe -zxnext -nextrom -w4 -mmc=./$projectName.mmc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment