summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraliaspider2014-12-09 01:59:02 +0100
committeraliaspider2014-12-09 01:59:02 +0100
commit50df6df600745247af98d0f6ed52f80043c9922b (patch)
tree216798810143c77fe838b1dfbaced3aba0e986fe
parent38158f67e2d8a9c8c43b3b3598a56f3d86a727f8 (diff)
downloadpicogpsp-50df6df600745247af98d0f6ed52f80043c9922b.tar.gz
picogpsp-50df6df600745247af98d0f6ed52f80043c9922b.tar.bz2
picogpsp-50df6df600745247af98d0f6ed52f80043c9922b.zip
fix undefined referances.
-rw-r--r--Makefile1
-rw-r--r--common.h2
-rw-r--r--input.c24
-rw-r--r--input.h22
-rw-r--r--libretro.c9
-rw-r--r--main.c10
-rw-r--r--memory.c2
-rw-r--r--video.c2
-rw-r--r--video.h2
9 files changed, 72 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 3152bf3..4ddb89f 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,7 @@ OBJS += cheats.o
OBJS += zip.o
OBJS += libretro.o
+OBJS += libco/libco.o
diff --git a/common.h b/common.h
index 24f99bd..dfcef6a 100644
--- a/common.h
+++ b/common.h
@@ -110,6 +110,8 @@
#define GBA_SCREEN_HEIGHT (160)
#define GBA_SCREEN_PITCH (240)
+void switch_to_main_thread(void);
+
#else
#include "SDL.h"
#endif
diff --git a/input.c b/input.c
index a2f147f..51e70cf 100644
--- a/input.c
+++ b/input.c
@@ -345,7 +345,29 @@ void init_input()
#elif defined(__LIBRETRO__)
-/* todo */
+static retro_input_state_t input_state_cb;
+void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; }
+
+u32 update_input(void)
+{
+// return;
+ unsigned i;
+ uint32_t new_key = 0;
+
+ if (!input_state_cb)
+ return 0;
+
+ for (i = 0; i < sizeof(btn_map) / sizeof(map); i++)
+ new_key |= input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, btn_map[i].retropad) ? btn_map[i].gba : 0;
+
+ if ((new_key | key) != key)
+ trigger_key(new_key);
+
+ key = new_key;
+ io_registers[REG_P1] = (~key) & 0x3FF;
+
+ return 0;
+}
#elif defined(PC_BUILD)
diff --git a/input.h b/input.h
index c5636bf..9427cc7 100644
--- a/input.h
+++ b/input.h
@@ -82,6 +82,28 @@ gui_action_type get_gui_input_fs_hold(u32 button_id);
void input_write_mem_savestate(file_tag_type savestate_file);
void input_read_savestate(file_tag_type savestate_file);
+#ifdef __LIBRETRO__
+#include "libretro.h"
+
+typedef struct
+{
+ unsigned retropad ;
+ input_buttons_type gba;
+} map;
+static const map btn_map[] = {
+ { RETRO_DEVICE_ID_JOYPAD_L, BUTTON_L },
+ { RETRO_DEVICE_ID_JOYPAD_R, BUTTON_R },
+ { RETRO_DEVICE_ID_JOYPAD_DOWN, BUTTON_DOWN },
+ { RETRO_DEVICE_ID_JOYPAD_UP, BUTTON_UP },
+ { RETRO_DEVICE_ID_JOYPAD_LEFT, BUTTON_LEFT },
+ { RETRO_DEVICE_ID_JOYPAD_RIGHT, BUTTON_RIGHT },
+ { RETRO_DEVICE_ID_JOYPAD_START, BUTTON_START },
+ { RETRO_DEVICE_ID_JOYPAD_SELECT, BUTTON_SELECT },
+ { RETRO_DEVICE_ID_JOYPAD_B, BUTTON_B },
+ { RETRO_DEVICE_ID_JOYPAD_A, BUTTON_A }
+};
+#endif
+
extern u32 gamepad_config_map[];
extern u32 global_enable_analog;
extern u32 analog_sensitivity_level;
diff --git a/libretro.c b/libretro.c
index ae427e6..381a471 100644
--- a/libretro.c
+++ b/libretro.c
@@ -21,6 +21,15 @@ struct retro_perf_callback perf_cb;
static cothread_t main_thread;
static cothread_t cpu_thread;
+/* to be removed */
+u32 savestate_slot = 0;
+void get_savestate_filename_noshot(u32 slot, char *name_buffer)
+{
+ (void) slot;
+ sprintf(name_buffer, "dummy.svs");
+}
+/* ------------ */
+
void switch_to_main_thread(void)
{
co_switch(main_thread);
diff --git a/main.c b/main.c
index b6729ed..49d2ae4 100644
--- a/main.c
+++ b/main.c
@@ -214,6 +214,7 @@ void init_main()
flush_translation_cache_bios();
}
+#ifndef __LIBRETRO__
int main(int argc, char *argv[])
{
char bios_filename[512];
@@ -384,6 +385,7 @@ int main(int argc, char *argv[])
#endif
return 0;
}
+#endif
void print_memory_stats(u32 *counter, u32 *region_stats, char *stats_str)
{
@@ -625,6 +627,12 @@ u32 update_gba()
flush_ram_count = 0;
#endif
+#ifdef __LIBRETRO__
+ switch_to_main_thread();
+
+ update_gbc_sound(cpu_ticks);
+ gbc_sound_update = 0;
+#else
if(update_input())
continue;
@@ -645,7 +653,7 @@ u32 update_gba()
if(update_backup_flag)
update_backup();
-
+#endif
process_cheats();
event_cycles++;
diff --git a/memory.c b/memory.c
index 56e0fbc..033312c 100644
--- a/memory.c
+++ b/memory.c
@@ -2197,7 +2197,9 @@ u32 load_gamepak(const char *name)
gamepak_maker[2] = 0;
load_game_config(gamepak_title, gamepak_code, gamepak_maker);
+#ifndef __LIBRETRO__
load_game_config_file();
+#endif
change_ext(gamepak_filename, cheats_filename, ".cht");
add_cheats(cheats_filename);
diff --git a/video.c b/video.c
index 3df1532..96ef006 100644
--- a/video.c
+++ b/video.c
@@ -3387,6 +3387,7 @@ void flip_screen()
#endif
+#ifndef __LIBRETRO__
u32 frame_to_render;
void update_screen()
@@ -3394,6 +3395,7 @@ void update_screen()
if(!skip_next_frame)
flip_screen();
}
+#endif
#ifdef PSP_BUILD
diff --git a/video.h b/video.h
index c54682f..18720bd 100644
--- a/video.h
+++ b/video.h
@@ -21,7 +21,9 @@
#define VIDEO_H
void update_scanline();
+#ifndef __LIBRETRO__
void update_screen();
+#endif
void init_video();
void video_resolution_large();
void video_resolution_small();