home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / AGStrip / AGS.S
Text File  |  1993-12-21  |  3KB  |  192 lines

  1. *************************************************
  2. *                        *
  3. *         (C)opyright 1993        *
  4. *                        *
  5. *          Tomi Blinnikka        *
  6. *                        *
  7. *    Don't try to understand the code    *
  8. *                        *
  9. * Version 1.00    31/05/1993            *
  10. *                        *
  11. * BUGS:                        *
  12. *                        *
  13. *************************************************
  14.     INCLUDE    "JMPLibs.i"
  15.     INCLUDE    "libraries/dos.i"
  16.  
  17.     INCLUDE    "XREF:2.0.xref"
  18.     INCLUDE    "XREF:exec.xref"
  19.     INCLUDE    "XREF:dos.xref"
  20.  
  21.  
  22. BUFSIZE:    EQU    #2000
  23.  
  24.         section    AGS,CODE
  25.  
  26.         openlib    Dos,NoDos
  27.  
  28.         lea.l    CLTemplate1,a0
  29.         move.l    a0,d1
  30.         lea.l    CLArray1,a0
  31.         move.l    a0,d2
  32.         clr.l    d3
  33.         lib    Dos,ReadArgs
  34.         move.l    d0,RDArgs1
  35.         beq    NoRDArgs
  36.  
  37.         lib    Dos,Output
  38.         move.l    d0,_stdout
  39.  
  40.         move.l    FromFile,d1
  41.         move.l    #MODE_OLDFILE,d2
  42.         lib    Dos,Open
  43.         move.l    d0,InputFile
  44.         beq    File_ERR1
  45.  
  46.         move.l    ToFile,d1
  47.         move.l    #MODE_OLDFILE,d2
  48.         lib    Dos,Open
  49.         move.l    d0,OutputFile
  50.         beq    File_ERR1
  51.  
  52.         move.l    InputFile,d1
  53.         lea.l    Buffer1,a0
  54.         move.l    a0,d2
  55.         move.l    #BUFSIZE,d3
  56.         lib    Dos,Read
  57.         move.l    d0,d3        ;Get amount read
  58.         bsr    Strip
  59.  
  60.  
  61.         bra    ShutDown
  62.  
  63. ;Input d3 = amount to do
  64.  
  65. Strip:        lea.l    Buffer1,a0
  66.         move.l    a0,a1
  67.         add.l    d3,a1
  68.  
  69.         cmp.b    #'@',(a0)
  70.         bne    Strip3
  71.  
  72.         add.l    #1,a0        ;skip '@'
  73.  
  74.         cmp.b    #'{',(a0)
  75.         bne    Strip2
  76.         move.w    #1,Status
  77.  
  78.         add.l    #1,a0        ;skip '{'
  79.         bra    Strip3
  80.  
  81. Strip2:        sub.l    #1,a0        ;go back one step (print '@')
  82.  
  83. Strip3:        cmp.b    #'}',(a0)
  84.         bne    Strip4
  85.  
  86.         tst.w    Status
  87.         beq    Strip4
  88.  
  89.         clr.w    Status
  90.         add.l    #1,a0        ;skip '}'
  91.  
  92. Strip4:        tst.w    Status
  93.         beq    Strip8
  94.  
  95.         cmp.b    #'{',(a0)
  96.         bne    Strip6
  97.  
  98.         add.l    #1,a0        ;Skip '{'
  99.         move.w    #2,Status
  100.  
  101. Strip6:        cmp.b    #'}',(a0)
  102.         bne    Strip7
  103.  
  104. Strip7:
  105.  
  106. Strip8:
  107.  
  108.         cmp.l    a0,a1
  109. ;        beq    Strip_OUT
  110.  
  111. Strip_OUT:    rts
  112.  
  113.  
  114. File_ERR1:    bsr    PrintDosFault
  115.         bra    ShutDown
  116.  
  117.  
  118. ShutDown:    move.l    RDArgs1,d1
  119.         beq    ShutDown9000
  120.         lib    Dos,FreeArgs
  121.  
  122. ShutDown9000:    move.l    InputFile,d1
  123.         beq    ShutDown8900
  124.         lib    Dos,Close
  125. ShutDown8900:    move.l    OutputFile,d1
  126.         beq    ShutDown8800
  127.         lib    Dos,Close
  128. ShutDown8800:
  129.  
  130.  
  131. ShutDown1000:    closlib    Dos
  132.         move.l    #RETURN_OK,d0
  133.         rts
  134.  
  135. NoDos:        move.l    #RETURN_FAIL,d0
  136.         rts
  137.  
  138. NoRDArgs:    bsr    PrintDosFault
  139.         bra    ShutDown
  140.  
  141. PrintDosFault:    lib    Dos,IoErr
  142.         move.l    d0,d1
  143.         clr.l    d2
  144.         lib    Dos,PrintFault
  145.         rts
  146.  
  147. Printer:    printa    a0,_stdout
  148.         rts
  149.  
  150. ;Library stuff
  151.  
  152.         libnames
  153.  
  154. ;Reservations
  155.  
  156. RDArgs1:    dc.l    0
  157.  
  158. ;Options
  159.  
  160. CLArray1:
  161. FromFile:    dc.l    0
  162. ToFile:        dc.l    0
  163.  
  164. ;Files
  165.  
  166. InputFile:    dc.l    0
  167. OutputFile:    dc.l    0
  168. _stdout:    dc.l    0
  169.  
  170. ;Other stuff
  171.  
  172. Status:        dc.w    0        ;0=normal text, 1=in {}
  173.  
  174. ;Strings, part I
  175.  
  176. CLTemplate1:    dc.b    "FROM/A,TO/A",0
  177. VersionString:    dc.b    "$VER: AGStrip 1.00 (31.05.93) (C)opyright Tomi Blinnikka 1993",0
  178.  
  179.  
  180. ;Strings, part II
  181.  
  182.         ds.l    0
  183.  
  184.  
  185. ;Other stuff, part II
  186.  
  187.  
  188. Buffer1:    dcb.b    #BUFSIZE,0
  189.  
  190.  
  191.         end
  192.