示例#1
0
 private void setRomBank(int bank) {
   if (bank == 0) {
     rom.setBank(1);
   } else {
     rom.setBank(bank % romBanks);
   }
 }
示例#2
0
  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");
  }
示例#3
0
 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;
 }
示例#4
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);
 }
示例#5
0
 /** {@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);
 }
示例#6
0
 public void forceWrite(int address, int data) {
   rom.forceWrite(address, data);
 }