Under the hood

Getting started

A commented disassembly of Konami's Golf, Konami's RC-723 for the MSX, a 16 KB cartridge mapped into page 1 (0x4000–0x7FFF). It reassembles into the exact ROM, byte for byte, and every one of its 16,384 bytes is accounted for.

The cartridge is not here

No repository distributes the game. Put your own dump in the root as golf.rom, 16384 bytes, sha256

6c539f0a4b46b3f723ded723a3bac036550e58385a6a9be73afb8ceb8c7ecae3

make comprueba checks it.

What each command does

make            traces the flow, builds the listing, reassembles it and runs the tests
make verify     the test that decides: reassembling must give the ROM back
make sanity     that not one byte is left unexplained, and no data comes out as code
make densidad   how much is commented, routine by routine
make web        rebuilds this site from the ROM and the notes

How it is put together

The listing is not hand-edited: tools/mkasm.py builds it from a flow trace and a file of address-anchored notes, so the comments survive a re-trace. The tracer follows the flow from the entry points; the ones it cannot deduce on its own —the interrupt hook, the jump tables, and the routines reached through push/ret— are declared in src/golf.entries, each with its reason.

The images on this site are not captures either: they are drawn by running in Python the same decompressors the Z80 runs, over the cartridge's own bytes. If a range or a format were wrong, noise would come out instead of the courses.

The cartridge

Konami's Golf is Konami's RC-723, from 1985: 16 KB in page 1, with no bank switching.

INIT is not where it usually is

The AB header declares only INIT, and puts it at 0x4053. In the house's other cartridges of this era INIT sits at 0x4010 — here 0x4010 is something else: the interrupt handler, which INIT hooks into H.KEYI before clearing the RAM and placing the stack. From then on the main program does nothing and the whole game runs inside the per-frame interrupt.

It does not carry Konami's hidden mark

At the end of many of its cartridges Konami hid its catalogue number and the title in katakana; Manuel Pazos (@ManuelPazosMSX) found it, and the block lives at offset 0x3FF0.

This one does not have it, checked by scanning all 16,384 positions of the ROM rather than just the tail, with a finder first validated against four other cartridges of the same family that do carry it. The dump shows why: the ROM runs full of code right up to 0x7FFD, with two bytes of filler left over.

The screen, back to front

SCREEN 2, but with the tables laid out the opposite way round from usual: colours at 0x0000, patterns at 0x2000, names at 0x3800, and sprites at 0x1800 and 0x3B00. The eight VDP registers come from a table in the ROM itself, at 0x447A.

How the 16 KB break down

  bytes  
traced code 8,665 52.89 %
identified data 7,719 47.11 %
unexplained 0 0.00 %

The code

One dead loop, and the whole machine in the interrupt

INIT (0x4053) puts a 0xC3 into H.KEYI with the address 0x4010 behind it, clears the 0x7FE bytes from 0xE000 to 0xE7FF with an ldir and drops the stack just below. From there the main program does nothing: the entire game runs inside the per-frame interrupt.

A routine that reads its own parameter

0x4379 starts with ex (sp),hl: it takes the return address — which points at the byte after the CALL — reads a sixteen-bit word from there, and hands back the address already advanced so the return lands past the parameter. In other words the parameter sits right after the CALL, inside the code stream.

There are thirteen such calls, and all thirteen words point inside the ROM. This is the detail that loses a naive disassembler: the first parameter is 0x44E9, and its low byte, an 0xE9, reads as a jp (hl) that does not exist.

The script interpreter

Almost everything drawn is compressed and dumped by one interpreter (0x4380 / 0x4389). The format, measured:

And there is a second door, at 0x601E, that reads the same format but against RAM. That is what lets 0x5FE2 paint a course tile and then the same tile mirrored left to right (0x5FFD), without spending one more byte of ROM. It is not a transpose, although it looks like one: the inc hl at 0x600E sits outside the bit loop, so the eight rounds of rl (hl) keep rotating the same byte and what comes out is that row with its bits reversed. The finish is that 0x6013 and 0x601B put an 0x88 in front and a 0x00 behind, so the mirrored row comes out already turned into a VRAM script the same routine can paint.

The holes

Two tables of nine pointers, at 0x79BC and 0x79CE. The first leads to the hole's header and the second to its grid, but you do not need both: the header ends in a 0x80 whose destination is the start of the grid.

Each grid cell is a code drawn as a block four tiles wide by two or four tall, onto a 20 by 16 canvas in RAM, in five depth bands. Codes 0x01 to 0x28 go through one set of tables and 0x29 to 0x34 through another; 0xEA is the tee, 0xC4 the edge, and 0x29 and 0x2A are the green. The terrain type is classified by 0x5BF0 against a set of thresholds, and that is what decides whether your shot comes out short.

And so the hole can be looked at from four angles, three tables of 48 codes (0x5471, 0x54A1 and 0x54D1) rotate the cell codes, with the game keeping four grids: one unrotated, two rotated and one reversed.

In the emulator

The drawings on this site come from the ROM, not from the emulator. But looking at a picture is not enough to believe it: in this series the VRAM is dumped from openMSX and compared byte for byte against what the Python builds. If they match, the format has been read correctly.

For this cartridge 30 screens were dumped — the title, the menu and the nine holes — and the comparison covers 385,199 bytes: patterns and colours of both screens, the sprite patterns, the hole's plan view, its whole header and the eight VDP registers. It comes out at zero differences. The command that does it is

python tools/graficos.py --comprueba golf.rom 0x4000 work/omsx

and the only cell it had to be handed is the wind, which is not in the ROM: ld a,r draws it, so each dump's own values are fed in.

Loading it

openmsx -machine Philips_VG_8020 -cart golf.rom

The measuring scripts

tools/ holds openMSX TCL scripts meant for checking, not for illustrating: they dump the 16 KB of VRAM and the VDP registers and exit on their own, with a real-time watchdog so a broken script cannot leave the emulator hanging.

Two things learned the hard way, in case you write your own: in TCL do not nest quotes inside a string (use {VDP regs}), and do not set breakpoints that fire every frame inside drawing routines — they choke the emulator, which then never even gets a game started.

Code shared with other Konami cartridges

This disassembly has been compared, instruction by instruction, with every other Konami one in the series. A block counts when the same instructions, at least six of them from a label to its ret or its unconditional jump, are in both cartridges; the addresses are left aside, because they change from one cartridge to the next. Of the other 57, 32 have at least one block in common with this one; these are the ones that share the most:

Cartridge Blocks Instructions For example (here = there)
Konami's Baseball 34 552 corre_el_canal_nota_larga (0x7449) = lee_una_nota_larga
Konami's Tennis 25 405 corre_el_canal_nota_larga (0x7449) = manda_de_la_melodia
Hyper Olympic 1 20 279 titulo_espera (0x4110) = SUBE_EL_ROTULO
Hyper Olympic 2 19 227 replica_los_tercios (0x4322) = COPIA_VRAM_A_VRAM
Hyper Sports 1 5 58 arranca_el_sonido_repite (0x7318) = SUMA_BONUS_7BFC
Magical Tree 5 65 corre_el_canal_nota (0x73E9) = lee_la_nota_de_la_partitura
Konami's Ping Pong 5 49 toca_el_mezclador (0x7333) = pon_el_mezclador

The whole matrix, the 58 cartridges against each other, is on The routines in the series database, along with the method and the program that measures it.