home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / muchmorepopa_378.lzh / MuchMorePoPa / PPData.asm < prev    next >
Assembly Source File  |  1990-10-10  |  2KB  |  117 lines

  1. ;
  2. ; PowerPacker Decrunch assembler subroutine V1.1
  3. ;
  4. ; call as:
  5. ;    DecrunchBuffer (endcrun, buffer, efficiency);
  6. ; with:
  7. ;    endcrun   : UBYTE * just after last byte of crunched file
  8. ;    buffer    : UBYTE * to memory block to decrunch in
  9. ;    efficiency: Longword defining efficiency with wich file was crunched
  10. ;
  11. ; NOTE:
  12. ;    Decrunch a few bytes higher (safety margin) than the crunched file
  13. ;    to decrunch in the same memory space. (64 bytes suffice)
  14. ;
  15.  
  16.         XDEF _pp_DecrunchBuffer
  17.  
  18. _pp_DecrunchBuffer:
  19.         movem.l d1-d7/a2-a6,-(a7)
  20.         bsr.s Decrunch
  21.         movem.l (a7)+,d1-d7/a2-a6
  22.         rts
  23. Decrunch:
  24.         lea myBitsTable(PC),a5
  25.         move.l d0,(a5)
  26.         move.l a1,a2
  27.         move.l -(a0),d5
  28.         moveq #0,d1
  29.         move.b d5,d1
  30.         lsr.l #8,d5
  31.         add.l d5,a1
  32.         move.l -(a0),d5
  33.         lsr.l d1,d5
  34.         move.b #32,d7
  35.         sub.b d1,d7
  36. LoopCheckCrunch:
  37.         bsr.s ReadBit
  38.         tst.b d1
  39.         bne.s CrunchedBytes
  40. NormalBytes:
  41.         moveq #0,d2
  42. Read2BitsRow:
  43.         moveq #2,d0
  44.         bsr.s ReadD1
  45.         add.w d1,d2
  46.         cmp.w #3,d1
  47.         beq.s Read2BitsRow
  48. ReadNormalByte:
  49.         move.w #8,d0
  50.         bsr.s ReadD1
  51.         move.b d1,-(a1)
  52.         dbf d2,ReadNormalByte
  53.         cmp.l a1,a2
  54.         bcs.s CrunchedBytes
  55.         rts
  56. CrunchedBytes:
  57.         moveq #2,d0
  58.         bsr.s ReadD1
  59.         moveq #0,d0
  60.         move.b 0(a5,d1.w),d0
  61.         move.l d0,d4
  62.         move.w d1,d2
  63.         addq.w #1,d2
  64.         cmp.w #4,d2
  65.         bne.s ReadOffset
  66.         bsr.s ReadBit
  67.         move.l d4,d0
  68.         tst.b d1
  69.         bne.s LongBlockOffset
  70.         moveq #7,d0
  71. LongBlockOffset:
  72.         bsr.s ReadD1
  73.         move.w d1,d3
  74. Read3BitsRow:
  75.         moveq #3,d0
  76.         bsr.s ReadD1
  77.         add.w d1,d2
  78.         cmp.w #7,d1
  79.         beq.s Read3BitsRow
  80.         bra.s DecrunchBlock
  81. ReadOffset:
  82.         bsr.s ReadD1
  83.         move.w d1,d3
  84. DecrunchBlock:
  85.         move.b 0(a1,d3.w),d0
  86.         move.b d0,-(a1)
  87.         dbf d2,DecrunchBlock
  88. EndOfLoop:
  89.         cmp.l a1,a2
  90.         bcs.s LoopCheckCrunch
  91.         rts
  92. ReadBit:
  93.         moveq #1,d0
  94. ReadD1:
  95.         moveq #0,d1
  96.         subq.w #1,d0
  97. ReadBits:
  98.         lsr.l #1,d5
  99.         roxl.l #1,d1
  100.         subq.b #1,d7
  101.         bne.s No32Read
  102.         move.b #32,d7
  103.         move.l -(a0),d5
  104. No32Read:
  105.         dbf d0,ReadBits
  106.         rts
  107. myBitsTable:
  108.         dc.b $09,$0a,$0b,$0b
  109.  
  110.  
  111.         end;
  112.  
  113.  
  114.  
  115.  
  116.  
  117.