diff --git a/src/core/fds.c b/src/core/fds.c index 37c8f8ad2..652ba68e2 100644 --- a/src/core/fds.c +++ b/src/core/fds.c @@ -220,6 +220,7 @@ BYTE fds_load_rom(BYTE format) { fds.info.expcted_sides = fds.info.total_sides; fds.info.write_protected = 0x00; fds.info.cycles_8bit_delay = emu_ms_to_cpu_cycles(FDS_8BIT_MS_DELAY); + fds.info.cycles_insert_delay = emu_ms_to_cpu_cycles(FDS_INSERT_MS_DELAY); fds.info.cycles_dummy_delay = emu_ms_to_cpu_cycles(FDS_OP_SIDE_MS_DELAY); // converto nel mio formato immagine @@ -367,6 +368,8 @@ BYTE fds_change_disk(uTCHAR *file) { _fds_info finfo; FILE *fp = NULL; + fds_free_fds_info(); + memset(&finfo, 0x00, sizeof(_fds_info)); umemset(&path[0], 0x00, usizeof(path)); ustrncpy(path, file, usizeof(path) - 1); @@ -444,10 +447,15 @@ BYTE fds_change_disk(uTCHAR *file) { position = 0; } + info.format = finfo.format; + ustrncpy(info.rom.file, path, usizeof(info.rom.file)); + finfo.expcted_sides = finfo.total_sides; finfo.write_protected = 0x00; finfo.enabled = fds.info.enabled; + finfo.writings_occurred = FALSE; finfo.cycles_8bit_delay = fds.info.cycles_8bit_delay; + finfo.cycles_insert_delay = fds.info.cycles_insert_delay; finfo.cycles_dummy_delay = fds.info.cycles_dummy_delay; // converto nel mio formato immagine @@ -461,10 +469,6 @@ BYTE fds_change_disk(uTCHAR *file) { finfo.frame_insert = nes[0].p.ppu.frames; - info.format = finfo.format; - ustrncpy(info.rom.file, path, usizeof(info.rom.file)); - - fds_free_fds_info(); memcpy(&fds.info, &finfo, sizeof(_fds_info)); fds_info(); @@ -588,7 +592,7 @@ void fds_disk_op(WORD type, BYTE side_to_insert, BYTE quiet) { fds.drive.transfer_reset = 0x02; fds.drive.motor_started = FALSE; fds.drive.delay_8bit = 0; - fds.drive.delay_insert = FDS_DELAY_INSERT; + fds.drive.delay_insert = fds.info.cycles_insert_delay; fds.auto_insert.r4032.frames = 0; fds.auto_insert.r4032.checks = 0; if (!quiet) { diff --git a/src/core/fds.h b/src/core/fds.h index cca51797d..9200b91fc 100644 --- a/src/core/fds.h +++ b/src/core/fds.h @@ -48,7 +48,6 @@ enum fds_misc { FDS_DISK_BLOCK_MARK = 0x80, FDS_AUTOINSERT_R4032_MAX_CHECKS = 7, FDS_MIN_LAG_FRAMES = 20, - FDS_DELAY_INSERT = 90000, FDS_IMAGE_SIDE_SIZE = 75500, DISK_FDS_SIDE_SIZE = 65500, DISK_QD_SIDE_SIZE = 65536, @@ -64,6 +63,8 @@ enum fds_misc { // Aspic (1988)(Bothtec)(J) necessita di almeno 1500 ms // Pulsar no Hikari - Space Wars Simulation (Japan) di almeno 1600 ms #define FDS_OP_SIDE_MS_DELAY 1600.0f +// Kosodate Gokko (Japan) (Unl) ha un delay di 78 ms +#define FDS_INSERT_MS_DELAY 74.0f #define fds_auto_insert_enabled() (cfg->fds_switch_side_automatically & !fds.auto_insert.disabled & !fds.bios.first_run) #define fds_reset_envelope_counter(env) (fds.snd.envelope.speed << 3) * (fds.snd.env.speed + 1) @@ -100,6 +101,7 @@ typedef struct _fds_info { BYTE last_operation; BYTE frame_insert; uint32_t cycles_8bit_delay; + uint32_t cycles_insert_delay; uint32_t cycles_dummy_delay; _fds_info_protection protection; _fds_info_side sides[20]; diff --git a/src/core/mappers/mapper_FDS.c b/src/core/mappers/mapper_FDS.c index 73af8e1d2..b054f5683 100644 --- a/src/core/mappers/mapper_FDS.c +++ b/src/core/mappers/mapper_FDS.c @@ -283,7 +283,6 @@ void extcl_cpu_every_cycle_FDS(BYTE nidx) { fds.drive.scan = FALSE; fds.info.last_operation = FDS_OP_NONE; - fds.drive.data_available = FALSE; if (fds.drive.motor_started) { fds.drive.scan = !fds.drive.transfer_reset; @@ -327,24 +326,27 @@ void extcl_cpu_every_cycle_FDS(BYTE nidx) { fds.auto_insert.r4032.checks = 0; if (transfer) { - fds.drive.data_available = 0x80; - fds.drive.transfer_flag = 0x02; - if (fds.drive.irq_disk_enabled) { nes[nidx].c.irq.high |= FDS_DISK_IRQ; } if (fds.drive.io_mode) { fds.drive.data_io = data; - fds.info.last_operation = FDS_OP_READ; + if (!fds.drive.data_available) { + fds.info.last_operation = FDS_OP_READ; + } } else { fds.side.info->data[fds.drive.disk_position] = data; fds.info.writings_occurred = TRUE; - fds.info.last_operation = FDS_OP_WRITE; + if (!fds.drive.data_available) { + fds.info.last_operation = FDS_OP_WRITE; + } } + fds.drive.data_available = 0x80; + fds.drive.transfer_flag = 0x02; } } if (++fds.drive.disk_position >= fds.info.sides[fds.drive.side_inserted].size) { - fds.drive.delay_insert = FDS_DELAY_INSERT; + fds.drive.delay_insert = fds.info.cycles_insert_delay; fds.drive.end_of_head = 0x40; // Bishoujo Alien Battle (Japan) (Unl).fds non esegue la routine a 0xE188 fds.auto_insert.in_game = TRUE;