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

Comparing SheepShaver/src/rsrc_patches.cpp (file contents):
Revision 1.11 by gbeauche, 2004-06-20T19:10:02Z vs.
Revision 1.12 by gbeauche, 2004-11-13T14:09:15Z

# Line 117 | Line 117 | void CheckLoad(uint32 type, int16 id, ui
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) {
# Line 468 | Line 468 | void CheckLoad(uint32 type, int16 id, ui
468  
469          } else if (type == FOURCC('t','h','n','g')) {
470                  // Collect info about used audio sifters
471 <                uint32 thing = (uintptr)p;
471 >                uint32 thing = Host2MacAddr((uint8 *)p);
472                  uint32 c_type = ReadMacInt32(thing);
473                  uint32 sub_type = ReadMacInt32(thing + 4);
474                  if (c_type == FOURCC('s','d','e','v') && sub_type == FOURCC('s','i','n','g')) {
# Line 571 | Line 571 | void check_load_invoc(uint32 type, int16
571                  return;
572          uint32 size = ReadMacInt32(p - 2 * 4) & 0xffffff;
573  
574 <        CheckLoad(type, id, (uint16 *)p, size);
574 >        CheckLoad(type, id, (uint16 *)Mac2HostAddr(p), size);
575   }
576  
577   #ifdef __BEOS__
# Line 756 | Line 756 | void PatchNativeResourceManager(void)
756          uint32 upp = ReadMacInt32(0x1480);
757          if ((upp & 0xffc00000) == ROM_BASE)
758                  return;
759 <        uint32 *tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
760 <        D(bug(" GetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
761 <        *(uint32 *)XLM_RES_LIB_TOC = tvec[1];
762 <        *(uint32 *)XLM_GET_RESOURCE = tvec[0];
759 >        uint32 tvec = ReadMacInt32(upp + 5 * 4);
760 >        D(bug(" GetResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
761 >        WriteMacInt32(XLM_RES_LIB_TOC, ReadMacInt32(tvec + 4));
762 >        WriteMacInt32(XLM_GET_RESOURCE, ReadMacInt32(tvec));
763   #if EMULATED_PPC
764 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_RESOURCE));
764 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_RESOURCE));
765   #else
766   #ifdef __BEOS__
767          uint32 *tvec2 = (uint32 *)get_resource;
768 <        tvec[0] = tvec2[0];
769 <        tvec[1] = tvec2[1];
768 >        WriteMacInt32(tvec, tvec2[0]);
769 >        WriteMacInt32(tvec + 4, tvec2[1]);
770   #else
771 <        tvec[0] = (uint32)get_resource;
771 >        WriteMacInt32(tvec, (uint32)get_resource);
772   #endif
773   #endif
774  
775          // Patch native Get1Resource()
776          upp = ReadMacInt32(0x0e7c);
777 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
778 <        D(bug(" Get1Resource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
779 <        *(uint32 *)XLM_GET_1_RESOURCE = tvec[0];
777 >        tvec = ReadMacInt32(upp + 5 * 4);
778 >        D(bug(" Get1Resource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
779 >        WriteMacInt32(XLM_GET_1_RESOURCE, ReadMacInt32(tvec));
780   #if EMULATED_PPC
781 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_1_RESOURCE));
781 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_RESOURCE));
782   #else
783   #ifdef __BEOS__
784          tvec2 = (uint32 *)get_1_resource;
785 <        tvec[0] = tvec2[0];
786 <        tvec[1] = tvec2[1];
785 >        WriteMacInt32(tvec, tvec2[0]);
786 >        WriteMacInt32(tvec + 4, tvec2[1]);
787   #else
788 <        tvec[0] = (uint32)get_1_resource;
788 >        WriteMacInt32(tvec, (uint32)get_1_resource);
789   #endif
790   #endif
791  
792          // Patch native GetIndResource()
793          upp = ReadMacInt32(0x1474);
794 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
795 <        D(bug(" GetIndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
796 <        *(uint32 *)XLM_GET_IND_RESOURCE = tvec[0];
794 >        tvec = ReadMacInt32(upp + 5 * 4);
795 >        D(bug(" GetIndResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
796 >        WriteMacInt32(XLM_GET_IND_RESOURCE, ReadMacInt32(tvec));
797   #if EMULATED_PPC
798 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_IND_RESOURCE));
798 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_IND_RESOURCE));
799   #else
800   #ifdef __BEOS__
801          tvec2 = (uint32 *)get_ind_resource;
802 <        tvec[0] = tvec2[0];
803 <        tvec[1] = tvec2[1];
802 >        WriteMacInt32(tvec, tvec2[0]);
803 >        WriteMacInt32(tvec + 4, tvec2[1]);
804   #else
805 <        tvec[0] = (uint32)get_ind_resource;
805 >        WriteMacInt32(tvec, (uint32)get_ind_resource);
806   #endif
807   #endif
808  
809          // Patch native Get1IndResource()
810          upp = ReadMacInt32(0x0e38);
811 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
812 <        D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
813 <        *(uint32 *)XLM_GET_1_IND_RESOURCE = tvec[0];
811 >        tvec = ReadMacInt32(upp + 5 * 4);
812 >        D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
813 >        WriteMacInt32(XLM_GET_1_IND_RESOURCE, ReadMacInt32(tvec));
814   #if EMULATED_PPC
815 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_1_IND_RESOURCE));
815 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_IND_RESOURCE));
816   #else
817   #ifdef __BEOS__
818          tvec2 = (uint32 *)get_1_ind_resource;
819 <        tvec[0] = tvec2[0];
820 <        tvec[1] = tvec2[1];
819 >        WriteMacInt32(tvec, tvec2[0]);
820 >        WriteMacInt32(tvec + 4, tvec2[1]);
821   #else
822 <        tvec[0] = (uint32)get_1_ind_resource;
822 >        WriteMacInt32(tvec, (uint32)get_1_ind_resource);
823   #endif
824   #endif
825  
826          // Patch native RGetResource()
827          upp = ReadMacInt32(0x0e30);
828 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
829 <        D(bug(" RGetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
830 <        *(uint32 *)XLM_R_GET_RESOURCE = tvec[0];
828 >        tvec = ReadMacInt32(upp + 5 * 4);
829 >        D(bug(" RGetResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
830 >        WriteMacInt32(XLM_R_GET_RESOURCE, ReadMacInt32(tvec));
831   #if EMULATED_PPC
832 <        tvec[0] = htonl(NativeFunction(NATIVE_R_GET_RESOURCE));
832 >        WriteMacInt32(tvec, NativeFunction(NATIVE_R_GET_RESOURCE));
833   #else
834   #ifdef __BEOS__
835          tvec2 = (uint32 *)r_get_resource;
836 <        tvec[0] = tvec2[0];
837 <        tvec[1] = tvec2[1];
836 >        WriteMacInt32(tvec, tvec2[0]);
837 >        WriteMacInt32(tvec + 4, tvec2[1]);
838   #else
839 <        tvec[0] = (uint32)r_get_resource;
839 >        WriteMacInt32(tvec, (uint32)r_get_resource);
840   #endif
841   #endif
842   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines