home *** CD-ROM | disk | FTP | other *** search
/ ANews 1 / AnewsCD01.iso / Indispensables / Compression / xfd / Developer / Sources / ASM / Unknown1.a < prev    next >
Text File  |  1999-08-03  |  6KB  |  292 lines

  1. * Programmheader
  2. *
  3. *    Name:        Unknown1
  4. *    Author:        SDI
  5. *    Distribution:    PD
  6. *    Description:    XFD external decruncher for Unknown Cruncher 1
  7. *    Compileropts:    -
  8. *    Linkeropts:    -
  9. *
  10. * 1.0   28.11.98 : first version
  11.  
  12.         INCLUDE    "AINCLUDE:IncDirs.i"
  13.         INCLUDE    "lvo.i"
  14.  
  15.         INCLUDE    "libraries/xfdmaster.i"
  16.         INCLUDE "exec/memory.i"
  17.  
  18.         * head function for tests
  19. *        INCLUDE    "xfdExeHead.a"
  20.  
  21. ForeMan        MOVEQ    #-1,D0
  22.         RTS
  23.  
  24.         DC.L    XFDF_ID
  25.         DC.W    1,0
  26.         DC.L    0,0,Slave1
  27.  
  28.         DC.B    "$VER: Unknown1 1.0 (28.11.1998) by SDI",0
  29. N_Unknown1    DC.B    'Unknown Cruncher 1',0
  30.         EVEN
  31.  
  32. Slave1        DC.L    0        ;no more slaves
  33.         DC.W    2        ;version
  34.         DC.W    36        ;master version
  35.         DC.L    N_Unknown1    ;name
  36.         DC.W    XFDPFF_ADDR    ;flags
  37.         DC.W    0
  38.         DC.L    RB_Unknown1    ;recog buffer
  39.         DC.L    DB_Unknown1    ;decrunch buffer
  40.         DC.L    0        ;recog segment
  41.         DC.L    0        ;decrunch segment
  42.         DC.W    0,0
  43.         DC.L    $68        ;MinBufSize
  44.  
  45. *************************************************************************
  46. *    Recog buffer function: receives buffer + length in A0/D0    *
  47. *************************************************************************
  48.  
  49. RB_Unknown1    MOVEQ    #0,D0            ; False
  50.  
  51.         CMP.L    #$000003F3,(A0)
  52.         BNE.B    .No
  53.         CMP.L    #$21CC0080,$28(A0)
  54.         BNE.B    .No
  55.         CMP.L    #$548F4CDB,$3C(A0)
  56.         BNE.B    .No
  57.         CMP.L    #$D10050D3,$50(A0)
  58.         BNE.B    .No
  59.         CMP.L    #$02130087,$54(A0)
  60.         BNE.B    .No
  61.         CMP.L    #$7FFFFF1A,$64(A0)
  62.         BNE.B    .No
  63.         MOVEQ    #1,D0            ; True
  64. .No        RTS
  65.  
  66. *************************************************************************
  67. *    Decrunch buffer function: receives xfdbiBufferInfo in A0    *
  68. *************************************************************************
  69.  
  70. DB_Unknown1    MOVEM.L    D2-D6/A2-A6,-(A7)
  71.         MOVE.L    A0,A5
  72.         MOVE.W    #XFDERR_NOMEMORY,xfdbi_Error(A5)
  73.  
  74.         MOVEA.L    xfdbi_SourceBuffer(A5),A4
  75.         MOVE.L    $212(A4),D0
  76.         SUB.L    $216(A4),D0
  77.         MOVE.L    D0,D6
  78.         MOVEQ    #0,D1            * MEMF_ANY
  79.         MOVEA.L    xfdm_ExecBase(A6),A6
  80.         JSR    _LVOAllocMem(A6)
  81.         MOVE.L    D0,xfdbi_TargetBuffer(A5)
  82.         BEQ.B    .NoMem
  83.  
  84.         MOVE.W    $21E(A4),D5
  85.         MOVE.L    $220(A4),xfdbi_DecrAddress(A5)
  86.         MOVE.L    $224(A4),xfdbi_JmpAddress(A5)
  87.  
  88.         MOVE.L    D0,A1            * start of buffer
  89.         LEA    (A1,D6.L),A0        * end of buffer
  90.         MOVE.L    $21A(A4),D0
  91.         LEA    $21E(A4),A4
  92.         LEA    (A4,D0.L),A2        * end of source
  93.  
  94.         MOVE.L    A6,-(A7)
  95.         BSR.B    Decrunch
  96.         MOVEA.L    A1,A4
  97.         BSR.W    DecrSize
  98.         MOVEA.L    (A7)+,A6
  99.  
  100.         MOVE.L    D0,xfdbi_TargetBufSaveLen(A5)
  101.         ADDQ.L    #1,D0
  102.         MOVE.L    D0,xfdbi_TargetBufLen(A5)
  103.         MOVE.L    xfdbi_TargetBufMemType(A5),D1
  104.         JSR    _LVOAllocMem(A6)
  105.         MOVE.W    #XFDERR_NOMEMORY,xfdbi_Error(A5)
  106.         MOVE.L    D0,xfdbi_TargetBuffer(A5)
  107.         BEQ.B    .NoMem2
  108.         MOVE.L    D0,A1
  109.         MOVEA.L    A4,A0
  110.         BSR.W    Decrunch2
  111.  
  112.         CLR.W    xfdbi_Error(A5)
  113.  
  114. .NoMem2        MOVEA.L    A4,A1
  115.         MOVE.L    D6,D0
  116.         JSR    _LVOFreeMem(A6)
  117.         
  118.         MOVE.W    xfdbi_Error(A5),D0
  119.         NOT.W    D0
  120. .NoMem        MOVEM.L    (A7)+,D2-D6/A2-A6
  121.         RTS
  122.  
  123.  
  124. *************************************************************************
  125. *    decrunch routine - copied from file (a bit modified)        *
  126. *************************************************************************
  127.  
  128. Decrunch    MOVEQ    #$10,D4
  129.         MOVE    D4,CCR
  130.         LEA    SubJmp(PC),A4
  131.         LEA    .Decr12(PC),A3
  132.         MOVE.L    -(A2),D3
  133. .Decr1        MOVEQ    #2,D0
  134.         LEA    .Decr2(PC),A6
  135.         JMP    (A4)
  136. .Decr2        CMPI.W    #6,D1
  137.         BCS.B    .Decr8
  138.         BEQ.B    .Decr12
  139.         LSL.L    #1,D3
  140.         BNE.B    .Decr3
  141.         MOVE.L    -(A2),D3
  142.         MOVE    D4,CCR
  143.         ROXL.L    #1,D3
  144. .Decr3        BCC.B    .Decr6
  145.         MOVEQ    #9,D0
  146.         LEA    .Decr4(PC),A6
  147.         JMP    (A4)
  148. .Decr4        SUBQ.W    #1,D1
  149.         BCC.B    .Decr8
  150.         MOVEQ    #$000F,D0
  151.         LEA    .Decr5(PC),A6
  152.         JMP    (A4)
  153. .Decr5        LEA    .Decr11(PC),A3
  154.         BRA.B    .Decr8
  155. .Decr6        MOVEQ    #3,D0
  156.         LEA    .Decr7(PC),A6
  157.         JMP    (A4)
  158. .Decr7        ADDQ.W    #6,D1
  159. .Decr8        MOVEQ    #7,D0
  160. .Decr9        LSL.L    #1,D3
  161.         BEQ.B    .Decr10
  162.         ROXL.B    #1,D2
  163.         DBRA    D0,.Decr9
  164.         MOVE.B    D2,-(A0)
  165.         DBRA    D1,.Decr8
  166.         CMPA.L    A0,A1
  167.         BCC.W    Finished
  168.         JMP    (A3)
  169. .Decr10        MOVE.L    -(A2),D3
  170.         LSL.L    #1,D3
  171.         ROXL.B    #1,D2
  172.         ADDQ.B    #1,D3
  173.         DBRA    D0,.Decr9
  174.         MOVE.B    D2,-(A0)
  175.         DBRA    D1,.Decr8
  176.         CMPA.L    A0,A1
  177.         BCC.W    Finished
  178.         JMP    (A3)
  179. .Decr11        LEA    .Decr12(PC),A3
  180.         BRA.B    .Decr1
  181. .Decr12        MOVEQ    #1,D0
  182.         LEA    .Decr13(PC),A6
  183.         JMP    (A4)
  184. .Decr13        MOVEQ    #7,D0
  185.         MOVEQ    #1,D2
  186.         TST.W    D1
  187.         BEQ.B    .Decr25
  188.         MOVEQ    #3,D2
  189.         CMPI.W    #2,D1
  190.         BEQ.B    .Decr22
  191.         CMPI.W    #3,D1
  192.         BEQ.B    .Decr15
  193.         MOVEQ    #2,D2
  194.         LSL.L    #1,D3
  195.         BNE.B    .Decr14
  196.         MOVE.L    -(A2),D3
  197.         MOVE    D4,CCR
  198.         ROXL.L    #1,D3
  199. .Decr14        BCC.B    .Decr25
  200.         MOVEQ    #$000D,D0
  201.         BRA.B    .Decr25
  202. .Decr15        MOVEQ    #1,D0
  203.         LEA    .Decr16(PC),A6
  204.         JMP    (A4)
  205. .Decr16        CMPI.W    #2,D1
  206.         BCC.B    .Decr17
  207.         ADDQ.W    #4,D1
  208.         BRA.B    .Decr21
  209. .Decr17        CMPI.W    #3,D1
  210.         BEQ.B    .Decr19
  211.         MOVEQ    #1,D0
  212.         LEA    .Decr18(PC),A6
  213.         JMP    (A4)
  214. .Decr18        ADDQ.W    #6,D1
  215.         BRA.B    .Decr21
  216. .Decr19        MOVEQ    #7,D0
  217.         LEA    .Decr20(PC),A6
  218.         JMP    (A4)
  219. .Decr20        ADDI.W    #$000A,D1
  220. .Decr21        MOVE.W    D1,D2
  221. .Decr22        MOVEQ    #$000F,D0
  222.         LSL.L    #1,D3
  223.         BNE.B    .Decr23
  224.         MOVE.L    -(A2),D3
  225.         MOVE    D4,CCR
  226.         ROXL.L    #1,D3
  227. .Decr23        BCS.B    .Decr25
  228.         MOVEQ    #$000B,D0
  229.         LSL.L    #1,D3
  230.         BNE.B    .Decr24
  231.         MOVE.L    -(A2),D3
  232.         MOVE    D4,CCR
  233.         ROXL.L    #1,D3
  234. .Decr24        BCS.B    .Decr25
  235.         MOVEQ    #7,D0
  236. .Decr25        LEA    .Decr26(PC),A6
  237.         JMP    (A4)
  238. .Decr26        ADDQ.L    #1,D1
  239. .Decr27        MOVE.B    -1(A0,D1.L),-(A0)
  240.         DBRA    D2,.Decr27
  241.         CMPA.L    A0,A1
  242.         BCS.W    .Decr1
  243. Finished    RTS
  244.  
  245. SubJmp        MOVEQ    #0,D1
  246. .SubLoop    LSL.L    #1,D3
  247.         BEQ.B    .Skip
  248.         ROXL.W    #1,D1
  249.         DBRA    D0,.SubLoop
  250.         JMP    (A6)
  251. .Skip        MOVE.L    -(A2),D3
  252.         LSL.L    #1,D3
  253.         ROXL.W    #1,D1
  254.         ADDQ.B    #1,D3
  255.         DBRA    D0,.SubLoop
  256.         JMP    (A6)
  257.  
  258. DecrSize    MOVEQ    #0,D0
  259. .Size1        MOVE.B    (A0)+,D1
  260.         ADDQ.L    #1,D0
  261.         CMP.B    D5,D1
  262.         BNE.B    .Size1
  263.         MOVEQ    #0,D1
  264.         MOVE.B    (A0)+,D1
  265.         BEQ.B    .Size1        * char + 0 --> means char
  266.         SUBQ.L    #1,D0
  267.         CMPI.B    #1,D1        * char + 1 --> means end
  268.         BEQ.B    .End
  269.         ADDQ.L    #1,D1
  270.         ADD.L    D1,D0        * char + x + a --> means (x+1) * a
  271.         MOVE.B    (A0)+,D1
  272.         BRA.B    .Size1
  273. .End        RTS
  274.  
  275. Decrunch2    
  276. .Dec1        MOVE.B    (A0)+,D1
  277.         MOVE.B    D1,(A1)+
  278.         CMP.B    D5,D1
  279.         BNE.B    .Dec1
  280.         MOVE.B    (A0)+,D1
  281.         BEQ.B    .Dec1
  282.         SUBQ.L    #1,A1
  283.         CMPI.B    #1,D1
  284.         BEQ.B    .End
  285.         ANDI.W    #$FF,D1
  286.         MOVE.B    (A0)+,D2
  287. .Dec2        MOVE.B    D2,(A1)+
  288.         DBRA    D1,.Dec2
  289.         BRA.B    .Dec1
  290. .End        RTS
  291.         END
  292.