Authors
Publication
Pub Details
Date
Pages
One of the fun things about using the TS2068 is the ability to PEEK and POKE in amongst the machine code and particularly when using TIMACHINE. This is the first in a series of articles I’ll write for TS2068 Up-Date on this subject. Bouquets or brick-bats are welcome!
For starters, let’s look at a scenario using the compiler Timachine. You have compiled a data file and entered about 18000 bytes of data. Then you decide you wish you had built in a routine to print the data to your big printer. It was only designed to print to the 2040 printer.
You have a choice: You can redesign the BASIC and recompile in which case you have to re-enter all the data (well, not really but I’ll come back to that); or you can PEEK out the data from the compiled code and using a simple routine in BASIC send the data to the big printer.
Once again, you will need the REM! LIST info which you should have kept when you compiled your program. If you didn’t do it at the time and you kept a copy of your BASIC program then go through the motion of compiling to get the runtime and variable lists and addresses.
Find the start address of the array or string containing the data. Remember the data really starts two bytes further on. For argument’s sake let’s say your array was d$(600,32) and let’s say that the start address listed was 40000 so that means that the data starts at 40002. In your BASIC program assign this to variable sl. By the way, don’t forget that Timachine limits arrays to two dimensions. Tough but that’s the way it is.
If all 600 subscripts are not. full, then you should know how many are used so far and this value should be in some variable, say, n. Look for n in your variables list and let’s hope your made it an integer when you compiled. If not the value will be in floating point notation. All is not lost if it is but it gets more difficult and I shall not go into that solution here. Assuming the value is indeed in integer notation, then n will be located at the address 33335 and the actual value of n will be at addresses 33335 and 33336. Use LET v1=PEEK 33335 + 256 * PEEK 33336 in BASIC to get this value.
Now build a FOR-NEXT loop to LPRINT the data to the big printer.
300 POR k = s1 10 s1+(v1 * 32) ,STEP 32
305 FOR m = 0 TO 31
310 LPRINI CHR$ PEEK (k + m);
313 NEXT m
320 LPRINT
330 NEXT k
This will not be as fast as a compiled routine would be, but it would be acceptable. As I said above, you don’t really have to re-enter all the data after you have recompiled a program. Here’s how I did it.
- Note the value of n (records entered so far).
- SAVE the data in your original compiled program by: SAVE “prog.C1″CODE start, len where start is the array start address + 2 and len is the total length of the array (600 * 32 = 19200).
- Restart the TS2068 and LOAD your newly recompiled program and make sure it is initialized by running it from the first entry point. ie, the first REM 1 OPEN #. LOAD “prog. C1″CODE, newstart where newstart is the new start address + 2 POKE the value n into the correct address.
- Proceed as you did in your earlier version.
On a different tack, here is a way to adapt the PRINT routine supplied with the Hacksel printer interface hardware to the Spectrum. This works on my emulator which is switched on by using OUT 244,3; whether it works on a real Spectrum, I know not. This technique should be adaptable for other CPI LPRINT routines.
- Change two ROM CALLS in the LPRINI code: CALL 0745h to CALL OC10 (at 65096 or FE48h) CALL 2009h to CALL 1F54 (at 65117 or FEDh) eg, CD4507 becomes CDI00C and you POKE the decimal equivalents into the right places).
- Now SAVE this and then CLEAR 64999 and LOAD the revised code into Spectrum.
- POKE 23749,0: POKE 23750,254 (These are the locations in the Spectrum Channel Info area corresponding to 26703 and 26704 in the TS2068.)
- POKE 65535 with 1 or 0 as required to turn the Sinclair character set off and the ASCII set on, and vice versa as instructed in the instructions for PRINT. In other words, this requirement is the same for the Spectrum and TS2068.
Products
Downloadable Media
Image Gallery
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.