home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / A / BIOS-R62.LZH / CXEM.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  8KB  |  502 lines

  1.     title    'Terminal Emulation (ADM-31 with K-Pro support)   26 April 87'
  2.  
  3.  
  4.     maclib    z80
  5.  
  6.     maclib    cxequ
  7.  
  8. lines    equ    24
  9.  
  10.     public    ?out80,ADM31
  11.  
  12. ;  Changes to this module were to remove all 40 column code.  Original
  13. ;  Copyright is still maintained by Commodore
  14. ;
  15. ;
  16. ;
  17. ;
  18. ;
  19. ;
  20. ;
  21. ;    ADM3A
  22. ;
  23. ;
  24. ;    ESC = row col        cursor position
  25. ;    ESC ESC ESC color    set color        ; added for C128 CP/M
  26. ;    ^H            cursor left
  27. ;    ^L            cursor right
  28. ;    ^J            cursor down
  29. ;    ^K            cursor up
  30. ;    ^Z            home and clear screen
  31. ;    ^M            carrage return
  32. ;    ^G            bell
  33.  
  34. ;
  35. ;    ADM31
  36. ;
  37. ;
  38. ;    ESC = row col    cursor position
  39. ;    ESC ESC ESC color    set color        ; added for C128 CP/M
  40. ;    ESC T        clear to end of line
  41. ;    ESC t        clear to end of line
  42. ;    ESC Y        clear to end of screen
  43. ;    ESC y        clear to end of screen
  44. ;    ESC :        home & clear screen
  45. ;    ESC *        home & clear screen
  46. ;    ESC )        Half intensity on
  47. ;    ESC (        Half intensity off
  48. ;    ESC G 4        Reverse video on
  49. ;    ESC G 2        Blinking on
  50. ;    ESC G 0        Rev. video and blinking off
  51. ;    ESC E        Insert line
  52. ;    ESC Q        Insert Character
  53. ;    ESC R        Delete Line
  54. ;    ESC W        Delete Character
  55. ;    ^H        cursor left
  56. ;    ^L        cursor right
  57. ;    ^J        cursor down
  58. ;    ^K        cursor up
  59. ;    ^Z        home and clear screen
  60. ;    ^M        carriage return
  61. ;    ^G        bell
  62. ;
  63.     page
  64. ;
  65. ;    KPRO II Terminal control sequences (not supported yet)
  66. ;
  67. ;
  68. ; Cursor Control
  69. ;
  70. ;    ^H    cursor left (bs)
  71. ;    ^L    cursor right
  72. ;    ^J    cursor down
  73. ;    ^K    cursor up
  74. ;    ^^    home cursor
  75. ;    ^Z    home cursor & clear screen
  76. ;    ^M    carriage return
  77. ;
  78. ; Cursor Positioning
  79. ;
  80. ;    ESC = R C    (R & C =' '+position)
  81. ;
  82. ; Line Insert/Delete
  83. ;
  84. ;    ESC E    Line Insert
  85. ;    ESC R    Line Delete
  86. ;
  87. ; Clear to End of Screen/Line
  88. ;
  89. ;    ^X    Clear to End of Line
  90. ;    ^W    Clear to End of Screen
  91. ;
  92. ; Set Greek or ASCII (not supported)
  93. ;
  94. ;    ESC A    Set ASCII
  95. ;    ESC G    Set Greek    (lower case letters print as Greek Alphabet)
  96. ;
  97.     page
  98.  
  99.     dseg
  100. ;
  101. ;
  102. ;
  103. ;
  104. ;
  105. ;
  106. ?out$80:
  107.     xra    a            ; 80 column offset is 0
  108.     lxi    h,parm$area$80
  109. out$cont:
  110.     sta    fun$offset
  111.     mvi    a,7fh
  112.     ana    c
  113.     mov    c,a
  114.     shld    parm$base
  115.     lhld    emulation$adr
  116.     pchl
  117.  
  118.     page
  119. ;
  120. ;    ADM-31 terminal emulation
  121. ;
  122. ADM31:
  123.     lhld    parm$base        ; 1st parm is exec adr (2 bytes)
  124.     mov    a,m
  125.     inx    h
  126.     mov    h,m
  127.     mov    l,a
  128.  
  129.     ora    h            ; L is in A already, test HL=0
  130.     mov    a,c            ; C is char to output
  131.     jrz    start$checking 
  132.     pchl
  133.  
  134. ;
  135. ;
  136. ;
  137. start$checking:
  138.     lxi    h,control$table
  139.     lxi    b,cnt$tbl$lng
  140.     ccir
  141.     lxi    h,control$exec$adr
  142.     jrz    find$exec$adr
  143.  
  144.     cpi    20h
  145.     rc
  146.  
  147. do$direct:
  148.     mov    d,a
  149.     TJMP    FR$wr$char
  150.  
  151.     page
  152. ;
  153. ;
  154. ;
  155. char$esc:                ; ESC
  156.     call    cont$later
  157. ;
  158. ;    ESC char    look for char in the ESC table
  159. ;
  160.     call    remove$exec$adr
  161.     lxi    h,esc$table
  162.     lxi    b,esc$tbl$lng
  163.     ccir
  164.     rnz                ; bad esc sequence
  165.     lxi    h,esc$exec$adr
  166.  
  167. find$exec$adr:
  168.     dad    b
  169.     dad    b
  170.     mov    a,m
  171.     inx    h
  172.     mov    h,m
  173.     mov    l,a
  174.     pchl
  175.  
  176.  
  177.  
  178.     page
  179. ;
  180. ;
  181. ;
  182. cont$later:
  183.     pop    h        ; get address to cont at in H
  184.     jr    save$exec$adr    ; save it
  185. ;
  186. ;
  187. ;
  188. remove$exec$adr:
  189.     lxi    h,0
  190. save$exec$adr:
  191.     xchg
  192.     lhld    parm$base
  193.     mov    m,e
  194.     inx    h
  195.     mov    m,d
  196.     ret
  197.  
  198.  
  199. ;
  200. ;
  201. ;
  202. esc$esc:
  203.     call    cont$later
  204. ;
  205. ;    check for ESC ESC ESC
  206. ;
  207.     cpi    esc            ; check if 3rd char is an ESC
  208.     jrnz    remove$exec$adr
  209.     call    cont$later
  210. ;
  211. ;    set current character as the attr
  212. ;
  213.     mov    b,a
  214.     TCALL    FR$color
  215.     jr    remove$exec$adr
  216.  
  217.     page
  218. ;
  219. ;
  220. ;
  221. esc$equ:
  222.     call    cont$later
  223. ;
  224. ;    ESC = R
  225. ;
  226.     lhld    parm$base
  227.     inx    h
  228.     inx    h
  229.     sui    ' '            ; remove ascii bias
  230.     mov    m,a
  231.     cpi    '8'-' '            ; test for line 25 (A=24?)
  232.     jrnz    not$status$line        ; no, jmp
  233.     inr    a            ; yes, A=25
  234.     sta    paint$size        ; set 40 column repaint to 25 lines
  235. not$status$line:
  236.     call    cont$later
  237. ;
  238. ;    ESC = R C    (go do it)
  239. ;
  240.     sui    ' '
  241.     mov    e,a            ; column # to E
  242.  
  243.     lhld    parm$base
  244.     inx    h
  245.     inx    h
  246.     mov    d,m            ; row # to D
  247.     TCALL    FR$cursor$pos
  248.     jr    remove$exec$adr
  249.  
  250.     page
  251. ;
  252. ;
  253. ;
  254. char$cnt$z:                ; ^Z    home and clear screen
  255.     lxi    d,lines*256+0        ; B=24(row) C=0(col)
  256.     TCALL    FR$cursor$pos
  257.     call    esc$t            ; clear the status line 
  258.     lxi    d,0
  259.     TCALL    FR$cursor$pos
  260. esc$y:
  261.     TJMP    FR$CES            ; clear to end of screen 
  262.  
  263. home$cursor:
  264.     lxi    d,0
  265.     TJMP    FR$cursor$pos
  266.     
  267. esc$t:
  268.     TJMP    FR$CEL            ; clear to end of line 
  269.  
  270. ;
  271. ;
  272. ;
  273. do$cr:
  274.     TJMP    FR$do$cr
  275.  
  276. ;
  277. ;
  278. ;
  279. cursor$rt:
  280.     TJMP    FR$cursor$rt
  281.  
  282. ;
  283. ;
  284. ;
  285. cursor$up:
  286.     TJMP    FR$cursor$up
  287.  
  288. ;
  289. ;
  290. ;
  291. cursor$down:
  292.     TJMP    FR$cursor$down
  293.  
  294. ;
  295. ;
  296. ;
  297. cursor$left:
  298.     TJMP    FR$cursor$left
  299.  
  300.     page
  301.  
  302. ;
  303. ;    placed in common so that link and gencpm will not
  304. ;    cause this code to show up at address 0D000h to 0DFFFh
  305. ;
  306. char$cnt$g:                ; ^G    bell
  307.     RJMP    FR$bell
  308.  
  309. ;
  310. ;    delete character
  311. ;
  312. esc$W:
  313.     TJMP    FR$char$del
  314.  
  315. ;
  316. ;    delete line
  317. ;
  318. esc$R:
  319.     TJMP    FR$line$del
  320.  
  321. ;
  322. ;    insert character
  323. ;
  324. esc$Q:
  325.     TJMP    FR$char$ins
  326.  
  327. ;
  328. ;    insert line
  329. ;
  330. esc$E:
  331.     TJMP    FR$line$ins
  332.  
  333.     page
  334. ;
  335. ;    Half Intensity Off
  336. ;
  337. esc$lfp:
  338.     mvi    c,00000001b        ; turn intensity up
  339.     jr    set$FR$atr$c
  340. ;
  341. ;    Half Intensity On
  342. ;
  343. esc$rtp:
  344.     mvi    c,00000000b        ; turn intensity down
  345. parn$cont:
  346.     mvi    b,00000001b        ; attribute bit to change
  347.     jr    set$FR$attr
  348.  
  349. ;
  350. ;    Set Attribute sequence
  351. ;
  352. esc$G:
  353.     call    cont$later
  354. ;
  355. ;    ESC G char
  356. ;
  357.     call    remove$exec$adr
  358.     sui    '4'            ; '4' reverse video on
  359.     jrz    esc$G$4
  360.     inr    a            ; '3' underline attr on
  361.     jrz    esc$G$3
  362.     inr    a            ; '2' blink attr on
  363.     jrz    esc$G$2
  364.     inr    a            ; '1' alt char set
  365.     jrz    esc$G$1
  366.     inr    a            ; '0' clear attributes
  367.     rnz
  368. ;
  369. ;    Rev. Video, blink, atl char set, and underline  off
  370. ;
  371. esc$G$0:
  372.     mvi    c,10000000b        ; turn attributes off
  373.     mvi    b,11110000b        ; attribute bit to change
  374.     jr    set$FR$attr
  375.  
  376. ;
  377. ;    Select alt character set
  378. ;
  379. esc$G$1:
  380.     mvi    c,00000000b        ; select alt character set
  381.     mvi    b,10000000b
  382.     jr    set$FR$attr
  383.  
  384. ;
  385. ;    Blinking On
  386. ;
  387. esc$G$2:    
  388.     mvi    c,00010000b        ; turn on blink attr
  389.     jr    set$FR$atr$c
  390.  
  391. ;
  392. ;    Under line
  393. ;
  394. esc$G$3:
  395.     mvi    c,00100000b        ; turn on underline bit
  396.     jr    set$FR$atr$c
  397.  
  398. ;
  399. ;    Reverse Video On
  400. ;
  401. esc$G$4:
  402.     mvi    c,01000000b        ; turn attributes on
  403.  
  404. set$FR$atr$c:
  405.     mov    b,c            ; reverse attr
  406. set$FR$attr:
  407.     TJMP    FR$attr
  408.  
  409.     page
  410. ;
  411. ;    table scanned top to bottom
  412. ;
  413. control$table:
  414.     db    07h    ; ^G        bell
  415.     db    bs    ; ^H        cursor left
  416.     db    lf    ; ^J        cursor down
  417.     db    0Bh    ; ^K        cursor up
  418.     db    0Ch    ; ^L        cursor right
  419.     db    cr    ; ^M        carrage return
  420.     db    1Ah    ; ^Z        home and clear screen
  421.     db    esc    ; ESC
  422.     db    18h    ; ^X        Clear to End of Line (K-Pro)
  423.     db    17h    ; ^W        Clear to End of Screen (K-Pro)
  424.     db    1Eh    ; ^^        home cursor (K-Pro)
  425.  
  426. cnt$tbl$lng    equ    $-control$table
  427.  
  428. ;
  429. ;    table scanned bottom to top
  430. ;
  431. control$exec$adr:
  432.     dw    home$cursor    ; ^^    home cursor    (K-Pro)
  433.     dw    esc$y        ; ^W    CES        (K-Pro)
  434.     dw    esc$t        ; ^X    CEL        (K-Pro)
  435.     dw    char$esc    ; ESC
  436.     dw    char$cnt$z    ; ^Z    home and clear screen
  437.     dw    do$cr        ; ^M    carriage return
  438.     dw    cursor$rt    ; ^L    cursor right
  439.     dw    cursor$up    ; ^K    cursor up
  440.     dw    cursor$down    ; ^J    cursor down
  441.     dw    cursor$left    ; ^H    cursor left
  442.     dw    char$cnt$g    ; ^G    bell
  443.  
  444.  
  445.     page
  446. ;
  447. ;    table scanned top to bottom
  448. ;
  449. esc$table:
  450.     db    '='        ; ESC = R C    
  451.  
  452.     db    'T'        ; ESC T      clear to end of line
  453.     db    't'        ; ESC t   clear to end of line
  454.     db    'Y'        ; ESC Y   clear to end of screen
  455.     db    'y'        ; ESC y   clear to end of screen
  456.     db    ':'        ; ESC :   home & clear screen
  457.     db    '*'        ; ESC *   home & clear screen
  458.  
  459.     db    'E'        ; ESC E   Insert line
  460.     db    'Q'        ; ESC Q   Insert Character
  461.     db    'R'        ; ESC R   Delete Line
  462.     db    'W'        ; ESC W   Delete Character
  463.  
  464.     db    ')'        ; ESC )   Half intensity on
  465.     db    '('        ; ESC (   Half intensity off
  466.     db    'G'        ; ESC G 4 Reverse video on
  467.                 ; ESC G 2 Blinking on
  468.                 ; ESC G 0 Rev. video and blinking off
  469.  
  470.     db    esc        ; ESC ESC
  471.  
  472. esc$tbl$lng    equ    $-esc$table
  473.  
  474.  
  475. ;
  476. ;    table scanned bottom to top
  477. ;
  478. esc$exec$adr:
  479.     dw    esc$esc        ; ESC ESC ESC color
  480.  
  481.     dw    esc$G        ; ESC G 4 Reverse video on
  482.                 ; ESC G 2 Blinking on
  483.                 ; ESC G 0 Rev. video and blinking off
  484.     dw    esc$lfp        ; ESC (   Half intensity off
  485.     dw    esc$rtp        ; ESC )   Half intensity on
  486.  
  487.     dw    esc$W        ; ESC W   Delete Character
  488.     dw    esc$R        ; ESC R   Delete Line
  489.     dw    esc$Q        ; ESC Q   Insert Character
  490.     dw    esc$E        ; ESC E   Insert line
  491.  
  492.     dw    char$cnt$z    ; ESC *   home & clear screen
  493.     dw    char$cnt$z    ; ESC :   home & clear screen
  494.     dw    esc$y        ; ESC y   clear to end of screen
  495.     dw    esc$y        ; ESC Y   clear to end of screen
  496.     dw    esc$t        ; ESC t   clear to end of line
  497.     dw    esc$t        ; ESC T      clear to end of line
  498.  
  499.     dw    esc$equ        ; ESC = RC
  500.  
  501.  of screen
  502.     dw    esc$t        ; ESC t   clear