1984 · Software Projects

Jet Set Willy

This minisite was contributed by air, 64kramsystem. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/c64/jet-set-willy with me to Gold.

The whole game, ported to JavaScript routine by routine and run on its own bytes at the C64's pace, sprite collisions and all.

01 · Play

Play Jet Set Willy with the keyboard

Willy walks with the keys of the top two rows, left and right in turn, and jumps with the bottom row. The arrow keys stand in for a joystick in port 2. On the title, Enter starts a game.

KeysOn the C64Does
Tap a key in this table to press it in the game.
EnterReturnstart a game on the title; the tune off or on in play
A to LA S D F G H J K L : ;pause; any other key goes on
= -+ and −the tune louder or quieter
EscRUN/STOPend the game
Q E T U O or ←Q E T U O @ 1 3 5 7 9, or the joystickwalk left
W R Y I P or →W R Y I P * 2 4 6 8 0, or the joystickwalk right
Z to /, Space or ↑Z X C V B N M , . / and Space, or firejump

The game as the port runs it, from the BCS crackers' start-up to the title and on. Every key of the C64's top two rows and its bottom row works as the game reads it, from the tables at $2C2B to $2C4C, and the keys of a PC keyboard stand where the C64's do.

02 · The port

Every routine of the game, written again in JavaScript

This page does not emulate a 6502. The game is written out in JavaScript, one function for each routine of the listing, and runs on the game's own 64 KB, loaded from the bytes the Source code tab shows. Every variable stays where the game keeps it: the room's record at $0840, the guardians at $0940, the rope at $0400, the items' flags at $22C3 and the screen at $7C00.

Two races between the main program and the play interrupt are kept as the game has them. The interrupt moves the rope's sprites while a new room sets them, and it sets Willy's bit in $D010, the sprites' ninth bit of X, while the main program reads, changes and writes back the register for an arrow, a guardian, the toilet, Maria, or the rope. An interrupt between that read and that write is undone, and Willy's bit stays as it was until the next frame's interrupt. The port yields at each read and write, so the page's interrupt can fall between them as the game's can.

The game finds its deaths by guardians and arrows in the video chip's collision registers, $D01E and $D01F. The site's model of them, collide.js, works them out as the beam draws the sprites and the graphics.

The page keeps the C64's pace by keeping its clock. Each routine the port calls moves the clock on by the cycles the game's own routine takes on average, and for a few by what they are given: the items in the room, the guardians that move, the spare lives. The code between two of the port's checkpoints that none of the routines accounts for moves it by that stretch's own average. The clock runs the play interrupt on its lines and takes from the processor the 43 cycles of each bad line and the cycles of each sprite's fetch, as the video chip does. Over 60,000 frames a pass of play takes the page 0.13 % less time than the game.

The screen is drawn by the site's model of the video chip from the port's memory, with each write to the chip at the line and cycle where the clock stood, and each change to memory where the game's code made it. The interrupt's changes count from where its cycles end: on the title, the interrupt at line $EA moves the ticker's row a character on after the chip has fetched the row for the frame, so the moved row shows from the next frame, as on the C64. The sound is the port's writes to the SID, in twelfths of a frame, played through the site's model of the SID.