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.

1350 lines
33 KiB

  1. ;
  2. ; Windows-NT MVDM Japanese DOS/V $DISP.SYS Dispatch Driver (High)
  3. ;
  4. .286
  5. include struc.inc
  6. include disp_win.inc
  7. include vint.inc
  8. ;----------------------------------------------------------------------------;
  9. ; Code Segment
  10. ;----------------------------------------------------------------------------;
  11. TEXT segment byte public
  12. assume cs:TEXT,ds:TEXT,es:TEXT
  13. org 0 ; drivers should start at address 0000h
  14. ; this will cause a linker warning - ignore it.
  15. public Header
  16. Header: ; device driver header
  17. DD fNEXTLINK ; link to next device driver
  18. DW fCHARDEVICE+fOPENCLOSE ; device attribute word:
  19. ; char.device+open/close
  20. DW Strat ; 'Strat' entry point
  21. DW Intr ; 'Intr' entry point
  22. DB 'NTDISP2$' ; logical device name (needs to be 8 chars)
  23. ;----------------------------------------------------------------------------;
  24. ; data variables
  25. ;----------------------------------------------------------------------------;
  26. public null
  27. null dw 0 ; dummy to do a quick erase of pAtomValue
  28. pAtomVal dw offset null ; pointer to value of result of atom search
  29. MemEnd dw ddddhList ; end of used memory: initially AtomList
  30. MaxMem dw ddddhList ; end of available memory: initially AtomList
  31. lpHeader dd 0 ; far pointer to request header
  32. org_int10_add dd 0 ; $disp.sys's int10 vector
  33. new_int10_add dd 0 ; $disp.sys's int10 vector
  34. pass_disp_add dd 0 ; Original int10 vector
  35. org_int08_add dd 0 ; original int 08 vector
  36. dbcs_vector dd 0 ; DBCS Vector address
  37. use_ntdisp_flag db 0
  38. display_mode db 3
  39. window_mode db 0
  40. nt_cons_mode db 0
  41. disp_init_flag db 0
  42. ;; #3086: VDM crash when exit 16bit apps of video mode 11h
  43. ;; 12/9/93 yasuho
  44. IMEStatusLines db 0
  45. setmode_flag db 0 ; for IME status line
  46. cursor_pos dw 0050h
  47. dw 0040h
  48. cursor_type dw 0060h
  49. dw 0040h
  50. bios_disp_mode dw 0049h
  51. dw 0040h
  52. bios_disp_hight dw 0085h
  53. dw 0040h
  54. packet_len dw 30
  55. video_buffer dw 0
  56. dw 0
  57. dmode_add dw 0
  58. dw 0
  59. windowed_add dw 0
  60. dw 0
  61. nt_cons_add dw 0
  62. dw 0
  63. disp_sys_init dw 0
  64. dw 0
  65. fullsc_resume_ptr dw 0
  66. dw 0
  67. ias_setmode_add dw 0
  68. dw 0
  69. ;----------------------------------------------------------------------------;
  70. ; Dispatch table for the interrupt routine command codes
  71. ;----------------------------------------------------------------------------;
  72. public Dispatch
  73. Dispatch:
  74. DW Init ; 0 = init driver
  75. DW Error ; 1 = Media Check (block devices only)
  76. DW Error ; 2 = build BPB (block devices only)
  77. DW Error ; 3 = I/O control read (not supported)
  78. DW Error ; 4 = read (input) from device (int 21h, 3Fh)
  79. DW Error ; 5 = nondestructive read (not supported)
  80. DW Error ; 6 = ret input status (int 21h, 4406h)
  81. DW Error ; 7 = flush device input buffer (not supportd)
  82. DW Error ; 8 = write (output) to device (int 21h, 40h)
  83. DW Error ; 9 = write with verify (== write) (21h, 40h)
  84. DW Error ; 10 = ret output status (int 21h, 4407h)
  85. DW Error ; 11 = flush output buffer (not supported)
  86. DW Error ; 12 = I/O control write (not supported)
  87. DW Success ; 13 = device open (int 21h, 3Dh)
  88. DW Success ; 14 = device close (int 21h, 3Eh)
  89. DW Error ; 15 = removable media (block devices only)
  90. DW Error ; 16 = Output until Busy (mostly for spooler)
  91. DW Error ; 17 = not used
  92. DW Error ; 18 = not used
  93. DW Error ; 19 = generic IOCTL (not supported)
  94. DW Error ; 20 = not used
  95. DW Error ; 21 = not used
  96. DW Error ; 22 = not used
  97. DW Error ; 23 = get logical device (block devices only)
  98. DW Error ; 24 = set logical device (block devices only)
  99. ;----------------------------------------------------------------------------;
  100. ; Dispatch table for the int 10h routine command codes
  101. ;----------------------------------------------------------------------------;
  102. public table_int10
  103. table_int10:
  104. DW mode_set ; 00 = Video mode set
  105. DW ctype_set ; 01 = Cursor type set
  106. DW cpos_set ; 02 = Cursor position set
  107. DW cpos_get ; 03 = Cursor position get
  108. DW go_disp_sys ; 04 = Not used
  109. DW go_disp_sys ; 05 = Use $disp.sys
  110. DW scroll_up ; 06 = Scroll up
  111. DW scroll_down ; 07 = Scroll down
  112. DW read_cell ; 08 = read chractor with attribute
  113. DW write_cell ; 09 = write chractor with attribute
  114. DW write_char ; 0A = write chractor
  115. DW go_disp_sys ; 0B = Not used
  116. DW go_disp_sys ; 0C = Use $disp.sys
  117. DW go_disp_sys ; 0D = Use $disp.sys
  118. DW write_tty ; 0E = write teletype
  119. DW disply_get ; 0F = get display status
  120. DW palet_set ; 10 = set palet registor
  121. DW char_set ; 11 = set sbcs charactor
  122. DW go_disp_sys ; 12 = Not used
  123. DW write_string ; 13 = read / write string
  124. DW go_disp_sys ; 14 = Not used
  125. DW go_disp_sys ; 15 = Not used
  126. DW go_disp_sys ; 16 = Not used
  127. DW go_disp_sys ; 17 = Not used
  128. DW go_disp_sys ; 18 = Use $disp.sys
  129. DW go_disp_sys ; 19 = Not used
  130. DW go_disp_sys ; 1A = Use $disp.sys
  131. DW go_disp_sys ; 1B = Not used
  132. DW go_disp_sys ; 1C = Not used
  133. DW getset_status ; 1D = IME status line manipulate functions
  134. ;; #3176: vz display white letter on white screen
  135. ;; 11/27/93 reviewed by yasuho
  136. ;;
  137. ;; save buffer for color palette and overscan registers.
  138. ;; what we did is we grab an initial set of there values, put it here and
  139. ;; then monitor int10 ah=10xx function to update these value accordiningly
  140. ;; so when win->fullscreen or reenter fullscreen happens, we know what
  141. ;; should be the palette/overscan/DAC should be and retore them
  142. ;; The reason that we are doing this is because console has differernt
  143. ;; palette and DAC(only the first 16 colors).
  144. NUM_PALETTE_REGISTERS equ 16
  145. public Palette_Registers
  146. Palette_Registers label BYTE
  147. DB NUM_PALETTE_REGISTERS dup(?)
  148. Over_Scan_Register label byte
  149. DB ?
  150. NUM_DAC_REGISTERS equ 256
  151. public DAC_Registers
  152. DAC_Registers label BYTE
  153. DB NUM_DAC_REGISTERS * 3 dup(?);
  154. ;; #3741: WordStar6.0: Hilight color is changed after running in window
  155. ;; 12/2/93 yasuho
  156. public Default_Palette_Regs
  157. Default_Palette_Regs label byte
  158. DB NUM_PALETTE_REGISTERS dup(?)
  159. Default_Over_Scan_Regs label byte
  160. DB ?
  161. Default_DAC_Regs label byte
  162. DB 16 * 3 dup(?);
  163. ;; #4210: Status of $IAS not display in full-screen
  164. ;; 12/16/93 yasuho
  165. IMEStat_buffer db 160 dup(?)
  166. ;----------------------------------------------------------------------------;
  167. ; Strategy Routine
  168. ;----------------------------------------------------------------------------;
  169. ; device driver Strategy routine, called by MS-DOS kernel with
  170. ; ES:BX = address of request header
  171. ;----------------------------------------------------------------------------;
  172. public Strat
  173. Strat PROC FAR
  174. mov word ptr cs:[lpHeader], bx ; save the address of the
  175. mov word ptr cs:[lpHeader+2], es ; request into 'lpHeader', and
  176. ret ; back to MS-DOS kernel
  177. Strat ENDP
  178. ;----------------------------------------------------------------------------;
  179. ; Intr
  180. ;----------------------------------------------------------------------------;
  181. ; Device driver interrupt routine, called by MS-DOS kernel after call to
  182. ; Strategy routine
  183. ; This routine basically calls the appropiate driver routine to handle the
  184. ; requested function.
  185. ; Routines called by Intr expect:
  186. ; ES:DI will have the address of the request header
  187. ; DS will be set to cs
  188. ; These routines should only affect ax, saving es,di,ds at least
  189. ;
  190. ; Input: NONE Output: NONE -- data is transferred through request header
  191. ;
  192. ;----------------------------------------------------------------------------;
  193. public Intr
  194. Intr PROC FAR
  195. push ds
  196. push es
  197. pusha ; save registers
  198. pushf ; save flags
  199. cld ; direction flag: go from low to high address
  200. mov si, cs ; make local data addressable
  201. mov ds, si ; by setting ds = cs
  202. les di, [lpHeader] ; ES:DI = address of req.header
  203. xor bx, bx ; erase bx
  204. mov bl,es:[di].ccode ; get BX = command code (from req.header)
  205. mov si,bx
  206. shl si,1
  207. add si,offset dispatch
  208. .IF <bx gt MaxCmd> ; check to make sure we have a valid
  209. call Error ; command code
  210. .ELSE ; else, call command-code routine,
  211. call [si] ; indexed from Dispatch table
  212. .ENDIF ; (Ebx used to allow scaling factors)
  213. or ax, fDONE ; merge Done bit into status and
  214. mov es:[di].stat,ax ; store status into request header
  215. popf ; restore registers
  216. popa ; restore flags
  217. pop es
  218. pop ds
  219. ret ; return to MS-DOS kernel
  220. Intr ENDP
  221. ;----------------------------------------------------------------------------;
  222. ; Success: When the only thing the program needs to do is set status to OK
  223. ;----------------------------------------------------------------------------;
  224. public Success
  225. Success PROC NEAR
  226. xor ax, ax ; set status to OK
  227. ret
  228. Success ENDP
  229. ;----------------------------------------------------------------------------;
  230. ; error: set the status word to error: unknown command
  231. ;----------------------------------------------------------------------------;
  232. public Error
  233. Error PROC NEAR
  234. mov ax, fERROR + fUNKNOWN_E ; error bit + "Unknown command" code
  235. ret
  236. Error ENDP
  237. ;----------------------------------------------------------------------------;
  238. ; Int10_dispatch:
  239. ;----------------------------------------------------------------------------;
  240. public Int10_dispatch
  241. Int10_dispatch PROC FAR
  242. if (MAX_ROW * MAX_COL * 4) GT 0FFFFh
  243. .err
  244. %out MAX_ROW or MAX_COL out of range
  245. endif
  246. .IF <cs:[setmode_flag] ne 0> ; flag is set by nt_resume_event_thread
  247. .IF <ah eq 0>
  248. mov cs:[setmode_flag],0 ; clear
  249. jmp simulate_iret ; no call original
  250. .ENDIF
  251. .ENDIF
  252. mov cs:[use_ntdisp_flag],1
  253. push bx
  254. push ax
  255. mov bx,ax
  256. push es
  257. push di
  258. .IF <cs:[disp_init_flag] eq 0>
  259. mov ax,0003h ; Clear display
  260. BOP 42h
  261. ; call reenter_win
  262. mov cs:[disp_init_flag],1
  263. .ENDIF
  264. les di,dword ptr cs:[dbcs_vector]
  265. mov ax,word ptr es:[di]
  266. .IF <cs:[nt_cons_mode] eq 1> ; Check Re-enter
  267. .IF <ax eq 0> ; Check SBCS or DBCS
  268. mov cs:[active_cp],CP_US ; Set bilingal US
  269. .ELSE
  270. ifdef JAPAN
  271. mov cs:[active_cp],CP_JP ; Set bilingal JAPAN
  272. endif
  273. ifdef KOREA
  274. mov cs:[active_cp],CP_KO ; Set bilingal KOREA
  275. endif
  276. .ENDIF
  277. .ENDIF
  278. .IF <ax eq 0> ; Check SBCS world
  279. ; Not nessesary after build #26
  280. ; .IF <cs:[nt_cons_mode] eq 1> ; Re-enter
  281. ; call reenter_fullsc
  282. ; mov cs:[nt_cons_mode],0
  283. ; .ENDIF
  284. pop di
  285. pop es
  286. pop ax
  287. pop bx
  288. pushf
  289. call cs:[pass_disp_add] ; Go SBCS world
  290. mov cs:[use_ntdisp_flag],0
  291. jmp simulate_iret
  292. .ENDIF
  293. ; williamh - The following checks are not necessary.
  294. ; When nt_event_event_thread get called, the video
  295. ; state is in console's default and we have no idea
  296. ; what it is at this moment so we have to reset the
  297. ; video to what we know - that is why reenter_win and
  298. ; reenter_fullsc for. If DBCS mode is enabled and the
  299. ; video mode is in SBCS graphic mode, we still have
  300. ; to reset the video, otherwise, the underneath driver
  301. ; will get confused.
  302. ; This reenter_win and reenter_fulsc are very very costy
  303. ; and we have to find ways to get rid of them if possible.
  304. ;
  305. ;
  306. ; .IF <bh ne 00h> ; Check SBCS mode
  307. ; mov al,cs:[display_mode]
  308. ; .IF <al ne 03h> and
  309. ; .IF <al ne 11h> and
  310. ; .IF <al ne 12h> and
  311. ; .IF <al ne 72h> and
  312. ; .IF <al ne 73h>
  313. ; pop di
  314. ; pop es
  315. ; pop ax
  316. ; pop bx
  317. ; pushf
  318. ; call cs:[pass_disp_add] ; Go SBCS world
  319. ; mov cs:[use_ntdisp_flag],0
  320. ; jmp simulate_iret
  321. ; .ENDIF
  322. ; .ENDIF
  323. IFDEF _X86_ ; By DEC-J. On ALPHA windowed_add is meanless.
  324. les di,dword ptr cs:[windowed_add]
  325. mov al,es:[di]
  326. .IF <al eq FULLSCREEN>
  327. ; .IF <cs:[nt_cons_mode] eq 1> ; Re-enter
  328. ; call reenter_fullsc
  329. ; mov cs:[nt_cons_mode],0
  330. ; mov cs:[window_mode],al
  331. ; .ENDIF
  332. .IF <al ne cs:[window_mode]> ; Win->Fullsc switched
  333. call wintofullsc
  334. .ENDIF
  335. .ELSE
  336. ; .IF <cs:[nt_cons_mode] eq 1> ; Re-enter
  337. ; call reenter_win
  338. ; mov cs:[nt_cons_mode],0
  339. ; .ENDIF
  340. .IF <bh eq 00h> ; Win->Fullsc switch
  341. ; .IF <bl eq 03h> or
  342. ; .IF <bl eq 73h> or
  343. .IF <bl eq 04h> or
  344. .IF <bl eq 05h> or
  345. .IF <bl eq 06h> or
  346. .IF <bl eq 0dh> or
  347. .IF <bl eq 0eh> or
  348. .IF <bl eq 0fh> or
  349. .IF <bl eq 10h> or
  350. .IF <bl eq 11h> or
  351. .IF <bl eq 12h> or
  352. .IF <bl eq 13h> or
  353. .IF <bl eq 72h>
  354. call wintofullsc
  355. mov cs:[nt_cons_mode],0
  356. mov al,FULLSCREEN
  357. .ENDIF
  358. .ENDIF
  359. .ENDIF
  360. mov cs:[window_mode],al
  361. ENDIF ;_ALPHA_
  362. pop di
  363. pop es
  364. pop ax
  365. pop bx
  366. .IF <ah eq 0feh>
  367. jmp teach_buffer
  368. .ENDIF
  369. .IF <ah eq 0ffh>
  370. jmp refresh_buffer
  371. .ENDIF
  372. .IF <ah be MaxFunc>
  373. push si
  374. push ax
  375. xchg ah,al
  376. xor ah,ah
  377. shl ax,1
  378. mov si,offset cs:table_int10
  379. add si,ax
  380. pop ax
  381. jmp cs:[si]
  382. .ENDIF
  383. public go_org_int10
  384. go_org_int10 label near
  385. pushf
  386. call cs:org_int10_add ;go to original int10
  387. mov cs:[use_ntdisp_flag],0
  388. jmp simulate_iret
  389. Int10_dispatch ENDP
  390. public mode_set
  391. mode_set proc near
  392. pop si
  393. IFDEF _X86_ ; By DEC-J.
  394. mov cs:[display_mode],al
  395. .IF <cs:[window_mode] ne FULLSCREEN>
  396. ELSE
  397. mov ah, al
  398. and ah, 7fh
  399. mov cs:[display_mode], ah
  400. .IF <ah eq 03h> or
  401. .IF <ah eq 73h>
  402. mov ah,0
  403. .IF< cs:[window_mode] eq FULLSCREEN>
  404. ;tobu tori atowo nigosu ichitaro.
  405. pushf
  406. call cs:org_int10_add
  407. mov cs:[window_mode], 0
  408. .ENDIF
  409. ENDIF ;_ALPHA_
  410. BOP 42h
  411. mov cs:[use_ntdisp_flag],0
  412. jmp simulate_iret
  413. .ENDIF
  414. IFNDEF _X86_ ; By DEC-J.
  415. mov ah, 0
  416. .IF< cs:[window_mode] ne FULLSCREEN>
  417. call wintofullsc ;for initialize $disp.sys
  418. mov cs:[window_mode], FULLSCREEN
  419. .ENDIF
  420. ENDIF ;_ALPHA_
  421. jmp go_org_int10
  422. mode_set endp
  423. public cpos_get
  424. cpos_get proc near
  425. cpos_set label near
  426. ctype_set label near
  427. read_cell label near
  428. disply_get label near
  429. palet_set label near
  430. pop si
  431. .IF <cs:[window_mode] ne FULLSCREEN>
  432. BOP 42h
  433. mov cs:[use_ntdisp_flag],0
  434. jmp simulate_iret
  435. .ENDIF
  436. jmp go_org_int10
  437. cpos_get endp
  438. ; MSKK kksuzuka #1223 9/7/94
  439. ; when dosshell is started with full screen, ntvdm must generate character
  440. public char_set
  441. char_set proc near
  442. pop si
  443. .IF <cs:[window_mode] ne FULLSCREEN>
  444. BOP 42h
  445. mov cs:[use_ntdisp_flag],0
  446. jmp simulate_iret
  447. .ENDIF
  448. .IF <al eq 00h> or
  449. .IF <al eq 11h>
  450. BOP 42h
  451. .ENDIF
  452. jmp go_org_int10
  453. char_set endp
  454. ;; #3741: WordStar6.0: Hilight color is changed after running in window
  455. ;; 11/27/93 yasuho
  456. ;;
  457. ;; restore palette/overscan and DAC registers
  458. public restore_palette_regs
  459. restore_palette_regs proc near
  460. mov ax, cs
  461. mov es, ax
  462. mov dx, offset DAC_Registers
  463. mov ax, 1012h
  464. mov cx, NUM_DAC_REGISTERS
  465. xor bx, bx
  466. pushf
  467. call cs:[org_int10_add]
  468. mov ax, cs
  469. mov es, ax
  470. mov dx, offset Palette_Registers
  471. mov ax, 1002h
  472. pushf
  473. call cs:[org_int10_add]
  474. ret
  475. restore_palette_regs endp
  476. public write_cell
  477. write_cell proc near
  478. write_char label near
  479. scroll_up label near
  480. scroll_down label near
  481. write_tty label near
  482. write_string label near
  483. pop si
  484. .IF <cs:[window_mode] ne FULLSCREEN>
  485. BOP 42h
  486. ; call get_vram
  487. mov cs:[use_ntdisp_flag],0
  488. jmp simulate_iret
  489. .ENDIF
  490. jmp go_org_int10
  491. write_cell endp
  492. ;; #3086: VDM crash when exit 16bit apps of video mode 11h
  493. ;; 12/9/93 yasuho
  494. ;; IME status line monitoring function.
  495. ;; so far, we don't use this value.
  496. public getset_status
  497. getset_status proc near
  498. pop si
  499. push ax
  500. cmp al, 0
  501. je show_status_line
  502. cmp al, 1
  503. jne @F
  504. hidden_status_line:
  505. xor al, al
  506. jmp set_IME_info
  507. show_status_line:
  508. mov al, bl
  509. set_IME_info:
  510. mov cs:[IMEStatusLines], al
  511. ;; #4183: status line of oakv(DOS/V FEP) doesn't disappear
  512. ;; 12/11/93 yasuho
  513. mov ah, 23h ; also tell to NTVDM
  514. BOP 43h
  515. @@:
  516. pop ax
  517. jmp go_org_int10
  518. getset_status endp
  519. public teach_buffer
  520. teach_buffer proc near
  521. ifdef JAPAN
  522. .IF <cs:[window_mode] ne FULLSCREEN>
  523. push ax
  524. push es
  525. push di
  526. les di,dword ptr cs:[bios_disp_mode]
  527. mov al,byte ptr es:[di]
  528. pop di
  529. pop es
  530. .IF <al eq 3>
  531. mov ax,cs:[video_buffer+0]
  532. mov di,ax
  533. mov ax,cs:[video_buffer+2]
  534. mov es,ax
  535. .ENDIF
  536. pop ax
  537. jmp simulate_iret
  538. .ENDIF
  539. jmp go_org_int10
  540. endif
  541. ifdef KOREA ; WriteTtyInterim
  542. jmp go_org_int10
  543. endif
  544. teach_buffer endp
  545. public refresh_buffer
  546. refresh_buffer proc near
  547. .IF <cs:[window_mode] ne FULLSCREEN>
  548. ; call put_vram
  549. BOP 43h
  550. mov cs:[use_ntdisp_flag],0
  551. jmp simulate_iret
  552. .ENDIF
  553. jmp go_org_int10
  554. refresh_buffer endp
  555. public go_disp_sys
  556. go_disp_sys proc near
  557. pop si
  558. jmp go_org_int10
  559. go_disp_sys endp
  560. if 0
  561. public get_vram
  562. get_vram proc near
  563. push ax
  564. push cx
  565. push si
  566. push di
  567. push ds
  568. push es
  569. pushf
  570. mov di,cs:[video_buffer+0]
  571. mov es,cs:[video_buffer+2]
  572. xor si,si
  573. mov ax,0b800h
  574. mov ds,ax
  575. .IF <cs:[display_mode] eq 73h>
  576. mov cx,MAX_ROW*MAX_COL*4
  577. .ELSE
  578. mov cx,MAX_ROW*MAX_COL*2
  579. .ENDIF
  580. cld
  581. shr cx,1
  582. rep movsw
  583. adc cx, 0
  584. rep movsb
  585. popf
  586. pop es
  587. pop ds
  588. pop di
  589. pop si
  590. pop cx
  591. pop ax
  592. ret
  593. get_vram endp
  594. public put_vram
  595. put_vram proc near
  596. push ax
  597. push cx
  598. push si
  599. push di
  600. push ds
  601. push es
  602. pushf
  603. mov si,cs:[video_buffer+0]
  604. mov ds,cs:[video_buffer+2]
  605. xor di,di
  606. mov ax,0b800h
  607. mov es,ax
  608. .IF <cs:[display_mode] eq 73h>
  609. mov cx,MAX_ROW*MAX_COL*4
  610. .ELSE
  611. mov cx,MAX_ROW*MAX_COL*2
  612. .ENDIF
  613. cld
  614. shr cx,1
  615. rep movsw
  616. adc cx,0
  617. rep movsb
  618. popf
  619. pop es
  620. pop ds
  621. pop di
  622. pop si
  623. pop cx
  624. pop ax
  625. ret
  626. put_vram endp
  627. endif
  628. public wintofullsc
  629. wintofullsc proc near
  630. pusha
  631. push es
  632. ;; save max rows number because we are going to set video mode
  633. ;; which will reset this value and the IME got messed up.
  634. ;; #3086: VDM crash when exit 16bit apps of video mode 11h
  635. ;; 12/9/93 yasuho
  636. ;; push es
  637. ;; mov ax, 40h
  638. ;; mov es, ax
  639. ;; mov al, es:[84h]
  640. ;; push ax
  641. IFDEF _X86_ ; By DEC-J
  642. mov ah,03h
  643. mov bh,00h
  644. pushf
  645. call cs:[pass_disp_add]
  646. push dx
  647. push cx
  648. mov ax,2100h ; Save Text
  649. .IF <cs:[display_mode] eq 73h>
  650. mov cx,MAX_ROW*MAX_COL*4
  651. .ELSE
  652. mov cx,MAX_ROW*MAX_COL*2
  653. .ENDIF
  654. les di,dword ptr cs:[video_buffer]
  655. bop 43h
  656. ENDIF ;_ALPHA_
  657. mov ah,0
  658. IFDEF _X86_ ;DEC-J
  659. mov al,cs:[display_mode] ; Set display mode
  660. ELSE
  661. mov al, 03h
  662. ENDIF ;_ALPHA_ DEC-J
  663. pushf
  664. call cs:[org_int10_add]
  665. ;; #3176: vz display white letter on white screen
  666. ;; 11/27/93 reviewed by yasuho
  667. ;;
  668. ;; restore color states after set mode
  669. mov ax, cs
  670. mov es, ax
  671. mov di, offset Palette_Registers
  672. mov ax, 2200h ; get palette/DAC
  673. BOP 43h
  674. call restore_palette_regs
  675. IFDEF _X86_ ; By DEC-J
  676. mov ax,2101h ; Restore Text
  677. .IF <cs:[display_mode] eq 73h>
  678. mov cx,MAX_ROW*MAX_COL*4
  679. .ELSE
  680. mov cx,MAX_ROW*MAX_COL*2
  681. .ENDIF
  682. les di,dword ptr cs:[video_buffer]
  683. bop 43h
  684. ; mov ax,0012h ; Set display mode
  685. ; pushf
  686. ; call cs:[pass_disp_add]
  687. ; les di,dword ptr cs:[bios_disp_mode]; Set display mode
  688. ; mov byte ptr es:[di],3
  689. .IF <cs:[display_mode] eq 73h>
  690. push bp
  691. les bp,dword ptr cs:[video_buffer]; Refresh display
  692. mov cx,MAX_ROW*MAX_COL
  693. mov dx,0
  694. mov bh,0
  695. mov ax,1321h
  696. pushf
  697. call cs:[org_int10_add]
  698. pop bp
  699. .ELSE
  700. ENDIF ;_ALPHA_
  701. les di,dword ptr cs:[video_buffer]; Refresh display
  702. mov cx,MAX_ROW*MAX_COL
  703. mov ah,0ffh
  704. pushf
  705. call cs:[org_int10_add]
  706. IFDEF _X86_ ; By DEC-J
  707. .ENDIF
  708. pop cx
  709. ; les di,dword ptr cs:[cursor_type] ; Set cursor type
  710. ; mov cx,es:[di]
  711. mov ah,01h
  712. pushf
  713. call cs:[org_int10_add]
  714. pop dx
  715. ; les di,dword ptr cs:[cursor_pos] ; Set cursor position
  716. ; mov dx,es:[di]
  717. mov bh,0
  718. mov ah,02h
  719. pushf
  720. call cs:[org_int10_add]
  721. ENDIF ;_ALPHA_
  722. ;; #3086: VDM crash when exit 16bit apps of video mode 11h
  723. ;; 12/9/93 yasuho
  724. mov ax, 40h
  725. mov es, ax
  726. mov al, es:[84h]
  727. sub al, cs:[IMEStatusLines]
  728. mov es:[84h], al ; #3019: incorrect cursor pos.
  729. ; 10/29/93 yasuho
  730. pop es
  731. popa
  732. ret
  733. wintofullsc endp
  734. public reenter_fullsc
  735. reenter_fullsc proc near
  736. push es
  737. push ds
  738. pusha
  739. ;; #3741: WordStar6.0: Hilight color is changed after running in window
  740. ;; 11/27/93 yasuho
  741. ;;
  742. ;; restore palette and DAC register if SBCS world
  743. les di, dword ptr cs:[dbcs_vector]
  744. cmp word ptr es:[di], 0 ; DBCS mode ?
  745. jnz short @F ; yes
  746. mov ax, cs
  747. mov es, ax
  748. mov dx, offset Default_DAC_Regs
  749. mov ax, 1012h
  750. mov cx, 16
  751. xor bx, bx
  752. pushf
  753. call cs:[org_int10_add] ; restore DAC registers
  754. mov dx, offset Default_Palette_Regs
  755. mov ax, 1002h
  756. pushf
  757. call cs:[org_int10_add] ; restore palette registers
  758. jmp exit_reenter_fullsc
  759. @@:
  760. ;; save max rows number because we are going to set video mode
  761. ;; which will reset this value and the IME got messed up.
  762. ;; #3086: VDM crash when exit 16bit apps of video mode 11h
  763. ;; 12/2/93 yasuho
  764. ;; mov ax, 40h
  765. ;; mov es, ax
  766. ;; mov al, es:[84h]
  767. ;; push ax
  768. ;; #4210: Status of $IAS not display in full-screen
  769. ;; 12/16/93 yasuho
  770. ;; save IME status lines if IME is active
  771. ;; NOTE: This is easy fix. We should save the # of IME status lines
  772. ;; in the future.
  773. cmp cs:[IMEStatusLines], 0
  774. je short @F
  775. lds si, dword ptr cs:[video_buffer]
  776. add si, 24*160
  777. mov di, offset IMEstat_buffer
  778. mov ax, cs
  779. mov es, ax
  780. mov cx, 160
  781. cld
  782. rep movsb
  783. @@:
  784. IFDEF _X86_ ; By DEC-J
  785. mov ah,03h
  786. mov bh,00h
  787. pushf
  788. call cs:[pass_disp_add]
  789. push dx
  790. push cx
  791. ;; #3086: VDM crash when exit 16bit apps of video mode 11h
  792. ;; 12/2/93 yasuho
  793. ;; les di,dword ptr cs:[video_buffer]
  794. ;; mov ax,2100h ; Save Text
  795. ;; mov cx,MAX_ROW*MAX_COL*2
  796. ;; bop 43h
  797. ENDIF ;_ALPHA_
  798. les di,dword ptr cs:[bios_disp_mode]
  799. mov ah,0
  800. mov al,es:[di] ; Set display mode
  801. pushf
  802. call cs:[org_int10_add]
  803. IFDEF _X86_ ; By DEC-J
  804. ; mov ax,0b800h
  805. ; mov es,ax
  806. ; xor di,di
  807. ; mov ah,0feh ; Get video buffer
  808. ; pushf
  809. ; call cs:[org_int10_add]
  810. ; mov ax,es
  811. ; mov cs:[video_buffer+0],di
  812. ; mov cs:[video_buffer+2],ax
  813. ;; #3086: VDM crash when exit 16bit apps of video mode 11h
  814. ;; 12/2/93 yasuho
  815. les di,dword ptr cs:[video_buffer]
  816. mov ax,2103h ; Restore Text
  817. mov cx,MAX_ROW*MAX_COL*2
  818. bop 43h
  819. ;; #4210: Status of $IAS not display in full-screen
  820. ;; 12/16/93 yasuho
  821. ;; restore IME status lines if IME is active
  822. ;; NOTE: This is easy fix. We should save the # of IME status lines
  823. ;; in the future.
  824. cmp cs:[IMEStatusLines], 0
  825. je short @F
  826. mov si, offset IMEstat_buffer
  827. mov ax, cs
  828. mov ds, ax
  829. les di, dword ptr cs:[video_buffer]
  830. add di, 24*160
  831. mov cx, 160
  832. cld
  833. rep movsb
  834. @@:
  835. ENDIF ;_ALPHA_
  836. les di,dword ptr cs:[video_buffer] ; Refresh display
  837. mov cx,MAX_ROW*MAX_COL
  838. mov ah,0ffh
  839. pushf
  840. call cs:[org_int10_add]
  841. IFDEF _X86_ ; By DEC-J
  842. pop cx
  843. mov ah,01h
  844. pushf
  845. call cs:[org_int10_add]
  846. pop dx
  847. mov bh,0
  848. mov ah,02h
  849. pushf
  850. call cs:[org_int10_add]
  851. ENDIF ;_ALPHA_
  852. ;; #3086: VDM crash when exit 16bit apps of video mode 11h
  853. ;; 12/2/93 yasuho
  854. mov ax, 40h
  855. mov es, ax
  856. mov al, es:[84h]
  857. sub al, cs:[IMEStatusLines]
  858. mov es:[84h], al
  859. exit_reenter_fullsc:
  860. popa
  861. pop ds
  862. pop es
  863. BOP 0FEh
  864. reenter_fullsc endp
  865. public reenter_win
  866. reenter_win proc near
  867. ; pusha
  868. ;
  869. ; mov ax,0b800h
  870. ; mov es,ax
  871. ; xor di,di
  872. ; mov ah,0feh ; Get video buffer
  873. ; pushf
  874. ; call cs:[org_int10_add]
  875. ; mov ax,es
  876. ; mov cs:[video_buffer+0],di
  877. ; mov cs:[video_buffer+2],ax
  878. ;
  879. ; call get_vram
  880. ;
  881. ; popa
  882. ret
  883. reenter_win endp
  884. ;----------------------------------------------------------------------------;
  885. ; Int08_dispatch:
  886. ;----------------------------------------------------------------------------;
  887. public Int08_dispatch
  888. Int08_dispatch PROC FAR
  889. push ax
  890. push es
  891. push di
  892. les di,dword ptr cs:[dbcs_vector]
  893. mov ax,word ptr es:[di]
  894. .IF <ax ne 0> ; Check DBCS mode
  895. .IF <cs:[display_mode] eq 3> or ; Check TEXT mode
  896. .IF <cs:[display_mode] eq 73h>
  897. .IF <cs:[use_ntdisp_flag] eq 0> ; Check using int10h
  898. ; les di,dword ptr cs:[windowed_add]
  899. ; mov al,es:[di]
  900. ; .IF <al eq FULLSCREEN> and ; Full-screen?
  901. ; .IF <al ne cs:[window_mode]> ; Win->Fullsc
  902. call wintofullsc
  903. mov cs:[window_mode],FULLSCREEN
  904. ; .ENDIF
  905. .ENDIF
  906. .ENDIF
  907. .ENDIF
  908. pop di
  909. pop es
  910. pop ax
  911. BOP 0feh
  912. ret
  913. Int08_dispatch ENDP
  914. ;----------------------------------------------------------------------------;
  915. ; Int2f (Bilingal function) dispatch from "biling.sys"
  916. ;----------------------------------------------------------------------------;
  917. ;Data area for bilingal system
  918. public org_int2f_add
  919. org_int2f_add dd ?
  920. ifdef JAPAN
  921. default_cp dw CP_JP
  922. active_cp dw CP_JP
  923. endif
  924. ifdef KOREA
  925. default_cp dw CP_KO
  926. active_cp dw CP_KO
  927. endif
  928. video_flag db 1
  929. public biling_func_tbl
  930. biling_func_tbl label word
  931. dw get_ver
  932. dw get_cp
  933. dw regist_video
  934. dw strip_video
  935. BILING_FUNC_MAX equ ($ - offset biling_func_tbl) / 2
  936. public Int2f_dispatch
  937. Int2f_dispatch PROC FAR
  938. cmp ah,4fh
  939. jnz biling_pass
  940. cmp al,BILING_FUNC_MAX
  941. jae biling_pass
  942. push bx
  943. mov bl,al
  944. xor bh,bh
  945. shl bx,1
  946. mov ax,cs:[biling_func_tbl+bx] ; get subfunction address
  947. pop bx
  948. call ax ; execute subfunction
  949. simulate_iret:
  950. FIRET
  951. biling_pass:
  952. jmp cs:[org_int2f_add]
  953. Int2f_dispatch ENDP
  954. public get_ver
  955. get_ver proc near
  956. mov dl,MAJOR_VER
  957. mov dh,MINOR_VER
  958. mov ax,0
  959. ret
  960. get_ver endp
  961. public get_cp
  962. get_cp proc near
  963. ;
  964. ; Reload active code page when code page changed
  965. ; ntraid:mskkbug#2708 10/13/93 yasuho
  966. ;
  967. push ds
  968. lds bx,dword ptr cs:[dbcs_vector]
  969. mov ax,word ptr [bx]
  970. pop ds
  971. .IF <ax eq 0> ; Check SBCS or DBCS
  972. mov ax,CP_US ; US
  973. .ELSE
  974. ifdef JAPAN
  975. mov ax,CP_JP ; JAPAN
  976. endif
  977. ifdef KOREA
  978. mov ax,CP_KO ; KOREA
  979. endif
  980. .ENDIF
  981. mov cs:[active_cp],ax ; Set active code page
  982. mov bx,cs:active_cp
  983. cmp cs:video_flag,1
  984. jz @f
  985. mov bx,-1 ; if DBCS video system is not available
  986. @@:
  987. mov ax,0
  988. ret
  989. get_cp endp
  990. public regist_video
  991. regist_video proc near
  992. mov cs:video_flag,1
  993. mov ax,0
  994. ret
  995. regist_video endp
  996. public strip_video
  997. strip_video proc near
  998. mov cs:video_flag,0
  999. mov ax,0
  1000. ret
  1001. strip_video endp
  1002. ;----------------------------------------------------------------------------;
  1003. ;****************************************************************************;
  1004. ;----------------------------------------------------------------------------;
  1005. ; ;
  1006. ; BEGINNING OF SPACE TO BE USED AS DRIVER MEMORY ;
  1007. ; ALL CODE AFTER ATOMLIST WILL BE ERASED BY THE DRIVER'S DATA ;
  1008. ; OR BY OTHER LOADED DRIVERS ;
  1009. ; ;
  1010. ;----------------------------------------------------------------------------;
  1011. ;****************************************************************************;
  1012. ;----------------------------------------------------------------------------;
  1013. ;----------------------------------------------------------------------------;
  1014. ; Initialization Data and Code
  1015. ; Only needed once, so after the driver is loaded and initialized it releases
  1016. ; any memory that it won't use. The device allocates memory for its own use
  1017. ; starting from 'ddddlList'.
  1018. ;----------------------------------------------------------------------------;
  1019. public ddddhList
  1020. ddddhList label near
  1021. ifndef KOREA
  1022. ini_msg db "Windows-NT DISP.SYS Dispatch Driver 2 version 0.1"
  1023. db lf,cr,eom
  1024. endif
  1025. err_msg db "NTDISP1.SYS is not installed"
  1026. db lf,cr,eom
  1027. devnam db "NTDISP1$",0
  1028. public Init
  1029. Init PROC NEAR
  1030. push ds
  1031. push es
  1032. pusha
  1033. les di, [lpHeader] ; allow us to use the request values
  1034. mov ax, MemEnd ; set ax to End of Memory relative to
  1035. ; previous end of memory.
  1036. mov MaxMem, ax ; store the new value in MaxMem
  1037. mov es:[di].xseg,cs ; tell MS-DOS the end of our used
  1038. mov es:[di].xfer,ax ; memory (the break address)
  1039. ifndef KOREA
  1040. ShowStr ini_msg
  1041. endif
  1042. mov dx,offset devnam ; open ddddl.sys
  1043. mov ax,3d00h
  1044. int 21h
  1045. jnc get_prev_int10_vector
  1046. not_install:
  1047. ShowStr err_msg
  1048. mov es:[di].xfer,0 ; clean up memory (the break address)
  1049. jmp init_exit
  1050. popa
  1051. ; xor ax,ax
  1052. mov ax,0100h
  1053. ret
  1054. get_prev_int10_vector:
  1055. mov bx,ax
  1056. ; kksuzuka:#4041
  1057. push bx ; handle
  1058. mov ax,4400h
  1059. int 21h ; get device data
  1060. pop bx
  1061. jc not_install
  1062. ; dx=device word
  1063. push bx
  1064. xor dh,dh ; should not change
  1065. or dl,20h ; set binary mode
  1066. mov ax,4401h
  1067. int 21h ; set device data
  1068. pop bx
  1069. jc not_install
  1070. push bx
  1071. mov dx,offset pass_disp_add ; get original int10 address
  1072. mov cx,4
  1073. mov ax,3f00h
  1074. int 21h
  1075. pop bx ; close ddddl.sys
  1076. mov ax,3e00h
  1077. int 21h
  1078. mov ax,0b800h
  1079. mov es,ax
  1080. xor di,di
  1081. mov ah,0feh ; Get video buffer
  1082. int 10h
  1083. mov ax,es
  1084. mov [video_buffer+0],di
  1085. mov [video_buffer+2],ax
  1086. mov ax,offset display_mode ; Tell NTVDM Virtual TEXT V-RAM address
  1087. mov [dmode_add+0],ax ; ,display mode address
  1088. mov ax,ds ; and get Windowed flag address
  1089. mov [dmode_add+2],ax ; and tell Nt console mode flag add
  1090. mov ax,offset nt_cons_mode
  1091. mov [nt_cons_add+0],ax
  1092. mov ax,ds
  1093. mov [nt_cons_add+2],ax
  1094. mov ax,offset int08_dispatch
  1095. mov [disp_sys_init+0],ax
  1096. mov ax,cs
  1097. mov [disp_sys_init+2],ax
  1098. mov [fullsc_resume_ptr], offset reenter_fullsc
  1099. mov [fullsc_resume_ptr + 2], ax
  1100. mov [ias_setmode_add], offset setmode_flag
  1101. mov [ias_setmode_add + 2], ax
  1102. mov si,offset packet_len
  1103. mov ah,20h
  1104. BOP 43h
  1105. mov ax,VECTOR_SEG ;Get original int10 vector
  1106. mov es,ax
  1107. mov ax,word ptr es:[4*10h+0]
  1108. mov word ptr [org_int10_add+0],ax
  1109. mov ax,word ptr es:[4*10h+2]
  1110. mov word ptr [org_int10_add+2],ax
  1111. mov ax,offset cs:Int10_dispatch ;Set my int10 vector
  1112. mov word ptr [new_int10_add+0],ax
  1113. mov word ptr es:[4*10h+0],ax
  1114. mov ax,cs
  1115. mov word ptr es:[4*10h+2],ax
  1116. mov word ptr [new_int10_add+2],ax
  1117. push ds
  1118. mov ax,6300h ; Get DBCS Vector address
  1119. int 21h
  1120. mov bx,[si]
  1121. mov ax,ds
  1122. pop ds
  1123. mov word ptr [dbcs_vector+0],si
  1124. mov word ptr [dbcs_vector+2],ax
  1125. IFDEF _X86_ ; By DEC-J
  1126. les di,dword ptr [windowed_add]
  1127. mov al,es:[di]
  1128. .IF <al eq FULLSCREEN>
  1129. mov ah,03h
  1130. mov bh,00h
  1131. pushf
  1132. call cs:[pass_disp_add] ; Save Cursor
  1133. push dx
  1134. push cx
  1135. mov ax,0003h ; set DOS/V text mode
  1136. pushf
  1137. call [org_int10_add]
  1138. ; kksuzuka #6168 set screen attibutes
  1139. mov ah,24h ; get console attributes
  1140. BOP 43h
  1141. shl ax,8 ; ah = console attributes
  1142. mov al,20h
  1143. les di,dword ptr cs:[video_buffer] ; DOS/V VRAM
  1144. mov cx,MAX_ROW*MAX_COL
  1145. push di
  1146. push es
  1147. rep stosw
  1148. pop es
  1149. pop di
  1150. mov cx,MAX_ROW*MAX_COL
  1151. mov ah,0ffh
  1152. pushf
  1153. call cs:[org_int10_add]
  1154. mov [nt_cons_mode],0
  1155. mov [window_mode],FULLSCREEN
  1156. mov cs:[disp_init_flag],1
  1157. pop cx ; Restore cursor
  1158. mov ah,01h
  1159. pushf
  1160. call cs:[org_int10_add]
  1161. pop dx
  1162. mov bh,0
  1163. mov ah,02h
  1164. pushf
  1165. call cs:[org_int10_add]
  1166. .ENDIF
  1167. ENDIF ;_ALPHA_
  1168. ;; #3741: WordStar6.0: Hilight color is changed after running in window
  1169. ;; 12/2/93 yasuho
  1170. ;;
  1171. ;; get initial color palette and DAC registers
  1172. mov ax, cs
  1173. mov es, ax
  1174. mov dx, offset Default_Palette_Regs
  1175. mov ax, 1009h
  1176. pushf
  1177. call cs:[org_int10_add]
  1178. mov ax, cs
  1179. mov es, ax
  1180. mov dx, offset Default_DAC_Regs
  1181. mov ax, 1017h
  1182. mov cx, 16
  1183. xor bx, bx
  1184. pushf
  1185. call cs:[org_int10_add]
  1186. mov ax,VECTOR_SEG
  1187. mov es,ax
  1188. ; mov ax,word ptr es:[4*08h+0] ;Get original int08 vector
  1189. ; mov word ptr [org_int08_add+0],ax
  1190. ; mov ax,word ptr es:[4*08h+2]
  1191. ; mov word ptr [org_int08_add+2],ax
  1192. ;
  1193. ; mov ax,offset cs:Int08_dispatch ;Set my int08 vector
  1194. ; mov word ptr es:[4*08h+0],ax
  1195. ; mov ax,cs
  1196. ; mov word ptr es:[4*08h+2],ax
  1197. mov ax,word ptr es:[4*2fh+0] ;Get original int2f vector
  1198. mov word ptr [org_int2f_add+0],ax
  1199. mov ax,word ptr es:[4*2fh+2]
  1200. mov word ptr [org_int2f_add+2],ax
  1201. mov ax,offset cs:Int2f_dispatch ;Set my int2f vector
  1202. mov word ptr es:[4*2fh+0],ax
  1203. mov ax,cs
  1204. mov word ptr es:[4*2fh+2],ax
  1205. init_exit:
  1206. popa
  1207. pop es
  1208. pop ds
  1209. ; xor ax,ax
  1210. mov ax,0100h
  1211. ret
  1212. Init ENDP
  1213. TEXT ENDS
  1214. END