HOPKINS: Start refactoring BTOCEAN. Get rid of two labels and their associated GOTOs

This commit is contained in:
Strangerke 2013-02-03 13:38:51 +01:00
parent 0f69da1a4f
commit 397c0cc238

View File

@ -106,7 +106,7 @@ Common::Error HopkinsEngine::run() {
else if (getPlatform() == Common::kPlatformWindows) else if (getPlatform() == Common::kPlatformWindows)
runWin95Demo(); runWin95Demo();
else { else {
warning("Unhandled version, switching to linux demo. Please report this version to ScummVM developers"); warning("Unhandled version, switching to Linux demo. Please report this version to ScummVM developers");
runLinuxDemo(); runLinuxDemo();
} }
@ -783,7 +783,7 @@ bool HopkinsEngine::runFull() {
_graphicsManager.clearScreen(); _graphicsManager.clearScreen();
_graphicsManager.unlockScreen(); _graphicsManager.unlockScreen();
_graphicsManager.clearPalette(); _graphicsManager.clearPalette();
if (getPlatform() == Common::kPlatformLinux) { if (getPlatform() == Common::kPlatformLinux) {
_graphicsManager.loadImage("H2"); _graphicsManager.loadImage("H2");
_graphicsManager.fadeInLong(); _graphicsManager.fadeInLong();
@ -813,7 +813,9 @@ bool HopkinsEngine::runFull() {
_globals.PERSO_TYPE = 0; _globals.PERSO_TYPE = 0;
_globals._mapCarPosX = _globals._mapCarPosY = 0; _globals._mapCarPosX = _globals._mapCarPosY = 0;
memset(_globals._saveData, 0, 2000); memset(_globals._saveData, 0, 2000);
_globals._exitId = 0; _globals._exitId = 0;
for (;;) { for (;;) {
if (_globals._exitId == 300) if (_globals._exitId == 300)
_globals._exitId = 0; _globals._exitId = 0;
@ -2526,189 +2528,174 @@ void HopkinsEngine::displayCredits() {
void HopkinsEngine::BTOCEAN() { void HopkinsEngine::BTOCEAN() {
_fontManager.hideText(9); _fontManager.hideText(9);
if (_eventsManager._mouseCursorId == 16) { if (_eventsManager._mouseCursorId != 16)
_eventsManager.getMouseX(); return;
if (_objectsManager._zoneNum > 0) {
int oldPosX = _eventsManager.getMouseX(); _eventsManager.getMouseX();
int oldPosY = _eventsManager.getMouseY(); if (_objectsManager._zoneNum <= 0)
bool displAnim = false; return;
if (_objectsManager._zoneNum == 1) {
if (_globals._oceanDirection == 3) int oldPosX = _eventsManager.getMouseX();
_objectsManager.SPACTION(_globals.PERSO, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,-1,", 0, 0, 6, false); int oldPosY = _eventsManager.getMouseY();
else if (_globals._oceanDirection == 1) bool displAnim = false;
_objectsManager.SPACTION(_globals.PERSO, "27,26,25,24,23,22,21,20,19,18,-1,", 0, 0, 6, false);
else if (_globals._oceanDirection == 5) if (_objectsManager._zoneNum == 1) {
_objectsManager.SPACTION(_globals.PERSO, "9,10,11,12,13,14,15,16,17,18,-1,", 0, 0, 6, false); if (_globals._oceanDirection == 3)
_globals._oceanDirection = 7; _objectsManager.SPACTION(_globals.PERSO, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,-1,", 0, 0, 6, false);
_globals._exitId = 1; else if (_globals._oceanDirection == 1)
int oldX = _objectsManager.getSpriteX(0); _objectsManager.SPACTION(_globals.PERSO, "27,26,25,24,23,22,21,20,19,18,-1,", 0, 0, 6, false);
for (;;) { else if (_globals._oceanDirection == 5)
if (_globals._speed == 1) _objectsManager.SPACTION(_globals.PERSO, "9,10,11,12,13,14,15,16,17,18,-1,", 0, 0, 6, false);
oldX -= 2; _globals._oceanDirection = 7;
else if (_globals._speed == 2) _globals._exitId = 1;
oldX -= 4; int oldX = _objectsManager.getSpriteX(0);
else if (_globals._speed == 3) for (;;) {
oldX -= 6; if (_globals._speed == 1)
_objectsManager.setSpriteX(0, oldX); oldX -= 2;
OCEAN_HOME(); else if (_globals._speed == 2)
_eventsManager.VBL(); oldX -= 4;
if (_eventsManager.getMouseButton() == 1) { else if (_globals._speed == 3)
if (oldPosX == _eventsManager.getMouseX()) { oldX -= 6;
if (_eventsManager.getMouseY() == oldPosY) _objectsManager.setSpriteX(0, oldX);
break; OCEAN_HOME();
} _eventsManager.VBL();
} if (_eventsManager.getMouseButton() == 1 && oldPosX == _eventsManager.getMouseX() && _eventsManager.getMouseY() == oldPosY) {
if (oldX <= -100)
goto LABEL_22;
}
displAnim = true; displAnim = true;
break;
} }
LABEL_22:
if (_objectsManager._zoneNum == 2) { if (oldX <= -100)
if (_globals._oceanDirection == 7) break;
_objectsManager.SPACTION(_globals.PERSO, "18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,-1,", 0, 0, 6, false); }
else if (_globals._oceanDirection == 1) }
_objectsManager.SPACTION(_globals.PERSO, "27,28,29,30,31,32,33,34,35,36,-1,", 0, 0, 6, false);
else if (_globals._oceanDirection == 5) if (_objectsManager._zoneNum == 2) {
_objectsManager.SPACTION(_globals.PERSO, "9,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 6, false); if (_globals._oceanDirection == 7)
_globals._oceanDirection = 3; _objectsManager.SPACTION(_globals.PERSO, "18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,-1,", 0, 0, 6, false);
_globals._exitId = 2; else if (_globals._oceanDirection == 1)
int oldX = _objectsManager.getSpriteX(0); _objectsManager.SPACTION(_globals.PERSO, "27,28,29,30,31,32,33,34,35,36,-1,", 0, 0, 6, false);
for (;;) { else if (_globals._oceanDirection == 5)
if (_globals._speed == 1) _objectsManager.SPACTION(_globals.PERSO, "9,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 6, false);
oldX += 2; _globals._oceanDirection = 3;
else if (_globals._speed == 2) _globals._exitId = 2;
oldX += 4; int oldX = _objectsManager.getSpriteX(0);
else if (_globals._speed == 3) for (;;) {
oldX += 6; if (_globals._speed == 1)
_objectsManager.setSpriteX(0, oldX); oldX += 2;
OCEAN_HOME(); else if (_globals._speed == 2)
_eventsManager.VBL(); oldX += 4;
if (_eventsManager.getMouseButton() == 1) { else if (_globals._speed == 3)
if (oldPosX == _eventsManager.getMouseX()) { oldX += 6;
if (_eventsManager.getMouseY() == oldPosY) _objectsManager.setSpriteX(0, oldX);
break; OCEAN_HOME();
} _eventsManager.VBL();
} if (_eventsManager.getMouseButton() == 1 && oldPosX == _eventsManager.getMouseX() && _eventsManager.getMouseY() == oldPosY) {
if (oldX > 499)
goto LABEL_41;
}
displAnim = true; displAnim = true;
break;
} }
LABEL_41: if (oldX > 499)
if (_objectsManager._zoneNum == 3) { break;
if (_globals._oceanDirection == 3) { }
int oldX = _objectsManager.getSpriteX(0); }
do { if (_objectsManager._zoneNum == 3) {
if (_globals._speed == 1) if (_globals._oceanDirection == 3) {
oldX += 2; int oldX = _objectsManager.getSpriteX(0);
else if (_globals._speed == 2) do {
oldX += 4; if (_globals._speed == 1)
else if (_globals._speed == 3) oldX += 2;
oldX += 6; else if (_globals._speed == 2)
_objectsManager.setSpriteX(0, oldX); oldX += 4;
OCEAN_HOME(); else if (_globals._speed == 3)
_eventsManager.VBL(); oldX += 6;
if (_eventsManager.getMouseButton() == 1) { _objectsManager.setSpriteX(0, oldX);
if (oldPosX == _eventsManager.getMouseX()) { OCEAN_HOME();
if (_eventsManager.getMouseY() == oldPosY) { _eventsManager.VBL();
displAnim = true; if (_eventsManager.getMouseButton() == 1 && oldPosX == _eventsManager.getMouseX() && _eventsManager.getMouseY() == oldPosY) {
goto LABEL_57; displAnim = true;
} goto LABEL_57;
}
}
} while (oldX <= 235);
if (!displAnim)
_objectsManager.SPACTION(_globals.PERSO, "36,35,34,33,32,31,30,29,28,27,-1,", 0, 0, 6, false);
} }
} while (oldX <= 235);
if (!displAnim)
_objectsManager.SPACTION(_globals.PERSO, "36,35,34,33,32,31,30,29,28,27,-1,", 0, 0, 6, false);
}
LABEL_57: LABEL_57:
if (_globals._oceanDirection == 7) { if (_globals._oceanDirection == 7) {
int oldX = _objectsManager.getSpriteX(0); int oldX = _objectsManager.getSpriteX(0);
do { do {
if (_globals._speed == 1) if (_globals._speed == 1)
oldX -= 2; oldX -= 2;
else if (_globals._speed == 2) else if (_globals._speed == 2)
oldX -= 4; oldX -= 4;
else if (_globals._speed == 3) else if (_globals._speed == 3)
oldX -= 6; oldX -= 6;
_objectsManager.setSpriteX(0, oldX); _objectsManager.setSpriteX(0, oldX);
OCEAN_HOME(); OCEAN_HOME();
_eventsManager.VBL(); _eventsManager.VBL();
if (_eventsManager.getMouseButton() == 1) { if (_eventsManager.getMouseButton() == 1 && oldPosX == _eventsManager.getMouseX() && _eventsManager.getMouseY() == oldPosY) {
if (oldPosX == _eventsManager.getMouseX()) { displAnim = true;
if (_eventsManager.getMouseY() == oldPosY) { goto LABEL_72;
displAnim = true;
goto LABEL_72;
}
}
}
} while (oldX > 236);
if (!displAnim)
_objectsManager.SPACTION(_globals.PERSO, "18,19,20,21,22,23,24,25,26,27,-1,", 0, 0, 6, false);
} }
} while (oldX > 236);
if (!displAnim)
_objectsManager.SPACTION(_globals.PERSO, "18,19,20,21,22,23,24,25,26,27,-1,", 0, 0, 6, false);
}
LABEL_72: LABEL_72:
if (_globals._oceanDirection == 5) if (_globals._oceanDirection == 5)
_objectsManager.SPACTION(_globals.PERSO, "9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,", 0, 0, 6, false); _objectsManager.SPACTION(_globals.PERSO, "9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,", 0, 0, 6, false);
_globals._oceanDirection = 1; _globals._oceanDirection = 1;
_globals._exitId = 3; _globals._exitId = 3;
} }
if (_objectsManager._zoneNum == 4) { if (_objectsManager._zoneNum == 4) {
if (_globals._oceanDirection == 3) { if (_globals._oceanDirection == 3) {
int oldX = _objectsManager.getSpriteX(0); int oldX = _objectsManager.getSpriteX(0);
do { do {
if (_globals._speed == 1) if (_globals._speed == 1)
oldX += 2; oldX += 2;
else if (_globals._speed == 2) else if (_globals._speed == 2)
oldX += 4; oldX += 4;
else if (_globals._speed == 3) else if (_globals._speed == 3)
oldX += 6; oldX += 6;
_objectsManager.setSpriteX(0, oldX); _objectsManager.setSpriteX(0, oldX);
OCEAN_HOME(); OCEAN_HOME();
_eventsManager.VBL(); _eventsManager.VBL();
if (_eventsManager.getMouseButton() == 1) { if (_eventsManager.getMouseButton() == 1 && oldPosX == _eventsManager.getMouseX() && _eventsManager.getMouseY() == oldPosY) {
if (oldPosX == _eventsManager.getMouseX()) { displAnim = true;
if (_eventsManager.getMouseY() == oldPosY) { goto LABEL_91;
displAnim = true;
goto LABEL_91;
}
}
}
} while (oldX <= 235);
if (!displAnim)
_objectsManager.SPACTION(_globals.PERSO, "0,1,2,3,4,5,6,7,8,9,-1,", 0, 0, 6, false);
} }
} while (oldX <= 235);
if (!displAnim)
_objectsManager.SPACTION(_globals.PERSO, "0,1,2,3,4,5,6,7,8,9,-1,", 0, 0, 6, false);
}
LABEL_91: LABEL_91:
if (_globals._oceanDirection == 7) { if (_globals._oceanDirection == 7) {
int oldX = _objectsManager.getSpriteX(0); int oldX = _objectsManager.getSpriteX(0);
for (;;) { for (;;) {
if (_globals._speed == 1) if (_globals._speed == 1)
oldX -= 2; oldX -= 2;
else if (_globals._speed == 2) else if (_globals._speed == 2)
oldX -= 4; oldX -= 4;
else if (_globals._speed == 3) else if (_globals._speed == 3)
oldX -= 6; oldX -= 6;
_objectsManager.setSpriteX(0, oldX); _objectsManager.setSpriteX(0, oldX);
OCEAN_HOME(); OCEAN_HOME();
_eventsManager.VBL(); _eventsManager.VBL();
if (_eventsManager.getMouseButton() == 1) { if (_eventsManager.getMouseButton() == 1) {
if (oldPosX == _eventsManager.getMouseX()) { if (oldPosX == _eventsManager.getMouseX()) {
if (_eventsManager.getMouseY() == oldPosY) if (_eventsManager.getMouseY() == oldPosY)
break;
}
}
if (oldX <= 236) {
if (!displAnim)
_objectsManager.SPACTION(_globals.PERSO, "18,17,16,15,14,13,12,11,10,9,-1,", 0, 0, 6, false);
break; break;
}
} }
} }
if (_globals._oceanDirection == 1) if (oldX <= 236) {
_objectsManager.SPACTION(_globals.PERSO, "27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,-1,", 0, 0, 6, false); if (!displAnim)
_globals._oceanDirection = 5; _objectsManager.SPACTION(_globals.PERSO, "18,17,16,15,14,13,12,11,10,9,-1,", 0, 0, 6, false);
_globals._exitId = 4; break;
}
} }
} }
if (_globals._oceanDirection == 1)
_objectsManager.SPACTION(_globals.PERSO, "27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,-1,", 0, 0, 6, false);
_globals._oceanDirection = 5;
_globals._exitId = 4;
} }
} }
@ -2734,14 +2721,14 @@ void HopkinsEngine::OCEAN(int16 curExitId, Common::String backgroundFilename, in
if (backgroundFilename.size()) if (backgroundFilename.size())
_graphicsManager.loadImage(backgroundFilename); _graphicsManager.loadImage(backgroundFilename);
if ((curExitId != 77) && (curExitId != 84) && (curExitId != 91)) if (curExitId == 77)
_objectsManager.INILINK("ocean");
else if (curExitId == 77)
_objectsManager.INILINK("IM77"); _objectsManager.INILINK("IM77");
else if (curExitId == 84) else if (curExitId == 84)
_objectsManager.INILINK("IM84"); _objectsManager.INILINK("IM84");
else if (curExitId == 91) else if (curExitId == 91)
_objectsManager.INILINK("IM91"); _objectsManager.INILINK("IM91");
else
_objectsManager.INILINK("ocean");
if (!exit1) if (!exit1)
_objectsManager.disableZone(1); _objectsManager.disableZone(1);
@ -2800,7 +2787,7 @@ void HopkinsEngine::OCEAN(int16 curExitId, Common::String backgroundFilename, in
_objectsManager.checkZone(); _objectsManager.checkZone();
OCEAN_HOME(); OCEAN_HOME();
_eventsManager.VBL(); _eventsManager.VBL();
if (_globals._exitId) if (_globals._exitId || g_system->getEventManager()->shouldQuit())
loopCond = true; loopCond = true;
} while (!loopCond); } while (!loopCond);