Home » Archimedes archive » Archimedes World » AW-1996-03-Disc 2.adf » !AcornAns_AcornAns » November/Squash/Squash
November/Squash/Squash
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/Squash |
Read OK: | ✔ |
File size: | 0540 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10REM >Squash 20file$ = "Sample" 30PROCload_source_data 40PROCcompress_data 50PROCsave_compressed_data 60PROCdisplay_stats 70END 80: 90: 100DEF PROCcompress_data 110SYS "Squash_Compress", %1000, datasize% TO workspacesize%, maxoutputsize% 120compsize% = 20 + maxoutputsize% 130DIM comp% compsize%, work% workspacesize% 140: 150REM Now we set up the 20 byte Squash file's header 160$comp% = "SQSH" 170comp%!4 = datasize% 180comp%!8 = loadaddr% 190comp%!12 = execaddr% 200comp%!16 = 0 210: 220REM And now we compress the data! 230SYS "Squash_Compress", 0, work%, data%, datasize%, comp%+20, compsize%-20 TO status%,,,, endoutput% 240IF status%<>0 ERROR 0, "One step compression failed, status "+STR$status% 250ENDPROC 260: 270DEF PROCdisplay_stats 280PRINT "Source file size: ", datasize% 290PRINT "Compression workspace size: ", workspacesize% 300PRINT "Maximum compressed file size:", compsize% 310PRINT "Actual compressed file size: ", endoutput%-comp% 320PRINT 330ENDPROC 340: 350DEF PROCsave_compressed_data 360SYS "OS_File", 10, LEFT$(file$, 9)+"X", &FCA,, comp%, endoutput% 370ENDPROC 380: 390DEF PROCload_source_data 400LOCAL type% 410SYS "OS_File", 5, file$ TO objtype%,, loadaddr%, execaddr%, datasize% 420REM loadaddr,execaddr will typically hold the file's filetype & datestamp (see PRM 2-14) 430IF objtype%<>1 ERROR 0, "File '"+file$+"' does not exist" 440DIM data% datasize% 450SYS "OS_File", 255, file$, data%, 0 460ENDPROC
� >Squash file$ = "Sample" �load_source_data (�compress_data 2�save_compressed_data <�display_stats F� P: Z: d� �compress_data nKș "Squash_Compress", %1000, datasize% � workspacesize%, maxoutputsize% x#compsize% = 20 + maxoutputsize% �+� comp% compsize%, work% workspacesize% �: �4� Now we set up the 20 byte Squash file's header �$comp% = "SQSH" �comp%!4 = datasize% �comp%!8 = loadaddr% �comp%!12 = execaddr% �comp%!16 = 0 �: �#� And now we compress the data! �eș "Squash_Compress", 0, work%, data%, datasize%, comp%+20, compsize%-20 � status%,,,, endoutput% �E� status%<>0 � 0, "One step compression failed, status "+�status% �� : � �display_stats 0� "Source file size: ", datasize% "5� "Compression workspace size: ", workspacesize% ,0� "Maximum compressed file size:", compsize% 67� "Actual compressed file size: ", endoutput%-comp% @� J� T: ^� �save_compressed_data h>ș "OS_File", 10, �file$, 9)+"X", &FCA,, comp%, endoutput% r� |: �� �load_source_data �� type% �Gș "OS_File", 5, file$ � objtype%,, loadaddr%, execaddr%, datasize% �Z� loadaddr,execaddr will typically hold the file's filetype & datestamp (see PRM 2-14) �8� objtype%<>1 � 0, "File '"+file$+"' does not exist" �� data% datasize% �&ș "OS_File", 255, file$, data%, 0 �� �
00000000 0d 00 0a 0d f4 20 3e 53 71 75 61 73 68 0d 00 14 |..... >Squash...| 00000010 14 66 69 6c 65 24 20 3d 20 22 53 61 6d 70 6c 65 |.file$ = "Sample| 00000020 22 0d 00 1e 15 f2 6c 6f 61 64 5f 73 6f 75 72 63 |".....load_sourc| 00000030 65 5f 64 61 74 61 0d 00 28 12 f2 63 6f 6d 70 72 |e_data..(..compr| 00000040 65 73 73 5f 64 61 74 61 0d 00 32 19 f2 73 61 76 |ess_data..2..sav| 00000050 65 5f 63 6f 6d 70 72 65 73 73 65 64 5f 64 61 74 |e_compressed_dat| 00000060 61 0d 00 3c 12 f2 64 69 73 70 6c 61 79 5f 73 74 |a..<..display_st| 00000070 61 74 73 0d 00 46 05 e0 0d 00 50 05 3a 0d 00 5a |ats..F....P.:..Z| 00000080 05 3a 0d 00 64 14 dd 20 f2 63 6f 6d 70 72 65 73 |.:..d.. .compres| 00000090 73 5f 64 61 74 61 0d 00 6e 4b c8 99 20 22 53 71 |s_data..nK.. "Sq| 000000a0 75 61 73 68 5f 43 6f 6d 70 72 65 73 73 22 2c 20 |uash_Compress", | 000000b0 25 31 30 30 30 2c 20 64 61 74 61 73 69 7a 65 25 |%1000, datasize%| 000000c0 20 b8 20 77 6f 72 6b 73 70 61 63 65 73 69 7a 65 | . workspacesize| 000000d0 25 2c 20 6d 61 78 6f 75 74 70 75 74 73 69 7a 65 |%, maxoutputsize| 000000e0 25 0d 00 78 23 63 6f 6d 70 73 69 7a 65 25 20 3d |%..x#compsize% =| 000000f0 20 32 30 20 2b 20 6d 61 78 6f 75 74 70 75 74 73 | 20 + maxoutputs| 00000100 69 7a 65 25 0d 00 82 2b de 20 63 6f 6d 70 25 20 |ize%...+. comp% | 00000110 63 6f 6d 70 73 69 7a 65 25 2c 20 77 6f 72 6b 25 |compsize%, work%| 00000120 20 77 6f 72 6b 73 70 61 63 65 73 69 7a 65 25 0d | workspacesize%.| 00000130 00 8c 05 3a 0d 00 96 34 f4 20 4e 6f 77 20 77 65 |...:...4. Now we| 00000140 20 73 65 74 20 75 70 20 74 68 65 20 32 30 20 62 | set up the 20 b| 00000150 79 74 65 20 53 71 75 61 73 68 20 66 69 6c 65 27 |yte Squash file'| 00000160 73 20 68 65 61 64 65 72 0d 00 a0 15 24 63 6f 6d |s header....$com| 00000170 70 25 20 20 20 3d 20 22 53 51 53 48 22 0d 00 aa |p% = "SQSH"...| 00000180 18 63 6f 6d 70 25 21 34 20 20 3d 20 64 61 74 61 |.comp%!4 = data| 00000190 73 69 7a 65 25 0d 00 b4 18 63 6f 6d 70 25 21 38 |size%....comp%!8| 000001a0 20 20 3d 20 6c 6f 61 64 61 64 64 72 25 0d 00 be | = loadaddr%...| 000001b0 18 63 6f 6d 70 25 21 31 32 20 3d 20 65 78 65 63 |.comp%!12 = exec| 000001c0 61 64 64 72 25 0d 00 c8 10 63 6f 6d 70 25 21 31 |addr%....comp%!1| 000001d0 36 20 3d 20 30 0d 00 d2 05 3a 0d 00 dc 23 f4 20 |6 = 0....:...#. | 000001e0 41 6e 64 20 6e 6f 77 20 77 65 20 63 6f 6d 70 72 |And now we compr| 000001f0 65 73 73 20 74 68 65 20 64 61 74 61 21 0d 00 e6 |ess the data!...| 00000200 65 c8 99 20 22 53 71 75 61 73 68 5f 43 6f 6d 70 |e.. "Squash_Comp| 00000210 72 65 73 73 22 2c 20 30 2c 20 77 6f 72 6b 25 2c |ress", 0, work%,| 00000220 20 64 61 74 61 25 2c 20 64 61 74 61 73 69 7a 65 | data%, datasize| 00000230 25 2c 20 63 6f 6d 70 25 2b 32 30 2c 20 63 6f 6d |%, comp%+20, com| 00000240 70 73 69 7a 65 25 2d 32 30 20 b8 20 73 74 61 74 |psize%-20 . stat| 00000250 75 73 25 2c 2c 2c 2c 20 65 6e 64 6f 75 74 70 75 |us%,,,, endoutpu| 00000260 74 25 0d 00 f0 45 e7 20 73 74 61 74 75 73 25 3c |t%...E. status%<| 00000270 3e 30 20 85 20 30 2c 20 22 4f 6e 65 20 73 74 65 |>0 . 0, "One ste| 00000280 70 20 63 6f 6d 70 72 65 73 73 69 6f 6e 20 66 61 |p compression fa| 00000290 69 6c 65 64 2c 20 73 74 61 74 75 73 20 22 2b c3 |iled, status "+.| 000002a0 73 74 61 74 75 73 25 0d 00 fa 05 e1 0d 01 04 05 |status%.........| 000002b0 3a 0d 01 0e 14 dd 20 f2 64 69 73 70 6c 61 79 5f |:..... .display_| 000002c0 73 74 61 74 73 0d 01 18 30 f1 20 22 53 6f 75 72 |stats...0. "Sour| 000002d0 63 65 20 66 69 6c 65 20 73 69 7a 65 3a 20 20 20 |ce file size: | 000002e0 20 20 20 20 20 20 20 20 20 22 2c 20 64 61 74 61 | ", data| 000002f0 73 69 7a 65 25 0d 01 22 35 f1 20 22 43 6f 6d 70 |size%.."5. "Comp| 00000300 72 65 73 73 69 6f 6e 20 77 6f 72 6b 73 70 61 63 |ression workspac| 00000310 65 20 73 69 7a 65 3a 20 20 22 2c 20 77 6f 72 6b |e size: ", work| 00000320 73 70 61 63 65 73 69 7a 65 25 0d 01 2c 30 f1 20 |spacesize%..,0. | 00000330 22 4d 61 78 69 6d 75 6d 20 63 6f 6d 70 72 65 73 |"Maximum compres| 00000340 73 65 64 20 66 69 6c 65 20 73 69 7a 65 3a 22 2c |sed file size:",| 00000350 20 63 6f 6d 70 73 69 7a 65 25 0d 01 36 37 f1 20 | compsize%..67. | 00000360 22 41 63 74 75 61 6c 20 63 6f 6d 70 72 65 73 73 |"Actual compress| 00000370 65 64 20 66 69 6c 65 20 73 69 7a 65 3a 20 22 2c |ed file size: ",| 00000380 20 65 6e 64 6f 75 74 70 75 74 25 2d 63 6f 6d 70 | endoutput%-comp| 00000390 25 0d 01 40 05 f1 0d 01 4a 05 e1 0d 01 54 05 3a |%..@....J....T.:| 000003a0 0d 01 5e 1b dd 20 f2 73 61 76 65 5f 63 6f 6d 70 |..^.. .save_comp| 000003b0 72 65 73 73 65 64 5f 64 61 74 61 0d 01 68 3e c8 |ressed_data..h>.| 000003c0 99 20 22 4f 53 5f 46 69 6c 65 22 2c 20 31 30 2c |. "OS_File", 10,| 000003d0 20 c0 66 69 6c 65 24 2c 20 39 29 2b 22 58 22 2c | .file$, 9)+"X",| 000003e0 20 26 46 43 41 2c 2c 20 63 6f 6d 70 25 2c 20 65 | &FCA,, comp%, e| 000003f0 6e 64 6f 75 74 70 75 74 25 0d 01 72 05 e1 0d 01 |ndoutput%..r....| 00000400 7c 05 3a 0d 01 86 17 dd 20 f2 6c 6f 61 64 5f 73 ||.:..... .load_s| 00000410 6f 75 72 63 65 5f 64 61 74 61 0d 01 90 0b ea 20 |ource_data..... | 00000420 74 79 70 65 25 0d 01 9a 47 c8 99 20 22 4f 53 5f |type%...G.. "OS_| 00000430 46 69 6c 65 22 2c 20 35 2c 20 66 69 6c 65 24 20 |File", 5, file$ | 00000440 b8 20 6f 62 6a 74 79 70 65 25 2c 2c 20 6c 6f 61 |. objtype%,, loa| 00000450 64 61 64 64 72 25 2c 20 65 78 65 63 61 64 64 72 |daddr%, execaddr| 00000460 25 2c 20 64 61 74 61 73 69 7a 65 25 0d 01 a4 5a |%, datasize%...Z| 00000470 f4 20 6c 6f 61 64 61 64 64 72 2c 65 78 65 63 61 |. loadaddr,execa| 00000480 64 64 72 20 77 69 6c 6c 20 74 79 70 69 63 61 6c |ddr will typical| 00000490 6c 79 20 68 6f 6c 64 20 74 68 65 20 66 69 6c 65 |ly hold the file| 000004a0 27 73 20 66 69 6c 65 74 79 70 65 20 26 20 64 61 |'s filetype & da| 000004b0 74 65 73 74 61 6d 70 20 28 73 65 65 20 50 52 4d |testamp (see PRM| 000004c0 20 32 2d 31 34 29 0d 01 ae 38 e7 20 6f 62 6a 74 | 2-14)...8. objt| 000004d0 79 70 65 25 3c 3e 31 20 85 20 30 2c 20 22 46 69 |ype%<>1 . 0, "Fi| 000004e0 6c 65 20 27 22 2b 66 69 6c 65 24 2b 22 27 20 64 |le '"+file$+"' d| 000004f0 6f 65 73 20 6e 6f 74 20 65 78 69 73 74 22 0d 01 |oes not exist"..| 00000500 b8 15 de 20 64 61 74 61 25 20 64 61 74 61 73 69 |... data% datasi| 00000510 7a 65 25 0d 01 c2 26 c8 99 20 22 4f 53 5f 46 69 |ze%...&.. "OS_Fi| 00000520 6c 65 22 2c 20 32 35 35 2c 20 66 69 6c 65 24 2c |le", 255, file$,| 00000530 20 64 61 74 61 25 2c 20 30 0d 01 cc 05 e1 0d ff | data%, 0.......| 00000540