graph.inc 86 KB

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