The cartridge

The header and the machine

The first sixteen bytes are the header the BIOS reads:

4000  41 42        "AB", a cartridge's signature
4002  4A 40        INIT = 0x404A
4004  00 00 00 00 00 00   STATEMENT, DEVICE and TEXT set to zero
400A  00 x6        padding

With the header at 0x4000 the BIOS maps the cartridge into page 1 (0x4000-0x7FFF) and jumps to INIT once it has finished booting. From there the program never comes back: INIT writes jp 0x4010 into the H.KEYI hook (0xFD9A) and drops into a two-byte jr $ at 0x4074. The whole game runs inside the interrupt, one step per frame.

RAM is used from 0xE000 up, with the stack at 0xF000, so a 16 KB MSX is enough.

Video memory

SCREEN 2, with the eight registers at 0x43FD:

registervaluewhat it says
R00x02graphics mode 2
R10xE216 K, screen and interrupt on, 16 × 16 sprites
R20x0Ename table at 0x3800
R30x7Fcolour table at 0x0000
R40x07pattern table at 0x2000
R50x76sprite attributes at 0x3B00
R60x03sprite patterns at 0x1800
R70xE4ink 14 on background 4

In SCREEN 2 the screen is split into three thirds of eight rows, and each third has its own 256 patterns. Pippols loads all three the same, so a character number means the same thing whatever row it is on; without that, the background would break as it crossed row 8 or row 16.

The 256 characters are shared out like this:

characterswhat they are
0x00-0x0Fplain background and fixed decorations (0x00 and 0x0C are the empty pair)
0x09-0x0Athe ground, which changes on every screen
0x10-0x39the font: ten digits and twenty-six letters
0x40-0xFFthe 192 of the scrolling background

Those 192 are the point of the whole cartridge: eight copies of the same set of 24 characters, each one a pixel lower. They are explained in The pixel scroll.

What goes to VRAM is compressed with a three-order RLE (0x43AE): a command byte, and if it is 0 it ends, if bit 7 is clear it repeats the next byte that many times, and if it is set it copies that many bytes as they are. 0x80 starts another block with a new address. The font, for example, takes 264 bytes in the cartridge and 336 in VRAM; the KONAMI logo patterns, 151 and 216.

The sprites

The 52 common patterns are decompressed in one go into 0x1880 (0x5E67), and the player's are loaded separately: there are 26 blocks in the table at 0x643A, and each frame whichever one matches the current sprite set —walking, sitting on the throne, dying— is sent up to 0x1800. That is how the little fellow is animated without burning spare patterns.

The attribute table holds 32 sprites: the boss, four for the player, ten creatures, seven objects, two of your shots and three of theirs. The order they are written in alternates from one frame to the next (0x7F83), creatures first on one frame and objects first on the next, so that the MSX's limit of four sprites per line does not always hide the same ones.

The cartridge's sprites

The RAM map

addresswhat it holds
0xE000/0xE001the program's state and substate
0xE005the interrupt's lock
0xE010-0xE039the three sound channels, 14 bytes each
0xE043-0xE048high score and score, three BCD bytes each
0xE050lives
0xE060-0xE0EFthe name table buffer: 24 rows of 6 bytes
0xE100/0xE101the position within the stage, in pixels
0xE103the background stage (0-7)
0xE11Cthe offset of 0 to 7 pixels within the character
0xE120-0xE126the player: state, direction, animation, Y, X and sprite set
0xE132which world screen you are on (0-17)
0xE1B0-0xE1C7three enemy shots of 8 bytes
0xE1E0-0xE1EFthe player's two shots
0xE200-0xE29Fthe ten creatures, 16 bytes each
0xE400-0xE42Fthe seven objects, 6 bytes each
0xE500-0xE91Fthe 44 map pieces, 24 rows each
0xEA00-0xEABFthe four background strips and their four colour strips

A creature's slot is 16 bytes: type, substate, animation, counter, Y, X, pattern, colour, the Y and X fractions, the Y and X velocities in 8.8 fixed point, and the target. A negative type means it is dying.

What it is made of

bytes
code909955.5 %
data728544.5 %
unidentified0

The data, from the inside: 1201 bytes are the music and effect tracks, 1485 the compressed common sprite patterns and 883 the player's 26 blocks, 647 the whole map (the dictionary, the sequence, the stretches and the plans), 409 the background strips with their colour, 408 the KONAMI logo and the title, 358 the object lists of the six roads and 264 the font. The rest are tables of a few dozen bytes each: which creatures each stage gets, the sideways movement curves, the jump steps and the corners each creature comes in through.

At the end of the cartridge there are 45 padding bytes of 0xFF and, behind them, nine bytes nobody reads: Konami's hidden mark, the title ピポルス backwards and the 29 of RC-729. It is in Findings.