graph.inc 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555
  1. {
  2. $Id$
  3. }
  4. { How this works: }
  5. { QueryAdapter - Va chercher tout les modes videos et drivers }
  6. { disponibles sur cette carte, et les mets dans une linked list }
  7. { en ordre de driver number, et a l'interieur de cela, dans un }
  8. { ordre croissant de mode number. }
  9. { DetectGraph - Verifie si la liste chainee de drivers existe, sinon }
  10. { apelle QueryAdapter }
  11. { InitGraph - Appelle DetectGraph, et verifie que le mode demande existe}
  12. { bel et bien et est disponible sur ce PC }
  13. {$ifndef fpc}
  14. {$ifndef noasmgraph}
  15. {$define asmgraph}
  16. {$endif noasmgraph}
  17. {$i dpmi.inc}
  18. {$else fpc}
  19. {$asmmode intel}
  20. {$endif fpc}
  21. { How to access real mode memory }
  22. { using 32-bit DPMI memory }
  23. { 1. Allocate a descriptor }
  24. { 2. Set segment limit }
  25. { 3. Set base linear address }
  26. const
  27. InternalDriverName = 'DOSGX';
  28. {$ifdef fpc}
  29. {$ifdef asmgraph}
  30. VideoOfs : DWord = 0; { Segment to draw to }
  31. {$else asmgraph}
  32. VideoOfs : word = 0; { Segment to draw to }
  33. {$endif asmgraph}
  34. {$else fpc}
  35. VideoOfs : word = 0; { Segment to draw to }
  36. {$endif fpc}
  37. FirstPlane = $0102; (* 02 = Index to Color plane Select, *)
  38. (* 01 = Enable color plane 1 *)
  39. { ; ===== VGA Register Values ===== }
  40. SCREEN_WIDTH = 80 ; { MODE-X 320 SCREEN WIDTH }
  41. { CHANGE THE VALUE IF OTHER MODES }
  42. { OTHER THEN 320 ARE USED. }
  43. ATTRIB_Ctrl = $03C0 ; { VGA Attribute Controller }
  44. GC_Index = $03CE ; { VGA Graphics Controller }
  45. SC_Index = $03C4 ; { VGA Sequencer Controller }
  46. SC_Data = $03C5 ; { VGA Sequencer Data Port }
  47. CRTC_Index = $03D4 ; { VGA CRT Controller }
  48. CRTC_Data = $03D5 ; { VGA CRT Controller Data }
  49. MISC_OUTPUT = $03C2 ; { VGA Misc Register }
  50. INPUT_1 = $03DA ; { Input Status #1 Register }
  51. DAC_WRITE_ADDR = $03C8 ; { VGA DAC Write Addr Register }
  52. DAC_READ_ADDR = $03C7 ; { VGA DAC Read Addr Register }
  53. PEL_DATA_REG = $03C9 ; { VGA DAC/PEL data Register R/W }
  54. PIXEL_PAN_REG = $033 ; { Attrib Index: Pixel Pan Reg }
  55. MAP_MASK = $002 ; { S= $Index: Write Map Mask reg }
  56. READ_MAP = $004 ; { GC Index: Read Map Register }
  57. START_DISP_HI = $00C ; { CRTC Index: Display Start Hi }
  58. START_DISP_LO = $00D ; { CRTC Index: Display Start Lo }
  59. MAP_MASK_PLANE1 = $00102 ; { Map Register + Plane 1 }
  60. MAP_MASK_PLANE2 = $01102 ; { Map Register + Plane 1 }
  61. ALL_PLANES_ON = $00F02 ; { Map Register + All Bit Planes }
  62. CHAIN4_OFF = $00604 ; { Chain 4 mode Off }
  63. ASYNC_RESET = $00100 ; { (A)synchronous Reset }
  64. SEQU_RESTART = $00300 ; { Sequencer Restart }
  65. LATCHES_ON = $00008 ; { Bit Mask + Data from Latches }
  66. LATCHES_OFF = $0FF08 ; { Bit Mask + Data from CPU }
  67. VERT_RETRACE = $08 ; { INPUT_1: Vertical Retrace Bit }
  68. PLANE_BITS = $03 ; { Bits 0-1 of Xpos = Plane # }
  69. ALL_PLANES = $0F ; { All Bit Planes Selected }
  70. CHAR_BITS = $0F ; { Bits 0-3 of Character Data }
  71. GET_CHAR_PTR = $01130 ; { VGA BIOS Func: Get Char Set }
  72. ROM_8x8_Lo = $03 ; { ROM 8x8 Char Set Lo Pointer }
  73. ROM_8x8_Hi = $04 ; { ROM 8x8 Char Set Hi Pointer }
  74. { Constants Specific for these routines }
  75. NUM_MODES = $8 ; { # of Mode X Variations }
  76. var
  77. ScrWidth : word absolute $40:$4a;
  78. {$ifndef tp}
  79. procedure seg_bytemove(sseg : word;source : longint;dseg : word;dest : longint;count : longint);
  80. begin
  81. asm
  82. push es
  83. push ds
  84. cld
  85. mov ecx,count
  86. mov esi,source
  87. mov edi,dest
  88. mov ax,dseg
  89. mov es,ax
  90. mov ax,sseg
  91. mov ds,ax
  92. rep movsb
  93. pop ds
  94. pop es
  95. end ['ESI','EDI','ECX','EAX']
  96. end;
  97. {$endif tp}
  98. {************************************************************************}
  99. {* 4-bit planar VGA mode routines *}
  100. {************************************************************************}
  101. Procedure Init640x200x16; {$ifndef fpc}far;{$endif fpc} assembler;
  102. { must also clear the screen...}
  103. asm
  104. mov ax,000Eh
  105. {$ifdef fpc}
  106. push ebp
  107. {$endif fpc}
  108. int 10h
  109. {$ifdef fpc}
  110. pop ebp
  111. {$endif fpc}
  112. end;
  113. Procedure Init640x350x16; {$ifndef fpc}far;{$endif fpc} assembler;
  114. { must also clear the screen...}
  115. asm
  116. mov ax,0010h
  117. {$ifdef fpc}
  118. push ebp
  119. {$endif fpc}
  120. int 10h
  121. {$ifdef fpc}
  122. pop ebp
  123. {$endif fpc}
  124. end;
  125. procedure Init640x480x16; {$ifndef fpc}far;{$endif fpc} assembler;
  126. { must also clear the screen...}
  127. asm
  128. mov ax,0012h
  129. {$ifdef fpc}
  130. push ebp
  131. {$endif fpc}
  132. int 10h
  133. {$ifdef fpc}
  134. pop ebp
  135. {$endif fpc}
  136. end;
  137. Procedure PutPixel16(X,Y : Integer; Pixel: Word); {$ifndef fpc}far;{$endif fpc}
  138. {$ifndef asmgraph}
  139. var offset: word;
  140. dummy: byte;
  141. {$endif asmgraph}
  142. Begin
  143. X:= X + StartXViewPort;
  144. Y:= Y + StartYViewPort;
  145. { convert to absolute coordinates and then verify clipping...}
  146. if ClipPixels then
  147. Begin
  148. if (X < StartXViewPort) or (X > (StartXViewPort + ViewWidth)) then
  149. exit;
  150. if (Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)) then
  151. exit;
  152. end;
  153. {$ifndef asmgraph}
  154. offset := y * 80 + (x shr 3) + VideoOfs;
  155. PortW[$3ce] := $f01;
  156. PortW[$3ce] := Pixel shl 8;
  157. PortB[$3ce] := 8;
  158. PortW[$3cf] := $80 shr (x and $7) + (Pixel shl 8);
  159. dummy := Mem[$a000: offset];
  160. Mem[$a000: offset] := dummy;
  161. PortW[$3ce] := $ff08;
  162. PortB[$3ce] := 1;
  163. {$else asmgraph}
  164. asm
  165. {$ifndef fpc}
  166. mov es, [SegA000]
  167. {$endif fpc}
  168. { enable the set / reset function and load the color }
  169. mov dx, 3ceh
  170. mov ax, 0f01h
  171. out dx, ax
  172. { setup set/reset register }
  173. mov ax, [Pixel]
  174. shl ax, 8
  175. out dx, ax
  176. { setup the bit mask register }
  177. mov al, 8
  178. out dx, al
  179. inc dx
  180. { load the bitmask register }
  181. mov cx, [X]
  182. and cx, 0007h
  183. mov al, 80h
  184. shr al, cl
  185. out dx, ax
  186. {$ifndef fpc}
  187. { get the x index and divide by 8 for 16-color }
  188. mov ax,[X]
  189. shr ax,3
  190. push ax
  191. { determine the address }
  192. mov ax,80
  193. mov bx,[Y]
  194. mul bx
  195. pop cx
  196. add ax,cx
  197. mov di,ax
  198. add di, [VideoOfs]
  199. { send the data through the display memory through set/reset }
  200. mov bl,es:[di]
  201. mov es:[di],bl
  202. { reset for formal vga operation }
  203. mov dx,3ceh
  204. mov ax,0ff08h
  205. out dx,ax
  206. { restore enable set/reset register }
  207. mov ax,0001h
  208. out dx,ax
  209. {$else fpc}
  210. { get the x index and divide by 8 for 16-color }
  211. movzx eax,[X]
  212. shr eax,3
  213. push eax
  214. { determine the address }
  215. mov eax,80
  216. mov bx,[Y]
  217. mul bx
  218. pop ecx
  219. add eax,ecx
  220. mov edi,eax
  221. add edi, [VideoOfs]
  222. { send the data through the display memory through set/reset }
  223. mov bl,fs:[edi+$a0000]
  224. mov fs:[edi+$a0000],bl
  225. { reset for formal vga operation }
  226. mov dx,3ceh
  227. mov ax,0ff08h
  228. out dx,ax
  229. { restore enable set/reset register }
  230. mov ax,0001h
  231. out dx,ax
  232. {$endif fpc}
  233. end;
  234. {$endif asmgraph}
  235. end;
  236. Function GetPixel16(X,Y: Integer):word; {$ifndef fpc}far;{$endif fpc}
  237. {$ifndef asmgraph}
  238. Var dummy, offset: Word;
  239. shift: byte;
  240. {$endif asmgraph}
  241. Begin
  242. X:= X + StartXViewPort;
  243. Y:= Y + StartYViewPort;
  244. {$ifndef asmgraph}
  245. offset := Y * 80 + (x shr 3) + VideoOfs;
  246. PortB[$3ce] := 4;
  247. shift := 7 - (X and 7);
  248. PortB[$3cf] := 0;
  249. dummy := (Mem[$a000:offset] shr shift) and 1;
  250. PortB[$3cf] := 1;
  251. dummy := dummy or (((Mem[$a000:offset] shr shift) and 1) shl 1);
  252. PortB[$3cf] := 2;
  253. dummy := dummy or (((Mem[$a000:offset] shr shift) and 1) shl 2);
  254. PortB[$3cf] := 3;
  255. dummy := dummy or (((Mem[$a000:offset] shr shift) and 1) shl 3);
  256. GetPixel16 := dummy;
  257. {$else asmgraph}
  258. asm
  259. {$ifndef fpc}
  260. mov ax, [X] { Get X address }
  261. push ax
  262. shr ax, 3
  263. push ax
  264. mov ax,80
  265. mov bx,[Y]
  266. mul bx
  267. pop cx
  268. add ax,cx
  269. mov si,ax { SI = correct offset into video segment }
  270. mov es,[SegA000]
  271. add si,[VideoOfs] { Point to correct page offset... }
  272. mov dx,03ceh
  273. mov ax,4
  274. out dx,al
  275. inc dx
  276. pop ax
  277. and ax,0007h
  278. mov cl,07
  279. sub cl,al
  280. mov bl,cl
  281. { read plane 0 }
  282. mov al,0 { Select plane to read }
  283. out dx,al
  284. mov al,es:[si] { read display memory }
  285. shr al,cl
  286. and al,01h
  287. mov ah,al { save bit in AH }
  288. { read plane 1 }
  289. mov al,1 { Select plane to read }
  290. out dx,al
  291. mov al,es:[si]
  292. shr al,cl
  293. and al,01h
  294. shl al,1
  295. or ah,al { save bit in AH }
  296. { read plane 2 }
  297. mov al,2 { Select plane to read }
  298. out dx,al
  299. mov al,es:[si]
  300. shr al,cl
  301. and al,01h
  302. shl al,2
  303. or ah,al { save bit in AH }
  304. { read plane 3 }
  305. mov al,3 { Select plane to read }
  306. out dx,al
  307. mov al,es:[si]
  308. shr al,cl
  309. and al,01h
  310. shl al,3
  311. or ah,al { save bit in AH }
  312. mov al,ah { 16-bit pixel in AX }
  313. xor ah,ah
  314. mov @Result, ax
  315. {$else fpc}
  316. movzx eax, [X] { Get X address }
  317. push eax
  318. shr eax, 3
  319. push eax
  320. mov eax,80
  321. mov bx,[Y]
  322. mul bx
  323. pop ecx
  324. add eax,ecx
  325. mov esi,eax { SI = correct offset into video segment }
  326. add esi,[VideoOfs] { Point to correct page offset... }
  327. mov dx,03ceh
  328. mov ax,4
  329. out dx,al
  330. inc dx
  331. pop eax
  332. and eax,0007h
  333. mov cl,07
  334. sub cl,al
  335. mov bl,cl
  336. { read plane 0 }
  337. mov al,0 { Select plane to read }
  338. out dx,al
  339. mov al,fs:[esi+$a0000] { read display memory }
  340. shr al,cl
  341. and al,01h
  342. mov ah,al { save bit in AH }
  343. { read plane 1 }
  344. mov al,1 { Select plane to read }
  345. out dx,al
  346. mov al,fs:[esi+$a0000]
  347. shr al,cl
  348. and al,01h
  349. shl al,1
  350. or ah,al { save bit in AH }
  351. { read plane 2 }
  352. mov al,2 { Select plane to read }
  353. out dx,al
  354. mov al,fs:[esi+$a0000]
  355. shr al,cl
  356. and al,01h
  357. shl al,2
  358. or ah,al { save bit in AH }
  359. { read plane 3 }
  360. mov al,3 { Select plane to read }
  361. out dx,al
  362. mov al,fs:[esi+$a0000]
  363. shr al,cl
  364. and al,01h
  365. shl al,3
  366. or ah,al { save bit in AH }
  367. mov al,ah { 16-bit pixel in AX }
  368. xor ah,ah
  369. mov @Result, ax
  370. {$endif fpc}
  371. end;
  372. {$endif asmgraph}
  373. end;
  374. Procedure GetScanLine16(y: integer; var data);
  375. var dummylong: longint;
  376. Offset, count, count2, amount, index: word;
  377. plane: byte;
  378. Begin
  379. {$ifdef logging}
  380. LogLn('GetScanLine16 start, length to get: '+strf(ViewWidth+1)+' at y = '+strf(y));
  381. {$Endif logging}
  382. PortB[$3ce] := 4;
  383. offset := (Y + StartYViewPort) * 80 + (StartXViewPort shr 3) + VideoOfs;
  384. {$ifdef logging}
  385. LogLn('Offset: '+HexStr(offset,4)+' - ' + strf(offset));
  386. {$Endif logging}
  387. { first get enough pixels so offset is 32bit aligned }
  388. amount := 0;
  389. index := 0;
  390. If ((StartXViewPort and 31) <> 0) Or
  391. (ViewWidth < 32) Then
  392. Begin
  393. If (ViewWidth >= 32+32-(StartXViewPort and 31)) Then
  394. amount := 32-(StartXViewPort and 31)
  395. Else amount := ViewWidth + 1;
  396. {$ifdef logging}
  397. LogLn('amount to align to 32bits or to get all: ' + strf(amount));
  398. {$Endif logging}
  399. For count := 0 to amount-1 do
  400. WordArray(Data)[Count] := getpixel16(Count,y);
  401. index := count+1;
  402. Inc(Offset,(amount+7) shr 3);
  403. {$ifdef logging}
  404. LogLn('offset now: '+HexStr(offset,4)+' - ' + strf(offset));
  405. LogLn('index now: '+strf(index));
  406. {$Endif logging}
  407. End;
  408. amount := ViewWidth + 1 - amount;
  409. {$ifdef logging}
  410. LogLn('amount left: ' + strf(amount));
  411. {$Endif logging}
  412. If amount = 0 Then Exit;
  413. { first get everything from plane 3 (4th plane) }
  414. PortB[$3cf] := 3;
  415. Count := 0;
  416. For Count := 1 to (amount shr 5) Do
  417. Begin
  418. dummylong := MemL[$a000:offset+(Count-1)*4];
  419. dummylong :=
  420. ((dummylong and $ff) shl 24) or
  421. ((dummylong and $ff00) shl 8) or
  422. ((dummylong and $ff0000) shr 8) or
  423. ((dummylong and $ff000000) shr 24);
  424. For Count2 := 31 downto 0 Do
  425. Begin
  426. WordArray(Data)[index+Count2] := DummyLong and 1;
  427. DummyLong := DummyLong shr 1;
  428. End;
  429. Inc(Index, 32);
  430. End;
  431. { Now get the data from the 3 other planes }
  432. plane := 3;
  433. Repeat
  434. Dec(Index,Count*32);
  435. Dec(plane);
  436. PortB[$3cf] := plane;
  437. Count := 0;
  438. For Count := 1 to (amount shr 5) Do
  439. Begin
  440. dummylong := MemL[$a000:offset+(Count-1)*4];
  441. dummylong :=
  442. ((dummylong and $ff) shl 24) or
  443. ((dummylong and $ff00) shl 8) or
  444. ((dummylong and $ff0000) shr 8) or
  445. ((dummylong and $ff000000) shr 24);
  446. For Count2 := 31 downto 0 Do
  447. Begin
  448. WordArray(Data)[index+Count2] :=
  449. (WordArray(Data)[index+Count2] shl 1) + (DummyLong and 1);
  450. DummyLong := DummyLong shr 1;
  451. End;
  452. Inc(Index, 32);
  453. End;
  454. Until plane = 0;
  455. amount := amount and 31;
  456. Dec(index);
  457. {$ifdef Logging}
  458. LogLn('Last array index written to: '+strf(index));
  459. LogLn('amount left: '+strf(amount)+' starting at x = '+strf(index+1));
  460. {$Endif logging}
  461. For Count := 1 to amount Do
  462. WordArray(Data)[index+Count] := getpixel16(index+Count,y);
  463. {$ifdef logging}
  464. LogLn('First 32 bytes gotten with getscanline16: ');
  465. If ViewWidth + 1 >= 32 Then
  466. Count2 := 32
  467. Else Count2 := ViewWidth;
  468. For Count := 0 to Count2-1 Do
  469. Log(strf(WordArray(Data)[Count])+' ');
  470. LogLn('');
  471. If ViewWidth + 1 >= 32 Then
  472. Begin
  473. LogLn('Last 32 bytes gotten with getscanline16: ');
  474. For Count := 31 downto 0 Do
  475. Log(strf(WordArray(Data)[ViewWidth-Count])+' ');
  476. End;
  477. LogLn('');
  478. GetScanLineDefault(y,Data);
  479. LogLn('First 32 bytes gotten with getscanlinedef: ');
  480. If ViewWidth + 1 >= 32 Then
  481. Count2 := 32
  482. Else Count2 := ViewWidth;
  483. For Count := 0 to Count2-1 Do
  484. Log(strf(WordArray(Data)[Count])+' ');
  485. LogLn('');
  486. If ViewWidth + 1 >= 32 Then
  487. Begin
  488. LogLn('Last 32 bytes gotten with getscanlinedef: ');
  489. For Count := 31 downto 0 Do
  490. Log(strf(WordArray(Data)[ViewWidth-Count])+' ');
  491. End;
  492. LogLn('');
  493. LogLn('GetScanLine16 end');
  494. {$Endif logging}
  495. End;
  496. Procedure DirectPutPixel16(X,Y : Integer); {$ifndef fpc}far;{$endif fpc}
  497. { x,y -> must be in global coordinates. No clipping. }
  498. var
  499. color: word;
  500. {$ifndef asmgraph}
  501. offset: word;
  502. dummy: byte;
  503. {$endif asmgraph}
  504. begin
  505. case CurrentWriteMode of
  506. XORPut:
  507. begin
  508. { getpixel wants local/relative coordinates }
  509. Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
  510. Color := CurrentColor Xor Color;
  511. end;
  512. OrPut:
  513. begin
  514. { getpixel wants local/relative coordinates }
  515. Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
  516. Color := CurrentColor Or Color;
  517. end;
  518. AndPut:
  519. begin
  520. { getpixel wants local/relative coordinates }
  521. Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
  522. Color := CurrentColor And Color;
  523. end;
  524. NotPut:
  525. begin
  526. Color := Not Color;
  527. end
  528. else
  529. Color := CurrentColor;
  530. end;
  531. {$ifndef asmgraph}
  532. offset := Y * 80 + (X shr 3) + VideoOfs;
  533. PortW[$3ce] := $f01;
  534. PortW[$3ce] := Color shl 8;
  535. PortB[$3ce] := 8;
  536. PortW[$3cf] := $80 shr (X and 7) + (Color shl 8);
  537. dummy := Mem[$a000: offset];
  538. Mem[$a000: offset] := dummy;
  539. PortW[$3ce] := $ff08;
  540. PortB[$3ce] := 1;
  541. {$else asmgraph}
  542. asm
  543. {$ifndef fpc}
  544. mov es, [SegA000]
  545. { enable the set / reset function and load the color }
  546. mov dx, 3ceh
  547. mov ax, 0f01h
  548. out dx, ax
  549. { setup set/reset register }
  550. mov ax, [Color]
  551. shl ax, 8
  552. out dx, ax
  553. { setup the bit mask register }
  554. mov al, 8
  555. out dx, al
  556. inc dx
  557. { load the bitmask register }
  558. mov cx, [X]
  559. and cx, 0007h
  560. mov al, 80h
  561. shr al, cl
  562. out dx, ax
  563. { get the x index and divide by 8 for 16-color }
  564. mov ax,[X]
  565. shr ax,3
  566. push ax
  567. { determine the address }
  568. mov ax,80
  569. mov bx,[Y]
  570. mul bx
  571. pop cx
  572. add ax,cx
  573. mov di,ax
  574. { send the data through the display memory through set/reset }
  575. add di,[VideoOfs] { add correct page }
  576. mov bl,es:[di]
  577. mov es:[di],bl
  578. { reset for formal vga operation }
  579. mov dx,3ceh
  580. mov ax,0ff08h
  581. out dx,ax
  582. { restore enable set/reset register }
  583. mov ax,0001h
  584. out dx,ax
  585. {$else fpc}
  586. { enable the set / reset function and load the color }
  587. mov dx, 3ceh
  588. mov ax, 0f01h
  589. out dx, ax
  590. { setup set/reset register }
  591. mov ax, [Color]
  592. shl ax, 8
  593. out dx, ax
  594. { setup the bit mask register }
  595. mov al, 8
  596. out dx, al
  597. inc dx
  598. { load the bitmask register }
  599. mov cx, [X]
  600. and cx, 0007h
  601. mov al, 80h
  602. shr al, cl
  603. out dx, ax
  604. { get the x index and divide by 8 for 16-color }
  605. movzx eax,[X]
  606. shr eax,3
  607. push eax
  608. { determine the address }
  609. mov eax,80
  610. mov bx,[Y]
  611. mul bx
  612. pop ecx
  613. add eax,ecx
  614. mov edi,eax
  615. { send the data through the display memory through set/reset }
  616. add edi,[VideoOfs] { add correct page }
  617. mov bl,fs:[edi+$a0000]
  618. mov fs:[edi+$a0000],bl
  619. { reset for formal vga operation }
  620. mov dx,3ceh
  621. mov ax,0ff08h
  622. out dx,ax
  623. { restore enable set/reset register }
  624. mov ax,0001h
  625. out dx,ax
  626. {$endif fpc}
  627. end;
  628. {$endif asmgraph}
  629. end;
  630. {$ifndef tp}
  631. procedure HLine16(x,x2,y: integer); {$ifndef fpc}far;{$endif fpc}
  632. var
  633. xtmp: integer;
  634. ScrOfs,HLength : word;
  635. LMask,RMask : byte;
  636. Begin
  637. { must we swap the values? }
  638. if x > x2 then
  639. Begin
  640. xtmp := x2;
  641. x2 := x;
  642. x:= xtmp;
  643. end;
  644. { First convert to global coordinates }
  645. X := X + StartXViewPort;
  646. X2 := X2 + StartXViewPort;
  647. Y := Y + StartYViewPort;
  648. if ClipPixels then
  649. Begin
  650. if LineClipped(x,y,x2,y,StartXViewPort,StartYViewPort,
  651. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  652. exit;
  653. end;
  654. ScrOfs:=y*ScrWidth+x div 8;
  655. HLength:=x2 div 8-x div 8;
  656. LMask:=$ff shr (x and 7);
  657. {$ifopt r+}
  658. {$define rangeOn}
  659. {$r-}
  660. {$endif}
  661. {$ifopt q+}
  662. {$define overflowOn}
  663. {$q-}
  664. {$endif}
  665. RMask:=$ff shl (7-(x2 and 7));
  666. {$ifdef rangeOn}
  667. {$undef rangeOn}
  668. {$r+}
  669. {$endif}
  670. {$ifdef overflowOn}
  671. {$undef overflowOn}
  672. {$q+}
  673. {$endif}
  674. if HLength=0 then
  675. LMask:=LMask and RMask;
  676. port[$3ce]:=0;
  677. If CurrentWriteMode <> NotPut Then
  678. port[$3cf]:= CurrentColor
  679. else port[$3cf]:= not CurrentColor;
  680. port[$3ce]:=1;
  681. port[$3cf]:=$f;
  682. port[$3ce]:=3;
  683. case CurrentWriteMode of
  684. XORPut:
  685. port[$3cf]:=3 shl 3;
  686. ANDPut:
  687. port[$3cf]:=1 shl 3;
  688. ORPut:
  689. port[$3cf]:=2 shl 3;
  690. NormalPut, NotPut:
  691. port[$3cf]:=0
  692. else
  693. port[$3cf]:=0
  694. end;
  695. port[$3ce]:=8;
  696. port[$3cf]:=LMask;
  697. {$ifopt r+}
  698. {$define rangeOn}
  699. {$r-}
  700. {$endif}
  701. {$ifopt q+}
  702. {$define overflowOn}
  703. {$q-}
  704. {$endif}
  705. Mem[$a000:ScrOfs]:=Mem[$a000:ScrOfs]+1;
  706. {$ifdef rangeOn}
  707. {$undef rangeOn}
  708. {$r+}
  709. {$endif}
  710. {$ifdef overflowOn}
  711. {$undef overflowOn}
  712. {$q+}
  713. {$endif}
  714. port[$3ce]:=8;
  715. if HLength>0 then
  716. begin
  717. dec(HLength);
  718. inc(ScrOfs);
  719. if HLength>0 then
  720. begin
  721. port[$3cf]:=$ff;
  722. seg_bytemove(dosmemselector,$a0000+ScrOfs,dosmemselector,$a0000+ScrOfs,HLength);
  723. ScrOfs:=ScrOfs+HLength;
  724. end;
  725. port[$3cf]:=RMask;
  726. {$ifopt r+}
  727. {$define rangeOn}
  728. {$r-}
  729. {$endif}
  730. {$ifopt q+}
  731. {$define overflowOn}
  732. {$q-}
  733. {$endif}
  734. Mem[$a000:ScrOfs]:=Mem[$a000:ScrOfs]+1;
  735. {$ifdef rangeOn}
  736. {$undef rangeOn}
  737. {$r+}
  738. {$endif}
  739. {$ifdef overflowOn}
  740. {$undef overflowOn}
  741. {$q+}
  742. {$endif}
  743. end;
  744. // clean up
  745. port[$3cf]:=0;
  746. port[$3ce]:=8;
  747. port[$3cf]:=$ff;
  748. port[$3ce]:=1;
  749. port[$3cf]:=0;
  750. port[$3ce]:=3;
  751. port[$3cf]:=0;
  752. end;
  753. procedure VLine16(x,y,y2: integer); {$ifndef fpc}far;{$endif fpc}
  754. var
  755. ytmp: integer;
  756. ScrOfs,i : longint;
  757. BitMask : byte;
  758. Begin
  759. { must we swap the values? }
  760. if y > y2 then
  761. Begin
  762. ytmp := y2;
  763. y2 := y;
  764. y:= ytmp;
  765. end;
  766. { First convert to global coordinates }
  767. X := X + StartXViewPort;
  768. Y2 := Y2 + StartYViewPort;
  769. Y := Y + StartYViewPort;
  770. if ClipPixels then
  771. Begin
  772. if LineClipped(x,y,x,y2,StartXViewPort,StartYViewPort,
  773. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  774. exit;
  775. end;
  776. ScrOfs:=y*ScrWidth+x div 8;
  777. BitMask:=$80 shr (x and 7);
  778. port[$3ce]:=0;
  779. If CurrentWriteMode <> NotPut Then
  780. port[$3cf]:= CurrentColor
  781. else port[$3cf]:= not CurrentColor;
  782. port[$3ce]:=1;
  783. port[$3cf]:=$f;
  784. port[$3ce]:=8;
  785. port[$3cf]:=BitMask;
  786. port[$3ce]:=3;
  787. case CurrentWriteMode of
  788. XORPut:
  789. port[$3cf]:=3 shl 3;
  790. ANDPut:
  791. port[$3cf]:=1 shl 3;
  792. ORPut:
  793. port[$3cf]:=2 shl 3;
  794. NormalPut, NotPut:
  795. port[$3cf]:=0
  796. else
  797. port[$3cf]:=0
  798. end;
  799. for i:=y to y2 do
  800. begin
  801. {$ifopt r+}
  802. {$define rangeOn}
  803. {$r-}
  804. {$endif}
  805. {$ifopt q+}
  806. {$define overflowOn}
  807. {$q-}
  808. {$endif}
  809. Mem[$a000:ScrOfs]:=Mem[$a000:ScrOfs]+1;
  810. {$ifdef rangeOn}
  811. {$undef rangeOn}
  812. {$r+}
  813. {$endif}
  814. {$ifdef overflowOn}
  815. {$undef overflowOn}
  816. {$q+}
  817. {$endif}
  818. ScrOfs:=ScrOfs+ScrWidth;
  819. end;
  820. // clean up
  821. port[$3cf]:=0;
  822. port[$3ce]:=8;
  823. port[$3cf]:=$ff;
  824. port[$3ce]:=1;
  825. port[$3cf]:=0;
  826. port[$3ce]:=3;
  827. port[$3cf]:=0;
  828. End;
  829. {$endif tp}
  830. procedure SetVisual480(page: word); {$ifndef fpc}far;{$endif fpc}
  831. { no page flipping support in 640x480 mode }
  832. begin
  833. VideoOfs := 0;
  834. end;
  835. procedure SetActive480(page: word); {$ifndef fpc}far;{$endif fpc}
  836. { no page flipping support in 640x480 mode }
  837. begin
  838. VideoOfs := 0;
  839. end;
  840. procedure SetVisual200(page: word); {$ifndef fpc}far;{$endif fpc}
  841. { two page support... }
  842. begin
  843. if page > HardwarePages then exit;
  844. asm
  845. mov ax,[page] { only lower byte is supported. }
  846. mov ah,05h
  847. {$ifdef fpc}
  848. push ebp
  849. {$endif fpc}
  850. int 10h
  851. {$ifdef fpc}
  852. pop ebp
  853. {$endif fpc}
  854. { read start address }
  855. mov dx,3d4h
  856. mov al,0ch
  857. out dx,al
  858. inc dx
  859. in al,dx
  860. mov ah,al
  861. dec dx
  862. mov al,0dh
  863. out dx,al
  864. in al,dx
  865. end;
  866. end;
  867. procedure SetActive200(page: word); {$ifndef fpc}far;{$endif fpc}
  868. { two page support... }
  869. begin
  870. case page of
  871. 0 : VideoOfs := 0;
  872. 1 : VideoOfs := 16384;
  873. 2 : VideoOfs := 32768;
  874. else
  875. VideoOfs := 0;
  876. end;
  877. end;
  878. procedure SetVisual350(page: word); {$ifndef fpc}far;{$endif fpc}
  879. { one page support... }
  880. begin
  881. if page > HardwarePages then exit;
  882. asm
  883. mov ax,[page] { only lower byte is supported. }
  884. mov ah,05h
  885. {$ifdef fpc}
  886. push ebp
  887. {$endif fpc}
  888. int 10h
  889. {$ifdef fpc}
  890. pop ebp
  891. {$endif fpc}
  892. end;
  893. end;
  894. procedure SetActive350(page: word); {$ifndef fpc}far;{$endif fpc}
  895. { one page support... }
  896. begin
  897. case page of
  898. 0 : VideoOfs := 0;
  899. 1 : VideoOfs := 32768;
  900. else
  901. VideoOfs := 0;
  902. end;
  903. end;
  904. {************************************************************************}
  905. {* 320x200x256c Routines *}
  906. {************************************************************************}
  907. Procedure Init320; {$ifndef fpc}far;{$endif fpc} assembler;
  908. asm
  909. mov ax,0013h
  910. {$ifdef fpc}
  911. push ebp
  912. {$endif fpc}
  913. int 10h
  914. {$ifdef fpc}
  915. pop ebp
  916. {$endif fpc}
  917. end;
  918. Procedure PutPixel320(X,Y : Integer; Pixel: Word); {$ifndef fpc}far;{$endif fpc}
  919. { x,y -> must be in local coordinates. Clipping if required. }
  920. Begin
  921. X:= X + StartXViewPort;
  922. Y:= Y + StartYViewPort;
  923. { convert to absolute coordinates and then verify clipping...}
  924. if ClipPixels then
  925. Begin
  926. if (X < StartXViewPort) or (X > (StartXViewPort + ViewWidth)) then
  927. exit;
  928. if (Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)) then
  929. exit;
  930. end;
  931. {$ifndef asmgraph}
  932. Mem[$a000: y * 320 + x + VideoOfs] := Lo(Pixel);
  933. {$else asmgraph}
  934. asm
  935. {$ifndef fpc}
  936. mov es, [SegA000]
  937. mov ax, [Y]
  938. mov di, [X]
  939. xchg ah, al { The value of Y must be in AH }
  940. add di, ax
  941. shr ax, 2
  942. add di, ax
  943. add di, [VideoOfs] { point to correct page.. }
  944. mov ax, [Pixel]
  945. mov es:[di], al
  946. {$else fpc}
  947. movzx edi, x
  948. movzx ebx, y
  949. add edi, [VideoOfs]
  950. shl ebx, 6
  951. add edi, ebx
  952. mov ax, pixel
  953. mov fs:[edi+ebx*4+$a0000], al
  954. {$endif fpc}
  955. end;
  956. {$endif asmgraph}
  957. end;
  958. Function GetPixel320(X,Y: Integer):word; {$ifndef fpc}far;{$endif fpc}
  959. Begin
  960. X:= X + StartXViewPort;
  961. Y:= Y + StartYViewPort;
  962. {$ifndef asmgraph}
  963. GetPixel320 := Mem[$a000:y * 320 + x + VideoOfs];
  964. {$else asmgraph}
  965. asm
  966. {$ifndef fpc}
  967. mov es, [SegA000]
  968. mov ax, [Y]
  969. mov di, [X]
  970. xchg ah, al { The value of Y must be in AH }
  971. add di, ax
  972. shr ax, 2
  973. add di, ax
  974. xor ax, ax
  975. add di, [VideoOfs] { point to correct gfx page ... }
  976. mov al,es:[di]
  977. mov @Result,ax
  978. {$else fpc}
  979. movzx edi, x
  980. movzx ebx, y
  981. add edi, [VideoOfs]
  982. shl ebx, 6
  983. add edi, ebx
  984. mov al, fs:[edi+ebx*4+$a0000]
  985. mov @Result, al
  986. {$endif fpc}
  987. end;
  988. {$endif asmgraph}
  989. end;
  990. Procedure DirectPutPixel320(X,Y : Integer); {$ifndef fpc}far;{$endif fpc}
  991. { x,y -> must be in global coordinates. No clipping. }
  992. {$ifndef asmgraph}
  993. var offset: word;
  994. dummy: Byte;
  995. begin
  996. dummy := CurrentColor;
  997. offset := y * 320 + x + VideoOfs;
  998. case CurrentWriteMode of
  999. XorPut: dummy := dummy xor Mem[$a000:offset];
  1000. OrPut: dummy := dummy or Mem[$a000:offset];
  1001. AndPut: dummy := dummy and Mem[$a000:offset];
  1002. NotPut: dummy := Not dummy;
  1003. end;
  1004. Mem[$a000:offset] := dummy;
  1005. end;
  1006. {$else asmgraph}
  1007. assembler;
  1008. asm
  1009. {$ifndef fpc}
  1010. mov es, [SegA000]
  1011. mov ax, [Y]
  1012. mov di, [X]
  1013. xchg ah, al { The value of Y must be in AH }
  1014. add di, ax
  1015. shr ax, 2
  1016. add di, ax
  1017. add di, [VideoOfs]
  1018. mov ax, [CurrentColor]
  1019. cmp [CurrentWriteMode],XORPut { check write mode }
  1020. jne @MOVMode
  1021. mov ah,es:[di] { read the byte... }
  1022. xor al,ah { xor it and return value into AL }
  1023. @MovMode:
  1024. mov es:[di], al
  1025. {$else fpc}
  1026. movzx edi, y
  1027. shl edi, 6
  1028. mov ebx, edx
  1029. add edi, [VideoOfs]
  1030. mov ax, [CurrentColor]
  1031. cmp [CurrentWriteMode],XORPut { check write mode }
  1032. jne @MOVMode
  1033. mov bl, fs:[edi+ebx*4+$a0000]
  1034. xor al, bl
  1035. @MovMode:
  1036. mov fs:[edi+ebx*4+$a0000], al
  1037. {$endif fpc}
  1038. end;
  1039. {$endif asmgraph}
  1040. procedure SetVisual320(page: word); {$ifndef fpc}far;{$endif fpc}
  1041. { no page support... }
  1042. begin
  1043. end;
  1044. procedure SetActive320(page: word); {$ifndef fpc}far;{$endif fpc}
  1045. { no page support... }
  1046. begin
  1047. VideoOfs := 0;
  1048. end;
  1049. {************************************************************************}
  1050. {* Mode-X related routines *}
  1051. {************************************************************************}
  1052. const CrtAddress: word = 0;
  1053. procedure InitModeX; {$ifndef fpc}far;{$endif fpc}
  1054. begin
  1055. asm
  1056. {see if we are using color-/monochorme display}
  1057. MOV DX,3CCh {use output register: }
  1058. IN AL,DX
  1059. TEST AL,1 {is it a color display? }
  1060. MOV DX,3D4h
  1061. JNZ @L1 {yes }
  1062. MOV DX,3B4h {no }
  1063. @L1: {DX = 3B4h / 3D4h = CRTAddress-register for monochrome/color}
  1064. MOV CRTAddress,DX
  1065. MOV AX, 0013h
  1066. {$ifdef fpc}
  1067. push ebp
  1068. {$EndIf fpc}
  1069. INT 10h
  1070. {$ifdef fpc}
  1071. pop ebp
  1072. {$EndIf fpc}
  1073. MOV DX,03C4h {select memory-mode-register at sequencer port }
  1074. MOV AL,04
  1075. OUT DX,AL
  1076. INC DX {read in data via the according data register }
  1077. IN AL,DX
  1078. AND AL,0F7h {bit 3 := 0: don't chain the 4 planes}
  1079. OR AL,04 {bit 2 := 1: no odd/even mechanism }
  1080. OUT DX,AL {activate new settings }
  1081. MOV DX,03C4h {s.a.: address sequencer reg. 2 (=map-mask),... }
  1082. MOV AL,02
  1083. OUT DX,AL
  1084. INC DX
  1085. MOV AL,0Fh {...and allow access to all 4 bit maps }
  1086. OUT DX,AL
  1087. {$ifndef fpc}
  1088. MOV AX,[SegA000] {starting with segment A000h, set 8000h logical }
  1089. MOV ES,AX {words = 4*8000h physical words (because of 4 }
  1090. XOR DI,DI {bitplanes) to 0 }
  1091. XOR AX,AX
  1092. MOV CX,8000h
  1093. CLD
  1094. REP STOSW
  1095. {$else fpc}
  1096. push es
  1097. push fs
  1098. mov edi, $a0000
  1099. pop es
  1100. xor eax, eax
  1101. mov ecx, 4000h
  1102. cld
  1103. rep stosd
  1104. pop es
  1105. {$EndIf fpc}
  1106. MOV DX,CRTAddress {address the underline-location-register at }
  1107. MOV AL,14h {the CRT-controller port, read out the according }
  1108. OUT DX,AL {data register: }
  1109. INC DX
  1110. IN AL,DX
  1111. AND AL,0BFh {bit 6:=0: no double word addressing scheme in}
  1112. OUT DX,AL {video RAM }
  1113. DEC DX
  1114. MOV AL,17h {select mode control register }
  1115. OUT DX,AL
  1116. INC DX
  1117. IN AL,DX
  1118. OR AL,40h {bit 6 := 1: memory access scheme=linear bit array }
  1119. OUT DX,AL
  1120. end;
  1121. end;
  1122. Function GetPixelX(X,Y: Integer): word; {$ifndef fpc}far;{$endif fpc}
  1123. {$ifndef asmgraph}
  1124. var offset: word;
  1125. {$endif asmgraph}
  1126. begin
  1127. X:= X + StartXViewPort;
  1128. Y:= Y + StartYViewPort;
  1129. {$ifndef asmgraph}
  1130. offset := y * 80 + x shr 2 + VideoOfs;
  1131. PortW[$3c4] := FirstPlane shl (x and 3);
  1132. GetPixelX := Mem[$a000:offset];
  1133. {$else asmgraph}
  1134. asm
  1135. {$ifndef fpc}
  1136. mov di,[Y] ; (* DI = Y coordinate *)
  1137. (* Multiply by 80 start *)
  1138. mov bx, di
  1139. shl di, 6 ; (* Faster on 286/386/486 machines *)
  1140. shl bx, 4
  1141. add di, bx ; (* Multiply Value by 80 *)
  1142. (* End multiply by 80 *)
  1143. mov cx, [X]
  1144. mov ax, cx
  1145. {DI = Y * LINESIZE, BX = X, coordinates admissible}
  1146. shr ax, 1 ; (* Faster on 286/86 machines *)
  1147. shr ax, 1
  1148. add di, ax ; {DI = Y * LINESIZE + (X SHR 2) }
  1149. add di, [VideoOfs] ; (* Pointing at start of Active page *)
  1150. (* Select plane to use *)
  1151. mov dx, 03c4h
  1152. mov ax, FirstPlane ; (* Map Mask & Plane Select Register *)
  1153. and cl, 03h ; (* Get Plane Bits *)
  1154. shl ah, cl ; (* Get Plane Select Value *)
  1155. out dx, ax
  1156. (* End selection of plane *)
  1157. mov es,[SegA000]
  1158. mov al, ES:[DI]
  1159. xor ah, ah
  1160. mov @Result, ax
  1161. {$else fpc}
  1162. movzx edi,[Y] ; (* DI = Y coordinate *)
  1163. (* Multiply by 80 start *)
  1164. mov ebx, edi
  1165. shl edi, 6 ; (* Faster on 286/386/486 machines *)
  1166. shl ebx, 4
  1167. add edi, ebx ; (* Multiply Value by 80 *)
  1168. (* End multiply by 80 *)
  1169. movzx ecx, [X]
  1170. movzx eax, [Y]
  1171. {DI = Y * LINESIZE, BX = X, coordinates admissible}
  1172. shr eax, 2
  1173. add edi, eax ; {DI = Y * LINESIZE + (X SHR 2) }
  1174. add edi, [VideoOfs] ; (* Pointing at start of Active page *)
  1175. (* Select plane to use *)
  1176. mov dx, 03c4h
  1177. mov ax, FirstPlane ; (* Map Mask & Plane Select Register *)
  1178. and cl, 03h ; (* Get Plane Bits *)
  1179. shl ah, cl ; (* Get Plane Select Value *)
  1180. out dx, ax
  1181. (* End selection of plane *)
  1182. mov ax, fs:[edi+$a0000]
  1183. mov @Result, ax
  1184. {$endif fpc}
  1185. end;
  1186. {$endif asmgraph}
  1187. end;
  1188. procedure SetVisualX(page: word); {$ifndef fpc}far;{$endif fpc}
  1189. { 4 page support... }
  1190. Procedure SetVisibleStart(AOffset: word); Assembler;
  1191. (* Select where the left corner of the screen will be *)
  1192. { By Matt Pritchard }
  1193. asm
  1194. { Wait if we are currently in a Vertical Retrace }
  1195. MOV DX, INPUT_1 { Input Status #1 Register }
  1196. @DP_WAIT0:
  1197. IN AL, DX { Get VGA status }
  1198. AND AL, VERT_RETRACE { In Display mode yet? }
  1199. JNZ @DP_WAIT0 { If Not, wait for it }
  1200. { Set the Start Display Address to the new page }
  1201. MOV DX, CRTC_Index { We Change the VGA Sequencer }
  1202. MOV AL, START_DISP_LO { Display Start Low Register }
  1203. {$ifndef fpc}
  1204. MOV AH, BYTE PTR [AOffset] { Low 8 Bits of Start Addr }
  1205. OUT DX, AX { Set Display Addr Low }
  1206. MOV AL, START_DISP_HI { Display Start High Register }
  1207. MOV AH, BYTE PTR [AOffset+1] { High 8 Bits of Start Addr }
  1208. {$else fpc}
  1209. mov ah, byte [AOffset]
  1210. out dx, ax
  1211. mov AL, START_DISP_HI
  1212. mov ah, byte [AOffset+1]
  1213. {$endif fpc}
  1214. OUT DX, AX { Set Display Addr High }
  1215. { Wait for a Vertical Retrace to smooth out things }
  1216. MOV DX, INPUT_1 { Input Status #1 Register }
  1217. @DP_WAIT1:
  1218. IN AL, DX { Get VGA status }
  1219. AND AL, VERT_RETRACE { Vertical Retrace Start? }
  1220. JZ @DP_WAIT1 { If Not, wait for it }
  1221. { Now Set Display Starting Address }
  1222. end;
  1223. {$ifdef fpc}
  1224. {$undef asmgraph}
  1225. {$endif fpc}
  1226. begin
  1227. Case page of
  1228. 0: SetVisibleStart(0);
  1229. 1: SetVisibleStart(16000);
  1230. 2: SetVisibleStart(32000);
  1231. 3: SetVisibleStart(48000);
  1232. else
  1233. SetVisibleStart(0);
  1234. end;
  1235. end;
  1236. procedure SetActiveX(page: word); {$ifndef fpc}far;{$endif fpc}
  1237. { 4 page support... }
  1238. begin
  1239. case page of
  1240. 0: VideoOfs := 0;
  1241. 1: VideoOfs := 16000;
  1242. 2: VideoOfs := 32000;
  1243. 3: VideoOfs := 48000;
  1244. else
  1245. VideoOfs:=0;
  1246. end;
  1247. end;
  1248. Procedure PutPixelX(X,Y: Integer; color:word); {$ifndef fpc}far;{$endif fpc}
  1249. {$ifndef asmgraph}
  1250. var offset: word;
  1251. dummy: byte;
  1252. {$endif asmgraph}
  1253. begin
  1254. X:= X + StartXViewPort;
  1255. Y:= Y + StartYViewPort;
  1256. { convert to absolute coordinates and then verify clipping...}
  1257. if ClipPixels then
  1258. Begin
  1259. if (X < StartXViewPort) or (X > (StartXViewPort + ViewWidth)) then
  1260. exit;
  1261. if (Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)) then
  1262. exit;
  1263. end;
  1264. {$ifndef asmgraph}
  1265. Dummy := color;
  1266. offset := y * 80 + x shr 2 + VideoOfs;
  1267. PortW[$3c4] := FirstPlane shl (x and 3);
  1268. If CurrentWriteMode = XorPut Then
  1269. Dummy := Dummy Xor Mem[$a000:offset];
  1270. Mem[$a000:offset] := Dummy;
  1271. {$else asmgraph}
  1272. asm
  1273. mov di,[Y] ; (* DI = Y coordinate *)
  1274. (* Multiply by 80 start *)
  1275. mov bx, di
  1276. shl di, 6 ; (* Faster on 286/386/486 machines *)
  1277. shl bx, 4
  1278. add di, bx ; (* Multiply Value by 80 *)
  1279. (* End multiply by 80 *)
  1280. mov cx, [X]
  1281. mov ax, cx
  1282. {DI = Y * LINESIZE, BX = X, coordinates admissible}
  1283. shr ax, 2
  1284. add di, ax ; {DI = Y * LINESIZE + (X SHR 2) }
  1285. add di, [VideoOfs] ; (* Pointing at start of Active page *)
  1286. (* Select plane to use *)
  1287. mov dx, 03c4h
  1288. mov ax, FirstPlane ; (* Map Mask & Plane Select Register *)
  1289. and cl, 03h ; (* Get Plane Bits *)
  1290. shl ah, cl ; (* Get Plane Select Value *)
  1291. out dx, ax
  1292. (* End selection of plane *)
  1293. mov es,[SegA000]
  1294. mov ax,[Color] ; { only lower byte is used. }
  1295. cmp [CurrentWriteMode],XORPut { check write mode }
  1296. jne @MOVMode
  1297. mov ah,es:[di] { read the byte... }
  1298. xor al,ah { xor it and return value into AL }
  1299. @MovMode:
  1300. mov es:[di], al
  1301. end;
  1302. {$endif asmgraph}
  1303. end;
  1304. Procedure DirectPutPixelX(X,Y: Integer); {$ifndef fpc}far;{$endif fpc}
  1305. { x,y -> must be in global coordinates. No clipping. }
  1306. {$ifndef asmgraph}
  1307. Var offset: Word;
  1308. dummy: Byte;
  1309. begin
  1310. dummy := CurrentColor;
  1311. offset := y * 80 + x shr 2 + VideoOfs;
  1312. PortW[$3c4] := FirstPlane shl (x and 3);
  1313. If CurrentWriteMode = XorPut Then
  1314. dummy := dummy xor Mem[$a000: offset];
  1315. Mem[$a000: offset] := Dummy;
  1316. end;
  1317. {$else asmgraph}
  1318. Assembler;
  1319. asm
  1320. mov di,[Y] ; (* DI = Y coordinate *)
  1321. (* Multiply by 80 start *)
  1322. mov bx, di
  1323. shl di, 6 ; (* Faster on 286/386/486 machines *)
  1324. shl bx, 4
  1325. add di, bx ; (* Multiply Value by 80 *)
  1326. (* End multiply by 80 *)
  1327. mov cx, [X]
  1328. mov ax, cx
  1329. {DI = Y * LINESIZE, BX = X, coordinates admissible}
  1330. shr ax, 2
  1331. add di, ax ; {DI = Y * LINESIZE + (X SHR 2) }
  1332. add di, [VideoOfs] ; (* Pointing at start of Active page *)
  1333. (* Select plane to use *)
  1334. mov dx, 03c4h
  1335. mov ax, FirstPlane ; (* Map Mask & Plane Select Register *)
  1336. and cl, 03h ; (* Get Plane Bits *)
  1337. shl ah, cl ; (* Get Plane Select Value *)
  1338. out dx, ax
  1339. (* End selection of plane *)
  1340. mov es,[SegA000]
  1341. mov ax,[CurrentColor] ; { only lower byte is used. }
  1342. cmp [CurrentWriteMode],XORPut { check write mode }
  1343. jne @MOVMode
  1344. mov ah,es:[di] { read the byte... }
  1345. xor al,ah { xor it and return value into AL }
  1346. @MovMode:
  1347. mov es:[di], al
  1348. end;
  1349. {$endif asmgraph}
  1350. {************************************************************************}
  1351. {* General routines *}
  1352. {************************************************************************}
  1353. var
  1354. SavePtr : pointer; { pointer to video state }
  1355. StateSize: word; { size in 64 byte blocks for video state }
  1356. VideoMode: byte; { old video mode before graph mode }
  1357. SaveSupported : Boolean; { Save/Restore video state supported? }
  1358. {**************************************************************}
  1359. {* DPMI Routines *}
  1360. {**************************************************************}
  1361. {$IFDEF DPMI}
  1362. RealStateSeg: word; { Real segment of saved video state }
  1363. Procedure SaveStateVGA; {$ifndef fpc}far;{$endif fpc}
  1364. var
  1365. PtrLong: longint;
  1366. regs: TDPMIRegisters;
  1367. begin
  1368. SaveSupported := FALSE;
  1369. SavePtr := nil;
  1370. { Get the video mode }
  1371. asm
  1372. mov ah,0fh
  1373. int 10h
  1374. mov [VideoMode], al
  1375. end;
  1376. { Prepare to save video state...}
  1377. asm
  1378. mov ax, 1C00h { get buffer size to save state }
  1379. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  1380. {$ifdef fpc}
  1381. push ebp
  1382. {$endif fpc}
  1383. int 10h
  1384. {$ifdef fpc}
  1385. pop ebp
  1386. {$endif fpc}
  1387. mov [StateSize], bx
  1388. cmp al,01ch
  1389. jnz @notok
  1390. mov [SaveSupported],TRUE
  1391. @notok:
  1392. end;
  1393. if SaveSupported then
  1394. begin
  1395. {$ifndef fpc}
  1396. PtrLong:=GlobalDosAlloc(64*StateSize); { values returned in 64-byte blocks }
  1397. {$else fpc}
  1398. PtrLong:=Global_Dos_Alloc(64*StateSize); { values returned in 64-byte blocks }
  1399. {$endif fpc}
  1400. if PtrLong = 0 then
  1401. RunError(203);
  1402. SavePtr := pointer(longint(PtrLong and $0000ffff) shl 16);
  1403. {$ifndef fpc}
  1404. { In FPC mode, we can't do anything with this (no far pointers) }
  1405. { However, we still need to keep it to be able to free the }
  1406. { memory afterwards. Since this data is not accessed in PM code, }
  1407. { there's no need to save it in a seperate buffer (JM) }
  1408. if not assigned(SavePtr) then
  1409. RunError(203);
  1410. {$endif fpc}
  1411. RealStateSeg := word(PtrLong shr 16);
  1412. FillChar(regs, sizeof(regs), #0);
  1413. { call the real mode interrupt ... }
  1414. regs.eax := $1C01; { save the state buffer }
  1415. regs.ecx := $07; { Save DAC / Data areas / Hardware states }
  1416. regs.es := RealStateSeg;
  1417. regs.ebx := 0;
  1418. RealIntr($10,regs);
  1419. FillChar(regs, sizeof(regs), #0);
  1420. { restore state, according to Ralph Brown Interrupt list }
  1421. { some BIOS corrupt the hardware after a save... }
  1422. regs.eax := $1C02; { restore the state buffer }
  1423. regs.ecx := $07; { rest DAC / Data areas / Hardware states }
  1424. regs.es := RealStateSeg;
  1425. regs.ebx := 0;
  1426. RealIntr($10,regs);
  1427. end;
  1428. end;
  1429. procedure RestoreStateVGA; {$ifndef fpc}far;{$endif fpc}
  1430. var
  1431. regs:TDPMIRegisters;
  1432. begin
  1433. { go back to the old video mode...}
  1434. asm
  1435. mov ah,00
  1436. mov al,[VideoMode]
  1437. {$ifdef fpc}
  1438. push ebp
  1439. {$endif fpc}
  1440. int 10h
  1441. {$ifdef fpc}
  1442. pop ebp
  1443. {$endif fpc}
  1444. end;
  1445. { then restore all state information }
  1446. {$ifndef fpc}
  1447. if assigned(SavePtr) and (SaveSupported=TRUE) then
  1448. {$else fpc}
  1449. { No far pointer support, so it's possible that that assigned(SavePtr) }
  1450. { would return false under FPC. Just check if it's different from nil. }
  1451. if (SavePtr <> nil) and (SaveSupported=TRUE) then
  1452. {$endif fpc}
  1453. begin
  1454. FillChar(regs, sizeof(regs), #0);
  1455. { restore state, according to Ralph Brown Interrupt list }
  1456. { some BIOS corrupt the hardware after a save... }
  1457. regs.eax := $1C02; { restore the state buffer }
  1458. regs.ecx := $07; { rest DAC / Data areas / Hardware states }
  1459. regs.es := RealStateSeg;
  1460. regs.ebx := 0;
  1461. RealIntr($10,regs);
  1462. {$ifndef fpc}
  1463. if GlobalDosFree(longint(SavePtr) shr 16)<>0 then
  1464. {$else fpc}
  1465. if Not Global_Dos_Free(longint(SavePtr) shr 16) then
  1466. {$endif fpc}
  1467. RunError(216);
  1468. SavePtr := nil;
  1469. end;
  1470. end;
  1471. {$ELSE}
  1472. {**************************************************************}
  1473. {* Real mode routines *}
  1474. {**************************************************************}
  1475. Procedure SaveStateVGA; far;
  1476. begin
  1477. SavePtr := nil;
  1478. SaveSupported := FALSE;
  1479. { Get the video mode }
  1480. asm
  1481. mov ah,0fh
  1482. int 10h
  1483. mov [VideoMode], al
  1484. end;
  1485. { Prepare to save video state...}
  1486. asm
  1487. mov ax, 1C00h { get buffer size to save state }
  1488. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  1489. int 10h
  1490. mov [StateSize], bx
  1491. cmp al,01ch
  1492. jnz @notok
  1493. mov [SaveSupported],TRUE
  1494. @notok:
  1495. end;
  1496. if SaveSupported then
  1497. Begin
  1498. GetMem(SavePtr, 64*StateSize); { values returned in 64-byte blocks }
  1499. if not assigned(SavePtr) then
  1500. RunError(203);
  1501. asm
  1502. mov ax, 1C01h { save the state buffer }
  1503. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  1504. mov es, WORD PTR [SavePtr+2]
  1505. mov bx, WORD PTR [SavePtr]
  1506. int 10h
  1507. end;
  1508. { restore state, according to Ralph Brown Interrupt list }
  1509. { some BIOS corrupt the hardware after a save... }
  1510. asm
  1511. mov ax, 1C02h { save the state buffer }
  1512. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  1513. mov es, WORD PTR [SavePtr+2]
  1514. mov bx, WORD PTR [SavePtr]
  1515. int 10h
  1516. end;
  1517. end;
  1518. end;
  1519. procedure RestoreStateVGA; far;
  1520. begin
  1521. { go back to the old video mode...}
  1522. asm
  1523. mov ah,00
  1524. mov al,[VideoMode]
  1525. int 10h
  1526. end;
  1527. { then restore all state information }
  1528. if assigned(SavePtr) and (SaveSupported=TRUE) then
  1529. begin
  1530. { restore state, according to Ralph Brown Interrupt list }
  1531. asm
  1532. mov ax, 1C02h { save the state buffer }
  1533. mov cx, 00000111b { Save DAC / Data areas / Hardware states }
  1534. mov es, WORD PTR [SavePtr+2]
  1535. mov bx, WORD PTR [SavePtr]
  1536. int 10h
  1537. end;
  1538. FreeMem(SavePtr, 64*StateSize);
  1539. SavePtr := nil;
  1540. end;
  1541. end;
  1542. {$ENDIF DPMI}
  1543. { VGA is never a direct color mode, so no need to check ... }
  1544. Procedure SetVGARGBPalette(ColorNum, RedValue, GreenValue,
  1545. BlueValue : Integer); {$ifndef fpc}far;{$endif fpc} assembler;
  1546. asm
  1547. { on some hardware - there is a snow like effect }
  1548. { when changing the palette register directly }
  1549. { so we wait for a vertical retrace start period. }
  1550. mov dx, $03da
  1551. @1:
  1552. in al, dx { Get input status register }
  1553. test al, $08 { check if in vertical retrace }
  1554. jnz @1 { yes, complete it }
  1555. { we have to wait for the next }
  1556. { retrace to assure ourselves }
  1557. { that we have time to complete }
  1558. { the DAC operation within }
  1559. { the vertical retrace period }
  1560. @2:
  1561. in al, dx
  1562. test al, $08
  1563. jz @2 { repeat until vertical retrace start }
  1564. mov dx, $03c8 { Set color register address to use }
  1565. mov ax, [ColorNum]
  1566. out dx, al
  1567. inc dx { Point to DAC registers }
  1568. mov ax, [RedValue] { Get RedValue }
  1569. { and ax, $ff } { mask out all upper bits }
  1570. shr al, 2 { convert to LSB RGB format }
  1571. out dx, al
  1572. mov ax, [GreenValue]{ Get RedValue }
  1573. { and ax, $ff } { mask out all upper bits }
  1574. shr al, 2 { convert to LSB RGB format }
  1575. out dx, al
  1576. mov ax, [BlueValue] { Get RedValue }
  1577. { and ax, $ff } { mask out all upper bits }
  1578. shr al, 2 { convert to LSB RGB format }
  1579. out dx, al
  1580. end;
  1581. { VGA is never a direct color mode, so no need to check ... }
  1582. Procedure GetVGARGBPalette(ColorNum: integer; Var
  1583. RedValue, GreenValue, BlueValue : integer); {$ifndef fpc}far;{$endif fpc}
  1584. begin
  1585. Port[$03C7] := ColorNum;
  1586. { we must convert to lsb values... because the vga uses the 6 msb bits }
  1587. { which is not compatible with anything. }
  1588. RedValue := Integer(Port[$3C9] shl 2);
  1589. GreenValue := Integer(Port[$3C9] shl 2);
  1590. BlueValue := Integer(Port[$3C9] shl 2);
  1591. end;
  1592. {************************************************************************}
  1593. {* VESA related routines *}
  1594. {************************************************************************}
  1595. {$I vesa.inc}
  1596. {************************************************************************}
  1597. {* General routines *}
  1598. {************************************************************************}
  1599. procedure CloseGraph;
  1600. Begin
  1601. If not isgraphmode then
  1602. begin
  1603. _graphresult := grnoinitgraph;
  1604. exit
  1605. end;
  1606. {$ifdef logging}
  1607. LogLn('calling RestoreVideoState at '+strf(longint(RestoreVideoState)));
  1608. {$endif logging}
  1609. if not assigned(RestoreVideoState) then
  1610. RunError(216);
  1611. {$ifdef logging}
  1612. LogLn('actual call of RestoreVideoState');
  1613. {$endif logging}
  1614. RestoreVideoState;
  1615. isgraphmode := false;
  1616. end;
  1617. function QueryAdapterInfo:PModeInfo;
  1618. { This routine returns the head pointer to the list }
  1619. { of supported graphics modes. }
  1620. { Returns nil if no graphics mode supported. }
  1621. { This list is READ ONLY! }
  1622. var
  1623. EGADetected : Boolean;
  1624. VGADetected : Boolean;
  1625. mode: TModeInfo;
  1626. begin
  1627. QueryAdapterInfo := ModeList;
  1628. { If the mode listing already exists... }
  1629. { simply return it, without changing }
  1630. { anything... }
  1631. if assigned(ModeList) then
  1632. exit;
  1633. EGADetected := FALSE;
  1634. VGADetected := FALSE;
  1635. { check if Hercules adapter supported ... }
  1636. { check if EGA adapter supported... }
  1637. asm
  1638. mov ah,12h
  1639. mov bx,0FF10h
  1640. {$ifdef fpc}
  1641. push ebp
  1642. {$endif fpc}
  1643. int 10h { get EGA information }
  1644. {$ifdef fpc}
  1645. pop ebp
  1646. {$endif fpc}
  1647. cmp bh,0ffh
  1648. jz @noega
  1649. mov [EGADetected],TRUE
  1650. @noega:
  1651. end;
  1652. {$ifdef logging}
  1653. LogLn('EGA detected: '+strf(Longint(EGADetected)));
  1654. {$endif logging}
  1655. { check if VGA adapter supported... }
  1656. if EGADetected then
  1657. begin
  1658. asm
  1659. mov ax,1a00h
  1660. {$ifdef fpc}
  1661. push ebp
  1662. {$endif fpc}
  1663. int 10h { get display combination code...}
  1664. {$ifdef fpc}
  1665. pop ebp
  1666. {$endif fpc}
  1667. cmp al,1ah { check if supported... }
  1668. jne @novga
  1669. { now check if this is the ATI EGA }
  1670. mov ax,1c00h { get state size for save... }
  1671. { ... all important data }
  1672. mov cx,07h
  1673. {$ifdef fpc}
  1674. push ebp
  1675. {$endif fpc}
  1676. int 10h
  1677. {$ifdef fpc}
  1678. pop ebp
  1679. {$endif fpc}
  1680. cmp al,1ch { success? }
  1681. jne @novga
  1682. mov [VGADetected],TRUE
  1683. @novga:
  1684. end;
  1685. end;
  1686. {$ifdef logging}
  1687. LogLn('VGA detected: '+strf(Longint(VGADetected)));
  1688. {$endif logging}
  1689. if VGADetected then
  1690. begin
  1691. SaveVideoState := SaveStateVGA;
  1692. {$ifdef logging}
  1693. LogLn('Setting VGA SaveVideoState to '+strf(longint(SaveVideoState)));
  1694. {$endif logging}
  1695. RestoreVideoState := RestoreStateVGA;
  1696. {$ifdef logging}
  1697. LogLn('Setting VGA RestoreVideoState to '+strf(longint(RestoreVideoState)));
  1698. {$endif logging}
  1699. InitMode(mode);
  1700. { now add all standard VGA modes... }
  1701. mode.DriverNumber:= LowRes;
  1702. mode.HardwarePages:= 0;
  1703. mode.ModeNumber:=0;
  1704. mode.ModeName:='320 x 200 VGA';
  1705. mode.MaxColor := 256;
  1706. mode.PaletteSize := mode.MaxColor;
  1707. mode.DirectColor := FALSE;
  1708. mode.MaxX := 319;
  1709. mode.MaxY := 199;
  1710. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel320;
  1711. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel320;
  1712. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel320;
  1713. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVGARGBPalette;
  1714. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVGARGBPalette;
  1715. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisual320;
  1716. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActive320;
  1717. mode.InitMode := {$ifdef fpc}@{$endif}Init320;
  1718. mode.XAspect := 10000;
  1719. mode.YAspect := 10000;
  1720. AddMode(mode);
  1721. { now add all standard VGA modes... }
  1722. InitMode(mode);
  1723. mode.DriverNumber:= LowRes;
  1724. mode.ModeNumber:=1;
  1725. mode.HardwarePages := 3; { 0..3 }
  1726. mode.ModeName:='320 x 200 ModeX';
  1727. mode.MaxColor := 256;
  1728. mode.DirectColor := FALSE;
  1729. mode.PaletteSize := mode.MaxColor;
  1730. mode.MaxX := 319;
  1731. mode.MaxY := 199;
  1732. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixelX;
  1733. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixelX;
  1734. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixelX;
  1735. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVGARGBPalette;
  1736. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVGARGBPalette;
  1737. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualX;
  1738. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveX;
  1739. mode.InitMode := {$ifdef fpc}@{$endif}InitModeX;
  1740. mode.XAspect := 10000;
  1741. mode.YAspect := 10000;
  1742. AddMode(mode);
  1743. InitMode(mode);
  1744. mode.ModeNumber:=VGALo;
  1745. mode.DriverNumber := VGA;
  1746. mode.ModeName:='640 x 200 VGA';
  1747. mode.MaxColor := 16;
  1748. mode.HardwarePages := 2;
  1749. mode.DirectColor := FALSE;
  1750. mode.PaletteSize := mode.MaxColor;
  1751. mode.MaxX := 639;
  1752. mode.MaxY := 199;
  1753. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16;
  1754. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16;
  1755. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16;
  1756. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVGARGBPalette;
  1757. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVGARGBPalette;
  1758. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisual200;
  1759. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActive200;
  1760. mode.InitMode := {$ifdef fpc}@{$endif}Init640x200x16;
  1761. mode.HLine := {$ifdef fpc}@{$endif}HLine16;
  1762. mode.VLine := {$ifdef fpc}@{$endif}VLine16;
  1763. mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
  1764. mode.XAspect := 10000;
  1765. mode.YAspect := 10000;
  1766. AddMode(mode);
  1767. InitMode(mode);
  1768. mode.ModeNumber:=VGAMed;
  1769. mode.DriverNumber := VGA;
  1770. mode.ModeName:='640 x 350 VGA';
  1771. mode.HardwarePages := 1;
  1772. mode.MaxColor := 16;
  1773. mode.DirectColor := FALSE;
  1774. mode.PaletteSize := mode.MaxColor;
  1775. mode.MaxX := 639;
  1776. mode.MaxY := 349;
  1777. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16;
  1778. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16;
  1779. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16;
  1780. mode.InitMode := {$ifdef fpc}@{$endif}Init640x350x16;
  1781. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVGARGBPalette;
  1782. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVGARGBPalette;
  1783. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisual350;
  1784. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActive350;
  1785. mode.HLine := {$ifdef fpc}@{$endif}HLine16;
  1786. mode.VLine := {$ifdef fpc}@{$endif}VLine16;
  1787. mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
  1788. mode.XAspect := 10000;
  1789. mode.YAspect := 10000;
  1790. AddMode(mode);
  1791. InitMode(mode);
  1792. mode.ModeNumber:=VGAHi;
  1793. mode.DriverNumber := VGA;
  1794. mode.HardwarePages := 0;
  1795. mode.ModeName:='640 x 480 VGA';
  1796. mode.MaxColor := 16;
  1797. mode.DirectColor := FALSE;
  1798. mode.PaletteSize := mode.MaxColor;
  1799. mode.MaxX := 639;
  1800. mode.MaxY := 479;
  1801. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16;
  1802. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16;
  1803. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16;
  1804. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVGARGBPalette;
  1805. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVGARGBPalette;
  1806. mode.InitMode := {$ifdef fpc}@{$endif}Init640x480x16;
  1807. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisual480;
  1808. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActive480;
  1809. mode.HLine := {$ifdef fpc}@{$endif}HLine16;
  1810. mode.VLine := {$ifdef fpc}@{$endif}VLine16;
  1811. mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
  1812. mode.XAspect := 10000;
  1813. mode.YAspect := 10000;
  1814. AddMode(mode);
  1815. end;
  1816. { check if VESA adapter supported... }
  1817. {$ifndef noSupportVESA}
  1818. hasVesa := getVesaInfo(VESAInfo);
  1819. {$else noSupportVESA}
  1820. hasVESA := false;
  1821. {$endif noSupportVESA}
  1822. if hasVesa then
  1823. begin
  1824. { We have to set and restore the entire VESA state }
  1825. { otherwise, if we use the VGA BIOS only function }
  1826. { there might be a crash under DPMI, such as in the}
  1827. { ATI Mach64 }
  1828. SaveVideoState := SaveStateVESA;
  1829. {$ifdef logging}
  1830. LogLn('Setting SaveVideoState to '+strf(longint(SaveVideoState)));
  1831. {$endif logging}
  1832. RestoreVideoState := RestoreStateVESA;
  1833. {$ifdef logging}
  1834. LogLn('Setting RestoreVideoState to '+strf(longint(RestoreVideoState)));
  1835. {$endif logging}
  1836. { now check all supported modes...}
  1837. if SearchVESAModes(m320x200x32k) then
  1838. begin
  1839. InitMode(mode);
  1840. mode.ModeNumber:=m320x200x32k;
  1841. mode.DriverNumber := VESA;
  1842. mode.ModeName:='320 x 200 VESA';
  1843. mode.MaxColor := 32768;
  1844. { the ModeInfo is automatically set if the mode is supported }
  1845. { by the call to SearchVESAMode. }
  1846. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  1847. mode.PaletteSize := mode.MaxColor;
  1848. mode.DirectColor := TRUE;
  1849. mode.MaxX := 319;
  1850. mode.MaxY := 199;
  1851. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA32k;
  1852. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA32k;
  1853. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA32k;
  1854. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  1855. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  1856. mode.InitMode := {$ifdef fpc}@{$endif}Init320x200x32k;
  1857. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  1858. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  1859. mode.XAspect := 10000;
  1860. mode.YAspect := 10000;
  1861. AddMode(mode);
  1862. end;
  1863. if SearchVESAModes(m320x200x64k) then
  1864. begin
  1865. InitMode(mode);
  1866. mode.ModeNumber:=m320x200x64k;
  1867. mode.DriverNumber := VESA;
  1868. mode.ModeName:='320 x 200 VESA';
  1869. mode.MaxColor := 65536;
  1870. { the ModeInfo is automatically set if the mode is supported }
  1871. { by the call to SearchVESAMode. }
  1872. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  1873. mode.PaletteSize := mode.MaxColor;
  1874. mode.DirectColor := TRUE;
  1875. mode.MaxX := 319;
  1876. mode.MaxY := 199;
  1877. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA64k;
  1878. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA64k;
  1879. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA64k;
  1880. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  1881. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  1882. mode.InitMode := {$ifdef fpc}@{$endif}Init320x200x64k;
  1883. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  1884. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  1885. mode.XAspect := 10000;
  1886. mode.YAspect := 10000;
  1887. AddMode(mode);
  1888. end;
  1889. if SearchVESAModes(m640x400x256) then
  1890. begin
  1891. InitMode(mode);
  1892. mode.ModeNumber:=m640x400x256;
  1893. mode.DriverNumber := VESA;
  1894. mode.ModeName:='640 x 400 VESA';
  1895. mode.MaxColor := 256;
  1896. { the ModeInfo is automatically set if the mode is supported }
  1897. { by the call to SearchVESAMode. }
  1898. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  1899. mode.PaletteSize := mode.MaxColor;
  1900. mode.DirectColor := FALSE;
  1901. mode.MaxX := 639;
  1902. mode.MaxY := 399;
  1903. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
  1904. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
  1905. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
  1906. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  1907. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  1908. mode.InitMode := {$ifdef fpc}@{$endif}Init640x400x256;
  1909. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  1910. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  1911. mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
  1912. mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
  1913. mode.XAspect := 10000;
  1914. mode.YAspect := 10000;
  1915. AddMode(mode);
  1916. end;
  1917. if SearchVESAModes(m640x480x256) then
  1918. begin
  1919. InitMode(mode);
  1920. mode.ModeNumber:=m640x480x256;
  1921. mode.DriverNumber := VESA;
  1922. mode.ModeName:='640 x 480 VESA';
  1923. mode.MaxColor := 256;
  1924. { the ModeInfo is automatically set if the mode is supported }
  1925. { by the call to SearchVESAMode. }
  1926. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  1927. mode.PaletteSize := mode.MaxColor;
  1928. mode.MaxX := 639;
  1929. mode.MaxY := 479;
  1930. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
  1931. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
  1932. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
  1933. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  1934. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  1935. mode.InitMode := {$ifdef fpc}@{$endif}Init640x480x256;
  1936. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  1937. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  1938. mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
  1939. mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
  1940. mode.XAspect := 10000;
  1941. mode.YAspect := 10000;
  1942. AddMode(mode);
  1943. end;
  1944. if SearchVESAModes(m640x480x32k) then
  1945. begin
  1946. InitMode(mode);
  1947. mode.ModeNumber:=m640x480x32k;
  1948. mode.DriverNumber := VESA;
  1949. mode.ModeName:='640 x 400 VESA';
  1950. mode.MaxColor := 32768;
  1951. { the ModeInfo is automatically set if the mode is supported }
  1952. { by the call to SearchVESAMode. }
  1953. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  1954. mode.PaletteSize := mode.MaxColor;
  1955. mode.DirectColor := TRUE;
  1956. mode.MaxX := 639;
  1957. mode.MaxY := 399;
  1958. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA32k;
  1959. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA32k;
  1960. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA32k;
  1961. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  1962. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  1963. mode.InitMode := {$ifdef fpc}@{$endif}Init640x480x32k;
  1964. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  1965. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  1966. mode.XAspect := 10000;
  1967. mode.YAspect := 10000;
  1968. AddMode(mode);
  1969. end;
  1970. if SearchVESAModes(m640x480x64k) then
  1971. begin
  1972. InitMode(mode);
  1973. mode.ModeNumber:=m640x480x64k;
  1974. mode.DriverNumber := VESA;
  1975. mode.ModeName:='640 x 480 VESA';
  1976. mode.MaxColor := 65536;
  1977. { the ModeInfo is automatically set if the mode is supported }
  1978. { by the call to SearchVESAMode. }
  1979. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  1980. mode.PaletteSize := mode.MaxColor;
  1981. mode.DirectColor := TRUE;
  1982. mode.MaxX := 639;
  1983. mode.MaxY := 479;
  1984. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA64k;
  1985. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA64k;
  1986. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA64k;
  1987. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  1988. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  1989. mode.InitMode := {$ifdef fpc}@{$endif}Init640x480x64k;
  1990. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  1991. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  1992. mode.XAspect := 10000;
  1993. mode.YAspect := 10000;
  1994. AddMode(mode);
  1995. end;
  1996. if SearchVESAModes(m800x600x16) then
  1997. begin
  1998. InitMode(mode);
  1999. mode.ModeNumber:=m800x600x16;
  2000. mode.DriverNumber := VESA;
  2001. mode.ModeName:='800 x 600 VESA';
  2002. mode.MaxColor := 16;
  2003. { the ModeInfo is automatically set if the mode is supported }
  2004. { by the call to SearchVESAMode. }
  2005. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2006. mode.DirectColor := FALSE;
  2007. mode.PaletteSize := mode.MaxColor;
  2008. mode.MaxX := 799;
  2009. mode.MaxY := 599;
  2010. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA16;
  2011. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2012. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2013. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA16;
  2014. (* mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA16; *)
  2015. mode.InitMode := {$ifdef fpc}@{$endif}Init800x600x16;
  2016. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2017. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2018. mode.XAspect := 10000;
  2019. mode.YAspect := 10000;
  2020. AddMode(mode);
  2021. end;
  2022. if SearchVESAModes(m800x600x256) then
  2023. begin
  2024. InitMode(mode);
  2025. mode.ModeNumber:=m800x600x256;
  2026. mode.DriverNumber := VESA;
  2027. mode.ModeName:='800 x 600 VESA';
  2028. mode.MaxColor := 256;
  2029. { the ModeInfo is automatically set if the mode is supported }
  2030. { by the call to SearchVESAMode. }
  2031. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2032. mode.PaletteSize := mode.MaxColor;
  2033. mode.DirectColor := FALSE;
  2034. mode.MaxX := 799;
  2035. mode.MaxY := 599;
  2036. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
  2037. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
  2038. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
  2039. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2040. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2041. mode.InitMode := {$ifdef fpc}@{$endif}Init800x600x256;
  2042. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2043. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2044. mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
  2045. mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
  2046. mode.XAspect := 10000;
  2047. mode.YAspect := 10000;
  2048. AddMode(mode);
  2049. end;
  2050. if SearchVESAModes(m800x600x32k) then
  2051. begin
  2052. InitMode(mode);
  2053. mode.ModeNumber:=m800x600x32k;
  2054. mode.DriverNumber := VESA;
  2055. mode.ModeName:='800 x 600 VESA';
  2056. mode.MaxColor := 32768;
  2057. { the ModeInfo is automatically set if the mode is supported }
  2058. { by the call to SearchVESAMode. }
  2059. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2060. mode.PaletteSize := mode.MaxColor;
  2061. mode.DirectColor := TRUE;
  2062. mode.MaxX := 799;
  2063. mode.MaxY := 599;
  2064. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA32k;
  2065. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA32k;
  2066. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA32k;
  2067. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2068. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2069. mode.InitMode := {$ifdef fpc}@{$endif}Init800x600x32k;
  2070. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2071. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2072. mode.XAspect := 10000;
  2073. mode.YAspect := 10000;
  2074. AddMode(mode);
  2075. end;
  2076. if SearchVESAModes(m800x600x64k) then
  2077. begin
  2078. InitMode(mode);
  2079. mode.ModeNumber:=m800x600x16;
  2080. mode.DriverNumber := VESA;
  2081. mode.ModeName:='800 x 600 VESA';
  2082. mode.MaxColor := 65536;
  2083. { the ModeInfo is automatically set if the mode is supported }
  2084. { by the call to SearchVESAMode. }
  2085. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2086. mode.PaletteSize := mode.MaxColor;
  2087. mode.DirectColor := TRUE;
  2088. mode.MaxX := 799;
  2089. mode.MaxY := 599;
  2090. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA64k;
  2091. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA64k;
  2092. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA64k;
  2093. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2094. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2095. mode.InitMode := {$ifdef fpc}@{$endif}Init800x600x64k;
  2096. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2097. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2098. mode.XAspect := 10000;
  2099. mode.YAspect := 10000;
  2100. AddMode(mode);
  2101. end;
  2102. if SearchVESAModes(m1024x768x16) then
  2103. begin
  2104. InitMode(mode);
  2105. mode.ModeNumber:=m1024x768x16;
  2106. mode.DriverNumber := VESA;
  2107. mode.ModeName:='1024 x 768 VESA';
  2108. mode.MaxColor := 16;
  2109. { the ModeInfo is automatically set if the mode is supported }
  2110. { by the call to SearchVESAMode. }
  2111. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2112. mode.PaletteSize := mode.MaxColor;
  2113. mode.DirectColor := FALSE;
  2114. mode.MaxX := 1023;
  2115. mode.MaxY := 767;
  2116. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA16;
  2117. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA16;
  2118. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2119. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2120. (* mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA16; *)
  2121. mode.InitMode := {$ifdef fpc}@{$endif}Init1024x768x16;
  2122. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2123. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2124. mode.XAspect := 10000;
  2125. mode.YAspect := 10000;
  2126. AddMode(mode);
  2127. end;
  2128. if SearchVESAModes(m1024x768x256) then
  2129. begin
  2130. InitMode(mode);
  2131. mode.ModeNumber:=m1024x768x256;
  2132. mode.DriverNumber := VESA;
  2133. mode.ModeName:='1024 x 768 VESA';
  2134. mode.MaxColor := 256;
  2135. { the ModeInfo is automatically set if the mode is supported }
  2136. { by the call to SearchVESAMode. }
  2137. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2138. mode.PaletteSize := mode.MaxColor;
  2139. mode.DirectColor := FALSE;
  2140. mode.MaxX := 1023;
  2141. mode.MaxY := 767;
  2142. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
  2143. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
  2144. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
  2145. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2146. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2147. mode.InitMode := {$ifdef fpc}@{$endif}Init1024x768x256;
  2148. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2149. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2150. mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
  2151. mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
  2152. mode.XAspect := 10000;
  2153. mode.YAspect := 10000;
  2154. AddMode(mode);
  2155. end;
  2156. if SearchVESAModes(m1024x768x32k) then
  2157. begin
  2158. InitMode(mode);
  2159. mode.ModeNumber:=m1024x768x32k;
  2160. mode.DriverNumber := VESA;
  2161. mode.ModeName:='1024 x 768 VESA';
  2162. mode.MaxColor := 32768;
  2163. { the ModeInfo is automatically set if the mode is supported }
  2164. { by the call to SearchVESAMode. }
  2165. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2166. mode.PaletteSize := mode.MaxColor;
  2167. mode.DirectColor := TRUE;
  2168. mode.MaxX := 1023;
  2169. mode.MaxY := 767;
  2170. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA32k;
  2171. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA32k;
  2172. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA32k;
  2173. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2174. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2175. mode.InitMode := {$ifdef fpc}@{$endif}Init640x480x32k;
  2176. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2177. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2178. mode.XAspect := 10000;
  2179. mode.YAspect := 10000;
  2180. AddMode(mode);
  2181. end;
  2182. if SearchVESAModes(m1024x768x64k) then
  2183. begin
  2184. InitMode(mode);
  2185. mode.ModeNumber:=m1024x768x64k;
  2186. mode.DriverNumber := VESA;
  2187. mode.ModeName:='1024 x 768 VESA';
  2188. mode.MaxColor := 65536;
  2189. mode.DirectColor := TRUE;
  2190. { the ModeInfo is automatically set if the mode is supported }
  2191. { by the call to SearchVESAMode. }
  2192. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2193. mode.PaletteSize := mode.MaxColor;
  2194. mode.MaxX := 1023;
  2195. mode.MaxY := 767;
  2196. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA64k;
  2197. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA64k;
  2198. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA64k;
  2199. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2200. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2201. mode.InitMode := {$ifdef fpc}@{$endif}Init1024x768x64k;
  2202. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2203. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2204. mode.XAspect := 10000;
  2205. mode.YAspect := 10000;
  2206. AddMode(mode);
  2207. end;
  2208. if SearchVESAModes(m1280x1024x16) then
  2209. begin
  2210. InitMode(mode);
  2211. mode.ModeNumber:=m1280x1024x16;
  2212. mode.DriverNumber := VESA;
  2213. mode.ModeName:='1280 x 1024 VESA';
  2214. mode.MaxColor := 16;
  2215. { the ModeInfo is automatically set if the mode is supported }
  2216. { by the call to SearchVESAMode. }
  2217. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2218. mode.DirectColor := FALSE;
  2219. mode.PaletteSize := mode.MaxColor;
  2220. mode.MaxX := 1279;
  2221. mode.MaxY := 1023;
  2222. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA16;
  2223. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2224. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2225. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA16;
  2226. (* mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA16; *)
  2227. mode.InitMode := {$ifdef fpc}@{$endif}Init1280x1024x16;
  2228. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2229. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2230. mode.XAspect := 10000;
  2231. mode.YAspect := 10000;
  2232. AddMode(mode);
  2233. end;
  2234. if SearchVESAModes(m1280x1024x256) then
  2235. begin
  2236. InitMode(mode);
  2237. mode.ModeNumber:=m1280x1024x256;
  2238. mode.DriverNumber := VESA;
  2239. mode.ModeName:='1280 x 1024 VESA';
  2240. mode.MaxColor := 256;
  2241. { the ModeInfo is automatically set if the mode is supported }
  2242. { by the call to SearchVESAMode. }
  2243. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2244. mode.DirectColor := FALSE;
  2245. mode.PaletteSize := mode.MaxColor;
  2246. mode.MaxX := 1279;
  2247. mode.MaxY := 1023;
  2248. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA256;
  2249. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA256;
  2250. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA256;
  2251. mode.InitMode := {$ifdef fpc}@{$endif}Init1280x1024x256;
  2252. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2253. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2254. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2255. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2256. mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
  2257. mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
  2258. mode.XAspect := 10000;
  2259. mode.YAspect := 10000;
  2260. AddMode(mode);
  2261. end;
  2262. if SearchVESAModes(m1280x1024x32k) then
  2263. begin
  2264. InitMode(mode);
  2265. mode.ModeNumber:=m1280x1024x32k;
  2266. mode.DriverNumber := VESA;
  2267. mode.ModeName:='1280 x 1024 VESA';
  2268. mode.MaxColor := 32768;
  2269. { the ModeInfo is automatically set if the mode is supported }
  2270. { by the call to SearchVESAMode. }
  2271. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2272. mode.DirectColor := TRUE;
  2273. mode.PaletteSize := mode.MaxColor;
  2274. mode.MaxX := 1279;
  2275. mode.MaxY := 1023;
  2276. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA32k;
  2277. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA32k;
  2278. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA32k;
  2279. mode.InitMode := {$ifdef fpc}@{$endif}Init1280x1024x32k;
  2280. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2281. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2282. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2283. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2284. mode.XAspect := 10000;
  2285. mode.YAspect := 10000;
  2286. AddMode(mode);
  2287. end;
  2288. if SearchVESAModes(m1280x1024x64k) then
  2289. begin
  2290. InitMode(mode);
  2291. mode.ModeNumber:=m1280x1024x64k;
  2292. mode.DriverNumber := VESA;
  2293. mode.ModeName:='1280 x 1024 VESA';
  2294. mode.MaxColor := 65536;
  2295. { the ModeInfo is automatically set if the mode is supported }
  2296. { by the call to SearchVESAMode. }
  2297. mode.HardwarePages := VESAModeInfo.NumberOfPages;
  2298. mode.DirectColor := TRUE;
  2299. mode.PaletteSize := mode.MaxColor;
  2300. mode.MaxX := 1279;
  2301. mode.MaxY := 1023;
  2302. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixVESA64k;
  2303. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixVESA64k;
  2304. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA64k;
  2305. mode.InitMode := {$ifdef fpc}@{$endif}Init1280x1024x64k;
  2306. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
  2307. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
  2308. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
  2309. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
  2310. mode.XAspect := 10000;
  2311. mode.YAspect := 10000;
  2312. AddMode(mode);
  2313. end;
  2314. end;
  2315. end;
  2316. {
  2317. $Log$
  2318. Revision 1.21 1999-09-27 23:34:40 peter
  2319. * new graph unit is default for go32v2
  2320. * removed warnings/notes
  2321. Revision 1.20 1999/09/26 13:31:06 jonas
  2322. * changed name of modeinfo variable to vesamodeinfo and fixed
  2323. associated errors (fillchar(modeinfo,sizeof(tmodeinfo),#0) instead
  2324. of sizeof(TVesamodeinfo) etc)
  2325. * changed several sizeof(type) to sizeof(varname) to avoid similar
  2326. errors in the future
  2327. Revision 1.19 1999/09/24 22:52:38 jonas
  2328. * optimized patternline a bit (always use hline when possible)
  2329. * isgraphmode stuff cleanup
  2330. * vesainfo.modelist now gets disposed in cleanmode instead of in
  2331. closegraph (required moving of some declarations from vesa.inc to
  2332. new vesah.inc)
  2333. * queryadapter gets no longer called from initgraph (is called from
  2334. initialization of graph unit)
  2335. * bugfix for notput in 32k and 64k vesa modes
  2336. * a div replaced by / in fillpoly
  2337. Revision 1.18 1999/09/24 14:22:38 jonas
  2338. + getscanline16
  2339. Revision 1.17 1999/09/24 11:31:38 jonas
  2340. * fixed another typo :(
  2341. Revision 1.16 1999/09/23 14:00:41 jonas
  2342. * -dlogging no longer required to fuction correctly
  2343. * some typo's fixed
  2344. Revision 1.15 1999/09/22 13:13:34 jonas
  2345. * renamed text.inc -> gtext.inc to avoid conflict with system unit
  2346. * fixed textwidth
  2347. * isgraphmode now gets properly updated, so mode restoring works
  2348. again
  2349. Revision 1.14 1999/09/18 22:21:09 jonas
  2350. + hlinevesa256 and vlinevesa256
  2351. + support for not/xor/or/andput in vesamodes with 32k/64k colors
  2352. * lots of changes to avoid warnings under FPC
  2353. Revision 1.13 1999/09/18 16:03:36 jonas
  2354. * graph.pp: removed pieslice and sector from ToDo list
  2355. * closegraph: exits now immidiately if isgraphmode = false (caused
  2356. RTE 204 with VESA enabled if you set exitproc to call closegraph
  2357. and also called closegraph explicitely before exit, like bgidemo)
  2358. Revision 1.12 1999/09/15 13:37:50 jonas
  2359. * small change to internalellipsedef to be TP compatible
  2360. * fixed directputpixel for vga 320*200*256
  2361. Revision 1.11 1999/09/12 17:28:59 jonas
  2362. * several changes to internalellipse to make it faster
  2363. and to make sure it updates the ArcCall correctly
  2364. (not yet done for width = 3)
  2365. * Arc mostly works now, only sometimes an endless loop, don't know
  2366. why
  2367. Revision 1.10 1999/09/11 19:43:01 jonas
  2368. * FloodFill: did not take into account current viewport settings
  2369. * GetScanLine: only get line inside viewport, data outside of it
  2370. is not used anyway
  2371. * InternalEllipseDefault: fix for when xradius or yradius = 0 and
  2372. increase xradius and yradius always by one (TP does this too)
  2373. * fixed conlict in vesa.inc from last update
  2374. * some conditionals to avoid range check and overflow errors in
  2375. places where it doesn't matter
  2376. Revision 1.9 1999/08/01 14:50:51 jonas
  2377. * fixed hline16 and vline16 for notput (also TP supports copy, and, or, xor and
  2378. notput for lines!!)
  2379. * fixed directputpixel16 to support all the different put types
  2380. Revision 1.8 1999/07/18 15:07:19 jonas
  2381. + xor-, and and- orput support for VESA256 modes
  2382. * compile with -dlogging if you want some info to be logged to grlog.txt
  2383. Revision 1.7 1999/07/14 18:18:02 florian
  2384. * cosmetic changes
  2385. Revision 1.6 1999/07/14 18:16:23 florian
  2386. * HLine16 and VLine16 implemented
  2387. Revision 1.5 1999/07/14 14:32:12 florian
  2388. * small VGA detection problem solved
  2389. Revision 1.4 1999/07/12 13:27:08 jonas
  2390. + added Log and Id tags
  2391. * added first FPC support, only VGA works to some extend for now
  2392. * use -dasmgraph to use assembler routines, otherwise Pascal
  2393. equivalents are used
  2394. * use -dsupportVESA to support VESA (crashes under FPC for now)
  2395. * only dispose vesainfo at closegrph if a vesa card was detected
  2396. * changed int32 to longint (int32 is not declared under FPC)
  2397. * changed the declaration of almost every procedure in graph.inc to
  2398. "far;" because otherwise you can't assign them to procvars under TP
  2399. real mode (but unexplainable "data segnment too large" errors prevent
  2400. it from working under real mode anyway)
  2401. }