1987 · Imagine

Arkanoid: controls

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

Four ways to steer the Vaus, chosen on a menu before every game: a joystick, the keyboard, paddles or a Neos mouse. Each is read by its own routine, and they do not feel the same.

02 · Four devices

One reader for each device

Each frame the game jumps to the chosen device's reader through a table (read_input_device, $FC9F), in the menu's order: N, J, K, P.

DeviceMoves the VausFire
Joystick (read_joystick, $FDA2)port 1, or port 2 for player 2 with two devices; left and right only, a step that grows with the ball's speedthe stick's button
Keyboard (read_keyboard, $FD7B)left SHIFT left, right SHIFT right, the same steps as the joystickSPACE, or fire on a joystick in port 1
Paddles (read_paddle, $FE09)the paddle's position, read from the sound chip ($D419 for player 1, $D41A for player 2)the paddle's button ($DC01 bit 2 or 3)
Neos mouse (read_neos_mouse, $FE43)its movement, read as four 4-bit pieces through the portthe button, when $D419 reads $FF

The joystick in port 1 is unusual: most games read port 2. Player 1's joystick and mouse are read on port 1, and with one device both players share it. Up and down are read and ignored. Pressing left and right together leaves the Vaus where it is (joystick_step, $FDBF).

The keyboard is the joystick by another route. read_keyboard turns the two SHIFT keys into the joystick's left and right bits ($0203) and hands them to the same step routine. Its fire is bit 4 of port 1, which is both SPACE and a joystick's fire, so a stick in port 1 can fire for the keyboard player.

Whatever the device, place_vaus ($FCEE) then keeps the Vaus between the walls, its left edge at X $20 or more and its right edge below $DB, and reaching the right-hand limit is what lets it through an open Break exit ($023E).

03 · Stick or paddle

The joystick speeds up with the ball; the paddle goes where the hand is

A joystick moves the Vaus a fixed step each frame, and the step is tied to the ball's speed. A paddle sets where the Vaus should be, and it closes half the distance each frame.

How many frames each device takes to move the Vaus 100 pixels, at fifty frames a second. The joystick's step is 2 × (speed + 1) pixels a frame (joystick_step, $FDBF, from ball_speed, $023A). The paddle's new centre is (255 − reading + old centre) / 2, rounded down (read_paddle, $FE09), counted here until the Vaus is within a pixel of the target. A life starts at speed 2; the S capsule takes one off, the D capsule adds one, and the speed rises as the round goes on, up to 11 ($ADE7).

At the start of a life the stick moves the Vaus 6 pixels a frame, and late in a long round 24, so fine aiming gets harder as the ball gets faster. The paddle has no such limit: it covers most of a move in the first few frames whatever the ball is doing. Players on Lemon64 say the game is much better with paddles (Reception). How the Vaus sends the ball back once it gets there is on the How it works tab.

04 · The Neos mouse

Bug: the mouse reader loses track of its port

The Neos mouse sends its movement four bits at a time. The game sets bit 4 of the mouse's port to an output and toggles it between reads, with short delays between (delay_y, $FEC9), to collect the high and low halves of the X movement and then of the Y movement. Part way through, a TAX at $FE86 puts the X movement in the register that held the port's number. The reads and writes after it, $DC00,X, then reach the CIA 1 register the movement happens to pick rather than the mouse's port. This was traced in the code and not tried with a mouse: the emulator's Neos mouse was not used.

An older copy of the same reader, left in memory and never run, reads port 2 only, by its fixed addresses, and does not have the bug (old_build_mouse, $BEDF).