Skip to content

Commit ae42450

Browse files
committed
floppy: Gently de-jitter/precomp WDATA line
This can be enough to handle heavily-precompensated marginal write signals. Fixes #861
1 parent cbbac4e commit ae42450

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/floppy_generic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ static void IRQ_wdata_dma(void)
674674
bc_dat = image->write_bc_window;
675675
for (cons = dma_wr->cons; cons != prod; cons = (cons+1) & buf_mask) {
676676
next = dma_wr->buf[cons];
677-
curr = (uint16_t)(next - prev) - (cell >> 1);
677+
curr = (int16_t)(next - prev) - (cell >> 1);
678678
if (unlikely(curr < 0)) {
679679
/* Runt flux, much shorter than bitcell clock. Merge it forward. */
680680
continue;
@@ -686,6 +686,8 @@ static void IRQ_wdata_dma(void)
686686
if (!(bc_prod&31))
687687
bc_buf[((bc_prod-1) / 32) & bc_bufmask] = htobe32(bc_dat);
688688
}
689+
curr += cell >> 1; /* remove the 1/2-cell bias */
690+
prev -= curr >> 2; /* de-jitter/precomp: carry 1/4 of phase error */
689691
bc_dat = (bc_dat << 1) | 1;
690692
bc_prod++;
691693
switch (sync) {

0 commit comments

Comments
 (0)