ref: 999f960108cdd4f36aff80d80b898030b9177275
parent: 60dafa3dfb733d569305e406d10d4b7d43e9cf00
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Oct 14 00:25:01 EDT 2024
get pics palette translation back
--- a/common.c
+++ b/common.c
@@ -1,5 +1,7 @@
#include "quakedef.h"
+pixel_t q1pal[256], q1palindexed[256];
+
cvar_t registered = {"registered","0"};
char com_token[1024];
--- a/draw.c
+++ b/draw.c
@@ -63,8 +63,8 @@
q->width = LittleLong(q->width);
q->height = LittleLong(q->height);
n = q->width*q->height;
- q = Cache_Realloc(&pic->cache, sizeof(*q)+n*sizeof(pixel_t));
- torgbx((byte*)q->pixels, q->pixels, n);
+ q = Cache_Realloc(&pic->cache, sizeof(*q) + n*sizeof(pixel_t));
+ paltorgbx((byte*)q->pixels, q->pixels, n, q1palindexed);
return q;
}
@@ -230,8 +230,8 @@
*/
void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation)
{
- pixel_t *dest, *source, tpix;
- int v, u;
+ pixel_t *dest, *source, tpix;
+ int v, u;
if (x < 0 || y < 0 || x+pic->width > vid.width || y+pic->height > vid.height)
fatal ("Draw_TransPic: bad coordinates");
@@ -241,7 +241,7 @@
for(v=0; v<pic->height; v++){
for(u=0; u<pic->width; u++)
if(opaque(tpix = source[u]))
- dest[u] = tpix;
+ dest[u] = q1pal[translation[tpix>>24]];
dest += vid.width;
source += pic->width;
}
--- a/i_wad.c
+++ b/i_wad.c
@@ -139,13 +139,12 @@
q = Cache_Alloc(c, sizeof(*q) + n*sizeof(pixel_t));
q->width = w;
q->height = h;
-
if(wad->ver == WAD_VER2){
- for(i = 0; i < n; i++)
- q->pixels[i] = q1pal[p[i]];
+ for(i = 0; i < n; i++, p++)
+ q->pixels[i] = q1palindexed[*p];
}else if(wad->ver == WAD_VER3 && palsz > 0){
- for(i = 0; i < n; i++){
- j = (*p++)*3;
+ for(i = 0; i < n; i++, p++){
+ j = *p*3;
q->pixels[i] = j < palsz*3 ? (0xff<<24 | pal[j+0]<<16 | pal[j+1]<<8 | pal[j+2]) : 0;
}
}
--- a/quakedef.h
+++ b/quakedef.h
@@ -186,7 +186,7 @@
#define opaque(p) ((p) != 0)
-extern pixel_t q1pal[256];
+extern pixel_t q1pal[256], q1palindexed[256];
void pal3torgbx(byte *in, pixel_t *out, int n, byte *pal, int palsz);
void paltorgbx(byte *in, pixel_t *out, int n, pixel_t *pal);
void torgbx(byte *in, pixel_t *out, int n);
--- a/vid_plan9.c
+++ b/vid_plan9.c
@@ -7,7 +7,6 @@
Point center; /* of window */
Rectangle grabr;
-pixel_t q1pal[256];
static Image *fbi;
static s32int *scibuf;
static int scifactor;
@@ -170,9 +169,12 @@
int x;
byte *p;
- for(p = p0, x = 0; x < 256; x++, p += 3)
+ for(p = p0, x = 0; x < 256; x++, p += 3){
q1pal[x] = (x < 256-32 ? 0xff : 0)<<24 | p[0]<<16 | p[1]<<8 | p[2];
- q1pal[255] &= 0;
+ q1palindexed[x] = opaque(q1pal[x]) ? (x<<24 | p[0]<<16 | p[1]<<8 | p[2]) : 0;
+ }
+ q1pal[255] = 0;
+ q1palindexed[255] = 0;
scr_fullupdate = 0;
}
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -2,8 +2,6 @@
#include "colormatrix.h"
#include <SDL.h>
-pixel_t q1pal[256];
-
static SDL_Renderer *rend;
static SDL_Texture *fbi;
static SDL_Window *win;
@@ -119,9 +117,12 @@
int x;
byte *p;
- for(p = p0, x = 0; x < 256; x++, p += 3)
+ for(p = p0, x = 0; x < 256; x++, p += 3){
q1pal[x] = (x < 256-32 ? 0xff : 0)<<24 | p[0]<<16 | p[1]<<8 | p[2];
- q1pal[255] &= 0;
+ q1palindexed[x] = opaque(q1pal[x]) ? (x<<24 | p[0]<<16 | p[1]<<8 | p[2]) : 0;
+ }
+ q1pal[255] = 0;
+ q1palindexed[255] = 0;
scr_fullupdate = 0;
}