home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / xfd_developer / sources / asm / vice.a < prev    next >
Encoding:
Text File  |  2000-06-27  |  3.5 KB  |  180 lines

  1. *******************************************************
  2. **     XFD external decruncher for Vice Cruncher     **
  3. **        written by Mr. Larmer / Wanted Team        **
  4. **       shortened and fixed by SDI in 1999           **
  5. *******************************************************
  6.  
  7.         INCLUDE    "AINCLUDE:IncDirs.i"
  8.         INCLUDE    "libraries/xfdmaster.i"
  9.  
  10.         * head function for tests
  11. *        INCLUDE    "xfdExeHead.a"
  12.  
  13. ; xfdForeman structure MUST be first thing in all external decrunchers
  14.  
  15. ForeMan        moveq    #-1,d0        ;security
  16.         rts
  17.         dc.l    XFDF_ID        ;id
  18.         dc.w    1        ;version
  19.         dc.w    0
  20.         dc.l    0,0        ;private
  21.         dc.l    S_Vice        ;first slave
  22.  
  23. **************************************************
  24.  
  25.         dc.b    "$VER: Vice 2.0 (18.12.1999)",0
  26. N_Vice        dc.b    "(Vice) Data Cruncher",0
  27.         even
  28.  
  29. **************************************************
  30.  
  31. ; xfdSlave structure: this one doesn't support segment decrunching
  32.  
  33. S_Vice        dc.l    0        ;no more slaves
  34.         dc.w    2        ;version
  35.         dc.w    39        ;master version
  36.         dc.l    N_Vice        ;name
  37.         dc.w    XFDPFF_DATA|XFDPFF_USERTARGET|XFDPFF_RECOGLEN
  38.         dc.w    0
  39.         dc.l    RB_Vice        ;recog buffer
  40.         dc.l    DB_Vice        ;decrunch buffer
  41.         dc.l    0        ;recog segment
  42.         dc.l    0        ;decrunch segment
  43.         dc.w    0,0
  44.         dc.l    12+2
  45.  
  46. ;-------------------------------------------------
  47.  
  48. ; Recog buffer function: receives buffer + length in a0/d0
  49.  
  50. RB_Vice        MOVEQ    #0,D0
  51.         CMP.L    #'Vice',(A0)
  52.         BNE.B    .Exit
  53.         CMP.B    #$80,4(A0)
  54.         BNE.B    .Exit
  55.         MOVE.L    #200000,xfdrr_MinTargetLen(A1)
  56.         MOVE.L    #-1,xfdrr_FinalTargetLen(A1)
  57.         MOVEQ    #1,D0
  58. .Exit        RTS
  59.  
  60. ;-------------------------------------------------
  61.  
  62. ;Decrunch buffer function: receives bufferinfo in a0
  63.  
  64. DB_Vice        movem.l    D2-D7/A2-A6,-(A7)
  65.         MOVEA.L    A0,A5
  66.         MOVE.L    xfdbi_SourceBuffer(A5),A6
  67.         MOVE.L    xfdbi_UserTargetBuf(A5),A3    ; dest start
  68.         MOVEA.L    A6,A0
  69.         ADD.L    xfdbi_SourceBufLen(A5),A0    ; source end
  70.         ADDQ.L    #4,A6                ; source start
  71.         MOVE.L    A3,A1
  72.         ADD.L    xfdbi_UserTargetBufLen(A5),A1    ; dest end
  73.  
  74.         MOVE.L    A3,D2
  75.         MOVEM.L    D2/A5,-(a7)
  76.         BSR.B    D_Vice
  77.         MOVEM.L    (A7)+,D2/A5
  78.         MOVE.W    #XFDERR_CORRUPTEDDATA,xfdbi_Error(A5)
  79.  
  80.         SUBA.L    D2,A3
  81.         MOVE.L    A3,xfdbi_TargetBufSaveLen(A5)
  82.  
  83.         ; D0 already set
  84.         MOVEM.L    (A7)+,D2-D7/A2-A6
  85.         RTS
  86.  
  87. D_Vice        LEA    $200(A6),A5
  88.         LEA    $200(A5),A4
  89.         MOVEQ    #1,D6
  90.         MOVE.W    $1FE(A6),D4
  91.         MOVEQ    #$1F,D7
  92.         MOVEQ    #7,D3
  93.  
  94. .Vice01:    MOVEQ    #0,D1
  95.         BSR.S    .ViceSub
  96.         TST.B    D5
  97.         BEQ.S    .Error
  98.         MOVE.B    D5,D1
  99.         BPL.S    .Vice03
  100.         BCLR    D3,D1
  101.         SUBQ.B    #1,D1
  102.         BSR.S    .ViceSub
  103. .Vice02:    CMPA.L    A1,A3
  104.         BGE.B    .DestEnd
  105.         MOVE.B    D5,(A3)+
  106.         DBRA    D1,.Vice02
  107.         BRA.S    .Vice01
  108. .Vice03:    SUBQ.B    #1,D1
  109. .Vice04:    MOVE.W    D4,D5
  110. .Vice05:    LSR.L    #1,D6
  111.         BCC.S    .Vice08
  112.         BEQ.S    .Vice07
  113. .Vice06:    MOVE.W    (A5,D5.W),D5
  114.         BMI.S    .Vice09
  115.         LSR.L    #1,D6
  116.         BCC.S    .Vice08
  117.         BEQ.S    .Vice07
  118.         MOVE.W    (A5,D5.W),D5
  119.         BPL.S    .Vice05
  120.         CMPA.L    A1,A3
  121.         BGE.B    .DestEnd
  122.         MOVE.B    D5,(A3)+
  123.         DBRA    D1,.Vice04
  124.         BRA.S    .Vice01
  125. .Vice07:    MOVE.L    (A4)+,D6
  126.         CMPA.L    A0,A4
  127.         BGT.B    .SourceEnd
  128.         LSR.L    #1,D6
  129.         BSET    D7,D6
  130.         BCS.S    .Vice06
  131. .Vice08:    MOVE.W    (A6,D5.W),D5
  132.         BMI.S    .Vice09
  133.         LSR.L    #1,D6
  134.         BCC.S    .Vice08
  135.         BEQ.S    .Vice07
  136.         MOVE.W    (A5,D5.W),D5
  137.         BPL.S    .Vice05
  138. .Vice09:    CMPA.L    A1,A3
  139.         BGE.B    .DestEnd
  140.         MOVE.B    D5,(A3)+
  141.         DBRA    D1,.Vice04
  142.         BRA.S    .Vice01
  143.  
  144. .DestEnd    MOVEQ    #0,D0
  145.         RTS
  146.  
  147. .SourceEndSub    ADDQ.L    #4,A7
  148. .Error
  149. .SourceEnd    MOVEQ    #1,D0
  150.         RTS
  151.  
  152. .ViceSub:    MOVE.W    D4,D5
  153. .ViceS1:    LSR.L    #1,D6
  154.         BCC.S    .ViceS4
  155.         BEQ.S    .ViceS3
  156. .ViceS2:    MOVE.W    (A5,D5.W),D5
  157.         BMI.S    .End
  158.         LSR.L    #1,D6
  159.         BCC.S    .ViceS4
  160.         BEQ.S    .ViceS3
  161.         MOVE.W    (A5,D5.W),D5
  162.         BPL.S    .ViceS1
  163.         RTS
  164. .ViceS3:    MOVE.L    (A4)+,D6
  165.         CMP.L    A0,A4
  166.         BGT.B    .SourceEndSub
  167.         LSR.L    #1,D6
  168.         BSET    D7,D6
  169.         BCS.S    .ViceS2
  170. .ViceS4:    MOVE.W    (A6,D5.W),D5
  171.         BMI.S    .End
  172.         LSR.L    #1,D6
  173.         BCC.S    .ViceS4
  174.         BEQ.S    .ViceS3
  175.         MOVE.W    (A5,D5.W),D5
  176.         BPL.S    .ViceS1
  177. .End:        RTS
  178.         END
  179.  
  180.