diff options
-rw-r--r-- | source/nds/ds2_main.c | 5 | ||||
-rw-r--r-- | source/nds/entry.cpp | 6 | ||||
-rw-r--r-- | source/nds/gui.c | 54 | ||||
-rw-r--r-- | source/nds/gui.h | 4 |
4 files changed, 42 insertions, 27 deletions
diff --git a/source/nds/ds2_main.c b/source/nds/ds2_main.c index f9b29d5..af81df3 100644 --- a/source/nds/ds2_main.c +++ b/source/nds/ds2_main.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "port.h" + #include <stdio.h> #include "console.h" #include "fs_api.h" @@ -25,6 +27,7 @@ #include "ds2_timer.h" #include "ds2_malloc.h" #include "ds2sound.h" +#include "gui.h" #define BLACK_COLOR RGB15(0, 0, 0) #define WHITE_COLOR RGB15(31, 31, 31) @@ -47,7 +50,7 @@ void ddump_mem(unsigned char* addr, unsigned int len) void ds2_main(void) { int err; - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); //Initial video and audio and other input and output err = ds2io_initb(DS2_BUFFER_SIZE, SND_SAMPLE_RATE, 0, 0); if(err) goto _failure; diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp index 986ecce..5d79b64 100644 --- a/source/nds/entry.cpp +++ b/source/nds/entry.cpp @@ -86,7 +86,7 @@ void S9xParseDisplayArg (char **argv, int &ind, int) void S9xExit () { - ds2_setCPUclocklevel(13); // Crank it up to exit quickly + HighFrequencyCPU(); // Crank it up to exit quickly if(Settings.SPC7110) (*CleanUp7110)(); @@ -1125,7 +1125,7 @@ unsigned int S9xReadJoypad (int which1) if (inputdata.key & KEY_LID) { - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); ds2_setSupend(); do { ds2_getrawInput(&inputdata); @@ -1136,7 +1136,7 @@ unsigned int S9xReadJoypad (int which1) // screen's backlight. mdelay(100); // needed to avoid ds2_setBacklight crashing ds2_setBacklight(2); - set_cpu_clock(clock_speed_number); + GameFrequencyCPU(); } u32 HotkeyReturnToMenu = game_config.HotkeyReturnToMenu != 0 ? game_config.HotkeyReturnToMenu : emu_config.HotkeyReturnToMenu; diff --git a/source/nds/gui.c b/source/nds/gui.c index 4f808b4..3942672 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1651,12 +1651,22 @@ int save_state(char* file, void* screen) return 0; } -void set_cpu_clock(u32 num) +void LowFrequencyCPU() { - u32 clock_speed_table[6] = {6, 9, 10, 11, 12, 13}; //240, 300, 336, 360, 384, 394 + ds2_setCPUclocklevel(0); // 60 MHz +} + +void HighFrequencyCPU() +{ + ds2_setCPUclocklevel(13); // 396 MHz +} + +void GameFrequencyCPU() +{ + u32 clock_speed_table[6] = {6, 9, 10, 11, 12, 13}; //240, 300, 336, 360, 384, 396 - if(num <= 5) - ds2_setCPUclocklevel(clock_speed_table[num]); + if(clock_speed_number <= 5) + ds2_setCPULevel(clock_speed_table[clock_speed_number]); } void savefast_int(void) @@ -1761,7 +1771,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) void menu_exit() { - ds2_setCPUclocklevel(13); // Crank it up, leave quickly + HighFrequencyCPU(); // Crank it up, leave quickly if(gamepak_name[0] != 0) { game_config.clock_speed_number = clock_speed_number; @@ -1794,9 +1804,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int load_result = load_gamepak(line_buffer); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if(load_result == -1) { first_load = 1; @@ -1862,9 +1872,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int load_result = load_gamepak(args[1]); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if(load_result == -1) { @@ -2074,9 +2084,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_SAVED_STATE_CREATING]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int flag = save_state(tmp_filename, (void*)screen); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); //clear message draw_message(down_screen_addr, NULL, 28, 31, 227, 96, 0); if(flag < 0) @@ -2143,9 +2153,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); draw_string_vcenter(up_screen_addr, 36, 75, 190, COLOR_MSSG, msg[MSG_PROGRESS_SAVED_STATE_LOADING]); - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int flag = load_state(tmp_filename); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if(0 == flag) { return_value = 1; @@ -2160,9 +2170,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } else //load screen snapshot { - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); load_game_stat_snapshot(tmp_filename); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); } } else @@ -2732,7 +2742,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { if(gui_action == CURSOR_LEFT || gui_action == CURSOR_RIGHT) { - ds2_setCPUclocklevel(13); // crank it up + HighFrequencyCPU(); // crank it up if(bg_screenp != NULL) { bg_screenp_color = COLOR16(43, 11, 11); @@ -2757,7 +2767,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } save_emu_config_file(); - ds2_setCPUclocklevel(0); // and back down + LowFrequencyCPU(); // and back down wait_Allkey_release(0); } } @@ -3497,9 +3507,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) ext_pos = emu_config.latest_file[current_option_num -1]; - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int load_result = load_gamepak(ext_pos); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if(load_result == -1) { first_load = 1; @@ -3572,7 +3582,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) //----------------------------------------------------------------------------// // Menu Start - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if (!FirstInvocation) { // assume that the backlight is already at 3 when the emulator starts mdelay(100); // to prevent ds2_setBacklight() from crashing @@ -4100,7 +4110,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) mdelay(100); // to prevent ds2_setBacklight() from crashing ds2_setBacklight(2); - set_cpu_clock(clock_speed_number); + GameFrequencyCPU(); return return_value; } @@ -4708,7 +4718,7 @@ void gui_init(u32 lang_id) { int flag; - ds2_setCPUclocklevel(13); // Crank it up. When the menu starts, -> 0. + HighFrequencyCPU(); // Crank it up. When the menu starts, -> 0. // Start with no saved state existing, as no game is loaded yet. int i; diff --git a/source/nds/gui.h b/source/nds/gui.h index 0b91758..b2eae62 100644 --- a/source/nds/gui.h +++ b/source/nds/gui.h @@ -129,7 +129,9 @@ extern u32 menu(u16 *original_screen, bool8 FirstInvocation); extern void game_disableAudio(); extern void game_set_frameskip(); extern void game_set_fluidity(); -extern void set_cpu_clock(u32 num); +extern void LowFrequencyCPU(); +extern void HighFrequencyCPU(); +extern void GameFrequencyCPU(); extern int load_language_msg(char *filename, u32 language); #ifdef __cplusplus |