Exemplo n.º 1
0
Arquivo: Core.java Projeto: Osmose/sno
  public static void init(InputStream is, boolean isZip) {
    CPU.resetCPU();
    PPU.init();
    printStats();
    Log.debug("====Starting SNO====");
    RomLoader rl = new RomLoader(is, isZip);
    if (rl.getRomInfo().isHiROM()) mem = new HiROMMemory();
    else mem = new LoROMMemory();
    rl.loadMemory(mem);
    instCount = 0;

    // Initiate Reset Vector
    CPU.resetVectorInit();
  }
Exemplo n.º 2
0
Arquivo: Core.java Projeto: Osmose/sno
  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();
  }
Exemplo n.º 3
0
  @Override
  public void actionPerformed(ActionEvent e) {
    System.out.println(e.getActionCommand());
    if (e.getActionCommand().equals("Open")) {
      FileDialog fd = new FileDialog(new Frame(), "Choose a rom file", FileDialog.LOAD);
      fd.setVisible(true);

      String file = fd.getFile();
      String dir = fd.getDirectory();

      if (file != null) {
        if (dir != null) {
          file = dir.concat(file);
        }

        InputStream is = null;
        boolean isZip = file.endsWith(".zip");
        try {
          is = new FileInputStream(file);
        } catch (FileNotFoundException e1) {

        }

        if (is != null) {
          runGame(is, isZip);
        } else {
          System.out.println("File '" + file + "' not found!");
        }
      }
    }

    if (e.getActionCommand().equals("About")) {
      JOptionPane.showMessageDialog(
          getContentPane(),
          "Created By: Keith Johnson, Mike Kelly, and Eric Wells\r\nhttps://cs.fit.edu/proxy/proj/sno/",
          "About us!",
          JOptionPane.INFORMATION_MESSAGE);
    }
    if (e.getActionCommand().equals("Options")) {
      Core.pause = true;
      layout.show(getContentPane(), "Options");
    } else if (e.getActionCommand().equals("Input")) {
      Core.pause = true;
      layout.show(getContentPane(), "Input");
    }

    if (e.getActionCommand().equals("Dump APU RAM")) {
      APUMemory.dump();
    } else if (e.getActionCommand().equals("Reset APU")) {
      APU.debugReset();
    } else if (e.getActionCommand().equals("Dump VRAM")) {
      PPU.dumpVRAM();
    } else if (e.getActionCommand().equals("Dump WRAM")) {
      Core.mem.dumpWRAM();
    } else if (e.getActionCommand().equals("Dump Sprites")) {
      Sprites.dumpSpriteData();
    } else if (e.getActionCommand().equals("Dump OBJs")) {
      Sprites.dumpOBJ();
    } else if (e.getActionCommand().equals("BG Status")) {
      System.out.println(PPU.bg[0].toString());
      System.out.println(PPU.bg[1].toString());
      System.out.println(PPU.bg[2].toString());
      System.out.println(PPU.bg[3].toString());
    } else if (e.getActionCommand().equals("Dump Palette")) {
      CGRAM.dumpCGRAM();
      CGRAM.testColors();
    } else if (e.getActionCommand().equals("Dump BGs")) {
      PPU.bg[0].dumpBGGraphics();
      PPU.bg[1].dumpBGGraphics();
      PPU.bg[2].dumpBGGraphics();
      PPU.bg[3].dumpBGGraphics();
    } else if (e.getActionCommand().equals("Output Hex Colors")) {
      CGRAM.outputHexColors();
    } else if (e.getActionCommand().equals("Toggle Logging")) {
      Log.setLogEnabled(!Log.enabled);
    } else if (e.getActionCommand().equals("Dump Tiles")) {
      OAM.dumpTiles();
    } else if (e.getActionCommand().equals("Toggle IRQ")) {
      CPU.userDisableIRQ = !CPU.userDisableIRQ;
    }
  }