From 4b7c1bd37ed78be5d4ab58fb1bae16993b76806e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 3 Jun 2021 17:21:31 +0200 Subject: [PATCH] - WH: Init fixes and cleanup. --- source/games/whaven/src/fonts.cpp | 9 -- source/games/whaven/src/main.cpp | 54 +++++---- source/games/whaven/src/wh.h | 2 +- source/games/whaven/src/whfx.cpp | 177 ------------------------------ 4 files changed, 35 insertions(+), 207 deletions(-) diff --git a/source/games/whaven/src/fonts.cpp b/source/games/whaven/src/fonts.cpp index 58b57f524..32e3347c2 100644 --- a/source/games/whaven/src/fonts.cpp +++ b/source/games/whaven/src/fonts.cpp @@ -13,15 +13,6 @@ BEGIN_WH_NS void InitFonts() { - // Remap table for the menu font. - uint8_t remapbuf[256]; - for (int i = 0; i < 256; i++) remapbuf[i] = i; - for(int i = 242; i < 252; i++) //yellow to green - remapbuf[i] = (uint8_t) (368 - i); - //for(int i = 117; i < 127; i++) //green to yellow - //remapbuf[i] = (uint8_t) (368 - i); - lookups.makeTable(20, remapbuf, 0, 0, 0, true); - GlyphSet fontdata; // Small font diff --git a/source/games/whaven/src/main.cpp b/source/games/whaven/src/main.cpp index d1e08e45a..2830d865e 100644 --- a/source/games/whaven/src/main.cpp +++ b/source/games/whaven/src/main.cpp @@ -538,41 +538,55 @@ static void readpalettetable(void) } } +void GameInterface::loadPalette() +{ + paletteLoadFromDisk(); + readpalettetable(); + + if (isWh2()) { + tileDelete(FLOORMIRROR); + uint8_t tempbuf[256]; + for (int j = 0; j < 256; j++) + tempbuf[j] = (byte)((j + 32) & 0xFF); // remap colors for screwy palette sectors + lookups.makeTable(16, tempbuf, 0, 0, 0, 1); + for (int j = 0; j < 256; j++) + tempbuf[j] = (byte)j; + lookups.makeTable(17, tempbuf, 24, 24, 24, 1); + + for (int j = 0; j < 256; j++) + tempbuf[j] = (byte)j; // (j&31)+32; + lookups.makeTable(18, tempbuf, 8, 8, 48, 1); + } + + // Remap table for the menu font. + uint8_t remapbuf[256]; + for (int i = 0; i < 256; i++) remapbuf[i] = i; + for (int i = 242; i < 252; i++) //yellow to green + remapbuf[i] = (uint8_t)(368 - i); + //for(int i = 117; i < 127; i++) //green to yellow + //remapbuf[i] = (uint8_t) (368 - i); + lookups.makeTable(20, remapbuf, 0, 0, 0, true); + +} + + void GameInterface::app_init() { + InitFonts(); + GameTicRate = TIMERRATE / TICSPERFRAME; InitNames(); engineInit(); - TileFiles.LoadArtSet("tiles%03d.art"); TileFiles.tileMakeWritable(ANILAVA); TileFiles.tileMakeWritable(HEALTHWATER); initlava(); initwater(); //ConsoleInit(); g_visibility=1024; - readpalettetable(); - TileFiles.SetBackup(); - InitFonts(); connectpoint2[0] = -1; - - if(isWh2()) { - tileDelete(FLOORMIRROR); - uint8_t tempbuf[256]; - for (int j = 0; j < 256; j++) - tempbuf[j] = (byte) ((j + 32) & 0xFF); // remap colors for screwy palette sectors - lookups.makeTable(16, tempbuf, 0, 0, 0, 1); - for (int j = 0; j < 256; j++) - tempbuf[j] = (byte) j; - lookups.makeTable(17, tempbuf, 24, 24, 24, 1); - - for (int j = 0; j < 256; j++) - tempbuf[j] = (byte) j; // (j&31)+32; - lookups.makeTable(18, tempbuf, 8, 8, 48, 1); - } - FadeInit(); setupmidi(); sfxInit(); //sndInit(); diff --git a/source/games/whaven/src/wh.h b/source/games/whaven/src/wh.h index 6f881430c..92c866bc9 100644 --- a/source/games/whaven/src/wh.h +++ b/source/games/whaven/src/wh.h @@ -386,7 +386,6 @@ void bats(PLAYER& plr, int k); void cracks(); void lavadryland(); void warpfxsprite(int s); -void FadeInit(); void resetEffects(); void weaponpowerup(PLAYER& plr); void makesparks(short i, int type); @@ -510,6 +509,7 @@ struct GameInterface : public ::GameInterface const char* Name() override { return "Witchaven"; } void app_init() override; void clearlocalinputstate() override; + void loadPalette(); bool GenerateSavePic() override; GameStats getStats() override; void MenuOpened() override; diff --git a/source/games/whaven/src/whfx.cpp b/source/games/whaven/src/whfx.cpp index 4af636409..8edfa843f 100644 --- a/source/games/whaven/src/whfx.cpp +++ b/source/games/whaven/src/whfx.cpp @@ -1024,183 +1024,6 @@ void warpfxsprite(int s) { (bsin(daang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 1); } -void FadeInit() { -#pragma message("Fix fades") -#if 0 - Console.Println("Initializing fade effects", 0); - registerFade("RED", new FadeEffect(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA) { - private int intensive; - - @Override - public void update(int intensive) { - this.intensive = intensive; - if (intensive > 0) { - r = 3 * (intensive + 32); - a = 2 * (intensive + 32); - } else - r = a = 0; - if (r > 255) - r = 255; - if (a > 255) - a = 255; - } - - @Override - public void draw(GL10 gl) { - gl.glBlendFunc(sfactor, dfactor); - gl.glColor4ub(r, 0, 0, a); - gl.glBegin(GL_TRIANGLES); - gl.glVertex2f(-2.5f, 1.f); - gl.glVertex2f(2.5f, 1.f); - gl.glVertex2f(.0f, -2.5f); - gl.glEnd(); - - int multiple = intensive / 2; - if (multiple > 170) - multiple = 170; - gl.glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl.glColor4ub(r > 0 ? multiple : 0, 0, 0, 0); - gl.glBegin(GL_TRIANGLES); - gl.glVertex2f(-2.5f, 1.f); - gl.glVertex2f(2.5f, 1.f); - gl.glVertex2f(.0f, -2.5f); - gl.glEnd(); - } - }); - - registerFade("WHITE", new FadeEffect(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA) { - private int intensive; - - @Override - public void update(int intensive) { - this.intensive = intensive; - if (intensive > 0) { - g = r = 10 * intensive; - a = (intensive + 32); - } else - g = r = a = 0; - - if (r > 255) - r = 255; - if (g > 255) - g = 255; - if (a > 255) - a = 255; - } - - @Override - public void draw(GL10 gl) { - gl.glBlendFunc(sfactor, dfactor); - gl.glColor4ub(r, g, 0, a); - gl.glBegin(GL_TRIANGLES); - gl.glVertex2f(-2.5f, 1.f); - gl.glVertex2f(2.5f, 1.f); - gl.glVertex2f(.0f, -2.5f); - gl.glEnd(); - - if (intensive > 0) { - int multiple = intensive; - if (multiple > 255) - multiple = 255; - gl.glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl.glColor4ub(r > 0 ? multiple : 0, g > 0 ? multiple : 0, 0, 0); - gl.glBegin(GL_TRIANGLES); - gl.glVertex2f(-2.5f, 1.f); - gl.glVertex2f(2.5f, 1.f); - gl.glVertex2f(.0f, -2.5f); - gl.glEnd(); - } - } - }); - - registerFade("GREEN", new FadeEffect(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA) { - private int intensive; - - @Override - public void update(int intensive) { - this.intensive = intensive; - if (intensive > 0) { - g = 4 * intensive; - a = (intensive + 32); - } else - g = a = 0; - - if (g > 255) - g = 255; - if (a > 255) - a = 255; - } - - @Override - public void draw(GL10 gl) { - gl.glBlendFunc(sfactor, dfactor); - gl.glColor4ub(0, g, 0, a); - gl.glBegin(GL_TRIANGLES); - gl.glVertex2f(-2.5f, 1.f); - gl.glVertex2f(2.5f, 1.f); - gl.glVertex2f(.0f, -2.5f); - gl.glEnd(); - - if (intensive > 0) { - int multiple = intensive; - if (multiple > 255) - multiple = 255; - gl.glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl.glColor4ub(0, g > 0 ? multiple : 0, 0, 0); - gl.glBegin(GL_TRIANGLES); - gl.glVertex2f(-2.5f, 1.f); - gl.glVertex2f(2.5f, 1.f); - gl.glVertex2f(.0f, -2.5f); - gl.glEnd(); - } - } - }); - - registerFade("BLUE", new FadeEffect(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA) { - private int intensive; - - @Override - public void update(int intensive) { - this.intensive = intensive; - if (intensive > 0) { - b = 4 * intensive; - a = (intensive + 32); - } else - b = a = 0; - - if (b > 255) - b = 255; - if (a > 255) - a = 255; - } - - @Override - public void draw(GL10 gl) { - gl.glBlendFunc(sfactor, dfactor); - gl.glColor4ub(0, 0, b, a); - gl.glBegin(GL_TRIANGLES); - gl.glVertex2f(-2.5f, 1.f); - gl.glVertex2f(2.5f, 1.f); - gl.glVertex2f(.0f, -2.5f); - gl.glEnd(); - - if (intensive > 0) { - int multiple = intensive; - if (multiple > 255) - multiple = 255; - gl.glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl.glColor4ub(0, 0, b > 0 ? multiple : 0, 0); - gl.glBegin(GL_TRIANGLES); - gl.glVertex2f(-2.5f, 1.f); - gl.glVertex2f(2.5f, 1.f); - gl.glVertex2f(.0f, -2.5f); - gl.glEnd(); - } - } - }); -#endif -} - void resetEffects() { #if 0 greencount = 0;