Some fixes, Socket 7 3 V, and the on-board Vibra 16S.

This commit is contained in:
OBattler
2023-10-08 05:21:12 +02:00
parent 4be73f0b7a
commit 684a842699
9 changed files with 331 additions and 13 deletions

View File

@@ -340,6 +340,7 @@ extern const machine_filter_t machine_chipsets[];
extern const machine_t machines[];
extern int bios_only;
extern int machine;
extern void * machine_snd;
/* Core functions. */
extern int machine_count(void);
@@ -371,19 +372,25 @@ extern void machine_close(void);
extern int machine_has_mouse(void);
extern int machine_is_sony(void);
extern uint8_t machine_get_p1_default(void);
extern uint8_t machine_get_p1(void);
extern void machine_set_p1_default(uint8_t val);
extern void machine_set_p1(uint8_t val);
extern void machine_and_p1(uint8_t val);
extern void machine_init_p1(void);
extern uint8_t machine_handle_p1(uint8_t write, uint8_t val);
extern uint32_t machine_get_gpio_default(void);
extern uint32_t machine_get_gpio(void);
extern void machine_set_gpio_default(uint32_t val);
extern void machine_set_gpio(uint32_t val);
extern void machine_and_gpio(uint32_t val);
extern void machine_init_gpio(void);
extern uint32_t machine_handle_gpio(uint8_t write, uint32_t val);
extern uint32_t machine_get_gpio_acpi_default(void);
extern uint32_t machine_get_gpio_acpi(void);
extern void machine_set_gpio_acpi_default(uint32_t val);
extern void machine_set_gpio_acpi(uint32_t val);
extern void machine_and_gpio_acpi(uint32_t val);
extern void machine_init_gpio_acpi(void);
extern uint32_t machine_handle_gpio_acpi(uint8_t write, uint32_t val);
@@ -615,6 +622,7 @@ extern int machine_at_exp8551_init(const machine_t *);
extern int machine_at_gw2katx_init(const machine_t *);
extern int machine_at_thor_init(const machine_t *);
extern int machine_at_mrthor_init(const machine_t *);
extern uint32_t machine_at_endeavor_gpio_handler(uint8_t write, uint32_t val);
extern int machine_at_endeavor_init(const machine_t *);
extern int machine_at_ms5119_init(const machine_t *);
extern int machine_at_pb640_init(const machine_t *);

View File

@@ -71,7 +71,6 @@ typedef struct sb_ct1345_mixer_t {
uint8_t index;
uint8_t regs[256];
} sb_ct1345_mixer_t;
/* SB16 and AWE32 */
@@ -147,6 +146,7 @@ typedef struct sb_t {
uint8_t pnp_rom[512];
uint16_t opl_pnp_addr;
uint16_t gameport_addr;
void *opl_mixer;
void (*opl_mix)(void*, double*, double*);

View File

@@ -81,6 +81,8 @@ extern void inital(void);
extern void givealbuffer(void *buf);
extern void givealbuffer_cd(void *buf);
extern void sb_vibra16s_onboard_relocate_base(uint16_t new_addr, void *priv);
#ifdef EMU_DEVICE_H
/* AdLib and AdLib Gold */
extern const device_t adlib_device;
@@ -128,6 +130,7 @@ extern const device_t sb_pro_v2_device;
extern const device_t sb_pro_mcv_device;
extern const device_t sb_pro_compat_device;
extern const device_t sb_16_device;
extern const device_t sb_vibra16s_onboard_device;
extern const device_t sb_16_pnp_device;
extern const device_t sb_16_compat_device;
extern const device_t sb_16_compat_nompu_device;

View File

@@ -174,7 +174,7 @@ machine_at_zappa_gpio_init(void)
/* 66 MHz: Switch 7 = Off, Switch 8 = On. */
/* Bit 2: No Connect. */
/* Bit 1: No Connect. */
/* Bit 0: 0 = 1.5x multiplier, 1 = 2x multiplier (Switch 6). */
/* Bit 0: 2x multiplier, 1 = 1.5x multiplier (Switch 6). */
/* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */
gpio = 0xffffe6ff;

View File

@@ -41,11 +41,43 @@
#include <86box/fdc.h>
#include <86box/nvr.h>
#include <86box/plat_unused.h>
#include <86box/sound.h>
static void
machine_at_thor_gpio_init(void)
{
uint32_t gpio = 0xffffffff;
/* Register 0x0079: */
/* Bit 7: 0 = Clear password, 1 = Keep password. */
/* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */
/* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */
/* Bit 4: External CPU clock (Switch 8). */
/* Bit 3: External CPU clock (Switch 7). */
/* 50 MHz: Switch 7 = Off, Switch 8 = Off. */
/* 60 MHz: Switch 7 = On, Switch 8 = Off. */
/* 66 MHz: Switch 7 = Off, Switch 8 = On. */
/* Bit 2: 0 = On-board audio absent, 1 = On-board audio present. */
/* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */
/* Bit 0: 0 = Reserved. */
/* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */
gpio = 0xffffe1ff;
if (cpu_busspeed <= 50000000)
gpio |= 0xffff10ff;
else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000))
gpio |= 0xffff18ff;
else if (cpu_busspeed > 60000000)
gpio |= 0xffff00ff;
machine_set_gpio_default(gpio);
}
static void
machine_at_thor_common_init(const machine_t *model, UNUSED(int mr))
{
machine_at_common_init_ex(model, 2);
machine_at_thor_gpio_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0);
@@ -196,6 +228,92 @@ machine_at_mrthor_init(const machine_t *model)
return ret;
}
static void
machine_at_endeavor_gpio_init(void)
{
uint32_t gpio = 0xffffe0cf;
uint16_t addr;
/* Register 0x0078: */
/* Bit 5,4: Vibra 16S base address: 0 = 220h, 1 = 260h, 2 = 240h, 3 = 280h. */
device_context(machine_get_snd_device(machine));
addr = device_get_config_hex16("base");
switch (addr) {
case 0x0220:
gpio |= 0xffff00cf;
break;
case 0x0240:
gpio |= 0xffff00ef;
break;
case 0x0260:
gpio |= 0xffff00df;
break;
case 0x0280:
gpio |= 0xffff00ff;
break;
}
device_context_restore();
/* Register 0x0079: */
/* Bit 7: 0 = Clear password, 1 = Keep password. */
/* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */
/* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */
/* Bit 4: External CPU clock (Switch 8). */
/* Bit 3: External CPU clock (Switch 7). */
/* 50 MHz: Switch 7 = Off, Switch 8 = Off. */
/* 60 MHz: Switch 7 = On, Switch 8 = Off. */
/* 66 MHz: Switch 7 = Off, Switch 8 = On. */
/* Bit 2: 0 = On-board audio absent, 1 = On-board audio present. */
/* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */
/* Bit 0: 0 = 2x multiplier, 1 = 1.5x multiplier (Switch 6). */
/* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */
if (cpu_busspeed <= 50000000)
gpio |= 0xffff10cf;
else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000))
gpio |= 0xffff18cf;
else if (cpu_busspeed > 60000000)
gpio |= 0xffff00cf;
if (sound_card_current[0] == SOUND_INTERNAL)
gpio |= 0xffff04cf;
if (cpu_dmulti <= 1.5)
gpio |= 0xffff01cf;
else
gpio |= 0xffff00cf;
machine_set_gpio_default(gpio);
}
uint32_t
machine_at_endeavor_gpio_handler(uint8_t write, uint32_t val)
{
uint32_t ret = machine_get_gpio_default();
if (write) {
ret &= (val | 0xffff00ff);
ret = (ret & 0xffffffcf) | (val & 0x0000ff30);
if (machine_snd != NULL) switch ((val >> 4) & 0x03) {
case 0x00:
sb_vibra16s_onboard_relocate_base(0x0220, machine_snd);
break;
case 0x01:
sb_vibra16s_onboard_relocate_base(0x0260, machine_snd);
break;
case 0x02:
sb_vibra16s_onboard_relocate_base(0x0240, machine_snd);
break;
case 0x03:
sb_vibra16s_onboard_relocate_base(0x0280, machine_snd);
break;
}
machine_set_gpio(ret);
} else
ret = machine_get_gpio();
return ret;
}
int
machine_at_endeavor_init(const machine_t *model)
{
@@ -209,6 +327,7 @@ machine_at_endeavor_init(const machine_t *model)
return ret;
machine_at_common_init_ex(model, 2);
machine_at_endeavor_gpio_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0);
@@ -220,7 +339,10 @@ machine_at_endeavor_init(const machine_t *model)
pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0);
if (gfxcard[0] == VID_INTERNAL)
device_add(&s3_phoenix_trio64_onboard_pci_device);
device_add(machine_get_vid_device(machine));
if (sound_card_current[0] == SOUND_INTERNAL)
machine_snd = device_add(machine_get_snd_device(machine));
device_add(&keyboard_ps2_intel_ami_pci_device);
device_add(&i430fx_device);
@@ -260,6 +382,41 @@ machine_at_ms5119_init(const machine_t *model)
return ret;
}
static void
machine_at_pb640_gpio_init(void)
{
uint32_t gpio = 0xffffffff;
/* Register 0x0079: */
/* Bit 7: 0 = Clear password, 1 = Keep password. */
/* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */
/* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */
/* Bit 4: External CPU clock (Switch 8). */
/* Bit 3: External CPU clock (Switch 7). */
/* 50 MHz: Switch 7 = Off, Switch 8 = Off. */
/* 60 MHz: Switch 7 = On, Switch 8 = Off. */
/* 66 MHz: Switch 7 = Off, Switch 8 = On. */
/* Bit 2: No Connect. */
/* Bit 1: No Connect. */
/* Bit 0: 2x multiplier, 1 = 1.5x multiplier (Switch 6). */
/* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */
gpio = 0xffffe6ff;
if (cpu_busspeed <= 50000000)
gpio |= 0xffff10ff;
else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000))
gpio |= 0xffff18ff;
else if (cpu_busspeed > 60000000)
gpio |= 0xffff00ff;
if (cpu_dmulti <= 1.5)
gpio |= 0xffff01ff;
else
gpio |= 0xffff00ff;
machine_set_gpio_default(gpio);
}
int
machine_at_pb640_init(const machine_t *model)
{
@@ -272,6 +429,7 @@ machine_at_pb640_init(const machine_t *model)
return ret;
machine_at_common_init_ex(model, 2);
machine_at_pb640_gpio_init();
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0);

View File

@@ -77,7 +77,10 @@ machine_init_ex(int m)
machine_init_gpio();
machine_init_gpio_acpi();
machine_snd = NULL;
is_vpc = 0;
standalone_gameport_type = NULL;
gameport_instance_id = 0;

View File

@@ -9085,7 +9085,7 @@ const machine_t machines[] = {
.chipset = MACHINE_CHIPSET_INTEL_430FX,
.init = machine_at_endeavor_init,
.p1_handler = NULL,
.gpio_handler = NULL,
.gpio_handler = machine_at_endeavor_gpio_handler,
.available_flag = MACHINE_AVAILABLE,
.gpio_acpi_handler = NULL,
.cpu = {
@@ -9114,7 +9114,7 @@ const machine_t machines[] = {
.fdc_device = NULL,
.sio_device = NULL,
.vid_device = &s3_phoenix_trio64_onboard_pci_device,
.snd_device = NULL,
.snd_device = &sb_vibra16s_onboard_device,
.net_device = NULL
},
/* This has an AMIKey-2, which is an updated version of type 'H'. */
@@ -13272,6 +13272,14 @@ static uint32_t machine_gpio;
static uint32_t machine_gpio_acpi_default;
static uint32_t machine_gpio_acpi;
void *machine_snd = NULL;
uint8_t
machine_get_p1_default(void)
{
return machine_p1_default;
}
uint8_t
machine_get_p1(void)
{
@@ -13287,9 +13295,14 @@ machine_set_p1_default(uint8_t val)
void
machine_set_p1(uint8_t val)
{
machine_p1 = machine_p1_default & val;
machine_p1 = val;
}
void
machine_and_p1(uint8_t val)
{
machine_p1 = machine_p1_default & val;
}
uint8_t
machine_handle_p1(uint8_t write, uint8_t val)
@@ -13314,6 +13327,12 @@ machine_init_p1(void)
machine_p1 = machine_p1_default = machines[machine].kbc_p1;
}
uint32_t
machine_get_gpio_default(void)
{
return machine_gpio_default;
}
uint32_t
machine_get_gpio(void)
{
@@ -13328,6 +13347,12 @@ machine_set_gpio_default(uint32_t val)
void
machine_set_gpio(uint32_t val)
{
machine_gpio = val;
}
void
machine_and_gpio(uint32_t val)
{
machine_gpio = machine_gpio_default & val;
}
@@ -13355,6 +13380,12 @@ machine_init_gpio(void)
machine_gpio = machine_gpio_default = machines[machine].gpio;
}
uint32_t
machine_get_gpio_acpi_default(void)
{
return machine_gpio_acpi_default;
}
uint32_t
machine_get_gpio_acpi(void)
{
@@ -13369,6 +13400,12 @@ machine_set_gpio_acpi_default(uint32_t val)
void
machine_set_gpio_acpi(uint32_t val)
{
machine_gpio_acpi = val;
}
void
machine_and_gpio_acpi(uint32_t val)
{
machine_gpio_acpi = machine_gpio_acpi_default & val;
}

View File

@@ -40,6 +40,7 @@
typedef struct pc87306_t {
uint8_t tries;
uint8_t regs[29];
uint8_t gpio[2];
uint16_t gpioba;
int cur_reg;
fdc_t *fdc;
@@ -51,19 +52,33 @@ static void
pc87306_gpio_write(uint16_t port, uint8_t val, void *priv)
{
pc87306_t *dev = (pc87306_t *) priv;
uint8_t shift = ((8 << (port & 1)) - 8);
uint32_t shifted_val = (((uint32_t) val) << shift);
uint32_t ff_mask = ~(((uint32_t) 0xff) << shift);
uint32_t gpio = 0xffff0000;
(void) machine_handle_gpio(1, ff_mask | shifted_val);
dev->gpio[port & 0x0001] = val;
if (port & 0x0001) {
gpio |= ((uint32_t) val) << 8;
gpio |= dev->gpio[0];
} else {
gpio |= ((uint32_t) dev->gpio[1]) << 8;
gpio |= val;
}
(void) machine_handle_gpio(1, gpio);
}
uint8_t
pc87306_gpio_read(uint16_t port, void *priv)
{
const pc87306_t *dev = (pc87306_t *) priv;
uint32_t ret = machine_handle_gpio(0, 0xffffffff);
return machine_handle_gpio(0, 0xffffffff) >> ((8 << (port & 1)) - 8);
if (port & 0x0001)
ret = (ret >> 8) & 0xff;
else
ret &= 0xff;
return ret;
}
static void
@@ -397,7 +412,7 @@ pc87306_read(uint16_t port, void *priv)
}
void
pc87306_reset(void *priv)
pc87306_reset_common(void *priv)
{
pc87306_t *dev = (pc87306_t *) priv;
@@ -432,6 +447,17 @@ pc87306_reset(void *priv)
nvr_wp_set(0, 0, dev->nvr);
}
void
pc87306_reset(void *priv)
{
pc87306_t *dev = (pc87306_t *) priv;
pc87306_gpio_write(0x0000, 0xff, dev);
pc87306_gpio_write(0x0001, 0xff, dev);
pc87306_reset_common(dev);
}
static void
pc87306_close(void *priv)
{
@@ -453,7 +479,9 @@ pc87306_init(UNUSED(const device_t *info))
dev->nvr = device_add(&at_mb_nvr_device);
pc87306_reset(dev);
dev->gpio[0] = dev->gpio[1] = 0xff;
pc87306_reset_common(dev);
io_sethandler(0x02e, 0x0002,
pc87306_read, NULL, NULL, pc87306_write, NULL, NULL, dev);

View File

@@ -854,6 +854,15 @@ sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *priv)
case 0x84:
/* MPU Control register, per the Linux source code. */
/* Bits 2-1: MPU-401 address:
0, 0 = 330h;
0, 1 = Disabled;
1, 0 = 300h;
1, 1 = ???? (Reserved?)
Bit 0: Gameport address:
0, 0 = 200-207h;
0, 1 = Disabled
*/
if (sb->mpu != NULL) {
if ((val & 0x06) == 0x00)
mpu401_change_addr(sb->mpu, 0x330);
@@ -862,6 +871,12 @@ sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *priv)
else if ((val & 0x06) == 0x02)
mpu401_change_addr(sb->mpu, 0);
}
sb->gameport_addr = 0;
gameport_remap(sb->gameport, 0);
if (!(val & 0x01)) {
sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, 0x200);
}
break;
default:
@@ -1055,6 +1070,8 @@ sb_ct1745_mixer_read(uint16_t addr, void *priv)
else
ret = 0x06; /* Should never happen. */
}
if (!sb->gameport_addr)
ret |= 0x01;
break;
case 0x90:
@@ -1375,6 +1392,45 @@ sb_16_reply_mca_write(int port, uint8_t val, void *priv)
sb_dsp_setdma16(&sb->dsp, high_dma);
}
void
sb_vibra16s_onboard_relocate_base(uint16_t new_addr, void *priv)
{
sb_t *sb = (sb_t *) priv;
uint16_t addr = sb->dsp.sb_addr;
io_removehandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 4, 0x0002,
sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL,
sb);
sb_dsp_setaddr(&sb->dsp, 0);
addr = new_addr;
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 4, 0x0002,
sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL,
sb);
sb_dsp_setaddr(&sb->dsp, addr);
}
static void
sb_16_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
{
@@ -1968,6 +2024,8 @@ sb_16_init(UNUSED(const device_t *info))
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
sb->gameport_addr = 0x200;
return sb;
}
@@ -2003,6 +2061,8 @@ sb_16_reply_mca_init(UNUSED(const device_t *info))
sb->pos_regs[0] = 0x38;
sb->pos_regs[1] = 0x51;
sb->gameport_addr = 0x200;
return sb;
}
@@ -2045,6 +2105,7 @@ sb_16_pnp_init(UNUSED(const device_t *info))
mpu401_change_addr(sb->mpu, 0);
ide_remove_handlers(2);
sb->gameport_addr = 0;
gameport_remap(sb->gameport, 0);
return sb;
@@ -2069,6 +2130,8 @@ sb_16_compat_init(const device_t *info)
mpu401_init(sb->mpu, 0, 0, M_UART, info->local);
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
sb->gameport_addr = 0x200;
return sb;
}
@@ -2165,6 +2228,8 @@ sb_awe32_init(UNUSED(const device_t *info))
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
sb->gameport_addr = 0x200;
return sb;
}
@@ -2264,6 +2329,8 @@ sb_awe32_pnp_init(const device_t *info)
emu8k_change_addr(&sb->emu8k, 0);
sb->gameport_addr = 0;
gameport_remap(sb->gameport, 0);
return sb;
@@ -3609,6 +3676,20 @@ const device_t sb_16_device = {
.config = sb_16_config
};
const device_t sb_vibra16s_onboard_device = {
.name = "Sound Blaster Vibra 16S (On-Board)",
.internal_name = "sb_vibra16s_onboard",
.flags = DEVICE_ISA | DEVICE_AT,
.local = 0,
.init = sb_16_init,
.close = sb_close,
.reset = NULL,
{ .available = NULL },
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_16_config
};
const device_t sb_16_reply_mca_device = {
.name = "Sound Blaster 16 Reply MCA",
.internal_name = "sb16_reply_mca",