static void UnloadPics(void) { int i; if (HubCount || gametype == DEATHMATCH) { W_ReleaseLumpName("INTERPIC"); patchINTERPIC = W_CacheLumpName("INTERPIC", PU_STATIC); FontBLumpBase = W_GetNumForName("FONTB16"); for (i = 0; i < 10; i++) { W_ReleaseLumpNum(FontBLumpBase + i); } W_ReleaseLumpName("FONTB13"); W_ReleaseLumpName("FONTB15"); W_ReleaseLumpName("FONTB05"); } }
static void UnloadLumpCallback(const char *lumpname, int lumpnum, patch_t **ptr) { if (lumpname != NULL) { W_ReleaseLumpName(lumpname); } else { W_ReleaseLumpNum(lumpnum); } }
void I_EnableLoadingDisk(void) { patch_t *disk; byte *tmpbuf; char *disk_name; int y; char buf[20]; SDL_VideoDriverName(buf, 15); if (!strcmp(buf, "Quartz")) { // MacOS Quartz gives us pageflipped graphics that screw up the // display when we use the loading disk. Disable it. // This is a gross hack. return; } if (M_CheckParm("-cdrom") > 0) disk_name = DEH_String("STCDROM"); else disk_name = DEH_String("STDISK"); disk = W_CacheLumpName(disk_name, PU_STATIC); // Draw the patch into a temporary buffer tmpbuf = Z_Malloc(SCREENWIDTH * (disk->height + 1), PU_STATIC, NULL); V_UseBuffer(tmpbuf); // Draw the disk to the screen: V_DrawPatch(0, 0, disk); disk_image = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL); saved_background = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL); for (y=0; y<LOADING_DISK_H; ++y) { memcpy(disk_image + LOADING_DISK_W * y, tmpbuf + SCREENWIDTH * y, LOADING_DISK_W); } // All done - free the screen buffer and restore the normal // video buffer. W_ReleaseLumpName(disk_name); V_RestoreBuffer(); Z_Free(tmpbuf); }
static void LoadDiskImage(void) { patch_t *disk; char *disk_name; int y; int xoffset = SCREENWIDTH - LOADING_DISK_W; int yoffset = SCREENHEIGHT - LOADING_DISK_H; char buf[20]; SDL_VideoDriverName(buf, 15); if (!strcmp(buf, "Quartz")) { // MacOS Quartz gives us pageflipped graphics that screw up the // display when we use the loading disk. Disable it. // This is a gross hack. return; } if (M_CheckParm("-cdrom") > 0) disk_name = DEH_String("STCDROM"); else disk_name = DEH_String("STDISK"); disk = W_CacheLumpName(disk_name, PU_STATIC); // Draw the disk to the screen: V_DrawPatch(SCREENWIDTH - LOADING_DISK_W, SCREENHEIGHT - LOADING_DISK_H, 0, disk); disk_image = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL); saved_background = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL); for (y=0; y<LOADING_DISK_H; ++y) { memcpy(disk_image + LOADING_DISK_W * y, screens[0] + SCREENWIDTH * (y + yoffset) + xoffset, LOADING_DISK_W); } W_ReleaseLumpName(disk_name); }
static boolean LoadInstrumentTable(void) { byte *lump; lump = W_CacheLumpName("GENMIDI", PU_STATIC); // Check header if (strncmp((char *) lump, GENMIDI_HEADER, strlen(GENMIDI_HEADER)) != 0) { W_ReleaseLumpName("GENMIDI"); return false; } main_instrs = (genmidi_instr_t *) (lump + strlen(GENMIDI_HEADER)); percussion_instrs = main_instrs + GENMIDI_NUM_INSTRS; main_instr_names = (char (*)[32]) (percussion_instrs + GENMIDI_NUM_PERCUSSION); percussion_names = main_instr_names + GENMIDI_NUM_INSTRS; return true; }
// // R_InitTextures // Initializes the texture list // with the textures from the world map. // void R_InitTextures (void) { maptexture_t* mtexture; texture_t* texture; mappatch_t* mpatch; texpatch_t* patch; int i; int j; int* maptex; int* maptex2; int* maptex1; char name[9]; char* names; char* name_p; int* patchlookup; int totalwidth; int nummappatches; int offset; int maxoff; int maxoff2; int numtextures1; int numtextures2; int* directory; int temp1; int temp2; int temp3; // Load the patch names from pnames.lmp. name[8] = 0; names = W_CacheLumpName (DEH_String("PNAMES"), PU_STATIC); nummappatches = LONG ( *((int *)names) ); name_p = names+4; patchlookup = Z_Malloc(nummappatches*sizeof(*patchlookup), PU_STATIC, NULL); for (i=0 ; i<nummappatches ; i++) { strncpy (name,name_p+i*8, 8); patchlookup[i] = W_CheckNumForName (name); } W_ReleaseLumpName(DEH_String("PNAMES")); // Load the map texture definitions from textures.lmp. // The data is contained in one or two lumps, // TEXTURE1 for shareware, plus TEXTURE2 for commercial. maptex = maptex1 = W_CacheLumpName (DEH_String("TEXTURE1"), PU_STATIC); numtextures1 = LONG(*maptex); maxoff = W_LumpLength (W_GetNumForName (DEH_String("TEXTURE1"))); directory = maptex+1; if (W_CheckNumForName (DEH_String("TEXTURE2")) != -1) { maptex2 = W_CacheLumpName (DEH_String("TEXTURE2"), PU_STATIC); numtextures2 = LONG(*maptex2); maxoff2 = W_LumpLength (W_GetNumForName (DEH_String("TEXTURE2"))); } else { maptex2 = NULL; numtextures2 = 0; maxoff2 = 0; } numtextures = numtextures1 + numtextures2; textures = Z_Malloc (numtextures * sizeof(*textures), PU_STATIC, 0); texturecolumnlump = Z_Malloc (numtextures * sizeof(*texturecolumnlump), PU_STATIC, 0); texturecolumnofs = Z_Malloc (numtextures * sizeof(*texturecolumnofs), PU_STATIC, 0); texturecomposite = Z_Malloc (numtextures * sizeof(*texturecomposite), PU_STATIC, 0); texturecompositesize = Z_Malloc (numtextures * sizeof(*texturecompositesize), PU_STATIC, 0); texturewidthmask = Z_Malloc (numtextures * sizeof(*texturewidthmask), PU_STATIC, 0); textureheight = Z_Malloc (numtextures * sizeof(*textureheight), PU_STATIC, 0); totalwidth = 0; // Really complex printing shit... temp1 = W_GetNumForName (DEH_String("S_START")); // P_??????? temp2 = W_GetNumForName (DEH_String("S_END")) - 1; temp3 = ((temp2-temp1+63)/64) + ((numtextures+63)/64); // If stdout is a real console, use the classic vanilla "filling // up the box" effect, which uses backspace to "step back" inside // the box. If stdout is a file, don't draw the box. if (I_ConsoleStdout()) { printf("["); for (i = 0; i < temp3 + 9; i++) printf(" "); printf("]"); for (i = 0; i < temp3 + 10; i++) printf("\b"); } for (i=0 ; i<numtextures ; i++, directory++) { if (!(i&63)) printf ("."); if (i == numtextures1) { // Start looking in second texture file. maptex = maptex2; maxoff = maxoff2; directory = maptex+1; } offset = LONG(*directory); if (offset > maxoff) I_Error ("R_InitTextures: bad texture directory"); mtexture = (maptexture_t *) ( (byte *)maptex + offset); texture = textures[i] = Z_Malloc (sizeof(texture_t) + sizeof(texpatch_t)*(SHORT(mtexture->patchcount)-1), PU_STATIC, 0); texture->width = SHORT(mtexture->width); texture->height = SHORT(mtexture->height); texture->patchcount = SHORT(mtexture->patchcount); memcpy (texture->name, mtexture->name, sizeof(texture->name)); mpatch = &mtexture->patches[0]; patch = &texture->patches[0]; for (j=0 ; j<texture->patchcount ; j++, mpatch++, patch++) { patch->originx = SHORT(mpatch->originx); patch->originy = SHORT(mpatch->originy); patch->patch = patchlookup[SHORT(mpatch->patch)]; if (patch->patch == -1) { I_Error ("R_InitTextures: Missing patch in texture %s", texture->name); } } texturecolumnlump[i] = Z_Malloc (texture->width*sizeof(**texturecolumnlump), PU_STATIC,0); texturecolumnofs[i] = Z_Malloc (texture->width*sizeof(**texturecolumnofs), PU_STATIC,0); j = 1; while (j*2 <= texture->width) j<<=1; texturewidthmask[i] = j-1; textureheight[i] = texture->height<<FRACBITS; totalwidth += texture->width; } Z_Free(patchlookup); W_ReleaseLumpName(DEH_String("TEXTURE1")); if (maptex2) W_ReleaseLumpName(DEH_String("TEXTURE2")); // Precalculate whatever possible. for (i=0 ; i<numtextures ; i++) R_GenerateLookup (i); // Create translation table for global animation. texturetranslation = Z_Malloc ((numtextures+1)*sizeof(*texturetranslation), PU_STATIC, 0); for (i=0 ; i<numtextures ; i++) texturetranslation[i] = i; GenerateTextureHashTable(); }
static void InitGameVersion(void) { byte *demolump; char demolumpname[6]; int demoversion; int p; int i; boolean status; //! // @arg <version> // @category compat // // Emulate a specific version of Doom. Valid values are "1.666", // "1.7", "1.8", "1.9", "ultimate", "final", "final2", "hacx" and // "chex". // p = M_CheckParmWithArgs("-gameversion", 1); if (p) { for (i=0; gameversions[i].description != NULL; ++i) { if (!strcmp(myargv[p+1], gameversions[i].cmdline)) { gameversion = gameversions[i].version; break; } } if (gameversions[i].description == NULL) { printf("Supported game versions:\n"); for (i=0; gameversions[i].description != NULL; ++i) { printf("\t%s (%s)\n", gameversions[i].cmdline, gameversions[i].description); } I_Error("Unknown game version '%s'", myargv[p+1]); } } else { // Determine automatically if (gamemission == pack_chex) { // chex.exe - identified by iwad filename gameversion = exe_chex; } else if (gamemission == pack_hacx) { // hacx.exe: identified by iwad filename gameversion = exe_hacx; } else if (gamemode == shareware || gamemode == registered || (gamemode == commercial && gamemission == doom2)) { // original gameversion = exe_doom_1_9; // Detect version from demo lump for (i = 1; i <= 3; ++i) { M_snprintf(demolumpname, 6, "demo%i", i); if (W_CheckNumForName(demolumpname) > 0) { demolump = W_CacheLumpName(demolumpname, PU_STATIC); demoversion = demolump[0]; W_ReleaseLumpName(demolumpname); status = true; switch (demoversion) { case 106: gameversion = exe_doom_1_666; break; case 107: gameversion = exe_doom_1_7; break; case 108: gameversion = exe_doom_1_8; break; case 109: gameversion = exe_doom_1_9; break; default: status = false; break; } if (status) { break; } } } } else if (gamemode == retail) { gameversion = exe_ultimate; } else if (gamemode == commercial) { // Final Doom: tnt or plutonia // Defaults to emulating the first Final Doom executable, // which has the crash in the demo loop; however, having // this as the default should mean that it plays back // most demos correctly. gameversion = exe_final; } } // The original exe does not support retail - 4th episode not supported if (gameversion < exe_ultimate && gamemode == retail) { gamemode = registered; } // EXEs prior to the Final Doom exes do not support Final Doom. if (gameversion < exe_final && gamemode == commercial && (gamemission == pack_tnt || gamemission == pack_plut)) { gamemission = doom2; } }
static void WI_unloadCallback(char *name, patch_t **variable) { W_ReleaseLumpName(name); *variable = NULL; }
// // R_InitTextures // Initializes the texture list // with the textures from the world map. // static void R_InitTextures(void) { maptexture_t *mtexture; texture_t *texture; mappatch_t *mpatch; texpatch_t *patch; int i; int j; int *maptex; int *maptex2; int *maptex1; char name[9]; char *names; char *name_p; int *patchlookup; int totalwidth; int nummappatches; int offset; int maxoff; int maxoff2; int numtextures1; int numtextures2; int *directory; // Load the patch names from pnames.lmp. name[8] = 0; names = (char *)W_CacheLumpName("PNAMES", PU_STATIC); nummappatches = LONG(*((int *)names)); name_p = names + 4; patchlookup = (int *)Z_Malloc(nummappatches * sizeof(*patchlookup), PU_STATIC, NULL); for (i = 0; i < nummappatches; i++) { M_StringCopy(name, name_p + i * 8, sizeof(name)); patchlookup[i] = W_CheckNumForName(name); } W_ReleaseLumpName("PNAMES"); // Load the map texture definitions from textures.lmp. // The data is contained in one or two lumps, // TEXTURE1 for shareware, plus TEXTURE2 for commercial. maptex = maptex1 = W_CacheLumpName("TEXTURE1", PU_STATIC); numtextures1 = LONG(*maptex); maxoff = W_LumpLength(W_GetNumForName("TEXTURE1")); directory = maptex + 1; if (W_CheckNumForName("TEXTURE2") != -1) { maptex2 = W_CacheLumpName("TEXTURE2", PU_STATIC); numtextures2 = LONG(*maptex2); maxoff2 = W_LumpLength(W_GetNumForName("TEXTURE2")); } else { maptex2 = NULL; numtextures2 = 0; maxoff2 = 0; } numtextures = numtextures1 + numtextures2; textures = Z_Malloc(numtextures * sizeof(*textures), PU_STATIC, 0); texturecolumnlump = Z_Malloc(numtextures * sizeof(*texturecolumnlump), PU_STATIC, 0); texturecolumnofs = Z_Malloc(numtextures * sizeof(*texturecolumnofs), PU_STATIC, 0); texturecomposite = Z_Malloc(numtextures * sizeof(*texturecomposite), PU_STATIC, 0); texturecompositesize = Z_Malloc(numtextures * sizeof(*texturecompositesize), PU_STATIC, 0); texturewidthmask = Z_Malloc(numtextures * sizeof(*texturewidthmask), PU_STATIC, 0); textureheight = Z_Malloc(numtextures * sizeof(*textureheight), PU_STATIC, 0); texturefullbright = Z_Malloc(numtextures * sizeof(*texturefullbright), PU_STATIC, 0); totalwidth = 0; for (i = 0; i < numtextures; i++, directory++) { if (i == numtextures1) { // Start looking in second texture file. maptex = maptex2; maxoff = maxoff2; directory = maptex + 1; } offset = LONG(*directory); if (offset > maxoff) I_Error("R_InitTextures: bad texture directory"); mtexture = (maptexture_t *)((byte *)maptex + offset); texture = textures[i] = Z_Malloc(sizeof(texture_t) + sizeof(texpatch_t) * (SHORT(mtexture->patchcount) - 1), PU_STATIC, 0); texture->width = SHORT(mtexture->width); texture->height = SHORT(mtexture->height); texture->patchcount = SHORT(mtexture->patchcount); memcpy(texture->name, mtexture->name, sizeof(texture->name)); mpatch = &mtexture->patches[0]; patch = &texture->patches[0]; for (j = 0; j < texture->patchcount; j++, mpatch++, patch++) { patch->originx = SHORT(mpatch->originx); patch->originy = SHORT(mpatch->originy); patch->patch = patchlookup[SHORT(mpatch->patch)]; if (patch->patch == -1) patch->patch = 0; // [crispy] make non-fatal } texturecolumnlump[i] = Z_Malloc(texture->width * sizeof(**texturecolumnlump), PU_STATIC, 0); texturecolumnofs[i] = Z_Malloc(texture->width * sizeof(**texturecolumnofs), PU_STATIC, 0); for (j = 1; j * 2 <= texture->width; j <<= 1); texturewidthmask[i] = j - 1; textureheight[i] = texture->height << FRACBITS; totalwidth += texture->width; R_DoomTextureHacks(texture); } Z_Free(patchlookup); W_ReleaseLumpName("TEXTURE1"); if (maptex2) W_ReleaseLumpName("TEXTURE2"); lookuptextures = Z_Malloc(numtextures * sizeof(boolean), PU_STATIC, 0); for (i = 0; i < numtextures; i++) lookuptextures[i] = false; lookupprogress = numtextures; // Precalculate whatever possible. for (i = 0; i < numtextures; i++) R_GenerateLookup(i); // Create translation table for global animation. texturetranslation = Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, 0); for (i = 0; i < numtextures; i++) texturetranslation[i] = i; GenerateTextureHashTable(); // [BH] Initialize partially fullbright textures. memset(texturefullbright, 0, numtextures * sizeof(*texturefullbright)); if (brightmaps) { i = 0; while (fullbright[i].colormask) { if (fullbright[i].texture) { int num = R_CheckTextureNumForName(fullbright[i].texture); if (num != -1) texturefullbright[num] = fullbright[i].colormask; i++; } } } }