Sound cleanups, part 2.
This commit is contained in:
12
src/config.c
12
src/config.c
@@ -12,7 +12,7 @@
|
|||||||
* it on Windows XP, and possibly also Vista. Use the
|
* it on Windows XP, and possibly also Vista. Use the
|
||||||
* -DANSI_CFG for use on these systems.
|
* -DANSI_CFG for use on these systems.
|
||||||
*
|
*
|
||||||
* Version: @(#)config.c 1.0.11 2018/04/08
|
* Version: @(#)config.c 1.0.12 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -69,9 +69,6 @@
|
|||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
#include "sound/sound.h"
|
#include "sound/sound.h"
|
||||||
#include "sound/midi.h"
|
#include "sound/midi.h"
|
||||||
#include "sound/snd_dbopl.h"
|
|
||||||
#include "sound/snd_mpu401.h"
|
|
||||||
#include "sound/snd_opl.h"
|
|
||||||
#include "sound/sound.h"
|
#include "sound/sound.h"
|
||||||
#include "video/video.h"
|
#include "video/video.h"
|
||||||
#include "plat.h"
|
#include "plat.h"
|
||||||
@@ -627,8 +624,6 @@ load_sound(void)
|
|||||||
|
|
||||||
mpu401_standalone_enable = !!config_get_int(cat, "mpu401_standalone", 0);
|
mpu401_standalone_enable = !!config_get_int(cat, "mpu401_standalone", 0);
|
||||||
|
|
||||||
GAMEBLASTER = !!config_get_int(cat, "gameblaster", 0);
|
|
||||||
|
|
||||||
memset(temp, '\0', sizeof(temp));
|
memset(temp, '\0', sizeof(temp));
|
||||||
p = config_get_string(cat, "opl3_type", "dbopl");
|
p = config_get_string(cat, "opl3_type", "dbopl");
|
||||||
strcpy(temp, p);
|
strcpy(temp, p);
|
||||||
@@ -1620,11 +1615,6 @@ save_sound(void)
|
|||||||
else
|
else
|
||||||
config_set_int(cat, "mpu401_standalone", mpu401_standalone_enable);
|
config_set_int(cat, "mpu401_standalone", mpu401_standalone_enable);
|
||||||
|
|
||||||
if (GAMEBLASTER == 0)
|
|
||||||
config_delete_var(cat, "gameblaster");
|
|
||||||
else
|
|
||||||
config_set_int(cat, "gameblaster", GAMEBLASTER);
|
|
||||||
|
|
||||||
if (opl3_type == 0)
|
if (opl3_type == 0)
|
||||||
config_delete_var(cat, "opl3_type");
|
config_delete_var(cat, "opl3_type");
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Main include file for the application.
|
* Main include file for the application.
|
||||||
*
|
*
|
||||||
* Version: @(#)emu.h 1.0.15 2018/04/08
|
* Version: @(#)emu.h 1.0.16 2018/04/08
|
||||||
*
|
*
|
||||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
@@ -115,7 +115,8 @@ extern int romdos_enabled; /* (C) enable ROM DOS */
|
|||||||
#endif
|
#endif
|
||||||
extern int hdc_type; /* (C) HDC type */
|
extern int hdc_type; /* (C) HDC type */
|
||||||
extern int sound_is_float, /* (C) sound uses FP values */
|
extern int sound_is_float, /* (C) sound uses FP values */
|
||||||
GAMEBLASTER, /* (C) sound option */
|
mpu401_standalone_enable, /* (C) sound option */
|
||||||
|
opl3_type, /* (C) sound option */
|
||||||
voodoo_enabled; /* (C) video option */
|
voodoo_enabled; /* (C) video option */
|
||||||
extern int joystick_type; /* (C) joystick type */
|
extern int joystick_type; /* (C) joystick type */
|
||||||
extern int mem_size; /* (C) memory size */
|
extern int mem_size; /* (C) memory size */
|
||||||
|
|||||||
5
src/pc.c
5
src/pc.c
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Main emulator module where most things are controlled.
|
* Main emulator module where most things are controlled.
|
||||||
*
|
*
|
||||||
* Version: @(#)pc.c 1.0.21 2018/04/08
|
* Version: @(#)pc.c 1.0.22 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -130,7 +130,8 @@ int romdos_enabled = 0; /* (C) enable ROM DOS */
|
|||||||
#endif
|
#endif
|
||||||
int hdc_type = 0; /* (C) HDC type */
|
int hdc_type = 0; /* (C) HDC type */
|
||||||
int sound_is_float = 1, /* (C) sound uses FP values */
|
int sound_is_float = 1, /* (C) sound uses FP values */
|
||||||
GAMEBLASTER = 0, /* (C) sound option */
|
mpu401_standalone_enable = 0, /* (C) sound option */
|
||||||
|
opl3_type = 0, /* (C) sound option */
|
||||||
voodoo_enabled = 0; /* (C) video option */
|
voodoo_enabled = 0; /* (C) video option */
|
||||||
int joystick_type = 0; /* (C) joystick type */
|
int joystick_type = 0; /* (C) joystick type */
|
||||||
int mem_size = 0; /* (C) memory size */
|
int mem_size = 0; /* (C) memory size */
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the VARCem Project.
|
||||||
*
|
*
|
||||||
* Implementation of the Create CMS/GameBlaster sound device.
|
* Implementation of the Creative CMS/GameBlaster sound device.
|
||||||
*
|
*
|
||||||
* Version: @(#)snd_cms.c 1.0.3 2018/04/08
|
* Version: @(#)snd_cms.c 1.0.4 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -47,194 +47,228 @@
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
|
|
||||||
#define MASTER_CLOCK 7159090
|
#define MASTER_CLOCK 7159090
|
||||||
|
|
||||||
|
|
||||||
typedef struct cms_t
|
typedef struct {
|
||||||
{
|
int addrs[2];
|
||||||
int addrs[2];
|
uint8_t regs[2][32];
|
||||||
uint8_t regs[2][32];
|
uint16_t latch[2][6];
|
||||||
uint16_t latch[2][6];
|
int freq[2][6];
|
||||||
int freq[2][6];
|
float count[2][6];
|
||||||
float count[2][6];
|
int vol[2][6][2];
|
||||||
int vol[2][6][2];
|
int stat[2][6];
|
||||||
int stat[2][6];
|
uint16_t noise[2][2];
|
||||||
uint16_t noise[2][2];
|
uint16_t noisefreq[2][2];
|
||||||
uint16_t noisefreq[2][2];
|
int noisecount[2][2];
|
||||||
int noisecount[2][2];
|
int noisetype[2][2];
|
||||||
int noisetype[2][2];
|
|
||||||
|
|
||||||
uint8_t latched_data;
|
|
||||||
|
|
||||||
int16_t buffer[SOUNDBUFLEN * 2];
|
uint8_t latched_data;
|
||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
|
int16_t buffer[SOUNDBUFLEN * 2];
|
||||||
} cms_t;
|
} cms_t;
|
||||||
|
|
||||||
void cms_update(cms_t *cms)
|
|
||||||
{
|
|
||||||
for (; cms->pos < sound_pos_global; cms->pos++)
|
|
||||||
{
|
|
||||||
int c, d;
|
|
||||||
int16_t out_l = 0, out_r = 0;
|
|
||||||
|
|
||||||
for (c = 0; c < 4; c++)
|
static void
|
||||||
{
|
cms_update(cms_t *dev)
|
||||||
switch (cms->noisetype[c >> 1][c & 1])
|
{
|
||||||
{
|
int16_t out_l = 0, out_r = 0;
|
||||||
case 0: cms->noisefreq[c >> 1][c & 1] = MASTER_CLOCK/256; break;
|
int c, d;
|
||||||
case 1: cms->noisefreq[c >> 1][c & 1] = MASTER_CLOCK/512; break;
|
|
||||||
case 2: cms->noisefreq[c >> 1][c & 1] = MASTER_CLOCK/1024; break;
|
for (; dev->pos < sound_pos_global; dev->pos++) {
|
||||||
case 3: cms->noisefreq[c >> 1][c & 1] = cms->freq[c >> 1][(c & 1) * 3]; break;
|
for (c = 0; c < 4; c++) {
|
||||||
}
|
switch (dev->noisetype[c>>1][c&1]) {
|
||||||
}
|
case 0:
|
||||||
for (c = 0; c < 2; c ++)
|
dev->noisefreq[c>>1][c&1] = MASTER_CLOCK/256;
|
||||||
{
|
break;
|
||||||
if (cms->regs[c][0x1C] & 1)
|
case 1:
|
||||||
{
|
dev->noisefreq[c>>1][c&1] = MASTER_CLOCK/512;
|
||||||
for (d = 0; d < 6; d++)
|
break;
|
||||||
{
|
case 2:
|
||||||
if (cms->regs[c][0x14] & (1 << d))
|
dev->noisefreq[c>>1][c&1] = MASTER_CLOCK/1024;
|
||||||
{
|
break;
|
||||||
if (cms->stat[c][d]) out_l += (cms->vol[c][d][0] * 90);
|
case 3:
|
||||||
if (cms->stat[c][d]) out_r += (cms->vol[c][d][1] * 90);
|
dev->noisefreq[c>>1][c&1] = dev->freq[c>>1][(c&1) * 3];
|
||||||
cms->count[c][d] += cms->freq[c][d];
|
break;
|
||||||
if (cms->count[c][d] >= 24000)
|
}
|
||||||
{
|
}
|
||||||
cms->count[c][d] -= 24000;
|
|
||||||
cms->stat[c][d] ^= 1;
|
for (c = 0; c < 2; c ++) {
|
||||||
}
|
if (dev->regs[c][0x1C] & 1) {
|
||||||
}
|
for (d = 0; d < 6; d++) {
|
||||||
else if (cms->regs[c][0x15] & (1 << d))
|
if (dev->regs[c][0x14] & (1 << d)) {
|
||||||
{
|
if (dev->stat[c][d])
|
||||||
if (cms->noise[c][d / 3] & 1) out_l += (cms->vol[c][d][0] * 90);
|
out_l += (dev->vol[c][d][0] * 90);
|
||||||
if (cms->noise[c][d / 3] & 1) out_r += (cms->vol[c][d][0] * 90);
|
if (dev->stat[c][d])
|
||||||
}
|
out_r += (dev->vol[c][d][1] * 90);
|
||||||
}
|
dev->count[c][d] += dev->freq[c][d];
|
||||||
for (d = 0; d < 2; d++)
|
if (dev->count[c][d] >= 24000) {
|
||||||
{
|
dev->count[c][d] -= 24000;
|
||||||
cms->noisecount[c][d] += cms->noisefreq[c][d];
|
dev->stat[c][d] ^= 1;
|
||||||
while (cms->noisecount[c][d] >= 24000)
|
}
|
||||||
{
|
} else if (dev->regs[c][0x15] & (1 << d)) {
|
||||||
cms->noisecount[c][d] -= 24000;
|
if (dev->noise[c][d / 3] & 1)
|
||||||
cms->noise[c][d] <<= 1;
|
out_l += (dev->vol[c][d][0] * 90);
|
||||||
if (!(((cms->noise[c][d] & 0x4000) >> 8) ^ (cms->noise[c][d] & 0x40)))
|
if (dev->noise[c][d / 3] & 1)
|
||||||
cms->noise[c][d] |= 1;
|
out_r += (dev->vol[c][d][0] * 90);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
for (d = 0; d < 2; d++) {
|
||||||
cms->buffer[(cms->pos << 1)] = out_l;
|
dev->noisecount[c][d] += dev->noisefreq[c][d];
|
||||||
cms->buffer[(cms->pos << 1) + 1] = out_r;
|
while (dev->noisecount[c][d] >= 24000) {
|
||||||
}
|
dev->noisecount[c][d] -= 24000;
|
||||||
|
dev->noise[c][d] <<= 1;
|
||||||
|
if (!(((dev->noise[c][d] & 0x4000) >> 8) ^ (dev->noise[c][d] & 0x40)))
|
||||||
|
dev->noise[c][d] |= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dev->buffer[(dev->pos << 1)] = out_l;
|
||||||
|
dev->buffer[(dev->pos << 1) + 1] = out_r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cms_get_buffer(int32_t *buffer, int len, void *p)
|
|
||||||
|
static void
|
||||||
|
get_buffer(int32_t *buffer, int len, void *priv)
|
||||||
{
|
{
|
||||||
cms_t *cms = (cms_t *)p;
|
cms_t *dev = (cms_t *)priv;
|
||||||
|
int c;
|
||||||
int c;
|
|
||||||
|
|
||||||
cms_update(cms);
|
cms_update(dev);
|
||||||
|
|
||||||
for (c = 0; c < len * 2; c++)
|
|
||||||
buffer[c] += cms->buffer[c];
|
|
||||||
|
|
||||||
cms->pos = 0;
|
for (c = 0; c < len * 2; c++)
|
||||||
|
buffer[c] += dev->buffer[c];
|
||||||
|
|
||||||
|
dev->pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cms_write(uint16_t addr, uint8_t val, void *p)
|
|
||||||
|
static void
|
||||||
|
cms_write(uint16_t addr, uint8_t val, void *priv)
|
||||||
{
|
{
|
||||||
cms_t *cms = (cms_t *)p;
|
cms_t *dev = (cms_t *)priv;
|
||||||
int voice;
|
int voice;
|
||||||
int chip = (addr & 2) >> 1;
|
int chip = (addr & 2) >> 1;
|
||||||
|
|
||||||
switch (addr & 0xf)
|
switch (addr & 0xf) {
|
||||||
{
|
case 1:
|
||||||
case 1:
|
dev->addrs[0] = val & 31;
|
||||||
cms->addrs[0] = val & 31;
|
break;
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
cms->addrs[1] = val & 31;
|
dev->addrs[1] = val & 31;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0: case 2:
|
case 0:
|
||||||
cms_update(cms);
|
case 2:
|
||||||
cms->regs[chip][cms->addrs[chip] & 31] = val;
|
cms_update(dev);
|
||||||
switch (cms->addrs[chip] & 31)
|
dev->regs[chip][dev->addrs[chip] & 31] = val;
|
||||||
{
|
|
||||||
case 0x00: case 0x01: case 0x02: /*Volume*/
|
switch (dev->addrs[chip] & 31) {
|
||||||
case 0x03: case 0x04: case 0x05:
|
case 0x00: case 0x01: case 0x02: /*Volume*/
|
||||||
voice = cms->addrs[chip] & 7;
|
case 0x03: case 0x04: case 0x05:
|
||||||
cms->vol[chip][voice][0] = val & 0xf;
|
voice = dev->addrs[chip] & 7;
|
||||||
cms->vol[chip][voice][1] = val >> 4;
|
dev->vol[chip][voice][0] = val & 0xf;
|
||||||
break;
|
dev->vol[chip][voice][1] = val >> 4;
|
||||||
case 0x08: case 0x09: case 0x0A: /*Frequency*/
|
break;
|
||||||
case 0x0B: case 0x0C: case 0x0D:
|
|
||||||
voice = cms->addrs[chip] & 7;
|
case 0x08: case 0x09: case 0x0A: /*Frequency*/
|
||||||
cms->latch[chip][voice] = (cms->latch[chip][voice] & 0x700) | val;
|
case 0x0B: case 0x0C: case 0x0D:
|
||||||
cms->freq[chip][voice] = (MASTER_CLOCK/512 << (cms->latch[chip][voice] >> 8)) / (511 - (cms->latch[chip][voice] & 255));
|
voice = dev->addrs[chip] & 7;
|
||||||
break;
|
dev->latch[chip][voice] = (dev->latch[chip][voice] & 0x700) | val;
|
||||||
case 0x10: case 0x11: case 0x12: /*Octave*/
|
dev->freq[chip][voice] = (MASTER_CLOCK/512 << (dev->latch[chip][voice] >> 8)) / (511 - (dev->latch[chip][voice] & 255));
|
||||||
voice = (cms->addrs[chip] & 3) << 1;
|
break;
|
||||||
cms->latch[chip][voice] = (cms->latch[chip][voice] & 0xFF) | ((val & 7) << 8);
|
|
||||||
cms->latch[chip][voice + 1] = (cms->latch[chip][voice + 1] & 0xFF) | ((val & 0x70) << 4);
|
case 0x10: case 0x11: case 0x12: /*Octave*/
|
||||||
cms->freq[chip][voice] = (MASTER_CLOCK/512 << (cms->latch[chip][voice] >> 8)) / (511 - (cms->latch[chip][voice] & 255));
|
voice = (dev->addrs[chip] & 3) << 1;
|
||||||
cms->freq[chip][voice + 1] = (MASTER_CLOCK/512 << (cms->latch[chip][voice + 1] >> 8)) / (511 - (cms->latch[chip][voice + 1] & 255));
|
dev->latch[chip][voice] = (dev->latch[chip][voice] & 0xFF) | ((val & 7) << 8);
|
||||||
break;
|
dev->latch[chip][voice + 1] = (dev->latch[chip][voice + 1] & 0xFF) | ((val & 0x70) << 4);
|
||||||
case 0x16: /*Noise*/
|
dev->freq[chip][voice] = (MASTER_CLOCK/512 << (dev->latch[chip][voice] >> 8)) / (511 - (dev->latch[chip][voice] & 255));
|
||||||
cms->noisetype[chip][0] = val & 3;
|
dev->freq[chip][voice + 1] = (MASTER_CLOCK/512 << (dev->latch[chip][voice + 1] >> 8)) / (511 - (dev->latch[chip][voice + 1] & 255));
|
||||||
cms->noisetype[chip][1] = (val >> 4) & 3;
|
break;
|
||||||
break;
|
|
||||||
}
|
case 0x16: /*Noise*/
|
||||||
break;
|
dev->noisetype[chip][0] = val & 3;
|
||||||
case 0x6: case 0x7:
|
dev->noisetype[chip][1] = (val >> 4) & 3;
|
||||||
cms->latched_data = val;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
case 0x6: case 0x7:
|
||||||
|
dev->latched_data = val;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t cms_read(uint16_t addr, void *p)
|
|
||||||
{
|
|
||||||
cms_t *cms = (cms_t *)p;
|
|
||||||
|
|
||||||
switch (addr & 0xf)
|
static uint8_t
|
||||||
{
|
cms_read(uint16_t addr, void *priv)
|
||||||
case 0x1:
|
{
|
||||||
return cms->addrs[0];
|
cms_t *dev = (cms_t *)priv;
|
||||||
case 0x3:
|
uint8_t ret = 0xff;
|
||||||
return cms->addrs[1];
|
|
||||||
case 0x4:
|
switch (addr & 0xf) {
|
||||||
return 0x7f;
|
case 0x1:
|
||||||
case 0xa: case 0xb:
|
ret = dev->addrs[0];
|
||||||
return cms->latched_data;
|
break;
|
||||||
}
|
|
||||||
return 0xff;
|
case 0x3:
|
||||||
|
ret = dev->addrs[1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x4:
|
||||||
|
ret = 0x7f;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xa:
|
||||||
|
case 0xb:
|
||||||
|
ret = dev->latched_data;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cms_init(const device_t *info)
|
|
||||||
{
|
|
||||||
cms_t *cms = malloc(sizeof(cms_t));
|
|
||||||
memset(cms, 0, sizeof(cms_t));
|
|
||||||
|
|
||||||
pclog("cms_init\n");
|
static void *
|
||||||
io_sethandler(0x0220, 0x0010, cms_read, NULL, NULL, cms_write, NULL, NULL, cms);
|
cms_init(const device_t *info)
|
||||||
sound_add_handler(cms_get_buffer, cms);
|
{
|
||||||
return cms;
|
cms_t *dev;
|
||||||
|
|
||||||
|
dev = (cms_t *)malloc(sizeof(cms_t));
|
||||||
|
memset(dev, 0x00, sizeof(cms_t));
|
||||||
|
|
||||||
|
io_sethandler(0x0220, 16,
|
||||||
|
cms_read,NULL,NULL, cms_write,NULL,NULL, dev);
|
||||||
|
|
||||||
|
sound_add_handler(get_buffer, dev);
|
||||||
|
|
||||||
|
return(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cms_close(void *p)
|
|
||||||
|
static void
|
||||||
|
cms_close(void *priv)
|
||||||
{
|
{
|
||||||
cms_t *cms = (cms_t *)p;
|
cms_t *dev = (cms_t *)priv;
|
||||||
|
|
||||||
free(cms);
|
free(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
const device_t cms_device =
|
|
||||||
{
|
const device_t cms_device = {
|
||||||
"Creative Music System / Game Blaster",
|
"Creative Music System / Game Blaster",
|
||||||
0, 0,
|
DEVICE_ISA,
|
||||||
cms_init, cms_close, NULL,
|
0,
|
||||||
NULL, NULL, NULL, NULL,
|
cms_init, cms_close, NULL,
|
||||||
NULL
|
NULL, NULL, NULL, NULL,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
* NOTE: See MSC_ macros for allocation on stack. --FvK
|
* NOTE: See MSC_ macros for allocation on stack. --FvK
|
||||||
*
|
*
|
||||||
* Version: @(#)snd_dbopl.cpp 1.0.3 2018/02/22
|
* Version: @(#)snd_dbopl.cpp 1.0.4 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -51,9 +51,6 @@
|
|||||||
#include "snd_dbopl.h"
|
#include "snd_dbopl.h"
|
||||||
|
|
||||||
|
|
||||||
int opl3_type = 0;
|
|
||||||
|
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
DBOPL::Chip chip;
|
DBOPL::Chip chip;
|
||||||
|
|||||||
2143
src/sound/snd_gus.c
2143
src/sound/snd_gus.c
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Roland MPU-401 emulation.
|
* Roland MPU-401 emulation.
|
||||||
*
|
*
|
||||||
* Version: @(#)snd_mpu401.c 1.0.4 2018/04/02
|
* Version: @(#)snd_mpu401.c 1.0.5 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -62,16 +62,15 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int mpu401_standalone_enable = 0;
|
#ifdef ENABLE_SOUND_MPU401_LOG
|
||||||
|
int sound_mpu401_do_log = ENABLE_SOUND_MPU401_LOG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int64_t mpu401_event_callback = 0LL;
|
static int64_t mpu401_event_callback = 0LL;
|
||||||
static int64_t mpu401_eoi_callback = 0LL;
|
static int64_t mpu401_eoi_callback = 0LL;
|
||||||
static int64_t mpu401_reset_callback = 0LL;
|
static int64_t mpu401_reset_callback = 0LL;
|
||||||
|
|
||||||
#ifdef ENABLE_SOUND_MPU401_LOG
|
|
||||||
int sound_mpu401_do_log = ENABLE_SOUND_MPU401_LOG;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static void MPU401_WriteCommand(mpu_t *mpu, uint8_t val);
|
static void MPU401_WriteCommand(mpu_t *mpu, uint8_t val);
|
||||||
static void MPU401_EOIHandlerDispatch(void *p);
|
static void MPU401_EOIHandlerDispatch(void *p);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Roland MPU-401 emulation.
|
* Roland MPU-401 emulation.
|
||||||
*
|
*
|
||||||
* Version: @(#)snd_mpu401.h 1.0.2 2018/03/15
|
* Version: @(#)snd_mpu401.h 1.0.3 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -43,14 +43,25 @@
|
|||||||
# define SOUND_MPU401_H
|
# define SOUND_MPU401_H
|
||||||
|
|
||||||
|
|
||||||
#define MPU401_VERSION 0x15
|
#define MPU401_VERSION 0x15
|
||||||
#define MPU401_REVISION 0x01
|
#define MPU401_REVISION 0x01
|
||||||
#define MPU401_QUEUE 32
|
#define MPU401_QUEUE 32
|
||||||
#define MPU401_TIMECONSTANT (60000000/1000.0f)
|
#define MPU401_TIMECONSTANT (60000000/1000.0f)
|
||||||
#define MPU401_RESETBUSY 27.0f
|
#define MPU401_RESETBUSY 27.0f
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
M_UART,
|
||||||
|
M_INTELLIGENT
|
||||||
|
} MpuMode;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
T_OVERFLOW,
|
||||||
|
T_MARK,
|
||||||
|
T_MIDI_SYS,
|
||||||
|
T_MIDI_NORM,
|
||||||
|
T_COMMAND
|
||||||
|
} MpuDataType;
|
||||||
|
|
||||||
typedef enum MpuMode { M_UART,M_INTELLIGENT } MpuMode;
|
|
||||||
typedef enum MpuDataType {T_OVERFLOW,T_MARK,T_MIDI_SYS,T_MIDI_NORM,T_COMMAND} MpuDataType;
|
|
||||||
|
|
||||||
/* Messages sent to MPU-401 from host */
|
/* Messages sent to MPU-401 from host */
|
||||||
#define MSG_EOX 0xf7
|
#define MSG_EOX 0xf7
|
||||||
@@ -64,57 +75,61 @@ typedef enum MpuDataType {T_OVERFLOW,T_MARK,T_MIDI_SYS,T_MIDI_NORM,T_COMMAND} Mp
|
|||||||
#define MSG_MPU_CLOCK 0xfd
|
#define MSG_MPU_CLOCK 0xfd
|
||||||
#define MSG_MPU_ACK 0xfe
|
#define MSG_MPU_ACK 0xfe
|
||||||
|
|
||||||
typedef struct mpu_t
|
|
||||||
{
|
typedef struct {
|
||||||
int uart_mode;
|
int uart_mode;
|
||||||
uint8_t rx_data;
|
uint8_t rx_data;
|
||||||
int intelligent;
|
int intelligent;
|
||||||
MpuMode mode;
|
MpuMode mode;
|
||||||
int irq;
|
int irq;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
uint8_t queue[MPU401_QUEUE];
|
uint8_t queue[MPU401_QUEUE];
|
||||||
int queue_pos,queue_used;
|
int queue_pos,
|
||||||
struct track
|
queue_used;
|
||||||
{
|
|
||||||
int counter;
|
struct track {
|
||||||
uint8_t value[8],sys_val;
|
int counter;
|
||||||
uint8_t vlength,length;
|
uint8_t value[8],
|
||||||
MpuDataType type;
|
sys_val;
|
||||||
} playbuf[8],condbuf;
|
uint8_t vlength,
|
||||||
struct {
|
length;
|
||||||
int conductor,cond_req,cond_set, block_ack;
|
MpuDataType type;
|
||||||
int playing,reset;
|
} playbuf[8],
|
||||||
int wsd,wsm,wsd_start;
|
condbuf;
|
||||||
int run_irq,irq_pending;
|
|
||||||
int send_now;
|
struct {
|
||||||
int eoi_scheduled;
|
int conductor,cond_req,cond_set, block_ack;
|
||||||
int data_onoff;
|
int playing,reset;
|
||||||
uint32_t command_byte,cmd_pending;
|
int wsd,wsm,wsd_start;
|
||||||
uint8_t tmask,cmask,amask;
|
int run_irq,irq_pending;
|
||||||
uint16_t midi_mask;
|
int send_now;
|
||||||
uint16_t req_mask;
|
int eoi_scheduled;
|
||||||
uint8_t channel,old_chan;
|
int data_onoff;
|
||||||
} state;
|
uint32_t command_byte,cmd_pending;
|
||||||
struct {
|
uint8_t tmask,cmask,amask;
|
||||||
uint8_t timebase,old_timebase;
|
uint16_t midi_mask;
|
||||||
uint8_t tempo,old_tempo;
|
uint16_t req_mask;
|
||||||
uint8_t tempo_rel,old_tempo_rel;
|
uint8_t channel,old_chan;
|
||||||
uint8_t tempo_grad;
|
} state;
|
||||||
uint8_t cth_rate,cth_counter;
|
|
||||||
int clock_to_host,cth_active;
|
struct {
|
||||||
} clock;
|
uint8_t timebase,old_timebase;
|
||||||
|
uint8_t tempo,old_tempo;
|
||||||
|
uint8_t tempo_rel,old_tempo_rel;
|
||||||
|
uint8_t tempo_grad;
|
||||||
|
uint8_t cth_rate,cth_counter;
|
||||||
|
int clock_to_host,cth_active;
|
||||||
|
} clock;
|
||||||
} mpu_t;
|
} mpu_t;
|
||||||
|
|
||||||
uint8_t MPU401_ReadData(mpu_t *mpu);
|
|
||||||
|
|
||||||
void mpu401_init(mpu_t *mpu, uint16_t addr, int irq, int mode);
|
|
||||||
|
|
||||||
extern int mpu401_standalone_enable;
|
|
||||||
|
|
||||||
void mpu401_device_add(void);
|
|
||||||
extern const device_t mpu401_device;
|
extern const device_t mpu401_device;
|
||||||
|
|
||||||
void mpu401_uart_init(mpu_t *mpu, uint16_t addr);
|
|
||||||
|
extern uint8_t MPU401_ReadData(mpu_t *mpu);
|
||||||
|
extern void mpu401_init(mpu_t *mpu, uint16_t addr, int irq, int mode);
|
||||||
|
extern void mpu401_device_add(void);
|
||||||
|
extern void mpu401_uart_init(mpu_t *mpu, uint16_t addr);
|
||||||
|
|
||||||
|
|
||||||
#endif /*SOUND_MPU401_H*/
|
#endif /*SOUND_MPU401_H*/
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Sound emulation core.
|
* Sound emulation core.
|
||||||
*
|
*
|
||||||
* Version: @(#)sound.c 1.0.7 2018/04/08
|
* Version: @(#)sound.c 1.0.8 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -74,7 +74,6 @@ int sound_gain = 0;
|
|||||||
volatile int soundon = 1;
|
volatile int soundon = 1;
|
||||||
|
|
||||||
|
|
||||||
//static int card_last = 0;
|
|
||||||
static sndhnd_t handlers[8];
|
static sndhnd_t handlers[8];
|
||||||
static sndhnd_t process_handlers[8];
|
static sndhnd_t process_handlers[8];
|
||||||
static int handlers_num;
|
static int handlers_num;
|
||||||
@@ -333,15 +332,9 @@ sound_reset(void)
|
|||||||
|
|
||||||
/* Initialize the currently selected sound card. */
|
/* Initialize the currently selected sound card. */
|
||||||
snddev_reset();
|
snddev_reset();
|
||||||
// card_last = sound_card_current;
|
|
||||||
|
|
||||||
if (mpu401_standalone_enable)
|
if (mpu401_standalone_enable)
|
||||||
mpu401_device_add();
|
mpu401_device_add();
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (GAMEBLASTER)
|
|
||||||
device_add(&cms_device);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Sound devices support module.
|
* Sound devices support module.
|
||||||
*
|
*
|
||||||
* Version: @(#)sound_dev.c 1.0.1 2018/04/08
|
* Version: @(#)sound_dev.c 1.0.2 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -89,6 +89,7 @@ static const sound_t sound_cards[] = {
|
|||||||
{"Disabled", "none", NULL },
|
{"Disabled", "none", NULL },
|
||||||
{"[ISA] Adlib", "adlib", &adlib_device },
|
{"[ISA] Adlib", "adlib", &adlib_device },
|
||||||
{"[ISA] Adlib Gold", "adlibgold", &adgold_device },
|
{"[ISA] Adlib Gold", "adlibgold", &adgold_device },
|
||||||
|
{"[ISA] Creative Music System", "cms", &cms_device },
|
||||||
{"[ISA] Gravis Ultra Sound", "gus", &gus_device },
|
{"[ISA] Gravis Ultra Sound", "gus", &gus_device },
|
||||||
{"[ISA] Innovation SSI-2001", "ssi2001", &ssi2001_device },
|
{"[ISA] Innovation SSI-2001", "ssi2001", &ssi2001_device },
|
||||||
{"[ISA] Sound Blaster 1.0", "sb", &sb_1_device },
|
{"[ISA] Sound Blaster 1.0", "sb", &sb_1_device },
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Application resource script for Windows.
|
* Application resource script for Windows.
|
||||||
*
|
*
|
||||||
* Version: @(#)VARCem.rc 1.0.15 2018/04/08
|
* Version: @(#)VARCem.rc 1.0.16 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -488,9 +488,6 @@ BEGIN
|
|||||||
|
|
||||||
CONTROL "Use FLOAT32 sound",IDC_CHECK_FLOAT,"Button",
|
CONTROL "Use FLOAT32 sound",IDC_CHECK_FLOAT,"Button",
|
||||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,81,94,10
|
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
|
END
|
||||||
|
|
||||||
DLG_CFG_NETWORK DIALOG DISCARDABLE 97, 0, 267, 63
|
DLG_CFG_NETWORK DIALOG DISCARDABLE 97, 0, 267, 63
|
||||||
|
|||||||
@@ -160,7 +160,6 @@
|
|||||||
#define IDC_CHECK_FLOAT 1074
|
#define IDC_CHECK_FLOAT 1074
|
||||||
#define IDC_CHECK_MPU401 1075
|
#define IDC_CHECK_MPU401 1075
|
||||||
#define IDC_CONFIGURE_MPU401 1076
|
#define IDC_CONFIGURE_MPU401 1076
|
||||||
#define IDC_CHECK_CMS 1077
|
|
||||||
|
|
||||||
#define IDC_COMBO_NET_TYPE 1090 /* network config */
|
#define IDC_COMBO_NET_TYPE 1090 /* network config */
|
||||||
#define IDC_COMBO_PCAP 1091
|
#define IDC_COMBO_PCAP 1091
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Implementation of the Settings dialog.
|
* Implementation of the Settings dialog.
|
||||||
*
|
*
|
||||||
* Version: @(#)win_settings.c 1.0.19 2018/04/08
|
* Version: @(#)win_settings.c 1.0.20 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -67,7 +67,6 @@
|
|||||||
#include "../network/network.h"
|
#include "../network/network.h"
|
||||||
#include "../sound/sound.h"
|
#include "../sound/sound.h"
|
||||||
#include "../sound/midi.h"
|
#include "../sound/midi.h"
|
||||||
#include "../sound/snd_dbopl.h"
|
|
||||||
#include "../sound/snd_mpu401.h"
|
#include "../sound/snd_mpu401.h"
|
||||||
#include "../video/video.h"
|
#include "../video/video.h"
|
||||||
#include "../video/vid_voodoo.h"
|
#include "../video/vid_voodoo.h"
|
||||||
@@ -92,7 +91,7 @@ static int temp_mouse, temp_joystick;
|
|||||||
|
|
||||||
/* Sound category. */
|
/* Sound category. */
|
||||||
static int temp_sound_card, temp_midi_device, temp_mpu401,
|
static int temp_sound_card, temp_midi_device, temp_mpu401,
|
||||||
temp_GAMEBLASTER, temp_opl3_type, temp_float;
|
temp_opl3_type, temp_float;
|
||||||
|
|
||||||
/* Network category. */
|
/* Network category. */
|
||||||
static int temp_net_type, temp_net_card;
|
static int temp_net_type, temp_net_card;
|
||||||
@@ -192,7 +191,6 @@ settings_init(void)
|
|||||||
temp_sound_card = sound_card_current;
|
temp_sound_card = sound_card_current;
|
||||||
temp_midi_device = midi_device_current;
|
temp_midi_device = midi_device_current;
|
||||||
temp_mpu401 = mpu401_standalone_enable;
|
temp_mpu401 = mpu401_standalone_enable;
|
||||||
temp_GAMEBLASTER = GAMEBLASTER;
|
|
||||||
temp_opl3_type = opl3_type;
|
temp_opl3_type = opl3_type;
|
||||||
temp_float = sound_is_float;
|
temp_float = sound_is_float;
|
||||||
|
|
||||||
@@ -268,7 +266,6 @@ settings_changed(void)
|
|||||||
i = i || (sound_card_current != temp_sound_card);
|
i = i || (sound_card_current != temp_sound_card);
|
||||||
i = i || (midi_device_current != temp_midi_device);
|
i = i || (midi_device_current != temp_midi_device);
|
||||||
i = i || (mpu401_standalone_enable != temp_mpu401);
|
i = i || (mpu401_standalone_enable != temp_mpu401);
|
||||||
i = i || (GAMEBLASTER != temp_GAMEBLASTER);
|
|
||||||
i = i || (opl3_type != temp_opl3_type);
|
i = i || (opl3_type != temp_opl3_type);
|
||||||
i = i || (sound_is_float != temp_float);
|
i = i || (sound_is_float != temp_float);
|
||||||
|
|
||||||
@@ -370,7 +367,6 @@ settings_save(void)
|
|||||||
sound_card_current = temp_sound_card;
|
sound_card_current = temp_sound_card;
|
||||||
midi_device_current = temp_midi_device;
|
midi_device_current = temp_midi_device;
|
||||||
mpu401_standalone_enable = temp_mpu401;
|
mpu401_standalone_enable = temp_mpu401;
|
||||||
GAMEBLASTER = temp_GAMEBLASTER;
|
|
||||||
opl3_type = temp_opl3_type;
|
opl3_type = temp_opl3_type;
|
||||||
sound_is_float = temp_float;
|
sound_is_float = temp_float;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Implementation of the Settings dialog.
|
* Implementation of the Settings dialog.
|
||||||
*
|
*
|
||||||
* Version: @(#)win_settings_sound.h 1.0.3 2018/04/08
|
* Version: @(#)win_settings_sound.h 1.0.4 2018/04/08
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -162,9 +162,6 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
h = GetDlgItem(hdlg, IDC_CONFIGURE_MPU401);
|
h = GetDlgItem(hdlg, IDC_CONFIGURE_MPU401);
|
||||||
EnableWindow(h, (mpu401_standalone_allow() && temp_mpu401) ? TRUE : FALSE);
|
EnableWindow(h, (mpu401_standalone_allow() && temp_mpu401) ? TRUE : FALSE);
|
||||||
|
|
||||||
h = GetDlgItem(hdlg, IDC_CHECK_CMS);
|
|
||||||
SendMessage(h, BM_SETCHECK, temp_GAMEBLASTER, 0);
|
|
||||||
|
|
||||||
h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL);
|
h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL);
|
||||||
SendMessage(h, BM_SETCHECK, temp_opl3_type, 0);
|
SendMessage(h, BM_SETCHECK, temp_opl3_type, 0);
|
||||||
|
|
||||||
@@ -249,9 +246,6 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
h = GetDlgItem(hdlg, IDC_CHECK_MPU401);
|
h = GetDlgItem(hdlg, IDC_CHECK_MPU401);
|
||||||
temp_mpu401 = SendMessage(h, BM_GETCHECK, 0, 0);
|
temp_mpu401 = SendMessage(h, BM_GETCHECK, 0, 0);
|
||||||
|
|
||||||
h = GetDlgItem(hdlg, IDC_CHECK_CMS);
|
|
||||||
temp_GAMEBLASTER = SendMessage(h, BM_GETCHECK, 0, 0);
|
|
||||||
|
|
||||||
h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL);
|
h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL);
|
||||||
temp_opl3_type = SendMessage(h, BM_GETCHECK, 0, 0);
|
temp_opl3_type = SendMessage(h, BM_GETCHECK, 0, 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user