shithub: wl3d

Download patch

ref: efc660ab1ac0f887e06fc3c20ca51244f27ae87c
parent: b109f9a857d3a69745e707913e5b321c0740bdb3
author: Konstantinn Bonnet <qu7uux@gmail.com>
date: Wed Apr 13 02:32:27 EDT 2016

fuck shit goddamn palette crap arrgh

red and white shift palettes are generated based on the base palette (here C0),
which is different for spear of destiny-based versions, hence we need to
account for that, and modify those palettes in addition to C0.
generation of individual values (cf reference code; acid prompt elided):
% acid
p166=0x2d083f
p167=0x2a003f
defn rp(p, i) {
	r=p>>16 & 0xff;
	g=p>>8 & 0xff;
	b=p & 0xff;
	r=(r + (64 - r) * i/8) * 255/63 & 0xff;
	g=(g + (0 - g) * i/8) * 255/63 & 0xff;
	b=(b + (0 - b) * i/8) * 255/63 & 0xff;
	print(r<<16 | g<<8 | b\X, "\n");
	}
defn wp(p, i) {
	r=p>>16 & 0xff;
	g=p>>8 & 0xff;
	b=p & 0xff;
	r=(r + (64 - r) * i/20) * 255/63 & 0xff;
	g=(g + (62 - g) * i/20) * 255/63 & 0xff;
	b=(b + (0 - b) * i/20) * 255/63 & 0xff;
	print(r<<16 | g<<8 | b\X, "\n");
	}
i=1
while i<7 do { rp(s166, i); rp(s167, i); i=i+1; }
i=1
while i<4 do { wp(s166, i); wp(s167, i); i=i+1; }

--- a/fs.c
+++ b/fs.c
@@ -387,6 +387,19 @@
 	}
 };
 
+static u32int sodpal[] = {
+	0x003800, 0x002800,
+	0x203400, 0x202400,
+	0x402c00, 0x402000,
+	0x612400, 0x611c00,
+	0x811c00, 0x811400,
+	0xa11800, 0xa11000,
+	0xc21000, 0xc20c00,
+	0x0c4000, 0x0c3000,
+	0x184800, 0x183c00,
+	0x245500, 0x244400
+};
+
 /* what bullshit. */
 uchar *pict;
 static uchar picts[4][Pend]={ {
@@ -913,6 +926,20 @@
 }
 
 void
+fixpal(void)
+{
+	u32int *p, *s;
+
+	p = pals[C0] + 166;
+	s = sodpal;
+	while(p < pals[Cfad]){
+		p[0] = *s++;
+		p[1] = *s++;
+		p += nelem(pals[C0]);
+	}
+}
+
+void
 dat(char *dir)
 {
 	rfork(RFNAMEG);
@@ -925,9 +952,7 @@
 	audiot();
 	gfx();
 
+	if(ver >= SDM)
+		fixpal();
 	pal = pals[C0];
-	if(ver >= SDM){
-		pal[166] = 0x003800;
-		pal[167] = 0x002800;
-	}
 }