Prev: CAA2 Up: Map Next: CAF1
CAD2: Give every room back its own colour
Used by the routine at AFTER_GAME.
Called at every new game (AFTER_GAME). A room's third byte holds its colour twice: bits 3-5 as the tape has it, and bits 0-2, the ink in use, which an activated chamber turns white (LOOSE_VALVE). This copies bits 3-5 into bits 0-2 in every record of the room directory (ROOM02), stepping from one to the next by the count at +1, so a new game starts with no chamber activated.
RESET_ROOM_COLOURS CAD2 LD HL,ROOM02 The room directory and its end; HL on the first record's count
CAD5 LD BC,OBJECT_TABLE
CAD8 INC HL
RESET_ROOM_COLOURS_0 CAD9 LD E,(HL) E = the count; HL on the third byte
CADA INC HL
CADB LD A,(HL) Bits 3-5 into bits 0-2
CADC RRCA
CADD RRCA
CADE RRCA
CADF AND $07
CAE1 LD D,A
CAE2 LD A,(HL)
CAE3 AND $F8
CAE5 OR D
CAE6 LD (HL),A
CAE7 LD D,$00 On to the next record's count
CAE9 ADD HL,DE
CAEA AND A Until the end of the directory
CAEB SBC HL,BC
CAED RET NC
CAEE ADD HL,BC
CAEF JR RESET_ROOM_COLOURS_0
Prev: CAA2 Up: Map Next: CAF1