Prev: A4BA Up: Map Next: A522
A4E7: 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 11 and above means Jetman is not on foot.
TestJetmanAction A4E7 LD A,($6078) Fetch Jetman_Slot.
A4EA CP $11 Return if Jetman's type is at least 11.
A4EC RET NC
A4ED CALL TestActionKey Call TestActionKey.
A4F0 RET Z Return if the action key is not pressed.
A4F1 LD A,($6080) Fetch Jetman_Flags.
A4F4 AND %00000001 Keep only bit 0.
A4F6 RET NZ Return if Jetman is already carrying.
A4F7 BIT 7,(IX+$08) Return if bit 7 of the actor flags is set.
A4FB RET NZ
Compare this actor against Jetman_Position and Jetman_Y.
TestJetmanAction_ComparePosition A4FC LD L,(IX+$02) Fetch the actor world X.
A4FF LD H,(IX+$03) Fetch the high byte.
A502 LD BC,$0008 Add an 08 offset.
A505 ADD HL,BC
Return unless Jetman is horizontally close to the actor.
A506 LD BC,($607A) Fetch Jetman_Position.
A50A AND A Clear the carry flag.
A50B SBC HL,BC Subtract Jetman's world X.
A50D LD A,H Fetch the high byte of the difference.
A50E AND %00011111 Keep only bits 0-4.
A510 RET NZ Return if the actor is on a different screen.
A511 LD A,L Fetch the low byte.
A512 CP $10 Return if it is at least 10.
A514 RET NC
Test whether Jetman is vertically within reach of the actor.
A515 LD A,($607C) Fetch Jetman_Y.
A518 SUB $08 Subtract 08.
A51A SUB (IX+$04) Subtract the actor Y.
A51D NEG Negate the difference.
A51F CP $18 Compare it against 18.
A521 RET Return.
Prev: A4BA Up: Map Next: A522