TWINE: added debug commands to toggle the dark palette mode

This commit is contained in:
Martin Gerhardy 2021-12-29 14:29:45 +01:00
parent 41bb954435
commit 593b7d068d
5 changed files with 45 additions and 13 deletions

View File

@ -29,6 +29,7 @@
#include "twine/resources/hqr.h"
#include "twine/scene/gamestate.h"
#include "twine/scene/scene.h"
#include "twine/renderer/screens.h"
#include "twine/text.h"
#include "twine/twine.h"
#include "twine/audio/music.h"
@ -50,6 +51,7 @@ TwinEConsole::TwinEConsole(TwinEEngine *engine) : _engine(engine), GUI::Debugger
registerCmd("dumpfile", WRAP_METHOD(TwinEConsole, doDumpFile));
registerCmd("list_menutext", WRAP_METHOD(TwinEConsole, doListMenuText));
registerCmd("toggle_debug", WRAP_METHOD(TwinEConsole, doToggleDebug));
registerCmd("toggle_darkpal", WRAP_METHOD(TwinEConsole, doToggleDarkPal));
registerCmd("toggle_zones", WRAP_METHOD(TwinEConsole, doToggleZoneRendering));
registerCmd("toggle_tracks", WRAP_METHOD(TwinEConsole, doToggleTrackRendering));
registerCmd("toggle_godmode", WRAP_METHOD(TwinEConsole, doToggleGodMode));
@ -303,6 +305,17 @@ bool TwinEConsole::doGiveKashes(int argc, const char **argv) {
return true;
}
bool TwinEConsole::doToggleDarkPal(int argc, const char **argv) {
if (_engine->_screens->_useAlternatePalette) {
debugPrintf("Disabling dark palette\n");
_engine->_screens->setNormalPal();
} else {
debugPrintf("Enabling dark palette\n");
_engine->_screens->setDarkPal();
}
return true;
}
bool TwinEConsole::doToggleDebug(int argc, const char **argv) {
if (_engine->_cfgfile.Debug) {
debugPrintf("Disabling debug mode\n");

View File

@ -47,6 +47,7 @@ private:
bool doChangeScene(int argc, const char **argv);
bool doListMenuText(int argc, const char **argv);
bool doToggleDebug(int argc, const char **argv);
bool doToggleDarkPal(int argc, const char **argv);
bool doToggleAutoAggressive(int argc, const char **argv);
bool doGiveKey(int argc, const char **argv);
bool doGiveGas(int argc, const char **argv);

View File

@ -217,6 +217,25 @@ void Screens::blackToWhite() {
}
}
void Screens::setDarkPal() {
ScopedEngineFreeze scoped(_engine);
HQR::getEntry(_palette, Resources::HQR_RESS_FILE, RESSHQR_DARKPAL);
convertPalToRGBA(_palette, _paletteRGBA);
if (!_fadePalette) {
// set the palette hard if it should not get faded
_engine->setPalette(_paletteRGBA);
}
_useAlternatePalette = true;
}
void Screens::setNormalPal() {
_useAlternatePalette = false;
if (!_fadePalette) {
// reset the palette hard if it should not get faded
_engine->setPalette(_mainPaletteRGBA);
}
}
void Screens::setBackPal() {
memset(_palette, 0, sizeof(_palette));
memset(_paletteRGBA, 0, sizeof(_paletteRGBA));

View File

@ -73,6 +73,16 @@ public:
void convertPalToRGBA(const uint8 *in, uint32 *out);
/**
* @sa setNormalPal
*/
void setDarkPal();
/**
* @sa setDarkPal()
* Reset the palette to the main palette after the script changed it via @c setDarkPal()
*/
void setNormalPal();
/**
* Load a custom palette
* @param index \a RESS.HQR entry index (starting from 0)

View File

@ -1546,14 +1546,7 @@ static int32 lASK_CHOICE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
* @note Opcode @c 0x5C
*/
static int32 lSET_DARK_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
ScopedEngineFreeze scoped(engine);
HQR::getEntry(engine->_screens->_palette, Resources::HQR_RESS_FILE, RESSHQR_DARKPAL);
engine->_screens->convertPalToRGBA(engine->_screens->_palette, engine->_screens->_paletteRGBA);
if (!engine->_screens->_fadePalette) {
// set the palette hard if it should not get faded
engine->setPalette(engine->_screens->_paletteRGBA);
}
engine->_screens->_useAlternatePalette = true;
engine->_screens->setDarkPal();
return 0;
}
@ -1562,11 +1555,7 @@ static int32 lSET_DARK_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
* @note Opcode @c 0x5D
*/
static int32 lSET_NORMAL_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_screens->_useAlternatePalette = false;
if (!engine->_screens->_fadePalette) {
// reset the palette hard if it should not get faded
engine->setPalette(engine->_screens->_mainPaletteRGBA);
}
engine->_screens->setNormalPal();
return 0;
}