Prev: 61660 Up: Map Next: 61758
61667: Script Routine: (15) Have entity put down carried entity
Make the entity put down whatever it is carrying.
Input
IX Address of complex state data for an entity
ScriptRoutine_PutDownCarried 61667 CALL Script_PutDown_SetCarryingFlag Call Script_PutDown_SetCarryingFlag to script Put Down Set Carrying Flag.
61670 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
This entry point is used by the routine at Update_Berk_ReadControls.
Place the held entity using Berk's Y as the put-down baseline.
ScriptRoutine_PutDownCarried_PlaceHeldFromBerk 61673 LD C,(IX+5) Load C with the current entity's y-coordinate.
61676 LD IY,(29356) Load IY with the current-entity pointer (Pointer_CurrentEntity).
61680 JR ScriptRoutine_PutDownCarried_SaveSizeAndPlaceY Jump to ScriptRoutine_PutDownCarried_SaveSizeAndPlaceY to continue this routine.
Set bit 4 of flags byte 3 and prepare the held entity for put-down.
Script_PutDown_SetCarryingFlag 61682 SET 4,(IX+3) Set bit 4 of the current entity's flags byte 3.
61686 LD C,(IX+5) Load C with the current entity's y-coordinate.
61689 LD IY,(29356) Load IY with the current-entity pointer (Pointer_CurrentEntity).
61693 LD A,(IY+0) Load A with the referenced entity's entity type.
61696 CP 1 Is A equal to 1? If not, jump to Script_PutDown_Apply.
61698 JR NZ,Script_PutDown_Apply
61700 XOR A Clear A to 0.
61701 LD (29383),A Set the Bad Tempered Thing state (BadTemperedThingState).
Reactivate the held entity; if it is type 9, set Slimies in TaskThreeFlags.
Script_PutDown_Apply 61704 RES 7,(IY+0) Reset bit 7 of the referenced entity's entity type.
61708 CP 9 Is A equal to 9? If not, jump to ScriptRoutine_PutDownCarried_SetHeldBit5.
61710 JR NZ,ScriptRoutine_PutDownCarried_SetHeldBit5
61712 LD A,(29366) Load A with the task-three flags (TaskThreeFlags).
61715 SET 1,A Set Slimies (bit 1 of A. put-down of type 9).
61717 LD (29366),A Set the task-three flags (TaskThreeFlags).
Set bit 5 on the held entity before writing its grounded Y.
ScriptRoutine_PutDownCarried_SetHeldBit5 61720 SET 5,(IY+1) Set bit 5 of the referenced entity's flags byte 1.
Save held width/height into CameraYCoordinate/CameraXCoordinate and park the entity at the put-down Y.
ScriptRoutine_PutDownCarried_SaveSizeAndPlaceY 61724 LD A,(IY+8) Load A with the referenced entity's x-extent.
61727 SUB (IY+7) Subtract the referenced entity's x-coordinate from A.
61730 LD (29421),A Store the held entity's width (x-extent − x) in CameraYCoordinate.
61733 LD A,(IY+6) Load A with the referenced entity's y-extent.
61736 SUB (IY+5) Subtract the referenced entity's y-coordinate from A.
61739 LD (29422),A Store the held entity's height (y-extent − y) in CameraXCoordinate.
61742 LD B,A Keep a copy of A in B.
61743 SRL A Shift A right logical.
61745 NEG Negate A (flip a delta/direction).
61747 ADD A,C A+=C.
61748 ADD A,2 A+=2.
61750 LD (IY+5),A Set the referenced entity's y-coordinate.
61753 ADD A,B A+=B.
61754 LD (IY+6),A Set the referenced entity's y-extent.
61757 RET Return.
Prev: 61660 Up: Map Next: 61758