- preparations for refactoring Blood's HUD drawer, mainly to pass the palette explicitly to the drawers.

This commit is contained in:
Christoph Oelckers 2020-07-27 23:29:10 +02:00
parent ecdc92e6b9
commit 74c4bbc0e0
14 changed files with 123 additions and 134 deletions

View file

@ -1044,6 +1044,7 @@ int GameInterface::app_main()
if (playvideo)
credLogosDos();
UpdateDacs(0, true);
RESTART:
sub_79760();
@ -1202,7 +1203,6 @@ RESTART:
gDemo.Close();
if (gRestartGame)
{
UpdateDacs(0, true);
Mus_Stop();
soundEngine->StopAllChannels();
gQuitGame = 0;

View file

@ -52,7 +52,7 @@ void CChoke::sub_83ff0(int a1, void(*a2)(PLAYER*))
}
}
void CChoke::sub_84110(int x, int y)
void CChoke::sub_84110(int x, int y, int basepal)
{
if (!at8)
return;
@ -67,18 +67,7 @@ void CChoke::sub_84110(int x, int y)
atc = at8->at10;
int vdi = at8->at10-atc;
at8->Play(vdi-vd, vdi, -1, NULL);
int vb = windowxy1.x;
int v10 = windowxy1.y;
int vc = windowxy2.x;
int v8 = windowxy2.y;
windowxy1.x = windowxy1.y = 0;
windowxy2.x = xdim-1;
windowxy2.y = ydim-1;
at8->Draw(vdi, 10, 0, 0);
windowxy1.x = vb;
windowxy1.y = v10;
windowxy2.x = vc;
windowxy2.y = v8;
at8->Draw(&twodpsp, vdi, 10, 0, 0, basepal, false);
gFrameClock = v4;
}

View file

@ -42,7 +42,7 @@ public:
at18 = 0;
};
void sub_83ff0(int a1, void(*a2)(PLAYER*));
void sub_84110(int x, int y);
void sub_84110(int x, int y, int basepal);
void sub_84218();
char *at0;
QAV *at8;

View file

@ -210,7 +210,6 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
}
}
UpdateDacs(0, true);
gameHandleEvents();
ClockTicks nStartTime = totalclock;

View file

@ -114,13 +114,13 @@ void CGameMenuItemQAV::Draw(void)
int backX = data->x;
for (int i = 0; i < nCount; i++)
{
data->Draw(data->at10 - at2c, 10 + kQavOrientationLeft, 0, 0);
data->Draw(twod, data->at10 - at2c, 10 + kQavOrientationLeft, 0, 0, 0, false);
data->x += 320;
}
data->x = backX;
}
else
data->Draw(data->at10 - at2c, 10, 0, 0);
data->Draw(twod, data->at10 - at2c, 10, 0, 0, 0, false);
windowxy1.x = wx1;
windowxy1.y = wy1;

View file

@ -51,7 +51,7 @@ struct PLAYER;
extern QAV* weaponQAV[];
void WeaponInit(void);
void WeaponDraw(PLAYER *pPlayer, int a2, int a3, int a4, int a5);
void WeaponDraw(PLAYER *pPlayer, int a2, int a3, int a4, int a5, int basepal);
void WeaponRaise(PLAYER *pPlayer);
void WeaponLower(PLAYER *pPlayer);
char WeaponUpgrade(PLAYER *pPlayer, char newWeapon);

View file

@ -4793,7 +4793,7 @@ void playerQavSceneProcess(PLAYER* pPlayer, QAVSCENE* pQavScene) {
}
}
void playerQavSceneDraw(PLAYER* pPlayer, int a2, int a3, int a4, int a5) {
void playerQavSceneDraw(PLAYER* pPlayer, int a2, int a3, int a4, int a5, int basepal) {
if (pPlayer == NULL || pPlayer->sceneQav == -1) return;
QAVSCENE* pQavScene = &gPlayerCtrl[pPlayer->nPlayer].qavScene;
@ -4813,21 +4813,12 @@ void playerQavSceneDraw(PLAYER* pPlayer, int a2, int a3, int a4, int a5) {
if (!(pSprite->flags & kModernTypeFlag1)) {
pQAV->x = a3; pQAV->y = a4;
pQAV->Draw(v4, flags, a2, a5);
pQAV->Draw(&twodpsp, v4, flags, a2, a5, basepal, true);
// draw fullscreen (currently 4:3 only)
} else {
int wx1 = windowxy1.x, wy1 = windowxy1.y, wx2 = windowxy2.x, wy2 = windowxy2.y;
windowxy2.x = xdim - 1; windowxy2.y = ydim - 1;
windowxy1.x = windowxy1.y = 0;
pQAV->Draw(v4, flags, a2, a5);
windowxy1.x = wx1; windowxy1.y = wy1;
windowxy2.x = wx2; windowxy2.y = wy2;
// What an awful hack... :?
pQAV->Draw(&twodpsp, v4, flags, a2, a5, basepal, false);
}
}

View file

@ -314,7 +314,7 @@ void playerDeactivateShrooms(PLAYER* pPlayer);
QAV* playerQavSceneLoad(int qavId);
void playerQavSceneProcess(PLAYER* pPlayer, QAVSCENE* pQavScene);
void playerQavScenePlay(PLAYER* pPlayer);
void playerQavSceneDraw(PLAYER* pPlayer, int a2, int a3, int a4, int a5);
void playerQavSceneDraw(PLAYER* pPlayer, int a2, int a3, int a4, int a5, int basepal);
void playerQavSceneReset(PLAYER* pPlayer);
// ------------------------------------------------------------------------- //
void callbackUniMissileBurst(int nSprite);

View file

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "build.h"
#include "v_2ddrawer.h"
#include "compat.h"
#include "common_game.h"
#include "qav.h"
@ -43,7 +44,7 @@ int qavRegisterClient(void(*pClient)(int, void *))
return nClients++;
}
void DrawFrame(int x, int y, TILE_FRAME *pTile, int stat, int shade, int palnum)
void DrawFrame(F2DDrawer *twod, int x, int y, TILE_FRAME *pTile, int stat, int shade, int palnum, int basepal, bool to3dview)
{
stat |= pTile->stat;
int angle = pTile->angle;
@ -60,12 +61,22 @@ void DrawFrame(int x, int y, TILE_FRAME *pTile, int stat, int shade, int palnum)
}
if (palnum <= 0)
palnum = pTile->palnum;
rotatesprite((x + pTile->x) << 16, (y + pTile->y) << 16, pTile->z, angle,
pTile->picnum, ClipRange(pTile->shade + shade, -128, 127), palnum, stat,
windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y);
if (!to3dview)
{
twod_rotatesprite(twod, (x + pTile->x) << 16, (y + pTile->y) << 16, pTile->z, angle,
pTile->picnum, ClipRange(pTile->shade + shade, -128, 127), palnum, stat,
0, 0, 0, 0, twod->GetWidth(), twod->GetHeight(), nullptr, basepal);
}
else
{
twod_rotatesprite(twod, (x + pTile->x) << 16, (y + pTile->y) << 16, pTile->z, angle,
pTile->picnum, ClipRange(pTile->shade + shade, -128, 127), palnum, stat,
0, 0, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y, nullptr, basepal);
}
}
void QAV::Draw(int ticks, int stat, int shade, int palnum)
void QAV::Draw(F2DDrawer* twod, int ticks, int stat, int shade, int palnum, int basepal, bool to3dview)
{
dassert(ticksPerFrame > 0);
int nFrame = ticks / ticksPerFrame;
@ -74,7 +85,7 @@ void QAV::Draw(int ticks, int stat, int shade, int palnum)
for (int i = 0; i < 8; i++)
{
if (pFrame->tiles[i].picnum > 0)
DrawFrame(x, y, &pFrame->tiles[i], stat, shade, palnum);
DrawFrame(twod, x, y, &pFrame->tiles[i], stat, shade, palnum, basepal, to3dview);
}
}

View file

@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "common_game.h"
#include "blood.h"
class F2DDrawer;
BEGIN_BLD_NS
#define kQavOrientationLeft 4096
@ -79,7 +81,7 @@ struct QAV
//SPRITE *pSprite; // 1c
char pad3[4]; // 20
FRAMEINFO frames[1]; // 24
void Draw(int ticks, int stat, int shade, int palnum);
void Draw(F2DDrawer *twod, int ticks, int stat, int shade, int palnum, int basepal, bool inviewport);
void Play(int, int, int, void *);
void Preload(void);
void Precache(void);

View file

@ -131,7 +131,6 @@ void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits)
videoInit();
videoClearViewableArea(0);
videoNextPage();
scrSetPalette(curPalette);
}
END_BLD_NS

View file

@ -2917,69 +2917,68 @@ void UpdateDacs(int nPalette, bool bNoTint)
scrSetPalette(nPalette);
oldPalette = nPalette;
}
if (videoGetRenderMode() >= REND_POLYMOST)
gLastPal = 0;
auto& tint = lookups.tables[MAXPALOOKUPS - 1];
tint.tintFlags = 0;
switch (nPalette)
{
gLastPal = 0;
auto &tint = lookups.tables[MAXPALOOKUPS-1];
int nRed = 0;
int nGreen = 0;
int nBlue = 0;
tint.tintFlags = 0;
switch (nPalette)
{
case 0:
default:
tint.tintColor.r = 255;
tint.tintColor.g = 255;
tint.tintColor.b = 255;
break;
case 1:
tint.tintColor.r = 132;
tint.tintColor.g = 164;
tint.tintColor.b = 255;
break;
case 2:
tint.tintColor.r = 255;
tint.tintColor.g = 126;
tint.tintColor.b = 105;
break;
case 3:
tint.tintColor.r = 162;
tint.tintColor.g = 186;
tint.tintColor.b = 15;
break;
case 4:
tint.tintColor.r = 255;
tint.tintColor.g = 255;
tint.tintColor.b = 255;
break;
}
if (!bNoTint)
{
nRed += gView->pickupEffect;
nGreen += gView->pickupEffect;
nBlue -= gView->pickupEffect;
nRed += ClipHigh(gView->painEffect, 85)*2;
nGreen -= ClipHigh(gView->painEffect, 85)*3;
nBlue -= ClipHigh(gView->painEffect, 85)*3;
nRed -= gView->blindEffect;
nGreen -= gView->blindEffect;
nBlue -= gView->blindEffect;
nRed -= gView->chokeEffect>>6;
nGreen -= gView->chokeEffect>>5;
nBlue -= gView->chokeEffect>>6;
}
nRed = ClipRange(nRed, -255, 255);
nGreen = ClipRange(nGreen, -255, 255);
nBlue = ClipRange(nBlue, -255, 255);
videoSetPalette(nPalette);
videoTintBlood(nRed, nGreen, nBlue);
case 0:
default:
tint.tintColor.r = 255;
tint.tintColor.g = 255;
tint.tintColor.b = 255;
break;
case 1:
tint.tintColor.r = 132;
tint.tintColor.g = 164;
tint.tintColor.b = 255;
break;
case 2:
tint.tintColor.r = 255;
tint.tintColor.g = 126;
tint.tintColor.b = 105;
break;
case 3:
tint.tintColor.r = 162;
tint.tintColor.g = 186;
tint.tintColor.b = 15;
break;
case 4:
tint.tintColor.r = 255;
tint.tintColor.g = 255;
tint.tintColor.b = 255;
break;
}
videoSetPalette(nPalette);
}
void UpdateBlend()
{
int nRed = 0;
int nGreen = 0;
int nBlue = 0;
nRed += gView->pickupEffect;
nGreen += gView->pickupEffect;
nBlue -= gView->pickupEffect;
nRed += ClipHigh(gView->painEffect, 85) * 2;
nGreen -= ClipHigh(gView->painEffect, 85) * 3;
nBlue -= ClipHigh(gView->painEffect, 85) * 3;
nRed -= gView->blindEffect;
nGreen -= gView->blindEffect;
nBlue -= gView->blindEffect;
nRed -= gView->chokeEffect >> 6;
nGreen -= gView->chokeEffect >> 5;
nBlue -= gView->chokeEffect >> 6;
nRed = ClipRange(nRed, -255, 255);
nGreen = ClipRange(nGreen, -255, 255);
nBlue = ClipRange(nBlue, -255, 255);
videoTintBlood(nRed, nGreen, nBlue);
}
char otherMirrorGotpic[2];
@ -3102,6 +3101,20 @@ void viewDrawScreen(bool sceneonly)
}
if (gViewMode == 3 || gOverlayMap)
{
int basepal = 0;
if (powerupCheck(gView, kPwUpDeathMask) > 0) basepal = 4;
else if (powerupCheck(gView, kPwUpReflectShots) > 0) basepal = 1;
else if (gView->isUnderwater) {
if (gView->nWaterPal) basepal = gView->nWaterPal;
else {
if (gView->pXSprite->medium == kMediumWater) basepal = 1;
else if (gView->pXSprite->medium == kMediumGoo) basepal = 3;
else basepal = 2;
}
}
UpdateDacs(basepal);
UpdateBlend();
int yxAspect = yxaspect;
int viewingRange = viewingrange;
if (r_usenewaspect)
@ -3443,12 +3456,11 @@ void viewDrawScreen(bool sceneonly)
}
#endif
PspTwoDSetter p2set;
if (gViewPos == 0)
{
if (cl_crosshair)
{
rotatesprite(160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, 0, 2, gViewX0, gViewY0, gViewX1, gViewY1);
twod_rotatesprite(&twodpsp, 160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, 0, 2, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1);
}
cX = (v4c >> 8) + 160;
cY = (v48 >> 8) + 220 + (zDelta >> 7);
@ -3461,14 +3473,14 @@ void viewDrawScreen(bool sceneonly)
}
#ifdef NOONE_EXTENSIONS
if (gView->sceneQav < 0) WeaponDraw(gView, nShade, cX, cY, nPalette);
else if (gView->pXSprite->health > 0) playerQavSceneDraw(gView, nShade, cX, cY, nPalette);
if (gView->sceneQav < 0) WeaponDraw(gView, nShade, cX, cY, nPalette, basepal);
else if (gView->pXSprite->health > 0) playerQavSceneDraw(gView, nShade, cX, cY, nPalette, basepal);
else {
gView->sceneQav = gView->weaponQav = -1;
gView->weaponTimer = gView->curWeapon = 0;
}
#else
WeaponDraw(gView, nShade, cX, cY, nPalette);
WeaponDraw(gView, nShade, cX, cY, nPalette, curbasepal);
#endif
@ -3480,22 +3492,22 @@ void viewDrawScreen(bool sceneonly)
}
if (packItemActive(gView, 1))
{
rotatesprite(0, 0, 65536, 0, 2344, 0, 0, 256 + 18, gViewX0, gViewY0, gViewX1, gViewY1);
rotatesprite(320 << 16, 0, 65536, 1024, 2344, 0, 0, 512 + 22, gViewX0, gViewY0, gViewX1, gViewY1);
rotatesprite(0, 200 << 16, 65536, 0, 2344, 0, 0, 256 + 22, gViewX0, gViewY0, gViewX1, gViewY1);
rotatesprite(320 << 16, 200 << 16, 65536, 1024, 2344, 0, 0, 512 + 18, gViewX0, gViewY0, gViewX1, gViewY1);
twod_rotatesprite(&twodpsp, 0, 0, 65536, 0, 2344, 0, 0, 256 + 18, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1, nullptr, basepal);
twod_rotatesprite(&twodpsp, 320 << 16, 0, 65536, 1024, 2344, 0, 0, 512 + 22, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1, nullptr, basepal);
twod_rotatesprite(&twodpsp, 0, 200 << 16, 65536, 0, 2344, 0, 0, 256 + 22, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1, nullptr, basepal);
twod_rotatesprite(&twodpsp, 320 << 16, 200 << 16, 65536, 1024, 2344, 0, 0, 512 + 18, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1, nullptr, basepal);
if (gDetail >= 4)
{
rotatesprite(15 << 16, 3 << 16, 65536, 0, 2346, 32, 0, 256 + 19, gViewX0, gViewY0, gViewX1, gViewY1);
rotatesprite(212 << 16, 77 << 16, 65536, 0, 2347, 32, 0, 512 + 19, gViewX0, gViewY0, gViewX1, gViewY1);
twod_rotatesprite(&twodpsp, 15 << 16, 3 << 16, 65536, 0, 2346, 32, 0, 256 + 19, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1, nullptr, basepal);
twod_rotatesprite(&twodpsp, 212 << 16, 77 << 16, 65536, 0, 2347, 32, 0, 512 + 19, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1, nullptr, basepal);
}
}
if (powerupCheck(gView, kPwUpAsbestArmor) > 0)
{
rotatesprite(0, 200 << 16, 65536, 0, 2358, 0, 0, 256 + 22, gViewX0, gViewY0, gViewX1, gViewY1);
rotatesprite(320 << 16, 200 << 16, 65536, 1024, 2358, 0, 0, 512 + 18, gViewX0, gViewY0, gViewX1, gViewY1);
twod_rotatesprite(&twodpsp, 0, 200 << 16, 65536, 0, 2358, 0, 0, 256 + 22, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1, nullptr, basepal);
twod_rotatesprite(&twodpsp, 320 << 16, 200 << 16, 65536, 1024, 2358, 0, 0, 512 + 18, 0, 0, gViewX0, gViewY0, gViewX1, gViewY1, nullptr, basepal);
}
p2set.clear();
if (v4 && gNetPlayers > 1)
{
DoLensEffect();
@ -3506,18 +3518,8 @@ void viewDrawScreen(bool sceneonly)
rotatesprite(280 << 16, 35 << 16, 53248, 0, 1683, v10, 0, 512 + 35, gViewX0, gViewY0, gViewX1, gViewY1);
renderSetAspect(viewingRange, yxAspect);
}
if (powerupCheck(gView, kPwUpDeathMask) > 0) nPalette = 4;
else if (powerupCheck(gView, kPwUpReflectShots) > 0) nPalette = 1;
else if (gView->isUnderwater) {
if (gView->nWaterPal) nPalette = gView->nWaterPal;
else {
if (gView->pXSprite->medium == kMediumWater) nPalette = 1;
else if (gView->pXSprite->medium == kMediumGoo) nPalette = 3;
else nPalette = 2;
}
}
}
UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays.
if (gViewMode == 4)
{
gViewMap.sub_25DB0(gView->pSprite);
@ -3528,7 +3530,7 @@ void viewDrawScreen(bool sceneonly)
if (IsPlayerSprite(gMe->pSprite) && pPSprite->hand == 1)
{
//static int lastClock;
gChoke.sub_84110(160, zn);
gChoke.sub_84110(160, zn, 0);
//if ((gGameClock % 5) == 0 && gGameClock != lastClock)
//{
// gChoke.swayV(pPSprite);
@ -3561,7 +3563,6 @@ void viewDrawScreen(bool sceneonly)
{
RestoreInterpolations();
}
UpdateDacs(nPalette);
}
bool GameInterface::GenerateSavePic()
@ -3637,7 +3638,6 @@ void viewLoadingScreenUpdate(const char *pzText4, int nPercent)
void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const char *pText3)
{
UpdateDacs(0, true);
nLoadingScreenTile = nTile;
if (pText)
strncpy(pzLoadingScreenText1, pText, 256);

View file

@ -232,7 +232,7 @@ void WeaponPrecache(void)
}
}
void WeaponDraw(PLAYER *pPlayer, int a2, int a3, int a4, int a5)
void WeaponDraw(PLAYER *pPlayer, int a2, int a3, int a4, int a5, int basepal)
{
dassert(pPlayer != NULL);
if (pPlayer->weaponQav == -1)
@ -252,7 +252,7 @@ void WeaponDraw(PLAYER *pPlayer, int a2, int a3, int a4, int a5)
a2 = -128;
flags |= 1;
}
pQAV->Draw(v4, flags, a2, a5);
pQAV->Draw(&twodpsp, v4, flags, a2, a5, basepal, true);
}
void WeaponPlay(PLAYER *pPlayer)

View file

@ -2990,14 +2990,12 @@ void videoNextPage(void)
videoShowFrame(0);
}
#ifdef USE_OPENGL
omdtims = mdtims;
mdtims = timerGetTicks();
for (native_t i = 0; i < MAXSPRITES + MAXUNIQHUDID; ++i)
if ((mdpause && spriteext[i].mdanimtims) || (spriteext[i].flags & SPREXT_NOMDANIM))
spriteext[i].mdanimtims += mdtims - omdtims;
#endif
beforedrawrooms = 1;
numframes++;