home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / asmlib.lbr / SCREEN.AZM / SCREEN.ASM
Encoding:
Assembly Source File  |  1991-06-25  |  6.0 KB  |  219 lines

  1. ;----------------------------------------------------------------
  2. ;         This is a module in the ASMLIB library.
  3. ;This module contains....
  4. ; 1) BELL    Rings the console bell
  5. ; 2) CLEAR    Clear the screen
  6. ; 3) CRLF    Send a crlf pair to the screen
  7. ; 4) CURSOR    Position the cursor to D = X, E = Y
  8. ; 5) SETXY       Position cursor. DE -> to 2 bytes, X and Y.
  9. ; 6) CLEOL    Clear to end of line. Leave cursor alone.
  10. ; 7) CLEOP    Clear to end of page. Leave cursor alone.
  11. ;
  12. ; Note that all functions are table driven except for bell and crlf.
  13. ; The table has an ID string of 00 1a 1a 02 which is patched by
  14. ; application programs for different terminals.
  15. ;
  16. ;            Written         R.C.H.     16/8/83
  17. ;            Last Update    R.C.H.       30/11/83
  18. ;----------------------------------------------------------------
  19. ;
  20.     name    'screen'
  21. ;
  22.     public    bell,clear,crlf,cursor,setxy,cleop,cleol
  23.     public    curon,curoff
  24.     extrn    dispatch
  25.     maclib    z80
  26. ;
  27. ;----------------------------------------------------------------
  28. ;         Ring the console bell.
  29. ;----------------------------------------------------------------
  30. ;
  31. bell:
  32.     push    psw
  33.     mvi    a,07
  34. bell2:
  35.     call    dispatch        ; to console
  36.     pop    psw
  37.     ret
  38. ;
  39. ;----------------------------------------------------------------
  40. ;             Send a CR LF pair to the screen
  41. ;----------------------------------------------------------------
  42. ;
  43. crlf:
  44.     push    psw
  45.     mvi    a,0dh
  46.     call    dispatch
  47.     mvi    a,0ah
  48.     jr    bell2
  49. ;
  50. ;----------------------------------------------------------------
  51. ;             Clear the screen
  52. ;----------------------------------------------------------------
  53. ;
  54. clear:
  55.     push    b
  56.     push    h            ; save
  57.     push    psw
  58.     lxi    h,cpfn            ; clear page function
  59.     jr    do$fn            ; send the function and return
  60. ;
  61. ;----------------------------------------------------------------
  62. ; Clear the screen till the end of the line. This is highly
  63. ; terminal dependant and is table driven to suit.
  64. ;----------------------------------------------------------------
  65. ;
  66. cleol:
  67.     push    b
  68.     push    h            ; save
  69.     push    psw
  70.     lxi    h,clfn            ; clear page function
  71.     jr    do$fn            ; send the function and return
  72. ;
  73. ;----------------------------------------------------------------
  74. ; Clear to the end of the page. Same comments as the above fn.
  75. ;----------------------------------------------------------------
  76. ;
  77. cleop:
  78.     push    b
  79.     push    h            ; save
  80.     push    psw
  81.     lxi    h,epfn            ; clear page function
  82.     jr    do$fn            ; end of job
  83. ;
  84. ;
  85. ; This routine uses HL to send the fnction to the
  86. ; screen.
  87. ;
  88. send$fn:
  89.     mov    a,m            ; test if this is not supported
  90.     ora    a
  91.     rz                ; not supported if no bytes to send
  92.     mov    b,a            ; load a counter
  93. send$fn2:
  94.     inx    h            ; get next byte
  95.     mov    a,m
  96.     call    dispatch
  97.     djnz    send$fn2
  98.     ret
  99. ;
  100. ; Send the function pointed to by HL to the terminal then exit
  101. ;
  102. do$fn
  103.     call    send$fn            ; send it.
  104. ; Fall through to the exit routine
  105. end$fn:
  106.     pop    psw
  107.     pop    h
  108.     pop    b
  109.     ret
  110. ;
  111. ;----------------------------------------------------------------
  112. ; Enable the cursor.
  113. ;----------------------------------------------------------------
  114. ;
  115. curon:
  116.     push    b
  117.     push    h
  118.     push    psw
  119.     lxi    h,ecfn        ; enable cursor function
  120.     jr    do$fn
  121. ;
  122. ;----------------------------------------------------------------
  123. ; Disable the cursor
  124. ;----------------------------------------------------------------
  125. ;
  126. curoff:
  127.     push    b
  128.     push    h
  129.     push    psw
  130.     lxi    h,dcfn
  131.     jr    do$fn
  132. ;
  133. ;----------------------------------------------------------------
  134. ; Position the cursor to the value in DE. D = X, E = Y.
  135. ; This is a highly painful routine which must use a table to send the
  136. ; correct codes to suit the terminal in use. This naturally must
  137. ; do the correct lead ins, correct offset, correct row/column sequence
  138. ; so there is a bit of code. Sorry.
  139. ;----------------------------------------------------------------
  140. ;
  141. cursor:
  142.     push    b
  143.     push    h
  144.     push    psw            ; save registers
  145.     push    d            ; save the original
  146. ; Send the lead in string
  147.     lxi    h,xyfn            ; XY addressing lead in string
  148.     call    send$fn
  149. ; Now we must add the offsets to be applied to the X and Y values
  150.     lda    xoff
  151.     add    e            ; Y value
  152.     mov    e,a            ; save it
  153. ;
  154.     lda    yoff
  155.     add    d            ; X value
  156.     mov    d,a            ; save it also
  157. ; Now decode the row or column sent first decision
  158.     lda    rowcol            ; 00 = row first
  159.     ora    a
  160.     jrz    row$first
  161. ; Here and we are sending the column first (X value first)
  162.     mov    a,d            ; X value
  163.     call    dispatch
  164.     mov    a,e            ; Y next
  165.     jr    row$first2
  166. ; Here and we send the row first for cursor addressing
  167. row$first:
  168.     mov    a,e            ; Y value
  169.     call    dispatch
  170.     mov    a,d            ; X value next
  171. row$first2:
  172.     call    dispatch
  173.     pop    d            ; restore original cursor address
  174.     jr    end$fn            ; restore registers and return
  175. ;
  176. ;----------------------------------------------------------------
  177. ; Set the cursor up according to two bytes in ram which contain
  178. ; the X and Y addresses in them. The bytes --> by DE.
  179. ;----------------------------------------------------------------
  180. ;
  181. setxy:
  182.     push    d            ; save 
  183.     push    h
  184.     xchg                ; HL --> bytes
  185.     mov    d,m            ; load X value
  186.     inx    h
  187.     mov    e,m
  188.     call    cursor            ; Set it up
  189.     pop    h            ; restore all now
  190.     pop    d
  191.     ret
  192. ;
  193. ;****************************************************************
  194. ; This is the function table which is used for all hardware
  195. ; dependant code. This table is patched by application programs
  196. ; which find the 00 1a 1a 02 and patch it for different terminals
  197. ; Each entry is 5 bytes long. Cursor addressing takes two entries
  198. ;****************************************************************
  199. ;
  200. id:
  201.     db    0ffh,01ah,0ffh,01ah,02    ; 5 byte i.d. code
  202. ;
  203. xyfn:    db    02,01bh,'=',00,00    ; xy addressing
  204. ; The next 5 bytes are the cursor flags and offsets
  205. rowcol:    db    00            ; 00 means row first
  206. xoff:    db    32            ; X offset
  207. yoff:    db    32            ; Y offset
  208. filler    db    00,00            ; to make the 5
  209. ;
  210. cpfn    db    02,01bh,'*',00,00    ; erase whole page
  211. clfn    db    02,01bh,'T',00,00    ; erase to end of line
  212. epfn    db    02,01bh,'Y',00,00    ; erase to end of page
  213. ecfn    db    00,00,00,00,00        ; enable cursor function
  214. dcfn    db    00,00,00,00,00        ; disable cursor function
  215. ;
  216.     end
  217.  
  218.  
  219.