Hi-Res
Graphics Aid Routines
Jon Hylands
Graphics Aid Routines
Jon Hylands
This handy utility makes it easy to perform sophisticated operations on Apple high-resolution graphics screens: inverting screens, copying screens, superimposing one screen on another, and more. It works on any Apple II-series computer with DOS 3.3 or ProDOS.
Like most personal computers, Apple II-series machines can display high-resolution color graphics. There are many commercial programs that let you draw, save, and reload hi-res screens. But few of them let you easily perform complex operations such as inverting an entire hi-res screen or superimposing one screen on another. "Hi-Res Graphics Aid" fills that gap. Though the program uses machine language for speed, you don't need to know ML to use it.
Type in and save the program below, then run it. The screen prompts are self-explanatory. Keep in mind that this is not a general-purpose drawing or design program; it performs large-scale tasks on existing graphics screens. Since the Apple can store two hi-res. screens in memory at a time, most operations let you act on either screen 1 or screen 2.
When you run Graphics Aid, it displays a main menu of six selections. From this menu you can dis play a screen, edit a screen, load a screen, save a screen, display a disk catalog, or quit. The current selection is highlighted in inverse video. To choose a different selection, press the up-arrow or down-arrow keys (CTRL-K or CTRL-J on the Apple II+) and then press RETURN. Here's a brief description of the options:
Display screen. Enter 1 to display screen 1; 2 for screen 2.
Edit screen. This option displays a second menu with the following options:
• Display screen. Enter 1 or 2.
• Invert screen. Enter 1 or 2.
• Copy screen. Enter 1 to copy screen 1 to screen 2, or vice versa.
• Superimpose screen. Enter 1 to superimpose screen 1 on screen 2, or vice versa. Then choose the mode by pressing a number key from 1-3. Mode 1 is ORA mode; every pixel that's turned on in either screen remains on. Mode 2 is AND mode; only pixels that are on in both screens remain on. In Mode 3 (XOR), every pixel that's turned on in both screens will be turned off, and vice versa.
• Color screen. Choose screen 1 or 2, then enter a color number from 0-7.
• Flip high bits. Choose screen 1 or 2, then choose the mode by pressing a number key from 1-3, Mode 1 sets the high bits, mode 2 clears them, and mode 3 inverts them (on bits are turned off, and vice versa).
• Swap screens. Swap the contents of screen 1 and screen 2.
• Return to command menu.
Load to screen. Choose screen 1 or 2, then select drive 1 or 2 and enter the filename of the graphics file you wish to load.
Save screen. Choose screen 1 or 2, then select drive 1 or 2 and enter the filename you wish to use when saving the graphics screen to disk.
Catalog. Displays a disk catalog.
Quit. Exit to BASIC.
Hi-Res Graphics Aid
For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.
82 10 BA = 32768: FOR I = BA TO
BA + 212: READ A:CK = CK +
A: POKE I,A: NEXT : REM L
OAD HR.CODE
CA 20 IF CK < > 31397 THEN PRINT
"ERROR IN DATA STATEMENTS
.": STOP
F4 30 DATA 76,18,128,76,33,128,7
6,55
A0 40 DATA 128,76,80,128,76,115,
128,76
E1 50 DATA 151,128,166,255,173,8
0,192,173
E7 60 DATA 82,192,173,87,192,189
,83,192
7D 70 DATA 96,166,255,189,195,12
8,133,251
35 80 DATA 32,186,128,177,250,73
,255,145
5F 90 DATA 250,32,177,128,208,24
5,96,166
68 100 DATA 255,189,195,128,133,
251,189,198
F9 110 DATA 128,133,253,32,186,1
28,177,250
BE 120 DATA 145,252,32,177,128,2
08,247,96
FD 130 DATA 166,255,189,195,128,
133,251,189
07 140 DATA 198,128,133,253,166,
254,189,201
05 150 DATA 128,141,105,128,32,1
86,128,177
45 160 DATA 250,17,252,145,252,3
2,177,128
21 170 DATA 208,245,96,166,255,1
89,195,128
87 180 DATA 133,251,166,254,189,
205,128,141
ED 190 DATA 141,128,189,209,128,
141,142,126
CA 200 DATA 32,186,128,177,250,9
,128,145
79 210 DATA 250,32,177,128,208,2
45,96,169
B2 220 DATA 32,133,251,10,133,25
3,32,186
92 230 DATA 128,177,250,72,177,2
52,145,250
8B 240 DATA 104,145,252,32,177,1
28,208,241
DE 250 DATA 96,200,208,5,230,251
,230,253
73 260 DATA 202,96,160,0,132,250
,132,252
EA 270 DATA 162,32,96,0,32,64,0,
64
23 280 DATA 32,0,17,49,81,0,9,41
38 290 DATA 73,0,128,127,128
16 300 TEXT : HOME : PRINT : PRI
NT CHR$ (4);"PR#0": PRINT
: REM INITIALIZATION
2A 310 D$ = CHR$ (4):BE$ = CHR$
(7):E$ = CHR$ (27):L$ = "
----------":D = 1
F4 320 READ L: DIM X(L),TI$(L,13
)
52 330 FOR J = 1 TO L: READ X(J)
: FOR I = 1 TO X(J): READ
TI$(J,I): NEXT : NEXT
57 340 DATA 2,6,DISPLAY SCREEN,S
CREEN EDITOR,LOAD SCREEN,
SAVE SCREEN,CATALOG,QUIT
E4 350 DATA 8,DISPLAY SCREEN,INV
ERT SCREEN,COPY SCREEN,SU
PERIMPOSE SCREEN,COLOR SC
REEN,FLIP HI BITS,SWAP SC
REENS,COMMAND MENU
IB 360 READ X: DIM ER$(X): FOR I
= 1 TO X: READ ER$(I): N
EXT
CC 370 DATA 13,,,,WRITE PROTECTE
D,,FILE NOT FOUND,VOLUME
MISMATCH,I/O ERROR,DISK F
ULL,FILE LOCKED,SYNTAX ER
ROR,,FILE TYPE MISMATCH
09 380 REM COMMAND MENU
81 390 HOME : TEXT :J = 1:M$ = "
HI.RES COMMAND MENU": GOS
UB 640
51 400 IF I = X(J) THEN VTAB 10
+ X(J): END
50 410 ON I GOSUB 890,840,1290,1
360,1430
9B 420 GOTO 390
4B 430 REM GET A KEYSTROKE
22 440 A = 0: GET A$. IF A$ = E$
THEN POP : RETURN
23 450 A = VAL (A$): RETURN
68 460 REM CENTER MESSAGE
C0 470 VTAB V: HTAB ( INT ((40 -
LEN (M$)) / 2) + 1): PRI
NT M$: RETURN
F6 480 REM DRAW A LINE
66 490 VTAB V: FOR I = 1 TO 4: P
RINT L$;: NEXT : RETURN
70 500 REM GET DRIVE
84 510 PRINT "DRIVE : ";D; CHR$
(8);
10 520 GOSUB 440: IF A$ = CHR$ (
13) THEN A = 1
82 530 IF A < 1 OR A > 2 THEN 52
0
7E 540 D = A: RETURN
7D 550 REM GET PAGE
ED 560 GOSUB 440: IF A < 0 OR A
> 2 THEN 560
E4 570 P = A: RETURN
0A 580 REM ASK. 'ARE YOU SURE ?
'
D6 590 PRINT "ARE YOU SURE ? Y";
CHR$ (8);
67 600 GET A$: IF A$ = "N" OR A$
= E$ THEN PRINT A$;: POP
: RETURN
24 610 IF A$ = CHR$ (13) OR A$ =
"Y" THEN RETURN
16 620 GOTO 600
21 630 REM CUSTOM MENU ROUTINE
Fl 640 V = 2: GOSUB 490
F3 650 V = 4: GOSUB 470
76 660 V = 6: GOSUB 490
21 670 PRINT : VTAB 9
AB 680 FOR I = 1 TO X(J): HTAB 2
: PRINT TI$(J,I): NEXT
3A 690 I = 1: VTAB 24: CALL - 86
8
E7 700 VTAB I + 8: HTAB 2: INVER
SE : PRINT TI$(J,I): NORM
AL
54 710 A = PEEK ( - 16384): IF A
< 128 THEN 710
C4 720 POKE - 16368,0:A = A - 12
8
CF 730 IF A = 21 OR A = 10 THEN
770
CE 740 IF A = 8 OR A = 11 THEN 8
00
A9 750 IF A = 13 THEN RETURN
A8 760 GOTO 710
89 770 VTAB I + B: HTAB 2: PRINT
TI$(J,I)
CB 780 IF I + 1 > X(J) THEN I =
1: GOTO 700
BD 790 I = I + 1: GOTO 700
7C 800 VTAB I + 8: HTAB 2: PRINT
TI$(J,I)
AE 810 IF I = 1 THEN I = X(J): G
OTO 700
31 820 1 = I - 1: GOTO 700
99 830 REM SCREEN EDITOR
BE B40 HOME : TEXT :J = 2:M$ = "
SCREEN EDITOR": GOSUB 640
EE 850 IF I = X(J) THEN RETURN
D3 860 ON I GOSUB 890,930,970,10
20,1100,1190,1260
27 870 GOTO 840
65 880 REM DISPLAY SCREEN
3A 890 VTAB 23: PRINT : PRINT "D
ISPLAY SCREEN : ";
70 900 GOSUB 560: IF A = 0 THEN
RETURN
9D 910 POKE 255,P: CALL BA: GOTO
900
6D 920 REM INVERT SCREEN
86 930 VTAB 23: PRINT : PRINT "I
NVERT SCREEN : ";
78 940 GOSUB 560: IF A = 0 THEN
RETURN
28 950 POKE 255,P: CALL BA + 3:
RETURN
20 960 REM COPY SCREEN
14 970 VTAB 22: PRINT : PRINT "C
OPY SCREEN ";: GOSUB 560:
IF A = 0 THEN RETURN
73 980 POKE 255,P: PRINT P;" TO
";3 - P
68 990 GOSUB 590
AC 1000 CALL BA + 6: RE=TURN
C5 1010 REM SUPERIMPOSE SCREEN
14 1020 VTAB 21: PRINT : PRINT "
SUPERIMPOSE SCREEN ";: G
OSUB 560: IF A = 0 THEN
RETURN
72 1030 POKE 255,P: PRINT P;" TO
";3 - P
6C 1040 PRINT "1 : ORA 2 : AND
3 : FOR CHOOSE
4A 1050 GOSUB 440
7F 1060 IF A < 1 OR A > 3 THEN 1
050
31 1070 PRINT A: POKE 254,A: GOS
UB 590
E4 1080 CALL BA + 9: RETURN
AA 1090 REM COLOR SCREEN
E2 1100 VTAB 21: PRINT : PRINT "
COLOR SCREEN : ";: GOSUB
560: IF A = 0 THEN RETU
RN
Fl 1110 PRINT P: PRINT "COLOR :
";
A4 1120 GET A$: IF A$ = E$ THEN
RETURN
98 1130 IF A$ = "0" THEN C = 0:
GOTO 1150
08 1140 C = VAL (A$): IF C < 1 O
R C > 7 THEN 1120
72 1150 PRINT C: GOSUB 590
98 1160 POKE 230,32 * P: HCOLOR=
C: HPLOT 0,0: CALL 6245
4
EF 1170 RETURN
C9 1180 REM FLIP HI BITS
87 1190 VTAB 21: PRINT : PRINT "
FLIP HI BITS ON SCREEN :
";: GOSUB 560: IF A = 0
THEN RETURN
46 1200 PRINT P: POKE 255,P: PRI
NT "1 : SET 2 : CLEAR
3 : FLIP CHOOSE : ";
3E 1210 GOSUB 440
43 1220 IF A < 1 OR A > 3 THEN 1
210
34 1230 PRINT A;: POKE 254,A: GO
SUB 590
5C 1240 CALL BA + 12: RETURN
55 1250 REM SWAP SCREENS
3A 1260 VTAB 23: PRINT : GOSUB 5
90
98 1270 CALL BA + 15: RETURN
FD 1280 REM LOAD SCREEN
AE 1290 VTAB 20. PRINT : PRINT "
LOAD TO SCREEN : ";: GOS
UB 560: IF A = 0 THEN RE
TURN
BC 1300 PRINT P: GOSUB 510: IF A
= 0 THEN RETURN
15 1310 PRINT D: INPUT "FILENAME
: ";F$
C3 1320 IF F$ = "" THEN RETURN
35 1330 VTAB 1: PRINT : PRINT D$
;"BLOAD"; F$;",D"; D;",A";
P * 8192
E7 1340 RETURN
97 1350 REM SAVE SCREEN
20 1360 VTAB 20: PRINT : PRINT "
SAVE SCREEN : ";: GOSUB
560: IF A = 0 THEN RETUR
N
AB 1370 PRINT P: GOSUB 510: IF A
= 0 THEN RETURN
31 1380 PRINT D: INPUT "FILENAME
: ";F$
DF 1390 IF F$ = "" THEN RETURN
11 1400 VTAB 1: PRINT : PRINT D$
:"BSAVE"; F$;",D";D;",A";
P * 8192;",L8192"
DD 1410 RETURN
F6 1420 REM CATALOG DISK
36 1430 VTAB 23: PRINT : GOSUB 5
10: IF A = 0 THEN RETURN
22 1440 HOME :M$ = "CATALOG OF D
RIVE " + STR$ (D):V = 1:
GOSUB 470
95 1450 V = 2: GOSUB 490
CA 1460 POKE 34,2: PRINT : PRINT
D$"CATALOG,D"D
91 1470 V = 2:M$ = " PRESS A KEY
... ": GOSUB 470
3B 1480 VTAB 2: HTAB 27: GET T$:
POKE 34,0: RETURN