Rainbow Screen Customizer

Type
Utility
Category
Programming utility (multicoloured GRAPHICS 0 screens with display-list interrupts)
Author
James Hague
Published in
Antic, March 1987 (Vol. 5, No. 11)
Year
1987
Language
Atari BASIC (with a machine-language interrupt routine)
Requirements
Any Atari 8-bit, Atari BASIC, joystick in port 1, disk drive to save subroutines
The View/Edit screen: a help box listing OPTION, SELECT, START and TRIGGER, an arrow pointing at one GRAPHICS 0 line coloured blue, and columns of sample text ABCabc down the right

About the program

The Atari can show 128 colours, yet most BASIC programs use only two or three, because GRAPHICS 0 normally allows just a background colour and one text brightness. James Hague's Rainbow Screen Customizer lets you give each of the 24 text lines its own background colour and its own character brightness, "up to an amazing 24 colors in all". Then it writes a BASIC subroutine that recreates your design inside any program, so you could, for example, have a vivid red message area at the bottom of a word processor. Hague, from Richardson, Texas, had written Uncle Henry's Nuclear Waste Dump for Antic a few months earlier.

Typing it in

A few lines contain inverse-video text for the menus: {inv}…{/inv} means press the Atari key before and after. The DATA in lines 10100–10175 is the 107-byte machine-language routine, so type it carefully. The magazine printed TYPO II codes for checking.

How to use it

From the main menu, press 1 (View/Edit Screen). Move the arrow to a line with the joystick. Hold START to cycle through 16 colours for that line, press SELECT to step through eight background brightnesses, and press OPTION for eight text brightnesses. The sample text is only there to help you judge the colours. If text and background have the same brightness, the text vanishes. Press the button to return to the menu.

Press 2 (Create Subroutine) and give a starting line number, a step and a file name (use .LST). The program writes the subroutine to disk in LISTed form. LOAD your own program, ENTER the file, and GOSUB to its first line to switch the custom screen on. POKE CTRL,1 turns the colours on and POKE CTRL,0 turns them off. A GRAPHICS statement cancels the effect, and another GOSUB brings it back.

Hague pointed out two catches. The keyclick makes the screen shudder (on XL/XE machines, POKE 731,255 turns the click off). And the routine and its tables live in page 6 (from 1536), so it can't be used with other page-6 machine code.

How it works

  • Tables in page 6. Locations 1536–1559 hold the 24 line colours and 1560–1583 the text brightnesses. The editor just POKEs these bytes (lines 1130–1180).
  • The interrupt routine at 1584 does three things. It sets the interrupt bit on every text line of the display list. It installs a vertical blank routine that sets the first line's colours and resets a line counter. And it installs a display-list interrupt which, at the end of each line, waits for horizontal sync and stores the next pair of values into the hardware colour registers for text (53271) and background (53272).
  • Code generation. Lines 2080–2110 PRINT #1 complete BASIC lines, with their DATA statements, to the output file. Location 205, which the subroutine calls CTRL, is the on/off switch the VBI checks.

Listing

10 REM SCREEN CUSTOMIZER
20 REM BY JAMES HAGUE
30 REM (c) 1986, ANTIC PUBLISHING
100 GOSUB 10000:POKE 752,1
105 POKE CTRL,0:POKE 709,10
110 POKE 710,0:? CHR$(125)
115 POSITION 11,4:? "GRAPHICS MODE ZERO"
120 POSITION 11,5:? "SCREEN  CUSTOMIZER"
125 POSITION 7,7:? "programmed by James Hague"
130 POSITION 15,10:? "MAIN MENU"
135 POSITION 9,12:? "{CTRL-H}{inv}1{CTRL-H}{/inv} View/Edit Screen"
140 POSITION 9,14:? "{CTRL-H}{inv}2{CTRL-H}{/inv} Create Subroutine"
145 POSITION 9,16:? "{CTRL-H}{inv}3{CTRL-H}{/inv} Exit Program"
150 POSITION 3,19:? "press the number of your selection"
155 GOSUB 500
160 IF CHR$(A)="1" THEN GOSUB 1000:GOTO 105
165 IF CHR$(A)="2" THEN GOSUB 2000:GOTO 105
170 IF CHR$(A)="3" THEN GRAPHICS 0:? "Your computer is";:END
175 FOR A=15 TO 0 STEP -1:SOUND 0,240,10,A:NEXT A:GOTO 155
499 REM RETURN KEYPRESS IN (A)
500 POKE 764,255:OPEN #1,4,0,"K:"
505 GET #1,A:CLOSE #1:RETURN
999 REM EDIT/VIEW SCREEN
1000 ? CHR$(125)
1005 POSITION 7,5:? "THE FOLLOWING CONTROLS ARE"
1010 POSITION 8,6:? "AVAILABLE DURING EDITING"
1015 POSITION 7,9:? "select line with JOYSTICK"
1020 POSITION 6,11:? "OPTION - character luminance"
1025 POSITION 6,12:? "SELECT - line luminance"
1030 POSITION 6,13:? "START  - line color"
1035 POSITION 5,15:? "press TRIGGER to stop editing"
1040 POSITION 6,18:? "press any key to continue..."
1045 GOSUB 500:? CHR$(125)
1050 POKE CTRL,1:LINE=11:GOSUB 3000
1055 FOR A=6 TO 23:POSITION 25,A
1060 IF INT(A/2)=A/2 THEN ? "{inv} ABCabc {/inv}ABCabc";:GOTO 1070
1065 ? "ABCabc{inv} ABCabc {/inv}";
1070 IF A<>23 THEN PRINT
1075 NEXT A
1080 POSITION 2,LINE:? "->"
1085 A=STICK(0)
1090 IF A=14 AND LINE THEN A=LINE-1:GOTO 1105
1095 IF A=13 AND LINE<>23 THEN A=LINE+1:GOTO 1105
1100 GOTO 1110
1105 POSITION 2,LINE:? "  ";:POSITION 2,A:? "->";:LINE=A
1110 A=PEEK(53279):IF A<>7 THEN 1125
1115 POKE 20,0
1117 IF PEEK(20)>=5 THEN 1085
1120 IF  NOT STRIG(0) THEN RETURN
1122 GOTO 1117
1125 IF A<>3 THEN 1145
1130 B=PEEK(1560+LINE)+2
1135 IF B=16 THEN B=0
1140 POKE 1560+LINE,B:GOTO 1115
1145 B=INT(PEEK(1536+LINE)/16)
1150 C=PEEK(1536+LINE)-16*B
1155 IF A<>6 THEN 1170
1160 B=B+1:IF B>15 THEN B=0
1165 GOTO 1180
1170 IF A<>5 THEN 1115
1175 C=C+2:IF C>15 THEN C=0
1180 POKE 1536+LINE,B*16+C
1185 GOTO 1115
1999 REM CREATE SUBROUTINE
2000 ? CHR$(125)
2005 POSITION 11,0:? "SUBROUTINE CREATOR":? :POKE 752,0
2010 ? "Enter the line number that you would  like the routine to start at."
2015 TRAP 2015:INPUT LINE:IF LINE<0 OR LINE>32700 THEN 2015
2020 ? :? "Enter the line number increment."
2025 TRAP 2025:INPUT INC:IF INC<1 OR INC<>INT(INC) OR INC>100 THEN 2025
2030 ? :? "Enter the filename to save the sub-   routine as.  The 'D:' is optional."
2035 INPUT A$:IF A$="" THEN 2035
2040 IF A$(2,2)=":" AND A$(1,1)<>"D" THEN 2035
2045 IF A$(2,2)<>":" AND A$(3,3)<>":" THEN B$=A$:A$="D:":A$(3)=B$
2050 POKE 752,1:? CHR$(125)
2055 POSITION 6,10:? "Insert a FORMATTED diskette":POSITION 6,12:? "press any key to write file"
2060 GOSUB 500:TRAP 2500:? CHR$(125)
2065 CLOSE #1:OPEN #1,8,0,A$:? CHR$(125)
2070 POSITION 14,10:? "writing file"
2075 ? #1;LINE;"IF PEEK(1584)=104 AND PEEK(1585)=173 THEN";LINE+3*INC:LINE=LINE+INC
2080 ? #1;LINE;"RESTORE";LINE+3*INC;":FOR A=0 TO 47:READ B:POKE 1536+A,B:NEXT A":LINE=LINE+INC
2085 ? #1;LINE;"FOR A=0 TO 106:READ B:POKE 1584+A,B:NEXT A":LINE=LINE+INC
2090 ? #1;LINE;"A=USR(1584):CTRL=205:RETURN":LINE=LINE+INC
2095 ? #1;LINE;"DATA";PEEK(1536);
2100 FOR A=1 TO 23:? #1;",";PEEK(1536+A);:NEXT A:? #1:LINE=LINE+INC
2105 ? #1;LINE;"DATA";PEEK(1560);
2110 FOR A=1 TO 23:? #1;",";PEEK(1560+A);:NEXT A:? #1:LINE=LINE+INC
2115 FOR A=0 TO 14
2120 ? #1;LINE;"DATA";PEEK(1584+7*A);
2125 FOR B=1 TO 6:? #1;",";PEEK(1584+7*A+B);:NEXT B:? #1:LINE=LINE+INC:NEXT A
2130 ? #1;LINE;"DATA 104,64"
2135 CLOSE #1:RETURN
2499 REM ERROR HANDLER
2500 TRAP 2505:CLOSE #1
2505 ? CHR$(125)
2510 POSITION 13,10:? "I/O ERROR ";PEEK(195)
2515 POSITION 6,12:? "press any key for main menu"
2520 GOSUB 500:RETURN
3000 POSITION 6,0:? "{CTRL-Q}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-E}"
3010 POSITION 6,1:? "|OPTION=Character Luminence|"
3020 POSITION 6,2:? "|SELECT=Line Luminence     |"
3030 POSITION 6,3:? "|START= Line Color         |"
3040 POSITION 6,4:? "|TRIGGER= Main Menu        |"
3050 POSITION 6,5:? "{CTRL-Z}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-C}"
3060 RETURN
9999 REM INITIALIZATION
10000 FOR A=0 TO 23:POKE 1536+A,0:POKE 1560+A,10:NEXT A
10005 RESTORE 10100
10010 FOR A=0 TO 106:READ B:POKE 1584+A,B:NEXT A
10015 CTRL=205:A=USR(1584):DIM A$(20),B$(20)
10020 RETURN
10100 DATA 104,173,48,2,133,203,173
10105 DATA 49,2,133,204,160,3,177
10110 DATA 203,9,128,145,203,160,6
10115 DATA 169,130,145,203,200,192,29
10120 DATA 208,249,169,129,141,0,2
10125 DATA 169,6,141,1,2,160,99
10130 DATA 162,6,169,7,133,205,76
10135 DATA 92,228,162,64,165,205,240
10140 DATA 18,173,24,6,141,197,2
10145 DATA 173,0,6,141,198,2,169
10150 DATA 1,133,206,162,192,142,14
10155 DATA 212,76,98,228,72,138,72
10160 DATA 166,206,189,24,6,141,10
10165 DATA 212,141,23,208,189,0,6
10170 DATA 141,24,208,230,206,104,170
10175 DATA 104,64

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: SCREEN.BAS.

Credits