()
| 159 | } |
| 160 | |
| 161 | void write() { |
| 162 | if (writeMode) { |
| 163 | while (diskUpdatePending.get()) { |
| 164 | // If another thread requested writes to block (e.g. because of disk activity), wait for it to finish! |
| 165 | Thread.onSpinWait(); |
| 166 | } |
| 167 | // Holding the lock should block any other threads from writing to disk |
| 168 | synchronized (diskUpdatePending) { |
| 169 | if (disk != null) { |
| 170 | // Do nothing if write-protection is enabled! |
| 171 | if (getMediaEntry() == null || !getMediaEntry().writeProtected) { |
| 172 | dirtyTracks.add(trackStartOffset / FloppyDisk.TRACK_NIBBLE_LENGTH); |
| 173 | disk.nibbles[trackStartOffset + nibbleOffset++] = latch; |
| 174 | triggerDiskUpdate(); |
| 175 | StateManager.markDirtyValue(disk.nibbles); |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | if (nibbleOffset >= FloppyDisk.TRACK_NIBBLE_LENGTH) { |
| 181 | nibbleOffset = 0; |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | void setLatchValue(byte value) { |
| 187 | if (writeMode) { |
nothing calls this directly
no test coverage detected