Under the hood

Rebuilding the ROM

make verify assembles src/junofirst.asm with pasmo and out comes the 8 KB ROM byte for byte; repeated four times, it gives the 32 KB dump. make sanity checks what reassembling does not cover: that no byte declared as data is read as code, and that all 8,192 are explained. make test runs the tests. The ROM is not in the repository: it has to be put in the root as junofirst.rom (the GoodMSX dump, [!], sha1 846bd4d8...).

  bytes
traced code 5,627
named data 2,565
unexplained 0

The listing carries 1,219 comments on 2,915 instructions (41.8%), 359 routines and labels, none under 10% commented, and no called routine without a name.

Page 0, without the BIOS

The header gives INIT at 0x030D, and the BIOS calls it with CALSLT, which puts the cartridge in page 0. From there everything belongs to the cartridge: RAM cleared, interrupt mode 1 (which jumps to 0x0038), the stack at 0xE500, and its RSTs:

  What it does
RST 10h B bytes from HL to VRAM, at address DE
RST 18h the same, but queued for the interrupt
RST 20h DE + 32: the next row of the name table
RST 28h address DE to the VDP
RST 30h the current player's state into A and the alternate registers

Tables behind the call

tabla_de_bytes (0x15B0) and tabla_de_palabras (0x15B8) read entry A of a table stuck right after the instruction that calls them, and return after the 0xFF that ends it. There are five in the cartridge (the keyboard rows, the firing frequency, the astronaut's points, the enemies per wave and each type's pattern and colour): the trace declares them as data and follows the code after them.

The VDP queue and the interrupt

The game loop (0x06B5) does not write to VRAM: what has to be copied is queued with RST 18h in an eight-slot queue (0xE008), and the interrupt (0x0038) empties it every frame, along with the ship, its shots, the marked sprites and the field. The interrupt also counts TIME, reads both joysticks and the keyboard (two equal readings in a row, to skip bounces), runs the sound and keeps the speed.

The field, made of letters

It is all SCREEN 1. The field in perspective is a 24 x 21 letter buffer (0xE190): five lines leaving the horizon at an angle that depends on where the ship is, plotted dot by dot as letters 0x20-0x2F (one dot in one of eight positions), and a row that lights up and moves with the speed (pinta_campo, 0x07B8). The ship is eight letters, with four drawings already shifted two pixels apart; the ship's shots, three letters. The enemies, their shots and the explosions are sprites.

The RAM

   
0xE002 the wait of 0x14E1 (drops every 6 frames)
0xE005-0xE007 the two joysticks and the frame counter
0xE008-0xE02F the VDP queue
0xE030-0xE037 the ship: its address and its 8 letters
0xE050 the mode: game, field running, keyboard, player 2, two players
0xE051 the high score (BCD)
0xE055 the current joystick
0xE060-0xE06F player 1: state, enemies, lives, wave, WARP, TIME, points
0xE070-0xE07F player 2
0xE081 the speed (signed)
0xE083 the ship's X
0xE088 the twelve falling dots
0xE0C0 the twelve enemies on screen (10 bytes)
0xE138 the five enemy shots
0xE170 the ship's three shots
0xE17C-0xE187 the three sound channels
0xE190 the field: 24 x 21 letters

The tools

   
tools/z80trace.py, tools/mkasm.py the trace and the listing
tools/presupuesto.py, tools/densidad.py the explained bytes and the comments
tools/omsx_graba.tcl, tools/lanza_graba.ps1 record the cartridge in openMSX, frame by frame
tools/guiones/*.tcl what is pressed (and the pokes) in each recording
tools/vdp.py, tools/gifs.py the TMS9918 in Python and the GIFs
tools/pantallas.py, tools/graficos.py Sony, the menu, the sprites, the ship and the picture, running the cartridge with tools/z80run.py, and their check
tools/musica.py the tunes, running its engine

The checks

  Result
the Sony screen and the menu 0 pixels different out of 49,152
the sprite patterns 0 bytes out of 576
the four tunes whole, frame by frame, on both channels

Code shared with other Konami cartridges

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 62, 7 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)
Frogger 2 12 rellena_cero (0x0760) = BORRA_BC_BYTES
Konami's Baseball 1 6 rellena_cero (0x0760) = borra_bloque_de_ram
Konami's Golf 1 6 rellena_cero (0x0760) = borra_memoria

The whole matrix, the 63 cartridges against each other, is on The routines in the series database, along with the method and the program that measures it.