home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / msvp98b1.lzh / MSYP98.ASM < prev    next >
Assembly Source File  |  1992-11-03  |  114KB  |  5,392 lines

  1. ;+ This is MSYP98.ASM   VT100 emulation for NEC-PC9801          by.H.Fujii
  2. ;
  3. ; Update History
  4. ; 04-Jul-1992 KEK 2.00 ALPHA1
  5. ;             VTS comes here.
  6. ; 25-May-1991 Bug in vt_C1_CSI. "mov spec_stage,0" was missing.
  7. ; 17-Apr-1991 vt_ourarg in vt100_modlin1 for modeline is changed.
  8. ;             prn_out is replaced by pntchr.
  9. ;             [these are done by Joe Doupnik]
  10. ; 01-Sep-1990 DCS is interpreted. Bugs for C0 characters in ESC/CSI seq.
  11. ;             have been fixed.
  12. ;             Saved CX in vt100_modlin.
  13. ; 29-Jul-1990 DCS is separated and ignored.
  14. ; 27-Jul-1990 For MS-Kermit v3.02
  15. ; 25-Jun-1990 Fixed bug of ESC FF (forgot to clear ESC flag).
  16. ; 04-Aug-1989 Fixed wrong ESC M (reverse index) and ESC E (next line).
  17. ; 30-May-1989 ESC [ 0 m resets colors to default (color in command mode).
  18. ; 21-Apr-1989 Backquote modification for display is moved to disp_char.
  19. ; 19-Apr-1989 Put CR/LF for CSI*;1H in the cooked-log file.
  20. ; 16-Apr-1989 Installed Cooked log
  21. ; 17-Jan-1989 Bug in VT100_color. Highlight color set was wrong.
  22. ; 03-Dec-1988 Bug report from Mikami-san at NTT software lab. for
  23. ;             ESC[;r.  The routine for 'set scroll region' is fixed.
  24. ; 06-Nov-1988 Bug found in VT100_SAVE.  In some situation, VT100 screen
  25. ;             is not restored correctly.
  26. ; 10-Sep-1988 Autoprint feateres are installed
  27. ; 14-Aug-1988 Roll-Up/Down features with simple circular movement.
  28. ;
  29. ; ESC sequence
  30. ; - General rule -
  31. ;   1) 2-byte sequence
  32. ;      a) ESC Fs terminated by 6/0 - 7/14 (standard sequence)
  33. ;      b) ESC Fp terminated by 3/0 - 3/15 (private sequence)
  34. ;      c) ESC Fe terminated by 4/0 - 5/15 (C1 control character)
  35. ;   2) multibyte sequnce
  36. ;      a) ESC I...I Fp terminated by 3/0 - 3/15 (private sequence)
  37. ;      b) ESC I...I Ft terminated by 4/0 - 7/14 (standard sequence)
  38. ;      where I is 2/0 - 2/15
  39. ;
  40. ; Cotrol sequence
  41. ;   1) CSI P...P I...I Ft terminated by 4/0 - 6/15 (standard sequence)
  42. ;   2) CSI P...P I...I Fp terminated by 7/0 - 7/14 (private sequence)
  43. ;      where CSI is 9/11 or ESC 5/11 (one of ESC Fe sequnce)
  44. ;            P is 3/0 - 3/15,
  45. ;                 3/11 is separator
  46. ;                 3/15 is private parameter introducer
  47. ;            I is 2/0 - 2/15
  48. ;
  49. ; CRT display character
  50. ;
  51. ;   Character plane
  52. ;              F E D C B A 9 8   7 6 5 4 3 2 1 0
  53. ;             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  54. ;             |      0        | |    ANK code   |         ANK
  55. ;             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  56. ;
  57. ;             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  58. ;             |0|   JIS 2nd   | |JIS 1st - '20'X|     Kanji Left half
  59. ;             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  60. ;             |1|   JIS 2nd   | |JIS 1st - '20'X|     Kanji Right half
  61. ;             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  62. ;
  63. ;
  64. ;   Attribute plane
  65. ;              F E D C B A 9 8   7 6 5 4 3 2 1 0
  66. ;             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  67. ;             |      N/A      | |G|R|B| | | | | |
  68. ;             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  69. ;                                ^ ^ ^ ^ ^ ^ ^ ^
  70. ;                                | | | | | | | |
  71. ;                                | | | | | | | secret (0)
  72. ;                                | | | | | | blink (1)
  73. ;                                | | | | | reverse (1)
  74. ;                                | | | | underline (1)
  75. ;                                | | | vertical line/graph pattern
  76. ;                                color
  77. ;
  78. ;
  79. ; The following Japanese Industrial Standards specify the Kana-Kanji treatment
  80. ; for information interchange.
  81. ;
  82. ;   JIS C 6226:
  83. ;     Code of the Japanese Graphic Character Set
  84. ;     for Information Intercahnge
  85. ;
  86. ;   JIS C 6228:
  87. ;     Code Extension Techniques for Use with the Code
  88. ;     for Information Interchange .
  89. ;
  90. ; In these standards, each byte of the multi-byte code is in the range
  91. ; 2/1 - 7/14. Each character is specified by an index of the current character
  92. ; table. In 7-bit environment, every index is the character code itself (or the
  93. ; first byte of the multi-byte character code). In 8-bit environment, there are
  94. ; two sets of current character table, called GL and GR.  A GL-character is
  95. ; specified by the character code itself, and a GR-character is specified by
  96. ; the character code with 8-th bits on.
  97. ; As intermediate character sets, four sets of characters can be used at onece.
  98. ; These sets are called G0, G1, G2 and G3.  To invoke these sets to the current
  99. ; character set(s),
  100. ;
  101. ; in 7-bit environment,
  102. ;
  103. ;   0/F       Shift In                Invoke G0 character set
  104. ;   0/E       Shift Out               Invoke G1 character set
  105. ;   ESC 6/E   Locking Shift 2         Invoke G2 character set
  106. ;   ESC 6/F   Locking Shift 3         Invoke G3 character set
  107. ;
  108. ;   ESC 4/E   Single Shift 2          Invoke G2 character
  109. ;   ESC 4/F   Single Shift 3          Invoke G3 character
  110. ;
  111. ; in 8-bit environment,
  112. ;
  113. ;   0/F       Locking Shift 0         Invoke G0 character set to GL
  114. ;   0/E       Locking Shift 1         Invoke G1 character set to GL
  115. ;   ESC 7/E   Locking Shift 1 Right   Invoke G1 character set to GR
  116. ;   ESC 6/E   Locking Shift 2         Invoke G2 character set to GL
  117. ;   ESC 7/D   Locking Shift 2 Right   Invoke G2 character set to GR
  118. ;   ESC 6/F   Locking Shift 3         Invoke G3 character set to GL
  119. ;   ESC 7/C   Locking Shift 3 Right   Invoke G3 character set to GR
  120. ;
  121. ;   8/E       Single Shift 2          Invoke G2 character
  122. ;   8/F       Single Shift 3          Invoke G3 character.
  123. ;
  124. ; To designate the single-byte character set, (JIS C 6228: 5.3.7)
  125. ;   ESC 2/8 F      and ESC 2/12 F              to G0 character set
  126. ;   ESC 2/9 F      and ESC 2/13 F              to G1 character set
  127. ;   ESC 2/10 F     and ESC 2/14 F              to G2 character set
  128. ;   ESC 2/11 F     and ESC 2/15 F              to G3 character set
  129. ;
  130. ;   where F is a final character in the range 3/0 - 7/14 which specifies the
  131. ;   character set. For example,
  132. ;
  133. ;       F        Character Set
  134. ;      ----      -------------
  135. ;      4/1       UK
  136. ;      4/2       US (ASCII)
  137. ;      4/9       JIS Katakana
  138. ;      4/10      JIS Roman
  139. ;      4/11      Germany
  140. ;      5/2       France
  141. ;      5/4       Chinese Roman
  142. ;      5/9       Italy
  143. ;      5/10      Spain
  144. ;      5/11      Greek
  145. ; .
  146. ;
  147. ; To designate the multi-byte character set, (JIS C 6226: 5.3.8)
  148. ;   ESC 2/4 F      and ESC 2/4 2/12 F          to G0 character set
  149. ;   ESC 2/4 2/9 F  and ESC 2/4 2/13 F          to G1 character set
  150. ;   ESC 2/4 2/10 F and ESC 2/4 2/14 F          to G2 character set
  151. ;   ESC 2/4 2/11 F and ESC 2/4 2/15 F          to G3 character set
  152. ;
  153. ;   where F is a final character in the range 3/0 - 7/14 which specifies the
  154. ;   character set. For example,
  155. ;
  156. ;       F        Character Set
  157. ;      ---       -------------
  158. ;      4/0       JIS C 6226 - 1978
  159. ;      4/1       Chinese Kanji
  160. ;      4/2       JIS C 6226 - 1983
  161. ;  .
  162. ;
  163. ; Corresponding Internatial Standard is ISO 2022.
  164. ;
  165.     include    mssdef.h
  166.     include    msxp98.h
  167. ;
  168. NUL    equ    0
  169. CSI    equ    9Bh
  170. ;
  171. ROLLMEM_MIN    equ    40        ; minimum & maximum number of
  172. ROLLMEM_MAX    equ    4000        ; paragraphs for roll-back buffer
  173. ;
  174.  
  175. CHR_REV        equ    04h
  176. CRT_TXT_SEG    equ    0A000h
  177.  
  178. PRIVP_FLG    equ    08000h
  179.  
  180. in_ESC_MODE    equ    1
  181. in_CSI_MODE    equ    2
  182. in_DCS_MODE    equ    3
  183.  
  184. VT52_DCA_L    equ    64
  185. VT52_DCA_C    equ    65
  186.  
  187. IN_SIXEL    equ    66
  188.  
  189.     public    vts
  190.     public    vt100,vt100_ini,vt100_save,vt100_restore,vt100_reset
  191.     public    vt100_modlin, vt100_dump, vt100_color
  192.     public    vt100_rupn, vt100_rdnn, vt100_prnl, vt100_prns
  193.     public    set_modlin
  194.     public    prn_chk
  195.  
  196.     public    termtb
  197.     public    char_SS, char_GL, char_GR
  198.     public    gnrm_color, gbck_color
  199.     public    crt_cols, crt_lins
  200.  
  201. data     segment
  202.  
  203.     extrn    flags:byte, trans:byte
  204.     extrn    npages:word
  205.     extrn    denyflg:word
  206.     extrn    kstatus:word
  207.     extrn    comand:byte
  208.     extrn    cpu_clock:byte, vtgrph_flg:byte, vttest_flg:byte
  209.     extrn    curkey_mode:byte, keypad_mode:byte
  210.     extrn    keyin_dos:byte, display_mode:byte
  211.     extrn    kanji_rcode:byte, kanji_scode:byte
  212.     extrn    vt100_cursr:word
  213.     extrn    vt100_flags:byte, vt100_pflag:byte
  214.     extrn    vt100_lflag:byte, vt100_gflag:byte
  215.     extrn    vt_ourarg:byte
  216.     extrn    def_color:byte, scn_color:byte
  217.     extrn    scrn_lines:word        ; in MSXP98.ASM
  218.  
  219.                     ; begin Terminal emulator data set
  220. termtb    db    5            ; entries for Status, not Set
  221.     mkeyw    'VT102',ttvt102
  222.     mkeyw    'VT100',ttvt100
  223.     mkeyw    'VT52',ttvt52
  224.     mkeyw    'Tek4010',tttek
  225.     mkeyw    'none',ttgenrc
  226.  
  227. vttbl    db    16
  228.     mkeyw    'Character-set',vtchar
  229.     mkeyw    'Cooked-log',vtslog
  230.     mkeyw    'Kanji-code',vtskanj
  231.     mkeyw    'Kanji-separation',vtsksep
  232.     mkeyw    'Keyinput',vtskyin
  233.     mkeyw    'Insert',vtsflg3
  234.     mkeyw    'Newline',vtsflg1
  235.     mkeyw    'Origin',vtsflg4
  236.     mkeyw    'Wrap',vtsflg2
  237.     mkeyw    'Display',vtsdis
  238.     mkeyw    'Type',vttype        ; SET TERM TYPE
  239.     mkeyw    'None',vttyp0
  240.     mkeyw    'VT52',vttyp2
  241.     mkeyw    'VT100',vttyp4
  242.     mkeyw    'VT102',vttyp8
  243.     mkeyw    'Tek4010',vttyp40
  244.  
  245. ;@@vttbl    db    34            ; number of entries
  246. ;@@    mkeyw    'Arrow-keys',flg11
  247. ;@@    mkeyw    'Controls',flg9
  248. ;@@    mkeyw    'Cursor-style',flg7
  249. ;@@    mkeyw    'Direction',flg4
  250. ;@@    mkeyw    'Keyclick',flg5
  251. ;@@    mkeyw    'Keypad',flg10
  252. ;@@    mkeyw    'Margin-bell',flg6
  253. ;@@    mkeyw    'Newline',flg1
  254. ;@@    mkeyw    'Screen-background',flg8
  255. ;@@    mkeyw    'Tabstops',tabmod
  256. ;@@    mkeyw    'Width',flg12
  257. ;@@    mkeyw    'Wrap',flg2
  258.  
  259. ;@@    mkeyw    'Bell',vtbeep
  260. ;@@    mkeyw    'Bytesize',vtbyte
  261. ;@@    mkeyw    'Clear-screen',vtcls
  262. ;@@    mkeyw    'Color',vtcolor
  263. ;@@    mkeyw    'Display',vtbyte    ; syn for set display 7/8
  264. ;@@    mkeyw    'Graphics',vtgraph
  265. ;@@    mkeyw    'Replay',replay
  266. ;@@    mkeyw    'Rollback',vtrollbk
  267. ;@@    mkeyw    'output-shift',vtshift
  268. ;@@    mkeyw    'UPSS',vtupss
  269. ;@@    mkeyw    'Type',vttype        ; SET TERM TYPE
  270. ;@@    mkeyw    'None',vttyp0
  271. ;@@    mkeyw    'Heath-19',vttyp1
  272. ;@@    mkeyw    'VT52',vttyp2
  273. ;@@    mkeyw    'VT100',vttyp4
  274. ;@@    mkeyw    'VT102',vttyp8
  275. ;@@    mkeyw    'VT220',vttyp10
  276. ;@@    mkeyw    'VT320',vttyp20
  277. ;@@    mkeyw    'Tek4010',vttyp40
  278. ;@@    mkeyw    'Honeywell',vttyp80
  279. ;@@    mkeyw    'PT200',vttyp100
  280.  
  281. kanjitab    db    5
  282.     mkeyw    'DEC',KNJCODE_DEC
  283.     mkeyw    'EUC',KNJCODE_DEC
  284.     mkeyw    'JIS7',KNJCODE_JIS7
  285.     mkeyw    'Shift-JIS',KNJCODE_SJIS
  286.     mkeyw    'none',KNJCODE_NONE
  287.  
  288. keyintab    db    3
  289.     mkeyw    'BIOS',0
  290.     mkeyw    'CON',1
  291.     mkeyw    'DOS',2
  292.  
  293. ontab    db    2            ; two entries
  294.     mkeyw    'off',0
  295.     mkeyw    'on',1
  296.  
  297. beltab    db    3            ; bell type
  298.     mkeyw    'audible',0
  299.     mkeyw    'visual',1
  300.     mkeyw    'none',2
  301.  
  302. distab    db    4            ; display
  303.     mkeyw    '7-bit',0
  304.     mkeyw    '8-bit',d8bit
  305.     mkeyw    'analogue',1001H
  306.     mkeyw    'digital',1000H
  307.  
  308. scrtab    db    2            ; screen attributes
  309.     mkeyw    'normal',0
  310.     mkeyw    'reverse',1
  311.  
  312. dirtab    db    2            ; writing direction
  313.     mkeyw    'left-to-right',0
  314.     mkeyw    'right-to-left',1
  315.  
  316. curtab    db    2            ; cursor attributes
  317.     mkeyw    'block',0
  318.     mkeyw    'underline',1
  319.      
  320. chatab    db    6            ; National Replacement Character sets
  321.     mkeyw    'ASCII',CSET_JISROMAN    ; ASCII is default (0, no NRC)
  322.     mkeyw    'DEC-Special',CSET_DECGRAPH
  323.     mkeyw    'JIS-KATAKANA',CSET_JISKATAKANA
  324.     mkeyw    'JIS-KANJI',CSET_JISC6226
  325.     mkeyw    'JIS-ROMAN',CSET_JISROMAN
  326.     mkeyw    'JIS-X0208',CSET_JISC6226
  327.  
  328. upsstab    db    2
  329.     mkeyw    'DEC-MCS',94        ; DEC Supplemental Graphics
  330.     mkeyw    'Latin1',96        ; Latin-1
  331.  
  332. sidetab    db    4            ; SET TERM CHAR <char set> Gn
  333.     mkeyw    'G0','0'
  334.     mkeyw    'G1','1'
  335.     mkeyw    'G2','2'
  336.     mkeyw    'G3','3'
  337.  
  338. shifttab db    5            ; SET TERM OUTPUT-SHIFT
  339.     mkeyw    'none',0
  340.     mkeyw    'automatic',8
  341.     mkeyw    'SI/SO',1
  342.     mkeyw    'SS2',2
  343.     mkeyw    'SS3',4
  344.  
  345. graftab    db    12
  346.     mkeyw    'auto-sensing',0    ; autosensing
  347.     mkeyw    'CGA',1
  348.     mkeyw    'EGA',2
  349.     mkeyw    'VGA',3
  350.     mkeyw    'Hercules',4
  351.     mkeyw    'ATT',5
  352.     mkeyw    'WyseA(1280x800)',6    ; Wyse-700 1280 x 800 mode
  353.     mkeyw    'WyseH(1280x780)',7    ; Wyse-700 1280 x 780 mode
  354.     mkeyw    'WyseT(1024x780)',8    ; Wyse-700 1024 x 780 mode
  355.     mkeyw    'character-writing',101h
  356.     mkeyw    'color',103h
  357.     mkeyw    'cursor',102h
  358.  
  359. gchrtab    db    2            ; set term graphics char-writing
  360.     mkeyw    'opaque',1
  361.     mkeyw    'transparent',0
  362.  
  363. disatab    db    2            ; Tek disable/enable table
  364.     mkeyw    'disable',1
  365.     mkeyw    'enable',0
  366.  
  367. tabtab    db    2            ; label says it all!
  368.     mkeyw    'at',0FFH        ; For setting tab stops
  369.     mkeyw    'Clear',0        ; For clearing tab stops
  370.      
  371. alltab    db    2            ; more tab command decoding
  372.     mkeyw    'all',0
  373.     mkeyw    'at',1
  374.  
  375. cntltab    db    2            ; 8-bit controls
  376.     mkeyw    '7-bit',0
  377.     mkeyw    '8-bit',1
  378.  
  379. kpamtab    db    2            ; keypad, application
  380.     mkeyw    'numeric',0
  381.     mkeyw    'application',1
  382.  
  383. arrtab    db    2            ; cursor keys, application
  384.     mkeyw    'cursor',0
  385.     mkeyw    'application',1
  386.  
  387.  
  388. widtab    db    2
  389.     mkeyw    '80-columns',0
  390.     mkeyw    '132-columns',1
  391.  
  392. colortb    db    0,4,2,6,1,5,3,7        ; color reversed-bit setting bytes
  393. clrset    db    0            ; Temp for SET Term Tabstops xxx
  394. ;
  395.     even
  396. ;
  397. temp        dw    0        ; scratch
  398. temp2        dw    0        ; scratch2
  399. ;
  400. vt_saveseg    dw    ?        ; segment address to save screen
  401. vt_rollseg    dw    ?        ; segment address to roll-up screen
  402. vt_rollmxs    dw    ?        ; maximum segment address allocated
  403. vt_rollmxl    dw    ?
  404. vt_rollcur    dw    ?        ; current segment address
  405. vt_rollcln    dw    0        ; current line number of the buffer
  406. vt_rollfil    dw    1
  407. vt_rollnum    dw    0
  408.  
  409. vt_init        db    0
  410. vt_wrap        db    0        ; wrap request flag
  411. vt_graph    db    0
  412. vt_chrset    db    0
  413. vt_chratr    db    0        ; current character attributes
  414. vt_blkatr    db    0        ; blank area attributes
  415. vt_nrmatr    db    0E1h        ; normal character attributes
  416. vt_hglatr    db    0C0h        ; highlight character attribute
  417. vt_modatr    db    0C5h        ; mode line character attributes
  418.  
  419. vt_in_stat    db    0        ; in status line flag
  420. vt_stat_type    db    1        ; status line type
  421. stat_col    db    0        ; column in status line
  422. stat_row    db    24        ; row of the status line (from 0)
  423.  
  424. crt_cols    db    80
  425. crt_lins    db    24
  426.  
  427. sixel_disp_on    db    0, 0
  428.  
  429. save_flags    db    ?
  430. save_graph    db    ?
  431. save_chrset    db    ?
  432. save_chratr    db    ?
  433. save_blkatr    db    ?
  434.  
  435. vt_knjsep    db    0FFh
  436. vt_knjmode    db    0        ; Kanji mode if 1
  437. vt_kanji1    db    0        ; Kanji 1st byte
  438. vt_kanji2    db    0
  439.  
  440. ; The fllowing parameters are used for ESC/CSI/DCS sequence.
  441. ;   seq_stage:  0  normal character stage
  442. ;               1  in ESC seq.
  443. ;               2  in ESC intermediate stage
  444. ;               3  in CSI (parameter) stage.
  445. ;               4  in CSI intermediate stage
  446. ;               5  in DCS (parameter) stage.
  447. ;               6  in DCS intermediate stage
  448. ;
  449. spec_mode    db    0
  450. spec_stage    db    0
  451. I_pnt        dw    0
  452. I_buf        db    128 dup (?)
  453. P_pnt        dw    0
  454. P_buf        dw    128 dup (?)
  455.  
  456. priv_pflg    dw    0
  457. priv_char    db    0
  458.  
  459. char_SS        dw    0        ; GL for single shift
  460. char_GL        dw    ?
  461. char_GR        dw    ?
  462.  
  463. char_save_SS    dw    ?
  464. char_save_GL    dw    ?
  465. char_save_GR    dw    ?
  466.  
  467. char_G0        db    CSET_JISROMAN
  468. char_G1        db    CSET_DECGRAPH
  469. char_G2        db    CSET_JISKATAKANA
  470. char_G3        db    CSET_JISC6226
  471.  
  472. char_save_G0    db    ?
  473. char_save_G1    db    ?
  474. char_save_G2    db    ?
  475. char_save_G3    db    ?
  476.  
  477. ; Normal PC98 color table
  478. ;
  479. gnrm_color    db    000h,000h,000h        ;  0:black
  480.         db    000h,000h,0ffh        ;  1:blue
  481.         db    0ffh,000h,000h        ;  2:red
  482.         db    0ffh,000h,0ffh        ;  3:magenta
  483.         db    000h,0ffh,000h        ;  4:green
  484.         db    000h,0ffh,0ffh        ;  5:cyan
  485.         db    0ffh,0ffh,000h        ;  6:yellow
  486.         db    0ffh,0ffh,0ffh        ;  7:white
  487.         db    0afh,0afh,0afh        ;  8:light-gray
  488.         db    000h,000h,0afh        ;  9:dark-blue
  489.         db    0afh,000h,000h        ; 10:dark-red
  490.         db    0afh,000h,0afh        ; 11:dark-magenta
  491.         db    000h,0afh,000h        ; 12:dark-green
  492.         db    000h,0afh,0afh        ; 13:dark-cyan
  493.         db    0afh,0afh,000h        ; 14:dark-yellow
  494.         db    07fh,07fh,07fh        ; 15:dark-gray
  495. ;
  496. gbck_color    db    000h,000h,000h        ;  0:
  497.         db    000h,000h,000h        ;  1:
  498.         db    000h,000h,000h        ;  2:
  499.         db    000h,000h,000h        ;  3:
  500.         db    000h,000h,000h        ;  4:
  501.         db    000h,000h,000h        ;  5:
  502.         db    000h,000h,000h        ;  6:
  503.         db    000h,000h,000h        ;  7:
  504.         db    000h,000h,000h        ;  8:
  505.         db    000h,000h,000h        ;  9:
  506.         db    000h,000h,000h        ; 10:
  507.         db    000h,000h,000h        ; 11:
  508.         db    000h,000h,000h        ; 12:
  509.         db    000h,000h,000h        ; 13:
  510.         db    000h,000h,000h        ; 14:
  511.         db    000h,000h,000h        ; 15:
  512.  
  513. vt_gset        db    0EAh,087h,009h,00Ch,00Dh,00Ah,0DFh,08Fh
  514.         db    015h,00Bh,09Bh,099h,098h,09Ah,08Fh,094h
  515.         db    094h,095h,081h,080h,093h,092h,090h,091h
  516.         db    096h,01Dh,01Ch,01Eh,01Fh,0F1h,0A5h,020h
  517.  
  518.         even
  519. C0_func_tab    dw    vt_disp_none        ; 00H NUL
  520.         dw    vt_disp_none        ; 01H SOH
  521.         dw    vt_disp_none        ; 02H STX
  522.         dw    vt_disp_none        ; 03H ETX
  523.         dw    vt_disp_none        ; 04H EOT
  524.         dw    vt_disp_none        ; 05H ENQ
  525.         dw    vt_disp_none        ; 06H ACK
  526.         dw    vt_disp_BEL        ; 07H BEL
  527.         dw    vt_disp_BS        ; 08H BS
  528.         dw    vt_disp_HT        ; 09H HT
  529.         dw    vt_disp_LF        ; 0AH LF
  530.         dw    vt_disp_LF        ; 0BH VT
  531.         dw    vt_disp_LF        ; 0CH FF
  532.         dw    vt_disp_CR        ; 0DH CR
  533.         dw    vt_disp_SO        ; 0EH SO
  534.         dw    vt_disp_SI        ; 0FH SI
  535. ;
  536.         dw    vt_disp_none        ; 10H DLE
  537.         dw    vt_disp_none        ; 11H DC1 (XON)
  538.         dw    vt_disp_none        ; 12H DC2
  539.         dw    vt_disp_none        ; 13H DC3 (XOFF)
  540.         dw    vt_disp_none        ; 14H DC4
  541.         dw    vt_disp_none        ; 15H NAK
  542.         dw    vt_disp_none        ; 16H SYN
  543.         dw    vt_disp_none        ; 17H ETB
  544.         dw    vt_disp_CAN        ; 18H CAN
  545.         dw    vt_disp_none        ; 19H EM
  546.         dw    vt_disp_SUB        ; 1AH SUB
  547.         dw    vt_disp_ESC        ; 1BH ESC
  548.         dw    vt_disp_none        ; 1CH FS
  549.         dw    vt_disp_GS        ; 1DH GS
  550.         dw    vt_disp_none        ; 1EH RS
  551.         dw    vt_disp_none        ; 1FH US
  552. ;
  553.         even
  554. vram_line    dw    0000h        ; 0-line
  555.         dw    00a0h        ; 1
  556.         dw    0140h        ; 2
  557.         dw    01e0h        ; 3
  558.         dw    0280h        ; 4
  559.         dw    0320h        ; 5
  560.         dw    03c0h        ; 6
  561.         dw    0460h        ; 7
  562.         dw    0500h        ; 8
  563.         dw    05a0h        ; 9
  564.         dw    0640h        ;10
  565.         dw    06e0h        ;11
  566.         dw    0780h        ;12
  567.         dw    0820h        ;13
  568.         dw    08c0h        ;14
  569.         dw    0960h        ;15
  570.         dw    0a00h        ;16
  571.         dw    0aa0h        ;17
  572. vram_line_18    dw    0b40h        ;18
  573. vram_line_19    dw    0be0h        ;19
  574.         dw    0c80h        ;20
  575.         dw    0d20h        ;21
  576.         dw    0dc0h        ;22
  577. vram_line_23    dw    0e60h        ;23
  578. vram_line_24    dw    0f00h        ;24
  579.  
  580. vram_botm_line    dw    0e60h        ;23
  581. vram_last_line    dw    0f00h        ;24
  582.  
  583. ;
  584. I_am_vt52    db    3
  585.         db    ESCAPE,"/Z"
  586. I_am_vt102    db    5
  587.         db    ESCAPE,"[?6c"
  588. I_am_vt220    db    16
  589.         db    ESCAPE,"[?62;1;2;6;7;8c"
  590. I_am_fine    db    4
  591.         db    ESCAPE,"[0n"
  592. My_cursor_is    db    ESCAPE,"["
  593.         db    10 dup (?)
  594. cur_col        db    0
  595. cur_row        db    0
  596. cur_save_col    db    0
  597. cur_save_row    db    0
  598.  
  599. text_col    db    0
  600. text_row    db    0
  601. text_top    db    0
  602. text_bottom    db    0
  603.  
  604. color_index_table    db    0, 2, 4, 6, 1, 3, 5, 7
  605. ;
  606. vt_lines    dw    24
  607.  
  608. vt_phys_top    db    0
  609. vt_phys_bottom    db    23
  610.  
  611. vt_top        db    0
  612. vt_bottom    db    23
  613.  
  614. tabstops    db    80 dup (?)    ; tab stop table
  615.         db    1,1        ; guard
  616.  
  617. nam_none    db    '          '
  618. nam_vt52    db    'VT52      '
  619. nam_vt100    db    'VT102 '
  620. LED_buff    db    '....'
  621. nam_tek        db    'TEK4010/14'
  622. nam_prn        db    ' PRN'
  623. nam_nprn    db    '    '
  624.  
  625. dump_pntr    dw    ?
  626. dump_buffer    db    256    dup (?)
  627. dump_mode    db    0
  628.  
  629. watch_pnd    dw    0
  630. watch_buf    db    12 dup (?)
  631. watch_lvl    db    0
  632. watch_mod    db    0
  633.  
  634. ;
  635. ; Kermit mode line buffer
  636. ;
  637. mode_len    db    0
  638. mode_ker    db    'Esc-chr: '
  639. mode_esc    db    '^]'
  640.         db    '  help: '
  641. mode_hlp    db    '^]'
  642.         db    '?  port:'
  643. mode_prt    db    '1'
  644.         db    ' speed:'
  645. mode_spd    db    '     '
  646.         db    ' parity:'
  647. mode_pty    db    'none'
  648.         db    ' echo:'
  649. mode_ech    db    'rem'
  650.         db    ' '
  651. mode_trm    db    '          '
  652. mode_prn    db    '    '
  653. MODE_LINE_LENG    = $ - mode_len
  654.  
  655. unkbaud        db    ' Unk '    ; must be 5 characters
  656. baudname    db    ' 45.5'
  657.         db    '  50 '
  658.         db    '  75 '
  659.         db    ' 110 '
  660.         db    '134.5'
  661.         db    ' 150 '
  662.         db    ' 300 '
  663.         db    ' 600 '
  664.         db    ' 1200'
  665.         db    ' 1800'
  666.         db    ' 2000'
  667.         db    ' 2400'
  668.         db    ' 4800'
  669.         db    ' 9600'
  670.         db    '19200'
  671.         db    '38400'
  672.         db    '57.6K'
  673.         db    '115 K'
  674. BAUDNSIZ    equ    18
  675.  
  676. parityname    db    'even'        ; must be 4 characters
  677.         db    'mark'
  678.         db    'none'
  679.         db    'odd '
  680.         db    'spc '
  681.  
  682. lclename    db    'loc'
  683. remename    db    'rem'
  684.  
  685. vthlp    db ' one of the following:',cr,lf
  686.     db '  TYPE of: None, VT52, VT100, VT102 (default), or '
  687.     db 'Tek4014',cr,lf
  688.     db '  Clock (5MHz,8MHz,10MHz)            ',cr,lf
  689.     db '  Keyclick (on/off)                  '
  690.     db    '  Keyinput (BIOS/CON/DOS)            ',cr,lf
  691.     db    '  Keypad-mode (application/normal)   '
  692.     db    '  Cursorkey-mode (application/normal)',cr,lf
  693.     db    '  Foreground (white,yellow...)       '
  694.     db    '  Background (black,blue...)         ',cr,lf
  695.     db    '  Highlight (yellow,magenta...)      '
  696.     db    '  Modeline-color (white,green...)    ',cr,lf
  697.     db    '  Kanji-code (DEC-code,Shift-JIS,JIS-'
  698.     db    '7, or none)',cr,lf
  699.     db    '  Insert (on/off)                    '
  700.     db    '  Origin-mode (on/off)               ',cr,lf
  701.     db    '  Newline-mode (on/off)              '
  702.     db    '  Wrap (on/off)                      ',cr,lf
  703.     db    '  Cooked-log (on/off)                ',cr
  704.     db    '$'
  705.  
  706. keyinhlp    db    ' one of the following:',cr,lf
  707.         db    'BIOS (PC-9801 Keyinput BIOS)',cr,lf
  708.         db    'CON  (MS-DOS console i/o + keysense BIOS)',cr,lf
  709.         db    'DOS  (MS-DOS console i/o)',cr,lf
  710.         db    '$'
  711.  
  712. ; VT setup command table
  713. ; The higher byte indicates the group of the command.
  714. ;  8100H   -- terminal type
  715. ;   300H   -- color group
  716. ;   400H   -- Kanji group
  717. ;   500H   -- Keymode application/normal
  718. ;   600H   -- Playback file
  719. ;   700H   -- clear
  720. ;  2000H   -- vt100_flags on/off
  721. ;  2100H   -- vt100_pflag on/off
  722. ;  2200H   -- vtgrph_flg on/off
  723. ;  2300H   -- vt100_lflag on/off
  724. ;  2400H   -- vttest_flg on/off
  725. ;
  726. ; <<< DO NOT forget to update the number of items at 'vttbl' when you add
  727. ;     new item to the following list >>>
  728. ;@@vttbl    db    36
  729. ;@@    mkeyw    'Background',301H
  730. ;@@    mkeyw    'Clear-screen',700H
  731. ;@@    mkeyw    'Clock',503H
  732. ;@@    mkeyw    'Color',300H
  733. ;@@    mkeyw    'Cooked-log',LOGCOOK_BIT+2300H
  734. ;@@    mkeyw    'Cursorkey-mode',502H
  735. ;@@    mkeyw    'Display-mode',504H
  736. ;@@    mkeyw    'Exit-graphic',EXITG_BIT+2200H
  737. ;@@    mkeyw    'Foreground',300H
  738. ;@@    mkeyw    'GWait',GCLRWAIT_BIT+2200H
  739. ;@@    mkeyw    'Highlight',302H
  740. ;@@    mkeyw    'Insert-mode',INSERT_BIT+2000H
  741. ;@@    mkeyw    'Kanji-Code',400H
  742. ;@@    mkeyw    'Keyclick',KEYCLICK_BIT+2000H
  743. ;@@    mkeyw    'Keyinput',500H
  744. ;@@    mkeyw    'Keypad-mode',501H
  745. ;@@    mkeyw    'Modeline-color',303H
  746. ;@@    mkeyw    'Mouse',MOUSE_BIT+2200H
  747. ;@@    mkeyw    'Newline-mode',NEWLINE_BIT+2000H
  748. ;@@    mkeyw    'None',ttgenrc+100H    ; note 100H flag for decoding here
  749. ;@@    mkeyw    'Origin-mode',ORIGIN_BIT+2000H
  750. ;@@    mkeyw    'Playback',600H
  751. ;@@    mkeyw    'PrintEXT',PRINTEXT_BIT+2100H
  752. ;@@    mkeyw    'PrintFF',PRINTFF_BIT+2100H
  753. ;@@    mkeyw    'Tek4014',tttek+100H
  754. ;@@    mkeyw    'test1',2401H
  755. ;@@    mkeyw    'test2',2402H
  756. ;@@    mkeyw    'test3',2404H
  757. ;@@    mkeyw    'test4',2408H
  758. ;@@    mkeyw    'test5',2410H
  759. ;@@    mkeyw    'test6',2420H
  760. ;@@    mkeyw    'test7',2440H
  761. ;@@    mkeyw    'test8',2480H
  762. ;@@    mkeyw    'VT102',ttvt100+100H
  763. ;@@    mkeyw    'VT52',ttvt52+100H
  764. ;@@    mkeyw    'Wrap',AUTOWRAP_BIT+2000H
  765. ; <<< DO NOT forget to update the number of items at 'vttbl' when you add
  766. ;     new item to the above list >>>
  767. data    ends
  768.  
  769.  
  770. code    segment
  771.     assume    cs:code,ds:data,es:nothing
  772.  
  773.     extrn    sbrk:near        ; memory allocation routine in mssker
  774.     extrn    comnd:near
  775.     extrn    s2jis:near, jis2s:near    ; in MSZP98
  776.     extrn    set_cursor:near        ; in MSZP98
  777.     extrn    set_gpalette:near    ; in MSGP98
  778.     extrn    gdisp_on:near, gdisp_off:near    ; in MSGP98
  779.     extrn    tek4014_color:near    ; in MSGP98
  780.     extrn    set_gcolor:near        ; in MSGP98
  781.     extrn    pntchr:near
  782.     extrn    outcapt:near        ; in MSXP98
  783.     extrn    set_cur_color:near    ; in MSXP98
  784.     extrn    sixel_in:near        ; in MSGP98
  785.     extrn    sixel_clear:near    ; in MSGP98
  786.     extrn    sixel:near        ; in MSGP98
  787. ;
  788. ; VT100 terminal emulator
  789. ;
  790. ;-----------------------------------------------------------
  791. ; SET Term parameters.
  792. ; VTS is called only by mssset to set terminal type and characteristics.
  793. ; Exit carry set for failure.
  794.  
  795. VTS    proc    near            ; SET TERM whatever
  796.     mov    kstatus,kssuc        ; success
  797.     mov    ah,cmkey        ; Parse another keyword
  798.     mov    bx,offset vthlp        ; Use this help
  799.     mov    dx,offset vttbl        ; Use this table
  800.     call    comnd
  801.     jnc    vset1            ; nc = success
  802.     ret                ; failure
  803. vset1:    call    bx            ; dispatch to processing routine
  804.     jnc    vset2            ; c = failure
  805.     mov    kstatus,kssuc        ; success
  806. vset2:    ret
  807.  
  808. vsetnotimp:
  809.     clc
  810.     ret
  811.                     ; SET TERM kind
  812. vttyp0:    mov    bx,ttgenrc        ; NONE
  813.     jmp    short vsett1
  814. vttyp1:    mov    bx,ttheath        ; Heath-19
  815.     jmp    short vsett1
  816. vttyp2:    mov    bx,ttvt52        ; VT52
  817.     jmp    short vsett1
  818. vttyp4:    mov    bx,ttvt100        ; VT100
  819.     jmp    short vsett1
  820. vttyp8:    mov    bx,ttvt102        ; VT102
  821.     jmp    short vsett1
  822. vttyp10:mov    bx,ttvt220        ; VT220
  823.     jmp    short vsett1
  824. vttyp20:mov    bx,ttvt320        ; VT320
  825.     jmp    short vsett1
  826. vttyp40:mov    bx,tttek        ; Tek
  827.     jmp    short vsett1
  828. vttyp80:mov    bx,tthoney        ; Honeywell VIP7809
  829.     jmp    short vsett1
  830. vttyp100:mov    bx,ttpt200        ; Prime PT200
  831.     jmp    short vsett1
  832.  
  833. vttype:    mov    ah,cmkey        ; SET TERM TYPE
  834.     xor    bx,bx            ; table is help
  835.     mov    dx,offset termtb    ; use this table
  836.     call    comnd
  837.     jnc    vsett1            ; nc = success
  838.     ret                ; failure
  839.  
  840. vsett1:    mov    temp,bx            ; save terminal type
  841.     mov    temp2,-1        ; assume no enable/disable Tek
  842.     cmp    bx,tttek        ; set term tek?
  843.     jne    vsett2            ; ne = no
  844.     mov    dx,offset disatab    ; disable/enable keyword table
  845.     xor    bx,bx            ; help is the table
  846.     mov    comand.cmcr,1        ; allow bare CR's
  847.         mov    ah,cmkey        ; get enable/disable keyword
  848.     call    comnd
  849.     mov    comand.cmcr,0        ; no more bare CR's
  850.     jc    vsett2            ; c = no such keyword
  851.     mov    temp2,bx        ; save enable/disable keyword value
  852.     mov    bx,flags.vtflg        ; get current terminal type
  853.     mov    temp,bx            ; and force it here
  854.  
  855. vsett2:    mov    ah,cmeol
  856.     call    comnd            ; get a confirm
  857.     jc    vsettx            ; c = failure
  858. vsett3:    mov    bx,temp
  859.     mov    flags.vtflg,bx        ; Set the terminal emulation type
  860. ;[HF]    mov    tekflg,0        ; clear Tek sub mode
  861.     cmp    bx,tttek        ; adjusting Tek?
  862.     jne    vsett4            ; ne = no
  863.     cmp    temp2,-1        ; just enable/disable tek?
  864.     je    vsett4            ; e = no
  865.     and    denyflg,not tekxflg    ; enable Tek
  866.     cmp    temp2,1            ; ought we disable?
  867.     jne    vsett4            ; ne = no
  868.     or    denyflg,tekxflg        ; disable Tek
  869. vsett4:    clc                ; success
  870. vsettx:    ret
  871.  
  872. vtskanj:mov    ah,cmkey
  873.     mov    bx,0
  874.     mov    dx,offset kanjitab
  875.     call    comnd
  876.     jc    vtskanx            ; c = failure
  877.     push    bx
  878.     mov    ah,cmeol        ; get a confirm
  879.     call    comnd
  880.     pop    bx
  881.     jc    vtskanx            ; c = failure
  882.     mov    kanji_scode,bl
  883.     mov    kanji_rcode,bl
  884.     clc
  885. vtskanx:ret
  886.  
  887. vtsksep:mov    ah,cmkey
  888.     mov    bx,0
  889.     mov    dx,offset disatab
  890.     call    comnd
  891.     jc    vtskspx            ; c = failure
  892.     push    bx
  893.     mov    ah,cmeol        ; get a confirm
  894.     call    comnd
  895.     pop    bx
  896.     jc    vtskspx
  897.     mov    vt_knjsep,0FFh        ; assume enable
  898.     cmp    bl,0            ; enable ?
  899.     je    vtsksp1            ; e = yes
  900.     mov    vt_knjsep,0        ; disable
  901. vtsksp1:clc
  902. vtskspx:ret
  903.  
  904. vtskyin:mov    ah,cmkey        ; Set Term Keyinput
  905.     mov    bx,offset keyinhlp    ; Use this help
  906.     mov    dx,offset keyintab    ; Use keyintab
  907.     call    comnd
  908.     jc    vtskyix            ; c = failure
  909.     push    bx
  910.     mov    ah,cmeol        ; get a confirm
  911.     call    comnd
  912.     pop    bx
  913.     jc    vtskyix            ; c = failure
  914.     mov    keyin_dos,bl        ; set the parameter
  915.     clc
  916. vtskyix:ret
  917.  
  918. vtsdis:    mov    ah,cmkey        ; Set Term Graphics
  919.     xor    bx,bx            ; Use table for help
  920.     mov    dx,offset distab    ; Use distab
  921.     call    comnd
  922.     jc    vtsdix            ; c = failure
  923.     push    bx
  924.     mov    ah,cmeol        ; get a confirm
  925.     call    comnd
  926.     pop    bx
  927.     jc    vtsdix            ; c = failure
  928.     cmp    bh,0            ; dismplay mode ?
  929.     je    vtsdib            ; e = no, set display 7/8
  930.     mov    display_mode,bl        ; set display mode
  931.     clc
  932.     jmp    vtsdix
  933. vtsdib:    and    flags.remflg,not d8bit    ; clear display 8-bit bit
  934.     or    flags.remflg,bl
  935.     clc
  936. vtsdix:    ret
  937.  
  938. vtsflg1:mov    al,NEWLINE_BIT
  939.     mov    dx,offset ontab
  940.     jmp    vtsflgs
  941. vtsflg2:mov    al,AUTOWRAP_BIT
  942.     mov    dx,offset ontab
  943.     jmp    vtsflgs
  944. vtsflg3:mov    al,INSERT_BIT
  945.     mov    dx,offset ontab
  946.     jmp    vtsflgs
  947. vtsflg4:mov    al,ORIGIN_BIT
  948.     mov    dx,offset ontab
  949. vtsflgs:push    si
  950.     mov    si,offset vt100_flags
  951.     jmp    flg100set
  952. ;
  953. vtslog:    mov    al,LOGCOOK_BIT
  954.     mov    dx,offset ontab
  955.     push    si
  956.     mov    si,offset vt100_lflag
  957. ;
  958. flg100set:
  959.     push    ax            ; save index
  960.     mov    ah,cmkey        ; another keyword
  961.     xor    bx,bx            ; use default help
  962.     call    comnd
  963.     pop    ax            ; recover index
  964.     jc    flg100set0        ; c = failure
  965.     push    ax
  966.     push    bx
  967.     mov    ah,cmeol        ; get confirm
  968.     call    comnd
  969.     pop    bx
  970.     pop    ax
  971.     jc    flg100set0        ; c = failure
  972.     or    bx,bx            ; set or clear
  973.     je    flg100set1        ; e = clear
  974.     or    [si],al            ; set
  975.     jmp    flg100set3
  976. flg100set1:
  977.     not    al
  978.     and    [si],al            ; clear
  979.     not    al
  980. flg100set3:
  981.     clc
  982. flg100set0:
  983.     pop    si
  984.     ret
  985.  
  986. vtchar:    mov    ah,cmkey        ; Set Term character set
  987.     xor    bx,bx            ; character set table for help 
  988.     mov    temp,bx            ; counter of trailing items
  989.     mov    dx,offset chatab    ; character set table
  990.     call    comnd
  991.     jc    vtcharx            ; c = failure
  992.     mov    I_buf,bl        ; save here
  993.     mov    al,char_G0        ; table of 4 overrides now
  994.     mov    ah,char_G1
  995.     mov    P_buf,ax
  996.     mov    al,char_G2
  997.     mov    ah,char_G3
  998.     mov    P_buf+2,ax
  999. vtchar1:mov    comand.cmcr,1        ; allow bare CR's
  1000.     mov    ah,cmkey
  1001.     xor    bx,bx
  1002.     mov    dx,offset sidetab    ; read Gnumber item, if any
  1003.     call    comnd
  1004.     mov    comand.cmcr,0        ; no bare CR's
  1005.     jc    vtchar2            ; c = no match, get confirm
  1006.     inc    temp            ; say have a trailing table number
  1007.     and    bx,3            ; remove ASCII value encoding
  1008.     add    bx,offset P_buf        ; address of slot to store info
  1009.     mov    al,I_buf        ; set ident
  1010.     mov    [bx],al            ; store table ident in G0..G3 slot
  1011.     jmp    short vtchar1        ; repeat
  1012.  
  1013. ; vtemu.vtchset:    changed to new set if no table trailers, else intact
  1014. ; char_G0, _G1, _G2, _G3     char set numbers for G0..G3 as overrides,
  1015. vtchar2:mov    ah,cmeol        ; get EOL confirmation
  1016.     call    comnd
  1017.     jc    vtcharx            ; c = failure, quit
  1018. ;@@    mov    vtemu.vtchop,0ffh    ; say reinit char tables
  1019.     cmp    temp,0            ; trailers (skip regular setup)?
  1020.     jne    vtchar3            ; ne = yes
  1021. ;@@    mov    al,dumpbuf        ; get character set
  1022. ;@@    mov    vtemu.vtchset,al    ; set default character set
  1023.                     ; just overrides
  1024. vtchar3:mov    ax,P_buf        ; first pair of char set idents
  1025.     mov    char_G0,al
  1026.     mov    char_G1,ah
  1027.     mov    ax,P_buf+2        ; second pair
  1028.     mov    char_G2,al
  1029.     mov    char_G3,ah
  1030.     clc
  1031. vtcharx:ret
  1032.  
  1033. ;@@
  1034. ;@@vsetup1:cmp    bh,81H            ; marker for terminal type?
  1035. ;@@    jne    vsetup_n1        ; ne = no
  1036. ;@@    jmp    vsetup_1
  1037. ;@@vsetup_n1:
  1038. ;@@    cmp    bh,20h            ; set term vt100_flags on/off?
  1039. ;@@    jne    vsetup_n20        ; ne = no
  1040. ;@@    jmp    vsetup_20
  1041. ;@@vsetup_n20:
  1042. ;@@    cmp    bh,21h            ; set term vt100_pflag on/off?
  1043. ;@@    jne    vsetup_n21        ; ne = no
  1044. ;@@    jmp    vsetup_20
  1045. ;@@vsetup_n21:
  1046. ;@@    cmp    bh,22h            ; set term vtgrph_flg on/off
  1047. ;@@    jne    vsetup_n22
  1048. ;@@    jmp    vsetup_20
  1049. ;@@vsetup_n22:
  1050. ;@@    cmp    bh,23h            ; set term vt100_lflag on/off
  1051. ;@@    jne    vsetup_n23
  1052. ;@@    jmp    vsetup_20
  1053. ;@@vsetup_n23:
  1054. ;@@    cmp    bh,24h            ; set term vttest_flg on/off
  1055. ;@@    jne    vsetup_n24
  1056. ;@@    jmp    vsetup_20
  1057. ;@@vsetup_n24:
  1058. ;@@vsetup_n2:
  1059. ;@@    cmp    bh,3h            ; marker for color
  1060. ;@@    jne    vsetup_n3        ; ne = no
  1061. ;@@    jmp    vsetup_3
  1062. ;@@vsetup_n3:
  1063. ;@@    cmp    bh,4h            ; marker for kanji
  1064. ;@@    jne    vsetup_n4        ; ne = no
  1065. ;@@    jmp    vsetup_4
  1066. ;@@vsetup_n4:
  1067. ;@@    cmp    bh,5            ; marker for keyboard
  1068. ;@@    jne    vsetup_n5
  1069. ;@@    jmp    vsetup_5
  1070. ;@@vsetup_n5:
  1071. ;@@    cmp    bh,6            ; marker for playback file
  1072. ;@@    jne    vsetup_n6
  1073. ;@@    jmp    vsetup_6
  1074. ;@@vsetup_n6:
  1075. ;@@    cmp    bh,7
  1076. ;@@    jne    vsetup_n7
  1077. ;@@    jmp    vsetup_7
  1078. ;@@vsetup_n7:
  1079. ;@@    jmp    vsetup_ex
  1080. ;
  1081. ;@@vsetup_1:
  1082. ;@@vsetup_20:
  1083. ;@@    and    bh,1Fh
  1084. ;@@    mov    param_dst,bx
  1085. ;@@    mov    ah,cmkey
  1086. ;@@    mov    bx,0
  1087. ;@@    mov    dx,offset ontab
  1088. ;@@    call    fcomnd
  1089. ;@@    jnc    vsetup_2_0_1
  1090. ;@@    ret                ; bad keyword
  1091. ;@@vsetup_2_0_1:
  1092. ;@@    push    bx
  1093. ;@@    mov    ah,cmeol        ; get a confirm
  1094. ;@@    call    fcomnd
  1095. ;@@    jnc    vsetup_2_0_2
  1096. ;@@    jmp    vsetup_ex2        ; did not get a confirm
  1097. ;@@vsetup_2_0_2:
  1098. ;@@    mov    ax,param_dst
  1099. ;@@    pop    bx
  1100. ;@@    cmp    bl,0
  1101. ;@@    jne    vsetup_2_on
  1102. ;@@    not    al
  1103. ;
  1104. ;   OFF mode
  1105. ;
  1106. ;@@    cmp    ah,0
  1107. ;@@    jne    vsetup_2_off1
  1108. ;@@    and    vt100_flags,al
  1109. ;@@    jmp    vsetup_2_2
  1110. ;@@vsetup_2_off1:
  1111. ;@@    cmp    ah,1
  1112. ;@@    jne    vsetup_2_off2
  1113. ;@@    and    vt100_pflag,al
  1114. ;@@    jmp    vsetup_2_2
  1115. ;@@vsetup_2_off2:
  1116. ;@@    cmp    ah,2
  1117. ;@@    jne    vsetup_2_off3
  1118. ;@@    and    vtgrph_flg,al
  1119. ;@@    jmp    vsetup_2_2
  1120. ;@@vsetup_2_off3:
  1121. ;@@    cmp    ah,3
  1122. ;@@    jne    vsetup_2_off4
  1123. ;@@    and    vt100_lflag,al
  1124. ;@@    jmp    vsetup_2_2
  1125. ;@@vsetup_2_off4:
  1126. ;@@    cmp    ah,4
  1127. ;@@    jne    vsetup_2_off5
  1128. ;@@    and    vttest_flg,al
  1129. ;@@vsetup_2_off5:
  1130. ;@@    jmp    vsetup_2_2
  1131. ;
  1132. ;  ON mode
  1133. ;
  1134. ;@@vsetup_2_on:
  1135. ;@@    cmp    ah,0
  1136. ;@@    jne    vsetup_2_on1
  1137. ;@@    or    vt100_flags,al
  1138. ;@@    jmp    vsetup_2_2
  1139. ;@@vsetup_2_on1:
  1140. ;@@    cmp    ah,1
  1141. ;@@    jne    vsetup_2_on2
  1142. ;@@    or    vt100_pflag,al
  1143. ;@@    jmp    vsetup_2_2
  1144. ;@@vsetup_2_on2:
  1145. ;@@    cmp    ah,2
  1146. ;@@    jne    vsetup_2_on3
  1147. ;@@    or    vtgrph_flg,al
  1148. ;@@    jmp    vsetup_2_2
  1149. ;@@vsetup_2_on3:
  1150. ;@@    cmp    ah,3
  1151. ;@@    jne    vsetup_2_on4
  1152. ;@@    or    vt100_lflag,al
  1153. ;@@    jmp    vsetup_2_2
  1154. ;@@vsetup_2_on4:
  1155. ;@@    cmp    ah,4
  1156. ;@@    jne    vsetup_2_on5
  1157. ;@@    or    vttest_flg,al
  1158. ;@@    jmp    vsetup_2_2
  1159. ;@@vsetup_2_on5:
  1160. ;@@vsetup_2_2:
  1161. ;;    jmp    rskp
  1162. ;@@    clc
  1163. ;@@    ret
  1164.  
  1165. ;@@vsetup_3:
  1166. ;@@    mov    dx,offset def_color
  1167. ;@@    xor    bh,bh
  1168. ;@@    add    dx,bx
  1169. ;@@    mov    param_dst,dx
  1170.  
  1171. ;@@    mov    ah,cmkey
  1172. ;@@    mov    bx,0
  1173. ;@@    mov    dx,offset colortab
  1174. ;@@    call    fcomnd
  1175. ;@@    jnc    vsetup_3_1
  1176. ;@@    ret                ; bad keyword
  1177. ;@@vsetup_3_1:
  1178. ;@@    push    bx
  1179. ;@@    mov    ah,cmeol        ; get a confirm
  1180. ;@@    call    fcomnd
  1181. ;@@    jnc    vsetup_3_2
  1182. ;@@    jmp    vsetup_ex2        ; did not get a confirm
  1183. ;@@vsetup_3_2:
  1184. ;@@    pop    dx            ; get old bx value to dx
  1185. ;@@    mov    bx,param_dst
  1186. ;@@    mov    byte ptr [bx],dl
  1187. ;@@    push    si
  1188. ;@@    mov    si,offset def_color
  1189. ;@@    cmp    bx,si            ; if foreground color, set modecol also
  1190. ;@@    jne    vsetup_3_7
  1191. ;@@    mov    byte ptr [bx+3],dl
  1192. ;@@vsetup_3_7:
  1193. ;@@    call    fcolset
  1194. ;@@    pop    si
  1195. ;;    jmp    rskp
  1196. ;@@    ret
  1197.  
  1198. ;@@vsetup_5:
  1199. ;@@    xor    bh,bh
  1200. ;@@    cmp    bx,0
  1201. ;@@    jne    vsetup_5n0
  1202. ;@@    mov    dx,offset keyin_dos
  1203. ;@@    mov    param_dst,dx
  1204. ;@@    mov    dx,offset keyintab
  1205. ;@@    jmp    vsetup_5do
  1206. ;@@vsetup_5n0:
  1207. ;@@    cmp    bx,1
  1208. ;@@    jne    vsetup_5n1
  1209. ;@@    mov    dx,offset keypad_mode
  1210. ;@@    mov    param_dst,dx
  1211. ;@@    mov    dx,offset keypadtab
  1212. ;@@    jmp    vsetup_5do
  1213. ;@@vsetup_5n1:
  1214. ;@@    cmp    bx,2
  1215. ;@@    jne    vsetup_5n2
  1216. ;@@    mov    dx,offset curkey_mode
  1217. ;@@    mov    param_dst,dx
  1218. ;@@    mov    dx,offset keypadtab
  1219. ;@@    jmp    vsetup_5do
  1220. ;@@vsetup_5n2:
  1221. ;@@    cmp    bx,3
  1222. ;@@    jne    vsetup_5n3
  1223. ;@@    mov    dx,offset cpu_clock
  1224. ;@@    mov    param_dst,dx
  1225. ;@@    mov    dx,offset clocktab
  1226. ;@@    jmp    vsetup_5do
  1227. ;@@vsetup_5n3:
  1228. ;@@    cmp    bx,4
  1229. ;@@    jne    vsetup_5n4
  1230. ;@@    mov    dx,offset display_mode
  1231. ;@@    mov    param_dst,dx
  1232. ;@@    mov    dx,offset displaytab
  1233. ;@@    jmp    vsetup_5do
  1234. ;@@vsetup_5n4:
  1235. ;;    jmp    rskp
  1236. ;@@    ret
  1237. ;@@vsetup_5do:
  1238. ;@@    mov    ah,cmkey
  1239. ;@@    mov    bx,0
  1240. ;@@    call    fcomnd
  1241. ;@@    jnc    vsetup_5do_1
  1242. ;@@    ret
  1243. ;@@vsetup_5do_1:
  1244. ;@@    push    bx
  1245. ;@@    mov    ah,cmeol
  1246. ;@@    call    fcomnd
  1247. ;@@    jnc    vsetup_5do_2
  1248. ;@@    jmp    vsetup_ex2
  1249. ;@@vsetup_5do_2:
  1250. ;@@    pop    dx
  1251. ;@@    mov    bx,param_dst
  1252. ;@@    mov    byte ptr [bx],dl
  1253. ;;    jmp    rskp
  1254. ;@@    ret
  1255.  
  1256. vsetup_6:
  1257.  
  1258. ; Set playback filename. Taken from 'setdmp' in MSSSET.ASM
  1259. ; Puts filename in global string playback_fnam.
  1260. ; Discared due to device independent module has playback command now.
  1261. ;        mov     dx,offset rdbuf         ; work area
  1262. ;        mov     rdbuf,0                 ; clear it
  1263. ;        mov     bx,offset playback_hlp  ; help message
  1264. ;        mov     ah,cmword               ; allow paths
  1265. ;        call    comnd
  1266. ;        jnc    vsetup_6_1
  1267. ;        ret
  1268. ;vsetup_6_1:
  1269. ;        mov     ah,cmeol
  1270. ;        call    comnd
  1271. ;        jnc    vsetup_6_2
  1272. ;        ret
  1273. ;vsetup_6_2:
  1274. ;        mov     dx,offset rdbuf         ; assume we will use this text
  1275. ;        call    strlen                  ; filename given?
  1276. ;        mov     si,dx                   ; for strcpy
  1277. ;        cmp     cx,0                    ; length of user's filename
  1278. ;        jg      vsetup_6_3              ; g = filename is given
  1279. ;        mov     si,offset playback_defnam     ; no name, use default instead
  1280. ;vsetup_6_3:
  1281. ;        mov     di,offset playback_fnam       ; copy to globally available loc
  1282. ;        call    strcpy
  1283. ;        or    vt100_flags,LOOPTEST_BIT
  1284. ;;        jmp     rskp
  1285.     ret
  1286.  
  1287. vsetup_7:
  1288. ;    push    bx
  1289. ;    mov    ah,cmeol
  1290. ;    call    comnd
  1291. ;    jnc    vsetup_7_1
  1292. ;    jmp    vsetup_ex2
  1293. vsetup_7_1:
  1294. ;    call    vtreset
  1295.     ret
  1296.  
  1297. vsetup_ex:
  1298. ;;    jmp    rskp
  1299.     ret
  1300. vsetup_ex2:
  1301.     pop    bx
  1302.     ret
  1303. ;@@vsetup    endp
  1304. VTS     endp
  1305.  
  1306. ;
  1307. ;-----------------------------------------------------------
  1308. ;
  1309. ; Initilization routine
  1310. ; This is called from lclini, local initialization routine.
  1311.  
  1312. VT100_INI    PROC    NEAR
  1313.     cmp    vt_init,0
  1314.     je    vt100_ini_1
  1315.     jmp    vt100_ini_ex
  1316. vt100_ini_1:
  1317.     mov    vt_init,1
  1318. ;
  1319. ; Allocate memory to save screen
  1320. ;
  1321.     mov    ax,2000h    ; display + attributes
  1322.     call    sbrk
  1323.     mov    vt_saveseg,ax
  1324. ;
  1325. ; Check the memory size
  1326. ;
  1327.     mov    bx,0FFFFh    ; allocate full integer (must fail)
  1328.     mov    ah,ALLOC    ; memory allocation
  1329.     int    DOS        ; system call. BX has number of free para.
  1330.     mov    ax,bx
  1331.     cmp    ax,2000        ; keep 32K for COMMAND.COM (in parag. size)
  1332.     ja    vt100_ini_r1
  1333.     mov    ax,ROLLMEM_MIN
  1334.     jmp    vt100_ini_r2
  1335. vt100_ini_r1:
  1336.     sub    ax,2000
  1337.     mov    bx,ax        ; save it in BX
  1338.     mov    ax,500        ; number of parag. per page (25 x 20)
  1339.     mul    npages        ; total number of paragraphs wanted
  1340.     cmp    ax,bx
  1341.     jbe    vt100_ini_r2
  1342.     mov    ax,ROLLMEM_MAX
  1343. vt100_ini_r2:
  1344.     xor    dx,dx
  1345.     mov    cx,20        ; number of parag. per line
  1346.     div    cx
  1347.     mov    vt_rollmxl,ax
  1348.     mov    cx,20        ; number of parag. per line
  1349.     mul    cx
  1350.     push    ax        ; save number of parag.
  1351.     mov    bx,ax
  1352.     mov    ah,ALLOC    ; allocate memory
  1353.     int    DOS
  1354.     mov    vt_rollseg,ax
  1355.     mov    vt_rollcur,ax
  1356.     mov    vt_rollcln,0
  1357.     mov    vt_rollfil,1
  1358.     pop    bx
  1359.     add    ax,bx
  1360.     mov    vt_rollmxs,ax
  1361. ;
  1362. vt100_ini_ex:
  1363.     call    vt100_soft_res    ; reset software parameters
  1364.     ret
  1365. VT100_INI    ENDP
  1366.  
  1367. VT100_RESET    PROC    NEAR
  1368.     call    vt100_soft_res
  1369.     call    vt100_restore
  1370.     call    vt100_modlin
  1371.     ret
  1372. VT100_RESET    ENDP
  1373.  
  1374. VT100_SOFT_RES    PROC    NEAR
  1375. ;
  1376. ; Software reset terminal (* means not supported yet)
  1377. ;  * Text cursor      On
  1378. ;    Insert/Replace   Replace
  1379. ;    Origin Mode      Absolute
  1380. ;    Autowrap         Off
  1381. ;  * Keyboard Action  Unlocked
  1382. ;    Keypad Mode      Numeric
  1383. ;    Cursor Key Mode  Normal
  1384. ;    Top Margin       1
  1385. ;    Bottom Margin    24
  1386. ;    Character Sets   default
  1387. ;    Video Character  Normal
  1388. ;
  1389.     push    ax
  1390.     push    bx
  1391. ;
  1392.     cmp    scrn_lines,21        ; 20 line mode ?
  1393.     jge    vt_soft_res1        ; ge = no
  1394.     mov    ax,vram_line_18
  1395.     mov    bx,vram_line_19
  1396.     jmp    vt_soft_res2
  1397. vt_soft_res1:
  1398.     mov    ax,vram_line_23
  1399.     mov    bx,vram_line_24
  1400. vt_soft_res2:
  1401.     mov    vram_botm_line,ax    ; bottom line
  1402.     mov    vram_last_line,bx    ; status line
  1403.     mov    ax,scrn_lines
  1404.     dec    ax
  1405.     mov    vt_lines,ax
  1406.     mov    stat_row,al
  1407.     dec    ax
  1408.     mov    vt_phys_bottom,al
  1409.     mov    ax,0
  1410.     mov    vt_phys_top,0
  1411. ;
  1412.     mov    sixel_disp_on,0        ; no sixel display
  1413.     mov    spec_mode,0        ; clear ESC/CSI/DCS mode flag
  1414.     mov    vt100_gflag,1
  1415.     push    si
  1416.     mov    si,offset def_color    ; set color to default
  1417.     call    set_cur_color
  1418.     call    vt100_color
  1419.     pop    si
  1420. ;
  1421.     mov    vt_in_stat,0        ; main screen
  1422.     mov    vt_stat_type,1
  1423. ;
  1424.     mov    ax,'..'            ; LED-clear
  1425.     mov    bx,offset LED_buff
  1426.     mov    [bx],ax
  1427.     mov    [bx+2],ax
  1428. ;
  1429.     and    vt100_flags,(not INSERT_BIT)
  1430.     and    vt100_flags,(not ORIGIN_BIT)
  1431.     and    vt100_flags,(not AUTOWRAP_BIT)
  1432.     mov    vt100_pflag,0        ; flags for printer control
  1433.     mov    ax,vt100_cursr
  1434.     mov    al,0            ; default cursor style
  1435.     mov    vt100_cursr,ax        ; cursor style
  1436.     mov    curkey_mode,0
  1437.     mov    keypad_mode,0
  1438.     mov    cur_col,0
  1439.     mov    cur_row,0
  1440.     mov    cur_save_col,0
  1441.     mov    cur_save_row,0
  1442.     mov    al,vt_nrmatr
  1443.     mov    vt_chratr,al
  1444.     mov    vt_blkatr,al
  1445.     mov    al,vt_phys_top
  1446.     mov    vt_top,al
  1447.     mov    al,vt_phys_bottom
  1448.     mov    vt_bottom,al
  1449.     mov    priv_pflg,0
  1450. ;
  1451.     mov    char_G0,CSET_JISROMAN
  1452.     mov    char_G1,CSET_DECGRAPH
  1453.     mov    char_G2,CSET_JISKATAKANA
  1454.     mov    char_G3,CSET_JISC6226
  1455. ;
  1456.     mov    vt_graph,0
  1457.     mov    char_SS,0
  1458.     mov    char_GL,offset char_G0
  1459.     mov    char_GR,offset char_G3
  1460. ;
  1461. ; Erase save area
  1462. ;
  1463.     push    es
  1464.     push    di
  1465.     cld
  1466.     mov    ax,vt_saveseg
  1467.     mov    es,ax
  1468.     mov    di,0        ; offset address
  1469.     mov    cx,0800h
  1470.     mov    ax,0020h
  1471.     rep    stosw
  1472.     mov    al,vt_blkatr
  1473.     xor    ah,ah
  1474.     mov    cx,0800h
  1475.     rep    stosw
  1476. ;
  1477.     pop    di
  1478.     pop    es
  1479. ;
  1480. ; Initialize TAB table
  1481. ;
  1482.     push    cx
  1483.     push    dx
  1484. ;
  1485.     mov    bx,offset tabstops
  1486.     mov    cx,80
  1487.     xor    ax,ax
  1488. vt_ini_t1:
  1489.     mov    dl,0
  1490.     test    ax,7
  1491.     jnz    vt_ini_t2
  1492.     mov    dl,1
  1493. vt_ini_t2:
  1494.     push    bx
  1495.     add    bx,ax
  1496.     mov    byte ptr [bx],dl
  1497.     pop    bx
  1498.     inc    ax
  1499.     loop    vt_ini_t1
  1500. ;
  1501.     pop    dx
  1502.     pop    cx
  1503. ;
  1504.     call    set_modlin        ; set Kermit modeline buffer
  1505.     call    save_cursor
  1506.     pop    bx
  1507.     pop    ax
  1508.     ret
  1509. VT100_SOFT_RES    ENDP
  1510.  
  1511. ;
  1512. ; save VT100 screen
  1513. ;
  1514. VT100_SAVE    PROC    NEAR
  1515.     push    ax
  1516.     push    cx
  1517.     push    dx
  1518.     push    ds
  1519.     push    es
  1520. ;
  1521.     cld
  1522. ;
  1523.     mov    ah,0Dh            ; stop display
  1524.     int    BIOS
  1525. ;
  1526.     mov    ax,vt_saveseg
  1527.     mov    es,ax            ; destination segment address
  1528.     mov    di,0
  1529.     mov    si,vram_line        ; set source address [06-Nov-88]
  1530.     push    si            ; save it for later use [06-Nov-88]
  1531.     mov    ax,CRT_TXT_SEG
  1532.     mov    ds,ax
  1533.     mov    cx,0800h
  1534.     rep    movsw
  1535.     pop    si            ; remember source address [06-Nov-88]
  1536.     add    si,2000h        ; attribute area
  1537.     mov    cx,0800h
  1538.     rep    movsw
  1539. ;
  1540.     pop    es
  1541.     pop    ds
  1542. ;
  1543. ; clear mode line
  1544. ;
  1545.     mov    al,vt_blkatr
  1546.     call    vt_stat_clr
  1547. ;
  1548.     mov    ah,0Ch            ; start dispay
  1549.     int    BIOS
  1550. ;
  1551.     mov    ax,vt100_cursr
  1552.     mov    al,0
  1553.     call    set_cursor        ; restore cursor attributes
  1554. ;
  1555.     mov    si,offset gnrm_color
  1556.     call    set_gpalette
  1557.     call    gdisp_off
  1558. ;
  1559.     pop    dx
  1560.     pop    cx
  1561.     pop    ax
  1562. ;
  1563.     ret
  1564. VT100_SAVE    ENDP
  1565.  
  1566. ;
  1567. ; restore VT100 screen
  1568. ;
  1569. VT100_RESTORE    PROC    NEAR
  1570.     push    ax
  1571.     push    bx
  1572.     push    cx
  1573.     push    dx
  1574.     push    ds
  1575.     push    es
  1576. ;
  1577.     cld
  1578. ;
  1579.     mov    ah,0Dh            ; stop display
  1580.     int    BIOS
  1581. ;
  1582.     mov    ax,CRT_TXT_SEG
  1583.     mov    es,ax            ; destination sagment address
  1584.     mov    di,vram_line
  1585.     push    di
  1586.     mov    ax,vt_saveseg
  1587.     mov    ds,ax
  1588.     mov    si,0
  1589.     mov    cx,0800h
  1590.     rep    movsw
  1591.     pop    di
  1592.     add    di,2000h        ; attribute area
  1593.     mov    cx,0800h
  1594.     rep    movsw
  1595. ;
  1596.     mov    ah,0Ch            ; start dispay
  1597.     int    BIOS
  1598. ;
  1599.     pop    es
  1600.     pop    ds
  1601. ;
  1602.     mov    ax,vt100_cursr
  1603.     call    set_cursor        ; set cursor attributes
  1604. ;
  1605.     call    locate_cur
  1606. ;
  1607.     call    set_gcolor
  1608.     call    gdisp_on
  1609. ;
  1610.     pop    dx
  1611.     pop    cx
  1612.     pop    bx
  1613.     pop    ax
  1614. ;
  1615.     ret
  1616. VT100_RESTORE    ENDP
  1617.  
  1618. set_termnam    proc    near
  1619.     push    ax
  1620.     push    cx
  1621.     push    si
  1622.     push    di
  1623.     push    es
  1624. ;
  1625.     mov    ax,ds
  1626.     mov    es,ax
  1627. ;  terminal type
  1628.     mov    cx,10            ; length of terminal name
  1629.     mov    si,offset nam_vt52
  1630.     cmp    flags.vtflg,ttvt52
  1631.     je    set_termnam1
  1632.     mov    si,offset nam_vt100
  1633.     cmp    flags.vtflg,ttvt100
  1634.     je    set_termnam1
  1635.     cmp    flags.vtflg,ttvt102
  1636.     je    set_termnam1
  1637.     mov    si,offset nam_tek
  1638.     cmp    flags.vtflg,tttek
  1639.     je    set_termnam1
  1640.     mov    si,offset nam_none
  1641. set_termnam1:
  1642.     mov    di,offset mode_trm
  1643.     rep    movsb
  1644. ;
  1645.     pop    es
  1646.     pop    di
  1647.     pop    si
  1648.     pop    cx
  1649.     pop    ax
  1650.     ret
  1651. set_termnam    endp
  1652. ;
  1653. set_prnstat    proc
  1654.     push    ax
  1655.     push    cx
  1656.     push    si
  1657.     push    di
  1658.     push    es
  1659. ;
  1660.     mov    ax,ds
  1661.     mov    es,ax
  1662. ;
  1663. ;  printer status
  1664. ;
  1665.     mov    cx,4
  1666.     mov    si,offset nam_nprn
  1667.     test    vt100_pflag,(AUTOPRINT_BIT+PRINTCTRL_BIT)
  1668.     jz    set_prnstat1
  1669.     mov    si,offset nam_prn
  1670. set_prnstat1:
  1671.     mov    di,offset mode_prn
  1672.     rep    movsb
  1673.     pop    es
  1674.     pop    di
  1675.     pop    si
  1676.     pop    cx
  1677.     pop    ax
  1678.     ret
  1679. set_prnstat    endp
  1680. ;
  1681. SET_MODLIN    PROC    NEAR
  1682. ; set the mode line buffer
  1683. ;
  1684.     push    es
  1685.     mov    ax,ds
  1686.     mov    es,ax
  1687. ;
  1688.     mov    al,' '
  1689.     mov    ah,trans.escchr
  1690.     cmp    ah,020h
  1691.     jge    set_modlin1
  1692.     mov    al,'^'
  1693.     or    ah,040h
  1694. set_modlin1:
  1695.     mov    word ptr mode_esc,ax
  1696.     mov    word ptr mode_hlp,ax
  1697. ;
  1698.     mov    al,vt_ourarg.baudb
  1699.     mov    si,offset unkbaud    ; Assume unknown baud.
  1700.     mov    cx,5            ; length of baud space
  1701.     cmp    al,BAUDNSIZ        ; too big?
  1702.     jnb    set_modlin2        ; yes, use default
  1703.     mul    cl
  1704.     xor    ah,ah
  1705.     add    ax,offset baudname
  1706.     mov    si,ax
  1707. set_modlin2:
  1708.     mov    di,offset mode_spd
  1709.     rep    movsb
  1710. ;
  1711.     mov    al,vt_ourarg.prt
  1712.     cmp    al,'A'
  1713.     jae    set_modlin3
  1714.     add    al,'0'            ; convert to character
  1715. set_modlin3:
  1716.     mov    mode_prt,al
  1717. ;
  1718.     mov    al,vt_ourarg.parity
  1719.     xor    ah,ah
  1720.     mov    cx,4
  1721.     imul    cl
  1722.     add    ax,offset parityname
  1723.     mov    si,ax
  1724.     mov    di,offset mode_pty
  1725.     rep    movsb
  1726. ;
  1727.     mov    si,offset lclename
  1728.     test    vt_ourarg.flgs,lclecho
  1729.     jnz    set_modlin4
  1730.     mov    si,offset remename
  1731. set_modlin4:
  1732.     mov    cx,3
  1733.     mov    di,offset mode_ech
  1734.     rep    movsb
  1735. ;
  1736.     call    set_termnam
  1737.     call    set_prnstat
  1738. ;
  1739.     mov    mode_len,MODE_LINE_LENG
  1740. ;
  1741.     pop    es
  1742.     ret
  1743. SET_MODLIN    ENDP
  1744. ;
  1745. vt_stat_clr    proc    near
  1746. ;
  1747. ; clear status line with attribute in AL.
  1748. ;
  1749.     push    bx
  1750.     push    es
  1751.     push    di
  1752.     push    si
  1753. ;
  1754.     mov    bx,ax
  1755.     cld
  1756.     mov    ax,CRT_TXT_SEG
  1757.     mov    es,ax
  1758.     mov    di,vram_last_line
  1759.     mov    cx,80
  1760.     xor    ah,ah
  1761.     mov    al,' '
  1762.     rep    stosw
  1763.     mov    di,vram_last_line
  1764.     add    di,02000h
  1765.     mov    al,bl
  1766.     mov    cx,80
  1767.     rep    stosw
  1768. ;
  1769.     mov    ax,bx
  1770.     pop    si
  1771.     pop    di
  1772.     pop    es
  1773.     pop    bx
  1774.     ret
  1775. vt_stat_clr    endp
  1776. ;
  1777. VT100_MODLIN    PROC    NEAR
  1778. ;
  1779. ; Mode line display control
  1780. ;
  1781. ; Inputs:
  1782. ;    dx    offset address of the mode line buffer;
  1783. ;        The 1st byte of the mode line buffer must contain the
  1784. ;        the number of characters in the buffer. If it is zero,
  1785. ;        the mode line is cleared.
  1786. ;
  1787.     push    ax
  1788.     push    cx
  1789.     cmp    vt_stat_type,0        ; clear status buffer ?
  1790.     jne    vt100_modlin1        ; ne=no.
  1791.     mov    al,vt_blkatr        ; attribute
  1792.     call    vt_stat_clr        ; clear the status line
  1793.     jmp    vt100_modlin_ex        ; and return
  1794. ;
  1795. vt100_modlin1:
  1796.     cmp    vt_stat_type,1        ; Kermit mode line control ?
  1797.     jne    vt100_modlin2        ; ne=no.
  1798.     test    vt_ourarg.flgs,modoff    ; mode line off ?
  1799.     jz    vt100_modlin1_1        ; z=no.
  1800.     mov    al,vt_blkatr
  1801.     call    vt_stat_clr
  1802.     jmp    vt100_modlin_ex
  1803. ;
  1804. ;  display kermit mode line
  1805. ;
  1806. vt100_modlin1_1:
  1807.     mov    al,vt_modatr
  1808.     call    vt_stat_clr
  1809. ;
  1810.     push    es
  1811.     push    di
  1812.     push    si
  1813. ;
  1814.     cld
  1815.     xor    ch,ch
  1816.     mov    cl,mode_len
  1817.     mov    si,offset mode_ker
  1818.     mov    ax,CRT_TXT_SEG
  1819.     mov    es,ax
  1820.     mov    di,vram_last_line
  1821.     xor    ah,ah
  1822. vt100_modlin1_2:
  1823.     mov    al,[si]
  1824.     mov    es:[di],ax
  1825.     inc    si
  1826.     add    di,2
  1827.     loop    vt100_modlin1_2
  1828. ;
  1829.     pop    si
  1830.     pop    di
  1831.     pop    es
  1832.     jmp    vt100_modlin_ex
  1833. ;
  1834. vt100_modlin2:
  1835. ;@@    mov    al,vt_modatr
  1836. ;@@    call    vt_stat_clr
  1837. ;
  1838. vt100_modlin_ex:
  1839.     call    locate_cur
  1840. ;
  1841.     pop    cx
  1842.     pop    ax
  1843.     ret
  1844. VT100_MODLIN    ENDP
  1845.  
  1846. VT100_COLOR    PROC    NEAR
  1847. ;
  1848. ; Change color to the value specified in [si].
  1849. ;    [si]    color index for foreground
  1850. ;    [si+1]    color index for background
  1851. ;    [si+2]    color index for highlight
  1852. ;    [si+3]    color index for modeline
  1853. ;
  1854.     push    ax
  1855.     push    cx
  1856. ;
  1857.     mov    al,[si]
  1858.     and    vt_nrmatr,1Fh        ; mask color attributes
  1859.     and    vt_chratr,1Fh
  1860.     and    vt_blkatr,1Fh
  1861.     mov    cl,5
  1862.     shl    al,cl
  1863.     or    vt_nrmatr,al
  1864.     or    vt_chratr,al
  1865.     or    vt_blkatr,al
  1866. ;
  1867.     push    di
  1868.     push    si
  1869.     mov    al,[si+1]
  1870.     xor    ah,ah
  1871.     mov    si,offset gnrm_color
  1872.     add    si,ax
  1873.     add    si,ax
  1874.     add    si,ax
  1875.     mov    di,offset gbck_color
  1876.     mov    cx,16
  1877. vt100_color1:
  1878.     mov    al,[si]
  1879.     mov    [di],al
  1880.     inc    di
  1881.     mov    al,[si+1]
  1882.     mov    [di],al
  1883.     inc    di
  1884.     mov    al,[si+2]
  1885.     mov    [di],al
  1886.     inc    di
  1887.     loop    vt100_color1
  1888.     pop    si
  1889.     pop    di
  1890. ;
  1891.     mov    al,[si+2]
  1892.     and    vt_hglatr,1Fh        ; mask color attributes
  1893.     mov    cl,5
  1894.     shl    al,cl
  1895.     or    vt_hglatr,al
  1896. ;
  1897.     mov    al,[si+3]
  1898.     and    vt_modatr,1Fh        ; mask color attributes
  1899.     mov    cl,5
  1900.     shl    al,cl
  1901.     or    vt_modatr,al
  1902. ;
  1903.     pop    cx
  1904.     pop    ax
  1905.     ret
  1906. VT100_COLOR    ENDP
  1907.  
  1908. mrsave        proc    near
  1909. ;
  1910. ; save n lines (given by CL) in roll-up buffer (circular).
  1911. ;
  1912.     push    ax
  1913.     push    cx
  1914.     push    si
  1915.     push    di
  1916.     push    ds
  1917.     push    es
  1918. ;
  1919.     xor    ch,ch        ; clear high byte of CX
  1920.     mov    si,vram_line
  1921. mrsave1:
  1922.     cmp    cx,0
  1923.     jle    mrsave3
  1924.     push    cx
  1925.     push    ds
  1926.     mov    ax,vt_rollcur    ; current roll-buffer segment
  1927.     mov    es,ax        ; destination segment address
  1928.     mov    di,0        ; destination offset address
  1929.     mov    ax,CRT_TXT_SEG
  1930.     mov    ds,ax        ; source segment address
  1931.     push    si        ; save the source offset address
  1932.     mov    cx,80        ; words per line
  1933.     rep    movsw        ; save the text area
  1934.     pop    si
  1935.     add    si,2000h    ; offset address of the attribute area
  1936.     mov    cx,80
  1937.     rep    movsw        ; save the attribute area
  1938.     sub    si,2000h    ; return to text area
  1939.     pop    ds
  1940.     pop    cx
  1941.     dec    cx
  1942.     inc    vt_rollcln    ; update lines
  1943.     add    vt_rollcur,20    ; update segment address. 20 parag. per line
  1944.     mov    ax,vt_rollfil
  1945.     cmp    ax,vt_rollmxl
  1946.     jge    mrsave2
  1947.     inc    vt_rollfil
  1948. mrsave2:
  1949.     mov    ax,vt_rollcln
  1950.     cmp    ax,vt_rollmxl    ; exceed maximum lines ?
  1951.     jl    mrsave1
  1952.     mov    ax,vt_rollseg
  1953.     mov    vt_rollcur,ax
  1954.     mov    vt_rollcln,0
  1955.     jmp    mrsave1
  1956. mrsave3:
  1957.     pop    es
  1958.     pop    ds
  1959.     pop    di
  1960.     pop    si
  1961.     pop    cx
  1962.     pop    ax
  1963.     ret
  1964. mrsave        endp
  1965.  
  1966. prn_chk    proc    near
  1967. ;
  1968. ; Check the printer port
  1969. ; carry on  -- printer not ready
  1970. ;
  1971.     push    ax
  1972.     mov    ah,ioctl
  1973.     mov    al,7            ; get output status of printer
  1974.     push    bx
  1975.     mov    bx,4            ; file handle for system printer
  1976.     int    dos
  1977.     pop    bx
  1978.      jc    prn_chk1        ; c = printer not ready
  1979.      cmp    al,0ffh            ; Ready status?
  1980.     je    prn_chk2        ; e = Ready
  1981. prn_chk1:
  1982.     call    vt_bell
  1983.     stc
  1984. prn_chk2:
  1985.     pop    ax
  1986.     ret
  1987. prn_chk    endp
  1988.  
  1989.  
  1990. VT100_RUPN    proc    near
  1991. ;
  1992. ; roll-up n lines (n is given in cx)
  1993. ; cx will be broken when return.
  1994. ; 1) copy the last line of the screen to the current save area
  1995. ; 2) decrement the save area pointer
  1996. ; 3) scroll down the screen by one line
  1997. ; 4) copy the current save area to the top of screen
  1998. ; 5) increment the number of moved lines
  1999. ;
  2000.     push    ax
  2001.     push    dx
  2002.     push    si
  2003.     push    di
  2004.     push    es
  2005. ;
  2006. vt100_rupn_1:
  2007.     cmp    cx,0
  2008.     jg    vt100_rupn_2
  2009.     jmp    vt100_rupn_ex
  2010. vt100_rupn_2:
  2011.     mov    ax,vt_rollnum
  2012.     inc    ax
  2013.     cmp    ax,vt_rollfil
  2014.     jl    vt100_rupn_3
  2015.     jmp    vt100_rupn_ex
  2016. ;
  2017. vt100_rupn_3:
  2018.     push    cx            ; save counter
  2019.     mov    ax,vt_rollcur
  2020.     mov    es,ax
  2021.     mov    di,0
  2022. ;
  2023.     push    ds
  2024. ;
  2025.     mov    ax,CRT_TXT_SEG
  2026.     mov    si,vram_botm_line
  2027.     push    si
  2028.     mov    cx,80
  2029.     mov    ds,ax
  2030.     cld
  2031.     rep    movsw
  2032.     pop    si
  2033.     add    si,2000h        ; attribute area
  2034.     mov    cx,80
  2035.     rep    movsw            ; save attributes
  2036. ;
  2037.     pop    ds
  2038. ;
  2039.     mov    cx,20            ; one line (display + attributes)
  2040.     cmp    vt_rollcln,0
  2041.     jg    vt100_rupn_4
  2042.     mov    ax,vt_rollmxl
  2043.     mov    vt_rollcln,ax
  2044.     mov    ax,vt_rollmxs
  2045.     mov    vt_rollcur,ax
  2046. vt100_rupn_4:
  2047.     dec    vt_rollcln
  2048.     mov    ax,vt_rollcln
  2049.     sub    vt_rollcur,cx
  2050. ;
  2051.     mov    cx,vram_botm_line
  2052.     sub    cx,vram_line
  2053.     mov    di,vram_last_line
  2054.     dec    di
  2055.     mov    si,vram_botm_line
  2056.     dec    si
  2057.     std
  2058.     mov    ax,CRT_TXT_SEG
  2059. ;
  2060.     push    ds
  2061. ;
  2062.     push    cx
  2063.     push    di
  2064.     push    si
  2065.     mov    ds,ax
  2066.     mov    es,ax
  2067.     std
  2068.     rep    movsb
  2069.     pop    si
  2070.     pop    di
  2071.     pop    cx
  2072.     add    si,2000h
  2073.     add    di,2000h
  2074.     rep    movsb
  2075. ;
  2076.     pop    ds
  2077.     cld
  2078. ;
  2079.     mov    di,vram_line
  2080.     mov    si,0
  2081.     mov    ax,CRT_TXT_SEG
  2082.     mov    es,ax
  2083.     mov    ax,vt_rollcur
  2084. ;
  2085.     push    ds
  2086. ;
  2087.     mov    ds,ax
  2088.     mov    cx,80
  2089.     push    di
  2090.     rep    movsw
  2091.     pop    di
  2092.     add    di,2000h
  2093.     mov    cx,80
  2094.     rep    movsw
  2095. ;
  2096.     pop    ds
  2097. ;
  2098.     inc    vt_rollnum
  2099.     pop    cx            ; restore line counter
  2100.     dec    cx
  2101.     jmp    vt100_rupn_1
  2102. ;
  2103. vt100_rupn_ex:
  2104.     pop    es
  2105.     pop    di
  2106.     pop    si
  2107.     pop    dx
  2108.     pop    ax
  2109.     ret
  2110. VT100_RUPN    endp
  2111.  
  2112. VT100_RDNN    proc    near
  2113. ;
  2114. ; roll-down n lines (n is given in CX).
  2115. ; CX will be broken when return.
  2116. ; 1) copy the top of the screen to the current save area
  2117. ; 2) increment the save area pointer
  2118. ; 3) screen scroll up one line
  2119. ; 4) copy the current save area to the bottom of the screen
  2120. ; 5) decrement the number of moved lines
  2121. ;
  2122.     push    ax
  2123.     push    dx
  2124.     push    si
  2125.     push    di
  2126.     push    es
  2127. ;
  2128. vt100_rdnn_1:
  2129.     cmp    cx,0
  2130.     jg    vt100_rdnn_2
  2131.     jmp    vt100_rdnn_ex
  2132. vt100_rdnn_2:
  2133.     mov    ax,vt_rollnum
  2134.     cmp    ax,0
  2135.     jg    vt100_rdnn_3
  2136.     jmp    vt100_rdnn_ex
  2137. ;
  2138. vt100_rdnn_3:
  2139.     push    cx            ; save line counter
  2140.     mov    ax,vt_rollcur
  2141.     mov    es,ax
  2142.     mov    di,0
  2143. ;
  2144.     push    ds
  2145. ;
  2146.     mov    ax,CRT_TXT_SEG
  2147.     mov    si,vram_line
  2148.     push    si
  2149.     mov    cx,80
  2150.     mov    ds,ax
  2151.     cld
  2152.     rep    movsw
  2153.     pop    si
  2154.     add    si,2000h        ; attribute area
  2155.     mov    cx,80
  2156.     rep    movsw            ; save attributes
  2157. ;
  2158.     pop    ds
  2159. ;  increment save-area pointer
  2160.     mov    cx,20            ; one line (display + attributes)
  2161.     inc    vt_rollcln
  2162.     add    vt_rollcur,cx
  2163.     mov    ax,vt_rollcln
  2164.     cmp    ax,vt_rollmxl
  2165.     jl    vt100_rdnn_4
  2166.     mov    vt_rollcln,0
  2167.     mov    ax,vt_rollseg
  2168.     mov    vt_rollcur,ax
  2169. vt100_rdnn_4:
  2170. ;
  2171.     mov    cx,vram_botm_line
  2172.     sub    cx,vram_line
  2173.     mov    di,vram_line
  2174.     mov    si,di
  2175.     add    si,160
  2176.     mov    ax,CRT_TXT_SEG
  2177. ;
  2178.     push    ds
  2179. ;
  2180.     push    cx
  2181.     push    di
  2182.     push    si
  2183.     mov    ds,ax
  2184.     mov    es,ax
  2185.     rep    movsb
  2186.     pop    si
  2187.     pop    di
  2188.     pop    cx
  2189.     add    si,2000h
  2190.     add    di,2000h
  2191.     rep    movsb
  2192. ;
  2193.     pop    ds
  2194. ;
  2195.     mov    di,vram_botm_line
  2196.     mov    si,0
  2197.     mov    ax,CRT_TXT_SEG
  2198.     mov    es,ax
  2199.     mov    ax,vt_rollcur
  2200. ;
  2201.     push    ds
  2202. ;
  2203.     mov    ds,ax
  2204.     mov    cx,80
  2205.     push    di
  2206.     rep    movsw
  2207.     pop    di
  2208.     add    di,2000h
  2209.     mov    cx,80
  2210.     rep    movsw
  2211. ;
  2212.     pop    ds
  2213. ;
  2214.     dec    vt_rollnum
  2215.     pop    cx            ; restore line counter
  2216.     dec    cx
  2217.     jmp    vt100_rdnn_1
  2218. ;
  2219. vt100_rdnn_ex:
  2220.     pop    es
  2221.     pop    di
  2222.     pop    si
  2223.     pop    dx
  2224.     pop    ax
  2225.     ret
  2226. VT100_RDNN    endp
  2227.  
  2228. scrn_mode    proc    near
  2229. ;
  2230. ; set screen mode to normal(AL=0)/reverse(AL=1)
  2231. ; [NOTE]
  2232. ;    registers AX and BX are broken when return
  2233. ;
  2234.     push    cx
  2235.     push    di
  2236.     push    es
  2237. ;
  2238.     mov    bx,ax
  2239.     mov    ax,CRT_TXT_SEG
  2240.     mov    es,ax
  2241.     mov    di,vram_line
  2242.     add    di,2000h
  2243.     mov    cx,1920            ; 1920 = 80 x 24
  2244.     cmp    bl,0
  2245.     je    scrn_mode0
  2246. scrn_mode1:
  2247. ;  light background dark text.
  2248.     test    vt_nrmatr,CHR_REV
  2249.     jz    scrn_mode1L
  2250.     jmp    scrn_mode3
  2251. scrn_mode1L:
  2252.     xor    BYTE PTR es:[di],CHR_REV
  2253.     add    di,2
  2254.     loop    scrn_mode1L
  2255.     or    vt_nrmatr,CHR_REV
  2256.     or    vt_chratr,CHR_REV
  2257.     or    vt_blkatr,CHR_REV
  2258.     jmp    scrn_mode3
  2259. scrn_mode0:
  2260. ;  dark background light text.
  2261.     test    vt_nrmatr,CHR_REV
  2262.     jnz    scrn_mode0L
  2263.     jmp    scrn_mode3
  2264. scrn_mode0L:
  2265.     xor    BYTE PTR es:[di],CHR_REV
  2266.     add    di,2
  2267.     loop    scrn_mode0L
  2268.     and    vt_nrmatr,NOT CHR_REV
  2269.     and    vt_chratr,NOT CHR_REV
  2270.     and    vt_blkatr,NOT CHR_REV
  2271. scrn_mode3:
  2272.     pop    es
  2273.     pop    di
  2274.     pop    cx
  2275.     ret
  2276. scrn_mode    endp
  2277.  
  2278.  
  2279. locate_cur    proc    near
  2280. ;
  2281. ; locate cursor at (cur_row,cur_col)
  2282. ;
  2283. ; [NOTE]
  2284. ;    Registers ax, bx and dx are to be broken when return.
  2285. ;
  2286.  
  2287.     mov    dh,cur_row
  2288.     mov    dl,cur_col
  2289.     call    move_cur
  2290.     mov    vt_wrap,0        ; new position clears wrap req. flag
  2291.     ret
  2292. locate_cur    endp
  2293. ;
  2294. move_cur    proc    near
  2295. ;
  2296. ;  Move cursor at (dh:row,dl:col)
  2297. ;  Registers ax, bx and dx are broken when return.
  2298. ;
  2299.     call    vram_ofs        ; get VRAM address in BX
  2300.     shr    bx,1
  2301.     cli
  2302. move_cur1:
  2303.     in    al,60h
  2304.     test    al,04h            ; test GDC status
  2305.     jz    move_cur1        ; z=not ready
  2306.     mov    al,49h
  2307.     out    62h,al
  2308.     mov    al,bl
  2309.     out    60h,al
  2310.     mov    al,bh
  2311.     out    60h,al
  2312.     sti
  2313.     ret
  2314. move_cur    endp
  2315. ;
  2316. disp_char    proc    near
  2317. ;
  2318. ; Display character in AX on the screen.
  2319. ; Cursor moves to the next character position.
  2320. ; AX:will be broken when return.
  2321. ;
  2322.     cmp    ax,00060h        ; backquote special treatment
  2323.     jne    disp_char_mod1
  2324.     mov    ax,06009h        ; for backquote
  2325.     jmp    disp_char_modx
  2326. disp_char_mod1:
  2327. ;@@    cmp    ax,0005Ch        ; backslash
  2328. ;@@    jne    disp_char_mod2
  2329. ;@@    mov    ax,000EFh
  2330. disp_char_mod2:
  2331. disp_char_modx:
  2332. ;
  2333.     push    es            ; save segment reg.
  2334.     mov    dx,CRT_TXT_SEG        ; set vram segment address
  2335.     mov    es,dx
  2336.     cmp    vt_wrap,0        ; wrap requested ?
  2337.     je    disp_char_nowrap    ; e = no.
  2338. ;
  2339.     mov    cur_col,0        ; return to left margin
  2340.     mov    bl,cur_row
  2341.     cmp    bl,vt_bottom        ; exceed bottom margin ?
  2342.     jl    disp_char_wrap1        ; l = No.
  2343.     je    disp_char_wrap2
  2344.     inc    cur_row
  2345.     mov    bl,cur_row
  2346.     cmp    bl,vt_phys_bottom
  2347.     jle    disp_char_nowrap
  2348.     mov    bl,vt_phys_bottom
  2349.     mov    cur_row,bl
  2350.     jmp    disp_char_nowrap
  2351. disp_char_wrap1:
  2352.     inc    cur_row
  2353.     jmp    disp_char_nowrap
  2354. disp_char_wrap2:
  2355.     push    ax
  2356.     mov    al,vt_top
  2357.     mov    ah,vt_bottom
  2358.     mov    cx,1
  2359.     call    scroll_up
  2360.     pop    ax
  2361. disp_char_nowrap:
  2362.     mov    dh,cur_row        ; get current cursor position
  2363.     mov    dl,cur_col
  2364.     call    vram_ofs        ; get vram offset address in bx
  2365.     mov    di,bx            ; set destination
  2366.     test    vt100_flags,INSERT_BIT    ; insert mode ?
  2367.     jz    disp_char_noins        ; z = no
  2368.     cmp    cur_col,79        ; at left margin ?
  2369.     jge    disp_char_noins        ; ge = Yes. No characters shifted
  2370.     mov    cx,79
  2371.     sub    cl,cur_col        ; get num. of chars. to be shifted
  2372.     mov    dh,cur_row
  2373.     mov    dl,79
  2374.     call    vram_ofs        ; get destination offset address
  2375.     mov    di,bx            ; set destination reg
  2376.     mov    si,bx
  2377.     sub    si,2            ; source offset address
  2378.     push    ds            ; save data-seg. reg.
  2379.     mov    dx,CRT_TXT_SEG
  2380.     mov    ds,dx
  2381.     std                ; inverse direction
  2382.     rep    movsw            ; shift the characters
  2383.     cld                ; reset direction flag
  2384.     pop    ds            ; restore data-seg. reg.
  2385. disp_char_noins:
  2386.     mov    es:[di],ax        ; put the character
  2387.     xor    ah,ah            ; clear higher bit
  2388.     mov    al,vt_chratr        ; load attribute
  2389.     add    di,02000h        ; attribute offset address
  2390.     stosw                ; put attribute and increment address
  2391.     pop    es            ; restore segment
  2392.     inc    cur_col            ; update cursor position
  2393.     mov    al,cur_col
  2394.     cmp    al,79            ; exceed right margin ?
  2395.     jbe    disp_char_loc        ; be = No.
  2396.     mov    cur_col,79        ; stay at right margin
  2397.     test    vt100_flags,AUTOWRAP_BIT    ; Autowrap enable ?
  2398.     jz    disp_char_ex        ; z = No. NoWrap
  2399.     mov    vt_wrap,1        ; wrap request
  2400.     jmp    disp_char_ex        ; all done.
  2401. disp_char_loc:
  2402.     call    locate_cur
  2403. disp_char_ex:
  2404.     ret
  2405. disp_char    endp
  2406.  
  2407. save_cursor    proc    near
  2408. ; saves
  2409. ; 1) cursor position
  2410.     mov    al,cur_row
  2411.     mov    cur_save_row,al
  2412.     mov    al,cur_col
  2413.     mov    cur_save_col,al
  2414. ; 2) graphic rendition
  2415.     mov    al,vt_graph
  2416.     mov    save_graph,al
  2417.     mov    al,vt_chrset
  2418.     mov    save_chrset,al
  2419.     mov    al,vt_chratr
  2420.     mov    save_chratr,al
  2421.     mov    al,vt_blkatr
  2422.     mov    save_blkatr,al
  2423. ;
  2424.     mov    ax,char_SS
  2425.     mov    char_save_SS,ax
  2426.     mov    ax,char_GL
  2427.     mov    char_save_GL,ax
  2428.     mov    ax,char_GR
  2429.     mov    char_save_GR,ax
  2430. ;
  2431.     mov    al,char_G0
  2432.     mov    char_save_G0,al
  2433.     mov    al,char_G1
  2434.     mov    char_save_G1,al
  2435.     mov    al,char_G2
  2436.     mov    char_save_G2,al
  2437.     mov    al,char_G3
  2438.     mov    char_save_G3,al
  2439. ; 3) state of wrap flag
  2440. ; 4) state of origin mode
  2441.     mov    al,vt100_flags
  2442.     mov    save_flags,al
  2443. ; 5) state of selective erase
  2444.     ret
  2445. save_cursor    endp
  2446.  
  2447. restore_cursor    proc    near
  2448. ; 1) state of selective erase
  2449. ; 2) state of origin mode
  2450.     and    vt100_flags,(not ORIGIN_BIT)
  2451.     mov    al,save_flags
  2452.     and    al,ORIGIN_BIT
  2453.     or    vt100_flags,al
  2454. ; 3) state of wrap flag
  2455.     and    vt100_flags,(not AUTOWRAP_BIT)
  2456.     mov    al,save_flags
  2457.     and    al,AUTOWRAP_BIT
  2458.     or    vt100_flags,al
  2459. ; 4) graphic rendition
  2460.     mov    al,save_graph
  2461.     mov    vt_graph,al
  2462.     mov    al,save_chrset
  2463.     mov    vt_chrset,al
  2464.     mov    al,save_chratr
  2465.     mov    vt_chratr,al
  2466.     mov    al,save_blkatr
  2467.     mov    vt_blkatr,al
  2468. ;
  2469.     mov    ax,char_save_SS
  2470.     mov    char_SS,ax
  2471.     mov    ax,char_save_GL
  2472.     mov    char_GL,ax
  2473.     mov    ax,char_save_GR
  2474.     mov    char_GR,ax
  2475. ;
  2476.     mov    al,char_save_G0
  2477.     mov    char_G0,al
  2478.     mov    al,char_save_G1
  2479.     mov    char_G1,al
  2480.     mov    al,char_save_G2
  2481.     mov    char_G2,al
  2482.     mov    al,char_save_G3
  2483.     mov    char_G3,al
  2484. ; 5) cursor position
  2485.     mov    al,cur_save_row
  2486.     mov    cur_row,al
  2487.     mov    al,cur_save_col
  2488.     mov    cur_col,al
  2489.     call    locate_cur
  2490.     ret
  2491. restore_cursor    endp
  2492.  
  2493. vt_dump    proc    near
  2494. ;
  2495. ; copy the one line image from es:[si] to dump buffer.
  2496. ; input
  2497. ;   ES:SI
  2498. ; outputs
  2499. ;   CX        contains number of characters.
  2500. ;   ES:SI    will be updated (points to the next line).
  2501. ;
  2502.     push    ax
  2503.     push    di
  2504. ;
  2505.     mov    dump_mode,0
  2506.     mov    di,offset dump_buffer
  2507.     mov    dump_pntr,di
  2508.     mov    cx,80
  2509. ;
  2510. vt_dump1:
  2511.     mov    ax,es:[si]
  2512.     cmp    ah,0            ; 1 byte code ?
  2513.     je    vt_dump3        ; e = yes.
  2514.     cmp    al,09h            ; ANK ?
  2515.     jne    vt_dump11        ; ne = no.
  2516.     mov    al,ah
  2517.     mov    ah,0
  2518.     jmp    vt_dump3
  2519. vt_dump11:
  2520.     cmp    dump_mode,0
  2521.     je    vt_dump12
  2522.     mov    byte ptr [di],ESCAPE
  2523.     mov    word ptr [di+1],'0)'
  2524.     add    di,3
  2525.     mov    dump_pntr,di
  2526.     mov    dump_mode,0
  2527. vt_dump12:
  2528.     add    ax,20h            ; convert to jis
  2529.     and    ax,7F7Fh        ; mask 8th bit
  2530.     call    jis2s            ; convert to shift jis
  2531.     mov    [di],al
  2532.     mov    [di+1],ah
  2533.     add    di,2
  2534.     add    si,4
  2535.     dec    cx
  2536.     mov    dump_pntr,di
  2537.     jmp    vt_dump2
  2538. vt_dump3:
  2539. ; check graphic code. It is overrap over the shift-JIS kanji code.
  2540. ; In that case, we should put the ESC seq to change the character set.
  2541.     cmp    al,80h
  2542.     jbe    vt_dump6
  2543.     cmp    al,0FCh
  2544.     ja    vt_dump6
  2545.     cmp    al,09Fh
  2546.     jbe    vt_dump5
  2547.     cmp    al,0E0h
  2548.     jb    vt_dump6
  2549. vt_dump5:
  2550.     cmp    dump_mode,0
  2551.     jne    vt_dump4
  2552.     mov    byte ptr [di],ESCAPE
  2553.     mov    word ptr [di+1],'3)'
  2554.     add    di,3
  2555.     mov    dump_pntr,di
  2556.     mov    dump_mode,1
  2557.     jmp    vt_dump4
  2558. vt_dump6:
  2559.     cmp    dump_mode,0
  2560.     je    vt_dump4
  2561.     mov    byte ptr [di],ESCAPE
  2562.     mov    word ptr [di+1],'0)'
  2563.     add    di,3
  2564.     mov    dump_pntr,di
  2565.     mov    dump_mode,0
  2566. vt_dump4:
  2567.     mov    [di],al            ; remove Kanji flag etc in ah.
  2568.     inc    di
  2569.     add    si,2
  2570.     cmp    al,' '            ; Is it blank ?
  2571.     je    vt_dump2        ; e = yes.
  2572.     mov    dump_pntr,di
  2573. vt_dump2:
  2574.     dec    cx
  2575.     jcxz    vt_dump7
  2576.     jmp    vt_dump1
  2577. ;
  2578. vt_dump7:
  2579.     mov    di,dump_pntr
  2580.     cmp    dump_mode,0
  2581.     je    vt_dump8
  2582.     mov    byte ptr [di],ESCAPE
  2583.     mov    word ptr [di+1],'0)'
  2584.     add    di,3
  2585. vt_dump8:
  2586.     mov    ax,0A0Dh        ; add CR/LF
  2587.     mov    [di],ax
  2588.     add    di,2
  2589.     mov    cx,di
  2590.     sub    cx,offset dump_buffer
  2591. ;
  2592.     pop    di
  2593.     pop    ax
  2594.     ret
  2595. vt_dump    endp
  2596.  
  2597.  
  2598. vt_prn    proc    near
  2599. ;
  2600. ; copy the one line image from es:[si] to dump buffer as a printer
  2601. ; image.
  2602. ;
  2603. ; input
  2604. ;   ES:SI
  2605. ; outputs
  2606. ;   CX        contains number of characters.
  2607. ;   ES:SI    will be updated (points to the next line).
  2608. ;
  2609.     push    ax
  2610.     push    di
  2611. ;
  2612.     mov    dump_mode,0
  2613.     mov    di,offset dump_buffer
  2614.     mov    dump_pntr,di
  2615.     mov    cx,80
  2616. ;
  2617. vt_prn1:
  2618.     mov    ax,es:[si]
  2619.     cmp    ah,0            ; 1 byte code ?
  2620.     je    vt_prn3            ; e = yes.
  2621. vt_prn11:
  2622.     cmp    dump_mode,0        ; in 2 byte mode ?
  2623.     jne    vt_prn12        ; ne = yes.
  2624.     mov    byte ptr [di],ESCAPE
  2625.     mov    byte ptr [di+1],'K'    ; Kanji mode.
  2626.     add    di,2
  2627.     mov    dump_pntr,di
  2628.     mov    dump_mode,1
  2629. vt_prn12:
  2630.     add    ax,20h            ; convert to jis
  2631.     and    ax,7F7Fh        ; mask 8th bit
  2632.     mov    [di],al
  2633.     mov    [di+1],ah
  2634.     add    di,2
  2635.     add    si,4
  2636.     dec    cx
  2637.     mov    dump_pntr,di
  2638.     jmp    vt_prn2
  2639. vt_prn3:
  2640.     cmp    dump_mode,0        ; in 1 byte mode ?
  2641.     je    vt_prn4            ; e = yes.
  2642.     mov    byte ptr [di],ESCAPE
  2643.     mov    byte ptr [di+1],'H'    ; High density pica mode.
  2644.     add    di,2
  2645.     mov    dump_pntr,di
  2646.     mov    dump_mode,0
  2647. vt_prn4:
  2648.     mov    [di],al            ; remove Kanji flag etc in ah.
  2649.     inc    di
  2650.     add    si,2
  2651.     cmp    al,' '            ; Is it blank ?
  2652.     je    vt_prn2            ; e = yes.
  2653.     mov    dump_pntr,di
  2654. vt_prn2:
  2655.     dec    cx
  2656.     jcxz    vt_prn7
  2657.     jmp    vt_prn1
  2658. ;
  2659. vt_prn7:
  2660.     mov    di,dump_pntr
  2661.     cmp    dump_mode,0
  2662.     je    vt_prn8
  2663.     mov    byte ptr [di],ESCAPE
  2664.     mov    byte ptr [di+1],'H'
  2665.     add    di,2
  2666. vt_prn8:
  2667.     mov    ax,0A0Dh        ; add CR/LF
  2668.     mov    [di],ax
  2669.     add    di,2
  2670.     mov    cx,di
  2671.     sub    cx,offset dump_buffer
  2672. ;
  2673.     pop    di
  2674.     pop    ax
  2675.     ret
  2676. vt_prn    endp
  2677.  
  2678. vt_bell    proc    near
  2679.     push    ax
  2680.     push    cx
  2681. ;
  2682.     mov    al,06h
  2683.     out    37h,al
  2684.     mov    cx,0D000h
  2685. vt_bell1:
  2686.     loop    vt_bell1
  2687.     mov    al,07h
  2688.     out    37h,al
  2689. ;
  2690.     pop    cx
  2691.     pop    ax
  2692. vt_bell    endp
  2693.  
  2694. ;---------------------------
  2695. VT100_DUMP    PROC    NEAR
  2696. ;---------------------------
  2697. ; Dump screen. This procedure dump the VT100 screen on the disk using
  2698. ; MS-DOS function 40H (int 21H).
  2699. ;
  2700. ; Inputs
  2701. ;   BX    file handle
  2702. ;
  2703. ; Outputs
  2704. ;   None
  2705. ;
  2706.     push    cx
  2707.     push    dx
  2708.     push    es
  2709.     push    si
  2710.     push    di
  2711.  
  2712.     mov    ax,CRT_TXT_SEG
  2713.     mov    es,ax
  2714.     mov    si,vram_line
  2715.     mov    cx,24
  2716. vt100_dump0:
  2717.     push    cx
  2718.     call    vt_dump
  2719.     mov    ah,WRITE2        ; write function
  2720.     mov    dx,offset dump_buffer
  2721.     int    DOS
  2722. ;
  2723.     pop    cx
  2724.     loop    vt100_dump0
  2725. ;
  2726.     pop    di
  2727.     pop    si
  2728.     pop    es
  2729.     pop    dx
  2730.     pop    cx
  2731.     ret
  2732. VT100_DUMP    ENDP
  2733.  
  2734. ;------------------------------------------------------------------------------
  2735. VT100_PRNC    PROC    NEAR
  2736. ;
  2737. ;  Printer control (Transparent printing).
  2738. ;  - Watches the control seunce CSI 4 i (turns off printer controller mode).
  2739. ;    If this sequence is found, control returns to normal terminal mode.
  2740. ;  - Until CSI 4 i sequnce is found, all the received characters are sent to
  2741. ;    the printer without displaying them on the screen except NUL, XON, XOFF,
  2742. ;    CSI 5 i and CSI 4 i.
  2743. ;
  2744.     mov    di,offset watch_buf    ; get buffer pointer
  2745.     add    di,watch_pnd        ; adjust pointer
  2746.     mov    [di],al            ; save the character
  2747.     inc    watch_pnd        ; increment the pointer
  2748. ;
  2749.     cmp    watch_lvl,0        ; normal sequnce ?
  2750.     jne    vt100_prnc_n0        ; ne = no.
  2751.     jmp    vt100_prnc_L0
  2752. vt100_prnc_n0:
  2753.     cmp    watch_lvl,1        ; next ESC ?
  2754.     jne    vt100_prnc_n1        ; ne = no.
  2755.     jmp    vt100_prnc_L1
  2756. vt100_prnc_n1:
  2757.     cmp    watch_lvl,2        ; after CSI ?
  2758.     jne    vt100_prnc_n2        ; ne = no.
  2759.     jmp    vt100_prnc_L2
  2760. vt100_prnc_n2:
  2761.     cmp    watch_lvl,3        ; final character ?
  2762.     jne    vt100_prnc_n3        ; ne = no.
  2763.     jmp    vt100_prnc_L3
  2764. vt100_prnc_n3:                ; *** if come here, PROGRAM ERROR ***
  2765.     mov    watch_lvl,0
  2766.     mov    watch_pnd,0
  2767.     jmp    vt100_prnc_OUT
  2768. ;
  2769. vt100_prnc_L0:
  2770.     mov    watch_lvl,1        ; assume ESC
  2771.     cmp    al,ESCAPE        ; ESC ?
  2772.     je    vt100_prnc_L0_1        ; e = yes.
  2773.     mov    watch_lvl,2        ; assume CSI
  2774.     cmp    al,CSI            ; CSI ?
  2775.     je    vt100_prnc_L0_1        ; e = yes.
  2776.     jmp    vt100_prnc_OUT
  2777. ;
  2778. vt100_prnc_L0_1:
  2779.     mov    di,offset watch_buf
  2780.     mov    watch_pnd,0
  2781.     mov    [di],al
  2782.     inc    watch_pnd
  2783.     jmp    vt100_prnc_ex
  2784. ;
  2785. vt100_prnc_L1:
  2786.     cmp    al,'['
  2787.     je    vt100_prnc_L1_1
  2788.     jmp    vt100_prnc_OUT
  2789. vt100_prnc_L1_1:
  2790.     mov    watch_lvl,2
  2791.     jmp    vt100_prnc_ex
  2792. ;
  2793. vt100_prnc_L2:
  2794.     mov    watch_mod,al
  2795.     cmp    al,'5'
  2796.     je    vt100_prnc_L2_1
  2797.     cmp    al,'4'
  2798.     je    vt100_prnc_L2_1
  2799.     jmp    vt100_prnc_OUT
  2800. vt100_prnc_L2_1:
  2801.     mov    watch_lvl,3
  2802.     jmp    vt100_prnc_ex
  2803. ;
  2804. vt100_prnc_L3:
  2805.     cmp    al,'i'
  2806.     jne    vt100_prnc_OUT
  2807.     mov    watch_pnd,0        ; clear pending buffer
  2808.     cmp    watch_mod,'4'        ; off the printer control ?
  2809.     jne    vt100_prnc_L3_1        ; ne = no.
  2810.     and    vt100_pflag,(not PRINTCTRL_BIT)
  2811. vt100_prnc_L3_1:
  2812.     jmp    vt100_prnc_ex
  2813. ;
  2814. vt100_prnc_OUT:
  2815.     mov    di,offset watch_buf
  2816.     mov    cx,watch_pnd
  2817. vt100_prnc_OUT1:
  2818.     mov    ah,LSTOUT
  2819.     mov    dl,[di]
  2820.     int    DOS
  2821.     jc    vt100_prnc_OUT2
  2822.     inc    di
  2823.     loop    vt100_prnc_OUT1
  2824.     mov    watch_pnd,0
  2825.     jmp    vt100_prnc_ex
  2826. ;
  2827. vt100_prnc_OUT2:
  2828.     call    vt_bell
  2829.     and    vt100_pflag,(not (AUTOPRINT_BIT+PRINTCTRL_BIT))
  2830.     mov    watch_pnd,0
  2831. ;
  2832. vt100_prnc_ex:
  2833.     xor    ah,ah
  2834.     xor    cx,cx
  2835.     ret
  2836. VT100_PRNC    ENDP
  2837.  
  2838. ;------------------------------------------------------------------------------
  2839. VT100_PRNL    PROC    NEAR
  2840. ;
  2841. ;  Print the current line on the printer
  2842. ;
  2843.     push    dx
  2844. ;
  2845.     push    bx
  2846.     mov    dh,cur_row
  2847.     mov    dl,0
  2848.     call    vram_ofs
  2849.     mov    si,bx
  2850.     pop    bx
  2851. ;
  2852.     push    es
  2853.     mov    ax,CRT_TXT_SEG
  2854.     mov    es,ax
  2855.     call    vt_prn
  2856.     pop    es
  2857. ;
  2858.     mov    di,offset dump_buffer
  2859. vt100_prnl1:
  2860.     mov    al,[di]
  2861.     call    pntchr
  2862.     jc    vt100_prnl2
  2863.     inc    di
  2864.     loop    vt100_prnl1
  2865.     jmp    vt100_prnl3
  2866. ;
  2867. vt100_prnl2:
  2868.     call    vt_bell
  2869.     and    vt100_pflag,(not (AUTOPRINT_BIT+PRINTCTRL_BIT))
  2870. ;
  2871. vt100_prnl3:
  2872. ;
  2873.     pop    dx
  2874.     ret
  2875. VT100_PRNL    ENDP
  2876.  
  2877. ;------------------------------------------------------------------------------
  2878. VT100_PRNS    PROC    NEAR
  2879. ;
  2880. ;  Print the current screen on the printer.
  2881. ;  Similar to dump.
  2882. ;
  2883.     push    cx
  2884.     push    dx
  2885.     push    es
  2886.     push    si
  2887.     push    di
  2888. ;
  2889.     test    vt100_pflag,AUTOPRINT_BIT    ; printer off?
  2890.     jnz    vt100_prns1        ; nz = no not. it is on.
  2891.     call    prn_chk            ; check the printer port
  2892.     jnc    vt100_prns1        ; nc = ready.
  2893.     jmp    vt100_prns5
  2894. ;
  2895. vt100_prns1:
  2896.     mov    ax,CRT_TXT_SEG
  2897.     mov    es,ax
  2898.     mov    si,vram_line
  2899.     mov    cx,24
  2900.     test    vt100_pflag,PRINTEXT_BIT    ; full screen printing?
  2901.     jnz    vt100_prns2        ; nz = yes.
  2902.     mov    al,vt_top        ; determine start address
  2903.     xor    ah,ah
  2904.     mov    cx,ax
  2905.     shl    ax,1
  2906.     mov    si,offset vram_line
  2907.     add    si,ax
  2908.     mov    si,[si]
  2909.     mov    al,vt_bottom
  2910.     xor    ah,ah
  2911.     xchg    ax,cx
  2912.     sub    cx,ax
  2913.     inc    cx
  2914. vt100_prns2:
  2915.     push    cx
  2916.     call    vt_prn
  2917.     mov    di,offset dump_buffer
  2918. ;
  2919. vt100_prns3:
  2920.     mov    al,[di]
  2921.     call    pntchr
  2922.     jc    vt100_prns4
  2923.     inc    di
  2924.     loop    vt100_prns3
  2925. ;
  2926.     pop    cx
  2927.     loop    vt100_prns2
  2928. ;
  2929.     test    vt100_pflag,PRINTFF_BIT    ; must print FF ?
  2930.     jz    vt100_prns5    ; z = no.
  2931.     mov    al,FF
  2932.     call    pntchr
  2933.     jc    vt100_prns4
  2934.     jmp    vt100_prns5
  2935. ;
  2936. vt100_prns4:
  2937.     call    vt_bell
  2938.     and    vt100_pflag,(not (AUTOPRINT_BIT+PRINTCTRL_BIT))
  2939. ;
  2940. vt100_prns5:
  2941.     pop    di
  2942.     pop    si
  2943.     pop    es
  2944.     pop    dx
  2945.     pop    cx
  2946.     ret
  2947. VT100_PRNS    ENDP
  2948.  
  2949. ;------------------------------------------------------------------------------
  2950. VT100        PROC    NEAR
  2951. ;
  2952. ;  The main program for VT100 emulator
  2953. ;  Inputs:
  2954. ;       AL  character code
  2955. ;  Outputs:
  2956. ;       AH  results
  2957. ;           0:Normal, in this case,
  2958. ;       CX  number of characters to be sent to communication port
  2959. ;    DS:SI  character string to be sent
  2960. ;
  2961. ;       AH  non zero means 'change to the tek4010 emulation mode'
  2962. ;           1:only change the mode. do not pass any character.
  2963. ;           2:change the mode and send the character in AL.
  2964. ;           3:change the mode and send the characters in DH and DL.
  2965. ;       DX  character pair to be sent to tek4010 emulator if AH=3.
  2966. ;    
  2967. ;------------------------------------------------------------------------------
  2968. ;
  2969. ; Character display routine in VT-100 mode
  2970. ;
  2971. vt_disp:
  2972.     mov    vt_rollnum,0
  2973. ;
  2974.     cmp    spec_mode,0        ; in special mode ?
  2975.     je    vt_disp_NRM        ; e = No. go to normal process.
  2976.     cmp    spec_mode,IN_ESC_MODE    ; in ESC sequence ?
  2977.     jne    vt_disp_01        ; ne = No. check other sequnce.
  2978.     jmp    vt_disp_inESC        ; go to ESC sequence procedure.
  2979. vt_disp_01:
  2980.     cmp    spec_mode,IN_CSI_MODE    ; in CSI sequence ?
  2981.     jne    vt_disp_02        ; ne = No. check other sequnce.
  2982.     jmp    vt_disp_inCSI        ; go to CSI sequence procedure.
  2983. vt_disp_02:
  2984.     cmp    spec_mode,IN_DCS_MODE    ; in DCS sequence ?
  2985.     jne    vt_disp_03        ; ne = No.
  2986.     jmp    vt_disp_inDCS        ; go to DCS sequence procedure.
  2987. vt_disp_03:
  2988.     mov    spec_mode,0        ; May be my program error. treate as
  2989.                     ; normal character.
  2990. ;
  2991. vt_disp_NRM:
  2992.     cmp    al,080h            ; C0/GL character ?
  2993.     jae    vt_disp_C1GR        ; ae = No.
  2994. ;
  2995. ; C0/D0 character
  2996. ;
  2997.     cmp    al,020h            ; C0 code ?
  2998.     jae    vt_disp_GL        ; ae = No. This is GL code.
  2999.     jmp    vt_disp_C0        ; do C0 control.
  3000. vt_disp_GL:
  3001.     cmp    al,07Fh            ; DEL code ?
  3002.     je    vt_disp_ex        ; e = Yes. Ignore this character.
  3003.     cmp    char_SS,0        ; single shift in progress ?
  3004.     je    vt_disp_GL2        ; e = No.
  3005.     mov    bx,char_SS        ; single shift
  3006.     jmp    disp_out        ; display character
  3007. vt_disp_GL2:
  3008.     mov    bx,char_GL        ; GL character
  3009.     jmp    disp_out        ; display character
  3010. vt_disp_ex:
  3011.     mov    ah,0            ; continue vt emulation
  3012.     mov    cx,0
  3013.     ret
  3014. ;
  3015. ; C1/GR character
  3016. ;
  3017. vt_disp_C1GR:
  3018.     cmp    al,0A0h            ; C1 code ?
  3019.     jae    vt_disp_GR        ; ae = No. This is GR code
  3020.     jmp    vt_disp_C1        ; do C1 control
  3021. vt_disp_GR:
  3022.     cmp    al,0FFh            ; 8 bit DEL code ?
  3023.     je    vt_disp_ex        ; e = Yes. Ignore this character
  3024.     and    al,07Fh
  3025.     cmp    char_SS,0        ; Single shift in progress ?
  3026.     je    vt_disp_GR2        ; e = No.
  3027.     mov    bx,char_SS        ; set single shift
  3028.     jmp    disp_out
  3029. vt_disp_GR2:
  3030.     mov    bx,char_GR        ; GR character
  3031. ;-----------------------------------
  3032. ; Display the character code.
  3033. ; Inputs:
  3034. ;   AL: Character code
  3035. ;   BX: Address of the character set
  3036. ;-----------------------------------
  3037. disp_out:
  3038.     cmp    vt_knjmode,0        ; multi-byte code in progress ?
  3039.     jne    disp_Kanji        ; ne = Yes.
  3040.     jmp    disp_out0        ; 1st byte character code.
  3041. ;
  3042. disp_Kanji:
  3043.     mov    vt_kanji2,al        ; save Kanji 2nd byte
  3044. ;
  3045. ;       test logging
  3046. ;
  3047.     cmp    vt100_lflag,(LOGCOOK_BIT+LOGENAB_BIT) ; log enabled and cooked
  3048.     jne    disp_Kanji_1            ; ne = No.
  3049.     mov    ah,vt_kanji2
  3050.     mov    al,vt_kanji1
  3051.     call    jis2s            ; convert to shift JIS
  3052.     call    outcapt                 ; log 1st byte
  3053.     xchg    ah,al
  3054.     call    outcapt            ; log 2nd byte
  3055. disp_Kanji_1:
  3056. ;
  3057. ;       Display Kanji
  3058. ;
  3059.     mov    ah,vt_kanji2        ; restore Kanji 2nd byte
  3060.     mov    al,vt_kanji1        ; restore Kanji 1st byte
  3061.     sub    ax,020h
  3062.     push    ax
  3063.     call    disp_char
  3064.     pop    ax
  3065.     or    ax,8000h
  3066.     call    disp_char
  3067.     mov    vt_knjmode,0
  3068.     mov    char_SS,0        ; reset single shift
  3069.     jmp    vt_disp_ex
  3070. ;
  3071. disp_out0:
  3072.     mov    ah,[bx]            ; Get character set number
  3073.     mov    vt_graph,ah
  3074.     xor    ah,ah
  3075.     cmp    vt_graph,CSET_JISROMAN    ; JIS roman character set ?
  3076.     jne    disp_out1
  3077.     jmp    disp_outit
  3078. disp_out1:
  3079.     cmp    vt_graph,CSET_DECGRAPH    ; DEC special graphics character set ?
  3080.     jne    disp_out2
  3081.     jmp    disp_DECGRAPH
  3082. disp_out2:
  3083.     cmp    vt_graph,CSET_JISC6226    ; JIS 2-byte Kanji code ?
  3084.     jne    disp_out3
  3085.     jmp    disp_JISC6226
  3086. disp_out3:
  3087.     cmp    vt_graph,CSET_JISKATAKANA
  3088.     jne    disp_out4
  3089.     jmp    disp_JISKATAKANA
  3090. disp_out4:
  3091.     jmp    disp_outit
  3092. ;---------------------------------------
  3093. disp_DECGRAPH:
  3094.     cmp    ax,060h
  3095.     jge    disp_DECGRAPH1
  3096.     jmp    disp_outit
  3097. disp_DECGRAPH1:
  3098.     sub    ax,060h
  3099.     mov    bx,offset vt_gset
  3100.     add    bx,ax
  3101.     mov    al,[bx]
  3102.     jmp    disp_outit
  3103. disp_JISC6226:
  3104.     mov    vt_kanji1,al
  3105.     mov    vt_knjmode,1
  3106.     jmp    vt_disp_ex
  3107. disp_JISKATAKANA:
  3108.     or    al,080h
  3109. disp_outit:
  3110.     cmp    vt100_lflag,(LOGCOOK_BIT+LOGENAB_BIT)
  3111.     jne    disp_outit_1
  3112.     call    outcapt
  3113. disp_outit_1:
  3114.     call    disp_char
  3115.     mov    char_SS,0        ; reset single shift
  3116.     jmp    vt_disp_ex
  3117. ;
  3118. ;-------------------------------------------------
  3119. ; C0 control characters
  3120. ; Note that only CAN and SUB clear ESC, CSI stage.
  3121. ;-------------------------------------------------
  3122. vt_disp_C0:
  3123.     mov    bh,vt_knjsep
  3124.     and    vt_knjmode,bh
  3125.     push    ax
  3126.     mov    bx,offset C0_func_tab    ; jump table address
  3127.     xor    ah,ah
  3128.     shl    ax,1
  3129.     add    bx,ax
  3130.     pop    ax
  3131.     jmp    [bx]
  3132. ;
  3133. ; No action
  3134. ;
  3135. vt_disp_none:
  3136.     jmp    vt_disp_ex
  3137. ;
  3138. ; BEL
  3139. ;
  3140. vt_disp_BEL:
  3141.     mov    al,06h
  3142.     out    37h,al
  3143.     mov    cx,0D000h
  3144. bell_loop:
  3145.     loop    bell_loop
  3146.     mov    al,07h
  3147.     out    37h,al
  3148.     jmp    vt_disp_ex
  3149. ;
  3150. ; BS
  3151. ;
  3152. vt_disp_BS:
  3153.     cmp    cur_col,0
  3154.     jg    vt_disp_BS_1
  3155.     jmp    vt_disp_ex
  3156. vt_disp_BS_1:
  3157.     dec    cur_col
  3158.     call    locate_cur
  3159.     jmp    vt_disp_ex
  3160. ;
  3161. ; HT
  3162. ;
  3163. vt_disp_HT:
  3164.     cmp    vt100_lflag,(LOGCOOK_BIT+LOGENAB_BIT)
  3165.     jne    vt_disp_HT0
  3166.     call    outcapt
  3167. vt_disp_HT0:
  3168.     push    bx            ; save BX register
  3169.     mov    bx,offset tabstops    ; set address of tabstops
  3170.     mov    al,cur_col        ; get current cursor position
  3171.     xor    ah,ah            ; clear higher byte
  3172.     add    bx,ax            ; tab table pointer
  3173. vt_disp_HT1:
  3174.     cmp    al,79            ; right margin ?
  3175.     jge    vt_disp_HT2        ; ge = Yes. do not move any more
  3176.     inc    al            ; move position
  3177.     inc    bx            ; update table pointer
  3178.     cmp    byte ptr [bx],0        ; TAB stop position ?
  3179.     je    vt_disp_HT1        ; e = No. increment pointer and cont.
  3180. ;
  3181. vt_disp_HT2:
  3182.     pop    bx
  3183.     mov    cur_col,al        ; save the new cursor position
  3184.     call    locate_cur        ; and move the cursor
  3185.     jmp    vt_disp_ex
  3186. ;
  3187. ; LF
  3188. ;
  3189. vt_disp_LF:
  3190.     cmp    vt100_lflag,(LOGCOOK_BIT+LOGENAB_BIT)
  3191.     jne    vt_disp_LF0
  3192.     call    outcapt
  3193. vt_disp_LF0:
  3194.     test    vt100_pflag,AUTOPRINT_BIT    ; auto-print requested ?
  3195.     jz    vt_disp_LF5    ; z = no.
  3196.     call    vt100_prnl    ; print the current line
  3197. vt_disp_LF5:
  3198.     mov    bl,vt_bottom    ; get bottom margin
  3199.     cmp    cur_row,bl
  3200.     jl    vt_disp_LF2    ; above boundary
  3201.     je    vt_disp_LF1    ; on the boundary
  3202.     inc    cur_row
  3203.     mov    bl,vt_phys_bottom
  3204.     cmp    cur_row,bl    ; screen boundary
  3205.     jle    vt_disp_LF3
  3206.     mov    cur_row,bl
  3207.     jmp    vt_disp_LF3
  3208. vt_disp_LF1:
  3209.     mov    cur_row,bl
  3210.     mov    al,vt_top
  3211.     mov    ah,vt_bottom
  3212.     mov    cx,1
  3213.     call    scroll_up
  3214.     jmp    vt_disp_LF3
  3215. vt_disp_LF2:
  3216.     inc    cur_row
  3217. vt_disp_LF3:
  3218.     test    vt100_flags,NEWLINE_BIT    ; newline enabled ?
  3219.     jz    vt_disp_LF4    ; z = no.
  3220.     mov    cur_col,0
  3221. vt_disp_LF4:
  3222.     call    locate_cur
  3223.     jmp    vt_disp_ex
  3224. ;
  3225. ; CR
  3226. ;
  3227. vt_disp_CR:
  3228.     cmp    vt100_lflag,(LOGCOOK_BIT+LOGENAB_BIT)
  3229.     jne    vt_disp_CR0
  3230.     call    outcapt
  3231. vt_disp_CR0:
  3232.     mov    cur_col,0
  3233.     call    locate_cur
  3234.     jmp    vt_disp_ex
  3235. ;
  3236. ; SO
  3237. ;
  3238. vt_disp_SO:
  3239.     mov    vt_knjmode,0        ; clear multi-byte flag
  3240.     mov    char_GL,offset char_G1
  3241.     jmp    vt_disp_ex
  3242. ;
  3243. ; SI
  3244. ;
  3245. vt_disp_SI:
  3246.     mov    vt_knjmode,0        ; clear multi-byte flag
  3247.     mov    char_GL,offset char_G0
  3248.     jmp    vt_disp_ex
  3249. ;
  3250. ; CAN
  3251. ;
  3252. vt_disp_CAN:
  3253.     mov    vt_knjmode,0        ; clear multi-byte flag
  3254.     mov    spec_mode,0        ; clear ESC/CSI seq.
  3255.     jmp    vt_disp_ex
  3256. ;
  3257. ; SUB
  3258. ;
  3259. vt_disp_SUB:
  3260.     mov    vt_knjmode,0        ; clear multi-byte flag
  3261.     mov    spec_mode,0        ; clear ESC/CSI seq.
  3262.     mov    ax,001Ah
  3263.     jmp    disp_outit        ; and display it.
  3264. ;
  3265. vt_disp_ESC:
  3266.     mov    spec_mode,in_ESC_MODE    ; enter in ESC mode
  3267.     mov    spec_stage,0        ; show that just entered
  3268.     mov    I_pnt,0
  3269.     mov    bx,offset I_buf
  3270.     mov    word ptr [bx],0
  3271.     jmp    vt_disp_ex
  3272. ;
  3273. ; GS  Enter tektronix mode if tek4010 enabled
  3274. ;
  3275. vt_disp_GS:
  3276.     test    vt100_flags,AUTOTEK_BIT
  3277.     jnz    vt_disp_GS_01
  3278.     jmp    vt_disp_ex
  3279. vt_disp_GS_01:
  3280.     mov    vt_knjmode,0        ; clear multi-byte flag
  3281.     mov    spec_mode,0
  3282.     mov    ah,2            ; pass character in AL
  3283.     mov    cx,0
  3284.     ret
  3285. ;
  3286. ;----------------------
  3287. ; C1 control characters
  3288. ;----------------------
  3289. vt_disp_C1:
  3290.     mov    bh,vt_knjsep
  3291.     and    vt_knjmode,bh        ; clear multi-byte flag
  3292.     cmp    al,084h            ; IND
  3293.     jne    vt_disp_C1_n84
  3294.     jmp    vt_C1_IND
  3295. vt_disp_C1_n84:
  3296.     cmp    al,085h            ; NEL
  3297.     jne    vt_disp_C1_n85
  3298.     jmp    vt_C1_NEL
  3299. vt_disp_C1_n85:
  3300.     cmp    al,088h            ; HTS
  3301.     jne    vt_disp_C1_n88
  3302.     jmp    vt_C1_HTS
  3303. vt_disp_C1_n88:
  3304.     cmp    al,08Dh            ; RI
  3305.     jne    vt_disp_C1_n8D
  3306.     jmp    vt_C1_RI
  3307. vt_disp_C1_n8D:
  3308.     cmp    al,08Eh            ; SS2
  3309.     jne    vt_disp_C1_n8E
  3310.     jmp    vt_C1_SS2
  3311. vt_disp_C1_n8E:
  3312.     cmp    al,08Fh            ; SS3
  3313.     jne    vt_disp_C1_n8F
  3314.     jmp    vt_C1_SS3
  3315. vt_disp_C1_n8F:
  3316.     cmp    al,090h            ; DCS
  3317.     jne    vt_disp_C1_n90
  3318.     jmp    vt_C1_DCS
  3319. vt_disp_C1_n90:
  3320.     cmp    al,09Bh            ; CSI
  3321.     jne    vt_disp_C1_n9B
  3322.     jmp    vt_C1_CSI
  3323. vt_disp_C1_n9B:
  3324.     cmp    al,09Ch            ; ST
  3325.     jne    vt_disp_C1_n9C
  3326.     jmp    vt_C1_ST
  3327. vt_disp_C1_n9C:
  3328.     jmp    vt_disp_ex
  3329. ;--------------------------------------------
  3330. vt_disp_vt52ESC:
  3331.     cmp    al,'A'
  3332.     jb    vt_disp_vt52ESC_nD
  3333.     cmp    al,'D'
  3334.     ja    vt_disp_vt52ESC_nD
  3335.     mov    WORD PTR P_buf,1
  3336.     jmp    vt_CSI_ABCD
  3337. vt_disp_vt52ESC_nD:
  3338.     cmp    al,'H'
  3339.     jne    vt_disp_vt52ESC_nH
  3340.     mov    cur_col,0
  3341.     mov    cur_row,0
  3342.     call    locate_cur
  3343.     jmp    vt_esc_done
  3344. vt_disp_vt52ESC_nH:
  3345.     cmp    al,'I'
  3346.     jne    vt_disp_vt52ESC_nI
  3347.     jmp    vt_C1_RI
  3348. vt_disp_vt52ESC_nI:
  3349.     cmp    al,'J'
  3350.     jne    vt_disp_vt52ESC_nJ
  3351.     mov    WORD PTR P_buf,0
  3352.     jmp    vt_CSI_J
  3353. vt_disp_vt52ESC_nJ:
  3354.     cmp    al,'K'
  3355.     jne    vt_disp_vt52ESC_nK
  3356.     mov    WORD PTR P_buf,0
  3357.     jmp    vt_CSI_K
  3358. vt_disp_vt52ESC_nK:
  3359.     cmp    al,'Y'
  3360.     jne    vt_disp_vt52ESC_nY
  3361.     mov    spec_stage,VT52_DCA_L
  3362. vt_disp_vt52ESC_nY:
  3363.     cmp    al,'F'            ; enter graphics mode ?
  3364.     jne    vt_disp_vt52ESC_nF
  3365.     jmp    vt_esc_done
  3366. vt_disp_vt52ESC_nF:
  3367.     cmp    al,'G'            ; leave graphics mode ?
  3368.     jne    vt_disp_vt52ESC_nG
  3369.     jmp    vt_esc_done
  3370. vt_disp_vt52ESC_nG:
  3371.     cmp    al,'W'            ; enter printer control mode ?
  3372.     jne    vt_disp_vt52ESC_nW
  3373.     jmp    vt_esc_done
  3374. vt_disp_vt52ESC_nW:
  3375.     cmp    al,'X'            ; leave printer control mode ?
  3376.     jne    vt_disp_vt52ESC_nX
  3377.     jmp    vt_esc_done
  3378. vt_disp_vt52ESC_nX:
  3379.     cmp    al,'V'            ; print cursor line ?
  3380.     jne    vt_disp_vt52ESC_nV
  3381.     jmp    vt_esc_done
  3382. vt_disp_vt52ESC_nV:
  3383. ;
  3384. ; Non VT52 sequence is interpreted as VT100 sequence.
  3385. ;
  3386.     add    al,040h        ; convert to C1
  3387.     jmp    vt_disp_c1
  3388. ;
  3389. vt_disp_vt52ESC_YL:
  3390.     xor    ah,ah
  3391.     sub    ax,32
  3392.     mov    P_buf,ax
  3393.     mov    spec_stage,VT52_DCA_C
  3394.     jmp    vt_disp_ex
  3395. ;
  3396. vt_disp_vt52ESC_YC:
  3397.     push    ax
  3398.     xor    ah,ah
  3399.     sub    ax,32
  3400.     mov    cur_col,al
  3401.     mov    ax,P_buf
  3402.     mov    cur_row,al
  3403.     call    locate_cur
  3404.     pop    ax
  3405.     jmp    vt_esc_done
  3406. ;------------------------------------------------------------------------------
  3407. ; ESC sequence analysis
  3408. ; Note that VT100 allows many C0 characters in ESC-seq.
  3409.  
  3410. vt_disp_inESC:
  3411.     cmp    al,07Eh            ; check the allowed range
  3412.     ja    vt_disp_inESCe        ; error.
  3413.     cmp    al,020h            ; normal GL character ?
  3414.     jae    vt_disp_inESC1        ; ae = yes.
  3415. ; C0 control character
  3416.     cmp    spec_stage,0        ; 1st character in ESC seq.?
  3417.     je    vt_disp_inESC0        ; e = Yes. Need check ESC FF.
  3418.     jmp    vt_disp_C0
  3419. vt_disp_inESC0:
  3420.     cmp    al,0Ch            ; FF ?
  3421.     je    vt_disp_ESC_FF        ; e = Yes. Need special treatment.
  3422.     jmp    vt_disp_C0
  3423. ;
  3424. ; ESC FF:Enter tektronix mode if tek4010 enabled
  3425. ;
  3426. vt_disp_ESC_FF:
  3427.     test    vt100_flags,AUTOTEK_BIT    ; AutoTek enabled ?
  3428.     jnz    vt_disp_ESC_FF_do    ; nz = Yes.
  3429.     jmp    vt_disp_C0
  3430. vt_disp_ESC_FF_do:
  3431.     mov    spec_mode,0        ; ESC sequnce done. [25-Jun-1990]
  3432.     mov    ah,3            ; pass character in DX
  3433.     mov    dh,ESCAPE
  3434.     mov    dl,al
  3435.     mov    cx,0
  3436.     ret
  3437. ;--------------
  3438. vt_disp_inESC1:
  3439.     cmp    spec_stage,0        ; 1st character in ESC seq.?
  3440.     jne    vt_disp_inESC2        ; ne = no, check the sequnce type
  3441.     jmp    vt_esc_1
  3442. vt_disp_inESC2:
  3443.     cmp    spec_stage,1        ; ESC with I sequence ?
  3444.     jne    vt_disp_inESC3
  3445.     jmp    vt_esc_2
  3446. vt_disp_inESC3:
  3447.     cmp    flags.vtflg,ttvt52
  3448.     jne    vt_disp_inESCe
  3449. ;
  3450.     cmp    spec_stage,VT52_DCA_L
  3451.     jne    vt_disp_inESC4
  3452.     jmp    vt_disp_VT52ESC_YL
  3453. vt_disp_inESC4:
  3454.     cmp    spec_stage,VT52_DCA_C
  3455.     jne    vt_disp_inESCe
  3456.     jmp    vt_disp_VT52ESC_YC
  3457. vt_disp_inESCe:
  3458.     mov    spec_mode,0        ; Sequence error. Clear flags and
  3459.     jmp    vt_disp_NRM        ; treat as normal case.
  3460. ;--------------------------------
  3461. ; 1st byte just after the ESC
  3462. ; AL is in 2/0 - 7/E
  3463. vt_esc_1:
  3464.     cmp    al,02Fh
  3465.     ja    vt_esc_10        ; char is in 3/0 - 7/14, i.e., single
  3466.     mov    spec_stage,1        ; set mutibyte flag
  3467.     jmp    vt_esc_I        ; and goto I-seq.
  3468. vt_esc_10:
  3469.     cmp    al,05Fh
  3470.     ja    vt_esc_do_s        ; char is in 6/0 - 7/14, i.e., single
  3471.     cmp    al,040h
  3472.     jb    vt_esc_do_s        ; char is in 3/0 - 3/15, i.e., single
  3473. ;  now AL is in 4/0 - 5/15, i.e., C1 except for a few cases
  3474.     cmp    al,'Z'            ; DECDA ?
  3475.     jne    vt_esc_11
  3476.     jmp    vt_CSI_DA
  3477. vt_esc_11:
  3478.     cmp    flags.vtflg,ttvt52    ; vt52 mode ?
  3479.     jne    vt_esc_12        ; ne = no.
  3480.     jmp    vt_disp_vt52ESC
  3481. vt_esc_12:
  3482.     add    al,040h            ; convert to C1
  3483.     jmp    vt_disp_c1        ; display the C1 character
  3484. ;--------------------------------
  3485. ; in multi-byte ESC seq.
  3486. ; AL is 2/0 - 7/E
  3487. vt_esc_2:
  3488.     cmp    al,02Fh
  3489.     jbe    vt_esc_I        ; char is in 2/0 - 2/15, i.e., I
  3490.     jmp    vt_esc_do_m        ; char is in 3/0 - 7/14, i.e., final
  3491. vt_esc_I:
  3492.     mov    bx,offset I_buf
  3493.     add    bx,I_pnt
  3494.     mov    byte ptr [bx],al
  3495.     inc    I_pnt
  3496.     jmp    vt_disp_ex
  3497. ;
  3498. vt_esc_done:
  3499. vt_CSI_done:
  3500.     mov    spec_mode,0
  3501.     jmp    vt_disp_ex
  3502. ;
  3503. ; Found the final character of the ESC sequence
  3504. ;
  3505. ; Single-byte ESC seq.
  3506. ; 3/0 - 3/15  private seq.
  3507. ; 6/0 - 7/14  standard seq.
  3508. vt_esc_do_s:
  3509.     cmp    al,6Eh
  3510.     jne    vt_esc_do_n6E
  3511.     mov    char_GL,offset char_G2
  3512.     jmp    vt_esc_done
  3513. vt_esc_do_n6E:
  3514.     cmp    al,6Fh
  3515.     jne    vt_esc_do_n6F
  3516.     mov    char_GL,offset char_G3
  3517.     jmp    vt_esc_done
  3518. vt_esc_do_n6F:
  3519.     cmp    al,7Ch
  3520.     jne    vt_esc_do_n7C
  3521.     mov    char_GR,offset char_G3
  3522.     jmp    vt_esc_done
  3523. vt_esc_do_n7C:
  3524.     cmp    al,7Dh
  3525.     jne    vt_esc_do_n7D
  3526.     mov    char_GR,offset char_G2
  3527.     jmp    vt_esc_done
  3528. vt_esc_do_n7D:
  3529.     cmp    al,7Eh
  3530.     jne    vt_esc_do_n7E
  3531.     mov    char_GR,offset char_G1
  3532.     jmp    vt_esc_done
  3533. vt_esc_do_n7E:
  3534.     cmp    al,63h            ; ESC c
  3535.     jne    vt_esc_do_n63
  3536.     call    vt100_reset
  3537.     jmp    vt_esc_done
  3538. vt_esc_do_n63:
  3539.     cmp    al,3Dh            ; ESC =
  3540.     jne    vt_esc_do_n3D
  3541.     mov    keypad_mode,1
  3542.     jmp    vt_esc_done
  3543. vt_esc_do_n3D:
  3544.     cmp    al,3Eh            ; ESC >
  3545.     jne    vt_esc_do_n3E
  3546.     mov    keypad_mode,0
  3547.     jmp    vt_esc_done
  3548. vt_esc_do_n3E:
  3549.     cmp    al,37h            ; ESC 7
  3550.     jne    vt_esc_do_n37
  3551.     call    save_cursor
  3552.     jmp    vt_esc_done
  3553. vt_esc_do_n37:
  3554.     cmp    al,38h            ; ESC 8
  3555.     jne    vt_esc_do_n38
  3556.     call    restore_cursor
  3557.     jmp    vt_esc_done
  3558. vt_esc_do_n38:
  3559.     cmp    al,3Ch            ; ESC < VT52 -> ANSI mode ?
  3560.     jne    vt_esc_do_n3C
  3561.     mov    flags.vtflg,ttvt100
  3562.     call    set_termnam
  3563.     call    vt100_modlin
  3564.     jmp    vt_esc_done
  3565. vt_esc_do_n3C:
  3566.     jmp    vt_esc_done
  3567. ;
  3568. ; Multi-byte ESC seq.
  3569. ; 3/0 - 3/15  Private seq.
  3570. ; 4/0 - 7/14  Standard seq.
  3571. vt_esc_do_m:
  3572. vt_esc_do32:
  3573.     mov    bx,offset I_buf
  3574.     mov    ah,byte ptr [bx]
  3575.     cmp    ah,24h            ; multibyte designation code ?
  3576.     jne    vt_esc_do34
  3577.     jmp    vt_desig_m
  3578. vt_esc_do34:
  3579.     cmp    ah,28h            ; singlebyte desig. code (2/8-2/15)?
  3580.     jb    vt_esc_do36        ; b = no.
  3581.     cmp    ah,2Fh            ;
  3582.     ja    vt_esc_do36        ; a = no.
  3583.     jmp    vt_desig_s
  3584. vt_esc_do36:
  3585.     cmp    al,'0'            ; Possible Select Tek mode ?
  3586.     jne    vt_esc_do37        ; ne = no
  3587.     cmp    I_pnt,2
  3588.     jne    vt_esc_do37
  3589.     cmp    ah,'%'            ; Tek4105 Select code 1st byte ?
  3590.     jne    vt_esc_do37        ; ne = no
  3591.     inc    bx            ; next int. char.
  3592.     mov    ah,byte ptr [bx]
  3593.     cmp    ah,'!'            ; Tek4105 Select code 2nd byte ?
  3594.     jne    vt_esc_do37
  3595.     mov    vt100_gflag,5        ; Tek41xx screen color
  3596.     mov    ah,1            ; enter Tek mode
  3597.     mov    cx,0
  3598.     mov    spec_mode,0        ; clear ESC/CSI seq.
  3599.     ret
  3600. vt_esc_do37:
  3601.     jmp    vt_esc_done        ; unknown
  3602. ;-------------------------------------
  3603. ; designate single byte character set
  3604. ;
  3605. vt_desig_s:
  3606.     and    ah,3
  3607.     mov    bx,offset char_G0
  3608.     add    bl,ah
  3609.     mov    ah,CSET_JISROMAN
  3610.     cmp    al,49h
  3611.     jne    vt_desig_s1
  3612.     mov    ah,CSET_JISKATAKANA
  3613.     jmp    vt_desig_s2
  3614. vt_desig_s1:
  3615.     cmp    al,30h
  3616.     jne    vt_desig_s2
  3617.     mov    ah,CSET_DECGRAPH
  3618. vt_desig_s2:
  3619.     mov    byte ptr [bx],ah
  3620.     jmp    vt_esc_done
  3621. ;
  3622. ; designate multi-byte character set.
  3623. ;
  3624. vt_desig_m:
  3625.     mov    ah,0
  3626.     cmp    I_pnt,1
  3627.     jbe    vt_desig_m1
  3628.     add    bx,1
  3629.     mov    ah,byte ptr [bx]
  3630.     and    ah,3
  3631. vt_desig_m1:
  3632.     mov    bx,offset char_G0
  3633.     add    bl,ah
  3634.     mov    ah,CSET_JISC6226
  3635.     mov    byte ptr [bx],ah
  3636.     jmp    vt_esc_done
  3637. ;----------------------------------------------------
  3638. ; Control seuence analysis
  3639. ; Note that VT100 allows C0 characters in CSI seq.
  3640. vt_disp_inCSI:
  3641.     cmp    al,07Eh            ; check the range
  3642.     ja    vt_disp_inCSIe        ; error.
  3643.     cmp    al,020h            ; C0 character ?
  3644.     jae    vt_disp_inCSI1        ; ae = no. It is GL.
  3645.     jmp    vt_disp_C0
  3646. vt_disp_inCSI1:
  3647.     cmp    spec_stage,0        ; 1st character in CSI ?
  3648.     jne    vt_disp_inCSI2        ; ne = No.
  3649.     jmp    vt_CSI_1        ; CSI with Parameters
  3650. vt_disp_inCSI2:
  3651.     cmp    spec_stage,1        ; in intermediates ?
  3652.     jne    vt_disp_inCSI3
  3653.     jmp    vt_CSI_2        ; CSI with Intermediates
  3654. vt_disp_inCSI3:
  3655. vt_disp_inCSIe:
  3656.     mov    spec_mode,0        ; clear flags and treat as normal
  3657.     jmp    vt_disp_NRM
  3658. ;
  3659. vt_disp_inCSIx:
  3660.     mov    spec_mode,0
  3661.     jmp    vt_disp_ex
  3662. ;-----------------------------------------------------
  3663. ; DCS analysis
  3664. ;-----------------------------------------------------
  3665. vt_disp_inDCS:
  3666.     cmp    spec_stage,IN_SIXEL    ; in sixel mode ?
  3667.     je    vt_disp_inSIXEL        ; e = yes.
  3668.     jmp    vt_disp_inDCS1
  3669. vt_disp_inSIXEL:
  3670.     push    ax            ; save the current char
  3671.     cmp    al,01ah            ; SUB ?
  3672.     jne    vt_disp_inSIXEL1
  3673.     mov    al,03fh            ; yes, replace it blank
  3674. vt_disp_inSIXEL1:
  3675.     call    sixel            ; call sixel emulator
  3676.     pop    ax            ; remember the character
  3677.     cmp    al,018h            ; CAN ?
  3678.     jne    vt_disp_inSIXEL2    ; ne = no.
  3679.     mov    spec_stage,0
  3680.     mov    spec_mode,0
  3681.     jmp    vt_disp_ex
  3682. vt_disp_inSIXEL2:
  3683.     cmp    al,01bh            ; ESC ?
  3684.     jne    vt_disp_inSIXEL3
  3685.     mov    spec_stage,0
  3686.     mov    spec_mode,0
  3687.     jmp    vt_disp_NRM
  3688. vt_disp_inSIXEL3:
  3689.     cmp    al,07fh
  3690.     jbe    vt_disp_inSIXELe
  3691.     mov    spec_stage,0
  3692.     mov    spec_mode,0
  3693.     jmp    vt_disp_NRM
  3694. vt_disp_inSIXELe:
  3695.     jmp    vt_disp_ex
  3696. ;
  3697. vt_disp_inDCS1:
  3698.     cmp    al,07Fh            ; check the range
  3699.     jae    vt_disp_inDCSe        ; sequence error.
  3700.     cmp    al,020h
  3701.     jb    vt_disp_inDCSe
  3702. vt_disp_inDCS2:
  3703.     jmp    vt_DCS_1
  3704. vt_disp_inDCSe:
  3705.     mov    spec_stage,0
  3706.     mov    spec_mode,0        ; sequence error.
  3707.     jmp    vt_disp_NRM
  3708. ;--------------------------
  3709. vt_DCS_do:
  3710.     cmp    al,'q'            ; sixel ?
  3711.     jne    vt_DCS_do_nq
  3712.     mov    spec_stage,IN_SIXEL
  3713.     call    sixel_in
  3714.     mov    vt100_gflag,2
  3715.     mov    sixel_disp_on,1
  3716. vt_DCS_do_nq:
  3717.     jmp    vt_disp_ex
  3718. ;----------------------------------------------------------
  3719. ; CSI & DCS sequence analysys
  3720. ;----------------------------------------------------------
  3721. vt_DCS_1:
  3722. vt_CSI_1:
  3723.     cmp    al,030h            ; Parameter (3/0-3/15) ?
  3724.     jb    vt_CSI_2
  3725.     cmp    al,03Fh
  3726.     jbe    vt_CSI_Para
  3727.     mov    spec_stage,1
  3728. vt_CSI_2:
  3729.     cmp    al,020h            ; Intermediate (2/0-2/15) ?
  3730.     jb    vt_CSI_3
  3731.     cmp    al,02Fh
  3732.     jbe    vt_CSI_Intr
  3733.     cmp    al,040h            ; Terminator (4/0-7/14) ?
  3734.     jb    vt_CSI_3
  3735.     cmp    spec_mode,IN_CSI_MODE
  3736.     jne    vt_CSI_2_1
  3737.     jmp    vt_CSI_do
  3738. vt_CSI_2_1:
  3739.     jmp    vt_DCS_do
  3740. vt_CSI_3:
  3741.     jmp    vt_CSI_done
  3742. ;
  3743. ; Parameter (3/0-3/15)
  3744. ;
  3745. vt_CSI_Para:
  3746.     cmp    al,03ah
  3747.     jae    vt_CSI_Para1
  3748.     mov    bx,offset P_buf
  3749.     add    bx,P_pnt
  3750.     mov    cx,[bx]            ; cx = previous value
  3751.     and    cx,7FFFh        ; mask private parameter flag
  3752.     mov    dx,cx
  3753.     shl    dx,1
  3754.     shl    dx,1
  3755.     add    dx,cx            ; dx = cx*5
  3756.     shl    dx,1            ; dx = (previous value)*10
  3757.     xor    ah,ah
  3758.     sub    ax,030h
  3759.     add    ax,dx            ; ax is (previous value)*10 + new
  3760.     or    ax,priv_pflg        ; set private parameter flag
  3761.     mov    [bx],ax            ; save it
  3762.     jmp    vt_disp_ex
  3763. vt_CSI_Para1:
  3764.     cmp    al,'?'            ; Private parameter ? (3/15)
  3765.     jne    vt_CSI_Para11
  3766.     mov    priv_pflg,PRIVP_FLG
  3767.     jmp    vt_disp_ex
  3768. vt_CSI_Para11:
  3769.     add    P_pnt,2            ; separator
  3770.     mov    bx,offset P_buf
  3771.     add    bx,P_pnt
  3772.     mov    word ptr [bx],0        ; clear for next parameter
  3773.     jmp    vt_disp_ex
  3774. ;
  3775. ; Intermediate (2/0-2/15)
  3776. ;
  3777. vt_CSI_Intr:
  3778.     mov    bx,offset I_buf
  3779.     add    bx,I_pnt
  3780.     mov    byte ptr [bx],al
  3781.     inc    I_pnt
  3782.     jmp    vt_disp_ex
  3783.  
  3784. ;------------------------
  3785. ; Do the control sequence
  3786. ;------------------------
  3787. vt_CSI_do:
  3788.     cmp    al,'K'
  3789.     jne    vt_CSI_do_10
  3790.     jmp    vt_CSI_K
  3791. vt_CSI_do_10:
  3792.     cmp    al,'J'
  3793.     jne    vt_CSI_do_20
  3794.     jmp    vt_CSI_J
  3795. vt_CSI_do_20:
  3796.     cmp    al,'H'
  3797.     jne    vt_CSI_do_25
  3798.     jmp    vt_CSI_H
  3799. vt_CSI_do_25:
  3800.     cmp    al,'f'
  3801.     jne    vt_CSI_do_30
  3802.     jmp    vt_CSI_H
  3803. vt_CSI_do_30:
  3804.     cmp    al,'A'
  3805.     jb    vt_CSI_do_40
  3806.     cmp    al,'D'
  3807.     ja    vt_CSI_do_40
  3808.     jmp    vt_CSI_ABCD
  3809. vt_CSI_do_40:
  3810.     cmp    al,'r'
  3811.     jne    vt_CSI_do_50
  3812.     jmp    vt_CSI_SCR
  3813. vt_CSI_do_50:
  3814.     cmp    al,'L'
  3815.     jne    vt_CSI_do_60
  3816.     jmp    vt_CSI_L
  3817. vt_CSI_do_60:
  3818.     cmp    al,'M'
  3819.     jne    vt_CSI_do_70
  3820.     jmp    vt_CSI_M
  3821. vt_CSI_do_70:
  3822.     cmp    al,'m'
  3823.     jne    vt_CSI_do_80
  3824.     jmp    vt_CSI_CATR
  3825. vt_CSI_do_80:
  3826.     cmp    al,'c'
  3827.     jne    vt_CSI_do_90
  3828.     jmp    vt_CSI_DA
  3829. vt_CSI_do_90:
  3830.     cmp    al,'h'
  3831.     jne    vt_CSI_do_100
  3832.     jmp    vt_CSI_SET_M
  3833. vt_CSI_do_100:
  3834.     cmp    al,'l'
  3835.     jne    vt_CSI_do_110
  3836.     jmp    vt_CSI_RESET_M
  3837. vt_CSI_do_110:
  3838.     cmp    al,'n'
  3839.     jne    vt_CSI_do_120
  3840.     jmp    vt_CSI_DSR
  3841. vt_CSI_do_120:
  3842.     cmp    al,'q'
  3843.     jne    vt_CSI_do_130
  3844.     jmp    vt_CSI_LED
  3845. vt_CSI_do_130:
  3846.     cmp    al,'P'
  3847.     jne    vt_CSI_do_140
  3848.     jmp    vt_CSI_DCH
  3849. vt_CSI_do_140:
  3850.     cmp    al,'@'
  3851.     jne    vt_CSI_do_150
  3852.     jmp    vt_CSI_ICH
  3853. vt_CSI_do_150:
  3854.     cmp    al,'X'
  3855.     jne    vt_CSI_do_160
  3856.     jmp    vt_CSI_ECH
  3857. vt_CSI_do_160:
  3858.     cmp    al,'g'
  3859.     jne    vt_CSI_do_170
  3860.     jmp    vt_CSI_TBC
  3861. vt_CSI_do_170:
  3862.     cmp    al,'i'
  3863.     jne    vt_CSI_do_180
  3864.     jmp    vt_CSI_PRN
  3865. vt_CSI_do_180:
  3866.     cmp    al,'}'
  3867.     jne    vt_CSI_do_190
  3868.     jmp    vt_CSI_DECSASD
  3869. vt_CSI_do_190:
  3870.     cmp    al,'~'
  3871.     jne    vt_CSI_do_200
  3872.     jmp    vt_CSI_DECSSDT
  3873. vt_CSI_do_200:
  3874. vt_CSI_do_ex:
  3875.     jmp    vt_CSI_done
  3876. ;
  3877. vt_CSI_DA:
  3878. ; Device attributes
  3879.     mov    si,offset I_am_vt52
  3880.     cmp    flags.vtflg,ttvt52
  3881.     je    vt_CSI_DA_1
  3882.     mov    si,offset I_am_vt102
  3883. vt_CSI_DA_1:
  3884.     xor    cx,cx
  3885.     mov    cl,[si]
  3886.     inc    si
  3887.     mov    spec_mode,0            ; done the sequence
  3888.     mov    ah,0
  3889.     ret
  3890. ;
  3891. vt_CSI_DSR:
  3892. ;
  3893. ; Device status report
  3894. ;     Host to VT             VT returns
  3895. ;      CSI 5 n                CSI 0 n      no mulfunction
  3896. ;                             CSI 3 n      mulfunction
  3897. ;
  3898. ;      CSI 6 n                CSI Pr;Pc R  cursor position is Pr(row)
  3899. ;                                          Pc (column)
  3900. ;
  3901.     mov    spec_mode,0        ; done the sequence
  3902.     mov    si,offset P_buf        ; get param. buff address
  3903.     mov    bx,[si]            ; get parameter value
  3904.     cmp    bx,5
  3905.     je    vt_CSI_DSR5
  3906.     cmp    bx,6
  3907.     je    vt_CSI_DSR6
  3908.     jmp    vt_CSI_do_ex
  3909. ;
  3910. vt_CSI_DSR5:
  3911.     mov    si,offset I_am_fine
  3912.     xor    cx,cx
  3913.     mov    cl,[si]
  3914.     inc    si
  3915.     mov    ah,0
  3916.     ret
  3917. vt_CSI_DSR6:
  3918.     mov    si,offset My_cursor_is
  3919.     add    si,2
  3920.     mov    cx,2
  3921. ;
  3922.     xor    ax,ax
  3923.     mov    al,cur_row
  3924.     inc    ax
  3925.     cmp    ax,100
  3926.     jb    vt_CSI_DSR61
  3927.     mov    bx,100
  3928.     div    bl
  3929.     or    al,30h
  3930.     mov    byte ptr [si],al
  3931.     inc    si
  3932.     inc    cx
  3933.     mov    al,ah
  3934.     xor    ah,ah
  3935.     jmp    vt_CSI_DSR62
  3936. vt_CSI_DSR61:
  3937.     cmp    ax,10
  3938.     jb    vt_CSI_DSR63
  3939. vt_CSI_DSR62:
  3940.     mov    bx,10
  3941.     div    bl
  3942.     or    al,30h
  3943.     mov    byte ptr [si],al
  3944.     inc    si
  3945.     inc    cx
  3946.     mov    al,ah
  3947.     xor    ah,ah
  3948. vt_CSI_DSR63:
  3949.     or    al,30h
  3950.     mov    byte ptr [si],al
  3951.     inc    si
  3952.     inc    cx
  3953. ;
  3954.     mov    byte ptr [si],';'
  3955.     inc    si
  3956.     inc    cx
  3957. ;
  3958.     xor    ax,ax
  3959.     mov    al,cur_col
  3960.     inc    ax
  3961.     cmp    ax,100
  3962.     jb    vt_CSI_DSR64
  3963.     mov    bx,100
  3964.     div    bl
  3965.     or    al,30h
  3966.     mov    byte ptr [si],al
  3967.     inc    si
  3968.     inc    cx
  3969.     mov    al,ah
  3970.     xor    ah,ah
  3971.     jmp    vt_CSI_DSR65
  3972. vt_CSI_DSR64:
  3973.     cmp    ax,10
  3974.     jb    vt_CSI_DSR66
  3975. vt_CSI_DSR65:
  3976.     mov    bx,10
  3977.     div    bl
  3978.     or    al,30h
  3979.     mov    byte ptr [si],al
  3980.     inc    si
  3981.     inc    cx
  3982.     mov    al,ah
  3983.     xor    ah,ah
  3984. vt_CSI_DSR66:
  3985.     or    al,30h
  3986.     mov    byte ptr [si],al
  3987.     inc    si
  3988.     inc    cx
  3989. ;
  3990.     mov    byte ptr [si],'R'
  3991.     inc    si
  3992.     inc    cx
  3993. ;
  3994.     mov    si,offset My_cursor_is
  3995.     mov    ah,0
  3996.     ret
  3997. ;
  3998. ; Character attributes
  3999. ;    0  All off
  4000. ;    1  Bold (Highlight)
  4001. ;    4  Underscored
  4002. ;    5  Blinking
  4003. ;    7  Reverse
  4004. ;   22  Normal intensity
  4005. ;   24  Not underlined
  4006. ;   25  Not blinking
  4007. ;   27  Positive image
  4008. ; 30-37 Foreground color = 30 + colors (colors: 1=red, 2=green, 4=blue)
  4009. ;
  4010. vt_CSI_CATR:
  4011.     push    cx
  4012.     push    si
  4013.  
  4014.     mov    si,offset P_buf
  4015.     mov    cx,P_pnt
  4016.     shr    cx,1
  4017.     inc    cx
  4018. vt_CSI_CATR1:
  4019.     mov    bx,[si]
  4020.     cmp    bx,0
  4021.     jne    vt_CSI_CATR2
  4022.     push    si
  4023.     mov    si,offset def_color    ; reset to default color
  4024.     call    set_cur_color
  4025.     call    vt100_color
  4026.     pop    si
  4027.     call    set_gcolor
  4028.     mov    al,vt_nrmatr
  4029.     mov    vt_chratr,al
  4030.     jmp    vt_CSI_CATRX
  4031. vt_CSI_CATR2:
  4032.     cmp    bx,1
  4033.     jne    vt_CSI_CATR3
  4034.     mov    al,vt_chratr            ; Bold
  4035.     and    al,01Fh
  4036.     or    al,vt_hglatr
  4037.     mov    vt_chratr,al
  4038.     jmp    vt_CSI_CATRX
  4039. vt_CSI_CATR3:
  4040.     cmp    bx,4
  4041.     jne    vt_CSI_CATR5
  4042.     or    vt_chratr,8            ; Underscored
  4043.     jmp    vt_CSI_CATRX
  4044. vt_CSI_CATR5:
  4045.     cmp    bx,5
  4046.     jne    vt_CSI_CATR7
  4047.     or    vt_chratr,2            ; Blinking
  4048.     jmp    vt_CSI_CATRX
  4049. vt_CSI_CATR7:
  4050.     cmp    bx,7
  4051.     jne    vt_CSI_CATR22
  4052.     test    vt_nrmatr,CHR_REV
  4053.     jz    vt_CSI_CATR7_1
  4054.     and    vt_chratr,(not CHR_REV)
  4055.     jmp    vt_CSI_CATRX
  4056. vt_CSI_CATR7_1:
  4057.     or    vt_chratr,CHR_REV
  4058.     jmp    vt_CSI_CATRX
  4059. vt_CSI_CATR22:
  4060.     cmp    bx,22
  4061.     jne    vt_CSI_CATR24
  4062.     jmp    vt_CSI_CATRX
  4063. vt_CSI_CATR24:
  4064.     cmp    bx,24
  4065.     jne    vt_CSI_CATR25
  4066.     and    vt_chratr,0F7h            ; not Underscored
  4067.     jmp    vt_CSI_CATRX
  4068. vt_CSI_CATR25:
  4069.     cmp    bx,25
  4070.     jne    vt_CSI_CATR27
  4071.     and    vt_chratr,0FDh            ; not blinking
  4072.     jmp    vt_CSI_CATRX
  4073. vt_CSI_CATR27:
  4074.     cmp    bx,27
  4075.     jne    vt_CSI_CATR30
  4076.     test    vt_nrmatr,CHR_REV
  4077.     jz    vt_CSI_CATR27_1
  4078.     or    vt_chratr,CHR_REV
  4079.     jmp    vt_CSI_CATRX
  4080. vt_CSI_CATR27_1:
  4081.     and    vt_chratr,(not CHR_REV)        ; positive image
  4082.     jmp    vt_CSI_CATRX
  4083. vt_CSI_CATR30:
  4084.     cmp    bx,30
  4085.     jb    vt_CSI_CATR40
  4086.     cmp    bx,37
  4087.     ja    vt_CSI_CATR40
  4088.     mov    ax,bx
  4089.     sub    ax,30
  4090.     mov    bx,offset color_index_table
  4091.     add    bx,ax
  4092.     mov    al,[bx]
  4093.     push    si
  4094.     mov    si,offset scn_color
  4095.     mov    [si],al
  4096.     call    vt100_color            ; set color
  4097.     pop    si
  4098.     jmp    vt_CSI_CATRX
  4099. vt_CSI_CATR40:
  4100.     cmp    bx,40
  4101.     jb    vt_CSI_CATRX
  4102.     cmp    bx,47
  4103.     ja    vt_CSI_CATRX
  4104.     mov    ax,bx
  4105.     sub    ax,40
  4106.     mov    bx,offset color_index_table
  4107.     add    bx,ax
  4108.     mov    al,[bx]
  4109.     push    si
  4110.     mov    si,offset scn_color
  4111.     mov    [si+1],al
  4112.     call    vt100_color
  4113.     pop    si
  4114.     call    set_gcolor
  4115. ;
  4116. vt_CSI_CATRX:
  4117.     add    si,2
  4118.     dec    cx
  4119.     jcxz    vt_CSI_CATRXX
  4120.     jmp    vt_CSI_CATR1
  4121. vt_CSI_CATRXX:
  4122.     pop    si
  4123.     pop    cx
  4124.     jmp    vt_CSI_do_ex
  4125.  
  4126. ; LED control
  4127. vt_CSI_LED:
  4128.     push    cx
  4129.     push    si
  4130.  
  4131.     mov    si,offset P_buf
  4132.     mov    cx,P_pnt
  4133.     shr    cx,1
  4134.     inc    cx
  4135. vt_CSI_LED1:
  4136.     mov    bx,[si]
  4137.     cmp    bx,0
  4138.     jb    vt_CSI_LEDX
  4139.     jne    vt_CSI_LED2
  4140.     mov    ax,'..'
  4141.     mov    bx,offset LED_buff
  4142.     mov    [bx],ax
  4143.     mov    [bx+2],ax
  4144.     jmp    vt_CSI_LED3
  4145. vt_CSI_LED2:
  4146.     cmp    bx,4
  4147.     ja    vt_CSI_LEDX
  4148.     mov    ax,bx
  4149.     dec    bx
  4150.     add    bx,offset LED_buff
  4151.     add    al,'0'
  4152.     mov    [bx],al
  4153. vt_CSI_LED3:
  4154. vt_CSI_LEDX:
  4155.     add    si,2
  4156.     loop    vt_CSI_LED1
  4157.     call    set_termnam
  4158.     call    vt100_modlin
  4159.     pop    si
  4160.     pop    cx
  4161.     jmp    vt_CSI_do_ex
  4162.  
  4163. ;
  4164. ; Set mode
  4165. ;   2  Keyboard locked
  4166. ;   4  Insert mode
  4167. ;  12  Send-Receive off
  4168. ;  20  LF is newline
  4169. ;  ?1  Cursor Key is application
  4170. ;  ?3  132 column
  4171. ;  ?4  Smooth scroll
  4172. ;  ?5  Reverse screen
  4173. ;  ?6  Origin mode relative
  4174. ;  ?7  Auto Wrap on
  4175. ;  ?8  Auto repeate on
  4176. ; ?18  Print form feed on
  4177. ; ?19  Print extent is full screen
  4178. ; ?25  Text cursor enable on
  4179. ; ?38  Tektronix graphic mode
  4180. ;
  4181. vt_CSI_SET_M:
  4182.     push    cx
  4183.     push    si
  4184.  
  4185.     mov    si,offset P_buf
  4186.     mov    cx,P_pnt
  4187.     shr    cx,1
  4188.     inc    cx
  4189. vt_CSI_SET_M0:
  4190.     mov    bx,[si]
  4191. vt_CSI_SET_M4:
  4192.     cmp    bx,4            ; 4 = Insert mode ?
  4193.     jne    vt_CSI_SET_M5        ; ne = no
  4194.     or    vt100_flags,INSERT_BIT
  4195.     jmp    vt_CSI_SET_MX
  4196. vt_CSI_SET_M5:
  4197. vt_CSI_SET_M20:
  4198.     cmp    bx,20            ; 20 = Newline mode ?
  4199.     jne    vt_CSI_SET_M21        ; ne = no
  4200.     or    vt100_flags,NEWLINE_BIT
  4201.     jmp    vt_CSI_SET_MX
  4202. vt_CSI_SET_M21:
  4203. ;
  4204. ; Private sequence
  4205. ;
  4206. vt_CSI_SET_MP1:
  4207.     cmp    bx,1+PRIVP_FLG        ; ?1 = Cursor key application ?
  4208.     jne    vt_CSI_SET_MP2        ; ne = no
  4209.     mov    curkey_mode,1
  4210.     jmp    vt_CSI_SET_MX
  4211. vt_CSI_SET_MP2:
  4212. vt_CSI_SET_MP3:
  4213.     cmp    bx,3+PRIVP_FLG        ; ?3 = 132 Column ?
  4214.     jne    vt_CSI_SET_MP4
  4215.     jmp    vt_CSI_SET_MX
  4216. vt_CSI_SET_MP4:
  4217. vt_CSI_SET_MP5:
  4218.     cmp    bx,5+PRIVP_FLG        ; ?5 = reverse screen ?
  4219.     jne    vt_CSI_SET_MP6
  4220.     mov    ax,1
  4221.     call    scrn_mode
  4222.     jmp    vt_CSI_SET_MX
  4223. vt_CSI_SET_MP6:
  4224.     cmp    bx,6+PRIVP_FLG        ; ?6 = Origin relative mode ?
  4225.     jne    vt_CSI_SET_MP7
  4226.     or    vt100_flags,ORIGIN_BIT
  4227.     mov    al,vt_top
  4228.     mov    cur_row,al
  4229.     mov    cur_col,0
  4230.     call    locate_cur
  4231.     jmp    vt_CSI_SET_MX
  4232. vt_CSI_SET_MP7:
  4233.     cmp    bx,7+PRIVP_FLG        ; ?7 = AutoWrap ?
  4234.     jne    vt_CSI_SET_MP8
  4235.     or    vt100_flags,AUTOWRAP_BIT
  4236.     jmp    vt_CSI_SET_MX
  4237. vt_CSI_SET_MP8:
  4238.     cmp    bx,18+PRIVP_FLG        ; ?18 = Print form feed
  4239.     jne    vt_CSI_SET_MP19
  4240.     or    vt100_pflag,PRINTFF_BIT
  4241.     jmp    vt_CSI_SET_MX
  4242. vt_CSI_SET_MP19:
  4243.     cmp    bx,19+PRIVP_FLG        ; ?19 = Print Extent
  4244.     jne    vt_CSI_SET_MP20
  4245.     or    vt100_pflag,PRINTEXT_BIT
  4246.     jmp    vt_CSI_SET_MX
  4247. vt_CSI_SET_MP20:
  4248. vt_CSI_SET_MP38:
  4249.     cmp    bx,38+PRIVP_FLG        ; ?38 = Tektronix mode
  4250.     jne    vt_CSI_SET_MP39
  4251.     pop    si
  4252.     pop    cx
  4253.     mov    spec_mode,0        ; done the sequence.
  4254.     mov    vt100_gflag,4        ; Tek40xx color
  4255.     mov    ah,1            ; do not pass the character
  4256.     mov    al,0
  4257.     mov    cx,0
  4258.     ret
  4259. vt_CSI_SET_MP39:
  4260. vt_CSI_SET_MX:
  4261.     add    si,2
  4262.     dec    cx
  4263.     jcxz    vt_CSI_SET_MX0
  4264.     jmp    vt_CSI_SET_M0
  4265. vt_CSI_SET_MX0:
  4266.     pop    si
  4267.     pop    cx
  4268.     jmp    vt_CSI_do_ex
  4269. ;
  4270. ; Reset mode
  4271. ;   2  Keyboard Unlocked
  4272. ;   4  Replace mode
  4273. ;  12  Send-Receive on
  4274. ;  20  LF is line feed
  4275. ;  ?1  Normal cursor key
  4276. ;  ?2  Enter VT52 mode
  4277. ;  ?3  80 column
  4278. ;  ?4  Jump scroll
  4279. ;  ?5  Normal screen
  4280. ;  ?6  Orgin mode is absolute
  4281. ;  ?7  Auto wrap off
  4282. ;  ?8  Auto repeat off
  4283. ; ?18  Print form feed off
  4284. ; ?19  Print extent is scroll region
  4285. ; ?25  Text cursor enable off
  4286. ;
  4287. vt_CSI_RESET_M:
  4288.     push    cx
  4289.     push    si
  4290.  
  4291.     mov    si,offset P_buf
  4292.     mov    cx,P_pnt
  4293.     shr    cx,1
  4294.     inc    cx
  4295. vt_CSI_RESET_M0:
  4296.     mov    bx,[si]
  4297. vt_CSI_RESET_M4:
  4298.     cmp    bx,4            ; 4 = Replace mode ?
  4299.     jne    vt_CSI_RESET_M5        ; ne = no.
  4300.     and    vt100_flags,(not INSERT_BIT)
  4301.     jmp    vt_CSI_RESET_MX
  4302. vt_CSI_RESET_M5:
  4303. vt_CSI_RESET_M20:
  4304.     cmp    bx,20            ; 20 = Linefeed mode ?
  4305.     jne    vt_CSI_RESET_M21    ; ne = no.
  4306.     and    vt100_flags,(not NEWLINE_BIT)
  4307.     jmp    vt_CSI_RESET_MX
  4308. vt_CSI_RESET_M21:
  4309. ;
  4310. ; Private sequence
  4311. ;
  4312. vt_CSI_RESET_MP1:
  4313.     cmp    bx,1+PRIVP_FLG        ; ?1 = Normal cursor key ?
  4314.     jne    vt_CSI_RESET_MP2
  4315.     mov    curkey_mode,0
  4316.     jmp    vt_CSI_RESET_MX
  4317. vt_CSI_RESET_MP2:
  4318.     cmp    bx,2+PRIVP_FLG        ; ?2 = Enter VT52 mode ?
  4319.     jne    vt_CSI_RESET_MP3
  4320.     mov    flags.vtflg,ttvt52
  4321.     call    set_termnam        ; set terminal name
  4322.     call    vt100_modlin        ; re-display mode line
  4323.     jmp    vt_CSI_RESET_MX
  4324. vt_CSI_RESET_MP3:
  4325. vt_CSI_RESET_MP5:
  4326.     cmp    bx,5+PRIVP_FLG        ; ?5 = normal screen ?
  4327.     jne    vt_CSI_RESET_MP6
  4328.     mov    ax,0
  4329.     call    scrn_mode
  4330.     jmp    vt_CSI_RESET_MX
  4331. vt_CSI_RESET_MP6:
  4332.     cmp    bx,6+PRIVP_FLG        ; ?6 = Origin absolute mode ?
  4333.     jne    vt_CSI_RESET_MP7
  4334.     and    vt100_flags,(not ORIGIN_BIT)
  4335.     mov    cur_row,0
  4336.     mov    cur_col,0
  4337.     call    locate_cur
  4338.     jmp    vt_CSI_RESET_MX
  4339. vt_CSI_RESET_MP7:
  4340.     cmp    bx,7+PRIVP_FLG
  4341.     jne    vt_CSI_RESET_MP8
  4342.     and    vt100_flags,(not AUTOWRAP_BIT)
  4343.     jmp    vt_CSI_RESET_MX
  4344. vt_CSI_RESET_MP8:
  4345.     cmp    bx,18+PRIVP_FLG
  4346.     jne    vt_CSI_RESET_MP19
  4347.     and    vt100_pflag,(not PRINTFF_BIT)
  4348.     jmp    vt_CSI_RESET_MX
  4349. vt_CSI_RESET_MP19:
  4350.     cmp    bx,19+PRIVP_FLG
  4351.     jne    vt_CSI_RESET_MP20
  4352.     and    vt100_pflag,(not PRINTEXT_BIT)
  4353.     jmp    vt_CSI_RESET_MX
  4354. vt_CSI_RESET_MP20:
  4355. vt_CSI_RESET_MX:
  4356.     add    si,2
  4357.     dec    cx
  4358.     jcxz    vt_CSI_RESET_MX0
  4359.     jmp    vt_CSI_RESET_M0
  4360. vt_CSI_RESET_MX0:
  4361.     pop    si
  4362.     pop    cx
  4363.     jmp    vt_CSI_do_ex
  4364. ;
  4365. vt_CSI_ABCD:
  4366.     mov    bx,offset P_buf
  4367.     mov    bx,[bx]
  4368.     cmp    bx,1
  4369.     jae    vt_CSI_ABCD1
  4370.     mov    bx,1
  4371. vt_CSI_ABCD1:
  4372.     cmp    al,'B'
  4373.     je    vt_CSI_CUD
  4374.     cmp    al,'C'
  4375.     je    vt_CSI_CUR
  4376.     cmp    al,'D'
  4377.     je    vt_CSI_CUL
  4378. vt_CSI_CUU:
  4379.     xor    ah,ah
  4380.     mov    al,cur_row
  4381.     sub    ax,bx
  4382.     xor    bh,bh
  4383.     mov    bl,vt_top
  4384.     cmp    ax,bx
  4385.     jge    vt_CSI_CUU1
  4386.     mov    ax,bx
  4387. vt_CSI_CUU1:
  4388.     mov    cur_row,al
  4389.     jmp    vt_CSI_ABCD_ex
  4390. vt_CSI_CUD:
  4391.     xor    ah,ah
  4392.     mov    al,cur_row
  4393.     add    ax,bx
  4394.     cmp    al,vt_bottom
  4395.     jle    vt_CSI_CUD1
  4396.     mov    al,vt_bottom
  4397. vt_CSI_CUD1:
  4398.     mov    cur_row,al
  4399.     jmp    vt_CSI_ABCD_ex
  4400. vt_CSI_CUR:
  4401.     xor    ah,ah
  4402.     mov    al,cur_col
  4403.     add    ax,bx
  4404.     cmp    ax,79
  4405.     jle    vt_CSI_CUR1
  4406.     mov    ax,79
  4407. vt_CSI_CUR1:
  4408.     mov    cur_col,al
  4409.     jmp    vt_CSI_ABCD_ex
  4410. vt_CSI_CUL:
  4411.     xor    ah,ah
  4412.     mov    al,cur_col
  4413.     sub    ax,bx
  4414.     cmp    ax,0
  4415.     jge    vt_CSI_CUL1
  4416.     mov    ax,0
  4417. vt_CSI_CUL1:
  4418.     mov    cur_col,al
  4419. vt_CSI_ABCD_ex:
  4420.     call    locate_cur
  4421.     jmp    vt_CSI_do_ex
  4422. ;
  4423. vt_CSI_K:
  4424.     mov    bx,offset P_buf
  4425.     mov    ax,[bx]
  4426.     cmp    ax,0
  4427.     jne    vt_CSI_K1
  4428.     mov    dh,cur_row
  4429.     mov    dl,cur_col
  4430.     call    vram_ofs
  4431.     mov    ax,bx
  4432.     mov    dh,cur_row
  4433.     mov    dl,79
  4434.     jmp    vt_CSI_KX
  4435. vt_CSI_K1:
  4436.     cmp    ax,1
  4437.     jne    vt_CSI_K2
  4438.     mov    dh,cur_row
  4439.     mov    dl,0
  4440.     call    vram_ofs
  4441.     mov    ax,bx
  4442.     mov    dh,cur_row
  4443.     mov    dl,cur_col
  4444.     jmp    vt_CSI_KX
  4445. vt_CSI_K2:
  4446.     cmp    ax,2
  4447.     jne    vt_CSI_K3
  4448.     mov    dh,cur_row
  4449.     mov    dl,0
  4450.     call    vram_ofs
  4451.     mov    ax,bx
  4452.     mov    dh,cur_row
  4453.     mov    dl,79
  4454.     jmp    vt_CSI_KX
  4455. vt_CSI_K3:
  4456.     jmp    vt_CSI_do_ex
  4457. vt_CSI_KX:
  4458.     call    vram_ofs
  4459.     call    vt_erase
  4460.     jmp    vt_CSI_do_ex
  4461. ;
  4462. vt_CSI_L:
  4463.     mov    al,cur_row
  4464.     cmp    al,vt_top
  4465.     jge    vt_CSI_L01
  4466.     jmp    vt_CSI_do_ex
  4467. vt_CSI_L01:
  4468.     cmp    al,vt_bottom
  4469.     jle    vt_CSI_L02
  4470.     jmp    vt_CSI_do_ex
  4471. vt_CSI_L02:
  4472.     mov    bx,offset P_buf
  4473.     mov    cx,[bx]
  4474.     cmp    cx,0
  4475.     jg    vt_CSI_L1
  4476.     mov    cx,1
  4477. vt_CSI_L1:
  4478.     mov    ah,vt_bottom
  4479.     call    scroll_down
  4480.     mov    cur_col,0
  4481.     call    locate_cur
  4482.     jmp    vt_CSI_do_ex
  4483.  
  4484. vt_CSI_M:
  4485.     mov    al,cur_row
  4486.     cmp    al,vt_top
  4487.     jge    vt_CSI_M01
  4488.     jmp    vt_CSI_do_ex
  4489. vt_CSI_M01:
  4490.     cmp    al,vt_bottom
  4491.     jle    vt_CSI_M02
  4492.     jmp    vt_CSI_do_ex
  4493. vt_CSI_M02:
  4494.     mov    bx,offset P_buf
  4495.     mov    cx,[bx]
  4496.     cmp    cx,0
  4497.     jg    vt_CSI_M1
  4498.     mov    cx,1
  4499. vt_CSI_M1:
  4500.     mov    ah,vt_bottom
  4501.     call    scroll_up
  4502.     mov    cur_col,0
  4503.     call    locate_cur
  4504.     jmp    vt_CSI_do_ex
  4505.  
  4506. vt_CSI_J:
  4507.     mov    bx,offset P_buf
  4508.     mov    ax,[bx]
  4509.     cmp    ax,0
  4510.     jg    vt_CSI_J1
  4511.     mov    dh,cur_row
  4512.     mov    dl,cur_col
  4513.     call    vram_ofs
  4514.     mov    ax,bx
  4515.     mov    dh,vt_phys_bottom
  4516.     mov    dl,79
  4517.     call    vram_ofs
  4518.     jmp    vt_CSI_JX
  4519. vt_CSI_J1:
  4520.     cmp    ax,1
  4521.     jg    vt_CSI_J2
  4522.     mov    dh,0
  4523.     mov    dl,0
  4524.     call    vram_ofs
  4525.     mov    ax,bx
  4526.     mov    dh,cur_row
  4527.     mov    dl,cur_col
  4528.     call    vram_ofs
  4529.     jmp    vt_CSI_JX
  4530. vt_CSI_J2:
  4531.     cmp    sixel_disp_on,1
  4532.     jne    vt_CSI_J2_1
  4533.     call    sixel_clear
  4534.     mov    vt100_gflag,1
  4535.     mov    sixel_disp_on,0
  4536. vt_CSI_J2_1:
  4537.     mov    dh,0
  4538.     mov    dl,0
  4539.     call    vram_ofs
  4540.     mov    ax,bx
  4541.     mov    dh,vt_phys_bottom
  4542.     mov    dl,79
  4543.     call    vram_ofs
  4544. vt_CSI_JX:
  4545.     call    vt_erase
  4546.     jmp    vt_CSI_do_ex
  4547. ;
  4548. ; Cursor Position CUP    CSI Pl ; Pc H
  4549. ;
  4550. vt_CSI_H:
  4551.     mov    bx,offset P_buf
  4552.     mov    ax,[bx]
  4553.     cmp    ax,1
  4554.     jae    vt_CSI_H1
  4555.     mov    ax,1
  4556. vt_CSI_H1:
  4557.     test    vt100_flags,ORIGIN_BIT    ; relative mode ?
  4558.     jz    vt_CSI_H2        ; z = no.
  4559.     add    al,vt_top        ; convert to absolute
  4560.     cmp    al,vt_bottom
  4561.     jbe    vt_CSI_H3
  4562.     mov    al,vt_bottom
  4563.     jmp    vt_CSI_H31
  4564. vt_CSI_H2:
  4565.     cmp    ax,vt_lines
  4566.     jbe    vt_CSI_H3
  4567.     mov    ax,vt_lines
  4568. vt_CSI_H3:
  4569.     dec    ax
  4570. vt_CSI_H31:
  4571.     mov    cur_row,al
  4572.     xor    ax,ax
  4573.     cmp    P_pnt,2
  4574.     jb    vt_CSI_H6
  4575.     mov    ax,[bx+2]
  4576.     cmp    ax,1
  4577.     jae    vt_CSI_H4
  4578.     mov    ax,1
  4579. vt_CSI_H4:
  4580.     cmp    ax,80
  4581.     jbe    vt_CSI_H5
  4582.     mov    ax,80
  4583. vt_CSI_H5:
  4584.     dec    ax
  4585. vt_CSI_H6:
  4586.     mov    cur_col,al
  4587. ;
  4588. ;    put the CR/LF for the cooked log.
  4589. ;
  4590.     cmp    vt100_lflag,(LOGCOOK_BIT+LOGENAB_BIT)
  4591.     jne    vt_CSI_H61
  4592. ;@@    cmp    al,0
  4593. ;@@    jne    vt_CSI_H61
  4594.     mov    al,0Dh        ; put CR
  4595.     call    outcapt
  4596.     mov    al,0Ah        ; put LF
  4597.     call    outcapt
  4598. vt_CSI_H61:
  4599. ;
  4600.     call    locate_cur
  4601.     jmp    vt_CSI_do_ex
  4602.  
  4603. ;
  4604. ; Chracter editing functions
  4605. ;   CSI Pn @     ICH           Inserts Pn blank characters
  4606. ;   CSI Pn P     DCH           Deletes Pn characters
  4607. ;   CSI Pn X     ECH           Erases Pn characters
  4608. ; In each function, action starts from current cursor position
  4609. ; and the cursor does not move.
  4610. ;
  4611.  
  4612. ; Insert characters (ICH) -- CSI Pn @
  4613.  
  4614. vt_CSI_ICH:
  4615. vt_CSI_ICH1:
  4616.     mov    bx,offset P_buf        ; get the address of the parameter
  4617.     mov    cx,[bx]            ; get the parameter value
  4618.     cmp    cx,0
  4619.     jg    vt_CSI_ICH2
  4620.     mov    cx,1            ; use default
  4621. vt_CSI_ICH2:
  4622.     std                ; backward direction
  4623.     mov    dl,79            ; set destination (row,col)
  4624.     mov    dh,cur_row
  4625.     call    vram_ofs
  4626.     mov    di,bx            ; set destination address
  4627.     xor    ax,ax
  4628.     mov    al,cur_col
  4629.     mov    bx,ax            ; save column position
  4630.     add    ax,cx            ; ax = cur_col + Pn
  4631.     cmp    ax,79            ; inside the right margin ?
  4632.     jle    vt_CSI_ICH3        ; le = Yes.
  4633.     mov    cx,80
  4634.     sub    cx,bx            ; cx = 80 - cur_col
  4635.     jmp    vt_CSI_ICH4
  4636. vt_CSI_ICH3:
  4637.     push    cx            ; save Pn
  4638.     mov    dx,79
  4639.     sub    dx,cx            ; dx = 79 - Pn
  4640.     mov    dh,cur_row
  4641.     call    vram_ofs        ; get VRAM offset address
  4642.     mov    si,bx            ; set source address
  4643.     mov    cx,80
  4644.     sub    cx,ax            ; cx = 80 - cur_col - Pn
  4645.     mov    ax,CRT_TXT_SEG
  4646.     push    es            ; save segment registers
  4647.     push    ds
  4648.     mov    es,ax            ; set segment registers
  4649.     mov    ds,ax
  4650.     push    si
  4651.     push    di
  4652.     push    cx
  4653.     rep    movsw            ; move the characters
  4654.     pop    cx
  4655.     pop    di
  4656.     pop    si
  4657.     add    di,2000h        ; attribute area
  4658.     add    si,2000h
  4659.     rep    movsw            ; move the attributes
  4660.     sub    di,2000h
  4661.     pop    ds
  4662.     pop    es
  4663.     pop    cx            ; restore Pn
  4664. vt_CSI_ICH4:
  4665.     push    es
  4666.     push    cx
  4667.     push    di
  4668.     mov    ax,CRT_TXT_SEG
  4669.     mov    es,ax
  4670.     mov    ax,20h            ; set blank code
  4671.     rep    stosw
  4672.     pop    di
  4673.     pop    cx
  4674.     add    di,2000h        ; attribute area
  4675.     mov    al,vt_nrmatr        ; set normal attributes
  4676.     rep    stosw
  4677.     pop    es
  4678.     cld                ; reset direction flag
  4679.     jmp    vt_CSI_do_ex
  4680.  
  4681.  
  4682. ; Delete characters (DCH) -- CSI Pn P
  4683.  
  4684. vt_CSI_DCH:
  4685. vt_CSI_DCH1:
  4686.     mov    bx,offset P_buf        ; get the address of the parameter
  4687.     mov    cx,[bx]            ; get the parameter value
  4688.     cmp    cx,0
  4689.     jg    vt_CSI_DCH2
  4690.     mov    cx,1            ; use default
  4691. vt_CSI_DCH2:
  4692.     cld
  4693.     xor    ax,ax
  4694.     mov    al,cur_col
  4695.     mov    dh,cur_row
  4696.     mov    dl,cur_col
  4697.     call    vram_ofs        ; get the destination address
  4698.     mov    di,bx            ; set the destination address
  4699.     mov    bx,ax            ; save column position
  4700.     add    ax,cx            ; ax = cur_col + Pn
  4701.     cmp    ax,79            ; inside the right margin ?
  4702.     jle    vt_CSI_DCH3        ; le = Yes.
  4703.     mov    cx,80
  4704.     sub    cx,bx            ; cx = 80 - cur_col
  4705.     jmp    vt_CSI_DCH4
  4706. vt_CSI_DCH3:
  4707.     push    cx
  4708.     mov    cx,80
  4709.     sub    cx,ax            ; cx = 80 - cur_col - Pn
  4710.     mov    dh,cur_row        ; set curosr pointer
  4711.     mov    dl,al
  4712.     call    vram_ofs        ; get VRAM offset address
  4713.     mov    si,bx            ; set the source address
  4714.     mov    ax,CRT_TXT_SEG
  4715.     push    es            ; save segment registers
  4716.     push    ds
  4717.     mov    es,ax            ; set segment registers
  4718.     mov    ds,ax
  4719.     push    si
  4720.     push    di
  4721.     push    cx
  4722.     rep    movsw            ; move the characters
  4723.     pop    cx
  4724.     pop    di
  4725.     pop    si
  4726.     add    di,2000h
  4727.     add    si,2000h
  4728.     rep    movsw            ; move the attributes
  4729.     sub    di,2000h
  4730.     pop    ds
  4731.     pop    es
  4732.     pop    cx
  4733. vt_CSI_DCH4:
  4734.     push    es
  4735.     push    cx
  4736.     push    di
  4737.     mov    ax,CRT_TXT_SEG
  4738.     mov    es,ax
  4739.     mov    ax,20h            ; set blank code
  4740.     rep    stosw
  4741.     pop    di
  4742.     pop    cx
  4743.     add    di,2000h
  4744.     mov    al,vt_blkatr        ; set blank attributes
  4745.     rep    stosw
  4746.     pop    es
  4747.     jmp    vt_CSI_do_ex
  4748.  
  4749.  
  4750. ; Erase characters (ECH) -- CSI Pn X
  4751.  
  4752. vt_CSI_ECH:
  4753. vt_CSI_ECH1:
  4754.     mov    bx,offset P_buf        ; get the address of the parameter
  4755.     mov    cx,[bx]            ; get the parameter value
  4756.     cmp    cx,0
  4757.     jg    vt_CSI_ECH2
  4758.     mov    cx,1            ; use default
  4759. vt_CSI_ECH2:
  4760.     cld
  4761.     xor    ax,ax
  4762.     mov    al,cur_col
  4763.     mov    dh,cur_row
  4764.     mov    dl,cur_col
  4765.     call    vram_ofs        ; get the destination address
  4766.     mov    di,bx            ; set the destination address
  4767.     mov    bx,ax            ; save column position
  4768.     add    ax,cx            ; ax = cur_col + Pn
  4769.     cmp    ax,79            ; inside the right margin ?
  4770.     jle    vt_CSI_ECH3        ; le = Yes.
  4771.     mov    cx,80
  4772.     sub    cx,bx            ; cx = 80 - cur_col
  4773. vt_CSI_ECH3:
  4774.     push    es
  4775.     push    cx
  4776.     push    di
  4777.     mov    ax,CRT_TXT_SEG
  4778.     mov    es,ax
  4779.     mov    ax,20h            ; set blank code
  4780.     rep    stosw
  4781.     pop    di
  4782.     pop    cx
  4783.     add    di,2000h
  4784.     mov    al,vt_nrmatr        ; set normal attributes
  4785.     rep    stosw
  4786.     pop    es
  4787.     jmp    vt_CSI_do_ex
  4788.  
  4789. ;  Tabulation Clear (TBC)
  4790. ;    CSI g
  4791. ;    CSI 0 g    Clears a horizontal tab stop at cursor position
  4792. ;    CSI 3 g    Clears all horizontal tab stops
  4793.  
  4794. vt_CSI_TBC:
  4795.     mov    bx,offset P_buf
  4796.     mov    ax,[bx]            ; get the parameter value
  4797.     cmp    ax,0            ; zero ?
  4798.     je    vt_CSI_TBC0        ; e = yes.
  4799.     cmp    ax,3            ; 3 ?
  4800.     je    vt_CSI_TBC3        ; e = yes.
  4801.     jmp    vt_CSI_do_ex        ; not supported
  4802. ;
  4803. vt_CSI_TBC0:
  4804.     xor    ax,ax
  4805.     mov    al,cur_col        ; get current cursor position
  4806.     mov    bx,offset tabstops
  4807.     add    bx,ax
  4808.     mov    byte ptr [bx],0        ; clear the tab
  4809.     jmp    vt_CSI_do_ex
  4810. ;
  4811. vt_CSI_TBC3:
  4812.     push    es
  4813.     push    di
  4814.     mov    ax,ds
  4815.     mov    es,ax            ; set destination segment
  4816.     mov    di,offset tabstops    ; set destination offset
  4817.     mov    cx,80            ; number of bytes
  4818.     mov    ax,0            ; data = 0
  4819.     cld
  4820.     rep    stosb            ; store it
  4821.     pop    di
  4822.     pop    es
  4823.     jmp    vt_CSI_do_ex
  4824.  
  4825. ;  Printer control
  4826. ;    * not implemented yet
  4827. ;    CSI i    Prints the screen (full/scroll region) display.
  4828. ;    CSI 0 i    Same as above.
  4829. ;  * CSI 4 i    Turns off printer controller mode.
  4830. ;  * CSI 5 i    Turns on printer controller mode (transparent printing).
  4831. ;    CSI ? 1 i    Prints the display line containing the cursor.
  4832. ;    CSI ? 4 i    Turns off auto print mode.
  4833. ;    CSI ? 5 i    Turns on auto print mode.
  4834. ;
  4835.  
  4836. vt_CSI_PRN:
  4837.     mov    bx,offset P_buf
  4838.     mov    ax,[bx]            ; get the parameter value
  4839.     cmp    ax,0            ; 0
  4840.     je    vt_CSI_PRN_S0        ; e = yes.
  4841.     cmp    ax,1+PRIVP_FLG        ; ?1
  4842.     je    vt_CSI_PRN_P1        ; e = yes.
  4843.     cmp    ax,4+PRIVP_FLG        ; ?4
  4844.     je    vt_CSI_PRN_P4        ; e = yes.
  4845.     cmp    ax,5+PRIVP_FLG        ; ?5 ?
  4846.     je    vt_CSI_PRN_P5        ; e = yes.
  4847.     jmp    vt_CSI_do_ex        ; not supported
  4848. ;
  4849. vt_CSI_PRN_S0:
  4850.     call    vt100_prns
  4851.     jmp    vt_CSI_do_ex
  4852. ;
  4853. vt_CSI_PRN_P1:
  4854.     test    vt100_pflag,AUTOPRINT_BIT    ; printer off?
  4855.     jnz    vt_CSI_PRN_P1_1        ; nz = no not. it is on.
  4856.     call    prn_chk            ; check the printer port
  4857.     jc    vt_CSI_PRN_P1_2        ; c = not ready.
  4858. vt_CSI_PRN_P1_1:
  4859.     call    vt100_prnl
  4860. vt_CSI_PRN_P1_2:
  4861.     jmp    vt_CSI_do_ex
  4862. ;
  4863. vt_CSI_PRN_P4:
  4864.     and    vt100_pflag,(not AUTOPRINT_BIT)    ; turns off the printer
  4865.     call    set_prnstat        ; show printer status
  4866.     call    vt100_modlin        ; re-display mode line
  4867.     jmp    vt_CSI_do_ex
  4868. ;
  4869. vt_CSI_PRN_P5:
  4870.     test    vt100_pflag,AUTOPRINT_BIT    ; printer off?
  4871.     jnz    vt_CSI_PRN_P5_1        ; nz = no not. do nothing.
  4872.     call    prn_chk            ; check the printer port
  4873.     jc    vt_CSI_PRN_P5_1        ; c = not ready.
  4874.     or    vt100_pflag,AUTOPRINT_BIT    ; turns on auto print
  4875.     call    set_prnstat            ; show printer status
  4876.     call    vt100_modlin        ; re-display mode line
  4877. vt_CSI_PRN_P5_1:
  4878.     jmp    vt_CSI_do_ex
  4879.  
  4880. ;  Set scroll region.
  4881. ;  It is NOT clear that this command affects the cursor position
  4882. ;  or not.  In my experence, cursor moves to the left-top corner of the
  4883. ;  entire screen (i.e., same as <ESC>[1;1H ).
  4884. ;  - The above statement was wrong. In ORIGIN mode, the cursor goes to
  4885. ;    left-top corner of the scroll region. Thanx for VTTEST. [01-Oct-88].
  4886. ;  - Bugs for funny scroll region are fixed. Thanx for VTTEST. [01-Oct-88].
  4887. ;  - Bug for ESC[;r is fixed. [03-Dec-88].
  4888.  
  4889. vt_CSI_SCR:
  4890.     mov    bx,offset P_buf
  4891.     cmp    P_pnt,2            ; have good number of parameters ?
  4892.     je    vt_CSI_SCR1        ; e = yes.
  4893.     ja    vt_CSI_SCR7        ; a = too many. Ignore. [03-Dec-88].
  4894.     mov    ax,[bx]
  4895.     mov    bx,vt_lines        ; set to default
  4896.     jmp    vt_CSI_SCR2
  4897. vt_CSI_SCR1:
  4898.     mov    ax,[bx]
  4899.     mov    bx,[bx+2]
  4900. vt_CSI_SCR2:
  4901.     cmp    ax,1
  4902.     jae    vt_CSI_SCR3
  4903.     mov    ax,1
  4904. vt_CSI_SCR3:
  4905.     cmp    bx,0            ; Pb = 0? [03-Dec-88]
  4906.     ja    vt_CSI_SCR31        ; a = no. [03-Dec-88]
  4907.     mov    bx,vt_lines        ; set to default. [03-Dec-88].
  4908.     jmp    vt_CSI_SCR4        ; [03-Dec-88].
  4909. vt_CSI_SCR31:                ; [03-Dec-88].
  4910.     cmp    bx,vt_lines
  4911.     jbe    vt_CSI_SCR4
  4912.     mov    bx,vt_lines
  4913. vt_CSI_SCR4:
  4914.     cmp    ax,bx            ; Pt < Pb ?
  4915.     jae    vt_CSI_SCR7        ; ae = no. Do nothing.
  4916. vt_CSI_SCR5:
  4917.     dec    ax
  4918.     dec    bx
  4919.     mov    vt_top,al
  4920.     mov    vt_bottom,bl
  4921.     test    vt100_flags,ORIGIN_BIT    ; origin relative mode ?
  4922.     jnz    vt_CSI_SCR6        ; nz = Yes. Use vt_top.
  4923.     mov    ax,0
  4924. vt_CSI_SCR6:
  4925.     mov    cur_row,al
  4926.     mov    cur_col,0
  4927.     call    locate_cur
  4928. vt_CSI_SCR7:
  4929.     jmp    vt_CSI_do_ex
  4930. ;
  4931. vt_CSI_DECSASD:
  4932.     cmp    I_pnt,1            ; requires 1 intermediate char.
  4933.     je    vt_CSI_DECSASD_1    ; e=yes, we have.
  4934.     jmp    vt_CSI_do_ex
  4935. vt_CSI_DECSASD_1:
  4936.     cmp    I_buf,'$'        ; required character ?
  4937.     je    vt_CSI_DECSASD_2    ; e=yes, we have.
  4938.     jmp    vt_CSI_do_ex
  4939. vt_CSI_DECSASD_2:
  4940.     mov    ax,P_buf        ; P_buf always has at least 0.
  4941.     cmp    ax,0
  4942.     je    vt_CSI_DECSASD_3
  4943.     jmp    vt_CSI_DECSASD_5
  4944. ;
  4945. vt_CSI_DECSASD_3:
  4946.     cmp    vt_in_stat,0        ; already in main screen ?
  4947.     jne    vt_CSI_DECSASD_4
  4948.     jmp    vt_CSI_do_ex
  4949. vt_CSI_DECSASD_4:
  4950.     mov    vt_in_stat,0
  4951.     mov    al,cur_row
  4952.     mov    stat_row,al
  4953.     mov    al,cur_col
  4954.     mov    stat_col,al
  4955.     mov    al,text_row
  4956.     mov    cur_row,al
  4957.     mov    al,text_col
  4958.     mov    cur_col,al
  4959.     mov    al,text_top
  4960.     mov    vt_top,al
  4961.     mov    al,text_bottom
  4962.     mov    vt_bottom,al
  4963.     call    locate_cur
  4964.     jmp    vt_CSI_do_ex
  4965. ;
  4966. vt_CSI_DECSASD_5:
  4967.     cmp    vt_in_stat,1        ; already in status line ?
  4968.     jne    vt_CSI_DECSASD_6
  4969.     jmp    vt_CSI_do_ex
  4970. vt_CSI_DECSASD_6:
  4971.     cmp    vt_stat_type,2        ; host writable status line ?
  4972.     je    vt_CSI_DECSASD_7    ; e=yes.
  4973.     jmp    vt_CSI_do_ex
  4974. vt_CSI_DECSASD_7:
  4975.     mov    vt_in_stat,1
  4976.     mov    al,cur_row
  4977.     mov    text_row,al
  4978.     mov    al,cur_col
  4979.     mov    text_col,al
  4980.     mov    al,vt_top
  4981.     mov    text_top,al
  4982.     mov    al,vt_bottom
  4983.     mov    text_bottom,al
  4984. ;
  4985.     mov    al,stat_col
  4986.     mov    cur_col,al
  4987.     mov    al,stat_row
  4988.     mov    cur_row,al
  4989.     mov    vt_top,al
  4990.     mov    vt_bottom,al
  4991.     call    locate_cur
  4992.     jmp    vt_CSI_do_ex
  4993. ;
  4994. vt_CSI_DECSSDT:
  4995.     cmp    I_pnt,1            ; requires 1 intermediate char.
  4996.     je    vt_CSI_DECSSDT_1    ; e=yes, we have.
  4997.     jmp    vt_CSI_do_ex
  4998. vt_CSI_DECSSDT_1:
  4999.     cmp    I_buf,'$'        ; required character ?
  5000.     je    vt_CSI_DECSSDT_2    ; e=yes, we have.
  5001.     jmp    vt_CSI_do_ex
  5002. vt_CSI_DECSSDT_2:
  5003.     mov    ax,P_buf        ; P_buf always has at least 1 param.
  5004.     cmp    ax,2            ; allowed parameter?
  5005.     jbe    vt_CSI_DECSSDT_3    ; be=yes.
  5006.     jmp    vt_CSI_do_ex
  5007. vt_CSI_DECSSDT_3:
  5008.     cmp    al,vt_stat_type        ; same type?
  5009.     jne    vt_CSI_DECSSDT_4    ; ne=no.
  5010.     jmp    vt_CSI_do_ex
  5011. vt_CSI_DECSSDT_4:
  5012.     cmp    ax,2            ; host writable ?
  5013.     jne    vt_CSI_DECSSDT_5    ; ne=no.
  5014.     push    ax
  5015.     mov    al,vt_blkatr
  5016.     call    vt_stat_clr        ; clear status line
  5017.     pop    ax
  5018.     mov    stat_col,0        ; cursor move to left margin
  5019. vt_CSI_DECSSDT_5:
  5020.     mov    vt_stat_type,al
  5021.     call    vt100_modlin
  5022.     jmp    vt_CSI_do_ex
  5023. ;
  5024. ; Erase from VRAM address AX to BX
  5025. ;
  5026. vt_erase:
  5027.     cld
  5028.     push    es
  5029.     mov    cx,bx
  5030.     sub    cx,ax
  5031.     shr    cx,1
  5032.     inc    cx
  5033.     mov    di,ax
  5034.     push    cx
  5035.     push    di
  5036.     mov    ax,CRT_TXT_SEG
  5037.     mov    es,ax
  5038.     mov    ax,0020h
  5039.     rep    stosw
  5040.     pop    di
  5041.     add    di,2000h
  5042.     pop    cx
  5043.     xor    ah,ah
  5044.     mov    al,vt_blkatr
  5045.     rep    stosw
  5046.     pop    es
  5047.     ret
  5048.  
  5049. ;-------------
  5050. ; Scroll-down
  5051. ;-------------
  5052. ; scroll down n-lines in the region [Pt,Pb].  The cursor does not move.
  5053. ;
  5054. ; Input paramters:
  5055. ;    al: top row position Pt
  5056. ;    ah: bottom row position Pb
  5057. ;    cl: number of lines n (must be > 0)
  5058. ; Registers:
  5059. ;    ax, bx, cx, dx, si, di are broken
  5060.  
  5061. scroll_down:
  5062.     mov    bl,ah
  5063.     sub    bl,al
  5064.     cmp    cl,bl            ; n <= bottom - top ?
  5065.     jle    scroll_down_2        ; yes, text remains.
  5066.     jmp    scroll_down_3        ; no text remains.
  5067. scroll_down_2:
  5068.     mov    dh,ah
  5069.     sub    dh,cl
  5070.     mov    dl,79
  5071.     call    vram_ofs
  5072.     mov    si,bx            ; si is VRAM(bottom-n,79)
  5073.     mov    dh,al
  5074.     xor    dl,dl
  5075.     call    vram_ofs
  5076.     mov    cx,si
  5077.     sub    cx,bx
  5078.     shr    cx,1            ; byte counts -> word counts
  5079.     inc    cx            ; number of words to be moved
  5080.     mov    dh,ah
  5081.     mov    dl,79
  5082.     call    vram_ofs
  5083.     mov    di,bx            ; di is VRAM(bottom,79)
  5084.     push    es
  5085.     push    ds
  5086.     mov    ax,CRT_TXT_SEG
  5087.     mov    bl,vt_blkatr        ; save attribute before ds cahnge
  5088.     mov    es,ax
  5089.     mov    ds,ax
  5090.     push    cx            ; save word count
  5091.     push    di            ; save destination address
  5092.     push    si            ; save source address
  5093.     std
  5094.     rep    movsw            ; move the text codes
  5095.     mov    cx,di
  5096.     sub    cx,si
  5097.     shr    cx,1
  5098.     mov    ax,0020h        ; fill blank
  5099.     rep    stosw
  5100. ;
  5101.     pop    si
  5102.     pop    di
  5103.     pop    cx            ; cx, si, di are restored
  5104.     add    di,2000h        ; attribute block
  5105.     add    si,2000h
  5106.     rep    movsw            ; move the attributes
  5107.     mov    cx,di
  5108.     sub    cx,si
  5109.     shr    cx,1
  5110.     mov    al,bl            ; fill attributes
  5111.     xor    ah,ah
  5112.     rep    stosw
  5113. ;
  5114.     cld
  5115.     pop    ds
  5116.     pop    es
  5117.     jmp    scroll_down_ex
  5118. scroll_down_3:
  5119.     mov    dh,al
  5120.     xor    dl,dl
  5121.     call    vram_ofs
  5122.     mov    cx,bx
  5123.     mov    dh,ah
  5124.     mov    dl,79
  5125.     call    vram_ofs
  5126.     mov    ax,cx
  5127.     call    vt_erase
  5128. scroll_down_ex:
  5129.     ret
  5130. ;
  5131. ;-----------
  5132. ; Scroll-up
  5133. ;-----------
  5134. ; scroll up n-lines in the region [Pt,Pb].  The cursor does not move.
  5135. ;
  5136. ; Input paramters:
  5137. ;    al: top row position Pt
  5138. ;    ah: bottom row position Pb (ah must be > al)
  5139. ;    cl: number of lines n (must be > 0)
  5140. ; Registers:
  5141. ;    ax, bx, cx, dx, si, di are broken
  5142.  
  5143. scroll_up:
  5144.     cmp    al,0
  5145.     jne    scroll_up_1
  5146.     call    mrsave            ; save into roll buffer
  5147. scroll_up_1:
  5148.     mov    bl,ah
  5149.     sub    bl,al
  5150.     cmp    cl,bl            ; n <= bottom - top ?
  5151.     jle    scroll_up_2        ; yes, text remains.
  5152.     jmp    scroll_up_3        ; no text remains.
  5153. scroll_up_2:
  5154.     mov    dh,al
  5155.     add    dh,cl
  5156.     xor    dl,dl
  5157.     call    vram_ofs
  5158.     mov    si,bx            ; si is VRAM(top+n,0)
  5159.     mov    dh,ah
  5160.     xor    dl,79
  5161.     call    vram_ofs
  5162.     mov    cx,bx
  5163.     sub    cx,si
  5164.     shr    cx,1            ; byte counts -> word counts
  5165.     inc    cx            ; number of words to be moved
  5166.     mov    dh,al
  5167.     xor    dl,dl
  5168.     call    vram_ofs
  5169.     mov    di,bx            ; di is VRAM(top,0)
  5170.     push    es
  5171.     push    ds
  5172.     mov    ax,CRT_TXT_SEG
  5173.     mov    bl,vt_blkatr        ; save attribute before ds cahnge
  5174.     mov    es,ax
  5175.     mov    ds,ax
  5176.     push    cx            ; save word count
  5177.     push    di            ; save destination address
  5178.     push    si            ; save source address
  5179.     cld
  5180.     rep    movsw            ; move the text codes
  5181.     mov    cx,si
  5182.     sub    cx,di
  5183.     shr    cx,1
  5184.     mov    ax,0020h        ; fill blank
  5185.     rep    stosw
  5186. ;
  5187.     pop    si
  5188.     pop    di
  5189.     pop    cx            ; cx, si, di are restored
  5190.     add    di,2000h        ; attribute block
  5191.     add    si,2000h
  5192.     rep    movsw            ; move the attributes
  5193.     mov    cx,si
  5194.     sub    cx,di
  5195.     shr    cx,1
  5196.     mov    al,bl            ; fill attributes
  5197.     xor    ah,ah
  5198.     rep    stosw
  5199. ;
  5200.     cld
  5201.     pop    ds
  5202.     pop    es
  5203.     jmp    scroll_up_ex
  5204. scroll_up_3:
  5205.     mov    dh,al
  5206.     xor    dl,dl
  5207.     call    vram_ofs
  5208.     mov    cx,bx
  5209.     mov    dh,ah
  5210.     mov    dl,79
  5211.     call    vram_ofs
  5212.     mov    ax,cx
  5213.     call    vt_erase
  5214. scroll_up_ex:
  5215.     ret
  5216.  
  5217. ;
  5218. ; Calculate VRAM offset address from (col,row)
  5219. ; Inputs:
  5220. ;   dh: row (0-vt_phys_bottom)
  5221. ;   dl: col (0-79)
  5222. ; Output:
  5223. ;   bx: VRAM offset address
  5224. ;
  5225. ; dx is broken when return
  5226.  
  5227. vram_ofs:
  5228.     xor    bx,bx
  5229.     mov    bl,dh
  5230.     shl    bx,1
  5231.     add    bx,offset vram_line
  5232.     mov    bx,[bx]
  5233.     xor    dh,dh
  5234.     shl    dl,1
  5235.     add    bx,dx
  5236.     ret
  5237.  
  5238. ; C1 8-bit control character
  5239.  
  5240. ;-----------------------------
  5241. ; Single shift 2 (8/14); ESC N
  5242. ;-----------------------------
  5243. ; Temporarily invokes G2 character set into GL for the next graphic
  5244. ; character.
  5245.  
  5246. vt_c1_SS2:
  5247.     mov    char_SS,offset char_G2
  5248.     jmp    vt_esc_done
  5249.  
  5250. ;-----------------------------
  5251. ; Single shift 3 (8/15); ESC O
  5252. ;-----------------------------
  5253. ; Temporarily invokes G3 character set into GL for the next graphic
  5254. ; character.
  5255.  
  5256. vt_c1_SS3:
  5257.     mov    char_SS,offset char_G3
  5258.     jmp    vt_esc_done
  5259.  
  5260. ;----------------------
  5261. ; Index ( 8/4 ); ESC D
  5262. ;----------------------
  5263. ; Moves the cursor down one line in the same column.  If the cursor
  5264. ; is at the bottom margin, the screen perform a scroll-up.
  5265.  
  5266. vt_c1_IND:
  5267.     mov    ah,cur_row
  5268.     cmp    ah,vt_bottom
  5269.     jl    vt_c1_IND_1
  5270.     je    vt_c1_IND_2
  5271.     jmp    vt_esc_done
  5272. vt_c1_IND_1:
  5273.     inc    ah
  5274.     mov    cur_row,ah
  5275.     call    locate_cur
  5276.     jmp    vt_esc_done
  5277. vt_c1_IND_2:
  5278.     mov    al,vt_top
  5279.     mov    cx,1
  5280.     call    scroll_up
  5281.     jmp    vt_esc_done
  5282.  
  5283. ;-------------------------------
  5284. ; Reverse index ( 8/13 ); ESC M
  5285. ;-------------------------------
  5286. ; Moves the cursor up one line in the same column.  If the cursor is
  5287. ; at the top margin, the screen performs a scroll-down.
  5288.  
  5289. vt_c1_RI:
  5290.     mov    al,cur_row
  5291.     cmp    al,vt_top
  5292.     jg    vt_c1_RI_1
  5293.     je    vt_c1_RI_2        ; [04-Aug-1989]
  5294.     cmp    al,0            ; [04-Aug-1989]
  5295.     jg    vt_c1_RI_1        ; [04-Aug-1989]
  5296.     jmp    vt_esc_done        ; [04-Aug-1989]
  5297. vt_c1_RI_1:
  5298.     dec    al
  5299.     jmp    vt_c1_RI_3
  5300. vt_c1_RI_2:
  5301.     mov    al,vt_top
  5302.     mov    ah,vt_bottom
  5303.     mov    cx,1
  5304.     call    scroll_down
  5305.     mov    al,vt_top
  5306. vt_c1_RI_3:
  5307.     mov    cur_row,al
  5308.     call    locate_cur
  5309.     jmp    vt_esc_done
  5310.  
  5311. ;--------------------------
  5312. ; Next line ( 8/5 ); ESC E
  5313. ;--------------------------
  5314. ; Moves the cursor to the first position on the next line.
  5315. ; If the cursor is at the bottom margin, the screen performs a
  5316. ; scroll-up.
  5317.  
  5318. vt_c1_NEL:
  5319.     mov    ah,cur_row
  5320.     cmp    ah,vt_bottom
  5321.     jl    vt_c1_NEL_1
  5322.     je    vt_c1_NEL_2
  5323.     cmp    ah,vt_phys_bottom    ; [04-Aug-1989]
  5324.     jl    vt_c1_NEL_1        ; [04-Aug-1989]
  5325.     jmp    vt_esc_done
  5326. vt_c1_NEL_1:
  5327.     inc    ah
  5328.     mov    cur_row,ah
  5329.     mov    cur_col,0
  5330.     call    locate_cur
  5331.     jmp    vt_esc_done
  5332. vt_c1_NEL_2:
  5333.     mov    al,vt_top
  5334.     mov    cx,1
  5335.     call    scroll_up
  5336.     mov    cur_col,0
  5337.     call    locate_cur
  5338.     jmp    vt_esc_done
  5339.  
  5340. ;----------------------------------
  5341. ; Horizontal tab set (8/08); ESC H
  5342. ;----------------------------------
  5343. vt_c1_HTS:
  5344.     xor    ax,ax
  5345.     mov    al,cur_col
  5346.     mov    bx,offset tabstops
  5347.     add    bx,ax            ; tab pointer
  5348.     mov    byte ptr [bx],1
  5349.     jmp    vt_esc_done
  5350. ;
  5351. ;-------------------------------------------
  5352. ; Device Control String (9/0); ESC P
  5353. ;-------------------------------------------
  5354. vt_c1_DCS:
  5355.     mov    spec_mode,in_DCS_MODE
  5356.     mov    spec_stage,0        ; [24-May-1991]
  5357.     mov    P_pnt,0
  5358.     mov    bx,offset P_buf
  5359.     mov    word ptr [bx],0
  5360.     mov    I_pnt,0
  5361.     mov    bx,offset I_buf
  5362.     mov    byte ptr [bx],0
  5363.     mov    priv_pflg,0
  5364.     jmp    vt_disp_ex
  5365. ;
  5366. ;-------------------------------------------
  5367. ; Control Sequence Introducer (9/11); ESC [
  5368. ;-------------------------------------------
  5369. vt_c1_CSI:
  5370.     mov    spec_mode,in_CSI_MODE
  5371.     mov    spec_stage,0        ; [24-May-1991]
  5372.     mov    P_pnt,0
  5373.     mov    bx,offset P_buf
  5374.     mov    word ptr [bx],0
  5375.     mov    I_pnt,0
  5376.     mov    bx,offset I_buf
  5377.     mov    byte ptr [bx],0
  5378.     mov    priv_pflg,0
  5379.     jmp    vt_disp_ex
  5380. ;
  5381. ;-------------------------------------------
  5382. ; String Terminator (9/12); ESC \
  5383. ;-------------------------------------------
  5384. vt_c1_ST:
  5385.     mov    spec_mode,0
  5386.     jmp    vt_disp_ex
  5387. ;
  5388. VT100    ENDP
  5389.  
  5390. code    ends
  5391.     end
  5392.