コード例 #1
0
            internal static bool goodchecksum(IList <byte> romdata, RomMapMode mode, int size)
            {
                int snestopc(int snesAddress) => RomUtil.ConvertSnesToPc(snesAddress, mode, size);

                var checksum = (int)getchecksum(romdata);

                return(((romdata[snestopc(0x00FFDE)] ^ romdata[snestopc(0x00FFDC)]) == 0xFF) &&
                       ((romdata[snestopc(0x00FFDF)] ^ romdata[snestopc(0x00FFDD)]) == 0xFF) &&
                       ((romdata[snestopc(0x00FFDE)] & 0xFF) == (checksum & 0xFF)) &&
                       ((romdata[snestopc(0x00FFDF)] & 0xFF) == ((checksum >> 8) & 0xFF)));
            }
コード例 #2
0
        public ImportRomSettings CreateSettings()
        {
            ImportSettings.InitialLabels = RomUtil.GenerateVectorLabels(
                VectorTableEntriesEnabled, ImportSettings.RomSettingsOffset, ImportSettings.RomBytes, ImportSettings.RomMapMode);

            if (ShouldCheckHeader)
            {
                ImportSettings.InitialHeaderFlags =
                    RomUtil.GenerateHeaderFlags(ImportSettings.RomSettingsOffset, ImportSettings.RomBytes);
            }

            return(ImportSettings);
        }
コード例 #3
0
            internal static void fixchecksum(IList <byte> romdata, RomMapMode mode, int size)
            {
                int snestopc(int snesAddress) => RomUtil.ConvertSnesToPc(snesAddress, mode, size);

                // randomdude999: clear out checksum bytes before recalculating checksum, this should make it correct on roms that don't have a checksum yet
                romdata.writeromdata(snestopc(0x00FFDC), 0xFFFF0000);
                var checksum = getchecksum(romdata);

                romdata.writeromdata_byte(snestopc(0x00FFDE), (byte)(checksum & 255));
                romdata.writeromdata_byte(snestopc(0x00FFDF), (byte)((checksum >> 8) & 255));
                romdata.writeromdata_byte(snestopc(0x00FFDC), (byte)((checksum & 255) ^ 255));
                romdata.writeromdata_byte(snestopc(0x00FFDD), (byte)(((checksum >> 8) & 255) ^ 255));
            }
コード例 #4
0
        public void Init(string romFilename)
        {
            var rawRomBytes = RomUtil.ReadRomFileBytes(romFilename);

            ImportSettings = new ImportRomSettings
            {
                RomFilename = romFilename,
                RomBytes    = rawRomBytes,
                RomMapMode  = RomUtil.DetectRomMapMode(rawRomBytes, out var detectedMapModeSuccess),
            };

            ImportSettings.RomSpeed = RomUtil.GetRomSpeed(ImportSettings.RomSettingsOffset, rawRomBytes);

            if (detectedMapModeSuccess)
            {
                DetectedMapMode = ImportSettings.RomMapMode;
            }

            VectorTableEntriesEnabled = GenerateVectors();
        }
コード例 #5
0
ファイル: RomUtil.cs プロジェクト: furious/diztinguish
        public static int ConvertSnesToPc(int address, RomMapMode mode, int size)
        {
            if (address < 0)
            {
                return(-1);
            }

            int UnmirroredOffset(int offset) => RomUtil.UnmirroredOffset(offset, size);

            // WRAM is N/A to PC addressing
            if ((address & 0xFE0000) == 0x7E0000)
            {
                return(-1);
            }

            // WRAM mirror & PPU regs are N/A to PC addressing
            if (((address & 0x400000) == 0) && ((address & 0x8000) == 0))
            {
                return(-1);
            }

            switch (mode)
            {
            case RomMapMode.LoRom:
            {
                // SRAM is N/A to PC addressing
                if (((address & 0x700000) == 0x700000) && ((address & 0x8000) == 0))
                {
                    return(-1);
                }

                return(UnmirroredOffset(((address & 0x7F0000) >> 1) | (address & 0x7FFF)));
            }

            case RomMapMode.HiRom:
            {
                return(UnmirroredOffset(address & 0x3FFFFF));
            }

            case RomMapMode.SuperMmc:
            {
                return(UnmirroredOffset(address & 0x3FFFFF));    // todo, treated as hirom atm
            }

            case RomMapMode.Sa1Rom:
            case RomMapMode.ExSa1Rom:
            {
                // BW-RAM is N/A to PC addressing
                if (address >= 0x400000 && address <= 0x7FFFFF)
                {
                    return(-1);
                }

                if (address >= 0xC00000)
                {
                    return(mode == RomMapMode.ExSa1Rom ? UnmirroredOffset(address & 0x7FFFFF) : UnmirroredOffset(address & 0x3FFFFF));
                }

                if (address >= 0x800000)
                {
                    address -= 0x400000;
                }

                // SRAM is N/A to PC addressing
                if (((address & 0x8000) == 0))
                {
                    return(-1);
                }

                return(UnmirroredOffset(((address & 0x7F0000) >> 1) | (address & 0x7FFF)));
            }

            case RomMapMode.SuperFx:
            {
                // BW-RAM is N/A to PC addressing
                if (address >= 0x600000 && address <= 0x7FFFFF)
                {
                    return(-1);
                }

                if (address < 0x400000)
                {
                    return(UnmirroredOffset(((address & 0x7F0000) >> 1) | (address & 0x7FFF)));
                }

                if (address < 0x600000)
                {
                    return(UnmirroredOffset(address & 0x3FFFFF));
                }

                if (address < 0xC00000)
                {
                    return(0x200000 + UnmirroredOffset(((address & 0x7F0000) >> 1) | (address & 0x7FFF)));
                }

                return(0x400000 + UnmirroredOffset(address & 0x3FFFFF));
            }

            case RomMapMode.ExHiRom:
            {
                return(UnmirroredOffset(((~address & 0x800000) >> 1) | (address & 0x3FFFFF)));
            }

            case RomMapMode.ExLoRom:
            {
                // SRAM is N/A to PC addressing
                if (((address & 0x700000) == 0x700000) && ((address & 0x8000) == 0))
                {
                    return(-1);
                }

                return(UnmirroredOffset((((address ^ 0x800000) & 0xFF0000) >> 1) | (address & 0x7FFF)));
            }

            default:
            {
                return(-1);
            }
            }
        }