diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 55177f6a7..faa8deb80 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -276,7 +276,9 @@ SNDOBJ = sound.o \ wave8580_PST.o wave.o \ midi.o $(FSYNTHOBJ) $(MUNTOBJ) \ midi_system.o \ - snd_speaker.o snd_ps1.o snd_pssj.o \ + snd_speaker.o \ + snd_ps1.o snd_pssj.o \ + snd_lpt_dac.o snd_lpt_dss.o \ snd_adlib.o snd_adlibgold.o snd_ad1848.o \ snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \ snd_emu8k.o snd_gus.o snd_opl.o \ @@ -478,7 +480,7 @@ keyboard_pcjr.o: ibm.h io.h mem.h nmi.h pic.h pit.h timer.h \ keyboard_xt.o: ibm.h io.h mem.h pic.h pit.h timer.h device.h tandy_eeprom.h \ sound/sound.h sound/snd_speaker.h keyboard.h keyboard_xt.h -lpt.o: ibm.h io.h lpt.h +lpt.o: ibm.h io.h lpt.h sound/snd_lpt_dac.h sound/snd_lpt_dss.h mca.o: ibm.h io.h mem.h mca.h @@ -766,6 +768,10 @@ snd_emu8k.o: ibm.h io.h mem.h rom.h timer.h device.h sound/sound.h sound/snd_em snd_gus.o: ibm.h io.h pic.h dma.h timer.h device.h sound/sound.h sound/snd_gus.h +snd_lpt_dac.o: ibm.h cpu/cpu.h sound/filters.h lpt.h sound/snd_lpt_dac.h sound/sound.h timer.h + +snd_lpt_dss.o: ibm.h cpu/cpu.h sound/filters.h lpt.h sound/snd_lpt_dss.h sound/sound.h timer.h + snd_mpu401.o: ibm.h device.h io.h pic.h timer.h sound/midi.h sound/sound.h sound/snd_mpu401.h snd_opl.o: ibm.h io.h timer.h sound/sound.h sound/snd_opl.h sound/snd_dbopl.h diff --git a/src/config.c b/src/config.c index d81a989ef..00fd3ce07 100644 --- a/src/config.c +++ b/src/config.c @@ -34,6 +34,7 @@ #include "disc.h" #include "fdc.h" #include "fdd.h" +#include "lpt.h" #include "ibm.h" #include "cpu/cpu.h" #include "gameport.h" @@ -1134,6 +1135,24 @@ static void loadconfig_network(void) #endif +/* Ports (COM & LPT) */ +static void loadconfig_ports(void) +{ + char *cat = "Ports (COM & LPT)"; + char *p; + + serial_enabled[0] = !!config_get_int(cat, "serial1_enabled", 1); + serial_enabled[1] = !!config_get_int(cat, "serial2_enabled", 1); + lpt_enabled = !!config_get_int(cat, "lpt_enabled", 1); + + p = (char *)config_get_string(cat, "lpt1_device", "none"); + if (p != NULL) + strcpy(lpt1_device_name, p); + else + strcpy(lpt1_device_name, "none"); +} + + /* Other peripherals */ static void loadconfig_other_peripherals(void) { @@ -1166,8 +1185,11 @@ static void loadconfig_other_peripherals(void) } serial_enabled[0] = !!config_get_int(cat, "serial1_enabled", 1); + config_delete_var(cat, "serial1_enabled"); serial_enabled[1] = !!config_get_int(cat, "serial2_enabled", 1); + config_delete_var(cat, "serial2_enabled"); lpt_enabled = !!config_get_int(cat, "lpt_enabled", 1); + config_delete_var(cat, "lpt_enabled"); bugger_enabled = !!config_get_int(cat, "bugger_enabled", 0); } @@ -1749,6 +1771,9 @@ void loadconfig(wchar_t *fn) loadconfig_network(); #endif + /* Ports (COM & LPT) */ + loadconfig_ports(); + /* Other peripherals */ loadconfig_other_peripherals(); @@ -2212,6 +2237,51 @@ static void saveconfig_network(void) #endif +/* Ports (COM & LPT) */ +static void saveconfig_ports(void) +{ + char *cat = "Ports (COM & LPT)"; + + if (serial_enabled[0]) + { + config_delete_var(cat, "serial1_enabled"); + } + else + { + config_set_int(cat, "serial1_enabled", serial_enabled[0]); + } + + if (serial_enabled[1]) + { + config_delete_var(cat, "serial2_enabled"); + } + else + { + config_set_int(cat, "serial2_enabled", serial_enabled[1]); + } + + if (lpt_enabled) + { + config_delete_var(cat, "lpt_enabled"); + } + else + { + config_set_int(cat, "lpt_enabled", lpt_enabled); + } + + if (!strcmp(lpt1_device_name, "none")) + { + config_delete_var(cat, "lpt1_device"); + } + else + { + config_set_string(cat, "lpt1_device", lpt1_device_name); + } + + config_delete_section_if_empty(cat); +} + + /* Other peripherals */ static void saveconfig_other_peripherals(void) { @@ -2254,33 +2324,6 @@ static void saveconfig_other_peripherals(void) } } - if (serial_enabled[0]) - { - config_delete_var(cat, "serial1_enabled"); - } - else - { - config_set_int(cat, "serial1_enabled", serial_enabled[0]); - } - - if (serial_enabled[1]) - { - config_delete_var(cat, "serial2_enabled"); - } - else - { - config_set_int(cat, "serial2_enabled", serial_enabled[1]); - } - - if (lpt_enabled) - { - config_delete_var(cat, "lpt_enabled"); - } - else - { - config_set_int(cat, "lpt_enabled", lpt_enabled); - } - if (bugger_enabled == 0) { config_delete_var(cat, "bugger_enabled"); @@ -2570,6 +2613,9 @@ void saveconfig(void) saveconfig_network(); #endif + /* Ports (COM & LPT) */ + saveconfig_ports(); + /* Other peripherals */ saveconfig_other_peripherals(); diff --git a/src/cpu/386.c b/src/cpu/386.c index 9cab89b54..07064f906 100644 --- a/src/cpu/386.c +++ b/src/cpu/386.c @@ -231,12 +231,13 @@ void exec386(int cycs) int tempi; int cycdiff; int oldcyc; - int cycle_period = cycs / 2000; /*Use a 5us timing granularity*/ cycles+=cycs; /* output=3; */ while (cycles>0) { + int cycle_period = (timer_count >> TIMER_SHIFT) + 1; + cycdiff=0; oldcyc=cycles; timer_start_period(cycles << TIMER_SHIFT); diff --git a/src/lpt.c b/src/lpt.c index 736784981..459346bf0 100644 --- a/src/lpt.c +++ b/src/lpt.c @@ -3,21 +3,82 @@ */ #include "ibm.h" #include "io.h" -#include "lpt.h" +#include "lpt.h" +#include "sound/snd_lpt_dac.h" +#include "sound/snd_lpt_dss.h" + +char lpt1_device_name[16]; + +static struct +{ + char name[64]; + char internal_name[16]; + lpt_device_t *device; +} lpt_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} +}; + +char *lpt_device_get_name(int id) +{ + if (strlen(lpt_devices[id].name) == 0) + return NULL; + return lpt_devices[id].name; +} +char *lpt_device_get_internal_name(int id) +{ + if (strlen(lpt_devices[id].internal_name) == 0) + return NULL; + return lpt_devices[id].internal_name; +} + +static lpt_device_t *lpt1_device; +static void *lpt1_device_p; + +void lpt1_device_init() +{ + int c = 0; + + while (strcmp(lpt_devices[c].internal_name, lpt1_device_name) && strlen(lpt_devices[c].internal_name) != 0) + c++; + + if (strlen(lpt_devices[c].internal_name) == 0) + lpt1_device = NULL; + else + { + lpt1_device = lpt_devices[c].device; + if (lpt1_device) + lpt1_device_p = lpt1_device->init(); + } +} + +void lpt1_device_close() +{ + if (lpt1_device) + lpt1_device->close(lpt1_device_p); + lpt1_device = NULL; +} static uint8_t lpt1_dat, lpt2_dat, lpt3_dat; static uint8_t lpt1_ctrl, lpt2_ctrl, lpt3_ctrl; - void lpt1_write(uint16_t port, uint8_t val, void *priv) { switch (port & 3) { case 0: + if (lpt1_device) + lpt1_device->write_data(val, lpt1_device_p); lpt1_dat = val; break; case 2: + if (lpt1_device) + lpt1_device->write_ctrl(val, lpt1_device_p); lpt1_ctrl = val; break; } @@ -28,6 +89,10 @@ uint8_t lpt1_read(uint16_t port, void *priv) { case 0: return lpt1_dat; + case 1: + if (lpt1_device) + return lpt1_device->read_status(lpt1_device_p); + return 0; case 2: return lpt1_ctrl; } @@ -52,6 +117,8 @@ uint8_t lpt2_read(uint16_t port, void *priv) { case 0: return lpt2_dat; + case 1: + return 0; case 2: return lpt2_ctrl; } @@ -76,6 +143,8 @@ uint8_t lpt3_read(uint16_t port, void *priv) { case 0: return lpt3_dat; + case 1: + return 0; case 2: return lpt3_ctrl; } diff --git a/src/lpt.h b/src/lpt.h index 0568f55fd..c5e59b962 100644 --- a/src/lpt.h +++ b/src/lpt.h @@ -1,11 +1,26 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -extern void lpt_init(void); +extern void lpt_init(); extern void lpt1_init(uint16_t port); -extern void lpt1_remove(void); +extern void lpt1_remove(); extern void lpt2_init(uint16_t port); -extern void lpt2_remove(void); -extern void lpt2_remove_ams(void); +extern void lpt2_remove(); +extern void lpt2_remove_ams(); extern void lpt3_init(uint16_t port); -extern void lpt3_remove(void); +extern void lpt3_remove(); + +void lpt1_device_init(); +void lpt1_device_close(); + +char *lpt_device_get_name(int id); +char *lpt_device_get_internal_name(int id); + +extern char lpt1_device_name[16]; + +typedef struct +{ + char name[80]; + void *(*init)(); + void (*close)(void *p); + void (*write_data)(uint8_t val, void *p); + void (*write_ctrl)(uint8_t val, void *p); + uint8_t (*read_status)(void *p); +} lpt_device_t; diff --git a/src/pc.c b/src/pc.c index 04e98fd64..bcf3c8244 100644 --- a/src/pc.c +++ b/src/pc.c @@ -18,20 +18,15 @@ #include #include #include + #include "86box.h" #include "ibm.h" -#include "mem.h" -#include "cpu/cpu.h" -#include "cpu/x86_ops.h" -#include "cpu/codegen.h" -#include "dma.h" -#include "nvr.h" -#include "pic.h" -#include "pit.h" -#include "timer.h" -#include "device.h" -#include "machine/machine.h" +#include "mem.h" +#include "cpu/codegen.h" +#include "cpu/cpu.h" +#include "dma.h" +#include "device.h" #include "disc.h" #include "disc_86f.h" #include "disc_fdi.h" @@ -39,33 +34,38 @@ #include "disc_img.h" #include "disc_td0.h" #include "disc_random.h" +#include "cdrom.h" +#include "cdrom_image.h" +#include "cdrom_ioctl.h" +#include "cdrom_null.h" #include "config.h" #include "fdc.h" #include "fdd.h" #include "gameport.h" #include "hdd/hdd.h" #include "hdd/hdd_ide_at.h" -#include "cdrom.h" -#include "cdrom_ioctl.h" -#include "cdrom_image.h" -#include "cdrom_null.h" #include "keyboard.h" #include "keyboard_at.h" +#include "lpt.h" +#include "machine/machine.h" #include "sound/midi.h" #include "mouse.h" #ifdef USE_NETWORK #include "network/network.h" #endif +#include "nvr.h" +#include "pic.h" +#include "pit.h" #ifdef WALTJE # define UNICODE -# include "plat_dir.h" +# include "win/plat_dir.h" # undef UNICODE #endif -#include "plat_joystick.h" -#include "plat_keyboard.h" -#include "plat_midi.h" -#include "plat_mouse.h" -#include "plat_ui.h" +#include "win/plat_joystick.h" +#include "win/plat_keyboard.h" +#include "win/plat_midi.h" +#include "win/plat_mouse.h" +#include "win/plat_ui.h" #include "scsi/scsi.h" #include "serial.h" #include "sound/sound.h" @@ -77,8 +77,10 @@ #include "sound/snd_sb.h" #include "sound/snd_speaker.h" #include "sound/snd_ssi2001.h" +#include "timer.h" #include "video/video.h" #include "video/vid_voodoo.h" +#include "cpu/x86_ops.h" wchar_t pcempath[512]; @@ -519,7 +521,8 @@ void resetpchard_init(void) #endif machine_init(); video_init(); - speaker_init(); + speaker_init(); + lpt1_device_init(); ide_ter_disable(); ide_qua_disable(); @@ -719,6 +722,7 @@ void closepc(void) } dumpregs(0); closevideo(); + lpt1_device_close(); device_close_all(); midi_close(); #ifdef USE_NETWORK diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index 9bdfc9202..1b83a6ca2 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -784,7 +784,6 @@ aha_mbi(aha_t *dev) RaiseIntr(dev, 0, INTR_MBIF | INTR_ANY); while (dev->Interrupt) { - thread_wait_event(dev->evt, 10); } } @@ -1118,6 +1117,10 @@ aha_scsi_cmd(aha_t *dev) aha_mbi_setup(dev, req->CCBPointer, &req->CmdBlock, CCB_COMPLETE, SCSI_STATUS_CHECK_CONDITION, MBI_ERROR); } + + if (temp_cdb[0] == 0x42) { + thread_wait_event(dev->evt, 10); + } } @@ -1259,7 +1262,6 @@ aha_do_mail(aha_t *dev) RaiseIntr(dev, 0, INTR_MBOA | INTR_ANY); while (dev->Interrupt) { - thread_wait_event(dev->evt, 10); } } @@ -1289,7 +1291,6 @@ aha_event_restart: aha_scan_restart: while (aha_do_mail(dev) && dev->MailboxCount) { - thread_wait_event(dev->evt, 10); } if (!dev->MailboxCount) diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 03baeeaf3..4a25d2420 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -937,7 +937,6 @@ BuslogicMailboxIn(Buslogic_t *bl) BuslogicRaiseInterrupt(bl, 0, INTR_MBIF | INTR_ANY); while (bl->Interrupt) { - thread_wait_event(bl->evt, 10); } } @@ -2354,6 +2353,10 @@ BuslogicSCSICommand(Buslogic_t *bl) BuslogicMailboxInSetup(bl, req->CCBPointer, &req->CmdBlock, CCB_COMPLETE, SCSI_STATUS_CHECK_CONDITION, MBI_ERROR); } + + if (temp_cdb[0] == 0x42) { + thread_wait_event(bl->evt, 10); + } } @@ -2520,7 +2523,6 @@ BuslogicProcessMailbox(Buslogic_t *bl) BuslogicRaiseInterrupt(bl, 0, INTR_MBOA | INTR_ANY); while (bl->Interrupt) { - thread_wait_event(bl->evt, 10); } } @@ -2570,7 +2572,6 @@ BuslogicEventRestart: BuslogicScanRestart: while (BuslogicProcessMailbox(bl) && bl->MailboxCount) { - thread_wait_event(bl->evt, 10); } if (!bl->MailboxCount) diff --git a/src/sound/filters.h b/src/sound/filters.h index 528bf0b05..bf98aec1f 100644 --- a/src/sound/filters.h +++ b/src/sound/filters.h @@ -1,9 +1,7 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ #define NCoef 2 -static __inline float low_iir(int i, float NewSample) { +/* fc=350Hz */ +static inline float low_iir(int i, float NewSample) { float ACoef[NCoef+1] = { 0.00049713569693400649, 0.00099427139386801299, @@ -35,7 +33,8 @@ static __inline float low_iir(int i, float NewSample) { return y[i][0]; } -static __inline float low_cut_iir(int i, float NewSample) { +/* fc=350Hz */ +static inline float low_cut_iir(int i, float NewSample) { float ACoef[NCoef+1] = { 0.96839970114733542000, -1.93679940229467080000, @@ -67,7 +66,8 @@ static __inline float low_cut_iir(int i, float NewSample) { return y[i][0]; } -static __inline float high_iir(int i, float NewSample) { +/* fc=3.5kHz */ +static inline float high_iir(int i, float NewSample) { float ACoef[NCoef+1] = { 0.72248704753064896000, -1.44497409506129790000, @@ -98,7 +98,8 @@ static __inline float high_iir(int i, float NewSample) { return y[i][0]; } -static __inline float high_cut_iir(int i, float NewSample) { +/* fc=3.5kHz */ +static inline float high_cut_iir(int i, float NewSample) { float ACoef[NCoef+1] = { 0.03927726802250377400, 0.07855453604500754700, @@ -133,7 +134,8 @@ static __inline float high_cut_iir(int i, float NewSample) { #undef NCoef #define NCoef 2 -static __inline float sb_iir(int i, float NewSample) { +/* fc=3.2kHz */ +static inline float sb_iir(int i, float NewSample) { float ACoef[NCoef+1] = { 0.03356837051492005100, 0.06713674102984010200, @@ -155,7 +157,6 @@ static __inline float sb_iir(int i, float NewSample) { 1.00000000000000000000, -0.64940759319751051000 };*/ - static float y[2][NCoef+1]; /* output samples */ static float x[2][NCoef+1]; /* input samples */ int n; @@ -180,7 +181,8 @@ static __inline float sb_iir(int i, float NewSample) { #undef NCoef #define NCoef 2 -static __inline float adgold_highpass_iir(int i, float NewSample) { +/* fc=150Hz */ +static inline float adgold_highpass_iir(int i, float NewSample) { float ACoef[NCoef+1] = { 0.98657437157334349000, -1.97314874314668700000, @@ -212,7 +214,8 @@ static __inline float adgold_highpass_iir(int i, float NewSample) { return y[i][0]; } -static __inline float adgold_lowpass_iir(int i, float NewSample) { +/* fc=150Hz */ +static inline float adgold_lowpass_iir(int i, float NewSample) { float ACoef[NCoef+1] = { 0.00009159473951071446, 0.00018318947902142891, @@ -244,7 +247,8 @@ static __inline float adgold_lowpass_iir(int i, float NewSample) { return y[i][0]; } -static __inline float adgold_pseudo_stereo_iir(float NewSample) { +/* fc=56Hz */ +static inline float adgold_pseudo_stereo_iir(float NewSample) { float ACoef[NCoef+1] = { 0.00001409030866231767, 0.00002818061732463533, @@ -275,3 +279,69 @@ static __inline float adgold_pseudo_stereo_iir(float NewSample) { return y[0]; } + +/* fc=3.2kHz - probably incorrect */ +static inline float dss_iir(float NewSample) { + float ACoef[NCoef+1] = { + 0.03356837051492005100, + 0.06713674102984010200, + 0.03356837051492005100 + }; + + float BCoef[NCoef+1] = { + 1.00000000000000000000, + -1.41898265221812010000, + 0.55326988968868285000 + }; + + static float y[NCoef+1]; /* output samples */ + static float x[NCoef+1]; /* input samples */ + int n; + + /* shift the old samples */ + for(n=NCoef; n>0; n--) { + x[n] = x[n-1]; + y[n] = y[n-1]; + } + + /* Calculate the new output */ + x[0] = NewSample; + y[0] = ACoef[0] * x[0]; + for(n=1; n<=NCoef; n++) + y[0] += ACoef[n] * x[n] - BCoef[n] * y[n]; + + return y[0]; +} + +#undef NCoef +#define NCoef 1 +/*Basic high pass to remove DC bias. fc=10Hz*/ +static inline float dac_iir(int i, float NewSample) { + float ACoef[NCoef+1] = { + 0.99901119820285345000, + -0.99901119820285345000 + }; + + float BCoef[NCoef+1] = { + 1.00000000000000000000, + -0.99869185905052738000 + }; + + static float y[2][NCoef+1]; /* output samples */ + static float x[2][NCoef+1]; /* input samples */ + int n; + + /* shift the old samples */ + for(n=NCoef; n>0; n--) { + x[i][n] = x[i][n-1]; + y[i][n] = y[i][n-1]; + } + + /* Calculate the new output */ + x[i][0] = NewSample; + y[i][0] = ACoef[0] * x[i][0]; + for(n=1; n<=NCoef; n++) + y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n]; + + return y[i][0]; +} diff --git a/src/sound/snd_lpt_dac.c b/src/sound/snd_lpt_dac.c new file mode 100644 index 000000000..de34fc5f2 --- /dev/null +++ b/src/sound/snd_lpt_dac.c @@ -0,0 +1,119 @@ +#include +#include "../ibm.h" +#include "../cpu/cpu.h" +#include "filters.h" +#include "../lpt.h" +#include "snd_lpt_dac.h" +#include "sound.h" +#include "../timer.h" + +typedef struct lpt_dac_t +{ + uint8_t dac_val_l, dac_val_r; + + int is_stereo; + int channel; + + int16_t buffer[2][SOUNDBUFLEN]; + int pos; +} lpt_dac_t; + +static void dac_update(lpt_dac_t *lpt_dac) +{ + for (; lpt_dac->pos < sound_pos_global; lpt_dac->pos++) + { + lpt_dac->buffer[0][lpt_dac->pos] = (int8_t)(lpt_dac->dac_val_l ^ 0x80) * 0x40; + lpt_dac->buffer[1][lpt_dac->pos] = (int8_t)(lpt_dac->dac_val_r ^ 0x80) * 0x40; + } +} + + +static void dac_write_data(uint8_t val, void *p) +{ + lpt_dac_t *lpt_dac = (lpt_dac_t *)p; + + timer_clock(); + + if (lpt_dac->is_stereo) + { + if (lpt_dac->channel) + lpt_dac->dac_val_r = val; + else + lpt_dac->dac_val_l = val; + } + else + lpt_dac->dac_val_l = lpt_dac->dac_val_r = val; + dac_update(lpt_dac); +} + +static void dac_write_ctrl(uint8_t val, void *p) +{ + lpt_dac_t *lpt_dac = (lpt_dac_t *)p; + + if (lpt_dac->is_stereo) + lpt_dac->channel = val & 0x01; +} + +static uint8_t dac_read_status(void *p) +{ + return 0; +} + + +static void dac_get_buffer(int32_t *buffer, int len, void *p) +{ + lpt_dac_t *lpt_dac = (lpt_dac_t *)p; + int c; + + dac_update(lpt_dac); + + for (c = 0; c < len; c++) + { + buffer[c*2] += dac_iir(0, lpt_dac->buffer[0][c]); + buffer[c*2 + 1] += dac_iir(1, lpt_dac->buffer[1][c]); + } + lpt_dac->pos = 0; +} + +static void *dac_init() +{ + lpt_dac_t *lpt_dac = malloc(sizeof(lpt_dac_t)); + memset(lpt_dac, 0, sizeof(lpt_dac_t)); + + sound_add_handler(dac_get_buffer, lpt_dac); + + return lpt_dac; +} +static void *dac_stereo_init() +{ + lpt_dac_t *lpt_dac = dac_init(); + + lpt_dac->is_stereo = 1; + + return lpt_dac; +} +static void dac_close(void *p) +{ + lpt_dac_t *lpt_dac = (lpt_dac_t *)p; + + free(lpt_dac); +} + +lpt_device_t lpt_dac_device = +{ + "LPT DAC / Covox Speech Thing", + dac_init, + dac_close, + dac_write_data, + dac_write_ctrl, + dac_read_status +}; +lpt_device_t lpt_dac_stereo_device = +{ + "Stereo LPT DAC", + dac_stereo_init, + dac_close, + dac_write_data, + dac_write_ctrl, + dac_read_status +}; diff --git a/src/sound/snd_lpt_dac.h b/src/sound/snd_lpt_dac.h new file mode 100644 index 000000000..7db7a34dd --- /dev/null +++ b/src/sound/snd_lpt_dac.h @@ -0,0 +1,2 @@ +extern lpt_device_t lpt_dac_device; +extern lpt_device_t lpt_dac_stereo_device; diff --git a/src/sound/snd_lpt_dss.c b/src/sound/snd_lpt_dss.c new file mode 100644 index 000000000..245d45548 --- /dev/null +++ b/src/sound/snd_lpt_dss.c @@ -0,0 +1,115 @@ +#include +#include "../ibm.h" +#include "../cpu/cpu.h" +#include "filters.h" +#include "../lpt.h" +#include "snd_lpt_dss.h" +#include "sound.h" +#include "../timer.h" + +typedef struct dss_t +{ + uint8_t fifo[16]; + int read_idx, write_idx; + + uint8_t dac_val; + + int time; + + int16_t buffer[SOUNDBUFLEN]; + int pos; +} dss_t; + +static void dss_update(dss_t *dss) +{ + for (; dss->pos < sound_pos_global; dss->pos++) + dss->buffer[dss->pos] = (int8_t)(dss->dac_val ^ 0x80) * 0x40; +} + + +static void dss_write_data(uint8_t val, void *p) +{ + dss_t *dss = (dss_t *)p; + + timer_clock(); + + if ((dss->write_idx - dss->read_idx) < 16) + { + dss->fifo[dss->write_idx & 15] = val; + dss->write_idx++; + } +} + +static void dss_write_ctrl(uint8_t val, void *p) +{ +} + +static uint8_t dss_read_status(void *p) +{ + dss_t *dss = (dss_t *)p; + + if ((dss->write_idx - dss->read_idx) >= 16) + return 0x40; + return 0; +} + + +static void dss_get_buffer(int32_t *buffer, int len, void *p) +{ + dss_t *dss = (dss_t *)p; + int c; + + dss_update(dss); + + for (c = 0; c < len*2; c += 2) + { + int16_t val = (int16_t)dss_iir((float)dss->buffer[c >> 1]); + + buffer[c] += val; + buffer[c+1] += val; + } + + dss->pos = 0; +} + +static void dss_callback(void *p) +{ + dss_t *dss = (dss_t *)p; + + dss_update(dss); + + if ((dss->write_idx - dss->read_idx) > 0) + { + dss->dac_val = dss->fifo[dss->read_idx & 15]; + dss->read_idx++; + } + + dss->time += (TIMER_USEC * (1000000.0 / 7000.0)); +} + +static void *dss_init() +{ + dss_t *dss = malloc(sizeof(dss_t)); + memset(dss, 0, sizeof(dss_t)); + + sound_add_handler(dss_get_buffer, dss); + timer_add(dss_callback, &dss->time, TIMER_ALWAYS_ENABLED, dss); + + return dss; +} +static void dss_close(void *p) +{ + dss_t *dss = (dss_t *)p; + + free(dss); +} + +lpt_device_t dss_device = +{ + "Disney Sound Source", + dss_init, + dss_close, + dss_write_data, + dss_write_ctrl, + dss_read_status +}; diff --git a/src/sound/snd_lpt_dss.h b/src/sound/snd_lpt_dss.h new file mode 100644 index 000000000..b7d8fcbc1 --- /dev/null +++ b/src/sound/snd_lpt_dss.h @@ -0,0 +1 @@ +extern lpt_device_t dss_device; diff --git a/src/timer.c b/src/timer.c index 212f1b021..2f3a92035 100644 --- a/src/timer.c +++ b/src/timer.c @@ -95,7 +95,7 @@ void timer_update_outstanding(void) if (*timers[c].enable && *timers[c].count < timer_latch) timer_latch = *timers[c].count; } - timer_count = timer_latch = (timer_latch + ((1 << TIMER_SHIFT) - 1)) >> TIMER_SHIFT; + timer_count = timer_latch = (timer_latch + ((1 << TIMER_SHIFT) - 1)); } diff --git a/src/win/86Box.rc b/src/win/86Box.rc index dd38744a7..103f29c78 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -8,7 +8,7 @@ * * Windows resource script. * - * Version: @(#)86Box.rc 1.0.7 2017/08/26 + * Version: @(#)86Box.rc 1.0.8 2017/09/02 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -358,7 +358,24 @@ BEGIN END #endif -DLG_CFG_PERIPHERALS DIALOG DISCARDABLE 97, 0, 267, 115 +DLG_CFG_PORTS DIALOG DISCARDABLE 97, 0, 267, 61 +STYLE DS_CONTROL | WS_CHILD +FONT 9, "Segoe UI" +BEGIN + LTEXT "LPT1 Device:",IDT_1716,7,8,61,10 + COMBOBOX IDC_COMBO_LPT1,71,7,189,120,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + + CONTROL "Serial port 1",IDC_CHECK_SERIAL1,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,26,94,10 + CONTROL "Serial port 2",IDC_CHECK_SERIAL2,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,147,26,94,10 + + CONTROL "Parallel port",IDC_CHECK_PARALLEL,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,44,94,10 +END + +DLG_CFG_PERIPHERALS DIALOG DISCARDABLE 97, 0, 267, 97 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN @@ -379,15 +396,8 @@ BEGIN COMBOBOX IDC_COMBO_IDE_QUA,71,61,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Serial port 1",IDC_CHECK_SERIAL1,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10 - CONTROL "Serial port 2",IDC_CHECK_SERIAL2,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,147,80,94,10 - - CONTROL "Parallel port",IDC_CHECK_PARALLEL,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,98,94,10 CONTROL "ISABugger device",IDC_CHECK_BUGGER,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,147,98,94,10 + BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10 END DLG_CFG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154 @@ -529,13 +539,15 @@ END 259 ICON DISCARDABLE "win/icons/sound.ico" #ifdef USE_NETWORK 260 ICON DISCARDABLE "win/icons/network.ico" +261 ICON DISCARDABLE "win/icons/ports.ico" +262 ICON DISCARDABLE "win/icons/other_peripherals.ico" +263 ICON DISCARDABLE "win/icons/hard_disk.ico" +264 ICON DISCARDABLE "win/icons/removable_devices.ico" +#else +260 ICON DISCARDABLE "win/icons/ports.ico" 261 ICON DISCARDABLE "win/icons/other_peripherals.ico" 262 ICON DISCARDABLE "win/icons/hard_disk.ico" 263 ICON DISCARDABLE "win/icons/removable_devices.ico" -#else -260 ICON DISCARDABLE "win/icons/other_peripherals.ico" -261 ICON DISCARDABLE "win/icons/hard_disk.ico" -262 ICON DISCARDABLE "win/icons/removable_devices.ico" #endif 384 ICON DISCARDABLE "win/icons/floppy_525_empty.ico" 385 ICON DISCARDABLE "win/icons/floppy_525_empty_active.ico" @@ -585,7 +597,7 @@ END #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN - CONFIGUREDLG_MAIN, DIALOG + DLG_CFG_MAIN, DIALOG BEGIN RIGHTMARGIN, 365 END @@ -595,7 +607,7 @@ BEGIN RIGHTMARGIN, 208 END - CONFIGUREDLG_MACHINE, DIALOG + DLG_CFG_MACHINE, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 @@ -603,7 +615,7 @@ BEGIN BOTTOMMARGIN, 105 END - CONFIGUREDLG_VIDEO, DIALOG + DLG_CFG_VIDEO, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 @@ -611,7 +623,7 @@ BEGIN BOTTOMMARGIN, 56 END - CONFIGUREDLG_INPUT, DIALOG + DLG_CFG_INPUT, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 @@ -619,7 +631,7 @@ BEGIN BOTTOMMARGIN, 58 END - CONFIGUREDLG_SOUND, DIALOG + DLG_CFG_SOUND, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 @@ -628,7 +640,7 @@ BEGIN END #ifdef USE_NETWORK - CONFIGUREDLG_NETWORK, DIALOG + DLG_CFG_NETWORK, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 @@ -637,15 +649,23 @@ BEGIN END #endif - CONFIGUREDLG_PERIPHERALS, DIALOG + DLG_CFG_PORTS, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 TOPMARGIN, 7 - BOTTOMMARGIN, 102 + BOTTOMMARGIN, 48 END - CONFIGUREDLG_HARD_DISKS, DIALOG + DLG_CFG_PERIPHERALS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 260 + TOPMARGIN, 7 + BOTTOMMARGIN, 85 + END + + DLG_CFG_HARD_DISKS, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 @@ -653,7 +673,7 @@ BEGIN BOTTOMMARGIN, 137 END - CONFIGUREDLG_REMOVABLE_DEVICES, DIALOG + DLG_CFG_REMOVABLE_DEVICES, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 @@ -698,15 +718,16 @@ BEGIN IDS_2068 "Sound" #ifdef USE_NETWORK IDS_2069 "Network" + IDS_2070 "Ports (COM & LPT)" + IDS_2071 "Other peripherals" + IDS_2072 "Hard disks" + IDS_2073 "Removable devices" +#else + IDS_2069 "Ports (COM & LPT)" IDS_2070 "Other peripherals" IDS_2071 "Hard disks" IDS_2072 "Removable devices" -#else - IDS_2069 "Other peripherals" - IDS_2070 "Hard disks" - IDS_2071 "Removable devices" #endif - IDS_2073 "Unable to create bitmap file: %s" IDS_2074 "Use CTRL+ALT+PAGE DOWN to return to windowed mode" IDS_2075 "CD-ROM images (*.ISO;*.CUE)\0*.ISO;*.CUE\0All files (*.*)\0*.*\0" IDS_2076 "Host CD/DVD Drive (%c:)" @@ -725,6 +746,7 @@ BEGIN IDS_2085 "H" IDS_2086 "S" IDS_2087 "MB" + IDS_2088 "Unable to create bitmap file: %s" IDS_2089 "Enabled" IDS_2090 "Mute" IDS_2091 "Type" diff --git a/src/win/icons/ports.ico b/src/win/icons/ports.ico new file mode 100644 index 000000000..eece4a7dc Binary files /dev/null and b/src/win/icons/ports.ico differ diff --git a/src/win/resource.h b/src/win/resource.h index 3b131f54b..f0b54be18 100644 --- a/src/win/resource.h +++ b/src/win/resource.h @@ -32,10 +32,11 @@ #define DLG_CFG_INPUT 113 /* sub-dialog of config */ #define DLG_CFG_SOUND 114 /* sub-dialog of config */ #define DLG_CFG_NETWORK 115 /* sub-dialog of config */ -#define DLG_CFG_PERIPHERALS 116 /* sub-dialog of config */ -#define DLG_CFG_HARD_DISKS 117 /* sub-dialog of config */ -#define DLG_CFG_HARD_DISKS_ADD 118 /* sub-dialog of config */ -#define DLG_CFG_REMOVABLE_DEVICES 119 /* sub-dialog of config */ +#define DLG_CFG_PORTS 116 /* sub-dialog of config */ +#define DLG_CFG_PERIPHERALS 117 /* sub-dialog of config */ +#define DLG_CFG_HARD_DISKS 118 /* sub-dialog of config */ +#define DLG_CFG_HARD_DISKS_ADD 119 /* sub-dialog of config */ +#define DLG_CFG_REMOVABLE_DEVICES 120 /* sub-dialog of config */ /* Static text label IDs. */ #define IDT_1700 1700 /* Language: */ @@ -132,16 +133,18 @@ #define IDC_COMBO_PCAP 1091 #define IDC_COMBO_NET 1092 -#define IDC_OTHER_PERIPH 1110 /* other periph config */ -#define IDC_COMBO_SCSI 1111 -#define IDC_CONFIGURE_SCSI 1112 -#define IDC_COMBO_HDC 1113 -#define IDC_COMBO_IDE_TER 1114 -#define IDC_COMBO_IDE_QUA 1115 -#define IDC_CHECK_SERIAL1 1116 -#define IDC_CHECK_SERIAL2 1117 -#define IDC_CHECK_PARALLEL 1118 -#define IDC_CHECK_BUGGER 1119 +#define IDC_COMBO_LPT1 1110 /* ports config */ +#define IDC_CHECK_SERIAL1 1111 +#define IDC_CHECK_SERIAL2 1112 +#define IDC_CHECK_PARALLEL 1113 + +#define IDC_OTHER_PERIPH 1120 /* other periph config */ +#define IDC_COMBO_SCSI 1121 +#define IDC_CONFIGURE_SCSI 1122 +#define IDC_COMBO_HDC 1123 +#define IDC_COMBO_IDE_TER 1124 +#define IDC_COMBO_IDE_QUA 1125 +#define IDC_CHECK_BUGGER 1126 #define IDC_HARD_DISKS 1130 /* hard disk config */ #define IDC_LIST_HARD_DISKS 1131 @@ -153,7 +156,8 @@ #define IDC_COMBO_HD_ID 1137 #define IDC_COMBO_HD_LUN 1138 #define IDC_COMBO_HD_CHANNEL_IDE 1139 -#define IDC_EDIT_HD_FILE_NAME 1140 + +#define IDC_EDIT_HD_FILE_NAME 1140 /* add hard disk dialog */ #define IDC_EDIT_HD_SPT 1141 #define IDC_EDIT_HD_HPC 1142 #define IDC_EDIT_HD_CYL 1143 diff --git a/src/win/win_ddraw_screenshot.cc b/src/win/win_ddraw_screenshot.cc index 853ee25ef..27bb5b0b1 100644 --- a/src/win/win_ddraw_screenshot.cc +++ b/src/win/win_ddraw_screenshot.cc @@ -118,7 +118,7 @@ void SaveBitmap(wchar_t *szFilename,HBITMAP hBitmap) if((fp = _wfopen(szFilename,L"wb"))==NULL) { - _swprintf(szMessage, win_language_get_string_from_id(IDS_2073), szFilename); + _swprintf(szMessage, win_language_get_string_from_id(IDS_2088), szFilename); msgbox_error_wstr(ghwnd, szMessage); break; } diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 6a3561f82..c79758016 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -30,6 +30,7 @@ #include "../cdrom.h" #include "../disc.h" #include "../fdd.h" +#include "../lpt.h" #include "../hdd/hdd.h" #include "../hdd/hdd_ide_at.h" #include "../scsi/scsi.h" @@ -69,9 +70,13 @@ static int temp_net_type, temp_net_card; static char temp_pcap_dev[520]; #endif +/* Ports category */ +static char temp_lpt1_device_name[16]; +static int temp_serial[2], temp_lpt; + /* Peripherals category */ static int temp_scsi_card, hdc_ignore, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq; -static int temp_serial[2], temp_lpt, temp_bugger; +static int temp_bugger; static char temp_hdc_name[16]; @@ -141,11 +146,17 @@ static void win_settings_init(void) #ifdef USE_NETWORK /* Network category */ temp_net_type = network_type; - memset(temp_pcap_dev, '\0', sizeof(temp_pcap_dev)); + memset(temp_pcap_dev, 0, sizeof(temp_pcap_dev)); strcpy(temp_pcap_dev, network_pcap); temp_net_card = network_card; #endif + /* Ports category */ + strncpy(temp_lpt1_device_name, lpt1_device_name, sizeof(temp_lpt1_device_name) - 1); + temp_serial[0] = serial_enabled[0]; + temp_serial[1] = serial_enabled[1]; + temp_lpt = lpt_enabled; + /* Peripherals category */ temp_scsi_card = scsi_card_current; strncpy(temp_hdc_name, hdd_controller_name, sizeof(temp_hdc_name) - 1); @@ -153,9 +164,6 @@ static void win_settings_init(void) temp_ide_ter_irq = ide_irq[2]; temp_ide_qua = ide_enable[3]; temp_ide_qua_irq = ide_irq[3]; - temp_serial[0] = serial_enabled[0]; - temp_serial[1] = serial_enabled[1]; - temp_lpt = lpt_enabled; temp_bugger = bugger_enabled; /* Hard disks category */ @@ -215,6 +223,12 @@ static int win_settings_changed(void) i = i || (network_card != temp_net_card); #endif + /* Ports category */ + i = i || strncmp(temp_lpt1_device_name, lpt1_device_name, sizeof(temp_lpt1_device_name) - 1); + i = i || (temp_serial[0] != serial_enabled[0]); + i = i || (temp_serial[1] != serial_enabled[1]); + i = i || (temp_lpt != lpt_enabled); + /* Peripherals category */ i = i || (scsi_card_current != temp_scsi_card); i = i || strncmp(temp_hdc_name, hdd_controller_name, sizeof(temp_hdc_name) - 1); @@ -222,9 +236,6 @@ static int win_settings_changed(void) i = i || (temp_ide_ter_irq != ide_irq[2]); i = i || (temp_ide_qua != ide_enable[3]); i = i || (temp_ide_qua_irq != ide_irq[3]); - i = i || (temp_serial[0] != serial_enabled[0]); - i = i || (temp_serial[1] != serial_enabled[1]); - i = i || (temp_lpt != lpt_enabled); i = i || (temp_bugger != bugger_enabled); /* Hard disks category */ @@ -321,6 +332,12 @@ static void win_settings_save(void) network_card = temp_net_card; #endif + /* Ports category */ + strncpy(lpt1_device_name, temp_lpt1_device_name, sizeof(temp_lpt1_device_name) - 1); + serial_enabled[0] = temp_serial[0]; + serial_enabled[1] = temp_serial[1]; + lpt_enabled = temp_lpt; + /* Peripherals category */ scsi_card_current = temp_scsi_card; strncpy(hdd_controller_name, temp_hdc_name, sizeof(temp_hdc_name) - 1); @@ -328,9 +345,6 @@ static void win_settings_save(void) ide_irq[2] = temp_ide_ter_irq; ide_enable[3] = temp_ide_qua; ide_irq[3] = temp_ide_qua_irq; - serial_enabled[0] = temp_serial[0]; - serial_enabled[1] = temp_serial[1]; - lpt_enabled = temp_lpt; bugger_enabled = temp_bugger; /* Hard disks category */ @@ -1007,133 +1021,6 @@ static BOOL CALLBACK win_settings_input_proc(HWND hdlg, UINT message, WPARAM wPa } -static void recalc_hdd_list(HWND hdlg, int machine, int use_selected_hdd) -{ - HWND h; - - char *s; - int valid = 0; - char old_name[16]; - int c, d; - - LPTSTR lptsTemp; - - lptsTemp = (LPTSTR) malloc(512); - - h = GetDlgItem(hdlg, IDC_COMBO_HDC); - - if (machines[temp_machine].flags & MACHINE_HAS_IDE) - { - hdc_ignore = 1; - - SendMessage(h, CB_RESETCONTENT, 0, 0); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(IDS_2154)); - EnableWindow(h, FALSE); - SendMessage(h, CB_SETCURSEL, 0, 0); - } - else - { - hdc_ignore = 0; - - valid = 0; - - if (use_selected_hdd) - { - c = SendMessage(h, CB_GETCURSEL, 0, 0); - - if (c != -1 && hdd_names[c]) - { - strncpy(old_name, hdd_names[c], sizeof(old_name) - 1); - } - else - { - strcpy(old_name, "none"); - } - } - else - { - strncpy(old_name, temp_hdc_name, sizeof(old_name) - 1); - } - - SendMessage(h, CB_RESETCONTENT, 0, 0); - c = d = 0; - while (1) - { - s = hdd_controller_get_name(c); - if (s[0] == 0) - { - break; - } - if ((hdd_controller_get_flags(c) & DEVICE_AT) && !(machines[machine].flags & MACHINE_AT)) - { - c++; - continue; - } - if ((hdd_controller_get_flags(c) & DEVICE_PS2) && !(machines[machine].flags & MACHINE_PS2_HDD)) - { - c++; - continue; - } - if ((hdd_controller_get_flags(c) & DEVICE_MCA) && !(machines[machine].flags & MACHINE_MCA)) - { - c++; - continue; - } - if (!hdd_controller_available(c)) - { - c++; - continue; - } - if (c < 2) - { - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152 + c)); - } - else - { - mbstowcs(lptsTemp, s, strlen(s) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); - } - hdd_names[d] = hdd_controller_get_internal_name(c); - if (!strcmp(old_name, hdd_names[d])) - { - SendMessage(h, CB_SETCURSEL, d, 0); - valid = 1; - } - c++; - d++; - } - - if (!valid) - { - SendMessage(h, CB_SETCURSEL, 0, 0); - } - - EnableWindow(h, TRUE); - } - - free(lptsTemp); -} - - -int valid_ide_irqs[11] = { 2, 3, 4, 5, 7, 9, 10, 11, 12, 14, 15 }; - - -int find_irq_in_array(int irq, int def) -{ - int i = 0; - - for (i = 0; i < 11; i++) - { - if (valid_ide_irqs[i] == irq) - { - return i + 1; - } - } - - return 7 + def; -} - - int mpu401_present(void) { char *n; @@ -1416,6 +1303,210 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa } +static BOOL CALLBACK win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + HWND h; + int c = 0; + int d = 0; + char *s; + LPTSTR lptsTemp; + + switch (message) + { + case WM_INITDIALOG: + lptsTemp = (LPTSTR) malloc(512); + + h = GetDlgItem(hdlg, IDC_COMBO_LPT1); + c = d = 0; + while (1) + { + s = lpt_device_get_name(c); + + if (!s) + { + break; + } + + if (c == 0) + { + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(IDS_2152)); + } + else + { + mbstowcs(lptsTemp, s, strlen(s) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + + if (!strcmp(temp_lpt1_device_name, lpt_device_get_internal_name(c))) + { + d = c; + } + + c++; + } + SendMessage(h, CB_SETCURSEL, d, 0); + + h=GetDlgItem(hdlg, IDC_CHECK_SERIAL1); + SendMessage(h, BM_SETCHECK, temp_serial[0], 0); + + h=GetDlgItem(hdlg, IDC_CHECK_SERIAL2); + SendMessage(h, BM_SETCHECK, temp_serial[1], 0); + + h=GetDlgItem(hdlg, IDC_CHECK_PARALLEL); + SendMessage(h, BM_SETCHECK, temp_lpt, 0); + + free(lptsTemp); + + return TRUE; + + case WM_SAVESETTINGS: + h = GetDlgItem(hdlg, IDC_COMBO_LPT1); + c = SendMessage(h, CB_GETCURSEL, 0, 0); + strcpy(temp_lpt1_device_name, lpt_device_get_internal_name(c)); + + h = GetDlgItem(hdlg, IDC_CHECK_SERIAL1); + temp_serial[0] = SendMessage(h, BM_GETCHECK, 0, 0); + + h = GetDlgItem(hdlg, IDC_CHECK_SERIAL2); + temp_serial[1] = SendMessage(h, BM_GETCHECK, 0, 0); + + h = GetDlgItem(hdlg, IDC_CHECK_PARALLEL); + temp_lpt = SendMessage(h, BM_GETCHECK, 0, 0); + + default: + return FALSE; + } + return FALSE; +} + + +static void recalc_hdd_list(HWND hdlg, int machine, int use_selected_hdd) +{ + HWND h; + + char *s; + int valid = 0; + char old_name[16]; + int c, d; + + LPTSTR lptsTemp; + + lptsTemp = (LPTSTR) malloc(512); + + h = GetDlgItem(hdlg, IDC_COMBO_HDC); + + if (machines[temp_machine].flags & MACHINE_HAS_IDE) + { + hdc_ignore = 1; + + SendMessage(h, CB_RESETCONTENT, 0, 0); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(IDS_2154)); + EnableWindow(h, FALSE); + SendMessage(h, CB_SETCURSEL, 0, 0); + } + else + { + hdc_ignore = 0; + + valid = 0; + + if (use_selected_hdd) + { + c = SendMessage(h, CB_GETCURSEL, 0, 0); + + if (c != -1 && hdd_names[c]) + { + strncpy(old_name, hdd_names[c], sizeof(old_name) - 1); + } + else + { + strcpy(old_name, "none"); + } + } + else + { + strncpy(old_name, temp_hdc_name, sizeof(old_name) - 1); + } + + SendMessage(h, CB_RESETCONTENT, 0, 0); + c = d = 0; + while (1) + { + s = hdd_controller_get_name(c); + if (s[0] == 0) + { + break; + } + if ((hdd_controller_get_flags(c) & DEVICE_AT) && !(machines[machine].flags & MACHINE_AT)) + { + c++; + continue; + } + if ((hdd_controller_get_flags(c) & DEVICE_PS2) && !(machines[machine].flags & MACHINE_PS2_HDD)) + { + c++; + continue; + } + if ((hdd_controller_get_flags(c) & DEVICE_MCA) && !(machines[machine].flags & MACHINE_MCA)) + { + c++; + continue; + } + if (!hdd_controller_available(c)) + { + c++; + continue; + } + if (c < 2) + { + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152 + c)); + } + else + { + mbstowcs(lptsTemp, s, strlen(s) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + hdd_names[d] = hdd_controller_get_internal_name(c); + if (!strcmp(old_name, hdd_names[d])) + { + SendMessage(h, CB_SETCURSEL, d, 0); + valid = 1; + } + c++; + d++; + } + + if (!valid) + { + SendMessage(h, CB_SETCURSEL, 0, 0); + } + + EnableWindow(h, TRUE); + } + + free(lptsTemp); +} + + +int valid_ide_irqs[11] = { 2, 3, 4, 5, 7, 9, 10, 11, 12, 14, 15 }; + + +int find_irq_in_array(int irq, int def) +{ + int i = 0; + + for (i = 0; i < 11; i++) + { + if (valid_ide_irqs[i] == irq) + { + return i + 1; + } + } + + return 7 + def; +} + + static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h; @@ -1515,15 +1606,6 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR SendMessage(h, CB_SETCURSEL, 0, 0); } - h=GetDlgItem(hdlg, IDC_CHECK_SERIAL1); - SendMessage(h, BM_SETCHECK, temp_serial[0], 0); - - h=GetDlgItem(hdlg, IDC_CHECK_SERIAL2); - SendMessage(h, BM_SETCHECK, temp_serial[1], 0); - - h=GetDlgItem(hdlg, IDC_CHECK_PARALLEL); - SendMessage(h, BM_SETCHECK, temp_lpt, 0); - h=GetDlgItem(hdlg, IDC_CHECK_BUGGER); SendMessage(h, BM_SETCHECK, temp_bugger, 0); @@ -1596,15 +1678,6 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR temp_ide_qua = 1; } - h = GetDlgItem(hdlg, IDC_CHECK_SERIAL1); - temp_serial[0] = SendMessage(h, BM_GETCHECK, 0, 0); - - h = GetDlgItem(hdlg, IDC_CHECK_SERIAL2); - temp_serial[1] = SendMessage(h, BM_GETCHECK, 0, 0); - - h = GetDlgItem(hdlg, IDC_CHECK_PARALLEL); - temp_lpt = SendMessage(h, BM_GETCHECK, 0, 0); - h = GetDlgItem(hdlg, IDC_CHECK_BUGGER); temp_bugger = SendMessage(h, BM_GETCHECK, 0, 0); @@ -4180,13 +4253,15 @@ cdrom_bus_skip: #define SETTINGS_PAGE_SOUND 3 #ifdef USE_NETWORK #define SETTINGS_PAGE_NETWORK 4 +#define SETTINGS_PAGE_PORTS 5 +#define SETTINGS_PAGE_PERIPHERALS 6 +#define SETTINGS_PAGE_HARD_DISKS 7 +#define SETTINGS_PAGE_REMOVABLE_DEVICES 8 +#else +#define SETTINGS_PAGE_PORTS 4 #define SETTINGS_PAGE_PERIPHERALS 5 #define SETTINGS_PAGE_HARD_DISKS 6 #define SETTINGS_PAGE_REMOVABLE_DEVICES 7 -#else -#define SETTINGS_PAGE_PERIPHERALS 4 -#define SETTINGS_PAGE_HARD_DISKS 5 -#define SETTINGS_PAGE_REMOVABLE_DEVICES 6 #endif void win_settings_show_child(HWND hwndParent, DWORD child_id) @@ -4223,6 +4298,9 @@ void win_settings_show_child(HWND hwndParent, DWORD child_id) hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_NETWORK, hwndParent, win_settings_network_proc); break; #endif + case SETTINGS_PAGE_PORTS: + hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_PORTS, hwndParent, win_settings_ports_proc); + break; case SETTINGS_PAGE_PERIPHERALS: hwndChildDialog = CreateDialog(hinstance, (LPCWSTR)DLG_CFG_PERIPHERALS, hwndParent, win_settings_peripherals_proc); break; @@ -4252,9 +4330,9 @@ static BOOL win_settings_main_image_list_init(HWND hwndList) ILC_MASK | ILC_COLOR32, 1, 1); #ifdef USE_NETWORK - for (i = 0; i < 8; i++) + for (i = 0; i < 9; i++) #else - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) #endif { hiconItem = LoadIcon(hinstance, (LPCWSTR) (256 + i)); @@ -4276,9 +4354,9 @@ static BOOL win_settings_main_insert_categories(HWND hwndList) lvI.stateMask = lvI.iSubItem = lvI.state = 0; #ifdef USE_NETWORK - for (i = 0; i < 8; i++) + for (i = 0; i < 9; i++) #else - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) #endif { lvI.pszText = win_language_get_settings_category(i); @@ -4326,9 +4404,9 @@ static BOOL CALLBACK win_settings_main_proc(HWND hdlg, UINT message, WPARAM wPar { category = -1; #ifdef USE_NETWORK - for (i = 0; i < 8; i++) + for (i = 0; i < 9; i++) #else - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) #endif { h = GetDlgItem(hdlg, IDC_SETTINGSCATLIST);