fn new(rom_banks: Vec<RomBank>, num_ram_banks: usize, save_ram: bool) -> Self {
        assert!(rom_banks.len() >= 2, "Must have at least 2 rom banks.");
        assert!(
            rom_banks.len() <= 128,
            "MBC1 Rom can have at most 128 rom banks."
        );
        assert!(
            rom_banks.len().count_ones() == 1,
            "Number of rom banks must be a power of 2."
        );
        assert!(num_ram_banks <= 4, "MBC1 Rom can have at most 4 ram banks.");
        assert!(
            num_ram_banks == 0 || num_ram_banks.count_ones() == 1,
            "Number of ram banks must be a power of 2."
        );
        if rom_banks.len() > 32 && num_ram_banks > 1 {
            // It is unclear to me what happens if a cartridge has both > 32 rom banks and > 1 ram
            // bank.  This doc https://gbdev.io/pandocs/MBC1.html describes the situation with > 1
            // ram bank and > 32 rom banks, but not both. Perhaps there were no official cartridges
            // where that was the case.
            //
            // The implemenation I decided to go with was to just always apply the bank_set bits,
            // and then modulo by the number of banks of ram/rom. If only one of ram/rom is large
            // enough to require using bank_set, the behavior is definitely correct, but if both are
            // large enough to need bank_set, then both will be banked simultaneously, and I don't
            // know if that's right.
            warn!("MBC1 Rom is both Large Ram and Large Rom. Banking behavior may be wrong.");
        }
        Mbc1Rom {
            rom_banks,
            ram_banks: vec![[0u8; RAM_BANK_SIZE]; num_ram_banks],
            save_ram,
            ram_enable: false,
            rom_bank: 0,
            bank_set: 0,
            advanced_banking_mode: false,
        }
    }
/// Construct a new Mbc1Rom with the given rom banks and number of ram banks.
Construct a new Mbc1Rom with the given rom banks and number of ram banks.
Construct a new Mbc1Rom with the given rom banks and number of ram banks .
fn new(rom_banks: Vec<RomBank>, num_ram_banks: usize, save_ram: bool) -> Self {
        assert!(rom_banks.len() >= 2, "Must have at least 2 rom banks.");
        assert!(
            rom_banks.len() <= 128,
            "MBC1 Rom can have at most 128 rom banks."
        );
        assert!(
            rom_banks.len().count_ones() == 1,
            "Number of rom banks must be a power of 2."
        );
        assert!(num_ram_banks <= 4, "MBC1 Rom can have at most 4 ram banks.");
        assert!(
            num_ram_banks == 0 || num_ram_banks.count_ones() == 1,
            "Number of ram banks must be a power of 2."
        );
        if rom_banks.len() > 32 && num_ram_banks > 1 {
            // It is unclear to me what happens if a cartridge has both > 32 rom banks and > 1 ram
            // bank.  This doc https://gbdev.io/pandocs/MBC1.html describes the situation with > 1
            // ram bank and > 32 rom banks, but not both. Perhaps there were no official cartridges
            // where that was the case.
            //
            // The implemenation I decided to go with was to just always apply the bank_set bits,
            // and then modulo by the number of banks of ram/rom. If only one of ram/rom is large
            // enough to require using bank_set, the behavior is definitely correct, but if both are
            // large enough to need bank_set, then both will be banked simultaneously, and I don't
            // know if that's right.
            warn!("MBC1 Rom is both Large Ram and Large Rom. Banking behavior may be wrong.");
        }
        Mbc1Rom {
            rom_banks,
            ram_banks: vec![[0u8; RAM_BANK_SIZE]; num_ram_banks],
            save_ram,
            ram_enable: false,
            rom_bank: 0,
            bank_set: 0,
            advanced_banking_mode: false,
        }
    }
fn new ( rom_banks : Vec < RomBank > , num_ram_banks : usize , save_ram : bool ) -> Self { assert ! ( rom_banks len ( ) 2 " " ) ; assert ! ( rom_banks len ( ) 128 " " ) ; assert ! ( rom_banks len ( ) count_ones ( ) 1 " " ) ; assert ! ( num_ram_banks 4 " " ) ; assert ! ( num_ram_banks 0 num_ram_banks count_ones ( ) 1 " " ) ; if rom_banks . len ( ) > 32 && num_ram_banks > 1 { // It is unclear to me what happens if a cartridge has both > 32 rom banks and > 1 ram // bank.  This doc https://gbdev.io/pandocs/MBC1.html describes the situation with > 1 // ram bank and > 32 rom banks, but not both. Perhaps there were no official cartridges // where that was the case. // // The implemenation I decided to go with was to just always apply the bank_set bits, // and then modulo by the number of banks of ram/rom. If only one of ram/rom is large // enough to require using bank_set, the behavior is definitely correct, but if both are // large enough to need bank_set, then both will be banked simultaneously, and I don't // know if that's right. warn ! ( " " ) ; } Mbc1Rom { rom_banks , ram_banks : vec ! [ [ 0u8 RAM_BANK_SIZE ] num_ram_banks ] , save_ram , ram_enable : false , rom_bank : 0 , bank_set : 0 , advanced_banking_mode : false , } }
Construct a new Mbc1Rom with the given rom banks and number of ram banks.
Construct a new Mbc1Rom with the given rom banks and number of ram banks .
rom_banks
Vec<RomBank>
num_ram_banks
usize
save_ram
bool
rom_banks
Vec<RomBank>
num_ram_banks
usize
save_ram
bool