A commented disassembly of Casio World Open, the golf game Casio released for the MSX in 1985: a 32 KB cartridge filling pages 1 and 2 (0x4000-0xBFFF). It reassembles into 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
casioworldopen.rom, 32768 bytes, sha256
7b03fd41c11975131db7c2303aa0757b369c4f6e1e54586da8f2b70d68b8d19d
make comprueba checks it.
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
make densidad how much is commented, routine by routine
make web rebuilds this site, drawing the images from the ROM
The listing is not edited by hand: tools/mkasm.py builds it from a flow trace
and a file of notes anchored to addresses, so the comments survive a re-trace.
The entry points the tracer cannot work out on its own are declared in
src/casioworldopen.entries, each with its reason.
The images are not captures either: tools/graficos.py draws them by running in
Python the same decompression-and-indirection chain the Z80 runs.
Casio World Open is a 32 KB Casio cartridge from 1985, filling pages 1 and 2 (0x4000-0xBFFF).
The AB header at 0x4000 declares only INIT, at 0x4010. No STATEMENT, no
DEVICE, no TEXT.
The title runs in SCREEN 1, the 32-column text mode: the BIOS supplies the font and the colour for the whole screen fits in 32 bytes, one per eight patterns. The game runs in SCREEN 2, used as a bitmap: the name table is the identity map and the picture lives entirely in the pattern table.
Getting from one to the other has a trick. 0x44F3 enters SCREEN 1 only to keep the character set the BIOS has just loaded, copies it to RAM and, once in SCREEN 2, dumps it back as the course's patterns.
There are two handlers. The start-up one (0x415B) is temporary: it calls the real one and, the first time round, finishes the initialisation. The real one (0x44D3) runs the whole game, hooked into H.TIMI.
| bytes | ||
|---|---|---|
| traced code | 8,185 | 24.98 % |
| identified data | 24,583 | 75.02 % |
| unexplained | 0 | 0.00 % |
0xA8FB is simple: a two-byte header says how many source bytes are left to
consume, an 0xFF opens a run with its count and value, and any other byte is
copied as it is.
What is interesting is what 0xA8CB does after decompressing: it puts a
zero after every byte — turning the run into sixteen-bit values — and takes the
running total of them all. What comes out is not a picture: it is a list of tile
codes.
The hole plans and the eighty perspective-view maps store indices into
that list, one byte per cell. 0x5B61 resolves them: it enters the list with
add hl,bc twice — sixteen-bit indexing, because the pattern table has 570
entries — and hands the code to 0x5E66, which copies the 8×8 pattern to VRAM.
0x5E66 checks bit 7 of (0xE0A0) and, if it is set, flips the pattern bit by
bit with rlc and rra before copying it. And the loops that walk the maps do
the same: they advance the pointer and then run backwards. With that, half the
course is drawn without storing one more byte.
Three variables — (0xE001), (0xE06C) and (0xE077) — work as to-do lists: the interrupt handler rotates them and, for every bit set, calls the phase it belongs to. That is how a frame's work gets shared out without an explicit state machine.
Of the 32,768 bytes, 8,185 are code actually reached and 24,583 are data
declared one by one. The five bytes at 0x4B04 are a curious case: valid code —
ld a,080h / ld (0e077h),a — that no jump in the whole cartridge reaches.
The images are not captures, but the emulator does get used: to check them, and to ask the game what the listing takes longer to say.
tools/omsx_vram.tcl and tools/omsx_juega.tcl save the VRAM, the VDP
registers and a screenshot, by emulated clock and without breakpoints.
python3 tools/graficos.py casioworldopen.rom 0x4000 comprueba work/omsx
From the title screen come the wordmark's 304 bytes identical, its 32 of colour identical, and 766 of the 768 name-table cells.
When the hole plan would not turn up anywhere in the listing,
tools/omsx_quien_dibuja.tcl settled it: a breakpoint on the pattern drawer,
logging the return address and the parameters of every call.
All 3,522 calls came from one place, and going up a level gave two callers with their destinations: one painting from cell 22 to cell 607, which is exactly rows 0 to 18, columns 22 to 31. The plan. From there back to the listing, and from the listing to 0x5DEC.
The RAM buffers are reused three times a frame: 0xE800 is the accumulated code list, but during the scroll that same area doubles as a cache of patterns fetched from VRAM, and 0xEA00 is both the view map and yet another pattern buffer. Dumping RAM "at some point" tells you nothing.
tools/omsx_vista.tcl stops the machine at the exact instant a row of the view
is being painted and dumps both buffers. There it holds:
| assembled in Python | against real RAM |
|---|---|
| view map, 399 bytes (105+294) | 0 differing |
| shared background list, 129 codes | 0 differing |
| the hole's own list, 59 codes | 0 differing |
The same script logs what tile_por_indice resolves, cell by cell: across the
399 cells of hole 1's view, the index read and the tile code it yields match
the computed ones in all 399.
tools/omsx_vram_hoyo.tcl forces whichever hole you ask for by writing it into
(0xE0B4) from a single breakpoint, so the mirrored ones can be checked without
playing twelve holes. Across six holes — three mirrored, three not — the plan's
190 cells come out identical, pattern and colour:
hole 1 mirrored=False 190 cells, 0 differing
hole 2 mirrored=True 190 cells, 0 differing
hole 3 mirrored=False 190 cells, 0 differing
hole 5 mirrored=True 190 cells, 0 differing
hole 12 mirrored=True 190 cells, 0 differing
hole 17 mirrored=True 190 cells, 0 differing
tools/omsx_quien_sprites.tcl logs the LDIRVMs landing in the sprite pattern
table. Two show up: 320 bytes to 0x3800 and 1120 to 0x3B00, which is pattern
96 — exactly where the golfer starts. That second block matches 0xB4AE
decompressed byte for byte.
And the attribute table confirms how the positions are read: across the eight pieces of the rest pose, (0xE099) minus the table's first byte gives 144 in all eight, and (0xE098) minus the second gives 80 in all eight.
Of the 768 cells of a real in-game frame, 718 are patterns from
tabla_patrones_terreno. It is not that the pictures look alike: they come
out of the same table, byte for byte.
On the title screen the wordmark comes from the cartridge — 304 bytes at 0x4301 — but the text is written by the machine with its own BIOS font, which INIT32 loads into the pattern table. That font is not in the game's ROM, so drawing from the cartridge alone gives the wordmark and the background with the lines blank. That is why the site shows the wordmark and not the whole screen.