Under the hood

Rebuilding the ROM

make verify assembles src/exoidezarea5.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 exoidezarea5.rom (the GoodMSX dump, [!], sha1 22c7abe6...).

  bytes
traced code 10,969
named data 21,799
unexplained 0

The listing has 1,955 comments in 4,862 instructions (40.2%), 608 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 0x8000. The data comes before the code: the map (0x4038), the signs (0x4740), the sprite drawings (0x4800) and the drawings and colours of the tiles of the title and of the map pieces (0x5000-0x7FFF). The game code goes from 0x8000 to 0xAB7F, with data inside: the title and scoreboard texts (0x8AF8), the logo (0x8D7D), the star background (0x9505) and the tables of the ground targets and of the enemies (0x99ED, 0x9AC7). At the end, the letters (0xAB80) and the sound, its tables, its code and its pieces (0xAD00-0xBFFF).

The BIOS it uses

SETGRP for SCREEN 2, CHGCLR, WRTVDP, DISSCR and ENASCR; FILVRM, LDIRVM and WRTVRM for the VRAM; GTSTCK and GTTRIG for the controls and SNSMAT for the space bar, GRAPH, TAB and CAPS; WRTPSG for the sound; RSLREG and ENASLT for the slot. The letters are not the BIOS ones: they are in the cartridge.

The interrupt and the loop

INIT puts a jump to 0x88C2 in the H.TIMI hook. The interrupt runs the sound, counts frames (eight counters, 0xE010-0xE017) and reads the buttons; in the demo, it is the one that moves the ship. The game runs in the stage loop (bucle, 0x81C0): once per frame, the ship, its shots, the enemies, the ground targets, the map scrolling, the enemies that come out, the tiles that change, T.POWER and the flashing; with the ship hit or the stage over, it leaves the loop.

Two name tables. The map goes down point by point: the game has two name tables (0x1800 and 0x1C00) and, as the map goes down, shows one or the other (avance, 0x92D6). That is why the scoreboard is written twice.

The sprites flicker instead of vanishing. Every frame it copies the sprites to the table starting from a different one (sprites_rota, 0x8BD6): with more than four on a line, the one that is not seen changes.

How it was done

The trace follows the code from INIT, the interrupt and three jump tables (the ground targets, the enemies and the steps of the bullets), declared in src/exoidezarea5.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.

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/gifs.py makes the GIFs and tools/musica.py runs the sound engine.

The RAM

   
0xE000 playing
0xE001-0xE006 the points, one digit per byte
0xE00A / 0xE00B the stage (P= minus one) / the ships in reserve
0xE00C-0xE00E the points, in BCD
0xE010-0xE017 the frame counters
0xE020 / 0xE022 T.POWER / shoot, just pressed
0xE023 / 0xE039 TAB / CAPS on the title
0xE027 / 0xE037 the demo / its list of controls
0xE02E-0xE033 / 0xE034-0xE036 the high score: digits / BCD
0xE03A the 30,000 flag, which nobody reads
0xE051 the map position (0-0x50)
0xE100 the sprite attributes
0xE183 / 0xE186 the ship hit / the stage over
0xE1D3 the power (T.POWER)
0xE1E0 the fortresses stopped
0xE1E9 the sign
0xE280-0xE2D5 the sound: the three channels and the requests
0xE300-0xE35F the ship and its four shots (16 bytes each)
0xE360 the 16 enemies (16 bytes each)
0xE500 the 8 ground targets (16 bytes each)
0xE600 the title screen (72 rows)
0xEC00 the map screen (4 x 0xC0 tiles)