The Master 128 version

← Dunjunz

The Master 128 version

The official 1987 flippy disc has the Master 128 conversion on its boot side, side 2. Its BOOT is signed "Mastered by S Benfield". This document covers what that side shares with the Model B releases, what it changes, which Master features it uses, and how it copes with the Master's WD1770 disc controller and DFS 2.24 (the DFS that beebjit's Master 128 runs, sideways ROM bank 9 reading "DFS 2.24 (C)1985 Acorn" [confirmed]).

The listings are in versions/dunjunz-disc_master/, one for each program on the side: the game (disasm_dunjunz_disc_master.py, which applies the shared game annotations and adds the Master's own), *DUNJUNZ, Coder2, *EDITOR and *DEFAULT. BOOT is detokenised in basic/boot.bas. Statements are tagged [confirmed] (by the bytes, or by running the side in beebjit's Master 128 with MOS 3.20), or [inference].

In brief

The files

File Load Exec Length Runs at Contents
!BOOT — — 10 — CH."BOOT"
BOOT &0E00 &802B 668 — BASIC: on a Master shows README and runs *DUNJUNZ; otherwise asks for the flip side
README — — 544 — text: turn the disc over after choosing the heroes
Dunjunz &2649 &2649 &913 &2649 *DUNJUNZ, the loader and title screen
Coder2 &2000 &2000 &26 &2000 installs the joystick handler, then runs Coder
Coder &0400 &0740 &3FF &0400 the game's &0400–&07FE, with a loader at &0740
Dunj3 &08C0 &08C0 &43F &08C0 the game's &08C0–&0CFE
Dunj4 &0E00 &0E00 &1200 &0E00 the game's &0E00–&1FFF; a new game starts at &0E00
Dunj5 &2000 &2000 &1000 &2000 the game's &2000–&2FFF
Dunj2 &6E80 &6E80 &1180 &6E80 the game's &6E80–&7FFF
Code &C500 &C500 &6C HAZEL the joystick handler for BYTEV
Table &C5A0 &C5A0 &158 HAZEL level 25, game over, screen row offsets, pause key
Code2 &C700 &C700 &105A HAZEL the music player and its tune
Code3 &D800 &D800 &FF HAZEL a copy of the sprite plotter
Screen &3280 &3280 — — the title picture (identical to the Model B side's)
Stones &6E80 &6E80 &730 — ends with level 25 (identical to the Model B side's)
Level1 &6B00 &6B00 &2B0 — level 1 (identical to the Model B side's)
Editor &1910 &23B2 &158E &1910 *EDITOR, the level editor (see below)
Default &0E00 &0E00 &47E0 &0E00 *DEFAULT, which restores a level file from the copies it carries

Only level 1 is on this side. The README tells the players to turn the disc over once they have chosen their heroes, "in order to access the levels of play". The game then loads LevelN and Stones from the Model B side [confirmed by the catalogue and the code].

Starting up

  1. BOOT (BASIC) tests INKEY-256. On a Master 128 (253) it types README in a text window, waits for SPACE and runs *DUNJUNZ.
  2. *DUNJUNZ (&2649) loads Code2, Code3 and Table into HAZEL. It then runs the Model B side's loader start-up, which this file contains almost unchanged.
  3. It sets ESCAPE off and makes the cursor keys return codes.
  4. It sets up the Model B game's level counter and menu tables in page &08, which this side's game never reads.
  5. It loads the title picture with VDU output disabled and every colour black, then reveals it.
  6. It twinkles stars on the picture until a key is pressed.
  7. Choosing the next program. *DUNJUNZ reads joystick channel 1. A reading near the middle (high byte &80 or &81) means a joystick is present, and it runs CODER2, which loads Code (*L. Code), points BYTEV at it, and runs CODER. Any other reading runs CODER directly.
  8. Coder's loader (&0740) does the following, in order:
  9. sets the bell sound;
  10. copies page &0D to &C400;
  11. loads Dunj2 to Dunj5;
  12. restores the display that *DUNJUNZ blanked;
  13. selects COLOUR 2;
  14. jumps to &0E00, a new game.

The Master *DUNJUNZ is the Model B side's Dunjunz (load &26C0) with &2649–&26BF added in front. Only four of the bytes they share differ: - &26D2: the final *CODER becomes the joystick check. - &278D: the BREAK intercept at &0287 is left disabled, where the Model B loader arms it as JMP &15B5 to chain levels through a reset. - &287F and &2887: the row-offset table, &C375 → &C675.

All four are [confirmed].

What is shared

The resident game has the same layout as the cassette game: - &0400–&07FF; - &08C0–&0CFE; - page &0D, as workspace; - &0E00–&2FFF; - &6E80–&7FFF.

Compared byte for byte at the addresses they share (15,294 bytes, page &0D excluded), the Master game matches the sideways RAM hack in 14,534, the Model B disc in 14,490 and Ole's crack in 14,468 [confirmed].

Its pieces come from several releases: - From the cassette game (as the crack and the hack preserve it): - the resident level loop at &0E00–&0ECE; - the per-hero menu tables at &06F8; - the remains of the cassette level filename at &16D5; - the leftover filename "…nz1" at &07F5. The cassette lineage's &0400 images hold "Dunjunz1" at &07F0.

So Coder was built over a cassette-lineage &0400 image, not over one of the Model B disc's, which hold "Dun1" there [confirmed]. - From the Model B disc: - the level decryption and checksum routine at &0450–&0484; - its checksum table, with the correct &4D for level 5, unlike the crack's and the hack's &1A (see findings); - the P pause key; - the joystick handler; - the *DUNJUNZ loader.

All [confirmed].

Several routines in &1400–&1638 are byte for byte the cassette game's, at new addresses. The listing applies their shared annotations through an address shift:

Routine Cassette lineage Master
reset_workspace &14A0 &150D
draw_view_frames (its second half) &14E3 &1544
unpack_level &1510 &1571
reset_monsters &1583 &15E4
clear_text_area &161A &1619

What is different

After the first level the music's position is saved on the stack and restored, so the tune carries on from level to level. The cassette's "LEVEL n" screen is gone [confirmed]. - Screen addresses. screen_address (&0967) and the title's star plotter read the row × 640 table from Table at &C675, a copy of the MOS 1.20 table at &C375. MOS 3.20 has no such table [confirmed against the MOS 3.20 ROM]. - Text. The WRCHV handler's first instruction (&7F8F) is now JMP &E822, MOS 3.20's OSWRCH. So the game's own font routine never runs, and text appears in the MOS font [confirmed; &E822 is WRCHV's value under MOS 3.20 in beebjit]. - Keys. Three of the four heroes' keys change, and the Magic-User moves to the Master's numeric keypad:

Hero Up, down, right, left, fire (as the game's tables name them); magic Model B side
Ranger CAPS LOCK, SHIFT LOCK, Z, SHIFT, TAB; CTRL the same
Magic-User keypad #, keypad DELETE, keypad ,, keypad 3, keypad *; keypad ENTER →, ↑, COPY, DELETE, ↓; RETURN
Barbarian G, B, M, N, SPACE K, ,, /, ., SPACE
Fighter _, RETURN, COPY, DELETE, [ G, B, I, U, O

The joystick handler drives the Barbarian's keys, as it does on the Model B side [confirmed]. - Joystick. Code (&C500) is the Model B side's BYTEV handler, moved to HAZEL, with the Barbarian's new keys. It passes every other call to &EEB1, MOS 3.20's OSBYTE [confirmed; BYTEV holds &EEB1 under MOS 3.20 in beebjit]. It is installed only when the joystick reads as present at start-up. - Music. Code2 adds music during play, which the Model B releases do not have. - Set-up: start_music defines envelopes 6–9 and points EVNTV at music_event. It enables the interval-timer event and sets the timer to −12 centiseconds. - Each step: each event plays a three-byte tune step (a transposition, a channel 2 pitch and a channel 3 pitch). It also plays one step of a 32-step rhythm on channel 1 with the noise channel. - Song: the tune is 24 sections long and then loops. - Firing: the bell (VDU 7) that sounds when a missile is fired is replaced by NOPs at &6F45.

The event handler runs with HAZEL paged in (ACCCON &18 at &C76C) [confirmed]. - The sprite plotter is redirected to a copy. start_music overwrites the first three bytes of plot_sprite (&0900) with JMP &D800. Code3 at &D800 is a copy of &0900–&09FE. It is identical apart from the relocated JSR screen_address, so every sprite is then plotted from HAZEL [confirmed]. Why the copy was made is not clear from the code. - Pause is P, as on the Model B side, handled by pause_check in Table (&C6D0). The game's own pause routine at &1ED7 now just jumps there [confirmed]. - Game over stops the music. The wait for a key before a new game is &1F4 centiseconds (5 s), against 60 s in the crack and the hack and &246 in the Model B disc [confirmed].

The disc controller and the DFS

The Model B disc works only with DFS 0.90 on real hardware (see findings and the stardot notes). The game overwrites &0D00–&10FF, the DFS 1.20 NMI and workspace area, and moves between levels by resetting the machine through a BREAK intercept.

The Master version avoids every part of that:

In short, the conversion accommodates the WD1770 and DFS 2.24 by not competing with them. It lets the DFS do all the loading and keeps the DFS's NMI page intact whenever the DFS runs.

The level editor and the level restorer

The README offers two more programs: *EDITOR to edit levels and *DEFAULT to restore a level "back to its original format". Both work on the level files of the side in the drive, so the disc is turned over for them too. The Model B side has its own copies, which the README says are "for the BBC model B ONLY".

*EDITOR (&1910, run at &23B2) [confirmed from its code]: - Start-up. It copies its plotter page (&2700–&28FF) to &0900, the game's sprite plotter's home. That page holds the game's plot_sprite and screen_address, unchanged except that they read the editor's own sprite tables, together with those tables and a copy of the game's level checksum table. It also copies two routines to &7B00 and &7D80. - Choosing a level. It asks whether to edit a level or start a new one, then whether to use disc or tape (and, for disc, which drive), and *LOADs the file at &2700, over the plotter page's old copy. - Unpacking. It decrypts the level and unpacks it into 80 item slots, a wall map and an object-free map. It drops any object of type &73, the Chalice, which only level 25 has and the editor has no sprite for. It draws the 32 × 48 map in MODE 2, each cell two bytes wide and five pixel rows high. - Editing. The cursor moves with , . A Z; f0 slows it down. 1 and 2 choose the item: a wall, the exit, a trapdoor (labelled "Mons"), a door, a key, or one of eleven objects. SPACE places the item and TAB deletes. To give a door its key, choose the key, press SPACE on the door, then place the key. Holding CTRL draws each door–key link as a line. The limits are one exit, eight trapdoors, 20 doors and 29 objects. - Saving. SHIFT+S saves, once the exit, all eight trapdoors and every door's key are placed: - It walls in the map's edges and packs the slots into the level file. - It loads Stones and lets the player choose one of its 24 wall blocks. - It asks for the level's number (1–24). It sets the level's unused first byte so that the bytes sum to that level's entry in the checksum table, encrypts the level and saves it under the filename typed. - Pressing nothing at the level-number prompt catalogues the disc and calls Table's *FREE routine at &C6C0, which the game itself never uses. - Errors and BREAK. BRKV points at MOS 3.20's reset entry (&E364), so any filing system error restarts the machine. BREAK returns to the start, or to the save prompt while saving, through the BREAK intercept.

The packing walks the slots from the last to the first, while unpacking fills them from the last down. So every load and save reverses the order of each table (the exit stays in entry 30). That is the signature of the eight revised levels on the disc (see findings).

The Master conversion of the editor changes only a handful of things from the Model B side's [confirmed by comparing the two]: - BRKV &D9CD (MOS 1.20's reset entry) → &E364 (MOS 3.20's), and the final JMP &D9CD → JMP (&FFFC); - the screen row table &C375 → &C675, with *L. TABLE on the first run; - the catalogue's free-space display, now Table's routine.

The rest is the same code, moved 19–21 bytes by those changes. The two are annotated by one set of annotations (dunjunz_common/editor.py), and the Model B side's has its own listing in versions/dunjunz-disc/; after its last routine it keeps a stale copy of that routine's end.

*DEFAULT (&0E00) asks for a level number and saves that level's original file. It carries all 25 levels, encrypted, at &12B0 [confirmed]: - Its copies. They match the Model B side's files, except level 6, which is the cassette's version (see findings). - Level 25 is accepted. It is saved as Level25, a file the game never reads, since the game takes level 25 from Stones. A typed leading zero is kept too, so 05 is saved as Level05. - Its leftovers. Between the code and the levels lies the end of *DEFAULT's own tokenised BBC BASIC assembler source, lines 1150–1370. The listing shows it line by line.

The Model B side's Default (&1900) is a different program doing the same job [confirmed]: - it asks "Which level do you wish to reset ?" and accepts 1–24 only; - it carries levels 1–24 at &1DB0, byte for byte that side's level files, so its level 6 is the disc's; - the bytes between its code and the levels are leftover memory, among them most of an encrypted copy of level 4 at &1AC0. It sits where the Master's *DEFAULT keeps level 4, so it is laid out like the Master's copies.

It has its own listing in versions/dunjunz-disc/.

Hazards and oddities

All [confirmed].

Not yet examined