Coder2: joystick installer

Dunjunz, official flippy disc (Bug-Byte, 1987), Master 128 side

Updated 8 Nov 2026

← All Dunjunz versions

FileLoadExecLengthSHA-256
Coder2&2000&2000&0026a32ffa23236c7aae944d6d3201bf41ded524362436f8002ca9b1713a276c8770

Coder2: install the joystick handler and run Coder

Coder2 is the Master side's joystick installer, 38 bytes at &2000. *DUNJUNZ's run_coder runs it as *CODER2, in place of *CODER, when joystick channel 1 reads as a stick at rest; the display is already blanked and VDU output disabled. The run is three steps in a straight line: *L. Code loads the joystick handler into private RAM (HAZEL) at &C500, which MOS 3.20 leaves paged in; BYTEV is pointed at it; and *CODER loads and starts the game, and does not return. There is no RTS: the two command strings follow the last call. It leaves BYTEV pointing at the handler for the whole game. Every OSBYTE call then passes through it: INKEY scans of the Barbarian's (hero 2's) keys N, M, G, B and SPACE are answered from the joystick's two axes and fire buttons, so the joystick plays the Barbarian, and every other call goes straight to the MOS 3.20 OSBYTE routine at &EEB1. BYTEV's old value is not saved, so anything hooked into BYTEV before is bypassed.

2000 .coder2_start
LDX #<(load_code_command) ; *L. Code: load the joystick handler at &C500
2002 LDY #>(load_code_command) ; ...(X, Y) = the command line
2004 JSR oscli ; ...loaded into HAZEL, which MOS 3.20 leaves paged in
2007 LDA #<(joystick_handler) ; Point BYTEV at the handler, so every OSBYTE...
2009 STA bytev ; ...goes through it first...
200C LDA #>(joystick_handler) ; ...(the handler's page)...
200E STA bytev + 1 ; ...and INKEY scans for the hero's keys read the stick
2011 LDX #<(coder_command) ; *CODER: load and start the game
2013 LDY #>(coder_command) ; ...(X, Y) = the command line
2015 JSR oscli ; ...never returns: the game takes over the machine
; The OSCLI command lines, each ended by a carriage return.
2018 .load_code_command
EQUS "L. Code", &0D ; Load the joystick handler at its own &C500
2020 .coder_command
EQUS "CODER", &0D ; Run Coder, which loads and starts the game
fall through ↓