*****************************************************************************)
*                                                                           *)
*                                                                           *)
*    Program    : Display Software Monitor for EDDE.                        *)
*                                                                           *)
*    Purpose    : This the user interface software to collect, store and    *)
*                 display the event information in a dbase on this board.   *)
*                                                                           *)
*    Name       : Vinod E.F. REBELLO                                        *)
*                                                                           *)
*    Class      : CS & E 4                                                  *)
*                                                                           *)
*    Username   : VEFR                                                      *)
*                                                                           *)
*    Date       : 18th July 1989       Version 6.2                          *)
*                 Rev. 17 July 1989    Ver 6.2  to allow display of CentreNt*)
*                                      packet without processing.           *)
*                 Rev. 12 March 1990   Bugfixing.                           *)
*                     5th May   199    Centrenet packet sequencing.         *)
*                    10th July  1990   Hardware Filtering.                  *)
*                     3rd Oct   1990   History cmd and init handshake.      *)
*                                                                           *)
*    Supervisor : Damal K. ARVIND                                           *)
*                                                                           *)
*****************************************************************************)
        incl   subr.asm
*
led     equ     $70000                 * General Purpose Reg. address.
clr     equ    #$ff                    * Clear all H'ware Flags.
grnoff  equ    #$01
rroff   equ    #$02
rgoff   equ    #$03                    * both led and read req off.
ctpoff  equ    #$04
evpoff  equ    #$08
cepoff  equ    #$0c
grnon   equ    #$fe                    * light led.
rron    equ    #$fd                    * read req to fifo.
rgon    equ    #$fc                    * read req and green led on
ctpon   equ    #$fb                    * C Pks 
evpon   equ    #$f7                    * Normal events 
stack   equ    #$03fdf8
time    equ    #$020000                * Time stamp hours,mins,sec etc
m1      equ    #$02000c                * for currently displaying event.
m2      equ    #$02000d                
m3      equ    #$02000e
m4      equ    #$02000f
m5      equ    #$020010
status  equ     $020012                *  Address of Mode status register.
stats2  equ     $020013                *  Address of operational stats reg.
mode    equ     $020014                * Address of mode flag.
scbnds  equ     $020016                * Mem mirror reg addresses for filter
dtbnds  equ     $020018                * registers and control field.
filctl  equ     $020021
hwcnt   equ     $020023                * H'ware Mirror Register.For Led,fifo etc
dbadrw  equ    #$020080                *  address of Database write addr ptr.
dbadrr  equ    #$020084                *     "    "     "     read   "    " .
dbase   equ    #$020088                *  database start address.
dbfull  equ    #$02ff00                *  database upper limit.
esc     equ    #$1b
lbk     equ    #$5b
ascii0  equ    $30
hr      equ    #3600000000             * these 3 are constant used to
tmin    equ    #600000000              * convert hex timestamp to user
min     equ    #60000000               * readable time.
tstpak1 equ    #$5                     * Value of the packets used for the
tstpak2 equ    #$1fef6c41              * initialisation handshake between boards


* :*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*
*
* Program messages
*
promms:	dc.b	cr,lf,'PDSEMB>'
prommn:	ds.w	0                                *
iconms:	dc.b	cr,lf,' XX:Unknown Event   '
        dc.b       ' PA:Prcs. Activated '
        dc.b       ' PT:Prcs.Terminated '
        dc.b       ' PD:Process Dead    '
        dc.b	cr,lf,' PB:Process Blocked '
        dc.b       ' PH:Process Halted  '
        dc.b       ' PR:Prcs. Restarted '
        dc.b       ' ..:Process Active  '
        dc.b	cr,lf,' PS:Prcs. Suspended ' 
        dc.b       ' OF:Opening File    '
        dc.b       ' CF:Closing File    '
        dc.b       ' U1:User Defined #1 '
        dc.b	cr,lf,' T_:Tx to process _ ' 
        dc.b       ' R_:Rx from prcs. _ '
        dc.b       ' W_:Synch. with _   '
        dc.b       ' U2:User Defined #2 '
iconmn:	ds.w	0
helpms:	dc.b	cr,lf,'A : Event Line Monitoring  '
        dc.b       'G : gandalf/aux RS232 Prt '
        dc.b       'Q : Quit                   '
        dc.b	cr,lf,'D : System Diagnostics     '
        dc.b       'H : System HALT           '
        dc.b       'R : REBOOT - Clears Dbase  '
        dc.b	cr,lf,'E : Event Log Monitoring   '
        dc.b       'I : Icon Help - Line Mntr '
        dc.b       'S : Screen Lock/Unlock     '
        dc.b	cr,lf,'F : Hware Filtering addrs  '
        dc.b       'P : Print Screen          '
        dc.b       'Z : Restart - Prsrvs Dbase '
helpmn:	ds.w	0


intro1: dc.b   'The POSIE Distributed System'
intro1n:ds.w   0
intro2: dc.b   'EDDE - Event Monitor'
intro2n:ds.w   0
intro3: dc.b   'Version  2.0'
intro3n:ds.w   0
intro4: dc.b   ' July  1990'
intro4n:ds.w   0
intro5: dc.b   'Department of Computer Science'
intro5n:ds.w   0
intro6: dc.b   'University of Edinburgh.'
intro6n:ds.w   0

lin1:   dc.b   '** Event Line Monitoring. **'
lin1n:  ds.w   0
topl:   dc.b   'lqqqqqqwqqqwqqqqw'
        dc.b   'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq'
        dc.b   'wqqqk'
topln:  ds.w   0
midl:   dc.b   'tqqqqqqnqqqnqqqqn'
        dc.b   'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq'
        dc.b   'nqqqu'
midln:  ds.w   0
botl:   dc.b   'mqqqqqqvqqqvqqqqv'
        dc.b   'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq'
        dc.b   'vqqqj'
botln:  ds.w   0
mtxt:   dc.b   'Pro.No Idt LtEv             Previous Activites/Events'
        dc.b   '              BNo'
mtxtn:  ds.w   0

log1:   dc.b   '*** Event Log Monitoring ***'
log1n:  ds.w   0
tlog:   dc.b   'lqqqqqqqqqqqqqqqqwqqqqqqwqqqw'
        dc.b   'qqqqqqwqqqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk'
tlogn:  ds.w   0
mlog:   dc.b   'tqqqqqqqqqqqqqqqqnqqqqqqnqqqn'
        dc.b   'qqqqqqnqqqnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu'
mlogn:  ds.w   0
blog:   dc.b   'mqqqqqqqqqqqqqqqqvqqqqqqvqqqv'
        dc.b   'qqqqqqvqqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj'
blogn:  ds.w   0
log1t:  dc.b   '  Time  Stamp     From  On    To   On          '       
        dc.b   ' Process  Event'
log1tn: ds.w   0
log2t:  dc.b   ' Hr:Mn: Seconds  Procss Brd Procss Brd'
log2tn: ds.w   0

ctxt1p: dc.b   ' Int. Sys. Brd.                          '
        dc.b   'Ctrl Source Destn.   Data'
ctxt1n: ds.w   0
ctxt2p: dc.b   'Sequence Numbers                         '
        dc.b   ' Fd   Addr   Addr    Field'
ctxt2n: ds.w   0

mstat:  dc.b   'Monitor Status : '
mstatn: ds.w   0
hltp:   dc.b   '** HALTED **      '
hltpn:  ds.w   0
sclkp:  dc.b   'Screen Locked     '
sclkpn: ds.w   0
actp:   dc.b   'ACTIVE            '
actpn:  ds.w   0
prntp:  dc.b   'Printing Screen   '
prntpn  ds.w   0
wat:    dc.b   'WAITING for event '
watn:   ds.w   0
err:    dc.b   '** SYSTEM ERROR **'
errn:   ds.w   0
dbfp:   dc.b   '* Database FULL * '
dbfpn:  ds.w   0
ev0:    dc.b   'Unknown - failed to identify'
ev0n:   ds.w   0
ev1:    dc.b   'Process Activated           '
ev1n:   ds.w   0
ev2:    dc.b   'Process Terminated          '
ev2n:   ds.w   0
ev3:    dc.b   'Process Blocked             '
ev3n:   ds.w   0
ev4:    dc.b   'Process Dead                '
ev4n:   ds.w   0
ev5:    dc.b   'Process Halted              '
ev5n:   ds.w   0
ev6:    dc.b   'Process Suspended           '
ev6n    ds.w   0
ev7:    dc.b   'Process Restarted           '
ev7n    ds.w   0
ev8:    dc.b   'Process Active              '
ev8n:   ds.w   0
ev9:    dc.b   'Process Transmitting        '
ev9n:   ds.w   0
ev10:   dc.b   'Process Receiving           '
ev10n:  ds.w   0
ev11:   dc.b   'Waiting for Synchronisation '
ev11n:  ds.w   0
ev12:   dc.b   'Opening File                '
ev12n:  ds.w   0
ev13:   dc.b   'Closing File                '
ev13n:  ds.w   0
ev14:   dc.b   'User Defined #1             '
ev14n:  ds.w   0
ev15:   dc.b   'User Defined #2             '
ev15n:  ds.w   0
lfinms: dc.b   cr,lf,'Load finished',cr,lf
lfinmn: ds.w   0
labtms: dc.b   cr,lf,'Load aborted',cr,lf,bell
labtmn: ds.w   0
* agnp: dc.b   cr,lf
diagnp: dc.b   cr,lf,'                      The POSIE Distributed Event Monitor.'
        dc.b   cr,lf
diag1:  dc.b   cr,lf,'                        A CS&E 4th Year Honours Project'

diag2:  dc.b   cr,lf,'        This project developed into a dual processor'
        dc.b   ' board system aimed'
        dc.b   cr,lf,'     at capturing interprocess communication '
        dc.b   'packets, interpreting them and'
        dc.b   cr,lf,'     logging, in chronological order, the events which '
        dc.b   'occur within a system.'
        dc.b   cr,lf
        dc.b   cr,lf,'        Current System Version :  2.0'
        dc.b   cr,lf
        dc.b   cr,lf,'          The system is configured to interface with '
        dc.b   'the departmental'
        dc.b   cr,lf,'          Centrenet network operating in Burst '
        dc.b   'Protocol Mode.'
        dc.b   cr,lf
        dc.b   cr,lf,'          Board 1 :   Hardware - Centrenet Interface,'
        dc.b   ' Interpretation'
        dc.b   cr,lf,'                                 Processor and '
        dc.b   'associated buffering (FIFO).'
        dc.b   cr,lf,'                      Software - Currently a simple '
        dc.b   'interpretation routine'
        dc.b   cr,lf,'                                 which expects '
        dc.b   'useful info in first 2 packets'
        dc.b   cr,lf,'          Board2  :   Hardware - Interprocess Buffer,'
        dc.b   ' Display Processor and'
        dc.b   cr,lf,'                                 Communications.'
        dc.b   cr,lf,'                      Software - Wyse Screen handling,'
        dc.b   ' Comms, CLI and'
        dc.b   cr,lf,'                                 Event database '
        dc.b   'bookkeeping.'
diagnn: ds.w   0
gandp:  dc.b   ' ** Aux RS232 Link To The Gandalf ** '
        dc.b   cr,lf,'Control \ to return to Monitor. '
gandpn: ds.w   0

cnt1p:  dc.b   cr,lf,'                        EDDE - The POSIE event Monitor.'
        dc.b   cr,lf,cr,lf
        dc.b   cr,lf,'                 The monitor is currently configured to display '
cnt1pn: ds.w   0
eip:    dc.b   cr,lf
        dc.b   cr,lf,'                              EVENT INFORMATION'
eipn:   ds.w   0
cpp:    dc.b   cr,lf,cr,lf,'                              '
cpps:   dc.b   'CENTRENET PACKETS'
cppn:   ds.w   0
cnt2p:  dc.b   cr,lf
        dc.b   cr,lf,'                 and a change from this mode of operation to'
        dc.b   cr,lf,'                 displaying'
cnt2pn: ds.w   0
cnt3p:  dc.b   cr,lf,cr,lf,'                 requires the current database to be deleted !'
        dc.b   cr,lf
        dc.b   cr,lf,'                    C - to change mode of operation or'
        dc.b   cr,lf,'                    Q - to return.'
cnt3pn: ds.w   0
cnt4p:  dc.b   cr,lf,cr,lf,'                 Previous Request Still '
        dc.b   'Uncompleted.'
        dc.b   cr,lf,'                  Please QUIT and Try This Option Again.'
cnt4pn: ds.w   0


*
*

moveto: move.l d0,-(a7)                * move the cursor on WYSE to position
        move.b esc,d0                  * x,y on the screen. 2 ascii coded values
        jsr    outch                   * required e.g. 5 = $3035 and 17 = $3137
        move.b lbk,d0
        jsr    outch
        rol.w  #8,d2
        move.b d2,d0
        jsr    outch
        lsr.w  #8,d2
        move.b d2,d0
        jsr    outch
        move.b #59,d0       *  ;
        jsr    outch
        rol.w  #8,d3
        move.b d3,d0
        jsr    outch
        lsr.w  #8,d3
        move.b d3,d0
        jsr    outch
        move.b #72,d0       *  H
        jsr    outch
        move.l (a7)+,d0
        rts

upst:   movem.l d1/d2/d3/a4,-(a7)      * Update monitor status and display
        move.w #$3033,d2               * current status.
        move.w #$3631,d3
        jsr    moveto
        btst   #0,stats2
        beq    ht
        lea    err,a4
        move.l #errn-err,d1            * Error status
        jsr    pdata
        bra    upe
ht:     btst   #2,stats2
        beq    ptn
        lea    hltp,a4
        move.l #hltpn-hltp,d1          * Halt status
        jsr    pdata
        bra    upe
ptn:    btst   #4,stats2
        beq    nht
        lea    prntp,a4
        move.l #prntpn-prntp,d1        * Printing screen status
        jsr    pdata
        bra    upe
nht:    btst   #1,stats2
        beq    nsl
        lea    sclkp,a4
        move.l #sclkpn-sclkp,d1        * Screen lock status
        jsr    pdata
        bra    upe
nsl:    btst   #6,stats2               * Warning when database memory 
        beq    ac0                     * allocation used up.
        lea    dbfp,a4
        move.l #dbfpn-dbfp,d1
        jsr    pdata
        bra    upe
ac0:    btst   #3,stats2
        beq    ac1
        lea    wat,a4
        move.l #watn-wat,d1            * Wait for event i.e. all entries
        jsr    pdata                   * in the data base have been displayed.
        bra    upe
ac1:    btst   #5,stats2
        beq    ac2
        lea    cpps,a4                 * Displaying centrenet packets, i.e
        move.l #cppn-cpps,d1           * no event/information is being extracted
        jsr    pdata                   * from the IPC messages.
        bra    upe
ac2:    lea    actp,a4
        move.l #actpn-actp,d1          * Monitor active status
        jsr    pdata
upe     movem.l (a7)+,d1/d2/d3/a4
        rts

*********** Interupt Servers ***********

ffserv: movem.l d0/a0/a1,-(a7)         * Continual background process to
        move.b hwcnt,d0                * read the Fifo. It is in fact an
        or.b   rroff,d0                * service routine which places the
        move.b d0,hwcnt                * incoming packet in the next free
        move.b d0,led
        move.w fifo,d0                 * address in the database.
        move.l dbadrw,a1
        move.l (a1),a0
        move.w d0,(a0)+
        move.l a0,(a1)
        cmp.l  dbfull,a0               * Check for db being full
        bne    notful
        eori.b #$40,stats2             * set db full flag
        jsr    upst
        bra    ffexit
notful: move.b hwcnt,d0
        and.b  rron,d0
        move.b d0,hwcnt
        move.b d0,led
ffexit: movem.l (a7)+,d0/a0/a1
        rte

acksrv: movem.l a0/d0,-(a7)            * Service routine to complete handshake
        move.b hwcnt,d0                * with interpretation processor.
        or.b   cepoff,d0               * if dbfull dont make read req.
        move.b d0,led
        move.b d0,hwcnt
        move.w mode,d0
        cmp.b  #0,d0
        beq    acont
        eori.b #$20,stats2
        move.w #0,mode
acont:  movem.l (a7)+,a0/d0
        rte

****************************************

clrled: move.b hwcnt,d0                  * LED off
        or.b   grnoff,d0
        move.b d0,led
        move.b d0,hwcnt
        rts
*
grnled: move.b hwcnt,d0                * LED on
        and.b  grnon,d0
        move.b d0,led
        move.b d0,hwcnt
        rts

home:   movem.l d2/d3,-(a7)            * move cursor to position 1,1
        move.w #ascii0+1,d2
        move.w #ascii0+1,d3
        jsr    moveto
        movem.l (a7)+,d2/d3
        rts

wind:   move.l d0,-(a7)                * Building block routine to define
        move.b esc,d0                  * windows.
        jsr    outch
        move.b lbk,d0
        jsr    outch
        rol.w  #8,d2
        move.b d2,d0
        jsr    outch
        lsr.w  #8,d2
        move.b d2,d0
        jsr    outch
        move.b #59,d0
        jsr    outch
        rol.w  #8,d3
        move.b d3,d0
        jsr    outch
        lsr.w  #8,d3
        move.b d3,d0
        jsr    outch
        move.b #114,d0
        jsr    outch
        move.l (a7)+,d0
        rts


windf2: movem.l d2/d3,-(a7)            * defines size of window, from line 1-22.
        move.w  #$3031,d2
        move.w  #$3232,d3
        jsr     wind
        movem.l (a7)+,d2/d3
        rts

windf:  movem.l d2/d3,-(a7)            * defines the full screen window.
        move.w  #$3031,d2
        move.w  #$3234,d3
        jsr     wind
        movem.l (a7)+,d2/d3
        rts

cls:    move.l d0,-(a7)                * clear full screen routine.
        jsr    home
        move.b esc,d0
        jsr    outch
        move.b lbk,d0
        jsr    outch
        move.b #ascii0+2,d0       *  2
        jsr    outch
        move.b #ascii0+4,d0       *  4
        jsr    outch
        move.b #76,d0       *  L
        jsr    outch
        move.l (a7)+,d0
        rts

smthsc: move.l d0,-(a7)                * enable/disable Smooth scroll
        move.b esc,d0                  *     00/04 in d2 as param.
        jsr    outch
        move.b lbk,d0
        jsr    outch
        move.b #63,d0
        jsr    outch
        move.b #$34,d0
        jsr    outch
        move.b #104,d0
        add.b  d2,d0
        jsr    outch
        move.l (a7)+,d0
        rts

attr:   move.l  d0,-(a7)               * To allow character attributes
        move.b  esc,d0                 * for the text which follows.
        jsr     outch                  * Attribute value must be d2.
        move.b  lbk,d0
        jsr     outch
        rol.w   #8,d2
        move.b  d2,d0
        jsr     outch
        lsr.w   #8,d2
        move.b  d2,d0
        jsr     outch
        move.b  #112,d0
        jsr     outch
        move.l  (a7)+,d0
        rts

clratt: move.l  d2,-(a7)               * Clear text attributes.
        move.w  #$0,d2
        jsr     attr
        move.l  (a7)+,d2
        rts


prtstt: movem.l d1/d2/d3/a4,-(a7)      * Print Monitor status prompt
        move.w #$3033,d2
        move.w #$3434,d3
        jsr    moveto
        lea    mstat,a4
        move.l #mstatn-mstat,d1
        jsr    pdata
        movem.l (a7)+,d1/d2/d3/a4
        rts

intscn: jsr    windf                   * Draws the Introduction screen.
        jsr    cls
        lea    intro1,a4
        move.l #intro1n-intro1,d1
        move.w #ascii0+4,d2
        move.w #$3235,d3
        jsr    moveto
        move.w #$3038,d2
        jsr    attr
        jsr    pdata
        jsr    clratt
        lea    intro2,a4
        move.l #intro2n-intro2,d1
        move.w #ascii0+6,d2
        move.w #$3239,d3           *  32
        jsr    moveto
        move.w #$3130,d2
        jsr    attr
        jsr    pdata
        jsr    clratt
        lea    intro3,a4
        move.l #intro3n-intro3,d1
        move.w #$3039,d2
        move.w #$3334,d3
        jsr    moveto
        jsr    pdata
        lea    intro4,a4
        move.l #intro4n-intro4,d1
        move.w #$3130,d2
        move.w #$3335,d3
        jsr    moveto
        jsr    pdata
        lea    intro5,a4
        move.l #intro5n-intro5,d1
        move.w #$3133,d2
        move.w #$3235,d3
        jsr    moveto
        jsr    pdata
        lea    intro6,a4
        move.l #intro6n-intro6,d1
        move.w #$3135,d2
        move.w #$3238,d3
        jsr    moveto
        jsr    pdata
        jsr    home 
        jsr    pbell
        rts

grmode: move.l d0,-(a7)                * Put WYSE in Graphics mode.
        move.b esc,d0
        jsr    outch
        move   #40,d0     *   (
        jsr    outch
        move   #ascii0,d0
        jsr    outch
        move.l (a7)+,d0
        rts

nmode:  move.l d0,-(a7)                * Returns WYSE to Normal Font mode.
        move.b esc,d0
        jsr    outch
        move   #40,d0
        jsr    outch
        move.b #66,d0    *    B
        jsr    outch
        move.l (a7)+,d0
        rts

movec:  move.l d0,-(a7)                * Cursor to column stored in ascii code
        move.b esc,d0                  * with tens in d2 and units in d3.
        jsr    outch
        move.b lbk,d0
        jsr    outch
        move.b d2,d0
        jsr    outch
        move.b d3,d0
        jsr    outch
        move.b #71,d0    *   G
        jsr    outch
        move.l (a7)+,d0
        rts

************************************************************
**      Routines to display the Event Line Monitoring Screen

ptxtln: movem.l d0/d2/d3,-(a7)         * draws graphics chars for the text
        move.b #$30,d2                 * lines in the graphics window.
        move.b #$35,d3
        jsr    movec
        move.b #120,d0       *  x
        jsr    outch
        move.b #$31,d2
        move.b #$32,d3
        jsr    movec
        jsr    outch
        move.b #$36,d3
        jsr    movec
        jsr    outch
        move.b #$32,d2
        move.b #$31,d3
        jsr    movec
        jsr    outch
        move.b #$37,d2
        move.b #$32,d3
        jsr    movec
        jsr    outch
        move.b #$36,d3
        jsr    movec
        jsr    outch
        movem.l (a7)+,d0/d2/d3
        rts

ttxtln: lea    mtxt,a4                 * Prints headings for columns in 
        move.l #mtxtn-mtxt,d1          * the graphics window.
        move.w #$3035,d2
        move.w #$3036,d3
        jsr    moveto
        jsr    nmode
        jsr    pdata
        jsr    grmode
        jsr    ptxtln
        rts


linsc1: jsr    windf2                  * Draws the top half of the
        jsr    cls                     * Graphics window 
        lea    lin1,a4
        move.l #lin1n-lin1,d1
        move.w #ascii0+2,d2
        move.w #$3235,d3
        jsr    moveto
        move.w #$3038,d2
        jsr    attr
        jsr    pdata
        jsr    clratt
        jsr    prtstt
        lea    topl,a4
        move.l #topln-topl,d1
        move.w #ascii0+4,d2
        move.w #ascii0+5,d3
        jsr    moveto
        jsr    grmode
        jsr    pdata
        move.w #ascii0+5,d2
        move.w #ascii0+1,d3
        jsr    moveto
        jsr    ttxtln
        lea    midl,a4
        move.l #midln-midl,d1
        move.w #ascii0+6,d2
        move.w #ascii0+5,d3
        jsr    moveto
        jsr    pdata
        rts

nxtln:  move.l d0,-(a7)                * moves the cursor down one line.
        move.b esc,d0
        jsr    outch
        move.b lbk,d0
        jsr    outch
        move.b #69,d0
        jsr    outch
        move.l (a7)+,d0
        rts


linsc2: move.w #11,d0                  * Draws the second half the 
        bra    tent                    * graphics display window.
more:   jsr    nxtln
        jsr    ptxtln
tent:   dbra   d0,more
        lea    botl,a4
        move.l #botln-botl,d1
        move.w #$3138,d2
        move.w #ascii0+5,d3
        jsr    moveto
        jsr    pdata
        jsr    nmode
        rts

wind1a: movem.l d2/d3,-(a7)            * Sets up the graphics display
        move.w  #$3038,d2              * Window
        move.w  #$3137,d3
        jsr     wind
        movem.l (a7)+,d2/d3
        rts

wind1:  movem.l d2/d3,-(a7)
        move.w  #$3037,d2
        move.w  #$3137,d3
        jsr     wind
        movem.l (a7)+,d2/d3
        rts

wind2a: movem.l d2/d3,-(a7)
        move.w  #$3139,d2
        move.w  #$3234,d3
        jsr     wind
        movem.l (a7)+,d2/d3
        rts

wind2:  movem.l d2/d3,-(a7)
        move.w  #$3139,d2
        move.w  #$3232,d3
        jsr     wind
        movem.l (a7)+,d2/d3
        rts

wind3:  movem.l d2/d3,-(a7)
        move.w  #$3233,d2
        move.w  #$3234,d3
        jsr     wind
        movem.l (a7)+,d2/d3
        rts

*
* :*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*
*
* Initialisation routines
*
* :*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*
*
*
* 68681 initialization : 9600 baud,8 data bits,1 stop bit,
* no parity check and for interupt interface with processor.
*
duart:	movem.l d0/d1/a0/a1,-(a7)   * save registers
	move.b	#noints,imr	* clear all interrupt enables
	move.l	#tablx,a0   * get init parameters
	move.l	#lengtx,d0  * get number of parameters
*
	bra sk0inix        * do loop test
lp0inix:	move.l (a0)+,a1   * get register address
	move.l (a0)+,d1     * parity etc.
*
	move.b	d1,(a1)   	* put command
sk0inix:	dbra	d0,lp0inix * loop test
*
*
*
     move.b    #ten,cmda
     move.b    #ten,cmdb
     move.b    #ren,cmda
     move.b    #ren,cmdb
     movem.l   (a7)+,d0/d1/a0/a1_*restore registers
	rts
*
* set mode of channel A - 7 bits, no parity, 1 stop bit 9600 baud
*  no hsking
*
tablx:dc.l   cmda,point1
     dc.l   modea,norrts+rirdy+cerr+nopar+bits8
     dc.l   modea,norop+notrts+nocts+stop1
*
* Set mode of Channel B - 7 bits, no parity, 1 stop bit, 9600 baud
* no hsking
*
     dc.l   cmdb,point1
     dc.l   modeb,norrts+rirdy+cerr+nopar+bits8
     dc.l   modeb,norop+notrts+nocts+stop1
*
* set output port config register
*
     dc.l   opcr,allout
*
* Reset and enable channel A
*
     dc.l    cmda,rstrx
     dc.l    cmda,rsttx_* reset transmitter
     dc.l    cmda,rsterr
     dc.l    cmda,rstint
     dc.l    cmda,brkoff+tdis+ren
     dc.l    clka,b9600
*
* Reset and enable channel b
*
     dc.l   cmdb,rstrx
     dc.l   cmdb,rsttx
     dc.l   cmdb,rsterr
     dc.l   cmdb,rstint
     dc.l   cmdb,brkoff+tdis+ren
     dc.l   clkb,b9600
*
* Setup output pins
*
     dc.l   imr,$02 
     dc.l   bitset,$ff
lengtx equ   (*-tablx)/8
     rts

* :*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*
*
*
* 68681 initialization : 9600 baud,8 data bits,1 stop bit,
* no parity checkand for a polling interface with processor
*
redrt:	movem.l d0/d1/a0/a1,-(a7)   * save registers
	move.b	#noints,imr	* clear all interrupt enables
	move.l	#table,a0   * get init parameters
	move.l	#length,d0  * get number of parameters
*
	bra sk0init        * do loop test
lp0init:	move.l (a0)+,a1   * get register address
	move.l (a0)+,d1     * parity etc.
*
	move.b	d1,(a1)   	* put command
sk0init:	dbra	d0,lp0init * loop test
*
*
*
     move.b    #ten,cmda
     move.b    #ten,cmdb
     move.b    #ren,cmda
     move.b    #ren,cmdb
     movem.l   (a7)+,d0/d1/a0/a1_*restore registers
	rts
*
* set mode of channel A - 7 bits, no parity, 1 stop bit 9600 baud
*  no hsking
*
table:dc.l   imr,noints
     dc.l   cmda,point1
     dc.l   modea,norrts+rirdy+cerr+nopar+bits8
     dc.l   modea,norop+notrts+nocts+stop1
*
* Set mode of Channel B - 7 bits, no parity, 1 stop bit, 9600 baud
* no hsking
*
     dc.l   cmdb,point1
     dc.l   modeb,norrts+rirdy+cerr+nopar+bits8
     dc.l   modeb,norop+notrts+nocts+stop1
*
* set output port config register
*
     dc.l   opcr,allout
*
* Reset and enable channel A
*
     dc.l    cmda,rstrx
     dc.l    cmda,rsttx_* reset transmitter
     dc.l    cmda,rsterr
     dc.l    cmda,rstint
     dc.l    cmda,brkoff+tdis+ren
     dc.l    clka,b9600
*
* Reset and enable channel b
*
     dc.l   cmdb,rstrx
     dc.l   cmdb,rsttx
     dc.l   cmdb,rsterr
     dc.l   cmdb,rstint
     dc.l   cmdb,brkoff+tdis+ren
     dc.l   clkb,b9600
*
* Setup output pins
*
     dc.l   bitset,$ff
length equ   (*-table)/8
     rts

fset:   move.w dtbnds,dgbar            * Routine to set Hardware Filter Regs
        move.w scbnds,sgbar
        move.b filctl,contr
        rts

sinit:  jsr    clrled                  * Initialises the event database.
        move.l dbadrw,a0
        move.l dbase,(a0)    * test on dbase2
        move.l dbadrr,a0
        move.l dbase,(a0)
        rts

init:   or.w   #$0700,sr               * disable all interrupts
        jsr    sinit                   * clears database registers.
        move.b #$20,stats2             * clears monitor status register
        move.b #0,status               * clears monitor mode register
        move.w #0,mode                 * clears change operation mode flag.
        move.b rron,led                * initiate database entry of 
        move.b rron,hwcnt              * event packets.
        jsr    duart                   * duart initialise in interupt mode
        move.w #$ff00,scbnds           * set filter H'ware source bound
        move.w #$ff00,dtbnds           *                   destination
        move.b #$dd,filctl             * control reg for filter.
        jsr    fset                    * set Filter H'ware to mirror reg values
*        jsr    inchu                   * press a key to start
        move.l #4,d2                   * smooth scroll currently disabled
        jsr    smthsc
        and.w  #$fcff,sr               * enable level 5 and above interrupts
        rts

* :*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*
*
* Main command interpreter routine
*
* :*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*
*

cpstt:  movem.l  d0/d4/d5,-(a7)        * Get cursor position.
        move.w  #$30,d4                * Need two communication with
        move.w  #$30,d5                * the WYSE.
        move.w  #00,d6
        move.w  #00,d7
        move.b  esc,d0
        jsr     outch
        move    lbk,d0
        jsr     outch
        cmp.b   #$36,d2
        bne     printc
        move.b  d2,d0
        jsr     outch
        move.b  #110,d0
        jsr     outch
        jsr     inch     * the esc
        jsr     inch     * [
        jsr     inch     * P0
        move.b  d0,d6
        jsr     inch
        cmp.b   #59,d0   * ;
        beq     yval
        move.b  d6,d5
        move.b  d0,d6
        jsr     inch
yval:   jsr     inch
        move.b  d0,d7
        jsr     inch
        cmp.b   #82,d0   * R
        beq     nval
        move.b  d7,d4
        move.b  d0,d7
        jsr     inch
nval:   lsl.w   #8,d4
        lsl.w   #8,d5
        add.w   d5,d6
        add.w   d4,d7
        movem.l (a7)+,d0/d4/d5
        rts
printc: move.b  #63,d0                 Tell WYSE to print screen.
        jsr     outch
        move.b  #$31,d0
        jsr     outch
        move.b  #$35,d0
        jsr     outch
        jsr     inchu
        jsr     inchu
        jsr     inchu
        jsr     inchu
        jsr     inchu
        move.b  d0,d2
        jsr     inchu
        movem.l (a7)+,d0/d4/d5
        rts

tstwd:  movem.l d2/d3,-(a7)            * Reset the Windows after key
        btst    #4,status              * pressed routines.
        beq     tst5
        jsr     windf2
        bra     tted
tst5:   btst    #5,status
        beq     tst6
        jsr     windf2
        bra     tted
tst6:   btst    #6,status
        beq     tst7
        jsr     wind1
        bra     tted
tst7:   btst    #7,status
        beq     tted
        jsr     wind1a
tted:   move.w  d6,d2
        move.w  d7,d3
        jsr     moveto
        move.b  #04,d2
        jsr     smthsc
        movem.l (a7)+,d2/d3
        rts

lpromt: movem.l d2/d3,-(a7)            * Move cursor to user prompt.
        jsr    wind3
        move.w #$3233,d2
        move.w #$3031,d3
        jsr    moveto
        jsr    nxtln
        movem.l (a7)+,d2/d3
        rts

lprom:  movem.l d1/a4,-(a7)            * Print user/monitor prompt
        jsr    lpromt
        lea    promms,a4	*
        move.l #prommn-promms,d1	* get message length
        jsr    pdata	* print prompt
        movem.l (a7)+,d1/a4
        rts

eline:  jsr     outch                  * Change mode to event line monitoring
        jsr     lprom
        jsr     tstwd
        move.b  #$40,status
        movem.l (a7)+,d0/d1/d2/d3
        rte

elog:   jsr     outch                  * Change mode to event log monitoring.
        jsr     lprom
        jsr     tstwd
        move.b  #$80,status
        movem.l (a7)+,d0/d1/d2/d3
        rte

shdg:   jsr     outch                  * Change mode to display version
        jsr     lprom                  * of hardware and software in use
        jsr     tstwd
        move.b  #$10,status
        movem.l (a7)+,d0/d1/d2/d3
        rte

fltch:  jsr     outch                  * Change mode to Allow the filter latches to be
        jsr     lprom                  * to be updated. 
        jsr     tstwd
        move.b  #$20,status
        movem.l (a7)+,d0/d1/d2/d3
        rte

rset:   jsr     outch                  * change mode to reset sequence
        jsr     lprom
        jsr     tstwd
*        or.w    #$0700,sr
        jsr     init
        move.b  #$00,status
        movem.l (a7)+,d0/d1/d2/d3
        rte
*
*
* Load program from remote device
*
ploadr: jsr outch	* echo command char
pload1:	jsr hinch	* get char from network
	cmp.b #$53,d0	* is it "S"?
	bne pload1	* no, try again
	jsr outch	* output "S"
	jsr hinch	* get record type no (1,2 or 9)
	cmp.b #$31,d0	* is it 1?
	beq shadd	* yes, short address version
	cmp.b #$32,d0	* is it 2?
	beq lngadd	* yes, long address version
	cmp.b #$39,d0	* is it 9?
	beq windup	* yes, download ending
	bra lprm70	* abort if any other character
shadd:	jsr hin2hx	* get record length
	bcs lprm70	* prompt if <CR>
	clr.l d2
	move.b d0,d2	* record length in D2
	sub.l #4,d2	* adjust it to count data only
	clr.l d3	* clear address pointer
shad2:	jsr hin4hx	* get address
	bcs lprm70	* prompt if <CR>
	move.w d1,d3	* put addr in pointer
	move.l d3,a4	* move it to a4
getbyt:	jsr hin2hx	* get data byte
	bcs lprm70	* prompt if <CR>
	move.b d0,(a4)+	* put in memory
	dbra d2,getbyt	* repeat as rqd
	jsr hin2hx	* throw away checksum
	bcs lprm70	* prompt if <CR>
	bra pload1	* get next record
lngadd:	jsr hin2hx	* get record length
	bcs lprm70	* prompt if <CR>
	clr.l d2
	move.b d0,d2	* record length into d2
	sub.l #5,d2	* adjust to count data only
	clr.l d3
	jsr hin2hx	* get msb of addr to d0
	bcs lprm70	* prompt if <CR>
	move.b d0,d3	* put it in d3
	swap d3		* move it to correct byte of d3
	bra shad2	* continue
windup:	jsr hin4hx
	jsr hin4hx	* throw away 4 bytes
	lea lfinms,a4	* load finished message
	move.l #lfinmn-lfinms,d1
lprm69:	jsr pdata	* print message
       rts
*      bra lprom	* goto prompt
lprm70: lea labtms,a4	* load aborted message
        move.l #labtmn-labtms,d1
        bra lprm69
*
* RSLINK: links to auxiliary RS232 port, allows downloading
* 
rslink: lea    gandp,a4
        move.l #gandpn-gandp,d1
        jsr    pdata
        move.b cr,d0
        jsr    outch2
*	jsr outch	* echo char
rsloop:	jsr inchr2	* get char from aux RS232
	bcc gotch	* branch if char available
	jsr inchr	* get char from terminal
	bcs rsloop	* loop if no char available
	cmp.b #netbrk,d0	* is it NETWORK BREAK char?
	bne rscont	* branch if not
     rts
*bra lprom	* goto prompt
rscont:	jsr outch2	* send char to aux RS232 port
	bra rsloop	* loop
gotch:	cmp.b #00,d0	* is it null char?
	beq rsloop	* if so discard and loop
	cmp.b #netbrk,d0	* is it NETWORK BREAK char?
	beq ploadr	* if so, go to program downloader
	jsr outch	* otherwise send to terminal
	bra rsloop	* and loop

gand:   jsr     windf2                 * Setup gandalf link.
        jsr     cls
        move.b  #04,d2
        jsr     smthsc
        jsr     rslink
        move.b  #$02,status
        jsr     lprom
        jsr     tstwd
        movem.l (a7)+,d0/d1/d2/d3
        rte

quit:   jsr     outch                  * Change mode the quit mode.
        move.b  #$04,status
*        jsr     setst
        jsr     lprom
        jsr     tstwd
        movem.l (a7)+,d0/d1/d2/d3
        rte

lpromx: jsr lprom                     * No action to mode update
        jsr     tstwd                 * since return pressed.- escape
        movem.l (a7)+,d0/d1/d2/d3     * from key board handling routines.
        rte


iconi:  move.b #00,d2
        jsr    smthsc
        jsr    outch                  * Icon help
        jsr    wind2
        move.w #$3139,d2
        move.w #$3031,d3
        jsr    moveto
        move.l a4,-(a7)
        lea    iconms,a4	* get message pointer
        move.l #iconmn-iconms,d1	* get message length
        jsr    pdata	* print it
        jsr    lprom
        jsr     tstwd
        move.l (a7)+,a4
        movem.l (a7)+,d0/d1/d2/d3
        rte

hisnum: move.l #0,d3                 * register for relative flag
        move.l #0,d2                 * register for accumulation of value.
        move.l #0,d0
        jsr    pspac1
hnext:  jsr    inchu
        cmp.b  #cr,d0
        beq    hnexit                * rts if cr pressed
        cmp.b  #$2d,d0               * check if is `-'
        beq    relat
        cmp.b  #$30,d0               * is it less than 0
        blt    hnext
        cmp.b  #$39,d0
        bgt    hnext
        jsr    outch
        sub.b  #$30,d0
        move.l d2,d1
        lsl.l  #3,d2
        lsl.l  #1,d1
        add.l  d1,d2
        add.l  d0,d2
        bra    hnext
relat:  jsr    outch
        move.b d0,d3
        bra    hnext
hnexit: rts

histor: jsr    outch                * output char
        movem.l a0/a1,-(a7)
        jsr    hisnum               * input index value to start display from
        move.l dbadrr,a0
        move.l dbase,d1
        cmp.b  #$2d,d3
        bne    habs
        move.l (a0),d0              * put read db address ptr in d0.
        sub.l  d1,d0                * find db size for read packets.
        lsr.l  #3,d0                * find the number of packets read.
        sub.l  d2,d0                * move ptr back this number of places
        cmp.l  #0,d0
        bgt    hplus
        move.l #0,d0
hplus:  lsl.l  #3,d0                * convert back to bytes
        add.l  d1,d0                * add dbase to value
        move.l (a0),d0              * write to pointer.
        bra    hisext
habs:   move.l dbadrw,a1            * get write pointer
        move.l (a1),d0
        sub.l  d1,d0                * find number of bytes in db
        lsr.l  #3,d0                * find number of packets in db
        cmp.l  d2,d0                * is inputed value larger than number in db
        blt    hisext
        lsl.l  #3,d2 
        add.l  d1,d2
        move.l d2,(a0)
hisext: jsr    lprom
        jsr    tstwd
        movem.l (a7)+,a0/a1
        movem.l (a7)+,d0/d1/d2/d3
        rte

pscrn:  jsr    outch                  * Print screen      
        eori.b #$10,stats2
        jsr    upst
        jsr    lprom
*prtst:  move.b #0,d2
*       jsr    cpstt
*       cmp.b  #$30,d2
*       bne    prtst
*       move.b esc,d0
*       jsr    outch
*       move.b lbk,d0
*       jsr    outch
*       move.b #105,d0
*       jsr    outch
        jsr     tstwd
        movem.l (a7)+,d0/d1/d2/d3
        rte

tlah:   eori.b #$04,stats2            * Cause monitor to halt.
        jsr    outch
        jsr    upst
        jsr    lprom
        jsr    tstwd
        movem.l (a7)+,d0/d1/d2/d3
        rte

lkscrn: eori.b #$02,stats2            * Cause screen display to freeze.
        jsr    outch
        jsr    upst
        jsr    lprom
        jsr     tstwd
        movem.l (a7)+,d0/d1/d2/d3
        rte

rstart: jsr    outch                  * initate a soft reset
        jsr    lprom
        jsr     tstwd
        move.l  dbadrr,a0
        move.l  dbase,(a0)
        move.b  #00,status
        movem.l (a7)+,d0/d1/d2/d3
        rte

centnt: jsr    outch
        jsr    windf2
        jsr    cls
        move.w #$3033,d2
        move.w #$3031,d3
        jsr    moveto
        move.l a4,-(a7)
        lea    cnt1p,a4
        move.l #cnt1pn-cnt1p,d1
        jsr    pdata
        btst   #5,stats2
        beq    norm1
        lea    cpp,a4
        move.l #cppn-cpp,d1
        jsr    pdata
        bra    cont1
norm1:  lea    eip,a4
        move.l #eipn-eip,d1
        jsr    pdata
cont1:  lea    cnt2p,a4
        move.l #cnt2pn-cnt2p,d1
        jsr    pdata
        btst   #5,stats2
        beq    norm2
        lea    eip,a4
        move.l #eipn-eip,d1
        jsr    pdata
        bra    cont2
norm2:  lea    cpp,a4
        move.l #cppn-cpp,d1
        jsr    pdata
cont2:  lea    cnt3p,a4
        move.l #cnt3pn-cnt3p,d1
        jsr    pdata
        move.w mode,d0
        cmp.w  #0,d0
        beq    charp
        lea    cnt4p,a4
        move.l #cnt4pn-cnt4p,d1
        jsr    pdata
charp:  jsr    inchu
        cmp.b  #cr,d0            * is it <cr>?
        beq    charp
        cmp.b  #$43,d0           * is it 'C'? Continue.
        beq    chmod
        cmp.b  #$51,d0           * is it 'Q'? Quit.
        beq    cterm
        jsr    pbell
        bra    charp

chmod:  move.w #$ffff,mode           * Set mode change flag. Cleared when other
        move.b hwcnt,d0
        btst   #5,stats2         * Board acknowledges the change of operation.
        beq    zip
        and.b  evpon,d0
        move.b d0,hwcnt
        move.b d0,led
        bra    cterm
zip:    and.b  ctpon,d0
        move.b d0,hwcnt
        move.b d0,led
*
**czip:   or.w   #$0500,sr        * disable keyboard and buffer interrupts while 
*        jsr    sinit           * resetting db.
**        and.w  #$fcff,sr       * enable interrupts again. 5 upwards.
cterm:  jsr    lpromt
        move.l #3234,d2
        move.l #3038,d3
        jsr    moveto
        jsr    outch
        jsr    lprom
        jsr    tstwd
        move.b #00,status
        move.l (a7)+,a4
        movem.l (a7)+,d0/d1/d2/d3
        rte
**
*
chinp:  movem.l d0/d1/d2/d3,-(a7)     * Get character from Duart
        move.l d0,-(a7)               * converted it to upper case.
*       move.b  #00,d2                * Take the necessary action by
*       jsr     smthsc                * setting the status registers.
        move.b #$36,d2                * The monitor will then change
        jsr    cpstt                  * mode at specific times.
        jsr    lpromt
        move.w #$3234,d2
        move.w #$3038,d3
        jsr    moveto
        move.l (a7)+,d0
*       jsr    upcse
        jsr    inchu	* get an upper-case character
        cmp.b  #cr,d0	* is it <CR>?
        beq    lpromx	* yes, goto prompt
        cmp.b  #$3f,d0	* is it "?"?
        beq    query	* yes, goto query
        cmp.b  #$41,d0	* is it "A"?
        beq    eline	* yes, goto event line monitor
        cmp.b  #$42,d0 * is it "B"?
        beq    histor  * yes goto Database History routine
        cmp.b  #$43,d0 * is it "C"?
        beq    centnt * yes goto change monitor mode
        cmp.b  #$44,d0	* is it "D"?
        beq    shdg	* yes, goto system diagnostics
        cmp.b  #$45,d0	* is it "E"?
        beq    elog	* yes, goto event log monitor
        cmp.b  #$46,d0	* is it "F"?
        beq    fltch	* yes, goto filter change      
        cmp.b  #$47,d0	* is it "G"?
        beq    gand	* yes, goto gandalf interface
        cmp.b  #$48,d0	* is it "H"?
        beq    tlah	* yes, goto halt routine
        cmp.b  #$49,d0	* is it "I"?
        beq    iconi	* yes, goto icon info for event line monitor
        cmp.b  #$50,d0	* is it "P"?
        beq    pscrn	* yes, goto print screen routine
        cmp.b  #$51,d0	* is it "Q"?
        beq    quit	* yes, goto quit routine
        cmp.b  #$52,d0	* is it "R"?
        beq    rset	* yes, goto REBOOT routine
        cmp.b  #$53,d0	* is it "S"?
        beq    lkscrn	* yes, goto lock screen routine
        cmp.b  #$5a,d0	* is it "Z"?
        beq    rstart	* yes, goto restart routine
*
* character not found
*
        jsr    pbell	* char not found, print bell
        movem.l (a7)+,d0/d1/d2/d3
        rte

akey:   movem.l d0/d2,-(a7)            * Has a key been pressed if so
        and.w   #$f8ff,sr           * what is and take the appropriate action.
*       jsr     inchr
*       bcs     nokey
*       jsr     chinp
        move.l  #$ffffffff,d0       * A delay
zz:     dbra    d0,zz
        or.w    #$0400,sr           * disable level 4 and below interrupts
        move.b  #04,d2
        jsr     smthsc
        movem.l (a7)+,d0/d2
        rts

*
* Command Jump table
*
lprom1: move.b  #00,d2
        jsr     smthsc
        jsr    outch	* echo character   
        jsr    lprom	* goto prompt
        jsr     tstwd
        movem.l (a7)+,d0/d1/d2/d3
        rte
*
* QUERY: print help message* uses D1, D0
*
query:  move.b #00,d2
        jsr    smthsc
        jsr    outch	* output character
        jsr    wind2
        move.w #$3139,d2
        move.w #$3031,d3
        jsr    moveto
        move.l a4,-(a7)
        lea    helpms,a4	* get message pointer
        move.l #helpmn-helpms,d1	* get message length
        jsr    pdata	* print it
        jsr    lprom
        jsr    tstwd
        move.l (a7)+,a4
        movem.l (a7)+,d0/d1/d2/d3
        rte

*************************************************************
*       Routines for Event Log Monitoring.

**   Graphics routines to draw the graphical window.

ptlgln: movem.l d0/d2/d3,-(a7)       * draws the vertical lines between
        move.b #$30,d2               * columns
        move.b #$35,d3
        jsr    movec
        move.b #120,d0       *  x
        jsr    outch
        move.b #$32,d2
        move.b #$32,d3
        jsr    movec
        jsr    outch
        move.b #$39,d3
        jsr    movec
        jsr    outch
        move.b #$33,d2
        move.b #$33,d3
        jsr    movec
        jsr    outch
        move.b #$34,d2
        move.b #$30,d3
        jsr    movec
        jsr    outch
        move.b #$34,d3
        jsr    movec
        jsr    outch
        move.b #$37,d2
        move.b #$36,d3
        jsr    movec
        jsr    outch
        movem.l (a7)+,d0/d2/d3
        rts

evlg2:  move.w #10,d0             * Draws the lower half of the graphics
        bra    lgnt               * window for event log monitoring
lgre:   jsr    nxtln
        jsr    ptlgln
lgnt:   dbra   d0,lgre
        lea    blog,a4
        move.l #blogn-blog,d1
        move.w #$3138,d2
        move.w #ascii0+5,d3
        jsr    moveto
        jsr    pdata
        jsr    nmode
        rts

tlogln: btst   #5,stats2
        bne    cp1
        lea    log1t,a4          * Draws the top half of the graphics
        move.l #log1tn-log1t,d1  * window.
        bra    prev1
cp1:    lea    ctxt1p,a4
        move.l #ctxt1n-ctxt1p,d1
prev1:  move.w #$3035,d2
        move.w #$3036,d3
        jsr    moveto
        jsr    nmode
        jsr    pdata
        jsr    grmode
        jsr    ptlgln
        btst   #5,stats2
        bne    cp2
        lea    log2t,a4
        move.l #log2tn-log2t,d1
        bra    prev2
cp2:    lea    ctxt2p,a4
        move.l #ctxt2n-ctxt2p,d1
prev2:  move.w #$3036,d2
        jsr    moveto
        jsr    nmode
        jsr    pdata
        jsr    grmode
        jsr    ptlgln
        rts



evlg1:  jsr    windf2               * Sets up screen for event log monitoring
        jsr    cls                  * displays screen heading
        lea    log1,a4
        move.l #log1n-log1,d1
        move.w #ascii0+2,d2
        move.w #$3235,d3
        jsr    moveto
        move.w #$3038,d2
        jsr    attr
        jsr    pdata
        jsr    clratt
        jsr    prtstt
        lea    tlog,a4
        move.l #tlogn-tlog,d1
        move.w #ascii0+4,d2
        move.w #ascii0+5,d3
        jsr    moveto
        jsr    grmode
        jsr    pdata
        move.w #ascii0+5,d2
        move.w #ascii0+1,d3
        jsr    moveto
        jsr    tlogln
        lea    mlog,a4
        move.l #mlogn-mlog,d1
        move.w #ascii0+7,d2
        move.w #ascii0+5,d3
        jsr    moveto
        jsr    pdata
        rts

**********************************************************
***      Routines to interpret the event packet and convert 
***      to a human readable format and display it.

gttmp:  movem.l d0/d1/d3/a0,-(a7)     * This routine converts the timestamp
        move.l  time,a0               * to hrs, min, secs and usec.
        move.l  #00,(a0)+
        move.l  #00,(a0)+
        move.l  #00,(a0)
        move.l  time,a0
        move.b  #$2f,d0
dhr:    add.b   #1,d0
        sub.l   hr,d2
        bcc     dhr
        add.l   hr,d2
        move.b  d0,(a0)+
        move.b  #$2f,d0
dtmin:  add.b   #1,d0
        sub.l   tmin,d2
        bcc     dtmin
        add.l   tmin,d2
        move.b  d0,(a0)+
        move.b  #$2f,d0
dmin:   add.b   #1,d0
        sub.l   min,d2
        bcc     dmin
        add.l   min,d2
        move.b  d0,(a0)+
        jsr     decpt
        movem.l (a7)+,d0/d1/d3/a0
        rts

prtms:  movem.l d0/d2/a0,-(a7)       * this routine prints the timestamp
        move.l  time,a0              * the lefthand side column.
        move.b  (a0)+,d0
        jsr     outch
        move.b  #58,d0
        jsr     outch
        move.b  (a0)+,d0
        jsr     outch
        move.b  (a0)+,d0
        jsr     outch
        move.b  #58,d0
        jsr     outch
        move.b  (a0)+,d0
        jsr     outch
        move.b  (a0)+,d0 
        jsr     outch
        move.b  #46,d0
        jsr     outch
        move.b  #05,d2
pts:    move.b  (a0)+,d0
        jsr     outch
        dbra    d2,pts
        movem.l (a7)+,d0/d2/a0
        rts

ptev:   movem.l d1/d2/a4,-(a7)    * Identifies the one of 16 events
        and.b   #$0f,d2           * and print the corresponding message
        cmp.b   #0,d2
        bne     ne0
        lea     ev0,a4
        move.l  #ev0n-ev0,d1
        bra     eeq
ne0:    cmp.b   #1,d2
        bne     ne1
        lea     ev1,a4
        move.l  #ev1n-ev1,d1
        bra     eeq
ne1:    cmp.b   #2,d2
        bne     ne2
        lea     ev2,a4
        move.l  #ev2n-ev2,d1
        bra     eeq
ne2:    cmp.b   #3,d2
        bne     ne3
        lea     ev3,a4
        move.l  #ev3n-ev3,d1
        bra     eeq
ne3:    cmp.b   #4,d2
        bne     ne4
        lea     ev4,a4
        move.l  #ev4n-ev4,d1
        bra     eeq
ne4:    cmp.b   #5,d2
        bne     ne5
        lea     ev5,a4
        move.l  #ev5n-ev5,d1
        bra     eeq
ne5:    cmp.b   #6,d2
        bne     ne6
        lea     ev6,a4
        move.l  #ev6n-ev6,d1
        bra     eeq
ne6:    cmp.b   #7,d2
        bne     ne7
        lea     ev7,a4
        move.l  #ev7n-ev7,d1
        bra     eeq
ne7:    cmp.b   #8,d2
        bne     ne8
        lea     ev8,a4
        move.l  #ev8n-ev8,d1
        bra     eeq
ne8:    cmp.b   #9,d2
        bne     ne9
        lea     ev9,a4
        move.l  #ev9n-ev9,d1
        bra     eeq
ne9:    cmp.b   #10,d2
        bne     ne10
        lea     ev10,a4
        move.l  #ev10n-ev10,d1
        bra     eeq
ne10:   cmp.b   #11,d2
        bne     ne11
        lea     ev11,a4
        move.l  #ev11n-ev11,d1
        bra     eeq
ne11:   cmp.b   #12,d2
        bne     ne12
        lea     ev12,a4
        move.l  #ev12n-ev12,d1
        bra     eeq
ne12:   cmp.b   #13,d2
        bne     ne13
        lea     ev13,a4
        move.l  #ev13n-ev13,d1
        bra     eeq
ne13:   cmp.b   #14,d2
        bne     ne14
        lea     ev14,a4
        move.l  #ev14n-ev14,d1
        bra     eeq
ne14:   lea     ev15,a4
        move.l  #ev15n-ev15,d1
eeq:    jsr     pdata
        movem.l (a7)+,d1/d2/a4
        rts

**
** LOHEX: print LS four bits in D0 as hex digit
**
*lohex:  and.b   #$0f,d0	* clear top 4 bits
*        cmp.b   #10,d0	* greater than 10?
*        bge     lohex1	* yes, continue
*        add.b   #$30,d0	* add char offset
*lohex2: jsr     outch	* output char
*        rts     * return
*lohex1: add.b   #$41-10,d0	* add "A"-10
*        bra     lohex2	* continue
**
** HIHEX: print MS four bits of D0 as hexadecimal digit
**
*hihex: rol.b    #4,d0	* swap nibbles
*       jsr      lohex	* print it
*       rts		* return

*
* CH2HX2: print the two nibble values in D0 as two hex digits
*         at the two cursor positions

ch2hx2:move.l   d0,-(sp)		* save value
       jsr      hihex	* print ms 4 bits
       move.l   (sp)+,d0		* restore value
        move.b  #$34,d2
        move.b  #$32,d3
       jsr      movec
       jsr      lohex	* print ls 4 bits
       rts		* return
*
sdb:    move.l  d0,-(a7)          * Prints out the source and destination 
        move.l  d2,d0             * 4-bit address in hex
        lsr.w   #4,d0
        move.b  #$33,d2
        move.b  #$31,d3
        jsr     movec
        jsr     ch2hx2
        move.l  (a7)+,d0
        rts

dval:   dc.l    1000,100,10,1
ptpn:   movem.l d0/d1/d2/d3,-(a7)      * prints out the process id in decimal.
        move.l  #$03,d1             * max val = 1023
        lea     dval,a1
        move.l  (a1)+,d3
pn1:    move.b  #$2f,d0
pn2:    add.b   #1,d0
        sub.l   d3,d2
        bcc     pn2
        add.l   d3,d2
        jsr     outch
        move.l  (a1)+,d3
        dbra    d1,pn1
        movem.l (a7)+,d0/d1/d2/d3
        rts

ptsp:   movem.l d1/d2,-(a7)         * print the source process id
        move.l  #22,d1
        lsr.l   d1,d2
        and.l   #$03ff,d2
        jsr     ptpn
        movem.l (a7)+,d1/d2
        rts

ptdp:   movem.l d1/d2,-(a7)         * print the destination process id
        move.l  #12,d1
        lsr.l   d1,d2
        and.l   #$03ff,d2
        jsr     ptpn
        movem.l (a7)+,d1/d2
        rts

evlog:  movem.l d2/d3,-(a7)       * logs an event to the screen
        move.b  #$30,d2
        move.b  #$37,d3
        jsr     movec
        move.l  d0,d2             * EVENT PACKETS in D0 and D1.
        jsr     gttmp             * convert timestamp
        jsr     prtms             * print timestamp
        move.b  #$32,d2
        move.b  #$34,d3
        jsr     movec
        move.l  d1,d2
        jsr     ptsp              * print source proc id
        move.b  #$33,d2
        move.b  #$35,d3
        jsr     movec
        move.l  d1,d2
        jsr     ptdp              * print destination proc id
*       move.l  d1,d2
        jsr     sdb
        move.b  #$34,d2
        move.b  #$36,d3
        jsr     movec
        move.l  d1,d2
        jsr     ptev              * print type of event
        movem.l (a7)+,d2/d3
        rts
****************************************************************

chst2:  jsr    akey               * Checks the status register and take
        btst   #0,stats2          * necessary action
        bne    error              * error condition - flag error and hang
        btst   #1,stats2
        bne    chst2              * Halt - cycle until condition cleared
        btst   #2,stats2          * also interupts should be disabled.
        bne    chst2              * screen lock - cycle until condition cleared
*        btst   #3,stats2          * Waiting for event- wait until another event
*        bne    chst2              * arrives.
*        btst   #4,stats2
*        bne    chst2
        rts

fetchv: movem.l d0/d1/a0/a1,-(a7)
        movem.l (a7)+,d0/d1/a0/a1
        rts

lgln:   movem.l d0/d2/d3,-(a7)      * Scrolls inside the graphics window
        jsr    wind1a               * to allow new events to be printed
        move.w #$3137,d2            * of the window.
        move.w #$3031,d3
        jsr    moveto
        move.b #lf,d0
        jsr    outch
        move.b #cr,d0
        jsr    outch
        jsr    grmode
        jsr    ptlgln
        jsr    nmode
        movem.l (a7)+,d0/d2/d3
        rts

ptctpk: movem.l d0/d1/d2/d3/d4,-(a7)
        move.w  d0,d4              * backup MSLong word.
        move.w  #$31,d2            * move to begining of the line
        move.w  #$32,d3            * to print sequence number.
        jsr     movec              *  jump to position.
        lsr.l   #8,d0              * Shift out dest. addr.
        lsr.l   #8,d0              * Shift out source address.
        move.w  d0,d2              * backup again.
        lsr.w   #8,d2
        jsr     ptpn               * Prints value in decimal.
        move.w  #$34,d2
        move.w  #$38,d3
        jsr     movec
        jsr     ch2hex              * Print the control field of the centnt Pk.
        jsr     pspac4
        move.w  d4,d0
        lsr.w   #8,d0               * Print the source addr of the Centrenet Pk.
        jsr     ch2hex
        jsr     pspac4
        move.b  d4,d0               * Print the destination address of the C Pk.
        jsr     ch2hex
        jsr     pspac3
        jsr     ch8hex              * Print the data field held in D1.
        movem.l (a7)+,d0/d1/d2/d3/d4
        rts

anypks: movem.l a0/d0/d1,-(a7)     * Routine will clear carry flag if there are 
        move.l  dbadrw,a0          * valid entries in the database still to be
        move.l  (a0)+,d0           * displayed.
        move.l  (a0),d1
        sub.l   d1,d0
        cmp.l   #08,d0
        bge     yes 
* Test for end of database memory space. Set flag and disable fifo interupt.
*
        or.b    #$01,ccr
        bra     exi
yes:    and.b   #$fe,ccr            * Clear the carry flag
exi:    movem.l (a7)+,a0/d0/d1
        rts


scrn3:  movem.l d0/d1/a0/a1,-(a7)   * If there is an event yet to be displayed
        jsr    chst2                * print it otherwise update status and exit
        move.l  #stats2,a1
        move.b  (a1),d1
        jsr     anypks
        bcc     rdev
        or.b    #$08,stats2
        btst    #3,d1
        bne     nchnge
        jsr     upst
        bra     nchnge
rdev:   and.b   #$f7,stats2
        btst    #3,d1
        beq     nchg
        jsr     upst
nchg:   jsr    lgln             * an event to be printed
        move.l  dbadrr,a0
        move.l  (a0),a1
        move.l  (a1)+,d0        * Move MS word of event packet to D0.
        move.l  (a1)+,d1        * Move LS word of event packet to D1.
        move.l  a1,(a0)
*        move.l  d0,d2
*        and.l   #$ff000000,d2
*        cmp.l   #$ff000000,d2   * Test for Centrenet Packet.
*        bne     lgev
        btst    #5,stats2
        beq     lgev
        jsr     ptctpk
        bra     nchnge
lgev:   jsr    evlog            * display event
nchnge: jsr    akey             * Check to see if a key has been pressed.
        movem.l (a7)+,d0/d1/a0/a1
        rts

inevlg: jsr    evlg1            * set up and display graphics window
        jsr    evlg2            * for event log monitoring.
        jsr    upst
evg:    jsr    clrled
        jsr    scrn3
*       jsr    upst
        jsr    akey
        btst   #7,status        * Check if a change of mode has been
        bne    evg              * indicated by key board support routines
        rts

shdiag: move.b #04,d2           * Change screen format and print out 
        jsr    smthsc           * information on current hardware and 
        jsr    windf2           * software being used.
        jsr    cls
        move.w #$3031,d2
        move.w #$3031,d3
        jsr    moveto
        lea    diagnp,a4
        move.l #diagnn-diagnp,d1
        jsr    pdata
*        move.b #00,d2
*        jsr    smthsc
shdig:  jsr    akey
        btst   #4,status
        bne    shdig
        rts

*********************************************************************

fint1p: dc.b   'Hardware Filtering by'
fint1n: ds.w   0
fint2p: dc.b   'Bounded Centrenet Board Addresses'
fint2n: ds.w   0
fint3p: dc.b   'Source Address Filter                Destination Address Filter'
fint3n: ds.w   0
flbp:   dc.b   'Lower Bound'
flbn:   ds.w   0
fubp:   dc.b   'Upper Bound'
fubn:   ds.w   0
fadp:   dc.b   '  Address'
fadn:   ds.w   0
fconp:  dc.b   ' Condition'
fconn:  ds.w   0
fonp:   dc.b   'ON '
fonn:   ds.w   0
foffp:  dc.b   'OFF'
foffn:  ds.w   0
finp:   dc.b   'IN '
finn:   ds.w   0
foutp:  dc.b   'OUT'
foutn:  ds.w   0
fhelp:  dc.b   'To change options, use two letter codes as described'
        dc.b   ' ( * = HEX digit ).       '
        dc.b   lf,cr
        dc.b   ' (S) to identify Source and (D) to identify Destination.'
        dc.b   ' Then (I) or (L) or (U)'
        dc.b   lf,cr
        dc.b   'to toggle "the Active Filter Range" or Lower or Upper '
        dc.b   'Bounds respectively.     '
        dc.b   lf,cr
        dc.b   ' (L) or (U) followed by ** sets the corresponding Address'
        dc.b   ' Values.  (X) to exit.'
fhelpn: ds.w   0

fpon:   lea    fonp,a4
        move.l #fonn-fonp,d1
        jsr    pdata
        rts

fpoff:  lea    foffp,a4
        move.l #foffn-foffp,d1
        jsr    pdata
        rts

fpin:   lea    finp,a4
        move.l #finn-finp,d1
        jsr    pdata
        rts

fpout:  lea    foutp,a4
        move.l #foutn-foutp,d1
        jsr    pdata
        rts

fplb:   lea    flbp,a4
        move.l #flbn-flbp,d1
        jsr    pdata
        rts

fpub:   lea    fubp,a4
        move.l #fubn-fubp,d1
        jsr    pdata
        rts

fpad:   lea    fadp,a4
        move.l #fadn-fadp,d1
        jsr    pdata
        rts

fpcon:  lea    fconp,a4
        move.l #fconn-fconp,d1
        jsr    pdata
        rts

fintro: move.w #$3033,d2
        move.w #$3238,d3
        jsr    moveto
        move.w #$3038,d2
        jsr    attr
        move.l #fint1n-fint1p,d1
        lea    fint1p,a4
        jsr    pdata
        jsr    clratt
        move.l #fint2n-fint2p,d1
        lea    fint2p,a4
        move.w #$3035,d2
        move.w #$3232,d3
        jsr    moveto
        move.w #$3038,d2
        jsr    attr
        jsr    pdata
        jsr    clratt
        lea    fint3p,a4
        move.l #fint3n-fint3p,d1
        move.w #$3038,d2
        move.w #$3130,d3
        jsr    moveto
        jsr    pdata
        move.w #$3131,d2
        move.w #$3132,d3
        jsr    moveto
        jsr    fplb
        move.w #$3131,d2
        move.w #$3532,d3
        jsr    moveto
        jsr    fplb
        move.w #$3134,d2
        move.w #$3132,d3
        jsr    moveto
        jsr    fpub
        move.w #$3134,d2
        move.w #$3532,d3
        jsr    moveto
        jsr    fpub
        move.w #$3132,d2
        move.w #$3132,d3
        jsr    moveto
        jsr    fpad
        move.w #$3132,d2
        move.w #$3532,d3
        jsr    moveto
        jsr    fpad
        move.w #$3135,d2
        move.w #$3132,d3
        jsr    moveto
        jsr    fpad
        move.w #$3135,d2
        move.w #$3532,d3
        jsr    moveto
        jsr    fpad
        move.w #$3137,d2
        move.w #$3132,d3
        jsr    moveto
        jsr    fpcon
        move.w #$3137,d2
        move.w #$3532,d3
        jsr    moveto
        jsr    fpcon
        rts

fudo:   move.w #$3131,d2
        move.w #$3235,d3
        jsr    moveto
        btst   #3,filctl
        beq    f3f
        jsr    fpon
        bra    f2
f3f:    jsr    fpoff
f2:     move.w #$3134,d2
        move.w #$3235,d3
        jsr    moveto
        btst   #2,filctl
        beq    f2f
        jsr    fpon
        bra    f7
f2f:    jsr    fpoff
f7:     move.w #$3131,d2
        move.w #$3635,d3
        jsr    moveto
        btst   #7,filctl
        beq    f7f
        jsr    fpon
        bra    f6
f7f:    jsr    fpoff
f6:     move.w #$3134,d2
        move.w #$3635,d3
        jsr    moveto
        btst   #6,filctl
        beq    f6f
        jsr    fpon
        bra    f0
f6f:    jsr    fpoff
f0:     move.w #$3137,d2
        move.w #$3235,d3
        jsr    moveto
        btst   #0,filctl
        beq    f0f
        jsr    fpin
        bra    f4
f0f:    jsr    fpout
f4:     move.w #$3635,d3
        move.w #$3137,d2
        jsr    moveto
        btst   #4,filctl
        beq    f4f
        jsr    fpin
        rts
f4f:    jsr    fpout
        rts

fuad:   move.w #$3132,d2
        move.w #$3235,d3
        jsr    moveto
        move.w scbnds,d0
        jsr    ch2hex
        move.w #$3135,d2
        move.w #$3235,d3
        jsr    moveto
        move.w scbnds,d0
        lsr.w  #8,d0
        jsr    ch2hex
        move.w #$3132,d2
        move.w #$3635,d3
        jsr    moveto
        move.w dtbnds,d0
        jsr    ch2hex
        move.w #$3135,d2
        move.w #$3635,d3
        jsr    moveto
        move.w dtbnds,d0
        lsr.w  #8,d0
        jsr    ch2hex
        rts

fqury:  jsr    outch
        jsr    wind2
        move.w #$3230,d2
        move.w #$3031,d3
        jsr    moveto
        lea    fhelp,a4
        move.l #fhelpn-fhelp,d1
        jsr    pdata
        bra    fnwchr

fkeys:  jsr    outch
        move.w #0,d4
        jsr    inchu
        cmp.b  #cr,d0             * If carriage return then toggle both
        bne    fkcr               * lower and Upper bound flags.
        jsr    outch
        addi.b #$c,d4
        lsl.b  d3,d4
        eor.b  d4,filctl
        jsr    fudo
        bra    fnwchr
fkcr:   cmp.b  #$49,d0            * If 'I' then toggle In/out flag.
        bne    fkni
        jsr    outch
        addi.b #1,d4
        lsl.b  d3,d4
        eor.b  d4,filctl
        jsr    fudo
        bra    fnwchr
fkni:   cmp.b  #$4c,d0            * If 'L' check for following hexd digits
        bne    fknl
        jsr    outch
        jsr    sin2hx
        bcs    fkl
        adda.l #1,a0
        move.b d0,(a0)
        jsr    fuad
        bra    fnwchr
fkl:    addi.b #$8,d4
        lsl.b  d3,d4
        eor.b  d4,filctl
        jsr    fudo
        bra    fnwchr
fknl:   cmp.b  #$55,d0            * If 'U' then see if followed by hex digits
        bne    fnwchr
        jsr    outch
        jsr    sin2hx
        bcs    fku                * No hex digits
        move.b d0,(a0)            * Hex digits so update address values
        jsr    fuad
        bra    fnwchr
fku:    addi.b #$4,d4
        lsl.b  d3,d4
        eor.b  d4,filctl
        jsr    fudo
        bra    fnwchr

fkey:   move.b #0,d2
        jsr    smthsc
fnwchr: jsr    lprom
fnchr:  jsr    inchu
        cmp.b  #cr,d0             * If cr then new promt
        bne    fncr
        jsr    outch
        bra    fnwchr
fncr:   cmp.b  #$58,d0            * If X then quit mode by setting H'ware
        beq    fset               * to new values.
        cmp.b  #$3f,d0            * If '?' then print help message
        beq    fqury
        cmp.b  #$53,d0            * If 'S' then fetch source address and 
        bne    fns                * set d3 which is the flag to control
        lea    scbnds,a0          * bit toggling in the control register.
        move.b #0,d3
        bra    fkeys
fns:    cmp.b  #$44,d0            * If 'D' the fetch destination add as above.
        bne    fnd
        lea    dtbnds,a0
        move.b #4,d3
        bra    fkeys
fnd:    jsr    pbell              *Else invalid 
        bra    fnchr
fend:   rts

filtch: jsr    windf2
        jsr    cls
        jsr    fintro
        jsr    fudo
        jsr    fuad
        jsr    fkey
*
* Intro
* Fetch current values
* Allow updates to values
* set new values and exit.
*
        jsr    outch              *output final 'F' char
        jsr    lprom              * shift up promt
        move.b #4,d2
        jsr    smthsc             * diasable smooth scrolling.

ftch:   jsr    akey
        btst   #5,status
        bne    ftch
        rts

*********************************************************************

inlsc2: jsr    linsc1         * setup for event line monitoring
        jsr    linsc2
        jsr    upst
lsc:    jsr    akey
        btst   #6,status
        bne    lsc
        rts

quitt:  jsr    windf2        * Routine to shutdown monitor.
        jsr    cls
        or.w  #$0700,sr      * disable interupts
*       jsr    redrt
        jsr    intscn
        trap   #0
stop:   jmp    stop

error:  move.w #$3033,d2     * Fatal system errors will be flagged
        move.w #$3631,d3     * and currently monitor will hang.
        jsr    moveto
        lea    err,a4
        move.l #errn-err,d1
        jsr    pdata
err1:   jmp    err1

chgst:  jsr    chst2         * Routine to change mode of operation of the
*       btst   #0,status     * monitor.
*       beq    nxtst4
*       move.l stack,a7     ***   Clear the stack
*       bra    start
        btst   #2,status     * quit the monitor
        beq    nxtst
        rts
nxtst:  btst   #4,status
        beq    nxtst1
        jsr    shdiag        * print out system information
nxtst1: btst   #5,status
        beq    nxtst2
        jsr    filtch        * update hardware filter addresses
nxtst2: btst   #6,status
        beq    nxtst3
        jsr    inlsc2        * Event line monitoring.
nxtst3: btst   #7,status
        beq    nwscn
        jsr    inevlg        * Event log monitoring.
nwscn:  move.l #status,a0
        move.b (a0),d0
*        lsr.w  #8,d0
        cmp.b  #00,d0
        bne    chgst
        jsr    windf         * If no mode active draw intro screen
        jsr    cls
        jsr    intscn
        jsr    lprom
nwscn2: jsr    akey
        move.l #status,a0    * wait to move into an active mode.
        move.b (a0),d0
*        lsr.w  #8,d0
        cmp.b  #00,d0
        beq    nwscn2
        bra    chgst

exitmn: or.w   #$0700,sr    * disable all interrupts
        move.b hwcnt,d0
        or.b   #$ff,d0      * switch off both leds,read requests and interupts
        move.b d0,led       * requests to other processor and controllers.
        move.b d0,hwcnt
        rts

        org    $035000

start:  jsr    init         * setup register, database and duart
        jsr    inchu
        jsr    chgst        * Get monitor mode and cycle thro modes until
        jsr    exitmn       * Shut down monitor i.e.
        jsr    grnled       * quit. light green led for okay

        jmp    quitt
*       jmp    stop
*

*
*******************************************************************
**      Interupt vector - for use with running the 68000 software monitor.

        org    $03fe50
        jmp    chinp
        org    $03fe60
        jmp    ffserv
        org    $03fe68
        jmp    acksrv
*
        END
