Upside-Down Character Set Flipper
- Type
- Graphics
- Category
- Character set redefinition demo
- Author
- David Small, Sandy Small and George Blank (editors)
- Published in
- The Creative Atari (Creative Computing Press, 1983), "Character Sets", Program 27
- Year
- 1983
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, 16K RAM, Atari BASIC
About the program
The Creative Atari (Creative Computing Press, 1983) gathered the Atari material from Creative Computing magazine, much of it by the book's editors David and Sandy Small and George Blank, together with new chapters. Its graphics tutorial works step by step from the TV picture up to player/missile graphics and character sets, with a short program at each step. The character set chapter builds up redefinition one step at a time: read a character's bitmap, copy the font to RAM, point the hardware at the copy, change it. This program is the showpiece of the series. It makes an upside-down copy of the whole character set and then switches the screen between the normal set and the inverted one, over and over again. Every character on the screen flips on the spot, while the text stays in the same place.
What you need
Any Atari 8-bit with Atari BASIC.
Typing it in
Plain ASCII. Line 141 (LIST) is there on purpose: it puts the program's own text on the screen, so there is something to watch. Type GRAPHICS 0 or press RESET before you run it a second time, so that RAMTOP is not lowered twice.
How to use it
RUN it. The listing appears, followed by "COPYING." Because the program switches to the RAM font before copying it (line 300), you see the characters appear one by one as their bytes arrive. Next the characters turn upside down as the second loop runs. Then the screen starts flickering between the two sets. Press BREAK to stop and RESET to get the normal font back.
How it works
- Location 106 (RAMTOP) gives the top of usable RAM in 256-byte pages. Lines 100–140 lower it by 4 pages (1K), the size of a full character set. The
GRAPHICS 0call then rebuilds the screen below the new limit, so the font area is safe. - Location 756 (CHBAS) tells ANTIC which page the font starts on. The ROM font is at page 224 (address 57344).
- Lines 500–520 copy the 1024 bytes of the ROM font. Lines 600–635 then copy each 8-byte character again with its bytes in reverse order (
7-BYTE), which turns it upside down. - Lines 710–730 just POKE 756 back and forth. The change takes effect on the next frame, so the flip rate depends on how fast BASIC runs the loop.
Variations to try
- Add a delay loop in line 715 and line 725 for a slower, steadier flip.
- Mirror the characters left-to-right instead. Reverse the bits of each byte, for example by building a 256-entry lookup table first.
- In the same chapter, Program 26 sets the bottom row of every character to 255 instead, which underlines all text. Combine that with the flip.
Listing
45 REM THEN FLIPS BACK AND FORTH
100 MEMTOP=PEEK(106)
110 GRTOP=MEMTOP-4
115 CLOC=GRTOP
120 POKE 106,GRTOP
130 REM RESET GR.0 DM/DL AREA
140 GRAPHICS 0
141 LIST
150 CH=756
160 CHROM=PEEK(CH)*256
170 CHRAM=GRTOP*256
175 PRINT "CHRAM=";CHRAM;" CHROM=";CHROM
180 PRINT "COPYING."
190 REM COPY ROM TO RAM
300 POKE CH,CLOC
500 FOR N=0 TO 1023
510 POKE CHRAM+N,PEEK(CHROM+N)
520 NEXT N
530 PRINT "COPIED."
550 REM NOW COPY UPSIDE DOWN
600 FOR CHNUM=0 TO 127
610 FOR BYTE=0 TO 7
615 Z=PEEK(CHROM+(CHNUM*8)+BYTE)
620 POKE (CHNUM*8)+(CHRAM)+(7-BYTE),Z
630 NEXT BYTE
635 NEXT CHNUM
640 PRINT "RECOPIED."
700 REM FLIP
710 POKE CH,224:REM NORMAL ROM
720 POKE CH,CLOC
730 GOTO 710
Credits
- Program listing: Upside-Down Character Set Flipper — program listing (The Creative Atari (Creative Computing Press, 1983), "Character Sets", Program 27) — David Small, Sandy Small and George Blank (editors)
- Picture: Caught mid-flip: the program's own listing shown in the upside-down character set. — David Small, Sandy Small and George Blank (editors) (program); screenshot by the site
- The Creative Atari — Character Sets (atariarchives.org) — David Small, Sandy Small and George Blank (editors)
