Prev: 45656 Up: Map Next: 46106
45738: 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 45738 CALL Test_EntityOverlap_AllowSpecial Call Test_EntityOverlap_AllowSpecial to test Entity Overlap (Allow Special)? If so, jump to Update_Entity_Slot_SnapToRoomFloor.
45741 JP C,Update_Entity_Slot_SnapToRoomFloor
45744 CP 65 Is A equal to 65? If not, jump to Update_Entity_Slot_Branch.
45746 JR NZ,Update_Entity_Slot_Branch
45748 LD A,(IX+8) Load A with the current entity's x-extent.
45751 CP 115 Is the current entity's x-extent less than 115? If so, jump to Update_Entity_Slot_AtColumn6B.
45753 JR C,Update_Entity_Slot_AtColumn6B
45755 JR Update_Entity_Slot_Branch Jump to Update_Entity_Slot_Branch to continue the entity-slot update.
At column 107, nudge the entity up and right before latching the rise path.
Update_Entity_Slot_AtColumn6B 45757 LD A,(IX+7) Load A with the current entity's x-coordinate.
45760 CP 107 Is the current entity's x-coordinate equal to 107? If not, jump to Update_Entity_Slot_SetRiseAndEvent.
45762 JR NZ,Update_Entity_Slot_SetRiseAndEvent
45764 DEC (IX+5) Move this entity one character up.
45767 DEC (IX+6)
45770 INC (IX+7) Move this entity one character right.
45773 INC (IX+8)
Set the risen flag, raise a room/script event, and maybe poke Bad Tempered Thing state 6.
Update_Entity_Slot_SetRiseAndEvent 45776 SET 5,(IX+2) Set bit 5 of the current entity's flags byte 2.
45780 SET 0,(HL) Set "room / script event raised" (bit 0 of GameEventFlags).
45782 LD A,(IX+0) Fetch the current entity's type for the type test.
45785 CP 1 Is the current entity's entity type equal to 1? If not, jump to Update_Entity_Slot_ReturnSuccess.
45787 JR NZ,Update_Entity_Slot_ReturnSuccess
45789 LD A,6 Load A with Bad Tempered Thing state 6 for BadTemperedThingState.
45791 LD (29383),A Set the Bad Tempered Thing state (BadTemperedThingState).
Signal success and return from the entity-slot update.
Update_Entity_Slot_ReturnSuccess 45794 SCF Signal success.
45795 RET Return.
Test overlap with the last-collided entity; type 4/6 spawns a task entity, else compare heights.
Update_Entity_Slot_Branch 45796 LD IY,(29354) Load IY with the last-collided entity pointer (Pointer_LastCollidedEntity).
45800 BIT 1,(IY+2) Is bit 1 of the referenced entity's flags byte 2 set? If not, jump to Update_Entity_Slot_SnapToRoomFloor.
45804 JP Z,Update_Entity_Slot_SnapToRoomFloor
45807 LD A,(IX+7) Load A with the current entity's x-coordinate.
45810 CP (IY+7) Is this entity's x left of the referenced entity's x? If so, no horizontal overlap, so jump to Update_Entity_Slot_SnapToRoomFloor.
45813 JP C,Update_Entity_Slot_SnapToRoomFloor
45816 LD A,(IY+8) Load A with the referenced entity's x-extent.
45819 CP (IX+8) 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.
45822 JP C,Update_Entity_Slot_SnapToRoomFloor
45825 LD A,(IY+0) Load A with the referenced entity's entity type.
45828 CP 4 Is referenced entity's entity type equal to 4? If not, jump to Update_Entity_Slot_CompareHeights.
45830 JR NZ,Update_Entity_Slot_CompareHeights
45832 LD A,(IX+0) Fetch the current entity's type for the type test.
45835 CP 6 Is the current entity's entity type equal to 6? If not, jump to Update_Entity_Slot_SnapToRoomFloor.
45837 JP NZ,Update_Entity_Slot_SnapToRoomFloor
45840 CALL Spawn_Task_Entity Call Spawn_Task_Entity to spawn Task Entity.
45843 LD (IX+0),0 Write 0 to the current entity's entity type.
45847 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 45850 LD A,(IX+6) Load A with the current entity's y-extent.
45853 SUB (IX+5) Subtract the current entity's y-coordinate from A.
45856 JR Z,Update_Entity_Slot_PlantOfferPath If the result was zero, jump to Update_Entity_Slot_PlantOfferPath.
45858 LD C,A Keep the current entity's y-extent in C for later.
45859 LD A,(IY+6) Load A with the referenced entity's y-extent.
45862 SUB (IY+5) Subtract the referenced entity's y-coordinate from A.
45865 CP C Is the referenced entity's y-extent less than C? If so, no vertical overlap, jump to Update_Entity_Slot_SnapToRoomFloor.
45866 JP C,Update_Entity_Slot_SnapToRoomFloor
Type-15 path: clear a type-13 offer, bump the plant state, and set interaction flags.
Update_Entity_Slot_PlantOfferPath 45869 LD A,(IY+0) Load A with the referenced entity's entity type.
45872 CP 15 Is referenced entity's entity type equal to 15? If not, jump to Update_Entity_Slot_StoveCollision.
45874 JR NZ,Update_Entity_Slot_StoveCollision
45876 LD A,(IX+0) Fetch the current entity's type for the type test.
45879 CP 13 Is the current entity's entity type equal to 13? If not, jump to Update_Entity_Slot_SnapToRoomFloor.
45881 JP NZ,Update_Entity_Slot_SnapToRoomFloor
45884 LD (IX+0),0 Write 0 to the current entity's entity type.
45888 RES 1,(IY+2) Reset bit 1 of the referenced entity's flags byte 2.
45892 INC (IY+9) Increment the referenced entity's direction / state.
45895 LD (IY+12),50 Write 50 to the referenced entity's extra state.
45899 LD A,(29369) Load A with the entity interaction flag (EntityInteractionFlag).
45902 SET 1,A Set bit 1 of EntityInteractionFlag.
45904 SET 3,A Set bit 3 of EntityInteractionFlag.
45906 LD (29369),A Set the entity interaction flag (EntityInteractionFlag).
45909 JR Update_Entity_Slot_ClearBit7AndSound Jump to Update_Entity_Slot_ClearBit7AndSound to finish the entity-slot update.
Stove path: when type 9 meets type 20, update the stove and mark the slot complete.
Update_Entity_Slot_StoveCollision 45911 CP 20 Is the referenced entity's entity type equal to 20? If not, jump to Update_Entity_Slot_YellowCupCollision.
45913 JR NZ,Update_Entity_Slot_YellowCupCollision
45915 LD A,(IX+0) Fetch the current entity's type for the type test.
45918 CP 9 Is the current entity's entity type equal to 9? If not, jump to Update_Entity_Slot_YellowCupCollision.
45920 JR NZ,Update_Entity_Slot_YellowCupCollision
45922 CALL Update_Stove Call Update_Stove to update Stove.
45925 JR Update_Entity_Slot_MarkComplete Jump to Update_Entity_Slot_MarkComplete to mark the entity slot complete.
Gate past type 5 / reject type 9 before testing type-8 collisions.
Update_Entity_Slot_YellowCupCollision 45927 CP 5 Is the current entity's entity type equal to 5? If so, jump to Update_Entity_Slot_BasketCollision.
45929 JR Z,Update_Entity_Slot_BasketCollision
45931 LD A,(IX+0) Fetch the current entity's type for the type test.
45934 CP 9 Is the current entity's entity type equal to 9? If so, jump to Update_Entity_Slot_SnapToRoomFloor.
45936 JR Z,Update_Entity_Slot_SnapToRoomFloor
45938 LD A,(IY+0) Load A with the referenced entity's entity type.
Type-8/11 collision path: check entity collision then mark the slot complete.
Update_Entity_Slot_BasketCollision 45941 CP 8 Is referenced entity's entity type equal to 8? If not, jump to Update_Entity_Slot_CrusherCollision.
45943 JR NZ,Update_Entity_Slot_CrusherCollision
45945 LD A,(IX+0) Fetch the current entity's type for the type test.
45948 CP 11 Is the current entity's entity type equal to 11? If not, jump to Update_Entity_Slot_CrusherCollision.
45950 JR NZ,Update_Entity_Slot_CrusherCollision
45952 CALL Check_Entity_Collision Call Check_Entity_Collision to check Entity Collision.
45955 JR Update_Entity_Slot_MarkComplete Jump to Update_Entity_Slot_MarkComplete to mark the entity slot complete.
Crusher path: type 22 meeting type 14 updates the crusher and completes the slot.
Update_Entity_Slot_CrusherCollision 45957 CP 22 Is the current entity's entity type equal to 22? If not, jump to Update_Entity_Slot_BadTemperedThing.
45959 JR NZ,Update_Entity_Slot_BadTemperedThing
45961 LD A,(IX+0) Fetch the current entity's type for the type test.
45964 CP 14 Is the current entity's entity type equal to 14? If not, jump to Update_Entity_Slot_SnapToRoomFloor.
45966 JP NZ,Update_Entity_Slot_SnapToRoomFloor
45969 CALL Update_Crusher Call Update_Crusher to update Crusher.
45972 JR Update_Entity_Slot_MarkComplete Jump to Update_Entity_Slot_MarkComplete to mark the entity slot complete.
If this slot is type 1, set Bad Tempered Thing state 3 before completing.
Update_Entity_Slot_BadTemperedThing 45974 LD A,(IX+0) Fetch the current entity's type for the type test.
45977 CP 1 Is the current entity's entity type equal to 1? If not, jump to Update_Entity_Slot_MarkComplete.
45979 JR NZ,Update_Entity_Slot_MarkComplete
45981 LD A,3 Load A with Bad Tempered Thing state 3 for BadTemperedThingState.
45983 LD (29383),A Set the Bad Tempered Thing state (BadTemperedThingState).
Mark the entity slot complete: set risen/extra-state bits and type bit 7.
Update_Entity_Slot_MarkComplete 45986 SET 5,(IX+1) Set bit 5 of the current entity's flags byte 1.
45990 PUSH IY Stash IY on the stack.
45992 POP BC Restore BC from the stack.
45993 LD (IX+12),C Store C in the current entity's extra state.
45996 LD (IX+13),B Store B in the current entity's extra state.
45999 SET 7,(IX+0) Set bit 7 of the current entity's entity type.
Clear entity-flags bit 7, queue the entity-slot sound, and return success.
Update_Entity_Slot_ClearBit7AndSound 46003 RES 7,(IX+1) Reset bit 7 of the current entity's flags byte 1.
46007 LD A,132 Load A with sound index 132.
46009 CALL Queue_Sound Call Queue_Sound to queue a sound effect.
46012 SCF Signal success.
46013 RET Return.
Snap the entity to the room-floor y band, restore helper layout when type 6, else fall through.
Update_Entity_Slot_SnapToRoomFloor 46014 LD A,(IX+4) Load A with the current entity's room index.
46017 ADD A,34 Add 34 to A (adjust an entity coordinate).
46019 LD B,A Keep the current entity's room index in B for later.
46020 CP (IX+6) Does room+34 match this entity's y-extent? If not, jump to Update_Entity_Slot_RaiseYAndEvent.
46023 JR NC,Update_Entity_Slot_RaiseYAndEvent
46025 LD A,(IX+6) Load A with the current entity's y-extent.
46028 SUB (IX+5) Subtract the current entity's y-coordinate from A.
46031 LD C,A Keep the current entity's y-extent in C for later.
46032 LD (IX+6),B Store B in the current entity's y-extent.
46035 LD A,B Copy the loop counter from B into A.
46036 SUB C Subtract C from the current entity's y-extent.
46037 LD (IX+5),A Set the current entity's y-coordinate.
46040 RES 7,(IX+1) Reset bit 7 of the current entity's flags byte 1.
46044 LD A,(IX+0) Fetch the current entity's type for the type test.
46047 CP 6 Is the current entity's entity type equal to 6? If not, jump to Update_Entity_Slot_MaybeSetBTT.
46049 JR NZ,Update_Entity_Slot_MaybeSetBTT
46051 LD A,(29365) Load A with the task-two flags (TaskTwoFlags).
46054 SET 3,A Set "helper entity needs its layout restoring" (bit 3 of TaskTwoFlags).
46056 LD (29365),A Set the task-two flags (TaskTwoFlags).
46059 LD BC,40384 Load BC with helper graphic layout address GraphicLayout_WhiteBurst.
46062 LD (36833),BC Write the layout address into the spawned helper's layout field (36833).
46066 JR Update_Entity_Slot_QueueLandSound Jump to Update_Entity_Slot_QueueLandSound to queue the entity-slot wait sound.
When task-two flags are 1, set Bad Tempered Thing state 2.
Update_Entity_Slot_MaybeSetBTT 46068 CP 1 Is task-two flags equal to 1? If not, jump to Update_Entity_Slot_MaybeTaskThreeBit.
46070 JR NZ,Update_Entity_Slot_MaybeTaskThreeBit
46072 LD A,2 Load A with Bad Tempered Thing state 2 for BadTemperedThingState.
46074 LD (29383),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 46077 CP 9 Is 2 equal to 9? If not, jump to Update_Entity_Slot_QueueLandSound.
46079 JR NZ,Update_Entity_Slot_QueueLandSound
46081 LD A,(29366) Load A with the task-three flags (TaskThreeFlags).
46084 SET 2,A Set SlimyLoose (bit 2 of TaskThreeFlags. 55559 skips that line while set).
46086 LD (29366),A Set the task-three flags (TaskThreeFlags).
Update_Entity_Slot_QueueLandSound 46089 LD A,135 Load A with sound index 135.
46091 CALL Queue_Sound Call Queue_Sound to queue a sound effect.
46094 SCF Signal success.
46095 RET Return.
Land-step: drop the entity one row and raise a room/script event on GameEventFlags.
Update_Entity_Slot_RaiseYAndEvent 46096 INC (IX+5) Move this entity one character down.
46099 INC (IX+6)
46102 SET 0,(HL) Set "room / script event raised" (bit 0 of GameEventFlags).
46104 XOR A Clear A as a false / no-match result.
46105 RET Return.
Prev: 45656 Up: Map Next: 46106