From: Shamus Hammons Date: Tue, 1 Apr 2014 13:47:16 +0000 (-0500) Subject: Fixed stupid lockup bug on exit when emulation paused/off. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e6f6a0ca5f0f2ee31df2209b7c0f36c84ae887a;p=apple2 Fixed stupid lockup bug on exit when emulation paused/off. --- diff --git a/Makefile b/Makefile index 8f36aec..7c67256 100644 --- a/Makefile +++ b/Makefile @@ -198,7 +198,7 @@ obj/%.o: src/gui/%.cpp $(TARGET)$(EXESUFFIX): $(OBJS) @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m" - $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + @$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) # strip --strip-all vj$(EXESUFFIX) # upx -9 vj$(EXESUFFIX) diff --git a/src/apple2.cpp b/src/apple2.cpp index 9a659b2..eaa0ea5 100644 --- a/src/apple2.cpp +++ b/src/apple2.cpp @@ -117,7 +117,7 @@ static SDL_Thread * cpuThread = NULL; static SDL_cond * cpuCond = NULL; static SDL_sem * mainSem = NULL; static bool cpuFinished = false; -static bool cpuSleep = false; +//static bool cpuSleep = false; // NB: Apple //e Manual sez 6502 is running @ 1,022,727 Hz @@ -141,14 +141,14 @@ int CPUThreadFunc(void * data) do { // This is never set to true anywhere... - if (cpuSleep) - SDL_CondWait(cpuCond, cpuMutex); +// if (cpuSleep) +// SDL_CondWait(cpuCond, cpuMutex); // decrement mainSem... #ifdef THREAD_DEBUGGING WriteLog("CPU: SDL_SemWait(mainSem);\n"); #endif -SDL_SemWait(mainSem); + SDL_SemWait(mainSem); // There are exactly 800 slices of 21.333 cycles per frame, so it works out // evenly. @@ -385,26 +385,29 @@ cpuFinished = true; //USE A CONDITIONAL!!! OF COURSE!!!!!!11!11!11!!!1! //Nope, use a semaphore... WriteLog("Main: SDL_SemWait(mainSem);\n"); -SDL_SemWait(mainSem);//should lock until CPU thread is waiting... + // Only do this if NOT in power off/emulation paused mode! + if (!pauseMode) + // Should lock until CPU thread is waiting... + SDL_SemWait(mainSem); #endif WriteLog("Main: SDL_CondSignal(cpuCond);//thread is probably asleep, wake it up\n"); -SDL_CondSignal(cpuCond);//thread is probably asleep, wake it up + SDL_CondSignal(cpuCond);//thread is probably asleep, wake it up WriteLog("Main: SDL_WaitThread(cpuThread, NULL);\n"); -SDL_WaitThread(cpuThread, NULL); + SDL_WaitThread(cpuThread, NULL); //nowok:SDL_WaitThread(CPUThreadFunc, NULL); WriteLog("Main: SDL_DestroyCond(cpuCond);\n"); -SDL_DestroyCond(cpuCond); - -SDL_DestroySemaphore(mainSem); + SDL_DestroyCond(cpuCond); + SDL_DestroySemaphore(mainSem); if (settings.autoStateSaving) { // Save state here... SaveApple2State(settings.autoStatePath); } -floppyDrive.SaveImage(0); -floppyDrive.SaveImage(1); + + floppyDrive.SaveImage(0); + floppyDrive.SaveImage(1); SoundDone(); VideoDone();