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: 5020
Author: andrewbroad
Date: 06/11/2005
Subject: Re: Infinite death from falling too far
andrewbroad wrote:
>...
> My next game will be Afrikaan, a 48K JSW game with several patches
> which have to be written first:
> * if you fall off the bottom of the screen from a height of moreThe JSW game-engine actually codes this infinite-death scenario
> than 4 character-rows, it kills you immediately, rather than
> infinitely in the room below.
explicitly!
38098: LD A,(33004) ; get room below from current-room buffer
38101: LD (33824),A ; set current room to room below
38104: XOR A ;;;;;;;; A= 0
38105: LD (34255),A ; set Willy at pixel-row 0 (top of screen)
38108: LD A,(34257) ; get Willy's airborne status (2..254: falling)
38111: CP 11 ;;;;;;;; } if airborne >= 11
38113: JR NC,+5 ;;;;; } then jump to 38120
38115: LD A,2 ;;;;;;;
38117: LD (34257),A ; set airborne status to 2 (start of fall)
38120: LD A,(34259) ; get low byte of Willy's attribute-address
38123: AND 00011111 ; knock out row [Bits 7:5], preserve column [4:0]
38125: LD (34259),A ; write it back
38128: LD A,92 ;;;;;; } set high byte of Willy's attribute-address
38130: LD (34260),A ; } to top half of screen (MSb of row = 0)
38133: POP HL
38134: JP 35090 ;;;;; enter destination-room
The instruction at 38113 skips over the code that resets Willy's
fall-counter if he has fallen too far off the bottom of the screen.
So POKE 38113,0: POKE 38114,0 blanks out this instruction, meaning
that the fall-counter will always be reset at the top of the room
below, no matter how far you have fallen.
To kill Willy rather than move to the room below isn't so
straightforward, as it would require the 3-byte instruction JP 37047
(jump to the lose-life routine) to replace the 2-byte JR.
A bit of code-motion needed here...
But the simpler solution would actually be desirable in a game where
you could be falling into a room that has fall-without-dying enabled
from one that does not (POKE 36477,1 actually freezes the fall-
counter - it will not save you if the fall-counter is already too
great).
--
Dr. Andrew Broad
http://www.geocities.com/andrewbroad/
http://www.geocities.com/andrewbroad/spectrum/
http://www.geocities.com/andrewbroad/spectrum/willy/
