aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/preagi_winnie.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agi/preagi_winnie.cpp')
-rw-r--r--engines/agi/preagi_winnie.cpp136
1 files changed, 72 insertions, 64 deletions
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index a91ad24fc6..8fb9daca5e 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -134,7 +134,7 @@ uint32 WinnieEngine::readObj(int iObj, uint8 *buffer) {
Common::File file;
if (!file.open(fileName)) {
- warning ("Could not open file \'%s\'", fileName.c_str());
+ warning("Could not open file \'%s\'", fileName.c_str());
return 0;
}
@@ -192,16 +192,16 @@ void WinnieEngine::randomize() {
void WinnieEngine::intro() {
drawPic(IDS_WTP_FILE_LOGO);
printStr(IDS_WTP_INTRO_0);
- _gfx->doUpdate();
+ g_system->updateScreen();
_system->delayMillis(0x640);
if (getPlatform() == Common::kPlatformAmiga)
- _gfx->clearScreen(0);
+ _gfx->clearDisplay(0);
drawPic(IDS_WTP_FILE_TITLE);
printStr(IDS_WTP_INTRO_1);
- _gfx->doUpdate();
+ g_system->updateScreen();
_system->delayMillis(0x640);
if (!playSound(IDI_WTP_SND_POOH_0))
@@ -226,11 +226,11 @@ void WinnieEngine::setTakeDrop(int fCanSel[]) {
fCanSel[IDI_WTP_SEL_DROP] = _gameStateWinnie.iObjHave;
}
-void WinnieEngine::setFlag(int iFlag) {
+void WinnieEngine::setWinnieFlag(int iFlag) {
_gameStateWinnie.fGame[iFlag] = 1;
}
-void WinnieEngine::clearFlag(int iFlag) {
+void WinnieEngine::clearWinnieFlag(int iFlag) {
_gameStateWinnie.fGame[iFlag] = 0;
}
@@ -274,9 +274,10 @@ int WinnieEngine::parser(int pc, int index, uint8 *buffer) {
memset(fCanSel, 0, sizeof(fCanSel));
// check if NSEW directions should be displayed
- if (hdr.roomNew[0])
+ if (hdr.roomNew[0]) {
fCanSel[IDI_WTP_SEL_NORTH] = fCanSel[IDI_WTP_SEL_SOUTH] =
fCanSel[IDI_WTP_SEL_EAST] = fCanSel[IDI_WTP_SEL_WEST] = true;
+ }
// check if object in room or player carrying one
setTakeDrop(fCanSel);
@@ -291,7 +292,7 @@ int WinnieEngine::parser(int pc, int index, uint8 *buffer) {
}
// extract menu string
- strcpy(szMenu, (char *)(buffer + pc));
+ Common::strlcpy(szMenu, (char *)(buffer + pc), 121);
XOR80(szMenu);
break;
default:
@@ -404,11 +405,11 @@ int WinnieEngine::parser(int pc, int index, uint8 *buffer) {
break;
case IDO_WTP_FLAG_CLEAR:
opcode = *(buffer + pc++);
- clearFlag(opcode);
+ clearWinnieFlag(opcode);
break;
case IDO_WTP_FLAG_SET:
opcode = *(buffer + pc++);
- setFlag(opcode);
+ setWinnieFlag(opcode);
break;
case IDO_WTP_GAME_OVER:
gameOver();
@@ -452,7 +453,7 @@ int WinnieEngine::parser(int pc, int index, uint8 *buffer) {
if (iBlock == 1)
return IDI_WTP_PAR_OK;
- _gfx->doUpdate();
+ g_system->updateScreen();
}
return IDI_WTP_PAR_OK;
@@ -477,7 +478,7 @@ void WinnieEngine::inventory() {
Common::String missing = Common::String::format(IDS_WTP_INVENTORY_1, _gameStateWinnie.nObjMiss);
drawStr(IDI_WTP_ROW_OPTION_4, IDI_WTP_COL_MENU, IDA_DEFAULT, missing.c_str());
- _gfx->doUpdate();
+ g_system->updateScreen();
getSelection(kSelAnyKey);
}
@@ -494,7 +495,7 @@ void WinnieEngine::printObjStr(int iObj, int iStr) {
bool WinnieEngine::isRightObj(int iRoom, int iObj, int *iCode) {
WTP_ROOM_HDR roomhdr;
- WTP_OBJ_HDR objhdr;
+ WTP_OBJ_HDR objhdr;
uint8 *roomdata = (uint8 *)malloc(4096);
uint8 *objdata = (uint8 *)malloc(2048);
@@ -755,7 +756,7 @@ void WinnieEngine::drawMenu(char *szMenu, int iSel, int fCanSel[]) {
break;
}
drawStr(iRow, iCol - 1, IDA_DEFAULT, ">");
- _gfx->doUpdate();
+ g_system->updateScreen();
}
void WinnieEngine::incMenuSel(int *iSel, int fCanSel[]) {
@@ -777,7 +778,7 @@ void WinnieEngine::getMenuMouseSel(int *iSel, int fCanSel[], int x, int y) {
case IDI_WTP_ROW_OPTION_1:
case IDI_WTP_ROW_OPTION_2:
case IDI_WTP_ROW_OPTION_3:
- if (fCanSel[y - IDI_WTP_ROW_OPTION_1]) *iSel = y - IDI_WTP_ROW_OPTION_1;
+ if (fCanSel[y - IDI_WTP_ROW_OPTION_1]) *iSel = y - IDI_WTP_ROW_OPTION_1;
break;
case IDI_WTP_ROW_OPTION_4:
if (fCanSel[IDI_WTP_SEL_NORTH] && (x > IDI_WTP_COL_NORTH - 1) && (x < 6)) *iSel = IDI_WTP_SEL_NORTH;
@@ -821,15 +822,16 @@ void WinnieEngine::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {
// Change cursor
if (fCanSel[IDI_WTP_SEL_NORTH] && hotspotNorth.contains(event.mouse.x, event.mouse.y)) {
- _gfx->setCursorPalette(true);
+ //_gfx->setCursorPalette(true);
+ // ????
} else if (fCanSel[IDI_WTP_SEL_SOUTH] && hotspotSouth.contains(event.mouse.x, event.mouse.y)) {
- _gfx->setCursorPalette(true);
+ //_gfx->setCursorPalette(true);
} else if (fCanSel[IDI_WTP_SEL_WEST] && hotspotWest.contains(event.mouse.x, event.mouse.y)) {
- _gfx->setCursorPalette(true);
+ //_gfx->setCursorPalette(true);
} else if (fCanSel[IDI_WTP_SEL_EAST] && hotspotEast.contains(event.mouse.x, event.mouse.y)) {
- _gfx->setCursorPalette(true);
+ //_gfx->setCursorPalette(true);
} else {
- _gfx->setCursorPalette(false);
+ //_gfx->setCursorPalette(false);
}
break;
@@ -838,47 +840,52 @@ void WinnieEngine::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {
if (fCanSel[IDI_WTP_SEL_NORTH] && hotspotNorth.contains(event.mouse.x, event.mouse.y)) {
*iSel = IDI_WTP_SEL_NORTH;
makeSel(iSel, fCanSel);
- _gfx->setCursorPalette(false);
+ //_gfx->setCursorPalette(false);
+ // TODO???
return;
} else if (fCanSel[IDI_WTP_SEL_SOUTH] && hotspotSouth.contains(event.mouse.x, event.mouse.y)) {
*iSel = IDI_WTP_SEL_SOUTH;
makeSel(iSel, fCanSel);
- _gfx->setCursorPalette(false);
+ //_gfx->setCursorPalette(false);
+ // TODO???
return;
} else if (fCanSel[IDI_WTP_SEL_WEST] && hotspotWest.contains(event.mouse.x, event.mouse.y)) {
*iSel = IDI_WTP_SEL_WEST;
makeSel(iSel, fCanSel);
- _gfx->setCursorPalette(false);
+ //_gfx->setCursorPalette(false);
+ // TODO???
return;
} else if (fCanSel[IDI_WTP_SEL_EAST] && hotspotEast.contains(event.mouse.x, event.mouse.y)) {
*iSel = IDI_WTP_SEL_EAST;
makeSel(iSel, fCanSel);
- _gfx->setCursorPalette(false);
+ //_gfx->setCursorPalette(false);
+ // TODO???
return;
} else {
- _gfx->setCursorPalette(false);
+ //_gfx->setCursorPalette(false);
+ // TODO???
}
switch (*iSel) {
- case IDI_WTP_SEL_OPT_1:
- case IDI_WTP_SEL_OPT_2:
- case IDI_WTP_SEL_OPT_3:
- for (int iSel2 = 0; iSel2 < IDI_WTP_MAX_OPTION; iSel2++) {
- if (*iSel == (fCanSel[iSel2 + IDI_WTP_SEL_REAL_OPT_1] - 1)) {
- *iSel = iSel2;
- // Menu selection made, hide the mouse cursor
- CursorMan.showMouse(false);
- return;
- }
- }
- break;
- default:
- if (fCanSel[*iSel]) {
+ case IDI_WTP_SEL_OPT_1:
+ case IDI_WTP_SEL_OPT_2:
+ case IDI_WTP_SEL_OPT_3:
+ for (int iSel2 = 0; iSel2 < IDI_WTP_MAX_OPTION; iSel2++) {
+ if (*iSel == (fCanSel[iSel2 + IDI_WTP_SEL_REAL_OPT_1] - 1)) {
+ *iSel = iSel2;
// Menu selection made, hide the mouse cursor
CursorMan.showMouse(false);
return;
}
- break;
+ }
+ break;
+ default:
+ if (fCanSel[*iSel]) {
+ // Menu selection made, hide the mouse cursor
+ CursorMan.showMouse(false);
+ return;
+ }
+ break;
}
break;
case Common::EVENT_RBUTTONUP:
@@ -941,7 +948,7 @@ void WinnieEngine::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {
break;
case Common::KEYCODE_s:
if (event.kbd.flags & Common::KBD_CTRL) {
- flipflag(fSoundOn);
+ flipFlag(VM_FLAG_SOUND_ON);
} else {
*iSel = IDI_WTP_SEL_SOUTH;
makeSel(iSel, fCanSel);
@@ -987,7 +994,7 @@ void WinnieEngine::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {
}
break;
default:
- if (!event.kbd.flags) { // if the control/alt/shift keys are not pressed
+ if (!event.kbd.flags) { // if the control/alt/shift keys are not pressed
keyHelp();
clrMenuSel(iSel, fCanSel);
}
@@ -1016,7 +1023,7 @@ void WinnieEngine::gameLoop() {
readRoom(_room, roomdata, hdr);
drawRoomPic();
- _gfx->doUpdate();
+ g_system->updateScreen();
decodePhase = 1;
}
@@ -1064,7 +1071,7 @@ void WinnieEngine::drawPic(const char *szName) {
Common::File file;
if (!file.open(fileName)) {
- warning ("Could not open file \'%s\'", fileName.c_str());
+ warning("Could not open file \'%s\'", fileName.c_str());
return;
}
@@ -1083,7 +1090,7 @@ void WinnieEngine::drawObjPic(int iObj, int x0, int y0) {
if (!iObj)
return;
- WTP_OBJ_HDR objhdr;
+ WTP_OBJ_HDR objhdr;
uint8 *buffer = (uint8 *)malloc(2048);
uint32 objSize = readObj(iObj, buffer);
parseObjHeader(&objhdr, buffer, sizeof(WTP_OBJ_HDR));
@@ -1102,7 +1109,7 @@ void WinnieEngine::drawRoomPic() {
int iObj = getObjInRoom(_room);
// clear gfx screen
- _gfx->clearScreen(0);
+ _gfx->clearDisplay(0);
// read room picture
readRoom(_room, buffer, roomhdr);
@@ -1175,7 +1182,8 @@ void WinnieEngine::clrMenuSel(int *iSel, int fCanSel[]) {
while (!fCanSel[*iSel]) {
*iSel += 1;
}
- _gfx->setCursorPalette(false);
+ //_gfx->setCursorPalette(false);
+ // TODO???
}
void WinnieEngine::printRoomStr(int iRoom, int iStr) {
@@ -1209,7 +1217,7 @@ void WinnieEngine::saveGame() {
if (!outfile)
return;
- outfile->writeUint32BE(MKTAG('W','I','N','N')); // header
+ outfile->writeUint32BE(MKTAG('W', 'I', 'N', 'N')); // header
outfile->writeByte(WTP_SAVEGAME_VERSION);
outfile->writeByte(_gameStateWinnie.fSound);
@@ -1244,7 +1252,7 @@ void WinnieEngine::loadGame() {
if (!infile)
return;
- if (infile->readUint32BE() == MKTAG('W','I','N','N')) {
+ if (infile->readUint32BE() == MKTAG('W', 'I', 'N', 'N')) {
saveVersion = infile->readByte();
if (saveVersion != WTP_SAVEGAME_VERSION)
warning("Old save game version (%d, current version is %d). Will try and read anyway, but don't be surprised if bad things happen", saveVersion, WTP_SAVEGAME_VERSION);
@@ -1262,25 +1270,25 @@ void WinnieEngine::loadGame() {
// Since we read the save file data as little-endian, we skip the first byte of each
// variable
- infile->seek(0); // Jump back to the beginning of the file
+ infile->seek(0); // Jump back to the beginning of the file
- infile->readUint16LE(); // skip unused field
- infile->readByte(); // first 8 bits of fSound
+ infile->readUint16LE(); // skip unused field
+ infile->readByte(); // first 8 bits of fSound
_gameStateWinnie.fSound = infile->readByte();
- infile->readByte(); // first 8 bits of nMoves
+ infile->readByte(); // first 8 bits of nMoves
_gameStateWinnie.nMoves = infile->readByte();
- infile->readByte(); // first 8 bits of nObjMiss
+ infile->readByte(); // first 8 bits of nObjMiss
_gameStateWinnie.nObjMiss = infile->readByte();
- infile->readByte(); // first 8 bits of nObjRet
+ infile->readByte(); // first 8 bits of nObjRet
_gameStateWinnie.nObjRet = infile->readByte();
- infile->readUint16LE(); // skip unused field
- infile->readUint16LE(); // skip unused field
- infile->readUint16LE(); // skip unused field
- infile->readByte(); // first 8 bits of iObjHave
+ infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
+ infile->readByte(); // first 8 bits of iObjHave
_gameStateWinnie.iObjHave = infile->readByte();
- infile->readUint16LE(); // skip unused field
- infile->readUint16LE(); // skip unused field
- infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
+ infile->readUint16LE(); // skip unused field
}
for (i = 0; i < IDI_WTP_MAX_FLAG; i++)
@@ -1322,7 +1330,7 @@ WinnieEngine::~WinnieEngine() {
void WinnieEngine::init() {
// Initialize sound
- switch (MidiDriver::getMusicType(MidiDriver::detectDevice(MDT_PCSPK|MDT_PCJR))) {
+ switch (MidiDriver::getMusicType(MidiDriver::detectDevice(MDT_PCSPK | MDT_PCJR))) {
case MT_PCSPK:
_soundemu = SOUND_EMU_PC;
break;
@@ -1335,7 +1343,7 @@ void WinnieEngine::init() {
}
_sound = new SoundMgr(this, _mixer);
- setflag(fSoundOn, true); // enable sound
+ setFlag(VM_FLAG_SOUND_ON, true); // enable sound
memset(&_gameStateWinnie, 0, sizeof(_gameStateWinnie));
_gameStateWinnie.fSound = 1;