Character Analysis asks for a single character, either any character from the space to © or one of the user-defined graphics a–u. It shows the character and its code at the top, draws an 8×8 grid at the left of the screen with each square 16 pixels across, and fills in red each square whose bit is set. Each row’s byte value is printed beside it. “Again?” takes y to analyse another character or n to stop. The program is numbered 9800–9960 so it can be merged with a program under development.
The REM in line 9800 reads “> Character Analysis < by Alvin Albrecht”. The program was written up as “Character Analysis” in Time Designs, volume 3, number 2 (January/February 1987). It was on the disk SNUG_11_12 under a file name that begins with the CHR$ token.
Program Analysis
Line 9840 finds a ROM character in the set pointed to by CHARS (23606–23607), adding 256 because CHARS points 256 bytes below the space character. Line 9850 finds a UDG through the UDG system variable (23675–23676). Line 9960 draws the grid with nine PLOT/DRAW lines each way. Lines 9870–9910 take each of the eight bytes and test its bits from 7 down to 0 by subtracting 2^x; a set bit prints two rows of two red-paper spaces to fill its square.
Notable Techniques
- High line numbers let the routine be
MERGEd into another program as a design aid. - One routine handles both the ROM characters and the UDGs by changing only the base address.
Potential Issues
- Line 9930 uses
RUNto start again. Once merged with another program, that would run the host program from its first line rather than this routine. - The bit test uses floating-point powers of two, so each character takes a few seconds to draw.
- Filled squares are printed over the grid, so the grid lines along their edges are erased.
This program came from an Oliger (JLO SAFE) disk. It has no disk commands, so it needed no changes for tape and auto-runs at line 9800. It was tested in ZEsarUX, where the letter A gave the rows 0, 60, 66, 66, 126, 66, 66, 0.
Source Code
9800 REM > Character Analysis < by Alvin Albrecht
9810 BORDER 5: PAPER 5: CLS
9820 CLS : INPUT " ENTER CHARACTER TO BE ANALYZED "; LINE a$: IF LEN a$<>1 THEN GO TO 9820
9830 IF (a$<" " OR a$>"*") AND (a$<"a" OR a$>"u") THEN GO TO 9820
9840 IF a$>=" " AND a$<="*" THEN LET base=PEEK 23606+256*PEEK 23607+256: LET a=CODE a$-32: GO TO 9860
9850 LET base=PEEK 23675+256*PEEK 23676: LET a=CODE a$-144
9860 GO SUB 9960: DIM b(8): LET a=a*8: LET base=base+a: LET t=0
9870 PRINT AT 1,9; INK 0;a$;" - CODE: ";CODE a$: FOR z=0 TO 7: LET a=PEEK (base+z): PRINT AT z*2+5,17;a: FOR x=7 TO 0 STEP -1
9880 IF a-2^x<0 THEN GO TO 9910
9890 PRINT AT z*2+5,(7-x)*2; PAPER 2;" ";AT z*2+6,(7-x)*2;" "
9900 LET a=a-2^x
9910 NEXT x: NEXT z: OVER 0
9920 INPUT "Again? "; LINE a$
9930 IF a$="y" OR a$="Y" THEN RUN
9940 IF a$="n" OR a$="N" THEN STOP
9950 GO TO 9920
9960 CLS : FOR z=0 TO 8: PLOT 16*z,8: DRAW 0,128: PLOT 0,z*16+8: DRAW 128,0: NEXT z: RETURNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

