]> Shamusworld >> Repos - apple2/commitdiff
Fixed Apple power state to pause CPU thread immediately.
authorShamus Hammons <jlhamm@acm.org>
Mon, 31 Mar 2014 18:59:37 +0000 (13:59 -0500)
committerShamus Hammons <jlhamm@acm.org>
Mon, 31 Mar 2014 18:59:37 +0000 (13:59 -0500)
src/apple2.cpp
src/apple2.h
src/applevideo.cpp

index 9afc35ff980a86eaa591a801461482ccc008fa00..9a659b2e7fdfeffc0ba3458ee30db8535a9103b6 100644 (file)
@@ -140,6 +140,7 @@ int CPUThreadFunc(void * data)
 
        do
        {
+// This is never set to true anywhere...
                if (cpuSleep)
                        SDL_CondWait(cpuCond, cpuMutex);
 
@@ -151,31 +152,6 @@ SDL_SemWait(mainSem);
 
 // There are exactly 800 slices of 21.333 cycles per frame, so it works out
 // evenly.
-#if 0
-               uint32_t cycles = 17066;
-#ifdef CPU_THREAD_OVERFLOW_COMPENSATION
-// ODD! It's closer *without* this overflow compensation. ??? WHY ???
-               overflow += 0.666666667;
-
-               if (overflow > 1.0)
-               {
-                       overflow -= 1.0;
-                       cycles++;
-               }
-#endif
-
-#ifdef THREAD_DEBUGGING
-WriteLog("CPU: Execute65C02(&mainCPU, cycles);\n");
-#endif
-               Execute65C02(&mainCPU, cycles); // how much? 1 frame (after 1 s, off by 40 cycles) not any more--it's off by as much as 240 now!
-
-               // Adjust the sound routine's last cycle toggled time base
-               // Also, since we're finished executing, .clock is now valid
-#ifdef THREAD_DEBUGGING
-WriteLog("CPU: AdjustLastToggleCycles(mainCPU.clock);\n");
-#endif
-               AdjustLastToggleCycles(mainCPU.clock);
-#else
 #ifdef THREAD_DEBUGGING
 WriteLog("CPU: Execute65C02(&mainCPU, cycles);\n");
 #endif
@@ -196,7 +172,6 @@ WriteLog("CPU: Execute65C02(&mainCPU, cycles);\n");
                        // Dunno if this is correct (seems to be close enough)...
                        vbl = (i < 670 ? true : false);
                }
-#endif
 
 #ifdef THREAD_DEBUGGING
 WriteLog("CPU: SDL_mutexP(cpuMutex);\n");
@@ -847,14 +822,16 @@ static void FrameCallback(void)
                {
                        pauseMode = false;
                        SoundResume();
-                       ResetApple2State();
+                       // Unlock the CPU thread...
+                       SDL_SemPost(mainSem);
                }
                else
                {
                        pauseMode = true;
+                       // Should lock until CPU thread is waiting...
+                       SDL_SemWait(mainSem);
                        SoundPause();
-//NOPE                 SDL_SemWait(mainSem);//should lock until CPU thread is waiting...
-//                     ResetApple2State();
+                       ResetApple2State();
                }
 
                powerStateChangeRequested = false;
@@ -902,7 +879,7 @@ if (counter == 60)
        uint64_t cpuCycles = GetCurrentV65C02Clock();
        uint32_t cyclesBurned = (uint32_t)(cpuCycles - lastCPUCycles);
        WriteLog("FrameCallback: used %i cycles\n", cyclesBurned);
-       lastCPUCycles = cpuCycles;
+       lastCPUCycles = cpuCycles
 #endif
 
 //let's wait, then signal...
index 0b60d624f6fd033d23b81ec5aa014b4b385251cb..17a1f0175f192cbbbee6ca8ab44289a674dd65d9 100644 (file)
@@ -15,7 +15,6 @@ void SetPowerState(void);
 
 extern uint8_t ram[0x10000], rom[0x10000];             // RAM & ROM pointers
 extern uint8_t ram2[0x10000];                                  // Auxillary RAM
-//extern uint8_t diskRom[0x100];                                       // Floppy disk ROM
 extern uint8_t appleType;
 extern FloppyDrive floppyDrive;
 extern uint8_t lastKeyPressed;
index e7672cff7c2291bc44801354d0e421c8cc676514..f9a8b0da06e1a5d19010370376934037c78a34f9 100644 (file)
@@ -35,6 +35,7 @@
 #include "video.h"
 #include "charset.h"
 #include "gui/font14pt.h"
+#include "gui/gui.h"
 
 /* Reference: Technote tn-iigs-063 "Master Color Values"
 
@@ -869,43 +870,50 @@ static void RenderDHiRes(uint16_t toLine/*= 192*/)
 
 void RenderVideoFrame(void)
 {
-       if (textMode)
+       if (GUI::powerOnState == true)
        {
-               if (!col80Mode)
-                       Render40ColumnText();
+               if (textMode)
+               {
+                       if (!col80Mode)
+                               Render40ColumnText();
+                       else
+                               Render80ColumnText();
+               }
                else
-                       Render80ColumnText();
-       }
-       else
-       {
-               if (mixedMode)
                {
-                       if (hiRes)
+                       if (mixedMode)
                        {
-                               RenderHiRes(160);
-                               Render40ColumnTextLine(20);
-                               Render40ColumnTextLine(21);
-                               Render40ColumnTextLine(22);
-                               Render40ColumnTextLine(23);
+                               if (hiRes)
+                               {
+                                       RenderHiRes(160);
+                                       Render40ColumnTextLine(20);
+                                       Render40ColumnTextLine(21);
+                                       Render40ColumnTextLine(22);
+                                       Render40ColumnTextLine(23);
+                               }
+                               else
+                               {
+                                       RenderLoRes(20);
+                                       Render40ColumnTextLine(20);
+                                       Render40ColumnTextLine(21);
+                                       Render40ColumnTextLine(22);
+                                       Render40ColumnTextLine(23);
+                               }
                        }
                        else
                        {
-                               RenderLoRes(20);
-                               Render40ColumnTextLine(20);
-                               Render40ColumnTextLine(21);
-                               Render40ColumnTextLine(22);
-                               Render40ColumnTextLine(23);
+                               if (dhires)
+                                       RenderDHiRes();
+                               else if (hiRes)
+                                       RenderHiRes();
+                               else
+                                       RenderLoRes();
                        }
                }
-               else
-               {
-                       if (dhires)
-                               RenderDHiRes();
-                       else if (hiRes)
-                               RenderHiRes();
-                       else
-                               RenderLoRes();
-               }
+       }
+       else
+       {
+               memset(scrBuffer, 0, VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT * sizeof(uint32_t));
        }
 
        if (msgTicks)