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: 6123

Author: andrewbroad

Date: 16/04/2007

Subject: Re: Invalid-arrow technology

 

Alexandra wrote:

>
> Would it be possible to change the nature of the arrows so there is
> no arrow at all? Then it would be possible to use arrows solely as
> moving platforms.

This is the code that draws the three pixel-rows of an arrow (upon
entry, HL holds the address of the pixel-position of the middle line):

#928D: DEC H ;;;;;;; up 1 pixel-row
#928E: LD A,(IX+6) ; top-line graphic
#9291: LD (HL),A ;;; write it to graphics-buffer
#9292: INC H ;;;;;;; down 1 pixel-row
#9293: LD A,(HL) ;;; read pixel-row from graphics-buffer
#9294: AND (IX+5) ;; if any pixels overlap
#9297: JP NZ,#90B7 ; then jump to collision-handling routine
#929A: LD (HL),#FF ; write middle-row graphic (always %11111111)
#929C: INC H ;;;;;;; down 1 pixel-row
#929D: LD A,(IX+6) ; bottom-line graphic
#92A0: LD (HL),A ;;; write it to graphics-buffer

The vertical position of an arrow is defined by its middle line.
Valid arrows have a pixel-row (within the character-row) between 1
and 6 inclusive. Invalid arrows have a pixel-row of 0 or 7.

The address of the pixel-position of the top line of an arrow is
calculated by subtracting 256 from the address of the middle line.
When the pixel-row is 0, and the arrow is in the top 8 character-rows
of the screen, this results in a negative offset, and hence the
calculated address falls in the 256 bytes below the graphics-buffer,
which happens to be the bottom 8 character-rows of the colour-
attributes buffer.

So the instruction at #9291 draws the 'invalid' part of the arrow,
while the instructions at #929A/B and #92A0 draw the middle line and
the bottom line, respectively.

So the solution to what you ask is to set the bytes at #929A, #929B
and #92A0 to 0 (POKE 37530,0: POKE 37531,0: POKE 37536,0).

Please note that these pokes affect every arrow in the game! But in
JSW64, you could use the room-entry patch-vector to turn them on/off
for specific rooms.


> It might be nice to slow them down, too,

I don't have time to work through the details right now, but the
following instruction...

#926D: ADD A,(IX+4)

...is what applies the arrow's current column to the sprite-position
lookup-table in order to draw it. So you could replace this
instruction with a sequence of instructions to read (IX+4), halve it
(i.e. right-shift it), and ADD that intermediate value instead.

This will require either shunting the code at #9270 forwards until it
fills the gap left by the above 3 byte-deletions, or overwriting the
ADD A,(IX+4) instruction with a call to a subroutine to do the dirty
work.


> or make them print blocks nearer to where the arrow actually is.

To make the blocks appear /at/ the position of the arrow, rather than
8 character-rows below it, you'd have to subtract 512 rather than 256
from the address of the pixel-position of the middle line.

All this takes is another DEC H after the one at #928D and, to
compensate, another INC H after the one at #9292. And since we've
already NOPped out the instruction at #929A/B, that gives us a nice
2-byte gap to shunt into:

#928D: DEC H
#928E: DEC H ;;;;;;; inserted
#928F: LD A,(IX+6)
#9292: LD (HL),A
#9293: INC H
#9294: INC H ;;;;;;; inserted
#9295: LD A,(HL)
#9296: AND (IX+5)
#9299: JP NZ,#90B7

In the hex-editor, replace:

#928E: DD 7E
#9290: 06 77 24 7E DD A6 05 C2
#9298: B7 90 36 FF

with:

#928E: 25 DD
#9290: 7E 06 77 24 24 7E DD A6
#9298: 05 C2 B7 90

Don't forget: under this patch, all 'arrows' should have a pixel-row
of 0 (I have to say, when it comes to editing arrows, JSW CK is
vastly superior to JSWED v2.3.1, albeit only for JSW48).


Finally, on the subject of invalid arrows, I've been pondering
whether there might not be a good use for the Attic-Bug. This occurs
when the vertical position of an arrow is off the bottom of the
screen, as in "The Attic" in the original, unpatched JSW.

With a vertical position of 213 pixels*2 from the top of the screen,
this arrow tramples over the guardian-class table, causing permanent
damage to a few of the guardian-classes; but by setting the vertical
position so that it tramples over another area of memory instead,
more satisfactory results might be obtained...

--
Dr. Andrew Broad
http://geocities.com/andrewbroad/
http://geocities.com/andrewbroad/spectrum/
http://geocities.com/andrewbroad/spectrum/willy/
http://geocities.com/andrewbroad/spectrum/willy/bugs.html
http://geocities.com/andrewbroad/spectrum/willy/bugs.html#attic_bug

 

 

arrowleft
arrowright