Prev: 25999 Up: Map Next: 26075
26002: Check whether Sam has been hit by a bullet
Used by the routine at 26075. Returns with the carry flag set if Sam has been hit by a bullet.
D Bullet's next screen y-coordinate (1-20)
E Bullet's next screen x-coordinate (0-31)
26002 EXX
26003 XOR A Initialise E' to 0; E' may be updated by the call to 59648 below
26004 LD E,A
26005 EXX
26006 PUSH HL
26007 PUSH DE Save the bullet's screen coordinates
26008 LD HL,(32766) Collect the x- and y-coordinates of the top-left tile of the play area on screen in L and H
26011 ADD HL,DE Add the bullet's screen coordinates
26012 EX DE,HL Now DE holds the bullet's play area coordinates
26013 LD HL,58884 Point HL at byte 4 of Sam's buffer
26016 LD A,(HL) A=Sam's z-coordinate
26017 DEC A Set the zero flag if Sam's indoors
26018 CALL 59648 Print the play area tile where the bullet will be next (if Sam's not indoors)
26021 LD A,E A=reference of the sprite tile (of Sam's) that was printed, or 0 if none was printed
26022 AND A Was a sprite tile printed?
26023 JR Z,26072 Jump if not (Sam was not hit)
26025 CP 16 Was the sprite tile reference in the range 1-15?
26027 JR C,26033 Jump if so
26029 CP 26 Was the sprite tile reference in the range 16-25?
26031 JR C,26047 Jump if so (Sam was hit by the bullet)
The reference of the sprite tile upon which the bullet impinged was in the range 1-15 or greater than 25. Closer examination is required to determine whether Sam was hit.
26033 LD HL,25990 Point HL at the table of sprite tile references at 25990
26036 LD B,9 There are 9 sprite tile references in the table
26038 CP (HL) Compare the reference of the sprite tile that was printed with a reference from the table
26039 JR Z,26047 Jump if they match (Sam was hit)
26041 INC HL Point HL at the next sprite tile reference in the table
26042 DJNZ 26038 Jump back to compare it with the sprite tile that was printed
26044 AND A Reset the carry flag: Sam was not hit by the bullet
26045 JR 26072
Sam was hit by the bullet.
26047 CALL 26352 Make the sound effect of Sam being hit by a bullet
26050 LD HL,32751 32751 holds the number of remaining first aid kits
26053 LD A,(HL) Pick this up in A
26054 ADD A,A Discard a first aid kit
26055 LD (HL),A
26056 JR C,26068 Jump if there was a first aid kit left to discard
Sam has already used all his first aid kits. Game over.
26058 LD L,158 HL=32670 (bucks)
26060 LD (HL),A Reduce Sam's cash supply to 0
26061 INC L
26062 LD (HL),A
26063 LD A,99 Message 99: 'I HAD TO GO TO HOSPITAL...'
26065 JP 31445 Display the ending cutscene with this message
Sam had a first aid kit left.
26068 CALL 29719 Display any remaining first aid kits
26071 SCF Set the carry flag: Sam was hit by the bullet
26072 POP DE Restore the bullet's screen coordinates to DE
26073 POP HL
26074 RET
Prev: 25999 Up: Map Next: 26075