11.07.2015 Views

Untitled - TRS-80 Color Computer Archive

Untitled - TRS-80 Color Computer Archive

Untitled - TRS-80 Color Computer Archive

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

FileCompressorChrisRogersThis Commodore 64 utility crunchesBASIC programs and other files sothat they occupy less room on a disk.Since smaller files load faster, compressed files can also transfer to andfrom disk faster than usual. A diskdrive is required.Using a clever programming technique, "File Compressor" makes itpossible to squeeze disk files into asmaller space than usual, whichconserves disk space and speeds upthe transfer of data between thecomputer and the disk drive. Onceyou have installed File Compressor,it can automatically compressBASIC programs during any SAVEand decode compressed programsinto normal form during a LOAD.You can also compress other datasuch as hi-res graphics screens.Typing File CompressorType in the program and save acopy. Because File Compressor iswritten in machine language, youmust enter it with the "MLX" machine language entry program listed elsewhere in this issue. Be sureto read the MLX article carefullybefore you attempt to use it. Whenyou run MLX, you'll be asked for astarting address and an ending address for the data you'll be entering.Here are the correct addresses:Starting address: C200Ending address: C617After you save File Compressor, you can load it with the command LOAD "COMPRESSOR",8,1(replace COMPRESSOR with thefilename you used when saving theprogram). After the program loads,type NEW and press RETURN toreset important BASIC pointers.Compressing BASICFile Compressor can be used twodifferent ways. The first method al-lows you to save and load a BASICprogram in compressed form. Toinstall File Compressor, load it intomemory; then type SYS 50600 andpress RETURN. To save a BASICprogram in compressed form, typeSAVE and press RETURN. Whenthe computer prompts you to entera filename, enter the desired nameand press RETURN again. The program is saved to disk in compressedformat. To load a compressedBASIC program, type LOAD andpress RETURN; then enter the desired filename at the prompt.To save or load BASIC programs in normal form, supply afilename with the LOAD or SAVEcommand. For instance, SAVE"TEST",8,1 saves the programTEST to disk as usual. Because itintercepts LOAD and SAVE commands that don't include a filename, File Compressor doesn'tsave compressed files to tape. However, you can still save and loadwith tape in uncompressed form byincluding a filename and adding,1,1 to the command. For instance,SAVE "TEST", 1,1 saves the program TEST to tape as a normalprogramfile.(Don't confuse File Compressor's crunching with normal program storage. You may have heardthat the computer automaticallycrunches BASIC program lines.When you type in a line, the computer stores the line number in onlytwo bytes and replaces every keyword with a one-byte symbol calleda token. This process, usually calledtokenization, reduces the size of theprogram significantly, since manyBASIC keywords are four or fivecharacters long. File Compressorbegins with the already-tokenizedBASIC program and crunches iteven further.)Compressing DataFile Compressor also lets you"crunch" and save the contents ofany memory area, which may include a hi-res graphics screen,sprite shapes, or any other sort ofdata. Of course, it also allows you toreload the data in uncompressedform. This routine demonstrateshow to save a memory area:10000 REM COMPRESSED SAVE SA=START OF SAVE: EA=END OF SAVE: FLS=FILENAME10002 POKE 6<strong>80</strong>,SA/256:POKE 679,SA-PEEK{6<strong>80</strong>)*25610004 POKE 682,EA/256:POKE 681,EA-PEEK(682)*25610006 FLS=FL?+",P,W"+CHR$(0):FOR 1=1 TO LEN(FL$)10008 POKE 831+1,ASC(MID$(FL$,I,1)+CHRS(0)):NEXT10010 SYS 50689:RETURNBefore it calls File Compressorwith SYS, the routine POKEs thestarring and ending addresses ofthe desired memory area into locations 679-6<strong>80</strong> and 681-682, respectively. You must also store theASCII characters for the disk filename in the zone beginning at location 832. Note that the filenamemust include the extension ,P,Wand end with a zero byte. This routine shows how to load a compressed file back into memory:10012 REM COMPRESSED LOAD SA=START OF LOAD: FLS=FILENAME10014 POKE 6<strong>80</strong>,SA/256:POKE 679,SA-PEEK(6<strong>80</strong>)*25610016 FL$=FLS+",P,R"+CHRS(0):FOR 1=1 TO LEN(FLS)10018 POKE 831+1,ASC(MIDS(FL$,I,1)+CHRS(0)):NEXT10020 SYS 50666:RETURNThis procedure is similar to theprevious routine. However, youneed only specify a beginning address for the load, and the filenameshould end with ,P,R. When thatpreparation is complete, SYS 50666calls File Compressor to decode thefile data and put it back in memory.Less Is MoreYou can use File Compressor without knowing how it works. However, you may be interested in aFebruary 1987 COMPUTE) 53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!