diff options
Diffstat (limited to 'libretro.c')
-rw-r--r-- | libretro.c | 62 |
1 files changed, 44 insertions, 18 deletions
@@ -5,6 +5,11 @@ #include <stdint.h> #include "common.h" #include "libco.h" +#include "libretro.h" + +#ifndef MAX_PATH +#define MAX_PATH (512) +#endif static retro_log_printf_t log_cb; static retro_video_refresh_t video_cb; @@ -28,7 +33,7 @@ static inline void switch_to_cpu_thread(void) static void cpu_thread_entry(void) { - execute_arm_translate(reg[EXECUTE_CYCLES]); + execute_arm_translate(execute_cycles); } static inline void init_context_switch(void) @@ -42,6 +47,26 @@ static inline void deinit_context_switch(void) co_delete(cpu_thread); } +#ifdef PERF_TEST + +extern struct retro_perf_callback perf_cb; + +#define RETRO_PERFORMANCE_INIT(X) \ + static struct retro_perf_counter X = {#X}; \ + do { \ + if (!(X).registered) \ + perf_cb.perf_register(&(X)); \ + } while(0) + +#define RETRO_PERFORMANCE_START(X) perf_cb.perf_start(&(X)) +#define RETRO_PERFORMANCE_STOP(X) perf_cb.perf_stop(&(X)) +#else +#define RETRO_PERFORMANCE_INIT(X) +#define RETRO_PERFORMANCE_START(X) +#define RETRO_PERFORMANCE_STOP(X) + +#endif + void retro_get_system_info(struct retro_system_info *info) { info->library_name = "TempGBA"; @@ -59,8 +84,8 @@ void retro_get_system_av_info(struct retro_system_av_info *info) info->geometry.max_width = GBA_SCREEN_WIDTH; info->geometry.max_height = GBA_SCREEN_HEIGHT; info->geometry.aspect_ratio = 0; - info->timing.fps = ((float) CPU_FREQUENCY) / (308 * 228 * 4); // 59.72750057 hz - info->timing.sample_rate = SOUND_FREQUENCY; + info->timing.fps = ((float) (16* 1024 * 1024)) / (308 * 228 * 4); // 59.72750057 hz + info->timing.sample_rate = 44100; // info->timing.sample_rate = 32 * 1024; } @@ -68,13 +93,13 @@ void retro_get_system_av_info(struct retro_system_av_info *info) void retro_init() { init_gamepak_buffer(); - init_sound(); + init_sound(1); } void retro_deinit() { perf_cb.perf_log(); - quit_gba(); + memory_term(); } void retro_set_environment(retro_environment_t cb) @@ -110,27 +135,28 @@ void retro_reset() size_t retro_serialize_size() { - return SAVESTATE_SIZE; +// return SAVESTATE_SIZE; + return 0; } bool retro_serialize(void *data, size_t size) { - if (size < SAVESTATE_SIZE) +// if (size < SAVESTATE_SIZE) return false; - gba_save_state(data); +// gba_save_state(data); - return true; +// return true; } bool retro_unserialize(const void *data, size_t size) { - if (size < SAVESTATE_SIZE) +// if (size < SAVESTATE_SIZE) return false; - gba_load_state(data); +// gba_load_state(data); - return true; +// return true; } void retro_cheat_reset() {} @@ -184,12 +210,12 @@ bool retro_load_game(const struct retro_game_info *info) strncat(filename_bios, "/gba_bios.bin",sizeof(filename_bios)); - if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir) - strncpy(dir_save, dir, sizeof(dir_save)); - else - strncpy(dir_save, main_path, sizeof(dir_save)); +// if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir) +// strncpy(dir_save, dir, sizeof(dir_save)); +// else +// strncpy(dir_save, main_path, sizeof(dir_save)); - strncat(dir_save, "/",sizeof(dir_save)); +// strncat(dir_save, "/",sizeof(dir_save)); strncat(main_path, "/",sizeof(main_path)); @@ -281,7 +307,7 @@ void retro_run() render_audio(); - video_cb(GBA_FRAME_TEXTURE, GBA_SCREEN_WIDTH, GBA_SCREEN_HEIGHT, 512); + video_cb(gba_screen_pixels, GBA_SCREEN_WIDTH, GBA_SCREEN_HEIGHT, GBA_SCREEN_PITCH * 2); if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) check_variables(); |