aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lure/game.cpp88
-rw-r--r--engines/lure/game.h10
-rw-r--r--engines/lure/lure.h1
3 files changed, 73 insertions, 26 deletions
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index 5bffc6ade8..091cfbfe0a 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -24,12 +24,13 @@
*/
#include "lure/game.h"
-#include "lure/strings.h"
-#include "lure/room.h"
-#include "lure/scripts.h"
-#include "lure/res_struct.h"
#include "lure/animseq.h"
#include "lure/fights.h"
+#include "lure/res_struct.h"
+#include "lure/room.h"
+#include "lure/scripts.h"
+#include "lure/sound.h"
+#include "lure/strings.h"
#include "common/config-manager.h"
@@ -45,6 +46,7 @@ Game::Game() {
int_game = this;
_debugger = new Debugger();
_slowSpeedFlag = true;
+ _preloadFlag = true;
_soundFlag = true;
}
@@ -52,7 +54,7 @@ Game::~Game() {
delete _debugger;
}
-void Game::tick(bool fastSpeed) {
+void Game::tick() {
// Call the tick method for each hotspot - this is somewaht complicated
// by the fact that a tick proc can unload both itself and/or others,
// so we first get a list of the Ids, and call the tick proc for each
@@ -66,7 +68,7 @@ void Game::tick(bool fastSpeed) {
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) {
Hotspot *hotspot = *i;
- if (!fastSpeed || ((hotspot->layer() != 0xff) &&
+ if (!_preloadFlag || ((hotspot->layer() != 0xff) &&
(hotspot->hotspotId() < FIRST_NONCHARACTER_ID)))
// Add hotspot to list to execute
idList[idSize++] = hotspot->hotspotId();
@@ -85,6 +87,21 @@ void Game::tick(bool fastSpeed) {
delete[] idList;
}
+void Game::tickCheck() {
+ Resources &res = Resources::getReference();
+ Room &room = Room::getReference();
+ bool remoteFlag = res.fieldList().getField(OLD_ROOM_NUMBER) != 0;
+
+ _state |= GS_TICK;
+ if ((room.roomNumber() == ROOMNUM_VILLAGE_SHOP) && !remoteFlag && ((_state & GS_TICK) != 0)) {
+ // In the village shop,
+ bool tockFlag = (_state & GS_TOCK) != 0;
+ Sound.addSound(tockFlag ? 16 : 50);
+
+ _state = _state ^ (GS_TICK | GS_TOCK);
+ }
+}
+
void Game::nextFrame() {
Resources &res = Resources::getReference();
Room &room = Room::getReference();
@@ -110,31 +127,41 @@ void Game::execute() {
ValueTableData &fields = res.fieldList();
uint32 timerVal = system.getMillis();
+ uint32 timerVal2 = system.getMillis();
screen.empty();
//_screen.resetPalette();
screen.setPaletteEmpty();
- setState(0);
+ while (!events.quitFlag) {
+ setState(0);
+ Script::execute(STARTUP_SCRIPT);
- Script::execute(STARTUP_SCRIPT);
+ int bootParam = ConfMan.getInt("boot_param");
+ handleBootParam(bootParam);
- int bootParam = ConfMan.getInt("boot_param");
- handleBootParam(bootParam);
+ // Set the player direction
+ res.getActiveHotspot(PLAYER_ID)->setDirection(UP);
- // Set the player direction
- res.getActiveHotspot(PLAYER_ID)->setDirection(UP);
+ room.update();
+ mouse.setCursorNum(CURSOR_ARROW);
+ mouse.cursorOn();
+if (bootParam == 1) _state = GS_RESTORE_RESTART; //******DEBUG******
- room.update();
- mouse.setCursorNum(CURSOR_ARROW);
- mouse.cursorOn();
-
- while (!events.quitFlag) {
- while (!events.quitFlag && (_state == 0)) {
+ // Main game loop
+ while (!events.quitFlag && ((_state & GS_RESTART) == 0)) {
// If time for next frame, allow everything to update
if (system.getMillis() > timerVal + GAME_FRAME_DELAY) {
timerVal = system.getMillis();
nextFrame();
+
+ Sound.musicInterface_ContinuePlaying();
+ }
+
+ // Also check if time to do another village shop tick check
+ if (system.getMillis() > timerVal2 + GAME_TICK_DELAY) {
+ timerVal2 = system.getMillis();
+ tickCheck();
}
res.delayList().tick();
@@ -232,24 +259,35 @@ void Game::execute() {
_debugger->onFrame();
}
+ room.leaveRoom();
+ screen.paletteFadeOut();
+
// If Skorl catches player, show the catching animation
if ((_state & GS_CAUGHT) != 0) {
Palette palette(SKORL_CATCH_PALETTE_ID);
AnimationSequence *anim = new AnimationSequence(screen, system,
SKORL_CATCH_ANIM_ID, palette, false);
mouse.cursorOff();
+ Sound.addSound(0x33);
anim->show();
mouse.cursorOn();
}
// If the Restart/Restore dialog is needed, show it
- if ((_state & GS_RESTORE_RESTART) != 0) {
- // TODO: Restore/Restart dialog - for now, simply flag for exit
+ if ((_state & GS_RESTORE) != 0) {
+ // Show the Restore/Restart dialog
+ bool restartFlag = RestartRestoreDialog::show();
+
+ setState(0);
+
+ if (restartFlag) {
+ res.reloadData();
+ Script::execute(STARTUP_SCRIPT);
+ }
+ } else if ((_state & GS_RESTART) == 0)
+ // Exiting game
events.quitFlag = true;
- }
}
-
- room.leaveRoom();
}
void Game::handleMenuResponse(uint8 selection) {
@@ -296,6 +334,8 @@ void Game::playerChangeRoom() {
delayList.clear();
+ Sound.removeSounds();
+
RoomData *roomData = res.getRoom(roomNum);
assert(roomData);
roomData->flags |= HOTSPOTFLAG_FOUND;
@@ -361,7 +401,7 @@ void Game::displayChuteAnimation()
delete anim;
mouse.cursorOn();
- fields.setField(82, 1);
+ fields.setField(AREA_FLAG, 1);
}
void Game::displayBarrelAnimation()
diff --git a/engines/lure/game.h b/engines/lure/game.h
index 20e56df776..7b2099ef0c 100644
--- a/engines/lure/game.h
+++ b/engines/lure/game.h
@@ -39,7 +39,9 @@
namespace Lure {
-enum GameState {GS_RESTORE_RESTART = 1, GS_CAUGHT = 2, GS_EXIT = 3};
+enum GameState {GS_ERROR = 1, GS_TICK = 2, GS_TOCK = 4, GS_PROT = 8, GS_RESTART = 0x10,
+ GS_CAUGHT = 0x20, GS_RESTORE = 0x40, GS_FLOPPY = 0x80,
+ GS_RESTORE_RESTART = 0x50};
class Game {
private:
@@ -48,6 +50,7 @@ private:
uint8 _state;
uint16 _tellCommands[MAX_TELL_COMMANDS * 3 + 1];
int _numTellCommands;
+ bool _preloadFlag;
void handleMenuResponse(uint8 selection);
void handleClick();
@@ -60,16 +63,19 @@ private:
void displayChuteAnimation();
void displayBarrelAnimation();
void handleBootParam(int value);
+ int restartRestoreScreen();
public:
Game();
virtual ~Game();
static Game &getReference();
- void tick(bool fastSpeed = false);
+ void tick();
+ void tickCheck();
void nextFrame();
void execute();
void setState(uint8 flags) { _state = flags; }
+ bool &preloadFlag() { return _preloadFlag; }
// Menu item support methods
void doDebugMenu();
diff --git a/engines/lure/lure.h b/engines/lure/lure.h
index aa7f0ae93a..7ac0977900 100644
--- a/engines/lure/lure.h
+++ b/engines/lure/lure.h
@@ -71,6 +71,7 @@ public:
uint32 features() { return _features; }
uint8 game() { return _game; }
Disk &disk() { return *_disk; }
+ Common::Language getLanguage() { return _language; }
bool loadGame(uint8 slotNumber);
bool saveGame(uint8 slotNumber, Common::String &caption);