home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / beehive / program / jmon.arc / JVDU.Z80 < prev   
Encoding:
Text File  |  1990-07-22  |  3.0 KB  |  196 lines

  1. ;
  2. ;VDU section for JMON
  3. ;label wr$a
  4. ;displays char [A] on VDU, preserves all other registers
  5. ;
  6. ;MicroBee memory mapped VDU version, with hardware scroll
  7. ;This version uses the vswpc
  8. ;
  9. ;Default video attributes
  10. vd$lin    equ    80        ;No of chars per line
  11. vd$pag    equ    80*24        ;No of chars per page
  12. ;
  13. ;
  14. ;Start
  15. ;Snk=0 Normal
  16. ; non ctrl
  17. ; ctrl
  18. ;   cr,lf,bs,bel,cls,del,nul
  19. ;
  20. wr$a:    push    bc
  21.     push    de
  22.     push    hl
  23.     push    af
  24.     ld    c,a        ;C=char
  25. v$pos    equ    $+1
  26.     ld    a,00h
  27.     ld    b,a        ;B=column
  28. v$csr    equ    $+1
  29.     ld    hl,0F000h    ;HL=cursor address
  30. ;Expand control codes
  31. v0snk:    ld    a,c
  32.     cp    20h
  33.     jr    c,vctrl
  34. ;Put char to screen
  35. vput:    ld    (hl),a
  36. ;Move cursor pointer, column pointer, and test if line wrap needed
  37.     inc    hl
  38.     inc    b
  39. ;Set cursor, column pointer to HL,B
  40. vsccp:    res    3,h
  41.     ld    (v$csr+poff),hl
  42.     ld    a,vd$lin
  43.     neg
  44.     add    a,b
  45.     jr    c,vlwp
  46.     ld    a,b
  47. vlwp:    ld    (v$pos+poff),a
  48. ;Test if scroll needed, skip if no scroll wanted
  49.     ld    hl,(v$csr+poff)
  50. v$tlc    equ    $+1
  51.     ld    de,0F000h
  52.     or    a
  53.     set    3,h
  54.     sbc    hl,de
  55.     ld    de,vd$pag
  56.     res    3,h
  57.     or    a
  58.     sbc    hl,de
  59.     jr    c,vscsr
  60. ;Fill bottom line with non-masked blanks
  61.     ld    de,(v$tlc+poff)
  62.     ld    hl,vd$pag
  63.     add    hl,de
  64.     ld    a,vd$lin
  65.     ld    b,a
  66. vfbl1:    res    3,h
  67.     ld    (hl),' '
  68.     inc    hl
  69.     djnz    vfbl1
  70. ;Move screen display pointers by line length
  71.     ld    hl,vd$lin
  72.     ld    h,b
  73.     add    hl,de
  74. ;Set display start to current top left corner location
  75. vstlc:    res    3,h
  76.     ld    (v$tlc+poff),hl
  77.     ld    a,0Ch
  78.     call    poff+vscrtc
  79. ;Set cursor to current cursor location, with overscan check
  80. vscsr:    ld    hl,(v$csr+poff)
  81.     ld    de,(v$tlc+poff)
  82.     or    a
  83.     push    hl
  84.     sbc    hl,de
  85.     pop    hl
  86.     jr    nc,vnovsc
  87.     set    3,h
  88. vnovsc:    ld    a,0Eh
  89.     call    poff+vscrtc
  90. ;
  91. vxt0:    pop    af
  92.     pop    hl
  93.     pop    de
  94.     pop    bc
  95.     ret
  96. ;
  97. ;Expand control codes from a table
  98. vctrl:    ld    de,poff+vcttbl
  99.     call    poff+vswpc
  100.     jr    vsccp
  101. ;Default 0 snk
  102. vnul:    pop    hl
  103.     jr    vxt0
  104.  
  105. ;Bell
  106. vbel:    ld    c,50
  107. vbel0:    in    a,(0Ch)
  108.     and    c
  109.     jr    nz,vbel0
  110.     in    a,(02h)
  111. vbel1:    xor    40h
  112.     out    (02h),a
  113.     ld    b,82
  114. vbel2:    djnz    vbel2
  115.     dec    c
  116.     jr    nz,vbel1
  117.     jr    vnul
  118. ;Carriage return
  119. vcr:    inc    hl
  120.     inc    b
  121.     set    3,h
  122. vcr1:    dec    hl
  123.     djnz    vcr1
  124.     res    3,h
  125.     ret
  126. ;Line feed
  127. vlf:    ld    de,vd$lin
  128.     ld    d,0
  129.     add    hl,de
  130.     ret
  131. ;Backspace
  132. vbs:    inc    b
  133.     djnz    vbs1
  134.     ex    de,hl
  135.     ld    hl,(v$tlc+poff)
  136.     or    a
  137.     sbc    hl,de
  138.     ex    de,hl
  139.     jr    z,vnul
  140.     ld    a,vd$lin
  141.     ld    b,a
  142. vbs1:    dec    b
  143.     set    3,h
  144.     dec    hl
  145.     ret
  146. ;Clear Screen and Home
  147. vcls:    ld    hl,vd$pag
  148.     dec    hl
  149.     ld    b,h
  150.     ld    c,l
  151.     ld    de,0F000h
  152.     add    hl,de
  153.     ld    d,h
  154.     ld    e,l
  155.     dec    de
  156.     ld    (hl),' '
  157.     lddr
  158.     ld    (v$csr+poff),hl
  159.     ld    a,b
  160.     ld    (v$pos+poff),a
  161.     pop    de
  162.     jp    vstlc+poff
  163. ;
  164. ;Set CRTC registers [A,A+1] with [L,H]
  165. vscrtc:    ld    c,0Dh
  166.     out    (0Ch),a
  167.     res    4,h
  168.     out    (c),h
  169.     inc    a
  170.     out    (0Ch),a
  171.     out    (c),l
  172.     ret
  173. ;
  174. ;Get HL=tlc+pag
  175. vhlbnl:    ld    hl,vd$pag
  176.     ld    bc,(v$tlc+poff)
  177.     add    hl,bc
  178.     res    3,h
  179.     ret
  180. ;
  181. ;Control code table
  182. ;
  183. vcttbl:    db    0Dh
  184.     dw    poff+vcr
  185.     db    0Ah
  186.     dw    poff+vlf
  187.     db    08h
  188.     dw    poff+vbs
  189.     db    09h
  190.     dw    poff+vbel
  191.     db    1Ah
  192.     dw    poff+vcls
  193.     db    80h
  194.     dw    poff+vnul
  195. ;end of include file
  196.