aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2007-01-29 17:04:37 +0000
committerSven Hesse2007-01-29 17:04:37 +0000
commit36a54218b16cef112909bb5362f5d85615368fab (patch)
tree867039305d23d9a71da10c93a1a223d4318487f9 /engines
parent9a7c1c9baf56f28e78acdff45bf6d573daa89a2f (diff)
downloadscummvm-rg350-36a54218b16cef112909bb5362f5d85615368fab.tar.gz
scummvm-rg350-36a54218b16cef112909bb5362f5d85615368fab.tar.bz2
scummvm-rg350-36a54218b16cef112909bb5362f5d85615368fab.zip
- Another attempt at fixing the immediately-closing notepad heisenbug (#1621089)
- Implemented wide surfaces + scrolling - Some clean-up svn-id: r25253
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/draw.cpp168
-rw-r--r--engines/gob/draw.h23
-rw-r--r--engines/gob/draw_v1.cpp5
-rw-r--r--engines/gob/draw_v2.cpp97
-rw-r--r--engines/gob/game.cpp14
-rw-r--r--engines/gob/game_v2.cpp5
-rw-r--r--engines/gob/init.cpp4
-rw-r--r--engines/gob/init_v1.cpp2
-rw-r--r--engines/gob/init_v2.cpp8
-rw-r--r--engines/gob/inter.h4
-rw-r--r--engines/gob/inter_v2.cpp227
-rw-r--r--engines/gob/mult_v2.cpp27
-rw-r--r--engines/gob/util.cpp2
-rw-r--r--engines/gob/video.cpp25
-rw-r--r--engines/gob/video.h3
-rw-r--r--engines/gob/video_v2.cpp17
16 files changed, 182 insertions, 449 deletions
diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp
index b48ec98e3c..9764ea1a16 100644
--- a/engines/gob/draw.cpp
+++ b/engines/gob/draw.cpp
@@ -40,7 +40,6 @@ namespace Gob {
Draw::Draw(GobEngine *vm) : _vm(vm) {
int i;
- int j;
_fontIndex = 0;
_spriteLeft = 0;
@@ -65,13 +64,8 @@ Draw::Draw(GobEngine *vm) : _vm(vm) {
_textToPrint = 0;
_transparency = 0;
- for (i = 0; i < 50; i++) {
+ for (i = 0; i < 50; i++)
_spritesArray[i] = 0;
- _spritesHeights[i] = 0;
- for (j = 0; j < 3; j++) {
- _bigSpritesParts[i][j] = 0;
- }
- }
_invalidatedCount = 0;
for (i = 0; i < 30; i++) {
@@ -163,7 +157,7 @@ void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) {
bottom = temp;
}
- if (left > 319 || right < 0 || top > 199 || bottom < 0)
+ if (left > (_vm->_video->_surfWidth - 1) || right < 0 || top > 199 || bottom < 0)
return;
_noInvalidated = 0;
@@ -171,7 +165,7 @@ void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) {
if (_invalidatedCount >= 30) {
_invalidatedLefts[0] = 0;
_invalidatedTops[0] = 0;
- _invalidatedRights[0] = 319;
+ _invalidatedRights[0] = _vm->_video->_surfWidth - 1;
_invalidatedBottoms[0] = 199;
_invalidatedCount = 1;
return;
@@ -180,8 +174,8 @@ void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) {
if (left < 0)
left = 0;
- if (right > 319)
- right = 319;
+ if (right > (_vm->_video->_surfWidth - 1))
+ right = _vm->_video->_surfWidth - 1;
if (top < 0)
top = 0;
@@ -271,8 +265,8 @@ void Draw::blitInvalidated(void) {
if (_applyPal) {
clearPalette();
- _vm->_video->drawSprite(_backSurface, _frontSurface, 0, 0, 319,
- 199, 0, 0, 0);
+ _vm->_video->drawSprite(_backSurface, _frontSurface, 0, 0,
+ _vm->_video->_surfWidth - 1, 199, 0, 0, 0);
setPalette();
_invalidatedCount = 0;
_noInvalidated = 1;
@@ -295,7 +289,7 @@ void Draw::blitInvalidated(void) {
}
void Draw::setPalette(void) {
- if (_vm->_global->_videoMode != 0x13)
+ if ((_vm->_global->_videoMode != 0x13) && (_vm->_global->_videoMode != 0x14))
error("setPalette: Video mode 0x%x is not supported!\n",
_vm->_global->_videoMode);
@@ -314,17 +308,10 @@ void Draw::clearPalette(void) {
}
void Draw::freeSprite(int16 index) {
- int i;
-
- // .-- sub_CD84 ---
if (_spritesArray[index] == 0)
return;
- _vm->_video->freeSurfDesc(_spritesArray[index]);
- for (i = 0; i < 3; i++)
- if (_bigSpritesParts[index][i] != 0)
- _vm->_video->freeSurfDesc(_bigSpritesParts[index][i]);
- // '------
+ _vm->_video->freeSurfDesc(_spritesArray[index]);
_spritesArray[index] = 0;
}
@@ -353,143 +340,6 @@ void Draw::adjustCoords(char adjust, int16 *coord1, int16 *coord2) {
}
}
-void Draw::fillRect(int16 index, int16 left, int16 top, int16 right,
- int16 bottom, int16 color) {
- int i;
- int16 newbottom;
-
- if (bottom < _spritesHeights[index]) {
- _vm->_video->fillRect(_spritesArray[index], left, top, right, bottom, color);
- return;
- }
-
- if (top < _spritesHeights[index]) {
- _vm->_video->fillRect(_spritesArray[index], left, top, right,
- _spritesHeights[index]-1, color);
- }
-
- for (i = 1; i < 4; i++) {
- if ((_spritesHeights[index] * i) > bottom)
- continue;
- if (_bigSpritesParts[index][i-1] == 0)
- return;
- newbottom = MIN(bottom - (_spritesHeights[index] * i), (_spritesHeights[index] * i) - 1);
- _vm->_video->fillRect(_bigSpritesParts[index][i-1], left, 0, right, newbottom, color);
- }
-}
-
-void Draw::drawSprite(int16 source, int16 dest, int16 left,
- int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) {
- int i;
- int16 topS;
- int16 yS;
- int16 newbottom;
-
- if (bottom < _spritesHeights[source]) {
- drawSprite(_spritesArray[source], dest, left, top, right, bottom, x, y, transp);
- return;
- }
-
- topS = top;
- yS = y;
-
- if (top < _spritesHeights[source]) {
- drawSprite(_spritesArray[source], dest, left, top, right,
- _spritesHeights[source], x, y, transp);
- yS = y + _spritesHeights[source] - top;
- topS = _spritesHeights[source];
- }
- for (i = 1; i < 4; i++) {
- if ((_spritesHeights[source] * i) > topS)
- continue;
- if ((_spritesHeights[source] * (i+1)) <= topS)
- continue;
- if (_bigSpritesParts[source][i-1] == 0)
- break;
- newbottom = MIN(bottom - (_spritesHeights[source] * i), _spritesHeights[source] - 1);
- drawSprite(_bigSpritesParts[source][i-1], dest, left,
- topS - _spritesHeights[source], right, newbottom, x, yS, transp);
- yS += newbottom - (topS - (_spritesHeights[source] * i)) + 1;
- topS += newbottom - (topS - (_spritesHeights[source] * i)) + 1;
- }
-}
-
-void Draw::drawSprite(Video::SurfaceDesc * source, int16 dest, int16 left,
- int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) {
- int i;
- int16 topS;
- int16 yS;
- int16 newbottom;
-
- if ((y + bottom - top) < _spritesHeights[dest]) {
- _vm->_video->drawSprite(source, _spritesArray[dest], left, top,
- right, bottom, x, y, transp);
- return;
- }
-
- topS = top;
- yS = y;
-
- if (y < _spritesHeights[dest]) {
- _vm->_video->drawSprite(source, _spritesArray[dest], left, top, right,
- top + _spritesHeights[dest] - y - 1, x, y, transp);
- yS = _spritesHeights[dest];
- topS += _spritesHeights[dest] - y;
- }
-
- for (i = 1; i < 4; i++) {
- if ((_spritesHeights[dest] * i) > yS)
- continue;
- if ((_spritesHeights[dest] * (i+1)) <= yS)
- continue;
- if (_bigSpritesParts[dest][i-1] == 0)
- break;
- newbottom = MIN(bottom, (int16) (topS + _spritesHeights[dest] - 1));
- _vm->_video->drawSprite(source, _bigSpritesParts[dest][i-1], left, topS,
- right, newbottom, x, yS - (_spritesHeights[dest] * i), transp);
- yS += newbottom - topS + 1;
- topS += newbottom - topS + 1;
- }
-}
-
-void Draw::drawSprite(int16 source, Video::SurfaceDesc * dest, int16 left,
- int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) {
- int i;
- int16 topS;
- int16 yS;
- int16 newbottom;
-
- if (bottom < _spritesHeights[source]) {
- _vm->_video->drawSprite(_spritesArray[source], dest, left, top, right,
- bottom, x, y, transp);
- return;
- }
-
- topS = top;
- yS = y;
-
- if (top < _spritesHeights[source]) {
- _vm->_video->drawSprite(_spritesArray[source], dest, left, top, right,
- _spritesHeights[source] - 1, x, y, transp);
- yS = y + _spritesHeights[source] - top;
- topS = _spritesHeights[source];
- }
-
- for (i = 1; i < 4; i++) {
- if ((_spritesHeights[source] * i) > topS)
- continue;
- if ((_spritesHeights[source] * (i+1)) <= topS)
- continue;
- if (_bigSpritesParts[source][i-1] == 0)
- break;
- newbottom = MIN(bottom - (_spritesHeights[source] * i), _spritesHeights[source] - 1);
- _vm->_video->drawSprite(_bigSpritesParts[source][i-1], dest, left,
- topS - (_spritesHeights[source] * i), right, newbottom, x, y, transp);
- yS += newbottom - (topS - (_spritesHeights[source] * i)) + 1;
- topS += newbottom - (topS - (_spritesHeights[source] * i)) + 1;
- }
-}
-
void Draw::drawString(char *str, int16 x, int16 y, int16 color1, int16 color2,
int16 transp, Video::SurfaceDesc *dest, Video::FontDesc *font) {
while (*str != '\0') {
diff --git a/engines/gob/draw.h b/engines/gob/draw.h
index e67e2981fd..b14d0ffb9e 100644
--- a/engines/gob/draw.h
+++ b/engines/gob/draw.h
@@ -24,6 +24,7 @@
#define GOB_DRAW_H
#include "gob/video.h"
+#include "gob/global.h"
namespace Gob {
@@ -62,8 +63,6 @@ public:
char *_textToPrint;
int16 _transparency;
Video::SurfaceDesc *_spritesArray[50];
- Video::SurfaceDesc *_bigSpritesParts[50][3];
- uint16 _spritesHeights[50];
int16 _invalidatedCount;
int16 _invalidatedTops[30];
@@ -128,14 +127,6 @@ public:
void freeSprite(int16 index);
void adjustCoords(char adjust, int16 *coord1, int16 *coord2);
- void fillRect(int16 index, int16 left, int16 top, int16 right,
- int16 bottom, int16 color);
- void drawSprite(int16 source, int16 dest, int16 left,
- int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
- void drawSprite(Video::SurfaceDesc * source, int16 dest, int16 left,
- int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
- void drawSprite(int16 source, Video::SurfaceDesc * dest, int16 left,
- int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
void drawString(char *str, int16 x, int16 y, int16 color1, int16 color2,
int16 transp, Video::SurfaceDesc *dest, Video::FontDesc *font);
void printTextCentered(int16 arg_0, int16 left, int16 top, int16 right,
@@ -160,7 +151,10 @@ protected:
class Draw_v1 : public Draw {
public:
- virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags);
+ virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags) {
+ _vm->_draw->_spritesArray[index] =
+ _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, flags);
+ }
virtual void printText(void);
virtual void spriteOperation(int16 operation);
virtual void blitCursor(void);
@@ -174,7 +168,12 @@ public:
class Draw_v2 : public Draw_v1 {
public:
- virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags);
+ virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags) {
+ // This would init big surfaces in pieces, to avoid breaking page bounds.
+ // This isn't necessary anymore, so we don't do it.
+ initSpriteSurf(index, _vm->_global->_videoMode, width, height, flags);
+ _vm->_video->clearSurf(_spritesArray[index]);
+ }
virtual void printText(void);
virtual void spriteOperation(int16 operation);
virtual void blitCursor(void);
diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp
index 4628ef1f37..6a96587949 100644
--- a/engines/gob/draw_v1.cpp
+++ b/engines/gob/draw_v1.cpp
@@ -39,11 +39,6 @@ namespace Gob {
Draw_v1::Draw_v1(GobEngine *vm) : Draw(vm) {
}
-void Draw_v1::initBigSprite(int16 index, int16 width, int16 height, int16 flags) {
- _vm->_draw->_spritesArray[index] =
- _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, flags);
-}
-
void Draw_v1::printText(void) {
int16 savedFlags;
int16 ldestSpriteX;
diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp
index fcdb96646a..baf082a5c0 100644
--- a/engines/gob/draw_v2.cpp
+++ b/engines/gob/draw_v2.cpp
@@ -39,54 +39,6 @@ namespace Gob {
Draw_v2::Draw_v2(GobEngine *vm) : Draw_v1(vm) {
}
-void Draw_v2::initBigSprite(int16 index, int16 width, int16 height, int16 flags) {
- int i;
- int16 partsheight;
- int16 remainheight;
- int8 fragment;
-
- if (flags != 0)
- flags = 2;
-
- // .-- sub_CBD0 ---
-
- for (i = 0; i < 3; i++)
- _bigSpritesParts[index][i] = 0;
- _spritesHeights[index] = height;
-
- if (_vm->_video->getRectSize(width, height, flags, _vm->_global->_videoMode) > 65000) {
- _spritesHeights[index] = height & 0xFFFE;
- while (_vm->_video->getRectSize(width, _spritesHeights[index], flags,
- _vm->_global->_videoMode) > 65000) {
- _spritesHeights[index] -= 2;
- }
-
- partsheight = _spritesHeights[index];
- initSpriteSurf(index, _vm->_global->_videoMode, width, partsheight, flags);
- fragment = 0;
- while (partsheight < height) {
- remainheight = height - partsheight;
- if (_spritesHeights[index] >= remainheight) {
- _bigSpritesParts[index][fragment] =
- _vm->_video->initSurfDesc(_vm->_global->_videoMode, width,
- remainheight, flags);
- partsheight = height;
- } else {
- _bigSpritesParts[index][fragment] =
- _vm->_video->initSurfDesc(_vm->_global->_videoMode, width,
- _spritesHeights[index], flags);
- partsheight += _spritesHeights[index];
- }
- _vm->_video->clearSurf(_bigSpritesParts[index][fragment]);
- fragment++;
- }
- } else
- initSpriteSurf(index, _vm->_global->_videoMode, width, height, flags);
-
- _vm->_video->clearSurf(_spritesArray[index]);
- // '------
-}
-
void Draw_v2::printText(void) {
int i;
char *dataPtr;
@@ -545,7 +497,7 @@ void Draw_v2::spriteOperation(int16 operation) {
_spriteBottom -= _frontSurface->height;
}
if (_destSurface == 21)
- invalidateRect(0, _frontSurface->height, 319,
+ invalidateRect(0, _frontSurface->height, _vm->_video->_surfWidth - 1,
_frontSurface->height + _off_2E51B->height - 1);
destSurface += 4;
}
@@ -591,31 +543,12 @@ void Draw_v2::spriteOperation(int16 operation) {
if ((sourceSurf == 0) || (destSurf == 0))
break;
- if ((sourceSurf->vidMode & 0x80) && (destSurf->vidMode & 0x80))
- _vm->_video->drawSprite(_spritesArray[_sourceSurface],
- _spritesArray[_destSurface],
- _spriteLeft, _spriteTop,
- _spriteLeft + _spriteRight - 1,
- _spriteTop + _spriteBottom - 1,
- _destSpriteX, _destSpriteY, _transparency);
- else if (!(sourceSurf->vidMode & 0x80) && (destSurf->vidMode & 0x80))
- drawSprite(_sourceSurface, _spritesArray[_destSurface],
- _spriteLeft, spriteTop,
- _spriteLeft + _spriteRight - 1,
- _spriteTop + _spriteBottom - 1,
- _destSpriteX, _destSpriteY, _transparency);
- else if ((sourceSurf->vidMode & 0x80) && !(destSurf->vidMode & 0x80))
- drawSprite(_spritesArray[_sourceSurface], _destSurface,
- _spriteLeft, spriteTop,
- _spriteLeft + _spriteRight - 1,
- _spriteTop + _spriteBottom - 1,
- _destSpriteX, _destSpriteY, _transparency);
- else
- drawSprite(_sourceSurface, _destSurface,
- _spriteLeft, _spriteTop,
- _spriteLeft + _spriteRight - 1,
- _spriteTop + _spriteBottom - 1,
- _destSpriteX, _destSpriteY, _transparency);
+ _vm->_video->drawSprite(_spritesArray[_sourceSurface],
+ _spritesArray[_destSurface],
+ _spriteLeft, spriteTop,
+ _spriteLeft + _spriteRight - 1,
+ _spriteTop + _spriteBottom - 1,
+ _destSpriteX, _destSpriteY, _transparency);
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
@@ -634,8 +567,8 @@ void Draw_v2::spriteOperation(int16 operation) {
break;
case DRAW_FILLRECT:
- fillRect(_destSurface, destSpriteX, _destSpriteY,
- _destSpriteX + _spriteRight - 1,
+ _vm->_video->fillRect(_spritesArray[_destSurface], destSpriteX,
+ _destSpriteY, _destSpriteX + _spriteRight - 1,
_destSpriteY + _spriteBottom - 1, _backColor);
if (_destSurface == 21) {
@@ -718,7 +651,7 @@ void Draw_v2::spriteOperation(int16 operation) {
left = _destSpriteX;
if ((_fontIndex >= 4) || (_fontToSprite[_fontIndex].sprite == -1)) {
if (_fonts[_fontIndex]->extraData == 0) {
- if (((signed int) _textToPrint[0]) == -1) {
+ if (((int8) _textToPrint[0]) == -1) {
dataBuf = _vm->_game->_totTextData->dataPtr + _textToPrint[1] + 1;
len = *dataBuf++;
for (i = 0; i < len; i++) {
@@ -763,9 +696,11 @@ void Draw_v2::spriteOperation(int16 operation) {
}
}
} else {
+ sourceSurf = _spritesArray[_fontToSprite[_fontIndex].sprite];
+ ratio = ((sourceSurf == _frontSurface) || (sourceSurf == _backSurface)) ?
+ 320 : sourceSurf->width;
+ ratio /= _fontToSprite[_fontIndex].width;
for (i = 0; i < len; i++) {
- ratio = _spritesArray[_fontToSprite[_fontIndex].sprite]->width
- / _fontToSprite[_fontIndex].width;
y = ((_textToPrint[i] - _fontToSprite[_fontIndex].base) / ratio)
* _fontToSprite[_fontIndex].height;
x = ((_textToPrint[i] - _fontToSprite[_fontIndex].base) % ratio)
@@ -1039,7 +974,7 @@ void Draw_v2::initScreen(void) {
_off_2E517->vidPtr = _frontSurface->vidPtr +
((_frontSurface->width * _frontSurface->height ) / 4);
}
- initBigSprite(21, 320, 200, 0);
+ initBigSprite(21, _vm->_video->_surfWidth, 200, 0);
_backSurface = _spritesArray[21];
_vm->_video->clearSurf(_backSurface);
@@ -1066,7 +1001,7 @@ void Draw_v2::closeScreen(void) {
_scummvmCursor = 0;
if (_off_2E51B != 0) {
memcpy(_frontSurface, _off_2E51B, sizeof(Video::SurfaceDesc));
- _frontSurface->width = 320;
+ _frontSurface->width = _vm->_video->_surfWidth;
_frontSurface->height = 200;
delete _off_2E51B;
delete _off_2E517;
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp
index 5d1f3d4c8c..e239248807 100644
--- a/engines/gob/game.cpp
+++ b/engines/gob/game.cpp
@@ -834,7 +834,7 @@ int8 Game::openImd(const char *path, int16 x, int16 y, int16 repeat, int16 flags
memset(_imdFrameData, 0, _imdFrameDataSize + 1000);
memset(_imdVidBuffer, 0, _imdVidBufferSize + 1000);
- if (_vm->_video->_extraMode) {
+ if (_vm->_global->_videoMode == 0x14) {
_byte_2FC83 = (flags & 0x80) ? 1 : 0;
if (!(_imdFile->field_E & 0x100) || (_imdFile->field_E & 0x2000)) {
setImdXY(_imdFile, 0, 0);
@@ -854,7 +854,7 @@ int8 Game::openImd(const char *path, int16 x, int16 y, int16 repeat, int16 flags
if (flags & 0x40) {
_imdX = x != -1 ? x : _imdX;
_imdY = y != -1 ? y : _imdY;
- if (_vm->_video->_extraMode && ((_imdFile->surfDesc->vidMode & 0x7F) == 0x13)) {
+ if ((_imdFile->surfDesc->vidMode & 0x7F) == 0x14) {
surfDesc = _vm->_video->initSurfDesc(0x13, _imdFile->width, _imdFile->height, 0);
_vm->_video->drawSprite(_vm->_draw->_spritesArray[21], surfDesc, _imdX, _imdY,
_imdX + _imdFile->width - 1, _imdY + _imdFile->height - 1, 0, 0, 0);
@@ -1148,7 +1148,7 @@ void Game::playImd(int16 frame, int16 arg_2, int16 arg_4, int16 arg_6, int16 arg
if ((var_1 == 1) && (arg_2 == 8) && (_byte_2FC83 != 0))
_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
- if (_vm->_video->_extraMode && (_imdFile->surfDesc->vidMode == 0x13)) {
+ if (_imdFile->surfDesc->vidMode == 0x14) {
if ((_byte_2FC82 != 0) && (_word_2FC80 == _vm->_draw->_spritesArray[20]->vidPtr)) {
vidMemBak = _vm->_draw->_spritesArray[20]->vidPtr;
_vm->_draw->_spritesArray[20]->vidPtr = _vm->_draw->_spritesArray[21]->vidPtr;
@@ -1166,7 +1166,7 @@ void Game::playImd(int16 frame, int16 arg_2, int16 arg_4, int16 arg_6, int16 arg
_imdFile->frameCoords[frame].bottom);
}
} else {
- if ((_imdFile->field_E & 0x100) && (_vm->_video->_extraMode) &&
+ if ((_imdFile->field_E & 0x100) && (_vm->_global->_videoMode == 0x14) &&
(_byte_2FC82 != 0) && (sub_2C825(_imdFile) & 0x8000) && (_byte_2FC83 == 0)) {
surfDescBak = _imdFile->surfDesc;
if (_word_2FC80 == _vm->_draw->_spritesArray[20]->vidPtr)
@@ -1181,7 +1181,7 @@ void Game::playImd(int16 frame, int16 arg_2, int16 arg_4, int16 arg_6, int16 arg
var_4 = viewImd(_imdFile, frame);
if (!(var_4 & 0x800)) {
if (_byte_2FC83 == 0) {
- if (_vm->_video->_extraMode) {
+ if (_vm->_global->_videoMode == 0x14) {
if (_byte_2FC82 == 0) {
memcpy((char *) &frontSurfBak, (char *) &_vm->_draw->_frontSurface,
sizeof(Video::SurfaceDesc));
@@ -1219,7 +1219,7 @@ void Game::playImd(int16 frame, int16 arg_2, int16 arg_4, int16 arg_6, int16 arg
_imdFile->frameCoords[frame].bottom);
}
} else
- if (_vm->_video->_extraMode)
+ if (_vm->_global->_videoMode == 0x14)
imdDrawFrame(_imdFile, frame, _imdX, _imdY);
}
}
@@ -1407,7 +1407,7 @@ int16 Game::viewImd(Game::Imd *imdPtr, int16 frame) {
retVal |= *_imdFrameData;
if (imdPtr->surfDesc == 0)
continue;
- if (!(_vm->_video->_extraMode && (imdPtr->surfDesc->vidMode == 0x13)))
+ if (imdPtr->surfDesc->vidMode != 0x14)
imdRenderFrame(imdPtr);
else
warning("GOB2 Stub! viedImd, sub_2C69A(imdPtr);");
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index 410ca10cfa..1669da9e40 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -492,7 +492,7 @@ int16 Game_v2::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId,
int16 cursorBottom;
int16 oldWord_2FC9C;
int16 oldWord_2FC9E;
- if ((_vm->_video->_extraMode) && (handleMouse != 0)) {
+ if ((_vm->_global->_videoMode == 0x14) && (handleMouse != 0)) {
width = _vm->_draw->_frontSurface->width;
height = _vm->_draw->_frontSurface->height;
if ((width > _vm->_global->_primaryWidth) || (height > _vm->_global->_primaryHeight)
@@ -678,7 +678,8 @@ void Game_v2::prepareStart(void) {
_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
_vm->_draw->initScreen();
- _vm->_video->fillRect(_vm->_draw->_frontSurface, 0, 0, 319, 199, 1);
+ _vm->_video->fillRect(_vm->_draw->_frontSurface, 0, 0,
+ _vm->_video->_surfWidth - 1, 199, 1);
_vm->_util->setMousePos(152, 92);
diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp
index 7263fe9658..a026354eb2 100644
--- a/engines/gob/init.cpp
+++ b/engines/gob/init.cpp
@@ -135,8 +135,8 @@ memBlocks = word ptr -2*/
_vm->_global->_inter_variablesSizes = 0;
_palDesc = new Video::PalDesc;
- if (_vm->_global->_videoMode != 0x13)
- error("initGame: Only 0x13 video mode is supported!");
+ if ((_vm->_global->_videoMode != 0x13) && (_vm->_global->_videoMode != 0x14))
+ error("initGame: Only 0x13 or 0x14 video mode is supported!");
_palDesc->vgaPal = _vm->_draw->_vgaPalette;
_palDesc->unused1 = _vm->_draw->_unusedPalette1;
diff --git a/engines/gob/init_v1.cpp b/engines/gob/init_v1.cpp
index d24b939153..73a09dd34b 100644
--- a/engines/gob/init_v1.cpp
+++ b/engines/gob/init_v1.cpp
@@ -37,7 +37,7 @@ Init_v1::Init_v1(GobEngine *vm) : Init(vm) {
}
void Init_v1::soundVideo(int32 smallHeap, int16 flag) {
- if (_vm->_global->_videoMode != 0x13 && _vm->_global->_videoMode != 0)
+ if (_vm->_global->_videoMode != 0x13 && _vm->_global->_videoMode != 0x14 && _vm->_global->_videoMode != 0)
error("soundVideo: Video mode 0x%x is not supported!",
_vm->_global->_videoMode);
diff --git a/engines/gob/init_v2.cpp b/engines/gob/init_v2.cpp
index 36b6492979..86cc7d7dbb 100644
--- a/engines/gob/init_v2.cpp
+++ b/engines/gob/init_v2.cpp
@@ -37,12 +37,13 @@ Init_v2::Init_v2(GobEngine *vm) : Init_v1(vm) {
}
void Init_v2::soundVideo(int32 smallHeap, int16 flag) {
- if (_vm->_global->_videoMode != 0x13 && _vm->_global->_videoMode != 0)
+ if (_vm->_global->_videoMode != 0x13 && _vm->_global->_videoMode != 0x14 &&
+ _vm->_global->_videoMode != 0)
error("soundVideo: Video mode 0x%x is not supported!",
_vm->_global->_videoMode);
_vm->_draw->_frontSurface = &_vm->_global->_primarySurfDesc;
- _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0x80);
+ _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_video->_surfWidth, 200, 0x80);
//if ((flag & 4) == 0)
// _vm->_video->findVideo();
@@ -68,7 +69,8 @@ void Init_v2::soundVideo(int32 smallHeap, int16 flag) {
// _vm->_global->_pPrimarySurfDesc = &_vm->_global->_primarySurfDesc;
if (_vm->_global->_videoMode != 0)
- _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, PRIMARY_SURFACE);
+ _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_video->_surfWidth, 200,
+ PRIMARY_SURFACE);
if (_vm->_global->_soundFlags & MIDI_FLAG) {
_vm->_global->_soundFlags &= _vm->_global->_presentSound;
diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index 4fcddb04a3..879722a240 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -321,9 +321,7 @@ protected:
void o2_switchTotSub(void);
void o2_stub0x54(void);
void o2_stub0x55(void);
- void o2_stub0x80(void);
void o2_stub0x81(void);
- void o2_stub0x82(void);
void o2_stub0x85(void);
bool o2_getFreeMem(char &cmdCount, int16 &counter, int16 &retFlag);
bool o2_readData(char &cmdCount, int16 &counter, int16 &retFlag);
@@ -362,6 +360,8 @@ protected:
void o2_playMult(void);
void o2_initCursor(void);
void o2_playImd(void);
+ void o2_initScreen(void);
+ void o2_setScrollOffset(void);
void o2_handleGoblins(int16 &extraData, int32 *retVarPtr, Goblin::Gob_Object *objDesc);
void o2_playInfogrames(int16 &extraData, int32 *retVarPtr, Goblin::Gob_Object *objDesc);
};
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 1dbad5fae1..63c451dedc 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -285,9 +285,9 @@ void Inter_v2::setupOpcodes(void) {
{NULL, ""},
{NULL, ""},
/* 80 */
- OPCODE(o2_stub0x80),
+ OPCODE(o2_initScreen),
OPCODE(o2_stub0x81),
- OPCODE(o2_stub0x82),
+ OPCODE(o2_setScrollOffset),
OPCODE(o2_playImd),
/* 84 */
OPCODE(o2_drawStub),
@@ -812,77 +812,6 @@ void Inter_v2::o2_stub0x55(void) {
}
}
-void Inter_v2::o2_stub0x80(void) {
- int16 start;
- int16 videoMode;
- int16 width;
- int16 height;
-
- start = load16();
-
- videoMode = start & 0xFF;
- start = (start >> 8) & 0xFF;
-
- width = _vm->_parse->parseValExpr();
- height = _vm->_parse->parseValExpr();
-
- if ((videoMode == _vm->_global->_videoMode) && (width == -1))
- return;
-
- if (videoMode == 0x14) {
- videoMode = 0x13;
- _vm->_video->_extraMode = true;
- }
- else
- _vm->_video->_extraMode = false;
-
- _vm->_draw->closeScreen();
- _vm->_util->clearPalette();
- memset(_vm->_global->_redPalette, 0, 256);
- memset(_vm->_global->_greenPalette, 0, 256);
- memset(_vm->_global->_bluePalette, 0, 256);
-// warning("GOB2 Stub! _vid_setStubDriver");
-
- if (videoMode == 0x10) {
- _vm->_global->_videoMode = 0x12;
- _vm->_video->initPrimary(0xE);
- _vm->_global->_videoMode = 0x10;
- warning("GOB2 Stub! Set VGA CRT Maximum Scan Line to 0");
- _vm->_draw->_frontSurface->height = 400;
- } else {
- _vm->_global->_videoMode = videoMode;
- _vm->_video->initPrimary(videoMode);
- }
- WRITE_VAR(15, _vm->_global->_videoMode);
-
- _vm->_global->_setAllPalette = 1;
-
- if ((width != -1) && _vm->_video->_extraMode) {
- _vm->_game->_byte_2FC9B = 1;
-/* if (width > 960)
- width = 960;
- _vm->_draw->_frontSurface->width = width;
- _vm->_draw->_frontSurface->height = height;
- warning("GOB2 Stub! _vid_setVirtRes(_vm->_draw->_frontSurface);");
- _vm->_global->_mouseMaxCol = width;
- _vm->_global->_mouseMaxRow = height;*/
- }
-
- _vm->_util->setMousePos(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY);
- _vm->_util->clearPalette();
-
- if (start == 0)
- _vm->_draw->_word_2E51F = 0;
- else
- _vm->_draw->_word_2E51F = _vm->_global->_primaryHeight - start;
- _vm->_draw->initScreen();
-
- if (_vm->_draw->_off_2E51B != 0) {
- warning("GOB2 Stub! _vid_setSplit(_vm->_global->_primaryHeight - start);");
- warning("GOB2 Stub! _vid_setPixelShift(0, start);");
- }
-}
-
void Inter_v2::o2_stub0x81(void) {
int16 var1;
int16 var2;
@@ -900,27 +829,6 @@ void Inter_v2::o2_stub0x81(void) {
warning("GOB2 Stub! o2_stub0x81(%d, %d, %d, %d, %d, %d)", var1, var2, var3, var4, var5, var6);
}
-void Inter_v2::o2_stub0x82(void) {
- int16 expr;
-
- expr = _vm->_parse->parseValExpr();
-
- if (expr == -1) {
- if (_vm->_game->_byte_2FC9B != 0)
- _vm->_game->_byte_2FC9B = 1;
- _vm->_parse->parseValExpr();
- WRITE_VAR(2, _vm->_draw->_word_2FC9E);
- WRITE_VAR(3, _vm->_draw->_word_2FC9C);
- } else {
- _vm->_draw->_word_2FC9E = expr;
- _vm->_draw->_word_2FC9C = _vm->_parse->parseValExpr();
- }
-/* if (_vm->_draw->_off_2E51B != 0)
- warning("GOB2 Stub! _vid_setPixelShift(_vm->_draw->_word_2FC9E, _vm->_draw->_word_2FC9C + 200 - _vm->_draw->_word_2E51F)");
- else
- warning("GOB2 Stub! _vid_setPixelShift(_vm->_draw->_word_2FC9E, _vm->_draw->_word_2FC9C);");*/
-}
-
void Inter_v2::o2_stub0x85(void) {
char dest[32];
@@ -2015,44 +1923,14 @@ void Inter_v2::o2_initMult(void) {
}
_vm->_draw->adjustCoords(0, &_vm->_anim->_areaWidth, &_vm->_anim->_areaHeight);
-
if (_vm->_anim->_animSurf == 0) {
- if (_vm->_global->_videoMode == 18) {
- _vm->_anim->_animSurf = new Video::SurfaceDesc;
- memcpy(_vm->_anim->_animSurf, _vm->_draw->_frontSurface, sizeof(Video::SurfaceDesc));
- _vm->_anim->_animSurf->width = (_vm->_anim->_areaLeft + _vm->_anim->_areaWidth - 1) | 7;
- _vm->_anim->_animSurf->width -= (_vm->_anim->_areaLeft & 0x0FFF8) - 1;
- _vm->_anim->_animSurf->height = _vm->_anim->_areaHeight;
- _vm->_anim->_animSurf->vidPtr += 0x0C000;
- _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf;
- } else {
- if ((_vm->_global->_videoMode == 0x13) && _vm->_video->_extraMode) {
- if (((_vm->_draw->_backSurface->width * _vm->_draw->_backSurface->height) / 2
- + (_vm->_anim->_areaWidth * _vm->_anim->_areaHeight) / 4) < 65536) {
- warning("GOB2 Stub! Inter_v2::o2_initMult(), wide frontSurface, using the extra space as animSurf");
-/* _vm->_anim->_animSurf = new Video::SurfaceDesc;
- memcpy(_vm->_anim->_animSurf, _vm->_draw->_frontSurface, sizeof(Video::SurfaceDesc));
- _vm->_anim->_animSurf->width = (_vm->_anim->_areaLeft + _vm->_anim->_areaWidth - 1) | 7;
- _vm->_anim->_animSurf->width -= (_vm->_anim->_areaLeft & 0x0FF8) - 1;
- _vm->_anim->_animSurf->height = _vm->_anim->_areaHeight;
- _vm->_anim->_animSurf->vidPtr = _vm->_draw->_backSurface->vidPtr +
- _vm->_draw->_backSurface->width * _vm->_draw->_backSurface->height / 4;
- _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf;*/
- _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0);
- _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22];
- } else
- _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0);
- _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22];
- } else
- _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0);
- _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22];
- }
+ _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0);
+ _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22];
if (_terminate)
return;
}
_vm->_draw->adjustCoords(1, &_vm->_anim->_areaWidth, &_vm->_anim->_areaHeight);
-
_vm->_draw->_sourceSurface = 21;
_vm->_draw->_destSurface = 22;
_vm->_draw->_spriteLeft = _vm->_anim->_areaLeft;
@@ -2248,6 +2126,102 @@ void Inter_v2::o2_playImd(void) {
_vm->_game->closeImd();
}
+void Inter_v2::o2_initScreen(void) {
+ int16 start;
+ int16 videoMode;
+ int16 width;
+ int16 height;
+
+ start = load16();
+
+ videoMode = start & 0xFF;
+ start = (start >> 8) & 0xFF;
+
+ width = _vm->_parse->parseValExpr();
+ height = _vm->_parse->parseValExpr();
+
+ if ((videoMode == _vm->_global->_videoMode) && (width == -1))
+ return;
+
+ _vm->_video->_surfWidth = videoMode == 0x14 ? 640 : 320;
+
+ _vm->_draw->closeScreen();
+ _vm->_util->clearPalette();
+ memset(_vm->_global->_redPalette, 0, 256);
+ memset(_vm->_global->_greenPalette, 0, 256);
+ memset(_vm->_global->_bluePalette, 0, 256);
+
+ if (videoMode == 0x10) {
+ _vm->_global->_videoMode = 0x12;
+ _vm->_video->initPrimary(0xE);
+ _vm->_global->_videoMode = 0x10;
+ warning("GOB2 Stub! Set VGA CRT Maximum Scan Line to 0");
+ _vm->_draw->_frontSurface->height = 400;
+ } else {
+ _vm->_global->_videoMode = videoMode;
+ _vm->_video->initPrimary(videoMode);
+ }
+ WRITE_VAR(15, _vm->_global->_videoMode);
+
+ _vm->_global->_setAllPalette = 1;
+
+ if ((width != -1) && (_vm->_global->_videoMode == 0x14)) {
+ _vm->_game->_byte_2FC9B = 1;
+/*
+ if (width > 960)
+ width = 960;
+ _vm->_draw->_frontSurface->width = width;
+ _vm->_draw->_frontSurface->height = height;
+ warning("GOB2 Stub! _vid_setVirtRes(_vm->_draw->_frontSurface);");
+ _vm->_global->_mouseMaxCol = width;
+ _vm->_global->_mouseMaxRow = height;
+*/
+ }
+
+ _vm->_util->setMousePos(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY);
+ _vm->_util->clearPalette();
+
+ if (start == 0)
+ _vm->_draw->_word_2E51F = 0;
+ else
+ _vm->_draw->_word_2E51F = _vm->_global->_primaryHeight - start;
+ _vm->_draw->initScreen();
+
+ if (_vm->_draw->_off_2E51B != 0) {
+ _vm->_video->_scrollOffset = 0;
+
+/*
+ warning("_vid_setSplit(%d)", _vm->_global->_primaryHeight - start);
+ warning("_vid_setPixelShift(0, %d", start);
+*/
+ }
+}
+
+void Inter_v2::o2_setScrollOffset(void) {
+ int16 offset;
+
+ offset = _vm->_parse->parseValExpr();
+
+ if (offset == -1) {
+ if (_vm->_game->_byte_2FC9B != 0)
+ _vm->_game->_byte_2FC9B = 1;
+ _vm->_parse->parseValExpr();
+ WRITE_VAR(2, _vm->_draw->_word_2FC9E);
+ WRITE_VAR(3, _vm->_draw->_word_2FC9C);
+ } else {
+ _vm->_draw->_word_2FC9E = offset;
+ _vm->_draw->_word_2FC9C = _vm->_parse->parseValExpr();
+ }
+ _vm->_video->_scrollOffset = _vm->_draw->_word_2FC9E;
+
+/*
+ if (_vm->_draw->_off_2E51B != 0)
+ warning("_vid_setPixelShift(%d, %d)", _vm->_draw->_word_2FC9E, _vm->_draw->_word_2FC9C + 200 - _vm->_draw->_word_2E51F);
+ else
+ warning("_vid_setPixelShift(%d, %d)", _vm->_draw->_word_2FC9E, _vm->_draw->_word_2FC9C);;
+*/
+}
+
void Inter_v2::o2_totSub(void) {
char totFile[14];
byte length;
@@ -2266,6 +2240,7 @@ void Inter_v2::o2_totSub(void) {
totFile[i] = 0;
}
+ _vm->_util->longDelay(100);
flags = (byte) *_vm->_global->_inter_execPtr++;
_vm->_game->totSub(flags, totFile);
}
diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp
index 70ccb1ffd5..2d53f893f2 100644
--- a/engines/gob/mult_v2.cpp
+++ b/engines/gob/mult_v2.cpp
@@ -428,7 +428,7 @@ void Mult_v2::playMult(int16 startFrame, int16 endFrame, char checkEscape,
_vm->_util->setFrameRate(_multData2->frameRate);
_vm->_anim->_areaTop = 0;
_vm->_anim->_areaLeft = 0;
- _vm->_anim->_areaWidth = 320;
+ _vm->_anim->_areaWidth = _vm->_video->_surfWidth;
_vm->_anim->_areaHeight = 200;
_objCount = 4;
@@ -472,26 +472,9 @@ void Mult_v2::playMult(int16 startFrame, int16 endFrame, char checkEscape,
}
_vm->_draw->adjustCoords(0, &_vm->_anim->_areaWidth, &_vm->_anim->_areaHeight);
+ _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0);
+ _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22];
- if ((_vm->_global->_videoMode == 0x13) && _vm->_video->_extraMode &&
- ((_vm->_draw->_backSurface->width * _vm->_draw->_backSurface->height) / 2
- + (_vm->_anim->_areaWidth * _vm->_anim->_areaHeight) / 4) < 64000) {
- warning("GOB2 Stub! Mult_v2::playMult(), wide frontSurface, using the extra space as animSurf");
-/* _vm->_anim->_animSurf = new Video::SurfaceDesc;
- memcpy(_vm->_anim->_animSurf, _vm->_draw->_frontSurface, sizeof(Video::SurfaceDesc));
- _vm->_anim->_animSurf->width = (_vm->_anim->_areaLeft + _vm->_anim->_areaWidth - 1) | 7;
- _vm->_anim->_animSurf->width -= (_vm->_anim->_areaLeft & 0x0FFF8) - 1;
- _vm->_anim->_animSurf->height = _vm->_anim->_areaHeight;
- _vm->_anim->_animSurf->vidPtr +=
- (_vm->_draw->_backSurface->width * _vm->_draw->_backSurface->height) / 2;
- _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf;*/
- _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0);
- _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22];
- } else {
- _vm->_draw->initBigSprite(22, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0);
- _vm->_anim->_animSurf = _vm->_draw->_spritesArray[22];
- }
-
_vm->_draw->adjustCoords(1, &_vm->_anim->_areaWidth, &_vm->_anim->_areaHeight);
_vm->_draw->_sourceSurface = 21;
_vm->_draw->_destSurface = 22;
@@ -499,7 +482,7 @@ void Mult_v2::playMult(int16 startFrame, int16 endFrame, char checkEscape,
_vm->_draw->_destSpriteY = 0;
_vm->_draw->_spriteLeft = 0;
_vm->_draw->_spriteTop = 0;
- _vm->_draw->_spriteRight = 320;
+ _vm->_draw->_spriteRight = _vm->_video->_surfWidth;
_vm->_draw->_spriteBottom = 200;
_vm->_draw->_transparency = 0;
_vm->_draw->spriteOperation(0);
@@ -631,7 +614,7 @@ char Mult_v2::drawStatics(char stop) {
_vm->_draw->_destSpriteY = 0;
_vm->_draw->_spriteLeft = 0;
_vm->_draw->_spriteTop = 0;
- _vm->_draw->_spriteRight = 320;
+ _vm->_draw->_spriteRight = _vm->_video->_surfWidth;
_vm->_draw->_spriteBottom = 200;
_vm->_draw->_transparency = 0;
_vm->_draw->spriteOperation(0);
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 35c17bb9cf..47a5ce076d 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -318,7 +318,7 @@ void Util::clearPalette(void) {
int16 i;
byte colors[768];
- if (_vm->_global->_videoMode != 0x13)
+ if ((_vm->_global->_videoMode != 0x13) && (_vm->_global->_videoMode != 0x14))
error("clearPalette: Video mode 0x%x is not supported!",
_vm->_global->_videoMode);
diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp
index 068ebd3b3f..6ea2adb11c 100644
--- a/engines/gob/video.cpp
+++ b/engines/gob/video.cpp
@@ -36,8 +36,9 @@ namespace Gob {
/* NOT IMPLEMENTED */
Video::Video(GobEngine *vm) : _vm(vm) {
- _extraMode = false;
_videoDriver = 0;
+ _surfWidth = 320;
+ _scrollOffset = 0;
}
char Video::initDriver(int16 vidMode) {
@@ -60,7 +61,7 @@ void Video::freeDriver() {
int32 Video::getRectSize(int16 width, int16 height, int16 flag, int16 mode) {
int32 size;
- if ((mode & 0x7f) != 0x13)
+ if (((mode & 0x7f) != 0x13) && ((mode & 0x7f) != 0x14))
warning
("Video::getRectSize: Video mode %d is not fully supported!",
mode & 0x7f);
@@ -85,14 +86,10 @@ int32 Video::getRectSize(int16 width, int16 height, int16 flag, int16 mode) {
}
void Video::freeSurfDesc(SurfaceDesc * surfDesc) {
- if (surfDesc == 0)
+ if ((surfDesc == 0) || (surfDesc == _vm->_draw->_frontSurface))
return;
- // TODO: valgrind shows an "Invalid free() / delete / delete[]" here...
- // delete[] surfDesc->vidPtr;
-
- // GOB2: surfDesc != _vm->_draw->_frontSurface (since _frontSurface is set
- // to _pPrimarySurfDesc in Game::prepareStart(), is there a difference?)
+ delete[] surfDesc->vidPtr;
if (surfDesc != _vm->_global->_pPrimarySurfDesc) {
_vm->_global->_sprAllocated--;
delete surfDesc;
@@ -297,7 +294,7 @@ void Video::drawPackedSprite(byte *sprBuf, int16 width, int16 height, int16 x, i
if (spriteUncompressor(sprBuf, width, height, x, y, transp, dest))
return;
- if ((dest->vidMode & 0x7f) != 0x13)
+ if (((dest->vidMode & 0x7f) != 0x13) && ((dest->vidMode & 0x7f) != 0x14))
error("Video::drawPackedSprite: Video mode 0x%x is not fully supported!",
dest->vidMode & 0x7f);
@@ -312,7 +309,7 @@ void Video::setPalElem(int16 index, char red, char green, char blue, int16 unuse
_vm->_global->_greenPalette[index] = green;
_vm->_global->_bluePalette[index] = blue;
- if (vidMode != 0x13)
+ if ((vidMode != 0x13) && (vidMode != 0x14))
error("Video::setPalElem: Video mode 0x%x is not supported!",
vidMode);
@@ -328,7 +325,7 @@ void Video::setPalette(PalDesc *palDesc) {
byte pal[1024];
int16 numcolors;
- if (_vm->_global->_videoMode != 0x13)
+ if ((_vm->_global->_videoMode != 0x13) && (_vm->_global->_videoMode != 0x14))
error("Video::setPalette: Video mode 0x%x is not supported!",
_vm->_global->_videoMode);
@@ -374,11 +371,11 @@ void Video::setFullPalette(PalDesc *palDesc) {
void Video::initPrimary(int16 mode) {
int16 old;
- if (mode != 0x13 && mode != 3 && mode != -1)
+ if (mode != 0x13 && mode != 0x14 && mode != 3 && mode != -1)
error("Video::initPrimary: Video mode 0x%x is not supported!",
mode);
- if (_vm->_global->_videoMode != 0x13)
+ if ((_vm->_global->_videoMode != 0x13) && (_vm->_global->_videoMode != 0x14))
error("Video::initPrimary: Video mode 0x%x is not supported!",
mode);
@@ -391,7 +388,7 @@ void Video::initPrimary(int16 mode) {
Video::initDriver(mode);
if (mode != 3) {
- initSurfDesc(mode, 320, 200, PRIMARY_SURFACE);
+ initSurfDesc(mode, _surfWidth, 200, PRIMARY_SURFACE);
if (_vm->_global->_dontSetPalette)
return;
diff --git a/engines/gob/video.h b/engines/gob/video.h
index 96f9894e80..af41934d62 100644
--- a/engines/gob/video.h
+++ b/engines/gob/video.h
@@ -90,7 +90,8 @@ public:
PalDesc() : vgaPal(0), unused1(0), unused2(0) {}
};
- bool _extraMode;
+ int16 _surfWidth;
+ int16 _scrollOffset;
Video(class GobEngine *vm);
virtual ~Video() {};
diff --git a/engines/gob/video_v2.cpp b/engines/gob/video_v2.cpp
index f11b94de93..ce5cfa938e 100644
--- a/engines/gob/video_v2.cpp
+++ b/engines/gob/video_v2.cpp
@@ -40,7 +40,8 @@ Video_v2::Video_v2(GobEngine *vm) : Video_v1(vm) {
void Video_v2::waitRetrace(int16) {
CursorMan.showMouse((_vm->_draw->_showCursor & 2) != 0);
if (_vm->_draw->_frontSurface) {
- g_system->copyRectToScreen(_vm->_draw->_frontSurface->vidPtr, 320, 0, 0, 320, 200);
+ g_system->copyRectToScreen(_vm->_draw->_frontSurface->vidPtr + _scrollOffset,
+ _surfWidth, 0, 0, 320, 200);
g_system->updateScreen();
}
}
@@ -97,7 +98,7 @@ Video::SurfaceDesc *Video_v2::initSurfDesc(int16 vidMode, int16 width, int16 hei
if (flags & RETURN_PRIMARY)
return _vm->_draw->_frontSurface;
- if (vidMode != 0x13)
+ if ((vidMode != 0x13) && (vidMode != 0x14))
error("Video::initSurfDesc: Only VGA 0x13 mode is supported!");
if ((flags & PRIMARY_SURFACE) == 0)
@@ -129,8 +130,8 @@ Video::SurfaceDesc *Video_v2::initSurfDesc(int16 vidMode, int16 width, int16 hei
assert(descPtr);
if (descPtr->vidPtr != 0)
delete[] descPtr->vidPtr;
- vidMem = new byte[320 * 200];
- memset(vidMem, 0, 64000);
+ vidMem = new byte[_surfWidth * 200];
+ memset(vidMem, 0, _surfWidth * 200);
} else {
if (flags & DISABLE_SPR_ALLOC) {
descPtr = new SurfaceDesc;
@@ -177,7 +178,7 @@ char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
if (!destDesc)
return 1;
- if ((destDesc->vidMode & 0x7f) != 0x13)
+ if (((destDesc->vidMode & 0x7f) != 0x13) && ((destDesc->vidMode & 0x7f) != 0x14))
error("Video::spriteUncompressor: Video mode 0x%x is not supported!",
destDesc->vidMode & 0x7f);
@@ -203,12 +204,6 @@ char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
srcPtr = sprBuf + 3;
sourceLeft = READ_LE_UINT32(srcPtr);
- // TODO: Needed until wide/scrolling surfaces are supported...
- if ((x + srcWidth) >= destDesc->width)
- x = 0;
- if ((y + srcHeight) >= destDesc->height)
- y = 0;
-
destPtr = destDesc->vidPtr + destDesc->width * y + x;
curWidth = 0;