Midway-Clowns-Full-Disassembly-and-C-Port

Clowns (Midway, 1978) - annotated disassembly

Byte-exact, fully labelled listing of the Clowns program ROM (MAME clowns, rev. 2: six 1K ROMs, $0000-$17FF), generated from the ROM image and checked against it by a read-back verifier. The layout follows the Tempest disassembly: one program listing, one defines file, generator scripts, a verifier.

sprites_preview.html draws every bitmap in the ROM (font, seesaw, clowns, balloons). The C port built from this listing, and the test that runs it against the real ROM, are in ../c_src/.

Regenerate and verify

cd disasm
python gen_from_roms.py                    # ROMs from ../roms
python gen_from_roms.py C:\path\to\clowns.zip

gen_from_roms.py finds the six ROMs by size and CRC32 (zip or loose files, any names), writes build/clowns_cpu.bin, then runs:

  1. emit.py -> clowns_program_rom.asm
  2. emit_defines.py -> clowns_defines.asm
  3. verify.py - must print MISMATCHES : 0
  4. emit_sprites.py -> sprites_preview.html

Any failing step prints !! and the exit status is 1. Python 3 only, no packages.

Current result: verify 6144/6144 bytes, 0 mismatches; 2238 instructions, 2311 data bytes, 207 named labels, 137 routine headers.

Files

File What
clowns_program_rom.asm program ROM $0000-$17FF - generated
clowns_defines.asm memory map, I/O ports, RAM variables, constants - generated
sprites_preview.html rendered bitmaps - generated
gen_from_roms.py driver (above)
i8080.py Intel 8080 opcode table, decoder and encoder
trace.py recursive-descent tracer: separates code from data
notes.py data layout, RAM / port / constant tables, loader for notes/*.txt
notes/*.txt labels, routine headers and comments, by address
emit.py, emit_defines.py, emit_sprites.py generators
verify.py independent read-back of the two .asm files: re-encodes every line and compares with the image

The .asm files are generated: change notes.py / notes/*.txt and regenerate.

Inputs, not distributed here: the ROM set (../roms/clowns.zip). No source code for Clowns is known. Hardware facts (memory map, ports, switch bits, video layout, interrupts) follow the MAME driver mw8080bw.cpp / mw8080bw_a.cpp.

The reading of the code in the listing is not only the author’s: the C port in ../c_src is a statement-by-statement translation of it, and that port matches the real ROM byte for byte over 1.2 million compared events (96 % of the instructions).

Conventions (program listing)

Conventions (defines)

Sections: Memory map, Input ports, Output ports (the 8080’s separate port space), four Work RAM groups, Constants. Format .alias NAME $VALUE ;comment. Every identifier the program listing uses is defined here.

How the program works (short)