(NOTE: REPRINTING OR REPRODUCING THIS COLUMN WITHOUT THE EXPRESSED WRITTEN PERMISSION OF THE AUTHOR IS HEREBY PROHIBITED. FOR PERMISSION, WRITE THE AUTHOR IN CARE OF THIS PUBLICATION.)
If you are used to SAVEing SCREEN$ files, you may have noticed that the file size is rather large especially if you LOAD or SAVE using cassette storage medium. The file is 6912 bytes long. Another problem to overcome is that if you want to store more than four or five SCREEN$’s in RAM memory, there is hardly any memory left for your programs. This months utility will COMPRESS a typical SCREEN$ file up to as much as 1/2 its usual size. In addition, a header is automatically included in the SAVED file which will resolve the compressed SCREEN$ back to its full size onto the screen by simply using RANDOMIZE USR (address). The following program will SAVE the compressed SCREEN$ CODE at address 40246 and you will be shown the file length if you wish to write it down. When you are ready to LOAD the compressed file into your own program, you can LOAD it to any legal address then “call” that address to get your expanded SCREEN$. The following program will POKE in the CODE then prompt you to INPUT the file name of the SCREEN$ that you want to compress. It will then LOAD it and temporarily store it. Next you’ll be asked what name you want to give the compressed SCREEN$. The SCREEN$ will be instantly compressed and you will be notified of the start address and byte length of the file. Now, a prompt to press any key when you are ready to SAVE your file. Don’t worry, your compressed file is already stored at address 40246. This utility can be easily modified by you to work with any disk system. I use this utility alot to animate as many as 15 compressed SCREEN$ by LOADing them consecutively in memory then calling them in sequence to simulate animation. The CODE is not relocatable and is 132 bytes long. Have fun!
“CMPRES” By Michael J. Di Rienzo
10 CLEAR 36611: LET store=36720: LET recall=36732: LET compress=36612: GO SUB 100
20 INPUT "What is the file name to LOAD? ";n$
30 LOAD n$SCREEN$ : RANDOMIZE USR store
40 INPUT "What is the file name to SAVE? ";n$: RANDOMIZE USR recall
50 RANDOMIZE USR compress: LET L=USR 40192: LET L=L-40246
60 PRINT INK 2; PAPER 5;AT 10,0;"File:""";n$;"""CODE 40246,";L; FLASH 1;AT 11,5;"Press any key to SAVE": PAUSE 0
70 SAVE n$CODE 40246,L
80 CLS : RANDOMIZE USR 40246: PRINT INK 1; FLASH 1;AT 10,0;"To resolve the compressed file back to the screen in the futureRANDOMIZE USR (Starting address where CODE is LOADed!)"
90 STOP
100 LET t=0
110 FOR N=36612 TO 36743
120 READ a: POKE n,a: LET t=t+a
130 NEXT n: IF t<>12070 THEN PRINT FLASH 1;"Data Error! Recheck DATA line.": STOP
140 RETURN
150 DATA 17,0,157,33,16,143,1,98,0,237,176,201,197,209,33,100,0,25,235,33,0,64,14,1,126,167,40,9,254,255,40,5,237,160,3,24,21,71,121,60,35,40,7,126,184,32,3,12,24,243,120,18,19,121,18,19,14,1,124,254,91,32,217,213,193,201,17,0,64,221,33,46,0,221,9,122,254,91,200,221,126,0,167,40,10,254,255,40,6,18,19,221,35,24,236,221,70,1,18,19,16,252,221,35,221,35,24,223
160 DATA 17,0,157,33,0,64,1,0,24,237,176,201,17,0,64,33,0,157,1,0,24,237,176,201
CMPRES.B1 m/c
compress 36612 8F04 LD DE,40192
36615 8F07 LD HL,36624
36618 8F0A LD BC,98
36621 8F0D LDIR
36623 8F0F RET
36624 8F10 PUSH BC
36625 8F11 POP DE
36626 8F12 LD HL,100
36629 8F15 ADD HL,DE
36630 8F16 EX DE,HL
36631 8F17 LD HL,16384
36634 8F1A LD C,1;
36636 8F1C LD A,(HL)
36637 8F1D AND A
36638 8F1E JR Z,36649
36640 8F20 CP 255;
36642 8F22 JR Z,36649
36644 8F24 LDI
36646 8F26 INC BC
36647 8F27 JR 36670
36649 8F29 LD B,A
36650 8F2A LD A,C
36651 8F2B INC A
36652 8F2C INC HL
36653 8F2D JR Z,36662
36655 8F2F LD A,(HL)
36656 8F30 CP B
36657 8F31 JR NZ,36662
36659 8F33 INC C
36660 8F34 JR 36649
36662 8F36 LD A,B
36663 8F37 LD (DE),A
36664 8F38 INC DE
36665 8F39 LD A,C
36666 8F3A LD (DE),A
36667 8F3B INC DE
36668 8F3C LD C,1;
36670 8F3E LD A,H
36671 8F3F CP 91; [
36673 8F41 JR NZ,36636
36675 8F43 PUSH DE
36676 8F44 POP BC
36677 8F45 RET
36678 8F46 LD DE,16384
36681 8F49 LD IX,46
36685 8F4D ADD IX,BC
36687 8F4F LD A,D
36688 8F50 CP 91; [
36690 8F52 RET Z
36691 8F53 LD A,(IX+0)
36694 8F56 AND A
36695 8F57 JR Z,36707
36697 8F59 CP 255;
36699 8F5B JR Z,36707
36701 8F5D LD (DE),A
36702 8F5E INC DE
36703 8F5F INC IX
36705 8F61 JR 36687
36707 8F63 LD B,(IX+1)
36710 8F66 LD (DE),A
36711 8F67 INC DE
36712 8F68 DJNZ 36710
36714 8F6A INC IX
36716 8F6C INC IX
36718 8F6E JR 36687
store 36720 8F70 LD DE,40192
36723 8F73 LD HL,16384
36726 8F76 LD BC,6144
36729 8F79 LDIR
36731 8F7B RET
recall 36732 8F7C LD DE,16384
36735 8F7F LD HL,40192
36738 8F82 LD BC,6144
36741 8F85 LDIR
36743 8F87 RET
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.