- WH: Init fixes and cleanup.

This commit is contained in:
Christoph Oelckers 2021-06-03 17:21:31 +02:00
parent 095391ed3a
commit 4b7c1bd37e
4 changed files with 35 additions and 207 deletions

View file

@ -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

View file

@ -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();

View file

@ -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;

View file

@ -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;