diff --git a/src/devices/machine/sis7018_audio.cpp b/src/devices/machine/sis7018_audio.cpp index 8bb6eab06ed..afcbfb13efd 100644 --- a/src/devices/machine/sis7018_audio.cpp +++ b/src/devices/machine/sis7018_audio.cpp @@ -6,7 +6,7 @@ SiS 7018 Audio device (AC97 complaint) TODO: - Stub interface, to be improved; -- Reportedly based off Trident 4DWave technology; +- Reportedly based off Trident 4DWave technology, some registers effectively matches up; **************************************************************************************************/ @@ -32,7 +32,7 @@ DEFINE_DEVICE_TYPE(SIS7018_AUDIO, sis7018_audio_device, "sis7018_audio", "SiS 70 sis7018_audio_device::sis7018_audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : pci_device(mconfig, SIS7018_AUDIO, tag, owner, clock) - + , m_joy(*this, "pc_joy") { // 0x040100 - Multimedia device, audio device (vendor specific i/f) // 0x01 - Rev 1 @@ -41,15 +41,29 @@ sis7018_audio_device::sis7018_audio_device(const machine_config &mconfig, const void sis7018_audio_device::device_add_mconfig(machine_config &config) { - + PC_JOY(config, m_joy); + // ... } +// NOTE: prefer using Trident naming if a register is there too. void sis7018_audio_device::config_map(address_map &map) { pci_device::config_map(map); - // map(0x003e, 0x003f) max latency min=0x02, max=0x18 - map(0x40, 0xe3).rw(FUNC(sis7018_audio_device::unmap_log_r), FUNC(sis7018_audio_device::unmap_log_w)); + map(0x48, 0xe3).rw(FUNC(sis7018_audio_device::unmap_log_r), FUNC(sis7018_audio_device::unmap_log_w)); + + map(0x44, 0x44).lrw8( + NAME([this] (offs_t offset) { + return m_legacy_io_base; + }), + NAME([this] (offs_t offset, u8 data) { + LOGIO("PCI $44: Legacy I/O base %02x\n", data); + m_legacy_io_base = data; + remap_cb(); + }) + ); + // 0x45 Legacy DMA Decoding + // 0x46 PM_CFG Power Management Config (Legacy Control on Trident) // PMC capability identifier map(0xdc, 0xdf).r(FUNC(sis7018_audio_device::pmc_id_r)); @@ -82,19 +96,14 @@ void sis7018_audio_device::io_map(address_map &map) } -void sis7018_audio_device::map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space, - uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) -{ -// io_space->install_device(0, 0x03ff, *this, &sis7018_audio_device::io_map); - // TODO: legacy handling, including game port -} - void sis7018_audio_device::device_start() { pci_device::device_start(); add_map(256, M_IO, FUNC(sis7018_audio_device::io_map)); // not explicitly stated, assume 4096 size from the MEM decoding add_map(4096, M_MEM, FUNC(sis7018_audio_device::memory_map)); + + // TODO: PCI regs 0x3e/0x3f max_lat = 0x18, min_gnt = 0x02 } @@ -104,10 +113,38 @@ void sis7018_audio_device::device_reset() command = 0x0000; status = 0x0000; - // INTB# - intr_pin = 2; + // INTA# + intr_pin = 1; // TODO: can be written to with $46=1 subsystem_id = 0x10397018; + + m_legacy_io_base = 0xe2; // 0xf0 on Trident + remap_cb(); +} + +void sis7018_audio_device::map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space, + uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) +{ + // if(BIT(m_legacy_io_base, 7)) + // const u16 mpu401base_io_addr = 0x300 | (BIT(m_legacy_io_base, 6) ? 0x00 : 0x30); + + if (BIT(m_legacy_io_base, 5)) + { + const u16 gamebase_io_addr = 0x200 | (BIT(m_legacy_io_base, 4) << 3); + io_space->install_device(gamebase_io_addr, gamebase_io_addr | 0x7, *this, &sis7018_audio_device::gameport_map); + } + + // if(BIT(m_legacy_io_base, 3)) + // const u16 adlibbase_io_addr = 0x388 | (BIT(m_legacy_io_base, 2) << 2); + + // if(BIT(m_legacy_io_base, 1)) + // const u16 sbbase_io_addr = 0x200 | (BIT(m_legacy_io_base, 0) ? 0x20 : 0x40); +} + +// 200h / 208h +void sis7018_audio_device::gameport_map(address_map &map) +{ + map(0x00, 0x07).rw(m_joy, FUNC(pc_joy_device::joy_port_r), FUNC(pc_joy_device::joy_port_w)); } /* @@ -116,11 +153,11 @@ void sis7018_audio_device::device_reset() u8 sis7018_audio_device::unmap_log_r(offs_t offset) { - LOGTODO("AUDIO Unemulated [%02x] R\n", offset + 0x40); + LOGTODO("AUDIO Unemulated [%02x] R\n", offset + 0x48); return 0; } void sis7018_audio_device::unmap_log_w(offs_t offset, u8 data) { - LOGTODO("AUDIO Unemulated [%02x] %02x W\n", offset + 0x40, data); + LOGTODO("AUDIO Unemulated [%02x] %02x W\n", offset + 0x48, data); } diff --git a/src/devices/machine/sis7018_audio.h b/src/devices/machine/sis7018_audio.h index d72794e05c6..5f50316015f 100644 --- a/src/devices/machine/sis7018_audio.h +++ b/src/devices/machine/sis7018_audio.h @@ -8,6 +8,8 @@ #include "pci.h" +#include "bus/pc_joy/pc_joy.h" + class sis7018_audio_device : public pci_device { public: @@ -31,14 +33,20 @@ protected: void io_map(address_map &map); private: + required_device m_joy; + virtual u8 capptr_r() override; + void gameport_map(address_map &map); + u32 pmc_id_r(); // void pmc_status_r(); // u32 pmc_control(offs_t offset, u32 data, u32 mem_mask = ~0); u8 unmap_log_r(offs_t offset); void unmap_log_w(offs_t offset, u8 data); + + u8 m_legacy_io_base = 0; }; DECLARE_DEVICE_TYPE(SIS7018_AUDIO, sis7018_audio_device)