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: 6340
Author: andrewbroad
Date: 29/12/2007
Subject: Laterally inverting a diagonal guardian
Following on from Message 6280, here's another worked example of
laterally inverting a diagonal guardian for my JSW64:Z James Bond
game.
This time, I want a symmetrical skier on the right-hand side of "On
Her Majesty's Secret Service" [5].
The existing, left-hand skier has changed since v0.7. It now starts
one pixel above (11,2); I have elongated its path by changing its
right-boundary from 11 to 12, and made it white to avoid colour-
clash. This new path makes OHMSS completable.
Thus the hex of the left-hand skier is:
86 EF 02 AE FC AF 00 0C
(In what follows, these bytes are referred to as Bytes 0 to 7.)
N.B. When laterally inverting something that is one cell-column wide,
its cell-column maps from x to 31-x (#1F-x).
When laterally inverting something that is two cell-columns wide, its
left cell-column maps from x to 30-x (#1E-x).
To create a right-hand skier that is a mirror-image of the left:
1. Change Byte 0 (initial direction and guardian-type) from #86 to
#05 (reset Bit 7 to go left initially, and set Bits 3:0 to 5 to
change it from a '/' DG to a '\' DG).
2. Change Byte 2 (the start-column) from #02 to #1C.
3. Swap Bytes 6 and 7 (left- and right-boundaries) and laterally
invert them; thus #0C for Byte 7 maps to #12 for Byte 6, while #00
for Byte 6 maps to #1E for Byte 7.
4. The air on the right-hand side of the mountain is not BRIGHT, so
change Byte 1 from #EF to #E7 (unlike a conventional colour-attribute
where the BRIGHT-flag is Bit 6, here it's Bit 3).
Thus the hex of the right-hand skier is as follows:
05 E7 1C AE FC AF 12 1E
However, this guardian is 7 pixels lower than the left-hand skier,
causing it to sink into the snow: goodbye, Mr. Bond!
The explanation is that a JSW horizontal guardian that goes right
initially (as the left-hand skier does) always starts on its leftmost
sprite-frame, but so does a horizontal guardian that goes left
initially! (A DG is best thought of as a HG with a vertical speed.)
This means that (without patching the game-engine), it is impossible
to laterally invert a HG or DG exactly: if you map its start-column
from x to 30-x, it'll be 3 steps forward (when mapping the initial
direction from right to left) or 3 steps behind (when mapping the
initial direction from left to right).
So the closest solution is to add 1 to the start-column when mapping
the initial direction from right to left (making it one step behind),
or subtract 1 when mapping the initial direction from left to right
(making it one step ahead). In other words, map the start-column
using 31-x instead of 30-x (whilst still using 30-x for the
boundaries).
This gives the right-hand skier as:
05 E7 1D AE FC AF 12 1E
(using a start-column of #1D instead of #1C).
This makes the right-hand skier 3 pixels above the snow (its vertical
speed is 2 pixels per time-frame), so my final tweak is to move its
start-row down 2 pixels (Byte 3: #AE -> #B2 - the standard unit of
height in MM/JSW is pixels*2):
05 E7 1D B2 FC AF 12 1E
And the left-hand skier is one time-frame ahead of the right-hand
skier, as per the above explanation.
--
Dr. Andrew Broad
http://geocities.com/andrewbroad/
http://geocities.com/andrewbroad/spectrum/
http://geocities.com/andrewbroad/spectrum/willy/
