Visit Atarimax Store


Free-Net Logo
The Atari SIG Historical Archive
Created and hosted by: atarimax.com
[ HOME | GO ATARI | 8-BIT | ST/TT | PORTFOLIO | LYNX | JAGUAR | LIBRARY ]


Article #51 (51 is last):
From: aa700@cleveland.Freenet.Edu (Michael Current)
Newsgroups: freenet.sci.comp.atari.product.8bit.tricks
Subject: 97 colors in GRAPHICS 0
Reply-To: aa700@cleveland.Freenet.Edu (Michael Current)
Posted-By: xx004 (Atari SIG)
Date: Sun May 23 22:02:57 1999


From: seagtgruff@aol.com (SeaGtGruff)
>Newsgroups: comp.sys.atari.8bit
Date: 15 May 1999 07:58:16 GMT

Thank you, those who responded regarding my program to
"jazz up" the Atari's GRAPHICS 0 mode.

I typed in the BASIC listing that creates the binary file with
the USR routines, DLI, and VBI.  When I ran it, I thought I'd
come up against a compatibility problem, because the P/M
graphics weren't being drawn correctly.  The next night I
sat down and scanned my typing carefully, and discovered
that I'd made a typo-- I typed "20" instead of "200"-- and when
I corrected it, everything ran like a champ!

One thing I've noticed is that the colors aren't exactly the
same as on a TV set.  I thought hue 4 was supposed to be a
red color, but the emulator is displaying it as violet.  [sigh]

Anyway, I've created a disk image with the programs on it,
but now I need to type up the article that goes with them,
which I'll save as a "README.TXT" file on the disk image.

I found out that I have to retract one of the things I said.  The
standard P/M graphics are used, rather than the GRAF
registers in upper memory.  Now that my memory's been
jolted, I recall that I *did* try using the GRAF registers as I'd
described, to save memory.  However, this meant that the
DLI had too many things to do in too short a time, and the
machine cycles required exceeded the number of machine
cycles in the horizontal blank.  Consequently, I went back to
using the standard P/M graphics, although I did use the
double-scanline mode to save *some* memory.

What I said about using self-modifying DLIs was correct.  In
fact, I used only one DLI, which is called before each row in
the DL.  After the DLI changes the colors on each row, it
increments some of the addresses in the DLI, so that the next
time the DLI executes, it pulls the color information from the
next set of addresses in the color arrays.  I did this in order to
keep the number of machine cycles required by the DLI to a
bare minimum.

I just LISTed the programs to the "H:" device, so I can post them in this
message.  This first program creates the machine language routines and stores
them in a disk file.

100 REM * JAZZING UP GRAPHICS 0 -- #0:
(C) 1999 BY MICHAEL SHELDON RIDEOUT
101 OPEN #1,8,0,"D:JAZZING.USR"
102 FOR I=1 TO 643:READ A:PUT #1,A
103 NEXT I:CLOSE #1
104 DATA 170,104,104,202,208,251,96
105 DATA 104,133,204,104,133,205,104
106 DATA 240,39,201,3,240,3,76
107 DATA 0,148,104,104,141,48,145
108 DATA 104,104,141,49,145,104,104
109 DATA 141,50,145,201,24,176,13
110 DATA 173,49,145,201,24,176,6
111 DATA 165,205,72,165,204,72,96
112 DATA 104,240,3,76,0,148,165
113 DATA 87,240,1,96,173,48,2
114 DATA 133,204,173,49,2,133,205
115 DATA 160,2,169,240,145,204,200
116 DATA 169,194,145,204,160,6,169
117 DATA 130,145,204,200,192,28,208
118 DATA 249,169,144,141,7,212,169
119 DATA 1,141,111,2,169,58,141
120 DATA 0,2,169,150,141,1,2
121 DATA 160,36,162,150,169,6,32
122 DATA 92,228,169,0,168,153,128
123 DATA 145,153,0,146,153,128,146
124 DATA 153,0,147,153,128,147,200
125 DATA 16,238,168,169,148,153,56
126 DATA 145,200,192,24,208,248,169
127 DATA 202,160,0,153,80,145,200
128 DATA 192,24,208,248,169,0,168
129 DATA 153,104,145,200,192,24,208
130 DATA 248,76,192,148,104,240,3
131 DATA 76,0,148,168,169,46,141
132 DATA 47,2,169,3,141,29,208
133 DATA 185,118,150,153,0,208,200
134 DATA 192,13,208,245,169,192,141
135 DATA 14,212,96,104,240,3,76
136 DATA 0,148,168,141,29,208,153
137 DATA 0,208,200,192,13,208,248
138 DATA 169,64,141,14,212,96,32
139 DATA 7,148,172,49,145,173,48
140 DATA 145,153,56,145,200,204,50
141 DATA 145,144,247,240,245,96,32
142 DATA 7,148,172,49,145,173,48
143 DATA 145,153,80,145,200,204,50
144 DATA 145,144,247,240,245,96,32
145 DATA 7,148,172,49,145,173,48
146 DATA 145,153,104,145,200,204,50
147 DATA 145,144,247,240,245,96,104
148 DATA 208,1,96,201,5,240,3
149 DATA 76,0,148,104,104,141,48
150 DATA 145,104,104,141,51,145,104
151 DATA 104,141,52,145,104,104,141
152 DATA 53,145,170,104,104,141,54
153 DATA 145,201,24,176,218,224,40
154 DATA 176,214,173,52,145,174,51
155 DATA 145,201,24,176,204,224,40
156 DATA 176,200,142,49,145,141,50
157 DATA 145,165,89,133,205,165,88
158 DATA 172,50,145,240,10,24,105
159 DATA 40,144,2,230,205,136,208
160 DATA 246,133,204,173,49,145,41
161 DATA 7,168,185,100,150,141,55
162 DATA 145,173,49,145,41,56,74
163 DATA 74,168,185,109,150,133,207
164 DATA 173,50,145,10,10,24,121
165 DATA 108,150,133,206,172,49,145
166 DATA 173,48,145,41,1,240,6
167 DATA 169,128,17,204,208,4,169
168 DATA 127,49,204,145,204,160,0
169 DATA 173,48,145,41,2,240,7
170 DATA 173,55,145,17,206,208,7
171 DATA 173,55,145,73,255,49,206
172 DATA 145,206,20,192,4,208,249
173 DATA 173,49,145,205,53,145,176
174 DATA 25,238,49,145,78,55,145
175 DATA 208,188,169,128,141,55,145
176 DATA 24,101,206,133,206,144,176
177 DATA 230,207,76,175,149,173,50
178 DATA 145,205,54,145,176,23,173
179 DATA 51,145,141,49,145,238,50
180 DATA 145,165,204,24,105,40,133
181 DATA 204,144,2,230,205,76,139
182 DATA 149,96,8,72,169,104,141
183 DATA 62,150,169,80,141,77,150
184 DATA 169,56,141,83,150,104,40
185 DATA 76,95,228,8,72,234,173
186 DATA 104,145,141,18,208,141,19
187 DATA 208,141,20,208,141,21,208
188 DATA 173,80,145,141,23,208,173
189 DATA 56,145,141,24,208,238,62
190 DATA 150,238,77,150,238,83,150
191 DATA 104,40,64,128,64,32,16
192 DATA 8,4,2,1,144,145,16
193 DATA 146,144,146,16,147,144,147
194 DATA 80,112,144,176,72,64,56
195 DATA 48,3,3,3,3,255

This next program loads the created file into memory so the USR routines can be
used in your BASIC programs.  Note
that it uses the MEMLOAD routine (which I just discussed in
another post) to load the file.  Your program would go
between lines 2 and 32699.

0 REM * JAZZING UP GRAPHICS 0 -- #1:
(C) 1999 BY MICHAEL SHELDON RIDEOUT
1 GOSUB 32700
2 REM * YOUR PROGRAM GOES HERE
32699 END
32700 RESTORE 32704:DIM MEMLOAD$(45)
32701 MEMLOAD=ADR(MEMLOAD$)
32702 FOR I=1 TO 45:READ A
32703 MEMLOAD$(I)=CHR$(A):NEXT I
32704 DATA 104,240,41,201,3,208,31
32705 DATA 104,104,10,10,10,10,170
32706 DATA 104,157,69,3,104,157,68
32707 DATA 3,104,157,73,3,104,157
32708 DATA 72,3,169,7,157,66,3
32709 DATA 76,86,228,170,104,104,202
32710 DATA 208,251,96
32711 OPEN #1,4,0,"D:JAZZING.USR"
32712 A=USR(MEMLOAD,1,37888,643)
32713 CLOSE #1:INSTALL=37944
32714 ENABLE=38074:DISABLE=38108
32715 SCREEN=38132:TEXT=38153
32716 PLAYER=38174:AREA=38195
32717 POKE 106,144:GRAPHICS 0
32718 A=USR(INSTALL):RESTORE :RETURN

This next program is a demo that uses the USR routines to
draw colorful boxes on the GRAPHICS 0 screen.  "I can't
believe it's GRAPHICS 0!"  ;-)  Note how the above program
is duplicated below, but the demo program has been added
between lines 2 and 32699.

0 REM * JAZZING UP GRAPHICS 0 -- #2:
(C) 1999 BY MICHAEL SHELDON RIDEOUT
1 GOSUB 32700
2 REM * YOUR PROGRAM GOES HERE
10 POKE 752,1:PRINT " "
100 C=2*INT(128*RND(0))
110 R1=INT(20*RND(0))
120 R2=R1+4
130 A=USR(SCREEN,C,R1,R2)
200 C=2*INT(8*RND(0))
210 R1=INT(20*RND(0))
220 R2=R1+4
230 A=USR(TEXT,C,R1,R2)
300 C=2*INT(128*RND(0))
310 R1=INT(20*RND(0))
320 R2=R1+4
330 A=USR(PLAYER,C,R1,R2)
400 FOR C=0 TO 3
410 C1=INT(32*RND(0))
420 R1=INT(16*RND(0))
430 C2=C1+8
440 R2=R1+8
450 A=USR(AREA,C,C1,R1,C2,R2)
460 NEXT C
470 GOTO 100
32699 END
32700 RESTORE 32704:DIM MEMLOAD$(45)
32701 MEMLOAD=ADR(MEMLOAD$)
32702 FOR I=1 TO 45:READ A
32703 MEMLOAD$(I)=CHR$(A):NEXT I
32704 DATA 104,240,41,201,3,208,31
32705 DATA 104,104,10,10,10,10,170
32706 DATA 104,157,69,3,104,157,68
32707 DATA 3,104,157,73,3,104,157
32708 DATA 72,3,169,7,157,66,3
32709 DATA 76,86,228,170,104,104,202
32710 DATA 208,251,96
32711 OPEN #1,4,0,"D:JAZZING.USR"
32712 A=USR(MEMLOAD,1,37888,643)
32713 CLOSE #1:INSTALL=37944
32714 ENABLE=38074:DISABLE=38108
32715 SCREEN=38132:TEXT=38153
32716 PLAYER=38174:AREA=38195
32717 POKE 106,144:GRAPHICS 0
32718 A=USR(INSTALL):RESTORE :RETURN

Finally, this next program is a static display showing 97 colors
at once on the GRAPHICS 0 screen.

0 REM * JAZZING UP GRAPHICS 0 -- #3:
(C) 1999 BY MICHAEL SHELDON RIDEOUT
1 GOSUB 32700
2 REM * YOUR PROGRAM GOES HERE
10 POKE 752,1:PRINT " "
20 SETCOLOR 4,6,6
100 A=USR(AREA,1,10,0,19,23)
110 A=USR(AREA,2,20,0,29,23)
120 A=USR(AREA,3,30,0,39,23)
140 C1=0:C2=128:L=8
150 FOR R=0 TO 23
160 A=USR(SCREEN,C1,R,R)
170 A=USR(TEXT,L,R,R)
180 A=USR(PLAYER,C2,R,R)
190 C1=C1+2:C2=C2+2:L=L+2
200 IF L<16 THEN GOTO 220
210 C1=C1+8:C2=C2+8:L=8
220 NEXT R
230 POKE 752,0
32699 END
32700 RESTORE 32704:DIM MEMLOAD$(45)
32701 MEMLOAD=ADR(MEMLOAD$)
32702 FOR I=1 TO 45:READ A
32703 MEMLOAD$(I)=CHR$(A):NEXT I
32704 DATA 104,240,41,201,3,208,31
32705 DATA 104,104,10,10,10,10,170
32706 DATA 104,157,69,3,104,157,68
32707 DATA 3,104,157,73,3,104,157
32708 DATA 72,3,169,7,157,66,3
32709 DATA 76,86,228,170,104,104,202
32710 DATA 208,251,96
32711 OPEN #1,4,0,"D:JAZZING.USR"
32712 A=USR(MEMLOAD,1,37888,643)
32713 CLOSE #1:INSTALL=37944
32714 ENABLE=38074:DISABLE=38108
32715 SCREEN=38132:TEXT=38153
32716 PLAYER=38174:AREA=38195
32717 POKE 106,144:GRAPHICS 0
32718 A=USR(INSTALL):RESTORE :RETURN

I'll get to work rewriting the article that explains each of the
USR routines and how to use them, but the following notes--
along with the two demo programs-- should get you started.

A=USR(INSTALL)

No parameter is required.  This routine modifies the DL for
the DLIs, sets up the P/M graphics, and initializes the arrays.
If you issue a GRAPHICS command, you need to call this
routine again, because the GRAPHICS commands wipe out
the modified DL.  This routine aborts if you aren't already in
GRAPHICS 0.  Note that this routine automatically falls into
the next one.

A=USR(ENABLE)

No parameter is required.  This routine enables the P/M
graphics and DLIs if they've been disabled with the next
command.

A=USR(DISABLE)

No parameter is required.  This routine disables the P/M
graphics and DLIs, to return you to a normal GRAPHICS 0
display (although the DL isn't changed).  This might be useful
if you want to temporarily revert to a normal screen without
destroying the DLIs.

A=USR(SCREEN,color,row1,row2)

Three parameters are required: the color you want to use
(given as a value between 0 and 255, or-- if you prefer-- as
the expression 16*hue+luminance); the first row on which to
apply the new screen color; and the last row on which to
apply the new screen color.

A=USR(TEXT,luminance,row1,row2)

Three parameters are required: the luminance you want to use (given as a value
between 0 and 255-- as with SCREEN--
although only the luminance value has an effect); the first row
on which to apply the new text luminance; and the last row on
which to apply the new text luminance.

A=USR(PLAYER,color,row1,row2)

Three parameters are required.  This is the same as the
SCREEN color routine, but it changes the PLAYER color
(which is used as a second screen color).

A=USR(AREA,type,column1,row1,column2,row2)

Five parameters are required: the type of area (or "box") to
draw (0, 1, 2, or 3); the first column and row (for the top left
corner of the box); and the second column and row (for the
bottom right corner of the box).  A type 0 box uses the
SCREEN color, with no inverse graphics.  A type 1 box uses
the SCREEN color, with inverse graphics.  A type 2 box uses
the PLAYER color, with no inverse graphics.  And a type 3
box uses the PLAYER color, with inverse graphics.  Note
that if you draw a box containing inverse graphics, you
shouldn't PRINT over the box, as it will interfere with the
inverse bits.  It's preferable to PRINT your text first, and
then draw a box around it (if the box uses inverse graphics).

A=USR(MEMLOAD,filenumber,startingaddress,length)

This routine isn't part of the USR file, but it's used to load the
USR file into memory.  You can of course use it for your own
purposes, such as loading character sets or other binary files.
You can find a rather thorough discussion of this routine in
another posting (including an explanation of how it works).

Michael Rideout
-- 
Michael Current, mailto:mcurrent@carleton.edu
8-bit Atari FAQ and Vendor Lists, http://www.faqs.org/faqs/atari-8-bit/
Cleveland Free-Net Atari SIG, telnet://freenet-in-c.cwru.edu (go atari)
St. Paul Atari Computer Enthusiasts, http://www.library.carleton.edu/space/



Visit Atarimax Store