Search › A-Z › K › Kung-Fu Master
Kung-Fu Master
Kung-Fu Master (Irem / Data East, 1984) is the side-scrolling beat-'em-up in which Thomas fights his way up the five floors of the Devil's Temple, punching and kicking through waves of grippers, knife throwers and other henchmen to rescue Sylvia and reach Mr. X. This build is a from-scratch emulation of Irem's M62 arcade board in the browser: a single Zilog Z80 main CPU that runs the whole game, driving a per-row-scrolling 8×8 background tilemap, the multi-height 16×16 sprite hardware, a two-level tile/sprite priority and a six-PROM colour system. It boots straight into attract mode and is wired to the emulators.org in-frame debugger, so you can single-step the Z80, read and write its registers and the 64K memory, and set execution breakpoints and write watchpoints.
Board ported from MAME's irem/m62.cpp ↗
Runs on: Web browser
Kung-Fu Master Online Emulator
Play Kung-Fu Master using JavaScript directly in your browser.
Controls
Configurations
| Configuration | Emulator | Machine | OS | Legal | |
|---|---|---|---|---|---|
| Kung-Fu Master | Kung-Fu Master | Kung-Fu Master | grey | Open ⛶ |
Machine emulated
The Kung-Fu Master arcade board (Irem, 1984) is the first M62 design: a single Zilog Z80 main CPU at 3.072 MHz (18.432 MHz / 6) that runs the whole game. The video hardware is a 64×32 background of 8×8 three-bit tiles with per-row horizontal scroll (the top six rows held fixed for the score line), up to 32 three-bit 16×16 sprites whose height is one, two or four tiles as set by a small height PROM, and a two-level priority that lets some background tiles draw in front of the sprites. Colour comes from six 256×4 PROMs — three for the characters and three for the sprites, one per colour gun — decoded through a resistor-network DAC. The board scans a 256×256 raster on a horizontal monitor. The separate Irem M6803 sound board is not emulated here.
Chips
Notes
Embedding
Kung-Fu Master is Irem's 1984 arcade machine and the first game on the M62 board: a single Zilog Z80 main CPU at 3.072 MHz (18.432 MHz / 6) that runs the whole game. This build is a from-scratch JavaScript emulation whose board is a port of MAME's irem/m62.cpp and irem/m62_v.cpp. The Z80 core is Molly Howell's MIT Z80.js, reused unchanged. The whole board runs from a host-owned loop, so the debugger can pause and single-step it.
Boot. Constructing the machine fetches the ROMs, decodes the character and sprite graphics and the six colour PROMs, resets the Z80 and starts the loop; the board comes up in attract mode:
var m = new KungFuMaster({ canvas, romBase, manifest });
m.boot(); // fetch ROMs, decode GFX + PROMs, reset the Z80, run
// each animation frame runs one 60Hz field of the Z80, then draws the screen
The machine object. Everything the host and debugger need is a field or method on the machine:
| Member | Kind | What it does |
|---|---|---|
m.cpu | field | The Z80 core that runs the game. Registers are read with getReg(name) / written with setReg(name,v) for A F B C D E H L, the AF/BC/DE/HL pairs, IX IY SP PC, and I R. |
m.dbgRead(a) / m.dbgWrite(a,v) | method | Side-effect-free read of the 64K bus and the CPU write path -- what the debugger's memory views read and poke. |
m.setInput(id, down) | method | Drive a control (up, down, left, right, punch, kick, coin, start1, start2) into the input ports. |
EMU_BOOT.transport | field | The pause / resume / step / breakpoint / watchpoint surface the shared debugger drives. |
Video. The screen is a 64×32-tile background of 8×8 three-bit characters with per-row horizontal scroll (the top six rows stay fixed for the score line), and up to 32 three-bit 16×16 sprites whose height is one, two or four tiles as set by a small height PROM. A two-level priority (from the tile colour code, plus the fixed top rows) lets some background tiles draw in front of the sprites, so Thomas walks behind the temple pillars. Colour is fixed in six 256×4 PROMs -- three for the characters and three for the sprites, one per gun -- decoded through a resistor-network DAC into a 256-entry character palette and a 256-entry sprite palette; because the raw palette is dark, its contrast is amplified once at boot. The renderer draws the 256×256 raster directly (the M62 is a horizontal cabinet).
Debugger integration
Because the whole board is ordinary JavaScript and the host owns the run loop, the debugger's controls need no changes to the CPU core: the loop can pause, single-step and check breakpoints between any two instructions. window.EMU_BOOT.transport maps the shared debugger onto the Z80:
- pause / resume / isPaused -- stop or restart the
requestAnimationFrameloop. - stepInsn(n) -- run exactly n Z80 instructions through the core's
run_instruction()entry. - step(n) -- advance n whole 60 Hz fields, each honouring the one mode-1 vblank interrupt (
RST 38h). - breakpoints -- a
Setof PC values checked before each instruction; a match pauses before the instruction runs. - watchpoints -- the Z80's memory-write path flags a hit when a watched address is written, and the loop pauses on it.
The stock Z80.js keeps its registers in a closure and exposes a whole-core getState()/setState(); the vendored copy adds two cheap hooks -- get_pc() and set_pc() -- so the run loop can read PC before every instruction (for breakpoints) without allocating a state object, and the machine wraps getState/setState in focused getReg/setReg/getFlag/setFlag helpers that the plug-in binds to. Memory reads use the machine's side-effect-free dbgRead, which returns program ROM, sprite RAM, the tile/colour RAM and work RAM without touching the port-mapped input latches, so inspecting memory never disturbs the machine. The Z80 disassembler is the shared decoder at /debugger/src/cpus/z80.js -- reused unchanged, since the Z80 is already a first-class debugger CPU.
Architecture
The M62 board (Irem, 1984) is a single-Z80 design with Irem's tile/sprite hardware, run on a horizontal monitor:
- Main CPU -- Zilog Z80 at 3.072 MHz (18.432 MHz / 6). Program ROM at
0x0000–0x7fff, the background horizontal-scroll latch at0xa000/0xb000, sprite RAM at0xc000–0xc0ff, the interleaved tile-code and tile-colour RAM at0xd000–0xdfff(codes in the low half, colours in the high half), and work RAM at0xe000–0xefff. This is the CPU the debugger targets. - Ports -- input and dip switches are Z80 port reads:
0x00system (coin / start),0x01player 1,0x02player 2,0x03/0x04the two dip banks. Port writes send the sound command (0x00) and the screen-flip / coin-counter latch (0x01). - Interrupts -- the Z80 runs in interrupt mode 1 and takes a single vblank interrupt each field, vectoring through
RST 38h. - Background -- a 64×32 map of 8×8 three-bit tiles (code extended by two colour bits, 32 palettes, per-tile X-flip). Horizontal scroll is applied per tile row; the top six rows are held fixed for the score line. A per-tile priority category selects whether a tile draws behind or in front of the sprites.
- Sprites -- up to 32 three-bit 16×16 sprites from the
0xc000list; a 32-entry height PROM gives each sprite a height of one, two or four tiles, and the hardware handles X/Y flip and a 512-wide coordinate space. - Palette -- there is no palette RAM. Six 256×4 PROMs (three for characters, three for sprites, one per colour gun) are decoded through a resistor-network DAC into a 256-entry character palette and a 256-entry sprite palette.
The Irem M6803 sound board is omitted here -- audio is optional -- and the graphics ROMs are decoded to one-byte-per-pixel tiles once at boot.