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,9 +25,7 @@
namespace Kingdom {
void Logic::GPLogic4() {
switch(_statPlay) {
case 900:
void Logic::GPL4_900() {
if (_vm->_aTimer > 0) {
_vm->playSound(0);
_vm->_aTimer = 133;
@ -55,7 +53,7 @@ void Logic::GPLogic4() {
_vm->setATimer();
_vm->_userInput = 0;
GPLogic4_SP901();
GPL4_901();
} else {
if (_vm->_aTimer > 0) {
_vm->setATimer();
@ -64,11 +62,47 @@ void Logic::GPLogic4() {
_vm->showPic(120);
_statPlay = 901;
}
break;
case 901:
GPLogic4_SP901();
break;
case 991:
}
void Logic::GPL4_901() {
_vm->setMouse();
_vm->eraseCursor();
_vm->fadeToBlack2();
_vm->showPic(106);
_vm->drawIcon(4, 0, 12 - _healthOld);
if (_tideCntl)
_vm->drawPic(178);
else
_vm->drawPic(179);
_vm->_iconRedraw = true;
if (_vm->_userInput == 0x2F1) {
_vm->_asMode = false;
_vm->restoreAS();
_statPlay = _oldStatPlay;
_vm->_loopFlag = true;
} else {
if (_health == 10 || _health == 6 || _health == 2 || _vm->_userInput < 0x400 || _vm->_userInput > 0x427) {
_vm->_asMode = false;
_vm->restoreAS();
_statPlay = _oldStatPlay;
} else {
_statPlay = _mapExit[_vm->_userInput - 0x400];
_vm->_userInput = 0;
wound();
_vm->playMovie(10);
inventoryDel(3);
_vm->_tsIconOnly = false;
enAll();
switchAS();
_mapStat = 0;
}
_vm->_userInput = 0;
_vm->_loopFlag = true;
}
}
void Logic::GPL4_991() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
@ -117,8 +151,9 @@ void Logic::GPLogic4() {
inventoryDel(12);
_statPlay = 50;
}
break;
case 992:
}
void Logic::GPL4_992() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
@ -165,8 +200,9 @@ void Logic::GPLogic4() {
inventoryDel(12);
_statPlay = 270;
}
break;
case 993:
}
void Logic::GPL4_993() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
@ -215,8 +251,9 @@ void Logic::GPLogic4() {
inventoryDel(12);
_statPlay = 520;
}
break;
case 994:
}
void Logic::GPL4_994() {
switch(_vm->_userInput) {
case 0x190:
_vm->initPlay();
@ -227,47 +264,11 @@ void Logic::GPLogic4() {
// 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;
}
}
void Logic::GPLogic4_SP901() {
_vm->setMouse();
_vm->eraseCursor();
_vm->fadeToBlack2();
_vm->showPic(106);
_vm->drawIcon(4, 0, 12 - _healthOld);
if (_tideCntl)
_vm->drawPic(178);
else
_vm->drawPic(179);
_vm->_iconRedraw = true;
if (_vm->_userInput == 0x2F1) {
_vm->_asMode = false;
_vm->restoreAS();
_statPlay = _oldStatPlay;
_vm->_loopFlag = true;
} else {
if (_health == 10 || _health == 6 || _health == 2 || _vm->_userInput < 0x400 || _vm->_userInput > 0x427) {
_vm->_asMode = false;
_vm->restoreAS();
_statPlay = _oldStatPlay;
} else {
_statPlay = _mapExit[_vm->_userInput - 0x400];
_vm->_userInput = 0;
wound();
_vm->playMovie(10);
inventoryDel(3);
_vm->_tsIconOnly = false;
enAll();
switchAS();
_mapStat = 0;
}
_vm->_userInput = 0;
_vm->_loopFlag = true;
}
}
} // 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);