diff --git a/src/core/cpu_inline.h b/src/core/cpu_inline.h index a0e04335d..42be81739 100644 --- a/src/core/cpu_inline.h +++ b/src/core/cpu_inline.h @@ -729,9 +729,6 @@ static BYTE INLINE fds_rd_mem(WORD address, BYTE made_tick) { } else if (!fds.drive.scan) { cpu.openbus |= 0x02; } -#if !defined (RELEASE) - //fprintf(stderr, "0x%04X 0x%02X\n", address, cpu.openbus); -#endif return (TRUE); } if (address == 0x4033) { @@ -2016,7 +2013,6 @@ static BYTE INLINE fds_wr_mem(WORD address, BYTE value) { if (!fds.drive.enabled_dsk_reg) { return (TRUE); } - fds.drive.data_external_connector = value; return (TRUE); } @@ -2028,51 +2024,43 @@ static BYTE INLINE fds_wr_mem(WORD address, BYTE value) { if (fds.drive.enabled_snd_reg) { if ((address >= 0x4040) && (address <= 0x407F)) { fds.snd.wave.data[address & 0x003F] = value & 0x3F; - return (TRUE); } if (address == 0x4080) { fds.snd.volume.speed = value & 0x3F; fds.snd.volume.increase = value & 0x40; fds.snd.volume.mode = value & 0x80; - return (TRUE); } if (address == 0x4082) { fds.snd.main.frequency = (fds.snd.main.frequency & 0xFF00) | value; - return (TRUE); } if (address == 0x4083) { fds.snd.main.frequency = ((value & 0x0F) << 8) | (fds.snd.main.frequency & 0x00FF); fds.snd.envelope.disabled = value & 0x40; fds.snd.main.silence = value & 0x80; - return (TRUE); } if (address == 0x4084) { fds.snd.sweep.speed = value & 0x3F; fds.snd.sweep.increase = value & 0x40; fds.snd.sweep.mode = value & 0x80; - return (TRUE); } if (address == 0x4085) { fds.snd.sweep.bias = ((SBYTE) (value << 1)) / 2; fds.snd.modulation.index = 0; - return (TRUE); } if (address == 0x4086) { fds.snd.modulation.frequency = (fds.snd.modulation.frequency & 0xFF00) | value; - return (TRUE); } if (address == 0x4087) { fds.snd.modulation.frequency = ((value & 0x0F) << 8) | (fds.snd.modulation.frequency & 0x00FF); fds.snd.modulation.disabled = value & 0x80; - return (TRUE); } if (address == 0x4088) { @@ -2090,18 +2078,15 @@ static BYTE INLINE fds_wr_mem(WORD address, BYTE value) { } fds.snd.modulation.data[a + 1] = fds.snd.modulation.data[a]; } - return (TRUE); } if (address == 0x4089) { fds.snd.wave.writable = value & 0x80; fds.snd.wave.volume = value & 0x03; - return (TRUE); } if (address == 0x408A) { fds.snd.envelope.speed = value; - return (TRUE); } } diff --git a/src/core/fds.c b/src/core/fds.c index 36e6a78ba..566326321 100644 --- a/src/core/fds.c +++ b/src/core/fds.c @@ -42,6 +42,8 @@ typedef struct _fds_diff_ele { void fds_init(void) { memset(&fds, 0x00, sizeof(fds)); + fds.side.change.new_side = 0xFF; + fds.drive.disk_ejected = TRUE; fds.drive.motor_on = TRUE; fds.drive.enabled_dsk_reg = 0x01; @@ -249,9 +251,7 @@ void fds_disk_op(WORD type, BYTE side_to_insert) { #endif fds.side.data = (WORD *) malloc(fds.info.sides_size[side_to_insert] * sizeof(WORD)); - fds.side.counted_files = 0xFFFF; - break; } @@ -405,10 +405,12 @@ void fds_disk_op(WORD type, BYTE side_to_insert) { break; case FDS_DISK_SELECT_AND_INSERT: type = FDS_DISK_INSERT; + fds.side.change.new_side = 0xFF; fds.drive.side_inserted = side_to_insert; fds_diff_op(FDS_OP_READ, 0, 0); goto fds_disk_op_start; case FDS_DISK_SELECT: + fds.side.change.new_side = 0xFF; fds.drive.side_inserted = side_to_insert; text_add_line_info(1, "Disk [cyan]%d [normal]side [cyan]%c [brown]selected", (fds.drive.side_inserted / 2) + 1, (fds.drive.side_inserted & 0x01) + 'A'); diff --git a/src/core/fds.h b/src/core/fds.h index 1d2c0e390..573fbc65d 100644 --- a/src/core/fds.h +++ b/src/core/fds.h @@ -86,6 +86,10 @@ EXTERNC struct _fds { uint32_t position; } block_4; } file[0xFF]; + struct _fds_side_change { + BYTE new_side; + uint32_t delay; + } change; WORD *data; uint32_t counted_files; } side; diff --git a/src/core/mappers/mapper_FDS.c b/src/core/mappers/mapper_FDS.c index 603fbf7ff..654ac1cc8 100644 --- a/src/core/mappers/mapper_FDS.c +++ b/src/core/mappers/mapper_FDS.c @@ -71,6 +71,14 @@ void extcl_cpu_every_cycle_FDS(void) { } } + /* se c'e' un delay aspetto */ + if (fds.side.change.delay > 0) { + if (!(--fds.side.change.delay)) { + fds_disk_op(FDS_DISK_SELECT_AND_INSERT, fds.side.change.new_side); + } + return; + } + /* no disco, no party */ if (fds.drive.disk_ejected) { fds.drive.delay = 1000; diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index 65029992b..c061afb63 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -1211,7 +1211,12 @@ void mainWindow::ctrl_disk_side(QAction *action) { } else { action->setEnabled(false); } - if (side == fds.drive.side_inserted) { + + if (fds.side.change.new_side == 0xFF) { + if (side == fds.drive.side_inserted) { + action->setChecked(true); + } + } else if (side == fds.side.change.new_side) { action->setChecked(true); } } @@ -1821,9 +1826,9 @@ void mainWindow::s_disk_side() { int side = QVariant(((QObject *)sender())->property("myValue")).toInt(); if (side == 0xFFF) { - side = fds.drive.side_inserted; - if (++side >= fds.info.total_sides) { - side = 0; + side = fds.drive.side_inserted ^ 0x01; + if (side >= fds.info.total_sides) { + return; } } @@ -1831,7 +1836,15 @@ void mainWindow::s_disk_side() { return; } - fds_disk_op(FDS_DISK_SELECT, side); + if (fds.drive.disk_ejected) { + fds.side.change.new_side = 0xFF; + fds.side.change.delay = 0; + fds_disk_op(FDS_DISK_SELECT, side); + } else { + fds.side.change.new_side = side; + fds.side.change.delay = 3000000; + fds_disk_op(FDS_DISK_EJECT, 0); + } update_menu_nes(); }