        section code

        dc.b    'pmc0'
        dc.w    last-first

first   ; if numeric argument >= 0, go to getkey
        ; else go to scroll
        tst.l   d0
        bpl     getkey

scroll
        ; get address of top lefthand corner of
        ; Xchange window !
        movea.l -4(a5),a0

        ; get distance from one line to the next
        moveq   #0,d0
        move.w  -6(a5),d0
        add.l   d0,d0

        ; move top line+1 to buffer
        move.w  #124,d1
        adda.l  d0,a0
        lea     buffer,a1
        bra.s   l2
l1      move.b  2(a0,d1.w),0(a1,d1.w)
l2      dbf     d1,l1

        ; move the other 254 lines one line up,
        ; scrolling the display
        move.w  #253,d3
l3      lea     0(a0,d0.w),a1
        move.w  #124,d2
        bra.s   l5
l4      move.b  2(a1,d2.w),2(a0,d2.w)
l5      dbf     d2,l4
        movea.l a1,a0
l6      dbf     d3,l3

        ; move the previous top line from buffer
        ; to the bottom of the screen
        move.w  #124,d1
        lea     buffer,a1
        bra.s   l8
l7      move.b  0(a1,d1.w),2(a0,d1.w)
l8      dbf     d1,l7

        ; return to Archive
        rts

buffer  ds.b    124

getkey  ; use argument as timeout
        move.w  d0,d3

        ; fetch channel id of main Xchange window
        movea.l $1392(a5),a0

        ; now get a key
        moveq   #1,d0
        trap    #3

        ; and return error code ...
        tst.l   d0
        bne     error

        ; ... or keypress
        move.b  d1,d0

error   rts

last
        end
