aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mortevielle/actions.cpp40
-rw-r--r--engines/mortevielle/graphics.cpp2
-rw-r--r--engines/mortevielle/mortevielle.cpp2
-rw-r--r--engines/mortevielle/mortevielle.h4
-rw-r--r--engines/mortevielle/outtext.cpp15
-rw-r--r--engines/mortevielle/outtext.h2
-rw-r--r--engines/mortevielle/utils.cpp41
7 files changed, 56 insertions, 50 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp
index 91d9177dc6..88eee0cf7d 100644
--- a/engines/mortevielle/actions.cpp
+++ b/engines/mortevielle/actions.cpp
@@ -241,17 +241,17 @@ void MortevielleEngine::fctTake() {
if ((_coreVar._currPlace == ATTIC) && (_num == 1) && (_coreVar._atticBallHoleObjectId != 0)) {
putInHand(_coreVar._atticBallHoleObjectId);
if ((_crep != 997) && (_crep != 139))
- drawAnimFrame(2, 7);
+ displayAnimFrame(2, 7);
}
if ((_coreVar._currPlace == ATTIC) && (_num == 2) && (_coreVar._atticRodHoleObjectId != 0)) {
putInHand(_coreVar._atticRodHoleObjectId);
if ((_crep != 997) && (_crep != 139))
- drawAnimFrame(2, 6);
+ displayAnimFrame(2, 6);
}
if ((_coreVar._currPlace == CELLAR) && (_coreVar._cellarObjectId != 0)) {
putInHand(_coreVar._cellarObjectId);
if ((_crep != 997) && (_crep != 139))
- drawAnimFrame(2, 2);
+ displayAnimFrame(2, 2);
}
if ((_coreVar._currPlace == CRYPT) && (_coreVar._cryptObjectId != 0))
putInHand(_coreVar._cryptObjectId);
@@ -260,13 +260,13 @@ void MortevielleEngine::fctTake() {
putInHand(_coreVar._secretPassageObjectId);
if ((_crep != 997) && (_crep != 139)) {
_crep = 182;
- drawAnimFrame(2, 1);
+ displayAnimFrame(2, 1);
}
}
if ((_coreVar._currPlace == WELL) && (_coreVar._wellObjectId != 0)) {
putInHand(_coreVar._wellObjectId);
if ((_crep != 997) && (_crep != 139))
- drawAnimFrame(2, 1);
+ displayAnimFrame(2, 1);
}
if ((_crep != 997) && (_crep != 182) && (_crep != 139))
_crep = 999;
@@ -631,7 +631,7 @@ void MortevielleEngine::fctOpen() {
_speechManager.startSpeech(7, 9, 1);
}
_openObjects[tmpPlace] = _num;
- drawAnimFrame(1, _num);
+ displayAnimFrame(1, _num);
}
tmpPlace = _coreVar._currPlace;
if (_coreVar._currPlace == CRYPT)
@@ -675,14 +675,14 @@ void MortevielleEngine::fctPlace() {
} else {
_coreVar._atticBallHoleObjectId = _coreVar._selectedObjectId;
if (_coreVar._selectedObjectId == 141)
- drawAnimFrame(1, 7);
+ displayAnimFrame(1, 7);
}
} else if (_coreVar._atticRodHoleObjectId != 0) {
_crep = 188;
} else {
_coreVar._atticRodHoleObjectId = _coreVar._selectedObjectId;
if (_coreVar._selectedObjectId == 159)
- drawAnimFrame(1, 6);
+ displayAnimFrame(1, 6);
}
}
@@ -693,8 +693,8 @@ void MortevielleEngine::fctPlace() {
_coreVar._cellarObjectId = _coreVar._selectedObjectId;
if (_coreVar._selectedObjectId == 151) {
// Open hidden passage
- drawAnimFrame(1, 2);
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 2);
+ displayAnimFrame(1, 1);
handleDescriptionText(2, 165);
displayEmptyHand();
_speechManager.startSpeech(6, -9, 1);
@@ -727,16 +727,16 @@ void MortevielleEngine::fctPlace() {
_menu.setDestinationText(_coreVar._currPlace);
setPal(14);
drawPicture();
- drawAnimFrame(1, 2);
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 2);
+ displayAnimFrame(1, 1);
alertTxt = getString(577);
_dialogManager.show(alertTxt, 1);
- drawAnimFrame(2, 1);
+ displayAnimFrame(2, 1);
_crep = 166;
}
prepareDisplayText();
} else {
- drawAnimFrame(2, 1);
+ displayAnimFrame(2, 1);
_crep = 166;
}
return;
@@ -756,7 +756,7 @@ void MortevielleEngine::fctPlace() {
_crep = 188;
} else if (_coreVar._selectedObjectId == 143) {
_coreVar._secretPassageObjectId = 143;
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 1);
} else {
_crep = 1512;
loseGame();
@@ -768,7 +768,7 @@ void MortevielleEngine::fctPlace() {
_crep = 188;
} else if ((_coreVar._selectedObjectId == 140) || (_coreVar._selectedObjectId == 120)) {
_coreVar._wellObjectId = _coreVar._selectedObjectId;
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 1);
} else {
_crep = 185;
}
@@ -856,7 +856,7 @@ void MortevielleEngine::fctAttach() {
_crep = 999;
if ((_coreVar._selectedObjectId == 120) || (_coreVar._selectedObjectId == 140)) {
_coreVar._wellObjectId = _coreVar._selectedObjectId;
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 1);
} else
_crep = 185;
displayEmptyHand();
@@ -886,7 +886,7 @@ void MortevielleEngine::fctClose() {
++cx;
} while ((cx <= 6) && (_num != _openObjects[cx]));
if (_num == _openObjects[cx]) {
- drawAnimFrame(2, _num);
+ displayAnimFrame(2, _num);
_crep = 998;
_openObjects[cx] = 0;
--_openObjCount;
@@ -1148,7 +1148,7 @@ void MortevielleEngine::fctEnter() {
else {
int randVal = (getRandomNumber(0, 10)) - 5;
_speechManager.startSpeech(7, randVal, 1);
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 1);
int charIndex = convertBitIndexToCharacterIndex(z);
++_coreVar._faithScore;
@@ -1169,7 +1169,7 @@ void MortevielleEngine::fctEnter() {
} else {
int randVal = (getRandomNumber(0, 10)) - 5;
_speechManager.startSpeech(7, randVal, 1);
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 1);
_coreVar._currPlace = _roomDoorId;
prepareDisplayText();
diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp
index cb674a2317..e5edeed97a 100644
--- a/engines/mortevielle/graphics.cpp
+++ b/engines/mortevielle/graphics.cpp
@@ -937,7 +937,7 @@ void ScreenSurface::drawPicture(GfxSurface &surface, int x, int y) {
(x + surface.w) * 2, (y + surface.h) * 2));
// Get a lookup for the palette mapping
- const byte *paletteMap = &_vm->_mem[(kAdrCurrentPicture * 16) + 2];
+ const byte *paletteMap = &_vm->_curPict[2];
// Loop through writing
for (int yp = 0; yp < surface.h; ++yp) {
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index c13eba4a4a..f98832f984 100644
--- a/engines/mortevielle/mortevielle.cpp
+++ b/engines/mortevielle/mortevielle.cpp
@@ -101,9 +101,11 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g
_day = 0;
memset(_mem, 0, sizeof(_mem));
+ _curPict = nullptr;
}
MortevielleEngine::~MortevielleEngine() {
+ free(_curPict);
}
/**
diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h
index 27d590ddb7..91a65c1e0c 100644
--- a/engines/mortevielle/mortevielle.h
+++ b/engines/mortevielle/mortevielle.h
@@ -64,7 +64,6 @@ namespace Mortevielle {
* 7000:4138 - width, height, x/y offset of decoded image
*/
const int kAdrMusic = 0x5000;
-const int kAdrCurrentPicture = 0x7000;
const int kAdrCompMusicBuf1 = 0x7414;
const int kAdrCompMusicBuf2 = 0x3800;
@@ -435,7 +434,7 @@ private:
void addObjectToInventory(int objectId);
void putInHand(int &objId);
void initMaxAnswer();
- void drawAnimFrame(int frameNum, int animId);
+ void displayAnimFrame(int frameNum, int animId);
void copcha();
void adzon();
@@ -477,6 +476,7 @@ public:
// TODO: Replace the following with proper implementations, or refactor out the code using them
byte _mem[65536 * 16];
+ byte *_curPict;
Debugger _debugger;
ScreenSurface _screenSurface;
diff --git a/engines/mortevielle/outtext.cpp b/engines/mortevielle/outtext.cpp
index 311a4c2ee4..37ea06eb33 100644
--- a/engines/mortevielle/outtext.cpp
+++ b/engines/mortevielle/outtext.cpp
@@ -125,17 +125,20 @@ void TextHandler::displayStr(Common::String inputStr, int x, int y, int dx, int
}
/**
- * Load DES file
+ * Load DES (picture container) file
* @remarks Originally called 'chardes'
*/
-void TextHandler::loadDesFile(Common::String filename, int32 skipSize, int length) {
+void TextHandler::loadPictureFile(Common::String filename, int32 skipSize, int length) {
Common::File f;
if (!f.open(filename))
error("Missing file %s", filename.c_str());
assert(skipSize + length <= f.size());
+
+ free(_vm->_curPict);
+ _vm->_curPict = (byte *)malloc(sizeof(byte) * length);
f.seek(skipSize);
- f.read(&_vm->_mem[(kAdrCurrentPicture * 16)], length);
+ f.read(_vm->_curPict, length);
f.close();
}
@@ -257,10 +260,10 @@ void TextHandler::taffich() {
_vm->_maff = a;
npal = a + 37;
}
- loadDesFile(filename, drawingStartPos, drawingSize);
+ loadPictureFile(filename, drawingStartPos, drawingSize);
if (_vm->_currGraphicalDevice == MODE_HERCULES) {
for (int i = 0; i <= 15; ++i) {
- int palh = READ_LE_UINT16(&_vm->_mem[(kAdrCurrentPicture * 16) + 2 + (i << 1)]);
+ int palh = READ_LE_UINT16(&_vm->_curPict[2 + (i << 1)]);
alllum[i] = (palh & 15) + (((uint)palh >> 12) & 15) + (((uint)palh >> 8) & 15);
}
for (int i = 0; i <= 15; ++i) {
@@ -269,7 +272,7 @@ void TextHandler::taffich() {
if (alllum[j] > alllum[k])
k = j;
}
- _vm->_mem[(kAdrCurrentPicture * 16) + 2 + (k << 1)] = rang[i];
+ _vm->_curPict[2 + (k << 1)] = rang[i];
alllum[k] = -1;
}
}
diff --git a/engines/mortevielle/outtext.h b/engines/mortevielle/outtext.h
index 514aae3a4c..1689e01714 100644
--- a/engines/mortevielle/outtext.h
+++ b/engines/mortevielle/outtext.h
@@ -42,7 +42,7 @@ private:
public:
void setParent(MortevielleEngine *vm);
void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ);
- void loadDesFile(Common::String filename, int32 skipSize, int length);
+ void loadPictureFile(Common::String filename, int32 skipSize, int length);
void loadAniFile(Common::String filename, int32 skipSize, int length);
void taffich();
};
diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp
index 0dd197840c..c6dd3f90e7 100644
--- a/engines/mortevielle/utils.cpp
+++ b/engines/mortevielle/utils.cpp
@@ -1979,8 +1979,8 @@ void MortevielleEngine::setPal(int n) {
case MODE_EGA:
case MODE_AMSTRAD1512:
for (int i = 1; i <= 16; ++i) {
- _mem[(kAdrCurrentPicture * 16) + (2 * i)] = _stdPal[n][i].x;
- _mem[(kAdrCurrentPicture * 16) + (2 * i) + 1] = _stdPal[n][i].y;
+ _curPict[(2 * i)] = _stdPal[n][i].x;
+ _curPict[(2 * i) + 1] = _stdPal[n][i].y;
}
break;
case MODE_CGA: {
@@ -2008,12 +2008,12 @@ void MortevielleEngine::setPal(int n) {
void MortevielleEngine::displayCGAPattern(int n, Pattern p, nhom *pal) {
int addr = n * 404 + 0xd700;
- WRITE_LE_UINT16(&_mem[(kAdrCurrentPicture * 16) + addr], p._tax);
- WRITE_LE_UINT16(&_mem[(kAdrCurrentPicture * 16) + addr + 2], p._tay);
+ WRITE_LE_UINT16(&_curPict[addr], p._tax);
+ WRITE_LE_UINT16(&_curPict[addr + 2], p._tay);
addr += 4;
for (int i = 0; i < p._tax; ++i) {
for (int j = 0; j < p._tay; ++j)
- _mem[(kAdrCurrentPicture * 16) + addr + j * p._tax + i] = pal[n]._hom[p._des[i + 1][j + 1]];
+ _curPict[addr + j * p._tax + i] = pal[n]._hom[p._des[i + 1][j + 1]];
}
}
@@ -2240,7 +2240,7 @@ void MortevielleEngine::showTitleScreen() {
void MortevielleEngine::draw(int x, int y) {
_mouse.hideMouse();
setPal(_numpal);
- displayPicture(&_mem[kAdrCurrentPicture * 16], x, y);
+ displayPicture(_curPict, x, y);
_mouse.showMouse();
}
@@ -2250,9 +2250,9 @@ void MortevielleEngine::draw(int x, int y) {
*/
void MortevielleEngine::drawRightFrame() {
setPal(89);
- if (_currGraphicalDevice == MODE_HERCULES) {
- _mem[(kAdrCurrentPicture * 16) + 14] = 15;
- }
+ if (_currGraphicalDevice == MODE_HERCULES)
+ _curPict[14] = 15;
+
_mouse.hideMouse();
displayPicture(&_mem[kAdrRightFramePic * 16], 0, 0);
_mouse.showMouse();
@@ -2544,12 +2544,13 @@ void MortevielleEngine::displayPicture(const byte *pic, int x, int y) {
surface.decode(pic);
if (_currGraphicalDevice == MODE_HERCULES) {
- _mem[(kAdrCurrentPicture * 16) + 2] = 0;
- _mem[(kAdrCurrentPicture * 16) + 32] = 15;
+ _curPict[2] = 0;
+ _curPict[32] = 15;
}
- if ((_caff != 51) && (READ_LE_UINT16(&_mem[(kAdrCurrentPicture * 16) + 0x4138]) > 0x100))
- WRITE_LE_UINT16(&_mem[(kAdrCurrentPicture * 16) + 0x4138], 0x100);
+ // CHECKME: Is it useful?
+ // if ((_caff != 51) && (READ_LE_UINT16(&_mem[(kAdrCurrentPicture * 16) + 0x4138]) > 0x100))
+ // WRITE_LE_UINT16(&_mem[(kAdrCurrentPicture * 16) + 0x4138], 0x100);
_screenSurface.drawPicture(surface, x, y);
}
@@ -2954,7 +2955,7 @@ void MortevielleEngine::displayQuestionText(Common::String s, int cmd) {
* Display animation frame
* @remarks Originally called 'aniof'
*/
-void MortevielleEngine::drawAnimFrame(int frameNum, int animId) {
+void MortevielleEngine::displayAnimFrame(int frameNum, int animId) {
if ((_caff == BATHROOM) && ((animId == 4) || (animId == 5)))
return;
@@ -2994,21 +2995,21 @@ void MortevielleEngine::drawPicture() {
if ((_caff < 30) || (_caff > 32)) {
for (int cx = 1; cx <= 6; ++cx) {
if (_openObjects[cx] != 0)
- drawAnimFrame(1, _openObjects[cx]);
+ displayAnimFrame(1, _openObjects[cx]);
}
if (_caff == ATTIC) {
if (_coreVar._atticBallHoleObjectId == 141)
- drawAnimFrame(1, 7);
+ displayAnimFrame(1, 7);
if (_coreVar._atticRodHoleObjectId == 159)
- drawAnimFrame(1, 6);
+ displayAnimFrame(1, 6);
} else if ((_caff == CELLAR) && (_coreVar._cellarObjectId == 151))
- drawAnimFrame(1, 2);
+ displayAnimFrame(1, 2);
else if ((_caff == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId == 143))
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 1);
else if ((_caff == WELL) && (_coreVar._wellObjectId != 0))
- drawAnimFrame(1, 1);
+ displayAnimFrame(1, 1);
}
if (_caff < ROOM26)