public Mbc1(string romPath, bool hasRam, int romBankCount, RamSize ramSize, byte[] cartridgeData) : base(romPath) { mode = 0; this.romBankCount = romBankCount; MemoryRange[] switchableBanks = new MemoryRange[romBankCount]; for (int i = 0; i < romBankCount; i++) { int startAddress = RomSizePerBank * i; var bankdata = GetCartridgeChunk(startAddress, RomSizePerBank, cartridgeData); switchableBanks[i] = new MemoryRange(bankdata, true); } romBanks = new Bank(switchableBanks); romBanks.Switch(1); if (hasRam) { ramBanks = new MbcRam(ramSize.Banks, ramSize.SizePerBank, GetSaveFilePath()); } else { ramBanks = new MbcRam(0, 0); } Bank0 = romBanks.GetBank(0); }
public MBC3(string romPath, bool hasRam, int romBankCount, RamSize ramSize, byte[] cartridgeData) : base(romPath) { this.romBankCount = romBankCount; MemoryRange[] switchableBanks = new MemoryRange[romBankCount]; for (int i = 0; i < romBankCount; i++) { int startAddress = RomSizePerBank * i; var bankData = GetCartridgeChunk(startAddress, RomSizePerBank, cartridgeData); switchableBanks[i] = new MemoryRange(bankData, true); } romBanks = new Bank(switchableBanks); romBanks.Switch(1); byte count; ushort size; if (!hasRam) { count = 0; size = 0; } else { count = ramSize.Banks; size = ramSize.SizePerBank; } IMemoryRange[] ramAndClock = new IMemoryRange[0xD]; var clock = new RTC(); for (int i = 0; i < ramAndClock.Length; i++) { if (i > 0x07) { ramAndClock[i] = clock; } else { if (i <= count) { ramAndClock[i] = new MemoryRange(size); } else { ramAndClock[i] = new DummyRange(); } } } ramBanks = new MbcRam(ramAndClock, GetSaveFilePath()); }