Prev: 42170 Up: Map Next: 42274
42215: Test Jetman Action
Return whether Jetman can collect, using his type and the action key.
Input
IX Actor slot
Return unless Jetman can collect and action is pressed. Type 17 and above means Jetman is not on foot.
TestJetmanAction 42215 LD A,(24696) Fetch Jetman_Slot.
42218 CP 17 Return if Jetman's type is at least 17.
42220 RET NC
42221 CALL TestActionKey Call TestActionKey.
42224 RET Z Return if the action key is not pressed.
42225 LD A,(24704) Fetch Jetman_Flags.
42228 AND %00000001 Keep only bit 0.
42230 RET NZ Return if Jetman is already carrying.
42231 BIT 7,(IX+8) Return if bit 7 of the actor flags is set.
42235 RET NZ
Compare this actor against Jetman_Position and Jetman_Y.
TestJetmanAction_ComparePosition 42236 LD L,(IX+2) Fetch the actor world X.
42239 LD H,(IX+3) Fetch the high byte.
42242 LD BC,8 Add an 8 offset.
42245 ADD HL,BC
Return unless Jetman is horizontally close to the actor.
42246 LD BC,(24698) Fetch Jetman_Position.
42250 AND A Clear the carry flag.
42251 SBC HL,BC Subtract Jetman's world X.
42253 LD A,H Fetch the high byte of the difference.
42254 AND %00011111 Keep only bits 0-4.
42256 RET NZ Return if the actor is on a different screen.
42257 LD A,L Fetch the low byte.
42258 CP 16 Return if it is at least 16.
42260 RET NC
Test whether Jetman is vertically within reach of the actor.
42261 LD A,(24700) Fetch Jetman_Y.
42264 SUB 8 Subtract 8.
42266 SUB (IX+4) Subtract the actor Y.
42269 NEG Negate the difference.
42271 CP 24 Compare it against 24.
42273 RET Return.
Prev: 42170 Up: Map Next: 42274