Source code of Windows XP (NT5)
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.

1172 lines
30 KiB

  1. page ,132
  2. ;-----------------------------Module-Header-----------------------------;
  3. ; Module Name: VFLAT.ASM
  4. ;
  5. ; module for doing direct video access under windows.
  6. ;
  7. ; we will talk to VflatD to get the linear address of the video buffer.
  8. ;
  9. ; we MUST not use these API in the background, how do we do this?
  10. ;
  11. ; we support the following modes: (same as SVGA256...)
  12. ;
  13. ; VRAM II 640x480x8bpp
  14. ; VRAM II 720x512x8bpp
  15. ; VRAM II 800x600x8bpp
  16. ; VRAM II 1024x768x8bpp
  17. ;
  18. ; V7 VGA 640x480x8bpp
  19. ; V7 VGA 720x512x8bpp
  20. ; V7 VGA 800x600x8bpp
  21. ; V7 VGA 1024x768x8bpp
  22. ;
  23. ; WD VGA 640x480x8bpp
  24. ; WD VGA 800x600x8bpp
  25. ; WD VGA 1024x768x8bpp
  26. ; WD VGA 640x480x16bpp
  27. ; WD VGA 800x600x16bpp
  28. ;
  29. ; Trident 640x480x8bpp
  30. ; Trident 800x600x8bpp
  31. ; Trident 1024x768x8bpp
  32. ;
  33. ; Oak 640x480x8bpp
  34. ; Oak 800x600x8bpp
  35. ; Oak 1024x768x8bpp
  36. ;
  37. ; ATI 640x480x8bpp
  38. ; ATI 800x600x8bpp
  39. ; ATI 1024x768x8bpp
  40. ; ATI 640x480x24bpp
  41. ;
  42. ; Compaq AVGA 640x480x8bpp
  43. ;
  44. ; Compaq QVision 640x480x8bpp
  45. ; Compaq QVision 800x600x8bpp
  46. ; Compaq QVision 1024x768x8bpp
  47. ;
  48. ; Compaq QVision 640x480x16bpp
  49. ; Compaq QVision 800x600x16bpp
  50. ; Compaq QVision 1024x768x16bpp
  51. ;
  52. ; Tseng ET4000 640x480x8bpp
  53. ; Tseng ET4000 800x600x8bpp
  54. ; Tseng ET4000 1024x768x8bpp
  55. ; Tseng ET4000 640x480x16bpp
  56. ; Tseng ET4000 800x600x16bpp
  57. ;
  58. ; Everex 640x480x8bpp
  59. ; Everex 800x600x8bpp
  60. ; Everex 1024x768x8bpp
  61. ;
  62. ; Cirrus 542x 640x480x8bpp
  63. ; Cirrus 542x 800x600x8bpp
  64. ; Cirrus 542x 1024x768x8bpp
  65. ;
  66. ; Cirrus 6420 640x480x8bpp
  67. ; Cirrus 6420 800x600x8bpp
  68. ; Cirrus 6420 1024x768x8bpp
  69. ;
  70. ; Created: 03-20-90
  71. ; Author: Todd Laney [ToddLa]
  72. ;
  73. ; Copyright (c) 1984-1994 Microsoft Corporation
  74. ;
  75. ; Public Functions:
  76. ;
  77. ; VFlatInit()
  78. ;
  79. ; Public Data:
  80. ;
  81. ; General Description:
  82. ;
  83. ; Restrictions:
  84. ;
  85. ;-----------------------------------------------------------------------;
  86. ?PLM = 1
  87. ?WIN = 0
  88. .386
  89. .xlist
  90. include cmacros.inc
  91. include windows.inc
  92. WIN31=1
  93. include VflatD.inc
  94. .list
  95. externFP GetDC
  96. externFP ReleaseDC
  97. externFP GetDeviceCaps
  98. externFP OutputDebugString
  99. externFP WriteProfileString
  100. externA __C000h
  101. externA __A000h
  102. sBegin Data
  103. ScreenMode dw 0 ; current mode (index)
  104. VflatD_Proc dd 0 ; VflatD entry point
  105. bank_save dw 0 ; saved bank...
  106. sEnd Data
  107. ;----------------------------------------------------------------------------
  108. ;----------------------------------------------------------------------------
  109. ifdef DEBUG
  110. DPF macro text
  111. local string, string_end
  112. jmp short string_end
  113. string label byte
  114. db "&text&",13,10,0
  115. string_end label byte
  116. pusha
  117. push es
  118. push cs
  119. push offset string
  120. call OutputDebugString
  121. pop es
  122. popa
  123. endm
  124. else
  125. DPF macro text
  126. endm
  127. endif
  128. ;----------------------------------------------------------------------------
  129. ;----------------------------------------------------------------------------
  130. ifndef SEGNAME
  131. SEGNAME equ <_TEXT>
  132. endif
  133. createSeg %SEGNAME, CodeSeg, word, public, CODE
  134. sBegin CodeSeg
  135. .386p
  136. assumes cs,CodeSeg
  137. assumes ds,Data
  138. assumes es,nothing
  139. ;----------------------------------------------------------------------------
  140. ;----------------------------------------------------------------------------
  141. ifdef DEBUG
  142. szDebug db "Debug", 0
  143. szDrawDib db "DrawDib", 0
  144. szDetect db "detect", 0
  145. szDetectDVA db "DetectDVA: ", 0
  146. szNone db "None", 0
  147. endif
  148. ;----------------------------------------------------------------------------
  149. ;----------------------------------------------------------------------------
  150. ModeInfo STRUC
  151. ModeNext dw ?
  152. ModeDetect dw ?
  153. ModeNum dw ?
  154. ModeWidth dw ?
  155. ModeHeight dw ?
  156. ModeDepth dw ?
  157. ModeSetBank dw ?
  158. ModeGetBank dw ?
  159. ModeSetBank32 dw ?
  160. ModeSetBank32Size dw ?
  161. ModeName db ?
  162. ModeInfo ENDS
  163. ;----------------------------------------------------------------------------
  164. ;----------------------------------------------------------------------------
  165. Mode macro y, n, w, h, b, x, name
  166. local l1,l2
  167. l1:
  168. dw l2 - l1
  169. dw Detect&y, n, w, h, b, SetBank&x, GetBank&x, SetBank32&x, SetBank32&x&Size
  170. ifdef DEBUG
  171. db name
  172. db 0
  173. endif
  174. l2:
  175. endm
  176. ModeInfoTable label byte
  177. Mode VRAM, 67h, 640, 480, 8, VRAM, "VRAM II 640x480x8bpp"
  178. Mode VRAM, 68h, 720, 512, 8, VRAM, "VRAM II 720x512x8bpp"
  179. Mode VRAM, 69h, 800, 600, 8, VRAM, "VRAM II 800x600x8bpp"
  180. Mode VRAM, 6Ah, 1024,768, 8, VRAM, "VRAM II 1024x768x8bpp"
  181. Mode V7, 67h, 640, 480, 8, V7, "V7 VGA 640x480x8bpp"
  182. Mode V7, 68h, 720, 512, 8, V7, "V7 VGA 720x512x8bpp"
  183. Mode V7, 69h, 800, 600, 8, V7, "V7 VGA 800x600x8bpp"
  184. Mode V7, 6Ah, 1024,768, 8, V7, "V7 VGA 1024x768x8bpp"
  185. Mode WD, 5Fh, 640, 480, 8, WD, "WD VGA 640x480x8bpp"
  186. Mode WD, 5Ch, 800, 600, 8, WD, "WD VGA 800x600x8bpp"
  187. Mode WD, 60h, 1024,768, 8, WD, "WD VGA 1024x768x8bpp"
  188. Mode WD, 64h, 640, 480,16, WD, "WD VGA 640x480x16bpp"
  189. Mode WD, 65h, 800, 600,16, WD, "WD VGA 800x600x16bpp"
  190. Mode Trident, 5Dh, 640, 480, 8, Trident, "Trident 640x480x8bpp"
  191. Mode Trident, 5Eh, 800, 600, 8, Trident, "Trident 800x600x8bpp"
  192. Mode Trident, 62h, 1024,768, 8, Trident, "Trident 1024x768x8bpp"
  193. Mode Oak, 53h, 640, 480, 8, Oak, "Oak 640x480x8bpp"
  194. Mode Oak, 54h, 800, 600, 8, Oak, "Oak 800x600x8bpp"
  195. Mode Oak, 59h, 1024,768, 8, Oak, "Oak 1024x768x8bpp"
  196. Mode ATI, 12h, 640, 480, 8, ATI, "ATI 640x480x8bpp"
  197. Mode ATI, 12h, 800, 600, 8, ATI, "ATI 800x600x8bpp"
  198. Mode ATI, 12h, 1024,768, 8, ATI, "ATI 1024x768x8bpp"
  199. Mode ATI, 12h, 2048,1024,8, ATI, "ATI 2048x1024x8bpp"
  200. Mode ATI, 12h, 640, 480,16, ATI, "ATI 640x480x16bpp"
  201. Mode ATI, 12h, 800, 600,16, ATI, "ATI 800x600x16bpp"
  202. Mode ATI, 12h, 1024,768,16, ATI, "ATI 1024x768x16bpp"
  203. Mode ATI, 12h, 2048,1024,16,ATI, "ATI 2048x1024x16bpp"
  204. Mode ATI, 12h, 640, 480,24, ATI, "ATI 640x480x24bpp"
  205. Mode ATI, 12h, 800, 600,24, ATI, "ATI 800x600x24bpp"
  206. Mode ATI, 12h, 1024,768,24, ATI, "ATI 1024x768x24bpp"
  207. Mode ATI, 12h, 2048,1024,24,ATI, "ATI 2048x1024x24bpp"
  208. Mode ATI, 62h, 640, 480, 8, ATI, "ATI 640x480x8bpp"
  209. Mode ATI, 63h, 800, 600, 8, ATI, "ATI 800x600x8bpp"
  210. Mode ATI, 64h, 1024,768, 8, ATI, "ATI 1024x768x8bpp"
  211. Mode ATI, 75h, 640, 480,24, ATI, "ATI 640x480x24bpp"
  212. Mode Compaq,2Eh, 640, 480, 8, Compaq, "Compaq AVGA 640x480x8bpp"
  213. Mode Compaq,12h, 640, 480, 8, Compaq, "Compaq AVGA 640x480x8bpp"
  214. Mode Compaq,06h, 640, 480, 8, Compaq, "Compaq QVision 640x480x8bpp"
  215. Mode Compaq,06h, 800, 600, 8, Compaq, "Compaq QVision 800x600x8bpp"
  216. Mode Compaq,06h, 1024,768, 8, Compaq, "Compaq QVision 1024x768x8bpp"
  217. Mode Compaq,06h, 640, 480, 16, Compaq, "Compaq QVision 640x480x16bpp"
  218. Mode Compaq,06h, 800, 600, 16, Compaq, "Compaq QVision 800x600x16bpp"
  219. Mode Compaq,06h, 1024,768, 16, Compaq, "Compaq QVision 1024x768x16bpp"
  220. Mode Tseng, 2Eh, 640, 480, 8, Tseng, "Tseng ET4000 640x480x8bpp"
  221. Mode Tseng, 30h, 800, 600, 8, Tseng, "Tseng ET4000 800x600x8bpp"
  222. Mode Tseng, 38h, 1024,768, 8, Tseng, "Tseng ET4000 1024x768x8bpp"
  223. Mode Tseng, 2Eh, 640, 480,16, Tseng, "Tseng ET4000 640x480x16bpp"
  224. Mode Tseng, 30h, 800, 600,16, Tseng, "Tseng ET4000 800x600x16bpp"
  225. Mode Everex, 2Eh, 640, 480, 8, Tseng, "Everex 640x480x8bpp"
  226. Mode Everex, 30h, 800, 600, 8, Tseng, "Everex 800x600x8bpp"
  227. Mode Everex, 38h, 1024,768, 8, Tseng, "Everex 1024x768x8bpp"
  228. ; Until we get a detect routine for Cirrus, we won't include these.
  229. ;Mode C542x, 5Fh, 640, 480, 8, C542x, "C542x 640x480x8bpp"
  230. ;Mode C542x, 5Ch, 800, 600, 8, C542x, "C542x 800x600x8bpp"
  231. ;Mode C542x, 60h, 1024,768, 8, C542x, "C542x 1024x768x8bpp"
  232. ;Mode C6420, 2Eh, 640, 480, 8, C6420, "C6420 640x480x8bpp"
  233. ;Mode C6420, 30h, 800, 600, 8, C6420, "C6420 800x600x8bpp"
  234. ;Mode C6420, 38h, 1024,768, 8, C6420, "C6420 1024x768x8bpp"
  235. ModeInfoTableEnd label byte
  236. ;-----------------------------------------------------------------------;
  237. ;-----------------------------------------------------------------------;
  238. szTseng: db "Tseng", 0
  239. szOAK: db " OAK", 0
  240. szTrident: db "TRIDENT", 0
  241. szEverex: db "Everex", 0
  242. szParadise: db "PARADISE", 0
  243. szWD: db "WESTERN DIGITAL", 0
  244. szWeitek: db "WEITEK",0
  245. szViper: db "VIPER VLB",0
  246. ;---------------------------Public-Routine------------------------------;
  247. ; VFlatInit
  248. ;
  249. ; initialize for a banked display
  250. ;
  251. ; Returns:
  252. ; C if error
  253. ; NC if success
  254. ;-----------------------------------------------------------------------;
  255. assumes ds,Data
  256. assumes es,nothing
  257. cProc VFlatInit, <NEAR, PASCAL, PUBLIC>, <si,di,ds>
  258. localW hdc
  259. localW ScreenWidth
  260. localW ScreenHeight
  261. localW ScreenDepth
  262. localW BiosMode
  263. cBegin
  264. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  265. ; get a display DC and get resolution info
  266. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  267. cCall GetDC, <0>
  268. mov hdc,ax
  269. cCall GetDeviceCaps, <hdc,HORZRES>
  270. mov ScreenWidth,ax
  271. cCall GetDeviceCaps, <hdc,VERTRES>
  272. mov ScreenHeight,ax
  273. cCall GetDeviceCaps, <hdc,BITSPIXEL>
  274. push ax
  275. cCall GetDeviceCaps, <hdc,PLANES>
  276. pop dx
  277. mul dx
  278. mov ScreenDepth,ax
  279. cCall ReleaseDC, <0, hdc>
  280. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  281. ; scan our mode table
  282. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  283. mov ax, 6F04h ;Get V7 mode
  284. int 10h
  285. cmp al,04h
  286. jne short @f
  287. mov ax,0F00h ;Call BIOS to get mode back.
  288. int 10h ;al = mode we are in.
  289. @@: xor ah,ah
  290. mov BiosMode,ax
  291. lea bx,ModeInfoTable
  292. mode_search:
  293. mov ax,BiosMode
  294. cmp cs:[bx].ModeNum,ax
  295. jne short mode_search_next
  296. mov ax,ScreenWidth
  297. cmp cs:[bx].ModeWidth,ax
  298. jne short mode_search_next
  299. mov ax,ScreenHeight
  300. cmp cs:[bx].ModeHeight,ax
  301. jne short mode_search_next
  302. mov ax,ScreenDepth
  303. cmp cs:[bx].ModeDepth,ax
  304. jne short mode_search_next
  305. push bx
  306. call cs:[bx].ModeDetect
  307. pop bx
  308. or ax,ax
  309. jnz short mode_search_found
  310. errn$ mode_search_next
  311. mode_search_next:
  312. add bx,cs:[bx].ModeNext
  313. cmp bx,offset ModeInfoTableEnd
  314. jl mode_search
  315. jge mode_search_fail
  316. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  317. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  318. mode_search_found:
  319. mov ScreenMode,bx ; save this for later.
  320. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  321. ; this is a banked display, we need to talk to VflatD in order for
  322. ; anything to work.
  323. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  324. xor di,di
  325. mov es,di
  326. mov ax,1684h
  327. mov bx,VflatD_Windows_ID
  328. int 2fh ;returns with es:di-->VFlatD Entry point
  329. mov word ptr [VflatD_Proc][0],di
  330. mov word ptr [VflatD_Proc][2],es
  331. mov ax,es
  332. or ax,di
  333. jne short mode_search_vflat
  334. xor di,di
  335. mov es,di
  336. mov ax,1684h
  337. mov bx,VflatD_Chicago_ID
  338. int 2fh ;returns with es:di-->VFlatD Entry point
  339. mov word ptr [VflatD_Proc][0],di
  340. mov word ptr [VflatD_Proc][2],es
  341. mov ax,es
  342. or ax,di
  343. jz short mode_search_fail
  344. mode_search_vflat:
  345. xor ax,ax
  346. mov dx,VflatD_Get_Version
  347. call [VflatD_Proc]
  348. cmp ax,VflatD_Version
  349. jb short mode_search_fail
  350. ;
  351. ; estimate the required framebuffer memory
  352. ;
  353. mov ax,ScreenDepth ; bitdepth
  354. mul ScreenWidth ; * width = bit width
  355. shr ax,3 ; / 8 = width bytes
  356. add ax,1024-1 ; round up to nearest K
  357. and ax,not (1024-1) ; now we have scan width
  358. mul ScreenHeight ; * number of scans = total bytes
  359. add ax,0FFFFh ; round up to nearest MB
  360. adc dx,0000Fh
  361. and dx,0FFF0h
  362. shl dx,4 ; convert to 4K pages.
  363. mov ax,dx
  364. mov dx,VflatD_Get_Sel ; get selector
  365. ;;;;;;;;mov ax,512 ; size in pages of video memory?
  366. mov bx,ScreenMode
  367. mov cx,cs:[bx].ModeSetBank32Size; size of bank code.
  368. mov di,cs:[bx].ModeSetBank32 ; point es:di to bank code.
  369. push cs
  370. pop es
  371. call [VflatD_Proc] ; let VflatD init things.
  372. jc short mode_search_fail
  373. or ax,ax
  374. jz short mode_search_fail
  375. errn$ mode_search_ok
  376. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  377. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  378. mode_search_ok:
  379. ifdef DEBUG
  380. pusha
  381. mov bx,ScreenMode
  382. lea ax,[bx].ModeName
  383. lea bx,szDrawDib
  384. lea cx,szDetect
  385. cCall WriteProfileString, <cs,bx, cs,cx, cs,ax>
  386. popa
  387. endif
  388. mov dx, ax
  389. xor ax, ax
  390. jmp short mode_search_exit
  391. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  392. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  393. mode_search_fail:
  394. ifdef DEBUG
  395. pusha
  396. lea ax,szDrawDib
  397. lea bx,szDetect
  398. lea cx,szNone
  399. cCall WriteProfileString, <cs,ax, cs,bx, cs,cx>
  400. popa
  401. endif
  402. xor ax,ax
  403. mov dx,ax
  404. mov ScreenMode,ax
  405. mov word ptr [VflatD_Proc][0],ax
  406. mov word ptr [VflatD_Proc][2],ax
  407. errn$ mode_search_exit
  408. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  409. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  410. mode_search_exit:
  411. cEnd
  412. ;---------------------------Public-Routine------------------------------;
  413. ; VFlatBegin - start direct frame buffer access
  414. ;
  415. ; Returns:
  416. ; Wed 04-Jan-1993 13:45:58 -by- Todd Laney [ToddLa]
  417. ; Created.
  418. ;-----------------------------------------------------------------------;
  419. assumes ds,Data
  420. assumes es,nothing
  421. cProc VFlatBegin, <NEAR, PUBLIC>, <>
  422. cBegin
  423. mov bx, ScreenMode
  424. or bx, bx
  425. jz short BeginExit
  426. %out is CLI/STI needed?
  427. ;;;;;;;;cli
  428. call cs:[bx].ModeGetBank
  429. xchg bank_save,ax
  430. mov dx,ax
  431. call cs:[bx].ModeSetBank
  432. ;;;;;;;;sti
  433. BeginExit:
  434. cEnd
  435. ;---------------------------Public-Routine------------------------------;
  436. ; VFlatEnd - end direct frame buffer access
  437. ;
  438. ; Returns:
  439. ; Wed 04-Jan-1993 13:45:58 -by- Todd Laney [ToddLa]
  440. ; Created.
  441. ;-----------------------------------------------------------------------;
  442. assumes ds,Data
  443. assumes es,nothing
  444. cProc VFlatEnd, <NEAR, PUBLIC>, <>
  445. cBegin
  446. mov bx, ScreenMode
  447. or bx, bx
  448. jz short EndExit
  449. %out is CLI/STI needed?
  450. ;;;;;;;;cli
  451. call cs:[bx].ModeGetBank
  452. xchg bank_save,ax
  453. mov dx,ax
  454. call cs:[bx].ModeSetBank
  455. ;;;;;;;;sti
  456. EndExit:
  457. cEnd
  458. ;---------------------------Public-Routine------------------------------;
  459. ; ScanROM - scan the video bios ROM looking for a string
  460. ;
  461. ; Entry:
  462. ; cs:ax - string to look for.
  463. ;
  464. ; Returns:
  465. ; Wed 04-Jan-1993 13:45:58 -by- Todd Laney [ToddLa]
  466. ; Created.
  467. ;-----------------------------------------------------------------------;
  468. assumes ds,Data
  469. assumes es,nothing
  470. ScanROM proc near
  471. push si
  472. mov si,ax
  473. mov ax,__C000h
  474. mov es,ax
  475. xor bx,bx ; start at zero
  476. mov cx,512 ; search first 512 bytes.
  477. mov dx,si
  478. scan_start:
  479. mov si,dx
  480. mov al,cs:[si]
  481. scan_cmp:
  482. cmp byte ptr es:[bx], al
  483. je short scan_found
  484. inc bx
  485. loop scan_start
  486. xor ax,ax
  487. pop si
  488. ret
  489. scan_next:
  490. inc bx
  491. loop scan_cmp
  492. xor ax,ax
  493. pop si
  494. ret
  495. scan_found:
  496. inc si
  497. mov al,cs:[si]
  498. or al,al
  499. jnz scan_next
  500. inc ax
  501. pop si
  502. ret
  503. ScanROM endp
  504. ;----------------------------------------------------------------------------
  505. ; BANK SWITCH TEMPLATES
  506. ; Each template is given to vflatd.386 which copies it inline in to the
  507. ; page fault handling code.
  508. ; NOTE: This code runs at ring 0 in a USE32 code segment, so be carefull!!!
  509. ; ALL REGISTERS MUST BE PRESERVED (except for dx)
  510. ;----------------------------------------------------------------------------
  511. ;****************************************************************************
  512. ; V7
  513. ;****************************************************************************
  514. DetectV7 proc near
  515. mov ax,6f00h ;Test for Video 7
  516. xor bx,bx
  517. cld
  518. int 10h
  519. xor ax,ax
  520. cmp bx,'V7'
  521. jne short @f
  522. inc ax
  523. @@: ret
  524. DetectV7 endp
  525. SetBank32V7 label byte
  526. push ax
  527. push bx
  528. mov bl,al
  529. and bl,1 ; BL = extended page select
  530. mov ah,al
  531. and ah,2
  532. shl ah,4 ; AH = page select bit
  533. and al,00ch
  534. mov bh,al
  535. shr al,2
  536. or bh,al ; BH = 256K bank select
  537. db 66h,0bah,0cch,03h ;mov dx, 3CCh
  538. in al,dx ; Get Miscellaneous Output Register
  539. and al,not 20h ; Clear page select bit
  540. or al,ah ; Set page select bit (maybe)
  541. mov dl,0c2h ; Write Miscellaneous Output Register
  542. out dx,al
  543. mov dl,0c4h ; Sequencer
  544. mov al,0f9h ; Extended page select register
  545. mov ah,bl ; Extended page select value
  546. out dx,eax ; out dx,ax
  547. mov al,0f6h ; 256K bank select
  548. out dx,al
  549. inc dx ; Point to data
  550. in al,dx
  551. and al,0f0h ; Clear out bank select banks
  552. or al,bh ; Set bank select banks (maybe)
  553. out dx,al
  554. pop bx
  555. pop ax
  556. SetBank32V7Size = $ - SetBank32V7
  557. SetBankV7 proc near
  558. mov bl,dl
  559. and bl,1 ; BL = extended page select
  560. mov ah,dl
  561. and ah,2
  562. shl ah,4 ; AH = page select bit
  563. and dl,00ch
  564. mov bh,dl
  565. shr dl,2
  566. or bh,dl ; BH = 256K bank select
  567. mov dx,03cch
  568. in al,dx ; Get Miscellaneous Output Register
  569. and al,not 20h ; Clear page select bit
  570. or al,ah ; Set page select bit (maybe)
  571. mov dl,0c2h ; Write Miscellaneous Output Register
  572. out dx,al
  573. mov dl,0c4h ; Sequencer
  574. mov al,0f9h ; Extended page select register
  575. mov ah,bl ; Extended page select value
  576. out dx,ax
  577. mov al,0f6h ; 256K bank select
  578. out dx,al
  579. inc dx ; Point to data
  580. in al,dx
  581. and al,0f0h ; Clear out bank select banks
  582. or al,bh ; Set bank select banks (maybe)
  583. out dx,al
  584. ret
  585. SetBankV7 endp
  586. GetBankV7 proc near
  587. mov dx,3cch
  588. in al,dx
  589. and al,20h ; page select bit
  590. shr al,4
  591. mov ah,al
  592. mov dx,3C4h
  593. mov al,0f9h
  594. out dx,al
  595. inc dx
  596. in al,dx
  597. and al,1
  598. or ah,al
  599. dec dx
  600. mov al,0F6h
  601. out dx,al
  602. inc dx
  603. in al,dx
  604. and al,0ch
  605. or al,ah
  606. xor ah,ah
  607. ret
  608. GetBankV7 endp
  609. ;****************************************************************************
  610. ; V7 II
  611. ;****************************************************************************
  612. DetectVRAM proc near
  613. if 0 ; ack!
  614. call DetectV7
  615. or ax,ax
  616. jz short novram
  617. mov dx,03C4H
  618. mov al,08FH
  619. out dx,al
  620. inc dx
  621. in al,dx
  622. mov ah,al
  623. dec dx
  624. mov al,08EH
  625. out dx,al
  626. inc dx
  627. in al,dx
  628. cmp ax,07151H ;VRAMII rev B id
  629. je short isvram
  630. cmp ax,07152H ;VRAMII rev C and D id
  631. je short isvram
  632. ; cmp ax,07760H ;HT216 rev B and C
  633. ; je short isvram
  634. ; cmp ax,07763H ;HT216 rev B, C, and D
  635. ; je short isvram
  636. ; cmp ax,07764H ;HT216 rev E
  637. ; je short isvram
  638. endif
  639. novram:
  640. xor ax,ax
  641. ret
  642. isvram:
  643. mov ax,1
  644. ret
  645. DetectVRAM endp
  646. SetBank32VRAM label byte
  647. push ax ;push eax
  648. shl dl,4
  649. mov ah,dl
  650. db 66h,0bah,0c4h,03h ; mov dx, 3C4h
  651. mov al,0e8h
  652. out dx,eax ; out dx,ax
  653. pop ax ; pop eax
  654. SetBank32VRAMSize = $ - SetBank32VRAM
  655. SetBankVRAM proc near
  656. shl dl,4
  657. mov ah,dl
  658. mov dx,03c4h
  659. mov al,0e8h
  660. out dx,ax
  661. ret
  662. SetBankVRAM endp
  663. GetBankVRAM proc near
  664. mov dx,3c4h
  665. mov al,0e8h
  666. out dx,al
  667. inc dx
  668. in al,dx
  669. shr al,4
  670. ret
  671. GetBankVRAM endp
  672. ;****************************************************************************
  673. ; ATI
  674. ;****************************************************************************
  675. public DetectATI
  676. DetectATI proc near
  677. mov ax,__C000h ;ATI VGA detect (largely from ATI example code)
  678. mov es,ax
  679. xor ax,ax
  680. cmp word ptr es:[40h],'13' ;ATI Signiture on the Video BIOS
  681. jne short @f
  682. inc ax
  683. @@: ret
  684. DetectATI endp
  685. SetBank32ATI label byte
  686. push ax
  687. mov ah,al
  688. shl ah,1
  689. mov al,0B2h
  690. db 66h,0bah,0ceh,01h ;mov dx, 1CEh
  691. out dx,eax
  692. pop ax
  693. SetBank32ATISize = $ - SetBank32ATI
  694. SetBankATI proc near
  695. mov ah,dl
  696. shl ah,1
  697. mov al,0b2h ;Page select register index
  698. mov dx,1ceh ;
  699. out dx,ax ;
  700. ret
  701. SetBankATI endp
  702. GetBankATI proc near
  703. mov dx,1ceh
  704. mov al,0b2h
  705. out dx,al
  706. inc dx
  707. in al,dx
  708. shr al,1
  709. ret
  710. GetBankATI endp
  711. ;****************************************************************************
  712. ; OAK
  713. ;****************************************************************************
  714. DetectOAK proc near
  715. lea ax,szOAK
  716. jmp ScanROM
  717. DetectOAK endp
  718. SetBank32Oak label byte
  719. push ax
  720. mov ah,al
  721. shl al,4
  722. or ah,al
  723. db 66h,0bah,0deh,03h ;mov dx, 3DEh
  724. mov al,11h
  725. out dx,eax
  726. pop ax
  727. SetBank32OakSize = $ - SetBank32Oak
  728. SetBankOAK proc near
  729. mov al,dl
  730. mov ah,al
  731. shl al,4
  732. or ah,al
  733. mov dx,3deh
  734. mov al,11h
  735. out dx,ax
  736. ret
  737. SetBankOAK endp
  738. GetBankOAK proc near
  739. mov dx,3deh
  740. mov al,11h
  741. out dx,al
  742. inc dx
  743. in al,dx
  744. and al,0Fh
  745. ret
  746. GetBankOAK endp
  747. ;****************************************************************************
  748. ; Everex
  749. ;****************************************************************************
  750. DetectEverex proc near
  751. lea ax,szEverex
  752. jmp ScanROM
  753. DetectEverex endp
  754. ;****************************************************************************
  755. ; Tseng
  756. ;****************************************************************************
  757. DetectTseng proc near
  758. lea ax,szTseng
  759. jmp ScanROM
  760. DetectTseng endp
  761. SetBank32Tseng label byte
  762. mov dx, ax ;mov edx,eax
  763. shl al, 4
  764. or al, dl
  765. db 66h,0bah,0cdh,03h ;mov dx, 3CDh
  766. out dx, al
  767. shr al, 4 ;shr al,4
  768. SetBank32TsengSize = $ - SetBank32Tseng
  769. SetBankTseng proc near
  770. and al,0fh
  771. mov al,dl
  772. mov ah,al
  773. shl al,4
  774. or al,ah
  775. mov dx,3cdh
  776. out dx,al
  777. ret
  778. SetBankTseng endp
  779. GetBankTseng proc near
  780. mov dx,3cdh
  781. in al,dx
  782. shr al, 4 ;shr al,4
  783. ret
  784. GetBankTseng endp
  785. ;****************************************************************************
  786. ; WD
  787. ;****************************************************************************
  788. DetectWD proc near
  789. lea ax,szWD
  790. call ScanROM
  791. or ax,ax
  792. jz short @f
  793. ret
  794. @@: lea ax,szParadise
  795. jmp ScanROM
  796. DetectWD endp
  797. SetBank32WD label byte
  798. push ax
  799. mov ah,al ;ah = bank number
  800. mov al,9 ;select the primary "bank adder" reg
  801. shl ah,4
  802. db 66h,0bah,0ceh,03h ;mov dx, 3CEh
  803. out dx,eax ;out dx,ax (write 3cf:09, desired bank)
  804. pop ax
  805. SetBank32WDSize = $ - SetBank32WD
  806. SetBankWD proc near
  807. mov al,9 ;select the primary "bank adder" reg
  808. mov ah,dl
  809. shl ah,4
  810. mov dx,3ceh
  811. out dx,ax ;write 3cf:09, desired bank
  812. ret
  813. SetBankWD endp
  814. GetBankWD proc near
  815. mov dx,3ceh
  816. mov al,9
  817. out dx,al
  818. inc dx
  819. in al,dx
  820. shr al,4
  821. ret
  822. GetBankWD endp
  823. ;****************************************************************************
  824. ; Weitek
  825. ;****************************************************************************
  826. DetectWeitek proc near
  827. lea ax,szWeitek
  828. jmp ScanROM
  829. DetectWeitek endp
  830. ;****************************************************************************
  831. ; Trident
  832. ;****************************************************************************
  833. DetectTrident proc near
  834. lea ax,szTrident
  835. jmp ScanROM
  836. DetectTrident endp
  837. SetBank32Trident label byte
  838. push ax
  839. mov ah,al
  840. xor ah,2
  841. mov al,0EH
  842. db 66h,0bah,0c4h,03h ;mov dx, 3C4h
  843. out dx,eax
  844. ;; db 66h,0bah,0ceh,03h ;mov dx, 3CEh
  845. ;; out dx,eax ;for 8900c or better only.
  846. pop ax
  847. SetBank32TridentSize = $ - SetBank32Trident
  848. SetBankTrident proc near
  849. mov ah,dl
  850. xor ah,2
  851. mov al,0EH
  852. mov dx,3c4h
  853. out dx,ax
  854. ;; mov dx,3ceh
  855. ;; out dx,ax ;for 8900c or better only.
  856. ret
  857. SetBankTrident endp
  858. GetBankTrident proc near
  859. mov dx,3c4h
  860. mov al,0eh
  861. out dx,al
  862. inc dx
  863. in al,dx
  864. xor al,2
  865. ret
  866. GetBankTrident endp
  867. ;****************************************************************************
  868. ; Compaq
  869. ;****************************************************************************
  870. DetectCompaq proc near
  871. mov ax,__C000h
  872. mov es,ax
  873. xor ax,ax
  874. cmp word ptr es:[2],0E930h
  875. jne short @f
  876. inc ax
  877. @@: ret
  878. DetectCompaq endp
  879. SetBank32Compaq label byte
  880. push ax
  881. mov ah,al
  882. shl ah,4
  883. mov al,45h
  884. db 66h,0bah,0ceh,03h ;mov dx, 3CEh
  885. out dx,eax
  886. inc al
  887. add ah,08h
  888. out dx,eax
  889. pop ax
  890. SetBank32CompaqSize = $ - SetBank32Compaq
  891. SetBankCompaq proc near
  892. mov ah,dl
  893. shl ah,4
  894. mov dx,03CEh
  895. mov al,45h
  896. out dx,ax
  897. inc al
  898. add ah,08h
  899. out dx,ax
  900. ret
  901. SetBankCompaq endp
  902. GetBankCompaq proc near
  903. mov dx,03CEh
  904. mov al,45h
  905. out dx,al
  906. inc dx
  907. in al,dx
  908. shr al,4
  909. ret
  910. GetBankCompaq endp
  911. ;****************************************************************************
  912. ; Cirrus 6420
  913. ;****************************************************************************
  914. DetectC6420 proc near
  915. %out *** need a Detect function for Cirrus 6420
  916. mov ax,1 ;!!!
  917. ret
  918. DetectC6420 endp
  919. SetBank32C6420 label byte
  920. push ax
  921. mov ah,al
  922. shl ah,4
  923. mov al,0eh
  924. db 66h,0bah,0ceh,03h ;mov dx, 3CEh
  925. out dx,eax ;
  926. pop ax
  927. SetBank32C6420Size = $ - SetBank32C6420
  928. SetBankC6420 proc near
  929. mov ah,dl
  930. shl ah,4
  931. mov al,0eh
  932. mov dx, 3CEh
  933. out dx,ax
  934. ret
  935. SetBankC6420 endp
  936. GetBankC6420 proc near
  937. mov dx,03CEh
  938. mov al,0Eh
  939. out dx,al
  940. inc dx
  941. in al,dx
  942. shr al,4
  943. ret
  944. GetBankC6420 endp
  945. ;****************************************************************************
  946. ; Cirrus 542x
  947. ;****************************************************************************
  948. DetectC542x proc near
  949. %out *** need a Detect function for Cirrus 542x
  950. mov ax,1 ;!!!
  951. ret
  952. DetectC542x endp
  953. SetBank32C542x label byte
  954. push ax
  955. mov ah,al
  956. shl ah,4
  957. mov al,09h
  958. db 66h,0bah,0ceh,03h ;mov dx, 3CEh
  959. out dx,eax
  960. pop ax
  961. SetBank32C542xSize = $ - SetBank32C542x
  962. SetBankC542x proc near
  963. mov ah,dl
  964. shl ah,4
  965. mov al,09h
  966. mov dx,3CEh
  967. out dx,ax
  968. ret
  969. SetBankC542x endp
  970. GetBankC542x proc near
  971. mov dx,03CEh
  972. mov al,09h
  973. out dx,al
  974. inc dx
  975. in al,dx
  976. shr al,4
  977. ret
  978. GetBankC542x endp
  979. ;****************************************************************************
  980. ; Viper Vesa Local bus
  981. ;****************************************************************************
  982. public DetectViper
  983. DetectViper proc near
  984. lea ax,szViper
  985. jmp ScanROM
  986. DetectViper endp
  987. sEnd
  988. end