1 |
|
/* |
2 |
|
* rsrc_patches.cpp - Resource patches |
3 |
|
* |
4 |
< |
* SheepShaver (C) 1997-2002 Christian Bauer and Marc Hellwig |
4 |
> |
* SheepShaver (C) 1997-2004 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 |
31 |
|
#include "rom_patches.h" |
32 |
|
#include "main.h" |
33 |
|
#include "audio.h" |
34 |
+ |
#include "audio_defs.h" |
35 |
+ |
#include "thunks.h" |
36 |
|
|
37 |
|
#define DEBUG 0 |
38 |
|
#include "debug.h" |
107 |
|
* Resource patches via vCheckLoad |
108 |
|
*/ |
109 |
|
|
110 |
+ |
// 680x0 code pattern matching helper |
111 |
+ |
#define PM(N, V) (p[N] == htons(V)) |
112 |
+ |
|
113 |
|
void CheckLoad(uint32 type, int16 id, uint16 *p, uint32 size) |
114 |
|
{ |
115 |
|
uint16 *p16; |
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 ((uint32)p >= ROM_BASE && (uint32)p <= (ROM_BASE + ROM_SIZE)) |
120 |
> |
if ((uintptr)p >= ROM_BASE && (uintptr)p <= (ROM_BASE + ROM_SIZE)) |
121 |
|
return; |
122 |
|
|
123 |
|
if (type == FOURCC('b','o','o','t') && id == 3) { |
124 |
|
D(bug("boot 3 found\n")); |
125 |
|
size >>= 1; |
126 |
|
while (size--) { |
127 |
< |
if (p[0] == 0x2e49) { |
127 |
> |
if (PM(0,0x2e49)) { |
128 |
|
// Set boot stack pointer (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1, 8.5, 8.6) |
129 |
< |
p[0] = M68K_EMUL_OP_FIX_BOOTSTACK; |
129 |
> |
p[0] = htons(M68K_EMUL_OP_FIX_BOOTSTACK); |
130 |
|
D(bug(" patch 1 applied\n")); |
131 |
< |
} else if (p[0] == 0x4267 && p[1] == 0x3f01 && p[2] == 0x3f2a && p[3] == 0x0006 && p[4] == 0x6100) { |
131 |
> |
} else if (PM(0,0x4267) && PM(1,0x3f01) && PM(2,0x3f2a) && PM(3,0x0006) && PM(4,0x6100)) { |
132 |
|
// Check when ntrb 17 is installed (for native Resource Manager patch) (7.5.3, 7.5.5) |
133 |
< |
p[7] = M68K_EMUL_OP_NTRB_17_PATCH3; |
133 |
> |
p[7] = htons(M68K_EMUL_OP_NTRB_17_PATCH3); |
134 |
|
D(bug(" patch 2 applied\n")); |
135 |
< |
} else if (p[0] == 0x3f2a && p[1] == 0x0006 && p[2] == 0x3f2a && p[3] == 0x0002 && p[4] == 0x6100) { |
135 |
> |
} else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x6100)) { |
136 |
|
// Check when ntrb 17 is installed (for native Resource Manager patch) (7.6, 7.6.1, 8.0, 8.1) |
137 |
< |
p[7] = M68K_EMUL_OP_NTRB_17_PATCH; |
137 |
> |
p[7] = htons(M68K_EMUL_OP_NTRB_17_PATCH); |
138 |
|
D(bug(" patch 3 applied\n")); |
139 |
< |
} else if (p[0] == 0x3f2a && p[1] == 0x0006 && p[2] == 0x3f2a && p[3] == 0x0002 && p[4] == 0x61ff) { |
139 |
> |
} else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x61ff)) { |
140 |
|
// Check when ntrb 17 is installed (for native Resource Manager patch) (8.5, 8.6) |
141 |
< |
p[8] = M68K_EMUL_OP_NTRB_17_PATCH; |
141 |
> |
p[8] = htons(M68K_EMUL_OP_NTRB_17_PATCH); |
142 |
|
D(bug(" patch 4 applied\n")); |
143 |
< |
} else if (p[0] == 0x0c39 && p[1] == 0x0001 && p[2] == 0xf800 && p[3] == 0x0008 && p[4] == 0x6f00) { |
143 |
> |
} else if (PM(0,0x0c39) && PM(1,0x0001) && PM(2,0xf800) && PM(3,0x0008) && PM(4,0x6f00)) { |
144 |
|
// Don't read from 0xf8000008 (8.5 with Zanzibar ROM, 8.6) |
145 |
< |
p[0] = M68K_NOP; |
146 |
< |
p[1] = M68K_NOP; |
147 |
< |
p[2] = M68K_NOP; |
148 |
< |
p[3] = M68K_NOP; |
149 |
< |
p[4] = 0x6000; // bra |
145 |
> |
p[0] = htons(M68K_NOP); |
146 |
> |
p[1] = htons(M68K_NOP); |
147 |
> |
p[2] = htons(M68K_NOP); |
148 |
> |
p[3] = htons(M68K_NOP); |
149 |
> |
p[4] = htons(0x6000); // bra |
150 |
|
D(bug(" patch 5 applied\n")); |
151 |
< |
} else if (p[0] == 0x2f3c && p[1] == 0x6b72 && p[2] == 0x6e6c && p[3] == 0x4267 && p[4] == 0xa9a0 && p[5] == 0x265f && p[6] == 0x200b && p[7] == 0x6700) { |
151 |
> |
} else if (PM(0,0x2f3c) && PM(1,0x6b72) && PM(2,0x6e6c) && PM(3,0x4267) && PM(4,0xa9a0) && PM(5,0x265f) && PM(6,0x200b) && PM(7,0x6700)) { |
152 |
|
// Don't replace nanokernel ("krnl" resource) (8.6) |
153 |
< |
p[0] = M68K_NOP; |
154 |
< |
p[1] = M68K_NOP; |
155 |
< |
p[2] = M68K_NOP; |
156 |
< |
p[3] = M68K_NOP; |
157 |
< |
p[4] = M68K_NOP; |
158 |
< |
p[7] = 0x6000; // bra |
153 |
> |
p[0] = htons(M68K_NOP); |
154 |
> |
p[1] = htons(M68K_NOP); |
155 |
> |
p[2] = htons(M68K_NOP); |
156 |
> |
p[3] = htons(M68K_NOP); |
157 |
> |
p[4] = htons(M68K_NOP); |
158 |
> |
p[7] = htons(0x6000); // bra |
159 |
|
D(bug(" patch 6 applied\n")); |
160 |
< |
} else if (p[0] == 0xa8fe && p[1] == 0x3038 && p[2] == 0x017a && p[3] == 0x0c40 && p[4] == 0x8805 && p[5] == 0x6710) { |
160 |
> |
} else if (PM(0,0xa8fe) && PM(1,0x3038) && PM(2,0x017a) && PM(3,0x0c40) && PM(4,0x8805) && PM(5,0x6710)) { |
161 |
|
// No SCSI (calls via 0x205c jump vector which is not initialized in NewWorld ROM 1.6) (8.6) |
162 |
|
if (ROMType == ROMTYPE_NEWWORLD) { |
163 |
< |
p[5] = 0x6010; // bra |
163 |
> |
p[5] = htons(0x6010); // bra |
164 |
|
D(bug(" patch 7 applied\n")); |
165 |
|
} |
166 |
|
} |
174 |
|
static const uint8 dat[] = {0x4e, 0xba, 0x00, 0x9e, 0x3e, 0x00, 0x50, 0x4f, 0x67, 0x04}; |
175 |
|
base = find_rsrc_data((uint8 *)p, size, dat, sizeof(dat)); |
176 |
|
if (base) { |
177 |
< |
p16 = (uint16 *)((uint32)p + base + 6); |
177 |
> |
p16 = (uint16 *)((uintptr)p + base + 6); |
178 |
|
*p16 = htons(M68K_EMUL_OP_NTRB_17_PATCH2); |
179 |
|
D(bug(" patch 1 applied\n")); |
180 |
|
} |
183 |
|
D(bug("ptch 420 found\n")); |
184 |
|
size >>= 1; |
185 |
|
while (size--) { |
186 |
< |
if (p[0] == 0xa030 && p[1] == 0x5240 && p[2] == 0x303c && p[3] == 0x0100 && p[4] == 0xc06e && p[5] == 0xfef6) { |
186 |
> |
if (PM(0,0xa030) && PM(1,0x5240) && PM(2,0x303c) && PM(3,0x0100) && PM(4,0xc06e) && PM(5,0xfef6)) { |
187 |
|
// Disable VM (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1) |
188 |
< |
p[1] = M68K_NOP; |
189 |
< |
p[2] = M68K_NOP; |
190 |
< |
p[3] = M68K_NOP; |
191 |
< |
p[4] = M68K_NOP; |
192 |
< |
p[5] = M68K_NOP; |
193 |
< |
p[6] = M68K_NOP; |
194 |
< |
p[7] = M68K_NOP; |
195 |
< |
p[8] = M68K_NOP; |
196 |
< |
p[9] = M68K_NOP; |
197 |
< |
p[10] = M68K_NOP; |
198 |
< |
p[11] = M68K_NOP; |
188 |
> |
p[1] = htons(M68K_NOP); |
189 |
> |
p[2] = htons(M68K_NOP); |
190 |
> |
p[3] = htons(M68K_NOP); |
191 |
> |
p[4] = htons(M68K_NOP); |
192 |
> |
p[5] = htons(M68K_NOP); |
193 |
> |
p[6] = htons(M68K_NOP); |
194 |
> |
p[7] = htons(M68K_NOP); |
195 |
> |
p[8] = htons(M68K_NOP); |
196 |
> |
p[9] = htons(M68K_NOP); |
197 |
> |
p[10] = htons(M68K_NOP); |
198 |
> |
p[11] = htons(M68K_NOP); |
199 |
|
D(bug(" patch 1 applied\n")); |
200 |
|
break; |
201 |
< |
} else if (p[0] == 0xa030 && p[1] == 0x5240 && p[2] == 0x7000 && p[3] == 0x302e && p[4] == 0xfef6 && p[5] == 0x323c && p[6] == 0x0100) { |
201 |
> |
} else if (PM(0,0xa030) && PM(1,0x5240) && PM(2,0x7000) && PM(3,0x302e) && PM(4,0xfef6) && PM(5,0x323c) && PM(6,0x0100)) { |
202 |
|
// Disable VM (8.0, 8.1) |
203 |
< |
p[8] = M68K_NOP; |
204 |
< |
p[15] = M68K_NOP; |
203 |
> |
p[8] = htons(M68K_NOP); |
204 |
> |
p[15] = htons(M68K_NOP); |
205 |
|
D(bug(" patch 2 applied\n")); |
206 |
|
break; |
207 |
< |
} else if (p[0] == 0xa030 && p[1] == 0x5240 && p[2] == 0x7000 && p[3] == 0x302e && p[4] == 0xfecc && p[5] == 0x323c && p[6] == 0x0100) { |
207 |
> |
} else if (PM(0,0xa030) && PM(1,0x5240) && PM(2,0x7000) && PM(3,0x302e) && PM(4,0xfecc) && PM(5,0x323c) && PM(6,0x0100)) { |
208 |
|
// Disable VM (8.5, 8.6) |
209 |
< |
p[8] = M68K_NOP; |
210 |
< |
p[15] = M68K_NOP; |
209 |
> |
p[8] = htons(M68K_NOP); |
210 |
> |
p[15] = htons(M68K_NOP); |
211 |
|
D(bug(" patch 3 applied\n")); |
212 |
|
break; |
213 |
|
} |
218 |
|
D(bug("gpch 16 found\n")); |
219 |
|
size >>= 1; |
220 |
|
while (size--) { |
221 |
< |
if (p[0] == 0x6700 && p[13] == 0x7013 && p[14] == 0xfe0a) { |
221 |
> |
if (PM(0,0x6700) && PM(13,0x7013) && PM(14,0xfe0a)) { |
222 |
|
// Don't call FE0A in Shutdown Manager (7.6.1, 8.0, 8.1, 8.5) |
223 |
< |
p[0] = 0x6000; |
223 |
> |
p[0] = htons(0x6000); |
224 |
|
D(bug(" patch 1 applied\n")); |
225 |
|
break; |
226 |
|
} |
231 |
|
D(bug("gpch 650 found\n")); |
232 |
|
size >>= 1; |
233 |
|
while (size--) { |
234 |
< |
if (p[0] == 0x6600 && p[1] == 0x001a && p[2] == 0x2278 && p[3] == 0x0134) { |
234 |
> |
if (PM(0,0x6600) && PM(1,0x001a) && PM(2,0x2278) && PM(3,0x0134)) { |
235 |
|
// We don't have SonyVars (7.5.2) |
236 |
< |
p[0] = 0x6000; |
236 |
> |
p[0] = htons(0x6000); |
237 |
|
D(bug(" patch 1 applied\n")); |
238 |
< |
} else if (p[0] == 0x6618 && p[1] == 0x2278 && p[2] == 0x0134) { |
238 |
> |
} else if (PM(0,0x6618) && PM(1,0x2278) && PM(2,0x0134)) { |
239 |
|
// We don't have SonyVars (7.5.3) |
240 |
< |
p[-6] = M68K_NOP; |
241 |
< |
p[-3] = M68K_NOP; |
242 |
< |
p[0] = 0x6018; |
240 |
> |
p[-6] = htons(M68K_NOP); |
241 |
> |
p[-3] = htons(M68K_NOP); |
242 |
> |
p[0] = htons(0x6018); |
243 |
|
D(bug(" patch 2 applied\n")); |
244 |
< |
} else if (p[0] == 0x666e && p[1] == 0x2278 && p[2] == 0x0134) { |
244 |
> |
} else if (PM(0,0x666e) && PM(1,0x2278) && PM(2,0x0134)) { |
245 |
|
// We don't have SonyVars (7.5.5) |
246 |
< |
p[-6] = M68K_NOP; |
247 |
< |
p[-3] = M68K_NOP; |
248 |
< |
p[0] = 0x606e; |
246 |
> |
p[-6] = htons(M68K_NOP); |
247 |
> |
p[-3] = htons(M68K_NOP); |
248 |
> |
p[0] = htons(0x606e); |
249 |
|
D(bug(" patch 3 applied\n")); |
250 |
< |
} else if (p[0] == 0x6400 && p[1] == 0x011c && p[2] == 0x2278 && p[3] == 0x0134) { |
250 |
> |
} else if (PM(0,0x6400) && PM(1,0x011c) && PM(2,0x2278) && PM(3,0x0134)) { |
251 |
|
// We don't have SonyVars (7.6.1, 8.0, 8.1, 8.5, 8.6) |
252 |
< |
p[0] = 0x6000; |
252 |
> |
p[0] = htons(0x6000); |
253 |
|
D(bug(" patch 4 applied\n")); |
254 |
< |
} else if (p[0] == 0x6400 && p[1] == 0x00e6 && p[2] == 0x2278 && p[3] == 0x0134) { |
254 |
> |
} else if (PM(0,0x6400) && PM(1,0x00e6) && PM(2,0x2278) && PM(3,0x0134)) { |
255 |
|
// We don't have SonyVars (7.6) |
256 |
< |
p[0] = 0x6000; |
256 |
> |
p[0] = htons(0x6000); |
257 |
|
D(bug(" patch 5 applied\n")); |
258 |
|
} |
259 |
|
p++; |
263 |
|
D(bug("gpch 655 found\n")); |
264 |
|
size >>= 1; |
265 |
|
while (size--) { |
266 |
< |
if (p[0] == 0x83a8 && p[1] == 0x0024 && p[2] == 0x4e71) { |
266 |
> |
if (PM(0,0x83a8) && PM(1,0x0024) && PM(2,0x4e71)) { |
267 |
|
// Don't write to GC interrupt mask (7.6, 7.6.1, 8.0, 8.1 with Zanzibar ROM) |
268 |
< |
p[0] = M68K_NOP; |
269 |
< |
p[1] = M68K_NOP; |
268 |
> |
p[0] = htons(M68K_NOP); |
269 |
> |
p[1] = htons(M68K_NOP); |
270 |
|
D(bug(" patch 1 applied\n")); |
271 |
< |
} else if (p[0] == 0x207c && p[1] == 0xf300 && p[2] == 0x0034) { |
271 |
> |
} else if (PM(0,0x207c) && PM(1,0xf300) && PM(2,0x0034)) { |
272 |
|
// Don't read PowerMac ID (7.6, 7.6.1, 8.0, 8.1 with Zanzibar ROM) |
273 |
< |
p[0] = 0x303c; // move.w #id,d0 |
274 |
< |
p[1] = 0x3020; |
275 |
< |
p[2] = M68K_RTS; |
273 |
> |
p[0] = htons(0x303c); // move.w #id,d0 |
274 |
> |
p[1] = htons(0x3020); |
275 |
> |
p[2] = htons(M68K_RTS); |
276 |
|
D(bug(" patch 2 applied\n")); |
277 |
< |
} else if (p[0] == 0x13fc && p[1] == 0x0081 && p[2] == 0xf130 && p[3] == 0xa030) { |
277 |
> |
} else if (PM(0,0x13fc) && PM(1,0x0081) && PM(2,0xf130) && PM(3,0xa030)) { |
278 |
|
// Don't write to hardware (7.6, 7.6.1, 8.0, 8.1 with Zanzibar ROM) |
279 |
< |
p[0] = M68K_NOP; |
280 |
< |
p[1] = M68K_NOP; |
281 |
< |
p[2] = M68K_NOP; |
282 |
< |
p[3] = M68K_NOP; |
279 |
> |
p[0] = htons(M68K_NOP); |
280 |
> |
p[1] = htons(M68K_NOP); |
281 |
> |
p[2] = htons(M68K_NOP); |
282 |
> |
p[3] = htons(M68K_NOP); |
283 |
|
D(bug(" patch 3 applied\n")); |
284 |
< |
} else if (p[0] == 0x4e56 && p[1] == 0x0000 && p[2] == 0x227c && p[3] == 0xf800 && p[4] == 0x0000) { |
284 |
> |
} else if (PM(0,0x4e56) && PM(1,0x0000) && PM(2,0x227c) && PM(3,0xf800) && PM(4,0x0000)) { |
285 |
|
// OpenFirmare? (7.6.1, 8.0, 8.1 with Zanzibar ROM) |
286 |
< |
p[0] = M68K_RTS; |
286 |
> |
p[0] = htons(M68K_RTS); |
287 |
|
D(bug(" patch 4 applied\n")); |
288 |
< |
} else if (p[0] == 0x4e56 && p[1] == 0xfffc && p[2] == 0x48e7 && p[3] == 0x0300 && p[4] == 0x598f && p[5] == 0x2eb8 && p[6] == 0x01dc) { |
288 |
> |
} else if (PM(0,0x4e56) && PM(1,0xfffc) && PM(2,0x48e7) && PM(3,0x0300) && PM(4,0x598f) && PM(5,0x2eb8) && PM(6,0x01dc)) { |
289 |
|
// Don't write to SCC (7.6.1, 8.0, 8.1 with Zanzibar ROM) |
290 |
< |
p[0] = M68K_RTS; |
290 |
> |
p[0] = htons(M68K_RTS); |
291 |
|
D(bug(" patch 5 applied\n")); |
292 |
< |
} else if (p[0] == 0x4e56 && p[1] == 0x0000 && p[2] == 0x227c && p[3] == 0xf300 && p[4] == 0x0034) { |
292 |
> |
} else if (PM(0,0x4e56) && PM(1,0x0000) && PM(2,0x227c) && PM(3,0xf300) && PM(4,0x0034)) { |
293 |
|
// Don't write to GC (7.6.1, 8.0, 8.1 with Zanzibar ROM) |
294 |
< |
p[0] = M68K_RTS; |
294 |
> |
p[0] = htons(M68K_RTS); |
295 |
|
D(bug(" patch 6 applied\n")); |
296 |
< |
} else if (p[0] == 0x40e7 && p[1] == 0x007c && p[2] == 0x0700 && p[3] == 0x48e7 && p[4] == 0x00c0 && p[5] == 0x2078 && p[6] == 0x0dd8 && p[7] == 0xd1e8 && p[8] == 0x0044 && p[9] == 0x8005 && p[11] == 0x93c8 && p[12] == 0x2149 && p[13] == 0x0024) { |
296 |
> |
} else if (PM(0,0x40e7) && PM(1,0x007c) && PM(2,0x0700) && PM(3,0x48e7) && PM(4,0x00c0) && PM(5,0x2078) && PM(6,0x0dd8) && PM(7,0xd1e8) && PM(8,0x0044) && PM(9,0x8005) && PM(11,0x93c8) && PM(12,0x2149) && PM(13,0x0024)) { |
297 |
|
// Don't replace NVRAM routines (7.6, 7.6.1, 8.0, 8.1 with Zanzibar ROM) |
298 |
< |
p[0] = M68K_RTS; |
298 |
> |
p[0] = htons(M68K_RTS); |
299 |
|
D(bug(" patch 7 applied\n")); |
300 |
< |
} else if (p[0] == 0x207c && p[1] == 0x50f1 && p[2] == 0xa101 && (p[3] == 0x08d0 || p[3] == 0x0890)) { |
300 |
> |
} else if (PM(0,0x207c) && PM(1,0x50f1) && PM(2,0xa101) && (PM(3,0x08d0) || PM(3,0x0890))) { |
301 |
|
// Don't write to 0x50f1a101 (8.1 with Zanzibar ROM) |
302 |
< |
p[3] = M68K_NOP; |
303 |
< |
p[4] = M68K_NOP; |
302 |
> |
p[3] = htons(M68K_NOP); |
303 |
> |
p[4] = htons(M68K_NOP); |
304 |
|
D(bug(" patch 8 applied\n")); |
305 |
|
} |
306 |
|
p++; |
310 |
|
D(bug("gpch 750 found\n")); |
311 |
|
size >>= 1; |
312 |
|
while (size--) { |
313 |
< |
if (p[0] == 0xf301 && p[1] == 0x9100 && p[2] == 0x0c11 && p[3] == 0x0044) { |
313 |
> |
if (PM(0,0xf301) && PM(1,0x9100) && PM(2,0x0c11) && PM(3,0x0044)) { |
314 |
|
// Don't read from 0xf3019100 (MACE ENET) (7.6, 7.6.1, 8.0, 8.1) |
315 |
< |
p[2] = M68K_NOP; |
316 |
< |
p[3] = M68K_NOP; |
317 |
< |
p[4] = 0x6026; |
315 |
> |
p[2] = htons(M68K_NOP); |
316 |
> |
p[3] = htons(M68K_NOP); |
317 |
> |
p[4] = htons(0x6026); |
318 |
|
D(bug(" patch 1 applied\n")); |
319 |
< |
} else if (p[0] == 0x41e8 && p[1] == 0x0374 && p[2] == 0xfc1e) { |
319 |
> |
} else if (PM(0,0x41e8) && PM(1,0x0374) && PM(2,0xfc1e)) { |
320 |
|
// Don't call FC1E opcode (7.6, 7.6.1, 8.0, 8.1, 8.5, 8.6) |
321 |
< |
p[2] = M68K_NOP; |
321 |
> |
p[2] = htons(M68K_NOP); |
322 |
|
D(bug(" patch 2 applied\n")); |
323 |
< |
} else if (p[0] == 0x700a && p[1] == 0xfe0a) { |
323 |
> |
} else if (PM(0,0x700a) && PM(1,0xfe0a)) { |
324 |
|
// Don't call FE0A opcode (7.6, 7.6.1, 8.0, 8.1, 8.5, 8.6) |
325 |
< |
p[1] = 0x7000; |
325 |
> |
p[1] = htons(0x7000); |
326 |
|
D(bug(" patch 3 applied\n")); |
327 |
+ |
} else if (PM(0,0x6c00) && PM(1,0x016a) && PM(2,0x2278) && PM(3,0x0134)) { |
328 |
+ |
// We don't have SonyVars (8.6) |
329 |
+ |
p[-4] = htons(0x21fc); // move.l $40810000,($0000) |
330 |
+ |
p[-3] = htons(0x4081); |
331 |
+ |
p[-2] = htons(0x0000); |
332 |
+ |
p[-1] = htons(0x0000); |
333 |
+ |
p[0] = htons(0x6000); |
334 |
+ |
D(bug(" patch 4 applied\n")); |
335 |
|
} |
336 |
|
p++; |
337 |
|
} |
340 |
|
D(bug("gpch 999 found\n")); |
341 |
|
size >>= 1; |
342 |
|
while (size--) { |
343 |
< |
if (p[0] == 0xf301 && p[1] == 0x9100 && p[2] == 0x0c11 && p[3] == 0x0044) { |
343 |
> |
if (PM(0,0xf301) && PM(1,0x9100) && PM(2,0x0c11) && PM(3,0x0044)) { |
344 |
|
// Don't read from 0xf3019100 (MACE ENET) (8.5, 8.6) |
345 |
< |
p[2] = M68K_NOP; |
346 |
< |
p[3] = M68K_NOP; |
347 |
< |
p[4] = 0x6026; |
345 |
> |
p[2] = htons(M68K_NOP); |
346 |
> |
p[3] = htons(M68K_NOP); |
347 |
> |
p[4] = htons(0x6026); |
348 |
|
D(bug(" patch 1 applied\n")); |
349 |
|
} |
350 |
|
p++; |
354 |
|
D(bug("gpch 3000 found\n")); |
355 |
|
size >>= 1; |
356 |
|
while (size--) { |
357 |
< |
if (p[0] == 0xf301 && p[1] == 0x9100 && p[2] == 0x0c11 && p[3] == 0x0044) { |
357 |
> |
if (PM(0,0xf301) && PM(1,0x9100) && PM(2,0x0c11) && PM(3,0x0044)) { |
358 |
|
// Don't read from 0xf3019100 (MACE ENET) (8.1 with NewWorld ROM) |
359 |
< |
p[2] = M68K_NOP; |
360 |
< |
p[3] = M68K_NOP; |
361 |
< |
p[4] = 0x6026; |
359 |
> |
p[2] = htons(M68K_NOP); |
360 |
> |
p[3] = htons(M68K_NOP); |
361 |
> |
p[4] = htons(0x6026); |
362 |
|
D(bug(" patch 1 applied\n")); |
363 |
|
} |
364 |
|
p++; |
369 |
|
#if 1 |
370 |
|
size >>= 1; |
371 |
|
while (size--) { |
372 |
< |
if (p[0] == 0xc2fc && p[1] == 0x0fa0 && p[2] == 0x82c5) { |
372 |
> |
if (PM(0,0xc2fc) && PM(1,0x0fa0) && PM(2,0x82c5)) { |
373 |
|
// Prevent division by 0 in speed test (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
374 |
< |
p[2] = 0x7200; |
374 |
> |
p[2] = htons(0x7200); |
375 |
|
WriteMacInt32(0x1d8, 0x2c00); |
376 |
|
WriteMacInt32(0x1dc, 0x2c00); |
377 |
|
D(bug(" patch 1 applied\n")); |
378 |
< |
} else if (p[0] == 0x1418 && p[1] == 0x84c1) { |
378 |
> |
} else if (PM(0,0x1418) && PM(1,0x84c1)) { |
379 |
|
// Prevent division by 0 (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
380 |
< |
p[1] = 0x7400; |
380 |
> |
p[1] = htons(0x7400); |
381 |
|
D(bug(" patch 2 applied\n")); |
382 |
< |
} else if (p[0] == 0x2678 && p[1] == 0x01dc && p[2] == 0x3018 && p[3] == 0x6708 && p[4] == 0x1680 && p[5] == 0xe058 && p[6] == 0x1680) { |
382 |
> |
} else if (PM(0,0x2678) && PM(1,0x01dc) && PM(2,0x3018) && PM(3,0x6708) && PM(4,0x1680) && PM(5,0xe058) && PM(6,0x1680)) { |
383 |
|
// Don't write to SCC (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
384 |
< |
p[4] = M68K_NOP; |
385 |
< |
p[6] = M68K_NOP; |
384 |
> |
p[4] = htons(M68K_NOP); |
385 |
> |
p[6] = htons(M68K_NOP); |
386 |
|
D(bug(" patch 3 applied\n")); |
387 |
< |
} else if (p[0] == 0x2278 && p[1] == 0x01dc && p[2] == 0x12bc && p[3] == 0x0006 && p[4] == 0x4e71 && p[5] == 0x1292) { |
387 |
> |
} else if (PM(0,0x2278) && PM(1,0x01dc) && PM(2,0x12bc) && PM(3,0x0006) && PM(4,0x4e71) && PM(5,0x1292)) { |
388 |
|
// Don't write to SCC (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
389 |
< |
p[2] = M68K_NOP; |
390 |
< |
p[3] = M68K_NOP; |
391 |
< |
p[5] = M68K_NOP; |
389 |
> |
p[2] = htons(M68K_NOP); |
390 |
> |
p[3] = htons(M68K_NOP); |
391 |
> |
p[5] = htons(M68K_NOP); |
392 |
|
D(bug(" patch 4 applied\n")); |
393 |
< |
} else if (p[0] == 0x2278 && p[1] == 0x01dc && p[2] == 0x12bc && p[3] == 0x0003 && p[4] == 0x4e71 && p[5] == 0x1281) { |
393 |
> |
} else if (PM(0,0x2278) && PM(1,0x01dc) && PM(2,0x12bc) && PM(3,0x0003) && PM(4,0x4e71) && PM(5,0x1281)) { |
394 |
|
// Don't write to SCC (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
395 |
< |
p[2] = M68K_NOP; |
396 |
< |
p[3] = M68K_NOP; |
397 |
< |
p[5] = M68K_NOP; |
395 |
> |
p[2] = htons(M68K_NOP); |
396 |
> |
p[3] = htons(M68K_NOP); |
397 |
> |
p[5] = htons(M68K_NOP); |
398 |
|
D(bug(" patch 5 applied\n")); |
399 |
< |
} else if (p[0] == 0x0811 && p[1] == 0x0000 && p[2] == 0x51c8 && p[3] == 0xfffa) { |
399 |
> |
} else if (PM(0,0x0811) && PM(1,0x0000) && PM(2,0x51c8) && PM(3,0xfffa)) { |
400 |
|
// Don't test SCC (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
401 |
< |
p[0] = M68K_NOP; |
402 |
< |
p[1] = M68K_NOP; |
401 |
> |
p[0] = htons(M68K_NOP); |
402 |
> |
p[1] = htons(M68K_NOP); |
403 |
|
D(bug(" patch 6 applied\n")); |
404 |
< |
} else if (p[0] == 0x4a2a && p[1] == 0x063e && p[2] == 0x66fa) { |
404 |
> |
} else if (PM(0,0x4a2a) && PM(1,0x063e) && PM(2,0x66fa)) { |
405 |
|
// Don't wait for SCC (7.5.2, 7.5.3, 7.5.5) |
406 |
< |
p[2] = M68K_NOP; |
406 |
> |
p[2] = htons(M68K_NOP); |
407 |
|
D(bug(" patch 7 applied\n")); |
408 |
< |
} else if (p[0] == 0x4a2a && p[1] == 0x03a6 && p[2] == 0x66fa) { |
408 |
> |
} else if (PM(0,0x4a2a) && PM(1,0x03a6) && PM(2,0x66fa)) { |
409 |
|
// Don't wait for SCC (7.6, 7.6.1, 8.0, 8.1) |
410 |
< |
p[2] = M68K_NOP; |
410 |
> |
p[2] = htons(M68K_NOP); |
411 |
|
D(bug(" patch 8 applied\n")); |
412 |
|
} |
413 |
|
p++; |
414 |
|
} |
415 |
|
#else |
416 |
|
// Disable LocalTalk |
417 |
< |
p[0] = M68K_JMP_A0; |
418 |
< |
p[1] = 0x7000; // moveq #0,d0 |
419 |
< |
p[2] = M68K_RTS; |
417 |
> |
p[0] = htons(M68K_JMP_A0); |
418 |
> |
p[1] = htons(0x7000); // moveq #0,d0 |
419 |
> |
p[2] = htons(M68K_RTS); |
420 |
|
D(bug(" patch 1 applied\n")); |
421 |
|
#endif |
422 |
|
|
423 |
|
} else if (type == FOURCC('n','s','r','d') && id == 1) { |
424 |
|
D(bug("nsrd 1 found\n")); |
425 |
< |
if (p[(0x378 + 0x570) >> 1] == 0x7c08 && p[(0x37a + 0x570) >> 1] == 0x02a6) { |
425 |
> |
if (p[(0x378 + 0x570) >> 1] == htons(0x7c08) && p[(0x37a + 0x570) >> 1] == htons(0x02a6)) { |
426 |
|
// Don't overwrite our serial drivers (8.0, 8.1) |
427 |
< |
p[(0x378 + 0x570) >> 1] = 0x4e80; // blr |
428 |
< |
p[(0x37a + 0x570) >> 1] = 0x0020; |
427 |
> |
p[(0x378 + 0x570) >> 1] = htons(0x4e80); // blr |
428 |
> |
p[(0x37a + 0x570) >> 1] = htons(0x0020); |
429 |
|
D(bug(" patch 1 applied\n")); |
430 |
< |
} else if (p[(0x378 + 0x6c0) >> 1] == 0x7c08 && p[(0x37a + 0x6c0) >> 1] == 0x02a6) { |
430 |
> |
} else if (p[(0x378 + 0x6c0) >> 1] == htons(0x7c08) && p[(0x37a + 0x6c0) >> 1] == htons(0x02a6)) { |
431 |
|
// Don't overwrite our serial drivers (8.5, 8.6) |
432 |
< |
p[(0x378 + 0x6c0) >> 1] = 0x4e80; // blr |
433 |
< |
p[(0x37a + 0x6c0) >> 1] = 0x0020; |
432 |
> |
p[(0x378 + 0x6c0) >> 1] = htons(0x4e80); // blr |
433 |
> |
p[(0x37a + 0x6c0) >> 1] = htons(0x0020); |
434 |
|
D(bug(" patch 2 applied\n")); |
435 |
|
} |
436 |
|
|
438 |
|
D(bug("citt 45 found\n")); |
439 |
|
size >>= 1; |
440 |
|
while (size--) { |
441 |
< |
if (p[0] == 0x203c && p[1] == 0x0100 && p[2] == 0x0000 && p[3] == 0xc0ae && p[4] == 0xfffc) { |
441 |
> |
if (PM(0,0x203c) && PM(1,0x0100) && PM(2,0x0000) && PM(3,0xc0ae) && PM(4,0xfffc)) { |
442 |
|
// Don't replace SCSI Manager (8.1, 8.5, 8.6) |
443 |
< |
p[5] = (p[5] & 0xff) | 0x6000; // beq |
443 |
> |
p[5] = htons((ntohs(p[5]) & 0xff) | 0x6000); // beq |
444 |
|
D(bug(" patch 1 applied\n")); |
445 |
|
break; |
446 |
|
} |
449 |
|
|
450 |
|
} else if (type == FOURCC('t','h','n','g')) { |
451 |
|
// Collect info about used audio sifters |
452 |
< |
uint32 c_type = 0[(uint32 *)p]; |
453 |
< |
uint32 sub_type = 1[(uint32 *)p]; |
452 |
> |
uint32 thing = (uintptr)p; |
453 |
> |
uint32 c_type = ReadMacInt32(thing); |
454 |
> |
uint32 sub_type = ReadMacInt32(thing + 4); |
455 |
|
if (c_type == FOURCC('s','d','e','v') && sub_type == FOURCC('s','i','n','g')) { |
456 |
< |
1[(uint32 *)p] = FOURCC('a','w','g','c'); |
456 |
> |
WriteMacInt32(thing + 4, FOURCC('a','w','g','c')); |
457 |
|
D(bug("thng %d, type %c%c%c%c (%08x), sub type %c%c%c%c (%08x), data %p\n", id, c_type >> 24, (c_type >> 16) & 0xff, (c_type >> 8) & 0xff, c_type & 0xff, c_type, sub_type >> 24, (sub_type >> 16) & 0xff, (sub_type >> 8) & 0xff, sub_type & 0xff, sub_type, p)); |
458 |
< |
AddSifter(*(uint32 *)(((uint32)p)+20), p[12]); |
459 |
< |
if (p[28]) // componentPFCount |
460 |
< |
AddSifter(*(uint32 *)(((uint32)p)+62), p[33]); |
458 |
> |
AddSifter(ReadMacInt32(thing + componentResType), ReadMacInt16(thing + componentResID)); |
459 |
> |
if (ReadMacInt32(thing + componentPFCount)) |
460 |
> |
AddSifter(ReadMacInt32(thing + componentPFResType), ReadMacInt16(thing + componentPFResID)); |
461 |
|
} |
462 |
|
|
463 |
|
} else if (type == FOURCC('s','i','f','t') || type == FOURCC('n','i','f','t')) { |
464 |
|
// Patch audio sifters |
465 |
|
if (FindSifter(type, id)) { |
466 |
|
D(bug("sifter found\n")); |
467 |
< |
p[0] = 0x4e56; p[1] = 0x0000; // link a6,#0 |
468 |
< |
p[2] = 0x48e7; p[3] = 0x8018; // movem.l d0/a3-a4,-(a7) |
469 |
< |
p[4] = 0x266e; p[5] = 0x000c; // movea.l $c(a6),a3 |
470 |
< |
p[6] = 0x286e; p[7] = 0x0008; // movea.l $8(a6),a4 |
471 |
< |
p[8] = M68K_EMUL_OP_AUDIO_DISPATCH; |
472 |
< |
p[9] = 0x2d40; p[10] = 0x0010; // move.l d0,$10(a6) |
473 |
< |
p[11] = 0x4cdf; p[12] = 0x1801; // movem.l (a7)+,d0/a3-a4 |
474 |
< |
p[13] = 0x4e5e; // unlk a6 |
475 |
< |
p[14] = 0x4e74; p[15] = 0x0008; // rtd #8 |
467 |
> |
p[0] = htons(0x4e56); p[1] = htons(0x0000); // link a6,#0 |
468 |
> |
p[2] = htons(0x48e7); p[3] = htons(0x8018); // movem.l d0/a3-a4,-(a7) |
469 |
> |
p[4] = htons(0x266e); p[5] = htons(0x000c); // movea.l $c(a6),a3 |
470 |
> |
p[6] = htons(0x286e); p[7] = htons(0x0008); // movea.l $8(a6),a4 |
471 |
> |
p[8] = htons(M68K_EMUL_OP_AUDIO_DISPATCH); |
472 |
> |
p[9] = htons(0x2d40); p[10] = htons(0x0010); // move.l d0,$10(a6) |
473 |
> |
p[11] = htons(0x4cdf); p[12] = htons(0x1801); // movem.l (a7)+,d0/a3-a4 |
474 |
> |
p[13] = htons(0x4e5e); // unlk a6 |
475 |
> |
p[14] = htons(0x4e74); p[15] = htons(0x0008); // rtd #8 |
476 |
|
D(bug(" patch applied\n")); |
477 |
|
} |
478 |
|
|
486 |
|
D(bug("INIT 1 (size 2416) found\n")); |
487 |
|
size >>= 1; |
488 |
|
while (size--) { |
489 |
< |
if (p[0] == 0x247c && p[1] == 0xf301 && p[2] == 0x9000) { |
489 |
> |
if (PM(0,0x247c) && PM(1,0xf301) && PM(2,0x9000)) { |
490 |
|
// Prevent "MacOS Licensing Extension" from accessing hardware (7.6) |
491 |
< |
p[22] = 0x6028; |
491 |
> |
p[22] = htons(0x6028); |
492 |
|
D(bug(" patch 1 applied\n")); |
493 |
|
break; |
494 |
|
} |
495 |
|
p++; |
496 |
|
} |
497 |
+ |
|
498 |
+ |
} else if (type == FOURCC('s','c','o','d') && id == -16465) { |
499 |
+ |
D(bug("scod -16465 found\n")); |
500 |
+ |
|
501 |
+ |
// Don't crash in Process Manager on reset/shutdown (8.6) |
502 |
+ |
static const uint8 dat[] = {0x4e, 0x56, 0x00, 0x00, 0x48, 0xe7, 0x03, 0x18, 0x2c, 0x2e, 0x00, 0x10}; |
503 |
+ |
base = find_rsrc_data((uint8 *)p, size, dat, sizeof(dat)); |
504 |
+ |
if (base) { |
505 |
+ |
p16 = (uint16 *)((uintptr)p + base); |
506 |
+ |
p16[0] = htons(0x7000); // moveq #0,d0 |
507 |
+ |
p16[1] = htons(M68K_RTS); |
508 |
+ |
D(bug(" patch 1 applied\n")); |
509 |
+ |
} |
510 |
+ |
|
511 |
+ |
} else if (type == FOURCC('N','O','b','j') && id == 100) { |
512 |
+ |
D(bug("NObj 100 found\n")); |
513 |
+ |
|
514 |
+ |
// Don't access VIA registers in MacBench 5.0 |
515 |
+ |
static const uint8 dat1[] = {0x7c, 0x08, 0x02, 0xa6, 0xbf, 0x01, 0xff, 0xe0, 0x90, 0x01, 0x00, 0x08}; |
516 |
+ |
base = find_rsrc_data((uint8 *)p, size, dat1, sizeof(dat1)); |
517 |
+ |
if (base) { |
518 |
+ |
p[(base + 0x00) >> 1] = htons(0x3860); // li r3,0 |
519 |
+ |
p[(base + 0x02) >> 1] = htons(0x0000); |
520 |
+ |
p[(base + 0x04) >> 1] = htons(0x4e80); // blr |
521 |
+ |
p[(base + 0x06) >> 1] = htons(0x0020); |
522 |
+ |
D(bug(" patch 1 applied\n")); |
523 |
+ |
} |
524 |
+ |
static const uint8 dat2[] = {0x7c, 0x6c, 0x1b, 0x78, 0x7c, 0x8b, 0x23, 0x78, 0x38, 0xc0, 0x3f, 0xfd}; |
525 |
+ |
base = find_rsrc_data((uint8 *)p, size, dat2, sizeof(dat2)); |
526 |
+ |
if (base) { |
527 |
+ |
p[(base + 0x00) >> 1] = htons(0x3860); // li r3,0 |
528 |
+ |
p[(base + 0x02) >> 1] = htons(0x0000); |
529 |
+ |
p[(base + 0x04) >> 1] = htons(0x4e80); // blr |
530 |
+ |
p[(base + 0x06) >> 1] = htons(0x0020); |
531 |
+ |
D(bug(" patch 2 applied\n")); |
532 |
+ |
} |
533 |
|
} |
534 |
|
} |
535 |
|
|
540 |
|
|
541 |
|
#ifdef __BEOS__ |
542 |
|
static |
543 |
+ |
#else |
544 |
+ |
extern "C" |
545 |
|
#endif |
546 |
< |
void check_load_invoc(uint32 type, int16 id, uint16 **h) |
546 |
> |
void check_load_invoc(uint32 type, int16 id, uint32 h) |
547 |
|
{ |
548 |
< |
if (h == NULL) |
548 |
> |
if (h == 0) |
549 |
|
return; |
550 |
< |
uint16 *p = *h; |
551 |
< |
if (p == NULL) |
550 |
> |
uint32 p = ReadMacInt32(h); |
551 |
> |
if (p == 0) |
552 |
|
return; |
553 |
< |
uint32 size = ((uint32 *)p)[-2] & 0xffffff; |
553 |
> |
uint32 size = ReadMacInt32(p - 2 * 4) & 0xffffff; |
554 |
|
|
555 |
< |
CheckLoad(type, id, p, size); |
555 |
> |
CheckLoad(type, id, (uint16 *)p, size); |
556 |
|
} |
557 |
|
|
558 |
|
#ifdef __BEOS__ |
734 |
|
D(bug("PatchNativeResourceManager\n")); |
735 |
|
|
736 |
|
// Patch native GetResource() |
737 |
< |
uint32 **upp = *(uint32 ***)0x1480; |
738 |
< |
if (((uint32)upp & 0xffc00000) == ROM_BASE) |
737 |
> |
uint32 upp = ReadMacInt32(0x1480); |
738 |
> |
if ((upp & 0xffc00000) == ROM_BASE) |
739 |
|
return; |
740 |
< |
uint32 *tvec = upp[5]; |
741 |
< |
D(bug(" GetResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
740 |
> |
uint32 *tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
741 |
> |
D(bug(" GetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
742 |
|
*(uint32 *)XLM_RES_LIB_TOC = tvec[1]; |
743 |
|
*(uint32 *)XLM_GET_RESOURCE = tvec[0]; |
744 |
+ |
#if EMULATED_PPC |
745 |
+ |
tvec[0] = htonl(NativeFunction(NATIVE_GET_RESOURCE)); |
746 |
+ |
#else |
747 |
|
#ifdef __BEOS__ |
748 |
|
uint32 *tvec2 = (uint32 *)get_resource; |
749 |
|
tvec[0] = tvec2[0]; |
751 |
|
#else |
752 |
|
tvec[0] = (uint32)get_resource; |
753 |
|
#endif |
754 |
+ |
#endif |
755 |
|
|
756 |
|
// Patch native Get1Resource() |
757 |
< |
upp = *(uint32 ***)0xe7c; |
758 |
< |
tvec = upp[5]; |
759 |
< |
D(bug(" Get1Resource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
757 |
> |
upp = ReadMacInt32(0x0e7c); |
758 |
> |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
759 |
> |
D(bug(" Get1Resource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
760 |
|
*(uint32 *)XLM_GET_1_RESOURCE = tvec[0]; |
761 |
+ |
#if EMULATED_PPC |
762 |
+ |
tvec[0] = htonl(NativeFunction(NATIVE_GET_1_RESOURCE)); |
763 |
+ |
#else |
764 |
|
#ifdef __BEOS__ |
765 |
|
tvec2 = (uint32 *)get_1_resource; |
766 |
|
tvec[0] = tvec2[0]; |
768 |
|
#else |
769 |
|
tvec[0] = (uint32)get_1_resource; |
770 |
|
#endif |
771 |
+ |
#endif |
772 |
|
|
773 |
|
// Patch native GetIndResource() |
774 |
< |
upp = *(uint32 ***)0x1474; |
775 |
< |
tvec = upp[5]; |
776 |
< |
D(bug(" GetIndResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
774 |
> |
upp = ReadMacInt32(0x1474); |
775 |
> |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
776 |
> |
D(bug(" GetIndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
777 |
|
*(uint32 *)XLM_GET_IND_RESOURCE = tvec[0]; |
778 |
+ |
#if EMULATED_PPC |
779 |
+ |
tvec[0] = htonl(NativeFunction(NATIVE_GET_IND_RESOURCE)); |
780 |
+ |
#else |
781 |
|
#ifdef __BEOS__ |
782 |
|
tvec2 = (uint32 *)get_ind_resource; |
783 |
|
tvec[0] = tvec2[0]; |
785 |
|
#else |
786 |
|
tvec[0] = (uint32)get_ind_resource; |
787 |
|
#endif |
788 |
+ |
#endif |
789 |
|
|
790 |
|
// Patch native Get1IndResource() |
791 |
< |
upp = *(uint32 ***)0xe38; |
792 |
< |
tvec = upp[5]; |
793 |
< |
D(bug(" Get1IndResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
791 |
> |
upp = ReadMacInt32(0x0e38); |
792 |
> |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
793 |
> |
D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
794 |
|
*(uint32 *)XLM_GET_1_IND_RESOURCE = tvec[0]; |
795 |
+ |
#if EMULATED_PPC |
796 |
+ |
tvec[0] = htonl(NativeFunction(NATIVE_GET_1_IND_RESOURCE)); |
797 |
+ |
#else |
798 |
|
#ifdef __BEOS__ |
799 |
|
tvec2 = (uint32 *)get_1_ind_resource; |
800 |
|
tvec[0] = tvec2[0]; |
802 |
|
#else |
803 |
|
tvec[0] = (uint32)get_1_ind_resource; |
804 |
|
#endif |
805 |
+ |
#endif |
806 |
|
|
807 |
|
// Patch native RGetResource() |
808 |
< |
upp = *(uint32 ***)0xe30; |
809 |
< |
tvec = upp[5]; |
810 |
< |
D(bug(" RGetResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
808 |
> |
upp = ReadMacInt32(0x0e30); |
809 |
> |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
810 |
> |
D(bug(" RGetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
811 |
|
*(uint32 *)XLM_R_GET_RESOURCE = tvec[0]; |
812 |
+ |
#if EMULATED_PPC |
813 |
+ |
tvec[0] = htonl(NativeFunction(NATIVE_R_GET_RESOURCE)); |
814 |
+ |
#else |
815 |
|
#ifdef __BEOS__ |
816 |
|
tvec2 = (uint32 *)r_get_resource; |
817 |
|
tvec[0] = tvec2[0]; |
819 |
|
#else |
820 |
|
tvec[0] = (uint32)r_get_resource; |
821 |
|
#endif |
822 |
+ |
#endif |
823 |
|
} |