graph.pp 92 KB

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