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; bool done = false;
while (!done) { while (!done) {
sharedFpsLimiter.mark();
bool needsRefresh = false; bool needsRefresh = false;
// FIXME: There is minor bug in the interface - pressing H/L to toggle // 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); automapRenderInMapWindow(window, elevation, frmImages[AUTOMAP_FRM_BACKGROUND].getData(), gAutomapFlags);
needsRefresh = false; needsRefresh = false;
} }
renderPresent();
sharedFpsLimiter.throttle();
} }
if (isoWasEnabled) { if (isoWasEnabled) {

View File

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

View File

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

View File

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

View File

@ -3116,7 +3116,12 @@ static void combatAttemptEnd()
void _combat_turn_run() void _combat_turn_run()
{ {
while (_combat_turn_running > 0) { while (_combat_turn_running > 0) {
sharedFpsLimiter.mark();
_process_bk(); _process_bk();
renderPresent();
sharedFpsLimiter.throttle();
} }
} }
@ -3124,6 +3129,8 @@ void _combat_turn_run()
static int _combat_input() static int _combat_input()
{ {
while ((gCombatState & COMBAT_STATE_0x02) != 0) { while ((gCombatState & COMBAT_STATE_0x02) != 0) {
sharedFpsLimiter.mark();
if ((gCombatState & COMBAT_STATE_0x08) != 0) { if ((gCombatState & COMBAT_STATE_0x08) != 0) {
break; break;
} }
@ -3142,9 +3149,8 @@ static int _combat_input()
int keyCode = inputGetInput(); int keyCode = inputGetInput();
if (_action_explode_running()) { if (_action_explode_running()) {
while (_combat_turn_running > 0) { // NOTE: Uninline.
_process_bk(); _combat_turn_run();
}
} }
if (gDude->data.critter.combat.ap <= 0 && _combat_free_move <= 0) { if (gDude->data.critter.combat.ap <= 0 && _combat_free_move <= 0) {
@ -3161,6 +3167,9 @@ static int _combat_input()
_scripts_check_state_in_combat(); _scripts_check_state_in_combat();
gameHandleKey(keyCode, true); gameHandleKey(keyCode, true);
} }
renderPresent();
sharedFpsLimiter.throttle();
} }
int v4 = _game_user_wants_to_quit; int v4 = _game_user_wants_to_quit;
@ -3283,9 +3292,8 @@ static int _combat_turn(Object* a1, bool a2)
} }
} }
while (_combat_turn_running > 0) { // NOTE: Uninline.
_process_bk(); _combat_turn_run();
}
if (a1 == gDude) { if (a1 == gDude) {
gameUiDisable(1); 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* dest = intermediateBuffer + CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT - CREDITS_WINDOW_WIDTH + (CREDITS_WINDOW_WIDTH - v19) / 2;
unsigned char* src = stringBuffer; unsigned char* src = stringBuffer;
for (int index = 0; index < lineHeight; index++) { for (int index = 0; index < lineHeight; index++) {
sharedFpsLimiter.mark();
if (inputGetInput() != -1) { if (inputGetInput() != -1) {
stop = true; stop = true;
break; break;
@ -183,6 +185,9 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
windowRefresh(window); windowRefresh(window);
src += CREDITS_WINDOW_WIDTH; src += CREDITS_WINDOW_WIDTH;
sharedFpsLimiter.throttle();
renderPresent();
} }
if (stop) { if (stop) {
@ -192,6 +197,8 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
if (!stop) { if (!stop) {
for (int index = 0; index < CREDITS_WINDOW_HEIGHT; index++) { for (int index = 0; index < CREDITS_WINDOW_HEIGHT; index++) {
sharedFpsLimiter.mark();
if (inputGetInput() != -1) { if (inputGetInput() != -1) {
break; break;
} }
@ -219,6 +226,9 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
tick = getTicks(); tick = getTicks();
windowRefresh(window); 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; int rc = -1;
while (rc == -1) { while (rc == -1) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput(); int keyCode = inputGetInput();
if (keyCode == 500) { 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) { if (_game_user_wants_to_quit != 0) {
rc = 1; rc = 1;
} }
renderPresent();
sharedFpsLimiter.throttle();
} }
windowDestroy(win); windowDestroy(win);
@ -698,6 +703,8 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
int rc = -1; int rc = -1;
while (rc == -1) { while (rc == -1) {
sharedFpsLimiter.mark();
unsigned int tick = getTicks(); unsigned int tick = getTicks();
int keyCode = inputGetInput(); int keyCode = inputGetInput();
int scrollDirection = FILE_DIALOG_SCROLL_DIRECTION_NONE; 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) { if (keyCode == 505 || keyCode == 503) {
break; break;
} }
renderPresent();
} }
} else { } else {
windowRefresh(win); windowRefresh(win);
@ -881,6 +890,9 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
if (_game_user_wants_to_quit) { if (_game_user_wants_to_quit) {
rc = 1; rc = 1;
} }
renderPresent();
sharedFpsLimiter.throttle();
} }
windowDestroy(win); windowDestroy(win);
@ -1085,6 +1097,8 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
int rc = -1; int rc = -1;
while (rc == -1) { while (rc == -1) {
sharedFpsLimiter.mark();
unsigned int tick = getTicks(); unsigned int tick = getTicks();
int keyCode = inputGetInput(); int keyCode = inputGetInput();
int scrollDirection = FILE_DIALOG_SCROLL_DIRECTION_NONE; 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) { if (key == 505 || key == 503) {
break; break;
} }
renderPresent();
} }
} else { } else {
blinkingCounter -= 1; blinkingCounter -= 1;
@ -1332,6 +1348,9 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
if (_game_user_wants_to_quit != 0) { if (_game_user_wants_to_quit != 0) {
rc = 1; rc = 1;
} }
renderPresent();
sharedFpsLimiter.throttle();
} }
if (rc == 0) { if (rc == 0) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@
#include <SDL.h> #include <SDL.h>
#include "db.h" #include "db.h"
#include "fps_limiter.h"
#include "geometry.h" #include "geometry.h"
#include "window.h" #include "window.h"
@ -31,6 +32,7 @@ extern SDL_Surface* gSdlSurface;
extern SDL_Renderer* gSdlRenderer; extern SDL_Renderer* gSdlRenderer;
extern SDL_Texture* gSdlTexture; extern SDL_Texture* gSdlTexture;
extern SDL_Surface* gSdlTextureSurface; extern SDL_Surface* gSdlTextureSurface;
extern FpsLimiter sharedFpsLimiter;
void mmxSetEnabled(bool a1); void mmxSetEnabled(bool a1);
int _init_mode_320_200(); 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`. // Relative to `scrollOffset`.
int previousSelectedItemIndex = -1; int previousSelectedItemIndex = -1;
while (1) { while (1) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput(); int keyCode = inputGetInput();
int mouseX; int mouseX;
int mouseY; 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); _GNW_win_refresh(window, &itemRect, NULL);
} }
} }
renderPresent();
sharedFpsLimiter.throttle();
} }
windowDestroy(win); windowDestroy(win);
@ -663,6 +668,9 @@ int _win_msg(const char* string, int x, int y, int flags)
windowRefresh(win); windowRefresh(win);
while (inputGetInput() != KEY_ESCAPE) { while (inputGetInput() != KEY_ESCAPE) {
sharedFpsLimiter.mark();
renderPresent();
sharedFpsLimiter.throttle();
} }
windowDestroy(win); 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. // decremented in the loop body when key is not handled.
bool isFirstKey = true; bool isFirstKey = true;
for (; cursorPos <= maxLength; cursorPos++) { for (; cursorPos <= maxLength; cursorPos++) {
sharedFpsLimiter.mark();
int keyCode = inputGetInput(); int keyCode = inputGetInput();
if (keyCode != -1) { if (keyCode != -1) {
if (keyCode == KEY_ESCAPE) { 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 { } else {
cursorPos--; cursorPos--;
} }
renderPresent();
sharedFpsLimiter.throttle();
} }
dest[cursorPos] = '\0'; dest[cursorPos] = '\0';

View File

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