graph.pp 84 KB

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