Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1847 lines
38 KiB

  1. PAGE ,132
  2. TITLE CONDEV FANCY CONSOLE DRIVER
  3. ;******************************************************************************
  4. ; Change Log:
  5. ; Date Who # Description
  6. ; -------- --- --- ------------------------------------------------------
  7. ; 06/01/90 MKS C02 Bug#173. ANSI was permitting you to go one line below
  8. ; the bottom of the screen. PROMPT $e[25;3H $e[1B will
  9. ; show you. (PYS: badly done. M005)
  10. ;******************************************************************************
  11. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12. ; ADDRESSES FOR I/O
  13. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  14. ;------------------------------------------------------------------------------
  15. ; New functionality in DOS 4.00
  16. ; GHG fix scrolling flashes on Mod 25/30's
  17. ; P1767 VIDEO_MODE_TABLE not initialized correctly 10/16/87 J.K.
  18. ; D375 /X needs to be supported by ANSI sequence also 12/14/87 J.K.
  19. ; D397 /L option for Enforcing number of lines 12/17/87 J.K.
  20. ; D479 An option to disable the extended keyboard functions 02/12/88 J.K.
  21. ; P4241 AN001 fix be Revised to fix this problem 04/20/88 J.K.
  22. ; P4532 Scrolling has a snow for CGA adapter 04/27/88 J.K.
  23. ; P4533 In mode Dh, Eh, Fh, 10h and 13h, Scrolling not working 04/27/88 J.K.
  24. ; P4766 In mode 11h, and 12h erase display leaves bottom 5 05/24/88 F.G.
  25. ;------------------------------------------------------------------------------
  26. INCLUDE DEVSYM.INC
  27. INCLUDE ANSI.INC ;equates and structures
  28. INCLUDE VECTOR.INC
  29. BREAK <ANSI driver code>
  30. PUBLIC SWITCH_X ; /X option for extended keyboard redefinition support
  31. PUBLIC SCAN_LINES
  32. PUBLIC VIDEO_MODE_TABLE
  33. PUBLIC VIDEO_TABLE_MAX
  34. PUBLIC MAX_VIDEO_TAB_NUM ;P1767
  35. PUBLIC PTRSAV
  36. PUBLIC ERR1
  37. PUBLIC ERR2
  38. PUBLIC EXT_16
  39. PUBLIC BRKKY
  40. PUBLIC COUT
  41. PUBLIC BASE
  42. PUBLIC MODE
  43. PUBLIC MAXCOL
  44. PUBLIC EXIT
  45. PUBLIC NO_OPERATION
  46. PUBLIC HDWR_FLAG
  47. PUBLIC SWITCH_L
  48. PUBLIC SWITCH_K
  49. PUBLIC SWITCH_S ; M008 /S for screensize option setting.
  50. PUBLIC fhavek09 ; M006
  51. PUBLIC CON$READ
  52. PUBLIC CON$RDND
  53. PUBLIC CON$FLSH
  54. PUBLIC CON$WRIT
  55. PUBLIC VIDEO
  56. PUBLIC CUU
  57. PUBLIC CUD
  58. PUBLIC CUF
  59. PUBLIC CUB
  60. PUBLIC CUP
  61. PUBLIC ED
  62. PUBLIC CPR
  63. PUBLIC SM
  64. PUBLIC RM
  65. PUBLIC SGR
  66. PUBLIC DSR
  67. PUBLIC KEYASN
  68. PUBLIC EXTKEY
  69. PUBLIC PSCP
  70. PUBLIC PRCP
  71. IFDEF JAPAN
  72. PUBLIC ROW_ADJ
  73. ENDIF
  74. CODE SEGMENT PUBLIC BYTE
  75. ASSUME CS:CODE,DS:NOTHING,ES:NOTHING
  76. ;-----------------------------------------------
  77. ; C O N - CONSOLE DEVICE DRIVER
  78. EXTRN CON$INIT : NEAR ; ANSI initialization code
  79. EXTRN GENERIC_IOCTL : NEAR ; Generic IOCTL code
  80. EXTRN REQ_TXT_LENGTH : WORD ; current text length
  81. EXTRN GRAPHICS_FLAG : BYTE ; graphics flag
  82. ATTRIB EQU CHARDEV+DEVIOCTL+DEV320+ISSPEC+ISCOUT+ISCIN
  83. CONDEV: SYSDEV <-1,ATTRIB,STRATEGY,ENTRY,'CON '> ; Matches CON
  84. ;--------------------------------------------------------------
  85. ; COMMAND JUMP TABLES
  86. CONTBL:
  87. DW CON$INIT
  88. DW NO_OPERATION
  89. DW NO_OPERATION
  90. DW NO_OPERATION
  91. DW CON$READ
  92. DW CON$RDND
  93. DW NO_OPERATION
  94. DW CON$FLSH
  95. DW CON$WRIT
  96. DW CON$WRIT
  97. DW NO_OPERATION
  98. DW NO_OPERATION
  99. DW NO_OPERATION
  100. DW NO_OPERATION
  101. DW NO_OPERATION
  102. DW NO_OPERATION
  103. DW NO_OPERATION
  104. DW NO_OPERATION
  105. DW NO_OPERATION
  106. DW GENERIC_IOCTL ; generic IOCTL routine offset
  107. MAX_CMD EQU ($ - CONTBL)/2 ; size of CONTBL
  108. CMDTABL DB 'A'
  109. DW CUU ; cursor up
  110. DB 'B'
  111. DW CUD ; cursor down
  112. DB 'C'
  113. DW CUF ; cursor forward
  114. DB 'D'
  115. DW CUB ; cursor back
  116. DB 'H'
  117. DW CUP ; cursor position
  118. DB 'J'
  119. DW ED ; erase display
  120. DB 'K'
  121. DW EL ; erase line
  122. DB 'R'
  123. DW CPR ; cursor postion report
  124. DB 'f'
  125. DW CUP ; cursor position
  126. DB 'h'
  127. DW SM ; set mode
  128. DB 'l'
  129. DW RM ; reset mode
  130. DB 'm'
  131. DW SGR ; select graphics rendition
  132. DB 'n'
  133. DW DSR ; device status report
  134. DB 'p'
  135. DW KEYASN ; key assignment
  136. DB 'q' ; dynamic support of /X option through ansi sequence
  137. DW EXTKEY ; esc[0q = reset it. esc[1q = set it
  138. DB 's'
  139. DW PSCP ; save cursor postion
  140. DB 'u'
  141. DW PRCP ; restore cursor position
  142. IFDEF JAPAN
  143. DB 'M'
  144. DW DELETE ; delete line
  145. DB 'L'
  146. DW INSERT ; insert line
  147. ENDIF
  148. DB 00
  149. GRMODE DB 00,00000000B,00000111B
  150. DB 01,11111111B,00001000B
  151. DB 04,11111000B,00000001B
  152. DB 05,11111111B,10000000B
  153. DB 07,11111000B,01110000B
  154. DB 08,10001000B,00000000B
  155. DB 30,11111000B,00000000B
  156. DB 31,11111000B,00000100B
  157. DB 32,11111000B,00000010B
  158. DB 33,11111000B,00000110B
  159. DB 34,11111000B,00000001B
  160. DB 35,11111000B,00000101B
  161. DB 36,11111000B,00000011B
  162. DB 37,11111000B,00000111B
  163. DB 40,10001111B,00000000B
  164. DB 41,10001111B,01000000B
  165. DB 42,10001111B,00100000B
  166. DB 43,10001111B,01100000B
  167. DB 44,10001111B,00010000B
  168. DB 45,10001111B,01010000B
  169. DB 46,10001111B,00110000B
  170. DB 47,10001111B,01110000B
  171. DB 0FFH
  172. ;---------------------------------------------------
  173. ; Device entry point
  174. PTRSAV DD 0
  175. BUF1: BUF_DATA <> ; Next CON Buffer area
  176. STRATP PROC FAR
  177. STRATEGY:
  178. mov word ptr cs:[PTRSAV],bx
  179. mov word ptr cs:[PTRSAV+2],es
  180. ret
  181. STRATP ENDP
  182. ENTRY:
  183. push si
  184. push ax
  185. push cx
  186. push dx
  187. push di
  188. push bp
  189. push ds
  190. push es
  191. push bx
  192. ; Check if header link has to be set (Code ported from
  193. ; DISPLAY.SYS)
  194. lea bx,BUF1
  195. mov di,OFFSET CONDEV ; CON Device header
  196. mov CONPTR.DEV_HDRO,di
  197. mov CONPTR.DEV_HDRS,cs
  198. cld ; all moves forward
  199. cmp CONPTR.CON_STRAO, -1
  200. jne L4 ; has been linked to DOS CON
  201. cmp CONPTR.CON_STRAS, -1
  202. jne L4 ; has been linked to DOS CON
  203. ; next device header : ES:[DI]
  204. lds si,dword ptr CONPTR.DEV_HDRO
  205. les di,HP.SDEVNEXT
  206. L1: ; while pointer to next device header
  207. push es ; is not -1
  208. pop ax
  209. cmp ax,-1
  210. jne NOT0FFFF ; leave if both offset and segment are
  211. cmp di,-1 ; 0FFFFH
  212. je L4
  213. NOT0FFFF:
  214. push di
  215. push si
  216. mov cx,8
  217. lea di,NHD.SDEVNAME
  218. lea si,HP.SDEVNAME
  219. repe cmpsb
  220. pop si
  221. pop di
  222. and cx,cx
  223. ; Exit if name is found in linked hd.
  224. jnz L3 ; Name is not found
  225. ; Name is found in the linked header
  226. mov ax,NHD.SDEVSTRAT ; Get the STRATEGY address
  227. mov CONPTR.CON_STRAO,ax
  228. mov ax,es
  229. X1: mov CONPTR.CON_STRAS,ax
  230. mov ax,NHD.SDEVINT ; Get the INTERRUPT address
  231. mov CONPTR.CON_INTRO,ax
  232. mov ax,es
  233. X2: mov CONPTR.CON_INTRS,ax
  234. jmp SHORT L4 ; Device Name
  235. L3:
  236. les di,NHD.SDEVNEXT
  237. jmp L1
  238. L4:
  239. lds bx,cs:[PTRSAV] ; GET PONTER TO I/O PACKET
  240. mov cx,word ptr ds:[bx].COUNT
  241. mov al,byte ptr ds:[bx].CMD
  242. cbw
  243. mov si,OFFSET CONTBL
  244. add si,ax
  245. add si,ax
  246. cmp al,MAX_CMD ; not a call for ANSI...chain to lower device
  247. ja NO_OPERATION
  248. ifdef KOREA ; <MSCH>
  249. mov ah, byte ptr ds:[bx].media
  250. endif ; KOREA
  251. les di,dword ptr ds:[bx].TRANS
  252. ; Following code, supplied by Compaq, is the "hit-it-on-the-head"
  253. ; approach to solving the problem of resetting the screen length
  254. ; after a character set reload. We should try to find a better
  255. ; approach. For now this will stay in. - MGD
  256. push ax ; SAVE AX
  257. mov ax,40H ; GET ROM VAR
  258. mov ds,ax ;
  259. mov al,ds:[84h] ; GET MAX NUM OF ROWS
  260. cmp al,0 ; Q:ZERO
  261. jne ENTRY10 ; jmp IF NO
  262. mov al,24 ; SET TO 24 ROWS
  263. ENTRY10: ;
  264. push cs
  265. pop ds
  266. ASSUME ds:CODE
  267. inc al ; BUMP FOR ONE BASED
  268. mov byte ptr [REQ_TXT_LENGTH],al ; SET LENGTH TO 40:84H VALUE. *F
  269. pop ax ; RESTORE AX
  270. jmp word ptr [si] ; GO DO COMMAND
  271. ;=====================================================
  272. ;=
  273. ;= SUBROUTINES SHARED BY MULTIPLE DEVICES
  274. ;=
  275. ;=====================================================
  276. ;----------------------------------------------------------
  277. ; EXIT - ALL ROUTINES RETURN THROUGH THIS PATH
  278. BUS$EXIT: ; DEVICE BUSY EXIT
  279. mov ah,00000011B
  280. jmp SHORT ERR1
  281. NO_OPERATION:
  282. call PASS_CONTROL ; Pass control to lower CON
  283. jmp SHORT ERR2
  284. ERR$EXIT:
  285. mov ah,10000001B ; MARK ERROR RETURN
  286. jmp SHORT ERR1
  287. EXITP PROC FAR
  288. EXIT: mov ah,00000001B
  289. ifdef KOREA
  290. INTERIM$EXIT: ; <MSCH>
  291. endif ; KOREA
  292. ERR1: lds bx,cs:[PTRSAV]
  293. mov word ptr [bx].STATUS,ax ; MARK OPERATION COMPLETE
  294. ERR2:
  295. pop bx
  296. pop es
  297. pop ds
  298. pop bp
  299. pop di
  300. pop dx
  301. pop cx
  302. pop ax
  303. pop si
  304. ret ; RESTORE REGS and RETURN
  305. EXITP ENDP
  306. ; PASS CONTROL
  307. ; This calls the attached device to perform any further
  308. ; action on the call!
  309. PASS_CONTROL PROC
  310. lea si,BUF1
  311. les bx,cs:[PTRSAV] ; pass the request header to the
  312. call dword ptr cs:[si].CON_STRAO ; CON strategy routine.
  313. call dword ptr cs:[si].CON_INTRO ; interrupt the CON
  314. ret
  315. PASS_CONTROL ENDP
  316. ;-----------------------------------------------
  317. ; BREAK KEY HANDLING
  318. BRKKY:
  319. mov byte ptr cs:ALTAH,3 ; INDICATE BREAK KEY SET
  320. INTRET: iret
  321. ; WARNING - Variables are very order dependent, be careful
  322. ; when adding new ones! - c.p.
  323. WRAP DB 0 ; 0 = WRAP, 1 = NO WRAP
  324. ASNPTR DW 4
  325. STATE DW S1
  326. MODE DB 3 ;*
  327. MAXCOL DB 79 ;*
  328. COL DB 0
  329. ROW DB 0
  330. SAVCR DW 0
  331. INQ DB 0
  332. PRMCNT LABEL BYTE
  333. PRMCNTW DW 0
  334. KEYCNT DB 0
  335. KEYPTR DW BUF
  336. REPORT DB ESC_CHAR,'[00;00R',CR ;CURSOR POSTION REPORT BUFFER
  337. ALTAH DB 0 ;Special key handling
  338. SAVE_CHAR DW 0 ; Temp storage for char/attr for new scroll code
  339. EXT_16 DB 0 ; Extended INT 16h flag
  340. SWITCH_X DB OFF ; /X flag
  341. SWITCH_L DB OFF ; DCR397; 1= /L flag entered.
  342. SWITCH_K DB OFF ; To control EXT_16
  343. fhavek09 DB OFF ; M006
  344. SCAN_LINES DB ? ; flag for available scan lines (VGA)
  345. HDWR_FLAG DW 0 ; byte of flags indicating video support
  346. SWITCH_S DB OFF ; M008; /S flag
  347. ifdef KOREA ;
  348. REQ_TYPE DB 0 ;
  349. EXT_REQ_TYPE DB 0 ;
  350. LEADBYTE DB 0 ;
  351. TRAILBYTE DB 0 ;
  352. ECSPRE DB 0 ;
  353. endif ; KOREA ;
  354. VIDEO_MODE_TABLE LABEL BYTE ; table containing applicable
  355. MODE_TABLE <> ; video modes and corresponding
  356. MODE_TABLE <> ; data.
  357. MODE_TABLE <> ; this table is initialized at
  358. MODE_TABLE <> ; INIT time
  359. MODE_TABLE <>
  360. MODE_TABLE <>
  361. MODE_TABLE <>
  362. MODE_TABLE <>
  363. MODE_TABLE <>
  364. MODE_TABLE <>
  365. MODE_TABLE <>
  366. MODE_TABLE <>
  367. MODE_TABLE <>
  368. MODE_TABLE <>
  369. MODE_TABLE <>
  370. ifdef KOREA ; The KOREAN video mode
  371. MODE_TABLE <> ; have 4 more than standard
  372. MODE_TABLE <> ; VGA card
  373. MODE_TABLE <> ;
  374. MODE_TABLE <> ;
  375. endif ; KOREA ;
  376. VIDEO_TABLE_MAX EQU $ ; maximum address for video table
  377. MAX_VIDEO_TAB_NUM EQU ($-VIDEO_MODE_TABLE)/TYPE MODE_TABLE ;P1767 Max number of table
  378. IFDEF DBCS
  379. dbcs_flag DB 0 ; 0=single, 1=lead byte, 2=tail byte
  380. ENDIF
  381. IFDEF JAPAN
  382. new_mode DB 0 ; mode for '>'
  383. row_adj DB 0 ; for ESC[>1l
  384. ENDIF
  385. ;-------------------------------------------------------------
  386. ; CHROUT - WRITE OUT CHAR IN AL USING CURRENT ATTRIBUTE
  387. ATTRW LABEL WORD
  388. ATTR DB 00000111B ; CHARACTER ATTRIBUTE
  389. BPAGE DB 0 ; BASE PAGE
  390. BASE DW 0b800h
  391. SCREEN_SEG DW 00000h
  392. chrout:
  393. ifdef KOREA ; <MSCH>
  394. ;
  395. cmp [leadbyte],1 ; Is the previous byte a lead byte? ; KeyW
  396. jnz TestDBCSRange ; No,
  397. mov byte ptr [leadbyte],0
  398. mov byte ptr [trailbyte],1 ; Mark that this is trail byte of ECS
  399. jmp short OUTCHR
  400. ;
  401. ;
  402. ; Note : TestECS routine is hard coded. If you have the different code range,
  403. ; you should change some codes below.
  404. ; 1990/11/9 This routine is changed to use IsDBCS routines.
  405. ;
  406. TestDBCSRange:
  407. mov byte ptr [trailbyte], 0 ; Mark it as a non trail byte
  408. call IsDBCSleadbyte
  409. jnz realout ; Jump if one byte code
  410. ;
  411. ; CMP AL, 0A1H ;
  412. ; JB REALOUT ;
  413. ; CMP AL, 0FEH ;
  414. ; JA REALOUT ;
  415. mov byte ptr [leadbyte], 1 ; it as a lead byte
  416. mov ah, [col] ;
  417. cmp ah, [maxcol] ;
  418. jnz outchr ;
  419. ; ;
  420. ; Decide the position to print the Lead byte which is on the column boundary.
  421. ;
  422. cmp [wrap],0 ;
  423. jz skip1 ;
  424. dec [col] ;
  425. cmp [ecspre],1 ;
  426. jnz oneback1 ;
  427. dec [col] ;
  428. oneback1: ;
  429. call setit1 ;
  430. jmp short outchr ;
  431. skip1: ;
  432. push ax ;
  433. call outchr1 ;
  434. pop ax ;
  435. jmp short outchr ;
  436. realout:
  437. endif ; KOREA ;
  438. cmp al,13
  439. jnz trylf
  440. mov [COL],0
  441. ifdef KOREA
  442. jmp setit
  443. else
  444. IFDEF JAPAN
  445. jmp setit
  446. ELSE
  447. jmp short setit
  448. ENDIF
  449. endif ; KOREA
  450. trylf: cmp al,10
  451. jz lf
  452. cmp al,7
  453. jnz tryback
  454. torom:
  455. mov bx,[ATTRW]
  456. and bl,7
  457. mov ah,14
  458. int 10h
  459. ret5: ret
  460. tryback:
  461. cmp al,8
  462. jnz outchr
  463. cmp [COL],0
  464. jz ret5
  465. dec [COL]
  466. jmp short setit
  467. outchr:
  468. mov bx,[ATTRW]
  469. mov cx,1
  470. mov ah,9
  471. int 10h
  472. inc [COL]
  473. mov al,[COL]
  474. cmp al,[MAXCOL]
  475. jbe setit
  476. cmp [wrap],0
  477. jz outchr1
  478. dec [COL]
  479. ifdef KOREA
  480. ;
  481. ; Set boundary position for DBCS code.
  482. ; No lead byte can arrive here.
  483. ;
  484. cmp [trailbyte],1
  485. jnz onebk
  486. dec [col]
  487. onebk:
  488. call setit1
  489. ;
  490. ; We don't need ECSPRE change, because we have enough time to deal with it.
  491. ; Wait for another character to change ECSPRE.
  492. ;
  493. endif ; KOREA
  494. ret
  495. outchr1:
  496. mov [COL],0
  497. lf: inc [ROW]
  498. mov ah,30 ; GHG Fix for ROUNDUP/PALACE
  499. mov al,MODE ; GHG Fix for ROUNDUP/PALACE
  500. cmp al,11H ; GHG Fix for ROUNDUP/PALACE
  501. je LF2 ; GHG Fix for ROUNDUP/PALACE
  502. cmp al,12H ; GHG Fix for ROUNDUP/PALACE
  503. je LF2 ; GHG Fix for ROUNDUP/PALACE
  504. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  505. jne tmplab1
  506. mov ah,DEFAULT_LENGTH
  507. jmp short tmplab2
  508. tmplab1:
  509. mov ah,byte ptr [REQ_TXT_LENGTH]
  510. tmplab2:
  511. LF2: ; GHG Fix for ROUNDUP/PALACE
  512. IFDEF JAPAN
  513. sub ah,row_adj
  514. ENDIF
  515. cmp [ROW],AH ; GHG Fix for ROUNDUP/PALACE
  516. jb setit
  517. dec ah ; GHG Fix for ROUNDUP/PALACE
  518. mov [ROW],AH ; GHG Fix for ROUNDUP/PALACE
  519. call scroll
  520. setit:
  521. ifdef KOREA
  522. preset:
  523. xor al, al
  524. cmp [trailbyte],al
  525. jz noDBCStrail
  526. inc al
  527. noDBCStrail:
  528. mov [ecspre], al
  529. setit1:
  530. endif ; KOREA
  531. mov dh,row
  532. mov dl,col
  533. mov bh,[bpage]
  534. mov ah,2
  535. int 10h
  536. ret
  537. ;Writing a LF char through Teletype function to scroll the screen
  538. ;has a side effect of changing the color of the cursor when the PROMPT
  539. ;setting in PTM P4241 is used. AN001 uses this method to fix the strobing
  540. ;problem of the palace machine. The old method of scrolling used to directly
  541. ;write into video buffer. The old method has been used by AN001 for
  542. ;CGA adater of mode 2 or 3 only.
  543. ;To solve P4241, but to maintain the fix of the strobing problem of palace
  544. ;machine, we return back to the old logic but the old logic has to be
  545. ;Revised for the displays above CGA level. For the adapters above
  546. ;CGA display, we don't need to turn off/on the video - this will causes
  547. ;a strobing, if you use do this, for Palace machine.
  548. ;This logic will be only applied to mode 2 and 3 only.
  549. ; Following code is bug fix supplied by Compaq - MGD
  550. scroll:
  551. ifdef KOREA ; Responsible for ROM
  552. mov al, 10
  553. jmp torom
  554. else
  555. IFDEF JAPAN ; ### if JAPAN ###
  556. xor cx,cx
  557. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  558. jnz scroll10 ; if nor graphic
  559. mov dh,DEFAULT_LENGTH
  560. xor bh,bh
  561. jmp short scroll20
  562. scroll10:
  563. mov dh,byte ptr [REQ_TXT_LENGTH]
  564. mov bh,[ATTR]
  565. scroll20:
  566. sub dh,row_adj
  567. dec dh
  568. mov dl,[MAXCOL]
  569. mov ax,0601h ; scroll up
  570. int 10h
  571. jmp short setit
  572. else ; ### if Not JAPAN ###
  573. mov al,mode ; get display mode
  574. cmp al,4 ;Q: mode less than 4?
  575. jc is_text ;Y: perform kludge
  576. cmp al,7 ;N: Q: monochrome mode?
  577. je is_text ; Y: perform kludge
  578. mov al,10 ; send the line feed to the ROM
  579. jmp torom ; exit
  580. is_text:
  581. mov ah,8 ; read char/attr at cursor pos
  582. mov bh,[bpage]
  583. int 10h
  584. mov [save_char],ax ; save char/attribute
  585. mov ah,9 ; write char at cursor pos
  586. mov bx,[ATTRW] ; use current attribute
  587. mov cx,1
  588. int 10h
  589. mov al,10 ; send the line feed to the ROM
  590. call torom
  591. mov ah,3 ; read cursor pos
  592. int 10h
  593. push dx ; save it
  594. mov ah,2 ; set cursor position
  595. dec dh ; (to row-1)
  596. int 10h
  597. mov ax,[save_char] ; retrieve saved char/attr
  598. mov bl,ah
  599. mov ah,9 ; write it back to the screen
  600. mov cx,1
  601. int 10h
  602. pop dx ; retrieve new cursor position
  603. mov ah,2 ; set cursor position
  604. int 10h
  605. ret
  606. ENDIF ; ### end if Not JAPAN ###
  607. endif ; KOREA
  608. ;------------------------------------------------------
  609. ; CONSOLE READ ROUTINE
  610. CON$READ:
  611. jcxz CON$EXIT
  612. ifdef KOREA ;
  613. mov [req_type], 0 ;
  614. mov [ext_req_type], 10h ;
  615. test ah, 00000001b ;
  616. jz con$loop ;
  617. mov [req_type], 0f0h ; ; Get Interim mode
  618. mov [ext_req_type], 0f8h ;
  619. cmp cx, 1 ;
  620. jnz con$ndisp ;
  621. ;
  622. call chrin ;
  623. stosb ;
  624. cmp ah, 0f0h ; ; Is this an interim code ?
  625. jnz con$exit ;
  626. mov ah, 00000101b ;
  627. jmp interim$exit ; ; return to DOS with interim flag set
  628. con$ndisp: ;
  629. call chrin ;
  630. cmp ah, 0f0h ; ; Is this an interim code ?
  631. jz con$ndisp ; ; Skip the interims
  632. stosb ;
  633. LOOP CON$NDISP ;
  634. JMP EXIT ;
  635. endif ; KOREA
  636. CON$LOOP:
  637. push cx ; SAVE COUNT
  638. call CHRIN ; GET CHAR IN AL
  639. pop cx
  640. stosb ; STORE CHAR AT ES:DI
  641. loop CON$LOOP
  642. CON$EXIT:
  643. jmp EXIT
  644. ;---------------------------------------------------------
  645. ; INPUT SINGLE CHAR INTO AL
  646. CHRIN: xor ax,ax
  647. xchg al,ALTAH ; GET CHARACTER & ZERO ALTAH
  648. or al,al
  649. jnz KEYRET
  650. INAGN: cmp KEYCNT,0
  651. jnz KEY5A
  652. ifdef KOREA
  653. mov ah, [req_type]
  654. else
  655. xor ah,AH
  656. endif ; KOREA
  657. cmp EXT_16,ON ; extended interrupt available?
  658. jne tmplab3
  659. ifdef KOREA
  660. mov ah, [ext_req_type]
  661. else
  662. mov ah,10h ; yes..perform extended call
  663. endif ; KOREA
  664. INT 16h
  665. ifdef KOREA
  666. cmp ah, 0f0h
  667. jz keyret1 ; Breief return for the interim code
  668. endif ; KOREA
  669. cmp SWITCH_X,OFF ; /X switch used?
  670. jne tmplab5
  671. call CHECK_FOR_REMAP ; no....map to normal call
  672. tmplab5:
  673. call SCAN ; check for redefinition
  674. jz tmplab4 ; no redefinition?....and
  675. cmp SWITCH_X,ON ; /X switch used?
  676. jne tmplab4
  677. call CHECK_FOR_REMAP ; then remap..
  678. or bx,bx ; reset zero flag for jump test in old code
  679. jmp short tmplab4
  680. ; extended interrupt not available
  681. tmplab3:
  682. int 16h
  683. ifdef KOREA
  684. cmp ah, 0f0h
  685. jz keyret1
  686. endif ; KOREA
  687. call SCAN ; check for redefinition
  688. tmplab4:
  689. jnz ALT10 ; IF NO MATCH JUST RETURN IT
  690. dec cx
  691. dec cx
  692. inc bx
  693. inc bx
  694. cmp al,0 ; check whether keypacket is an extended one
  695. jz tmplab7
  696. cmp al,0e0h
  697. jnz tmplab6
  698. ifdef KOREA
  699. cmp ah, 0f0h
  700. jb mschtmp2
  701. cmp ah, 0f2h
  702. jbe tmplab7
  703. mschtmp2:
  704. endif ; KOREA
  705. cmp SWITCH_X,1
  706. jnz tmplab6
  707. tmplab7:
  708. dec cx ; adjust pointers
  709. inc bx ; appropiately
  710. tmplab6:
  711. mov KEYCNT,cl
  712. mov KEYPTR,bx
  713. KEY5A: ; Jmp here to get rest of translation
  714. call KEY5 ; GET FIRST KEY FROM TRANSLATION
  715. ALT10:
  716. or ax,ax ; Check for non-key after BREAK
  717. jz INAGN
  718. or al,al ; SPECIAL CASE?
  719. jnz KEYRET
  720. mov ALTAH,ah ; STORE SPECIAL KEY
  721. KEYRET:
  722. ifdef KOREA
  723. mov ah, 0f1h
  724. keyret1:
  725. endif ; KOREA
  726. ret
  727. KEY5: mov bx,KEYPTR ; GET A KEY FROM TRANSLATION TABLE
  728. mov ax,word ptr [bx]
  729. dec KEYCNT
  730. inc bx
  731. or al,al
  732. jnz KEY6
  733. inc bx
  734. dec KEYCNT
  735. KEY6: mov KEYPTR,bx
  736. ret
  737. SCAN: mov bx,OFFSET BUF
  738. KEYLP: mov cl,byte ptr [bx]
  739. xor ch,ch
  740. or cx,cx
  741. jz NOTFND
  742. cmp al,0 ; check whether extended keypacket
  743. jz tmplab8
  744. cmp al,0e0h ; extended must be enabled with /x
  745. jnz tmplab9
  746. ifdef KOREA ; Jump when Hangeul char
  747. cmp ah, 0f0h
  748. jb mschtmp1
  749. cmp ah, 0f2h
  750. jbe tmplab9
  751. mschtmp1:
  752. endif ; KOREA
  753. cmp SWITCH_X,ON
  754. jnz tmplab9
  755. tmplab8:
  756. cmp ax,word ptr [bx+1] ; yes...compare the word
  757. jmp short tmplab10
  758. tmplab9:
  759. cmp al,byte ptr [bx+1] ; no...compare the byte
  760. tmplab10:
  761. jz MATCH
  762. add bx,cx
  763. jmp KEYLP
  764. NOTFND: or bx,bx
  765. MATCH: ret
  766. ;--------------------------------------------------------------
  767. ; KEYBOARD NON DESTRUCTIVE READ, NO WAIT
  768. CON$RDND:
  769. mov al,[ALTAH]
  770. or al,al
  771. ifdef KOREA
  772. jnz To_RDEXIT
  773. else
  774. jnz RDEXIT
  775. endif ; KOREA
  776. cmp [KEYCNT],0
  777. jz RD1
  778. mov bx,[KEYPTR]
  779. mov al,byte ptr [bx]
  780. ifdef KOREA
  781. to_rdexit:
  782. jmp rdexit
  783. else
  784. jmp SHORT RDEXIT
  785. endif ; KOREA
  786. RD1:
  787. ifdef KOREA
  788. mov [req_type], 1
  789. mov [ext_req_type], 11H
  790. test ah, 00000001b
  791. jz rd11
  792. mov [req_type], 0f1h
  793. mov [ext_req_type], 0f9H
  794. RD11:
  795. mov ah, [req_type]
  796. cmp ext_16, on
  797. jnz tmplab11
  798. mov ah, [ext_req_type]
  799. else
  800. mov ah,1
  801. cmp EXT_16,ON
  802. jnz tmplab11
  803. add ah,10h ; yes....adjust to extended call
  804. endif ; KOREA
  805. tmplab11:
  806. int 16h
  807. jz CheckForEvent
  808. or ax,ax
  809. jnz RD2
  810. ifdef KOREA
  811. mov ah, [req_type]
  812. and ah, 11111110b
  813. else
  814. mov ah,0
  815. endif ; KOREA
  816. cmp EXT_16,ON ; extended interrupt available?
  817. jne tmplab12
  818. ifdef KOREA
  819. mov ah, [ext_req_type]
  820. and ah, 11111110b
  821. else
  822. mov ah,10h ; yes..perform extended call
  823. endif ; KOREA
  824. int 16h
  825. cmp SWITCH_X,OFF ; /X switch used?
  826. jnz tmplab13
  827. call CHECK_FOR_REMAP ; no....map to normal call
  828. jmp short tmplab13
  829. tmplab12:
  830. int 16h
  831. tmplab13:
  832. jmp CON$RDND
  833. RD2:
  834. ifdef KOREA
  835. cmp ah, 0f0h
  836. jz rdexit
  837. endif ; KOREA
  838. call SCAN
  839. jz tmplab14 ; if no redefinition
  840. cmp EXT_16,ON
  841. jnz tmplab14 ; and extended INT16 used
  842. cmp SWITCH_X,ON ; and /x used
  843. jnz tmplab14
  844. call CHECK_FOR_REMAP ; remap to standard call
  845. or bx,bx ; reset zero flag for jump test in old code
  846. tmplab14:
  847. jnz RDEXIT
  848. mov al,byte ptr [bx+2]
  849. cmp byte ptr [bx+1],0
  850. jnz RDEXIT
  851. mov al,byte ptr [bx+3]
  852. RDEXIT: lds bx,[PTRSAV]
  853. mov [bx].MEDIA,al
  854. EXVEC: jmp EXIT
  855. ; M006 - begin
  856. CheckForEvent:
  857. cmp fhavek09,0
  858. jz CONBUS ; return with busy status if not k09
  859. les bx,[ptrsav]
  860. assume es:nothing
  861. test es:[bx].status,0400h ; system wait enabled?
  862. jz CONBUS ; return with busy status if not
  863. ; need to wait for ibm response to request for code
  864. ; on how to use the system wait call.
  865. mov ax,4100h ; wait on an external event
  866. xor bl,bl ; wait for any event
  867. int 15h ; call rom for system wait
  868. ; M006 - end
  869. CONBUS: jmp BUS$EXIT
  870. ;--------------------------------------------------------------
  871. ; KEYBOARD FLUSH ROUTINE
  872. CON$FLSH:
  873. mov [ALTAH],0 ; Clear out holding buffer
  874. mov [KEYCNT],0
  875. ifdef KOREA
  876. mov ah, 0f3h
  877. int 16h
  878. ReadNullByte: ; We may have final char
  879. mov ah, 0f1h
  880. int 16h
  881. jz FlushDone
  882. mov ah, 0f0h
  883. int 16h
  884. jmp short ReadNullByte
  885. FlushDone:
  886. else
  887. Flush: mov ah,1
  888. cmp EXT_16,ON ; if extended call available
  889. jnz tmplab15
  890. add ah,10h ; then use it
  891. tmplab15:
  892. int 16h
  893. jz FlushDone
  894. mov ah,0
  895. cmp EXT_16,ON ; if extended call available
  896. jnz tmplab16
  897. add ah,10h ; use it
  898. tmplab16:
  899. int 16h
  900. jmp Flush
  901. FlushDone:
  902. endif ; KOREA
  903. jmp EXVEC
  904. ;----------------------------------------------------------
  905. ; CONSOLE WRITE ROUTINE
  906. CON$WRIT:
  907. jcxz EXVEC
  908. ifdef KOREA
  909. test ah, 00000001b
  910. jnz con$lp_nac ;OUT CHAR WITHOUT CURSOR ADVANCING
  911. endif ; KOREA
  912. CON$LP: mov al,es:[di] ; GET CHAR
  913. inc di
  914. call OUTC ; OUTPUT CHAR
  915. loop CON$LP ; REPEAT UNTIL ALL THROUGH
  916. jmp EXVEC
  917. ifdef KOREA
  918. con$lp_nac:
  919. mov al, es:[di]
  920. inc di
  921. call outchr_nac ;OUTPUT CHAR WITHOUT CURSOR MOVE
  922. loop con$lp_nac ;REPEAT UNTIL ALL THROUGH
  923. jmp exit
  924. outchr_nac:
  925. push ax
  926. push si
  927. push di
  928. push bp
  929. mov ah, 0feh ;OUTPUT CHAR WITHOUT CURSOR ADVANCING
  930. mov bl, 7 ;SET FOREGROUND COLOR
  931. int 10h ;CALL ROM BIOS
  932. pop bp
  933. pop di
  934. pop si
  935. pop ax
  936. ret
  937. endif
  938. COUT: sti
  939. push ds
  940. push cs
  941. pop ds
  942. call OUTC
  943. pop ds
  944. Iret
  945. OUTC: push ax
  946. push bx
  947. push cx
  948. push dx
  949. push si
  950. push di
  951. push es
  952. push bp
  953. mov [BASE],0b800h
  954. xchg ax,si ; SAVE CHARACTER TO STUFF
  955. mov ax,40h ; POINT TO ROS BIOS
  956. mov ds,ax
  957. mov ax,ds:[49h] ; AL=MODE, AH=MAX COL
  958. dec ah ; ANSI NEEDS 0-79 OR 0-39
  959. mov word ptr cs:[MODE],ax ; SAVE MODE and MAX COL
  960. cmp al,7
  961. jnz NOT_BW
  962. mov word ptr cs:[BASE],0B000H
  963. NOT_BW: mov al,ds:[62H] ; GET ACTIVE PAGE
  964. mov cs:[BPAGE],al
  965. cbw
  966. add ax,ax
  967. mov bx,ax
  968. mov ax,ds:[bx+50H] ; AL=COL, AH=ROW
  969. mov word ptr cs:[COL],ax ; SAVE ROW and COLUMN
  970. mov ax,ds:[4EH] ; GET START OF SCREEN SEG
  971. mov cl,4
  972. shr ax,cl ; CONVERT TO A SEGMENT
  973. push cs
  974. pop ds
  975. mov [SCREEN_SEG],ax
  976. xchg ax,si ; GET BACK CHARACTER IN AL
  977. call VIDEO
  978. pop bp
  979. pop es
  980. pop di
  981. pop si
  982. pop dx
  983. pop cx
  984. pop bx
  985. pop ax
  986. ret
  987. ;----------------------------------------------------------
  988. ; OUTPUT SINGLE CHAR IN AL TO VIDEO DEVICE
  989. VIDEO: mov si,OFFSET STATE
  990. jmp [si]
  991. S2: cmp al,'['
  992. jz S22
  993. ifdef KOREA
  994. cmp al, '$'
  995. jnz chk_off
  996. mov word ptr [si], offset S8
  997. ret
  998. chk_off:
  999. cmp al, '('
  1000. jnz jmp_S1
  1001. mov word ptr [si], offset S10
  1002. ret
  1003. jmp_S1:
  1004. endif ; KOREA
  1005. jmp S1
  1006. S22: mov word ptr [si],OFFSET S3
  1007. xor bx,bx
  1008. mov word ptr INQ,bx
  1009. jmp SHORT S3B
  1010. S3: cmp al,';'
  1011. jnz S3C
  1012. S3A: inc PRMCNT
  1013. S3B: call GETPTR
  1014. xor ax,ax
  1015. mov word ptr [bx],ax ; DEFAULT VALUE IS ZERO
  1016. ret
  1017. S3C: cmp al,'0'
  1018. jb S3D
  1019. cmp al,'9'
  1020. ja S3D
  1021. call GETPTR
  1022. sub al,'0'
  1023. xchg al,byte ptr [bx]
  1024. mov ah,10
  1025. mul ah ; *10
  1026. add byte ptr [bx],al ; movE IN DIGIT
  1027. ret
  1028. S3D: cmp al,'='
  1029. jz S3ret
  1030. cmp al,'?'
  1031. jz S3ret
  1032. IFDEF JAPAN
  1033. cmp al,'>'
  1034. jz s3f
  1035. ENDIF
  1036. cmp al,'"' ; BEGIN QUOTED STRING
  1037. jz S3E
  1038. cmp al,"'"
  1039. jnz S7
  1040. S3E: mov word ptr [si],OFFSET S4
  1041. mov [INQ],al
  1042. S3ret: ret
  1043. IFDEF JAPAN
  1044. s3f:
  1045. mov new_mode,1
  1046. jmp short s3ret
  1047. ENDIF
  1048. ; ENTER QUOTED STRINGS
  1049. S4: cmp al,[INQ] ; CHECK FOR STRING TERMINATOR
  1050. jnz S4A
  1051. dec PRMCNT ; TERMINATE STRING
  1052. mov word ptr [si],OFFSET S3
  1053. ret
  1054. S4A: call GETPTR
  1055. mov byte ptr [bx],al
  1056. mov word ptr [si],OFFSET S4
  1057. jmp S3A
  1058. ; LOOK FOR ANSI COMMAND SPECIFIED IN AL
  1059. PUBLIC S7
  1060. S7: mov bx,OFFSET CMDTABL-3
  1061. S7A: add bx,3
  1062. cmp byte ptr [bx],0
  1063. jz S1B
  1064. cmp byte ptr [bx],al
  1065. jnz S7A
  1066. S7B: mov ax,word ptr [bx+1] ; AX = JUMP addRESS
  1067. mov bx,OFFSET BUF
  1068. inc bx
  1069. add bx,ASNPTR ; BX = PTR TO PARM LIST
  1070. mov DL,byte ptr [bx]
  1071. xor DH,DH ; DX = FIRST PARAMETER
  1072. mov cx,dx
  1073. or cx,cx
  1074. jnz S7C
  1075. inc cx ; CX = DX, CX=1 IF DX=0
  1076. S7C: jmp ax ; AL = COMMAND
  1077. S1: cmp al,ESC_CHAR ; ESCAPE SEQUENCE?
  1078. jnz S1B
  1079. IFDEF DBCS
  1080. mov dbcs_flag,0
  1081. ENDIF
  1082. IFDEF JAPAN
  1083. mov new_mode,0
  1084. ENDIF
  1085. mov word ptr [si],OFFSET S2
  1086. ret
  1087. S1B:
  1088. ifndef KOREA ; IN KOREA, WE ALREADY handled
  1089. IFDEF DBCS
  1090. cmp dbcs_flag,1
  1091. jz set_dbcs ; if it was lead byte
  1092. cmp dbcs_flag,2
  1093. jnz @f ; if it was not tail byte
  1094. mov dbcs_flag,0 ; reset
  1095. @@:
  1096. call IsDBCSLeadByte
  1097. jnz @f ; if this is not lead byte
  1098. set_dbcs:
  1099. inc dbcs_flag
  1100. @@:
  1101. cmp dbcs_flag,1
  1102. jnz @f
  1103. mov dl,col
  1104. cmp dl,maxcol
  1105. jnz @f
  1106. push ax
  1107. mov al,' '
  1108. call chrout
  1109. pop ax
  1110. @@:
  1111. ENDIF
  1112. endif ; NOT KOREA
  1113. call CHROUT
  1114. S1A: mov word ptr [STATE],OFFSET S1
  1115. ret
  1116. ifdef KOREA
  1117. S8: cmp al, ')'
  1118. jnz s1
  1119. mov word ptr [si], offset S9
  1120. ret
  1121. S9: cmp al, '1'
  1122. jnz S1
  1123. han_on:
  1124. mov ah, 0f2h
  1125. mov al, 08h ; Hangeul input mode on
  1126. int 16h
  1127. ret
  1128. S10: cmp al, '2'
  1129. jnz S1
  1130. han_off:
  1131. mov ah, 0f2h
  1132. mov al, 00h
  1133. int 16h
  1134. ret
  1135. endif ; KOREA
  1136. MOVCUR: ;C02
  1137. cmp byte ptr [bx],AH
  1138. jz SETCUR
  1139. add byte ptr [bx],al
  1140. loop MOVCUR
  1141. SETCUR: mov dx,word ptr COL
  1142. ;*C05 xor bx,bx
  1143. mov ah,0fh ;*C05
  1144. int 10h ;*C05
  1145. mov ah,2
  1146. int 16
  1147. jmp S1A
  1148. CUP:
  1149. IFDEF JAPAN ; ### if JAPAN ###
  1150. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  1151. jnz tmplab17 ; if not graphic mode
  1152. mov ah,DEFAULT_LENGTH
  1153. jmp short tmplab18
  1154. tmplab17:
  1155. mov ah,byte ptr [REQ_TXT_LENGTH]
  1156. tmplab18:
  1157. sub ah,row_adj
  1158. cmp cl,ah
  1159. ELSE
  1160. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  1161. jnz tmplab17
  1162. cmp cl,DEFAULT_LENGTH
  1163. jmp short tmplab18
  1164. tmplab17:
  1165. cmp cl,byte ptr [REQ_TXT_LENGTH]
  1166. tmplab18:
  1167. ENDIF ; ### end if JAPAN ###
  1168. ja SETCUR
  1169. mov al,MAXCOL
  1170. mov ch,byte ptr [bx+1]
  1171. or ch,CH
  1172. jz CUP1
  1173. dec CH
  1174. CUP1: cmp al,CH
  1175. ja CUP2
  1176. mov ch,al
  1177. CUP2: xchg cl,CH
  1178. dec CH
  1179. mov word ptr COL,cx
  1180. jmp SETCUR
  1181. CUF: mov ah,MAXCOL
  1182. mov al,1
  1183. CUF1: mov bx,OFFSET COL
  1184. jmp MOVCUR
  1185. CUB: mov ax,00FFH
  1186. jmp CUF1
  1187. CUU: mov ax,00FFH
  1188. CUU1: mov bx,OFFSET ROW
  1189. jmp MOVCUR
  1190. CUD:
  1191. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  1192. jnz tmplab19
  1193. mov ah,DEFAULT_LENGTH
  1194. jmp short tmplab20
  1195. tmplab19:
  1196. mov ah,byte ptr [REQ_TXT_LENGTH]
  1197. dec ah ; M005; REQ_TXT_LENGTH is not 0 based
  1198. tmplab20:
  1199. IFDEF JAPAN
  1200. sub ah,row_adj
  1201. ENDIF
  1202. mov al,1
  1203. jmp CUU1
  1204. ExtKey:
  1205. cmp dl, 0 ; DL = previous parameter
  1206. jne ExtKey_1
  1207. mov Switch_X, OFF ; reset it if 0.
  1208. jmp S1A
  1209. ExtKey_1:
  1210. cmp dl, 1 ; 1 ?
  1211. je SetExtKey
  1212. jmp S1A ; ignore it
  1213. SetExtKey:
  1214. mov Switch_X, ON ; set it if 1.
  1215. jmp S1A
  1216. PSCP: mov ax,word ptr COL
  1217. mov SAVCR,ax
  1218. jmp SETCUR
  1219. PRCP: mov ax,SAVCR
  1220. mov word ptr COL,ax
  1221. jmp SETCUR
  1222. SGR: xor cx,cx
  1223. xchg cl,PRMCNT
  1224. call GETPTR
  1225. inc cx
  1226. SGR1: mov al,byte ptr [bx]
  1227. push bx
  1228. mov bx,OFFSET GRMODE
  1229. SGR2: mov ah,byte ptr [bx]
  1230. add bx,3
  1231. cmp ah,0FFH
  1232. jz SGR3
  1233. cmp ah,al
  1234. jnz SGR2
  1235. mov ax,word ptr [bx-2]
  1236. and ATTR,al
  1237. or ATTR,AH
  1238. SGR3: pop bx
  1239. inc bx
  1240. loop SGR1
  1241. jmp SETCUR
  1242. IFDEF JAPAN ; ### if JAPAN ###
  1243. ED:
  1244. mov bl,dl ; save function no.
  1245. mov dh,30
  1246. mov al,MODE
  1247. cmp al,11h
  1248. je ed20 ; if graphic 640X480
  1249. cmp al,12h
  1250. je ed20 ; if graphic 640X480
  1251. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  1252. jnz ed10 ; if not graphic mode
  1253. mov dh,DEFAULT_LENGTH
  1254. jmp short ed20
  1255. ed10:
  1256. mov dh,byte ptr [REQ_TXT_LENGTH]
  1257. ed20:
  1258. sub dh,row_adj
  1259. dec dh ; last row
  1260. mov dl,MAXCOL
  1261. xor cx,cx
  1262. cmp bl,0
  1263. jz ed_func0
  1264. cmp bl,1
  1265. jz ed_func1
  1266. mov word ptr COL,cx ; ESC[2J
  1267. jmp short ed_30
  1268. ed_func0: ; ESC[0J
  1269. push dx
  1270. mov cx,word ptr COL
  1271. mov dh,ch
  1272. mov dl,MAXCOL
  1273. call erase ; erase to eol
  1274. pop dx
  1275. mov ch,ROW
  1276. cmp ch,dh
  1277. jz ed_end ; if at bottom
  1278. inc ch
  1279. mov cl,0
  1280. jmp short ed_30
  1281. ed_func1: ; ESC[1J
  1282. mov dx,word ptr COL
  1283. mov ch,dh
  1284. mov cl,0
  1285. call erase ; erase from top
  1286. mov dh,ROW
  1287. cmp dh,0
  1288. jz ed_end
  1289. dec dh
  1290. mov dl,MAXCOL
  1291. xor cx,cx
  1292. ed_30:
  1293. call erase
  1294. ed_end:
  1295. jmp setcur
  1296. EL:
  1297. cmp dl,1
  1298. jz el_func1
  1299. cmp dl,2
  1300. jz el_func2
  1301. mov cx,word ptr COL ; ESC[0K
  1302. mov dh,ch
  1303. mov dl,MAXCOL
  1304. jmp short el_10
  1305. el_func1:
  1306. mov dx,word ptr COL ; ESC[1K
  1307. mov ch,dh
  1308. mov cl,0
  1309. jmp short el_10
  1310. el_func2:
  1311. mov ch,ROW ; ESC[2K
  1312. mov dh,ch
  1313. mov cl,0
  1314. mov dl,MAXCOL
  1315. el_10:
  1316. call erase
  1317. jmp setcur
  1318. erase:
  1319. cmp GRAPHICS_FLAG,GRAPHICS_MODE ; if we are in graphics mode,
  1320. jnz erase10
  1321. xor bh,bh ; then use 0 as attribute
  1322. jmp short erase20
  1323. erase10:
  1324. mov bh,ATTR ; else use ATTR
  1325. erase20:
  1326. mov ax,0600H ; clear
  1327. int 10h
  1328. ret
  1329. else ; ### if Not JAPAN ###
  1330. ED: xor cx,cx
  1331. mov word ptr COL,cx
  1332. mov DH,30
  1333. mov al,MODE
  1334. cmp al,11H
  1335. je ERASE
  1336. cmp al,12H
  1337. je ERASE
  1338. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  1339. jnz tmplab21
  1340. mov dh,DEFAULT_LENGTH
  1341. jmp short tmplab22
  1342. tmplab21:
  1343. mov dh,byte ptr [REQ_TXT_LENGTH]
  1344. tmplab22:
  1345. ERASE: mov DL,MAXCOL
  1346. cmp GRAPHICS_FLAG,GRAPHICS_MODE ; if we are in graphics mode,
  1347. jnz tmplab23
  1348. xor bh,bh ; then use 0 as attribute
  1349. jmp short tmplab24
  1350. tmplab23:
  1351. mov bh,ATTR ; else use ATTR
  1352. tmplab24:
  1353. mov ax,0600H
  1354. int 16
  1355. ED3: jmp SETCUR
  1356. EL: mov cx,word ptr COL
  1357. mov DH,CH
  1358. jmp ERASE
  1359. ENDIF ; ### end if Not JAPAN ###
  1360. IFDEF JAPAN ; ### if JAPAN ###
  1361. delete:
  1362. mov ah,6 ; scroll up
  1363. jmp short insdel
  1364. insert:
  1365. mov ah,7 ; scroll down
  1366. insdel:
  1367. mov al,cl ; set scroll number
  1368. mov COL,0 ; set to top of row
  1369. mov cx,word ptr COL
  1370. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  1371. jnz line10 ; if not graphic mode
  1372. mov dh,DEFAULT_LENGTH
  1373. xor bh,bh ; attribute
  1374. jmp short line20
  1375. line10:
  1376. mov bh,ATTR
  1377. mov dh,byte ptr [REQ_TXT_LENGTH]
  1378. line20:
  1379. sub dh,row_adj
  1380. dec dh
  1381. mov dl,MAXCOL
  1382. int 10h ; scroll
  1383. jmp setcur
  1384. ENDIF ; ### end if JAPAN ###
  1385. BIN2ASC:mov DL,10
  1386. inc AL
  1387. xor ah,AH
  1388. div dl
  1389. add ax,'00'
  1390. ret
  1391. DSR: mov ah,REQ_CRSR_POS
  1392. push bx
  1393. xor bh,bh
  1394. int 10h
  1395. pop bx
  1396. push dx
  1397. mov al,dh ;REPORT CURRENT CURSOR POSITION
  1398. call BIN2ASC
  1399. mov word ptr REPORT+2,ax
  1400. pop dx
  1401. mov al,DL
  1402. call BIN2ASC
  1403. mov word ptr REPORT+5,ax
  1404. mov [KEYCNT],9
  1405. mov [KEYPTR],OFFSET REPORT
  1406. CPR: jmp S1A
  1407. RM: mov cl,1
  1408. jmp SHORT SM1
  1409. SM: xor cx,cx
  1410. SM1: mov al,DL
  1411. IFDEF JAPAN
  1412. cmp new_mode,1
  1413. jz nmode
  1414. ENDIF
  1415. cmp al,MODE7 ; if mode isn't (0-6, 13-19)
  1416. jl tmplab25 ; then skip (cas -- signed?)
  1417. cmp al,MODE13
  1418. jl tmplab26
  1419. cmp al,MODE19
  1420. jg tmplab26
  1421. tmplab25:
  1422. test HDWR_FLAG,LCD_ACTIVE ; is this the LCD?
  1423. jz tmplab25a ; skip if not
  1424. push ds ; WGR yes...
  1425. push ax ; WGR save mode
  1426. mov ax,ROM_BIOS
  1427. mov ds,ax ; WGR get equipment status flag..
  1428. mov ax,DS:[EQUIP_FLAG]
  1429. and ax,INIT_VID_MASK ; WGR clear initial video bits..
  1430. or ax,LCD_COLOR_MODE ; WGR .....set bits as color
  1431. mov ds:[EQUIP_FLAG],ax ; WGR replace updated flag.
  1432. pop ax ; WGR restore mode.
  1433. pop ds
  1434. tmplab25a:
  1435. mov ah,SET_MODE ; WGR yes....set mode..
  1436. int 10H
  1437. jmp short tmplab27
  1438. tmplab26:
  1439. cmp al,7 ; then if 7, wrap at EOL
  1440. jnz tmplab27
  1441. mov [WRAP],CL ; WGR yes....wrap...
  1442. tmplab27:
  1443. jmp CPR
  1444. IFDEF JAPAN ; ### if JAPAN ###
  1445. nmode:
  1446. mov new_mode,0
  1447. cmp al,1
  1448. jz row_mode ; set row mode
  1449. cmp al,5
  1450. jz cur_mode ; set cursor mode
  1451. jmp cpr
  1452. row_mode:
  1453. mov row_adj,0
  1454. jcxz row_mode_ret ; if set mode
  1455. cmp GRAPHICS_FLAG,GRAPHICS_MODE
  1456. jnz row_mode10 ; if not graphic mode
  1457. mov ah,DEFAULT_LENGTH
  1458. jmp short row_mode20
  1459. row_mode10:
  1460. mov ah,byte ptr [REQ_TXT_LENGTH]
  1461. row_mode20:
  1462. dec ah
  1463. cmp row,ah
  1464. jb row_mode_30 ; if cursor not at bottom row
  1465. dec row
  1466. call scroll
  1467. row_mode_30:
  1468. inc row_adj
  1469. row_mode_ret:
  1470. jmp cpr
  1471. cur_mode:
  1472. push cx
  1473. mov ah,3 ; get cursor
  1474. mov bh,bpage
  1475. int 10h
  1476. pop ax
  1477. or ax,ax
  1478. jz cur_mode10 ; if for cursor off
  1479. and ch,11011111b ; cursor on
  1480. jmp short cur_mode20
  1481. cur_mode10:
  1482. or ch,00100000b ; corsor off
  1483. cur_mode20:
  1484. mov ah,1 ; set cursor
  1485. int 10h
  1486. jmp cpr
  1487. ENDIF ; ### end if JAPAN ###
  1488. KEYASN: xor dx,dx
  1489. xchg DL,PRMCNT ;GET CHARACTER COUNT
  1490. inc dx
  1491. inc dx
  1492. call GETPTR
  1493. mov ax,word ptr [bx] ;GET CHARACTER TO BE ASSIGNED
  1494. call SCAN ;LOOK IT UP
  1495. jnz KEYAS1
  1496. mov di,bx ;DELETE OLD DEFINITION
  1497. sub ASNPTR,cx
  1498. mov KEYCNT,0 ; This delete code shuffles the
  1499. ; key definition table all around.
  1500. ; This will cause all sorts of trouble
  1501. ; if we are in the middle of expanding
  1502. ; one of the definitions being shuffled.
  1503. ; So shut off the expansion.
  1504. mov si,di
  1505. add si,cx
  1506. mov cx,OFFSET BUF+ASNMAX
  1507. sub cx,si
  1508. cld
  1509. push es ; SAVE USER'S ES
  1510. push CS
  1511. pop es ; SET UP ES addRESSABILITY
  1512. rep movsb
  1513. pop es ; RESTORE ES
  1514. KEYAS1: call GETPTR
  1515. cmp DL,3
  1516. jb KEYAS3
  1517. mov byte ptr [bx-1],DL ; SET LENGTH
  1518. add ASNPTR,dx ; REMEMBER END OF LIST
  1519. add bx,dx
  1520. cmp ASNPTR,ASNMAX ; Too much???
  1521. jb KEYAS3 ; No
  1522. sub bx,dx ; Next three instructions undo the above
  1523. sub ASNPTR,dx
  1524. KEYAS3: mov byte ptr [bx-1],00
  1525. mov STATE,OFFSET S1 ; RETURN
  1526. ret
  1527. GETPTR: mov bx,ASNPTR
  1528. inc bx
  1529. add bx,PRMCNTW
  1530. cmp bx,ASNMAX + 8
  1531. jb GET1
  1532. dec PRMCNT
  1533. jmp GETPTR
  1534. GET1: add bx,OFFSET BUF
  1535. ret
  1536. ; CHECK_FOR_REMAP:
  1537. ; This function esnures that the keypacket
  1538. ; passed to it in AX is mapped to a standard INT16h call
  1539. CHECK_FOR_REMAP PROC NEAR
  1540. cmp al,0e0h ; extended key?
  1541. jnz tmplab28
  1542. ifdef KOREA
  1543. cmp ah, 0f0h
  1544. jb mschtmp
  1545. cmp ah, 0f2h
  1546. jbe tmplab28
  1547. mschtmp:
  1548. endif ; KOREA
  1549. or ah,ah ; probably, but check for alpha character
  1550. jz tmplab28
  1551. xor al,al ; if not an alpha, map extended to standard
  1552. tmplab28:
  1553. ret
  1554. CHECK_FOR_REMAP ENDP
  1555. IFDEF DBCS
  1556. ; Test if the character is DBCS Lead Byte
  1557. ; input: AL = character to check
  1558. ; outpit: ZF = 1 if DBCS Lead Byte
  1559. public DBCSLeadByteTable
  1560. DBCSLeadByteTable dd 0
  1561. IsDBCSLeadByte proc near
  1562. push ax
  1563. push si
  1564. push ds
  1565. lds si,cs:DBCSLeadByteTable
  1566. idlb_check:
  1567. cmp word ptr [si],0
  1568. jz idlb_not ; if end of table
  1569. cmp al,[si]
  1570. jb idlb_next ; if below low value
  1571. cmp al,[si+1]
  1572. jbe idlb_yes ; if below high value
  1573. idlb_next:
  1574. add si,2 ; do next
  1575. jmp short idlb_check
  1576. idlb_not:
  1577. or al,1 ; reset ZF
  1578. jmp short idlb_end
  1579. idlb_yes:
  1580. and al,0 ; set ZF
  1581. idlb_end:
  1582. pop ds
  1583. pop si
  1584. pop ax
  1585. ret
  1586. IsDBCSLeadByte endp
  1587. ENDIF
  1588. BUF DB 4,00,72H,16,0
  1589. DB ASNMAX+8-5 DUP (?)
  1590. CODE ENDS
  1591. END
  1592.