1 #include "executor.h"
\r
6 static unsigned char MMXBuffer[8];
\r
8 void DBFillScreen(unsigned long c)
\r
13 p = (unsigned long *)DblBuffer;
\r
14 for(i = 0; i < 64000; i++)
\r
18 void DBSetClip(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2)
\r
26 unsigned long DBPoint(unsigned short x, unsigned short y)
\r
28 return(*(unsigned long *)&DblBuffer[((unsigned long)y << 10) + ((unsigned long)y << 8) + ((unsigned long)x << 2)]);
\r
31 /*void DBPSet(unsigned short x, unsigned short y, unsigned long c)
\r
33 *(unsigned long *)&DblBuffer[((unsigned long)y << 10) + ((unsigned long)y << 8) + ((unsigned long)x << 2)] = c;
\r
36 void DBPSetC(unsigned short x, unsigned short y, unsigned long c)
\r
38 if ((x >= clip_x1) && (x <= clip_x2) && (y >= clip_y1) && (y <= clip_y2))
\r
39 *(unsigned long *)&DblBuffer[((unsigned long)y << 10) + ((unsigned long)y << 8) + ((unsigned long)x << 2)] = c;
\r
42 void DBPSetCTrans(unsigned short x, unsigned short y, unsigned long c, unsigned char Method)
\r
44 if ((x >= clip_x1) && (x <= clip_x2) && (y >= clip_y1) && (y <= clip_y2))
\r
45 TransOps[Method]((unsigned long *)&DblBuffer[((unsigned long)y << 10) + ((unsigned long)y << 8) + ((unsigned long)x << 2)], c);
\r
48 void DBFRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned long c)
\r
50 unsigned short y, x;
\r
52 for(y = y1; y <= y2; y++)
\r
54 for(x = x1; x <= x2; x++)
\r
61 void DBFRectTrans(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned long c, unsigned char Method)
\r
63 unsigned short y, x;
\r
65 for(y = y1; y <= y2; y++)
\r
67 for(x = x1; x <= x2; x++)
\r
69 DBPSetCTrans(x, y, c, Method);
\r
74 void DBFCircle(signed short x, signed short y, unsigned short r, unsigned long Color, unsigned char Filled, float Aspect)
\r
76 signed short y1, y2, x1, x2;
\r
77 signed short cy, cx;
\r
92 for(r2 = (unsigned long)r * (unsigned long)r; cy <= y2; cy++)
\r
94 x1 = x - (x2 = (sqrt(r2 - ((unsigned long)cy * (unsigned long)cy)) * Aspect));
\r
102 for(cx = x1; cx <= x2; cx++)
\r
103 DBPSetC(cx, y1, Color);
\r
105 DBPSetC(x1, y1, Color);
\r
106 DBPSetC(x2, y1, Color);
\r
112 void DBFCircleTrans(signed short x, signed short y, unsigned short r, unsigned long Color, unsigned char Filled, float Aspect, unsigned char Method)
\r
114 signed short y1, y2, x1, x2;
\r
115 signed short cy, cx;
\r
118 if(y - r < clip_y1)
\r
126 if(y + r > clip_y2)
\r
130 for(r2 = (unsigned long)r * (unsigned long)r; cy <= y2; cy++)
\r
132 x1 = x - (x2 = (sqrt(r2 - ((unsigned long)cy * (unsigned long)cy)) * Aspect));
\r
140 for(cx = x1; cx <= x2; cx++)
\r
141 DBPSetCTrans(cx, y1, Color, Method);
\r
143 DBPSetCTrans(x1, y1, Color, Method);
\r
144 DBPSetCTrans(x2, y1, Color, Method);
\r
150 void DBFCircleFadedTrans(signed short x, signed short y, unsigned short r, unsigned long Color, float Aspect, unsigned char Method)
\r
152 signed short y1, y2, x1, x2;
\r
153 signed short cy, cx;
\r
155 struct ColorType MainColor, MidColor, CurColor;
\r
156 unsigned short RE, GE, BE;
\r
159 if(y - r < clip_y1)
\r
167 if(y + r > clip_y2)
\r
171 MainColor = *(struct ColorType *)&Color;
\r
172 for(r2 = (unsigned long)r * (unsigned long)r; cy <= y2; cy++)
\r
176 MidColor.R = (unsigned char)(((unsigned long)MainColor.R * (unsigned long)(r + cy)) / (unsigned long)r);
\r
177 MidColor.G = (unsigned char)(((unsigned long)MainColor.G * (unsigned long)(r + cy)) / (unsigned long)r);
\r
178 MidColor.B = (unsigned char)(((unsigned long)MainColor.B * (unsigned long)(r + cy)) / (unsigned long)r);
\r
180 MidColor.R = (unsigned char)(((unsigned long)MainColor.R * (unsigned long)(r - cy)) / (unsigned long)r);
\r
181 MidColor.G = (unsigned char)(((unsigned long)MainColor.G * (unsigned long)(r - cy)) / (unsigned long)r);
\r
182 MidColor.B = (unsigned char)(((unsigned long)MainColor.B * (unsigned long)(r - cy)) / (unsigned long)r);
\r
184 *(unsigned long *)&CurColor = 0;
\r
186 x1 = x - (x2 = (sqrt(r2 - ((unsigned long)cy * (unsigned long)cy)) * Aspect));
\r
191 CurColor.R = (unsigned char)(((unsigned long)(clip_x1 - x1) * (unsigned long)MidColor.R) / (unsigned long)r);
\r
192 CurColor.G = (unsigned char)(((unsigned long)(clip_x1 - x1) * (unsigned long)MidColor.G) / (unsigned long)r);
\r
193 CurColor.B = (unsigned char)(((unsigned long)(clip_x1 - x1) * (unsigned long)MidColor.B) / (unsigned long)r);
\r
200 for(cx = x1; cx <= x2; cx++)
\r
207 DBPSetCTrans(cx, y1, *(unsigned long *)&CurColor, Method);
\r
208 RE += (unsigned short)MidColor.R;
\r
209 GE += (unsigned short)MidColor.G;
\r
210 BE += (unsigned short)MidColor.B;
\r
231 void DBFPoly(signed short x1, signed short y1, signed short x2, signed short y2, signed short x3, signed short y3, unsigned long Color)
\r
233 signed short x[3], y[3], Temp, m1, m2;
\r
234 signed short i, o, StartX, StopX;
\r
235 signed long k1, k2, cx1, cx2;
\r
237 x[0] = x1; y[0] = y1;
\r
238 x[1] = x2; y[1] = y2;
\r
239 x[2] = x3; y[2] = y3;
\r
240 for(i = 0; i < 2; i++)
\r
242 for(o = i + 1; o < 3; o++)
\r
255 cx1 = cx2 = x[0] << 16;
\r
260 k1 = ((signed long)(x[1] - x[0]) << 16) / (signed long)(y[1] - y[0]);
\r
261 k2 = ((signed long)(x[2] - x[0]) << 16) / (signed long)(y[2] - y[0]);
\r
262 for(i = y[0]; i <= y[1]; i++)
\r
264 if((i >= clip_y1) && (i <= clip_y2))
\r
268 StartX = cx2 >> 16;
\r
271 StartX = cx1 >> 16;
\r
274 if(StartX < clip_x1)
\r
276 if(StopX > clip_x2)
\r
278 if((StartX <= clip_x2) && (StopX >= clip_x1))
\r
280 for(o = StartX; o <= StopX; o++)
\r
281 DBPSetC(o, i, Color);
\r
289 : "a" (Color), "c" ((abs(x1 - x2) >> 16) + 1), "D" ((unsigned long)DblBuffer + ((unsigned long)i << 10) + ((unsigned long)i << 8) + (((x1 < x2)?x1:x2) >> 14))
\r
297 k1 = ((signed long)(x[2] - x[1]) << 16) / (signed long)(y[2] - y[1]);
\r
298 k2 = ((signed long)(x[2] - x[0]) << 16) / (signed long)(y[2] - y[0]);
\r
299 for(i = y[1] + 1; i <= y[2]; i++)
\r
301 if((i >= clip_y1) && (i <= clip_y2))
\r
305 StartX = cx2 >> 16;
\r
308 StartX = cx1 >> 16;
\r
311 if(StartX < clip_x1)
\r
313 if(StopX > clip_x2)
\r
315 if((StartX <= clip_x2) && (StopX >= clip_x1))
\r
317 for(o = StartX; o <= StopX; o++)
\r
318 DBPSetC(o, i, Color);
\r
326 : "a" (Color), "c" ((abs(x1 - x2) >> 16) + 1), "D" ((unsigned long)DblBuffer + ((unsigned long)i << 10) + ((unsigned long)i << 8) + (((x1 < x2)?x1:x2) >> 14))
\r
333 void DBFPolyTrans(signed short x1, signed short y1, signed short x2, signed short y2, signed short x3, signed short y3, unsigned long Color, unsigned char Method)
\r
335 signed short x[3], y[3], Temp, m1, m2;
\r
336 signed short i, o, StartX, StopX;
\r
337 signed long k1, k2, cx1, cx2;
\r
339 x[0] = x1; y[0] = y1;
\r
340 x[1] = x2; y[1] = y2;
\r
341 x[2] = x3; y[2] = y3;
\r
342 for(i = 0; i < 2; i++)
\r
344 for(o = i + 1; o < 3; o++)
\r
357 cx1 = cx2 = x[0] << 16;
\r
362 k1 = ((signed long)(x[1] - x[0]) << 16) / (signed long)(y[1] - y[0]);
\r
363 k2 = ((signed long)(x[2] - x[0]) << 16) / (signed long)(y[2] - y[0]);
\r
364 for(i = y[0]; i <= y[1]; i++)
\r
366 if((i >= clip_y1) && (i <= clip_y2))
\r
370 StartX = cx2 >> 16;
\r
373 StartX = cx1 >> 16;
\r
376 if(StartX < clip_x1)
\r
378 if(StopX > clip_x2)
\r
380 if((StartX <= clip_x2) && (StopX >= clip_x1))
\r
382 for(o = StartX; o <= StopX; o++)
\r
383 DBPSetCTrans(o, i, Color, Method);
\r
394 k1 = ((signed long)(x[2] - x[1]) << 16) / (signed long)(y[2] - y[1]);
\r
395 k2 = ((signed long)(x[2] - x[0]) << 16) / (signed long)(y[2] - y[0]);
\r
396 for(i = y[1] + 1; i <= y[2]; i++)
\r
398 if((i >= clip_y1) && (i <= clip_y2))
\r
402 StartX = cx2 >> 16;
\r
405 StartX = cx1 >> 16;
\r
408 if(StartX < clip_x1)
\r
410 if(StopX > clip_x2)
\r
412 if((StartX <= clip_x2) && (StopX >= clip_x1))
\r
414 for(o = StartX; o <= StopX; o++)
\r
415 DBPSetCTrans(o, i, Color, Method);
\r
423 void DBLine(signed short x1, signed short y1, signed short x2, signed short y2, unsigned long c1, unsigned long c2)
\r
425 signed short dx, dy, x, y;
\r
426 signed short xi, yi, d;
\r
452 for(i = 0; i <= dx; i++)
\r
454 DBPSetC((unsigned short)x, (unsigned short)y, ((c ^= 1) == 0)?c2:c1);
\r
464 for(i = 0; i <= dy; i++)
\r
466 DBPSetC((unsigned short)x, (unsigned short)y, ((c ^= 1) == 0)?c2:c1);
\r
478 void DBLineTrans(signed short x1, signed short y1, signed short x2, signed short y2, unsigned long c1, unsigned long c2, unsigned char Method)
\r
480 signed short dx, dy, x, y;
\r
481 signed short xi, yi, d;
\r
507 for(i = 0; i <= dx; i++)
\r
509 DBPSetCTrans((unsigned short)x, (unsigned short)y, ((c ^= 1) == 0)?c2:c1, Method);
\r
519 for(i = 0; i <= dy; i++)
\r
521 DBPSetCTrans((unsigned short)x, (unsigned short)y, ((c ^= 1) == 0)?c2:c1, Method);
\r
533 void DBCopyBuffer(signed short x, signed short y, unsigned char *Buffer, unsigned short w, unsigned short h, unsigned long bgc)
\r
535 unsigned char *WorkOffset;
\r
536 unsigned long offset;
\r
537 unsigned long OffsetAdd;
\r
538 unsigned short cx, cy;
\r
539 unsigned long data;
\r
542 WorkOffset = DblBuffer + ((signed long)y << 10) + ((signed long)y << 8) + ((signed long)x << 2);
\r
543 OffsetAdd = 1280 - (w << 2);
\r
544 for(cy = 0; cy < h; cy++)
\r
546 for(cx = 0; cx < w; cx++)
\r
548 data = *(unsigned long *)Buffer;
\r
550 *(unsigned long *)WorkOffset = data;
\r
554 WorkOffset += OffsetAdd;
\r
557 DBCopyBufferAsm(x, y, Buffer, w, h, bgc);
\r
561 void DBCopyBufferClip(signed short x, signed short y, unsigned char *Buffer, unsigned short w, unsigned short h, unsigned long bgc)
\r
563 unsigned char *WorkOffset;
\r
564 unsigned long OffsetAdd1, OffsetAdd2;
\r
565 signed short cx, cy, sx, sy, cw, ch;
\r
566 unsigned long data;
\r
568 if((x > clip_x2) || ((x + w) < clip_x1) || (y > clip_y2) || ((y + h) < clip_y1))
\r
570 if((x >= clip_x1) && ((x + w) <= clip_x2) && (y >= clip_y1) && ((y + h) <= clip_y2))
\r
572 DBCopyBuffer(x, y, Buffer, w, h, bgc);
\r
575 sx = (x < clip_x1)?(clip_x1 - x):0;
\r
576 sy = (y < clip_y1)?(clip_y1 - y):0;
\r
577 cw = (x + (signed short)w - 1 > clip_x2)?(clip_x2 - x + 1):(signed short)w;
\r
578 ch = (y + (signed short)h - 1 > clip_y2)?(clip_y2 - y + 1):(signed short)h;
\r
579 Buffer += (sx + (sy * w)) << 2;
\r
580 OffsetAdd1 = (sx + w - cw) << 2;
\r
581 OffsetAdd2 = 1280 - ((cw - sx) << 2);
\r
582 WorkOffset = DblBuffer + ((signed long)(y + sy) << 10) + ((signed long)(y + sy) << 8) + ((signed long)(x + sx) << 2);
\r
583 for(cy = 0; cy < ch - sy; cy++)
\r
585 for(cx = 0; cx < cw - sx; cx++)
\r
587 data = *(unsigned long *)Buffer;
\r
589 *(unsigned long *)WorkOffset = data;
\r
593 Buffer += OffsetAdd1;
\r
594 WorkOffset += OffsetAdd2;
\r
598 void DBSpriteLine(signed short x1, signed short y1, signed short x2, signed short y2, unsigned char *Buffer, unsigned short w, unsigned short h)
\r
600 signed short dx, dy, x, y;
\r
601 signed short xi, yi, d;
\r
627 for(i = 0; i <= dx; i++)
\r
629 DBCopyBufferClip((unsigned short)x, (unsigned short)y, Buffer, w, h, 0);
\r
639 for(i = 0; i <= dy; i++)
\r
641 DBCopyBufferClip((unsigned short)x, (unsigned short)y, Buffer, w, h, 0);
\r
653 void DBCopyBufferRotated(signed short x, signed short y, unsigned char *Buffer, unsigned short w, unsigned short h, unsigned long bgc, signed short rx, signed short ry, unsigned short a)
\r
655 signed short cx, cy, sx, sy, xd, yd;
\r
656 unsigned long Data, OffsetMax;
\r
657 signed long w1, h1;
\r
658 signed long x0, y0, xn, yn;
\r
661 c = (signed long)(Cosine[a] * 0x10000);
\r
662 s = (signed long)(Sine[a] * 0x10000);
\r
665 w1 = (s * h) + (c * w);
\r
666 h1 = (c * h) + (s * w);
\r
667 x0 = (signed long)((Sine[a] * Sine[a] * (float)w) * 0x10000);
\r
668 y0 = (signed long)(-(Sine[a] * Cosine[a] * (float)w) * 0x10000);
\r
670 yd = (signed short)((s * (signed long)w) >> 16);
\r
673 w1 = (s * h) - (c * w);
\r
674 h1 = (s * w) - (c * h);
\r
675 x0 = (signed long)((w - ((Sine[a] * Cosine[a]) * (float)h)) * 0x10000);
\r
676 y0 = (signed long)((Cosine[a] * Cosine[a] * (float)h) * 0x10000);
\r
677 xd = (signed short)((-c * (signed long)w) >> 16);
\r
678 yd = (signed short)(h1 >> 16);
\r
681 w1 = -(s * h) - (c * w);
\r
682 h1 = -(s * w) - (c * h);
\r
683 x0 = (signed long)((Cosine[a] * Cosine[a] * (float)w) * 0x10000);
\r
684 y0 = (signed long)((h + (Sine[a] * Cosine[a] * (float)w)) * 0x10000);
\r
685 xd = (signed short)(w1 >> 16);
\r
686 yd = (signed short)((-c * (signed long)h) >> 16);
\r
688 w1 = (c * w) - (s * h);
\r
689 h1 = (c * h) - (s * w);
\r
690 x0 = (signed long)((Sine[a] * Cosine[a] * (float)h) * 0x10000);
\r
691 y0 = (signed long)((Sine[a] * Sine[a] * (float)h) * 0x10000);
\r
692 xd = (signed short)((-s * (signed long)h) >> 16);
\r
695 if((w1 & 0xFFFF) != 0)
\r
696 w1 = (w1 & 0xFFFF0000) + 0x10000;
\r
697 if((h1 & 0xFFFF) != 0)
\r
698 h1 = (h1 & 0xFFFF0000) + 0x10000;
\r
701 xd += (signed short)(((c * (signed long)rx) + (s * (signed long)ry)) >> 16);
\r
702 yd += (signed short)(((c * (signed long)ry) - (s * (signed long)ry)) >> 16);
\r
704 for(cy = 0; cy < h1; cy++)
\r
709 for(cx = 0; cx < w1; cx++)
\r
711 if((xn >= 0) && (yn >= 0) && (xn < (w << 16)) && (yn < (h << 16)))
\r
713 Data = ((unsigned long *)Buffer)[((xn & 0xFFFF0000) + ((yn & 0xFFFF0000) * w)) >> 16];
\r
715 DBPSetC(sx, sy, Data);
\r
716 if((sx == x) && (sy == y))
\r
717 ((unsigned long *)Buffer)[((xn & 0xFFFF0000) + ((yn & 0xFFFF0000) * w)) >> 16] = MakeColor(255, 0, 0);
\r
729 void ColorAdd(unsigned long *Bg, unsigned long Amount)
\r
733 unsigned short R, G, B;
\r
736 c2 = *(Color *)&Amount;
\r
737 R = (unsigned short)c1->R + (unsigned short)c2.R;
\r
738 G = (unsigned short)c1->G + (unsigned short)c2.G;
\r
739 B = (unsigned short)c1->B + (unsigned short)c2.B;
\r
746 c1->R = (unsigned char)R;
\r
747 c1->G = (unsigned char)G;
\r
748 c1->B = (unsigned char)B;
\r
751 void ColorSub(unsigned long *Bg, unsigned long Amount)
\r
755 signed short R, G, B;
\r
758 c2 = *(Color *)&Amount;
\r
759 R = (unsigned short)c1->R - (unsigned short)c2.R;
\r
760 G = (unsigned short)c1->G - (unsigned short)c2.G;
\r
761 B = (unsigned short)c1->B - (unsigned short)c2.B;
\r
768 c1->R = (unsigned char)R;
\r
769 c1->G = (unsigned char)G;
\r
770 c1->B = (unsigned char)B;
\r
773 /*void ColorAdd(unsigned long *Bg, unsigned long Amount)
\r
777 movd (%%esi), %%mm1
\r
778 paddusb %%mm1, %%mm0
\r
779 movd %%mm0, 0(%%esi)
\r
782 : "a" (Amount), "S" (Bg)
\r
785 addb %%al, 0(%%esi)
\r
786 jnc ColorAddNoBlueOF
\r
787 movb $0xFF, 0(%%esi)
\r
789 addb %%ah, 1(%%esi)
\r
790 jnc ColorAddNoGreenOF
\r
791 movb $0xFF, 1(%%esi)
\r
794 addb %%al, 2(%%esi)
\r
795 jnc ColorAddNoRedOF
\r
796 movb $0xFF, 2(%%esi)
\r
800 : "a" (Amount), "S" (Bg)
\r
804 /*void ColorSub(unsigned long *Bg, unsigned long Amount)
\r
807 subb %%al, 0(%%esi)
\r
808 jnc ColorSubNoBlueOF
\r
809 movb $0x00, 0(%%esi)
\r
811 subb %%ah, 1(%%esi)
\r
812 jnc ColorSubNoGreenOF
\r
813 movb $0x00, 1(%%esi)
\r
816 subb %%al, 2(%%esi)
\r
817 jnc ColorSubNoRedOF
\r
818 movb $0x00, 2(%%esi)
\r
822 : "a" (Amount), "S" (Bg)
\r
826 void ColorAvr(unsigned long *Bg, unsigned long Amount)
\r
830 addb %%al, 0(%%esi)
\r
833 addb %%ah, 1(%%esi)
\r
838 addb %%al, 2(%%esi)
\r
844 : "a" (Amount), "S" (Bg)
\r
847 ((Color *)(Bg))->R = (unsigned char)(((unsigned short)((Color *)(Bg))->R + (unsigned short)(*(Color *)(&Amount)).R) >> 1);
\r
848 ((Color *)(Bg))->G = (unsigned char)(((unsigned short)((Color *)(Bg))->G + (unsigned short)(*(Color *)(&Amount)).G) >> 1);
\r
849 ((Color *)(Bg))->B = (unsigned char)(((unsigned short)((Color *)(Bg))->B + (unsigned short)(*(Color *)(&Amount)).B) >> 1);
\r
852 void ColorSpc(unsigned long *Bg, unsigned long Amount)
\r
856 unsigned short R, G, B;
\r
859 c2 = *(Color *)&Amount;
\r
860 R = ((3 * (unsigned short)c1->R) + (3 * (unsigned short)c2.R)) >> 2;
\r
861 G = ((3 * (unsigned short)c1->G) + (3 * (unsigned short)c2.G)) >> 2;
\r
862 B = ((3 * (unsigned short)c1->B) + (3 * (unsigned short)c2.B)) >> 2;
\r
869 c1->R = (unsigned char)R;
\r
870 c1->G = (unsigned char)G;
\r
871 c1->B = (unsigned char)B;
\r
874 void ColorFul(unsigned long *Bg, unsigned long Amount)
\r
878 *(unsigned long *)&c2 = Amount;
\r
888 void DBCopyMapBufferClip(signed short x, signed short y, unsigned char *Buffer, unsigned char *BgBuffer, unsigned short w, unsigned short h)
\r
890 unsigned char *WorkOffset;
\r
891 unsigned long OffsetAdd1, OffsetAdd2;
\r
892 signed short cx, cy, sx, sy, cw, ch;
\r
893 unsigned long data;
\r
895 if((x > clip_x2) || ((x + w) < clip_x1) || (y > clip_y2) || ((y + h) < clip_y1))
\r
897 sx = (x < clip_x1)?(clip_x1 - x):0;
\r
898 sy = (y < clip_y1)?(clip_y1 - y):0;
\r
899 cw = (x + (signed short)w - 1 > clip_x2)?(clip_x2 - x + 1):(signed short)w;
\r
900 ch = (y + (signed short)h - 1 > clip_y2)?(clip_y2 - y + 1):(signed short)h;
\r
901 Buffer += (sx + (sy * w)) << 2;
\r
902 BgBuffer += sx + (sy * w);
\r
903 OffsetAdd1 = (sx + w - cw) << 2;
\r
904 OffsetAdd2 = 1280 - ((cw - sx) << 2);
\r
905 WorkOffset = DblBuffer + ((signed long)(y + sy) << 10) + ((signed long)(y + sy) << 8) + ((signed long)(x + sx) << 2);
\r
906 for(cy = 0; cy < ch - sy; cy++)
\r
908 for(cx = 0; cx < cw - sx; cx++)
\r
910 data = *(unsigned long *)Buffer;
\r
913 if(((*BgBuffer) & 0x70) == 0x20)
\r
914 ColorAdd((unsigned long *)WorkOffset, data);
\r
916 *(unsigned long *)WorkOffset = data;
\r
922 Buffer += OffsetAdd1;
\r
923 BgBuffer += OffsetAdd1 >> 2;
\r
924 WorkOffset += OffsetAdd2;
\r
928 void DBCopyBufferTrans(signed short x, signed short y, unsigned char *Buffer, unsigned short w, unsigned short h, unsigned long bgc, unsigned char Method)
\r
930 unsigned char *WorkOffset;
\r
931 unsigned long OffsetAdd;
\r
932 unsigned short cx, cy;
\r
933 unsigned long data;
\r
935 WorkOffset = DblBuffer + ((signed long)y << 10) + ((signed long)y << 8) + ((signed long)x << 2);
\r
936 OffsetAdd = 1280 - (w << 2);
\r
937 for(cy = 0; cy < h; cy++)
\r
939 for(cx = 0; cx < w; cx++)
\r
941 data = *(unsigned long *)Buffer;
\r
943 TransOps[Method]((unsigned long *)WorkOffset, data);
\r
947 WorkOffset += OffsetAdd;
\r
951 void DBCopyBufferClipTrans(signed short x, signed short y, unsigned char *Buffer, unsigned short w, unsigned short h, unsigned short bgc, unsigned char Method)
\r
953 unsigned char *WorkOffset;
\r
954 unsigned long OffsetAdd1, OffsetAdd2;
\r
955 signed short cx, cy, sx, sy, cw, ch;
\r
956 unsigned long data;
\r
958 if((x > clip_x2) || ((x + w) < clip_x1) || (y > clip_y2) || ((y + h) < clip_y1))
\r
960 if((x >= clip_x1) && ((x + w) <= clip_x2) && (y >= clip_y1) && ((y + h) <= clip_y2))
\r
962 DBCopyBufferTrans(x, y, Buffer, w, h, bgc, Method);
\r
965 sx = (x < clip_x1)?(clip_x1 - x):0;
\r
966 sy = (y < clip_y1)?(clip_y1 - y):0;
\r
967 cw = (x + (signed short)w - 1 > clip_x2)?(clip_x2 - x + 1):(signed short)w;
\r
968 ch = (y + (signed short)h - 1 > clip_y2)?(clip_y2 - y + 1):(signed short)h;
\r
969 Buffer += (sx + (sy * w)) << 2;
\r
970 OffsetAdd1 = (sx + w - cw) << 2;
\r
971 OffsetAdd2 = 1280 - ((cw - sx) << 2);
\r
972 WorkOffset = DblBuffer + ((signed long)(y + sy) << 10) + ((signed long)(y + sy) << 8) + ((signed long)(x + sx) << 2);
\r
973 for(cy = 0; cy < ch - sy; cy++)
\r
975 for(cx = 0; cx < cw - sx; cx++)
\r
977 data = *(unsigned long *)Buffer;
\r
979 TransOps[Method]((unsigned long *)WorkOffset, data);
\r
983 Buffer += OffsetAdd1;
\r
984 WorkOffset += OffsetAdd2;
\r
988 void DBSpriteLineTrans(signed short x1, signed short y1, signed short x2, signed short y2, unsigned char *Buffer, unsigned short w, unsigned short h, unsigned char Method)
\r
990 signed short dx, dy, x, y;
\r
991 signed short xi, yi, d;
\r
1017 for(i = 0; i <= dx; i++)
\r
1019 DBCopyBufferClipTrans((unsigned short)x, (unsigned short)y, Buffer, w, h, 0, Method);
\r
1029 for(i = 0; i <= dy; i++)
\r
1031 DBCopyBufferClipTrans((unsigned short)x, (unsigned short)y, Buffer, w, h, 0, Method);
\r
1043 void DBCopyBufferTransRotated(signed short x, signed short y, unsigned char *Buffer, unsigned short w, unsigned short h, unsigned long bgc, unsigned char Method, signed short rx, signed short ry, unsigned short a)
\r
1045 unsigned short cx, cy, sx, sy;
\r
1046 unsigned long Data, OffsetMax;
\r
1047 signed long w1, h1;
\r
1048 signed long x0, y0, xn, yn;
\r
1051 c = (signed long)(Cosine[a] * 0x10000);
\r
1052 s = (signed long)(Sine[a] * 0x10000);
\r
1053 w1 = (s * h) + (c * w);
\r
1054 h1 = (c * h) + (s * w);
\r
1055 x0 = (signed long)((Sine[a] * Sine[a] * (float)w) * 0x10000);
\r
1056 y0 = (signed long)(-(Sine[a] * Cosine[a] * (float)w) * 0x10000);
\r
1057 if((w1 & 0xFFFF) != 0)
\r
1058 w1 = (w1 & 0xFFFF0000) + 0x10000;
\r
1059 if((h1 & 0xFFFF) != 0)
\r
1060 h1 = (h1 & 0xFFFF0000) + 0x10000;
\r
1065 for(cy = 0; cy < h1; cy++)
\r
1069 for(cx = 0; cx < w1; cx++)
\r
1071 if((xn >= 0) && (yn >= 0) && (xn < (w << 16)) && (yn < (h << 16)))
\r
1073 Data = ((unsigned long *)Buffer)[((xn & 0xFFFF0000) + ((yn & 0xFFFF0000) * w)) >> 16];
\r
1075 DBPSetCTrans(sx, sy, Data, Method);
\r
1088 #undef MOTION_BLUR
\r
1090 void DisplayDB(void)
\r
1092 SDL_Flip(VBuffer);
\r
1096 void DisplayDB(void)
\r
1103 #ifndef MOTION_BLUR
\r
1106 /*for(i = 0; i < 256000; i += 4)
\r
1108 *(unsigned long *)&VBuffer[i] = SmoothColor(*(unsigned long *)&DblBuffer[i], *(unsigned long *)&DblBuffer[i - 1280], *(unsigned long *)&DblBuffer[i + 1280], *(unsigned long *)&DblBuffer[i - 4], *(unsigned long *)&DblBuffer[i + 4]);
\r
1110 /*for(i = 0; i < 64000; i++)
\r
1111 ((unsigned long *)VBuffer)[i] = ((unsigned long *)DblBuffer)[i];*/
\r
1113 /*for(i = 0; i < 256000; i++)
\r
1114 _farpokeb(VideoLDT, i, DblBuffer[i]);*/
\r
1116 for(i = 0; i < 64000; i++)
\r
1118 VBuffer[i * 3] = (DblBuffer)[i * 4];
\r
1119 VBuffer[(i * 3) + 1] = (DblBuffer)[(i * 4) + 1];
\r
1120 VBuffer[(i * 3) + 2] = (DblBuffer)[(i * 4) + 2];
\r
1132 for(i = 0; i < 256000; i += 4)
\r
1135 movd (%%eax), %%mm0
\r
1136 movd (%%esi), %%mm1
\r
1137 punpcklbw %%mm2, %%mm0
\r
1138 punpcklbw %%mm2, %%mm1
\r
1139 paddw %%mm1, %%mm0
\r
1141 packuswb %%mm0, %%mm0
\r
1142 movd %%mm0, (%%esi)
\r
1145 : "a" (DblBuffer + i), "S" (VBuffer + i)
\r