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: 4396
Author: john_elliott_uk
Date: 19/08/2004
Subject: Re: Patch Vectors
--- In manicminerandjetsetwilly@yahoogroups.com, "Alexandra"
> I'll want to be able to do stuff like:
This one is simple enough that I can write it off the top of my head.
> - make the conveyor alternate direction every n frames
tick: defb 0 ; Number of frames since conveyors reversed
vector: ld hl,tick ;HL = address of the tick count.
inc (hl) ;Add 1 to the count.
ld a,(hl) ;Get its new value
cp 26 ;Or however many ticks you want
ret c ;If A is less than 26, return.
ld (hl),0 ;Reset the counter to 0.
ld hl,80D6h ;HL = address of the conveyor direction
ld a,(hl) ;A = current conveyor flag
xor 1 ;If A was 1, it becomes 0, and vice versa.
ld (hl),a
ret
> - make certain guardians wrap around or be lifts
Guardian stuff like this can be done in two ways. Either define a
new game-wide guardian type, or do something special with patch vectors.
To define a new game-wide type, you have to write two machine-code
programs - the 'move' routine, and the 'draw' routine. The table of
guardian movement routines is at 84D2h; the table of drawing routines
is at 0EC66h. At the end of a movement routine, jump to 91B6h; at the
end of a draw routine, jump to 93B3h.
The alternative system (patch vectors) is how JSW64:MM did its
skylabs until I wrote the new Skylab support code. This worked by
having a Skylab table after the end of the room guardian table; then
the patch vector code was pretty much a direct lift from Manic Miner.
> - make some guardians leave a trail like the foot does
You'd have to draw the trail each frame. A custom guardian draw
vector looks like the way to go here.
> - other types of switch
Such as?
> - silly stuff like mirroring willy's coords every n frames
I did the "every n frames" bit above. For mirroring Willy's coords,
you replace the last 5 lines with something like
ld hl,85D3h ; Address of Willy's X-coordinate
ld a,(hl) ; A = X-coord (low 5 bits) and
; some of the Y-coord (high 3 bits)
and 31 ; A = X-coord
ld c,a ; C = X-coord
ld a,(hl)
and 0E0h ; A = 3 bits of Y-coord
ld b,a ; B = 3 bits of Y-coord
ld a,31
sub c ; A = 31 - X
or b ; A = (31 - X) + (3 bits of Y-coord)
ld (hl),a ; Set new position
ret
The fiddly bit here is reversing the value in the low 5 bits of the
byte without altering the high 3.
> The most complicated patch I need so far involves "rescuing" Monty
Changing the graphics for guardians can be done with triggers, of
> Mole from a coal crusher by flipping a character switch. Flipping the
> switch is intended to change the graphics for several of the room
> sprites, to depict a saved Monty, give an extra life to the player,
> and set a flag in the room so that next time you enter you cannot re-
> rescue Monty.
>
> Would that be possible to fit into 64 bytes, do you think?
course. Changing the graphics for cells can't be done without a
full-scale room reset, on the order of Willy going out and coming back
in. Giving an extra life can be done in 3 bytes - CALL 9000h. Setting
a flag can be done in 5 bytes:
LD HL,8B11h
LD (HL),1
but you'd also have to patch the game startup code so that the flag
gets reset at the start of a new game.
