home *** CD-ROM | disk | FTP | other *** search
-
- *******************************************************************************
- *
- * !a little data-packer før thøse whø can't dø their!
- * !øwn packer ør whø just need a simple øne!
- * !this uncanny versiøn can!
- * !pack -belive ør nøt- ønly zerøes(!!!!!!!!)!
- *
- * VER: zerø-packer v0.1 by teuvo tursas (29/08/1993)
- * VER: zerø-packer v0.2 by teuvo tursas (23/10/1993)
- * VER: zerø-packer v0.3 by teuvo tursas (02/04/1993)
- * VER: zerø-packer v0.31 by teuvo tursas (24/02/1995)
- * $VER: zerø-packer v0.4 by teuvo tursas (25/02/1995)
- *
- * v0.1 - started frøm a scratch
- * v0.2 - nøw writes file's lenght intø packet
- * v0.3 - works with unpacker v0.3
- * v0.31 - løts øf little øptimizatiøns
- * v0.4 - writes the øriginal lenght alsø
- *
- * a5 - pointer to original file
- * a6 - pointer to packet's room
- *
- * returns packet's lenght in d7
- * returns 0 in d0 if no error / 1 in d0 if could not
- * find any character for marking the packet /
- * 2 in d0 if the packet grew too big
- *
- *******************************************************************************
-
- testoptions: moveq.l #1,d3 ;faster output with this
- move.l a5,a0
- move.l lenghtoffile,d0
- sub.b d1,d1
- sub.l d6,d6 ;zeros
- sub.l d7,d7 ;addbytes
-
- headersearch: move.b (a0)+,d2
- cmp.b d1,d2
- beq.s addoneandagain
- sub.l d3,d0
- bne.s headersearch
- move.b d1,d5 ;header found
- bra.b writeheader
-
- addoneandagain: cmp.b #$ff,d1
- beq.w headeroverflow
- add.b d3,d1
- move.l lenghtoffile,d0
- move.l a5,a0
- bra.b headersearch
-
- writeheader: move.l a6,a0
-
- writelenght: move.l #0,(a0)+ ;nulls here, because in the
- move.l lenghtoffile,(a0)+ ;end we put the real values
- move.b d5,(a0)+ ;to the beginning of the packet
- move.l #4+4+1,d7 ;lenght of header and lenghts
-
- beginning: move.l a5,a1
- move.l lenghtoffile,d0
- move.l d0,d1
- asl.l #1,d1 ;mulu #2,d1
-
- packloop: move.b (a1)+,d2 ;main loop. pack all zeroes
- beq.s zerobytefound
- sub.l d3,d1
- beq.s sizeoverflow ;size exceeds the limit
- move.b d2,(a0)+
- add.l d3,d7
- sub.l d3,d0
- beq.s quit
- bra.b packloop
-
- zerobytefound: add.l d3,d6 ;at least one zero found
-
- sub.l d3,d1
- beq.s sizeoverflow ;size exceeds the limit
-
- move.b d5,(a0)+
- add.l d3,d7
- sub.l d3,d0
- beq.s endoffile
-
- searchloop: tst.l d0 ;search for more zeroes
- beq.s endoffile
- sub.l d3,d0
- move.b (a1)+,d2
- bne.s notzero
- add.l d3,d6
- bra.b searchloop
-
- notzero: sub.l #4,d1
- cmp.l d3,d1
- blt.s sizeoverflow ;size exceeds the limit
-
- move.l d6,d4
- move.l d4,(a0)+
- addq.l #4,d7
- sub.l d6,d6
-
- sub.l d3,d1
- beq.s sizeoverflow ;size exceeds the limit
-
- move.b d2,(a0)+
- add.l d3,d7
- bra.w packloop
-
- endoffile: move.l d6,d4
-
- sub.l #4,d1
- cmp.l d3,d1
- blt.s sizeoverflow ;size exceeds the limit
-
- move.l d4,(a0)+
- addq.l #4,d7
-
- quit: move.l a6,a0
- move.l d7,(a0)+ ;here we put it!
- sub.l d0,d0 ;no error
- rts
-
- headeroverflow: moveq.l #1,d0 ;error! header-overflow
- rts
-
- sizeoverflow: moveq.l #2,d0 ;error! size is too high
- rts
-