[Scummvm-git-logs] scummvm master -> 2352a26046d21e1f1148d4577ef0ee3906b6fa41
mduggan
noreply at scummvm.org
Tue Oct 20 03:37:40 UTC 2026
This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
de0574637b ACCESS: Small refactors and cleanups
471de6efcb ACCESS: Remove unused variable _charCol
0a9f2f104e ACCESS: Correctly treat static _fontColors as static
366f5236f9 ACCESS: More small code cleanups
5bfa6f5ab1 ACCESS: Fix inconsistent variable naming in Player
5dbb71a529 ACCESS: Rename bubble box enum to more meaningful values
2de76481cc ACCESS: Refactor script opcodes
2352a26046 ACCESS: Fall back to EN_ANY for game lang
Commit: de0574637befea268cd0996c06b880255184eaa1
https://github.com/scummvm/scummvm/commit/de0574637befea268cd0996c06b880255184eaa1
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2026-10-20T14:16:47+11:00
Commit Message:
ACCESS: Small refactors and cleanups
* Add direct file load call for sprite and anim resources to avoid the messy
and error-prone load/load/free pattern
* Move a few member variables to cleaner locations (private, move out of
engine)
* Replace getGameId with slightly more readable "gameIs" function
Changed paths:
engines/access/access.cpp
engines/access/access.h
engines/access/amazon/amazon_logic.cpp
engines/access/amazon/amazon_room.cpp
engines/access/amazon/amazon_scripts.cpp
engines/access/animation.cpp
engines/access/animation.h
engines/access/asurface.cpp
engines/access/asurface.h
engines/access/bubble_box.cpp
engines/access/bubble_box.h
engines/access/char.cpp
engines/access/debugger.cpp
engines/access/events.cpp
engines/access/files.cpp
engines/access/inventory.cpp
engines/access/martian/martian_duct.cpp
engines/access/martian/martian_game.cpp
engines/access/martian/martian_scripts.cpp
engines/access/metaengine.cpp
engines/access/noctropolis/noctropolis_game.cpp
engines/access/noctropolis/noctropolis_player.cpp
engines/access/noctropolis/noctropolis_room.cpp
engines/access/player.cpp
engines/access/resources.cpp
engines/access/room.cpp
engines/access/room.h
engines/access/screen.cpp
engines/access/scripts.cpp
engines/access/scripts.h
engines/access/sound.cpp
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 577a43e5fbe..a93f6dee223 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -106,7 +106,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
ARRAYCLEAR(_ask);
ARRAYCLEAR(_asked);
_startAboutItem = _startAboutBox = 0;
- _keepAskPosition = false;
_bcnt = 0;
_boxDataStart = 0;
_boxDataEnd = false;
@@ -251,10 +250,8 @@ int AccessEngine::getRandomNumber(int maxNumber) {
void AccessEngine::loadCells(const Common::Array<CellIdent> &cells) {
for (const auto &cell : cells) {
- Resource *spriteData = _files->loadFile(cell);
assert(_objectsTable[cell._cell] == nullptr); // ensure no leaks
- _objectsTable[cell._cell] = new SpriteResource(this, spriteData);
- delete spriteData;
+ _objectsTable[cell._cell] = new SpriteResource(this, cell._fileNum, cell._subFile);
}
}
diff --git a/engines/access/access.h b/engines/access/access.h
index 6044f115658..591f736bbad 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -241,9 +241,9 @@ public:
SpriteResource *_objectsTable[128];
bool _establishTable[128];
bool _establishFlag;
- int _establishMode;
- int _establishGroup;
- int _establishCtrlTblOfs;
+ int _establishMode; // Amazon only?
+ int _establishGroup; // Amazon only?
+ int _establishCtrlTblOfs; // Amazon only?
TimerList _timers;
DeathList _deaths;
FontManager _fonts;
@@ -254,10 +254,11 @@ public:
int _mouseMode;
uint8 _playerDataCount;
- int _currentManOld;
- int _converseMode;
+ int _currentManOld; // Amazon only
+ int _converseMode; // Set but never read?
bool _currentCharFlag;
bool _boxSelect;
+
int _scale;
int _scaleH1, _scaleH2;
int _scaleN1;
@@ -269,11 +270,11 @@ public:
bool _canSaveLoad;
Resource *_establish;
- int _printEnd;
- int _txtPages;
- int _narateFile;
- int _sndSubFile;
- int _countTbl[6];
+ int _printEnd; // Amazon only
+ int _txtPages; // Amazon only
+ int _narateFile; // Used in speakText, only called in Amazon?
+ int _sndSubFile; // Used in speakText, only called in Amazon?
+ int _countTbl[6]; // Used in speakText, only called in Amazon?
// Fields that are included in savegames
int _conversation;
@@ -292,8 +293,6 @@ public:
int _startAboutItem;
int _startAboutBox;
- Common::Point _askBase; // Noctropolis only
- bool _keepAskPosition; // Noctropolis only
int _boxDataStart;
bool _boxDataEnd;
int _boxSelectY;
@@ -313,7 +312,7 @@ public:
int &_useItem;
int &_startup;
int &_manScaleOff;
- int &_pictureTaken;
+ int &_pictureTaken; // Only used in MM
public:
AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
@@ -328,6 +327,7 @@ public:
Common::Platform getPlatform() const;
uint16 getVersion() const;
AccessGameType getGameID() const;
+ bool gameIs(AccessGameType game) const;
uint32 getGameFeatures() const;
bool shouldQuitOrRestart();
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index aeb79964d1b..5fb74e05637 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -99,10 +99,7 @@ void CampScene::mWhileDoOpen() {
_vm->establishCenter(0, 1);
}
- Resource *data = _vm->_files->loadFile(1, 0);
- _vm->_objectsTable[1] = new SpriteResource(_vm, data);
- delete data;
-
+ _vm->_objectsTable[1] = new SpriteResource(_vm, 1, 0);
_vm->_files->_setPaletteFlag = false;
_vm->_files->loadScreen(1, 2);
_vm->_buffer2.blitFrom(*_vm->_screen);
@@ -110,9 +107,7 @@ void CampScene::mWhileDoOpen() {
// Load animation data
_vm->_animation->freeAnimationData();
- Resource *animResource = _vm->_files->loadFile(1, 1);
- _vm->_animation->loadAnimations(animResource);
- delete animResource;
+ _vm->_animation->loadAnimations(1, 1);
_xTrack = 8;
_yTrack = -3;
@@ -187,14 +182,9 @@ void CampScene::mWhileDoOpen() {
if (_vm->isCD()) {
if (_vm->_conversation == 2) {
// Cutscene at end of Chapter 6
- Resource *spriteData = _vm->_files->loadFile(28, 37);
- _vm->_objectsTable[28] = new SpriteResource(_vm, spriteData);
- delete spriteData;
-
+ _vm->_objectsTable[28] = new SpriteResource(_vm, 28, 37);
_vm->_animation->freeAnimationData();
- animResource = _vm->_files->loadFile(28, 38);
- _vm->_animation->loadAnimations(animResource);
- delete animResource;
+ _vm->_animation->loadAnimations(28, 38);
}
} else {
_vm->freeCells();
@@ -336,9 +326,7 @@ void Opening::doTitle() {
_vm->_sound->playSound(1, true);
- Resource *spriteData = _vm->_files->loadFile(0, 2);
- _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
- delete spriteData;
+ _vm->_objectsTable[0] = new SpriteResource(_vm, 0, 2);
_vm->_files->_setPaletteFlag = false;
_vm->_files->loadScreen(0, 4);
@@ -573,7 +561,7 @@ Plane::Plane(AmazonEngine *vm) : PannedScene(vm) {
void Plane::doFlyCell() {
- SpriteResource *sprites = _vm->_objectsTable[15];
+ const SpriteResource *sprites = _vm->_objectsTable[15];
if (_pCount <= 40) {
_vm->_buffer2.plotImage(sprites, 3, Common::Point(70, 74));
@@ -1277,12 +1265,8 @@ void Cast::doCast(int param1) {
screen.setPanel(3);
_vm->_chapter = 14;
- Resource *spriteData = _vm->_files->loadFile(91, 0);
- _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
- delete spriteData;
- spriteData = _vm->_files->loadFile(91, 1);
- _vm->_objectsTable[1] = new SpriteResource(_vm, spriteData);
- delete spriteData;
+ _vm->_objectsTable[0] = new SpriteResource(_vm, 91, 0);
+ _vm->_objectsTable[1] = new SpriteResource(_vm, 91, 1);
_vm->_files->_setPaletteFlag = false;
_vm->_files->loadScreen(58, 1);
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 824db8f4ed5..097587dc9dc 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -145,9 +145,9 @@ void AmazonRoom::roomMenu() {
}
void AmazonRoom::mainAreaLClick() {
- Common::Point &mousePos = _vm->_events->_mousePos;
+ const Common::Point &mousePos = _vm->_events->_mousePos;
Common::Point pt = _vm->_events->calcRawMouse();
- Screen &screen = *_vm->_screen;
+ const Screen &screen = *_vm->_screen;
Player &player = *_vm->_player;
if (_selectCommand == -1) {
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 4b089b62fd9..11de4e6cbce 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -59,9 +59,7 @@ void AmazonScripts::mWhile1() {
_vm->_screen->setIconPalette();
_vm->_screen->forceFadeIn();
- Resource *spriteData = _vm->_files->loadFile(14, 6);
- _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
- delete spriteData;
+ _vm->_objectsTable[0] = new SpriteResource(_vm, 14, 6);
_vm->_images.clear();
_vm->_oldRects.clear();
@@ -77,9 +75,7 @@ void AmazonScripts::mWhile1() {
_game->establish(-1, 14);
- spriteData = _vm->_files->loadFile(14, 7);
- _vm->_objectsTable[1] = new SpriteResource(_vm, spriteData);
- delete spriteData;
+ _vm->_objectsTable[1] = new SpriteResource(_vm, 14, 7);
_vm->_sound->playSound(0);
_vm->_screen->setDisplayScan();
@@ -115,9 +111,7 @@ void AmazonScripts::mWhile1() {
_vm->_screen->setIconPalette();
_vm->freeCells();
- spriteData = _vm->_files->loadFile(14, 8);
- _vm->_objectsTable[2] = new SpriteResource(_vm, spriteData);
- delete spriteData;
+ _vm->_objectsTable[2] = new SpriteResource(_vm, 14, 8);
_vm->_images.clear();
_vm->_oldRects.clear();
@@ -130,9 +124,7 @@ void AmazonScripts::mWhile1() {
} while (_vm->_flags[52] == 3);
_vm->freeCells();
- spriteData = _vm->_files->loadFile(14, 9);
- _vm->_objectsTable[3] = new SpriteResource(_vm, spriteData);
- delete spriteData;
+ _vm->_objectsTable[3] = new SpriteResource(_vm, 14, 9);
_vm->_screen->setDisplayScan();
_vm->_events->hideCursor();
@@ -167,9 +159,7 @@ void AmazonScripts::mWhile2() {
_vm->_screen->setIconPalette();
_vm->_screen->forceFadeIn();
- Resource *spriteData = _vm->_files->loadFile(14, 6);
- _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
- delete spriteData;
+ _vm->_objectsTable[0] = new SpriteResource(_vm, 14, 6);
_vm->_images.clear();
_vm->_oldRects.clear();
@@ -182,9 +172,7 @@ void AmazonScripts::mWhile2() {
_vm->_screen->fadeOut();
_vm->freeCells();
- spriteData = _vm->_files->loadFile(14, 9);
- _vm->_objectsTable[3] = new SpriteResource(_vm, spriteData);
- delete spriteData;
+ _vm->_objectsTable[3] = new SpriteResource(_vm, 14, 9);
_vm->_screen->setDisplayScan();
_vm->_events->hideCursor();
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index ceff342618a..a4215cd950d 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -56,7 +56,7 @@ Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : Man
// WORKAROUND: In Amazon floppy English, there's an animation associated with
// the librarian that isn't used, and has junk data. Luckily, it's animation
// type is also invalid, so if the _type isn't in range, exit immediately
- if (_type > 7 && _vm->getGameID() == kGameAmazon) {
+ if (_type > 7 && _vm->gameIs(kGameAmazon)) {
_scaling = -1;
_frameNumber = -1;
_initialTicks = _countdownTicks = 0;
@@ -442,6 +442,13 @@ void AnimationManager::clearTimers() {
_animationTimers.clear();
}
+
+void AnimationManager::loadAnimations(int fileNum, int subfile) {
+ Resource *res = _vm->_files->loadFile(fileNum, subfile);
+ loadAnimations(res);
+ delete res;
+}
+
void AnimationManager::loadAnimations(Resource *res) {
_animationTimers.clear();
delete _animation;
diff --git a/engines/access/animation.h b/engines/access/animation.h
index 90fe83e7b47..a3ddb2e72c6 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -47,6 +47,7 @@ public:
~AnimationManager();
void freeAnimationData();
void loadAnimations(Resource *res);
+ void loadAnimations(int fileNum, int subfile);
Animation *findAnimation(int animId);
Animation *setAnimation(int animId);
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index bfa1fbafe3e..a11598b5977 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -40,7 +40,17 @@ namespace Access {
static constexpr int TRANSPARENCY = 0;
+SpriteResource::SpriteResource(const AccessEngine *vm, int fileNum, int subfile) {
+ Resource *res = vm->_files->loadFile(fileNum, subfile);
+ loadFromResource(vm, res);
+ delete res;
+}
+
SpriteResource::SpriteResource(const AccessEngine *vm, Resource *res) {
+ loadFromResource(vm, res);
+}
+
+void SpriteResource::loadFromResource(const AccessEngine *vm, Resource *res) {
Common::Array<uint32> offsets;
int count = res->_stream->readUint16LE();
if (count > 4096)
@@ -73,7 +83,7 @@ SpriteFrame::SpriteFrame(const AccessEngine *vm, Common::SeekableReadStream *str
int xSize = stream->readUint16LE();
int ySize = stream->readUint16LE();
- if (vm->getGameID() == kGameMartianMemorandum) {
+ if (vm->gameIs(kGameMartianMemorandum)) {
int size = stream->readUint16LE();
if (size != frameSize)
warning("Unexpected file difference: framesize %d - size %d %d - unknown %d", frameSize, xSize, ySize, size);
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 72ee07a0dfd..3f2f1d6550b 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -148,11 +148,15 @@ public:
Common::Array<SpriteFrame *> _frames;
public:
SpriteResource(const AccessEngine *vm, Resource *res);
+ SpriteResource(const AccessEngine *vm, int fileNum, int subfile);
~SpriteResource();
int getCount() const { return _frames.size(); }
const SpriteFrame *getFrame(int idx) const { return _frames[idx]; }
+
+private:
+ void loadFromResource(const AccessEngine *vm, Resource *res);
};
enum ImageFlag {
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index f608616dbdb..cf7d6216489 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -111,12 +111,12 @@ void BubbleBox::placeBubble1(const Common::String &msg) {
_bubbles.clear();
_vm->_fonts._charSet._lo = 1;
_vm->_fonts._charSet._hi = 8;
- _vm->_fonts._charFor._lo = (_vm->getGameID() == kGameMartianMemorandum) ? 247 : 29;
- _vm->_fonts._charFor._hi = (_vm->getGameID() == kGameMartianMemorandum) ? 255 : 32;
+ _vm->_fonts._charFor._lo = (_vm->gameIs(kGameMartianMemorandum) ? 247 : 29);
+ _vm->_fonts._charFor._hi = (_vm->gameIs(kGameMartianMemorandum) ? 255 : 32);
calcBubble(msg);
- if (_vm->getGameID() != kGameNoctropolis) {
+ if (!_vm->gameIs(kGameNoctropolis)) {
// Noctropolis bounds are different and might have the extra box
// decoration, so we save them during the render step (in doBox_v3)
Common::Rect r = _bubbles[0];
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index 4e6801d2771..026713e8ac6 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -57,6 +57,16 @@ private:
int _bIconStartX, _bIconStartY;
int _boxPStartX, _boxPStartY;
+ int _btnId1;
+ int _btnX1;
+ int _btnId2;
+ int _btnX2;
+ int _btnId3;
+ int _btnX3;
+
+ Common::Rect _btnUpPos;
+ Common::Rect _btnDownPos;
+
void displayBoxData();
void drawSelectBox();
/**
@@ -74,14 +84,6 @@ public:
Common::String _bubbleDisplStr; // the title that will be drawn on the next bubble
Common::String _tempList[60];
int _tempListIdx[60];
- int _btnId1;
- int _btnX1;
- int _btnId2;
- int _btnX2;
- int _btnId3;
- int _btnX3;
- Common::Rect _btnUpPos;
- Common::Rect _btnDownPos;
Common::Array<Common::Rect> _bubbles;
public:
BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w, int h, int val1, int val2, int val3, int val4, const char *title);
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index 2916cbed27c..ce306d0f75f 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -30,7 +30,7 @@ CharEntry::CharEntry(const byte *data, AccessEngine *vm) {
Common::MemoryReadStream s(data, 999);
_charFlag = s.readByte();
- if (vm->getGameID() != kGameAmazon || !vm->isCD()) {
+ if (!vm->gameIs(kGameAmazon) || !vm->isCD()) {
_screenFile.load(s);
_estabIndex = s.readSint16LE();
} else {
@@ -40,7 +40,7 @@ CharEntry::CharEntry(const byte *data, AccessEngine *vm) {
_paletteFile.load(s);
_startColor = s.readUint16LE();
- if (vm->getGameID() == kGameMartianMemorandum) {
+ if (vm->gameIs(kGameMartianMemorandum)) {
int lastColor = s.readUint16LE();
_numColors = lastColor - _startColor;
} else
@@ -91,7 +91,7 @@ void CharManager::loadChar(int charId) {
// Amazon calls "establish" before loading the screen, but MM does it after.
_vm->_establishFlag = false;
- if (_vm->getGameID() == kGameAmazon && ce._estabIndex != -1) {
+ if (_vm->gameIs(kGameAmazon) && ce._estabIndex != -1) {
_vm->_establishFlag = true;
if (!_vm->_establishTable[ce._estabIndex]) {
_vm->_establishTable[ce._estabIndex] = true;
@@ -113,7 +113,7 @@ void CharManager::loadChar(int charId) {
_vm->_buffer2.blitFrom(*_vm->_screen);
_vm->_screen->setDisplayScan();
- if (_vm->getGameID() == kGameMartianMemorandum && ce._estabIndex != -1) {
+ if (_vm->gameIs(kGameMartianMemorandum) && ce._estabIndex != -1) {
_vm->_establishFlag = true;
if (!_vm->_establishTable[ce._estabIndex]) {
_vm->_establishTable[ce._estabIndex] = true;
@@ -129,7 +129,7 @@ void CharManager::loadChar(int charId) {
_vm->_screen->_startColor = ce._startColor;
_vm->_screen->_numColors = ce._numColors;
if (ce._paletteFile._fileNum != -1) {
- int srcOffset = (_vm->getGameID() == kGameMartianMemorandum ? ce._startColor * 3 : 0);
+ int srcOffset = (_vm->gameIs(kGameMartianMemorandum) ? ce._startColor * 3 : 0);
_vm->_screen->loadPalette(ce._paletteFile._fileNum, ce._paletteFile._subFile, srcOffset);
}
_vm->_screen->setIconPalette();
@@ -137,9 +137,7 @@ void CharManager::loadChar(int charId) {
_vm->loadCells(ce._cells);
if (ce._animFile._fileNum != -1) {
- Resource *data = _vm->_files->loadFile(ce._animFile);
- _vm->_animation->loadAnimations(data);
- delete data;
+ _vm->_animation->loadAnimations(ce._animFile._fileNum, ce._animFile._subFile);
}
// Load script data
@@ -162,10 +160,10 @@ void CharManager::charMenu() {
screen.saveScreen();
screen.setDisplayScan();
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
screen.plotImage(icons, 17, Common::Point(0, 184));
screen.plotImage(icons, 18, Common::Point(193, 184));
- } else if (_vm->getGameID() == kGameAmazon) {
+ } else if (_vm->gameIs(kGameAmazon)) {
screen.plotImage(icons, 17, Common::Point(0, 176));
screen.plotImage(icons, 18, Common::Point(155, 176));
} else
diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index e063f780be9..1c76f71913f 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -244,10 +244,10 @@ bool Debugger::Cmd_Travel(int argc, const char **argv) {
for (int i = 0; i < ARRAYSIZE(_vm->_travel); ++i) {
const char *label = "UNKNOWN";
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
if (!Martian::TRAVDATA[i])
break;
- } else if (_vm->getGameID() == kGameNoctropolis) {
+ } else if (_vm->gameIs(kGameNoctropolis)) {
int j = 0;
while (Noctropolis::TRAV_ROOMS[j]) {
if (Noctropolis::TRAV_ROOMS[j] == i)
@@ -378,7 +378,7 @@ bool Debugger::Cmd_Everything(int argc, const char **argv) {
12, // LOVE SCENE
};
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
for (uint i = 0; i < ARRAYSIZE(MM_INVALID_TRAVEL_LOCATIONS); ++i)
_vm->_travel[MM_INVALID_TRAVEL_LOCATIONS[i]] = 0;
}
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 3d88141652d..70ab7c79a7a 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -84,7 +84,7 @@ void EventsManager::setCursor(CursorType cursorId) {
cursorSurface.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
byte *destP = (byte *)cursorSurface.getPixels();
- if (_vm->getGameID() != kGameNoctropolis) {
+ if (!_vm->gameIs(kGameNoctropolis)) {
Common::fill(destP, destP + width * height, 0);
// Loop to build up the cursor
for (int y = 0; y < height; ++y) {
@@ -313,7 +313,7 @@ void EventsManager::nextTimer() {
_vm->_animation->updateTimers();
_vm->_timers.updateTimers();
_vm->_player->updateTimers();
- if (_vm->getGameID() == kGameNoctropolis)
+ if (_vm->gameIs(kGameNoctropolis))
((Noctropolis::NoctropolisEngine *)_vm)->_stil->updateTimers();
}
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index b31aa2db5fe..6d690158d9c 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -99,7 +99,7 @@ Resource *FileManager::loadFile(int fileNum, int subfile) {
// Noctropolis remastered has music in OGG or MID format broken
// out into the individual files.
- if (_vm->getGameID() == kGameNoctropolis && fileNum == 98 && !SearchMan.hasFile(filepath)) {
+ if (_vm->gameIs(kGameNoctropolis) && fileNum == 98 && !SearchMan.hasFile(filepath)) {
Common::Path path = Common::Path(Common::String::format("MUSIC/M%02d.mid", subfile));
// TODO: Also check for OGG file here. Make it a configuration
// variable - originally hidef_music, default true.
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index faa4cd35ce3..1a4290deb5f 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -204,7 +204,7 @@ void InventoryManager::showAllItems() {
}
void InventoryManager::putInvIcon(int itemIndex, int itemId) {
- SpriteResource *spr = _vm->_objectsTable[99];
+ const SpriteResource *spr = _vm->_objectsTable[99];
assert(spr);
Common::Point pt((itemIndex % 6) * 46 + 23, (itemIndex / 6) * 35 + 15);
_vm->_buffer2.plotImage(spr, itemId, pt);
@@ -309,7 +309,7 @@ void InventoryManager::combineItems() {
Common::Point lastBox(inv.left, inv.top);
_vm->_buffer2.copyBlock(&_vm->_buffer1, r);
- SpriteResource *sprites = _vm->_objectsTable[99];
+ const SpriteResource *sprites = _vm->_objectsTable[99];
int invItem = _items[_boxNum];
events.pollEvents();
@@ -377,7 +377,7 @@ void InventoryManager::combineItems() {
void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool shrink) {
Screen &screen = *_vm->_screen;
screen._screenYOff = 0;
- SpriteResource *sprites = _vm->_objectsTable[99];
+ const SpriteResource *sprites = _vm->_objectsTable[99];
int oldScale = _vm->_scale;
int zoomScale = shrink ? 255 : 1;
diff --git a/engines/access/martian/martian_duct.cpp b/engines/access/martian/martian_duct.cpp
index c3833b1ba50..3e997b53a6b 100644
--- a/engines/access/martian/martian_duct.cpp
+++ b/engines/access/martian/martian_duct.cpp
@@ -60,8 +60,7 @@ void MartianDuct::doDuct() {
_vm->_events->hideCursor();
_vm->_files->loadScreen(20, 0);
- Resource *res = _vm->_files->loadFile(20, 1);
- _vm->_objectsTable[20] = new SpriteResource(_vm, res);
+ _vm->_objectsTable[20] = new SpriteResource(_vm, 20, 1);
if (_vm->_inventory->_inv[40]._value == ITEM_IN_INVENTORY) {
// Show map if we have it.
_vm->_screen->plotImage(_vm->_objectsTable[20], 8, Common::Point(140, 10));
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
index 65c8a81e9a5..58bdeb26401 100644
--- a/engines/access/martian/martian_game.cpp
+++ b/engines/access/martian/martian_game.cpp
@@ -243,9 +243,7 @@ void MartianEngine::doCredits() {
_screen->setDisplayScan();
_events->hideCursor();
_screen->forceFadeOut();
- Resource *data = _files->loadFile(41, 1);
- _objectsTable[41] = new SpriteResource(this, data);
- delete data;
+ _objectsTable[41] = new SpriteResource(this, 41, 1);
_files->loadScreen(41, 0);
_buffer2.copyFrom(*_screen);
diff --git a/engines/access/martian/martian_scripts.cpp b/engines/access/martian/martian_scripts.cpp
index 9930694c1e4..7bcc031b3c8 100644
--- a/engines/access/martian/martian_scripts.cpp
+++ b/engines/access/martian/martian_scripts.cpp
@@ -206,15 +206,11 @@ void MartianScripts::cmdSpecial7() {
_vm->_screen->forceFadeIn();
// Load objects specific to this special scene
- Resource *data = _vm->_files->loadFile(40, 2);
- _game->_objectsTable[40] = new SpriteResource(_vm, data);
- delete data;
+ _game->_objectsTable[40] = new SpriteResource(_vm, 40, 2);
// Load animation data
_vm->_animation->freeAnimationData();
- Resource *animResource = _vm->_files->loadFile(40, 1);
- _vm->_animation->loadAnimations(animResource);
- delete animResource;
+ _vm->_animation->loadAnimations(40, 1);
// Load script
Resource *newScript = _vm->_files->loadFile(40, 0);
diff --git a/engines/access/metaengine.cpp b/engines/access/metaengine.cpp
index 309663aa331..1bbd13030a3 100644
--- a/engines/access/metaengine.cpp
+++ b/engines/access/metaengine.cpp
@@ -49,6 +49,10 @@ AccessGameType AccessEngine::getGameID() const {
return (AccessGameType)(_gameDescription->gameID);
}
+bool AccessEngine::gameIs(AccessGameType game) const {
+ return getGameID() == game;
+}
+
uint32 AccessEngine::getGameFeatures() const {
return _gameDescription->features;
}
diff --git a/engines/access/noctropolis/noctropolis_game.cpp b/engines/access/noctropolis/noctropolis_game.cpp
index 0d8b2380cc7..18e423f233c 100644
--- a/engines/access/noctropolis/noctropolis_game.cpp
+++ b/engines/access/noctropolis/noctropolis_game.cpp
@@ -327,15 +327,13 @@ void NoctropolisEngine::doIntro() {
_midi->loadMusic(98, 1);
_midi->midiPlay();
- _room->loadPlayField(1, 0);
+ _room->loadPlayField(FileIdent(1, 0));
// This ignores window values, but we know that's ok here.
_buffer2.copyFrom(*_screen);
_buffer1.copyFrom(*_screen);
- Resource *spriteRes = _files->loadFile(1, 1);
- SpriteResource *sprites = new SpriteResource(this, spriteRes);
- delete spriteRes;
+ SpriteResource *sprites = new SpriteResource(this, 1, 1);
// TODO: Check these fades
_screen->setPalette();
@@ -438,7 +436,7 @@ void NoctropolisEngine::doTravel() {
_buffer1.clear();
_buffer2.clear();
_screen->clearScreen();
- _room->loadPlayField(0, 0); // MAP.AP
+ _room->loadPlayField(FileIdent(0, 0)); // MAP.AP
_screen->setPalette();
_screen->setIconPalette();
_scrollRow = _travScrollRow;
@@ -446,9 +444,7 @@ void NoctropolisEngine::doTravel() {
_scrollX = _travScrollX;
_scrollY = _travScrollY;
// Load MAP.AP
- Resource *spriteData = _files->loadFile(0, 1);
- _objectsTable[0] = new SpriteResource(this, spriteData);
- delete spriteData;
+ _objectsTable[0] = new SpriteResource(this, 0, 1);
// This section is "state 1" in NoctTravelEngine::ticker
((NoctropolisRoom *)_room)->buildScreenXScroll();
diff --git a/engines/access/noctropolis/noctropolis_player.cpp b/engines/access/noctropolis/noctropolis_player.cpp
index d21f0176e73..2bf407cf8f8 100644
--- a/engines/access/noctropolis/noctropolis_player.cpp
+++ b/engines/access/noctropolis/noctropolis_player.cpp
@@ -64,9 +64,7 @@ void NoctropolisPlayer::load() {
void NoctropolisPlayer::loadAnimation(int fileNum, int subFile) {
if (!_animManager)
_animManager = new AnimationManager(_vm);
- Resource *data = _vm->_files->loadFile(fileNum, subFile);
- _animManager->loadAnimations(data);
- delete data;
+ _animManager->loadAnimations(fileNum, subFile);
}
/*
diff --git a/engines/access/noctropolis/noctropolis_room.cpp b/engines/access/noctropolis/noctropolis_room.cpp
index e75a26b183c..a6012ab8881 100644
--- a/engines/access/noctropolis/noctropolis_room.cpp
+++ b/engines/access/noctropolis/noctropolis_room.cpp
@@ -77,10 +77,8 @@ void NoctropolisRoom::loadPlayer1() {
_vm->_player->loadNoctPalette(fileNum, _palIntensity + palOffset);
((NoctropolisPlayer *)_vm->_player)->loadAnimation(fileNum, 0);
- for (int i = subFileBase; i <= numSubFiles; i++) {
- Resource *data = _vm->_files->loadFile(fileNum, i);
- _vm->_objectsTable[objBase + i - subFileBase] = new SpriteResource(_vm, data);
- }
+ for (int i = subFileBase; i <= numSubFiles; i++)
+ _vm->_objectsTable[objBase + i - subFileBase] = new SpriteResource(_vm, fileNum, i);
}
}
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 357300e0b49..c6cbeff2443 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -136,7 +136,7 @@ void Player::load() {
_playerSprites = _playerSprites1;
if (_manPal1) {
- if (_vm->getGameID() == kGameNoctropolis) {
+ if (_vm->gameIs(kGameNoctropolis)) {
//if (_vm->_room->_roomFlag & kRoomFlagStiletto) {
// Common::copy(_manPal1 + 0x1e0, _manPal1 + 0x1e0 + 99, _vm->_screen->_stilPal);
//}
@@ -200,7 +200,7 @@ void Player::removeSprite1() {
bool Player::isMMHover() const {
// Whether or not this is MM and the player is on the hoverboard.
- return (_vm->getGameID() == kGameMartianMemorandum &&
+ return (_vm->gameIs(kGameMartianMemorandum) &&
_vm->_flags[174] == 1);
}
@@ -211,7 +211,7 @@ void Player::calcManScale() {
_vm->_screen->setScaleTable(_vm->_scale);
_playerOffset.x = _vm->_screen->_scaleTable1[20];
- _playerOffset.y = _vm->_screen->_scaleTable1[(_vm->getGameID() == kGameMartianMemorandum) ? 62 : 67];
+ _playerOffset.y = _vm->_screen->_scaleTable1[(_vm->gameIs(kGameMartianMemorandum)) ? 62 : 67];
_inactiveYOff = _playerOffset.y;
}
}
@@ -260,7 +260,7 @@ void Player::jetpack() {
void Player::walk() {
_collideFlag = false;
- if (_vm->getGameID() == kGameMartianMemorandum && _vm->_flags[173] == 1) {
+ if (_vm->gameIs(kGameMartianMemorandum) && _vm->_flags[173] == 1) {
// Special case for MM Jetpack
jetpack();
return;
@@ -344,9 +344,10 @@ void Player::walkUp() {
calcManScale();
- if (_vm->getGameID() == kGameMartianMemorandum && _vm->_flags[174] == 0 && (_frame == 8 || _frame == 12))
+ // Note: Flag 174 is Hoverboard.
+ if (_vm->gameIs(kGameMartianMemorandum) && _vm->_flags[174] == 0 && (_frame == 8 || _frame == 12))
_vm->_sound->playSound(0);
- else if (_vm->getGameID() == kGameAmazon && _vm->_currentMan != 3 && (_frame == 17 || _frame == 21))
+ else if (_vm->gameIs(kGameAmazon) && _vm->_currentMan != 3 && (_frame == 17 || _frame == 21))
_vm->_sound->playSound(0);
if (++_frame > _upWalkMax)
@@ -375,9 +376,9 @@ void Player::walkDown() {
calcManScale();
- if (_vm->getGameID() == kGameMartianMemorandum && _vm->_flags[174] == 0 && (_frame == 17 || _frame == 21))
+ if (_vm->gameIs(kGameMartianMemorandum) && _vm->_flags[174] == 0 && (_frame == 17 || _frame == 21))
_vm->_sound->playSound(0);
- else if (_vm->getGameID() == kGameAmazon && _vm->_currentMan != 3 && (_frame == 10 || _frame == 14))
+ else if (_vm->gameIs(kGameAmazon) && _vm->_currentMan != 3 && (_frame == 10 || _frame == 14))
_vm->_sound->playSound(0);
if (++_frame > _downWalkMax)
@@ -417,9 +418,9 @@ void Player::walkLeft() {
_rawPlayerLow.x = _rawTempL;
++_frame;
- if (_vm->getGameID() == kGameMartianMemorandum && _vm->_flags[174] == 0 && (_frame == 7 || _frame == 3))
+ if (_vm->gameIs(kGameMartianMemorandum) && _vm->_flags[174] == 0 && (_frame == 7 || _frame == 3))
_vm->_sound->playSound(0);
- else if (_vm->getGameID() == kGameAmazon && _vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
+ else if (_vm->gameIs(kGameAmazon) && _vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
_vm->_sound->playSound(0);
if (_frame > _sideWalkMax)
@@ -459,9 +460,9 @@ void Player::walkRight() {
_rawPlayerLow.x = _rawTempL;
++_frame;
- if (_vm->getGameID() == kGameMartianMemorandum && _vm->_flags[174] == 0 && (_frame == 7 || _frame == 3))
+ if (_vm->gameIs(kGameMartianMemorandum) && _vm->_flags[174] == 0 && (_frame == 7 || _frame == 3))
_vm->_sound->playSound(0);
- else if (_vm->getGameID() == kGameAmazon && _vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
+ else if (_vm->gameIs(kGameAmazon) && _vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
_vm->_sound->playSound(0);
// Useless check removed
@@ -749,11 +750,11 @@ void Player::plotCom(int flags) {
}
void Player::plotCom0() {
- plotCom(_vm->getGameID() == kGameAmazon ? 0 : IMGFLAG_BACKWARDS);
+ plotCom(_vm->gameIs(kGameAmazon) ? 0 : IMGFLAG_BACKWARDS);
}
void Player::plotCom1() {
- plotCom(_vm->getGameID() == kGameAmazon ? IMGFLAG_BACKWARDS : 0);
+ plotCom(_vm->gameIs(kGameAmazon) ? IMGFLAG_BACKWARDS : 0);
}
void Player::plotCom2() {
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index d4a8f327e47..00d609c3719 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -29,11 +29,11 @@
namespace Access {
Resources *Resources::init(AccessEngine *vm) {
- if (vm->getGameID() == kGameAmazon)
+ if (vm->gameIs(kGameAmazon))
return new Amazon::AmazonResources(vm);
- else if (vm->getGameID() == kGameMartianMemorandum)
+ else if (vm->gameIs(kGameMartianMemorandum))
return new Martian::MartianResources(vm);
- else if (vm->getGameID() == kGameNoctropolis)
+ else if (vm->gameIs(kGameNoctropolis))
return new Noctropolis::NoctropolisResources(vm);
error("Unknown game");
@@ -101,7 +101,7 @@ bool Resources::load(Common::U32String &errorMessage) {
void Resources::load(Common::SeekableReadStream &s) {
uint count;
- assert(_vm->getGameID() != kGameNoctropolis);
+ assert(!_vm->gameIs(kGameNoctropolis));
// Get the offset of the data for the game
uint entryOffset = findEntry(_vm->getGameID(), _vm->isCD() ? 1 : 0,
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 15b0a3e8c58..097e514e212 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -166,8 +166,8 @@ void Room::doRoom() {
bool reloadFlag = false;
// Noctropolis doesn't have an icon bar at the bottom, so never set arrow cursor
- int mouseCursorArrowYThreshold = (_vm->getGameID() == kGameMartianMemorandum) ? 184 :
- ((_vm->getGameID() == kGameAmazon) ? 177 : 1000);
+ int mouseCursorArrowYThreshold = (_vm->gameIs(kGameMartianMemorandum)) ? 184 :
+ ((_vm->gameIs(kGameAmazon)) ? 177 : 1000);
while (!_vm->shouldQuit()) {
if (!reloadFlag) {
@@ -210,11 +210,11 @@ void Room::doRoom() {
_vm->_scripts->_continuenceFlag = false;
} else*/
{
- if ((_vm->getGameID() == kGameMartianMemorandum) && (_vm->_player->_roomNumber == 47)) {
+ if ((_vm->gameIs(kGameMartianMemorandum)) && (_vm->_player->_roomNumber == 47)) {
takePicture();
} else {
_vm->_player->walk();
- if (_vm->getGameID() == kGameNoctropolis)
+ if (_vm->gameIs(kGameNoctropolis))
((Noctropolis::NoctropolisEngine *)_vm)->stilWalk();
_vm->_midi->midiRepeat();
_vm->_player->checkScroll();
@@ -230,7 +230,7 @@ void Room::doRoom() {
// DOROOMFLASHBACK jump point in Amazon
// NoctRoomEngine::afterDoCommandsTick in Noctropolis
- if (_vm->getGameID() == kGameNoctropolis) {
+ if (_vm->gameIs(kGameNoctropolis)) {
// TODO: Need to check the
if (_vm->_flags[200] && !_vm->_timers[0x12]._flag) {
warning("TODO: Work out when to call DeadMeat1");
@@ -238,20 +238,20 @@ void Room::doRoom() {
}
if (_function == FN_CLEAR1) {
- if (_vm->getGameID() == kGameNoctropolis)
+ if (_vm->gameIs(kGameNoctropolis))
_vm->_screen->fadeOut();
clearRoom();
break;
} else if (_function == FN_CLEAR2) {
clearRoom();
- if (_vm->getGameID() == kGameNoctropolis)
+ if (_vm->gameIs(kGameNoctropolis))
((Noctropolis::NoctropolisEngine *)_vm)->doTravel();
return;
} else if (_function == FN_RELOAD) {
reloadRoom1();
// WORKAROUND: This doesn't seem to restore the palette
// correctly in MM abduction scene (special 0)
- if (_vm->getGameID() == kGameMartianMemorandum)
+ if (_vm->gameIs(kGameMartianMemorandum))
_vm->_screen->setPalette();
reloadFlag = true;
break;
@@ -349,7 +349,7 @@ void Room::loadRoomData(const byte *roomData) {
_roomFlag = roomInfo._roomFlag;
_palIntensity = roomInfo._palIntensity;
- if (_vm->getGameID() == kGameNoctropolis && _roomFlag & kRoomFlagStiletto) {
+ if (_vm->gameIs(kGameNoctropolis) && _roomFlag & kRoomFlagStiletto) {
// Load _vm->_screen->_stilPal
Resource *stilPal = _vm->_files->loadFile(0xfd, _palIntensity + 6);
const byte *stilPalData = stilPal->data();
@@ -360,11 +360,8 @@ void Room::loadRoomData(const byte *roomData) {
Player *stil = ((Noctropolis::NoctropolisEngine *)_vm)->_stil;
((Noctropolis::NoctropolisPlayer *)stil)->loadAnimation(0xfd, 0);
- for (int subFileNum = 1; subFileNum < 6; subFileNum++) {
- Resource *data = _vm->_files->loadFile(0xfd, subFileNum);
- _vm->_objectsTable[0x6d + subFileNum] = new SpriteResource(_vm, data);
- delete data;
- }
+ for (int subFileNum = 1; subFileNum < 6; subFileNum++)
+ _vm->_objectsTable[0x6d + subFileNum] = new SpriteResource(_vm, 0xfd, subFileNum);
}
_vm->_establishFlag = false;
@@ -391,8 +388,7 @@ void Room::loadRoomData(const byte *roomData) {
_vm->_scaleT1 = ((_vm->_scaleH1 - _vm->_scaleH2) << 8) / _vm->_scaleN1;
if (roomInfo._playFieldFile._fileNum != -1) {
- loadPlayField(roomInfo._playFieldFile._fileNum,
- roomInfo._playFieldFile._subFile);
+ loadPlayField(roomInfo._playFieldFile);
setupRoom();
_vm->_scaleMaxY = _playFieldHeight << 4;
@@ -411,9 +407,7 @@ void Room::loadRoomData(const byte *roomData) {
// Load animation data
_vm->_animation->freeAnimationData();
if (roomInfo._animFile._fileNum != -1) {
- Resource *anim = _vm->_files->loadFile(roomInfo._animFile);
- _vm->_animation->loadAnimations(anim);
- delete anim;
+ _vm->_animation->loadAnimations(roomInfo._animFile._fileNum, roomInfo._animFile._subFile);
}
_vm->_scale = _vm->_scaleI = roomInfo._scaleI;
@@ -476,7 +470,7 @@ void Room::setupRoom() {
screen.setScaleTable(_vm->_scale);
screen.setBufferScan();
- if (_roomFlag != 2 || _vm->getGameID() == kGameNoctropolis)
+ if (_roomFlag != 2 || _vm->gameIs(kGameNoctropolis))
screen.setIconPalette();
if (screen._vWindowWidth == _playFieldWidth) {
@@ -623,8 +617,8 @@ static void loadHeader(RoomHeader &hdr, Common::SeekableReadStream *stream, uint
}
}
-void Room::loadPlayField(int fileNum, int subfile) {
- Resource *playData = _vm->_files->loadFile(fileNum, subfile);
+void Room::loadPlayField(const FileIdent &file) {
+ Resource *playData = _vm->_files->loadFile(file);
RoomHeader header;
loadHeader(header, playData->_stream, _vm->getGameID());
@@ -634,7 +628,7 @@ void Room::loadPlayField(int fileNum, int subfile) {
screen.loadRawPalette(playData->_stream);
// WORKAROUND: Screen 46 in Noctropolis has a color 0 of (0, 0, 63) which
// causes the background to be blue?
- if (_vm->getGameID() == kGameNoctropolis && fileNum == 46) {
+ if (_vm->gameIs(kGameNoctropolis) && file._fileNum == 46) {
screen.clearColor0();
}
@@ -646,7 +640,7 @@ void Room::loadPlayField(int fileNum, int subfile) {
// Copy off the playfield data
_matrixSize = (int)header._tilesWidth * header._tilesHeight;
_playField = new uint16[_matrixSize];
- if (_vm->getGameID() == kGameNoctropolis) {
+ if (_vm->gameIs(kGameNoctropolis)) {
for (int i = 0; i < _matrixSize; i++) {
_playField[i] = playData->_stream->readUint16LE();
}
@@ -729,7 +723,7 @@ void Room::doCommands() {
handleCommand(7);
} else if (_vm->_events->_leftButton) {
- if (_vm->getGameID() != kGameNoctropolis && _vm->_events->_mouseRow >= 22) {
+ if (!_vm->gameIs(kGameNoctropolis) && _vm->_events->_mouseRow >= 22) {
// Mouse in user interface area
for (commandId = 0; commandId < 10; ++commandId) {
if (_vm->_events->_mousePos.x >= _rMouse[commandId][0] &&
@@ -776,7 +770,7 @@ void Room::handleCommand(int commandId) {
// Only open if allowed at the moment.
if (_vm->_canSaveLoad)
_vm->openMainMenuDialog();
- } else if ((commandId == 9) || (_vm->getGameID() == kGameNoctropolis && commandId == 10)) {
+ } else if ((commandId == 9) || (_vm->gameIs(kGameNoctropolis) && commandId == 10)) {
// Open Options menu (in all games)
// NOTE: In Noctropolis we map both "Options" and "Disk" to this.
// If we implement original dialogs we can split these cases.
@@ -799,7 +793,7 @@ void Room::executeCommand(int commandId) {
Screen &screen = *_vm->_screen;
_selectCommand = commandId;
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
switch (commandId) {
case 4:
events.setCursor(CURSOR_ARROW);
@@ -850,7 +844,7 @@ void Room::executeCommand(int commandId) {
events.setCursor(CURSOR_CROSSHAIRS);
break;
}
- } else if (_vm->getGameID() == kGameAmazon) {
+ } else if (_vm->gameIs(kGameAmazon)) {
switch (commandId) {
case 0:
case 1:
@@ -885,7 +879,7 @@ void Room::executeCommand(int commandId) {
break;
}
} else {
- assert(_vm->getGameID() == kGameNoctropolis);
+ assert(_vm->gameIs(kGameNoctropolis));
// See the code in NoctRoomEngine::afterDoCommandsTick / CheckCommand
if (commandId == Noctropolis::kNoctCmdInventory) {
while (!_vm->shouldQuitOrRestart()) {
@@ -946,16 +940,16 @@ void Room::executeCommand(int commandId) {
const SpriteResource *icons = _vm->getIcons();
// Draw the button as selected (except in Noctropolis)
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
screen.plotImage(icons, 0, Common::Point(5, 184));
screen.plotImage(icons, 1, Common::Point(155, 184));
- } else if (_vm->getGameID() == kGameAmazon) {
+ } else if (_vm->gameIs(kGameAmazon)) {
screen.plotImage(icons, 0, Common::Point(0, 177));
screen.plotImage(icons, 1, Common::Point(143, 177));
}
- if (_vm->getGameID() != kGameNoctropolis)
+ if (!_vm->gameIs(kGameNoctropolis))
screen.plotImage(icons, _selectCommand + 2,
- Common::Point(_rMouse[_selectCommand][0], (_vm->getGameID() == kGameMartianMemorandum) ? 184 : 176));
+ Common::Point(_rMouse[_selectCommand][0], (_vm->gameIs(kGameMartianMemorandum)) ? 184 : 176));
_vm->_screen->restoreScreen();
_vm->_boxSelect = true;
@@ -982,7 +976,7 @@ void Room::walkCursor() {
void Room::commandOff() {
_selectCommand = -1;
_vm->_events->forceSetCursor(CURSOR_CROSSHAIRS);
- if (_vm->getGameID() != kGameNoctropolis)
+ if (!_vm->gameIs(kGameNoctropolis))
roomMenu();
}
diff --git a/engines/access/room.h b/engines/access/room.h
index f165fc7ee1e..b73d634ecf8 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -69,6 +69,10 @@ enum RoomFlag {
class Room : public Manager {
+private:
+ Common::Array<JetFrame> _jetFrame;
+ int _matrixSize;
+
private:
void roomLoop();
@@ -131,21 +135,22 @@ protected:
virtual void mainAreaRClick() {};
virtual void walkCursor();
+
public:
+ int _rMouse[10][2];
+ byte _palIntensity;
+ uint16 *_playField;
Plotter _plotter;
- Common::Array<JetFrame> _jetFrame;
+ byte *_tile;
Function _function;
int _roomFlag;
- byte _palIntensity;
- uint16 *_playField;
- int _matrixSize;
int _playFieldWidth;
int _playFieldHeight;
- byte *_tile;
int _selectCommand;
bool _conFlag; // not the same as script->_continuenceFlag which is used in Noctropolis
- int _rMouse[10][2];
+
public:
+
Room(AccessEngine *vm);
virtual ~Room();
@@ -187,7 +192,7 @@ public:
*/
void handleCommand(int commandId);
- void loadPlayField(int fileNum, int subfile);
+ void loadPlayField(const FileIdent &file);
int checkBoxes1(const Common::Point &pt);
};
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 0ae13ff3bbc..8c77f1f4012 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -118,11 +118,11 @@ void Screen::setInitialPalettte() {
void Screen::setManPalette() {
// Player palette is colors 224~246 in MM
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
for (int i = 0; i < 0x42; i++) {
_rawPalette[0x2a0 + i] = PALETTE_6BIT_TO_8BIT(_manPal[i]);
}
- } else if (_vm->getGameID() == kGameNoctropolis) {
+ } else if (_vm->gameIs(kGameNoctropolis)) {
for (int i = 0; i < 0x84; i++) {
_rawPalette[0x240 + i] = PALETTE_6BIT_TO_8BIT(_manPal[i]);
}
@@ -130,7 +130,7 @@ void Screen::setManPalette() {
}
void Screen::setStilPalette() {
- assert(_vm->getGameID() == kGameNoctropolis);
+ assert(_vm->gameIs(kGameNoctropolis));
for (int i = 0; i < 99; i++) {
_rawPalette[0x1e0 + i] = PALETTE_6BIT_TO_8BIT(_stilPal[i]);
}
@@ -138,11 +138,11 @@ void Screen::setStilPalette() {
void Screen::setIconPalette() {
// Icon palette is colors 247~255
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
for (int i = 0; i < 0x1B; i++) {
_rawPalette[741 + i] = PALETTE_6BIT_TO_8BIT(Martian::ICON_PALETTE[i]);
}
- } else if (_vm->getGameID() == kGameNoctropolis) {
+ } else if (_vm->gameIs(kGameNoctropolis)) {
for (int i = 0; i < 60; i++) {
_rawPalette[708 + i] = Noctropolis::ICON_PALETTE[i];
}
@@ -165,7 +165,7 @@ void Screen::loadPalette(int fileNum, int subfile, int srcOffset) {
Resource *res = _vm->_files->loadFile(fileNum, subfile);
const byte *palette = res->data() + srcOffset;
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
for (int i = 0; i < _numColors * 3; i++)
_rawPalette[_startColor * 3 + i] = PALETTE_6BIT_TO_8BIT(palette[i]);
} else {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index debbd6b6775..81968b3dfe2 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -44,6 +44,7 @@ Scripts::Scripts(AccessEngine *vm) : Manager(vm) {
_choiceStart = 0;
_charsOrg = Common::Point(0, 0);
_texsOrg = Common::Point(0, 0);
+ _keepAskPosition = false;
setOpcodes();
}
@@ -326,7 +327,7 @@ void Scripts::cmdObject() {
void Scripts::cmdEndObject() {
const char *msg = _vm->_res->getGeneralMessage(_vm->_room->_selectCommand);
debugC(1, kDebugScripts, "cmdEndObject(msg=\"%s\")", msg);
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
doCmdPrint_v1(msg);
cmdRetPos();
} else {
@@ -487,7 +488,7 @@ void Scripts::cmdPrint_v2() {
Common::String msg = _data->readString();
debugC(1, kDebugScripts, "cmdPrint_v2(msg=\"%s\")", msg.c_str());
printString(msg);
- //if (_vm->getGameID() == kGameNoctropolis) ??
+ //if (_vm->gameIs(kGameNoctropolis)) ??
// _continuenceFlag = true;
}
@@ -509,7 +510,7 @@ void Scripts::cmdPrint_v1() {
}
void Scripts::printString(const Common::String &msg, Common::Point pt) {
- if (_vm->getGameID() == kGameNoctropolis) {
+ if (_vm->gameIs(kGameNoctropolis)) {
if (pt.x == -1)
pt = Common::Point(320, 200);
_vm->_screen->_printOrg = _vm->_screen->_printStart = pt;
@@ -604,7 +605,7 @@ void Scripts::cmdSetInventory() {
_vm->_inventory->_startInvBox = 0;
_vm->_inventory->_invChangeFlag = true;
- if (itemVal == 1 && _vm->getGameID() == kGameNoctropolis) {
+ if (itemVal == 1 && _vm->gameIs(kGameNoctropolis)) {
((Noctropolis::NoctropolisEngine *)_vm)->playInventoryStinger();
}
}
@@ -664,7 +665,7 @@ void Scripts::cmdNewRoom() {
_vm->_room->_function = FN_CLEAR1;
_vm->freeChar();
- if (_vm->getGameID() == kGameNoctropolis) {
+ if (_vm->gameIs(kGameNoctropolis)) {
_vm->_room->_selectCommand = 0;
_vm->_events->setCursor(CURSOR_ARROW);
}
@@ -777,7 +778,7 @@ void Scripts::cmdDispInv_v1() {
debugC(1, kDebugScripts, "cmdDispInv_v1()");
_vm->_inventory->displayInv();
- if (_vm->getGameID() == kGameNoctropolis)
+ if (_vm->gameIs(kGameNoctropolis))
_continuenceFlag = true;
}
@@ -829,7 +830,7 @@ void Scripts::cmdCheckTimer() {
if (_endFlag)
return;
- if (_vm->getGameID() == kGameAmazon && idx == 9 && _vm->_events->isKeyActionPending()) {
+ if (_vm->gameIs(kGameAmazon) && idx == 9 && _vm->_events->isKeyActionPending()) {
_vm->_events->zeroKeysActions();
_vm->_timers[9]._timer = 0;
_vm->_timers[9]._flag = 0;
@@ -934,7 +935,7 @@ void Scripts::cmdSetVideo_v3() {
void Scripts::cmdPlayVideo() {
debugC(1, kDebugScripts, "cmdPlayVideo()");
_vm->_video->playVideo();
- if (_vm->getGameID() == kGameNoctropolis)
+ if (_vm->gameIs(kGameNoctropolis))
_continuenceFlag = true;
}
@@ -1076,29 +1077,31 @@ void Scripts::cmdDoTravel_Noct() {
void Scripts::cmdHelp_v1() {
debugC(1, kDebugScripts, "cmdHelp_v1()");
+
+ BubbleBox &helpBox = *_vm->_helpBox;
int idx = 0;
for (int i = 0; i < 40; i++) {
byte c = _data->readByte();
if (c != 0xFF) {
Common::String tmpStr = c + _data->readString();
if (Martian::HELP[i]) {
- _vm->_helpBox->_tempList[idx] = tmpStr;
- _vm->_helpBox->_tempListIdx[idx] = i;
+ helpBox._tempList[idx] = tmpStr;
+ helpBox._tempListIdx[idx] = i;
++idx;
}
} else
break;
}
- _vm->_helpBox->_tempList[idx] = "";
+ helpBox._tempList[idx] = "";
int btnSelected = 0;
- int boxX = _vm->_helpBox->doBox_v1(0, 0, btnSelected);
+ int boxX = helpBox.doBox_v1(0, 0, btnSelected);
if (boxX == -1)
btnSelected = 2;
if (btnSelected != 2)
- _vm->_useItem = _vm->_helpBox->_tempListIdx[boxX];
+ _vm->_useItem = helpBox._tempListIdx[boxX];
else
_vm->_useItem = -1;
}
@@ -1129,7 +1132,7 @@ void Scripts::cmdSpecial() {
AccessGameType game = _vm->getGameID();
if ((game == kGameAmazon && _specialFunction == 1) || game == kGameMartianMemorandum) {
- if (_vm->getGameID() == kGameAmazon && _vm->_establishTable[p2])
+ if (_vm->gameIs(kGameAmazon) && _vm->_establishTable[p2])
return;
_vm->_screen->savePalette();
@@ -1143,7 +1146,7 @@ void Scripts::cmdSpecial() {
// WORKAROUND: This fixes scene establishment being re-shown
// when restoring savegames in rooms which have one
- if (_vm->getGameID() == kGameAmazon && !_vm->isCD())
+ if (_vm->gameIs(kGameAmazon) && !_vm->isCD())
_vm->_establishTable[p2] = true;
}
}
@@ -1220,7 +1223,7 @@ void Scripts::cmdPlayerSpeak() {
void Scripts::cmdPlayerChoice() {
// This is similar to cmdTexChoice but used in Noctropolis
- assert(_vm->getGameID() == kGameNoctropolis);
+ assert(_vm->gameIs(kGameNoctropolis));
int16 x = _data->readUint16LE();
int16 startY = _data->readUint16LE();
@@ -1274,7 +1277,7 @@ void Scripts::cmdPlayerChoice() {
void Scripts::cmdTexSpeak() {
_vm->_screen->_printOrg = _texsOrg;
_vm->_screen->_printStart = _texsOrg;
- _vm->_screen->_maxChars = (_vm->getGameID() == kGameMartianMemorandum) ? 23 : 20;
+ _vm->_screen->_maxChars = (_vm->gameIs(kGameMartianMemorandum)) ? 23 : 20;
Common::String str = _data->readString();
debugC(1, kDebugScripts, "cmdTexSpeak(str=\"%s\")", str.c_str());
@@ -1293,7 +1296,7 @@ void Scripts::cmdTexChoice() {
_vm->_fonts._charSet._hi = 8;
_vm->_fonts._charFor._hi = 255;
- if (_vm->getGameID() == kGameMartianMemorandum) {
+ if (_vm->gameIs(kGameMartianMemorandum)) {
_vm->_fonts._charFor._lo = 247;
_vm->_screen->_maxChars = 23;
} else {
@@ -1312,7 +1315,7 @@ void Scripts::cmdTexChoice() {
_vm->_bubbleBox->calcBubble(tmpStr);
_vm->_bubbleBox->printBubble(tmpStr);
- const int responseYOff = (_vm->getGameID() == kGameMartianMemorandum) ? 20 : 11;
+ const int responseYOff = (_vm->gameIs(kGameMartianMemorandum)) ? 20 : 11;
Common::Array<Common::Rect> responseCoords;
responseCoords.push_back(_vm->_bubbleBox->_bounds);
@@ -1355,7 +1358,7 @@ void Scripts::cmdTexChoice() {
_vm->_bubbleBox->_bubbleDisplStr = _vm->_bubbleBox->_bubbleTitle;
if (_vm->_events->_leftButton) {
- if (_vm->_events->_mouseRow >= ((_vm->getGameID() == kGameMartianMemorandum) ? 23 : 22)) {
+ if (_vm->_events->_mouseRow >= ((_vm->gameIs(kGameMartianMemorandum)) ? 23 : 22)) {
_vm->_events->debounceLeft();
int x = _vm->_events->_mousePos.x;
choice = _vm->_res->inButtonXRange(x);
@@ -1390,7 +1393,7 @@ void Scripts::cmdWait() {
_vm->_events->debounceLeft();
_vm->_events->zeroKeysActions();
- if (_vm->getGameID() == kGameNoctropolis)
+ if (_vm->gameIs(kGameNoctropolis))
_continuenceFlag = true;
}
@@ -1453,7 +1456,7 @@ void Scripts::cmdFreeSound() {
if (sound.hasSounds()) {
// Keep doing char display loop if playing sound for it
do {
- if (_vm->getGameID() == kGameAmazon && _vm->_flags[236] == 1)
+ if (_vm->gameIs(kGameAmazon) && _vm->_flags[236] == 1)
charLoop();
_vm->_events->pollEvents();
@@ -1540,20 +1543,20 @@ void Scripts::cmdDispAbout_v3() {
SpriteResource *askSprites = new SpriteResource(_vm, spriteData);
delete spriteData;
- if (!_vm->_keepAskPosition) {
+ if (!_keepAskPosition) {
for (int i = 0; i < 40; i++)
_vm->_asked[i] = false;
int16 warpMouseX, warpMouseY;
- _vm->_askBase.x = _vm->_events->clipMouseCenter(_vm->_events->_mousePos.x, 226, 640, warpMouseX);
- _vm->_askBase.y = _vm->_events->clipMouseCenter(_vm->_events->_mousePos.y, 145, 400, warpMouseY);
+ _askBase.x = _vm->_events->clipMouseCenter(_vm->_events->_mousePos.x, 226, 640, warpMouseX);
+ _askBase.y = _vm->_events->clipMouseCenter(_vm->_events->_mousePos.y, 145, 400, warpMouseY);
- _vm->_keepAskPosition = true;
+ _keepAskPosition = true;
if (warpMouseX != _vm->_events->_mousePos.x || warpMouseY != _vm->_events->_mousePos.y)
g_system->warpMouse(warpMouseX, warpMouseY);
}
- const Common::Point base = _vm->_askBase;
+ const Common::Point base = _askBase;
// Build the list of available ask items
for (int i = 0; i < 40; i++) {
@@ -1656,7 +1659,7 @@ void Scripts::cmdDispAbout_v3() {
} else if (_vm->_events->_rightButton) {
_vm->_events->debounceRight();
selectedItem = 255;
- _vm->_keepAskPosition = false;
+ _keepAskPosition = false;
}
_vm->_events->pollEventsAndWait();
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 52fe492827c..2148143a630 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -42,6 +42,14 @@ class Scripts : public Manager {
private:
int _specialFunction;
+ int _scriptCommand;
+ int _choice;
+ int32 _choiceStart;
+
+ // Game variables only ever used from inside scripts
+ Common::Point _askBase; // Noctropolis only
+ bool _keepAskPosition; // Noctropolis only
+ Common::Point _charsOrg, _texsOrg;
void clearWatch();
void printWatch();
@@ -182,10 +190,6 @@ public:
int _sequence;
bool _endFlag;
int _returnCode;
- int _scriptCommand;
- int _choice;
- int32 _choiceStart;
- Common::Point _charsOrg, _texsOrg;
int _continuenceType; // Only used in Noctropolis
bool _continuenceFlag; // Only set in Noctropolis (always false otherwise). See also room->_conFlag which is used in earlier games.
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 214cfcf742d..5102fbbef53 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -318,8 +318,8 @@ MusicManagerMIDI::MusicManagerMIDI(AccessEngine *vm) : MusicManager(vm), Audio::
//
switch (musicType) {
case MT_ADLIB: {
- if (_vm->getGameID() == kGameAmazon && !_vm->isDemo()) {
- Resource *midiDrvResource = _vm->_files->loadFile(92, 1);
+ if (_vm->gameIs(kGameAmazon) && !_vm->isDemo()) {
+ Resource *midiDrvResource = _vm->_files->loadFile(92, 1);
Common::MemoryReadStream *adLibInstrumentStream = new Common::MemoryReadStream(midiDrvResource->data(), midiDrvResource->_size);
_driver = Audio::MidiDriver_Miles_AdLib_create("", "", adLibInstrumentStream);
@@ -477,7 +477,7 @@ void MusicManagerMIDI::newMusic(int musicId, int mode) {
_isLooping = (mode == 2);
_tempMusic = _music;
stopSong();
- int musicFile = (_vm->getGameID() == kGameAmazon ? 97 : 98);
+ int musicFile = (_vm->gameIs(kGameAmazon) ? 97 : 98);
loadMusic(musicFile, musicId);
}
Commit: 471de6efcba914f3fc13b9e8fe1b421f267bb9bc
https://github.com/scummvm/scummvm/commit/471de6efcba914f3fc13b9e8fe1b421f267bb9bc
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2026-10-20T14:16:48+11:00
Commit Message:
ACCESS: Remove unused variable _charCol
Changed paths:
engines/access/bubble_box.cpp
engines/access/bubble_box.h
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index cf7d6216489..cc84f78f2ad 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -46,7 +46,6 @@ BubbleBox::BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w
_btnUpPos = Common::Rect(0, 0, 0, 0);
_btnDownPos = Common::Rect(0, 0, 0, 0);
_startItem = _startBox = 0;
- _charCol = 0;
_rowOff = 0;
}
@@ -455,11 +454,10 @@ void BubbleBox::doBox_v2(int item, int box) {
_startBox = box;
// Save state information
- FontVal charSet = fonts._charSet;
- FontVal charFor = fonts._charFor;
+ const FontVal charSet = fonts._charSet;
+ const FontVal charFor = fonts._charFor;
const Common::Point printOrg = screen._printOrg;
const Common::Point printStart = screen._printStart;
- int charCol = _charCol;
int rowOff = _rowOff;
_vm->_screen->saveScreen();
@@ -541,7 +539,6 @@ void BubbleBox::doBox_v2(int item, int box) {
fonts._charFor = charFor;
screen._printOrg = printOrg;
screen._printStart = printStart;
- _charCol = charCol;
_rowOff = rowOff;
_vm->_screen->restoreScreen();
}
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index 026713e8ac6..f71e506660e 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -49,7 +49,7 @@ enum BoxType {
class BubbleBox : public Manager {
private:
int _startItem, _startBox;
- int _charCol, _rowOff;
+ int _rowOff;
Common::Point _fileStart;
Common::Point _fileOff;
int _boxStartX, _boxStartY;
Commit: 0a9f2f104ea20b145e2b60f92dbfa24dff96a55f
https://github.com/scummvm/scummvm/commit/0a9f2f104ea20b145e2b60f92dbfa24dff96a55f
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2026-10-20T14:16:48+11:00
Commit Message:
ACCESS: Correctly treat static _fontColors as static
Changed paths:
engines/access/access.cpp
engines/access/amazon/amazon_game.cpp
engines/access/bubble_box.cpp
engines/access/inventory.cpp
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index a93f6dee223..4791bdddfca 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -363,10 +363,10 @@ void AccessEngine::printText(BaseSurface *s, const Common::String &msg) {
bool lastLine = _fonts._font2->getLine(lines, s->_maxChars * 6, line, width);
// Set font colors
- _fonts._font2->_fontColors[0] = 0;
- _fonts._font2->_fontColors[1] = 28;
- _fonts._font2->_fontColors[2] = 29;
- _fonts._font2->_fontColors[3] = 30;
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 28;
+ Font::_fontColors[2] = 29;
+ Font::_fontColors[3] = 30;
_fonts._font2->drawString(s, line, s->_printOrg);
s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 43daaeb4774..e47c3ee08bf 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -401,18 +401,18 @@ void AmazonEngine::helpTitle() {
AmazonResources &res = *(AmazonResources *)_res;
int width = _fonts._font2->stringWidth(_bubbleBox->_bubbleTitle);
int posX = 160 - (width / 2);
- _fonts._font2->_fontColors[0] = 0;
- _fonts._font2->_fontColors[1] = 33;
- _fonts._font2->_fontColors[2] = 34;
- _fonts._font2->_fontColors[3] = 35;
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 33;
+ Font::_fontColors[2] = 34;
+ Font::_fontColors[3] = 35;
_fonts._font2->drawString(_screen, _bubbleBox->_bubbleTitle, Common::Point(posX, 24));
width = _fonts._font2->stringWidth(res.HELPLVLTXT[_helpLevel]);
posX = 160 - (width / 2);
- _fonts._font2->_fontColors[0] = 0;
- _fonts._font2->_fontColors[1] = 10;
- _fonts._font2->_fontColors[2] = 11;
- _fonts._font2->_fontColors[3] = 12;
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 10;
+ Font::_fontColors[2] = 11;
+ Font::_fontColors[3] = 12;
_fonts._font2->drawString(_screen, res.HELPLVLTXT[_helpLevel], Common::Point(posX, 36));
Common::String iqText = "IQ: ";
@@ -433,10 +433,10 @@ void AmazonEngine::helpTitle() {
width = _fonts._font2->stringWidth(iqText);
posX = 160 - (width / 2);
- _fonts._font2->_fontColors[0] = 0;
- _fonts._font2->_fontColors[1] = 10;
- _fonts._font2->_fontColors[2] = 11;
- _fonts._font2->_fontColors[3] = 12;
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 10;
+ Font::_fontColors[2] = 11;
+ Font::_fontColors[3] = 12;
_fonts._font2->drawString(_screen, iqText, Common::Point(posX, 44));
}
@@ -453,10 +453,10 @@ void AmazonEngine::drawHelpText(const Common::String &msg) {
lastLine = _fonts._font2->getLine(lines, _screen->_maxChars * 6, line, width);
// Set font colors
- _fonts._font2->_fontColors[0] = 0;
- _fonts._font2->_fontColors[1] = 27;
- _fonts._font2->_fontColors[2] = 28;
- _fonts._font2->_fontColors[3] = 29;
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 27;
+ Font::_fontColors[2] = 28;
+ Font::_fontColors[3] = 29;
_fonts._font2->drawString(_screen, line, _screen->_printOrg);
_screen->_printOrg = Common::Point(_screen->_printStart.x, _screen->_printOrg.y + 8);
@@ -600,7 +600,7 @@ void AmazonEngine::startChapter(int chapter) {
_fonts._charSet._lo = 1;
_fonts._charSet._hi = 10;
_fonts._charFor._lo = 55;
- _fonts._charFor._hi = 0xFF;
+ _fonts._charFor._hi = 255;
_screen->_maxChars = 43;
_screen->_printOrg = Common::Point(31, 77);
_screen->_printStart = Common::Point(31, 77);
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index cc84f78f2ad..0b0ee9adb42 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -284,10 +284,10 @@ void BubbleBox::printBubble_v2(const Common::String &msg) {
lastLine = font2.getLine(s, _vm->_screen->_maxChars * 6, line, width);
// Set font colors
- font2._fontColors[0] = 0;
- font2._fontColors[1] = 27;
- font2._fontColors[2] = 28;
- font2._fontColors[3] = 29;
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 27;
+ Font::_fontColors[2] = 28;
+ Font::_fontColors[3] = 29;
int xp = _vm->_screen->_printOrg.x;
if (_type == kBoxTypeFileDialog)
@@ -527,10 +527,10 @@ void BubbleBox::doBox_v2(int item, int box) {
// Handle drawing title
int titleWidth = _vm->_fonts._font2->stringWidth(_bubbleDisplStr);
const Font &font2 = *_vm->_fonts._font2;
- font2._fontColors[0] = 0;
- font2._fontColors[1] = 3;
- font2._fontColors[2] = 2;
- font2._fontColors[3] = 1;
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 3;
+ Font::_fontColors[2] = 2;
+ Font::_fontColors[3] = 1;
font2.drawString(_vm->_screen, _bubbleDisplStr, Common::Point(
_bounds.left + (_bounds.width() / 2) - (titleWidth / 2), _bounds.top + 1));
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 1a4290deb5f..30a6cffe9a9 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -282,10 +282,10 @@ void InventoryManager::outlineIcon(int itemIndex) {
const Font &font = *_vm->_fonts._font2;
int strWidth = font.stringWidth(s);
- font._fontColors[0] = 0;
- font._fontColors[1] = 10;
- font._fontColors[2] = 11;
- font._fontColors[3] = 12;
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 10;
+ Font::_fontColors[2] = 11;
+ Font::_fontColors[3] = 12;
font.drawString(&screen, s, Common::Point((screen.w - strWidth) / 2, 184));
}
Commit: 366f5236f95acba7828f59b1908429be213604ab
https://github.com/scummvm/scummvm/commit/366f5236f95acba7828f59b1908429be213604ab
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2026-10-20T14:16:48+11:00
Commit Message:
ACCESS: More small code cleanups
* Switch to local references to avoid repeating the same _vm-> pattern too much
* Remove some redundant cursor hide/show pairs - these were needed in the
original but not in scummvm as clearing an area cannot corrupt the cursor for
us. Keep the cursor hides which are done before fades etc as they are
visible to the user.
Changed paths:
engines/access/bubble_box.cpp
engines/access/martian/martian_duct.cpp
engines/access/martian/martian_game.cpp
engines/access/martian/martian_room.cpp
engines/access/room.cpp
engines/access/scripts.cpp
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 0b0ee9adb42..76a40237584 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -55,38 +55,40 @@ void BubbleBox::load(Common::SeekableReadStream *stream) {
}
void BubbleBox::clearBubbles() {
+ Screen &screen = *_vm->_screen;
+
// Loop through the bubble list to restore the screen areas
if (_vm->getGameID() == kGameNoctropolis) {
for (Common::Rect r: _bubbles) {
// clear the areas outside the background if the bubble went outside it
- if (r.left < _vm->_screen->_windowXAdd || r.top < _vm->_screen->_windowYAdd) {
- _vm->_screen->fillRect(Common::Rect(0, 0, _vm->_screen->w, _vm->_screen->_windowYAdd), 0);
- _vm->_screen->fillRect(Common::Rect(0, 0, _vm->_screen->_windowXAdd, _vm->_screen->h), 0);
+ if (r.left < screen._windowXAdd || r.top < screen._windowYAdd) {
+ screen.fillRect(Common::Rect(0, 0, screen.w, screen._windowYAdd), 0);
+ screen.fillRect(Common::Rect(0, 0, screen._windowXAdd, screen.h), 0);
}
- if (r.right > _vm->_screen->w - _vm->_screen->_windowXAdd || r.bottom > _vm->_screen->h - _vm->_screen->_windowYAdd) {
- _vm->_screen->fillRect(Common::Rect(_vm->_screen->w - _vm->_screen->_windowXAdd, 0, _vm->_screen->w, _vm->_screen->h), 0);
- _vm->_screen->fillRect(Common::Rect(0, _vm->_screen->h - _vm->_screen->_windowYAdd, _vm->_screen->w, _vm->_screen->h), 0);
+ if (r.right > screen.w - screen._windowXAdd || r.bottom > screen.h - screen._windowYAdd) {
+ screen.fillRect(Common::Rect(screen.w - screen._windowXAdd, 0, screen.w, screen.h), 0);
+ screen.fillRect(Common::Rect(0, screen.h - screen._windowYAdd, screen.w, screen.h), 0);
}
- _vm->_screen->_screenYOff = 0;
- r.left -= (MIN((int)r.left, 2) + _vm->_screen->_windowXAdd);
- r.right = MIN(r.right, (int16)(_vm->_screen->w - _vm->_screen->_windowXAdd));
- r.top -= _vm->_screen->_windowYAdd;
- r.bottom -= _vm->_screen->_windowYAdd;
+ screen._screenYOff = 0;
+ r.left -= (MIN((int)r.left, 2) + screen._windowXAdd);
+ r.right = MIN(r.right, (int16)(screen.w - screen._windowXAdd));
+ r.top -= screen._windowYAdd;
+ r.bottom -= screen._windowYAdd;
- r.clip(Common::Rect(_vm->_screen->w, _vm->_screen->h));
+ r.clip(Common::Rect(screen.w, screen.h));
// then copy in the bit we need from the draw buffer.
- _vm->_screen->copyBlock(&_vm->_buffer2, r);
+ screen.copyBlock(&_vm->_buffer2, r);
}
} else {
for (Common::Rect r: _bubbles) {
- _vm->_screen->_screenYOff = 0;
+ screen._screenYOff = 0;
r.left -= 2;
- r.right = MIN(r.right, (int16)_vm->_screen->w);
+ r.right = MIN(r.right, (int16)screen.w);
- _vm->_screen->copyBlock(&_vm->_buffer1, r);
+ screen.copyBlock(&_vm->_buffer1, r);
}
}
@@ -580,15 +582,12 @@ void BubbleBox::displayBoxData() {
return;
}
- _vm->_events->hideCursor();
-
_vm->_screen->_orgX1 = _boxStartX;
_vm->_screen->_orgX2 = _boxEndX + 1;
_vm->_screen->_orgY1 = _boxStartY;
_vm->_screen->_orgY2 = _boxEndY;
_vm->_screen->_lColor = 0xFA;
_vm->_screen->drawRect();
- _vm->_events->showCursor();
}
_vm->_events->hideCursor();
@@ -627,7 +626,6 @@ void BubbleBox::drawSelectBox() {
return;
if (_vm->_boxSelectYOld != -1) {
- _vm->_events->hideCursor();
_vm->_screen->_lColor = 0xFA;
int val = _vm->_boxSelectYOld + _boxPStartY + 1;
@@ -636,10 +634,8 @@ void BubbleBox::drawSelectBox() {
_vm->_screen->_orgX1 = _boxStartX;
_vm->_screen->_orgX2 = _boxEndX;
_vm->_screen->drawBox();
- _vm->_events->showCursor();
}
- _vm->_events->hideCursor();
_vm->_boxSelectYOld = _vm->_boxSelectY;
int val = _boxPStartY + _vm->_boxSelectY + 1;
_vm->_screen->_orgY1 = (val << 3) + 2;
@@ -648,7 +644,6 @@ void BubbleBox::drawSelectBox() {
_vm->_screen->_orgX2 = _boxEndX;
_vm->_screen->_lColor = 0xFE;
_vm->_screen->drawBox();
- _vm->_events->showCursor();
if (_type == TYPE_3)
warning("TODO: List filenames");
@@ -658,19 +653,22 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
static constexpr int ICONW[] = { 0, 11, 28, 19, 19, 15 };
FontManager &fonts = _vm->_fonts;
+ EventsManager &events = *_vm->_events;
+ Screen &screen = *_vm->_screen;
+
int retval_ = -1;
_startItem = item;
_startBox = box;
- const Common::Point origPrintStart = _vm->_screen->_printStart;
- const Common::Point origPrintOrg = _vm->_screen->_printOrg;
+ const Common::Point origPrintStart = screen._printStart;
+ const Common::Point origPrintOrg = screen._printOrg;
- _vm->_events->hideCursor();
+ events.hideCursor();
// Save state information
- _vm->_screen->saveScreen();
- _vm->_screen->setDisplayScan();
+ screen.saveScreen();
+ screen.setDisplayScan();
fonts._charFor._hi = 0xff;
fonts._charSet._lo = 1;
@@ -681,62 +679,62 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
if (_type != TYPE_2) {
Common::Rect r = _bounds;
r.left -= 2;
- _vm->_screen->saveBlock(r);
+ screen.saveBlock(r);
}
// Set the up boundaries and color to use for the box background
- _vm->_screen->_orgX1 = _bounds.left - 2;
- _vm->_screen->_orgY1 = _bounds.top;
- _vm->_screen->_orgX2 = _bounds.right - 2;
- _vm->_screen->_orgY2 = _bounds.bottom;
- _vm->_screen->_lColor = 0xFB;
+ screen._orgX1 = _bounds.left - 2;
+ screen._orgY1 = _bounds.top;
+ screen._orgX2 = _bounds.right - 2;
+ screen._orgY2 = _bounds.bottom;
+ screen._lColor = 0xFB;
// Draw a background for the entire area
- _vm->_screen->drawRect();
+ screen.drawRect();
// Draw the inner box;
- ++_vm->_screen->_orgX1;
- ++_vm->_screen->_orgY1;
- _vm->_screen->_orgX2 -= 2;
- _vm->_screen->_orgY2 -= 2;
- _vm->_screen->_lColor = 0xF9;
+ ++screen._orgX1;
+ ++screen._orgY1;
+ screen._orgX2 -= 2;
+ screen._orgY2 -= 2;
+ screen._lColor = 0xF9;
// Draw the inner border
- _vm->_screen->drawBox();
+ screen.drawBox();
const SpriteResource *icons = _vm->getIcons();
// Draw upper border
- _vm->_bcnt = (_vm->_screen->_orgX2 - _vm->_screen->_orgX1) >> 4;
- int oldX = _vm->_screen->_orgX1;
+ _vm->_bcnt = (screen._orgX2 - screen._orgX1) >> 4;
+ int oldX = screen._orgX1;
for ( ;_vm->_bcnt > 0; --_vm->_bcnt) {
- _vm->_screen->plotImage(icons, 16, Common::Point(_vm->_screen->_orgX1, _vm->_screen->_orgY1));
- _vm->_screen->_orgX1 += 16;
+ screen.plotImage(icons, 16, Common::Point(screen._orgX1, screen._orgY1));
+ screen._orgX1 += 16;
}
- _vm->_screen->_orgX1 = oldX;
- int oldY = _vm->_screen->_orgY2;
- _vm->_screen->_orgY2 = _vm->_screen->_orgY1 + 8;
- _vm->_screen->_lColor = 0xF9;
+ screen._orgX1 = oldX;
+ int oldY = screen._orgY2;
+ screen._orgY2 = screen._orgY1 + 8;
+ screen._lColor = 0xF9;
- _boxStartY = _vm->_screen->_orgY2 + 1;
- _vm->_screen->_orgY2 = oldY;
+ _boxStartY = screen._orgY2 + 1;
+ screen._orgY2 = oldY;
int tmpX = 0;
int tmpY = 0;
if (_type != TYPE_2) {
// Draw the button background at the bottom
- oldY = _vm->_screen->_orgY1;
+ oldY = screen._orgY1;
// Original does this here, but we need bottom/right offset by 1.
- //--_vm->_screen->_orgY2;
- _vm->_screen->_orgY1 = _vm->_screen->_orgY2 - 8;
+ //--screen._orgY2;
+ screen._orgY1 = screen._orgY2 - 8;
if (_type == TYPE_3)
- _vm->_screen->_orgY1 -= 8;
- _vm->_screen->drawRect();
- tmpX = _bIconStartX = _vm->_screen->_orgX1;
+ screen._orgY1 -= 8;
+ screen.drawRect();
+ tmpX = _bIconStartX = screen._orgX1;
_boxStartX = tmpX + 1;
- tmpY = _boxEndY = _vm->_screen->_orgY1;
+ tmpY = _boxEndY = screen._orgY1;
if (_type == TYPE_3)
_bIconStartY = tmpY + 9;
@@ -757,57 +755,57 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
printString("FILE: ");
_vm->_fonts._charFor._hi = 0xFF;
}
- _vm->_screen->_orgY1 = oldY;
+ screen._orgY1 = oldY;
}
if ((_type != TYPE_0) && (_type != TYPE_2)) {
- _vm->_screen->_orgY1 += 8;
+ screen._orgY1 += 8;
if (_type == TYPE_3)
- _vm->_screen->_orgY2 -= 8;
+ screen._orgY2 -= 8;
- _vm->_screen->_orgY2 -= 8;
- _btnUpPos.right = _btnDownPos.right = _vm->_screen->_orgX2;
- _btnUpPos.left = _btnDownPos.left = _vm->_screen->_orgX1 = _vm->_screen->_orgX2 - 8;
- _boxEndX = _vm->_screen->_orgX1 - 1;
- _vm->_screen->drawBox();
+ screen._orgY2 -= 8;
+ _btnUpPos.right = _btnDownPos.right = screen._orgX2;
+ _btnUpPos.left = _btnDownPos.left = screen._orgX1 = screen._orgX2 - 8;
+ _boxEndX = screen._orgX1 - 1;
+ screen.drawBox();
- _vm->_screen->_orgY1 += 6;
- _vm->_screen->_orgY2 -= 6;
- _vm->_screen->drawBox();
+ screen._orgY1 += 6;
+ screen._orgY2 -= 6;
+ screen.drawBox();
- _btnUpPos.bottom = _vm->_screen->_orgY1 + 1;
+ _btnUpPos.bottom = screen._orgY1 + 1;
_btnUpPos.top = _btnUpPos.bottom - 5;
- _btnDownPos.top = _vm->_screen->_orgY2 + 1;
+ _btnDownPos.top = screen._orgY2 + 1;
_btnDownPos.bottom = _btnDownPos.top + 6;
- _vm->_screen->_orgX1 += 4;
- _vm->_screen->_orgX2 = _vm->_screen->_orgX1;
- _vm->_screen->_orgY1 -= 4;
- _vm->_screen->_orgY2 += 2;
- _vm->_screen->drawLine();
+ screen._orgX1 += 4;
+ screen._orgX2 = screen._orgX1;
+ screen._orgY1 -= 4;
+ screen._orgY2 += 2;
+ screen.drawLine();
- ++_vm->_screen->_orgY1;
- --_vm->_screen->_orgX1;
- ++_vm->_screen->_orgX2;
- _vm->_screen->drawLine();
+ ++screen._orgY1;
+ --screen._orgX1;
+ ++screen._orgX2;
+ screen.drawLine();
- ++_vm->_screen->_orgY1;
- --_vm->_screen->_orgX1;
- ++_vm->_screen->_orgX2;
- _vm->_screen->drawLine();
+ ++screen._orgY1;
+ --screen._orgX1;
+ ++screen._orgX2;
+ screen.drawLine();
- _vm->_screen->_orgY1 = _vm->_screen->_orgY2;
- _vm->_screen->drawLine();
+ screen._orgY1 = screen._orgY2;
+ screen.drawLine();
- ++_vm->_screen->_orgX1;
- --_vm->_screen->_orgX2;
- ++_vm->_screen->_orgY1;
- _vm->_screen->drawLine();
+ ++screen._orgX1;
+ --screen._orgX2;
+ ++screen._orgY1;
+ screen.drawLine();
- ++_vm->_screen->_orgX1;
- --_vm->_screen->_orgX2;
- ++_vm->_screen->_orgY1;
- _vm->_screen->drawLine();
+ ++screen._orgX1;
+ --screen._orgX2;
+ ++screen._orgY1;
+ screen.drawLine();
}
// Draw the box title
@@ -828,13 +826,13 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
setCursorPos(newX, _boxPStartY);
Font::_fontColors[1] = _vm->_fonts._charFor._lo = 0xFF;
- _vm->_fonts._bitFont->drawString(_vm->_screen, _bubbleDisplStr, _vm->_screen->_printOrg);
+ _vm->_fonts._bitFont->drawString(_vm->_screen, _bubbleDisplStr, screen._printOrg);
if (_type == TYPE_2) {
- _vm->_events->showCursor();
- _vm->_screen->_printStart = origPrintStart;
- _vm->_screen->_printOrg = origPrintOrg;
- _vm->_screen->restoreScreen();
+ events.showCursor();
+ screen._printStart = origPrintStart;
+ screen._printOrg = origPrintOrg;
+ screen.restoreScreen();
return retval_;
}
@@ -852,22 +850,22 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
ICON1T = _btnId1;
ICON1X = _bIconStartX + _btnX1;
ICON1Y = _bIconStartY;
- _vm->_screen->plotImage(icons, ICON1T + 10, Common::Point(ICON1X, ICON1Y));
+ screen.plotImage(icons, ICON1T + 10, Common::Point(ICON1X, ICON1Y));
if (_btnId2) {
ICON2T = _btnId2;
ICON2X = _bIconStartX + _btnX2;
- _vm->_screen->plotImage(icons, ICON2T + 10, Common::Point(ICON2X, _bIconStartY));
+ screen.plotImage(icons, ICON2T + 10, Common::Point(ICON2X, _bIconStartY));
if (_btnId3) {
ICON3T = _btnId3;
ICON3X = _bIconStartX + _btnX3;
- _vm->_screen->plotImage(icons, ICON3T + 10, Common::Point(ICON3X, _bIconStartY));
+ screen.plotImage(icons, ICON3T + 10, Common::Point(ICON3X, _bIconStartY));
}
}
}
- _vm->_screen->restoreScreen();
+ screen.restoreScreen();
_vm->_boxDataStart = _startItem;
_vm->_boxSelectYOld = -1;
_vm->_boxSelectY = _startBox;
@@ -876,13 +874,13 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
if (_type == TYPE_3)
--_vm->_numLines;
- _vm->_events->showCursor();
+ events.showCursor();
displayBoxData();
drawSelectBox();
while (!_vm->shouldQuit()) {
- _vm->_events->pollEvents();
- if (!_vm->_events->_leftButton && !_vm->_events->_wheelDown && !_vm->_events->_wheelUp && !_vm->_events->isKeyActionPending())
+ events.pollEvents();
+ if (!events._leftButton && !events._wheelDown && !events._wheelUp && !events.isKeyActionPending())
continue;
//
@@ -893,8 +891,8 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
++_vm->_timers[2]._flag;
Common::CustomEventType action = kActionNone;
- _vm->_events->getAction(action);
- if (_btnUpPos.contains(_vm->_events->_mousePos) || _vm->_events->_wheelUp || action == kActionMoveUp) {
+ events.getAction(action);
+ if (_btnUpPos.contains(events._mousePos) || events._wheelUp || action == kActionMoveUp) {
if (_vm->_bcnt) {
if (_vm->_boxSelectY != 0) {
--_vm->_boxSelectY;
@@ -906,7 +904,7 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
}
}
continue;
- } else if (_btnDownPos.contains(_vm->_events->_mousePos) || _vm->_events->_wheelDown || action == kActionMoveDown) {
+ } else if (_btnDownPos.contains(events._mousePos) || events._wheelDown || action == kActionMoveDown) {
if (_vm->_bcnt) {
if (_vm->_bcnt == _vm->_numLines) {
if (_vm->_bcnt != _vm->_boxSelectY + 1) {
@@ -926,12 +924,12 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
}
}
- if (!_vm->_events->_leftButton)
+ if (!events._leftButton)
continue;
- if ((_vm->_events->_mousePos.x >= _boxStartX) && (_vm->_events->_mousePos.x <= _boxEndX)
- && (_vm->_events->_mousePos.y >= _boxStartY) && (_vm->_events->_mousePos.y <= _boxEndY)) {
- int val = (_vm->_events->_mousePos.y >> 3) - _boxPStartY;
+ if ((events._mousePos.x >= _boxStartX) && (events._mousePos.x <= _boxEndX)
+ && (events._mousePos.y >= _boxStartY) && (events._mousePos.y <= _boxEndY)) {
+ int val = (events._mousePos.y >> 3) - _boxPStartY;
if (val > _vm->_bcnt)
continue;
--val;
@@ -942,24 +940,24 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
if (_vm->_boxSelectY == val)
break;
_vm->_boxSelectY = val;
- _vm->_events->debounceLeft();
+ events.debounceLeft();
drawSelectBox();
continue;
}
}
- if ((_vm->_events->_mousePos.y >= ICON1Y) && (_vm->_events->_mousePos.y <= ICON1Y + 8)
- && (_vm->_events->_mousePos.x >= ICON1X)) {
+ if ((events._mousePos.y >= ICON1Y) && (events._mousePos.y <= ICON1Y + 8)
+ && (events._mousePos.x >= ICON1X)) {
btnSelected = 1;
- if (_vm->_events->_mousePos.x < ICON1X + ICONW[ICON1T])
+ if (events._mousePos.x < ICON1X + ICONW[ICON1T])
break;
- if ((_vm->_events->_mousePos.x >= ICON2X) && (_vm->_events->_mousePos.x < ICON2X + ICONW[ICON2T])) {
+ if ((events._mousePos.x >= ICON2X) && (events._mousePos.x < ICON2X + ICONW[ICON2T])) {
btnSelected = 2;
break;
}
- if ((_vm->_events->_mousePos.x >= ICON3X) && (_vm->_events->_mousePos.x < ICON3X + ICONW[ICON3T])) {
+ if ((events._mousePos.x >= ICON3X) && (events._mousePos.x < ICON3X + ICONW[ICON3T])) {
btnSelected = 3;
break;
}
@@ -967,27 +965,25 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
if (_type != TYPE_3)
continue;
- if ((_vm->_events->_mousePos.x < tmpX) || (_vm->_events->_mousePos.x > tmpX + 144))
+ if ((events._mousePos.x < tmpX) || (events._mousePos.x > tmpX + 144))
continue;
- if ((_vm->_events->_mousePos.y < tmpY) || (_vm->_events->_mousePos.y > tmpY + 8))
+ if ((events._mousePos.y < tmpY) || (events._mousePos.y > tmpY + 8))
continue;
warning("TODO: sub175B5 - List of files");
}
}
- _vm->_events->hideCursor();
- _vm->_screen->restoreBlock();
- _vm->_events->showCursor();
- _vm->_events->debounceLeft();
+ screen.restoreBlock();
+ events.debounceLeft();
if (_vm->_bcnt == 0)
retval_ = -1;
else
retval_ = _vm->_boxDataStart + _vm->_boxSelectY;
- _vm->_screen->_printStart = origPrintStart;
- _vm->_screen->_printOrg = origPrintOrg;
+ screen._printStart = origPrintStart;
+ screen._printOrg = origPrintOrg;
return retval_;
}
diff --git a/engines/access/martian/martian_duct.cpp b/engines/access/martian/martian_duct.cpp
index 3e997b53a6b..be418630c9c 100644
--- a/engines/access/martian/martian_duct.cpp
+++ b/engines/access/martian/martian_duct.cpp
@@ -132,12 +132,10 @@ void MartianDuct::drawArrowSprites() {
}
void MartianDuct::drawArrowSprites2() {
- _vm->_events->hideCursor();
_vm->_screen->plotImage(_vm->_objectsTable[20], 14, Common::Point(16, 0x58));
if (_mapLoc > 3 && _mapLoc < 13) {
_vm->_screen->plotImage(_vm->_objectsTable[20], 13, Common::Point(17, 0x59));
}
- _vm->_events->showCursor();
}
void MartianDuct::clearWorkScreenArea() {
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
index 58bdeb26401..582e46f5758 100644
--- a/engines/access/martian/martian_game.cpp
+++ b/engines/access/martian/martian_game.cpp
@@ -401,22 +401,6 @@ Common::Error MartianEngine::synchronize(Common::Serializer &s) {
s.syncAsByte(_ask[i]);
}
- /*
- TODO: Do any of these need to be synchronized here?
- Mostly involved in modal dialogs.
- _startTravelItem
- _startTravelBox
- _startAboutItem
- _startAboutBox
- _byte26CB5
- _bcnt
- _boxDataStart
- _boxDataEnd
- _boxSelectY
- _boxSelectYOld
- _numLines
- */
-
return Common::kNoError;
}
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
index 35397b43b56..3cb1b64b3ef 100644
--- a/engines/access/martian/martian_room.cpp
+++ b/engines/access/martian/martian_room.cpp
@@ -62,9 +62,7 @@ void MartianRoom::reloadRoom1() {
_vm->_player->_playerOff = false;
_vm->_screen->forceFadeOut();
- _vm->_events->hideCursor();
_vm->_screen->clearScreen();
- _vm->_events->showCursor();
roomInit();
_vm->_player->load();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 097e514e212..1866b081ddb 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -69,7 +69,6 @@ void Room::freeTileData() {
void Room::clearCamera() {
_vm->_player->_scrollFlag = true;
- _vm->_events->hideCursor();
_vm->_screen->_orgX1 = 48;
_vm->_screen->_orgY1 = 24;
@@ -78,8 +77,6 @@ void Room::clearCamera() {
_vm->_screen->_lColor = 0;
_vm->_screen->drawRect();
- _vm->_events->showCursor();
-
_vm->_events->_vbCount = 4;
while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
_vm->_events->pollEventsAndWait();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 81968b3dfe2..2dca492a88f 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -237,15 +237,12 @@ void Scripts::charLoop() {
}
void Scripts::clearWatch() {
- _vm->_events->hideCursor();
_vm->_screen->_orgX1 = 128;
_vm->_screen->_orgY1 = 57;
_vm->_screen->_orgX2 = 228;
_vm->_screen->_orgY2 = 106 + 1;
_vm->_screen->_lColor = 0;
_vm->_screen->drawRect();
-
- _vm->_events->showCursor();
}
void Scripts::printWatch() {
@@ -497,9 +494,7 @@ void Scripts::doCmdPrint_v1(const Common::String &msg) {
_vm->_screen->_printStart = Common::Point(20, 32);
_vm->_bubbleBox->placeBubble(msg);
_vm->_events->waitKeyActionMouse();
- _vm->_events->hideCursor();
_vm->_screen->restoreBlock();
- _vm->_events->showCursor();
findNull();
}
Commit: 5bfa6f5ab1bde4576c5d9eb29f38bab2e13917e3
https://github.com/scummvm/scummvm/commit/5bfa6f5ab1bde4576c5d9eb29f38bab2e13917e3
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2026-10-20T14:16:48+11:00
Commit Message:
ACCESS: Fix inconsistent variable naming in Player
Changed paths:
engines/access/player.cpp
engines/access/player.h
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index c6cbeff2443..1a455174782 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -52,7 +52,7 @@ Player::Player(AccessEngine *vm) : Manager(vm), ImageEntry() {
_playerSprites1 = nullptr;
_manPal1 = nullptr;
_frameNumber = 0;
- _rawTempL = 0;
+ _rawXTempL = 0;
_rawXTemp = 0;
_rawYTempL = 0;
_rawYTemp = 0;
@@ -403,7 +403,7 @@ void Player::walkLeft() {
if (flag) {
int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
int tempL = _rawPlayerLow.x - (isMMHover() ? 2 : _vm->_screen->_scaleTable2[walkOffset]);
- _rawTempL = (byte)tempL;
+ _rawXTempL = (byte)tempL;
_rawXTemp = _rawPlayer.x - (isMMHover() ? 2 : _vm->_screen->_scaleTable1[walkOffset]) -
(tempL < 0 ? 1 : 0);
} else {
@@ -415,7 +415,7 @@ void Player::walkLeft() {
plotCom2();
} else {
_rawPlayer.x = _rawXTemp;
- _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.x = _rawXTempL;
++_frame;
if (_vm->gameIs(kGameMartianMemorandum) && _vm->_flags[174] == 0 && (_frame == 7 || _frame == 3))
@@ -445,7 +445,7 @@ void Player::walkRight() {
if (flag) {
int walkOffset = _walkOffRight[_frame - _sideWalkMin];
int tempL = _rawPlayerLow.x + (isMMHover() ? 2 : _vm->_screen->_scaleTable2[walkOffset]);
- _rawTempL = (byte)tempL;
+ _rawXTempL = (byte)tempL;
_rawXTemp = _rawPlayer.x + (isMMHover() ? 2 : _vm->_screen->_scaleTable1[walkOffset]) +
(tempL >= 0x100 ? 1 : 0);
} else {
@@ -457,7 +457,7 @@ void Player::walkRight() {
plotCom2();
} else {
_rawPlayer.x = _rawXTemp;
- _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.x = _rawXTempL;
++_frame;
if (_vm->gameIs(kGameMartianMemorandum) && _vm->_flags[174] == 0 && (_frame == 7 || _frame == 3))
@@ -489,7 +489,7 @@ void Player::walkUpLeft() {
if (flag) {
walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x;
tempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
- _rawTempL = (byte)tempL;
+ _rawXTempL = (byte)tempL;
_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset] -
(tempL < 0 ? 1 : 0);
} else {
@@ -507,7 +507,7 @@ void Player::walkUpLeft() {
} else {
_rawPlayer.x = _rawXTemp;
_rawPlayer.y = _rawYTemp;
- _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.x = _rawXTempL;
_rawPlayerLow.y = _rawYTempL;
++_frame;
@@ -539,7 +539,7 @@ void Player::walkDownLeft() {
if (flag) {
walkOffset = _walkOffDL[_frame - _sideWalkMin].x;
tempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
- _rawTempL = (byte)tempL;
+ _rawXTempL = (byte)tempL;
_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset] -
(tempL < 0 ? 1 : 0);
} else {
@@ -557,7 +557,7 @@ void Player::walkDownLeft() {
} else {
_rawPlayer.x = _rawXTemp;
_rawPlayer.y = _rawYTemp;
- _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.x = _rawXTempL;
_rawPlayerLow.y = _rawYTempL;
++_frame;
@@ -589,7 +589,7 @@ void Player::walkUpRight() {
if (flag) {
walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x;
tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset];
- _rawTempL = (byte)tempL;
+ _rawXTempL = (byte)tempL;
_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] +
(tempL >= 0x100 ? 1 : 0);
} else {
@@ -607,7 +607,7 @@ void Player::walkUpRight() {
} else {
_rawPlayer.x = _rawXTemp;
_rawPlayer.y = _rawYTemp;
- _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.x = _rawXTempL;
_rawPlayerLow.y = _rawYTempL;
++_frame;
@@ -639,7 +639,7 @@ void Player::walkDownRight() {
if (flag) {
walkOffset = _walkOffUR[_frame - _diagDownWalkMin].x;
tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset];
- _rawTempL = (byte)tempL;
+ _rawXTempL = (byte)tempL;
_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] +
(tempL >= 0x100 ? 1 : 0);
} else {
@@ -657,7 +657,7 @@ void Player::walkDownRight() {
} else {
_rawPlayer.x = _rawXTemp;
_rawPlayer.y = _rawYTemp;
- _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.x = _rawXTempL;
_rawPlayerLow.y = _rawYTempL;
calcManScale();
diff --git a/engines/access/player.h b/engines/access/player.h
index cee2c1c6800..59c2e368fa1 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -96,7 +96,7 @@ public:
Common::Point *_walkOffDR;
Common::Point *_walkOffUL;
Common::Point *_walkOffDL;
- byte _rawTempL;
+ byte _rawXTempL;
int _rawXTemp;
byte _rawYTempL;
int _rawYTemp;
Commit: 5dbb71a52965cb99ab3a0b058b42fae2797fc814
https://github.com/scummvm/scummvm/commit/5dbb71a52965cb99ab3a0b058b42fae2797fc814
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2026-10-20T14:16:48+11:00
Commit Message:
ACCESS: Rename bubble box enum to more meaningful values
Changed paths:
engines/access/access.cpp
engines/access/bubble_box.cpp
engines/access/bubble_box.h
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 4791bdddfca..6e30c16dc50 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -173,13 +173,13 @@ void AccessEngine::initialize() {
// Create sub-objects of the engine
_animation = new AnimationManager(this);
- _bubbleBox = new BubbleBox(this, TYPE_2, 64, 32, 130, 122, 0, 0, 0, 0, "");
+ _bubbleBox = new BubbleBox(this, kBoxTypeNormal, 64, 32, 130, 122, 0, 0, 0, 0, "");
if (getGameID() == kGameMartianMemorandum) {
// Note: add 1 more pixel to width and height to get the right box size.
- _helpBox = new BubbleBox(this, TYPE_1, 64, 24, 147, 123, 1, 32, 2, 76, "HELP");
- _travelBox = new BubbleBox(this, TYPE_1, 64, 32, 195, 123, 1, 24, 2, 74, "TRAVEL");
- _invBox = new BubbleBox(this, TYPE_1, 64, 32, 147, 123, 1, 32, 2, 76, "INVENTORY");
- _aboutBox = new BubbleBox(this, TYPE_1, 64, 32, 195, 123, 1, 32, 2, 76, "ASK ABOUT");
+ _helpBox = new BubbleBox(this, kBoxTypeList, 64, 24, 147, 123, 1, 32, 2, 76, "HELP");
+ _travelBox = new BubbleBox(this, kBoxTypeList, 64, 32, 195, 123, 1, 24, 2, 74, "TRAVEL");
+ _invBox = new BubbleBox(this, kBoxTypeList, 64, 32, 147, 123, 1, 32, 2, 76, "INVENTORY");
+ _aboutBox = new BubbleBox(this, kBoxTypeList, 64, 32, 195, 123, 1, 32, 2, 76, "ASK ABOUT");
} else {
_helpBox = nullptr;
_travelBox = nullptr;
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 76a40237584..9b83294729c 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -574,7 +574,7 @@ void BubbleBox::displayBoxData() {
return;
int idx = 0;
- if ((_type == TYPE_1) || (_type == TYPE_3)) {
+ if ((_type == kBoxTypeList) || (_type == kBoxTypeFileList)) {
_vm->_bcnt = 0;
if (_tempList[idx].size() == 0) {
@@ -622,7 +622,7 @@ void BubbleBox::drawSelectBox() {
if (_tempList[0].size() == 0)
return;
- if (((_type != TYPE_1) && (_type != TYPE_3)) || !_vm->_bcnt)
+ if (((_type != kBoxTypeList) && (_type != kBoxTypeFileList)) || !_vm->_bcnt)
return;
if (_vm->_boxSelectYOld != -1) {
@@ -645,7 +645,7 @@ void BubbleBox::drawSelectBox() {
_vm->_screen->_lColor = 0xFE;
_vm->_screen->drawBox();
- if (_type == TYPE_3)
+ if (_type == kBoxTypeFileList)
warning("TODO: List filenames");
}
@@ -676,7 +676,7 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
_vm->_destIn = _vm->_screen; // TODO: Redundant
- if (_type != TYPE_2) {
+ if (_type != kBoxTypeNormal) {
Common::Rect r = _bounds;
r.left -= 2;
screen.saveBlock(r);
@@ -722,13 +722,13 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
int tmpX = 0;
int tmpY = 0;
- if (_type != TYPE_2) {
+ if (_type != kBoxTypeNormal) {
// Draw the button background at the bottom
oldY = screen._orgY1;
// Original does this here, but we need bottom/right offset by 1.
//--screen._orgY2;
screen._orgY1 = screen._orgY2 - 8;
- if (_type == TYPE_3)
+ if (_type == kBoxTypeFileList)
screen._orgY1 -= 8;
screen.drawRect();
tmpX = _bIconStartX = screen._orgX1;
@@ -736,12 +736,12 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
_boxStartX = tmpX + 1;
tmpY = _boxEndY = screen._orgY1;
- if (_type == TYPE_3)
+ if (_type == kBoxTypeFileList)
_bIconStartY = tmpY + 9;
else
_bIconStartY = tmpY + 1;
- if (_type == TYPE_3) {
+ if (_type == kBoxTypeFileList) {
_fileStart = Common::Point((tmpX + 2) >> 3, (tmpY + 2) >> 3);
int rowOff = tmpY - (_fileStart.y << 3) + 1;
if (rowOff == 8) {
@@ -758,9 +758,9 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
screen._orgY1 = oldY;
}
- if ((_type != TYPE_0) && (_type != TYPE_2)) {
+ if ((_type != kBoxTypeNone) && (_type != kBoxTypeNormal)) {
screen._orgY1 += 8;
- if (_type == TYPE_3)
+ if (_type == kBoxTypeFileList)
screen._orgY2 -= 8;
screen._orgY2 -= 8;
@@ -828,7 +828,7 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
Font::_fontColors[1] = _vm->_fonts._charFor._lo = 0xFF;
_vm->_fonts._bitFont->drawString(_vm->_screen, _bubbleDisplStr, screen._printOrg);
- if (_type == TYPE_2) {
+ if (_type == kBoxTypeNormal) {
events.showCursor();
screen._printStart = origPrintStart;
screen._printOrg = origPrintOrg;
@@ -871,7 +871,7 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
_vm->_boxSelectY = _startBox;
_vm->_numLines = (_bounds.height() / 8) - 2;
- if (_type == TYPE_3)
+ if (_type == kBoxTypeFileList)
--_vm->_numLines;
events.showCursor();
@@ -887,7 +887,7 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
// Slight enhancement from original - we also allow mouse wheel and
// keyboard events to scroll up/down.
//
- if (((_type == TYPE_1) || (_type == TYPE_3)) && (_vm->_timers[2]._flag == 0)) {
+ if (((_type == kBoxTypeList) || (_type == kBoxTypeFileList)) && (_vm->_timers[2]._flag == 0)) {
++_vm->_timers[2]._flag;
Common::CustomEventType action = kActionNone;
@@ -933,7 +933,7 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
if (val > _vm->_bcnt)
continue;
--val;
- if (_type == TYPE_3)
+ if (_type == kBoxTypeFileList)
_vm->_boxSelect = val;
else {
btnSelected = 1;
@@ -962,7 +962,7 @@ int BubbleBox::doBox_v1(int item, int box, int &btnSelected) {
break;
}
- if (_type != TYPE_3)
+ if (_type != kBoxTypeFileList)
continue;
if ((events._mousePos.x < tmpX) || (events._mousePos.x > tmpX + 144))
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index f71e506660e..a3ab09c6dc3 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -35,12 +35,14 @@ namespace Access {
class AccessEngine;
+// MM/Amazon uses an enum, Noctropolis uses flags.
enum BoxType {
- TYPE_0 = 0,
- TYPE_1 = 1,
- TYPE_2 = 2,
- TYPE_3 = 3,
+ kBoxTypeNone = 0,
+ kBoxTypeList = 1,
+ kBoxTypeNormal = 2,
+ kBoxTypeFileList = 3,
kBoxTypeFileDialog = 4,
+
kTextBoxNoctPlain = 1,
kTextBoxNoctCaption = 2,
kTextBoxNoctCenter = 4,
@@ -100,11 +102,6 @@ public:
*/
void calcBubble(const Common::String &msg);
- /**
- * Noctropolis version of bubble calculation
- */
- //void calcBubble_v3(const Common::String &msg);
-
/**
* Prints a text bubble and it's contents
*/
Commit: 2de76481cca25172dbd86fe6a6cde14a5ca09778
https://github.com/scummvm/scummvm/commit/2de76481cca25172dbd86fe6a6cde14a5ca09778
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2026-10-20T14:22:50+11:00
Commit Message:
ACCESS: Refactor script opcodes
Replaced raw function pointers with the Common::Functor pattern, so we can use
proper inheritance and move game-specific opcodes into their own scripts
classes.
Reduces games-specific logic in common Scripts class.
Changed paths:
engines/access/amazon/amazon_scripts.cpp
engines/access/amazon/amazon_scripts.h
engines/access/martian/martian_scripts.cpp
engines/access/martian/martian_scripts.h
engines/access/noctropolis/noctropolis_scripts.cpp
engines/access/noctropolis/noctropolis_scripts.h
engines/access/scripts.cpp
engines/access/scripts.h
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 11de4e6cbce..61750d62252 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -33,9 +33,38 @@ namespace Amazon {
AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
_game = (AmazonEngine *)_vm;
- setOpcodes_v2();
}
+
+
+void AmazonScripts::setOpcodes() {
+ #define Opcode(func) Common::SharedPtr<Common::Functor0<void>>( \
+ new Common::Functor0Mem<void, AmazonScripts>(this, &AmazonScripts::func))
+
+ Scripts::setOpcodes();
+
+ _opcodes.resize(80);
+ // Modify command list for Amazon
+ _opcodes[3] = Opcode(cmdJumpHelp);
+ _opcodes[9] = Opcode(cmdPrint_v2);
+ _opcodes[15] = Opcode(cmdSetInventory);
+ _opcodes[28] = Opcode(cmdDispInv_v2);
+ _opcodes[29] = Opcode(cmdSetTimer);
+ _opcodes[32] = Opcode(cmdJumpGoto);
+ _opcodes[40] = Opcode(cmdVideoEnded);
+ _opcodes[45] = _opcodes[46] = Opcode(cmdSpecial);
+ _opcodes[63] = _opcodes[64] = _opcodes[65] = _opcodes[66] = _opcodes[67] = Opcode(cmdPushLocation_v2);
+
+ _opcodes[73] = Opcode(cmdHelp_v2);
+ _opcodes[74] = Opcode(cmdCycleBack);
+ _opcodes[75] = Opcode(cmdChapter);
+ _opcodes[76] = Opcode(cmdSetHelp);
+ _opcodes[77] = Opcode(cmdCenterPanel);
+ _opcodes[78] = Opcode(cmdMainPanel);
+ _opcodes[79] = Opcode(cmdRetFlash);
+}
+
+
void AmazonScripts::cLoop() {
searchForSequence();
_vm->_images.clear();
@@ -364,22 +393,6 @@ bool AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
return false;
}
-typedef void(AmazonScripts::*AmazonScriptMethodPtr)();
-
-void AmazonScripts::executeCommand(int commandIndex) {
- static const AmazonScriptMethodPtr AMAZON_COMMAND_LIST[] = {
- &AmazonScripts::cmdHelp_v2, &AmazonScripts::cmdCycleBack,
- &AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp,
- &AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
- &AmazonScripts::CMDRETFLASH
- };
-
- if (commandIndex >= 73)
- (this->*AMAZON_COMMAND_LIST[commandIndex - 73])();
- else
- Scripts::executeCommand(commandIndex);
-}
-
void AmazonScripts::cmdHelp_v2() {
Common::String helpMessage = _data->readString();
@@ -457,6 +470,19 @@ void AmazonScripts::cmdHelp_v2() {
findNull();
}
+void AmazonScripts::cmdPushLocation_v2() {
+ // TODO: Double-check this code. It doesn't seem to match function
+ // sub13BC0 in Amazon?
+ debugC(1, kDebugScripts, "cmdPushLocation()");
+ _choiceStart = _data->pos() - 1;
+}
+
+void AmazonScripts::cmdDispInv_v2() {
+ debugC(1, kDebugScripts, "cmdDispInv_v2()");
+ _vm->_inventory->displayInv();
+ _vm->_events->forceSetCursor(CURSOR_ARROW);
+}
+
void AmazonScripts::cmdCycleBack() {
if (_vm->_startup == -1)
_vm->_screen->cyclePaletteBackwards();
@@ -514,7 +540,7 @@ void AmazonScripts::cmdMainPanel() {
}
}
-void AmazonScripts::CMDRETFLASH() {
+void AmazonScripts::cmdRetFlash() {
error("TODO CMDRETFLASH");
}
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 1f794fd1d31..1681d33c7ea 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -35,8 +35,9 @@ class AmazonScripts : public Scripts {
private:
AmazonEngine *_game;
protected:
+ void setOpcodes() override;
+
bool executeSpecial(int commandIndex, int param1, int param2) override;
- void executeCommand(int commandIndex) override;
void cLoop();
void mWhile1();
@@ -48,13 +49,15 @@ protected:
void setInactive();
void boatWalls(int param1, int param2);
+ void cmdDispInv_v2();
+ void cmdPushLocation_v2();
void cmdHelp_v2();
void cmdCycleBack();
void cmdChapter();
void cmdSetHelp();
void cmdCenterPanel();
void cmdMainPanel();
- void CMDRETFLASH();
+ void cmdRetFlash();
public:
AmazonScripts(AccessEngine *vm);
};
diff --git a/engines/access/martian/martian_scripts.cpp b/engines/access/martian/martian_scripts.cpp
index 7bcc031b3c8..fa5fa00cc49 100644
--- a/engines/access/martian/martian_scripts.cpp
+++ b/engines/access/martian/martian_scripts.cpp
@@ -365,11 +365,6 @@ bool MartianScripts::executeSpecial(int commandIndex, int param1, int param2) {
return false;
}
-typedef void(MartianScripts::*MartianScriptMethodPtr)();
-
-void MartianScripts::executeCommand(int commandIndex) {
- Scripts::executeCommand(commandIndex);
-}
} // End of namespace Martian
diff --git a/engines/access/martian/martian_scripts.h b/engines/access/martian/martian_scripts.h
index b172a4dadf3..a146b0f922a 100644
--- a/engines/access/martian/martian_scripts.h
+++ b/engines/access/martian/martian_scripts.h
@@ -48,11 +48,11 @@ private:
protected:
bool executeSpecial(int commandIndex, int param1, int param2) override;
- void executeCommand(int commandIndex) override;
public:
MartianScripts(AccessEngine *vm);
~MartianScripts();
+
};
} // End of namespace Martian
diff --git a/engines/access/noctropolis/noctropolis_scripts.cpp b/engines/access/noctropolis/noctropolis_scripts.cpp
index 5d57ee67b0b..c9db1c8687a 100644
--- a/engines/access/noctropolis/noctropolis_scripts.cpp
+++ b/engines/access/noctropolis/noctropolis_scripts.cpp
@@ -22,15 +22,69 @@
#include "access/noctropolis/noctropolis_scripts.h"
#include "access/noctropolis/noctropolis_game.h"
#include "access/noctropolis/noctropolis_room.h"
+#include "access/noctropolis/noctropolis_resources.h"
namespace Access {
namespace Noctropolis {
-NoctropolisScripts::NoctropolisScripts(NoctropolisEngine *vm) : Scripts(vm) {
- setOpcodes_v3();
+NoctropolisScripts::NoctropolisScripts(NoctropolisEngine *vm) : Scripts(vm),
+_keepAskPosition(false) {
}
+void NoctropolisScripts::setOpcodes() {
+ #define Opcode(func) Common::SharedPtr<Common::Functor0<void>>( \
+ new Common::Functor0Mem<void, NoctropolisScripts>(this, &NoctropolisScripts::func))
+
+ Scripts::setOpcodes();
+
+ _opcodes.resize(96);
+
+ // Modify command list for Noctropolis
+ _opcodes[1] = Opcode(cmdEndObject_v3);
+ _opcodes[6] = Opcode(cmdJumpUse_v3);
+ _opcodes[7] = Opcode(cmdJumpTalk_v3);
+ _opcodes[9] = Opcode(cmdPrint_v2);
+ _opcodes[18] = Opcode(cmdSetCoords);
+ _opcodes[33] = Opcode(cmdJumpGoto_v3);
+ _opcodes[34] = Opcode(cmdSetVideo_v3);
+ _opcodes[45] = Opcode(cmdDoTravel_Noct);
+ _opcodes[50] = Opcode(cmdCharSpeak_v3);
+ _opcodes[51] = Opcode(cmdPlayerSpeak);
+ _opcodes[52] = Opcode(cmdPlayerChoice);
+ // 52 to 57 unchanged
+ _opcodes[57] = Opcode(cmdDigitalPlay);
+ _opcodes[60] = Opcode(cmdFillSound);
+ _opcodes[61] = Opcode(cmdBD);
+ _opcodes[62] = Opcode(cmdPlayVid1);
+ _opcodes[63] = Opcode(cmdNull); // empty function CmdPRINTWITHOUT
+ _opcodes[64] = Opcode(cmdDispAbout_v3);
+ _opcodes[71] = Opcode(cmdFadeOut_v3);
+ _opcodes[74] = Opcode(cmdCharWait);
+ _opcodes[75] = Opcode(cmdUndoText);
+ _opcodes[76] = Opcode(cmdResetAnim);
+ _opcodes[77] = Opcode(cmdWalkTo);
+ _opcodes[78] = Opcode(cmdWalkCheck);
+ _opcodes[79] = Opcode(cmdSoundEnd);
+ _opcodes[80] = Opcode(cmdFadeWhite);
+ _opcodes[81] = Opcode(cmdGotoFrame);
+ _opcodes[82] = Opcode(cmdPlayerScale);
+ _opcodes[83] = Opcode(cmdRestoreBlock);
+ _opcodes[84] = Opcode(cmdCopyScnBuf);
+ _opcodes[85] = Opcode(cmdStilWalkTo);
+ _opcodes[86] = Opcode(cmdStilWalkCheck);
+ _opcodes[87] = Opcode(cmdStilOff);
+ _opcodes[88] = Opcode(cmdStilOn);
+ _opcodes[89] = Opcode(cmdReturnExit);
+ _opcodes[90] = Opcode(cmdSetStilCoords);
+ _opcodes[91] = Opcode(cmdSetPlayerDir);
+ _opcodes[92] = Opcode(cmdSetStilDir);
+ _opcodes[93] = Opcode(cmdStilScale);
+ _opcodes[94] = Opcode(cmdLockInterface);
+ _opcodes[95] = Opcode(cmdUnlockInterface);
+}
+
+
static int COMMAND_ARG_SIZES[] = {
-1, 0, 2, 2, 2, 2, 2, 2, 2, -1,
0, 1, 2, 6, 2, 1, 2, 6, 4, 1,
@@ -97,6 +151,656 @@ void NoctropolisScripts::searchForSequence() {
}
}
+void NoctropolisScripts::cmdEndObject_v3() {
+ if (_vm->_room->_selectCommand == Noctropolis::kNoctCmdTalk && _vm->_boxSelectY == 0x62) {
+
+ // Note: removed "DARK/" from these..
+ const char *vidfile = "VID/A4IN00.VID";
+ if (_vm->_flags[91] == 2) {
+ vidfile = "VID/A4IN26.VID";
+ }
+
+ if (_vm->_textFlag) {
+ Noctropolis::NoctropolisResources *res = (Noctropolis::NoctropolisResources *)_vm->_res;
+ const char *subtitle = res->getEndMessage();
+ if (_vm->_flags[91] == 2) {
+ subtitle = res->getStilMessage();
+ }
+ _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctPlain);
+ _vm->_bubbleBox->placeBubble(subtitle);
+ }
+
+ debug("cmdEndObject_v3: TODO: duck music volume to 50%% here.");
+
+ VideoPlayer_v2 vidPlayer(_vm);
+ vidPlayer.VideoPlayer::setVideo(_vm->_screen, Common::Point(100, 100), Common::Path(vidfile), 0);
+ vidPlayer.playToEnd();
+
+ _vm->_bubbleBox->clearBubbles();
+
+ } else {
+ const char *msg = _vm->_res->getGeneralMessage(_vm->_room->_selectCommand);
+ debugC(1, kDebugScripts, "cmdEndObject_v3(msg=\"%s\")", msg);
+
+ _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctCenter);
+ if (_vm->_player->_roomNumber <= 4)
+ _vm->_bubbleBox->_type = (BoxType)(_vm->_bubbleBox->_type | kTextBoxNoctPlain);
+
+ printString(msg);
+ }
+ _continuenceFlag = true;
+ _endFlag = true;
+ _returnCode = 0;
+}
+
+void NoctropolisScripts::cmdJumpUse_v3() {
+ debugCN(1, kDebugScripts, "cmdJumpUse_v3(selectCommand=%d)", _vm->_room->_selectCommand);
+ if (_vm->_room->_selectCommand == Noctropolis::kNoctCmdUse) {
+ debugC(1, kDebugScripts, " -> True");
+ cmdGoto();
+ } else {
+ debugC(1, kDebugScripts, " -> False");
+ _data->skip(2);
+ }
+}
+
+void NoctropolisScripts::cmdJumpTalk_v3() {
+ debugCN(1, kDebugScripts, "cmdJumpTalk_v3(selectCommand=%d)", _vm->_room->_selectCommand);
+ if (_vm->_room->_selectCommand == Noctropolis::kNoctCmdTalk) {
+ debugC(1, kDebugScripts, " -> True");
+ cmdGoto();
+ } else {
+ debugC(1, kDebugScripts, " -> False");
+ _data->skip(2);
+ }
+}
+
+void NoctropolisScripts::cmdJumpGoto_v3() {
+ debugCN(1, kDebugScripts, "cmdJumpGoto_v3(selectCommand=%d)", _vm->_room->_selectCommand);
+ if (_vm->_room->_selectCommand == Noctropolis::kNoctCmdGoto) {
+ debugC(1, kDebugScripts, " -> True");
+ cmdGoto();
+ } else {
+ debugC(1, kDebugScripts, " -> False");
+ _data->skip(2);
+ }
+}
+
+void NoctropolisScripts::cmdSetVideo_v3() {
+ Common::Point pt;
+ short rawx = _data->readSint16LE();
+ pt.y = _data->readSint16LE();
+ int cellIndex = _data->readUint16LE();
+ int noFrame = _data->readUint16LE();
+
+ if (cellIndex > 0x3f)
+ error("Invalid room video number %d", cellIndex);
+
+ const int roomNum = _vm->_player->_roomNumber;
+#if 0
+ bool flag;
+
+ if ((roomNum == 0x1e && cellIndex == 0) || roomNum == 0x21 || (roomNum == 0x36 && cellIndex < 32))
+ flag = true;
+ else
+ flag = false;
+#endif
+
+ if (roomNum == 0x1b || roomNum == 0x1e)
+ pt.x = rawx + -5;
+ else
+ pt.x = rawx;
+
+ debugC(1, kDebugScripts, "cmdSetVideo_v3(x=%d, y=%d, cellIndex=%d, noFrame=%d)", pt.x, pt.y, cellIndex, noFrame);
+
+ Common::Path vidpath(_vm->_extraCells[cellIndex]._vidFilename);
+ if (!_vm->_files->existFile(vidpath)) {
+ // Try removing "DARK/" from video file names -
+ // for the demo the are in DEMO/
+ Common::StringArray parts = vidpath.splitComponents();
+ vidpath = Common::Path::joinComponents(parts.begin() + 1, parts.end());
+ }
+ _vm->_video->setVideo(_vm->_screen, pt, vidpath, 0);
+
+ ((VideoPlayer_v2 *)_vm->_video)->setDrawBorder(noFrame == 0);
+
+ if (cellIndex == 1 && roomNum == 0x36)
+ _vm->_screen->setIconPalette();
+}
+
+void NoctropolisScripts::cmdCharSpeak_v3() {
+ int16 x = _data->readUint16LE();
+ int16 y = _data->readUint16LE();
+ _charsOrg = Common::Point(x, y);
+ _vm->_screen->_printOrg = _charsOrg;
+ _vm->_screen->_printStart = _charsOrg;
+
+ //debug("cmdCharSpeak_v3: duck music volume to 50%% here.");
+
+ Common::String str = _data->readString();
+ debugC(1, kDebugScripts, "cmdCharSpeak(%d, %d, str=\"%s\")", x, y, str.c_str());
+ if (_vm->_textFlag) {
+ _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctPlain);
+ _vm->_bubbleBox->placeBubble(str);
+ }
+ findNull();
+}
+
+void NoctropolisScripts::cmdDispAbout_v3() {
+ // Graphical ask box for Noctropolis
+ debugC(1, kDebugScripts, "cmdDispAbout_v3()");
+
+ static constexpr struct { int16 x1, y1, x2, y2; } askItemPos[] = {
+ {84, 0, 126, 48},
+ {42, 24, 84, 72},
+ {126, 24, 168, 72},
+ {0, 48, 42, 96},
+ {84, 48, 126, 96},
+ {168, 48, 210, 96},
+ {42, 72, 84, 120},
+ {126, 72, 168, 120},
+ {18, 102, 40, 120},
+ {186, 102, 208, 120}
+ };
+ bool menuUpArrow = false;
+ bool menuDownArrow = false;
+ int hoveredItem = -1, slotIndex;
+ byte slotItems[20];
+ Common::Array<byte> items;
+ int selectedItem = -2;
+ bool needRedraw = true;
+
+ Common::Path path = ((Noctropolis::NoctropolisResources *)_vm->_res)->translatePath("DARK/ASK.AP");
+ Resource *spriteData = _vm->_files->loadRawFile(path);
+ SpriteResource *askSprites = new SpriteResource(_vm, spriteData);
+ delete spriteData;
+
+ if (!_keepAskPosition) {
+ for (int i = 0; i < 40; i++)
+ _vm->_asked[i] = false;
+
+ int16 warpMouseX, warpMouseY;
+ _askBase.x = _vm->_events->clipMouseCenter(_vm->_events->_mousePos.x, 226, 640, warpMouseX);
+ _askBase.y = _vm->_events->clipMouseCenter(_vm->_events->_mousePos.y, 145, 400, warpMouseY);
+
+ _keepAskPosition = true;
+ if (warpMouseX != _vm->_events->_mousePos.x || warpMouseY != _vm->_events->_mousePos.y)
+ g_system->warpMouse(warpMouseX, warpMouseY);
+ }
+
+ const Common::Point base = _askBase;
+
+ // Build the list of available ask items
+ for (int i = 0; i < 40; i++) {
+ if (_vm->_ask[i] == 1)
+ items.push_back(i);
+ }
+
+ // Grab screen background
+ _vm->_screen->saveBlock(Common::Rect(base, 226, 145));
+ // Draw ask panel
+ _vm->_screen->plotImage(askSprites, 0, Common::Point(base.x, base.y + 96));
+
+ _vm->_events->setCursor(CURSOR_ARROW);
+
+ const Font *font = _vm->_fonts.getFont(1);
+ Font::_fontColors[0] = 246;
+ Font::_fontColors[1] = 238;
+
+ Noctropolis::NoctropolisResources *res = (Noctropolis::NoctropolisResources *)_vm->_res;
+
+ while (selectedItem == -2 && !_vm->shouldQuitOrRestart()) {
+ int item = -1;
+
+ if (needRedraw) {
+ hoveredItem = -1;
+ menuUpArrow = false;
+ menuDownArrow = false;
+ slotIndex = 0;
+ if (items.size() > 0) {
+ // Draw "Up" arrow if required
+ menuUpArrow = _vm->_startAboutItem > 0;
+ _vm->_screen->plotImage(askSprites, menuUpArrow ? 1 : 3, Common::Point(base.x + 18, base.y + 102));
+ // Draw ask items
+ for (uint i = 0; i < 8 && _vm->_startAboutItem + i < items.size(); i++) {
+ slotItems[slotIndex] = items[_vm->_startAboutItem + i];
+ _vm->_screen->plotImage(askSprites, slotItems[slotIndex] + 6, Common::Point(base.x + askItemPos[slotIndex].x1, base.y + askItemPos[slotIndex].y1));
+ if (_vm->_asked[slotItems[slotIndex]]) {
+ _vm->_screen->plotImage(askSprites, 5, Common::Point(base.x + askItemPos[slotIndex].x1, base.y + askItemPos[slotIndex].y1));
+ }
+ slotIndex++;
+ }
+ // Draw "Down" arrow if required
+ menuDownArrow = (int)items.size() > _vm->_startAboutItem + 8;
+ _vm->_screen->plotImage(askSprites, menuDownArrow ? 2 : 3, Common::Point(base.x + 186, base.y + 102));
+ }
+ // Draw remaining empty slots if any
+ while (slotIndex < 8) {
+ slotItems[slotIndex] = 0;
+ _vm->_screen->plotImage(askSprites, 4, Common::Point(base.x + askItemPos[slotIndex].x1, base.y + askItemPos[slotIndex].y1));
+ slotIndex++;
+ }
+ needRedraw = false;
+ }
+
+ // Find at which slot the mouse is
+ for (int i = 0; i < 10; i++) {
+ if (_vm->_events->_mousePos.x >= base.x + askItemPos[i].x1 && _vm->_events->_mousePos.x <= base.x + askItemPos[i].x2 &&
+ _vm->_events->_mousePos.y >= base.y + askItemPos[i].y1 && _vm->_events->_mousePos.y <= base.y + askItemPos[i].y2) {
+ item = i;
+ break;
+ }
+ }
+
+ if (hoveredItem != item) {
+ _vm->_screen->fillRect(Common::Rect(Common::Point(base.x + 41, base.y + 128), 150, 8), 246);
+ if ((item == 8 && menuUpArrow) || (item == 9 && menuDownArrow)) {
+ font->drawString(_vm->_screen, res->getMoreItemsText(), Common::Point(base.x + 41, base.y + 128));
+ } else if (item >= 0 && item < 8) {
+ font->drawString(_vm->_screen, res->getAskItem(slotItems[item]), Common::Point(base.x + 41, base.y + 128));
+ }
+ hoveredItem = item;
+ }
+
+ // Support the mouse wheel for scrolling through the ask items
+ if (menuUpArrow && _vm->_events->_wheelUp) {
+ _vm->_startAboutItem--;
+ needRedraw = true;
+ } else if (menuDownArrow && _vm->_events->_wheelDown) {
+ _vm->_startAboutItem++;
+ needRedraw = true;
+ }
+
+ if (_vm->_events->_leftButton) {
+ _vm->_events->debounceLeft();
+ if (hoveredItem == 8 && menuUpArrow) {
+ _vm->_startAboutItem--;
+ needRedraw = true;
+ } else if (hoveredItem == 9 && menuDownArrow) {
+ _vm->_startAboutItem++;
+ needRedraw = true;
+ } else if (hoveredItem >= 0 && hoveredItem < 8) {
+ if (_vm->_startAboutItem + hoveredItem > (int)items.size()) {
+ // An empty slot was clicked
+ selectedItem = -1;
+ } else {
+ selectedItem = slotItems[hoveredItem];
+ _vm->_asked[selectedItem] = true;
+ }
+ }
+ } else if (_vm->_events->_rightButton) {
+ _vm->_events->debounceRight();
+ selectedItem = 255;
+ _keepAskPosition = false;
+ }
+
+ _vm->_events->pollEventsAndWait();
+ }
+
+ _vm->_useItem = selectedItem;
+
+ // Restore screen background
+ _vm->_screen->restoreBlock();
+
+ _continuenceFlag = true;
+}
+
+
+void NoctropolisScripts::cmdFadeOut_v3() {
+ byte flag = _data->readByte();
+ debugC(1, kDebugScripts, "cmdFadeOut_v3(%d)", flag);
+ if (flag)
+ _vm->_screen->forceFadeIn();
+ else
+ _vm->_screen->forceFadeOut();
+ _continuenceFlag = true;
+}
+
+void NoctropolisScripts::cmdDoTravel_Noct() {
+ ((Noctropolis::NoctropolisEngine *)_vm)->doTravel();
+ cmdRetPos();
+}
+
+void NoctropolisScripts::cmdDigitalPlay() {
+ // Wait until the current sound has finished playing, then
+ // if subtitles are enabled wait for input
+ debugC(1, kDebugScripts, "cmdDigitalPlay()");
+ while (_vm->_sound->isSFXPlaying() && !_vm->shouldQuit()) {
+ _vm->_events->pollEventsAndWait();
+ }
+
+ _continuenceFlag = true;
+}
+
+void NoctropolisScripts::cmdFillSound() {
+ debugC(1, kDebugScripts, "cmdFillSound()");
+ while (_vm->_sound->isSFXPlaying() && !_vm->shouldQuit()) {
+ _vm->_events->pollEventsAndWait();
+ Common::CustomEventType action;
+ if (_vm->_events->getAction(action) && action == kActionSkip) {
+ _vm->_sound->stopSound();
+ _vm->_events->zeroKeysActions();
+ break;
+ }
+ }
+ _continuenceFlag = true;
+}
+
+void NoctropolisScripts::cmdPlayVid1() {
+ // TODO: should this mark the video finished if it's not loaded?
+ _vm->_video->playVideo();
+ _continuenceFlag = true;
+}
+
+void NoctropolisScripts::cmdCharWait() {
+ int x = _data->readSint16LE();
+ int y = _data->readUint16LE();
+ Common::String msg = _data->readString();
+ debugC(1, kDebugScripts, "cmdCharWait(%d, %d, '%s')", x, y, msg.c_str());
+
+ printString(msg);
+ _continuenceFlag = true;
+}
+
+void NoctropolisScripts::cmdUndoText() {
+ debugC(1, kDebugScripts, "cmdUndoText()");
+
+ // TODO: Restore music volume to 100%
+
+ if (_vm->_textFlag)
+ _vm->_bubbleBox->clearBubbles();
+}
+
+void NoctropolisScripts::cmdResetAnim() {
+ byte animNum = _data->readByte();
+ debugC(1, kDebugScripts, "cmdResetAnim(%d)", animNum);
+ Animation *anim = _vm->_animation->findAnimation(animNum);
+ if (!anim)
+ error("cmdResetAnim: Invalid anim num %d", animNum);
+
+ anim->_countdownTicks = anim->_initialTicks;
+ anim->_frameNumber = 0;
+ if (anim->_type == 3 || anim->_type == 4) {
+ anim->_currentLoopCount = anim->_loopCount;
+ } else {
+ anim->_currentLoopCount = 0;
+ }
+}
+
+void NoctropolisScripts::cmdWalkTo() {
+ int16 x = _data->readSint16LE();
+ int16 y = _data->readSint16LE();
+ int16 dir = _data->readSint16LE();
+ debugC(1, kDebugScripts, "cmdWalkTo(%d, %d, %d)", x, y, dir);
+
+ _vm->_player->_moveTo.x = x;
+ _vm->_player->_moveTo.y = y;
+ _vm->_player->setDirFromScript(dir);
+ _vm->_player->_move = (Direction)dir;
+ _vm->_player->_playerMove = true;
+}
+
+void NoctropolisScripts::cmdWalkCheck() {
+ debugCN(1, kDebugScripts, "cmdWalkCheck()");
+ if (!_vm->_player->_playerMove) {
+ // Walk is done
+ debugC(1, kDebugScripts, " -> True");
+ cmdGoto();
+ } else {
+ debugC(1, kDebugScripts, " -> False");
+ _data->skip(2);
+ }
+}
+
+
+void NoctropolisScripts::cmdPlayerScale() {
+ _vm->_manScaleOff = _data->readUint16LE();
+ debugC(1, kDebugScripts, "cmdPlayerScale(%d)", _vm->_manScaleOff);
+}
+
+void NoctropolisScripts::cmdPlayerSpeak() {
+ int16 x = _data->readUint16LE();
+ int16 y = _data->readUint16LE();
+
+ const char *title = _vm->_res->getEgoName();
+ Common::String str = _data->readString();
+ debugC(1, kDebugScripts, "cmdPlayerSpeak(%d, %d, \"%s\", \"%s\")", x, y, title, str.c_str());
+
+ _charsOrg = Common::Point(x, y);
+ _vm->_screen->_printOrg = _charsOrg;
+ _vm->_screen->_printStart = _charsOrg;
+ _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctPlain);
+ _vm->_bubbleBox->_bubbleDisplStr = title;
+
+ _vm->_bubbleBox->placeBubble(str);
+ _continuenceFlag = true;
+ findNull();
+
+ while (!_vm->shouldQuitOrRestart() && !_vm->_events->isKeyActionMousePressed()) {
+ _vm->_events->pollEventsAndWait();
+ }
+
+ _vm->_events->debounceLeft();
+ _vm->_events->zeroKeysActions();
+ _vm->_bubbleBox->clearBubbles();
+}
+
+
+void NoctropolisScripts::cmdPlayerChoice() {
+ // This is similar to cmdTexChoice but used in Noctropolis
+ assert(_vm->gameIs(kGameNoctropolis));
+
+ int16 x = _data->readUint16LE();
+ int16 startY = _data->readUint16LE();
+
+ Common::Array<Common::String> choiceStrs;
+ for (int i = 0; i < 6; i++) {
+ Common::String tmpStr;
+ tmpStr = _data->readString();
+ if (!tmpStr.empty())
+ choiceStrs.push_back(tmpStr);
+ }
+
+ debugC(1, kDebugScripts, "cmdPlayerChoice(%d, %d, ..(%d choices)..)", x, startY, choiceStrs.size());
+
+ _vm->_screen->_printStart = _vm->_screen->_printOrg = Common::Point(x, startY);
+
+ _vm->_events->setCursor(CURSOR_ARROW);
+ const char *respTitle = ((Noctropolis::NoctropolisResources *)_vm->_res)->getResponseTitle();
+ Common::Array<Common::Rect> responseCoords;
+
+ for (uint i = 0; i < choiceStrs.size(); i++) {
+ _vm->_bubbleBox->_bubbleDisplStr = Common::String::format(respTitle, i + 1);
+ _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctPlain);
+ _vm->_bubbleBox->calcBubble(choiceStrs[i]);
+ _vm->_bubbleBox->printBubble(choiceStrs[i]);
+ responseCoords.push_back(_vm->_bubbleBox->_bounds);
+ _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 10;
+ _vm->_screen->_printOrg.x = _vm->_screen->_printStart.x;
+ }
+
+ _vm->_bubbleBox->_bubbleDisplStr = _vm->_bubbleBox->_bubbleTitle;
+
+ int choice = -1;
+ do {
+ _vm->_events->pollEvents();
+ if (_vm->shouldQuit())
+ return;
+
+ if (_vm->_events->_leftButton) {
+ _vm->_events->debounceLeft();
+ choice = _vm->_events->checkMouseBox1(responseCoords);
+ }
+ } while (choice == -1);
+
+ _choice = choice + 1;
+ _vm->_bubbleBox->clearBubbles();
+
+ _continuenceFlag = true;
+}
+
+void NoctropolisScripts::cmdSoundEnd() {
+ debugCN(1, kDebugScripts, "cmdSoundEnd()");
+ if (!_vm->_sound->isSFXPlaying()) {
+ debugC(1, kDebugScripts, " -> True");
+ cmdGoto();
+ } else {
+ debugC(1, kDebugScripts, " -> False");
+ _data->skip(2);
+ }
+}
+
+void NoctropolisScripts::cmdFadeWhite() {
+ debugC(1, kDebugScripts, "cmdFadeWhite()");
+ _vm->_screen->forceFadeWhite();
+ _continuenceFlag = true;
+}
+
+void NoctropolisScripts::cmdGotoFrame() {
+ uint16 animNum = _data->readUint16LE();
+ uint16 frameNum = _data->readUint16LE();
+ debugC(1, kDebugScripts, "cmdGotoFrame(%d, %d)", animNum, frameNum);
+ Animation *anim = _vm->_animation->findAnimation(animNum);
+ if (!anim)
+ error("cmdGotoFrame: Invalid anim num %d", animNum);
+ anim->_frameNumber = frameNum;
+}
+
+void NoctropolisScripts::cmdRestoreBlock() {
+ int16 x = _data->readSint16LE();
+ int16 y = _data->readSint16LE();
+ int16 w = _data->readSint16LE();
+ int16 h = _data->readSint16LE();
+ debugC(1, kDebugScripts, "cmdRestoreBlock(%d, %d, %d, %d)", x, y, w, h);
+ Common::Rect r(Common::Point(x, y), w, h);
+ r.translate(-_vm->_screen->_windowXAdd, -_vm->_screen->_windowYAdd);
+ r.clip(_vm->_screen->w, _vm->_screen->h);
+ _vm->_screen->copyBlock(&_vm->_buffer2, r);
+
+ // Remake does this, but it doesn't use same buffer setup..
+ //_vm->clearPlotImagesIn(x, y, w, h);
+ //_vm->clearPlotVidsIn(x, y, w, h);
+}
+
+void NoctropolisScripts::cmdCopyScnBuf() {
+ debugC(1, kDebugScripts, "cmdCopyScnBuf()");
+
+ // Copy the screen to the buffer, applying windowing offsets
+
+ //
+ // WORKAROUND: This causes double-drawing in the noct credits?
+ // Just skip for now which causes a small graphical glitch after
+ // showing the colored bars video.
+ //
+ if (_vm->_player->_roomNumber == 0x61)
+ return;
+
+ Common::Rect src(_vm->_screen->w, _vm->_screen->h);
+ const Common::Rect screenSize = src;
+ src.translate(_vm->_screen->_windowXAdd, _vm->_screen->_windowYAdd + _vm->_screen->_screenYOff);
+ src.clip(screenSize);
+ Common::Rect dest = src;
+ dest.translate(-dest.left, -dest.top);
+ _vm->_buffer2.blitFrom(*_vm->_screen, src, dest);
+}
+
+void NoctropolisScripts::cmdStilWalkTo() {
+ int16 x = _data->readSint16LE();
+ int16 y = _data->readSint16LE();
+ int16 dir = _data->readSint16LE();
+ debugC(1, kDebugScripts, "cmdStilWalkTo(%d, %d, %d)", x, y, dir);
+
+ ((Noctropolis::NoctropolisEngine*)_vm)->_stil->_moveTo.x = x;
+ ((Noctropolis::NoctropolisEngine*)_vm)->_stil->_moveTo.y = y;
+ ((Noctropolis::NoctropolisEngine*)_vm)->_stil->setDirFromScript(dir);
+ ((Noctropolis::NoctropolisEngine*)_vm)->_stil->_move = (Direction)dir;
+ ((Noctropolis::NoctropolisEngine*)_vm)->_stil->_playerMove = true;
+}
+
+void NoctropolisScripts::cmdStilWalkCheck() {
+ debugCN(1, kDebugScripts, "cmdStilWalkCheck()");
+ if (!((Noctropolis::NoctropolisEngine*)_vm)->_stil->_playerMove) {
+ debugC(1, kDebugScripts, " -> True");
+ cmdGoto();
+ } else {
+ debugC(1, kDebugScripts, " -> False");
+ _data->skip(2);
+ }
+}
+
+void NoctropolisScripts::cmdStilOff() {
+ debugC(1, kDebugScripts, "cmdStilOff()");
+ ((Noctropolis::NoctropolisEngine *)_vm)->_stil->_playerOff = true;
+}
+
+void NoctropolisScripts::cmdStilOn() {
+ debugC(1, kDebugScripts, "cmdStilOn()");
+ ((Noctropolis::NoctropolisEngine *)_vm)->_stil->_playerOff = false;
+}
+
+void NoctropolisScripts::cmdReturnExit() {
+ debugC(1, kDebugScripts, "cmdReturnExit()");
+ _vm->_exitBox = true;
+ _endFlag = true;
+ _returnCode = 0;
+}
+
+void NoctropolisScripts::cmdSetCoords() {
+ const int x = _data->readSint16LE();
+ const int y = _data->readSint16LE();
+ debugC(1, kDebugScripts, "cmdSetCoords(x=%d, y=%d)", x, y);
+ _vm->_player->_rawPlayer.x = x;
+ _vm->_player->_moveTo.x = x;
+ _vm->_player->checkScroll();
+ bool hscroll = _vm->_player->_scrollFlag;
+ _vm->_player->_rawPlayer.y = y;
+ _vm->_player->_moveTo.y = y;
+ _vm->_player->checkScroll();
+ _vm->_player->_scrollFlag |= hscroll;
+}
+
+void NoctropolisScripts::cmdSetStilCoords() {
+ const int x = _data->readSint16LE();
+ const int y = _data->readSint16LE();
+ debugC(1, kDebugScripts, "cmdSetStilCoords(x=%d, y=%d)", x, y);
+ Player *stil = ((Noctropolis::NoctropolisEngine *)_vm)->_stil;
+ stil->_rawPlayer.x = x;
+ stil->_moveTo.x = x;
+ stil->_rawPlayer.y = y;
+ stil->_moveTo.y = y;
+}
+
+void NoctropolisScripts::cmdSetPlayerDir() {
+ byte dir = _data->readByte();
+ debugC(1, kDebugScripts, "cmdSetPlayerDir(%d)", dir);
+ _vm->_player->setDirFromScript(dir);
+}
+
+void NoctropolisScripts::cmdSetStilDir() {
+ byte dir = _data->readByte();
+ debugC(1, kDebugScripts, "cmdSetStilDir(%d)", dir);
+ ((Noctropolis::NoctropolisEngine *)_vm)->_stil->setDirFromScript(dir);
+}
+
+void NoctropolisScripts::cmdStilScale() {
+ short scale = _data->readUint16LE();
+ debugC(1, kDebugScripts, "cmdStilScale(%d)", scale);
+ _vm->_stilScaleOff = scale;
+}
+
+void NoctropolisScripts::cmdLockInterface() {
+ debugC(1, kDebugScripts, "cmdLockInterface()");
+ _vm->_events->_interfaceOff = true;
+ _vm->_events->setCursor(CURSOR_DARK_ANKH);
+}
+
+void NoctropolisScripts::cmdUnlockInterface() {
+ debugC(1, kDebugScripts, "cmdUnlockInterface()");
+ _vm->_events->_interfaceOff = false;
+ debug("TODO: cmdUnlockInterface - restore cursor");
+ _vm->_events->setCursor(CURSOR_ARROW);
+}
+
bool NoctropolisScripts::executeSpecial(int commandIndex, int param1, int param2) {
NoctropolisEngine *vm = ((NoctropolisEngine *)_vm);
diff --git a/engines/access/noctropolis/noctropolis_scripts.h b/engines/access/noctropolis/noctropolis_scripts.h
index a8386265a9c..9ac05478dc1 100644
--- a/engines/access/noctropolis/noctropolis_scripts.h
+++ b/engines/access/noctropolis/noctropolis_scripts.h
@@ -38,8 +38,55 @@ public:
void searchForSequence() override;
+protected:
+ virtual void setOpcodes() override;
+
+ void cmdJumpUse_v3();
+ void cmdJumpTalk_v3();
+ void cmdJumpGoto_v3();
+ void cmdSetVideo_v3();
+ void cmdDispAbout_v3();
+ void cmdFadeOut_v3();
+ void cmdEndObject_v3();
+ void cmdCharSpeak_v3();
+
+ void cmdDoTravel_Noct();
+ void cmdDigitalPlay();
+ void cmdFillSound();
+ void cmdPlayVid1();
+ void cmdCharWait();
+ void cmdUndoText();
+ void cmdResetAnim();
+ void cmdWalkTo();
+ void cmdWalkCheck();
+
+ void cmdSoundEnd();
+ void cmdFadeWhite();
+ void cmdGotoFrame();
+ void cmdPlayerScale();
+ void cmdRestoreBlock();
+ void cmdCopyScnBuf();
+ void cmdStilWalkTo();
+ void cmdStilWalkCheck();
+ void cmdStilOff();
+ void cmdStilOn();
+ void cmdReturnExit();
+ void cmdSetCoords();
+ void cmdSetStilCoords();
+ void cmdSetPlayerDir();
+ void cmdSetStilDir();
+ void cmdStilScale();
+ void cmdLockInterface();
+ void cmdUnlockInterface();
+ void cmdPlayerSpeak();
+ void cmdPlayerChoice();
+
private:
void skipCommand(byte cmd);
+
+ Common::Point _askBase;
+ bool _keepAskPosition;
+
};
} // end namespace Noctropolis
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2dca492a88f..ca365e00537 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -26,7 +26,6 @@
#include "access/asurface.h"
#include "access/martian/martian_resources.h"
#include "access/noctropolis/noctropolis_game.h"
-#include "access/noctropolis/noctropolis_resources.h"
namespace Access {
@@ -44,7 +43,6 @@ Scripts::Scripts(AccessEngine *vm) : Manager(vm) {
_choiceStart = 0;
_charsOrg = Common::Point(0, 0);
_texsOrg = Common::Point(0, 0);
- _keepAskPosition = false;
setOpcodes();
}
@@ -53,140 +51,88 @@ Scripts::~Scripts() {
}
void Scripts::setOpcodes() {
- COMMAND_LIST[0] = &Scripts::cmdObject;
- COMMAND_LIST[1] = &Scripts::cmdEndObject;
- COMMAND_LIST[2] = &Scripts::cmdJumpLook;
- COMMAND_LIST[3] = &Scripts::cmdJumpOpen;
- COMMAND_LIST[4] = &Scripts::cmdJumpGet;
- COMMAND_LIST[5] = &Scripts::cmdJumpMove;
- COMMAND_LIST[6] = &Scripts::cmdJumpUse;
- COMMAND_LIST[7] = &Scripts::cmdJumpTalk;
- COMMAND_LIST[8] = &Scripts::cmdNull;
- COMMAND_LIST[9] = &Scripts::cmdPrint_v1;
- COMMAND_LIST[10] = &Scripts::cmdRetPos;
- COMMAND_LIST[11] = &Scripts::cmdAnim;
- COMMAND_LIST[12] = &Scripts::cmdSetFlag;
- COMMAND_LIST[13] = &Scripts::cmdCheckFlag;
- COMMAND_LIST[14] = &Scripts::cmdGoto;
- COMMAND_LIST[15] = &Scripts::cmdAddScore;
- COMMAND_LIST[16] = &Scripts::cmdSetInventory;
- COMMAND_LIST[17] = &Scripts::cmdCheckInventory;
- COMMAND_LIST[18] = &Scripts::cmdSetPlayerCoords;
- COMMAND_LIST[19] = &Scripts::cmdNewRoom;
- COMMAND_LIST[20] = &Scripts::cmdConverse;
- COMMAND_LIST[21] = &Scripts::cmdCheckFrame;
- COMMAND_LIST[22] = &Scripts::cmdCheckAnim;
- COMMAND_LIST[23] = &Scripts::cmdSnd;
- COMMAND_LIST[24] = &Scripts::cmdRetNeg;
- COMMAND_LIST[25] = &Scripts::cmdRetPos;
- COMMAND_LIST[26] = &Scripts::cmdCheckLoc;
- COMMAND_LIST[27] = &Scripts::cmdSetAnim;
- COMMAND_LIST[28] = &Scripts::cmdDispInv_v1;
- COMMAND_LIST[29] = &Scripts::cmdSetAbout;
- COMMAND_LIST[30] = &Scripts::cmdSetTimer;
- COMMAND_LIST[31] = &Scripts::cmdCheckTimer;
- COMMAND_LIST[32] = &Scripts::cmdSetTravel;
- COMMAND_LIST[33] = &Scripts::cmdJumpGoto;
- COMMAND_LIST[34] = &Scripts::cmdSetVideo_v1;
- COMMAND_LIST[35] = &Scripts::cmdPlayVideo;
- COMMAND_LIST[36] = &Scripts::cmdPlotImage;
- COMMAND_LIST[37] = &Scripts::cmdSetDisplay;
- COMMAND_LIST[38] = &Scripts::cmdSetBuffer;
- COMMAND_LIST[39] = &Scripts::cmdSetScroll;
- COMMAND_LIST[40] = &Scripts::cmdSaveRect;
- COMMAND_LIST[41] = &Scripts::cmdVideoEnded; // aka CheckVid
- COMMAND_LIST[42] = &Scripts::cmdSetBufVid;
- COMMAND_LIST[43] = &Scripts::cmdPlayBufVid;
- COMMAND_LIST[44] = &Scripts::cmdRemoveLast;
- COMMAND_LIST[45] = &Scripts::cmdDoTravel;
- COMMAND_LIST[46] = &Scripts::cmdCheckAbout;
- COMMAND_LIST[47] = &Scripts::cmdSpecial;
- COMMAND_LIST[48] = &Scripts::cmdSetCycle;
- COMMAND_LIST[49] = &Scripts::cmdCycle;
- COMMAND_LIST[50] = &Scripts::cmdCharSpeak;
- COMMAND_LIST[51] = &Scripts::cmdTexSpeak;
- COMMAND_LIST[52] = &Scripts::cmdTexChoice;
- COMMAND_LIST[53] = &Scripts::cmdWait;
- COMMAND_LIST[54] = &Scripts::cmdSetConPos;
- COMMAND_LIST[55] = &Scripts::cmdCheckVFrame;
- COMMAND_LIST[56] = &Scripts::cmdJumpChoice;
- COMMAND_LIST[57] = &Scripts::cmdReturnChoice;
- COMMAND_LIST[58] = &Scripts::cmdClearBlock;
- COMMAND_LIST[59] = &Scripts::cmdLoadSound;
- COMMAND_LIST[60] = &Scripts::cmdFreeSound;
- COMMAND_LIST[61] = &Scripts::cmdSetVideoSound;
- COMMAND_LIST[62] = &Scripts::cmdPlayVideoSound;
- COMMAND_LIST[63] = &Scripts::cmdPrintWatch;
- COMMAND_LIST[64] = &Scripts::cmdDispAbout;
- COMMAND_LIST[65] = &Scripts::cmdPushLocation_v1;
- COMMAND_LIST[66] = &Scripts::cmdCheckTravel;
- COMMAND_LIST[67] = &Scripts::cmdBlock;
- COMMAND_LIST[68] = &Scripts::cmdPlayerOff;
- COMMAND_LIST[69] = &Scripts::cmdPlayerOn;
- COMMAND_LIST[70] = &Scripts::cmdDead;
- COMMAND_LIST[71] = &Scripts::cmdFadeOut;
- COMMAND_LIST[72] = &Scripts::cmdEndVideo;
- COMMAND_LIST[73] = &Scripts::cmdHelp_v1;
-}
-
-void Scripts::setOpcodes_v2() {
- // Modify command list for Amazon
- COMMAND_LIST[3] = &Scripts::cmdJumpHelp;
- COMMAND_LIST[9] = &Scripts::cmdPrint_v2;
- COMMAND_LIST[15] = &Scripts::cmdSetInventory;
- COMMAND_LIST[28] = &Scripts::cmdDispInv_v2;
- COMMAND_LIST[29] = &Scripts::cmdSetTimer;
- COMMAND_LIST[32] = &Scripts::cmdJumpGoto;
- COMMAND_LIST[40] = &Scripts::cmdVideoEnded;
- COMMAND_LIST[45] = COMMAND_LIST[46] = &Scripts::cmdSpecial;
- COMMAND_LIST[63] = COMMAND_LIST[64] = COMMAND_LIST[65] = COMMAND_LIST[66] = COMMAND_LIST[67] = &Scripts::cmdPushLocation;
-}
-
-void Scripts::setOpcodes_v3() {
- // Modify command list for Noctropolis
- COMMAND_LIST[1] = &Scripts::cmdEndObject_v3;
- COMMAND_LIST[6] = &Scripts::cmdJumpUse_v3;
- COMMAND_LIST[7] = &Scripts::cmdJumpTalk_v3;
- COMMAND_LIST[9] = &Scripts::cmdPrint_v2;
- COMMAND_LIST[18] = &Scripts::cmdSetCoords;
- COMMAND_LIST[33] = &Scripts::cmdJumpGoto_v3;
- COMMAND_LIST[34] = &Scripts::cmdSetVideo_v3;
- COMMAND_LIST[45] = &Scripts::cmdDoTravel_Noct;
- COMMAND_LIST[50] = &Scripts::cmdCharSpeak_v3;
- COMMAND_LIST[51] = &Scripts::cmdPlayerSpeak;
- COMMAND_LIST[52] = &Scripts::cmdPlayerChoice;
- // 52 to 57 unchanged
- COMMAND_LIST[57] = &Scripts::cmdDigitalPlay;
- COMMAND_LIST[60] = &Scripts::cmdFillSound;
- COMMAND_LIST[61] = &Scripts::cmdBD;
- COMMAND_LIST[62] = &Scripts::cmdPlayVid1;
- COMMAND_LIST[63] = &Scripts::cmdNull; // empty function CmdPRINTWITHOUT
- COMMAND_LIST[64] = &Scripts::cmdDispAbout_v3;
- COMMAND_LIST[71] = &Scripts::cmdFadeOut_v3;
- COMMAND_LIST[74] = &Scripts::cmdCharWait;
- COMMAND_LIST[75] = &Scripts::cmdUndoText;
- COMMAND_LIST[76] = &Scripts::cmdResetAnim;
- COMMAND_LIST[77] = &Scripts::cmdWalkTo;
- COMMAND_LIST[78] = &Scripts::cmdWalkCheck;
- COMMAND_LIST[79] = &Scripts::cmdSoundEnd;
- COMMAND_LIST[80] = &Scripts::cmdFadeWhite;
- COMMAND_LIST[81] = &Scripts::cmdGotoFrame;
- COMMAND_LIST[82] = &Scripts::cmdPlayerScale;
- COMMAND_LIST[83] = &Scripts::cmdRestoreBlock;
- COMMAND_LIST[84] = &Scripts::cmdCopyScnBuf;
- COMMAND_LIST[85] = &Scripts::cmdStilWalkTo;
- COMMAND_LIST[86] = &Scripts::cmdStilWalkCheck;
- COMMAND_LIST[87] = &Scripts::cmdStilOff;
- COMMAND_LIST[88] = &Scripts::cmdStilOn;
- COMMAND_LIST[89] = &Scripts::cmdReturnExit;
- COMMAND_LIST[90] = &Scripts::cmdSetStilCoords;
- COMMAND_LIST[91] = &Scripts::cmdSetPlayerDir;
- COMMAND_LIST[92] = &Scripts::cmdSetStilDir;
- COMMAND_LIST[93] = &Scripts::cmdStilScale;
- COMMAND_LIST[94] = &Scripts::cmdLockInterface;
- COMMAND_LIST[95] = &Scripts::cmdUnlockInterface;
+ #define Opcode(func) Common::SharedPtr<Common::Functor0<void>>( \
+ new Common::Functor0Mem<void, Scripts>(this, &Scripts::func))
+
+ _opcodes.resize(74);
+ // This is the default list used in MM.
+ _opcodes[0] = Opcode(cmdObject);
+ _opcodes[1] = Opcode(cmdEndObject);
+ _opcodes[2] = Opcode(cmdJumpLook);
+ _opcodes[3] = Opcode(cmdJumpOpen);
+ _opcodes[4] = Opcode(cmdJumpGet);
+ _opcodes[5] = Opcode(cmdJumpMove);
+ _opcodes[6] = Opcode(cmdJumpUse);
+ _opcodes[7] = Opcode(cmdJumpTalk);
+ _opcodes[8] = Opcode(cmdNull);
+ _opcodes[9] = Opcode(cmdPrint_v1);
+ _opcodes[10] = Opcode(cmdRetPos);
+ _opcodes[11] = Opcode(cmdAnim);
+ _opcodes[12] = Opcode(cmdSetFlag);
+ _opcodes[13] = Opcode(cmdCheckFlag);
+ _opcodes[14] = Opcode(cmdGoto);
+ _opcodes[15] = Opcode(cmdAddScore);
+ _opcodes[16] = Opcode(cmdSetInventory);
+ _opcodes[17] = Opcode(cmdCheckInventory);
+ _opcodes[18] = Opcode(cmdSetPlayerCoords);
+ _opcodes[19] = Opcode(cmdNewRoom);
+ _opcodes[20] = Opcode(cmdConverse);
+ _opcodes[21] = Opcode(cmdCheckFrame);
+ _opcodes[22] = Opcode(cmdCheckAnim);
+ _opcodes[23] = Opcode(cmdSnd);
+ _opcodes[24] = Opcode(cmdRetNeg);
+ _opcodes[25] = Opcode(cmdRetPos);
+ _opcodes[26] = Opcode(cmdCheckLoc);
+ _opcodes[27] = Opcode(cmdSetAnim);
+ _opcodes[28] = Opcode(cmdDispInv_v1);
+ _opcodes[29] = Opcode(cmdSetAbout);
+ _opcodes[30] = Opcode(cmdSetTimer);
+ _opcodes[31] = Opcode(cmdCheckTimer);
+ _opcodes[32] = Opcode(cmdSetTravel);
+ _opcodes[33] = Opcode(cmdJumpGoto);
+ _opcodes[34] = Opcode(cmdSetVideo_v1);
+ _opcodes[35] = Opcode(cmdPlayVideo);
+ _opcodes[36] = Opcode(cmdPlotImage);
+ _opcodes[37] = Opcode(cmdSetDisplay);
+ _opcodes[38] = Opcode(cmdSetBuffer);
+ _opcodes[39] = Opcode(cmdSetScroll);
+ _opcodes[40] = Opcode(cmdSaveRect);
+ _opcodes[41] = Opcode(cmdVideoEnded); // aka CheckVid
+ _opcodes[42] = Opcode(cmdSetBufVid);
+ _opcodes[43] = Opcode(cmdPlayBufVid);
+ _opcodes[44] = Opcode(cmdRemoveLast);
+ _opcodes[45] = Opcode(cmdDoTravel);
+ _opcodes[46] = Opcode(cmdCheckAbout);
+ _opcodes[47] = Opcode(cmdSpecial);
+ _opcodes[48] = Opcode(cmdSetCycle);
+ _opcodes[49] = Opcode(cmdCycle);
+ _opcodes[50] = Opcode(cmdCharSpeak);
+ _opcodes[51] = Opcode(cmdTexSpeak);
+ _opcodes[52] = Opcode(cmdTexChoice);
+ _opcodes[53] = Opcode(cmdWait);
+ _opcodes[54] = Opcode(cmdSetConPos);
+ _opcodes[55] = Opcode(cmdCheckVFrame);
+ _opcodes[56] = Opcode(cmdJumpChoice);
+ _opcodes[57] = Opcode(cmdReturnChoice);
+ _opcodes[58] = Opcode(cmdClearBlock);
+ _opcodes[59] = Opcode(cmdLoadSound);
+ _opcodes[60] = Opcode(cmdFreeSound);
+ _opcodes[61] = Opcode(cmdSetVideoSound);
+ _opcodes[62] = Opcode(cmdPlayVideoSound);
+ _opcodes[63] = Opcode(cmdPrintWatch);
+ _opcodes[64] = Opcode(cmdDispAbout);
+ _opcodes[65] = Opcode(cmdPushLocation_v1);
+ _opcodes[66] = Opcode(cmdCheckTravel);
+ _opcodes[67] = Opcode(cmdBlock);
+ _opcodes[68] = Opcode(cmdPlayerOff);
+ _opcodes[69] = Opcode(cmdPlayerOn);
+ _opcodes[70] = Opcode(cmdDead);
+ _opcodes[71] = Opcode(cmdFadeOut);
+ _opcodes[72] = Opcode(cmdEndVideo);
+ _opcodes[73] = Opcode(cmdHelp_v1);
}
+
void Scripts::setScript(Resource *res, bool restartFlag) {
debugC(1, kDebugScripts, "setScript(res=%p (%s), restartFlag=%d)", (void *)res, res->getFileName(), restartFlag);
_resource = res;
@@ -313,7 +259,7 @@ int Scripts::executeScript() {
}
void Scripts::executeCommand(int commandIndex) {
- (this->*COMMAND_LIST[commandIndex])();
+ (*_opcodes[commandIndex])();
}
void Scripts::cmdObject() {
@@ -333,48 +279,6 @@ void Scripts::cmdEndObject() {
}
-void Scripts::cmdEndObject_v3() {
- if (_vm->_room->_selectCommand == Noctropolis::kNoctCmdTalk && _vm->_boxSelectY == 0x62) {
-
- // Note: removed "DARK/" from these..
- const char *vidfile = "VID/A4IN00.VID";
- if (_vm->_flags[91] == 2) {
- vidfile = "VID/A4IN26.VID";
- }
-
- if (_vm->_textFlag) {
- Noctropolis::NoctropolisResources *res = (Noctropolis::NoctropolisResources *)_vm->_res;
- const char *subtitle = res->getEndMessage();
- if (_vm->_flags[91] == 2) {
- subtitle = res->getStilMessage();
- }
- _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctPlain);
- _vm->_bubbleBox->placeBubble(subtitle);
- }
-
- debug("cmdEndObject_v3: TODO: duck music volume to 50%% here.");
-
- VideoPlayer_v2 vidPlayer(_vm);
- vidPlayer.VideoPlayer::setVideo(_vm->_screen, Common::Point(100, 100), Common::Path(vidfile), 0);
- vidPlayer.playToEnd();
-
- _vm->_bubbleBox->clearBubbles();
-
- } else {
- const char *msg = _vm->_res->getGeneralMessage(_vm->_room->_selectCommand);
- debugC(1, kDebugScripts, "cmdEndObject_v3(msg=\"%s\")", msg);
-
- _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctCenter);
- if (_vm->_player->_roomNumber <= 4)
- _vm->_bubbleBox->_type = (BoxType)(_vm->_bubbleBox->_type | kTextBoxNoctPlain);
-
- printString(msg);
- }
- _continuenceFlag = true;
- _endFlag = true;
- _returnCode = 0;
-}
-
void Scripts::cmdJumpLook() {
debugCN(1, kDebugScripts, "cmdJumpLook(selectCommand=%d)", _vm->_room->_selectCommand);
if (_vm->_room->_selectCommand == 0) {
@@ -441,17 +345,6 @@ void Scripts::cmdJumpUse() {
}
}
-void Scripts::cmdJumpUse_v3() {
- debugCN(1, kDebugScripts, "cmdJumpUse_v3(selectCommand=%d)", _vm->_room->_selectCommand);
- if (_vm->_room->_selectCommand == Noctropolis::kNoctCmdUse) {
- debugC(1, kDebugScripts, " -> True");
- cmdGoto();
- } else {
- debugC(1, kDebugScripts, " -> False");
- _data->skip(2);
- }
-}
-
void Scripts::cmdJumpTalk() {
debugCN(1, kDebugScripts, "cmdJumpTalk(selectCommand=%d)", _vm->_room->_selectCommand);
if (_vm->_room->_selectCommand == 6) {
@@ -463,17 +356,6 @@ void Scripts::cmdJumpTalk() {
}
}
-void Scripts::cmdJumpTalk_v3() {
- debugCN(1, kDebugScripts, "cmdJumpTalk_v3(selectCommand=%d)", _vm->_room->_selectCommand);
- if (_vm->_room->_selectCommand == Noctropolis::kNoctCmdTalk) {
- debugC(1, kDebugScripts, " -> True");
- cmdGoto();
- } else {
- debugC(1, kDebugScripts, " -> False");
- _data->skip(2);
- }
-}
-
void Scripts::cmdNull() {
debugC(1, kDebugScripts, "cmdNull()");
}
@@ -777,12 +659,6 @@ void Scripts::cmdDispInv_v1() {
_continuenceFlag = true;
}
-void Scripts::cmdDispInv_v2() {
- debugC(1, kDebugScripts, "cmdDispInv_v2()");
- _vm->_inventory->displayInv();
- _vm->_events->forceSetCursor(CURSOR_ARROW);
-}
-
void Scripts::cmdSetAbout() {
int idx = _data->readByte();
byte val = _data->readByte();
@@ -864,17 +740,6 @@ void Scripts::cmdJumpGoto() {
}
}
-void Scripts::cmdJumpGoto_v3() {
- debugCN(1, kDebugScripts, "cmdJumpGoto_v3(selectCommand=%d)", _vm->_room->_selectCommand);
- if (_vm->_room->_selectCommand == Noctropolis::kNoctCmdGoto) {
- debugC(1, kDebugScripts, " -> True");
- cmdGoto();
- } else {
- debugC(1, kDebugScripts, " -> False");
- _data->skip(2);
- }
-}
-
void Scripts::cmdSetVideo_v1() {
Common::Point pt;
pt.x = _data->readSint16LE();
@@ -885,48 +750,6 @@ void Scripts::cmdSetVideo_v1() {
_vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate);
}
-void Scripts::cmdSetVideo_v3() {
- Common::Point pt;
- short rawx = _data->readSint16LE();
- pt.y = _data->readSint16LE();
- int cellIndex = _data->readUint16LE();
- int noFrame = _data->readUint16LE();
-
- if (cellIndex > 0x3f)
- error("Invalid room video number %d", cellIndex);
-
- const int roomNum = _vm->_player->_roomNumber;
-#if 0
- bool flag;
-
- if ((roomNum == 0x1e && cellIndex == 0) || roomNum == 0x21 || (roomNum == 0x36 && cellIndex < 32))
- flag = true;
- else
- flag = false;
-#endif
-
- if (roomNum == 0x1b || roomNum == 0x1e)
- pt.x = rawx + -5;
- else
- pt.x = rawx;
-
- debugC(1, kDebugScripts, "cmdSetVideo_v3(x=%d, y=%d, cellIndex=%d, noFrame=%d)", pt.x, pt.y, cellIndex, noFrame);
-
- Common::Path vidpath(_vm->_extraCells[cellIndex]._vidFilename);
- if (!_vm->_files->existFile(vidpath)) {
- // Try removing "DARK/" from video file names -
- // for the demo the are in DEMO/
- Common::StringArray parts = vidpath.splitComponents();
- vidpath = Common::Path::joinComponents(parts.begin() + 1, parts.end());
- }
- _vm->_video->setVideo(_vm->_screen, pt, vidpath, 0);
-
- ((VideoPlayer_v2 *)_vm->_video)->setDrawBorder(noFrame == 0);
-
- if (cellIndex == 1 && roomNum == 0x36)
- _vm->_screen->setIconPalette();
-}
-
void Scripts::cmdPlayVideo() {
debugC(1, kDebugScripts, "cmdPlayVideo()");
_vm->_video->playVideo();
@@ -1065,11 +888,6 @@ void Scripts::cmdDoTravel() {
}
}
-void Scripts::cmdDoTravel_Noct() {
- ((Noctropolis::NoctropolisEngine *)_vm)->doTravel();
- cmdRetPos();
-}
-
void Scripts::cmdHelp_v1() {
debugC(1, kDebugScripts, "cmdHelp_v1()");
@@ -1170,105 +988,6 @@ void Scripts::cmdCharSpeak() {
findNull();
}
-void Scripts::cmdCharSpeak_v3() {
- int16 x = _data->readUint16LE();
- int16 y = _data->readUint16LE();
- _charsOrg = Common::Point(x, y);
- _vm->_screen->_printOrg = _charsOrg;
- _vm->_screen->_printStart = _charsOrg;
-
- //debug("cmdCharSpeak_v3: duck music volume to 50%% here.");
-
- Common::String str = _data->readString();
- debugC(1, kDebugScripts, "cmdCharSpeak(%d, %d, str=\"%s\")", x, y, str.c_str());
- if (_vm->_textFlag) {
- _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctPlain);
- _vm->_bubbleBox->placeBubble(str);
- }
- findNull();
-}
-
-void Scripts::cmdPlayerSpeak() {
- int16 x = _data->readUint16LE();
- int16 y = _data->readUint16LE();
-
- const char *title = _vm->_res->getEgoName();
- Common::String str = _data->readString();
- debugC(1, kDebugScripts, "cmdPlayerSpeak(%d, %d, \"%s\", \"%s\")", x, y, title, str.c_str());
-
- _charsOrg = Common::Point(x, y);
- _vm->_screen->_printOrg = _charsOrg;
- _vm->_screen->_printStart = _charsOrg;
- _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctPlain);
- _vm->_bubbleBox->_bubbleDisplStr = title;
-
- _vm->_bubbleBox->placeBubble(str);
- _continuenceFlag = true;
- findNull();
-
- while (!_vm->shouldQuitOrRestart() && !_vm->_events->isKeyActionMousePressed()) {
- _vm->_events->pollEventsAndWait();
- }
-
- _vm->_events->debounceLeft();
- _vm->_events->zeroKeysActions();
- _vm->_bubbleBox->clearBubbles();
-}
-
-
-void Scripts::cmdPlayerChoice() {
- // This is similar to cmdTexChoice but used in Noctropolis
- assert(_vm->gameIs(kGameNoctropolis));
-
- int16 x = _data->readUint16LE();
- int16 startY = _data->readUint16LE();
-
- Common::Array<Common::String> choiceStrs;
- for (int i = 0; i < 6; i++) {
- Common::String tmpStr;
- tmpStr = _data->readString();
- if (!tmpStr.empty())
- choiceStrs.push_back(tmpStr);
- }
-
- debugC(1, kDebugScripts, "cmdPlayerChoice(%d, %d, ..(%d choices)..)", x, startY, choiceStrs.size());
-
- _vm->_screen->_printStart = _vm->_screen->_printOrg = Common::Point(x, startY);
-
- _vm->_events->setCursor(CURSOR_ARROW);
- const char *respTitle = ((Noctropolis::NoctropolisResources *)_vm->_res)->getResponseTitle();
- Common::Array<Common::Rect> responseCoords;
-
- for (uint i = 0; i < choiceStrs.size(); i++) {
- _vm->_bubbleBox->_bubbleDisplStr = Common::String::format(respTitle, i + 1);
- _vm->_bubbleBox->_type = (BoxType)(kTextBoxNoctCaption | kTextBoxNoctPlain);
- _vm->_bubbleBox->calcBubble(choiceStrs[i]);
- _vm->_bubbleBox->printBubble(choiceStrs[i]);
- responseCoords.push_back(_vm->_bubbleBox->_bounds);
- _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 10;
- _vm->_screen->_printOrg.x = _vm->_screen->_printStart.x;
- }
-
- _vm->_bubbleBox->_bubbleDisplStr = _vm->_bubbleBox->_bubbleTitle;
-
- int choice = -1;
- do {
- _vm->_events->pollEvents();
- if (_vm->shouldQuit())
- return;
-
- if (_vm->_events->_leftButton) {
- _vm->_events->debounceLeft();
- choice = _vm->_events->checkMouseBox1(responseCoords);
- }
- } while (choice == -1);
-
- _choice = choice + 1;
- _vm->_bubbleBox->clearBubbles();
-
- _continuenceFlag = true;
-}
-
void Scripts::cmdTexSpeak() {
_vm->_screen->_printOrg = _texsOrg;
_vm->_screen->_printStart = _texsOrg;
@@ -1509,165 +1228,6 @@ void Scripts::cmdDispAbout() {
}
-void Scripts::cmdDispAbout_v3() {
- // Graphical ask box for Noctropolis
- debugC(1, kDebugScripts, "cmdDispAbout_v3()");
-
- static constexpr struct { int16 x1, y1, x2, y2; } askItemPos[] = {
- {84, 0, 126, 48},
- {42, 24, 84, 72},
- {126, 24, 168, 72},
- {0, 48, 42, 96},
- {84, 48, 126, 96},
- {168, 48, 210, 96},
- {42, 72, 84, 120},
- {126, 72, 168, 120},
- {18, 102, 40, 120},
- {186, 102, 208, 120}
- };
- bool menuUpArrow = false;
- bool menuDownArrow = false;
- int hoveredItem = -1, slotIndex;
- byte slotItems[20];
- Common::Array<byte> items;
- int selectedItem = -2;
- bool needRedraw = true;
-
- Common::Path path = ((Noctropolis::NoctropolisResources *)_vm->_res)->translatePath("DARK/ASK.AP");
- Resource *spriteData = _vm->_files->loadRawFile(path);
- SpriteResource *askSprites = new SpriteResource(_vm, spriteData);
- delete spriteData;
-
- if (!_keepAskPosition) {
- for (int i = 0; i < 40; i++)
- _vm->_asked[i] = false;
-
- int16 warpMouseX, warpMouseY;
- _askBase.x = _vm->_events->clipMouseCenter(_vm->_events->_mousePos.x, 226, 640, warpMouseX);
- _askBase.y = _vm->_events->clipMouseCenter(_vm->_events->_mousePos.y, 145, 400, warpMouseY);
-
- _keepAskPosition = true;
- if (warpMouseX != _vm->_events->_mousePos.x || warpMouseY != _vm->_events->_mousePos.y)
- g_system->warpMouse(warpMouseX, warpMouseY);
- }
-
- const Common::Point base = _askBase;
-
- // Build the list of available ask items
- for (int i = 0; i < 40; i++) {
- if (_vm->_ask[i] == 1)
- items.push_back(i);
- }
-
- // Grab screen background
- _vm->_screen->saveBlock(Common::Rect(base, 226, 145));
- // Draw ask panel
- _vm->_screen->plotImage(askSprites, 0, Common::Point(base.x, base.y + 96));
-
- _vm->_events->setCursor(CURSOR_ARROW);
-
- const Font *font = _vm->_fonts.getFont(1);
- Font::_fontColors[0] = 246;
- Font::_fontColors[1] = 238;
-
- Noctropolis::NoctropolisResources *res = (Noctropolis::NoctropolisResources *)_vm->_res;
-
- while (selectedItem == -2 && !_vm->shouldQuitOrRestart()) {
- int item = -1;
-
- if (needRedraw) {
- hoveredItem = -1;
- menuUpArrow = false;
- menuDownArrow = false;
- slotIndex = 0;
- if (items.size() > 0) {
- // Draw "Up" arrow if required
- menuUpArrow = _vm->_startAboutItem > 0;
- _vm->_screen->plotImage(askSprites, menuUpArrow ? 1 : 3, Common::Point(base.x + 18, base.y + 102));
- // Draw ask items
- for (uint i = 0; i < 8 && _vm->_startAboutItem + i < items.size(); i++) {
- slotItems[slotIndex] = items[_vm->_startAboutItem + i];
- _vm->_screen->plotImage(askSprites, slotItems[slotIndex] + 6, Common::Point(base.x + askItemPos[slotIndex].x1, base.y + askItemPos[slotIndex].y1));
- if (_vm->_asked[slotItems[slotIndex]]) {
- _vm->_screen->plotImage(askSprites, 5, Common::Point(base.x + askItemPos[slotIndex].x1, base.y + askItemPos[slotIndex].y1));
- }
- slotIndex++;
- }
- // Draw "Down" arrow if required
- menuDownArrow = (int)items.size() > _vm->_startAboutItem + 8;
- _vm->_screen->plotImage(askSprites, menuDownArrow ? 2 : 3, Common::Point(base.x + 186, base.y + 102));
- }
- // Draw remaining empty slots if any
- while (slotIndex < 8) {
- slotItems[slotIndex] = 0;
- _vm->_screen->plotImage(askSprites, 4, Common::Point(base.x + askItemPos[slotIndex].x1, base.y + askItemPos[slotIndex].y1));
- slotIndex++;
- }
- needRedraw = false;
- }
-
- // Find at which slot the mouse is
- for (int i = 0; i < 10; i++) {
- if (_vm->_events->_mousePos.x >= base.x + askItemPos[i].x1 && _vm->_events->_mousePos.x <= base.x + askItemPos[i].x2 &&
- _vm->_events->_mousePos.y >= base.y + askItemPos[i].y1 && _vm->_events->_mousePos.y <= base.y + askItemPos[i].y2) {
- item = i;
- break;
- }
- }
-
- if (hoveredItem != item) {
- _vm->_screen->fillRect(Common::Rect(Common::Point(base.x + 41, base.y + 128), 150, 8), 246);
- if ((item == 8 && menuUpArrow) || (item == 9 && menuDownArrow)) {
- font->drawString(_vm->_screen, res->getMoreItemsText(), Common::Point(base.x + 41, base.y + 128));
- } else if (item >= 0 && item < 8) {
- font->drawString(_vm->_screen, res->getAskItem(slotItems[item]), Common::Point(base.x + 41, base.y + 128));
- }
- hoveredItem = item;
- }
-
- // Support the mouse wheel for scrolling through the ask items
- if (menuUpArrow && _vm->_events->_wheelUp) {
- _vm->_startAboutItem--;
- needRedraw = true;
- } else if (menuDownArrow && _vm->_events->_wheelDown) {
- _vm->_startAboutItem++;
- needRedraw = true;
- }
-
- if (_vm->_events->_leftButton) {
- _vm->_events->debounceLeft();
- if (hoveredItem == 8 && menuUpArrow) {
- _vm->_startAboutItem--;
- needRedraw = true;
- } else if (hoveredItem == 9 && menuDownArrow) {
- _vm->_startAboutItem++;
- needRedraw = true;
- } else if (hoveredItem >= 0 && hoveredItem < 8) {
- if (_vm->_startAboutItem + hoveredItem > (int)items.size()) {
- // An empty slot was clicked
- selectedItem = -1;
- } else {
- selectedItem = slotItems[hoveredItem];
- _vm->_asked[selectedItem] = true;
- }
- }
- } else if (_vm->_events->_rightButton) {
- _vm->_events->debounceRight();
- selectedItem = 255;
- _keepAskPosition = false;
- }
-
- _vm->_events->pollEventsAndWait();
- }
-
- _vm->_flags[99] = selectedItem;
-
- // Restore screen background
- _vm->_screen->restoreBlock();
-
- _continuenceFlag = true;
-}
-
void Scripts::cmdPushLocation_v1() {
// MM only
@@ -1676,12 +1236,6 @@ void Scripts::cmdPushLocation_v1() {
cmdGoto();
}
-void Scripts::cmdPushLocation() {
- // TODO: Double-check this code. It doesn't seem to match function
- // sub13BC0 in Amazon?
- debugC(1, kDebugScripts, "cmdPushLocation()");
- _choiceStart = _data->pos() - 1;
-}
void Scripts::cmdCheckTravel() {
int idx = _data->readSint16LE();
@@ -1736,279 +1290,10 @@ void Scripts::cmdFadeOut() {
_vm->_screen->forceFadeOut();
}
-void Scripts::cmdFadeOut_v3() {
- byte flag = _data->readByte();
- debugC(1, kDebugScripts, "cmdFadeOut_v3(%d)", flag);
- if (flag)
- _vm->_screen->forceFadeIn();
- else
- _vm->_screen->forceFadeOut();
- _continuenceFlag = true;
-}
-
void Scripts::cmdEndVideo() {
debugC(1, kDebugScripts, "cmdEndVideo()");
_vm->_video->closeVideo();
_vm->_video->_videoEnd = true;
}
-void Scripts::cmdDigitalPlay() {
- // Wait until the current sound has finished playing, then
- // if subtitles are enabled wait for input
- debugC(1, kDebugScripts, "cmdDigitalPlay()");
- while (_vm->_sound->isSFXPlaying() && !_vm->shouldQuit()) {
- _vm->_events->pollEventsAndWait();
- }
-
- _continuenceFlag = true;
-}
-
-void Scripts::cmdFillSound() {
- debugC(1, kDebugScripts, "cmdFillSound()");
- while (_vm->_sound->isSFXPlaying() && !_vm->shouldQuit()) {
- _vm->_events->pollEventsAndWait();
- Common::CustomEventType action;
- if (_vm->_events->getAction(action) && action == kActionSkip) {
- _vm->_sound->stopSound();
- _vm->_events->zeroKeysActions();
- break;
- }
- }
- _continuenceFlag = true;
-}
-
-void Scripts::cmdPlayVid1() {
- // TODO: should this mark the video finished if it's not loaded?
- _vm->_video->playVideo();
- _continuenceFlag = true;
-}
-
-void Scripts::cmdCharWait() {
- int x = _data->readSint16LE();
- int y = _data->readUint16LE();
- Common::String msg = _data->readString();
- debugC(1, kDebugScripts, "cmdCharWait(%d, %d, '%s')", x, y, msg.c_str());
-
- printString(msg);
- _continuenceFlag = true;
-}
-
-void Scripts::cmdUndoText() {
- debugC(1, kDebugScripts, "cmdUndoText()");
-
- // TODO: Restore music volume to 100%
-
- if (_vm->_textFlag)
- _vm->_bubbleBox->clearBubbles();
-}
-
-void Scripts::cmdResetAnim() {
- byte animNum = _data->readByte();
- debugC(1, kDebugScripts, "cmdResetAnim(%d)", animNum);
- Animation *anim = _vm->_animation->findAnimation(animNum);
- if (!anim)
- error("cmdResetAnim: Invalid anim num %d", animNum);
-
- anim->_countdownTicks = anim->_initialTicks;
- anim->_frameNumber = 0;
- if (anim->_type == 3 || anim->_type == 4) {
- anim->_currentLoopCount = anim->_loopCount;
- } else {
- anim->_currentLoopCount = 0;
- }
-}
-
-void Scripts::cmdWalkTo() {
- int16 x = _data->readSint16LE();
- int16 y = _data->readSint16LE();
- int16 dir = _data->readSint16LE();
- debugC(1, kDebugScripts, "cmdWalkTo(%d, %d, %d)", x, y, dir);
-
- _vm->_player->_moveTo.x = x;
- _vm->_player->_moveTo.y = y;
- _vm->_player->setDirFromScript(dir);
- _vm->_player->_move = (Direction)dir;
- _vm->_player->_playerMove = true;
-}
-
-void Scripts::cmdWalkCheck() {
- debugCN(1, kDebugScripts, "cmdWalkCheck()");
- if (!_vm->_player->_playerMove) {
- // Walk is done
- debugC(1, kDebugScripts, " -> True");
- cmdGoto();
- } else {
- debugC(1, kDebugScripts, " -> False");
- _data->skip(2);
- }
-}
-
-void Scripts::cmdSoundEnd() {
- debugCN(1, kDebugScripts, "cmdSoundEnd()");
- if (!_vm->_sound->isSFXPlaying()) {
- debugC(1, kDebugScripts, " -> True");
- cmdGoto();
- } else {
- debugC(1, kDebugScripts, " -> False");
- _data->skip(2);
- }
-}
-
-void Scripts::cmdFadeWhite() {
- debugC(1, kDebugScripts, "cmdFadeWhite()");
- _vm->_screen->forceFadeWhite();
- _continuenceFlag = true;
-}
-
-void Scripts::cmdGotoFrame() {
- uint16 animNum = _data->readUint16LE();
- uint16 frameNum = _data->readUint16LE();
- debugC(1, kDebugScripts, "cmdGotoFrame(%d, %d)", animNum, frameNum);
- Animation *anim = _vm->_animation->findAnimation(animNum);
- if (!anim)
- error("cmdGotoFrame: Invalid anim num %d", animNum);
- anim->_frameNumber = frameNum;
-}
-
-void Scripts::cmdPlayerScale() {
- _vm->_manScaleOff = _data->readUint16LE();
- debugC(1, kDebugScripts, "cmdPlayerScale(%d)", _vm->_manScaleOff);
-}
-
-void Scripts::cmdRestoreBlock() {
- int16 x = _data->readSint16LE();
- int16 y = _data->readSint16LE();
- int16 w = _data->readSint16LE();
- int16 h = _data->readSint16LE();
- debugC(1, kDebugScripts, "cmdRestoreBlock(%d, %d, %d, %d)", x, y, w, h);
- Common::Rect r(Common::Point(x, y), w, h);
- r.translate(-_vm->_screen->_windowXAdd, -_vm->_screen->_windowYAdd);
- r.clip(_vm->_screen->w, _vm->_screen->h);
- _vm->_screen->copyBlock(&_vm->_buffer2, r);
-
- // Remake does this, but it doesn't use same buffer setup..
- //_vm->clearPlotImagesIn(x, y, w, h);
- //_vm->clearPlotVidsIn(x, y, w, h);
-}
-
-void Scripts::cmdCopyScnBuf() {
- debugC(1, kDebugScripts, "cmdCopyScnBuf()");
-
- // Copy the screen to the buffer, applying windowing offsets
-
- //
- // WORKAROUND: This causes double-drawing in the noct credits?
- // Just skip for now which causes a small graphical glitch after
- // showing the colored bars video.
- //
- if (_vm->_player->_roomNumber == 0x61)
- return;
-
- Common::Rect src(_vm->_screen->w, _vm->_screen->h);
- const Common::Rect screenSize = src;
- src.translate(_vm->_screen->_windowXAdd, _vm->_screen->_windowYAdd + _vm->_screen->_screenYOff);
- src.clip(screenSize);
- Common::Rect dest = src;
- dest.translate(-dest.left, -dest.top);
- _vm->_buffer2.blitFrom(*_vm->_screen, src, dest);
-}
-
-void Scripts::cmdStilWalkTo() {
- int16 x = _data->readSint16LE();
- int16 y = _data->readSint16LE();
- int16 dir = _data->readSint16LE();
- debugC(1, kDebugScripts, "cmdStilWalkTo(%d, %d, %d)", x, y, dir);
-
- ((Noctropolis::NoctropolisEngine*)_vm)->_stil->_moveTo.x = x;
- ((Noctropolis::NoctropolisEngine*)_vm)->_stil->_moveTo.y = y;
- ((Noctropolis::NoctropolisEngine*)_vm)->_stil->setDirFromScript(dir);
- ((Noctropolis::NoctropolisEngine*)_vm)->_stil->_move = (Direction)dir;
- ((Noctropolis::NoctropolisEngine*)_vm)->_stil->_playerMove = true;
-}
-
-void Scripts::cmdStilWalkCheck() {
- debugCN(1, kDebugScripts, "cmdStilWalkCheck()");
- if (!((Noctropolis::NoctropolisEngine*)_vm)->_stil->_playerMove) {
- debugC(1, kDebugScripts, " -> True");
- cmdGoto();
- } else {
- debugC(1, kDebugScripts, " -> False");
- _data->skip(2);
- }
-}
-
-void Scripts::cmdStilOff() {
- debugC(1, kDebugScripts, "cmdStilOff()");
- ((Noctropolis::NoctropolisEngine *)_vm)->_stil->_playerOff = true;
-}
-
-void Scripts::cmdStilOn() {
- debugC(1, kDebugScripts, "cmdStilOn()");
- ((Noctropolis::NoctropolisEngine *)_vm)->_stil->_playerOff = false;
-}
-
-void Scripts::cmdReturnExit() {
- debugC(1, kDebugScripts, "cmdReturnExit()");
- _vm->_exitBox = true;
- _endFlag = true;
- _returnCode = 0;
-}
-
-void Scripts::cmdSetCoords() {
- const int x = _data->readSint16LE();
- const int y = _data->readSint16LE();
- debugC(1, kDebugScripts, "cmdSetCoords(x=%d, y=%d)", x, y);
- _vm->_player->_rawPlayer.x = x;
- _vm->_player->_moveTo.x = x;
- _vm->_player->checkScroll();
- bool hscroll = _vm->_player->_scrollFlag;
- _vm->_player->_rawPlayer.y = y;
- _vm->_player->_moveTo.y = y;
- _vm->_player->checkScroll();
- _vm->_player->_scrollFlag |= hscroll;
-}
-
-void Scripts::cmdSetStilCoords() {
- const int x = _data->readSint16LE();
- const int y = _data->readSint16LE();
- debugC(1, kDebugScripts, "cmdSetStilCoords(x=%d, y=%d)", x, y);
- Player *stil = ((Noctropolis::NoctropolisEngine *)_vm)->_stil;
- stil->_rawPlayer.x = x;
- stil->_moveTo.x = x;
- stil->_rawPlayer.y = y;
- stil->_moveTo.y = y;
-}
-
-void Scripts::cmdSetPlayerDir() {
- byte dir = _data->readByte();
- debugC(1, kDebugScripts, "cmdSetPlayerDir(%d)", dir);
- _vm->_player->setDirFromScript(dir);
-}
-
-void Scripts::cmdSetStilDir() {
- byte dir = _data->readByte();
- debugC(1, kDebugScripts, "cmdSetStilDir(%d)", dir);
- ((Noctropolis::NoctropolisEngine *)_vm)->_stil->setDirFromScript(dir);
-}
-
-void Scripts::cmdStilScale() {
- short scale = _data->readUint16LE();
- debugC(1, kDebugScripts, "cmdStilScale(%d)", scale);
- _vm->_stilScaleOff = scale;
-}
-
-void Scripts::cmdLockInterface() {
- debugC(1, kDebugScripts, "cmdLockInterface()");
- _vm->_events->_interfaceOff = true;
- _vm->_events->setCursor(CURSOR_DARK_ANKH);
-}
-
-void Scripts::cmdUnlockInterface() {
- debugC(1, kDebugScripts, "cmdUnlockInterface()");
- _vm->_events->_interfaceOff = false;
- debug("TODO: cmdUnlockInterface - restore cursor");
- _vm->_events->setCursor(CURSOR_ARROW);
-}
-
-
} // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 2148143a630..b8c299a997e 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -43,13 +43,6 @@ class Scripts : public Manager {
private:
int _specialFunction;
int _scriptCommand;
- int _choice;
- int32 _choiceStart;
-
- // Game variables only ever used from inside scripts
- Common::Point _askBase; // Noctropolis only
- bool _keepAskPosition; // Noctropolis only
- Common::Point _charsOrg, _texsOrg;
void clearWatch();
void printWatch();
@@ -57,7 +50,13 @@ private:
protected:
Resource *_resource;
Common::SeekableReadStream *_data;
- ScriptMethodPtr COMMAND_LIST[100];
+ //ScriptMethodPtr _opcodes[100];
+ Common::Array<Common::SharedPtr<Common::Functor0<void>>> _opcodes;
+
+ // Game variables only ever used from inside scripts
+ Common::Point _charsOrg, _texsOrg;
+ int _choice;
+ int32 _choiceStart;
virtual bool executeSpecial(int commandIndex, int param1, int param2) = 0;
virtual void executeCommand(int commandIndex);
@@ -66,16 +65,13 @@ protected:
void cmdObject();
void cmdEndObject();
- void cmdEndObject_v3();
void cmdJumpLook();
void cmdJumpOpen();
void cmdJumpHelp();
void cmdJumpGet();
void cmdJumpMove();
void cmdJumpUse();
- void cmdJumpUse_v3();
void cmdJumpTalk();
- void cmdJumpTalk_v3();
void cmdNull();
void cmdPrint_v1();
void cmdPrint_v2();
@@ -102,15 +98,12 @@ protected:
void cmdCheckLoc();
void cmdSetAnim();
void cmdDispInv_v1();
- void cmdDispInv_v2();
void cmdSetAbout();
void cmdSetTimer();
void cmdCheckTimer();
void cmdJumpGoto();
- void cmdJumpGoto_v3();
void cmdSetTravel();
void cmdSetVideo_v1();
- void cmdSetVideo_v3();
void cmdPlayVideo();
void cmdPlotImage();
void cmdSetDisplay();
@@ -140,8 +133,7 @@ protected:
void cmdPlayVideoSound();
void cmdPrintWatch();
void cmdDispAbout();
- void cmdDispAbout_v3();
- void cmdPushLocation();
+
void cmdPushLocation_v1();
void cmdCheckTravel();
void cmdBlock();
@@ -149,42 +141,8 @@ protected:
void cmdPlayerOn();
void cmdDead();
void cmdFadeOut();
- void cmdFadeOut_v3();
void cmdEndVideo();
void cmdHelp_v1();
- //void cmdHelp_v2(); // only in AmazonScripts
- void cmdCycleBack();
- void cmdSetHelp();
- void cmdDoTravel_Noct();
- void cmdDigitalPlay();
- void cmdFillSound();
- void cmdPlayVid1();
- void cmdCharWait();
- void cmdUndoText();
- void cmdResetAnim();
- void cmdWalkTo();
- void cmdWalkCheck();
- void cmdSoundEnd();
- void cmdFadeWhite();
- void cmdGotoFrame();
- void cmdPlayerScale();
- void cmdRestoreBlock();
- void cmdCopyScnBuf();
- void cmdStilWalkTo();
- void cmdStilWalkCheck();
- void cmdStilOff();
- void cmdStilOn();
- void cmdReturnExit();
- void cmdSetCoords();
- void cmdSetStilCoords();
- void cmdSetPlayerDir();
- void cmdSetStilDir();
- void cmdStilScale();
- void cmdLockInterface();
- void cmdUnlockInterface();
- void cmdCharSpeak_v3();
- void cmdPlayerSpeak();
- void cmdPlayerChoice();
public:
int _sequence;
@@ -199,10 +157,6 @@ public:
virtual ~Scripts();
- void setOpcodes();
- void setOpcodes_v2();
- void setOpcodes_v3();
-
void setScript(Resource *data, bool restartFlag = false);
void freeScriptData();
@@ -211,7 +165,6 @@ public:
int executeScript();
- void findNull();
void doCmdPrint_v1(const Common::String &msg);
@@ -224,6 +177,11 @@ public:
void cmdFreeSound();
void cmdRetPos();
void converse1(int val);
+
+protected:
+ virtual void setOpcodes();
+
+ void findNull();
};
} // End of namespace Access
Commit: 2352a26046d21e1f1148d4577ef0ee3906b6fa41
https://github.com/scummvm/scummvm/commit/2352a26046d21e1f1148d4577ef0ee3906b6fa41
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2026-10-20T14:35:34+11:00
Commit Message:
ACCESS: Fall back to EN_ANY for game lang
Fixes #17368.
Changed paths:
engines/access/metaengine.cpp
diff --git a/engines/access/metaengine.cpp b/engines/access/metaengine.cpp
index 1bbd13030a3..806fb613f44 100644
--- a/engines/access/metaengine.cpp
+++ b/engines/access/metaengine.cpp
@@ -70,7 +70,9 @@ bool AccessEngine::isDemo() const {
}
Common::Language AccessEngine::getLanguage() const {
- return _lang;
+ if (_lang != Common::UNK_LANG)
+ return _lang;
+ return Common::EN_ANY;
}
Common::Platform AccessEngine::getPlatform() const {
More information about the Scummvm-git-logs
mailing list