diff --git a/src/bugger.c b/src/bugger.c index cf66def..67a62c9 100644 --- a/src/bugger.c +++ b/src/bugger.c @@ -44,7 +44,7 @@ * configuration register (CTRL_SPCFG bit set) but have to * remember that stuff first... * - * Version: @(#)bugger.c 1.0.2 2018/03/15 + * Version: @(#)bugger.c 1.0.5 2018/04/28 * * Author: Fred N. van Kempen, * @@ -83,12 +83,13 @@ #include #include #include +#include #include #include "emu.h" #include "io.h" #include "device.h" +#include "ui/ui.h" #include "plat.h" -#include "ui.h" #include "bugger.h" @@ -114,7 +115,6 @@ static uint8_t bug_ctrl, /* control register */ static uint8_t bug_buff[FIFO_LEN], /* serial port data buffer */ *bug_bptr; # define UISTR_LEN 24 -static char bug_str[UISTR_LEN]; /* UI output string */ extern void ui_sb_bugui(char *__str); @@ -124,6 +124,9 @@ extern void ui_sb_bugui(char *__str); static void bug_setui(void) { + wchar_t temp[128]; + char bug_str[UISTR_LEN]; + /* Format all current info in a string. */ sprintf(bug_str, "%02X:%02X %c%c%c%c%c%c%c%c-%c%c%c%c%c%c%c%c", bug_seg2, bug_seg1, @@ -136,8 +139,11 @@ bug_setui(void) (bug_ledr&0x08)?'R':'r', (bug_ledr&0x04)?'R':'r', (bug_ledr&0x02)?'R':'r', (bug_ledr&0x01)?'R':'r'); + /* Convert to Unicode. */ + mbstowcs(temp, bug_str, sizeof_w(temp)); + /* Send formatted string to the UI. */ - ui_sb_bugui(bug_str); + ui_sb_text_set_w(temp); } @@ -285,7 +291,7 @@ bug_reset(void) /* Handle a WRITE operation to one of our registers. */ static void -bug_write(uint16_t port, uint8_t val, void *priv) +bug_write(uint16_t port, uint8_t val, UNUSED(void *priv)) { switch (port-BUGGER_ADDR) { case BUG_CTRL: /* control register */ @@ -310,7 +316,7 @@ bug_write(uint16_t port, uint8_t val, void *priv) /* Handle a READ operation from one of our registers. */ static uint8_t -bug_read(uint16_t port, void *priv) +bug_read(uint16_t port, UNUSED(void *priv)) { uint8_t ret = 0xff; diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 87492f8..af28417 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.11 2018/03/31 + * Version: @(#)cdrom.c 1.0.13 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -55,8 +55,8 @@ #include "../scsi/scsi.h" #include "../disk/hdc.h" #include "../disk/hdc_ide.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "cdrom.h" #include "cdrom_image.h" #include "cdrom_null.h" @@ -2064,9 +2064,9 @@ cdrom_readtoc_fallback: dev->all_blocks_total = dev->block_total; if (dev->packet_status != CDROM_PHASE_COMPLETE) - ui_sb_update_icon(SB_CDROM | id, 1); + ui_sb_icon_update(SB_CDROM | id, 1); else - ui_sb_update_icon(SB_CDROM | id, 0); + ui_sb_icon_update(SB_CDROM | id, 0); return; case GPCMD_READ_HEADER: @@ -3140,7 +3140,7 @@ void cdrom_phase_callback(uint8_t id) dev->status = READY_STAT; dev->phase = 3; dev->packet_status = 0xFF; - ui_sb_update_icon(SB_CDROM | id, 0); + ui_sb_icon_update(SB_CDROM | id, 0); cdrom_irq_raise(id); return; case CDROM_PHASE_DATA_OUT: @@ -3177,7 +3177,7 @@ void cdrom_phase_callback(uint8_t id) dev->status = READY_STAT | ERR_STAT; dev->phase = 3; cdrom_irq_raise(id); - ui_sb_update_icon(SB_CDROM | id, 0); + ui_sb_icon_update(SB_CDROM | id, 0); return; } } diff --git a/src/cdrom/cdrom_image.cpp b/src/cdrom/cdrom_image.cpp index 5a67633..365a400 100644 --- a/src/cdrom/cdrom_image.cpp +++ b/src/cdrom/cdrom_image.cpp @@ -8,7 +8,7 @@ * * CD-ROM image support. * - * Version: @(#)cdrom_image.cpp 1.0.7 2018/03/21 + * Version: @(#)cdrom_image.cpp 1.0.8 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -96,7 +96,7 @@ void cdrom_image_log(const char *format, ...) void image_close(uint8_t id); -void image_audio_callback(uint8_t id, int16_t *output, int len) +static void image_audio_callback(uint8_t id, int16_t *output, int len) { cdrom_t *dev = cdrom[id]; @@ -138,7 +138,7 @@ void image_audio_callback(uint8_t id, int16_t *output, int len) dev->cd_buflen -= len; } -void image_audio_stop(uint8_t id) +static void image_audio_stop(uint8_t id) { cdrom_t *dev = cdrom[id]; diff --git a/src/config.c b/src/config.c index 959a4c7..4eb34d7 100644 --- a/src/config.c +++ b/src/config.c @@ -12,7 +12,7 @@ * it on Windows XP, and possibly also Vista. Use the * -DANSI_CFG for use on these systems. * - * Version: @(#)config.c 1.0.19 2018/04/26 + * Version: @(#)config.c 1.0.20 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -72,8 +72,8 @@ #include "sound/midi.h" #include "sound/sound.h" #include "video/video.h" +#include "ui/ui.h" #include "plat.h" -#include "ui.h" #define ANSI_CFG 1 /* for now, always */ diff --git a/src/device.c b/src/device.c index cf17597..a057560 100644 --- a/src/device.c +++ b/src/device.c @@ -9,7 +9,7 @@ * Implementation of the generic device interface to handle * all devices attached to the emulator. * - * Version: @(#)device.c 1.0.7 2018/04/25 + * Version: @(#)device.c 1.0.8 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -48,8 +48,8 @@ #include "device.h" #include "machine/machine.h" #include "sound/sound.h" +#include "ui/ui.h" #include "plat.h" -#include "ui.h" #define DEVICE_MAX 256 /* max # of devices */ diff --git a/src/disk/hdc_esdi_at.c b/src/disk/hdc_esdi_at.c index f2eebb3..f7fab21 100644 --- a/src/disk/hdc_esdi_at.c +++ b/src/disk/hdc_esdi_at.c @@ -8,7 +8,7 @@ * * Driver for the ESDI controller (WD1007-vse1) for PC/AT. * - * Version: @(#)hdc_esdi_at.c 1.0.7 2018/04/23 + * Version: @(#)hdc_esdi_at.c 1.0.9 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,16 +45,16 @@ #include #include #include "../emu.h" -#include "../device.h" -#include "../io.h" -#include "../mem.h" -#include "../pic.h" -#include "../rom.h" #include "../cpu/cpu.h" #include "../machine/machine.h" +#include "../io.h" +#include "../pic.h" +#include "../mem.h" +#include "../rom.h" +#include "../device.h" #include "../timer.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "hdc.h" #include "hdd.h" @@ -438,7 +438,7 @@ hdc_readw(uint16_t port, void *priv) dev->callback = 6LL*HDC_TIME; timer_update_outstanding(); } else { - ui_sb_update_icon(SB_HDD|HDD_BUS_ESDI, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_ESDI, 0); } } } @@ -513,7 +513,7 @@ hdc_callback(void *priv) dev->cylinder = 0; dev->reset = 0; - ui_sb_update_icon(SB_HDD|HDD_BUS_ESDI, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_ESDI, 0); return; } @@ -565,7 +565,7 @@ hdc_callback(void *priv) dev->pos = 0; dev->status = STAT_DRQ|STAT_READY|STAT_DSC; irq_raise(dev); - ui_sb_update_icon(SB_HDD|HDD_BUS_ESDI, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ESDI, 1); break; case CMD_WRITE: @@ -595,7 +595,7 @@ hdc_callback(void *priv) } else { dev->status = STAT_READY|STAT_DSC; } - ui_sb_update_icon(SB_HDD|HDD_BUS_ESDI, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ESDI, 1); break; case CMD_VERIFY: @@ -616,7 +616,7 @@ hdc_callback(void *priv) hdd_image_read(drive->hdd_num, addr, 1, (uint8_t *)dev->buffer); - ui_sb_update_icon(SB_HDD|HDD_BUS_ESDI, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ESDI, 1); next_sector(dev); dev->secount = (dev->secount - 1) & 0xff; if (dev->secount) @@ -647,7 +647,7 @@ hdc_callback(void *priv) dev->status = STAT_READY|STAT_DSC; irq_raise(dev); - ui_sb_update_icon(SB_HDD|HDD_BUS_ESDI, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ESDI, 1); break; case CMD_DIAGNOSE: @@ -779,7 +779,7 @@ hdc_callback(void *priv) break; } - ui_sb_update_icon(SB_HDD|HDD_BUS_ESDI, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_ESDI, 0); } @@ -838,7 +838,7 @@ wd1007vse1_init(const device_t *info) timer_add(hdc_callback, &dev->callback, &dev->callback, dev); - ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 0); + ui_sb_icon_update(SB_HDD | HDD_BUS_ESDI, 0); return(dev); } @@ -859,7 +859,7 @@ wd1007vse1_close(void *priv) free(dev); - ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 0); + ui_sb_icon_update(SB_HDD | HDD_BUS_ESDI, 0); } diff --git a/src/disk/hdc_esdi_mca.c b/src/disk/hdc_esdi_mca.c index 0ee1fd8..5d49041 100644 --- a/src/disk/hdc_esdi_mca.c +++ b/src/disk/hdc_esdi_mca.c @@ -52,7 +52,7 @@ * however, are auto-configured by the system software as * shown above. * - * Version: @(#)hdc_esdi_mca.c 1.0.8 2018/04/24 + * Version: @(#)hdc_esdi_mca.c 1.0.10 2018/04/28 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -85,14 +85,14 @@ #include #include "../emu.h" #include "../device.h" -#include "../dma.h" #include "../io.h" +#include "../dma.h" +#include "../pic.h" #include "../mca.h" #include "../mem.h" -#include "../pic.h" #include "../rom.h" #include "../timer.h" -#include "../ui.h" +#include "../ui/ui.h" #include "hdc.h" #include "hdd.h" @@ -375,7 +375,7 @@ hdc_callback(void *priv) if (dev->rba >= drive->sectors) fatal("Read past end of drive\n"); hdd_image_read(drive->hdd_num, dev->rba, 1, (uint8_t *)dev->data); - ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 1); + ui_sb_icon_update(SB_HDD | HDD_BUS_ESDI, 1); } while (dev->data_pos < 256) { @@ -461,11 +461,11 @@ hdc_callback(void *priv) hdd_image_write(drive->hdd_num, dev->rba, 1, (uint8_t *)dev->data); dev->rba++; dev->sector_pos++; - ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 1); + ui_sb_icon_update(SB_HDD | HDD_BUS_ESDI, 1); dev->data_pos = 0; } - ui_sb_update_icon(SB_HDD | HDD_BUS_ESDI, 0); + ui_sb_icon_update(SB_HDD | HDD_BUS_ESDI, 0); dev->status = STATUS_CMD_IN_PROGRESS; dev->cmd_state = 2; diff --git a/src/disk/hdc_ide_ata.c b/src/disk/hdc_ide_ata.c index abacc0b..561d4d5 100644 --- a/src/disk/hdc_ide_ata.c +++ b/src/disk/hdc_ide_ata.c @@ -14,7 +14,7 @@ * Devices currently implemented are hard disk, CD-ROM and * ZIP IDE/ATAPI devices. * - * Version: @(#)hdc_ide_ata.c 1.0.19 2018/04/25 + * Version: @(#)hdc_ide_ata.c 1.0.21 2018/04/28 * * Authors: Miran Grca, * Sarah Walker, @@ -61,8 +61,8 @@ #include "../device.h" #include "../cdrom/cdrom.h" #include "../scsi/scsi.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "hdc.h" #include "hdc_ide.h" #include "hdd.h" @@ -1767,7 +1767,7 @@ uint32_t ide_read_data(int ide_board, int length) } else { - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 0); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 0); } } } @@ -2189,7 +2189,7 @@ void callbackide(int ide_board) ide_irq_raise(ide); - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 1); return; case WIN_READ_DMA: @@ -2241,7 +2241,7 @@ void callbackide(int ide_board) ide->atastat = READY_STAT | DSC_STAT; ide_irq_raise(ide); - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 0); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 0); } } else { #ifdef ENABLE_HDC_LOG @@ -2298,7 +2298,7 @@ void callbackide(int ide_board) ide->blockcount = 0; } - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 1); return; case WIN_WRITE: @@ -2319,12 +2319,12 @@ void callbackide(int ide_board) ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT; ide->pos=0; ide_next_sector(ide); - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 1); } else { ide->atastat = READY_STAT | DSC_STAT; - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 0); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 0); } return; @@ -2372,7 +2372,7 @@ void callbackide(int ide_board) ide->atastat = READY_STAT | DSC_STAT; ide_irq_raise(ide); - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 0); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 0); } } else { #ifdef ENABLE_HDC_LOG @@ -2405,12 +2405,12 @@ void callbackide(int ide_board) ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT; ide->pos=0; ide_next_sector(ide); - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 1); } else { ide->atastat = READY_STAT | DSC_STAT; - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 0); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 0); } return; @@ -2427,7 +2427,7 @@ void callbackide(int ide_board) ide->pos=0; ide->atastat = READY_STAT | DSC_STAT; ide_irq_raise(ide); - ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1); + ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 1); return; case WIN_FORMAT: @@ -2444,7 +2444,7 @@ void callbackide(int ide_board) ide->atastat = READY_STAT | DSC_STAT; ide_irq_raise(ide); - /* ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1); */ + /* ui_sb_icon_update(SB_HDD | hdd[ide->hdd_num].bus, 1); */ return; case WIN_DRIVE_DIAGNOSTICS: diff --git a/src/disk/hdc_ide_xta.c b/src/disk/hdc_ide_xta.c index a17e8ac..e1bd8fb 100644 --- a/src/disk/hdc_ide_xta.c +++ b/src/disk/hdc_ide_xta.c @@ -46,7 +46,7 @@ * * NOTE: The XTA interface is 0-based for sector numbers !! * - * Version: @(#)hdc_ide_xta.c 1.0.4 2018/04/25 + * Version: @(#)hdc_ide_xta.c 1.0.6 2018/04/28 * * Author: Fred N. van Kempen, * @@ -100,14 +100,14 @@ #include "../rom.h" #include "../device.h" #include "../timer.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "hdc.h" #include "hdd.h" #define HDC_TIME (50*TIMER_USEC) -#define XTA_NUM 2 /* we support 2 drives */ +#define XTA_NUM 1 /* we support 1 drive */ #define WD_BIOS_FILE L"disk/xta/idexywd2.bin" @@ -388,7 +388,7 @@ do_format(hdc_t *dev, drive_t *drive, dcb_t *dcb) drive->id, dev->track, dev->head); #endif /* Activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 1); do_fmt: /* @@ -423,7 +423,7 @@ do_fmt: } /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); } @@ -529,7 +529,7 @@ hdc_callback(void *priv) case STATE_SEND: /* Activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 1); #ifdef ENABLE_HDC_LOG hdc_log("%s: read_%s(%d: %d,%d,%d) cnt=%d\n", dev->name, (no_data)?"verify":"sector", @@ -540,7 +540,7 @@ do_send: /* Get address of sector to load. */ if (get_sector(dev, drive, &addr)) { /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); dev->comp |= COMP_ERR; set_intr(dev); return; @@ -604,7 +604,7 @@ do_send: drive->id); #endif /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); set_intr(dev); return; @@ -652,7 +652,7 @@ do_send: case STATE_RECV: /* Activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 1); #ifdef ENABLE_HDC_LOG hdc_log("%s: write_%s(%d: %d,%d,%d) cnt=%d\n", dev->name, (no_data)?"verify":"sector", @@ -711,7 +711,7 @@ do_recv: /* Get address of sector to write. */ if (get_sector(dev, drive, &addr)) { /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); dev->comp |= COMP_ERR; set_intr(dev); @@ -730,7 +730,7 @@ do_recv: drive->id); #endif /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); set_intr(dev); return; diff --git a/src/disk/hdc_st506_at.c b/src/disk/hdc_st506_at.c index 762ba1f..eb9a2bc 100644 --- a/src/disk/hdc_st506_at.c +++ b/src/disk/hdc_st506_at.c @@ -12,7 +12,7 @@ * based design. Most cards were WD1003-WA2 or -WAH, where the * -WA2 cards had a floppy controller as well (to save space.) * - * Version: @(#)hdc_st506_at.c 1.0.5 2018/04/23 + * Version: @(#)hdc_st506_at.c 1.0.7 2018/04/28 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -47,14 +47,14 @@ #include #include #include "../emu.h" -#include "../device.h" -#include "../io.h" -#include "../pic.h" #include "../cpu/cpu.h" #include "../machine/machine.h" +#include "../io.h" +#include "../pic.h" +#include "../device.h" #include "../timer.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "hdc.h" #include "hdd.h" @@ -506,7 +506,7 @@ hdc_readw(uint16_t port, void *priv) dev->callback = 6LL*ST506_TIME; timer_update_outstanding(); } else { - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 0); } } } @@ -606,7 +606,7 @@ do_callback(void *priv) dev->reset = 0; - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 0); return; } @@ -640,7 +640,7 @@ do_callback(void *priv) dev->pos = 0; dev->status = STAT_DRQ|STAT_READY|STAT_DSC; irq_raise(dev); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 1); break; case CMD_WRITE: @@ -665,9 +665,9 @@ do_callback(void *priv) dev->status |= STAT_DRQ; dev->pos = 0; next_sector(dev); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 1); } else { - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 0); } irq_raise(dev); break; @@ -681,7 +681,7 @@ do_callback(void *priv) dev->pos = 0; dev->status = STAT_READY|STAT_DSC; irq_raise(dev); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 1); break; case CMD_FORMAT: @@ -701,7 +701,7 @@ do_callback(void *priv) dev->status = STAT_READY|STAT_DSC; irq_raise(dev); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 1); break; case CMD_DIAGNOSE: @@ -784,7 +784,7 @@ st506_init(const device_t *info) timer_add(do_callback, &dev->callback, &dev->callback, dev); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 0); return(dev); } @@ -804,7 +804,7 @@ st506_close(void *priv) free(dev); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 0); } diff --git a/src/disk/hdc_st506_xt.c b/src/disk/hdc_st506_xt.c index b8b08f0..4fb4ed9 100644 --- a/src/disk/hdc_st506_xt.c +++ b/src/disk/hdc_st506_xt.c @@ -41,7 +41,7 @@ * Since all controllers (including the ones made by DTC) use * (mostly) the same API, we keep them all in this module. * - * Version: @(#)hdc_st506_xt.c 1.0.7 2018/04/23 + * Version: @(#)hdc_st506_xt.c 1.0.9 2018/04/28 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -83,8 +83,8 @@ #include "../pic.h" #include "../rom.h" #include "../timer.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "hdc.h" #include "hdd.h" @@ -445,7 +445,7 @@ st506_callback(void *priv) st506_complete(dev); - ui_sb_update_icon(SB_HDD | HDD_BUS_ST506, 1); + ui_sb_icon_update(SB_HDD | HDD_BUS_ST506, 1); break; default: @@ -492,7 +492,7 @@ st506_callback(void *priv) hdd_image_read(drive->hdd_num, addr, 1, (uint8_t *) dev->sector_buf); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 1); if (dev->irq_dma_mask & DMA_ENA) dev->callback = ST506_TIME; @@ -539,7 +539,7 @@ st506_callback(void *priv) hdd_image_read(drive->hdd_num, addr, 1, (uint8_t *) dev->sector_buf); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 1); dev->state = STATE_SEND_DATA; @@ -551,7 +551,7 @@ st506_callback(void *priv) } } else { st506_complete(dev); - ui_sb_update_icon(SB_HDD | HDD_BUS_ST506, 0); + ui_sb_icon_update(SB_HDD | HDD_BUS_ST506, 0); } break; @@ -613,7 +613,7 @@ st506_callback(void *priv) hdd_image_write(drive->hdd_num, addr, 1, (uint8_t *) dev->sector_buf); - ui_sb_update_icon(SB_HDD|HDD_BUS_ST506, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_ST506, 1); next_sector(dev); dev->data_pos = 0; diff --git a/src/disk/hdd.c b/src/disk/hdd.c index c639910..8db3060 100644 --- a/src/disk/hdd.c +++ b/src/disk/hdd.c @@ -8,7 +8,7 @@ * * Common code to handle all sorts of hard disk images. * - * Version: @(#)hdd.c 1.0.3 2018/04/23 + * Version: @(#)hdd.c 1.0.5 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -41,8 +41,8 @@ #include #define HAVE_STDARG_H #include "../emu.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "hdd.h" @@ -77,6 +77,21 @@ hdd_init(void) } +int +hdd_count(int bus) +{ + int c = 0; + int i; + + for (i=0; i * Miran Grca, @@ -41,6 +41,10 @@ #define HDD_NUM 30 /* total of 30 images supported */ +#ifdef __cplusplus +extern "C" { +#endif + /* Hard Disk bus types. */ enum { HDD_BUS_DISABLED = 0, @@ -105,6 +109,7 @@ extern int hdd_do_log; extern void hdd_log(const char *fmt, ...); extern int hdd_init(void); +extern int hdd_count(int bus); extern int hdd_string_to_bus(char *str, int cdrom); extern char *hdd_bus_to_string(int bus, int cdrom); extern int hdd_is_valid(int c); @@ -126,5 +131,9 @@ extern void hdd_image_close(uint8_t id); extern int image_is_hdi(const wchar_t *s); extern int image_is_hdx(const wchar_t *s, int check_signature); +#ifdef __cplusplus +} +#endif + #endif /*EMU_HDD_H*/ diff --git a/src/disk/zip.c b/src/disk/zip.c index c02111a..cd24632 100644 --- a/src/disk/zip.c +++ b/src/disk/zip.c @@ -9,7 +9,7 @@ * Implementation of the Iomega ZIP drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)zip.c 1.0.10 2018/04/02 + * Version: @(#)zip.c 1.0.12 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,8 +50,8 @@ #include "../nvr.h" #include "../disk/hdc.h" #include "../disk/hdc_ide.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "zip.h" @@ -512,7 +512,7 @@ int find_zip_for_channel(uint8_t channel) void zip_init(int id, int cdb_len_setting); -int zip_load(uint8_t id, wchar_t *fn) +int zip_load(uint8_t id, const wchar_t *fn) { int read_only = zip_drives[id].ui_writeprot; int size = 0; @@ -1673,9 +1673,9 @@ void zip_command(uint8_t id, uint8_t *cdb) zip[id].all_blocks_total = zip[id].block_total; if (zip[id].packet_status != ZIP_PHASE_COMPLETE) - ui_sb_update_icon(SB_ZIP | id, 1); + ui_sb_icon_update(SB_ZIP | id, 1); else - ui_sb_update_icon(SB_ZIP | id, 0); + ui_sb_icon_update(SB_ZIP | id, 0); return; case GPCMD_VERIFY_6: @@ -1765,9 +1765,9 @@ void zip_command(uint8_t id, uint8_t *cdb) zip[id].all_blocks_total = zip[id].block_total; if (zip[id].packet_status != ZIP_PHASE_COMPLETE) - ui_sb_update_icon(SB_ZIP | id, 1); + ui_sb_icon_update(SB_ZIP | id, 1); else - ui_sb_update_icon(SB_ZIP | id, 0); + ui_sb_icon_update(SB_ZIP | id, 0); return; case GPCMD_WRITE_SAME_10: @@ -1831,9 +1831,9 @@ void zip_command(uint8_t id, uint8_t *cdb) zip[id].all_blocks_total = zip[id].block_total; if (zip[id].packet_status != ZIP_PHASE_COMPLETE) - ui_sb_update_icon(SB_ZIP | id, 1); + ui_sb_icon_update(SB_ZIP | id, 1); else - ui_sb_update_icon(SB_ZIP | id, 0); + ui_sb_icon_update(SB_ZIP | id, 0); return; case GPCMD_MODE_SENSE_6: @@ -2334,7 +2334,7 @@ void zip_pio_request(uint8_t id, uint8_t out) zip_command_complete(id); } else zip_command_complete(id); - ui_sb_update_icon(SB_ZIP | id, 0); + ui_sb_icon_update(SB_ZIP | id, 0); zip_buf_free(id); } else { #ifdef ENABLE_ZIP_LOG @@ -2436,7 +2436,7 @@ int zip_read_from_dma(uint8_t id) zip[id].packet_status = ZIP_PHASE_COMPLETE; zip[id].status = READY_STAT; zip[id].phase = 3; - ui_sb_update_icon(SB_ZIP | id, 0); + ui_sb_icon_update(SB_ZIP | id, 0); zip_irq_raise(id); if (ret) return 1; @@ -2504,7 +2504,7 @@ int zip_write_to_dma(uint8_t id) zip[id].packet_status = ZIP_PHASE_COMPLETE; zip[id].status = READY_STAT; zip[id].phase = 3; - ui_sb_update_icon(SB_ZIP | id, 0); + ui_sb_icon_update(SB_ZIP | id, 0); zip_irq_raise(id); if (ret) return 1; @@ -2542,7 +2542,7 @@ void zip_phase_callback(uint8_t id) zip[id].status = READY_STAT; zip[id].phase = 3; zip[id].packet_status = 0xFF; - ui_sb_update_icon(SB_ZIP | id, 0); + ui_sb_icon_update(SB_ZIP | id, 0); zip_irq_raise(id); return; case ZIP_PHASE_DATA_OUT: @@ -2581,7 +2581,7 @@ void zip_phase_callback(uint8_t id) zip[id].phase = 3; zip[id].packet_status = 0xFF; zip_irq_raise(id); - ui_sb_update_icon(SB_ZIP | id, 0); + ui_sb_icon_update(SB_ZIP | id, 0); return; } } diff --git a/src/disk/zip.h b/src/disk/zip.h index 3371a62..29a2f45 100644 --- a/src/disk/zip.h +++ b/src/disk/zip.h @@ -9,7 +9,7 @@ * Implementation of the Iomega ZIP drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)zip.h 1.0.4 2018/03/20 + * Version: @(#)zip.h 1.0.5 2018/04/28 * * Author: Miran Grca, * @@ -217,7 +217,7 @@ extern int zip_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t extern void zip_global_init(void); extern void zip_hard_reset(void); -extern int zip_load(uint8_t id, wchar_t *fn); +extern int zip_load(uint8_t id, const wchar_t *fn); extern void zip_close(uint8_t id); #ifdef __cplusplus diff --git a/src/dma.c b/src/dma.c index f58914d..5bfa71c 100644 --- a/src/dma.c +++ b/src/dma.c @@ -8,7 +8,7 @@ * * Implementation of the Intel DMA controllers. * - * Version: @(#)dma.c 1.0.3 2018/03/13 + * Version: @(#)dma.c 1.0.4 2018/04/26 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -48,6 +48,7 @@ #include "mem.h" #include "io.h" #include "dma.h" +#include "plat.h" dma_t dma[8]; @@ -84,7 +85,7 @@ static void dma_ps2_run(int channel); static uint8_t -dma_read(uint16_t addr, void *priv) +dma_read(uint16_t addr, UNUSED(void *priv)) { int channel = (addr >> 1) & 3; uint8_t temp; @@ -124,7 +125,7 @@ dma_read(uint16_t addr, void *priv) static void -dma_write(uint16_t addr, uint8_t val, void *priv) +dma_write(uint16_t addr, uint8_t val, UNUSED(void *priv)) { int channel = (addr >> 1) & 3; @@ -197,7 +198,7 @@ dma_write(uint16_t addr, uint8_t val, void *priv) static uint8_t -dma_ps2_read(uint16_t addr, void *priv) +dma_ps2_read(uint16_t addr, UNUSED(void *priv)) { dma_t *dma_c = &dma[dma_ps2.xfr_channel]; uint8_t temp = 0xff; @@ -264,7 +265,7 @@ dma_ps2_read(uint16_t addr, void *priv) static void -dma_ps2_write(uint16_t addr, uint8_t val, void *priv) +dma_ps2_write(uint16_t addr, uint8_t val, UNUSED(void *priv)) { dma_t *dma_c = &dma[dma_ps2.xfr_channel]; uint8_t mode; @@ -355,7 +356,7 @@ dma_ps2_write(uint16_t addr, uint8_t val, void *priv) static uint8_t -dma16_read(uint16_t addr, void *priv) +dma16_read(uint16_t addr, UNUSED(void *priv)) { int channel = ((addr >> 2) & 3) + 4; uint8_t temp; @@ -398,7 +399,7 @@ dma16_read(uint16_t addr, void *priv) static void -dma16_write(uint16_t addr, uint8_t val, void *priv) +dma16_write(uint16_t addr, uint8_t val, UNUSED(void *priv)) { int channel = ((addr >> 2) & 3) + 4; addr >>= 1; @@ -477,7 +478,7 @@ dma16_write(uint16_t addr, uint8_t val, void *priv) static void -dma_page_write(uint16_t addr, uint8_t val, void *priv) +dma_page_write(uint16_t addr, uint8_t val, UNUSED(void *priv)) { dmapages[addr & 0xf] = val; @@ -534,7 +535,7 @@ dma_page_write(uint16_t addr, uint8_t val, void *priv) static uint8_t -dma_page_read(uint16_t addr, void *priv) +dma_page_read(uint16_t addr, UNUSED(void *priv)) { return(dmapages[addr & 0xf]); } @@ -624,7 +625,7 @@ ps2_dma_init(void) uint8_t -_dma_read(uint32_t addr) +_dma_read(int32_t addr) { uint8_t temp = mem_readb_phys_dma(addr); diff --git a/src/emu.h b/src/emu.h index f8b5d45..6df1a0d 100644 --- a/src/emu.h +++ b/src/emu.h @@ -8,7 +8,7 @@ * * Main include file for the application. * - * Version: @(#)emu.h 1.0.19 2018/04/26 + * Version: @(#)emu.h 1.0.20 2018/04/28 * * Author: Fred N. van Kempen, * @@ -104,7 +104,9 @@ extern int vid_api, /* (C) video renderer */ suppress_overscan, /* (C) suppress overscans */ scale, /* (C) screen scale factor */ enable_overscan, /* (C) video */ - force_43; /* (C) video */ + force_43, /* (C) video */ + rctrl_is_lalt, /* (C) set R-CTRL as L-ALT */ + update_icons; /* (C) update statbar icons */ extern int video_card, /* (C) graphics/video card */ video_speed, /* (C) video option */ voodoo_enabled; /* (C) video option */ @@ -115,8 +117,6 @@ extern int game_enabled, /* (C) enable game port */ parallel_enabled[], /* (C) enable LPT ports */ parallel_device[], /* (C) set up LPT devices */ bugger_enabled; /* (C) enable ISAbugger */ -extern int rctrl_is_lalt; /* (C) set R-CTRL as L-ALT */ -extern int update_icons; /* (C) enable icons updates */ #ifdef WALTJE extern int romdos_enabled; /* (C) enable ROM DOS */ #endif diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 0394ee1..8b2ee42 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -9,7 +9,7 @@ * Implementation of the NEC uPD-765 and compatible floppy disk * controller. * - * Version: @(#)fdc.c 1.0.7 2018/04/12 + * Version: @(#)fdc.c 1.0.9 2018/04/28 * * Authors: Miran Grca, * Sarah Walker, @@ -52,7 +52,7 @@ #include "../dma.h" #include "../pic.h" #include "../timer.h" -#include "../ui.h" +#include "../ui/ui.h" #include "fdd.h" #include "fdc.h" @@ -101,7 +101,6 @@ static const int command_has_drivesel[256] = { }; uint8_t current_drive = 0; -//int timetolive; int lastbyte = 0; int floppymodified[FDD_NUM]; int floppyrate[FDD_NUM]; @@ -689,7 +688,7 @@ fdc_io_command_phase1(fdc_t *fdc, int out) fdc_implied_seek(fdc); fdc->rw_track = fdc->params[1]; fdc->time = 0LL; - ui_sb_update_icon(SB_FLOPPY | fdc->drive, 1); + ui_sb_icon_update(SB_FLOPPY | fdc->drive, 1); fdc->stat = out ? 0x90 : 0x50; if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma) fdc->stat |= 0x20; @@ -764,7 +763,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->time = 128LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); fdc->interrupt = -1; - ui_sb_update_icon(SB_FLOPPY | 0, 0); + ui_sb_icon_update(SB_FLOPPY | 0, 0); fdc_ctrl_reset(fdc); } if (!fdd_get_flags(0)) @@ -794,7 +793,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->perp &= 0xfc; for (i = 0; i < FDD_NUM; i++) - ui_sb_update_icon(SB_FLOPPY | i, 0); + ui_sb_icon_update(SB_FLOPPY | i, 0); fdc_ctrl_reset(fdc); } @@ -1387,7 +1386,7 @@ fdc_poll_common_finish(fdc_t *fdc, int compare, int st5) fdc->res[9]=fdc->sector; fdc->res[10]=fdc->params[4]; fdc_log("Read/write finish (%02X %02X %02X %02X %02X %02X %02X)\n" , fdc->res[4], fdc->res[5], fdc->res[6], fdc->res[7], fdc->res[8], fdc->res[9], fdc->res[10]); - ui_sb_update_icon(SB_FLOPPY | fdc->drive, 0); + ui_sb_icon_update(SB_FLOPPY | fdc->drive, 0); fdc->paramstogo = 7; } @@ -1444,7 +1443,7 @@ fdc_callback(void *priv) return; case 2: /*Read track*/ - ui_sb_update_icon(SB_FLOPPY | fdc->drive, 1); + ui_sb_icon_update(SB_FLOPPY | fdc->drive, 1); fdc->eot[fdc->drive]--; fdc->read_track_sector.id.r++; if (!fdc->eot[fdc->drive] || fdc->tc) { @@ -1561,7 +1560,7 @@ fdc_callback(void *priv) } } else if (fdc->sector < fdc->params[5]) fdc->sector++; - ui_sb_update_icon(SB_FLOPPY | fdc->drive, 1); + ui_sb_icon_update(SB_FLOPPY | fdc->drive, 1); switch (fdc->interrupt) { case 5: case 9: @@ -1739,7 +1738,7 @@ fdc_error(fdc_t *fdc, int st5, int st6) } fdc->paramstogo = 7; - ui_sb_update_icon(SB_FLOPPY | fdc->drive, 0); + ui_sb_icon_update(SB_FLOPPY | fdc->drive, 0); } @@ -1988,7 +1987,7 @@ fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side, uint8_t sector, uint8_t si fdc->res[10] = size; fdc->paramstogo = 7; - ui_sb_update_icon(SB_FLOPPY | fdc->drive, 0); + ui_sb_icon_update(SB_FLOPPY | fdc->drive, 0); } @@ -2133,7 +2132,7 @@ fdc_reset(void *priv) current_drive = 0; for (i = 0; i < FDD_NUM; i++) - ui_sb_update_icon(SB_FLOPPY | i, 0); + ui_sb_icon_update(SB_FLOPPY | i, 0); } diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index f817f05..1dc0e7c 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -8,7 +8,9 @@ * * Implementation of the floppy drive emulation. * - * Version: @(#)fdd.c 1.0.8 2018/04/10 + * TODO: Implement the ENABLE_FDD_LOG stuff. + * + * Version: @(#)fdd.c 1.0.10 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,8 +48,8 @@ #include "../rom.h" #include "../config.h" #include "../timer.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "fdd.h" #include "fdd_86f.h" #include "fdd_fdi.h" @@ -480,7 +482,7 @@ no_load: drive_empty[drive] = 1; fdd_set_head(drive, 0); memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); - ui_sb_update_icon_state(drive, 1); + ui_sb_icon_state(drive, 1); return 0; } @@ -511,7 +513,7 @@ void fdd_close(int drive) d86f_destroy(drive); - ui_sb_update_icon_state(drive, 1); + ui_sb_icon_state(drive, 1); } int fdd_notfound = 0; diff --git a/src/floppy/fdd_86f.c b/src/floppy/fdd_86f.c index 34c1f01..e016151 100644 --- a/src/floppy/fdd_86f.c +++ b/src/floppy/fdd_86f.c @@ -10,7 +10,7 @@ * data in the form of FM/MFM-encoded transitions) which also * forms the core of the emulator's floppy disk emulation. * - * Version: @(#)fdd_86f.c 1.0.7 2018/04/10 + * Version: @(#)fdd_86f.c 1.0.8 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,8 +49,8 @@ #include "../dma.h" #include "../nvr.h" #include "../random.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "fdd.h" #include "fdc.h" #include "fdd_86f.h" diff --git a/src/floppy/lzf/lzf_c.c b/src/floppy/lzf/lzf_c.c index cfeb424..17df2f6 100644 --- a/src/floppy/lzf/lzf_c.c +++ b/src/floppy/lzf/lzf_c.c @@ -33,11 +33,16 @@ * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ - #include - #include "lzfP.h" +#ifndef ULTRA_FAST +# define ULTRA_FAST 0 +#endif +#ifndef VERY_FAST +# define VERY_FAST 0 +#endif + #define HSIZE (1 << (HLOG)) /* diff --git a/src/floppy/lzf/lzf_d.c b/src/floppy/lzf/lzf_d.c index 8433b8f..cab113c 100644 --- a/src/floppy/lzf/lzf_d.c +++ b/src/floppy/lzf/lzf_d.c @@ -33,7 +33,6 @@ * provisions above, a recipient may use your version of this file under * either the BSD or the GPL. */ - #include "lzfP.h" #if AVOID_ERRNO @@ -43,7 +42,8 @@ # define SET_ERRNO(n) errno = (n) #endif -#if USE_REP_MOVSB /* small win on amd, big loss on intel */ + +#ifdef USE_REP_MOVSB /* small win on amd, big loss on intel */ #if (__i386 || __amd64) && __GNUC__ >= 3 # define lzf_movsb(dst, src, len) \ asm ("rep movsb" \ diff --git a/src/i82335.c b/src/i82335.c index 8030461..c144800 100644 --- a/src/i82335.c +++ b/src/i82335.c @@ -8,7 +8,7 @@ * * Intel 82335 SX emulation, used by the Phoenix 386 clone. * - * Version: @(#)i82335.c 1.0.1 2018/02/14 + * Version: @(#)i82335.c 1.0.2 2018/04/26 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,6 +42,7 @@ #include #include "io.h" #include "mem.h" +#include "plat.h" typedef struct { @@ -54,7 +55,7 @@ static i82335_t i82335; static uint8_t -i82335_read(uint16_t addr, void *priv) +i82335_read(uint16_t addr, UNUSED(void *priv)) { // pclog("i82335_read(%04X)\n", addr); if (addr == 0x22) { @@ -70,7 +71,7 @@ i82335_read(uint16_t addr, void *priv) static void -i82335_write(uint16_t addr, uint8_t val, void *priv) +i82335_write(uint16_t addr, uint8_t val, UNUSED(void *priv)) { int mem_write = 0; int i = 0; diff --git a/src/intel.c b/src/intel.c index 5fad663..b6c3600 100644 --- a/src/intel.c +++ b/src/intel.c @@ -8,7 +8,7 @@ * * Implementation of Intel mainboards. * - * Version: @(#)intel.c 1.0.2 2018/03/27 + * Version: @(#)intel.c 1.0.3 2018/04/26 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -47,13 +47,14 @@ #include "pit.h" #include "timer.h" #include "intel.h" +#include "plat.h" static uint16_t batman_timer_latch; static int64_t batman_timer = 0; -uint8_t batman_brdconfig(uint16_t port, void *p) +uint8_t batman_brdconfig(uint16_t port, UNUSED(void *p)) { switch (port) { @@ -66,13 +67,13 @@ uint8_t batman_brdconfig(uint16_t port, void *p) } -static void batman_timer_over(void *p) +static void batman_timer_over(UNUSED(void *p)) { batman_timer = 0; } -static void batman_timer_write(uint16_t addr, uint8_t val, void *p) +static void batman_timer_write(uint16_t addr, uint8_t val, UNUSED(void *p)) { if (addr & 1) batman_timer_latch = (batman_timer_latch & 0xff) | (val << 8); @@ -82,7 +83,7 @@ static void batman_timer_write(uint16_t addr, uint8_t val, void *p) } -static uint8_t batman_timer_read(uint16_t addr, void *p) +static uint8_t batman_timer_read(uint16_t addr, UNUSED(void *p)) { uint16_t batman_timer_latch; @@ -101,7 +102,7 @@ static uint8_t batman_timer_read(uint16_t addr, void *p) } -void intel_batman_init() +void intel_batman_init(void) { io_sethandler(0x0073, 0x0001, batman_brdconfig, NULL, NULL, NULL, NULL, NULL, NULL); io_sethandler(0x0075, 0x0001, batman_brdconfig, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/src/machine/m_at_4gpv31.c b/src/machine/m_at_4gpv31.c index b8161a3..d5af118 100644 --- a/src/machine/m_at_4gpv31.c +++ b/src/machine/m_at_4gpv31.c @@ -11,7 +11,7 @@ * NOTE: The NEAT 82c206 code should be moved into a 82c206 module, * so it can be re-used by other boards. * - * Version: @(#)m_4gpv31.c 1.0.4 2018/04/26 + * Version: @(#)m_4gpv31.c 1.0.5 2018/04/27 * * Author: Fred N. van Kempen, * @@ -69,7 +69,7 @@ typedef struct { } neat_t; -#if NOT_USED +#if 0 /*NOT_USED*/ static void neat_wrems(uint32_t addr, uint8_t val, void *priv) { diff --git a/src/machine/m_at_neat.c b/src/machine/m_at_neat.c index 4c0a53b..a238cc5 100644 --- a/src/machine/m_at_neat.c +++ b/src/machine/m_at_neat.c @@ -10,7 +10,7 @@ * * This is the chipset used in the AMI 286 clone model. * - * Version: @(#)m_at_neat.c 1.0.4 2018/04/26 + * Version: @(#)m_at_neat.c 1.0.5 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -99,7 +99,7 @@ neat_read(uint16_t port, void *priv) } -#if NOT_USED +#if 0 /*NOT_USED*/ static void neat_writeems(uint32_t addr, uint8_t val) { diff --git a/src/machine/m_at_t3100e.c b/src/machine/m_at_t3100e.c index dcac8a8..87aab04 100644 --- a/src/machine/m_at_t3100e.c +++ b/src/machine/m_at_t3100e.c @@ -117,7 +117,7 @@ * bit 2 set for single-pixel LCD font * bits 0,1 for display font * - * Version: @(#)m_at_t3100e.c 1.0.6 2018/04/26 + * Version: @(#)m_at_t3100e.c 1.0.7 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -285,7 +285,7 @@ port_to_page(uint16_t addr) } -#if NOTUSED +#if 0 /*NOT_USED*/ /* Used to dump the memory mapping table, for debugging. */ static void dump_mappings(void) @@ -335,7 +335,7 @@ t3100e_map_ram(uint8_t val) int32_t upper_len; int n; -#if NOTUSED +#if 0 /*NOT_USED*/ if (t3100e_log) { pclog("OUT 0x8084, %02x [ set memory mapping :", val | 0x40); if (val & 1) pclog("ENABLE_EMS "); @@ -385,7 +385,7 @@ t3100e_map_ram(uint8_t val) t3100e_ems_out(t3100e_ems_page_reg[n], t3100e_ems.page[n], &t3100e_ems); -#if NOTUSED +#if 0 /*NOT_USED*/ dump_mappings(); #endif } @@ -399,7 +399,7 @@ t3100e_sys_in(uint16_t addr, void *p) /* The low 4 bits always seem to be 0x0C. The high 4 are a * notification sent by the keyboard controller when it detects * an [Fn] key combination */ -#if NOTUSED +#if 0 /*NOT_USED*/ if (t3100e_log) pclog("IN 0x8084\n"); #endif @@ -415,7 +415,7 @@ t3100e_sys_out(uint16_t addr, uint8_t val, void *p) switch (val & 0xE0) { case 0x00: /* Set serial port IRQs. Not implemented */ -#if NOTUSED +#if 0 /*NOT_USED*/ if (t3100e_log) pclog("OUT 0x8084, %02x [ set serial port IRQs]\n", val); #endif @@ -430,7 +430,7 @@ t3100e_sys_out(uint16_t addr, uint8_t val, void *p) break; default: /* Other options not implemented. */ -#if NOTUSED +#if 0 /*NOT_USED*/ if (t3100e_log) pclog("OUT 0x8084, %02x\n", val); #endif break; @@ -457,7 +457,7 @@ t3100e_ems_out(uint16_t addr, uint8_t val, void *p) int pg = port_to_page(addr); regs->page_exec[pg & 3] = t3100e_ems_execaddr(regs, pg, val); -#if UNUSED +#if 0 /*NOT_USED*/ if (t3100e_log) pclog("EMS: page %d %02x -> %02x [%06x]\n", pg, regs->page[pg], val, regs->page_exec[pg & 3]); #endif @@ -466,14 +466,14 @@ t3100e_ems_out(uint16_t addr, uint8_t val, void *p) /* Bit 7 set if page is enabled, reset if page is disabled */ pg &= 3; if (regs->page_exec[pg]) { -#if UNUSED +#if 0 /*NOT_USED*/ if (t3100e_log) pclog("Enabling EMS RAM at %05x\n", page_to_addr(pg)); #endif mem_mapping_enable(®s->mapping[pg]); mem_mapping_set_exec(®s->mapping[pg], ram + regs->page_exec[pg]); } else { -#if UNUSED +#if 0 /*NOT_USED*/ if (t3100e_log) pclog("Disabling EMS RAM at %05x\n", page_to_addr(pg)); #endif @@ -649,7 +649,7 @@ machine_at_t3100e_init(const machine_t *model, void *arg) /* Map the EMS page frame */ for (pg = 0; pg < 4; pg++) { -#if UNUSED +#if 0 /*NOT_USED*/ if (t3100e_log) pclog("Adding memory map at %x for page %d\n", page_to_addr(pg), pg); #endif mem_mapping_add(&t3100e_ems.mapping[pg], diff --git a/src/machine/m_europc.c b/src/machine/m_europc.c index 816cf7f..97672e8 100644 --- a/src/machine/m_europc.c +++ b/src/machine/m_europc.c @@ -66,7 +66,7 @@ * bit 1: b8000 memory available * 0000:046a: 00 jim 250 01 jim 350 * - * Version: @(#)m_europc.c 1.0.11 2018/04/26 + * Version: @(#)m_europc.c 1.0.12 2018/04/27 * * Author: Fred N. van Kempen, * @@ -225,7 +225,7 @@ rtc_time_get(uint8_t *regs, struct tm *tm) tm->tm_mday = RTC_DCB(regs[MRTC_DAYS]); tm->tm_mon = (RTC_DCB(regs[MRTC_MONTHS]) - 1); tm->tm_year = RTC_DCB(regs[MRTC_YEARS]); -#if USE_Y2K +#if 0 /*USE_Y2K*/ tm->tm_year += (RTC_DCB(regs[MRTC_CENTURY]) * 100) - 1900; #endif } @@ -243,7 +243,7 @@ rtc_time_set(uint8_t *regs, struct tm *tm) regs[MRTC_DAYS] = RTC_BCD(tm->tm_mday); regs[MRTC_MONTHS] = RTC_BCD(tm->tm_mon + 1); regs[MRTC_YEARS] = RTC_BCD(tm->tm_year % 100); -#if USE_Y2K +#if 0 /*USE_Y2K*/ regs[MRTC_CENTURY] = RTC_BCD((tm->tm_year+1900) / 100); #endif } diff --git a/src/machine/m_ps1_hdc.c b/src/machine/m_ps1_hdc.c index 89bb26c..7b420e4 100644 --- a/src/machine/m_ps1_hdc.c +++ b/src/machine/m_ps1_hdc.c @@ -43,7 +43,7 @@ * Type table with the main code, so the user can only select * items from that list... * - * Version: @(#)m_ps1_hdc.c 1.0.5 2018/04/25 + * Version: @(#)m_ps1_hdc.c 1.0.6 2018/04/28 * * Author: Fred N. van Kempen, * @@ -98,8 +98,8 @@ #include "../timer.h" #include "../disk/hdc.h" #include "../disk/hdd.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "machine.h" @@ -701,7 +701,7 @@ do_format(hdc_t *dev, drive_t *drive, ccb_t *ccb) dev->buf_len++; /* must be even */ /* Enable for PIO or DMA, as needed. */ -#if NOT_USED +#if 0 /*NOT_USED*/ if (dev->ctrl & ACR_DMA_EN) dev->callback = HDC_TIME; else @@ -748,7 +748,7 @@ do_fmt: #endif /* Activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 1); /* Seek to cylinder. */ if (do_seek(dev, drive, start_cyl)) { @@ -787,7 +787,7 @@ do_fmt: } /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); /* This saves us a LOT of code. */ dev->state = STATE_FINIT; @@ -797,7 +797,7 @@ do_fmt: /* If we errored out, go back idle. */ if (intr) { /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); do_finish(dev); } @@ -872,7 +872,7 @@ hdc_callback(void *priv) case STATE_SEND: /* Activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 1); do_send: #ifdef ENABLE_HDC_LOG @@ -885,7 +885,7 @@ do_send: /* Get address of sector to load. */ if (get_sector(dev, drive, &addr)) { /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); do_finish(dev); return; } @@ -928,7 +928,7 @@ do_send: hdc_log("HDC: CMD_READ_SECTORS out of data (idx=%d, len=%d)!\n", dev->buf_idx, dev->buf_len); /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); dev->intstat |= ISR_EQUIP_CHECK; dev->ssb.need_reset = 1; @@ -951,7 +951,7 @@ do_send: drive->id); #endif /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); if (! (dev->ctrl & ACR_DMA_EN)) dev->status &= ~(ASR_DATA_REQ|ASR_DIR); @@ -1038,7 +1038,7 @@ do_send: case STATE_RECV: /* Activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 1); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 1); do_recv: #ifdef ENABLE_HDC_LOG hdc_log("HDC write_%s(%d: %d,%d,%d) cnt=%d\n", @@ -1074,7 +1074,7 @@ do_recv: hdc_log("HDC: CMD_WRITE_SECTORS out of data (idx=%d, len=%d)!\n", dev->buf_idx, dev->buf_len); /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); dev->intstat |= ISR_EQUIP_CHECK; dev->ssb.need_reset = 1; @@ -1099,7 +1099,7 @@ do_recv: /* Get address of sector to write. */ if (get_sector(dev, drive, &addr)) { /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); do_finish(dev); return; @@ -1117,7 +1117,7 @@ do_recv: drive->id); #endif /* De-activate the status icon. */ - ui_sb_update_icon(SB_HDD|HDD_BUS_IDE, 0); + ui_sb_icon_update(SB_HDD|HDD_BUS_IDE, 0); if (! (dev->ctrl & ACR_DMA_EN)) dev->status &= ~ASR_DATA_REQ; diff --git a/src/machine/m_xt_laserxt.c b/src/machine/m_xt_laserxt.c index b5dee94..a1a382d 100644 --- a/src/machine/m_xt_laserxt.c +++ b/src/machine/m_xt_laserxt.c @@ -8,7 +8,7 @@ * * Emulation of the Laser XT series of machines. * - * Version: @(#)m_xt_laserxt.c 1.0.4 2018/03/27 + * Version: @(#)m_xt_laserxt.c 1.0.5 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -48,6 +48,9 @@ #include "machine.h" +#if defined(DEV_BRANCH) && defined(USE_LASERXT) + + static int ems_page[4]; static int ems_control[4]; static mem_mapping_t ems_mapping[4]; @@ -198,3 +201,7 @@ machine_xt_laserxt_init(const machine_t *model, void *arg) laserxt_init(); } + + + +#endif /*defined(DEV_BRANCH) && defined(USE_LASERXT)*/ diff --git a/src/machine/m_xt_t1000.c b/src/machine/m_xt_t1000.c index 2fbf8c3..032bbe4 100644 --- a/src/machine/m_xt_t1000.c +++ b/src/machine/m_xt_t1000.c @@ -50,7 +50,7 @@ * * FIXME: The ROM drive should be re-done using the "option file". * - * Version: @(#)m_xt_t1000.c 1.0.11 2018/04/26 + * Version: @(#)m_xt_t1000.c 1.0.12 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -642,7 +642,7 @@ cfgsys_save(t1000_t *dev) } -#if NOTUSED +#if 0 /*NOT_USED*/ /* All RAM beyond 512K is non-volatile */ static void emsboard_load(t1000_t *dev) diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c index 62f9e35..338cc3d 100644 --- a/src/network/net_ne2000.c +++ b/src/network/net_ne2000.c @@ -12,7 +12,7 @@ * - Realtek RTL8019AS (ISA 16-bit, PnP); * - Realtek RTL8029AS (PCI). * - * Version: @(#)net_ne2000.c 1.0.4 2018/03/31 + * Version: @(#)net_ne2000.c 1.0.6 2018/04/28 * * Based on @(#)ne2k.cc v1.56.2.1 2004/02/02 22:37:22 cbothamy * @@ -61,8 +61,8 @@ #include "../pic.h" #include "../random.h" #include "../device.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "network.h" #include "net_ne2000.h" #include "bswap.h" @@ -2195,7 +2195,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len) int endbytes; //FIXME: move to upper layer - ui_sb_update_icon(SB_NETWORK, 1); + ui_sb_icon_update(SB_NETWORK, 1); if (io_len != 60) nelog(2, "%s: rx_frame with length %d\n", dev->name, io_len); @@ -2227,7 +2227,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len) nelog(1, "%s: no space\n", dev->name); //FIXME: move to upper layer - ui_sb_update_icon(SB_NETWORK, 0); + ui_sb_icon_update(SB_NETWORK, 0); return; } @@ -2235,7 +2235,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len) nelog(1, "%s: rejected small packet, length %d\n", dev->name, io_len); //FIXME: move to upper layer - ui_sb_update_icon(SB_NETWORK, 0); + ui_sb_icon_update(SB_NETWORK, 0); return; } @@ -2258,7 +2258,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len) nelog(2, "%s: RX BC disabled\n", dev->name); //FIXME: move to upper layer - ui_sb_update_icon(SB_NETWORK, 0); + ui_sb_icon_update(SB_NETWORK, 0); return; } } @@ -2272,7 +2272,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len) #endif //FIXME: move to upper layer - ui_sb_update_icon(SB_NETWORK, 0); + ui_sb_icon_update(SB_NETWORK, 0); return; } @@ -2282,7 +2282,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len) nelog(2, "%s: RX MC not listed\n", dev->name); //FIXME: move to upper layer - ui_sb_update_icon(SB_NETWORK, 0); + ui_sb_icon_update(SB_NETWORK, 0); return; } } @@ -2335,7 +2335,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len) nic_interrupt(dev, 1); //FIXME: move to upper layer - ui_sb_update_icon(SB_NETWORK, 0); + ui_sb_icon_update(SB_NETWORK, 0); } diff --git a/src/network/network.c b/src/network/network.c index 32a26e6..cf563c5 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -12,7 +12,7 @@ * it should be malloc'ed and then linked to the NETCARD def. * Will be done later. * - * Version: @(#)network.c 1.0.5 2018/04/10 + * Version: @(#)network.c 1.0.7 2018/04/28 * * Author: Fred N. van Kempen, * @@ -58,8 +58,8 @@ #endif #include "../emu.h" #include "../device.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "network.h" #include "net_ne2000.h" @@ -329,7 +329,7 @@ network_reset(void) pclog("NETWORK: reset (type=%d, card=%d)\n", network_type, network_card); #endif - ui_sb_update_icon(SB_NETWORK, 0); + ui_sb_icon_update(SB_NETWORK, 0); /* Just in case.. */ network_close(); @@ -381,7 +381,7 @@ network_reset(void) void network_tx(uint8_t *bufp, int len) { - ui_sb_update_icon(SB_NETWORK, 1); + ui_sb_icon_update(SB_NETWORK, 1); #ifdef WALTJE { @@ -401,7 +401,7 @@ network_tx(uint8_t *bufp, int len) break; } - ui_sb_update_icon(SB_NETWORK, 0); + ui_sb_icon_update(SB_NETWORK, 0); } diff --git a/src/network/slirp/config-host.h b/src/network/slirp/config-host.h deleted file mode 100644 index 2983fc7..0000000 --- a/src/network/slirp/config-host.h +++ /dev/null @@ -1,9 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#define CONFIG_QEMU_SHAREDIR "/c/Program Files/Qemu" -#define HOST_I386 1 -#define HOST_LONG_BITS 32 -#define CONFIG_WIN32 1 -#define CONFIG_GDBSTUB 1 -#define CONFIG_SLIRP 1 -#define QEMU_VERSION "0.9.0" -#define CONFIG_UNAME_RELEASE "" diff --git a/src/network/slirp/config.h b/src/network/slirp/config.h deleted file mode 100644 index d9043ae..0000000 --- a/src/network/slirp/config.h +++ /dev/null @@ -1,9 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#include "config-host.h" -#define CONFIG_QEMU_PREFIX "/usr/gnemul/qemu-i386" -#define TARGET_ARCH "i386" -#define TARGET_I386 1 -#define USE_KQEMU 1 -#define CONFIG_SOFTMMU 1 -#define CONFIG_SDL 1 -#define HAVE_STRDUP 1 diff --git a/src/network/slirp/debug.c b/src/network/slirp/debug.c index eef2c7d..503727a 100644 --- a/src/network/slirp/debug.c +++ b/src/network/slirp/debug.c @@ -41,7 +41,7 @@ debug_init(file, dbg) dfd = fopen(file,"w"); if (dfd != NULL) { #if 1 - fprintf(dfd,"Slirp %s - Debugging Started.\n", SLIRP_VERSION); + fprintf(dfd,"Slirp - Debugging Started.\n"); #endif fprintf(dfd,"Debugging Started level %i.\r\n",dbg); fflush(dfd); diff --git a/src/network/slirp/ip_icmp.c b/src/network/slirp/ip_icmp.c index 7bd7878..2aead29 100644 --- a/src/network/slirp/ip_icmp.c +++ b/src/network/slirp/ip_icmp.c @@ -217,7 +217,7 @@ icmp_error(struct SLIRPmbuf *msrc, u_char type, u_char code, int minsize, char * /* check msrc */ if(!msrc) goto end_error; ip = mtod(msrc, struct ip *); -#if SLIRP_DEBUG +#ifdef SLIRP_DEBUG { char bufa[20], bufb[20]; strcpy(bufa, inet_ntoa(ip->ip_src)); strcpy(bufb, inet_ntoa(ip->ip_dst)); @@ -274,7 +274,7 @@ icmp_error(struct SLIRPmbuf *msrc, u_char type, u_char code, int minsize, char * HTONS(icp->icmp_ip.ip_id); HTONS(icp->icmp_ip.ip_off); -#if SLIRP_DEBUG +#ifdef SLIRP_DEBUG if(message) { /* DEBUG : append message to ICMP packet */ int message_len; char *cpnt; diff --git a/src/network/slirp/slirp.h b/src/network/slirp/slirp.h index b78dc93..36f8f66 100644 --- a/src/network/slirp/slirp.h +++ b/src/network/slirp/slirp.h @@ -1,75 +1,189 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#define SLIRP_VERSION "Cockatrice special" -#define CONFIG_QEMU +#define HOST_I386 1 +#define HOST_LONG_BITS 32 +#define CONFIG_WIN32 1 +#define CONFIG_SLIRP 1 +#define CONFIG_UNAME_RELEASE "" +#define HAVE_STRDUP 1 -#ifndef CONFIG_QEMU -#include "version.h" +/* + * User definable configuration options + */ +/* Undefine if you don't want talk emulation */ +#undef EMULATE_TALK + +/* Define if you want the connection to be probed */ +/* XXX Not working yet, so ignore this for now */ +#undef PROBE_CONN + +/* Define to 1 if you want KEEPALIVE timers */ +#define DO_KEEPALIVE 0 + +/* Define to MAX interfaces you expect to use at once */ +/* MAX_INTERFACES determines the max. TOTAL number of interfaces (SLIP and PPP) */ +/* MAX_PPP_INTERFACES determines max. number of PPP interfaces */ +#define MAX_INTERFACES 1 +#define MAX_PPP_INTERFACES 1 + +/* Define if you want slirp's socket in /tmp */ +/* XXXXXX Do this in ./configure */ +#undef USE_TMPSOCKET + +/* Define if you want slirp to use cfsetXspeed() on the terminal */ +#undef DO_CFSETSPEED + +/* Define this if you want slirp to write to the tty as fast as it can */ +/* This should only be set if you are using load-balancing, slirp does a */ +/* pretty good job on single modems already, and seting this will make */ +/* interactive sessions less responsive */ +/* XXXXX Talk about having fast modem as unit 0 */ +#undef FULL_BOLT + +/* + * Define if you want slirp to use less CPU + * You will notice a small lag in interactive sessions, but it's not that bad + * Things like Netscape/ftp/etc. are completely unaffected + * This is mainly for sysadmins who have many slirp users + */ +#undef USE_LOWCPU + +/* Define this if your compiler doesn't like prototypes */ +#ifndef __STDC__ +#define NO_PROTOTYPES #endif -#include "config.h" -#include "slirp_config.h" + +/*********************************************************/ +/* + * Autoconf defined configuration options + * You shouldn't need to touch any of these + */ + +/* Ignore this */ +#undef DUMMY_PPP + +/* XXX: Define according to how time.h should be included */ +#undef TIME_WITH_SYS_TIME +#define TIME_WITH_SYS_TIME 0 +#undef HAVE_SYS_TIME_H + +/* Define if your sprintf returns char * instead of int */ +#undef BAD_SPRINTF + +/* Define if you have readv */ +#undef HAVE_READV + +/* Define if iovec needs to be declared */ +#undef DECLARE_IOVEC +#ifdef _WIN32 +#define DECLARE_IOVEC +#endif + +/* Define if a declaration of sprintf/fprintf is needed */ +#undef DECLARE_SPRINTF + +/* Define if you have sys/stropts.h */ +#undef HAVE_SYS_STROPTS_H + +/* Define if your compiler doesn't like prototypes */ +#undef NO_PROTOTYPES + +/* Define if you don't have u_int32_t etc. typedef'd */ +#undef NEED_TYPEDEFS +#ifdef __sun__ +#define NEED_TYPEDEFS +#endif + +/* Define to sizeof(char *) */ +#ifdef SIZEOF_VOID_P +# define SIZEOF_CHAR_P SIZEOF_VOID_P +#else +# define SIZEOF_CHAR_P 8 /*FIXME: sizeof() does not work in cpp!*/ +#endif + +#undef HAVE_RANDOM /* Define if you have random() */ +#undef HAVE_SRANDOM /* Define if you have srandom() */ +#undef HAVE_SETENV /* Define if you have setenv */ +#undef HAVE_INDEX /* Define if you have index() */ +#undef HAVE_BCMP /* Define if you have bcmp() */ +#undef HAVE_DRAND48 /* Define if you have drand48 */ +#define HAVE_MEMMOVE /* Define if you have memmove */ +#undef HAVE_GETHOSTID /* Define if you have gethostid */ + +/* Define if you DON'T have unix-domain sockets */ +#ifdef _WIN32 +# define NO_UNIX_SOCKETS +#else +# undef NO_UNIX_SOCKETS +#endif + +#undef GETTIMEOFDAY_ONE_ARG /* Define if gettimeofday only takes one argument */ + +#undef HAVE_REVOKE /* Define if you have revoke() */ + +#undef HAVE_GRANTPTi /* Define if you have the sysv method of opening pty's (/dev/ptmx, etc.) */ + +#undef HAVE_FCHMOD /* Define if you have fchmod */ + +#undef HAVE_SYS_TYPES32_H /* Define if you have */ #ifdef _WIN32 -#ifdef __GNUC__ /* MINGW? */ -# include -typedef uint8_t u_int8_t; -typedef uint16_t u_int16_t; -typedef uint32_t u_int32_t; -typedef uint64_t u_int64_t; -typedef char *SLIRPcaddr_t; -typedef int socklen_t; -typedef unsigned long ioctlsockopt_t; -#else -typedef unsigned char u_int8_t; -typedef char int8_t; +# ifdef __GNUC__ /* MINGW? */ +# include +typedef uint8_t u_int8_t; +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; +typedef char *SLIRPcaddr_t; +typedef int socklen_t; +typedef unsigned long ioctlsockopt_t; +# else +typedef unsigned char u_int8_t; +typedef char int8_t; typedef unsigned char uint8_t; typedef unsigned short u_int16_t; typedef unsigned short uint16_t; -typedef short int16_t; +typedef short int16_t; typedef unsigned int u_int32_t; typedef unsigned int uint32_t; -typedef int int32_t; +typedef int int32_t; typedef unsigned __int64 u_int64_t; typedef char *SLIRPcaddr_t; typedef int socklen_t; typedef unsigned long ioctlsockopt_t; - -#endif - -# include /* needs to be on top otherwise, it'll pull in winsock1 */ +# endif +# include /* on top otherwise, it'll pull in winsock1 */ # include - # include # include -# define USE_FIONBIO 1 -#ifndef EWOULDBLOCK -# define EWOULDBLOCK WSAEWOULDBLOCK -#endif -#ifndef EINPROGRESS -# define EINPROGRESS WSAEINPROGRESS -#endif -#ifndef ENOTCONN -# define ENOTCONN WSAENOTCONN -#endif -#ifndef EHOSTUNREACH -# define EHOSTUNREACH WSAEHOSTUNREACH -#endif -#ifndef ENETUNREACH -# define ENETUNREACH WSAENETUNREACH -#endif -#ifndef ECONNREFUSED -# define ECONNREFUSED WSAECONNREFUSED -#endif +# define USE_FIONBIO 1 +# ifndef EWOULDBLOCK +# define EWOULDBLOCK WSAEWOULDBLOCK +# endif +# ifndef EINPROGRESS +# define EINPROGRESS WSAEINPROGRESS +# endif +# ifndef ENOTCONN +# define ENOTCONN WSAENOTCONN +# endif +# ifndef EHOSTUNREACH +# define EHOSTUNREACH WSAEHOSTUNREACH +# endif +# ifndef ENETUNREACH +# define ENETUNREACH WSAENETUNREACH +# endif +# ifndef ECONNREFUSED +# define ECONNREFUSED WSAECONNREFUSED +# endif -/* Basilisk II Router defines those */ # define udp_read_completion slirp_udp_read_completion -# define write_udp slirp_write_udp -# define init_udp slirp_init_udp -# define final_udp slirp_final_udp +# define write_udp slirp_write_udp +# define init_udp slirp_init_udp +# define final_udp slirp_final_udp #else # include # define HAVE_STDINT_H @@ -77,15 +191,15 @@ typedef unsigned long ioctlsockopt_t; # define HAVE_STRING_H # define HAVE_UNISTD_H # define HAVE_INET_ATON -typedef uint8_t u_int8_t; -typedef uint16_t u_int16_t; -typedef uint32_t u_int32_t; -typedef uint64_t u_int64_t; -typedef char *SLIRPcaddr_t; -typedef int ioctlsockopt_t; -# define ioctlsocket ioctl -# define closesocket(s) close(s) -# define O_BINARY 0 +typedef uint8_t u_int8_t; +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; +typedef char *SLIRPcaddr_t; +typedef int ioctlsockopt_t; +# define ioctlsocket ioctl +# define closesocket(s) close(s) +# define O_BINARY 0 #endif #include @@ -95,11 +209,10 @@ typedef int ioctlsockopt_t; #ifdef HAVE_STDINT_H # include #endif - -#ifndef _MSC_VER -#include +#ifdef _MSC_VER +# include #else -#include +# include #endif #ifdef NEED_TYPEDEFS @@ -139,23 +252,21 @@ typedef u_int32_t uint32; #ifdef HAVE_UNISTD_H # include #endif - #ifdef HAVE_STDLIB_H # include #endif - #include #include #ifndef HAVE_MEMMOVE -#define memmove(x, y, z) bcopy(y, x, z) +# define memmove(x, y, z) bcopy(y, x, z) #endif -#if TIME_WITH_SYS_TIME +#ifdef TIME_WITH_SYS_TIME # include # include #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include # else # include @@ -165,11 +276,11 @@ typedef u_int32_t uint32; #ifdef HAVE_STRING_H # include #else -#ifndef _MSC_VER -# include -#else -#include -#endif +# ifndef _MSC_VER +# include +# else +# include +# endif #endif #ifndef _WIN32 @@ -177,20 +288,20 @@ typedef u_int32_t uint32; #endif #ifndef _P -#ifndef NO_PROTOTYPES +# ifndef NO_PROTOTYPES # define _P(x) x -#else +# else # define _P(x) () -#endif +# endif #endif #ifndef _WIN32 -#include -#include +# include +# include #endif #ifdef GETTIMEOFDAY_ONE_ARG -#define gettimeofday(x, y) gettimeofday(x) +# define gettimeofday(x, y) gettimeofday(x) #endif /* Systems lacking strdup() definition in . */ @@ -236,10 +347,6 @@ int inet_aton _P((const char *cp, struct in_addr *ia)); # include #endif -#ifdef USE_PPP -#include -#endif - #ifdef __STDC__ #include #else @@ -250,7 +357,13 @@ int inet_aton _P((const char *cp, struct in_addr *ia)); /* Avoid conflicting with the libc insque() and remque(), which have different prototypes. */ +#ifdef insque +# undef insque +#endif #define insque slirp_insque +#ifdef remque +# undef remque +#endif #define remque slirp_remque #ifdef HAVE_SYS_STROPTS_H @@ -289,10 +402,6 @@ int inet_aton _P((const char *cp, struct in_addr *ia)); #include "main.h" #include "misc.h" #include "ctl.h" -#ifdef USE_PPP -#include "ppp/pppd.h" -#include "ppp/ppp.h" -#endif #include "bootp.h" #include "tftp.h" diff --git a/src/network/slirp/slirp_config.h b/src/network/slirp/slirp_config.h index e583dcc..7d775a0 100644 --- a/src/network/slirp/slirp_config.h +++ b/src/network/slirp/slirp_config.h @@ -87,7 +87,11 @@ #endif /* Define to sizeof(char *) */ -#define SIZEOF_CHAR_P SIZEOF_VOID_P +#ifdef SIZEOF_VOID_P +# define SIZEOF_CHAR_P SIZEOF_VOID_P +#else +# define SIZEOF_CHAR_P 4 /*FIXME: sizeof() does not work in cpp!*/ +#endif /* Define if you have random() */ #undef HAVE_RANDOM diff --git a/src/pc.c b/src/pc.c index 770f257..7f29fa5 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.29 2018/04/26 + * Version: @(#)pc.c 1.0.30 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -85,7 +85,7 @@ #include "sound/sound.h" #include "sound/snd_speaker.h" #include "video/video.h" -#include "ui.h" +#include "ui/ui.h" #include "plat.h" @@ -120,7 +120,9 @@ int vid_api = 0, /* (C) video renderer */ scale = 0, /* (C) screen scale factor */ enable_overscan = 0, /* (C) video */ force_43 = 0, /* (C) video */ - video_card = 0, /* (C) graphics/video card */ + rctrl_is_lalt, /* (C) set R-CTRL as L-ALT */ + update_icons = 1; /* (C) update statbar icons */ +int video_card = 0, /* (C) graphics/video card */ video_speed = 0, /* (C) video */ voodoo_enabled = 0; /* (C) video option */ int mouse_type = 0; /* (C) selected mouse type */ @@ -130,8 +132,6 @@ int game_enabled = 0, /* (C) enable game port */ parallel_enabled[] = {0,0,0}, /* (C) enable LPT ports */ parallel_device[] = {0,0,0}, /* (C) set up LPT devices */ bugger_enabled = 0; /* (C) enable ISAbugger */ -int rctrl_is_lalt; /* (C) set R-CTRL as L-ALT */ -int update_icons; /* (C) enable icons updates */ #ifdef WALTJE int romdos_enabled = 0; /* (C) enable ROM DOS */ #endif @@ -858,7 +858,7 @@ pc_reset_hard_init(void) game_update_joystick_type(); if (config_changed) { - ui_sb_update_panes(); + ui_sb_update(); config_save(); @@ -995,7 +995,7 @@ pc_thread(void *param) while (! *quitp) { /* Update the Stat(u)s window with the current info. */ if (status_update_needed) { - ui_status_update(); + dlg_status_update(); status_update_needed = 0; } diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index 80871c1..9cdeff3 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -8,7 +8,7 @@ * * Emulation of SCSI fixed and removable disks. * - * Version: @(#)scsi_disk.c 1.0.7 2018/04/23 + * Version: @(#)scsi_disk.c 1.0.9 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,8 +51,8 @@ #include "../disk/hdd.h" #include "../disk/hdc.h" #include "../disk/hdc_ide.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "scsi.h" #include "scsi_disk.h" @@ -991,7 +991,7 @@ scsi_hd_command(uint8_t id, uint8_t *cdb) if ((!shdc[id].sector_len) || (*BufLen == 0)) { scsi_hd_set_phase(id, SCSI_PHASE_STATUS); - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); scsi_hd_log("SCSI HD %i: All done - callback set\n", id); shdc[id].packet_status = CDROM_PHASE_COMPLETE; shdc[id].callback = 20 * SCSI_TIME; @@ -1014,7 +1014,7 @@ scsi_hd_command(uint8_t id, uint8_t *cdb) scsi_hd_data_command_finish(id, alloc_length, alloc_length, alloc_length, 0); } shdc[id].all_blocks_total = shdc[id].block_total; - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 1); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 1); return; case GPCMD_VERIFY_6: @@ -1064,7 +1064,7 @@ scsi_hd_command(uint8_t id, uint8_t *cdb) if ((!shdc[id].sector_len) || (*BufLen == 0)) { scsi_hd_set_phase(id, SCSI_PHASE_STATUS); - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); scsi_hd_log("SCSI HD %i: All done - callback set\n", id); shdc[id].packet_status = CDROM_PHASE_COMPLETE; shdc[id].callback = 20 * SCSI_TIME; @@ -1087,7 +1087,7 @@ scsi_hd_command(uint8_t id, uint8_t *cdb) scsi_hd_data_command_finish(id, alloc_length, alloc_length, alloc_length, 1); } shdc[id].all_blocks_total = shdc[id].block_total; - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 1); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 1); return; case GPCMD_WRITE_SAME_10: @@ -1112,7 +1112,7 @@ scsi_hd_command(uint8_t id, uint8_t *cdb) if ((!shdc[id].sector_len) || (*BufLen == 0)) { scsi_hd_set_phase(id, SCSI_PHASE_STATUS); - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); scsi_hd_log("SCSI HD %i: All done - callback set\n", id); shdc[id].packet_status = CDROM_PHASE_COMPLETE; shdc[id].callback = 20 * SCSI_TIME; @@ -1135,7 +1135,7 @@ scsi_hd_command(uint8_t id, uint8_t *cdb) scsi_hd_data_command_finish(id, alloc_length, alloc_length, alloc_length, 1); } shdc[id].all_blocks_total = shdc[id].block_total; - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 1); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 1); return; case GPCMD_MODE_SENSE_6: @@ -1399,7 +1399,7 @@ scsi_hd_phase_data_in(uint8_t id) if (!*BufLen) { scsi_hd_log("scsi_hd_phase_data_in(): Buffer length is 0\n"); scsi_hd_set_phase(id, SCSI_PHASE_STATUS); - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); return; } @@ -1442,7 +1442,7 @@ scsi_hd_phase_data_in(uint8_t id) } scsi_hd_set_phase(id, SCSI_PHASE_STATUS); - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); } @@ -1463,7 +1463,7 @@ scsi_hd_phase_data_out(uint8_t id) if (!*BufLen) { scsi_hd_set_phase(id, SCSI_PHASE_STATUS); - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); return; } @@ -1574,7 +1574,7 @@ scsi_hd_phase_data_out(uint8_t id) } scsi_hd_set_phase(id, SCSI_PHASE_STATUS); - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); } @@ -1594,7 +1594,7 @@ scsi_hd_callback(uint8_t id) shdc[id].status = READY_STAT; shdc[id].phase = 3; shdc[id].packet_status = 0xFF; - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); return; case CDROM_PHASE_DATA_OUT: scsi_hd_log("SCSI HD %i: PHASE_DATA_OUT\n", id); @@ -1607,7 +1607,7 @@ scsi_hd_callback(uint8_t id) shdc[id].packet_status = CDROM_PHASE_COMPLETE; shdc[id].status = READY_STAT; shdc[id].phase = 3; - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); return; case CDROM_PHASE_DATA_IN: scsi_hd_log("SCSI HD %i: PHASE_DATA_IN\n", id); @@ -1620,7 +1620,7 @@ scsi_hd_callback(uint8_t id) shdc[id].packet_status = CDROM_PHASE_COMPLETE; shdc[id].status = READY_STAT; shdc[id].phase = 3; - ui_sb_update_icon((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); + ui_sb_icon_update((hdd[id].bus == HDD_BUS_SCSI_REMOVABLE) ? (SB_RDISK | id) : (SB_HDD | HDD_BUS_SCSI), 0); return; case CDROM_PHASE_ERROR: scsi_hd_log("SCSI HD %i: PHASE_ERROR\n", id); diff --git a/src/scsi/scsi_ncr53c810.c b/src/scsi/scsi_ncr53c810.c index 073ebc0..8ed3bcd 100644 --- a/src/scsi/scsi_ncr53c810.c +++ b/src/scsi/scsi_ncr53c810.c @@ -10,7 +10,7 @@ * NCR and later Symbios and LSI. This controller was designed * for the PCI bus. * - * Version: @(#)scsi_ncr53c810.c 1.0.7 2018/04/02 + * Version: @(#)scsi_ncr53c810.c 1.0.8 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -310,7 +310,7 @@ sextract32(uint32_t value, int start, int length) } -#if NOTUSED +#if 0 /*NOT_USED*/ static __inline uint32_t deposit32(uint32_t value, int start, int length, uint32_t fieldval) diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index 97320cf..d30470b 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -12,7 +12,7 @@ * * These controllers were designed for various buses. * - * Version: @(#)scsi_x54x.c 1.0.9 2018/04/02 + * Version: @(#)scsi_x54x.c 1.0.10 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,9 +46,7 @@ #include #include #include -#define HAVE_STDARG_H #include "../emu.h" -#include "../cpu/cpu.h" // for debug, temporary #include "../io.h" #include "../dma.h" #include "../pic.h" @@ -69,32 +67,10 @@ #define X54X_RESET_DURATION_US UINT64_C(50000) -#ifdef ENABLE_SCSI_X54X_LOG -int scsi_x54x_do_log = ENABLE_SCSI_X54X_LOG; -#endif - - static void x54x_cmd_callback(void *priv); static x54x_t *x54x_dev; -static void -x54x_log(const char *fmt, ...) -{ -#ifdef ENABLE_SCSI_X54X_LOG - va_list ap; - - if (scsi_x54x_do_log) { -// for debug, temporary -pclog("In %s mode: ",(msw&1)?((eflags&VM_FLAG)?"V86":"protected"):"real"); - va_start(ap, fmt); - pclog_ex(fmt, ap); - va_end(ap); - } -#endif -} - - static void x54x_irq(x54x_t *dev, int set) { @@ -107,7 +83,7 @@ x54x_irq(x54x_t *dev, int set) irq = dev->Irq; if (dev->bus & DEVICE_PCI) { - x54x_log("PCI IRQ: %02X, PCI_INTA\n", dev->pci_slot); + scsi_dev_log("PCI IRQ: %02X, PCI_INTA\n", dev->pci_slot); if (set) { pci_set_irq(dev->pci_slot, PCI_INTA); } else { @@ -141,12 +117,12 @@ raise_irq(x54x_t *dev, int suppress, uint8_t Interrupt) } } else if (Interrupt & INTR_HACC) { if (dev->Interrupt == 0 || dev->Interrupt == (INTR_ANY | INTR_HACC)) { - x54x_log("%s: RaiseInterrupt(): Interrupt=%02X\n", + scsi_dev_log("%s: RaiseInterrupt(): Interrupt=%02X\n", dev->name, dev->Interrupt); } dev->Interrupt |= Interrupt; } else { - x54x_log("%s: RaiseInterrupt(): Invalid interrupt state!\n", dev->name); + scsi_dev_log("%s: RaiseInterrupt(): Invalid interrupt state!\n", dev->name); } dev->Interrupt |= INTR_ANY; @@ -160,11 +136,11 @@ static void clear_irq(x54x_t *dev) { dev->Interrupt = 0; - x54x_log("%s: lowering IRQ %i (stat 0x%02x)\n", + scsi_dev_log("%s: lowering IRQ %i (stat 0x%02x)\n", dev->name, dev->Irq, dev->Interrupt); x54x_irq(dev, 0); if (dev->PendingInterrupt) { - x54x_log("%s: Raising Interrupt 0x%02X (Pending)\n", + scsi_dev_log("%s: Raising Interrupt 0x%02X (Pending)\n", dev->name, dev->Interrupt); if (dev->MailboxOutInterrupts || !(dev->Interrupt & INTR_MBOA)) { raise_irq(dev, 0, dev->PendingInterrupt); @@ -269,7 +245,7 @@ x54x_bios_command_08(uint8_t id, uint8_t lun, uint8_t *buffer) buffer[i] = rcbuf[i]; for (i=4; i<6; i++) buffer[i] = rcbuf[(i + 2) ^ 1]; - x54x_log("BIOS Command 0x08: %02X %02X %02X %02X %02X %02X\n", + scsi_dev_log("BIOS Command 0x08: %02X %02X %02X %02X %02X %02X\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); return(0); @@ -293,7 +269,7 @@ x54x_bios_command_15(uint8_t id, uint8_t lun, uint8_t *buffer) scsi_device_type_data(id, lun, &(buffer[4]), &(buffer[5])); - x54x_log("BIOS Command 0x15: %02X %02X %02X %02X %02X %02X\n", + scsi_dev_log("BIOS Command 0x15: %02X %02X %02X %02X %02X %02X\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); return(sc); @@ -316,10 +292,10 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) else lba = (cmd->u.chs.cyl << 9) + (cmd->u.chs.head << 5) + cmd->u.chs.sec; - x54x_log("BIOS Command = 0x%02X\n", cmd->command); + scsi_dev_log("BIOS Command = 0x%02X\n", cmd->command); if ((cmd->id > max_id) || (cmd->lun > 7)) { - x54x_log("BIOS Target ID %i or LUN %i are above maximum\n", + scsi_dev_log("BIOS Target ID %i or LUN %i are above maximum\n", cmd->id, cmd->lun); return(0x80); } @@ -329,20 +305,20 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) dev->BufferLength = 0; if (! scsi_device_present(cmd->id, cmd->lun)) { - x54x_log("BIOS Target ID %i and LUN %i have no device attached\n", + scsi_dev_log("BIOS Target ID %i and LUN %i have no device attached\n", cmd->id, cmd->lun); return(0x80); } if ((dev->LunType == SCSI_CDROM) && !x54x->cdrom_boot) { - x54x_log("BIOS Target ID %i and LUN %i is CD-ROM on unsupported BIOS\n", + scsi_dev_log("BIOS Target ID %i and LUN %i is CD-ROM on unsupported BIOS\n", cmd->id, cmd->lun); return(0x80); } dma_address = ADDR_TO_U32(cmd->dma_address); - x54x_log("BIOS Data Buffer write: length %d, pointer 0x%04X\n", + scsi_dev_log("BIOS Data Buffer write: length %d, pointer 0x%04X\n", sector_len, dma_address); if (dev->CmdBuffer != NULL) { @@ -367,7 +343,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) memset(dev->CmdBuffer, 0x00, 14); if (sector_len > 0) { - x54x_log("BIOS DMA: Reading 14 bytes at %08X\n", + scsi_dev_log("BIOS DMA: Reading 14 bytes at %08X\n", dma_address); DMAPageWrite(dma_address, scsi_device_sense(cmd->id, cmd->lun), 14); @@ -394,7 +370,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) cdb[7] = 0; cdb[8] = sector_len; #if 0 - x54x_log("BIOS CMD(READ, %08lx, %d)\n", lba, cmd->secount); + scsi_dev_log("BIOS CMD(READ, %08lx, %d)\n", lba, cmd->secount); #endif scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb); @@ -406,7 +382,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) scsi_device_command_phase1(cmd->id, cmd->lun); if (sector_len > 0) { - x54x_log("BIOS DMA: Reading %i bytes at %08X\n", + scsi_dev_log("BIOS DMA: Reading %i bytes at %08X\n", dev->BufferLength, dma_address); DMAPageWrite(dma_address, dev->CmdBuffer, dev->BufferLength); @@ -434,7 +410,7 @@ skip_read_phase1: cdb[7] = 0; cdb[8] = sector_len; #if 0 - x54x_log("BIOS CMD(WRITE, %08lx, %d)\n", lba, cmd->secount); + scsi_dev_log("BIOS CMD(WRITE, %08lx, %d)\n", lba, cmd->secount); #endif scsi_device_command_phase0(cmd->id, cmd->lun, 12, cdb); @@ -445,7 +421,7 @@ skip_read_phase1: dev->CmdBuffer = (uint8_t *)malloc(dev->BufferLength); if (sector_len > 0) { - x54x_log("BIOS DMA: Reading %i bytes at %08X\n", + scsi_dev_log("BIOS DMA: Reading %i bytes at %08X\n", dev->BufferLength, dma_address); DMAPageRead(dma_address, dev->CmdBuffer, dev->BufferLength); @@ -504,7 +480,7 @@ skip_write_phase1: ret = x54x_bios_command_08(cmd->id, cmd->lun, dev->CmdBuffer); - x54x_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address); + scsi_dev_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address); DMAPageWrite(dma_address, dev->CmdBuffer, 4 /* dev->BufferLength */); @@ -570,7 +546,7 @@ skip_write_phase1: ret = x54x_bios_command_15(cmd->id, cmd->lun, dev->CmdBuffer); - x54x_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address); + scsi_dev_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address); DMAPageWrite(dma_address, dev->CmdBuffer, 4 /* dev->BufferLength */); @@ -582,11 +558,11 @@ skip_write_phase1: return(ret); default: - x54x_log("BIOS: Unimplemented command: %02X\n", cmd->command); + scsi_dev_log("BIOS: Unimplemented command: %02X\n", cmd->command); return(1); } - x54x_log("BIOS Request complete\n"); + scsi_dev_log("BIOS Request complete\n"); } @@ -604,7 +580,7 @@ x54x_cmd_done(x54x_t *dev, int suppress) if ((dev->Command != CMD_START_SCSI) || fast) { dev->Status &= ~STAT_DFULL; - x54x_log("%s: Raising IRQ %i\n", dev->name, dev->Irq); + scsi_dev_log("%s: Raising IRQ %i\n", dev->name, dev->Irq); raise_irq(dev, suppress, INTR_HACC); } @@ -633,7 +609,7 @@ x54x_mbi_setup(x54x_t *dev, uint32_t CCBPointer, CCBU *CmdBlock, req->TargetStatus = TargetStatus; req->MailboxCompletionCode = mbcc; - x54x_log("Mailbox in setup\n"); + scsi_dev_log("Mailbox in setup\n"); } @@ -643,7 +619,7 @@ x54x_ccb(x54x_t *dev) Req_t *req = &dev->Req; /* Rewrite the CCB up to the CDB. */ - x54x_log("CCB completion code and statuses rewritten (pointer %08X)\n", req->CCBPointer); + scsi_dev_log("CCB completion code and statuses rewritten (pointer %08X)\n", req->CCBPointer); DMAPageWrite(req->CCBPointer + 0x000D, &(req->MailboxCompletionCode), 1); DMAPageWrite(req->CCBPointer + 0x000E, &(req->HostStatus), 1); DMAPageWrite(req->CCBPointer + 0x000F, &(req->TargetStatus), 1); @@ -674,32 +650,32 @@ x54x_mbi(x54x_t *dev) CmdBlock->common.TargetStatus = TargetStatus; /* Rewrite the CCB up to the CDB. */ - x54x_log("CCB statuses rewritten (pointer %08X)\n", req->CCBPointer); + scsi_dev_log("CCB statuses rewritten (pointer %08X)\n", req->CCBPointer); DMAPageWrite(req->CCBPointer + 0x000E, &(req->HostStatus), 1); DMAPageWrite(req->CCBPointer + 0x000F, &(req->TargetStatus), 1); x54x_add_to_period(2); } else { - x54x_log("Mailbox not found!\n"); + scsi_dev_log("Mailbox not found!\n"); } - x54x_log("Host Status 0x%02X, Target Status 0x%02X\n",HostStatus,TargetStatus); + scsi_dev_log("Host Status 0x%02X, Target Status 0x%02X\n",HostStatus,TargetStatus); if (dev->Mbx24bit) { U32_TO_ADDR(CCBPointer, req->CCBPointer); - x54x_log("Mailbox 24-bit: Status=0x%02X, CCB at 0x%04X\n", req->MailboxCompletionCode, CCBPointer); + scsi_dev_log("Mailbox 24-bit: Status=0x%02X, CCB at 0x%04X\n", req->MailboxCompletionCode, CCBPointer); DMAPageWrite(Incoming, &(req->MailboxCompletionCode), 1); DMAPageWrite(Incoming + 1, (uint8_t *)&CCBPointer, 3); x54x_add_to_period(4); - x54x_log("%i bytes of 24-bit mailbox written to: %08X\n", sizeof(Mailbox_t), Incoming); + scsi_dev_log("%i bytes of 24-bit mailbox written to: %08X\n", sizeof(Mailbox_t), Incoming); } else { U32_TO_ADDR(CCBPointer, req->CCBPointer); - x54x_log("Mailbox 32-bit: Status=0x%02X, CCB at 0x%04X\n", req->MailboxCompletionCode, CCBPointer); + scsi_dev_log("Mailbox 32-bit: Status=0x%02X, CCB at 0x%04X\n", req->MailboxCompletionCode, CCBPointer); DMAPageWrite(Incoming, (uint8_t *)&(req->CCBPointer), 4); DMAPageWrite(Incoming + 4, &(req->HostStatus), 1); DMAPageWrite(Incoming + 5, &(req->TargetStatus), 1); DMAPageWrite(Incoming + 7, &(req->MailboxCompletionCode), 1); x54x_add_to_period(7); - x54x_log("%i bytes of 32-bit mailbox written to: %08X\n", sizeof(Mailbox32_t), Incoming); + scsi_dev_log("%i bytes of 32-bit mailbox written to: %08X\n", sizeof(Mailbox32_t), Incoming); } dev->MailboxInPosCur++; @@ -722,7 +698,7 @@ x54x_rd_sge(int Is24bit, uint32_t Address, SGE32 *SG) x54x_add_to_period(sizeof(SGE)); /* Convert the 24-bit entries into 32-bit entries. */ - x54x_log("Read S/G block: %06X, %06X\n", SGE24.Segment, SGE24.SegmentPointer); + scsi_dev_log("Read S/G block: %06X, %06X\n", SGE24.Segment, SGE24.SegmentPointer); SG->Segment = ADDR_TO_U32(SGE24.Segment); SG->SegmentPointer = ADDR_TO_U32(SGE24.SegmentPointer); } else { @@ -744,12 +720,12 @@ x54x_get_length(Req_t *req, int Is24bit) if (Is24bit) { DataPointer = ADDR_TO_U32(req->CmdBlock.old.DataPointer); DataLength = ADDR_TO_U32(req->CmdBlock.old.DataLength); - x54x_log("Data length: %08X\n", req->CmdBlock.old.DataLength); + scsi_dev_log("Data length: %08X\n", req->CmdBlock.old.DataLength); } else { DataPointer = req->CmdBlock.new.DataPointer; DataLength = req->CmdBlock.new.DataLength; } - x54x_log("Data Buffer write: length %d, pointer 0x%04X\n", + scsi_dev_log("Data Buffer write: length %d, pointer 0x%04X\n", DataLength, DataPointer); if (!DataLength) @@ -796,11 +772,11 @@ x54x_set_residue(Req_t *req, int32_t TransferLength) U32_TO_ADDR(Residue24, Residue); DMAPageWrite(req->CCBPointer + 0x0004, (uint8_t *)&Residue24, 3); x54x_add_to_period(3); - x54x_log("24-bit Residual data length for reading: %d\n", Residue); + scsi_dev_log("24-bit Residual data length for reading: %d\n", Residue); } else { DMAPageWrite(req->CCBPointer + 0x0004, (uint8_t *)&Residue, 4); x54x_add_to_period(4); - x54x_log("32-bit Residual data length for reading: %d\n", Residue); + scsi_dev_log("32-bit Residual data length for reading: %d\n", Residue); } } } @@ -827,7 +803,7 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir) DataPointer = req->CmdBlock.new.DataPointer; DataLength = req->CmdBlock.new.DataLength; } - x54x_log("Data Buffer %s: length %d, pointer 0x%04X\n", + scsi_dev_log("Data Buffer %s: length %d, pointer 0x%04X\n", dir ? "write" : "read", BufLen, DataPointer); if ((req->CmdBlock.common.ControlByte != 0x03) && TransferLength && BufLen) { @@ -844,25 +820,25 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir) DataToTransfer = MIN(SGBuffer.Segment, BufLen); if (read_from_host && DataToTransfer) { - x54x_log("Reading S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); + scsi_dev_log("Reading S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); DMAPageRead(Address, &(SCSIDevices[req->TargetID][req->LUN].CmdBuffer[sg_pos]), DataToTransfer); } else if (write_to_host && DataToTransfer) { - x54x_log("Writing S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); + scsi_dev_log("Writing S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); DMAPageWrite(Address, &(SCSIDevices[req->TargetID][req->LUN].CmdBuffer[sg_pos]), DataToTransfer); } else - x54x_log("No action on S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); + scsi_dev_log("No action on S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); sg_pos += SGBuffer.Segment; BufLen -= SGBuffer.Segment; -#if BUFLEN_IS_UNSIGNED +#if 0 /*BUFLEN_IS_UNSIGNED*/ if (BufLen < 0) BufLen = 0; #endif - x54x_log("After S/G segment done: %i, %i\n", sg_pos, BufLen); + scsi_dev_log("After S/G segment done: %i, %i\n", sg_pos, BufLen); } } } else if ((req->CmdBlock.common.Opcode == SCSI_INITIATOR_COMMAND) || @@ -888,7 +864,7 @@ x54x_buf_alloc(uint8_t id, uint8_t lun, int length) SCSIDevices[id][lun].CmdBuffer = NULL; } - x54x_log("Allocating data buffer (%i bytes)\n", length); + scsi_dev_log("Allocating data buffer (%i bytes)\n", length); SCSIDevices[id][lun].CmdBuffer = (uint8_t *) malloc(length); memset(SCSIDevices[id][lun].CmdBuffer, 0, length); } @@ -907,14 +883,14 @@ x54x_buf_free(uint8_t id, uint8_t lun) static uint8_t ConvertSenseLength(uint8_t RequestSenseLength) { - x54x_log("Unconverted Request Sense length %i\n", RequestSenseLength); + scsi_dev_log("Unconverted Request Sense length %i\n", RequestSenseLength); if (RequestSenseLength == 0) RequestSenseLength = 14; else if (RequestSenseLength == 1) RequestSenseLength = 0; - x54x_log("Request Sense length %i\n", RequestSenseLength); + scsi_dev_log("Request Sense length %i\n", RequestSenseLength); return(RequestSenseLength); } @@ -952,13 +928,13 @@ SenseBufferFree(Req_t *req, int Copy) */ SenseBufferAddress = SenseBufferPointer(req); - x54x_log("Request Sense address: %02X\n", SenseBufferAddress); + scsi_dev_log("Request Sense address: %02X\n", SenseBufferAddress); - x54x_log("SenseBufferFree(): Writing %i bytes at %08X\n", + scsi_dev_log("SenseBufferFree(): Writing %i bytes at %08X\n", SenseLength, SenseBufferAddress); DMAPageWrite(SenseBufferAddress, temp_sense, SenseLength); x54x_add_to_period(SenseLength); - x54x_log("Sense data written to buffer: %02X %02X %02X\n", + scsi_dev_log("Sense data written to buffer: %02X %02X %02X\n", temp_sense[2], temp_sense[12], temp_sense[13]); } } @@ -988,13 +964,13 @@ x54x_scsi_cmd(x54x_t *dev) if (!scsi_device_valid(id, lun)) fatal("SCSI target on %02i:%02i has disappeared\n", id, lun); - x54x_log("target_data_len = %i\n", target_data_len); + scsi_dev_log("target_data_len = %i\n", target_data_len); - x54x_log("SCSI command being executed on ID %i, LUN %i\n", id, lun); + scsi_dev_log("SCSI command being executed on ID %i, LUN %i\n", id, lun); - x54x_log("SCSI CDB[0]=0x%02X\n", req->CmdBlock.common.Cdb[0]); + scsi_dev_log("SCSI CDB[0]=0x%02X\n", req->CmdBlock.common.Cdb[0]); for (i=1; iCmdBlock.common.CdbLength; i++) - x54x_log("SCSI CDB[%i]=%i\n", i, req->CmdBlock.common.Cdb[i]); + scsi_dev_log("SCSI CDB[%i]=%i\n", i, req->CmdBlock.common.Cdb[i]); memset(temp_cdb, 0x00, target_cdb_len); if (req->CmdBlock.common.CdbLength <= target_cdb_len) { @@ -1011,13 +987,13 @@ x54x_scsi_cmd(x54x_t *dev) BufLen = scsi_device_get_buf_len(id, lun); *BufLen = target_data_len; - x54x_log("Command buffer: %08X\n", SCSIDevices[id][lun].CmdBuffer); + scsi_dev_log("Command buffer: %08X\n", SCSIDevices[id][lun].CmdBuffer); scsi_device_command_phase0(id, lun, req->CmdBlock.common.CdbLength, temp_cdb); phase = SCSIDevices[id][lun].Phase; - x54x_log("Control byte: %02X\n", (req->CmdBlock.common.ControlByte == 0x03)); + scsi_dev_log("Control byte: %02X\n", (req->CmdBlock.common.ControlByte == 0x03)); if (phase != SCSI_PHASE_STATUS) { if ((temp_cdb[0] == 0x03) && (req->CmdBlock.common.ControlByte == 0x03)) { @@ -1052,7 +1028,7 @@ x54x_scsi_cmd(x54x_t *dev) x54x_buf_free(id, lun); - x54x_log("Request complete\n"); + scsi_dev_log("Request complete\n"); if (SCSIDevices[id][lun].Status == SCSI_STATUS_OK) { x54x_mbi_setup(dev, req->CCBPointer, &req->CmdBlock, @@ -1062,7 +1038,7 @@ x54x_scsi_cmd(x54x_t *dev) CCB_COMPLETE, SCSI_STATUS_CHECK_CONDITION, MBI_ERROR); } - x54x_log("SCSIDevices[%02i][%02i].Status = %02X\n", id, lun, SCSIDevices[id][lun].Status); + scsi_dev_log("SCSIDevices[%02i][%02i].Status = %02X\n", id, lun, SCSIDevices[id][lun].Status); } @@ -1095,60 +1071,60 @@ x54x_req_setup(x54x_t *dev, uint32_t CCBPointer, Mailbox32_t *Mailbox32) id = req->TargetID; lun = req->LUN; if ((id > max_id) || (lun > 7)) { - x54x_log("SCSI Target ID %i or LUN %i is not valid\n",id,lun); + scsi_dev_log("SCSI Target ID %i or LUN %i is not valid\n",id,lun); x54x_mbi_setup(dev, CCBPointer, &req->CmdBlock, CCB_SELECTION_TIMEOUT, SCSI_STATUS_OK, MBI_ERROR); - x54x_log("%s: Callback: Send incoming mailbox\n", dev->name); + scsi_dev_log("%s: Callback: Send incoming mailbox\n", dev->name); x54x_notify(dev); return; } - x54x_log("Scanning SCSI Target ID %i\n", id); + scsi_dev_log("Scanning SCSI Target ID %i\n", id); SCSIDevices[id][lun].Status = SCSI_STATUS_OK; /* If there is no device at ID:0, timeout the selection - the LUN is then checked later. */ if (! scsi_device_present(id, 0)) { - x54x_log("SCSI Target ID %i and LUN %i have no device attached\n",id,lun); + scsi_dev_log("SCSI Target ID %i and LUN %i have no device attached\n",id,lun); x54x_mbi_setup(dev, CCBPointer, &req->CmdBlock, CCB_SELECTION_TIMEOUT, SCSI_STATUS_OK, MBI_ERROR); - x54x_log("%s: Callback: Send incoming mailbox\n", dev->name); + scsi_dev_log("%s: Callback: Send incoming mailbox\n", dev->name); x54x_notify(dev); } else { - x54x_log("SCSI Target ID %i detected and working\n", id); + scsi_dev_log("SCSI Target ID %i detected and working\n", id); - x54x_log("Transfer Control %02X\n", req->CmdBlock.common.ControlByte); - x54x_log("CDB Length %i\n", req->CmdBlock.common.CdbLength); - x54x_log("CCB Opcode %x\n", req->CmdBlock.common.Opcode); + scsi_dev_log("Transfer Control %02X\n", req->CmdBlock.common.ControlByte); + scsi_dev_log("CDB Length %i\n", req->CmdBlock.common.CdbLength); + scsi_dev_log("CCB Opcode %x\n", req->CmdBlock.common.Opcode); if ((req->CmdBlock.common.Opcode > 0x04) && (req->CmdBlock.common.Opcode != 0x81)) { - x54x_log("Invalid opcode: %02X\n", + scsi_dev_log("Invalid opcode: %02X\n", req->CmdBlock.common.ControlByte); x54x_mbi_setup(dev, CCBPointer, &req->CmdBlock, CCB_INVALID_OP_CODE, SCSI_STATUS_OK, MBI_ERROR); - x54x_log("%s: Callback: Send incoming mailbox\n", dev->name); + scsi_dev_log("%s: Callback: Send incoming mailbox\n", dev->name); x54x_notify(dev); return; } if (req->CmdBlock.common.Opcode == 0x81) { - x54x_log("Bus reset opcode\n"); + scsi_dev_log("Bus reset opcode\n"); x54x_mbi_setup(dev, req->CCBPointer, &req->CmdBlock, CCB_COMPLETE, SCSI_STATUS_OK, MBI_SUCCESS); - x54x_log("%s: Callback: Send incoming mailbox\n", dev->name); + scsi_dev_log("%s: Callback: Send incoming mailbox\n", dev->name); x54x_notify(dev); return; } if (req->CmdBlock.common.ControlByte > 0x03) { - x54x_log("Invalid control byte: %02X\n", + scsi_dev_log("Invalid control byte: %02X\n", req->CmdBlock.common.ControlByte); x54x_mbi_setup(dev, CCBPointer, &req->CmdBlock, CCB_INVALID_DIRECTION, SCSI_STATUS_OK, MBI_ERROR); - x54x_log("%s: Callback: Send incoming mailbox\n", dev->name); + scsi_dev_log("%s: Callback: Send incoming mailbox\n", dev->name); x54x_notify(dev); return; } - x54x_log("%s: Callback: Process SCSI request\n", dev->name); + scsi_dev_log("%s: Callback: Process SCSI request\n", dev->name); x54x_scsi_cmd(dev); - x54x_log("%s: Callback: Send incoming mailbox\n", dev->name); + scsi_dev_log("%s: Callback: Send incoming mailbox\n", dev->name); x54x_notify(dev); } } @@ -1165,7 +1141,7 @@ x54x_req_abort(x54x_t *dev, uint32_t CCBPointer) x54x_mbi_setup(dev, CCBPointer, &CmdBlock, 0x26, SCSI_STATUS_OK, MBI_NOT_FOUND); - x54x_log("%s: Callback: Send incoming mailbox\n", dev->name); + scsi_dev_log("%s: Callback: Send incoming mailbox\n", dev->name); x54x_notify(dev); } @@ -1219,18 +1195,18 @@ x54x_mbo_process(x54x_t *dev) Outgoing = x54x_mbo(dev, &mb32); if (mb32.u.out.ActionCode == MBO_START) { - x54x_log("Start Mailbox Command\n"); + scsi_dev_log("Start Mailbox Command\n"); x54x_req_setup(dev, mb32.CCBPointer, &mb32); } else if (!dev->MailboxIsBIOS && (mb32.u.out.ActionCode == MBO_ABORT)) { - x54x_log("Abort Mailbox Command\n"); + scsi_dev_log("Abort Mailbox Command\n"); x54x_req_abort(dev, mb32.CCBPointer); } /* else { - x54x_log("Invalid action code: %02X\n", mb32.u.out.ActionCode); + scsi_dev_log("Invalid action code: %02X\n", mb32.u.out.ActionCode); } */ if ((mb32.u.out.ActionCode == MBO_START) || (!dev->MailboxIsBIOS && (mb32.u.out.ActionCode == MBO_ABORT))) { /* We got the mailbox, mark it as free in the guest. */ - x54x_log("x54x_do_mail(): Writing %i bytes at %08X\n", sizeof(CmdStatus), Outgoing + CodeOffset); + scsi_dev_log("x54x_do_mail(): Writing %i bytes at %08X\n", sizeof(CmdStatus), Outgoing + CodeOffset); DMAPageWrite(Outgoing + CodeOffset, &CmdStatus, 1); x54x_add_to_period(1); @@ -1258,13 +1234,13 @@ x54x_do_mail(x54x_t *dev) if (dev->is_aggressive_mode) { aggressive = dev->is_aggressive_mode(dev); - x54x_log("Processing mailboxes in %s mode...\n", aggressive ? "aggressive" : "strict"); + scsi_dev_log("Processing mailboxes in %s mode...\n", aggressive ? "aggressive" : "strict"); }/* else { - x54x_log("Defaulting to process mailboxes in %s mode...\n", aggressive ? "aggressive" : "strict"); + scsi_dev_log("Defaulting to process mailboxes in %s mode...\n", aggressive ? "aggressive" : "strict"); }*/ if (!dev->MailboxCount) { - x54x_log("x54x_do_mail(): No Mailboxes\n"); + scsi_dev_log("x54x_do_mail(): No Mailboxes\n"); return; } @@ -1312,7 +1288,7 @@ x54x_cmd_callback(void *priv) period = (1000000.0 / x54x_dev->ha_bps) * ((double) TIMER_USEC) * ((double) dev->temp_period); dev->timer_period = dev->media_period + ((int64_t) period) + (40LL * TIMER_USEC); - x54x_log("Temporary period: %" PRId64 " us (%" PRIi64 " periods)\n", dev->timer_period, dev->temp_period); + scsi_dev_log("Temporary period: %" PRId64 " us (%" PRIi64 " periods)\n", dev->timer_period, dev->temp_period); } @@ -1371,7 +1347,7 @@ x54x_in(uint16_t port, void *priv) } #if 0 - x54x_log("%s: Read Port 0x%02X, Value %02X\n", dev->name, port, ret); + scsi_dev_log("%s: Read Port 0x%02X, Value %02X\n", dev->name, port, ret); #endif return(ret); } @@ -1452,7 +1428,7 @@ void x54x_reset_ctrl(x54x_t *dev, uint8_t Reset) { /* Say hello! */ - x54x_log("%s %s (IO=0x%04X, IRQ=%d, DMA=%d, BIOS @%05lX) ID=%d\n", + scsi_dev_log("%s %s (IO=0x%04X, IRQ=%d, DMA=%d, BIOS @%05lX) ID=%d\n", dev->vendor, dev->name, dev->Base, dev->Irq, dev->DmaChannel, dev->rom_addr, dev->HostID); @@ -1484,21 +1460,21 @@ x54x_out(uint16_t port, uint8_t val, void *priv) uint8_t host_id = dev->HostID; uint8_t irq = 0; - x54x_log("%s: Write Port 0x%02X, Value %02X\n", dev->name, port, val); + scsi_dev_log("%s: Write Port 0x%02X, Value %02X\n", dev->name, port, val); switch (port & 3) { case 0: if ((val & CTRL_HRST) || (val & CTRL_SRST)) { reset = (val & CTRL_HRST); - x54x_log("Reset completed = %x\n", reset); + scsi_dev_log("Reset completed = %x\n", reset); x54x_reset_ctrl(dev, reset); - x54x_log("Controller reset: "); + scsi_dev_log("Controller reset: "); break; } if (val & CTRL_IRST) { clear_irq(dev); - x54x_log("Interrupt reset: "); + scsi_dev_log("Interrupt reset: "); } break; @@ -1506,7 +1482,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) /* Fast path for the mailbox execution command. */ if ((val == CMD_START_SCSI) && (dev->Command == 0xff)) { dev->MailboxReq++; - x54x_log("Start SCSI command: "); + scsi_dev_log("Start SCSI command: "); return; } if (dev->ven_fast_cmds) { @@ -1522,7 +1498,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) dev->CmdParamLeft = 0; dev->Status &= ~(STAT_INVCMD | STAT_IDLE); - x54x_log("%s: Operation Code 0x%02X\n", dev->name, val); + scsi_dev_log("%s: Operation Code 0x%02X\n", dev->name, val); switch (dev->Command) { case CMD_MBINIT: dev->CmdParamLeft = sizeof(MailboxInit_t); @@ -1566,7 +1542,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) } if (! dev->CmdParamLeft) { - x54x_log("Running Operation Code 0x%02X\n", dev->Command); + scsi_dev_log("Running Operation Code 0x%02X\n", dev->Command); switch (dev->Command) { case CMD_NOP: /* No Operation */ dev->DataReplyLeft = 0; @@ -1582,7 +1558,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) dev->MailboxOutAddr = ADDR_TO_U32(mbi->Address); dev->MailboxInAddr = dev->MailboxOutAddr + (dev->MailboxCount * sizeof(Mailbox_t)); - x54x_log("Initialize Mailbox: MBO=0x%08lx, MBI=0x%08lx, %d entries at 0x%08lx\n", + scsi_dev_log("Initialize Mailbox: MBO=0x%08lx, MBI=0x%08lx, %d entries at 0x%08lx\n", dev->MailboxOutAddr, dev->MailboxInAddr, mbi->Count, @@ -1590,7 +1566,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) dev->Status &= ~STAT_INIT; dev->DataReplyLeft = 0; - x54x_log("Mailbox init: "); + scsi_dev_log("Mailbox init: "); break; case CMD_BIOSCMD: /* execute BIOS */ @@ -1602,32 +1578,32 @@ x54x_out(uint16_t port, uint8_t val, void *priv) } if (dev->lba_bios) { /* 1640 uses LBA. */ - x54x_log("BIOS LBA=%06lx (%lu)\n", + scsi_dev_log("BIOS LBA=%06lx (%lu)\n", lba32_blk(cmd), lba32_blk(cmd)); } else { cmd->u.chs.head &= 0xf; cmd->u.chs.sec &= 0x1f; - x54x_log("BIOS CHS=%04X/%02X%02X\n", + scsi_dev_log("BIOS CHS=%04X/%02X%02X\n", cmd->u.chs.cyl, cmd->u.chs.head, cmd->u.chs.sec); } dev->DataBuf[0] = x54x_bios_command(dev, dev->max_id, cmd, (dev->lba_bios)?1:0); - x54x_log("BIOS Completion/Status Code %x\n", dev->DataBuf[0]); + scsi_dev_log("BIOS Completion/Status Code %x\n", dev->DataBuf[0]); dev->DataReplyLeft = 1; break; case CMD_INQUIRY: /* Inquiry */ memcpy(dev->DataBuf, dev->fw_rev, 4); - x54x_log("Adapter inquiry: %c %c %c %c\n", dev->fw_rev[0], dev->fw_rev[1], dev->fw_rev[2], dev->fw_rev[3]); + scsi_dev_log("Adapter inquiry: %c %c %c %c\n", dev->fw_rev[0], dev->fw_rev[1], dev->fw_rev[2], dev->fw_rev[3]); dev->DataReplyLeft = 4; break; case CMD_EMBOI: /* enable MBO Interrupt */ if (dev->CmdBuf[0] <= 1) { dev->MailboxOutInterrupts = dev->CmdBuf[0]; - x54x_log("Mailbox out interrupts: %s\n", dev->MailboxOutInterrupts ? "ON" : "OFF"); + scsi_dev_log("Mailbox out interrupts: %s\n", dev->MailboxOutInterrupts ? "ON" : "OFF"); suppress = 1; } else { dev->Status |= STAT_INVCMD; @@ -1642,19 +1618,19 @@ x54x_out(uint16_t port, uint8_t val, void *priv) case CMD_BUSON_TIME: /* bus-on time */ dev->BusOnTime = dev->CmdBuf[0]; dev->DataReplyLeft = 0; - x54x_log("Bus-on time: %d\n", dev->CmdBuf[0]); + scsi_dev_log("Bus-on time: %d\n", dev->CmdBuf[0]); break; case CMD_BUSOFF_TIME: /* bus-off time */ dev->BusOffTime = dev->CmdBuf[0]; dev->DataReplyLeft = 0; - x54x_log("Bus-off time: %d\n", dev->CmdBuf[0]); + scsi_dev_log("Bus-off time: %d\n", dev->CmdBuf[0]); break; case CMD_DMASPEED: /* DMA Transfer Rate */ dev->ATBusSpeed = dev->CmdBuf[0]; dev->DataReplyLeft = 0; - x54x_log("DMA transfer rate: %02X\n", dev->CmdBuf[0]); + scsi_dev_log("DMA transfer rate: %02X\n", dev->CmdBuf[0]); break; case CMD_RETDEVS: /* return Installed Devices */ @@ -1696,7 +1672,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) dev->DataBuf[2] = dev->ven_get_host_id(dev); else dev->DataBuf[2] = dev->HostID; - x54x_log("Configuration data: %02X %02X %02X\n", dev->DataBuf[0], dev->DataBuf[1], dev->DataBuf[2]); + scsi_dev_log("Configuration data: %02X %02X %02X\n", dev->DataBuf[0], dev->DataBuf[1], dev->DataBuf[2]); dev->DataReplyLeft = 3; break; @@ -1716,7 +1692,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) } dev->DataReplyLeft = dev->CmdBuf[0]; - x54x_log("Return Setup Information: %d (length: %i)\n", dev->CmdBuf[0], sizeof(ReplyInquireSetupInformation)); + scsi_dev_log("Return Setup Information: %d (length: %i)\n", dev->CmdBuf[0], sizeof(ReplyInquireSetupInformation)); } break; @@ -1731,7 +1707,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) Address.mid = dev->CmdBuf[1]; Address.lo = dev->CmdBuf[2]; FIFOBuf = ADDR_TO_U32(Address); - x54x_log("Adaptec LocalRAM: Reading 64 bytes at %08X\n", FIFOBuf); + scsi_dev_log("Adaptec LocalRAM: Reading 64 bytes at %08X\n", FIFOBuf); DMAPageRead(FIFOBuf, dev->dma_buffer, 64); break; @@ -1741,7 +1717,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) Address.mid = dev->CmdBuf[1]; Address.lo = dev->CmdBuf[2]; FIFOBuf = ADDR_TO_U32(Address); - x54x_log("Adaptec LocalRAM: Writing 64 bytes at %08X\n", FIFOBuf); + scsi_dev_log("Adaptec LocalRAM: Writing 64 bytes at %08X\n", FIFOBuf); DMAPageWrite(FIFOBuf, dev->dma_buffer, 64); break; @@ -1827,12 +1803,12 @@ x54x_io_set(x54x_t *dev, uint32_t base, uint8_t len) bit32 = 1; if (bit32) { - x54x_log("x54x: [PCI] Setting I/O handler at %04X\n", base); + scsi_dev_log("x54x: [PCI] Setting I/O handler at %04X\n", base); io_sethandler(base, len, x54x_in, x54x_inw, x54x_inl, x54x_out, x54x_outw, x54x_outl, dev); } else { - x54x_log("x54x: [ISA] Setting I/O handler at %04X\n", base); + scsi_dev_log("x54x: [ISA] Setting I/O handler at %04X\n", base); io_sethandler(base, len, x54x_in, x54x_inw, NULL, x54x_out, x54x_outw, NULL, dev); @@ -1850,7 +1826,7 @@ x54x_io_remove(x54x_t *dev, uint32_t base, uint8_t len) else if ((dev->bus & DEVICE_MCA) && dev->bit32) bit32 = 1; - x54x_log("x54x: Removing I/O handler at %04X\n", base); + scsi_dev_log("x54x: Removing I/O handler at %04X\n", base); if (bit32) { io_removehandler(base, len, diff --git a/src/sound/midi_fluidsynth.c b/src/sound/midi_fluidsynth.c index 3e416bb..1639798 100644 --- a/src/sound/midi_fluidsynth.c +++ b/src/sound/midi_fluidsynth.c @@ -17,7 +17,7 @@ * website (for 32bit and 64bit Windows) are working, and * need no additional support files other than sound fonts. * - * Version: @(#)midi_fluidsynth.c 1.0.7 2018/04/25 + * Version: @(#)midi_fluidsynth.c 1.0.8 2018/04/27 * * Code borrowed from scummvm. * @@ -56,8 +56,8 @@ #include "../emu.h" #include "../config.h" #include "../device.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "midi.h" #include "midi_fluidsynth.h" #include "sound.h" diff --git a/src/sound/openal.c b/src/sound/openal.c index b7c379c..3fbe6db 100644 --- a/src/sound/openal.c +++ b/src/sound/openal.c @@ -8,7 +8,7 @@ * * Interface to the OpenAL sound processing library. * - * Version: @(#)openal.c 1.0.9 2018/04/14 + * Version: @(#)openal.c 1.0.10 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -52,8 +52,8 @@ # include #endif #include "../emu.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "sound.h" #include "midi.h" diff --git a/src/sound/resid-fp/convolve.cpp b/src/sound/resid-fp/convolve.cpp index b028ace..4efdfe0 100644 --- a/src/sound/resid-fp/convolve.cpp +++ b/src/sound/resid-fp/convolve.cpp @@ -16,6 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // --------------------------------------------------------------------------- +#include "sid.h" float convolve(const float *a, const float *b, int n) { diff --git a/src/sound/resid-fp/sid.h b/src/sound/resid-fp/sid.h index 6dad2e0..5eacfd8 100644 --- a/src/sound/resid-fp/sid.h +++ b/src/sound/resid-fp/sid.h @@ -127,4 +127,7 @@ protected: bool can_use_sse; }; +extern float convolve(const float *, const float *, int); +extern float convolve_sse(const float *, const float *, int); + #endif // not __SID_H__ diff --git a/src/sound/snd_dbopl.h b/src/sound/snd_dbopl.h index a5484af..dca57a6 100644 --- a/src/sound/snd_dbopl.h +++ b/src/sound/snd_dbopl.h @@ -8,7 +8,7 @@ * * Definitions for the DOSbox OPL emulator. * - * Version: @(#)snd_dbopl.h 1.0.1 2018/02/14 + * Version: @(#)snd_dbopl.h 1.0.2 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,6 +49,7 @@ extern "C" { void opl_init(void (*timer_callback)(void *param, int timer, int64_t period), void *timer_param, int nr, int is_opl3); void opl_write(int nr, uint16_t addr, uint8_t val); uint8_t opl_read(int nr, uint16_t addr); + void opl_status_update(int nr); void opl_timer_over(int nr, int timer); void opl2_update(int nr, int16_t *buffer, int samples); void opl3_update(int nr, int16_t *buffer, int samples); diff --git a/src/sound/snd_emu8k.c b/src/sound/snd_emu8k.c index 73be9fb..e42c5ba 100644 --- a/src/sound/snd_emu8k.c +++ b/src/sound/snd_emu8k.c @@ -8,7 +8,7 @@ * * Implementation of Emu8000 emulator. * - * Version: @(#)snd_emu8k.c 1.0.8 2018/04/02 + * Version: @(#)snd_emu8k.c 1.0.9 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -361,7 +361,7 @@ static inline int16_t EMU8K_READ(emu8k_t *emu8k, uint32_t addr) return emu8k->ram_pointers[addrmem.hb_address][addrmem.lw_address]; } -#if NOTUSED +#if 0 /*NOT_USED*/ static inline int16_t EMU8K_READ_INTERP_LINEAR(emu8k_t *emu8k, uint32_t int_addr, uint16_t fract) { /* The interpolation in AWE32 used a so-called patented 3-point interpolation diff --git a/src/ui.h b/src/ui/ui.h similarity index 57% rename from src/ui.h rename to src/ui/ui.h index 3f5bc7c..83d780a 100644 --- a/src/ui.h +++ b/src/ui/ui.h @@ -8,7 +8,7 @@ * * Define the various UI functions. * - * Version: @(#)ui.h 1.0.4 2018/04/09 + * Version: @(#)ui.h 1.0.5 2018/04/29 * * Author: Fred N. van Kempen, * @@ -48,62 +48,7 @@ # define EMU_UI_H -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef USE_WX -# define RENDER_FPS 30 /* default render speed */ -#endif - - -/* Define whether or not we need the Logging submenu. */ -#if defined(ENABLE_PCI_LOG) || \ - defined(ENABLE_KEYBOARD_LOG) || \ - defined(ENABLE_SERIAL_LOG) || \ - defined(ENABLE_FDC_LOG) || defined(ENABLE_D86F_LOG) || \ - defined(ENABLE_HDC_LOG) || defined(ENABLE_HDD_LOG) || \ - defined(ENABLE_ZIP_LOG) || defined(ENABLE_CDROM_LOG) || \ - defined(ENABLE_CDROM_IMAGE_LOG) || defined(ENABLE_CDROM_IOCTL_LOG) || \ - defined(ENABLE_SOUND_EMU8K_LOG) || defined(ENABLE_SOUND_MPU401_LOG) || \ - defined(ENABLE_SOUND_DEV_LOG) || \ - defined(ENABLE_NIC_LOG) || \ - defined(ENABLE_SCSI_BUS_LOG) || defined(ENABLE_SCSI_DISK_LOG) || \ - defined(ENABLE_SCSI_DEV_LOG) || defined(ENABLE_SCSI_X54X_LOG) || \ - defined(ENABLE_VOODOO_LOG) -# define ENABLE_LOG_TOGGLES 1 -#endif - -#if defined(ENABLE_LOG_BREAKPOINT) -# define ENABLE_LOG_COMMANDS 1 -#endif - - -#ifdef ENABLE_LOG_TOGGLES -extern int pci_do_log; -extern int keyboard_do_log; -extern int serial_do_log; -extern int fdc_do_log; -extern int d86f_do_log; -extern int hdc_do_log; -extern int hdd_do_log; -extern int zip_do_log; -extern int cdrom_do_log; -extern int cdrom_image_do_log; -extern int cdrom_ioctl_do_log; -extern int sound_emu8k_do_log; -extern int sound_mpu401_do_log; -extern int sound_dev_do_log; -extern int nic_do_log; -extern int scsi_bus_do_log; -extern int scsi_hd_do_log; -extern int scsi_dev_do_log; -extern int scsi_x54x_do_log; -extern int voodoo_do_log; -#endif - -/* Message Box functions. */ +/* Message Box definitions. */ #define MBX_INFO 1 #define MBX_WARNING 2 #define MBX_ERROR 3 @@ -112,11 +57,7 @@ extern int voodoo_do_log; #define MBX_FATAL 0x20 #define MBX_ANSI 0x80 -extern int ui_msgbox(int type, void *arg); - -extern void ui_check_menu_item(int id, int checked); - -/* Status Bar functions. */ +/* Status Bar definitions. */ #define SB_ICON_WIDTH 24 #define SB_FLOPPY 0x00 #define SB_CDROM 0x10 @@ -127,20 +68,120 @@ extern void ui_check_menu_item(int id, int checked); #define SB_SOUND 0x70 #define SB_TEXT 0x80 +#ifdef USE_WX +# define RENDER_FPS 30 /* default render speed */ +#endif + +/* Define whether or not we need the Logging submenu. */ +#if defined(ENABLE_BUS_LOG) || \ + defined(ENABLE_KEYBOARD_LOG) || defined(ENABLE_MOUSE_LOG) || \ + defined(ENABLE_GAME_LOG) || \ + defined(ENABLE_SERIAL_LOG) || defined(ENABLE_PARALLELL_LOG) || \ + defined(ENABLE_FDC_LOG) || defined(ENABLE_FDD_LOG) || \ + defined(ENABLE_D86F_LOG) || \ + defined(ENABLE_HDC_LOG) || defined(ENABLE_HDD_LOG) || \ + defined(ENABLE_ZIP_LOG) || defined(ENABLE_CDROM_LOG) || \ + defined(ENABLE_CDROM_IMAGE_LOG) || defined(ENABLE_CDROM_IOCTL_LOG) || \ + defined(ENABLE_SOUND_EMU8K_LOG) || defined(ENABLE_SOUND_MPU401_LOG) || \ + defined(ENABLE_SOUND_DEV_LOG) || \ + defined(ENABLE_NETWORK_LOG) || defined(ENABLE_NETWORK_DEV_LOG) || \ + defined(ENABLE_SCSI_BUS_LOG) || defined(ENABLE_SCSI_DISK_LOG) || \ + defined(ENABLE_SCSI_DEV_LOG) || \ + defined(ENABLE_VOODOO_LOG) +# define ENABLE_LOG_TOGGLES 1 +#endif + +#if defined(ENABLE_LOG_BREAKPOINT) +# define ENABLE_LOG_COMMANDS 1 +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef ENABLE_LOG_TOGGLES +extern int pci_do_log; +extern int keyboard_do_log; +extern int mouse_do_log; +extern int game_do_log; +extern int parallel_do_log; +extern int serial_do_log; +extern int fdc_do_log; +extern int fdd_do_log; +extern int d86f_do_log; +extern int hdc_do_log; +extern int hdd_do_log; +extern int zip_do_log; +extern int cdrom_do_log; +extern int cdrom_image_do_log; +extern int cdrom_ioctl_do_log; +extern int sound_emu8k_do_log; +extern int sound_mpu401_do_log; +extern int sound_dev_do_log; +extern int network_do_log; +extern int network_dev_do_log; +extern int scsi_bus_do_log; +extern int scsi_hd_do_log; +extern int scsi_dev_do_log; +extern int voodoo_do_log; +#endif + +/* Main GUI functions. */ +extern int ui_msgbox(int type, void *arg); +extern void ui_menu_reset_all(void); +extern int ui_menu_command(int idm); +extern void ui_menu_set_radio_item(int idm, int num, int val); +extern void ui_menu_set_logging_item(int idm, int val); +extern void ui_menu_toggle_video_item(int idm, int *val); + +/* Main GUI helper functions. */ +extern void menu_enable_item(int idm, int val); +extern void menu_set_item(int idm, int val); extern wchar_t *ui_window_title(wchar_t *s); -extern void ui_status_update(void); -extern int ui_sb_find_part(int tag); -extern void ui_sb_update_panes(void); -extern void ui_sb_update_tip(int meaning); -extern void ui_sb_check_menu_item(int tag, int id, int chk); -extern void ui_sb_enable_menu_item(int tag, int id, int val); -extern void ui_sb_update_icon(int tag, int val); -extern void ui_sb_update_icon_state(int tag, int active); -extern void ui_sb_set_text_w(wchar_t *wstr); -extern void ui_sb_set_text(char *str); -extern void ui_sb_bugui(char *str); -extern void ui_sb_mount_floppy_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name); -extern void ui_sb_mount_zip_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name); + +/* Status Bar functions. */ +extern void ui_sb_update(void); +extern void ui_sb_click(int part); +extern void ui_sb_menu_command(int idm, int tag); +extern void ui_sb_menu_enable_item(int tag, int id, int val); +extern void ui_sb_menu_set_item(int tag, int id, int val); +extern void ui_sb_text_set_w(const wchar_t *str); +extern void ui_sb_text_set(const char *str); +extern void ui_sb_icon_update(int tag, int val); +extern void ui_sb_icon_state(int tag, int active); +extern void ui_sb_tip_update(int tag); +extern void ui_sb_mount_floppy(uint8_t drive, int part, int8_t wp, + const wchar_t *fn); +extern void ui_sb_mount_zip(uint8_t drive, int part, int8_t wp, + const wchar_t *fn); + +/* Status Bar helper functions. */ +extern int sb_fdd_icon(int type); +extern void sb_setup(int parts, const int *widths); +extern void sb_menu_destroy(void); +extern void sb_menu_create(int part); +extern void sb_menu_add_item(int part, int idm, const wchar_t *str); +extern void sb_menu_enable_item(int part, int idm, int val);; +extern void sb_menu_set_item(int part, int idm, int val); +extern void sb_set_icon(int part, int icon); +extern void sb_set_text(int part, const wchar_t *str); +extern void sb_set_tooltip(int part, const wchar_t *str); + +/* Dialogs. */ +extern void dlg_about(void); +extern int dlg_settings(int ask); +extern void dlg_status(void); +extern void dlg_status_update(void); +extern void dlg_new_floppy(int idm, int tag); +extern void dlg_sound_gain(void); +extern int dlg_file(const wchar_t *filt, const wchar_t *ifn, + wchar_t *fn, int save); + +/* Floppy image creation. */ +extern int floppy_create_86f(const wchar_t *, int8_t sz, int8_t rpm_mode); +extern int floppy_create_image(const wchar_t *, int8_t sz, int8_t is_zip, int8_t is_fdi); +extern int zip_create_image(const wchar_t *, int8_t sz, int8_t is_zdi); #ifdef __cplusplus } diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c new file mode 100644 index 0000000..7f7c189 --- /dev/null +++ b/src/ui/ui_main.c @@ -0,0 +1,523 @@ +/* + * VARCem Virtual ARchaeological Computer EMulator. + * An emulator of (mostly) x86-based PC systems and devices, + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * spanning the era between 1981 and 1995. + * + * This file is part of the VARCem Project. + * + * Generic code for the "main" user interface. + * + * This code is called by the UI frontend modules, and, also, + * depends on those same modules for lower-level functions. + * + * Version: @(#)ui_main.c 1.0.4 2018/04/28 + * + * Author: Fred N. van Kempen, + * + * Copyright 2018 Fred N. van Kempen. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the entire + * above notice, this list of conditions and the following + * disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names + * of its contributors may be used to endorse or promote + * products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include +#include "../emu.h" +#include "../config.h" +#include "../device.h" +#include "../input/keyboard.h" +#include "../video/video.h" +#include "../plat.h" +#include "ui.h" +#include "ui_resource.h" + + +/* Set a radio group menu item. */ +void +ui_menu_set_radio_item(int idm, int num, int val) +{ + int i; + + for (i = 0; i < num; i++) + menu_set_item(idm + i, 0); + menu_set_item(idm + val, 1); +} + + +#if defined(ENABLE_LOG_TOGGLES) || defined(ENABLE_LOG_COMMANDS) +/* Simplest way to handle all these, for now.. */ +void +ui_menu_set_logging_item(int idm, int val) +{ + int *ptr = NULL; + + switch(idm) { +#ifdef ENABLE_BUS_LOG + case IDM_LOG_BUS: + ptr = &pci_do_log; + break; +#endif + +#ifdef ENABLE_KEYBOARD_LOG + case IDM_LOG_KEYBOARD: + ptr = &keyboard_do_log; + break; +#endif + +#ifdef ENABLE_MOUSE_LOG + case IDM_LOG_MOUSE: + ptr = &mouse_do_log; + break; +#endif + +#ifdef ENABLE_GAME_LOG + case IDM_LOG_GAME: + ptr = &game_do_log; + break; +#endif + +#ifdef ENABLE_PARALLEL_LOG + case IDM_LOG_PARALLEL: + ptr = ¶llel_do_log; + break; +#endif + +#ifdef ENABLE_FDC_LOG + case IDM_LOG_FDC: + ptr = &fdc_do_log; + break; +#endif + +#ifdef ENABLE_FDD_LOG + case IDM_LOG_FDD: + ptr = &fdd_do_log; + break; +#endif + +#ifdef ENABLE_D86F_LOG + case IDM_LOG_D86F: + ptr = &d86f_do_log; + break; +#endif + +#ifdef ENABLE_HDC_LOG + case IDM_LOG_HDC: + ptr = &hdc_do_log; + break; +#endif + +#ifdef ENABLE_HDD_LOG + case IDM_LOG_HDD: + ptr = &hdd_do_log; + break; +#endif + +#ifdef ENABLE_ZIP_LOG + case IDM_LOG_ZIP: + ptr = &zip_do_log; + break; +#endif + +#ifdef ENABLE_CDROM_LOG + case IDM_LOG_CDROM: + ptr = &cdrom_do_log; + break; +#endif + +#ifdef ENABLE_CDROM_IMAGE_LOG + case IDM_LOG_CDROM_IMAGE: + ptr = &cdrom_image_do_log; + break; +#endif + +#ifdef ENABLE_CDROM_IOCTL_LOG + case IDM_LOG_CDROM_IOCTL: + ptr = &cdrom_ioctl_do_log; + break; +#endif + +#ifdef ENABLE_NETWORK_LOG + case IDM_LOG_NETWORK: + ptr = &network_do_log; + break; +#endif + +#ifdef ENABLE_NETWORK_DEV_LOG + case IDM_LOG_NETWORK_DEV: + ptr = &network_dev_do_log; + break; +#endif + +#ifdef ENABLE_SOUND_EMU8K_LOG + case IDM_LOG_SOUND_EMU8K: + ptr = &sound_emu8k_do_log; + break; +#endif + +#ifdef ENABLE_SOUND_MPU401_LOG + case IDM_LOG_SOUND_MPU401: + ptr = &sound_mpu401_do_log; + break; +#endif + +#ifdef ENABLE_SOUND_DEV_LOG + case IDM_LOG_SOUND_DEV: + ptr = &sound_dev_do_log; + break; +#endif + +#ifdef ENABLE_SCSI_BUS_LOG + case IDM_LOG_SCSI_BUS: + ptr = &scsi_bus_do_log; + break; +#endif + +#ifdef ENABLE_SCSI_DISK_LOG + case IDM_LOG_SCSI_DISK: + ptr = &scsi_hd_do_log; + break; +#endif + +#ifdef ENABLE_SCSI_DEV_LOG + case IDM_LOG_SCSI_DEV: + ptr = &scsi_dev_do_log; + break; +#endif + +#ifdef ENABLE_VOODOO_LOG + case IDM_LOG_VOODOO: + ptr = &voodoo_do_log; + break; +#endif + } + + if (ptr != NULL) { + /* Set the desired value. */ + if (val != 0xff) { + /* Initialize the logging value. */ + if (val < 0) *ptr ^= 1; + else *ptr = val; + } + + /* And update its menu entry. */ + menu_set_item(idm, *ptr); + } +} +#endif + + +/* Toggle one of the Video options, with a lock on the blitter. */ +void +ui_menu_toggle_video_item(int idm, int *val) +{ + startblit(); + video_wait_for_blit(); + *val ^= 1; + endblit(); + + menu_set_item(idm, *val); + + device_force_redraw(); + + config_save(); +} + + +/* Reset all (main) menu items to their default state. */ +void +ui_menu_reset_all(void) +{ + int i; + +#ifndef DEV_BRANCH + /* FIXME: until we fix these.. --FvK */ + menu_enable_item(IDM_LOAD, 0); + menu_enable_item(IDM_SAVE, 0); +#endif + + menu_set_item(IDM_RESIZE, vid_resize); + menu_set_item(IDM_REMEMBER, window_remember); + + ui_menu_set_radio_item(IDM_VID_DDRAW, 4, -1); + + ui_menu_set_radio_item(IDM_SCALE_1, 4, scale); + + menu_set_item(IDM_FULLSCREEN, vid_fullscreen); + + ui_menu_set_radio_item(IDM_STRETCH, 5, vid_fullscreen_scale); + + menu_set_item(IDM_VGA_INVERT, invert_display); + menu_set_item(IDM_VGA_OVERSCAN, enable_overscan); + + ui_menu_set_radio_item(IDM_SCREEN_RGB, 5, vid_grayscale); + + ui_menu_set_radio_item(IDM_GRAY_601, 3, vid_graytype); + + menu_set_item(IDM_FORCE_43, force_43); + + menu_set_item(IDM_CGA_CONTR, vid_cga_contrast); + + menu_set_item(IDM_RCTRL_IS_LALT, rctrl_is_lalt); + + menu_set_item(IDM_UPDATE_ICONS, update_icons); + +#ifdef ENABLE_LOG_TOGGLES + for (i = IDM_LOG_BEGIN; i < IDM_LOG_END; i++) + ui_menu_set_logging_item(i, 0xff); +#endif +} + + +/* Handle a main menu command. */ +int +ui_menu_command(int idm) +{ + int i; + + switch (idm) { + case IDM_SCREENSHOT: + take_screenshot(); + break; + + case IDM_RESET_HARD: + pc_reset(1); + break; + + case IDM_RESET: + pc_reset(0); + break; + + case IDM_EXIT: + /*NOTHANDLED*/ + return(0); + + case IDM_CAE: + keyboard_send_cae(); + break; + + case IDM_CAB: + keyboard_send_cab(); + break; + + case IDM_PAUSE: + plat_pause(dopause ^ 1); + menu_set_item(idm, dopause); + break; + + case IDM_SETTINGS: + plat_pause(1); + if (dlg_settings(1) == 2) + pc_reset_hard_init(); + plat_pause(0); + break; + + case IDM_ABOUT: + dlg_about(); + break; + + case IDM_STATUS: + dlg_status(); + break; + + case IDM_UPDATE_ICONS: + update_icons ^= 1; + menu_set_item(idm, update_icons); + config_save(); + break; + + case IDM_RESIZE: + vid_resize ^= 1; + menu_set_item(idm, vid_resize); + if (vid_resize) { + /* Force scaling to 1.0. */ + scale = 1; + ui_menu_set_radio_item(IDM_SCALE_1, 4, scale); + } + + /* Disable scaling settings. */ + for (i = 0; i < 4; i++) + menu_enable_item(IDM_SCALE_1+i, !vid_resize); + doresize = 1; + config_save(); + return(0); + + case IDM_REMEMBER: + window_remember ^= 1; + menu_set_item(idm, window_remember); + return(0); + + case IDM_VID_DDRAW: + case IDM_VID_D3D: +#ifdef USE_VNC + case IDM_VID_VNC: +#endif +#ifdef USE_RDP + case IDM_VID_RDP: +#endif + plat_setvid(idm - IDM_VID_DDRAW); + ui_menu_set_radio_item(IDM_VID_DDRAW, 4, vid_api); + config_save(); + break; + + case IDM_FULLSCREEN: + plat_setfullscreen(1); + config_save(); + break; + + case IDM_STRETCH: + case IDM_STRETCH_43: + case IDM_STRETCH_SQ: + case IDM_STRETCH_INT: + case IDM_STRETCH_KEEP: + vid_fullscreen_scale = (idm - IDM_STRETCH); + ui_menu_set_radio_item(IDM_STRETCH, 5, vid_fullscreen_scale); + device_force_redraw(); + config_save(); + break; + + case IDM_SCALE_1: + case IDM_SCALE_2: + case IDM_SCALE_3: + case IDM_SCALE_4: + scale = (idm - IDM_SCALE_1); + ui_menu_set_radio_item(IDM_SCALE_1, 4, scale); + device_force_redraw(); + video_force_resize_set(1); + config_save(); + break; + + case IDM_FORCE_43: + ui_menu_toggle_video_item(idm, &force_43); + video_force_resize_set(1); + break; + + case IDM_VGA_INVERT: + ui_menu_toggle_video_item(idm, &invert_display); + break; + + case IDM_VGA_OVERSCAN: + ui_menu_toggle_video_item(idm, &enable_overscan); + video_force_resize_set(1); + break; + + case IDM_CGA_CONTR: + vid_cga_contrast ^= 1; + menu_set_item(idm, vid_cga_contrast); + cgapal_rebuild(); + config_save(); + break; + + case IDM_GRAY_601: + case IDM_GRAY_709: + case IDM_GRAY_AVE: + vid_graytype = (idm - IDM_GRAY_601); + ui_menu_set_radio_item(IDM_GRAY_601, 3, vid_graytype); + device_force_redraw(); + config_save(); + break; + + case IDM_SCREEN_RGB: + case IDM_SCREEN_GRAYSCALE: + case IDM_SCREEN_AMBER: + case IDM_SCREEN_GREEN: + case IDM_SCREEN_WHITE: + vid_grayscale = (idm - IDM_SCREEN_RGB); + ui_menu_set_radio_item(IDM_SCREEN_RGB, 5, vid_grayscale); + device_force_redraw(); + config_save(); + break; + + case IDM_RCTRL_IS_LALT: + rctrl_is_lalt ^= 1; + menu_set_item(idm, rctrl_is_lalt); + config_save(); + break; + +#ifdef ENABLE_LOG_BREAKPOINT + case IDM_LOG_BREAKPOINT: + pclog("---- LOG BREAKPOINT ----\n"); + break; +#endif + +#ifdef ENABLE_LOG_TOGGLES + case IDM_LOG_BUS: + case IDM_LOG_KEYBOARD: + case IDM_LOG_MOUSE: + case IDM_LOG_GAME: + case IDM_LOG_PARALLEL: + case IDM_LOG_SERIAL: + case IDM_LOG_FDC: + case IDM_LOG_FDD: + case IDM_LOG_D86F: + case IDM_LOG_HDC: + case IDM_LOG_HDD: + case IDM_LOG_ZIP: + case IDM_LOG_CDROM: + case IDM_LOG_CDROM_IMAGE: + case IDM_LOG_CDROM_IOCTL: + case IDM_LOG_NETWORK: + case IDM_LOG_NETWORK_DEV: + case IDM_LOG_SOUND_EMU8K: + case IDM_LOG_SOUND_MPU401: + case IDM_LOG_SOUND_DEV: + case IDM_LOG_SCSI_BUS: + case IDM_LOG_SCSI_DISK: + case IDM_LOG_SCSI_DEV: + case IDM_LOG_VOODOO: + ui_menu_set_logging_item(idm, -1); + break; +#endif + +#if 0 + /* FIXME: need to fix these.. */ + case IDM_LOAD: + plat_pause(1); + if (! file_dlg_st(hwnd, IDS_2160, L"", 0) && + (ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051) == IDYES)) { + pc_reload(wopenfilestring); + ResetAllMenus(); + } + plat_pause(0); + break; + + case IDM_SAVE: + plat_pause(1); + if (! file_dlg_st(hwnd, IDS_2160, L"", 1)) { + config_write(wopenfilestring); + } + plat_pause(0); + break; +#endif + } + + return(1); +} diff --git a/src/ui/ui_new_floppy.c b/src/ui/ui_new_floppy.c new file mode 100644 index 0000000..b40877d --- /dev/null +++ b/src/ui/ui_new_floppy.c @@ -0,0 +1,555 @@ +/* + * VARCem Virtual ARchaeological Computer EMulator. + * An emulator of (mostly) x86-based PC systems and devices, + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * spanning the era between 1981 and 1995. + * + * This file is part of the VARCem Project. + * + * Generic code support for the New Floppy Image dialog. + * + * NOTE: Most of this code should be moved to the Floppy image file + * format handlers, and re-integrated with that code. This is + * just the wrong place for it.. + * + * Version: @(#)ui_new_floppy.c 1.0.1 2018/04/28 + * + * Authors: Fred N. van Kempen, + * Miran Grca, + * + * Copyright 2018 Fred N. van Kempen. + * Copyright 2018 Miran Grca. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307 + * USA. + */ +#include +#include +#include +#include +#include +#include "../emu.h" +#include "../random.h" +#include "../disk/zip.h" +#include "../ui/ui.h" +#include "../plat.h" + + +typedef struct { + int8_t hole; + int8_t sides; + int8_t data_rate; + int8_t encoding; + int8_t rpm; + uint8_t tracks; + int8_t sectors; /* for IMG and Japanese FDI only */ + int8_t sector_len; /* for IMG and Japanese FDI only */ + + uint8_t media_desc; + int8_t spc; + int8_t num_fats; + int8_t spfat; + uint8_t root_dir_entries; +} disk_size_t; + + +static const disk_size_t disk_sizes[14] = { + { 0, 1, 2, 1, 0, 40, 8, 2, 0xfe, 2, 2, 1, 112 }, /* 160k */ + { 0, 1, 2, 1, 0, 40, 9, 2, 0xfc, 2, 2, 1, 112 }, /* 180k */ + { 0, 2, 2, 1, 0, 40, 8, 2, 0xff, 2, 2, 1, 112 }, /* 320k */ + { 0, 2, 2, 1, 0, 40, 9, 2, 0xfd, 2, 2, 2, 112 }, /* 360k */ + { 0, 2, 2, 1, 0, 80, 8, 2, 0xfb, 2, 2, 2, 112 }, /* 640k */ + { 0, 2, 2, 1, 0, 80, 9, 2, 0xf9, 2, 2, 3, 112 }, /* 720k */ + { 1, 2, 0, 1, 1, 80, 15, 2, 0xf9, 1, 2, 7, 224 }, /* 1.2M */ + { 1, 2, 0, 1, 1, 77, 8, 3, 0xfe, 1, 2, 2, 192 }, /* 1.25M */ + { 1, 2, 0, 1, 0, 80, 18, 2, 0xf0, 1, 2, 9, 224 }, /* 1.44M */ + { 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 2, 2, 5, 16 }, /* DMF 1024 */ + { 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 4, 2, 3, 16 }, /* DMF 2048 */ + { 2, 2, 3, 1, 0, 80, 36, 2, 0xf0, 2, 2, 9, 240 }, /* 2.88M */ + { 0, 64, 0, 0, 0, 96, 32, 2, 0, 0, 0, 0, 0 }, /* ZIP 100 */ + { 0, 64, 0, 0, 0, 239, 32, 2, 0, 0, 0, 0, 0 } /* ZIP 250 */ +}; + + +/* This function should be moved to the D86F format handler. */ +int +floppy_create_86f(const wchar_t *fn, int8_t ds, int8_t rpm_mode) +{ + const disk_size_t *dp = &disk_sizes[ds]; + uint8_t *empty; + FILE *f; + + uint32_t magic = 0x46423638; + uint16_t version = 0x020B; + uint16_t dflags = 0; + uint16_t tflags = 0; + uint32_t index_hole_pos = 0; + uint32_t tarray[512]; + uint32_t array_size, array_size2; + uint32_t track_base, track_size; + int i; + uint32_t shift = 0; + + dflags = 0; /* Has surface data? - Assume no for now. */ + dflags |= (dp->hole << 1); /* Hole */ + dflags |= ((dp->sides - 1) << 3); /* Sides. */ + dflags |= (0 << 4); /* Write protect? - Assume no for now. */ + dflags |= (rpm_mode << 5); /* RPM mode. */ + dflags |= (0 << 7); /* Has extra bit cells? - Assume no for now. */ + + tflags = dp->data_rate; /* Data rate. */ + tflags |= (dp->encoding << 3); /* Encoding. */ + tflags |= (dp->rpm << 5); /* RPM. */ + + switch (dp->hole) { + case 0: + case 1: + default: + switch(rpm_mode) { + case 1: + array_size = 25250; + break; + case 2: + array_size = 25374; + break; + case 3: + array_size = 25750; + break; + default: + array_size = 25000; + break; + } + break; + case 2: + switch(rpm_mode) { + case 1: + array_size = 50500; + break; + case 2: + array_size = 50750; + break; + case 3: + array_size = 51000; + break; + default: + array_size = 50000; + break; + } + break; + } + + array_size2 = (array_size << 3); + array_size = (array_size2 >> 4) << 1; + if (array_size2 & 15) + array_size += 2; + + f = plat_fopen(fn, L"wb"); + if (f == NULL) + return 0; + + empty = (uint8_t *)malloc(array_size); + memset(tarray, 0x00, 2048); + memset(empty, 0x00, array_size); + + fwrite(&magic, 4, 1, f); + fwrite(&version, 2, 1, f); + fwrite(&dflags, 2, 1, f); + + track_size = array_size + 6; + + track_base = 8 + ((dp->sides == 2) ? 2048 : 1024); + + for (i = 0; i < dp->tracks * dp->sides; i++) + if (dp->tracks <= 43) + shift = 1; + + for (i = 0; i < (dp->tracks * dp->sides) << shift; i++) + tarray[i] = track_base + (i * track_size); + + fwrite(tarray, 1, (dp->sides == 2) ? 2048 : 1024, f); + + for (i = 0; i < (dp->tracks * dp->sides) << shift; i++) { + fwrite(&tflags, 2, 1, f); + fwrite(&index_hole_pos, 4, 1, f); + fwrite(empty, 1, array_size, f); + } + + free(empty); + + fclose(f); + + return 1; +} + + +/* This function should be moved to the Floppy Image format handler. */ +int +floppy_create_image(const wchar_t *fn, int8_t ds, int8_t is_zip, int8_t is_fdi) +{ + const disk_size_t *dp = &disk_sizes[ds]; + uint8_t *empty; + FILE *f; + + uint32_t total_size = 0; + uint32_t total_sectors = 0; + uint32_t sector_bytes = 0; + uint32_t root_dir_bytes = 0; + uint32_t fat_size = 0; + uint32_t fat1_offs = 0; + uint32_t fat2_offs = 0; + uint32_t zero_bytes = 0; + uint16_t base = 0x1000; + + f = plat_fopen(fn, L"wb"); + if (f == NULL) + return 0; + + sector_bytes = (128 << dp->sector_len); + total_sectors = dp->sides * dp->tracks * dp->sectors; + if (total_sectors > ZIP_SECTORS) + total_sectors = ZIP_250_SECTORS; + total_size = total_sectors * sector_bytes; + root_dir_bytes = (dp->root_dir_entries << 5); + fat_size = (dp->spfat * sector_bytes); + fat1_offs = sector_bytes; + fat2_offs = fat1_offs + fat_size; + zero_bytes = fat2_offs + fat_size + root_dir_bytes; + + /* FIXME: is_zip is _always_ 0 ... */ + if (!is_zip && is_fdi) { + empty = (uint8_t *)malloc(base); + memset(empty, 0x00, base); + + *(uint32_t *) &(empty[0x08]) = (uint32_t)base; + *(uint32_t *) &(empty[0x0C]) = total_size; + *(uint16_t *) &(empty[0x10]) = (uint16_t)sector_bytes; + *(uint8_t *) &(empty[0x14]) = (uint8_t)dp->sectors; + *(uint8_t *) &(empty[0x18]) = (uint8_t)dp->sides; + *(uint8_t *) &(empty[0x1C]) = (uint8_t)dp->tracks; + + fwrite(empty, 1, base, f); + + free(empty); + } + + empty = (uint8_t *)malloc(total_size); + memset(empty, 0x00, zero_bytes); + + if (!is_zip) { + memset(empty + zero_bytes, 0xF6, total_size - zero_bytes); + + empty[0x00] = 0xEB; /* Jump to make MS-DOS happy. */ + empty[0x01] = 0x58; + empty[0x02] = 0x90; + + empty[0x03] = 0x38; /* '86BOX5.0' OEM ID. */ + empty[0x04] = 0x36; + empty[0x05] = 0x42; + empty[0x06] = 0x4F; + empty[0x07] = 0x58; + empty[0x08] = 0x35; + empty[0x09] = 0x2E; + empty[0x0A] = 0x30; + + *(uint16_t *) &(empty[0x0B]) = (uint16_t) sector_bytes; + *(uint8_t *) &(empty[0x0D]) = (uint8_t) dp->spc; + *(uint16_t *) &(empty[0x0E]) = (uint16_t) 1; + *(uint8_t *) &(empty[0x10]) = (uint8_t) dp->num_fats; + *(uint16_t *) &(empty[0x11]) = (uint16_t) dp->root_dir_entries; + *(uint16_t *) &(empty[0x13]) = (uint16_t) total_sectors; + *(uint8_t *) &(empty[0x15]) = (uint8_t) dp->media_desc; + *(uint16_t *) &(empty[0x16]) = (uint16_t) dp->spfat; + *(uint8_t *) &(empty[0x18]) = (uint8_t) dp->sectors; + *(uint8_t *) &(empty[0x1A]) = (uint8_t) dp->sides; + + empty[0x26] = 0x29; /* ')' followed by randomly-generated volume serial number. */ + empty[0x27] = random_generate(); + empty[0x28] = random_generate(); + empty[0x29] = random_generate(); + empty[0x2A] = random_generate(); + + memset(&(empty[0x2B]), 0x20, 11); + + empty[0x36] = 'F'; + empty[0x37] = 'A'; + empty[0x38] = 'T'; + empty[0x39] = '1'; + empty[0x3A] = '2'; + empty[0x3B] = ' '; + empty[0x3C] = ' '; + empty[0x3D] = ' '; + + empty[0x1FE] = 0x55; + empty[0x1FF] = 0xAA; + + empty[fat1_offs + 0x00] = empty[fat2_offs + 0x00] = empty[0x15]; + empty[fat1_offs + 0x01] = empty[fat2_offs + 0x01] = 0xFF; + empty[fat1_offs + 0x02] = empty[fat2_offs + 0x02] = 0xFF; + } + + fwrite(empty, 1, total_size, f); + + free(empty); + + fclose(f); + + return 1; +} + + +/* This function should be moved to the ZIP drive module. */ +int +zip_create_image(const wchar_t *fn, int8_t ds, int8_t is_zdi) +{ + const disk_size_t *dp = &disk_sizes[ds]; + uint8_t *empty; + FILE *f; + + uint32_t total_size = 0; + uint32_t total_sectors = 0; + uint32_t sector_bytes = 0; + uint32_t root_dir_bytes = 0; + uint32_t fat_size = 0; + uint32_t fat1_offs = 0; + uint32_t fat2_offs = 0; + uint32_t zero_bytes = 0; + uint16_t base = 0x1000; + uint32_t pbar_max = 0; + uint32_t i; + + f = plat_fopen(fn, L"wb"); + if (f == NULL) + return 0; + + sector_bytes = (128 << dp->sector_len); + total_sectors = dp->sides * dp->tracks * dp->sectors; + if (total_sectors > ZIP_SECTORS) + total_sectors = ZIP_250_SECTORS; + total_size = total_sectors * sector_bytes; + root_dir_bytes = (dp->root_dir_entries << 5); + fat_size = (dp->spfat * sector_bytes); + fat1_offs = sector_bytes; + fat2_offs = fat1_offs + fat_size; + zero_bytes = fat2_offs + fat_size + root_dir_bytes; + + pbar_max = total_size; + if (is_zdi) + pbar_max += base; + pbar_max >>= 11; + pbar_max--; + + //FIXME: we will implement a ProgressBar handler. --FvK +#if 0 + h = GetDlgItem(hwnd, IDC_COMBO_RPM_MODE); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + h = GetDlgItem(hwnd, IDT_1751); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + h = GetDlgItem(hwnd, IDC_PBAR_IMG_CREATE); + SendMessage(h, PBM_SETRANGE32, (WPARAM) 0, (LPARAM) pbar_max); + SendMessage(h, PBM_SETPOS, (WPARAM) 0, (LPARAM) 0); + EnableWindow(h, TRUE); + ShowWindow(h, SW_SHOW); + h = GetDlgItem(hwnd, IDT_1757); + EnableWindow(h, TRUE); + ShowWindow(h, SW_SHOW); + + h = GetDlgItem(hwnd, IDC_PBAR_IMG_CREATE); +#endif + pbar_max++; + + if (is_zdi) { + empty = (uint8_t *)malloc(base); + memset(empty, 0x00, base); + + *(uint32_t *) &(empty[0x08]) = (uint32_t) base; + *(uint32_t *) &(empty[0x0C]) = total_size; + *(uint16_t *) &(empty[0x10]) = (uint16_t) sector_bytes; + *(uint8_t *) &(empty[0x14]) = (uint8_t) dp->sectors; + *(uint8_t *) &(empty[0x18]) = (uint8_t) dp->sides; + *(uint8_t *) &(empty[0x1C]) = (uint8_t) dp->tracks; + + fwrite(empty, 1, 2048, f); +#if 0 + SendMessage(h, PBM_SETPOS, (WPARAM) 1, (LPARAM) 0); +#endif + + fwrite(&empty[0x0800], 1, 2048, f); + + free(empty); + +#if 0 + SendMessage(h, PBM_SETPOS, (WPARAM) 2, (LPARAM) 0); +#endif + pbar_max -= 2; + } + + empty = (uint8_t *)malloc(total_size); + memset(empty, 0x00, zero_bytes); + + if (total_sectors == ZIP_SECTORS) { + /* ZIP 100 */ + /* MBR */ + *(uint64_t *) &(empty[0x0000]) = 0x0000030000025245LL; + *(uint64_t *) &(empty[0x0008]) = 0x0000000000000000LL; + *(uint64_t *) &(empty[0x0010]) = 0x0900E90300000100LL; + *(uint64_t *) &(empty[0x0018]) = 0x726F70726F430100LL; + *(uint64_t *) &(empty[0x0020]) = 0x202D206E6F697461LL; + *(uint64_t *) &(empty[0x0028]) = 0x30392F33322F3131LL; + + *(uint64_t *) &(empty[0x01AE]) = 0x0116010100E905E2LL; + *(uint64_t *) &(empty[0x01B6]) = 0x226BEDCE014E0135LL; + *(uint64_t *) &(empty[0x01BE]) = 0x5E203F0600010180LL; + *(uint64_t *) &(empty[0x01C6]) = 0x0002FE6000000020LL; + + *(uint16_t *) &(empty[0x01FE]) = 0xAA55; + + /* 4 sectors filled with 0xFA */ + memset(&(empty[0x0200]), 0xFA, 0x0800); + + /* Iomega_Reserved sector */ + *(uint64_t *) &(empty[0x0A00]) = 0x0500000000004D50LL; + *(uint64_t *) &(empty[0x0A08]) = 0xAFF9010051060100LL; + + *(uint64_t *) &(empty[0x0A30]) = 0x525F6167656D6F49LL; + *(uint64_t *) &(empty[0x0A38]) = 0x0064657672657365LL; + + *(uint64_t *) &(empty[0x0A54]) = 0x03000000AFF90100LL; + + /* 26 sectors filled with 0x48 */ + memset(&(empty[0x0C00]), 0x48, 0x3400); + + /* Boot sector */ + *(uint64_t *) &(empty[0x4000]) = 0x584F4236389058EBLL; + *(uint64_t *) &(empty[0x4008]) = 0x0001040200302E35LL; + *(uint64_t *) &(empty[0x4010]) = 0x00C0F80000020002LL; + *(uint64_t *) &(empty[0x4018]) = 0x0000002000400020LL; + *(uint32_t *) &(empty[0x4020]) = 0x0002FFE0; + *(uint16_t *) &(empty[0x4024]) = 0x0080; + + empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */ + empty[0x4027] = random_generate(); + empty[0x4028] = random_generate(); + empty[0x4029] = random_generate(); + empty[0x402A] = random_generate(); + + memset(&(empty[0x402B]), 0x00, 0x000B); + memset(&(empty[0x4036]), 0x20, 0x0008); + + empty[0x4036] = 'F'; + empty[0x4037] = 'A'; + empty[0x4038] = 'T'; + empty[0x4039] = '1'; + empty[0x403A] = '6'; + + empty[0x41FE] = 0x55; + empty[0x41FF] = 0xAA; + + empty[0x4200] = empty[0x1C200] = empty[0x4015]; + empty[0x4201] = empty[0x1C201] = 0xFF; + empty[0x4202] = empty[0x1C202] = 0xFF; + empty[0x4203] = empty[0x1C203] = 0xFF; + + /* Root directory = 0x34200 + Data = 0x38200 */ + } else { + /* ZIP 250 */ + /* MBR */ + *(uint64_t *) &(empty[0x0000]) = 0x2054524150492EEBLL; + *(uint64_t *) &(empty[0x0008]) = 0x3930302065646F63LL; + *(uint64_t *) &(empty[0x0010]) = 0x67656D6F49202D20LL; + *(uint64_t *) &(empty[0x0018]) = 0x726F70726F432061LL; + *(uint64_t *) &(empty[0x0020]) = 0x202D206E6F697461LL; + *(uint64_t *) &(empty[0x0028]) = 0x30392F33322F3131LL; + + *(uint64_t *) &(empty[0x01AE]) = 0x0116010100E900E9LL; + *(uint64_t *) &(empty[0x01B6]) = 0x2E32A7AC014E0135LL; + + *(uint64_t *) &(empty[0x01EE]) = 0xEE203F0600010180LL; + *(uint64_t *) &(empty[0x01F6]) = 0x000777E000000020LL; + *(uint16_t *) &(empty[0x01FE]) = 0xAA55; + + /* 31 sectors filled with 0x48 */ + memset(&(empty[0x0200]), 0x48, 0x3E00); + + /* The second sector begins with some strange data + in my reference image. */ + *(uint64_t *) &(empty[0x0200]) = 0x3831393230334409LL; + *(uint64_t *) &(empty[0x0208]) = 0x6A57766964483130LL; + *(uint64_t *) &(empty[0x0210]) = 0x3C3A34676063653FLL; + *(uint64_t *) &(empty[0x0218]) = 0x586A56A8502C4161LL; + *(uint64_t *) &(empty[0x0220]) = 0x6F2D702535673D6CLL; + *(uint64_t *) &(empty[0x0228]) = 0x255421B8602D3456LL; + *(uint64_t *) &(empty[0x0230]) = 0x577B22447B52603ELL; + *(uint64_t *) &(empty[0x0238]) = 0x46412CC871396170LL; + *(uint64_t *) &(empty[0x0240]) = 0x704F55237C5E2626LL; + *(uint64_t *) &(empty[0x0248]) = 0x6C7932C87D5C3C20LL; + *(uint64_t *) &(empty[0x0250]) = 0x2C50503E47543D6ELL; + *(uint64_t *) &(empty[0x0258]) = 0x46394E807721536ALL; + *(uint64_t *) &(empty[0x0260]) = 0x505823223F245325LL; + *(uint64_t *) &(empty[0x0268]) = 0x365C79B0393B5B6ELL; + + /* Boot sector */ + *(uint64_t *) &(empty[0x4000]) = 0x584F4236389058EBLL; + *(uint64_t *) &(empty[0x4008]) = 0x0001080200302E35LL; + *(uint64_t *) &(empty[0x4010]) = 0x00EFF80000020002LL; + *(uint64_t *) &(empty[0x4018]) = 0x0000002000400020LL; + *(uint32_t *) &(empty[0x4020]) = 0x000777E0; + *(uint16_t *) &(empty[0x4024]) = 0x0080; + + empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */ + empty[0x4027] = random_generate(); + empty[0x4028] = random_generate(); + empty[0x4029] = random_generate(); + empty[0x402A] = random_generate(); + + memset(&(empty[0x402B]), 0x00, 0x000B); + memset(&(empty[0x4036]), 0x20, 0x0008); + + empty[0x4036] = 'F'; + empty[0x4037] = 'A'; + empty[0x4038] = 'T'; + empty[0x4039] = '1'; + empty[0x403A] = '6'; + + empty[0x41FE] = 0x55; + empty[0x41FF] = 0xAA; + + empty[0x4200] = empty[0x22000] = empty[0x4015]; + empty[0x4201] = empty[0x22001] = 0xFF; + empty[0x4202] = empty[0x22002] = 0xFF; + empty[0x4203] = empty[0x22003] = 0xFF; + + /* Root directory = 0x3FE00 + Data = 0x38200 */ + } + + for (i = 0; i < pbar_max; i++) { + fwrite(&empty[i << 11], 1, 2048, f); +#if 0 + SendMessage(h, PBM_SETPOS, (WPARAM) i + 2, (LPARAM) 0); +#endif + } + + free(empty); + + fclose(f); + + return 1; +} diff --git a/src/ui/ui_resource.h b/src/ui/ui_resource.h new file mode 100644 index 0000000..fedebf5 --- /dev/null +++ b/src/ui/ui_resource.h @@ -0,0 +1,177 @@ +/* + * VARCem Virtual ARchaeological Computer EMulator. + * An emulator of (mostly) x86-based PC systems and devices, + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * spanning the era between 1981 and 1995. + * + * This file is part of the VARCem Project. + * + * Platform-independent resource identifiers. + * + * Version: @(#)ui_resource.h 1.0.2 2018/04/29 + * + * Authors: Fred N. van Kempen, + * Miran Grca, + * Sarah Walker, + * + * Copyright 2018 Fred N. van Kempen. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the entire + * above notice, this list of conditions and the following + * disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names + * of its contributors may be used to endorse or promote + * products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef EMU_UI_RESOURCE_H +# define EMU_UI_RESOURCE_H + + +/* ACTION menu. */ +#define IDM_ACTION 40100 +#define IDM_RESET_HARD (IDM_ACTION+1) +#define IDM_RESET (IDM_ACTION+2) +#define IDM_CAE (IDM_ACTION+3) +#define IDM_CAB (IDM_ACTION+4) +#define IDM_PAUSE (IDM_ACTION+5) +#define IDM_EXIT (IDM_ACTION+99) /* fixed on WxWidgets */ + +/* VIEW menu. */ +#define IDM_VIEW 40200 +#define IDM_RESIZE (IDM_VIEW+1) +#define IDM_REMEMBER (IDM_VIEW+2) +#define IDM_RENDER (IDM_VIEW+10) +# define IDM_VID_DDRAW (IDM_RENDER+1) +# define IDM_VID_D3D (IDM_RENDER+2) +# define IDM_VID_VNC (IDM_RENDER+3) +# define IDM_VID_RDP (IDM_RENDER+4) +#define IDM_SCALE (IDM_VIEW+20) +# define IDM_SCALE_1 (IDM_SCALE+1) +# define IDM_SCALE_2 (IDM_SCALE+2) +# define IDM_SCALE_3 (IDM_SCALE+3) +# define IDM_SCALE_4 (IDM_SCALE+4) +#define IDM_FULLSCREEN (IDM_VIEW+30) +#define IDM_FULL_STRETCH (IDM_FULLSCREEN+1) +# define IDM_STRETCH (IDM_FULLSCREEN+2) +# define IDM_STRETCH_43 (IDM_FULLSCREEN+3) +# define IDM_STRETCH_SQ (IDM_FULLSCREEN+4) +# define IDM_STRETCH_INT (IDM_FULLSCREEN+5) +# define IDM_STRETCH_KEEP (IDM_FULLSCREEN+6) +#define IDM_VGA_SETTINGS (IDM_VIEW+40) +# define IDM_VGA_INVERT (IDM_VGA_SETTINGS+1) +# define IDM_VGA_OVERSCAN (IDM_VGA_SETTINGS+2) +# define IDM_VGA_SCREEN (IDM_VIEW+50) +# define IDM_SCREEN_RGB (IDM_VGA_SCREEN+1) +# define IDM_SCREEN_GRAYSCALE (IDM_VGA_SCREEN+2) +# define IDM_SCREEN_AMBER (IDM_VGA_SCREEN+3) +# define IDM_SCREEN_GREEN (IDM_VGA_SCREEN+4) +# define IDM_SCREEN_WHITE (IDM_VGA_SCREEN+5) +#define IDM_VGA_GRAYSCALE (IDM_VIEW+60) +# define IDM_GRAY_601 (IDM_VGA_GRAYSCALE+1) +# define IDM_GRAY_709 (IDM_VGA_GRAYSCALE+2) +# define IDM_GRAY_AVE (IDM_VGA_GRAYSCALE+3) +# define IDM_FORCE_43 (IDM_VIEW+3) +# define IDM_CGA_CONTR (IDM_VIEW+4) +#define IDM_RCTRL_IS_LALT (IDM_VIEW+5) +#define IDM_UPDATE_ICONS (IDM_VIEW+6) + +/* TOOLS menu. */ +#define IDM_TOOLS 40300 +#define IDM_SETTINGS (IDM_TOOLS+1) +#define IDM_LOAD (IDM_TOOLS+2) +#define IDM_SAVE (IDM_TOOLS+3) +#define IDM_LOGGING (IDM_TOOLS+10) +# define IDM_LOG_BEGIN (IDM_LOGGING+1) +# define IDM_LOG_BUS (IDM_LOG_BEGIN+0) +# define IDM_LOG_KEYBOARD (IDM_LOG_BEGIN+1) +# define IDM_LOG_MOUSE (IDM_LOG_BEGIN+2) +# define IDM_LOG_GAME (IDM_LOG_BEGIN+3) +# define IDM_LOG_PARALLEL (IDM_LOG_BEGIN+4) +# define IDM_LOG_SERIAL (IDM_LOG_BEGIN+5) +# define IDM_LOG_FDC (IDM_LOG_BEGIN+6) +# define IDM_LOG_FDD (IDM_LOG_BEGIN+7) +# define IDM_LOG_D86F (IDM_LOG_BEGIN+8) +# define IDM_LOG_HDC (IDM_LOG_BEGIN+9) +# define IDM_LOG_HDD (IDM_LOG_BEGIN+10) +# define IDM_LOG_ZIP (IDM_LOG_BEGIN+11) +# define IDM_LOG_CDROM (IDM_LOG_BEGIN+12) +# define IDM_LOG_CDROM_IMAGE (IDM_LOG_BEGIN+13) +# define IDM_LOG_CDROM_IOCTL (IDM_LOG_BEGIN+14) +# define IDM_LOG_NETWORK (IDM_LOG_BEGIN+15) +# define IDM_LOG_NETWORK_DEV (IDM_LOG_BEGIN+16) +# define IDM_LOG_SOUND_EMU8K (IDM_LOG_BEGIN+17) +# define IDM_LOG_SOUND_MPU401 (IDM_LOG_BEGIN+18) +# define IDM_LOG_SOUND_DEV (IDM_LOG_BEGIN+19) +# define IDM_LOG_SCSI_BUS (IDM_LOG_BEGIN+20) +# define IDM_LOG_SCSI_DISK (IDM_LOG_BEGIN+21) +# define IDM_LOG_SCSI_DEV (IDM_LOG_BEGIN+22) +# define IDM_LOG_VOODOO (IDM_LOG_BEGIN+23) +# define IDM_LOG_END (IDM_LOG_BEGIN+24) +# define IDM_LOG_BREAKPOINT (IDM_LOGGING+99) +#define IDM_STATUS (IDM_TOOLS+4) +#define IDM_SCREENSHOT (IDM_TOOLS+5) + +/* HELP menu. */ +#define IDM_HELP 40400 +# define IDM_ABOUT (IDM_HELP+1) + +/* + * Status Bar commands. + * + * We need 7 bits for CDROM (2 bits ID and 5 bits for host drive), + * and 5 bits for Removable Disks (5 bits for ID), so we use an + * 8bit (256 entries) space for these devices. + */ +#define IDM_SBAR 40960 /* 0x0a000 */ + +#define IDM_FLOPPY_IMAGE_NEW (IDM_SBAR + 0x0000) +#define IDM_FLOPPY_IMAGE_EXISTING (IDM_SBAR + 0x0100) +#define IDM_FLOPPY_IMAGE_EXISTING_WP (IDM_SBAR + 0x0200) +#define IDM_FLOPPY_EXPORT_TO_86F (IDM_SBAR + 0x0300) +#define IDM_FLOPPY_EJECT (IDM_SBAR + 0x0400) + +#define IDM_CDROM_MUTE (IDM_SBAR + 0x0800) +#define IDM_CDROM_EMPTY (IDM_SBAR + 0x0900) +#define IDM_CDROM_RELOAD (IDM_SBAR + 0x0a00) +#define IDM_CDROM_IMAGE (IDM_SBAR + 0x0b00) +#define IDM_CDROM_HOST_DRIVE (IDM_SBAR + 0x0c00) + +#define IDM_ZIP_IMAGE_NEW (IDM_SBAR + 0x1000) +#define IDM_ZIP_IMAGE_EXISTING (IDM_SBAR + 0x1100) +#define IDM_ZIP_IMAGE_EXISTING_WP (IDM_SBAR + 0x1200) +#define IDM_ZIP_EJECT (IDM_SBAR + 0x1300) +#define IDM_ZIP_RELOAD (IDM_SBAR + 0x1400) + +#define IDM_RDISK_EJECT (IDM_SBAR + 0x1800) +#define IDM_RDISK_RELOAD (IDM_SBAR + 0x1900) +#define IDM_RDISK_SEND_CHANGE (IDM_SBAR + 0x1a00) +#define IDM_RDISK_IMAGE (IDM_SBAR + 0x1b00) +#define IDM_RDISK_IMAGE_WP (IDM_SBAR + 0x1c00) + +#define IDM_SOUND (IDM_SBAR + 8192) + + +#endif /*EMU_UI_RESOURCE_H*/ diff --git a/src/ui/ui_stbar.c b/src/ui/ui_stbar.c new file mode 100644 index 0000000..70036f8 --- /dev/null +++ b/src/ui/ui_stbar.c @@ -0,0 +1,1081 @@ +/* + * VARCem Virtual ARchaeological Computer EMulator. + * An emulator of (mostly) x86-based PC systems and devices, + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * spanning the era between 1981 and 1995. + * + * This file is part of the VARCem Project. + * + * Common UI support functions for the Status Bar module. + * + * Version: @(#)ui_stbar.c 1.0.1 2018/04/29 + * + * Authors: Fred N. van Kempen, + * Miran Grca, + * + * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2016-2018 Miran Grca. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307 + * USA. + */ +#include +#include +#include +#include +#include +#include "../emu.h" +#include "../config.h" +#include "../cpu/cpu.h" +#include "../device.h" +#include "../machine/machine.h" +#include "../floppy/fdd.h" +#include "../disk/hdd.h" +#include "../disk/hdc.h" +#include "../disk/zip.h" +#include "../cdrom/cdrom.h" +#include "../cdrom/cdrom_image.h" +#include "../cdrom/cdrom_null.h" +#include "../scsi/scsi.h" +#include "../scsi/scsi_disk.h" +#include "../network/network.h" +#include "../video/video.h" +#include "../sound/sound.h" +#include "../plat.h" +#include "ui.h" +#include "ui_resource.h" + + +static int *sb_widths; +static int *sb_flags; +static int *sb_tags; +static int *sb_icons; +static wchar_t **sb_tips; + +static int sb_parts = 0; +static int sb_ready = 0; + + +/* Find the part in which a given tag lives. */ +static int +find_tag(int tag) +{ + int part; + + if (sb_tags == NULL) return(-1); + + for (part = 0; part < sb_parts; part++) { + if (sb_tags[part] == tag) + return(part); + } + + return(-1); +} + + +/* Enable or disable a given status bar menu item. */ +void +ui_sb_menu_enable_item(int tag, int idm, int val) +{ + int part; + + /* Find the status bar part for this tag. */ + if ((part = find_tag(tag)) == -1) return; + + sb_menu_enable_item(part, idm, val); +} + + +/* Set (check) or clear (uncheck) a given status bar menu item. */ +void +ui_sb_menu_set_item(int tag, int idm, int val) +{ + int part; + + /* Find the status bar part for this tag. */ + if ((part = find_tag(tag)) == -1) return; + + sb_menu_set_item(part, idm, val); +} + + +/* Update one of the icons after activity. */ +// FIXME: implement a timer on each icon! +void +ui_sb_icon_update(int tag, int active) +{ + int part; + + if (! update_icons) return; + + if (((tag & 0xf0) >= SB_TEXT) || !sb_ready || (sb_parts == 0)) return; + + /* Find the status bar part for this tag. */ + if ((part = find_tag(tag)) == -1) return; + + if ((sb_flags[part] & 1) != active) { + sb_flags[part] &= ~1; + sb_flags[part] |= active; + + sb_icons[part] &= ~257; + sb_icons[part] |= sb_flags[part]; + + sb_set_icon(part, sb_icons[part]); + } +} + + +/* Set the 'active' state for an icon. */ +void +ui_sb_icon_state(int tag, int state) +{ + int part; + + if (((tag & 0xf0) >= SB_HDD) || !sb_ready || + (sb_parts == 0) || (sb_flags == NULL) || (sb_icons == NULL)) return; + + /* Find the status bar part for this tag. */ + if ((part = find_tag(tag)) == -1) return; + + sb_flags[part] &= ~256; + sb_flags[part] |= state ? 256 : 0; + + sb_icons[part] &= ~257; + sb_icons[part] |= sb_flags[part]; + + sb_set_icon(part, sb_icons[part]); +} + + +/* Set the 'text' field with a given (Unicode) string. */ +void +ui_sb_text_set_w(const wchar_t *str) +{ + int part; + + if (!sb_ready || (sb_parts == 0)) return; + + /* Find the status bar part for this tag. */ + if ((part = find_tag(SB_TEXT)) == -1) return; + + sb_set_text(part, str); +} + + +/* Set the 'text' field with a given (ANSI) string. */ +void +ui_sb_text_set(const char *str) +{ + static wchar_t temp[512]; + + mbstowcs(temp, str, sizeof_w(temp)); + + ui_sb_text_set_w(temp); +} + + +/* Update the 'tool tip' text on one of the parts. */ +void +ui_sb_tip_update(int tag) +{ + wchar_t tip[512]; + wchar_t temp[512]; + wchar_t *str; + const char *stransi; + int bus, drive, id; + int type, part; + + if (sb_tags == NULL) return; + + /* Find the status bar part for this tag. */ + if ((part = find_tag(tag)) == -1) return; + + switch(tag & 0xf0) { + case SB_FLOPPY: + drive = sb_tags[part] & 0x0f; + stransi = fdd_getname(fdd_get_type(drive)); + mbstowcs(temp, stransi, sizeof_w(temp)); + if (wcslen(floppyfns[drive]) == 0) { + _swprintf(tip, plat_get_string(IDS_2158), + drive+1, temp, plat_get_string(IDS_2057)); + } else { + _swprintf(tip, plat_get_string(IDS_2158), + drive+1, temp, floppyfns[drive]); + } + break; + + case SB_CDROM: + drive = sb_tags[part] & 0x0f; + bus = cdrom_drives[drive].bus_type; + id = IDS_4352 + (bus - 1); + str = plat_get_string(id); + if (cdrom_drives[drive].host_drive == 200) { + if (wcslen(cdrom_image[drive].image_path) == 0) { + _swprintf(tip, plat_get_string(IDS_5120), + drive+1, str, plat_get_string(IDS_2057)); + } else { + _swprintf(tip, plat_get_string(IDS_5120), + drive+1, str, cdrom_image[drive].image_path); + } + } else if ((cdrom_drives[drive].host_drive >= 'A') && + (cdrom_drives[drive].host_drive <= 'Z')) { + _swprintf(temp, plat_get_string(IDS_2058), + cdrom_drives[drive].host_drive & ~0x20); + _swprintf(tip, plat_get_string(IDS_5120), + drive+1, str, temp); + } else { + _swprintf(tip, plat_get_string(IDS_5120), + drive+1, str, plat_get_string(IDS_2057)); + } + break; + + case SB_ZIP: + drive = sb_tags[part] & 0x0f; + type = zip_drives[drive].is_250 ? 250 : 100; + if (wcslen(zip_drives[drive].image_path) == 0) { + _swprintf(tip, plat_get_string(IDS_2177), + drive+1, type, plat_get_string(IDS_2057)); + } else { + _swprintf(tip, plat_get_string(IDS_2177), + drive+1, type, zip_drives[drive].image_path); + } + break; + + case SB_RDISK: + drive = sb_tags[part] & 0x1f; + if (wcslen(hdd[drive].fn) == 0) { + _swprintf(tip, plat_get_string(IDS_4115), + drive, plat_get_string(IDS_2057)); + } else { + _swprintf(tip, plat_get_string(IDS_4115), + drive, hdd[drive].fn); + } + break; + + case SB_HDD: + bus = sb_tags[part] & 0x0f; + id = IDS_4352 + (bus - 1); + str = plat_get_string(id); + _swprintf(tip, plat_get_string(IDS_4096), str); + break; + + case SB_NETWORK: + _swprintf(tip, plat_get_string(IDS_2069)); + break; + + case SB_SOUND: + _swprintf(tip, plat_get_string(IDS_2068)); + break; + + default: + break; + } + + if (sb_tips[part] != NULL) + free(sb_tips[part]); + + sb_tips[part] = (wchar_t *)malloc(sizeof(wchar_t) * (wcslen(tip) + 1)); + wcscpy(sb_tips[part], tip); + + sb_set_tooltip(part, sb_tips[part]); +} + + +void +ui_sb_tip_destroy(void) +{ + int part; + + if ((sb_parts == 0) || (sb_tips == NULL)) return; + + for (part = 0; part < sb_parts; part++) { + if (sb_tips[part] != NULL) + free(sb_tips[part]); + } + + free(sb_tips); + + sb_tips = NULL; +} + + +/* Create the "Floppy drive" menu. */ +static void +menu_floppy(int part, int drive) +{ + sb_menu_add_item(part, IDM_FLOPPY_IMAGE_NEW | drive, + plat_get_string(IDS_2161)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_FLOPPY_IMAGE_EXISTING | drive, + plat_get_string(IDS_2162)); + sb_menu_add_item(part, IDM_FLOPPY_IMAGE_EXISTING_WP | drive, + plat_get_string(IDS_2163)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_FLOPPY_EXPORT_TO_86F | drive, + plat_get_string(IDS_2172)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_FLOPPY_EJECT | drive, + plat_get_string(IDS_2164)); + + if (floppyfns[drive][0] == L'\0') { + sb_menu_enable_item(part, IDM_FLOPPY_EJECT | drive, 0); + sb_menu_enable_item(part, IDM_FLOPPY_EXPORT_TO_86F | drive, 0); + } +} + + +/* Create the "CD-ROM drive" menu. */ +static void +menu_cdrom(int part, int drive) +{ + wchar_t temp[64]; + int i; + + sb_menu_add_item(part, IDM_CDROM_MUTE | drive, + plat_get_string(IDS_2165)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_CDROM_EMPTY | drive, + plat_get_string(IDS_2166)); + sb_menu_add_item(part, IDM_CDROM_RELOAD | drive, + plat_get_string(IDS_2167)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_CDROM_IMAGE | drive, + plat_get_string(IDS_2168)); + + if (host_cdrom_drive_available_num == 0) { + if ((cdrom_drives[drive].host_drive >= 'A') && + (cdrom_drives[drive].host_drive <= 'Z')) { + cdrom_drives[drive].host_drive = 0; + } + + goto check_menu_items; + } else { + if ((cdrom_drives[drive].host_drive >= 'A') && + (cdrom_drives[drive].host_drive <= 'Z')) { + if (! host_cdrom_drive_available[cdrom_drives[drive].host_drive - 'A']) { + cdrom_drives[drive].host_drive = 0; + } + } + } + + sb_menu_add_item(part, -1, NULL); + + for (i = 3; i < 26; i++) { + _swprintf(temp, L"Host CD/DVD Drive (%c:)", i+'A'); + if (host_cdrom_drive_available[i]) + sb_menu_add_item(part, IDM_CDROM_HOST_DRIVE | (i << 3)|drive, temp); + } + +check_menu_items: + if (! cdrom_drives[drive].sound_on) + sb_menu_set_item(part, IDM_CDROM_MUTE | drive, 1); + + if (cdrom_drives[drive].host_drive == 200) + sb_menu_set_item(part, IDM_CDROM_IMAGE | drive, 1); + else + if ((cdrom_drives[drive].host_drive >= 'A') && + (cdrom_drives[drive].host_drive <= 'Z')) { + sb_menu_set_item(part, IDM_CDROM_HOST_DRIVE | drive | + ((cdrom_drives[drive].host_drive - 'A') << 3), 1); + } else { + cdrom_drives[drive].host_drive = 0; + sb_menu_set_item(part, IDM_CDROM_EMPTY | drive, 1); + } +} + + +/* Create the "ZIP drive" menu. */ +static void +menu_zip(int part, int drive) +{ + sb_menu_add_item(part, IDM_ZIP_IMAGE_NEW | drive, + plat_get_string(IDS_2161)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_ZIP_IMAGE_EXISTING | drive, + plat_get_string(IDS_2162)); + sb_menu_add_item(part, IDM_ZIP_IMAGE_EXISTING_WP | drive, + plat_get_string(IDS_2163)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_ZIP_EJECT | drive, plat_get_string(IDS_2164)); + sb_menu_add_item(part, IDM_ZIP_RELOAD | drive, plat_get_string(IDS_2167)); + + if (zip_drives[drive].image_path[0] == L'\0') { + sb_menu_enable_item(part, IDM_ZIP_EJECT | drive, 0); + sb_menu_enable_item(part, IDM_ZIP_RELOAD | drive, 1); + } else { + sb_menu_enable_item(part, IDM_ZIP_EJECT | drive, 1); + sb_menu_enable_item(part, IDM_ZIP_RELOAD | drive, 0); + } +} + + +/* Create the "Removable Media" menu. */ +static void +menu_remov(int part, int drive) +{ + sb_menu_add_item(part, IDM_RDISK_EJECT | drive, + plat_get_string(IDS_2164)); + sb_menu_add_item(part, IDM_RDISK_RELOAD | drive, + plat_get_string(IDS_2167)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_RDISK_SEND_CHANGE | drive, + plat_get_string(IDS_2142)); + sb_menu_add_item(part, -1, NULL); + sb_menu_add_item(part, IDM_RDISK_IMAGE | drive, + plat_get_string(IDS_2168)); + sb_menu_add_item(part, IDM_RDISK_IMAGE_WP | drive, + plat_get_string(IDS_2169)); +} + + +/* Initialize or update the entire status bar. */ +void +ui_sb_update(void) +{ + int c_st506, c_esdi, c_scsi; + int c_ide_pio, c_ide_dma; + int do_net, edge = 0; + int drive, part; + int hdint; + const char *hdc; + + sb_ready = 0; + + /* First, remove any existing parts of the status bar. */ + if (sb_parts > 0) { + /* Clear all the current icons from the status bar. */ + for (part = 0; part < sb_parts; part++) + sb_set_icon(part, -1); + + /* Reset the status bar to 0 parts. */ + sb_setup(0, NULL); + + if (sb_widths != NULL) + free(sb_widths); + if (sb_tags != NULL) + free(sb_tags); + if (sb_icons != NULL) + free(sb_icons); + if (sb_flags != NULL) + free(sb_flags); + + /* Destroy all existing tool tips. */ + ui_sb_tip_destroy(); + + /* Destroy all current menus. */ + sb_menu_destroy(); + } + + /* OK, all cleaned up. */ + sb_parts = 0; + + /* Calculate the number of part classes. */ + hdint = (machines[machine].flags & MACHINE_HDC) ? 1 : 0; + c_st506 = hdd_count(HDD_BUS_ST506); + c_esdi = hdd_count(HDD_BUS_ESDI); + c_ide_pio = hdd_count(HDD_BUS_IDE_PIO_ONLY); + c_ide_dma = hdd_count(HDD_BUS_IDE_PIO_AND_DMA); + c_scsi = hdd_count(HDD_BUS_SCSI); + do_net = network_available(); + + for (drive = 0; drive < FDD_NUM; drive++) { + if (fdd_get_type(drive) != 0) + sb_parts++; + } + + /* Get name of current HDC. */ + hdc = hdc_get_internal_name(hdc_type); + + for (drive = 0; drive < CDROM_NUM; drive++) { + /* Could be Internal or External IDE.. */ + if (((cdrom_drives[drive].bus_type==CDROM_BUS_ATAPI_PIO_ONLY) && + (cdrom_drives[drive].bus_type==CDROM_BUS_ATAPI_PIO_AND_DMA)) && + !(hdint || !strncmp(hdc, "ide", 3) || !strncmp(hdc, "xta", 3))) { + continue; + } + + if ((cdrom_drives[drive].bus_type == CDROM_BUS_SCSI) && (scsi_card == 0)) { + continue; + } + + if (cdrom_drives[drive].bus_type != 0) { + sb_parts++; + } + } + + for (drive = 0; drive < ZIP_NUM; drive++) { + /* Could be Internal or External IDE.. */ + if (((zip_drives[drive].bus_type==ZIP_BUS_ATAPI_PIO_ONLY) && + (zip_drives[drive].bus_type==ZIP_BUS_ATAPI_PIO_AND_DMA)) && + !(hdint || !strncmp(hdc, "ide", 3) || !strncmp(hdc, "xta", 3))) { + continue; + } + + if ((zip_drives[drive].bus_type == ZIP_BUS_SCSI) && + (scsi_card == 0)) { + continue; + } + + if (zip_drives[drive].bus_type != 0) { + sb_parts++; + } + } + + for (drive = 0; drive < HDD_NUM; drive++) { + if ((hdd[drive].bus==HDD_BUS_SCSI_REMOVABLE) && (scsi_card != 0)) { + sb_parts++; + } + } + + if (c_st506 && (hdint || !strncmp(hdc, "st506", 5))) { + /* ST506 MFM/RLL drives, and MFM or Internal controller. */ + sb_parts++; + } + if (c_esdi && (hdint || !strncmp(hdc, "esdi", 4))) { + /* ESDI drives, and ESDI or Internal controller. */ + sb_parts++; + } + if (c_ide_pio && (hdint || !strncmp(hdc, "ide", 3) || !strncmp(hdc, "xta", 3))) { + /* IDE_PIO drives, and IDE or Internal controller. */ + sb_parts++; + } + if (c_ide_dma && (hdint || !strncmp(hdc, "ide", 3))) { + /* IDE_DMA drives, and IDE or Internal controller. */ + sb_parts++; + } + if (c_scsi && (scsi_card != 0)) { + sb_parts++; + } + if (do_net) { + sb_parts++; + } + sb_parts += 2; + + /* Now (re-)allocate the fields. */ + sb_widths = (int *)malloc(sb_parts * sizeof(int)); + memset(sb_widths, 0x00, sb_parts * sizeof(int)); + sb_tags = (int *)malloc(sb_parts * sizeof(int)); + memset(sb_tags, 0x00, sb_parts * sizeof(int)); + sb_icons = (int *)malloc(sb_parts * sizeof(int)); + memset(sb_icons, 0x00, sb_parts * sizeof(int)); + sb_flags = (int *)malloc(sb_parts * sizeof(int)); + memset(sb_flags, 0x00, sb_parts * sizeof(int)); + sb_tips = (wchar_t **)malloc(sb_parts * sizeof(wchar_t *)); + memset(sb_tips, 0x00, sb_parts * sizeof(wchar_t *)); + + /* Start populating the fields. */ + sb_parts = 0; + + for (drive = 0; drive < FDD_NUM; drive++) { + if (fdd_get_type(drive) != 0) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_FLOPPY | drive; + sb_parts++; + } + } + + for (drive = 0; drive < CDROM_NUM; drive++) { + /* Could be Internal or External IDE.. */ + if ((cdrom_drives[drive].bus_type==CDROM_BUS_ATAPI_PIO_ONLY) && + !(hdint || !strncmp(hdc, "ide", 3))) { + continue; + } + + /* Could be Internal or External IDE.. */ + if ((cdrom_drives[drive].bus_type==CDROM_BUS_ATAPI_PIO_AND_DMA) && + !(hdint || !strncmp(hdc, "ide", 3))) { + continue; + } + + if ((cdrom_drives[drive].bus_type == CDROM_BUS_SCSI) && (scsi_card == 0)) { + continue; + } + + if (cdrom_drives[drive].bus_type != 0) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_CDROM | drive; + sb_parts++; + } + } + + for (drive = 0; drive < ZIP_NUM; drive++) { + /* Could be Internal or External IDE.. */ + if ((zip_drives[drive].bus_type==ZIP_BUS_ATAPI_PIO_ONLY) && + !(hdint || !strncmp(hdc, "ide", 3))) { + continue; + } + + /* Could be Internal or External IDE.. */ + if ((zip_drives[drive].bus_type==ZIP_BUS_ATAPI_PIO_AND_DMA) && + !(hdint || !strncmp(hdc, "ide", 3))) { + continue; + } + + if ((zip_drives[drive].bus_type == ZIP_BUS_SCSI) && (scsi_card == 0)) { + continue; + } + + if (zip_drives[drive].bus_type != 0) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_ZIP | drive; + sb_parts++; + } + } + + for (drive = 0; drive < HDD_NUM; drive++) { + if ((hdd[drive].bus==HDD_BUS_SCSI_REMOVABLE) && (scsi_card != 0)) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_RDISK | drive; + sb_parts++; + } + } + + if (c_st506 && (hdint || !strncmp(hdc, "st506", 5))) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_HDD | HDD_BUS_ST506; + sb_parts++; + } + + if (c_esdi && (hdint || !strncmp(hdc, "esdi", 4))) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_HDD | HDD_BUS_ESDI; + sb_parts++; + } + + if (c_ide_pio && (hdint || !strncmp(hdc, "ide", 3) || !strncmp(hdc, "xta", 3))) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_HDD | HDD_BUS_IDE_PIO_ONLY; + sb_parts++; + } + + if (c_ide_dma && (hdint || !strncmp(hdc, "ide", 3))) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_HDD | HDD_BUS_IDE_PIO_AND_DMA; + sb_parts++; + } + + if (c_scsi && (scsi_card != 0)) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_HDD | HDD_BUS_SCSI; + sb_parts++; + } + + if (do_net) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_NETWORK; + sb_parts++; + } + + /* Initialize the Sound field. */ + if (sound_card != 0) { + edge += SB_ICON_WIDTH; + sb_widths[sb_parts] = edge; + sb_tags[sb_parts] = SB_SOUND; + sb_parts++; + } + + /* Add a text field and finalize the field settings. */ + if (sb_parts) + sb_widths[sb_parts - 1] += (24 - SB_ICON_WIDTH); + sb_widths[sb_parts] = -1; + sb_tags[sb_parts] = SB_TEXT; + sb_parts++; + + /* Set up the status bar parts and their widths. */ + sb_setup(sb_parts, sb_widths); + + /* Initialize each status bar part. */ + for (part = 0; part < sb_parts; part++) { + switch (sb_tags[part] & 0xf0) { + case SB_FLOPPY: /* Floppy */ + drive = sb_tags[part] & 0x0f; + sb_flags[part] = (wcslen(floppyfns[drive]) == 0) ? 256 : 0; + sb_icons[part] = sb_fdd_icon(fdd_get_type(drive)) | sb_flags[part]; + sb_menu_create(part); + menu_floppy(part, drive); + ui_sb_tip_update(sb_tags[part]); + break; + + case SB_CDROM: /* CD-ROM */ + drive = sb_tags[part] & 0x0f; + if (cdrom_drives[drive].host_drive == 200) { + sb_flags[part] = (wcslen(cdrom_image[drive].image_path) == 0) ? 256 : 0; + } else if ((cdrom_drives[drive].host_drive >= 'A') && (cdrom_drives[drive].host_drive <= 'Z')) { + sb_flags[part] = 0; + } else { + sb_flags[part] = 256; + } + //FIXME: different icons for CD,DVD,BD ? + sb_icons[part] = 160 | sb_flags[part]; + sb_menu_create(part); + menu_cdrom(part, drive); + ui_sb_tip_update(sb_tags[part]); + break; + + case SB_ZIP: /* Iomega ZIP */ + drive = sb_tags[part] & 0x0f; + sb_flags[part] = (wcslen(zip_drives[drive].image_path) == 0) ? 256 : 0; + sb_icons[part] = 176 + sb_flags[part]; + sb_menu_create(part); + menu_zip(part, drive); + ui_sb_tip_update(sb_tags[part]); + break; + + case SB_RDISK: /* Removable hard disk */ + sb_flags[part] = (wcslen(hdd[drive].fn) == 0) ? 256 : 0; + sb_icons[part] = 192 + sb_flags[part]; + sb_menu_create(part); + menu_remov(part, drive); + ui_sb_tip_update(sb_tags[part]); + break; + + case SB_HDD: /* Hard disk */ + sb_icons[part] = 208; + ui_sb_tip_update(sb_tags[part]); + break; + + case SB_NETWORK: /* Network */ + sb_icons[part] = 224; + ui_sb_tip_update(sb_tags[part]); + break; + + case SB_SOUND: /* Sound */ + sb_icons[part] = 259; + ui_sb_tip_update(sb_tags[part]); + break; + + case SB_TEXT: /* Status text */ + sb_icons[part] = -1; + sb_set_text(part, L""); + break; + } + + /* Set up the correct icon for this part. */ + if (sb_icons[part] != -1) { + sb_set_text(part, L""); + sb_set_icon(part, sb_icons[part]); + } else { + sb_set_icon(part, -1); + } + } + + sb_ready = 1; +} + + +/* Handle a command from one of the status bar menus. */ +void +ui_sb_menu_command(int idm, int tag) +{ + wchar_t temp[512]; + int new_cdrom_drive; + int drive; + int part; + int i; + + switch (idm) { + case IDM_FLOPPY_IMAGE_NEW: + drive = tag & 0x0003; + part = find_tag(SB_FLOPPY | drive); + if (part == -1) break; + + dlg_new_floppy(idm, part); + break; + + case IDM_FLOPPY_IMAGE_EXISTING: + case IDM_FLOPPY_IMAGE_EXISTING_WP: + drive = tag & 0x0003; + part = find_tag(SB_FLOPPY | drive); + if (part == -1) break; + + i = (idm == IDM_FLOPPY_IMAGE_EXISTING_WP) ? 0x80 : 0; + if (! dlg_file(plat_get_string(IDS_2159), + floppyfns[drive], temp, i)) + ui_sb_mount_floppy(drive, part, i ? 1 : 0, temp); + break; + + case IDM_FLOPPY_EJECT: + drive = tag & 0x0003; + part = find_tag(SB_FLOPPY | drive); + if (part == -1) break; + + fdd_close(drive); + ui_sb_icon_state(SB_FLOPPY | drive, 1); + sb_menu_enable_item(part, IDM_FLOPPY_EJECT | drive, 0); + sb_menu_enable_item(part, IDM_FLOPPY_EXPORT_TO_86F | drive, 0); + ui_sb_tip_update(SB_FLOPPY | drive); + config_save(); + break; + + case IDM_FLOPPY_EXPORT_TO_86F: + drive = tag & 0x0003; + part = find_tag(SB_FLOPPY | drive); + if (part == -1) break; + + if (! dlg_file(plat_get_string(IDS_2173), floppyfns[drive], temp, 1)) { + plat_pause(1); + if (! d86f_export(drive, temp)) + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_4108); + plat_pause(0); + } + break; + + case IDM_CDROM_MUTE: + drive = tag & 0x0007; + part = find_tag(SB_CDROM | drive); + if (part == -1) break; + + cdrom_drives[drive].sound_on ^= 1; + sb_menu_set_item(part, IDM_CDROM_MUTE | drive, + cdrom_drives[drive].sound_on); + config_save(); + sound_cd_stop(); + break; + + case IDM_CDROM_EMPTY: + drive = tag & 0x0007; + cdrom_eject(drive); + break; + + case IDM_CDROM_RELOAD: + drive = tag & 0x0007; + cdrom_reload(drive); + break; + + case IDM_CDROM_IMAGE: + drive = tag & 0x0007; + part = find_tag(SB_CDROM | drive); + if (part == -1) break; + + if (dlg_file(plat_get_string(IDS_2075), + cdrom_image[drive].image_path, temp, 0x80)) break; + + cdrom_drives[drive].prev_host_drive = cdrom_drives[drive].host_drive; + if (! cdrom_image[drive].prev_image_path) + cdrom_image[drive].prev_image_path = (wchar_t *)malloc(1024); + wcscpy(cdrom_image[drive].prev_image_path, cdrom_image[drive].image_path); + cdrom_drives[drive].handler->exit(drive); + cdrom_close(drive); + image_open(drive, temp); + + /* Signal media change to the emulated machine. */ + cdrom_insert(drive); + sb_menu_set_item(part, IDM_CDROM_EMPTY | drive, 0); + if ((cdrom_drives[drive].host_drive >= 'A') && + (cdrom_drives[drive].host_drive <= 'Z')) { + sb_menu_set_item(part, + IDM_CDROM_HOST_DRIVE | drive | ((cdrom_drives[drive].host_drive - 'A') << 3), + 0); + } + cdrom_drives[drive].host_drive = (wcslen(cdrom_image[drive].image_path) == 0) ? 0 : 200; + if (cdrom_drives[drive].host_drive == 200) { + sb_menu_set_item(part, IDM_CDROM_IMAGE | drive, 1); + ui_sb_icon_state(SB_CDROM | drive, 0); + } else { + sb_menu_set_item(part, IDM_CDROM_IMAGE | drive, 0); + sb_menu_set_item(part, IDM_CDROM_EMPTY | drive, 0); + ui_sb_icon_state(SB_CDROM | drive, 1); + } + sb_menu_enable_item(part, IDM_CDROM_RELOAD | drive, 0); + ui_sb_tip_update(SB_CDROM | drive); + config_save(); + break; + + case IDM_CDROM_HOST_DRIVE: + drive = tag & 0x0007; + i = ((tag >> 3) & 0x001f) + 'A'; + part = find_tag(SB_CDROM | drive); + if (part == -1) break; + + new_cdrom_drive = i; + if (cdrom_drives[drive].host_drive == new_cdrom_drive) { + /* Switching to the same drive. Do nothing. */ + break; + } + cdrom_drives[drive].prev_host_drive = cdrom_drives[drive].host_drive; + cdrom_drives[drive].handler->exit(drive); + cdrom_close(drive); + ioctl_open(drive, new_cdrom_drive); + + /* Signal media change to the emulated machine. */ + cdrom_insert(drive); + sb_menu_set_item(part, IDM_CDROM_EMPTY | drive, 0); + if ((cdrom_drives[drive].host_drive >= 'A') && + (cdrom_drives[drive].host_drive <= 'Z')) { + sb_menu_set_item(part, IDM_CDROM_HOST_DRIVE | drive | ((cdrom_drives[drive].host_drive - 'A') << 3), 0); + } + sb_menu_set_item(part, IDM_CDROM_IMAGE | drive, 0); + cdrom_drives[drive].host_drive = new_cdrom_drive; + sb_menu_set_item(part, IDM_CDROM_HOST_DRIVE | drive | ((cdrom_drives[drive].host_drive - 'A') << 3), 1); + sb_menu_enable_item(part, IDM_CDROM_RELOAD | drive, 0); + ui_sb_icon_state(SB_CDROM | drive, 0); + ui_sb_tip_update(SB_CDROM | drive); + config_save(); + break; + + case IDM_ZIP_IMAGE_NEW: + drive = tag & 0x0003; + part = find_tag(SB_ZIP | drive); + if (part == -1) break; + + dlg_new_floppy(drive | 0x80, part); + break; + + case IDM_ZIP_IMAGE_EXISTING: + case IDM_ZIP_IMAGE_EXISTING_WP: + drive = tag & 0x0003; + part = find_tag(SB_ZIP | drive); + if (part == -1) break; + + i = (idm == IDM_ZIP_IMAGE_EXISTING_WP) ? 0x80 : 0; + if (dlg_file(plat_get_string(IDS_2175), + zip_drives[drive].image_path, temp, i)) break; + ui_sb_mount_zip(drive, part, i ? 1 : 0, temp); + break; + + case IDM_ZIP_EJECT: + drive = tag & 0x0003; + zip_eject(drive); + break; + + case IDM_ZIP_RELOAD: + drive = tag & 0x0003; + zip_reload(drive); + break; + + case IDM_RDISK_EJECT: + drive = tag & 0x001f; + removable_disk_eject(drive); + break; + + case IDM_RDISK_RELOAD: + drive = tag & 0x001f; + removable_disk_reload(drive); + break; + + case IDM_RDISK_SEND_CHANGE: + drive = tag & 0x001f; + scsi_disk_insert(drive); + break; + + case IDM_RDISK_IMAGE: + case IDM_RDISK_IMAGE_WP: + drive = tag & 0x001f; + part = find_tag(idm | drive); + + i = (idm == IDM_RDISK_IMAGE_WP) ? 0x80 : 0; + if (dlg_file(plat_get_string(IDS_4106), + hdd[drive].fn, temp, i)) break; + + removable_disk_unload(drive); + + memset(hdd[drive].fn, 0x00, sizeof(hdd[drive].fn)); + wcscpy(hdd[drive].fn, temp); + hdd[drive].wp = i ? 1 : 0; + + scsi_loadhd(hdd[drive].id.scsi.id, hdd[drive].id.scsi.lun, drive); + scsi_disk_insert(drive); + + if (wcslen(hdd[drive].fn) > 0) { + ui_sb_icon_state(SB_RDISK | drive, 0); + sb_menu_enable_item(part, IDM_RDISK_EJECT | drive, 1); + sb_menu_enable_item(part, IDM_RDISK_RELOAD | drive, 0); + sb_menu_enable_item(part, IDM_RDISK_SEND_CHANGE | drive, 0); + } else { + ui_sb_icon_state(SB_RDISK | drive, 1); + sb_menu_enable_item(part, IDM_RDISK_EJECT | drive, 0); + sb_menu_enable_item(part, IDM_RDISK_RELOAD | drive, 0); + sb_menu_enable_item(part, IDM_RDISK_SEND_CHANGE | drive, 0); + } + ui_sb_tip_update(SB_RDISK | drive); + config_save(); + break; + + default: + break; + } +} + + +/* Handle a "double-click" on one of the icons. */ +void +ui_sb_click(int part) +{ + if (part >= sb_parts) return; + + switch(sb_tags[part] & 0xf0) { + case SB_SOUND: + dlg_sound_gain(); + break; + } +} + + +void +ui_sb_mount_floppy(uint8_t drive, int part, int8_t wp, const wchar_t *fn) +{ + int len; + + fdd_close(drive); + + ui_writeprot[drive] = wp; + fdd_load(drive, fn); + + len = wcslen(floppyfns[drive]); + ui_sb_icon_state(SB_FLOPPY | drive, len ? 0 : 1); + + sb_menu_enable_item(part, IDM_FLOPPY_EJECT | drive, len ? 1 : 0); + sb_menu_enable_item(part, IDM_FLOPPY_EXPORT_TO_86F | drive, len ? 1 : 0); + + ui_sb_tip_update(SB_FLOPPY | drive); + + config_save(); +} + + +void +ui_sb_mount_zip(uint8_t drive, int part, int8_t wp, const wchar_t *fn) +{ + int len; + + zip_close(drive); + + zip_drives[drive].ui_writeprot = wp; + zip_load(drive, fn); + zip_insert(drive); + + len = wcslen(zip_drives[drive].image_path); + ui_sb_icon_state(SB_ZIP | drive, len ? 0 : 1); + + sb_menu_enable_item(part, IDM_ZIP_EJECT | drive, len ? 1 : 0); + sb_menu_enable_item(part, IDM_ZIP_RELOAD | drive, len ? 0 : 1); + + ui_sb_tip_update(SB_ZIP | drive); + + config_save(); +} diff --git a/src/version.h b/src/version.h index 684116c..4cfc67a 100644 --- a/src/version.h +++ b/src/version.h @@ -8,7 +8,7 @@ * * Define application version and build info. * - * Version: @(#)version.h 1.0.10 2018/04/26 + * Version: @(#)version.h 1.0.11 2018/04/29 * * Author: Fred N. van Kempen, * @@ -55,7 +55,7 @@ #define EMU_VER_MAJOR 0 #define EMU_VER_MINOR 1 #define EMU_VER_REV 5 -#define EMU_VER_PATCH 4 +#define EMU_VER_PATCH 5 /* Standard C preprocessor macros. */ diff --git a/src/win/VARCem.rc b/src/win/VARCem.rc index a5d0ddb..7e46a82 100644 --- a/src/win/VARCem.rc +++ b/src/win/VARCem.rc @@ -8,7 +8,7 @@ * * Application resource script for Windows. * - * Version: @(#)VARCem.rc 1.0.21 2018/04/26 + * Version: @(#)VARCem.rc 1.0.22 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -36,18 +36,19 @@ */ #include #define IN_RESOURCE_H -#include "resource.h" #include "../emu.h" #include "../version.h" +#include "../ui/ui.h" +#include "../ui/ui_resource.h" #include "../plat.h" -#include "../ui.h" +#include "resource.h" #undef IN_RESOURCE_H -#define APSTUDIO_READONLY_SYMBOLS -#define APSTUDIO_HIDDEN_SYMBOLS +//#define APSTUDIO_READONLY_SYMBOLS +//#define APSTUDIO_HIDDEN_SYMBOLS #include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS -#undef APSTUDIO_READONLY_SYMBOLS +//#undef APSTUDIO_READONLY_SYMBOLS +//#undef APSTUDIO_HIDDEN_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources @@ -63,23 +64,24 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Menu ///////////////////////////////////////////////////////////////////////////// -MainMenu MENU DISCARDABLE +MainMenu MENU DISCARDABLE BEGIN POPUP "&Action" BEGIN - MENUITEM "&Hard Reset", IDM_ACTION_HRESET - MENUITEM "&Ctrl+Alt+Del", IDM_ACTION_RESET_CAD + MENUITEM "&Hard Reset", IDM_RESET_HARD + MENUITEM "&Ctrl+Alt+Del", IDM_RESET MENUITEM SEPARATOR - MENUITEM "Ctrl+Alt+&Esc", IDM_ACTION_CTRL_ALT_ESC + MENUITEM "Ctrl+Alt+&Esc", IDM_CAE + MENUITEM "Ctrl+Alt+&Break", IDM_CAB MENUITEM SEPARATOR - MENUITEM "&Pause", IDM_ACTION_PAUSE + MENUITEM "&Pause", IDM_PAUSE MENUITEM SEPARATOR - MENUITEM "E&xit", IDM_ACTION_EXIT + MENUITEM "E&xit", IDM_EXIT END POPUP "&View" BEGIN - MENUITEM "&Resizeable window", IDM_VID_RESIZE - MENUITEM "R&emember size && position", IDM_VID_REMEMBER + MENUITEM "&Resizeable window", IDM_RESIZE + MENUITEM "R&emember size && position", IDM_REMEMBER MENUITEM SEPARATOR POPUP "Re&nderer" BEGIN @@ -95,113 +97,126 @@ BEGIN MENUITEM SEPARATOR POPUP "&Window scale factor" BEGIN - MENUITEM "&0.5x", IDM_VID_SCALE_1X - MENUITEM "&1x", IDM_VID_SCALE_2X - MENUITEM "1.&5x", IDM_VID_SCALE_3X - MENUITEM "&2x", IDM_VID_SCALE_4X + MENUITEM "&0.5x", IDM_SCALE_1 + MENUITEM "&1x", IDM_SCALE_2 + MENUITEM "1.&5x", IDM_SCALE_3 + MENUITEM "&2x", IDM_SCALE_4 END MENUITEM SEPARATOR - MENUITEM "&Fullscreen\tCtrl+Alt+PageUP", IDM_VID_FULLSCREEN + MENUITEM "&Fullscreen\tCtrl+Alt+PageUP",IDM_FULLSCREEN POPUP "Fullscreen &stretch mode" BEGIN - MENUITEM "&Full screen stretch", IDM_VID_FS_FULL - MENUITEM "&4:3", IDM_VID_FS_43 - MENUITEM "&Square pixels", IDM_VID_FS_SQ - MENUITEM "&Integer scale", IDM_VID_FS_INT - MENUITEM "&Keep size", IDM_VID_FS_KEEPRATIO + MENUITEM "&Full screen stretch", IDM_STRETCH + MENUITEM "&4:3", IDM_STRETCH_43 + MENUITEM "&Square pixels", IDM_STRETCH_SQ + MENUITEM "&Integer scale", IDM_STRETCH_INT + MENUITEM "&Keep size", IDM_STRETCH_KEEP END POPUP "E&GA/(S)VGA settings" BEGIN - MENUITEM "&Inverted VGA monitor", IDM_VID_INVERT - MENUITEM "E&GA/(S)VGA overscan", IDM_VID_OVERSCAN + MENUITEM "&Inverted VGA monitor", IDM_VGA_INVERT + MENUITEM "E&GA/(S)VGA overscan", IDM_VGA_OVERSCAN POPUP "VGA screen &type" BEGIN - MENUITEM "RGB &Color", IDM_VID_GRAY_RGB - MENUITEM "&RGB Grayscale", IDM_VID_GRAY_MONO - MENUITEM "&Amber monitor", IDM_VID_GRAY_AMBER - MENUITEM "&Green monitor", IDM_VID_GRAY_GREEN - MENUITEM "&White monitor", IDM_VID_GRAY_WHITE + MENUITEM "RGB &Color", IDM_SCREEN_RGB + MENUITEM "&RGB Grayscale", IDM_SCREEN_GRAYSCALE + MENUITEM "&Amber monitor", IDM_SCREEN_AMBER + MENUITEM "&Green monitor", IDM_SCREEN_GREEN + MENUITEM "&White monitor", IDM_SCREEN_WHITE END POPUP "Grayscale &conversion type" BEGIN - MENUITEM "BT&601 (NTSC/PAL)", IDM_VID_GRAYCT_601 - MENUITEM "BT&709 (HDTV)", IDM_VID_GRAYCT_709 - MENUITEM "&Average", IDM_VID_GRAYCT_AVE + MENUITEM "BT&601 (NTSC/PAL)", IDM_GRAY_601 + MENUITEM "BT&709 (HDTV)", IDM_GRAY_709 + MENUITEM "&Average", IDM_GRAY_AVE END END MENUITEM SEPARATOR - MENUITEM "F&orce 4:3 display ratio", IDM_VID_FORCE43 - MENUITEM "Change contrast for &monochrome display", IDM_VID_CGACON + MENUITEM "F&orce 4:3 display ratio", IDM_FORCE_43 + MENUITEM "Change contrast for &monochrome display", IDM_CGA_CONTR MENUITEM SEPARATOR - MENUITEM "R&ight CTRL is left ALT", IDM_KBD_RCTRL_IS_LALT + MENUITEM "R&ight CTRL is left ALT", IDM_RCTRL_IS_LALT + MENUITEM SEPARATOR + MENUITEM "&Update status bar icons", IDM_UPDATE_ICONS END POPUP "&Tools" BEGIN - MENUITEM "&Settings...", IDM_CONFIG + MENUITEM "&Settings...", IDM_SETTINGS MENUITEM SEPARATOR #if defined(ENABLE_LOG_TOGGLES) || defined(ENABLE_LOG_COMMANDS) POPUP "&Logging" BEGIN - -# ifdef ENABLE_PCI_LOG - MENUITEM "Enable PCI bus logs\tCtrl+F1", IDM_LOG_PCI +# ifdef ENABLE_BUS_LOG + MENUITEM "Enable system bus logging\tCtrl+F1", IDM_LOG_BUS # endif # ifdef ENABLE_KEYBOARD_LOG - MENUITEM "Enable keyboard logs\tCtrl+F2", IDM_LOG_KEYBOARD + MENUITEM "Enable keyboard logging\tCtrl+F2", IDM_LOG_KEYBOARD +# endif +# ifdef ENABLE_MOUSE_LOG + MENUITEM "Enable mouse logging\tCtrl+F3", IDM_LOG_MOUSE +# endif +# ifdef ENABLE_GAME_LOG + MENUITEM "Enable game port logging\tCtrl+F4", IDM_LOG_GAME +# endif +# ifdef ENABLE_PARALLEL_LOG + MENUITEM "Enable parallel port logging\tCtrl+F5", IDM_LOG_PARALLEL # endif # ifdef ENABLE_SERIAL_LOG - MENUITEM "Enable Serial Port logs\tCtrl+F3", IDM_LOG_SERIAL + MENUITEM "Enable serial port logging\tCtrl+F6", IDM_LOG_SERIAL # endif # ifdef ENABLE_FDC_LOG - MENUITEM "Enable floppy controller logs\tCtrl+F4", IDM_LOG_FDC + MENUITEM "Enable FDC logging\tCtrl+F7", IDM_LOG_FDC +# endif +# ifdef ENABLE_FDD_LOG + MENUITEM "Enable floppy (image) logging\tCtrl+F8", IDM_LOG_FDD # endif # ifdef ENABLE_D86F_LOG - MENUITEM "Enable floppy (86F) logs\tCtrl+F5", IDM_LOG_D86F + MENUITEM "Enable floppy (D86F) logging\tCtrl+F9", IDM_LOG_D86F # endif # ifdef ENABLE_HDC_LOG - MENUITEM "Enable Hard Disk controller logs\tCtrl+F6", IDM_LOG_HDC + MENUITEM "Enable HDC logging\tCtrl+F10", IDM_LOG_HDC # endif # ifdef ENABLE_HDD_LOG - MENUITEM "Enable Hard Disk images logs\tCtrl+F7", IDM_LOG_HDD + MENUITEM "Enable disk (image) logging\tCtrl+F11", IDM_LOG_HDD # endif # ifdef ENABLE_ZIP_LOG - MENUITEM "Enable ZIP drive logs\tCtrl+F8", IDM_LOG_ZIP + MENUITEM "Enable ZIP drive logging\tCtrl+F12", IDM_LOG_ZIP # endif # ifdef ENABLE_CDROM_LOG - MENUITEM "Enable CD-ROM logs\tCtrl+F9", IDM_LOG_CDROM + MENUITEM "Enable CD-ROM drive logging\tCtrl+Alt+F1", IDM_LOG_CDROM # endif # ifdef ENABLE_CDROM_IMAGE_LOG - MENUITEM "Enable CD-ROM images logs\tCtrl+F10", IDM_LOG_CDROM_IMAGE + MENUITEM "Enable CD-ROM (image) logging\tCtrl+Alt+F2", IDM_LOG_CDROM_IMAGE # endif # ifdef ENABLE_CDROM_IOCTL_LOG - MENUITEM "Enable CD-ROM ioctl logs\tCtrl+F11", IDM_LOG_CDROM_IOCTL + MENUITEM "Enable CD-ROM (ioctl) logging\tCtrl+Alt+F3", IDM_LOG_CDROM_IOCTL # endif -# ifdef ENABLE_NIC_LOG - MENUITEM "Enable Network logs\tCtrl+F12", IDM_LOG_NIC +# ifdef ENABLE_NETWORK_LOG + MENUITEM "Enable network logging\tCtrl+Alt+F4", IDM_LOG_NETWORK +# endif +# ifdef ENABLE_NETWORK_LOG_DEV + MENUITEM "Enable network device logging\tCtrl+Alt+F5", IDM_LOG_NETWORK_DEV # endif # ifdef ENABLE_SOUND_EMU8K_LOG - MENUITEM "Enable sound EMU8K logs\tCtrl+Alt+F1", IDM_LOG_SOUND_EMU8K + MENUITEM "Enable sound (EMU8K) logging\tCtrl+Alt+F6", IDM_LOG_SOUND_EMU8K # endif # ifdef ENABLE_SOUND_MPU401_LOG - MENUITEM "Enable sound MPU401 logs\tCtrl+Alt+F2", IDM_LOG_SOUND_MPU401 + MENUITEM "Enable sound (MPU401) logging\tCtrl+Alt+F7", IDM_LOG_SOUND_MPU401 # endif -# ifdef ENABLE_SOUND_AUDIOPCI_LOG - MENUITEM "Enable sound device logs\tCtrl+Alt+F3", IDM_LOG_SOUND_AUDIOPCI +# ifdef ENABLE_SOUND_DEV_LOG + MENUITEM "Enable sound device logging\tCtrl+Alt+F8", IDM_LOG_SOUND_DEV # endif # ifdef ENABLE_SCSI_BUS_LOG - MENUITEM "Enable SCSI bus logs\tCtrl+Alt+F4", IDM_LOG_SCSI_BUS + MENUITEM "Enable SCSI bus logging\tCtrl+Alt+F9", IDM_LOG_SCSI_BUS # endif # ifdef ENABLE_SCSI_DISK_LOG - MENUITEM "Enable SCSI disk logs\tCtrl+Alt+F5", IDM_LOG_SCSI_DISK + MENUITEM "Enable SCSI disk logging\tCtrl+Alt+F10", IDM_LOG_SCSI_DISK # endif # ifdef ENABLE_SCSI_DEV_LOG - MENUITEM "Enable SCSI controller logs\tCtrl+Alt+F6", IDM_LOG_SCSI_DEV -# endif -# ifdef ENABLE_SCSI_X54X_LOG - MENUITEM "Enable Adaptec/BusLogic command logs\tCtrl+Alt+F7", IDM_LOG_SCSI_X54X + MENUITEM "Enable SCSI controller logging\tCtrl+Alt+F11", IDM_LOG_SCSI_DEV # endif # ifdef ENABLE_VOODOO_LOG - MENUITEM "Enable Voodoo logs\tCtrl+Alt+F9", IDM_LOG_VOODOO + MENUITEM "Enable Voodoo logging\tCtrl+Alt+F12", IDM_LOG_VOODOO # endif # if defined(ENABLE_LOG_COMMANDS) && defined(ENABLE_LOG_TOGGLES) @@ -215,9 +230,7 @@ BEGIN END #endif MENUITEM "S&tatus", IDM_STATUS - MENUITEM "Take s&creenshot\tCtrl+Home", IDM_ACTION_SCREENSHOT - MENUITEM SEPARATOR - MENUITEM "&Update status bar icons", IDM_UPDATE_ICONS + MENUITEM "Take s&creenshot\tCtrl+Home", IDM_SCREENSHOT END POPUP "&Help" BEGIN @@ -225,7 +238,7 @@ BEGIN END END -StatusBarMenu MENU DISCARDABLE +StatusBarMenu MENU DISCARDABLE BEGIN MENUITEM SEPARATOR END @@ -234,76 +247,87 @@ END // Accelerator ///////////////////////////////////////////////////////////////////////////// -MainAccel ACCELERATORS MOVEABLE PURE +MainAccel ACCELERATORS MOVEABLE PURE BEGIN -#ifdef ENABLE_PCI_LOG - VK_F1, IDM_LOG_PCI, VIRTKEY, CONTROL +#ifdef ENABLE_BUS_LOG + VK_F1, IDM_LOG_BUS, VIRTKEY, CONTROL #endif #ifdef ENABLE_KEYBOARD_LOG VK_F2, IDM_LOG_KEYBOARD, VIRTKEY, CONTROL #endif +#ifdef ENABLE_MOUSE_LOG + VK_F3, IDM_LOG_MOUSE, VIRTKEY, CONTROL +#endif +#ifdef ENABLE_GAME_LOG + VK_F4, IDM_LOG_GAME, VIRTKEY, CONTROL +#endif +#ifdef ENABLE_PARALLEL_LOG + VK_F5, IDM_LOG_PARALLEL, VIRTKEY, CONTROL +#endif #ifdef ENABLE_SERIAL_LOG - VK_F3, IDM_LOG_SERIAL, VIRTKEY, CONTROL + VK_F6, IDM_LOG_SERIAL, VIRTKEY, CONTROL #endif #ifdef ENABLE_FDC_LOG - VK_F4, IDM_LOG_FDC, VIRTKEY, CONTROL + VK_F7, IDM_LOG_FDC, VIRTKEY, CONTROL +#endif +#ifdef ENABLE_FDD_LOG + VK_F8, IDM_LOG_FDD, VIRTKEY, CONTROL #endif #ifdef ENABLE_D86F_LOG - VK_F5, IDM_LOG_D86F, VIRTKEY, CONTROL + VK_F9, IDM_LOG_D86F, VIRTKEY, CONTROL #endif #ifdef ENABLE_HDC_LOG - VK_F6, IDM_LOG_HDC, VIRTKEY, CONTROL + VK_F10, IDM_LOG_HDC, VIRTKEY, CONTROL #endif #ifdef ENABLE_HDD_LOG - VK_F7, IDM_LOG_HDD, VIRTKEY, CONTROL + VK_F11, IDM_LOG_HDD, VIRTKEY, CONTROL #endif #ifdef ENABLE_ZIP_LOG - VK_F8, IDM_LOG_ZIP, VIRTKEY, CONTROL + VK_F12, IDM_LOG_ZIP, VIRTKEY, CONTROL #endif #ifdef ENABLE_CDROM_LOG - VK_F9, IDM_LOG_CDROM, VIRTKEY, CONTROL + VK_F1, IDM_LOG_CDROM, VIRTKEY, CONTROL #endif #ifdef ENABLE_CDROM_IMAGE_LOG - VK_F10, IDM_LOG_CDROM_IMAGE, VIRTKEY, CONTROL + VK_F2, IDM_LOG_CDROM_IMAGE, VIRTKEY, CONTROL #endif #ifdef ENABLE_CDROM_IOCTL_LOG - VK_F11, IDM_LOG_CDROM_IOCTL, VIRTKEY, CONTROL + VK_F3, IDM_LOG_CDROM_IOCTL, VIRTKEY, CONTROL #endif -#ifdef ENABLE_NIC_LOG - VK_F12, IDM_LOG_NIC, VIRTKEY, CONTROL +#ifdef ENABLE_NETWORK_LOG + VK_F4, IDM_LOG_NETWORK, VIRTKEY, CONTROL +#endif +#ifdef ENABLE_NETWORK_DEV_LOG + VK_F5, IDM_LOG_NETWORK_DEV, VIRTKEY, CONTROL #endif - # ifdef ENABLE_EMU8K_LOG - VK_F1, IDM_LOG_SOUND_EMU8K, VIRTKEY, CONTROL, ALT + VK_F6, IDM_LOG_SOUND_EMU8K, VIRTKEY, CONTROL, ALT # endif # ifdef ENABLE_MPU401_LOG - VK_F2, IDM_LOG_SOUND_MPU401, VIRTKEY, CONTROL, ALT + VK_F7, IDM_LOG_SOUND_MPU401, VIRTKEY, CONTROL, ALT # endif -# ifdef ENABLE_AUDIOPCI_LOG - VK_F3, IDM_LOG_SOUND_AUDIOPCI, VIRTKEY, CONTROL, ALT +# ifdef ENABLE_SOUND_DEV_LOG + VK_F8, IDM_LOG_SOUND_DEV, VIRTKEY, CONTROL, ALT # endif # ifdef ENABLE_SCSI_BUS_LOG - VK_F4, IDM_LOG_SCSI_BUS, VIRTKEY, CONTROL, ALT + VK_F9, IDM_LOG_SCSI_BUS, VIRTKEY, CONTROL, ALT # endif # ifdef ENABLE_SCSI_DISK_LOG - VK_F5, IDM_LOG_SCSI_DISK, VIRTKEY, CONTROL, ALT + VK_F10, IDM_LOG_SCSI_DISK, VIRTKEY, CONTROL, ALT # endif # ifdef ENABLE_SCSI_DEV_LOG - VK_F6, IDM_LOG_SCSI_DEV, VIRTKEY, CONTROL, ALT -# endif -# ifdef ENABLE_X54X_LOG - VK_F7, IDM_LOG_SCSI_X54X, VIRTKEY, CONTROL, ALT + VK_F11, IDM_LOG_SCSI_DEV, VIRTKEY, CONTROL, ALT # endif # ifdef ENABLE_VOODOO_LOG - VK_F9, IDM_LOG_VOODOO, VIRTKEY, CONTROL, ALT + VK_F12, IDM_LOG_VOODOO, VIRTKEY, CONTROL, ALT # endif #ifdef ENABLE_LOG_BREAKPOINT VK_INSERT, IDM_LOG_BREAKPOINT, VIRTKEY, CONTROL #endif - VK_PRIOR,IDM_VID_FULLSCREEN, VIRTKEY, CONTROL, ALT - VK_HOME, IDM_ACTION_SCREENSHOT, VIRTKEY, CONTROL - VK_PAUSE,IDM_ACTION_PAUSE, VIRTKEY, CONTROL + VK_PRIOR,IDM_FULLSCREEN, VIRTKEY, CONTROL, ALT + VK_HOME, IDM_SCREENSHOT, VIRTKEY, CONTROL + VK_PAUSE,IDM_PAUSE, VIRTKEY, CONTROL END @@ -349,7 +373,7 @@ FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,57,7,50,14 PUSHBUTTON "Cancel",IDCANCEL,57,24,50,14 - CONTROL "Gain",IDC_SLIDER_GAIN,"msctls_trackbar32",TBS_VERT | + CONTROL "Gain",IDC_SLIDER_GAIN,"msctls_trackbar32",TBS_VERT | TBS_BOTH | TBS_AUTOTICKS | WS_TABSTOP,15,20,20,109 CTEXT "Gain",IDT_1746,16,7,32,9,SS_CENTERIMAGE END @@ -365,13 +389,13 @@ BEGIN LTEXT "Disk size:",IDT_1750,7,25,44,12,SS_CENTERIMAGE LTEXT "RPM mode:",IDT_1751,7,45,44,12,SS_CENTERIMAGE EDITTEXT IDC_EDIT_FILE_NAME,53,5,154,14,ES_AUTOHSCROLL | ES_READONLY - COMBOBOX IDC_COMBO_DISK_SIZE,53,25,166,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_DISK_SIZE,53,25,166,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_COMBO_RPM_MODE,53,45,166,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_RPM_MODE,53,45,166,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "...",IDC_CFILE,206,5,13,14 LTEXT "Progress:",IDT_1757,7,45,44,12,SS_CENTERIMAGE - CONTROL "IMGCreateProgress",IDC_PBAR_IMG_CREATE,"msctls_progress32",PBS_SMOOTH | + CONTROL "IMGCreateProgress",IDC_PBAR_IMG_CREATE,"msctls_progress32",PBS_SMOOTH | WS_BORDER,53,45,166,14 END @@ -382,7 +406,7 @@ FONT 9, "Segoe UI" BEGIN DEFPUSHBUTTON "OK",IDOK,246,230,50,14 PUSHBUTTON "Cancel",IDCANCEL,307,230,50,14 - CONTROL "List2",IDC_SETTINGSCATLIST,"SysListView32",LVS_LIST | + CONTROL "List2",IDC_SETTINGSCATLIST,"SysListView32",LVS_LIST | LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,7,90,207 CONTROL "",-1,"Static",SS_BLACKFRAME | SS_SUNKEN,1,221,363,1 /* Leave this commented out until we get into localization. */ @@ -401,28 +425,28 @@ DLG_CFG_MACHINE DIALOG DISCARDABLE 97, 0, 267, 99 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN - COMBOBOX IDC_COMBO_MACHINE,71,7,138,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_MACHINE,71,7,138,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Machine:",IDT_1701,7,8,60,10 PUSHBUTTON "Configure",IDC_CONFIGURE_MACHINE,214,7,46,12 - COMBOBOX IDC_COMBO_CPU_TYPE,71,25,45,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_CPU_TYPE,71,25,45,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "CPU type:",IDT_1702,7,26,59,10 - COMBOBOX IDC_COMBO_CPU,145,25,115,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_CPU,145,25,115,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "CPU:",IDT_1704,124,26,18,10 - COMBOBOX IDC_COMBO_WS,71,44,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_COMBO_WS,71,44,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Wait states:",IDT_1703,7,45,60,10 EDITTEXT IDC_MEMTEXT,70,63,45,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_MEMSPIN,"msctls_updown32",UDS_SETBUDDYINT | + CONTROL "",IDC_MEMSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,113,63, 12,12 LTEXT "MB",IDT_1705,123,64,10,10 LTEXT "Memory:",IDT_1706,7,64,30,10 CONTROL "Enable time sync",IDC_CHECK_SYNC,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,81,102,10 - CONTROL "Enable FPU",IDC_CHECK_FPU,"Button",BS_AUTOCHECKBOX | + CONTROL "Enable FPU",IDC_CHECK_FPU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,147,81,113,10 #ifdef USE_DYNAREC CONTROL "Dynamic Recompiler",IDC_CHECK_DYNAREC,"Button", @@ -435,10 +459,10 @@ STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN LTEXT "Video:",IDT_1707,7,8,55,10 - COMBOBOX IDC_COMBO_VIDEO,71,7,140,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_VIDEO,71,7,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure",IDC_CONFIGURE_VID,214,7,46,12 - COMBOBOX IDC_COMBO_VIDEO_SPEED,71,25,189,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_VIDEO_SPEED,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Video speed:",IDT_1708,7,26,58,10 CONTROL "Voodoo Graphics",IDC_CHECK_VOODOO,"Button", @@ -451,11 +475,11 @@ STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN LTEXT "Mouse :",IDT_1709,7,8,57,10 - COMBOBOX IDC_COMBO_MOUSE,71,7,140,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_MOUSE,71,7,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure",IDC_CONFIGURE_MOUSE,214,7,46,12 LTEXT "Joystick :",IDT_1710,7,26,58,10 - COMBOBOX IDC_COMBO_JOYSTICK,71,25,189,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_JOYSTICK,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Joystick 1...",IDC_JOY1,7,44,50,14 PUSHBUTTON "Joystick 2...",IDC_JOY2,74,44,50,14 @@ -467,12 +491,12 @@ DLG_CFG_SOUND DIALOG DISCARDABLE 97, 0, 267, 116 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN - COMBOBOX IDC_COMBO_SOUND,71,7,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_COMBO_SOUND,71,7,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Sound card:",IDT_1711,7,8,59,10 PUSHBUTTON "Configure",IDC_CONFIGURE_SND,214,7,46,12 - COMBOBOX IDC_COMBO_MIDI,71,25,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_COMBO_MIDI,71,25,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "MIDI Out Device:",IDT_1712,7,26,59,10 PUSHBUTTON "Configure",IDC_CONFIGURE_MIDI,214,25,46,12 @@ -493,15 +517,15 @@ STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN LTEXT "Network type:",IDT_1713,7,8,59,10 - COMBOBOX IDC_COMBO_NET_TYPE,71,7,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_COMBO_NET_TYPE,71,7,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "PCap device:",IDT_1714,7,26,59,10 - COMBOBOX IDC_COMBO_PCAP,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_COMBO_PCAP,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Network adapter:",IDT_1715,7,44,59,10 - COMBOBOX IDC_COMBO_NET,71,43,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_COMBO_NET,71,43,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure",IDC_CONFIGURE_NET,214,43,46,12 END @@ -515,17 +539,17 @@ BEGIN CONTROL "Parallel port 1",IDC_CHECK_PARALLEL1,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,27,70,10 - COMBOBOX IDC_COMBO_PARALLEL1,80,26,159,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_PARALLEL1,80,26,159,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Parallel port 2",IDC_CHECK_PARALLEL2,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,46,70,10 - COMBOBOX IDC_COMBO_PARALLEL2,80,45,159,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_PARALLEL2,80,45,159,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Parallel port 3",IDC_CHECK_PARALLEL3,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,65,70,10 - COMBOBOX IDC_COMBO_PARALLEL3,80,64,159,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_PARALLEL3,80,64,159,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Serial port 1",IDC_CHECK_SERIAL1,"Button", @@ -540,21 +564,21 @@ STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN LTEXT "SCSI Controller:",IDT_1716,7,8,59,10 - COMBOBOX IDC_COMBO_SCSI,71,7,140,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_SCSI,71,7,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure",IDC_CONFIGURE_SCSI,214,7,46,12 LTEXT "HD Controller:",IDT_1717,7,26,61,10 - COMBOBOX IDC_COMBO_HDC,71,25,140,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HDC,71,25,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure",IDC_CONFIGURE_HDC,214,25,46,12 LTEXT "Tertiary IDE:",IDT_1718,7,44,61,10 - COMBOBOX IDC_COMBO_IDE_TER,71,43,189,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_IDE_TER,71,43,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Quaternary IDE:",IDT_1719,7,62,61,10 - COMBOBOX IDC_COMBO_IDE_QUA,71,61,189,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_IDE_QUA,71,61,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "ISABugger device",IDC_CHECK_BUGGER,"Button", @@ -565,26 +589,26 @@ DLG_CFG_DISK DIALOG DISCARDABLE 97, 0, 267, 154 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN - CONTROL "List1",IDC_LIST_HARD_DISKS,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | + CONTROL "List1",IDC_LIST_HARD_DISKS,"SysListView32",LVS_REPORT | + LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,18,253,92 LTEXT "Hard disks:",IDT_1720,7,7,34,8 PUSHBUTTON "&New...",IDC_BUTTON_HDD_ADD_NEW,60,137,62,10 PUSHBUTTON "&Existing...",IDC_BUTTON_HDD_ADD,129,137,62,10 PUSHBUTTON "&Remove",IDC_BUTTON_HDD_REMOVE,198,137,62,10 - COMBOBOX IDC_COMBO_HD_BUS,33,117,90,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_BUS,33,117,90,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Bus:",IDT_1721,7,119,24,8 - COMBOBOX IDC_COMBO_HD_CHANNEL,170,117,90,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_CHANNEL,170,117,90,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Channel:",IDT_1722,131,119,38,8 - COMBOBOX IDC_COMBO_HD_ID,170,117,22,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_ID,170,117,22,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "ID:",IDT_1723,131,119,38,8 - COMBOBOX IDC_COMBO_HD_LUN,239,117,22,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_LUN,239,117,22,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "LUN:",IDT_1724,200,119,38,8 - COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,170,117,90,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,170,117,90,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END @@ -601,7 +625,7 @@ BEGIN EDITTEXT IDC_EDIT_HD_HPC,112,34,28,12 EDITTEXT IDC_EDIT_HD_CYL,42,34,28,12 EDITTEXT IDC_EDIT_HD_SIZE,42,52,28,12 - COMBOBOX IDC_COMBO_HD_TYPE,113,52,98,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_TYPE,113,52,98,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Sectors:",IDT_1726,154,35,27,10 LTEXT "Heads:",IDT_1727,81,35,29,8 @@ -609,22 +633,22 @@ BEGIN LTEXT "Size (MB):",IDT_1729,7,54,33,8 LTEXT "Type:",IDT_1730,86,54,24,8 LTEXT "File name:",IDT_1731,7,7,204,9 - COMBOBOX IDC_COMBO_HD_BUS,33,71,58,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_BUS,33,71,58,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Bus:",IDT_1721,7,73,24,8 - COMBOBOX IDC_COMBO_HD_CHANNEL,134,71,77,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_CHANNEL,134,71,77,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Channel:",IDT_1722,99,73,34,8 - COMBOBOX IDC_COMBO_HD_ID,133,71,26,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_ID,133,71,26,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "ID:",IDT_1723,117,73,15,8 - COMBOBOX IDC_COMBO_HD_LUN,185,71,26,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_LUN,185,71,26,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "LUN:",IDT_1724,168,73,15,8 - COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,134,71,77,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_HD_CHANNEL_IDE,134,71,77,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Progress:",IDT_1752,7,7,204,9 - CONTROL "IMGCreateProgress",IDC_PBAR_IMG_CREATE,"msctls_progress32",PBS_SMOOTH | + CONTROL "IMGCreateProgress",IDC_PBAR_IMG_CREATE,"msctls_progress32",PBS_SMOOTH | WS_BORDER,7,16,204,12 END @@ -633,10 +657,10 @@ STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN CONTROL "List1",IDC_LIST_FLOPPY_DRIVES,"SysListView32", - LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,18,253,60 LTEXT "Floppy drives:",IDT_1737,7,7,43,8 - COMBOBOX IDC_COMBO_FD_TYPE,33,85,90,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_FD_TYPE,33,85,90,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Type:",IDT_1738,7,87,24,8 CONTROL "Turbo timings",IDC_CHECKTURBO,"Button", @@ -649,39 +673,39 @@ DLG_CFG_RMV_DEVICES DIALOG DISCARDABLE 97, 0, 267, 221 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN - CONTROL "List1",IDC_LIST_CDROM_DRIVES,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | + CONTROL "List1",IDC_LIST_CDROM_DRIVES,"SysListView32",LVS_REPORT | + LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,18,253,60 LTEXT "CD-ROM drives:",IDT_1739,7,7,50,8 - COMBOBOX IDC_COMBO_CD_BUS,33,85,90,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_CD_BUS,33,85,90,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Bus:",IDT_1740,7,87,24,8 - COMBOBOX IDC_COMBO_CD_ID,170,85,22,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_CD_ID,170,85,22,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "ID:",IDT_1741,131,87,38,8 - COMBOBOX IDC_COMBO_CD_LUN,239,85,22,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_CD_LUN,239,85,22,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "LUN:",IDT_1742,200,87,38,8 - COMBOBOX IDC_COMBO_CD_CHANNEL_IDE,170,85,90,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_CD_CHANNEL_IDE,170,85,90,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Channel:",IDT_1743,131,87,38,8 - COMBOBOX IDC_COMBO_CD_SPEED,33,105,90,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_CD_SPEED,33,105,90,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Speed:",IDT_1761,7,107,24,8 - CONTROL "List1",IDC_LIST_ZIP_DRIVES,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | + CONTROL "List1",IDC_LIST_ZIP_DRIVES,"SysListView32",LVS_REPORT | + LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,137,253,60 LTEXT "ZIP drives:",IDT_1762,7,127,50,8 - COMBOBOX IDC_COMBO_ZIP_BUS,73,204,90,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_ZIP_BUS,73,204,90,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Bus:",IDT_1753,57,206,14,8 - COMBOBOX IDC_COMBO_ZIP_ID,190,204,22,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_ZIP_ID,190,204,22,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "ID:",IDT_1754,171,206,18,8 - COMBOBOX IDC_COMBO_ZIP_LUN,239,204,22,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_ZIP_LUN,239,204,22,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "LUN:",IDT_1755,220,206,18,8 - COMBOBOX IDC_COMBO_ZIP_CHANNEL_IDE,200,204,60,120,CBS_DROPDOWNLIST | + COMBOBOX IDC_COMBO_ZIP_CHANNEL_IDE,200,204,60,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Channel:",IDT_1756,171,206,28,8 CONTROL "ZIP 250",IDC_CHECK250,"Button", @@ -701,56 +725,56 @@ END // Icon ///////////////////////////////////////////////////////////////////////////// -100 ICON DISCARDABLE "win/icons/varcem.ico" -128 ICON DISCARDABLE "win/icons/floppy_525.ico" -129 ICON DISCARDABLE "win/icons/floppy_525_active.ico" -144 ICON DISCARDABLE "win/icons/floppy_35.ico" -145 ICON DISCARDABLE "win/icons/floppy_35_active.ico" -160 ICON DISCARDABLE "win/icons/cdrom.ico" -161 ICON DISCARDABLE "win/icons/cdrom_active.ico" -176 ICON DISCARDABLE "win/icons/zip.ico" -177 ICON DISCARDABLE "win/icons/zip_active.ico" -192 ICON DISCARDABLE "win/icons/removable_disk.ico" -193 ICON DISCARDABLE "win/icons/removable_disk_active.ico" -208 ICON DISCARDABLE "win/icons/hard_disk.ico" -209 ICON DISCARDABLE "win/icons/hard_disk_active.ico" -224 ICON DISCARDABLE "win/icons/network.ico" -225 ICON DISCARDABLE "win/icons/network_active.ico" -256 ICON DISCARDABLE "win/icons/machine.ico" -257 ICON DISCARDABLE "win/icons/display.ico" -258 ICON DISCARDABLE "win/icons/input_devices.ico" -259 ICON DISCARDABLE "win/icons/sound.ico" -260 ICON DISCARDABLE "win/icons/network.ico" -261 ICON DISCARDABLE "win/icons/ports.ico" -262 ICON DISCARDABLE "win/icons/other_peripherals.ico" -263 ICON DISCARDABLE "win/icons/hard_disk.ico" -264 ICON DISCARDABLE "win/icons/floppy_drives.ico" -265 ICON DISCARDABLE "win/icons/other_removable_devices.ico" -384 ICON DISCARDABLE "win/icons/floppy_525_empty.ico" -385 ICON DISCARDABLE "win/icons/floppy_525_empty_active.ico" -400 ICON DISCARDABLE "win/icons/floppy_35_empty.ico" -401 ICON DISCARDABLE "win/icons/floppy_35_empty_active.ico" -416 ICON DISCARDABLE "win/icons/cdrom_empty.ico" -417 ICON DISCARDABLE "win/icons/cdrom_empty_active.ico" -432 ICON DISCARDABLE "win/icons/zip_empty.ico" -433 ICON DISCARDABLE "win/icons/zip_empty_active.ico" -448 ICON DISCARDABLE "win/icons/removable_disk_empty.ico" -449 ICON DISCARDABLE "win/icons/removable_disk_empty_active.ico" -512 ICON DISCARDABLE "win/icons/floppy_disabled.ico" -514 ICON DISCARDABLE "win/icons/cdrom_disabled.ico" -515 ICON DISCARDABLE "win/icons/zip_disabled.ico" +100 ICON DISCARDABLE "icons/varcem.ico" +128 ICON DISCARDABLE "icons/floppy_525.ico" +129 ICON DISCARDABLE "icons/floppy_525_active.ico" +144 ICON DISCARDABLE "icons/floppy_35.ico" +145 ICON DISCARDABLE "icons/floppy_35_active.ico" +160 ICON DISCARDABLE "icons/cdrom.ico" +161 ICON DISCARDABLE "icons/cdrom_active.ico" +176 ICON DISCARDABLE "icons/zip.ico" +177 ICON DISCARDABLE "icons/zip_active.ico" +192 ICON DISCARDABLE "icons/removable_disk.ico" +193 ICON DISCARDABLE "icons/removable_disk_active.ico" +208 ICON DISCARDABLE "icons/hard_disk.ico" +209 ICON DISCARDABLE "icons/hard_disk_active.ico" +224 ICON DISCARDABLE "icons/network.ico" +225 ICON DISCARDABLE "icons/network_active.ico" +256 ICON DISCARDABLE "icons/machine.ico" +257 ICON DISCARDABLE "icons/display.ico" +258 ICON DISCARDABLE "icons/input_devices.ico" +259 ICON DISCARDABLE "icons/sound.ico" +260 ICON DISCARDABLE "icons/network.ico" +261 ICON DISCARDABLE "icons/ports.ico" +262 ICON DISCARDABLE "icons/other_peripherals.ico" +263 ICON DISCARDABLE "icons/hard_disk.ico" +264 ICON DISCARDABLE "/icons/floppy_drives.ico" +265 ICON DISCARDABLE "icons/other_removable_devices.ico" +384 ICON DISCARDABLE "icons/floppy_525_empty.ico" +385 ICON DISCARDABLE "icons/floppy_525_empty_active.ico" +400 ICON DISCARDABLE "icons/floppy_35_empty.ico" +401 ICON DISCARDABLE "icons/floppy_35_empty_active.ico" +416 ICON DISCARDABLE "icons/cdrom_empty.ico" +417 ICON DISCARDABLE "icons/cdrom_empty_active.ico" +432 ICON DISCARDABLE "icons/zip_empty.ico" +433 ICON DISCARDABLE "icons/zip_empty_active.ico" +448 ICON DISCARDABLE "icons/removable_disk_empty.ico" +449 ICON DISCARDABLE "icons/removable_disk_empty_active.ico" +512 ICON DISCARDABLE "icons/floppy_disabled.ico" +514 ICON DISCARDABLE "icons/cdrom_disabled.ico" +515 ICON DISCARDABLE "icons/zip_disabled.ico" #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // TEXTINCLUDE ///////////////////////////////////////////////////////////////////////////// -1 TEXTINCLUDE DISCARDABLE +1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h" END -2 TEXTINCLUDE DISCARDABLE +2 TEXTINCLUDE DISCARDABLE BEGIN "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" "#include ""windows.h""\r\n" @@ -759,7 +783,7 @@ BEGIN "" END -3 TEXTINCLUDE DISCARDABLE +3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "" @@ -773,7 +797,7 @@ END ///////////////////////////////////////////////////////////////////////////// #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE +GUIDELINES DESIGNINFO DISCARDABLE BEGIN DLG_SND_GAIN, DIALOG BEGIN @@ -892,7 +916,7 @@ END // String Table ///////////////////////////////////////////////////////////////////////////// -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_2048 "Error" IDS_2049 "Fatal Error" @@ -1022,7 +1046,7 @@ BEGIN IDS_2179 "Speed:" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_4096 "Hard disk (%s)" IDS_4097 "%01i:%01i" @@ -1046,7 +1070,7 @@ BEGIN IDS_4115 "Removable disk %i (SCSI): %ls" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_4352 "ST506" IDS_4353 "ESDI" @@ -1056,7 +1080,7 @@ BEGIN IDS_4357 "SCSI (removable)" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_4608 "ST506 (%01i:%01i)" IDS_4609 "ESDI (%01i:%01i)" @@ -1066,12 +1090,12 @@ BEGIN IDS_4613 "SCSI (removable) (%02i:%02i)" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_5120 "CD-ROM %i (%s): %s" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_5376 "Disabled" IDS_5377 "" @@ -1082,7 +1106,7 @@ BEGIN IDS_5382 "SCSI" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_5632 "Disabled" IDS_5633 "" @@ -1093,7 +1117,7 @@ BEGIN IDS_5638 "SCSI (%02i:%02i)" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_5888 "160 kB" IDS_5889 "180 kB" @@ -1111,7 +1135,7 @@ BEGIN IDS_5901 "ZIP 250" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_6144 "Perfect RPM" IDS_6145 "1%% below perfect RPM" @@ -1119,7 +1143,7 @@ BEGIN IDS_6147 "2%% below perfect RPM" END -STRINGTABLE DISCARDABLE +STRINGTABLE DISCARDABLE BEGIN IDS_7168 "English (United States)" END diff --git a/src/win/mingw/Makefile.MinGW b/src/win/mingw/Makefile.MinGW index 714fc77..d6f08f4 100644 --- a/src/win/mingw/Makefile.MinGW +++ b/src/win/mingw/Makefile.MinGW @@ -8,7 +8,7 @@ # # Makefile for Windows systems using the MinGW32 environment. # -# Version: @(#)Makefile.mingw 1.0.34 2018/04/26 +# Version: @(#)Makefile.mingw 1.0.35 2018/04/28 # # Author: Fred N. van Kempen, # @@ -208,7 +208,7 @@ VPATH := $(EXPATH) . cpu \ sound/munt sound/munt/c_interface sound/munt/sha1 \ sound/munt/srchelper \ sound/resid-fp \ - scsi video network network/slirp win + scsi video network network/slirp ui win # # Select the required build environment. We have, uhm, many.. @@ -474,12 +474,14 @@ endif # Final versions of the toolchain flags. CFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \ - $(AFLAGS) -fomit-frame-pointer -mstackrealign -Wall + $(AFLAGS) -fomit-frame-pointer -mstackrealign \ + -Wall -Wundef #-Wunused-parameter -Wmissing-declarations + CXXFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \ $(AFLAGS) -fno-strict-aliasing -fvisibility=hidden \ - -Wall -Wundef -fvisibility-inlines-hidden \ - -Wunused-parameter -Wno-ctor-dtor-privacy \ - -Woverloaded-virtual + -fvisibility-inlines-hidden \ + -Wall -Wundef -Wunused-parameter -Wmissing-declarations \ + -Wno-ctor-dtor-privacy -Woverloaded-virtual ######################################################################### @@ -490,6 +492,8 @@ MAINOBJ := pc.o config.o \ pci.o mca.o mcr.o mem.o memregs.o rom.o rom_load.o \ device.o nvr.o nvr_at.o nvr_ps2.o $(VNCOBJ) $(RDPOBJ) +UIOBJ += ui_main.o ui_new_floppy.o ui_stbar.o + INTELOBJ := intel.o \ intel_flash.o \ intel_sio.o \ @@ -632,7 +636,7 @@ endif OBJ := $(MAINOBJ) $(INTELOBJ) $(CPUOBJ) $(MCHOBJ) $(DEVOBJ) \ $(FDDOBJ) $(CDROMOBJ) $(ZIPOBJ) $(HDDOBJ) \ $(USBOBJ) $(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) \ - $(PLATOBJ) $(UIOBJ) $(FSYNTHOBJ) $(MUNTOBJ) $(DEVBROBJ) + $(UIOBJ) $(PLATOBJ) $(FSYNTHOBJ) $(MUNTOBJ) $(DEVBROBJ) ifdef EXOBJ OBJ += $(EXOBJ) endif diff --git a/src/win/mingw/include/pcap-stdinc.h b/src/win/mingw/include/pcap-stdinc.h index 4176041..c26044b 100644 --- a/src/win/mingw/include/pcap-stdinc.h +++ b/src/win/mingw/include/pcap-stdinc.h @@ -60,7 +60,7 @@ #define caddr_t char* -#if _MSC_VER < 1500 +#if defined(_MSC_VER) && _MSC_VER < 1500 #define snprintf _snprintf #define vsnprintf _vsnprintf #define strdup _strdup diff --git a/src/win/resource.h b/src/win/resource.h index e290852..4e1e7d7 100644 --- a/src/win/resource.h +++ b/src/win/resource.h @@ -8,7 +8,7 @@ * * Windows resource defines. * - * Version: @(#)resource.h 1.0.12 2018/04/26 + * Version: @(#)resource.h 1.0.13 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -248,113 +248,8 @@ #define IDC_STATUS 1282 -#define IDM_ABOUT 40001 -#define IDC_ABOUT_ICON 65535 -#define IDM_ACTION_SCREENSHOT 40011 -#define IDM_ACTION_HRESET 40012 -#define IDM_ACTION_RESET_CAD 40013 -#define IDM_ACTION_EXIT 40014 -#define IDM_ACTION_CTRL_ALT_ESC 40015 -#define IDM_ACTION_PAUSE 40016 -#define IDM_CONFIG 40020 -#define IDM_CONFIG_LOAD 40021 -#define IDM_CONFIG_SAVE 40022 -#define IDM_STATUS 40030 -#define IDM_UPDATE_ICONS 40040 -#define IDM_VID_RESIZE 40050 -#define IDM_VID_REMEMBER 40051 -#define IDM_VID_DDRAW 40060 -#define IDM_VID_D3D 40061 -#define IDM_VID_VNC 40062 -#define IDM_VID_RDP 40063 -#define IDM_VID_SCALE_1X 40064 -#define IDM_VID_SCALE_2X 40065 -#define IDM_VID_SCALE_3X 40066 -#define IDM_VID_SCALE_4X 40067 -#define IDM_VID_FULLSCREEN 40070 -#define IDM_VID_FS_FULL 40071 -#define IDM_VID_FS_43 40072 -#define IDM_VID_FS_SQ 40073 -#define IDM_VID_FS_INT 40074 -#define IDM_VID_FS_KEEPRATIO 40075 -#define IDM_VID_FORCE43 40076 -#define IDM_VID_OVERSCAN 40077 -#define IDM_VID_INVERT 40079 -#define IDM_VID_CGACON 40080 -#define IDM_VID_GRAYCT_601 40085 -#define IDM_VID_GRAYCT_709 40086 -#define IDM_VID_GRAYCT_AVE 40087 -#define IDM_VID_GRAY_RGB 40090 -#define IDM_VID_GRAY_MONO 40091 -#define IDM_VID_GRAY_AMBER 40092 -#define IDM_VID_GRAY_GREEN 40093 -#define IDM_VID_GRAY_WHITE 40094 -#define IDM_KBD_RCTRL_IS_LALT 40101 - -#define IDM_LOGGING 51200 -#define IDM_LOG_BREAKPOINT (IDM_LOGGING + 0) -#define IDM_LOG_PCI (IDM_LOGGING + 1) -#define IDM_LOG_KEYBOARD (IDM_LOGGING + 2) -#define IDM_LOG_SERIAL (IDM_LOGGING + 3) -#define IDM_LOG_FDC (IDM_LOGGING + 4) -#define IDM_LOG_D86F (IDM_LOGGING + 5) -#define IDM_LOG_HDC (IDM_LOGGING + 6) -#define IDM_LOG_HDD (IDM_LOGGING + 7) -#define IDM_LOG_ZIP (IDM_LOGGING + 8) -#define IDM_LOG_CDROM (IDM_LOGGING + 9) -#define IDM_LOG_CDROM_IMAGE (IDM_LOGGING + 10) -#define IDM_LOG_CDROM_IOCTL (IDM_LOGGING + 11) -#define IDM_LOG_NIC (IDM_LOGGING + 12) -#define IDM_LOG_SOUND_EMU8K (IDM_LOGGING + 13) -#define IDM_LOG_SOUND_MPU401 (IDM_LOGGING + 14) -#define IDM_LOG_SOUND_DEV (IDM_LOGGING + 15) -#define IDM_LOG_SCSI_BUS (IDM_LOGGING + 16) -#define IDM_LOG_SCSI_DISK (IDM_LOGGING + 17) -#define IDM_LOG_SCSI_DEV (IDM_LOGGING + 18) -#define IDM_LOG_SCSI_X54X (IDM_LOGGING + 19) -#define IDM_LOG_VOODOO (IDM_LOGGING + 20) - - -/* - * We need 7 bits for CDROM (2 bits ID and 5 bits for host drive), - * and 5 bits for Removable Disks (5 bits for ID), so we use an - * 8bit (256 entries) space for these devices. - */ -#define IDM_FLOPPY_IMAGE_NEW 0x1200 -#define IDM_FLOPPY_IMAGE_EXISTING 0x1300 -#define IDM_FLOPPY_IMAGE_EXISTING_WP 0x1400 -#define IDM_FLOPPY_EXPORT_TO_86F 0x1500 -#define IDM_FLOPPY_EJECT 0x1600 - -#define IDM_CDROM_MUTE 0x2200 -#define IDM_CDROM_EMPTY 0x2300 -#define IDM_CDROM_RELOAD 0x2400 -#define IDM_CDROM_IMAGE 0x2500 -#define IDM_CDROM_HOST_DRIVE 0x2600 - -#define IDM_ZIP_IMAGE_NEW 0x3200 -#define IDM_ZIP_IMAGE_EXISTING 0x3300 -#define IDM_ZIP_IMAGE_EXISTING_WP 0x3400 -#define IDM_ZIP_EJECT 0x3500 -#define IDM_ZIP_RELOAD 0x3600 - -#define IDM_RDISK_EJECT 0x4200 -#define IDM_RDISK_RELOAD 0x4300 -#define IDM_RDISK_SEND_CHANGE 0x4400 -#define IDM_RDISK_IMAGE 0x4500 -#define IDM_RDISK_IMAGE_WP 0x4600 - - -/* Next default values for new objects */ -#ifdef APSTUDIO_INVOKED -# ifndef APSTUDIO_READONLY_SYMBOLS -# define _APS_NO_MFC 1 -# define _APS_NEXT_RESOURCE_VALUE 1400 -# define _APS_NEXT_COMMAND_VALUE 55000 -# define _APS_NEXT_CONTROL_VALUE 1800 -# define _APS_NEXT_SYMED_VALUE 200 -# endif -#endif +/* HELP menu. */ +#define IDC_ABOUT_ICON 65535 #endif /*WIN_RESOURCE_H*/ diff --git a/src/win/win.c b/src/win/win.c index 3d804e1..5aa22a1 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * Platform main support module for Windows. * - * Version: @(#)win.c 1.0.14 2018/04/26 + * Version: @(#)win.c 1.0.15 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -52,9 +52,9 @@ #include "../device.h" #include "../input/mouse.h" #include "../video/video.h" +#include "../ui/ui.h" #define GLOBAL #include "../plat.h" -#include "../ui.h" #ifdef USE_VNC # include "../vnc.h" #endif @@ -631,7 +631,7 @@ plat_vidapi_name(int api) char *name = "default"; switch(api) { -#if USE_WX +#ifdef USE_WX case 0: break; diff --git a/src/win/win.h b/src/win/win.h index d33181d..30dfd04 100644 --- a/src/win/win.h +++ b/src/win/win.h @@ -8,7 +8,7 @@ * * Platform support defintions for Win32. * - * Version: @(#)win.h 1.0.6 2018/03/31 + * Version: @(#)win.h 1.0.8 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,7 +43,8 @@ extern "C" { #endif -#include "resource.h" +#include "resource.h" /* local resources */ +#include "../ui/ui_resource.h" /* common resources */ /* Class names and such. */ @@ -72,8 +73,6 @@ extern HICON hIcon[512]; extern int status_is_open; -extern char openfilestring[]; -extern WCHAR wopenfilestring[]; extern DWORD filterindex; @@ -108,44 +107,21 @@ extern uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type); extern int getfile(HWND hwnd, char *f, char *fn); extern int getsfile(HWND hwnd, char *f, char *fn); -extern int win_settings_open(HWND hwnd, int ask); - extern void hard_disk_add_open(HWND hwnd, int is_existing); extern int hard_disk_was_added(void); - /* Platform UI support functions. */ extern int ui_init(int nCmdShow); - -/* Functions in win_about.c: */ -extern void AboutDialogCreate(HWND hwnd); - - -/* Functions in win_snd_gain.c: */ -extern void SoundGainDialogCreate(HWND hwnd); - - -/* Functions in win_new_floppy.c: */ -extern void NewFloppyDialogCreate(HWND hwnd, int id, int part); - - -/* Functions in win_status.c: */ -extern HWND hwndStatus; -extern void StatusWindowCreate(HWND hwnd); - - /* Functions in win_stbar.c: */ extern HWND hwndSBAR; extern void StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst); - /* Functions in win_dialog.c: */ extern void dialog_center(HWND hdlg); -extern int file_dlg(HWND hwnd, WCHAR *filt, WCHAR *ifn, int save); -extern int file_dlg_st(HWND hwnd, int i, WCHAR *fn, int save); - +extern int dlg_file_ex(HWND hwnd, const wchar_t *filt, + const wchar_t *ifn, wchar_t *fn, int save); #ifdef __cplusplus } diff --git a/src/win/win_about.c b/src/win/win_about.c index e06c762..a1d1658 100644 --- a/src/win/win_about.c +++ b/src/win/win_about.c @@ -8,7 +8,7 @@ * * Handle the About dialog. * - * Version: @(#)win_about.c 1.0.5 2018/03/20 + * Version: @(#)win_about.c 1.0.6 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,6 +43,7 @@ #include #include "../emu.h" #include "../version.h" +#include "../ui/ui.h" #include "../plat.h" #include "win.h" @@ -77,7 +78,7 @@ static LRESULT CALLBACK #else static BOOL CALLBACK #endif -AboutDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { char temp[128]; HWND h; @@ -116,11 +117,11 @@ AboutDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) void -AboutDialogCreate(HWND hwnd) +dlg_about(void) { plat_pause(1); - DialogBox(hinstance, (LPCTSTR)DLG_ABOUT, hwnd, AboutDialogProcedure); + DialogBox(hinstance, (LPCTSTR)DLG_ABOUT, hwndMain, dlg_proc); plat_pause(0); } diff --git a/src/win/win_cdrom.c b/src/win/win_cdrom.c index 2589f23..c65a001 100644 --- a/src/win/win_cdrom.c +++ b/src/win/win_cdrom.c @@ -8,7 +8,7 @@ * * Handle the platform-side of CDROM drives. * - * Version: @(#)win_cdrom.c 1.0.6 2018/04/23 + * Version: @(#)win_cdrom.c 1.0.7 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,8 +50,8 @@ #include "../cdrom/cdrom_null.h" #include "../scsi/scsi.h" #include "../scsi/scsi_disk.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "win.h" @@ -90,8 +90,8 @@ cdrom_eject(uint8_t id) if ((cdrom_drives[id].host_drive >= 'A') && (cdrom_drives[id].host_drive <= 'Z')) { - ui_sb_check_menu_item(SB_CDROM|id, - IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_UNCHECKED); + ui_sb_menu_set_item(SB_CDROM | id, + IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), 0); } if (cdrom_image[id].prev_image_path) { @@ -112,12 +112,12 @@ cdrom_eject(uint8_t id) cdrom_insert(id); } - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED); + ui_sb_menu_set_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, 0); cdrom_drives[id].host_drive=0; - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED); - ui_sb_update_icon_state(SB_CDROM|id, 1); - ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - ui_sb_update_tip(SB_CDROM|id); + ui_sb_menu_set_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, 1); + ui_sb_icon_state(SB_CDROM|id, 1); + ui_sb_menu_enable_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, 1); + ui_sb_tip_update(SB_CDROM|id); config_save(); } @@ -145,15 +145,15 @@ cdrom_reload(uint8_t id) cdrom_insert(id); } if (wcslen(cdrom_image[id].image_path) == 0) { - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED); + ui_sb_menu_set_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, 1); cdrom_drives[id].host_drive = 0; - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED); - ui_sb_update_icon_state(SB_CDROM|id, 1); + ui_sb_menu_set_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, 0); + ui_sb_icon_state(SB_CDROM|id, 1); } else { - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED); + ui_sb_menu_set_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, 0); cdrom_drives[id].host_drive = 200; - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_CHECKED); - ui_sb_update_icon_state(SB_CDROM|id, 0); + ui_sb_menu_set_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, 1); + ui_sb_icon_state(SB_CDROM|id, 0); } } else { new_cdrom_drive = cdrom_drives[id].prev_host_drive; @@ -162,14 +162,14 @@ cdrom_reload(uint8_t id) /* Signal disc change to the emulated machine. */ cdrom_insert(id); } - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED); + ui_sb_menu_set_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, 0); cdrom_drives[id].host_drive = new_cdrom_drive; - ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_CHECKED); - ui_sb_update_icon_state(SB_CDROM|id, 0); + ui_sb_menu_set_item(SB_CDROM|id, IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), 1); + ui_sb_icon_state(SB_CDROM|id, 0); } - ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_update_tip(SB_CDROM|id); + ui_sb_menu_enable_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, 0); + ui_sb_tip_update(SB_CDROM|id); config_save(); } @@ -184,10 +184,10 @@ zip_eject(uint8_t id) zip_insert(id); } - ui_sb_update_icon_state(SB_ZIP | id, 1); - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - ui_sb_update_tip(SB_ZIP | id); + ui_sb_icon_state(SB_ZIP | id, 1); + ui_sb_menu_enable_item(SB_ZIP|id, IDM_ZIP_EJECT | id, 0); + ui_sb_menu_enable_item(SB_ZIP|id, IDM_ZIP_RELOAD | id, 1); + ui_sb_tip_update(SB_ZIP | id); config_save(); } @@ -197,15 +197,15 @@ zip_reload(uint8_t id) { zip_disk_reload(id); if (wcslen(zip_drives[id].image_path) == 0) { - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_update_icon_state(SB_ZIP|id, 1); + ui_sb_menu_enable_item(SB_ZIP|id, IDM_ZIP_EJECT | id, 0); + ui_sb_icon_state(SB_ZIP|id, 1); } else { - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED); - ui_sb_update_icon_state(SB_ZIP|id, 0); + ui_sb_menu_enable_item(SB_ZIP|id, IDM_ZIP_EJECT | id, 1); + ui_sb_icon_state(SB_ZIP|id, 0); } - ui_sb_enable_menu_item(SB_ZIP|id, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_update_tip(SB_ZIP|id); + ui_sb_menu_enable_item(SB_ZIP|id, IDM_ZIP_RELOAD | id, 0); + ui_sb_tip_update(SB_ZIP|id); config_save(); } @@ -228,12 +228,12 @@ void removable_disk_eject(uint8_t id) { removable_disk_unload(id); - ui_sb_update_icon_state(SB_RDISK|id, 1); - ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | MF_GRAYED); + ui_sb_icon_state(SB_RDISK|id, 1); + ui_sb_menu_enable_item(SB_RDISK|id, IDM_RDISK_EJECT | id, 0); + ui_sb_menu_enable_item(SB_RDISK|id, IDM_RDISK_RELOAD | id, 1); + ui_sb_menu_enable_item(SB_RDISK|id, IDM_RDISK_SEND_CHANGE | id, 0); - ui_sb_update_tip(SB_RDISK|id); + ui_sb_tip_update(SB_RDISK|id); config_save(); } @@ -252,13 +252,13 @@ removable_disk_reload(uint8_t id) scsi_disk_insert(id); #endif - ui_sb_update_icon_state(SB_RDISK|id, wcslen(hdd[id].fn) ? 0 : 1); + ui_sb_icon_state(SB_RDISK|id, wcslen(hdd[id].fn) ? 0 : 1); - ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_EJECT | id, MF_BYCOMMAND | (wcslen(hdd[id].fn) ? MF_ENABLED : MF_GRAYED)); - ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | (wcslen(hdd[id].fn) ? MF_ENABLED : MF_GRAYED)); + ui_sb_menu_enable_item(SB_RDISK|id, IDM_RDISK_EJECT | id, wcslen(hdd[id].fn) ? 1 : 0); + ui_sb_menu_enable_item(SB_RDISK|id, IDM_RDISK_RELOAD | id, 0); + ui_sb_menu_enable_item(SB_RDISK|id, IDM_RDISK_SEND_CHANGE | id, wcslen(hdd[id].fn) ? 1 : 0); - ui_sb_update_tip(SB_RDISK|id); + ui_sb_tip_update(SB_RDISK|id); config_save(); } diff --git a/src/win/win_ddraw.cpp b/src/win/win_ddraw.cpp index 91f5d49..06b8e0c 100644 --- a/src/win/win_ddraw.cpp +++ b/src/win/win_ddraw.cpp @@ -11,7 +11,7 @@ * NOTES: This code should be re-merged into a single init() with a * 'fullscreen' argument, indicating FS mode is requested. * - * Version: @(#)win_ddraw.cpp 1.0.5 2018/04/25 + * Version: @(#)win_ddraw.cpp 1.0.6 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -54,8 +54,8 @@ # pragma warning(disable: 4200) #endif #include "../video/video.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "win.h" #include "win_ddraw.h" diff --git a/src/win/win_devconf.c b/src/win/win_devconf.c index a17fbbf..7a03f35 100644 --- a/src/win/win_devconf.c +++ b/src/win/win_devconf.c @@ -12,7 +12,7 @@ * and builds a complete Win32 DIALOG resource block in a * buffer in memory, and then passes that to the API handler. * - * Version: @(#)win_devconf.c 1.0.11 2018/04/25 + * Version: @(#)win_devconf.c 1.0.14 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,8 +51,8 @@ #include "../emu.h" #include "../config.h" #include "../device.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "win.h" @@ -183,6 +183,7 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: + dialog_center(hdlg); dlg_init(hdlg); return TRUE; @@ -425,8 +426,8 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (ws[c] == L'|') ws[c] = 0; - if (! file_dlg(hdlg, ws, L"", 0)) - SendMessage(h, WM_SETTEXT, 0, (LPARAM)wopenfilestring); + if (! dlg_file_ex(hdlg, ws, NULL, temp, 0)) + SendMessage(h, WM_SETTEXT, 0, (LPARAM)temp); } break; } diff --git a/src/win/win_dialog.c b/src/win/win_dialog.c index 61ced09..d500fc5 100644 --- a/src/win/win_dialog.c +++ b/src/win/win_dialog.c @@ -8,7 +8,7 @@ * * Implementation of server several dialogs. * - * Version: @(#)win_dialog.c 1.0.6 2018/04/09 + * Version: @(#)win_dialog.c 1.0.8 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -48,13 +48,11 @@ #include "../emu.h" #include "../version.h" #include "../device.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "win.h" -WCHAR wopenfilestring[1024]; -char openfilestring[1024]; DWORD filterindex = 0; @@ -173,26 +171,45 @@ ui_msgbox(int flags, void *arg) } -int -file_dlg(HWND hwnd, WCHAR *filt, WCHAR *ifn, int save) +/* Use a hook to center the OFN dialog. */ +static UINT_PTR CALLBACK +dlg_file_hook(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) { + OFNOTIFY *np; + + switch (uiMsg) { + case WM_NOTIFY: + np = (OFNOTIFY *)lParam; + if (np->hdr.code == CDN_INITDONE) + dialog_center(GetParent(hdlg)); + break; + } + + return(TRUE); +} + + +/* Implement the main GetFileName dialog. */ +int +dlg_file_ex(HWND hwnd, const wchar_t *filt, const wchar_t *ifn, wchar_t *fn, int save) +{ + wchar_t temp[512]; OPENFILENAME ofn; - wchar_t fn[1024]; - char temp[1024]; BOOL r; DWORD err; - /* Clear out the ("initial") pathname. */ - memset(fn, 0x00, sizeof(fn)); + /* Clear the temp path. */ + memset(temp, 0x00, sizeof(temp)); /* Initialize OPENFILENAME. */ memset(&ofn, 0x00, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; + ofn.lpfnHook = dlg_file_hook; /* This is the buffer in which to place the resulting filename. */ - ofn.lpstrFile = fn; - ofn.nMaxFile = sizeof_w(fn); + ofn.lpstrFile = temp; + ofn.nMaxFile = sizeof_w(temp); /* Set up the "file types" filter. */ ofn.lpstrFilter = filt; @@ -201,12 +218,20 @@ file_dlg(HWND hwnd, WCHAR *filt, WCHAR *ifn, int save) ofn.nMaxFileTitle = 0; /* Tell the dialog where to go initially. */ - ofn.lpstrInitialDir = usr_path; + if (ifn == NULL) + ifn = usr_path; + ofn.lpstrInitialDir = ifn; /* Set up the flags for this dialog. */ - ofn.Flags = OFN_PATHMUSTEXIST; - if (! save) + r = (save & 0x80) ? TRUE : FALSE; + save &= 0x7f; + ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER | OFN_PATHMUSTEXIST; + + if (! save) { ofn.Flags |= OFN_FILEMUSTEXIST; + if (r == TRUE) + ofn.Flags |= OFN_READONLY; + } /* Display the Open dialog box. */ if (save) @@ -219,10 +244,7 @@ file_dlg(HWND hwnd, WCHAR *filt, WCHAR *ifn, int save) if (r) { /* All good, see if we can make this a relative path. */ - pc_path(wopenfilestring, sizeof_w(wopenfilestring), fn); - - /* All good, create an ASCII copy of the string as well. */ - wcstombs(openfilestring, wopenfilestring, sizeof(openfilestring)); + pc_path(fn, sizeof_w(temp), temp); /* Remember the file type for next time. */ filterindex = ofn.nFilterIndex; @@ -231,12 +253,11 @@ file_dlg(HWND hwnd, WCHAR *filt, WCHAR *ifn, int save) } /* If an error occurred, log this. */ - err = CommDlgExtendedError(); - if (err != NO_ERROR) { - sprintf(temp, "OpenFile(%ls, %d):\n\n error 0x%08lx", - usr_path, save, err); - pclog("%s\n", temp); - (void)ui_msgbox(MBX_ERROR|MBX_ANSI, temp); + if ((err = CommDlgExtendedError()) != NO_ERROR) { + sprintf((char *)temp, + "OpenFile(%ls, %d):\n\n error 0x%08lx", ifn, save, err); + pclog("%s\n", (char *)temp); + (void)ui_msgbox(MBX_ERROR|MBX_ANSI, (char *)temp); } return(1); @@ -244,7 +265,7 @@ file_dlg(HWND hwnd, WCHAR *filt, WCHAR *ifn, int save) int -file_dlg_st(HWND hwnd, int id, WCHAR *fn, int save) +dlg_file(const wchar_t *filt, const wchar_t *ifn, wchar_t *ofn, int save) { - return(file_dlg(hwnd, plat_get_string(id), fn, save)); + return(dlg_file_ex(hwndMain, filt, ifn, ofn, save)); } diff --git a/src/win/win_new_floppy.c b/src/win/win_new_floppy.c index 670eec0..f8767c1 100644 --- a/src/win/win_new_floppy.c +++ b/src/win/win_new_floppy.c @@ -8,7 +8,7 @@ * * Implementation of the New Floppy Image dialog. * - * Version: @(#)win_new_floppy.c 1.0.9 2018/03/31 + * Version: @(#)win_new_floppy.c 1.0.11 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -44,507 +44,21 @@ #include #include #include "../emu.h" -#include "../plat.h" -#include "../random.h" -#include "../ui.h" #include "../disk/zip.h" +#include "../ui/ui.h" +#include "../plat.h" #include "win.h" -typedef struct { - int hole; - int sides; - int data_rate; - int encoding; - int rpm; - int tracks; - int sectors; /* For IMG and Japanese FDI only. */ - int sector_len; /* For IMG and Japanese FDI only. */ - int media_desc; - int spc; - int num_fats; - int spfat; - int root_dir_entries; -} disk_size_t; - - -disk_size_t disk_sizes[14] = { { 0, 1, 2, 1, 0, 40, 8, 2, 0xFE, 2, 2, 1, 112 }, /* 160k */ - { 0, 1, 2, 1, 0, 40, 9, 2, 0xFC, 2, 2, 1, 112 }, /* 180k */ - { 0, 2, 2, 1, 0, 40, 8, 2, 0xFF, 2, 2, 1, 112 }, /* 320k */ - { 0, 2, 2, 1, 0, 40, 9, 2, 0xFD, 2, 2, 2, 112 }, /* 360k */ - { 0, 2, 2, 1, 0, 80, 8, 2, 0xFB, 2, 2, 2, 112 }, /* 640k */ - { 0, 2, 2, 1, 0, 80, 9, 2, 0xF9, 2, 2, 3, 112 }, /* 720k */ - { 1, 2, 0, 1, 1, 80, 15, 2, 0xF9, 1, 2, 7, 224 }, /* 1.2M */ - { 1, 2, 0, 1, 1, 77, 8, 3, 0xFE, 1, 2, 2, 192 }, /* 1.25M */ - { 1, 2, 0, 1, 0, 80, 18, 2, 0xF0, 1, 2, 9, 224 }, /* 1.44M */ - { 1, 2, 0, 1, 0, 80, 21, 2, 0xF0, 2, 2, 5, 16 }, /* DMF cluster 1024 */ - { 1, 2, 0, 1, 0, 80, 21, 2, 0xF0, 4, 2, 3, 16 }, /* DMF cluster 2048 */ - { 2, 2, 3, 1, 0, 80, 36, 2, 0xF0, 2, 2, 9, 240 }, /* 2.88M */ - { 0, 64, 0, 0, 0, 96, 32, 2, 0, 0, 0, 0, 0 }, /* ZIP 100 */ - { 0, 64, 0, 0, 0, 239, 32, 2, 0, 0, 0, 0, 0 } }; /* ZIP 250 */ - -static char *empty; - - -static int -create_86f(WCHAR *file_name, disk_size_t disk_size, uint8_t rpm_mode) -{ - FILE *f; - - uint32_t magic = 0x46423638; - uint16_t version = 0x020B; - uint16_t dflags = 0; - uint16_t tflags = 0; - uint32_t index_hole_pos = 0; - uint32_t tarray[512]; - uint32_t array_size, array_size2; - uint32_t track_base, track_size; - int i; - uint32_t shift = 0; - - dflags = 0; /* Has surface data? - Assume no for now. */ - dflags |= (disk_size.hole << 1); /* Hole */ - dflags |= ((disk_size.sides - 1) << 3); /* Sides. */ - dflags |= (0 << 4); /* Write protect? - Assume no for now. */ - dflags |= (rpm_mode << 5); /* RPM mode. */ - dflags |= (0 << 7); /* Has extra bit cells? - Assume no for now. */ - - tflags = disk_size.data_rate; /* Data rate. */ - tflags |= (disk_size.encoding << 3); /* Encoding. */ - tflags |= (disk_size.rpm << 5); /* RPM. */ - - switch (disk_size.hole) { - case 0: - case 1: - default: - switch(rpm_mode) { - case 1: - array_size = 25250; - break; - case 2: - array_size = 25374; - break; - case 3: - array_size = 25750; - break; - default: - array_size = 25000; - break; - } - break; - case 2: - switch(rpm_mode) { - case 1: - array_size = 50500; - break; - case 2: - array_size = 50750; - break; - case 3: - array_size = 51000; - break; - default: - array_size = 50000; - break; - } - break; - } - - array_size2 = (array_size << 3); - array_size = (array_size2 >> 4) << 1; - if (array_size2 & 15) - array_size += 2; - - empty = (char *) malloc(array_size); - - memset(tarray, 0, 2048); - memset(empty, 0, array_size); - - f = plat_fopen(file_name, L"wb"); - if (!f) - return 0; - - fwrite(&magic, 4, 1, f); - fwrite(&version, 2, 1, f); - fwrite(&dflags, 2, 1, f); - - track_size = array_size + 6; - - track_base = 8 + ((disk_size.sides == 2) ? 2048 : 1024); - - for (i = 0; i < disk_size.tracks * disk_size.sides; i++) - if (disk_size.tracks <= 43) - shift = 1; - - for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++) - tarray[i] = track_base + (i * track_size); - - fwrite(tarray, 1, (disk_size.sides == 2) ? 2048 : 1024, f); - - for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++) { - fwrite(&tflags, 2, 1, f); - fwrite(&index_hole_pos, 4, 1, f); - fwrite(empty, 1, array_size, f); - } - - free(empty); - - fclose(f); - - return 1; -} - - -static int is_zip; - - -static int -create_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_fdi) -{ - FILE *f; - uint32_t total_size = 0; - uint32_t total_sectors = 0; - uint32_t sector_bytes = 0; - uint32_t root_dir_bytes = 0; - uint32_t fat_size = 0; - uint32_t fat1_offs = 0; - uint32_t fat2_offs = 0; - uint32_t zero_bytes = 0; - uint16_t base = 0x1000; - - f = plat_fopen(file_name, L"wb"); - if (!f) - return 0; - - sector_bytes = (128 << disk_size.sector_len); - total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors; - if (total_sectors > ZIP_SECTORS) - total_sectors = ZIP_250_SECTORS; - total_size = total_sectors * sector_bytes; - root_dir_bytes = (disk_size.root_dir_entries << 5); - fat_size = (disk_size.spfat * sector_bytes); - fat1_offs = sector_bytes; - fat2_offs = fat1_offs + fat_size; - zero_bytes = fat2_offs + fat_size + root_dir_bytes; - - if (!is_zip && is_fdi) { - empty = (char *) malloc(base); - memset(empty, 0, base); - - *(uint32_t *) &(empty[0x08]) = (uint32_t) base; - *(uint32_t *) &(empty[0x0C]) = total_size; - *(uint16_t *) &(empty[0x10]) = (uint16_t) sector_bytes; - *(uint8_t *) &(empty[0x14]) = (uint8_t) disk_size.sectors; - *(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sides; - *(uint8_t *) &(empty[0x1C]) = (uint8_t) disk_size.tracks; - - fwrite(empty, 1, base, f); - free(empty); - } - - empty = (char *) malloc(total_size); - memset(empty, 0x00, zero_bytes); - - if (!is_zip) { - memset(empty + zero_bytes, 0xF6, total_size - zero_bytes); - - empty[0x00] = 0xEB; /* Jump to make MS-DOS happy. */ - empty[0x01] = 0x58; - empty[0x02] = 0x90; - - empty[0x03] = 0x38; /* '86BOX5.0' OEM ID. */ - empty[0x04] = 0x36; - empty[0x05] = 0x42; - empty[0x06] = 0x4F; - empty[0x07] = 0x58; - empty[0x08] = 0x35; - empty[0x09] = 0x2E; - empty[0x0A] = 0x30; - - *(uint16_t *) &(empty[0x0B]) = (uint16_t) sector_bytes; - *(uint8_t *) &(empty[0x0D]) = (uint8_t) disk_size.spc; - *(uint16_t *) &(empty[0x0E]) = (uint16_t) 1; - *(uint8_t *) &(empty[0x10]) = (uint8_t) disk_size.num_fats; - *(uint16_t *) &(empty[0x11]) = (uint16_t) disk_size.root_dir_entries; - *(uint16_t *) &(empty[0x13]) = (uint16_t) total_sectors; - *(uint8_t *) &(empty[0x15]) = (uint8_t) disk_size.media_desc; - *(uint16_t *) &(empty[0x16]) = (uint16_t) disk_size.spfat; - *(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sectors; - *(uint8_t *) &(empty[0x1A]) = (uint8_t) disk_size.sides; - - empty[0x26] = 0x29; /* ')' followed by randomly-generated volume serial number. */ - empty[0x27] = random_generate(); - empty[0x28] = random_generate(); - empty[0x29] = random_generate(); - empty[0x2A] = random_generate(); - - memset(&(empty[0x2B]), 0x20, 11); - - empty[0x36] = 'F'; - empty[0x37] = 'A'; - empty[0x38] = 'T'; - empty[0x39] = '1'; - empty[0x3A] = '2'; - empty[0x3B] = ' '; - empty[0x3C] = ' '; - empty[0x3D] = ' '; - - empty[0x1FE] = 0x55; - empty[0x1FF] = 0xAA; - - empty[fat1_offs + 0x00] = empty[fat2_offs + 0x00] = empty[0x15]; - empty[fat1_offs + 0x01] = empty[fat2_offs + 0x01] = 0xFF; - empty[fat1_offs + 0x02] = empty[fat2_offs + 0x02] = 0xFF; - } - - fwrite(empty, 1, total_size, f); - free(empty); - - fclose(f); - - return 1; -} - - -static int -create_zip_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_zdi, HWND hwnd) -{ - HWND h; - FILE *f; - uint32_t total_size = 0; - uint32_t total_sectors = 0; - uint32_t sector_bytes = 0; - uint32_t root_dir_bytes = 0; - uint32_t fat_size = 0; - uint32_t fat1_offs = 0; - uint32_t fat2_offs = 0; - uint32_t zero_bytes = 0; - uint16_t base = 0x1000; - uint32_t pbar_max = 0; - uint32_t i; - - f = plat_fopen(file_name, L"wb"); - if (!f) - return 0; - - sector_bytes = (128 << disk_size.sector_len); - total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors; - if (total_sectors > ZIP_SECTORS) - total_sectors = ZIP_250_SECTORS; - total_size = total_sectors * sector_bytes; - root_dir_bytes = (disk_size.root_dir_entries << 5); - fat_size = (disk_size.spfat * sector_bytes); - fat1_offs = sector_bytes; - fat2_offs = fat1_offs + fat_size; - zero_bytes = fat2_offs + fat_size + root_dir_bytes; - - pbar_max = total_size; - if (is_zdi) - pbar_max += base; - pbar_max >>= 11; - pbar_max--; - - h = GetDlgItem(hwnd, IDC_COMBO_RPM_MODE); - EnableWindow(h, FALSE); - ShowWindow(h, SW_HIDE); - h = GetDlgItem(hwnd, IDT_1751); - EnableWindow(h, FALSE); - ShowWindow(h, SW_HIDE); - h = GetDlgItem(hwnd, IDC_PBAR_IMG_CREATE); - SendMessage(h, PBM_SETRANGE32, (WPARAM) 0, (LPARAM) pbar_max); - SendMessage(h, PBM_SETPOS, (WPARAM) 0, (LPARAM) 0); - EnableWindow(h, TRUE); - ShowWindow(h, SW_SHOW); - h = GetDlgItem(hwnd, IDT_1757); - EnableWindow(h, TRUE); - ShowWindow(h, SW_SHOW); - - h = GetDlgItem(hwnd, IDC_PBAR_IMG_CREATE); - pbar_max++; - - if (is_zdi) { - empty = (char *) malloc(base); - memset(empty, 0, base); - - *(uint32_t *) &(empty[0x08]) = (uint32_t) base; - *(uint32_t *) &(empty[0x0C]) = total_size; - *(uint16_t *) &(empty[0x10]) = (uint16_t) sector_bytes; - *(uint8_t *) &(empty[0x14]) = (uint8_t) disk_size.sectors; - *(uint8_t *) &(empty[0x18]) = (uint8_t) disk_size.sides; - *(uint8_t *) &(empty[0x1C]) = (uint8_t) disk_size.tracks; - - fwrite(empty, 1, 2048, f); - SendMessage(h, PBM_SETPOS, (WPARAM) 1, (LPARAM) 0); - - fwrite(&empty[0x0800], 1, 2048, f); - free(empty); - - SendMessage(h, PBM_SETPOS, (WPARAM) 2, (LPARAM) 0); - pbar_max -= 2; - } - - empty = (char *) malloc(total_size); - memset(empty, 0x00, zero_bytes); - - if (total_sectors == ZIP_SECTORS) { - /* ZIP 100 */ - /* MBR */ - *(uint64_t *) &(empty[0x0000]) = 0x0000030000025245LL; - *(uint64_t *) &(empty[0x0008]) = 0x0000000000000000LL; - *(uint64_t *) &(empty[0x0010]) = 0x0900E90300000100LL; - *(uint64_t *) &(empty[0x0018]) = 0x726F70726F430100LL; - *(uint64_t *) &(empty[0x0020]) = 0x202D206E6F697461LL; - *(uint64_t *) &(empty[0x0028]) = 0x30392F33322F3131LL; - - *(uint64_t *) &(empty[0x01AE]) = 0x0116010100E905E2LL; - *(uint64_t *) &(empty[0x01B6]) = 0x226BEDCE014E0135LL; - *(uint64_t *) &(empty[0x01BE]) = 0x5E203F0600010180LL; - *(uint64_t *) &(empty[0x01C6]) = 0x0002FE6000000020LL; - - *(uint16_t *) &(empty[0x01FE]) = 0xAA55; - - /* 4 sectors filled with 0xFA */ - memset(&(empty[0x0200]), 0xFA, 0x0800); - - /* Iomega_Reserved sector */ - *(uint64_t *) &(empty[0x0A00]) = 0x0500000000004D50LL; - *(uint64_t *) &(empty[0x0A08]) = 0xAFF9010051060100LL; - - *(uint64_t *) &(empty[0x0A30]) = 0x525F6167656D6F49LL; - *(uint64_t *) &(empty[0x0A38]) = 0x0064657672657365LL; - - *(uint64_t *) &(empty[0x0A54]) = 0x03000000AFF90100LL; - - /* 26 sectors filled with 0x48 */ - memset(&(empty[0x0C00]), 0x48, 0x3400); - - /* Boot sector */ - *(uint64_t *) &(empty[0x4000]) = 0x584F4236389058EBLL; - *(uint64_t *) &(empty[0x4008]) = 0x0001040200302E35LL; - *(uint64_t *) &(empty[0x4010]) = 0x00C0F80000020002LL; - *(uint64_t *) &(empty[0x4018]) = 0x0000002000400020LL; - *(uint32_t *) &(empty[0x4020]) = 0x0002FFE0; - *(uint16_t *) &(empty[0x4024]) = 0x0080; - - empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */ - empty[0x4027] = random_generate(); - empty[0x4028] = random_generate(); - empty[0x4029] = random_generate(); - empty[0x402A] = random_generate(); - - memset(&(empty[0x402B]), 0x00, 0x000B); - memset(&(empty[0x4036]), 0x20, 0x0008); - - empty[0x4036] = 'F'; - empty[0x4037] = 'A'; - empty[0x4038] = 'T'; - empty[0x4039] = '1'; - empty[0x403A] = '6'; - - empty[0x41FE] = 0x55; - empty[0x41FF] = 0xAA; - - empty[0x4200] = empty[0x1C200] = empty[0x4015]; - empty[0x4201] = empty[0x1C201] = 0xFF; - empty[0x4202] = empty[0x1C202] = 0xFF; - empty[0x4203] = empty[0x1C203] = 0xFF; - - /* Root directory = 0x34200 - Data = 0x38200 */ - } else { - /* ZIP 250 */ - /* MBR */ - *(uint64_t *) &(empty[0x0000]) = 0x2054524150492EEBLL; - *(uint64_t *) &(empty[0x0008]) = 0x3930302065646F63LL; - *(uint64_t *) &(empty[0x0010]) = 0x67656D6F49202D20LL; - *(uint64_t *) &(empty[0x0018]) = 0x726F70726F432061LL; - *(uint64_t *) &(empty[0x0020]) = 0x202D206E6F697461LL; - *(uint64_t *) &(empty[0x0028]) = 0x30392F33322F3131LL; - - *(uint64_t *) &(empty[0x01AE]) = 0x0116010100E900E9LL; - *(uint64_t *) &(empty[0x01B6]) = 0x2E32A7AC014E0135LL; - - *(uint64_t *) &(empty[0x01EE]) = 0xEE203F0600010180LL; - *(uint64_t *) &(empty[0x01F6]) = 0x000777E000000020LL; - *(uint16_t *) &(empty[0x01FE]) = 0xAA55; - - /* 31 sectors filled with 0x48 */ - memset(&(empty[0x0200]), 0x48, 0x3E00); - - /* The second sector begins with some strange data - in my reference image. */ - *(uint64_t *) &(empty[0x0200]) = 0x3831393230334409LL; - *(uint64_t *) &(empty[0x0208]) = 0x6A57766964483130LL; - *(uint64_t *) &(empty[0x0210]) = 0x3C3A34676063653FLL; - *(uint64_t *) &(empty[0x0218]) = 0x586A56A8502C4161LL; - *(uint64_t *) &(empty[0x0220]) = 0x6F2D702535673D6CLL; - *(uint64_t *) &(empty[0x0228]) = 0x255421B8602D3456LL; - *(uint64_t *) &(empty[0x0230]) = 0x577B22447B52603ELL; - *(uint64_t *) &(empty[0x0238]) = 0x46412CC871396170LL; - *(uint64_t *) &(empty[0x0240]) = 0x704F55237C5E2626LL; - *(uint64_t *) &(empty[0x0248]) = 0x6C7932C87D5C3C20LL; - *(uint64_t *) &(empty[0x0250]) = 0x2C50503E47543D6ELL; - *(uint64_t *) &(empty[0x0258]) = 0x46394E807721536ALL; - *(uint64_t *) &(empty[0x0260]) = 0x505823223F245325LL; - *(uint64_t *) &(empty[0x0268]) = 0x365C79B0393B5B6ELL; - - /* Boot sector */ - *(uint64_t *) &(empty[0x4000]) = 0x584F4236389058EBLL; - *(uint64_t *) &(empty[0x4008]) = 0x0001080200302E35LL; - *(uint64_t *) &(empty[0x4010]) = 0x00EFF80000020002LL; - *(uint64_t *) &(empty[0x4018]) = 0x0000002000400020LL; - *(uint32_t *) &(empty[0x4020]) = 0x000777E0; - *(uint16_t *) &(empty[0x4024]) = 0x0080; - - empty[0x4026] = 0x29; /* ')' followed by randomly-generated volume serial number. */ - empty[0x4027] = random_generate(); - empty[0x4028] = random_generate(); - empty[0x4029] = random_generate(); - empty[0x402A] = random_generate(); - - memset(&(empty[0x402B]), 0x00, 0x000B); - memset(&(empty[0x4036]), 0x20, 0x0008); - - empty[0x4036] = 'F'; - empty[0x4037] = 'A'; - empty[0x4038] = 'T'; - empty[0x4039] = '1'; - empty[0x403A] = '6'; - - empty[0x41FE] = 0x55; - empty[0x41FF] = 0xAA; - - empty[0x4200] = empty[0x22000] = empty[0x4015]; - empty[0x4201] = empty[0x22001] = 0xFF; - empty[0x4202] = empty[0x22002] = 0xFF; - empty[0x4203] = empty[0x22003] = 0xFF; - - /* Root directory = 0x3FE00 - Data = 0x38200 */ - } - - for (i = 0; i < pbar_max; i++) { - fwrite(&empty[i << 11], 1, 2048, f); - SendMessage(h, PBM_SETPOS, (WPARAM) i + 2, (LPARAM) 0); - } - - free(empty); - - fclose(f); - - return 1; -} - - -static int fdd_id, sb_part; - -static int file_type = 0; /* 0 = IMG, 1 = Japanese FDI, 2 = 86F */ static wchar_t fd_file_name[512]; +static int is_zip; +static int fdd_id, sb_part; +static int file_type = 0; /* 0 = IMG, 1 = Japanese FDI, 2 = 86F */ /* Show a MessageBox dialog. This is nasty, I know. --FvK */ static int -new_floppy_msgbox(HWND hwnd, int type, void *arg) +msg_box(HWND hwnd, int type, void *arg) { HWND h; int i; @@ -560,55 +74,76 @@ new_floppy_msgbox(HWND hwnd, int type, void *arg) } +static void +dlg_init(HWND hdlg) +{ + int i, zip_types; + HWND h; + + h = GetDlgItem(hdlg, IDC_COMBO_DISK_SIZE); + if (is_zip) { + zip_types = zip_drives[fdd_id].is_250 ? 2 : 1; + for (i = 0; i < zip_types; i++) + SendMessage(h, CB_ADDSTRING, 0, + (LPARAM)plat_get_string(IDS_5900 + i)); + } else { + for (i = 0; i < 12; i++) + SendMessage(h, CB_ADDSTRING, 0, + (LPARAM)plat_get_string(IDS_5888 + i)); + } + SendMessage(h, CB_SETCURSEL, 0, 0); + EnableWindow(h, FALSE); + + h = GetDlgItem(hdlg, IDC_COMBO_RPM_MODE); + for (i = 0; i < 4; i++) + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_6144 + i)); + SendMessage(h, CB_SETCURSEL, 0, 0); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + + h = GetDlgItem(hdlg, IDT_1751); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + + h = GetDlgItem(hdlg, IDOK); + EnableWindow(h, FALSE); + + h = GetDlgItem(hdlg, IDC_PBAR_IMG_CREATE); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); + + h = GetDlgItem(hdlg, IDT_1757); + EnableWindow(h, FALSE); + ShowWindow(h, SW_HIDE); +} + + #ifdef __amd64__ static LRESULT CALLBACK #else static BOOL CALLBACK #endif -NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { + wchar_t temp_path[512]; HWND h; - int i = 0; int wcs_len, ext_offs; wchar_t *ext; uint32_t disk_size, rpm_mode; int ret; FILE *f; - int zip_types; wchar_t *twcs; switch (message) { case WM_INITDIALOG: plat_pause(1); - memset(fd_file_name, 0, 512 * sizeof(wchar_t)); - h = GetDlgItem(hdlg, IDC_COMBO_DISK_SIZE); - if (is_zip) { - zip_types = zip_drives[fdd_id].is_250 ? 2 : 1; - for (i = 0; i < zip_types; i++) - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(IDS_5900 + i)); - } else { - for (i = 0; i < 12; i++) - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(IDS_5888 + i)); - } - SendMessage(h, CB_SETCURSEL, 0, 0); - EnableWindow(h, FALSE); - h = GetDlgItem(hdlg, IDC_COMBO_RPM_MODE); - for (i = 0; i < 4; i++) - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(IDS_6144 + i)); - SendMessage(h, CB_SETCURSEL, 0, 0); - EnableWindow(h, FALSE); - ShowWindow(h, SW_HIDE); - h = GetDlgItem(hdlg, IDT_1751); - EnableWindow(h, FALSE); - ShowWindow(h, SW_HIDE); - h = GetDlgItem(hdlg, IDOK); - EnableWindow(h, FALSE); - h = GetDlgItem(hdlg, IDC_PBAR_IMG_CREATE); - EnableWindow(h, FALSE); - ShowWindow(h, SW_HIDE); - h = GetDlgItem(hdlg, IDT_1757); - EnableWindow(h, FALSE); - ShowWindow(h, SW_HIDE); + + dialog_center(hdlg); + + memset(fd_file_name, 0x00, sizeof(fd_file_name)); + + dlg_init(hdlg); + break; case WM_COMMAND: @@ -618,35 +153,38 @@ NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) disk_size = SendMessage(h, CB_GETCURSEL, 0, 0); if (is_zip) disk_size += 12; + if (file_type == 2) { h = GetDlgItem(hdlg, IDC_COMBO_RPM_MODE); rpm_mode = SendMessage(h, CB_GETCURSEL, 0, 0); - ret = create_86f(fd_file_name, disk_sizes[disk_size], rpm_mode); + ret = floppy_create_86f(fd_file_name, disk_size, rpm_mode); } else { if (is_zip) - ret = create_zip_sector_image(fd_file_name, disk_sizes[disk_size], file_type, hdlg); + ret = zip_create_image(fd_file_name, disk_size, file_type); else - ret = create_sector_image(fd_file_name, disk_sizes[disk_size], file_type); + ret = floppy_create_image(fd_file_name, disk_size, 0, file_type); } if (ret) { if (is_zip) - ui_sb_mount_zip_img(fdd_id, sb_part, 0, fd_file_name); + ui_sb_mount_zip(fdd_id, sb_part, 0, fd_file_name); else - ui_sb_mount_floppy_img(fdd_id, sb_part, 0, fd_file_name); + ui_sb_mount_floppy(fdd_id, sb_part, 0, fd_file_name); } else { - new_floppy_msgbox(hdlg, MBX_ERROR, (wchar_t *)IDS_4108); + msg_box(hdlg, MBX_ERROR, (wchar_t *)IDS_4108); + plat_pause(0); return TRUE; } + case IDCANCEL: EndDialog(hdlg, 0); plat_pause(0); return TRUE; case IDC_CFILE: - if (!file_dlg(hdlg, plat_get_string(is_zip ? IDS_2176 : IDS_2174), L"", 1)) { - if (!wcschr(wopenfilestring, L'.')) { - if (wcslen(wopenfilestring) && (wcslen(wopenfilestring) <= 256)) { - twcs = &wopenfilestring[wcslen(wopenfilestring)]; + if (! dlg_file_ex(hdlg, plat_get_string(is_zip ? IDS_2176 : IDS_2174), NULL, temp_path, 1)) { + if (! wcschr(temp_path, L'.')) { + if (wcslen(temp_path) && (wcslen(temp_path) <= 256)) { + twcs = &temp_path[wcslen(temp_path)]; twcs[0] = L'.'; if (!is_zip && (filterindex == 3)) { twcs[1] = L'8'; @@ -660,21 +198,21 @@ NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } } h = GetDlgItem(hdlg, IDC_EDIT_FILE_NAME); - f = _wfopen(wopenfilestring, L"rb"); + f = _wfopen(temp_path, L"rb"); if (f != NULL) { fclose(f); - if (new_floppy_msgbox(hdlg, MBX_QUESTION, (wchar_t *)IDS_4111) != 0) /* yes */ + if (msg_box(hdlg, MBX_QUESTION, (wchar_t *)IDS_4111) != 0) /* yes */ return FALSE; } - SendMessage(h, WM_SETTEXT, 0, (LPARAM) wopenfilestring); - memset(fd_file_name, 0, sizeof(fd_file_name)); - wcscpy(fd_file_name, wopenfilestring); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)temp_path); + memset(fd_file_name, 0x00, sizeof(fd_file_name)); + wcscpy(fd_file_name, temp_path); h = GetDlgItem(hdlg, IDC_COMBO_DISK_SIZE); if (!is_zip || zip_drives[fdd_id].is_250) EnableWindow(h, TRUE); - wcs_len = wcslen(wopenfilestring); + wcs_len = wcslen(temp_path); ext_offs = wcs_len - 4; - ext = &(wopenfilestring[ext_offs]); + ext = &(temp_path[ext_offs]); if (is_zip) { if (((wcs_len >= 4) && !wcsicmp(ext, L".ZDI"))) file_type = 1; @@ -721,10 +259,11 @@ NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) void -NewFloppyDialogCreate(HWND hwnd, int id, int part) +dlg_new_floppy(int idm, int tag) { - fdd_id = id & 0x7f; - sb_part = part; - is_zip = !!(id & 0x80); - DialogBox(hinstance, (LPCTSTR)DLG_NEW_FLOPPY, hwnd, NewFloppyDialogProcedure); + is_zip = !!(idm & 0x80); + fdd_id = idm & 0x7f; + sb_part = tag; + + DialogBox(hinstance, (LPCTSTR)DLG_NEW_FLOPPY, hwndMain, dlg_proc); } diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 246b213..de67b5b 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings.c 1.0.24 2018/04/26 + * Version: @(#)win_settings.c 1.0.26 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -70,8 +70,8 @@ #include "../sound/midi.h" #include "../sound/snd_mpu401.h" #include "../video/video.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "win.h" @@ -167,7 +167,7 @@ settings_msgbox(int type, void *arg) /* This does the initial read of global variables into the temporary ones. */ static void -settings_init(void) +dlg_init(void) { int i = 0; @@ -569,7 +569,7 @@ static LRESULT CALLBACK #else static BOOL CALLBACK #endif -settings_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h; int category; @@ -580,7 +580,8 @@ settings_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: - settings_init(); + dialog_center(hdlg); + dlg_init(); disk_track_init(); cdrom_track_init(); @@ -600,6 +601,8 @@ settings_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) EnableWindow(h, FALSE); ShowWindow(h, SW_HIDE); #endif + +// dialog_center(hdlg); return(TRUE); case WM_NOTIFY: @@ -654,7 +657,7 @@ settings_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) int -win_settings_open(HWND hwnd, int ask) +dlg_settings(int ask) { int i, m, v; @@ -671,7 +674,7 @@ win_settings_open(HWND hwnd, int ask) } ask_sure = ask; - i = DialogBox(hinstance, (LPCWSTR)DLG_CONFIG, hwnd, settings_proc); + i = DialogBox(hinstance, (LPCWSTR)DLG_CONFIG, hwndMain, dlg_proc); return(i); } diff --git a/src/win/win_settings_disk.h b/src/win/win_settings_disk.h index c875a94..bc63a79 100644 --- a/src/win/win_settings_disk.h +++ b/src/win/win_settings_disk.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_disk.h 1.0.4 2018/04/24 + * Version: @(#)win_settings_disk.h 1.0.6 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -763,6 +763,7 @@ static BOOL CALLBACK #endif disk_add_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { + wchar_t temp_path[512]; char buf[512], *big_buf; HWND h = INVALID_HANDLE_VALUE; uint64_t i = 0; @@ -780,6 +781,7 @@ disk_add_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: + dialog_center(hdlg); memset(hd_file_name, 0x00, sizeof(hd_file_name)); if (existing & 2) { @@ -1063,10 +1065,10 @@ hd_add_ok_common: return TRUE; case IDC_CFILE: - if (!file_dlg(hdlg, plat_get_string(IDS_4106), L"", !(existing & 1))) { - if (!wcschr(wopenfilestring, L'.')) { - if (wcslen(wopenfilestring) && (wcslen(wopenfilestring) <= 256)) { - twcs = &wopenfilestring[wcslen(wopenfilestring)]; + if (! dlg_file_ex(hdlg, plat_get_string(IDS_4106), NULL, temp_path, !(existing & 1))) { + if (! wcschr(temp_path, L'.')) { + if (wcslen(temp_path) && (wcslen(temp_path) <= 256)) { + twcs = &temp_path[wcslen(temp_path)]; twcs[0] = L'.'; twcs[1] = L'i'; twcs[2] = L'm'; @@ -1075,7 +1077,7 @@ hd_add_ok_common: } if (!(existing & 1)) { - f = _wfopen(wopenfilestring, L"rb"); + f = _wfopen(temp_path, L"rb"); if (f != NULL) { fclose(f); if (settings_msgbox(MBX_QUESTION, (wchar_t *)IDS_4111) != 0) { /* yes */ @@ -1084,14 +1086,14 @@ hd_add_ok_common: } } - f = _wfopen(wopenfilestring, (existing & 1) ? L"rb" : L"wb"); + f = _wfopen(temp_path, (existing & 1) ? L"rb" : L"wb"); if (f == NULL) { hdd_add_file_open_error: settings_msgbox(MBX_ERROR, (existing & 1) ? (wchar_t *)IDS_4107 : (wchar_t *)IDS_4108); return TRUE; } if (existing & 1) { - if (image_is_hdi(wopenfilestring) || image_is_hdx(wopenfilestring, 1)) { + if (image_is_hdi(temp_path) || image_is_hdx(temp_path, 1)) { fseeko64(f, 0x10, SEEK_SET); fread(§or_size, 1, 4, f); if (sector_size != 512) { @@ -1161,9 +1163,9 @@ hdd_add_file_open_error: } h = GetDlgItem(hdlg, IDC_EDIT_HD_FILE_NAME); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)wopenfilestring); - memset(hd_file_name, 0, sizeof(hd_file_name)); - wcscpy(hd_file_name, wopenfilestring); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)temp_path); + memset(hd_file_name, 0x00, sizeof(hd_file_name)); + wcscpy(hd_file_name, temp_path); return TRUE; diff --git a/src/win/win_settings_floppy.h b/src/win/win_settings_floppy.h index c159cb5..0c93fbc 100644 --- a/src/win/win_settings_floppy.h +++ b/src/win/win_settings_floppy.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_floppy.h 1.0.1 2018/04/05 + * Version: @(#)win_settings_floppy.h 1.0.3 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -58,7 +58,7 @@ floppy_image_list_init(HWND hwndList) ILC_MASK | ILC_COLOR32, 1, 1); for (i = 0; i < 14; i++) { - hiconItem = LoadIcon(hinstance, (LPCWSTR)fdd_type_to_icon(i)); + hiconItem = LoadIcon(hinstance, (LPCWSTR)sb_fdd_icon(i)); ImageList_AddIcon(hSmall, hiconItem); DestroyIcon(hiconItem); } diff --git a/src/win/win_settings_input.h b/src/win/win_settings_input.h index 1381280..77fcf55 100644 --- a/src/win/win_settings_input.h +++ b/src/win/win_settings_input.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_input.h 1.0.5 2018/04/26 + * Version: @(#)win_settings_input.h 1.0.6 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_settings_machine.h b/src/win/win_settings_machine.h index 1158e13..05d22f8 100644 --- a/src/win/win_settings_machine.h +++ b/src/win/win_settings_machine.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_machine.h 1.0.3 2018/04/14 + * Version: @(#)win_settings_machine.h 1.0.4 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_settings_network.h b/src/win/win_settings_network.h index 3cc6bec..b283a91 100644 --- a/src/win/win_settings_network.h +++ b/src/win/win_settings_network.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_network.h 1.0.3 2018/04/10 + * Version: @(#)win_settings_network.h 1.0.4 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_settings_periph.h b/src/win/win_settings_periph.h index bc59368..436762b 100644 --- a/src/win/win_settings_periph.h +++ b/src/win/win_settings_periph.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_periph.h 1.0.4 2018/04/25 + * Version: @(#)win_settings_periph.h 1.0.5 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_settings_ports.h b/src/win/win_settings_ports.h index a28268b..2a2e3bf 100644 --- a/src/win/win_settings_ports.h +++ b/src/win/win_settings_ports.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_ports.h 1.0.3 2018/04/26 + * Version: @(#)win_settings_ports.h 1.0.4 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_settings_remov.h b/src/win/win_settings_remov.h index 7c25fa4..c3950ba 100644 --- a/src/win/win_settings_remov.h +++ b/src/win/win_settings_remov.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_remov.h 1.0.2 2018/04/07 + * Version: @(#)win_settings_remov.h 1.0.3 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_settings_sound.h b/src/win/win_settings_sound.h index 88e7193..175cc53 100644 --- a/src/win/win_settings_sound.h +++ b/src/win/win_settings_sound.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_sound.h 1.0.5 2018/04/10 + * Version: @(#)win_settings_sound.h 1.0.6 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_settings_video.h b/src/win/win_settings_video.h index 2b7a3b3..78a79bf 100644 --- a/src/win/win_settings_video.h +++ b/src/win/win_settings_video.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_video.h 1.0.2 2018/04/14 + * Version: @(#)win_settings_video.h 1.0.3 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_snd_gain.c b/src/win/win_snd_gain.c index fed910f..fabf8fc 100644 --- a/src/win/win_snd_gain.c +++ b/src/win/win_snd_gain.c @@ -8,7 +8,7 @@ * * Implementation of the Sound Gain dialog. * - * Version: @(#)win_snd_gain.c 1.0.3 2018/03/07 + * Version: @(#)win_snd_gain.c 1.0.4 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,8 +45,9 @@ #include #include "../emu.h" #include "../config.h" -#include "../plat.h" #include "../sound/sound.h" +#include "../ui/ui.h" +#include "../plat.h" #include "win.h" @@ -58,7 +59,7 @@ static LRESULT CALLBACK #else static BOOL CALLBACK #endif -SoundGainDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h; @@ -104,7 +105,7 @@ SoundGainDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) void -SoundGainDialogCreate(HWND hwnd) +dlg_sound_gain(void) { - DialogBox(hinstance, (LPCTSTR)DLG_SND_GAIN, hwnd, SoundGainDialogProcedure); + DialogBox(hinstance, (LPCTSTR)DLG_SND_GAIN, hwndMain, dlg_proc); } diff --git a/src/win/win_status.c b/src/win/win_status.c index 22c406a..8b08466 100644 --- a/src/win/win_status.c +++ b/src/win/win_status.c @@ -8,7 +8,7 @@ * * Implementation of the Status Window dialog. * - * Version: @(#)win_status.c 1.0.3 2018/03/07 + * Version: @(#)win_status.c 1.0.4 2018/04/27 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,12 +51,13 @@ # include "../cpu/codegen.h" #endif #include "../device.h" +#include "../ui/ui.h" #include "../plat.h" #include "win.h" -HWND hwndStatus = NULL; +static HWND hwndStatus = NULL; extern int sreadlnum, swritelnum, segareads, segawrites, scycles_lost; @@ -69,7 +70,7 @@ static LRESULT CALLBACK #else static BOOL CALLBACK #endif -StatusWindowProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { char temp[4096]; uint64_t new_time; @@ -139,19 +140,19 @@ StatusWindowProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) void -StatusWindowCreate(HWND hwndParent) +dlg_status(void) { HWND hwnd; - hwnd = CreateDialog(hinstance, (LPCSTR)DLG_STATUS, - hwndParent, StatusWindowProcedure); + hwnd = CreateDialog(hinstance, (LPCSTR)DLG_STATUS, hwndMain, dlg_proc); + ShowWindow(hwnd, SW_SHOW); } /* Tell the Status window to update. */ void -ui_status_update(void) +dlg_status_update(void) { SendMessage(hwndStatus, WM_USER, 0, 0); } diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 5f082ab..39c52f4 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -8,7 +8,7 @@ * * Implementation of the Status Bar module. * - * Version: @(#)win_stbar.c 1.0.11 2018/04/24 + * Version: @(#)win_stbar.c 1.0.13 2018/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,24 +46,8 @@ #include #include #include "../emu.h" -#include "../config.h" -#include "../cpu/cpu.h" -#include "../device.h" -#include "../machine/machine.h" -#include "../floppy/fdd.h" -#include "../disk/hdd.h" -#include "../disk/hdc.h" -#include "../disk/zip.h" -#include "../cdrom/cdrom.h" -#include "../cdrom/cdrom_image.h" -#include "../cdrom/cdrom_null.h" -#include "../scsi/scsi.h" -#include "../scsi/scsi_disk.h" -#include "../network/network.h" -#include "../video/video.h" -#include "../sound/sound.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "win.h" #ifndef GWL_WNDPROC @@ -71,25 +55,157 @@ #endif +#define SBAR_HEIGHT 17 /* for 16x16 icons */ + + HWND hwndSBAR; -int update_icons = 1; static LONG_PTR OriginalProcedure; -static HMENU *sb_menu_handles; static HMENU menuSBAR; -static WCHAR **sbTips; -static int *iStatusWidths; -static int *sb_icon_flags; -static int *sb_part_meanings; -static int *sb_part_icons; -static int sb_parts = 0; -static int sb_ready = 0; +static HMENU *sb_menu; +static int sb_nparts; + + +static VOID APIENTRY +PopupMenu(HWND hwnd, POINT pt, int part) +{ + if (part >= (sb_nparts - 1)) return; + + pt.x = part * SB_ICON_WIDTH; /* justify to the left */ + pt.y = 0; /* justify to the top */ + + ClientToScreen(hwnd, (LPPOINT)&pt); + + TrackPopupMenu(sb_menu[part], + TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON, + pt.x, pt.y, 0, hwndSBAR, NULL); +} + + +/* Handle messages for the Status Bar window. */ +#ifdef __amd64__ +static LRESULT CALLBACK +#else +static BOOL CALLBACK +#endif +dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + RECT r; + POINT pt; + int idm, tag; + + switch (message) { + case WM_COMMAND: + idm = LOWORD(wParam) & 0xff00; /* low 8 bits */ + tag = LOWORD(wParam) & 0x00ff; /* high 8 bits */ + ui_sb_menu_command(idm, tag); + return(0); + + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + GetClientRect(hwnd, (LPRECT)&r); + pt.x = GET_X_LPARAM(lParam); + pt.y = GET_Y_LPARAM(lParam); + if (PtInRect((LPRECT)&r, pt)) + PopupMenu(hwnd, pt, (pt.x / SB_ICON_WIDTH)); + break; + + case WM_LBUTTONDBLCLK: + GetClientRect(hwnd, (LPRECT)&r); + pt.x = GET_X_LPARAM(lParam); + pt.y = GET_Y_LPARAM(lParam); + tag = (pt.x / SB_ICON_WIDTH); + if (PtInRect((LPRECT)&r, pt)) + ui_sb_click(tag); + break; + + default: + return(CallWindowProc((WNDPROC)OriginalProcedure, + hwnd, message, wParam, lParam)); + } + + return(0); +} + + +/* Create and set up the Status Bar window. */ +void +StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) +{ + intptr_t i; + int dw, dh; + RECT r; + + /* Load our icons into the cache for faster access. */ + for (i = 128; i < 130; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 144; i < 146; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 160; i < 162; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 176; i < 178; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 192; i < 194; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 208; i < 210; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 224; i < 226; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 259; i < 260; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 384; i < 386; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 400; i < 402; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 416; i < 418; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 432; i < 434; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + for (i = 448; i < 450; i++) + hIcon[i] = LoadIconEx((PCTSTR)i); + + GetWindowRect(hwndParent, &r); + dw = r.right - r.left; + dh = r.bottom - r.top; + + /* Load the Common Controls DLL if needed. */ + InitCommonControls(); + + /* Create the window, and make sure it's using the STATUS class. */ + hwndSBAR = CreateWindowEx(0, + STATUSCLASSNAME, + (LPCTSTR)NULL, + SBARS_SIZEGRIP|WS_CHILD|WS_VISIBLE|SBT_TOOLTIPS, + 0, dh-SBAR_HEIGHT, dw, SBAR_HEIGHT, + hwndParent, + (HMENU)idStatus, hInst, NULL); + + /* Replace the original procedure with ours. */ + OriginalProcedure = GetWindowLongPtr(hwndSBAR, GWLP_WNDPROC); + SetWindowLongPtr(hwndSBAR, GWL_WNDPROC, (LONG_PTR)&dlg_proc); + + SendMessage(hwndSBAR, SB_SETMINHEIGHT, (WPARAM)SBAR_HEIGHT, (LPARAM)0); + + /* Align the window with the parent (main) window. */ + GetWindowRect(hwndSBAR, &r); + SetWindowPos(hwndSBAR, + HWND_TOPMOST, + r.left, r.top, r.right-r.left, r.bottom-r.top, + SWP_SHOWWINDOW); + + /* Load the dummu menu for this window. */ + menuSBAR = LoadMenu(hInst, SB_MENU_NAME); + + /* Clear the menus, just in case.. */ + sb_nparts = 0; + sb_menu = NULL; +} /* Also used by win_settings.c */ -intptr_t -fdd_type_to_icon(int type) +int +sb_fdd_icon(int type) { int ret = 512; @@ -124,1291 +240,98 @@ fdd_type_to_icon(int type) } -/* FIXME: should be hdd_count() in hdd.c */ -static int -hdd_count(int bus) -{ - int c = 0; - int i; - - for (i=0; i= 'A') && - (cdrom_drives[id].host_drive <= 'Z')) { - cdrom_drives[id].host_drive = 0; - } - - goto check_menu_items; - } else { - if ((cdrom_drives[id].host_drive >= 'A') && - (cdrom_drives[id].host_drive <= 'Z')) { - if (!host_cdrom_drive_available[cdrom_drives[id].host_drive - 'A']) { - cdrom_drives[id].host_drive = 0; - } - } - } - - AppendMenu(m, MF_SEPARATOR, 0, 0); - - for (i=0; i<26; i++) { - _swprintf(s, L"Host CD/DVD Drive (%c:)", i+'A'); - if (host_cdrom_drive_available[i]) - AppendMenu(m, MF_STRING, IDM_CDROM_HOST_DRIVE | (i<<3)|id, s); - } - -check_menu_items: - if (! cdrom_drives[id].sound_on) - CheckMenuItem(m, IDM_CDROM_MUTE | id, MF_CHECKED); - - if (cdrom_drives[id].host_drive == 200) - CheckMenuItem(m, IDM_CDROM_IMAGE | id, MF_CHECKED); - else - if ((cdrom_drives[id].host_drive >= 'A') && (cdrom_drives[id].host_drive <= 'Z')) { - CheckMenuItem(m, IDM_CDROM_HOST_DRIVE | id | - ((cdrom_drives[id].host_drive - 'A') << 3), MF_CHECKED); - } else { - cdrom_drives[id].host_drive = 0; - CheckMenuItem(m, IDM_CDROM_EMPTY | id, MF_CHECKED); - } -} - - -static void -StatusBarCreateZIPSubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_NEW | id, - plat_get_string(IDS_2161)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_EXISTING | id, - plat_get_string(IDS_2162)); - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_EXISTING_WP | id, - plat_get_string(IDS_2163)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_ZIP_EJECT | id, - plat_get_string(IDS_2164)); - AppendMenu(m, MF_STRING, IDM_ZIP_RELOAD | id, - plat_get_string(IDS_2167)); - - if (zip_drives[id].image_path[0] == 0x0000) { - EnableMenuItem(m, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(m, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - } else { - EnableMenuItem(m, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(m, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - } -} - - -static void -StatusBarCreateRemovableDiskSubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_RDISK_EJECT | id, - plat_get_string(IDS_2164)); - AppendMenu(m, MF_STRING, IDM_RDISK_RELOAD | id, - plat_get_string(IDS_2167)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_RDISK_SEND_CHANGE | id, - plat_get_string(IDS_2142)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_RDISK_IMAGE | id, - plat_get_string(IDS_2168)); - AppendMenu(m, MF_STRING, IDM_RDISK_IMAGE_WP | id, - plat_get_string(IDS_2169)); -} - - -/* API */ -int -ui_sb_find_part(int tag) -{ - int found = -1; - int i; - - if (!sb_ready || (sb_parts == 0) || (sb_part_meanings == NULL)) { - return -1; - } - - for (i=0; i= SB_TEXT) || !sb_ready || (sb_parts == 0) || (sb_icon_flags == NULL) || (sb_part_icons == NULL)) { - return; - } + sb_menu = (HMENU *)malloc(parts * sizeof(HMENU)); + memset(sb_menu, 0x00, parts * sizeof(HMENU)); - temp_flags |= active; - - found = ui_sb_find_part(tag); - if (found != -1) { - if (temp_flags != (sb_icon_flags[found] & 1)) { - sb_icon_flags[found] &= ~1; - sb_icon_flags[found] |= active; - - sb_part_icons[found] &= ~257; - sb_part_icons[found] |= sb_icon_flags[found]; - - SendMessage(hwndSBAR, SB_SETICON, found, - (LPARAM)hIcon[sb_part_icons[found]]); - } - } + sb_nparts = parts; } -/* API: This is for the drive state indicator. */ void -ui_sb_update_icon_state(int tag, int state) +sb_menu_destroy(void) { - int found = -1; + int i; - if (((tag & 0xf0) >= SB_HDD) || !sb_ready || (sb_parts == 0) || (sb_icon_flags == NULL) || (sb_part_icons == NULL)) { - return; + if (!sb_nparts || (sb_menu == NULL)) return; + + for (i = 0; i < sb_nparts; i++) { + if (sb_menu[i] != NULL) + DestroyMenu(sb_menu[i]); } - found = ui_sb_find_part(tag); - if (found != -1) { - sb_icon_flags[found] &= ~256; - sb_icon_flags[found] |= state ? 256 : 0; + free(sb_menu); - sb_part_icons[found] &= ~257; - sb_part_icons[found] |= sb_icon_flags[found]; - - SendMessage(hwndSBAR, SB_SETICON, found, - (LPARAM)hIcon[sb_part_icons[found]]); - } + sb_menu = NULL; } -static void -StatusBarCreateFloppyTip(int part) -{ - WCHAR wtext[512]; - WCHAR tempTip[512]; - - int drive = sb_part_meanings[part] & 0xf; - - mbstowcs(wtext, fdd_getname(fdd_get_type(drive)), - strlen(fdd_getname(fdd_get_type(drive))) + 1); - if (wcslen(floppyfns[drive]) == 0) { - _swprintf(tempTip, plat_get_string(IDS_2158), - drive+1, wtext, plat_get_string(IDS_2057)); - } else { - _swprintf(tempTip, plat_get_string(IDS_2158), - drive+1, wtext, floppyfns[drive]); - } - - if (sbTips[part] != NULL) { - free(sbTips[part]); - sbTips[part] = NULL; - } - sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2); - wcscpy(sbTips[part], tempTip); -} - - -static void -StatusBarCreateCdromTip(int part) -{ - WCHAR wtext[512]; - WCHAR tempTip[512]; - WCHAR *szText; - int id; - int drive = sb_part_meanings[part] & 0xf; - int bus = cdrom_drives[drive].bus_type; - - id = IDS_4352 + (bus - 1); - szText = plat_get_string(id); - - if (cdrom_drives[drive].host_drive == 200) { - if (wcslen(cdrom_image[drive].image_path) == 0) { - _swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057)); - } else { - _swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, cdrom_image[drive].image_path); - } - } else if ((cdrom_drives[drive].host_drive >= 'A') && (cdrom_drives[drive].host_drive <= 'Z')) { - _swprintf(wtext, plat_get_string(IDS_2058), cdrom_drives[drive].host_drive & ~0x20); - _swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, wtext); - } else { - _swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057)); - } - - if (sbTips[part] != NULL) { - free(sbTips[part]); - sbTips[part] = NULL; - } - sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2); - wcscpy(sbTips[part], tempTip); -} - - -static void -StatusBarCreateZIPTip(int part) -{ - WCHAR tempTip[512]; - - int drive = sb_part_meanings[part] & 0xf; - - int type = zip_drives[drive].is_250 ? 250 : 100; - - if (wcslen(zip_drives[drive].image_path) == 0) { - _swprintf(tempTip, plat_get_string(IDS_2177), - drive+1, type, plat_get_string(IDS_2057)); - } else { - _swprintf(tempTip, plat_get_string(IDS_2177), - drive+1, type, zip_drives[drive].image_path); - } - - if (sbTips[part] != NULL) { - free(sbTips[part]); - sbTips[part] = NULL; - } - sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2); - wcscpy(sbTips[part], tempTip); -} - - -static void -StatusBarCreateRemovableDiskTip(int part) -{ - WCHAR tempTip[512]; - int drive = sb_part_meanings[part] & 0x1f; - - if (wcslen(hdd[drive].fn) == 0) { - _swprintf(tempTip, plat_get_string(IDS_4115), drive, plat_get_string(IDS_2057)); - } else { - _swprintf(tempTip, plat_get_string(IDS_4115), drive, hdd[drive].fn); - } - - if (sbTips[part] != NULL) { - free(sbTips[part]); - sbTips[part] = NULL; - } - sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2); - wcscpy(sbTips[part], tempTip); -} - - -static void -StatusBarCreateDiskTip(int part) -{ - WCHAR tempTip[512]; - WCHAR *szText; - int id; - int bus = sb_part_meanings[part] & 0xf; - - id = IDS_4352 + (bus - 1); - szText = plat_get_string(id); - - _swprintf(tempTip, plat_get_string(IDS_4096), szText); - if (sbTips[part] != NULL) - free(sbTips[part]); - sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2); - wcscpy(sbTips[part], tempTip); -} - - -static void -StatusBarCreateNetworkTip(int part) -{ - WCHAR tempTip[512]; - - _swprintf(tempTip, plat_get_string(IDS_2069)); - - if (sbTips[part] != NULL) - free(sbTips[part]); - sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2); - wcscpy(sbTips[part], tempTip); -} - - -static void -StatusBarCreateSoundTip(int part) -{ - WCHAR tempTip[512]; - - _swprintf(tempTip, plat_get_string(IDS_2068)); - - if (sbTips[part] != NULL) - free(sbTips[part]); - sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2); - wcscpy(sbTips[part], tempTip); -} - - -/* API */ +/* Create a menu for a status bar part. */ void -ui_sb_update_tip(int meaning) -{ - int part = -1; - int i; - - if (!sb_ready || (sb_parts == 0) || (sb_part_meanings == NULL)) return; - - for (i=0; i 0) { - for (i = 0; i < sb_parts; i++) - SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)NULL); - SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)0, (LPARAM)NULL); - - if (iStatusWidths) { - free(iStatusWidths); - iStatusWidths = NULL; - } - if (sb_part_meanings) { - free(sb_part_meanings); - sb_part_meanings = NULL; - } - if (sb_part_icons) { - free(sb_part_icons); - sb_part_icons = NULL; - } - if (sb_icon_flags) { - free(sb_icon_flags); - sb_icon_flags = NULL; - } - StatusBarDestroyMenus(); - StatusBarDestroyTips(); - } - - sb_parts = 0; - for (i=0; i= 'A') && (cdrom_drives[id].host_drive <= 'Z')) { - sb_icon_flags[i] = 0; - } else { - sb_icon_flags[i] = 256; - } - sb_part_icons[i] = 160 | sb_icon_flags[i]; - sb_menu_handles[i] = StatusBarCreatePopupMenu(i); - StatusBarCreateCdromSubmenu(sb_menu_handles[i], sb_part_meanings[i] & 0xf); - EnableMenuItem(sb_menu_handles[i], IDM_CDROM_RELOAD | (sb_part_meanings[i] & 0xf), MF_BYCOMMAND | MF_GRAYED); - StatusBarCreateCdromTip(i); - break; - - case SB_ZIP: /* Iomega ZIP */ - sb_icon_flags[i] = (wcslen(zip_drives[sb_part_meanings[i] & 0xf].image_path) == 0) ? 256 : 0; - sb_part_icons[i] = 176 + sb_icon_flags[i]; - sb_menu_handles[i] = StatusBarCreatePopupMenu(i); - StatusBarCreateZIPSubmenu(sb_menu_handles[i], sb_part_meanings[i] & 0xf); - EnableMenuItem(sb_menu_handles[i], IDM_ZIP_EJECT | (sb_part_meanings[i] & 0xf), MF_BYCOMMAND | ((sb_icon_flags[i] & 256) ? MF_GRAYED : MF_ENABLED)); - StatusBarCreateZIPTip(i); - break; - - case SB_RDISK: /* Removable hard disk */ - sb_icon_flags[i] = (wcslen(hdd[sb_part_meanings[i] & 0x1f].fn) == 0) ? 256 : 0; - sb_part_icons[i] = 192 + sb_icon_flags[i]; - sb_menu_handles[i] = StatusBarCreatePopupMenu(i); - StatusBarCreateRemovableDiskSubmenu(sb_menu_handles[i], sb_part_meanings[i] & 0x1f); - EnableMenuItem(sb_menu_handles[i], IDM_RDISK_EJECT | (sb_part_meanings[i] & 0x1f), MF_BYCOMMAND | ((sb_icon_flags[i] & 256) ? MF_GRAYED : MF_ENABLED)); - EnableMenuItem(sb_menu_handles[i], IDM_RDISK_RELOAD | (sb_part_meanings[i] & 0x1f), MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(sb_menu_handles[i], IDM_RDISK_SEND_CHANGE | (sb_part_meanings[i] & 0x1f), MF_BYCOMMAND | ((sb_icon_flags[i] & 256) ? MF_GRAYED : MF_ENABLED)); - StatusBarCreateRemovableDiskTip(i); - break; - - case SB_HDD: /* Hard disk */ - sb_part_icons[i] = 208; - StatusBarCreateDiskTip(i); - break; - - case SB_NETWORK: /* Network */ - sb_part_icons[i] = 224; - StatusBarCreateNetworkTip(i); - break; - - case SB_SOUND: /* Sound */ - sb_part_icons[i] = 259; - StatusBarCreateSoundTip(i); - break; - - case SB_TEXT: /* Status text */ - SendMessage(hwndSBAR, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM)L""); - sb_part_icons[i] = -1; - break; - } - - if (sb_part_icons[i] != -1) { - SendMessage(hwndSBAR, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM)L""); - SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)hIcon[sb_part_icons[i]]); - SendMessage(hwndSBAR, SB_SETTIPTEXT, i, (LPARAM)sbTips[i]); - } else { - SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)NULL); - } - } - - sb_ready = 1; -} - - -static VOID APIENTRY -StatusBarPopupMenu(HWND hwnd, POINT pt, int id) -{ - if (id >= (sb_parts - 1)) return; - - pt.x = id * SB_ICON_WIDTH; /* Justify to the left. */ - pt.y = 0; /* Justify to the top. */ - ClientToScreen(hwnd, (LPPOINT) &pt); - TrackPopupMenu(sb_menu_handles[id], - TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON, - pt.x, pt.y, 0, hwndSBAR, NULL); + if (idm >= 0) + AppendMenu(sb_menu[part], MF_STRING, idm, str); + else + AppendMenu(sb_menu[part], MF_SEPARATOR, 0, NULL); } void -ui_sb_mount_floppy_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name) +sb_menu_enable_item(int part, int idm, int val) { - fdd_close(id); - ui_writeprot[id] = wp; - fdd_load(id, file_name); - ui_sb_update_icon_state(SB_FLOPPY | id, wcslen(floppyfns[id]) ? 0 : 1); - EnableMenuItem(sb_menu_handles[part], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | (wcslen(floppyfns[id]) ? MF_ENABLED : MF_GRAYED)); - EnableMenuItem(sb_menu_handles[part], IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | (wcslen(floppyfns[id]) ? MF_ENABLED : MF_GRAYED)); - ui_sb_update_tip(SB_FLOPPY | id); - config_save(); + EnableMenuItem(sb_menu[part], idm, + val ? MF_BYCOMMAND|MF_ENABLED : MF_BYCOMMAND|MF_GRAYED); } void -ui_sb_mount_zip_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name) +sb_menu_set_item(int part, int idm, int val) { - zip_close(id); - zip_drives[id].ui_writeprot = wp; - zip_load(id, file_name); - zip_insert(id); - ui_sb_update_icon_state(SB_ZIP | id, wcslen(zip_drives[id].image_path) ? 0 : 1); - EnableMenuItem(sb_menu_handles[part], IDM_ZIP_EJECT | id, MF_BYCOMMAND | (wcslen(zip_drives[id].image_path) ? MF_ENABLED : MF_GRAYED)); - EnableMenuItem(sb_menu_handles[part], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | (wcslen(zip_drives[id].image_path) ? MF_GRAYED : MF_ENABLED)); - ui_sb_update_tip(SB_ZIP | id); - config_save(); + CheckMenuItem(sb_menu[part], idm, val ? MF_CHECKED : MF_UNCHECKED); } -/* Handle messages for the Status Bar window. */ -#ifdef __amd64__ -static LRESULT CALLBACK -#else -static BOOL CALLBACK -#endif -StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - WCHAR temp_path[1024]; - RECT rc; - POINT pt; - int new_cdrom_drive; - int ret = 0; - int item_id = 0; - int item_params = 0; - int id = 0; - int part = 0; - int letter = 0; - - switch (message) { - case WM_COMMAND: - item_id = LOWORD(wParam) & 0xff00; /* low 8 bits */ - item_params = LOWORD(wParam) & 0x00ff; /* high 8 bits */ - - switch (item_id) { - case IDM_FLOPPY_IMAGE_NEW: - id = item_params & 0x0003; - part = ui_sb_find_part(SB_FLOPPY | id); - NewFloppyDialogCreate(hwnd, id, part); - break; - - case IDM_FLOPPY_IMAGE_EXISTING: - case IDM_FLOPPY_IMAGE_EXISTING_WP: - id = item_params & 0x0003; - part = ui_sb_find_part(SB_FLOPPY | id); - if ((part == -1) || (sb_menu_handles == NULL)) - break; - - ret = file_dlg_st(hwnd, IDS_2159, floppyfns[id], 0); - if (! ret) - ui_sb_mount_floppy_img(id, part, (item_id == IDM_FLOPPY_IMAGE_EXISTING_WP) ? 1 : 0, wopenfilestring); - break; - - case IDM_FLOPPY_EJECT: - id = item_params & 0x0003; - part = ui_sb_find_part(SB_FLOPPY | id); - if ((part == -1) || (sb_menu_handles == NULL)) - break; - - fdd_close(id); - ui_sb_update_icon_state(SB_FLOPPY | id, 1); - EnableMenuItem(sb_menu_handles[part], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(sb_menu_handles[part], IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_update_tip(SB_FLOPPY | id); - config_save(); - break; - - case IDM_FLOPPY_EXPORT_TO_86F: - id = item_params & 0x0003; - part = ui_sb_find_part(SB_FLOPPY | id); - if ((part == -1) || (sb_menu_handles == NULL)) - break; - - ret = file_dlg_st(hwnd, IDS_2173, floppyfns[id], 1); - if (! ret) { - plat_pause(1); - ret = d86f_export(id, wopenfilestring); - if (!ret) - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_4108); - plat_pause(0); - } - break; - - case IDM_CDROM_MUTE: - id = item_params & 0x0007; - part = ui_sb_find_part(SB_CDROM | id); - if ((part == -1) || (sb_menu_handles == NULL)) - break; - - cdrom_drives[id].sound_on ^= 1; - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_MUTE | id, cdrom_drives[id].sound_on ? MF_UNCHECKED : MF_CHECKED); - config_save(); - sound_cd_stop(); - break; - - case IDM_CDROM_EMPTY: - id = item_params & 0x0007; - cdrom_eject(id); - break; - - case IDM_CDROM_RELOAD: - id = item_params & 0x0007; - cdrom_reload(id); - break; - - case IDM_CDROM_IMAGE: - id = item_params & 0x0007; - part = ui_sb_find_part(SB_CDROM | id); - if ((part == -1) || (sb_menu_handles == NULL)) - break; - - if (!file_dlg_st(hwnd, IDS_2075, cdrom_image[id].image_path, 0)) { - cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive; - wcscpy(temp_path, wopenfilestring); - if (!cdrom_image[id].prev_image_path) - cdrom_image[id].prev_image_path = (wchar_t *) malloc(1024); - wcscpy(cdrom_image[id].prev_image_path, cdrom_image[id].image_path); - cdrom_drives[id].handler->exit(id); - cdrom_close(id); - image_open(id, temp_path); - /* Signal media change to the emulated machine. */ - cdrom_insert(id); - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED); - if ((cdrom_drives[id].host_drive >= 'A') && (cdrom_drives[id].host_drive <= 'Z')) { - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_UNCHECKED); - } - cdrom_drives[id].host_drive = (wcslen(cdrom_image[id].image_path) == 0) ? 0 : 200; - if (cdrom_drives[id].host_drive == 200) { - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_CHECKED); - ui_sb_update_icon_state(SB_CDROM | id, 0); - } else { - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_UNCHECKED); - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED); - ui_sb_update_icon_state(SB_CDROM | id, 1); - } - EnableMenuItem(sb_menu_handles[part], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_update_tip(SB_CDROM | id); - config_save(); - } - break; - - case IDM_CDROM_HOST_DRIVE: - id = item_params & 0x0007; - letter = ((item_params >> 3) & 0x001f) + 'A'; - part = ui_sb_find_part(SB_CDROM | id); - if ((part == -1) || (sb_menu_handles == NULL)) - { - break; - } - - new_cdrom_drive = letter; - if (cdrom_drives[id].host_drive == new_cdrom_drive) - { - /* Switching to the same drive. Do nothing. */ - break; - } - cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive; - cdrom_drives[id].handler->exit(id); - cdrom_close(id); - ioctl_open(id, new_cdrom_drive); - /* Signal media change to the emulated machine. */ - cdrom_insert(id); - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED); - if ((cdrom_drives[id].host_drive >= 'A') && (cdrom_drives[id].host_drive <= 'Z')) - { - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_UNCHECKED); - } - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_UNCHECKED); - cdrom_drives[id].host_drive = new_cdrom_drive; - CheckMenuItem(sb_menu_handles[part], IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_CHECKED); - EnableMenuItem(sb_menu_handles[part], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - ui_sb_update_icon_state(SB_CDROM | id, 0); - ui_sb_update_tip(SB_CDROM | id); - config_save(); - break; - - case IDM_ZIP_IMAGE_NEW: - id = item_params & 0x0003; - part = ui_sb_find_part(SB_ZIP | id); - NewFloppyDialogCreate(hwnd, id | 0x80, part); /* NewZIPDialogCreate */ - break; - - case IDM_ZIP_IMAGE_EXISTING: - case IDM_ZIP_IMAGE_EXISTING_WP: - id = item_params & 0x0003; - part = ui_sb_find_part(SB_ZIP | id); - if ((part == -1) || (sb_menu_handles == NULL)) - break; - - ret = file_dlg_st(hwnd, IDS_2175, zip_drives[id].image_path, 0); - if (! ret) - ui_sb_mount_zip_img(id, part, (item_id == IDM_ZIP_IMAGE_EXISTING_WP) ? 1 : 0, wopenfilestring); - break; - - case IDM_ZIP_EJECT: - id = item_params & 0x0003; - zip_eject(id); - break; - - case IDM_ZIP_RELOAD: - id = item_params & 0x0003; - zip_reload(id); - break; - - case IDM_RDISK_EJECT: - id = item_params & 0x001f; - removable_disk_eject(id); - break; - - case IDM_RDISK_RELOAD: - id = item_params & 0x001f; - removable_disk_reload(id); - break; - - case IDM_RDISK_SEND_CHANGE: - id = item_params & 0x001f; - scsi_disk_insert(id); - break; - - case IDM_RDISK_IMAGE: - case IDM_RDISK_IMAGE_WP: - id = item_params & 0x001f; - ret = file_dlg_st(hwnd, IDS_4106, hdd[id].fn, id); - if (!ret) { - removable_disk_unload(id); - memset(hdd[id].fn, 0, sizeof(hdd[id].fn)); - wcscpy(hdd[id].fn, wopenfilestring); - hdd[id].wp = (item_id == IDM_RDISK_IMAGE_WP) ? 1 : 0; - scsi_loadhd(hdd[id].id.scsi.id, hdd[id].id.scsi.lun, id); - scsi_disk_insert(id); - if (wcslen(hdd[id].fn) > 0) { - ui_sb_update_icon_state(SB_RDISK | id, 0); - EnableMenuItem(sb_menu_handles[part], IDM_RDISK_EJECT | id, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(sb_menu_handles[part], IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(sb_menu_handles[part], IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | MF_ENABLED); - } - else { - ui_sb_update_icon_state(SB_RDISK | id, 1); - EnableMenuItem(sb_menu_handles[part], IDM_RDISK_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(sb_menu_handles[part], IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(sb_menu_handles[part], IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | MF_GRAYED); - } - ui_sb_update_tip(SB_RDISK | id); - config_save(); - } - break; - - default: - break; - } - return(0); - - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - GetClientRect(hwnd, (LPRECT)& rc); - pt.x = GET_X_LPARAM(lParam); - pt.y = GET_Y_LPARAM(lParam); - if (PtInRect((LPRECT) &rc, pt)) - StatusBarPopupMenu(hwnd, pt, (pt.x / SB_ICON_WIDTH)); - break; - - case WM_LBUTTONDBLCLK: - GetClientRect(hwnd, (LPRECT)& rc); - pt.x = GET_X_LPARAM(lParam); - pt.y = GET_Y_LPARAM(lParam); - item_id = (pt.x / SB_ICON_WIDTH); - if (PtInRect((LPRECT) &rc, pt) && (item_id < sb_parts)) { - if (sb_part_meanings[item_id] == SB_SOUND) - SoundGainDialogCreate(hwndMain); - } - break; - - default: - return(CallWindowProc((WNDPROC)OriginalProcedure, - hwnd, message, wParam, lParam)); - } - - return(0); -} - - -/* API: Create and set up the Status Bar window. */ void -StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) +sb_set_icon(int part, int icon) { - RECT rectDialog; - int dw, dh; - uintptr_t i; + HANDLE ptr; - /* Load our icons into the cache for faster access. */ - for (i = 128; i < 130; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 144; i < 146; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 160; i < 162; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 176; i < 178; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 192; i < 194; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 208; i < 210; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 224; i < 226; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 259; i < 260; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 384; i < 386; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 400; i < 402; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 416; i < 418; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 432; i < 434; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); - for (i = 448; i < 450; i++) - hIcon[i] = LoadIconEx((PCTSTR) i); + if (icon == -1) ptr = NULL; + else ptr = hIcon[(intptr_t)icon]; - GetWindowRect(hwndParent, &rectDialog); - dw = rectDialog.right - rectDialog.left; - dh = rectDialog.bottom - rectDialog.top; - - /* Load the Common Controls DLL if needed. */ - InitCommonControls(); - - /* Create the window, and make sure it's using the STATUS class. */ - hwndSBAR = CreateWindowEx(0, - STATUSCLASSNAME, - (LPCTSTR)NULL, - SBARS_SIZEGRIP|WS_CHILD|WS_VISIBLE|SBT_TOOLTIPS, - 0, dh-17, dw, 17, - hwndParent, - (HMENU)idStatus, hInst, NULL); - - /* Replace the original procedure with ours. */ - OriginalProcedure = GetWindowLongPtr(hwndSBAR, GWLP_WNDPROC); - SetWindowLongPtr(hwndSBAR, GWL_WNDPROC, (LONG_PTR)&StatusBarProcedure); - - SendMessage(hwndSBAR, SB_SETMINHEIGHT, (WPARAM)17, (LPARAM)0); - - /* Align the window with the parent (main) window. */ - GetWindowRect(hwndSBAR, &rectDialog); - SetWindowPos(hwndSBAR, - HWND_TOPMOST, - rectDialog.left, rectDialog.top, - rectDialog.right-rectDialog.left, - rectDialog.bottom-rectDialog.top, - SWP_SHOWWINDOW); - - /* Load the dummu menu for this window. */ - menuSBAR = LoadMenu(hInst, SB_MENU_NAME); - - /* Initialize the status bar. This is clumsy. */ - sb_parts = 1; - iStatusWidths = (int *)malloc(sb_parts * sizeof(int)); - memset(iStatusWidths, 0, sb_parts * sizeof(int)); - sb_part_meanings = (int *)malloc(sb_parts * sizeof(int)); - memset(sb_part_meanings, 0, sb_parts * sizeof(int)); - sb_part_icons = (int *)malloc(sb_parts * sizeof(int)); - memset(sb_part_icons, 0, sb_parts * sizeof(int)); - sb_icon_flags = (int *)malloc(sb_parts * sizeof(int)); - memset(sb_icon_flags, 0, sb_parts * sizeof(int)); - sb_menu_handles = (HMENU *)malloc(sb_parts * sizeof(HMENU)); - memset(sb_menu_handles, 0, sb_parts * sizeof(HMENU)); - sbTips = (WCHAR **)malloc(sb_parts * sizeof(WCHAR *)); - memset(sbTips, 0, sb_parts * sizeof(WCHAR *)); - sb_parts = 0; - iStatusWidths[sb_parts] = -1; - sb_part_meanings[sb_parts] = SB_TEXT; - sb_part_icons[sb_parts] = -1; - sb_parts++; - SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)sb_parts, (LPARAM)iStatusWidths); - SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS, - (LPARAM)L"Welcome to VARCem !"); - sb_ready = 1; + SendMessage(hwndSBAR, SB_SETICON, part, (LPARAM)ptr); } -/* API (Settings) */ void -ui_sb_check_menu_item(int tag, int id, int chk) +sb_set_text(int part, const wchar_t *str) { - int part; - - part = ui_sb_find_part(tag); - if ((part == -1) || (sb_menu_handles == NULL)) - return; - - CheckMenuItem(sb_menu_handles[part], id, chk); + SendMessage(hwndSBAR, SB_SETTEXT, part | SBT_NOBORDERS, (LPARAM)str); } -/* API (Settings) */ void -ui_sb_enable_menu_item(int tag, int id, int flg) +sb_set_tooltip(int part, const wchar_t *str) { - int part; - - part = ui_sb_find_part(tag); - if ((part == -1) || (sb_menu_handles == NULL)) - return; - - EnableMenuItem(sb_menu_handles[part], id, flg); -} - - -/* API */ -void -ui_sb_set_text_w(wchar_t *wstr) -{ - int part = -1; - int i; - - if (!sb_ready || (sb_parts == 0) || (sb_part_meanings == NULL)) return; - - for (i=0; i * Miran Grca, @@ -52,8 +52,8 @@ #include "../input/keyboard.h" #include "../input/mouse.h" #include "../video/video.h" +#include "../ui/ui.h" #include "../plat.h" -#include "../ui.h" #include "win.h" #include "win_d3d.h" @@ -113,7 +113,7 @@ LoadIconEx(PCTSTR pszIconName) #if 0 static void -win_menu_update(void) +menu_update(void) { menuMain = LoadMenu(hinstance, L"MainMenu")); @@ -121,258 +121,26 @@ win_menu_update(void) initmenu(); - SetMenu(hwndMain, menu); + SetMenu(memnuMain, menu); win_title_update = 1; } #endif -static void -video_toggle_option(HMENU h, int *val, int id) +/* Enable or disable a menu item. */ +void +menu_enable_item(int idm, int val) { - startblit(); - video_wait_for_blit(); - *val ^= 1; - CheckMenuItem(h, id, *val ? MF_CHECKED : MF_UNCHECKED); - endblit(); - config_save(); - device_force_redraw(); + EnableMenuItem(menuMain, idm, (val) ? MF_ENABLED : MF_DISABLED); } -#if defined(ENABLE_LOG_TOGGLES) || defined(ENABLE_LOG_COMMANDS) -/* Simplest way to handle all these, for now.. */ -static void -SetLoggingItem(int idm, int val) +/* Set (check) or clear (uncheck) a menu item. */ +void +menu_set_item(int idm, int val) { - int *ptr = NULL; - - switch(idm) { -#ifdef ENABLE_PCI_LOG - case IDM_LOG_PCI: - ptr = &pci_do_log; - break; -#endif - -#ifdef ENABLE_KEYBOARD_LOG - case IDM_LOG_KEYBOARD: - ptr = &keyboard_do_log; - break; -#endif - -#ifdef ENABLE_SERIAL_LOG - case IDM_LOG_SERIAL: - ptr = &serial_do_log; - break; -#endif - -#ifdef ENABLE_FDC_LOG - case IDM_LOG_FDC: - ptr = &fdc_do_log; - break; -#endif - -#ifdef ENABLE_D86F_LOG - case IDM_LOG_D86F: - ptr = &d86f_do_log; - break; -#endif - -#ifdef ENABLE_HDC_LOG - case IDM_LOG_HDC: - ptr = &hdc_do_log; - break; -#endif - -#ifdef ENABLE_HDD_LOG - case IDM_LOG_HDD: - ptr = &hdd_do_log; - break; -#endif - -#ifdef ENABLE_ZIP_LOG - case IDM_LOG_ZIP: - ptr = &zip_do_log; - break; -#endif - -#ifdef ENABLE_CDROM_LOG - case IDM_LOG_CDROM: - ptr = &cdrom_do_log; - break; -#endif - -#ifdef ENABLE_CDROM_IMAGE_LOG - case IDM_LOG_CDROM_IMAGE: - ptr = &cdrom_image_do_log; - break; -#endif - -#ifdef ENABLE_CDROM_IOCTL_LOG - case IDM_LOG_CDROM_IOCTL: - ptr = &cdrom_ioctl_do_log; - break; -#endif - -#ifdef ENABLE_NIC_LOG - case IDM_LOG_NIC: - ptr = &nic_do_log; - break; -#endif - -#ifdef ENABLE_SOUND_EMU8K_LOG - case IDM_LOG_SOUND_EMU8K: - ptr = &sound_emu8k_do_log; - break; -#endif - -#ifdef ENABLE_SOUND_MPU401_LOG - case IDM_LOG_SOUND_MPU401: - ptr = &sound_mpu401_do_log; - break; -#endif - -#ifdef ENABLE_SOUND_DEV_LOG - case IDM_LOG_SOUND_DEV: - ptr = &sound_dev_do_log; - break; -#endif - -#ifdef ENABLE_SCSI_BUS_LOG - case IDM_LOG_SCSI_BUS: - ptr = &scsi_bus_do_log; - break; -#endif - -#ifdef ENABLE_SCSI_DISK_LOG - case IDM_LOG_SCSI_DISK: - ptr = &scsi_hd_do_log; - break; -#endif - -#ifdef ENABLE_SCSI_DEV_LOG - case IDM_LOG_SCSI_DEV: - ptr = &scsi_dev_do_log; - break; -#endif - -#ifdef ENABLE_SCSI_X54X_LOG - case IDM_LOG_SCSI_X54X: - ptr = &scsi_x54x_do_log; - break; -#endif - -#ifdef ENABLE_VOODOO_LOG - case IDM_LOG_VOODOO: - ptr = &voodoo_do_log; - break; -#endif - } - - if (ptr != NULL) { - /* Set the desired value. */ - if (val != 0xff) { - /* Initialize the logging value. */ - if (val < 0) *ptr ^= 1; - else *ptr = val; - } - - /* And update its menu entry. */ - CheckMenuItem(menuMain, idm, (*ptr) ? MF_CHECKED : MF_UNCHECKED); - } -} -#endif - - -static void -ResetAllMenus(void) -{ -#ifndef DEV_BRANCH - /* FIXME: until we fix these.. --FvK */ - EnableMenuItem(menuMain, IDM_CONFIG_LOAD, MF_DISABLED); - EnableMenuItem(menuMain, IDM_CONFIG_SAVE, MF_DISABLED); -#endif - - CheckMenuItem(menuMain, IDM_KBD_RCTRL_IS_LALT, MF_UNCHECKED); - - CheckMenuItem(menuMain, IDM_UPDATE_ICONS, MF_UNCHECKED); - -#ifdef ENABLE_LOG_TOGGLES - SetLoggingItem(IDM_LOG_PCI, 0xff); - SetLoggingItem(IDM_LOG_KEYBOARD, 0xff); - SetLoggingItem(IDM_LOG_SERIAL, 0xff); - SetLoggingItem(IDM_LOG_FDC, 0xff); - SetLoggingItem(IDM_LOG_D86F, 0xff); - SetLoggingItem(IDM_LOG_HDC, 0xff); - SetLoggingItem(IDM_LOG_HDD, 0xff); - SetLoggingItem(IDM_LOG_ZIP, 0xff); - SetLoggingItem(IDM_LOG_CDROM, 0xff); - SetLoggingItem(IDM_LOG_CDROM_IMAGE, 0xff); - SetLoggingItem(IDM_LOG_CDROM_IOCTL, 0xff); - SetLoggingItem(IDM_LOG_NIC, 0xff); - SetLoggingItem(IDM_LOG_SOUND_EMU8K, 0xff); - SetLoggingItem(IDM_LOG_SOUND_MPU401, 0xff); - SetLoggingItem(IDM_LOG_SOUND_DEV, 0xff); - SetLoggingItem(IDM_LOG_SCSI_BUS, 0xff); - SetLoggingItem(IDM_LOG_SCSI_DISK, 0xff); - SetLoggingItem(IDM_LOG_SCSI_DEV, 0xff); - SetLoggingItem(IDM_LOG_SCSI_X54X, 0xff); - SetLoggingItem(IDM_LOG_VOODOO, 0xff); -#endif - - CheckMenuItem(menuMain, IDM_VID_FORCE43, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_OVERSCAN, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_INVERT, MF_UNCHECKED); - - CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_DDRAW+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_DDRAW+1, MF_UNCHECKED); -#ifdef USE_VNC - CheckMenuItem(menuMain, IDM_VID_DDRAW+2, MF_UNCHECKED); -#endif -#ifdef USE_VNC - CheckMenuItem(menuMain, IDM_VID_DDRAW+3, MF_UNCHECKED); -#endif - CheckMenuItem(menuMain, IDM_VID_FS_FULL+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+1, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+2, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+3, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+4, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_REMEMBER, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+1, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+2, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+3, MF_UNCHECKED); - - CheckMenuItem(menuMain, IDM_VID_CGACON, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+1, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+2, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+1, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+2, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+3, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+4, MF_UNCHECKED); - - CheckMenuItem(menuMain, IDM_KBD_RCTRL_IS_LALT, rctrl_is_lalt ? MF_CHECKED : MF_UNCHECKED); - - CheckMenuItem(menuMain, IDM_UPDATE_ICONS, update_icons ? MF_CHECKED : MF_UNCHECKED); - - CheckMenuItem(menuMain, IDM_VID_FORCE43, force_43?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_INVERT, invert_display ? MF_CHECKED : MF_UNCHECKED); - - if (vid_resize) - CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_DDRAW+vid_api, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+vid_fullscreen_scale, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_REMEMBER, window_remember?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+scale, MF_CHECKED); - - CheckMenuItem(menuMain, IDM_VID_CGACON, vid_cga_contrast?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+vid_graytype, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+vid_grayscale, MF_CHECKED); + CheckMenuItem(menuMain, idm, val ? MF_CHECKED : MF_UNCHECKED); } @@ -412,10 +180,11 @@ LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) static LRESULT CALLBACK MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - HMENU hmenu; +// HMENU hmenu; RECT rect; int sb_borders[3]; int temp_x, temp_y; + int idm; switch (message) { case WM_CREATE: @@ -428,59 +197,18 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: UpdateWindow(hwnd); - hmenu = GetMenu(hwnd); - switch (LOWORD(wParam)) { - case IDM_ACTION_SCREENSHOT: - take_screenshot(); - break; +// We may need this later. +// hmenu = GetMenu(hwnd); + idm = LOWORD(wParam); - case IDM_ACTION_HRESET: - pc_reset(1); - break; - - case IDM_ACTION_RESET_CAD: - pc_reset(0); - break; - - case IDM_ACTION_EXIT: + /* Let the general UI handle it first, and then we do. */ + if (! ui_menu_command(idm)) switch(idm) { + case IDM_EXIT: PostQuitMessage(0); break; - case IDM_ACTION_CTRL_ALT_ESC: - keyboard_send_cae(); - break; - - case IDM_ACTION_PAUSE: - plat_pause(dopause ^ 1); - CheckMenuItem(menuMain, IDM_ACTION_PAUSE, dopause ? MF_CHECKED : MF_UNCHECKED); - break; - - case IDM_CONFIG: - plat_pause(1); - if (win_settings_open(hwnd, 1) == 2) - pc_reset_hard_init(); - plat_pause(0); - break; - - case IDM_ABOUT: - AboutDialogCreate(hwnd); - break; - - case IDM_STATUS: - StatusWindowCreate(hwnd); - break; - - case IDM_UPDATE_ICONS: - update_icons ^= 1; - CheckMenuItem(hmenu, IDM_UPDATE_ICONS, update_icons ? MF_CHECKED : MF_UNCHECKED); - config_save(); - break; - - case IDM_VID_RESIZE: - vid_resize = !vid_resize; - CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize)? MF_CHECKED : MF_UNCHECKED); + case IDM_RESIZE: GetWindowRect(hwnd, &rect); - if (vid_resize) SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW) | WS_VISIBLE); else @@ -508,23 +236,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ClipCursor(&rect); } - - if (vid_resize) { - CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED); - CheckMenuItem(hmenu, IDM_VID_SCALE_2X, MF_CHECKED); - scale = 1; - } - EnableMenuItem(hmenu, IDM_VID_SCALE_1X, vid_resize ? MF_GRAYED : MF_ENABLED); - EnableMenuItem(hmenu, IDM_VID_SCALE_2X, vid_resize ? MF_GRAYED : MF_ENABLED); - EnableMenuItem(hmenu, IDM_VID_SCALE_3X, vid_resize ? MF_GRAYED : MF_ENABLED); - EnableMenuItem(hmenu, IDM_VID_SCALE_4X, vid_resize ? MF_GRAYED : MF_ENABLED); - doresize = 1; - config_save(); break; - case IDM_VID_REMEMBER: - window_remember = !window_remember; - CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED); + case IDM_REMEMBER: GetWindowRect(hwnd, &rect); if (window_remember) { window_x = rect.left; @@ -534,148 +248,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } config_save(); break; - - case IDM_VID_DDRAW: - case IDM_VID_D3D: -#ifdef USE_VNC - case IDM_VID_VNC: -#endif -#ifdef USE_RDP - case IDM_VID_RDP: -#endif - CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_UNCHECKED); - plat_setvid(LOWORD(wParam) - IDM_VID_DDRAW); - CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_CHECKED); - config_save(); - break; - - case IDM_VID_FULLSCREEN: - /* pclog("enter full screen though menu\n"); */ - plat_setfullscreen(1); - config_save(); - break; - - case IDM_VID_FS_FULL: - case IDM_VID_FS_43: - case IDM_VID_FS_SQ: - case IDM_VID_FS_INT: - case IDM_VID_FS_KEEPRATIO: - CheckMenuItem(hmenu, IDM_VID_FS_FULL+vid_fullscreen_scale, MF_UNCHECKED); - vid_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL; - CheckMenuItem(hmenu, IDM_VID_FS_FULL+vid_fullscreen_scale, MF_CHECKED); - device_force_redraw(); - config_save(); - break; - - case IDM_VID_SCALE_1X: - case IDM_VID_SCALE_2X: - case IDM_VID_SCALE_3X: - case IDM_VID_SCALE_4X: - CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_UNCHECKED); - scale = LOWORD(wParam) - IDM_VID_SCALE_1X; - CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_CHECKED); - device_force_redraw(); - video_force_resize_set(1); - config_save(); - break; - - case IDM_VID_FORCE43: - video_toggle_option(hmenu, &force_43, IDM_VID_FORCE43); - video_force_resize_set(1); - break; - - case IDM_VID_INVERT: - video_toggle_option(hmenu, &invert_display, IDM_VID_INVERT); - break; - - case IDM_VID_OVERSCAN: - update_overscan = 1; - video_toggle_option(hmenu, &enable_overscan, IDM_VID_OVERSCAN); - video_force_resize_set(1); - break; - - case IDM_VID_CGACON: - vid_cga_contrast ^= 1; - CheckMenuItem(hmenu, IDM_VID_CGACON, vid_cga_contrast ? MF_CHECKED : MF_UNCHECKED); - cgapal_rebuild(); - config_save(); - break; - - case IDM_VID_GRAYCT_601: - case IDM_VID_GRAYCT_709: - case IDM_VID_GRAYCT_AVE: - CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+vid_graytype, MF_UNCHECKED); - vid_graytype = LOWORD(wParam) - IDM_VID_GRAYCT_601; - CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+vid_graytype, MF_CHECKED); - device_force_redraw(); - config_save(); - break; - - case IDM_VID_GRAY_RGB: - case IDM_VID_GRAY_MONO: - case IDM_VID_GRAY_AMBER: - case IDM_VID_GRAY_GREEN: - case IDM_VID_GRAY_WHITE: - CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+vid_grayscale, MF_UNCHECKED); - vid_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB; - CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+vid_grayscale, MF_CHECKED); - device_force_redraw(); - config_save(); - break; - - case IDM_KBD_RCTRL_IS_LALT: - rctrl_is_lalt ^= 1; - CheckMenuItem(hmenu, IDM_KBD_RCTRL_IS_LALT, rctrl_is_lalt ? MF_CHECKED : MF_UNCHECKED); - config_save(); - break; - -#ifdef ENABLE_LOG_BREAKPOINT - case IDM_LOG_BREAKPOINT: - pclog("---- LOG BREAKPOINT ----\n"); - break; -#endif - -#ifdef ENABLE_LOG_TOGGLES - case IDM_LOG_PCI: - case IDM_LOG_KEYBOARD: - case IDM_LOG_SERIAL: - case IDM_LOG_FDC: - case IDM_LOG_D86F: - case IDM_LOG_HDC: - case IDM_LOG_HDD: - case IDM_LOG_ZIP: - case IDM_LOG_CDROM: - case IDM_LOG_CDROM_IMAGE: - case IDM_LOG_CDROM_IOCTL: - case IDM_LOG_NIC: - case IDM_LOG_SOUND_EMU8K: - case IDM_LOG_SOUND_MPU401: - case IDM_LOG_SOUND_DEV: - case IDM_LOG_SCSI_BUS: - case IDM_LOG_SCSI_DISK: - case IDM_LOG_SCSI_DEV: - case IDM_LOG_SCSI_X54X: - case IDM_LOG_VOODOO: - SetLoggingItem(LOWORD(wParam), -1); - break; -#endif - case IDM_CONFIG_LOAD: - plat_pause(1); - if (! file_dlg_st(hwnd, IDS_2160, L"", 0) && - (ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051) == IDYES)) { - pc_reload(wopenfilestring); - ResetAllMenus(); - } - plat_pause(0); - break; - - case IDM_CONFIG_SAVE: - plat_pause(1); - if (! file_dlg_st(hwnd, IDS_2160, L"", 1)) { - config_write(wopenfilestring); - } - plat_pause(0); - break; } return(0); @@ -814,14 +386,14 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_SHOWSETTINGS: plat_pause(1); - if (win_settings_open(hwnd, 1) == 2) + if (dlg_settings(1) == 2) pc_reset_hard_init(); plat_pause(0); break; case WM_PAUSE: plat_pause(dopause ^ 1); - CheckMenuItem(menuMain, IDM_ACTION_PAUSE, dopause ? MF_CHECKED : MF_UNCHECKED); + menu_set_item(IDM_PAUSE, dopause); break; case WM_SYSCOMMAND: @@ -874,7 +446,8 @@ ui_init(int nCmdShow) return(6); } - win_settings_open(NULL, 0); + (void)dlg_settings(0); + return(0); } @@ -933,7 +506,7 @@ ui_init(int nCmdShow) MoveWindow(hwnd, window_x, window_y, window_w, window_h, TRUE); /* Reset all menus to their defaults. */ - ResetAllMenus(); + ui_menu_reset_all(); /* Make the window visible on the screen. */ ShowWindow(hwnd, nCmdShow); @@ -990,7 +563,7 @@ ui_init(int nCmdShow) break; case 2: /* Configuration error, user wants to re-config. */ - if (win_settings_open(NULL, 0)) { + if (dlg_settings(0)) { /* Save the new configuration to file. */ config_save(); @@ -1128,8 +701,7 @@ plat_pause(int p) dopause = p; /* Update the actual menu. */ - CheckMenuItem(menuMain, IDM_ACTION_PAUSE, - (dopause) ? MF_CHECKED : MF_UNCHECKED); + menu_set_item(IDM_PAUSE, dopause); }