Example #1
0
 private void setRomBank(int bank) {
   if (bank == 0) {
     rom.setBank(1);
   } else {
     rom.setBank(bank % romBanks);
   }
 }
Example #2
0
  public void loadROM(ROM rom) {

    // System.out.println("Loading ROM.");

    if (!rom.isValid()) {
      // System.out.println("MMC2: Invalid ROM! Unable to load.");
      return;
    }

    // Get number of 16K banks:
    int num_16k_banks = rom.getRomBankCount() * 4;

    // Load PRG-ROM:
    loadRomBank(0, 0x8000);
    loadRomBank(num_16k_banks - 1, 0xC000);

    // Load CHR-ROM:
    loadCHRROM();

    // Load Battery RAM (if present):
    loadBatteryRam();

    // Do Reset-Interrupt:
    nes.getCpu().requestIrq(CPU.IRQ_RESET);
  }
Example #3
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 #4
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 #5
0
  public void loadROM(ROM rom) {

    if (!rom.isValid()) {
      // System.out.println("Invalid ROM! Unable to load.");
      return;
    }

    // Initial Load:
    loadPRGROM();
    loadCHRROM();

    // Do Reset-Interrupt:
    nes.getCpu().requestIrq(CPU.IRQ_RESET);
  }
Example #6
0
  public void loadROM(ROM rom) {

    // System.out.println("Loading ROM.");

    if (!rom.isValid()) {
      System.out.println("VRC2: Invalid ROM! Unable to load.");
      return;
    }

    // Get number of 8K banks:
    int num_8k_banks = rom.getRomBankCount() * 2;

    // Load PRG-ROM:
    load8kRomBank(0, 0x8000);
    load8kRomBank(1, 0xA000);
    load8kRomBank(num_8k_banks - 2, 0xC000);
    load8kRomBank(num_8k_banks - 1, 0xE000);

    // Load CHR-ROM:
    loadCHRROM();

    // Do Reset-Interrupt:
    nes.getCpu().requestIrq(CPU.IRQ_RESET);
  }
Example #7
0
  public void loadROM(ROM rom) {

    int num_8k_banks = rom.getRomBankCount() * 2;

    // Load PRG-ROM:
    load8kRomBank(0, 0x8000);
    load8kRomBank(1, 0xA000);
    load8kRomBank(num_8k_banks - 2, 0xC000);
    load8kRomBank(num_8k_banks - 1, 0xE000);

    // Load CHR-ROM:
    loadCHRROM();

    // Do Reset-Interrupt:
    nes.getCpu().requestIrq(CPU.IRQ_RESET);
  }
Example #8
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 #9
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 #10
0
 public void forceWrite(int address, int data) {
   rom.forceWrite(address, data);
 }