author | tron |
Thu, 10 Feb 2005 05:43:30 +0000 | |
changeset 1349 | 07514c2cc6d1 |
parent 1348 | 1d123409026e |
child 1350 | 067b22970f19 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
1349
07514c2cc6d1
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1348
diff
changeset
|
3 |
#include "spritecache.h" |
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1130
diff
changeset
|
4 |
#include "strings.h" |
0 | 5 |
#include "gfx.h" |
6 |
#include "table/palettes.h" |
|
7 |
#include "hal.h" |
|
8 |
||
1348 | 9 |
static void GfxMainBlitter(Sprite *sprite, int x, int y, int mode); |
0 | 10 |
|
11 |
static int _stringwidth_out; |
|
12 |
static byte _cursor_backup[64*64]; |
|
13 |
static Rect _invalid_rect; |
|
14 |
static byte *_color_remap_ptr; |
|
15 |
static byte _string_colorremap[3]; |
|
16 |
||
17 |
#define DIRTY_BYTES_PER_LINE (MAX_SCREEN_WIDTH/64) |
|
18 |
static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8]; |
|
19 |
||
20 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
21 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
22 |
void memcpy_pitch(void *d, void *s, int w, int h, int spitch, int dpitch) |
0 | 23 |
{ |
24 |
byte *dp = (byte*)d; |
|
25 |
byte *sp = (byte*)s; |
|
26 |
||
27 |
assert(h >= 0); |
|
1056
ff3cfd9042a3
(svn r1557) Replace strange if () do while () construct with a plain for ()
tron
parents:
1009
diff
changeset
|
28 |
for (; h != 0; --h) { |
0 | 29 |
memcpy(dp, sp, w); |
30 |
dp += dpitch; |
|
31 |
sp += spitch; |
|
1056
ff3cfd9042a3
(svn r1557) Replace strange if () do while () construct with a plain for ()
tron
parents:
1009
diff
changeset
|
32 |
} |
0 | 33 |
} |
34 |
||
35 |
||
36 |
void GfxScroll(int left, int top, int width, int height, int xo, int yo) { |
|
37 |
byte *src, *dst; |
|
38 |
int p; |
|
39 |
int ht; |
|
40 |
||
41 |
if (xo == 0 && yo == 0) |
|
42 |
return; |
|
43 |
||
44 |
if (_cursor.visible) |
|
45 |
UndrawMouseCursor(); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
46 |
UndrawTextMessage(); |
0 | 47 |
|
48 |
p = _screen.pitch; |
|
49 |
||
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
50 |
if (yo > 0) { |
0 | 51 |
// Calculate pointers |
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
52 |
dst = _screen.dst_ptr + (top + height - 1) * p + left; |
0 | 53 |
src = dst - yo * p; |
54 |
||
55 |
// Decrease height and increase top |
|
56 |
top += yo; |
|
57 |
height -= yo; |
|
58 |
assert(height > 0); |
|
59 |
||
60 |
// Adjust left & width |
|
61 |
if (xo >= 0) { |
|
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
62 |
dst += xo; |
0 | 63 |
left += xo; |
64 |
width -= xo; |
|
65 |
} else { |
|
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
66 |
src -= xo; |
0 | 67 |
width += xo; |
68 |
} |
|
69 |
||
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
70 |
for (ht = height; ht > 0; --ht) { |
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
71 |
memcpy(dst, src, width); |
0 | 72 |
src -= p; |
73 |
dst -= p; |
|
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
74 |
} |
0 | 75 |
} else { |
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
76 |
// Calculate pointers |
0 | 77 |
dst = _screen.dst_ptr + top * p + left; |
78 |
src = dst - yo * p; |
|
79 |
||
80 |
// Decrese height. (yo is <=0). |
|
81 |
height += yo; |
|
82 |
assert(height > 0); |
|
83 |
||
84 |
// Adjust left & width |
|
85 |
if (xo >= 0) { |
|
86 |
dst += xo; |
|
87 |
left += xo; |
|
88 |
width -= xo; |
|
89 |
} else { |
|
90 |
src -= xo; |
|
91 |
width += xo; |
|
92 |
} |
|
93 |
||
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
94 |
// the y-displacement may be 0 therefore we have to use memmove, |
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
95 |
// because source and destination may overlap |
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
96 |
for (ht = height; ht > 0; --ht) { |
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
97 |
memmove(dst, src, width); |
0 | 98 |
src += p; |
99 |
dst += p; |
|
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
100 |
} |
0 | 101 |
} |
375
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
102 |
// This part of the screen is now dirty. |
6a1e279049d2
(svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents:
332
diff
changeset
|
103 |
_video_driver->make_dirty(left, top, width, height); |
0 | 104 |
} |
105 |
||
106 |
||
107 |
void GfxFillRect(int left, int top, int right, int bottom, int color) { |
|
108 |
DrawPixelInfo *dpi = _cur_dpi; |
|
109 |
byte *dst,*ctab; |
|
332 | 110 |
const int otop = top; |
111 |
const int oleft = left; |
|
0 | 112 |
|
113 |
if (dpi->zoom != 0) |
|
114 |
return; |
|
115 |
||
116 |
if (left > right || top > bottom) |
|
117 |
return; |
|
118 |
||
119 |
if (right < dpi->left || left >= dpi->left + dpi->width) |
|
120 |
return; |
|
121 |
||
122 |
if (bottom < dpi->top || top >= dpi->top + dpi->height) |
|
123 |
return; |
|
124 |
||
125 |
if ( (left -= dpi->left) < 0) left = 0; |
|
126 |
right = right - dpi->left + 1; |
|
127 |
if (right > dpi->width) right=dpi->width; |
|
128 |
right -= left; |
|
129 |
assert(right > 0); |
|
130 |
||
131 |
if ( (top -= dpi->top) < 0) top = 0; |
|
132 |
bottom = bottom - dpi->top + 1; |
|
133 |
if (bottom > dpi->height) bottom=dpi->height; |
|
134 |
bottom -= top; |
|
135 |
assert(bottom > 0); |
|
136 |
||
137 |
dst = dpi->dst_ptr + top * dpi->pitch + left; |
|
138 |
||
139 |
if (!(color & 0x8000)) { |
|
140 |
if (!(color & 0x4000)) { |
|
141 |
do { |
|
142 |
memset(dst, color, right); |
|
143 |
dst += dpi->pitch; |
|
144 |
} while (--bottom); |
|
145 |
} else { |
|
146 |
/* use colortable mode */ |
|
147 |
ctab = GetSpritePtr(color & 0x3FFF) + 1; |
|
148 |
do { |
|
149 |
int i; |
|
150 |
for(i=0; i!=right;i++) |
|
151 |
dst[i] = ctab[dst[i]]; |
|
152 |
dst += dpi->pitch; |
|
153 |
} while (--bottom); |
|
154 |
} |
|
155 |
} else { |
|
332 | 156 |
byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1; |
0 | 157 |
do { |
158 |
int i; |
|
332 | 159 |
for (i = (bo ^= 1); i < right; i += 2) |
160 |
dst[i] = (byte)color; |
|
0 | 161 |
dst += dpi->pitch; |
332 | 162 |
} while (--bottom > 0); |
0 | 163 |
} |
164 |
} |
|
165 |
||
410 | 166 |
static void GfxSetPixel(int x, int y, int color) |
0 | 167 |
{ |
168 |
DrawPixelInfo *dpi = _cur_dpi; |
|
169 |
if ((x-=dpi->left) < 0 || x>=dpi->width || (y-=dpi->top)<0 || y>=dpi->height) |
|
170 |
return; |
|
171 |
dpi->dst_ptr[y*dpi->pitch+x] = color; |
|
172 |
} |
|
173 |
||
174 |
void GfxDrawLine(int x, int y, int x2, int y2, int color) |
|
175 |
{ |
|
176 |
int dy; |
|
177 |
int dx; |
|
178 |
int stepx, stepy; |
|
179 |
int frac; |
|
180 |
||
181 |
// Check clipping first |
|
182 |
{ |
|
183 |
DrawPixelInfo *dpi = _cur_dpi; |
|
184 |
int t; |
|
185 |
||
186 |
if (x < dpi->left && x2 < dpi->left) |
|
187 |
return; |
|
188 |
||
189 |
if (y < dpi->top && y2 < dpi->top) |
|
190 |
return; |
|
191 |
||
192 |
t = dpi->left + dpi->width; |
|
193 |
if (x > t && x2 > t) |
|
194 |
return; |
|
195 |
||
196 |
t = dpi->top + dpi->height; |
|
197 |
if (y > t && y2 > t) |
|
198 |
return; |
|
199 |
} |
|
200 |
||
201 |
dy = (y2 - y) * 2; |
|
202 |
if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } |
|
203 |
||
204 |
dx = (x2 - x) * 2; |
|
205 |
if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } |
|
206 |
||
207 |
GfxSetPixel(x, y, color); |
|
208 |
if (dx > dy) { |
|
209 |
frac = dy - (dx >> 1); |
|
210 |
while (x != x2) { |
|
211 |
if (frac >= 0) { |
|
212 |
y += stepy; |
|
213 |
frac -= dx; |
|
214 |
} |
|
215 |
x += stepx; |
|
216 |
frac += dy; |
|
217 |
GfxSetPixel(x, y, color); |
|
218 |
} |
|
219 |
} else { |
|
220 |
frac = dx - (dy >> 1); |
|
221 |
while (y != y2) { |
|
222 |
if (frac >= 0) { |
|
223 |
x += stepx; |
|
224 |
frac -= dy; |
|
225 |
} |
|
226 |
y += stepy; |
|
227 |
frac += dx; |
|
228 |
GfxSetPixel(x, y, color); |
|
229 |
} |
|
230 |
} |
|
231 |
} |
|
232 |
||
233 |
// ASSIGNMENT OF ASCII LETTERS < 32 |
|
234 |
// 0 - end of string |
|
235 |
// 1 - SETX <BYTE> |
|
236 |
// 2 - SETXY <BYTE> <BYTE> |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
237 |
// 3-7 - |
0 | 238 |
// 8 - TINYFONT |
239 |
// 9 - BIGFONT |
|
240 |
// 10 - newline |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
241 |
// 11-14 - |
0 | 242 |
// 15-31 - 17 colors |
243 |
||
244 |
||
245 |
enum { |
|
246 |
ASCII_LETTERSTART = 32, |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
247 |
|
0 | 248 |
ASCII_SETX = 1, |
249 |
ASCII_SETXY = 2, |
|
250 |
||
251 |
ASCII_TINYFONT = 8, |
|
252 |
ASCII_BIGFONT = 9, |
|
253 |
ASCII_NL = 10, |
|
254 |
||
255 |
ASCII_COLORSTART = 15, |
|
256 |
}; |
|
257 |
||
258 |
||
259 |
/* returns right coordinate */ |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
260 |
int DrawString(int x, int y, uint16 str, uint16 color) |
0 | 261 |
{ |
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
262 |
char buffer[512]; |
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
263 |
|
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
264 |
GetString(buffer, str); |
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
265 |
return DoDrawString(buffer, x, y, color); |
0 | 266 |
} |
267 |
||
268 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
269 |
void DrawStringRightAligned(int x, int y, uint16 str, uint16 color) |
0 | 270 |
{ |
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
271 |
char buffer[512]; |
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
272 |
|
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
273 |
GetString(buffer, str); |
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
274 |
DoDrawString(buffer, x - GetStringWidth(buffer), y, color); |
0 | 275 |
} |
276 |
||
277 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
278 |
int DrawStringCentered(int x, int y, uint16 str, uint16 color) |
0 | 279 |
{ |
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
280 |
char buffer[512]; |
0 | 281 |
int w; |
282 |
||
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
283 |
GetString(buffer, str); |
0 | 284 |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
285 |
w = GetStringWidth(buffer); |
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
286 |
DoDrawString(buffer, x - w / 2, y, color); |
0 | 287 |
|
288 |
return w; |
|
289 |
} |
|
290 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
291 |
void DrawStringCenterUnderline(int x, int y, uint16 str, uint16 color) |
0 | 292 |
{ |
293 |
int w = DrawStringCentered(x, y, str, color); |
|
294 |
GfxFillRect(x-(w>>1), y+10, x-(w>>1)+w, y+10, _string_colorremap[1]); |
|
295 |
} |
|
296 |
||
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
297 |
static uint32 FormatStringLinebreaks(char *str, int maxw) |
1095 | 298 |
{ |
0 | 299 |
int num = 0; |
300 |
int base = _stringwidth_base; |
|
301 |
int w; |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
302 |
char *last_space; |
0 | 303 |
byte c; |
304 |
||
305 |
for(;;) { |
|
306 |
w = 0; |
|
307 |
last_space = NULL; |
|
308 |
||
309 |
for(;;) { |
|
310 |
c = *str++; |
|
311 |
if (c == ' ') last_space = str; |
|
312 |
||
313 |
if (c >= ASCII_LETTERSTART) { |
|
314 |
w += _stringwidth_table[base + ((byte)c) - 0x20]; |
|
315 |
if (w > maxw) { |
|
316 |
str = last_space; |
|
317 |
if (str == NULL) |
|
318 |
return num + (base << 16); |
|
319 |
break; |
|
320 |
} |
|
321 |
} else { |
|
322 |
if (c == 0) return num + (base << 16); |
|
323 |
if (c == ASCII_NL) break; |
|
324 |
||
325 |
if (c == ASCII_SETX) str++; |
|
326 |
else if (c == ASCII_SETXY) str += 2; |
|
327 |
else if (c == ASCII_TINYFONT) base = 224; |
|
328 |
else if (c == ASCII_BIGFONT) base = 448; |
|
329 |
} |
|
330 |
} |
|
331 |
||
332 |
num++; |
|
333 |
str[-1] = 0; |
|
334 |
} |
|
335 |
} |
|
336 |
||
337 |
||
338 |
void DrawStringMultiCenter(int x, int y, uint16 str, int maxw) |
|
339 |
{ |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
340 |
char buffer[512]; |
0 | 341 |
uint32 tmp; |
342 |
int num, w, mt, t; |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
343 |
const char *src; |
0 | 344 |
byte c; |
345 |
||
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
346 |
GetString(buffer, str); |
0 | 347 |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
348 |
tmp = FormatStringLinebreaks(buffer, maxw); |
0 | 349 |
num = (uint16)tmp; |
350 |
t = tmp >> 16; |
|
351 |
||
352 |
mt = 10; |
|
353 |
if (t != 0) { |
|
354 |
mt = 6; |
|
355 |
if (t != 244) mt = 18; |
|
356 |
} |
|
357 |
||
358 |
y -= (mt >> 1) * num; |
|
359 |
||
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
360 |
src = buffer; |
0 | 361 |
|
362 |
for(;;) { |
|
363 |
w = GetStringWidth(src); |
|
364 |
DoDrawString(src, x - (w>>1), y, 0xFE); |
|
365 |
_stringwidth_base = _stringwidth_out; |
|
366 |
||
367 |
for(;;) { |
|
368 |
c = *src++; |
|
369 |
if (c == 0) { |
|
370 |
y += mt; |
|
371 |
if (--num < 0) { |
|
372 |
_stringwidth_base = 0; |
|
373 |
return; |
|
374 |
} |
|
375 |
break; |
|
376 |
} else if (c == ASCII_SETX) { |
|
377 |
src++; |
|
378 |
} else if (c == ASCII_SETXY) { |
|
379 |
src+=2; |
|
380 |
} |
|
381 |
} |
|
382 |
} |
|
383 |
} |
|
384 |
||
385 |
void DrawStringMultiLine(int x, int y, uint16 str, int maxw) { |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
386 |
char buffer[512]; |
0 | 387 |
uint32 tmp; |
388 |
int num, w, mt, t; |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
389 |
const char *src; |
0 | 390 |
byte c; |
391 |
||
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
392 |
GetString(buffer, str); |
0 | 393 |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
394 |
tmp = FormatStringLinebreaks(buffer, maxw); |
0 | 395 |
num = (uint16)tmp; |
396 |
t = tmp >> 16; |
|
397 |
mt = 10; |
|
398 |
if (t != 0) { |
|
399 |
mt = 6; |
|
400 |
if (t != 244) mt = 18; |
|
401 |
} |
|
402 |
||
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1323
diff
changeset
|
403 |
src = buffer; |
0 | 404 |
|
405 |
for(;;) { |
|
406 |
w = GetStringWidth(src); |
|
407 |
DoDrawString(src, x, y, 0xFE); |
|
408 |
_stringwidth_base = _stringwidth_out; |
|
409 |
||
410 |
for(;;) { |
|
411 |
c = *src++; |
|
412 |
if (c == 0) { |
|
413 |
y += mt; |
|
414 |
if (--num < 0) { |
|
415 |
_stringwidth_base = 0; |
|
416 |
return; |
|
417 |
} |
|
418 |
break; |
|
419 |
} else if (c == ASCII_SETX) { |
|
420 |
src++; |
|
421 |
} else if (c == ASCII_SETXY) { |
|
422 |
src+=2; |
|
423 |
} |
|
424 |
} |
|
425 |
} |
|
426 |
} |
|
427 |
||
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
428 |
int GetStringWidth(const char *str) |
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
429 |
{ |
0 | 430 |
int w = -1; |
431 |
byte c; |
|
432 |
int base = _stringwidth_base; |
|
433 |
||
434 |
for(;;) { |
|
435 |
c = *str++; |
|
436 |
if (c == 0) |
|
437 |
return w; |
|
438 |
if (c >= ASCII_LETTERSTART) { |
|
439 |
w += _stringwidth_table[base + c - ASCII_LETTERSTART]; |
|
440 |
} else { |
|
441 |
if (c == ASCII_SETX) str++; |
|
442 |
else if (c == ASCII_SETXY) str += 2; |
|
443 |
else if (c == ASCII_TINYFONT) base = 224; |
|
444 |
else if (c == ASCII_BIGFONT) base = 448; |
|
445 |
} |
|
446 |
} |
|
447 |
} |
|
448 |
||
449 |
void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags) { |
|
450 |
byte color_2 = _color_list[ctab].window_color_1a; |
|
451 |
byte color_interior = _color_list[ctab].window_color_bga; |
|
452 |
byte color_3 = _color_list[ctab].window_color_bgb; |
|
453 |
byte color = _color_list[ctab].window_color_2; |
|
454 |
||
455 |
if (!(flags & 0x8)) { |
|
456 |
if (!(flags & 0x20)) { |
|
457 |
GfxFillRect(left, top, left, bottom-1, color); |
|
458 |
GfxFillRect(left+1, top, right-1, top, color); |
|
459 |
GfxFillRect(right, top, right, bottom-1, color_2); |
|
460 |
GfxFillRect(left, bottom, right, bottom, color_2); |
|
461 |
if (!(flags & 0x10)) { |
|
462 |
GfxFillRect(left+1, top+1, right-1, bottom-1, color_interior); |
|
463 |
} |
|
464 |
} else { |
|
465 |
GfxFillRect(left, top, left, bottom, color_2); |
|
466 |
GfxFillRect(left+1, top, right, top, color_2); |
|
467 |
GfxFillRect(right, top+1, right, bottom-1, color); |
|
468 |
GfxFillRect(left+1, bottom, right, bottom, color); |
|
469 |
if (!(flags & 0x10)) { |
|
470 |
GfxFillRect(left+1, top+1, right-1, bottom-1, |
|
471 |
flags&0x40 ? color_interior : color_3); |
|
472 |
} |
|
473 |
} |
|
474 |
} else if (flags & 0x1) { |
|
475 |
// transparency |
|
476 |
GfxFillRect(left, top, right, bottom, 0x4322); |
|
477 |
} else { |
|
478 |
GfxFillRect(left, top, right, bottom, color_interior); |
|
479 |
} |
|
480 |
} |
|
481 |
||
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
482 |
int DoDrawString(const char *string, int x, int y, uint16 real_color) |
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
483 |
{ |
0 | 484 |
DrawPixelInfo *dpi = _cur_dpi; |
485 |
int base = _stringwidth_base; |
|
509
52dde395d888
(svn r819) Code cleanup: colors for langfile strings are now taken from a color table instead of a sprite
dominik
parents:
461
diff
changeset
|
486 |
byte c; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
487 |
byte color; |
0 | 488 |
int xo = x, yo = y; |
489 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
490 |
color = real_color & 0xFF; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
491 |
|
0 | 492 |
if (color != 0xFE) { |
493 |
if (x >= dpi->left + dpi->width || |
|
494 |
x + _screen.width*2 <= dpi->left || |
|
495 |
y >= dpi->top + dpi->height || |
|
496 |
y + _screen.height <= dpi->top) |
|
497 |
return x; |
|
498 |
||
499 |
if (color != 0xFF) { |
|
500 |
switch_color:; |
|
657
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
619
diff
changeset
|
501 |
if (real_color & IS_PALETTE_COLOR) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
502 |
_string_colorremap[1] = color; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
503 |
_string_colorremap[2] = 215; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
504 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
505 |
_string_colorremap[1] = _string_colormap[color].text; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
506 |
_string_colorremap[2] = _string_colormap[color].shadow; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
507 |
} |
0 | 508 |
_color_remap_ptr = _string_colorremap; |
509 |
} |
|
510 |
} |
|
511 |
||
512 |
check_bounds: |
|
513 |
if (y + 19 <= dpi->top || dpi->top + dpi->height <= y) { |
|
514 |
skip_char:; |
|
515 |
for(;;) { |
|
516 |
c = *string++; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
517 |
if (c < ASCII_LETTERSTART) goto skip_cont; |
0 | 518 |
} |
519 |
} |
|
520 |
||
521 |
for(;;) { |
|
522 |
c = *string++; |
|
523 |
skip_cont:; |
|
524 |
if (c == 0) { |
|
525 |
_stringwidth_out = base; |
|
526 |
return x; |
|
527 |
} |
|
528 |
if (c >= ASCII_LETTERSTART) { |
|
529 |
if (x >= dpi->left + dpi->width) goto skip_char; |
|
530 |
if (x + 26 >= dpi->left) { |
|
531 |
GfxMainBlitter(GetSpritePtr(base + 2 + c - ASCII_LETTERSTART), x, y, 1); |
|
532 |
} |
|
533 |
x += _stringwidth_table[base + c - ' ']; |
|
534 |
} else if (c == ASCII_NL) { // newline = {} |
|
535 |
x = xo; |
|
536 |
y += 10; |
|
537 |
if (base != 0) { |
|
538 |
y -= 4; |
|
539 |
if (base != 0xE0) |
|
540 |
y += 12; |
|
541 |
} |
|
542 |
goto check_bounds; |
|
543 |
} else if (c >= ASCII_COLORSTART) { // change color? |
|
544 |
color = (byte)(c - ASCII_COLORSTART); |
|
545 |
goto switch_color; |
|
546 |
} else if (c == ASCII_SETX) { // {SETX} |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
547 |
x = xo + (byte)*string++; |
0 | 548 |
} else if (c == ASCII_SETXY) {// {SETXY} |
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
549 |
x = xo + (byte)*string++; |
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
550 |
y = yo + (byte)*string++; |
0 | 551 |
} else if (c == ASCII_TINYFONT) { // {TINYFONT} |
552 |
base = 0xE0; |
|
553 |
} else if (c == ASCII_BIGFONT) { // {BIGFONT} |
|
554 |
base = 0x1C0; |
|
555 |
} else { |
|
556 |
printf("Unknown string command character %d\n", c); |
|
557 |
} |
|
558 |
} |
|
559 |
} |
|
560 |
||
561 |
void DrawSprite(uint32 img, int x, int y) { |
|
562 |
if (img & 0x8000) { |
|
563 |
_color_remap_ptr = GetSpritePtr(img >> 16) + 1; |
|
564 |
GfxMainBlitter(GetSpritePtr(img & 0x3FFF), x, y, 1); |
|
565 |
} else if (img & 0x4000) { |
|
566 |
_color_remap_ptr = GetSpritePtr(img >> 16) + 1; |
|
567 |
GfxMainBlitter(GetSpritePtr(img & 0x3FFF), x, y, 2); |
|
568 |
} else { |
|
569 |
GfxMainBlitter(GetSpritePtr(img & 0x3FFF), x, y, 0); |
|
570 |
} |
|
571 |
} |
|
572 |
||
573 |
typedef struct BlitterParams { |
|
574 |
int start_x, start_y; |
|
575 |
byte *sprite, *sprite_org; |
|
576 |
byte *dst; |
|
577 |
int mode; |
|
578 |
int width, height; |
|
579 |
int width_org, height_org; |
|
580 |
int pitch; |
|
581 |
byte info; |
|
582 |
} BlitterParams; |
|
583 |
||
584 |
static void GfxBlitTileZoomIn(BlitterParams *bp) |
|
585 |
{ |
|
586 |
byte *src_o = bp->sprite, *src; |
|
587 |
int num, skip; |
|
588 |
byte done; |
|
589 |
byte *dst, *ctab; |
|
590 |
||
591 |
if (bp->mode & 1) { |
|
592 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
593 |
|
0 | 594 |
do { |
595 |
do { |
|
596 |
done = src_o[0]; |
|
597 |
num = done & 0x7F; |
|
598 |
skip = src_o[1]; |
|
599 |
src = src_o + 2; |
|
600 |
src_o += num + 2; |
|
601 |
||
602 |
dst = bp->dst; |
|
603 |
||
604 |
if ( (skip -= bp->start_x) > 0) { |
|
605 |
dst += skip; |
|
606 |
} else { |
|
607 |
src -= skip; |
|
608 |
num += skip; |
|
609 |
if (num <= 0) |
|
610 |
continue; |
|
611 |
skip = 0; |
|
612 |
} |
|
613 |
||
614 |
skip = skip + num - bp->width; |
|
615 |
if (skip > 0) { |
|
616 |
num -= skip; |
|
617 |
if (num <= 0) |
|
618 |
continue; |
|
619 |
} |
|
620 |
||
621 |
ctab = _color_remap_ptr; |
|
622 |
||
623 |
while (num >= 4) { |
|
624 |
dst[3] = ctab[src[3]]; |
|
625 |
dst[2] = ctab[src[2]]; |
|
626 |
dst[1] = ctab[src[1]]; |
|
627 |
dst[0] = ctab[src[0]]; |
|
628 |
dst += 4; |
|
629 |
src += 4; |
|
630 |
num -= 4; |
|
631 |
} |
|
632 |
while (num) { |
|
633 |
*dst++ = ctab[*src++]; |
|
634 |
num--; |
|
635 |
} |
|
636 |
} while (!(done & 0x80)); |
|
637 |
||
638 |
bp->dst += bp->pitch; |
|
639 |
} while (--bp->height); |
|
640 |
} else if (bp->mode & 2) { |
|
641 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
642 |
do { |
|
643 |
do { |
|
644 |
done = src_o[0]; |
|
645 |
num = done & 0x7F; |
|
646 |
skip = src_o[1]; |
|
647 |
src_o += num + 2; |
|
648 |
||
649 |
dst = bp->dst; |
|
650 |
||
651 |
if ( (skip -= bp->start_x) > 0) { |
|
652 |
dst += skip; |
|
653 |
} else { |
|
654 |
num += skip; |
|
655 |
if (num <= 0) |
|
656 |
continue; |
|
657 |
skip = 0; |
|
658 |
} |
|
659 |
||
660 |
skip = skip + num - bp->width; |
|
661 |
if (skip > 0) { |
|
662 |
num -= skip; |
|
663 |
if (num <= 0) |
|
664 |
continue; |
|
665 |
} |
|
666 |
||
667 |
ctab = _color_remap_ptr; |
|
668 |
while (num) { |
|
669 |
*dst = ctab[*dst]; |
|
670 |
dst++; |
|
671 |
num--; |
|
672 |
} |
|
673 |
} while (!(done & 0x80)); |
|
674 |
||
675 |
bp->dst += bp->pitch; |
|
676 |
} while (--bp->height); |
|
677 |
||
678 |
} else { |
|
679 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
680 |
do { |
|
681 |
do { |
|
682 |
done = src_o[0]; |
|
683 |
num = done & 0x7F; |
|
684 |
skip = src_o[1]; |
|
685 |
src = src_o + 2; |
|
686 |
src_o += num + 2; |
|
687 |
||
688 |
dst = bp->dst; |
|
689 |
||
690 |
if ( (skip -= bp->start_x) > 0) { |
|
691 |
dst += skip; |
|
692 |
} else { |
|
693 |
src -= skip; |
|
694 |
num += skip; |
|
695 |
if (num <= 0) |
|
696 |
continue; |
|
697 |
skip = 0; |
|
698 |
} |
|
699 |
||
700 |
skip = skip + num - bp->width; |
|
701 |
if (skip > 0) { |
|
702 |
num -= skip; |
|
703 |
if (num <= 0) |
|
704 |
continue; |
|
705 |
} |
|
706 |
#if defined(_WIN32) |
|
707 |
if (num & 1) *dst++ = *src++; |
|
708 |
if (num & 2) { *(uint16*)dst = *(uint16*)src; dst += 2; src += 2; } |
|
709 |
if (num >>= 2) { |
|
710 |
do { |
|
711 |
*(uint32*)dst = *(uint32*)src; |
|
712 |
dst += 4; |
|
713 |
src += 4; |
|
714 |
} while (--num); |
|
715 |
} |
|
716 |
#else |
|
717 |
memcpy(dst, src, num); |
|
718 |
#endif |
|
719 |
} while (!(done & 0x80)); |
|
720 |
||
721 |
bp->dst += bp->pitch; |
|
722 |
} while (--bp->height); |
|
723 |
} |
|
724 |
} |
|
725 |
||
726 |
static void GfxBlitZoomInUncomp(BlitterParams *bp) |
|
727 |
{ |
|
728 |
byte *src = bp->sprite; |
|
729 |
byte *dst = bp->dst; |
|
730 |
int height = bp->height; |
|
731 |
int width = bp->width; |
|
732 |
int i; |
|
733 |
||
734 |
assert(height > 0); |
|
735 |
assert(width > 0); |
|
736 |
||
737 |
if (bp->mode & 1) { |
|
738 |
if (bp->info & 1) { |
|
739 |
byte *ctab = _color_remap_ptr; |
|
740 |
byte b; |
|
741 |
||
742 |
do { |
|
743 |
for(i=0; i!=width; i++) { |
|
744 |
if ((b=ctab[src[i]]) != 0) |
|
745 |
dst[i] = b; |
|
746 |
} |
|
747 |
src += bp->width_org; |
|
748 |
dst += bp->pitch; |
|
749 |
} while (--height); |
|
750 |
} |
|
751 |
} else if (bp->mode & 2) { |
|
752 |
if (bp->info & 1) { |
|
753 |
byte *ctab = _color_remap_ptr; |
|
754 |
do { |
|
755 |
for(i=0; i!=width; i++) |
|
756 |
if (src[i]) |
|
757 |
dst[i] = ctab[dst[i]]; |
|
758 |
src += bp->width_org; |
|
759 |
dst += bp->pitch; |
|
760 |
} while (--height); |
|
761 |
} |
|
762 |
} else { |
|
763 |
if (!(bp->info & 1)) { |
|
764 |
do { |
|
765 |
memcpy(dst, src, width); |
|
766 |
src += bp->width_org; |
|
767 |
dst += bp->pitch; |
|
768 |
} while (--height); |
|
769 |
} else { |
|
770 |
do { |
|
771 |
int n = width; |
|
772 |
while (n >= 4) { |
|
773 |
if (src[0]) dst[0] = src[0]; |
|
774 |
if (src[1]) dst[1] = src[1]; |
|
775 |
if (src[2]) dst[2] = src[2]; |
|
776 |
if (src[3]) dst[3] = src[3]; |
|
777 |
||
778 |
dst += 4; |
|
779 |
src += 4; |
|
780 |
n -= 4; |
|
781 |
} |
|
782 |
||
783 |
while (n) { |
|
784 |
if (src[0]) dst[0] = src[0]; |
|
785 |
src++; |
|
786 |
dst++; |
|
787 |
n--; |
|
788 |
} |
|
789 |
||
790 |
src += bp->width_org - width; |
|
791 |
dst += bp->pitch - width; |
|
792 |
||
793 |
} while (--height); |
|
794 |
} |
|
795 |
} |
|
796 |
} |
|
797 |
||
798 |
static void GfxBlitTileZoomMedium(BlitterParams *bp) |
|
799 |
{ |
|
800 |
byte *src_o = bp->sprite, *src; |
|
801 |
int num, skip; |
|
802 |
byte done; |
|
803 |
byte *dst, *ctab; |
|
804 |
||
805 |
if (bp->mode & 1) { |
|
806 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
807 |
do { |
|
808 |
do { |
|
809 |
done = src_o[0]; |
|
810 |
num = done & 0x7F; |
|
811 |
skip = src_o[1]; |
|
812 |
src = src_o + 2; |
|
813 |
src_o += num + 2; |
|
814 |
||
815 |
dst = bp->dst; |
|
816 |
||
817 |
if (skip & 1) { |
|
818 |
skip++; |
|
819 |
src++; |
|
820 |
if (!--num) |
|
821 |
continue; |
|
822 |
} |
|
823 |
||
824 |
if ( (skip -= bp->start_x) > 0) { |
|
825 |
dst += skip >> 1; |
|
826 |
} else { |
|
827 |
src -= skip; |
|
828 |
num += skip; |
|
829 |
if (num <= 0) |
|
830 |
continue; |
|
831 |
skip = 0; |
|
832 |
} |
|
833 |
||
834 |
skip = skip + num - bp->width; |
|
835 |
if (skip > 0) { |
|
836 |
num -= skip; |
|
837 |
if (num <= 0) |
|
838 |
continue; |
|
839 |
} |
|
840 |
||
841 |
ctab = _color_remap_ptr; |
|
842 |
num = (num + 1) >> 1; |
|
843 |
if (num) { |
|
844 |
do { |
|
845 |
*dst = ctab[*src]; |
|
846 |
dst++; |
|
847 |
src+=2; |
|
848 |
} while (--num); |
|
849 |
} |
|
850 |
} while (!(done & 0x80)); |
|
851 |
bp->dst += bp->pitch; |
|
852 |
if (!--bp->height) |
|
853 |
return; |
|
854 |
||
855 |
do { |
|
856 |
done = src_o[0]; |
|
857 |
src_o += (done & 0x7F) + 2; |
|
858 |
} while (!(done & 0x80)); |
|
859 |
} while (--bp->height); |
|
860 |
} else if (bp->mode & 2) { |
|
861 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
862 |
do { |
|
863 |
do { |
|
864 |
done = src_o[0]; |
|
865 |
num = done & 0x7F; |
|
866 |
skip = src_o[1]; |
|
867 |
src_o += num + 2; |
|
868 |
||
869 |
dst = bp->dst; |
|
870 |
||
871 |
if (skip & 1) { |
|
872 |
skip++; |
|
873 |
if (!--num) |
|
874 |
continue; |
|
875 |
} |
|
876 |
||
877 |
if ( (skip -= bp->start_x) > 0) { |
|
878 |
dst += skip >> 1; |
|
879 |
} else { |
|
880 |
num += skip; |
|
881 |
if (num <= 0) |
|
882 |
continue; |
|
883 |
skip = 0; |
|
884 |
} |
|
885 |
||
886 |
skip = skip + num - bp->width; |
|
887 |
if (skip > 0) { |
|
888 |
num -= skip; |
|
889 |
if (num <= 0) |
|
890 |
continue; |
|
891 |
} |
|
892 |
||
893 |
ctab = _color_remap_ptr; |
|
894 |
num = (num + 1) >> 1; |
|
895 |
if (num) { |
|
896 |
do { |
|
897 |
*dst = ctab[*dst]; |
|
898 |
dst++; |
|
899 |
} while (--num); |
|
900 |
} |
|
901 |
||
902 |
} while (!(done & 0x80)); |
|
903 |
bp->dst += bp->pitch; |
|
904 |
if (!--bp->height) |
|
905 |
return; |
|
906 |
||
907 |
do { |
|
908 |
done = src_o[0]; |
|
909 |
src_o += (done & 0x7F) + 2; |
|
910 |
} while (!(done & 0x80)); |
|
911 |
} while (--bp->height); |
|
912 |
||
913 |
} else { |
|
914 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
915 |
do { |
|
916 |
do { |
|
917 |
done = src_o[0]; |
|
918 |
num = done & 0x7F; |
|
919 |
skip = src_o[1]; |
|
920 |
src = src_o + 2; |
|
921 |
src_o += num + 2; |
|
922 |
||
923 |
dst = bp->dst; |
|
924 |
||
925 |
if (skip & 1) { |
|
926 |
skip++; |
|
927 |
src++; |
|
928 |
if (!--num) |
|
929 |
continue; |
|
930 |
} |
|
931 |
||
932 |
if ( (skip -= bp->start_x) > 0) { |
|
933 |
dst += skip >> 1; |
|
934 |
} else { |
|
935 |
src -= skip; |
|
936 |
num += skip; |
|
937 |
if (num <= 0) |
|
938 |
continue; |
|
939 |
skip = 0; |
|
940 |
} |
|
941 |
||
942 |
skip = skip + num - bp->width; |
|
943 |
if (skip > 0) { |
|
944 |
num -= skip; |
|
945 |
if (num <= 0) |
|
946 |
continue; |
|
947 |
} |
|
948 |
||
949 |
num = (num + 1) >> 1; |
|
950 |
||
951 |
if (num) { |
|
952 |
do { |
|
953 |
*dst = *src; |
|
954 |
dst++; |
|
955 |
src+=2; |
|
956 |
} while (--num); |
|
957 |
} |
|
958 |
||
959 |
} while (!(done & 0x80)); |
|
960 |
||
961 |
bp->dst += bp->pitch; |
|
962 |
if (!--bp->height) |
|
963 |
return; |
|
964 |
||
965 |
do { |
|
966 |
done = src_o[0]; |
|
967 |
src_o += (done & 0x7F) + 2; |
|
968 |
} while (!(done & 0x80)); |
|
969 |
||
970 |
} while (--bp->height); |
|
971 |
} |
|
972 |
} |
|
973 |
||
974 |
static void GfxBlitZoomMediumUncomp(BlitterParams *bp) |
|
975 |
{ |
|
976 |
byte *src = bp->sprite; |
|
977 |
byte *dst = bp->dst; |
|
978 |
int height = bp->height; |
|
979 |
int width = bp->width; |
|
980 |
int i; |
|
981 |
||
982 |
assert(height > 0); |
|
983 |
assert(width > 0); |
|
984 |
||
985 |
if (bp->mode & 1) { |
|
986 |
if (bp->info & 1) { |
|
987 |
byte *ctab = _color_remap_ptr,b; |
|
988 |
height >>= 1; |
|
989 |
if (height) do { |
|
990 |
for(i=0; i!=width>>1; i++) |
|
991 |
if ((b=ctab[src[i*2]]) != 0) |
|
992 |
dst[i] = b; |
|
993 |
src += bp->width_org * 2; |
|
994 |
dst += bp->pitch; |
|
995 |
} while (--height); |
|
996 |
} |
|
997 |
} else if (bp->mode & 2) { |
|
998 |
if (bp->info & 1) { |
|
999 |
byte *ctab = _color_remap_ptr; |
|
1000 |
height >>= 1; |
|
1001 |
if (height) do { |
|
1002 |
for(i=0; i!=width>>1; i++) |
|
1003 |
if (src[i*2]) |
|
1004 |
dst[i] = ctab[dst[i]]; |
|
1005 |
src += bp->width_org * 2; |
|
1006 |
dst += bp->pitch; |
|
1007 |
} while (--height); |
|
1008 |
} |
|
1009 |
} else { |
|
1010 |
if (bp->info & 1) { |
|
1011 |
height >>= 1; |
|
1012 |
if (height) do { |
|
1013 |
for(i=0; i!=width>>1; i++) |
|
1014 |
if (src[i*2]) |
|
1015 |
dst[i] = src[i*2]; |
|
1016 |
src += bp->width_org * 2; |
|
1017 |
dst += bp->pitch; |
|
1018 |
} while (--height); |
|
1019 |
} |
|
1020 |
} |
|
1021 |
} |
|
1022 |
||
1023 |
static void GfxBlitTileZoomOut(BlitterParams *bp) |
|
1024 |
{ |
|
1025 |
byte *src_o = bp->sprite, *src; |
|
1026 |
int num, skip; |
|
1027 |
byte done; |
|
1028 |
byte *dst, *ctab; |
|
1029 |
||
1030 |
if (bp->mode & 1) { |
|
1031 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
1032 |
for(;;) { |
|
1033 |
do { |
|
1034 |
done = src_o[0]; |
|
1035 |
num = done & 0x7F; |
|
1036 |
skip = src_o[1]; |
|
1037 |
src = src_o + 2; |
|
1038 |
src_o += num + 2; |
|
1039 |
||
1040 |
dst = bp->dst; |
|
1041 |
||
1042 |
if (skip & 1) { |
|
1043 |
skip++; |
|
1044 |
src++; |
|
1045 |
if (!--num) |
|
1046 |
continue; |
|
1047 |
} |
|
1048 |
||
1049 |
if (skip & 2) { |
|
1050 |
skip+=2; |
|
1051 |
src+=2; |
|
1052 |
if ((num-=2) <= 0) |
|
1053 |
continue; |
|
1054 |
} |
|
1055 |
||
1056 |
if ( (skip -= bp->start_x) > 0) { |
|
1057 |
dst += skip >> 2; |
|
1058 |
} else { |
|
1059 |
src -= skip; |
|
1060 |
num += skip; |
|
1061 |
if (num <= 0) |
|
1062 |
continue; |
|
1063 |
skip = 0; |
|
1064 |
} |
|
1065 |
||
1066 |
skip = skip + num - bp->width; |
|
1067 |
if (skip > 0) { |
|
1068 |
num -= skip; |
|
1069 |
if (num <= 0) |
|
1070 |
continue; |
|
1071 |
} |
|
1072 |
||
1073 |
ctab = _color_remap_ptr; |
|
1074 |
num = (num + 3) >> 2; |
|
1075 |
if (num) { |
|
1076 |
do { |
|
1077 |
*dst = ctab[*src]; |
|
1078 |
dst++; |
|
1079 |
src+=4; |
|
1080 |
} while (--num); |
|
1081 |
} |
|
1082 |
} while (!(done & 0x80)); |
|
1083 |
bp->dst += bp->pitch; |
|
1084 |
if (!--bp->height) |
|
1085 |
return; |
|
1086 |
||
1087 |
do { |
|
1088 |
done = src_o[0]; |
|
1089 |
src_o += (done & 0x7F) + 2; |
|
1090 |
} while (!(done & 0x80)); |
|
1091 |
if (!--bp->height) |
|
1092 |
return; |
|
1093 |
||
1094 |
do { |
|
1095 |
done = src_o[0]; |
|
1096 |
src_o += (done & 0x7F) + 2; |
|
1097 |
} while (!(done & 0x80)); |
|
1098 |
if (!--bp->height) |
|
1099 |
return; |
|
1100 |
||
1101 |
do { |
|
1102 |
done = src_o[0]; |
|
1103 |
src_o += (done & 0x7F) + 2; |
|
1104 |
} while (!(done & 0x80)); |
|
1105 |
if (!--bp->height) |
|
1106 |
return; |
|
1107 |
} |
|
1108 |
} else if (bp->mode & 2) { |
|
1109 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
1110 |
for(;;) { |
|
1111 |
do { |
|
1112 |
done = src_o[0]; |
|
1113 |
num = done & 0x7F; |
|
1114 |
skip = src_o[1]; |
|
1115 |
src_o += num + 2; |
|
1116 |
||
1117 |
dst = bp->dst; |
|
1118 |
||
1119 |
if (skip & 1) { |
|
1120 |
skip++; |
|
1121 |
if (!--num) |
|
1122 |
continue; |
|
1123 |
} |
|
1124 |
||
1125 |
if (skip & 2) { |
|
1126 |
skip+=2; |
|
1127 |
if ((num-=2) <= 0) |
|
1128 |
continue; |
|
1129 |
} |
|
1130 |
||
1131 |
if ( (skip -= bp->start_x) > 0) { |
|
1132 |
dst += skip >> 2; |
|
1133 |
} else { |
|
1134 |
num += skip; |
|
1135 |
if (num <= 0) |
|
1136 |
continue; |
|
1137 |
skip = 0; |
|
1138 |
} |
|
1139 |
||
1140 |
skip = skip + num - bp->width; |
|
1141 |
if (skip > 0) { |
|
1142 |
num -= skip; |
|
1143 |
if (num <= 0) |
|
1144 |
continue; |
|
1145 |
} |
|
1146 |
||
1147 |
ctab = _color_remap_ptr; |
|
1148 |
num = (num + 3) >> 2; |
|
1149 |
if (num) { |
|
1150 |
do { |
|
1151 |
*dst = ctab[*dst]; |
|
1152 |
dst++; |
|
1153 |
} while (--num); |
|
1154 |
} |
|
1155 |
||
1156 |
} while (!(done & 0x80)); |
|
1157 |
bp->dst += bp->pitch; |
|
1158 |
if (!--bp->height) |
|
1159 |
return; |
|
1160 |
||
1161 |
do { |
|
1162 |
done = src_o[0]; |
|
1163 |
src_o += (done & 0x7F) + 2; |
|
1164 |
} while (!(done & 0x80)); |
|
1165 |
if (!--bp->height) |
|
1166 |
return; |
|
1167 |
||
1168 |
do { |
|
1169 |
done = src_o[0]; |
|
1170 |
src_o += (done & 0x7F) + 2; |
|
1171 |
} while (!(done & 0x80)); |
|
1172 |
if (!--bp->height) |
|
1173 |
return; |
|
1174 |
||
1175 |
do { |
|
1176 |
done = src_o[0]; |
|
1177 |
src_o += (done & 0x7F) + 2; |
|
1178 |
} while (!(done & 0x80)); |
|
1179 |
if (!--bp->height) |
|
1180 |
return; |
|
1181 |
} |
|
1182 |
} else { |
|
1183 |
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); |
|
1184 |
for(;;) { |
|
1185 |
do { |
|
1186 |
done = src_o[0]; |
|
1187 |
num = done & 0x7F; |
|
1188 |
skip = src_o[1]; |
|
1189 |
src = src_o + 2; |
|
1190 |
src_o += num + 2; |
|
1191 |
||
1192 |
dst = bp->dst; |
|
1193 |
||
1194 |
if (skip & 1) { |
|
1195 |
skip++; |
|
1196 |
src++; |
|
1197 |
if (!--num) |
|
1198 |
continue; |
|
1199 |
} |
|
1200 |
||
1201 |
if (skip & 2) { |
|
1202 |
skip+=2; |
|
1203 |
src+=2; |
|
1204 |
if ((num-=2) <= 0) |
|
1205 |
continue; |
|
1206 |
} |
|
1207 |
||
1208 |
if ( (skip -= bp->start_x) > 0) { |
|
1209 |
dst += skip >> 2; |
|
1210 |
} else { |
|
1211 |
src -= skip; |
|
1212 |
num += skip; |
|
1213 |
if (num <= 0) |
|
1214 |
continue; |
|
1215 |
skip = 0; |
|
1216 |
} |
|
1217 |
||
1218 |
skip = skip + num - bp->width; |
|
1219 |
if (skip > 0) { |
|
1220 |
num -= skip; |
|
1221 |
if (num <= 0) |
|
1222 |
continue; |
|
1223 |
} |
|
1224 |
||
1225 |
num = (num + 3) >> 2; |
|
1226 |
||
1227 |
if (num) { |
|
1228 |
do { |
|
1229 |
*dst = *src; |
|
1230 |
dst++; |
|
1231 |
src+=4; |
|
1232 |
} while (--num); |
|
1233 |
} |
|
1234 |
||
1235 |
} while (!(done & 0x80)); |
|
1236 |
||
1237 |
bp->dst += bp->pitch; |
|
1238 |
if (!--bp->height) |
|
1239 |
return; |
|
1240 |
||
1241 |
do { |
|
1242 |
done = src_o[0]; |
|
1243 |
src_o += (done & 0x7F) + 2; |
|
1244 |
} while (!(done & 0x80)); |
|
1245 |
if (!--bp->height) |
|
1246 |
return; |
|
1247 |
||
1248 |
do { |
|
1249 |
done = src_o[0]; |
|
1250 |
src_o += (done & 0x7F) + 2; |
|
1251 |
} while (!(done & 0x80)); |
|
1252 |
if (!--bp->height) |
|
1253 |
return; |
|
1254 |
||
1255 |
do { |
|
1256 |
done = src_o[0]; |
|
1257 |
src_o += (done & 0x7F) + 2; |
|
1258 |
} while (!(done & 0x80)); |
|
1259 |
if (!--bp->height) |
|
1260 |
return; |
|
1261 |
} |
|
1262 |
} |
|
1263 |
} |
|
1264 |
||
1265 |
static void GfxBlitZoomOutUncomp(BlitterParams *bp) |
|
1266 |
{ |
|
1267 |
byte *src = bp->sprite; |
|
1268 |
byte *dst = bp->dst; |
|
1269 |
int height = bp->height; |
|
1270 |
int width = bp->width; |
|
1271 |
int i; |
|
1272 |
||
1273 |
assert(height > 0); |
|
1274 |
assert(width > 0); |
|
1275 |
||
1276 |
if (bp->mode & 1) { |
|
1277 |
if (bp->info & 1) { |
|
1278 |
byte *ctab = _color_remap_ptr,b; |
|
1279 |
height >>= 2; |
|
1280 |
if (height) do { |
|
1281 |
for(i=0; i!=width>>2; i++) |
|
1282 |
if ((b=ctab[src[i*4]]) != 0) |
|
1283 |
dst[i] = b; |
|
1284 |
src += bp->width_org * 4; |
|
1285 |
dst += bp->pitch; |
|
1286 |
} while (--height); |
|
1287 |
} |
|
1288 |
} else if (bp->mode & 2) { |
|
1289 |
if (bp->info & 1) { |
|
1290 |
byte *ctab = _color_remap_ptr; |
|
1291 |
height >>= 2; |
|
1292 |
if (height) do { |
|
1293 |
for(i=0; i!=width>>2; i++) |
|
1294 |
if (src[i*4]) |
|
1295 |
dst[i] = ctab[dst[i]]; |
|
1296 |
src += bp->width_org * 4; |
|
1297 |
dst += bp->pitch; |
|
1298 |
} while (--height); |
|
1299 |
} |
|
1300 |
} else { |
|
1301 |
if (bp->info & 1) { |
|
1302 |
height >>= 2; |
|
1303 |
if (height) do { |
|
1304 |
for(i=0; i!=width>>2; i++) |
|
1305 |
if (src[i*4]) |
|
1306 |
dst[i] = src[i*4]; |
|
1307 |
src += bp->width_org * 4; |
|
1308 |
dst += bp->pitch; |
|
1309 |
} while (--height); |
|
1310 |
} |
|
1311 |
} |
|
1312 |
} |
|
1313 |
||
1314 |
typedef void (*BlitZoomFunc)(BlitterParams *bp); |
|
1315 |
||
1348 | 1316 |
static void GfxMainBlitter(Sprite *sprite, int x, int y, int mode) |
0 | 1317 |
{ |
1318 |
DrawPixelInfo *dpi = _cur_dpi; |
|
1319 |
int start_x, start_y; |
|
1320 |
byte info; |
|
1321 |
BlitterParams bp; |
|
1322 |
int zoom_mask = ~((1 << (dpi->zoom))-1); |
|
1323 |
||
1324 |
static const BlitZoomFunc zf_tile[3] = |
|
1325 |
{ |
|
1326 |
GfxBlitTileZoomIn, |
|
1327 |
GfxBlitTileZoomMedium, |
|
1328 |
GfxBlitTileZoomOut |
|
1329 |
}; |
|
1330 |
static const BlitZoomFunc zf_uncomp[3] = |
|
1331 |
{ |
|
1332 |
GfxBlitZoomInUncomp, |
|
1333 |
GfxBlitZoomMediumUncomp, |
|
1334 |
GfxBlitZoomOutUncomp |
|
1335 |
}; |
|
1336 |
||
1337 |
/* decode sprite header */ |
|
1348 | 1338 |
x += (int16)TO_LE16(sprite->x_offs); |
1339 |
y += (int16)TO_LE16(sprite->y_offs); |
|
1340 |
bp.width_org = bp.width = TO_LE16(sprite->width); |
|
1341 |
bp.height_org = bp.height = sprite->height; |
|
1342 |
info = sprite->info; |
|
0 | 1343 |
bp.info = info; |
1348 | 1344 |
bp.sprite_org = bp.sprite = sprite->data; |
0 | 1345 |
bp.dst = dpi->dst_ptr; |
1346 |
bp.mode = mode; |
|
1347 |
bp.pitch = dpi->pitch; |
|
1348 |
||
1349 |
assert(bp.height > 0); |
|
1350 |
assert(bp.width > 0); |
|
1351 |
||
1352 |
if (info & 8) { |
|
1353 |
/* tile blit */ |
|
1354 |
start_y = 0; |
|
1355 |
||
1356 |
if (dpi->zoom > 0) { |
|
1357 |
start_y += bp.height &~ zoom_mask; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
1358 |
bp.height &= zoom_mask; |
0 | 1359 |
if (bp.height == 0) return; |
1360 |
y&=zoom_mask; |
|
1361 |
} |
|
1362 |
||
1363 |
if ( (y -= dpi->top) < 0) { |
|
1364 |
if ((bp.height += y) <= 0) |
|
1365 |
return; |
|
1366 |
start_y -= y; |
|
1367 |
y = 0; |
|
1368 |
} else { |
|
1369 |
bp.dst += bp.pitch * (y>>(dpi->zoom)); |
|
1370 |
} |
|
1371 |
bp.start_y = start_y; |
|
1372 |
||
1373 |
if ( (y = y + bp.height - dpi->height) > 0) { |
|
1374 |
if ( (bp.height -= y) <= 0) |
|
1375 |
return; |
|
1376 |
} |
|
1377 |
||
1378 |
start_x = 0; |
|
1379 |
x &= zoom_mask; |
|
1380 |
if ( (x -= dpi->left) < 0) { |
|
1381 |
if ((bp.width += x) <= 0) |
|
1382 |
return; |
|
1383 |
start_x -= x; |
|
1384 |
x = 0; |
|
1385 |
} |
|
1386 |
bp.start_x = start_x; |
|
1387 |
bp.dst += x>>(dpi->zoom); |
|
1388 |
||
1389 |
if ( (x = x + bp.width - dpi->width) > 0) { |
|
1390 |
if ( (bp.width -= x) <= 0) |
|
1391 |
return; |
|
1392 |
} |
|
1393 |
||
1394 |
zf_tile[dpi->zoom](&bp); |
|
1395 |
} else { |
|
1396 |
||
1397 |
bp.sprite += bp.width * (bp.height & ~zoom_mask); |
|
1398 |
bp.height &= zoom_mask; |
|
1399 |
if (bp.height == 0) |
|
1400 |
return; |
|
1401 |
||
1402 |
y &= zoom_mask; |
|
1403 |
||
1404 |
if ( (y -= dpi->top) < 0) { |
|
1405 |
if ((bp.height += y) <= 0) |
|
1406 |
return; |
|
1407 |
bp.sprite -= bp.width * y; |
|
1408 |
y = 0; |
|
1409 |
} else { |
|
1410 |
bp.dst += bp.pitch * (y>>(dpi->zoom)); |
|
1411 |
} |
|
1412 |
||
1413 |
if ( (y = y + bp.height - dpi->height) > 0) { |
|
1414 |
if ( (bp.height -= y) <= 0) |
|
1415 |
return; |
|
1416 |
} |
|
1417 |
||
1418 |
start_x = 0; |
|
1419 |
||
1420 |
x &= zoom_mask; |
|
1421 |
||
1422 |
if ( (x -= dpi->left) < 0) { |
|
1423 |
if ((bp.width += x) <= 0) |
|
1424 |
return; |
|
1425 |
start_x -= x; |
|
1426 |
bp.sprite -= x; |
|
1427 |
x = 0; |
|
1428 |
} |
|
1429 |
bp.dst += x>>(dpi->zoom); |
|
1430 |
||
1431 |
if ( (x = x + bp.width - dpi->width) > 0) { |
|
1432 |
if ( (bp.width -= x) <= 0) |
|
1433 |
return; |
|
1434 |
start_x += x; |
|
1435 |
} |
|
1436 |
bp.start_x = start_x; |
|
1437 |
||
1438 |
if (info&2) { |
|
1439 |
int totpix = bp.height_org * bp.width_org; |
|
1440 |
byte *dst = (byte*)alloca(totpix); |
|
1441 |
byte *src = bp.sprite_org; |
|
1442 |
signed char b; |
|
1443 |
||
461
9129fe36ef0d
(svn r679) Clarify bp.sprite assignment in GfxMainBlitter(). Pointed out by Oskar.
pasky
parents:
410
diff
changeset
|
1444 |
bp.sprite = dst + (bp.sprite - bp.sprite_org); |
0 | 1445 |
|
1446 |
while (totpix != 0) { |
|
1447 |
assert(totpix > 0); |
|
1448 |
b = *src++; |
|
1449 |
if (b >= 0) { |
|
1450 |
int i, count=b; |
|
1451 |
for(i=0; i!=count; i++) |
|
1452 |
dst[i] = src[i]; |
|
1453 |
dst += count; |
|
1454 |
src += count; |
|
1455 |
totpix -= count; |
|
1456 |
} else { |
|
1457 |
byte *tmp = dst- (((b&7)<<8)|(*src++)); |
|
1458 |
int i; |
|
1459 |
int count = -(b >> 3); |
|
1460 |
||
1461 |
for(i=0; i!=count; i++) |
|
1462 |
dst[i] = tmp[i]; |
|
1463 |
dst += count; |
|
1464 |
totpix -= count; |
|
1465 |
} |
|
1466 |
} |
|
1467 |
} |
|
1468 |
zf_uncomp[dpi->zoom](&bp); |
|
1469 |
} |
|
1470 |
} |
|
1471 |
||
798 | 1472 |
#if 0 |
410 | 1473 |
static void GfxScalePalette(int pal, byte scaling) |
0 | 1474 |
{ |
1475 |
byte *dst, *src; |
|
1476 |
size_t count; |
|
1477 |
||
1478 |
GfxInitPalettes(); |
|
1479 |
||
1480 |
dst = _cur_palette; |
|
1481 |
src = GET_PALETTE(pal); |
|
1482 |
count = 256; |
|
1483 |
do { |
|
1484 |
dst[0] = (byte)(src[0] * scaling >> 8); |
|
1485 |
dst[1] = (byte)(src[1] * scaling >> 8); |
|
1486 |
dst[2] = (byte)(src[2] * scaling >> 8); |
|
1487 |
dst += 3; |
|
1488 |
src += 3; |
|
1489 |
} while (--count); |
|
1490 |
} |
|
798 | 1491 |
#endif |
0 | 1492 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1493 |
void DoPaletteAnimations(void); |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1494 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1495 |
void GfxInitPalettes(void) |
0 | 1496 |
{ |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1497 |
int pal = _use_dos_palette?1:0; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1498 |
memcpy(_cur_palette, _palettes[pal], 256*3); |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1499 |
|
0 | 1500 |
_pal_first_dirty = 0; |
1501 |
_pal_last_dirty = 255; |
|
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1502 |
DoPaletteAnimations(); |
0 | 1503 |
} |
1504 |
||
1505 |
#define EXTR(p,q) (((uint16)(_timer_counter * (p)) * (q)) >> 16) |
|
1506 |
#define EXTR2(p,q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16) |
|
1507 |
#define COPY_TRIPLET do {d[0]=s[0+j]; d[1]=s[1+j]; d[2]=s[2+j];d+=3;}while(0) |
|
1508 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1509 |
void DoPaletteAnimations(void) |
0 | 1510 |
{ |
1511 |
const byte *s; |
|
1512 |
byte *d; |
|
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1513 |
/* Amount of colors to be rotated. |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1514 |
* A few more for the DOS palette, because the water colors are |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1515 |
* 245-254 for DOS and 217-226 for Windows. */ |
915 | 1516 |
int c = _use_dos_palette?38:28; |
0 | 1517 |
int j; |
1518 |
int i; |
|
1519 |
const ExtraPaletteValues *ev = &_extra_palette_values; |
|
619
2a8675eeeb3f
(svn r1045) -Fix: OpenTTD compiles again under VC6 (sign_de)
truelight
parents:
614
diff
changeset
|
1520 |
byte old_val[114]; // max(c*(38:28)) = 114 |
0 | 1521 |
|
1522 |
d = _cur_palette + 217*3; |
|
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1523 |
memcpy(old_val, d, c*3); |
0 | 1524 |
|
1525 |
// Dark blue water |
|
1526 |
s = ev->a; |
|
1527 |
if (_opt.landscape == LT_CANDY) s = ev->ac; |
|
1528 |
j = EXTR(320,5) * 3; |
|
1529 |
for(i=0; i!=5; i++) { |
|
1530 |
COPY_TRIPLET; |
|
1531 |
j+=3; |
|
1532 |
if (j == 15) j = 0; |
|
1533 |
} |
|
1534 |
||
1535 |
// Glittery water |
|
1536 |
s = ev->b; |
|
1537 |
if (_opt.landscape == LT_CANDY) s = ev->bc; |
|
1538 |
j = EXTR(128, 15) * 3; |
|
1539 |
for(i=0; i!=5; i++) { |
|
1540 |
COPY_TRIPLET; |
|
1541 |
j += 9; |
|
1542 |
if (j >= 45) j -= 45; |
|
1543 |
} |
|
1544 |
||
1545 |
s = ev->e; |
|
1546 |
j = EXTR2(512, 5) * 3; |
|
1547 |
for(i=0; i!=5; i++) { |
|
1548 |
COPY_TRIPLET; |
|
1549 |
j += 3; |
|
1550 |
if (j == 3*5) j = 0; |
|
1551 |
} |
|
1552 |
||
1553 |
// Oil refinery fire animation |
|
1554 |
s = ev->oil_ref; |
|
1555 |
j = EXTR2(512, 7) * 3; |
|
1556 |
for(i=0; i!=7; i++) { |
|
1557 |
COPY_TRIPLET; |
|
1558 |
j += 3; |
|
1559 |
if (j == 3*7) j = 0; |
|
1560 |
} |
|
1561 |
||
1562 |
// Radio tower blinking |
|
1563 |
{ |
|
1564 |
byte i,v; |
|
1565 |
i = (_timer_counter >> 1) & 0x7F; |
|
1566 |
(v = 255, i < 0x3f) || |
|
1567 |
(v = 128, i < 0x4A || i >= 0x75) || |
|
1568 |
(v = 20); |
|
1569 |
d[0] = v; |
|
1570 |
d[1] = d[2] = 0; |
|
1571 |
d += 3; |
|
1572 |
||
1573 |
i ^= 0x40; |
|
1574 |
(v = 255, i < 0x3f) || |
|
1575 |
(v = 128, i < 0x4A || i >= 0x75) || |
|
1576 |
(v = 20); |
|
1577 |
d[0] = v; |
|
1578 |
||
1579 |
d[1] = d[2] = 0; |
|
1580 |
d += 3; |
|
1581 |
} |
|
1582 |
||
1583 |
// Handle lighthouse and stadium animation |
|
1584 |
s = ev->lighthouse; |
|
1585 |
j = EXTR(256, 4) * 3; |
|
1586 |
for(i=0; i!=4; i++) { |
|
1587 |
COPY_TRIPLET; |
|
1588 |
j += 3; |
|
1589 |
if (j == 3*4) j = 0; |
|
1590 |
} |
|
1591 |
||
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1592 |
// Animate water for old DOS graphics |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1593 |
if(_use_dos_palette) { |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1594 |
// Dark blue water DOS |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1595 |
s = ev->a; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1596 |
if (_opt.landscape == LT_CANDY) s = ev->ac; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1597 |
j = EXTR(320,5) * 3; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1598 |
for(i=0; i!=5; i++) { |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1599 |
COPY_TRIPLET; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1600 |
j+=3; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1601 |
if (j == 15) j = 0; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1602 |
} |
915 | 1603 |
|
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1604 |
// Glittery water DOS |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1605 |
s = ev->b; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1606 |
if (_opt.landscape == LT_CANDY) s = ev->bc; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1607 |
j = EXTR(128, 15) * 3; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1608 |
for(i=0; i!=5; i++) { |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1609 |
COPY_TRIPLET; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1610 |
j += 9; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1611 |
if (j >= 45) j -= 45; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1612 |
} |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1613 |
} |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1614 |
|
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1615 |
if (memcmp(old_val, _cur_palette + 217*3, c*3)) { |
0 | 1616 |
if (_pal_first_dirty > 217) _pal_first_dirty = 217; |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
1617 |
if (_pal_last_dirty < 217+c) _pal_last_dirty = 217+c; |
0 | 1618 |
} |
1619 |
} |
|
1620 |
||
1621 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1622 |
void LoadStringWidthTable(void) |
0 | 1623 |
{ |
1624 |
int i; |
|
1625 |
byte *b; |
|
1626 |
||
1627 |
b = _stringwidth_table; |
|
1628 |
||
1629 |
// 2 equals space. |
|
1630 |
for(i=2; i != 0xE2; i++) { |
|
1631 |
*b++ = (byte)((i < 93 || i >= 129 || i == 98) ? GetSpritePtr(i)[2] : 0); |
|
1632 |
} |
|
1633 |
||
1634 |
for(i=0xE2; i != 0x1C2; i++) { |
|
1635 |
*b++ = (byte)((i < 317 || i >= 353) ? GetSpritePtr(i)[2]+1 : 0); |
|
1636 |
} |
|
1637 |
||
1638 |
for(i=0x1C2; i != 0x2A2; i++) { |
|
1639 |
*b++ = (byte)((i < 541 || i >= 577) ? GetSpritePtr(i)[2]+1 : 0); |
|
1640 |
} |
|
1641 |
} |
|
1642 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1643 |
void ScreenSizeChanged(void) |
0 | 1644 |
{ |
1645 |
// check the dirty rect |
|
1646 |
if (_invalid_rect.right >= _screen.width) _invalid_rect.right = _screen.width; |
|
1647 |
if (_invalid_rect.bottom >= _screen.height) _invalid_rect.bottom = _screen.height; |
|
1648 |
||
1649 |
// screen size changed and the old bitmap is invalid now, so we don't want to undraw it |
|
1650 |
_cursor.visible = false; |
|
1651 |
} |
|
1652 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1653 |
void UndrawMouseCursor(void) |
0 | 1654 |
{ |
1655 |
if (_cursor.visible) { |
|
1656 |
_cursor.visible = false; |
|
1657 |
memcpy_pitch( |
|
1658 |
_screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch, |
|
1659 |
_cursor_backup, |
|
1660 |
_cursor.draw_size.x, _cursor.draw_size.y, _cursor.draw_size.x, _screen.pitch); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
1661 |
|
0 | 1662 |
_video_driver->make_dirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y); |
1663 |
} |
|
1664 |
} |
|
1665 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1666 |
void DrawMouseCursor(void) |
0 | 1667 |
{ |
1668 |
int x,y,w,h; |
|
1669 |
||
1670 |
// Don't draw the mouse cursor if it's already drawn |
|
1671 |
if (_cursor.visible) { |
|
1672 |
if (!_cursor.dirty) |
|
1673 |
return; |
|
1674 |
UndrawMouseCursor(); |
|
1675 |
} |
|
1676 |
||
1677 |
w = _cursor.size.x; |
|
1678 |
x = _cursor.pos.x + _cursor.offs.x; |
|
1679 |
if (x < 0) { w += x; x=0; } |
|
1680 |
if (w>_screen.width-x) { w = _screen.width-x; } |
|
1681 |
if (w <= 0) return; |
|
1682 |
_cursor.draw_pos.x = x; |
|
1683 |
_cursor.draw_size.x = w; |
|
1684 |
||
1685 |
h = _cursor.size.y; |
|
1686 |
y = _cursor.pos.y + _cursor.offs.y; |
|
1687 |
if (y < 0) { h += y; y=0; } |
|
1688 |
if (h>_screen.height-y) { h = _screen.height-y; } |
|
1689 |
if (h <= 0) return; |
|
1690 |
_cursor.draw_pos.y = y; |
|
1691 |
_cursor.draw_size.y = h; |
|
1692 |
||
1130
236aa7efbe7a
(svn r1631) A couple of fixes for the signed/unsigned warnings. Only train_cmd.c remains to need fixing...
dominik
parents:
1095
diff
changeset
|
1693 |
assert(w*h < (int) sizeof(_cursor_backup)); |
0 | 1694 |
|
1695 |
// Make backup of stuff below cursor |
|
1696 |
memcpy_pitch( |
|
1697 |
_cursor_backup, |
|
1698 |
_screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch, |
|
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
1699 |
_cursor.draw_size.x, _cursor.draw_size.y, _screen.pitch, _cursor.draw_size.x); |
0 | 1700 |
|
1701 |
// Draw cursor on screen |
|
1702 |
_cur_dpi = &_screen; |
|
1703 |
DrawSprite(_cursor.sprite, _cursor.pos.x, _cursor.pos.y); |
|
1704 |
||
1705 |
_video_driver->make_dirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y); |
|
1706 |
||
1707 |
_cursor.visible = true; |
|
1708 |
_cursor.dirty = false; |
|
1709 |
} |
|
1710 |
||
798 | 1711 |
#if defined(_DEBUG) |
410 | 1712 |
static void DbgScreenRect(int left, int top, int right, int bottom) |
0 | 1713 |
{ |
1714 |
DrawPixelInfo dp,*old; |
|
1715 |
||
1716 |
old = _cur_dpi; |
|
1717 |
_cur_dpi = &dp; |
|
1718 |
dp = _screen; |
|
1719 |
GfxFillRect(left, top, right-1, bottom-1, rand() & 255); |
|
1720 |
_cur_dpi = old; |
|
1721 |
} |
|
798 | 1722 |
#endif |
0 | 1723 |
|
1724 |
extern bool _dbg_screen_rect; |
|
1725 |
||
1726 |
void RedrawScreenRect(int left, int top, int right, int bottom) |
|
1727 |
{ |
|
1728 |
assert(right <= _screen.width && bottom <= _screen.height); |
|
1729 |
if (_cursor.visible) { |
|
1730 |
if (right > _cursor.draw_pos.x && |
|
1731 |
left < _cursor.draw_pos.x + _cursor.draw_size.x && |
|
1732 |
bottom > _cursor.draw_pos.y && |
|
1733 |
top < _cursor.draw_pos.y + _cursor.draw_size.y) { |
|
1734 |
UndrawMouseCursor(); |
|
1735 |
} |
|
1736 |
} |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1737 |
UndrawTextMessage(); |
0 | 1738 |
|
1739 |
#if defined(_DEBUG) |
|
1740 |
if (_dbg_screen_rect) |
|
1741 |
DbgScreenRect(left, top, right, bottom); |
|
1742 |
else |
|
1743 |
#endif |
|
1744 |
DrawOverlappedWindowForAll(left, top, right, bottom); |
|
1745 |
||
1746 |
_video_driver->make_dirty(left, top, right-left, bottom-top); |
|
1747 |
} |
|
1748 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1749 |
void DrawDirtyBlocks(void) |
0 | 1750 |
{ |
1751 |
byte *b = _dirty_blocks; |
|
1752 |
int x=0,y=0; |
|
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
1753 |
const int w = (_screen.width + 63) & ~63; |
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
1754 |
const int h = (_screen.height + 7) & ~7; |
0 | 1755 |
|
1756 |
do { |
|
1757 |
if (*b != 0) { |
|
1758 |
int left,top; |
|
1759 |
int right = x + 64; |
|
1760 |
int bottom = y; |
|
1761 |
byte *p = b; |
|
1762 |
int h2; |
|
1763 |
// First try coalescing downwards |
|
1764 |
do { |
|
1765 |
*p = 0; |
|
1766 |
p += DIRTY_BYTES_PER_LINE; |
|
1767 |
bottom += 8; |
|
1768 |
} while (bottom != h && *p); |
|
1769 |
||
1770 |
// Try coalescing to the right too. |
|
1771 |
h2 = (bottom - y) >> 3; |
|
1772 |
assert(h2>0); |
|
1773 |
p = b; |
|
1774 |
||
1775 |
while (right != w) { |
|
1776 |
byte *p2 = ++p; |
|
1777 |
int h = h2; |
|
1778 |
// Check if a full line of dirty flags is set. |
|
1779 |
do { |
|
1780 |
if (!*p2) goto no_more_coalesc; |
|
1781 |
p2 += DIRTY_BYTES_PER_LINE; |
|
1782 |
} while (--h); |
|
1783 |
||
1784 |
// Wohoo, can combine it one step to the right! |
|
1785 |
// Do that, and clear the bits. |
|
1786 |
right += 64; |
|
1787 |
||
1788 |
h = h2; |
|
1789 |
p2 = p; |
|
1790 |
do { |
|
1791 |
*p2 = 0; |
|
1792 |
p2 += DIRTY_BYTES_PER_LINE; |
|
1793 |
} while (--h); |
|
1794 |
} |
|
1795 |
no_more_coalesc:; |
|
1796 |
||
1797 |
left = x; |
|
1798 |
top = y; |
|
1799 |
||
1800 |
if (left < _invalid_rect.left)left = _invalid_rect.left; |
|
1801 |
if (top < _invalid_rect.top) top = _invalid_rect.top; |
|
1802 |
if (right > _invalid_rect.right)right = _invalid_rect.right; |
|
1803 |
if (bottom > _invalid_rect.bottom)bottom = _invalid_rect.bottom; |
|
1804 |
||
1805 |
if (left < right && top < bottom) { |
|
1806 |
RedrawScreenRect(left, top, right, bottom); |
|
1807 |
} |
|
1808 |
||
1809 |
} |
|
1810 |
} while (b++, (x+=64) != w || (x=0,b+=-(w>>6)+DIRTY_BYTES_PER_LINE,(y+=8) != h)); |
|
1811 |
||
1812 |
_invalid_rect.left = w; |
|
1813 |
_invalid_rect.top = h; |
|
1814 |
_invalid_rect.right = 0; |
|
1815 |
_invalid_rect.bottom = 0; |
|
1816 |
} |
|
1817 |
||
1818 |
||
1819 |
void SetDirtyBlocks(int left, int top, int right, int bottom) |
|
1820 |
{ |
|
1821 |
byte *b; |
|
1822 |
int width,height,i; |
|
1823 |
||
1824 |
if (left < 0) left = 0; |
|
1825 |
if (top < 0) top = 0; |
|
1826 |
if (right > _screen.width) right = _screen.width; |
|
1827 |
if (bottom > _screen.height) bottom = _screen.height; |
|
1828 |
||
1829 |
if (left >= right || top >= bottom) |
|
1830 |
return; |
|
1831 |
||
1832 |
if (left < _invalid_rect.left) _invalid_rect.left = left; |
|
1833 |
if (top < _invalid_rect.top) _invalid_rect.top = top; |
|
1834 |
if (right > _invalid_rect.right)_invalid_rect.right = right; |
|
1835 |
if (bottom > _invalid_rect.bottom)_invalid_rect.bottom = bottom; |
|
1836 |
||
1837 |
left >>= 6; |
|
1838 |
top >>= 3; |
|
1839 |
||
1840 |
b = _dirty_blocks + top * DIRTY_BYTES_PER_LINE + left; |
|
1841 |
||
1842 |
width = ((right-1) >> 6) - left + 1; |
|
1843 |
height = ((bottom-1) >> 3) - top + 1; |
|
1844 |
||
1845 |
assert(width > 0 && height > 0); |
|
1846 |
||
1847 |
do { |
|
1848 |
i=width; |
|
1849 |
do b[--i] = 0xFF; while (i); |
|
1850 |
||
1851 |
b += DIRTY_BYTES_PER_LINE; |
|
1852 |
} while (--height); |
|
1853 |
} |
|
1854 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1855 |
void MarkWholeScreenDirty(void) |
0 | 1856 |
{ |
1857 |
SetDirtyBlocks(0, 0, _screen.width, _screen.height); |
|
1858 |
} |
|
1859 |
||
1860 |
bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, int width, int height) |
|
1861 |
{ |
|
1862 |
int t; |
|
1863 |
||
1864 |
if (o == NULL) |
|
1865 |
o = _cur_dpi; |
|
1866 |
||
1867 |
n->zoom = 0; |
|
1868 |
||
1869 |
assert(width > 0); |
|
1870 |
assert(height > 0); |
|
1871 |
||
1872 |
n->left = 0; |
|
1873 |
if ((left -= o->left) < 0) { |
|
1874 |
if ((width += left) < 0) |
|
1875 |
return false; |
|
1876 |
n->left = -left; |
|
1877 |
left = 0; |
|
1878 |
} |
|
1879 |
||
1880 |
if ((t=width + left - o->width) > 0) { |
|
1881 |
if ((width -= t) < 0) |
|
1882 |
return false; |
|
1883 |
} |
|
1884 |
n->width = width; |
|
1885 |
||
1886 |
n->top = 0; |
|
1887 |
if ((top -= o->top) < 0) { |
|
1888 |
if ((height += top) < 0) |
|
1889 |
return false; |
|
1890 |
n->top = -top; |
|
1891 |
top = 0; |
|
1892 |
} |
|
1893 |
||
1894 |
n->dst_ptr = o->dst_ptr + left + top * (n->pitch = o->pitch); |
|
1895 |
||
1896 |
if ((t=height + top - o->height) > 0) { |
|
1897 |
if ((height-=t) < 0) |
|
1898 |
return false; |
|
1899 |
} |
|
1900 |
n->height = height; |
|
1901 |
||
1902 |
||
1903 |
return true; |
|
1904 |
} |
|
1905 |
||
1906 |
static void SetCursorSprite(uint cursor) |
|
1907 |
{ |
|
1908 |
CursorVars *cv = &_cursor; |
|
1348 | 1909 |
const Sprite *p; |
0 | 1910 |
|
1911 |
if (cv->sprite == cursor) |
|
1912 |
return; |
|
1913 |
||
1914 |
p = GetSpritePtr(cursor & 0x3FFF); |
|
1915 |
cv->sprite = cursor; |
|
1348 | 1916 |
cv->size.y = p->height; |
1917 |
cv->size.x = TO_LE16(p->width); |
|
1918 |
cv->offs.x = (int16)TO_LE16(p->x_offs); |
|
1919 |
cv->offs.y = (int16)TO_LE16(p->y_offs); |
|
0 | 1920 |
|
1921 |
cv->dirty = true; |
|
1922 |
} |
|
1923 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1924 |
static void SwitchAnimatedCursor(void) |
0 | 1925 |
{ |
1926 |
CursorVars *cv = &_cursor; |
|
1927 |
const uint16 *cur; |
|
1928 |
uint sprite; |
|
1929 |
||
1930 |
cur = cv->animate_cur; |
|
1931 |
if (cur == NULL || *cur == 0xFFFF) |
|
1932 |
cur = cv->animate_list; |
|
1933 |
sprite = cur[0]; |
|
1934 |
cv->animate_timeout = cur[1]; |
|
1935 |
cv->animate_cur = cur + 2; |
|
1936 |
||
1937 |
SetCursorSprite(sprite); |
|
1938 |
} |
|
1939 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1940 |
void CursorTick(void) |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1056
diff
changeset
|
1941 |
{ |
0 | 1942 |
CursorVars *cv = &_cursor; |
1943 |
if (cv->animate_timeout && !--cv->animate_timeout) |
|
1944 |
SwitchAnimatedCursor(); |
|
1945 |
} |
|
1946 |
||
1947 |
void SetMouseCursor(uint cursor) |
|
1948 |
{ |
|
1949 |
// Turn off animation |
|
1950 |
_cursor.animate_timeout = 0; |
|
1951 |
// Set cursor |
|
1952 |
SetCursorSprite(cursor); |
|
1953 |
} |
|
1954 |
||
1955 |
void SetAnimatedMouseCursor(const uint16 *table) |
|
1956 |
{ |
|
1957 |
_cursor.animate_list = table; |
|
1958 |
_cursor.animate_cur = NULL; |
|
1959 |
SwitchAnimatedCursor(); |
|
1960 |
} |
|
1961 |
||
1962 |
bool ChangeResInGame(int w, int h) |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
1963 |
{ |
0 | 1964 |
if ((_screen.width != w || _screen.height != h) && !_video_driver->change_resolution(w, h)) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
126
diff
changeset
|
1965 |
return false; |
0 | 1966 |
|
1967 |
_cur_resolution[0] = w; |
|
1968 |
_cur_resolution[1] = h; |
|
1969 |
return true; |
|
1970 |
} |
|
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1971 |
|
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1972 |
void ToggleFullScreen(const bool full_screen) |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1973 |
{ |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1974 |
_fullscreen = full_screen; |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1975 |
/* use preset resolutions, not _screen.height and _screen.width. On windows for example |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1976 |
if Desktop-size is 1280x1024, and gamesize is also 1280x1024, _screen.height will be |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1977 |
only 1000 because of possible start-bar. For this reason you cannot switch to |
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1978 |
fullscreen mode from this resolution. Use of preset resolution will fix this */ |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1979 |
if (!_video_driver->change_resolution(_cur_resolution[0], _cur_resolution[1])) |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1980 |
_fullscreen ^= true; // switching resolution failed, put back full_screen to original status |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
1981 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1982 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1983 |
uint16 GetDrawStringPlayerColor(byte player) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1984 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1985 |
// Get the color for DrawString-subroutines which matches the color |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1986 |
// of the player |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1987 |
if (player == OWNER_SPECTATOR || player == OWNER_SPECTATOR - 1) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1988 |
return 1; |
657
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
619
diff
changeset
|
1989 |
return (_color_list[_player_colors[player]].window_color_1b) | IS_PALETTE_COLOR; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
510
diff
changeset
|
1990 |
} |