SCUMM: Fix MM NES palette and colors

Also adds an optional more natural palette as a game option
This commit is contained in:
mataniko 2020-05-02 13:31:43 -04:00 committed by Eugene Sandulenko
parent 217884d873
commit e85e6cf846
5 changed files with 86 additions and 35 deletions

View file

@ -2859,6 +2859,9 @@ void ScummEngine::actorTalk(const byte *msg) {
} }
if (_game.heversion >= 72 || getTalkingActor() > 0x7F) { if (_game.heversion >= 72 || getTalkingActor() > 0x7F) {
if (_game.platform == Common::kPlatformNES)
_charsetColor = 0; // NES MM intro color is always 0
else
_charsetColor = (byte)_string[0].color; _charsetColor = (byte)_string[0].color;
} else if (_game.platform == Common::kPlatformNES) { } else if (_game.platform == Common::kPlatformNES) {
if (_NES_lastTalkingActor != getTalkingActor()) if (_NES_lastTalkingActor != getTalkingActor())

View file

@ -1372,11 +1372,21 @@ static const ExtraGuiOption comiObjectLabelsOption = {
true true
}; };
static const ExtraGuiOption mmnesObjectLabelsOption = {
_s("Use NES Classic Palette"),
_s("Use a more neutral color palette that closely emulates the NES Classic"),
"mm_nes_classic_palette",
false
};
const ExtraGuiOptions ScummMetaEngine::getExtraGuiOptions(const Common::String &target) const { const ExtraGuiOptions ScummMetaEngine::getExtraGuiOptions(const Common::String &target) const {
ExtraGuiOptions options; ExtraGuiOptions options;
if (target.empty() || ConfMan.get("gameid", target) == "comi") { if (target.empty() || ConfMan.get("gameid", target) == "comi") {
options.push_back(comiObjectLabelsOption); options.push_back(comiObjectLabelsOption);
} }
if (target.empty() || Common::parsePlatform(ConfMan.get("platform", target)) == Common::kPlatformNES) {
options.push_back(mmnesObjectLabelsOption);
}
return options; return options;
} }

View file

@ -423,6 +423,9 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int
_res->createResource(rtBuffer, slot + 1, size); _res->createResource(rtBuffer, slot + 1, size);
vs->setPixels(getResourceAddress(rtBuffer, slot + 1)); vs->setPixels(getResourceAddress(rtBuffer, slot + 1));
if (_game.platform == Common::kPlatformNES)
memset(vs->getBasePtr(0, 0), 0x1d, size); // reset background (MM NES)
else
memset(vs->getBasePtr(0, 0), 0, size); // reset background memset(vs->getBasePtr(0, 0), 0, size); // reset background
if (twobufs) { if (twobufs) {
@ -1036,6 +1039,11 @@ void ScummEngine::restoreBackground(Common::Rect rect, byte backColor) {
backColor = _roomPalette[backColor]; backColor = _roomPalette[backColor];
} }
// MM NES background color is 0x1d
if (_game.platform == Common::kPlatformNES) {
backColor = 0x1d;
}
// Convert 'rect' to local (virtual screen) coordinates // Convert 'rect' to local (virtual screen) coordinates
rect.top -= vs->topline; rect.top -= vs->topline;
rect.bottom -= vs->topline; rect.bottom -= vs->topline;
@ -1116,6 +1124,9 @@ void ScummEngine::restoreCharsetBg() {
} }
} else { } else {
// Clear area // Clear area
if (_game.platform == Common::kPlatformNES)
memset(screenBuf, 0x1d, vs->h * vs->pitch);
else
memset(screenBuf, 0, vs->h * vs->pitch); memset(screenBuf, 0, vs->h * vs->pitch);
} }
@ -2562,10 +2573,6 @@ void ScummEngine::NES_loadCostumeSet(int n) {
byte *palette = getResourceAddress(rtCostume, v1MMNEScostTables[n][5]) + 2; byte *palette = getResourceAddress(rtCostume, v1MMNEScostTables[n][5]) + 2;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
byte c = *palette++; byte c = *palette++;
if (c == 0x1D) // HACK - switch around colors 0x00 and 0x1D
c = 0; // so we don't need a zillion extra checks
else if (c == 0)// for determining the proper background color
c = 0x1D;
_NESPalette[1][i] = c; _NESPalette[1][i] = c;
} }
@ -2588,14 +2595,6 @@ void GdiNES::decodeNESGfx(const byte *room) {
decodeNESTileData(_vm->getResourceAddress(rtCostume, 37 + tileset), _vm->_NESPatTable[1] + _vm->_NESBaseTiles * 16); decodeNESTileData(_vm->getResourceAddress(rtCostume, 37 + tileset), _vm->_NESPatTable[1] + _vm->_NESBaseTiles * 16);
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
byte c = *gdata++; byte c = *gdata++;
if (c == 0x0D)
c = 0x1D;
if (c == 0x1D) // HACK - switch around colors 0x00 and 0x1D
c = 0; // so we don't need a zillion extra checks
else if (c == 0) // for determining the proper background color
c = 0x1D;
_vm->_NESPalette[0][i] = c; _vm->_NESPalette[0][i] = c;
} }
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
@ -3817,6 +3816,9 @@ void ScummEngine::fadeOut(int effect) {
// when bypassed of FT and TheDig. // when bypassed of FT and TheDig.
if ((_game.version == 7 || _screenEffectFlag) && effect != 0) { if ((_game.version == 7 || _screenEffectFlag) && effect != 0) {
// Fill screen 0 with black // Fill screen 0 with black
if (_game.platform == Common::kPlatformNES)
memset(vs->getPixels(0, 0), 0x1d, vs->pitch * vs->h);
else
memset(vs->getPixels(0, 0), 0, vs->pitch * vs->h); memset(vs->getPixels(0, 0), 0, vs->pitch * vs->h);
// Fade to black with the specified effect, if any. // Fade to black with the specified effect, if any.

View file

@ -20,6 +20,7 @@
* *
*/ */
#include "common/config-manager.h"
#include "common/system.h" #include "common/system.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "common/util.h" #include "common/util.h"
@ -71,26 +72,55 @@ void ScummEngine::resetPalette() {
0x7F, 0x3B, 0xA6 0x7F, 0x3B, 0xA6
}; };
static const byte tableNESPalette[] = { /** This is Mesen's NTSC palette and the new default palette for ScummVM.
0x00, 0x00, 0x00, 0x00, 0x23, 0x8C, 0x00, 0x13, 0x9B, 0x2D, 0x05, 0x85, * It was chosen due to the accuracy of Mesen when it comes to emulating a NES
0x5D, 0x00, 0x52, 0x7A, 0x00, 0x17, 0x7A, 0x08, 0x00, 0x5F, 0x18, 0x00, */
0x35, 0x2A, 0x00, 0x09, 0x39, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3C, 0x22, static const byte tableNESNTSCPalette[] = {
0x00, 0x32, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x2A, 0x88, 0x14, 0x12, 0xA7, 0x3B, 0x00, 0xA4,
0x5C, 0x00, 0x7E, 0x6E, 0x00, 0x40, 0x6C, 0x06, 0x00, 0x56, 0x1D, 0x00,
0x33, 0x35, 0x00, 0x0B, 0x48, 0x00, 0x00, 0x52, 0x00, 0x00, 0x4F, 0x08,
0x00, 0x40, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xA1, 0xA1, 0xA1, 0x00, 0x53, 0xEE, 0x15, 0x3C, 0xFE, 0x60, 0x28, 0xE4, 0xAD, 0xAD, 0xAD, 0x15, 0x5F, 0xD9, 0x42, 0x40, 0xFF, 0x75, 0x27, 0xFE,
0xA9, 0x1D, 0x98, 0xD4, 0x1E, 0x41, 0xD2, 0x2C, 0x00, 0xAA, 0x44, 0x00, 0xA0, 0x1A, 0xCC, 0xB7, 0x1E, 0x7B, 0xB5, 0x31, 0x20, 0x99, 0x4E, 0x00,
0x6C, 0x5E, 0x00, 0x2D, 0x73, 0x00, 0x00, 0x7D, 0x06, 0x00, 0x78, 0x52, 0x6B, 0x6D, 0x00, 0x38, 0x87, 0x00, 0x0C, 0x93, 0x00, 0x00, 0x8F, 0x32,
0x00, 0x69, 0xA9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x8D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0x1F, 0xA5, 0xFE, 0x5E, 0x89, 0xFE, 0xB5, 0x72, 0xFE, 0xFF, 0xFE, 0xFF, 0x64, 0xB0, 0xFF, 0x92, 0x90, 0xFF, 0xC6, 0x76, 0xFF,
0xFE, 0x65, 0xF6, 0xFE, 0x67, 0x90, 0xFE, 0x77, 0x3C, 0xFE, 0x93, 0x08, 0xF3, 0x6A, 0xFF, 0xFE, 0x6E, 0xCC, 0xFE, 0x81, 0x70, 0xEA, 0x9E, 0x22,
0xC4, 0xB2, 0x00, 0x79, 0xCA, 0x10, 0x3A, 0xD5, 0x4A, 0x11, 0xD1, 0xA4, 0xBC, 0xBE, 0x00, 0x88, 0xD8, 0x00, 0x5C, 0xE4, 0x30, 0x45, 0xE0, 0x82,
0x06, 0xBF, 0xFE, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xCD, 0xDE, 0x4F, 0x4F, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xA0, 0xD9, 0xFE, 0xBD, 0xCC, 0xFE, 0xE1, 0xC2, 0xFE, 0xFF, 0xFE, 0xFF, 0xC0, 0xDF, 0xFF, 0xD3, 0xD2, 0xFF, 0xE8, 0xC8, 0xFF,
0xFE, 0xBC, 0xFB, 0xFE, 0xBD, 0xD0, 0xFE, 0xC5, 0xA9, 0xFE, 0xD1, 0x8E, 0xFB, 0xC2, 0xFF, 0xFE, 0xC4, 0xEA, 0xFE, 0xCC, 0xC5, 0xF7, 0xD8, 0xA5,
0xE9, 0xDE, 0x86, 0xC7, 0xE9, 0x92, 0xA8, 0xEE, 0xB0, 0x95, 0xEC, 0xD9, 0xE4, 0xE5, 0x94, 0xCF, 0xEF, 0x96, 0xBD, 0xF4, 0xAB, 0xB3, 0xF3, 0xCC,
0x91, 0xE4, 0xFE, 0xAC, 0xAC, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0xB5, 0xEB, 0xF2, 0xB8, 0xB8, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/** This is an alternative palette based on FirebrandX's NES Classic
* palette. This palette is what Nintendo ships on the NES Classic which
* makes it somewhat of an "official" digital palette for the NES
*/
static const byte tableNESClassicPalette[] = {
0x60, 0x61, 0x5F, 0x00, 0x00, 0x83, 0x1D, 0x01, 0x95, 0x34, 0x08, 0x75,
0x51, 0x05, 0x5E, 0x56, 0x00, 0x0F, 0x4C, 0x07, 0x00, 0x37, 0x23, 0x08,
0x20, 0x3A, 0x0B, 0x0F, 0x4B, 0x0E, 0x19, 0x4C, 0x16, 0x02, 0x42, 0x1E,
0x02, 0x31, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xA9, 0xAA, 0xA8, 0x10, 0x4B, 0xBF, 0x47, 0x12, 0xD8, 0x63, 0x00, 0xCA,
0x88, 0x00, 0xA9, 0x93, 0x0B, 0x46, 0x8A, 0x2D, 0x04, 0x6F, 0x52, 0x06,
0x5C, 0x71, 0x14, 0x1B, 0x8D, 0x12, 0x19, 0x95, 0x09, 0x17, 0x84, 0x48,
0x20, 0x6B, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFB, 0xFB, 0xFB, 0x66, 0x99, 0xF8, 0x89, 0x74, 0xF9, 0xAB, 0x58, 0xF8,
0xD5, 0x57, 0xEF, 0xDE, 0x5F, 0xA9, 0xDC, 0x7F, 0x59, 0xC7, 0xA2, 0x24,
0xA7, 0xBE, 0x03, 0x75, 0xD7, 0x03, 0x60, 0xE3, 0x4F, 0x3C, 0xD6, 0x8D,
0x56, 0xC9, 0xCC, 0x41, 0x42, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFB, 0xFB, 0xFB, 0xBE, 0xD4, 0xFA, 0xC9, 0xC7, 0xF9, 0xD7, 0xBE, 0xFA,
0xE8, 0xB8, 0xF9, 0xF5, 0xBA, 0xE5, 0xF3, 0xCA, 0xC2, 0xDF, 0xCD, 0xA7,
0xD9, 0xE0, 0x9C, 0xC9, 0xEB, 0x9E, 0xC0, 0xED, 0xB8, 0xB5, 0xF4, 0xC7,
0xB9, 0xEA, 0xE9, 0xAB, 0xAB, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };
static const byte tableAmigaPalette[] = { static const byte tableAmigaPalette[] = {
@ -160,7 +190,10 @@ void ScummEngine::resetPalette() {
} else if (_game.platform == Common::kPlatformC64) { } else if (_game.platform == Common::kPlatformC64) {
setPaletteFromTable(tableC64Palette, sizeof(tableC64Palette) / 3); setPaletteFromTable(tableC64Palette, sizeof(tableC64Palette) / 3);
} else if (_game.platform == Common::kPlatformNES) { } else if (_game.platform == Common::kPlatformNES) {
setPaletteFromTable(tableNESPalette, sizeof(tableNESPalette) / 3); if (ConfMan.getBool("mm_nes_classic_palette"))
setPaletteFromTable(tableNESClassicPalette, sizeof(tableNESClassicPalette) / 3);
else
setPaletteFromTable(tableNESNTSCPalette, sizeof(tableNESNTSCPalette) / 3);
} else { } else {
setPaletteFromTable(tableV1Palette, sizeof(tableV1Palette) / 3); setPaletteFromTable(tableV1Palette, sizeof(tableV1Palette) / 3);
if (_game.id == GID_ZAK) if (_game.id == GID_ZAK)

View file

@ -1311,6 +1311,9 @@ Common::Error ScummEngine::init() {
return Common::Error(Common::kUnsupportedColorMode, "This game requires dual graphics layer support which is disabled in this build"); return Common::Error(Common::kUnsupportedColorMode, "This game requires dual graphics layer support which is disabled in this build");
#endif #endif
initGraphics(screenWidth, screenHeight); initGraphics(screenWidth, screenHeight);
if (_game.platform == Common::kPlatformNES)
_system->fillScreen(0x1d);
} }
} }