예제 #1
0
        internal static bool GameInit()
        {
            long RAMBaseAddr  = 0;
            var  mmap_entries = ImportsMgr.EnumerateVirtualMemorySpaces(dolphin).Where(mmap_entry =>
                                                                                       mmap_entry.Size == 0x2000000 &&
                                                                                       !mmap_entry.IsPrivate &&
                                                                                       mmap_entry.Permissions == (VirtualMemoryPermissions.READ | VirtualMemoryPermissions.WRITE)
                                                                                       ).ToArray();

            foreach (var mmap_entry in mmap_entries)
            {
                RAMBaseAddr = mmap_entry.BaseAddress;
                GCMem.Init(dolphin, RAMBaseAddr);
                if (!IsValidGameCode(GameCode))
                {
                    RAMBaseAddr = 0;
                    GCMem.DeInit();
                    continue;
                }
                break;
            }
            return(RAMBaseAddr != 0);
        }
예제 #2
0
        internal static void InitMP()
        {
            MetroidPrime = null;
            if (IsGCGame)
            {
                if (GameCode.Substring(0, 3) == "GM8")
                {
                    if (GameCode[3] == 'E')
                    {
                        if (GameVersion == 0)
                        {
                            MetroidPrime = new Prime.MP1_NTSC_0_00();
                        }
                        if (GameVersion == 1)
                        {
                            MetroidPrime = new Prime.MP1_NTSC_0_01();
                        }
                        if (GameVersion == 2)
                        {
                            MetroidPrime = new Prime.MP1_NTSC_0_02();
                        }
                        if (GameVersion == 48)
                        {
                            MetroidPrime = new Prime.MP1_NTSC_K();
                        }
                    }
                    if (GameCode[3] == 'J')
                    {
                        MetroidPrime = new Prime.MP1_NTSC_J();
                    }
                    if (GameCode[3] == 'P')
                    {
                        MetroidPrime = new Prime.MP1_PAL();
                    }
                }
                if (GameCode.Substring(0, 3) == "G2M")
                {
                    if (GameCode[3] == 'E')
                    {
                        MetroidPrime = new Echoes.MP2_NTSC_U();
                    }
                    if (GameCode[3] == 'J')
                    {
                        MetroidPrime = new Echoes.MP2_NTSC_J();
                    }
                    if (GameCode[3] == 'P')
                    {
                        MetroidPrime = new Echoes.MP2_PAL();
                    }
                }
            }
            if (IsWiiGame)
            {
                UInt32 opcode = GCMem.ReadUInt32(0x8046d340);
                if (GameCode.Substring(0, 2) == "R3")
                {
                    // Trilogy
                    if (GameCode[2] == 'M')
                    {
                        if (GameCode[3] == 'E')
                        {
                            while ((opcode = GCMem.ReadUInt32(0x8046d340)) == 0x38000018)
                            {
                                Thread.Sleep(10);
                            }
                            if (opcode == 0x4e800020)
                            {
                                MetroidPrime = new Prime.MPT_MP1_NTSC_U();
                            }
                            if (opcode == 0x4bff64e1)
                            {
                                MetroidPrime = new Echoes.MPT_MP2_NTSC_U();
                            }
                            // Wait for game to be fully loaded
                            Thread.Sleep(100);
                            if (GCMem.ReadUInt32(0x80576ae8) == 0x7d415378)
                            {
                                MetroidPrime = new Corruption.MPT_MP3_NTSC_U();
                            }
                        }
                        if (GameCode[3] == 'P')
                        {
                            while ((opcode = GCMem.ReadUInt32(0x8046d340)) == 0x7c0000d0)
                            {
                                Thread.Sleep(10);
                            }
                            if (opcode == 0x7c962378)
                            {
                                MetroidPrime = new Prime.MPT_MP1_PAL();
                            }
                            if (opcode == 0x80830000)
                            {
                                MetroidPrime = new Echoes.MPT_MP2_PAL();
                            }
                            // Wait for game to be fully loaded
                            Thread.Sleep(100);
                            if (GCMem.ReadUInt32(0x805795a4) == 0x7d415378)
                            {
                                MetroidPrime = new Corruption.MPT_MP3_PAL();
                            }
                        }
                    }

                    if (GameCode[2] == 'I' && GameCode[3] == 'J')
                    {
                        while ((opcode = GCMem.ReadUInt32(0x8046d340)) == 0x806ddaec)
                        {
                            Thread.Sleep(10);
                        }
                        if (opcode == 0x53687566)
                        {
                            MetroidPrime = new Prime.MPT_MP1_NTSC_J();
                        }
                    }

                    if (GameCode[2] == '2' && GameCode[3] == 'J')
                    {
                        while ((opcode = GCMem.ReadUInt32(0x8046d340)) == 0x801e0000)
                        {
                            Thread.Sleep(10);
                        }
                        if (opcode == 0x936daabc)
                        {
                            MetroidPrime = new Echoes.MPT_MP2_NTSC_J();
                        }
                    }
                }

                if (GameCode.Substring(0, 3) == "RM3")
                {
                    if (GameCode[3] == 'E')
                    {
                        MetroidPrime = new Corruption.MP3_NTSC_U();
                    }
                    if (GameCode[3] == 'J')
                    {
                        MetroidPrime = new Corruption.MP3_NTSC_J();
                    }
                    if (GameCode[3] == 'P')
                    {
                        MetroidPrime = new Corruption.MP3_PAL();
                    }
                }
            }
        }