Under the hood

Rebuilding the ROM

make verify assembles src/stone.asm with pasmo and out comes the 32 KB ROM byte for byte. make sanity checks what reassembly does not cover: that no byte declared as data is read as code, that no entry point falls in data and that all 32,768 bytes are explained. make test runs the tests. The ROM is not in the repository: put it in the root as stone.rom (the GoodMSX dump, [!], sha1 3950f222...).

  bytes
traced code 12,649
named data 20,119
unexplained 0

The listing has 2,382 comments in 5,724 instructions (41.6%), 672 routines and labels, none under 10% commented, and no called routine without a name.

The cartridge

32 KB at 0x4000-0xBFFF, with the header at 0x4000. INIT (0x4010) also puts the cartridge in page 2 and jumps to 0x8010. The data comes first: the 58 rooms (the pointers at 0x4042 and their descriptions, 0x40B6-0x4D46), 2,745 bytes of EPROM programmer filler (0x4D47), the sprite drawings (0x5800), the title and game tiles with their colours (0x6000-0x7EFF, with a tile set that is not used) and the demo's controls (0x7F00). The code goes from 0x8000 to 0xB67F, with the texts in between (0x9145-0x9351, 0x93C4, 0x946E) and the room pieces (0x9F21-0xA22B); after it, the sound (0xB700-0xBFFF).

The BIOS it uses

RSLREG and ENASLT for the slot; SETGRP, CHGCLR, WRTVDP, DISSCR and ENASCR; FILVRM, LDIRVM and WRTVRM; GTSTCK and GTTRIG for the controls and SNSMAT for the space bar, GRAPH, STOP, F1, SELECT and ESC; WRTPSG for the sound. It reads from the BIOS its font (the letters from 0x1D3F and the kana from 0x1FEF, 0x22BF and 0x22AF), the bytes at 0x1500 for the title and the keyboard buffer (GETPNT, 0xF3F8) for the password.

The interrupt and the loop

INIT puts a jump to 0x8EBB in the H.TIMI hook. The interrupt does the requested silence, runs the sound, counts frames (sixteen counters, 0xE010-0xE01F) and reads F1, STOP, the buttons, the space bar, GRAPH and the joystick; in the demo, a byte of its list every 16 frames (interrupcion, 0x8EBB). The game runs in the loop (bucle, 0x8440): once per frame, the sprites, the background sound and, if there is no pause, the blink of being hit, the hero, the weapon, the change of room, the points, the enemies, the objects, the scoreboard blink, the shop and the room's rule (bucle_juego, 0x8480).

The rooms. Each room is built in RAM (0xE700, 24 x 24 tiles) from its description: the type (no frame, frame, frame with two of the eight openings, shop or the eagle room), fills of four alternating tiles, rectangles, drawings, and the lists of enemies (to 0xE380) and objects (to 0xE400). To pass, the hero and the enemies look at two tiles on the side they are going to: below 0x60 they pass (casillas_pasan, 0x98D7). On changing room, the old one and the new one are put together at 0xE940 (in rows of 48 or one on top of the other) and a 24 x 24 window slides across them.

How it was done

The trace follows the code from INIT, the interrupt and the three jump tables (the objects, 0xA329; the enemies, 0xA3F1; the room rules, 0xB49D), declared in src/stone.entries. The rest was measured in openMSX (tools/omsx_cobertura.tcl) on a Philips VG 8020, waiting for the demo and playing: nothing that ran was left out of the trace. Part of the comments of the sound engine and the shared routines come from other Casio games already done (comun/casio/porta.py, only on identical stretches), checked one by one.

The recordings for the site (tools/guiones/*.tcl, recorded with tools/lanza_graba.ps1 on C-BIOS) log, on every frame, the VDP registers, the RAM from 0xE000, the PSG and the VRAM that changed. tools/pantallas.py runs the title with tools/bios.py and checks it against the recording (0 different points), tools/salas.py builds the 58 rooms by running sala_monta, tools/gifs.py makes the GIFs and tools/musica.py runs the sound engine.

The RAM

   
0xE000 playing
0xE001-0xE006 the score digits
0xE009 the rounds (the sage: 1, the first ending; 2, the true one)
0xE00A the scene (0-4)
0xE00C-0xE00E the score (BCD)
0xE010-0xE01F the frame counters
0xE020-0xE02D the buttons: just pressed and held
0xE023 / 0xE039 SELECT / ESC in the intro
0xE027 / 0xE037 the demo / its list of controls
0xE02E-0xE033 / 0xE034-0xE036 the high score: digits / BCD
0xE03E the room
0xE040 / 0xE042 / 0xE044 INTEL / POWER / LIFE
0xE049 the scene over (the sage)
0xE050 / 0xE051 the stones: BCD / binary
0xE052 the next scoreboard slot for what is bought
0xE053 the password (0-4)
0xE058-0xE05B the four scenes cleared
0xE180 the joystick
0xE183 out of life
0xE186 the scene's stone taken
0xE198 the side the room is left by
0xE1B3 / 0xE1B5 / 0xE1B7 F1 / STOP / the pause
0xE1BA / 0xE1BB the room's two doors (the rule)
0xE1BC / 0xE1C1 / 0xE1C2 / 0xE1C3 in the room: enemies / chests / open chests / stones
0xE1BF the room: 1, shop; 2, the eagle one
0xE280-0xE2D5 the sound: the three channels and the requests
0xE300 the sprites: 16 of 16 bytes
0xE320 / 0xE340 the hero (two sprites) / the weapon
0xE354-0xE35D what was bought: how many of each hieroglyph
0xE380 the eight enemies (16 bytes each)
0xE400 the sixteen objects of the room
0xE700 the room (24 x 24)
0xE940 the two rooms together, when changing
0xEE00 / 0xEF00 the beaten enemies / the objects taken