graph.pp 90 KB

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