319 |
|
// Don't call FE0A opcode (7.6, 7.6.1, 8.0, 8.1, 8.5, 8.6) |
320 |
|
p[1] = 0x7000; |
321 |
|
D(bug(" patch 3 applied\n")); |
322 |
+ |
} else if (p[0] == 0x6c00 && p[1] == 0x016a && p[2] == 0x2278 && p[3] == 0x0134) { |
323 |
+ |
// We don't have SonyVars (8.6) |
324 |
+ |
p[-4] = 0x21fc; // move.l $40810000,($0000) |
325 |
+ |
p[-3] = 0x4081; |
326 |
+ |
p[-2] = 0x0000; |
327 |
+ |
p[-1] = 0x0000; |
328 |
+ |
p[0] = 0x6000; |
329 |
+ |
D(bug(" patch 4 applied\n")); |
330 |
|
} |
331 |
|
p++; |
332 |
|
} |
488 |
|
} |
489 |
|
p++; |
490 |
|
} |
491 |
+ |
|
492 |
+ |
} else if (type == FOURCC('s','c','o','d') && id == -16465) { |
493 |
+ |
D(bug("scod -16465 found\n")); |
494 |
+ |
|
495 |
+ |
// Don't crash in Process Manager on reset/shutdown (8.6) |
496 |
+ |
static const uint8 dat[] = {0x4e, 0x56, 0x00, 0x00, 0x48, 0xe7, 0x03, 0x18, 0x2c, 0x2e, 0x00, 0x10}; |
497 |
+ |
base = find_rsrc_data((uint8 *)p, size, dat, sizeof(dat)); |
498 |
+ |
if (base) { |
499 |
+ |
p16 = (uint16 *)((uint32)p + base); |
500 |
+ |
p16[0] = 0x7000; // moveq #0,d0 |
501 |
+ |
p16[1] = M68K_RTS; |
502 |
+ |
D(bug(" patch 1 applied\n")); |
503 |
+ |
} |
504 |
|
} |
505 |
|
} |
506 |
|
|
705 |
|
D(bug("PatchNativeResourceManager\n")); |
706 |
|
|
707 |
|
// Patch native GetResource() |
708 |
< |
uint32 **upp = *(uint32 ***)0x1480; |
708 |
> |
uint32 **upp = (uint32 **)(uintptr)ReadMacInt32(0x1480); |
709 |
|
if (((uint32)upp & 0xffc00000) == ROM_BASE) |
710 |
|
return; |
711 |
|
uint32 *tvec = upp[5]; |
712 |
|
D(bug(" GetResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
713 |
|
*(uint32 *)XLM_RES_LIB_TOC = tvec[1]; |
714 |
|
*(uint32 *)XLM_GET_RESOURCE = tvec[0]; |
715 |
+ |
#if EMULATED_PPC |
716 |
+ |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_GET_RESOURCE); |
717 |
+ |
#else |
718 |
|
#ifdef __BEOS__ |
719 |
|
uint32 *tvec2 = (uint32 *)get_resource; |
720 |
|
tvec[0] = tvec2[0]; |
722 |
|
#else |
723 |
|
tvec[0] = (uint32)get_resource; |
724 |
|
#endif |
725 |
+ |
#endif |
726 |
|
|
727 |
|
// Patch native Get1Resource() |
728 |
|
upp = *(uint32 ***)0xe7c; |
729 |
|
tvec = upp[5]; |
730 |
|
D(bug(" Get1Resource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
731 |
|
*(uint32 *)XLM_GET_1_RESOURCE = tvec[0]; |
732 |
+ |
#if EMULATED_PPC |
733 |
+ |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_GET_1_RESOURCE); |
734 |
+ |
#else |
735 |
|
#ifdef __BEOS__ |
736 |
|
tvec2 = (uint32 *)get_1_resource; |
737 |
|
tvec[0] = tvec2[0]; |
739 |
|
#else |
740 |
|
tvec[0] = (uint32)get_1_resource; |
741 |
|
#endif |
742 |
+ |
#endif |
743 |
|
|
744 |
|
// Patch native GetIndResource() |
745 |
|
upp = *(uint32 ***)0x1474; |
746 |
|
tvec = upp[5]; |
747 |
|
D(bug(" GetIndResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
748 |
|
*(uint32 *)XLM_GET_IND_RESOURCE = tvec[0]; |
749 |
+ |
#if EMULATED_PPC |
750 |
+ |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_GET_IND_RESOURCE); |
751 |
+ |
#else |
752 |
|
#ifdef __BEOS__ |
753 |
|
tvec2 = (uint32 *)get_ind_resource; |
754 |
|
tvec[0] = tvec2[0]; |
756 |
|
#else |
757 |
|
tvec[0] = (uint32)get_ind_resource; |
758 |
|
#endif |
759 |
+ |
#endif |
760 |
|
|
761 |
|
// Patch native Get1IndResource() |
762 |
|
upp = *(uint32 ***)0xe38; |
763 |
|
tvec = upp[5]; |
764 |
|
D(bug(" Get1IndResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
765 |
|
*(uint32 *)XLM_GET_1_IND_RESOURCE = tvec[0]; |
766 |
+ |
#if EMULATED_PPC |
767 |
+ |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_GET_1_IND_RESOURCE); |
768 |
+ |
#else |
769 |
|
#ifdef __BEOS__ |
770 |
|
tvec2 = (uint32 *)get_1_ind_resource; |
771 |
|
tvec[0] = tvec2[0]; |
773 |
|
#else |
774 |
|
tvec[0] = (uint32)get_1_ind_resource; |
775 |
|
#endif |
776 |
+ |
#endif |
777 |
|
|
778 |
|
// Patch native RGetResource() |
779 |
|
upp = *(uint32 ***)0xe30; |
780 |
|
tvec = upp[5]; |
781 |
|
D(bug(" RGetResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
782 |
|
*(uint32 *)XLM_R_GET_RESOURCE = tvec[0]; |
783 |
+ |
#if EMULATED_PPC |
784 |
+ |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_R_GET_RESOURCE); |
785 |
+ |
#else |
786 |
|
#ifdef __BEOS__ |
787 |
|
tvec2 = (uint32 *)r_get_resource; |
788 |
|
tvec[0] = tvec2[0]; |
790 |
|
#else |
791 |
|
tvec[0] = (uint32)r_get_resource; |
792 |
|
#endif |
793 |
+ |
#endif |
794 |
|
} |