Merge pull request #120 from pjft/pjft-experimental
[pcsx_rearmed.git] / frontend / libretro.c
index 3013a7f..090e10b 100644 (file)
 
 #define PORTS_NUMBER 8
 
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
 #define ISHEXDEC ((buf[cursor]>='0') && (buf[cursor]<='9')) || ((buf[cursor]>='a') && (buf[cursor]<='f')) || ((buf[cursor]>='A') && (buf[cursor]<='F'))
 
 //hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key
@@ -64,6 +68,7 @@ static int is_pal_mode;
 
 /* memory card data */
 extern char Mcd1Data[MCD_SIZE];
+extern char Mcd2Data[MCD_SIZE];
 extern char McdDisable[2];
 
 /* PCSX ReARMed core calls and stuff */
@@ -82,6 +87,15 @@ int in_enable_vibration = 1;
 #define VOUT_MAX_WIDTH 1024
 #define VOUT_MAX_HEIGHT 512
 
+//Dummy functions
+bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info){return false;}
+void retro_unload_game(void){}
+static int vout_open(void){return 0;}
+static void vout_close(void){}
+static int snd_init(void){return 0;}
+static void snd_finish(void){}
+static int snd_busy(void){return 0;}
+
 static void init_memcard(char *mcd_data)
 {
        unsigned off = 0;
@@ -115,11 +129,6 @@ static void init_memcard(char *mcd_data)
        }
 }
 
-static int vout_open(void)
-{
-       return 0;
-}
-
 static void vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp)
 {
        vout_width = w;
@@ -198,10 +207,6 @@ out:
        pl_rearmed_cbs.flip_cnt++;
 }
 
-static void vout_close(void)
-{
-}
-
 #ifdef _3DS
 typedef struct
 {
@@ -410,20 +415,6 @@ void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in)
 }
 
 /* sound calls */
-static int snd_init(void)
-{
-       return 0;
-}
-
-static void snd_finish(void)
-{
-}
-
-static int snd_busy(void)
-{
-       return 0;
-}
-
 static void snd_feed(void *buf, int bytes)
 {
        if (audio_batch_cb != NULL)
@@ -1281,15 +1272,6 @@ bool retro_load_game(const struct retro_game_info *info)
        return true;
 }
 
-bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info)
-{
-       return false;
-}
-
-void retro_unload_game(void)
-{
-}
-
 unsigned retro_get_region(void)
 {
        return is_pal_mode ? RETRO_REGION_PAL : RETRO_REGION_NTSC;
@@ -1546,11 +1528,6 @@ static void update_variables(bool in_flight)
    }
 }
 
-static int min(int a, int b)
-{
-    return a < b ? a : b;
-}
-
 void retro_run(void)
 {
     int i;
@@ -1581,10 +1558,10 @@ void retro_run(void)
 
                if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD)
                {
-                       in_analog_left[i][0] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
-                       in_analog_left[i][1] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
-                       in_analog_right[i][0] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
-                       in_analog_right[i][1] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
+                       in_analog_left[i][0] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
+                       in_analog_left[i][1] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
+                       in_analog_right[i][0] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
+                       in_analog_right[i][1] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
                }
        }
 
@@ -1658,7 +1635,7 @@ static void check_system_specs(void)
 
 void retro_init(void)
 {
-       const char *bios[] = { "scph1001", "scph5501", "scph7001" };
+       const char *bios[] = { "SCPH101", "SCPH7001", "SCPH5501", "SCPH1001" };
        const char *dir;
        char path[256];
        int i, ret;
@@ -1725,7 +1702,7 @@ void retro_init(void)
                SysPrintf("no BIOS files found.\n");
                struct retro_message msg =
                {
-                       "no BIOS found, expect bugs!",
+                       "No BIOS file found - add for better compatibility",
                        180
                };
                environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg);
@@ -1748,6 +1725,7 @@ void retro_init(void)
        McdDisable[0] = 0;
        McdDisable[1] = 1;
        init_memcard(Mcd1Data);
+   init_memcard(Mcd2Data);
 
        SaveFuncs.open = save_open;
        SaveFuncs.read = save_read;