| Routines

07318: THE 'SET PERMANENT COLOURS' SUBROUTINE

The address of this routine is derived from an offset found in the command class table. This subroutine allows for the current temporary colours to be made permanent. As command class 7 it is in effect the command routine for the six colour item commands.
CLASS_07 | 07318 | BIT 7,(IY+1) | The syntax/run flag (bit 7 of FLAGS) is read.
| 07322 | RES 0,(IY+2) | Signal 'main screen' (reset bit 0 of TV-FLAG).
| 07326 | CALL NZ,TEMPS | Only during a 'run' call TEMPS to ensure the temporary colours are the main screen colours.
| 07329 | POP AF | Drop the return address SCAN_LOOP.
| 07330 | LD A,(23668) | Fetch the low byte of T-ADDR and subtract 19 to give the range 217 to 222 which are the token codes for INK to OVER.
| 07333 | SUB 19
| 07335 | CALL CO_TEMP_4 | Change the temporary colours as directed by the BASIC statement.
| 07338 | CALL CHECK_END | Move on to the next statement if checking syntax.
| 07341 | LD HL,(23695) | Now the temporary colour values (ATTR-T and MASK-T) are made permanent (ATTR-P and MASK-P).
| 07344 | LD (23693),HL
| 07347 | LD HL,23697 | This is P-FLAG, and that too has to be considered.
| 07350 | LD A,(HL)
The following instructions cleverly copy the even bits of the supplied byte to the odd bits, in effect making the permanent bits the same as the temporary ones.
| 07351 | RLCA | Move the mask leftwards.
| 07352 | XOR (HL) | Impress onto the mask only the even bits of the other byte.
| 07353 | AND %10101010
| 07355 | XOR (HL)
| 07356 | LD (HL),A | Restore the result.
| 07357 | RET |