graph.inc 81 KB

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