Compresses a full TS2068 screen into a smaller block of code and decodes it back again. You pick the address where the coded picture will go (55200 is suggested), then load a SCREEN$, either the next one on the tape or one by name. A 185-byte machine code routine at 55000 encodes the screen and the program reports the coded length next to the size of a normal screen. A keypress clears the display and a second routine at 55130 rebuilds the picture from the coded copy, after which the coded block can be saved as CODE.
A sample screen follows the program on the tape: the "Print a Page" screen from Pixel Print Professional. In testing it compressed to 4771 bytes.
Program Analysis
Program Structure
- Line 400 (the auto-run line):
CLEAR 54999, load thepico.C1machine code, then go to line 30. - Lines 30–78: ask for the destination address
v, store it as a 16-bit value in 23728/23729, and load the screen. - Lines 100–140: call the encoder at 55000, then read the coded length back from 23728/23729 and print it.
- Lines 150–210: store the address again, wait for a key, and call the decoder at 55130.
- Lines 220–260: optionally
SAVE n$ CODE v,x. - Line 300: saves the BASIC with
LINE 400.
The Encoding
The encoder walks the display file and attributes from 16384. Non-zero bytes are copied to the output unchanged. A zero byte is written once and followed by a two-byte count of the zeros in that run, so large blank areas shrink to three bytes each. Runs of any other value are not compressed, so the saving depends on how much of the picture is empty. The decoder reverses the process, copying literal bytes back to the screen and expanding each zero-and-count entry. BASIC and the machine code pass values through the two bytes at 23728/23729: the destination address on the way in and the coded length on the way out.
Notable Techniques
- The two bytes at 23728/23729 carry the parameter and the result between BASIC and the machine code, so no
USRreturn value is needed. POKE 23728,v-256*INT (v/256): POKE 23729,INT (v/256)splits the address into low and high bytes.- The auto-run line comes after the main program and uses
GO TO 30to start it, soCLEARand the code load happen only once.
Potential Issues
- Line 140 gives the normal screen length as 6192 bytes. A full screen with attributes is 6912 bytes.
- Line 230 loops back to itself instead of to the
INPUTat line 220, so any answer other thanyornhangs the program until BREAK.
This program comes from a Larken disk in the TS User Group collection. For tape, the LKDOS prefixes were removed, the 16-bit LKDOS POKE of the address was replaced with two ordinary POKEs, and the disk-load option now loads a screen by name from tape. It was tested in ZEsarUX.
Source Code
10 REM PICO DEMO
20 RANDOMIZE USR 100: OPEN #4,"dd"
30 CLS : PRINT "Where in memory do you want the picture data stored?"
40 PRINT ''"(Recommended 55200)"
50 INPUT v
60 PRINT #4: POKE 23728,v
65 CLS
70 INPUT "Load from tape or disk? t/d"' LINE i$
75 IF i$<>"t" AND i$<>"d" THEN GO TO 75
77 IF i$="t" THEN LOAD ""SCREEN$
78 IF i$="d" THEN INPUT "drive? (0-3) ";drv: PRINT #4: GO TO drv: INPUT "Name of picture? (eg. index.CM)"' LINE n$: PRINT #4: LOAD n$SCREEN$
100 RANDOMIZE USR 55000
110 CLS : PRINT "Picture now in memory in code."
120 LET x=PEEK 23728+256*PEEK 23729
130 PRINT '''"Picture code length = ";x
140 PRINT ''"Normal screen length = 6192 bytes"
150 PRINT #4: POKE 23728,v
170 PRINT '''"Press any key for decoded picture."
180 PAUSE 0
190 CLS
200 RANDOMIZE USR 55130
210 BEEP .1,3
220 INPUT "Save coded picture? y/n"; LINE s$
230 IF s$<>"y" AND s$<>"n" THEN GO TO 230
240 IF s$="y" THEN INPUT "name (eg, index.C$) "; LINE n$: PRINT #4: SAVE n$CODE v,x
250 IF s$="n" THEN PRINT #4: GO TO 2: PRINT #4: NEW
260 STOP
300 PRINT #4: SAVE "pico.B1" LINE 400: STOP
400 CLEAR 54999: PRINT #4: LOAD "pico.C1"CODE : GO TO 30Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


