Hi-Res Graphics 8 Demo ("Graphics 8 Plus")

Type
Graphics
Category
Graphics technique demo (reversed GRAPHICS 8)
Author
Clay Halliwell
Published in
Antic, January 1989 (Vol. 7, No. 9), Tech Tips
Year
1989
Language
Atari BASIC
Requirements
Any Atari 8-bit, 32K RAM (two 7,680-byte screen buffers), Atari BASIC; a colour TV or monitor to see artifacting
A GRAPHICS 8 test screen: three blocks of vertical lines at left, a large fan of diagonal lines forming an hourglass and diamond shapes, a small diamond at right, and caption text below

About the program

The manuals say GRAPHICS 8 is a 320×192 mode with one colour plus background. Most programmers knew better. On NTSC machines a single lit pixel in an even column shows up in one colour and in an odd column in another, while two side by side make white. This is the well-known artifacting effect. Clay Halliwell, a computer science student at Southwest Missouri State University, sent Antic's Tech Tips a further twist on it, which he admitted had "been around for years". He said GRAPHICS 8 is "backwards".

Fill every pixel of the screen with the drawing colour, then swap the colours. The full-screen "drawing colour" becomes dark (luminance 0) and the "background" becomes bright (luminance 10). The screen looks black again, but now you draw by turning bits off, with COLOR 0. Halliwell called it GRAPHICS 8 Plus, and said that compared with normal GRAPHICS 8:

  • pixels are sharper and brighter, and bleed less;
  • artifact colours look more solid, without the vertical "hum lines" some TVs show;
  • on a monochrome monitor, all pixels look equally bright.

He added that the same trick works in GRAPHICS 0.

Typing it in

Line 15 holds a machine-language block-move routine as a string. The inverse characters ({inv}…{/inv}: Atari key on and off) and {CTRL-E}, {CTRL-Q}, {CTRL-D}, {CTRL-P}, {CTRL-,}, {CTRL-.} (CTRL plus that key) must be exact. Line 17 uses CTRL-comma (character 0) to clear the buffers. Everything else is plain BASIC. The two 7,680-byte strings in line 10 need about 15K of free memory.

How to use it

RUN it. The program quietly draws the same test picture twice, once in each version, while the screen sits dimmed in attract mode (line 15 pokes 131 into location 77). Then it shows the normal GRAPHICS 8 version, with the caption "This is how Mode 8 normally looks". Press any key to switch to the GRAPHICS 8 Plus version, and any key again to switch back. Compare the three blocks of vertical lines. The top block uses every column, the middle one every even column and the bottom one every odd column, so they show white and the two artifact colours. The fan of diagonal lines and the diamond show how edges look.

How it works

  • Fast fill. Line 65 POKEs 255 into the first screen byte, then calls the move routine to copy the screen onto itself one byte further on: USR(MOV,SAVMSC,SAVMSC+1,7679). Because the copy runs forwards, each byte copies the one just written, so the 255 ripples through all 7,680 bytes in a moment. It's a classic trick.
  • Swapping roles. For the Plus screen, POKE 709,0:POKE 710,10 makes set bits (colour register 1) dark and clear bits (register 2, the background in GRAPHICS 8) bright. Then the same drawing routines are run with COLOR 0.
  • Page flipping by copying. Both pictures are saved into strings (SCRN1$, SCRN2$) with the move routine. Lines 100–150 copy one or the other back into screen memory with DMA switched off (POKE 559,0), then on again, so each switch looks instant.

Variations to try

  • Halliwell said the same applies to GRAPHICS 0, so try it there. Fill the screen with inverse spaces, swap the luminances in 709 and 710, and compare the text with the normal screen.
  • Use SETCOLOR 2 hues other than 0 on the Plus screen to tint the whole display.

Listing

1 REM HI-RES GRAPHICS 8 DEMO
2 REM BY CLAY HALLIWELL
3 REM
10 DIM SCRN1$(7680),SCRN2$(7680)
15 MOV=ADR("hh{inv}{CTRL-E}W{/inv}h{inv}{CTRL-E}V{/inv}h{inv}{CTRL-E}Y{/inv}h{inv}{CTRL-E}X{/inv}h{inv}{CTRL-E}Z{/inv}h{inv}* {/inv}{CTRL-,}{inv}1V{CTRL-Q}XHP{/inv}{CTRL-D}{inv}fWfYJPrFZ{/inv}{CTRL-P}{inv}n{/inv}{CTRL-.}"):POKE 77,131
17 SCRN1$(1)="{CTRL-,}":SCRN1$(7680)=SCRN1$:SCRN1$(2)=SCRN1$:SCRN2$=SCRN1$
20 GRAPHICS 8+16:POKE 709,10:POKE 710,0
30 COLOR 1:GOSUB 1000:GOSUB 2000
35 SAVMSC=PEEK(88)+PEEK(89)*256:I=USR(MOV,SAVMSC,ADR(SCRN1$),7680)
60 GRAPHICS 8+16:REM FAST SCREEN FILL
65 POKE SAVMSC,255:I=USR(MOV,SAVMSC,SAVMSC+1,7679)
70 POKE 709,0:POKE 710,10
80 COLOR 0:GOSUB 1000:GOSUB 2000:I=USR(MOV,SAVMSC,ADR(SCRN2$),7680)
90 POKE 77,0
100 GRAPHICS 8:POKE 559,0:POKE 709,10:POKE 710,0:I=USR(MOV,ADR(SCRN1$),SAVMSC,7680):POKE 752,1
110 ? "{CLEAR}This is how Mode 8 normally looks.":? "Press any key for the Magic of Hi-Res":? ,"GRAPHICS 8+..."
115 ? "(Press any to return here.)";
120 POKE 559,34:GOSUB 300
130 GRAPHICS 8+16:POKE 559,0:POKE 709,0:POKE 710,10:I=USR(MOV,ADR(SCRN2$),SAVMSC,7680)
140 POKE 559,34
150 GOSUB 300:GOTO 100
300 POKE 764,255:REM WAIT FOR KEY
310 POKE 77,0:IF PEEK(764)=255 THEN 310
320 POKE 764,255:RETURN
999 REM DRAW ARTIFACT BLOCKS
1000 X=10:Y=10:INC=1:GOSUB 1500
1010 X=10:Y=60:INC=2:GOSUB 1500
1020 X=11:Y=110:INC=2:GOSUB 1500
1030 RETURN
1499 REM DRAW
1500 FOR X1=X TO 50 STEP INC:PLOT X1,Y:DRAWTO X1,Y+40:NEXT X1:RETURN
1999 REM DRAW LINES
2000 FOR I=60 TO 319 STEP 15:PLOT 189,160:DRAWTO I,100:DRAWTO 379-I,0:NEXT I
2010 PLOT 270,30:DRAWTO 290,50:DRAWTO 270,70:DRAWTO 250,50:DRAWTO 270,30:RETURN

Download

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

Credits