aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBenjamin Haisch2008-04-23 20:12:06 +0000
committerBenjamin Haisch2008-04-23 20:12:06 +0000
commitd0ad5867e0d8ecb21aee7abfe0e7beb8eacfcf25 (patch)
tree77bafd6d29d67402ed0d22db8c43b64c4eb5f926 /engines
parentc841481aa37e673af7cadda41da6dbc77514a8d4 (diff)
downloadscummvm-rg350-d0ad5867e0d8ecb21aee7abfe0e7beb8eacfcf25.tar.gz
scummvm-rg350-d0ad5867e0d8ecb21aee7abfe0e7beb8eacfcf25.tar.bz2
scummvm-rg350-d0ad5867e0d8ecb21aee7abfe0e7beb8eacfcf25.zip
Fixed palette issues when showing the inventory and the menu.
Moved drawing code from drawFlex/drawAnimFrame to drawSurface. Implemented opcodes: - o1_VISUALFX - o1_SCREENLOCK - o1_SETTIMER - o1_SETGROUND - o1_SETCLIP - o1_SETEXCLUDE svn-id: r31675
Diffstat (limited to 'engines')
-rw-r--r--engines/made/resource.cpp13
-rw-r--r--engines/made/resource.h4
-rw-r--r--engines/made/screen.cpp109
-rw-r--r--engines/made/screen.h18
-rw-r--r--engines/made/script.cpp2
-rw-r--r--engines/made/scriptfuncs.cpp28
6 files changed, 100 insertions, 74 deletions
diff --git a/engines/made/resource.cpp b/engines/made/resource.cpp
index be212be733..3d9cec6fc1 100644
--- a/engines/made/resource.cpp
+++ b/engines/made/resource.cpp
@@ -69,12 +69,14 @@ void PictureResource::load(byte *source, int size) {
/*uint16 u = */sourceS->readUint16LE();
uint16 width = sourceS->readUint16LE();
uint16 height = sourceS->readUint16LE();
+
+ _paletteColorCount = (cmdOffs - 18) / 3; // 18 = sizeof header
debug(2, "width = %d; height = %d\n", width, height);
if (_hasPalette) {
- _picturePalette = new byte[768];
- sourceS->read(_picturePalette, 768);
+ _picturePalette = new byte[_paletteColorCount * 3];
+ sourceS->read(_picturePalette, _paletteColorCount * 3);
}
_picture = new Graphics::Surface();
@@ -196,6 +198,13 @@ void MenuResource::load(byte *source, int size) {
delete sourceS;
}
+const char *MenuResource::getString(int index) const {
+ if (index < _strings.size())
+ return _strings[index].c_str();
+ else
+ return NULL;
+}
+
/* ProjectReader */
ProjectReader::ProjectReader() {
diff --git a/engines/made/resource.h b/engines/made/resource.h
index 5508a65ffc..9fc89a5892 100644
--- a/engines/made/resource.h
+++ b/engines/made/resource.h
@@ -64,9 +64,11 @@ public:
Graphics::Surface *getPicture() const { return _picture; }
byte *getPalette() const { return _picturePalette; }
bool hasPalette() const { return _hasPalette; }
+ int getPaletteColorCount() const { return _paletteColorCount; }
protected:
Graphics::Surface *_picture;
byte *_picturePalette;
+ int _paletteColorCount;
bool _hasPalette;
};
@@ -103,7 +105,7 @@ public:
~MenuResource();
void load(byte *source, int size);
int getCount() const { return _strings.size(); }
- Common::String getString(int index) const { return _strings[index]; }
+ const char *getString(int index) const;
protected:
Common::Array<Common::String> _strings;
};
diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp
index c809749cf1..e63854db64 100644
--- a/engines/made/screen.cpp
+++ b/engines/made/screen.cpp
@@ -51,6 +51,19 @@ Screen::Screen(MadeEngine *vm) : _vm(vm) {
_screenLock = false;
_paletteLock = false;
+ _paletteInitialized = false;
+ _needPalette = false;
+ _oldPaletteColorCount = 256;
+ _paletteColorCount = 256;
+ memset(_newPalette, 0, 768);
+ memset(_palette, 0, 768);
+
+ _ground = 1;
+ _clip = 0;
+ _exclude = 0;
+
+ _visualEffectNum = 0;
+
clearChannels();
}
@@ -62,10 +75,30 @@ Screen::~Screen() {
void Screen::clearScreen() {
_screen1->fillRect(Common::Rect(0, 0, 320, 200), 0);
_screen2->fillRect(Common::Rect(0, 0, 320, 200), 0);
+ _needPalette = true;
//_vm->_system->clearScreen();
}
-void Screen::drawSurface(Graphics::Surface *source, int x, int y) {
+void Screen::drawSurface(Graphics::Surface *sourceSurface, int x, int y, const ClipInfo &clipInfo) {
+
+ byte *source = (byte*)sourceSurface->getBasePtr(0, 0);
+ byte *dest = (byte*)clipInfo.destSurface->getBasePtr(x, y);
+
+ // FIXME: Implement actual clipping
+ if (x + sourceSurface->w > clipInfo.destSurface->w || y + sourceSurface->h > clipInfo.destSurface->h) {
+ debug(2, "CLIPPING PROBLEM: x = %d; y = %d; w = %d; h = %d; x+w = %d; y+h = %d\n",
+ x, y, sourceSurface->w, sourceSurface->h, x + sourceSurface->w, y + sourceSurface->h);
+ return;
+ }
+
+ for (int16 yc = 0; yc < sourceSurface->h; yc++) {
+ for (int16 xc = 0; xc < sourceSurface->w; xc++) {
+ if (source[xc])
+ dest[xc] = source[xc];
+ }
+ source += sourceSurface->pitch;
+ dest += clipInfo.destSurface->pitch;
+ }
}
@@ -200,11 +233,11 @@ void Screen::updateSprites() {
memcpy(_screen2->pixels, _screen1->pixels, 64000);
- //drawSpriteChannels(_clipInfo1, 3, 0x40);//CHECKME
- drawSpriteChannels(_clipInfo1, 3, 0);//CHECKME
- drawSpriteChannels(_clipInfo2, 1, 2);//CHECKME
+ drawSpriteChannels(_clipInfo1, 3, 0);
+ drawSpriteChannels(_clipInfo2, 1, 2);
_vm->_system->copyRectToScreen((const byte*)_screen2->pixels, _screen2->pitch, 0, 0, _screen2->w, _screen2->h);
+
}
void Screen::clearChannels() {
@@ -220,36 +253,19 @@ uint16 Screen::drawFlex(uint16 flexIndex, int16 x, int16 y, uint16 flag1, uint16
if (flexIndex == 0)
return 0;
- if (flexIndex == 1279) return 0; // HACK: fixes the first screen
-
PictureResource *flex = _vm->_res->getPicture(flexIndex);
Graphics::Surface *sourceSurface = flex->getPicture();
- byte *source = (byte*)sourceSurface->getBasePtr(0, 0);
- byte *dest = (byte*)clipInfo.destSurface->getBasePtr(x, y);
-
-
- if (x + sourceSurface->w > clipInfo.destSurface->w || y + sourceSurface->h > clipInfo.destSurface->h) {
- debug(2, "CLIPPING PROBLEM: x = %d; y = %d; w = %d; h = %d; x+w = %d; y+h = %d\n",
- x, y, sourceSurface->w, sourceSurface->h, x + sourceSurface->w, y + sourceSurface->h);
- //fflush(stdout); g_system->delayMillis(5000);
- return 0;
- }
- for (int16 yc = 0; yc < sourceSurface->h; yc++) {
- for (int16 xc = 0; xc < sourceSurface->w; xc++) {
- if (source[xc])
- dest[xc] = source[xc];
- }
- source += sourceSurface->pitch;
- dest += clipInfo.destSurface->pitch;
- }
+ drawSurface(sourceSurface, x, y, clipInfo);
// Palette is set in showPage
- if (flex->hasPalette()) {
- byte *pal = flex->getPalette();
- if (pal != 0) {
- loadRGBPalette(pal);
- }
+ if (flex->hasPalette() && !_paletteLock && _needPalette) {
+ byte *flexPalette = flex->getPalette();
+ _oldPaletteColorCount = _paletteColorCount;
+ _paletteColorCount = flex->getPaletteColorCount();
+ memcpy(_newPalette, _palette, _oldPaletteColorCount * 3);
+ memcpy(_palette, flexPalette, _paletteColorCount * 3);
+ _needPalette = false;
}
_vm->_res->freeResource(flex);
@@ -264,24 +280,15 @@ void Screen::drawAnimFrame(uint16 animIndex, int16 x, int16 y, int16 frameNum, u
AnimationResource *anim = _vm->_res->getAnimation(animIndex);
Graphics::Surface *sourceSurface = anim->getFrame(frameNum);
- byte *source = (byte*)sourceSurface->getBasePtr(0, 0);
- byte *dest = (byte*)clipInfo.destSurface->getBasePtr(x, y);
- for (int16 yc = 0; yc < sourceSurface->h; yc++) {
- for (int16 xc = 0; xc < sourceSurface->w; xc++) {
- if (source[xc])
- dest[xc] = source[xc];
- }
- source += sourceSurface->pitch;
- dest += clipInfo.destSurface->pitch;
- }
+ drawSurface(sourceSurface, x, y, clipInfo);
_vm->_res->freeResource(anim);
}
uint16 Screen::drawPic(uint16 index, int16 x, int16 y, uint16 flag1, uint16 flag2) {
- //HACK (until clipping is impelemented)
+ //HACK (until clipping is implemented)
if (y > 200) y = 0;
drawFlex(index, x, y, flag1, flag2, _clipInfo1);
@@ -306,7 +313,6 @@ uint16 Screen::drawSprite(uint16 flexIndex, int16 x, int16 y) {
uint16 Screen::placeSprite(uint16 channelIndex, uint16 flexIndex, int16 x, int16 y) {
debug(2, "placeSprite(%d, %04X, %d, %d)\n", channelIndex, flexIndex, x, y); fflush(stdout);
- //g_system->delayMillis(5000);
if (channelIndex < 1 || channelIndex >= 100)
return 0;
@@ -445,15 +451,24 @@ void Screen::show() {
// TODO
+ if (_screenLock)
+ return;
+
+ drawSpriteChannels(_clipInfo1, 3, 0);
memcpy(_screen2->pixels, _screen1->pixels, 64000);
-
- drawSpriteChannels(_clipInfo2, 0, 0);
-
- //drawSpriteChannels(_clipInfo2, 3, 0);//CHECKME
- //drawSpriteChannels(_clipInfo2, 1, 2);//CHECKME
+ drawSpriteChannels(_clipInfo2, 1, 2);
- //_vm->_system->copyRectToScreen((const byte*)_screen1->pixels, _screen1->pitch, 0, 0, _screen1->w, _screen1->h);
+ // TODO: Implement visual effects (palette fading etc.)
+ if (!_paletteLock)
+ setRGBPalette(_palette, 0, _paletteColorCount);
_vm->_system->copyRectToScreen((const byte*)_screen2->pixels, _screen2->pitch, 0, 0, _screen2->w, _screen2->h);
+ _vm->_system->updateScreen();
+
+ if (!_paletteInitialized) {
+ memcpy(_newPalette, _palette, _paletteColorCount * 3);
+ _oldPaletteColorCount = _paletteColorCount;
+ _paletteInitialized = true;
+ }
}
diff --git a/engines/made/screen.h b/engines/made/screen.h
index c25ddbd6fb..eb072477a3 100644
--- a/engines/made/screen.h
+++ b/engines/made/screen.h
@@ -60,11 +60,16 @@ public:
void clearScreen();
- void drawSurface(Graphics::Surface *source, int x, int y);
+ void drawSurface(Graphics::Surface *sourceSurface, int x, int y, const ClipInfo &clipInfo);
void loadRGBPalette(byte *palRGB, int count = 256);
void setRGBPalette(byte *palRGB, int start = 0, int count = 256);
bool isPaletteLocked() { return _paletteLock; }
+ void setScreenLock(bool lock) { _screenLock = lock; }
void setPaletteLock(bool lock) { _paletteLock = lock; }
+ void setVisualEffectNum(int visualEffectNum) { _visualEffectNum = visualEffectNum; }
+ void setClip(uint16 clip) { _clip = clip; }
+ void setExclude(uint16 exclude) { _exclude = exclude; }
+ void setGround(uint16 ground) { _ground = ground; }
uint16 updateChannel(uint16 channelIndex);
void deleteChannel(uint16 channelIndex);
@@ -76,7 +81,7 @@ public:
void drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask, int16 excludeStateMask);
void updateSprites();
void clearChannels();
-
+
uint16 drawFlex(uint16 flexIndex, int16 x, int16 y, uint16 flag1, uint16 flag2, const ClipInfo &clipInfo);
void drawAnimFrame(uint16 animIndex, int16 x, int16 y, int16 frameNum, uint16 flag1, uint16 flag2, const ClipInfo &clipInfo);
@@ -98,10 +103,6 @@ public:
void show();
- void setClip(uint16 clip);
- void setExclude(uint16 exclude);
- void setGround(uint16 ground);
-
byte _screenPalette[256 * 4];
protected:
@@ -110,7 +111,12 @@ protected:
bool _screenLock;
bool _paletteLock;
+ byte _palette[768], _newPalette[768];
+ int _paletteColorCount, _oldPaletteColorCount;
+ bool _paletteInitialized, _needPalette;
+
uint16 _clip, _exclude, _ground;
+ int _visualEffectNum;
Graphics::Surface *_screen1, *_screen2;
ClipInfo _clipArea, _clipInfo1, _clipInfo2;
diff --git a/engines/made/script.cpp b/engines/made/script.cpp
index 2231f3ed2b..1f5518c685 100644
--- a/engines/made/script.cpp
+++ b/engines/made/script.cpp
@@ -682,7 +682,7 @@ void ScriptInterpreter::cmd_extend() {
byte argc = readByte();
int16 *argv = _stack.getStackPtr();
- debug(4, "func = %d (%s); argc = %d\n", func, extendFuncNames[func], argc); fflush(stdout);
+ debug(4, "func = %d (%s); argc = %d\n", func, extendFuncNames[func], argc);
for (int i = 0; i < argc; i++)
debug(4, "argv[%02d] = %04X (%d)\n", i, argv[i], argv[i]);
diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp
index 3010fc9b36..5c5995f593 100644
--- a/engines/made/scriptfuncs.cpp
+++ b/engines/made/scriptfuncs.cpp
@@ -176,10 +176,6 @@ int16 ScriptFunctionsRtz::o1_RESTOREGRAF(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_DRAWPIC(int16 argc, int16 *argv) {
-
- fflush(stdout);
- //g_system->delayMillis(5000);
-
int16 channel = _vm->_screen->drawPic(argv[4], argv[3], argv[2], argv[1], argv[0]);
return channel;
}
@@ -190,8 +186,6 @@ int16 ScriptFunctionsRtz::o1_CLS(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_SHOWPAGE(int16 argc, int16 *argv) {
- if (!_vm->_screen->isPaletteLocked())
- _vm->_system->setPalette(_vm->_screen->_screenPalette, 0, 256);
_vm->_screen->show();
return 0;
}
@@ -272,6 +266,7 @@ int16 ScriptFunctionsRtz::o1_EVENTKEY(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_VISUALFX(int16 argc, int16 *argv) {
+ _vm->_screen->setVisualEffectNum(argv[0]);
return 0;
}
@@ -343,6 +338,7 @@ int16 ScriptFunctionsRtz::o1_MUSICBEAT(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_SCREENLOCK(int16 argc, int16 *argv) {
+ _vm->_screen->setScreenLock(argv[0] != 0);
return 0;
}
@@ -377,7 +373,7 @@ int16 ScriptFunctionsRtz::o1_GETTIMER(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_SETTIMER(int16 argc, int16 *argv) {
- //g_system->delayMillis(5000);
+ _vm->setTimer(argv[1], argv[0]);
return 0;
}
@@ -444,6 +440,7 @@ int16 ScriptFunctionsRtz::o1_LOADCURSOR(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_SETGROUND(int16 argc, int16 *argv) {
+ _vm->_screen->setGround(argv[0]);
return 0;
}
@@ -456,6 +453,7 @@ int16 ScriptFunctionsRtz::o1_CLIPAREA(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_SETCLIP(int16 argc, int16 *argv) {
+ _vm->_screen->setClip(argv[0]);
return 0;
}
@@ -568,10 +566,8 @@ int16 ScriptFunctionsRtz::o1_PLACESPRITE(int16 argc, int16 *argv) {
int16 ScriptFunctionsRtz::o1_PLACETEXT(int16 argc, int16 *argv) {
Object *obj = _vm->_dat->getObject(argv[5]);
- _vm->_dat->dumpObject(argv[5]);
const char *text = obj->getString();
debug(4, "text = %s\n", text); fflush(stdout);
- //!! g_system->delayMillis(5000);
return 0;
}
@@ -605,12 +601,11 @@ int16 ScriptFunctionsRtz::o1_EXCLUDEAREA(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_SETEXCLUDE(int16 argc, int16 *argv) {
- g_system->delayMillis(5000);
+ _vm->_screen->setExclude(argv[0]);
return 0;
}
int16 ScriptFunctionsRtz::o1_GETSTATE(int16 argc, int16 *argv) {
- //!! g_system->delayMillis(5000);
int16 state = _vm->_screen->getChannelState(argv[0]);
return state;
}
@@ -635,8 +630,6 @@ int16 ScriptFunctionsRtz::o1_GETFRAMECOUNT(int16 argc, int16 *argv) {
debug(4, "anim = %04X\n", argv[0]);
int16 frameCount = _vm->_screen->getAnimFrameCount(argv[0]);
debug(4, "frameCount = %04X\n", frameCount);
- //fflush(stdout);
- //g_system->delayMillis(5000);
return frameCount;
}
@@ -681,18 +674,19 @@ int16 ScriptFunctionsRtz::o1_READTEXT(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_READMENU(int16 argc, int16 *argv) {
- /*
+
int16 objectIndex = argv[2];
int16 menuIndex = argv[1];
int16 textIndex = argv[0];
MenuResource *menu = _vm->_res->getMenu(menuIndex);
if (menu) {
- const char *text = menu->getString(textIndex).c_str();
+ const char *text = menu->getString(textIndex);
debug(4, "text = %s\n", text); fflush(stdout);
+ Object *obj = _vm->_dat->getObject(objectIndex);
+ obj->setString(text);
_vm->_res->freeResource(menu);
}
- g_system->delayMillis(5000);
- */
+
return 0;
}