/* ================== SCR_Init ================== */ void SCR_Init (void) { Cvar_RegisterVariable (&scr_fov); Cvar_RegisterVariable (&scr_viewsize); Cvar_RegisterVariable (&scr_conspeed); Cvar_RegisterVariable (&scr_showram); Cvar_RegisterVariable (&scr_showturtle); Cvar_RegisterVariable (&scr_showpause); Cvar_RegisterVariable (&scr_centertime); Cvar_RegisterVariable (&scr_printspeed); Cvar_RegisterVariable (&scr_allowsnap); // // register our commands // Cmd_AddCommand ("screenshot",SCR_ScreenShot_f); Cmd_AddCommand ("snap",SCR_RSShot_f); Cmd_AddCommand ("sizeup",SCR_SizeUp_f); Cmd_AddCommand ("sizedown",SCR_SizeDown_f); scr_ram = W_GetLumpName ("ram"); scr_net = W_GetLumpName ("net"); scr_turtle = W_GetLumpName ("turtle"); scr_initialized = true; }
// // R_InitColormaps // void R_InitColormaps (void) { // [RH] Try and convert BOOM colormaps into blending values. // This is a really rough hack, but it's better than // not doing anything with them at all (right?) int lastfakecmap = W_CheckNumForName ("C_END"); firstfakecmap = W_CheckNumForName ("C_START"); if (firstfakecmap == -1 || lastfakecmap == -1) numfakecmaps = 1; else { if(firstfakecmap > lastfakecmap) I_Error("no fake cmaps"); numfakecmaps = lastfakecmap - firstfakecmap; } realcolormaps = (byte *)Z_Malloc (256*(NUMCOLORMAPS+1)*numfakecmaps+255,PU_STATIC,0); realcolormaps = (byte *)(((ptrdiff_t)realcolormaps + 255) & ~255); fakecmaps = (FakeCmap *)Z_Malloc (sizeof(*fakecmaps) * numfakecmaps, PU_STATIC, 0); fakecmaps[0].name[0] = 0; R_SetDefaultColormap ("COLORMAP"); if (numfakecmaps > 1) { int i; size_t j; palette_t *pal = GetDefaultPalette (); for (i = ++firstfakecmap, j = 1; j < numfakecmaps; i++, j++) { if (W_LumpLength (i) >= (NUMCOLORMAPS+1)*256) { int k, r, g, b; byte *map = (byte *)W_CacheLumpNum (i, PU_CACHE); memcpy (realcolormaps+(NUMCOLORMAPS+1)*256*j, map, (NUMCOLORMAPS+1)*256); if(pal->basecolors) { r = RPART(pal->basecolors[*map]); g = GPART(pal->basecolors[*map]); b = BPART(pal->basecolors[*map]); W_GetLumpName (fakecmaps[j].name, i); for (k = 1; k < 256; k++) { r = (r + RPART(pal->basecolors[map[k]])) >> 1; g = (g + GPART(pal->basecolors[map[k]])) >> 1; b = (b + BPART(pal->basecolors[map[k]])) >> 1; } fakecmaps[j].blend = MAKEARGB (255, r, g, b); } }
/* =============== Draw_LoadPics -- johnfitz =============== */ void Draw_LoadPics (void) { byte *data; src_offset_t offset; data = (byte *) W_GetLumpName ("conchars"); if (!data) Sys_Error ("Draw_LoadPics: couldn't load conchars"); offset = (src_offset_t)data - (src_offset_t)wad_base; char_texture = TexMgr_LoadImage (NULL, WADFILENAME":conchars", 128, 128, SRC_INDEXED, data, WADFILENAME, offset, TEXPREF_ALPHA | TEXPREF_NEAREST | TEXPREF_NOPICMIP | TEXPREF_CONCHARS); draw_disc = Draw_PicFromWad ("disc"); draw_backtile = Draw_PicFromWad ("backtile"); }
/* ================ Draw_PicFromWad ================ */ qpic_t *Draw_PicFromWad (const char *name) { qpic_t *p; glpic_t gl; src_offset_t offset; //johnfitz p = (qpic_t *) W_GetLumpName (name); if (!p) return pic_nul; //johnfitz // load little ones into the scrap if (p->width < 64 && p->height < 64) { int x, y; int i, j, k; int texnum; texnum = Scrap_AllocBlock (p->width, p->height, &x, &y); scrap_dirty = true; k = 0; for (i=0 ; i<p->height ; i++) { for (j=0 ; j<p->width ; j++, k++) scrap_texels[texnum][(y+i)*BLOCK_WIDTH + x + j] = p->data[k]; } gl.gltexture = scrap_textures[texnum]; //johnfitz -- changed to an array //johnfitz -- no longer go from 0.01 to 0.99 gl.sl = x/(float)BLOCK_WIDTH; gl.sh = (x+p->width)/(float)BLOCK_WIDTH; gl.tl = y/(float)BLOCK_WIDTH; gl.th = (y+p->height)/(float)BLOCK_WIDTH; } else { char texturename[64]; //johnfitz q_snprintf (texturename, sizeof(texturename), "%s:%s", WADFILENAME, name); //johnfitz offset = (src_offset_t)p - (src_offset_t)wad_base + sizeof(int)*2; //johnfitz gl.gltexture = TexMgr_LoadImage (NULL, texturename, p->width, p->height, SRC_INDEXED, p->data, WADFILENAME, offset, TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr gl.sl = 0; gl.sh = (float)p->width/(float)TexMgr_PadConditional(p->width); //johnfitz gl.tl = 0; gl.th = (float)p->height/(float)TexMgr_PadConditional(p->height); //johnfitz } memcpy (p->data, &gl, sizeof(glpic_t)); return p; }
// // R_InitColormaps // void R_InitColormaps (void) { // [RH] Try and convert BOOM colormaps into blending values. // This is a really rough hack, but it's better than // not doing anything with them at all (right?) int lastfakecmap = W_CheckNumForName ("C_END"); firstfakecmap = W_CheckNumForName ("C_START"); if (firstfakecmap == -1 || lastfakecmap == -1) numfakecmaps = 1; else { if(firstfakecmap > lastfakecmap) I_Error("no fake cmaps"); numfakecmaps = lastfakecmap - firstfakecmap; } realcolormaps.colormap = (byte *)Z_Malloc (256*(NUMCOLORMAPS+1)*numfakecmaps,PU_STATIC,0); realcolormaps.shademap = (argb_t *)Z_Malloc (256*sizeof(argb_t)*(NUMCOLORMAPS+1)*numfakecmaps,PU_STATIC,0); fakecmaps = (FakeCmap *)Z_Malloc (sizeof(*fakecmaps) * numfakecmaps, PU_STATIC, 0); fakecmaps[0].name[0] = 0; R_ForceDefaultColormap ("COLORMAP"); if (numfakecmaps > 1) { int i; size_t j; palette_t *pal = GetDefaultPalette (); shaderef_t defpal = shaderef_t(&pal->maps, 0); for (i = ++firstfakecmap, j = 1; j < numfakecmaps; i++, j++) { if (W_LumpLength (i) >= (NUMCOLORMAPS+1)*256) { int k, r, g, b; byte *map = (byte *)W_CacheLumpNum (i, PU_CACHE); byte *colormap = realcolormaps.colormap+(NUMCOLORMAPS+1)*256*j; argb_t *shademap = realcolormaps.shademap+(NUMCOLORMAPS+1)*256*j; // Copy colormap data: memcpy (colormap, map, (NUMCOLORMAPS+1)*256); if(pal->basecolors) { r = RPART(pal->basecolors[*map]); g = GPART(pal->basecolors[*map]); b = BPART(pal->basecolors[*map]); W_GetLumpName (fakecmaps[j].name, i); for (k = 1; k < 256; k++) { r = (r + RPART(pal->basecolors[map[k]])) >> 1; g = (g + GPART(pal->basecolors[map[k]])) >> 1; b = (b + BPART(pal->basecolors[map[k]])) >> 1; } // NOTE(jsd): This alpha value is used for 32bpp in water areas. fakecmaps[j].blend = MAKEARGB (64, r, g, b); // Set up shademap for the colormap: for (k = 0; k < 256; ++k) { argb_t c = pal->basecolors[map[0]]; shademap[k] = alphablend1a(c, MAKERGB(r,g,b), j * (256 / numfakecmaps)); } } else { // Set up shademap for the colormap: for (k = 0; k < 256; ++k)
void FStringTable::LoadStrings (int lump, int expectedSize, bool enuOnly) { BYTE *strData = (BYTE *)W_CacheLumpNum (lump, PU_CACHE); int lumpLen = LELONG(((Header *)strData)->FileSize); int nameCount = LESHORT(((Header *)strData)->NameCount); int nameLen = LESHORT(((Header *)strData)->NameLen); int languageStart = sizeof(Header) + nameCount*4 + nameLen; languageStart += (4 - languageStart) & 3; if (expectedSize >= 0 && nameCount != expectedSize) { char name[9]; W_GetLumpName (name, lump); name[8] = 0; I_FatalError ("%s had %d strings.\nThis version of ZDoom expects it to have %d.", name, nameCount, expectedSize); } FreeStandardStrings (); NumStrings = nameCount; LumpNum = lump; if (Strings == NULL) { Strings = new char *[nameCount]; StringStatus = new BYTE[(nameCount+7)/8]; memset (StringStatus, 0, (nameCount+7)/8); // 0 means: from wad (standard) memset (Strings, 0, sizeof(char *)*nameCount); } BYTE *const start = strData + languageStart; BYTE *const end = strData + lumpLen; int loadedCount, i; for (loadedCount = i = 0; i < NumStrings; ++i) { if (Strings[i] != NULL) { ++loadedCount; } } if (!enuOnly) { for (i = 0; i < 4 && loadedCount != nameCount; ++i) { loadedCount += LoadLanguage (LanguageIDs[i], true, start, end); loadedCount += LoadLanguage (LanguageIDs[i] & MAKE_ID(0xff,0xff,0,0), true, start, end); loadedCount += LoadLanguage (LanguageIDs[i], false, start, end); } } // Fill in any missing strings with the default language (enu) if (loadedCount != nameCount) { loadedCount += LoadLanguage (MAKE_ID('e','n','u',0), true, start, end); } DoneLoading (start, end); if (loadedCount != nameCount) { I_FatalError ("Loaded %d strings (expected %d)", loadedCount, nameCount); } }