X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Flibretro.c;h=a9b6e433c7a32880dbabe8aea726f5d39fd0dbc3;hb=f72db18e0c39a5bf115f493767decc409e10f94a;hp=69fad2a3785f9c4ca6be53d6eba74c3e0ddc56a4;hpb=fc99395c2d7efbbaa0663feed47dc89a54e49506;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index 69fad2a3..a9b6e433 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -29,9 +29,7 @@ #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 +192,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 +205,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 +223,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 +235,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; @@ -329,8 +327,8 @@ void retro_set_environment(retro_environment_t cb) static const struct retro_variable vars[] = { { "pcsx_rearmed_frameskip", "Frameskip; 0|1|2|3" }, { "pcsx_rearmed_region", "Region; Auto|NTSC|PAL" }, - { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog" }, - { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog" }, + { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog|negcon" }, #ifndef DRC_DISABLE { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" }, #endif @@ -1067,6 +1065,8 @@ static void update_variables(bool in_flight) in_type1 = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) in_type1 = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type1 = PSE_PAD_TYPE_NEGCON; } var.value = NULL; @@ -1077,6 +1077,9 @@ static void update_variables(bool in_flight) in_type2 = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) in_type2 = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type2 = PSE_PAD_TYPE_NEGCON; + } #ifdef __ARM_NEON__ @@ -1134,7 +1137,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 @@ -1215,7 +1218,7 @@ static void update_variables(bool in_flight) void retro_run(void) { - int i; + int i, val; input_poll_cb(); @@ -1232,6 +1235,7 @@ void retro_run(void) if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i)) in_keystate |= retro_psx_map[i]; + if (in_type1 == PSE_PAD_TYPE_ANALOGPAD) { in_a1[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; @@ -1248,6 +1252,60 @@ void retro_run(void) in_a4[1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; } + + if (in_type1 == PSE_PAD_TYPE_NEGCON) + { + /* left brake */ + if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12)) + in_a1[1] = 255; + else + in_a1[1] = 0; + + /* steer */ + in_a2[0] = (input_state_cb(0, 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)); + if(val < -2) { + in_a1[0] = 256 - val; + } + if (val > 2) { + in_a2[1] = val; + } + if(val >= -2 && val <= 2) + { + in_a2[1] = 0; + in_a1[0] = 0; + } + } + + if (in_type2 == PSE_PAD_TYPE_NEGCON) + { + /* left brake */ + 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(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + + /* thrust and fire */ + 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; + } + if (val > 2) { + in_a4[1] = val; + } + if(val >= -2 && val <= 2) + { + in_a4[1] = 0; + in_a3[0] = 0; + } + } + + stop = 0; psxCpu->Execute(); @@ -1280,7 +1338,7 @@ static bool try_use_bios(const char *path) return true; } -#if 1 +#ifndef VITA #include #include @@ -1325,18 +1383,24 @@ 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_svchax) + Config.Cpu = CPU_INTERPRETER; +#endif ret |= emu_core_init(); if (ret != 0) { SysPrintf("PCSX init failed.\n"); exit(1); } -#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) +#ifdef _3DS + vout_buf = linearMemAlign(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2, 0x80); +#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && !defined(VITA) posix_memalign(&vout_buf, 16, VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); #else vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); @@ -1402,6 +1466,18 @@ void retro_init(void) void retro_deinit(void) { SysClose(); +#ifdef _3DS + linearFree(vout_buf); +#else free(vout_buf); +#endif vout_buf = NULL; } + +#ifdef VITA +#include +int usleep (unsigned long us) +{ + sceKernelDelayThread(us); +} +#endif