From 90206450327a222607119b04f34cf1853faf37f8 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 21 May 2009 19:14:28 +0300 Subject: [PATCH] tweaks from 2008 (gpsp09-2xb_3) --- gp2x/gp2x.c | 8 ++- gp2x/readme_gp2x.txt | 17 +++++ gui.c | 156 ++++++++++++++++++++++++++++++++----------- input.c | 6 +- main.c | 9 ++- video.c | 34 ++++++++-- 6 files changed, 177 insertions(+), 53 deletions(-) diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c index 29ee5f4..7f723b5 100644 --- a/gp2x/gp2x.c +++ b/gp2x/gp2x.c @@ -28,12 +28,13 @@ extern int main_cpuspeed(int argc, char *argv[]); extern SDL_Surface* screen; -u32 gp2x_audio_volume = 74; +u32 gp2x_audio_volume = 74/2; u32 gpsp_gp2x_dev_audio = 0; u32 gpsp_gp2x_dev = 0; volatile u16 *gpsp_gp2x_memregs; volatile u32 *gpsp_gp2x_memregl; +extern unsigned short *gp2x_memregs; static volatile u16 *MEM_REG; @@ -64,7 +65,9 @@ void gp2x_overclock() gpsp_gp2x_memregs = (unsigned short *)gpsp_gp2x_memregl; clear_screen(0); - main_cpuspeed(0, NULL); +// main_cpuspeed(0, NULL); + gp2x_memregs = (void *)gpsp_gp2x_memregs; + cpuctrl_init(); gp2x_sound_volume(1); } @@ -73,6 +76,7 @@ void gp2x_quit() munmap((void *)gpsp_gp2x_memregl, 0x10000); close(gpsp_gp2x_dev_audio); close(gpsp_gp2x_dev); + chdir("/usr/gp2x"); execl("gp2xmenu", "gp2xmenu", NULL); } diff --git a/gp2x/readme_gp2x.txt b/gp2x/readme_gp2x.txt index 434250a..a0af69d 100644 --- a/gp2x/readme_gp2x.txt +++ b/gp2x/readme_gp2x.txt @@ -12,6 +12,23 @@ not apply however). Changelog: +0.9-2xb u1 (unofficial notaz release): +- Fixed a problen in thread synchronization which caused deadlock after + some time. + +0.9-2xb u2 (unofficial notaz release): +- Replaced non-working mmuhack.o with proper one, added cache flush calls + to avoid artifacts. + +0.9-2xb u3 (unofficial notaz release, released with permission): +- Removed built-in CPU/LCD/RAM-Tweaker. +- Improved usability of volume control. +- Removed PSP-specific GUI options, adjusted help text. +- Overclocking from menu now works, keep it at 200 if you don't want that + (if you want to overclock using launcher, for example). +- Fixed centering-on-first-run problem. +- 3:2 scaled option now does what it says. + 0.9-2xb: -- IMPORTANT-- If you're overwriting an old version, be sure to delete the gpsp.cfg file first, or be prepared to have a bunch of weird button diff --git a/gui.c b/gui.c index 6eb9ddb..21e1023 100644 --- a/gui.c +++ b/gui.c @@ -25,6 +25,10 @@ #endif +#ifndef GP2X_BUILD +#include "gp2x/cpuctrl.h" +#endif + #include "common.h" #include "font.h" @@ -643,7 +647,7 @@ u32 gamepad_config_line_to_button[] = #ifdef GP2X_BUILD u32 gamepad_config_line_to_button[] = - { 0, 2, 1, 3, 8, 9, 10, 11, 6, 7, 4, 5 }; + { 0, 2, 1, 3, 8, 9, 10, 11, 6, 7, 4, 5, 14 }; #endif @@ -672,8 +676,13 @@ s32 load_game_config_file() random_skip = file_options[2] % 2; clock_speed = file_options[3]; +#ifdef GP2X_BUILD + if(clock_speed >= 300) + clock_speed = 200; +#else if(clock_speed > 333) clock_speed = 333; +#endif if(clock_speed < 33) clock_speed = 33; @@ -701,7 +710,11 @@ s32 load_game_config_file() current_frameskip_type = auto_frameskip; frameskip_value = 4; random_skip = 0; +#ifdef GP2X_BUILD + clock_speed = 200; +#else clock_speed = 333; +#endif for(i = 0; i < 10; i++) { @@ -945,7 +958,10 @@ void get_savestate_filename_noshot(u32 slot, u8 *name_buffer) u32 menu(u16 *original_screen) { - u32 clock_speed_number = (clock_speed / 33) - 1; + u32 clock_speed_number; +#ifdef GP2X_BUILD + static u32 clock_speed_old = 200; +#endif u8 print_buffer[81]; u32 _current_option = 0; gui_action_type gui_action; @@ -1001,7 +1017,11 @@ u32 menu(u16 *original_screen) void menu_quit() { + #ifdef PSP_BUILD clock_speed = (clock_speed_number + 1) * 33; + #elif defined(GP2X_BUILD) + clock_speed = 150 + clock_speed_number * 10; + #endif save_config_file(); quit(); } @@ -1134,7 +1154,10 @@ u32 menu(u16 *original_screen) u8 *scale_options[] = { - "unscaled 3:2", "scaled 3:2", "fullscreen 16:9" + "unscaled 3:2", "scaled 3:2", "fullscreen" +#ifdef PSP_BUILD + " 16:9" +#endif }; u8 *frameskip_options[] = { "automatic", "manual", "off" }; @@ -1158,11 +1181,20 @@ u32 menu(u16 *original_screen) u8 *update_backup_options[] = { "Exit only", "Automatic" }; +#ifdef GP2X_BUILD + u8 *clock_speed_options[] = + { + "150MHz", "160MHz", "170MHz", "180MHz", "190MHz", + "200MHz", "210MHz", "220MHz", "230MHz", "240MHz", + "250MHz", "260MHz", "270MHz", "280MHz", "290MHz" + }; +#else u8 *clock_speed_options[] = { "33MHz", "66MHz", "100MHz", "133MHz", "166MHz", "200MHz", "233MHz", "266MHz", "300MHz", "333MHz" }; +#endif u8 *gamepad_config_buttons[] = { @@ -1195,38 +1227,52 @@ u32 menu(u16 *original_screen) { string_selection_option(NULL, "Display scaling", scale_options, (u32 *)(&screen_scale), 3, +#ifndef GP2X_BUILD "Determines how the GBA screen is resized in relation to the entire\n" "screen. Select unscaled 3:2 for GBA resolution, scaled 3:2 for GBA\n" "aspect ratio scaled to fill the height of the PSP screen, and\n" - "fullscreen to fill the entire PSP screen.", 2), + "fullscreen to fill the entire PSP screen." +#endif + "", 2), +#ifndef GP2X_BUILD string_selection_option(NULL, "Screen filtering", yes_no_options, (u32 *)(&screen_filter), 2, "Determines whether or not bilinear filtering should be used when\n" "scaling the screen. Selecting this will produce a more even and\n" "smooth image, at the cost of being blurry and having less vibrant\n" "colors.", 3), +#endif string_selection_option(NULL, "Frameskip type", frameskip_options, (u32 *)(¤t_frameskip_type), 3, - "Determines what kind of frameskipping should be employed.\n" + "Determines what kind of frameskipping to use.\n" +#ifndef GP2X_BUILD "Frameskipping may improve emulation speed of many games.\n" "Off: Do not skip any frames.\n" "Auto: Skip up to N frames (see next option) as needed.\n" - "Manual: Always render only 1 out of N + 1 frames.", 5), + "Manual: Always render only 1 out of N + 1 frames." +#endif + "", 5), numeric_selection_option(NULL, "Frameskip value", &frameskip_value, 100, +#ifndef GP2X_BUILD "For auto frameskip, determines the maximum number of frames that\n" "are allowed to be skipped consecutively.\n" "For manual frameskip, determines the number of frames that will\n" - "always be skipped.", 6), + "always be skipped." +#endif + "", 6), string_selection_option(NULL, "Framskip variation", frameskip_variation_options, &random_skip, 2, +#ifndef GP2X_BUILD "If objects in the game flicker at a regular rate certain manual\n" "frameskip values may cause them to normally disappear. Change this\n" "value to 'random' to avoid this. Do not use otherwise, as it tends to\n" - "make the image quality worse, especially in high motion games.", 7), + "make the image quality worse, especially in high motion games." +#endif + "", 7), string_selection_option(NULL, "Audio output", yes_no_options, &global_enable_audio, 2, - "Select 'no' to turn off all audio output. This will not result in a\n" - "significant change in performance.", 9), + "Select 'no' to turn off all audio output. This will\n" + "not result in a significant change in performance.", 9), #ifndef PSP_BUILD string_selection_option(NULL, "Audio buffer", audio_buffer_options, &audio_buffer_size_number, 11, @@ -1258,16 +1304,28 @@ u32 menu(u16 *original_screen) cheat_option(8), cheat_option(9), string_selection_option(NULL, "Clock speed", - clock_speed_options, &clock_speed_number, 10, - "Change the clock speed of the device. Higher clock speed will yield\n" - "better performance, but will use drain battery life further.", 11), + clock_speed_options, &clock_speed_number, +#ifdef GP2X_BUILD + 15, +#else + 10, +#endif + "Change the clock speed of the device. Higher clock\n" + "speed will yield better performance, but will drain\n" + "battery life further.", 11), string_selection_option(NULL, "Update backup", update_backup_options, &update_backup_flag, 2, +#ifdef GP2X_BUILD + "Determines when in-game save files should be\n" + "written back to SD card.", +#else "Determines when in-game save files should be written back to\n" "memstick. If set to 'automatic' writebacks will occur shortly after\n" "the game's backup is altered. On 'exit only' it will only be written\n" "back when you exit from this menu (NOT from using the home button).\n" - "Use the latter with extreme care.", 12), + "Use the latter with extreme care.", +#endif + 12), submenu_option(NULL, "Back", "Return to the main menu.", 14) }; @@ -1277,17 +1335,20 @@ u32 menu(u16 *original_screen) { numeric_selection_action_hide_option(menu_load_state, menu_change_state, "Load savestate from current slot", &savestate_slot, 10, - "Select to load the game state from the current slot for this game.\n" + "Select to load the game state from the current slot\n" + "for this game.\n" "Press left + right to change the current slot.", 6), numeric_selection_action_hide_option(menu_save_state, menu_change_state, "Save savestate to current slot", &savestate_slot, 10, - "Select to save the game state to the current slot for this game.\n" + "Select to save the game state to the current slot\n" + "for this game.\n" "Press left + right to change the current slot.", 7), numeric_selection_action_hide_option(menu_load_state_file, menu_change_state, "Load savestate from file", &savestate_slot, 10, "Restore gameplay from a savestate file.\n" - "Note: The same file used to save the state must be present.\n", 9), + "Note: The same file used to save the state must be\n" + "present.\n", 9), numeric_selection_option(menu_change_state, "Current savestate slot", &savestate_slot, 10, "Change the current savestate slot.\n", 11), @@ -1350,7 +1411,8 @@ u32 menu(u16 *original_screen) gamepad_config_option("Right Trigger", 9), gamepad_config_option("Start ", 10), gamepad_config_option("Select ", 11), - submenu_option(NULL, "Back", "Return to the main menu.", 13) + gamepad_config_option("Stick Push ", 12), + submenu_option(NULL, "Back", "Return to the main menu.", 14) }; @@ -1381,39 +1443,42 @@ u32 menu(u16 *original_screen) menu_option_type main_options[] = { submenu_option(&graphics_sound_menu, "Graphics and Sound options", - "Select to set display parameters and frameskip behavior,\n" - "audio on/off, audio buffer size, and audio filtering.", 0), + "Select to set display parameters and frameskip\n" + "behavior, audio on/off, buffer size, and filtering.", 0), numeric_selection_action_option(menu_load_state, NULL, "Load state from slot", &savestate_slot, 10, - "Select to load the game state from the current slot for this game,\n" - "if it exists (see the extended menu for more information)\n" + "Select to load the game state from the current slot\n" + "for this game, if it exists.\n" "Press left + right to change the current slot.", 2), numeric_selection_action_option(menu_save_state, NULL, "Save state to slot", &savestate_slot, 10, - "Select to save the game state to the current slot for this game.\n" - "See the extended menu for more information.\n" + "Select to save the game state to the current slot\n" + "for this game. See the extended menu for more info.\n" "Press left + right to change the current slot.", 3), submenu_option(&savestate_menu, "Savestate options", - "Select to enter a menu for loading, saving, and viewing the\n" - "currently active savestate for this game (or to load a savestate\n" - "file from another game)", 4), + "Select to enter a menu for loading, saving, and\n" + "viewing the currently active savestate for this game\n" + "(or to load a savestate file from another game)", 4), submenu_option(&gamepad_config_menu, "Configure gamepad input", - "Select to change the in-game behavior of the PSP buttons and d-pad.", - 6), + "Select to change the in-game behavior of buttons\n" + "and d-pad.", 6), +#ifndef GP2X_BUILD submenu_option(&analog_config_menu, "Configure analog input", "Select to change the in-game behavior of the PSP analog nub.", 7), +#endif submenu_option(&cheats_misc_menu, "Cheats and Miscellaneous options", - "Select to manage cheats, set backup behavior, and set device clock\n" - "speed.", 9), + "Select to manage cheats, set backup behavior,\n" + "and set device clock speed.", 9), action_option(menu_load, NULL, "Load new game", - "Select to load a new game (will exit a game if currently playing).", - 11), + "Select to load a new game\n" + "(will exit a game if currently playing).", 11), action_option(menu_restart, NULL, "Restart game", - "Select to reset the GBA with the current game loaded.", 12), + "Select to reset the GBA with the current game\n" + "loaded.", 12), action_option(menu_exit, NULL, "Return to game", "Select to exit this menu and resume gameplay.", 13), action_option(menu_quit, NULL, "Exit gpSP", - "Select to exit gpSP and return to the PSP XMB/loader.", 15) + "Select to exit gpSP and return to the menu.", 15) }; make_menu(main, submenu_main, NULL); @@ -1440,10 +1505,16 @@ u32 menu(u16 *original_screen) { for(i = 0; i < 6; i++) { - print_string_pad(" ", COLOR_BG, COLOR_BG, 30, 210 + (i * 10), 70); + print_string_pad(" ", COLOR_BG, COLOR_BG, 8, 210 + (i * 10), 70); } } +#ifdef PSP_BUILD + clock_speed_number = (clock_speed / 33) - 1; +#elif defined(GP2X_BUILD) + clock_speed_number = (clock_speed - 150) / 10; +#endif + video_resolution_large(); #ifndef GP2X_BUILD @@ -1516,7 +1587,7 @@ u32 menu(u16 *original_screen) } print_string(current_option->help_string, COLOR_HELP_TEXT, - COLOR_BG, 30, 210); + COLOR_BG, 8, 210); flip_screen(); @@ -1593,10 +1664,17 @@ u32 menu(u16 *original_screen) set_gba_resolution(screen_scale); video_resolution_small(); - clock_speed = (clock_speed_number + 1) * 33; - #ifdef PSP_BUILD + clock_speed = (clock_speed_number + 1) * 33; scePowerSetClockFrequency(clock_speed, clock_speed, clock_speed / 2); + #elif defined(GP2X_BUILD) + clock_speed = 150 + clock_speed_number * 10; + if (clock_speed != clock_speed_old) + { + printf("about to set CPU clock to %iMHz\n", clock_speed); + set_FCLK(clock_speed); + clock_speed_old = clock_speed; + } #endif SDL_PauseAudio(0); diff --git a/input.c b/input.c index be00c60..2b17f50 100644 --- a/input.c +++ b/input.c @@ -513,7 +513,7 @@ u32 update_input() { static u32 rapidfire_flag = 1; static u32 last_buttons; - u32 non_repeat_buttons; + u32 handled_buttons; u32 button_id; u32 new_key = 0; u32 buttons = gpsp_gp2x_joystick_read(); @@ -525,12 +525,12 @@ u32 update_input() buttons |= GP2X_VOL_MIDDLE; } - non_repeat_buttons = (last_buttons ^ buttons) & buttons; + handled_buttons = ((last_buttons ^ buttons) | GP2X_VOL_DOWN | GP2X_VOL_UP) & buttons; last_buttons = buttons; for(i = 0; i < 16; i++) { - if(non_repeat_buttons & button_gp2x_mask_to_config[i]) + if(handled_buttons & button_gp2x_mask_to_config[i]) button_id = gamepad_config_map[i]; else button_id = BUTTON_ID_NONE; diff --git a/main.c b/main.c index 1f076c8..ac891cb 100644 --- a/main.c +++ b/main.c @@ -84,7 +84,11 @@ u32 oam_update_count = 0; u32 synchronize_flag = 1; u32 update_backup_flag = 1; +#ifdef GP2X_BUILD +u32 clock_speed = 200; +#else u32 clock_speed = 333; +#endif u8 main_path[512]; void trigger_ext_event(); @@ -351,7 +355,7 @@ int main(int argc, char *argv[]) current_savestate_filename); load_state(current_savestate_filename); */ - debug_on(); +// debug_on(); if(argc > 2) { @@ -1008,7 +1012,8 @@ void get_ticks_us(u64 *ticks_return) void delay_us(u32 us_count) { - usleep(us_count); + //usleep(us_count); + SDL_Delay(us_count / 1000); } void get_ticks_us(u64 *ticks_return) diff --git a/video.c b/video.c index 19a4c11..1240377 100644 --- a/video.c +++ b/video.c @@ -3406,6 +3406,13 @@ void flip_screen() SDL_Rect drect = {40, 40, 240, 160}; SDL_BlitSurface(screen, &srect, hw_screen, &drect); } + else if((screen_scale == scaled_aspect) && + (resolution_width == small_resolution_width) && + (resolution_height == small_resolution_height)) + { + SDL_Rect drect = {0, 10, 0, 0}; + SDL_BlitSurface(screen, NULL, hw_screen, &drect); + } else { SDL_BlitSurface(screen, NULL, hw_screen, NULL); @@ -3673,11 +3680,18 @@ void video_resolution_small() current_scale = screen_scale; #ifdef GP2X_BUILD + int w, h; SDL_FreeSurface(screen); SDL_GP2X_AllowGfxMemory(NULL, 0); - hw_screen = SDL_SetVideoMode((screen_scale == unscaled ? 320 : - small_resolution_width * video_scale), (screen_scale == unscaled ? 320 : - small_resolution_height * video_scale), 16, SDL_HWSURFACE); + + w = 320; h = 240; + if (screen_scale != unscaled) + { + w = small_resolution_width * video_scale; + h = small_resolution_height * video_scale; + } + if (screen_scale == scaled_aspect) h += 20; + hw_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE); screen = SDL_CreateRGBSurface(SDL_HWSURFACE, small_resolution_width * video_scale, small_resolution_height * @@ -3768,7 +3782,7 @@ void print_string_ext(const char *str, u16 fg_color, u16 bg_color, /* EDIT */ - if(y + FONT_HEIGHT >= resolution_height) + if(y + FONT_HEIGHT > resolution_height) return; while(current_char) @@ -3812,8 +3826,13 @@ void print_string_ext(const char *str, u16 fg_color, u16 bg_color, str_index++; } - if(current_x + FONT_WIDTH >= resolution_width /* EDIT */) - break; + if(current_x + FONT_WIDTH > resolution_width /* EDIT */) + { + while (current_char && current_char != '\n') + { + current_char = str[str_index++]; + } + } } } @@ -3923,7 +3942,8 @@ void debug_screen_printl(const char *format, ...) va_start(ap, format); debug_screen_printf(format, ap); - debug_screen_printf("\n"); + debug_screen_newline(1); +// debug_screen_printf("\n"); va_end(ap); } -- 2.39.5