1 |
|
/* |
2 |
|
* rsrc_patches.cpp - Resource patches |
3 |
|
* |
4 |
< |
* SheepShaver (C) 1997-2002 Christian Bauer and Marc Hellwig |
4 |
> |
* SheepShaver (C) 1997-2005 Christian Bauer and Marc Hellwig |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
117 |
|
D(bug("vCheckLoad %c%c%c%c (%08x) ID %d, data %p, size %d\n", type >> 24, (type >> 16) & 0xff, (type >> 8) & 0xff, type & 0xff, type, id, p, size)); |
118 |
|
|
119 |
|
// Don't modify resources in ROM |
120 |
< |
if ((uintptr)p >= ROM_BASE && (uintptr)p <= (ROM_BASE + ROM_SIZE)) |
120 |
> |
if ((uintptr)p >= (uintptr)ROMBaseHost && (uintptr)p <= (uintptr)(ROMBaseHost + ROM_SIZE)) |
121 |
|
return; |
122 |
|
|
123 |
|
if (type == FOURCC('b','o','o','t') && id == 3) { |
136 |
|
// Check when ntrb 17 is installed (for native Resource Manager patch) (7.6, 7.6.1, 8.0, 8.1) |
137 |
|
p[7] = htons(M68K_EMUL_OP_NTRB_17_PATCH); |
138 |
|
D(bug(" patch 3 applied\n")); |
139 |
< |
} else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x61ff)) { |
139 |
> |
} else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x61ff) && PM(8,0x245f)) { |
140 |
|
// Check when ntrb 17 is installed (for native Resource Manager patch) (8.5, 8.6) |
141 |
|
p[8] = htons(M68K_EMUL_OP_NTRB_17_PATCH); |
142 |
|
D(bug(" patch 4 applied\n")); |
143 |
+ |
} else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x61ff) && PM(7,0x301f)) { |
144 |
+ |
// Check when ntrb 17 is installed (for native Resource Manager patch) (9.0) |
145 |
+ |
p[7] = htons(M68K_EMUL_OP_NTRB_17_PATCH4); |
146 |
+ |
p[8] = htons(ntohs(p[8]) & 0xf0ff); // bra |
147 |
+ |
D(bug(" patch 8 applied\n")); |
148 |
|
} else if (PM(0,0x0c39) && PM(1,0x0001) && PM(2,0xf800) && PM(3,0x0008) && PM(4,0x6f00)) { |
149 |
|
// Don't read from 0xf8000008 (8.5 with Zanzibar ROM, 8.6) |
150 |
|
p[0] = htons(M68K_NOP); |
168 |
|
p[5] = htons(0x6010); // bra |
169 |
|
D(bug(" patch 7 applied\n")); |
170 |
|
} |
171 |
+ |
} else if (PM(0,0x2f3c) && PM(1,0x7665) && PM(2,0x7273) && PM(3,0x3f3c) && PM(4,0x0001) && PM(10,0x2041) && PM(11,0x2248) && PM(12,0x2050) && PM(20,0x7066) && PM(21,0xa9c9)) { |
172 |
+ |
// Check when vers 1 is installed (for safe abort if MacOS < 8.1 is used with a NewWorld ROM) |
173 |
+ |
p[10] = htons(M68K_EMUL_OP_CHECK_SYSV); |
174 |
+ |
p[11] = htons(0x4a81); // tst.l d1 |
175 |
+ |
p[12] = htons(0x670e); // beq.s <SysError #dsOldSystem> |
176 |
+ |
D(bug(" patch 9 applied\n")); |
177 |
|
} |
178 |
|
p++; |
179 |
|
} |
190 |
|
D(bug(" patch 1 applied\n")); |
191 |
|
} |
192 |
|
|
193 |
+ |
} else if (type == FOURCC('p','t','c','h') && id == 156) { |
194 |
+ |
D(bug("ptch 156 found\n")); |
195 |
+ |
size >>= 1; |
196 |
+ |
while (size--) { |
197 |
+ |
if (PM(0,0x4e56) && PM(1,0xfffa) && PM(2,0x48e7) && PM(3,0x1f18) && PM(4,0x7800) && PM(5,0x267c) && PM(6,0x6900) && PM(7,0x0000)) { |
198 |
+ |
// Don't call FE0A opcode (9.0) |
199 |
+ |
p[0] = htons(0x7000); // moveq #0,d0 |
200 |
+ |
p[1] = htons(M68K_RTS); |
201 |
+ |
D(bug(" patch 1 applied\n")); |
202 |
+ |
break; |
203 |
+ |
} |
204 |
+ |
p++; |
205 |
+ |
} |
206 |
+ |
|
207 |
|
} else if (type == FOURCC('p','t','c','h') && id == 420) { |
208 |
|
D(bug("ptch 420 found\n")); |
209 |
|
size >>= 1; |
457 |
|
p[(0x378 + 0x6c0) >> 1] = htons(0x4e80); // blr |
458 |
|
p[(0x37a + 0x6c0) >> 1] = htons(0x0020); |
459 |
|
D(bug(" patch 2 applied\n")); |
460 |
+ |
} else if (p[(0x374 + 0x510) >> 1] == htons(0x7c08) && p[(0x376 + 0x510) >> 1] == htons(0x02a6)) { |
461 |
+ |
// Don't overwrite our serial drivers (9.0) |
462 |
+ |
p[(0x374 + 0x510) >> 1] = htons(0x4e80); // blr |
463 |
+ |
p[(0x376 + 0x510) >> 1] = htons(0x0020); |
464 |
+ |
D(bug(" patch 3 applied\n")); |
465 |
|
} |
466 |
|
|
467 |
|
} else if (type == FOURCC('c','i','t','t') && id == 45) { |
479 |
|
|
480 |
|
} else if (type == FOURCC('t','h','n','g')) { |
481 |
|
// Collect info about used audio sifters |
482 |
< |
uint32 thing = (uintptr)p; |
482 |
> |
uint32 thing = Host2MacAddr((uint8 *)p); |
483 |
|
uint32 c_type = ReadMacInt32(thing); |
484 |
|
uint32 sub_type = ReadMacInt32(thing + 4); |
485 |
|
if (c_type == FOURCC('s','d','e','v') && sub_type == FOURCC('s','i','n','g')) { |
537 |
|
p16[1] = htons(M68K_RTS); |
538 |
|
D(bug(" patch 1 applied\n")); |
539 |
|
} |
540 |
+ |
|
541 |
+ |
} else if (type == FOURCC('N','O','b','j') && id == 100) { |
542 |
+ |
D(bug("NObj 100 found\n")); |
543 |
+ |
|
544 |
+ |
// Don't access VIA registers in MacBench 5.0 |
545 |
+ |
static const uint8 dat1[] = {0x7c, 0x08, 0x02, 0xa6, 0xbf, 0x01, 0xff, 0xe0, 0x90, 0x01, 0x00, 0x08}; |
546 |
+ |
base = find_rsrc_data((uint8 *)p, size, dat1, sizeof(dat1)); |
547 |
+ |
if (base) { |
548 |
+ |
p[(base + 0x00) >> 1] = htons(0x3860); // li r3,0 |
549 |
+ |
p[(base + 0x02) >> 1] = htons(0x0000); |
550 |
+ |
p[(base + 0x04) >> 1] = htons(0x4e80); // blr |
551 |
+ |
p[(base + 0x06) >> 1] = htons(0x0020); |
552 |
+ |
D(bug(" patch 1 applied\n")); |
553 |
+ |
} |
554 |
+ |
static const uint8 dat2[] = {0x7c, 0x6c, 0x1b, 0x78, 0x7c, 0x8b, 0x23, 0x78, 0x38, 0xc0, 0x3f, 0xfd}; |
555 |
+ |
base = find_rsrc_data((uint8 *)p, size, dat2, sizeof(dat2)); |
556 |
+ |
if (base) { |
557 |
+ |
p[(base + 0x00) >> 1] = htons(0x3860); // li r3,0 |
558 |
+ |
p[(base + 0x02) >> 1] = htons(0x0000); |
559 |
+ |
p[(base + 0x04) >> 1] = htons(0x4e80); // blr |
560 |
+ |
p[(base + 0x06) >> 1] = htons(0x0020); |
561 |
+ |
D(bug(" patch 2 applied\n")); |
562 |
+ |
} |
563 |
+ |
|
564 |
+ |
} else if (type == FOURCC('C','O','D','E') && id == 27 && size == 25024) { |
565 |
+ |
D(bug("CODE 27 found [Apple Personal Diagnostics]\n")); |
566 |
+ |
|
567 |
+ |
// Don't access FCBs directly in Apple Personal Diagnostics (MacOS 9) |
568 |
+ |
// FIXME: this should not be called in the first place, use UTResolveFCB? |
569 |
+ |
static const uint8 dat[] = {0x2d, 0x78, 0x03, 0x4e, 0xff, 0xf8, 0x20, 0x6e, 0xff, 0xf8}; |
570 |
+ |
base = find_rsrc_data((uint8 *)p, size, dat, sizeof(dat)); |
571 |
+ |
if (base |
572 |
+ |
&& ReadMacInt16(0x3f6) == 4 /* FSFCBLen */ |
573 |
+ |
&& p[(base + 0x1a) >> 1] == htons(0x605e) |
574 |
+ |
&& p[(base + 0x80) >> 1] == htons(0x7000)) |
575 |
+ |
{ |
576 |
+ |
p[(base + 0x1a) >> 1] = htons(0x6064); |
577 |
+ |
D(bug(" patch1 applied\n")); |
578 |
+ |
} |
579 |
|
} |
580 |
|
} |
581 |
|
|
582 |
|
|
583 |
|
/* |
584 |
+ |
* Resource patches via GetNamedResource() and Get1NamedResource() |
585 |
+ |
*/ |
586 |
+ |
|
587 |
+ |
void CheckLoad(uint32 type, const char *name, uint8 *p, uint32 size) |
588 |
+ |
{ |
589 |
+ |
uint16 *p16; |
590 |
+ |
uint32 base; |
591 |
+ |
D(bug("vCheckLoad %c%c%c%c (%08x) name \"%*s\", data %p, size %d\n", type >> 24, (type >> 16) & 0xff, (type >> 8) & 0xff, type & 0xff, type, name[0], &name[1], p, size)); |
592 |
+ |
|
593 |
+ |
// Don't modify resources in ROM |
594 |
+ |
if ((uintptr)p >= (uintptr)ROMBaseHost && (uintptr)p <= (uintptr)(ROMBaseHost + ROM_SIZE)) |
595 |
+ |
return; |
596 |
+ |
} |
597 |
+ |
|
598 |
+ |
|
599 |
+ |
/* |
600 |
|
* Native Resource Manager patches |
601 |
|
*/ |
602 |
|
|
614 |
|
return; |
615 |
|
uint32 size = ReadMacInt32(p - 2 * 4) & 0xffffff; |
616 |
|
|
617 |
< |
CheckLoad(type, id, (uint16 *)p, size); |
617 |
> |
CheckLoad(type, id, (uint16 *)Mac2HostAddr(p), size); |
618 |
> |
} |
619 |
> |
|
620 |
> |
#ifdef __BEOS__ |
621 |
> |
static |
622 |
> |
#else |
623 |
> |
extern "C" |
624 |
> |
#endif |
625 |
> |
void named_check_load_invoc(uint32 type, uint32 name, uint32 h) |
626 |
> |
{ |
627 |
> |
if (h == 0) |
628 |
> |
return; |
629 |
> |
uint32 p = ReadMacInt32(h); |
630 |
> |
if (p == 0) |
631 |
> |
return; |
632 |
> |
uint32 size = ReadMacInt32(p - 2 * 4) & 0xffffff; |
633 |
> |
|
634 |
> |
CheckLoad(type, (char *)Mac2HostAddr(name), Mac2HostAddr(p), size); |
635 |
|
} |
636 |
|
|
637 |
|
#ifdef __BEOS__ |
799 |
|
addi r1,r1,56+12 |
800 |
|
blr |
801 |
|
} |
802 |
+ |
|
803 |
+ |
static asm void **get_named_resource(register uint32 type, register uint32 name) |
804 |
+ |
{ |
805 |
+ |
// Create stack frame |
806 |
+ |
mflr r0 |
807 |
+ |
stw r0,8(r1) |
808 |
+ |
stwu r1,-(56+12)(r1) |
809 |
+ |
|
810 |
+ |
// Save type/ID |
811 |
+ |
stw r3,56(r1) |
812 |
+ |
stw r4,56+4(r1) |
813 |
+ |
|
814 |
+ |
// Call old routine |
815 |
+ |
lwz r0,XLM_GET_NAMED_RESOURCE |
816 |
+ |
lwz r2,XLM_RES_LIB_TOC |
817 |
+ |
mtctr r0 |
818 |
+ |
bctrl |
819 |
+ |
lwz r2,XLM_TOC // Get TOC |
820 |
+ |
stw r3,56+8(r1) // Save handle |
821 |
+ |
|
822 |
+ |
// Call CheckLoad |
823 |
+ |
lwz r3,56(r1) |
824 |
+ |
lwz r4,56+4(r1) |
825 |
+ |
lwz r5,56+8(r1) |
826 |
+ |
bl named_check_load_invoc |
827 |
+ |
lwz r3,56+8(r1) // Restore handle |
828 |
+ |
|
829 |
+ |
// Return to caller |
830 |
+ |
lwz r0,56+12+8(r1) |
831 |
+ |
mtlr r0 |
832 |
+ |
addi r1,r1,56+12 |
833 |
+ |
blr |
834 |
+ |
} |
835 |
+ |
|
836 |
+ |
static asm void **get_1_named_resource(register uint32 type, register uint32 name) |
837 |
+ |
{ |
838 |
+ |
// Create stack frame |
839 |
+ |
mflr r0 |
840 |
+ |
stw r0,8(r1) |
841 |
+ |
stwu r1,-(56+12)(r1) |
842 |
+ |
|
843 |
+ |
// Save type/ID |
844 |
+ |
stw r3,56(r1) |
845 |
+ |
stw r4,56+4(r1) |
846 |
+ |
|
847 |
+ |
// Call old routine |
848 |
+ |
lwz r0,XLM_GET_1_NAMED_RESOURCE |
849 |
+ |
lwz r2,XLM_RES_LIB_TOC |
850 |
+ |
mtctr r0 |
851 |
+ |
bctrl |
852 |
+ |
lwz r2,XLM_TOC // Get TOC |
853 |
+ |
stw r3,56+8(r1) // Save handle |
854 |
+ |
|
855 |
+ |
// Call CheckLoad |
856 |
+ |
lwz r3,56(r1) |
857 |
+ |
lwz r4,56+4(r1) |
858 |
+ |
lwz r5,56+8(r1) |
859 |
+ |
bl named_check_load_invoc |
860 |
+ |
lwz r3,56+8(r1) // Restore handle |
861 |
+ |
|
862 |
+ |
// Return to caller |
863 |
+ |
lwz r0,56+12+8(r1) |
864 |
+ |
mtlr r0 |
865 |
+ |
addi r1,r1,56+12 |
866 |
+ |
blr |
867 |
+ |
} |
868 |
|
#else |
869 |
|
// Routines in asm_linux.S |
870 |
|
extern "C" void get_resource(void); |
872 |
|
extern "C" void get_ind_resource(void); |
873 |
|
extern "C" void get_1_ind_resource(void); |
874 |
|
extern "C" void r_get_resource(void); |
875 |
+ |
extern "C" void get_named_resource(void); |
876 |
+ |
extern "C" void get_1_named_resource(void); |
877 |
|
#endif |
878 |
|
|
879 |
|
void PatchNativeResourceManager(void) |
884 |
|
uint32 upp = ReadMacInt32(0x1480); |
885 |
|
if ((upp & 0xffc00000) == ROM_BASE) |
886 |
|
return; |
887 |
< |
uint32 *tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
888 |
< |
D(bug(" GetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
889 |
< |
*(uint32 *)XLM_RES_LIB_TOC = tvec[1]; |
890 |
< |
*(uint32 *)XLM_GET_RESOURCE = tvec[0]; |
887 |
> |
uint32 tvec = ReadMacInt32(upp + 5 * 4); |
888 |
> |
D(bug(" GetResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4))); |
889 |
> |
WriteMacInt32(XLM_RES_LIB_TOC, ReadMacInt32(tvec + 4)); |
890 |
> |
WriteMacInt32(XLM_GET_RESOURCE, ReadMacInt32(tvec)); |
891 |
|
#if EMULATED_PPC |
892 |
< |
tvec[0] = htonl(NativeFunction(NATIVE_GET_RESOURCE)); |
892 |
> |
WriteMacInt32(tvec, NativeFunction(NATIVE_GET_RESOURCE)); |
893 |
|
#else |
894 |
|
#ifdef __BEOS__ |
895 |
|
uint32 *tvec2 = (uint32 *)get_resource; |
896 |
< |
tvec[0] = tvec2[0]; |
897 |
< |
tvec[1] = tvec2[1]; |
896 |
> |
WriteMacInt32(tvec, tvec2[0]); |
897 |
> |
WriteMacInt32(tvec + 4, tvec2[1]); |
898 |
|
#else |
899 |
< |
tvec[0] = (uint32)get_resource; |
899 |
> |
WriteMacInt32(tvec, (uint32)get_resource); |
900 |
|
#endif |
901 |
|
#endif |
902 |
|
|
903 |
|
// Patch native Get1Resource() |
904 |
|
upp = ReadMacInt32(0x0e7c); |
905 |
< |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
906 |
< |
D(bug(" Get1Resource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
907 |
< |
*(uint32 *)XLM_GET_1_RESOURCE = tvec[0]; |
905 |
> |
tvec = ReadMacInt32(upp + 5 * 4); |
906 |
> |
D(bug(" Get1Resource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4))); |
907 |
> |
WriteMacInt32(XLM_GET_1_RESOURCE, ReadMacInt32(tvec)); |
908 |
|
#if EMULATED_PPC |
909 |
< |
tvec[0] = htonl(NativeFunction(NATIVE_GET_1_RESOURCE)); |
909 |
> |
WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_RESOURCE)); |
910 |
|
#else |
911 |
|
#ifdef __BEOS__ |
912 |
|
tvec2 = (uint32 *)get_1_resource; |
913 |
< |
tvec[0] = tvec2[0]; |
914 |
< |
tvec[1] = tvec2[1]; |
913 |
> |
WriteMacInt32(tvec, tvec2[0]); |
914 |
> |
WriteMacInt32(tvec + 4, tvec2[1]); |
915 |
|
#else |
916 |
< |
tvec[0] = (uint32)get_1_resource; |
916 |
> |
WriteMacInt32(tvec, (uint32)get_1_resource); |
917 |
|
#endif |
918 |
|
#endif |
919 |
|
|
920 |
|
// Patch native GetIndResource() |
921 |
|
upp = ReadMacInt32(0x1474); |
922 |
< |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
923 |
< |
D(bug(" GetIndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
924 |
< |
*(uint32 *)XLM_GET_IND_RESOURCE = tvec[0]; |
922 |
> |
tvec = ReadMacInt32(upp + 5 * 4); |
923 |
> |
D(bug(" GetIndResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4))); |
924 |
> |
WriteMacInt32(XLM_GET_IND_RESOURCE, ReadMacInt32(tvec)); |
925 |
|
#if EMULATED_PPC |
926 |
< |
tvec[0] = htonl(NativeFunction(NATIVE_GET_IND_RESOURCE)); |
926 |
> |
WriteMacInt32(tvec, NativeFunction(NATIVE_GET_IND_RESOURCE)); |
927 |
|
#else |
928 |
|
#ifdef __BEOS__ |
929 |
|
tvec2 = (uint32 *)get_ind_resource; |
930 |
< |
tvec[0] = tvec2[0]; |
931 |
< |
tvec[1] = tvec2[1]; |
930 |
> |
WriteMacInt32(tvec, tvec2[0]); |
931 |
> |
WriteMacInt32(tvec + 4, tvec2[1]); |
932 |
|
#else |
933 |
< |
tvec[0] = (uint32)get_ind_resource; |
933 |
> |
WriteMacInt32(tvec, (uint32)get_ind_resource); |
934 |
|
#endif |
935 |
|
#endif |
936 |
|
|
937 |
|
// Patch native Get1IndResource() |
938 |
|
upp = ReadMacInt32(0x0e38); |
939 |
< |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
940 |
< |
D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
941 |
< |
*(uint32 *)XLM_GET_1_IND_RESOURCE = tvec[0]; |
939 |
> |
tvec = ReadMacInt32(upp + 5 * 4); |
940 |
> |
D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4))); |
941 |
> |
WriteMacInt32(XLM_GET_1_IND_RESOURCE, ReadMacInt32(tvec)); |
942 |
|
#if EMULATED_PPC |
943 |
< |
tvec[0] = htonl(NativeFunction(NATIVE_GET_1_IND_RESOURCE)); |
943 |
> |
WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_IND_RESOURCE)); |
944 |
|
#else |
945 |
|
#ifdef __BEOS__ |
946 |
|
tvec2 = (uint32 *)get_1_ind_resource; |
947 |
< |
tvec[0] = tvec2[0]; |
948 |
< |
tvec[1] = tvec2[1]; |
947 |
> |
WriteMacInt32(tvec, tvec2[0]); |
948 |
> |
WriteMacInt32(tvec + 4, tvec2[1]); |
949 |
|
#else |
950 |
< |
tvec[0] = (uint32)get_1_ind_resource; |
950 |
> |
WriteMacInt32(tvec, (uint32)get_1_ind_resource); |
951 |
|
#endif |
952 |
|
#endif |
953 |
|
|
954 |
|
// Patch native RGetResource() |
955 |
|
upp = ReadMacInt32(0x0e30); |
956 |
< |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
957 |
< |
D(bug(" RGetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
958 |
< |
*(uint32 *)XLM_R_GET_RESOURCE = tvec[0]; |
956 |
> |
tvec = ReadMacInt32(upp + 5 * 4); |
957 |
> |
D(bug(" RGetResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4))); |
958 |
> |
WriteMacInt32(XLM_R_GET_RESOURCE, ReadMacInt32(tvec)); |
959 |
|
#if EMULATED_PPC |
960 |
< |
tvec[0] = htonl(NativeFunction(NATIVE_R_GET_RESOURCE)); |
960 |
> |
WriteMacInt32(tvec, NativeFunction(NATIVE_R_GET_RESOURCE)); |
961 |
|
#else |
962 |
|
#ifdef __BEOS__ |
963 |
|
tvec2 = (uint32 *)r_get_resource; |
964 |
< |
tvec[0] = tvec2[0]; |
965 |
< |
tvec[1] = tvec2[1]; |
964 |
> |
WriteMacInt32(tvec, tvec2[0]); |
965 |
> |
WriteMacInt32(tvec + 4, tvec2[1]); |
966 |
> |
#else |
967 |
> |
WriteMacInt32(tvec, (uint32)r_get_resource); |
968 |
> |
#endif |
969 |
> |
#endif |
970 |
> |
|
971 |
> |
// Patch native GetNamedResource() |
972 |
> |
upp = ReadMacInt32(0x1484); |
973 |
> |
tvec = ReadMacInt32(upp + 5 * 4); |
974 |
> |
D(bug(" GetNamedResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4))); |
975 |
> |
WriteMacInt32(XLM_GET_NAMED_RESOURCE, ReadMacInt32(tvec)); |
976 |
> |
#if EMULATED_PPC |
977 |
> |
WriteMacInt32(tvec, NativeFunction(NATIVE_GET_NAMED_RESOURCE)); |
978 |
> |
#else |
979 |
> |
#ifdef __BEOS__ |
980 |
> |
tvec2 = (uint32 *)get_named_resource; |
981 |
> |
WriteMacInt32(tvec, tvec2[0]); |
982 |
> |
WriteMacInt32(tvec + 4, tvec2[1]); |
983 |
> |
#else |
984 |
> |
WriteMacInt32(tvec, (uint32)get_named_resource); |
985 |
> |
#endif |
986 |
> |
#endif |
987 |
> |
|
988 |
> |
// Patch native Get1NamedResource() |
989 |
> |
upp = ReadMacInt32(0x0e80); |
990 |
> |
tvec = ReadMacInt32(upp + 5 * 4); |
991 |
> |
D(bug(" Get1NamedResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4))); |
992 |
> |
WriteMacInt32(XLM_GET_1_NAMED_RESOURCE, ReadMacInt32(tvec)); |
993 |
> |
#if EMULATED_PPC |
994 |
> |
WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_NAMED_RESOURCE)); |
995 |
> |
#else |
996 |
> |
#ifdef __BEOS__ |
997 |
> |
tvec2 = (uint32 *)get_1_named_resource; |
998 |
> |
WriteMacInt32(tvec, tvec2[0]); |
999 |
> |
WriteMacInt32(tvec + 4, tvec2[1]); |
1000 |
|
#else |
1001 |
< |
tvec[0] = (uint32)r_get_resource; |
1001 |
> |
WriteMacInt32(tvec, (uint32)get_1_named_resource); |
1002 |
|
#endif |
1003 |
|
#endif |
1004 |
|
} |