diff options
Diffstat (limited to 'engines/cruise')
| -rw-r--r-- | engines/cruise/actor.cpp | 2 | ||||
| -rw-r--r-- | engines/cruise/cruise.cpp | 9 | ||||
| -rw-r--r-- | engines/cruise/cruise_main.cpp | 255 | ||||
| -rw-r--r-- | engines/cruise/cruise_main.h | 2 | ||||
| -rw-r--r-- | engines/cruise/ctp.cpp | 8 | ||||
| -rw-r--r-- | engines/cruise/font.cpp | 4 | ||||
| -rw-r--r-- | engines/cruise/function.cpp | 6 | ||||
| -rw-r--r-- | engines/cruise/gfxModule.cpp | 13 | ||||
| -rw-r--r-- | engines/cruise/gfxModule.h | 1 | ||||
| -rw-r--r-- | engines/cruise/menu.cpp | 2 | ||||
| -rw-r--r-- | engines/cruise/saveload.cpp | 8 |
11 files changed, 142 insertions, 168 deletions
diff --git a/engines/cruise/actor.cpp b/engines/cruise/actor.cpp index 969be96573..845867409e 100644 --- a/engines/cruise/actor.cpp +++ b/engines/cruise/actor.cpp @@ -528,7 +528,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2 return; } - /****** COUPE LE CHEMIN ******/ + /****** Trim down any un-necessary walk points ******/ i++; d = 0; diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp index 4656704cb8..3d3a44a36c 100644 --- a/engines/cruise/cruise.cpp +++ b/engines/cruise/cruise.cpp @@ -118,6 +118,7 @@ void CruiseEngine::initialize() { // video init stuff initSystem(); + gfxModuleData_Init(); // another bit of video init @@ -139,6 +140,14 @@ void CruiseEngine::initialize() { void CruiseEngine::deinitialise() { polyStructNorm.clear(); polyStructExp.clear(); + + // Clear any backgrounds + for (int i = 0; i < 8; ++i) { + if (backgroundScreens[i]) { + free(backgroundScreens[i]); + backgroundScreens[i] = NULL; + } + } } bool CruiseEngine::loadLanguageStrings() { diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 938e823fe9..e5864ebb31 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -35,13 +35,13 @@ namespace Cruise { +enum RelationType {RT_REL = 30, RT_MSG = 50}; + static int playerDontAskQuit; unsigned int timer = 0; gfxEntryStruct* linkedMsgList = NULL; -extern bool isBlack; - void drawBlackSolidBoxSmall() { // gfxModuleData.drawSolidBox(64,100,256,117,0); drawSolidBox(64, 100, 256, 117, 0); @@ -514,6 +514,7 @@ void CruiseEngine::initAllData(void) { strcpy(lastOverlay, "AUTO00"); _gameSpeed = GAME_FRAME_DELAY_1; + _speedFlag = false; return; } @@ -1025,8 +1026,8 @@ void callSubRelation(menuElementSubStruct *pMenuElement, int nOvl, int nObj) { } if ((obj2Ovl == nOvl) && (pHeader->obj2Number != -1) && (pHeader->obj2Number == nObj)) { -// int x = 60; -// int y = 60; + int x = 60; + int y = 60; objectParamsQuery params; memset(¶ms, 0, sizeof(objectParamsQuery)); // to remove warning @@ -1036,7 +1037,7 @@ void callSubRelation(menuElementSubStruct *pMenuElement, int nOvl, int nObj) { } if ((pHeader->obj2OldState == -1) || (params.state == pHeader->obj2OldState)) { - if (pHeader->type == 30) { // REL + if (pHeader->type == RT_REL) { // REL if (currentScriptPtr) { attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); } else { @@ -1074,8 +1075,69 @@ void callSubRelation(menuElementSubStruct *pMenuElement, int nOvl, int nObj) { changeScriptParamInList(ovlIdx, pHeader->id, &relHead, 0, 9998); } } - } else if (pHeader->type == 50) { - ASSERT(0); + } else if (pHeader->type == RT_MSG) { + + if (pHeader->obj2Number >= 0) { + if ((pHeader->trackX !=-1) && (pHeader->trackY !=-1) && + (pHeader->trackX != 9999) && (pHeader->trackY != 9999)) { + x = pHeader->trackX - 100; + y = pHeader->trackY - 150; + } else if (params.scale >= 0) { + x = params.X - 100; + y = params.Y - 40; + } + + if (pHeader->obj2NewState != -1) { + objInit(obj2Ovl, pHeader->obj2Number, pHeader->obj2NewState); + } + } + + if ((pHeader->obj1Number >= 0) && (pHeader->obj1NewState != -1)) { + int obj1Ovl = pHeader->obj1Overlay; + if (!obj1Ovl) obj1Ovl = ovlIdx; + objInit(obj1Ovl, pHeader->obj1Number, pHeader->obj1NewState); + } + + if (currentScriptPtr) { + createTextObject(&cellHead, ovlIdx, pHeader->id, x, y, 200, findHighColor(), masterScreen, currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber); + } else { + createTextObject(&cellHead, ovlIdx, pHeader->id, x, y, 200, findHighColor(), masterScreen, 0, 0); + } + + userWait = 1; + autoOvl = ovlIdx; + autoMsg = pHeader->id; + + if ((narratorOvl > 0) && (pHeader->trackX != -1) && (pHeader->trackY != -1)) { + actorStruct *pTrack = findActor(&actorHead, narratorOvl, narratorIdx, 0); + + if (pTrack) { + objectParamsQuery naratorParams; + animationStart = false; + + if (pHeader->trackDirection == 9999) { + getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams); + pTrack->x_dest = naratorParams.X; + pTrack->y_dest = naratorParams.Y; + pTrack->endDirection = direction(naratorParams.X, naratorParams.Y, pHeader->trackX,pHeader->trackY, 0, 0); + } else if ((pHeader->trackX == 9999) && (pHeader->trackY == 9999)) { + getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams); + pTrack->x_dest = naratorParams.X; + pTrack->y_dest = naratorParams.Y; + pTrack->endDirection = pHeader->trackDirection; + } else { + pTrack->x_dest = pHeader->trackX; + pTrack->y_dest = pHeader->trackY; + pTrack->endDirection = pHeader->trackDirection; + } + + pTrack->flag = 1; + autoTrack = true; + userWait = 0; + userEnabled = 0; + freezeCell(&cellHead, ovlIdx, pHeader->id, 5, -1, 0, 9998); + } + } } } } @@ -1113,7 +1175,7 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { if (pHeader->obj2Number == nObj2) { // REL - if (pHeader->type == 30) { + if (pHeader->type == RT_REL) { if (currentScriptPtr) { attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); } else { @@ -1151,7 +1213,7 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { changeScriptParamInList(ovlIdx, pHeader->id, &relHead, 0, 9998); } } - } else if (pHeader->type == 50) { // MSG + } else if (pHeader->type == RT_MSG) { // MSG int obj1Ovl = pHeader->obj1Overlay; if (!obj1Ovl) obj1Ovl = ovlIdx; @@ -1293,11 +1355,6 @@ int CruiseEngine::processInput(void) { buttonDown = 0; } - if (userDelay && !userWait) { - userDelay--; - return 0; - } - // Check for Exit 'X' key if (keyboardCode == Common::KEYCODE_x) return 1; @@ -1343,6 +1400,8 @@ int CruiseEngine::processInput(void) { // Check for left mouse button click or Space to end user waiting if ((keyboardCode == Common::KEYCODE_SPACE) || (button == MB_LEFT)) userWait = 0; + + keyboardCode = Common::KEYCODE_INVALID; return 0; } @@ -1567,11 +1626,14 @@ int currentMouseButton = 0; bool bFastMode = false; -void manageEvents() { +bool manageEvents() { Common::Event event; + bool result = false; Common::EventManager * eventMan = g_system->getEventManager(); - while (eventMan->pollEvent(event)) { + while (eventMan->pollEvent(event) && !result) { + result = true; + switch (event.type) { case Common::EVENT_LBUTTONDOWN: currentMouseButton |= MB_LEFT; @@ -1588,11 +1650,12 @@ void manageEvents() { case Common::EVENT_MOUSEMOVE: currentMouseX = event.mouse.x; currentMouseY = event.mouse.y; + result = false; break; case Common::EVENT_QUIT: case Common::EVENT_RTL: playerDontAskQuit = 1; - return; + break; case Common::EVENT_KEYUP: switch (event.kbd.keycode) { case Common::KEYCODE_ESCAPE: @@ -1612,72 +1675,6 @@ void manageEvents() { break; } - /* - * switch (event.kbd.keycode) { - * case '\n': - * case '\r': - * case 261: // Keypad 5 - * if (allowPlayerInput) { - * mouseLeft = 1; - * } - * break; - * case 27: // ESC - * if (allowPlayerInput) { - * mouseRight = 1; - * } - * break; - * case 282: // F1 - * if (allowPlayerInput) { - * playerCommand = 0; // EXAMINE - * makeCommandLine(); - * } - * break; - * case 283: // F2 - * if (allowPlayerInput) { - * playerCommand = 1; // TAKE - * makeCommandLine(); - * } - * break; - * case 284: // F3 - * if (allowPlayerInput) { - * playerCommand = 2; // INVENTORY - * makeCommandLine(); - * } - * break; - * case 285: // F4 - * if (allowPlayerInput) { - * playerCommand = 3; // USE - * makeCommandLine(); - * } - * break; - * case 286: // F5 - * if (allowPlayerInput) { - * playerCommand = 4; // ACTIVATE - * makeCommandLine(); - * } - * break; - * case 287: // F6 - * if (allowPlayerInput) { - * playerCommand = 5; // SPEAK - * makeCommandLine(); - * } - * break; - * case 290: // F9 - * if (allowPlayerInput && !inMenu) { - * makeActionMenu(); - * makeCommandLine(); - * } - * break; - * case 291: // F10 - * if (!disableSystemMenu && !inMenu) { - * g_cine->makeSystemMenu(); - * } - * break; - * default: - * //lastKeyStroke = event.kbd.keycode; - * break; - * } - * break; */ if (event.kbd.flags == Common::KBD_CTRL) { if (event.kbd.keycode == Common::KEYCODE_d) { // Start the debugger @@ -1694,17 +1691,10 @@ void manageEvents() { } } - /*if (count) { - * mouseData.left = mouseLeft; - * mouseData.right = mouseRight; - * mouseLeft = 0; - * mouseRight = 0; - * } - */ + return result; } void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY) { - manageEvents(); *pMouseX = currentMouseX; *pMouseY = currentMouseY; *pMouseButton = currentMouseButton; @@ -1747,11 +1737,15 @@ void CruiseEngine::mainLoop(void) { if (!bFastMode) { // Delay for the specified amount of time, but still respond to events + bool skipEvents = false; + while (currentTick < lastTick + _gameSpeed) { g_system->delayMillis(10); currentTick = g_system->getMillis(); - manageEvents(); + if (!skipEvents) + skipEvents = manageEvents(); + if (playerDontAskQuit) break; if (_vm->getDebugger()->isAttached()) @@ -1784,35 +1778,35 @@ void CruiseEngine::mainLoop(void) { // t_start=Osystem_GetTicks(); // readKeyboard(); - bool isUserWait = userWait != 0; + bool isUserWait = userWait != 0; playerDontAskQuit = processInput(); if (playerDontAskQuit) break; - if (isUserWait && !userWait) { - // User waiting has ended - changeScriptParamInList(-1, -1, &procHead, 9999, 0); - changeScriptParamInList(-1, -1, &relHead, 9999, 0); - - mainDraw(0); - flipScreen(); - } - if (enableUser) { userEnabled = 1; enableUser = 0; } - if (userWait < 1) { - manageScripts(&relHead); - manageScripts(&procHead); + if (userDelay && !userWait) { + userDelay--; + continue; + } + + if (isUserWait & !userWait) { + // User waiting has ended + changeScriptParamInList(-1, -1, &procHead, 9999, 0); + changeScriptParamInList(-1, -1, &relHead, 9999, 0); + } + + manageScripts(&relHead); + manageScripts(&procHead); - removeFinishedScripts(&relHead); - removeFinishedScripts(&procHead); + removeFinishedScripts(&relHead); + removeFinishedScripts(&procHead); - processAnimation(); - } + processAnimation(); if (remdo) { // ASSERT(0); @@ -1837,10 +1831,8 @@ void CruiseEngine::mainLoop(void) { PCFadeFlag = 0; /*if (!PCFadeFlag)*/ - if (!isUserWait) { - mainDraw(0); - flipScreen(); - } + mainDraw(userWait); + flipScreen(); if (userEnabled && !userWait && !autoTrack) { if (currentActiveMenu == -1) { @@ -1849,7 +1841,7 @@ void CruiseEngine::mainLoop(void) { getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); - if (mouseX != oldMouseX && mouseY != oldMouseY) { + if (mouseX != oldMouseX || mouseY != oldMouseY) { int objectType; int newCursor1; int newCursor2; @@ -1874,38 +1866,9 @@ void CruiseEngine::mainLoop(void) { changeCursor(CURSOR_NORMAL); } - if (isUserWait) { - // User Wait handling - if (userWait == 1) { - // Initial step - do { - // Make sure any previous mouse press is released - getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); - } while (mouseButton != 0); - - ++userWait; -// mainDraw(0); -// flipScreen(); - } else { - // Standard handling -/* - manageScripts(&relHead); - manageScripts(&procHead); - - removeFinishedScripts(&relHead); - removeFinishedScripts(&procHead); -*/ - if (isBlack) { - // This is a bit of a hack to ensure that user waits directly after a palette fade - // have time to restore the palette before waiting starts - mainDraw(0); - flipScreen(); - } else { - // Draw the next screen - processAnimation(); - gfxModuleData_flipScreen(); - } - } + if (userWait == 1) { + // Waiting for press - original wait loop has been integrated into the + // main event loop continue; } diff --git a/engines/cruise/cruise_main.h b/engines/cruise/cruise_main.h index 86e8dc1591..d2e9350d70 100644 --- a/engines/cruise/cruise_main.h +++ b/engines/cruise/cruise_main.h @@ -96,7 +96,6 @@ void *mallocAndZero(int32 size); uint8 *mainProc14(uint16 overlay, uint16 idx); void printInfoBlackBox(const char *string); void waitForPlayerInput(void); -int initCt(const char * ctpName); void loadPackedFileToMem(int fileIdx, uint8 * buffer); int getNumObjectsByClass(int scriptIdx, int param); void resetFileEntryRange(int param1, int param2); @@ -108,7 +107,6 @@ void resetPtr2(scriptInstanceStruct * ptr); void getFileExtention(const char *name, char *buffer); void *allocAndZero(int size); void freeStuff2(void); -const char *getObjectName(int index, const char * string); void mainLoop(void); void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY); bool testMask(int x, int y, unsigned char* pData, int stride); diff --git a/engines/cruise/ctp.cpp b/engines/cruise/ctp.cpp index be4639af4d..aa2a6c7772 100644 --- a/engines/cruise/ctp.cpp +++ b/engines/cruise/ctp.cpp @@ -106,7 +106,7 @@ void renderCTPWalkBox(int16 *walkboxData, int hotPointX, int hotPointY, int X, i int16 *destination; int startX = X - ((upscaleValue(hotPointX, scale) + 0x8000) >> 16); -// int startY = Y - ((upscaleValue(hotPointY, scale) + 0x8000) >> 16); + int startY = Y - ((upscaleValue(hotPointY, scale) + 0x8000) >> 16); numPoints = *(walkboxData++); @@ -117,7 +117,7 @@ void renderCTPWalkBox(int16 *walkboxData, int hotPointX, int hotPointY, int X, i int pointY = *(walkboxData++); int scaledX = ((upscaleValue(pointX, scale) + 0x8000) >> 16) + startX; - int scaledY = ((upscaleValue(pointY, scale) + 0x8000) >> 16) + startX; + int scaledY = ((upscaleValue(pointY, scale) + 0x8000) >> 16) + startY; *(destination++) = scaledX; *(destination++) = scaledY; @@ -209,9 +209,9 @@ int setNodeState(int nodeIdx, int nodeState) { int oldState = walkboxState[nodeIdx]; if (nodeState == -1) - return + return oldState; - walkboxState[nodeIdx] = nodeState; + walkboxState[nodeIdx] = nodeState; return oldState; } diff --git a/engines/cruise/font.cpp b/engines/cruise/font.cpp index d5010b2bf8..c1afba3c45 100644 --- a/engines/cruise/font.cpp +++ b/engines/cruise/font.cpp @@ -159,7 +159,9 @@ void initSystem(void) { switchPal = 0; masterScreen = 0; + changeCursor(CURSOR_NOMOUSE); changeCursor(CURSOR_NORMAL); + mouseOn(); strcpy(cmdLine, ""); @@ -242,7 +244,7 @@ int32 prepareWordRender(int32 inRightBorder_X, int16 wordSpacingWidth, if (character == '|' || !character) { finish = 1; } else { - if (charData) { + if (charData >= 0) { if (pixelCount + wordSpacingWidth + (int16)fontData[charData].charWidth >= inRightBorder_X) { finish = 1; diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index eab69c6846..6fe82f76d4 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -709,9 +709,7 @@ int16 Op_GetMouseButton(void) { getMouseStatus(&dummy, &mouseX, &mouseButton, &mouseY); - if (mouseButton) - return 1; - return 0; + return mouseButton; } int16 Op_AddCell(void) { @@ -828,7 +826,7 @@ int16 Op_Preload(void) { } int16 Op_LoadCt(void) { - return initCt((char*)popPtr()); + return initCt((const char *)popPtr()); } int16 Op_EndAnim(void) { diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp index 50e6587d90..003a335e42 100644 --- a/engines/cruise/gfxModule.cpp +++ b/engines/cruise/gfxModule.cpp @@ -40,7 +40,6 @@ palEntry lpalette[256]; int palDirtyMin = 256; int palDirtyMax = -1; -bool isBlack = false; gfxModuleDataStruct gfxModuleData = { 0, // use Tandy @@ -218,6 +217,12 @@ void gfxCopyRect(const uint8 *sourceBuffer, int width, int height, byte *dest, i } } +void gfxModuleData_Init(void) { + memset(globalScreen, 0, 320 * 200); + memset(page00, 0, 320 * 200); + memset(page10, 0, 320 * 200); +} + void gfxModuleData_flipScreen(void) { memcpy(globalScreen, gfxModuleData.pPage00, 320 * 200); @@ -238,12 +243,6 @@ void flip() { g_system->setPalette(paletteRGBA + palDirtyMin*4, palDirtyMin, palDirtyMax - palDirtyMin + 1); palDirtyMin = 256; palDirtyMax = -1; - - isBlack = true; - for (i = 0; i < 256; ++i) { - isBlack = (lpalette[i].R == 0) && (lpalette[i].G == 0) && (lpalette[i].B == 0); - if (!isBlack) break; - } } g_system->copyRectToScreen(globalScreen, 320, 0, 0, 320, 200); diff --git a/engines/cruise/gfxModule.h b/engines/cruise/gfxModule.h index 4b06e62991..dc085d8b0d 100644 --- a/engines/cruise/gfxModule.h +++ b/engines/cruise/gfxModule.h @@ -56,6 +56,7 @@ void gfxCopyRect(const uint8 *sourceBuffer, int width, int height, byte *dest, i void gfxModuleData_gfxCopyScreen(const uint8 *sourcePtr, uint8 *destPtr); void convertGfxFromMode4(const uint8 *sourcePtr, int width, int height, uint8 *destPtr); void convertGfxFromMode5(const uint8 *sourcePtr, int width, int height, uint8 *destPtr); +void gfxModuleData_Init(void); void gfxModuleData_flipScreen(void); //void gfxModuleData_setPal(uint8 * ptr); void gfxModuleData_convertOldPalColor(uint16 oldColor, uint8 *pOutput); diff --git a/engines/cruise/menu.cpp b/engines/cruise/menu.cpp index 0e9ab55c82..54f686f32a 100644 --- a/engines/cruise/menu.cpp +++ b/engines/cruise/menu.cpp @@ -146,7 +146,7 @@ void updateMenuMouse(int mouseX, int mouseY, menuStruct *pMenu) { } } -void manageEvents(); +bool manageEvents(); int processMenu(menuStruct *pMenu) { int16 mouseX; diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp index d151950c5e..7fcc5ecb1b 100644 --- a/engines/cruise/saveload.cpp +++ b/engines/cruise/saveload.cpp @@ -898,11 +898,15 @@ Common::Error loadSavegameData(int saveGameIdx) { printf("Unsupported mono file load!\n"); ASSERT(0); //loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4); - } else */{ + } else */ + if (strlen(filesDatabase[i].subData.name) > 0) { loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i); - i = j - 1; + } else { + filesDatabase[i].subData.ptr = NULL; + filesDatabase[i].subData.ptrMask = NULL; } + i = j - 1; lowMemory = lowMemorySave; } } |
