Beispiel #1
0
  public static void cycle(long count) throws Exception {
    long instCount = 0;

    // Do as many instructions as set in properties file
    // Will execute indefinitely if instruction count is negative
    try {
      while ((instCount < count || count < 0) && running) {
        if (pause && !advanceFrameOnce) continue;
        CPU.cycle();
        instCount++;
      }
    } catch (Exception err) {
      // Finish timing and print stats before throwing error up
      timeEnd = new Date().getTime();
      System.out.println("Total time: " + ((timeEnd - timeBegin) / 1000) + " seconds");
      System.out.println("Instructions performed: " + instCount);
      System.out.println("Cycles performed: " + Timing.getCycles());
      System.out.println(
          "Average speed: "
              + (((Timing.getCycles() + 0f) / ((timeEnd - timeBegin + 0f) / 1000f))
                  / (1024f * 1024f))
              + " MHz");
      System.out.println(
          "Average speed: "
              + (((Timing.getCycles() + 0f) / ((timeEnd - timeBegin + 0f) / 1000f)))
              + " Hz");
      printMMaps();

      throw err;
    }

    Core.instCount += instCount;
  }
Beispiel #2
0
  public static void run(InputStream is, boolean isZip) throws Exception {
    init(is, isZip);
    instCount = 0;
    maxInstructions = Long.parseLong(Settings.get(Settings.CORE_MAX_INSTRUCTIONS));

    // Load save file if found
    if (Settings.isSet(Settings.SAVE_PATH)) {
      InputStream saveStream = Util.getStreamFromUrl(Settings.get(Settings.SAVE_PATH));
      if (saveStream != null) {
        mem.loadSram(saveStream);
      }
    }

    // Execute and time game
    if (Log.instruction.enabled() && Settings.get(Settings.CPU_ALT_DEBUG) == "false") {
      Log.instruction("====CPU Execution====");
      Log.instruction(
          "romAdr pbr:pc   op   CPU Status                      args              Instruction");
      Log.instruction(
          "------ -------  --   ------------------------------- ---------------   -----------");
    }
    timeBegin = new Date().getTime();
    cycle(maxInstructions);
    timeEnd = new Date().getTime();
    running = false;

    // Print run stats
    System.out.println("Total time: " + ((timeEnd - timeBegin) / 1000) + " seconds");
    System.out.println("Instructions performed: " + instCount);
    System.out.println("Cycles performed: " + Timing.getCycles());
    System.out.println(
        "Average speed: "
            + (((Timing.getCycles() + 0f) / ((timeEnd - timeBegin + 0f) / 1000f)) / (1024f * 1024f))
            + " MHz");
    System.out.println(
        "Average speed: "
            + (((Timing.getCycles() + 0f) / ((timeEnd - timeBegin + 0f) / 1000f)))
            + " Hz");
    printMMaps();

    PPU.dumpVRAM();
    mem.dumpWRAM();
    APUMemory.dump();
    renderScreen();
  }
Beispiel #3
0
  public int read(Size size, int bank, int addr) {
    boolean fastrom = false;

    // Determine speed by bank
    if (bank >= 0x80) {
      fastrom = true;
    }

    if ((bank == 0x00 || bank == 0x80) && addr >= 0x4000 && addr <= 0x41FF) {
      Timing.cycle(12); // 12 master cycles to access these
      return get(size, bank, addr);
    }

    if (fastrom) { // 6 cycles
      Timing.cycle(6);
      return get(size, bank, addr);
    } else { // 8 cycles
      Timing.cycle(8);
      return get(size, bank, addr);
    }
  }