Decouple drawing and rendering (#165)

This commit is contained in:
Alexander Batalov 2022-10-08 00:54:27 +03:00 committed by GitHub
parent ddae4df4ab
commit a4105d5826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 446 additions and 27 deletions

View File

@ -397,6 +397,8 @@ void automapShow(bool isInGame, bool isUsingScanner)
bool done = false;
while (!done) {
sharedFpsLimiter.mark();
bool needsRefresh = false;
// FIXME: There is minor bug in the interface - pressing H/L to toggle
@ -477,6 +479,9 @@ void automapShow(bool isInGame, bool isUsingScanner)
automapRenderInMapWindow(window, elevation, frmImages[AUTOMAP_FRM_BACKGROUND].getData(), gAutomapFlags);
needsRefresh = false;
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (isoWasEnabled) {

View File

@ -817,6 +817,8 @@ int characterEditorShow(bool isCreationMode)
int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
_frame_time = getTicks();
int keyCode = inputGetInput();
@ -1166,6 +1168,9 @@ int characterEditorShow(bool isCreationMode)
}
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (rc == 0) {
@ -1929,6 +1934,8 @@ static int _get_input_str(int win, int cancelKeyCode, char* text, int maxLength,
int rc = 1;
while (rc == 1) {
sharedFpsLimiter.mark();
_frame_time = getTicks();
int keyCode = inputGetInput();
@ -1980,6 +1987,9 @@ static int _get_input_str(int win, int cancelKeyCode, char* text, int maxLength,
windowRefresh(win);
while (getTicksSince(_frame_time) < 1000 / 24) { }
renderPresent();
sharedFpsLimiter.throttle();
}
if (rc == 0 || nameLength > 0) {
@ -2263,6 +2273,7 @@ static void characterEditorDrawBigNumber(int x, int y, int flags, int value, int
onesBufferPtr,
windowWidth);
windowRefreshRect(windowHandle, &rect);
renderPresent();
while (getTicksSince(_frame_time) < BIG_NUM_ANIMATION_DELAY)
;
}
@ -2274,6 +2285,7 @@ static void characterEditorDrawBigNumber(int x, int y, int flags, int value, int
onesBufferPtr,
windowWidth);
windowRefreshRect(windowHandle, &rect);
renderPresent();
if (previousValue / 10 != tens) {
_frame_time = getTicks();
@ -2284,6 +2296,7 @@ static void characterEditorDrawBigNumber(int x, int y, int flags, int value, int
tensBufferPtr,
windowWidth);
windowRefreshRect(windowHandle, &rect);
renderPresent();
while (getTicksSince(_frame_time) < BIG_NUM_ANIMATION_DELAY)
;
}
@ -2295,6 +2308,7 @@ static void characterEditorDrawBigNumber(int x, int y, int flags, int value, int
tensBufferPtr,
windowWidth);
windowRefreshRect(windowHandle, &rect);
renderPresent();
} else {
blitBufferToBuffer(numbersGraphicBufferPtr + BIG_NUM_WIDTH * tens,
BIG_NUM_WIDTH,
@ -3399,6 +3413,8 @@ static int characterEditorEditAge()
}
while (true) {
sharedFpsLimiter.mark();
_frame_time = getTicks();
change = 0;
flags = 0;
@ -3462,6 +3478,8 @@ static int characterEditorEditAge()
_repFtime = 4;
while (true) {
sharedFpsLimiter.mark();
_frame_time = getTicks();
v33++;
@ -3516,6 +3534,9 @@ static int characterEditorEditAge()
if (keyCode == 503 || keyCode == 504 || _game_user_wants_to_quit != 0) {
break;
}
renderPresent();
sharedFpsLimiter.throttle();
}
} else {
windowRefresh(win);
@ -3523,6 +3544,9 @@ static int characterEditorEditAge()
while (getTicksSince(_frame_time) < 1000 / 24)
;
}
renderPresent();
sharedFpsLimiter.throttle();
}
critterSetBaseStat(gDude, STAT_AGE, savedAge);
@ -3627,6 +3651,8 @@ static void characterEditorEditGender()
_win_set_button_rest_state(btns[savedGender], 1, 0);
while (true) {
sharedFpsLimiter.mark();
_frame_time = getTicks();
int eventCode = inputGetInput();
@ -3668,6 +3694,9 @@ static void characterEditorEditGender()
while (getTicksSince(_frame_time) < 41)
;
renderPresent();
sharedFpsLimiter.throttle();
}
characterEditorDrawGender();
@ -3692,6 +3721,8 @@ static void characterEditorAdjustPrimaryStat(int eventCode)
bool cont = true;
do {
sharedFpsLimiter.mark();
_frame_time = getTicks();
if (v11 <= 19.2) {
v11++;
@ -3747,6 +3778,9 @@ static void characterEditorAdjustPrimaryStat(int eventCode)
while (getTicksSince(_frame_time) < 1000 / 24) {
}
}
renderPresent();
sharedFpsLimiter.throttle();
} while (inputGetInput() != 518 && cont);
characterEditorDrawCard();
@ -3854,6 +3888,8 @@ static int characterEditorShowOptions()
int rc = 0;
while (rc == 0) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (_game_user_wants_to_quit != 0) {
@ -4141,6 +4177,9 @@ static int characterEditorShowOptions()
}
windowRefresh(win);
renderPresent();
sharedFpsLimiter.throttle();
}
windowDestroy(win);
@ -5161,6 +5200,8 @@ static void characterEditorHandleAdjustSkillButtonPressed(int keyCode)
int repeatDelay = 0;
for (;;) {
sharedFpsLimiter.mark();
_frame_time = getTicks();
if (repeatDelay <= dbl_5018F0) {
repeatDelay++;
@ -5246,6 +5287,8 @@ static void characterEditorHandleAdjustSkillButtonPressed(int keyCode)
int keyCode = inputGetInput();
if (keyCode != 522 && keyCode != 524 && rc != -1) {
renderPresent();
sharedFpsLimiter.throttle();
continue;
}
}
@ -5954,6 +5997,8 @@ static int perkDialogHandleInput(int count, void (*refreshProc)())
int rc = 0;
while (rc == 0) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
int v19 = 0;
@ -6067,6 +6112,8 @@ static int perkDialogHandleInput(int count, void (*refreshProc)())
gPerkDialogPreviousCurrentLine = -2;
do {
sharedFpsLimiter.mark();
_frame_time = getTicks();
if (v19 <= dbl_5019BE) {
v19++;
@ -6099,6 +6146,9 @@ static int perkDialogHandleInput(int count, void (*refreshProc)())
while (getTicksSince(_frame_time) < 1000 / _repFtime) {
}
}
renderPresent();
sharedFpsLimiter.throttle();
} while (inputGetInput() != 574);
break;
@ -6108,6 +6158,8 @@ static int perkDialogHandleInput(int count, void (*refreshProc)())
if (count > 11) {
do {
sharedFpsLimiter.mark();
_frame_time = getTicks();
if (v19 <= dbl_5019BE) {
v19++;
@ -6141,9 +6193,14 @@ static int perkDialogHandleInput(int count, void (*refreshProc)())
while (getTicksSince(_frame_time) < 1000 / _repFtime) {
}
}
renderPresent();
sharedFpsLimiter.throttle();
} while (inputGetInput() != 575);
} else {
do {
sharedFpsLimiter.mark();
_frame_time = getTicks();
if (v19 <= dbl_5019BE) {
v19++;
@ -6172,6 +6229,9 @@ static int perkDialogHandleInput(int count, void (*refreshProc)())
while (getTicksSince(_frame_time) < 1000 / _repFtime) {
}
}
renderPresent();
sharedFpsLimiter.throttle();
} while (inputGetInput() != 575);
}
break;
@ -6199,6 +6259,9 @@ static int perkDialogHandleInput(int count, void (*refreshProc)())
break;
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
return rc;

View File

@ -163,6 +163,8 @@ int characterSelectorOpen()
int rc = 0;
bool done = false;
while (!done) {
sharedFpsLimiter.mark();
if (_game_user_wants_to_quit != 0) {
break;
}
@ -237,6 +239,9 @@ int characterSelectorOpen()
characterSelectorWindowRefresh();
break;
}
renderPresent();
sharedFpsLimiter.throttle();
}
paletteFadeTo(gPaletteBlack);

View File

@ -209,9 +209,11 @@ void colorPaletteFadeBetween(unsigned char* oldPalette, unsigned char* newPalett
}
_setSystemPalette(palette);
renderPresent();
}
_setSystemPalette(newPalette);
renderPresent();
}
// 0x4C73D4

View File

@ -3116,7 +3116,12 @@ static void combatAttemptEnd()
void _combat_turn_run()
{
while (_combat_turn_running > 0) {
sharedFpsLimiter.mark();
_process_bk();
renderPresent();
sharedFpsLimiter.throttle();
}
}
@ -3124,6 +3129,8 @@ void _combat_turn_run()
static int _combat_input()
{
while ((gCombatState & COMBAT_STATE_0x02) != 0) {
sharedFpsLimiter.mark();
if ((gCombatState & COMBAT_STATE_0x08) != 0) {
break;
}
@ -3142,9 +3149,8 @@ static int _combat_input()
int keyCode = inputGetInput();
if (_action_explode_running()) {
while (_combat_turn_running > 0) {
_process_bk();
}
// NOTE: Uninline.
_combat_turn_run();
}
if (gDude->data.critter.combat.ap <= 0 && _combat_free_move <= 0) {
@ -3161,6 +3167,9 @@ static int _combat_input()
_scripts_check_state_in_combat();
gameHandleKey(keyCode, true);
}
renderPresent();
sharedFpsLimiter.throttle();
}
int v4 = _game_user_wants_to_quit;
@ -3283,9 +3292,8 @@ static int _combat_turn(Object* a1, bool a2)
}
}
while (_combat_turn_running > 0) {
_process_bk();
}
// NOTE: Uninline.
_combat_turn_run();
if (a1 == gDude) {
gameUiDisable(1);

View File

@ -153,6 +153,8 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
unsigned char* dest = intermediateBuffer + CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT - CREDITS_WINDOW_WIDTH + (CREDITS_WINDOW_WIDTH - v19) / 2;
unsigned char* src = stringBuffer;
for (int index = 0; index < lineHeight; index++) {
sharedFpsLimiter.mark();
if (inputGetInput() != -1) {
stop = true;
break;
@ -183,6 +185,9 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
windowRefresh(window);
src += CREDITS_WINDOW_WIDTH;
sharedFpsLimiter.throttle();
renderPresent();
}
if (stop) {
@ -192,6 +197,8 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
if (!stop) {
for (int index = 0; index < CREDITS_WINDOW_HEIGHT; index++) {
sharedFpsLimiter.mark();
if (inputGetInput() != -1) {
break;
}
@ -219,6 +226,9 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
tick = getTicks();
windowRefresh(window);
sharedFpsLimiter.throttle();
renderPresent();
}
}

View File

@ -498,6 +498,8 @@ int showDialogBox(const char* title, const char** body, int bodyLength, int x, i
int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode == 500) {
@ -520,6 +522,9 @@ int showDialogBox(const char* title, const char** body, int bodyLength, int x, i
if (_game_user_wants_to_quit != 0) {
rc = 1;
}
renderPresent();
sharedFpsLimiter.throttle();
}
windowDestroy(win);
@ -698,6 +703,8 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
unsigned int tick = getTicks();
int keyCode = inputGetInput();
int scrollDirection = FILE_DIALOG_SCROLL_DIRECTION_NONE;
@ -864,6 +871,8 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
if (keyCode == 505 || keyCode == 503) {
break;
}
renderPresent();
}
} else {
windowRefresh(win);
@ -881,6 +890,9 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
if (_game_user_wants_to_quit) {
rc = 1;
}
renderPresent();
sharedFpsLimiter.throttle();
}
windowDestroy(win);
@ -1085,6 +1097,8 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
unsigned int tick = getTicks();
int keyCode = inputGetInput();
int scrollDirection = FILE_DIALOG_SCROLL_DIRECTION_NONE;
@ -1305,6 +1319,8 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
if (key == 505 || key == 503) {
break;
}
renderPresent();
}
} else {
blinkingCounter -= 1;
@ -1332,6 +1348,9 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
if (_game_user_wants_to_quit != 0) {
rc = 1;
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (rc == 0) {

View File

@ -394,6 +394,8 @@ int elevatorSelectLevel(int elevator, int* mapPtr, int* elevationPtr, int* tileP
bool done = false;
int keyCode;
while (!done) {
sharedFpsLimiter.mark();
keyCode = inputGetInput();
if (keyCode == KEY_ESCAPE) {
done = true;
@ -410,6 +412,9 @@ int elevatorSelectLevel(int elevator, int* mapPtr, int* elevationPtr, int* tileP
done = true;
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (keyCode != KEY_ESCAPE) {
@ -434,6 +439,8 @@ int elevatorSelectLevel(int elevator, int* mapPtr, int* elevationPtr, int* tileP
float v41 = (float)keyCode * v42;
float v44 = (float)(*elevationPtr) * v42;
do {
sharedFpsLimiter.mark();
unsigned int tick = getTicks();
v44 += v43;
blitBufferToBuffer(
@ -448,6 +455,9 @@ int elevatorSelectLevel(int elevator, int* mapPtr, int* elevationPtr, int* tileP
while (getTicksSince(tick) < delay) {
}
renderPresent();
sharedFpsLimiter.throttle();
} while ((v43 <= 0.0 || v44 < v41) && (v43 > 0.0 || v44 > v41));
inputPauseForTocks(200);

View File

@ -356,6 +356,8 @@ static void endgameEndingRenderPanningScene(int direction, const char* narratorF
unsigned int since = 0;
while (start != end) {
sharedFpsLimiter.mark();
int v12 = 640 - v32;
// TODO: Complex math, setup scene in debugger.
@ -413,6 +415,9 @@ static void endgameEndingRenderPanningScene(int direction, const char* narratorF
endgameEndingVoiceOverFree();
break;
}
renderPresent();
sharedFpsLimiter.throttle();
}
tickersEnable();
@ -424,7 +429,12 @@ static void endgameEndingRenderPanningScene(int direction, const char* narratorF
}
while (mouseGetEvent() != 0) {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
}
}
@ -465,6 +475,8 @@ static void endgameEndingRenderStaticScene(int fid, const char* narratorFileName
int keyCode;
while (true) {
sharedFpsLimiter.mark();
keyCode = inputGetInput();
if (keyCode != -1) {
break;
@ -486,6 +498,9 @@ static void endgameEndingRenderStaticScene(int fid, const char* narratorFileName
endgameEndingRefreshSubtitles();
windowRefresh(gEndgameEndingSlideshowWindow);
soundContinueAll();
renderPresent();
sharedFpsLimiter.throttle();
}
tickersEnable();
@ -502,7 +517,12 @@ static void endgameEndingRenderStaticScene(int fid, const char* narratorFileName
paletteFadeTo(gPaletteBlack);
while (mouseGetEvent() != 0) {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
}
}

View File

@ -1148,10 +1148,18 @@ static void showHelp()
paletteSetEntries(_cmap);
while (inputGetInput() == -1 && _game_user_wants_to_quit == 0) {
sharedFpsLimiter.mark();
renderPresent();
sharedFpsLimiter.throttle();
}
while (mouseGetEvent() != 0) {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
}
paletteSetEntries(gPaletteBlack);

View File

@ -1442,6 +1442,8 @@ int gameDialogShowReview()
gameDialogReviewWindowUpdate(win, v1);
while (true) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode == 17 || keyCode == 24 || keyCode == 324) {
showQuitConfirmationDialog();
@ -1467,6 +1469,9 @@ int gameDialogShowReview()
v1 = gGameDialogReviewEntriesLength - 1;
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (gameDialogReviewWindowFree(&win) == -1) {
@ -1845,6 +1850,8 @@ int _gdProcess()
int pageOffsets[10];
pageOffsets[0] = 0;
for (;;) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
convertMouseWheelToArrowKey(&keyCode);
@ -1967,6 +1974,9 @@ int _gdProcess()
}
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
_gdReenterLevel -= 1;
@ -2506,11 +2516,16 @@ void gameDialogWaitForFidgetToComplete()
debugPrint("Waiting for fidget to complete...\n");
while (artGetFrameCount(gGameDialogFidgetFrm) > gGameDialogFidgetFrmCurrentFrame) {
sharedFpsLimiter.mark();
if (getTicksSince(gGameDialogFidgetLastUpdateTimestamp) >= gGameDialogFidgetUpdateDelay) {
gameDialogRenderTalkingHead(gGameDialogFidgetFrm, gGameDialogFidgetFrmCurrentFrame);
gGameDialogFidgetLastUpdateTimestamp = getTicks();
gGameDialogFidgetFrmCurrentFrame++;
}
renderPresent();
sharedFpsLimiter.throttle();
}
gGameDialogFidgetFrmCurrentFrame = 0;
@ -2889,6 +2904,8 @@ void _gdialog_scroll_subwin(int win, int a2, unsigned char* a3, unsigned char* a
}
for (; v18 >= 0; v18--) {
sharedFpsLimiter.mark();
soundContinueAll();
blitBufferToBuffer(a3,
GAME_DIALOG_WINDOW_WIDTH,
@ -2904,6 +2921,9 @@ void _gdialog_scroll_subwin(int win, int a2, unsigned char* a3, unsigned char* a
tick = getTicks();
while (getTicksSince(tick) < 33) {
}
renderPresent();
sharedFpsLimiter.throttle();
}
} else {
rect.right = GAME_DIALOG_WINDOW_WIDTH - 1;
@ -2912,6 +2932,8 @@ void _gdialog_scroll_subwin(int win, int a2, unsigned char* a3, unsigned char* a
rect.top = 0;
for (int index = a6 / 10; index > 0; index--) {
sharedFpsLimiter.mark();
soundContinueAll();
blitBufferToBuffer(a5,
@ -2939,6 +2961,9 @@ void _gdialog_scroll_subwin(int win, int a2, unsigned char* a3, unsigned char* a
tick = getTicks();
while (getTicksSince(tick) < 33) {
}
renderPresent();
sharedFpsLimiter.throttle();
}
}
}
@ -3624,6 +3649,8 @@ void partyMemberControlWindowHandleEvents()
bool done = false;
while (!done) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode != -1) {
if (keyCode == KEY_CTRL_Q || keyCode == KEY_CTRL_X || keyCode == KEY_F10) {
@ -3691,6 +3718,9 @@ void partyMemberControlWindowHandleEvents()
}
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
}
@ -3864,6 +3894,8 @@ void partyMemberCustomizationWindowHandleEvents()
{
bool done = false;
while (!done) {
sharedFpsLimiter.mark();
unsigned int keyCode = inputGetInput();
if (keyCode != -1) {
if (keyCode == KEY_CTRL_Q || keyCode == KEY_CTRL_X || keyCode == KEY_F10) {
@ -3883,6 +3915,9 @@ void partyMemberCustomizationWindowHandleEvents()
_dialogue_state = 10;
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
}
@ -4066,6 +4101,8 @@ int _gdCustomSelect(int a1)
bool done = false;
unsigned int v53 = 0;
while (!done) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode == -1) {
continue;
@ -4148,6 +4185,9 @@ int _gdCustomSelect(int a1)
}
v53 = timestamp;
}
renderPresent();
sharedFpsLimiter.throttle();
}
windowDestroy(win);

View File

@ -1136,6 +1136,8 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
int v33 = mouseY;
int actionIndex = 0;
while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_UP) == 0) {
sharedFpsLimiter.mark();
inputGetInput();
if (_game_user_wants_to_quit != 0) {
@ -1158,6 +1160,9 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
}
v33 = v47;
}
renderPresent();
sharedFpsLimiter.throttle();
}
isoEnable();
@ -2450,4 +2455,10 @@ static void customMouseModeFrmsInit()
configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_USE_REPAIR_FRM_KEY, &(gGameMouseModeFrmIds[GAME_MOUSE_MODE_USE_REPAIR]));
}
void gameMouseRefreshImmediately()
{
gameMouseRefresh();
renderPresent();
}
} // namespace fallout

View File

@ -101,6 +101,8 @@ int gameMouseHighlightActionMenuItemAtIndex(int menuItemIndex);
void gameMouseLoadItemHighlight();
void _gmouse_remove_item_outline(Object* object);
void gameMouseRefreshImmediately();
} // namespace fallout
#endif /* GAME_MOUSE_H */

View File

@ -1358,6 +1358,8 @@ void interfaceBarEndButtonsShow(bool animated)
int time = 0;
int frame = 0;
while (frame < frameCount) {
sharedFpsLimiter.mark();
if (getTicksSince(time) >= delay) {
unsigned char* src = artGetFrameData(art, frame, 0);
if (src != NULL) {
@ -1369,6 +1371,9 @@ void interfaceBarEndButtonsShow(bool animated)
frame++;
}
gameMouseRefresh();
renderPresent();
sharedFpsLimiter.throttle();
}
} else {
unsigned char* src = artGetFrameData(art, frameCount - 1, 0);
@ -1412,6 +1417,8 @@ void interfaceBarEndButtonsHide(bool animated)
int frame = artGetFrameCount(art);
while (frame != 0) {
sharedFpsLimiter.mark();
if (getTicksSince(time) >= delay) {
unsigned char* src = artGetFrameData(art, frame - 1, 0);
unsigned char* dest = gInterfaceWindowBuffer + 640 * 38 + 580;
@ -1424,6 +1431,9 @@ void interfaceBarEndButtonsHide(bool animated)
frame--;
}
gameMouseRefresh();
renderPresent();
sharedFpsLimiter.throttle();
}
} else {
unsigned char* dest = gInterfaceWindowBuffer + 640 * 38 + 580;
@ -1803,11 +1813,16 @@ static void interfaceBarSwapHandsAnimatePutAwayTakeOutSequence(int previousWeapo
gameMouseSetCursor(MOUSE_CURSOR_WAIT_WATCH);
while (gInterfaceBarSwapHandsInProgress) {
sharedFpsLimiter.mark();
if (_game_user_wants_to_quit) {
break;
}
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
}
gameMouseSetCursor(MOUSE_CURSOR_NONE);
@ -2044,6 +2059,7 @@ static void interfaceRenderCounter(int x, int y, int previousValue, int value, i
blitBufferToBuffer(upSrc, 9, 17, 360, onesDest, 640);
_mouse_info();
gameMouseRefresh();
renderPresent();
inputBlockForTocks(delay);
windowRefreshRect(gInterfaceBarWindow, &numbersRect);
@ -2053,6 +2069,7 @@ static void interfaceRenderCounter(int x, int y, int previousValue, int value, i
blitBufferToBuffer(upSrc, 9, 17, 360, tensDest, 640);
_mouse_info();
gameMouseRefresh();
renderPresent();
inputBlockForTocks(delay);
windowRefreshRect(gInterfaceBarWindow, &numbersRect);
@ -2062,6 +2079,7 @@ static void interfaceRenderCounter(int x, int y, int previousValue, int value, i
blitBufferToBuffer(upSrc, 9, 17, 360, hundredsDest, 640);
_mouse_info();
gameMouseRefresh();
renderPresent();
inputBlockForTocks(delay);
windowRefreshRect(gInterfaceBarWindow, &numbersRect);
@ -2074,11 +2092,13 @@ static void interfaceRenderCounter(int x, int y, int previousValue, int value, i
blitBufferToBuffer(downSrc, 9, 17, 360, hundredsDest, 640);
_mouse_info();
gameMouseRefresh();
renderPresent();
inputBlockForTocks(delay);
windowRefreshRect(gInterfaceBarWindow, &numbersRect);
}
blitBufferToBuffer(downSrc, 9, 17, 360, tensDest, 640);
renderPresent();
inputBlockForTocks(delay);
windowRefreshRect(gInterfaceBarWindow, &numbersRect);
}
@ -2086,6 +2106,7 @@ static void interfaceRenderCounter(int x, int y, int previousValue, int value, i
blitBufferToBuffer(downSrc, 9, 17, 360, onesDest, 640);
_mouse_info();
gameMouseRefresh();
renderPresent();
inputBlockForTocks(delay);
windowRefreshRect(gInterfaceBarWindow, &numbersRect);
@ -2098,6 +2119,7 @@ static void interfaceRenderCounter(int x, int y, int previousValue, int value, i
blitBufferToBuffer(previousValue >= 0 ? plusSrc : minusSrc, 6, 17, 360, signDest, 640);
_mouse_info();
gameMouseRefresh();
renderPresent();
inputBlockForTocks(delay);
windowRefreshRect(gInterfaceBarWindow, &numbersRect);
}

View File

@ -588,6 +588,8 @@ void inventoryOpen()
inventorySetCursor(INVENTORY_WINDOW_CURSOR_HAND);
for (;;) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
// SFALL: Close with 'I'.
@ -683,6 +685,9 @@ void inventoryOpen()
}
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
_inven_dude = _stack[0];
@ -2351,8 +2356,13 @@ static void _inven_pickup(int keyCode, int a2)
}
do {
sharedFpsLimiter.mark();
inputGetInput();
_display_body(-1, INVENTORY_WINDOW_TYPE_NORMAL);
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
@ -2616,6 +2626,8 @@ void inventoryOpenUseItemOn(Object* a1)
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_USE_ITEM_ON);
inventorySetCursor(INVENTORY_WINDOW_CURSOR_HAND);
for (;;) {
sharedFpsLimiter.mark();
if (_game_user_wants_to_quit != 0) {
break;
}
@ -2726,6 +2738,9 @@ void inventoryOpenUseItemOn(Object* a1)
if (keyCode == KEY_ESCAPE) {
break;
}
renderPresent();
sharedFpsLimiter.throttle();
}
_exit_inventory(isoWasEnabled);
@ -3687,6 +3702,8 @@ static void inventoryWindowOpenContextMenu(int keyCode, int inventoryWindowType)
int mouseState;
do {
sharedFpsLimiter.mark();
inputGetInput();
if (inventoryWindowType == INVENTORY_WINDOW_TYPE_NORMAL) {
@ -3703,6 +3720,9 @@ static void inventoryWindowOpenContextMenu(int keyCode, int inventoryWindowType)
windowRefresh(gInventoryWindow);
return;
}
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseState & MOUSE_EVENT_LEFT_BUTTON_DOWN_REPEAT) != MOUSE_EVENT_LEFT_BUTTON_DOWN_REPEAT);
inventorySetCursor(INVENTORY_WINDOW_CURSOR_BLANK);
@ -3807,6 +3827,8 @@ static void inventoryWindowOpenContextMenu(int keyCode, int inventoryWindowType)
int menuItemIndex = 0;
int previousMouseY = y;
while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_UP) == 0) {
sharedFpsLimiter.mark();
inputGetInput();
if (inventoryWindowType == INVENTORY_WINDOW_TYPE_NORMAL) {
@ -3828,6 +3850,9 @@ static void inventoryWindowOpenContextMenu(int keyCode, int inventoryWindowType)
windowRefreshRect(gInventoryWindow, &rect);
previousMouseY = y;
}
renderPresent();
sharedFpsLimiter.throttle();
}
buttonDestroy(btn);
@ -4199,6 +4224,8 @@ int inventoryOpenLooting(Object* a1, Object* a2)
int stealingXp = 0;
int stealingXpBonus = 10;
for (;;) {
sharedFpsLimiter.mark();
if (_game_user_wants_to_quit != 0) {
break;
}
@ -4387,6 +4414,9 @@ int inventoryOpenLooting(Object* a1, Object* a2)
if (keyCode == KEY_ESCAPE) {
break;
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (critterCount != 0) {
@ -4540,7 +4570,12 @@ static int _move_inventory(Object* a1, int a2, Object* a3, bool a4)
}
do {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
@ -4755,7 +4790,12 @@ static void _barter_move_inventory(Object* a1, int quantity, int a3, int a4, Obj
}
do {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
@ -4837,7 +4877,12 @@ static void _barter_move_from_table_inventory(Object* a1, int quantity, int a3,
}
do {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);
if (itemInventoryFrmImage.isLocked()) {
@ -5047,6 +5092,8 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
int keyCode = -1;
for (;;) {
sharedFpsLimiter.mark();
if (keyCode == KEY_ESCAPE || _game_user_wants_to_quit != 0) {
break;
}
@ -5269,6 +5316,9 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
}
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
itemMoveAll(a1a, a2);
@ -5537,6 +5587,8 @@ static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int ma
bool v5 = false;
for (;;) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode == KEY_ESCAPE) {
inventoryQuantityWindowFree(inventoryWindowType);
@ -5565,6 +5617,8 @@ static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int ma
unsigned int delay = 100;
while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0) {
sharedFpsLimiter.mark();
if (value < max) {
value++;
}
@ -5576,6 +5630,9 @@ static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int ma
delay--;
inputPauseForTocks(delay);
}
renderPresent();
sharedFpsLimiter.throttle();
}
} else {
if (value < max) {
@ -5598,6 +5655,8 @@ static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int ma
unsigned int delay = 100;
while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0) {
sharedFpsLimiter.mark();
if (value > min) {
value--;
}
@ -5609,6 +5668,9 @@ static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int ma
delay--;
inputPauseForTocks(delay);
}
renderPresent();
sharedFpsLimiter.throttle();
}
} else {
if (value > min) {
@ -5648,6 +5710,9 @@ static int inventoryQuantitySelect(int inventoryWindowType, Object* item, int ma
continue;
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
inventoryQuantityWindowFree(inventoryWindowType);

View File

@ -478,6 +478,8 @@ int lsgSaveGame(int mode)
int rc = -1;
int doubleClickSlot = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
unsigned int tick = getTicks();
int keyCode = inputGetInput();
bool selectionChanged = false;
@ -590,6 +592,8 @@ int lsgSaveGame(int mode)
bool isScrolling = false;
int scrollCounter = 0;
do {
sharedFpsLimiter.mark();
unsigned int start = getTicks();
scrollCounter += 1;
@ -650,6 +654,9 @@ int lsgSaveGame(int mode)
}
keyCode = inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while (keyCode != 505 && keyCode != 503);
} else {
if (selectionChanged) {
@ -783,6 +790,9 @@ int lsgSaveGame(int mode)
}
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
@ -867,6 +877,7 @@ int lsgLoadGame(int mode)
unsigned char* windowBuffer = windowGetBuffer(window);
bufferFill(windowBuffer, LS_WINDOW_WIDTH, LS_WINDOW_HEIGHT, LS_WINDOW_WIDTH, _colorTable[0]);
windowRefresh(window);
renderPresent();
}
if (lsgLoadGameInSlot(_slot_cursor) != -1) {
@ -929,6 +940,7 @@ int lsgLoadGame(int mode)
if (_GetSlotList() == -1) {
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
windowRefresh(gLoadSaveWindow);
renderPresent();
soundPlayFile("iisxxxx1");
strcpy(_str0, getmsg(&gLoadSaveMessageList, &gLoadSaveMessageListItem, 106));
strcpy(_str1, getmsg(&gLoadSaveMessageList, &gLoadSaveMessageListItem, 107));
@ -963,11 +975,14 @@ int lsgLoadGame(int mode)
_ShowSlotList(2);
_DrawInfoBox(_slot_cursor);
windowRefresh(gLoadSaveWindow);
renderPresent();
_dbleclkcntr = 24;
int rc = -1;
int doubleClickSlot = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
unsigned int time = getTicks();
int keyCode = inputGetInput();
bool selectionChanged = false;
@ -1073,6 +1088,8 @@ int lsgLoadGame(int mode)
bool isScrolling = false;
int scrollCounter = 0;
do {
sharedFpsLimiter.mark();
unsigned int start = getTicks();
scrollCounter += 1;
@ -1138,6 +1155,9 @@ int lsgLoadGame(int mode)
}
keyCode = inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while (keyCode != 505 && keyCode != 503);
} else {
if (selectionChanged) {
@ -1215,6 +1235,9 @@ int lsgLoadGame(int mode)
break;
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
lsgWindowFree(mode == LOAD_SAVE_MODE_FROM_MAIN_MENU
@ -2184,6 +2207,7 @@ static int _get_input_str2(int win, int doneKeyCode, int cancelKeyCode, char* de
fontDrawText(windowBuffer + windowWidth * y + x, text, windowWidth, windowWidth, textColor);
windowRefresh(win);
renderPresent();
int blinkCounter = 3;
bool blink = false;
@ -2192,6 +2216,8 @@ static int _get_input_str2(int win, int doneKeyCode, int cancelKeyCode, char* de
int rc = 1;
while (rc == 1) {
sharedFpsLimiter.mark();
int tick = getTicks();
int keyCode = inputGetInput();
@ -2247,6 +2273,9 @@ static int _get_input_str2(int win, int doneKeyCode, int cancelKeyCode, char* de
while (getTicksSince(tick) < 1000 / 24) {
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (rc == 0) {

View File

@ -14,7 +14,6 @@
#include "debug.h"
#include "draw.h"
#include "endgame.h"
#include "fps_limiter.h"
#include "game.h"
#include "game_mouse.h"
#include "game_movie.h"
@ -80,7 +79,7 @@ static void main_exit_system();
static int _main_load_new(char* fname);
static int main_loadgame_new();
static void main_unload_new();
static void mainLoop(FpsLimiter& fpsLimiter);
static void mainLoop();
static void _main_selfrun_exit();
static void _main_selfrun_record();
static void _main_selfrun_play();
@ -93,7 +92,7 @@ static void mainMenuWindowFree();
static void mainMenuWindowHide(bool animate);
static void mainMenuWindowUnhide(bool animate);
static int _main_menu_is_enabled();
static int mainMenuWindowHandleEvents(FpsLimiter& fpsLimiter);
static int mainMenuWindowHandleEvents();
static int main_menu_fatal_error();
static void main_menu_play_sound(const char* fileName);
@ -193,8 +192,6 @@ int falloutMain(int argc, char** argv)
gameMoviePlay(MOVIE_CREDITS, 0);
}
FpsLimiter fpsLimiter;
if (mainMenuWindowInit() == 0) {
bool done = false;
while (!done) {
@ -203,7 +200,7 @@ int falloutMain(int argc, char** argv)
mainMenuWindowUnhide(1);
mouseShowCursor();
int mainMenuRc = mainMenuWindowHandleEvents(fpsLimiter);
int mainMenuRc = mainMenuWindowHandleEvents();
mouseHideCursor();
switch (mainMenuRc) {
@ -231,7 +228,7 @@ int falloutMain(int argc, char** argv)
_main_load_new(mapNameCopy);
free(mapNameCopy);
mainLoop(fpsLimiter);
mainLoop();
paletteFadeTo(gPaletteWhite);
// NOTE: Uninline.
@ -266,7 +263,7 @@ int falloutMain(int argc, char** argv)
} else if (loadGameRc != 0) {
windowDestroy(win);
win = -1;
mainLoop(fpsLimiter);
mainLoop();
}
paletteFadeTo(gPaletteWhite);
if (win != -1) {
@ -429,7 +426,7 @@ static void main_unload_new()
}
// 0x480E48
static void mainLoop(FpsLimiter& fpsLimiter)
static void mainLoop()
{
bool cursorWasHidden = cursorIsHidden();
if (cursorWasHidden) {
@ -441,7 +438,7 @@ static void mainLoop(FpsLimiter& fpsLimiter)
scriptsEnable();
while (_game_user_wants_to_quit == 0) {
fpsLimiter.mark();
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
gameHandleKey(keyCode, false);
@ -460,7 +457,8 @@ static void mainLoop(FpsLimiter& fpsLimiter)
_game_user_wants_to_quit = 2;
}
fpsLimiter.throttle();
renderPresent();
sharedFpsLimiter.throttle();
}
scriptsDisable();
@ -614,7 +612,12 @@ static void showDeath()
}
while (mouseGetEvent() != 0) {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
}
keyboardReset();
@ -668,7 +671,12 @@ static void showDeath()
unsigned int time = getTicks();
int keyCode;
do {
sharedFpsLimiter.mark();
keyCode = inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
} while (keyCode == -1 && !_main_death_voiceover_done && getTicksSince(time) < delay);
speechSetEndCallback(NULL);
@ -676,7 +684,12 @@ static void showDeath()
speechDelete();
while (mouseGetEvent() != 0) {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
}
if (keyCode == -1) {
@ -999,7 +1012,7 @@ static int _main_menu_is_enabled()
}
// 0x481AEC
static int mainMenuWindowHandleEvents(FpsLimiter& fpsLimiter)
static int mainMenuWindowHandleEvents()
{
_in_main_menu = true;
@ -1012,7 +1025,7 @@ static int mainMenuWindowHandleEvents(FpsLimiter& fpsLimiter)
int rc = -1;
while (rc == -1) {
fpsLimiter.mark();
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
@ -1065,7 +1078,8 @@ static int mainMenuWindowHandleEvents(FpsLimiter& fpsLimiter)
}
}
fpsLimiter.throttle();
renderPresent();
sharedFpsLimiter.throttle();
}
if (oldCursorIsHidden) {

View File

@ -802,7 +802,7 @@ static int mapLoad(File* stream)
int savedMouseCursorId = gameMouseGetCursor();
gameMouseSetCursor(MOUSE_CURSOR_WAIT_PLANET);
fileSetReadProgressHandler(gameMouseRefresh, 32768);
fileSetReadProgressHandler(gameMouseRefreshImmediately, 32768);
tileDisable();
int rc = 0;

View File

@ -471,6 +471,8 @@ int showOptionsWithInitialKeyCode(int initialKeyCode)
int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
bool showPreferences = false;
@ -541,6 +543,9 @@ int showOptionsWithInitialKeyCode(int initialKeyCode)
break;
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
optionsWindowFree();
@ -823,6 +828,8 @@ int showPause(bool a1)
bool done = false;
while (!done) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
switch (keyCode) {
case KEY_PLUS:
@ -842,6 +849,9 @@ int showPause(bool a1)
done = true;
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (!a1) {
@ -1698,6 +1708,8 @@ static int _do_prefscreen()
int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
int eventCode = inputGetInput();
switch (eventCode) {
@ -1737,6 +1749,9 @@ static int _do_prefscreen()
}
break;
}
renderPresent();
sharedFpsLimiter.throttle();
}
preferencesWindowFree();
@ -1895,6 +1910,8 @@ static void _DoThing(int eventCode)
int sfxVolumeExample = 0;
int speechVolumeExample = 0;
while (true) {
sharedFpsLimiter.mark();
inputGetInput();
int tick = getTicks();
@ -1905,6 +1922,7 @@ static void _DoThing(int eventCode)
soundPlayFile("ib1lu1x1");
_UpdateThing(preferenceIndex);
windowRefresh(gPreferencesWindow);
renderPresent();
_changed = true;
return;
}
@ -2034,6 +2052,9 @@ static void _DoThing(int eventCode)
while (getTicksSince(tick) < 35)
;
renderPresent();
sharedFpsLimiter.throttle();
}
} else if (preferenceIndex == 19) {
gPreferencesPlayerSpeedup1 ^= 1;

View File

@ -415,6 +415,8 @@ int pipboyOpen(int intent)
gPipboyLastEventTimestamp = getTicks();
while (true) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (intent == PIPBOY_OPEN_INTENT_REST) {
@ -469,6 +471,9 @@ int pipboyOpen(int intent)
if (_proc_bail_flag) {
break;
}
renderPresent();
sharedFpsLimiter.throttle();
}
pipboyWindowFree();
@ -1960,6 +1965,8 @@ static bool pipboyRest(int hours, int minutes, int duration)
double v4 = v3 * 20.0;
int v5 = 0;
for (int v5 = 0; v5 < (int)v4; v5++) {
sharedFpsLimiter.mark();
if (rc) {
break;
}
@ -1995,6 +2002,9 @@ static bool pipboyRest(int hours, int minutes, int duration)
while (getTicksSince(start) < 50) {
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (!rc) {
@ -2017,6 +2027,8 @@ static bool pipboyRest(int hours, int minutes, int duration)
double v7 = (v2 - v3) * 20.0;
for (int hour = 0; hour < (int)v7; hour++) {
sharedFpsLimiter.mark();
if (rc) {
break;
}
@ -2061,6 +2073,9 @@ static bool pipboyRest(int hours, int minutes, int duration)
while (getTicksSince(start) < 50) {
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (!rc) {
@ -2234,6 +2249,8 @@ static int pipboyRenderScreensaver()
int v31 = 50;
while (true) {
sharedFpsLimiter.mark();
unsigned int time = getTicks();
mouseGetPositionInWindow(gPipboyWindow, &gPipboyMouseX, &gPipboyMouseY);
@ -2352,6 +2369,9 @@ static int pipboyRenderScreensaver()
while (getTicksSince(time) < 50) {
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
blitBufferToBuffer(buf,

View File

@ -90,14 +90,24 @@ void selfrunPlaybackLoop(SelfrunData* selfrunData)
}
while (gSelfrunState == SELFRUN_STATE_PLAYING) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode != selfrunData->stopKeyCode) {
gameHandleKey(keyCode, false);
}
renderPresent();
sharedFpsLimiter.throttle();
}
while (mouseGetEvent() != 0) {
sharedFpsLimiter.mark();
inputGetInput();
renderPresent();
sharedFpsLimiter.throttle();
}
if (cursorWasHidden) {
@ -156,6 +166,8 @@ void selfrunRecordingLoop(SelfrunData* selfrunData)
bool done = false;
while (!done) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode == selfrunData->stopKeyCode) {
vcrStop();
@ -164,6 +176,9 @@ void selfrunRecordingLoop(SelfrunData* selfrunData)
} else {
gameHandleKey(keyCode, false);
}
renderPresent();
sharedFpsLimiter.throttle();
}
}
gSelfrunState = SELFRUN_STATE_TURNED_OFF;

View File

@ -116,6 +116,8 @@ int skilldexOpen()
int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
// SFALL: Close with 'S'.
@ -127,6 +129,9 @@ int skilldexOpen()
} else if (keyCode >= 501 && keyCode <= 509) {
rc = keyCode - 500;
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (rc != 0) {

View File

@ -85,6 +85,9 @@ SDL_Renderer* gSdlRenderer = NULL;
SDL_Texture* gSdlTexture = NULL;
SDL_Surface* gSdlTextureSurface = NULL;
// TODO: Remove once migration to update-render cycle is completed.
FpsLimiter sharedFpsLimiter;
// 0x4CACD0
void mmxSetEnabled(bool a1)
{
@ -357,7 +360,6 @@ void directDrawSetPaletteInRange(unsigned char* palette, int start, int count)
SDL_SetPaletteColors(gSdlSurface->format->palette, colors, start, count);
SDL_BlitSurface(gSdlSurface, NULL, gSdlTextureSurface, NULL);
renderPresent();
} else {
for (int index = start; index < start + count; index++) {
unsigned short r = palette[0] << 2;
@ -401,7 +403,6 @@ void directDrawSetPalette(unsigned char* palette)
SDL_SetPaletteColors(gSdlSurface->format->palette, colors, 0, 256);
SDL_BlitSurface(gSdlSurface, NULL, gSdlTextureSurface, NULL);
renderPresent();
} else {
for (int index = 0; index < 256; index++) {
unsigned short r = palette[index * 3] << 2;
@ -479,7 +480,6 @@ void _GNW95_ShowRect(unsigned char* src, int srcPitch, int a3, int srcX, int src
destRect.x = destX;
destRect.y = destY;
SDL_BlitSurface(gSdlSurface, &srcRect, gSdlTextureSurface, &destRect);
renderPresent();
}
// 0x4CB93C
@ -516,7 +516,6 @@ void _GNW95_MouseShowRect16(unsigned char* src, int srcPitch, int a3, int srcX,
destRect.x = destX;
destRect.y = destY;
SDL_BlitSurface(gSdlSurface, &srcRect, gSdlTextureSurface, &destRect);
renderPresent();
}
// 0x4CBA44
@ -561,7 +560,6 @@ void _GNW95_MouseShowTransRect16(unsigned char* src, int srcPitch, int a3, int s
destRect.x = destX;
destRect.y = destY;
SDL_BlitSurface(gSdlSurface, &srcRect, gSdlTextureSurface, &destRect);
renderPresent();
}
// Clears drawing surface.
@ -584,7 +582,6 @@ void _GNW95_zero_vid_mem()
SDL_UnlockSurface(gSdlSurface);
SDL_BlitSurface(gSdlSurface, NULL, gSdlTextureSurface, NULL);
renderPresent();
}
int screenGetWidth()

View File

@ -4,6 +4,7 @@
#include <SDL.h>
#include "db.h"
#include "fps_limiter.h"
#include "geometry.h"
#include "window.h"
@ -31,6 +32,7 @@ extern SDL_Surface* gSdlSurface;
extern SDL_Renderer* gSdlRenderer;
extern SDL_Texture* gSdlTexture;
extern SDL_Surface* gSdlTextureSurface;
extern FpsLimiter sharedFpsLimiter;
void mmxSetEnabled(bool a1);
int _init_mode_320_200();

View File

@ -324,6 +324,8 @@ int _win_list_select_at(const char* title, char** items, int itemsLength, ListSe
// Relative to `scrollOffset`.
int previousSelectedItemIndex = -1;
while (1) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
int mouseX;
int mouseY;
@ -527,6 +529,9 @@ int _win_list_select_at(const char* title, char** items, int itemsLength, ListSe
_GNW_win_refresh(window, &itemRect, NULL);
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
windowDestroy(win);
@ -663,6 +668,9 @@ int _win_msg(const char* string, int x, int y, int flags)
windowRefresh(win);
while (inputGetInput() != KEY_ESCAPE) {
sharedFpsLimiter.mark();
renderPresent();
sharedFpsLimiter.throttle();
}
windowDestroy(win);
@ -1025,6 +1033,8 @@ int _win_input_str(int win, char* dest, int maxLength, int x, int y, int textCol
// decremented in the loop body when key is not handled.
bool isFirstKey = true;
for (; cursorPos <= maxLength; cursorPos++) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode != -1) {
if (keyCode == KEY_ESCAPE) {
@ -1099,6 +1109,9 @@ int _win_input_str(int win, char* dest, int maxLength, int x, int y, int textCol
} else {
cursorPos--;
}
renderPresent();
sharedFpsLimiter.throttle();
}
dest[cursorPos] = '\0';

View File

@ -2949,6 +2949,8 @@ static int wmWorldMapFunc(int a1)
int rc = 0;
for (;;) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
unsigned int tick = getTicks();
@ -3074,6 +3076,7 @@ static int wmWorldMapFunc(int a1)
if (!wmGenData.isWalking && !wmGenData.mousePressed && abs(wmGenData.worldPosX - v4) < 5 && abs(wmGenData.worldPosY - v5) < 5) {
wmGenData.mousePressed = true;
wmInterfaceRefresh();
renderPresent();
}
} else {
continue;
@ -3204,6 +3207,9 @@ static int wmWorldMapFunc(int a1)
if (map != -1 || v25 == -1) {
break;
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (wmInterfaceExit() == -1) {
@ -3308,6 +3314,7 @@ static int wmRndEncounterOccurred()
return -1;
}
renderPresent();
inputBlockForTocks(200);
}
@ -3387,6 +3394,7 @@ static int wmRndEncounterOccurred()
return -1;
}
renderPresent();
inputBlockForTocks(200);
}
@ -5717,6 +5725,8 @@ static int wmTownMapFunc(int* mapIdxPtr)
CityInfo* city = &(wmAreaInfoList[wmGenData.currentAreaId]);
for (;;) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput();
if (keyCode == KEY_CTRL_Q || keyCode == KEY_CTRL_X || keyCode == KEY_F10) {
showQuitConfirmationDialog();
@ -5791,6 +5801,9 @@ static int wmTownMapFunc(int* mapIdxPtr)
}
}
}
renderPresent();
sharedFpsLimiter.throttle();
}
if (wmTownMapExit() == -1) {