make verify assembles src/pooyan.asm with pasmo and the 16 KB ROM comes out
byte for byte. make sanity checks what reassembling does not cover: that
no byte declared as data is read as code, and that all 16,384 are explained.
make test runs the tests. The ROM is not in the repository: put it in the root
as pooyan.rom (the GoodMSX dump, [!], sha1 692a5539...).
| bytes | |
|---|---|
| traced code | 6,240 |
| named data | 10,144 |
| unexplained | 0 |
The listing has 1,387 comments on 3,252 instructions (42.7%), 342 routines and labels, none below 10% commented, and no routine called without a name.
Konami's Pooyan did not come out on a cartridge but on a Hudson Soft Bee Card: a card, cheaper to make and of small capacity, that went into the MSX through an adapter (Hudson used similar cards on the PC Engine). For the MSX it is the same as a cartridge: a ROM in the slot. This one is 16 KB, at 0x4000-0x7FFF; the header only has "AB" and INIT (0x4004), and the program starts at the next byte.
The program relies on the BIOS: SETWRT (0x0053) to set the VRAM address, WRTVDP
(0x0047), WRTPSG (0x0093), GICINI (0x0090), GTSTCK (0x00D5) and GTTRIG (0x00D8)
for the keyboard and the joysticks, and KEYINT (0x013E). Bytes go to the VDP
through port 0x98, each with a short wait (vram, 0x5A81).
The screen is SCREEN 2 with 128 characters of its own in each third (0x6CEB), the eight sets of the basket (0x80-0xCF), 48 characters for each map (0xD0-0xFF), and the colours in RLE (0x791B: how many times and the byte). The wolves, the balloons, the arrows, the stones, the boulder, the meat and the signs are 16 x 16 sprites; the pig in her basket, the ladder wolves, the ones at the top and the pulley are characters.
init puts a jp 0x5753 on the H.KEYI hook (0xFD9A), which the BIOS calls on
every interrupt. That interrupt only calls KEYINT and moves the sound: the three
music channels and the two effect channels. Everything else is done by each
round's loop, which does not wait for the frame (see
Curiosities).
Each thing goes at its own speed with fourteen "count and limit" pairs at
0xE503 (divisores, 0x55DE): ten of them add one on every turn of the loop, and
when their count is zero, "it's time". Three limits come from the round table:
the basket's, the wolves' and the script's, and the arrows the magenta wolf
takes.
| starting limit | what it moves | |
|---|---|---|
0xE503 |
6 (5, 4 or 3 in the rounds) | the basket |
0xE505 |
100 | the wolves' drawing |
0xE507 |
10 (10 down to 4 in the rounds) | the wolves and the script |
0xE509 |
2 | the meat, the loose balloons and the boulder |
0xE50B |
40 | the popping balloons |
0xE50D |
2 | the stone |
0xE50F, 0xE511 |
12, 2 | the falling pig, down and sideways |
0xE513 |
2 | the arrows that pop a balloon (one in two) |
0xE515 |
6 (6 or 7 in the rounds) | the ones for the magenta wolf's balloon |
0xE517 |
254 | a loose balloon comes out |
0xE519, 0xE51B |
13, 17 | chance: the two counts added |
0xE51D |
10 | the pulley |
0xE000 |
the round (from 0) |
0xE003 |
the lives |
0xE006 |
the wolves left |
0xE009 |
the pig is falling |
0xE00C, 0xE00F |
the script step and its wait |
0xE001... |
the other player's copies (0x4377 swaps them) |
0xE010 |
the meat's streak |
0xE011 |
bonus round |
0xE012, 0xE013 |
the music's divider and switch |
0xE018-0xE01B |
the basket: X, Y, its state and the rope |
0xE01C-0xE022 |
the meat: X, Y, its step, where it left from and its direction |
0xE024-0xE027 |
the arrow: flying, X, Y, and whether it is falling |
0xE028, 0xE029 |
the boulder and the wolves that have reached the top |
0xE02C, 0xE032 |
the points (hundreds and the half hundred) |
0xE035 |
the extra life already given |
0xE038, 0xE03A, 0xE03B |
two players, who is playing and what the game was started with |
0xE03D-0xE04B |
what was read from the keyboard and the joysticks |
0xE04D |
the six balloon wolves (6 bytes) |
0xE072 |
their balloons when they get away (4 bytes) |
0xE08B |
the four ladder wolves (2 bytes) |
0xE093 |
the stone (4 bytes) |
0xE0A3 |
the six loose balloons (6 bytes) |
0xE0C7 |
the five points signs (4 bytes) |
0xE500, 0xE502 |
the high score |
0xE503-0xE51E |
the dividers |
0xE51F-0xE53E |
the three music channels and the two effect channels |
tools/z80trace.py, tools/mkasm.py |
the trace and the listing |
tools/presupuesto.py, tools/densidad.py |
the bytes explained and the comments |
tools/omsx_graba.tcl, tools/lanza_graba.ps1 |
record the ROM in openMSX, frame by frame |
tools/guiones/*.tcl |
what is pressed (and what is poked into RAM) in each recording |
tools/sonda_vueltas.tcl, tools/lanza_vueltas.ps1 |
how many times the loop goes round each frame |
tools/vdp.py, tools/gifs.py |
the TMS9918 in Python and the GIFs |
tools/pantallas.py |
the title, the logo and the two screens, running the ROM with tools/z80run.py, and their check |
tools/musica.py, tools/motor_musica.py |
the tunes, running its engine, and their check |
| Result | |
|---|---|
| the title | 0 dots different out of 49,152 |
| the two round screens | characters, colours and sprites equal byte for byte; only the cells the loop paints on top change (counters, pulley and basket) |
| the seven tunes | whole, frame by frame: 0 different |
| the script starting over | from step 34 to 1 (frames 2020 and 2022) |
| the loop's turns | 3,191 in 900 frames: 3, 4 or 5 per frame |
| volume 16 in the music | 0 times in all seven |
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 64, 6 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) |
|---|---|---|---|
| Magical Tree | 1 | 6 | pinta_puntos_aire_sigue (0x494D) |
| The Pro Yakyuu Gekitotsu Pennant Race | 1 | 6 | sale_globo_busca (0x48D1) |
| Gekitotsu Pennant Race 2 | 1 | 7 | borra_letreros (0x56F4) |
The whole matrix, the 65 cartridges against each other, is on The routines in the series database, along with the method and the program that measures it.