aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/agi/picture.cpp21
-rw-r--r--engines/agi/picture.h2
-rw-r--r--engines/agi/preagi_common.cpp2
-rw-r--r--engines/agi/preagi_troll.cpp31
-rw-r--r--engines/agi/preagi_troll.h4
5 files changed, 36 insertions, 24 deletions
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 7df391104d..3d7ae77b16 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -253,11 +253,6 @@ INLINE int PictureMgr::isOkFillHere(int x, int y) {
p = _vm->_game.sbuf16c[y * _width + x];
- // FIXME: This overflows stack, but otherwise is a wild guess
- // original has some checks against color 11 (0xB)
- if (_pictureVersion == AGIPIC_V15 && 0)
- return (p & 0x0f) == 0;
-
if (!_priOn && _scrOn && _scrColor != 15)
return (p & 0x0f) == 15;
@@ -811,7 +806,7 @@ uint8 *PictureMgr::convertV3Pic(uint8 *src, uint32 len) {
* @param clear clear AGI screen before drawing
* @param agi256 load an AGI256 picture resource
*/
-int PictureMgr::decodePicture(int n, int clear, bool agi256, int pic_width, int pic_height) {
+int PictureMgr::decodePicture(int n, int clr, bool agi256, int pic_width, int pic_height) {
debugC(8, kDebugLevelResources, "(%d)", n);
_patCode = 0;
@@ -827,7 +822,7 @@ int PictureMgr::decodePicture(int n, int clear, bool agi256, int pic_width, int
_width = pic_width;
_height = pic_height;
- if (clear && !agi256) // 256 color pictures should always fill the whole screen, so no clearing for them.
+ if (clr && !agi256) // 256 color pictures should always fill the whole screen, so no clearing for them.
memset(_vm->_game.sbuf16c, 0x4f, _width * _height); // Clear 16 color AGI screen (Priority 4, color white).
if (!agi256) {
@@ -843,9 +838,9 @@ int PictureMgr::decodePicture(int n, int clear, bool agi256, int pic_width, int
warning("Oversized AGI256 picture resource %d, decoding only %ux%u part of it", n, _width, _height);
}
- if (clear)
+ if (clr)
_vm->clearImageStack();
- _vm->recordImageStackCall(ADD_PIC, n, clear, agi256, 0, 0, 0, 0);
+ _vm->recordImageStackCall(ADD_PIC, n, clr, agi256, 0, 0, 0, 0);
return errOK;
}
@@ -859,7 +854,7 @@ int PictureMgr::decodePicture(int n, int clear, bool agi256, int pic_width, int
* @param length the size of the picture data buffer
* @param clear clear AGI screen before drawing
*/
-int PictureMgr::decodePicture(byte* data, uint32 length, int clear, int pic_width, int pic_height) {
+int PictureMgr::decodePicture(byte* data, uint32 length, int clr, int pic_width, int pic_height) {
_patCode = 0;
_patNum = 0;
_priOn = _scrOn = false;
@@ -873,7 +868,7 @@ int PictureMgr::decodePicture(byte* data, uint32 length, int clear, int pic_widt
_width = pic_width;
_height = pic_height;
- if (clear) // 256 color pictures should always fill the whole screen, so no clearing for them.
+ if (clr) // 256 color pictures should always fill the whole screen, so no clearing for them.
memset(_vm->_game.sbuf16c, 0x4f, _width * _height); // Clear 16 color AGI screen (Priority 4, color white).
drawPicture(); // Draw 16 color picture.
@@ -900,6 +895,10 @@ int PictureMgr::unloadPicture(int n) {
return errOK;
}
+void PictureMgr::clear() {
+ memset(_vm->_game.sbuf16c, 0x4f, _width * _height);
+}
+
/**
* Show AGI picture.
* This function copies a ``hidden'' AGI picture to the output device.
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 50689b5b3a..5d41036a59 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -101,6 +101,8 @@ public:
void setPictureFlags(int flags) { _flags = flags; }
+ void clear();
+
void setOffset(int offX, int offY) {
_xOffset = offX;
_yOffset = offY;
diff --git a/engines/agi/preagi_common.cpp b/engines/agi/preagi_common.cpp
index 9ad494e410..a1d6883f58 100644
--- a/engines/agi/preagi_common.cpp
+++ b/engines/agi/preagi_common.cpp
@@ -40,7 +40,7 @@ void PreAgiEngine::clearScreen(int attr, bool overrideDefault) {
if (overrideDefault)
_defaultColor = attr;
- _gfx->clearScreen((attr & 0xF0) / 0x10);
+ _gfx->clearScreen((attr & 0xF0) / 0x10);
}
void PreAgiEngine::clearGfxScreen(int attr) {
diff --git a/engines/agi/preagi_troll.cpp b/engines/agi/preagi_troll.cpp
index 5136286768..d34286535b 100644
--- a/engines/agi/preagi_troll.cpp
+++ b/engines/agi/preagi_troll.cpp
@@ -108,16 +108,18 @@ void Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {
// Graphics
-void Troll::drawPic(int iPic, bool f3IsCont, bool clear) {
+void Troll::drawPic(int iPic, bool f3IsCont, bool clr) {
uint8 frame[] = {
0xf1, 0x3, 0xf9, 0x0, 0x0, 0x9f, 0x0, 0x9f, 0xa7, 0x0, 0xa7, 0x0, 0x0, 0xff
};
- if (clear)
- _vm->clearScreen(0x0f);
-
_vm->_picture->setDimensions(IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
+ if (clr) {
+ _vm->clearScreen(0x0f, false);
+ _vm->_picture->clear();
+ }
+
_vm->_picture->setPictureData(frame, ARRAYSIZE(frame));
_vm->_picture->drawPicture();
@@ -330,6 +332,7 @@ void Troll::intro() {
_vm->_system->delayMillis(3200);
// Draw logo
+ _vm->setDefaultTextColor(0x0f);
drawPic(45, false, true);
_vm->_gfx->doUpdate();
@@ -368,7 +371,7 @@ void Troll::gameOver() {
int Troll::drawRoom(char *menu) {
int n;
- drawPic(_currentRoom - 1, false, true);
+ drawPic(_locationDescIndex, false, true);
_vm->_gfx->doUpdate();
// TODO: Troll
@@ -381,7 +384,7 @@ int Troll::drawRoom(char *menu) {
sprintf(tmp, "\n %d.", i);
strcat(menu, tmp);
- strncat(menu, (char *)_gameData + _options[_roomDescs[_currentRoom - 1].options[i]], 35);
+ strncat(menu, (char *)_gameData + _options[_roomDescs[_currentRoom - 1].options[i]- 1], 35);
n = i + 1;
}
@@ -400,6 +403,8 @@ void Troll::gameLoop() {
_treasuresLeft = IDI_TRO_MAX_TREASURE;
_haveFlashlight = false;
_locationDescIndex = 0;
+
+ memset(_roomStates, 0, sizeof(_roomStates));
while (!done) {
*menu = 0;
@@ -412,13 +417,12 @@ void Troll::gameLoop() {
_moves++;
switch(_roomDescs[_currentRoom - 1].optionTypes[currentOption]) {
- case IDI_TRO_SEL_OPTION_1:
+ case OT_GO:
+ _locationDescIndex = _roomDescs[_currentRoom - 1].roomDescIndex[currentOption];
+ _currentRoom = _roomPicStartIdx[_locationDescIndex];
+ _currentRoom += _roomStates[_locationDescIndex];
break;
- case IDI_TRO_SEL_OPTION_2:
- break;
- case IDI_TRO_SEL_OPTION_3:
- break;
- case OT_UNKN:
+ default:
break;
}
}
@@ -433,6 +437,9 @@ void Troll::fillOffsets() {
for (i = 0; i < IDI_TRO_NUM_OPTIONS; i++)
_options[i] = READ_LE_UINT16(_gameData + IDO_TRO_OPTIONS + i * 2);
+
+ for (i = 0; i < IDI_TRO_NUM_NUMROOMS; i++)
+ _roomPicStartIdx[i] = _gameData[IDO_TRO_PICSTARTIDX + i];
}
void Troll::fillRoomDescs() {
diff --git a/engines/agi/preagi_troll.h b/engines/agi/preagi_troll.h
index ef458afb41..a064f4eb04 100644
--- a/engines/agi/preagi_troll.h
+++ b/engines/agi/preagi_troll.h
@@ -119,6 +119,7 @@ const char IDS_TRO_NAME_TREASURE[][16] = {
#define IDI_TRO_NUM_ROOMDESCS 65
#define IDI_TRO_NUM_OPTIONS 129
+#define IDI_TRO_NUM_NUMROOMS 43
// offsets
@@ -129,6 +130,7 @@ const char IDS_TRO_NAME_TREASURE[][16] = {
#define IDO_TRO_LOCMESSAGES 0x1F7C
#define IDO_TRO_ROOMDESCS 0x0082
#define IDO_TRO_OPTIONS 0x0364
+#define IDO_TRO_PICSTARTIDX 0x02CD
enum OptionType {
OT_GO,
@@ -190,6 +192,8 @@ private:
private:
int _pictureOffsets[IDI_TRO_PICNUM];
+ int _roomPicStartIdx[IDI_TRO_NUM_NUMROOMS];
+ int _roomStates[IDI_TRO_NUM_NUMROOMS];
};
} // End of namespace Agi