home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / packery / xpk_source / libraries / fast / xpkfast.a < prev    next >
Text File  |  1996-10-19  |  5KB  |  160 lines

  1.     INCLUDE    AINCLUDE:IncDirs.i *sets all includedirs, needed for my ASM
  2.     INCDIR    PrC:projekte/xpkmaster/xpk_private
  3.     INCLUDE    FAST/xpkLibFAST.i
  4.     include    "xpk/xpk.i"
  5.     include    "xpk/xpksub.i"
  6.     INCLUDE exec/memory.i
  7.  
  8.     INCLUDE    FAST/compress.a
  9.     INCLUDE    FAST/compress2.a
  10.     INCLUDE    FAST/decompress.a
  11.  
  12. ;    XREF    compress_fast
  13. ;    XREF    compress_slow
  14. ;    XREF    decompress
  15.  
  16. PACKMEM_FAST    equ    $10000
  17. PACKMEM_SLOW    equ    $44000
  18.  
  19. UNPACKMEM    equ    0
  20.  
  21. _XpksPackChunk:
  22.     movem.l a0-a6/d1,-(a7)
  23.     move.l    a6,a5            ; lib base
  24.     move.l    a0,a4            ; xparams
  25.  
  26.     move.l    xsp_Mode(a4),d1
  27.     
  28.     move.l    #PACKMEM_FAST,d0
  29.     lea.l    compress_fast(pc),a3
  30.  
  31.     cmp.l    #80,d1
  32.     bcs.s    IsFast
  33.     move.l    #PACKMEM_SLOW,d0
  34.     lea.l    compress_slow(pc),a3
  35. IsFast:
  36.     tst.l    xsp_Sub(a4)             ;Is there some memory allocated?
  37.     beq.s    AllocPackMem
  38.     cmp.l    xsp_Sub+4(a4),d0    ; Is the size right?
  39.     beq.s    packMemOK
  40.  
  41.     bsr.s    _XpksPackFree        ; Free currently allocated memory.
  42. AllocPackMem:
  43.     move.l    d0,xsp_Sub+4(a4)
  44.     move.l    #MEMF_PUBLIC,d1
  45.     move.l    4.W,a6
  46.     JSR    _LVOAllocMem(A6)
  47.     move.l    d0,xsp_Sub(a4)
  48.     bne.s    packMemOK
  49.     move.l    #XPKERR_NOMEM,d0
  50.     bra.s    endPackChunk
  51.  
  52. packMemOK:
  53.     move.l    xsp_InBuf(a4),a0        ;a0:=InBuf
  54.     move.l    xsp_OutBuf(a4),a1       ;a1:=OutBuf
  55.     move.l    xsp_Sub(a4),a2          ;a2:=Hash
  56.     move.l    xsp_InLen(a4),d0        ;d0:=InLen
  57.     moveq.l #90,d1
  58.     jsr    (a3)            ; call the compressor.
  59.     tst.l    d0
  60.     bne.s    Nooverrun
  61.     moveq.l #XPKERR_EXPANSION,d0
  62.     bra.s    endPackChunk
  63. Nooverrun:
  64.     move.l    d0,xsp_OutLen(a4)       ;Fill in Final output length XpkSubParams
  65.     moveq    #XPKERR_OK,d0
  66. endPackChunk:
  67.     movem.l (sp)+,a0-a6/d1
  68.     rts
  69.  
  70. _XpksPackFree:    movem.l a0-a2/a6/d0-d1,-(a7)
  71.         move.l    xsp_Sub(a0),a1
  72.         beq.s    packFreeEnd
  73.         clr.l    xsp_Sub(a0)
  74.         move.l    xsp_Sub+4(a0),d0    ; currently allocated amount.
  75.         clr.l    xsp_Sub+4(a0)
  76.         move.l    4.W,a6
  77.         JSR    _LVOFreeMem(A6)
  78. packFreeEnd:    movem.l (a7)+,a0-a2/a6/d0-d1
  79.         moveq    #XPKERR_OK,d0
  80.         rts
  81.  
  82. _XpksUnpackChunk:
  83.         move.l    a1,-(sp)
  84.         move.l    xsp_OutBuf(a0),a1
  85.         move.l    xsp_InLen(a0),d0
  86.         move.l    xsp_InBuf(a0),a0
  87.  
  88.         bsr    decompress
  89.         move.l    (sp)+,a1
  90.         moveq.l #XPKERR_OK,d0
  91.         rts
  92.  
  93.  
  94. _XpksPackerInfo:
  95.         move.l    a0,d0
  96.         lea    FastInfo(pc),a0
  97.         exg    a0,d0
  98.         rts
  99.  
  100.  
  101. ; --- Static Data --------
  102. FastInfo:
  103.  dc.w    1        ;xi_XpkInfoVersion:Version number of this structure
  104.  dc.w    VERSION     ;xi_LibVersion     : The version of this sublibrary
  105.  dc.w    2        ;xi_MasterVersion: The required master lib version
  106.  dc.w    0        ;xi_ModesVersion : Longword align
  107.  dc.l    FastName    ;xi_Name     : Brief name of the packer
  108.  dc.l    LongName    ;xi_LongName     : Full name of the packer
  109.  dc.l    Description    ;xi_Description  : One line description of packer
  110.  dc.b    'FAST'          ;xi_ID           : ID the packer goes by (XPK format)
  111.             ;xi_Flags     : Defined below
  112.  dc.l    XPKIF_PK_CHUNK|XPKIF_UP_CHUNK|XPKIF_MODES
  113.  dc.l    $7FFFFFFF    ;xi_MaxPkInChunk : Max input chunk size for packing
  114.  dc.l    0        ;xi_MinPkInChunk : Min input chunk size for packing
  115.  dc.l    $10000        ;xi_DefPkInChunk : Default packing chunk size
  116.  dc.l    PackMsg     ;xi_PackMsg     : Packing message, present tense
  117.  dc.l    UnpackMsg    ;xi_UnpackMsg     : Unpacking message, present tense
  118.  dc.l    PackedMsg    ;xi_PackedMsg     : Packing message, past tense
  119.  dc.l    UnpackedMsg    ;xi_UnpackedMsg  : Unpacking message, past tense
  120.  dc.w    50        ;xi_DefMode     : Default mode number
  121.  dc.w    0        ;xi_Pad      : for future use
  122.  dc.l    Modes        ;xi_Modes     : Array of compression modes
  123.  dc.l    0,0,0,0,0,0    ;xi_Reserved,6*4 : Future expansion - set to zero
  124.  
  125. FastName:    dc.b    'fasTcinator',0
  126. LongName:    dc.b    'FAST alias WOOP or LZRW++',0
  127. Description:    dc.b    'LZ77-family, windowsize: 4095, no quotecount, 2 streams',0
  128. PackMsg:    dc.b    'tieing',0
  129. PackedMsg:    dc.b    'compressed',0
  130. UnpackMsg:    dc.b    'untieing',0
  131. UnpackedMsg:    dc.b    'decompressed',0
  132.     EVEN
  133.  
  134. Modes:
  135.  dc.l    Crawling    ;xm_Next      : Chain to next descriptor for ModeDesc list
  136.  dc.l    79        ;xm_Upto      : Maximum efficiency handled by this mode.
  137.             ;xm_Flags      : Defined below
  138.  dc.l    XPKMF_A3000SPEED
  139.  dc.l    PACKMEM_FAST     ;xm_PackMemory      : Extra memory required during packing
  140.  dc.l    UNPACKMEM    ;xm_UnpackMemory  : Extra memory during unpacking
  141.  dc.l    428        ;xm_PackSpeed      : Approx packing speed in K per second
  142.  dc.l    1055        ;xm_UnpackSpeed   : Approx unpacking speed in K per second
  143.  dc.w    327        ;xm_Ratio      : CF in 0.1% for AmigaVision executable
  144.  dc.w    0        ;xm_ChunkSize      : Desired chunk size in K (!!) for this mode
  145.  dc.b    'speedy',0,0,0,0 ;xm_Description,10:8 character mode description
  146.  
  147. Crawling:
  148.  dc.l    0        ;xm_Next      : Chain to next descriptor for ModeDesc list
  149.  dc.l    100        ;xm_Upto      : Maximum efficiency handled by this mode.
  150.             ;xm_Flags      : Defined below
  151.  dc.l    XPKMF_A3000SPEED
  152.  dc.l    PACKMEM_SLOW     ;xm_PackMemory      : Extra memory required during packing
  153.  dc.l    UNPACKMEM    ;xm_UnpackMemory  : Extra memory during unpacking
  154.  dc.l    70        ;xm_PackSpeed      : Approx packing speed in K per second
  155.  dc.l    1096        ;xm_UnpackSpeed   : Approx unpacking speed in K per second
  156.  dc.w    393        ;xm_Ratio      : CF in 0.1% for AmigaVision executable
  157.  dc.w    0        ;xm_ChunkSize      : Desired chunk size in K (!!) for this mode
  158.  dc.b    'crawling',0,0  ;xm_Description,10:8 character mode description
  159.     END
  160.