graph.inc 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562
  1. { How this works: }
  2. { QueryAdapter - Va chercher tout les modes videos et drivers }
  3. { disponibles sur cette carte, et les mets dans une linked list }
  4. { en ordre de driver number, et a l'interieur de cela, dans un }
  5. { ordre croissant de mode number. }
  6. { DetectGraph - Verifie si la liste chainee de drivers existe, sinon }
  7. { apelle QueryAdapter }
  8. { InitGraph - Appelle DetectGraph, et verifie que le mode demande existe}
  9. { bel et bien et est disponible sur ce PC }
  10. {$i dpmi.inc}
  11. CONST
  12. { VESA Specific video modes. }
  13. m320x200x32k = $10D;
  14. m320x200x64k = $10E;
  15. m640x400x256 = $100;
  16. m640x480x256 = $101;
  17. m640x480x32k = $110;
  18. m640x480x64k = $111;
  19. m800x600x16 = $102;
  20. m800x600x256 = $103;
  21. m800x600x32k = $113;
  22. m800x600x64k = $114;
  23. m1024x768x16 = $104;
  24. m1024x768x256 = $105;
  25. m1024x768x32k = $116;
  26. m1024x768x64k = $117;
  27. m1280x1024x16 = $106;
  28. m1280x1024x256 = $107;
  29. m1280x1024x32k = $119;
  30. m1280x1024x64k = $11A;
  31. { How to access real mode memory }
  32. { using 32-bit DPMI memory }
  33. { 1. Allocate a descriptor }
  34. { 2. Set segment limit }
  35. { 3. Set base linear address }
  36. const
  37. InternalDriverName = 'DOSGX';
  38. VideoOfs : word = 0; { Segment to draw to }
  39. FirstPlane = $0102; (* 02 = Index to Color plane Select, *)
  40. (* 01 = Enable color plane 1 *)
  41. { ; ===== VGA Register Values ===== }
  42. SCREEN_WIDTH = 80 ; { MODE-X 320 SCREEN WIDTH }
  43. { CHANGE THE VALUE IF OTHER MODES }
  44. { OTHER THEN 320 ARE USED. }
  45. ATTRIB_Ctrl = $03C0 ; { VGA Attribute Controller }
  46. GC_Index = $03CE ; { VGA Graphics Controller }
  47. SC_Index = $03C4 ; { VGA Sequencer Controller }
  48. SC_Data = $03C5 ; { VGA Sequencer Data Port }
  49. CRTC_Index = $03D4 ; { VGA CRT Controller }
  50. CRTC_Data = $03D5 ; { VGA CRT Controller Data }
  51. MISC_OUTPUT = $03C2 ; { VGA Misc Register }
  52. INPUT_1 = $03DA ; { Input Status #1 Register }
  53. DAC_WRITE_ADDR = $03C8 ; { VGA DAC Write Addr Register }
  54. DAC_READ_ADDR = $03C7 ; { VGA DAC Read Addr Register }
  55. PEL_DATA_REG = $03C9 ; { VGA DAC/PEL data Register R/W }
  56. PIXEL_PAN_REG = $033 ; { Attrib Index: Pixel Pan Reg }
  57. MAP_MASK = $002 ; { S= $Index: Write Map Mask reg }
  58. READ_MAP = $004 ; { GC Index: Read Map Register }
  59. START_DISP_HI = $00C ; { CRTC Index: Display Start Hi }
  60. START_DISP_LO = $00D ; { CRTC Index: Display Start Lo }
  61. MAP_MASK_PLANE1 = $00102 ; { Map Register + Plane 1 }
  62. MAP_MASK_PLANE2 = $01102 ; { Map Register + Plane 1 }
  63. ALL_PLANES_ON = $00F02 ; { Map Register + All Bit Planes }
  64. CHAIN4_OFF = $00604 ; { Chain 4 mode Off }
  65. ASYNC_RESET = $00100 ; { (A)synchronous Reset }
  66. SEQU_RESTART = $00300 ; { Sequencer Restart }
  67. LATCHES_ON = $00008 ; { Bit Mask + Data from Latches }
  68. LATCHES_OFF = $0FF08 ; { Bit Mask + Data from CPU }
  69. VERT_RETRACE = $08 ; { INPUT_1: Vertical Retrace Bit }
  70. PLANE_BITS = $03 ; { Bits 0-1 of Xpos = Plane # }
  71. ALL_PLANES = $0F ; { All Bit Planes Selected }
  72. CHAR_BITS = $0F ; { Bits 0-3 of Character Data }
  73. GET_CHAR_PTR = $01130 ; { VGA BIOS Func: Get Char Set }
  74. ROM_8x8_Lo = $03 ; { ROM 8x8 Char Set Lo Pointer }
  75. ROM_8x8_Hi = $04 ; { ROM 8x8 Char Set Hi Pointer }
  76. { Constants Specific for these routines }
  77. NUM_MODES = $8 ; { # of Mode X Variations }
  78. {************************************************************************}
  79. {* 4-bit planar VGA mode routines *)
  80. {************************************************************************}
  81. Procedure Init640x200x16; assembler;
  82. { must also clear the screen...}
  83. asm
  84. mov ax,000Eh
  85. int 10h
  86. end;
  87. Procedure Init640x350x16; assembler;
  88. { must also clear the screen...}
  89. asm
  90. mov ax,0010h
  91. int 10h
  92. end;
  93. procedure Init640x480x16; assembler;
  94. { must also clear the screen...}
  95. asm
  96. mov ax,0012h
  97. int 10h
  98. end;
  99. Procedure PutPixel16(X,Y : Integer; Pixel: Word);
  100. Begin
  101. X:= X + StartXViewPort;
  102. Y:= Y + StartYViewPort;
  103. { convert to absolute coordinates and then verify clipping...}
  104. if ClipPixels then
  105. Begin
  106. if (X < StartXViewPort) or (X > (StartXViewPort + ViewWidth)) then
  107. exit;
  108. if (Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)) then
  109. exit;
  110. end;
  111. asm
  112. mov es, [SegA000]
  113. { enable the set / reset function and load the color }
  114. mov dx, 3ceh
  115. mov ax, 0f01h
  116. out dx, ax
  117. { setup set/reset register }
  118. mov ax, [Pixel]
  119. shl ax, 8
  120. out dx, ax
  121. { setup the bit mask register }
  122. mov al, 8
  123. out dx, al
  124. inc dx
  125. { load the bitmask register }
  126. mov cx, [X]
  127. and cx, 0007h
  128. mov al, 80h
  129. shr al, cl
  130. out dx, ax
  131. { get the x index and divide by 8 for 16-color }
  132. mov ax,[X]
  133. shr ax,3
  134. push ax
  135. { determine the address }
  136. mov ax,80
  137. mov bx,[Y]
  138. mul bx
  139. pop cx
  140. add ax,cx
  141. mov di,ax
  142. add di, [VideoOfs]
  143. { send the data through the display memory through set/reset }
  144. mov bl,es:[di]
  145. mov es:[di],bl
  146. { reset for formal vga operation }
  147. mov dx,3ceh
  148. mov ax,0ff08h
  149. out dx,ax
  150. { restore enable set/reset register }
  151. mov ax,0001h
  152. out dx,ax
  153. end;
  154. end;
  155. Function GetPixel16(X,Y: Integer):word;
  156. Begin
  157. X:= X + StartXViewPort;
  158. Y:= Y + StartYViewPort;
  159. asm
  160. mov ax, [X] { Get X address }
  161. push ax
  162. shr ax, 3
  163. push ax
  164. mov ax,80
  165. mov bx,[Y]
  166. mul bx
  167. pop cx
  168. add ax,cx
  169. mov si,ax { SI = correct offset into video segment }
  170. mov es,[SegA000]
  171. add si,[VideoOfs] { Point to correct page offset... }
  172. mov dx,03ceh
  173. mov ax,4
  174. out dx,al
  175. inc dx
  176. pop ax
  177. and ax,0007h
  178. mov cl,07
  179. sub cl,al
  180. mov bl,cl
  181. { read plane 0 }
  182. mov al,0 { Select plane to read }
  183. out dx,al
  184. mov al,es:[si] { read display memory }
  185. shr al,cl
  186. and al,01h
  187. mov ah,al { save bit in AH }
  188. { read plane 1 }
  189. mov al,1 { Select plane to read }
  190. out dx,al
  191. mov al,es:[si]
  192. shr al,cl
  193. and al,01h
  194. shl al,1
  195. or ah,al { save bit in AH }
  196. { read plane 2 }
  197. mov al,2 { Select plane to read }
  198. out dx,al
  199. mov al,es:[si]
  200. shr al,cl
  201. and al,01h
  202. shl al,2
  203. or ah,al { save bit in AH }
  204. { read plane 3 }
  205. mov al,3 { Select plane to read }
  206. out dx,al
  207. mov al,es:[si]
  208. shr al,cl
  209. and al,01h
  210. shl al,3
  211. or ah,al { save bit in AH }
  212. mov al,ah { 16-bit pixel in AX }
  213. xor ah,ah
  214. mov @Result, ax
  215. end;
  216. end;
  217. Procedure DirectPutPixel16(X,Y : Integer);
  218. { x,y -> must be in global coordinates. No clipping. }
  219. var
  220. color: word;
  221. begin
  222. if CurrentWriteMode = XORPut then
  223. begin
  224. { getpixel wants local/relative coordinates }
  225. Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
  226. Color := CurrentColor XOR Color;
  227. end
  228. else
  229. Color := CurrentColor;
  230. asm
  231. mov es, [SegA000]
  232. { enable the set / reset function and load the color }
  233. mov dx, 3ceh
  234. mov ax, 0f01h
  235. out dx, ax
  236. { setup set/reset register }
  237. mov ax, [Color]
  238. shl ax, 8
  239. out dx, ax
  240. { setup the bit mask register }
  241. mov al, 8
  242. out dx, al
  243. inc dx
  244. { load the bitmask register }
  245. mov cx, [X]
  246. and cx, 0007h
  247. mov al, 80h
  248. shr al, cl
  249. out dx, ax
  250. { get the x index and divide by 8 for 16-color }
  251. mov ax,[X]
  252. shr ax,3
  253. push ax
  254. { determine the address }
  255. mov ax,80
  256. mov bx,[Y]
  257. mul bx
  258. pop cx
  259. add ax,cx
  260. mov di,ax
  261. { send the data through the display memory through set/reset }
  262. add di,[VideoOfs] { add correct page }
  263. mov bl,es:[di]
  264. mov es:[di],bl
  265. { reset for formal vga operation }
  266. mov dx,3ceh
  267. mov ax,0ff08h
  268. out dx,ax
  269. { restore enable set/reset register }
  270. mov ax,0001h
  271. out dx,ax
  272. end;
  273. end;
  274. procedure SetVisual480(page: word);
  275. { no page flipping support in 640x480 mode }
  276. begin
  277. VideoOfs := 0;
  278. end;
  279. procedure SetActive480(page: word);
  280. { no page flipping support in 640x480 mode }
  281. begin
  282. VideoOfs := 0;
  283. end;
  284. procedure SetVisual200(page: word);
  285. { two page support... }
  286. begin
  287. if page > 2 then exit;
  288. asm
  289. mov ax,[page] { only lower byte is supported. }
  290. mov ah,05h
  291. int 10h
  292. { read start address }
  293. mov dx,3d4h
  294. mov al,0ch
  295. out dx,al
  296. inc dx
  297. in al,dx
  298. mov ah,al
  299. dec dx
  300. mov al,0dh
  301. out dx,al
  302. in al,dx
  303. end;
  304. end;
  305. procedure SetActive200(page: word);
  306. { two page support... }
  307. begin
  308. case page of
  309. 0 : VideoOfs := 0;
  310. 1 : VideoOfs := 16384;
  311. 2 : VideoOfs := 32768;
  312. else
  313. VideoOfs := 0;
  314. end;
  315. end;
  316. procedure SetVisual350(page: word);
  317. { one page support... }
  318. begin
  319. if page > 1 then exit;
  320. asm
  321. mov ax,[page] { only lower byte is supported. }
  322. mov ah,05h
  323. int 10h
  324. end;
  325. end;
  326. procedure SetActive350(page: word);
  327. { one page support... }
  328. begin
  329. case page of
  330. 0 : VideoOfs := 0;
  331. 1 : VideoOfs := 32768;
  332. else
  333. VideoOfs := 0;
  334. end;
  335. end;
  336. {************************************************************************}
  337. {* 320x200x256c Routines *)
  338. {************************************************************************}
  339. Procedure Init320; assembler;
  340. asm
  341. mov ax,0013h
  342. int 10h
  343. end;
  344. Procedure PutPixel320(X,Y : Integer; Pixel: Word);
  345. { x,y -> must be in local coordinates. Clipping if required. }
  346. Begin
  347. X:= X + StartXViewPort;
  348. Y:= Y + StartYViewPort;
  349. { convert to absolute coordinates and then verify clipping...}
  350. if ClipPixels then
  351. Begin
  352. if (X < StartXViewPort) or (X > (StartXViewPort + ViewWidth)) then
  353. exit;
  354. if (Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)) then
  355. exit;
  356. end;
  357. asm
  358. mov es, [SegA000]
  359. mov ax, [Y]
  360. mov di, [X]
  361. xchg ah, al { The value of Y must be in AH }
  362. add di, ax
  363. shr ax, 2
  364. add di, ax
  365. add di, [VideoOfs] { point to correct page.. }
  366. mov ax, [Pixel]
  367. mov es:[di], al
  368. end;
  369. end;
  370. Function GetPixel320(X,Y: Integer):word;
  371. Begin
  372. X:= X + StartXViewPort;
  373. Y:= Y + StartYViewPort;
  374. asm
  375. mov es, [SegA000]
  376. mov ax, [Y]
  377. mov di, [X]
  378. xchg ah, al { The value of Y must be in AH }
  379. add di, ax
  380. shr ax, 2
  381. add di, ax
  382. add di, [VideoOfs] { point to correct gfx page ... }
  383. mov al,es:[di]
  384. cbw
  385. mov @Result,ax
  386. end;
  387. end;
  388. Procedure DirectPutPixel320(X,Y : Integer);assembler;
  389. { x,y -> must be in global coordinates. No clipping. }
  390. asm
  391. mov es, [SegA000]
  392. mov ax, [Y]
  393. mov di, [X]
  394. xchg ah, al { The value of Y must be in AH }
  395. add di, ax
  396. shr ax, 2
  397. add di, ax
  398. add di, [VideoOfs]
  399. mov ax, [CurrentColor]
  400. cmp [CurrentWriteMode],XORPut { check write mode }
  401. jne @MOVMode
  402. mov ah,es:[di] { read the byte... }
  403. xor al,ah { xor it and return value into AL }
  404. @MovMode:
  405. mov es:[di], al
  406. end;
  407. procedure SetVisual320(page: word);
  408. { no page support... }
  409. begin
  410. end;
  411. procedure SetActive320(page: word);
  412. { no page support... }
  413. begin
  414. VideoOfs := 0;
  415. end;
  416. {************************************************************************}
  417. {* Mode-X related routines *}
  418. {************************************************************************}
  419. const CrtAddress: word = 0;
  420. procedure InitModeX;
  421. begin
  422. asm
  423. {see if we are using color-/monochorme display}
  424. MOV DX,3CCh {use output register: }
  425. IN AL,DX
  426. TEST AL,1 {is it a color display? }
  427. MOV DX,3D4h
  428. JNZ @L1 {yes }
  429. MOV DX,3B4h {no }
  430. @L1: {DX = 3B4h / 3D4h = CRTAddress-register for monochrome/color}
  431. MOV CRTAddress,DX
  432. MOV AX, 0013h
  433. INT 10h
  434. MOV DX,03C4h {select memory-mode-register at sequencer port }
  435. MOV AL,04
  436. OUT DX,AL
  437. INC DX {read in data via the according data register }
  438. IN AL,DX
  439. AND AL,0F7h {bit 3 := 0: don't chain the 4 planes}
  440. OR AL,04 {bit 2 := 1: no odd/even mechanism }
  441. OUT DX,AL {activate new settings }
  442. MOV DX,03C4h {s.a.: address sequencer reg. 2 (=map-mask),... }
  443. MOV AL,02
  444. OUT DX,AL
  445. INC DX
  446. MOV AL,0Fh {...and allow access to all 4 bit maps }
  447. OUT DX,AL
  448. MOV AX,[SegA000] {starting with segment A000h, set 8000h logical }
  449. MOV ES,AX {words = 4*8000h physical words (because of 4 }
  450. SUB DI,DI {bitplanes) to 0 }
  451. MOV AX,DI
  452. MOV CX,8000h
  453. CLD
  454. REP STOSW
  455. MOV DX,CRTAddress {address the underline-location-register at }
  456. MOV AL,14h {the CRT-controller port, read out the according }
  457. OUT DX,AL {data register: }
  458. INC DX
  459. IN AL,DX
  460. AND AL,0BFh {bit 6:=0: no double word addressing scheme in}
  461. OUT DX,AL {video RAM }
  462. DEC DX
  463. MOV AL,17h {select mode control register }
  464. OUT DX,AL
  465. INC DX
  466. IN AL,DX
  467. OR AL,40h {bit 6 := 1: memory access scheme=linear bit array }
  468. OUT DX,AL
  469. end;
  470. end;
  471. Function GetPixelX(X,Y: Integer): word;
  472. begin
  473. X:= X + StartXViewPort;
  474. Y:= Y + StartYViewPort;
  475. ASM
  476. mov di,[Y] ; (* DI = Y coordinate *)
  477. (* Multiply by 80 start *)
  478. mov bx, di
  479. shl di, 6 ; (* Faster on 286/386/486 machines *)
  480. shl bx, 4
  481. add di, bx ; (* Multiply Value by 80 *)
  482. (* End multiply by 80 *)
  483. mov cx, [X]
  484. mov ax, cx
  485. {DI = Y * LINESIZE, BX = X, coordinates admissible}
  486. shr ax, 1 ; (* Faster on 286/86 machines *)
  487. shr ax, 1
  488. add di, ax ; {DI = Y * LINESIZE + (X SHR 2) }
  489. add di, [VideoOfs] ; (* Pointing at start of Active page *)
  490. (* Select plane to use *)
  491. mov dx, 03c4h
  492. mov ax, FirstPlane ; (* Map Mask & Plane Select Register *)
  493. and cl, 03h ; (* Get Plane Bits *)
  494. shl ah, cl ; (* Get Plane Select Value *)
  495. out dx, ax
  496. (* End selection of plane *)
  497. mov es,[SegA000]
  498. mov al, ES:[DI]
  499. xor ah, ah
  500. mov @Result, ax
  501. end;
  502. end;
  503. procedure SetVisualX(page: word);
  504. { 4 page support... }
  505. Procedure SetVisibleStart(AOffset: word); Assembler;
  506. (* Select where the left corner of the screen will be *)
  507. { By Matt Pritchard }
  508. ASM
  509. { Wait if we are currently in a Vertical Retrace }
  510. MOV DX, INPUT_1 { Input Status #1 Register }
  511. @DP_WAIT0:
  512. IN AL, DX { Get VGA status }
  513. AND AL, VERT_RETRACE { In Display mode yet? }
  514. JNZ @DP_WAIT0 { If Not, wait for it }
  515. { Set the Start Display Address to the new page }
  516. MOV DX, CRTC_Index { We Change the VGA Sequencer }
  517. MOV AL, START_DISP_LO { Display Start Low Register }
  518. MOV AH, BYTE PTR [AOffset] { Low 8 Bits of Start Addr }
  519. OUT DX, AX { Set Display Addr Low }
  520. MOV AL, START_DISP_HI { Display Start High Register }
  521. MOV AH, BYTE PTR [AOffset+1] { High 8 Bits of Start Addr }
  522. OUT DX, AX { Set Display Addr High }
  523. { Wait for a Vertical Retrace to smooth out things }
  524. MOV DX, INPUT_1 { Input Status #1 Register }
  525. @DP_WAIT1:
  526. IN AL, DX { Get VGA status }
  527. AND AL, VERT_RETRACE { Vertical Retrace Start? }
  528. JZ @DP_WAIT1 { If Not, wait for it }
  529. { Now Set Display Starting Address }
  530. end;
  531. begin
  532. Case page of
  533. 0: SetVisibleStart(0);
  534. 1: SetVisibleStart(16000);
  535. 2: SetVisibleStart(32000);
  536. 3: SetVisibleStart(48000);
  537. else
  538. SetVisibleStart(0);
  539. end;
  540. end;
  541. procedure SetActiveX(page: word);
  542. { 4 page support... }
  543. begin
  544. case page of
  545. 0: VideoOfs := 0;
  546. 1: VideoOfs := 16000;
  547. 2: VideoOfs := 32000;
  548. 3: VideoOfs := 48000;
  549. else
  550. VideoOfs:=0;
  551. end;
  552. end;
  553. Procedure PutPixelX(X,Y: Integer; color:word);
  554. begin
  555. X:= X + StartXViewPort;
  556. Y:= Y + StartYViewPort;
  557. { convert to absolute coordinates and then verify clipping...}
  558. if ClipPixels then
  559. Begin
  560. if (X < StartXViewPort) or (X > (StartXViewPort + ViewWidth)) then
  561. exit;
  562. if (Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)) then
  563. exit;
  564. end;
  565. ASM
  566. mov di,[Y] ; (* DI = Y coordinate *)
  567. (* Multiply by 80 start *)
  568. mov bx, di
  569. shl di, 6 ; (* Faster on 286/386/486 machines *)
  570. shl bx, 4
  571. add di, bx ; (* Multiply Value by 80 *)
  572. (* End multiply by 80 *)
  573. mov cx, [X]
  574. mov ax, cx
  575. {DI = Y * LINESIZE, BX = X, coordinates admissible}
  576. shr ax, 2
  577. add di, ax ; {DI = Y * LINESIZE + (X SHR 2) }
  578. add di, [VideoOfs] ; (* Pointing at start of Active page *)
  579. (* Select plane to use *)
  580. mov dx, 03c4h
  581. mov ax, FirstPlane ; (* Map Mask & Plane Select Register *)
  582. and cl, 03h ; (* Get Plane Bits *)
  583. shl ah, cl ; (* Get Plane Select Value *)
  584. out dx, ax
  585. (* End selection of plane *)
  586. mov es,[SegA000]
  587. mov ax,[Color] ; { only lower byte is used. }
  588. cmp [CurrentWriteMode],XORPut { check write mode }
  589. jne @MOVMode
  590. mov ah,es:[di] { read the byte... }
  591. xor al,ah { xor it and return value into AL }
  592. @MovMode:
  593. mov es:[di], al
  594. end;
  595. end;
  596. Procedure DirectPutPixelX(X,Y: Integer); Assembler;
  597. { x,y -> must be in global coordinates. No clipping. }
  598. ASM
  599. mov di,[Y] ; (* DI = Y coordinate *)
  600. (* Multiply by 80 start *)
  601. mov bx, di
  602. shl di, 6 ; (* Faster on 286/386/486 machines *)
  603. shl bx, 4
  604. add di, bx ; (* Multiply Value by 80 *)
  605. (* End multiply by 80 *)
  606. mov cx, [X]
  607. mov ax, cx
  608. {DI = Y * LINESIZE, BX = X, coordinates admissible}
  609. shr ax, 2
  610. add di, ax ; {DI = Y * LINESIZE + (X SHR 2) }
  611. add di, [VideoOfs] ; (* Pointing at start of Active page *)
  612. (* Select plane to use *)
  613. mov dx, 03c4h
  614. mov ax, FirstPlane ; (* Map Mask & Plane Select Register *)
  615. and cl, 03h ; (* Get Plane Bits *)
  616. shl ah, cl ; (* Get Plane Select Value *)
  617. out dx, ax
  618. (* End selection of plane *)
  619. mov es,[SegA000]
  620. mov ax,[CurrentColor] ; { only lower byte is used. }
  621. cmp [CurrentWriteMode],XORPut { check write mode }
  622. jne @MOVMode
  623. mov ah,es:[di] { read the byte... }
  624. xor al,ah { xor it and return value into AL }
  625. @MovMode:
  626. mov es:[di], al
  627. end;
  628. {************************************************************************}
  629. {* General routines *}
  630. {************************************************************************}
  631. var
  632. SavePtr : pointer; { pointer to video state }
  633. StateSize: word; { size in 64 byte blocks for video state }
  634. VideoMode: byte; { old video mode before graph mode }
  635. SaveSupported : Boolean; { Save/Restore video state supported? }
  636. {**************************************************************}
  637. {* DPMI Routines *}
  638. {**************************************************************}
  639. {$IFDEF DPMI}
  640. RealStateSeg: word; { Real segment of saved video state }
  641. Procedure SaveStateVGA;
  642. var
  643. PtrLong: longint;
  644. regs: TDPMIRegisters;
  645. begin
  646. SaveSupported := FALSE;
  647. SavePtr := nil;
  648. { Get the video mode }
  649. asm
  650. mov ah,0fh
  651. int 10h
  652. mov [VideoMode], al
  653. end;
  654. { Prepare to save video state...}
  655. asm
  656. mov ax, 1C00h { get buffer size to save state }
  657. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  658. int 10h
  659. mov [StateSize], bx
  660. cmp al,01ch
  661. jnz @notok
  662. mov [SaveSupported],TRUE
  663. @notok:
  664. end;
  665. if SaveSupported then
  666. begin
  667. PtrLong:=GlobalDosAlloc(64*StateSize); { values returned in 64-byte blocks }
  668. if PtrLong = 0 then
  669. RunError(203);
  670. SavePtr := pointer(longint(PtrLong and $0000ffff) shl 16);
  671. RealStateSeg := word((PtrLong and $ffff0000) shr 16);
  672. if not assigned(SavePtr) then
  673. RunError(203);
  674. FillChar(regs, sizeof(regs), #0);
  675. { call the real mode interrupt ... }
  676. regs.eax := $1C01; { save the state buffer }
  677. regs.ecx := $07; { Save DAC / Data areas / Hardware states }
  678. regs.es := RealStateSeg;
  679. regs.ebx := 0;
  680. RealIntr($10,regs);
  681. FillChar(regs, sizeof(regs), #0);
  682. { restore state, according to Ralph Brown Interrupt list }
  683. { some BIOS corrupt the hardware after a save... }
  684. regs.eax := $1C02; { restore the state buffer }
  685. regs.ecx := $07; { rest DAC / Data areas / Hardware states }
  686. regs.es := RealStateSeg;
  687. regs.ebx := 0;
  688. RealIntr($10,regs);
  689. end;
  690. end;
  691. procedure RestoreStateVGA;
  692. var
  693. regs:TDPMIRegisters;
  694. begin
  695. { go back to the old video mode...}
  696. asm
  697. mov ah,00
  698. mov al,[VideoMode]
  699. int 10h
  700. end;
  701. { then restore all state information }
  702. if assigned(SavePtr) and (SaveSupported=TRUE) then
  703. begin
  704. FillChar(regs, sizeof(regs), #0);
  705. { restore state, according to Ralph Brown Interrupt list }
  706. { some BIOS corrupt the hardware after a save... }
  707. regs.eax := $1C02; { restore the state buffer }
  708. regs.ecx := $07; { rest DAC / Data areas / Hardware states }
  709. regs.es := RealStateSeg;
  710. regs.ebx := 0;
  711. RealIntr($10,regs);
  712. if GlobalDosFree(longint(SavePtr) shr 16)<>0 then
  713. RunError(216);
  714. SavePtr := nil;
  715. end;
  716. end;
  717. {$ELSE}
  718. {**************************************************************}
  719. {* Real mode routines *}
  720. {**************************************************************}
  721. Procedure SaveStateVGA;
  722. begin
  723. SavePtr := nil;
  724. SaveSupported := FALSE;
  725. { Get the video mode }
  726. asm
  727. mov ah,0fh
  728. int 10h
  729. mov [VideoMode], al
  730. end;
  731. { Prepare to save video state...}
  732. asm
  733. mov ax, 1C00h { get buffer size to save state }
  734. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  735. int 10h
  736. mov [StateSize], bx
  737. cmp al,01ch
  738. jnz @notok
  739. mov [SaveSupported],TRUE
  740. @notok:
  741. end;
  742. if SaveSupported then
  743. Begin
  744. GetMem(SavePtr, 64*StateSize); { values returned in 64-byte blocks }
  745. if not assigned(SavePtr) then
  746. RunError(203);
  747. asm
  748. mov ax, 1C01h { save the state buffer }
  749. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  750. mov es, WORD PTR [SavePtr+2]
  751. mov bx, WORD PTR [SavePtr]
  752. int 10h
  753. end;
  754. { restore state, according to Ralph Brown Interrupt list }
  755. { some BIOS corrupt the hardware after a save... }
  756. asm
  757. mov ax, 1C02h { save the state buffer }
  758. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  759. mov es, WORD PTR [SavePtr+2]
  760. mov bx, WORD PTR [SavePtr]
  761. int 10h
  762. end;
  763. end;
  764. end;
  765. procedure RestoreStateVGA;
  766. begin
  767. { go back to the old video mode...}
  768. asm
  769. mov ah,00
  770. mov al,[VideoMode]
  771. int 10h
  772. end;
  773. { then restore all state information }
  774. if assigned(SavePtr) and (SaveSupported=TRUE) then
  775. begin
  776. { restore state, according to Ralph Brown Interrupt list }
  777. asm
  778. mov ax, 1C02h { save the state buffer }
  779. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  780. mov es, WORD PTR [SavePtr+2]
  781. mov bx, WORD PTR [SavePtr]
  782. int 10h
  783. end;
  784. FreeMem(SavePtr, 64*StateSize);
  785. SavePtr := nil;
  786. end;
  787. end;
  788. {$ENDIF DPMI}
  789. { VGA is never a direct color mode, so no need to check ... }
  790. Procedure SetVGARGBPalette(ColorNum, RedValue, GreenValue,
  791. BlueValue : Integer); assembler;
  792. asm
  793. { on some hardware - there is a snow like effect }
  794. { when changing the palette register directly }
  795. { so we wait for a vertical retrace start period. }
  796. mov dx, $03da
  797. @1:
  798. in al, dx { Get input status register }
  799. test al, $08 { check if in vertical retrace }
  800. jnz @1 { yes, complete it }
  801. { we have to wait for the next }
  802. { retrace to assure ourselves }
  803. { that we have time to complete }
  804. { the DAC operation within }
  805. { the vertical retrace period }
  806. @2:
  807. in al, dx
  808. test al, $08
  809. jz @2 { repeat until vertical retrace start }
  810. mov dx, $03c8 { Set color register address to use }
  811. mov ax, [ColorNum]
  812. out dx, al
  813. inc dx { Point to DAC registers }
  814. mov ax, [RedValue] { Get RedValue }
  815. and ax, $ff { mask out all upper bits }
  816. shr al, 2 { convert to LSB RGB format }
  817. out dx, al
  818. mov ax, [GreenValue]{ Get RedValue }
  819. and ax, $ff { mask out all upper bits }
  820. shr al, 2 { convert to LSB RGB format }
  821. out dx, al
  822. mov ax, [BlueValue] { Get RedValue }
  823. and ax, $ff { mask out all upper bits }
  824. shr al, 2 { convert to LSB RGB format }
  825. out dx, al
  826. end;
  827. { VGA is never a direct color mode, so no need to check ... }
  828. Procedure GetVGARGBPalette(ColorNum: integer; Var
  829. RedValue, GreenValue, BlueValue : integer);
  830. begin
  831. Port[$03C7] := ColorNum;
  832. { we must convert to lsb values... because the vga uses the 6 msb bits }
  833. { which is not compatible with anything. }
  834. RedValue := Integer(Port[$3C9] shl 2);
  835. GreenValue := Integer(Port[$3C9] shl 2);
  836. BlueValue := Integer(Port[$3C9] shl 2);
  837. end;
  838. {************************************************************************}
  839. {* VESA related routines *}
  840. {************************************************************************}
  841. {$I vesa.inc}
  842. {************************************************************************}
  843. {* General routines *}
  844. {************************************************************************}
  845. procedure CloseGraph;
  846. Begin
  847. if not assigned(RestoreVideoState) then
  848. RunError(216);
  849. RestoreVideoState;
  850. {$IFDEF DPMI}
  851. { We had copied the buffer of mode information }
  852. { and allocated it dynamically... now free it }
  853. Dispose(VESAInfo.ModeList);
  854. {$ENDIF}
  855. end;
  856. function QueryAdapterInfo:PModeInfo;
  857. { This routine returns the head pointer to the list }
  858. { of supported graphics modes. }
  859. { Returns nil if no graphics mode supported. }
  860. { This list is READ ONLY! }
  861. var
  862. EGADetected : Boolean;
  863. VGADetected : Boolean;
  864. mode: TModeInfo;
  865. begin
  866. QueryAdapterInfo := ModeList;
  867. { If the mode listing already exists... }
  868. { simply return it, without changing }
  869. { anything... }
  870. if assigned(ModeList) then
  871. exit;
  872. EGADetected := FALSE;
  873. VGADetected := FALSE;
  874. { check if Hercules adapter supported ... }
  875. { check if EGA adapter supported... }
  876. asm
  877. mov ah,12h
  878. mov bx,0FF10h
  879. int 10h { get EGA information }
  880. cmp bh,0ffh
  881. jz @noega
  882. mov [EGADetected],TRUE
  883. @noega:
  884. end;
  885. { check if VGA adapter supported... }
  886. if EGADetected then
  887. begin
  888. asm
  889. mov ax,1a00h
  890. int 10h { get display combination code...}
  891. cmp al,1ah { check if supported... }
  892. jne @novga
  893. { now check if this is the ATI EGA }
  894. mov ax,1c00h { get state size for save... }
  895. mov cx,00h
  896. int 10h
  897. cmp al,1ch { success? }
  898. jne @novga
  899. mov [VGADetected],TRUE
  900. @novga:
  901. end;
  902. end;
  903. if VGADetected then
  904. begin
  905. SaveVideoState := SaveStateVGA;
  906. RestoreVideoState := RestoreStateVGA;
  907. InitMode(mode);
  908. { now add all standard VGA modes... }
  909. mode.DriverNumber:= LowRes;
  910. mode.ModeNumber:=0;
  911. mode.ModeName:='320 x 200 VGA';
  912. mode.MaxColor := 256;
  913. mode.PaletteSize := mode.MaxColor;
  914. mode.DirectColor := FALSE;
  915. mode.MaxX := 319;
  916. mode.MaxY := 199;
  917. mode.DirectPutPixel:=DirectPutPixel320;
  918. mode.PutPixel:=PutPixel320;
  919. mode.GetPixel:=GetPixel320;
  920. mode.SetRGBPalette := SetVGARGBPalette;
  921. mode.GetRGBPalette := GetVGARGBPalette;
  922. mode.SetVisualPage := SetVisual320;
  923. mode.SetActivePage := SetActive320;
  924. mode.InitMode := Init320;
  925. mode.XAspect := 10000;
  926. mode.YAspect := 10000;
  927. AddMode(mode);
  928. { now add all standard VGA modes... }
  929. InitMode(mode);
  930. mode.DriverNumber:= LowRes;
  931. mode.ModeNumber:=1;
  932. mode.ModeName:='320 x 200 ModeX';
  933. mode.MaxColor := 256;
  934. mode.DirectColor := FALSE;
  935. mode.PaletteSize := mode.MaxColor;
  936. mode.MaxX := 319;
  937. mode.MaxY := 199;
  938. mode.DirectPutPixel:=DirectPutPixelX;
  939. mode.PutPixel:=PutPixelX;
  940. mode.GetPixel:=GetPixelX;
  941. mode.SetRGBPalette := SetVGARGBPalette;
  942. mode.GetRGBPalette := GetVGARGBPalette;
  943. mode.SetVisualPage := SetVisualX;
  944. mode.SetActivePage := SetActiveX;
  945. mode.InitMode := InitModeX;
  946. mode.XAspect := 10000;
  947. mode.YAspect := 10000;
  948. AddMode(mode);
  949. InitMode(mode);
  950. mode.ModeNumber:=VGALo;
  951. mode.DriverNumber := VGA;
  952. mode.ModeName:='640 x 200 VGA';
  953. mode.MaxColor := 16;
  954. mode.DirectColor := FALSE;
  955. mode.PaletteSize := mode.MaxColor;
  956. mode.MaxX := 639;
  957. mode.MaxY := 199;
  958. mode.DirectPutPixel:=DirectPutPixel16;
  959. mode.PutPixel:=PutPixel16;
  960. mode.GetPixel:=GetPixel16;
  961. mode.SetRGBPalette := SetVGARGBPalette;
  962. mode.GetRGBPalette := GetVGARGBPalette;
  963. mode.SetVisualPage := SetVisual200;
  964. mode.SetActivePage := SetActive200;
  965. mode.InitMode := Init640x200x16;
  966. mode.XAspect := 10000;
  967. mode.YAspect := 10000;
  968. AddMode(mode);
  969. InitMode(mode);
  970. mode.ModeNumber:=VGAMed;
  971. mode.DriverNumber := VGA;
  972. mode.ModeName:='640 x 350 VGA';
  973. mode.MaxColor := 16;
  974. mode.DirectColor := FALSE;
  975. mode.PaletteSize := mode.MaxColor;
  976. mode.MaxX := 639;
  977. mode.MaxY := 349;
  978. mode.DirectPutPixel:=DirectPutPixel16;
  979. mode.PutPixel:=PutPixel16;
  980. mode.GetPixel:=GetPixel16;
  981. mode.InitMode := Init640x350x16;
  982. mode.SetRGBPalette := SetVGARGBPalette;
  983. mode.GetRGBPalette := GetVGARGBPalette;
  984. mode.SetVisualPage := SetVisual350;
  985. mode.SetActivePage := SetActive350;
  986. mode.XAspect := 10000;
  987. mode.YAspect := 10000;
  988. AddMode(mode);
  989. InitMode(mode);
  990. mode.ModeNumber:=VGAHi;
  991. mode.DriverNumber := VGA;
  992. mode.ModeName:='640 x 480 VGA';
  993. mode.MaxColor := 16;
  994. mode.DirectColor := FALSE;
  995. mode.PaletteSize := mode.MaxColor;
  996. mode.MaxX := 639;
  997. mode.MaxY := 479;
  998. mode.DirectPutPixel:=DirectPutPixel16;
  999. mode.PutPixel:=PutPixel16;
  1000. mode.GetPixel:=GetPixel16;
  1001. mode.SetRGBPalette := SetVGARGBPalette;
  1002. mode.GetRGBPalette := GetVGARGBPalette;
  1003. mode.InitMode := Init640x480x16;
  1004. mode.SetVisualPage := SetVisual480;
  1005. mode.SetActivePage := SetActive480;
  1006. mode.XAspect := 10000;
  1007. mode.YAspect := 10000;
  1008. AddMode(mode);
  1009. end;
  1010. { check if VESA adapter supported... }
  1011. if getVesaInfo(VESAInfo) then
  1012. begin
  1013. { We have to set and restore the entire VESA state }
  1014. { otherwise, if we use the VGA BIOS only function }
  1015. { there might be a crash under DPMI, such as in the}
  1016. { ATI Mach64 }
  1017. SaveVideoState := SaveStateVESA;
  1018. RestoreVideoState := RestoreStateVESA;
  1019. { now check all supported modes...}
  1020. if SearchVESAModes(m320x200x32k) then
  1021. begin
  1022. InitMode(mode);
  1023. mode.ModeNumber:=m320x200x32k;
  1024. mode.DriverNumber := VESA;
  1025. mode.ModeName:='320 x 200 VESA';
  1026. mode.MaxColor := 32768;
  1027. mode.PaletteSize := mode.MaxColor;
  1028. mode.DirectColor := TRUE;
  1029. mode.MaxX := 319;
  1030. mode.MaxY := 199;
  1031. mode.DirectPutPixel:=DirectPutPixVESA32k;
  1032. mode.PutPixel:=PutPixVESA32k;
  1033. mode.GetPixel:=GetPixVESA32k;
  1034. mode.SetRGBPalette := SetVESARGBPalette;
  1035. mode.GetRGBPalette := GetVESARGBPalette;
  1036. mode.InitMode := Init320x200x32k;
  1037. { mode.SetVisualPage := SetVisual480;
  1038. mode.SetActivePage := SetActive480;}
  1039. mode.XAspect := 10000;
  1040. mode.YAspect := 10000;
  1041. AddMode(mode);
  1042. end;
  1043. if SearchVESAModes(m320x200x64k) then
  1044. begin
  1045. InitMode(mode);
  1046. mode.ModeNumber:=m320x200x64k;
  1047. mode.DriverNumber := VESA;
  1048. mode.ModeName:='320 x 200 VESA';
  1049. mode.MaxColor := 65536;
  1050. mode.PaletteSize := mode.MaxColor;
  1051. mode.DirectColor := TRUE;
  1052. mode.MaxX := 319;
  1053. mode.MaxY := 199;
  1054. mode.DirectPutPixel:=DirectPutPixVESA64k;
  1055. mode.PutPixel:=PutPixVESA64k;
  1056. mode.GetPixel:=GetPixVESA64k;
  1057. mode.SetRGBPalette := SetVESARGBPalette;
  1058. mode.GetRGBPalette := GetVESARGBPalette;
  1059. mode.InitMode := Init320x200x64k;
  1060. { mode.SetVisualPage := SetVisual480;
  1061. mode.SetActivePage := SetActive480;}
  1062. mode.XAspect := 10000;
  1063. mode.YAspect := 10000;
  1064. AddMode(mode);
  1065. end;
  1066. if SearchVESAModes(m640x400x256) then
  1067. begin
  1068. InitMode(mode);
  1069. mode.ModeNumber:=m640x400x256;
  1070. mode.DriverNumber := VESA;
  1071. mode.ModeName:='640 x 400 VESA';
  1072. mode.MaxColor := 256;
  1073. mode.PaletteSize := mode.MaxColor;
  1074. mode.DirectColor := FALSE;
  1075. mode.MaxX := 639;
  1076. mode.MaxY := 399;
  1077. mode.DirectPutPixel:=DirectPutPixVESA256;
  1078. mode.PutPixel:=PutPixVESA256;
  1079. mode.GetPixel:=GetPixVESA256;
  1080. mode.SetRGBPalette := SetVESARGBPalette;
  1081. mode.GetRGBPalette := GetVESARGBPalette;
  1082. mode.InitMode := Init640x400x256;
  1083. { mode.SetVisualPage := SetVisual480;
  1084. mode.SetActivePage := SetActive480;}
  1085. mode.XAspect := 10000;
  1086. mode.YAspect := 10000;
  1087. AddMode(mode);
  1088. end;
  1089. if SearchVESAModes(m640x480x256) then
  1090. begin
  1091. InitMode(mode);
  1092. mode.ModeNumber:=m640x480x256;
  1093. mode.DriverNumber := VESA;
  1094. mode.ModeName:='640 x 480 VESA';
  1095. mode.MaxColor := 256;
  1096. mode.PaletteSize := mode.MaxColor;
  1097. mode.MaxX := 639;
  1098. mode.MaxY := 479;
  1099. mode.DirectPutPixel:=DirectPutPixVESA256;
  1100. mode.PutPixel:=PutPixVESA256;
  1101. mode.GetPixel:=GetPixVESA256;
  1102. mode.SetRGBPalette := SetVESARGBPalette;
  1103. mode.GetRGBPalette := GetVESARGBPalette;
  1104. mode.InitMode := Init640x480x256;
  1105. { mode.SetVisualPage := SetVisual480;
  1106. mode.SetActivePage := SetActive480;}
  1107. mode.XAspect := 10000;
  1108. mode.YAspect := 10000;
  1109. AddMode(mode);
  1110. end;
  1111. if SearchVESAModes(m640x480x32k) then
  1112. begin
  1113. InitMode(mode);
  1114. mode.ModeNumber:=m640x480x32k;
  1115. mode.DriverNumber := VESA;
  1116. mode.ModeName:='640 x 400 VESA';
  1117. mode.MaxColor := 32768;
  1118. mode.PaletteSize := mode.MaxColor;
  1119. mode.DirectColor := TRUE;
  1120. mode.MaxX := 639;
  1121. mode.MaxY := 399;
  1122. mode.DirectPutPixel:=DirectPutPixVESA32k;
  1123. mode.PutPixel:=PutPixVESA32k;
  1124. mode.GetPixel:=GetPixVESA32k;
  1125. mode.SetRGBPalette := SetVESARGBPalette;
  1126. mode.GetRGBPalette := GetVESARGBPalette;
  1127. mode.InitMode := Init640x480x32k;
  1128. { mode.SetVisualPage := SetVisual480;
  1129. mode.SetActivePage := SetActive480;}
  1130. mode.XAspect := 10000;
  1131. mode.YAspect := 10000;
  1132. AddMode(mode);
  1133. end;
  1134. if SearchVESAModes(m640x480x64k) then
  1135. begin
  1136. InitMode(mode);
  1137. mode.ModeNumber:=m640x480x64k;
  1138. mode.DriverNumber := VESA;
  1139. mode.ModeName:='640 x 480 VESA';
  1140. mode.MaxColor := 65536;
  1141. mode.PaletteSize := mode.MaxColor;
  1142. mode.DirectColor := TRUE;
  1143. mode.MaxX := 639;
  1144. mode.MaxY := 479;
  1145. mode.DirectPutPixel:=DirectPutPixVESA64k;
  1146. mode.PutPixel:=PutPixVESA64k;
  1147. mode.GetPixel:=GetPixVESA64k;
  1148. mode.SetRGBPalette := SetVESARGBPalette;
  1149. mode.GetRGBPalette := GetVESARGBPalette;
  1150. mode.InitMode := Init640x480x64k;
  1151. { mode.SetVisualPage := SetVisual480;
  1152. mode.SetActivePage := SetActive480;}
  1153. mode.XAspect := 10000;
  1154. mode.YAspect := 10000;
  1155. AddMode(mode);
  1156. end;
  1157. if SearchVESAModes(m800x600x16) then
  1158. begin
  1159. InitMode(mode);
  1160. mode.ModeNumber:=m800x600x16;
  1161. mode.DriverNumber := VESA;
  1162. mode.ModeName:='800 x 600 VESA';
  1163. mode.MaxColor := 16;
  1164. mode.DirectColor := FALSE;
  1165. mode.PaletteSize := mode.MaxColor;
  1166. mode.MaxX := 799;
  1167. mode.MaxY := 599;
  1168. mode.DirectPutPixel:=DirectPutPixVESA16;
  1169. mode.SetRGBPalette := SetVESARGBPalette;
  1170. mode.GetRGBPalette := GetVESARGBPalette;
  1171. mode.PutPixel:=PutPixVESA16;
  1172. { mode.GetPixel:=GetPixVESA16;}
  1173. mode.InitMode := Init800x600x16;
  1174. { mode.SetVisualPage := SetVisual480;
  1175. mode.SetActivePage := SetActive480;}
  1176. mode.XAspect := 10000;
  1177. mode.YAspect := 10000;
  1178. AddMode(mode);
  1179. end;
  1180. if SearchVESAModes(m800x600x256) then
  1181. begin
  1182. InitMode(mode);
  1183. mode.ModeNumber:=m800x600x256;
  1184. mode.DriverNumber := VESA;
  1185. mode.ModeName:='800 x 600 VESA';
  1186. mode.MaxColor := 256;
  1187. mode.PaletteSize := mode.MaxColor;
  1188. mode.DirectColor := FALSE;
  1189. mode.MaxX := 799;
  1190. mode.MaxY := 599;
  1191. mode.DirectPutPixel:=DirectPutPixVESA256;
  1192. mode.PutPixel:=PutPixVESA256;
  1193. mode.GetPixel:=GetPixVESA256;
  1194. mode.SetRGBPalette := SetVESARGBPalette;
  1195. mode.GetRGBPalette := GetVESARGBPalette;
  1196. mode.InitMode := Init800x600x256;
  1197. { mode.SetVisualPage := SetVisual480;
  1198. mode.SetActivePage := SetActive480;}
  1199. mode.XAspect := 10000;
  1200. mode.YAspect := 10000;
  1201. AddMode(mode);
  1202. end;
  1203. if SearchVESAModes(m800x600x32k) then
  1204. begin
  1205. InitMode(mode);
  1206. mode.ModeNumber:=m800x600x32k;
  1207. mode.DriverNumber := VESA;
  1208. mode.ModeName:='800 x 600 VESA';
  1209. mode.MaxColor := 32768;
  1210. mode.PaletteSize := mode.MaxColor;
  1211. mode.DirectColor := TRUE;
  1212. mode.MaxX := 799;
  1213. mode.MaxY := 599;
  1214. mode.DirectPutPixel:=DirectPutPixVESA32k;
  1215. mode.PutPixel:=PutPixVESA32k;
  1216. mode.GetPixel:=GetPixVESA32k;
  1217. mode.SetRGBPalette := SetVESARGBPalette;
  1218. mode.GetRGBPalette := GetVESARGBPalette;
  1219. mode.InitMode := Init800x600x32k;
  1220. { mode.SetVisualPage := SetVisual480;
  1221. mode.SetActivePage := SetActive480;}
  1222. mode.XAspect := 10000;
  1223. mode.YAspect := 10000;
  1224. AddMode(mode);
  1225. end;
  1226. if SearchVESAModes(m800x600x64k) then
  1227. begin
  1228. InitMode(mode);
  1229. mode.ModeNumber:=m800x600x16;
  1230. mode.DriverNumber := VESA;
  1231. mode.ModeName:='800 x 600 VESA';
  1232. mode.MaxColor := 65536;
  1233. mode.PaletteSize := mode.MaxColor;
  1234. mode.DirectColor := TRUE;
  1235. mode.MaxX := 799;
  1236. mode.MaxY := 599;
  1237. mode.DirectPutPixel:=DirectPutPixVESA64k;
  1238. mode.PutPixel:=PutPixVESA64k;
  1239. mode.GetPixel:=GetPixVESA64k;
  1240. mode.SetRGBPalette := SetVESARGBPalette;
  1241. mode.GetRGBPalette := GetVESARGBPalette;
  1242. mode.InitMode := Init800x600x64k;
  1243. { mode.SetVisualPage := SetVisual480;
  1244. mode.SetActivePage := SetActive480;}
  1245. mode.XAspect := 10000;
  1246. mode.YAspect := 10000;
  1247. AddMode(mode);
  1248. end;
  1249. if SearchVESAModes(m1024x768x16) then
  1250. begin
  1251. InitMode(mode);
  1252. mode.ModeNumber:=m1024x768x16;
  1253. mode.DriverNumber := VESA;
  1254. mode.ModeName:='1024 x 768 VESA';
  1255. mode.MaxColor := 16;
  1256. mode.PaletteSize := mode.MaxColor;
  1257. mode.DirectColor := FALSE;
  1258. mode.MaxX := 1023;
  1259. mode.MaxY := 767;
  1260. mode.DirectPutPixel:=DirectPutPixVESA16;
  1261. mode.PutPixel:=PutPixVESA16;
  1262. mode.SetRGBPalette := SetVESARGBPalette;
  1263. mode.GetRGBPalette := GetVESARGBPalette;
  1264. { mode.GetPixel:=GetPixVESA16;}
  1265. mode.InitMode := Init1024x768x16;
  1266. { mode.SetVisualPage := SetVisual480;
  1267. mode.SetActivePage := SetActive480;}
  1268. mode.XAspect := 10000;
  1269. mode.YAspect := 10000;
  1270. AddMode(mode);
  1271. end;
  1272. if SearchVESAModes(m1024x768x256) then
  1273. begin
  1274. InitMode(mode);
  1275. mode.ModeNumber:=m1024x768x256;
  1276. mode.DriverNumber := VESA;
  1277. mode.ModeName:='1024 x 768 VESA';
  1278. mode.MaxColor := 256;
  1279. mode.PaletteSize := mode.MaxColor;
  1280. mode.DirectColor := FALSE;
  1281. mode.MaxX := 1023;
  1282. mode.MaxY := 767;
  1283. mode.DirectPutPixel:=DirectPutPixVESA256;
  1284. mode.PutPixel:=PutPixVESA256;
  1285. mode.GetPixel:=GetPixVESA256;
  1286. mode.SetRGBPalette := SetVESARGBPalette;
  1287. mode.GetRGBPalette := GetVESARGBPalette;
  1288. mode.InitMode := Init1024x768x256;
  1289. { mode.SetVisualPage := SetVisual480;
  1290. mode.SetActivePage := SetActive480;}
  1291. mode.XAspect := 10000;
  1292. mode.YAspect := 10000;
  1293. AddMode(mode);
  1294. end;
  1295. if SearchVESAModes(m1024x768x32k) then
  1296. begin
  1297. InitMode(mode);
  1298. mode.ModeNumber:=m1024x768x32k;
  1299. mode.DriverNumber := VESA;
  1300. mode.ModeName:='1024 x 768 VESA';
  1301. mode.MaxColor := 32768;
  1302. mode.PaletteSize := mode.MaxColor;
  1303. mode.DirectColor := TRUE;
  1304. mode.MaxX := 1023;
  1305. mode.MaxY := 767;
  1306. mode.DirectPutPixel:=DirectPutPixVESA32k;
  1307. mode.PutPixel:=PutPixVESA32k;
  1308. mode.GetPixel:=GetPixVESA32k;
  1309. mode.SetRGBPalette := SetVESARGBPalette;
  1310. mode.GetRGBPalette := GetVESARGBPalette;
  1311. mode.InitMode := Init640x480x32k;
  1312. { mode.SetVisualPage := SetVisual480;
  1313. mode.SetActivePage := SetActive480;}
  1314. mode.XAspect := 10000;
  1315. mode.YAspect := 10000;
  1316. AddMode(mode);
  1317. end;
  1318. if SearchVESAModes(m1024x768x64k) then
  1319. begin
  1320. InitMode(mode);
  1321. mode.ModeNumber:=m1024x768x64k;
  1322. mode.DriverNumber := VESA;
  1323. mode.ModeName:='1024 x 768 VESA';
  1324. mode.MaxColor := 65536;
  1325. mode.DirectColor := TRUE;
  1326. mode.PaletteSize := mode.MaxColor;
  1327. mode.MaxX := 1023;
  1328. mode.MaxY := 767;
  1329. mode.DirectPutPixel:=DirectPutPixVESA64k;
  1330. mode.PutPixel:=PutPixVESA64k;
  1331. mode.GetPixel:=GetPixVESA64k;
  1332. mode.SetRGBPalette := SetVESARGBPalette;
  1333. mode.GetRGBPalette := GetVESARGBPalette;
  1334. mode.InitMode := Init1024x768x64k;
  1335. { mode.SetVisualPage := SetVisual480;
  1336. mode.SetActivePage := SetActive480;}
  1337. mode.XAspect := 10000;
  1338. mode.YAspect := 10000;
  1339. AddMode(mode);
  1340. end;
  1341. if SearchVESAModes(m1280x1024x16) then
  1342. begin
  1343. InitMode(mode);
  1344. mode.ModeNumber:=m1280x1024x16;
  1345. mode.DriverNumber := VESA;
  1346. mode.ModeName:='1280 x 1024 VESA';
  1347. mode.MaxColor := 16;
  1348. mode.DirectColor := FALSE;
  1349. mode.PaletteSize := mode.MaxColor;
  1350. mode.MaxX := 1279;
  1351. mode.MaxY := 1023;
  1352. mode.DirectPutPixel:=DirectPutPixVESA16;
  1353. mode.SetRGBPalette := SetVESARGBPalette;
  1354. mode.GetRGBPalette := GetVESARGBPalette;
  1355. mode.PutPixel:=PutPixVESA16;
  1356. { mode.GetPixel:=GetPixVESA16;}
  1357. mode.InitMode := Init1280x1024x16;
  1358. { mode.SetVisualPage := SetVisual480;
  1359. mode.SetActivePage := SetActive480;}
  1360. mode.XAspect := 10000;
  1361. mode.YAspect := 10000;
  1362. AddMode(mode);
  1363. end;
  1364. if SearchVESAModes(m1280x1024x256) then
  1365. begin
  1366. InitMode(mode);
  1367. mode.ModeNumber:=m1280x1024x256;
  1368. mode.DriverNumber := VESA;
  1369. mode.ModeName:='1280 x 1024 VESA';
  1370. mode.MaxColor := 256;
  1371. mode.DirectColor := FALSE;
  1372. mode.PaletteSize := mode.MaxColor;
  1373. mode.MaxX := 1279;
  1374. mode.MaxY := 1023;
  1375. mode.DirectPutPixel:=DirectPutPixVESA256;
  1376. mode.PutPixel:=PutPixVESA256;
  1377. mode.GetPixel:=GetPixVESA256;
  1378. mode.InitMode := Init1280x1024x256;
  1379. mode.SetRGBPalette := SetVESARGBPalette;
  1380. mode.GetRGBPalette := GetVESARGBPalette;
  1381. { mode.SetVisualPage := SetVisual480;
  1382. mode.SetActivePage := SetActive480;}
  1383. mode.XAspect := 10000;
  1384. mode.YAspect := 10000;
  1385. AddMode(mode);
  1386. end;
  1387. if SearchVESAModes(m1280x1024x32k) then
  1388. begin
  1389. InitMode(mode);
  1390. mode.ModeNumber:=m1280x1024x32k;
  1391. mode.DriverNumber := VESA;
  1392. mode.ModeName:='1280 x 1024 VESA';
  1393. mode.MaxColor := 32768;
  1394. mode.DirectColor := TRUE;
  1395. mode.PaletteSize := mode.MaxColor;
  1396. mode.MaxX := 1279;
  1397. mode.MaxY := 1023;
  1398. mode.DirectPutPixel:=DirectPutPixVESA32k;
  1399. mode.PutPixel:=PutPixVESA32k;
  1400. mode.GetPixel:=GetPixVESA32k;
  1401. mode.InitMode := Init1280x1024x32k;
  1402. mode.SetRGBPalette := SetVESARGBPalette;
  1403. mode.GetRGBPalette := GetVESARGBPalette;
  1404. { mode.SetVisualPage := SetVisual480;
  1405. mode.SetActivePage := SetActive480;}
  1406. mode.XAspect := 10000;
  1407. mode.YAspect := 10000;
  1408. AddMode(mode);
  1409. end;
  1410. if SearchVESAModes(m1280x1024x64k) then
  1411. begin
  1412. InitMode(mode);
  1413. mode.ModeNumber:=m1280x1024x64k;
  1414. mode.DriverNumber := VESA;
  1415. mode.ModeName:='1280 x 1024 VESA';
  1416. mode.MaxColor := 65536;
  1417. mode.DirectColor := TRUE;
  1418. mode.PaletteSize := mode.MaxColor;
  1419. mode.MaxX := 1279;
  1420. mode.MaxY := 1023;
  1421. mode.DirectPutPixel:=DirectPutPixVESA64k;
  1422. mode.PutPixel:=PutPixVESA64k;
  1423. mode.GetPixel:=GetPixVESA64k;
  1424. mode.InitMode := Init1280x1024x64k;
  1425. mode.SetRGBPalette := SetVESARGBPalette;
  1426. mode.GetRGBPalette := GetVESARGBPalette;
  1427. { mode.SetVisualPage := SetVisual480;
  1428. mode.SetActivePage := SetActive480;}
  1429. mode.XAspect := 10000;
  1430. mode.YAspect := 10000;
  1431. AddMode(mode);
  1432. end;
  1433. end;
  1434. end;