OSDN Git Service

wwww
[proj16/16.git] / 16 / v2 / source / verge / ENGINE / VESA.C
1 /*\r
2 Copyright (C) 1998 BJ Eirich (aka vecna)\r
3 This program is free software; you can redistribute it and/or\r
4 modify it under the terms of the GNU General Public License\r
5 as published by the Free Software Foundation; either version 2\r
6 of the License, or (at your option) any later version.\r
7 This program is distributed in the hope that it will be useful,\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
10 See the GNU General Public Lic\r
11 See the GNU General Public License for more details.\r
12 You should have received a copy of the GNU General Public License\r
13 along with this program; if not, write to the Free Software\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r
15 */\r
16 \r
17 #include <pc.h>\r
18 #include <dpmi.h>\r
19 #include <go32.h>\r
20 \r
21 #include <dpmi.h>\r
22 #include <sys\nearptr.h>\r
23 #include "verge.h"\r
24 \r
25 // ================================= Data ====================================\r
26 \r
27 byte *vesascreen, *vesascreenx;             // virscr | realscr\r
28 \r
29 // ================================= Code ====================================\r
30 \r
31 void VESASetMode(int mode)\r
32 {\r
33   REGISTERS r;\r
34   SET_AX(r, mode);\r
35   INTERRUPT(0x10, r);\r
36 }\r
37 \r
38 int VESAShutdown(void)\r
39 {\r
40   VESASetMode(0x3);\r
41   free(vesascreen);\r
42   return 0;\r
43 }\r
44 \r
45 void VESASetBank(int bank)\r
46 {\r
47   REGISTERS r;\r
48   SET_AX(r, 0x4f05);\r
49   SET_BX(r, 0);\r
50   SET_DX(r, bank);\r
51   INTERRUPT(0x10, r);\r
52 }\r
53 \r
54 int VESAShowPage(void)\r
55 { byte *s,*d;\r
56   int y,bytes,bank;\r
57   int span;\r
58 \r
59   RenderGUI();\r
60   cpubyte=PFLIP;\r
61 \r
62   s=vesascreen+(16*tsx)+16;\r
63   d=vesascreenx;\r
64 \r
65   bank=0;\r
66   bytes=65536;\r
67   VESASetBank(bank++);\r
68 \r
69   for (y=sy; y; y--)\r
70   {\r
71     if (bytes >= sx)\r
72     { memcpy(d,s,sx);\r
73       bytes-=sx;\r
74       s+=sx;\r
75       d+=sx;\r
76     }\r
77     else\r
78     { memcpy(d,s,bytes);\r
79       s+=bytes;\r
80       span=sx-bytes;\r
81 \r
82       VESASetBank(bank++);\r
83       d=vesascreenx;\r
84       bytes=65536;\r
85 \r
86       memcpy(d,s,span);\r
87       bytes-=span;\r
88       s+=span;\r
89       d+=span;\r
90     }\r
91     s+=32;\r
92   }\r
93 \r
94   cpubyte=ETC;\r
95   return 0;\r
96 }\r
97 \r
98 int VESACopySprite(int x, int y, int width, int height, byte *src)\r
99 {\r
100   cpubyte=RENDER;\r
101 \r
102   asm("movl %3, %%edx                   \n\t"\r
103       "movl %4, %%esi                   \n\t"\r
104 "csl0:                                  \n\t"\r
105       "movl %1, %%eax                   \n\t"\r
106       "imul $672, %%eax                 \n\t"\r
107       "addl %0, %%eax                   \n\t"\r
108       "addl _vesascreen, %%eax          \n\t"\r
109       "movl %%eax, %%edi                \n\t"\r
110       "movl %2, %%ecx                   \n\t"\r
111       "shrl $2, %%ecx                   \n\t"\r
112       "repz                             \n\t"\r
113       "movsl                            \n\t"\r
114       "incl %1                          \n\t"\r
115       "decl %%edx                       \n\t"\r
116       "jnz csl0                         \n\t"\r
117       :\r
118       : "m" (x), "m" (y), "m" (width), "m" (height), "m" (src)\r
119       : "eax","edx","esi","edi","ecx","cc" );\r
120   cpubyte=ETC;\r
121   return 0;\r
122 }\r
123 \r
124 int VESACCopySprite(int x,int y,int width,int height,byte *src)\r
125 {\r
126   byte *s,*d;\r
127   int xl,yl,xs,ys;\r
128   int cx1=0, cy1=0, cx2=tsx-1, cy2=tsy-1;\r
129 \r
130   cpubyte=RENDER;\r
131 \r
132   xl=width;\r
133   yl=height;\r
134   xs=ys=0;\r
135 \r
136   if (x>cx2 || y>cy2 || x+xl<cx1 || y+yl<cy1)\r
137     return 0;\r
138 \r
139   if (x+xl > cx2) xl=cx2-x+1;\r
140   if (y+yl > cy2) yl=cy2-y+1;\r
141 \r
142   if (x<cx1) { xs=cx1-x; xl-=xs; x=cx1; }\r
143   if (y<cy1) { ys=cy1-y; yl-=ys; y=cy1; }\r
144 \r
145   s=src;\r
146   if (xs+ys) s+=(ys*width)+xs;\r
147   d=vesascreen+(y*tsx)+x;\r
148 \r
149   for (; yl; yl--)\r
150   {\r
151     memcpy(d,s,xl);\r
152     s+=width;\r
153     d+=tsx;\r
154   }\r
155 \r
156   cpubyte=ETC;\r
157   return 0;\r
158 }\r
159 \r
160 int VESATCCopySprite(int x,int y,int width,int height,byte *src)\r
161 {\r
162   byte *s,*d,c;\r
163   int xl,yl,xs,ys;\r
164   int cx1=0, cy1=0, cx2=tsx-1, cy2=tsy-1;\r
165 \r
166   cpubyte=RENDER;\r
167 \r
168   xl=width;\r
169   yl=height;\r
170   xs=ys=0;\r
171 \r
172   if (x>cx2 || y>cy2 || x+xl<cx1 || y+yl<cy1)\r
173     return 0;\r
174 \r
175   if (x+xl > cx2) xl=cx2-x+1;\r
176   if (y+yl > cy2) yl=cy2-y+1;\r
177 \r
178   if (x<cx1) { xs=cx1-x; xl-=xs; x=cx1; }\r
179   if (y<cy1) { ys=cy1-y; yl-=ys; y=cy1; }\r
180 \r
181   s=src;\r
182   if (xs+ys) s+=(ys*width)+xs;\r
183   d=vesascreen+(y*tsx)+x;\r
184 \r
185   for (; yl; yl--)\r
186   {\r
187     for (x=0; x<xl; x++)\r
188     {\r
189       c=s[x];\r
190       if (c)\r
191         d[x]=c;\r
192     }\r
193     s+=width;\r
194     d+=tsx;\r
195   }\r
196 \r
197   cpubyte=ETC;\r
198   return 0;\r
199 }\r
200 \r
201 int VESACopyTile(int x, int y, byte *spr)\r
202 {\r
203   int h;\r
204   byte *d;\r
205 \r
206   cpubyte=RENDER;\r
207 \r
208   h=16;\r
209 \r
210   d=vesascreen+(y*tsx)+x;\r
211   for (; h; h--)\r
212   {\r
213     memcpy(d, spr, 16);\r
214     spr+=16;\r
215     d+=tsx;\r
216   }\r
217 \r
218   cpubyte=ETC;\r
219   return 0;\r
220 }\r
221 \r
222 int VESATCopySprite(int x, int y, int width, int height, byte *src)\r
223 {\r
224   cpubyte=RENDER;\r
225 \r
226   asm("movl %3, %%ecx                   \n\t"\r
227       "movl %4, %%esi                   \n\t"\r
228 "tcsl0:                                 \n\t"\r
229       "movl %1, %%eax                   \n\t"\r
230       "imul $672, %%eax                 \n\t"\r
231       "addl %0, %%eax                   \n\t"\r
232       "addl _vesascreen, %%eax          \n\t"\r
233       "movl %%eax, %%edi                \n\t"\r
234       "movl %2, %%edx                   \n\t"\r
235 "drawloop:                              \n\t"\r
236       "lodsb                            \n\t"\r
237       "orb %%al, %%al                   \n\t"\r
238       "jz nodraw                        \n\t"\r
239       "stosb                            \n\t"\r
240       "decl %%edx                       \n\t"\r
241       "jz endline                       \n\t"\r
242       "jmp drawloop                     \n\t"\r
243 "nodraw:                                \n\t"\r
244       "incl %%edi                       \n\t"\r
245       "decl %%edx                       \n\t"\r
246       "jnz drawloop                     \n\t"\r
247 "endline:                               \n\t"\r
248       "incl %1                          \n\t"\r
249       "decl %%ecx                       \n\t"\r
250       "jnz tcsl0                        \n\t"\r
251       :\r
252       : "m" (x), "m" (y), "m" (width), "m" (height), "m" (src)\r
253       : "eax","edx","esi","edi","ecx","cc" );\r
254 \r
255   cpubyte=ETC;\r
256   return 0;\r
257 }\r
258 \r
259 int VESATCopyTile(int x, int y, byte *spr, byte *matte)\r
260 {\r
261   cpubyte=RENDER;\r
262   asm("movl $16, %%ecx                  \n\t"\r
263       "movl %2, %%esi                   \n\t"\r
264       "movl %1, %%edi                   \n\t"\r
265       "imul $672, %%edi                 \n\t"\r
266       "addl %0, %%edi                   \n\t"\r
267       "addl _vesascreen, %%edi          \n\t"\r
268       "movl %3, %%edx                   \n\t"\r
269 "tctl0:                                 \n\t"\r
270       "movl (%%edi), %%eax              \n\t"\r
271       "andl (%%edx), %%eax              \n\t"\r
272       "orl  (%%esi), %%eax              \n\t"\r
273       "movl %%eax, (%%edi)              \n\t"\r
274       "movl 4(%%edi), %%eax             \n\t"\r
275       "andl 4(%%edx), %%eax             \n\t"\r
276       "orl  4(%%esi), %%eax             \n\t"\r
277       "movl %%eax, 4(%%edi)             \n\t"\r
278       "movl 8(%%edi), %%eax             \n\t"\r
279       "andl 8(%%edx), %%eax             \n\t"\r
280       "orl  8(%%esi), %%eax             \n\t"\r
281       "movl %%eax, 8(%%edi)             \n\t"\r
282       "movl 12(%%edi), %%eax            \n\t"\r
283       "andl 12(%%edx), %%eax            \n\t"\r
284       "orl  12(%%esi), %%eax            \n\t"\r
285       "movl %%eax, 12(%%edi)            \n\t"\r
286       "addl $16, %%esi                  \n\t"\r
287       "addl $672, %%edi                 \n\t"\r
288       "addl $16, %%edx                  \n\t"\r
289       "decl %%ecx                       \n\t"\r
290       "jnz tctl0                        \n\t"\r
291       :\r
292       : "m" (x), "m" (y), "m" (spr), "m" (matte)\r
293       : "eax","ecx","edx","esi","edi","cc" );\r
294 \r
295   cpubyte=ETC;\r
296   return 0;\r
297 }\r
298 \r
299 int VESAScaleSprite(int x, int y, int w, int h, int tw, int th, byte *s)\r
300 {\r
301   int i,j,xm,ym,xd,yd,sx,sy=0,xs,ys,dys=0;\r
302   unsigned char *d;\r
303 \r
304   cpubyte=RENDER;\r
305 \r
306   if (!tw || !th) return 0;\r
307   tw += sgn(tw); th += sgn(th);\r
308   xm = abs(tw); ym = abs(th);\r
309   xs = (w<<16)/xm; ys = (h<<16)/ym;\r
310   xd = sgn(tw); yd = sgn(th);\r
311 \r
312   if (tw>0 && th>0) dys=tsx-xm;\r
313   else if (tw>0 && th<0) dys=(0-tsx)-xm;\r
314   else if (tw<0 && th>0) dys=tsx+xm;\r
315   else if (tw<0 && th<0) dys=(0-tsx)+xm;\r
316 \r
317   d = vesascreen+(y*tsx)+x;\r
318   for (i=0;i<ym;++i) {\r
319     sx=0;\r
320     for (j=0;j<xm;++j) {\r
321       *d=s[(sx>>16)];\r
322       d+=xd;\r
323       sx+=xs;\r
324       }\r
325     d+=dys;\r
326     sy+=ys;\r
327     s+=(sy>>16)*w;\r
328     sy&=0xffff;\r
329     }\r
330   cpubyte=ETC;\r
331   return 0;\r
332 }\r
333 \r
334 int VESARenderMAPLine(int x, int y, int yofs, word *map)\r
335 {\r
336   cpubyte=RENDER;\r
337   // ...\r
338   cpubyte=ETC;\r
339   return 0;\r
340 }\r
341 \r
342 int VESATRenderMAPLine(int x, int y, int yofs, word *map)\r
343 {\r
344   cpubyte=RENDER;\r
345   // ...\r
346   cpubyte=ETC;\r
347   return 0;\r
348 }\r
349 \r
350 int VESAColorField(int x, int y, byte c)\r
351 {\r
352   cpubyte=RENDER;\r
353   // ...\r
354   cpubyte=ETC;\r
355   return 0;\r
356 }\r
357 \r
358 int VESAClearScreen()\r
359 {\r
360   cpubyte=RENDER;\r
361   memset(vesascreen+(672*16)+16,0,(672*480));\r
362   cpubyte=ETC;\r
363   return 0;\r
364 }\r
365 \r
366 int VESAPutPixel(int x, int y, int color)\r
367 {\r
368   cpubyte=RENDER;\r
369 \r
370   if (x<cx1 || y<cy1 || x>cx2 || y>cy2)\r
371   {\r
372     cpubyte=ETC;\r
373     return 0;\r
374   }\r
375 \r
376   x+=16;\r
377   y+=16;\r
378 \r
379   vesascreen[(y*tsx)+x]=color;\r
380 \r
381   cpubyte=ETC;\r
382   return 0;\r
383 }\r
384 \r
385 int VESAGetPixel(int x, int y)\r
386 {\r
387   cpubyte=RENDER;\r
388 \r
389   if (x<cx1 || y<cy1 || x>cx2 || y>cy2)\r
390   {\r
391     cpubyte=ETC;\r
392     return 0;\r
393   }\r
394 \r
395   x+=16;\r
396   y+=16;\r
397 \r
398   cpubyte=ETC;\r
399   return vesascreen[(y*tsx)+x];\r
400   return 0;\r
401 }\r
402 \r
403 int VESAHLine(int x, int y, int x2, int color)\r
404 {\r
405   byte *d;\r
406   int width;\r
407 \r
408   cpubyte=RENDER;\r
409 \r
410   // swap?\r
411   if (x2<x) { int t=x2; x=x2; x2=t; }\r
412 \r
413   width=x2-x+1;\r
414   if (x>cx2 || y>cy2 || x+width<cx1 || y<cy1)\r
415     return 0;\r
416 \r
417   if (x+width > cx2) width=cx2-x+1;\r
418   if (x<cx1) { width-=(cx1-x); x=cx1; }\r
419 \r
420   x+=16;\r
421   y+=16;\r
422   x2+=16;\r
423 \r
424   d=vesascreen+(y*tsx)+x;\r
425   memset(d,color,width);\r
426 \r
427   cpubyte=ETC;\r
428   return 0;\r
429 }\r
430 \r
431 int VESAVLine(int x, int y, int y2, int color)\r
432 {\r
433   byte *d;\r
434   int height;\r
435 \r
436   cpubyte=RENDER;\r
437 \r
438   // swap?\r
439   if (y2<y) { int t=y2; x=y2; y2=t; }\r
440 \r
441   height=y2-y+1;\r
442   if (x>cx2 || y>cy2 || x<cx1 || y+height<cy1)\r
443   {\r
444     cpubyte=ETC;\r
445     return 0;\r
446   }\r
447 \r
448   if (y+height > cy2) height=cy2-y+1;\r
449   if (y<cy1) { height-=(cy1-y); y=cy1; }\r
450 \r
451   x+=16;\r
452   y+=16;\r
453   y2+=16;\r
454 \r
455   d=vesascreen+(y*tsx)+x;\r
456   for (; height; height--)\r
457   {\r
458     *d=color;\r
459     d+=tsx;\r
460   }\r
461 \r
462   cpubyte=ETC;\r
463   return 0;\r
464 }\r
465 \r
466 int VESALine(int x1, int y1, int x2, int y2, int color)\r
467 {\r
468   short i,xc,yc,er,n,m,xi,yi,xcxi,ycyi,xcyi;\r
469   unsigned dcy,dcx;\r
470 \r
471   cpubyte=RENDER;\r
472 \r
473   // check to see if the line is completly clipped off\r
474   if ((x1<cx1 && x2<cx1) || (x1>cx2 && x2>cx2)\r
475   || (y1<cy1 && y2<cy1) || (y1>cy2 && y2>cy2))\r
476   {\r
477     cpubyte=ETC;\r
478     return 0;\r
479   }\r
480 \r
481   if (x1>x2)\r
482   {\r
483     i=x1; x1=x2; x2=i;\r
484     i=y1; y1=y2; y2=i;\r
485   }\r
486 \r
487   // clip the left side\r
488   if (x1<cx1)\r
489   { int myy=(y2-y1);\r
490     int mxx=(x2-x1),b;\r
491     if (!mxx)\r
492     {\r
493       cpubyte=ETC;\r
494       return 0;\r
495     }\r
496     if (myy)\r
497     {\r
498       b=y1-(y2-y1)*x1/mxx;\r
499       y1=myy*cx1/mxx+b;\r
500       x1=cx1;\r
501     }\r
502     else x1=cx1;\r
503   }\r
504 \r
505   // clip the right side\r
506   if (x2>cx2)\r
507   { int myy=(y2-y1);\r
508     int mxx=(x2-x1),b;\r
509     if (!mxx)\r
510     {\r
511       cpubyte=ETC;\r
512       return 0;\r
513     }\r
514     if (myy)\r
515     {\r
516       b=y1-(y2-y1)*x1/mxx;\r
517       y2=myy*cx2/mxx+b;\r
518       x2=cx2;\r
519     }\r
520     else x2=cx2;\r
521   }\r
522 \r
523   if (y1>y2)\r
524   {\r
525     i=x1; x1=x2; x2=i;\r
526     i=y1; y1=y2; y2=i;\r
527   }\r
528 \r
529   // clip the bottom\r
530   if (y2>cy2)\r
531   { int mxx=(x2-x1);\r
532     int myy=(y2-y1),b;\r
533     if (!myy)\r
534     {\r
535       cpubyte=ETC;\r
536       return 0;\r
537     }\r
538     if (mxx)\r
539     {\r
540       b=y1-(y2-y1)*x1/mxx;\r
541       x2=(cy2-b)*mxx/myy;\r
542       y2=cy2;\r
543     }\r
544     else y2=cy2;\r
545   }\r
546 \r
547   // clip the top\r
548   if (y1<cy1)\r
549   { int mxx=(x2-x1);\r
550     int myy=(y2-y1),b;\r
551     if (!myy)\r
552     {\r
553       cpubyte=ETC;\r
554       return 0;\r
555     }\r
556     if (mxx)\r
557     {\r
558       b=y1-(y2-y1)*x1/mxx;\r
559       x1=(cy1-b)*mxx/myy;\r
560       y1=cy1;\r
561     }\r
562     else y1=cy1;\r
563   }\r
564 \r
565   // ???\r
566   // see if it got cliped into the box, out out\r
567   if (x1<cx1 || x2<cx1 || x1>cx2 || x2>cx2 || y1<cy1 || y2 <cy1 || y1>cy2 || y2>cy2)\r
568   {\r
569     cpubyte=ETC;\r
570     return 0;\r
571   }\r
572 \r
573   if (x1>x2)\r
574   { xc=x2; xi=x1; }\r
575   else { xi=x2; xc=x1; }\r
576 \r
577   x1+=16;y1+=16; // aen; adjust these here??\r
578   x2+=16;y2+=16;\r
579 \r
580   // assume y1<=y2 from above swap operation\r
581   yi=y2; yc=y1;\r
582 \r
583   dcx=x1; dcy=y1;\r
584   xc=(x2-x1); yc=(y2-y1);\r
585   if (xc<0) xi=-1; else xi=1;\r
586   if (yc<0) yi=-1; else yi=1;\r
587   n=abs(xc); m=abs(yc);\r
588   ycyi=abs(2*yc*xi);\r
589   er=0;\r
590 \r
591   if (n>m)\r
592   {\r
593     xcxi=abs(2*xc*xi);\r
594     for (i=0;i<=n;i++)\r
595     {\r
596       vesascreen[(dcy*tsx)+dcx]=color;\r
597       if (er>0)\r
598       { dcy+=yi;\r
599         er-=xcxi;\r
600       }\r
601       er+=ycyi;\r
602       dcx+=xi;\r
603     }\r
604   }\r
605   else\r
606   {\r
607     xcyi=abs(2*xc*yi);\r
608     for (i=0;i<=m;i++)\r
609     {\r
610       vesascreen[(dcy*tsx)+dcx]=color;\r
611       if (er>0)\r
612       { dcx+=xi;\r
613         er-=ycyi;\r
614       }\r
615       er+=xcyi;\r
616       dcy+=yi;\r
617     }\r
618   }\r
619 \r
620   cpubyte=ETC;\r
621   return 0;\r
622 }\r
623 \r
624 int VESACircle(int x, int y, int radius, int color)\r
625 {\r
626   int cx=0;\r
627   int cy=radius;\r
628   int df=1-radius;\r
629   int d_e=3;\r
630   int d_se=-2*radius+5;\r
631 \r
632   cpubyte=RENDER;\r
633 \r
634   do {\r
635     VESAPutPixel(x+cx,y+cy,color);\r
636     if (cx) VESAPutPixel(x-cx,y+cy,color);\r
637     if (cy) VESAPutPixel(x+cx,y-cy,color);\r
638     if ((cx) && (cy)) VESAPutPixel(x-cx,y-cy,color);\r
639 \r
640     if (cx != cy)\r
641     {\r
642       VESAPutPixel(x+cy,y+cx,color);\r
643       if (cx) VESAPutPixel(x+cy,y-cx,color);\r
644       if (cy) VESAPutPixel(x-cy,y+cx,color);\r
645       if (cx && cy) VESAPutPixel(x-cy,y-cx,color);\r
646     }\r
647 \r
648     if (df<0)\r
649     {\r
650       df+=d_e;\r
651       d_e+=2;\r
652       d_se+=2;\r
653     }\r
654     else\r
655     {\r
656       df+=d_se;\r
657       d_e+=2;\r
658       d_se+=4;\r
659       cy--;\r
660     }\r
661 \r
662     cx++;\r
663 \r
664   } while (cx <= cy);\r
665 \r
666   cpubyte=ETC;\r
667   return 0;\r
668 }\r
669 \r
670 int VESACircleFill(int x, int y, int radius, int color)\r
671 {\r
672   int cx=0;\r
673   int cy=radius;\r
674   int df=1-radius;\r
675   int d_e=3;\r
676   int d_se=-2*radius+5;\r
677 \r
678   cpubyte=RENDER;\r
679 \r
680   do {\r
681     VESAHLine(x-cy,y-cx,x+cy,color);\r
682     if (cx) VESAHLine(x-cy,y+cx,x+cy,color);\r
683 \r
684     if (df<0)\r
685     {\r
686       df+=d_e;\r
687       d_e+=2;\r
688       d_se+=2;\r
689     }\r
690     else\r
691     {\r
692       if (cx != cy)\r
693       {\r
694         VESAHLine(x-cx,y-cy,x+cx,color);\r
695         if (cy) VESAHLine(x-cx,y+cy,x+cx,color);\r
696       }\r
697 \r
698       df+=d_se;\r
699       d_e+=2;\r
700       d_se+=4;\r
701       cy--;\r
702     }\r
703 \r
704     cx++;\r
705 \r
706   } while (cx <= cy);\r
707 \r
708   cpubyte=ETC;\r
709   return 0;\r
710 }\r
711 \r
712 int VESARect(int x, int y, int x2, int y2, int color)\r
713 {\r
714   VESAHLine(x,y,x2,color);\r
715   VESAHLine(x,y2,x2,color);\r
716   VESAVLine(x,y+1,y2-1,color);\r
717   VESAVLine(x2,y+1,y2-1,color);\r
718   return 0;\r
719 }\r
720 \r
721 int VESARectFill(int x, int y, int x2, int y2, int color)\r
722 {\r
723   cpubyte=RENDER;\r
724 \r
725   if (y2<y) { int t=y2; y=y2; y2=t; }\r
726 \r
727   for (; y<=y2; y++)\r
728     VESAHLine(x,y,x2,color);\r
729 \r
730   cpubyte=ETC;\r
731   return 0;\r
732 }\r
733 \r
734 void InitVESA(void)\r
735 {\r
736   REGISTERS r;\r
737 \r
738   SET_BX(r, 0x0101);\r
739   SET_AX(r, 0x4f02);\r
740   INTERRUPT(0x10, r);\r
741 \r
742   vesascreenx = (byte *) 0xA0000 + __djgpp_conventional_base;\r
743   vesascreen = (byte *) valloc(344064, "vesascreen", 0);\r
744   memset(vesascreen, 0, 344064);\r
745 \r
746   sx=640;  sy=480;\r
747   tsx=672; tsy=512;\r
748   tx=40;   ty=30;\r
749   cx1=0;   cy1=0;\r
750   cx2=sx-1;cy2=sy-1;\r
751 \r
752   // Mode successfuly set, now lets set up the driver.\r
753   ShutdownVideo = VESAShutdown;\r
754   ShowPage = VESAShowPage;\r
755   CopySprite = VESACopySprite;\r
756   TCopySprite = VESATCopySprite;\r
757   CCopySprite = VESACCopySprite;\r
758   TCCopySprite = VESATCCopySprite;\r
759   CopyTile = VESACopyTile;\r
760   TCopyTile = VESATCopyTile;\r
761   ScaleSprite = VESAScaleSprite;\r
762   RenderMAPLine = VESARenderMAPLine;\r
763   TRenderMAPLine = VESATRenderMAPLine;\r
764   ColorField = VESAColorField;\r
765   ClearScreen = VESAClearScreen;\r
766   PutPixel = VESAPutPixel;\r
767   GetPixel = VESAGetPixel;\r
768   HLine = VESAHLine;\r
769   VLine = VESAVLine;\r
770   Line = VESALine;\r
771   Circle = VESACircle;\r
772   CircleFill = VESACircleFill;\r
773   Rect = VESARect;\r
774   RectFill = VESARectFill;\r
775   DriverDesc = "640x480 (VESA, Banked)";\r
776 }\r