Exemple #1
0
  @Override
  public final synchronized void setFrame(
      final int[] nextframe, final int[] bgcolors, boolean dotcrawl) {
    // todo: stop running video filters while paused!
    // also move video filters into a worker thread because they
    // don't really depend on emulation state at all. Yes this is going to
    // cause more lag but it will hopefully get back up to playable speed with NTSC filter

    frametimes[frametimeptr] = nes.getFrameTime();
    ++frametimeptr;
    frametimeptr %= frametimes.length;

    if (frametimeptr == 0) {
      long averageframes = 0;
      for (long l : frametimes) {
        averageframes += l;
      }
      averageframes /= frametimes.length;
      fps = 1E9 / averageframes;
      this.setTitle(
          String.format(
              "HalfNES %s - %s, %2.2f fps" + ((frameskip > 0) ? " frameskip " + frameskip : ""),
              NES.VERSION,
              nes.getCurrentRomName(),
              fps));
    }
    if (nes.framecount % (frameskip + 1) == 0) {
      frame = renderer.render(nextframe, bgcolors, dotcrawl);
      render();
    }
  }
Exemple #2
0
 private void showActionReplayDialog() {
   nes.pause();
   final ActionReplay actionReplay = nes.getActionReplay();
   if (actionReplay != null) {
     final ActionReplayGui dialog = new ActionReplayGui(this, false, actionReplay);
     dialog.setVisible(true);
   } else {
     JOptionPane.showMessageDialog(
         this, "You have to load a game first.", "No ROM", JOptionPane.ERROR_MESSAGE);
   }
   nes.resume();
 }
Exemple #3
0
 private void showOptions() {
   final PreferencesDialog dialog = new PreferencesDialog(this);
   dialog.setVisible(true);
   if (dialog.okClicked()) {
     setRenderOptions();
     nes.setParameters();
   }
 }
Exemple #4
0
 public GUIImpl(NES nes) {
   this.nes = nes;
   screenScaleFactor = PrefsSingleton.get().getInt("screenScaling", 2);
   padController1 = new ControllerImpl(this, 0);
   padController2 = new ControllerImpl(this, 1);
   nes.setControllers(padController1, padController2);
   padController1.startEventQueue();
   padController2.startEventQueue();
 }
Exemple #5
0
 private void loadRomFromZip(String zipName) throws IOException {
   final String romName = selectRomInZip(listRomsInZip(zipName));
   if (romName != null) {
     final File extractedFile = extractRomFromZip(zipName, romName);
     if (extractedFile != null) {
       extractedFile.deleteOnExit();
       nes.loadROM(extractedFile.getCanonicalPath());
     }
   }
 }
Exemple #6
0
 private void loadROM(String path) {
   if (path.endsWith(".zip") || path.endsWith(".ZIP")) {
     try {
       loadRomFromZip(path);
     } catch (IOException ex) {
       this.messageBox(
           "Could not load file:\nFile does not exist or is not a valid NES game.\n"
               + ex.getMessage());
     }
   } else {
     nes.loadROM(path);
   }
 }