#include "cpuexec.h"
#include "gfx.h"
#include "ppu.h"
-#include "display.h"
#include "memmap.h"
#include "soundux.h"
#include "hacks.h"
#include "snapshot.h"
-#include "hgw.h"
+#include "screenshot.h"
-#define kPollEveryNFrames 5 //Poll input only every this many frames
-#define kPollHgwEveryNFrames 10 //Poll dbus only every this many frames
+#define kPollEveryNFrames 2 //Poll input only every this many frames
+
+#if CONF_GUI
+#include "osso.h"
+#define kPollOssoEveryNFrames 10 //Poll dbus only every this many frames
+#endif
#define TRACE printf("trace: %s:%s\n", __FILE__, __func__);
#define DIE(format, ...) do { \
printf("%s\n", message);
}
-void S9xLoadSDD1Data()
-{TRACE
- Settings.SDD1Pack=FALSE;
-}
-
void S9xAutoSaveSRAM()
{
Memory.SaveSRAM(S9xGetFilename(FILE_SRAM));
}
/* This comes nearly straight from snes9x */
+/** Calculates framerate, enables frame skip if to low, sleeps if too high, etc. */
static void frameSync() {
+ Uint32 now = SDL_GetTicks();
+
if (Settings.TurboMode)
{
+ // In Turbo mode, just skip as many frames as desired, but don't sleep.
if(Settings.SkipFrames == AUTO_FRAMERATE ||
++IPPU.FrameSkip >= Settings.SkipFrames)
{
++IPPU.SkippedFrames;
IPPU.RenderThisFrame = FALSE;
}
- return;
+
+ // Take care of framerate display
+ if (Settings.DisplayFrameRate) {
+ static Uint32 last = 0;
+ // Update framecounter every second
+ if (now > last && (now - last > 1000)) {
+ IPPU.DisplayedRenderedFrameCount =
+ IPPU.RenderedFramesCount;
+ IPPU.RenderedFramesCount = 0;
+ last = now;
+ }
+ }
} else {
static Uint32 next1 = 0;
- Uint32 now = SDL_GetTicks();
// If there is no known "next" frame, initialize it now
if (next1 == 0) {
// Calculate the timestamp of the next frame.
next1 += Settings.FrameTime;
+
+ // Take care of framerate display
+ if (Settings.DisplayFrameRate) {
+ // Update every theoretical 60 frames
+ if (IPPU.FrameCount % Memory.ROMFramesPerSecond == 0) {
+ IPPU.DisplayedRenderedFrameCount =
+ IPPU.RenderedFramesCount;
+ IPPU.RenderedFramesCount = 0;
+ }
+ }
}
}
static int frames = 0;
if (++frames > kPollEveryNFrames) {
- S9xProcessEvents(FALSE);
+ S9xProcessEvents(false);
frames = 0;
}
}
-#if CONF_HGW
-/** Wraps HgwPollEvents, taking care of kPollHgwEveryNFrames */
-static inline void pollHgwEvents() {
+#if CONF_GUI
+/** Wraps OssoPollEvents, taking care of kPollOssoEveryNFrames */
+static inline void pollOssoEvents() {
static int frames = 0;
- if (!hgwLaunched) return;
+ if (!OssoOk()) return;
- if (++frames > kPollHgwEveryNFrames) {
- HgwPollEvents();
+ if (++frames > kPollOssoEveryNFrames) {
+ OssoPollEvents();
frames = 0;
}
}
#endif
-int main(int argc, const char ** argv) {
+int main(int argc, char ** argv) {
// Initialise SDL
if (SDL_Init(0) < 0)
DIE("SDL_Init: %s", SDL_GetError());
// Configure snes9x
-#if CONF_HGW
- HgwInit(); // Hildon-games-wrapper initialization.
+#if CONF_GUI
+ OssoInit(); // Hildon-games-wrapper initialization.
#endif
S9xLoadConfig(argc, argv); // Load config files and parse cmd line.
-#if CONF_HGW
- HgwConfig(); // Apply specific hildon-games config.
+#if CONF_GUI
+ OssoConfig(); // Apply specific hildon-games config.
#endif
// S9x initialization
frameSync(); // May block, or set frameskip to true.
S9xMainLoop(); // Does CPU things, renders if needed.
pollEvents();
-#if CONF_HGW
- pollHgwEvents();
+#if CONF_GUI
+ pollOssoEvents();
#endif
} while (!Config.quitting);
S9xGraphicsDeinit();
Memory.Deinit();
S9xUnloadConfig();
-#if CONF_HGW
- HgwDeinit();
+#if CONF_GUI
+ OssoDeinit();
#endif
SDL_Quit();
S9xVideoToggleFullscreen();
}
+#if CONF_PNG
+ if (action & kActionScreenshot) {
+ S9xSaveScreenshot(S9xGetFilename(FILE_SCREENSHOT));
+ S9xSetInfoString("Screenshot taken");
+ }
+#endif
+
if (action & kActionQuickLoad1) {
const char * file = S9xGetQuickSaveFilename(1);
int result = S9xUnfreezeGame(file);