X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=frontend%2Flibretro.c;h=d6922cb392ecf79ec065b18b6189b891bdaeb4d1;hb=61c4962abc49e430aabea5e565d93436a57cfa0a;hp=29645875e8e31a066735194fb7cd46637d72e1c5;hpb=0b7f536b486f3f411651573009c3da6063b560ea;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index 29645875..d6922cb3 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; @@ -55,10 +53,19 @@ extern char Mcd1Data[MCD_SIZE]; extern char McdDisable[2]; /* PCSX ReARMed core calls and stuff */ -int in_type1, in_type2; -int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; -int in_a3[2] = { 127, 127 }, in_a4[2] = { 127, 127 }; -int in_keystate; +//int in_type1, in_type2; +//int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; +//int in_a3[2] = { 127, 127 }, in_a4[2] = { 127, 127 }; +//int in_keystate; + +int in_type[8]; +int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; +int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; +unsigned short in_keystate[8]; + + + + int in_enable_vibration = 1; /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */ @@ -194,7 +201,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 +214,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 +232,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 +244,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 +336,14 @@ 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" }, + { "pcsx_rearmed_pad3type", "Pad 3 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad4type", "Pad 4 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad5type", "Pad 5 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad6type", "Pad 6 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad7type", "Pad 7 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad8type", "Pad 8 Type; standard|analog|negcon" }, #ifndef DRC_DISABLE { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" }, #endif @@ -365,6 +378,7 @@ unsigned retro_api_version(void) void retro_set_controller_port_device(unsigned port, unsigned device) { + printf("port %u device %u",port,device); } void retro_get_system_info(struct retro_system_info *info) @@ -1047,7 +1061,6 @@ static void update_variables(bool in_flight) var.value = NULL; var.key = "pcsx_rearmed_region"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { Config.PsxAuto = 0; @@ -1061,24 +1074,100 @@ static void update_variables(bool in_flight) var.value = NULL; var.key = "pcsx_rearmed_pad1type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { - in_type1 = PSE_PAD_TYPE_STANDARD; + in_type[0] = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) - in_type1 = PSE_PAD_TYPE_ANALOGPAD; + in_type[0] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[0] = PSE_PAD_TYPE_NEGCON; } var.value = NULL; var.key = "pcsx_rearmed_pad2type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { - in_type2 = PSE_PAD_TYPE_STANDARD; + in_type[1] = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) - in_type2 = PSE_PAD_TYPE_ANALOGPAD; + in_type[1] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[1] = PSE_PAD_TYPE_NEGCON; } + var.value = NULL; + var.key = "pcsx_rearmed_pad3type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[2] = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type[2] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[2] = PSE_PAD_TYPE_NEGCON; + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad4type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ + in_type[3] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[3] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[3] = PSE_PAD_TYPE_NEGCON; + } + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad5type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[4] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[4] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[4] = PSE_PAD_TYPE_NEGCON; + } + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad6type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ + in_type[5] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[5] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[5] = PSE_PAD_TYPE_NEGCON; + } + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad7type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ + in_type[6] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[6] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[6] = PSE_PAD_TYPE_NEGCON; + } + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad8type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ + in_type[7] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[7] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[7] = PSE_PAD_TYPE_NEGCON; + } + } + + + #ifdef __ARM_NEON__ var.value = "NULL"; var.key = "pcsx_rearmed_neon_interlace_enable"; @@ -1134,7 +1223,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,6 +1304,7 @@ static void update_variables(bool in_flight) void retro_run(void) { + int i; input_poll_cb(); @@ -1223,29 +1313,46 @@ void retro_run(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(true); - in_keystate = 0; - for (i = 0; i < RETRO_PSX_MAP_LEN; i++) - if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) - in_keystate |= retro_psx_map[i]; - in_keystate <<= 16; - for (i = 0; i < RETRO_PSX_MAP_LEN; i++) - if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i)) - in_keystate |= retro_psx_map[i]; - if (in_type1 == PSE_PAD_TYPE_ANALOGPAD) + + // récupération de l'état des boutons par libretro + +// in_keystate = 0; +// for (i = 0; i < RETRO_PSX_MAP_LEN; i++){ +// if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) +// in_keystate |= retro_psx_map[i]; +// +// } +// in_keystate <<= 16; +// for (i = 0; i < RETRO_PSX_MAP_LEN; i++) +// if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i)) +// in_keystate |= retro_psx_map[i]; + + //reset all keystate, query from libretro for keystate + int j; + for(i=0;i<8;i++){ + in_keystate[i] = 0; + //query from libretro for keystate + for (j = 0; j < RETRO_PSX_MAP_LEN; j++){ + if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, j)) + in_keystate[i] |= retro_psx_map[j]; + } + } + + if (in_type[0] == 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; - in_a1[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; - in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_a2[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_left[0][0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_left[0][1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_right[0][0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_right[0][1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; } - if (in_type2 == PSE_PAD_TYPE_ANALOGPAD) + if (in_type[1] == PSE_PAD_TYPE_ANALOGPAD) { - in_a3[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_a3[1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; - in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_a4[1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_left[1][0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_left[1][1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_right[1][0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_right[1][1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; } stop = 0; @@ -1325,14 +1432,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();