        incl   subr.asm
*
led     equ    #$70000
off     equ    #$000f
green   equ    #$000e
rdreq   equ    #$000d
dbadr   equ    #$020000
dbase   equ    #$020004
esc     equ    #$1b
lbk     equ    #$5b
ascii0  equ    $30

*
*


ffserv: movem.l d0/a0/a1,-(a7)
        move.l led,a0
        move.w off,(a0)
        move.l fifo,a1
        move.w (a1),d0
        move.l dbadr,a1
        move.l (a1),a0
        move.w d0,(a0)+
        move.l a0,(a1)
        move.l led,a0
        move.w rdreq,(a0)
        movem.l (a7)+,d0/a0/a1
        rte

clrled: move.l led,a2
        move.w off,(a2)
        rts
*
grnled: move.l led,a2
        move.w green,(a2)
        rts

pbell:  move.l d0,-(a7)
        move.b #bell,d0
        jsr    outch
        move.l (a7)+,d0
        rts

moveto: move.l d0,-(a7)
        move.b esc,d0
        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 #72,d0       *  H
        jsr    outch
        move.l (a7)+,d0
        rts

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

cls:    move.l d0,-(a7)
        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

*pdata:  move.l d0,-(a7)
*        bra    pdatst
*pdatlp: move.b (a4)+,d0
*        jsr    outch
*pdatst: dbra   d1,pdatlp
*        move.l (a7)+,d0
*        rts

attr:   move.l  d0,-(a7)
        move.b  esc,d0
        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  #112,d0
        jsr     outch
        move.l  (a7)+,d0
        rts

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


intro1: dc.b   'The POSIE Distributed System'
intro1n:ds.w   0
intro2: dc.b   'Event  Monitor'
intro2n:ds.w   0
intro3: dc.b   'Version  1.0'
intro3n:ds.w   0
intro4: dc.b   'April 1989'
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

intscn: 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 #$3332,d3           *  32
        jsr    moveto
        move.w #$3130,d2
        jsr    attr
        jsr    pdata
        jsr    clratt
        lea    intro3,a4
        move.l #intro3n-intro3,d1
        move.w #$3130,d2
        move.w #$3334,d3
        jsr    moveto
        jsr    pdata
        lea    intro4,a4
        move.l #intro4n-intro4,d1
        move.w #$3131,d2
        move.w #$3335,d3
        jsr    moveto
        jsr    pdata
        lea    intro5,a4
        move.l #intro5n-intro5,d1
        move.w #$3138,d2
        move.w #$3235,d3
        jsr    moveto
        jsr    pdata
        lea    intro6,a4
        move.l #intro6n-intro6,d1
        move.w #$3230,d2
        move.w #$3238,d3
        jsr    moveto
        jsr    pdata
        jsr    home 
        jsr    pbell
        rts

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

grmode: move.l d0,-(a7)
        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)
        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)
        move.b esc,d0
        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

ptxtln: movem.l d0/d2/d3,-(a7)
        move.b #$30,d2
        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
        move.l #mtxtn-mtxt,d1
        move.w #$3035,d2
        move.w #$3036,d3
        jsr    moveto
        jsr    nmode
        jsr    pdata
        jsr    grmode
        jsr    ptxtln
        rts


linsc1: jsr    cls
        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
        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)
        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
        bra    tent
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

wind:   move.l d0,-(a7)
        move.b esc,d0
        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

window: movem.l d2/d3,-(a7)
*        move.w  #$3037,d2
*        move.w  #$3137,d3
*        jsr     wind
*        move.w  #$3139,d2
*        move.w  #$3232,d3
*        jsr     wind
*        move.w  #$3233,d2
*        move.w  #$3234,d3
*        jsr     wind
        movem.l (a7)+,d2/d3
        rts

inlsc2: jsr    window
        jsr    linsc1
        jsr    linsc2
        rts

init:   jsr    clrled
        move.l dbadr,a0
        move.l dbase,(a0)
*       jsr    duart
*       and.w  #$f9ff,sr     * enable interupts
*       or.w  #$0700,sr      * disable interupts
        rts


        org    $034000

start:  jsr     init 
        jsr     intscn
        jsr     inchu
        jsr     inlsc2
        jsr     grnled
stop    bra     stop
*
*
        org    $03fe40
        jmp    ffserv
*
        END
