private void execIOFormatTrack() { boolean done = false; int srcIdx = 0; FloppyDiskDrive drive = getExecutingDrive(); if (drive != null) { if (this.dataBuf != null) { int nSectors = this.dataPos / 4; if ((nSectors > 0) && ((nSectors * 4) <= this.dataBuf.length)) { int n = this.args[2] & 0x0F; int sectorSize = 128; if (n > 0) { sectorSize = (128 << n); } byte[] contentBuf = new byte[sectorSize]; Arrays.fill(contentBuf, (byte) this.args[5]); SectorID[] sectors = new SectorID[nSectors]; int dstIdx = 0; while (((srcIdx + 3) < this.dataBuf.length) && (dstIdx < sectors.length)) { int cyl = (int) this.dataBuf[srcIdx++] & 0xFF; int head = (int) this.dataBuf[srcIdx++] & 0xFF; int rec = (int) this.dataBuf[srcIdx++] & 0xFF; int sizeCode = (int) this.dataBuf[srcIdx++] & 0xFF; sectors[dstIdx++] = new SectorID(cyl, head, rec, sizeCode); } done = drive.formatTrack((this.args[1] >> 2) & 0x01, sectors, contentBuf); } } } drive = getExecutingDrive(); if (drive != null) { if (this.dataBuf.length >= 4) { this.sectorIdCyl = (int) this.dataBuf[0] & 0xFF; this.sectorIdHead = (int) this.dataBuf[0] & 0xFF; this.sectorIdRec = (int) this.dataBuf[0] & 0xFF; this.sectorIdSizeCode = (int) this.dataBuf[0] & 0xFF; } if (done) { srcIdx -= 4; if ((srcIdx + 3) < this.dataBuf.length) { this.sectorIdCyl = (int) this.dataBuf[srcIdx++] & 0xFF; this.sectorIdHead = (int) this.dataBuf[srcIdx++] & 0xFF; this.sectorIdRec = ((int) this.dataBuf[srcIdx++] & 0xFF) + 1; this.sectorIdSizeCode = (int) this.dataBuf[srcIdx] & 0xFF; } } else { this.statusReg0 |= ST0_ABNORMAL_TERMINATION; if (this.executingDrive.isReadOnly()) { this.statusReg1 |= ST1_NOT_WRITABLE; } else { this.statusReg1 |= ST1_DATA_ERROR; this.statusReg2 |= ST2_DATA_ERROR_IN_DATA_FIELD; } } stopExecution(); } }