BitMagic X16 Prog8
Debug Prog8 programs for the Commander X16 in VS Code, at the level of the Prog8 source. Programs are compiled with Prog8 and run on the BitMagic emulator.
- Breakpoints on Prog8 lines, with conditions (
i == 5), hit counts and log points (i={i}). %breakpoint in your program stops too.
- Stepping by Prog8 line: into, over and out. Calls into the Prog8 library (
txt, floats and so on) are run through, or stepped into with its source if you turn that on.
- The call stack of subroutines, each with its line. Library and ROM frames are shown too, greyed out, with the disassembly.
- Variables with their real types: bytes and words signed or not, longs, floats, bools, strings (PETSCII or ISO), arrays (paged, split word arrays put back together), pointers and structs. The subroutine's own (and its parents', for nested subroutines), its block's, the other blocks', constants, and the
cx16.r0 to r15 registers. Change them while stopped.
- Watches and hovers take Prog8 expressions:
points[i].x, ptr^^, total as uword * 2, lsb(w), len(name), with Prog8's rules (byte arithmetic wraps as it does on the X16).
- Stop on a BRK at the Prog8 line it was on, with the call stack and variables as they were.
- The X16 Screen tab shows the display and takes your typing, and the X16 Prog8 Live view shows where the program is and its block variables while it runs.
- Compiler errors and warnings go in the Problems view.
- BitMagic's own views (memory, VERA layers, sprites, palette and the rest) work alongside, as they do for assembler.
Getting started
You need Java 17 or later and the 64tass assembler (1.58 or later), as Prog8 itself does. The extension finds them on the PATH (and Java in the usual install folders), or set bitMagicX16Prog8.javaPath and bitMagicX16Prog8.tass64Path. When a folder with .p8 files opens, it tells you straight away if anything is missing or too old. If the Prog8 compiler isn't there, it offers to download Prog8 12.3.5; it never downloads Java or 64tass.
Open a folder with a .p8 file and press F5, or use Debug Prog8 File on the X16 from the editor's run button. Or run X16 Prog8: Create X16 Prog8 Project for a program to try it on; with no folder open, the Explorer has a button for it too.
The extension compiles with -target cx16 -noopt (plus -dumpvars and -asmlist, which the debugger reads) into a build folder next to the program, then debugs the result.
{
"type": "prog8",
"request": "launch",
"name": "Debug Prog8 on the X16",
"program": "${workspaceFolder}/main.p8"
}
| Option |
|
program |
The Prog8 file to compile, or a .prg the extension built before. |
compile |
Compile first (default true). |
compilerArgs |
Extra prog8c arguments, added to the bitMagicX16Prog8.compilerArgs setting. |
optimise |
Let Prog8 optimise (default the bitMagicX16Prog8.optimise setting, off). |
outputFolder |
Where the .prg and the rest go; build next to the program by default. |
project |
A BitMagic project.json to take the ROM, SD card and so on from. |
stopOnEntry |
Stop on main.start's first line. |
run |
Load the program at BASIC's READY and RUN it (default true). |
onProgramEnd |
ready (default) or terminate when the program ends. |
stepIntoLibrary |
Step into the Prog8 library rather than running through it. |
breakpointDirectives |
Stop at %breakpoint (default true). |
renderOnStop |
Draw the whole screen when stopping, so output shows straight away (default true). |
romFile |
The ROM to use, if not BitMagic's. |
sourceFolder |
Where to find sources the build's paths don't find. |
Commands and settings
| Command |
|
| Debug Prog8 File on the X16 |
Compile the open Prog8 file and debug it. Also on the editor's run button. |
| Run Prog8 File on the X16 |
The same, without debugging. |
| Compile Prog8 File |
Just compile, with the messages in the Problems view. |
| Show the X16 Screen |
Open the X16 Screen tab. |
| Choose Prog8 Version |
Pick the Prog8 to build with from its GitHub releases, betas included. |
| Check Tools (Java, 64tass, Prog8) |
Say what was found and what's missing. The same check runs when a folder with .p8 files opens. |
| Create X16 Prog8 Project |
Write a main.p8, launch.json and .gitignore into a folder, to try it on. Also in the Explorer when no folder is open. |
| Setting |
|
bitMagicX16Prog8.compilerPath |
A prog8c-*-all.jar, the folder it's in, or a prog8c launcher. If empty: PROG8C, a downloaded copy, prog8c on the PATH, or else the extension offers to download it. |
bitMagicX16Prog8.prog8Version |
A dropdown of the Prog8 to build with, downloaded as soon as it's set: the tested 12.3.5, the latest release, the latest including betas, or a particular release. The debugger supports 12.3.1 and later, including the 14.0 betas. compilerPath wins if set. |
bitMagicX16Prog8.prog8VersionOther |
The version to use when prog8Version is Other, typed in: eg a release newer than the extension. |
bitMagicX16Prog8.javaPath |
Java (or a JDK folder). If empty: JAVA_HOME, the PATH, then the usual install folders. |
bitMagicX16Prog8.tass64Path |
64tass (or its folder). If empty: TASS64, then the PATH. |
bitMagicX16Prog8.compilerArgs |
prog8c arguments for every build, eg ["-srcdirs", "lib"]. |
bitMagicX16Prog8.optimise |
Let Prog8 optimise (default false). |
bitMagicX16Prog8.stepIntoLibrary |
Step into the Prog8 library (default false). |
bitMagicX16Prog8.showRunButtons |
Show the Debug and Run buttons in the editor title for Prog8 files (default true). |
bitMagicX16Prog8.openScreen |
Open the X16 Screen tab when a program starts debugging (default true). |
bitMagicX16Prog8.debugModePath |
A debugger build to use instead of the extension's, for working on the debugger. |
Good to know
- Debug without optimisation (the default here). With it, Prog8 inlines small subroutines and turns a call at the end of a subroutine into a jump, so lines and stack frames go missing.
- Even without optimisation Prog8 removes variables nobody uses, and makes variables nobody writes into constants; those show their value and can't be changed.
- A call that's the last thing on its line returns straight to the next line, so stepping out of it stops there.
- An
asmsub or %asm block is one line; step through its instructions in the disassembly view.
- Prog8 subroutines aren't re-entrant, so every variable has one place in memory: the variables of a caller's frame are always its current values.
- The extension also gives
.p8 files basic colouring, comments and brackets. For more, the Prog8 language extension works alongside.
Requirements
The BitMagic extension, which is installed with this one, Java 17+ and 64tass.
Licence
GPL-3.0, the same as BitMagic.
| |