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