Beispiel #1
0
 private static HardDisk[] getHardDisks(Properties props, String propPrefix) {
   HardDisk[] rv = null;
   if (props != null) {
     for (int i = 0; i < 2; i++) {
       HardDisk disk = null;
       String prefix = String.format("%sharddisk.%d.", propPrefix, i + 1);
       String diskModel = EmuUtil.getProperty(props, prefix + "model");
       String fileName = EmuUtil.getProperty(props, prefix + "file");
       if (!diskModel.isEmpty() && !fileName.isEmpty()) {
         int c = EmuUtil.getIntProperty(props, prefix + "cylinders", 0);
         int h = EmuUtil.getIntProperty(props, prefix + "heads", 0);
         int n = EmuUtil.getIntProperty(props, prefix + "sectors_per_track", 0);
         if ((c > 0) && (h > 0) && (n > 0)) {
           disk = new HardDisk(diskModel, c, h, n, fileName);
         }
       }
       if (disk != null) {
         if (rv != null) {
           HardDisk[] a = new HardDisk[rv.length + 1];
           System.arraycopy(rv, 0, a, 0, rv.length);
           rv = a;
         } else {
           rv = new HardDisk[1];
         }
         rv[rv.length - 1] = disk;
       }
     }
   }
   return rv;
 }
Beispiel #2
0
 private void execFormatTrackTask() {
   File file = this.ioFile;
   long pos = this.ioFilePos;
   int cnt = this.ioByteCnt;
   if ((file != null) && (pos >= 0) && (cnt > 0)) {
     boolean err = false;
     RandomAccessFile raf = null;
     try {
       raf = new RandomAccessFile(file, "rw");
       raf.seek(pos);
       while (cnt > 0) {
         raf.write(0);
         --cnt;
       }
       raf.close();
       raf = null;
     } catch (IOException ex) {
       err = true;
       if (!this.writeErrShown) {
         this.writeErrShown = true;
         EmuUtil.fireShowError(this.owner, null, ex);
       }
     } finally {
       EmuUtil.doClose(raf);
     }
     if (err) {
       this.errorReg = ERROR_UNCORRECTABLE_DATA;
       this.statusReg |= STATUS_ERROR;
     }
     fireInterrupt();
   }
 }
Beispiel #3
0
 private void execReadSectorsTask() {
   File file = this.ioFile;
   long pos = this.ioFilePos;
   if (this.debugLevel > 3) {
     System.out.printf("GIDE io task: read track, pos=%d", pos);
   }
   if ((file != null) && (pos >= 0)) {
     if (file.exists()) {
       RandomAccessFile raf = null;
       try {
         raf = new RandomAccessFile(file, "r");
         raf.seek(pos);
         this.ioByteCnt = (int) raf.read(this.ioBuf, 0, this.ioByteCnt);
         if (this.debugLevel > 3) {
           System.out.printf("GIDE io task: read sector: %d read\n", this.ioByteCnt);
         }
       } catch (IOException ex) {
         if (this.debugLevel > 3) {
           System.out.println("GIDE io task: read sector: error");
         }
         if (!this.readErrShown) {
           this.readErrShown = true;
           EmuUtil.fireShowError(
               this.owner,
               "Die Festplattenabbilddatei kann nicht gelesen"
                   + " werden.\n"
                   + "Gegen\u00FCber dem emulierten System"
                   + " wird jedoch kein Fehler signalisiert.",
               ex);
         }
       } finally {
         EmuUtil.doClose(raf);
       }
     } else {
       EmuUtil.fireShowError(
           this.owner,
           "Die Festplattenabbilddatei existiert nicht und"
               + " kann deshalb auch nicht gelesen werden.\n"
               + "Gegen\u00FCber dem emulierten System"
               + " wird jedoch kein Fehler signalisiert.\n"
               + "Mit dem ersten Schreibzugriff auf das"
               + " emulierte Laufwerk wird die Abbilddatei"
               + " angelegt.",
           null);
     }
     this.ioBufPos = 0;
     this.statusReg |= STATUS_DATA_REQUEST;
     fireInterrupt();
   }
 }
Beispiel #4
0
 private void execWriteSectorsTask() {
   File file = this.ioFile;
   long pos = this.ioFilePos;
   if (this.debugLevel > 3) {
     System.out.printf("GIDE io task: write sector, pos=%d", pos);
   }
   if ((file != null) && (pos >= 0)) {
     boolean err = false;
     RandomAccessFile raf = null;
     try {
       raf = new RandomAccessFile(file, "rw");
       raf.seek(pos);
       raf.write(this.ioBuf, 0, SECTOR_SIZE);
       raf.close();
       raf = null;
     } catch (IOException ex) {
       err = true;
       if (!this.writeErrShown) {
         this.writeErrShown = true;
         EmuUtil.fireShowError(this.owner, null, ex);
       }
     } finally {
       EmuUtil.doClose(raf);
     }
     if (err) {
       this.errorReg = ERROR_UNCORRECTABLE_DATA;
       this.statusReg |= STATUS_ERROR;
       if (this.debugLevel > 3) {
         System.out.println("GIDE io task: write sector: error");
       }
     } else {
       this.ioBufPos = 0;
       countSector();
       if (this.sectorCnt > 0) {
         fireInterrupt();
       } else {
         this.statusReg = STATUS_SEEK_COMPLETE | STATUS_DRIVE_READY;
       }
       if (this.debugLevel > 3) {
         System.out.println("GIDE io task: write sector: ok");
       }
     }
   }
 }
Beispiel #5
0
 private static boolean emulatesGIDE(Properties props, String propPrefix) {
   boolean rv = true;
   for (int i = 0; i < propKeys.length; i++) {
     if (EmuUtil.getProperty(props, propPrefix + "harddisk.1." + propKeys[i]).isEmpty()) {
       rv = false;
       break;
     }
   }
   return rv;
 }
Beispiel #6
0
 public static int getDefaultSpeedKHz(Properties props) {
   int rv = A5105.getDefaultSpeedKHz();
   String sysName = EmuUtil.getProperty(props, "jkcemu.system");
   if (sysName != null) {
     if (sysName.startsWith("AC1")) {
       rv = AC1.getDefaultSpeedKHz();
     } else if (sysName.startsWith("BCS3")) {
       rv = BCS3.getDefaultSpeedKHz(props);
     } else if (sysName.startsWith("C80")) {
       rv = C80.getDefaultSpeedKHz();
     } else if (sysName.startsWith("HC900")
         || sysName.startsWith("KC85/2")
         || sysName.startsWith("KC85/3")
         || sysName.startsWith("KC85/4")
         || sysName.startsWith("KC85/5")) {
       rv = KC85.getDefaultSpeedKHz(props);
     } else if (sysName.startsWith("HueblerEvertMC")) {
       rv = HueblerEvertMC.getDefaultSpeedKHz();
     } else if (sysName.startsWith("HueblerGraphicsMC")) {
       rv = HueblerGraphicsMC.getDefaultSpeedKHz();
     } else if (sysName.startsWith("KC85/1")
         || sysName.startsWith("KC87")
         || sysName.startsWith("Z9001")) {
       rv = Z9001.getDefaultSpeedKHz();
     } else if (sysName.startsWith("KCcompact")) {
       rv = KCcompact.getDefaultSpeedKHz();
     } else if (sysName.startsWith("KramerMC")) {
       rv = KramerMC.getDefaultSpeedKHz();
     } else if (sysName.startsWith("LC80")) {
       rv = LC80.getDefaultSpeedKHz(props);
     } else if (sysName.startsWith("LLC1")) {
       rv = LLC1.getDefaultSpeedKHz();
     } else if (sysName.startsWith("LLC2")) {
       rv = LLC2.getDefaultSpeedKHz();
     } else if (sysName.startsWith("PC/M")) {
       rv = PCM.getDefaultSpeedKHz();
     } else if (sysName.startsWith("Poly880")) {
       rv = Poly880.getDefaultSpeedKHz();
     } else if (sysName.startsWith("SC2")) {
       rv = SC2.getDefaultSpeedKHz();
     } else if (sysName.startsWith("SLC1")) {
       rv = SLC1.getDefaultSpeedKHz();
     } else if (sysName.startsWith("VCS80")) {
       rv = VCS80.getDefaultSpeedKHz();
     } else if (sysName.startsWith("Z1013")) {
       rv = Z1013.getDefaultSpeedKHz(props);
     } else if (sysName.startsWith("ZXSpectrum")) {
       rv = ZXSpectrum.getDefaultSpeedKHz();
     }
   }
   return rv;
 }
Beispiel #7
0
 public void updCPUSpeed(Properties props) {
   int maxSpeedKHz = getDefaultSpeedKHz(props);
   String maxSpeedText = EmuUtil.getProperty(props, "jkcemu.maxspeed.khz");
   if (maxSpeedText.equals("unlimited")) {
     maxSpeedKHz = 0;
   } else {
     if (!maxSpeedText.equals("default")) {
       if (maxSpeedText.length() > 0) {
         try {
           int value = Integer.parseInt(maxSpeedText);
           if (value > 0) maxSpeedKHz = value;
         } catch (NumberFormatException ex) {
         }
       }
     }
   }
   this.z80cpu.setMaxSpeedKHz(maxSpeedKHz);
 }
Beispiel #8
0
  @Override
  public void applyInput(Properties props, boolean selected) throws UserInputException {
    Component tab = null;
    try {
      tab = this.tabModel;

      String os = "3.1_64x32";
      if (this.btnMon31_64x16.isSelected()) {
        os = "3.1_64x16";
      } else if (this.btnMonSCCH80.isSelected()) {
        os = "SCCH8.0";
      } else if (this.btnMonSCCH1088.isSelected()) {
        os = "SCCH10/88";
      } else if (this.btnMon2010.isSelected()) {
        os = "2010";
      }
      props.setProperty(this.propPrefix + "os.version", os);

      tab = this.tabRF;
      this.tabRF.applyInput(props, selected);

      tab = this.tabGIDE;
      this.tabGIDE.applyInput(props, selected);

      tab = this.tabSCCH;
      this.tabSCCH.applyInput(props, selected);

      tab = this.tab2010;
      this.fldAltPio2Rom2010.applyInput(props, selected);
      this.fldRomBank2010.applyInput(props, selected);

      tab = this.tabExt;
      EmuUtil.setProperty(props, this.propPrefix + "color", this.btnColor.isSelected());
      EmuUtil.setProperty(
          props, this.propPrefix + "floppydisk.enabled", this.btnFloppyDisk.isSelected());
      EmuUtil.setProperty(props, this.propPrefix + "kcnet.enabled", this.btnKCNet.isSelected());
      EmuUtil.setProperty(props, this.propPrefix + "vdip.enabled", this.btnVDIP.isSelected());
      EmuUtil.setProperty(
          props, this.propPrefix + "joystick.enabled", this.btnJoystick.isSelected());

      tab = this.tabEtc;
      EmuUtil.setProperty(props, this.propPrefix + "paste.fast", this.btnPasteFast.isSelected());
      this.fldAltOS.applyInput(props, selected);
      this.fldAltFont.applyInput(props, selected);
    } catch (UserInputException ex) {
      if (tab != null) {
        this.tabbedPane.setSelectedComponent(tab);
      }
      throw ex;
    }
  }
Beispiel #9
0
  @Override
  public void updFields(Properties props) {
    String os = EmuUtil.getProperty(props, this.propPrefix + "os.version");
    if (os.equals("3.1_64x16")) {
      this.btnMon31_64x16.setSelected(true);
    } else if (os.equals("3.1_64x32")) {
      this.btnMon31_64x32.setSelected(true);
    } else if (os.equals("SCCH8.0")) {
      this.btnMonSCCH80.setSelected(true);
    } else if (os.equals("2010")) {
      this.btnMon2010.setSelected(true);
    } else {
      this.btnMonSCCH1088.setSelected(true);
    }
    this.tabRF.updFields(props);
    this.tabGIDE.updFields(props);
    this.tabSCCH.updFields(props);
    this.fldAltPio2Rom2010.updFields(props);
    this.fldRomBank2010.updFields(props);

    this.btnColor.setSelected(EmuUtil.getBooleanProperty(props, this.propPrefix + "color", false));

    this.btnFloppyDisk.setSelected(
        EmuUtil.getBooleanProperty(props, this.propPrefix + "floppydisk.enabled", false));

    this.btnKCNet.setSelected(
        EmuUtil.getBooleanProperty(props, this.propPrefix + "kcnet.enabled", false));

    this.btnVDIP.setSelected(
        EmuUtil.getBooleanProperty(props, this.propPrefix + "vdip.enabled", false));

    this.btnJoystick.setSelected(
        EmuUtil.getBooleanProperty(props, this.propPrefix + "joystick.enabled", false));

    this.btnPasteFast.setSelected(
        EmuUtil.getBooleanProperty(props, this.propPrefix + "paste.fast", false));

    this.fldAltOS.updFields(props);
    this.fldAltFont.updFields(props);

    updSCCHFieldsEnabled();
    upd2010FieldsEnabled();
  }
Beispiel #10
0
  public synchronized void applySettings(Properties props) {
    // zu emulierendes System ermitteln
    boolean done = false;
    EmuSys emuSys = this.emuSys;
    if (emuSys != null) {
      if (emuSys.canApplySettings(props)) {
        done = true;
      }
    }
    if ((emuSys != null) && done) {
      emuSys.applySettings(props);
    } else {
      if (emuSys != null) {
        emuSys.cancelPastingText();
        emuSys.die();
      }
      String sysName = EmuUtil.getProperty(props, "jkcemu.system");
      if (sysName.startsWith("AC1")) {
        emuSys = new AC1(this, props);
      } else if (sysName.startsWith("BCS3")) {
        emuSys = new BCS3(this, props);
      } else if (sysName.startsWith("C80")) {
        emuSys = new C80(this, props);
      } else if (sysName.startsWith("HueblerEvertMC")) {
        emuSys = new HueblerEvertMC(this, props);
      } else if (sysName.startsWith("HueblerGraphicsMC")) {
        emuSys = new HueblerGraphicsMC(this, props);
      } else if (sysName.startsWith("KC85/1")
          || sysName.startsWith("KC87")
          || sysName.startsWith("Z9001")) {
        emuSys = new Z9001(this, props);
      } else if (sysName.startsWith("HC900")
          || sysName.startsWith("KC85/2")
          || sysName.startsWith("KC85/3")
          || sysName.startsWith("KC85/4")
          || sysName.startsWith("KC85/5")) {
        emuSys = new KC85(this, props);
      } else if (sysName.startsWith("KCcompact")) {
        emuSys = new KCcompact(this, props);
      } else if (sysName.startsWith("KramerMC")) {
        emuSys = new KramerMC(this, props);
      } else if (sysName.startsWith("LC80")) {
        emuSys = new LC80(this, props);
      } else if (sysName.startsWith("LLC1")) {
        emuSys = new LLC1(this, props);
      } else if (sysName.startsWith("LLC2")) {
        emuSys = new LLC2(this, props);
      } else if (sysName.startsWith("PC/M")) {
        emuSys = new PCM(this, props);
      } else if (sysName.startsWith("Poly880")) {
        emuSys = new Poly880(this, props);
      } else if (sysName.startsWith("SC2")) {
        emuSys = new SC2(this, props);
      } else if (sysName.startsWith("SLC1")) {
        emuSys = new SLC1(this, props);
      } else if (sysName.startsWith("VCS80")) {
        emuSys = new VCS80(this, props);
      } else if (sysName.startsWith("Z1013")) {
        emuSys = new Z1013(this, props);
      } else if (sysName.startsWith("ZXSpectrum")) {
        emuSys = new ZXSpectrum(this, props);
      } else {
        emuSys = new A5105(this, props);
      }
      ResetLevel resetLevel = ResetLevel.POWER_ON;
      if (this.emuSys != null) {
        String s1 = this.emuSys.getTitle();
        String s2 = emuSys.getTitle();
        if ((s1 != null) && (s2 != null)) {
          if (s1.equals(s2)) {
            resetLevel = ResetLevel.COLD_RESET;
          }
        }
      }
      this.emuSys = emuSys;
      fireReset(resetLevel);
    }

    // Floppy Disks
    FloppyDiskStationFrm frm = FloppyDiskStationFrm.getSharedInstance(this.screenFrm);
    if (frm != null) {
      int n = emuSys.getSupportedFloppyDiskDriveCount();
      frm.setDriveCount(n);
      for (int i = 0; i < n; i++) {
        emuSys.setFloppyDiskDrive(i, frm.getDrive(i));
      }
    }

    // Joysticks
    int nJoys = emuSys.getSupportedJoystickCount();
    for (int i = 0; i < this.joyThreads.length; i++) {
      JoystickThread jt = null;
      synchronized (this.joyThreads) {
        jt = this.joyThreads[i];
        if (jt != null) {
          if (i >= nJoys) {
            jt.fireStop();
            this.joyThreads[i] = null;
          }
          jt = null;
        } else {
          if (i < nJoys) {
            jt = new JoystickThread(this, i, false);
            this.joyThreads[i] = jt;
          }
        }
      }
      if (jt != null) {
        jt.start();
      }
      updJoystickFrm(i);
    }

    // CPU-Geschwindigkeit
    updCPUSpeed(props);

    // sonstiges
    this.iso646de = null;
  }