From 616a8501b56ad1a098ca02a42fd843c441c790bc Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 29 Jun 2020 02:19:05 +0200 Subject: [PATCH] Moved floppy writeback call to fdc_poll_readwrite_finish(), in order to have the track written less often (no need to write it on every sector). --- src/floppy/fdc.c | 3 +++ src/floppy/fdd.c | 7 +++++++ src/floppy/fdd_86f.c | 1 - src/include/86box/fdd.h | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 2667727b6..3be66cf0f 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -1468,6 +1468,9 @@ fdc_poll_common_finish(fdc_t *fdc, int compare, int st5) static void fdc_poll_readwrite_finish(fdc_t *fdc, int compare) { + if ((fdc->interrupt == 5) || (fdc->interrupt == 9)) + fdd_do_writeback(real_drive(fdc, fdc->drive)); + fdc->inread = 0; fdc->interrupt = -2; diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index 791c82abd..7e1b21452 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -719,3 +719,10 @@ fdd_init(void) fdd_load(2, floppyfns[2]); fdd_load(3, floppyfns[3]); } + + +void +fdd_do_writeback(int drive) +{ + d86f_handler[drive].writeback(drive); +} diff --git a/src/floppy/fdd_86f.c b/src/floppy/fdd_86f.c index 131f1658f..fe61eae2a 100644 --- a/src/floppy/fdd_86f.c +++ b/src/floppy/fdd_86f.c @@ -1712,7 +1712,6 @@ d86f_write_sector_data(int drive, int side, int mfm, uint16_t am) dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0; dev->error_condition = 0; dev->state = STATE_IDLE; - d86f_handler[drive].writeback(drive); fdc_sector_finishread(d86f_fdc); return; } diff --git a/src/include/86box/fdd.h b/src/include/86box/fdd.h index b486b617d..4a7de7c21 100644 --- a/src/include/86box/fdd.h +++ b/src/include/86box/fdd.h @@ -112,6 +112,7 @@ extern void fdd_readaddress(int drive, int side, int density); extern void fdd_format(int drive, int side, int density, uint8_t fill); extern int fdd_hole(int drive); extern void fdd_stop(int drive); +extern void fdd_do_writeback(int drive); extern int motorspin; extern uint64_t motoron[FDD_NUM];