Beispiel #1
0
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);
        }
    }
}
Beispiel #2
0
void FindNearestColors(byte *palette)
{
    int i;

    if (W_CheckMultipleLumps("PLAYPAL") > 1)
        for (i = 0; i < PALETTESIZE; ++i)
            nearestcolors[i] = FindNearestColor(palette, originalcolors[i].red,
                originalcolors[i].green, originalcolors[i].blue);
    else
        for (i = 0; i < PALETTESIZE; ++i)
            nearestcolors[i] = i;
}
Beispiel #3
0
void R_InitColormaps(void)
{
    int         lump;
    boolean     COLORMAP = (W_CheckMultipleLumps("COLORMAP") > 1);

    // Load in the light tables,
    //  256 byte align tables.
    lump = W_GetNumForName("COLORMAP");
    colormaps = (lighttable_t *)W_CacheLumpNum(lump, PU_STATIC);

    // [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 luminence 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.
    {
        int     i;
        float   red, green, blue, gray;
        byte    *palsrc, *palette;

        palsrc = palette = W_CacheLumpName("PLAYPAL", PU_CACHE);

        for (i = 0; i < 255; i++)
        {
            red = *palsrc++ / 256.0f;
            green = *palsrc++ / 256.0f;
            blue = *palsrc++ / 256.0f;

            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[32 * 256 + i] = FindNearestColor(palette, (int)gray, (int)gray, (int)gray);
            }
        }
    }
}
Beispiel #4
0
// Draws "Entering <LevelName>"
void WI_drawEL(void)
{
    int         x = (ORIGINALWIDTH - SHORT(entering->width)) / 2;
    int         y = WI_TITLEY;
    char        name[9];

    // draw "Entering"
    V_DrawPatchWithShadow(x + 1, y + 1, FB, entering, false);

    // draw level
    y += 14;
    if (gamemode == commercial)
        snprintf(name, 9, "CWILV%2.2d", wbs->next);
    else
        snprintf(name, 9, "WILV%d%d", wbs->epsd, wbs->next);
    if (W_CheckMultipleLumps(name) > 1 && !nerve)
        V_DrawPatchWithShadow((ORIGINALWIDTH - SHORT(lnames[wbs->next]->width)) / 2 + 1, y + 1,
                              FB, lnames[wbs->next], false);
    else
        WI_drawWILV(y, nextmapname);
}
Beispiel #5
0
// Draws "<Levelname> Finished!"
void WI_drawLF(void)
{
    int         x = (ORIGINALWIDTH - SHORT(finished->width)) / 2;
    int         y = WI_TITLEY;
    char        name[9];

    // draw <LevelName>
    if (gamemode == commercial)
        snprintf(name, 9, "CWILV%2.2d", wbs->last);
    else
        snprintf(name, 9, "WILV%d%d", wbs->epsd, wbs->last);
    if (W_CheckMultipleLumps(name) > 1 && !nerve)
        V_DrawPatchWithShadow((ORIGINALWIDTH - SHORT(lnames[wbs->last]->width)) / 2 + 1, y + 1,
                              FB, lnames[wbs->last], false);
    else
        WI_drawWILV(y, mapname);

    // draw "Finished!"
    y += 14;
    V_DrawPatchWithShadow(x + 1, y + 1, FB, finished, false);
}
Beispiel #6
0
void HU_Init(void)
{
    int     j = HU_FONTSTART;
    int     lump;
    char    buffer[9];

    // load the heads-up font
    for (int i = 0; i < HU_FONTSIZE; i++)
    {
        M_snprintf(buffer, sizeof(buffer), "STCFN%.3d", j++);
        hu_font[i] = W_CacheLumpName(buffer);
        caretcolor = FindDominantColor(hu_font[i]);
    }

    if (W_CheckMultipleLumps("STTMINUS") > 1 || W_CheckMultipleLumps("STTNUM0") == 1)
        minuspatch = W_CacheLumpName("STTMINUS");

    tempscreen = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL);

    if ((lump = W_CheckNumForName("MEDIA0")) >= 0)
        healthpatch = W_CacheLumpNum(lump);

    if ((lump = W_CheckNumForName("PSTRA0")) >= 0)
        berserkpatch = W_CacheLumpNum(lump);
    else
        berserkpatch = healthpatch;

    if ((lump = W_CheckNumForName("ARM1A0")) >= 0)
        greenarmorpatch = W_CacheLumpNum(lump);

    if ((lump = W_CheckNumForName("ARM2A0")) >= 0)
        bluearmorpatch = W_CacheLumpNum(lump);

    ammopic[am_clip].patch = HU_LoadHUDAmmoPatch(am_clip);
    ammopic[am_shell].patch = HU_LoadHUDAmmoPatch(am_shell);

    if (gamemode != shareware)
        ammopic[am_cell].patch = HU_LoadHUDAmmoPatch(am_cell);

    ammopic[am_misl].patch = HU_LoadHUDAmmoPatch(am_misl);

    keypic[it_bluecard].patch = HU_LoadHUDKeyPatch(it_bluecard);
    keypic[it_yellowcard].patch = HU_LoadHUDKeyPatch(hacx ? it_yellowskull : it_yellowcard);
    keypic[it_redcard].patch = HU_LoadHUDKeyPatch(it_redcard);

    if (gamemode != shareware)
    {
        keypic[it_blueskull].patch = HU_LoadHUDKeyPatch(it_blueskull);
        keypic[it_yellowskull].patch = HU_LoadHUDKeyPatch(it_yellowskull);
        keypic[it_redskull].patch = HU_LoadHUDKeyPatch(it_redskull);
    }

    if ((lump = W_CheckNumForName(M_CheckParm("-cdrom") ? "STCDROM" : "STDISK")) >= 0)
    {
        stdisk = W_CacheLumpNum(lump);
        stdiskwidth = SHORT(stdisk->width);
    }

    s_STSTR_BEHOLD2 = M_StringCompare(s_STSTR_BEHOLD, STSTR_BEHOLD2);

    if (!M_StringCompare(playername, playername_default))
        s_GOTMEDINEED = s_GOTMEDINEED2;

    HU_AltInit();
    HU_SetTranslucency();
}
Beispiel #7
0
//
// D_DoomMainSetup
//
// CPhipps - the old contents of D_DoomMain, but moved out of the main
//  line of execution so its stack space can be freed
static void D_DoomMainSetup(void)
{
    int     p;
    char    file[256];
    int     temp;
    int     choseniwad;

    SDL_Init(0);

    M_FindResponseFile();

    iwadfile = D_FindIWAD();

    modifiedgame = false;

    nomonsters = M_CheckParm("-nomonsters");
    respawnparm = M_CheckParm("-respawn");
    fastparm = M_CheckParm("-fast");
    devparm = M_CheckParm("-devparm");
    if (M_CheckParm("-altdeath"))
        deathmatch = 2;
    else if (M_CheckParm("-deathmatch"))
        deathmatch = 1;

    M_SetConfigDir();

    // turbo option
    p = M_CheckParm("-turbo");
    if (p)
    {
        int        scale = 200;
        extern int forwardmove[2];
        extern int sidemove[2];

        if (p < myargc - 1)
            scale = atoi(myargv[p + 1]);
        if (scale < 10)
            scale = 10;
        if (scale > 400)
            scale = 400;
        forwardmove[0] = forwardmove[0] * scale / 100;
        forwardmove[1] = forwardmove[1] * scale / 100;
        sidemove[0] = sidemove[0] * scale / 100;
        sidemove[1] = sidemove[1] * scale / 100;
    }

    // init subsystems
    V_Init();

    // Load configuration files before initialising other subsystems.
    M_LoadDefaults();

    if (!M_FileExists("doomretro.wad"))
        if (!M_FileExists("doomretro.wad.temp"))
            I_Error("Can't find doomretro.wad.");

    if (iwadfile)
    {
        if (D_AddFile(iwadfile))
            if (runcount < RUNCOUNT_MAX)
                runcount++;
    }
    else 
    {
        if (!runcount)
            D_FirstUse();

        rename("doomretro.wad", "doomretro.wad.temp");

        do
        {
            choseniwad = D_ChooseIWAD();

            if (choseniwad == -1)
            {
                rename("doomretro.wad.temp", "doomretro.wad");
                I_Quit(false);
            }
            else if (!choseniwad)
                PlaySound((LPCTSTR)SND_ALIAS_SYSTEMHAND, NULL, SND_ALIAS_ID | SND_ASYNC);

        } while (!choseniwad);

        rename("doomretro.wad.temp", "doomretro.wad");

        if (runcount < RUNCOUNT_MAX)
            runcount++;
    }
    M_SaveDefaults();

    if (!W_MergeFile("doomretro.wad"))
        if (!W_MergeFile("doomretro.wad.temp"))
            I_Error("Can't find doomretro.wad.");

    if (W_CheckNumForName("BLD2A0") < 0 ||
        W_CheckNumForName("MEDBA0") < 0 ||
        W_CheckNumForName("STBAR2") < 0)
        I_Error("Wrong version of doomretro.wad.");

    p = M_CheckParmsWithArgs("-file", "-pwad", 1);
    if (p > 0)
    {
        for (p = p + 1; p < myargc && myargv[p][0] != '-'; ++p)
        {
            char *filename = uppercase(D_TryFindWADByName(myargv[p]));

            if (W_MergeFile(filename))
            {
                modifiedgame = true;
                if (D_CheckFilename(filename, "NERVE.WAD"))
                    nerve = true;
            }
        }
    }

    if (FREEDOOM && W_CheckNumForName("FREEDM") < 0 && !modifiedgame)
        I_Error("FREEDOOM requires a BOOM-compatible source port, and is therefore"
                "unable to be opened by DOOM RETRO.");

    DMENUPIC = (W_CheckNumForName("DMENUPIC") >= 0);
    M_DOOM = (W_CheckMultipleLumps("M_DOOM") > 1);
    M_EPISOD = (W_CheckMultipleLumps("M_EPISOD") > 1);
    M_GDHIGH = (W_CheckMultipleLumps("M_GDHIGH") > 1);
    M_GDLOW = (W_CheckMultipleLumps("M_GDLOW") > 1);
    M_LOADG = (W_CheckMultipleLumps("M_LOADG") > 1);
    M_LSCNTR = (W_CheckMultipleLumps("M_LSCNTR") > 1);
    M_MSENS = (W_CheckMultipleLumps("M_MSENS") > 1);
    M_MSGOFF = (W_CheckMultipleLumps("M_MSGOFF") > 1);
    M_MSGON = (W_CheckMultipleLumps("M_MSGON") > 1);
    M_NEWG = (W_CheckMultipleLumps("M_NEWG") > 1);
    M_NMARE = (W_CheckMultipleLumps("M_NMARE") > 1);
    M_OPTTTL = (W_CheckMultipleLumps("M_OPTTTL") > 1);
    M_PAUSE = (W_CheckMultipleLumps("M_PAUSE") > 1);
    M_SAVEG = (W_CheckMultipleLumps("M_SAVEG") > 1);
    M_SKILL = (W_CheckMultipleLumps("M_SKILL") > 1);
    M_SKULL1 = (W_CheckMultipleLumps("M_SKULL1") > 1);
    M_SVOL = (W_CheckMultipleLumps("M_SVOL") > 1);
    STARMS = (W_CheckMultipleLumps("STARMS") > 2);
    STBAR = (W_CheckMultipleLumps("STBAR") > 2);
    STCFN034 = (W_CheckMultipleLumps("STCFN034") > 1);
    STCFN039 = (W_CheckMultipleLumps("STCFN039") > 1);
    STCFN121 = (W_CheckMultipleLumps("STCFN121") > 1);
    STYSNUM0 = (W_CheckMultipleLumps("STYSNUM0") > 1);
    TITLEPIC = (W_CheckNumForName("TITLEPIC") >= 0);
    WISCRT2 = (W_CheckMultipleLumps("WISCRT2") > 1);

    bfgedition = (DMENUPIC && W_CheckNumForName("M_ACPT") >= 0);

    // Generate the WAD hash table. Speed things up a bit.
    W_GenerateHashTable();

    D_IdentifyVersion();
    InitGameVersion();
    D_SetGameDescription();
    D_SetSaveGameDir();

    // Check for -file in shareware
    if (modifiedgame)
    {
        // These are the lumps that will be checked in IWAD,
        // if any one is not present, execution will be aborted.
        char name[23][9] =
        {
            "e2m1", "e2m2", "e2m3", "e2m4", "e2m5", "e2m6", "e2m7", "e2m8", "e2m9",
            "e3m1", "e3m3", "e3m3", "e3m4", "e3m5", "e3m6", "e3m7", "e3m8", "e3m9",
            "dphoof", "bfgga0", "heada1", "cybra1", "spida1d1"
        };
        int i;

        if (gamemode == shareware)
            I_Error("You cannot use -FILE with the shareware version.\n"
                    "Please purchase the full version.");

        // Check for fake IWAD with right name,
        // but w/o all the lumps of the registered version.
        if (gamemode == registered)
            for (i = 0; i < 23; i++)
                if (W_CheckNumForName(name[i]) < 0)
                    I_Error("This is not the registered version.");
    }

    // get skill / episode / map from parms
    startskill = sk_medium;
    startepisode = 1;
    startmap = 1;
    autostart = false;

    p = M_CheckParmWithArgs("-skill", 1);
    if (p)
    {
        temp = myargv[p + 1][0] - '1';
        if (temp >= sk_baby && temp <= sk_nightmare)
        {
            startskill = (skill_t)temp;
            autostart = true;
        }
    }

    p = M_CheckParmWithArgs("-episode", 1);
    if (p)
    {
        temp = myargv[p + 1][0] - '0';
        if ((gamemode == shareware && temp == 1)
            || (temp >= 1
                && ((gamemode == registered && temp <= 3)
                    || (gamemode == retail && temp <= 4))))
        {
            startepisode = temp;
            startmap = 1;
            autostart = true;
        }
    }

    p = M_CheckParmWithArgs("-expansion", 1);
    if (p)
    {
        temp = myargv[p + 1][0] - '0';
        if (gamemode == commercial && temp <= (nerve ? 2 : 1))
        {
            gamemission = (temp == 1 ? doom2 : pack_nerve);
            selectedexpansion = temp - 1;
            startepisode = 1;
            startmap = 1;
            autostart = true;
        }
    }

    timelimit = 0;

    p = M_CheckParmWithArgs("-timer", 1);
    if (p)
        timelimit = atoi(myargv[p + 1]);

    p = M_CheckParm("-avg");
    if (p)
        timelimit = 20;

    p = M_CheckParmWithArgs("-warp", 1);
    if (p)
    {
        static char lumpname[6];

        if (gamemode == commercial)
        {
            if (strlen(myargv[p + 1]) == 5 &&
                toupper(myargv[p + 1][0]) == 'M' &&
                toupper(myargv[p + 1][1]) == 'A' &&
                toupper(myargv[p + 1][2]) == 'P')
                startmap = (myargv[p + 1][3] - '0') * 10 + myargv[p + 1][4] - '0';
            else
                startmap = atoi(myargv[p + 1]);

            sprintf(lumpname, "MAP%02i", startmap);
        }
        else
        {
            if (strlen(myargv[p + 1]) == 4 &&
                toupper(myargv[p + 1][0]) == 'E' &&
                toupper(myargv[p + 1][2]) == 'M')
            {
                startepisode = myargv[p + 1][1] - '0';
                startmap = myargv[p + 1][3] - '0';
            }
            else
            {
                startepisode = myargv[p + 1][0] - '0';

                if (p + 2 < myargc)
                    startmap = myargv[p + 2][0] - '0';
                else
                    startmap = 1;
            }

            sprintf(lumpname, "E%iM%i", startepisode, startmap);
        }

        if (W_CheckNumForName(lumpname) >= 0)
            autostart = true;
    }

    p = M_CheckParmWithArgs("-loadgame", 1);
    if (p)
        startloadgame = atoi(myargv[p + 1]);
    else
        startloadgame = -1;

    if (mouseSensitivity < MOUSESENSITIVITY_MIN || mouseSensitivity > MOUSESENSITIVITY_MAX)
        mouseSensitivity = MOUSESENSITIVITY_DEFAULT;
    if (mouseSensitivity == MOUSESENSITIVITY_MIN)
        mouseSensitivity = -5;
    gamepadSensitivity = (!mouseSensitivity ? 0.0f :
                          (2.0f + mouseSensitivity / (float)MOUSESENSITIVITY_MAX));

    if (sfxVolume < SFXVOLUME_MIN || sfxVolume > SFXVOLUME_MAX)
        sfxVolume = SFXVOLUME_DEFAULT;

    if (musicVolume < MUSICVOLUME_MIN || musicVolume > MUSICVOLUME_MAX)
        musicVolume = MUSICVOLUME_DEFAULT;

    if (screensize < SCREENSIZE_MIN || screensize > SCREENSIZE_MAX)
        screensize = SCREENSIZE_DEFAULT;
    if (widescreen && !fullscreen)
    {
        widescreen = false;
        screensize = SCREENSIZE_MAX;
    }
    if (!widescreen)
        hud = true;
    if (fullscreen && screensize == SCREENSIZE_MAX)
    {
        widescreen = true;
        screensize = SCREENSIZE_MAX - 1;
    }
    if (widescreen)
    {
        returntowidescreen = true;
        widescreen = false;
    }

    if (screenwidth && screenheight
        && (screenwidth < SCREENWIDTH || screenheight < SCREENHEIGHT * 3 / 4))
    {
        screenwidth = SCREENWIDTH;
        screenheight = SCREENWIDTH * 3 / 4;
    }

    if (windowwidth < SCREENWIDTH || windowheight < SCREENWIDTH * 3 / 4)
    {
        windowwidth = SCREENWIDTH;
        windowheight = SCREENWIDTH * 3 / 4;
    }

    if (gammalevel < GAMMALEVEL_MIN || gammalevel > GAMMALEVEL_MAX)
        gammalevel = GAMMALEVEL_DEFAULT;
    gammalevelindex = 0;
    while (gammalevelindex < GAMMALEVELS)
        if (gammalevels[gammalevelindex++] == gammalevel)
            break;
    if (gammalevelindex == GAMMALEVELS)
    {
        gammalevelindex = 0;
        while (gammalevels[gammalevelindex++] != GAMMALEVEL_DEFAULT);
    }
    gammalevelindex--;

    if (bloodsplats < BLOODSPLATS_MIN || bloodsplats > BLOODSPLATS_MAX)
        bloodsplats = BLOODSPLATS_DEFAULT;
    bloodSplatSpawner = ((bloodsplats == UNLIMITED ? P_SpawnBloodSplat : 
                         (bloodsplats ? P_SpawnBloodSplat2 : P_SpawnBloodSplat3)));

    if (pixelwidth < PIXELWIDTH_MIN || pixelwidth > PIXELWIDTH_MAX)
        pixelwidth = PIXELWIDTH_DEFAULT;
    while (SCREENWIDTH % pixelwidth)
        pixelwidth--;
    if (pixelheight < PIXELHEIGHT_MIN || pixelheight > PIXELHEIGHT_MAX)
        pixelheight = PIXELHEIGHT_DEFAULT;
    while (SCREENHEIGHT % pixelheight)
        pixelheight--;

    M_Init();

    R_Init();

    P_Init();

    I_Init();

    S_Init((int)(sfxVolume * (127.0f / 15.0f)), (int)(musicVolume * (127.0f / 15.0f)));

    D_CheckNetGame();

    HU_Init();

    ST_Init();

    AM_Init();

    if (startloadgame >= 0)
    {
        M_StringCopy(file, P_SaveGameFile(startloadgame), sizeof(file));
        G_LoadGame(file);
    }

    if (gameaction != ga_loadgame)
    {
        if (autostart || netgame)
            G_DeferredInitNew(startskill, startepisode, startmap);
        else
            D_StartTitle();                     // start up intro loop
    }
}