DRAGONS: Fixed bug while evaluating script expressions. expression

operands are signed.
This commit is contained in:
Eric Fry 2019-11-23 08:49:33 +11:00 committed by Eugene Sandulenko
parent c836646b69
commit 88b0e2cff5
4 changed files with 16 additions and 13 deletions

View File

@ -824,18 +824,20 @@ uint16 DragonsEngine::getIniFromImg() {
}
void DragonsEngine::runINIScripts() {
bool isFlag8Set = isFlagSet(ENGINE_FLAG_8);
for (uint16 i = 0; i < _dragonINIResource->totalRecords(); i++) {
DragonINI *ini = getINI(i);
if (ini->field_1a_flags_maybe & Dragons::INI_FLAG_10) {
ini->field_1a_flags_maybe &= ~Dragons::INI_FLAG_10;
byte *data = _dragonOBD->getFromOpt(i);
ScriptOpCall scriptOpCall(data + 8, READ_LE_UINT32(data));
uint32 currentFlags = _flags;
clearFlags(Dragons::ENGINE_FLAG_8);
_scriptOpcodes->runScript3(scriptOpCall);
_flags = currentFlags;
}
}
if (isFlag8Set) {
setFlags(ENGINE_FLAG_8);
}
}
/*
void DragonsEngine::engineFlag0x20UpdateFunction() {
@ -911,6 +913,7 @@ void DragonsEngine::engineFlag0x20UpdateFunction() {
return (uint)run_func_ptr_unk_countdown_timer;
} */
//TODO the logic in this function doesn't match the original. It should be redone.
void DragonsEngine::engineFlag0x20UpdateFunction() {
if (_flags & Dragons::ENGINE_FLAG_20) {
if ((_flags & (Dragons::ENGINE_FLAG_80000000 | Dragons::ENGINE_FLAG_8)) == 8) {

View File

@ -34,14 +34,14 @@ Minigame4::Minigame4(DragonsEngine *vm) : _vm(vm) {}
void Minigame4::run() {
uint16 uVar1;
DragonINI *uVar2;
DragonINI *flicker;
uint uVar4;
ushort result;
int16_t uVar3;
uVar4 = _vm->getAllFlags();
uVar3 = _vm->_inventory->getType();
uVar2 = _vm->_dragonINIResource->getFlickerRecord();
flicker = _vm->_dragonINIResource->getFlickerRecord();
uVar1 = _vm->getCurrentSceneId();
// fade_related_calls_with_1f();
_vm->reset_screen_maybe();
@ -101,7 +101,7 @@ void Minigame4::run() {
_vm->setFlags(ENGINE_FLAG_1);
_vm->videoFlags &= ~(uint16)4;
// EnableVSyncEvent();
_vm->_dragonINIResource->setFlickerRecord(uVar2);
_vm->_dragonINIResource->setFlickerRecord(flicker);
_vm->_inventory->setType(uVar3);
// _vm->_screen->loadPalette(4,(uint)*(ushort *)
// (*(int *)(&DAT_80071c30 + (uint)actors[0].actorFileDictionaryIndex * 8) + 10)
@ -109,7 +109,7 @@ void Minigame4::run() {
_vm->_screen->updatePaletteTransparency(4,1,0xff,true);
_vm->_scene->setSceneId(uVar1);
_vm->setAllFlags(uVar4);
uVar2->sceneId = uVar1;
flicker->sceneId = uVar1;
_vm->_scene->loadScene(uVar1,0x1e);
}

View File

@ -387,7 +387,7 @@ void ScriptOpcodes::opPlayMusic(ScriptOpCall &scriptOpCall) {
}
void ScriptOpcodes::opUnk13PropertiesRelated(ScriptOpCall &scriptOpCall) {
if (checkPropertyFlag(scriptOpCall)) {
if (evaluateExpression(scriptOpCall)) {
scriptOpCall._code += 4;
} else {
scriptOpCall._code += 4 + READ_LE_UINT16(scriptOpCall._code);
@ -395,7 +395,7 @@ void ScriptOpcodes::opUnk13PropertiesRelated(ScriptOpCall &scriptOpCall) {
}
void ScriptOpcodes::opUnk14PropertiesRelated(ScriptOpCall &scriptOpCall) {
if (checkPropertyFlag(scriptOpCall)) {
if (evaluateExpression(scriptOpCall)) {
ScriptOpCall localScriptOpCall(scriptOpCall._code + 4, READ_LE_UINT16(scriptOpCall._code));
localScriptOpCall._field8 = scriptOpCall._field8;
localScriptOpCall._result = 0;
@ -418,7 +418,7 @@ void ScriptOpcodes::opUnk14PropertiesRelated(ScriptOpCall &scriptOpCall) {
void ScriptOpcodes::opUnk15PropertiesRelated(ScriptOpCall &scriptOpCall) {
while (true) {
if (checkPropertyFlag(scriptOpCall)) {
if (evaluateExpression(scriptOpCall)) {
ScriptOpCall localScriptOpCall(scriptOpCall._code + 4, READ_LE_UINT32(scriptOpCall._code));
runScript(localScriptOpCall);
@ -452,15 +452,15 @@ void ScriptOpcodes::opUnk21(ScriptOpCall &scriptOpCall) {
}
}
bool ScriptOpcodes::checkPropertyFlag(ScriptOpCall &scriptOpCall) {
bool ScriptOpcodes::evaluateExpression(ScriptOpCall &scriptOpCall) {
byte *codePtrOffsetA = scriptOpCall._code + 0xA;
byte *codePtrOffset2 = scriptOpCall._code + 2;
uint16 status = 0;
uint16 result = 0;
uint16 t2 = 0;
uint16 t0 = 0;
int16 t2 = 0;
int16 t0 = 0;
for(;;) {
byte value = 0;

View File

@ -118,7 +118,7 @@ protected:
void opUnk20(ScriptOpCall &scriptOpCall);
void opUnk21(ScriptOpCall &scriptOpCall);
bool checkPropertyFlag(ScriptOpCall &scriptOpCall);
bool evaluateExpression(ScriptOpCall &scriptOpCall);
void opCode_UnkA_setsProperty(ScriptOpCall &scriptOpCall);
void opCode_Unk7(ScriptOpCall &scriptOpCall);