Resource centre for ZX Spectrum games
using Manic Miner and Jet Set Willy game engines
Archive of the
Manic Miner & Jet Set Willy Yahoo! Group
messages
|
|
||
|
|
Message: 5030
Author: andrewbroad
Date: 11/11/2005
Subject: Willy's movement / Turning in mid-jump / New superjump
I was hoping that the ability to turn left or right during a jump or
fall would be a simple matter of NOPping out a branch, but no such
luck.
--------------------------------------
Willy's movement in JSW: Code-overview
--------------------------------------
In Jet Set Willy, the subroutine to handle Willy's movement starts
at 8DD3. The controls for left, right and jump are only recognised
during walking-mode, which starts at 8ED4.
The code at 8DD3 branches to 8ED4 if Willy is on a rope. If not, it
branches to 8E36 if Willy is NOT jumping. Otherwise it processes the
jump with no regard for the controls, branching to 8FBC to handle
the horizontal movement.
The code at 8E36 checks what Willy's standing on, and is branched-to
at the end of a jump (after 18 time-frames) and also during the
downward part of the jump (after 13 and 16 time-frames - i.e. when
Willy is two and one character-row(s) above where he started the
jump).
The code at 8E36 examines the two cells under Willy's feet. If
they're Air (both cells) or Fire (either cell), it branches to 8E62
to start (or continue) falling. Otherwise it branches to 8ED4.
The code at 8ED4 handles walking, including on a conveyor. It is
this routine which tests for the left, right and jump controls,
setting the appropriate variables (to be acted on in the next time-
frame). It finishes by returning from the subroutine which began at
8DD3.
The code at 8FBC handles Willy's horizontal movement, and is used
for both walking and jumping, left or right. It handles everything
from moving within a character-column, to moving into a new
character-column, to moving into a new room, as well as housing the
code for fundamental movement (return if we hit a wall; deal with
ramps).
Summary (ignoring room-exits and losing a life):
8DD3: handle Willy's movement (branches to 8ED4, 8E36 or 8FBC)
8E36: check what he's standing on (branches to 8E62 or 8ED4)
8E62: falling (branches to 8FBC or returns)
8ED4: walking (branches to 8FBC or returns)
8FBC: horizontal movement (returns)
So the ability to turn left or right during a jump or fall is no
simple tweak: it would require incorporating the code which tests
for the left and right controls (in 8ED4) into the code which
processes the jump (in 8DD3) - possibly by packaging the control-
testing code (minus the jump-control, unless we want an effect
similar to superjump) into a subroutine which can be called from all
three places (the walking-code, the jumping-code and the falling-
code).
---------
Superjump
---------
The superjump POKE 36404,44 is an interesting one because it allows
the jump-control - but not the left & right controls - to be used in
the middle of a jump.
36389: LD A,(34261) ; if jump-phase counter
36392: CP 18 ;;;;;;;; == 18
36394: JP Z,8EB0h ;;; then jump is over (set fall-counter to 6)
36397: CP 16 ;;;;;;;; else if jump-phase counter == 16
36399: JR Z,8E36h ;;; then check what Willy's standing on (8E36)
36401: CP 13 ;;;;;;;; else if jump-phase counter <> 13
36403: JP NZ,8FBCh ;; then do horizontal movement (8FBC)
;;;;;;;;;;;;;;;;;;;;; (else fall through to 8E36)
POKE 36404,44 makes the following change:
36403: JP NZ,8F2Ch
This jumps into the middle of the walking-routine (8ED4) -
apparently after the left & right controls have been checked for,
but before the jump-control is checked for. (The walking-routine
eventually branches to 8FBC.)
So to allow left & right as well as jump-control during a jump, we
can branch to the point where the walking-routine starts checking
the controls (8EFA) with POKE 36404,250: POKE 36405,142 which make
the following change:
36403: JP NZ,8EFAh
Having applied these two POKEs, however, we need to knock out the
AND E instruction at 36611, where E holds the conveyor-mask (253 for
left-conveyor, 254 for right-conveyor, 255 for off-conveyor, 0 for
sticky conveyor).
Thus POKE 36404,250: POKE 36405,142: POKE 36611,0 gives Willy an
entirely new way of jumping: he can turn left and right, and stop,
during the jump, and can also fly upwards indefinitely. But POKE
36611,0 makes all conveyors behave as off-conveyors.
So it looks like the proper way to allow Willy to turn left and
right during a jump or fall is to replicate the control-checking
routine, with the jump-control code stripped out...
--
Dr. Andrew Broad
http://www.geocities.com/andrewbroad/
http://www.geocities.com/andrewbroad/spectrum/
http://www.geocities.com/andrewbroad/spectrum/willy/
