mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-18 16:03:05 +00:00
Fixed some method parameters, changed the main loop to a method of the engine class, and moved the frame delay code to the main loop to make the game more responsive to events
svn-id: r39180
This commit is contained in:
parent
63eda8cf3c
commit
979c1e0f6a
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
int playerDontAskQuit = 1;
|
||||
int quitValue2 = 1;
|
||||
int quitValue = 0;
|
||||
|
||||
do {
|
||||
frames++;
|
||||
do {
|
||||
// Handle frame delay
|
||||
uint32 currentTick = g_system->getMillis();
|
||||
|
||||
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();
|
||||
|
||||
manageEvents();
|
||||
|
||||
if (_vm->getDebugger()->isAttached())
|
||||
_vm->getDebugger()->onFrame();
|
||||
}
|
||||
} else {
|
||||
manageEvents();
|
||||
|
||||
if (currentTick >= (lastTickDebug + 10)) {
|
||||
lastTickDebug = currentTick;
|
||||
|
||||
if (_vm->getDebugger()->isAttached())
|
||||
_vm->getDebugger()->onFrame();
|
||||
}
|
||||
}
|
||||
|
||||
lastTick = g_system->getMillis();
|
||||
|
||||
// Handle the next frame
|
||||
|
||||
// frames++;
|
||||
// t_start=Osystem_GetTicks();
|
||||
|
||||
// readKeyboard();
|
||||
playerDontAskQuit = processInput();
|
||||
playerDontAskQuit = processInput();
|
||||
|
||||
if (enableUser) {
|
||||
userEnabled = 1;
|
||||
enableUser = 0;
|
||||
if (enableUser) {
|
||||
userEnabled = 1;
|
||||
enableUser = 0;
|
||||
}
|
||||
|
||||
manageScripts(&relHead);
|
||||
manageScripts(&procHead);
|
||||
|
||||
removeFinishedScripts(&relHead);
|
||||
removeFinishedScripts(&procHead);
|
||||
|
||||
processAnimation();
|
||||
|
||||
if (remdo) {
|
||||
// ASSERT(0);
|
||||
/* main3 = 0;
|
||||
* var24 = 0;
|
||||
* var23 = 0;
|
||||
*
|
||||
* freeStuff2(); */
|
||||
}
|
||||
|
||||
if (cmdLine[0]) {
|
||||
ASSERT(0);
|
||||
/* redrawStrings(0,&cmdLine,8);
|
||||
|
||||
waitForPlayerInput();
|
||||
|
||||
cmdLine = 0; */
|
||||
}
|
||||
|
||||
if (displayOn) {
|
||||
if (doFade)
|
||||
PCFadeFlag = 0;
|
||||
|
||||
/*if (!PCFadeFlag)*/
|
||||
{
|
||||
mainDraw(0);
|
||||
flipScreen();
|
||||
}
|
||||
|
||||
manageScripts(&relHead);
|
||||
manageScripts(&procHead);
|
||||
if (userEnabled && !userWait && !autoTrack) {
|
||||
if (currentActiveMenu == -1) {
|
||||
int16 mouseX;
|
||||
int16 mouseY;
|
||||
int16 mouseButton;
|
||||
|
||||
removeFinishedScripts(&relHead);
|
||||
removeFinishedScripts(&procHead);
|
||||
static int16 oldMouseX = -1;
|
||||
static int16 oldMouseY = -1;
|
||||
|
||||
processAnimation();
|
||||
getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY);
|
||||
|
||||
if (remdo) {
|
||||
// ASSERT(0);
|
||||
/* main3 = 0;
|
||||
* var24 = 0;
|
||||
* var23 = 0;
|
||||
*
|
||||
* freeStuff2(); */
|
||||
}
|
||||
if (mouseX != oldMouseX && mouseY != oldMouseY) {
|
||||
int objectType;
|
||||
int newCursor1;
|
||||
int newCursor2;
|
||||
|
||||
if (cmdLine[0]) {
|
||||
ASSERT(0);
|
||||
/* redrawStrings(0,&cmdLine,8);
|
||||
oldMouseX = mouseX;
|
||||
oldMouseY = mouseY;
|
||||
|
||||
waitForPlayerInput();
|
||||
objectType = findObject(mouseX, mouseY, &newCursor1, &newCursor2);
|
||||
|
||||
cmdLine = 0; */
|
||||
}
|
||||
|
||||
if (displayOn) {
|
||||
if (doFade)
|
||||
PCFadeFlag = 0;
|
||||
|
||||
/*if (!PCFadeFlag)*/
|
||||
{
|
||||
mainDraw(0);
|
||||
flipScreen();
|
||||
}
|
||||
|
||||
if (userEnabled && !userWait && !autoTrack) {
|
||||
if (currentActiveMenu == -1) {
|
||||
int16 mouseX;
|
||||
int16 mouseY;
|
||||
int16 mouseButton;
|
||||
|
||||
static int16 oldMouseX = -1;
|
||||
static int16 oldMouseY = -1;
|
||||
|
||||
getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY);
|
||||
|
||||
if (mouseX != oldMouseX && mouseY != oldMouseY) {
|
||||
int objectType;
|
||||
int newCursor1;
|
||||
int newCursor2;
|
||||
|
||||
oldMouseX = mouseX;
|
||||
oldMouseY = mouseY;
|
||||
|
||||
objectType = findObject(mouseX, mouseY, &newCursor1, &newCursor2);
|
||||
|
||||
if (objectType == 9) {
|
||||
changeCursor(CURSOR_EXIT);
|
||||
} else if (objectType != -1) {
|
||||
changeCursor(CURSOR_MAGNIFYING_GLASS);
|
||||
} else {
|
||||
changeCursor(CURSOR_WALK);
|
||||
}
|
||||
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 (userWait) {
|
||||
int16 mouseButton = 0;
|
||||
checkInput(&mouseButton);
|
||||
|
||||
while (!mouseButton) {
|
||||
manageScripts(&relHead);
|
||||
manageScripts(&procHead);
|
||||
|
||||
removeFinishedScripts(&relHead);
|
||||
removeFinishedScripts(&procHead);
|
||||
|
||||
processAnimation();
|
||||
|
||||
flip();
|
||||
|
||||
// not exactly this
|
||||
manageEvents();
|
||||
|
||||
checkInput(&mouseButton);
|
||||
}
|
||||
|
||||
changeScriptParamInList(-1, -1, &procHead, 9999, 0);
|
||||
changeScriptParamInList(-1, -1, &relHead, 9999, 0);
|
||||
userWait = 0;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
char* pText = getText(autoMsg, autoOvl);
|
||||
|
||||
if (strlen(pText))
|
||||
userWait = 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
if (userWait) {
|
||||
int16 mouseButton = 0;
|
||||
checkInput(&mouseButton);
|
||||
|
||||
}
|
||||
while (!mouseButton) {
|
||||
manageScripts(&relHead);
|
||||
manageScripts(&procHead);
|
||||
|
||||
int oldmain(int argc, char *argv[]) {
|
||||
printf("Cruise for a corpse recode\n");
|
||||
removeFinishedScripts(&relHead);
|
||||
removeFinishedScripts(&procHead);
|
||||
|
||||
// OSystemInit();
|
||||
// osystem = new OSystem;
|
||||
processAnimation();
|
||||
|
||||
printf("Osystem Initialized\n");
|
||||
flip();
|
||||
|
||||
printf("Initializing engine...\n");
|
||||
// not exactly this
|
||||
manageEvents();
|
||||
|
||||
PCFadeFlag = 0;
|
||||
checkInput(&mouseButton);
|
||||
}
|
||||
|
||||
//lowLevelInit();
|
||||
changeScriptParamInList(-1, -1, &procHead, 9999, 0);
|
||||
changeScriptParamInList(-1, -1, &relHead, 9999, 0);
|
||||
userWait = 0;
|
||||
}
|
||||
|
||||
// arg parser stuff
|
||||
// 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);
|
||||
|
||||
workBuffer = (uint8 *) mallocAndZero(8192);
|
||||
char* pText = getText(autoMsg, autoOvl);
|
||||
|
||||
/*volVar1 = 0;
|
||||
* fileData1 = 0; */
|
||||
if (strlen(pText))
|
||||
userWait = 1;
|
||||
}
|
||||
|
||||
/*PAL_fileHandle = -1; */
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// video init stuff
|
||||
manageEvents();
|
||||
|
||||
initSystem();
|
||||
|
||||
// another bit of video init
|
||||
|
||||
if (!readVolCnf()) {
|
||||
printf("Fatal: unable to load vol.cnf !\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
printf("Entering main loop...\n");
|
||||
mainLoop();
|
||||
|
||||
//freeStuff();
|
||||
|
||||
//freePtr(workBuffer);
|
||||
|
||||
return (0);
|
||||
} while (!playerDontAskQuit && quitValue2 && quitValue != 7);
|
||||
}
|
||||
|
||||
void *mallocAndZero(int32 size) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user