aboutsummaryrefslogtreecommitdiff
path: root/engines/lure
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lure')
-rw-r--r--engines/lure/game.cpp11
-rw-r--r--engines/lure/game.h2
-rw-r--r--engines/lure/hotspots.cpp88
-rw-r--r--engines/lure/hotspots.h7
-rw-r--r--engines/lure/luredefs.h2
-rw-r--r--engines/lure/res_struct.cpp15
-rw-r--r--engines/lure/res_struct.h10
-rw-r--r--engines/lure/room.cpp47
-rw-r--r--engines/lure/screen.cpp37
-rw-r--r--engines/lure/screen.h3
10 files changed, 148 insertions, 74 deletions
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index 3ac25f83b8..5bffc6ade8 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -52,7 +52,7 @@ Game::~Game() {
delete _debugger;
}
-void Game::tick() {
+void Game::tick(bool fastSpeed) {
// 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
@@ -65,7 +65,11 @@ void Game::tick() {
int idSize = 0;
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) {
Hotspot *hotspot = *i;
- idList[idSize++] = hotspot->hotspotId();
+
+ if (!fastSpeed || ((hotspot->layer() != 0xff) &&
+ (hotspot->hotspotId() < FIRST_NONCHARACTER_ID)))
+ // Add hotspot to list to execute
+ idList[idSize++] = hotspot->hotspotId();
}
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot ticks begin");
@@ -289,6 +293,7 @@ void Game::playerChangeRoom() {
uint16 roomNum = fields.playerNewPos().roomNumber;
fields.playerNewPos().roomNumber = 0;
Point &newPos = fields.playerNewPos().position;
+
delayList.clear();
RoomData *roomData = res.getRoom(roomNum);
@@ -302,7 +307,9 @@ void Game::playerChangeRoom() {
displayChuteAnimation();
else if (animFlag != 0)
displayBarrelAnimation();
+
fields.setField(ROOM_EXIT_ANIMATION, 0);
+ roomData->exitTime = g_system->getMillis();
// Change to the new room
Hotspot *player = res.getActiveHotspot(PLAYER_ID);
diff --git a/engines/lure/game.h b/engines/lure/game.h
index b1d1f8d21a..20e56df776 100644
--- a/engines/lure/game.h
+++ b/engines/lure/game.h
@@ -66,7 +66,7 @@ public:
static Game &getReference();
- void tick();
+ void tick(bool fastSpeed = false);
void nextFrame();
void execute();
void setState(uint8 flags) { _state = flags; }
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp
index 82b4725a70..7def0be9ab 100644
--- a/engines/lure/hotspots.cpp
+++ b/engines/lure/hotspots.cpp
@@ -689,7 +689,6 @@ void Hotspot::converse(uint16 destCharacterId, uint16 messageId, bool standStill
if (standStill) {
setDelayCtr(_data->talkCountdown);
_data->characterMode = CHARMODE_CONVERSING;
- //TODO: HS[3Eh]=character_hotspot_id, HS[40h]=active_hotspot_id
}
}
@@ -1332,7 +1331,10 @@ void Hotspot::doUse(HotspotData *hotspot) {
faceHotspot(hotspot);
endAction();
- // TODO: If character=3E9h, HS[-1]=28h, HS[1Fh]=50h
+ if (hotspotId() == RATPOUCH_ID) {
+ _tempDest.position.x = 40;
+ setFrameCtr(80);
+ }
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, USE);
@@ -1727,7 +1729,6 @@ void Hotspot::doBribe(HotspotData *hotspot) {
++tempId; // Move over entry's sequence offset
}
- // TODO: call to talk_setup
faceHotspot(hotspot);
setActionCtr(0);
endAction();
@@ -1738,8 +1739,8 @@ void Hotspot::doBribe(HotspotData *hotspot) {
if (sequenceOffset != 0) return;
}
- // TODO: talk_record_index
- showMessage(sequenceOffset);
+ uint16 talkIndex = res.fieldList().getField(TALK_INDEX);
+ showMessage((talkIndex == 6) ? 0x30 : 0x29);
}
void Hotspot::doExamine(HotspotData *hotspot) {
@@ -1811,7 +1812,7 @@ void Hotspot::npcHeySir(HotspotData *hotspot) {
return;
}
- // TODO: Check storage of hotspot Id in data_1090/data_1091=0
+ // TODO: Check storage of hotspot Id in talk_first=player/talk_second=0
// Get the npc to say "Hey Sir" to player
showMessage(0x22, PLAYER_ID);
@@ -2059,6 +2060,9 @@ void Hotspot::saveToStream(Common::WriteStream *stream) {
stream->writeSint16LE(_destX);
stream->writeSint16LE(_destY);
stream->writeUint16LE(_destHotspotId);
+ stream->writeByte(_tempDest.counter);
+ stream->writeSint16LE(_tempDest.position.x);
+ stream->writeSint16LE(_tempDest.position.y);
stream->writeUint16LE(_frameWidth);
stream->writeUint16LE(_height);
stream->writeUint16LE(_width);
@@ -2096,6 +2100,9 @@ void Hotspot::loadFromStream(Common::ReadStream *stream) {
_destX = stream->readSint16LE();
_destY = stream->readSint16LE();
_destHotspotId = stream->readUint16LE();
+ _tempDest.counter = stream->readByte();
+ _tempDest.position.x = stream->readSint16LE();
+ _tempDest.position.y = stream->readSint16LE();
_frameWidth = stream->readUint16LE();
_height = stream->readUint16LE();
_width = stream->readUint16LE();
@@ -2227,6 +2234,7 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
RoomPathsData &paths = Resources::getReference().getRoom(h.roomNumber())->paths;
PathFinder &pathFinder = h.pathFinder();
CurrentActionStack &actions = h.currentActions();
+ Hotspot *player = res.getActiveHotspot(PLAYER_ID);
uint16 impingingList[MAX_NUM_IMPINGING];
int numImpinging;
bool bumpedPlayer;
@@ -2276,8 +2284,6 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
if (numImpinging > 0) {
// Scan to check if the character has bumped into player
- Hotspot *player = res.getActiveHotspot(PLAYER_ID);
-
if (bumpedPlayer && (player->characterMode() == CHARMODE_IDLE)) {
// Signal the player to move out of the way automatically
player->setBlockedState(BS_INITIAL);
@@ -2300,8 +2306,12 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
h.setSkipFlag(false);
}
- // TODO: Handling of any set Tick Script Offset, as well as certain other
- // as of yet unknown hotspot flags
+ if (h.resource()->scriptHotspotId != 0) {
+ // Character bumped against another
+ fields.setField(USE_HOTSPOT_ID, h.resource()->scriptHotspotId);
+ Script::execute(h.resource()->tickScriptOffset);
+ h.resource()->scriptHotspotId = 0;
+ }
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 4");
if (h.pauseCtr() != 0) {
@@ -2332,13 +2342,14 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
// All other character modes
if (h.delayCtr() > 0) {
// There is some countdown left to do
- bool decrementFlag = true;
+ h.updateMovement();
- if (!decrementFlag) {
- HotspotData *hotspot = res.getHotspot(0); // TODO: HS[50h]
- decrementFlag = (hotspot->roomNumber != h.roomNumber()) ? false :
+ bool decrementFlag = (h.resource()->actionHotspotId != 0);
+ if (decrementFlag) {
+ HotspotData *hotspot = res.getHotspot(h.resource()->actionHotspotId);
+ decrementFlag = (hotspot->roomNumber != h.hotspotId()) ? false :
Support::charactersIntersecting(hotspot, h.resource());
- }
+ }
if (decrementFlag) {
h.setDelayCtr(h.delayCtr() - 1);
@@ -2353,12 +2364,20 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
h.pathFinder().clear();
if ((currentMode == CHARMODE_WAIT_FOR_PLAYER) || (currentMode == CHARMODE_WAIT_FOR_INTERACT)) {
- // TODO: HS[33h]=0
+ h.resource()->talkOverride = 0;
h.showMessage(1);
}
return;
}
+ /* interactHotspotId never seems to be set
+ if ((h.resource()->interactHotspotId != 0) && !player->currentActions().isEmpty()) {
+ h.setActionCtr(99);
+ if (!actions.isEmpty())
+ actions.top().setAction(DISPATCH_ACTION);
+ }
+ */
+
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 6");
CurrentAction action = actions.action();
PathFinderResult pfResult;
@@ -2567,7 +2586,9 @@ void HotspotTickHandlers::puzzledAnimHandler(Hotspot &h) {
}
void HotspotTickHandlers::roomExitAnimHandler(Hotspot &h) {
- RoomExitJoinData *rec = Resources::getReference().getExitJoin(h.hotspotId());
+ Resources &res = Resources::getReference();
+// ValueTableData &fields = res.fieldList();
+ RoomExitJoinData *rec = res.getExitJoin(h.hotspotId());
if (!rec) return;
byte *currentFrame, *destFrame;
@@ -2607,7 +2628,6 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) {
RoomPathsData &paths = Resources::getReference().getRoom(h.roomNumber())->paths;
PathFinder &pathFinder = h.pathFinder();
CurrentActionStack &actions = h.currentActions();
- ValueTableData &fields = res.fieldList();
uint16 impingingList[MAX_NUM_IMPINGING];
int numImpinging;
Action hsAction;
@@ -2637,7 +2657,17 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) {
return;
h.setSkipFlag(false);
}
- // TODO: HS[58h] check
+
+ /* interactHotspotId never seems to be set
+ if (h.resource()->interactHotspotId != 0) {
+ h.resource()->interactHotspotId = 0;
+ Hotspot *hotspot = res.getActiveHotspot(h.resource()->interactHotspotId);
+ assert(hotspot);
+ if ((hotspot->characterMode() != CHARMODE_WAIT_FOR_INTERACT) &&
+ !actions.isEmpty())
+ actions.top().setAction(ACTION_NONE);
+ }
+ */
if (h.pauseCtr() > 0) {
debugC(ERROR_DETAILED, kLureDebugAnimations, "Pause countdown = %d", h.pauseCtr());
@@ -2668,10 +2698,10 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) {
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character mode = %d", h.characterMode());
h.setOccupied(false);
h.setCharacterMode(CHARMODE_NONE);
- if (fields.playerPendingPos().isSet) {
+ if (h.tempDest().counter != 0) {
// Start walking to the previously set destination
- fields.playerPendingPos().isSet = false;
- h.setDestPosition(fields.playerPendingPos().pos.x, fields.playerPendingPos().pos.y);
+ h.tempDest().counter = 0;
+ h.setDestPosition(h.tempDest().position.x, h.tempDest().position.y);
h.currentActions().addFront(START_WALKING, h.roomNumber());
h.setWalkFlag(false);
}
@@ -2753,9 +2783,9 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) {
return;
} else if (h.blockedState() != BS_NONE) {
- fields.playerPendingPos().pos.x = h.destX();
- fields.playerPendingPos().pos.y = h.destY();
- fields.playerPendingPos().isSet = true;
+ h.tempDest().position.x = h.destX();
+ h.tempDest().position.y = h.destY();
+ h.tempDest().counter = 1;
h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));
h.setRandomDest();
return;
@@ -2795,7 +2825,7 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) {
// Walking done
if (room.cursorState() == CS_BUMPED)
room.setCursorState(CS_NONE);
- if (fields.playerPendingPos().isSet) {
+ if (h.tempDest().counter != 0) {
h.setCharacterMode(CHARMODE_PLAYER_WAIT);
h.setDelayCtr(IDLE_COUNTDOWN_SIZE);
return;
@@ -4474,9 +4504,9 @@ void Support::characterChangeRoom(Hotspot &h, uint16 roomNumber,
// TODO: Double-check.. is it impinging in leaving room (right now) or entering room
if (checkForIntersectingCharacter(h)) {
- fields.playerPendingPos().pos.x = h.destX();
- fields.playerPendingPos().pos.y = h.destY();
- fields.playerPendingPos().isSet = true;
+ h.tempDest().position.x = h.destX();
+ h.tempDest().position.y = h.destY();
+ h.tempDest().counter = 1;
Room::getReference().setCursorState(CS_BUMPED);
h.setActionCtr(0);
h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));
diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h
index 3f8bc544f6..fb3bb1478b 100644
--- a/engines/lure/hotspots.h
+++ b/engines/lure/hotspots.h
@@ -243,6 +243,11 @@ enum HotspotPrecheckResult {PC_EXECUTE, PC_NOT_IN_ROOM, PC_FAILED, PC_WAIT, PC_E
enum BarPlaceResult {BP_KEEP_TRYING, BP_GOT_THERE, BP_FAIL};
+struct DestStructure {
+ uint8 counter;
+ Point position;
+};
+
#define MAX_NUM_FRAMES 16
class Hotspot {
@@ -277,6 +282,7 @@ private:
bool _frameStartsUsed;
uint16 _frameStarts[MAX_NUM_FRAMES];
char _nameBuffer[MAX_HOTSPOT_NAME_SIZE];
+ DestStructure _tempDest;
// Runtime fields
uint16 _frameCtr;
@@ -516,6 +522,7 @@ public:
void doAction(Action action, HotspotData *hotspot);
CurrentActionStack &currentActions() { return _currentActions; }
PathFinder &pathFinder() { return _pathFinder; }
+ DestStructure &tempDest() { return _tempDest; }
uint16 frameCtr() { return _frameCtr; }
void setFrameCtr(uint16 value) { _frameCtr = value; }
void decrFrameCtr() { if (_frameCtr > 0) --_frameCtr; }
diff --git a/engines/lure/luredefs.h b/engines/lure/luredefs.h
index a715c4a1e7..d5991a5807 100644
--- a/engines/lure/luredefs.h
+++ b/engines/lure/luredefs.h
@@ -113,6 +113,8 @@ enum Action {
#define SUB_PALETTE_SIZE 64
// Palette resources have 220 palette entries
#define RES_PALETTE_ENTRIES 220
+// Main working palette size
+#define MAIN_PALETTE_SIZE 228
// Palette colour increment amouns for palette fade in/outs
#define PALETTE_FADE_INC_SIZE 4
diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp
index 79bf0dfe6e..12cf61a58a 100644
--- a/engines/lure/res_struct.cpp
+++ b/engines/lure/res_struct.cpp
@@ -466,7 +466,7 @@ void HotspotData::saveToStream(WriteStream *stream) {
stream->writeUint16LE(talkCountdown);
stream->writeUint16LE(pauseCtr);
stream->writeUint16LE(useHotspotId);
- stream->writeUint16LE(use2HotspotId);
+ stream->writeUint16LE(scriptHotspotId);
stream->writeUint16LE(talkGate);
stream->writeUint16LE(actionHotspotId);
stream->writeUint16LE(talkOverride);
@@ -507,7 +507,7 @@ void HotspotData::loadFromStream(ReadStream *stream) {
talkCountdown = stream->readUint16LE();
pauseCtr = stream->readUint16LE();
useHotspotId = stream->readUint16LE();
- use2HotspotId = stream->readUint16LE();
+ scriptHotspotId = stream->readUint16LE();
talkGate = stream->readUint16LE();
actionHotspotId = stream->readUint16LE();
talkOverride = stream->readUint16LE();
@@ -1119,7 +1119,7 @@ int PausedCharacterList::check(uint16 charId, int numImpinging, uint16 *impingin
if ((charHotspot->characterMode() == CHARMODE_PAUSED) ||
((charHotspot->pauseCtr() == 0) &&
(charHotspot->characterMode() == CHARMODE_NONE))) {
- hotspot->resource()->use2HotspotId = charId;
+ hotspot->resource()->scriptHotspotId = charId;
}
hotspot->setPauseCtr(IDLE_COUNTDOWN_SIZE);
@@ -1206,9 +1206,6 @@ ValueTableData::ValueTableData() {
_playerNewPos.roomNumber = 0;
_playerNewPos.position.x = 0;
_playerNewPos.position.y = 0;
- _playerPendingPos.pos.x = 0;
- _playerPendingPos.pos.y = 0;
- _playerPendingPos.isSet = false;
_flags = GAMEFLAG_4 | GAMEFLAG_1;
_hdrFlagMask = 1;
@@ -1252,9 +1249,6 @@ void ValueTableData::saveToStream(Common::WriteStream *stream)
stream->writeSint16LE(_playerNewPos.position.x);
stream->writeSint16LE(_playerNewPos.position.y);
stream->writeUint16LE(_playerNewPos.roomNumber);
- stream->writeByte(_playerPendingPos.isSet);
- stream->writeSint16LE(_playerPendingPos.pos.x);
- stream->writeSint16LE(_playerPendingPos.pos.y);
stream->writeByte(_flags);
stream->writeByte(_hdrFlagMask);
@@ -1270,9 +1264,6 @@ void ValueTableData::loadFromStream(Common::ReadStream *stream)
_playerNewPos.position.x = stream->readSint16LE();
_playerNewPos.position.y = stream->readSint16LE();
_playerNewPos.roomNumber = stream->readUint16LE();
- _playerPendingPos.isSet = stream->readByte() != 0;
- _playerPendingPos.pos.x = stream->readSint16LE();
- _playerPendingPos.pos.y = stream->readSint16LE();
_flags = stream->readByte();
_hdrFlagMask = stream->readByte();
diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h
index b5e4aef724..4d2c55e6b1 100644
--- a/engines/lure/res_struct.h
+++ b/engines/lure/res_struct.h
@@ -458,8 +458,7 @@ public:
uint16 talkGate;
uint16 actionHotspotId;
uint16 talkOverride;
-
- uint16 use2HotspotId;
+ uint16 scriptHotspotId;
void enable() { flags |= 0x80; }
void disable() { flags &= 0x7F; }
@@ -817,16 +816,10 @@ struct PlayerNewPosition {
uint16 roomNumber;
};
-struct PlayerPendingPosition {
- Point pos;
- bool isSet;
-};
-
class ValueTableData {
private:
uint16 _numGroats;
PlayerNewPosition _playerNewPos;
- PlayerPendingPosition _playerPendingPos;
uint8 _flags;
uint8 _hdrFlagMask;
@@ -845,7 +838,6 @@ public:
uint8 &flags() { return _flags; }
uint8 &hdrFlagMask() { return _hdrFlagMask; }
PlayerNewPosition &playerNewPos() { return _playerNewPos; }
- PlayerPendingPosition &playerPendingPos() { return _playerPendingPos; }
void saveToStream(Common::WriteStream *stream);
void loadFromStream(Common::ReadStream *stream);
diff --git a/engines/lure/room.cpp b/engines/lure/room.cpp
index 016432dfac..b48b50197b 100644
--- a/engines/lure/room.cpp
+++ b/engines/lure/room.cpp
@@ -24,6 +24,7 @@
#include "lure/luredefs.h"
#include "lure/res.h"
#include "lure/screen.h"
+#include "lure/game.h"
#include "lure/events.h"
#include "lure/strings.h"
#include "lure/scripts.h"
@@ -492,18 +493,26 @@ void Room::update() {
void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) {
Resources &r = Resources::getReference();
+ Game &game = Game::getReference();
+ Mouse &mouse = Mouse::getReference();
+
+ mouse.pushCursorNum(CURSOR_DISK);
+
_roomData = r.getRoom(newRoomNumber);
if (!_roomData)
error("Tried to change to non-existant room: %d", newRoomNumber);
- bool leaveFlag = (_layers[0] && (newRoomNumber != _roomNumber));
+ bool leaveFlag = (_layers[0] && (newRoomNumber != _roomNumber) && (_roomNumber != 0));
_roomNumber = _roomData->roomNumber;
_descId = _roomData->descId;
+ if (leaveFlag) {
+ _screen.paletteFadeOut();
+ leaveRoom();
+ }
+
_screen.empty();
- _screen.resetPalette();
- if (leaveFlag) leaveRoom();
_numLayers = _roomData->numLayers;
if (showOverlay) ++_numLayers;
@@ -512,13 +521,9 @@ void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) {
_layers[layerNum] = new RoomLayer(_roomData->layers[layerNum],
layerNum == 0);
- // Load in the palette, add in the two replacements segments, and then
- // set to the system palette
- Palette p(228, NULL, RGB64);
- Palette tempPalette(paletteId);
- p.copyFrom(&tempPalette);
- r.insertPaletteSubset(p);
- _screen.setPalette(&p);
+ // Load in the game palette and set the non-room specific colours at the top end of the palette
+ Palette mainPalette(GAME_PALETTE_RESOURCE_ID);
+ _screen.setPalette(&mainPalette, MAIN_PALETTE_SIZE, GAME_COLOURS - MAIN_PALETTE_SIZE);
// Set the new room number
r.fieldList().setField(ROOM_NUMBER, newRoomNumber);
@@ -527,8 +532,28 @@ void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) {
Script::execute(_roomData->sequenceOffset);
loadRoomHotspots();
- checkCursor();
+
+ if (_roomData->exitTime != 0xffff)
+ {
+ // If time has passed, animation ticks needed before room is displayed
+ int numSeconds = (g_system->getMillis() - _roomData->exitTime) / 1000;
+ if (numSeconds > 300) numSeconds = 300;
+
+ while (numSeconds-- > 0)
+ game.tick(true);
+ }
+
update();
+ _screen.update();
+
+ // Generate the palette for the room and fade it in
+ Palette p(MAIN_PALETTE_SIZE, NULL, RGB64);
+ Palette tempPalette(paletteId);
+ p.copyFrom(&tempPalette);
+ r.insertPaletteSubset(p);
+ _screen.paletteFadeIn(&p);
+
+ mouse.popCursor();
}
// checkCursor
diff --git a/engines/lure/screen.cpp b/engines/lure/screen.cpp
index 8477c0def4..0cd2dd9357 100644
--- a/engines/lure/screen.cpp
+++ b/engines/lure/screen.cpp
@@ -28,6 +28,7 @@
#include "lure/memory.h"
#include "lure/disk.h"
#include "lure/decode.h"
+#include "lure/events.h"
namespace Lure {
@@ -71,26 +72,40 @@ void Screen::setPalette(Palette *p) {
_system.updateScreen();
}
+// setPalette
+// Variation that allows the specification of a subset of a palette passed in to be copied
+
+void Screen::setPalette(Palette *p, uint16 start, uint16 num) {
+ _palette->palette()->copyFrom(p->palette(), start * PALETTE_FADE_INC_SIZE,
+ start * PALETTE_FADE_INC_SIZE, num * PALETTE_FADE_INC_SIZE);
+ _system.setPalette(_palette->data(), 0, GAME_COLOURS);
+ _system.updateScreen();
+}
+
// paletteFadeIn
// Fades in the palette. For proper operation, the palette should have been
// previously set to empty
void Screen::paletteFadeIn(Palette *p) {
+ assert(p->numEntries() <= _palette->numEntries());
+ Events &events = Events::getReference();
bool changed;
- byte *const pDest = p->data();
- byte *const pTemp = _palette->data();
do {
changed = false;
+ byte *pFinal = p->data();
+ byte *pCurrent = _palette->data();
- for (int palCtr = 0; palCtr < p->numEntries() * 4; ++palCtr)
+ for (int palCtr = 0; palCtr < p->numEntries() * PALETTE_FADE_INC_SIZE; ++palCtr, ++pCurrent, ++pFinal)
{
if (palCtr % PALETTE_FADE_INC_SIZE == (PALETTE_FADE_INC_SIZE - 1)) continue;
- bool isDifferent = pTemp[palCtr] < pDest[palCtr];
+ bool isDifferent = *pCurrent < *pFinal;
+
if (isDifferent) {
- if (pDest[palCtr] - pTemp[palCtr] < PALETTE_FADE_INC_SIZE)
- pTemp[palCtr] = pDest[palCtr];
- else pTemp[palCtr] += PALETTE_FADE_INC_SIZE;
+ if ((*pFinal - *pCurrent) < PALETTE_FADE_INC_SIZE)
+ *pCurrent = *pFinal;
+ else
+ *pCurrent += PALETTE_FADE_INC_SIZE;
changed = true;
}
}
@@ -99,6 +114,7 @@ void Screen::paletteFadeIn(Palette *p) {
_system.setPalette(_palette->data(), 0, GAME_COLOURS);
_system.updateScreen();
_system.delayMillis(20);
+ events.pollEvent();
}
} while (changed);
}
@@ -106,14 +122,16 @@ void Screen::paletteFadeIn(Palette *p) {
// paletteFadeOut
// Fades the screen to black by gradually decreasing the palette colours
-void Screen::paletteFadeOut() {
+void Screen::paletteFadeOut(int numEntries) {
+ assert((uint32)numEntries <= _palette->palette()->size());
+ Events &events = Events::getReference();
bool changed;
do {
byte *pTemp = _palette->data();
changed = false;
- for (uint32 palCtr = 0; palCtr < _palette->palette()->size(); ++palCtr, ++pTemp) {
+ for (uint32 palCtr = 0; palCtr < (uint32)(numEntries * PALETTE_FADE_INC_SIZE); ++palCtr, ++pTemp) {
if (palCtr % PALETTE_FADE_INC_SIZE == (PALETTE_FADE_INC_SIZE - 1))
continue;
bool isDifferent = *pTemp > 0;
@@ -128,6 +146,7 @@ void Screen::paletteFadeOut() {
_system.setPalette(_palette->data(), 0, GAME_COLOURS);
_system.updateScreen();
_system.delayMillis(20);
+ events.pollEvent();
}
} while (changed);
}
diff --git a/engines/lure/screen.h b/engines/lure/screen.h
index 9197f64a8d..7182c4236b 100644
--- a/engines/lure/screen.h
+++ b/engines/lure/screen.h
@@ -49,9 +49,10 @@ public:
void setPaletteEmpty();
void setPalette(Palette *p);
+ void setPalette(Palette *p, uint16 start, uint16 num);
Palette &getPalette() { return *_palette; }
void paletteFadeIn(Palette *p);
- void paletteFadeOut();
+ void paletteFadeOut(int numEntries = MAIN_PALETTE_SIZE);
void resetPalette();
void empty();
void update();