A commented disassembly of Hole in One Professional, the golf game HAL Laboratory released for the MSX in 1986: a 32 KB cartridge mapped into pages 1 and 2 (0x4000–0xBFFF). It reassembles to the exact ROM, byte for byte, and every one of its 32,768 bytes is accounted for.
No repository distributes the game. Put your own dump in the root as
holeinonepro.rom, 32768 bytes, sha256
99900247abc5cff8f12fed900e4ebf783c7a7ecf8d689b4a5cccd85a8416451e
make comprueba verifies it.
make comprueba the dump's sha256
make trace, listing, byte-for-byte reassembly,
coherence checks and tests
make densidad how many instructions carry a comment
make imagenes draws the images from the ROM
make vram and compares them against the emulator's VRAM
make web regenerates this site
make with no arguments is what decides: if the listing does not produce the
ROM byte for byte, it fails.
src/holeinonepro.asm the listing, generated
src/holeinonepro.notes the comments, anchored to addresses
src/holeinonepro.entries the entry points, each with its justification
src/holeinonepro.nocode the ranges that are NOT code
tools/ the tools, all of them measurable
tests/ what is claimed, tied to the binary
The .asm is generated and regenerated. What is edited by hand are the notes: a
file of address-anchored directives, so the comments survive a re-trace.
This is the check that decides whether the images are worth anything. The dump comes out of openMSX:
openmsx -machine C-BIOS_MSX1_EU -cart holeinonepro.rom \
-script tools/omsx_vram.tcl
and then make vram compares, byte for byte, the VRAM tools/graficos.py
builds against the real one. 28,240 of 28,240 match across patterns, colour,
sprites and all THREE name tables. The 17 cells that differ are the figures the
game writes as it plays: the TOP, the shot counts, the hole number, the distance, the
par, the wind and the slope.
32,768 bytes mapped into pages 1 and 2, that is, 0x4000 to 0xBFFF.
The first ten bytes are the MSX's AB header:
41 42 10 40 00 00 00 00 00 00
'A''B' INIT STATEMENT DEVICE TEXT
It only declares INIT, at 0x4010. STATEMENT, DEVICE and TEXT are zero, and
that is precisely what separates this cartridge from the 1984 Hole in One:
that one registered a BASIC statement — CALL GOLF — and could therefore load
courses from tape. This one does not. Outside courses get in another way: through
the editor.
| from | to | what |
|---|---|---|
| 0x4000 | 0x4010 | the AB header |
| 0x4010 | 0x5009 | boot, menu, scorecard and the round loop |
| 0x5009 | 0x5175 | the thirty-five golfers and their tables |
| 0x5175 | 0x52DE | the title screen's texts |
| 0x52DE | 0x63E9 | the shot: aim, bars, flight and physics |
| 0x63E9 | 0x6603 | terrain, arithmetic and the trigonometry tables |
| 0x6603 | 0x6C0D | screen, interrupt, joystick and the PSG player |
| 0x6C0D | 0x6F49 | the tone table and the twelve tracks |
| 0x6F49 | 0x716B | the hole builder |
| 0x716B | 0x9DDD | the two courses: 36 pointers, 36 scripts and the green |
| 0x9DDD | 0x9F85 | the close-up view and the swing |
| 0x9F85 | 0xAEA3 | everything that decompresses into VRAM |
| 0xAEA3 | 0xC000 | the course editor and the tape code |
In numbers: 14,186 bytes of traced code and 18,582 of named data. None unaccounted for.
init (0x4010) does the usual and one thing more. First it works out which slot
it is in itself — RSLREG, the subslot table at 0xFCC1 — and stores the result
at 0xFEDB. It will need that note much later, when the tape routine swaps page
1 for the BASIC ROM and has to put it back.
Then it pages its own second half into page 2 with ENASLT, clears 0xC002–0xF300 in one go, leaves QUEEN SIDE as the default course and the TOP at 0x12 — eighteen, one over par on every hole — starts the PSG, hooks the interrupt and goes off to the attract mode.
0x6603 does not put a jp into H.TIMI: it puts an inter-slot call.
ld a,0f7h ; 0xF7 is RST 30h, that is, CALSLT
ld (0fd9fh),a
ld a,(0fedbh) ; the slot, the one init noted down
ld (0fda0h),a
ld hl,0665bh ; and the address
ld (0fda1h),hl
It has to be that way because the handler lives inside the cartridge, and when the interrupt fires there is no guarantee the cartridge is paged in. The handler (0x665B) does two things: it marks that a frame has passed, and it gives the PSG player one step.
The MSX's SCREEN 2 has one name table, but VDP register 2 says where it is. This cartridge builds three and flips that register:
| address | what it is | how you get there |
|---|---|---|
| 0x1800 | the playing screen | the default, R2=0x06 |
| 0x1C00 | the eighteen-hole scorecard | 0x678B, xor 1 |
| 0x3C00 | the tournament leaderboard | 0x67CC, xor 9 |
Pressing F1 or F2 mid-round redraws nothing. It shows another screen that was already built, and letting go returns to the previous one.
SCREEN 2 is three independent thirds, and for all three to hold the same thing you have to write it three times. 0x66D4 makes the six calls — three of patterns and three of colour — and all three of each kind decompress the same source: 2 KB of cartridge for 6 KB of table.
And there is a second loading mode hidden in the same place. 0x66D4 begins with
an or 0AFh, which is the two bytes F6 AF. Entering at 0x66D5 — the second
byte of that instruction — what runs is a bare xor a: A goes to zero, Z is set
and the six calls load only the 360-byte tail of each third, which is tiles
0xD3 to 0xFF.
And those forty-five tiles are the title wordmark. The same ones that in play are the tee, the green and the flag. The cartridge swaps them by entering one instruction or the next, and (0xCA40) records which of the two sets is in place: that is why pressing F1 at the menu loads the playing tiles so the scorecard can be drawn, and then puts the wordmark's back.
There are two decompressors, told apart by their escape byte:
0xA0–0xAF means (n & 0x0F) + 2 copies of the next
byte.0x00–0x0F means (n & 0x0F) + 1 rounds of a pair of
alternating bytes. This is the one for SCREEN 2's colour tables, where bytes
come in pairs.Both stop when the destination reaches its limit, not when the input runs out. So where each block ends is written down nowhere: you find out by decompressing it. Do that, and the eleven fit one after another without a byte to spare, from 0x9F85 to 0xAEA3. It is the best evidence the format is understood, and there is a test watching it.
How the listing is made and why you can trust it.
Nobody edits the .asm. tools/mkasm.py generates it from three things:
tools/z80trace.py), which follows the code from the
entry points and marks which bytes are instructions;That way the comments survive a re-trace: if tomorrow a block turns out to be code, you re-trace and the comments stay where they were.
make verify
assembles the listing with pasmo and compares the result to the ROM. Byte for byte, the same sha256. Without that, everything else is decoration.
Reassembling cannot tell bytes read as code from the same bytes read as data: the binary comes out the same. So there are three more checks:
Static tracing does not reach everything. The ones that have to be declared by
hand live in src/holeinonepro.entries, each with its justification:
jp (hl) use to
dispatch the editor's states.ret.| traced code | 14,186 bytes (43.3%) |
| identified data | 18,582 bytes (56.7%) |
| unaccounted for | 0 |
| instructions | 7,133 |
| line comments | 3,169 |
| density | 44.4% |
| routines below 10% | 0 |
call targets left unnamed |
0 |
The last three are the series' bar, and all three are cleared.
Between 0x6485 and 0x6564 there is a small, well-made library, and at 0x6564 the routine that builds its tables in RAM at boot:
That is enough for everything: the angle between two points, the distance, the decomposition of a velocity into its two components, and friction.
Twelve PSG tracks, with the pointer table at 0x6B55 and the interpreter at 0x6B83, which runs once per interrupt.
The rules, read off the code: a byte with bit 7 or bit 6 set is a note — the
bottom six bits index, doubled, the tone table at 0x6C0D; with bit 5 clear it is
a wait in frames; and the rest are commands: 0x2D stores the envelope
shape, 0x33 is a jump, 0x3D is the stop and 0x3E zeroes registers
0 to 5.
Where each track ends is not written down. Following them with that same
interpreter (tools/pistas.py) gives twelve runs that fit without a gap, and two
things turn up: five tracks share a tail — 5 runs into 6, 6 into 0, 0 into 1,
1 into 7, and all five end at the same stop at 0x6D7A — and track 11 is the
only one that loops, because it ends in a jump to itself. The highest note the
twelve use is 43, which is exactly where the tone table ends.
This reading reproduces the cartridge's interpreter, but it is not corroborated against the emulator. The boundaries are measured; that it sounds like what is described here is not claimed.
What was measured with openMSX, and what for.
For one thing, but the one that decides: checking that the images on this site are not an interpretation. They are all drawn by running in Python the same decompressors and the same interpreters the Z80 runs. If any of them were misunderstood, what came out would be noise — or, worse, something that looks right and is wrong. The only way to know is to take the real VRAM and compare.
tools/omsx_vram.tcl sets no breakpoints: the dumps go by emulated clock, so
they do not depend on which instruction the emulator happens to stop at.
openmsx -machine C-BIOS_MSX1_EU -cart holeinonepro.rom \
-script tools/omsx_vram.tcl
It takes five dumps of the 16 KB of VRAM and, with each, the VDP's eight registers and a screenshot. Then:
make vram
02 E2 06 FF 03 36 07 F1
which is exactly what the code says it builds:
| register | value | what |
|---|---|---|
| R2 | 06 | name table at 0x1800 |
| R3 | FF | colour table at 0x2000 |
| R4 | 03 | pattern table at 0x0000 |
| R5 | 36 | sprite attributes at 0x1B00 |
| R6 | 07 | sprite patterns at 0x3800 |
| area | different | of |
|---|---|---|
| patterns, third 0 | 0 | 2,048 |
| patterns, third 1 | 0 | 2,048 |
| patterns, third 2 | 0 | 2,048 |
| colour, third 0 | 0 | 2,048 |
| colour, third 1 | 0 | 2,048 |
| colour, third 2 | 0 | 2,048 |
| sprite patterns | 0 | 736 |
| name table at 0x3C00 (leaderboard) | 0 | 768 |
| name table at 0x1C00 (scorecard) | 0 | 768 |
| name table at 0x1800 (panel and hole 1) | 0 | 624 |
| total | 0 | 15,184 |
Zero differences. And the last row is the one that says the most: the whole playing screen — the panel, the twenty columns of QUEEN SIDE's hole 1 map and both edge columns — comes out the same as on the machine.
They are all in columns 3 to 8, which is where the game writes figures as it plays:
what this repo builds what is in the emulator
*TOP +! *TOP ;18+! -> TOP +18
*1UP +! *1UP <0+! -> 1UP ±0
* 1UP +! * 1UP 0+! -> SHOTS 1UP 0
*HOLE +! *HOLE 1+! -> HOLE 1
* ? +! * 352 ? +! -> 352 m
* PAR +# * PAR 4 +# -> PAR 4
That is: the factory TOP, both players' shot counts, the hole number, the distance, the par, the wind and the slope. None of them comes out of a table — the code writes them from the state of the round — which is why those six columns are left out of the comparison.
And they double as another check: the 352 metres and the par 4 the
emulator shows are the ones tools/campos.py gets out of the script for hole 1
of QUEEN SIDE, reading the par off the tee tile and the metres off the three
ASCII digits that close the script.
The dumps above do not reach it: the cartridge goes off into the eighteen-hole
attract mode and takes over a minute to get to the menu. tools/omsx_menu.tcl
presses the space bar at ten seconds to cut it short — 0x66A0 returns on the
trigger — and dumps afterwards.
| area | different | of |
|---|---|---|
| patterns, all three thirds | 0 | 6,144 |
| colour, all three thirds | 0 | 6,144 |
| name table at 0x1800 (title and menu) | 0 | 768 |
| total | 0 | 13,056 |
There is the wordmark, with its tiles from 0xAA0E on top of the playing ones. And the whole name table, the menu's four lines included.
It is said in Open questions.