Prev: 47228 Up: Map Next: 47525
47404: Berk Put Down Entity
Used by the routine at Berk_Pick_Up_Entity.
Berk Put Down Entity for the player character using complex state at StateData_Boney.
Input
IX Address of complex state data for an entity
Berk_Put_Down_Entity 47404 LD BC,(29354) Load BC with the last-collided entity pointer (Pointer_LastCollidedEntity).
47408 INC BC Advance the counter/pointer in BC by one.
47409 LD A,(BC) Fetch a byte through the pointer in BC.
47410 AND %00001000 Keep only bit 3 of the flag byte in A (mask 8).
47412 JR NZ,Berk_Put_Down_Entity_FromCollision If the result was non-zero, jump to Berk_Put_Down_Entity_FromCollision.
47414 XOR A Clear A as a false / no-match result.
47415 RET Return.
Put-down from the last collision: room-transition special case or above-entity test.
Berk_Put_Down_Entity_FromCollision 47416 PUSH IX Stash IX on the stack.
47418 LD IX,(29354) Load IX with the last-collided entity pointer (Pointer_LastCollidedEntity).
47422 LD A,(IX+8) Load A with the current entity's x-extent.
47425 CP 180 Is the current entity's x-extent less than 180? If not, jump to Berk_Put_Down_Entity_RestoreReturn.
47427 JR NC,Berk_Put_Down_Entity_RestoreReturn
47429 CALL Test_EntityAbove Call Test_EntityAbove to test Entity Above? If so, jump to Berk_Put_Down_Entity_SetDirection.
47432 JR C,Berk_Put_Down_Entity_SetDirection
47434 CP 65 Is the current entity's x-extent equal to 65? If not, jump to Berk_Put_Down_Entity_CollisionRetry.
47436 JR NZ,Berk_Put_Down_Entity_CollisionRetry
47438 LD (IX+4),3 Write 3 to the current entity's room index.
47442 SET 4,(IX+2) Set bit 4 of the current entity's flags byte 2.
47446 LD HL,29363 Point HL at the game event flags (GameEventFlags).
47449 SET 6,(HL) Set "special put-down / room-transition event" (bit 6 of GameEventFlags).
47451 JR Berk_Put_Down_Entity_SetDirection Jump to Berk_Put_Down_Entity_SetDirection to finish putting the entity down.
Retry put-down via Berk_Put_Down_Entity after the first collision path did not finish.
Berk_Put_Down_Entity_CollisionRetry 47453 CALL Berk_Put_Down_Entity Call Berk_Put_Down_Entity to let Berk put down an entity? If so, jump to Berk_Put_Down_Entity_SetDirection.
47456 JR C,Berk_Put_Down_Entity_SetDirection
Exit the put-down attempt, restoring Berk's entity pointer in IX.
Berk_Put_Down_Entity_RestoreReturn 47458 POP IX Restore IX from the stack.
47460 RET Return.
Mark the put-down entity's direction/state as released (129).
Berk_Put_Down_Entity_SetDirection 47461 LD (IX+9),129 Write 129 to the current entity's direction / state.
47465 POP IX Restore IX from the stack.
47467 RET Return.
This entry point is used by the routine at Berk_Pick_Up_Entity.
Y-extent 56 put-down: run script 47889 when no timed event is pending.
Berk_Put_Down_Entity_AtYExtent38 47468 BIT 4,(IX+3) Is bit 4 of flags byte 3 (IX+3) set? If so, jump to Berk_ReadControls_Idle.
47472 JP NZ,Berk_ReadControls_Idle
47475 LD A,(29390) Load A with the timed event latch (TimedEventLatch).
47478 OR A Is timed event latch zero? If not, jump to Berk_ReadControls_Idle.
47479 JP NZ,Berk_ReadControls_Idle
47482 LD HL,47889 Point HL at Berk control/put-down script data (47889).
47485 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
This entry point is used by the routine at Berk_Pick_Up_Entity.
Y-extent 65 put-down: run script 47995.
Berk_Put_Down_Entity_AtYExtent41 47488 LD HL,47995 Point HL at Berk control/put-down script data (47995).
47491 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
This entry point is used by the routine at Update_Berk_ReadControls.
Low-band abort: refill attribute rows and republish Berk's script cursor.
Berk_Put_Down_Entity_PublishScriptPos 47494 CALL Reposition_CameraFollowEntity Call Reposition_CameraFollowEntity to fill Attribute Rows.
47497 LD HL,(29361) Load HL with Berk's script position pointer (Pointer_BerkScriptPosition).
47500 LD (29391),HL Store HL in the active script cursor (Pointer_ActiveScriptCursor).
47503 RET Return.
This entry point is used by the routine at Berk_Pick_Up_Entity.
Trap door y-extent put-down: run BerkPutDownScript_TrapDoor unless carrying or trap flags block it.
Berk_Put_Down_Entity_TrapDoor 47504 BIT 4,(IX+3) Is bit 4 of flags byte 3 (IX+3) set? If so, jump to Berk_ReadControls_Idle.
47508 JP NZ,Berk_ReadControls_Idle
47511 LD A,(29370) Load A with the trap door flags (TrapDoorFlags).
47514 BIT 3,A Is bit 3 of trap door flags set? If so, jump to Berk_ReadControls_Idle.
47516 JP NZ,Berk_ReadControls_Idle
47519 LD HL,47905 Point HL at a Berk put-down script (BerkPutDownScript_TrapDoor).
47522 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Prev: 47228 Up: Map Next: 47525