X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=main.c;h=ad79024bbf0752b582d72207e32b6760130ddca2;hb=eb3668fc5dab138073cd4844208ac05b94086a4a;hp=bd66c06d01ba05560ab5e705c368c6dceec7c169;hpb=ee0a3871f9982215361cd6bb4758eb9a7c7d8413;p=gpsp.git diff --git a/main.c b/main.c index bd66c06..ad79024 100644 --- a/main.c +++ b/main.c @@ -43,18 +43,10 @@ u32 global_cycles_per_instruction = 1; u32 random_skip = 0; u32 fps_debug = 0; -#ifdef GP2X_BUILD u32 frameskip_value = 2; -u64 frame_count_initial_timestamp = 0; u64 last_frame_interval_timestamp; -void gp2x_init(void); -void gp2x_quit(void); -#else - -u32 frameskip_value = 4; -#endif u32 skip_next_frame = 0; u32 frameskip_counter = 0; @@ -211,18 +203,17 @@ int main(int argc, char *argv[]) #endif getcwd(main_path, 512); - load_config_file(); - - gamepak_filename[0] = 0; #ifdef PSP_BUILD delay_us(2500000); #endif -#ifdef GP2X_BUILD - // Overclocking GP2X and MMU patch goes here - gp2x_init(); +#ifndef PC_BUILD + gpsp_plat_init(); #endif + load_config_file(); + + gamepak_filename[0] = 0; init_video(); @@ -244,7 +235,11 @@ int main(int argc, char *argv[]) debug_screen_printl("a860e8c0b6d573d191e4ec7db1b1e4f6 "); debug_screen_printl(" "); debug_screen_printl("When you do get it name it gba_bios.bin and put it"); +#ifdef PND_BUILD + debug_screen_printl("in /pandora/appdata/gpsp/ . "); +#else debug_screen_printl("in the same directory as gpSP. "); +#endif debug_screen_printl(" "); debug_screen_printl("Press any button to exit. "); @@ -296,7 +291,7 @@ int main(int argc, char *argv[]) { if(load_gamepak(argv[1]) == -1) { -#ifdef PC_BUILD +#ifndef PSP_BUILD printf("Failed to load gamepak %s, exiting.\n", load_filename); #endif exit(-1); @@ -318,7 +313,7 @@ int main(int argc, char *argv[]) { if(load_gamepak(load_filename) == -1) { -#ifdef PC_BUILD +#ifndef PSP_BUILD printf("Failed to load gamepak %s, exiting.\n", load_filename); #endif exit(-1); @@ -341,10 +336,6 @@ int main(int argc, char *argv[]) execute_arm_translate(execute_cycles); #else -#ifdef GP2X_BUILD - get_ticks_us(&frame_count_initial_timestamp); -#endif - /* u8 current_savestate_filename[512]; get_savestate_filename_noshot(savestate_slot, current_savestate_filename); @@ -614,9 +605,11 @@ u32 update_gba() if(fps_debug) { char print_buffer[32]; - sprintf(print_buffer, "%d (%d)", fps, frames_drawn); + sprintf(print_buffer, "%2d (%2d)", fps, frames_drawn); print_string(print_buffer, 0xFFFF, 0x000, 0, 0); } + if(!synchronize_flag) + print_string("-FF-", 0xFFFF, 0x000, 216, 0); update_screen(); @@ -670,10 +663,6 @@ u32 update_gba() return execute_cycles; } -u64 last_screen_timestamp = 0; -u32 frame_speed = 15000; - - #ifdef PSP_BUILD u32 real_frame_count = 0; @@ -693,7 +682,6 @@ void synchronize() if(!synchronize_flag) { - print_string("--FF--", 0xFFFF, 0x000, 0, 0); used_frameskip = 4; virtual_frame_count = real_frame_count - 1; } @@ -758,9 +746,7 @@ void synchronize() */ } -#endif - -#ifdef GP2X_BUILD +#else u32 real_frame_count = 0; u32 virtual_frame_count = 0; @@ -776,14 +762,11 @@ void synchronize() u64 time_delta; get_ticks_us(&new_ticks); - time_delta = new_ticks - last_screen_timestamp; - last_screen_timestamp = new_ticks; skip_next_frame = 0; virtual_frame_count++; - real_frame_count = ((new_ticks - - frame_count_initial_timestamp) * 3) / 50000; + real_frame_count = (new_ticks * 3) / 50000; if(real_frame_count >= virtual_frame_count) { @@ -800,6 +783,14 @@ void synchronize() num_skipped_frames = 0; } } + else if (synchronize_flag) + { +#if defined(PND_BUILD) + fb_wait_vsync(); +#elif !defined(GP2X_BUILD) // sleeping on GP2X is a bad idea + delay_us((u64)virtual_frame_count * 50000 / 3 - new_ticks + 2); +#endif + } frames++; @@ -840,76 +831,11 @@ void synchronize() interval_skipped_frames += skip_next_frame; - if(!synchronize_flag) - print_string("--FF--", 0xFFFF, 0x000, 0, 0); -} - -#endif - - -#ifdef PC_BUILD - -u32 ticks_needed_total = 0; -float us_needed = 0.0; -u32 frames = 0; -const u32 frame_interval = 60; - -void synchronize() -{ - u64 new_ticks; - u64 time_delta; +#if !defined(GP2X_BUILD) && !defined(PND_BUILD) char char_buffer[64]; - - get_ticks_us(&new_ticks); - time_delta = new_ticks - last_screen_timestamp; - last_screen_timestamp = new_ticks; - ticks_needed_total += time_delta; - - skip_next_frame = 0; - - if((time_delta < frame_speed) && synchronize_flag) - { - delay_us(frame_speed - time_delta); - } - - frames++; - - if(frames == frame_interval) - { - us_needed = (float)ticks_needed_total / frame_interval; - ticks_needed_total = 0; - frames = 0; - } - - if(current_frameskip_type == manual_frameskip) - { - frameskip_counter = (frameskip_counter + 1) % - (frameskip_value + 1); - if(random_skip) - { - if(frameskip_counter != (rand() % (frameskip_value + 1))) - skip_next_frame = 1; - } - else - { - if(frameskip_counter) - skip_next_frame = 1; - } - } - - if(synchronize_flag == 0) - print_string("--FF--", 0xFFFF, 0x000, 0, 0); - - sprintf(char_buffer, "gpSP: %.1fms %.1ffps", us_needed / 1000.0, - 1000000.0 / us_needed); + sprintf(char_buffer, "gpSP: %2d (%2d) fps", fps, frames_drawn); SDL_WM_SetCaption(char_buffer, "gpSP"); - -/* - sprintf(char_buffer, "%02d %02d %06d %07d", frameskip, (u32)ms_needed, - ram_translation_ptr - ram_translation_cache, rom_translation_ptr - - rom_translation_cache); - print_string(char_buffer, 0xFFFF, 0x0000, 0, 0); -*/ +#endif } #endif @@ -930,8 +856,8 @@ void quit() #else SDL_Quit(); -#ifdef GP2X_BUILD - gp2x_quit(); +#ifndef PC_BUILD + gpsp_plat_quit(); #endif exit(0); @@ -990,7 +916,7 @@ void delay_us(u32 us_count) void get_ticks_us(u64 *ticks_return) { - *ticks_return = (SDL_GetTicks() * 1000); + *ticks_return = (u64)SDL_GetTicks() * 1000; } #else