aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2008-12-12 00:10:39 +0000
committerSven Hesse2008-12-12 00:10:39 +0000
commit19146fe03206a2039c0dd568af1a81a8e5411556 (patch)
tree4c65e1b8eeb0b10a0abf7b9a879d3d20e42248bc /engines
parentc65886a3ea3a4fb30d34d9cc3136dd34db044d9f (diff)
downloadscummvm-rg350-19146fe03206a2039c0dd568af1a81a8e5411556.tar.gz
scummvm-rg350-19146fe03206a2039c0dd568af1a81a8e5411556.tar.bz2
scummvm-rg350-19146fe03206a2039c0dd568af1a81a8e5411556.zip
Working cursor in Urban Runner
svn-id: r35309
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/draw_v1.cpp22
-rw-r--r--engines/gob/draw_v2.cpp42
-rw-r--r--engines/gob/game.cpp25
-rw-r--r--engines/gob/game.h72
-rw-r--r--engines/gob/init.cpp11
-rw-r--r--engines/gob/inter_v1.cpp19
-rw-r--r--engines/gob/inter_v6.cpp17
-rw-r--r--engines/gob/video_v6.cpp19
8 files changed, 102 insertions, 125 deletions
diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp
index 8a5ac021eb..b856be1310 100644
--- a/engines/gob/draw_v1.cpp
+++ b/engines/gob/draw_v1.cpp
@@ -324,8 +324,6 @@ void Draw_v1::printTotText(int16 id) {
void Draw_v1::spriteOperation(int16 operation) {
uint16 id;
byte *dataBuf;
- Game::TotResItem *itemPtr;
- int32 offset;
int16 len;
int16 x, y;
int16 perLine;
@@ -409,25 +407,11 @@ void Draw_v1::spriteOperation(int16 operation) {
_destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1);
delete[] dataBuf;
break;
- } else if (id >= _vm->_game->_totResourceTable->itemsCount) {
- warning("Trying to load non-existent sprite (id = %d, count = %d)", id,
- _vm->_game->_totResourceTable->itemsCount);
- break;
- }
- // Load from .TOT resources
- itemPtr = &_vm->_game->_totResourceTable->items[id];
- offset = itemPtr->offset;
- if (offset >= 0) {
- dataBuf = _vm->_game->_totResourceTable->dataPtr +
- szGame_TotResTable + szGame_TotResItem *
- _vm->_game->_totResourceTable->itemsCount + offset;
- } else {
- dataBuf = _vm->_game->_imFileData +
- (int32) READ_LE_UINT32(&((int32 *) _vm->_game->_imFileData)[-offset - 1]);
}
- _spriteRight = itemPtr->width;
- _spriteBottom = itemPtr->height;
+ if (!(dataBuf = _vm->_game->loadTotResource(id, 0, &_spriteRight, &_spriteBottom)))
+ break;
+
_vm->_video->drawPackedSprite(dataBuf,
_spriteRight, _spriteBottom,
_destSpriteX, _destSpriteY,
diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp
index b5f0981c27..f14821d4cd 100644
--- a/engines/gob/draw_v2.cpp
+++ b/engines/gob/draw_v2.cpp
@@ -49,11 +49,13 @@ void Draw_v2::initScreen() {
_backSurface = _spritesArray[21];
_vm->_video->clearSurf(_backSurface);
- initSpriteSurf(23, 32, 16, 2);
- _cursorSpritesBack = _spritesArray[23];
- _cursorSprites = _cursorSpritesBack;
- _scummvmCursor =
- _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR);
+ if (!_spritesArray[23]) {
+ initSpriteSurf(23, 32, 16, 2);
+ _cursorSpritesBack = _spritesArray[23];
+ _cursorSprites = _cursorSpritesBack;
+ _scummvmCursor =
+ _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR);
+ }
_spritesArray[20] = _frontSurface;
_spritesArray[21] = _backSurface;
@@ -62,10 +64,10 @@ void Draw_v2::initScreen() {
}
void Draw_v2::closeScreen() {
- freeSprite(23);
- _cursorSprites = 0;
- _cursorSpritesBack = 0;
- _scummvmCursor = 0;
+ //freeSprite(23);
+ //_cursorSprites = 0;
+ //_cursorSpritesBack = 0;
+ //_scummvmCursor = 0;
freeSprite(21);
}
@@ -609,8 +611,6 @@ void Draw_v2::printTotText(int16 id) {
void Draw_v2::spriteOperation(int16 operation) {
uint16 id;
byte *dataBuf;
- Game::TotResItem *itemPtr;
- int32 offset;
int16 len;
int16 x, y;
SurfaceDesc *sourceSurf, *destSurf;
@@ -756,6 +756,7 @@ void Draw_v2::spriteOperation(int16 operation) {
case DRAW_LOADSPRITE:
id = _spriteLeft;
+ warning("Loadsprite %d to %d", id, _destSurface);
if ((id >= 30000) || (_vm->_game->_lomHandle >= 0)) {
dataBuf = 0;
@@ -779,19 +780,9 @@ void Draw_v2::spriteOperation(int16 operation) {
}
// Load from .TOT resources
- itemPtr = &_vm->_game->_totResourceTable->items[id];
- offset = itemPtr->offset;
- if (offset >= 0) {
- dataBuf = _vm->_game->_totResourceTable->dataPtr +
- szGame_TotResTable + szGame_TotResItem *
- _vm->_game->_totResourceTable->itemsCount + offset;
- } else {
- dataBuf = _vm->_game->_imFileData +
- (int32) READ_LE_UINT32(&((int32 *) _vm->_game->_imFileData)[-offset - 1]);
- }
+ if (!(dataBuf = _vm->_game->loadTotResource(id, 0, &_spriteRight, &_spriteBottom)))
+ break;
- _spriteRight = itemPtr->width;
- _spriteBottom = itemPtr->height;
_vm->_video->drawPackedSprite(dataBuf,
_spriteRight, _spriteBottom,
_destSpriteX, _destSpriteY,
@@ -802,6 +793,11 @@ void Draw_v2::spriteOperation(int16 operation) {
break;
case DRAW_PRINTTEXT:
+ if (_vm->getGameType() == kGameTypeUrban) {
+ warning("Urban Stub: Print text \"%s\"", _textToPrint);
+ break;
+ }
+
len = strlen(_textToPrint);
left = _destSpriteX;
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp
index 91d40f3d31..3bc721e08d 100644
--- a/engines/gob/game.cpp
+++ b/engines/gob/game.cpp
@@ -103,6 +103,16 @@ Game::Game(GobEngine *vm) : _vm(vm) {
}
Game::~Game() {
+ delete[] _vm->_game->_totFileData;
+ if (_vm->_game->_totTextData) {
+ if (_vm->_game->_totTextData->items)
+ delete[] _vm->_game->_totTextData->items;
+ delete _vm->_game->_totTextData;
+ }
+ if (_vm->_game->_totResourceTable) {
+ delete[] _vm->_game->_totResourceTable->items;
+ delete _vm->_game->_totResourceTable;
+ }
}
byte *Game::loadExtData(int16 itemId, int16 *pResWidth,
@@ -268,14 +278,27 @@ void Game::capturePop(char doDraw) {
_vm->_draw->freeSprite(30 + _captureCount);
}
-byte *Game::loadTotResource(int16 id, int16 *dataSize) {
+byte *Game::loadTotResource(int16 id,
+ int16 *dataSize, int16 *width, int16 *height) {
+
TotResItem *itemPtr;
int32 offset;
+ if (id >= _vm->_game->_totResourceTable->itemsCount) {
+ warning("Trying to load non-existent TOT resource (%s, %d/%d)",
+ _curTotFile, id, _totResourceTable->itemsCount - 1);
+ return 0;
+ }
+
itemPtr = &_totResourceTable->items[id];
offset = itemPtr->offset;
+
if (dataSize)
*dataSize = itemPtr->size;
+ if (width)
+ *width = itemPtr->width;
+ if (height)
+ *height = itemPtr->height;
if (offset < 0) {
offset = (-offset - 1) * 4;
diff --git a/engines/gob/game.h b/engines/gob/game.h
index b60ef970bf..1f19a64f7a 100644
--- a/engines/gob/game.h
+++ b/engines/gob/game.h
@@ -48,38 +48,6 @@ public:
uint16 funcSub;
} PACKED_STRUCT;
-#define szGame_TotResItem (4 + 2 + 2 + 2)
- struct TotResItem {
- int32 offset; // if > 0, then offset from end of resource table.
- // If < 0, then -offset-1 is index in .IM file table
- int16 size;
- int16 width;
- int16 height;
- } PACKED_STRUCT;
-
-#define szGame_TotResTable (2 + 1)
- struct TotResTable {
- int16 itemsCount;
- byte unknown;
- TotResItem *items;
- byte *dataPtr;
- } PACKED_STRUCT;
-
-#define szGame_ExtItem (4 + 2 + 2 + 2)
- struct ExtItem {
- int32 offset; // offset from the table end
- uint16 size;
- int16 width; // width & 0x7FFF: width, width & 0x8000: pack flag
- int16 height; // not zero
- } PACKED_STRUCT;
-
-#define szGame_ExtTable (2 + 1)
- struct ExtTable {
- int16 itemsCount;
- byte unknown;
- ExtItem *items;
- } PACKED_STRUCT;
-
#define szGame_TotTextItem (2 + 2)
struct TotTextItem {
int16 offset;
@@ -102,7 +70,6 @@ public:
#include "common/pack-end.h" // END STRUCT PACKING
- TotResTable *_totResourceTable;
Collision *_collisionAreas;
Collision *_collStack[5];
@@ -131,7 +98,7 @@ public:
virtual ~Game();
byte *loadExtData(int16 dataId, int16 *pResWidth, int16 *pResHeight, uint32 *dataSize = 0);
- byte *loadTotResource(int16 id, int16 *dataSize = 0);
+ byte *loadTotResource(int16 id, int16 *dataSize = 0, int16 *width = 0, int16 *height = 0);
void capturePush(int16 left, int16 top, int16 width, int16 height);
void capturePop(char doDraw);
@@ -166,6 +133,42 @@ public:
virtual void prepareStart(void) = 0;
protected:
+#include "common/pack-start.h" // START STRUCT PACKING
+
+#define szGame_TotResItem (4 + 2 + 2 + 2)
+ struct TotResItem {
+ int32 offset; // if > 0, then offset from end of resource table.
+ // If < 0, then -offset-1 is index in .IM file table
+ int16 size;
+ int16 width;
+ int16 height;
+ } PACKED_STRUCT;
+
+#define szGame_TotResTable (2 + 1)
+ struct TotResTable {
+ int16 itemsCount;
+ byte unknown;
+ TotResItem *items;
+ byte *dataPtr;
+ } PACKED_STRUCT;
+
+#define szGame_ExtItem (4 + 2 + 2 + 2)
+ struct ExtItem {
+ int32 offset; // offset from the table end
+ uint16 size;
+ int16 width; // width & 0x7FFF: width, width & 0x8000: pack flag
+ int16 height; // not zero
+ } PACKED_STRUCT;
+
+#define szGame_ExtTable (2 + 1)
+ struct ExtTable {
+ int16 itemsCount;
+ byte unknown;
+ ExtItem *items;
+ } PACKED_STRUCT;
+
+#include "common/pack-end.h" // END STRUCT PACKING
+
int16 _lastCollKey;
int16 _lastCollAreaIndex;
int16 _lastCollId;
@@ -178,6 +181,7 @@ protected:
char _tempStr[256];
+ TotResTable *_totResourceTable;
ExtTable *_extTable;
char _curImaFile[18];
diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp
index c2f8b48626..4fba74e02a 100644
--- a/engines/gob/init.cpp
+++ b/engines/gob/init.cpp
@@ -89,7 +89,6 @@ void Init::initGame(const char *totName) {
_vm->_game->_totTextData = 0;
_vm->_game->_totFileData = 0;
- _vm->_game->_totResourceTable = 0;
_palDesc = new Video::PalDesc;
_vm->validateVideoMode(_vm->_global->_videoMode);
@@ -208,16 +207,6 @@ void Init::initGame(const char *totName) {
_vm->_sound->cdStop();
_vm->_sound->cdUnloadLIC();
- delete[] _vm->_game->_totFileData;
- if (_vm->_game->_totTextData) {
- if (_vm->_game->_totTextData->items)
- delete[] _vm->_game->_totTextData->items;
- delete _vm->_game->_totTextData;
- }
- if (_vm->_game->_totResourceTable) {
- delete[] _vm->_game->_totResourceTable->items;
- delete _vm->_game->_totResourceTable;
- }
}
for (int i = 0; i < 4; i++) {
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index 64a3b811ea..777653c822 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -798,6 +798,7 @@ void Inter_v1::o1_initCursor() {
_vm->_draw->adjustCoords(0, &width, &height);
count = load16();
+
if (count < 2)
count = 2;
@@ -1163,10 +1164,8 @@ bool Inter_v1::o1_printTotText(OpFuncParams &params) {
}
bool Inter_v1::o1_loadCursor(OpFuncParams &params) {
- Game::TotResItem *itemPtr;
int16 width, height;
byte *dataBuf;
- int32 offset;
int16 id;
int8 index;
@@ -1176,20 +1175,7 @@ bool Inter_v1::o1_loadCursor(OpFuncParams &params) {
if ((index * _vm->_draw->_cursorWidth) >= _vm->_draw->_cursorSprites->getWidth())
return false;
- itemPtr = &_vm->_game->_totResourceTable->items[id];
- offset = itemPtr->offset;
-
- if (offset < 0) {
- offset = (-offset - 1) * 4;
- dataBuf = _vm->_game->_imFileData +
- (int32) READ_LE_UINT32(_vm->_game->_imFileData + offset);
- } else
- dataBuf = _vm->_game->_totResourceTable->dataPtr + szGame_TotResTable +
- szGame_TotResItem * _vm->_game->_totResourceTable->itemsCount +
- offset;
-
- width = itemPtr->width;
- height = itemPtr->height;
+ dataBuf = _vm->_game->loadTotResource(id, 0, &width, &height);
_vm->_video->fillRect(_vm->_draw->_cursorSprites,
index * _vm->_draw->_cursorWidth, 0,
@@ -1896,6 +1882,7 @@ bool Inter_v1::o1_copySprite(OpFuncParams &params) {
_vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
_vm->_draw->_transparency = load16();
+
_vm->_draw->spriteOperation(DRAW_BLITSURF);
return false;
}
diff --git a/engines/gob/inter_v6.cpp b/engines/gob/inter_v6.cpp
index d5ef5704d0..cb9e1ba8ab 100644
--- a/engines/gob/inter_v6.cpp
+++ b/engines/gob/inter_v6.cpp
@@ -650,10 +650,8 @@ const char *Inter_v6::getOpcodeGoblinDesc(int i) {
}
bool Inter_v6::o6_loadCursor(OpFuncParams &params) {
- Game::TotResItem *itemPtr;
int16 width, height;
byte *dataBuf;
- int32 offset;
int16 id;
int8 index;
@@ -686,20 +684,7 @@ bool Inter_v6::o6_loadCursor(OpFuncParams &params) {
if ((index * _vm->_draw->_cursorWidth) >= _vm->_draw->_cursorSprites->getWidth())
return false;
- itemPtr = &_vm->_game->_totResourceTable->items[id];
- offset = itemPtr->offset;
-
- if (offset < 0) {
- offset = (-offset - 1) * 4;
- dataBuf = _vm->_game->_imFileData +
- (int32) READ_LE_UINT32(_vm->_game->_imFileData + offset);
- } else
- dataBuf = _vm->_game->_totResourceTable->dataPtr + szGame_TotResTable +
- szGame_TotResItem * _vm->_game->_totResourceTable->itemsCount +
- offset;
-
- width = itemPtr->width;
- height = itemPtr->height;
+ dataBuf = _vm->_game->loadTotResource(id, 0, &width, &height);
_vm->_video->fillRect(_vm->_draw->_cursorSprites,
index * _vm->_draw->_cursorWidth, 0,
diff --git a/engines/gob/video_v6.cpp b/engines/gob/video_v6.cpp
index 3433e72bc5..27bc88ad1f 100644
--- a/engines/gob/video_v6.cpp
+++ b/engines/gob/video_v6.cpp
@@ -58,10 +58,12 @@ void Video_v6::drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc *sur
int16 height = READ_LE_UINT16(data + 2);
data += 4;
+ warning("drawPacked: %d, %d, %d, %d", x, y, width, height);
+
const byte *srcData = data;
byte *uncBuf = 0;
- if (*data++ != 0) {
+ if (*srcData++ != 0) {
uint32 size = READ_LE_UINT32(data);
uncBuf = new byte[size];
@@ -88,6 +90,8 @@ void Video_v6::drawYUVData(const byte *srcData, SurfaceDesc *destDesc,
if (dataHeight & 0xF)
dataHeight = (dataHeight & 0xFFF0) + 16;
+ warning("drawYUVData: %d, %d, %d, %d, %d, %d", x, y, width, height, dataWidth, dataHeight);
+
const byte *dataY = srcData;
const byte *dataU = dataY + (dataWidth * dataHeight);
const byte *dataV = dataU + ((dataWidth * dataHeight) >> 4);
@@ -114,10 +118,15 @@ void Video_v6::drawYUV(SurfaceDesc *destDesc, int16 x, int16 y,
int16 dataWidth, int16 dataHeight, int16 width, int16 height,
const byte *dataY, const byte *dataU, const byte *dataV) {
- byte *vidMem = destDesc->getVidMem() + y * width + x;
+ warning("drawYUV: %dx%d->%d+%d (%dx%d) (%dx%d)", width, height, x, y, dataWidth, dataHeight,
+ destDesc->getWidth(), destDesc->getHeight());
+
+ byte *vidMem = destDesc->getVidMem() + y * destDesc->getWidth() + x;
- width = MIN(width, destDesc->getWidth());
- height = MIN(height, destDesc->getHeight());
+ if ((x + width - 1) >= destDesc->getWidth())
+ width = destDesc->getWidth() - x;
+ if ((y + height - 1) >= destDesc->getHeight())
+ height = destDesc->getHeight() - y;
SierraLight *dither = new SierraLight(width, height, _palLUT);
@@ -136,7 +145,7 @@ void Video_v6::drawYUV(SurfaceDesc *destDesc, int16 x, int16 y,
}
dither->nextLine();
- vidMem += width;
+ vidMem += destDesc->getWidth();
}
}