private void execSenseInterruptStatus() { this.results[0] = 0; // Zylinder this.results[1] = 0x80; // Invalid Command Issue int driveMask = 0x01; for (int i = 0; i < this.seekStatus.length; i++) { int v = this.seekStatus[i]; if (v >= 0) { if ((v & 0xF8) != 0) { this.results[1] = v | i; FloppyDiskDrive drive = getDrive(i); if (drive != null) { this.results[0] = drive.getCylinder(); } this.statusRegMain &= ~driveMask; this.seekStatus[i] = -1; break; } this.results[1] = 0; } driveMask <<= 1; } this.resultIdx = 1; setResultMode(); }
private void execSenseDriveStatus() { this.statusReg3 = (this.args[1] & HEAD_DRIVE_MASK); FloppyDiskDrive drive = getArgDrive(); if (drive != null) { this.statusReg3 |= ST3_TWO_SIDE; if (drive.getCylinder() == 0) { this.statusReg3 |= ST3_TRACK_0; } if (drive.isReady()) { this.statusReg3 |= ST3_READY; } if (drive.isReadOnly()) { this.statusReg3 |= ST3_WRITE_PROTECTED; } } this.results[0] = this.statusReg3; this.resultIdx = 0; setResultMode(); }
private int getSectorIndexByCurHeadPos(FloppyDiskDrive drive) { int idx = -1; if (drive != null) { AbstractFloppyDisk disk = drive.getDisk(); if (disk != null) { int head = getArgHead(); int cyl = drive.getCylinder(); int spc = disk.getSectorsOfCylinder(cyl, head); int tpr = this.tStatesPerRotation; if ((spc > 0) && (tpr > 0) && (head < disk.getSides()) && (cyl < disk.getCylinders())) { idx = Math.round((float) this.tStateRotationCounter / (float) tpr * (float) spc); if (idx >= spc) { idx = spc - 1; } } if (idx < 0) { idx = 0; } } } return idx; }
private void seek(int driveNum, int head, int cyl) { this.statusRegMain &= ~STM_BUSY; this.statusReg0 = 0; if ((driveNum >= 0) && (driveNum < this.seekStatus.length)) { this.seekStatus[driveNum] = ((head << 2) & HEAD_MASK) | driveNum; FloppyDiskDrive drive = getDrive(driveNum); if (drive != null) { if (drive.getCylinder() == cyl) { this.seekStatus[driveNum] |= ST0_SEEK_END; this.interruptReq = true; } else { if (driveNum > 0) { this.statusRegMain |= (1 << driveNum); } else { this.statusRegMain |= 0x01; } drive.setSeekMode(head, cyl); this.remainSeekSteps[driveNum] = 77; if (!this.seekMode) { this.tStateStepCounter = 0; this.seekMode = true; } } } else { this.seekStatus[driveNum] |= ST0_ABNORMAL_TERMINATION; this.seekStatus[driveNum] |= ST0_NOT_READY; this.seekStatus[driveNum] |= ST0_SEEK_END; this.interruptReq = true; } } else { this.statusReg0 |= ST0_ABORT_BECAUSE_READY_CHANGED; this.statusReg0 |= ST0_SEEK_END; this.statusReg0 |= ST0_NOT_READY; this.statusReg0 |= ((head << 2) & HEAD_MASK); this.statusReg0 |= (driveNum & DRIVE_MASK); this.interruptReq = true; } }