Skip to content

Commit bff87bb

Browse files
committed
FF.CFG: write-drain = instant | realtime | eot
'eot' fixes Not Ready errors on large writes and disk copies to Gotek on Amstrad PPC640/512. Fixes #320
1 parent 0e9554d commit bff87bb

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

examples/FF.CFG

+8-1
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,19 @@ write-protect = no
6262
# Values: 0 <= N <= 255
6363
side-select-glitch-filter = 0
6464

65-
# Rotational offset of data after a track change
65+
# Rotational offset of disk after a track change
6666
# instant: No rotation during track change
6767
# realtime: Emulate rotation of disk while track is changing
6868
# Values: instant | realtime
6969
track-change = instant
7070

71+
# Rotational offset of disk after draining a write to Flash
72+
# instant: No rotation
73+
# realtime: Disk rotates in real time during drain
74+
# eot: Disk rotates to (near) end of track
75+
# Values: instant | realtime | eot
76+
write-drain = instant
77+
7178
# Index pulses suppressed when RDATA and WDATA inactive?
7279
# Values: yes | no
7380
index-suppression = yes

inc/config.h

+4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ struct packed ff_cfg {
155155
#define DORD_row 7
156156
#define DORD_double 8
157157
uint16_t display_order;
158+
#define WDRAIN_instant 0
159+
#define WDRAIN_realtime 1
160+
#define WDRAIN_eot 2
161+
uint8_t write_drain;
158162
};
159163

160164
extern struct ff_cfg ff_cfg;

scripts/mk_config.py

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def main(argv):
2525
val = "PIN_" + val
2626
elif opt == "track-change":
2727
val = "TRKCHG_" + val
28+
elif opt == "write-drain":
29+
val = "WDRAIN_" + val
2830
elif opt == "host":
2931
val = "HOST_" + val
3032
elif opt == "oled-font":

src/floppy_generic.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,21 @@ static void wdata_stop(void)
342342
/* Drain out the DMA buffer. */
343343
IRQx_set_pending(dma_wdata_irq);
344344

345-
/* Restart read exactly where write ended.
346-
* No more IDX pulses until write-out is complete. */
347-
drive_set_restart_pos(drv);
345+
switch (ff_cfg.write_drain) {
346+
case WDRAIN_instant:
347+
/* Restart read exactly where write ended. No more IDX pulses until
348+
* write-out is complete. */
349+
drive_set_restart_pos(drv);
350+
break;
351+
case WDRAIN_realtime:
352+
/* Nothing to do. */
353+
break;
354+
case WDRAIN_eot:
355+
/* Position so that an INDEX pulse is quickly triggered. */
356+
drv->restart_pos = drv->image->stk_per_rev - stk_ms(20);
357+
drv->index_suppressed = TRUE;
358+
break;
359+
}
348360

349361
/* Remember where this write's DMA stream ended. */
350362
write = get_write(image, image->wr_prod);
@@ -359,6 +371,7 @@ static void wdata_stop(void)
359371
IRQx_set_pending(FLOPPY_SOFTIRQ);
360372
/* Position read head so it quickly triggers an INDEX pulse. */
361373
drv->restart_pos = drv->image->stk_per_rev - stk_ms(20);
374+
drv->index_suppressed = TRUE;
362375
}
363376
#endif
364377
}

src/main.c

+7
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,13 @@ static void read_ff_cfg(void)
932932
: TRKCHG_instant;
933933
break;
934934

935+
case FFCFG_write_drain:
936+
ff_cfg.write_drain =
937+
!strcmp(opts.arg, "realtime") ? WDRAIN_realtime
938+
: !strcmp(opts.arg, "eot") ? WDRAIN_eot
939+
: WDRAIN_instant;
940+
break;
941+
935942
case FFCFG_index_suppression:
936943
ff_cfg.index_suppression = !strcmp(opts.arg, "yes");
937944
break;

0 commit comments

Comments
 (0)