Skip to content

Commit

Permalink
Revert "SCI32: Fix broken Remap implementation"
Browse files Browse the repository at this point in the history
This reverts commit cfda8b9.

This is only to re-apply it immediately in a series of smaller commits.
  • Loading branch information
wjp committed Jun 30, 2016
1 parent a40e43f commit c6c9593
Show file tree
Hide file tree
Showing 18 changed files with 521 additions and 1,067 deletions.
16 changes: 8 additions & 8 deletions engines/sci/engine/kernel.h
Expand Up @@ -412,7 +412,7 @@ reg_t kPlatform(EngineState *s, int argc, reg_t *argv);
reg_t kTextColors(EngineState *s, int argc, reg_t *argv);
reg_t kTextFonts(EngineState *s, int argc, reg_t *argv);
reg_t kShow(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColors(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColors16(EngineState *s, int argc, reg_t *argv);
reg_t kDummy(EngineState *s, int argc, reg_t *argv);
reg_t kEmpty(EngineState *s, int argc, reg_t *argv);
reg_t kStub(EngineState *s, int argc, reg_t *argv);
Expand Down Expand Up @@ -482,13 +482,13 @@ reg_t kScrollWindowDestroy(EngineState *s, int argc, reg_t *argv);

reg_t kMulDiv(EngineState *s, int argc, reg_t *argv);

reg_t kRemapColors32(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColorsOff(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColorsByRange(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColorsByPercent(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColorsToGray(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColorsToPercentGray(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColorsBlockRange(EngineState *s, int argc, reg_t *argv);
reg_t kRemapColors(EngineState *s, int argc, reg_t *argv);
reg_t kRemapOff(EngineState *s, int argc, reg_t *argv);
reg_t kRemapByRange(EngineState *s, int argc, reg_t *argv);
reg_t kRemapByPercent(EngineState *s, int argc, reg_t *argv);
reg_t kRemapToGray(EngineState *s, int argc, reg_t *argv);
reg_t kRemapToPercentGray(EngineState *s, int argc, reg_t *argv);
reg_t kRemapSetNoMatchRange(EngineState *s, int argc, reg_t *argv);

reg_t kAddScreenItem(EngineState *s, int argc, reg_t *argv);
reg_t kUpdateScreenItem(EngineState *s, int argc, reg_t *argv);
Expand Down
16 changes: 8 additions & 8 deletions engines/sci/engine/kernel_tables.h
Expand Up @@ -414,12 +414,12 @@ static const SciKernelMapSubEntry kList_subops[] = {

// version, subId, function-mapping, signature, workarounds
static const SciKernelMapSubEntry kRemapColors_subops[] = {
{ SIG_SCI32, 0, MAP_CALL(RemapColorsOff), "(i)", NULL },
{ SIG_SCI32, 1, MAP_CALL(RemapColorsByRange), "iiii(i)", NULL },
{ SIG_SCI32, 2, MAP_CALL(RemapColorsByPercent), "ii(i)", NULL },
{ SIG_SCI32, 3, MAP_CALL(RemapColorsToGray), "ii(i)", NULL },
{ SIG_SCI32, 4, MAP_CALL(RemapColorsToPercentGray), "iii(i)", NULL },
{ SIG_SCI32, 5, MAP_CALL(RemapColorsBlockRange), "ii", NULL },
{ SIG_SCI32, 0, MAP_CALL(RemapOff), "(i)", NULL },
{ SIG_SCI32, 1, MAP_CALL(RemapByRange), "iiii(i)", NULL },
{ SIG_SCI32, 2, MAP_CALL(RemapByPercent), "ii(i)", NULL },
{ SIG_SCI32, 3, MAP_CALL(RemapToGray), "ii(i)", NULL },
{ SIG_SCI32, 4, MAP_CALL(RemapToPercentGray), "iii(i)", NULL },
{ SIG_SCI32, 5, MAP_CALL(RemapSetNoMatchRange), "ii", NULL },
SCI_SUBOPENTRY_TERMINATOR
};

Expand Down Expand Up @@ -634,9 +634,9 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(PriCoord), SIG_EVERYWHERE, "i", NULL, NULL },
{ MAP_CALL(Random), SIG_EVERYWHERE, "i(i)(i)", NULL, NULL },
{ MAP_CALL(ReadNumber), SIG_EVERYWHERE, "r", NULL, kReadNumber_workarounds },
{ MAP_CALL(RemapColors), SIG_SCI11, SIGFOR_ALL, "i(i)(i)(i)(i)", NULL, NULL },
{ "RemapColors", kRemapColors16, SIG_SCI11, SIGFOR_ALL, "i(i)(i)(i)(i)", NULL, NULL },
#ifdef ENABLE_SCI32
{ "RemapColors", kRemapColors32, SIG_SCI32, SIGFOR_ALL, "i(i)(i)(i)(i)(i)", kRemapColors_subops, NULL },
{ MAP_CALL(RemapColors), SIG_SCI32, SIGFOR_ALL, "i(i)(i)(i)(i)(i)", kRemapColors_subops, NULL },
#endif
{ MAP_CALL(ResCheck), SIG_EVERYWHERE, "ii(iiii)", NULL, NULL },
{ MAP_CALL(RespondsTo), SIG_EVERYWHERE, ".i", NULL, NULL },
Expand Down
2 changes: 1 addition & 1 deletion engines/sci/engine/kgraphics.cpp
Expand Up @@ -1258,7 +1258,7 @@ reg_t kShow(EngineState *s, int argc, reg_t *argv) {
}

// Early variant of the SCI32 kRemapColors kernel function, used in the demo of QFG4
reg_t kRemapColors(EngineState *s, int argc, reg_t *argv) {
reg_t kRemapColors16(EngineState *s, int argc, reg_t *argv) {
uint16 operation = argv[0].toUint16();

switch (operation) {
Expand Down
75 changes: 31 additions & 44 deletions engines/sci/engine/kgraphics32.cpp
Expand Up @@ -54,7 +54,6 @@
#include "sci/graphics/frameout.h"
#include "sci/graphics/paint32.h"
#include "sci/graphics/palette32.h"
#include "sci/graphics/remap32.h"
#include "sci/graphics/text32.h"
#endif

Expand Down Expand Up @@ -926,69 +925,57 @@ reg_t kPalCycle(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
}

reg_t kRemapColors32(EngineState *s, int argc, reg_t *argv) {
reg_t kRemapColors(EngineState *s, int argc, reg_t *argv) {
if (!s)
return make_reg(0, getSciVersion());
error("not supposed to call this");
}

reg_t kRemapColorsOff(EngineState *s, int argc, reg_t *argv) {
if (argc == 0) {
g_sci->_gfxRemap32->remapAllOff();
} else {
const uint8 color = argv[0].toUint16();
g_sci->_gfxRemap32->remapOff(color);
}
reg_t kRemapOff(EngineState *s, int argc, reg_t *argv) {
byte color = (argc >= 1) ? argv[0].toUint16() : 0;
g_sci->_gfxRemap32->remapOff(color);
return s->r_acc;
}

reg_t kRemapColorsByRange(EngineState *s, int argc, reg_t *argv) {
const uint8 color = argv[0].toUint16();
const int16 from = argv[1].toSint16();
const int16 to = argv[2].toSint16();
const int16 base = argv[3].toSint16();
// NOTE: There is an optional last parameter after `base`
// which was only used by the priority map debugger, which
// does not exist in release versions of SSCI
g_sci->_gfxRemap32->remapByRange(color, from, to, base);
reg_t kRemapByRange(EngineState *s, int argc, reg_t *argv) {
byte color = argv[0].toUint16();
byte from = argv[1].toUint16();
byte to = argv[2].toUint16();
byte base = argv[3].toUint16();
// The last parameter, depth, is unused
g_sci->_gfxRemap32->setRemappingRange(color, from, to, base);
return s->r_acc;
}

reg_t kRemapColorsByPercent(EngineState *s, int argc, reg_t *argv) {
const uint8 color = argv[0].toUint16();
const int16 percent = argv[1].toSint16();
// NOTE: There is an optional last parameter after `percent`
// which was only used by the priority map debugger, which
// does not exist in release versions of SSCI
g_sci->_gfxRemap32->remapByPercent(color, percent);
reg_t kRemapByPercent(EngineState *s, int argc, reg_t *argv) {
byte color = argv[0].toUint16();
byte percent = argv[1].toUint16();
// The last parameter, depth, is unused
g_sci->_gfxRemap32->setRemappingPercent(color, percent);
return s->r_acc;
}

reg_t kRemapColorsToGray(EngineState *s, int argc, reg_t *argv) {
const uint8 color = argv[0].toUint16();
const int16 gray = argv[1].toSint16();
// NOTE: There is an optional last parameter after `gray`
// which was only used by the priority map debugger, which
// does not exist in release versions of SSCI
g_sci->_gfxRemap32->remapToGray(color, gray);
reg_t kRemapToGray(EngineState *s, int argc, reg_t *argv) {
byte color = argv[0].toUint16();
byte gray = argv[1].toUint16();
// The last parameter, depth, is unused
g_sci->_gfxRemap32->setRemappingToGray(color, gray);
return s->r_acc;
}

reg_t kRemapColorsToPercentGray(EngineState *s, int argc, reg_t *argv) {
const uint8 color = argv[0].toUint16();
const int16 gray = argv[1].toSint16();
const int16 percent = argv[2].toSint16();
// NOTE: There is an optional last parameter after `percent`
// which was only used by the priority map debugger, which
// does not exist in release versions of SSCI
g_sci->_gfxRemap32->remapToPercentGray(color, gray, percent);
reg_t kRemapToPercentGray(EngineState *s, int argc, reg_t *argv) {
byte color = argv[0].toUint16();
byte gray = argv[1].toUint16();
byte percent = argv[2].toUint16();
// The last parameter, depth, is unused
g_sci->_gfxRemap32->setRemappingToPercentGray(color, gray, percent);
return s->r_acc;
}

reg_t kRemapColorsBlockRange(EngineState *s, int argc, reg_t *argv) {
const uint8 from = argv[0].toUint16();
const uint8 count = argv[1].toUint16();
g_sci->_gfxRemap32->blockRange(from, count);
reg_t kRemapSetNoMatchRange(EngineState *s, int argc, reg_t *argv) {
byte from = argv[0].toUint16();
byte count = argv[1].toUint16();
g_sci->_gfxRemap32->setNoMatchRange(from, count);
return s->r_acc;
}

Expand Down
30 changes: 1 addition & 29 deletions engines/sci/engine/savegame.cpp
Expand Up @@ -48,9 +48,8 @@
#include "sci/sound/music.h"

#ifdef ENABLE_SCI32
#include "sci/graphics/frameout.h"
#include "sci/graphics/palette32.h"
#include "sci/graphics/remap32.h"
#include "sci/graphics/frameout.h"
#endif

namespace Sci {
Expand Down Expand Up @@ -808,33 +807,6 @@ void GfxPalette32::saveLoadWithSerializer(Common::Serializer &s) {
}
}
}

void GfxRemap32::saveLoadWithSerializer(Common::Serializer &s) {
if (s.getVersion() < 35) {
return;
}

s.syncAsByte(_numActiveRemaps);
s.syncAsByte(_blockedRangeStart);
s.syncAsSint16LE(_blockedRangeCount);

for (uint i = 0; i < _remaps.size(); ++i) {
SingleRemap &singleRemap = _remaps[i];
s.syncAsByte(singleRemap._type);
if (s.isLoading() && singleRemap._type != kRemapNone) {
singleRemap.reset();
}
s.syncAsByte(singleRemap._from);
s.syncAsByte(singleRemap._to);
s.syncAsByte(singleRemap._delta);
s.syncAsByte(singleRemap._percent);
s.syncAsByte(singleRemap._gray);
}

if (s.isLoading()) {
_needsUpdate = true;
}
}
#endif

void GfxPorts::saveLoadWithSerializer(Common::Serializer &s) {
Expand Down
3 changes: 1 addition & 2 deletions engines/sci/engine/savegame.h
Expand Up @@ -37,7 +37,6 @@ struct EngineState;
*
* Version - new/changed feature
* =============================
* 35 - SCI32 remap
* 34 - SCI32 palettes, and store play time in ticks
* 33 - new overridePriority flag in MusicEntry
* 32 - new playBed flag in MusicEntry
Expand All @@ -60,7 +59,7 @@ struct EngineState;
*/

enum {
CURRENT_SAVEGAME_VERSION = 35,
CURRENT_SAVEGAME_VERSION = 34,
MINIMUM_SAVEGAME_VERSION = 14
};

Expand Down

0 comments on commit c6c9593

Please sign in to comment.