home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / proasm / routines / script.r < prev    next >
Text File  |  1992-12-17  |  4KB  |  196 lines

  1.  
  2. ;---;  scripts.r  ;------------------------------------------------------------
  3. *
  4. *    ****    ROUTINES TO DEAL WITH BATCHES    ****
  5. *
  6. *    Author        Stefan Walter
  7. *    Version        1.00
  8. *    Last Revision    21.07.92
  9. *    Identifier    sab_defined
  10. *    Prefix        sab_    (scripts and batches)
  11. *                 ¯       ¯   ¯
  12. *    Functions    OpenScript, CloseScript, GetScriptCom, GetScriptArgs
  13. *    Macros        AddSArg_, AddSCom_
  14. *
  15. ;-------------------------------------------------------------------------------
  16. *
  17. *
  18. *
  19. ;-------------------------------------------------------------------------------
  20.  
  21. ;------------------
  22.     ifnd    sab_defined
  23. sab_defined    =1
  24.  
  25. ;------------------
  26. sab_oldbase    equ __base
  27.     base    sab_base
  28. sab_base:
  29.  
  30. ;------------------
  31.  
  32. ;------------------------------------------------------------------------------
  33. *
  34. * AddSCom_    Add a command to the command list.
  35. *
  36. * USAGE        AddSCom_ name,flags,arg1info,arg2info,...
  37. ;------------------------------------------------------------------------------
  38.  
  39. ;------------------
  40. AddSCom_
  41. ;------------------
  42.  
  43. ;------------------------------------------------------------------------------
  44. *
  45. * EndSCom_    End the command list.
  46. *
  47. * USAGE        EndSCom_
  48. *
  49. ;------------------------------------------------------------------------------
  50.  
  51. ;------------------
  52. EndSCom_    macro    
  53.  
  54. ;------------------
  55. ; Simply a dc.w 0.
  56. ;
  57.     dc.w    0
  58.     endm
  59.  
  60. ;------------------
  61.  
  62. ;------------------------------------------------------------------------------
  63. *
  64. * OpenScript    Opens a script and inits for reading it.
  65. *
  66. * INPUT:    a0    Script name
  67. *
  68. * RESULT:    d0    Addres of script or 0 if failed
  69. *        ccr    On d0
  70. *
  71. ;------------------------------------------------------------------------------
  72.  
  73. ;------------------
  74. OpenScript:
  75.  
  76. ;------------------
  77. ; Do all.
  78. ;
  79. \start:
  80.     movem.l    d1-a6,-(sp)
  81.     lea    sab_base(pc),a4
  82.     moveq    #1,d0
  83.     move.l    d0,sab_linenr(a4)
  84.  
  85.     move.l    a0,d0
  86.     moveq    #0,d1
  87.     moveq    #1,d2
  88.     bsr    LoadFile
  89.     move.l    d2,sab_length(a4)
  90.     move.l    d0,sab_script(a4)
  91.     beq.s    \done
  92.     move.l    d0,sab_current(a4)
  93.  
  94. \done:
  95.     movem.l    (sp)+,d1-a6
  96.     rts
  97.  
  98. ;------------------
  99.  
  100. ;------------------------------------------------------------------------------
  101. *
  102. * CloseScript    Closes the opened script.
  103. *
  104. ;------------------------------------------------------------------------------
  105.  
  106. ;------------------
  107. CloseScript:
  108.  
  109. ;------------------
  110. ; Do all.
  111. ;
  112. \start:
  113.     movem.l    d0-a6,-(sp)
  114.     lea    sab_script(pc),a0
  115.     tst.l    (a0)
  116.     beq.s    \done
  117.     move.l    (a0),a1
  118.     clr.l    (a0)
  119.     move.l    sab_length(pc),d0
  120.     move.l    4.w,a6
  121.     jsr    -210(a6)        ;FreeMem()
  122.  
  123. \done:
  124.     movem.l    8sp)+,d0-a6
  125.     rts
  126.  
  127. ;------------------
  128.  
  129. ;------------------------------------------------------------------------------
  130. *
  131. * GetScriptCom    Get next 'command line' from script and extract command info.
  132. *
  133. * INPUT        a0    Buffer (200 bytes)
  134. *
  135. * RESULT    a0    Pointer in buffer on first argument
  136. *        a1    Pointer to command info struct or 0
  137. *        d0    Line length or 0 if no more lines
  138. *        d1    Line number
  139. *        ccr    On d0
  140. *
  141. ;------------------------------------------------------------------------------
  142.  
  143. ;------------------
  144. CetScriptCom:
  145.  
  146. ;------------------
  147. ; Do all.
  148. ;
  149. \start:
  150.     movem.l    d2-d7/a2-a6,-(sp)
  151.     lea    sab_base(pc),a4
  152.     move.l    a0,d7
  153.     
  154.     move.l    sab_current(pc),a0
  155.     move.l    d7,a1
  156.     move.l    sab_linenr(pc),d1
  157.     bsr    CopyLine
  158.     move.l    a0,sab_current(a4)
  159.     move.l    d1,sab_linenr(a4)
  160.     tst.l    d0
  161.     beq.s    \done
  162.  
  163. \findcommand:
  164.     
  165. \done:
  166.     tst.l    d0
  167.     movem.l    (sp)+,d2-d7/a2-a6
  168.     rts
  169.  
  170. ;------------------
  171.  
  172. ;--------------------------------------------------------------------
  173.  
  174. ;------------------
  175.     include    dosfile.r
  176.     include    parse.r
  177.  
  178. ;------------------
  179. ; Script handling
  180. ;
  181. sab_script:    dc.l    0
  182. sab_length:    dc.l    0
  183. sab_current:    dc.l    0
  184. sab_linenr:    dc.l    0
  185.  
  186. ;--------------------------------------------------------------------
  187.  
  188. ;------------------
  189.     base    sab_oldbase
  190.  
  191. ;------------------
  192.     endif
  193.  
  194.     end
  195.  
  196.