aboutsummaryrefslogtreecommitdiff
path: root/engines/agos
diff options
context:
space:
mode:
authorTravis Howell2006-09-30 06:47:41 +0000
committerTravis Howell2006-09-30 06:47:41 +0000
commitc8689b29d891eaca26e80393b89e8a41e0f2dddf (patch)
tree6b05158c52df74bc29409b77520579ae1af1001f /engines/agos
parentf1c4e30b4d85c078bb7c2a1200bbafc4a64f7290 (diff)
downloadscummvm-rg350-c8689b29d891eaca26e80393b89e8a41e0f2dddf.tar.gz
scummvm-rg350-c8689b29d891eaca26e80393b89e8a41e0f2dddf.tar.bz2
scummvm-rg350-c8689b29d891eaca26e80393b89e8a41e0f2dddf.zip
Add mouse cursor support for PP and minor cleanup
svn-id: r24027
Diffstat (limited to 'engines/agos')
-rw-r--r--engines/agos/agos.cpp12
-rw-r--r--engines/agos/agos.h16
-rw-r--r--engines/agos/cursor.cpp124
-rw-r--r--engines/agos/items.cpp1
4 files changed, 89 insertions, 64 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index d07579f2ef..260d1d0f4a 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -167,9 +167,12 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_subtitles = false;
_animatePointer = 0;
- _mouseCursor = 0;
+ _maxCursorWidth = 0;
+ _maxCursorHeight = 0;
_mouseAnim = 0;
_mouseAnimMax = 0;
+ _mouseCursor = 0;
+ _mouseData = 0;
_oldMouseCursor = 0;
_currentMouseCursor = 0;
_currentMouseAnim = 0;
@@ -607,6 +610,7 @@ void AGOSEngine::setupGame() {
allocItemHeap();
allocTablesHeap();
+ initMouse();
_variableArray = (int16 *)calloc(_numVars, sizeof(int16));
_variableArray2 = (int16 *)calloc(_numVars, sizeof(int16));
@@ -1367,9 +1371,9 @@ void AGOSEngine::setZoneBuffers() {
byte *AGOSEngine::allocBlock(uint32 size) {
byte *block, *blockEnd;
- uint i;
+ int vgaMemSize = _vgaMemSize;
- for (i = 0; i < _vgaMemSize / size; i++) {
+ do {
block = _vgaMemPtr;
blockEnd = block + size;
@@ -1387,7 +1391,7 @@ byte *AGOSEngine::allocBlock(uint32 size) {
_vgaMemPtr = blockEnd;
return block;
}
- }
+ } while (vgaMemSize--);
error("allocBlock: Couldn't find free block");
}
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index 0b5db6cd96..1ebda88f95 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -330,16 +330,12 @@ protected:
int _mouseX, _mouseY;
int _mouseXOld, _mouseYOld;
- enum {
- kMaxCursorWidth = 40,
- kMaxCursorHeight = 40
- };
-
- byte _mouseData[kMaxCursorWidth * kMaxCursorHeight];
+ byte *_mouseData;
byte _animatePointer;
- byte _mouseCursor, _mouseAnim, _mouseAnimMax;
- byte _currentMouseCursor, _currentMouseAnim;
- byte _oldMouseCursor, _oldMouseAnimMax;
+ byte _maxCursorWidth, _maxCursorHeight;
+ byte _mouseAnim, _mouseAnimMax, _mouseCursor;
+ byte _currentMouseAnim, _currentMouseCursor;
+ byte _oldMouseAnimMax, _oldMouseCursor;
uint _mouseHideCount;
bool _mouseToggle;
@@ -687,6 +683,8 @@ protected:
void handleMouseMoved();
void pollMouseXY();
+ void initMouse();
+ void loadMouseImage();
void drawMousePointer();
void drawMousePointer_FF();
void drawMousePart(int image, byte x, byte y);
diff --git a/engines/agos/cursor.cpp b/engines/agos/cursor.cpp
index 70318f649e..27db13a019 100644
--- a/engines/agos/cursor.cpp
+++ b/engines/agos/cursor.cpp
@@ -226,13 +226,48 @@ static const byte _simon2_cursors[10][256] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff },
};
-void AGOSEngine::drawMousePointer() {
- if (getGameType() == GType_SIMON2) {
- CursorMan.replaceCursor(_simon2_cursors[_mouseCursor], 16, 16, 7, 7);
- } else {
- CursorMan.replaceCursor(_simon1_cursor, 16, 16, 0, 0);
- }
-}
+// Feeble Files specific
+static const byte _mouseOffs[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() {
uint x;
@@ -353,48 +388,35 @@ void AGOSEngine::pollMouseXY() {
_mouseY = _sdlMouseY;
}
-// Feeble Files specific
-static const byte _mouseOffs[29 * 32] = {
- 6,0,15,21,16,21,14,21,15,21,16,21,16,21,16,21,15,21,15,21,15,21,14,21,12,21,12,21,12,21,12,21,
- 6,2,10,12,9,12,8,11,7,10,6,9,4,8,3,7,1,7,0,6,3,7,4,8,6,9,7,10,8,11,9,12,
- 0,0,0,0,0,0,0,0,0,1,0,3,0,3,0,4,1,4,1,3,2,3,2,2,1,3,0,4,0,3,0,0,
-
- 0,0,5,16,4,19,2,21,1,21,1,21,1,21,1,18,3,9,6,2,6,0,3,6,4,12,4,13,4,13,4,14,
- 0,0,6,13,5,15,4,16,3,19,2,19,2,19,2,18,1,16,4,10,7,3,7,0,4,2,4,6,0,0,0,0,
-
- 0,0,7,0,7,1,8,1,11,1,13,1,9,1,6,1,6,0,6,0,6,0,7,0,11,0,13,0,9,0,7,0,
-
- 0,0,7,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+void AGOSEngine::initMouse() {
+ if (getGameType() == GType_PP) {
+ _maxCursorWidth = 75;
+ _maxCursorHeight = 97;
+ _mouseData = (byte *)calloc(_maxCursorWidth * _maxCursorHeight, 1);
+ } else if (getGameType() == GType_FF) {
+ _maxCursorWidth = 40;
+ _maxCursorHeight = 40;
+ _mouseData = (byte *)calloc(_maxCursorWidth * _maxCursorHeight, 1);
+ }
+}
-// SAM icons
- 0,0,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,
- 0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 0,0,5,5,5,5,5,5,5,5,5,4,1,1,2,2,3,3,5,5,7,6,9,8,11,10,14,13,16,16,0,0,
- 0,0,4,3,5,2,4,2,4,3,5,3,5,2,4,2,4,3,5,3,5,2,4,3,4,3,5,3,5,2,4,2,
+void AGOSEngine::loadMouseImage() {
+ loadZone(_variableArray[500]);
+ VgaPointersEntry *vpe = &_vgaBufferPointers[_variableArray[500]];
-// Asteroid Map icons
- 0,0,3,0,4,1,5,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,3,0,4,1,5,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,8,0,7,0,8,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-// Other icons
- 0,0,9,9,9,10,8,11,7,11,7,11,8,11,9,10,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,10,7,10,6,10,5,10,4,10,3,10,4,10,5,10,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,7,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,7,3,4,3,2,4,0,5,0,7,0,7,0,5,2,4,4,3,7,3,0,0,0,0,0,0,0,0,0,0,
- 0,0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-// Vent icons
- 0,0,8,3,7,3,6,3,5,3,4,3,3,3,2,3,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,2,3,3,3,4,3,8,3,10,3,12,3,14,3,17,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,3,14,4,12,5,10,6,9,7,8,7,7,8,6,9,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,2,3,3,2,3,4,3,4,3,5,3,4,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ byte *src = vpe->vgaFile2 + READ_LE_UINT32(vpe->vgaFile2 + _variableArray[501] * 8);
+ memcpy(_mouseData, src, _maxCursorWidth * _maxCursorHeight);
+}
- 0,0,7,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,9,9,9,10,8,11,7,11,7,11,8,11,9,10,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,10,7,10,6,10,5,10,4,10,3,10,4,10,5,10,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
+void AGOSEngine::drawMousePointer() {
+ if (getGameType() == GType_PP) {
+ CursorMan.replaceCursor(_mouseData, _maxCursorWidth, _maxCursorHeight, 37, 48, 0);
+ } else if (getGameType() == GType_SIMON2) {
+ CursorMan.replaceCursor(_simon2_cursors[_mouseCursor], 16, 16, 7, 7);
+ } else {
+ CursorMan.replaceCursor(_simon1_cursor, 16, 16, 0, 0);
+ }
+}
void AGOSEngine::drawMousePointer_FF() {
uint cursor;
@@ -449,7 +471,7 @@ void AGOSEngine::drawMousePointer_FF() {
hotspotY += 18;
}
- CursorMan.replaceCursor(_mouseData, kMaxCursorWidth, kMaxCursorHeight, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(_mouseData, _maxCursorWidth, _maxCursorHeight, hotspotX, hotspotY, 0);
}
}
@@ -458,7 +480,7 @@ void AGOSEngine::drawMousePart(int image, byte x, byte y) {
byte *src;
int width, height;
- byte *dst = _mouseData + y * kMaxCursorWidth + x;
+ byte *dst = _mouseData + y * _maxCursorWidth + x;
src = vpe->vgaFile2 + image * 8;
width = READ_LE_UINT16(src + 6);
@@ -466,8 +488,8 @@ void AGOSEngine::drawMousePart(int image, byte x, byte y) {
src = vpe->vgaFile2 + READ_LE_UINT32(src);
- assert(width + x <= kMaxCursorWidth);
- assert(height + y <= kMaxCursorWidth);
+ assert(width + x <= _maxCursorWidth);
+ assert(height + y <= _maxCursorWidth);
for (int h = 0; h < height; h++) {
for (int w = 0; w < width; w++) {
@@ -475,7 +497,7 @@ void AGOSEngine::drawMousePart(int image, byte x, byte y) {
dst[w] = src[w];
}
src += width;
- dst += kMaxCursorWidth;
+ dst += _maxCursorWidth;
}
}
diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp
index 8762e0511c..565f90c260 100644
--- a/engines/agos/items.cpp
+++ b/engines/agos/items.cpp
@@ -2580,6 +2580,7 @@ void AGOSEngine::o4_loadMouseImage() {
// 38: load mouse image
getVarOrByte();
getNextItemPtr();
+ loadMouseImage();
}
void AGOSEngine::o4_setShortText() {