void R_InitSpriteLumps (void) { int i; patch_t *patch; firstspritelump = W_GetNumForName ("S_START") + 1; lastspritelump = W_GetNumForName ("S_END") - 1; numspritelumps = lastspritelump - firstspritelump + 1; spritewidth = Z_Malloc (numspritelumps*4, PU_STATIC, 0); spriteoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0); spritetopoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0); for (i=0 ; i< numspritelumps ; i++) { #ifdef __NEXT__ if (!(i&63)) printf ("."); #else IncThermo(); #endif patch = W_CacheLumpNum (firstspritelump+i, PU_CACHE); spritewidth[i] = SHORT(patch->width)<<FRACBITS; spriteoffset[i] = SHORT(patch->leftoffset)<<FRACBITS; spritetopoffset[i] = SHORT(patch->topoffset)<<FRACBITS; } }
// // R_InitFlats // void R_InitFlats(void) { int i; firstflat = W_GetNumForName("F_START") + 1; lastflat = W_GetNumForName("F_END") - 1; numflats = lastflat - firstflat + 1; flatfullbright = Z_Malloc(numflats * sizeof(*flatfullbright), PU_STATIC, 0); // Create translation table for global animation. flattranslation = Z_Malloc((numflats + 1) * sizeof(*flattranslation), PU_STATIC, 0); for (i = 0; i < numflats; i++) flattranslation[i] = i; // [BH] Initialize partially fullbright flats. memset(flatfullbright, 0, numflats * sizeof(*flatfullbright)); //if (brightmaps) //{ // i = 0; // while (fullbright[i].colormask) // { // if (fullbright[i].flat) // { // int num = R_CheckFlatNumForName(fullbright[i].flat); // if (num != -1) // flatfullbright[num] = fullbright[i].colormask; // i++; // } // } //} }
/* ================ = = R_InitSpriteLumps = = Finds the width and hoffset of all sprites in the wad, so the sprite doesn't = need to be cached just for the header during rendering ================= */ void R_InitSpriteLumps (void) { int i; patch_t *patch; dstex_t *sprite_ds; firstspritelump = W_GetNumForName ("S_START") + 1; lastspritelump = W_GetNumForName ("S_END") - 1; numspritelumps = lastspritelump - firstspritelump + 1; spritewidth = (fixed_t *)Z_Malloc (numspritelumps*4, PU_STATIC, 0); spriteheight = (fixed_t *)Z_Malloc (numspritelumps*4, PU_STATIC, 0); spriteoffset = (fixed_t *)Z_Malloc (numspritelumps*4, PU_STATIC, 0); spritetopoffset = (fixed_t *)Z_Malloc (numspritelumps*4, PU_STATIC, 0); sprites_ds = (dstex_t *)Z_Malloc (numspritelumps*sizeof(dstex_t), PU_STATIC, 0); for (i=0 ; i< numspritelumps ; i++) { #ifdef __NEXT__ if (!(i&63)) printf ("."); #else IncThermo(); #endif patch = (patch_t *)W_CacheLumpNum (firstspritelump+i, PU_CACHE); spritewidth[i] = SHORT(patch->width)<<FRACBITS; spriteheight[i] = SHORT(patch->height)<<FRACBITS; spriteoffset[i] = SHORT(patch->leftoffset)<<FRACBITS; spritetopoffset[i] = SHORT(patch->topoffset)<<FRACBITS; sprite_ds = &sprites_ds[i]; ds_init_sprite(i,patch,sprite_ds); }
void IN_LoadPics(void) { int i; switch(gameepisode) { case 1: patchINTERPIC = W_CacheLumpName("MAPE1", PU_STATIC); break; case 2: patchINTERPIC = W_CacheLumpName("MAPE2", PU_STATIC); break; case 3: patchINTERPIC = W_CacheLumpName("MAPE3", PU_STATIC); break; default: break; } patchBEENTHERE = W_CacheLumpName("IN_X", PU_STATIC); patchGOINGTHERE = W_CacheLumpName("IN_YAH", PU_STATIC); FontBLumpBase = W_GetNumForName("FONTB16"); for(i=0; i<10; i++) { FontBNumbers[i] = W_CacheLumpNum(FontBLumpBase+i, PU_STATIC); } FontBLump = W_GetNumForName("FONTB_S")+1; FontBNegative = W_CacheLumpName("FONTB13", PU_STATIC); FontBSlash = W_CacheLumpName("FONTB15", PU_STATIC); FontBPercent = W_CacheLumpName("FONTB05", PU_STATIC); patchFaceOkayBase = W_GetNumForName("FACEA0"); patchFaceDeadBase = W_GetNumForName("FACEB0"); }
// // R_InitFlats // void R_InitFlats (void) { int i; firstflat = W_GetNumForName ("F_START") + 1; lastflat = W_GetNumForName ("F_END") - 1; if(firstflat >= lastflat) I_Error("no flats"); numflats = lastflat - firstflat + 1; delete[] flattranslation; // Create translation table for global animation. flattranslation = new int[numflats+1]; for (i = 0; i < numflats; i++) flattranslation[i] = i; delete[] flatwarp; flatwarp = new bool[numflats+1]; memset (flatwarp, 0, sizeof(bool) * (numflats+1)); delete[] warpedflats; warpedflats = new byte *[numflats+1]; memset (warpedflats, 0, sizeof(byte *) * (numflats+1)); delete[] flatwarpedwhen; flatwarpedwhen = new int[numflats+1]; memset (flatwarpedwhen, 0xff, sizeof(int) * (numflats+1)); }
// // R_InitSpriteLumps // Finds the width and hoffset of all sprites in the wad, // so the sprite does not need to be cached completely // just for having the header info ready during rendering. // void R_InitSpriteLumps (void) { int i; patch_t *patch; firstspritelump = W_GetNumForName ("S_START") + 1; lastspritelump = W_GetNumForName ("S_END") - 1; numspritelumps = lastspritelump - firstspritelump + 1; spritewidth = Z_Malloc (numspritelumps*4, PU_STATIC, 0); spriteoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0); spritetopoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0); for (i=0 ; i< numspritelumps ; i++) { if (!(i&63)) { sprintf (MsgText,"."); WriteDebug(MsgText); } patch = W_CacheLumpNum (firstspritelump+i, PU_CACHE); spritewidth[i] = (patch->width)<<FRACBITS; spriteoffset[i] = (patch->leftoffset)<<FRACBITS; spritetopoffset[i] = (patch->topoffset)<<FRACBITS; } }
void IN_LoadPics(void) { FontBLump = W_GetNumForName(DEH_String("FONTB_S")) + 1; patchFaceOkayBase = W_GetNumForName(DEH_String("FACEA0")); patchFaceDeadBase = W_GetNumForName(DEH_String("FACEB0")); IN_LoadUnloadPics(LoadLumpCallback); }
void R_InitColormaps(void) { dboolean COLORMAP = (W_CheckMultipleLumps("COLORMAP") > 1); int i; byte *palsrc, *palette; wad_file_t *colormapwad; if (W_CheckNumForName("C_START") >= 0 && W_CheckNumForName("C_END") >= 0) { firstcolormaplump = W_GetNumForName("C_START"); lastcolormaplump = W_GetNumForName("C_END"); numcolormaps = lastcolormaplump - firstcolormaplump; colormaps = Z_Malloc(sizeof(*colormaps) * numcolormaps, PU_STATIC, NULL); colormaps[0] = W_CacheLumpName("COLORMAP", PU_STATIC); for (i = 1; i < numcolormaps; i++) colormaps[i] = W_CacheLumpNum(i + firstcolormaplump, PU_STATIC); } else { colormaps = Z_Malloc(sizeof(*colormaps), PU_STATIC, NULL); colormaps[0] = W_CacheLumpName("COLORMAP", PU_STATIC); } colormapwad = lumpinfo[W_CheckNumForName("COLORMAP")]->wad_file; C_Output("Using the COLORMAP lump in %s file %s.", (colormapwad->type == IWAD ? "IWAD" : "PWAD"), uppercase(colormapwad->path)); // [BH] There's a typo in dcolors.c, the source code of the utility Id // Software used to construct the palettes and colormaps for DOOM (see // http://www.doomworld.com/idgames/?id=16644). When constructing colormap // 32, which is used for the invulnerability powerup, the traditional // Y luminance values are used (see http://en.wikipedia.org/wiki/YIQ), but a // value of 0.144 is used when it should be 0.114. So I've grabbed the // offending code from dcolor.c, corrected it, put it here, and now colormap // 32 is manually calculated rather than grabbing it from the colormap lump. // The resulting differences are minor. palsrc = palette = W_CacheLumpName("PLAYPAL", PU_CACHE); for (i = 0; i < 255; i++) { float red = *palsrc++ / 256.0f; float green = *palsrc++ / 256.0f; float blue = *palsrc++ / 256.0f; float gray = red * 0.299f + green * 0.587f + blue * 0.114f/*0.144f*/; grays[i] = FindNearestColor(palette, (int)(gray * 255.0f), (int)(gray * 255.0f), (int)(gray * 255.0f)); if (!COLORMAP) { gray = (1.0f - gray) * 255.0f; colormaps[0][32 * 256 + i] = FindNearestColor(palette, (int)gray, (int)gray, (int)gray); } } }
static void R_InitColormaps(void) { int i; firstcolormaplump = W_GetNumForName("C_START"); lastcolormaplump = W_GetNumForName("C_END"); numcolormaps = lastcolormaplump - firstcolormaplump; colormaps = Z_Malloc(sizeof(*colormaps) * numcolormaps, PU_STATIC, 0); colormaps[0] = (const lighttable_t *)W_CacheLumpName("COLORMAP"); for (i=1; i<numcolormaps; i++) colormaps[i] = (const lighttable_t *)W_CacheLumpNum(i+firstcolormaplump); // cph - always lock }
// This function loads the sound data from the WAD lump, // for single sound. // void* getsfx ( char* sfxname, int* len ) { unsigned char* sfx; unsigned char* sfxmem; int size; char name[20]; int sfxlump; float scale = 1.0f; // Get the sound data from the WAD, allocate lump // in zone memory. sprintf(name, "ds%s", sfxname); // Scale down the plasma gun, it clips if ( strcmp( sfxname, "plasma" ) == 0 ) { scale = 0.75f; } if ( strcmp( sfxname, "itemup" ) == 0 ) { scale = 1.333f; } // If sound requested is not found in current WAD, use pistol as default if ( W_CheckNumForName(name) == -1 ) sfxlump = W_GetNumForName("dspistol"); else sfxlump = W_GetNumForName(name); // Sound lump headers are 8 bytes. const int SOUND_LUMP_HEADER_SIZE_IN_BYTES = 8; size = W_LumpLength( sfxlump ) - SOUND_LUMP_HEADER_SIZE_IN_BYTES; sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_CACHE_SHARED ); const unsigned char * sfxSampleStart = sfx + SOUND_LUMP_HEADER_SIZE_IN_BYTES; // Allocate from zone memory. //sfxmem = (float*)DoomLib::Z_Malloc( size*(sizeof(float)), PU_SOUND_SHARED, 0 ); sfxmem = (unsigned char*)malloc( size * sizeof(unsigned char) ); // Now copy, and convert to Xbox360 native float samples, do initial volume ramp, and scale for ( int i=0; i<size; i++ ) { sfxmem[i] = sfxSampleStart[i];// * scale; } // Remove the cached lump. Z_Free( sfx ); // Set length. *len = size; // Return allocated padded data. return (void *) (sfxmem); }
void R_InitFlats (void) { int i; firstflat = W_GetNumForName ("F_START") + 1; lastflat = W_GetNumForName ("F_END") - 1; numflats = lastflat - firstflat + 1; /* translation table for global animation */ flattranslation = Z_Malloc ((numflats+1)*4, PU_STATIC, 0); for (i=0 ; i<numflats ; i++) flattranslation[i] = i; }
// // R_InitFlats // void R_InitFlats (void) { int i; ::g->firstflat = W_GetNumForName ("F_START") + 1; ::g->lastflat = W_GetNumForName ("F_END") - 1; ::g->numflats = ::g->lastflat - ::g->firstflat + 1; // Create translation table for global animation. ::g->flattranslation = (int*)DoomLib::Z_Malloc ((::g->numflats+1)*4, PU_STATIC, 0); for (i=0 ; i < ::g->numflats ; i++) ::g->flattranslation[i] = i; }
// // R_InitFlats // void R_InitFlats (void) { int i; firstflat = W_GetNumForName (DEH_String("F_START")) + 1; lastflat = W_GetNumForName (DEH_String("F_END")) - 1; numflats = lastflat - firstflat + 1; // Create translation table for global animation. flattranslation = Z_Malloc ((numflats+1)*sizeof(*flattranslation), PU_STATIC, 0); for (i=0 ; i<numflats ; i++) flattranslation[i] = i; }
// // R_InitSpriteLumps // Finds the width and hoffset of all sprites in the wad, // so the sprite does not need to be cached completely // just for having the header info ready during rendering. // void R_InitSpriteLumps (void) { firstspritelump = W_GetNumForName ("S_START") + 1; lastspritelump = W_GetNumForName ("S_END") - 1; numspritelumps = lastspritelump - firstspritelump + 1; if(firstspritelump > lastspritelump) I_Error("no sprite lumps"); // [RH] Rather than maintaining separate spritewidth, spriteoffset, // and spritetopoffset arrays, this data has now been moved into // the sprite frame definition and gets initialized by // R_InstallSpriteLump(), so there really isn't anything to do here. }
// // ST_HticInit // // Initializes the Heretic status bar: // * Caches most patch graphics used throughout // static void ST_HticInit() { int i; // load inventory numbers for(i = 0; i < 10; ++i) { char lumpname[9]; memset(lumpname, 0, 9); sprintf(lumpname, "IN%d", i); efree(invnums[i]); invnums[i] = PatchLoader::CacheName(wGlobalDir, lumpname, PU_STATIC); } // load small inventory numbers for(i = 0; i < 10; ++i) { char lumpname[9]; memset(lumpname, 0, 9); sprintf(lumpname, "SMALLIN%d", i); smallinvnums[i] = PatchLoader::CacheName(wGlobalDir, lumpname, PU_STATIC); } PatchINVLFGEM1 = PatchLoader::CacheName(wGlobalDir, DEH_String("INVGEML1"), PU_STATIC); PatchINVLFGEM2 = PatchLoader::CacheName(wGlobalDir, DEH_String("INVGEML2"), PU_STATIC); PatchINVRTGEM1 = PatchLoader::CacheName(wGlobalDir, DEH_String("INVGEMR1"), PU_STATIC); PatchINVRTGEM2 = PatchLoader::CacheName(wGlobalDir, DEH_String("INVGEMR2"), PU_STATIC); PatchBLACKSQ = PatchLoader::CacheName(wGlobalDir, DEH_String("BLACKSQ"), PU_STATIC); // haleyjd 10/09/05: load key graphics for HUD for(i = 0; i < NUMCARDS+3; ++i) //jff 2/23/98 show both keys too { extern patch_t *keys[]; char namebuf[9]; sprintf(namebuf, "STKEYS%d", i); efree(keys[i]); keys[i] = PatchLoader::CacheName(wGlobalDir, namebuf, PU_STATIC); } // load important numbers needed when some arithmetic is done with them spinbooklump = W_GetNumForName(DEH_String("SPINBK0")); spinflylump = W_GetNumForName(DEH_String("SPFLY0")); }
// // W_CacheLumpName // void* W_CacheLumpName ( char* name, int tag ) { return W_CacheLumpNum (W_GetNumForName(name), tag); }
// // R_InitColormaps // void R_InitColormaps (int lump) { int length; if (lump == 0) { lump = W_GetNumForName("COLORMAP"); firstcollump = W_CheckNumForName ("C_START"); lastcollump = W_CheckNumForName ("C_END"); } if ((lump != prevcollump) || (colourmap_size == 0)) { prevcollump = lump; length = W_LumpLength (lump) + 255; if (length > colourmap_size) { colourmap_size = length + 0x200; if (colourmaps_a) Z_Free (colourmaps_a); // Load in the light tables, colourmaps_a = Z_Malloc (colourmap_size, PU_STATIC, 0); // 256 byte align tables. colormaps = (byte *)( ((uintptr_t)colourmaps_a + 255)&~0xff); } W_ReadLump (lump,colormaps); } }
// // TextureManager::readPNamesDirectory // void TextureManager::readPNamesDirectory() { int lumpnum = W_GetNumForName("PNAMES"); size_t lumplen = W_LumpLength(lumpnum); byte* lumpdata = new byte[lumplen]; W_ReadLump(lumpnum, lumpdata); int num_pname_mappings = LELONG(*((int*)(lumpdata + 0))); mPNameLookup = new int[num_pname_mappings]; for (int i = 0; i < num_pname_mappings; i++) { const char* lumpname = (const char*)(lumpdata + 4 + 8 * i); mPNameLookup[i] = W_CheckNumForName(lumpname); // killough 4/17/98: // Some wads use sprites as wall patches, so repeat check and // look for sprites this time, but only if there were no wall // patches found. This is the same as allowing for both, except // that wall patches always win over sprites, even when they // appear first in a wad. This is a kludgy solution to the wad // lump namespace problem. if (mPNameLookup[i] == -1) mPNameLookup[i] = W_CheckNumForName(lumpname, ns_sprites); } delete [] lumpdata; }
void S_ChangeMusic(int music_id, int looping) { musicinfo_t *music; int music_file_failed; // cournia - if true load the default MIDI music char* music_filename; // cournia //jff 1/22/98 return if music is not enabled if (!mus_card || nomusicparm) return; if (music_id <= mus_None || music_id >= NUMMUSIC) I_Error("S_ChangeMusic: Bad music number %d", music_id); music = &S_music[music_id]; if (mus_playing == music) return; // shutdown old music S_StopMusic(); // get lumpnum if neccessary if (!music->lumpnum) { char namebuf[9]; sprintf(namebuf, "d_%s", music->name); music->lumpnum = W_GetNumForName(namebuf); } printf("mus: d_%s\n", music->name); music->data = W_CacheLumpNum(music->lumpnum); mus_play_music(music->data); mus_playing = music; }
void I_CacheSound(sfxinfo_t *sound) { if(sound->data) return; // already cached // sf: changed if(sound->link) I_CacheSound(sound->link); else { char name[20]; int sfxlump; // Get the sound data from the WAD, allocate lump // in zone memory. sprintf(name, "ds%s", sound->name); sfxlump = W_CheckNumForName(name); // use dspistol for lumps that are not found // fix bug with doom2 sounds in doom 1 if(sfxlump < 0) sfxlump = W_GetNumForName("dspistol"); sound->length = W_LumpLength(sfxlump); sound->data = W_CacheLumpNum(sfxlump, PU_STATIC); } }
// // E_LumpInclude // // Includes a WAD lump. Useful if you need to include a lump from a // file, since include() cannot do that. // int E_LumpInclude(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv) { int lumpnum = -1; if(argc != 1) { cfg_error(cfg, "wrong number of args to lumpinclude()\n"); return 1; } if(strlen(argv[0]) > 8) { cfg_error(cfg, "lumpinclude: %s is not a valid lump name\n", argv[0]); return 1; } switch(cfg_lexer_source_type(cfg)) { case -1: // from a file - include the newest lump return E_OpenAndCheckInclude(cfg, argv[0], W_GetNumForName(argv[0])); default: // lump if((lumpnum = E_FindLumpInclude(cfg, argv[0])) < 0) { cfg_error(cfg, "lumpinclude: %s not found\n", argv[0]); return 1; } return E_OpenAndCheckInclude(cfg, argv[0], lumpnum); } }
// // P_InitSwitchList() // // Only called at game initialization in order to list the set of switches // and buttons known to the engine. This enables their texture to change // when activated, and in the case of buttons, change back after a timeout. // // This routine modified to read its data from a predefined lump or // PWAD lump called SWITCHES rather than a static table in this module to // allow wad designers to insert or modify switches. // // Lump format is an array of byte packed switchlist_t structures, terminated // by a structure with episode == -0. The lump can be generated from a // text source file using SWANTBLS.EXE, distributed with the BOOM utils. // The standard list of switches and animations is contained in the example // source text file DEFSWANI.DAT also in the BOOM util distribution. // // Rewritten by Lee Killough to remove limit 2/8/98 // void P_InitSwitchList(void) { int i, index = 0; int episode = (gamemode == registered || gamemode==retail) ? 2 : gamemode == commercial ? 3 : 1; const switchlist_t *alphSwitchList; //jff 3/23/98 pointer to switch table int lump = W_GetNumForName("SWITCHES"); // cph - new wad lump handling //jff 3/23/98 read the switch table from a predefined lump alphSwitchList = (const switchlist_t *)W_CacheLumpNum(lump); for (i=0;;i++) { if (index+1 >= max_numswitches) switchlist = realloc(switchlist, sizeof *switchlist * (max_numswitches = max_numswitches ? max_numswitches*2 : 8)); if (SHORT(alphSwitchList[i].episode) <= episode) //jff 5/11/98 endianess { if (!SHORT(alphSwitchList[i].episode)) break; switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1); switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2); } } numswitches = index/2; switchlist[index] = -1; W_UnlockLumpNum(lump); }
void MN_Init(void) { InitFonts(); MenuActive = false; // messageson = true; // Set by defaults in .CFG MauloBaseLump = W_GetNumForName("FBULA0"); // ("M_SKL00"); }
void parse_include(char *lumpname) { int lumpnum; char *lump, *end; char *saved_rover; if(-1 == (lumpnum = W_GetNumForName(lumpname)) ) { script_error("include lump '%s' not found!\n", lumpname); return; } lump = W_CacheLumpNum(lumpnum, PU_STATIC); // realloc bigger for NULL at end lump = Z_Realloc(lump, W_LumpLength(lumpnum)+10, PU_STATIC, NULL); saved_rover = rover; // save rover during include rover = lump; end = lump+W_LumpLength(lumpnum); *end = 0; // preprocess the include // we assume that it does not include sections or labels or // other nasty things process_find_char(lump, 0); // now parse the lump parse_data(lump, end); // restore rover rover = saved_rover; // free the lump Z_Free(lump); }
static void setpalette(int pal) { if (colours == NULL) { int pplump = W_GetNumForName("PLAYPAL"); register const byte * palette = W_CacheLumpNum(pplump); register int i; num_pals = W_LumpLength(pplump) / (3*256); num_pals *= 256; if (!colours) colours = malloc(sizeof(*colours) * num_pals); for (i = 0; (size_t)i < num_pals; i++) { colours[i].r = palette[0]; colours[i].g = palette[1]; colours[i].b = palette[2]; palette += 3; } W_UnlockLumpNum(pplump); num_pals /= 256; } SDL_SetPalette(surface, SDL_LOGPAL | SDL_PHYSPAL, colours + 256 * pal, 0, 256); }
static void IN_LoadUnloadPics(void (*callback)(const char *lumpname, int lumpnum, patch_t **ptr)) { int i; switch (gameepisode) { case 1: callback(DEH_String("MAPE1"), 0, &patchINTERPIC); break; case 2: callback(DEH_String("MAPE2"), 0, &patchINTERPIC); break; case 3: callback(DEH_String("MAPE3"), 0, &patchINTERPIC); break; default: break; } callback(DEH_String("IN_X"), 0, &patchBEENTHERE); callback(DEH_String("IN_YAH"), 0, &patchGOINGTHERE); callback(DEH_String("FONTB13"), 0, &FontBNegative); callback(DEH_String("FONTB15"), 0, &FontBSlash); callback(DEH_String("FONTB05"), 0, &FontBPercent); FontBLumpBase = W_GetNumForName(DEH_String("FONTB16")); for (i = 0; i < 10; i++) { callback(NULL, FontBLumpBase + i, &FontBNumbers[i]); } }
void SetupAnimatedWall(int which) { animwall_t * aw; int i; int texture; aw = &animwalls[which]; aw->active=1; aw->ticcount=animwallsinfo[which].tictime; aw->count = 1; texture=W_GetNumForName(animwallsinfo[which].firstlump); aw->basetexture=texture; aw->texture=texture; if (DoPanicMapping()==true) { PreCacheLump(aw->basetexture,PU_CACHEWALLS,cache_pic_t); } else { for (i=aw->basetexture;i<aw->basetexture+animwallsinfo[which].numanims;i++) PreCacheLump(i,PU_CACHEWALLS,cache_pic_t); } }
/////////////////////////////////////////////////////////// // Palette stuff. // static void I_UploadNewPalette(int pal) { // This is used to replace the current 256 colour cmap with a new one // Used by 256 colour PseudoColor modes // Array of XColor structs used for setting the 256-colour palette static XColor* colours; static int cachedgamma; static size_t num_pals; if ((colours == NULL) || (cachedgamma != usegamma)) { int lump = W_GetNumForName("PLAYPAL"); const byte *palette = W_CacheLumpNum(lump); register const byte *const gtable = gammatable[cachedgamma = usegamma]; register int i; num_pals = W_LumpLength(lump) / (3*256); num_pals *= 256; if (!colours) { // First call - allocate and prepare colour array colours = malloc(sizeof(*colours)*num_pals); for (i=0 ; i<num_pals ; i++) { colours[i].pixel = i & 0xff; colours[i].flags = DoRed|DoGreen|DoBlue; } } // set the X colormap entries for (i=0 ; i<num_pals ; i++) { register int c; c = gtable[palette[0]]; colours[i].red = (c<<8) + c; c = gtable[palette[1]]; colours[i].green = (c<<8) + c; c = gtable[palette[2]]; colours[i].blue = (c<<8) + c; palette += 3; } W_UnlockLumpNum(lump); num_pals/=256; } #ifdef RANGECHECK if (pal >= num_pals) I_Error("I_UploadNewPalette: Palette number out of range (%d>=%d)", pal, num_pals); #endif // store the colors to the current colormap XStoreColors(X_display, X_cmap, colours + 256*pal, 256); #ifdef HAVE_LIBXXF86DGA /* install DGA colormap */ if(doDga) XF86DGAInstallColormap(X_display, X_screen, X_cmap); #endif }
// // R_InitColormaps // // killough 3/20/98: rewritten to allow dynamic colormaps // and to remove unnecessary 256-byte alignment // // killough 4/4/98: Add support for C_START/C_END markers // void R_InitColormaps() { const WadDirectory::namespace_t &ns = wGlobalDir.getNamespace(lumpinfo_t::ns_colormaps); r_numglobalmaps = 1; // always at least 1, for COLORMAP // check for global FOGMAP, for Hexen's benefit int fogmap; if((fogmap = W_CheckNumForName("FOGMAP")) >= 0) ++r_numglobalmaps; numcolormaps = ns.numLumps + r_numglobalmaps; // colormaps[0] is always the global COLORMAP lump size_t numbytes = sizeof(*colormaps) * numcolormaps; int cmlump = W_GetNumForName("COLORMAP"); colormaps = emalloctag(lighttable_t **, numbytes, PU_RENDERER, 0); colormaps[0] = (lighttable_t *)(wGlobalDir.cacheLumpNum(cmlump, PU_RENDERER)); // colormaps[1] is FOGMAP, if it exists if(fogmap >= 0) colormaps[1] = (lighttable_t *)(wGlobalDir.cacheLumpNum(fogmap, PU_RENDERER)); // load other colormaps from the colormaps namespace int i = r_numglobalmaps; WadNamespaceIterator nsi(wGlobalDir, lumpinfo_t::ns_colormaps); for(nsi.begin(); nsi.current(); nsi.next(), i++) colormaps[i] = (lighttable_t *)(wGlobalDir.cacheLumpNum((*nsi)->selfindex, PU_RENDERER)); firstcolormaplump = ns.firstLump; }
static void I_UploadNewPalette(int pal) { // This is used to replace the current 256 colour cmap with a new one // Used by 256 colour PseudoColor modes // Array of SDL_Color structs used for setting the 256-colour palette static SDL_Color* colours; static int cachedgamma; static size_t num_pals; if ((colours == NULL) || (cachedgamma != usegamma)) { int pplump = W_GetNumForName("PLAYPAL"); int gtlump = (W_CheckNumForName)("GAMMATBL",ns_prboom); register const byte * palette = W_CacheLumpNum(pplump); register const byte * const gtable = (const byte *)W_CacheLumpNum(gtlump) + 256*(cachedgamma = usegamma); register int i; num_pals = W_LumpLength(pplump) / (3*256); num_pals *= 256; if (!colours) { // First call - allocate and prepare colour array colours = malloc(sizeof(SDL_Color)*num_pals); } // set the colormap entries for (i=0 ; (size_t)i<num_pals ; i++) { colours[i].r = gtable[palette[0]]; colours[i].g = gtable[palette[1]]; colours[i].b = gtable[palette[2]]; palette += 3; } W_UnlockLumpNum(pplump); W_UnlockLumpNum(gtlump); num_pals/=256; } #ifdef RANGECHECK if ((size_t)pal >= num_pals) I_Error("I_UploadNewPalette: Palette number out of range (%d>=%d)", pal, num_pals); #endif // store the colors to the current display //SDL_SetColors(SDL_GetVideoSurface(), colours+256*pal, 0, 256); u32 i; for(i = 0; i < 256; i++) { u8 r, g, b; r = (u8)colours[i+256*pal].r; g = (u8)colours[i+256*pal].g; b = (u8)colours[i+256*pal].b; // Jefklak 20/11/06 - also update lower screen palette BG_PALETTE[i]=RGB8(r,g,b); if(!gen_console_enable) BG_PALETTE_SUB[i]=RGB8(r,g,b); } }