ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/rom_patches.cpp
(Generate patch)

Comparing SheepShaver/src/rom_patches.cpp (file contents):
Revision 1.41 by gbeauche, 2005-03-05T15:44:03Z vs.
Revision 1.42 by gbeauche, 2005-12-12T20:46:31Z

# Line 224 | Line 224 | static uint32 rsrc_ptr = 0;
224   // id = 4711 means "find any ID"
225   static uint32 find_rom_resource(uint32 s_type, int16 s_id = 4711, bool cont = false)
226   {
227 <        uint32 *lp = (uint32 *)(ROMBaseHost + 0x1a);
228 <        uint32 x = ntohl(*lp);
229 <        uint8 *bp = (uint8 *)(ROMBaseHost + x + 5);
230 <        uint32 header_size = *bp;
227 >        uint32 lp = ROM_BASE + 0x1a;
228 >        uint32 x = ReadMacInt32(lp);
229 >        uint32 header_size = ReadMacInt8(ROM_BASE + x + 5);
230  
231          if (!cont)
232                  rsrc_ptr = x;
# Line 235 | Line 234 | static uint32 find_rom_resource(uint32 s
234                  return 0;
235  
236          for (;;) {
237 <                lp = (uint32 *)(ROMBaseHost + rsrc_ptr);
238 <                rsrc_ptr = ntohl(*lp);
237 >                lp = ROM_BASE + rsrc_ptr;
238 >                rsrc_ptr = ReadMacInt32(lp);
239                  if (rsrc_ptr == 0)
240                          break;
241  
242                  rsrc_ptr += header_size;
243  
244 <                lp = (uint32 *)(ROMBaseHost + rsrc_ptr + 4);
245 <                uint32 data = ntohl(*lp); lp++;
246 <                uint32 type = ntohl(*lp); lp++;
247 <                int16 id = ntohs(*(int16 *)lp);
244 >                lp = ROM_BASE + rsrc_ptr + 4;
245 >                uint32 data = ReadMacInt32(lp);
246 >                uint32 type = ReadMacInt32(lp + 4);
247 >                int16 id = ReadMacInt16(lp + 8);
248                  if (type == s_type && (id == s_id || s_id == 4711))
249                          return data;
250          }
# Line 259 | Line 258 | static uint32 find_rom_resource(uint32 s
258  
259   static uint32 find_rom_trap(uint16 trap)
260   {
261 <        uint32 *lp = (uint32 *)(ROMBaseHost + 0x22);
263 <        lp = (uint32 *)(ROMBaseHost + ntohl(*lp));
261 >        uint32 lp = ROM_BASE + ReadMacInt32(ROM_BASE + 0x22);
262  
263          if (trap > 0xa800)
264 <                return ntohl(lp[trap & 0x3ff]);
264 >                return ReadMacInt32(lp + 4 * (trap & 0x3ff));
265          else
266 <                return ntohl(lp[(trap & 0xff) + 0x400]);
266 >                return ReadMacInt32(lp + 4 * ((trap & 0xff) + 0x400));
267   }
268  
269  
# Line 1715 | Line 1713 | static bool patch_68k(void)
1713          static const uint8 ext_cache_dat[] = {0x4e, 0x7b, 0x00, 0x02};
1714          if ((base = find_rom_data(0x1d0, 0x230, ext_cache_dat, sizeof(ext_cache_dat))) == 0) return false;
1715          D(bug("ext_cache %08lx\n", base));
1716 <        lp = (uint32 *)(ROMBaseHost + base + 6);
1717 <        wp = (uint16 *)(ROMBaseHost + ntohl(*lp) + base + 6);
1716 >        loc = ReadMacInt32(ROM_BASE + base + 6);
1717 >        wp = (uint16 *)(ROMBaseHost + loc + base + 6);
1718          *wp = htons(M68K_RTS);
1719 <        lp = (uint32 *)(ROMBaseHost + base + 12);
1720 <        wp = (uint16 *)(ROMBaseHost + ntohl(*lp) + base + 12);
1719 >        loc = ReadMacInt32(ROM_BASE + base + 12);
1720 >        wp = (uint16 *)(ROMBaseHost + loc + base + 12);
1721          *wp = htons(M68K_RTS);
1722  
1723          // Fake CPU speed test (SetupTimeK)
# Line 2264 | Line 2262 | static bool patch_68k(void)
2262          *wp++ = htons(M68K_JMP);
2263          *wp++ = htons((ROM_BASE + put_scrap) >> 16);
2264          *wp++ = htons((ROM_BASE + put_scrap) & 0xffff);
2265 <        lp = (uint32 *)(ROMBaseHost + 0x22);
2266 <        lp = (uint32 *)(ROMBaseHost + ntohl(*lp));
2269 <        lp[0xa9fe & 0x3ff] = htonl(PUT_SCRAP_PATCH_SPACE);
2265 >        base = ROM_BASE + ReadMacInt32(ROM_BASE + 0x22);
2266 >        WriteMacInt32(base + 4 * (0xa9fe & 0x3ff), PUT_SCRAP_PATCH_SPACE);
2267  
2268          // Patch GetScrap() for clipboard exchange with host OS
2269          uint32 get_scrap = find_rom_trap(0xa9fd);       // GetScrap()
# Line 2275 | Line 2272 | static bool patch_68k(void)
2272          *wp++ = htons(M68K_JMP);
2273          *wp++ = htons((ROM_BASE + get_scrap) >> 16);
2274          *wp++ = htons((ROM_BASE + get_scrap) & 0xffff);
2275 <        lp = (uint32 *)(ROMBaseHost + 0x22);
2276 <        lp = (uint32 *)(ROMBaseHost + ntohl(*lp));
2280 <        lp[0xa9fd & 0x3ff] = htonl(GET_SCRAP_PATCH_SPACE);
2275 >        base = ROM_BASE + ReadMacInt32(ROM_BASE + 0x22);
2276 >        WriteMacInt32(base + 4 * (0xa9fd & 0x3ff), GET_SCRAP_PATCH_SPACE);
2277  
2278          // Patch SynchIdleTime()
2279          if (PrefsFindBool("idlewait")) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines