@@ -149,14 +149,28 @@ std::unique_ptr<System> hardReset() {
149149 printf (" Using iso %s\n " , iso.c_str ());
150150 }
151151
152- std::string pathCard1 = config[" memoryCard" ][" 1" ];
153- if (!pathCard1.empty ()) {
154- auto card1 = getFileContents (pathCard1);
155- if (!card1.empty ()) {
156- std::copy_n (std::make_move_iterator (card1.begin ()), card1.size (), sys->controller ->card [0 ]->data .begin ());
157- printf (" [INFO] Loaded memory card 1 from %s\n " , getFilenameExt (pathCard1).c_str ());
152+ auto loadMemoryCard = [&](int slot) {
153+ assert (slot == 0 || slot == 1 );
154+ auto card = sys->controller ->card [slot].get ();
155+
156+ auto configEntry = config[" memoryCard" ][std::to_string (slot + 1 )];
157+ std::string pathCard = configEntry.is_null () ? " " : configEntry;
158+
159+ card->inserted = false ;
160+
161+ if (!pathCard.empty ()) {
162+ auto cardData = getFileContents (pathCard);
163+ if (!cardData.empty ()) {
164+ std::copy_n (std::make_move_iterator (cardData.begin ()), cardData.size (), sys->controller ->card [slot]->data .begin ());
165+ card->inserted = true ;
166+ printf (" [INFO] Loaded memory card %d from %s\n " , slot, getFilenameExt (pathCard).c_str ());
167+ }
158168 }
159- }
169+ };
170+
171+ loadMemoryCard (0 );
172+ loadMemoryCard (1 );
173+
160174 return sys;
161175}
162176
@@ -362,13 +376,16 @@ int main(int argc, char** argv) {
362376 bool frameLimitEnabled = true ;
363377 bool windowFocused = true ;
364378
379+ bool forceRedraw = false ;
380+
365381 SDL_Event event;
366382 while (running && !exitProgram) {
367383 bool newEvent = false ;
368- if (sys->state != System::State::run) {
384+ if (!forceRedraw && sys->state != System::State::run) {
369385 SDL_WaitEvent (&event);
370386 newEvent = true ;
371387 }
388+ forceRedraw = false ;
372389
373390 auto lockMouse = sys->state == System::State::run && inputManager->mouseLocked ;
374391 SDL_SetRelativeMouseMode ((SDL_bool)lockMouse);
@@ -427,6 +444,10 @@ int main(int argc, char** argv) {
427444 opengl.width = event.window .data1 ;
428445 opengl.height = event.window .data2 ;
429446 }
447+
448+ // Crude hack to force next frame after last event received (in paused mode)
449+ // Fixes ImGui window drawing
450+ forceRedraw = true ;
430451 }
431452
432453 if (doHardReset) {
0 commit comments