Prev: E4F1 Up: Map Next: E5F4
E581: Handler: Disappearing Floors
Used by the routine at InitialiseGame.
Handler_DisappearingFloors E581 LD IX,($5BE6) IX=*ReferenceDisappearingFloors.
Are we done?
Handler_DisappearingFloors_Loop E585 LD A,(IX+$00) Return if the terminator character has been received instead of a co-ordinate (FF).
E588 CP $FF
E58A RET Z
Bit 7 of *IX+02 holds the floor "state".
Is the floor currently visible?
E58B LD A,(IX+$02) A=Sprite width+state (*IX+02).
E58E AND %10000000 Keep only the current "state".
E590 JP Z,DisplayFloor Jump to DisplayFloor if the floor should be visible.
We didn't jump, so the floor is currently NOT visible.
The game uses a bunch of 00 bytes at Graphics_MaskSprite to "print empty space" - this is how we remove sprites.
E593 LD HL,$9F6C Write 9F6C (Graphics_MaskSprite) to *CHARS.
E596 LD ($5C36),HL
E599 INC (IX+$05) Increment the the floor change timer (*IX+05) by one.
Check the current floor change timer against the max. count for how long the floor should stay disappeared for.
E59C LD A,(IX+$04) Jump to PrintDisappearedFloor if the current floor change timer has not yet reached the maximum value set in the disappeared timer count.
E59F CP (IX+$05)
E5A2 JR NZ,PrintDisappearedFloor
The timer for how long the floor should be "disappeared" has elapsed.
E5A4 LD A,(IX+$02) A=Sprite width+state (*IX+02).
E5A7 AND %01111111 Strip off bit 7 (which is the current "state") as we need to unset it so the floor will display next cycle.
E5A9 LD (IX+$02),A Write this value back to sprite width+state (*IX+02).
E5AC LD (IX+$05),$00 Reset the the floor change timer back to 00.
Whilst this routine could also print the floor as well, the game needs to update other buffers when it changes, so this version is a lot simpler.
PrintDisappearedFloor E5B0 LD C,(IX+$00) C=Horizontal position (*IX+00).
E5B3 LD B,(IX+$01) B=Vertical position (*IX+01).
Bits 0-6 of *IX+02 hold the floor width.
E5B6 LD A,(IX+$02) A=Sprite width+state (*IX+02).
E5B9 AND %01111111 Strip off bit 7 (which is the current "state") as we need the actual width to render the empty space where the floor should be.
E5BB LD E,A E=Sprite width (A).
E5BC LD D,$01 D=Sprite height (always 01).
E5BE LD A,$20 A=base sprite ID (20).
E5C0 CALL PrintSprite Call PrintSprite.
E5C3 JR DisappearingFloors_Next Jump to DisappearingFloors_Next.
The floor is currently visible so handle checking the current floor change timer against the max. count for how long the floor should stay visible for.
DisplayFloor E5C5 LD A,(IX+$03) Fetch the maximum visible count value.
E5C8 INC (IX+$05) Increment the the floor change timer by one.
E5CB CP (IX+$05) Jump to PrintVisibleFloor if the current floor change timer has not yet reached the maximum value set in the visible timer count.
E5CE JR NZ,PrintVisibleFloor
The timer for how long the floor should be "visible" has elapsed.
E5D0 LD A,(IX+$02) A=Sprite width+state (*IX+02).
E5D3 OR %10000000 Set bit 7 (which is the current "state") so the floor will disappear next cycle.
E5D5 LD (IX+$02),A Write this value back to sprite width+state (*IX+02).
E5D8 LD (IX+$05),$00 Reset the the floor change timer back to 00.
Display the visible floor. Note the similarity to PrintDisappearedFloor.
PrintVisibleFloor E5DC LD C,(IX+$00) C=Horizontal position (*IX+00).
E5DF LD B,(IX+$01) B=Vertical position (*IX+01).
Bits 0-6 of *IX+02 hold the floor width.
E5E2 LD A,(IX+$02) A=Sprite width+state (*IX+02).
E5E5 AND %01111111 Strip off bit 7 (which is the current "state") as we need the actual width to render the floor.
E5E7 LD E,A E=Sprite width (A).
E5E8 LD D,$01 D=Sprite height (always 01).
E5EA CALL PrintSpriteUpdateBuffer Call PrintSpriteUpdateBuffer.
Move onto the next disappearing floor data.
DisappearingFloors_Next E5ED LD DE,$0006 IX+=0006.
E5F0 ADD IX,DE
E5F2 JR Handler_DisappearingFloors_Loop Jump to Handler_DisappearingFloors_Loop.
Prev: E4F1 Up: Map Next: E5F4