The first thing you do with a cartridge is disassemble it. Here you get
nonsense: the entry point is nop / dec h / add a,b / ld bc,09700h / illegal
sequence. It is not that the disassembler is failing: there is no code
there.
The header says so if you read all of it. INIT, STATEMENT and DEVICE all zero,
and the only thing declared is TEXT=0x8010. That means "there is a BASIC
program here", and the interpreter runs it from the ROM itself, without
copying it to RAM. The game's only call to machine code, USR(0) in line
30000, points at address 0: pressing STOP resets the machine.
The nine holes take exactly 4,000 bytes, from 0xB000 to 0xBF9F, one behind the other. Each is a list of 16-bit values that subroutine 2500 reads with PEEK. The values run three at a time - x, height, depth - and a lone value between 30001 and 30015 is a marker: it changes the colour whatever follows is drawn in and, along the way, shifts the grouping by one. A 32000 closes the hole.
The marker's colour is not decoration: it says what the next stretch is made of, and it is used to fill in the previous one. The order is the same in all nine:
6 the outer outline; its fill is the out-of-bounds
2 the fairway 3 the green
1 the flagstick; its fill, with the seed on top, is the hole
14 the bunkers 4 the water
13 the trees
Each hole's colour-1 stretch is four points: an 8-high vertical mast and a triangular pennant at the top. And it is planted exactly where that hole's DATA declares the flag to be, in all nine.
That matters because the DATA's order is not obvious. Each line carries the par, the distance, a varying number of fill seeds and the flag - and the flag is the last two values, not the first. We know because three separate counts have to agree at once, and they do:
PQ$
string in line 80 and add up to 36, the total the scoreboard writes by
hand.And there is a fourth check, coming from somewhere else entirely in the cartridge: the frozen round in the variable table (see below).
Trees are three consecutive magenta stretches: two crossed diagonals and the trunk. That is, four edges from the corners of a 4x4 base up to an apex 15 high, plus the axis. A wireframe fir in five lines.
It looked like the end of the run, and it is not. It is where subroutine 4000 - the plan view - stops drawing. What comes after still belongs to the hole, and subroutine 5000 draws it: two or three stretches with coordinates up to 20,000, which are the vanishing lines out to the horizon, and on hole 3 a 2,000x400 wall at depth 1,200: the mountain in the background. They are only visible in perspective.
Line 5166 works out each marker's colour... and nobody looks at it. Line 5690 draws always in white (or dark green when the camera is in the green's close-up). The colours only matter for the plan.
There is no logical map, no grid of cells. Line 380 takes the ball's position over to the plan view in the right-hand panel and reads with POINT the colour painted there. That colour is the terrain, and out of it come the golfer's stance, the penalties and how the ball bounces.
Which is why the plan is not decoration: it is the game's data structure, and why the order of the markers matters so much.
Line 440 checks whether the terrain is colour 12 and slows the ball if it is. That condition cannot happen: no hole paints colour 12 on the plan, in any of the nine. It is dead code - most likely the rough of an earlier version, before the rough became the background colour, which is 0.
The 3,231 bytes between the program and the course data are the interpreter's variable table, frozen exactly as it was left in a real session of the game. That is the trick that boots a BASIC cartridge with no INIT routine: the ROM carries the program and its state already set up.
It can be read in full, and it tells a story: hole 2, twelve strokes in all,
eleven of them spent on hole 1. And the course read pointer, ZM, holds
0xB37A - which is exactly where hole 3 begins, because with hole 2 in play its
outline had already been read. HX and HZ hold hole 2's flag with the
one-metre adjustment already taken off, and P holds 3, its par.
Four figures from the frozen state that agree with the reading of the course data, without using the program at all.
The last array, C1(), starts at 0xAFA1 and does not fit: it is 25 bytes
short, which is precisely where the course data begins. The table is cut off,
and it does not matter, because the interpreter rebuilds it all when it runs the
DIM in line 20.
The program never issues a RESTORE, and the ZM pointer does not rewind
either. The nine holes' DATA are read straight through, once, and the course is
read straight through, once. After hole 9, line 720 is a GOTO 720: an infinite
loop. Playing again means resetting the machine, and that is not an oversight at
the end - there would be no way to rewind even if it jumped back to line 110.
If the ball is in sand and you pick the putter, line 280 sends the turn back to the start. But the start of the turn is line 225, which adds a stroke. Trying it costs a stroke every time, with the ball never moving.
D2(240) is reserved in the DIM in line 20 and appears in no other line of
the program: 482 bytes of RAM set aside for nothing. ZL$ is assigned "0000"
at the end of line 70 and nobody reads that either. And the lone RND(1) in
line 90 does have a purpose: it stores its result nowhere, it is there so the
generator has advanced an unpredictable number of times before the first hole's
wind is drawn.
What is not settled, said as what it is.
DEFINT D and the 3D viewLine 3 ends in DEFINT D, verified in the bytes (AC 44). That makes every
variable starting with D an integer, DN() included - and DN() is where
subroutine 5000 keeps the rotated outline. The rotation in lines 5140 and 5145
ought, therefore, to be rounded to whole numbers.
Drawing the view both ways and comparing against the emulator's VRAM gives the opposite of what you would expect: without rounding, 18,011 of 18,432 pixels match; with rounding, only 17,756. Something is missing from the chain. It is written down as a question, not a conclusion.
The cartridge's own frozen variable table confirms DEFINT D is in force -
DX, DY, DZ, DD, DA, DB and D4-D7 are all stored as two-byte
integers, and DI() as an integer array - so the doubt is not whether the
directive works: it is why the drawing comes out better without applying it.
Of the 18,432 pixels in hole 1's view, 421 do not match the emulator. All of them are edge pixels of the same lines, off by one: the lines are where they should be, but the staircasing differs. Six variants of the trace were tried - initial error at 0, at half, at half plus one, at maximum, at one, and with the endpoints swapped - and they all land between 97.4 % and 97.8 %. Emulating the interpreter's six-digit precision does not fix it either.
It reads through and fits: 98 plain variables and nine arrays, in the program's
order, with the last one cut off 25 bytes from finishing because the course data
starts at 0xB000. What has not been done is checking value by value that all
98 hold what they should at that point in the round: the ones that pin down the
course reading were checked (H, ZM, HX, HZ, P), and the rest were taken
as good because the pattern fits.
From 0xBFA0 to 0xBFFF sit 96 bytes nobody reads: the ninth hole ends at 0xBF9F and that is where everything the program consults stops. They are not zeros - there is content - but no line reaches that far. Most likely they are whatever was in memory when the ROM was burned, like the variable table, but that is not verified.
All nine are decoded and drawn, and the three cross-checks agree on all nine. But only hole 1 has been compared against the emulator's VRAM, because to see hole 2 you have to hole out on 1, and there is no convenient way to automate that: the program has no shortcut for changing hole and the round cannot be rewound.
The other eight come out of the same engine and the same data, and their reading is backed up as well by the cartridge's frozen round, which points at hole 3. But compared byte for byte against the machine, one.