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; }