stevemonks / ZXSpectrumNextMachineCodeGuides

A selection of short machine code programs showing how to program various aspects of the ZX Spectrum Next.
MIT License
23 stars 0 forks source link

Generating SNX and NEX files with zcltest.exe #2

Open Threetwosevensixseven opened 3 years ago

Threetwosevensixseven commented 3 years ago

This works fine, I use it in all my projects. Both zeustest.exe and zcltest.exe have current Next support. zeus.exe and zcl.exe are older versions which have some initial experimental Next support, dating from before .nex files were invented. SImon's advice is to continue to use zeustest.exe/zcltest.exe for projects using zeusemulate "Next", and zeus.exe/zcl.exe for everything else.

  1. Add output_nex AppFilename+".nex", $FF40, AppEntry to the bottom of /SimpleSprite/zeus.asm.
  2. Download http://www.desdes.com/products/oldfiles/zcltest.exe (Version 4.09 TEST 30 Aug 2020) and place in /SimpleSprite/.
  3. Build with zcltest.exe zeus.asm.
  4. simplesprite.snx and simplesprite.nex are generated. Both work on the board with latest Next distro core/NextZXOS.
  5. Also works built with http://www.desdes.com/products/oldfiles/zeustest.exe (v4.09 TEST ONLY).
stevemonks commented 3 years ago

Thanks Robin, I know about zcltest.exe as when I was writing Galaxy of Error it very quickly grew beyond something that could be contained in a snx file.

For these examples I didn't want to direct anyone to what's labelled as a "test" version of the assembler, even though, it worked without issue for me in what turned out to be a reasonably large project (well, for one guy at least).

Interestingly, when I tried building these examples with zcltest.exe (before posting them here) it generated snx files that didn't work for me when I tested them. Dropping back to zcl.exe made everything work again, so for the sake of simplicity here I just stuck with that.

I'll revisit this over the weekend and see if I can rejig the asm files to work with both versions, additionally spitting out a .nex file if assembled with zcltest.exe.

Threetwosevensixseven commented 3 years ago

You should be able to do that, as zeus/zcl has a much older internal version number than zeustest/zcltest. The former is still at 73 (it really hasn't been updated for years), whereas the latter is now at 81 (and has years worth recent improvements). You can do something like:

if zeusver >= 81
  output_nex      AppFilename+".nex", $FF40, AppEntry
endif

Eventually zeus/zcl will have all the Next funtionality removed, and zeustest/zcltest will be renamed to something like zeusnext/zclnext, but Simon has more work planned to do before then.

If you ever reproduce the things that went wrong with SNX I'm happy to take a look. There are some Next-specific directives and the memory mapping is done in a different, Next specific way with zcltest, so it's probably that.

stevemonks commented 3 years ago

Thanks, I've just double checked it and it appears to be an issue running in CSpect (V2.12.31). If you build the PlayerSprite example with zcltest (the version I'm using is Version 4.05 TEST 23 Apr 2020) the generated snx will cause CSpect to reboot, but it seems to run okay on real hardware.

I was going to grab the latest version of zeustest.exe from Simon's site, but MS Defender has started flagging it as malware again. This happened some months ago, but seemed to resolve itself when Simon posted some updates.

It's probably a false positive (checking on virustotal.com and 7 out of 62 engines flag the .exe as malware), but I've messaged Simon via Facebook to let him know it's happening (I'm not friends with Simon on Facebook, so my message might not get through) although I'm not sure what he can do about it.

stevemonks commented 3 years ago

I've updated the zeus.asm files to generate either snx files if using zcl.exe or nex files if using zcltest.exe. This revealed a difference in the initial environment that I hadn't spotted before, that an nex file launches with interrupts disabled. When developing GOE I disabled interrupts during the initialisation phase, enabling them again before entering the game loop, so I hadn't realised this was an issue, although I think Remy had a similar issue when he rebuilt some of the examples using SJAsmPlus.

I also found an issue where examples with the code starting at $8000 didn't render colour bars in the ULA attributes correctly, they all came out black when running on CSpect. Bizarrely, moving the code start address down to $6000 rectified this. I suspect this is a bug in CSpect as I can't see any reason for this happening.