Prev: E2FC Up: Map Next: E36D
E329: Check for collision detection
Used by the routines at ED8A, F057, F10E, F24B, F277, F309, F334, F37D, F3AB, F409, F49D, F4D3, F503, F5F1, F674, F6EC and F746.
Input
IY Pointer to character buffer
E329 LD A,($A838) Get the x co-ordinate in the scratch buffer. (A838)
E32C SUB (IY+$05) Is it close enough to this player?
E32F SUB $0D
E331 CP $E6
E333 RET C Return if it isn't.
E334 LD A,($A839) Get the y co-ordinate in the scratch buffer.
E337 SUB (IY+$0A) Is it close enough to this player?
E33A SUB $1C
E33C CP $D6
E33E RET C Return if it isn't.
The character has collided with something. Decrease endurance. The amount to decrease by is set in F26E, set up by the various room specific routines. (Herbert is 2. The shark in the sewer is 64!) This entry point is used by the routines at F54F, F773 and F8B9, which reduce endurance by other means.
E33F LD A,($B55F) Is the current player computer controlled?
E342 OR A
E343 RET NZ Return if so.
The current character is human controlled, so decrease endurance.
E344 EXX Swap main registers.
E345 LD BC,$640A Play the 'decrease endurance' sound effect.
E348 LD DE,$0101
E34B LD HL,$6401
E34E CALL $E3D3
E351 LD A,($F26E) Get the amount of endurance to decrease by.
E354 LD B,A Put this in B.
E355 LD A,(IY+$14) Decrease the character's endurance by this amount.
E358 SUB B
E359 LD (IY+$14),A
E35C JR Z,$E362 If the endurance is zero or less, a life is lost.
E35E JR C,$E362
E360 JR $E36C Otherwise jump forward.
The character has run out of endurance, so lose a life.
E362 LD (IY+$14),$80 Put the endurance back up to maximum. (80)
E366 DEC (IY+$2D) Decrease the number of lives.
E369 JP Z,$B451 If no lives are left, signal the game is over.
E36C EXX Swap main registers. Control continues to E36D.
Prev: E2FC Up: Map Next: E36D