aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/preagi_troll.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agi/preagi_troll.cpp')
-rw-r--r--engines/agi/preagi_troll.cpp305
1 files changed, 156 insertions, 149 deletions
diff --git a/engines/agi/preagi_troll.cpp b/engines/agi/preagi_troll.cpp
index 445a9e34ff..c2e2bef66e 100644
--- a/engines/agi/preagi_troll.cpp
+++ b/engines/agi/preagi_troll.cpp
@@ -31,32 +31,35 @@
namespace Agi {
-Troll::Troll(PreAgiEngine* vm) : _vm(vm) {
+TrollEngine::TrollEngine(OSystem *syst, const AGIGameDescription *gameDesc) : PreAgiEngine(syst, gameDesc) {
+}
+
+TrollEngine::~TrollEngine() {
}
// User Interface
-void Troll::pressAnyKey(int col) {
- _vm->drawStr(24, col, kColorDefault, IDS_TRO_PRESSANYKEY);
- _vm->_gfx->doUpdate();
- _vm->getSelection(kSelAnyKey);
+void TrollEngine::pressAnyKey(int col) {
+ drawStr(24, col, kColorDefault, IDS_TRO_PRESSANYKEY);
+ _gfx->doUpdate();
+ getSelection(kSelAnyKey);
}
-void Troll::drawMenu(const char *szMenu, int iSel) {
- _vm->clearTextArea();
- _vm->drawStr(21, 0, kColorDefault, szMenu);
- _vm->drawStr(22 + iSel, 0, kColorDefault, " *");
- _vm->_gfx->doUpdate();
+void TrollEngine::drawMenu(const char *szMenu, int iSel) {
+ clearTextArea();
+ drawStr(21, 0, kColorDefault, szMenu);
+ drawStr(22 + iSel, 0, kColorDefault, " *");
+ _gfx->doUpdate();
}
-bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {
+bool TrollEngine::getMenuSel(const char *szMenu, int *iSel, int nSel) {
Common::Event event;
int y;
drawMenu(szMenu, *iSel);
- while (!_vm->shouldQuit()) {
- while (_vm->_system->getEventManager()->pollEvent(event)) {
+ while (!shouldQuit()) {
+ while (_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_RTL:
case Common::EVENT_QUIT:
@@ -117,8 +120,8 @@ bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {
break;
}
}
- _vm->_system->updateScreen();
- _vm->_system->delayMillis(10);
+ _system->updateScreen();
+ _system->delayMillis(10);
}
return true;
@@ -126,18 +129,18 @@ bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {
// Graphics
-void Troll::drawPic(int iPic, bool f3IsCont, bool clr, bool troll) {
- _vm->_picture->setDimensions(IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
+void TrollEngine::drawPic(int iPic, bool f3IsCont, bool clr, bool troll) {
+ _picture->setDimensions(IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
if (clr) {
- _vm->clearScreen(0x0f, false);
- _vm->_picture->clear();
+ clearScreen(0x0f, false);
+ _picture->clear();
}
- _vm->_picture->setPictureData(_gameData + IDO_TRO_FRAMEPIC);
- _vm->_picture->drawPicture();
+ _picture->setPictureData(_gameData + IDO_TRO_FRAMEPIC);
+ _picture->drawPicture();
- _vm->_picture->setPictureData(_gameData + _pictureOffsets[iPic]);
+ _picture->setPictureData(_gameData + _pictureOffsets[iPic]);
int addFlag = 0;
@@ -145,26 +148,26 @@ void Troll::drawPic(int iPic, bool f3IsCont, bool clr, bool troll) {
addFlag = kPicFTrollMode;
if (f3IsCont) {
- _vm->_picture->setPictureFlags(kPicFf3Cont | addFlag);
+ _picture->setPictureFlags(kPicFf3Cont | addFlag);
} else {
- _vm->_picture->setPictureFlags(kPicFf3Stop | addFlag);
+ _picture->setPictureFlags(kPicFf3Stop | addFlag);
}
- _vm->_picture->drawPicture();
+ _picture->drawPicture();
- _vm->_picture->showPic();
- _vm->_gfx->doUpdate();
+ _picture->showPic();
+ _gfx->doUpdate();
}
// Game Logic
-void Troll::inventory() {
+void TrollEngine::inventory() {
char tmp[40];
int n;
- _vm->clearScreen(0x07);
- _vm->drawStr(1, 12, kColorDefault, IDS_TRO_TREASURE_0);
- _vm->drawStr(2, 12, kColorDefault, IDS_TRO_TREASURE_1);
+ clearScreen(0x07);
+ drawStr(1, 12, kColorDefault, IDS_TRO_TREASURE_0);
+ drawStr(2, 12, kColorDefault, IDS_TRO_TREASURE_1);
for (int i = 0; i < IDI_TRO_MAX_TREASURE - _treasuresLeft; i++) {
@@ -172,36 +175,36 @@ void Troll::inventory() {
sprintf(tmp, " %2d ", i + 1);
- _vm->drawStr(2 + i, 10, _items[n].bg << 4 | 0x0f, tmp);
- _vm->drawStr(2 + i, 14, _items[n].bg << 4 | _items[n].fg, _items[n].name);
+ drawStr(2 + i, 10, _items[n].bg << 4 | 0x0f, tmp);
+ drawStr(2 + i, 14, _items[n].bg << 4 | _items[n].fg, _items[n].name);
}
switch (_treasuresLeft) {
case 1:
sprintf(tmp, IDS_TRO_TREASURE_5, _treasuresLeft);
- _vm->drawStr(20, 10, kColorDefault, tmp);
+ drawStr(20, 10, kColorDefault, tmp);
break;
case 0:
- _vm->drawStr(20, 1, kColorDefault, IDS_TRO_TREASURE_6);
+ drawStr(20, 1, kColorDefault, IDS_TRO_TREASURE_6);
break;
case IDI_TRO_MAX_TREASURE:
- _vm->drawStr(3, 17, kColorDefault, IDS_TRO_TREASURE_2);
+ drawStr(3, 17, kColorDefault, IDS_TRO_TREASURE_2);
default:
sprintf(tmp, IDS_TRO_TREASURE_4, _treasuresLeft);
- _vm->drawStr(20, 10, kColorDefault, tmp);
+ drawStr(20, 10, kColorDefault, tmp);
break;
}
pressAnyKey(6);
}
-void Troll::waitAnyKeyIntro() {
+void TrollEngine::waitAnyKeyIntro() {
Common::Event event;
int iMsg = 0;
- while (!_vm->shouldQuit()) {
- while (_vm->_system->getEventManager()->pollEvent(event)) {
+ while (!shouldQuit()) {
+ while (_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_RTL:
case Common::EVENT_QUIT:
@@ -217,26 +220,26 @@ void Troll::waitAnyKeyIntro() {
case 200:
iMsg = 0;
case 0:
- _vm->drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_2);
- _vm->_gfx->doUpdate();
+ drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_2);
+ _gfx->doUpdate();
break;
case 100:
- _vm->drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_3);
- _vm->_gfx->doUpdate();
+ drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_3);
+ _gfx->doUpdate();
break;
}
iMsg++;
- _vm->_system->updateScreen();
- _vm->_system->delayMillis(10);
+ _system->updateScreen();
+ _system->delayMillis(10);
}
}
-void Troll::credits() {
- _vm->clearScreen(0x07);
+void TrollEngine::credits() {
+ clearScreen(0x07);
- _vm->drawStr(1, 2, kColorDefault, IDS_TRO_CREDITS_0);
+ drawStr(1, 2, kColorDefault, IDS_TRO_CREDITS_0);
int color = 10;
char str[2];
@@ -245,49 +248,49 @@ void Troll::credits() {
for (uint i = 0; i < strlen(IDS_TRO_CREDITS_1); i++) {
str[0] = IDS_TRO_CREDITS_1[i];
- _vm->drawStr(7, 19 + i, color++, str);
+ drawStr(7, 19 + i, color++, str);
if (color > 15)
color = 9;
}
- _vm->drawStr(8, 19, kColorDefault, IDS_TRO_CREDITS_2);
+ drawStr(8, 19, kColorDefault, IDS_TRO_CREDITS_2);
- _vm->drawStr(13, 11, 9, IDS_TRO_CREDITS_3);
- _vm->drawStr(15, 8, 10, IDS_TRO_CREDITS_4);
- _vm->drawStr(17, 7, 12, IDS_TRO_CREDITS_5);
- _vm->drawStr(19, 2, 14, IDS_TRO_CREDITS_6);
+ drawStr(13, 11, 9, IDS_TRO_CREDITS_3);
+ drawStr(15, 8, 10, IDS_TRO_CREDITS_4);
+ drawStr(17, 7, 12, IDS_TRO_CREDITS_5);
+ drawStr(19, 2, 14, IDS_TRO_CREDITS_6);
- _vm->_gfx->doUpdate();
+ _gfx->doUpdate();
pressAnyKey();
}
-void Troll::tutorial() {
+void TrollEngine::tutorial() {
bool done = false;
int iSel = 0;
//char szTreasure[16] = {0};
- while (!_vm->shouldQuit()) {
- _vm->clearScreen(0xFF);
+ while (!shouldQuit()) {
+ clearScreen(0xFF);
- _vm->printStr(IDS_TRO_TUTORIAL_0);
- _vm->getSelection(kSelSpace);
+ printStr(IDS_TRO_TUTORIAL_0);
+ getSelection(kSelSpace);
- _vm->clearScreen(0x55);
- _vm->setDefaultTextColor(0x0F);
+ clearScreen(0x55);
+ setDefaultTextColor(0x0F);
done = false;
- while (!done && !_vm->shouldQuit()) {
+ while (!done && !shouldQuit()) {
getMenuSel(IDS_TRO_TUTORIAL_1, &iSel, IDI_TRO_MAX_OPTION);
switch (iSel) {
case IDI_TRO_SEL_OPTION_1:
- _vm->clearScreen(0x22, false);
- _vm->_gfx->doUpdate();
+ clearScreen(0x22, false);
+ _gfx->doUpdate();
break;
case IDI_TRO_SEL_OPTION_2:
- _vm->clearScreen(0x00, false);
- _vm->_gfx->doUpdate();
+ clearScreen(0x00, false);
+ _gfx->doUpdate();
break;
case IDI_TRO_SEL_OPTION_3:
done = true;
@@ -296,102 +299,102 @@ void Troll::tutorial() {
}
// do you need more practice ?
- _vm->clearScreen(0x4F);
- _vm->drawStr(7, 4, kColorDefault, IDS_TRO_TUTORIAL_5);
- _vm->drawStr(9, 4, kColorDefault, IDS_TRO_TUTORIAL_6);
- _vm->_gfx->doUpdate();
+ clearScreen(0x4F);
+ drawStr(7, 4, kColorDefault, IDS_TRO_TUTORIAL_5);
+ drawStr(9, 4, kColorDefault, IDS_TRO_TUTORIAL_6);
+ _gfx->doUpdate();
- if (!_vm->getSelection(kSelYesNo))
+ if (!getSelection(kSelYesNo))
break;
}
// show info texts
- _vm->clearScreen(0x5F);
- _vm->drawStr(4, 1, kColorDefault, IDS_TRO_TUTORIAL_7);
- _vm->drawStr(5, 1, kColorDefault, IDS_TRO_TUTORIAL_8);
- _vm->_gfx->doUpdate();
+ clearScreen(0x5F);
+ drawStr(4, 1, kColorDefault, IDS_TRO_TUTORIAL_7);
+ drawStr(5, 1, kColorDefault, IDS_TRO_TUTORIAL_8);
+ _gfx->doUpdate();
pressAnyKey();
- _vm->clearScreen(0x2F);
- _vm->drawStr(6, 1, kColorDefault, IDS_TRO_TUTORIAL_9);
- _vm->_gfx->doUpdate();
+ clearScreen(0x2F);
+ drawStr(6, 1, kColorDefault, IDS_TRO_TUTORIAL_9);
+ _gfx->doUpdate();
pressAnyKey();
- _vm->clearScreen(0x19);
- _vm->drawStr(7, 1, kColorDefault, IDS_TRO_TUTORIAL_10);
- _vm->drawStr(8, 1, kColorDefault, IDS_TRO_TUTORIAL_11);
- _vm->_gfx->doUpdate();
+ clearScreen(0x19);
+ drawStr(7, 1, kColorDefault, IDS_TRO_TUTORIAL_10);
+ drawStr(8, 1, kColorDefault, IDS_TRO_TUTORIAL_11);
+ _gfx->doUpdate();
pressAnyKey();
- _vm->clearScreen(0x6E);
- _vm->drawStr(9, 1, kColorDefault, IDS_TRO_TUTORIAL_12);
- _vm->drawStr(10, 1, kColorDefault, IDS_TRO_TUTORIAL_13);
- _vm->_gfx->doUpdate();
+ clearScreen(0x6E);
+ drawStr(9, 1, kColorDefault, IDS_TRO_TUTORIAL_12);
+ drawStr(10, 1, kColorDefault, IDS_TRO_TUTORIAL_13);
+ _gfx->doUpdate();
pressAnyKey();
- _vm->clearScreen(0x4C);
- _vm->drawStr(11, 1, kColorDefault, IDS_TRO_TUTORIAL_14);
- _vm->drawStr(12, 1, kColorDefault, IDS_TRO_TUTORIAL_15);
- _vm->_gfx->doUpdate();
+ clearScreen(0x4C);
+ drawStr(11, 1, kColorDefault, IDS_TRO_TUTORIAL_14);
+ drawStr(12, 1, kColorDefault, IDS_TRO_TUTORIAL_15);
+ _gfx->doUpdate();
pressAnyKey();
- _vm->clearScreen(0x5D);
- _vm->drawStr(13, 1, kColorDefault, IDS_TRO_TUTORIAL_16);
- _vm->drawStr(14, 1, kColorDefault, IDS_TRO_TUTORIAL_17);
- _vm->drawStr(15, 1, kColorDefault, IDS_TRO_TUTORIAL_18);
- _vm->_gfx->doUpdate();
+ clearScreen(0x5D);
+ drawStr(13, 1, kColorDefault, IDS_TRO_TUTORIAL_16);
+ drawStr(14, 1, kColorDefault, IDS_TRO_TUTORIAL_17);
+ drawStr(15, 1, kColorDefault, IDS_TRO_TUTORIAL_18);
+ _gfx->doUpdate();
pressAnyKey();
// show treasures
- _vm->clearScreen(0x2A);
- _vm->drawStr(2, 1, kColorDefault, IDS_TRO_TUTORIAL_19);
+ clearScreen(0x2A);
+ drawStr(2, 1, kColorDefault, IDS_TRO_TUTORIAL_19);
for (int i = 0; i < IDI_TRO_MAX_TREASURE; i++)
- _vm->drawStr(19 - i, 11, kColorDefault, _items[i].name);
+ drawStr(19 - i, 11, kColorDefault, _items[i].name);
- _vm->_gfx->doUpdate();
+ _gfx->doUpdate();
pressAnyKey();
}
-void Troll::intro() {
+void TrollEngine::intro() {
// sierra on-line presents
- _vm->clearScreen(0x2F);
- _vm->drawStr(9, 10, kColorDefault, IDS_TRO_INTRO_0);
- _vm->drawStr(14, 15, kColorDefault, IDS_TRO_INTRO_1);
- _vm->_gfx->doUpdate();
- _vm->_system->updateScreen();
- _vm->_system->delayMillis(3200);
+ clearScreen(0x2F);
+ drawStr(9, 10, kColorDefault, IDS_TRO_INTRO_0);
+ drawStr(14, 15, kColorDefault, IDS_TRO_INTRO_1);
+ _gfx->doUpdate();
+ _system->updateScreen();
+ _system->delayMillis(3200);
CursorMan.showMouse(true);
// Draw logo
- _vm->setDefaultTextColor(0x0f);
+ setDefaultTextColor(0x0f);
drawPic(45, false, true);
- _vm->_gfx->doUpdate();
+ _gfx->doUpdate();
// wait for keypress and alternate message
waitAnyKeyIntro();
// have you played this game before?
- _vm->drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_4);
- _vm->drawStr(23, 6, kColorDefault, IDS_TRO_INTRO_5);
- _vm->_gfx->doUpdate();
+ drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_4);
+ drawStr(23, 6, kColorDefault, IDS_TRO_INTRO_5);
+ _gfx->doUpdate();
- if (!_vm->getSelection(kSelYesNo))
+ if (!getSelection(kSelYesNo))
tutorial();
credits();
}
-void Troll::gameOver() {
+void TrollEngine::gameOver() {
// We do a check to see if the game should quit. Without this, the game show the picture, plays the
// music, and then quits. So if the game is quitting, we shouldn't run the "game over" part.
- if (_vm->shouldQuit())
+ if (shouldQuit())
return;
char szMoves[40];
- _vm->clearTextArea();
+ clearTextArea();
drawPic(42, true, true);
playTune(4, 25);
@@ -400,19 +403,19 @@ void Troll::gameOver() {
printUserMessage(33);
- _vm->clearTextArea();
+ clearTextArea();
drawPic(46, true, true);
sprintf(szMoves, IDS_TRO_GAMEOVER_0, _moves);
- _vm->drawStr(21, 1, kColorDefault, szMoves);
- _vm->drawStr(22, 1, kColorDefault, IDS_TRO_GAMEOVER_1);
- _vm->_gfx->doUpdate();
+ drawStr(21, 1, kColorDefault, szMoves);
+ drawStr(22, 1, kColorDefault, IDS_TRO_GAMEOVER_1);
+ _gfx->doUpdate();
pressAnyKey();
}
-void Troll::drawTroll() {
+void TrollEngine::drawTroll() {
for (int i = 0; i < IDI_TRO_NUM_NONTROLL; i++)
if (_currentRoom == _nonTrollRooms[i]) {
_isTrollAway = true;
@@ -422,14 +425,14 @@ void Troll::drawTroll() {
drawPic(43, false, false, true);
}
-int Troll::drawRoom(char *menu) {
+int TrollEngine::drawRoom(char *menu) {
int n = 0;
bool contFlag = false;
if (_currentRoom == 1) {
- _vm->_picture->setDimensions(IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
- _vm->clearScreen(0x00, false);
- _vm->_picture->clear();
+ _picture->setDimensions(IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
+ clearScreen(0x00, false);
+ _picture->clear();
} else {
if (_currentRoom != 42) {
@@ -439,7 +442,7 @@ int Troll::drawRoom(char *menu) {
}
drawPic(_currentRoom, contFlag, true);
- _vm->_gfx->doUpdate();
+ _gfx->doUpdate();
if (_currentRoom == 42) {
drawPic(44, false, false); // don't clear
@@ -450,7 +453,7 @@ int Troll::drawRoom(char *menu) {
}
}
- _vm->_gfx->doUpdate();
+ _gfx->doUpdate();
char tmp[10];
strncat(menu, (char*)_gameData + _locMessagesIdx[_currentRoom], 39);
@@ -469,7 +472,7 @@ int Troll::drawRoom(char *menu) {
return n;
}
-void Troll::playTune(int tune, int len) {
+void TrollEngine::playTune(int tune, int len) {
if (!_soundOn)
return;
@@ -482,34 +485,34 @@ void Troll::playTune(int tune, int len) {
duration = READ_LE_UINT16(_gameData + ptr);
ptr += 2;
- _vm->playNote(freq, duration);
+ playNote(freq, duration);
}
}
-void Troll::pickupTreasure(int treasureId) {
+void TrollEngine::pickupTreasure(int treasureId) {
char tmp[40];
_inventory[IDI_TRO_MAX_TREASURE - _treasuresLeft] = treasureId;
if (_currentRoom != 24) {
- _vm->clearTextArea();
+ clearTextArea();
drawPic(_currentRoom, false, true);
- _vm->_gfx->doUpdate();
+ _gfx->doUpdate();
}
printUserMessage(treasureId + 16);
- _vm->clearTextArea();
+ clearTextArea();
_treasuresLeft--;
switch (_treasuresLeft) {
case 1:
- _vm->drawStr(22, 1, kColorDefault, IDS_TRO_TREASURE_7);
+ drawStr(22, 1, kColorDefault, IDS_TRO_TREASURE_7);
break;
case 0:
- _vm->drawStr(22, 1, kColorDefault, IDS_TRO_TREASURE_8);
- _vm->drawStr(23, 4, kColorDefault, IDS_TRO_TREASURE_9);
+ drawStr(22, 1, kColorDefault, IDS_TRO_TREASURE_8);
+ drawStr(23, 4, kColorDefault, IDS_TRO_TREASURE_9);
_roomStates[6] = 1;
@@ -517,20 +520,20 @@ void Troll::pickupTreasure(int treasureId) {
break;
default:
sprintf(tmp, IDS_TRO_TREASURE_3, _treasuresLeft);
- _vm->drawStr(22, 1, kColorDefault, tmp);
+ drawStr(22, 1, kColorDefault, tmp);
break;
}
pressAnyKey();
}
-void Troll::printUserMessage(int msgId) {
+void TrollEngine::printUserMessage(int msgId) {
int i;
- _vm->clearTextArea();
+ clearTextArea();
for (i = 0; i < _userMessages[msgId - 1].num; i++) {
- _vm->drawStr(21 + i, 1, kColorDefault, _userMessages[msgId - 1].msg[i]);
+ drawStr(21 + i, 1, kColorDefault, _userMessages[msgId - 1].msg[i]);
}
if (msgId == 34) {
@@ -540,7 +543,7 @@ void Troll::printUserMessage(int msgId) {
pressAnyKey();
}
-void Troll::gameLoop() {
+void TrollEngine::gameLoop() {
bool done = false;
char menu[160+5];
int currentOption, numberOfOptions;
@@ -559,7 +562,7 @@ void Troll::gameLoop() {
memset(_inventory, 0, sizeof(_inventory));
- while (!done && !_vm->shouldQuit()) {
+ while (!done && !shouldQuit()) {
*menu = 0;
currentOption = 0;
@@ -589,7 +592,7 @@ void Troll::gameLoop() {
if (_currentRoom < 6 || _treasuresLeft == 0) {
_isTrollAway = true;
} else { // make odd 1:3
- _isTrollAway = (_vm->rnd(3) != 2);
+ _isTrollAway = (rnd(3) != 2);
}
break;
case OT_GET:
@@ -634,7 +637,7 @@ void Troll::gameLoop() {
}
-void Troll::fillOffsets() {
+void TrollEngine::fillOffsets() {
int i;
for (i = 0; i < IDI_TRO_PICNUM; i++)
@@ -721,8 +724,8 @@ void Troll::fillOffsets() {
// Init
-void Troll::init() {
- _vm->_picture->setPictureVersion(AGIPIC_V15);
+void TrollEngine::init() {
+ _picture->setPictureVersion(AGIPIC_V15);
//SetScreenPar(320, 200, (char*)ibm_fontdata);
const int gaps[] = { 0x3A40, 0x4600, 0x4800, 0x5800, 0x5a00, 0x6a00,
@@ -762,12 +765,16 @@ void Troll::init() {
fillOffsets();
}
-void Troll::run() {
- while (!_vm->shouldQuit()) {
+Common::Error TrollEngine::go() {
+ init();
+
+ while (!shouldQuit()) {
intro();
gameLoop();
gameOver();
}
+
+ return Common::kNoError;
}
} // End of namespace Agi