Here is a REM generator USR routine that I would like to share with other avid TS2068 fans.
Although the ability to save and load bytes separately is very handy, there are times when it might be convenient to be able to save/load relocatable USR routines, print fonts, UDG’s, etc., with the program they are to be used with.
If these bytes are stored in a REM (I think I hear my TS1000 chuckling softly to itself), then they are protected from RUN/CLEAR, and the entire program can be saved/loaded as one unit.
I modified a routine written by Gregory C. Harder for the TS1500 (see SWN 3:4 pg. 20) to allow for the start of the program area not being fixed in memory, as it is on the TS1000/1500. Automatic line renumbering of the REM to line 0 was added to protect the REM from unintentional editing and/or deletion.
Here is the disassembly:
Hexcode Mnemonic Remarks
010000 LD BC, 0000 ;poke with
;spaces
;required + 2
2A535C LD HL, (prog) ;
23 INC HL ;
3600 LD (HL),00 ;line #0
23 INC HL ;
23 INC HL ;
70 LD (HL),B ;
2B DEC HL ;
71 LD (HL),C ;
23 INC HL ;
23 INC HL ;
23 INC HL ;
0B DEC BC ;
0B DEC BC ;
C5 PUSH BC ;
E5 PUSH HL ;
CDBB12 CALL cins ;make room
E1 POP HL ;
C1 POP BC ;
362A LD (HL),"*" ;fill in REM
;with "*"
23 INC HL ;
0B DEC BC ;
78 LD A,B ;
B1 OR C ;
20F8 JR NZ,F8 ;
C9 RET ;done!
After typing in the code with you favorite hex-loader, and then saving, it can then be loaded to any address, as it is completely relocatable.
The routine fills out the REM with asterisks, which are subsequently overwritten with your data bytes. I for some reason you are impartial to asterisks, simply poke the appropriate address with the code of the CHR$ you prefer.
Poke the second and third addresses of the code, low/high, with the number of spaces required plus 2 extra, ie., if you need 545 spaces for your code, poke the address with the hexadecimal equivalent of 547 (23/02…low/high order).
Before calling the routine, enter “1 REM”. This will be changed to 0 REM and filled out with the number of spaces you poked into the code. Try to avoid listing the REM after placing your data into it. Otherwise you might get an error message such as “invalid color”, etc. Remember, since the start of the program is not fixed, only relocatable USR routines should be stored in the REM.
For the benefit of those who are not also TS1000 fans, find the address of the first asterisks by entering “PRINT PEEK 23635+PEEK 23636*256+5”. This is where your first byte of code should start.
I really enjoy the articles, programs, letters, and helpful hints from other readers. Hopefully someone will benefit from this brief article and will be encouraged to share some of their knowledge with the rest of us too.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.