示例#1
0
文件: GIDE.java 项目: rexut/jkcemu
 public synchronized void reset() {
   if (this.debugLevel > 0) {
     System.out.println("GIDE: reset");
   }
   this.pendingCmd = Command.NONE;
   this.resetFlag = false;
   this.ioTaskNoWait = false;
   this.ioTaskThread.interrupt();
   if (this.disks != null) {
     boolean sizeOK = false;
     if ((this.cylinders != null)
         && (this.heads != null)
         && (this.sectorsPerTrack != null)
         && (this.totalSectors != null)) {
       if ((this.cylinders.length >= this.disks.length)
           && (this.heads.length >= this.disks.length)
           && (this.sectorsPerTrack.length >= this.disks.length)
           && (this.totalSectors.length >= this.disks.length)) {
         sizeOK = false;
       }
     }
     if (!sizeOK) {
       this.cylinders = new int[this.disks.length];
       this.heads = new int[this.disks.length];
       this.sectorsPerTrack = new int[this.disks.length];
       this.totalSectors = new long[this.disks.length];
     }
     int maxSectsPerTrack = 0;
     for (int i = 0; i < this.disks.length; i++) {
       this.cylinders[i] = disks[i].getCylinders();
       this.heads[i] = disks[i].getHeads();
       this.sectorsPerTrack[i] = disks[i].getSectorsPerTrack();
       this.totalSectors[i] =
           (long) this.cylinders[i] * (long) this.heads[i] * (long) this.sectorsPerTrack[i];
       if (this.sectorsPerTrack[i] > maxSectsPerTrack) {
         maxSectsPerTrack = this.sectorsPerTrack[i];
       }
     }
     int bufSize = Math.max(maxSectsPerTrack, 1) * SECTOR_SIZE;
     if (this.ioBuf != null) {
       if (this.ioBuf.length < bufSize) {
         this.ioBuf = null;
       }
     }
     if (this.ioBuf == null) {
       this.ioBuf = new byte[bufSize];
     }
   }
   if (this.ioBuf != null) {
     Arrays.fill(this.ioBuf, (byte) 0);
   }
   softReset();
 }
示例#2
0
文件: GIDE.java 项目: rexut/jkcemu
 private void fireFetchSectors() {
   if ((this.curDisk != null) && (this.curDiskIdx >= 0)) {
     long pos = calcFilePos();
     if (pos < 0) {
       this.errorReg = ERROR_CMD_ABORTED;
       this.statusReg |= STATUS_ERROR;
     } else {
       Arrays.fill(this.ioBuf, (byte) 0xE5);
       File file = this.curDisk.getFile();
       if (file != null) {
         int nSec =
             Math.min(this.sectorsPerTrack[this.curDiskIdx] - this.sectorNum + 1, this.sectorCnt);
         startIOTask(file, pos, nSec * SECTOR_SIZE);
       }
     }
   }
 }
示例#3
0
文件: GIDE.java 项目: rexut/jkcemu
  private void execCmdIdentifyDrive() {
    if (this.curDisk != null) {
      Arrays.fill(this.ioBuf, 0, SECTOR_SIZE, (byte) 0);
      setIOBufWord(0, 0x015A);
      setIOBufWord(2, this.curDisk.getCylinders());
      setIOBufWord(6, this.curDisk.getHeads());
      setIOBufWord(8, this.curDisk.getSectorsPerTrack() * SECTOR_SIZE);
      setIOBufWord(10, SECTOR_SIZE);
      setIOBufWord(12, this.curDisk.getSectorsPerTrack());
      setIOBufASCII(20, Main.VERSION, 20);
      setIOBufWord(42, 1); // 1 Sektor Puffer
      setIOBufASCII(46, "JKCEMU", 8);

      String model = this.curDisk.getDiskModel();
      if (model != null) {
        if (model.isEmpty()) {
          model = null;
        }
      }
      if (model == null) {
        model =
            String.format(
                "Sonstige (%dx%dx%d)",
                this.curDisk.getCylinders(),
                this.curDisk.getHeads(),
                this.curDisk.getSectorsPerTrack());
      }
      setIOBufASCII(54, model, 40);
      File file = this.curDisk.getFile();
      if (file != null) {
        if (!file.canWrite()) {
          setIOBufWord(98, 1); // schreibgeschuetzt
        }
      }
      this.ioBufPos = 0;
      this.pendingCmd = Command.IDENTIFY_DISK;
      this.statusReg |= STATUS_DATA_REQUEST;
      fireInterrupt();
    }
  }
示例#4
0
文件: GIDE.java 项目: rexut/jkcemu
 private void writeFormatByte(int value) {
   if ((this.curDisk != null) && (this.curDiskIdx >= 0)) {
     if (this.ioBufPos < SECTOR_SIZE) {
       this.ioBuf[this.ioBufPos++] = (byte) value;
       if (this.ioBufPos == this.ioBuf.length) {
         boolean cmdFinished = true;
         /*
          * Da das verwendete Dateiformat die Sektornummern nicht speichert,
          * muessen diese mit eins beginnen und fortlaufend sein.
          * Nachfolgend wird geprueft, ob diese Bedingung erfuellt ist.
          */
         int spt = this.sectorsPerTrack[this.curDiskIdx];
         boolean[] sectors = new boolean[spt];
         Arrays.fill(sectors, false);
         int ptr = 0;
         boolean err = false;
         for (int i = 0; !err && (i < sectors.length); i++) {
           if ((ptr + 1) < SECTOR_SIZE) {
             // jeweils 1. Byte muss 00 (good sector) sein
             if (this.ioBuf[ptr++] != 0) {
               err = true;
             }
             // jeweils 2. Byte gibt Sektornummer an
             int v = (int) this.ioBuf[ptr++] & 0xFF;
             if (v < sectors.length) {
               if (sectors[v]) {
                 err = true; // Sektornummer zweimal angegeben
               } else {
                 sectors[v] = true;
               }
             } else {
               err = true; // Sktornummer ausserhalb des Bereichs
             }
           } else {
             err = true; // sollte niemals vorkommen
           }
         }
         if (!err) {
           for (int i = 0; i < sectors.length; i++) {
             if (!sectors[i]) {
               err = true; // Sektornummer fehlt
               break;
             }
           }
         }
         if (err) {
           this.errorReg = ERROR_UNCORRECTABLE_DATA;
           this.statusReg |= STATUS_ERROR;
         } else {
           // Sektoren loeschen
           int heads = this.heads[this.curDiskIdx];
           long headNum = this.sdhReg & 0x0F;
           if ((this.cylNum >= 0)
               && (this.cylNum < this.cylinders[this.curDiskIdx])
               && (headNum >= 0)
               && (headNum < heads)) {
             long sectOffs = (this.cylNum * heads * spt) + (headNum * spt);
             startIOTask(
                 this.curDisk.getFile(),
                 0x0100 + (sectOffs * ((long) SECTOR_SIZE)),
                 spt * SECTOR_SIZE);
             cmdFinished = false;
           }
         }
         if (cmdFinished) {
           fireInterrupt();
         }
       }
     }
   }
 }