aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2004-01-04 13:09:02 +0000
committerMax Horn2004-01-04 13:09:02 +0000
commit805f5124529dc3c1faf1eaae23d797b1c5eed1eb (patch)
treed1e93b75f988b26449f1efd70004e5fa2b4294f3
parent14cf65c0abefeebca080ec1a689af8294453597b (diff)
downloadscummvm-rg350-805f5124529dc3c1faf1eaae23d797b1c5eed1eb.tar.gz
scummvm-rg350-805f5124529dc3c1faf1eaae23d797b1c5eed1eb.tar.bz2
scummvm-rg350-805f5124529dc3c1faf1eaae23d797b1c5eed1eb.zip
replaced many instances of _screenWidth by VirtScreen::width, where approriate (there are cases, like when dealing with the camera, where _screenWidth is correct; in other places we still use it, because the VirtScreen is not available in that place at this time, will be fixed later). Reason for all this: eventually a clean seperation will allow us to use a main screen which is wider than the real screen width -> useful for V7+ smooth scrolling
svn-id: r12131
-rw-r--r--scumm/charset.cpp18
-rw-r--r--scumm/gfx.cpp80
-rw-r--r--scumm/nut_renderer.cpp3
-rw-r--r--scumm/script_v6.cpp2
-rw-r--r--scumm/scummvm.cpp1
-rw-r--r--scumm/verbs.cpp25
6 files changed, 72 insertions, 57 deletions
diff --git a/scumm/charset.cpp b/scumm/charset.cpp
index cdea6fd8f4..8012538757 100644
--- a/scumm/charset.cpp
+++ b/scumm/charset.cpp
@@ -973,7 +973,7 @@ void CharsetRendererV3::printChar(int chr) {
drawTop = _top - vs->topline;
char_ptr = _fontPtr + chr * 8;
- dest_ptr = vs->screenPtr + vs->xstart + drawTop * _vm->_screenWidth + _left;
+ dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
mask_ptr = _vm->getMaskBuffer(_left, drawTop, 0);
useMask = (vs->number == 0 && !_ignoreCharsetMask);
@@ -1091,12 +1091,12 @@ void CharsetRendererClassic::printChar(int chr) {
byte *mask = _vm->getMaskBuffer(_left, drawTop, 0);
- byte *dst = vs->screenPtr + vs->xstart + drawTop * _vm->_screenWidth + _left;
+ byte *dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
byte *back = dst;
if (_blitAlso) {
dst = _vm->getResourceAddress(rtBuffer, vs->number + 5)
- + vs->xstart + drawTop * _vm->_screenWidth + _left;
+ + vs->xstart + drawTop * vs->width + _left;
}
if (is2byte) {
@@ -1110,8 +1110,8 @@ void CharsetRendererClassic::printChar(int chr) {
int h = height;
do {
memcpy(back, dst, width);
- back += _vm->_screenWidth;
- dst += _vm->_screenWidth;
+ back += vs->width;
+ dst += vs->width;
} while (--h);
}
@@ -1167,7 +1167,7 @@ void CharsetRendererClassic::drawBitsN(VirtScreen *vs, byte *dst, const byte *sr
maskpos++;
}
}
- dst += _vm->_screenWidth - width;
+ dst += vs->width - width;
mask += _vm->gdi._numStrips;
}
}
@@ -1189,8 +1189,8 @@ void CharsetRendererCommon::drawBits1(VirtScreen *vs, byte *dst, const byte *src
if ((bits & revBitMask[x % 8]) && y + drawTop >= 0) {
if (_dropShadow) {
*(dst + 1) = _shadowColor;
- *(dst + _vm->_screenWidth) = _shadowColor;
- *(dst + _vm->_screenWidth + 1) = _shadowColor;
+ *(dst + vs->width) = _shadowColor;
+ *(dst + vs->width + 1) = _shadowColor;
}
*dst = _color;
if (useMask) {
@@ -1215,7 +1215,7 @@ void CharsetRendererCommon::drawBits1(VirtScreen *vs, byte *dst, const byte *src
}
}
- dst += _vm->_screenWidth - width;
+ dst += vs->width - width;
mask += _vm->gdi._numStrips;
}
}
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index 47edae6218..fe0be10656 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -228,8 +228,12 @@ void ScummEngine::initScreens(int b, int w, int h) {
}
if (!getResourceAddress(rtBuffer, 4)) {
- // Since the size of screen 3 is fixed, there is no need to reallocate it
- // if its size changed.
+ // Since the size of screen 3 is fixed, there is no need to reallocate
+ // it if its size changed.
+ // Not sure what it is good for, though. I think it may have been used
+ // in pre-V7 for the games messages (like 'Pause', Yes/No dialogs,
+ // version display, etc.). I don't know about V7, maybe the same is the
+ // case there. If so, we could probably just remove it completely.
if (_version >= 7) {
initVirtScreen(kUnkVirtScreen, 0, (_screenHeight / 2) - 10, _screenWidth, 13, false, false);
} else {
@@ -258,7 +262,7 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int
}
vs->number = slot;
- vs->width = _screenWidth;
+ vs->width = width;
vs->topline = top;
vs->height = height;
vs->alloctwobuffers = twobufs;
@@ -268,10 +272,16 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int
size = vs->width * vs->height;
if (vs->scrollable) {
+ // Allow enough spaces so that rooms can be up to 4 resp. 8 screens
+ // wide. To achieve (horizontal!) scrolling, we use a neat trick:
+ // only the offset into the screen buffer (xstart) is changed. That way
+ // very little of the screen has to be redrawn, and we have a very low
+ // memory overhead (namely for every pixel we want to scroll, we need
+ // one additional byte in the buffer).
if (_version >= 7) {
- size += _screenWidth * 8;
+ size += width * 8;
} else {
- size += _screenWidth * 4;
+ size += width * 4;
}
}
@@ -455,8 +465,8 @@ void Gdi::drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b) {
if (_vm->_screenTop < 0)
_vm->_screenTop = 0;
- ptr = vs->screenPtr + (x + vs->xstart) + (_vm->_screenTop + t) * _vm->_screenWidth;
- _vm->_system->copy_rect(ptr, _vm->_screenWidth, x, vs->topline + t, w, height);
+ ptr = vs->screenPtr + (x + vs->xstart) + (_vm->_screenTop + t) * vs->width;
+ _vm->_system->copy_rect(ptr, vs->width, x, vs->topline + t, w, height);
}
/**
@@ -497,6 +507,9 @@ void ScummEngine::blit(byte *dst, const byte *src, int w, int h) {
assert(h > 0);
assert(src != NULL);
assert(dst != NULL);
+
+ // TODO: This function currently always assumes that srcPitch == dstPitch
+ // and furthermore that both equal _screenWidth.
if (w==_screenWidth)
memcpy (dst, src, w*h);
@@ -554,19 +567,19 @@ void ScummEngine::drawBox(int x, int y, int x2, int y2, int color) {
markRectAsDirty(vs->number, x, x2, y, y2, 0);
- backbuff = vs->screenPtr + vs->xstart + y * _screenWidth + x;
+ backbuff = vs->screenPtr + vs->xstart + y * vs->width + x;
width = x2 - x;
height = y2 - y;
if (color == -1) {
if (vs->number != kMainVirtScreen)
error("can only copy bg to main window");
- bgbuff = getResourceAddress(rtBuffer, vs->number + 5) + vs->xstart + y * _screenWidth + x;
+ bgbuff = getResourceAddress(rtBuffer, vs->number + 5) + vs->xstart + y * vs->width + x;
blit(backbuff, bgbuff, width, height);
} else {
while (height--) {
memset(backbuff, color, width);
- backbuff += _screenWidth;
+ backbuff += vs->width;
}
}
}
@@ -625,6 +638,7 @@ void ScummEngine::initBGBuffers(int height) {
void ScummEngine::drawFlashlight() {
int i, j, offset, x, y;
+ VirtScreen *vs = &virtscr[kMainVirtScreen];
// Remove the flash light first if it was previously drawn
if (_flashlight.isDrawn) {
@@ -635,7 +649,7 @@ void ScummEngine::drawFlashlight() {
i = _flashlight.h;
do {
memset(_flashlight.buffer, 0, _flashlight.w);
- _flashlight.buffer += _screenWidth;
+ _flashlight.buffer += vs->width;
} while (--i);
}
_flashlight.isDrawn = false;
@@ -646,8 +660,8 @@ void ScummEngine::drawFlashlight() {
// Calculate the area of the flashlight
if (_gameId == GID_ZAK256 || _version <= 2) {
- x = _mouse.x + virtscr[0].xstart;
- y = _mouse.y - virtscr[0].topline;
+ x = _mouse.x + vs->xstart;
+ y = _mouse.y - vs->topline;
} else {
Actor *a = derefActor(VAR(VAR_EGO), "drawFlashlight");
x = a->_pos.x;
@@ -668,20 +682,20 @@ void ScummEngine::drawFlashlight() {
_flashlight.x = gdi._numStrips * 8 - _flashlight.w;
if (_flashlight.y < 0)
_flashlight.y = 0;
- else if (_flashlight.y + _flashlight.h> virtscr[0].height)
- _flashlight.y = virtscr[0].height - _flashlight.h;
+ else if (_flashlight.y + _flashlight.h> vs->height)
+ _flashlight.y = vs->height - _flashlight.h;
// Redraw any actors "under" the flashlight
for (i = _flashlight.x / 8; i < (_flashlight.x + _flashlight.w) / 8; i++) {
assert(0 <= i && i < gdi._numStrips);
setGfxUsageBit(_screenStartStrip + i, USAGE_BIT_DIRTY);
- virtscr[0].tdirty[i] = 0;
- virtscr[0].bdirty[i] = virtscr[0].height;
+ vs->tdirty[i] = 0;
+ vs->bdirty[i] = vs->height;
}
byte *bgbak;
- offset = _flashlight.y * _screenWidth + virtscr[0].xstart + _flashlight.x;
- _flashlight.buffer = virtscr[0].screenPtr + offset;
+ offset = _flashlight.y * vs->width + vs->xstart + _flashlight.x;
+ _flashlight.buffer = vs->screenPtr + offset;
bgbak = getResourceAddress(rtBuffer, 5) + offset;
blit(_flashlight.buffer, bgbak, _flashlight.w, _flashlight.h);
@@ -691,9 +705,9 @@ void ScummEngine::drawFlashlight() {
int corner_data[] = { 8, 6, 4, 3, 2, 2, 1, 1 };
int minrow = 0;
int maxcol = _flashlight.w - 1;
- int maxrow = (_flashlight.h - 1) * _screenWidth;
+ int maxrow = (_flashlight.h - 1) * vs->width;
- for (i = 0; i < 8; i++, minrow += _screenWidth, maxrow -= _screenWidth) {
+ for (i = 0; i < 8; i++, minrow += vs->width, maxrow -= vs->width) {
int d = corner_data[i];
for (j = 0; j < d; j++) {
@@ -811,16 +825,16 @@ void ScummEngine::restoreBG(Common::Rect rect, byte backColor) {
rect.left = 0;
if (rect.right < 0)
rect.right = 0;
- if (rect.left > _screenWidth)
+ if (rect.left > vs->width)
return;
- if (rect.right > _screenWidth)
- rect.right = _screenWidth;
+ if (rect.right > vs->width)
+ rect.right = vs->width;
if (rect.bottom >= height)
rect.bottom = height;
markRectAsDirty(vs->number, rect.left, rect.right, rect.top - topline, rect.bottom - topline, USAGE_BIT_RESTORED);
- int offset = (rect.top - topline) * _screenWidth + vs->xstart + rect.left;
+ int offset = (rect.top - topline) * vs->width + vs->xstart + rect.left;
backbuff = vs->screenPtr + offset;
bgbak = getResourceAddress(rtBuffer, vs->number + 5) + offset;
@@ -855,7 +869,7 @@ void ScummEngine::restoreBG(Common::Rect rect, byte backColor) {
} else {
while (height--) {
memset(backbuff, backColor, width);
- backbuff += _screenWidth;
+ backbuff += vs->width;
}
}
}
@@ -981,7 +995,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", bottom, vs->height);
}
- _vertStripNextInc = height * _vm->_screenWidth - 1;
+ _vertStripNextInc = height * vs->width - 1;
sx = x;
if (vs->scrollable)
@@ -1054,7 +1068,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
}
if (left <= theX && theX < right) {
*dst = *ptr_dither_table++;
- dst += _vm->_screenWidth;
+ dst += vs->width;
}
}
if (left <= theX && theX < right) {
@@ -1241,8 +1255,8 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
dst[j] = dst2[j] = 12+i;
maskbits <<= 1;
}
- dst += _vm->_screenWidth;
- dst2 += _vm->_screenWidth;
+ dst += vs->width;
+ dst2 += vs->width;
mask_ptr += _numStrips;
}
}
@@ -3462,7 +3476,7 @@ void ScummEngine::grabCursor(int x, int y, int w, int h) {
return;
}
- grabCursor(vs->screenPtr + (y - vs->topline) * _screenWidth + x, w, h);
+ grabCursor(vs->screenPtr + (y - vs->topline) * vs->width + x, w, h);
}
@@ -3503,7 +3517,7 @@ void ScummEngine::useIm01Cursor(const byte *im, int w, int h) {
for (i = 0; i < h; i++) {
memcpy(dst, src, w);
dst += w;
- src += _screenWidth;
+ src += vs->width;
}
drawBox(0, 0, w - 1, h - 1, 0xFF);
@@ -3521,7 +3535,7 @@ void ScummEngine::useIm01Cursor(const byte *im, int w, int h) {
for (i = 0; i < h; i++) {
memcpy(dst, src, w);
- dst += _screenWidth;
+ dst += vs->width;
src += w;
}
diff --git a/scumm/nut_renderer.cpp b/scumm/nut_renderer.cpp
index df737d9cda..240231c5e6 100644
--- a/scumm/nut_renderer.cpp
+++ b/scumm/nut_renderer.cpp
@@ -243,6 +243,7 @@ void NutRenderer::drawShadowChar(int c, int x, int y, byte color, bool useMask)
return;
}
+ VirtScreen *vs = &_vm->virtscr[kMainVirtScreen];
byte *dst, *mask = NULL;
// HACK: we draw the character a total of 7 times: 6 times shifted
@@ -262,7 +263,7 @@ void NutRenderer::drawShadowChar(int c, int x, int y, byte color, bool useMask)
y += offsetY[i];
color = cTable[i];
- dst = _vm->virtscr[0].screenPtr + (y + _vm->_screenTop) * _vm->_screenWidth + x + _vm->virtscr[0].xstart;
+ dst = vs->screenPtr + (y + _vm->_screenTop) * vs->width + x + vs->xstart;
if (useMask)
mask = _vm->getMaskBuffer(x, y + _vm->_screenTop, 0);
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index f6fe4c1891..06c134f066 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -3257,7 +3257,7 @@ void ScummEngine_v6::o6_unknownE1() {
return;
}
- int offset = (y - vs->topline) * _screenWidth + x + _screenLeft;
+ int offset = (y - vs->topline) * vs->width + x + _screenLeft;
byte area = *(getResourceAddress(rtBuffer, vs->number + 1) + offset);
push(area);
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index f57789b2f8..a5dc1d877d 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -925,7 +925,6 @@ void ScummEngine::launch() {
_verbRedraw = false;
allocResTypeData(rtBuffer, MKID('NONE'), 10, "buffer", 0);
-// initVirtScreen(kMainVirtScreen, 0, 0, _screenWidth, _screenHeight, false, false); // FIXME - why is this here? It seems we could remove it in f
setupScummVars();
diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp
index 6700367c6b..6891fc3a54 100644
--- a/scumm/verbs.cpp
+++ b/scumm/verbs.cpp
@@ -102,7 +102,7 @@ void ScummEngine::initV2MouseOver() {
}
void ScummEngine::checkV2MouseOver(Common::Point pos) {
- VirtScreen *vs = &virtscr[2];
+ VirtScreen *vs = &virtscr[kVerbVirtScreen];
Common::Rect rect;
byte *ptr, *dst;
int i, x, y, new_box = -1;
@@ -126,7 +126,7 @@ void ScummEngine::checkV2MouseOver(Common::Point pos) {
if (v2_mouseover_box != -1) {
rect = v2_mouseover_boxes[v2_mouseover_box].rect;
- dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left;
+ dst = ptr = vs->screenPtr + vs->xstart + rect.top * vs->width + rect.left;
// Remove highlight.
for (y = rect.height() - 1; y >= 0; y--) {
@@ -134,7 +134,7 @@ void ScummEngine::checkV2MouseOver(Common::Point pos) {
if (dst[x] == v2_mouseover_boxes[v2_mouseover_box].hicolor)
dst[x] = v2_mouseover_boxes[v2_mouseover_box].color;
}
- dst += _screenWidth;
+ dst += vs->width;
}
markRectAsDirty(kVerbVirtScreen, rect.left, rect.right, rect.top, rect.bottom, 0);
@@ -143,7 +143,7 @@ void ScummEngine::checkV2MouseOver(Common::Point pos) {
if (new_box != -1) {
rect = v2_mouseover_boxes[new_box].rect;
- dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left;
+ dst = ptr = vs->screenPtr + vs->xstart + rect.top * vs->width + rect.left;
// Apply highlight
for (y = rect.height() - 1; y >= 0; y--) {
@@ -151,7 +151,7 @@ void ScummEngine::checkV2MouseOver(Common::Point pos) {
if (dst[x] == v2_mouseover_boxes[new_box].color)
dst[x] = v2_mouseover_boxes[new_box].hicolor;
}
- dst += _screenWidth;
+ dst += vs->width;
}
markRectAsDirty(kVerbVirtScreen, rect.left, rect.right, rect.top, rect.bottom, 0);
@@ -164,7 +164,7 @@ void ScummEngine::checkV2MouseOver(Common::Point pos) {
void ScummEngine::checkV2Inventory(int x, int y) {
int object = 0;
- y -= virtscr[2].topline;
+ y -= virtscr[kVerbVirtScreen].topline;
if ((y < 34) || !(_mouseButStat & MBS_LEFT_CLICK))
return;
@@ -197,6 +197,7 @@ void ScummEngine::checkV2Inventory(int x, int y) {
}
void ScummEngine::redrawV2Inventory() {
+ VirtScreen *vs = &virtscr[kVerbVirtScreen];
int i;
int max_inv;
Common::Rect inventoryBox;
@@ -207,10 +208,10 @@ void ScummEngine::redrawV2Inventory() {
return;
// Clear on all invocations
- inventoryBox.top = virtscr[2].topline + 32;
- inventoryBox.bottom = virtscr[2].topline + virtscr[2].height;
+ inventoryBox.top = vs->topline + 32;
+ inventoryBox.bottom = vs->topline + virtscr[2].height;
inventoryBox.left = 0;
- inventoryBox.right = virtscr[2].width;
+ inventoryBox.right = vs->width;
restoreBG(inventoryBox);
_string[1].charset = 1;
@@ -223,7 +224,7 @@ void ScummEngine::redrawV2Inventory() {
if (obj == 0)
break;
- _string[1].ypos = v2_mouseover_boxes[i].rect.top + virtscr[2].topline;
+ _string[1].ypos = v2_mouseover_boxes[i].rect.top + vs->topline;
_string[1].xpos = v2_mouseover_boxes[i].rect.left;
_string[1].color = v2_mouseover_boxes[i].color;
@@ -245,7 +246,7 @@ void ScummEngine::redrawV2Inventory() {
// If necessary, draw "up" arrow
if (_inventoryOffset > 0) {
_string[1].xpos = v2_mouseover_boxes[kInventoryUpArrow].rect.left;
- _string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].rect.top + virtscr[2].topline;
+ _string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].rect.top + vs->topline;
_string[1].color = v2_mouseover_boxes[kInventoryUpArrow].color;
_messagePtr = (const byte *)" \1\2";
drawString(1);
@@ -254,7 +255,7 @@ void ScummEngine::redrawV2Inventory() {
// If necessary, draw "down" arrow
if (_inventoryOffset + 4 < getInventoryCount(_scummVars[VAR_EGO])) {
_string[1].xpos = v2_mouseover_boxes[kInventoryDownArrow].rect.left;
- _string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].rect.top + virtscr[2].topline;
+ _string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].rect.top + vs->topline;
_string[1].color = v2_mouseover_boxes[kInventoryDownArrow].color;
_messagePtr = (const byte *)" \3\4";
drawString(1);