From d3a868b566229a5a9d18ffd0b23c7dd179b25a5e Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 11 Sep 2021 02:15:20 -0700 Subject: [PATCH] Axe `RGBflip()` in favor of `getRGB()` RGBflip() does the exact same thing as getRGB(), now that all the surface masks have been fixed. This axes RGBflip() and changes all callers to use getRGB() instead. It is more readable that way. By doing this, there is less copy-pasting. Additionally, it is now easier to search for RGBf() - which is an ENTIRELY different function than RGBflip() - now that the name of RGBf is no longer the first four characters of some different, unrelated function. Previously I would've had to do `rg 'RGBf[^\w]'` which was stupid and awful and I hated it. --- desktop_version/src/Graphics.cpp | 109 ++++++++++++++---------------- desktop_version/src/Graphics.h | 2 - desktop_version/src/preloader.cpp | 28 ++++---- 3 files changed, 66 insertions(+), 73 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index e33e8f93..318f835d 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -2207,62 +2207,62 @@ void Graphics::drawbackground( int t ) { //Akward ordering to match tileset case 0: - bcol2 = RGBflip(0, 16*backboxint[0], 16*backboxint[0]); + bcol2 = getRGB(0, 16*backboxint[0], 16*backboxint[0]); break; //Cyan case 1: - bcol2 = RGBflip(16*backboxint[0], 0, 0); + bcol2 = getRGB(16*backboxint[0], 0, 0); break; //Red case 2: - bcol2 = RGBflip(16*backboxint[0], 0, 16*backboxint[0]); + bcol2 = getRGB(16*backboxint[0], 0, 16*backboxint[0]); break; //Purple case 3: - bcol2 = RGBflip(0, 0, 16*backboxint[0]); + bcol2 = getRGB(0, 0, 16*backboxint[0]); break; //Blue case 4: - bcol2 = RGBflip(16*backboxint[0], 16*backboxint[0], 0); + bcol2 = getRGB(16*backboxint[0], 16*backboxint[0], 0); break; //Yellow case 5: - bcol2 = RGBflip(0, 16 * backboxint[0], 0); + bcol2 = getRGB(0, 16 * backboxint[0], 0); break; //Green case 6: //crazy case switch(spcol) { case 0: - bcol2 = RGBflip(0, 16*backboxint[0], 16*backboxint[0]); + bcol2 = getRGB(0, 16*backboxint[0], 16*backboxint[0]); break; //Cyan case 1: - bcol2 = RGBflip(0, (spcoldel+1)*backboxint[0], 16*backboxint[0]); + bcol2 = getRGB(0, (spcoldel+1)*backboxint[0], 16*backboxint[0]); break; //Cyan case 2: - bcol2 = RGBflip(0, 0, 16*backboxint[0]); + bcol2 = getRGB(0, 0, 16*backboxint[0]); break; //Blue case 3: - bcol2 = RGBflip((16-spcoldel)*backboxint[0], 0, 16*backboxint[0]); + bcol2 = getRGB((16-spcoldel)*backboxint[0], 0, 16*backboxint[0]); break; //Blue case 4: - bcol2 = RGBflip(16*backboxint[0], 0, 16*backboxint[0]); + bcol2 = getRGB(16*backboxint[0], 0, 16*backboxint[0]); break; //Purple case 5: - bcol2 = RGBflip(16*backboxint[0], 0, (spcoldel+1)*backboxint[0]); + bcol2 = getRGB(16*backboxint[0], 0, (spcoldel+1)*backboxint[0]); break; //Purple case 6: - bcol2 = RGBflip(16*backboxint[0], 0, 0); + bcol2 = getRGB(16*backboxint[0], 0, 0); break; //Red case 7: - bcol2 = RGBflip(16*backboxint[0], (16-spcoldel)*backboxint[0], 0); + bcol2 = getRGB(16*backboxint[0], (16-spcoldel)*backboxint[0], 0); break; //Red case 8: - bcol2 = RGBflip(16*backboxint[0], 16*backboxint[0], 0); + bcol2 = getRGB(16*backboxint[0], 16*backboxint[0], 0); break; //Yellow case 9: - bcol2 = RGBflip((spcoldel+1)*backboxint[0], 16*backboxint[0], 0); + bcol2 = getRGB((spcoldel+1)*backboxint[0], 16*backboxint[0], 0); break; //Yellow case 10: - bcol2 = RGBflip(0, 16 * backboxint[0], 0); + bcol2 = getRGB(0, 16 * backboxint[0], 0); break; //Green case 11: - bcol2 = RGBflip(0, 16 * backboxint[0], (16-spcoldel)*backboxint[0]); + bcol2 = getRGB(0, 16 * backboxint[0], (16-spcoldel)*backboxint[0]); break; //Green } break; @@ -2275,62 +2275,62 @@ void Graphics::drawbackground( int t ) { //Akward ordering to match tileset case 0: - bcol = RGBflip(16, 128*backboxint[0], 128*backboxint[0]); + bcol = getRGB(16, 128*backboxint[0], 128*backboxint[0]); break; //Cyan case 1: - bcol = RGBflip(128*backboxint[0], 16, 16); + bcol = getRGB(128*backboxint[0], 16, 16); break; //Red case 2: - bcol = RGBflip(128*backboxint[0], 16, 128*backboxint[0]); + bcol = getRGB(128*backboxint[0], 16, 128*backboxint[0]); break; //Purple case 3: - bcol = RGBflip(16, 16, 128*backboxint[0]); + bcol = getRGB(16, 16, 128*backboxint[0]); break; //Blue case 4: - bcol = RGBflip(128*backboxint[0], 128*backboxint[0], 16); + bcol = getRGB(128*backboxint[0], 128*backboxint[0], 16); break; //Yellow case 5: - bcol = RGBflip(16, 128 * backboxint[0], 16); + bcol = getRGB(16, 128 * backboxint[0], 16); break; //Green case 6: //crazy case switch(spcol) { case 0: - bcol = RGBflip(16, 128*backboxint[0], 128*backboxint[0]); + bcol = getRGB(16, 128*backboxint[0], 128*backboxint[0]); break; //Cyan case 1: - bcol = RGBflip(16, ((spcoldel+1)*8)*backboxint[0], 128*backboxint[0]); + bcol = getRGB(16, ((spcoldel+1)*8)*backboxint[0], 128*backboxint[0]); break; //Cyan case 2: - bcol = RGBflip(16, 16, 128*backboxint[0]); + bcol = getRGB(16, 16, 128*backboxint[0]); break; //Blue case 3: - bcol = RGBflip((128-(spcoldel*8))*backboxint[0], 16, 128*backboxint[0]); + bcol = getRGB((128-(spcoldel*8))*backboxint[0], 16, 128*backboxint[0]); break; //Blue case 4: - bcol = RGBflip(128*backboxint[0], 16, 128*backboxint[0]); + bcol = getRGB(128*backboxint[0], 16, 128*backboxint[0]); break; //Purple case 5: - bcol = RGBflip(128*backboxint[0], 16, ((spcoldel+1)*8)*backboxint[0]); + bcol = getRGB(128*backboxint[0], 16, ((spcoldel+1)*8)*backboxint[0]); break; //Purple case 6: - bcol = RGBflip(128*backboxint[0], 16, 16); + bcol = getRGB(128*backboxint[0], 16, 16); break; //Red case 7: - bcol = RGBflip(128*backboxint[0], (128-(spcoldel*8))*backboxint[0], 16); + bcol = getRGB(128*backboxint[0], (128-(spcoldel*8))*backboxint[0], 16); break; //Red case 8: - bcol = RGBflip(128*backboxint[0], 128*backboxint[0], 16); + bcol = getRGB(128*backboxint[0], 128*backboxint[0], 16); break; //Yellow case 9: - bcol = RGBflip(((spcoldel+1)*8)*backboxint[0], 128*backboxint[0], 16); + bcol = getRGB(((spcoldel+1)*8)*backboxint[0], 128*backboxint[0], 16); break; //Yellow case 10: - bcol = RGBflip(16, 128 * backboxint[0], 16); + bcol = getRGB(16, 128 * backboxint[0], 16); break; //Green case 11: - bcol = RGBflip(16, 128 * backboxint[0], (128-(spcoldel*8))*backboxint[0]); + bcol = getRGB(16, 128 * backboxint[0], (128-(spcoldel*8))*backboxint[0]); break; //Green } break; @@ -2367,36 +2367,36 @@ void Graphics::drawbackground( int t ) { //Akward ordering to match tileset case 0: - warpbcol = RGBflip(0x0A, 0x10, 0x0E); - warpfcol = RGBflip(0x10, 0x22, 0x21); + warpbcol = getRGB(0x0A, 0x10, 0x0E); + warpfcol = getRGB(0x10, 0x22, 0x21); break; //Cyan case 1: - warpbcol = RGBflip(0x11, 0x09, 0x0B); - warpfcol = RGBflip(0x22, 0x10, 0x11); + warpbcol = getRGB(0x11, 0x09, 0x0B); + warpfcol = getRGB(0x22, 0x10, 0x11); break; //Red case 2: - warpbcol = RGBflip(0x0F, 0x0A, 0x10); - warpfcol = RGBflip(0x22,0x10,0x22); + warpbcol = getRGB(0x0F, 0x0A, 0x10); + warpfcol = getRGB(0x22,0x10,0x22); break; //Purple case 3: - warpbcol = RGBflip(0x0A, 0x0B, 0x10); - warpfcol = RGBflip(0x10, 0x10, 0x22); + warpbcol = getRGB(0x0A, 0x0B, 0x10); + warpfcol = getRGB(0x10, 0x10, 0x22); break; //Blue case 4: - warpbcol = RGBflip(0x10, 0x0D, 0x0A); - warpfcol = RGBflip(0x22, 0x1E, 0x10); + warpbcol = getRGB(0x10, 0x0D, 0x0A); + warpfcol = getRGB(0x22, 0x1E, 0x10); break; //Yellow case 5: - warpbcol = RGBflip(0x0D, 0x10, 0x0A); - warpfcol = RGBflip(0x14, 0x22, 0x10); + warpbcol = getRGB(0x0D, 0x10, 0x0A); + warpfcol = getRGB(0x14, 0x22, 0x10); break; //Green case 6: - warpbcol = RGBflip(0x0A, 0x0A, 0x0A); - warpfcol = RGBflip(0x12, 0x12, 0x12); + warpbcol = getRGB(0x0A, 0x0A, 0x0A); + warpfcol = getRGB(0x12, 0x12, 0x12); break; //Gray default: - warpbcol = RGBflip(0xFF, 0xFF, 0xFF); - warpfcol = RGBflip(0xFF, 0xFF, 0xFF); + warpbcol = getRGB(0xFF, 0xFF, 0xFF); + warpfcol = getRGB(0xFF, 0xFF, 0xFF); } for (int i = 10 ; i >= 0; i--) @@ -3259,11 +3259,6 @@ Uint32 Graphics::getRGB(Uint32 _col) return ( _col); } -Uint32 Graphics::RGBflip(Uint8 r, Uint8 g, Uint8 b) -{ - return SDL_MapRGB(backBuffer->format, r, g, b); -} - Uint32 Graphics::RGBf(int r, int g, int b) { r = (r+128) / 3; diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index 8bacf44c..f61e5919 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -185,8 +185,6 @@ public: Uint32 getRGB(Uint32 _col); - Uint32 RGBflip(Uint8 r, Uint8 g, Uint8 b); - Uint32 RGBf(int r, int g, int b); diff --git a/desktop_version/src/preloader.cpp b/desktop_version/src/preloader.cpp index 90a9c4b0..099459d3 100644 --- a/desktop_version/src/preloader.cpp +++ b/desktop_version/src/preloader.cpp @@ -54,32 +54,32 @@ void preloaderrender(void) if(pre_transition>=30){ switch(pre_curcol) { case 0: - pre_lightcol = graphics.RGBflip(0xBF,0x59,0x6F); - pre_darkcol = graphics.RGBflip(0x88,0x3E,0x53); + pre_lightcol = graphics.getRGB(0xBF,0x59,0x6F); + pre_darkcol = graphics.getRGB(0x88,0x3E,0x53); break; case 1: - pre_lightcol = graphics.RGBflip(0x6C,0xBC,0x5C); - pre_darkcol = graphics.RGBflip(0x50,0x86,0x40); + pre_lightcol = graphics.getRGB(0x6C,0xBC,0x5C); + pre_darkcol = graphics.getRGB(0x50,0x86,0x40); break; case 2: - pre_lightcol = graphics.RGBflip(0x5D,0x57,0xAA); - pre_darkcol = graphics.RGBflip(0x2F,0x2F,0x6C); + pre_lightcol = graphics.getRGB(0x5D,0x57,0xAA); + pre_darkcol = graphics.getRGB(0x2F,0x2F,0x6C); break; case 3: - pre_lightcol = graphics.RGBflip(0xB7,0xBA,0x5E); - pre_darkcol = graphics.RGBflip(0x84,0x83,0x42); + pre_lightcol = graphics.getRGB(0xB7,0xBA,0x5E); + pre_darkcol = graphics.getRGB(0x84,0x83,0x42); break; case 4: - pre_lightcol = graphics.RGBflip(0x57,0x90,0xAA); - pre_darkcol = graphics.RGBflip(0x2F,0x5B,0x6C); + pre_lightcol = graphics.getRGB(0x57,0x90,0xAA); + pre_darkcol = graphics.getRGB(0x2F,0x5B,0x6C); break; case 5: - pre_lightcol = graphics.RGBflip(0x90,0x61,0xB1); - pre_darkcol = graphics.RGBflip(0x58,0x3D,0x71); + pre_lightcol = graphics.getRGB(0x90,0x61,0xB1); + pre_darkcol = graphics.getRGB(0x58,0x3D,0x71); break; default: - pre_lightcol = graphics.RGBflip(0x00,0x00,0x00); - pre_darkcol = graphics.RGBflip(0x08,0x00,0x00); + pre_lightcol = graphics.getRGB(0x00,0x00,0x00); + pre_darkcol = graphics.getRGB(0x08,0x00,0x00); break; }