graph.inc 80 KB

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