aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/kyra/kyra3.cpp8
-rw-r--r--engines/kyra/kyra3.h2
-rw-r--r--engines/kyra/screen.cpp14
-rw-r--r--engines/kyra/screen.h7
4 files changed, 22 insertions, 9 deletions
diff --git a/engines/kyra/kyra3.cpp b/engines/kyra/kyra3.cpp
index 0738c1dc94..234ae9f74d 100644
--- a/engines/kyra/kyra3.cpp
+++ b/engines/kyra/kyra3.cpp
@@ -456,13 +456,13 @@ void KyraEngine_v3::updateTableBuffer(uint8 *buf) {
_tableBuffer2 = _tableBuffer1 = buf;
}
-int KyraEngine_v3::addShapeToTable(uint8 *buf, int id, int shapeNum) {
+int KyraEngine_v3::addShapeToTable(const uint8 *buf, int id, int shapeNum) {
debugC(9, kDebugLevelMain, "KyraEngine::addShapeToTable(%p, %d, %d)", (void*)buf, id, shapeNum);
if (!buf)
return 0;
- uint8 *shapePtr = _screen->getPtrToShape(buf, shapeNum);
+ const uint8 *shapePtr = _screen->getPtrToShape(buf, shapeNum);
if (!shapePtr)
return 0;
@@ -636,13 +636,13 @@ void KyraEngine_v3::initItems() {
_screen->loadBitmap("ITEMS.CSH", 3, 3, 0);
for (int i = 248; i <= 319; ++i) {
- addShapeToTable(_screen->getPagePtr(3), i, i-248);
+ addShapeToTable(_screen->getCPagePtr(3), i, i-248);
}
_screen->loadBitmap("ITEMS2.CSH", 3, 3, 0);
for (int i = 320; i <= 397; ++i) {
- addShapeToTable(_screen->getPagePtr(3), i, i-320);
+ addShapeToTable(_screen->getCPagePtr(3), i, i-320);
}
uint32 size = 0;
diff --git a/engines/kyra/kyra3.h b/engines/kyra/kyra3.h
index 6663e0dccd..06a772b726 100644
--- a/engines/kyra/kyra3.h
+++ b/engines/kyra/kyra3.h
@@ -129,7 +129,7 @@ private:
uint8 *allocTableSpace(uint8 *buf, int size, int id);
uint8 *findIdInTable(uint8 *buf, int id);
- int addShapeToTable(uint8 *buf, int id, int shapeNum);
+ int addShapeToTable(const uint8 *buf, int id, int shapeNum);
uint8 *findShapeInTable(int id);
// resource specific
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 5d74e0e97b..3491be528c 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -2242,6 +2242,18 @@ void Screen::loadBitmap(const char *filename, int tempPage, int dstPage, uint8 *
// kyra3 specific
+const uint8 *Screen::getPtrToShape(const uint8 *shpFile, int shape) {
+ debugC(9, kDebugLevelScreen, "KyraEngine::getPtrToShape(%p, %d)", (void *)shpFile, shape);
+ uint16 shapes = READ_LE_UINT16(shpFile);
+
+ if (shapes <= shape)
+ return 0;
+
+ uint32 offset = READ_LE_UINT32(shpFile + (shape << 2) + 2);
+
+ return shpFile + offset + 2;
+}
+
uint8 *Screen::getPtrToShape(uint8 *shpFile, int shape) {
debugC(9, kDebugLevelScreen, "KyraEngine::getPtrToShape(%p, %d)", (void *)shpFile, shape);
uint16 shapes = READ_LE_UINT16(shpFile);
@@ -2254,7 +2266,7 @@ uint8 *Screen::getPtrToShape(uint8 *shpFile, int shape) {
return shpFile + offset + 2;
}
-uint16 Screen::getShapeSize(uint8 *shp) {
+uint16 Screen::getShapeSize(const uint8 *shp) {
debugC(9, kDebugLevelScreen, "KyraEngine::getShapeSize(%p)", (void *)shp);
return READ_LE_UINT16(shp+6);
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 48deaf8400..f678c3f1f9 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -192,12 +192,13 @@ public:
static const int _screenDimTableCountK3;
uint8 *getPtrToShape(uint8 *shpFile, int shape);
+ const uint8 *getPtrToShape(const uint8 *shpFile, int shape);
- uint16 getShapeSize(uint8 *shp);
+ uint16 getShapeSize(const uint8 *shp);
- // only needed for Kyra3!
- uint8 *getPagePtr(int pageNum);
private:
+ uint8 *getPagePtr(int pageNum);
+
int16 encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size);
void restoreMouseRect();
void copyMouseToScreen();