![]() |
Routines |
| Prev: EDF8 | Up: Map | Next: EF12 |
|
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 32 is present and nearby entities have been adjusted). Called by Open_TrapDoor.
|
||||||||
| Check_EntitiesNearTrapDoor | EE30 | LD IX,$8EE9 | Point IX at Boney's complex entity state (StateData_Boney). | |||||
| EE34 | LD DE,$000E | Load DE with 000E. | ||||||
| EE37 | LD HL,$72B3 | Point HL at the game event flags (GameEventFlags). | ||||||
|
Scan complex entities for ones standing in the trap door X band of rooms 02–04.
|
||||||||
| CheckNearTrapDoor_Scan | EE3A | LD A,(IX+$00) | Fetch the current entity's type for the type test. | |||||
| EE3D | CP $32 | Is A equal to 32? If so, jump to CheckNearTrapDoor_FoundSceneryBlock. | ||||||
| EE3F | JP Z,CheckNearTrapDoor_FoundSceneryBlock | |||||||
| EE42 | OR A | Is A zero? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| EE43 | JR Z,CheckNearTrapDoor_NextEntity | |||||||
| EE45 | CP $21 | Is A less than 21? If not, jump to CheckNearTrapDoor_NextEntity. | ||||||
| EE47 | JR NC,CheckNearTrapDoor_NextEntity | |||||||
| EE49 | LD A,(IX+$04) | Load A with the current entity's room index. | ||||||
| EE4C | CP $05 | Is A equal to 05? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| EE4E | JR Z,CheckNearTrapDoor_NextEntity | |||||||
| EE50 | CP $02 | Is A less than 02? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| EE52 | JR C,CheckNearTrapDoor_NextEntity | |||||||
| EE54 | BIT 7,(IX+$01) | Is bit 07 of the current entity's flags byte 1 set? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| EE58 | JR NZ,CheckNearTrapDoor_NextEntity | |||||||
| EE5A | LD A,(IX+$08) | Load A with the current entity's x-extent. | ||||||
| EE5D | CP $6C | Is A less than 6C? If so, jump to CheckNearTrapDoor_NextEntity. | ||||||
| EE5F | JR C,CheckNearTrapDoor_NextEntity | |||||||
| EE61 | LD A,(IX+$07) | Load A with the current entity's x-coordinate. | ||||||
| EE64 | CP $74 | Is A less than 74? If not, jump to CheckNearTrapDoor_NextEntity. | ||||||
| EE66 | JR NC,CheckNearTrapDoor_NextEntity | |||||||
| EE68 | CP $72 | Is A less than 72? If so, jump to CheckNearTrapDoor_CheckEntityType. | ||||||
| EE6A | JR C,CheckNearTrapDoor_CheckEntityType | |||||||
| EE6C | JR NZ,CheckNearTrapDoor_SetBit7 | Jump to CheckNearTrapDoor_SetBit7 to continue if the comparison did not match. | ||||||
| EE6E | SET 6,(IX+$03) | Set bit 06 of the current entity's flags byte 3. | ||||||
| EE72 | JR CheckNearTrapDoor_MarkEntity | Jump to CheckNearTrapDoor_MarkEntity to handle the trap door. | ||||||
|
Flag this near-trap entity with bit 07 (right-of-band side).
|
||||||||
| CheckNearTrapDoor_SetBit7 | EE74 | SET 7,(IX+$03) | Set bit 07 of the current entity's flags byte 3. | |||||
| EE78 | 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 | EE7A | LD A,(IX+$00) | Fetch the current entity's type for the type test. | |||||
| EE7D | CP $14 | Is A less than 14? If not, jump to CheckNearTrapDoor_ClearPass. | ||||||
| EE7F | JR NC,CheckNearTrapDoor_ClearPass | |||||||
| EE81 | CP $01 | Is A equal to 01? If not, jump to CheckNearTrapDoor_MarkEntity. | ||||||
| EE83 | JR NZ,CheckNearTrapDoor_MarkEntity | |||||||
| EE85 | LD A,$07 | Load A with 07. | ||||||
| EE87 | LD ($72C7),A | Set the Bad Tempered Thing state (BadTemperedThingState). | ||||||
|
Set bit 00 on the near-trap entity, then advance.
|
||||||||
| CheckNearTrapDoor_MarkEntity | EE8A | SET 0,(IX+$02) | Set bit 00 of the current entity's flags byte 2. | |||||
|
Advance to the next complex entity in the near-trap scan.
|
||||||||
| CheckNearTrapDoor_NextEntity | EE8E | ADD IX,DE | IX+=DE. | |||||
| EE90 | JR CheckNearTrapDoor_Scan | Jump to CheckNearTrapDoor_Scan to handle the trap door. | ||||||
|
Restart from StateData_Boney to clear near-trap marks when no type-32 was found.
|
||||||||
| CheckNearTrapDoor_ClearPass | EE92 | LD IX,$8EE9 | Point IX at Boney's complex entity state (StateData_Boney). | |||||
|
Clear pass: wipe bit 00/06/07 marks until type 32, then refuse the open.
|
||||||||
| CheckNearTrapDoor_ClearScan | EE96 | LD A,(IX+$00) | Fetch the current entity's type for the type test. | |||||
| EE99 | CP $32 | Is A equal to 32? If so, jump to CheckNearTrapDoor_NoOpen. | ||||||
| EE9B | JR Z,CheckNearTrapDoor_NoOpen | |||||||
| EE9D | BIT 0,(IX+$02) | Is bit 00 of the current entity's flags byte 2 set? If not, jump to CheckNearTrapDoor_ClearNext. | ||||||
| EEA1 | JR Z,CheckNearTrapDoor_ClearNext | |||||||
| EEA3 | RES 0,(IX+$02) | Reset bit 00 of the current entity's flags byte 2. | ||||||
| EEA7 | RES 6,(IX+$03) | Reset bit 06 of the current entity's flags byte 3. | ||||||
| EEAB | RES 7,(IX+$03) | Reset bit 07 of the current entity's flags byte 3. | ||||||
| EEAF | CP $01 | Is A equal to 01? If not, jump to CheckNearTrapDoor_ClearNext. | ||||||
| EEB1 | JR NZ,CheckNearTrapDoor_ClearNext | |||||||
| EEB3 | LD A,$05 | Load A with sound index 05. | ||||||
| EEB5 | LD ($72C7),A | Set the Bad Tempered Thing state (BadTemperedThingState). | ||||||
|
Advance during the clear pass.
|
||||||||
| CheckNearTrapDoor_ClearNext | EEB8 | ADD IX,DE | IX+=DE. | |||||
| EEBA | JR CheckNearTrapDoor_ClearScan | Jump to CheckNearTrapDoor_ClearScan to handle the trap door. | ||||||
|
No open: clear the falling-entity latch (bit 02 of GameEventFlags) and return carry clear.
|
||||||||
| CheckNearTrapDoor_NoOpen | EEBC | RES 2,(HL) | Clear the falling-entity latch (bit 02 of GameEventFlags). | |||||
| EEBE | RET | Return. | ||||||
|
Type 32 found: restart from StateData_Boney to nudge marked entities before opening.
|
||||||||
| CheckNearTrapDoor_FoundSceneryBlock | EEBF | LD IX,$8EE9 | 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 | EEC3 | LD A,(IX+$00) | Fetch the current entity's type for the type test. | |||||
| EEC6 | CP $32 | Is A equal to 32? If so, jump to CheckNearTrapDoor_ShouldOpen. | ||||||
| EEC8 | JR Z,CheckNearTrapDoor_ShouldOpen | |||||||
| EECA | BIT 0,(IX+$02) | Is bit 00 of the current entity's flags byte 2 set? If not, jump to CheckNearTrapDoor_AdjustNext. | ||||||
| EECE | JR Z,CheckNearTrapDoor_AdjustNext | |||||||
| EED0 | LD A,(IX+$03) | Load A with the current entity's flags byte 3. | ||||||
| EED3 | LD C,A | Keep the flags byte in C. | ||||||
| EED4 | AND %00111111 | A&=3F. | ||||||
| EED6 | LD (IX+$03),A | Set the current entity's flags byte 3. | ||||||
| EED9 | LD A,C | Copy the saved count/flag from C into A. | ||||||
| EEDA | AND %11000000 | A&=C0. | ||||||
| EEDC | JR Z,CheckNearTrapDoor_ShrinkBounds | Jump to CheckNearTrapDoor_ShrinkBounds to continue if the comparison matched. | ||||||
| EEDE | RES 0,(IX+$02) | Reset bit 00 of the current entity's flags byte 2. | ||||||
| EEE2 | BIT 6,A | Is bit 06 of A set? If not, jump to CheckNearTrapDoor_BumpCoordinates. | ||||||
| EEE4 | JR Z,CheckNearTrapDoor_BumpCoordinates | |||||||
| EEE6 | INC (IX+$07) | Move this entity one character right. | ||||||
| EEE9 | INC (IX+$08) | |||||||
|
Bump a marked entity one character right away from the trap door band.
|
||||||||
| CheckNearTrapDoor_BumpCoordinates | EEEC | INC (IX+$07) | Bump this entity one character right. | |||||
| EEEF | INC (IX+$08) | |||||||
| EEF2 | JR CheckNearTrapDoor_AdjustNext | Jump to CheckNearTrapDoor_AdjustNext to handle the trap door. | ||||||
|
Randomly shrink a marked entity's Y/Y-extent by 04–07 characters.
|
||||||||
| CheckNearTrapDoor_ShrinkBounds | EEF4 | LD A,$04 | Load A with 04. | |||||
| EEF6 | CALL PseudoRandom | Call PseudoRandom to pick a pseudo-random value. | ||||||
| EEF9 | ADD A,$04 | A+=04. | ||||||
| EEFB | LD C,A | Keep A in C for the next calculation. | ||||||
| EEFC | LD A,(IX+$05) | Load A with the current entity's y-coordinate. | ||||||
| EEFF | SUB C | A-=C. | ||||||
| EF00 | LD (IX+$05),A | Set the current entity's y-coordinate. | ||||||
| EF03 | LD A,(IX+$06) | Load A with the current entity's y-extent. | ||||||
| EF06 | SUB C | A-=C. | ||||||
| EF07 | LD (IX+$06),A | Set the current entity's y-extent. | ||||||
|
Advance to the next entity in the adjust pass.
|
||||||||
| CheckNearTrapDoor_AdjustNext | EF0A | ADD IX,DE | IX+=DE. | |||||
| EF0C | JR CheckNearTrapDoor_AdjustScan | Jump to CheckNearTrapDoor_AdjustScan to handle the trap door. | ||||||
|
Signal that the trap door should open (set bit 02 of GameEventFlags, carry set).
|
||||||||
| CheckNearTrapDoor_ShouldOpen | EF0E | SET 2,(HL) | Set the falling-entity latch (bit 02 of GameEventFlags). | |||||
| EF10 | SCF | Signal success. | ||||||
| EF11 | RET | Return. | ||||||
| Prev: EDF8 | Up: Map | Next: EF12 |