diff --git a/src/core/cpu_inline.h b/src/core/cpu_inline.h index 0a9b5da11..c1dd95a3d 100644 --- a/src/core/cpu_inline.h +++ b/src/core/cpu_inline.h @@ -700,7 +700,6 @@ INLINE static BYTE fds_rd_mem(BYTE nidx, WORD address, BYTE made_tick) { // bit 1 (trasfer flag) nes[nidx].c.cpu.openbus |= fds.drive.transfer_flag; // bit 2 e 3 non settati - // TODO : bit 4 (CRC control : 0 passato, 1 errore) nes[nidx].c.cpu.openbus |= (fds.drive.crc ? 0x10 : 0x00); // bit 5 non settato // bit 6 (end of head) @@ -725,9 +724,12 @@ INLINE static BYTE fds_rd_mem(BYTE nidx, WORD address, BYTE made_tick) { fds.drive.transfer_flag = FALSE; nes[nidx].c.irq.high &= ~FDS_DISK_IRQ; #if !defined (RELEASE) - //printf("0x%04X 0x%02X [0x%04X] 0x%04X %d %d\n", address, nes[nidx].c.cpu.openbus, - // fds.info.sides[fds.drive.side_inserted].data[fds.drive.disk_position], nes[nidx].c.cpu.opcode_PC, - // fds.drive.disk_position, nes[nidx].c.irq.high); + //printf("0x%04X 0x%02X [0x%04X] 0x%04X %d %d\n", + // address, nes[nidx].c.cpu.openbus, + // fds.info.sides[fds.drive.side_inserted].data[fds.drive.disk_position], + // nes[nidx].c.cpu.opcode_PC, + // fds.drive.disk_position, + // nes[nidx].c.irq.high); #endif return (TRUE); } @@ -749,12 +751,13 @@ INLINE static BYTE fds_rd_mem(BYTE nidx, WORD address, BYTE made_tick) { nes[nidx].c.cpu.openbus |= fds.info.write_protected; #if !defined (RELEASE) - //printf("%5d - %3d - %3d : 0x%04X 0x%02X %d %d %d %d\n", + //printf("%5d - %3d - %3d : 0x%04X 0x%02X %d %d %d %d %d\n", // nes[nidx].p.ppu.frames, // nes[nidx].p.ppu.frame_y, // nes[nidx].p.ppu.frame_x, - // address, nes[nidx].c.cpu.openbus, fds.drive.disk_ejected, fds.drive.scan, - // fds.drive.delay_insert, fds.drive.disk_position); + // address, nes[nidx].c.cpu.openbus, + // fds.drive.end_of_head, fds.drive.transfer_reset, + // fds.drive.motor_started, fds.drive.io_mode, fds.drive.disk_position); #endif if (fds_auto_insert_enabled() && !fds.auto_insert.r4032.disabled && !fds.auto_insert.delay.dummy) { if (!fds.auto_insert.r4032.frames) { @@ -767,10 +770,10 @@ INLINE static BYTE fds_rd_mem(BYTE nidx, WORD address, BYTE made_tick) { if (diff < 70) { if (!fds.drive.scan && (++fds.auto_insert.r4032.checks > FDS_AUTOINSERT_R4032_MAX_CHECKS)) { // - 19 Neunzehn (1988)(Soft Pro)(J).fds (il controllo del r4032 e' mooooolto lento) - // - Dandy (19xx)(Pony Canyon)(J).fds - // - Zelda no Densetsu - The Hyrule Fantasy (1986)(Nintendo)(J).fds // - Ao no Senritsu (1987)(Gakken)(J).fds // - Bishojou SF Alien Battle (19xx)(Hacker International)(J)(Unl)[b].fds + // - Dandy (19xx)(Pony Canyon)(J).fds + // - Zelda no Densetsu - The Hyrule Fantasy (1986)(Nintendo)(J).fds fds_disk_op(FDS_DISK_EJECT, 0, TRUE); gui_update_fds_menu(); fds.auto_insert.delay.dummy = fds.info.cycles_dummy_delay; @@ -1950,7 +1953,7 @@ INLINE static BYTE fds_wr_mem(BYTE nidx, WORD address, BYTE value) { // |+- Enable disk I/O registers // +-- Enable sound I/O registers #if !defined (RELEASE) - //printf("0x%04X 0x%02X %d %d\n", address, value, fds.drive.disk_ejected, fds.drive.delay); + //printf("0x%04X 0x%02X %d %d\n", address, value, fds.drive.disk_ejected, fds.drive.io_mode); #endif fds.drive.enabled_dsk_reg = value & 0x01; fds.drive.enabled_snd_reg = value & 0x02; @@ -2001,18 +2004,14 @@ INLINE static BYTE fds_wr_mem(BYTE nidx, WORD address, BYTE value) { // nes[nidx].p.ppu.frames, // nes[nidx].p.ppu.frame_y, // nes[nidx].p.ppu.frame_x, - // address, value, fds.drive.motor_on, fds.drive.scan, + // address, value, + // fds.drive.motor_started, + // fds.drive.scan, // fds.drive.delay_insert, fds.drive.disk_position); #endif if (fds.drive.enabled_dsk_reg) { fds.drive.motor_on = value & 0x01; - if (!fds.drive.transfer_reset && (value & 0x02)) { - fds.drive.motor_started = TRUE; - } fds.drive.transfer_reset = value & 0x02; - if (!fds.drive.transfer_reset || !fds.drive.motor_on) { - fds.drive.motor_started = FALSE; - } fds.drive.io_mode = value & 0x04; fds.drive.mirroring = value & 0x08; if (fds.drive.mirroring) { @@ -2033,11 +2032,7 @@ INLINE static BYTE fds_wr_mem(BYTE nidx, WORD address, BYTE value) { fds.drive.mark_finded = FALSE; } fds.drive.irq_disk_enabled = value & 0x80; - - // "Akuu Senki Raijin (Japan) (Disk Writer)" (sporcare lo screen). - fds.drive.delay_8bit = fds.info.cycles_8bit_delay; } - fds.drive.transfer_flag = FALSE; nes[nidx].c.irq.high &= ~FDS_DISK_IRQ; return (TRUE); } diff --git a/src/core/fds.c b/src/core/fds.c index d371e2de1..37c8f8ad2 100644 --- a/src/core/fds.c +++ b/src/core/fds.c @@ -115,7 +115,6 @@ void fds_init(void) { fds.side.change.new_side = 0xFF; fds.drive.disk_ejected = TRUE; - fds.drive.motor_on = TRUE; fds.drive.enabled_dsk_reg = 0x01; fds.drive.enabled_snd_reg = 0x02; } @@ -329,7 +328,7 @@ BYTE fds_load_bios(void) { return (EXIT_OK); } -BYTE fds_create_empty_disk(BYTE format, BYTE type, BYTE double_side, uTCHAR *file) { +BYTE fds_create_empty_disk(uTCHAR *file, BYTE format, BYTE type, BYTE double_side) { BYTE total_sides = double_side ? 2 : 1, *mfds = NULL; size_t size = (type == FDS_TYPE_FDS ? 16 : 0) + (fds_disk_side_size(format) * total_sides); FILE *fp = NULL; @@ -561,7 +560,11 @@ void fds_disk_op(WORD type, BYTE side_to_insert, BYTE quiet) { case FDS_DISK_EJECT: fds.drive.disk_ejected = TRUE; fds.drive.scan = FALSE; + fds.drive.end_of_head = 0x40; + fds.drive.motor_on = 0x01; + fds.drive.transfer_reset = 0x02; fds.drive.motor_started = FALSE; + fds.drive.delay_8bit = 0; fds.auto_insert.r4032.frames = 0; fds.auto_insert.r4032.checks = 0; if (!quiet) { @@ -580,8 +583,12 @@ void fds_disk_op(WORD type, BYTE side_to_insert, BYTE quiet) { fds.drive.mark_finded = FALSE; fds.drive.disk_ejected = FALSE; fds.drive.scan = FALSE; + fds.drive.end_of_head = 0x40; + fds.drive.motor_on = 0x01; + fds.drive.transfer_reset = 0x02; fds.drive.motor_started = FALSE; - fds.drive.delay_insert = 32768; + fds.drive.delay_8bit = 0; + fds.drive.delay_insert = FDS_DELAY_INSERT; fds.auto_insert.r4032.frames = 0; fds.auto_insert.r4032.checks = 0; if (!quiet) { @@ -792,7 +799,7 @@ BYTE fds_to_image(_fds_info *finfo) { fib.blength = finfo->protection.magic_card_trainer ? 0x200 - : finfo->protection.kgk ? 0x500 : finfo->protection.quick_hunter ? 0x3000 : 0; + : finfo->protection.kgk ? 0x2500 : finfo->protection.quick_hunter ? 0x3000 : 0; // indico l'inizio del blocco fds_image_memset(&dst[size], FDS_DISK_BLOCK_MARK, 1); size += 1; @@ -1109,7 +1116,7 @@ void fds_image_sinfo(BYTE side, _fds_sinfo *sinfo) { memset(sinfo, 0x00, sizeof(_fds_sinfo)); for (position = 0; position < fds_disk_side_size(fds.info.format);) { - BYTE block = src[position], stop = FALSE;; + BYTE block = src[position], stop = FALSE; uint32_t blength = 1; switch (block) { @@ -1414,7 +1421,7 @@ BYTE fds_create_ips(const BYTE *d1, const size_t size1, const BYTE *d2, const si fwrite("PATCH", 5, 1, fp); fsize += 5; - while ((i < size1) || (i < size2)) { + while ((i < size1) && (i < size2)) { size_t length = 0; BYTE rle = TRUE; diff --git a/src/core/fds.h b/src/core/fds.h index a63355450..cca51797d 100644 --- a/src/core/fds.h +++ b/src/core/fds.h @@ -48,9 +48,10 @@ 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 + DISK_QD_SIDE_SIZE = 65536, }; // https://www.chrismcovell.com/fds-lister.html @@ -234,7 +235,7 @@ EXTERNC void fds_init(void); EXTERNC void fds_quit(void); EXTERNC BYTE fds_load_rom(BYTE format); EXTERNC BYTE fds_load_bios(void); -EXTERNC BYTE fds_create_empty_disk(BYTE format, BYTE type, BYTE double_side, uTCHAR *file); +EXTERNC BYTE fds_create_empty_disk(uTCHAR *file, BYTE format, BYTE type, BYTE double_side); EXTERNC BYTE fds_change_disk(uTCHAR *file); EXTERNC void fds_info(void); EXTERNC void fds_info_side(BYTE side); diff --git a/src/core/mappers/mapper_091.c b/src/core/mappers/mapper_091.c index d5879058e..4e1e9673d 100644 --- a/src/core/mappers/mapper_091.c +++ b/src/core/mappers/mapper_091.c @@ -94,7 +94,7 @@ void extcl_cpu_wr_mem_091(BYTE nidx, WORD address, BYTE value) { m091.chr[address & 0x03] = value; chr_fix_091(); } - return;; + return; case 0x7000: switch (address & 0x0003) { case 0: diff --git a/src/core/mappers/mapper_FDS.c b/src/core/mappers/mapper_FDS.c index 76437db1a..eef8a051a 100644 --- a/src/core/mappers/mapper_FDS.c +++ b/src/core/mappers/mapper_FDS.c @@ -44,7 +44,6 @@ void map_init_FDS(void) { fds.auto_insert.in_game = FALSE; fds.drive.mirroring = 0x08; - fds.drive.transfer_reset = 0x02; fds.drive.io_mode = 0x04; fds.drive.drive_ready = 0x40; @@ -250,89 +249,112 @@ void extcl_cpu_every_cycle_FDS(BYTE nidx) { return; } - if (fds.drive.delay_insert) { - fds.drive.delay_insert--; - return; + if (!fds.drive.motor_on) { + fds.drive.transfer_reset = 0x02; } - if (!fds.drive.motor_on && !fds.drive.motor_started) { + if (fds.drive.delay_insert) { + --fds.drive.delay_insert; + if (fds.drive.transfer_reset) { + fds.drive.motor_started = FALSE; + } + if (fds.drive.delay_insert) { + return; + } fds.drive.disk_position = 0; fds.drive.mark_finded = FALSE; - return; + fds.drive.end_of_head = FALSE; + fds.drive.data_available = FALSE; + fds.drive.delay_8bit = fds.info.cycles_8bit_delay; + } + + if (!fds.drive.motor_started && !fds.drive.transfer_reset && fds.drive.drive_ready) { + // "Akuu Senki Raijin (Japan) (Disk Writer)" (sporcare lo screen). + fds.drive.delay_8bit = fds.info.cycles_8bit_delay; + fds.drive.motor_started = TRUE; } // se c'e' un delay aspetto - if ((fds.drive.delay_8bit > 0) && --fds.drive.delay_8bit) { + if (fds.drive.delay_8bit && --fds.drive.delay_8bit) { return; } - fds.drive.scan = !fds.drive.transfer_reset; + fds.drive.scan = FALSE; fds.info.last_operation = FDS_OP_NONE; fds.drive.data_available = FALSE; - if (fds.drive.scan) { - BYTE data = 0, transfer = FALSE; + if (fds.drive.motor_started) { + fds.drive.scan = !fds.drive.transfer_reset; - data = fds.side.info->data[fds.drive.disk_position]; + if (fds.drive.scan) { + BYTE data = 0, transfer = FALSE; - if (fds.drive.io_mode) { - // read - if (fds.drive.drive_ready) { - if (fds.drive.mark_finded) { - transfer = TRUE; - fds.drive.crc = fds_crc_byte(fds.drive.crc, data); - } else if (data == FDS_DISK_BLOCK_MARK) { - fds.drive.mark_finded = TRUE; - fds.drive.crc = 0; - fds.drive.crc = fds_crc_byte(fds.drive.crc, data); + data = fds.side.info->data[fds.drive.disk_position]; + + if (fds.drive.io_mode) { + // read + if (fds.drive.drive_ready) { + if (fds.drive.mark_finded) { + transfer = TRUE; + fds.drive.crc = fds_crc_byte(fds.drive.crc, data); + } else if (data == FDS_DISK_BLOCK_MARK) { + fds.drive.mark_finded = TRUE; + fds.drive.crc = 0; + fds.drive.crc = fds_crc_byte(fds.drive.crc, data); + } } - } - } else { - if (!fds.drive.drive_ready) { - data = FDS_DISK_GAP; - fds.drive.crc = 0; } else { - if (fds.drive.crc_control) { - data = fds.drive.crc >> 0; - fds.drive.crc >>= 8; + // write + if (!fds.drive.drive_ready) { + data = FDS_DISK_GAP; + fds.drive.crc = 0; } else { - data = fds.drive.data_io; - fds.drive.crc = fds_crc_byte(fds.drive.crc, data); + if (fds.drive.crc_control) { + data = fds.drive.crc >> 0; + fds.drive.crc >>= 8; + } else { + data = fds.drive.data_io; + fds.drive.crc = fds_crc_byte(fds.drive.crc, data); + fds.drive.data_io = FDS_DISK_GAP; + } } + transfer = TRUE; } - transfer = TRUE; - } - fds.auto_insert.r4032.frames = 0; - fds.auto_insert.r4032.checks = 0; + fds.auto_insert.r4032.frames = 0; + fds.auto_insert.r4032.checks = 0; - if (transfer) { - fds.drive.data_available = 0x80; - - if (fds.drive.irq_disk_enabled) { + if (transfer) { + fds.drive.data_available = 0x80; fds.drive.transfer_flag = 0x02; - 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; - } 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.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; + } 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.scan || fds.drive.motor_started) { if (++fds.drive.disk_position >= fds.info.sides[fds.drive.side_inserted].size) { + fds.drive.delay_insert = FDS_DELAY_INSERT; + // Kosodate Gokko non risconosce il fine disco senza questo + if (!fds.drive.transfer_reset && fds.drive.transfer_flag && fds.drive.irq_disk_enabled) { + nes[nidx].c.irq.high |= FDS_DISK_IRQ; + } + // signal "disk is full" if end track was reached during writing + if (!fds.drive.io_mode) { + fds.drive.transfer_reset = 0x02; + } fds.drive.end_of_head = 0x40; - fds.drive.disk_position = 0; - fds.drive.transfer_reset = FALSE; - // Bishoujo Alien Battle (Japan) (Unl).fds non esegue la routine a 0xE188 + // Bishoujo Alien Battle (Japan) (Unl).fds non esegue la routine a 0xE188 fds.auto_insert.in_game = TRUE; if (fds.drive.motor_started) { - fds.drive.motor_on = FALSE; - fds.drive.motor_started = FALSE; if (fds_auto_insert_enabled() && !fds.auto_insert.end_of_head.disabled && !fds.auto_insert.delay.dummy) { fds_disk_op(FDS_DISK_EJECT, 0, TRUE); gui_update_fds_menu(); @@ -340,7 +362,6 @@ void extcl_cpu_every_cycle_FDS(BYTE nidx) { } } } else { - fds.drive.end_of_head = FALSE; // il delay per riuscire a leggere i prossimi 8 bit fds.drive.delay_8bit = fds.info.cycles_8bit_delay; } diff --git a/src/gui/designer/icons/disk_empty.svgz b/src/gui/designer/icons/disk_empty.svgz new file mode 100644 index 000000000..0e8928235 Binary files /dev/null and b/src/gui/designer/icons/disk_empty.svgz differ diff --git a/src/gui/designer/mainWindow.ui b/src/gui/designer/mainWindow.ui index 2ed9f8f18..9e42c8e18 100644 --- a/src/gui/designer/mainWindow.ui +++ b/src/gui/designer/mainWindow.ui @@ -104,6 +104,21 @@ + + + Create Empt&y Disk + + + + :/icon/icons/disk_empty.svgz:/icon/icons/disk_empty.svgz + + + + + + + + @@ -115,6 +130,7 @@ + @@ -819,6 +835,36 @@ C&hange Disk + + + Single Side &FDS Format (with Header) + + + + + Single Side F&DS Format (without Header) + + + + + Single Side &Quick Disk Format + + + + + Double Sides &FDS Format (with Header) + + + + + Double Sides F&DS Format (without Header) + + + + + Double Sides &Quick Disk Format + + diff --git a/src/gui/designer/pics/overlay_fds_motor_led_off.png b/src/gui/designer/pics/overlay_fds_motor_led_off.png new file mode 100644 index 000000000..57b12a701 Binary files /dev/null and b/src/gui/designer/pics/overlay_fds_motor_led_off.png differ diff --git a/src/gui/designer/pics/overlay_fds_motor_led_on.png b/src/gui/designer/pics/overlay_fds_motor_led_on.png new file mode 100644 index 000000000..9b3b3f445 Binary files /dev/null and b/src/gui/designer/pics/overlay_fds_motor_led_on.png differ diff --git a/src/gui/designer/pics/overlay_fds_motor_led_read.png b/src/gui/designer/pics/overlay_fds_motor_led_read.png new file mode 100644 index 000000000..2c38c5ead Binary files /dev/null and b/src/gui/designer/pics/overlay_fds_motor_led_read.png differ diff --git a/src/gui/designer/pics/overlay_fds_motor_led_write.png b/src/gui/designer/pics/overlay_fds_motor_led_write.png new file mode 100644 index 000000000..5ef018d07 Binary files /dev/null and b/src/gui/designer/pics/overlay_fds_motor_led_write.png differ diff --git a/src/gui/designer/resources.qrc b/src/gui/designer/resources.qrc index 2835520cb..fa5c5a0ab 100644 --- a/src/gui/designer/resources.qrc +++ b/src/gui/designer/resources.qrc @@ -7,6 +7,7 @@ icons/flag_arabic.svgz icons/bios.svgz icons/buffer_size.svgz + icons/disk_empty.svgz icons/barcode.svgz icons/camera.svgz icons/flag_germany.svgz @@ -246,6 +247,10 @@ pics/overlay_zapper.png pics/overlay_floppy_gray.png pics/overlay_floppy_green.png + pics/overlay_fds_motor_led_off.png + pics/overlay_fds_motor_led_on.png + pics/overlay_fds_motor_led_read.png + pics/overlay_fds_motor_led_write.png pics/overlay_floppy_red.png pics/overlay_mouse.png pics/overlay_mouse_button.png diff --git a/src/gui/designer/wdgOverlayUi.ui b/src/gui/designer/wdgOverlayUi.ui index 0cc432b38..1e6a3214a 100644 --- a/src/gui/designer/wdgOverlayUi.ui +++ b/src/gui/designer/wdgOverlayUi.ui @@ -190,7 +190,7 @@ - + 16 @@ -200,7 +200,7 @@ - + 16 diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index b30236721..600f12b04 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -895,6 +895,12 @@ void mainWindow::connect_menu_signals(void) { connect_action(action_Switch_sides, 0xFFF, SLOT(s_disk_side())); connect_action(action_Eject_Insert_Disk, SLOT(s_eject_disk())); connect_action(action_Change_Disk, SLOT(s_change_disk())); + connect_action(action_Empty_Disk_FDS_Format_with_Header, 0, SLOT(s_create_empty_disk())); + connect_action(action_Empty_Disk_FDS_Format_without_Header, 1, SLOT(s_create_empty_disk())); + connect_action(action_Empty_Disk_Quick_Disk_Format, 2, SLOT(s_create_empty_disk())); + connect_action(action_Empty_Disk_DS_FDS_Format_with_Header, 3, SLOT(s_create_empty_disk())); + connect_action(action_Empty_Disk_DS_FDS_Format_without_Header, 4, SLOT(s_create_empty_disk())); + connect_action(action_Empty_Disk_DS_Quick_Disk_Format, 5, SLOT(s_create_empty_disk())); connect_action(action_Current_state_to_FDS_with_Header, 0, SLOT(s_export_fds_image())); connect_action(action_Current_state_to_FDS_without_Header, 1, SLOT(s_export_fds_image())); connect_action(action_Current_state_to_Quick_Disk, 2, SLOT(s_export_fds_image())); @@ -1182,12 +1188,14 @@ void mainWindow::update_fds_menu(void) { ctrl_disk_side(action_Disk_4_side_B); action_Eject_Insert_Disk->setEnabled(true); action_Change_Disk->setEnabled(true); + menu_Empty_Disk->setEnabled(true); menu_Export_Current_state->setEnabled(true); } else { action_text(action_Eject_Insert_Disk, tr("&Eject/Insert disk"), sc); menu_Disk_Side->setEnabled(false); action_Eject_Insert_Disk->setEnabled(false); action_Change_Disk->setEnabled(false); + menu_Empty_Disk->setEnabled(false); menu_Export_Current_state->setEnabled(false); } } @@ -1626,6 +1634,72 @@ void mainWindow::s_change_disk(void) { emu_thread_continue(); } +void mainWindow::s_create_empty_disk(void) { + int format = QVariant(((QObject *)sender())->property("myValue")).toInt(); + QStringList filters; + QString file; + + emu_thread_pause(); + + switch (format) { + default: + case 0: + case 1: + filters.append(tr("Single Side FDS Format Disk")); + filters[0].append(" (*.fds *.FDS)"); + break; + case 2: + filters.append(tr("Single Side Quick Disk Format Disk")); + filters[0].append(" (*.qd *.QD)"); + break; + case 3: + case 4: + filters.append(tr("Double Sides FDS Format Disk")); + filters[0].append(" (*.fds *.FDS)"); + break; + case 5: + filters.append(tr("Double Sides Quick Disk Format Disk")); + filters[0].append(" (*.qd *.QD)"); + break; + } + + filters.append(tr("All files")); + filters[1].append(" (*.*)"); + + file = QFileDialog::getSaveFileName(this, tr("Create an image of an empty disk"), + uQString(gui.last_open_path), filters.join(";;")); + + if (!file.isNull()) { + QFileInfo fileinfo(file); + BYTE rc = EXIT_ERROR; + + if (fileinfo.suffix().isEmpty()) { + switch (format) { + default: + case 0: + case 1: + case 3: + case 4: + fileinfo.setFile(QString(file) + ".fds"); + break; + case 2: + case 5: + fileinfo.setFile(QString(file) + ".qd"); + break; + } + } + rc = fds_create_empty_disk(uQStringCD(fileinfo.absoluteFilePath()), + (format == 2) || (format == 5) ? QD_FORMAT : FDS_FORMAT, + (format == 0) || (format == 3) ? FDS_TYPE_FDS : FDS_TYPE_RAW, + format > 2); + if (rc == EXIT_ERROR) { + QMessageBox::critical(this, tr("Error creating file"), + tr("Impossible write %0.").arg(fileinfo.fileName()), QMessageBox::Ok); + } + } + + emu_thread_continue(); +} void mainWindow::s_export_fds_image(void) { int format = QVariant(((QObject *)sender())->property("myValue")).toInt(); QStringList filters; diff --git a/src/gui/mainWindow.hpp b/src/gui/mainWindow.hpp index f240397f3..33e8fb077 100644 --- a/src/gui/mainWindow.hpp +++ b/src/gui/mainWindow.hpp @@ -296,6 +296,7 @@ class mainWindow : public QMainWindow, public Ui::mainWindow { void s_disk_side(void); void s_eject_disk(void); void s_change_disk(void); + void s_create_empty_disk(void); void s_export_fds_image(void); void s_start_stop_audio_recording(void); #if defined (WITH_FFMPEG) diff --git a/src/gui/wdgOverlayUi.cpp b/src/gui/wdgOverlayUi.cpp index a2a938230..cfb8aee4b 100644 --- a/src/gui/wdgOverlayUi.cpp +++ b/src/gui/wdgOverlayUi.cpp @@ -886,41 +886,45 @@ void overlayWidgetFastForward::update_widget(void) { // overlayWidgetFloppy ------------------------------------------------------------------------------------------------- -overlayWidgetFloppy::overlayWidgetFloppy(QWidget *parent) : overlayWidget(parent) {} +overlayWidgetFloppy::overlayWidgetFloppy(QWidget *parent) : overlayWidget(parent) { + set_opacity(0.75); +} overlayWidgetFloppy::~overlayWidgetFloppy() = default; QSize overlayWidgetFloppy::sizeHint(void) const { - return (QSize(floppy.gray.size().width() + hpadtot(), minimum_eight())); + return (QSize(motor.off.size().width() + hpadtot(), minimum_eight())); } void overlayWidgetFloppy::paintEvent(QPaintEvent *event) { - const QPointF coords = QPointF(((qreal)rect().width() - (qreal)(floppy.gray.size().width())) / 2.0, - ((qreal)rect().height() - (qreal)floppy.gray.size().height()) / 2.0); + qreal x = ((qreal)rect().width() - (qreal)motor.off.size().width()) / 2.0; + qreal y = ((qreal)rect().height() - (qreal)motor.off.size().height()) / 2.0; + QPointF coords = QPointF(x, y); overlayWidget::paintEvent(event); painter.begin(this); painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); - if ((fds.info.last_operation | fds.drive.disk_ejected)) { - if (fds.drive.disk_ejected) { - painter.drawImage(coords, floppy.gray); - } else { - if (fds.info.last_operation == FDS_OP_READ) { - painter.drawImage(coords, floppy.green); - } else { - painter.drawImage(coords, floppy.red); - } - if (rwnd.action != RWND_ACT_PAUSE) { - fds.info.last_operation = FDS_OP_NONE; - } - } + + // led del motore e operazioni di I/O + if (fds.info.last_operation == FDS_OP_READ) { + painter.drawImage(coords, motor.read); + } else if (fds.info.last_operation == FDS_OP_WRITE) { + painter.drawImage(coords, motor.write); + } else if (fds.drive.motor_started) { + painter.drawImage(coords, motor.on); + } else { + painter.drawImage(coords, motor.off); + } + if (rwnd.action != RWND_ACT_PAUSE) { + fds.info.last_operation = FDS_OP_NONE; } painter.end(); } void overlayWidgetFloppy::update_dpr(void) { - floppy.gray = dpr_image(":/pics/pics/overlay_floppy_gray.png"); - floppy.red = dpr_image(":/pics/pics/overlay_floppy_red.png"); - floppy.green = dpr_image(":/pics/pics/overlay_floppy_green.png"); + motor.on = dpr_image(":/pics/pics/overlay_fds_motor_led_on.png"); + motor.off = dpr_image(":/pics/pics/overlay_fds_motor_led_off.png"); + motor.read = dpr_image(":/pics/pics/overlay_fds_motor_led_read.png"); + motor.write = dpr_image(":/pics/pics/overlay_fds_motor_led_write.png"); } void overlayWidgetFloppy::update_widget(void) { if (cfg->txt_on_screen & fds.info.enabled & !info.turn_off) { diff --git a/src/gui/wdgOverlayUi.hpp b/src/gui/wdgOverlayUi.hpp index 93eec35aa..f381799f1 100644 --- a/src/gui/wdgOverlayUi.hpp +++ b/src/gui/wdgOverlayUi.hpp @@ -195,11 +195,12 @@ class overlayWidgetFastForward : public overlayWidget { class overlayWidgetFloppy : public overlayWidget { private: - struct _images_floppy { - QImage gray; - QImage red; - QImage green; - } floppy; + struct _images_motor { + QImage on; + QImage off; + QImage read; + QImage write; + } motor; public: explicit overlayWidgetFloppy(QWidget *parent = nullptr);