Skip to content

Commit

Permalink
Implement color channel modifier and adapt colors of certain games so…
Browse files Browse the repository at this point in the history
… not one channel is every fully 0
  • Loading branch information
joyrider3774 committed May 11, 2023
1 parent 9bbcc57 commit 56ed8c8
Show file tree
Hide file tree
Showing 11 changed files with 225 additions and 52 deletions.
14 changes: 10 additions & 4 deletions src/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,13 @@ void CGame::LoadSettings()
if (SettingsFile)
{
int VolumeMusic, VolumeSound, aMotionBlur;
fscanf(SettingsFile, "VolumeMusic=%d\nVolumeSound=%d\nCrt=%d\nSpriteGhosting=%d\n", &VolumeMusic, &VolumeSound, &Crt, &aMotionBlur);
int ret = fscanf(SettingsFile, "VolumeMusic=%d\nVolumeSound=%d\nCrt=%d\nSpriteGhosting=%d\nColorModR=%d\nColorModG=%d\nColorModB=%d\n",
&VolumeMusic, &VolumeSound, &Crt, &aMotionBlur, &ColorModR, &ColorModG, &ColorModB);
MotionBlur = (aMotionBlur == 1);
Audio->SetVolumeSound(VolumeSound);
Audio->SetVolumeMusic(VolumeMusic);
if(ret > 0)
Audio->SetVolumeMusic(VolumeMusic);
if(ret > 1)
Audio->SetVolumeSound(VolumeSound);
fclose(SettingsFile);
}
else
Expand Down Expand Up @@ -529,7 +532,8 @@ void CGame::SaveSettings()
{
int VolumeMusic = Audio->GetVolumeMusic();
int VolumeSound = Audio->GetVolumeSound();
fprintf(SettingsFile, "VolumeMusic=%d\nVolumeSound=%d\nCrt=%d\nSpriteGhosting=%d\n", VolumeMusic, VolumeSound, Crt, MotionBlur?1:0);
fprintf(SettingsFile, "VolumeMusic=%d\nVolumeSound=%d\nCrt=%d\nSpriteGhosting=%d\nColorModR=%d\nColorModG=%d\nColorModB=%d\n",
VolumeMusic, VolumeSound, Crt, MotionBlur?1:0, ColorModR, ColorModG, ColorModB);
fclose(SettingsFile);
}
}
Expand Down Expand Up @@ -759,6 +763,8 @@ void CGame::MainLoop()
SDL_SetRenderDrawColor(Renderer, 0, 0, 0, 255);
SDL_RenderClear(Renderer);

SDL_SetTextureColorMod(TexScreen, ColorModR, ColorModG, ColorModB);

int w, h, w2, h2, x, y;
SDL_GetWindowSize(SdlWindow, &w , &h);
float ScaleX = (float)w / (float)ScreenWidth;
Expand Down
1 change: 1 addition & 0 deletions src/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class CGame {
bool MotionBlur;
int GFXFrameID, GFXMedal;
int CurrentGameMusicID;
int ColorModR=255, ColorModG=255, ColorModB=255;
CGame();
~CGame();

Expand Down
24 changes: 15 additions & 9 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,22 @@ PauseMenuDesc PMPauseMenus[PauseMenus] =
{PMSoundVol, "Sound Volume: "},
{PMMotionBlur, "Sprite Ghosting Effect: "},
{PMGameHelp, "Game Help"},
{PMColorModR, "Color Mod Red: "},
{PMColorModG, "Color Mod Green: "},
{PMColorModB, "Color Mod Blue: "},
{PMCrt, "Crt Effect: "}
};

//GamePauseMenus
GPGamePauseMenusDesc GPGamePauseMenus[Games] = {
{GSSpaceInvaders, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMQuit}},
{GSBreakout, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMQuit}},
{GSFrog, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMQuit}},
{GSSnake, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMQuit}},
{GSPang, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMQuit}},
{GSTetris, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMQuit}},
{GSRamIt, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMQuit}},
{GSEddy, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMQuit}}
{GSSpaceInvaders, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMColorModR, PMColorModG, PMColorModB, PMQuit}},
{GSBreakout, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMColorModR, PMColorModG, PMColorModB, PMQuit}},
{GSFrog, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMColorModR, PMColorModG, PMColorModB, PMQuit}},
{GSSnake, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMColorModR, PMColorModG, PMColorModB, PMQuit}},
{GSPang, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMColorModR, PMColorModG, PMColorModB, PMQuit}},
{GSTetris, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMColorModR, PMColorModG, PMColorModB, PMQuit}},
{GSRamIt, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMColorModR, PMColorModG, PMColorModB, PMQuit}},
{GSEddy, {PMContinue, PMGameHelp, PMMotionBlur, PMCrt, PMMusicVol, PMSoundVol, PMColorModR, PMColorModG, PMColorModB, PMQuit}}
};

//MainMenus
Expand All @@ -172,8 +175,11 @@ OptionMenusDesc OMOptionMenus[OptionMenus] =
{OMSoundVol, "Sound Volume: "},
{OMMotionBlur, "Sprite Ghosting Effect: "},
{OMCrt, "Crt Effect: "},
{OMColorModR, "Color Mod Red: "},
{OMColorModG, "Color Mod Green: "},
{OMColorModB, "Color Mod Blue: "},
{OMResetHighScores, "Reset Highscores"},
{OMBack, "Back"}
{OMBack, "Back"},
};

//CrtOptions
Expand Down
19 changes: 13 additions & 6 deletions src/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ constexpr int PMMusicVol = 2;
constexpr int PMSoundVol = 3;
constexpr int PMMotionBlur = 4;
constexpr int PMGameHelp = 5;
constexpr int PMCrt = 6;
constexpr int PMColorModR = 6;
constexpr int PMColorModG = 7;
constexpr int PMColorModB = 8;
constexpr int PMCrt = 9;

constexpr int PauseMenus = 7;

constexpr int PauseMenus = 10;

//main menus
constexpr int MMStart = 0;
Expand All @@ -104,9 +108,12 @@ constexpr int OMMusicVol = 0;
constexpr int OMSoundVol = 1;
constexpr int OMMotionBlur = 2;
constexpr int OMCrt = 3;
constexpr int OMResetHighScores = 4;
constexpr int OMBack = 5;
constexpr int OptionMenus = 6;
constexpr int OMColorModR = 4;
constexpr int OMColorModG = 5;
constexpr int OMColorModB = 6;
constexpr int OMResetHighScores = 7;
constexpr int OMBack = 8;
constexpr int OptionMenus = 9;

//CRTS
constexpr int Crts = 6;
Expand All @@ -131,7 +138,7 @@ struct PauseMenuDesc {

struct GPGamePauseMenusDesc {
int game;
int menus[7];
int menus[10];
};

struct MainMenusDesc {
Expand Down
70 changes: 68 additions & 2 deletions src/TitleScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ void TitleScreen(CGame *Game)
case MMOptions:
{
int selectedmenu = 0;
int menutextsize = 50;
int menuspacing = 65;
int menutextsize = 35;
int menuspacing = 45;

selectedmenu = OMOptionMenus[SelOptions].menu;
Text = "Options";
Expand Down Expand Up @@ -85,6 +85,18 @@ void TitleScreen(CGame *Game)
Text = OMOptionMenus[menu].name + CrtOptions[Game->Crt].name;
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, Text, Text.length(), 400, 185 + i * menuspacing, 0, color);
break;
case OMColorModR:
Text = OMOptionMenus[menu].name + " " + to_string((int)Game->ColorModR * 100 / 255) + "%";
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, Text, Text.length(), 400, 185 + i * menuspacing, 0, color);
break;
case OMColorModG:
Text = OMOptionMenus[menu].name + " " + to_string((int)Game->ColorModG * 100 / 255) + "%";
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, Text, Text.length(), 400, 185 + i * menuspacing, 0, color);
break;
case OMColorModB:
Text = OMOptionMenus[menu].name + " " + to_string((int)Game->ColorModB * 100 / 255) + "%";
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, Text, Text.length(), 400, 185 + i * menuspacing, 0, color);
break;
default:
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, OMOptionMenus[menu].name, OMOptionMenus[menu].name.length(), 400,
185 + i * menuspacing, 0, color);
Expand Down Expand Up @@ -144,6 +156,24 @@ void TitleScreen(CGame *Game)
Game->Crt = Crts -1;
Game->ReCreateCrt();
break;

case OMColorModR:
Game->ColorModR -= 5;
if(Game->ColorModR < 15)
Game->ColorModR = 15;
break;

case OMColorModG:
Game->ColorModG -= 5;
if(Game->ColorModG < 15)
Game->ColorModG = 15;
break;

case OMColorModB:
Game->ColorModB -= 5;
if(Game->ColorModB < 15)
Game->ColorModB = 15;
break;
}
//createcrt(global.crt)
//savehighscoresoptions()
Expand Down Expand Up @@ -176,6 +206,24 @@ void TitleScreen(CGame *Game)
Game->Crt = 0;
Game->ReCreateCrt();
break;

case OMColorModR:
Game->ColorModR += 5;
if(Game->ColorModR > 255)
Game->ColorModR = 255;
break;

case OMColorModG:
Game->ColorModG += 5;
if(Game->ColorModG > 255)
Game->ColorModG = 255;
break;

case OMColorModB:
Game->ColorModB += 5;
if(Game->ColorModB > 255)
Game->ColorModB = 255;
break;
}
//createcrt(global.crt)
//savehighscoresoptions()
Expand Down Expand Up @@ -222,6 +270,24 @@ void TitleScreen(CGame *Game)
Game->Crt = 0;
Game->ReCreateCrt();
break;

case OMColorModR:
Game->ColorModR += 5;
if(Game->ColorModR > 255)
Game->ColorModR = 15;
break;

case OMColorModG:
Game->ColorModG += 5;
if(Game->ColorModG > 255)
Game->ColorModG = 15;
break;

case OMColorModB:
Game->ColorModB += 5;
if(Game->ColorModB > 255)
Game->ColorModB = 15;
break;
}
//createcrt(global.crt)
//savehighscoresoptions()
Expand Down
93 changes: 90 additions & 3 deletions src/games/CGameBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ void CGameBase::PauseMenu()
//global.substatecounter = 10.6
int selected = 0;
int selectedmenu = 0;
int maxmenus = 7;
int menutextsize = 45;
int menuspacing = 55;
int maxmenus = 10;
int menutextsize = 34;
int menuspacing = 44;
Game->Input->ResetButtons();

Uint64 TotalFrames = 0;
Expand Down Expand Up @@ -131,6 +131,19 @@ void CGameBase::PauseMenu()
Text = PMPauseMenus[menu].name + CrtOptions[Game->Crt].name;
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, Text, Text.length(), 300, 180 + i * menuspacing, 0, color);
break;
case PMColorModR:
Text = PMPauseMenus[menu].name + " " + to_string((int)Game->ColorModR * 100 / 255) + "%";
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, Text, Text.length(), 300, 180 + i * menuspacing, 0, color);
break;
case PMColorModG:
Text = PMPauseMenus[menu].name + " " + to_string((int)Game->ColorModG * 100 / 255) + "%";
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, Text, Text.length(), 300, 180 + i * menuspacing, 0, color);
break;
case PMColorModB:
Text = PMPauseMenus[menu].name + " " + to_string((int)Game->ColorModB * 100 / 255) + "%";
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, Text, Text.length(), 300, 180 + i * menuspacing, 0, color);
break;

default:
Game->Font->WriteText(Game->Renderer, "Roboto-Regular", menutextsize, PMPauseMenus[menu].name, PMPauseMenus[menu].name.length(), 300, 180 + i * menuspacing, 0, color);
break;
Expand Down Expand Up @@ -237,6 +250,30 @@ void CGameBase::PauseMenu()
Game->ReCreateCrt();
break;
}

case PMColorModR:
{
Game->ColorModR -= 5;
if(Game->ColorModR < 15)
Game->ColorModR = 15;
break;
}

case PMColorModG:
{
Game->ColorModG -= 5;
if(Game->ColorModG < 15)
Game->ColorModG = 15;
break;
}

case PMColorModB:
{
Game->ColorModB -= 5;
if(Game->ColorModB < 15)
Game->ColorModB = 15;
break;
}
}
}

Expand Down Expand Up @@ -276,6 +313,30 @@ void CGameBase::PauseMenu()
Game->ReCreateCrt();
break;
}

case PMColorModR:
{
Game->ColorModR += 5;
if(Game->ColorModR > 255)
Game->ColorModR = 255;
break;
}

case PMColorModG:
{
Game->ColorModG += 5;
if(Game->ColorModG > 255)
Game->ColorModG = 255;
break;
}

case PMColorModB:
{
Game->ColorModB += 5;
if(Game->ColorModB > 255)
Game->ColorModB = 255;
break;
}
}
}

Expand Down Expand Up @@ -370,6 +431,30 @@ void CGameBase::PauseMenu()
Game->Input->ResetButtons();
break;
}

case PMColorModR:
{
Game->ColorModR += 5;
if(Game->ColorModR > 255)
Game->ColorModR = 15;
break;
}

case PMColorModG:
{
Game->ColorModG += 5;
if(Game->ColorModG > 255)
Game->ColorModG = 15;
break;
}

case PMColorModB:
{
Game->ColorModB += 5;
if(Game->ColorModB > 255)
Game->ColorModB = 15;
break;
}
}
}
}
Expand All @@ -392,6 +477,8 @@ void CGameBase::PauseMenu()
SDL_SetRenderTarget(Game->Renderer, Game->TexScreen);
SDL_RenderCopy(Game->Renderer, Game->TexOffScreen, NULL, NULL);

SDL_SetTextureColorMod(Game->TexScreen, Game->ColorModR, Game->ColorModG, Game->ColorModB);

SDL_SetRenderTarget(Game->Renderer, NULL);
SDL_SetRenderDrawColor(Game->Renderer, 0, 0, 0, 255);
SDL_RenderClear(Game->Renderer);
Expand Down
Loading

0 comments on commit 56ed8c8

Please sign in to comment.