UIQ3 bugfixes, SVP drc indirect jumps, stuff
[picodrive.git] / platform / uiq3 / engine / main.cpp
index 03c3e4f..53454c9 100644 (file)
@@ -84,8 +84,8 @@ char *loadrom_fname = NULL;
 int   loadrom_result = 0;\r
 static timeval noticeMsgTime = { 0, 0 };       // when started showing\r
 static CGameAudioMS *gameAudio = 0;                    // the audio object itself\r
-static int reset_timing;\r
-extern int pico_was_reset;\r
+static int reset_timing = 0;\r
+static int pico_was_reset = 0;\r
 extern RSemaphore initSemaphore;\r
 extern RSemaphore pauseSemaphore;\r
 extern RSemaphore loadWaitSemaphore;\r
@@ -170,21 +170,27 @@ static void TargetEpocGameL()
        int thissec = 0, frames_done = 0, frames_shown = 0;\r
        int target_fps, target_frametime;\r
        int i, lim_time;\r
-       //TRawEvent blevent;\r
 \r
        MainInit();\r
        buff[0] = 0;\r
 \r
+       // try to start pico\r
+       DEBUGPRINT(_L("PicoInit()"));\r
        PicoInit();\r
-\r
-       // just to keep the backlight on (works only on UIQ2)\r
-       //blevent.Set(TRawEvent::EActive);\r
+       PicoDrawSetColorFormat(2);\r
+       PicoWriteSound = updateSound;\r
 \r
        // loop?\r
        for(;;)\r
        {\r
                if (gamestate == PGS_Running)\r
                {\r
+                       #ifdef __DEBUG_PRINT\r
+                       TInt mem, cells = User::CountAllocCells();\r
+                       User::AllocSize(mem);\r
+                       DEBUGPRINT(_L("worker: cels=%d, size=%d KB"), cells, mem/1024);\r
+                       #endif\r
+\r
                        // switch context to other thread\r
                        User::After(50000);\r
                        // prepare window and stuff\r
@@ -203,7 +209,7 @@ static void TargetEpocGameL()
                                if(!noticeMsgTime.tv_sec) strcpy(noticeMsg, "NTSC@SYSTEM@/@60@FPS");\r
                        }\r
                        target_frametime = 1000000/target_fps;\r
-                       if(!noticeMsgTime.tv_sec && pico_was_reset)\r
+                       if (!noticeMsgTime.tv_sec && pico_was_reset)\r
                                gettimeofday(&noticeMsgTime, 0);\r
 \r
                        // prepare CD buffer\r
@@ -263,6 +269,7 @@ static void TargetEpocGameL()
                                                frames_shown -= target_fps; if (frames_shown < 0) frames_shown = 0;\r
                                                if (frames_shown > frames_done) frames_shown = frames_done;\r
                                        }\r
+                                       User::ResetInactivityTime();\r
                                }\r
 \r
 \r
@@ -331,14 +338,23 @@ static void TargetEpocGameL()
                        CPolledActiveScheduler::Instance()->Schedule();\r
                        CGameWindow::FreeResources();\r
                }\r
+               else if(gamestate == PGS_Reset)\r
+               {\r
+                       PicoReset();\r
+                       pico_was_reset = 1;\r
+                       gamestate = PGS_Running;\r
+               }\r
                else if(gamestate == PGS_ReloadRom)\r
                {\r
                        loadrom_result = emu_ReloadRom(loadrom_fname);\r
                        pico_was_reset = 1;\r
                        if (loadrom_result)\r
                                gamestate = PGS_Running;\r
-                       else\r
+                       else {\r
+                               extern char menuErrorMsg[];\r
                                gamestate = PGS_Paused;\r
+                               lprintf("%s\n", menuErrorMsg);\r
+                       }\r
                        DEBUGPRINT(_L("done loading ROM, retval=%i"), loadrom_result);\r
                        loadWaitSemaphore.Signal();\r
                        User::After(50000);\r
@@ -363,15 +379,8 @@ static void TargetEpocGameL()
                                User::After(150000);\r
                        }\r
 \r
+                       emu_WriteConfig(0);\r
                        CGameWindow::FreeResources();\r
-               } else if(gamestate == PGS_DebugHeap) {\r
-                       #ifdef __DEBUG_PRINT\r
-                       TInt cells = User::CountAllocCells();\r
-                       TInt mem;\r
-                       User::AllocSize(mem);\r
-                       DEBUGPRINT(_L("worker: cels=%d, size=%d KB"), cells, mem/1024);\r
-                       gamestate = gamestate_next;\r
-                       #endif\r
                } else if(gamestate == PGS_Quit) {\r
                        break;\r
                }\r
@@ -397,11 +406,6 @@ static void MainInit()
 \r
        DumpMemInfo();\r
 \r
-       // try to start pico\r
-       DEBUGPRINT(_L("PicoInit()"));\r
-       PicoDrawSetColorFormat(2);\r
-       PicoWriteSound = updateSound;\r
-\r
 //     if (pauseSemaphore.Handle() <= 0)\r
 //             pauseSemaphore.CreateLocal(0);\r
        DEBUGPRINT(_L("initSemaphore.Signal()"));\r
@@ -776,6 +780,8 @@ void CGameWindow::DoKeys(void)
                        areaActions = 0;\r
                }\r
        }\r
+\r
+       if (movie_data) emu_updateMovie();\r
 }\r
 \r
 \r
@@ -875,8 +881,11 @@ void CGameWindow::RunEvents(TUint32 which)
                sprintf(noticeMsg, "SAVE@SLOT@%i@SELECTED", state_slot);\r
                gettimeofday(&noticeMsgTime, 0);\r
        }\r
-       if(which & 0x0020) if(gameAudio) currentConfig.volume = gameAudio->ChangeVolume(0);\r
-       if(which & 0x0010) if(gameAudio) currentConfig.volume = gameAudio->ChangeVolume(1);\r
+       if ((which & 0x0030) && gameAudio != NULL) {\r
+               currentConfig.volume = gameAudio->ChangeVolume((which & 0x0010) ? 1 : 0);\r
+               sprintf(noticeMsg, "VOL@%02i@", currentConfig.volume);\r
+               gettimeofday(&noticeMsgTime, 0);\r
+       }\r
 }\r
 \r
 \r