summaryrefslogtreecommitdiff
path: root/gfx.c
diff options
context:
space:
mode:
authordominik <dominik@openttd.org>2004-12-12 20:36:24 +0000
committerdominik <dominik@openttd.org>2004-12-12 20:36:24 +0000
commit52134822b8fa62fb2ac680c6e598cceb1996a213 (patch)
tree43d5dfaaad2db9071fd4d6ed612bea8eb269ce09 /gfx.c
parent3c3ba97d11581cd67cd701fb8f755109401ff995 (diff)
downloadopenttd-52134822b8fa62fb2ac680c6e598cceb1996a213.tar.xz
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
Please read the Readme for further information. There are some minor graphical glitches when you use the DOS files. E.g. the autorail button is a bit screwed up.
Diffstat (limited to 'gfx.c')
-rw-r--r--gfx.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/gfx.c b/gfx.c
index af9266ee3..821c08278 100644
--- a/gfx.c
+++ b/gfx.c
@@ -1483,14 +1483,18 @@ static void GfxScalePalette(int pal, byte scaling)
} while (--count);
}
+void DoPaletteAnimations();
+
void GfxInitPalettes()
{
- memcpy(_cur_palette, _palettes[0], 256*3);
+ int pal = _use_dos_palette?1:0;
+ memcpy(_cur_palette, _palettes[pal], 256*3);
+
_pal_first_dirty = 0;
_pal_last_dirty = 255;
+ DoPaletteAnimations();
}
-
#define EXTR(p,q) (((uint16)(_timer_counter * (p)) * (q)) >> 16)
#define EXTR2(p,q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16)
#define COPY_TRIPLET do {d[0]=s[0+j]; d[1]=s[1+j]; d[2]=s[2+j];d+=3;}while(0)
@@ -1499,13 +1503,17 @@ void DoPaletteAnimations()
{
const byte *s;
byte *d;
+ /* Amount of colors to be rotated.
+ * A few more for the DOS palette, because the water colors are
+ * 245-254 for DOS and 217-226 for Windows. */
+ int c = _use_dos_palette?38:28;
int j;
int i;
const ExtraPaletteValues *ev = &_extra_palette_values;
- byte old_val[28*3];
+ byte old_val[c*3];
d = _cur_palette + 217*3;
- memcpy(old_val, d, 28*3);
+ memcpy(old_val, d, c*3);
// Dark blue water
s = ev->a;
@@ -1574,9 +1582,32 @@ void DoPaletteAnimations()
if (j == 3*4) j = 0;
}
- if (memcmp(old_val, _cur_palette + 217*3, 28*3)) {
+ // Animate water for old DOS graphics
+ if(_use_dos_palette) {
+ // Dark blue water DOS
+ s = ev->a;
+ if (_opt.landscape == LT_CANDY) s = ev->ac;
+ j = EXTR(320,5) * 3;
+ for(i=0; i!=5; i++) {
+ COPY_TRIPLET;
+ j+=3;
+ if (j == 15) j = 0;
+ }
+
+ // Glittery water DOS
+ s = ev->b;
+ if (_opt.landscape == LT_CANDY) s = ev->bc;
+ j = EXTR(128, 15) * 3;
+ for(i=0; i!=5; i++) {
+ COPY_TRIPLET;
+ j += 9;
+ if (j >= 45) j -= 45;
+ }
+ }
+
+ if (memcmp(old_val, _cur_palette + 217*3, c*3)) {
if (_pal_first_dirty > 217) _pal_first_dirty = 217;
- if (_pal_last_dirty < 217+29-1) _pal_last_dirty = 217+29-1;
+ if (_pal_last_dirty < 217+c) _pal_last_dirty = 217+c;
}
}