home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d501 / doswatch.lha / DOSWatch / DOSWatch.s < prev    next >
Text File  |  1991-06-27  |  34KB  |  1,512 lines

  1.         OPT    L-,C+,D-,M+                    ;NOlink,case dependant,NOdebug
  2.  
  3.         ;
  4.         ;  DOSWatch 1.0  MAY-1991
  5.         ;
  6.         ;  by
  7.         ;
  8.         ;  Andreas Voß Wrede
  9.         ;  Emdener Straße 11
  10.         ;  4400 Münster/Westfalen
  11.         ;  (WEST) GERMANY
  12.         ;  DATEXP: PSI%4589004317::VOSS_WREDE
  13.         ;
  14.         ;  with a little help from
  15.         ;  HiSoft GenAmiga V1.21 Assembler
  16.         ;
  17.  
  18.         INCDIR    "VWINC:"            ;where to look
  19.  
  20.         ;
  21.         include    exec/exec.i
  22.         include    exec/exec_lib.i            ;I want to call EXEC
  23.         include    exec/execbase.i            ;I want to call EXEC
  24.         include    libraries/dos_lib.i        ;and DOS
  25.         include    libraries/dos.i
  26.         include    libraries/dosextens.i
  27.         include    workbench/startup.i
  28.         include    workbench/workbench.i
  29.         include    workbench/icon_lib.i
  30.  
  31.         ;
  32.         ; some startup code to make a Workbench execute look like the CLI
  33.         ; based loosely on RKM Vol 1 page 4-36
  34.         ;        
  35.         EVEN
  36.  
  37.         movem.l    d0/a0,-(sp)            ;save initial values
  38.  
  39.         clr.l    returnMsg            ;WB message
  40.         sub.l    a1,a1
  41.         CALLEXEC FindTask            ;find us
  42.         move.l    d0,a4
  43.         tst.l    pr_CLI(a4)            ;called by a CLI?
  44.         beq.s    fromWorkbench
  45.  
  46.         ;
  47.         ; we were called from the CLI
  48.         ;
  49.         move.b    #0,_WB                ;WB flag
  50.         bra    end_startup            ;and run the user prog
  51.  
  52.         ;
  53.         ; we were called from the Workbench
  54.         ;
  55. fromWorkbench:    move.b    #1,_WB                ;workbench flag
  56.         lea    pr_MsgPort(a4),a0
  57.         CALLEXEC WaitPort            ;wait for a message
  58.         lea    pr_MsgPort(a4),a0
  59.         CALLEXEC GetMsg                ;then get it
  60.         move.l    d0,returnMsg            ;save it for later reply
  61.  
  62.         ;
  63.         ; do some other stuff here RSN like the command line etc
  64.         ; start by opening the DOS library
  65.         ;
  66. end_startup:    move.l    #dosname,a1            ;"dos.library"
  67.         moveq    #0,d0                ;any version
  68.         CALLEXEC OpenLibrary
  69.         move.l    d0,_DOSBase            ;save pointer
  70.  
  71.         ;
  72.         ; open icon lib to get WB parameter
  73.         ;
  74.         move.l    #iconname,a1            ;"icon.library"
  75.         moveq    #0,d0                ;any version
  76.         CALLEXEC OpenLibrary
  77.         move.l    d0,_ICONBase            ;save pointer
  78.  
  79.         ;
  80.         ; open my window 
  81.         ;
  82.         move.l    #WindowName,d1
  83.         move.l    #1005,d2            ;mode old    
  84.         CALLDOS    Open
  85.         move.l    d0,_VWOutHandle            ;output handle
  86.         move.l    d0,_VWInpHandle            ;input handle
  87.  
  88.         ;
  89.         ; command interface regs from CLI or WB
  90.         ;
  91.         movem.l    (sp)+,d0/a0            ;restore regs
  92.         cmp.b    #0,_WB                ;son of WB?
  93.         beq.s    _ComLin                ;no,from CLI
  94.  
  95.  
  96.         ; WB parameter 
  97.         ; .info must be a project with DOSWatch as the
  98.         ;  default tool [the tool type entry is optional]
  99.         ; * IMPORTANT* .info file must be in same directory
  100.         ; as the tool DOSWatch
  101.         ;
  102.         ; e.g. default tool: DH3:DOSWatch -> sm_NumArgs=2
  103.         ; wa_Name(1)="DH3:DOSWatch"
  104.         ; wa_Name(2)="DOSWatch"
  105.  
  106.         move.l    returnMsg,a2            ; WB message
  107.         move.l    sm_ArgList(a2),a0        ; arguments
  108.         move.l    wa_Name(a0),a0            ; get name of tool
  109.         move.l    a0,a5                ; save pointer
  110.  
  111.         move.l    _ICONBase,a6
  112.         jsr    _LVOGetDiskObject(a6)        ; read .info file
  113.  
  114.         tst.l    d0
  115.         bne.s    _ObjOK                ; cant read .info
  116.         move.l    #_maintxt003,d2            ; so print a 
  117.         jsr    _VWQStrOut            ; warning message
  118.         move.l    a5,d2                ; restore name
  119.         jsr    _VWQStrOut
  120.         move.l    #_maintxt004,d2
  121.         jsr    _VWQStrOut
  122.  
  123.  
  124. _ObjOK:        move.l    d0,a2
  125.         move.l    do_ToolTypes(a2),a0
  126.         move.l    (a0),a0                ; ->tool type array
  127.         move.l    a0,a2
  128.         move.l    #0,d0                ; find length of parameter
  129. _fzero:        add.l    #1,d0
  130.         cmp.b    #0,(a2)+
  131.         bne.s    _fzero    
  132.  
  133.         ; CLI call or tailored WorkBench SETUP
  134.         ;
  135.         ; check for leading ? in command line
  136.         ;
  137. _ComLin:    cmp.l    #1,d0                ; command line
  138.         ble    _go                ; NO parameter
  139.  
  140.         ; 
  141.         ; we have to replace ending CR with ZERO due to open LOG
  142.         ; <d0> is length of command line
  143.         ;
  144.         sub    #1,d0
  145.         move.b    #0,(a0,d0)
  146.  
  147.         ;
  148.         ; info required ?
  149.         ;
  150.         cmp.b    #"?",(a0)
  151.         bne.l    _check1
  152.  
  153.         ;
  154.         ; print usage info text
  155.         ;
  156. _check0:    move.l    #_maintxt00,d2
  157.         jsr    _VWQStrOut
  158.         move.l    #100,d1                ; wait 2 sex
  159.         CALLDOS    Delay
  160.         bra    _fromMain
  161.  
  162.         ;
  163.         ; print illegal parameter
  164.         ;
  165. _check01:    move.l    #_maintxt001,d2
  166.         jsr    _VWQStrOut
  167.         move.l    #100,d1                ; wait 2 sex
  168.         CALLDOS    Delay
  169.         bra    _fromMain
  170.  
  171.         ;
  172.         ; check command line
  173.         ;
  174. _check1:    cmp.b    #"I",(a0)+            ; with read/write?
  175.         beq.s    _check2
  176.         sub.l    #1,a0
  177.         bra.s    _check3
  178. _check2:    cmp.b    #"O",(a0)+
  179.         bne.s    _check01
  180.         move.b    #1,_RWflag
  181.         cmp.b    #3,d0
  182.         ble    _go                ; NO more qualifier
  183.         cmp.b    #" ",(a0)+
  184.         bne.s    _check01
  185.  
  186. _check3:    cmp.b    #"L",(a0)+            ; LOG file requested?
  187.         bne.s    _check01
  188.         cmp.b    #"O",(a0)+
  189.         bne.s    _check01
  190.         cmp.b    #"G",(a0)+
  191.         bne.s    _check01
  192.         cmp.b    #" ",(a0)+
  193.         bne.s    _check01
  194.  
  195.         ;
  196.         ; open logfile
  197.         ;
  198.         move.l    a0,d1                ; filename start
  199.         move.l    #1006,d2            ; mode new
  200.         CALLDOS    Open
  201.         move.l    d0,_VWLogHandle            ;log handle
  202.         cmp.l    #0,d0
  203.         bne    _go
  204.         
  205.         ;
  206.         ; error opening  logfile
  207.         ;
  208.         move.l    #_maintxt002,d2
  209.         jsr    _VWQStrOut
  210.         move.l    _LOGfile,d2
  211.         jsr    _VWQStrOut
  212.         move.l    #100,d1                ; wait 2 sex
  213.         CALLDOS    Delay
  214.         bra    _fromMain
  215.  
  216.         ;
  217.         ; main program
  218.         ;
  219.  
  220. _go:        bsr    _main                ;call our program
  221.  
  222.         ;
  223.         ; returns to here with exit code in d0
  224.         ;
  225. _fromMain:    move.l    d0,-(sp)            ;save it
  226.         tst.l    returnMsg
  227.         beq.s    exitToDOS            ;if I was a CLI
  228.  
  229.         CALLEXEC Forbid
  230.         move.l    returnMsg(pc),a1
  231.         CALLEXEC ReplyMsg
  232.  
  233.         ;
  234.         ; close window and DOS library
  235.         ;
  236. exitToDOS:    move.l    _VWOutHandle,d1
  237.         CALLDOS    Close        
  238.         move.l    _DOSBase,a1
  239.         CALLEXEC CloseLibrary
  240.  
  241.         ; close icon lib
  242.         ;
  243.         move.l    _ICONBase,a1
  244.         CALLEXEC CloseLibrary
  245.  
  246.         move.l    (sp)+,d0            ; restore exit code
  247.         RTS
  248.  
  249.         ;
  250.         ; startup code variable
  251.         ;
  252.         EVEN
  253. _WB:        dc.b    0
  254. returnMsg:    dc.l    0
  255. _VWOutHandle:    dc.l    0
  256. _VWInpHandle:    dc.l    0
  257. _DOSBase:    dc.l    0
  258. _ICONBase:    dc.l    0
  259. dosname        DOSNAME
  260.         EVEN
  261. iconname:    dc.b    "icon.library",0
  262.         EVEN
  263. WindowName:    dc.b    "CON:0/50/639/120/  DOSWatch V1.0  BY avw  [press F3 to quit]",0
  264.         EVEN
  265.  
  266.  
  267.         ;
  268.         ; maiiiiiin proogram
  269.         ;
  270.  
  271. _main:        move.l    _SysBase,a6        ; a very important adress
  272.         move.l    ThisTask(a6),d5        ; save it in d5
  273.         move.l    d5,_ThisTask
  274.  
  275.  
  276.     ; get DOS dispatch vector
  277.  
  278.         move.l    _DOSBase,d0
  279.         sub.l    #$1e,d0            ;e.g. c04ada OPEN WB1.2 1MB
  280.         addq    #4,d0
  281.         move.l    d0,a1
  282.         move.w    (a1),d1            ;e.g. $68
  283.         add.w    d1,d0
  284.         move.l    d0,_DOSVec        ;will be patched
  285.         addq    #6,d0
  286.         move.l    d0,_DOSVec1        ;original code
  287.  
  288.  
  289.     ; get a free signal
  290.  
  291.         move.l    #-1,d0            ; this one is for
  292.         jsr    _LVOAllocSignal(a6)    ; waking DOSWatch up -
  293.         move.l    d0,_Signal        ; from DOS calling task
  294.  
  295.  
  296.     ; init F3 dispatcher 
  297.  
  298.         jsr    _VWf3            ; interrupt service F3 key
  299.  
  300.     ; patch central DOS entry
  301.  
  302.         jsr    _LVODisable(a6)        ; no interrupts
  303.         move.l    _DOSVec,a0        ; central DOS entry via LIB
  304.         move.w    #$4ef9,(a0)+          ; JMP
  305.         move.l    #_NEWcode,(a0)        ; into my code
  306.         jsr    _LVOEnable(a6)        ; enable interrupting
  307.  
  308.     ; prepare TV buffer
  309.  
  310.         jsr    _VWInitTV        ; output into memory
  311.  
  312.  
  313.     ; BEGIN OF MAIN LOOP
  314.     ;
  315.     ; wait for signal from patch routine -
  316.     ; print some results if DOScall is NOT issued by this program
  317.  
  318. _main1:        move.l    _SysBase,a6            ; 
  319.         move.l    #8,d6                ; digits _VWHexOut
  320.         move.l    #0,_used            ; reset used flag
  321.  
  322.     ; wait for signal from patched DOS code executed by calling task
  323.  
  324.         move.l    _Signal,d0            ; wait for this
  325.         jsr    _LVOWait(a6)            ; and waaiiiit
  326.  
  327.     ; we got a signal - 
  328.     ; is it a signal from the F3 interrupt routine?
  329.  
  330.         move.l    _finish,d0            ; may be set by
  331.         cmp.l    #-1,d0                ; F3 handler
  332.         beq.l    _main5                ; remove it
  333.  
  334.  
  335.     ; check RWflag (exclude READ WRITE calls ?)
  336.  
  337.         cmp.b    #0,_RWflag
  338.         bne    _main1x                ; DON'T ignore RW
  339.  
  340.         move.l    _DOSfunction,d0            ; is it
  341.         cmp.b    #-$03,d0            ; READ ? 
  342.         beq    _main1                ; yes
  343.                             ; is ist 
  344.         cmp.b    #-$06,d0            ; WRITE ?
  345.         beq    _main1                ; yes
  346.         
  347.  
  348.        ; **** disable further DOS calls  during display ****
  349.  
  350. _main1x:    jsr    _LVODisable(a6)            ; disable interrupting
  351.  
  352.     ; timestamp and name of task who called DOS
  353.  
  354.         move.l    _DOSTask,a1            ; calling task
  355.         move.l    #_maintxt04,d2
  356.         jsr    _VWMQStrOut            ; string out 
  357.         jsr    _VWMTimeStamp            ; time string
  358.         ; print " from "
  359.         move.l    #_maintxt05,d2
  360.         jsr    _VWMQStrOut
  361.         ; name of task 
  362.         move.l    10(a1),d2            ; calling task name
  363.         jsr    _VWMQStrOut            ; and print
  364.  
  365.     ; name of command loaded (only for a process)
  366.  
  367.         move.l    8(a1),d0            ; put ln_type
  368.         and.l    #$ff000000,d0            ; into a byte
  369.         rol.l    #8,d0                ; 
  370.         cmpi    #13,d0                ; is it a process?
  371.         bne.s    _main3                ; NO
  372.  
  373.         move.l    pr_TaskNum(a1),d0        ; Command Name
  374.         beq.s    _main3                ; empty
  375.         move.l    #_maintxt34,d2            ; [ delimiter
  376.         jsr    _VWMQStrOut
  377.         move.l    pr_CLI(a1),d2
  378.         asl.l    #2,d2                ; BCPL convert
  379.         move.l    d2,a2
  380.         move.l    cli_CommandName(a2),d2
  381.         asl.l    #2,d2                ; BCPL convert
  382.         move.l    d2,a2
  383.         move.l    #0,d4
  384.         move.b    (a2),d4                ; BCPL str len
  385.         cmp.l    #15,d4
  386.         ble.s    _main2
  387.         move.l    #15,d4
  388. _main2:        add.l    #1,d2                ; BCPL string
  389.         jsr    _VWMQStrOutB            ; BCPL out
  390.         move.l    #_maintxt35,d2            ; ] delimiter
  391.         jsr    _VWMQStrOut
  392.  
  393.     ; called DOS function (contents of d0)
  394.  
  395. _main3:        ; print %%%%%%%%%
  396.         move.l    #_maintxt06,d2
  397.         jsr    _VWMQStrOut
  398.         jsr    _VWMPrtCrLf
  399.  
  400.         move.l    _DOSfunction,d0
  401.         move.l    #8,d6            ; 8 digits for output
  402.  
  403.     ; process info about alled DOS function
  404.     ; move it into TV buffer
  405.  
  406.         ; < Execute >,-$1b,_DOSRegD1,<NL>,< status:>
  407. _mainf00:    cmp.b    #-$1b,d0
  408.         bne    _mainf01
  409.         move.l    #_maint00,d2
  410.         jsr    _VWMQStrOut
  411.         move.l    _DOSretD0,d0        ; status
  412.         jsr    _VWMHexOutZ
  413.         move.l    #_maintxt01,d2        ; = (
  414.         jsr    _VWMQStrOut
  415.         move.l    _DOSRegD1,d2        ; command
  416.         jsr    _VWMQStrOut
  417.         move.l    #_maintxt02,d2        ; ,
  418.         jsr    _VWMQStrOut
  419.         move.l    _DOSRegD2,d2        ; input
  420.         jsr    _VWMHexOutZ
  421.         move.l    #_maintxt02,d2        ; ,
  422.         jsr    _VWMQStrOut
  423.         move.l    _DOSRegD3,d0        ; output
  424.         jsr    _VWMHexOutZ
  425.         bra    _main4
  426.  
  427.         ; < IsInteractive >,-$1a,<NoName>,_DOSRegD1,< status:>
  428. _mainf01:    cmp.b    #-$1a,d0
  429.         bne    _mainf02
  430.         move.l    #_maint01,d3
  431.         jsr    _VWHH
  432.         bra    _main4
  433.  
  434.         ; < Parentdir >,$23,<NoName>,_DOSRegD1,< newlock:>
  435. _mainf02:    cmp.b    #$23,d0
  436.         bne    _mainf03
  437.         move.l    #_maint02,d3
  438.         jsr    _VWHH
  439.         bra    _main4
  440.  
  441.         ; < WaitForChar >,$57,<NoName>,_DOSRegD1,< status:>
  442. _mainf03:    cmp.b    #$57,d0
  443.         bne    _mainf04
  444.         move.l    #_maint03,d3
  445.         jsr    _VWHHH
  446.         bra    _main4
  447.  
  448.         ; < Delay >,$2f,<NoName>,_DOSRegD1,<NL>
  449. _mainf04:    cmp.b    #$2f,d0
  450.         bne    _mainf05
  451.         move.l    #_maint04,d3
  452.         jsr    _VWH
  453.         bra    _main4
  454.  
  455.         ; < DateStamp >,-$19,<NoName>,_DOSRegD1,<NL>
  456. _mainf05:    cmp.b    #-$19,d0
  457.         bne    _mainf06
  458.         move.l    #_maint05,d3
  459.         jsr    _VWH
  460.         bra    _main4
  461.  
  462.         ; < SetProtection >,-$18,_DOSRegD1,<NL>,< status:>
  463. _mainf06:    cmp.b    #-$18,d0
  464.         bne    _mainf07
  465.         move.l    #_maint06,d3
  466.         jsr    _VWHNH
  467.         bra    _main4
  468.  
  469.         ; < SetComment >,-$17,_DOSRegD1,<NL>,< status:>
  470. _mainf07:    cmp.b    #-$17,d0
  471.         bne    _mainf08
  472.         move.l    #_maint07,d3
  473.         jsr    _VWHNH
  474.         bra    _main4
  475.  
  476.         ; < DeviceProc >,-$16,_DOSRegD1,<NL>,< process:>
  477. _mainf08:    cmp.b    #-$16,d0
  478.         bne    _mainf09
  479.         move.l    #_maint08,d3
  480.         jsr    _VWHN
  481.         bra    _main4
  482.  
  483.         ; < QueuPacket >,-$15,<NoName>,_DOSRegD1,< status:>
  484. _mainf09:    cmp.b    #-$15,d0
  485.         bne    _mainf10
  486.         move.l    #_maint09,d3
  487.         jsr    _VWHH
  488.         bra    _main4
  489.  
  490.         ; < GetPacket >,-$14,<NoName>,_DOSRegD1,<status:>
  491. _mainf10:    cmp.b    #-$14,d0
  492.         bne    _mainf11
  493.         move.l    #_maint10,d3
  494.         jsr    _VWHH
  495.         bra    _main4
  496.  
  497.         ; < UnLoadSeg >,$52,<NoName>,_DOSRegD1,<NL>
  498. _mainf11:    cmp.b    #$52,d0
  499.         bne    _mainf12
  500.         move.l    #_maint11,d3
  501.         jsr    _VWH
  502.         bra    _main4
  503.  
  504.         ; < LoadSeg >,-$13,_DOSRegD1,<NL>,< segment:>
  505. _mainf12:    cmp.b    #-$13,d0
  506.         bne    _mainf13
  507.         move.l    #_maint12,d3
  508.         jsr    _VWHN
  509.         bra    _main4
  510.  
  511.         ; < Exit >,$02,<NoName>,_DOSRegD1,<NL>
  512. _mainf13:    cmp.b    #$02,d0
  513.         bne    _mainf14
  514.         move.l    #_maint13,d3
  515.         jsr    _VWH
  516.         bra    _main4
  517.  
  518.         ; < CreateProc >,-$12,_DOSRegD1,<NL>,< process:>
  519. _mainf14:    cmp.b    #-$12,d0
  520.         bne    _mainf15
  521.         move.l    #_maint14,d2
  522.         jsr    _VWMQStrOut
  523.         move.l    _DOSretD0,d0        ; process
  524.         jsr    _VWMHexOutZ
  525.         move.l    #_maintxt01,d2        ; = (
  526.         jsr    _VWMQStrOut
  527.         move.l    _DOSRegD1,d2        ; name
  528.         jsr    _VWMQStrOut
  529.         move.l    #_maintxt02,d2        ; ,
  530.         jsr    _VWMQStrOut
  531.         move.l    _DOSRegD2,d0        ; pri
  532.         jsr    _VWMHexOutZ
  533.         move.l    #_maintxt02,d2        ; ,
  534.         jsr    _VWMQStrOut
  535.         move.l    _DOSRegD3,d0        ; segment
  536.         jsr    _VWMHexOutZ
  537.         move.l    #_maintxt02,d2        ; ,
  538.         jsr    _VWMQStrOut
  539.         move.l    _DOSRegD4,d0        ; stack
  540.         jsr    _VWMHexOutZ
  541.         jsr    _VWMprintTrailer    ; )
  542.         bra    _main4
  543.  
  544.         ; < IoErr >,-$11,<NoName>,<NL>,< error:>
  545. _mainf15:    cmp.b    #-$11,d0
  546.         bne    _mainf16
  547.         move.l    #_maint15,d3
  548.         jsr    _VW.H
  549.         bra    _main4
  550.  
  551.         ; < CurrentDir >,-$10,<NoName>,_DOSRegD1,< oldlock:>
  552. _mainf16:    cmp.b    #-$10,d0
  553.         bne    _mainf17
  554.         move.l    #_maint16,d3
  555.         jsr    _VWHH
  556.  
  557.         move.l    #_LockTXT,d2
  558.         jsr    _VWMQStrOut
  559.         move.l    _DOSRegD1,d0
  560.         jsr    _VWLockInfo
  561.         move.l    d0,d2
  562.         jsr    _VWMQStrOut
  563.  
  564.         bra    _main4
  565.  
  566.         ; < CreateDir >,-$0f,_DOSRegD1,<NL>,< lock:>
  567. _mainf17:    cmp.b    #-$0f,d0
  568.         bne    _mainf18
  569.         move.l    #_maint17,d3
  570.         jsr    _VWHN
  571.         bra    _main4
  572.  
  573.         ; < Info >,-$0e,<NoName>,_DOSRegD1,< status:>
  574. _mainf18:    cmp.b    #-$0e,d0
  575.         bne    _mainf19
  576.         move.l    #_maint18,d3
  577.         jsr    _VWHHH
  578.         bra    _main4
  579.  
  580.         ; < ExNext >,-$0d,<NoName>,_DOSRegD1,< status:>
  581. _mainf19:    cmp.b    #-$0d,d0
  582.         bne    _mainf20
  583.         move.l    #_maint19,d3
  584.         jsr    _VWHHH
  585.         bra    _main4
  586.  
  587.         ; < Examine >,-$0c,<NoName>,_DOSRegD1,< status:>
  588. _mainf20:    cmp.b    #-$0c,d0
  589.         bne    _mainf21
  590.         move.l    #_maint20,d3
  591.         jsr    _VWHHH
  592.  
  593.         move.l    #_LockTXT,d2
  594.         jsr    _VWMQStrOut
  595.         move.l    _DOSRegD1,d0
  596.         jsr    _VWLockInfo
  597.         move.l    d0,d2
  598.         jsr    _VWMQStrOut
  599.  
  600.         bra    _main4
  601.  
  602.         ; < DupLock >,$71,<NoName>,_DOSRegD1,< newlock:>
  603. _mainf21:    cmp.b    #$71,d0
  604.         bne    _mainf22
  605.         move.l    #_maint21,d3
  606.         jsr    _VWHH
  607.  
  608.         move.l    #_LockTXT,d2
  609.         jsr    _VWMQStrOut
  610.         move.l    _DOSretD0,d0
  611.         jsr    _VWLockInfo
  612.         move.l    d0,d2
  613.         jsr    _VWMQStrOut
  614.  
  615.         bra    _main4
  616.  
  617.         ; < UnLock >,$6d,<NoName>,_DOSRegD1,<NL>
  618. _mainf22:    cmp.b    #$6d,d0
  619.         bne    _mainf23
  620.         move.l    #_maint22,d3
  621.         jsr    _VWH
  622.         bra    _main4
  623.  
  624.         ; < Lock >,-$0b,_DOSRegD1,<NL>,< lock:>
  625. _mainf23:    cmp.b    #-$0b,d0
  626.         bne    _mainf24
  627.         move.l    #_maint23,d3
  628.         jsr    _VWHNH
  629.  
  630.         cmp.l    #-1,_DOSRegD2        ; write
  631.         bne.s    _mainf23_0
  632.         move.l    #_maint23_0,d2
  633.         jsr    _VWMQStrOut
  634.         bra    _mainf23_1
  635. _mainf23_0:    move.l    #_maint23_1,d2        ; read
  636.         jsr    _VWMQStrOut
  637.  
  638. _mainf23_1:    move.l    _DOSretD0,d0        ; lock
  639.         tst.l    d0
  640.         beq    _main4
  641.         move.l    #_LockTXT,d2
  642.         jsr    _VWMQStrOut
  643.         jsr    _VWLockInfo
  644.         move.l    d0,d2
  645.         jsr    _VWMQStrOut
  646.         bra    _main4
  647.  
  648.         ; < Rename >,-$0a,_DOSRegD1,<NL>,< status:>
  649. _mainf24:    cmp.b    #-$0a,d0
  650.         bne    _mainf25
  651.         move.l    #_maint24,d2
  652.         jsr    _VWMQStrOut
  653.         move.l    _DOSretD0,d0        ; hex
  654.         jsr    _VWMHexOutZ
  655.         move.l    #_maintxt01,d2        ; = (
  656.         jsr    _VWMQStrOut
  657.         move.l    _DOSRegD1,d2        ; name
  658.         jsr    _VWMQStrOut
  659.         move.l    _DOSRegD2,d2        ; name
  660.         jsr    _VWMQStrOut
  661.         bra    _main4
  662.  
  663.         ; < DeleteFile >,-$09,_DOSRegD1,<NL>,< status:>
  664. _mainf25:    cmp.b    #-$09,d0
  665.         bne    _mainf26
  666.         move.l    #_maint25,d3
  667.         jsr    _VWHN
  668.         bra    _main4
  669.  
  670.         ; < Seek >,-$08,<NoName>,_DOSRegD1,< status:>
  671. _mainf26:    cmp.b    #-$08,d0
  672.         bne    _mainf27
  673.         move.l    #_maint26,d3
  674.         jsr    _VWHHHH
  675.         bra    _main4
  676.  
  677.         ; < Output >,$42,<NoName>,<NL>,< file:>
  678. _mainf27:    cmp.b    #$42,d0
  679.         bne    _mainf28
  680.         move.l    #_maint27,d3
  681.         jsr    _VW.H
  682.         bra    _main4
  683.  
  684.         ; < Input >,$41,<NoName>,<NL>,< file:>
  685. _mainf28:    cmp.b    #$41,d0
  686.         bne    _mainf29
  687.         move.l    #_maint28,d3
  688.         jsr    _VW.H
  689.         bra    _main4
  690.  
  691.         ; < Write >,-$06,<NoName>,_DOSRegD1,< byte:>
  692. _mainf29:    cmp.b    #-$06,d0
  693.         bne    _mainf30
  694.         move.l    #_maint29,d3
  695.         jsr    _VWHHHH
  696.         bra    _main4
  697.  
  698.         ; < Read >,-$03,<NoName>,_DOSRegD1,< byte:>
  699. _mainf30:    cmp.b    #-$03,d0
  700.         bne    _mainf31
  701.         move.l    #_maint30,d3
  702.         jsr    _VWHHHH
  703.         bra    _main4
  704.  
  705.         ; < Close >,$5d,<NoName>,_DOSRegD1,<NL>
  706. _mainf31:    cmp.b    #$5d,d0
  707.         bne    _mainf32
  708.         move.l    #_maint31,d3
  709.         jsr    _VWH
  710.         bra    _main4
  711.  
  712.         ; < Open >,-$01,_DOSRegD1,<NL>,< file:>
  713. _mainf32:    cmp.b    #-$01,d0
  714.         bne    _main4
  715.         move.l    #_maint32,d3
  716.         jsr    _VWHNH
  717.  
  718.         cmp.l    #1005,_DOSRegD2
  719.         bne.s    _mainf32_0        
  720.         move.l    #_maint32_0,d2        ; mode OLD
  721.         jsr    _VWMQStrOut
  722.         bra.s    _mainf32_1
  723. _mainf32_0:    move.l    #_maint32_1,d2        ; mode NEW
  724.         jsr    _VWMQStrOut
  725. _mainf32_1:    cmp.l    #0,_DOSretD0
  726.         beq.s    _mainf32_2
  727.         move.l    #_maint32_2,d2        ; status SUCCESS
  728.         jsr    _VWMQStrOut
  729.         bra.s    _main4
  730. _mainf32_2:    move.l    #_maint32_3,d2        ; status FAILURE
  731.         jsr    _VWMQStrOut
  732.  
  733.  
  734.     ; ***** enable multitasking *****
  735.  
  736.  
  737. _main4:        jsr    _VWMPrtCrLf
  738.         jsr    _LVOEnable(a6)        ; enable interrupting
  739.  
  740.     ; put result from memory onto sreen
  741.  
  742.         jsr    _VWResetTV
  743.         jsr    _VWPrintTV
  744.  
  745.     ; and log it into LOG file , if requested
  746.  
  747.         move.l    _VWLogHandle,d6
  748.         cmp.b    #0,d6
  749.         BEQ    _main1            ; no log
  750.         move.l    _VWOutHandle,d7
  751.         move.l    d6,_VWOutHandle
  752.         jsr    _VWPrintTV
  753.         move.l    d7,_VWOutHandle
  754.         BRA    _main1            ; LOOP
  755.  
  756.  
  757.     ; this code is executed if you press F3
  758.     ;
  759.     ; remove interrupt routine
  760.  
  761. _main5:        jsr    _VWRemf3
  762.  
  763.  
  764.     ; restore THE original code by removing the patch
  765.  
  766. _RemCode:    move.l    _SysBase,a6
  767.         jsr    _LVODisable(a6)        ; no interrupts
  768.         move.l    _DOSVec,a0        ; DOS entry
  769.         move.l    #$48E73F3E,(a0)+      ; MOVEM.L D2-7/A2-6,-(A7)
  770.         move.w    #$91C8,(a0)        ; SUBA.L  A0,A0
  771.         jsr    _LVOEnable(a6)        ; enable interrrupts
  772.  
  773.     ; free memory allocated by TV buffer
  774.  
  775.         jsr    _VWCloseTV
  776.  
  777.     ; wait a while - just to print the finish message
  778.  
  779.         move.l    #0,_used        ; reset used flag
  780.         move.l    #_maintxt03,d2
  781.         jsr    _VWQStrOut
  782.         move.l    #100,d1
  783.         CALLDOS Delay
  784.  
  785.     ; free the signal
  786.  
  787.         move.l    _Signal,d0
  788.         move.l    _SysBase,a6
  789.         jsr    _LVOFreeSignal(a6)
  790.  
  791.     ; close log anyway
  792.  
  793. _mainX:        move.l    _VWLogHandle,d1
  794.         CALLDOS    Close        
  795.  
  796.         RTS
  797.  
  798.         ;
  799.         ; ------------- DATA of main program -------------------------
  800.         ;
  801.  
  802.         EVEN
  803. _mainICR:    equ    $BFEC01            ; interrupt control reg
  804. _VWLogHandle:    dc.l    0            ; 
  805. _LOGfile    dc.l    0            ; pointer to LOG name
  806. _DOSVec:    dc.l    0            ; original 
  807. _DOSVec1:    dc.l    0
  808. _DOSTask:    dc.l    0            ; address of calling Task
  809. _DOSfunction:    dc.l    0
  810. _DOSRegD1:    dc.l    0
  811. _DOSRegD2:    dc.l    0
  812. _DOSRegD3:    dc.l    0
  813. _DOSRegD4:    dc.l    0
  814. _Signal:    dc.l    0
  815. _ThisTask:    dc.l    0
  816. _DOSretD0:    dc.l    0
  817. _finish:    dc.l    0
  818. _used:        dc.l    0
  819. _RWflag        dc.b    0
  820.  
  821.         EVEN
  822. _LockTXT:    dc.b    13,10,13,10,"  lock » ",0
  823.         EVEN
  824. _maintxt00:    dc.b    13,10,13,10,"%DOS-I-USE, USAGE: DOSWatch [IO] [LOG <file>]",13,10,0
  825.         EVEN
  826. _maintxt001:    dc.b    13,10,13,10,"%DOS-F-IPA, illegal parameter > USAGE: DOSWatch [IO] [LOG file]",13,10,0
  827.         EVEN
  828. _maintxt002:    dc.b    13,10,13,10,"%DOS-F-NLOG, error opening LOG file ",13,10,0
  829.         EVEN
  830. _maintxt003:    dc.b    13,10,"%DOS-W-TIGN, error opening ",0
  831.         EVEN
  832. _maintxt004:    dc.b    ".info - can't get TOOL TYPE entry",13,10,0
  833.         EVEN
  834. _maintxt01:    dc.b    "=(",0
  835.         EVEN
  836. _maintxt02:    dc.b    ",",0
  837.         EVEN
  838. _maintxt03:    dc.b    13,10,"%DOS-I-BYE, Thank You For Playing - Program will be finished in 2 seconds.. ",13,10,0
  839.         EVEN
  840. _maintxt04:    dc.b    13,10,"%%%% DOSWatch message at ",0
  841.         EVEN
  842. _maintxt05:    dc.b    " from  ",0
  843.         EVEN
  844. _maintxt06:    dc.b    " %%%%",13,10,0
  845.         EVEN
  846. _maintxt34:    dc.b    "[",0
  847.         EVEN
  848. _maintxt35:    dc.b    "]",0
  849.         EVEN
  850. _maint00:    dc.b    " status=",$9B,"0;33;40mExecute",$9B,"0;31;40m(string,file,file)",0
  851.         EVEN
  852. _maint01:    dc.b    " status=",$9B,"0;33;40mIsInteractive",$9B,"0;31;40m(file)",0
  853.         EVEN
  854. _maint02:    dc.b    " newLock=",$9B,"0;33;40mParentdir",$9B,"0;31;40m(lock)",0
  855.         EVEN
  856. _maint03:    dc.b    " status=",$9B,"0;33;40mWaitForChar",$9B,"0;31;40m(file,timeout)",0
  857.         EVEN
  858. _maint04:    dc.b    " VOID ",$9B,"0;33;40mDelay",$9B,"0;31;40m(timeout)",0
  859.         EVEN
  860. _maint05:    dc.b    " ^date=",$9B,"0;33;40mDateStamp",$9B,"0;31;40m(date)",0
  861.         EVEN
  862. _maint06:    dc.b    " status=",$9B,"0;33;40mSetProtection",$9B,"0;31;40m(name,mask)",0
  863.         EVEN
  864. _maint07:    dc.b    " status=",$9B,"0;33;40mSetcomment",$9B,"0;31;40m(name,comment)",0
  865.         EVEN
  866. _maint08:    dc.b    " processID=",$9B,"0;33;40mDeviceProc",$9B,"0;31;40m(name)",0
  867.         EVEN
  868. _maint09:    dc.b    " status=",$9B,"0;33;40mQueuePacket",$9B,"0;31;40m(packet)",0
  869.         EVEN
  870. _maint10:    dc.b    " status=",$9B,"0;33;40mGetPacket",$9B,"0;31;40m(waitflag)",0
  871.         EVEN
  872. _maint11:    dc.b    " VOID ",$9B,"0;33;40mUnLoadSeg",$9B,"0;31;40m(segment)",0
  873.         EVEN
  874. _maint12:    dc.b    " segment=",$9B,"0;33;40mLoadSeg",$9B,"0;31;40m(filename)",0
  875.         EVEN
  876. _maint13:    dc.b    " VOID ",$9B,"0;33;40mExit",$9B,"0;31;40m(returnCode)",0
  877.         EVEN
  878. _maint14:    dc.b    " processID=",$9B,"0;33;40mCreateProc",$9B,"0;31;40m(name,pri,segList,stackSize)",13,10,13,10," ",0
  879.         EVEN
  880. _maint15:    dc.b    " error=",$9B,"0;33;40mIOErr",$9B,"0;31;40m()",0
  881.         EVEN
  882. _maint16:    dc.b    " oldLock=",$9B,"0;33;40mCurrentDir",$9B,"0;31;40m(lock)",0
  883.         EVEN
  884. _maint17:    dc.b    " lock=",$9B,"0;33;40mCreateDir",$9B,"0;31;40m(name)",0
  885.         EVEN
  886. _maint18:    dc.b    " status=",$9B,"0;33;40mInfo",$9B,"0;31;40m(lock,parameterBlock)",0
  887.         EVEN
  888. _maint19:    dc.b    " status=",$9B,"0;33;40mEXNext",$9B,"0;31;40m(lock,fileInfoBlock)",0
  889.         EVEN
  890. _maint20:    dc.b    " status=",$9B,"0;33;40mExamine",$9B,"0;31;40m(lock,fileInfoBlock)",0
  891.         EVEN
  892. _maint21:    dc.b    " newLock=",$9B,"0;33;40mDupLock",$9B,"0;31;40m(lock)",0
  893.         EVEN
  894. _maint22:    dc.b    " VOID ",$9B,"0;33;40mUnLock",$9B,"0;31;40m(lock)",0
  895.         EVEN
  896. _maint23:    dc.b    " lock=",$9B,"0;33;40mLock",$9B,"0;31;40m(name,type)",0
  897.         EVEN
  898. _maint23_0:    dc.b    " XWrite",0
  899.         EVEN
  900. _maint23_1:    dc.b    " SRead",0
  901.         EVEN
  902. _maint24:    dc.b    " status=",$9B,"0;33;40mRename",$9B,"0;31;40m(oldName,newName)",0
  903.         EVEN
  904. _maint25:    dc.b    " status=",$9B,"0;33;40mDeleteFile",$9B,"0;31;40m(name)",0
  905.         EVEN
  906. _maint26:    dc.b    " position=",$9B,"0;33;40mSeek",$9B,"0;31;40m(file,position,offset)",0
  907.         EVEN
  908. _maint27:    dc.b    " file=",$9B,"0;33;40mOutPut",$9B,"0;31;40m()",0
  909.         EVEN
  910. _maint28:    dc.b    " file=",$9B,"0;33;40mInPut",$9B,"0;31;40m()",0
  911.         EVEN
  912. _maint29:    dc.b    " byte=",$9B,"0;33;40mWrite",$9B,"0;31;40m(file,buffer,length)",0
  913.         EVEN
  914. _maint30:    dc.b    " byte=",$9B,"0;33;40mRead",$9B,"0;31;40m(file,buffer,length)",0
  915.         EVEN
  916. _maint31:    dc.b    " VOID ",$9B,"0;33;40mClose",$9B,"0;31;40m(file)",0
  917.         EVEN
  918. _maint32:    dc.b    " file=",$9B,"0;33;40mOpen",$9B,"0;31;40m(name,accessMode)",0
  919.         EVEN
  920. _maint32_0:    dc.b    13,10,13,10,"  mode: OLD",0
  921.         EVEN
  922. _maint32_1:    dc.b    13,10,13,10,"  mode: NEW",0
  923.         EVEN
  924. _maint32_2:    dc.b    "  status: SUCCESS",0
  925.         EVEN
  926. _maint32_3:    dc.b    "  status: FAILURE",0
  927.  
  928.         ;
  929.         ; ------------- SUBS of main program -------------------------
  930.         ;
  931.  
  932.         ; this code is for watching DOS calls
  933.         ; function code is in d0
  934.         ;
  935.         EVEN
  936. _NEWcode:    movem.l    d0-d2/a6,-(sp)        ; save some regs
  937.         move.l    _SysBase,a6
  938.         move.l    ThisTask(a6),d2        ; address of calling task
  939.         move.l    _ThisTask,d1        ; compare with DOSWatch
  940.         cmp.l    d1,d2
  941.         bne    _NEWcode1        ; calling Task is NOT me
  942.         bra    _NEWcode2        ; NO watch
  943.  
  944. _NEWcode1:    cmp.l    #0,_used        ; 
  945.         beq    _NEWcode3        ; used = 0 ,so watch
  946.  
  947.         move.l    #$BFE001,a6        ; LED off
  948.         bset    #1,(a6)
  949.         moveq    #$2f,d0            ; DELAY DOS function
  950.         move.l    #1,d1            ; wait 1/50 sec
  951.         move.l    _DOSBase,a6        ; 
  952.         move.l    #_NEWcode1,-(sp)    ; return PC
  953.         MOVEM.L    D2-D7/A2-A6,-(A7)    ; orig DOS code
  954.         SUBA.L    A0,A0            ; orig DOS code
  955.         move.l    _DOSVec1,-(sp)        ; PC just behind patch
  956.         RTS                ; call DOS
  957.  
  958.  
  959. _NEWcode2:    movem.l    (sp)+,d0-d2/a6        ; NO DOSWatch watch
  960.             MOVEM.L D2-D7/A2-A6,-(A7)    ; part of orig code
  961.             SUBA.L  A0,A0            ; part of orig code
  962.         move.l    _DOSVec1,-(sp)        ; jump to DOS function
  963.         RTS
  964.  
  965. _NEWcode3:    move.l    #$BFE001,a6        ; LED on
  966.         bclr    #1,(a6)
  967.  
  968.         move.l    d2,_DOSTask        ; save calling task
  969.         move.l    #_used,a6        ; incr used_flag
  970.         add.l    #1,(a6)            ; 
  971.         movem.l    (sp)+,d0-d2/a6        ; restore regs
  972.         move.l    #_NEWcode_1,-(sp)    ; this PC for return DOS
  973.             MOVEM.L D2-D7/A2-A6,-(A7)    ; part of orig code
  974.             SUBA.L  A0,A0            ; part of orig code
  975.         move.l    d0,_DOSfunction        ; SAVE
  976.         move.l    d1,_DOSRegD1        ;  SOME
  977.         move.l    d2,_DOSRegD2        ;   IMPORTANT
  978.         move.l    d3,_DOSRegD3        ;    VALUES
  979.         move.l    d4,_DOSRegD4        ;     FOR LOG
  980.         move.l    _DOSVec1,-(sp)        ; jump to DOS function
  981.         RTS
  982.  
  983.         ; woww, just returned from DOS function 
  984.         ; note that DOSWatch does NOT reach this code!
  985.         ;
  986. _NEWcode_1:    movem.l    d0-d7/a0-a6,-(sp)
  987.         move.l    _SysBase,a6
  988.         move.l    d0,_DOSretD0        ; save it
  989.         move.l    _ThisTask,a1        ; let DOSWatch know that
  990.         move.l    _Signal,d0        ; DOS was called
  991.         jsr    _LVOSignal(a6)
  992. _NEWcode_2:    movem.l    (sp)+,d0-d7/a0-a6
  993.         RTS                ; return to DOS caller
  994.  
  995.         ; print string in D3 with header
  996.         ;
  997.         EVEN
  998. _VWMprintHeader:    
  999.         move.l    d2,-(sp)
  1000.         move.l    #_VWheader,d2
  1001.         jsr    _VWMQStrOut
  1002.         move.l    d3,d2
  1003.         jsr    _VWMQStrOut
  1004.         move.l    #_VWheader1,d2
  1005.         jsr    _VWMQStrOut
  1006.         move.l    (sp)+,d2
  1007.         RTS
  1008. _VWheader:    dc.b    " ",0
  1009. _VWheader1:    dc.b    "   ",0
  1010.         EVEN
  1011.  
  1012.         ; print trailer
  1013.         ;
  1014.         EVEN
  1015. _VWMprintTrailer:
  1016.         move.l    d2,-(sp)
  1017.         move.l    #_VWTrailer,d2
  1018.         jsr    _VWMQStrOut
  1019.         move.l    (sp)+,d2
  1020.         RTS
  1021. _VWTrailer:    dc.b    ") ",0
  1022.         EVEN
  1023.     
  1024.         ; hex = (hex)
  1025.         ;
  1026. _VWHH:        jsr    _VWMprintHeader
  1027.         move.l    _DOSretD0,d0        ; hex
  1028.         jsr    _VWMHexOutZ
  1029.         move.l    #_maintxt01,d2        ; = (
  1030.         jsr    _VWMQStrOut
  1031.         move.l    _DOSRegD1,d0        ; hex
  1032.         jsr    _VWMHexOutZ
  1033.         jsr    _VWMprintTrailer
  1034.         RTS
  1035.  
  1036.         ; hex =(hex,hex)
  1037.         ;
  1038. _VWHHH:        jsr    _VWMprintHeader
  1039.         move.l    _DOSretD0,d0        ; hex
  1040.         jsr    _VWMHexOutZ
  1041.         move.l    #_maintxt01,d2        ; = (
  1042.         jsr    _VWMQStrOut
  1043.         move.l    _DOSRegD1,d0        ; hex
  1044.         jsr    _VWMHexOutZ
  1045.         move.l    #_maintxt02,d2        ; ,
  1046.         jsr    _VWMQStrOut
  1047.         move.l    _DOSRegD2,d0        ; hex
  1048.         jsr    _VWMHexOutZ
  1049.         jsr    _VWMprintTrailer
  1050.         RTS
  1051.  
  1052.         ; =(hex)
  1053.         ;
  1054. _VWH:        jsr    _VWMprintHeader
  1055.         move.l    #_maintxt01,d2        ; = (
  1056.         jsr    _VWMQStrOut
  1057.         move.l    _DOSRegD1,d0        ; hex
  1058.         jsr    _VWMHexOutZ
  1059.         jsr    _VWMprintTrailer
  1060.         RTS
  1061.  
  1062.         ; hex=(name,hex)
  1063.         ;
  1064. _VWHNH:        jsr    _VWMprintHeader
  1065.         move.l    _DOSretD0,d0        ; hex
  1066.         jsr    _VWMHexOutZ
  1067.         move.l    #_maintxt01,d2        ; = (
  1068.         jsr    _VWMQStrOut
  1069.         move.l    _DOSRegD1,d2        ; name
  1070.         jsr    _VWMQStrOut
  1071.         move.l    #_maintxt02,d2        ; ,
  1072.         jsr    _VWMQStrOut
  1073.         move.l    _DOSRegD2,d0        ; hex
  1074.         jsr    _VWMHexOutZ
  1075.         jsr    _VWMprintTrailer
  1076.         RTS
  1077.  
  1078.         ; hex=(hex,hex,hex)
  1079.         ;        
  1080. _VWHHHH:    jsr    _VWMprintHeader
  1081.         move.l    _DOSretD0,d0        ; hex
  1082.         jsr    _VWMHexOutZ
  1083.         move.l    #_maintxt01,d2        ; = (
  1084.         jsr    _VWMQStrOut
  1085.         move.l    _DOSRegD1,d0        ; hex
  1086.         jsr    _VWMHexOutZ
  1087.         move.l    #_maintxt02,d2        ; ,
  1088.         jsr    _VWMQStrOut
  1089.         move.l    _DOSRegD2,d0        ; hex
  1090.         jsr    _VWMHexOutZ
  1091.         move.l    #_maintxt02,d2        ; ,
  1092.         jsr    _VWMQStrOut
  1093.         move.l    _DOSRegD3,d0        ; hex
  1094.         jsr    _VWMHexOutZ
  1095.         jsr    _VWMprintTrailer
  1096.         RTS
  1097.  
  1098.         ; hex=(name)
  1099.         ;
  1100. _VWHN:        jsr    _VWMprintHeader
  1101.         move.l    _DOSretD0,d0        ; hex
  1102.         jsr    _VWMHexOutZ
  1103.         move.l    #_maintxt01,d2        ; = (
  1104.         jsr    _VWMQStrOut
  1105.         move.l    _DOSRegD1,d2        ; name
  1106.         jsr    _VWMQStrOut
  1107.         jsr    _VWMprintTrailer
  1108.         RTS
  1109.  
  1110.         ; hex =()
  1111.         ;
  1112. _VW.H:        jsr    _VWMprintHeader
  1113.         move.l    _DOSretD0,d0        ; hex
  1114.         jsr    _VWMHexOutZ
  1115.         move.l    #_maintxt01,d2        ; = (
  1116.         jsr    _VWMQStrOut
  1117.         jsr    _VWMprintTrailer
  1118.         RTS
  1119.  
  1120.         ; init F3 interrupt dispatcher
  1121.         ;
  1122. _VWf3:        movem.l    d0/a1/a6,-(sp)        ; for local variables
  1123.         move.l    #VBIStruc,a1        ; prepare vertical
  1124.         move.l    #VBI_name,10(a1)    ; interrupt routine
  1125.         move.l    #VBI_data,14(a1)    ; no data needed
  1126.         move.l    #VBI_code,18(a1)    ; but code
  1127.         move.l    #5,d0            ; interrupt number VBI
  1128.         jsr    _LVOAddIntServer(a6)    ; add server
  1129.         movem.l    (sp)+,d0/a1/a6        ; restore stack
  1130.         RTS                ; that's all
  1131.  
  1132. VBIStruc:    dc.l    0            ; ln_succ
  1133.         dc.l    0            ; ln_pred
  1134.         dc.b    2            ; ln_type
  1135.         dc.b    0            ; ln_pri
  1136.         dc.l    0            ; ln_name
  1137.         dc.l    0            ; ln_data
  1138.         dc.l    0            ; ln_code
  1139. VBI_data:    ds.l    1            ; data space
  1140. VBI_name:    dc.b    "F3-DOSWatch",0        ; interrupt name
  1141.  
  1142.         ; VBI interrupt routine (runs in supervisor mode)
  1143.         ; <PC.l and SR.w and d0-d1/a0-a1/a5-a6 on super stack>
  1144.         ;
  1145.         EVEN
  1146. VBI_code:    movem.l    d0-d2/a2/a6,-(sp)    ; for local vars save on SS
  1147.         cmp.b    #$5b,VBI_ICR        ; is F3 pressed ?
  1148.         bne.s    VBI_end            ; NO
  1149.         move.l    #-1,d0
  1150.         move.l    d0,_finish
  1151.         move.l    _SysBase,a6
  1152.         move.l    _ThisTask,a1        ; let task know that
  1153.         move.l    _Signal,d0        ; F3 was called
  1154.         jsr    _LVOSignal(a6)
  1155. VBI_end:    movem.l    (sp)+,d0-d2/a2/a6    ; restore REGS
  1156.         RTS                ; return to EXEC code
  1157. VBI_ICR        equ    $BFEC01            ; interrupt control reg
  1158.  
  1159.         ; remove interrupt server, cause it runs in task context
  1160.         ;
  1161.         EVEN
  1162. _VWRemf3:    movem.l    d0/a1/a6,-(sp)
  1163.         move.l    #5,d0
  1164.         move.l    #VBIStruc,a1
  1165.         move.l    _SysBase,a6
  1166.         jsr    _LVORemIntServer(a6)
  1167.         movem.l    (sp)+,d0/a1/a6
  1168.         RTS
  1169.  
  1170.         ; set D0 to  Name of locked file ; input D0=lock
  1171.         ;
  1172.         EVEN
  1173. _VWLockInfo:    movem.l    d1-d7/a0-a6,-(sp)
  1174.         move.l    d0,d1
  1175.         move.l    #_InfoBlock,d2
  1176.         CALLDOS Examine        
  1177.         move.l    #_InfoBlock,d0
  1178.         add.l    #8,d0
  1179.         movem.l    (sp)+,d1-d7/a0-a6
  1180.         RTS
  1181.  
  1182.         CNOP 0,4            ; address of _InfoBlock
  1183. _InfoBlock:    ds.b    260            ; MUST be on longword
  1184.                         ; boundary
  1185.  
  1186.         ; print carriage return & line feed on pTVbuf
  1187.         ;
  1188.         EVEN
  1189. _VWMPrtCrLf:    movem.l    d0-d7/a0-a6,-(sp)
  1190.         move.l    #_VWCrLf,d2
  1191.         jsr    _VWMQStrOut
  1192.         movem.l    (sp)+,d0-d7/a0-a6
  1193.         RTS
  1194. _VWCrLf:    dc.b    13,10,0
  1195.  
  1196.  
  1197.         ; copy a string D2 into memory pTVbuf
  1198.         ; endByte=$0 or ETVbuf or D4.L        D4.L overwritten!!!
  1199.         ; 
  1200.         EVEN
  1201. _VWMQStrOut:    move.l    #$ffff,d4
  1202. _VWMQStrOutB:    movem.l    d0-d7/a0-a6,-(sp)
  1203.         move.l    d2,a0                ;source
  1204.         move.l    _VWpTVbuf,a1            ;destination
  1205.         move.l    _VWETVbuf,d1            ;end of tv buff
  1206.         move.l    #0,d3                ;string length
  1207. _VWMQStrOut_1:    cmp.l    d4,d3                ;max chars
  1208.         beq.s    _VWMQStrOut_2
  1209.         cmp.b    #0,(a0)
  1210.         beq.s    _VWMQStrOut_2
  1211.         move.b    (a0)+,(a1)+            ;copy
  1212.         addq    #1,d3                ;d3 = length
  1213.         cmp.l    a1,d1                ;tv buff end?
  1214.         ble.s    _VWMQStrOut_2
  1215.         bra.s    _VWMQStrOut_1            ;no
  1216. _VWMQStrOut_2:    move.l    _VWpTVbuf,d0
  1217.         add.l    d3,d0
  1218.         move.l    d0,_VWpTVbuf
  1219.         movem.l    (sp)+,d0-d7/a0-a6
  1220.         RTS
  1221.  
  1222.         ; Hexadecimal output d0 to pTVbuf
  1223.         ; d6=#8 LONG , d6=#4 WORD , d6=#2 BYTE
  1224.         ; suppresses leading zeros
  1225.         ;
  1226.         EVEN
  1227. _VWMHexOut:    movem.l    d0-d7/a0-a6,-(sp)
  1228.         move.l    #0,d3                ;blank flag
  1229.         bra.s    _VWMHexOut_0
  1230. _VWMHexOutZ:    movem.l    d0-d7/a0-a6,-(sp)
  1231.         move.l    #1,d3                ;no blanks
  1232. _VWMHexOut_0:    move.l    _VWETVbuf,d1            ;check border
  1233.         move.l    _VWpTVbuf,d2            ;current pointer        
  1234.         add.l    d6,d2                
  1235.         cmp.l    d2,d1
  1236.         ble    _VWMHexOut_2            ;sorry,buffer full
  1237.  
  1238.         move.l    #32,d1                ;lead zero flag
  1239.         move.l    _VWpTVbuf,a1
  1240.         move.l     d0,d7                ;save d0
  1241. _VWMHexOut_1:    move.l     d7,d0                ;restore d0
  1242.         rol.l    #4,d0                ;rotate left 4 bits    
  1243.         move.l    d0,d7                ;save modified d0
  1244.         jsr    _VWMNibOut
  1245.         subq.b    #1,d6                ;counter -1 
  1246.         bne    _VWMHexOut_1
  1247. _VWMHexOut_2:    movem.l    (sp)+,d0-d7/a0-a6
  1248.         RTS
  1249.  
  1250. _VWMNibOut:    and.l    #15,d0                ;bits 31-4 clear
  1251.         cmp.b    #9,d0                ;d0 <=9 ?
  1252.         ble.s    _VWMNibOut_1
  1253.         add.b    #7,d0
  1254. _VWMNibOut_1:    add.b    #48,d0
  1255.  
  1256.         cmpi    #1,d6                ;ignore last digit
  1257.         beq.s    _VWMNibOut_2
  1258.         cmpi    #48,d0                ;zero suppress
  1259.         bne.s    _VWMNibOut_2
  1260.         cmpi    #32,d1
  1261.         bne.s    _VWMNibOut_2
  1262.         move.b    #32,d0
  1263.         cmpi    #1,d3
  1264.         bne.s    _VWMNibOut_2
  1265.         move.b    d0,d1                ;zero flag
  1266.         RTS        
  1267.  
  1268. _VWMNibOut_2:    move.b    d0,(a1)+
  1269.         move.l    a1,_VWpTVbuf
  1270.         move.b    d0,d1                ;zero flag
  1271.         RTS
  1272.  
  1273.         ; init TV buffer
  1274.         ;
  1275.         EVEN
  1276. _VWInitTV:    movem.l    a0-a6/d0-d7,-(sp)
  1277.         move.l    #MEMF_CHIP,d1            ;chip mem
  1278.         move.l    #20000,d0            ;mem size
  1279.         CALLEXEC AllocMem        
  1280.         tst.l    d0
  1281.         bgt.s    _VWInitTV1            ;ok
  1282.         move.l    _VWTVbufSpare,d0
  1283. _VWInitTV1:    move.l    #_VWpTVbuf,a1            ;init pTVbuf
  1284.         move.l    d0,(a1)
  1285.         move.l    d0,_VWTVbuf
  1286.         move.l    #20000,d1
  1287.         add.l    d1,d0
  1288.         sub.l    #1,d0                ;for zero terminator    
  1289.         move.l    d0,_VWETVbuf            ;buffer end
  1290.         movem.l    (sp)+,a0-a6/d0-d7
  1291.         RTS
  1292.  
  1293.         EVEN
  1294. _VWTVbufSpare:    ds.b    80                ;spare buf 
  1295.         EVEN
  1296. _VWTVbuf:    dc.l    0                ;adr of TVbuf
  1297. _VWETVbuf:    dc.l    0                ;end of TVBuf
  1298. _VWpTVbuf:    dc.l    0                ;curr pointer
  1299.  
  1300.  
  1301.         ; reset TVBuf
  1302.         ;
  1303.         EVEN
  1304. _VWResetTV:    move.l    a1,-(sp)
  1305.         move.l    _VWpTVbuf,a1
  1306.         move.b    #0,(a1)+            ;terminator 0
  1307.         move.l    #_VWpTVbuf,a1
  1308.         move.l    _VWTVbuf,(a1)
  1309.         move.l    (sp)+,a1
  1310.         RTS
  1311.  
  1312.         ; print TVBuf
  1313.         ;
  1314.         EVEN
  1315. _VWPrintTV:    movem.l    a0-a6/d0-d7,-(sp)
  1316.         move.l    _VWTVbuf,d2
  1317.         jsr    _VWQStrOut
  1318.         movem.l    (sp)+,a0-a6/d0-d7
  1319.         RTS
  1320.  
  1321.  
  1322.         ; close TV buffer , deallocate mem
  1323.         ;
  1324. _VWCloseTV:    movem.l    a0-a6/d0-d7,-(sp)
  1325.         move.l    _VWTVbuf,a1
  1326.         move.l    #20000,d0
  1327.         CALLEXEC FreeMem
  1328.         movem.l    (sp)+,a0-a6/d0-d7
  1329.         RTS
  1330.  
  1331.  
  1332.         ; Hexadecimal output d0 to OutHandle
  1333.         ; d6=#8 LONG , d6=#4 WORD , d6=#2 BYTE
  1334.         ;
  1335.         EVEN
  1336. _VWHexOut:    movem.l    d0-d7/a0-a6,-(sp)
  1337.         move.l     d0,d7                ;save d0
  1338.         move.l    _VWOutHandle,d1
  1339.         move.l    #_VWChrOut_buf,d2        ;the byte's buffer
  1340.         move.l    _DOSBase,a6
  1341.         moveq    #1,d3                ;print one byte
  1342. _VWHexOut_1:    move.l     d7,d0                ;restore d0
  1343.         rol.l    #4,d0                ;rotate left 4 bits    
  1344.         move.l    d0,d7                ;save modified d0
  1345.         jsr    _VWNibOut
  1346.         subq.b    #1,d6                ;counter -1 
  1347.         bne    _VWHexOut_1
  1348.         movem.l    (sp)+,d0-d7/a0-a6
  1349.         RTS
  1350. _VWNibOut:    and.l    #15,d0                ;bits 31-4 clear
  1351.         cmp.b    #9,d0                ;d0 <=9 ?
  1352.         ble.s    _VWNibOut_1
  1353.         add.b    #7,d0
  1354. _VWNibOut_1:    add.b    #48,d0
  1355.         move.b    d0,_VWChrOut_buf
  1356.         movem.l    d0-d7/a0-a6,-(sp)
  1357.         jsr    _LVOWrite(a6)
  1358.         movem.l    (sp)+,d0-d7/a0-a6
  1359.         RTS
  1360. _VWChrOut_buf:    dc.b    0
  1361.  
  1362.         ; copy a string to OutHandle start=d2, endByte=$0
  1363.         ; or for _VWQStrOutB length=D4.L
  1364.         ; [max. string length=10000]
  1365.         ;
  1366.         EVEN
  1367. _VWQStrOut:    movem.l    d0-d7/a0-a6,-(sp)
  1368.         move.l    d2,a0
  1369.         moveq    #0,d3
  1370. _VWQStrOut_1:    cmpi    #10000,d3
  1371.         beq.s    _VWQStrOut_2
  1372.         addq    #1,d3                ;d3 = length
  1373.         cmp.b    #0,(a0)+
  1374.         bne    _VWQStrOut_1        
  1375.         bra.s    _VWQStrOut_2
  1376.  
  1377. _VWQStrOutB:    movem.l    d0-d7/a0-a6,-(sp)
  1378.         move.l    d4,d3                ;d4 = lenght
  1379.  
  1380. _VWQStrOut_2:    move.l    _VWOutHandle,d1
  1381.         move.l    _DOSBase,a6
  1382.         jsr    _LVOWrite(a6)
  1383.         movem.l    (sp)+,d0-d7/a0-a6
  1384.         RTS
  1385.  
  1386.         ; Print a time Stamp 
  1387.         ;
  1388. _VWMTimeStamp:    movem.l    d0-d7/a0-a6,-(sp)
  1389.         move.l    #3,d6            ; digits for DECout
  1390.         move.l    #TimeStampVEC,d1
  1391.         CALLDOS    DateStamp
  1392.         move.l    #TimeStampVEC,a0
  1393.         move.l    4(a0),d0        ; minutes since midnight
  1394.         move.l    d0,d1            ; save it
  1395.         move.l    8(a0),d7        ; 1/50 seconds in this minute
  1396.         divu    #60,d0            ; midnight minutes /60
  1397.         move.l    d0,d3            ; and minutes
  1398.         and.l    #$0000ffff,d0        ; low order word is hours
  1399.         jsr    _VWMDecOutZ        ; hours
  1400.         move.l    #TimeStampTXT,d2
  1401.         jsr    _VWMQStrOut
  1402.         move.l    d3,d0
  1403.         and.l    #$ffff0000,d0        ; high order word is minutes
  1404.         swap    d0            ; nibble swap
  1405.         jsr    _VWMDecOutZ        ; hours
  1406.         move.l    #TimeStampTXT,d2
  1407.         jsr    _VWMQStrOut
  1408.         divu    #50,d7
  1409.         move.l    d7,d0
  1410.         and.l    #$0000ffff,d0        ; low order word is second
  1411.         jsr    _VWMDecOutZ        ; hours
  1412.         movem.l    (sp)+,d0-d7/a0-a6
  1413.         RTS
  1414.  
  1415. TimeStampVEC:    dc.l    0
  1416.         dc.l    0
  1417.         dc.l    0
  1418. TimeStampTXT:    dc.b    8,":",0
  1419.  
  1420.         ; Copy D0 decimal converted to _VWOutHandle
  1421.         ; D6 = digit count ;Max=11 ; leading ZEROS
  1422.         ;
  1423.         EVEN
  1424. _VWDecOutZ:    move.l    d2,-(sp)
  1425.         jsr    _VWDecConvZ
  1426.         jsr    _VWQStrOut
  1427.         move.l    (sp)+,d2        
  1428.         RTS
  1429.  
  1430.         ;  D0 convert to decimal ; D2 is ReceiveBufAdr
  1431.         ;  D6 = digit count max=11 ; with leading ZERO
  1432.         ;
  1433.         EVEN
  1434. _VWDecConvZ:    movem.l    d0/d1/d3/d4/a0/a5,-(sp)
  1435.         move.l    #0,d4            ; zero flag
  1436.         move.l    #11,d1
  1437.         move.l    #_VWDecConvBuf,a5
  1438.         tst.l    d0
  1439.         bne.s    _VWDecConv0
  1440.         move.l    #1,d4
  1441.         move.l    #1,d0            ;treat as zero
  1442. _VWDecConv0:    bmi.s    _VWDecConv1
  1443.         neg.l    d0
  1444.         move.b    #" ",10(a5)
  1445.         bra.s    _VWDecConv2
  1446. _VWDecConv1:    move.b    #"-",10(a5)
  1447. _VWDecConv2:    move.b    #0,11(a5)
  1448.         move.l    #_VWDecConvTab,a0
  1449.         clr.w    d1
  1450. _VWDecConv3:    move.l    (a0)+,d2
  1451.         beq.s    _VWDecConv6
  1452.         move.l  #-1,d3
  1453. _VWDecConv4:    add.l    d2,d0
  1454.         dbgt    d3,_VWDecConv4
  1455.         sub.l    d2,d0
  1456.         addq.w    #1,d3
  1457.         bne.s    _VWDecConv5
  1458.         tst.w    d1            ;lead zero
  1459.         bne.s    _VWDecConv5        ;yes
  1460.         move.b    #"0",(a5)+
  1461.         bra.s    _VWDecConv3
  1462. _VWDecConv5:    move.l    #-1,d1
  1463.         neg.b    d3
  1464.         addi.b    #"0",d3
  1465.         move.b    d3,(a5)+
  1466.         bra.s    _VWDecConv3
  1467. _VWDecConv6:    neg.b    d0
  1468.         addi.b    #"0",d0
  1469.         move.b    d0,(a5)+
  1470.         move.l    #_VWDecConvBuf,d2
  1471.         cmp.l    #0,d4            ;was it a zero?
  1472.         beq.s    _VWDecConv60        ;no
  1473.         sub.l    #1,a5                
  1474.         move.b    #"0",(a5)
  1475. _VWDecConv60:    move.l    #11,d1
  1476.         sub.l    d6,d1
  1477.         add.l    d1,d2
  1478.         move.l    d2,a0
  1479.         sub.l    #1,a0
  1480.         cmp.b    #"0",(a0)        
  1481.         beq.s    _VWDecConv7
  1482.         add.l    #1,a0
  1483.         move.b    #"*",(a0)
  1484.  
  1485. _VWDecConv7:    movem.l    (sp)+,d0/d1/d3/d4/a0/a5
  1486.         RTS
  1487.  
  1488. _VWDecConvTab:    dc.l    1000000000
  1489.         dc.l     100000000
  1490.         dc.l      10000000
  1491.         dc.l       1000000
  1492.         dc.l        100000
  1493.         dc.l         10000
  1494.         dc.l          1000
  1495.         dc.l           100
  1496.         dc.l            10
  1497.         dc.l             0
  1498. _VWDecConvBuf:    ds.b    12
  1499.  
  1500.         ; Copy D0 decimal converted to _VWOutHandle
  1501.         ; D6 = digit count ;Max=11 ; leading ZEROS
  1502.         ;
  1503.         EVEN
  1504. _VWMDecOutZ:    move.l    d2,-(sp)
  1505.         jsr    _VWDecConvZ
  1506.         jsr    _VWMQStrOut
  1507.         move.l    (sp)+,d2        
  1508.         RTS
  1509.  
  1510.         END
  1511.  
  1512.