From 4c3532f31e95fbb57f00843b39923c7852297f27 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 2 Sep 2017 23:39:26 +0200 Subject: [PATCH] Applied all mainline PCem commits; Removed SCSI thread waiting (except after executing the READ SUBCHANNEL command, to alleviate the effects of READ SUBCHANNEL spam done by CD players). --- src/Makefile.mingw | 10 +- src/config.c | 100 +++++--- src/cpu/386.c | 3 +- src/lpt.c | 73 +++++- src/lpt.h | 31 ++- src/pc.c | 48 ++-- src/scsi/scsi_aha154x.c | 7 +- src/scsi/scsi_buslogic.c | 7 +- src/sound/filters.h | 94 +++++++- src/sound/snd_lpt_dac.c | 119 +++++++++ src/sound/snd_lpt_dac.h | 2 + src/sound/snd_lpt_dss.c | 115 +++++++++ src/sound/snd_lpt_dss.h | 1 + src/timer.c | 2 +- src/win/86Box.rc | 80 ++++--- src/win/icons/ports.ico | Bin 0 -> 1150 bytes src/win/resource.h | 34 +-- src/win/win_ddraw_screenshot.cc | 2 +- src/win/win_settings.c | 410 +++++++++++++++++++------------- 19 files changed, 846 insertions(+), 292 deletions(-) create mode 100644 src/sound/snd_lpt_dac.c create mode 100644 src/sound/snd_lpt_dac.h create mode 100644 src/sound/snd_lpt_dss.c create mode 100644 src/sound/snd_lpt_dss.h create mode 100644 src/win/icons/ports.ico 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 0000000000000000000000000000000000000000..eece4a7dccc32d72e50c2715e406a452631c4a85 GIT binary patch literal 1150 zcmb`FOG_J36vwY92<<|lRJ!b_=CWsD7h87G;^ z8hb%y`fYih|Qf*^dc+wI$uEdSvI5jdwCIKc@g{Mj5%lz=$lMHRQ( z?X=l!+vN58{kJ#=hvYFy%&8olI$;0k=S;(R@XG*(3RyZcxu6fQ%d(4V+=^yQ zHab7vC(vDJke4((|1=Vb?CN<*!*e~uclANTVzDSztM$7!_xXJ99`fqxCX?yPXf%G+ vTU$gko6Sea)*`ujIR=B_J@$X8x29