00001
00025 #include "interface.h"
00026 #include "sdlengine.h"
00027 #include "main.h"
00028
00035 void draw_line(int startWidth, int startHeight, int endWidth, int endHeight, int lineColor)
00036 {
00037 int temp;
00038 short int flag;
00039 int flag2;
00040 unsigned char *out;
00041 short int color;
00042 short int var2;
00043 short int xchg;
00044 int currentLineColor = lineColor;
00045
00046
00047 if (startWidth > endWidth)
00048 {
00049 temp = endWidth;
00050 endWidth = startWidth;
00051 startWidth = temp;
00052
00053 temp = endHeight;
00054 endHeight = startHeight;
00055 startHeight = temp;
00056 }
00057
00058 flag = 0;
00059
00060 if (startWidth < SCREEN_TEXTLIMIT_LEFT)
00061 {
00062 flag |= 1;
00063 }
00064 else
00065 {
00066 if (startWidth > SCREEN_TEXTLIMIT_RIGHT)
00067 return;
00068 }
00069
00070 if (startHeight < SCREEN_TEXTLIMIT_TOP)
00071 {
00072 flag |= 8;
00073 }
00074 else
00075 {
00076 if (startHeight > SCREEN_TEXTLIMIT_BOTTOM)
00077 flag |= 4;
00078 }
00079
00080 flag <<= 8;
00081
00082 if (endWidth < SCREEN_TEXTLIMIT_LEFT)
00083 return;
00084 if (endWidth <= SCREEN_TEXTLIMIT_LEFT)
00085 flag |= 2;
00086
00087 if (endHeight < SCREEN_TEXTLIMIT_TOP)
00088 {
00089 flag |= 8;
00090 }
00091 else
00092 {
00093 if (endHeight > SCREEN_TEXTLIMIT_BOTTOM)
00094 flag |= 4;
00095 }
00096
00097 flag2 = flag;
00098
00099 if (flag)
00100 return;
00101
00102 flag2 = 640;
00103 endWidth -= startWidth;
00104 endHeight -= startHeight;
00105 if (endHeight < 0)
00106 {
00107 flag2 = -flag2;
00108 endHeight = -endHeight;
00109 }
00110
00111 out = frontVideoBuffer + screenLockupTable[startHeight] + startWidth;
00112
00113 color = currentLineColor;
00114 if (endWidth < endHeight)
00115 {
00116 xchg = endWidth;
00117 endWidth = endHeight;
00118 endHeight = xchg;
00119 var2 = endWidth;
00120 var2 <<= 1;
00121 startHeight = endWidth;
00122 endHeight <<= 1;
00123 endWidth++;
00124 do
00125 {
00126 *out = (unsigned char) color;
00127 startHeight -= endHeight;
00128 if (startHeight > 0)
00129 {
00130 out += flag2;
00131 }
00132 else
00133 {
00134 startHeight += var2;
00135 out += flag2 + 1;
00136 }
00137 }while (--endWidth);
00138 }
00139 else
00140 {
00141 var2 = endWidth;
00142 var2 <<= 1;
00143 startHeight = endWidth;
00144 endHeight <<= 1;
00145 endWidth++;
00146 do
00147 {
00148 *out = (unsigned char) color;
00149 out++;
00150 startHeight -= endHeight;
00151 if (startHeight < 0)
00152 {
00153 startHeight += var2;
00154 out += flag2;
00155 }
00156 }while (--endWidth);
00157 }
00158 }
00159
00169 void blit_box(int left, int top, int right, int bottom, char *source, int leftDest, int topDest, char *dest)
00170 {
00171 int width;
00172 int height;
00173 char *s;
00174 char *d;
00175 int insideLine;
00176 int temp3;
00177 int i;
00178 int j;
00179
00180 s = screenLockupTable[top] + source + left;
00181 d = screenLockupTable[topDest] + dest + leftDest;
00182
00183 width = right - left + 1;
00184 height = bottom - top + 1;
00185
00186 insideLine = SCREEN_WIDTH - width;
00187 temp3 = left;
00188
00189 left >>= 2;
00190 temp3 &= 3;
00191
00192 for(j = 0; j < height; j++)
00193 {
00194 for (i = 0; i < width; i++)
00195 {
00196 *(d++) = *(s++);
00197 }
00198
00199 d += insideLine;
00200 s += insideLine;
00201 }
00202 }
00203
00210 void draw_transparent_box(int left, int top, int right, int bottom, int colorAdj)
00211 {
00212 unsigned char *pos;
00213 int width;
00214 int height;
00215 int height2;
00216 int temp;
00217 int localMode;
00218 int var1;
00219 char color;
00220 char color2;
00221
00222 if (left > SCREEN_TEXTLIMIT_RIGHT)
00223 return;
00224 if (right < SCREEN_TEXTLIMIT_LEFT)
00225 return;
00226 if (top > SCREEN_TEXTLIMIT_BOTTOM)
00227 return;
00228 if (bottom < SCREEN_TEXTLIMIT_TOP)
00229 return;
00230
00231 if (left < SCREEN_TEXTLIMIT_LEFT)
00232 left = SCREEN_TEXTLIMIT_LEFT;
00233 if (right > SCREEN_TEXTLIMIT_RIGHT)
00234 right = SCREEN_TEXTLIMIT_RIGHT;
00235 if (top < SCREEN_TEXTLIMIT_TOP)
00236 top = SCREEN_TEXTLIMIT_TOP;
00237 if (bottom > SCREEN_TEXTLIMIT_BOTTOM)
00238 bottom = SCREEN_TEXTLIMIT_BOTTOM;
00239
00240 pos = screenLockupTable[top] + frontVideoBuffer + left;
00241 height2 = height = bottom - top;
00242 height2++;
00243
00244 width = right - left + 1;
00245
00246 temp = 640 - width;
00247 localMode = colorAdj;
00248
00249 do
00250 {
00251 var1 = width;
00252 do
00253 {
00254 color2 = color = *pos;
00255 color2 &= 0xF0;
00256 color &= 0x0F;
00257 color -= localMode;
00258 if (color < 0)
00259 color = color2;
00260 else
00261 color += color2;
00262 *pos++ = color;
00263 var1--;
00264 }
00265 while (var1 > 0);
00266 pos += temp;
00267 height2--;
00268 }
00269 while (height2 > 0);
00270 }
00271
00272 void draw_splitted_box(int left, int top, int right, int bottom, unsigned char e)
00273 {
00274 unsigned char *ptr;
00275
00276 int offset;
00277
00278 int x;
00279 int y;
00280
00281 if (left > SCREEN_TEXTLIMIT_RIGHT)
00282 return;
00283 if (right < SCREEN_TEXTLIMIT_LEFT)
00284 return;
00285 if (top > SCREEN_TEXTLIMIT_BOTTOM)
00286 return;
00287 if (bottom < SCREEN_TEXTLIMIT_TOP)
00288 return;
00289
00290
00291 offset = -((right - left) - SCREEN_WIDTH);
00292
00293 ptr = frontVideoBuffer + screenLockupTable[top] + left;
00294
00295 for (x = top; x < bottom; x++)
00296 {
00297 for (y = left; y < right; y++)
00298 {
00299 *(ptr++) = e;
00300 }
00301 ptr += offset;
00302 }
00303 }
00304
00305 void set_clip(int left, int top, int right, int bottom)
00306 {
00307 if (left < 0)
00308 left = 0;
00309 textWindowLeft = left;
00310
00311 if (top < 0)
00312 top = 0;
00313 textWindowTop = top;
00314
00315 if (right >= SCREEN_WIDTH)
00316 right = SCREEN_TEXTLIMIT_RIGHT;
00317 textWindowRight = right;
00318
00319 if (bottom >= SCREEN_HEIGHT)
00320 bottom = SCREEN_TEXTLIMIT_BOTTOM;
00321 textWindowBottom = bottom;
00322 }
00323
00324 void save_clip()
00325 {
00326 textWindowLeftSave = textWindowLeft;
00327 textWindowTopSave = textWindowTop;
00328 textWindowRightSave = textWindowRight;
00329 textWindowBottomSave = textWindowBottom;
00330 }
00331
00332 void reset_clip()
00333 {
00334 textWindowTop = textWindowLeft = SCREEN_TEXTLIMIT_TOP;
00335 textWindowRight = SCREEN_TEXTLIMIT_RIGHT;
00336 textWindowBottom = SCREEN_TEXTLIMIT_BOTTOM;
00337 }