Example #1
0
 private void setRomBank(int bank) {
   if (bank == 0) {
     rom.setBank(1);
   } else {
     rom.setBank(bank % romBanks);
   }
 }
Example #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");
  }
Example #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;
 }
Example #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);
 }
Example #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);
 }
Example #6
0
 public void forceWrite(int address, int data) {
   rom.forceWrite(address, data);
 }