home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / fm2000 / object.s < prev    next >
Encoding:
Text File  |  2000-02-04  |  12.6 KB  |  676 lines

  1. ;/*
  2. ;     Filemaster - Multitasking directory utility.
  3. ;     Copyright (C) 2000  Toni Wilen
  4. ;     
  5. ;     This program is free software; you can redistribute it and/or
  6. ;     modify it under the terms of the GNU General Public License
  7. ;     as published by the Free Software Foundation; either version 2
  8. ;     of the License, or (at your option) any later version.
  9. ;     
  10. ;     This program is distributed in the hope that it will be useful,
  11. ;     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;     GNU General Public License for more details.
  14. ;     
  15. ;     You should have received a copy of the GNU General Public License
  16. ;     along with this program; if not, write to the Free Software
  17. ;     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. ;*/
  19.  
  20. ;----------T----------T
  21.  
  22.     xdef    _RealTimeScroll
  23.     xdef    _unpack
  24.     xdef    _unpacknp
  25.     xdef    _hexconvert
  26.     xdef    _checksum
  27.     xdef    _bootsum
  28.     xdef    _formathook
  29.  
  30.     xdef    _mousebutton
  31.  
  32.     xdef    _initaudio
  33.     xdef    _endaudio
  34.     xdef    _startaudio
  35.     xdef    _waitaudio
  36.  
  37.     xdef    _regform
  38.     xdef    _fmexe
  39.     xdef    _fmexee
  40.  
  41.     xdef    _rlepack
  42.     xdef    _rleunpack
  43.  
  44.     section    text,code
  45.  
  46. _mousebutton
  47.     move.l    a6,-(sp)
  48.     move.l    a0,a6
  49. mloop    jsr    -$010e(a6)
  50.     btst    #6,$bfe001
  51.     bne.s    mloop
  52.     move.l    (sp)+,a6
  53.     rts
  54.  
  55.     ;a0=src,a1=bitmap,a2=(WORD*)row,d0=totrows,d1=scrbytes,d2=width,d3=mask,a6=shows
  56.  
  57. _unpack    movem.l    d2-d7/a2-a6,-(sp)    ;packed iff
  58.     ext.l    d2
  59.  
  60. nxrow    move.l    (a0),a4
  61.     moveq    #0,d7
  62.     move.b    5(a1),d7
  63.     subq.w    #1,d7
  64.     lea    8(a1),a5
  65. nxplane    move.l    (a5)+,a3
  66.     moveq    #0,d6
  67. nxbyte    moveq    #0,d5
  68.     subq.l    #1,d1
  69.     bmi.s    uperr
  70.     move.b    (a4)+,d5
  71.     bmi.s    nega
  72.     add.w    d5,d6
  73.     addq.w    #1,d6
  74. ident    move.b    (a4)+,(a3)+
  75.     subq.l    #1,d1
  76.     bmi.s    uperr
  77.     dbf    d5,ident
  78.     bra.s    nxblk
  79. nega    move.b    (a4)+,d4
  80.     subq.l    #1,d1
  81.     bmi.s    uperr
  82.     neg.b    d5
  83.     add.w    d5,d6
  84.     addq.w    #1,d6
  85. dupli    move.b    d4,(a3)+
  86.     dbf    d5,dupli
  87. nxblk    cmp.w    d2,d6
  88.     bcs.s    nxbyte
  89.     dbf    d7,nxplane
  90.     cmp.b    #1,d3
  91.     bne.s    nomask
  92.     bsr.s    mask
  93.     bmi.s    uperr
  94. nomask
  95.     bsr.s    sysput
  96.  
  97.     addq.w    #1,(a2)
  98.     move.l    a4,(a0)
  99.     cmp.w    (a2),d0
  100.     bne.s    nxrow
  101.  
  102. uperr    movem.l    (sp)+,d2-d7/a2-a6
  103.     rts
  104.  
  105.     ;a6=shows,d2=width
  106.  
  107. sysput    movem.l    d0-d7/a0-a6,-(sp)
  108.     move.l    a6,a5            ;shows
  109.     move.l    22(a5),a6        ;gfxbase
  110.     lsl.w    #3,d2
  111.  
  112.     move.l    26(a5),a0    ;srcbitmap
  113.     moveq    #0,d0        ;srcx
  114.     moveq    #0,d1        ;srcy
  115.     move.l    10(a5),a1    ;dstbitmap
  116.     move.w    d2,d4        ;sizex
  117.     subq.w    #1,d4
  118.     moveq    #1,d5        ;sizey
  119.     moveq    #0,d2        ;dstx
  120.     move.w    (a2),d3        ;dsty
  121.     move.b    #$c0,d6        ;minterm
  122.     st    d7        ;mask
  123.     sub.l    a2,a2
  124.     jsr    -$01e(a6)
  125.  
  126.     movem.l    (sp)+,d0-d7/a0-a6
  127.     rts
  128.  
  129.  
  130. mask    moveq    #0,d6
  131. nxbytem    subq.l    #1,d1
  132.     bmi.s    maskerr
  133.     moveq    #0,d5
  134.     move.b    (a4)+,d5
  135.     bmi.s    negam
  136.     addq.w    #1,d5
  137.     add.w    d5,d6
  138.     sub.l    d5,d1
  139.     bmi.s    maskerr
  140.     add.w    d5,a4
  141.     bra.s    nxblkm
  142. negam    addq.l    #1,a4
  143.     subq.l    #1,d1
  144.     bmi.s    maskerr
  145.     neg.b    d5
  146.     addq.w    #1,d5
  147.     add.w    d5,d6
  148. nxblkm    cmp.w    d2,d6
  149.     bcs.s    nxbytem
  150.     moveq    #1,d5
  151. maskerr    rts
  152.  
  153. _unpacknp    movem.l    d2-d7/a2-a6,-(sp)    ;unpacked iff
  154.     ext.l    d2
  155.  
  156. nnxrow    move.l    (a0),a4
  157.     moveq    #0,d7
  158.     move.b    5(a1),d7
  159.     subq.w    #1,d7
  160.     lea    8(a1),a5
  161. nnxplane
  162.     move.l    (a5)+,a3
  163. nnxbyte    move.w    d2,d6
  164. nnxbytec
  165.     move.b    (a4)+,(a3)+
  166.     subq.l    #1,d1
  167.     bmi.s    nuperr;
  168.     subq.w    #1,d6
  169.     bne.s    nnxbytec
  170.     dbf    d7,nnxplane
  171.     cmp.b    #1,d3
  172.     bne.s    nnomask
  173.  
  174.     move.w    d2,d6
  175. nnxbytem
  176.     addq.l    #1,a4
  177.     subq.l    #1,d1
  178.     bmi.s    nuperr;
  179.     subq.w    #1,d6
  180.     bne.s    nnxbytem
  181.  
  182. nnomask
  183.     bsr.w    sysput
  184.  
  185.     addq.w    #1,(a2)
  186.     move.l    a4,(a0)
  187.     cmp.w    (a2),d0
  188.     bne.s    nnxrow
  189.  
  190. nuperr    movem.l    (sp)+,d2-d7/a2-a6
  191.     rts
  192.  
  193.     ;a0=reqscroll
  194.  
  195. _RealTimeScroll
  196. l3C00    MOVEM.L    D0-D7/A0-A6,-(SP)
  197.     MOVE.L    A0,A3
  198.     MOVE.L    (A3),D0
  199.     MOVE.W    8(A3),D1
  200.     EXT.L    D1
  201.     BSR.W    l3B94
  202.     MOVE.L    D0,D7
  203. l3C14    MOVE.L    D7,D6
  204.     MOVE.L    4(A3),D0
  205.     SUB.L    10(A3),D0
  206.     BLE.W    l3D42
  207.     MOVE.L    14(A3),A0
  208.     MOVE.L    $22(A0),A0
  209.     MOVEQ    #0,D1
  210.     move.w    2(a0),d1
  211.     tst.w    48(a3)
  212.     bne.s    jaska
  213.     MOVE.W    4(A0),D1
  214. jaska    BSR.W    l3BCE
  215.     MOVE.L    D0,D2
  216.     MOVE.W    8(A3),D1
  217.     EXT.L    D1
  218.     BSR.W    l3B94
  219.     MOVE.L    D7,D1
  220.     SUB.L    D0,D1
  221.     MOVE.L    D1,D3
  222.     BEQ.W    l3D42
  223.     NEG.L    D1
  224.     BMI.S    l3C50
  225.     ADDQ.L    #8,D1
  226. l3C50    SUBQ.L    #4,D1
  227.     MOVE.L    D1,D0
  228.     BGE.S    l3C58
  229.     NEG.L    D0
  230. l3C58    MOVE.L    D1,D5
  231.     MOVE.W    #5,D1
  232.     BSR.W    l3BE0
  233.     MOVE.L    D0,D1
  234.     TST.L    D5
  235.     BGE.S    l3C6A
  236.     NEG.L    D1
  237. l3C6A    MOVE.W    8(A3),D4
  238.     MULU    12(A3),D4
  239.     MOVE.L    D4,D5
  240.     LSR.L    #2,D5
  241.     SUB.L    D5,D4
  242.     MOVE.W    8(A3),D5
  243.     EXT.L    D5
  244.     SUB.L    D5,D4
  245.     CMP.L    D4,D1
  246.     BGT.S    l3C8A
  247.     NEG.L    D1
  248.     CMP.L    D4,D1
  249.     BLE.S    l3CA6
  250. l3C8A    MOVE.L    D2,(A3)
  251.     SUB.L    D3,D7
  252.     MOVE.L    $12(A3),A0
  253.     MOVEM.L    D0-D7/A0-A6,-(SP)
  254.     EXG    A0,A3
  255.     MOVE.L    A0,-(SP)
  256.     JSR    (A3)
  257.     ADDQ.W    #4,SP
  258.     MOVEM.L    (SP)+,D0-D7/A0-A6
  259.     BRA.W    l3C14
  260.  
  261. l3CA6    NEG.L    D1
  262.     ADD.L    D1,D7
  263.     MOVE.L    D1,-(SP)
  264.     MOVE.L    D7,D2
  265.     MOVE.L    D6,D3
  266.     TST.L    (SP)
  267.     BPL.S    l3CC0
  268.     MOVE.W    8(A3),D1
  269.     SUBQ.W    #1,D1
  270.     EXT.L    D1
  271.     ADD.L    D1,D2
  272.     ADD.L    D1,D3
  273. l3CC0    MOVE.L    D2,D0
  274.     MOVE.W    8(A3),D1
  275.     BSR.W    l3BE0
  276.     MOVE.L    D0,D1
  277.     MOVE.L    D0,-(SP)
  278.     MOVE.W    8(A3),D0
  279.     EXT.L    D0
  280.     BSR.W    l3B94
  281.     MOVE.L    D0,D1
  282.     MOVE.L    (SP)+,D0
  283.     SUB.L    D7,D1
  284.     MOVEM.L    D0/D1,-(SP)
  285.     MOVE.L    D2,D0
  286.     MOVE.W    8(A3),D1
  287.     BSR.W    l3BE0
  288.     MOVE.L    D0,D2
  289.     MOVE.L    D3,D0
  290.     BSR.W    l3BE0
  291.     MOVE.L    D0,D3
  292.     MOVEM.L    (SP)+,D0/D1
  293.     SUB.L    D2,D3
  294.     BGE.S    l3D20
  295.     NEG.L    D3
  296.     MOVE.L    10(A3),D2
  297.     SUB.L    D3,D2
  298.     ADD.L    D2,D0
  299.     MOVEM.L    D0/D1,-(SP)
  300.     MOVE.L    D2,D0
  301.     MOVE.W    8(A3),D1
  302.     EXT.L    D1
  303.     BSR.B    l3B94
  304.     MOVE.L    D0,D2
  305.     MOVEM.L    (SP)+,D0/D1
  306.     ADD.L    D2,D1
  307. l3D20    MOVE.L    (SP)+,D2
  308.     MOVEM.L    D0-D7/A0-A6,-(SP)
  309.     ;MOVE.L    $1A(A3),-(SP)
  310.     move.l    a3,-(sp)
  311.     MOVEM.L    D0-D3,-(SP)
  312.     MOVE.L    $1A(A3),A0
  313.     EXG    A0,A3
  314.     JSR    (A3)
  315.     ADD.W    #$14,SP
  316.     MOVEM.L    (SP)+,D0-D7/A0-A6
  317.     BRA.W    l3C14
  318.  
  319. l3D42    MOVE.L    D7,D0
  320.     MOVE.W    8(A3),D1
  321.     BSR.W    l3BE0
  322.     MOVE.L    D0,(A3)
  323.     MOVE.L    $16(A3),A0
  324.     MOVE.L    A0,D2
  325.     BEQ.S    l3D66
  326.     MOVEM.L    D0-D7/A0-A6,-(SP)
  327.     EXG    A0,A3
  328.     MOVE.L    A0,-(SP)
  329.     JSR    (A3)
  330.     ADDQ.W    #4,SP
  331.     MOVEM.L    (SP)+,D0-D7/A0-A6
  332. l3D66    MOVE.L    A6,-(SP)
  333.     move.l    40(a3),a6
  334.     JSR    -$10E(A6)
  335.     MOVE.L    (SP)+,A6
  336.     MOVE.L    14(A3),A0
  337.     TST.B    13(A0)
  338.     BMI.W    l3C14
  339.     MOVEM.L    (SP)+,D0-D7/A0-A6
  340.     RTS
  341.  
  342. l3B94    MOVEM.L    D2-D7/A0-A6,-(SP)
  343.     MOVE.W    D1,D2
  344.     MULU    D0,D2
  345.     MOVE.L    D0,D3
  346.     SWAP    D3
  347.     MOVE.L    D1,D4
  348.     SWAP    D4
  349.     MULU    D4,D0
  350.     MULU    D3,D1
  351.     MULU    D4,D3
  352.     SWAP    D0
  353.     SWAP    D1
  354.     MOVE.L    D3,A0
  355.     ADD.W    D0,A0
  356.     ADD.W    D1,A0
  357.     CLR.W    D0
  358.     CLR.W    D1
  359.     ADD.L    D0,D2
  360.     BCC.S    l3BBE
  361.     ADDQ.L    #1,A0
  362. l3BBE    ADD.L    D1,D2
  363.     BCC.S    l3BC4
  364.     ADDQ.L    #1,A0
  365. l3BC4    MOVE.L    A0,D1
  366.     MOVE.L    D2,D0
  367.     MOVEM.L    (SP)+,D2-D7/A0-A6
  368.     RTS
  369.  
  370. l3BCE    BSR.B    l3B94
  371.     MOVE.W    D0,-(SP)
  372.     MOVE.W    D1,D0
  373.     SWAP    D0
  374.     TST.W    (SP)+
  375.     BPL.S    l3BDE
  376.     ADDQ.L    #1,D0
  377. l3BDE    RTS
  378.  
  379. l3BE0    MOVEM.L    D1-D7/A0-A6,-(SP)
  380.     MOVE.L    D0,D2
  381.     CLR.W    D2
  382.     SWAP    D2
  383.     DIVU    D1,D2
  384.     SWAP    D0
  385.     SWAP    D2
  386.     MOVE.W    D2,D0
  387.     SWAP    D0
  388.     DIVU    D1,D0
  389.     MOVE.W    D0,D2
  390.     MOVE.L    D2,D0
  391.     MOVEM.L    (SP)+,D1-D7/A0-A6
  392.     RTS
  393.  
  394.     ;a0=src,a1=dst,d0=len,d1=width
  395.  
  396. _hexconvert
  397.     movem.l    d2-d3/a2,-(sp)
  398.  
  399.     move.l    a1,a2
  400.     move.w    d1,d3
  401.     subq.w    #1,d3
  402. hc5    move.b    #32,(a2)+
  403.     move.b    #32,(a2)+
  404.     move.b    #32,(a2)+
  405.     dbf    d3,hc5
  406.     move.b    #32,(a2)
  407.  
  408.     move.w    d1,d3
  409.     add.w    d1,d3
  410.     add.w    d1,d3
  411.     addq.w    #1,d3
  412.  
  413.     subq.w    #1,d0
  414.     add.w    d1,d1
  415.     lea    1(a1,d1.w),a2
  416. hc3    move.b    (a0)+,d1
  417.     move.b    d1,d2
  418.     cmp.b    #32,d1
  419.     bcc.s    hc4
  420.     moveq    #'.',d2
  421. hc4    move.b    d2,(a2)+
  422.     move.b    d1,d2
  423.     lsr.b    #4,d1
  424.     and.b    #$0f,d1
  425.     cmp.b    #10,d1
  426.     bcs.s    hc1
  427.     addq.b    #7,d1
  428. hc1    add.b    #'0',d1
  429.     move.b    d1,(a1)+
  430.     and.b    #$0f,d2
  431.     cmp.b    #10,d2
  432.     bcs.s    hc2
  433.     addq.b    #7,d2
  434. hc2    add.b    #'0',d2
  435.     move.b    d2,(a1)+
  436.     dbf    d0,hc3
  437.     move.w    d3,d0
  438.     movem.l    (sp)+,d2-d3/a2
  439.     rts
  440.  
  441. _checksum
  442.     move.l    d0,d1
  443.     lsr.l    #2,d1
  444.     moveq    #0,d0
  445. checks2    add.l    (a0)+,d0
  446. checks1    dbf    d1,checks2
  447.     rts
  448.  
  449. _bootsum
  450.     moveq    #0,d0
  451.     move.l    a0,a1
  452.     move.w    #1024/4-1,d1
  453. boots2    add.l    (a0)+,d0
  454.     bcc.s    boots1
  455.     addq.l    #1,d0
  456. boots1    dbf    d1,boots2
  457.     move.l    d0,4(a1)
  458.     rts
  459.  
  460. custom    dc.l    $dff000
  461.  
  462. _initaudio    move.l    custom(pc),a1
  463.     move.w    #%0000000000001111,$96(a1)
  464.     move.w    #%0000011110000000,$9a(a1)
  465.     move.w    #%0000011110000000,$9c(a1)
  466.     move.w    #%0000000011111111,$9e(a1)
  467.     lsr.l    #1,d0
  468.     move.l    a0,$a0(a1)
  469.     move.w    d0,$a4(a1)
  470.     move.w    #64,$a8(a1)
  471.     move.w    d1,$a6(a1)
  472.     move.l    a0,$b0(a1)
  473.     move.w    d0,$b4(a1)
  474.     move.w    #64,$b8(a1)
  475.     move.w    d1,$b6(a1)
  476.     move.w    #%1000000000000011,$96(a1)
  477.     rts
  478. _endaudio    move.l    custom(pc),a1
  479.     move.w    #%0000000000001111,$96(a1)
  480.     move.w    #%0000000110000000,$9c(a1)
  481.     rts
  482. _startaudio
  483.     move.l    custom(pc),a1
  484.     move.w    #%0000000110000000,$9c(a1)
  485.     lsr.l    #1,d0
  486.     move.l    a0,$a0(a1)
  487.     move.w    d0,$a4(a1)
  488.     move.l    a0,$b0(a1)
  489.     move.w    d0,$b4(a1)
  490.     rts
  491. _waitaudio    move.l    a6,-(sp)
  492.     move.l    a0,a6
  493. wa2    move.l    custom(pc),a1
  494.     move.w    $1e(a1),d0
  495.     and.w    #%0000000110000000,d0
  496.     bne.s    wa1
  497.     moveq    #10,d1
  498.     jsr    -$00c6(a6)
  499.     bra.s    wa2
  500. wa1    move.l    (sp)+,a6
  501.     rts
  502.  
  503.  
  504. _formathook
  505.     move.l    a1,d0
  506.     move.l    16(a0),a1
  507.     move.b    d0,(a1)
  508.     addq.l    #1,16(a0)
  509.     rts
  510.  
  511.  
  512.     ;a0=source,a1=dest,d0=len
  513. _rlepack
  514.     move.l    a2,-(sp)
  515.     link    a5,#-12
  516.     ext.l    d0
  517.     move.l    d0,-(sp)
  518.     lea    -4(a5),a2
  519.     move.l    a1,(a2)
  520.     move.l    a2,-(sp)
  521.     lea    -8(a5),a2
  522.     move.l    a0,(a2)
  523.     move.l    a2,-(sp)
  524.     bsr.w    packrow
  525.     lea    12(sp),sp
  526.     unlk    a5
  527.     move.l    (sp)+,a2
  528.     rts
  529.  
  530. PT    equr  a0                ;-> beginning of replicate run (if any) 
  531. IX    equr  a1                ;-> end+1 of input line 
  532. IP    equr  a2                ;-> beginning of literal run (if any) 
  533. IQ    equr  a3                ;-> end+1 of lit and/or rep run (if any) 
  534. OP    equr  a4                ;-> end+1 of output line current pos 
  535. FP    equr  a6                ;frame pointer 
  536. ;SP    equr  a7               ; stack pointer 
  537. RT    equr  d0                ;return value 
  538. MX    equr  d1                ;check for maximum run = MAX 
  539. AM    equr  d2                ;amount 
  540. CH    equr  d3                ;character 
  541. REGS  reg   AM/CH/IP/IQ/OP 
  542. FRM   equ   8                 ;input line address 
  543. TOO   equ   12                ;output line address 
  544. AMT   equ   16                ;length of input line 
  545. MAX   equ   128               ;maximum encodable output run 
  546. CHECK equ   1                 ;turns on maximum row checking 
  547.  
  548.  
  549. packrow 
  550.  
  551.  
  552. CAS0    link     FP,#0 
  553.     movem.l  REGS,-(SP) 
  554.     movea.l  FRM(FP),IP 
  555.     movea.l  (IP),IP      ;IP = *from 
  556.     movea.l  IP,IQ      ;IQ = IP 
  557.     movea.l  IQ,IX 
  558.     adda.l   AMT(FP),IX    ;IX = IP + amt 
  559.     movea.l  TOO(FP),OP 
  560.     movea.l  (OP),OP      ;OP = *too 
  561. CAS1    movea.l  IQ,PT      ;adjust PT (no replicates yet!) 
  562.     move.b   (IQ)+,CH      ;grab character 
  563.     cmpa.l   IQ,IX      ;if input is finished 
  564.     beq.s    CAS5      ;branch to case 5 
  565.     ifd    CHECK 
  566.     move.l   IQ,MX 
  567.     sub.l    IP,MX 
  568.     cmpi     #MAX,MX      ;if run has reached MAX 
  569.     beq.s    CAS6      ;branch to case 6 
  570.     endc 
  571.     cmp.b    (IQ),CH      ;if next character != CH 
  572.     bne.s    CAS1      ;stay in case 1 
  573. CAS2    move.b   (IQ)+,CH      ;grab character 
  574.     cmpa.l   IQ,IX      ;if input is finished 
  575.     beq.s    CAS7      ;branch to case 7 
  576.     ifd    CHECK 
  577.     move.l   IQ,MX 
  578.     sub.l    IP,MX 
  579.     cmpi     #MAX,MX      ;if run has reached MAX 
  580.     beq.s    CAS6      ;branch to case 6 
  581.     endc 
  582.     cmp.b    (IQ),CH      ;if next character != CH 
  583.     bne.s    CAS1      ;branch to case 1 
  584. CAS3    move.b   (IQ)+,CH      ;grab character 
  585.     cmpa.l   IQ,IX       ; if input is finished 
  586.     beq.s    CAS7        ;  branch to case 7 
  587.     ifd    CHECK 
  588.     move.l   IQ,MX 
  589.     sub.l    PT,MX 
  590.     cmpi     #MAX,MX      ;if run has reached MAX 
  591.     beq.s    CAS4        ;  branch to case 4 
  592.     endc 
  593.     cmp.b    (IQ),CH      ;if next character = CH 
  594.     beq.s    CAS3        ;  stay in case 3 
  595. CAS4    move.l   PT,AM 
  596.     sub.l    IP,AM        ;AM = PT - IP 
  597.     beq.s    C41           ;branch to replicate run 
  598.     subq     #1,AM        ;AM = AM - 1 
  599.     move.b   AM,(OP)+     ;output literal control byte 
  600. C40    move.b   (IP)+,(OP)+    ;output literal run 
  601.     dbra     AM,C40 
  602. C41    move.l   PT,AM 
  603.     sub.l    IQ,AM        ;AM = PT - IQ (negative result!) 
  604.     addq     #1,AM        ;AM = AM + 1 
  605.     move.b   AM,(OP)+     ;output replicate control byte 
  606.     move.b   CH,(OP)+     ;output repeated character 
  607.     movea.l  IQ,IP      ;  reset IP 
  608.     bra.s    CAS1       ;  branch to case 1 (not done) 
  609. CAS5    move.l   IQ,AM 
  610.     sub.l    IP,AM        ;AM = IQ - IP (positive result > 0) 
  611.     subq     #1,AM        ;AM = AM - 1 
  612.     move.b   AM,(OP)+     ;output literal control byte 
  613. C50    move.b   (IP)+,(OP)+   ; output literal run 
  614.     dbra     AM,C50 
  615.     bra.s    CAS8       ;  branch to case 8 (done) 
  616.     ifd    CHECK 
  617. CAS6    move.l   IQ,AM 
  618.     sub.l    IP,AM        ;AM = IQ - IP (positive result > 0) 
  619.     subq     #1,AM        ;AM = AM - 1 
  620.     move.b   AM,(OP)+     ;output literal control byte 
  621. C60    move.b   (IP)+,(OP)+   ; output literal run 
  622.     dbra     AM,C60 
  623.     bra    CAS1       ;  branch to case 1 (not done) 
  624.     endc 
  625. CAS7    move.l   PT,AM 
  626.     sub.l    IP,AM       ; AM = PT - IP (positive result > 0) 
  627.     beq.s    C71           ;branch to replicate run 
  628.     subq     #1,AM        ;AM = AM - 1 
  629.     move.b   AM,(OP)+     ;output literal control byte 
  630. C70    move.b   (IP)+,(OP)+   ; output literal run 
  631.     dbra     AM,C70 
  632. C71    move.l   PT,AM 
  633.     sub.l    IQ,AM       ; AM = PT - IQ (negative result) 
  634.     addq     #1,AM       ; AM = AM + 1 
  635.     move.b   AM,(OP)+     ;output replicate control byte 
  636.     move.b   CH,(OP)+     ;output repeated character 
  637. CAS8    movea.l  FRM(FP),PT   ;  PT = **from 
  638.     move.l   IQ,(PT)     ; *from = *from + amt 
  639.     movea.l  TOO(FP),PT   ;  PT = **too 
  640.     move.l   OP,RT 
  641.     sub.l    (PT),RT     ;return = OP - *too  
  642.     move.l   OP,(PT)     ;*too = *too + return 
  643.     movem.l  (SP)+,REGS 
  644.     UNLK     FP 
  645.     rts 
  646.  
  647.     ;a0-source,a1-dest,d0=len
  648.  
  649. _rleunpack
  650. unpack    move.l    d2,-(sp)
  651. ccnext    moveq    #0,d2
  652.     move.b    (a0)+,d2
  653.     bmi.s    ccnega
  654. ccident    move.b    (a0)+,(a1)+
  655.     subq.w    #1,d0
  656.     beq.s    ccend
  657.     dbf    d2,ccident
  658.     bra.s    ccnext
  659. ccnega    move.b    (a0)+,d1
  660.     neg.b    d2
  661. ccdupl    move.b    d1,(a1)+
  662.     subq.w    #1,d0
  663.     beq.s    ccend
  664.     dbf    d2,ccdupl
  665.     bra.s    ccnext
  666. ccend    move.l    a0,d0
  667.     move.l    (sp)+,d2
  668.     rts
  669.  
  670.  
  671.     section __MERGED,data
  672.  
  673. _regform    incbin    "reg.form"
  674. _fmexe        incbin    "fmexe"
  675. _fmexee
  676.