aboutsummaryrefslogtreecommitdiff
path: root/queen
diff options
context:
space:
mode:
authorGregory Montoir2004-01-11 14:08:07 +0000
committerGregory Montoir2004-01-11 14:08:07 +0000
commitf2874733b0cee77307ef7abd59af9b5c4ac43c9f (patch)
tree77e4bcb09278312af532e4cb79f25299be0f8e8a /queen
parenta578817f98d6f26decee2cfd12fbbc535c12616e (diff)
downloadscummvm-rg350-f2874733b0cee77307ef7abd59af9b5c4ac43c9f.tar.gz
scummvm-rg350-f2874733b0cee77307ef7abd59af9b5c4ac43c9f.tar.bz2
scummvm-rg350-f2874733b0cee77307ef7abd59af9b5c4ac43c9f.zip
tweaked a bit dirty blocks display code, this fixes the minor glitch in interview intro
svn-id: r12317
Diffstat (limited to 'queen')
-rw-r--r--queen/display.cpp93
-rw-r--r--queen/display.h9
2 files changed, 25 insertions, 77 deletions
diff --git a/queen/display.cpp b/queen/display.cpp
index 391db8def0..966156584d 100644
--- a/queen/display.cpp
+++ b/queen/display.cpp
@@ -29,7 +29,6 @@
namespace Queen {
-
Display::Display(QueenEngine *vm, OSystem *system)
: _fullscreen(true), _horizontalScroll(0), _bdWidth(0), _bdHeight(0),
_system(system), _vm(vm) {
@@ -46,7 +45,7 @@ Display::Display(QueenEngine *vm, OSystem *system)
memset(_mousePtr, 0, sizeof(_mousePtr));
- _fullRefresh = true;
+ _fullRefresh = 1;
_dirtyBlocksWidth = SCREEN_W / D_BLOCK_W;
_dirtyBlocksHeight = SCREEN_H / D_BLOCK_H;
_dirtyBlocks = new uint8[_dirtyBlocksWidth * _dirtyBlocksHeight];
@@ -63,7 +62,6 @@ Display::Display(QueenEngine *vm, OSystem *system)
_pal.scrollable = true;
}
-
Display::~Display() {
delete[] _backdropBuf;
delete[] _panelBuf;
@@ -74,7 +72,6 @@ Display::~Display() {
delete[] _pal.panel;
}
-
void Display::dynalumInit(const char *roomName, uint16 roomNum) {
debug(9, "Display::dynalumInit(%s, %d)", roomName, roomNum);
memset(_dynalum.msk, 0, sizeof(_dynalum.msk));
@@ -97,7 +94,6 @@ void Display::dynalumInit(const char *roomName, uint16 roomNum) {
}
}
-
void Display::dynalumUpdate(int16 x, int16 y) {
if (!_dynalum.valid)
return;
@@ -141,7 +137,6 @@ void Display::dynalumUpdate(int16 x, int16 y) {
}
}
-
void Display::palConvert(uint8 *outPal, const uint8 *inPal, int start, int end) {
int i;
for (i = start; i <= end; i++) {
@@ -152,7 +147,6 @@ void Display::palConvert(uint8 *outPal, const uint8 *inPal, int start, int end)
}
}
-
void Display::palSet(const uint8 *pal, int start, int end, bool updateScreen) {
debug(9, "Display::palSet(%d, %d)", start, end);
uint8 tempPal[256 * 4];
@@ -164,26 +158,22 @@ void Display::palSet(const uint8 *pal, int start, int end, bool updateScreen) {
}
}
-
void Display::palSetJoeDress() {
memcpy(_pal.room + 144 * 3, _palJoeDress, 16 * 3);
memcpy(_pal.screen + 144 * 3, _palJoeDress, 16 * 3);
palSet(_pal.screen, 144, 159, true);
}
-
void Display::palSetJoeNormal() {
memcpy(_pal.room + 144 * 3, _palJoeClothes, 16 * 3);
memcpy(_pal.screen + 144 * 3, _palJoeClothes, 16 * 3);
palSet(_pal.screen, 144, 159, true);
}
-
void Display::palSetPanel() {
memcpy(_pal.room + 144 * 3, _pal.panel, (256 - 144) * 3);
}
-
void Display::palFadeIn(int start, int end, uint16 roomNum, bool dynalum, int16 dynaX, int16 dynaY) {
debug(9, "Display::palFadeIn(%d, %d)", start, end);
memcpy(_pal.screen, _pal.room, 256 * 3);
@@ -211,7 +201,6 @@ void Display::palFadeIn(int start, int end, uint16 roomNum, bool dynalum, int16
_pal.scrollable = true;
}
-
void Display::palFadeOut(int start, int end, uint16 roomNum) {
debug(9, "Display::palFadeOut(%d, %d)", start, end);
_pal.scrollable = false;
@@ -237,7 +226,6 @@ void Display::palFadeOut(int start, int end, uint16 roomNum) {
}
}
-
void Display::palFadePanel() {
int i;
uint8 tempPal[256 * 3];
@@ -249,7 +237,6 @@ void Display::palFadePanel() {
palSet(tempPal, 224, 255, true);
}
-
void Display::palScroll(int start, int end) {
debug(9, "Display::palScroll(%d, %d)", start, end);
@@ -271,7 +258,6 @@ void Display::palScroll(int start, int end) {
*palStart = b;
}
-
void Display::palCustomColors(uint16 roomNum) {
debug(9, "Display::palCustomColors(%d)", roomNum);
int i;
@@ -303,7 +289,6 @@ void Display::palCustomColors(uint16 roomNum) {
}
}
-
void Display::palCustomScroll(uint16 roomNum) {
debug(9, "Display::palCustomScroll(%d)", roomNum);
static int16 scrollx = 0;
@@ -512,7 +497,6 @@ void Display::palCustomScroll(uint16 roomNum) {
_pal.dirtyMax = MAX(_pal.dirtyMax, hiPal);
}
-
void Display::palCustomFlash() {
uint8 tempPal[256 * 3];
int i = 0;
@@ -534,7 +518,6 @@ void Display::palCustomFlash() {
palSet(_pal.screen, 0, 255, true);
}
-
void Display::palCustomLightsOff(uint16 roomNum) {
int end = 223;
int start = (roomNum == ROOM_FLODA_FRONTDESK) ? 32 : 16;
@@ -546,7 +529,6 @@ void Display::palCustomLightsOff(uint16 roomNum) {
_pal.scrollable = false;
}
-
void Display::palCustomLightsOn(uint16 roomNum) {
int end = 223;
int start = (roomNum == ROOM_FLODA_FRONTDESK) ? 32 : 0;
@@ -560,15 +542,9 @@ void Display::palCustomLightsOn(uint16 roomNum) {
_pal.scrollable = true;
}
-
void Display::screenMode(int comPanel, bool inCutaway) {
debug(6, "Display::screenMode(%d, %d)", comPanel, inCutaway);
- // FIXME: this is temporary, just to see if my theory is right
- if (comPanel == 2 && !inCutaway) {
- warning("Display::screenMode() - (comPanel == 2 && !inCutaway)");
- }
-
if (comPanel == 2 && inCutaway) {
fullscreen((_bdHeight == GAME_SCREEN_HEIGHT));
} else if (comPanel == 1) {
@@ -576,7 +552,6 @@ void Display::screenMode(int comPanel, bool inCutaway) {
}
}
-
void Display::prepareUpdate() {
if (!_fullscreen)
memcpy(_screenBuf + SCREEN_W * ROOM_ZONE_HEIGHT, _panelBuf, PANEL_W * PANEL_H);
@@ -591,7 +566,6 @@ void Display::prepareUpdate() {
}
}
-
void Display::update(bool dynalum, int16 dynaX, int16 dynaY) {
drawTexts();
if (_pal.scrollable && dynalum) {
@@ -602,11 +576,14 @@ void Display::update(bool dynalum, int16 dynaX, int16 dynaY) {
_pal.dirtyMin = 144;
_pal.dirtyMax = 144;
}
-// _fullRefresh = true;
+// _fullRefresh = 1;
if (_fullRefresh) {
_system->copy_rect(_screenBuf, SCREEN_W, 0, 0, SCREEN_W, SCREEN_H);
- _fullRefresh = false;
- debug(7, "Display::update() - Full blit");
+ --_fullRefresh;
+ if (_fullRefresh) {
+ memset(_dirtyBlocks, 0, _dirtyBlocksWidth * _dirtyBlocksHeight);
+ }
+ debug(7, "Display::update() - Full blit (%d)", _fullRefresh);
} else {
uint16 count = 0;
uint8 *scrBuf = _screenBuf;
@@ -639,7 +616,6 @@ void Display::update(bool dynalum, int16 dynaX, int16 dynaY) {
waitForTimer();
}
-
void Display::setupPanel() {
uint8 *pcxBuf = _vm->resource()->loadFile("panel.pcx");
uint32 size = _vm->resource()->fileSize("panel.pcx");
@@ -652,7 +628,6 @@ void Display::setupPanel() {
palSetPanel();
}
-
void Display::setupNewRoom(const char *name, uint16 room) {
dynalumInit(name, room);
@@ -671,18 +646,15 @@ void Display::setupNewRoom(const char *name, uint16 room) {
forceFullRefresh();
}
-
void Display::drawBobSprite(const uint8 *data, uint16 x, uint16 y, uint16 w, uint16 h, uint16 pitch, bool xflip) {
blit(_screenBuf, SCREEN_W, x, y, data, pitch, w, h, xflip, true);
setDirtyBlock(xflip ? (x - w + 1) : x, y, w, h);
}
-
void Display::drawBobPasteDown(const uint8 *data, uint16 x, uint16 y, uint16 w, uint16 h) {
blit(_backdropBuf, BACKDROP_W, x, y, data, w, w, h, false, true);
}
-
void Display::drawInventoryItem(const uint8 *data, uint16 x, uint16 y, uint16 w, uint16 h) {
if (data != NULL) {
blit(_panelBuf, PANEL_W, x, y, data, w, w, h, false, false);
@@ -692,7 +664,6 @@ void Display::drawInventoryItem(const uint8 *data, uint16 x, uint16 y, uint16 w,
setDirtyBlock(x, 150 + y, w, h);
}
-
void Display::blit(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, const uint8 *srcBuf, uint16 srcPitch, uint16 w, uint16 h, bool xflip, bool masked) {
assert(w <= dstPitch);
dstBuf += dstPitch * y + x;
@@ -729,7 +700,6 @@ void Display::blit(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, const uin
}
}
-
void Display::fill(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, uint16 w, uint16 h, uint8 color) {
assert(w <= dstPitch);
dstBuf += dstPitch * y + x;
@@ -739,7 +709,6 @@ void Display::fill(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, uint16 w,
}
}
-
void Display::readPCX(uint8 *dst, uint16 dstPitch, const uint8 *src, uint16 w, uint16 h) {
while (h--) {
uint8 *p = dst;
@@ -757,23 +726,27 @@ void Display::readPCX(uint8 *dst, uint16 dstPitch, const uint8 *src, uint16 w, u
}
}
-
void Display::horizontalScrollUpdate(int16 xCamera) {
debug(9, "Display::horizontalScrollUpdate(%d)", xCamera);
- int16 hs = _horizontalScroll;
- _horizontalScroll = 0;
- if (_bdWidth > 320) {
+ if (_bdWidth <= 320) {
+ horizontalScroll(0);
+ } else {
if (xCamera > 160 && xCamera < 480) {
- _horizontalScroll = xCamera - 160;
+ horizontalScroll(xCamera - 160);
} else if (xCamera >= 480) {
- _horizontalScroll = 320;
+ horizontalScroll(320);
+ } else {
+ horizontalScroll(0);
}
}
- if (hs != _horizontalScroll) {
- _fullRefresh = true;
- }
}
+void Display::horizontalScroll(int16 scroll) {
+ if (_horizontalScroll != scroll) {
+ _fullRefresh = 2;
+ _horizontalScroll = scroll;
+ }
+}
void Display::setDirtyBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
if (!_fullRefresh) {
@@ -795,12 +768,10 @@ void Display::setDirtyBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
}
}
-
void Display::handleTimer() {
_gotTick = true;
}
-
void Display::waitForTimer() {
_gotTick = false;
while (!_gotTick) {
@@ -808,7 +779,6 @@ void Display::waitForTimer() {
}
}
-
void Display::setMouseCursor(uint8 *buf, uint16 w, uint16 h) {
assert(w == 14 && h == 14);
uint16 size = 14 * 14;
@@ -826,12 +796,10 @@ void Display::setMouseCursor(uint8 *buf, uint16 w, uint16 h) {
_system->set_mouse_cursor(_mousePtr, 14, 14, 1, 1);
}
-
void Display::showMouseCursor(bool show) {
_system->show_mouse(show);
}
-
void Display::initFont() {
// calculate font justification sizes
uint16 i, y, x;
@@ -852,7 +820,6 @@ void Display::initFont() {
--_charWidth[(uint8)'^'];
}
-
void Display::setText(uint16 x, uint16 y, const char *text, bool outlined) {
if (y < GAME_SCREEN_HEIGHT) {
if (x == 0) x = 1;
@@ -866,13 +833,11 @@ void Display::setText(uint16 x, uint16 y, const char *text, bool outlined) {
}
}
-
void Display::setTextCentered(uint16 y, const char *text, bool outlined) {
uint16 x = (GAME_SCREEN_WIDTH - textWidth(text)) / 2;
setText(x, y, text, outlined);
}
-
void Display::drawTexts() {
int y;
for (y = GAME_SCREEN_HEIGHT - 1; y > 0; --y) {
@@ -883,7 +848,6 @@ void Display::drawTexts() {
}
}
-
void Display::clearTexts(uint16 y1, uint16 y2) {
while (y1 <= y2) {
_texts[y1].text.clear();
@@ -891,17 +855,14 @@ void Display::clearTexts(uint16 y1, uint16 y2) {
}
}
-
int Display::textCenterX(const char *text) const {
- return 160 - textWidth(text) / 2;
+ return (GAME_SCREEN_WIDTH - textWidth(text)) / 2;
}
-
uint16 Display::textWidth(const char *text) const {
return textWidth(text, strlen(text));
}
-
uint16 Display::textWidth(const char *text, uint16 len) const {
assert(len <= strlen(text));
uint16 width = 0;
@@ -911,7 +872,6 @@ uint16 Display::textWidth(const char *text, uint16 len) const {
return width;
}
-
void Display::drawChar(uint16 x, uint16 y, uint8 color, const uint8 *chr) {
uint8 *dstBuf = _screenBuf + SCREEN_W * y + x;
uint16 j, i;
@@ -931,7 +891,6 @@ void Display::drawChar(uint16 x, uint16 y, uint8 color, const uint8 *chr) {
}
}
-
void Display::drawText(uint16 x, uint16 y, uint8 color, const char *text, bool outlined) {
const uint8 *str = (const uint8*)text;
uint16 xs = x;
@@ -958,7 +917,6 @@ void Display::drawText(uint16 x, uint16 y, uint8 color, const char *text, bool o
setDirtyBlock(xs - 1, y - 1, x - xs + 2, 8 + 2);
}
-
void Display::drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint8 col) {
uint8 *p = _screenBuf;
int i;
@@ -970,7 +928,6 @@ void Display::drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint8 col) {
}
}
-
void Display::blankScreen() {
static int current = 0;
typedef void (Display::*BlankerEffect)();
@@ -984,7 +941,6 @@ void Display::blankScreen() {
forceFullRefresh();
}
-
void Display::blankScreenEffect1() {
uint8 buf[32 * 32];
while (_vm->input()->idleTime() >= Input::DELAY_SCREEN_BLANKER) {
@@ -1016,7 +972,6 @@ void Display::blankScreenEffect1() {
}
}
-
void Display::blankScreenEffect2() {
while (_vm->input()->idleTime() >= Input::DELAY_SCREEN_BLANKER) {
uint16 x = _vm->randomizer.getRandomNumber(SCREEN_W - 2);
@@ -1036,8 +991,6 @@ void Display::blankScreenEffect2() {
case 3:
c = *(p + SCREEN_W + 1);
break;
- default:
- break;
}
uint8 *buf = p;
int j = 2;
@@ -1051,7 +1004,6 @@ void Display::blankScreenEffect2() {
}
}
-
void Display::blankScreenEffect3() {
uint32 i = 0;
while (_vm->input()->idleTime() >= Input::DELAY_SCREEN_BLANKER) {
@@ -1081,7 +1033,6 @@ void Display::blankScreenEffect3() {
}
}
-
const uint8 Display::_font[] = {
0xF8, 0xB0, 0xB0, 0x80, 0xB0, 0xB0, 0xC0, 0x00, 0xF8, 0xB0,
0xB0, 0x80, 0xB0, 0xB0, 0xC0, 0x00, 0xF8, 0xB0, 0xB0, 0x80,
@@ -1290,7 +1241,6 @@ const uint8 Display::_font[] = {
0x00, 0x66, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x30, 0xFF
};
-
const uint8 Display::_palJoeClothes[] = {
0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x87, 0x87, 0x87,
0xB0, 0xB0, 0xB0, 0xDA, 0xDA, 0xDA, 0x43, 0x34, 0x20,
@@ -1300,7 +1250,6 @@ const uint8 Display::_palJoeClothes[] = {
0x98, 0xD4, 0xFF
};
-
const uint8 Display::_palJoeDress[] = {
0x00, 0x00, 0x00, 0x50, 0x50, 0x50, 0x70, 0x70, 0x70,
0x90, 0x90, 0x90, 0xC6, 0xC6, 0xC6, 0xFF, 0xFF, 0xFF,
diff --git a/queen/display.h b/queen/display.h
index 46df760791..3b42ef8554 100644
--- a/queen/display.h
+++ b/queen/display.h
@@ -73,14 +73,14 @@ public:
void readPCX(uint8 *dst, uint16 dstPitch, const uint8 *src, uint16 w, uint16 h);
void horizontalScrollUpdate(int16 xCamera);
- void horizontalScroll(int16 scroll) { _fullRefresh = true; _horizontalScroll = scroll; }
+ void horizontalScroll(int16 scroll);
int16 horizontalScroll() const { return _horizontalScroll; }
- void fullscreen(bool fs) { debug(6, "Display::fullscreen(%d)", fs); _fullRefresh = true; _fullscreen = fs; }
+ void fullscreen(bool fs) { _fullRefresh = 2; _fullscreen = fs; }
bool fullscreen() const { return _fullscreen; }
void setDirtyBlock(uint16 x, uint16 y, uint16 w, uint16 h);
- void forceFullRefresh() { _fullRefresh = true; memset(_dirtyBlocks, 0, _dirtyBlocksWidth * _dirtyBlocksHeight); }
+ void forceFullRefresh() { _fullRefresh = 2; }
void handleTimer();
void waitForTimer();
@@ -108,7 +108,6 @@ public:
void blankScreenEffect2();
void blankScreenEffect3();
-
private:
enum {
@@ -154,7 +153,7 @@ private:
uint8 _mousePtr[14 * 14];
- bool _fullRefresh;
+ uint8 _fullRefresh;
uint8 *_dirtyBlocks;
uint16 _dirtyBlocksWidth, _dirtyBlocksHeight;