Home » Personal collection » Commodore disks » disk32a_commodore_disk_user_3_7.d64 » compression
compression
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 » Personal collection » Commodore disks » disk32a_commodore_disk_user_3_7.d64 |
Filename: | compression |
Read OK: | ✔ |
File size: | 1C69 bytes |
Load address: | 0801 |
Exec address: | 0000 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- Arnold website » magazines_cdu » magazines_cdu_cdu307_cdu307.d64 » compression
- Personal collection » Commodore disks » disk32a_commodore_disk_user_3_7.d64 » compression
File contents
10 ;********************************** 15 ;* DATA COMPRESSION * 20 ;*--------------------------------* 25 ;* N.HIGGINS 1989 * 30 ;*--------------------------------* 35 ;* METHOD: RUN LENGTH ENCODING * 40 ;* USING : MARKER(COUNT,CHAR) * 45 ;********************************** 50 ;* FIRST CALL THE ROUTINES AT:- * 55 ;* * 60 ;* COMPRESS - SYS $C000 * 65 ;* DECOMPER - SYS $C0B8 * 70 ;* * 75 ;* NOW ENTER THE MONITOR AND USE * 80 ;* THE COMMAND (MC110 C170) TO * 85 ;* SEE THE RESULTS. * 90 ;********************************** 95 ; 100 ; 105 ; 110 ; 115 ;-------------------------------- 120 ;POINTER TO THE END OF THE DATA 125 ;TO BE COMPRESSED. 130 ;-------------------------------- 135 ; 140 TEXTEND=TEXT+16 145 ; 150 MARKER=$EF 155 DATPNT=$FB 160 STOPNT=$FD 165 ; 170 ; 175 *=49152 180 ; 185 ; 190 ;-------------------------------- 195 ;SET POINTER TO DATA TO BE 200 ;COMPRESSED (TEXT) 205 ;SET POINTER TO STORE THE 210 ;COMPRESSED DATA (STORAGE) 215 ;-------------------------------- 220 ; 225 COMPRESS LDA #<TEXT 230 STA DATPNT 235 LDA #>TEXT 240 STA DATPNT+1 245 LDA #<STORAGE 250 STA STOPNT 255 LDA #>STORAGE 260 STA STOPNT+1 265 ; 270 ; 275 ;--------------------------------- 280 ;SET (ENDFLAG) TO ZERO 285 ;SET (COUNT) TO 1 290 ;GET BYTE/IS CARRY SET? 295 ;YES:GOTO [E] 300 ;STORE BYTE 305 ;[A] GET NEXT BYTE/IS CARRY SET? 310 ;YES:GOTO [E] 315 ;IS BYTE SAME AS PREVIOUS? 320 ;NO :GOTO [C] 325 ;YES:INCREMENT (COUNT) 330 ;IS (COUNT) =0 335 ;YES:OUTPUT MARKER($FF,CHAR) 340 ;SET (COUNT)=1/GOTO [A] 345 ;NO :GOTO [A] 350 ;--------------------------------- 355 ; 360 LDY #0 365 STY ENDFLAG 370 LDA #1 375 STA COUNT 380 JSR GETBYTE 385 BCS FINISH 390 STA CHARACTER 395 ; 400 AGAIN JSR GETBYTE 405 BCS LOOP 410 CMP CHARACTER 415 BNE LOOP2 420 CONTINUE INC COUNT 425 BNE AGAIN 430 LDA #MARKER 435 JSR PUTBYTE 440 LDA #$FF 445 JSR PUTBYTE 450 LDA CHARACTER 455 JSR PUTBYTE 460 JMP CONTINUE 465 ; 470 ; 475 ;-------------------------------- 480 ;[C] STORE BYTE 485 ;GET PREVIOUS BYTE/IS IT A MARKER? 490 ;YES:GOTO [F] 495 ;NO :IS (COUNT) <4 500 ;YES:GOTO [G] 505 ;NO :GOTO [F] 510 ;-------------------------------- 515 ; 520 LOOP2 STA STORE 525 LOOP LDA CHARACTER 530 CMP #MARKER 535 BEQ LOOP9 540 LDA COUNT 545 CMP #4 550 BCC LOOP5 555 ; 560 ; 565 ;-------------------------------- 570 ;[F] OUTPUT MARKER(COUNT,CHAR) 575 ;-------------------------------- 580 ; 585 LOOP9 LDA #MARKER 590 JSR PUTBYTE 595 LDA COUNT 600 JSR PUTBYTE 605 LDA CHARACTER 610 JSR PUTBYTE 615 ; 620 ; 625 ;-------------------------------- 630 ;[D] CHECK FLAG/IS IT SET? 635 ;YES:GOTO [E] 640 ;NO :GET STORED BYTE 645 ;SET (COUNT) TO 1/GOTO [A] 650 ;-------------------------------- 655 ; 660 LOOP6 LDA ENDFLAG 665 BMI FINISH 670 LDA STORE 675 STA CHARACTER 680 LDA #1 685 STA COUNT 690 JMP AGAIN 695 ; 700 ; 705 ;-------------------------------- 710 ;[G] OUTPUT CHAR 715 ;DECREMENT (COUNT) 720 ;IS (COUNT)=0 725 ;YES:GOTO [D] 730 ;NO :GOTO [G] 735 ;-------------------------------- 740 ; 745 LOOP5 LDA CHARACTER 750 JSR PUTBYTE 755 DEC COUNT 760 BEQ LOOP6 765 JMP LOOP5 770 ; 775 ; 780 ;-------------------------------- 785 ;[E] WHEN FINISHED WE STORE THE 790 ;END ADDRESS+1 OF THE COMPACTED 795 ;DATA FOR THE DECOMPRESS ROUTINE. 800 ;-------------------------------- 805 ; 810 FINISH LDA STOPNT 815 STA COMPEND 820 LDA STOPNT+1 825 STA COMPEND+1 830 RTS 835 ; 840 ; 845 ;-------------------------------- 850 ;CHECK IF REACHED THE END OF DATA 855 ;NO :GET NEXT BYTE/CLR CARRY/RETURN 860 ;YES:SET (ENDFLAG)/SET CARRY/RETURN 865 ;-------------------------------- 870 ; 875 GETBYTE LDA DATPNT 880 CMP #<TEXTEND 885 BNE LOOP12 890 LDA DATPNT+1 895 CMP #>TEXTEND 900 BNE LOOP12 905 LDA #$FF 910 STA ENDFLAG 915 SEC 920 RTS 925 ; 930 LOOP12 LDA (DATPNT),Y 935 INC DATPNT 940 BNE LOOP14 945 INC DATPNT+1 950 LOOP14 CLC 955 RTS 960 ; 965 ; 970 ;--------------------------------- 975 ;OUTPUT BYTE 980 ;--------------------------------- 985 ; 990 PUTBYTE STA (STOPNT),Y 995 INC STOPNT 1000 BNE LOOP15 1005 INC STOPNT+1 1010 LOOP15 RTS 1015 ; 1020 ; 1025 ; 1030 ;********************************* 1035 ;* DECOMPRESS ROUTINE * 1040 ;********************************* 1045 ;* THIS MUST BE CALLED AFTER THE * 1050 ;* COMPRESSION ROUTINE,IT WILL * 1055 ;* RESTORE THE COMPRESSED DATA * 1060 ;* AT 'STORAGE' BACK TO ITS * 1065 ;* ORIGINAL VALUES AND PLACE IT * 1070 ;* AT 'NEWTEXT'. * 1075 ;********************************* 1080 ;* YOU CAN THEN COMPARE BOTH * 1085 ;* 'TEXT' & 'NEWTEXT' TO SEE * 1090 ;* THAT THEY MATCH. * 1095 ;********************************* 1100 ; 1105 ; 1110 ;------------------------------- 1115 ;SET POINTERS TO START OF 1120 ;COMPRESSED DATA (STORAGE) & 1125 ;DECOMPRESSED DATA (NEWTEXT) 1130 ;------------------------------- 1135 ; 1140 DECOMPER LDA #<STORAGE 1145 STA DATPNT 1150 LDA #>STORAGE 1155 STA DATPNT+1 1160 LDA #<NEWTEXT 1165 STA STOPNT 1170 LDA #>NEWTEXT 1175 STA STOPNT+1 1180 ; 1185 ;------------------------------- 1190 ;GET COMPRESSED DATA 1195 ;IS IT A MARKER? 1200 ;NO:OUTPUT IT/INCREMENT (NEWTEXT) 1205 ;INCREMENT POINTER (STORAGE) 1210 ;IS IT END OF COMP.DATA? 1215 ;NO:GO BACK GET NEXT BYTE 1220 ;YES:EXIT 1225 ;------------------------------- 1230 ; 1235 LDY #0 1240 RELOOP LDA (DATPNT),Y 1245 CMP #MARKER 1250 BEQ LOOP40 1255 STA (STOPNT),Y 1260 JSR PNT1 1265 LOOP50 JSR PNT2 1270 LDA DATPNT 1275 CMP COMPEND 1280 BNE RELOOP 1285 LDA DATPNT+1 1290 CMP COMPEND+1 1295 BNE RELOOP 1300 RTS 1305 ; 1310 ;------------------------------- 1315 ;IF A MARKER IS FOUND THEN 1320 ;PUT (COUNT) IN X 1325 ;PUT (CHAR) IN A 1330 ;OUTPUT (CHAR) UNTIL X=0 1335 ;------------------------------- 1340 ; 1345 LOOP40 JSR PNT2 1350 LDA (DATPNT),Y 1355 TAX 1360 JSR PNT2 1365 LDA (DATPNT),Y 1370 LOOP42 STA (STOPNT),Y 1375 JSR PNT1 1380 DEX 1385 BNE LOOP42 1390 BEQ LOOP50 1395 ; 1400 ; 1405 ;----------------------------- 1410 ;INCREMENT POINTERS 1415 ;----------------------------- 1420 ; 1425 PNT1 INC STOPNT 1430 BNE LOOP43 1435 INC STOPNT+1 1440 LOOP43 RTS 1445 ; 1450 PNT2 INC DATPNT 1455 BNE LOOP44 1460 INC DATPNT+1 1465 LOOP44 RTS 1470 ; 1475 ; 1480 ; 1485 ; 1490 ; 1495 COMPEND BYT 0,0 1500 STORE BYT 0 1505 COUNT BYT 0 1510 CHARACTER BYT 0 1515 ENDFLAG BYT 0 1520 ; 1525 ;-------------------------------- 1530 ;THESE ARE THE BYTES TO BE 1535 ;COMPRESSED...YOU CAN USE YOUR 1540 ;OWN INSTEAD BUT IF YOU EXTEND 1545 ;ITS SIZE THEN MAKE SURE YOU 1550 ;ALTER THE OTHER STORAGE AREA'S 1555 ;AND POINTERS ACCORDINGLY... 1560 ;-------------------------------- 1565 ; 1570 TEXT ; 1575 ; 1580 BYT $01,$01,$01,$01 1585 BYT $01,$01,$01,$01 1590 BYT $01,$01,$01,$01 1595 BYT $01,$01,$EF,$01 1600 ; 1605 ;-------------------------------- 1610 ;THE BYTES ABOVE ARE COMPRESSED 1615 ;AND STORED HERE.............. 1620 ;(3 BYTES/FOR EVERY 1 IN TEXT) 1625 ;-------------------------------- 1630 STORAGE ; 1635 ; 1640 BYT 0,0,0,0,0,0,0,0 1645 BYT 0,0,0,0,0,0,0,0 1650 BYT 0,0,0,0,0,0,0,0 1655 BYT 0,0,0,0,0,0,0,0 1660 BYT 0,0,0,0,0,0,0,0 1665 BYT 0,0,0,0,0,0,0,0 1670 ; 1675 ;-------------------------------- 1680 ;THE COMPRESSED DATA IN 'STORAGE' 1685 ;IS DECOMPRESSED & PLACED HERE... 1690 ;-------------------------------- 1695 ; 1700 NEWTEXT ; 1705 ; 1710 BYT 0,0,0,0,0,0,0,0 1715 BYT 0,0,0,0,0,0,0,0 1720 BYT 0,0,0,0,0,0,0,0 1725 BYT 0,0,0,0,0,0,0,0 1730 BYT 0,0,0,0,0,0,0,0 1735 BYT 0,0,0,0,0,0,0,0 1740 ; 1745 ;
) ;********************************** Q ;* DATA COMPRESSION * y ;*--------------------------------* � ;* N.HIGGINS 1989 * � ;*--------------------------------* �# ;* METHOD: RUN LENGTH ENCODING * ( ;* USING : MARKER(COUNT,CHAR) * A - ;********************************** i 2 ;* FIRST CALL THE ROUTINES AT:- * � 7 ;* * � <