home *** CD-ROM | disk | FTP | other *** search
-
- *******************************************************************************
- *
- * !unpacker før zerø-packer v0.4!
- *
- * VER: zerø-unpacker v0.1 by teuvo tursas (27/08/1993)
- * VER: zerø-unpacker v0.2 by teuvo tursas (23/10/1993)
- * VER: zerø-unpacker v0.3 by teuvo tursas (02/04/1994)
- * VER: zerø-unpacker v0.31 by teuvo tursas (06/10/1994)
- * $VER: zerø-unpacker v0.4 by teuvo tursas (25/02/1995)
- *
- * v0.1 - just unpacks zerøs.
- * v0.2 - reads alsø file's lenght.
- * v0.3 - optimized and fixed a major bug.
- * v0.2 was so full of bugs, that I wonder
- * how did it ever work!
- * v0.31 - optimized code. works little faster.
- * v0.4 - includes also file's original lenght.
- *
- * a0 - pointer to packet
- * a1 - pointer to data's area
- *
- * unpacked lenght can be found in packet's
- * second longword [ .l 4(a0) ].
- *
- * returns 0 in d0 if no error occured /
- * 1 in d0 if the packet was corrupted
- *
- *******************************************************************************
-
- unpackbeginning:sub.l d4,d4 ;faster output with this
- readlenght: move.l (a0)+,d0 ;file lenght (zpk)
- move.l (a0)+,d7 ;file lenght (bin)
- readheader: move.b (a0)+,d1 ;header
- sub.l #4+4+1,d0 ;4+4(lenght)+1(header)=9
- unpackloop: tst.l d0
- beq.b quitos
- move.b (a0)+,d2 ;move next byte
- cmp.b d2,d1 ;cmp it with header
- beq.s headerfound ;it was equal
- move.b d2,(a1)+ ;something else, move on
- subq.l #1,d0 ;sub one from lenght
- bra.b unpackloop
- headerfound: move.l (a0)+,d3 ;move the lenght of da zeroes
- writezeros: move.b d4,(a1)+ ;write a zero-byte
- subq.l #1,d3 ;sub one from zeros
- ; tst.l d3 ;are all zeros gone?
- bne.s writezeros ;not all written
- subq.l #4+1,d0 ;sub header and lenght of z's
- cmp.l d4,d0
- blt.b overflow
- bra.b unpackloop
- overflow: moveq #1,d0
- rts
- quitos: move.l d4,d0
- rts
-