return image_rgba;
}
+/*
+============
+LoadLMP
+============
+*/
+qbyte *LoadLMPAs8Bit (qbyte *f, int matchwidth, int matchheight)
+{
+ qbyte *image_8bit;
+ int width, height;
+
+ if (loadsize < 9)
+ {
+ Con_Printf("LoadLMPAs8Bit: invalid LMP file\n");
+ return NULL;
+ }
+
+ // parse the very complicated header *chuckle*
+ width = f[0] + f[1] * 256 + f[2] * 65536 + f[3] * 16777216;
+ height = f[4] + f[5] * 256 + f[6] * 65536 + f[7] * 16777216;
+ if ((unsigned) width > 4096 || (unsigned) height > 4096)
+ {
+ Con_Printf("LoadLMPAs8Bit: invalid size\n");
+ return NULL;
+ }
+ if ((matchwidth && width != matchwidth) || (matchheight && height != matchheight))
+ return NULL;
+
+ if (loadsize < 8 + width * height)
+ {
+ Con_Printf("LoadLMPAs8Bit: invalid LMP file\n");
+ return NULL;
+ }
+
+ image_width = width;
+ image_height = height;
+
+ image_8bit = Mem_Alloc(tempmempool, image_width * image_height);
+ if (!image_8bit)
+ {
+ Con_Printf("LoadLMPAs8Bit: not enough memory for %i by %i image\n", image_width, image_height);
+ return NULL;
+ }
+ memcpy(image_8bit, f + 8, image_width * image_height);
+ return image_8bit;
+}
+
void Image_StripImageExtension (char *in, char *out)
{
char *end, *temp;
}
// LordHavoc: rewrote this code greatly
-void M_MenuPlayerTranslate (qbyte *translation)
+void M_MenuPlayerTranslate (qbyte *translation, int top, int bottom)
{
- int i, c;
+ int i;
unsigned int trans[4096];
- qpic_t *p;
+ qbyte *data, *f;
+ static qbyte pixels[4096];
+ static int menuplyr_width, menuplyr_height, menuplyr_top, menuplyr_bottom, menuplyr_load = true, menuplyr_failed = false;
- p = W_GetLumpName ("gfx/menuplyr.lmp");
- if (!p)
+ if (menuplyr_failed)
return;
- c = p->width * p->height;
- if (c > 4096)
- {
- Con_Printf("M_MenuPlayerTranslate: image larger than 4096 pixel buffer\n");
+ if (menuplyr_top == top && menuplyr_bottom == bottom)
return;
+
+ menuplyr_top = top;
+ menuplyr_bottom = bottom;
+
+ if (menuplyr_load)
+ {
+ menuplyr_load = false;
+ f = COM_LoadFile("gfx/menuplyr.lmp", true);
+ if (!f)
+ {
+ menuplyr_failed = true;
+ return;
+ }
+ data = LoadLMPAs8Bit (f, 0, 0);
+ Mem_Free(f);
+ if (image_width * image_height > 4096)
+ {
+ Con_Printf("M_MenuPlayerTranslate: image larger than 4096 pixel buffer\n");
+ Mem_Free(data);
+ menuplyr_failed = true;
+ return;
+ }
+ menuplyr_width = image_width;
+ menuplyr_height = image_height;
+ memcpy(pixels, data, menuplyr_width * menuplyr_height);
+ Mem_Free(data);
}
- for (i = 0;i < c;i++)
- trans[i] = d_8to24table[translation[((qbyte *)p->data)[i]]];
+ M_BuildTranslationTable (menuplyr_top*16, menuplyr_bottom*16);
+
+ for (i = 0;i < menuplyr_width * menuplyr_height;i++)
+ trans[i] = d_8to24table[translation[pixels[i]]];
- Draw_NewPic("gfx/menuplyr.lmp", p->width, p->height, true, (qbyte *)trans);
+ Draw_NewPic("gfx/menuplyr.lmp", menuplyr_width, menuplyr_height, true, (qbyte *)trans);
}
void M_Setup_Draw (void)
M_DrawPic (160, 64, "gfx/bigbox.lmp");
// LordHavoc: rewrote this code greatly
- M_BuildTranslationTable (setup_top*16, setup_bottom*16);
- M_MenuPlayerTranslate (translationTable);
+ M_MenuPlayerTranslate (translationTable, setup_top, setup_bottom);
M_DrawPic (172, 72, "gfx/menuplyr.lmp");
M_DrawCharacter (56, setup_cursor_table [setup_cursor], 12+((int)(realtime*4)&1));
}
}
- if (setup_top > 13)
+ if (setup_top > 15)
setup_top = 0;
if (setup_top < 0)
- setup_top = 13;
- if (setup_bottom > 13)
+ setup_top = 15;
+ if (setup_bottom > 15)
setup_bottom = 0;
if (setup_bottom < 0)
- setup_bottom = 13;
+ setup_bottom = 15;
}
//=============================================================================