diff options
| author | 2024-01-26 11:11:34 +0100 | |
|---|---|---|
| committer | 2024-02-10 18:52:45 +0100 | |
| commit | d7e9314388de36716e19cc11493a070d4131c503 (patch) | |
| tree | 74be7cb7de453b1e6f8b1c196e28d6510508e7e7 /src/devices/cpu/sh | |
| parent | a1e5795e34b201210b00e90c8058fcd6dd1c544e (diff) | |
mu5/15: split the lcd
sh7042: Start fleshing it up
swx00: Same
mu15: Added
swp30: readd the scount increment
Diffstat (limited to 'src/devices/cpu/sh')
| -rw-r--r-- | src/devices/cpu/sh/sh7042.cpp | 21 | ||||
| -rw-r--r-- | src/devices/cpu/sh/sh7042.h | 12 | ||||
| -rw-r--r-- | src/devices/cpu/sh/sh_adc.cpp | 59 | ||||
| -rw-r--r-- | src/devices/cpu/sh/sh_adc.h | 67 | ||||
| -rw-r--r-- | src/devices/cpu/sh/sh_dmac.h | 50 |
5 files changed, 208 insertions, 1 deletions
diff --git a/src/devices/cpu/sh/sh7042.cpp b/src/devices/cpu/sh/sh7042.cpp index 7c3f7d2fba1..4c195e787a2 100644 --- a/src/devices/cpu/sh/sh7042.cpp +++ b/src/devices/cpu/sh/sh7042.cpp @@ -9,8 +9,18 @@ DEFINE_DEVICE_TYPE(SH7042, sh7042_device, "sh7042", "Hitachi SH-2 (SH7042)") sh7042_device::sh7042_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - sh2_device(mconfig, SH7042, tag, owner, clock, CPU_TYPE_SH2, address_map_constructor(FUNC(sh7042_device::map), this), 32, 0xffffffff) + sh2_device(mconfig, SH7042, tag, owner, clock, CPU_TYPE_SH2, address_map_constructor(FUNC(sh7042_device::map), this), 32, 0xffffffff), + m_adc(*this, "adc"), + m_read_adc(*this, 0) { + for(unsigned int i=0; i != m_read_adc.size(); i++) + m_read_adc[i].bind().set([this, i]() { return adc_default(i); }); +} + +u16 sh7042_device::adc_default(int adc) +{ + logerror("read of un-hooked adc %d\n", adc); + return 0; } void sh7042_device::device_start() @@ -25,5 +35,14 @@ void sh7042_device::device_reset() void sh7042_device::map(address_map &map) { + map(0xffff83e0, 0xffff83e0).rw(m_adc, FUNC(sh_adc_device::adcsr_r), FUNC(sh_adc_device::adcsr_w)); + map(0xffff83e1, 0xffff83e1).rw(m_adc, FUNC(sh_adc_device::adcr_r), FUNC(sh_adc_device::adcr_w)); + map(0xffff83f0, 0xffff83ff).r(m_adc, FUNC(sh_adc_device::addr_r)); + map(0xfffff000, 0xffffffff).ram(); } + +void sh7042_device::device_add_mconfig(machine_config &config) +{ + SH_ADC(config, m_adc, *this); +} diff --git a/src/devices/cpu/sh/sh7042.h b/src/devices/cpu/sh/sh7042.h index b47242013b4..7cf319f3ce4 100644 --- a/src/devices/cpu/sh/sh7042.h +++ b/src/devices/cpu/sh/sh7042.h @@ -9,17 +9,29 @@ #pragma once #include "sh2.h" +#include "sh_adc.h" class sh7042_device : public sh2_device { public: sh7042_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + template<int Port> auto read_adc() { return m_read_adc[Port].bind(); } + + u16 do_read_adc(int port) { return m_read_adc[port](); } + protected: virtual void device_start() override; virtual void device_reset() override; + virtual void device_add_mconfig(machine_config &config) override; private: + required_device<sh_adc_device> m_adc; + + devcb_read16::array<8> m_read_adc; + + u16 adc_default(int adc); + void map(address_map &map); }; diff --git a/src/devices/cpu/sh/sh_adc.cpp b/src/devices/cpu/sh/sh_adc.cpp new file mode 100644 index 00000000000..40f9546dc15 --- /dev/null +++ b/src/devices/cpu/sh/sh_adc.cpp @@ -0,0 +1,59 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "sh_adc.h" +#include "sh7042.h" + +DEFINE_DEVICE_TYPE(SH_ADC, sh_adc_device, "sh_adc", "SH7042 ADC") + +sh_adc_device::sh_adc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, SH_ADC, tag, owner, clock), + m_cpu(*this, finder_base::DUMMY_TAG), + m_adcsr(0), m_adcr(0) +{ +} + +u16 sh_adc_device::addr_r(offs_t offset) +{ + logerror("addr16_r %d %03x\n", offset, m_addr[offset]); + return m_addr[offset]; +} + +u8 sh_adc_device::adcsr_r() +{ + logerror("adcsr_r %02x\n", m_adcsr); + return m_adcsr; +} + +u8 sh_adc_device::adcr_r() +{ + logerror("adcr_r %02x\n", m_adcr); + return m_adcr; +} + +void sh_adc_device::adcsr_w(u8 data) +{ + logerror("adcsr_w %02x\n", data); + // u8 prev = m_adcsr; + m_adcsr = (data & 0x7f) | (m_adcsr & data & CSR_ADF); +} + +void sh_adc_device::adcr_w(u8 data) +{ + logerror("adcr_w %02x\n", data); + m_adcr = data; +} + +void sh_adc_device::device_start() +{ + save_item(NAME(m_addr)); + save_item(NAME(m_adcsr)); + save_item(NAME(m_adcr)); +} + +void sh_adc_device::device_reset() +{ + memset(m_addr, 0, sizeof(m_addr)); + m_adcsr = m_adcr = 0; +} diff --git a/src/devices/cpu/sh/sh_adc.h b/src/devices/cpu/sh/sh_adc.h new file mode 100644 index 00000000000..4b8c371c31d --- /dev/null +++ b/src/devices/cpu/sh/sh_adc.h @@ -0,0 +1,67 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_adc.h + + SH Analog to Digital Converter subsystem + +***************************************************************************/ + +#ifndef MAME_CPU_SH_SH_ADC_H +#define MAME_CPU_SH_SH_ADC_H + +#pragma once + +// To generalize eventually +class sh7042_device; + +class sh_adc_device : public device_t { +public: + sh_adc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + + template <typename T> sh_adc_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu) + : sh_adc_device(mconfig, tag, owner) + { + set_info(cpu); + } + + template<typename T> void set_info(T &&cpu) { m_cpu.set_tag(std::forward<T>(cpu)); } + + u16 addr_r(offs_t offset); + u8 adcsr_r(); + u8 adcr_r(); + void adcsr_w(u8 data); + void adcr_w(u8 data); + +protected: + enum { + CSR_ADF = 0x80, + CSR_ADIE = 0x40, + CSR_ADST = 0x20, + CSR_CKS = 0x10, + CSR_GRP = 0x08, + CSR_CHAN = 0x07 + }; + + enum { + CR_PWR = 0x40, + CR_TRGS = 0x30, + CR_SCAN = 0x08, + CR_SIM = 0x04, + CR_BUF = 0x03 + }; + + required_device<sh7042_device> m_cpu; + + uint16_t m_addr[8]; + uint8_t m_adcsr, m_adcr; + + + virtual void device_start() override; + virtual void device_reset() override; +}; + +DECLARE_DEVICE_TYPE(SH_ADC, sh_adc_device) + +#endif diff --git a/src/devices/cpu/sh/sh_dmac.h b/src/devices/cpu/sh/sh_dmac.h new file mode 100644 index 00000000000..25071765428 --- /dev/null +++ b/src/devices/cpu/sh/sh_dmac.h @@ -0,0 +1,50 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_dma.h + + SH DMA controller + +***************************************************************************/ + +#ifndef MAME_CPU_SH_SH_DMA_H +#define MAME_CPU_SH_SH_DMA_H + +#pragma once + +// To generalize eventually +class sh7042_device; + +class sh_dma_device : public device_t { +public: + sh_dma_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + + template <typename T> sh_dma_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu) + : sh_dma_device(mconfig, tag, owner) + { + set_info(cpu); + } + + template<typename T> void set_info(T &&cpu) { m_cpu.set_tag(std::forward<T>(cpu)); } + + u16 addr_r(offs_t offset); + u8 dmasr_r(); + u8 dmar_r(); + void dmasr_w(u8 data); + void dmar_w(u8 data); + +protected: + required_device<sh7042_device> m_cpu; + + uint16_t m_addr[8]; + uint8_t m_dmasr, m_dmar; + + + virtual void device_start() override; + virtual void device_reset() override; +}; + +DECLARE_DEVICE_TYPE(SH_DMA, sh_dma_device) + +#endif |
