Fast Graph

See all articles from CATS v1 n9
Author(s): Gordon Young
Publication: CATS Newsletter
Pub Details: CATS v1 n9 (Volume 1, Issue 9)
Date: December 1983
Pages: 6-7

The following program is reprinted from the Z-West newsletter, of Vista, CA, with permission. No author is given – I assume that it was written by the publisher, Gordon Young.

“This month’s presentation is a graph subroutine you can incorporate into your own program. This one is not in BASIC and will be printed onto your screen in about one second! The “Example” program will give you an idea of how it works (in BASIC).

You first need to reserve at least 215 bytes of memory for the machine code routine. This is easily accomplished by entering: 1 REM (followed by 215 characters [spaces, periods, numbers, anything!]). It is a good idea to do this in FAST mode. Keep in mind that this must be line number 1 (one). When you have completed line one, enough memory has been reserved to enter the machine code routine, and now you need a simple assembler program to enter the MC code numbers. Figure#1 is a program to do the entering of the numbers. You can now type RUN and begin entering code numbers from the listing. Enter the listing from left to right (top to bottom). When all the numbers have been entered, break out of the assembler by entering any letter to give an error report. Press ENTER once again and the computer will return to the program listing. Now, remove lines 2 through 12 and get rid of the assembler. SAVE the program so far (a crash will require you to start all over!). Your BASIC listing should now look something like figure #2. If everything has gone well so far, you can run the routine by entering RAND USR 16514 (& ENTER). The bar graph should now appear on your screen. If not, you better start checking your entries! It should look like that of figure #3.

Enter the rest of the BASIC “EXAMPLE” program and try it out. There are some small limitations you must take note of. You can enter 12 pieces of data to represent each month. The addresses that recieve this are: 16582-16593, so when you make use of the program, use these addresses to POKE your data into. Another important aspect of this routine is that data must be a number between 1 and 18. This means you will have to scale your data down to fit. Zero and 19 will cause the program to crash!

Room has been made to the right of the graph so that you may print levels of values down the side. You can see that there are nine horizontal divisions. Here again, you will have to scale the highest value to the ninth division (18). Although these small drawbacks require extra BASIC programming, the speed of this routine will make up for this problem.

If you are a new ZX/TS user, and have not had the chance to see how fast assembly language programming [sic.] is, this is a good example.

Z-WEST, September, 1983, 2(9), 3-4.

FIGURE #1

   1 REM .......................................................................................................................................................................................................................
2 FOR N=16514 TO 167[illegible]0
4 INPUT A
6 POKE N,A
8 PRINT AT 21,4;N,TAB 10;A
10 SCROLL
12 NEXT N

BASIC “EXAMPLE” PROGRAM

   1 REM \' D E£RND2\!.Y/77Q-X RETURN  4 SAVE GOSUB ?1? RETURN  4 GOSUB 2<\' 5 E£RND\!./ SAVE Y\: ?1? RETURN  4 INPUT :;Y\''?$7? RETURN  4 PLOT />$£\ '\.'\!.)?\''\: \ '\!:"(LEN RND?\ '  GOSUB ?ABS RND\!'MCHR$ RND??< GOSUB ?ABS RNDUCHR$ RND? GOSUB ?USR RNDE£RND\!.Q\|:\' 5  GOSUB PI1? RETURN  4 NEXT GOSUB ?USR RND\''\'' GOSUB ?USR RNDUVAL RNDXMVAL RND RETURN \' 4?Y$MVAL RND\' LEN RND GOSUB ?ABS RND\' ?\ ' GOSUB ?USR RNDY MCHR$ RNDE£RND)-\ ' GOSUB ???\' * 5RNDINKEY$ GOSUB K/*J F M A M J J A S O N DTAN
   2 PRINT "PRESS ANY KEY FOR A SAMPLE OF"
3 PRINT TAB 8;"THIS GRAPH."
4 IF INKEY$="" THEN GOTO 4
5 CLS
6 GOTO 11
8 SAVE "GRAP▒"
9 RUN
10 STOP
11 RAND USR 16514
12 FOR N=1 TO 250
13 NEXT N
14 CLS
15 PRINT TAB 10;"ENTER DATA"
16 FOR N=1 TO 12
17 INPUT A
18 IF A<1 OR A>18 THEN PRINT DATA OUT OF RANGE"
19 IF A<1 OR A>18 THEN GOTO 17
21 POKE (16581+N),A
22 PRINT A;" ";
23 NEXT N
24 CLS
25 GOTO 11

FIGURE #2

SECTION 1
1 41 0 42 12 64
30 9 62 24 35 35
54 22 61 254 0 32
248 237 74 29 123 254
0 32 237 30 19 1
33 0 42 12 64 9
SECTION 2
126 254 118 32 3 35
24 248 62 5 119 29
123 254 0 32 238 14
25 62 3 119 13 35
121 254 0 32 246 24
18 13 12 2 6 9
17 15 3 5 2 8
11 16 198 64 84 2
0 237 75 210 64 10
50 214 64 80 89 19
237 83 210 64 58 214
64 95 237 75 212 64
42 12 64 9 54 136
1 33 0 237 66 29
123 254 0 32 243 237
75 212 64 3 3 237
67 212 64 58 197 64
61 50 197 64 254 1
32 195 62 13 50 197
64 1 198 64 237 67
210 64 1 84 2 237
67 212 64 62 0 50
214 64 42 12 64 17
150 2 237 90 84 93
1 23 0 33 64 65
237 176 24 23 47 0
43 0 50 0 38 0
50 0 47 0 47 0
38 0 56 0 52 0
51 0 41 201
Fig. 3 Bar graph output, months J to D
Fig. 3 Bar graph output, months J to D

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.