Prev: B87C Up: Map Next: B9A5
B92C: 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 B92C LD BC,($72AA) Load BC with the last-collided entity pointer (Pointer_LastCollidedEntity).
B930 INC BC Advance the counter/pointer in BC by one.
B931 LD A,(BC) Fetch a byte through the pointer in BC.
B932 AND %00001000 Keep only bit 03 of the flag byte in A (mask 08).
B934 JR NZ,Berk_Put_Down_Entity_FromCollision If the result was non-zero, jump to Berk_Put_Down_Entity_FromCollision.
B936 XOR A Clear A as a false / no-match result.
B937 RET Return.
Put-down from the last collision: room-transition special case or above-entity test.
Berk_Put_Down_Entity_FromCollision B938 PUSH IX Stash IX on the stack.
B93A LD IX,($72AA) Load IX with the last-collided entity pointer (Pointer_LastCollidedEntity).
B93E LD A,(IX+$08) Load A with the current entity's x-extent.
B941 CP $B4 Is the current entity's x-extent less than B4? If not, jump to Berk_Put_Down_Entity_RestoreReturn.
B943 JR NC,Berk_Put_Down_Entity_RestoreReturn
B945 CALL Test_EntityAbove Call Test_EntityAbove to test Entity Above? If so, jump to Berk_Put_Down_Entity_SetDirection.
B948 JR C,Berk_Put_Down_Entity_SetDirection
B94A CP $41 Is the current entity's x-extent equal to 41? If not, jump to Berk_Put_Down_Entity_CollisionRetry.
B94C JR NZ,Berk_Put_Down_Entity_CollisionRetry
B94E LD (IX+$04),$03 Write 03 to the current entity's room index.
B952 SET 4,(IX+$02) Set bit 04 of the current entity's flags byte 2.
B956 LD HL,$72B3 Point HL at the game event flags (GameEventFlags).
B959 SET 6,(HL) Set "special put-down / room-transition event" (bit 06 of GameEventFlags).
B95B 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 B95D 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.
B960 JR C,Berk_Put_Down_Entity_SetDirection
Exit the put-down attempt, restoring Berk's entity pointer in IX.
Berk_Put_Down_Entity_RestoreReturn B962 POP IX Restore IX from the stack.
B964 RET Return.
Mark the put-down entity's direction/state as released (81).
Berk_Put_Down_Entity_SetDirection B965 LD (IX+$09),$81 Write 81 to the current entity's direction / state.
B969 POP IX Restore IX from the stack.
B96B RET Return.
This entry point is used by the routine at Berk_Pick_Up_Entity.
Y-extent 38 put-down: run script BB11 when no timed event is pending.
Berk_Put_Down_Entity_AtYExtent38 B96C BIT 4,(IX+$03) Is bit 04 of flags byte 3 (IX+03) set? If so, jump to Berk_ReadControls_Idle.
B970 JP NZ,Berk_ReadControls_Idle
B973 LD A,($72CE) Load A with the timed event latch (TimedEventLatch).
B976 OR A Is timed event latch zero? If not, jump to Berk_ReadControls_Idle.
B977 JP NZ,Berk_ReadControls_Idle
B97A LD HL,$BB11 Point HL at Berk control/put-down script data (BB11).
B97D 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 41 put-down: run script BB7B.
Berk_Put_Down_Entity_AtYExtent41 B980 LD HL,$BB7B Point HL at Berk control/put-down script data (BB7B).
B983 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 B986 CALL Reposition_CameraFollowEntity Call Reposition_CameraFollowEntity to fill Attribute Rows.
B989 LD HL,($72B1) Load HL with Berk's script position pointer (Pointer_BerkScriptPosition).
B98C LD ($72CF),HL Store HL in the active script cursor (Pointer_ActiveScriptCursor).
B98F 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 B990 BIT 4,(IX+$03) Is bit 04 of flags byte 3 (IX+03) set? If so, jump to Berk_ReadControls_Idle.
B994 JP NZ,Berk_ReadControls_Idle
B997 LD A,($72BA) Load A with the trap door flags (TrapDoorFlags).
B99A BIT 3,A Is bit 03 of trap door flags set? If so, jump to Berk_ReadControls_Idle.
B99C JP NZ,Berk_ReadControls_Idle
B99F LD HL,$BB21 Point HL at a Berk put-down script (BerkPutDownScript_TrapDoor).
B9A2 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Prev: B87C Up: Map Next: B9A5