Prev: D24C Up: Map Next: D30C
D2BC: Strip Attributes and Fade
Player-death transition. Strips the paper and bright bits from every attribute cell in the attribute area (5800–5AFF), keeping only the ink colour, then calls Fade_Screen to fade the screen pixel data to black with a flashing border effect. On return, two levels of call stack are discarded via back-to-back POP DE, aborting the current game-loop callers and returning to the outer death-handling code.
Strip_Attributes_And_Fade D2BC LD HL,$5800 Point HL to the start of the attribute area at 5800.
D2BF LD B,$07 Load the ink-colour mask 07 into B.
Strip_Attributes_Loop D2C1 LD A,(HL) Mask out the paper and bright bits from the current attribute cell.
D2C2 AND B
D2C3 LD (HL),A
D2C4 INC HL Advance to the next cell and loop until the end of the attribute area at 5B00.
D2C5 LD A,H
D2C6 CP $5B
D2C8 JP NZ,Strip_Attributes_Loop
D2CB CALL Fade_Screen Call the screen fade routine at Fade_Screen.
D2CE POP DE Discard two return addresses from the stack and return to the outer death handler.
D2CF POP DE
D2D0 RET
Screen fade: AND-masks the entire pixel area in 20 passes, cycling the border between black and white on each pass to create a flash effect.
Fade_Screen D2D1 LD B,$14 Set the fade pass counter to 14.
D2D3 LD HL,$0000 Initialise the pixel mask pointer to 00.
Fade_Screen_Outer_Loop D2D6 PUSH HL Stash the mask pointer and point DE to the start of the pixel area at 4000.
D2D7 LD DE,$4000
Fade_Screen_Inner_Loop D2DA LD A,(DE) AND each pixel byte with the corresponding mask byte; loop across the current 256-byte row until E wraps.
D2DB AND (HL)
D2DC LD (DE),A
D2DD INC DE
D2DE INC HL
D2DF LD A,E
D2E0 AND A
D2E1 JR NZ,Fade_Screen_Inner_Loop
D2E3 LD A,$00 Set the border to black ( BLACK) via port FE.
D2E5 OUT ($FE),A
D2E7 LD A,B Scale the pass counter for the delay loop duration.
D2E8 SLA A
D2EA SLA A
Fade_Screen_Black_Delay D2EC DEC A Busy-wait for the black border period.
D2ED JR NZ,Fade_Screen_Black_Delay
D2EF LD A,$18 Load the white border value 18.
D2F1 AND %00011000 Mask to border bits only.
D2F3 OUT ($FE),A Set the border to white via port FE.
D2F5 LD A,B Scale the pass counter for the second delay loop duration.
D2F6 SLA A
D2F8 SLA A
Fade_Screen_White_Delay D2FA DEC A Busy-wait for the white border period.
D2FB JR NZ,Fade_Screen_White_Delay
D2FD LD A,D Continue masking screen rows until the full pixel area (4000– 57FF) has been processed.
D2FE CP $58
D300 JR NZ,Fade_Screen_Inner_Loop
D302 POP HL Restore the mask pointer, advance the mask page, and repeat for the next fade pass.
D303 INC H
D304 DJNZ Fade_Screen_Outer_Loop
D306 RET Return.
Restore the border colour to white after the fade.
Restore_Border_White D307 LD A,$07 Set the border to white ( WHITE) via port FE and return.
D309 OUT ($FE),A
D30B RET
Prev: D24C Up: Map Next: D30C