Skip to content

Commit

Permalink
FF.CFG: write-drain = instant | realtime | eot
Browse files Browse the repository at this point in the history
'eot' fixes Not Ready errors on large writes and disk copies to
Gotek on Amstrad PPC640/512.

Fixes #320
  • Loading branch information
keirf committed Mar 13, 2020
1 parent 0e9554d commit bff87bb
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
9 changes: 8 additions & 1 deletion examples/FF.CFG
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,19 @@ write-protect = no
# Values: 0 <= N <= 255
side-select-glitch-filter = 0

# Rotational offset of data after a track change
# Rotational offset of disk after a track change
# instant: No rotation during track change
# realtime: Emulate rotation of disk while track is changing
# Values: instant | realtime
track-change = instant

# Rotational offset of disk after draining a write to Flash
# instant: No rotation
# realtime: Disk rotates in real time during drain
# eot: Disk rotates to (near) end of track
# Values: instant | realtime | eot
write-drain = instant

# Index pulses suppressed when RDATA and WDATA inactive?
# Values: yes | no
index-suppression = yes
Expand Down
4 changes: 4 additions & 0 deletions inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ struct packed ff_cfg {
#define DORD_row 7
#define DORD_double 8
uint16_t display_order;
#define WDRAIN_instant 0
#define WDRAIN_realtime 1
#define WDRAIN_eot 2
uint8_t write_drain;
};

extern struct ff_cfg ff_cfg;
Expand Down
2 changes: 2 additions & 0 deletions scripts/mk_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def main(argv):
val = "PIN_" + val
elif opt == "track-change":
val = "TRKCHG_" + val
elif opt == "write-drain":
val = "WDRAIN_" + val
elif opt == "host":
val = "HOST_" + val
elif opt == "oled-font":
Expand Down
19 changes: 16 additions & 3 deletions src/floppy_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,21 @@ static void wdata_stop(void)
/* Drain out the DMA buffer. */
IRQx_set_pending(dma_wdata_irq);

/* Restart read exactly where write ended.
* No more IDX pulses until write-out is complete. */
drive_set_restart_pos(drv);
switch (ff_cfg.write_drain) {
case WDRAIN_instant:
/* Restart read exactly where write ended. No more IDX pulses until
* write-out is complete. */
drive_set_restart_pos(drv);
break;
case WDRAIN_realtime:
/* Nothing to do. */
break;
case WDRAIN_eot:
/* Position so that an INDEX pulse is quickly triggered. */
drv->restart_pos = drv->image->stk_per_rev - stk_ms(20);
drv->index_suppressed = TRUE;
break;
}

/* Remember where this write's DMA stream ended. */
write = get_write(image, image->wr_prod);
Expand All @@ -359,6 +371,7 @@ static void wdata_stop(void)
IRQx_set_pending(FLOPPY_SOFTIRQ);
/* Position read head so it quickly triggers an INDEX pulse. */
drv->restart_pos = drv->image->stk_per_rev - stk_ms(20);
drv->index_suppressed = TRUE;
}
#endif
}
Expand Down
7 changes: 7 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,13 @@ static void read_ff_cfg(void)
: TRKCHG_instant;
break;

case FFCFG_write_drain:
ff_cfg.write_drain =
!strcmp(opts.arg, "realtime") ? WDRAIN_realtime
: !strcmp(opts.arg, "eot") ? WDRAIN_eot
: WDRAIN_instant;
break;

case FFCFG_index_suppression:
ff_cfg.index_suppression = !strcmp(opts.arg, "yes");
break;
Expand Down

0 comments on commit bff87bb

Please sign in to comment.