Prev: 41884 Up: Map Next: 41983
41921: Place Carried Item
On action, snap the object to the ground using the terrain under Jetman.
Input
IX Actor slot
On action, snap the object to the ground under Jetman.
PlaceCarriedItem 41921 CALL TestActionKey Call TestActionKey.
41924 JR Z,PlaceCarriedItem_Facing Jump to PlaceCarriedItem_Facing if the action key is not pressed.
41926 BIT 1,(IX+8) Jump to PlaceCarriedItem_Facing if bit 1 of the actor flags is set.
41930 JR NZ,PlaceCarriedItem_Facing
41932 CALL ReadTerrainCell Call ReadTerrainCell.
41935 LD A,D Fetch the first terrain byte under the object.
41936 AND A Jump to ReleaseCarriedItem if that cell is not empty.
41937 JR NZ,ReleaseCarriedItem
Bit 2 of Jetman's 0-based sprite index is facing. Copy that into bit 3 of this object.
PlaceCarriedItem_Facing 41939 LD A,(24696) Fetch Jetman_Slot.
41942 DEC A Decrease it to a 0-based sprite index.
41943 AND %00000100 Keep only the facing bit.
41945 JR NZ,PlaceCarriedItem_SetBit3 Jump to PlaceCarriedItem_SetBit3 if Jetman is facing right.
41947 RES 3,(IX+0) Reset bit 3 of the actor type.
Place the object at Jetman's X, just below his Y.
PlaceCarriedItem_Loop 41951 LD HL,(24698) Fetch Jetman_Position.
41954 LD (IX+2),L Write the low byte as the object world X.
41957 LD (IX+3),H Write the high byte.
41960 LD A,(24700) Fetch Jetman_Y.
41963 ADD A,8 Add 8.
41965 CP 175 Jump to PlaceCarriedItem_WriteY if that is still above the ground line.
41967 JR C,PlaceCarriedItem_WriteY
175 is the ground line.
41969 LD A,175 A=175.
PlaceCarriedItem_WriteY 41971 LD (IX+4),A Write it as the object Y.
41974 JP Handler_WorldObject_Loop Jump to Handler_WorldObject_Loop.
PlaceCarriedItem_SetBit3 41977 SET 3,(IX+0) Set bit 3 of the actor type.
41981 JR PlaceCarriedItem_Loop Jump to PlaceCarriedItem_Loop.
Prev: 41884 Up: Map Next: 41983