Prev: A219 Up: Map Next: A2CE
A240: Colour the status panel to go with the room
Used by the routine at ENTER_ROOM.
The third and last step of a room change, after CLEAR_PLAY_AREA and DRAW_ROOM. It writes attributes only -- the scroll, the timer and the score are drawn elsewhere and simply take whatever colour is underneath them, which is why walking into a differently-coloured room recolours the whole panel without anything being redrawn.
The colour is the room's own ink complemented: CPL then AND $07 keeps just the three ink bits and inverts them, so a red room gives a cyan panel, green gives magenta and so on. Complementing also throws away the bright and paper bits, which is why the panel comes out one shade darker than the room outline.
Inks 0 and 1 -- black and blue -- would be unreadable against black paper, so anything below 2 is replaced outright by $44, bright green. Measured by writing each room colour into $5E1A in turn and re-running: $42 gives $05, $43 gives $04, $44 gives $03, $45 gives $02, and $46 and $47 both give $44.
PAINT_PANEL A240 LD HL,$00C0 x = 192, the first character column past the play area.
A243 CALL PIXEL_TO_ATTR
A246 LD BC,$0818 8 columns wide, 24 rows deep -- the rest of the screen.
A249 LD A,($5E1A) The room's colour, inverted.
A24C CPL
A24D AND $07
A24F CP $02 Too dark to read against black...
A251 JR NC,PAINT_PANEL_0
A253 LD A,$44 ...so use bright green instead.
PAINT_PANEL_0 A255 LD E,A
A256 PUSH DE
PAINT_PANEL_1 A257 PUSH BC
A258 PUSH HL
PAINT_PANEL_2 A259 LD (HL),E Fill one row of the panel.
A25A INC L
A25B DJNZ PAINT_PANEL_2
A25D POP HL
A25E LD BC,$0020 32 bytes to the row below.
A261 ADD HL,BC
A262 POP BC
A263 DEC C
A264 JR NZ,PAINT_PANEL_1
A266 LD HL,$90C8 The little blocks below the scroll are coloured separately...
A269 CALL PIXEL_TO_ATTR
A26C LD A,($5E1A) ...in the room's own colour rather than the complement.
A26F LD BC,$0303
A272 CALL FILL_BLOCK
A275 INC L
A276 LD (HL),A
A277 ADD HL,DE
A278 LD BC,$0202
A27B CALL FILL_BLOCK
A27E LD HL,$98D0 One cell on its own.
A281 CALL PIXEL_TO_ATTR
A284 POP DE
A285 LD (HL),E
A286 LD HL,$7DC8
A289 CALL PIXEL_TO_ATTR
A28C LD BC,$0603 Bright white, for the part that never changes.
A28F LD A,$47
A291 CALL FILL_BLOCK
A294 LD HL,$5FC8
A297 CALL PIXEL_TO_ATTR
A29A LD BC,$0604
A29D LD A,$46
A29F CALL FILL_BLOCK
A2A2 LD HL,$48C8
A2A5 CALL PIXEL_TO_ATTR
A2A8 LD BC,$0601
A2AB LD A,$45
A2AD CALL FILL_BLOCK
A2B0 LD BC,$0601
A2B3 LD A,$47
A2B5 CALL FILL_BLOCK
A2B8 LD HL,$38C8
A2BB CALL PIXEL_TO_ATTR
A2BE LD BC,$0601
A2C1 LD A,$43
A2C3 CALL FILL_BLOCK
A2C6 LD BC,$0601
A2C9 LD A,$47
A2CB JP FILL_BLOCK
Prev: A219 Up: Map Next: A2CE