aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNebuleon Fumika2013-01-02 03:20:47 -0500
committerNebuleon Fumika2013-01-02 03:20:47 -0500
commit7c2a30c5b54e000106e466ba44fcc040746a0c90 (patch)
treed4070571f07729a39180bdb11ab8b64a895b9bb1
parent378f5a0e3f7321c581da32e9a1764e80afdeae2a (diff)
downloadsnes9x2005-7c2a30c5b54e000106e466ba44fcc040746a0c90.tar.gz
snes9x2005-7c2a30c5b54e000106e466ba44fcc040746a0c90.tar.bz2
snes9x2005-7c2a30c5b54e000106e466ba44fcc040746a0c90.zip
Sleep when the lid is closed AND emulation is running. I don't know to what extent this will save on battery usage, though I do set the DSTWO's CPU to the lowest frequency while it sleeps.
-rw-r--r--source/nds/entry.cpp21
-rw-r--r--source/nds/gui.c2
-rw-r--r--source/nds/gui.h2
3 files changed, 17 insertions, 8 deletions
diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp
index 8c5d8e4..9928985 100644
--- a/source/nds/entry.cpp
+++ b/source/nds/entry.cpp
@@ -126,16 +126,11 @@ bool8 S9xInitUpdate ()
}
-
-bool frame_flip = 0;
-
extern void NDSSFCDrawFrameAntialiased();
bool8 S9xDeinitUpdate (int Width, int Height, bool8 /*sixteen_bit*/)
{
-
-
switch(game_config.graphic)
{
//Up
@@ -175,12 +170,12 @@ bool8 S9xDeinitUpdate (int Width, int Height, bool8 /*sixteen_bit*/)
break;
}
- ds2_flipScreen(UP_SCREEN, UP_SCREEN_UPDATE_METHOD);
+ ds2_flipScreen(UP_SCREEN, UP_SCREEN_UPDATE_METHOD);
// A problem with update method 1 (wait, double buffer) means that, after
// about 15 minutes of play time, the screen starts to half-redraw every
// frame. With update method 0, this is mitigated. (Method 2 is too slow.)
- return (TRUE);
+ return (TRUE);
}
void _makepath (char *path, const char *, const char *dir,
@@ -980,6 +975,18 @@ unsigned int S9xReadJoypad (int which1)
struct key_buf inputdata;
ds2_getrawInput(&inputdata);
+
+ if (inputdata.key & KEY_LID)
+ {
+ ds2_setCPUclocklevel(0);
+ ds2_setSupend();
+ do {
+ ds2_getrawInput(&inputdata);
+ } while (inputdata.key & KEY_LID);
+ ds2_wakeup();
+ set_cpu_clock(clock_speed_number);
+ }
+
if(inputdata.key & KEY_TOUCH) //Active menu
Settings.Paused = 1;
diff --git a/source/nds/gui.c b/source/nds/gui.c
index be44f9a..ed867b4 100644
--- a/source/nds/gui.c
+++ b/source/nds/gui.c
@@ -274,7 +274,7 @@ u32 game_enable_audio = 1;
/******************************************************************************
******************************************************************************/
static u32 menu_cheat_page = 0;
-static u32 clock_speed_number = 5;
+u32 clock_speed_number = 5;
u32 gamepad_config_menu;
/******************************************************************************
diff --git a/source/nds/gui.h b/source/nds/gui.h
index 9ebaf26..5a40979 100644
--- a/source/nds/gui.h
+++ b/source/nds/gui.h
@@ -97,6 +97,7 @@ extern char main_path[MAX_PATH];
extern char rom_path[MAX_PATH];
extern u32 game_enable_audio;
+extern u32 clock_speed_number;
/******************************************************************************
******************************************************************************/
@@ -117,6 +118,7 @@ extern GAME_CONFIG game_config;
extern void gui_init(u32 lang_id);
extern u32 menu(u16 *original_screen);
extern void game_disableAudio();
+extern void set_cpu_clock(u32 num);
#ifdef __cplusplus
}