KINGDOM: Refactor GPL4

This commit is contained in:
Strangerke 2017-07-24 00:07:48 +02:00 committed by Eugene Sandulenko
parent f14a9e7c06
commit 36493f5bc2
4 changed files with 219 additions and 207 deletions

View File

@ -25,214 +25,46 @@
namespace Kingdom {
void Logic::GPLogic4() {
switch(_statPlay) {
case 900:
void Logic::GPL4_900() {
if (_vm->_aTimer > 0) {
_vm->playSound(0);
_vm->_aTimer = 133;
}
if (_vm->_asMode) {
_vm->switchMtoA();
_mapStat = 0;
_oldStatPlay--;
_vm->_asMode = false;
}
_vm->saveAS();
_vm->fadeToBlack2();
if (_health == 10 || _health == 6 || _health == 2) {
_vm->showPic(121);
_vm->_bTimer = 38;
_vm->readMouse();
while (_vm->_bTimer && !_vm->_mouseButton) {
_vm->checkTimers();
_vm->refreshSound();
_vm->readMouse();
}
if (_vm->_aTimer > 0)
_vm->setATimer();
_vm->_userInput = 0;
GPL4_901();
} else {
if (_vm->_aTimer > 0) {
_vm->playSound(0);
_vm->setATimer();
_vm->_aTimer = 133;
}
if (_vm->_asMode) {
_vm->switchMtoA();
_mapStat = 0;
_oldStatPlay--;
_vm->_asMode = false;
}
_vm->saveAS();
_vm->fadeToBlack2();
if (_health == 10 || _health == 6 || _health == 2) {
_vm->showPic(121);
_vm->_bTimer = 38;
_vm->readMouse();
while (_vm->_bTimer && !_vm->_mouseButton) {
_vm->checkTimers();
_vm->refreshSound();
_vm->readMouse();
}
if (_vm->_aTimer > 0)
_vm->setATimer();
_vm->_userInput = 0;
GPLogic4_SP901();
} else {
if (_vm->_aTimer > 0) {
_vm->setATimer();
_vm->_aTimer = 133;
}
_vm->showPic(120);
_statPlay = 901;
}
break;
case 901:
GPLogic4_SP901();
break;
case 991:
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
_currMap = 3;
dsAll();
_pouch = false;
_vm->playSound(1);
memset(_inventory, -1, 19);
_statPlay = 994;
} else {
_vm->_bTimer = 36;
while(_vm->_bTimer) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[29] == 1) {
_nodes[29] = 0;
_nodes[49] = 0;
}
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enAll();
_vm->_mapEx = true;
_nodeNum = 5;
_vm->drawLocation();
_vm->playSound(0);
if (_nodes[5] > 0) {
_vm->playMovie(197);
_resurrect = true;
}
inventoryDel(12);
_statPlay = 50;
}
break;
case 992:
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
_currMap = 3;
dsAll();
_pouch = false;
_vm->playSound(1);
memset(_inventory, -1, 19);
_statPlay = 994;
} else {
_vm->_bTimer = 36;
while(_vm->_bTimer != 0) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[29] == 1) {
_nodes[29] = 0;
_nodes[49] = 0;
}
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enAll();
_vm->_mapEx = true;
_nodeNum = 27;
_vm->drawLocation();
_resurrect = true;
_vm->playSound(0);
_vm->playMovie(195);
inventoryDel(12);
_statPlay = 270;
}
break;
case 993:
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
_currMap = 3;
dsAll();
_pouch = false;
_vm->playSound(1);
memset(_inventory, -1, 19);
_statPlay = 994;
} else {
_vm->_bTimer = 36;
while (_vm->_bTimer != 0) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[29] == 1) {
_nodes[29] = 0;
_nodes[49] = 0;
}
if (_nodes[68] == 1)
_nodes[68] = 0;
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enAll();
_vm->_mapEx = true;
_nodeNum = 52;
_vm->drawLocation();
_resurrect = true;
_vm->playSound(0);
_vm->playMovie(196);
inventoryDel(12);
_statPlay = 520;
}
break;
case 994:
switch(_vm->_userInput) {
case 0x190:
_vm->initPlay();
// TODO _QuitFlag = 1;
_vm->_quit = true;
break;
case 0x191:
// TODO _QuitFlag = 2;
_vm->_quit = true;
break;
}
break;
_vm->showPic(120);
_statPlay = 901;
}
}
void Logic::GPLogic4_SP901() {
void Logic::GPL4_901() {
_vm->setMouse();
_vm->eraseCursor();
_vm->fadeToBlack2();
@ -242,7 +74,7 @@ void Logic::GPLogic4_SP901() {
_vm->drawPic(178);
else
_vm->drawPic(179);
_vm->_iconRedraw = true;
if (_vm->_userInput == 0x2F1) {
_vm->_asMode = false;
@ -270,4 +102,173 @@ void Logic::GPLogic4_SP901() {
}
}
void Logic::GPL4_991() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
_currMap = 3;
dsAll();
_pouch = false;
_vm->playSound(1);
memset(_inventory, -1, 19);
_statPlay = 994;
} else {
_vm->_bTimer = 36;
while(_vm->_bTimer) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[29] == 1) {
_nodes[29] = 0;
_nodes[49] = 0;
}
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enAll();
_vm->_mapEx = true;
_nodeNum = 5;
_vm->drawLocation();
_vm->playSound(0);
if (_nodes[5] > 0) {
_vm->playMovie(197);
_resurrect = true;
}
inventoryDel(12);
_statPlay = 50;
}
}
void Logic::GPL4_992() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
_currMap = 3;
dsAll();
_pouch = false;
_vm->playSound(1);
memset(_inventory, -1, 19);
_statPlay = 994;
} else {
_vm->_bTimer = 36;
while(_vm->_bTimer != 0) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[29] == 1) {
_nodes[29] = 0;
_nodes[49] = 0;
}
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enAll();
_vm->_mapEx = true;
_nodeNum = 27;
_vm->drawLocation();
_resurrect = true;
_vm->playSound(0);
_vm->playMovie(195);
inventoryDel(12);
_statPlay = 270;
}
}
void Logic::GPL4_993() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
_currMap = 3;
dsAll();
_pouch = false;
_vm->playSound(1);
memset(_inventory, -1, 19);
_statPlay = 994;
} else {
_vm->_bTimer = 36;
while (_vm->_bTimer != 0) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[29] == 1) {
_nodes[29] = 0;
_nodes[49] = 0;
}
if (_nodes[68] == 1)
_nodes[68] = 0;
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enAll();
_vm->_mapEx = true;
_nodeNum = 52;
_vm->drawLocation();
_resurrect = true;
_vm->playSound(0);
_vm->playMovie(196);
inventoryDel(12);
_statPlay = 520;
}
}
void Logic::GPL4_994() {
switch(_vm->_userInput) {
case 0x190:
_vm->initPlay();
// TODO _QuitFlag = 1;
_vm->_quit = true;
break;
case 0x191:
// TODO _QuitFlag = 2;
_vm->_quit = true;
break;
default:
if (_vm->_userInput)
debug("Skipped UserInput %d(0x%04X) for _StatPlay %d", _vm->_userInput, _vm->_userInput, _statPlay);
break;
}
}
} // Namespace

View File

@ -190,7 +190,7 @@ Common::Error KingdomGame::run() {
}
if (_logic->_statPlay > 899)
_logic->GPLogic4();
_logic->executeOpcode();
}
if (!_loopFlag)

View File

@ -270,6 +270,13 @@ void Logic::initOpcodes() {
_opCodes[781] = &Logic::GPL3_781;
_opCodes[790] = &Logic::GPL3_790;
_opCodes[791] = &Logic::GPL3_791;
_opCodes[900] = &Logic::GPL4_900;
_opCodes[901] = &Logic::GPL4_901;
_opCodes[991] = &Logic::GPL4_991;
_opCodes[992] = &Logic::GPL4_992;
_opCodes[993] = &Logic::GPL4_993;
_opCodes[994] = &Logic::GPL4_994;
}
void Logic::enAll() {

View File

@ -230,6 +230,13 @@ private:
void GPL3_790();
void GPL3_791();
void GPL4_900();
void GPL4_901();
void GPL4_991();
void GPL4_992();
void GPL4_993();
void GPL4_994();
public:
int _statPlay;
int _oldStatPlay;
@ -267,7 +274,6 @@ public:
void GPLogic1_SubSP10();
void GPLogic1_SubSP121();
void GPLogic2_SubSP361();
void GPLogic4_SP901();
bool chkDesertObstacles();
void increaseHealth();
void endCredits();
@ -277,8 +283,6 @@ public:
explicit Logic(Kingdom::KingdomGame *vm);
virtual ~Logic(void) {}
void GPLogic3();
void GPLogic4();
void gameHelp();
void inventoryDel(int item);
void inventoryAdd(int item);