aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2007-09-05 15:43:56 +0000
committerFilippos Karapetis2007-09-05 15:43:56 +0000
commit5a97b3d9be9c92624fc319abf4fb39105f8e7757 (patch)
tree146f6a08ccaaf25b583766374872ea4772cfcb31 /engines
parent4d30763ab91a450db439440897e45757b87e1352 (diff)
downloadscummvm-rg350-5a97b3d9be9c92624fc319abf4fb39105f8e7757.tar.gz
scummvm-rg350-5a97b3d9be9c92624fc319abf4fb39105f8e7757.tar.bz2
scummvm-rg350-5a97b3d9be9c92624fc319abf4fb39105f8e7757.zip
Some updates for Mickey:
- Click to move functionality (improvement over the original game). It's now possible to navigate around using the mouse as well, together with the menu commands. The mouse cursor changes when the player hovers it at the picture's edges, towards a direction where Mickey is able to move to (north, south, east or west) - waitAnyKey has been moved into Mickey's code (because of the animation part) - Implemented the circle flag for AGI picture decoding svn-id: r28853
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.h2
-rw-r--r--engines/agi/picture.cpp8
-rw-r--r--engines/agi/picture.h3
-rw-r--r--engines/agi/preagi_common.cpp28
-rw-r--r--engines/agi/preagi_mickey.cpp143
-rw-r--r--engines/agi/preagi_mickey.h3
6 files changed, 137 insertions, 50 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 64220e6896..3c01b9a3f0 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -1003,10 +1003,8 @@ public:
void clearScreen(int attr);
// Keyboard
- void waitAnyKeyAnim();
int getSelection(int type);
bool waitAnyKeyChoice();
- void waitAnyKey(bool anim = false);
int rnd(int hi) { return (_rnd->getRandomNumber(hi) + 1); }
// Text
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 715c7349a7..3ffd4895fd 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -480,7 +480,7 @@ void PictureMgr::plotPattern(int x, int y) {
circle_word = *circle_ptr++;
for (counter = 0; counter <= pen_width; counter += counterStep) {
- //if (pic.fCircle) pen_status |= 0x10;
+ if (_flagCircle) patCode |= 0x10;
if (circleCond || ((binary_list[counter>>1] & circle_word) != 0)) {
temp8 = t % 2;
t = t >> 1;
@@ -779,6 +779,8 @@ int PictureMgr::decodePicture(int n, int clear, bool agi256, int pic_width, int
_vm->clearImageStack();
_vm->recordImageStackCall(ADD_PIC, n, clear, agi256, 0, 0, 0, 0);
+ _flagCircle = false;
+
return errOK;
}
@@ -830,4 +832,8 @@ void PictureMgr::setColor(uint8 color) {
scrColour = color;
}
+void PictureMgr::setFlagCircle() {
+ _flagCircle = true;
+}
+
} // End of namespace Agi
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 8cb0e65b43..a45bc6087c 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -75,11 +75,13 @@ private:
// TODO: this is hardcoded for V2 pictures for now
static const int pictureType = AGIPIC_V2;
int width, height;
+ bool _flagCircle;
public:
PictureMgr(AgiBase *agi, GfxMgr *gfx) {
_vm = agi;
_gfx = gfx;
+ _flagCircle = false;
}
int decodePicture(int n, int clear, bool agi256 = false, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
@@ -92,6 +94,7 @@ public:
// preagi needed functions (for plotPattern)
void setPattern(uint8 code, uint8 num);
void setColor(uint8 color);
+ void setFlagCircle(); // needed for some
};
} // End of namespace Agi
diff --git a/engines/agi/preagi_common.cpp b/engines/agi/preagi_common.cpp
index d204f757fc..dab6a827f5 100644
--- a/engines/agi/preagi_common.cpp
+++ b/engines/agi/preagi_common.cpp
@@ -94,10 +94,6 @@ void PreAgiEngine::clearRow(int row) {
// Input functions
-void PreAgiEngine::waitAnyKeyAnim() {
- waitAnyKey(true);
-}
-
int PreAgiEngine::getSelection(int type) {
Common::Event event;
@@ -179,28 +175,4 @@ bool PreAgiEngine::waitAnyKeyChoice() {
}
}
-void PreAgiEngine::waitAnyKey(bool anim) {
- Common::Event event;
-
- for (;;) {
- while (_eventMan->pollEvent(event)) {
- switch(event.type) {
- case Common::EVENT_QUIT:
- _system->quit();
- case Common::EVENT_KEYDOWN:
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONUP:
- return;
- default:
- break;
- }
- }
- // TODO
- /*if (anim) {
- _game->Animate();
- UpdateScreen();
- }*/
- }
-}
-
}
diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp
index a0ad65207a..bc605c209e 100644
--- a/engines/agi/preagi_mickey.cpp
+++ b/engines/agi/preagi_mickey.cpp
@@ -165,7 +165,7 @@ bool Mickey::chooseY_N(int ofsPrompt, bool fErrorMsg) {
case 1: return true;
default: if (fErrorMsg) {
printExeStr(IDO_MSA_PRESS_YES_OR_NO);
- _vm->waitAnyKey();
+ waitAnyKey();
printExeStr(ofsPrompt);
}
break;
@@ -222,7 +222,7 @@ void Mickey::printExeMsg(int ofs) {
if (!ofs)
return;
printExeStr(ofs);
- _vm->waitAnyKeyAnim();
+ waitAnyKeyAnim();
}
void Mickey::printDatStr(int iDat, int iStr) {
@@ -302,6 +302,7 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
int *sel = 0;
int nWords;
int x, y;
+ int goIndex = -1, northIndex = -1, southIndex = -1, eastIndex = -1, westIndex = -1;
switch(iRow) {
case 0:
@@ -312,6 +313,30 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
break;
}
nWords = menu.row[iRow].count;
+ clickToMove = false;
+
+ for (int i = 0; i <= menu.row[0].count; i++)
+ if (menu.row[0].entry[i].szText[0] == 71 && menu.row[0].entry[i].szText[1] == 79) // GO
+ goIndex = i;
+
+ if (goIndex >= 0) {
+ for (int j = 0; j <= menu.row[1].count; j++) {
+ if (menu.row[1].entry[j].szText[0] == 78 && menu.row[1].entry[j].szText[1] == 79 &&
+ menu.row[1].entry[j].szText[2] == 82 && menu.row[1].entry[j].szText[3] == 84 &&
+ menu.row[1].entry[j].szText[4] == 72)
+ northIndex = j;
+ if (menu.row[1].entry[j].szText[0] == 83 && menu.row[1].entry[j].szText[1] == 79 &&
+ menu.row[1].entry[j].szText[2] == 85 && menu.row[1].entry[j].szText[3] == 84 &&
+ menu.row[1].entry[j].szText[4] == 72)
+ southIndex = j;
+ if (menu.row[1].entry[j].szText[0] == 69 && menu.row[1].entry[j].szText[1] == 65 &&
+ menu.row[1].entry[j].szText[2] == 83 && menu.row[1].entry[j].szText[3] == 84)
+ eastIndex = j;
+ if (menu.row[1].entry[j].szText[0] == 87 && menu.row[1].entry[j].szText[1] == 69 &&
+ menu.row[1].entry[j].szText[2] == 83 && menu.row[1].entry[j].szText[3] == 84)
+ westIndex = j;
+ }
+ }
drawMenu(menu, *sel0, *sel1);
@@ -329,9 +354,54 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
getMouseMenuSelRow(menu, sel0, sel1, iRow, x, y);
drawMenu(menu, *sel0, *sel1);
}
+
+ // Change cursor
+ if (northIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
+ (event.mouse.y >= 0 && event.mouse.y <= 10)) {
+ _vm->_gfx->setCursor(true);
+ } else if (southIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
+ (event.mouse.y >= IDI_MSA_PIC_HEIGHT - 10 && event.mouse.y <= IDI_MSA_PIC_HEIGHT)) {
+ _vm->_gfx->setCursor(true);
+ } else if (westIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
+ (event.mouse.x >= 20 && event.mouse.x <= 30)) {
+ _vm->_gfx->setCursor(true);
+ } else if (eastIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
+ (event.mouse.x >= IDI_MSA_PIC_WIDTH * 2 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2)) {
+ _vm->_gfx->setCursor(true);
+ } else {
+ _vm->_gfx->setCursor(false);
+ }
}
break;
case Common::EVENT_LBUTTONUP:
+ // Click to move
+ if (northIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
+ (event.mouse.y >= 0 && event.mouse.y <= 10)) {
+ *sel0 = goIndex; *sel1 = northIndex;
+ drawMenu(menu, *sel0, *sel1);
+ _vm->_gfx->setCursor(false);
+ clickToMove = true;
+ } else if (southIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
+ (event.mouse.y >= IDI_MSA_PIC_HEIGHT - 10 && event.mouse.y <= IDI_MSA_PIC_HEIGHT)) {
+ *sel0 = goIndex; *sel1 = southIndex;
+ drawMenu(menu, *sel0, *sel1);
+ _vm->_gfx->setCursor(false);
+ clickToMove = true;
+ } else if (westIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
+ (event.mouse.x >= 20 && event.mouse.x <= 30)) {
+ *sel0 = goIndex; *sel1 = westIndex;
+ drawMenu(menu, *sel0, *sel1);
+ _vm->_gfx->setCursor(false);
+ clickToMove = true;
+ } else if (eastIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
+ (event.mouse.x >= IDI_MSA_PIC_WIDTH * 2 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2)) {
+ *sel0 = goIndex; *sel1 = eastIndex;
+ drawMenu(menu, *sel0, *sel1);
+ _vm->_gfx->setCursor(false);
+ clickToMove = true;
+ } else {
+ _vm->_gfx->setCursor(false);
+ }
return true;
case Common::EVENT_RBUTTONUP:
*sel0 = 0; *sel1 = -1;
@@ -424,13 +494,15 @@ void Mickey::getMenuSel(char *buffer, int *sel0, int *sel1) {
for (;;) {
for (;;) {
if (getMenuSelRow(menu, sel0, sel1, 0)) {
+ if (clickToMove)
+ break;
*sel1 = 0;
if (getMenuSelRow(menu, sel0, sel1, 1)) {
break;
}
}
}
- if (getMenuSelRow(menu, sel0, sel1, 2)) {
+ if (clickToMove || getMenuSelRow(menu, sel0, sel1, 2)) {
break;
}
}
@@ -512,7 +584,7 @@ void Mickey::printDatMessage(int iStr) {
printDatString(iStr);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKeyAnim();
+ waitAnyKeyAnim();
}
// Sound
@@ -611,6 +683,9 @@ void Mickey::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
int objWidth = 44;
int objHeight = 44;
_vm->preAgiLoadResource(rVIEW, iObj);
+
+ if (iObj == IDI_MSA_OBJECT_CRYSTAL)
+ _vm->_picture->setFlagCircle();
_vm->_picture->decodePicture(iObj, false, false, objWidth, objHeight);
_vm->_picture->showPic(x0, y0, objWidth, objHeight);
_vm->_gfx->doUpdate();
@@ -820,7 +895,7 @@ void Mickey::printRoomDesc() {
// print room description
printDesc(game.iRoom);
- _vm->waitAnyKeyAnim();
+ waitAnyKeyAnim();
// print extended room description
@@ -905,7 +980,7 @@ void Mickey::saveGame() {
void Mickey::showPlanetInfo() {
for (int i = 0; i < IDI_MSA_MAX_PLANET_INFO; i++) {
printExeStr(IDO_MSA_PLANET_INFO[game.iPlanet][i]);
- _vm->waitAnyKey();
+ waitAnyKey();
}
}
@@ -925,7 +1000,7 @@ void Mickey::printStory() {
}
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
_vm->clearScreen(IDA_DEFAULT);
for (iRow = 0; iRow < 21; iRow++) {
@@ -935,7 +1010,7 @@ void Mickey::printStory() {
}
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
drawRoom();
_vm->_gfx->doUpdate();
@@ -952,7 +1027,7 @@ void Mickey::hidden() {
_vm->clearTextArea();
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
}
}
@@ -995,7 +1070,7 @@ void Mickey::pressOB(int iButton) {
_vm->drawStr(IDI_MSA_ROW_BUTTONS, IDI_MSA_COL_BUTTONS, IDA_DEFAULT, szButtons);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
}
void Mickey::checkAirSupply(bool fSuit, int *iSupply) {
@@ -1021,7 +1096,7 @@ void Mickey::insertDisk(int iDisk) {
_vm->drawStr(IDI_MSA_ROW_INSERT_DISK, IDI_MSA_COL_INSERT_DISK, IDA_DEFAULT, (const char *)IDS_MSA_INSERT_DISK[iDisk]);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
}
void Mickey::gameOver() {
@@ -1038,7 +1113,7 @@ void Mickey::gameOver() {
printExeMsg(IDO_MSA_GAME_OVER[7]);
}
- _vm->waitAnyKey();
+ waitAnyKey();
exit(0);
}
@@ -1085,7 +1160,7 @@ void Mickey::flipSwitch() {
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
#endif
- _vm->waitAnyKeyAnim();
+ waitAnyKeyAnim();
}
} else {
printStory();
@@ -1112,7 +1187,7 @@ void Mickey::inventory() {
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
_vm->clearScreen(IDA_DEFAULT);
@@ -1486,7 +1561,7 @@ bool Mickey::parse(int cmd, int arg) {
}
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
break;
case IDI_MSA_ACTION_GET_XTAL_VENUS:
game.iRmMenu[game.iRoom] = 3;
@@ -1822,7 +1897,7 @@ bool Mickey::parse(int cmd, int arg) {
(const char *)IDS_MSA_TEMP_F[game.iPlanet]);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
break;
case IDI_MSA_ACTION_PRESS_ORANGE:
if (game.fFlying) {
@@ -1856,7 +1931,7 @@ bool Mickey::parse(int cmd, int arg) {
(const char *)IDS_MSA_PLANETS[game.iPlanet]);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKeyAnim();
+ waitAnyKeyAnim();
showPlanetInfo();
} else {
printDatMessage(arg);
@@ -1953,6 +2028,36 @@ void Mickey::gameLoop() {
delete [] buffer;
}
+// Keyboard
+
+void Mickey::waitAnyKeyAnim() {
+ waitAnyKey(true);
+}
+
+void Mickey::waitAnyKey(bool anim) {
+ Common::Event event;
+
+ for (;;) {
+ while (_vm->_system->getEventManager()->pollEvent(event)) {
+ switch(event.type) {
+ case Common::EVENT_QUIT:
+ _vm->_system->quit();
+ case Common::EVENT_KEYDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ return;
+ default:
+ break;
+ }
+ }
+ if (anim) {
+ animate();
+ _vm->_gfx->doUpdate();
+ _vm->_system->updateScreen(); // TODO: this should go in the game's main loop
+ }
+ }
+}
+
// Debug
void Mickey::debug_DrawObjs() {
@@ -1968,7 +2073,7 @@ void Mickey::debug_DrawObjs() {
_vm->drawStrMiddle(23, IDA_DEFAULT, (const char *)IDS_MSA_NAME_OBJ[iObj]);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
}
}
@@ -1983,7 +2088,7 @@ void Mickey::debug_DrawPics(){
_vm->drawStrMiddle(22, IDA_DEFAULT, szTitle);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->waitAnyKey();
+ waitAnyKey();
}
}
diff --git a/engines/agi/preagi_mickey.h b/engines/agi/preagi_mickey.h
index 053fe3c2f8..671ac732db 100644
--- a/engines/agi/preagi_mickey.h
+++ b/engines/agi/preagi_mickey.h
@@ -737,6 +737,7 @@ public:
protected:
PreAgiEngine *_vm;
MSA_GAME game;
+ bool clickToMove;
int getDat(int);
void readExe(int, uint8*, long);
@@ -796,6 +797,8 @@ protected:
void initVars();
void initEngine();
void flipSwitch();
+ void waitAnyKeyAnim();
+ void waitAnyKey(bool anim = false);
};
}