private void setRomBank(int bank) { if (bank == 0) { rom.setBank(1); } else { rom.setBank(bank % romBanks); } }
public MBC2(ROM cartridge) { rom = cartridge; romBanks = rom.getRomBanks(); eram = new Eram4bit(ADDRESS_ERAM_START, ADDRESS_ERAM_END, 1); System.out.println("This rom has " + romBanks + " banks"); }
public int read(int address) { if (address >= 0x0000 && address < 0x8000) { return rom.read(address); } else if (address >= ADDRESS_ERAM_START && address < ADDRESS_ERAM_4BIT_END && ramEnable) { return eram.read(address); } return 0; }
/** {@inheritDoc} */ public void saveState(FileOutputStream fos) throws IOException { rom.saveState(fos); eram.saveState(fos); FileIOStreamHelper.writeData(fos, (long) romBank, 4); FileIOStreamHelper.writeData(fos, (long) romBanks, 4); }
/** {@inheritDoc} */ public void readState(FileInputStream fis) throws IOException { rom.readState(fis); eram.readState(fis); romBank = (int) FileIOStreamHelper.readData(fis, 4); romBanks = (int) FileIOStreamHelper.readData(fis, 4); }
public void forceWrite(int address, int data) { rom.forceWrite(address, data); }