![]() |
Routines |
| Prev: 60920 | Up: Map | Next: 61202 |
|
Used by the routine at Open_TrapDoor.
Scan complex entity state starting at StateData_Boney. Returns with the carry flag set when the trap door should open (an entity of type 50 is present and nearby entities have been adjusted). Called by Open_TrapDoor.
|
||||||||
| Check_EntitiesNearTrapDoor | 60976 | LD IX,36585 | Point IX at Boney's complex entity state (StateData_Boney). | |||||
| 60980 | LD DE,14 | Load DE with 0014. | ||||||
| 60983 | LD HL,29363 | Point HL at the game event flags (GameEventFlags). | ||||||
|
Scan complex entities for ones standing in the trap door X band of rooms 2–4.
|
||||||||
| CheckNearTrapDoor_Scan | 60986 | LD A,(IX+0) | Fetch the current entity's type for the type test. | |||||
| 60989 | CP 50 | Is A equal to 50? If so, jump to CheckNearTrapDoor_FoundSceneryBlock. | ||||||
| 60991 | JP Z,CheckNearTrapDoor_FoundSceneryBlock | |||||||
| 60994 | OR A | Is A zero? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| 60995 | JR Z,CheckNearTrapDoor_NextEntity | |||||||
| 60997 | CP 33 | Is A less than 33? If not, jump to CheckNearTrapDoor_NextEntity. | ||||||
| 60999 | JR NC,CheckNearTrapDoor_NextEntity | |||||||
| 61001 | LD A,(IX+4) | Load A with the current entity's room index. | ||||||
| 61004 | CP 5 | Is A equal to 5? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| 61006 | JR Z,CheckNearTrapDoor_NextEntity | |||||||
| 61008 | CP 2 | Is A less than 2? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| 61010 | JR C,CheckNearTrapDoor_NextEntity | |||||||
| 61012 | BIT 7,(IX+1) | Is bit 7 of the current entity's flags byte 1 set? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| 61016 | JR NZ,CheckNearTrapDoor_NextEntity | |||||||
| 61018 | LD A,(IX+8) | Load A with the current entity's x-extent. | ||||||
| 61021 | CP 108 | Is A less than 108? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| 61023 | JR C,CheckNearTrapDoor_NextEntity | |||||||
| 61025 | LD A,(IX+7) | Load A with the current entity's x-coordinate. | ||||||
| 61028 | CP 116 | Is A less than 116? If not, jump to CheckNearTrapDoor_NextEntity. | ||||||
| 61030 | JR NC,CheckNearTrapDoor_NextEntity | |||||||
| 61032 | CP 114 | Is A less than 114? If so, jump to CheckNearTrapDoor_CheckEntityType. | ||||||
| 61034 | JR C,CheckNearTrapDoor_CheckEntityType | |||||||
| 61036 | JR NZ,CheckNearTrapDoor_SetBit7 | Jump to CheckNearTrapDoor_SetBit7 to continue if the comparison did not match. | ||||||
| 61038 | SET 6,(IX+3) | Set bit 6 of the current entity's flags byte 3. | ||||||
| 61042 | JR CheckNearTrapDoor_MarkEntity | Jump to CheckNearTrapDoor_MarkEntity to handle the trap door. | ||||||
|
Flag this near-trap entity with bit 7 (right-of-band side).
|
||||||||
| CheckNearTrapDoor_SetBit7 | 61044 | SET 7,(IX+3) | Set bit 7 of the current entity's flags byte 3. | |||||
| 61048 | JR CheckNearTrapDoor_MarkEntity | Jump to CheckNearTrapDoor_MarkEntity to handle the trap door. | ||||||
|
For X in the inner band: poke Bad Tempered Thing state for Berk, else just mark the entity.
|
||||||||
| CheckNearTrapDoor_CheckEntityType | 61050 | LD A,(IX+0) | Fetch the current entity's type for the type test. | |||||
| 61053 | CP 20 | Is A less than 20? If not, jump to CheckNearTrapDoor_ClearPass. | ||||||
| 61055 | JR NC,CheckNearTrapDoor_ClearPass | |||||||
| 61057 | CP 1 | Is A equal to 1? If not, jump to CheckNearTrapDoor_MarkEntity. | ||||||
| 61059 | JR NZ,CheckNearTrapDoor_MarkEntity | |||||||
| 61061 | LD A,7 | Load A with 7. | ||||||
| 61063 | LD (29383),A | Set the Bad Tempered Thing state (BadTemperedThingState). | ||||||
|
Set bit 0 on the near-trap entity, then advance.
|
||||||||
| CheckNearTrapDoor_MarkEntity | 61066 | SET 0,(IX+2) | Set bit 0 of the current entity's flags byte 2. | |||||
|
Advance to the next complex entity in the near-trap scan.
|
||||||||
| CheckNearTrapDoor_NextEntity | 61070 | ADD IX,DE | IX+=DE. | |||||
| 61072 | JR CheckNearTrapDoor_Scan | Jump to CheckNearTrapDoor_Scan to handle the trap door. | ||||||
|
Restart from StateData_Boney to clear near-trap marks when no type-50 was found.
|
||||||||
| CheckNearTrapDoor_ClearPass | 61074 | LD IX,36585 | Point IX at Boney's complex entity state (StateData_Boney). | |||||
|
Clear pass: wipe bit 0/6/7 marks until type 50, then refuse the open.
|
||||||||
| CheckNearTrapDoor_ClearScan | 61078 | LD A,(IX+0) | Fetch the current entity's type for the type test. | |||||
| 61081 | CP 50 | Is A equal to 50? If so, jump to CheckNearTrapDoor_NoOpen. | ||||||
| 61083 | JR Z,CheckNearTrapDoor_NoOpen | |||||||
| 61085 | BIT 0,(IX+2) | Is bit 0 of the current entity's flags byte 2 set? If not, jump to CheckNearTrapDoor_ClearNext. | ||||||
| 61089 | JR Z,CheckNearTrapDoor_ClearNext | |||||||
| 61091 | RES 0,(IX+2) | Reset bit 0 of the current entity's flags byte 2. | ||||||
| 61095 | RES 6,(IX+3) | Reset bit 6 of the current entity's flags byte 3. | ||||||
| 61099 | RES 7,(IX+3) | Reset bit 7 of the current entity's flags byte 3. | ||||||
| 61103 | CP 1 | Is A equal to 1? If not, jump to CheckNearTrapDoor_ClearNext. | ||||||
| 61105 | JR NZ,CheckNearTrapDoor_ClearNext | |||||||
| 61107 | LD A,5 | Load A with sound index 5. | ||||||
| 61109 | LD (29383),A | Set the Bad Tempered Thing state (BadTemperedThingState). | ||||||
|
Advance during the clear pass.
|
||||||||
| CheckNearTrapDoor_ClearNext | 61112 | ADD IX,DE | IX+=DE. | |||||
| 61114 | JR CheckNearTrapDoor_ClearScan | Jump to CheckNearTrapDoor_ClearScan to handle the trap door. | ||||||
|
No open: clear the falling-entity latch (bit 2 of GameEventFlags) and return carry clear.
|
||||||||
| CheckNearTrapDoor_NoOpen | 61116 | RES 2,(HL) | Clear the falling-entity latch (bit 2 of GameEventFlags). | |||||
| 61118 | RET | Return. | ||||||
|
Type 50 found: restart from StateData_Boney to nudge marked entities before opening.
|
||||||||
| CheckNearTrapDoor_FoundSceneryBlock | 61119 | LD IX,36585 | Point IX at Boney's complex entity state (StateData_Boney). | |||||
|
Adjust pass: shrink or bump entities that were marked near the trap door.
|
||||||||
| CheckNearTrapDoor_AdjustScan | 61123 | LD A,(IX+0) | Fetch the current entity's type for the type test. | |||||
| 61126 | CP 50 | Is A equal to 50? If so, jump to CheckNearTrapDoor_ShouldOpen. | ||||||
| 61128 | JR Z,CheckNearTrapDoor_ShouldOpen | |||||||
| 61130 | BIT 0,(IX+2) | Is bit 0 of the current entity's flags byte 2 set? If not, jump to CheckNearTrapDoor_AdjustNext. | ||||||
| 61134 | JR Z,CheckNearTrapDoor_AdjustNext | |||||||
| 61136 | LD A,(IX+3) | Load A with the current entity's flags byte 3. | ||||||
| 61139 | LD C,A | Keep the flags byte in C. | ||||||
| 61140 | AND %00111111 | A&=63. | ||||||
| 61142 | LD (IX+3),A | Set the current entity's flags byte 3. | ||||||
| 61145 | LD A,C | Copy the saved count/flag from C into A. | ||||||
| 61146 | AND %11000000 | A&=192. | ||||||
| 61148 | JR Z,CheckNearTrapDoor_ShrinkBounds | Jump to CheckNearTrapDoor_ShrinkBounds to continue if the comparison matched. | ||||||
| 61150 | RES 0,(IX+2) | Reset bit 0 of the current entity's flags byte 2. | ||||||
| 61154 | BIT 6,A | Is bit 6 of A set? If not, jump to CheckNearTrapDoor_BumpCoordinates. | ||||||
| 61156 | JR Z,CheckNearTrapDoor_BumpCoordinates | |||||||
| 61158 | INC (IX+7) | Move this entity one character right. | ||||||
| 61161 | INC (IX+8) | |||||||
|
Bump a marked entity one character right away from the trap door band.
|
||||||||
| CheckNearTrapDoor_BumpCoordinates | 61164 | INC (IX+7) | Bump this entity one character right. | |||||
| 61167 | INC (IX+8) | |||||||
| 61170 | JR CheckNearTrapDoor_AdjustNext | Jump to CheckNearTrapDoor_AdjustNext to handle the trap door. | ||||||
|
Randomly shrink a marked entity's Y/Y-extent by 4–7 characters.
|
||||||||
| CheckNearTrapDoor_ShrinkBounds | 61172 | LD A,4 | Load A with 4. | |||||
| 61174 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| 61177 | ADD A,4 | A+=4. | ||||||
| 61179 | LD C,A | Keep A in C for the next calculation. | ||||||
| 61180 | LD A,(IX+5) | Load A with the current entity's y-coordinate. | ||||||
| 61183 | SUB C | A-=C. | ||||||
| 61184 | LD (IX+5),A | Set the current entity's y-coordinate. | ||||||
| 61187 | LD A,(IX+6) | Load A with the current entity's y-extent. | ||||||
| 61190 | SUB C | A-=C. | ||||||
| 61191 | LD (IX+6),A | Set the current entity's y-extent. | ||||||
|
Advance to the next entity in the adjust pass.
|
||||||||
| CheckNearTrapDoor_AdjustNext | 61194 | ADD IX,DE | IX+=DE. | |||||
| 61196 | JR CheckNearTrapDoor_AdjustScan | Jump to CheckNearTrapDoor_AdjustScan to handle the trap door. | ||||||
|
Signal that the trap door should open (set bit 2 of GameEventFlags, carry set).
|
||||||||
| CheckNearTrapDoor_ShouldOpen | 61198 | SET 2,(HL) | Set the falling-entity latch (bit 2 of GameEventFlags). | |||||
| 61200 | SCF | Signal success. | ||||||
| 61201 | RET | Return. | ||||||
| Prev: 60920 | Up: Map | Next: 61202 |