diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cruise/backgroundIncrust.cpp | 4 | ||||
-rw-r--r-- | engines/cruise/cruise.cpp | 6 | ||||
-rw-r--r-- | engines/cruise/cruise.h | 13 | ||||
-rw-r--r-- | engines/cruise/cruise_main.cpp | 277 | ||||
-rw-r--r-- | engines/cruise/gfxModule.cpp | 22 | ||||
-rw-r--r-- | engines/cruise/mainDraw.cpp | 12 | ||||
-rw-r--r-- | engines/cruise/mainDraw.h | 2 |
7 files changed, 148 insertions, 188 deletions
diff --git a/engines/cruise/backgroundIncrust.cpp b/engines/cruise/backgroundIncrust.cpp index be872d9f81..f67f4e6170 100644 --- a/engines/cruise/backgroundIncrust.cpp +++ b/engines/cruise/backgroundIncrust.cpp @@ -147,7 +147,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx, backupBackground(newElement, newElement->X, newElement->Y, width, height, backgroundPtr); } - drawSprite(width, height, NULL, (char *)filesDatabase[params.fileIdx].subData.ptr, newElement->Y, newElement->X, (char *)backgroundPtr, (char *)filesDatabase[params.fileIdx].subData.ptrMask); + drawSprite(width, height, NULL, filesDatabase[params.fileIdx].subData.ptr, newElement->Y, newElement->X, backgroundPtr, filesDatabase[params.fileIdx].subData.ptrMask); } else { // poly if (saveBuffer == 1) { int newX; @@ -202,7 +202,7 @@ void regenerateBackgroundIncrust(backgroundIncrustStruct *pHead) { int width = filesDatabase[frame].width; int height = filesDatabase[frame].height; - drawSprite(width, height, NULL, (char *)filesDatabase[frame].subData.ptr, pl->Y, pl->X, (char*)backgroundPtrtable[pl->backgroundIdx], (char *)filesDatabase[frame].subData.ptrMask); + drawSprite(width, height, NULL, filesDatabase[frame].subData.ptr, pl->Y, pl->X, backgroundPtrtable[pl->backgroundIdx], filesDatabase[frame].subData.ptrMask); } else { // poly addBackgroundIncrustSub1(frame, pl->X, pl->Y, NULL, pl->scale, (char*)backgroundPtrtable[pl->backgroundIdx], (char *)filesDatabase[frame].subData.ptr); } diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp index 28cf97ff70..1f5f7d912e 100644 --- a/engines/cruise/cruise.cpp +++ b/engines/cruise/cruise.cpp @@ -83,7 +83,11 @@ Common::Error CruiseEngine::run() { Cruise::changeCursor(Cruise::CURSOR_NORMAL); CursorMan.showMouse(true); - Cruise::mainLoop(); + + lastTick = 0; + lastTickDebug = 0; + + mainLoop(); return Common::kNoError; } diff --git a/engines/cruise/cruise.h b/engines/cruise/cruise.h index 13b6a8018f..c8bc52045e 100644 --- a/engines/cruise/cruise.h +++ b/engines/cruise/cruise.h @@ -40,6 +40,8 @@ enum CruiseGameType { GType_CRUISE = 1 }; +#define GAME_FRAME_DELAY 70 + #define MAX_LANGUAGE_STRINGS 25 enum LangStringId { ID_PAUSED = 0, ID_INVENTORY = 5, ID_PLAYER_MENU = 7, @@ -49,15 +51,16 @@ struct CRUISEGameDescription; class CruiseEngine: public Engine { private: - void initialize(void); - bool loadLanguageStrings(); - bool makeLoad(char *saveName); - void mainLoop(int bootScriptIdx); - bool _preLoad; Debugger *_debugger; Common::StringList _langStrings; CursorType _savedCursor; + uint32 lastTick, lastTickDebug; + + void initialize(void); + bool loadLanguageStrings(); + bool makeLoad(char *saveName); + void mainLoop(); protected: // Engine APIs diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 8d8ae71713..01f4ed0b08 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -1700,8 +1700,8 @@ void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseButton = currentMouseButton; } -void mainLoop(void) { - int frames = 0; /* Number of frames displayed */ + +void CruiseEngine::mainLoop(void) { //int32 t_start,t_left; //uint32 t_end; //int32 q=0; /* Dummy */ @@ -1722,201 +1722,176 @@ void mainLoop(void) { initAllData(); - { - int playerDontAskQuit = 1; - int quitValue2 = 1; - int quitValue = 0; - - do { - frames++; -// t_start=Osystem_GetTicks(); - -// readKeyboard(); - playerDontAskQuit = processInput(); - - if (enableUser) { - userEnabled = 1; - enableUser = 0; - } + int playerDontAskQuit = 1; + int quitValue2 = 1; + int quitValue = 0; - manageScripts(&relHead); - manageScripts(&procHead); + do { + // Handle frame delay + uint32 currentTick = g_system->getMillis(); - removeFinishedScripts(&relHead); - removeFinishedScripts(&procHead); + if (!bFastMode) { + // Delay for the specified amount of time, but still respond to events + while (currentTick < lastTick + GAME_FRAME_DELAY) { + g_system->delayMillis(10); + currentTick = g_system->getMillis(); - processAnimation(); + manageEvents(); - if (remdo) { - // ASSERT(0); - /* main3 = 0; - * var24 = 0; - * var23 = 0; - * - * freeStuff2(); */ + if (_vm->getDebugger()->isAttached()) + _vm->getDebugger()->onFrame(); } + } else { + manageEvents(); - if (cmdLine[0]) { - ASSERT(0); - /* redrawStrings(0,&cmdLine,8); - - waitForPlayerInput(); + if (currentTick >= (lastTickDebug + 10)) { + lastTickDebug = currentTick; - cmdLine = 0; */ + if (_vm->getDebugger()->isAttached()) + _vm->getDebugger()->onFrame(); } + } - if (displayOn) { - if (doFade) - PCFadeFlag = 0; + lastTick = g_system->getMillis(); - /*if (!PCFadeFlag)*/ - { - mainDraw(0); - flipScreen(); - } + // Handle the next frame - if (userEnabled && !userWait && !autoTrack) { - if (currentActiveMenu == -1) { - int16 mouseX; - int16 mouseY; - int16 mouseButton; +// frames++; +// t_start=Osystem_GetTicks(); - static int16 oldMouseX = -1; - static int16 oldMouseY = -1; +// readKeyboard(); + playerDontAskQuit = processInput(); - getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); + if (enableUser) { + userEnabled = 1; + enableUser = 0; + } - if (mouseX != oldMouseX && mouseY != oldMouseY) { - int objectType; - int newCursor1; - int newCursor2; + manageScripts(&relHead); + manageScripts(&procHead); - oldMouseX = mouseX; - oldMouseY = mouseY; + removeFinishedScripts(&relHead); + removeFinishedScripts(&procHead); - objectType = findObject(mouseX, mouseY, &newCursor1, &newCursor2); + processAnimation(); - if (objectType == 9) { - changeCursor(CURSOR_EXIT); - } else if (objectType != -1) { - changeCursor(CURSOR_MAGNIFYING_GLASS); - } else { - changeCursor(CURSOR_WALK); - } - } - } else { - changeCursor(CURSOR_NORMAL); - } - } else { - changeCursor(CURSOR_NORMAL); - } + if (remdo) { + // ASSERT(0); + /* main3 = 0; + * var24 = 0; + * var23 = 0; + * + * freeStuff2(); */ + } - if (userWait) { - int16 mouseButton = 0; - checkInput(&mouseButton); + if (cmdLine[0]) { + ASSERT(0); + /* redrawStrings(0,&cmdLine,8); - while (!mouseButton) { - manageScripts(&relHead); - manageScripts(&procHead); + waitForPlayerInput(); - removeFinishedScripts(&relHead); - removeFinishedScripts(&procHead); + cmdLine = 0; */ + } - processAnimation(); + if (displayOn) { + if (doFade) + PCFadeFlag = 0; - flip(); + /*if (!PCFadeFlag)*/ + { + mainDraw(0); + flipScreen(); + } - // not exactly this - manageEvents(); + if (userEnabled && !userWait && !autoTrack) { + if (currentActiveMenu == -1) { + int16 mouseX; + int16 mouseY; + int16 mouseButton; - checkInput(&mouseButton); - } + static int16 oldMouseX = -1; + static int16 oldMouseY = -1; - changeScriptParamInList(-1, -1, &procHead, 9999, 0); - changeScriptParamInList(-1, -1, &relHead, 9999, 0); - userWait = 0; - } + getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); - // wait for character to finish auto track - if (autoTrack) { - if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, ATP_MOUSE)) { - if (autoMsg != -1) { - freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0); + if (mouseX != oldMouseX && mouseY != oldMouseY) { + int objectType; + int newCursor1; + int newCursor2; - char* pText = getText(autoMsg, autoOvl); + oldMouseX = mouseX; + oldMouseY = mouseY; - if (strlen(pText)) - userWait = 1; - } + objectType = findObject(mouseX, mouseY, &newCursor1, &newCursor2); - changeScriptParamInList(-1, -1, &relHead, 9998, 0); - autoTrack = false; - enableUser = 1; - } else { - userEnabled = false; + if (objectType == 9) { + changeCursor(CURSOR_EXIT); + } else if (objectType != -1) { + changeCursor(CURSOR_MAGNIFYING_GLASS); + } else { + changeCursor(CURSOR_WALK); + } } - } else if (autoMsg != -1) { - removeCell(&cellHead, autoOvl, autoMsg, 5, masterScreen); - autoMsg = -1; + } else { + changeCursor(CURSOR_NORMAL); } + } else { + changeCursor(CURSOR_NORMAL); } - // t_end = t_start+SPEED; -// t_left=t_start-Osystem_GetTicks()+SPEED; -#ifndef FASTDEBUG - /* if (t_left>0) - * if (t_left>SLEEP_MIN) - * Osystem_Delay(t_left-SLEEP_GRAN); - * while (Osystem_GetTicks()<t_end){q++;}; */ -#endif - manageEvents(); - - } while (!playerDontAskQuit && quitValue2 && quitValue != 7); - } - -} -int oldmain(int argc, char *argv[]) { - printf("Cruise for a corpse recode\n"); + if (userWait) { + int16 mouseButton = 0; + checkInput(&mouseButton); -// OSystemInit(); -// osystem = new OSystem; + while (!mouseButton) { + manageScripts(&relHead); + manageScripts(&procHead); - printf("Osystem Initialized\n"); + removeFinishedScripts(&relHead); + removeFinishedScripts(&procHead); - printf("Initializing engine...\n"); + processAnimation(); - PCFadeFlag = 0; + flip(); - //lowLevelInit(); + // not exactly this + manageEvents(); - // arg parser stuff - - workBuffer = (uint8 *) mallocAndZero(8192); - - /*volVar1 = 0; - * fileData1 = 0; */ - - /*PAL_fileHandle = -1; */ - - // video init stuff + checkInput(&mouseButton); + } - initSystem(); + changeScriptParamInList(-1, -1, &procHead, 9999, 0); + changeScriptParamInList(-1, -1, &relHead, 9999, 0); + userWait = 0; + } - // another bit of video init + // wait for character to finish auto track + if (autoTrack) { + if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, ATP_MOUSE)) { + if (autoMsg != -1) { + freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0); - if (!readVolCnf()) { - printf("Fatal: unable to load vol.cnf !\n"); - return (-1); - } + char* pText = getText(autoMsg, autoOvl); - printf("Entering main loop...\n"); - mainLoop(); + if (strlen(pText)) + userWait = 1; + } - //freeStuff(); + changeScriptParamInList(-1, -1, &relHead, 9998, 0); + autoTrack = false; + enableUser = 1; + } else { + userEnabled = false; + } + } else if (autoMsg != -1) { + removeCell(&cellHead, autoOvl, autoMsg, 5, masterScreen); + autoMsg = -1; + } + } - //freePtr(workBuffer); + manageEvents(); - return (0); + } while (!playerDontAskQuit && quitValue2 && quitValue != 7); } void *mallocAndZero(int32 size) { diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp index 3671b01b0e..8a21842503 100644 --- a/engines/cruise/gfxModule.cpp +++ b/engines/cruise/gfxModule.cpp @@ -222,10 +222,6 @@ void gfxModuleData_flipScreen(void) { flip(); } -extern bool bFastMode; - -static uint32 lastTick = 0, lastTickDebug = 0; - void flip() { int i; byte paletteRGBA[256 * 4]; @@ -244,24 +240,6 @@ void flip() { g_system->copyRectToScreen(globalScreen, 320, 0, 0, 320, 200); g_system->updateScreen(); - - uint32 currentTick = g_system->getMillis(); - - if (currentTick >= (lastTickDebug + 10)) { - lastTickDebug = currentTick; - - if (_vm->getDebugger()->isAttached()) - _vm->getDebugger()->onFrame(); - } - - if (!bFastMode) { - uint32 speed = 50; - if (lastTick + speed > currentTick) { - g_system->delayMillis(lastTick + speed - currentTick); - } - } - - lastTick = g_system->getMillis(); } void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 colour) { diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index 36a90c8d4c..6cdedd3d86 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -1181,12 +1181,12 @@ void drawMessage(const gfxEntryStruct *pGfxPtr, int globalX, int globalY, int wi } } -void drawSprite(int objX1, int var_6, cellStruct *currentObjPtr, char *data1, int objY2, int objX2, char *output, char *data2) { +void drawSprite(int objX1, int height, cellStruct *currentObjPtr, uint8 *data1, int objY2, int objX2, uint8 *output, uint8 *data2) { int x = 0; int y = 0; cellStruct* plWork = currentObjPtr; - int workBufferSize = var_6 * (objX1 / 8); + int workBufferSize = height * (objX1 / 8); unsigned char* workBuf = (unsigned char*)malloc(workBufferSize); memcpy(workBuf, data2, workBufferSize); @@ -1204,10 +1204,10 @@ void drawSprite(int objX1, int var_6, cellStruct *currentObjPtr, char *data1, in int maskFrame = params.fileIdx; if (filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_BGMK && filesDatabase[maskFrame].subData.ptrMask) { - drawMask(workBuf, objX1 / 8, var_6, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width / 8, filesDatabase[maskFrame].height, maskX - objX2, maskY - objY2, numPasses++); + drawMask(workBuf, objX1 / 8, height, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width / 8, filesDatabase[maskFrame].height, maskX - objX2, maskY - objY2, numPasses++); } else if (filesDatabase[maskFrame].subData.resourceType == OBJ_TYPE_SPRITE && filesDatabase[maskFrame].subData.ptrMask) { - drawMask(workBuf, objX1 / 8, var_6, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width / 8, filesDatabase[maskFrame].height, maskX - objX2, maskY - objY2, numPasses++); + drawMask(workBuf, objX1 / 8, height, filesDatabase[maskFrame].subData.ptrMask, filesDatabase[maskFrame].width / 8, filesDatabase[maskFrame].height, maskX - objX2, maskY - objY2, numPasses++); } } @@ -1215,7 +1215,7 @@ void drawSprite(int objX1, int var_6, cellStruct *currentObjPtr, char *data1, in plWork = plWork->next; } - for (y = 0; y < var_6; y++) { + for (y = 0; y < height; y++) { for (x = 0; x < (objX1); x++) { uint8 color = (data1[0]); data1++; @@ -1440,7 +1440,7 @@ void mainDraw(int16 param) { spriteHeight = filesDatabase[objZ2].height; // height if (filesDatabase[objZ2].subData.ptr) { - drawSprite(objX1, spriteHeight, currentObjPtr, (char *)filesDatabase[objZ2].subData.ptr, objY2, objX2, (char *)gfxModuleData.pPage10, (char *)filesDatabase[objZ2].subData.ptrMask); + drawSprite(objX1, spriteHeight, currentObjPtr, filesDatabase[objZ2].subData.ptr, objY2, objX2, gfxModuleData.pPage10, filesDatabase[objZ2].subData.ptrMask); } } } diff --git a/engines/cruise/mainDraw.h b/engines/cruise/mainDraw.h index 98ba47c842..84705badb5 100644 --- a/engines/cruise/mainDraw.h +++ b/engines/cruise/mainDraw.h @@ -39,7 +39,7 @@ void pixel(int x, int y, char color); void mainDraw(int16 param); void flipScreen(void); void buildPolyModel(int X, int Y, int scale, char *ptr2, char *destBuffer, char *dataPtr); -void drawSprite(int objX1, int var_6, cellStruct * currentObjPtr, char *data1, int objY2, int objX2, char *output, char *data2); +void drawSprite(int objX1, int height, cellStruct *currentObjPtr, uint8 *data1, int objY2, int objX2, uint8 *output, uint8 *data2); void flipPoly(int fileId, int16 *dataPtr, int scale, char** newFrame, int X, int Y, int *outX, int *outY, int *outScale); void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], unsigned char *dataPtr); bool findPoly(char* dataPtr, int x, int y, int zoom, int mouseX, int mouseY); |