VU-CALC for the ZX81/TS1000-1500 is a good program, but it has some limitations. Among them:
1) Once you’ve started using the program, you can’t add, delete or edit BASIC lines at will. If you do, the program crashes.
2) The only way to get a print-out is with the COPY command.
3) Keyboard entry is quite slow.
Fortunately, modifications can easily be made which overcome these three limitations. The first one re-initializes VU-CALC’s machine code every time you re-enter the program through the “C” (CONTINUE) option. This allows you to add, delete and edit BASIC lines. The mod can be added to a copy of VU-CALC which has titles and formulas in it.
LOAD your copy of VU-CALC. If it has no titles or formulas in the grid, enter some. For example, enter titles into boxes A01 to A03 and C01 to C03. It will be useful later if you enter the title of the box itself: “A01” into box A01, etc. STOP the program, then enter a line to hold machine code and a loader for entering it:
14 REM 1234567890123456789012345678901234
6000 DIM A$(4)
6010 FOR F=19656 TO 19689
6020 INPUT A$
6030 POKE F, VAL A$
6040 PRINT A$;
6050 NEXT F
6060 DIM A$(0)
Line 6060 is of special interest. It will clear the variable A$ from memory. The program will then stop with report 3/6060. Any string variable (undimensioned or array) can be cleared in this manner. All other variables are left intact. Any dimensioned numeric variable (but not undimensioned variables) can also be cleared in this way.
Before loading the machine code, check to make sure the REM line is long enough. Enter PRINT PEEK 19653. If this prints 36 to the screen, you have enough space reserved. Start the loader using GOTO 6000, then enter the following numbers one at a time:
58 134 64 167 40 24 42 16
64 1 238 32 9 1 35 0
17 3 65 235 115 35 114 35
35 235 9 61 32 245 205 143
65 201
After the program stops, check the numbers on the screen against the listing, and re-do it if you find any errors. If all is well, edit line 2000 to read:
2000 LET Z=19656
SAVE the modified program “just in case”. You can now restart VU-CALC using GOTO 110. DON’T USE RUN! Enter the “C” option to CONTINUE. If you’ve made a mistake, you’ll get a messed up screen. Start over again after pulling the plug or resetting.
Here’s a hex disassembly for those who use a hex loader:
4CC8▒3A8640 LD A,(4086)
4CCB A7 AND A
4CCC 2818 JR Z CALL
4CCE 2A1040 LD HL,(VARS)
4CD1 01EE20 LD BC,20EE
4CD4 09 ADD HL,BC
4CD5 012300 LD BC,0023
4CD8 110341 LD DE,4103
4CDB EB POKE EX DE,HL
4CDC 73 LD (HL),E
4CDD 23 INC HL
4CDE 72 LD (HL),D
4CDF 23 INC HL
4CE0 23 INC HL
4CE1 EB EX DE,HL
4CE2 09 ADD HL,BC
4CE3 3D DEC A
4CE4 20F5 JR NZ POKE
4CE6 CD8F41 CALL CALL 418F
4CE9 C9 RET
4CEA 00 NOP
4CEB 00 NOP
Now that you can add and delete BASIC lines, it is possible to program custom print-outs. All the information in VU-CALC’s grid is stored in B$(2 TO 8424). Each box is 8 characters long. One byte separates each box. The first character of boxes in columns are 9 bytes apart.
A01 = B$(2 TO 9)
B01 = B$(11 TO 18)
The first character of boxes in rows are 234 bytes apart.
A01 = B$(2 TO 9)
A02 = B$(236 TO 243)
Using this information, it is possible to calculate the location of any box on the grid. Let’s have the computer do it. Add the following short demo routine to VU-CALC. It locates, PRINTs, and LPRINTs information from the grid boxes.
6000 PRINT "ENTER ROW/COLUMN: E.G. ""B03"""
6010 INPUT A$
6020 LET Z=9*(CODE A$-28)+2
6030 LET Z=Z+234*(VAL A$(2 TO)-1)
6040 PRINT A$;TAB 5;"B$(";Z;" TO ";Z+7;")";
6050 PRINT TAB 23;B$(Z TO Z+7)
6060 LPRINT B$(Z TO Z+7)
6070 GOTO 6010
Start the routine using GOTO 6000. When the cursor (in quotes) appears, enter the row and column number of a box containing information. Use the format: “D05”, “R27”, etc. The routine will print the location and contents of the box to the screen, and then LPRINT the contents. To stop this routine, press ENTER (only) when the cursor asks for input.
Finding and printing one box at a time isn’t very useful. Let’s assume that you want to print boxes A01 through A03 and C01 through C03. Calculate the beginning number of the first and third boxes in row A (which turn out to be 2 and 470). Calculate the beginning number of the first box in row C (which is 20). A short BASIC routine will print the information.
7000 FOR F=2 TO 20 STEP 18
7010 FOR G=F TO F+468 STEP 234
7020 PRINT B$(G TO G+7);" ";
7030 NEXT G
7040 PRINT
7050 NEXT F
7060 STOP
Line 7000 determines whether row A or C is printed. Line 7010 determines whether column 1, 2 or 3 is printed. It’s a little tricky, but if you’re confused then calculate by hand what the value of G will be for each pass through the loops. This will help you see what’s going on. For hard copy, change the PRINT statements to LPRINT.
You now have the ability to modify the program, and can program your own custom print routines, making the program more useful. VU-CALC is nearly 16K long, which doesn’t leave you much room beyond the short routines presented here. If you want to add more, you will need more than 16K. [See also SWN Vol. 1 “Byte-Pynchers” for info on condensing the existing BASIC to allow more room for changes -fn.]
The final change this time around involves speeding up the keyboard delays. This allows faster entry of data and formulas. There are two simple ways to speed up keyboard response.
1) Alter the value in the main timing loop.
CHANGE VALUE DESCRIPTION ORIGINAL VALUE POKE 17459,100 Main timing loop 0 POKE 17592,25 Cursor delay 10 POKE 17600,25 Cursor delay 10
Advantage: Everything is speeded up.
Disadvantage: Program messages are only printed for a split second, with no simple way to keep them on the screen longer.
2) Alter only the values of the two keyboard delays:
CHANGE VALUE DESCRIPTION ORIGINAL VALUE POKE 17783,16 LOAD DATA/TITLES 32 POKE 17981,16 ENTER FORMULA 32
Advantage: Keyboard response is faster for entering titles and formulas. Program messages are unaffected.
Disadvantage: The program takes its normal slow time in going from one option to the next.
It would be ideal to have fast response time and long delays for displaying messages. At present, the two are interactive. The authors of VU-CALC failed to include a subroutine to test if a key was still being pressed. Instead, they used delays to assure that a key has been released. Not only that, but in several cases they used the same delay to determine how long a message would be displayed. If I come up with ways of patching in other improvements, I’ll let you know via this magazine. Meanwhile, you’re encouraged to experiment with this and other options on your own.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.