예제 #1
0
파일: Cartridge.cs 프로젝트: vilinet/6502
        public void LoadRom(string filepath)
        {
            using (var reader = new BinaryReader(new FileStream(filepath, FileMode.Open, FileAccess.Read)))
            {
                Info = LoadHeader(reader);

                if (Info.HasTrainerData)
                {
                    _trainerData = reader.ReadBytes(512);
                }
                _prgRom = reader.ReadBytes(Info.ProgramBanks * 16 * 1024);
                _chrRom = reader.ReadBytes(Info.CharBanks * 8 * 1024);
            }

            _mapper = GetMapper(Info.MapperId);
        }
예제 #2
0
파일: Cartridge.cs 프로젝트: vilinet/6502
        private RomInfo LoadHeader(BinaryReader reader)
        {
            var info  = new RomInfo();
            var bytes = reader.ReadBytes(16);

            info.ProgramBanks           = bytes[4];
            info.CharBanks              = bytes[5];
            info.Mirroring              = (bytes[6] & 1) == 1 ? Mirroring.Vertical : Mirroring.Horizontal;
            info.HasBattery             = (bytes[6] & 2) == 2;
            info.HasTrainerData         = (bytes[6] & 3) == 4;
            info.IgnoreMirroringControl = (bytes[6] & 4) == 8;
            info.MapperId   = (bytes[6] & 0xF0) >> 4;
            info.Unisystem  = (bytes[7] & 1) == 1;
            info.PlayChoice = (bytes[7] & 2) == 2;
            info.NewFormat  = (bytes[7] & 6) == 6;
            info.MapperId  += (bytes[7] & 0xF0);

            return(info);
        }