aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorFilippos Karapetis2007-09-03 15:03:50 +0000
committerFilippos Karapetis2007-09-03 15:03:50 +0000
commitb555a1569794b9d72803cd6207f70434cc83ed72 (patch)
tree07a230f15979c3d177a719763bdce45c337e7f71 /engines/agi
parent750ad32030f3343ded3ad7ac942993da43de68b0 (diff)
downloadscummvm-rg350-b555a1569794b9d72803cd6207f70434cc83ed72.tar.gz
scummvm-rg350-b555a1569794b9d72803cd6207f70434cc83ed72.tar.bz2
scummvm-rg350-b555a1569794b9d72803cd6207f70434cc83ed72.zip
Some updates for Mickey: objects are shown now (though still incorrectly), implemented some incomplete code for the ship's blinking lights, implemented the scene animation function
svn-id: r28848
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/loader_preagi.cpp20
-rw-r--r--engines/agi/picture.cpp18
-rw-r--r--engines/agi/picture.h9
-rw-r--r--engines/agi/preagi_mickey.cpp82
4 files changed, 84 insertions, 45 deletions
diff --git a/engines/agi/loader_preagi.cpp b/engines/agi/loader_preagi.cpp
index e503aeea6c..abf3f69af4 100644
--- a/engines/agi/loader_preagi.cpp
+++ b/engines/agi/loader_preagi.cpp
@@ -138,6 +138,7 @@ int AgiLoader_preagi::loadResource(int t, int n) {
int ec = errOK;
uint8 *data = NULL;
char szFile[255] = {0};
+ Common::File infile;
if (n > MAX_DIRS)
return errBadResource;
@@ -153,7 +154,6 @@ int AgiLoader_preagi::loadResource(int t, int n) {
data = new uint8[4096];
sprintf(szFile, IDS_MSA_PATH_PIC, n);
- Common::File infile;
if (!infile.open(szFile))
return errBadResource;
infile.read(data, infile.size());
@@ -185,7 +185,23 @@ int AgiLoader_preagi::loadResource(int t, int n) {
*/
break;
case rVIEW:
- //
+ data = new uint8[4096];
+
+ sprintf(szFile, IDS_MSA_PATH_OBJ, IDS_MSA_NAME_OBJ[n]);
+
+ if (!infile.open(szFile))
+ return errBadResource;
+ infile.read(data, infile.size());
+
+ if (data != NULL) {
+ _vm->_game.pictures[n].rdata = data;
+ _vm->_game.dirPic[n].len = infile.size();
+ _vm->_game.dirPic[n].flags |= RES_LOADED;
+ } else {
+ ec = errBadResource;
+ }
+
+ infile.close();
break;
default:
ec = errBadResource;
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 2bd13b10c6..908b356b1a 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -773,8 +773,8 @@ int PictureMgr::unloadPicture(int n) {
* Show AGI picture.
* This function copies a ``hidden'' AGI picture to the output device.
*/
-void PictureMgr::showPic(int x, int pic_width, int pic_height) {
- int i, y;
+void PictureMgr::showPic(int x, int y, int pic_width, int pic_height) {
+ int i, y1;
int offset;
width = pic_width;
height = pic_height;
@@ -783,12 +783,22 @@ void PictureMgr::showPic(int x, int pic_width, int pic_height) {
i = 0;
offset = _vm->_game.lineMinPrint * CHAR_LINES;
- for (y = 0; y < height; y++) {
- _gfx->putPixelsA(x, y + offset, width, &_vm->_game.sbuf16c[i]);
+ for (y1 = y; y1 < y + height; y1++) {
+ _gfx->putPixelsA(x, y1 + offset, width, &_vm->_game.sbuf16c[i]);
i += width;
}
_gfx->flushScreen();
}
+// preagi needed functions (for plotPattern)
+void PictureMgr::setPattern(uint8 code, uint8 num) {
+ patCode = code;
+ patNum = num;
+}
+
+void PictureMgr::setColor(uint8 color) {
+ scrColour = color;
+}
+
} // End of namespace Agi
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 799037e3cd..8cb0e65b43 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -69,7 +69,6 @@ private:
void yCorner();
void fill();
int plotPatternPoint(int x, int y, int bitpos);
- void plotPattern(int x, int y);
void plotBrush();
void drawPicture();
@@ -85,8 +84,14 @@ public:
int decodePicture(int n, int clear, bool agi256 = false, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
int unloadPicture(int);
- void showPic(int x = 0, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
+ void showPic(int x = 0, int y = 0, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
uint8 *convertV3Pic(uint8 *src, uint32 len);
+
+ void plotPattern(int x, int y); // public because it's used directly by preagi
+
+ // preagi needed functions (for plotPattern)
+ void setPattern(uint8 code, uint8 num);
+ void setColor(uint8 color);
};
} // End of namespace Agi
diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp
index 8d31bdb7c9..ec69b1c409 100644
--- a/engines/agi/preagi_mickey.cpp
+++ b/engines/agi/preagi_mickey.cpp
@@ -601,37 +601,32 @@ void Mickey::debug() {
// Graphics
void Mickey::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
- uint8 *buffer = new uint8[4096];
- char szFile[255] = {0};
-
- sprintf(szFile, IDS_MSA_PATH_OBJ, IDS_MSA_NAME_OBJ[iObj]);
-
- Common::File infile;
-
- if(!infile.open(szFile))
- return;
-
-
- infile.read(buffer, infile.size());
+ // FIXME: objects are rendered incorrectly
+
+ // FIXME: Not sure about object dimensions
+ int objWidth = 44;
+ int objHeight = 44;
+ _vm->preAgiLoadResource(rVIEW, iObj);
+ _vm->_picture->decodePicture(iObj, false, false, objWidth, objHeight);
+ _vm->_picture->showPic(x0, y0, objWidth, objHeight);
+ _vm->_gfx->doUpdate();
+ _vm->_system->updateScreen(); // TODO: this should go in the game's main loop
-#if 0
- // TODO
+ // TrollVM code
+ /*
if (iObj == IDI_MSA_OBJECT_CRYSTAL) {
AGI_DrawPic(IDI_MSA_PIC_X0 + x0, IDI_MSA_PIC_Y0 + y0, IDF_AGI_PIC_V2 | IDF_AGI_STEP, buffer);
} else {
AGI_DrawPic(IDI_MSA_PIC_X0 + x0, IDI_MSA_PIC_Y0 + y0, IDF_AGI_PIC_V2, buffer);
}
-#endif
-
- infile.close();
- delete [] buffer;
+ */
}
void Mickey::drawPic(int iPic) {
_vm->preAgiLoadResource(rPICTURE, iPic);
// Note that decodePicture clears the screen
_vm->_picture->decodePicture(iPic, true, false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
- _vm->_picture->showPic(10, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+ _vm->_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
}
@@ -705,29 +700,47 @@ void Mickey::drawRoomAnimation() {
case IDI_MSA_PIC_SHIP_JUPITER:
case IDI_MSA_PIC_SHIP_MARS:
case IDI_MSA_PIC_SHIP_URANUS:
-
+ {
// draw blinking ship lights
- int iColor;
+#if 0
+ // TODO
+ uint8 iColor = 0;
+ uint8 x = 53;
+ uint8 y = 45;
+ int i = 0;
+ int lightWidth = 8;
+ int lightHeight = 8;
+
+ _vm->_picture->setPattern(2, 0);
for (int i = 0; i < 12; i++) {
iColor = game.nFrame + i;
if (iColor > 15) iColor -= 15;
- objLight[1] = iColor;
- objLight[4] += 7;
-
-#if 0
- // TODO
- AGI_DrawPic(0, 0, IDF_AGI_PIC_V2 | IDF_AGI_CIRCLE, (uint8 *)objLight);
-#endif
+ _vm->_picture->setColor(iColor);
+ y += 7;
+ _vm->_picture->plotPattern(x, y);
+
+ for (int y1 = y; y1 < lightHeight; y1++) {
+ _vm->_gfx->putPixelsA(x, y1, lightWidth, &_vm->_game.sbuf16c[i]);
+ i += lightWidth;
+ }
+
+ _vm->_gfx->flushScreen();
+ _vm->_gfx->doUpdate();
+ _vm->_system->updateScreen(); // TODO: this should go in the game's main loop
+
+
+ //AGI_DrawPic(0, 0, IDF_AGI_PIC_V2 | IDF_AGI_CIRCLE, (uint8 *)objLight); // TrollVM
}
game.nFrame--;
if (game.nFrame < 0) game.nFrame = 15;
+#endif
playSound(IDI_MSA_SND_PRESS_BLUE);
-
+ }
break;
case IDI_MSA_PIC_SHIP_CONTROLS:
@@ -795,13 +808,8 @@ void Mickey::drawLogo() {
}
void Mickey::animate() {
-#if 0
- // TODO
- if ((int)SDL_GetTicks() > (game.nTicks + IDI_MSA_ANIM_DELAY)) {
- game.nTicks = SDL_GetTicks();
- drawRoomAnimation();
- }
-#endif
+ _vm->_system->delayMillis(IDI_MSA_ANIM_DELAY);
+ drawRoomAnimation();
}
void Mickey::printRoomDesc() {
@@ -1151,7 +1159,7 @@ void Mickey::flashScreen() {
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->_system->delayMillis(25);
+ _vm->_system->delayMillis(IDI_MSA_ANIM_DELAY);
//Set back to black
_vm->_gfx->clearScreen(0);