Home » Archimedes archive » Archimedes World » AW-1996-03-Disc 2.adf » !AcornAns_AcornAns » November/Squash/Sample
November/Squash/Sample
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Archimedes World » AW-1996-03-Disc 2.adf » !AcornAns_AcornAns |
Filename: | November/Squash/Sample |
Read OK: | ✔ |
File size: | 0586 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
Writing a game or application & short of disc space to get your code onto a single 800Kb floppy? Why not use the Squash module to compress some of your resouce files which can then be loaded & decompressed by your main program at run time, thus saving on disc space? This is a simple demo of how to use the Squash SWIs to do just that & this file is the sample data which is going to get squashed/unsquashed by the demo! 'Squash' loads, compresses & resaves me with the file name 'SampleX', using the Squash file format & Squash module SWIs. 'UnSquash' loads 'SampleX', & unsquashes it. So that you can check this has been done correctly, it then treats the data as text & prints it, however in real applications your compressed data could be of any type & once decompressed to memory, would be treated just as if it had been stored on disc uncompressed & loaded directly into that same memory. Disadvantages to storing data on disc in a compressed format (& using a one-step decompression process): * Need to have enough RAM to store both compressed & decompressed versions at same time, during decompression, plus room for workspace. Advantages: * Save on disc space. * Although decompression takes some time, due to faster file loading (of the smaller compressed file) overall loading/decompression time may be faster than loading of the uncompressed file.
00000000 0d 0a 57 72 69 74 69 6e 67 20 61 20 67 61 6d 65 |..Writing a game| 00000010 20 6f 72 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 | or application | 00000020 26 20 73 68 6f 72 74 20 6f 66 20 64 69 73 63 20 |& short of disc | 00000030 73 70 61 63 65 20 74 6f 20 67 65 74 20 79 6f 75 |space to get you| 00000040 72 20 63 6f 64 65 20 6f 6e 74 6f 20 61 0d 0a 73 |r code onto a..s| 00000050 69 6e 67 6c 65 20 38 30 30 4b 62 20 66 6c 6f 70 |ingle 800Kb flop| 00000060 70 79 3f 0d 0a 0d 0a 57 68 79 20 6e 6f 74 20 75 |py?....Why not u| 00000070 73 65 20 74 68 65 20 53 71 75 61 73 68 20 6d 6f |se the Squash mo| 00000080 64 75 6c 65 20 74 6f 20 63 6f 6d 70 72 65 73 73 |dule to compress| 00000090 20 73 6f 6d 65 20 6f 66 20 79 6f 75 72 20 72 65 | some of your re| 000000a0 73 6f 75 63 65 20 66 69 6c 65 73 20 77 68 69 63 |souce files whic| 000000b0 68 0d 0a 63 61 6e 20 74 68 65 6e 20 62 65 20 6c |h..can then be l| 000000c0 6f 61 64 65 64 20 26 20 64 65 63 6f 6d 70 72 65 |oaded & decompre| 000000d0 73 73 65 64 20 62 79 20 79 6f 75 72 20 6d 61 69 |ssed by your mai| 000000e0 6e 20 70 72 6f 67 72 61 6d 20 61 74 20 72 75 6e |n program at run| 000000f0 20 74 69 6d 65 2c 20 74 68 75 73 0d 0a 73 61 76 | time, thus..sav| 00000100 69 6e 67 20 6f 6e 20 64 69 73 63 20 73 70 61 63 |ing on disc spac| 00000110 65 3f 0d 0a 0d 0a 54 68 69 73 20 69 73 20 61 20 |e?....This is a | 00000120 73 69 6d 70 6c 65 20 64 65 6d 6f 20 6f 66 20 68 |simple demo of h| 00000130 6f 77 20 74 6f 20 75 73 65 20 74 68 65 20 53 71 |ow to use the Sq| 00000140 75 61 73 68 20 53 57 49 73 20 74 6f 20 64 6f 20 |uash SWIs to do | 00000150 6a 75 73 74 20 74 68 61 74 20 26 20 74 68 69 73 |just that & this| 00000160 0d 0a 66 69 6c 65 20 69 73 20 74 68 65 20 73 61 |..file is the sa| 00000170 6d 70 6c 65 20 64 61 74 61 20 77 68 69 63 68 20 |mple data which | 00000180 69 73 20 67 6f 69 6e 67 20 74 6f 20 67 65 74 20 |is going to get | 00000190 73 71 75 61 73 68 65 64 2f 75 6e 73 71 75 61 73 |squashed/unsquas| 000001a0 68 65 64 20 62 79 20 74 68 65 0d 0a 64 65 6d 6f |hed by the..demo| 000001b0 21 0d 0a 0d 0a 27 53 71 75 61 73 68 27 20 6c 6f |!....'Squash' lo| 000001c0 61 64 73 2c 20 63 6f 6d 70 72 65 73 73 65 73 20 |ads, compresses | 000001d0 26 20 72 65 73 61 76 65 73 20 6d 65 20 77 69 74 |& resaves me wit| 000001e0 68 20 74 68 65 20 66 69 6c 65 20 6e 61 6d 65 20 |h the file name | 000001f0 27 53 61 6d 70 6c 65 58 27 2c 20 75 73 69 6e 67 |'SampleX', using| 00000200 0d 0a 74 68 65 20 53 71 75 61 73 68 20 66 69 6c |..the Squash fil| 00000210 65 20 66 6f 72 6d 61 74 20 26 20 53 71 75 61 73 |e format & Squas| 00000220 68 20 6d 6f 64 75 6c 65 20 53 57 49 73 2e 0d 0a |h module SWIs...| 00000230 0d 0a 27 55 6e 53 71 75 61 73 68 27 20 6c 6f 61 |..'UnSquash' loa| 00000240 64 73 20 27 53 61 6d 70 6c 65 58 27 2c 20 26 20 |ds 'SampleX', & | 00000250 75 6e 73 71 75 61 73 68 65 73 20 69 74 2e 20 53 |unsquashes it. S| 00000260 6f 20 74 68 61 74 20 79 6f 75 20 63 61 6e 20 63 |o that you can c| 00000270 68 65 63 6b 20 74 68 69 73 20 68 61 73 0d 0a 62 |heck this has..b| 00000280 65 65 6e 20 64 6f 6e 65 20 63 6f 72 72 65 63 74 |een done correct| 00000290 6c 79 2c 20 69 74 20 74 68 65 6e 20 74 72 65 61 |ly, it then trea| 000002a0 74 73 20 74 68 65 20 64 61 74 61 20 61 73 20 74 |ts the data as t| 000002b0 65 78 74 20 26 20 70 72 69 6e 74 73 20 69 74 2c |ext & prints it,| 000002c0 20 68 6f 77 65 76 65 72 20 69 6e 0d 0a 72 65 61 | however in..rea| 000002d0 6c 20 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 79 |l applications y| 000002e0 6f 75 72 20 63 6f 6d 70 72 65 73 73 65 64 20 64 |our compressed d| 000002f0 61 74 61 20 63 6f 75 6c 64 20 62 65 20 6f 66 20 |ata could be of | 00000300 61 6e 79 20 74 79 70 65 20 26 20 6f 6e 63 65 0d |any type & once.| 00000310 0a 64 65 63 6f 6d 70 72 65 73 73 65 64 20 74 6f |.decompressed to| 00000320 20 6d 65 6d 6f 72 79 2c 20 77 6f 75 6c 64 20 62 | memory, would b| 00000330 65 20 74 72 65 61 74 65 64 20 6a 75 73 74 20 61 |e treated just a| 00000340 73 20 69 66 20 69 74 20 68 61 64 20 62 65 65 6e |s if it had been| 00000350 20 73 74 6f 72 65 64 20 6f 6e 0d 0a 64 69 73 63 | stored on..disc| 00000360 20 75 6e 63 6f 6d 70 72 65 73 73 65 64 20 26 20 | uncompressed & | 00000370 6c 6f 61 64 65 64 20 64 69 72 65 63 74 6c 79 20 |loaded directly | 00000380 69 6e 74 6f 20 74 68 61 74 20 73 61 6d 65 20 6d |into that same m| 00000390 65 6d 6f 72 79 2e 0d 0a 0d 0a 0d 0a 44 69 73 61 |emory.......Disa| 000003a0 64 76 61 6e 74 61 67 65 73 20 74 6f 20 73 74 6f |dvantages to sto| 000003b0 72 69 6e 67 20 64 61 74 61 20 6f 6e 20 64 69 73 |ring data on dis| 000003c0 63 20 69 6e 20 61 20 63 6f 6d 70 72 65 73 73 65 |c in a compresse| 000003d0 64 20 66 6f 72 6d 61 74 20 28 26 20 75 73 69 6e |d format (& usin| 000003e0 67 20 61 0d 0a 6f 6e 65 2d 73 74 65 70 20 64 65 |g a..one-step de| 000003f0 63 6f 6d 70 72 65 73 73 69 6f 6e 20 70 72 6f 63 |compression proc| 00000400 65 73 73 29 3a 0d 0a 0d 0a 2a 20 4e 65 65 64 20 |ess):....* Need | 00000410 74 6f 20 68 61 76 65 20 65 6e 6f 75 67 68 20 52 |to have enough R| 00000420 41 4d 20 74 6f 20 73 74 6f 72 65 20 62 6f 74 68 |AM to store both| 00000430 20 63 6f 6d 70 72 65 73 73 65 64 20 26 20 64 65 | compressed & de| 00000440 63 6f 6d 70 72 65 73 73 65 64 20 76 65 72 73 69 |compressed versi| 00000450 6f 6e 73 0d 0a 20 20 61 74 20 73 61 6d 65 20 74 |ons.. at same t| 00000460 69 6d 65 2c 20 64 75 72 69 6e 67 20 64 65 63 6f |ime, during deco| 00000470 6d 70 72 65 73 73 69 6f 6e 2c 20 70 6c 75 73 20 |mpression, plus | 00000480 72 6f 6f 6d 20 66 6f 72 20 77 6f 72 6b 73 70 61 |room for workspa| 00000490 63 65 2e 0d 0a 0d 0a 0d 0a 41 64 76 61 6e 74 61 |ce.......Advanta| 000004a0 67 65 73 3a 0d 0a 0d 0a 2a 20 53 61 76 65 20 6f |ges:....* Save o| 000004b0 6e 20 64 69 73 63 20 73 70 61 63 65 2e 0d 0a 2a |n disc space...*| 000004c0 20 41 6c 74 68 6f 75 67 68 20 64 65 63 6f 6d 70 | Although decomp| 000004d0 72 65 73 73 69 6f 6e 20 74 61 6b 65 73 20 73 6f |ression takes so| 000004e0 6d 65 20 74 69 6d 65 2c 20 64 75 65 20 74 6f 20 |me time, due to | 000004f0 66 61 73 74 65 72 20 66 69 6c 65 20 6c 6f 61 64 |faster file load| 00000500 69 6e 67 0d 0a 20 20 28 6f 66 20 74 68 65 20 73 |ing.. (of the s| 00000510 6d 61 6c 6c 65 72 20 63 6f 6d 70 72 65 73 73 65 |maller compresse| 00000520 64 20 66 69 6c 65 29 20 6f 76 65 72 61 6c 6c 20 |d file) overall | 00000530 6c 6f 61 64 69 6e 67 2f 64 65 63 6f 6d 70 72 65 |loading/decompre| 00000540 73 73 69 6f 6e 20 74 69 6d 65 0d 0a 20 20 6d 61 |ssion time.. ma| 00000550 79 20 62 65 20 66 61 73 74 65 72 20 74 68 61 6e |y be faster than| 00000560 20 6c 6f 61 64 69 6e 67 20 6f 66 20 74 68 65 20 | loading of the | 00000570 75 6e 63 6f 6d 70 72 65 73 73 65 64 20 66 69 6c |uncompressed fil| 00000580 65 2e 0d 0a 0d 0a |e.....| 00000586