Esempio n. 1
0
 private int readFromDisk() {
   int rv = -1;
   FloppyDiskDrive drive = this.executingDrive;
   if (drive != null) {
     if ((this.curCmd == Command.READ_DATA)
         || (this.curCmd == Command.READ_DELETED_DATA)
         || (this.curCmd == Command.READ_TRACK)) {
       this.tStatesTillOverrun = 0;
       SectorData sector = this.curSector;
       SectorData.Reader reader = this.curSectorReader;
       if ((sector != null) && (reader != null)) {
         if (this.remainBytes > 0) {
           rv = reader.read();
           --this.remainBytes;
         }
         if ((rv < 0)
             || ((this.statusReg0 & ST0_ERROR_MASK) != 0)
             || (((this.statusReg2 & ST2_CONTROL_MARK) != 0)
                 && ((this.args[0] & ARG0_SK_MASK) == 0))) {
           stopExecution();
         } else {
           this.statusRegMain &= ~STM_REQUEST_FOR_MASTER;
           if ((this.remainBytes > 0) && this.curSectorReader.isByteAvailable()) {
             startIOReqTimer();
           } else {
             /*
              * Die Zeit bis zum ersten Byte des naechsten Sektors
              * ist groesser als innerhalb eines Sektors.
              * Das muss auch so emuliert werden,
              * um nicht vor einem evtl. TC bereits mit dem Lesen
              * des naechsten Sektors zu beginnen,
              * was dann zum falschen Setzen des End Of Cylinder Bits
              * fuehren koennte.
              */
             this.curSector = null;
             this.curSectorReader = null;
             incSectorNum();
             if (this.curCmd == Command.READ_TRACK) {
               startIOTask(IOTaskCmd.READ_SECTOR_BY_INDEX, this.tStatesPerRotation / 5);
             } else {
               startIOTask(IOTaskCmd.READ_SECTOR_BY_ID, this.tStatesPerRotation / 5);
             }
           }
         }
       }
     }
   }
   return rv;
 }
Esempio n. 2
0
 private void writeToDrive(int value) {
   value &= 0xFF;
   this.statusRegMain &= ~STM_REQUEST_FOR_MASTER;
   FloppyDiskDrive drive = this.executingDrive;
   if (drive != null) {
     if ((this.curCmd == Command.SCAN_EQUAL)
         || (this.curCmd == Command.SCAN_LOW_OR_EQUAL)
         || (this.curCmd == Command.SCAN_HIGH_OR_EQUAL)) {
       this.tStatesTillOverrun = 0;
       int b = -1;
       SectorData sector = this.curSector;
       SectorData.Reader reader = this.curSectorReader;
       if ((sector != null) && (reader != null)) {
         if (this.remainBytes > 0) {
           b = reader.read();
           --this.remainBytes;
         }
         if ((b < 0) || ((this.statusReg0 & ST0_ERROR_MASK) != 0)) {
           stopExecution();
         } else {
           if (b != value) {
             this.statusReg2 &= ~ST2_SCAN_EQUAL_HIT;
           }
           if (this.curCmd == Command.SCAN_LOW_OR_EQUAL) {
             if (b > value) {
               this.statusReg2 |= ST2_SCAN_NOT_SATISFIED;
             }
           } else if (this.curCmd == Command.SCAN_HIGH_OR_EQUAL) {
             if (b < value) {
               this.statusReg2 |= ST2_SCAN_NOT_SATISFIED;
             }
           } else {
             if (b != value) {
               this.statusReg2 |= ST2_SCAN_NOT_SATISFIED;
             }
           }
           if ((this.remainBytes > 0) && this.curSectorReader.isByteAvailable()) {
             startIOReqTimer();
           } else {
             if ((this.statusReg0 & ST0_ERROR_MASK) != 0) {
               stopExecution();
             } else {
               /*
                * Die Zeit bis zum ersten Byte des naechsten Sektors
                * ist groesser als innerhalb eines Sektors.
                * Das muss auch so emuliert werden,
                * um nicht vor einem evtl. TC bereits mit dem Lesen
                * des naechsten Sektors zu beginnen,
                * was dann zum falschen Setzen des End Of Cylinder Bits
                * fuehren wuerde.
                */
               this.curSector = null;
               this.curSectorReader = null;
               addSectorNum(this.args[8]);
               startIOTask(IOTaskCmd.READ_SECTOR_BY_ID, this.tStatesPerRotation / 5);
             }
           }
         }
       }
     } else {
       if (this.dataBuf != null) {
         if ((this.dataPos >= 0)
             && (this.dataPos < this.dataBuf.length)
             && (this.dataPos < this.dataLen)) {
           if (this.curCmd == Command.FORMAT_TRACK) {
             this.dataBuf[this.dataPos++] = (byte) value;
             startIOReqTimer();
           } else if ((this.curCmd == Command.WRITE_DATA)
               || (this.curCmd == Command.WRITE_DELETED_DATA)) {
             this.tStatesTillOverrun = 0;
             this.dataBuf[this.dataPos++] = (byte) value;
             if ((this.dataPos < this.dataBuf.length) && (this.dataPos < this.dataLen)) {
               startIOReqTimer();
             } else {
               startIOTask(IOTaskCmd.WRITE_SECTOR, 0);
             }
           }
         }
       }
     }
   }
 }