Post by Jonathan Cauldwell on Aug 10, 2019 21:57:38 GMT
Work is underway on a debug option for MPAGD's ZX Spectrum compiler. This will build a simple debugger into any game that allows the developer to halt the game using BREAK and step through one game frame at a time, displaying the global variables on a debug screen. It will be possible to toggle between the game screen and the debug screen or resume normal execution at any time. You'll need to run your game under 128K/+2/+3 emulation though as the debugger won't run in 48K.
As debuggers go this will start off as a simple affair but I'm sure it will prove very useful to MPAGD developers trying to fix bugs in their own games or who would like to see how other people's games are put together. Of course, those still using AGD and AGDx are able to import their games into MPAGD at any time so the debug tool will also benefit them when they get stuck.
If the debugger proves popular there will be plenty of scope to expand it in time, maybe adding the facility to add breakpoints when a variable hits a certain value or change variables' values mid-game.
Post by Jonathan Cauldwell on Aug 11, 2019 13:33:15 GMT
The basic debugger is now up and running. In fact it has taken so little time I'm thinking about improvements before I release it.
Here's a screenshot taken while stepping through Ship of Doom:
I might shorten the text at the top so I could maybe add more options and include a couple more variables. If I changed the menu to "S Step, T Toggle display, Z Zoom" would that make sense to everyone?
Post by Jonathan Cauldwell on Aug 11, 2019 20:27:02 GMT
The way this will work is the Spectrum compiler will have an extra switch, -d, to create a debug build that can be interrupted with BREAK. Without the switch, the compiler will build a release version of the game.
After feedback on Facebook I'm going with "R Run" instead of "Z Zoom".
After a little more work this evening the debugger is showing sprite parameters. The user can step through the sprite table with the 'P' key and follow a sprite from one frame to the next to see how its variables change. Tested under +2 and +3 emulation so far and working perfectly for both.
Post by Jonathan Cauldwell on Aug 30, 2019 16:38:24 GMT
If anyone wants to test the debugger, it's here. Just copy the 3 files into the compilation directory. CompilerZX.exe and EngineZX.asm should overwrite the existing files but DebugZX.asm is entirely new.
To build with the debug option, just add -d to the line in your batch file that calls compilerzx, for example change compilerzx %1 -s to compilerzx %1 -s -d
With the -d option you should be able to BREAK the main loop and step through one frame at a time, toggling the screen display between the game screen and debug so you can see what the variables and sprite parameters are doing.
I'm quite sure I'll have messed something up somewhere so let me know how you get on.
The debugger uses the 128K machines' second screen so it's 128K/+2/+2A/+2B/+3 only, sorry!