Prev: B258 Up: Map Next: B41A
B2AA: Update Entity Slot
Used by the routine at Process_Special_Entity_Flags.
Update Entity Slot walking the entity tables at StateData_SimpleEntities / StateData_Boney.
Input
IX Address of complex state data for an entity
Update_Entity_Slot B2AA CALL Test_EntityOverlap_AllowSpecial Call Test_EntityOverlap_AllowSpecial to test Entity Overlap (Allow Special)? If so, jump to Update_Entity_Slot_SnapToRoomFloor.
B2AD JP C,Update_Entity_Slot_SnapToRoomFloor
B2B0 CP $41 Is A equal to 41? If not, jump to Update_Entity_Slot_Branch.
B2B2 JR NZ,Update_Entity_Slot_Branch
B2B4 LD A,(IX+$08) Load A with the current entity's x-extent.
B2B7 CP $73 Is the current entity's x-extent less than 73? If so, jump to Update_Entity_Slot_AtColumn6B.
B2B9 JR C,Update_Entity_Slot_AtColumn6B
B2BB JR Update_Entity_Slot_Branch Jump to Update_Entity_Slot_Branch to continue the entity-slot update.
At column 6B, nudge the entity up and right before latching the rise path.
Update_Entity_Slot_AtColumn6B B2BD LD A,(IX+$07) Load A with the current entity's x-coordinate.
B2C0 CP $6B Is the current entity's x-coordinate equal to 6B? If not, jump to Update_Entity_Slot_SetRiseAndEvent.
B2C2 JR NZ,Update_Entity_Slot_SetRiseAndEvent
B2C4 DEC (IX+$05) Move this entity one character up.
B2C7 DEC (IX+$06)
B2CA INC (IX+$07) Move this entity one character right.
B2CD INC (IX+$08)
Set the risen flag, raise a room/script event, and maybe poke Bad Tempered Thing state 06.
Update_Entity_Slot_SetRiseAndEvent B2D0 SET 5,(IX+$02) Set bit 05 of the current entity's flags byte 2.
B2D4 SET 0,(HL) Set "room / script event raised" (bit 00 of GameEventFlags).
B2D6 LD A,(IX+$00) Fetch the current entity's type for the type test.
B2D9 CP $01 Is the current entity's entity type equal to 01? If not, jump to Update_Entity_Slot_ReturnSuccess.
B2DB JR NZ,Update_Entity_Slot_ReturnSuccess
B2DD LD A,$06 Load A with Bad Tempered Thing state 06 for BadTemperedThingState.
B2DF LD ($72C7),A Set the Bad Tempered Thing state (BadTemperedThingState).
Signal success and return from the entity-slot update.
Update_Entity_Slot_ReturnSuccess B2E2 SCF Signal success.
B2E3 RET Return.
Test overlap with the last-collided entity; type 04/06 spawns a task entity, else compare heights.
Update_Entity_Slot_Branch B2E4 LD IY,($72AA) Load IY with the last-collided entity pointer (Pointer_LastCollidedEntity).
B2E8 BIT 1,(IY+$02) Is bit 01 of the referenced entity's flags byte 2 set? If not, jump to Update_Entity_Slot_SnapToRoomFloor.
B2EC JP Z,Update_Entity_Slot_SnapToRoomFloor
B2EF LD A,(IX+$07) Load A with the current entity's x-coordinate.
B2F2 CP (IY+$07) Is this entity's x left of the referenced entity's x? If so, no horizontal overlap, so jump to Update_Entity_Slot_SnapToRoomFloor.
B2F5 JP C,Update_Entity_Slot_SnapToRoomFloor
B2F8 LD A,(IY+$08) Load A with the referenced entity's x-extent.
B2FB CP (IX+$08) Is the referenced entity's x-extent left of this entity's x-extent? If so, no horizontal overlap, so jump to Update_Entity_Slot_SnapToRoomFloor.
B2FE JP C,Update_Entity_Slot_SnapToRoomFloor
B301 LD A,(IY+$00) Load A with the referenced entity's entity type.
B304 CP $04 Is referenced entity's entity type equal to 04? If not, jump to Update_Entity_Slot_CompareHeights.
B306 JR NZ,Update_Entity_Slot_CompareHeights
B308 LD A,(IX+$00) Fetch the current entity's type for the type test.
B30B CP $06 Is the current entity's entity type equal to 06? If not, jump to Update_Entity_Slot_SnapToRoomFloor.
B30D JP NZ,Update_Entity_Slot_SnapToRoomFloor
B310 CALL Spawn_Task_Entity Call Spawn_Task_Entity to spawn Task Entity.
B313 LD (IX+$00),$00 Write 00 to the current entity's entity type.
B317 JP Update_Entity_Slot_ClearBit7AndSound Jump to Update_Entity_Slot_ClearBit7AndSound to finish the entity-slot update.
Require vertical overlap with the collided entity before dispatching by type.
Update_Entity_Slot_CompareHeights B31A LD A,(IX+$06) Load A with the current entity's y-extent.
B31D SUB (IX+$05) Subtract the current entity's y-coordinate from A.
B320 JR Z,Update_Entity_Slot_PlantOfferPath If the result was zero, jump to Update_Entity_Slot_PlantOfferPath.
B322 LD C,A Keep the current entity's y-extent in C for later.
B323 LD A,(IY+$06) Load A with the referenced entity's y-extent.
B326 SUB (IY+$05) Subtract the referenced entity's y-coordinate from A.
B329 CP C Is the referenced entity's y-extent less than C? If so, no vertical overlap, jump to Update_Entity_Slot_SnapToRoomFloor.
B32A JP C,Update_Entity_Slot_SnapToRoomFloor
Type-0F path: clear a type-0D offer, bump the plant state, and set interaction flags.
Update_Entity_Slot_PlantOfferPath B32D LD A,(IY+$00) Load A with the referenced entity's entity type.
B330 CP $0F Is referenced entity's entity type equal to 0F? If not, jump to Update_Entity_Slot_StoveCollision.
B332 JR NZ,Update_Entity_Slot_StoveCollision
B334 LD A,(IX+$00) Fetch the current entity's type for the type test.
B337 CP $0D Is the current entity's entity type equal to 0D? If not, jump to Update_Entity_Slot_SnapToRoomFloor.
B339 JP NZ,Update_Entity_Slot_SnapToRoomFloor
B33C LD (IX+$00),$00 Write 00 to the current entity's entity type.
B340 RES 1,(IY+$02) Reset bit 01 of the referenced entity's flags byte 2.
B344 INC (IY+$09) Increment the referenced entity's direction / state.
B347 LD (IY+$0C),$32 Write 32 to the referenced entity's extra state.
B34B LD A,($72B9) Load A with the entity interaction flag (EntityInteractionFlag).
B34E SET 1,A Set bit 01 of EntityInteractionFlag.
B350 SET 3,A Set bit 03 of EntityInteractionFlag.
B352 LD ($72B9),A Set the entity interaction flag (EntityInteractionFlag).
B355 JR Update_Entity_Slot_ClearBit7AndSound Jump to Update_Entity_Slot_ClearBit7AndSound to finish the entity-slot update.
Stove path: when type 09 meets type 14, update the stove and mark the slot complete.
Update_Entity_Slot_StoveCollision B357 CP $14 Is the referenced entity's entity type equal to 14? If not, jump to Update_Entity_Slot_YellowCupCollision.
B359 JR NZ,Update_Entity_Slot_YellowCupCollision
B35B LD A,(IX+$00) Fetch the current entity's type for the type test.
B35E CP $09 Is the current entity's entity type equal to 09? If not, jump to Update_Entity_Slot_YellowCupCollision.
B360 JR NZ,Update_Entity_Slot_YellowCupCollision
B362 CALL Update_Stove Call Update_Stove to update Stove.
B365 JR Update_Entity_Slot_MarkComplete Jump to Update_Entity_Slot_MarkComplete to mark the entity slot complete.
Gate past type 05 / reject type 09 before testing type-08 collisions.
Update_Entity_Slot_YellowCupCollision B367 CP $05 Is the current entity's entity type equal to 05? If so, jump to Update_Entity_Slot_BasketCollision.
B369 JR Z,Update_Entity_Slot_BasketCollision
B36B LD A,(IX+$00) Fetch the current entity's type for the type test.
B36E CP $09 Is the current entity's entity type equal to 09? If so, jump to Update_Entity_Slot_SnapToRoomFloor.
B370 JR Z,Update_Entity_Slot_SnapToRoomFloor
B372 LD A,(IY+$00) Load A with the referenced entity's entity type.
Type-08/0B collision path: check entity collision then mark the slot complete.
Update_Entity_Slot_BasketCollision B375 CP $08 Is referenced entity's entity type equal to 08? If not, jump to Update_Entity_Slot_CrusherCollision.
B377 JR NZ,Update_Entity_Slot_CrusherCollision
B379 LD A,(IX+$00) Fetch the current entity's type for the type test.
B37C CP $0B Is the current entity's entity type equal to 0B? If not, jump to Update_Entity_Slot_CrusherCollision.
B37E JR NZ,Update_Entity_Slot_CrusherCollision
B380 CALL Check_Entity_Collision Call Check_Entity_Collision to check Entity Collision.
B383 JR Update_Entity_Slot_MarkComplete Jump to Update_Entity_Slot_MarkComplete to mark the entity slot complete.
Crusher path: type 16 meeting type 0E updates the crusher and completes the slot.
Update_Entity_Slot_CrusherCollision B385 CP $16 Is the current entity's entity type equal to 16? If not, jump to Update_Entity_Slot_BadTemperedThing.
B387 JR NZ,Update_Entity_Slot_BadTemperedThing
B389 LD A,(IX+$00) Fetch the current entity's type for the type test.
B38C CP $0E Is the current entity's entity type equal to 0E? If not, jump to Update_Entity_Slot_SnapToRoomFloor.
B38E JP NZ,Update_Entity_Slot_SnapToRoomFloor
B391 CALL Update_Crusher Call Update_Crusher to update Crusher.
B394 JR Update_Entity_Slot_MarkComplete Jump to Update_Entity_Slot_MarkComplete to mark the entity slot complete.
If this slot is type 01, set Bad Tempered Thing state 03 before completing.
Update_Entity_Slot_BadTemperedThing B396 LD A,(IX+$00) Fetch the current entity's type for the type test.
B399 CP $01 Is the current entity's entity type equal to 01? If not, jump to Update_Entity_Slot_MarkComplete.
B39B JR NZ,Update_Entity_Slot_MarkComplete
B39D LD A,$03 Load A with Bad Tempered Thing state 03 for BadTemperedThingState.
B39F LD ($72C7),A Set the Bad Tempered Thing state (BadTemperedThingState).
Mark the entity slot complete: set risen/extra-state bits and type bit 07.
Update_Entity_Slot_MarkComplete B3A2 SET 5,(IX+$01) Set bit 05 of the current entity's flags byte 1.
B3A6 PUSH IY Stash IY on the stack.
B3A8 POP BC Restore BC from the stack.
B3A9 LD (IX+$0C),C Store C in the current entity's extra state.
B3AC LD (IX+$0D),B Store B in the current entity's extra state.
B3AF SET 7,(IX+$00) Set bit 07 of the current entity's entity type.
Clear entity-flags bit 07, queue the entity-slot sound, and return success.
Update_Entity_Slot_ClearBit7AndSound B3B3 RES 7,(IX+$01) Reset bit 07 of the current entity's flags byte 1.
B3B7 LD A,$84 Load A with sound index 84.
B3B9 CALL Queue_Sound Call Queue_Sound to queue a sound effect.
B3BC SCF Signal success.
B3BD RET Return.
Snap the entity to the room-floor y band, restore helper layout when type 06, else fall through.
Update_Entity_Slot_SnapToRoomFloor B3BE LD A,(IX+$04) Load A with the current entity's room index.
B3C1 ADD A,$22 Add 22 to A (adjust an entity coordinate).
B3C3 LD B,A Keep the current entity's room index in B for later.
B3C4 CP (IX+$06) Does room+22 match this entity's y-extent? If not, jump to Update_Entity_Slot_RaiseYAndEvent.
B3C7 JR NC,Update_Entity_Slot_RaiseYAndEvent
B3C9 LD A,(IX+$06) Load A with the current entity's y-extent.
B3CC SUB (IX+$05) Subtract the current entity's y-coordinate from A.
B3CF LD C,A Keep the current entity's y-extent in C for later.
B3D0 LD (IX+$06),B Store B in the current entity's y-extent.
B3D3 LD A,B Copy the loop counter from B into A.
B3D4 SUB C Subtract C from the current entity's y-extent.
B3D5 LD (IX+$05),A Set the current entity's y-coordinate.
B3D8 RES 7,(IX+$01) Reset bit 07 of the current entity's flags byte 1.
B3DC LD A,(IX+$00) Fetch the current entity's type for the type test.
B3DF CP $06 Is the current entity's entity type equal to 06? If not, jump to Update_Entity_Slot_MaybeSetBTT.
B3E1 JR NZ,Update_Entity_Slot_MaybeSetBTT
B3E3 LD A,($72B5) Load A with the task-two flags (TaskTwoFlags).
B3E6 SET 3,A Set "helper entity needs its layout restoring" (bit 03 of TaskTwoFlags).
B3E8 LD ($72B5),A Set the task-two flags (TaskTwoFlags).
B3EB LD BC,$9DC0 Load BC with helper graphic layout address GraphicLayout_WhiteBurst.
B3EE LD ($8FE1),BC Write the layout address into the spawned helper's layout field (8FE1).
B3F2 JR Update_Entity_Slot_QueueLandSound Jump to Update_Entity_Slot_QueueLandSound to queue the entity-slot wait sound.
When task-two flags are 01, set Bad Tempered Thing state 02.
Update_Entity_Slot_MaybeSetBTT B3F4 CP $01 Is task-two flags equal to 01? If not, jump to Update_Entity_Slot_MaybeTaskThreeBit.
B3F6 JR NZ,Update_Entity_Slot_MaybeTaskThreeBit
B3F8 LD A,$02 Load A with Bad Tempered Thing state 02 for BadTemperedThingState.
B3FA LD ($72C7),A Set the Bad Tempered Thing state (BadTemperedThingState).
Maybe set SlimyLoose on the task-three flags before queuing the land sound.
Update_Entity_Slot_MaybeTaskThreeBit B3FD CP $09 Is 02 equal to 09? If not, jump to Update_Entity_Slot_QueueLandSound.
B3FF JR NZ,Update_Entity_Slot_QueueLandSound
B401 LD A,($72B6) Load A with the task-three flags (TaskThreeFlags).
B404 SET 2,A Set SlimyLoose (bit 02 of TaskThreeFlags. D907 skips that line while set).
B406 LD ($72B6),A Set the task-three flags (TaskThreeFlags).
Update_Entity_Slot_QueueLandSound B409 LD A,$87 Load A with sound index 87.
B40B CALL Queue_Sound Call Queue_Sound to queue a sound effect.
B40E SCF Signal success.
B40F RET Return.
Land-step: drop the entity one row and raise a room/script event on GameEventFlags.
Update_Entity_Slot_RaiseYAndEvent B410 INC (IX+$05) Move this entity one character down.
B413 INC (IX+$06)
B416 SET 0,(HL) Set "room / script event raised" (bit 00 of GameEventFlags).
B418 XOR A Clear A as a false / no-match result.
B419 RET Return.
Prev: B258 Up: Map Next: B41A