non-composited mode
[drnoksnes] / platform / sdl.cpp
index a6f1fde..8cab4cc 100644 (file)
@@ -6,7 +6,9 @@
 
 #include "platform.h"
 #include "snes9x.h"
+#include "cpuexec.h"
 #include "gfx.h"
+#include "ppu.h"
 #include "display.h"
 #include "memmap.h"
 #include "soundux.h"
@@ -189,6 +191,7 @@ static inline void pollEvents() {
        }
 }
 
+#if CONF_HGW
 /** Wraps HgwPollEvents, taking care of kPollHgwEveryNFrames */
 static inline void pollHgwEvents() {
        static int frames = 0;
@@ -200,6 +203,7 @@ static inline void pollHgwEvents() {
                frames = 0;
        }
 }
+#endif
 
 int main(int argc, const char ** argv) {       
        // Initialise SDL
@@ -207,9 +211,13 @@ int main(int argc, const char ** argv) {
                DIE("SDL_Init: %s", SDL_GetError());
 
        // Configure snes9x
+#if CONF_HGW
        HgwInit();                                              // Hildon-games-wrapper initialization.
+#endif
        S9xLoadConfig(argc, argv);              // Load config files and parse cmd line.
+#if CONF_HGW
        HgwConfig();                                    // Apply specific hildon-games config.
+#endif
 
        // S9x initialization
        S9xInitDisplay(argc, argv);
@@ -225,7 +233,7 @@ int main(int argc, const char ** argv) {
        // Late initialization
        sprintf(String, "DrNokSnes - %s", Memory.ROMName);
        S9xSetTitle(String);
-       S9xHacksLoadFile(Config.hacksFile[0] ? Config.hacksFile : 0);
+       S9xHacksLoadFile(Config.hacksFile);
        if (!S9xGraphicsInit())
          DIE("S9xGraphicsInit failed");
        S9xAudioOutputEnable(true);
@@ -234,11 +242,14 @@ int main(int argc, const char ** argv) {
                frameSync();                    // May block, or set frameskip to true.
                S9xMainLoop();                  // Does CPU things, renders if needed.
                pollEvents();
+#if CONF_HGW
                pollHgwEvents();
+#endif
        } while (!Config.quitting);
        
        // Deinitialization
        S9xAudioOutputEnable(false);
+       S9xDeinitInputDevices();
        S9xDeinitAudioOutput();
        S9xDeinitDisplay();
 
@@ -250,7 +261,9 @@ int main(int argc, const char ** argv) {
        S9xGraphicsDeinit();
        Memory.Deinit();
        S9xUnloadConfig();
+#if CONF_HGW
        HgwDeinit();
+#endif
 
        SDL_Quit();
 
@@ -262,7 +275,36 @@ void S9xDoAction(unsigned char action)
        if (action & kActionQuit) 
                Config.quitting = true;
 
-       if (action & kActionToggleFullscreen)
+       if (action & kActionToggleFullscreen) {
                S9xVideoToggleFullscreen();
+       }
+
+       if (action & kActionQuickLoad1) {
+               const char * file = S9xGetQuickSaveFilename(1);
+               int result = S9xUnfreezeGame(file);
+               S9xSetInfoString("Load slot %u: %s", 1,
+                       (result ? "done" : "failed"));
+       }
+
+       if (action & kActionQuickSave1) {
+               const char * file = S9xGetQuickSaveFilename(1);
+               int result = S9xFreezeGame(file);
+               S9xSetInfoString("Save slot %u: %s", 1,
+                       (result ? "done" : "failed"));
+       }
+
+       if (action & kActionQuickLoad2) {
+               const char * file = S9xGetQuickSaveFilename(2);
+               int result = S9xUnfreezeGame(file);
+               S9xSetInfoString("Load slot %u: %s", 2,
+                       (result ? "done" : "failed"));
+       }
+
+       if (action & kActionQuickSave2) {
+               const char * file = S9xGetQuickSaveFilename(2);
+               int result = S9xFreezeGame(file);
+               S9xSetInfoString("Save slot %u: %s", 2,
+                       (result ? "done" : "failed"));
+       }
 }