Using pattern tables to draw wireframe type characters is used a lot with the Apple II computers since they dont have sprites. This program uses letters stored in a string variable to draw graphics characters with a magnification parameter. The letters shown in figure 1 direct the drawing in 8 directions.
An upper case letter will move the pixel position and plot it. eg. If A$=”RDLU” – a box would be drawn (right down left up). The LPRINT command preceeded by RAND USR 50000: is used to pass the parameters to the machine code routine. The syntax is: RAND USR 50000: LPRINT x$, magnification, x coord, y coord.
-x$= (or any string var) holds the pattern string.
-Magnify= 0 to 9 (10 to 19 will un-plot the same pattern).
-X coord= starting X coordinate.
-Y coord= starting Y coordinate.
- all parameters can be fixed numbers, formulae, or expressions. You can also have more than one character drawn in one LPPRINT statement by separating sets of parameters by semi colons.
Enter the assembly language programs using an assembler such as the ZEUS assembler ( available from RMG Enterprises ) and save ths source code file before typing in the Basic program. All numbers are decimal unless preceeded by #.
This program also demonstrates how to link BASIC lines and formulas to you own machine language programs. Using the ROM calls with TS-2068 programming really simplify using formulas and finding variables.
The Basic Listing is an example of using the wire graphics. Keys 5-6-7-8 move the character about on screen. Keys 1 and 2 reduce or magnify the character size.
A large variable size character set could also be made using this approach. If the character is to be moved about the screen, you can increase the speed by moving more than one pixel at a time.



00001 ORIGIN 50000 ; Assemble code at 50000
00005 ;Wire Graphics by LARRY KENNY - LARKEN ELECTRONICS-
00010 Chadd EQU 23645 ; Current Char in BASIC being Interp.
00020 Start RST 32 ; Move Chadd to LPRINT token in BASIC .
00030 Again RST 32 ; Move Chadd to point to string variable.
00040 LD HL,(Chadd) ; Check to see if the variable
00050 INC HL ; is a string variable by comparing
00060 LD A,36 ; the character after the variable
00070 CP (HL) ; with a '$'.
00080 JR Z,String ; Continue if its a '$'.
00090 RST 8 ; If not, stop with Subscipt-
00100 DEFB 2 ; wrong Error.
00110 String CALL #2C70 ; Rom call to search for Variable.
00120 JR NC,Vfound ; Continue if the variable is found.
00130 RST 8 ; If not found, stop with error
00140 DEFB 1 ; Variable not found.
00150 Vfound LD (Strad),HL ; Store address of string variable.
00160 RST 32 ; Move 'Chadd' past the first comma.
00170 CALL EVALU ; Evaluate the Magnify parameter.
00180 LD A,C ; See if the magnify
00190 CP 21 ; parameter is out of range
00200 JP NC,Interr ; if larger than 20 then Int error.
00210 LD (Magni),A ; Store Magnify parameter.
00220 RST 32 ; Move Chadd past next comma.
00230 CALL EVALU ; Get the X coordinate.
00240 LD A,C ; Store the
00250 LD (Coord),A ; X coordinate.
00260 RST 32 ; Move Chadd past last comma.
00270 CALL EVALU ; Get the Y coordinate.
00280 LD A,C ; Check to see if it is in the
00290 CP 176 ; range of 176
00300 JP NC,Interr ; Jump to Integer out of Range Err.
00310 ADD A,16 ; Adjust it for bottom 2 lines.
00320 LD (Coord +1),A ; Store the Y coordinate.
00330 LD HL,(Strad) ; Get the Address of the String.
00340 INC HL ; Load the BC register
00350 LD C,(HL) ; with the length of
00360 INC HL ; of the String.
00370 LD B,(HL) ;
00380 INC HL ; Move the String pointer to the
00390 LD (Strad),HL ; start of the data in the String.
00400 LD A,(Magni) ; See if the Magnify
00410 CP 10 ; parameter is to erase or draw.
00420 JR NC,Setpix ; Go to set pixel setup
00430 LD A,255 ; Set the mask to
00440 LD (mask),A ; draw .
00450 JR Draw ; Go to Main routine
00460 Setpix SUB 10 ; Bring Magnify back into range
00470 LD (Magni),A ; of 0 to 9 and store
00480 XOR A ; Set the
00490 LD (mask),A ; mask to erase.
00500 Draw LD A,B ; Main draw loop.
00510 OR C ; See if we are at the end
00520 JP Z,EXIT ; of the String.
00530 DEC BC ; Reduce lenth counter.
00540 LD DE,(Strad) ; Load the current Letter
00550 LD A,(DE) ; into the accumulater.
00560 INC DE ; Point to next char in the string.
00570 LD (Strad),DE ; Store the String address.
00580 LD (Char),A ; Store the current Letter.
00590 LD A,(Magni) ; Load the Magnify parameter
00600 LD D,A ; into the D register for
00610 INC D ; a loop counter.
00620 INC D ; Preset the counter.
00630 Nextpx DEC D ; Reduce the loop counter.
00640 JR Z,Draw ; Get next letter if counter zero.
00650 LD A,(Char) ; Get the current Letter.
00660 LD HL,(Coord) ; Get the screen coordinates.
00670 RES 5,A ; Force letter to Upper case.
00680 CP 85 ; If its a 'U'
00690 JR Z,UP ; then go to UP
00700 CP 68 ; If its a 'D'
00710 JR Z,DN ; then go to down.
00720 CP 90 ; If its a 'Z'
00730 JR Z,RTDN ; then go to Right-Down.
00740 CP 86 ; If its a 'V'
00750 JR Z,LFDN ; then go to Left-Down.
00760 CP 88 ; If its a 'X'
00770 JR Z,LFUP ; then go to Left-Up.
00780 CP 89 ; If its a 'Y'
00790 JR Z,RTUP ; then go to Right-Up.
00800 RT CP 82 ; If its not a 'R'
00810 JR NZ,LF ; then go to Left.
00820 INC L ; If 'R' then Inc
00830 JR Plot ; Xlo it.
00840 LF CP 76 ; If no 'L' then goto
00850 JR NZ,Badchr ; Invalid Argument error.
00860 DEC L ; Dec X coord.
00870 JR Plot ; Plot it.
00880 RTDN INC L ; Inc X coord and
00890 JR DN ; and Dec Y coord.
00900 LFDN DEC L ; Dec X coord and
00910 JR DN ; dec Y coord.
00920 LFUP DEC L ; Dec X coord
00930 JR UP ; and inc Y coord.
00940 RTUP INC L ; Inc X coord and
00950 UP INC H ; Inc Y coord.
00960 LD A,H ; See if the Y coord is
00970 CP 192 ; within range.
00980 JR NZ,Plot ; If ok then plot it.
00990 LD H,0 ; If past the top, then
01000 JR Plot ; start it at the bottom again.
01010 DN DEC H ; Dec the Y coord.
01020 LD A,H ; See if the Y coord is past the
01030 CP 255 ; bottom of the screen.
01040 JR NZ,Plot ; If ok then plot it.
01050 LD H,191 ; If so the start at the top again.
01060 Plot LD (Coord),HL ; Save the newly adjusted coords.
01070 LD A,(Char) ; If the current Letter is lower
01080 BIT 5,A ; case the dont plot to the screen.
01090 JR NZ,Nextpx ; Go back to next command.
01100 PUSH BC ; Save the String length.
01110 CALL PIXEL ; Plot or Unplot the Pixel
01120 POP BC ; Get the length back.
01130 JR Nextpx ; Go back and do next command.
01140 Badchr RST 8 ; Invalid Argument Error if the
01150 DEFB 9 ; letter isn't recognised.
01160 EXIT LD HL,(Chadd) ; Load the Chadd pointer into HL.
01170 LD A,(HL) ; Repeat the complete Sprite routine
01180 CP 59 ; if a ';' is the next character.
01190 JP Z,Again ; Go back to the beginning.
01200 RET ; if not return to BASIC.
01210 EVALU CALL #1BE5 ; Rom call to evaluate the expression
01220 CALL #1F23 ; Rom call to put result in the BC reg.
01230 LD A,B ; If the number is less than 256
01240 CP 0 ; then return with out an error
01250 RET Z ;
01260 Interr RST 8 ; Interger out of Range
01270 DEFB 10 ; Error.
01280 PIXEL LD BC,(Coord) ;----------------------------
01290 LD A,191 ; This routine was in the 2068
01300 SUB B ; technical manual. (page 122)
01310 RET C ; It calculates the address of
01320 LD B,A ; the coordinates and the pixel
01330 AND #C0 ; position.
01340 RRA ;
01350 RRA ;
01360 RRA ;
01370 LD H,A ;
01380 LD A,B ;
01390 AND 7 ;
01400 OR H ;
01410 OR #40 ;
01420 LD H,A ;
01430 LD A,C ;
01440 RLCA ;
01450 RLCA ;
01460 RLCA ;
01470 AND #C7 ;
01480 LD L,A ;
01490 LD A,B ;
01500 AND #38 ;
01510 OR L ;
01520 RLCA ;
01530 RLCA ;
01540 LD L,A ;
01550 LD A,C ;
01560 AND 7 ;
01570 LD B,A ;----------------------------
01580 LD A,(mask) ;
01590 LD C,A ;
01600 LD A,1 ; This routine creates a mask
01610 INC B ; that will point to the
01620 Rotat RRCA ; pixel in the display file
01630 DJNZ Rotat ;(byte.
01640 BIT 0,C ; See if pixel is to be set
01650 JR Z,Reset ; or reset
01660 OR (HL) ; Set pixel in the display file
01670 LD (HL),A ; by ORing it with result mask.
01680 RET
01690 Reset CPL ; Reset the pixel by inverting
01700 AND (HL) ; and ANDing the result mask.
01710 LD (HL),A ;
01720 RET
01730 Magni DEFB 00 ; Declare some room for Variables.
01740 Char DEFB 00 ;
01750 Strad DEFW 0000 ;
01760 Coord DEFW 0000 ;
01770 mask DEFW 00 ;
1 REM > SPRITE GRAPHIC DEMO <
5 PRINT "Use curser Keys '5678' to move"
6 PRINT "Use Keys 1 and 2 magnify"
10 LET p$="RRRVZZZVXXXVUUU"
20 LET x=100: LET y=100: LET m=5: LET oldx=x: LET oldy=y
30 RANDOMIZE USR 50000: LPRINT p$,m+10,oldx,oldy
35 LET m=m-(INKEY$="1" AND m>0)+(INKEY$="2" AND m<9)
40 RANDOMIZE USR 50000: LPRINT p$,m,x,y
50 LET oldx=x: LET oldy=y
60 LET x=x-(((INKEY$="5")*4) AND x>0)+(((INKEY$="8")*4) AND x<
250)
70 LET y=y-(((INKEY$="6")*4) AND y>0)+(((INKEY$="7")*4) AND y<
165)
100 GO TO 30
500 RANDOMIZE USR 100: LOAD "Sprite.C1"CODE 50000: RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.