From 2fd18851754e715bd55e7040aaace2590ac0d8cb Mon Sep 17 00:00:00 2001 From: ds22x <45218067+ds22x@users.noreply.github.com> Date: Sat, 20 Jul 2024 16:12:24 +0200 Subject: [PATCH 1/2] Add Force VDP Mode option & update option description (#565) --- libretro/libretro.c | 81 ++++++++++++++++++++++++++++++++ libretro/libretro_core_options.h | 15 ++++++ 2 files changed, 96 insertions(+) diff --git a/libretro/libretro.c b/libretro/libretro.c index c632d64..a581879 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -1455,6 +1455,87 @@ static void check_variables(bool first_run) } } + var.key = "genesis_plus_gx_vdp_mode"; + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); + { + orig_value = config.vdp_mode; + if (var.value && !strcmp(var.value, "60hz")) + config.vdp_mode = 1; + else if (var.value && !strcmp(var.value, "50hz")) + config.vdp_mode = 2; + else + config.vdp_mode = 0; + + if (orig_value != config.vdp_mode) + { + if (system_hw) + { + get_region(NULL); + + if ((system_hw == SYSTEM_MCD) || ((system_hw & SYSTEM_SMS) && config.bios)) + { + /* system with region BIOS should be reinitialized */ + reinit = true; + } + else + { + static const uint16 vc_table[4][2] = + { + /* NTSC, PAL */ + {0xDA , 0xF2}, /* Mode 4 (192 lines) */ + {0xEA , 0x102}, /* Mode 5 (224 lines) */ + {0xDA , 0xF2}, /* Mode 4 (192 lines) */ + {0x106, 0x10A} /* Mode 5 (240 lines) */ + }; + + /* framerate might have changed, reinitialize audio timings */ + audio_set_rate(44100, 0); + + /* reinitialize I/O region register */ + if (system_hw == SYSTEM_MD) + { + io_reg[0x00] = 0x20 | region_code | (config.bios & 1); + } + else if (system_hw == SYSTEM_MCD) + { + io_reg[0x00] = region_code | (config.bios & 1); + } + else + { + io_reg[0x00] = 0x80 | (region_code >> 1); + } + + /* reinitialize VDP timings */ + lines_per_frame = vdp_pal ? 313 : 262; + + /* reinitialize NTSC/PAL mode in VDP status */ + if (system_hw & SYSTEM_MD) + { + status = (status & ~1) | vdp_pal; + } + + /* reinitialize VC max value */ + switch (bitmap.viewport.h) + { + case 192: + vc_max = vc_table[0][vdp_pal]; + break; + case 224: + vc_max = vc_table[1][vdp_pal]; + break; + case 240: + vc_max = vc_table[3][vdp_pal]; + break; + } + + update_viewports = true; + } + + update_frameskip = true; + } + } + } + var.key = "genesis_plus_gx_force_dtack"; environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); { diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h index 55928c1..d1cef8a 100644 --- a/libretro/libretro_core_options.h +++ b/libretro/libretro_core_options.h @@ -131,6 +131,21 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "auto" }, + { + "genesis_plus_gx_vdp_mode", + "Force VDP Mode", + NULL, + "Overrides the VDP mode to force it to run at either NTSC 60Hz or PAL 50Hz, regardless of system region.", + NULL, + "system", + { + { "auto", "Disabled" }, + { "60hz", "NTSC (60Hz)" }, + { "50hz", "PAL (50Hz)" }, + { NULL, NULL }, + }, + "auto" + }, { "genesis_plus_gx_bios", "System Boot ROM", From 15bb7aca8f694e891b54f93c6031335dfb1a7270 Mon Sep 17 00:00:00 2001 From: techmetx11 <114311037+techmetx11@users.noreply.github.com> Date: Sat, 10 Aug 2024 18:44:21 +0000 Subject: [PATCH 2/2] Add support for Shi San Zhang Ma Jiang: Zhong Guo Mei Nv Pian copy protection (#570) * Add support for Shi San Zhang Ma Jiang: Zhong Guo Mei Nv Pian copy protection * Move the entry closer to the Taiwanese unlicensed games that have the same mapper, and use the most similar set of values/address to the other games with the same mapper --- core/cart_hw/md_cart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/cart_hw/md_cart.c b/core/cart_hw/md_cart.c index a5fdb0f..766289d 100644 --- a/core/cart_hw/md_cart.c +++ b/core/cart_hw/md_cart.c @@ -224,7 +224,8 @@ static const md_entry_t rom_database[] = {0x0000,0x19ff,0x40,0x40,{{0x63,0x98,0xc9,0x18},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x400004,0x400006},0,0,NULL,m68k_unused_8_w,default_regs_r,NULL}}, /* Soul Blade */ {0x0000,0x0c5b,0x40,0x40,{{0x63,0x98,0xc9,0xf0},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x400004,0x400006},0,0,NULL,m68k_unused_8_w,default_regs_r,NULL}}, - +/* Shi San Zhang Ma Jiang: Zhong Guo Mei Nv Pian (only $400004 is checked, other addresses/values are assumed) */ + {0xffff,0xd41d,0x40,0x40,{{0x63,0x98,0xc9,0xf0},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x400004,0x400006},0,0,NULL,m68k_unused_8_w,default_regs_r,NULL}}, /* King of Fighter 98 */ {0x0000,0xd0a0,0x48,0x4f,{{0x00,0x00,0xaa,0xf0},{0xffffff,0xffffff,0xfc0000,0xfc0000},{0x000000,0x000000,0x480000,0x4c0000},0,0,NULL,m68k_unused_8_w,default_regs_r,NULL}},