gfx.c
changeset 614 e016770cb781
parent 543 e3b43338096b
child 619 2a8675eeeb3f
--- a/gfx.c	Sun Dec 12 18:51:24 2004 +0000
+++ b/gfx.c	Sun Dec 12 20:36:24 2004 +0000
@@ -1483,14 +1483,18 @@
 	} 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 @@
 {
 	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 @@
 		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;
 	}
 }