From 7c2a30c5b54e000106e466ba44fcc040746a0c90 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 2 Jan 2013 03:20:47 -0500 Subject: 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. --- source/nds/entry.cpp | 21 ++++++++++++++------- source/nds/gui.c | 2 +- source/nds/gui.h | 2 ++ 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 } -- cgit v1.2.3