Add rpi3 platform
[pcsx_rearmed.git] / frontend / libretro.c
index e73135b..ec06527 100644 (file)
 #include "main.h"
 #include "plugin.h"
 #include "plugin_lib.h"
+#include "arm_features.h"
 #include "revision.h"
 #include "libretro.h"
 
 #ifdef _3DS
-#include "3ds.h"
 #include "3ds/3ds_utils.h"
-int ctr_svchack_init_success = 0;
 #endif
 
 static retro_video_refresh_t video_cb;
@@ -194,7 +193,7 @@ void* pl_3ds_mmap(unsigned long addr, size_t size, int is_fixed,
    (void)is_fixed;
    (void)addr;
 
-   if (ctr_svchack_init_success)
+   if (__ctr_svchax)
    {
       psx_map_t* custom_map = custom_psx_maps;
 
@@ -207,7 +206,7 @@ void* pl_3ds_mmap(unsigned long addr, size_t size, int is_fixed,
             custom_map->buffer = malloc(size + 0x1000);
             ptr_aligned = (((u32)custom_map->buffer) + 0xFFF) & ~0xFFF;
 
-            if(svcControlMemory(&tmp, custom_map->target_map, ptr_aligned, size, MEMOP_MAP, 0x3) < 0)
+            if(svcControlMemory(&tmp, (void*)custom_map->target_map, (void*)ptr_aligned, size, MEMOP_MAP, 0x3) < 0)
             {
                SysPrintf("could not map memory @0x%08X\n", custom_map->target_map);
                exit(1);
@@ -225,7 +224,7 @@ void pl_3ds_munmap(void *ptr, size_t size, enum psxMapTag tag)
 {
    (void)tag;
 
-   if (ctr_svchack_init_success)
+   if (__ctr_svchax)
    {
       psx_map_t* custom_map = custom_psx_maps;
 
@@ -237,7 +236,7 @@ void pl_3ds_munmap(void *ptr, size_t size, enum psxMapTag tag)
 
             ptr_aligned = (((u32)custom_map->buffer) + 0xFFF) & ~0xFFF;
 
-            svcControlMemory(&tmp, custom_map->target_map, ptr_aligned, size, MEMOP_UNMAP, 0x3);
+            svcControlMemory(&tmp, (void*)custom_map->target_map, (void*)ptr_aligned, size, MEMOP_UNMAP, 0x3);
 
             free(custom_map->buffer);
             custom_map->buffer = NULL;
@@ -1139,7 +1138,7 @@ static void update_variables(bool in_flight)
       R3000Acpu *prev_cpu = psxCpu;
 
 #ifdef _3DS
-      if(!ctr_svchack_init_success)
+      if(!__ctr_svchax)
          Config.Cpu = CPU_INTERPRETER;
       else
 #endif
@@ -1220,7 +1219,7 @@ static void update_variables(bool in_flight)
 
 void retro_run(void) 
 {
-       int i;
+       int i, val;
 
        input_poll_cb();
 
@@ -1284,16 +1283,16 @@ void retro_run(void)
         if (in_type2 == PSE_PAD_TYPE_NEGCON)
         {
                /* left brake */
-               if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12))
+               if(input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, 12))
                        in_a3[1] = 255;
                else
                        in_a3[1] =  0;
 
                /* steer */
-                in_a4[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
+                in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
 
                /* thrust and fire */
-                val = ((input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127));
+                val = ((input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127));
                 if(val < -2) {
                         in_a3[0] = 256 - val;
                 } 
@@ -1385,14 +1384,13 @@ void retro_init(void)
        bool found_bios = false;
 
 #ifdef _3DS
-   ctr_svchack_init_success = ctr_svchack_init();
    psxMapHook = pl_3ds_mmap;
    psxUnmapHook = pl_3ds_munmap;
 #endif
        ret = emu_core_preinit();
 #ifdef _3DS
    /* emu_core_preinit sets the cpu to dynarec */
-   if(!ctr_svchack_init_success)
+   if(!__ctr_svchax)
       Config.Cpu = CPU_INTERPRETER;
 #endif
        ret |= emu_core_init();
@@ -1444,9 +1442,8 @@ void retro_init(void)
        /* Set how much slower PSX CPU runs * 100 (so that 200 is 2 times)
         * we have to do this because cache misses and some IO penalties
         * are not emulated. Warning: changing this may break compatibility. */
-#if !defined(__arm__) || defined(__ARM_ARCH_7A__)
        cycle_multiplier = 175;
-#else
+#ifdef HAVE_PRE_ARMV7
        cycle_multiplier = 200;
 #endif
        pl_rearmed_cbs.gpu_peops.iUseDither = 1;