Prev: E4F1 Up: Map Next: E5F4
E581: Handler: Disappearing Floors
Used by the routine at InitialiseGame.
Handler_DisappearingFloors E581 LD IX,($5BE6) Point IX at *ReferenceDisappearingFloors.
Walk the disappearing-floor table.
Handler_DisappearingFloors_Loop E585 LD A,(IX+$00) Return if this floor entry is the terminator (FF).
E588 CP $FF
E58A RET Z
Bit 7 of the width byte holds whether the floor is visible.
E58B LD A,(IX+$02) A=this floor's width and visibility state.
E58E AND %10000000 Keep only the visibility state.
E590 JP Z,DisplayFloor Jump to DisplayFloor if the floor is currently visible.
The floor is hidden; print empty space from Graphics_MaskSprite.
E593 LD HL,$9F6C Write 9F6C to *CHARS.
E596 LD ($5C36),HL
E599 INC (IX+$05) Advance this floor's change timer.
Stay hidden until the disappeared-timer count elapses.
E59C LD A,(IX+$04) Jump to PrintDisappearedFloor if the hidden timer has not elapsed.
E59F CP (IX+$05)
E5A2 JR NZ,PrintDisappearedFloor
Time to bring the floor back.
E5A4 LD A,(IX+$02) A=this floor's width and visibility state.
E5A7 AND %01111111 Clear the hidden state so the floor will show next cycle.
E5A9 LD (IX+$02),A Write the updated width and state back.
E5AC LD (IX+$05),$00 Reset this floor's change timer.
Print blank tiles where the floor should be. The visible path at PrintVisibleFloor also updates the room buffer.
PrintDisappearedFloor E5B0 LD C,(IX+$00) C=the floor's horizontal co-ordinate.
E5B3 LD B,(IX+$01) B=the floor's vertical co-ordinate.
Bits 0-6 hold the floor width.
E5B6 LD A,(IX+$02) A=this floor's width and visibility state.
E5B9 AND %01111111 Keep only the width.
E5BB LD E,A E=the floor width.
E5BC LD D,$01 D=01 (floors are one row high).
E5BE LD A,$20 A=a blank tile.
E5C0 CALL PrintSprite Print the empty floor space.
E5C3 JR DisappearingFloors_Next Jump to DisappearingFloors_Next.
The floor is visible; count down until it should vanish.
DisplayFloor E5C5 LD A,(IX+$03) Fetch how long this floor stays visible.
E5C8 INC (IX+$05) Advance this floor's change timer.
E5CB CP (IX+$05) Jump to PrintVisibleFloor if the visible timer has not elapsed.
E5CE JR NZ,PrintVisibleFloor
Time to hide the floor.
E5D0 LD A,(IX+$02) A=this floor's width and visibility state.
E5D3 OR %10000000 Set the hidden state so the floor will vanish next cycle.
E5D5 LD (IX+$02),A Write the updated width and state back.
E5D8 LD (IX+$05),$00 Reset this floor's change timer.
Draw the floor and update the room buffer.
PrintVisibleFloor E5DC LD C,(IX+$00) C=the floor's horizontal co-ordinate.
E5DF LD B,(IX+$01) B=the floor's vertical co-ordinate.
Bits 0-6 hold the floor width.
E5E2 LD A,(IX+$02) A=this floor's width and visibility state.
E5E5 AND %01111111 Keep only the width.
E5E7 LD E,A E=the floor width.
E5E8 LD D,$01 D=01 (floors are one row high).
E5EA CALL PrintSpriteUpdateBuffer Print the floor and update the room buffer.
Move onto the next disappearing floor.
DisappearingFloors_Next E5ED LD DE,$0006 Move IX on to the next six-byte floor entry.
E5F0 ADD IX,DE
E5F2 JR Handler_DisappearingFloors_Loop Jump to Handler_DisappearingFloors_Loop.
Prev: E4F1 Up: Map Next: E5F4