mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 05:32:45 +00:00
DRAGONS: Added palette cycling logic
This commit is contained in:
parent
894e0d99df
commit
40a13a853e
@ -92,6 +92,7 @@ DragonsEngine::DragonsEngine(OSystem *syst) : Engine(syst) {
|
||||
_pKeyDown = false;
|
||||
|
||||
_debugMode = false;
|
||||
_isGamePaused = false;
|
||||
|
||||
reset();
|
||||
}
|
||||
@ -671,6 +672,7 @@ void DragonsEngine::updateHandler() {
|
||||
}
|
||||
|
||||
// TODO 0x8001bed0
|
||||
updatePaletteCycling();
|
||||
|
||||
// 0x8001c294
|
||||
if (!(_unkFlags1 & ENGINE_UNK1_FLAG_8)) {
|
||||
@ -1294,11 +1296,11 @@ void DragonsEngine::reset() {
|
||||
data_800633fa = 0;
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
opCode1A_tbl[i].paletteType = 0;
|
||||
opCode1A_tbl[i].field2 = 0;
|
||||
opCode1A_tbl[i].field4 = 0;
|
||||
opCode1A_tbl[i].field6 = 0;
|
||||
opCode1A_tbl[i].field8 = 0;
|
||||
_paletteCyclingTbl[i].paletteType = 0;
|
||||
_paletteCyclingTbl[i].startOffset = 0;
|
||||
_paletteCyclingTbl[i].endOffset = 0;
|
||||
_paletteCyclingTbl[i].updateInterval = 0;
|
||||
_paletteCyclingTbl[i].updateCounter = 0;
|
||||
}
|
||||
|
||||
setSceneUpdateFunction(NULL);
|
||||
@ -1401,6 +1403,52 @@ void DragonsEngine::loadCurrentSceneMsf() {
|
||||
_sound->loadMsf(getCurrentSceneId());
|
||||
}
|
||||
|
||||
void DragonsEngine::updatePaletteCycling() {
|
||||
if (!_isGamePaused) {
|
||||
for (int loopIndex = 0; loopIndex < 8 ; loopIndex++) {
|
||||
if (_paletteCyclingTbl[loopIndex].updateInterval != 0) {
|
||||
if (_paletteCyclingTbl[loopIndex].updateCounter == 0) {
|
||||
uint16 *palette = (uint16 *)_screen->getPalette(_paletteCyclingTbl[loopIndex].paletteType);
|
||||
int16 uVar14 = (uint)(ushort)_paletteCyclingTbl[loopIndex].startOffset;
|
||||
int16 uVar8 = (uint)(ushort)_paletteCyclingTbl[loopIndex].endOffset;
|
||||
if (uVar14 < uVar8) {
|
||||
uint16 uVar11 = palette[uVar8];
|
||||
int uVar15 = uVar8;
|
||||
if (uVar14 < uVar8) {
|
||||
do {
|
||||
uVar8--;
|
||||
palette[uVar15] = palette[uVar15 - 1];
|
||||
uVar15 = uVar8 & 0xffff;
|
||||
} while ((uint)(ushort)_paletteCyclingTbl[loopIndex].startOffset < (uVar8 & 0xffff));
|
||||
}
|
||||
palette[(ushort)_paletteCyclingTbl[loopIndex].startOffset] = uVar11;
|
||||
_paletteCyclingTbl[loopIndex].updateCounter = _paletteCyclingTbl[loopIndex].updateInterval;
|
||||
}
|
||||
else {
|
||||
if (uVar8 < uVar14) {
|
||||
uint16 uVar11 = palette[uVar14];
|
||||
uint16 uVar15 = uVar8;
|
||||
if (uVar8 < uVar14) {
|
||||
do {
|
||||
uVar8--;
|
||||
palette[uVar15] = palette[uVar15 + 1];
|
||||
uVar15 = uVar8 & 0xffff;
|
||||
} while ((uVar8 & 0xffff) < (uint)(ushort)_paletteCyclingTbl[loopIndex].startOffset);
|
||||
}
|
||||
palette[(ushort)_paletteCyclingTbl[loopIndex].endOffset] = uVar11;
|
||||
_paletteCyclingTbl[loopIndex].updateCounter =
|
||||
_paletteCyclingTbl[loopIndex].updateInterval;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
_paletteCyclingTbl[loopIndex].updateCounter = _paletteCyclingTbl[loopIndex].updateCounter + -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void (*DragonsEngine::getSceneUpdateFunction())() {
|
||||
return _sceneUpdateFunction;
|
||||
}
|
||||
|
@ -96,12 +96,12 @@ enum UnkFlags {
|
||||
ENGINE_UNK1_FLAG_80 = 0x80
|
||||
};
|
||||
|
||||
struct opCode1AStruct {
|
||||
struct PaletteCyclingInstruction {
|
||||
int16 paletteType;
|
||||
int16 field2;
|
||||
int16 field4;
|
||||
int16 field6;
|
||||
int16 field8;
|
||||
int16 startOffset;
|
||||
int16 endOffset;
|
||||
int16 updateInterval;
|
||||
int16 updateCounter;
|
||||
};
|
||||
|
||||
class BigfileArchive;
|
||||
@ -143,7 +143,7 @@ public:
|
||||
Talk *_talk;
|
||||
SoundManager *_sound;
|
||||
|
||||
opCode1AStruct opCode1A_tbl[8];
|
||||
PaletteCyclingInstruction _paletteCyclingTbl[8];
|
||||
|
||||
uint16 data_800633fc;
|
||||
uint16 videoFlags; // TODO move to screen?
|
||||
@ -191,6 +191,7 @@ private:
|
||||
bool _pKeyDown;
|
||||
|
||||
bool _debugMode;
|
||||
bool _isGamePaused;
|
||||
|
||||
void (*_sceneUpdateFunction)();
|
||||
void (*_vsyncUpdateFunction)();
|
||||
@ -283,6 +284,7 @@ private:
|
||||
void gameLoop();
|
||||
void updateHandler();
|
||||
void updatePathfindingActors();
|
||||
void updatePaletteCycling();
|
||||
uint32 calulateTimeLeft();
|
||||
void wait();
|
||||
uint16 getIniFromImg();
|
||||
|
@ -51,7 +51,7 @@ void Scene::loadScene(uint32 sceneId, uint32 cameraPointId) {
|
||||
_vm->setUnkFlags(ENGINE_UNK1_FLAG_2);
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
_vm->opCode1A_tbl[i].field6 = 0;
|
||||
_vm->_paletteCyclingTbl[i].updateInterval = 0;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
@ -1102,11 +1102,11 @@ void ScriptOpcodes::opUnk1A(ScriptOpCall &scriptOpCall) {
|
||||
|
||||
assert(index < 8);
|
||||
|
||||
_vm->opCode1A_tbl[index].paletteType = field4;
|
||||
_vm->opCode1A_tbl[index].field2 = field6;
|
||||
_vm->opCode1A_tbl[index].field4 = field8;
|
||||
_vm->opCode1A_tbl[index].field6 = fieldA;
|
||||
_vm->opCode1A_tbl[index].field8 = 0;
|
||||
_vm->_paletteCyclingTbl[index].paletteType = field4;
|
||||
_vm->_paletteCyclingTbl[index].startOffset = field6;
|
||||
_vm->_paletteCyclingTbl[index].endOffset = field8;
|
||||
_vm->_paletteCyclingTbl[index].updateInterval = fieldA;
|
||||
_vm->_paletteCyclingTbl[index].updateCounter = 0;
|
||||
}
|
||||
|
||||
void ScriptOpcodes::opUnk1B(ScriptOpCall &scriptOpCall) {
|
||||
|
@ -941,26 +941,8 @@ void SpecialOpcodes::spcResetInventorySequence() {
|
||||
}
|
||||
|
||||
void SpecialOpcodes::spcUnk65ScenePaletteRelated() {
|
||||
byte *palette = _vm->_scene->getPalette();
|
||||
byte *palette = _vm->_screen->getPalette(0);
|
||||
memset(palette + 0xb1 * 2, 0, 32); //zero out 16 palette records from index 0xb1 to 0xc0
|
||||
//TODO Check above logic works. triggers on dodo under attack scene.
|
||||
// uint uVar1;
|
||||
// ushort uVar2;
|
||||
// RECT local_10;
|
||||
//
|
||||
// uVar2 = 0xb1;
|
||||
// local_10.y = 0xf1;
|
||||
// local_10.w = 0x100;
|
||||
// local_10.x = 0;
|
||||
// local_10.h = 1;
|
||||
// uVar1 = 0xb1;
|
||||
// do {
|
||||
// uVar2 = uVar2 + 1;
|
||||
// *(undefined2 *)(uVar1 * 2 + scrFileData_maybe) = 0;
|
||||
// uVar1 = (uint)uVar2;
|
||||
// } while (uVar2 < 0xc0);
|
||||
// LoadImage(&local_10,&palette_data);
|
||||
// DrawSync(0);
|
||||
}
|
||||
|
||||
void SpecialOpcodes::spcUnk66() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user