diff --git a/src/config.c b/src/config.c index 9a564d4..f19c6f3 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.10 2018/04/05 + * Version: @(#)config.c 1.0.11 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -55,6 +55,7 @@ #include "device.h" #include "serial.h" #include "parallel.h" +#include "parallel_dev.h" #include "mouse.h" #include "game/gameport.h" #include "floppy/fdd.h" @@ -626,9 +627,7 @@ load_sound(void) mpu401_standalone_enable = !!config_get_int(cat, "mpu401_standalone", 0); - SSI2001 = !!config_get_int(cat, "ssi2001", 0); GAMEBLASTER = !!config_get_int(cat, "gameblaster", 0); - GUS = !!config_get_int(cat, "gus", 0); memset(temp, '\0', sizeof(temp)); p = config_get_string(cat, "opl3_type", "dbopl"); @@ -701,8 +700,8 @@ load_network(void) static void load_ports(void) { - char temp[128]; char *cat = "Ports (COM & LPT)"; + char temp[128]; char *p; int i; @@ -718,7 +717,7 @@ load_ports(void) p = (char *)config_get_string(cat, temp, NULL); if (p == NULL) p = "none"; - strcpy(parallel_device[i], p); + parallel_device[i] = parallel_device_get_from_internal_name(p); } } @@ -1385,7 +1384,6 @@ save_general(void) { char *cat = "General"; char temp[512]; - char *va_name; config_set_int(cat, "vid_resize", vid_resize); @@ -1622,21 +1620,11 @@ save_sound(void) else config_set_int(cat, "mpu401_standalone", mpu401_standalone_enable); - if (SSI2001 == 0) - config_delete_var(cat, "ssi2001"); - else - config_set_int(cat, "ssi2001", SSI2001); - if (GAMEBLASTER == 0) config_delete_var(cat, "gameblaster"); else config_set_int(cat, "gameblaster", GAMEBLASTER); - if (GUS == 0) - config_delete_var(cat, "gus"); - else - config_set_int(cat, "gus", GUS); - if (opl3_type == 0) config_delete_var(cat, "opl3_type"); else @@ -1686,8 +1674,8 @@ save_network(void) static void save_ports(void) { - char temp[128]; char *cat = "Ports (COM & LPT)"; + char temp[128]; int i; for (i = 0; i < SERIAL_MAX; i++) { @@ -1699,15 +1687,16 @@ save_ports(void) } for (i = 0; i < PARALLEL_MAX; i++) { - if (parallel_enabled[i]) { - sprintf(temp, "parallel%i_enabled", i); + sprintf(temp, "parallel%i_enabled", i); + if (parallel_enabled[i]) config_set_int(cat, temp, 1); - } else + else config_delete_var(cat, temp); sprintf(temp, "parallel%i_device", i); - if (strcmp(parallel_device[i], "none")) - config_set_string(cat, temp, parallel_device[i]); + if (parallel_device[i] != 0) + config_set_string(cat, temp, + (char *)parallel_device_get_internal_name(parallel_device[i])); else config_delete_var(cat, temp); } diff --git a/src/emu.h b/src/emu.h index 7d64760..7a6dd6b 100644 --- a/src/emu.h +++ b/src/emu.h @@ -8,7 +8,7 @@ * * Main include file for the application. * - * Version: @(#)emu.h 1.0.14 2018/04/05 + * Version: @(#)emu.h 1.0.15 2018/04/08 * * Author: Fred N. van Kempen, * @@ -106,8 +106,8 @@ extern int vid_cga_contrast, /* (C) video */ video_speed; /* (C) video */ extern int serial_enabled[], /* (C) enable serial ports */ parallel_enabled[], /* (C) enable LPT ports */ + parallel_device[], /* (C) set up LPT devices */ bugger_enabled; /* (C) enable ISAbugger */ -extern char parallel_device[3][16]; /* (C) set up LPT devices */ extern int rctrl_is_lalt; /* (C) set R-CTRL as L-ALT */ extern int update_icons; /* (C) enable icons updates */ #ifdef WALTJE @@ -116,8 +116,6 @@ extern int romdos_enabled; /* (C) enable ROM DOS */ extern int hdc_type; /* (C) HDC type */ extern int sound_is_float, /* (C) sound uses FP values */ GAMEBLASTER, /* (C) sound option */ - GUS, /* (C) sound option */ - SSI2001, /* (C) sound option */ voodoo_enabled; /* (C) video option */ extern int joystick_type; /* (C) joystick type */ extern int mem_size; /* (C) memory size */ diff --git a/src/machine/m_amstrad.c b/src/machine/m_amstrad.c index 42b4c21..9795026 100644 --- a/src/machine/m_amstrad.c +++ b/src/machine/m_amstrad.c @@ -32,7 +32,7 @@ * BIOSES: I need to re-do the bios.txt format so we can load non-BIOS * ROM files for a given machine, such as font roms here.. * - * Version: @(#)m_amstrad.c 1.0.9 2018/04/05 + * Version: @(#)m_amstrad.c 1.0.10 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1230,7 +1230,7 @@ machine_amstrad_init(const machine_t *model, void *arg) device_add(&amstrad_nvr_device); - parallel_remove_amstrad(); +//FIXME: parallel_remove_amstrad(); io_sethandler(0x0078, 1, ms_read, NULL, NULL, ms_write, NULL, NULL, ams); diff --git a/src/machine/m_at_commodore.c b/src/machine/m_at_commodore.c index 87958be..77a4458 100644 --- a/src/machine/m_at_commodore.c +++ b/src/machine/m_at_commodore.c @@ -8,7 +8,7 @@ * * Implementation of the Commodore PC3 system. * - * Version: @(#)m_at_commodore.c 1.0.4 2018/04/05 + * Version: @(#)m_at_commodore.c 1.0.5 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -53,9 +53,6 @@ static void pc3_write(uint16_t port, uint8_t val, void *priv) { - parallel_remove(1); - parallel_remove(2); - switch (val & 3) { case 1: parallel_setup(1, 0x03bc); diff --git a/src/machine/m_at_sis_85c471.c b/src/machine/m_at_sis_85c471.c index 0571882..b99c67b 100644 --- a/src/machine/m_at_sis_85c471.c +++ b/src/machine/m_at_sis_85c471.c @@ -12,7 +12,7 @@ * * Used by DTK PKM-0038S E-2 * - * Version: @(#)m_at_sis85c471.c 1.0.5 2018/04/05 + * Version: @(#)m_at_sis85c471.c 1.0.6 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -101,8 +101,8 @@ sis_write(uint16_t port, uint8_t val, void *priv) if (x & 0x10) { if (val & 0x10) parallel_setup(1, 0x378); - else - parallel_remove(1); +//FIXME: else +//FIXME: parallel_remove(1); } break; @@ -136,7 +136,7 @@ sis_init(void) { int i = 0; - parallel_remove(2); +//FIXME: parallel_remove(2); sis_curreg = 0; for (i = 0; i < 0x27; i++) diff --git a/src/machine/m_ps1.c b/src/machine/m_ps1.c index a7cc086..d44bc7e 100644 --- a/src/machine/m_ps1.c +++ b/src/machine/m_ps1.c @@ -28,7 +28,7 @@ * boot. Sometimes, they do, and then it shows an "Incorrect * DOS" error message?? --FvK * - * Version: @(#)m_ps1.c 1.0.9 2018/04/05 + * Version: @(#)m_ps1.c 1.0.10 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -350,7 +350,6 @@ ps1_write(uint16_t port, uint8_t val, void *priv) break; case 0x0102: - parallel_remove(1); if (val & 0x04) serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); else @@ -512,8 +511,6 @@ ps1_setup(int model) 0xf80000, 0x80000, 0x7ffff, 0, MEM_MAPPING_EXTERNAL); #endif - parallel_remove(1); - parallel_remove(2); parallel_setup(1, 0x03bc); serial_remove(1); diff --git a/src/machine/m_ps2_isa.c b/src/machine/m_ps2_isa.c index 1e6a1dd..f7f3bc6 100644 --- a/src/machine/m_ps2_isa.c +++ b/src/machine/m_ps2_isa.c @@ -8,7 +8,7 @@ * * Implementation of ISA-based PS/2 machines. * - * Version: @(#)m_ps2_isa.c 1.0.5 2018/04/05 + * Version: @(#)m_ps2_isa.c 1.0.6 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -111,53 +111,51 @@ static void ps2_write(uint16_t port, uint8_t val, void *p) switch (port) { case 0x94: - ps2_94 = val; - break; + ps2_94 = val; + break; case 0x102: - parallel_remove(1); - if (val & 0x04) - serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); - else - serial_remove(1); - if (val & 0x10) - { - switch ((val >> 5) & 3) { - case 0: - parallel_setup(1, 0x3bc); - break; - case 1: - parallel_setup(1, 0x378); - break; - case 2: - parallel_setup(1, 0x278); - break; - } - } - ps2_102 = val; - break; + if (val & 0x04) + serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); + else + serial_remove(1); + if (val & 0x10) + { + switch ((val >> 5) & 3) { + case 0: + parallel_setup(1, 0x3bc); + break; + case 1: + parallel_setup(1, 0x378); + break; + case 2: + parallel_setup(1, 0x278); + break; + } + } + ps2_102 = val; + break; case 0x103: - ps2_103 = val; - break; + ps2_103 = val; + break; case 0x104: - ps2_104 = val; - break; + ps2_104 = val; + break; case 0x105: - ps2_105 = val; - break; + ps2_105 = val; + break; case 0x190: - ps2_190 = val; - break; - + ps2_190 = val; + break; case 0x322: - ps2_hd.ctrl = val; - if (val & 0x80) - ps2_hd.status |= 0x02; - break; + ps2_hd.ctrl = val; + if (val & 0x80) + ps2_hd.status |= 0x02; + break; case 0x324: - ps2_hd.attention = val & 0xf0; - if (ps2_hd.attention) - ps2_hd.status = 0x14; - break; + ps2_hd.attention = val & 0xf0; + if (ps2_hd.attention) + ps2_hd.status = 0x14; + break; } } diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index 8e17c65..3e851aa 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -8,7 +8,7 @@ * * Implementation of MCA-based PS/2 machines. * - * Version: @(#)m_ps2_mca.c 1.0.8 2018/04/05 + * Version: @(#)m_ps2_mca.c 1.0.9 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -357,7 +357,6 @@ static void model_50_write(uint16_t port, uint8_t val) case 0x101: break; case 0x102: - parallel_remove(1); serial_remove(1); if (val & 0x04) { @@ -413,7 +412,6 @@ static void model_55sx_write(uint16_t port, uint8_t val) case 0x101: break; case 0x102: - parallel_remove(1); serial_remove(1); if (val & 0x04) { @@ -489,7 +487,6 @@ static void model_70_type3_write(uint16_t port, uint8_t val) case 0x101: break; case 0x102: - parallel_remove(1); serial_remove(1); if (val & 0x04) { @@ -539,7 +536,6 @@ static void model_80_write(uint16_t port, uint8_t val) case 0x101: break; case 0x102: - parallel_remove(1); serial_remove(1); if (val & 0x04) { diff --git a/src/machine/m_xt_compaq.c b/src/machine/m_xt_compaq.c index 7aa1aaf..6d96e2b 100644 --- a/src/machine/m_xt_compaq.c +++ b/src/machine/m_xt_compaq.c @@ -8,7 +8,7 @@ * * Emulation of various Compaq XT-class PC's. * - * Version: @(#)m_xt_compaq.c 1.0.6 2018/04/05 + * Version: @(#)m_xt_compaq.c 1.0.7 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -74,7 +74,7 @@ machine_xt_compaq_init(const machine_t *model, void *arg) switch(model->id) { case ROM_PORTABLE: - parallel_remove(1); +//FIXME: parallel_remove(1); parallel_setup(1, 0x03bc); break; } diff --git a/src/machine/machine.c b/src/machine/machine.c index 6f7b9e5..f73a885 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.c 1.0.11 2018/04/05 + * Version: @(#)machine.c 1.0.12 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -153,17 +153,12 @@ machine_common_init(const machine_t *model, UNUSED(void *arg)) pic_init(); pit_init(); - /* Disable all LPT ports. */ - parallel_init(); - if (parallel_enabled[0]) - parallel_setup(1, PARALLEL1_ADDR); - + device_add(¶llel_1_device); if (parallel_enabled[1]) - parallel_setup(2, PARALLEL2_ADDR); - + device_add(¶llel_2_device); if (parallel_enabled[2]) - parallel_setup(3, PARALLEL3_ADDR); + device_add(¶llel_3_device); if (serial_enabled[0]) serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); diff --git a/src/parallel.c b/src/parallel.c index 9c7d69c..2113fa1 100644 --- a/src/parallel.c +++ b/src/parallel.c @@ -8,10 +8,7 @@ * * Implementation of the "LPT" style parallel ports. * - * NOTE: Have to re-do the "attach" and "detach" stuff for the - * "device" that use the ports. --FvK - * - * Version: @(#)parallel.c 1.0.4 2018/04/05 + * Version: @(#)parallel.c 1.0.4 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,25 +42,15 @@ #include #include "emu.h" #include "io.h" +#include "device.h" #include "parallel.h" -#include "sound/snd_lpt_dac.h" -#include "sound/snd_lpt_dss.h" +#include "parallel_dev.h" -static const struct { - const char *name; - const char *internal_name; - const lpt_device_t *device; -} parallel_devices[] = { - { "None", "none", NULL }, - { "Disney Sound Source", "dss", &dss_device }, - { "LPT DAC / Covox Speech Thing", "lpt_dac", &lpt_dac_device }, - { "Stereo LPT DAC", "lpt_dac_stereo", &lpt_dac_stereo_device }, - { "", "", NULL } -}; - static const uint16_t addr_list[] = { /* valid port addresses */ - 0x0378, 0x0278, 0x03bc + PARALLEL1_ADDR, + PARALLEL2_ADDR, + PARALLEL3_ADDR }; @@ -75,9 +62,9 @@ typedef struct { ctrl; /* port control register */ /* Device stuff. */ - char device_name[16]; /* name of attached device */ - const lpt_device_t *device_ts; - void *device_ps; + int dev_id; /* attached device */ + const lpt_device_t *dev_ts; + void *dev_ps; } parallel_t; @@ -93,14 +80,14 @@ parallel_write(uint16_t port, uint8_t val, void *priv) switch (port & 3) { case 0: - if (dev->device_ts != NULL) - dev->device_ts->write_data(val, dev->device_ps); + if (dev->dev_ts != NULL) + dev->dev_ts->write_data(val, dev->dev_ps); dev->dat = val; break; case 2: - if (dev->device_ts != NULL) - dev->device_ts->write_ctrl(val, dev->device_ps); + if (dev->dev_ts != NULL) + dev->dev_ts->write_ctrl(val, dev->dev_ps); dev->ctrl = val; break; } @@ -120,8 +107,8 @@ parallel_read(uint16_t port, void *priv) break; case 1: - if (dev->device_ts != NULL) - ret = dev->device_ts->read_status(dev->device_ps); + if (dev->dev_ts != NULL) + ret = dev->dev_ts->read_status(dev->dev_ps); else ret = 0x00; break; @@ -134,60 +121,101 @@ parallel_read(uint16_t port, void *priv) } -/* Initialize (all) the parallel ports. */ +static void * +parallel_init(const device_t *info) +{ + parallel_t *dev; + int id = info->local - 1; + + /* Get the correct device. */ + dev = &ports[id]; + + /* Clear port. */ + dev->dat = 0x00; + dev->ctrl = 0x00; + + /* Enable the I/O handler for this port. */ + io_sethandler(dev->base, 3, + parallel_read,NULL,NULL, + parallel_write,NULL,NULL, dev); + + /* If the user configured a device for this port, attach it. */ + if (parallel_device[id] != 0) { + dev->dev_ts = parallel_device_get_device(parallel_device[id]); + if (dev->dev_ts != NULL) + dev->dev_ps = dev->dev_ts->init(dev->dev_ts); + } + + return(dev); +} + + +static void +parallel_close(void *priv) +{ + parallel_t *dev = (parallel_t *)priv; + + /* Unlink the attached device if there is one. */ + if (dev->dev_ts != NULL) { + dev->dev_ts->close(dev->dev_ps); + dev->dev_ts = NULL; + dev->dev_ps = NULL; + } + + /* Remove the I/O handler. */ + io_removehandler(dev->base, 3, + parallel_read,NULL,NULL, + parallel_write,NULL,NULL, dev); + + /* Clear port. */ + dev->dat = 0x00; + dev->ctrl = 0x00; +} + + +const device_t parallel_1_device = { + "LPT1:", + 0, + 1, + parallel_init, parallel_close, NULL, + NULL, NULL, NULL, + NULL +}; + + +const device_t parallel_2_device = { + "LPT2:", + 0, + 2, + parallel_init, parallel_close, NULL, + NULL, NULL, NULL, + NULL +}; + + +const device_t parallel_3_device = { + "LPT3:", + 0, + 3, + parallel_init, parallel_close, NULL, + NULL, NULL, NULL, + NULL +}; + + +/* (Re-)initialize all parallel ports. */ void -parallel_init(void) +parallel_reset(void) { parallel_t *dev; int i; - pclog("LPT: initializing ports..."); - for (i = 0; i < PARALLEL_MAX; i++) { dev = &ports[i]; memset(dev, 0x00, sizeof(parallel_t)); dev->base = addr_list[i]; - - if (parallel_enabled[i]) { - io_sethandler(dev->base, 3, - parallel_read,NULL,NULL, - parallel_write,NULL,NULL, dev); - - pclog(" [%i=%04x]", i, dev->base); - } - } - - pclog("\n"); -} - - -/* Disable one of the parallel ports. */ -void -parallel_remove(int id) -{ - parallel_t *dev = &ports[id-1]; - - if (! parallel_enabled[id-1]) return; - - io_removehandler(dev->base, 3, - parallel_read,NULL,NULL, - parallel_write,NULL,NULL, dev); - - dev->base = addr_list[id-1]; -} - - -void -parallel_remove_amstrad(void) -{ - parallel_t *dev = &ports[1]; - - if (parallel_enabled[1]) { - io_removehandler(dev->base+1, 2, - parallel_read,NULL,NULL, - parallel_write,NULL,NULL, dev); } } @@ -198,77 +226,11 @@ parallel_setup(int id, uint16_t port) { parallel_t *dev = &ports[id-1]; +#ifdef _DEBUG + pclog("PARALLE: setting up LPT%d as %04X [enabled=%d]\n", + id, port, parallel_enabled[id-1]); +#endif if (! parallel_enabled[id-1]) return; dev->base = port; - io_sethandler(dev->base, 3, - parallel_read,NULL,NULL, - parallel_write,NULL,NULL, dev); -} - - -const char * -parallel_device_get_name(int id) -{ - if (strlen((char *)parallel_devices[id].name) == 0) - return(NULL); - - return((char *)parallel_devices[id].name); -} - - -char * -parallel_device_get_internal_name(int id) -{ - if (strlen((char *)parallel_devices[id].internal_name) == 0) - return(NULL); - - return((char *)parallel_devices[id].internal_name); -} - - -/* Attach the configured "LPT" devices. */ -void -parallel_devices_init(void) -{ - parallel_t *dev; - int c, i; - - for (i = 0; i < PARALLEL_MAX; i++) { - dev = &ports[i]; - - c = 0; - -#if 0 - /* FIXME: Gotta re-think this junk... --FvK */ - while (! strmpdev->device_name, (char *)strcmp(lpt_devices[c].internal_name, lpt_device_names[i]) && strlen((char *)lpt_devices[c].internal_name) != 0) - c++; - - if (strlen((char *)lpt_devices[c].internal_name) == 0) - lpt_device_ts[i] = NULL; - else { - lpt_device_ts[i] = lpt_devices[c].device; - if (lpt_device_ts[i]) - lpt_device_ps[i] = lpt_device_ts[i]->init(lpt_devices[c].device); - } -#endif - } -} - - -void -parallel_devices_close(void) -{ - parallel_t *dev; - int i; - - for (i = 0; i < PARALLEL_MAX; i++) { - dev = &ports[i]; - - if (dev->device_ts != NULL) { - dev->device_ts->close(dev->device_ps); - dev->device_ts = NULL; - dev->device_ps = NULL; - } - } } diff --git a/src/parallel.h b/src/parallel.h index 67a8819..3c99e56 100644 --- a/src/parallel.h +++ b/src/parallel.h @@ -8,7 +8,7 @@ * * Definitions for the "LPT" parallel port handlerss. * - * Version: @(#)parallel.h 1.0.3 2018/04/05 + * Version: @(#)parallel.h 1.0.4 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -47,26 +47,15 @@ #define PARALLEL3_ADDR 0x03BC /* part of the MDA */ -typedef struct _lpt_device_ { - const char *name; - int type; - void *(*init)(const struct _lpt_device_ *); - void (*close)(void *priv); - void (*write_data)(uint8_t val, void *priv); - void (*write_ctrl)(uint8_t val, void *priv); - uint8_t (*read_status)(void *priv); -} lpt_device_t; +#ifdef EMU_DEVICE_H +extern const device_t parallel_1_device; +extern const device_t parallel_2_device; +extern const device_t parallel_3_device; +#endif -extern void parallel_init(void); +extern void parallel_reset(void); extern void parallel_setup(int id, uint16_t port); -extern void parallel_remove(int id); -extern void parallel_remove_amstrad(void); - -extern const char *parallel_device_get_name(int id); -extern char *parallel_device_get_internal_name(int id); -extern void parallel_devices_init(void); -extern void parallel_devices_close(void); #endif /*EMU_PARALLEL_H*/ diff --git a/src/sound/snd_adlibgold.h b/src/parallel_dev.c similarity index 51% rename from src/sound/snd_adlibgold.h rename to src/parallel_dev.c index 3822dd8..661d9d4 100644 --- a/src/sound/snd_adlibgold.h +++ b/src/parallel_dev.c @@ -6,9 +6,9 @@ * * This file is part of the VARCem Project. * - * Definitions for the Adlib Gold driver. + * Implementation of the parallel-port-attached devices. * - * Version: @(#)snd_adlibgold.h 1.0.2 2018/03/15 + * Version: @(#)parallel_dev.c 1.0.1 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -36,11 +36,68 @@ * Boston, MA 02111-1307 * USA. */ -#ifndef SOUND_ADLIBGOLD_H -# define SOUND_ADLIBGOLD_H +#include +#include +#include +#include +#include "emu.h" +#include "io.h" +#include "parallel.h" +#include "parallel_dev.h" + +#include "sound/snd_lpt_dac.h" +#include "sound/snd_lpt_dss.h" -extern const device_t adgold_device; +static const struct { + const char *name; + const char *internal_name; + const lpt_device_t *device; +} devices[] = { + {"None", + "none", NULL }, + {"Disney Sound Source", + "dss", &dss_device }, + {"LPT DAC / Covox Speech Thing", + "lpt_dac", &lpt_dac_device }, + {"Stereo LPT DAC", + "lpt_dac_stereo", &lpt_dac_stereo_device }, + {NULL, NULL, + NULL } +}; -#endif /*SOUND_ADLIBGOLD_H*/ +const char * +parallel_device_get_name(int id) +{ + return(devices[id].name); +} + + +const char * +parallel_device_get_internal_name(int id) +{ + return(devices[id].internal_name); +} + + +const lpt_device_t * +parallel_device_get_device(int id) +{ + return(devices[id].device); +} + + +int +parallel_device_get_from_internal_name(char *s) +{ + int c = 0; + + while (devices[c].internal_name != NULL) { + if (! strcmp((char *)devices[c].internal_name, s)) + return(c); + c++; + } + + return(-1); +} diff --git a/src/sound/snd_adlib.h b/src/parallel_dev.h similarity index 61% rename from src/sound/snd_adlib.h rename to src/parallel_dev.h index 1955d74..08f13fa 100644 --- a/src/sound/snd_adlib.h +++ b/src/parallel_dev.h @@ -6,9 +6,9 @@ * * This file is part of the VARCem Project. * - * Definitions for the ADLIB driver. + * Definitions for the parallel port-attached devices. * - * Version: @(#)snd_adlib.h 1.0.2 2018/03/15 + * Version: @(#)parallel_dev.h 1.0.1 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -36,12 +36,27 @@ * Boston, MA 02111-1307 * USA. */ -#ifndef SOUND_ADLIB_H -# define SOUND_ADLIB_H +#ifndef EMU_PARALLEL_DEV_H +# define EMU_PARALLE_DEVL_H -extern const device_t adlib_device; -extern const device_t adlib_mca_device; +typedef struct _lpt_device_ { + const char *name; + int type; + void *(*init)(const struct _lpt_device_ *); + void (*close)(void *priv); + void (*write_data)(uint8_t val, void *priv); + void (*write_ctrl)(uint8_t val, void *priv); + uint8_t (*read_status)(void *priv); +} lpt_device_t; -#endif /*SOUND_ADLIB_H*/ +extern const char *parallel_device_get_name(int id); +extern const char *parallel_device_get_internal_name(int id); +extern const lpt_device_t *parallel_device_get_device(int id); +extern int parallel_device_get_from_internal_name(char *s); +extern void parallel_devices_init(void); +extern void parallel_devices_close(void); + + +#endif /*EMU_PARALLEL_DEV_H*/ diff --git a/src/pc.c b/src/pc.c index 68587d8..04e9bb3 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.20 2018/04/05 + * Version: @(#)pc.c 1.0.21 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -82,15 +82,7 @@ #include "scsi/scsi.h" #include "network/network.h" #include "sound/sound.h" -#include "sound/midi.h" -#include "sound/snd_cms.h" -#include "sound/snd_dbopl.h" -#include "sound/snd_mpu401.h" -#include "sound/snd_opl.h" -#include "sound/snd_gus.h" -#include "sound/snd_sb.h" #include "sound/snd_speaker.h" -#include "sound/snd_ssi2001.h" #include "video/video.h" #include "ui.h" #include "plat.h" @@ -127,10 +119,10 @@ int vid_cga_contrast = 0, /* (C) video */ force_43 = 0, /* (C) video */ vid_card = 0, /* (C) graphics/video card */ video_speed = 0; /* (C) video */ -int serial_enabled[SERIAL_MAX] = {0,0}, /* (C) enable serial ports */ - parallel_enabled[PARALLEL_MAX] = {0,0,0},/* (C) enable LPT ports */ +int serial_enabled[] = {0,0}, /* (C) enable serial ports */ + 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 */ -char parallel_device[PARALLEL_MAX][16]; /* (C) set up LPT devices */ int rctrl_is_lalt; /* (C) set R-CTRL as L-ALT */ int update_icons; /* (C) enable icons updates */ #ifdef WALTJE @@ -139,8 +131,6 @@ int romdos_enabled = 0; /* (C) enable ROM DOS */ int hdc_type = 0; /* (C) HDC type */ int sound_is_float = 1, /* (C) sound uses FP values */ GAMEBLASTER = 0, /* (C) sound option */ - GUS = 0, /* (C) sound option */ - SSI2001 = 0, /* (C) sound option */ voodoo_enabled = 0; /* (C) video option */ int joystick_type = 0; /* (C) joystick type */ int mem_size = 0; /* (C) memory size */ @@ -604,7 +594,6 @@ usage: * modules before we load the config.. */ mouse_init(); - sound_global_init(); hdd_init(); cdrom_global_init(); zip_global_init(); @@ -760,12 +749,10 @@ pc_init_modules(void) timer_reset(); - sound_reset(); + sound_init(); floppy_init(); - sound_init(); - /* FIXME: should be disk_init() */ cdrom_hard_reset(); zip_hard_reset(); @@ -792,13 +779,7 @@ pc_reset_hard_close(void) mouse_close(); - parallel_devices_close(); - device_close_all(); - - midi_close(); - - closeal(); } @@ -811,30 +792,22 @@ pc_reset_hard_close(void) void pc_reset_hard_init(void) { - /* - * First, we reset the modules that are not part of - * the actual machine, but which support some of the - * modules that are. - */ - sound_realloc_buffers(); - sound_cd_thread_reset(); - initalmain(0, NULL); - /* Reset the general machine support modules. */ io_init(); timer_reset(); device_init(); - /* FIXME: should all be in sound_reset(). */ - midi_device_init(); - inital(); - sound_reset(); - #ifndef WALTJE_SERIAL /* This is needed to initialize the serial timer. */ serial_init(); #endif + /* Reset the parallel ports [before machine!] */ + parallel_reset(); + + sound_reset(); + speaker_init(); + /* Initialize the actual machine and its basic modules. */ machine_init(); @@ -850,9 +823,7 @@ pc_reset_hard_init(void) */ /* Reset some basic devices. */ - speaker_init(); serial_reset(); - parallel_devices_init(); shadowbios = 0; @@ -879,18 +850,6 @@ pc_reset_hard_init(void) /* Reset and reconfigure the Network Card layer. */ network_reset(); - /* Reset and reconfigure the Sound Card layer. */ - // FIXME: should be just one sound_reset() here. --FvK - sound_card_init(); - if (mpu401_standalone_enable) - mpu401_device_add(); - if (GUS) - device_add(&gus_device); - if (GAMEBLASTER) - device_add(&cms_device); - if (SSI2001) - device_add(&ssi2001_device); - if (joystick_type != JOYSTICK_TYPE_NONE) gameport_update_joystick_type(); @@ -978,8 +937,6 @@ pc_close(thread_t *ptr) plat_mouse_capture(0); - parallel_devices_close(); - for (i=0; i * Miran Grca, @@ -197,11 +197,13 @@ scsi_card_init(void) { int i, j; - pclog("Building SCSI hard disk map...\n"); + pclog("SCSI: building hard disk map...\n"); build_scsi_hd_map(); - pclog("Building SCSI CD-ROM map...\n"); + + pclog("SCSI: building CD-ROM map...\n"); build_scsi_cdrom_map(); - pclog("Building SCSI ZIP map...\n"); + + pclog("SCSI: building ZIP map...\n"); build_scsi_zip_map(); for (i=0; i * @@ -157,11 +157,9 @@ process_value: case 1: if (valxor & 4) { - /* pclog("Removing LPT1\n"); */ - parallel_remove(1); +//FIXME: parallel_remove(1); if ((fdc37c669_regs[1] & 4) && (fdc37c669_regs[0x23] >= 0x40)) { - /* pclog("LPT1 init (%02X)\n", make_port(0x23)); */ parallel_setup(1, make_port(0x23)); } } @@ -232,11 +230,9 @@ process_value: case 0x23: if (valxor) { - /* pclog("Removing LPT1\n"); */ - parallel_remove(1); +//FIXME: parallel_remove(1); if ((fdc37c669_regs[1] & 4) && (fdc37c669_regs[0x23] >= 0x40)) { - /* pclog("LPT1 init (%02X)\n", make_port(0x23)); */ parallel_setup(1, make_port(0x23)); } } @@ -321,8 +317,8 @@ void fdc37c669_reset(void) serial_remove(2); serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ); - parallel_remove(1); - parallel_remove(2); +//FIXME: parallel_remove(1); +//FIXME: parallel_remove(2); parallel_setup(1, 0x378); memset(fdc37c669_regs, 0, 42); diff --git a/src/sio/sio_fdc37c66x.c b/src/sio/sio_fdc37c66x.c index 40a7e64..34522d6 100644 --- a/src/sio/sio_fdc37c66x.c +++ b/src/sio/sio_fdc37c66x.c @@ -9,7 +9,7 @@ * Implementation of the SMC FDC37C663 and FDC37C665 Super * I/O Chips. * - * Version: @(#)sio_fdc37c66x.c 1.0.3 2018/04/05 + * Version: @(#)sio_fdc37c66x.c 1.0.4 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -173,7 +173,7 @@ static void set_serial2_addr() static void lpt1_handler() { - parallel_remove(1); +//FIXME: parallel_remove(1); switch (fdc37c66x_regs[1] & 3) { case 1: @@ -303,8 +303,8 @@ static void fdc37c66x_reset(void) serial_remove(2); serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ); - parallel_remove(1); - parallel_remove(2); +//FIXME: parallel_remove(1); +//FIXME: parallel_remove(2); parallel_setup(1, 0x378); fdc_reset(fdc37c66x_fdc); diff --git a/src/sio/sio_fdc37c93x.c b/src/sio/sio_fdc37c93x.c index 0bb83c2..9fcdc49 100644 --- a/src/sio/sio_fdc37c93x.c +++ b/src/sio/sio_fdc37c93x.c @@ -9,7 +9,7 @@ * Implementation of the SMC FDC37C932FR and FDC37C935 Super * I/O Chips. * - * Version: @(#)sio_fdc37c93x.c 1.0.5 2018/04/05 + * Version: @(#)sio_fdc37c93x.c 1.0.6 2018/04/07 * * Author: Miran Grca, * @@ -108,7 +108,7 @@ static void fdc37c93x_lpt_handler(void) uint8_t global_enable = !!(fdc37c93x_regs[0x22] & (1 << 3)); uint8_t local_enable = !!fdc37c93x_ld_regs[3][0x30]; - parallel_remove(1); +//FIXME: parallel_remove(1); if (global_enable && local_enable) { ld_port = make_port(3); @@ -572,7 +572,7 @@ static void fdc37c935_reset(void) static void fdc37c93x_init(void) { - parallel_remove(2); +//FIXME: parallel_remove(2); fdc37c93x_fdc = device_add(&fdc_at_smc_device); diff --git a/src/sio/sio_pc87306.c b/src/sio/sio_pc87306.c index be6c9f8..995844c 100644 --- a/src/sio/sio_pc87306.c +++ b/src/sio/sio_pc87306.c @@ -8,7 +8,7 @@ * * Emulation of the NatSemi PC87306 Super I/O chip. * - * Version: @(#)sio_pc87306.c 1.0.3 2018/04/05 + * Version: @(#)sio_pc87306.c 1.0.4 2018/04/07 * * Author: Miran Grca, * @@ -229,7 +229,7 @@ process_value: case 0: if (valxor & 1) { - parallel_remove(1); +//FIXME: parallel_remove(1); if (val & 1) { lpt1_handler(); @@ -285,7 +285,7 @@ process_value: case 1: if (valxor & 3) { - parallel_remove(1); +//FIXME: parallel_remove(1); if (pc87306_regs[0] & 1) { lpt1_handler(); @@ -321,7 +321,7 @@ process_value: { if (val & 1) { - parallel_remove(1); +//FIXME: parallel_remove(1); serial_remove(1); serial_remove(2); fdc_remove(pc87306_fdc); @@ -369,7 +369,7 @@ process_value: case 0x19: if (valxor) { - parallel_remove(1); +//FIXME: parallel_remove(1); if (pc87306_regs[0] & 1) { lpt1_handler(); @@ -379,7 +379,7 @@ process_value: case 0x1B: if (valxor & 0x70) { - parallel_remove(1); +//FIXME: parallel_remove(1); if (!(val & 0x40)) { pc87306_regs[0x19] = 0xEF; @@ -476,8 +476,8 @@ void pc87306_reset(void) 0 = 360 rpm @ 500 kbps for 3.5" 1 = Default, 300 rpm @ 500,300,250,1000 kbps for 3.5" */ - parallel_remove(1); - parallel_remove(2); +//FIXME: parallel_remove(1); +//FIXME: parallel_remove(2); lpt1_handler(); serial_remove(1); serial_remove(2); @@ -491,7 +491,7 @@ void pc87306_init() { pc87306_fdc = device_add(&fdc_at_nsc_device); - parallel_remove(2); +//FIXME: parallel_remove(2); pc87306_reset(); diff --git a/src/sio/sio_um8669f.c b/src/sio/sio_um8669f.c index 51e5fbe..ac4ddc2 100644 --- a/src/sio/sio_um8669f.c +++ b/src/sio/sio_um8669f.c @@ -29,7 +29,7 @@ * 70 - IRQ * 74 - DMA * - * Version: @(#)sio_um8669f.c 1.0.3 2018/04/05 + * Version: @(#)sio_um8669f.c 1.0.4 2018/04/07 * * Author: Miran Grca, * Sarah Walker, @@ -181,7 +181,7 @@ void um8669f_pnp_write(uint16_t port, uint8_t val, void *p) case DEV_LPT1: if ((um8669f->cur_reg == REG_ENABLE) && valxor) { - parallel_remove(1); +//FIXME: parallel_remove(1); if (um8669f->dev[DEV_LPT1].enable & 1) parallel_setup(1, um8669f->dev[DEV_LPT1].addr); } @@ -289,8 +289,8 @@ void um8669f_reset(void) serial_remove(2); serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ); - parallel_remove(1); - parallel_remove(2); +//FIXME: parallel_remove(1); +//FIXME: parallel_remove(2); parallel_setup(1, 0x378); if (um8669f_global.pnp_active) { diff --git a/src/sio/sio_w83877f.c b/src/sio/sio_w83877f.c index 52a1720..e3a1e0d 100644 --- a/src/sio/sio_w83877f.c +++ b/src/sio/sio_w83877f.c @@ -11,7 +11,7 @@ * Winbond W83877F Super I/O Chip * Used by the Award 430HX * - * Version: @(#)sio_w83877f.c 1.0.3 2018/04/05 + * Version: @(#)sio_w83877f.c 1.0.4 2018/04/07 * * Author: Miran Grca, * @@ -412,7 +412,7 @@ process_value: } if (valxor & 0x80) { - parallel_remove(1); +//FIXME: parallel_remove(1); if (!(w83877f_regs[4] & 0x80)) parallel_setup(1, make_port(0x23)); } break; @@ -457,7 +457,7 @@ process_value: case 0x23: if (valxor) { - parallel_remove(1); +//FIXME: parallel_remove(1); if (!(w83877f_regs[4] & 0x80)) parallel_setup(1, make_port(0x23)); } break; @@ -517,7 +517,7 @@ uint8_t w83877f_read(uint16_t port, void *priv) void w83877f_reset(void) { - parallel_remove(1); +//FIXME: parallel_remove(1); parallel_setup(1, 0x378); fdc_reset(w83877f_fdc); @@ -554,7 +554,7 @@ void w83877f_init(void) { w83877f_fdc = device_add(&fdc_at_winbond_device); - parallel_remove(2); +//FIXME: parallel_remove(2); w83877f_reset(); diff --git a/src/sound/openal.c b/src/sound/openal.c index 0b56bef..b778b9f 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.6 2018/04/05 + * Version: @(#)openal.c 1.0.7 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -138,6 +138,8 @@ ALvoid alutInit(ALint *argc, ALbyte **argv) ALCcontext *Context; ALCdevice *Device; +pclog("SOUND: alutInit(%08lx)\n", openal_handle); + /* Only if DLL is loaded. */ if (openal_handle == NULL) return; /* Open device */ @@ -159,6 +161,8 @@ alutExit(ALvoid) ALCcontext *Context; ALCdevice *Device; +pclog("SOUND: alutExit(%08lx)\n", openal_handle); + /* Only if DLL is loaded. */ if (openal_handle == NULL) return; /* Get active context */ @@ -178,11 +182,13 @@ alutExit(ALvoid) f_alcDestroyContext(Context); } +#if 0 /* Unload the DLL if possible. */ if (openal_handle != NULL) { dynld_close((void *)openal_handle); openal_handle = NULL; } +#endif } #endif @@ -190,6 +196,7 @@ alutExit(ALvoid) void closeal(void) { +pclog("SOUND: closeal()\n"); #ifdef USE_OPENAL alutExit(); #endif @@ -199,29 +206,21 @@ closeal(void) void initalmain(int argc, char *argv[]) { +pclog("SOUND: initalmain()\n"); #ifdef USE_OPENAL - char *str; - - if (openal_handle != NULL) return; - - /* - * If the current MIDI device is neither "none", nor system MIDI, - * initialize the MIDI buffer and source, otherwise, do not. - */ - str = midi_device_get_internal_name(midi_device_current); - if (!strcmp(str, "none") || !strcmp(str, SYSTEM_MIDI_INT)) return; - - /* Try loading the DLL. */ - openal_handle = dynld_module(PATH_AL_DLL, openal_imports); - if (openal_handle != NULL) { - pclog("SOUND: OpenAL module '%s' loaded.\n", PATH_AL_DLL); - alutInit(NULL, NULL); - atexit(closeal); - } else { - pclog("SOUND: unable to load OpenAL module '%s' !\n", PATH_AL_DLL); - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2178); - return; + /* Try loading the DLL if needed. */ + if (openal_handle == NULL) { + openal_handle = dynld_module(PATH_AL_DLL, openal_imports); + if (openal_handle == NULL) { + pclog("SOUND: unable to load module '%s' !\n", PATH_AL_DLL); + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2178); + return; + } else + pclog("SOUND: module '%s' loaded.\n", PATH_AL_DLL); } + + alutInit(NULL, NULL); + atexit(closeal); #endif } @@ -233,24 +232,38 @@ inital(void) float *buf = NULL, *cd_buf = NULL, *midi_buf = NULL; int16_t *buf_int16 = NULL, *cd_buf_int16 = NULL, *midi_buf_int16 = NULL; int c; +#endif + int init_midi = 0; + char *str; - if (openal_handle == NULL) return; +pclog("SOUND: inital()\n"); + /* + * If the current MIDI device is neither "none", nor system MIDI, + * initialize the MIDI buffer and source, otherwise, do not. + */ + str = midi_device_get_internal_name(midi_device_current); + if (!strcmp(str, "none") || !strcmp(str, SYSTEM_MIDI_INT)) init_midi = 1; +#ifdef USE_OPENAL if (sound_is_float) { buf = (float *) malloc((BUFLEN << 1) * sizeof(float)); cd_buf = (float *) malloc((CD_BUFLEN << 1) * sizeof(float)); - midi_buf = (float *) malloc(midi_buf_size * sizeof(float)); + if (init_midi) + midi_buf = (float *) malloc(midi_buf_size * sizeof(float)); } else { buf_int16 = (int16_t *) malloc((BUFLEN << 1) * sizeof(int16_t)); cd_buf_int16 = (int16_t *) malloc((CD_BUFLEN << 1) * sizeof(int16_t)); - midi_buf_int16 = (int16_t *) malloc(midi_buf_size * sizeof(int16_t)); + if (init_midi) + midi_buf_int16 = (int16_t *) malloc(midi_buf_size * sizeof(int16_t)); } f_alGenBuffers(4, buffers); f_alGenBuffers(4, buffers_cd); - f_alGenBuffers(4, buffers_midi); - - f_alGenSources(3, source); + if (init_midi) { + f_alGenBuffers(4, buffers_midi); + f_alGenSources(3, source); + } else + f_alGenSources(2, source); f_alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0); f_alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0); @@ -262,47 +275,57 @@ inital(void) f_alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0); f_alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 ); f_alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE ); - f_alSource3f(source[2], AL_POSITION, 0.0, 0.0, 0.0); - f_alSource3f(source[2], AL_VELOCITY, 0.0, 0.0, 0.0); - f_alSource3f(source[2], AL_DIRECTION, 0.0, 0.0, 0.0); - f_alSourcef (source[2], AL_ROLLOFF_FACTOR, 0.0 ); - f_alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE ); + if (init_midi) { + f_alSource3f(source[2], AL_POSITION, 0.0, 0.0, 0.0); + f_alSource3f(source[2], AL_VELOCITY, 0.0, 0.0, 0.0); + f_alSource3f(source[2], AL_DIRECTION, 0.0, 0.0, 0.0); + f_alSourcef (source[2], AL_ROLLOFF_FACTOR, 0.0 ); + f_alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE ); + } if (sound_is_float) { memset(buf,0,BUFLEN*2*sizeof(float)); memset(cd_buf,0,BUFLEN*2*sizeof(float)); - memset(midi_buf,0,midi_buf_size*sizeof(float)); + if (init_midi) + memset(midi_buf,0,midi_buf_size*sizeof(float)); } else { memset(buf_int16,0,BUFLEN*2*sizeof(int16_t)); memset(cd_buf_int16,0,BUFLEN*2*sizeof(int16_t)); - memset(midi_buf_int16,0,midi_buf_size*sizeof(int16_t)); + if (init_midi) + memset(midi_buf_int16,0,midi_buf_size*sizeof(int16_t)); } for (c=0; c<4; c++) { if (sound_is_float) { f_alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ); f_alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ); - f_alBufferData(buffers_midi[c], AL_FORMAT_STEREO_FLOAT32, midi_buf, midi_buf_size*sizeof(float), midi_freq); + if (init_midi) + f_alBufferData(buffers_midi[c], AL_FORMAT_STEREO_FLOAT32, midi_buf, midi_buf_size*sizeof(float), midi_freq); } else { f_alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ); f_alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ); - f_alBufferData(buffers_midi[c], AL_FORMAT_STEREO16, midi_buf_int16, midi_buf_size*sizeof(int16_t), midi_freq); + if (init_midi) + f_alBufferData(buffers_midi[c], AL_FORMAT_STEREO16, midi_buf_int16, midi_buf_size*sizeof(int16_t), midi_freq); } } f_alSourceQueueBuffers(source[0], 4, buffers); f_alSourceQueueBuffers(source[1], 4, buffers_cd); - f_alSourceQueueBuffers(source[2], 4, buffers_midi); + if (init_midi) + f_alSourceQueueBuffers(source[2], 4, buffers_midi); f_alSourcePlay(source[0]); f_alSourcePlay(source[1]); - f_alSourcePlay(source[2]); + if (init_midi) + f_alSourcePlay(source[2]); if (sound_is_float) { - free(midi_buf); + if (init_midi) + free(midi_buf); free(cd_buf); free(buf); } else { - free(midi_buf_int16); + if (init_midi) + free(midi_buf_int16); free(cd_buf_int16); free(buf_int16); } diff --git a/src/sound/snd_adlib.c b/src/sound/snd_adlib.c index 515b2cf..98e6600 100644 --- a/src/sound/snd_adlib.c +++ b/src/sound/snd_adlib.c @@ -8,7 +8,7 @@ * * Implementation of the ADLIB sound device. * - * Version: @(#)snd_adlib.c 1.0.2 2018/03/15 + * Version: @(#)snd_adlib.c 1.0.3 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,7 +46,6 @@ #include "../mca.h" #include "../device.h" #include "sound.h" -#include "snd_adlib.h" #include "snd_opl.h" diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index fa2adbd..6f04ad0 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -10,7 +10,7 @@ * * TODO: Stack allocation of big buffers (line 688 et al.) * - * Version: @(#)snd_adlibgold.c 1.0.6 2018/03/31 + * Version: @(#)snd_adlibgold.c 1.0.7 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/sound/snd_audiopci.c b/src/sound/snd_audiopci.c index 2ea1580..492e350 100644 --- a/src/sound/snd_audiopci.c +++ b/src/sound/snd_audiopci.c @@ -8,7 +8,7 @@ * * Implementation of the AudioPCI sound device. * - * Version: @(#)snd_audiopci.c 1.0.9 2018/04/02 + * Version: @(#)snd_audiopci.c 1.0.11 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,7 +49,6 @@ #include "../pci.h" #include "../timer.h" #include "sound.h" -#include "snd_audiopci.h" #define N 16 @@ -579,9 +578,9 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p) break; case 0x12: /*CD volume*/ if (val & 0x8000) - sound_set_cd_volume(0, 0); + sound_cd_set_volume(0, 0); else - sound_set_cd_volume(codec_attn[0x1f - ((val >> 8) & 0x1f)] * 2, codec_attn[0x1f - (val & 0x1f)] * 2); + sound_cd_set_volume(codec_attn[0x1f - ((val >> 8) & 0x1f)] * 2, codec_attn[0x1f - (val & 0x1f)] * 2); break; } } diff --git a/src/sound/snd_audiopci.h b/src/sound/snd_audiopci.h deleted file mode 100644 index af775c9..0000000 --- a/src/sound/snd_audiopci.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - * - * Definitions for the AudioPCI driver. - * - * Version: @(#)snd_audiopci.h 1.0.2 2018/03/15 - * - * Authors: Fred N. van Kempen, - * Miran Grca, - * Sarah Walker, - * - * Copyright 2017,2018 Fred N. van Kempen. - * Copyright 2016-2018 Miran Grca. - * Copyright 2008-2018 Sarah Walker. - * - * 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. - */ -#ifndef SOUND_AUDIOPCI_H -# define SOUND_AUDIOPCI_H - - -extern const device_t es1371_device; - - -#endif /*SOUND_AUDIOPCI_H*/ diff --git a/src/sound/snd_cms.c b/src/sound/snd_cms.c index ec452f0..0b26d9f 100644 --- a/src/sound/snd_cms.c +++ b/src/sound/snd_cms.c @@ -8,7 +8,7 @@ * * Implementation of the Create CMS/GameBlaster sound device. * - * Version: @(#)snd_cms.c 1.0.2 2018/03/15 + * Version: @(#)snd_cms.c 1.0.3 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,7 +45,6 @@ #include "../io.h" #include "../device.h" #include "sound.h" -#include "snd_cms.h" #define MASTER_CLOCK 7159090 diff --git a/src/sound/snd_cms.h b/src/sound/snd_cms.h deleted file mode 100644 index e76b35c..0000000 --- a/src/sound/snd_cms.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - * - * Definitions for the CMS/GameBlaster driver. - * - * Version: @(#)snd_cms.h 1.0.2 2018/03/15 - * - * Authors: Fred N. van Kempen, - * Miran Grca, - * Sarah Walker, - * - * Copyright 2017,2018 Fred N. van Kempen. - * Copyright 2016-2018 Miran Grca. - * Copyright 2008-2018 Sarah Walker. - * - * 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. - */ -#ifndef SOUND_CMS_H -# define SOUND_CMS_H - - -extern const device_t cms_device; - - -#endif /*SOUND_CMS_H*/ diff --git a/src/sound/snd_gus.c b/src/sound/snd_gus.c index 5277282..afdab3e 100644 --- a/src/sound/snd_gus.c +++ b/src/sound/snd_gus.c @@ -8,7 +8,7 @@ * * Implementation of the Gravis UltraSound sound device. * - * Version: @(#)snd_gus.c 1.0.3 2018/03/28 + * Version: @(#)snd_gus.c 1.0.4 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,7 +49,6 @@ #include "../timer.h" #include "../device.h" #include "sound.h" -#include "snd_gus.h" typedef struct gus_t diff --git a/src/sound/snd_gus.h b/src/sound/snd_gus.h deleted file mode 100644 index 0656c0a..0000000 --- a/src/sound/snd_gus.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - * - * Definitions for the GUS device. - * - * Version: @(#)snd_gus.h 1.0.2 2018/03/15 - * - * Authors: Fred N. van Kempen, - * Miran Grca, - * Sarah Walker, - * - * Copyright 2017,2018 Fred N. van Kempen. - * Copyright 2016-2018 Miran Grca. - * Copyright 2008-2018 Sarah Walker. - * - * 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. - */ -#ifndef SOUND_GUS_H -# define SOUND_GUS_H - - -extern const device_t gus_device; - - -#endif /*SOUND_GUS_H*/ diff --git a/src/sound/snd_lpt_dac.c b/src/sound/snd_lpt_dac.c index 820ad39..3eb0f8f 100644 --- a/src/sound/snd_lpt_dac.c +++ b/src/sound/snd_lpt_dac.c @@ -8,7 +8,7 @@ * * Implemantation of LPT-based sound devices. * - * Version: @(#)snd_lpt_dac.c 1.0.4 2018/04/05 + * Version: @(#)snd_lpt_dac.c 1.0.5 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -44,7 +44,7 @@ #include "../emu.h" #include "../cpu/cpu.h" #include "../machine/machine.h" -#include "../parallel.h" +#include "../parallel_dev.h" #include "../timer.h" #include "sound.h" #include "filters.h" @@ -60,6 +60,8 @@ typedef struct { int16_t buffer[2][SOUNDBUFLEN]; int pos; + + const char *name; } lpt_dac_t; @@ -106,7 +108,7 @@ dac_write_ctrl(uint8_t val, void *priv) static uint8_t dac_read_status(void *priv) { - return 0; + return(0x00); } @@ -132,7 +134,11 @@ dac_init(const lpt_device_t *info) { lpt_dac_t *dev = malloc(sizeof(lpt_dac_t)); + pclog("SOUND: LPT device '%s' [%d] initializing!\n", + info->name, info->type); + memset(dev, 0x00, sizeof(lpt_dac_t)); + dev->name = info->name; switch(info->type) { case 1: @@ -142,7 +148,7 @@ dac_init(const lpt_device_t *info) sound_add_handler(dac_get_buffer, dev); - return dev; + return(dev); } @@ -150,7 +156,9 @@ static void dac_close(void *priv) { lpt_dac_t *dev = (lpt_dac_t *)priv; - + + pclog("SOUND: LPT device '%s' closed!\n", dev->name); + free(dev); } diff --git a/src/sound/snd_lpt_dss.c b/src/sound/snd_lpt_dss.c index ab3c42c..319d91b 100644 --- a/src/sound/snd_lpt_dss.c +++ b/src/sound/snd_lpt_dss.c @@ -8,7 +8,7 @@ * * Implementation of the LPT-based DSS sound device. * - * Version: @(#)snd_lpt_dss.c 1.0.4 2018/04/05 + * Version: @(#)snd_lpt_dss.c 1.0.5 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,7 +45,7 @@ #include "../cpu/cpu.h" #include "../machine/machine.h" #include "../timer.h" -#include "../parallel.h" +#include "../parallel_dev.h" #include "sound.h" #include "filters.h" #include "snd_lpt_dss.h" @@ -62,6 +62,8 @@ typedef struct { int16_t buffer[SOUNDBUFLEN]; int pos; + + const char *name; } dss_t; @@ -145,7 +147,9 @@ dss_init(const lpt_device_t *info) { dss_t *dev = malloc(sizeof(dss_t)); +pclog("SOUND: LPT device '%s' initializing!\n", info->name); memset(dev, 0x00, sizeof(dss_t)); + dev->name = info->name; sound_add_handler(dss_get_buffer, dev); @@ -160,6 +164,8 @@ dss_close(void *priv) { dss_t *dev = (dss_t *)priv; + pclog("SOUND: LPT device '%s' closed!\n", dev->name); + free(dev); } diff --git a/src/sound/snd_pas16.c b/src/sound/snd_pas16.c index 2fb3efb..f1f01a3 100644 --- a/src/sound/snd_pas16.c +++ b/src/sound/snd_pas16.c @@ -79,7 +79,7 @@ * FF88 - board model * 3 = PAS16 * - * Version: @(#)snd_pas16.c 1.0.3 2018/03/28 + * Version: @(#)snd_pas16.c 1.0.4 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -126,7 +126,6 @@ #include "snd_opl.h" #include "snd_sb.h" #include "snd_sb_dsp.h" -#include "snd_pas16.h" typedef struct pas16_t diff --git a/src/sound/snd_pas16.h b/src/sound/snd_pas16.h deleted file mode 100644 index 790bbd4..0000000 --- a/src/sound/snd_pas16.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - * - * Definitions for the PAS16 driver. - * - * Version: @(#)snd_pas16.h 1.0.2 2018/03/15 - * - * Authors: Fred N. van Kempen, - * Miran Grca, - * Sarah Walker, - * - * Copyright 2017,2018 Fred N. van Kempen. - * Copyright 2016-2018 Miran Grca. - * Copyright 2008-2018 Sarah Walker. - * - * 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. - */ -#ifndef SOUND_PAS16_H -# define SOUND_PAS16_H - - -extern const device_t pas16_device; - - -#endif /*SOUND_FLUIDSYNTH_H*/ diff --git a/src/sound/snd_resid.cpp b/src/sound/snd_resid.cpp index f4a536a..3fdd851 100644 --- a/src/sound/snd_resid.cpp +++ b/src/sound/snd_resid.cpp @@ -8,7 +8,7 @@ * * Interface to the ReSid library. * - * Version: @(#)snd_resid.cpp 1.0.2 2018/02/22 + * Version: @(#)snd_resid.cpp 1.0.3 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,109 +42,122 @@ #include #include "resid-fp/sid.h" #include "../plat.h" +#include "sound.h" #include "snd_resid.h" -typedef struct psid_t -{ - /* resid sid implementation */ - SIDFP *sid; - int16_t last_sample; +typedef struct { + /* resid sid implementation */ + SIDFP *sid; + + int16_t last_sample; } psid_t; -psid_t *psid; - - -void *sid_init(void) -{ -// psid_t *psid; - int c; - sampling_method method=SAMPLE_INTERPOLATE; - float cycles_per_sec = 14318180.0 / 16.0; - - psid = new psid_t; -// psid = (psid_t *)malloc(sizeof(sound_t)); - psid->sid = new SIDFP; - - psid->sid->set_chip_model(MOS8580FP); - - psid->sid->set_voice_nonlinearity(1.0f); - psid->sid->get_filter().set_distortion_properties(0.f, 0.f, 0.f); - psid->sid->get_filter().set_type4_properties(6.55f, 20.0f); - - psid->sid->enable_filter(true); - psid->sid->enable_external_filter(true); - - psid->sid->reset(); - - for (c=0;c<32;c++) - psid->sid->write(c,0); - - if (!psid->sid->set_sampling_parameters((float)cycles_per_sec, method, - (float)48000, 0.9*48000.0/2.0)) - { - // printf("reSID failed!\n"); - } - - psid->sid->set_chip_model(MOS6581FP); - psid->sid->set_voice_nonlinearity(0.96f); - psid->sid->get_filter().set_distortion_properties(3.7e-3f, 2048.f, 1.2e-4f); - - psid->sid->input(0); - psid->sid->get_filter().set_type3_properties(1.33e6f, 2.2e9f, 1.0056f, 7e3f); - - return (void *)psid; -} - -void sid_close(UNUSED(void *p)) -{ -// psid_t *psid = (psid_t *)p; - delete psid->sid; -// free(psid); -} - -void sid_reset(UNUSED(void *p)) -{ -// psid_t *psid = (psid_t *)p; - int c; - - psid->sid->reset(); - - for (c = 0; c < 32; c++) - psid->sid->write(c, 0); -} - - -uint8_t sid_read(uint16_t addr, UNUSED(void *p)) -{ -// psid_t *psid = (psid_t *)p; - - return psid->sid->read(addr & 0x1f); -// return 0xFF; -} - -void sid_write(uint16_t addr, uint8_t val, UNUSED(void *p)) -{ -// psid_t *psid = (psid_t *)p; - - psid->sid->write(addr & 0x1f,val); -} - #define CLOCK_DELTA(n) (int)(((14318180.0 * n) / 16.0) / 48000.0) +static void +fillbuf2(int& count, int16_t *buf, int len, psid_t *dev) +{ + int c; -static void fillbuf2(int& count, int16_t *buf, int len) -{ - int c; - c = psid->sid->clock(count, buf, len, 1); - if (!c) - *buf = psid->last_sample; - psid->last_sample = *buf; + c = dev->sid->clock(count, buf, len, 1); + if (!c) + *buf = dev->last_sample; + + dev->last_sample = *buf; } -void sid_fillbuf(int16_t *buf, int len, UNUSED(void *p)) + + +void * +sid_init(void) { -// psid_t *psid = (psid_t *)p; - int x = CLOCK_DELTA(len); - - fillbuf2(x, buf, len); + sampling_method method = SAMPLE_INTERPOLATE; + float cycles_per_sec = 14318180.0 / 16.0; + psid_t *dev; + + dev = new psid_t; + dev->sid = new SIDFP; + + dev->sid->set_chip_model(MOS8580FP); + + dev->sid->set_voice_nonlinearity(1.0f); + dev->sid->get_filter().set_distortion_properties(0.f, 0.f, 0.f); + dev->sid->get_filter().set_type4_properties(6.55f, 20.0f); + + dev->sid->enable_filter(true); + dev->sid->enable_external_filter(true); + + sid_reset(dev); + + if (! dev->sid->set_sampling_parameters((float)cycles_per_sec, + method, + (float)48000, + 0.9*48000.0/2.0)) { + snddev_log("ReSID set_sampling_parameters() failed!\n"); + } + + dev->sid->set_chip_model(MOS6581FP); + dev->sid->set_voice_nonlinearity(0.96f); + dev->sid->get_filter().set_distortion_properties(3.7e-3f, + 2048.f, + 1.2e-4f); + + dev->sid->input(0); + dev->sid->get_filter().set_type3_properties(1.33e6f, + 2.2e9f, + 1.0056f, + 7e3f); + + return(dev); +} + + +void +sid_close(void *priv) +{ + psid_t *dev = (psid_t *)priv; + + delete dev->sid; + delete dev; +} + + +void +sid_reset(void *priv) +{ + psid_t *dev = (psid_t *)priv; + int c; + + dev->sid->reset(); + + for (c = 0; c < 32; c++) + dev->sid->write(c, 0x00); +} + + +uint8_t +sid_read(uint16_t addr, void *priv) +{ + psid_t *dev = (psid_t *)priv; + + return(dev->sid->read(addr & 0x1f)); +} + + +void +sid_write(uint16_t addr, uint8_t val, void *priv) +{ + psid_t *dev = (psid_t *)priv; + + dev->sid->write(addr & 0x1f, val); +} + + +void +sid_fillbuf(int16_t *buf, int len, void *priv) +{ + psid_t *dev = (psid_t *)priv; + int x = CLOCK_DELTA(len); + + fillbuf2(x, buf, len, dev); } diff --git a/src/sound/snd_resid.h b/src/sound/snd_resid.h index 3079c24..49c6806 100644 --- a/src/sound/snd_resid.h +++ b/src/sound/snd_resid.h @@ -8,7 +8,7 @@ * * Definitions for the ReSid library interface. * - * Version: @(#)snd_resid.h 1.0.1 2018/02/14 + * Version: @(#)snd_resid.h 1.0.2 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,12 +43,14 @@ #ifdef __cplusplus extern "C" { #endif - void *sid_init(); - void sid_close(void *p); - void sid_reset(void *p); - uint8_t sid_read(uint16_t addr, void *p); - void sid_write(uint16_t addr, uint8_t val, void *p); - void sid_fillbuf(int16_t *buf, int len, void *p); + +extern void *sid_init(void); +extern void sid_close(void *priv); +extern void sid_reset(void *priv); +extern uint8_t sid_read(uint16_t addr, void *priv); +extern void sid_write(uint16_t addr, uint8_t val, void *priv); +extern void sid_fillbuf(int16_t *buf, int len, void *priv); + #ifdef __cplusplus } #endif diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 30c5fe2..5707e56 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -8,7 +8,7 @@ * * Sound Blaster emulation. * - * Version: @(#)sound_sb.c 1.0.4 2018/03/31 + * Version: @(#)sound_sb.c 1.0.5 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -549,7 +549,7 @@ void sb_ct1335_mixer_write(uint16_t addr, uint8_t val, void *p) mixer->cd = sb_att_4dbstep_3bits[(mixer->regs[0x08] >> 1)&0x7]; mixer->voice = sb_att_7dbstep_2bits[(mixer->regs[0x0A] >> 1)&0x3]; - sound_set_cd_volume(((uint32_t)mixer->master * (uint32_t)mixer->cd) / 65535, + sound_cd_set_volume(((uint32_t)mixer->master * (uint32_t)mixer->cd) / 65535, ((uint32_t)mixer->master * (uint32_t)mixer->cd) / 65535); } } @@ -670,7 +670,7 @@ void sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p) } /* TODO: pcspeaker volume? Or is it not worth? */ - sound_set_cd_volume(((uint32_t)mixer->master_l * (uint32_t)mixer->cd_l) / 65535, + sound_cd_set_volume(((uint32_t)mixer->master_l * (uint32_t)mixer->cd_l) / 65535, ((uint32_t)mixer->master_r * (uint32_t)mixer->cd_r) / 65535); } } @@ -836,7 +836,7 @@ void sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *p) mixer->treble_r = mixer->regs[0x45] >> 4; /*TODO: pcspeaker volume, with "output_selector" check? or better not? */ - sound_set_cd_volume(((uint32_t)mixer->master_l * (uint32_t)mixer->cd_l) / 65535, + sound_cd_set_volume(((uint32_t)mixer->master_l * (uint32_t)mixer->cd_l) / 65535, ((uint32_t)mixer->master_r * (uint32_t)mixer->cd_r) / 65535); // pclog("sb_ct1745: Received register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]); } diff --git a/src/sound/snd_sb.h b/src/sound/snd_sb.h index 9453985..e974a92 100644 --- a/src/sound/snd_sb.h +++ b/src/sound/snd_sb.h @@ -8,7 +8,7 @@ * * Definitions for the Sound Blaster driver. * - * Version: @(#)sound_sb.h 1.0.2 2018/03/15 + * Version: @(#)sound_sb.h 1.0.3 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -53,15 +53,4 @@ #define SND_PAS16 10 /* Pro Audio Spectrum 16 */ -extern const device_t sb_1_device; -extern const device_t sb_15_device; -extern const device_t sb_mcv_device; -extern const device_t sb_2_device; -extern const device_t sb_pro_v1_device; -extern const device_t sb_pro_v2_device; -extern const device_t sb_pro_mcv_device; -extern const device_t sb_16_device; -extern const device_t sb_awe32_device; - - #endif /*SOUND_SNDB_H*/ diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index f1b7580..84cac7b 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -8,7 +8,7 @@ * * Implementation of the SSI2001 sound device. * - * Version: @(#)snd_si2001.c 1.0.2 2018/03/15 + * Version: @(#)snd_si2001.c 1.0.3 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,79 +49,154 @@ #include "snd_ssi2001.h" -typedef struct ssi2001_t -{ - void *psid; - int16_t buffer[SOUNDBUFLEN * 2]; - int pos; +typedef struct { + uint16_t base; + int16_t game; + + void *psid; + + int pos; + int16_t buffer[SOUNDBUFLEN * 2]; } ssi2001_t; -static void ssi2001_update(ssi2001_t *ssi2001) + +static void +ssi_update(ssi2001_t *dev) { - if (ssi2001->pos >= sound_pos_global) - return; - - sid_fillbuf(&ssi2001->buffer[ssi2001->pos], sound_pos_global - ssi2001->pos, ssi2001->psid); - ssi2001->pos = sound_pos_global; + if (dev->pos >= sound_pos_global) return; + + sid_fillbuf(&dev->buffer[dev->pos], sound_pos_global-dev->pos, dev->psid); + + dev->pos = sound_pos_global; } -static void ssi2001_get_buffer(int32_t *buffer, int len, void *p) + +static void +get_buffer(int32_t *buffer, int len, void *priv) { - ssi2001_t *ssi2001 = (ssi2001_t *)p; - int c; + ssi2001_t *dev = (ssi2001_t *)priv; + int c; - ssi2001_update(ssi2001); - - for (c = 0; c < len * 2; c++) - buffer[c] += ssi2001->buffer[c >> 1] / 2; + ssi_update(dev); - ssi2001->pos = 0; + for (c = 0; c < len * 2; c++) + buffer[c] += dev->buffer[c >> 1] / 2; + + dev->pos = 0; } -static uint8_t ssi2001_read(uint16_t addr, void *p) + +static uint8_t +ssi_read(uint16_t addr, void *priv) { - ssi2001_t *ssi2001 = (ssi2001_t *)p; - - ssi2001_update(ssi2001); - - return sid_read(addr, p); + ssi2001_t *dev = (ssi2001_t *)priv; + + ssi_update(dev); + + return(sid_read(addr, priv)); } -static void ssi2001_write(uint16_t addr, uint8_t val, void *p) + +static void +ssi_write(uint16_t addr, uint8_t val, void *priv) { - ssi2001_t *ssi2001 = (ssi2001_t *)p; - - ssi2001_update(ssi2001); - sid_write(addr, val, p); + ssi2001_t *dev = (ssi2001_t *)priv; + + ssi_update(dev); + + sid_write(addr, val, priv); } -void *ssi2001_init(const device_t *info) + +static void * +ssi_init(const device_t *info) { - ssi2001_t *ssi2001 = malloc(sizeof(ssi2001_t)); - memset(ssi2001, 0, sizeof(ssi2001_t)); - - pclog("ssi2001_init\n"); - ssi2001->psid = sid_init(); - sid_reset(ssi2001->psid); - io_sethandler(0x0280, 0x0020, ssi2001_read, NULL, NULL, ssi2001_write, NULL, NULL, ssi2001); - sound_add_handler(ssi2001_get_buffer, ssi2001); - return ssi2001; + ssi2001_t *dev; + + dev = malloc(sizeof(ssi2001_t)); + memset(dev, 0x00, sizeof(ssi2001_t)); + + /* Get the device configuration. We ignore the game port for now. */ + dev->base = device_get_config_hex16("base"); + dev->game = !!device_get_config_int("game_port"); + + /* Initialize the 6581 SID. */ + dev->psid = sid_init(); + sid_reset(dev->psid); + + /* Set up our I/O handler. */ + io_sethandler(dev->base, 32, + ssi_read,NULL,NULL, ssi_write,NULL,NULL, dev); + + sound_add_handler(get_buffer, dev); + + return(dev); } -void ssi2001_close(void *p) -{ - ssi2001_t *ssi2001 = (ssi2001_t *)p; - - sid_close(ssi2001->psid); - free(ssi2001); +static void +ssi_close(void *priv) +{ + ssi2001_t *dev = (ssi2001_t *)priv; + + /* Remove our I/O handler. */ + io_removehandler(dev->base, 32, + ssi_read,NULL,NULL, ssi_write,NULL,NULL, dev); + + /* Close the SID. */ + sid_close(dev->psid); + + free(dev); } -const device_t ssi2001_device = + +static const device_config_t ssi2001_config[] = { - "Innovation SSI-2001", - 0, 0, - ssi2001_init, ssi2001_close, NULL, - NULL, NULL, NULL, NULL, - NULL + { + "base", "Address", CONFIG_HEX16, "", 0x280, + { + { + "0x280", 0x280 + }, + { + "0x2A0", 0x2a0 + }, + { + "0x2C0", 0x2c0 + }, + { + "0x2E0", 0x2e0 + }, + { + "" + } + }, + }, + { + "game_port", "Game Port", CONFIG_SELECTION, "", 0, + { + { + "Disabled", 0 + }, + { + "Enabled", 1 + }, + { + "" + } + }, + }, + { + "", "", -1 + } +}; + + +const device_t ssi2001_device = { + "Innovation SSI-2001", + DEVICE_ISA, + 0, + ssi_init, ssi_close, NULL, + NULL, NULL, NULL, NULL, + ssi2001_config }; diff --git a/src/sound/snd_wss.c b/src/sound/snd_wss.c index 7d5413e..4dc9b76 100644 --- a/src/sound/snd_wss.c +++ b/src/sound/snd_wss.c @@ -8,7 +8,7 @@ * * Implementation of the Windows Sound System sound device. * - * Version: @(#)snd_wss.c 1.0.2 2018/03/15 + * Version: @(#)snd_wss.c 1.0.3 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,7 +50,6 @@ #include "sound.h" #include "snd_ad1848.h" #include "snd_opl.h" -#include "snd_wss.h" /*530, 11, 3 - 530=23*/ diff --git a/src/sound/snd_wss.h b/src/sound/snd_wss.h deleted file mode 100644 index c837224..0000000 --- a/src/sound/snd_wss.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - * - * Definitions for the WSS driver. - * - * Version: @(#)snd_wss.h 1.0.2 2018/03/15 - * - * Authors: Fred N. van Kempen, - * Miran Grca, - * Sarah Walker, - * - * Copyright 2017,2018 Fred N. van Kempen. - * Copyright 2016-2018 Miran Grca. - * Copyright 2008-2018 Sarah Walker. - * - * 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. - */ -#ifndef SOUND_WSS_H -# define SOUND_WSS_H - - -extern const device_t wss_device; - - -#endif /*SOUND_WSS_H*/ diff --git a/src/sound/sound.c b/src/sound/sound.c index d360f6a..1ab2764 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.6 2018/04/05 + * Version: @(#)sound.c 1.0.7 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,179 +50,56 @@ #include "../plat.h" #include "sound.h" #include "midi.h" -#include "snd_opl.h" -#include "snd_adlib.h" -#include "snd_adlibgold.h" -#include "snd_audiopci.h" -#include "snd_mpu401.h" #ifdef USE_FLUIDSYNTH # include "midi_fluidsynth.h" #endif -#if defined(DEV_BRANCH) && defined(USE_PAS16) -# include "snd_pas16.h" -#endif +#include "snd_dbopl.h" +#include "snd_mpu401.h" +#include "snd_opl.h" #include "snd_sb.h" #include "snd_sb_dsp.h" -#include "snd_wss.h" +#include "snd_speaker.h" +#include "snd_ssi2001.h" #include "filters.h" -typedef struct { - const char *name; - const char *internal_name; - const device_t *device; -} sound_t; - typedef struct { void (*get_buffer)(int32_t *buffer, int len, void *p); void *priv; -} sound_handler_t; +} sndhnd_t; -#ifdef ENABLE_SOUND_DEV_LOG -int sound_dev_do_log = ENABLE_SOUND_DEV_LOG; -#endif -int sound_card_current = 0; -int sound_pos_global = 0; -int sound_gain = 0; -volatile int soundon = 1; +int sound_pos_global = 0; +int sound_gain = 0; +volatile int soundon = 1; -static int sound_card_last = 0; -static sound_handler_t sound_handlers[8]; -static sound_handler_t sound_process_handlers[8]; -static int sound_handlers_num; -static int sound_process_handlers_num; -static int64_t sound_poll_time = 0LL, sound_poll_latch; -static int16_t cd_buffer[CDROM_NUM][CD_BUFLEN * 2]; -static float cd_out_buffer[CD_BUFLEN * 2]; -static int16_t cd_out_buffer_int16[CD_BUFLEN * 2]; -static thread_t *sound_cd_thread_h; -static event_t *sound_cd_event; -static event_t *sound_cd_start_event; -static unsigned int cd_vol_l, - cd_vol_r; -static int cd_buf_update = CD_BUFLEN / SOUNDBUFLEN; -static volatile int cdaudioon = 0; -static int32_t *outbuffer; -static float *outbuffer_ex; -static int16_t *outbuffer_ex_int16; -static int cd_thread_enable = 0; +//static int card_last = 0; +static sndhnd_t handlers[8]; +static sndhnd_t process_handlers[8]; +static int handlers_num; +static int process_handlers_num; +static int64_t poll_time = 0LL, + poll_latch; +static int32_t *outbuffer; +static float *outbuffer_ex; +static int16_t *outbuffer_ex_int16; - -static const sound_t sound_cards[] = { - {"Disabled", "none", NULL }, - {"[ISA] Adlib", "adlib", &adlib_device }, - {"[ISA] Adlib Gold", "adlibgold", &adgold_device }, - {"[ISA] Sound Blaster 1.0", "sb", &sb_1_device }, - {"[ISA] Sound Blaster 1.5", "sb1.5", &sb_15_device }, - {"[ISA] Sound Blaster 2.0", "sb2.0", &sb_2_device }, - {"[ISA] Sound Blaster Pro v1", "sbprov1", &sb_pro_v1_device}, - {"[ISA] Sound Blaster Pro v2", "sbprov2", &sb_pro_v2_device}, - {"[ISA] Sound Blaster 16", "sb16", &sb_16_device }, - {"[ISA] Sound Blaster AWE32", "sbawe32", &sb_awe32_device}, -#if defined(DEV_BRANCH) && defined(USE_PAS16) - {"[ISA] Pro Audio Spectrum 16", "pas16", &pas16_device }, -#endif - {"[ISA] Windows Sound System", "wss", &wss_device }, - {"[MCA] Adlib", "adlib_mca", &adlib_mca_device}, - {"[MCA] Sound Blaster MCV", "sbmcv", &sb_mcv_device }, - {"[MCA] Sound Blaster Pro MCV", "sbpromcv", &sb_pro_mcv_device}, - {"[PCI] Ensoniq AudioPCI (ES1371)", "es1371", &es1371_device }, - {"[PCI] Sound Blaster PCI 128", "sbpci128", &es1371_device }, - {NULL, NULL, NULL } -}; - - -void -snddev_log(const char *fmt, ...) -{ -#ifdef ENABLE_SOUND_DEV_LOG - va_list ap; - - if (sound_dev_do_log) { - va_start(ap, fmt); - pclog_ex(fmt, ap); - va_end(ap); - } -#endif -} - - -int -sound_card_available(int card) -{ - if (sound_cards[card].device != NULL) - return(device_available(sound_cards[card].device)); - - return(1); -} - - -char * -sound_card_getname(int card) -{ - return((char *)sound_cards[card].name); -} - - -const device_t *sound_card_getdevice(int card) -{ - return(sound_cards[card].device); -} - - -int -sound_card_has_config(int card) -{ - if (sound_cards[card].device == NULL) return(0); - - return(sound_cards[card].device->config ? 1 : 0); -} - - -char * -sound_card_get_internal_name(int card) -{ - return((char *)sound_cards[card].internal_name); -} - - -int -sound_card_get_from_internal_name(char *s) -{ - int c = 0; - - while (sound_cards[c].internal_name != NULL) { - if (! strcmp((char *)sound_cards[c].internal_name, s)) - return(c); - c++; - } - - return(0); -} - - -void -sound_card_init(void) -{ - if (sound_cards[sound_card_current].device != NULL) - device_add(sound_cards[sound_card_current].device); - - sound_card_last = sound_card_current; -} - - -void -sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r) -{ - cd_vol_l = vol_l; - cd_vol_r = vol_r; -} +static int16_t cd_buffer[CDROM_NUM][CD_BUFLEN * 2]; +static float cd_out_buffer[CD_BUFLEN * 2]; +static int16_t cd_out_buffer_int16[CD_BUFLEN * 2]; +static thread_t *cd_thread_h; +static event_t *cd_event; +static event_t *cd_start_event; +static unsigned cd_vol_l, + cd_vol_r; +static int cd_buf_update = CD_BUFLEN / SOUNDBUFLEN; +static int cd_thread_enable = 0; +static volatile int cd_audioon = 0; static void -sound_cd_thread(void *param) +cd_thread(void *param) { float cd_buffer_temp[2] = {0.0, 0.0}; float cd_buffer_temp2[2] = {0.0, 0.0}; @@ -232,13 +109,13 @@ sound_cd_thread(void *param) int channel_select[2]; int c, d, i, has_audio; - thread_set_event(sound_cd_start_event); + thread_set_event(cd_start_event); - while (cdaudioon) { - thread_wait_event(sound_cd_event, -1); - thread_reset_event(sound_cd_event); + while (cd_audioon) { + thread_wait_event(cd_event, -1); + thread_reset_event(cd_event); - if (!soundon || !cdaudioon) return; + if (!soundon || !cd_audioon) return; for (c = 0; c < CD_BUFLEN*2; c += 2) { if (sound_is_float) { @@ -270,13 +147,13 @@ sound_cd_thread(void *param) for (c = 0; c < CD_BUFLEN*2; c += 2) { /* First, transfer the CD audio data to the temporary buffer. */ - cd_buffer_temp[0] = (float) cd_buffer[i][c]; - cd_buffer_temp[1] = (float) cd_buffer[i][c+1]; + cd_buffer_temp[0] = (float)cd_buffer[i][c]; + cd_buffer_temp[1] = (float)cd_buffer[i][c+1]; /* Then, adjust input from drive according to ATAPI/SCSI volume. */ - cd_buffer_temp[0] *= (float) audio_vol_l; + cd_buffer_temp[0] *= (float)audio_vol_l; cd_buffer_temp[0] /= 511.0; - cd_buffer_temp[1] *= (float) audio_vol_r; + cd_buffer_temp[1] *= (float)audio_vol_r; cd_buffer_temp[1] /= 511.0; /*Apply ATAPI channel select*/ @@ -290,21 +167,21 @@ sound_cd_thread(void *param) if (channel_select[1] & 2) cd_buffer_temp2[1] += cd_buffer_temp[1]; - if (sound_process_handlers_num) { - cd_buffer_temp4[0] = (int32_t) cd_buffer_temp2[0]; - cd_buffer_temp4[1] = (int32_t) cd_buffer_temp2[1]; + if (process_handlers_num) { + cd_buffer_temp4[0] = (int32_t)cd_buffer_temp2[0]; + cd_buffer_temp4[1] = (int32_t)cd_buffer_temp2[1]; - for (d = 0; d < sound_process_handlers_num; d++) - sound_process_handlers[d].get_buffer(cd_buffer_temp4, 1, sound_process_handlers[d].priv); + for (d = 0; d < process_handlers_num; d++) + process_handlers[d].get_buffer(cd_buffer_temp4, 1, process_handlers[d].priv); - cd_buffer_temp2[0] = (float) cd_buffer_temp4[0]; - cd_buffer_temp2[1] = (float) cd_buffer_temp4[1]; + cd_buffer_temp2[0] = (float)cd_buffer_temp4[0]; + cd_buffer_temp2[1] = (float)cd_buffer_temp4[1]; } else { /*Apply sound card CD volume*/ - cd_buffer_temp2[0] *= (float) cd_vol_l; + cd_buffer_temp2[0] *= (float)cd_vol_l; cd_buffer_temp2[0] /= 65535.0; - cd_buffer_temp2[1] *= (float) cd_vol_r; + cd_buffer_temp2[1] *= (float)cd_vol_r; cd_buffer_temp2[1] /= 65535.0; } @@ -336,87 +213,39 @@ sound_cd_thread(void *param) } -void -sound_realloc_buffers(void) +static void +cd_thread_end(void) { - if (outbuffer_ex != NULL) - free(outbuffer_ex); - if (outbuffer_ex_int16 != NULL) - free(outbuffer_ex_int16); + if (! cd_audioon) return; - if (sound_is_float) - outbuffer_ex = malloc(SOUNDBUFLEN * 2 * sizeof(float)); - else - outbuffer_ex_int16 = malloc(SOUNDBUFLEN * 2 * sizeof(int16_t)); -} - - -void -sound_init(void) -{ - int drives = 0; - int i; - - initalmain(0,NULL); - inital(); - - outbuffer_ex = NULL; - outbuffer_ex_int16 = NULL; - - outbuffer = malloc(SOUNDBUFLEN * 2 * sizeof(int32_t)); - - sound_realloc_buffers(); - - for (i = 0; i < CDROM_NUM; i++) { - if (cdrom_drives[i].bus_type != CDROM_BUS_DISABLED) - drives++; - } - - if (drives) { - cdaudioon = 1; - - sound_cd_start_event = thread_create_event(); - - sound_cd_event = thread_create_event(); - sound_cd_thread_h = thread_create(sound_cd_thread, NULL); + cd_audioon = 0; #if 0 - pclog("Waiting for CD start event...\n"); + pclog("Waiting for CD Audio thread to terminate...\n"); #endif - thread_wait_event(sound_cd_start_event, -1); - thread_reset_event(sound_cd_start_event); + thread_set_event(cd_event); + thread_wait(cd_thread_h, -1); #if 0 - pclog("Done!\n"); + pclog("CD Audio thread terminated...\n"); #endif - } else - cdaudioon = 0; - cd_thread_enable = drives ? 1 : 0; + if (cd_event) { + thread_destroy_event(cd_event); + cd_event = NULL; + } + cd_thread_h = NULL; + + if (cd_start_event) { + thread_destroy_event(cd_start_event); + cd_start_event = NULL; + } } -void -sound_add_handler(void (*get_buffer)(int32_t *buffer, int len, void *p), void *p) -{ - sound_handlers[sound_handlers_num].get_buffer = get_buffer; - sound_handlers[sound_handlers_num].priv = p; - sound_handlers_num++; -} - - -void -sound_add_process_handler(void (*get_buffer)(int32_t *buffer, int len, void *p), void *p) -{ - sound_process_handlers[sound_process_handlers_num].get_buffer = get_buffer; - sound_process_handlers[sound_process_handlers_num].priv = p; - sound_process_handlers_num++; -} - - -void +static void sound_poll(void *priv) { - sound_poll_time += sound_poll_latch; + poll_time += poll_latch; midi_poll(); @@ -426,8 +255,8 @@ sound_poll(void *priv) memset(outbuffer, 0, SOUNDBUFLEN * 2 * sizeof(int32_t)); - for (c = 0; c < sound_handlers_num; c++) - sound_handlers[c].get_buffer(outbuffer, SOUNDBUFLEN, sound_handlers[c].priv); + for (c = 0; c < handlers_num; c++) + handlers[c].get_buffer(outbuffer, SOUNDBUFLEN, handlers[c].priv); for (c = 0; c < SOUNDBUFLEN * 2; c++) { if (sound_is_float) { @@ -453,7 +282,7 @@ sound_poll(void *priv) cd_buf_update--; if (! cd_buf_update) { cd_buf_update = (48000 / SOUNDBUFLEN) / (CD_FREQ / CD_BUFLEN); - thread_set_event(sound_cd_event); + thread_set_event(cd_event); } } @@ -462,64 +291,125 @@ sound_poll(void *priv) } -void -sound_speed_changed(void) -{ - sound_poll_latch = (int64_t)((double)TIMER_USEC * (1000000.0 / 48000.0)); -} - - +/* Reset the sound system. */ void sound_reset(void) { int i; - timer_add(sound_poll, &sound_poll_time, TIMER_ALWAYS_ENABLED, NULL); + pclog("SOUND: reset (current=%d)\n", sound_card_current); - sound_handlers_num = 0; + /* Kill the CD-Audio thread. */ + sound_cd_stop(); - sound_process_handlers_num = 0; + /* Reset the sound module buffers. */ + if (outbuffer_ex != NULL) + free(outbuffer_ex); + if (outbuffer_ex_int16 != NULL) + free(outbuffer_ex_int16); + if (sound_is_float) + outbuffer_ex = malloc(SOUNDBUFLEN * 2 * sizeof(float)); + else + outbuffer_ex_int16 = malloc(SOUNDBUFLEN * 2 * sizeof(int16_t)); - sound_set_cd_volume(65535, 65535); + /* Reset the MIDI devices. */ + midi_device_init(); + + /* Reset OpenAL. */ + inital(); + + timer_add(sound_poll, &poll_time, TIMER_ALWAYS_ENABLED, NULL); + + handlers_num = 0; + + process_handlers_num = 0; + + sound_cd_set_volume(65535, 65535); for (i = 0; i < CDROM_NUM; i++) { if (cdrom_drives[i].handler->audio_stop) cdrom_drives[i].handler->audio_stop(i); } + + /* Initialize the currently selected sound card. */ + snddev_reset(); +// card_last = sound_card_current; + + if (mpu401_standalone_enable) + mpu401_device_add(); + +#if 0 + if (GAMEBLASTER) + device_add(&cms_device); +#endif } +/* Initialize the sound system (once.) */ void -sound_cd_thread_end(void) +sound_init(void) { - if (! cdaudioon) return; + int drives = 0; + int i; - cdaudioon = 0; + /* Initialize the OpenAL module. */ + initalmain(0,NULL); -#if 0 - pclog("Waiting for CD Audio thread to terminate...\n"); -#endif - thread_set_event(sound_cd_event); - thread_wait(sound_cd_thread_h, -1); -#if 0 - pclog("CD Audio thread terminated...\n"); +#ifdef USE_FLUIDSYNTH + /* Initialize the FluidSynth module. */ + fluidsynth_global_init(); #endif - if (sound_cd_event) { - thread_destroy_event(sound_cd_event); - sound_cd_event = NULL; - } - sound_cd_thread_h = NULL; + outbuffer_ex = NULL; + outbuffer_ex_int16 = NULL; - if (sound_cd_start_event) { - thread_destroy_event(sound_cd_start_event); - sound_cd_event = NULL; - } + outbuffer = malloc(SOUNDBUFLEN * 2 * sizeof(int32_t)); + + /* Set up the CD-AUDIO thread. */ + for (i = 0; i < CDROM_NUM; i++) { + if (cdrom_drives[i].bus_type != CDROM_BUS_DISABLED) + drives++; + } + if (drives) { + cd_audioon = 1; + + cd_start_event = thread_create_event(); + + cd_event = thread_create_event(); + cd_thread_h = thread_create(cd_thread, NULL); + +#if 0 + pclog("Waiting for CD start event...\n"); +#endif + thread_wait_event(cd_start_event, -1); + thread_reset_event(cd_start_event); +#if 0 + pclog("Done!\n"); +#endif + } else + cd_audioon = 0; + + cd_thread_enable = drives ? 1 : 0; +} + + +/* Close down the sound module. */ +void +sound_close(void) +{ + /* Kill the CD-Audio thread if needed. */ + sound_cd_stop(); + + /* Close down the MIDI module. */ + midi_close(); + + /* Close the OpenAL interface. */ + closeal(); } void -sound_cd_thread_reset(void) +sound_cd_stop(void) { int drives = 0; int i; @@ -529,28 +419,51 @@ sound_cd_thread_reset(void) drives++; } if (drives && !cd_thread_enable) { - cdaudioon = 1; + cd_audioon = 1; - sound_cd_start_event = thread_create_event(); + cd_start_event = thread_create_event(); - sound_cd_event = thread_create_event(); - sound_cd_thread_h = thread_create(sound_cd_thread, NULL); + cd_event = thread_create_event(); + cd_thread_h = thread_create(cd_thread, NULL); - thread_wait_event(sound_cd_start_event, -1); - thread_reset_event(sound_cd_start_event); + thread_wait_event(cd_start_event, -1); + thread_reset_event(cd_start_event); } else if (!drives && cd_thread_enable) { - sound_cd_thread_end(); + cd_thread_end(); } cd_thread_enable = drives ? 1 : 0; } -/* Called once, at application startup. */ void -sound_global_init(void) +sound_cd_set_volume(unsigned int vol_l, unsigned int vol_r) { -#ifdef USE_FLUIDSYNTH - fluidsynth_global_init(); -#endif + cd_vol_l = vol_l; + cd_vol_r = vol_r; +} + + +void +sound_add_handler(void (*get_buffer)(int32_t *buffer, int len, void *p), void *p) +{ + handlers[handlers_num].get_buffer = get_buffer; + handlers[handlers_num].priv = p; + handlers_num++; +} + + +void +sound_add_process_handler(void (*get_buffer)(int32_t *buffer, int len, void *p), void *p) +{ + process_handlers[process_handlers_num].get_buffer = get_buffer; + process_handlers[process_handlers_num].priv = p; + process_handlers_num++; +} + + +void +sound_speed_changed(void) +{ + poll_latch = (int64_t)((double)TIMER_USEC * (1000000.0 / 48000.0)); } diff --git a/src/sound/sound.h b/src/sound/sound.h index 37caf0e..6f4fad1 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -8,7 +8,7 @@ * * Definitions for the Sound Emulation core. * - * Version: @(#)sound.h 1.0.4 2018/04/02 + * Version: @(#)sound.h 1.0.5 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,6 +46,10 @@ #define CD_BUFLEN (CD_FREQ / 10) +#ifdef __cplusplus +extern "C" { +#endif + extern int sound_dev_do_log; extern int ppispeakon; @@ -55,8 +59,7 @@ extern int gated, extern int sound_pos_global; extern int sound_card_current; - -extern int sound_gain; +extern int sound_gain; extern void snddev_log(const char *fmt, ...); @@ -66,6 +69,7 @@ extern void sound_add_handler(void (*get_buffer)(int32_t *buffer, \ extern void sound_add_process_handler(void (*get_buffer)(int32_t *buffer, \ int len, void *p), void *p); +extern void snddev_reset(void); extern int sound_card_available(int card); extern char *sound_card_getname(int card); #ifdef EMU_DEVICE_H @@ -75,18 +79,15 @@ extern int sound_card_has_config(int card); extern char *sound_card_get_internal_name(int card); extern int sound_card_get_from_internal_name(char *s); extern void sound_card_init(void); -extern void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r); extern void sound_speed_changed(void); -extern void sound_realloc_buffers(void); - -extern void sound_global_init(void); -extern void sound_init(void); extern void sound_reset(void); +extern void sound_init(void); +extern void sound_close(void); -extern void sound_cd_thread_end(void); -extern void sound_cd_thread_reset(void); +extern void sound_cd_stop(void); +extern void sound_cd_set_volume(unsigned int vol_l, unsigned int vol_r); extern void closeal(void); extern void initalmain(int argc, char *argv[]); @@ -94,5 +95,9 @@ extern void inital(void); extern void givealbuffer(void *buf); extern void givealbuffer_cd(void *buf); +#ifdef __cplusplus +} +#endif + #endif /*EMU_SOUND_H*/ diff --git a/src/sound/sound_dev.c b/src/sound/sound_dev.c new file mode 100644 index 0000000..de01fbb --- /dev/null +++ b/src/sound/sound_dev.c @@ -0,0 +1,188 @@ +/* + * 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. + * + * Sound devices support module. + * + * Version: @(#)sound_dev.c 1.0.1 2018/04/08 + * + * Authors: Fred N. van Kempen, + * Miran Grca, + * Sarah Walker, + * + * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2016-2018 Miran Grca. + * Copyright 2008-2018 Sarah Walker. + * + * 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 +#define HAVE_STDARG_H +#include "../emu.h" +#include "../device.h" +#include "../plat.h" +#include "sound.h" + + +typedef struct { + const char *name; + const char *internal_name; + const device_t *device; +} sound_t; + + +#ifdef ENABLE_SOUND_DEV_LOG +int sound_dev_do_log = ENABLE_SOUND_DEV_LOG; +#endif +int sound_card_current = 0; + + +/* Sound card devices. */ +extern const device_t adlib_device; +extern const device_t adlib_mca_device; +extern const device_t adgold_device; +extern const device_t es1371_device; +extern const device_t cms_device; +extern const device_t gus_device; +#if defined(DEV_BRANCH) && defined(USE_PAS16) +extern const device_t pas16_device; +#endif +extern const device_t sb_1_device; +extern const device_t sb_15_device; +extern const device_t sb_mcv_device; +extern const device_t sb_2_device; +extern const device_t sb_pro_v1_device; +extern const device_t sb_pro_v2_device; +extern const device_t sb_pro_mcv_device; +extern const device_t sb_16_device; +extern const device_t sb_awe32_device; +extern const device_t ssi2001_device; +extern const device_t wss_device; + + +static const sound_t sound_cards[] = { + {"Disabled", "none", NULL }, + {"[ISA] Adlib", "adlib", &adlib_device }, + {"[ISA] Adlib Gold", "adlibgold", &adgold_device }, + {"[ISA] Gravis Ultra Sound", "gus", &gus_device }, + {"[ISA] Innovation SSI-2001", "ssi2001", &ssi2001_device }, + {"[ISA] Sound Blaster 1.0", "sb", &sb_1_device }, + {"[ISA] Sound Blaster 1.5", "sb1.5", &sb_15_device }, + {"[ISA] Sound Blaster 2.0", "sb2.0", &sb_2_device }, + {"[ISA] Sound Blaster Pro v1", "sbprov1", &sb_pro_v1_device}, + {"[ISA] Sound Blaster Pro v2", "sbprov2", &sb_pro_v2_device}, + {"[ISA] Sound Blaster 16", "sb16", &sb_16_device }, + {"[ISA] Sound Blaster AWE32", "sbawe32", &sb_awe32_device}, +#if defined(DEV_BRANCH) && defined(USE_PAS16) + {"[ISA] Pro Audio Spectrum 16", "pas16", &pas16_device }, +#endif + {"[ISA] Windows Sound System", "wss", &wss_device }, + {"[MCA] Adlib", "adlib_mca", &adlib_mca_device}, + {"[MCA] Sound Blaster MCV", "sbmcv", &sb_mcv_device }, + {"[MCA] Sound Blaster Pro MCV", "sbpromcv", &sb_pro_mcv_device}, + {"[PCI] Ensoniq AudioPCI (ES1371)", "es1371", &es1371_device }, + {"[PCI] Sound Blaster PCI 128", "sbpci128", &es1371_device }, + {NULL, NULL, NULL } +}; + + +void +snddev_log(const char *fmt, ...) +{ +#ifdef ENABLE_SOUND_DEV_LOG + va_list ap; + + if (sound_dev_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +#endif +} + + +void +snddev_reset(void) +{ + if (sound_cards[sound_card_current].device != NULL) + device_add(sound_cards[sound_card_current].device); +} + + +int +sound_card_available(int card) +{ + if (sound_cards[card].device != NULL) + return(device_available(sound_cards[card].device)); + + return(1); +} + + +char * +sound_card_getname(int card) +{ + return((char *)sound_cards[card].name); +} + + +const device_t *sound_card_getdevice(int card) +{ + return(sound_cards[card].device); +} + + +int +sound_card_has_config(int card) +{ + if (sound_cards[card].device == NULL) return(0); + + return(sound_cards[card].device->config ? 1 : 0); +} + + +char * +sound_card_get_internal_name(int card) +{ + return((char *)sound_cards[card].internal_name); +} + + +int +sound_card_get_from_internal_name(char *s) +{ + int c = 0; + + while (sound_cards[c].internal_name != NULL) { + if (! strcmp((char *)sound_cards[c].internal_name, s)) + return(c); + c++; + } + + return(0); +} diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 0078802..89ac9b1 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -11,7 +11,7 @@ * This is intended to be used by another SVGA driver, * and not as a card in it's own right. * - * Version: @(#)vid_svga.c 1.0.8 2018/03/26 + * Version: @(#)vid_svga.c 1.0.9 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -122,7 +122,7 @@ void svga_out(uint16_t addr, uint8_t val, void *p) } else if (svga->attraddr == 0x11) { - svga->overscan_color = svga->pallook[svga->overscan_color]; + svga->overscan_color = svga->pallook[svga->attrregs[0x11]]; if (o != val) svga_recalctimings(svga); } diff --git a/src/win/VARCem.rc b/src/win/VARCem.rc index 64a9a50..b2972c5 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.14 2018/04/05 + * Version: @(#)VARCem.rc 1.0.15 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -390,8 +390,8 @@ BEGIN /* Leave this commented out until we get into localization. */ #if 0 LTEXT "Language:",IDT_1700,7,232,41,10 - COMBOBOX IDC_COMBO_LANG,48,231,108,120,CBS_DROPDOWN | WS_VSCROLL | - WS_TABSTOP + COMBOBOX IDC_COMBO_LANG,48,231,108,120,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP #endif END @@ -483,17 +483,13 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,7,45,199,10 PUSHBUTTON "Configure",IDC_CONFIGURE_MPU401,214,44,46,12 - CONTROL "Innovation SSI-2001",IDC_CHECK_SSI,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,63,94,10 - CONTROL "CMS / Game Blaster",IDC_CHECK_CMS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,147,63,94,10 - - CONTROL "Gravis Ultrasound",IDC_CHECK_GUS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,81,94,10 CONTROL "Use Nuked OPL",IDC_CHECK_NUKEDOPL,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,147,81,94,10 + BS_AUTOCHECKBOX | WS_TABSTOP,7,63,94,10 CONTROL "Use FLOAT32 sound",IDC_CHECK_FLOAT,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,81,94,10 + + CONTROL "CMS / Game Blaster",IDC_CHECK_CMS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,99,94,10 END diff --git a/src/win/mingw/Makefile.MinGW b/src/win/mingw/Makefile.MinGW index a275572..dac4a0b 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.19 2018/04/05 +# Version: @(#)Makefile.mingw 1.0.21 2018/04/08 # # Author: Fred N. van Kempen, # @@ -509,7 +509,7 @@ MCHOBJ := machine.o machine_table.o \ m_at_430lx_nx.o m_at_430fx.o \ m_at_430hx.o m_at_430vx.o -DEVOBJ := bugger.o parallel.o $(SERIAL) \ +DEVOBJ := bugger.o parallel.o parallel_dev.o $(SERIAL) \ sio_fdc37c66x.o sio_fdc37c669.o sio_fdc37c93x.o \ sio_pc87306.o sio_w83877f.o sio_um8669f.o \ keyboard.o \ @@ -559,6 +559,7 @@ NETOBJ := network.o \ net_ne2000.o SNDOBJ := sound.o \ + sound_dev.o \ openal.o \ snd_opl.o snd_dbopl.o \ dbopl.o nukedopl.o \ diff --git a/src/win/msvc/Makefile.VC b/src/win/msvc/Makefile.VC index 71d16c1..a9784f5 100644 --- a/src/win/msvc/Makefile.VC +++ b/src/win/msvc/Makefile.VC @@ -8,7 +8,7 @@ # # Makefile for Windows using Visual Studio 2015. # -# Version: @(#)Makefile.VC 1.0.4 2018/04/05 +# Version: @(#)Makefile.VC 1.0.6 2018/04/08 # # Author: Fred N. van Kempen, # @@ -474,7 +474,7 @@ MCHOBJ := machine.obj machine_table.obj \ m_at_430lx_nx.obj m_at_430fx.obj \ m_at_430hx.obj m_at_430vx.obj -DEVOBJ := bugger.obj parallel.obj $(SERIAL) \ +DEVOBJ := bugger.obj parallel.obj parallel_dev.obj $(SERIAL) \ sio_fdc37c66x.obj sio_fdc37c669.obj sio_fdc37c93x.obj \ sio_pc87306.obj sio_w83877f.obj sio_um8669f.obj \ keyboard.obj \ @@ -524,6 +524,7 @@ NETOBJ := network.obj \ net_ne2000.obj SNDOBJ := sound.obj \ + sound_dev.obj \ openal.obj \ snd_opl.obj snd_dbopl.obj \ dbopl.obj nukedopl.obj \ diff --git a/src/win/msvc/vc14/VARCem.vcxproj b/src/win/msvc/vc14/VARCem.vcxproj index f3e8086..b8f878f 100644 --- a/src/win/msvc/vc14/VARCem.vcxproj +++ b/src/win/msvc/vc14/VARCem.vcxproj @@ -84,7 +84,6 @@ - @@ -155,6 +154,8 @@ + + @@ -422,7 +423,6 @@ - @@ -460,6 +460,8 @@ + + diff --git a/src/win/msvc/vc14/VARCem.vcxproj.filters b/src/win/msvc/vc14/VARCem.vcxproj.filters index fc9bfdc..5365970 100644 --- a/src/win/msvc/vc14/VARCem.vcxproj.filters +++ b/src/win/msvc/vc14/VARCem.vcxproj.filters @@ -15,7 +15,6 @@ - @@ -28,6 +27,8 @@ + + @@ -817,7 +818,6 @@ - @@ -825,6 +825,8 @@ + + diff --git a/src/win/msvc/vc15/VARCem.vcxproj b/src/win/msvc/vc15/VARCem.vcxproj index a006272..b497780 100644 --- a/src/win/msvc/vc15/VARCem.vcxproj +++ b/src/win/msvc/vc15/VARCem.vcxproj @@ -84,7 +84,8 @@ - + + @@ -422,7 +423,6 @@ - @@ -460,6 +460,8 @@ + + diff --git a/src/win/msvc/vc15/VARCem.vcxproj.filters b/src/win/msvc/vc15/VARCem.vcxproj.filters index c82fba8..fea2765 100644 --- a/src/win/msvc/vc15/VARCem.vcxproj.filters +++ b/src/win/msvc/vc15/VARCem.vcxproj.filters @@ -15,7 +15,6 @@ - @@ -28,6 +27,8 @@ + + @@ -817,7 +818,8 @@ - + + @@ -825,6 +827,8 @@ + + @@ -1663,4 +1667,4 @@ win - \ No newline at end of file + diff --git a/src/win/resource.h b/src/win/resource.h index 9b4b669..34cf7bd 100644 --- a/src/win/resource.h +++ b/src/win/resource.h @@ -8,7 +8,7 @@ * * Windows resource defines. * - * Version: @(#)resource.h 1.0.9 2018/04/05 + * Version: @(#)resource.h 1.0.10 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -155,14 +155,12 @@ #define IDC_SOUND 1070 /* sound config */ #define IDC_COMBO_SOUND 1071 -#define IDC_CHECK_SSI 1072 -#define IDC_CHECK_CMS 1073 -#define IDC_CHECK_GUS 1074 -#define IDC_CHECK_NUKEDOPL 1075 -#define IDC_COMBO_MIDI 1076 -#define IDC_CHECK_MPU401 1077 -#define IDC_CONFIGURE_MPU401 1078 -#define IDC_CHECK_FLOAT 1079 +#define IDC_COMBO_MIDI 1072 +#define IDC_CHECK_NUKEDOPL 1073 +#define IDC_CHECK_FLOAT 1074 +#define IDC_CHECK_MPU401 1075 +#define IDC_CONFIGURE_MPU401 1076 +#define IDC_CHECK_CMS 1077 #define IDC_COMBO_NET_TYPE 1090 /* network config */ #define IDC_COMBO_PCAP 1091 diff --git a/src/win/win_devconf.c b/src/win/win_devconf.c index 7b2ecd0..9792db2 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.8 2018/04/01 + * Version: @(#)win_devconf.c 1.0.9 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -510,7 +510,7 @@ deviceconfig_open(HWND hwnd, device_t *device) item->cx = 140; item->cy = 150; - item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL; + item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL; data = (uint16_t *)(item + 1); *data++ = 0xFFFF; diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 90ee805..2060152 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.18 2018/04/05 + * Version: @(#)win_settings.c 1.0.19 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -55,6 +55,7 @@ #include "../game/gameport.h" #include "../mouse.h" #include "../parallel.h" +#include "../parallel_dev.h" #include "../serial.h" #include "../disk/hdd.h" #include "../disk/hdc.h" @@ -75,66 +76,58 @@ #include "win.h" -/* Machine category */ -static int temp_machine, temp_cpu_m, temp_cpu, temp_wait_states, - temp_mem_size, temp_fpu, temp_sync; +/* Machine category. */ +static int temp_machine, + temp_cpu_m, temp_cpu, temp_wait_states, + temp_mem_size, temp_fpu, temp_sync; #ifdef USE_DYNAREC -static int temp_dynarec; +static int temp_dynarec; #endif -/* Video category */ -static int temp_vid_card, temp_video_speed, temp_voodoo; +/* Video category. */ +static int temp_vid_card, temp_video_speed, temp_voodoo; -/* Input devices category */ -static int temp_mouse, temp_joystick; +/* Input devices category. */ +static int temp_mouse, temp_joystick; -/* Sound category */ -static int temp_sound_card, temp_midi_device, temp_mpu401, temp_SSI2001, - temp_GAMEBLASTER, temp_GUS, temp_opl3_type, temp_float; +/* Sound category. */ +static int temp_sound_card, temp_midi_device, temp_mpu401, + temp_GAMEBLASTER, temp_opl3_type, temp_float; -/* Network category */ -static int temp_net_type, temp_net_card; -static char temp_host_dev[520]; +/* Network category. */ +static int temp_net_type, temp_net_card; +static char temp_host_dev[128]; -/* Ports category */ -static int temp_serial[SERIAL_MAX], temp_parallel[PARALLEL_MAX]; -static char temp_parallel_device[PARALLEL_MAX][16]; +/* Ports category. */ +static int temp_serial[SERIAL_MAX], + temp_parallel[PARALLEL_MAX], + temp_parallel_device[PARALLEL_MAX]; -/* Other peripherals category */ +/* Other peripherals category. */ static int temp_hdc_type, temp_scsi_card, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq; static int temp_bugger; -static uint8_t temp_deviceconfig; +/* Floppy drives category. */ +static int temp_fdd_types[FDD_NUM], + temp_fdd_turbo[FDD_NUM], + temp_fdd_check_bpb[FDD_NUM]; -/* Hard disks category */ +/* Hard disks category. */ static hard_disk_t temp_hdd[HDD_NUM]; -/* Floppy drives category */ -static int temp_fdd_types[FDD_NUM]; -static int temp_fdd_turbo[FDD_NUM]; -static int temp_fdd_check_bpb[FDD_NUM]; - -/* Other removable devices category */ +/* Other removable devices category. */ static cdrom_drive_t temp_cdrom_drives[CDROM_NUM]; static zip_drive_t temp_zip_drives[ZIP_NUM]; -static HWND hwndParentDialog, hwndChildDialog; -static int displayed_category = 0; -static int ask_sure = 0; - -static int romstolist[ROM_MAX], listtomachine[ROM_MAX], romstomachine[ROM_MAX], machinetolist[ROM_MAX]; -static int settings_sound_to_list[20], settings_list_to_sound[20]; -static int settings_midi_to_list[20], settings_list_to_midi[20]; -static int settings_mouse_to_list[20], settings_list_to_mouse[20]; -static int settings_scsi_to_list[20], settings_list_to_scsi[20]; -static int settings_network_to_list[20], settings_list_to_network[20]; - -static uint64_t mfm_tracking, esdi_tracking, xtide_tracking, - ide_tracking, scsi_tracking[16]; +static HWND hwndParentDialog, + hwndChildDialog; +static int displayed_category = 0; +static int ask_sure = 0; +static uint8_t temp_deviceconfig; /* Show a MessageBox dialog. This is nasty, I know. --FvK */ @@ -155,6 +148,19 @@ settings_msgbox(int type, void *arg) } +/* Load the per-page dialogs. */ +#include "win_settings_machine.h" /* Machine dialog */ +#include "win_settings_video.h" /* Video dialog */ +#include "win_settings_input.h" /* Input dialog */ +#include "win_settings_sound.h" /* Sound dialog */ +#include "win_settings_ports.h" /* Ports dialog */ +#include "win_settings_periph.h" /* Other Peripherals dialog */ +#include "win_settings_network.h" /* Network dialog */ +#include "win_settings_floppy.h" /* Floppy dialog */ +#include "win_settings_disk.h" /* (Hard) Disk dialog */ +#include "win_settings_remov.h" /* Removable Devices dialog */ + + /* This does the initial read of global variables into the temporary ones. */ static void settings_init(void) @@ -186,9 +192,7 @@ settings_init(void) temp_sound_card = sound_card_current; temp_midi_device = midi_device_current; temp_mpu401 = mpu401_standalone_enable; - temp_SSI2001 = SSI2001; temp_GAMEBLASTER = GAMEBLASTER; - temp_GUS = GUS; temp_opl3_type = opl3_type; temp_float = sound_is_float; @@ -203,7 +207,7 @@ settings_init(void) temp_serial[i] = serial_enabled[i]; for (i = 0; i < PARALLEL_MAX; i++) { temp_parallel[i] = parallel_enabled[i]; - strcpy(temp_parallel_device[i], parallel_device[i]); + temp_parallel_device[i] = parallel_device[i]; } /* Other peripherals category */ @@ -215,29 +219,6 @@ settings_init(void) temp_ide_qua_irq = ide_irq[3]; temp_bugger = bugger_enabled; - mfm_tracking = xtide_tracking = esdi_tracking = ide_tracking = 0; - for (i = 0; i < 16; i++) - scsi_tracking[i] = 0; - - /* Hard disks category */ - memcpy(temp_hdd, hdd, HDD_NUM * sizeof(hard_disk_t)); - for (i=0; i * Miran Grca, @@ -43,23 +43,54 @@ ************************************************************************/ /* Global variables needed for the Hard Disk dialogs. */ +static uint64_t mfm_tracking, esdi_tracking, xtide_tracking, + ide_tracking, scsi_tracking[16]; static hard_disk_t *hdd_ptr; -static wchar_t hd_file_name[512]; -static int hard_disk_added = 0; -static int max_spt = 63; -static int max_hpc = 255; -static int max_tracks = 266305; -static int no_update = 0; -static int existing = 0; -static uint64_t selection = 127; -static uint64_t spt, hpc, tracks, size; -static int chs_enabled = 0; -static int ignore_change = 0; -static int hdc_id_to_listview_index[HDD_NUM]; static hard_disk_t new_hdd; -static int hd_listview_items; -static int hdlv_current_sel; -static int next_free_id = 0; +static wchar_t hd_file_name[512]; +static int hard_disk_added = 0; +static int max_spt = 63; +static int max_hpc = 255; +static int max_tracks = 266305; +static int no_update = 0; +static int existing = 0; +static uint64_t selection = 127; +static uint64_t spt, hpc, tracks, size; +static int chs_enabled = 0; +static int ignore_change = 0; +static int hdc_id_to_listview_index[HDD_NUM]; +static int hd_listview_items; +static int hdlv_current_sel; +static int next_free_id = 0; + + +static void +disk_track_init(void) +{ + int i; + + mfm_tracking = xtide_tracking = esdi_tracking = ide_tracking = 0; + for (i = 0; i < 16; i++) + scsi_tracking[i] = 0; + + for (i=0; i * Miran Grca, @@ -42,6 +42,10 @@ * * ************************************************************************/ +static int mouse_to_list[20], + list_to_mouse[20]; + + static int mouse_valid(int num, int m) { @@ -74,19 +78,19 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) h = GetDlgItem(hdlg, IDC_COMBO_MOUSE); d = 0; for (c = 0; c < mouse_get_ndev(); c++) { - settings_mouse_to_list[c] = d; + mouse_to_list[c] = d; if (mouse_valid(c, temp_machine)) { stransi = mouse_get_name(c); mbstowcs(temp, stransi, sizeof_w(temp)); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); - settings_list_to_mouse[d] = c; + list_to_mouse[d] = c; d++; } } - SendMessage(h, CB_SETCURSEL, settings_mouse_to_list[temp_mouse], 0); + SendMessage(h, CB_SETCURSEL, mouse_to_list[temp_mouse], 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_MOUSE); if (mouse_has_config(temp_mouse)) @@ -119,7 +123,7 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDC_COMBO_MOUSE: h = GetDlgItem(hdlg, IDC_COMBO_MOUSE); - temp_mouse = settings_list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_mouse = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_MOUSE); if (mouse_has_config(temp_mouse)) @@ -130,7 +134,7 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_MOUSE: h = GetDlgItem(hdlg, IDC_COMBO_MOUSE); - temp_mouse = settings_list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_mouse = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; temp_deviceconfig |= deviceconfig_open(hdlg, (void *)mouse_get_device(temp_mouse)); break; @@ -176,7 +180,7 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_SAVESETTINGS: h = GetDlgItem(hdlg, IDC_COMBO_MOUSE); - temp_mouse = settings_list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_mouse = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_COMBO_JOYSTICK); temp_joystick = SendMessage(h, CB_GETCURSEL, 0, 0); diff --git a/src/win/win_settings_machine.h b/src/win/win_settings_machine.h index 4554043..85ac430 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.1 2018/04/05 + * Version: @(#)win_settings_machine.h 1.0.2 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,6 +42,11 @@ * * ************************************************************************/ +static int romstolist[ROM_MAX], + romstomachine[ROM_MAX], + machinetolist[ROM_MAX], listtomachine[ROM_MAX]; + + static void machine_recalc_cpu(HWND hdlg) { diff --git a/src/win/win_settings_network.h b/src/win/win_settings_network.h index 5217bd2..7729fa3 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.1 2018/04/05 + * Version: @(#)win_settings_network.h 1.0.2 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,7 +43,10 @@ ************************************************************************/ /* Global variables for the Network dialog. */ -static int net_ignore_message = 0; +static int nic_to_list[20], + list_to_nic[20]; +static int net_ignore_message = 0; + static void network_recalc_combos(HWND hdlg) @@ -123,19 +126,19 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (stransi == NULL) break; - settings_network_to_list[c] = d; + nic_to_list[c] = d; if (network_card_available(c) && device_is_valid(network_card_getdevice(c), machines[temp_machine].flags)) { mbstowcs(temp, stransi, sizeof_w(temp)); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); - settings_list_to_network[d] = c; + list_to_nic[d] = c; d++; } c++; } - SendMessage(h, CB_SETCURSEL, settings_network_to_list[temp_net_card], 0); + SendMessage(h, CB_SETCURSEL, nic_to_list[temp_net_card], 0); EnableWindow(h, d ? TRUE : FALSE); network_recalc_combos(hdlg); @@ -169,7 +172,7 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; h = GetDlgItem(hdlg, IDC_COMBO_NET); - temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_net_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; network_recalc_combos(hdlg); break; @@ -179,7 +182,7 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; h = GetDlgItem(hdlg, IDC_COMBO_NET); - temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_net_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; temp_deviceconfig |= deviceconfig_open(hdlg, (void *)network_card_getdevice(temp_net_card)); break; @@ -195,7 +198,7 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) strcpy(temp_host_dev, network_devs[SendMessage(h, CB_GETCURSEL, 0, 0)].device); h = GetDlgItem(hdlg, IDC_COMBO_NET); - temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_net_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; return FALSE; default: diff --git a/src/win/win_settings_periph.h b/src/win/win_settings_periph.h index 8ce84f4..f1c58c9 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.1 2018/04/05 + * Version: @(#)win_settings_periph.h 1.0.2 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,7 +42,9 @@ * * ************************************************************************/ -static char *hdc_names[16]; +static int scsi_to_list[20], + list_to_scsi[20]; +static char *hdc_names[16]; static const int valid_ide_irqs[11] = { 2, 3, 4, 5, 7, 9, 10, 11, 12, 14, 15 }; @@ -142,7 +144,7 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (! *stransi) break; - settings_scsi_to_list[c] = d; + scsi_to_list[c] = d; if (scsi_card_available(c)) { dev = scsi_card_getdevice(c); @@ -153,14 +155,14 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) mbstowcs(temp, stransi, sizeof_w(temp)); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); } - settings_list_to_scsi[d] = c; + list_to_scsi[d] = c; d++; } } c++; } - SendMessage(h, CB_SETCURSEL, settings_scsi_to_list[temp_scsi_card], 0); + SendMessage(h, CB_SETCURSEL, scsi_to_list[temp_scsi_card], 0); EnableWindow(h, d ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_SCSI); @@ -202,14 +204,14 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDC_CONFIGURE_SCSI: h = GetDlgItem(hdlg, IDC_COMBO_SCSI); - temp_scsi_card = settings_list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_scsi_card = list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; temp_deviceconfig |= deviceconfig_open(hdlg, (void *)scsi_card_getdevice(temp_scsi_card)); break; case IDC_COMBO_SCSI: h = GetDlgItem(hdlg, IDC_COMBO_SCSI); - temp_scsi_card = settings_list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_scsi_card = list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_SCSI); if (scsi_card_has_config(temp_scsi_card)) @@ -229,7 +231,7 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) temp_hdc_type = 0; h = GetDlgItem(hdlg, IDC_COMBO_SCSI); - temp_scsi_card = settings_list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_scsi_card = list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_COMBO_IDE_TER); temp_ide_ter = SendMessage(h, CB_GETCURSEL, 0, 0); diff --git a/src/win/win_settings_ports.h b/src/win/win_settings_ports.h index 81bb8ea..88d2775 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.1 2018/04/05 + * Version: @(#)win_settings_ports.h 1.0.2 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -68,9 +68,9 @@ ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) mbstowcs(temp, stransi, sizeof_w(temp)); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); - if (! strcmp(temp_parallel_device[i], parallel_device_get_internal_name(c))) + /* Currently selected device? */ + if (temp_parallel_device[i] == c) d = c; - c++; } SendMessage(h, CB_SETCURSEL, d, 0); @@ -112,7 +112,7 @@ ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) h = GetDlgItem(hdlg, IDC_COMBO_PARALLEL1+i); c = SendMessage(h, CB_GETCURSEL, 0, 0); - strcpy(temp_parallel_device[i], parallel_device_get_internal_name(c)); + temp_parallel_device[i] = c; } for (i = 0; i < SERIAL_MAX; i++) { diff --git a/src/win/win_settings_remov.h b/src/win/win_settings_remov.h index 7a0c3c1..7c25fa4 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.1 2018/04/05 + * Version: @(#)win_settings_remov.h 1.0.2 2018/04/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -47,6 +47,23 @@ static int rd_ignore_change = 0; static int cdlv_current_sel; static int zdlv_current_sel; + +static void +cdrom_track_init(void) +{ + int i; + + for (i=0; i * Miran Grca, @@ -42,6 +42,10 @@ * * ************************************************************************/ +static int sound_to_list[20], list_to_sound[20]; +static int midi_to_list[20], list_to_midi[20]; + + static int mpu401_present(void) { @@ -100,21 +104,21 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (stransi == NULL) break; - settings_sound_to_list[c] = d; + sound_to_list[c] = d; if (sound_card_available(c)) { dev = sound_card_getdevice(c); if (device_is_valid(dev, machines[temp_machine].flags)) { mbstowcs(temp, stransi, sizeof_w(temp)); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); - settings_list_to_sound[d] = c; + list_to_sound[d] = c; d++; } } c++; } - SendMessage(h, CB_SETCURSEL, settings_sound_to_list[temp_sound_card], 0); + SendMessage(h, CB_SETCURSEL, sound_to_list[temp_sound_card], 0); EnableWindow(h, d ? TRUE : FALSE); @@ -131,19 +135,19 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (stransi == NULL) break; - settings_midi_to_list[c] = d; + midi_to_list[c] = d; if (midi_device_available(c)) { mbstowcs(temp, stransi, sizeof_w(temp)); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); - settings_list_to_midi[d] = c; + list_to_midi[d] = c; d++; } c++; } - SendMessage(h, CB_SETCURSEL, settings_midi_to_list[temp_midi_device], 0); + SendMessage(h, CB_SETCURSEL, midi_to_list[temp_midi_device], 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_MIDI); if (midi_device_has_config(temp_midi_device)) @@ -161,12 +165,6 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) h = GetDlgItem(hdlg, IDC_CHECK_CMS); SendMessage(h, BM_SETCHECK, temp_GAMEBLASTER, 0); - h = GetDlgItem(hdlg, IDC_CHECK_GUS); - SendMessage(h, BM_SETCHECK, temp_GUS, 0); - - h = GetDlgItem(hdlg, IDC_CHECK_SSI); - SendMessage(h, BM_SETCHECK, temp_SSI2001, 0); - h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL); SendMessage(h, BM_SETCHECK, temp_opl3_type, 0); @@ -179,7 +177,7 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDC_COMBO_SOUND: h = GetDlgItem(hdlg, IDC_COMBO_SOUND); - temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_SND); if (sound_card_has_config(temp_sound_card)) @@ -197,14 +195,14 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_SND: h = GetDlgItem(hdlg, IDC_COMBO_SOUND); - temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; temp_deviceconfig |= deviceconfig_open(hdlg, (void *)sound_card_getdevice(temp_sound_card)); break; case IDC_COMBO_MIDI: h = GetDlgItem(hdlg, IDC_COMBO_MIDI); - temp_midi_device = settings_list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_MIDI); if (midi_device_has_config(temp_midi_device)) @@ -222,7 +220,7 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_MIDI: h = GetDlgItem(hdlg, IDC_COMBO_MIDI); - temp_midi_device = settings_list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; temp_deviceconfig |= deviceconfig_open(hdlg, (void *)midi_device_getdevice(temp_midi_device)); break; @@ -243,10 +241,10 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_SAVESETTINGS: h = GetDlgItem(hdlg, IDC_COMBO_SOUND); - temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_COMBO_MIDI); - temp_midi_device = settings_list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CHECK_MPU401); temp_mpu401 = SendMessage(h, BM_GETCHECK, 0, 0); @@ -254,12 +252,6 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) h = GetDlgItem(hdlg, IDC_CHECK_CMS); temp_GAMEBLASTER = SendMessage(h, BM_GETCHECK, 0, 0); - h = GetDlgItem(hdlg, IDC_CHECK_GUS); - temp_GUS = SendMessage(h, BM_GETCHECK, 0, 0); - - h = GetDlgItem(hdlg, IDC_CHECK_SSI); - temp_SSI2001 = SendMessage(h, BM_GETCHECK, 0, 0); - h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL); temp_opl3_type = SendMessage(h, BM_GETCHECK, 0, 0); diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 26dde3e..06a0ef7 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.6 2018/04/05 + * Version: @(#)win_stbar.c 1.0.7 2018/04/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1059,7 +1059,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 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_thread_reset(); + sound_cd_stop(); break; case IDM_CDROM_EMPTY: