home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma54.dms / ma54.adf / xpkFAST_V1_03 / FASTmisc.s < prev    next >
Text File  |  1993-12-03  |  5KB  |  174 lines

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