Michael Jimenez avatar Michael Jimenez committed b0802dd

fix for Capcom protected games (SFAA, VDC)

Comments (0)

Files changed (3)

 	/* restore the original stack pointer */
 	daddu	$sp, $a2, $zero
 
+#ifdef LOAD_EECORE_DOWN
+	lui	$v0, 0x000b
+#else
+	lui	$v0, 0x0008
+	ori	$v0, $v0, 0x8000
+#endif
+1:	
+	sq	$zero, 0x0000($v0)
+	sq	$zero, 0x0010($v0)
+	sq	$zero, 0x0020($v0)
+	sq	$zero, 0x0030($v0)
+	addiu	$v0, $v0, 0x0040
+#ifdef LOAD_EECORE_DOWN
+	lui	$v1, 0x0010
+#else
+	lui	$v1, 0x000e
+	ori	$v1, $v1, 0x7000
+#endif
+	sltu	$v1, $v0, $v1
+	bne	$v1, $zero, 1b
+
+	/* FlushCache */
+	daddu	$a0, $zero, $zero
+	addiu	$v1, $zero, __NR_FlushCache
+	syscall
+	addiu	$a0, $zero, 2
+	addiu	$v1, $zero, __NR_FlushCache
+	syscall
+
 	jr	$ra
 	addiu	$v0, $zero, 1
 
 				// some games like SOCOM3 uses faulty IOPRP path like "cdrom0:\RUN\IRX\DNAS300.IMGG;1"
 				// some games from Army Men series uses faulty IOPRP path like "cdrom0:\IRX\IOPRP205.IMG.IMG;1"
 				// this part ensure it will not get stucked on red screen
-				char *p;
+				char *p = NULL;
 				if (retry_count == 1)
 					p = _strrchr(ioprp_path, '.');
 				else if (retry_count == 2)
 	game_patch_t patch;
 } patchlist_t;
 
-static patchlist_t patch_list[35] = {
+static patchlist_t patch_list[38] = {
 	{ "SLES_524.58", USB_MODE, { 0xdeadbee0, 0x00000000, 0x00000000 }}, // Disgaea Hour of Darkness PAL - disable cdvd timeout stuff
 	{ "SLUS_206.66", USB_MODE, { 0xdeadbee0, 0x00000000, 0x00000000 }}, // Disgaea Hour of Darkness NTSC U - disable cdvd timeout stuff
 	{ "SLPS_202.51", USB_MODE, { 0xdeadbee0, 0x00000000, 0x00000000 }}, // Makai Senki Disgaea NTSC J - disable cdvd timeout stuff
 	{ "SLPS_203.45", USB_MODE, { 0xdeadbee0, 0x00000000, 0x00000000 }}, // Phantom Brave NTSC J - disable cdvd timeout stuff
 	{ "SLPS_203.44", USB_MODE, { 0xdeadbee0, 0x00000000, 0x00000000 }}, // Phantom Brave (limited edition) NTSC J - disable cdvd timeout stuff
 	{ "SLPS_731.08", USB_MODE, { 0xdeadbee0, 0x00000000, 0x00000000 }}, // Phantom Brave: 2-shuume Hajime Mashita (PlayStation 2 the Best) NTSC J - disable cdvd timeout stuff
+	{ "SLUS_213.17", ALL_MODE, { 0xbabecafe, 0x00149210, 0x00000000 }}, // SFA anthology US
+	{ "SLES_540.85", ALL_MODE, { 0xbabecafe, 0x00148db0, 0x00000000 }}, // SFA anthology EUR
+	{ "SLPM_659.98", ALL_MODE, { 0xbabecafe, 0x00146fd0, 0x00000000 }}, // Vampire: Darkstakers collection JP
 	{ "SLUS_212.00", USB_MODE, { 0xdeadbee1, 0x00000000, 0x00000000 }}, // Armored Core Nine Breaker NTSC U - skip failing case on binding a RPC server
 	{ "SLES_538.19", USB_MODE, { 0xdeadbee1, 0x00000000, 0x00000000 }}, // Armored Core Nine Breaker PAL - skip failing case on binding a RPC server
 	{ "SLPS_254.08", USB_MODE, { 0xdeadbee1, 0x00000000, 0x00000000 }}, // Armored Core Nine Breaker NTSC J - skip failing case on binding a RPC server
 	_sw(JAL((u32)delayed_cdRead), patch_addr);
 }
 
+
+static int (*capcom_lmb)(void *modpack_addr, int mod_index, int mod_argc, char **mod_argv);
+
+static void apply_capcom_protection_patch(void *modpack_addr, int mod_index, int mod_argc, char **mod_argv)
+{
+	u32 iop_addr = _lw((u32)modpack_addr + (mod_index << 3) + 8);
+	u32 opcode = 0x10000025;
+	smem_write((void *)(iop_addr+0x270), (void *)&opcode, sizeof(opcode));
+	FlushCache(0);
+	FlushCache(2);
+
+	capcom_lmb(modpack_addr, mod_index, mod_argc, mod_argv);
+}
+
+static void generic_capcom_protection_patches(u32 patch_addr)
+{
+	capcom_lmb = (void *)FNADDR(_lw(patch_addr));
+	_sw(JAL((u32)apply_capcom_protection_patch), patch_addr);
+}
+
+
 void apply_patches(void)
 {
 	patchlist_t *p = (patchlist_t *)&patch_list[0];
 				AC9B_generic_patches(); // Armored Core 9 Breaker USB generic patch
 			else if (p->patch.addr == 0xdeadbee2)
 				generic_delayed_cdRead_patches(p->patch.check, p->patch.val); // slow reads generic patch
+			else if (p->patch.addr == 0xbabecafe)
+				generic_capcom_protection_patches(p->patch.val); // Capcom anti cdvd emulator protection patch
 
 			// non-generic patches
 			else if (_lw(p->patch.addr) == p->patch.check)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.