Curiosities

Findings

The loader does not read the tape: it builds a bridge on the stack

The MSX BIOS only loads the first piece, the one at 0xD800. That piece reads the other four itself, and it does it with a trick.

0xD850 puts the stack at 0xFCA4 and pushes five words that are not data but instructions: 0xC961, 0xEDD9, 0x00E1, 0xCDD9 and 0x69ED. What ends up written at 0xFC9A is this:

FC9A  ED 69     out (c),l     ; c = 0xA8: switch the slot
FC9C  D9        exx
FC9D  CD E1 00  call 000E1h   ; the BIOS's TAPION
FCA0  D9        exx
FCA1  ED 61     out (c),h     ; and put the slot back
FCA3  C9        ret

And then it calls it with call 0fc9ah.

Why on the stack? Because the game needs RAM in every page, but reading tape needs the BIOS ROM. The bridge has to live somewhere visible under both configurations, and page 3 is always RAM. Before building it, 0xD83D saves what was there — twelve words of BIOS variables — and 0xD8C1 puts them back afterwards.

And the same bridge serves three different calls, because it rewrites itself:

There is a turbo loader that goes unused

At 0xD8D5 sits a routine that reads the tape bit by hand: it waits for the edge on port 0xA2, which is where the PSG hands back the cassette input, and along the way pushes two bytes out of the PSG.

It never runs. And that is measured, not assumed: sampling the PC four thousand times while the whole tape loads (tools/omsx_muestrea.tcl) turns up only 0xD82E-0xD831, 0xD883-0xD88C and 0xD89A-0xD8AF. Not one sample lands in 0xD8D5.

It is a turbo loader left inside, unused.

The loading bar is the screen border

While it reads, 0xD8A7 pushes the low byte of what is left out of VDP register 7. No bar drawn and no tiles to paint: the border colour just keeps changing, and that is the whole progress indicator.

The routine that draws the track rewrites itself

Told in full in The code. In short: the ld a,000h that push the pixels out of the VDP port read nothing; an earlier routine writes the value into the instruction, row by row.

That is seven operands hand-written in the drawing routine alone. And there are two more elsewhere: the sound channel's volume (0x81CF over 0x81C6) and the colour of a line of text (0x9695 over a nop at 0x9808).

One routine reads all eighty keys

0xBF62 manufactures the opcode: out of the low three bits of the key code it pulls the bit number, shifts it into place, ors in a 0x47 — which is bit 0,a — and writes the result into 0xBF85, the instruction it executes two lines later.

Fourteen tracks in 3,494 bytes

The fourteen add up to 3,494 rows of five tiles. They take 3,494 bytes, one per row, because they store no tiles but indices into a table of rows living in the last 0x800 bytes of the load.

All of them are on show, drawn from those bytes, in The 14 tracks.

The loading screen's colour is compressed eight to one

In SCREEN 2 the colour table is 0x1800 bytes. The loading screen stores 0x300: one byte per pattern, because all eight rows carry the same colour, and 0x889C writes it eight times over.

And both colours fit inside that byte: bits 0 to 2 are the ink and 3 to 5 the paper, indices into a palette of eight that sits there twice — once in the high nibble and once in the low — so they can be joined with an or. Bits 6 and 7 go unused.

The very same palette is in the game, at 0x9593, byte for byte, even though they are different pieces of tape.

The patterns are stored transposed

The loop that dumps patterns into VRAM reads eight bytes with inc h, not inc hl: jumping 256 at a time. Only afterwards does it move on to the next pattern.

So the byte (base + row*0x100 + pattern) is row row of pattern pattern, not eight consecutive rows. Read the obvious way, the loading screen comes out as noise. It happens in the loading screen (0x8858), in the game (0x9522) and in the scroller's buffer (0x961A).

The stars' colour comes from register R

0x90DE takes the DRAM refresh counter, shifts it into the high nibble and writes it into the colour table. Each star comes out whatever colour it lands on, without spending a byte on the decision. And the random number generator at 0x908E does the same: it mixes its seed with R, so two games do not come out alike even from an identical start.

The game says who made it

The scroller on the title screen — from 0x9E69 to 0xA29D — gives the full credits:

Welcome to Trailblazer.......... (c) Mr Chip 1986........This amazing version written by SHAUN HOLLINGWORTH, COLIN DOOLEY, PETER HARRAP, CHRIS KERRY and GREG HOLMES (too pey?) of Gremlin Graphics Software Limited........Originally created by Shaun Southern on the Commodore.....Game play and some graphic bits by Terry LLoyd (yaki da!) and P.Harrap.

And it goes on with the keys — Q-Left, W-right, P-Up, L-Down and Space to jump — with a grumble about how hard the levels are, with a P.S don't forget to read the P.S OK or you'll be sorry! and with a Hello Mum! at the end.

The tracks are named after the people who made them

The fourteen names, at 0xA4CB:

EASY GOING · WOOLY JUMPER · TERRY'S TEST · PETE STREET · HACKERS EVIL HOLES · GREG THE NIPPER · SHAUN NOT SEAN!! · JASON'S JUMPABOUT · MARK'S MOTOROLA · CHRIS'S CUL-DE-SAC · WELL I NEVER · SHRIGGLES'S SHRIGGLE · BOING BOING SPLAT!! · LAST BUT NOT LEAST!

Terry Lloyd, Pete Harrap, Greg Holmes, Shaun Hollingworth and Chris Kerry all appear in the credits.

The cheat mode banner is there, and cannot be seen

The scroller jokes that there may be a Cheat mode but I doubt it. The banner is there all right: at 0x9CE6, FOOLED YOU! YOU ARE NOW IN CHEAT MODE, right against Gremlin's copyright, terminated by bit 7 like every string in the game.

Nothing paints it. In all 38,299 bytes there is not one instruction loading anything from page 0x9C: no ld hl,09Cxxh, no ld h,09Ch, not one stray word pointing into the block.

On the Commodore 64 you enter the cheat mode with Z+X+C. Here you cannot: the whole keyboard goes through a single routine, mira_una_tecla at 0xBF62, which builds its bit n,a inside the instruction itself; the binary holds twelve calls to it, and among the codes handed to it — a key code is row×8+bit — there is no Z (0x2F), no X (0x2D) and no C (0x18):

code key what for
0x22 M the music
0x00 row 0 its bits 3 and 4: the menu's 3 and 4
0x26 0x21 0x2C 0x25 Q L W P left, down, right, up
0x40 SPACE jump
0x31 + 0x3C CTRL + STOP quit the game in progress

And asked of the machine: with a read watchpoint over 0x9CC8..0x9D19 and the three keys held down six seconds on the title, six on the options screen and eight during play, zero reads. As a control, the combination that does exist: with a breakpoint on 0x8AC1, five seconds of play touching nothing never reach it, and pressing CTRL+STOP does.

The text made the conversion; the trigger did not.

Two kilobytes of stale memory, recorded onto the tape

The piece carrying the tracks is 10,240 bytes but only the top half is used: all its code does is move the 0x2000 bytes at 0x9000 into RAM at 0x6000, and the game, loading afterwards, walks over 0x8800..0x9000 without anyone having read it.

And we know where those two kilobytes came from: 231 consecutive bytes, from 0x8815 to 0x88FC, are identical to what the game carries for those very addresses, and the same startup code follows byte for byte. Of the 2,048, exactly half match the game.

Whoever made the tape dumped 0x8800..0xB000 in one go because what mattered was 0x9000..0xB000, and got two kilobytes of the game thrown in.

The same thing happens, smaller, with the tails of the loader (143 bytes) and of the RAM finder (175): no instruction reads them.

The loading screen is signed

STEVE., bottom right and in small type. It is the only thing on the whole tape with a person's name on it that is not in the scroller.

Open questions

All 38,299 bytes are explained and the five listings reproduce the tape byte for byte. What follows are not gaps in the disassembly: they are things the game does whose why has not been measured, or that could not be reached.

How you get into the cheat mode — closed

You do not. The banner at 0x9CE6 is unreachable: no instruction in the tape loads anything from page 0x9C, none of the twelve key checks looks at Z, X or C — the C64's combination — and a read watchpoint over the block records nothing with the three keys held down on the title, on the options screen and during play. Measured, with its control, in Findings.

Six routines nobody is known to call

0x81A5, 0x8CBE, 0x93DC, 0x9722, 0x973F and 0x9DAD disassemble as complete, coherent routines — they start on a valid instruction, touch the same variables as the rest of the game and finish on a ret — but:

Either they belong to screens the test never reached — game over, the high score table — or they are dead code. They are declared as code because that is what they are; how you reach them is not known.

The turbo loader that goes unused

0xD8D5 reads the tape bit by hand through port 0xA2, and it is measured that it does not run. What is not known is whether it is another version's loader, a leftover from testing, or an alternative path that turns on under some condition we never met.

The fifth byte of the little headers

Each piece is preceded by eight bytes: 0xFE, the load address, the length, one more byte and two zeroes. The loader reads only four (ld de,00004h), so nobody looks at that fifth byte during loading.

The four values it takes are 0x6E, 0x6B, 0x5E and 0xC1. It looks like a checksum — the loader keeps one in b while reading (0xD8A5) — but since it is never compared against anything, it cannot be asserted.

The 768 bytes of the row table that go unused

The row table takes 0x800 bytes, that is 409 rows of five. The highest index any of the fourteen tracks uses is 173. From 174 on there are rows sitting there that no track names: are they from tracks that were dropped, or just padding?

How much of each track is actually played

All fourteen are drawn in full, but it has not been measured whether the game walks them to the end or the finish comes sooner. The 0xFF that closes each list is what makes 0x8B1B flag the end of a track, so in principle yes, but it has not been checked by running it.

Who STEVE is

The loading screen carries that signature bottom right. No Steve appears in the scroller's credits: the names there are Shaun Hollingworth, Colin Dooley, Peter Harrap, Chris Kerry, Greg Holmes, Terry Lloyd and Shaun Southern.