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.

1225 lines
29 KiB

  1. PAGE ,132
  2. TITLE ANSI Generic IOCTL Code
  3. ;******************************************************************************
  4. ; Change Log:
  5. ; Date Who # Description
  6. ; -------- --- --- ------------------------------------------------------
  7. ; 06/29/90 MKS C04 Bug#1150. Video 7 Fastwrite VGA has problems if a
  8. ; Hercules mono board is the active display.
  9. ;******************************************************************************
  10. ;****************** START OF SPECIFICATIONS **************************
  11. ; MODULE NAME: IOCTL.ASM
  12. ; DESCRIPTIVE NAME: PERFORM THE GENERIC IOCTL CALL IN ANSI.SYS
  13. ; FUNCTION: THE GENERIC DEVICE IOCTL IS USED TO SET AND GET THE
  14. ; MODE OF THE DISPLAY DEVICE ACCORDING TO PARAMETERS PASSED
  15. ; IN A BUFFER. ADDITIONALLY, THE CALL CAN TOGGLE THE
  16. ; USE OF THE INTENSITY BIT, AND CAN LOAD THE 8X8 CHARACTER
  17. ; SET, EFFECTIVELY GIVING MORE LINES PER SCREEN. THE
  18. ; AVAILABILITY OF THIS FUNCTION VARIES STRONGLY WITH HARDWARE
  19. ; ATTACHED.
  20. ; ENTRY POINT: GENERIC_IOCTL
  21. ; INPUT: LOCATION OF REQUEST PACKET STORED DURING STRATEGY CALL.
  22. ; AT EXIT:
  23. ; NORMAL: CARRY CLEAR - DEVICE CHARACTERISTICS SET
  24. ; ERROR: CARRY SET - ERROR CODE IN AX.
  25. ; AX = 1 - INVALID FUNCTION. EXTENDED ERROR = 20
  26. ; AX = 10 - UNSUPPORTED FUNCTION ON CURRENT HARDWARE.
  27. ; EXTENDED ERROR = 29
  28. ; AX = 12 - DISPLAY.SYS DOES NOT HAVE 8X8 RAM CHARACTER SET.
  29. ; EXTENDED ERROR = 31
  30. ; INTERNAL REFERENCES:
  31. ; ROUTINES: GET_IOCTL - PERFORMS THE GET DEVICE CHARACTERISTICS
  32. ; SET_IOCTL - PERFORMS THE SET DEVICE CHARACTERISTICS
  33. ; GET_SEARCH - SEARCHES THE INTERNAL VIDEO TABLE FOR THE
  34. ; CURRENT MODE MATCH
  35. ; SET_SEARCH - SEARCHES THE INTERNAL VIDEO TABEL FOR THE
  36. ; CURRENT MODE MATCH
  37. ; SET_CURSOR_EMUL - SETS THE BIT THAT CONTROLS CURSOR EMULATION
  38. ; INT10_COM - INTERRUPT 10H HANDLER TO KEEP CURRENT SCREEN SIZE
  39. ; INT2F_COM - INTERRUPT 2FH INTERFACE TO GENERIC IOCTL
  40. ; MAP_DOWN - PERFORMS CURSOR TYPE MAPPING FOR EGA WITH MONOCHROME
  41. ; SET_VIDEO_MODE - SETS THE VIDEO MODE
  42. ; DATA AREAS: SCAN_LINE_TABLE - HOLDS SCAN LINE INFORMATION FOR PS/2
  43. ; FUNC_INFO - BUFFER FOR PS/2 FUNCTIONALITY CALL.
  44. ; EXTERNAL REFERENCES:
  45. ; ROUTINES: INT 10H SERVICES
  46. ; DATA AREAS: VIDEO_MODE_TABLE - INTERNAL TABLE FOR CHARACTERISTICS TO MODE
  47. ; MATCH-UPS
  48. ; NOTES:
  49. ; REVISION HISTORY:
  50. ; Label: "DOS ANSI.SYS Device Driver"
  51. ; "Version 4.00 (C) Copyright 1988 Microsoft"
  52. ; "Licensed Material - Program Property of Microsoft"
  53. ;****************** END OF SPECIFICATIONS ****************************
  54. ;Modification history *********************************************************
  55. ; P1350 Codepage switching not working on EGA 10/10/87 J.K.
  56. ; P1626 ANSI does not allow lines=43 with PS2,Monochrome 10/15/87 J.K.
  57. ; p1774 Lines=43 after selecting cp 850 does not work 10/20/87 J.K.
  58. ; p1740 MODE CON LINES command causes problem with PE2 w PS/210/24/87 J.K.
  59. ; p2167 Does'nt say EGA in medium resol. cannot do 43 lines 10/30/87 J.K.
  60. ; p2236 After esc [=0h, issuing INT10h,AH=fh returns mode=1. 11/3/87 J.K.
  61. ; p2305 With ANSI loaded, loading RDTE hangs the system 11/06/87 J.K.
  62. ; P2617 Order dependecy problem with Display.sys 11/23/87 J.K.
  63. ; p2716 HOT key of VITTORIA does not work properly 12/03/87 J.K.
  64. ; d398 /L option for Enforcing the number of lines 12/17/87 J.K.
  65. ; D425 For OS2 compatibiltiy box, /L option status query 01/14/88 J.K.
  66. ; P5699 Moving selecting alternate print screen routine to only when it
  67. ; 10/26/88 is needed. OEM EGA cards don't support the call it, so they
  68. ; K. Sayers couldn't (shift) print screen at all when the alt. routine was
  69. ; invoked during initialization.
  70. ;******************************************************************************
  71. INCLUDE DEVSYM.INC
  72. INCLUDE ANSI.INC
  73. INCLUDE MULT.INC
  74. PUBLIC GENERIC_IOCTL
  75. PUBLIC SET_IOCTL
  76. PUBLIC GET_IOCTL
  77. PUBLIC SET_SEARCH
  78. PUBLIC GET_SEARCH
  79. PUBLIC SET_CURSOR_EMUL
  80. PUBLIC FUNC_INFO
  81. PUBLIC MAX_SCANS
  82. PUBLIC INT10_COM
  83. PUBLIC SET_MODE_HANDLER
  84. PUBLIC SET_CURSOR_HANDLER
  85. PUBLIC ROM_INT10
  86. PUBLIC INT2F_COM
  87. PUBLIC INT2F_HANDLER
  88. PUBLIC ROM_INT2F
  89. PUBLIC ABORT
  90. PUBLIC MAP_DOWN
  91. PUBLIC SET_VIDEO_MODE
  92. PUBLIC REQ_TXT_LENGTH
  93. PUBLIC GRAPHICS_FLAG
  94. PUBLIC DO_ROWS
  95. PUBLIC Display_Loaded_Before_Me
  96. CODE SEGMENT PUBLIC BYTE
  97. ASSUME CS:CODE,DS:CODE
  98. EXTRN PTRSAV:DWORD
  99. EXTRN NO_OPERATION:NEAR
  100. EXTRN ERR1:NEAR
  101. EXTRN VIDEO_MODE_TABLE:BYTE
  102. EXTRN MAX_VIDEO_TAB_NUM:ABS
  103. EXTRN HDWR_FLAG:WORD
  104. EXTRN SCAN_LINES:BYTE
  105. EXTRN SWITCH_L:Byte ;Defined in ANSI.ASM
  106. IFDEF JAPAN
  107. EXTRN row_adj:byte
  108. ENDIF
  109. SCAN_LINE_TABLE LABEL BYTE
  110. SCAN_LINE_STR <200,000000001B,0> ; 200 scan lines
  111. SCAN_LINE_STR <344,000000010B,1> ; 350 scan lines
  112. SCAN_LINE_STR <400,000000100B,2> ; 400 scan lines
  113. SCANS_AVAILABLE EQU ($ - SCAN_LINE_TABLE)/TYPE SCAN_LINE_STR
  114. ;This is used when ANSI calls Get_IOCTL, Set_IOCTL by itself.
  115. In_Generic_IOCTL_flag db 0
  116. I_AM_IN_NOW EQU 00000001b
  117. SET_MODE_BY_DISPLAY EQU 00000010b ;Display.sys calls Set mode INT 10h.
  118. CALLED_BY_INT10COM EQU 00000100b ;To prevent from calling set mode int 10h again.
  119. INT10_V_Mode db 0ffh ;Used by INT10_COM
  120. My_IOCTL_Req_Packet REQ_PCKT <0,0,0Eh,0,?,0,?,?,?,?,?>
  121. FUNC_INFO INFO_BLOCK <> ;data block for functionality call
  122. ROM_INT10 DW ? ;segment and offset of original..
  123. DW ? ;interrupt 10h vector.
  124. ROM_INT2F DW ? ;segment and offset of original..
  125. DW ? ;interrupt 2Fh vector.
  126. INTENSITY_FLAG DW OFF ;intensity flag initially off
  127. REQ_TXT_LENGTH DW DEFAULT_LENGTH ;requested text screen length
  128. SCAN_DESIRED DB 0 ;scan lines desired
  129. MAX_SCANS DB 0 ;maximum scan line setting
  130. GRAPHICS_FLAG DB TEXT_MODE ;flag for graphics mode
  131. Display_Loaded_Before_Me db 0 ;flag
  132. ANSI_SetMode_Call_Flag db 0 ;Ansi is issuing INT10,AH=0.
  133. ALT_PRT_SC_INVOKED DB FALSE ;indicates that have already set up alternat print screen routine
  134. ; PROCEDURE_NAME: GENERIC_IOCTL
  135. ; FUNCTION:
  136. ; TO GET OR SET DEVICE CHARACTERISTICS ACCORDING TO THE BUFFER PASSED
  137. ; IN THE REQUEST PACKET.
  138. ; AT ENTRY:
  139. ; AT EXIT:
  140. ; NORMAL: CARRY CLEAR - DEVICE CHARACTERISTICS SET
  141. ; ERROR: CARRY SET - ERROR CODE IN AL. (SEE MODULE DESCRIPTION ABOVE).
  142. ; NOTE: THIS PROC IS PERFORMED AS A JMP AS WITH THE OLD ANSI CALLS.
  143. GENERIC_IOCTL:
  144. les bx,[PTRSAV] ; establish addressability to request header
  145. mov al,es:[bx].MINORFUNCTION
  146. les di,es:[bx].GENERICIOCTL_PACKET ; point to request packet
  147. cmp al,GET_FUNC ; is this get subfunction?
  148. jnz gi_not_get
  149. call GET_IOCTL ; yes...execute routine
  150. jmp short gi_check_error
  151. gi_not_get:
  152. cmp al,SET_FUNC ; is this the set subfunction?
  153. jnz gi_none
  154. call SET_IOCTL ; yes....execute routine
  155. gi_check_error:
  156. jnc gi_done ; branch if no error
  157. or ax,CMD_ERROR ; yes...set error bit in status
  158. gi_done:
  159. or ax,DONE ; add done bit to status
  160. jmp ERR1 ; return with status in ax
  161. gi_none:
  162. jmp NO_OPERATION ; call lower CON device
  163. ; PROCEDURE_NAME: GET_IOCTL
  164. ; FUNCTION:
  165. ; THIS PROCEDURE RETURNS DEVICE CHARACTERISTICS.
  166. ; AT ENTRY: ES:DI POINTS TO REQUEST BUFFER
  167. ; AT EXIT:
  168. ; NORMAL: CARRY CLEAR - REQUEST BUFFER CONTAINS DEVICE CHARACTERISTICS
  169. ; ERROR: CARRY SET - ERROR CONDITION IN AX
  170. GET_IOCTL PROC NEAR
  171. cmp es:[di].INFO_LEVEL,0 ; check for valid info level
  172. jnz gi_invalid
  173. cmp es:[di].DATA_LENGTH,TYPE MODE_TABLE+1 ; and buffer size
  174. jge gi_valid
  175. gi_invalid:
  176. mov ax,INVALID_FUNC ; not valid...unsupported
  177. stc ; function..set error flag and
  178. ret
  179. gi_valid:
  180. mov es:[di].INFO_LEVEL+1,0 ; set reserved byte to 0.
  181. mov ah,REQ_VID_MODE ; request current video mode
  182. int 10H
  183. and al,VIDEO_MASK
  184. lea si,VIDEO_MODE_TABLE ; point to resident video table
  185. call GET_SEARCH ; perform search
  186. jnc gi_supported ; found?
  187. mov ax,NOT_SUPPORTED ; no....load unsupported function
  188. ret ; carry already set
  189. gi_supported:
  190. push di ;Save Request Buffer pointer
  191. mov WORD PTR es:[di].DATA_LENGTH,(TYPE MODE_TABLE)+1 ;length of data is struc size
  192. inc si ; skip mode value
  193. add di,RP_FLAGS ; point to flag word
  194. ; VGA,MCGA: VALUE RETURNED FROM FUNCTIONALITY CALL
  195. ; EGA: VALUE LAST SET THROUGH IOCTL. DEFAULT IS BLINKING.
  196. ; CGA,MONO: BLINKING
  197. cmp al,7 ; M004; Monochrome screen?
  198. mov ax,OFF ; assume CGA,MONO
  199. ; (we always have blink).
  200. jz gi_flags_done ; M004;
  201. cmp HDWR_FLAG,MCGA_ACTIVE ; if we have an EGA or better
  202. jl gi_flags_done
  203. test HDWR_FLAG,VGA_ACTIVE ; VGA supported?
  204. jz gi_as_intensity_flag
  205. push es ; yes...prepare for
  206. push di ; functionality call
  207. push ds
  208. pop es
  209. lea di,FUNC_INFO ; point to data block
  210. mov ah,FUNC_CALL ; load function number
  211. xor bx,bx ; implementation type 0
  212. int 10H
  213. mov INTENSITY_FLAG,OFF ; assume no intensity
  214. test es:[di].MISC_INFO,INT_BIT ; is blink bit set?
  215. jnz gi_intensity_is_fine ; if not no intensity
  216. inc INTENSITY_FLAG ; we want intensity
  217. gi_intensity_is_fine:
  218. pop di ; restore registers
  219. pop es
  220. gi_as_intensity_flag:
  221. mov ax,INTENSITY_FLAG ; write the control flag..
  222. gi_flags_done:
  223. stosw ; write the control flag..
  224. ; point to next field (display)
  225. mov cx,(TYPE MODE_TABLE)-1 ; load count
  226. rep movsb ; transfer data from video table
  227. ; to request packet
  228. sub si,TYPE MODE_TABLE ; point back to start of mode data
  229. ifdef JAPAN
  230. dec di ; point to number of rows
  231. dec di
  232. ENDIF
  233. cmp [si].D_MODE,TEXT_MODE ; if we are in text mode and
  234. jnz gi_row_counted
  235. cmp [si].SCR_ROWS,DEFAULT_LENGTH ; length <> 25 then we have an EGA or VGA
  236. jz gi_row_counted
  237. ifndef JAPAN
  238. dec di ; point back to length entry in req packet
  239. dec di
  240. ENDIF
  241. push ds
  242. mov ax,ROM_BIOS ; load ROM BIOS data area segment
  243. mov ds,ax
  244. mov al,BYTE PTR ds:[NUM_ROWS] ; load current number of rows
  245. cbw
  246. inc ax ; add 1 to row count
  247. mov WORD PTR es:[di],ax ; and copy to request packet
  248. pop ds
  249. gi_row_counted:
  250. ifdef JAPAN
  251. mov al,row_adj
  252. xor ah,ah
  253. sub es:[di],ax ; support ESC[>1l
  254. ENDIF
  255. xor ax,ax ; no errors
  256. clc ; clear error flag
  257. pop di ; Restore Request Buffer pointer
  258. ret ; return to calling module
  259. GET_IOCTL ENDP
  260. ; PROCEDURE_NAME: SET_IOCTL
  261. ; FUNCTION:
  262. ; THIS PROCEDURE SETS THE VIDEO MODE AND CHARACTER SET ACCORDING
  263. ; TO THE CHARACTERSTICS PROVIDED.
  264. ; AT ENTRY:
  265. ; ES:[DI] POINTS TO REQUEST BUFFER
  266. ; AT EXIT:
  267. ; NORMAL: CLEAR CARRY - VIDEO MODE SET
  268. ; ERROR: CARRY SET - ERROR CONDITION IN AX
  269. SET_IOCTL PROC NEAR
  270. or In_Generic_IOCTL_Flag, I_AM_IN_NOW ; Signal GENERIC_IOCTL request being processed
  271. push REQ_TXT_LENGTH ; save old value in case of error
  272. ifdef JAPAN
  273. push word ptr row_adj
  274. endif
  275. cmp es:[di].INFO_LEVEL,0 ; check for valid info level
  276. jnz si_invalid
  277. cmp es:[di].DATA_LENGTH,TYPE MODE_TABLE+1 ; ane buffer size
  278. jnz si_invalid
  279. mov ax,es:[di].RP_FLAGS ; test for invalid flags
  280. test ax,INVALID_FLAGS
  281. jnz si_invalid
  282. test es:[di].RP_FLAGS,ON ; if intensity is requested and..
  283. jz si_valid
  284. cmp HDWR_FLAG,MCGA_ACTIVE ; hardware does not support it
  285. jge si_valid
  286. si_invalid:
  287. mov ax,INVALID_FUNC ; not valid...unsupported..
  288. jmp si_failed
  289. si_valid:
  290. call SET_SEARCH ; search table for match
  291. jnc si_mode_valid
  292. si_not_supp:
  293. jmp si_not_supported
  294. si_mode_valid:
  295. cmp [si].D_MODE,TEXT_MODE ; is a text mode being requested?
  296. jz si_do_text_mode
  297. call SET_VIDEO_MODE
  298. jmp si_end_ok
  299. si_do_text_mode:
  300. mov ax,es:[di].RP_ROWS ; save new requested value.
  301. ifdef JAPAN
  302. mov row_adj,0
  303. cmp ax,DEFAULT_LENGTH-1
  304. jnz @f
  305. mov row_adj,1
  306. inc ax
  307. @@:
  308. endif
  309. mov REQ_TXT_LENGTH,ax
  310. cmp ax,DEFAULT_LENGTH ; is it just 25 lines needed?
  311. jz si_display_ok
  312. mov ax,DISPLAY_CHECK
  313. int 2FH
  314. cmp al,INSTALLED ; or is DISPLAY.SYS not there?
  315. jnz si_display_ok
  316. mov ax,CHECK_FOR_FONT
  317. int 2FH ; or if it is does it have the..
  318. jnc si_display_ok
  319. mov ax,NOT_AVAILABLE ; DISPLAY.SYS does not have the font
  320. jmp si_failed
  321. si_display_ok:
  322. cmp [si].SCR_ROWS,UNOCCUPIED
  323. jz si_is_vga
  324. test HDWR_FLAG,VGA_ACTIVE
  325. jz si_non_vga
  326. si_is_vga:
  327. mov ax,1A00h ;Get currently active adap.;C04
  328. int 10h ;VGA interrupt ;C04
  329. mov ax,REQ_TXT_LENGTH ; restore AX
  330. cmp bl,7 ;Q: non_vga adapter? ;C04
  331. jb si_non_vga ;Yes so do other stuff ;C04
  332. process_vga:
  333. mov cl,3 ; ax loaded with length requested
  334. shl ax,cl ; mulitply by 8 to get scan lines
  335. lea bx,SCAN_LINE_TABLE ; load bx with scan line table start
  336. mov cx,SCANS_AVAILABLE ; total number of scan lines settings
  337. pv_while:
  338. cmp ax,[bx].NUM_LINES ; pointing at the right setting?
  339. jz pv_found
  340. add bx,TYPE SCAN_LINE_STR ; not this setting..point to next
  341. loop pv_while
  342. jmp short si_not_supp
  343. pv_found:
  344. mov dl,[bx].REP_1BH
  345. test SCAN_LINES,dl ; does the hardware have it?
  346. jz si_not_supp
  347. mov cl,[bx].REP_12H ; yes, store value to set it
  348. mov SCAN_DESIRED,cl
  349. cmp REQ_TXT_LENGTH,DEFAULT_LENGTH ; 25 lines requested?
  350. jnz pv_scan_ok
  351. mov al,MAX_SCANS ; desired scan setting should be..
  352. mov SCAN_DESIRED,AL ; the maximum.
  353. pv_scan_ok:
  354. ; following added to overcome problems with rolling
  355. ; screens in QBX and WZMAIL. Problem still exists when switching between
  356. ; mono and VGA screens when ANSI is loaded with /L.
  357. test In_Generic_IOCTL_Flag,CALLED_BY_INT10COM
  358. jnz si_set_mode_done
  359. mov ah,ALT_SELECT ; set the appropriate number..
  360. mov bl,SELECT_SCAN ; of scan lines..
  361. mov al,SCAN_DESIRED
  362. int 10H
  363. jmp short si_processed
  364. si_non_vga:
  365. mov ax,REQ_TXT_LENGTH
  366. cmp ax,DEFAULT_LENGTH ; see if length requested..
  367. jz si_cursor_emul ; is valid
  368. cmp ax,[si].SCR_ROWS
  369. jnz si_not_supported
  370. si_cursor_emul:
  371. call SET_CURSOR_EMUL
  372. si_processed:
  373. call SET_VIDEO_MODE
  374. si_set_mode_done:
  375. call DO_ROWS
  376. cmp ALT_PRT_SC_INVOKED,FALSE ; If not set up already
  377. jnz si_printscreen_ok
  378. cmp es:[di].RP_ROWS,DEFAULT_LENGTH ; and needed because lines (or 30?)
  379. jle si_printscreen_ok
  380. cmp HDWR_FLAG,MCGA_ACTIVE ; and if we have EGA or better then.. (supported)
  381. jl si_printscreen_ok
  382. mov ah,ALT_SELECT ; issue select alternate print..
  383. mov BL,ALT_PRT_SC ; screen routine call..
  384. int 10H
  385. mov ALT_PRT_SC_INVOKED,TRUE ; mark that it was done
  386. si_printscreen_ok:
  387. call SET_CURSOR_EMUL ; yes..ensure cursor emulation
  388. ; is set accordingly.
  389. cmp HDWR_FLAG,MCGA_ACTIVE ; for the EGA and better...
  390. jl si_end_ok
  391. cmp [si].V_MODE,7 ; M004; and not monochrome
  392. jz si_end_ok
  393. xor bx,bx ; bx: 1=intensity on, 0: off
  394. ; assume off
  395. test es:[di].RP_FLAGS,ON
  396. jz si_intensity_ok
  397. inc bx ; user wants intensity
  398. si_intensity_ok:
  399. mov INTENSITY_FLAG,bx
  400. mov ax,BLINK_TOGGLE
  401. xor bl,ON ; bl is opposite
  402. ; of INTENSITY_FLAG
  403. int 10H
  404. si_end_ok:
  405. and In_Generic_IOCTL_Flag, NOT I_AM_IN_NOW ; Turn the flag off
  406. ifdef JAPAN
  407. pop ax ; throw old row_adj
  408. endif
  409. pop ax ; forget old REQ_TXT_LENGTH
  410. xor ax,ax ; clear error register
  411. clc ; clear error flag
  412. ret
  413. si_not_supported:
  414. mov ax,NOT_SUPPORTED
  415. si_failed:
  416. and In_Generic_IOCTL_Flag, NOT I_AM_IN_NOW ; Turn the flag off
  417. ifdef JAPAN
  418. pop word ptr row_adj
  419. endif
  420. pop REQ_TXT_LENGTH ; error...so restore old value.
  421. stc ; set error flag
  422. ret
  423. SET_IOCTL ENDP
  424. ; Procedure name: DO_ROWS
  425. ; Function:
  426. ; Only called for TEXT_MODE.
  427. ; If (REQ_TXT_LENGTH <> DEFAULT_LENGTH) &
  428. ; (DISPLAY.SYS not loaded or CODEPAGE not active)
  429. ; then
  430. ; LOAD ROM 8X8 charater.
  431. DO_ROWS PROC NEAR
  432. cmp req_txt_length, DEFAULT_LENGTH
  433. je dr_exit
  434. mov ax,LOAD_8X8 ; load 8x8 ROM font
  435. xor bl,bl
  436. int 10H ; M003;
  437. mov ax,SET_BLOCK_0 ; activate block = 0
  438. xor bl,bl
  439. int 10H ; M003;
  440. dr_exit:
  441. ret
  442. DO_ROWS ENDP
  443. ; PROCEDURE_NAME: SET_SEARCH
  444. ; FUNCTION:
  445. ; THIS PROCEDURE SEARCHES THE RESIDENT VIDEO TABLE IN ATTEMPT TO
  446. ; FIND A MODE THAT MATCHES THE CHARACTERISTICS REQUESTED.
  447. ; AT ENTRY:
  448. ; AT EXIT:
  449. ; NORMAL: CARRY CLEAR - SI POINTS TO APPLICABLE RECORD
  450. ; ERROR: CARRY SET
  451. ; When INT10_V_Mode <> 0FFH, then assumes that the user
  452. ; issuing INT10h, Set mode function call. Unlike Generic IOCTL
  453. ; set mode call, the user already has taken care of the video mode.
  454. ; So, we also find the matching V_MODE.
  455. ; WARNING: TRASH CX
  456. SET_SEARCH PROC NEAR
  457. lea si,VIDEO_MODE_TABLE ; point to video table
  458. mov cx,MAX_VIDEO_TAB_NUM ; load counter, # of tables
  459. ss_while:
  460. cmp [si].V_MODE,UNOCCUPIED ; while we have valid entries
  461. jz ss_not_found
  462. mov al,INT10_V_Mode
  463. cmp al,0ffh ; if not issued by Int10 set mode,
  464. jnz ss_from_set_mode
  465. mov al,es:[di].RP_MODE ; load register for compare.
  466. cmp [si].D_MODE,al ; match?
  467. jnz ss_end_while
  468. mov ax,es:[di].RP_COLORS ; yes...prepare next field
  469. cmp [si].COLORS,ax ; match?
  470. jnz ss_end_while
  471. cmp es:[di].RESERVED2,0 ; yes, ensure reserved byte is zero
  472. jnz ss_end_while
  473. cmp es:[di].RP_MODE,GRAPHICS_MODE ; for graphics mode
  474. jnz ss_not_graphic ; check the following:
  475. mov ax,es:[di].RP_WIDTH ; screen width.
  476. cmp [si].SCR_WIDTH,ax
  477. jnz ss_end_while
  478. mov ax,es:[di].RP_LENGTH ; screen length
  479. cmp [si].SCR_LENGTH,ax
  480. jnz ss_end_while ; ignore #rows and #coloumns
  481. jmp short ss_found
  482. ss_not_graphic:
  483. mov ax,es:[di].RP_COLS ; the rows are matched
  484. cmp [si].SCR_COLS,ax ; in the main routine
  485. jnz ss_end_while
  486. ss_found:
  487. clc
  488. jmp short ss_done
  489. ss_from_set_mode:
  490. cmp [si].V_MODE,al ; if V_MODE = AL, we are ok
  491. jz ss_found
  492. ss_end_while:
  493. add si,type MODE_TABLE ; then, this is not the correct entry.
  494. loop ss_while ; Let's find the next entry.
  495. ss_not_found:
  496. stc
  497. ss_done:
  498. mov INT10_V_Mode, 0FFh ; Done. Reset the value
  499. ret
  500. SET_SEARCH ENDP
  501. ; PROCEDURE_NAME: GET_SEARCH
  502. ; FUNCTION:
  503. ; THIS PROCEDURE SEARCHES THE VIDEO TABLE LOOKING FOR A MATCHING
  504. ; VIDEO MODE.
  505. ; AT ENTRY: DS:SI POINTS TO VIDEO TABLE
  506. ; AL CONTAINS THE MODE REQUESTED
  507. ; AT EXIT:
  508. ; NORMAL: CARRY CLEAR, DS:SI POINTS TO MATCHING RECORD
  509. ; ERROR: CARRY SET
  510. ; WARNING: TRASH CX
  511. GET_SEARCH PROC NEAR
  512. mov cx,MAX_VIDEO_TAB_NUM ; # of total tables
  513. gs_while:
  514. cmp [si].V_MODE,UNOCCUPIED ; while we're not pointing to
  515. jz gs_error
  516. cmp [si].V_MODE,al ; the right mode and we are still
  517. jz gs_got_it
  518. add si,TYPE MODE_TABLE ; point to the next mode
  519. loop gs_while
  520. gs_error:
  521. stc ; no, set error flag
  522. ret
  523. gs_got_it:
  524. clc
  525. ret
  526. GET_SEARCH ENDP
  527. ; PROCEDURE_NAME: SET_CURSOR_EMUL
  528. ; FUNCTION:
  529. ; THIS PROCEDURE SETS THE CURSOR EMULATION BIT OFF IN ROM BIOS. THIS
  530. ; IS TO PROVIDE A CURSOR ON THE EGA WITH THE 5154 LOADED WITH AN 8X8
  531. ; CHARACTER SET.
  532. ; AT ENTRY:
  533. ; AT EXIT:
  534. ; NORMAL: CURSOR EMULATION BIT SET FOR APPLICABLE HARDWARE
  535. ; ERROR: N/A
  536. SET_CURSOR_EMUL PROC NEAR
  537. test HDWR_FLAG,E5154_ACTIVE ; EGA with 5154?
  538. jz sce_done
  539. push si
  540. push ds ; yes..so..
  541. mov ax,ROM_BIOS ; check cursor emulation..
  542. mov ds,ax
  543. mov si,CURSOR_FLAG
  544. mov al,BYTE PTR [si]
  545. cmp cs:REQ_TXT_LENGTH,DEFAULT_LENGTH; >25 lines req?
  546. jnz sce_cursor_on
  547. and al,TURN_OFF ; no....set it OFF
  548. jmp short sce_cursor_ok
  549. sce_cursor_on:
  550. or al,TURN_ON ; yes...set it ON
  551. sce_cursor_ok:
  552. mov BYTE PTR [si],AL
  553. pop ds
  554. pop si
  555. sce_done:
  556. ret ; return to calling module
  557. SET_CURSOR_EMUL ENDP
  558. ; PROCEDURE_NAME: INT10_COM
  559. ; FUNCTION:
  560. ; THIS IS THE INTERRUPT 10H HANDLER TO CAPTURE THE FOLLOWING FUNCTIONS:
  561. ; AH=1H (SET CURSOR TYPE). CURSOR EMULATION IS PERFORMED IF WE HAVE
  562. ; AND EGA WITH A 5151 MONITOR, AND 43 LINES IS REQUESTED.
  563. ;M002; What is bellow was modified. The /L option was removed. But ansi
  564. ;M002; will still do a GET_IOCTL/SET_IOCTL for the application.
  565. ; AH=0H (SET MODE) SCREEN LENGTH IS MAINTAINED WHEN POSSIBLE. (IE. IN
  566. ; TEXT MODES ONLY.)
  567. ; AN004; Capturing Set Mode call and enforcing the # of Rows based on the
  568. ; previous Set_IOCTL request lines was a design mistake. ANSI cannot
  569. ; covers the all the application program out there which use INT 10h
  570. ; directly to make a full screen interface by their own way.
  571. ; This part of logic has been taken out by the management decision.
  572. ; Instead, for each set mdoe INT 10h function call, if it were not
  573. ; issued by SET_IOCTL procedures itself, or by DISPLAY.SYS program,
  574. ; then we assume that it was issued by an APPS, that usually does not
  575. ; know the new ANSI GET_IOCTL/SET_IOCTL interfaces.
  576. ; In this case, ANSI is going to call GET_IOCTL and SET_IOCTL function
  577. ; call - This is not to lose the local data consistency in ANSI.
  578. ; AT ENTRY:
  579. ; AT EXIT:
  580. ; NORMAL:
  581. ; ERROR:
  582. INT10_COM PROC NEAR
  583. sti ; restore interrupts
  584. cmp ah,SET_CURSOR_CALL
  585. jz SET_CURSOR_HANDLER
  586. cmp ah,SET_MODE
  587. jz SET_MODE_HANDLER
  588. jmp DWORD PTR cs:ROM_INT10 ; no...pass it on.
  589. SET_CURSOR_HANDLER:
  590. push ax
  591. test cs:HDWR_FLAG,E5151_ACTIVE ; do we have an EGA?
  592. jz sch_goto_rom
  593. cmp cs:REQ_TXT_LENGTH,DEFAULT_LENGTH
  594. jz sch_goto_rom
  595. cmp cs:GRAPHICS_FLAG,TEXT_MODE ; with 5151..so perform cursor mapping
  596. jnz sch_goto_rom
  597. cmp cl,8
  598. jl sch_goto_rom
  599. mov al,ch ; check for cursor..
  600. and al,60h ; off emulation. J.K.
  601. cmp al,20h
  602. jz sch_goto_rom
  603. mov al,ch ; start position for cursor
  604. call MAP_DOWN
  605. mov ch,al
  606. mov al,cl ; end position for cursor
  607. call MAP_DOWN
  608. mov cl,al
  609. sch_goto_rom:
  610. pop ax
  611. jmp DWORD PTR CS:ROM_INT10 ; continue interrupt processing
  612. SET_MODE_HANDLER:
  613. pushf ; prepare for IRET
  614. mov cs:ANSI_SetMode_Call_Flag, 1 ; Used by INT2F_COM
  615. call DWORD PTR CS:ROM_INT10 ; call INT10 routine
  616. mov cs:ANSI_SetMode_Call_Flag, 0 ; Reset it
  617. push bp
  618. push es
  619. push ds
  620. push si
  621. push di
  622. push dx
  623. push cx
  624. push bx
  625. push ax
  626. push cs
  627. pop ds
  628. mov ah,REQ_VID_MODE ; get current mode..
  629. pushf
  630. call DWORD PTR ROM_INT10
  631. and al,VIDEO_MASK ; mask bit 7 (refresh)
  632. test In_Generic_IOCTL_Flag, (I_AM_IN_NOW + SET_MODE_BY_DISPLAY) ; Flag is on?
  633. ;If not (I_AM_IN_NOW or SET_MODE_BY_DISPLAY),
  634. jnz smh_ioctl_done
  635. ; cmp SWITCH_L,0 ;M002; No more /L
  636. ; jnz smh_ioctl_done ;M002; No more /L
  637. push ax ;Save mode
  638. push es
  639. push cs
  640. pop es
  641. mov di,offset My_IOCTL_Req_Packet
  642. mov INT10_V_Mode,al ;Save current mode for SET_SEARCH
  643. call Get_IOCTL
  644. jc smh_set_ioctl_done
  645. or In_Generic_IOCTL_Flag, CALLED_BY_INT10COM ;Do not set mode INT 10h again. Already done.
  646. call Set_IOCTL
  647. and In_Generic_IOCTL_Flag, not CALLED_BY_INT10COM
  648. smh_set_ioctl_done:
  649. pop es
  650. pop ax ;Restore mode
  651. mov INT10_V_Mode,0FFh
  652. smh_ioctl_done:
  653. lea si,VIDEO_MODE_TABLE
  654. call GET_SEARCH ; look through table for mode selected.
  655. jc smh_graphic_mode ; M001; if not found then
  656. ; M001; assume graphic mode
  657. cmp [si].D_MODE,TEXT_MODE ; text mode?
  658. jz smh_text_mode
  659. smh_graphic_mode:
  660. mov GRAPHICS_FLAG,GRAPHICS_MODE ; no, set graphics flag
  661. jmp short smh_flag_done
  662. smh_text_mode:
  663. mov GRAPHICS_FLAG,TEXT_MODE ; set TEXT MODE
  664. smh_flag_done:
  665. ; test In_Generic_IOCTL_Flag, I_AM_IN_NOW
  666. ; jnz smh_l_done ; M002; No more /L
  667. ; cmp Graphics_Flag,TEXT_MODE ; M002; No more /L
  668. ; jnz smh_l_done ; M002; No more /L
  669. ; cmp SWITCH_L,1 ; M002; No more /L
  670. ; jnz smh_l_done ; M002; No more /L
  671. ; call DO_ROWS ; M002; No more /L
  672. smh_l_done:
  673. ;For each SET mode function int 10h function call, if it is not
  674. ;issued by ANSI GET_IOCTL and SET_IOCTL procedure themselves, we assume
  675. ;that the APPS, which usually does not know the ANSI GET_IOCTL/SET_IOCTL
  676. ;interfaces, intend to change the screen mode. In this case, ANSI is
  677. ;kind enough to call GET_IOCTL and SET_IOCTL function call for themselves.
  678. pop ax
  679. pop bx
  680. pop cx
  681. pop dx
  682. pop di
  683. pop si
  684. pop ds
  685. pop es
  686. pop bp
  687. iret
  688. INT10_COM ENDP
  689. ; PROCEDURE_NAME: INT2F_COM
  690. ; FUNCTION:
  691. ; THIS IS THE INTERRUPT 2FH HANDLER TO CAPTURE THE FOLLOWING FUNCTIONS:
  692. ; ax=1A00H INSTALL REQUEST. ANSI WILL RETURN AL=FFH IF LOADED.
  693. ; AH=1A01H THIS IS THE INT2FH INTERFACE TO THE GENERIC IOCTL.
  694. ; NOTE: THE GET CHARACTERISTICS FUNCTION CALL WILL RETURN
  695. ; THE REQ_TXT_LENGTH IN THE BUFFER AS OPPOSED TO
  696. ; THE ACTUAL HARDWARE SCREEN_LENGTH
  697. ; Ax=1A02h This is an information passing from DISPLAY.SYS about
  698. ; the INT 10h, SET MODE call.
  699. ; AT ENTRY:
  700. ; AT EXIT:
  701. ; NORMAL:
  702. ; ERROR:
  703. INT2F_COM PROC NEAR
  704. sti
  705. cmp ah,multANSI ; is this for ANSI?
  706. jnz ic_goto_rom
  707. cmp al,DA_INFO_2F
  708. jle INT2F_HANDLER
  709. ic_goto_rom:
  710. jmp DWORD PTR CS:ROM_INT2F ; no....jump to old INT2F
  711. INT2F_HANDLER:
  712. cmp al,INSTALL_CHECK
  713. jnz ih_not_check
  714. ; do install check
  715. mov al,INSTALLED ; load value to indicate installed
  716. clc ; clear error flag.
  717. jmp ih_iret
  718. ih_not_check:
  719. cmp al,DA_INFO_2F ; IOCTL or INFO passing?
  720. jbe ih_valid
  721. jmp ih_iret
  722. ih_valid:
  723. push bp
  724. push ax ; s
  725. push cx ; a
  726. push dx ; v
  727. push ds ; e r
  728. push es ; e
  729. push di ; g
  730. push si ; s.
  731. push bx
  732. push ds ; load ES with DS (for call)
  733. pop es
  734. mov di,dx ; load DI with dx (for call)
  735. push cs ; setup local addressability
  736. pop ds
  737. cmp al,IOCTL_2F ; IOCTL request
  738. jnz ih_not_ioctl
  739. cmp cl,GET_FUNC ; get function requested.
  740. jnz ih_not_get
  741. call GET_IOCTL
  742. jc ih_set_flags ; if no error and
  743. cmp HDWR_FLAG,E5151_ACTIVE ; >25 lines supported
  744. jl ih_set_flags
  745. cmp [si].D_MODE,TEXT_MODE ; this is a text mode then..
  746. jnz ih_set_flags
  747. ; cmp SWITCH_L,1 ; M002; No more /L
  748. ; jz ih_use_rtl ; M002; No more /L
  749. cmp ANSI_SetMode_Call_Flag,1
  750. jnz ih_use_rtl ; if not originated by ANSI thru AH=0, Int10
  751. cmp Display_Loaded_Before_me,1 ; or Display.sys not loaded before ANSI,
  752. jz ih_get_ok
  753. ih_use_rtl:
  754. mov bx,REQ_TXT_LENGTH ; then use REQ_TXT_LENGTH instead..
  755. ifdef JAPAN
  756. sub bl,row_adj
  757. endif
  758. mov es:[di].RP_ROWS,bx
  759. ih_get_ok:
  760. clc
  761. jmp short ih_set_flags
  762. ih_not_get:
  763. cmp cl,SET_FUNC
  764. jnz ih_invalid
  765. call SET_IOCTL ; set function requested.
  766. jmp short ih_set_flags
  767. ; invalid function
  768. ih_invalid:
  769. mov ax,INVALID_FUNC ; load error and...
  770. stc ; set error flag.
  771. jmp short ih_set_flags ; Info. passing
  772. ih_not_ioctl:
  773. cmp es:[di].DA_INFO_LEVEL,0 ; 0 - DA_SETMODE_FLAG request
  774. jnz ih_not_info
  775. cmp es:[di].DA_SETMODE_FLAG,1
  776. jnz ih_not_set
  777. or In_Generic_IOCTL_Flag, SET_MODE_BY_DISPLAY ;Turn the flag on
  778. jmp short ih_info_ok
  779. ih_not_set:
  780. and In_Generic_IOCTL_Flag, not SET_MODE_BY_DISPLAY ;Turn the flag off
  781. jmp short ih_info_ok
  782. ih_not_info:
  783. cmp es:[di].DA_INFO_LEVEL,1 ; 1 = DA_L_STATA query
  784. jnz ih_info_ok
  785. ; mov al,cs:[SWITCH_L] ; M002; No more /L
  786. mov al,OFF ; M002; No more /L
  787. mov es:[di].DA_L_STATE, al
  788. ih_info_ok:
  789. clc ; clear carry. There is no Error in DOS 4.00 for this call.
  790. ih_set_flags:
  791. pop bx ; restore all..
  792. pop si
  793. pop di ; registers except..
  794. pop es
  795. pop ds ; BP.
  796. pop dx
  797. pop cx
  798. push ax ; save error condition
  799. mov bp,sp ; setup frame pointer
  800. mov ax,[bp+10] ; load stack flags
  801. jc ih_error ; carry set???
  802. and ax,NOT_CY ; no.. set carry off.
  803. mov [bp+10],ax ; put back on stack.
  804. pop ax ; remove error flag from stack
  805. pop ax ; no error so bring back function call
  806. XCHG ah,al ; exchange to show that ANSI present
  807. jmp short ih_pop_bp
  808. ih_error:
  809. or ax,CY ; yes...set carry on.
  810. mov [bp+10],ax ; put back on stack.
  811. pop ax ; restore error flag
  812. pop bp ; pop off saved value of ax (destroyed)
  813. ih_pop_bp:
  814. pop bp ; restore final register.
  815. ih_iret:
  816. ABORT: iret
  817. INT2F_COM ENDP
  818. ; PROCEDURE_NAME: MAP_DOWN
  819. ; FUNCTION:
  820. ; THIS PROCEDURE MAPS THE CURSOR START (END) POSITION FROM A 14 PEL
  821. ; BOX SIZE TO AN 8 PEL BOX SIZE.
  822. ; AT ENTRY: AL HAS THE CURSOR START (END) TO BE MAPPED.
  823. ; AT EXIT:
  824. ; NORMAL: AL CONTAINS THE MAPPED POSITION FOR CURSOR START (END)
  825. ; ERROR: N/A
  826. MAP_DOWN PROC NEAR
  827. push bx
  828. xor ah,ah ; clear upper byte of cursor position
  829. mov bl,EIGHT ; multiply by current box size.
  830. push dx ; al x
  831. mul bl ; ---- = ---
  832. pop dx ; 14 8
  833. mov bl,FOURTEEN
  834. div bl ; divide by box size expected.
  835. pop bx
  836. ret
  837. MAP_DOWN ENDP
  838. ; PROCEDURE_NAME: SET_VIDEO_MODE
  839. ; FUNCTION:
  840. ; THIS PROCEDURE SETS THE VIDEO MODE SPECIFIED IN DS:[SI].V_MODE.
  841. ; AT ENTRY: DS:SI.V_MODE CONTAINS MODE NUMBER
  842. ; AT EXIT:
  843. ; NORMAL: MODE SET
  844. ; ERROR: N/A
  845. SET_VIDEO_MODE PROC NEAR
  846. test In_Generic_IOCTL_Flag,CALLED_BY_INT10COM
  847. jnz svm_done
  848. mov al,[si].V_MODE ; ..issue set mode
  849. test HDWR_FLAG,LCD_ACTIVE
  850. jnz svm_update_bios ; is this the LCD?
  851. test HDWR_FLAG,VGA_ACTIVE ; or VGA? (done for BRECON card)
  852. jz svm_update_done
  853. svm_update_bios:
  854. push ds ; yes...
  855. mov bl,al ; save mode
  856. mov ax,ROM_BIOS
  857. mov ds,ax ; get equipment status flag..
  858. mov ax,ds:[EQUIP_FLAG]
  859. and ax,INIT_VID_MASK ; clear initial video bits..
  860. cmp bl,MODE7 ; are we setting mono?
  861. jz svm_mono
  862. cmp bl,MODE15
  863. jnz svm_color
  864. svm_mono:
  865. or ax,LCD_MONO_MODE ; yes...set bits as mono
  866. jmp short svm_update_it
  867. svm_color:
  868. or ax,LCD_COLOR_MODE ; no...set bits as color
  869. svm_update_it:
  870. mov ds:[EQUIP_FLAG],ax ; replace updated flag.
  871. mov al,bl ; restore mode.
  872. pop ds
  873. svm_update_done:
  874. mov ah,SET_MODE ; set mode
  875. int 10H
  876. svm_done:
  877. ret
  878. SET_VIDEO_MODE ENDP
  879. CODE ENDS
  880. END
  881.