Exemple #1
0
        public CartRom(Stream romDataStream, Boolean headerOnly, FormatVerifyFlag verifyFlag)
        {
            m_HeaderOnly = headerOnly;

            /* Check some properties about the source stream */
            if (romDataStream.Length < (HeaderSize + BootRom.Size))
            {
                throw new ArgumentOutOfRangeException("Rom is too small to be valid");
            }

            if (!romDataStream.CanRead)
            {
                throw new ArgumentException("The source rom stream is not readable");
            }

            /* Verify the rom format and make the nessarily action */
            RomFormat format = RomFormat.Unknown;

            switch (verifyFlag)
            {
            case FormatVerifyFlag.Skip: break;

            case FormatVerifyFlag.Header: format = Cartridge.DetectFormatHeader(romDataStream); break;

            case FormatVerifyFlag.Cic: format = Cartridge.DectectFormatCIC(romDataStream); break;

            case FormatVerifyFlag.Crc: format = Cartridge.DectectFormatCRC(romDataStream); break;
            }

            if (verifyFlag != FormatVerifyFlag.Skip && format == RomFormat.Unknown)
            {
                logger.Warn("treid to verify rom but failed, emulator may be unstable");
            }
            else
            {
                romDataStream = Cartridge.GetCorrectStream(romDataStream, format);
            }

            /* Create the header */
            CreateHeader(romDataStream);

            /* Create the bootcode information */
            m_BootRom = new BootRom(romDataStream);

            if (!headerOnly)
            {
                m_RomStream            = romDataStream;
                romDataStream.Position = 0;
            }
        }
Exemple #2
0
        public CartRom(Stream romDataStream, Boolean headerOnly, FormatVerifyFlag verifyFlag)
        {
            m_HeaderOnly = headerOnly;

            /* Check some properties about the source stream */
            if (romDataStream.Length < (HeaderSize + BootRom.Size))
                throw new ArgumentOutOfRangeException("Rom is too small to be valid");

            if (!romDataStream.CanRead)
                throw new ArgumentException("The source rom stream is not readable");

            /* Verify the rom format and make the nessarily action */
            RomFormat format = RomFormat.Unknown;

            switch (verifyFlag)
            {
                case FormatVerifyFlag.Skip: break;
                case FormatVerifyFlag.Header: format = Cartridge.DetectFormatHeader(romDataStream); break;
                case FormatVerifyFlag.Cic: format = Cartridge.DectectFormatCIC(romDataStream); break;
                case FormatVerifyFlag.Crc: format = Cartridge.DectectFormatCRC(romDataStream); break;
            }

            if (verifyFlag != FormatVerifyFlag.Skip && format == RomFormat.Unknown)
            {
                logger.Warn("treid to verify rom but failed, emulator may be unstable");
            }
            else
            {
                romDataStream = Cartridge.GetCorrectStream(romDataStream, format);
            }

            /* Create the header */
            CreateHeader(romDataStream);

            /* Create the bootcode information */
            m_BootRom = new BootRom(romDataStream);

            if (!headerOnly)
            {
                m_RomStream = romDataStream;
                romDataStream.Position = 0;
            }
        }