Skip to content

Releases

B65 BASIC v0.3: the GHZ demo, OBJ65 for BASIC 65, 4-pixel painting

Choose a tag to compare

@beniacm beniacm released this 10 Nov 10:28

B65 BASIC is a BBC BASIC (Z80 v5 derived) interpreter for the MEGA65, rewritten for the 45GS02.

What's new since v0.2

  • GHZ, a three-act demo written in B65 BASIC (GHZ.BAS). It runs at 50 frames per second throughout.

    • Act 1 replays Maxice's SCROLLTEST, the Green Hill scroller from INTRO2.D81, frame for frame: seven parallax bands, the front layer, 64 rings and the waterfall.
    • Act 2 scrolls the program's own listing over the running scene.
    • Act 3 (K325T core) moves the rings into the list-mode object table: 1000 rings, plus clouds and bushes as objects, with a HUD showing the VIC-IV's own counters.

    The program reads the art at run time from your own copy of INTRO2.D81 (every MEGA65 SD card from the filehost has it). Without it, the demo uses an original generated tileset. None of the original art is in this repository or this release.

    video: (link follows)

  • OBJ65 for BASIC 65: the v3 object table, the collision engine and B65's object motion for BASIC 65 programs.

    • The library is two PRGs, OBJ65 and OBJ65X.
    • Four POKE recipes come with it, plus jumper65, the BASIC 65 twin of jumper.
    • docs/OBJ65.md describes it all.
  • 4-pixel painting (K325T step-7 core, feature level 4): every list-mode demo sets XCTL2 bit 0 when the core has it.

  • B65:

    • BGET#c,addr,n reads a block from a file into memory (34 KB in about 20 ms).
    • The compiled-expression cache has 16 ways instead of 4. Before, a loop could slow down for no visible reason when its lines moved in memory; benchmarks are unchanged.
    • INKEY at the end of a test script returns "no key" instead of ending the session.
  • Fixed, objects standing still on the K325T: when an update of the moving objects took more than about 3.9 ms (swarm2's 1000 bullets), B65's frame interrupt still held the VIC-IV's table snapshot at the next frame top, so the picture never changed. v0.2 had the same fault. The interrupt now runs just after the frame top, so an update has almost the whole frame. OBJ65 steps from BASIC 65's own interrupt below the picture: keep its updates under about 3.5 ms (docs/OBJ65.md).

  • Programming note, the RRB row budget: every token of a row costs painting time, even when it is parked off the screen. On a standard VIC-IV a row of 186 tokens needs DBLRR ($D051 bit 6). Set CHRCOUNT ($D05E) to the tokens a screen really uses. docs/USER.md and docs/GHZ.md have the details.

Files for the SD card (all in the SD card's root directory; B65 reads data files only from there, not from a mounted D81):

  • GHZ.BAS, B65GHZG.BBC (the generated tileset) and B65GHZS.BBC (act 2's font and listing, act 3's art).
  • INTRO2.D81, which is already on your card: GHZ takes the original art from it.

Then LOAD "GHZ", RUN in B65.

Downloads:

  • b65.d81: the interpreter as B65, the examples as text files (GHZ.BAS among them), OBJ65 and the BASIC 65 programs. Mount it, then DLOAD "B65", RUN.
  • b65.prg: the interpreter alone, load address $2001.
  • B65GHZG.BBC and B65GHZS.BBC: GHZ's data files, for the SD card root.

Verified:

  • K325T rig with the step-7 core (feature level 4):
    • smoke 34 of 34, the v3 object board test 20 PASS / 0 FAIL, SELFTEST 14 PASS / 0 FAIL (batch 4 core);
    • demos at 50 fps: jumper 600 frames in 1198 cs, swarm2 1500 in 3024 cs (moving: the integrator fix below), bounce 1500 in 3004 cs (850 pairs), parallax 600 in 1200 cs;
    • the SD card fsck-clean before and after the file tests;
    • 4-pixel painting (XCTL2 bit 0, with XCTL $D9): in a steady window the longest line painting is 326 cycles against 578 without it (bounce) and 651 against 1592 (swarm2, 1000 moving bullets), with no port collisions and no late pixels in either mode;
    • GHZ (2026-11-10): 1500 / 1532 / 1401 frames in its three acts at 50 fps (3 / 0 / 12 late frames), no late pixels, no one-frame glitches in the video.
  • Xemu: smoke, the check scripts, the GHZ, object and HITPIX models, and the card tests (fsck clean).

A standard MEGA65 has not been tested yet. B65 is written to run on one. Everything works there except drawing the list-mode objects, which still move logically. GHZ's acts 1 and 2 use only standard VIC-IV features; act 3 then shows a one-line note. If you have a standard MEGA65, please type *INFO, run SELFTEST (LOAD "SELFTEST", RUN) and GHZ, and paste the outputs (GHZ prints frames and late frames per act at the end) into an issue at https://github.com/beniacm/b65-basic/issues. Reports of any kind are welcome.

B65 BASIC v0.2: 5-6x faster than BASIC 65, and 1000 moving objects

Choose a tag to compare

@beniacm beniacm released this 09 Nov 15:52

B65 BASIC is a BBC BASIC (Z80 v5 derived) interpreter for the MEGA65, rewritten for the 45GS02.

What's new since v0.1-dev.1

  • Speed: 5-6 times faster than BASIC 65 on the board. Per statement:

    statement BASIC 65 B65 v0.2
    POKE 135 µs 24 µs
    integer add and IF 142 µs about 24 µs
    4-byte ! write 162 µs 40 µs
    MOD/AND expression 328 µs 62 µs

    How:

    • a compiler for numeric expressions, assignments and single-line IFs, with a cache of the compiled code;
    • integer constants encoded when the line is entered, integer FOR...NEXT, and the 45GS02 math unit for *, DIV and MOD;
    • cached GOTO/GOSUB targets and PROC/FN definitions.
  • Moving objects (list mode v3, K325T step-6 core): B65 keeps the table for up to 1024 objects and moves them in its frame interrupt; BASIC only starts and steers them. The statements:

    • OBJECT, OBJVEL, OBJMOVE (straight, turning, exact polar), OBJORBIT, OBJSPRING;
    • OBJLIFE, OBJLIMITS / OBJBOUNDS (wrap, bounce, kill), OBJKILL, OBJUPDATE;
    • ON OBJEVENT, OBJX/OBJY/OBJVX/OBJVY/OBJEVENT( );
    • HITPIX(a,b[,dx,dy]), a pixel-exact overlap test.
  • The K325T collision engine: ON COLLISION PROCname and COLLIDE(n) for objects 0..1023.

  • Diagnostics: *INFO (version, machine, ROM, RAM, K325T feature level) and SELFTEST (one PASS/FAIL line per subsystem).

  • Other changes:

    • whole-array AND, plus a tight integer loop for whole-array + and -;
    • WAIT on the VIC-IV frame counter;
    • *DELETE keeps both FAT copies and the free count right;
    • the packed PRG starts in 0.78 s.
  • New examples: bounce (64 balls), swarm (255 objects), swarm2 (1000 bullets), jumper (pixel-accurate platforms) and selftest. The first line of every example says which core it needs.

On the K325T rig with the step-6 core, jumper, bounce and parallax run at 50 frames per second, and swarm2 at 49 with 1000 bullets.

Flag day: the step-6 core (mega65-core 0209a1c57) uses 32-byte object table entries. The object examples in this release need it, so do not run them on older K325T bitstreams (feature levels 1-2). Programs that build a 16-byte table by hand move entry n from base+16n to base+32n. Tokenised programs SAVEd by v0.2 do not run in v0.1-dev.1; keep text copies.

Downloads:

  • b65.d81: the interpreter as B65 plus the examples as text files. Mount it, then DLOAD "B65", RUN; in B65, LOAD "JUMPER", RUN.
  • b65.prg: the interpreter alone, load address $2001.

Verified:

  • K325T rig with the step-6 core: smoke 33/33, the v3 object board test 20/20, SELFTEST 14/14, and the demo timings above.
  • Xemu: smoke, check scripts, the object and HITPIX models, and the card tests (fsck clean).

A standard MEGA65 has not been tested yet. B65 is written to run on one: everything works there except drawing the list-mode objects, which still move logically. Nobody has tried it on a stock machine yet. If you have one, please type *INFO, run SELFTEST (LOAD "SELFTEST", RUN) and paste both into an issue at https://github.com/beniacm/b65-basic/issues. Reports of any kind are welcome.

B65 BASIC v0.1-dev.1 (first preview)

Pre-release

Choose a tag to compare

@beniacm beniacm released this 08 Nov 16:55

First preview of B65 BASIC, a 45GS02 re-implementation of R.T. Russell's BBC BASIC (Z80) v5 for the MEGA65 (zlib licence). Built from commit e347057; the interpreter is the one verified on hardware (see "Status").

Files

file what it is
b65.d81 disk image with B65 (the interpreter) and the examples as text files: PARALLAX.BAS, RRBLISTB65.BAS, RRBLISTB65V2.BAS, plus PARALLAX65.PRG (the BASIC 65 twin of the parallax demo)
b65.prg the interpreter alone (load address $2001, 42 647 bytes) for loaders that push a PRG straight into memory
*.bas the example sources as text
SHA256SUMS checksums of the two binaries

How to use it

On a MEGA65 (any core with the MEGA65 ROM, tested with ROM 920413):

  1. Copy b65.d81 to the SD card.
  2. Mount it (the MEGA65's disk menu, or in BASIC 65: MOUNT "B65.D81").
  3. DLOAD "B65" then RUN. The banner shows the detected hardware (model, chip RAM, attic RAM).
  4. In B65: LOAD "PARALLAX" then RUN (LOAD "RRBLISTB65V2" and LOAD "RRBLISTB65" need the K325T core's RRB list mode; they say so in their first lines). Programs are typed in the BBC way: keywords in upper case, LIST, RUN, NEW, SAVE "NAME".
  5. Files: B65 reads and writes the SD card's FAT32 partition directly (LOAD, SAVE, OPENIN/OPENOUT, *CAT, *DELETE) and reads text programs from a mounted D81. A text program (plain ASCII, one line per program line, optional line numbers) loads with LOAD "NAME"; NAME.BBC (tokenised) is tried before NAME.BAS.

In Xemu (needs the MEGA65 ROM): xmega65 -8 b65.d81, then DLOAD "B65" and RUN in BASIC 65.

On the QMTech K325T rig (the board this was developed on, https://github.com/beniacm/mega65-k325t-cm4): scripts/b65_run.sh builds and starts it through the serial monitor; scripts/b65_run.sh demo FILE.bas also runs a program.

The language guide with the MEGA65 extensions (timers, SOUND/ENVELOPE, MODE 1 graphics, sprites, MOUSE, 28-bit ?/!/|, attic-RAM arrays, the list-mode demos) is docs/USER.md in the repository; docs/DESIGN.md describes the implementation and the memory map.

Status

  • Verified on the QMTech K325T build of the MEGA65 core (this repository's test rig): 22/22 smoke tests, the file tests on a real FAT32 card (fsck clean), MODE 1 graphics, sprites, MOUSE, SOUND, timers, 60 KB programs in bank 1, 2 MB attic-RAM arrays, and the parallax demo (pictured in the repository's README once the images are added).
  • A standard MEGA65 (R3–R6) has not been tested yet: HyperRAM timing for the attic arrays, the SD controller path and the non-K325T detection branch have only run in Xemu. Reports welcome.
  • Not yet implemented: see the feature table in the README (e.g. *EXEC, some * commands). Performance work is in progress: at this commit B65 is about as fast as BASIC 65 per statement.

Changes since the start

Everything is new. The highlights of this preview: the full BBC BASIC V statement set incl. whole-array operations and RETURN parameters, 40-bit floats on the MEGA65 math unit, files on FAT32 and D81, the MEGA65 extensions above, a 256-colour parallax demo written identically for B65 and BASIC 65.