diff options
-rw-r--r-- | scripts/src/machine.lua | 11 | ||||
-rw-r--r-- | scripts/src/sound.lua | 14 | ||||
-rw-r--r-- | src/devices/machine/cat702.cpp (renamed from src/mame/sony/cat702.cpp) | 141 | ||||
-rw-r--r-- | src/devices/machine/cat702.h (renamed from src/mame/sony/cat702.h) | 44 | ||||
-rw-r--r-- | src/devices/machine/intelfsh.cpp | 104 | ||||
-rw-r--r-- | src/devices/machine/intelfsh.h | 146 | ||||
-rw-r--r-- | src/devices/sound/dac3350a.cpp | 332 | ||||
-rw-r--r-- | src/devices/sound/dac3350a.h | 46 | ||||
-rw-r--r-- | src/devices/sound/mas3507d.cpp | 41 | ||||
-rw-r--r-- | src/devices/sound/mas3507d.h | 4 | ||||
-rw-r--r-- | src/mame/misc/xtom3d.cpp | 82 | ||||
-rw-r--r-- | src/mame/misc/xtom3d_piu10.cpp | 203 | ||||
-rw-r--r-- | src/mame/misc/xtom3d_piu10.h | 53 | ||||
-rw-r--r-- | src/mame/sony/zn.h | 2 |
14 files changed, 1036 insertions, 187 deletions
diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua index 5ca9f9d977d..d38de5d4293 100644 --- a/scripts/src/machine.lua +++ b/scripts/src/machine.lua @@ -5354,3 +5354,14 @@ if (MACHINES["UPD7261"]~=null) then MAME_DIR .. "src/devices/machine/upd7261.h", } end + +--------------------------------------------------- +-- +--@src/devices/machine/cat702.h,MACHINES["CAT702"] = true +--------------------------------------------------- +if (MACHINES["CAT702"]~=null) then + files { + MAME_DIR .. "src/devices/machine/cat702.cpp", + MAME_DIR .. "src/devices/machine/cat702.h", + } +end diff --git a/scripts/src/sound.lua b/scripts/src/sound.lua index b53cd0b10a8..ccbab43419c 100644 --- a/scripts/src/sound.lua +++ b/scripts/src/sound.lua @@ -551,6 +551,20 @@ end --------------------------------------------------- +-- Micronas DAC 3550A Stereo Audio DAC +--@src/devices/sound/dac3350a.h,SOUNDS["DAC3350A"] = true +--------------------------------------------------- + +if (SOUNDS["DAC3350A"]~=null) then + files { + MAME_DIR .. "src/devices/sound/dac3350a.cpp", + MAME_DIR .. "src/devices/sound/dac3350a.h", + } +end + + + +--------------------------------------------------- -- MEA8000 Voice Synthesizer --@src/devices/sound/mea8000.h,SOUNDS["MEA8000"] = true --------------------------------------------------- diff --git a/src/mame/sony/cat702.cpp b/src/devices/machine/cat702.cpp index 067be2f0edc..80e548bb871 100644 --- a/src/mame/sony/cat702.cpp +++ b/src/devices/machine/cat702.cpp @@ -87,21 +87,24 @@ #include "emu.h" #include "cat702.h" +static constexpr uint8_t initial_sbox[8] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x7f }; + DEFINE_DEVICE_TYPE(CAT702, cat702_device, "cat702", "CAT702") +DEFINE_DEVICE_TYPE(CAT702_PIU, cat702_piu_device, "cat702_piu", "CAT702_PIU") -cat702_device::cat702_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, CAT702, tag, owner, clock), - m_region(*this, DEVICE_SELF), +cat702_device_base::cat702_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, type, tag, owner, clock), m_select(1), m_clock(1), m_datain(1), m_state(0), m_bit(0), - m_dataout_handler(*this) + m_dataout_handler(*this), + m_region(*this, DEVICE_SELF) { } -void cat702_device::device_start() +void cat702_device_base::device_start() { memset(m_transform, 0xff, sizeof(m_transform)); @@ -132,55 +135,70 @@ void cat702_device::device_start() #if 0 static int c_linear(uint8_t x, uint8_t a) { - int i; - uint8_t r; x &= a; - r = 0; - for(i=0; i<8; i++) - if(x & (1<<i)) + uint8_t r = 0; + for (int i = 0; i < 8; i++) + { + if (BIT(x, i)) r = !r; + } return r; } #endif // Derive the sbox xor mask for a given input and select bit -uint8_t cat702_device::compute_sbox_coef(int sel, int bit) +uint8_t cat702_device_base::compute_sbox_coef(int sel, int bit) { - if(!sel) + if (!sel) return m_transform[bit]; - uint8_t r = compute_sbox_coef((sel-1) & 7, (bit-1) & 7); - r = (r << 1)|(((r >> 7)^(r >> 6)) & 1); - if(bit != 7) + uint8_t r = compute_sbox_coef((sel - 1) & 7, (bit - 1) & 7); + r = (r << 1) | (BIT(r, 7) ^ BIT(r, 6)); + if (bit != 7) return r; return r ^ compute_sbox_coef(sel, 0); } // Apply the sbox for a input 0 bit -void cat702_device::apply_bit_sbox(int sel) +void cat702_device_base::apply_bit_sbox(int sel) { - int i; uint8_t r = 0; - for(i=0; i<8; i++) - if(m_state & (1<<i)) + for (int i = 0; i < 8; i++) + { + if (BIT(m_state, i)) r ^= compute_sbox_coef(sel, i); - + } m_state = r; } // Apply a sbox -void cat702_device::apply_sbox(const uint8_t *sbox) +void cat702_device_base::apply_sbox(const uint8_t *sbox) { - int i; uint8_t r = 0; - for(i=0; i<8; i++) - if(m_state & (1<<i)) + for (int i = 0; i < 8; i++) + { + if (BIT(m_state, i)) r ^= sbox[i]; - + } m_state = r; } +void cat702_device_base::write_datain(int state) +{ + m_datain = state; +} + + +/////////////// + + +cat702_device::cat702_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + cat702_device_base(mconfig, CAT702, tag, owner, clock) +{ +} + + void cat702_device::write_select(int state) { if (m_select != state) @@ -201,8 +219,6 @@ void cat702_device::write_select(int state) void cat702_device::write_clock(int state) { - static const uint8_t initial_sbox[8] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x7f }; - if (!state && m_clock && !m_select) { if (m_bit==0) @@ -212,7 +228,7 @@ void cat702_device::write_clock(int state) } // Compute the output and change the state - m_dataout_handler(((m_state >> m_bit) & 1) != 0); + m_dataout_handler(BIT(m_state, m_bit)); } if (state && !m_clock && !m_select) @@ -220,14 +236,75 @@ void cat702_device::write_clock(int state) if (!m_datain) apply_bit_sbox(m_bit); - m_bit++; - m_bit&=7; + m_bit = (m_bit + 1) & 7; } m_clock = state; } -void cat702_device::write_datain(int state) + +/////////////// + +cat702_piu_device::cat702_piu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + cat702_device_base(mconfig, CAT702_PIU, tag, owner, clock) { - m_datain = state; +} + +void cat702_piu_device::write_select(int state) +{ + if (m_select != state) + { + if (!state) + { + m_state = 0xfc; + m_bit = 0; + + apply_sbox(initial_sbox); + } + else + { + m_dataout_handler(1); + } + + m_select = state; + } +} + +void cat702_piu_device::write_clock(int state) +{ + /* + Pump It Up uses a CAT702 but accesses it directly and in a way that + seems conflicting with how the ZN uses it through the PS1's SIO. + + This is the sequence performed with clock and data lines write and read data: + write unkbit 0 + write unkbit 1 + write select 0 + loop for all bits that need to be transferred: + write clk = 0, data = x + write clk = x, data = 0/1 + write clk = 1, data = x + read data + write select 1 + + Modifying the old code to work with PIU breaks ZN games. + */ + if (state && !m_clock && !m_select) + { + // Compute the output and change the state + if (!m_datain) + apply_bit_sbox(m_bit); + + m_bit = (m_bit + 1) & 7; + + if (m_bit == 0) + { + // Apply the initial sbox + apply_sbox(initial_sbox); + } + + m_dataout_handler(BIT(m_state, m_bit)); + } + + m_clock = state; } diff --git a/src/mame/sony/cat702.h b/src/devices/machine/cat702.h index febddbc1d45..306ca94abf5 100644 --- a/src/mame/sony/cat702.h +++ b/src/devices/machine/cat702.h @@ -2,37 +2,31 @@ // copyright-holders:smf /* CAT702 security chip */ -#ifndef MAME_SONY_CAT702_H -#define MAME_SONY_CAT702_H +#ifndef MAME_MACHINE_CAT702_H +#define MAME_MACHINE_CAT702_H #pragma once DECLARE_DEVICE_TYPE(CAT702, cat702_device) +DECLARE_DEVICE_TYPE(CAT702_PIU, cat702_piu_device) -class cat702_device : public device_t +class cat702_device_base : public device_t { public: - cat702_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - // configuration helpers auto dataout_handler() { return m_dataout_handler.bind(); } - void write_select(int state); void write_datain(int state); - void write_clock(int state); protected: + cat702_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + virtual void device_start() override; -private: - uint8_t compute_sbox_coef(int sel, int bit); void apply_bit_sbox(int sel); void apply_sbox(const uint8_t *sbox); - optional_memory_region m_region; - uint8_t m_transform[8]; - int m_select; int m_clock; int m_datain; @@ -40,6 +34,30 @@ private: uint8_t m_bit; devcb_write_line m_dataout_handler; + +private: + uint8_t compute_sbox_coef(int sel, int bit); + + optional_memory_region m_region; + uint8_t m_transform[8]; +}; + +class cat702_device : public cat702_device_base +{ +public: + cat702_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + void write_select(int state); + void write_clock(int state); +}; + +class cat702_piu_device : public cat702_device_base +{ +public: + cat702_piu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + void write_select(int state); + void write_clock(int state); }; -#endif // MAME_SONY_CAT702_H +#endif // MAME_MACHINE_CAT702_H diff --git a/src/devices/machine/intelfsh.cpp b/src/devices/machine/intelfsh.cpp index 93f558b3d3c..d4a417567e1 100644 --- a/src/devices/machine/intelfsh.cpp +++ b/src/devices/machine/intelfsh.cpp @@ -82,54 +82,56 @@ enum //************************************************************************** // device type definition -DEFINE_DEVICE_TYPE(INTEL_28F016S5, intel_28f016s5_device, "intel_28f016s5", "Intel 28F016S5 Flash") -DEFINE_DEVICE_TYPE(SHARP_LH28F016S, sharp_lh28f016s_device, "sharp_lh28f016s", "Sharp LH28F016S Flash") -DEFINE_DEVICE_TYPE(SHARP_LH28F016S_16BIT, sharp_lh28f016s_16bit_device, "sharp_lh28f016s_16bit", "Sharp LH28F016S Flash (16-bit)") -DEFINE_DEVICE_TYPE(ATMEL_29C010, atmel_29c010_device, "atmel_29c010", "Atmel 29C010 Flash") -DEFINE_DEVICE_TYPE(AMD_29F010, amd_29f010_device, "amd_29f010", "AMD 29F010 Flash") -DEFINE_DEVICE_TYPE(AMD_29F040, amd_29f040_device, "amd_29f040", "AMD 29F040 Flash") -DEFINE_DEVICE_TYPE(AMD_29F080, amd_29f080_device, "amd_29f080", "AMD 29F080 Flash") -DEFINE_DEVICE_TYPE(AMD_29F400T, amd_29f400t_device, "amd_29f400t", "AMD 29F400T Flash") -DEFINE_DEVICE_TYPE(AMD_29F800T, amd_29f800t_device, "amd_29f800t", "AMD 29F800T Flash") -DEFINE_DEVICE_TYPE(AMD_29F800B_16BIT, amd_29f800b_16bit_device, "amd_29f800b_16bit", "AMD 29F800B Flash (16-bit)") -DEFINE_DEVICE_TYPE(AMD_29LV200T, amd_29lv200t_device, "amd_29lv200t", "AMD 29LV200T Flash") -DEFINE_DEVICE_TYPE(FUJITSU_29F160TE, fujitsu_29f160te_device, "mbm29f160te", "Fujitsu MBM29F160TE Flash") -DEFINE_DEVICE_TYPE(FUJITSU_29F160TE_16BIT,fujitsu_29f160te_16bit_device,"mbm29f160te_16bit", "Fujitsu MBM29F160TE Flash (16-bit)") -DEFINE_DEVICE_TYPE(FUJITSU_29F016A, fujitsu_29f016a_device, "mbm29f016a", "Fujitsu MBM29F016A Flash") -DEFINE_DEVICE_TYPE(FUJITSU_29DL164BD, fujitsu_29dl164bd_device, "mbm29dl164bd", "Fujitsu MBM29DL164BD Flash") -DEFINE_DEVICE_TYPE(FUJITSU_29LV002TC, fujitsu_29lv002tc_device, "mbm29lv002tc", "Fujitsu MBM29LV002TC Flash") -DEFINE_DEVICE_TYPE(FUJITSU_29LV800B, fujitsu_29lv800b_device, "mbm29lv800b", "Fujitsu MBM29LV800B Flash") -DEFINE_DEVICE_TYPE(INTEL_E28F400B, intel_e28f400b_device, "intel_e28f400b", "Intel E28F400B Flash") -DEFINE_DEVICE_TYPE(MACRONIX_29F008TC, macronix_29f008tc_device, "macronix_29f008tc", "Macronix 29F008TC Flash") -DEFINE_DEVICE_TYPE(MACRONIX_29L001MC, macronix_29l001mc_device, "macronix_29l001mc", "Macronix 29L001MC Flash") -DEFINE_DEVICE_TYPE(MACRONIX_29LV160TMC, macronix_29lv160tmc_device, "macronix_29lv160tmc", "Macronix 29LV160TMC Flash") -DEFINE_DEVICE_TYPE(TMS_29F040, tms_29f040_device, "tms_29f040", "Texas Instruments 29F040 Flash") - -DEFINE_DEVICE_TYPE(PANASONIC_MN63F805MNP, panasonic_mn63f805mnp_device, "panasonic_mn63f805mnp", "Panasonic MN63F805MNP Flash") -DEFINE_DEVICE_TYPE(SANYO_LE26FV10N1TS, sanyo_le26fv10n1ts_device, "sanyo_le26fv10n1ts", "Sanyo LE26FV10N1TS Flash") -DEFINE_DEVICE_TYPE(SST_28SF040, sst_28sf040_device, "sst_28sf040", "SST 28SF040 Flash") -DEFINE_DEVICE_TYPE(SST_39SF040, sst_39sf040_device, "sst_39sf040", "SST 39SF040 Flash") -DEFINE_DEVICE_TYPE(SST_39VF020, sst_39vf020_device, "sst_39vf020", "SST 39VF020 Flash") -DEFINE_DEVICE_TYPE(SST_49LF020, sst_49lf020_device, "sst_49lf020", "SST 49LF020 Flash") - -DEFINE_DEVICE_TYPE(SHARP_LH28F400, sharp_lh28f400_device, "sharp_lh28f400", "Sharp LH28F400 Flash") -DEFINE_DEVICE_TYPE(INTEL_E28F008SA, intel_e28f008sa_device, "intel_e28f008sa", "Intel E28F008SA Flash") -DEFINE_DEVICE_TYPE(INTEL_TE28F160, intel_te28f160_device, "intel_te28f160", "Intel TE28F160 Flash") -DEFINE_DEVICE_TYPE(SHARP_LH28F160S3, sharp_lh28f160s3_device, "sharp_lh28f160s3", "Sharp LH28F160S3 Flash") -DEFINE_DEVICE_TYPE(INTEL_TE28F320, intel_te28f320_device, "intel_te28f320", "Intel TE28F320 Flash") -DEFINE_DEVICE_TYPE(SHARP_LH28F320BF, sharp_lh28f320bf_device, "sharp_lh28f320bf", "Sharp LH28F320BFHE-PBTL Flash") -DEFINE_DEVICE_TYPE(INTEL_28F320J3D, intel_28f320j3d_device, "intel_28f320j3d", "Intel 28F320J3D Flash") -DEFINE_DEVICE_TYPE(SPANSION_S29GL064S, spansion_s29gl064s_device, "spansion_s29gl064s", "Spansion / Cypress S29GL064S Flash") -DEFINE_DEVICE_TYPE(INTEL_28F320J5, intel_28f320j5_device, "intel_28f320j5", "Intel 28F320J5 Flash") -DEFINE_DEVICE_TYPE(INTEL_28F640J5, intel_28f640j5_device, "intel_28f640j5", "Intel 28F640J5 Flash") - -DEFINE_DEVICE_TYPE(SST_39VF400A, sst_39vf400a_device, "sst_39vf400a", "SST 39VF400A Flash") - -DEFINE_DEVICE_TYPE(ATMEL_49F4096, atmel_49f4096_device, "atmel_49f4096", "Atmel AT49F4096 Flash") - -DEFINE_DEVICE_TYPE(CAT28F020, cat28f020_device, "cat28f020", "CSI CAT28F020 Flash") - -DEFINE_DEVICE_TYPE(TC58FVT800, tc58fvt800_device, "tc58fvt800", "Toshiba TC58FVT800 Flash") +DEFINE_DEVICE_TYPE(INTEL_28F016S5, intel_28f016s5_device, "intel_28f016s5", "Intel 28F016S5 Flash") +DEFINE_DEVICE_TYPE(SHARP_LH28F016S, sharp_lh28f016s_device, "sharp_lh28f016s", "Sharp LH28F016S Flash") +DEFINE_DEVICE_TYPE(SHARP_LH28F016S_16BIT, sharp_lh28f016s_16bit_device, "sharp_lh28f016s_16bit", "Sharp LH28F016S Flash (16-bit)") +DEFINE_DEVICE_TYPE(ATMEL_29C010, atmel_29c010_device, "atmel_29c010", "Atmel 29C010 Flash") +DEFINE_DEVICE_TYPE(AMD_29F010, amd_29f010_device, "amd_29f010", "AMD 29F010 Flash") +DEFINE_DEVICE_TYPE(AMD_29F040, amd_29f040_device, "amd_29f040", "AMD 29F040 Flash") +DEFINE_DEVICE_TYPE(AMD_29F080, amd_29f080_device, "amd_29f080", "AMD 29F080 Flash") +DEFINE_DEVICE_TYPE(AMD_29F400T, amd_29f400t_device, "amd_29f400t", "AMD 29F400T Flash") +DEFINE_DEVICE_TYPE(AMD_29F800T, amd_29f800t_device, "amd_29f800t", "AMD 29F800T Flash") +DEFINE_DEVICE_TYPE(AMD_29F800B_16BIT, amd_29f800b_16bit_device, "amd_29f800b_16bit", "AMD 29F800B Flash (16-bit)") +DEFINE_DEVICE_TYPE(AMD_29LV200T, amd_29lv200t_device, "amd_29lv200t", "AMD 29LV200T Flash") +DEFINE_DEVICE_TYPE(FUJITSU_29F160TE, fujitsu_29f160te_device, "mbm29f160te", "Fujitsu MBM29F160TE Flash") +DEFINE_DEVICE_TYPE(FUJITSU_29F160TE_16BIT, fujitsu_29f160te_16bit_device, "mbm29f160te_16bit", "Fujitsu MBM29F160TE Flash (16-bit)") +DEFINE_DEVICE_TYPE(FUJITSU_29F016A, fujitsu_29f016a_device, "mbm29f016a", "Fujitsu MBM29F016A Flash") +DEFINE_DEVICE_TYPE(FUJITSU_29DL164BD, fujitsu_29dl164bd_device, "mbm29dl164bd", "Fujitsu MBM29DL164BD Flash") +DEFINE_DEVICE_TYPE(FUJITSU_29LV002TC, fujitsu_29lv002tc_device, "mbm29lv002tc", "Fujitsu MBM29LV002TC Flash") +DEFINE_DEVICE_TYPE(FUJITSU_29LV800B, fujitsu_29lv800b_device, "mbm29lv800b", "Fujitsu MBM29LV800B Flash") +DEFINE_DEVICE_TYPE(INTEL_E28F400B, intel_e28f400b_device, "intel_e28f400b", "Intel E28F400B Flash") +DEFINE_DEVICE_TYPE(MACRONIX_29F008TC, macronix_29f008tc_device, "macronix_29f008tc", "Macronix 29F008TC Flash") +DEFINE_DEVICE_TYPE(MACRONIX_29F1610MC, macronix_29f1610mc_device, "macronix_29f1610mc", "Macronix 29F1610MC Flash") +DEFINE_DEVICE_TYPE(MACRONIX_29F1610MC_16BIT, macronix_29f1610mc_16bit_device, "macronix_29f1610mc_16bit", "Macronix 29F1610MC Flash (16-bit)") +DEFINE_DEVICE_TYPE(MACRONIX_29L001MC, macronix_29l001mc_device, "macronix_29l001mc", "Macronix 29L001MC Flash") +DEFINE_DEVICE_TYPE(MACRONIX_29LV160TMC, macronix_29lv160tmc_device, "macronix_29lv160tmc", "Macronix 29LV160TMC Flash") +DEFINE_DEVICE_TYPE(TMS_29F040, tms_29f040_device, "tms_29f040", "Texas Instruments 29F040 Flash") + +DEFINE_DEVICE_TYPE(PANASONIC_MN63F805MNP, panasonic_mn63f805mnp_device, "panasonic_mn63f805mnp", "Panasonic MN63F805MNP Flash") +DEFINE_DEVICE_TYPE(SANYO_LE26FV10N1TS, sanyo_le26fv10n1ts_device, "sanyo_le26fv10n1ts", "Sanyo LE26FV10N1TS Flash") +DEFINE_DEVICE_TYPE(SST_28SF040, sst_28sf040_device, "sst_28sf040", "SST 28SF040 Flash") +DEFINE_DEVICE_TYPE(SST_39SF040, sst_39sf040_device, "sst_39sf040", "SST 39SF040 Flash") +DEFINE_DEVICE_TYPE(SST_39VF020, sst_39vf020_device, "sst_39vf020", "SST 39VF020 Flash") +DEFINE_DEVICE_TYPE(SST_49LF020, sst_49lf020_device, "sst_49lf020", "SST 49LF020 Flash") + +DEFINE_DEVICE_TYPE(SHARP_LH28F400, sharp_lh28f400_device, "sharp_lh28f400", "Sharp LH28F400 Flash") +DEFINE_DEVICE_TYPE(INTEL_E28F008SA, intel_e28f008sa_device, "intel_e28f008sa", "Intel E28F008SA Flash") +DEFINE_DEVICE_TYPE(INTEL_TE28F160, intel_te28f160_device, "intel_te28f160", "Intel TE28F160 Flash") +DEFINE_DEVICE_TYPE(SHARP_LH28F160S3, sharp_lh28f160s3_device, "sharp_lh28f160s3", "Sharp LH28F160S3 Flash") +DEFINE_DEVICE_TYPE(INTEL_TE28F320, intel_te28f320_device, "intel_te28f320", "Intel TE28F320 Flash") +DEFINE_DEVICE_TYPE(SHARP_LH28F320BF, sharp_lh28f320bf_device, "sharp_lh28f320bf", "Sharp LH28F320BFHE-PBTL Flash") +DEFINE_DEVICE_TYPE(INTEL_28F320J3D, intel_28f320j3d_device, "intel_28f320j3d", "Intel 28F320J3D Flash") +DEFINE_DEVICE_TYPE(SPANSION_S29GL064S, spansion_s29gl064s_device, "spansion_s29gl064s", "Spansion / Cypress S29GL064S Flash") +DEFINE_DEVICE_TYPE(INTEL_28F320J5, intel_28f320j5_device, "intel_28f320j5", "Intel 28F320J5 Flash") +DEFINE_DEVICE_TYPE(INTEL_28F640J5, intel_28f640j5_device, "intel_28f640j5", "Intel 28F640J5 Flash") + +DEFINE_DEVICE_TYPE(SST_39VF400A, sst_39vf400a_device, "sst_39vf400a", "SST 39VF400A Flash") + +DEFINE_DEVICE_TYPE(ATMEL_49F4096, atmel_49f4096_device, "atmel_49f4096", "Atmel AT49F4096 Flash") + +DEFINE_DEVICE_TYPE(CAT28F020, cat28f020_device, "cat28f020", "CSI CAT28F020 Flash") + +DEFINE_DEVICE_TYPE(TC58FVT800, tc58fvt800_device, "tc58fvt800", "Toshiba TC58FVT800 Flash") @@ -236,6 +238,12 @@ intel_e28f008sa_device::intel_e28f008sa_device(const machine_config &mconfig, co macronix_29f008tc_device::macronix_29f008tc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : intelfsh8_device(mconfig, MACRONIX_29F008TC, tag, owner, clock, 0x100000, MFG_MACRONIX, 0x81) { m_sector_is_4k = true; } +macronix_29f1610mc_device::macronix_29f1610mc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : intelfsh8_device(mconfig, MACRONIX_29F1610MC, tag, owner, clock, 0x200000, MFG_MACRONIX, 0xfa) { } + +macronix_29f1610mc_16bit_device::macronix_29f1610mc_16bit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : intelfsh16_device(mconfig, MACRONIX_29F1610MC_16BIT, tag, owner, clock, 0x100000, MFG_MACRONIX, 0xfa) { } + macronix_29l001mc_device::macronix_29l001mc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : intelfsh8_device(mconfig, MACRONIX_29L001MC, tag, owner, clock, 0x20000, MFG_MACRONIX, 0x51) { } diff --git a/src/devices/machine/intelfsh.h b/src/devices/machine/intelfsh.h index 168b5e7baa0..9f17487c6be 100644 --- a/src/devices/machine/intelfsh.h +++ b/src/devices/machine/intelfsh.h @@ -136,12 +136,6 @@ public: fujitsu_29lv002tc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); }; -class fujitsu_29lv800b_device : public intelfsh16_device -{ -public: - fujitsu_29lv800b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - class atmel_29c010_device : public intelfsh8_device { public: @@ -178,12 +172,6 @@ public: amd_29f800t_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); }; -class amd_29f800b_16bit_device : public intelfsh16_device -{ -public: - amd_29f800b_16bit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - class amd_29lv200t_device : public intelfsh8_device { public: @@ -196,12 +184,6 @@ public: sharp_lh28f016s_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); }; -class sharp_lh28f016s_16bit_device : public intelfsh16_device -{ -public: - sharp_lh28f016s_16bit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - class intel_e28f008sa_device : public intelfsh8_device { public: @@ -214,6 +196,12 @@ public: macronix_29f008tc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); }; +class macronix_29f1610mc_device : public intelfsh8_device +{ +public: + macronix_29f1610mc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + class macronix_29l001mc_device : public intelfsh8_device { public: @@ -268,6 +256,12 @@ public: tms_29f040_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); }; +class cat28f020_device : public intelfsh8_device +{ +public: + cat28f020_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + // 16-bit variants class fujitsu_29f160te_16bit_device : public intelfsh16_device { @@ -347,63 +341,83 @@ public: atmel_49f4096_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); }; -class cat28f020_device : public intelfsh8_device +class tc58fvt800_device : public intelfsh16_device { public: - cat28f020_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + tc58fvt800_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); }; -class tc58fvt800_device : public intelfsh16_device +class fujitsu_29lv800b_device : public intelfsh16_device { public: - tc58fvt800_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + fujitsu_29lv800b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class amd_29f800b_16bit_device : public intelfsh16_device +{ +public: + amd_29f800b_16bit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class sharp_lh28f016s_16bit_device : public intelfsh16_device +{ +public: + sharp_lh28f016s_16bit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class macronix_29f1610mc_16bit_device : public intelfsh16_device +{ +public: + macronix_29f1610mc_16bit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); }; // device type definition -DECLARE_DEVICE_TYPE(INTEL_28F016S5, intel_28f016s5_device) -DECLARE_DEVICE_TYPE(SHARP_LH28F016S, sharp_lh28f016s_device) -DECLARE_DEVICE_TYPE(SHARP_LH28F016S_16BIT, sharp_lh28f016s_16bit_device) -DECLARE_DEVICE_TYPE(ATMEL_29C010, atmel_29c010_device) -DECLARE_DEVICE_TYPE(AMD_29F010, amd_29f010_device) -DECLARE_DEVICE_TYPE(AMD_29F040, amd_29f040_device) -DECLARE_DEVICE_TYPE(AMD_29F080, amd_29f080_device) -DECLARE_DEVICE_TYPE(AMD_29F400T, amd_29f400t_device) -DECLARE_DEVICE_TYPE(AMD_29F800T, amd_29f800t_device) -DECLARE_DEVICE_TYPE(AMD_29F800B_16BIT, amd_29f800b_16bit_device) -DECLARE_DEVICE_TYPE(AMD_29LV200T, amd_29lv200t_device) -DECLARE_DEVICE_TYPE(FUJITSU_29F160TE, fujitsu_29f160te_device) -DECLARE_DEVICE_TYPE(FUJITSU_29F160TE_16BIT,fujitsu_29f160te_16bit_device) -DECLARE_DEVICE_TYPE(FUJITSU_29F016A, fujitsu_29f016a_device) -DECLARE_DEVICE_TYPE(FUJITSU_29DL164BD, fujitsu_29dl164bd_device) -DECLARE_DEVICE_TYPE(FUJITSU_29LV002TC, fujitsu_29lv002tc_device) -DECLARE_DEVICE_TYPE(FUJITSU_29LV800B, fujitsu_29lv800b_device) -DECLARE_DEVICE_TYPE(INTEL_E28F400B, intel_e28f400b_device) -DECLARE_DEVICE_TYPE(MACRONIX_29F008TC, macronix_29f008tc_device) -DECLARE_DEVICE_TYPE(MACRONIX_29L001MC, macronix_29l001mc_device) -DECLARE_DEVICE_TYPE(MACRONIX_29LV160TMC, macronix_29lv160tmc_device) -DECLARE_DEVICE_TYPE(TMS_29F040, tms_29f040_device) - -DECLARE_DEVICE_TYPE(PANASONIC_MN63F805MNP, panasonic_mn63f805mnp_device) -DECLARE_DEVICE_TYPE(SANYO_LE26FV10N1TS, sanyo_le26fv10n1ts_device) -DECLARE_DEVICE_TYPE(SST_28SF040, sst_28sf040_device) -DECLARE_DEVICE_TYPE(SST_39SF040, sst_39sf040_device) -DECLARE_DEVICE_TYPE(SST_39VF020, sst_39vf020_device) -DECLARE_DEVICE_TYPE(SST_49LF020, sst_49lf020_device) - -DECLARE_DEVICE_TYPE(SHARP_LH28F400, sharp_lh28f400_device) -DECLARE_DEVICE_TYPE(INTEL_E28F008SA, intel_e28f008sa_device) -DECLARE_DEVICE_TYPE(INTEL_TE28F160, intel_te28f160_device) -DECLARE_DEVICE_TYPE(SHARP_LH28F160S3, sharp_lh28f160s3_device) -DECLARE_DEVICE_TYPE(INTEL_TE28F320, intel_te28f320_device) -DECLARE_DEVICE_TYPE(SPANSION_S29GL064S, spansion_s29gl064s_device) -DECLARE_DEVICE_TYPE(SHARP_LH28F320BF, sharp_lh28f320bf_device) -DECLARE_DEVICE_TYPE(INTEL_28F320J3D, intel_28f320j3d_device) -DECLARE_DEVICE_TYPE(INTEL_28F320J5, intel_28f320j5_device) -DECLARE_DEVICE_TYPE(INTEL_28F640J5, intel_28f640j5_device) -DECLARE_DEVICE_TYPE(SST_39VF400A, sst_39vf400a_device) -DECLARE_DEVICE_TYPE(ATMEL_49F4096, atmel_49f4096_device) -DECLARE_DEVICE_TYPE(CAT28F020, cat28f020_device) -DECLARE_DEVICE_TYPE(TC58FVT800, tc58fvt800_device) +DECLARE_DEVICE_TYPE(INTEL_28F016S5, intel_28f016s5_device) +DECLARE_DEVICE_TYPE(SHARP_LH28F016S, sharp_lh28f016s_device) +DECLARE_DEVICE_TYPE(SHARP_LH28F016S_16BIT, sharp_lh28f016s_16bit_device) +DECLARE_DEVICE_TYPE(ATMEL_29C010, atmel_29c010_device) +DECLARE_DEVICE_TYPE(AMD_29F010, amd_29f010_device) +DECLARE_DEVICE_TYPE(AMD_29F040, amd_29f040_device) +DECLARE_DEVICE_TYPE(AMD_29F080, amd_29f080_device) +DECLARE_DEVICE_TYPE(AMD_29F400T, amd_29f400t_device) +DECLARE_DEVICE_TYPE(AMD_29F800T, amd_29f800t_device) +DECLARE_DEVICE_TYPE(AMD_29F800B_16BIT, amd_29f800b_16bit_device) +DECLARE_DEVICE_TYPE(AMD_29LV200T, amd_29lv200t_device) +DECLARE_DEVICE_TYPE(FUJITSU_29F160TE, fujitsu_29f160te_device) +DECLARE_DEVICE_TYPE(FUJITSU_29F160TE_16BIT, fujitsu_29f160te_16bit_device) +DECLARE_DEVICE_TYPE(FUJITSU_29F016A, fujitsu_29f016a_device) +DECLARE_DEVICE_TYPE(FUJITSU_29DL164BD, fujitsu_29dl164bd_device) +DECLARE_DEVICE_TYPE(FUJITSU_29LV002TC, fujitsu_29lv002tc_device) +DECLARE_DEVICE_TYPE(FUJITSU_29LV800B, fujitsu_29lv800b_device) +DECLARE_DEVICE_TYPE(INTEL_E28F400B, intel_e28f400b_device) +DECLARE_DEVICE_TYPE(MACRONIX_29F008TC, macronix_29f008tc_device) +DECLARE_DEVICE_TYPE(MACRONIX_29F1610MC, macronix_29f1610mc_device) +DECLARE_DEVICE_TYPE(MACRONIX_29F1610MC_16BIT,macronix_29f1610mc_16bit_device) +DECLARE_DEVICE_TYPE(MACRONIX_29L001MC, macronix_29l001mc_device) +DECLARE_DEVICE_TYPE(MACRONIX_29LV160TMC, macronix_29lv160tmc_device) +DECLARE_DEVICE_TYPE(TMS_29F040, tms_29f040_device) + +DECLARE_DEVICE_TYPE(PANASONIC_MN63F805MNP, panasonic_mn63f805mnp_device) +DECLARE_DEVICE_TYPE(SANYO_LE26FV10N1TS, sanyo_le26fv10n1ts_device) +DECLARE_DEVICE_TYPE(SST_28SF040, sst_28sf040_device) +DECLARE_DEVICE_TYPE(SST_39SF040, sst_39sf040_device) +DECLARE_DEVICE_TYPE(SST_39VF020, sst_39vf020_device) +DECLARE_DEVICE_TYPE(SST_49LF020, sst_49lf020_device) + +DECLARE_DEVICE_TYPE(SHARP_LH28F400, sharp_lh28f400_device) +DECLARE_DEVICE_TYPE(INTEL_E28F008SA, intel_e28f008sa_device) +DECLARE_DEVICE_TYPE(INTEL_TE28F160, intel_te28f160_device) +DECLARE_DEVICE_TYPE(SHARP_LH28F160S3, sharp_lh28f160s3_device) +DECLARE_DEVICE_TYPE(INTEL_TE28F320, intel_te28f320_device) +DECLARE_DEVICE_TYPE(SPANSION_S29GL064S, spansion_s29gl064s_device) +DECLARE_DEVICE_TYPE(SHARP_LH28F320BF, sharp_lh28f320bf_device) +DECLARE_DEVICE_TYPE(INTEL_28F320J3D, intel_28f320j3d_device) +DECLARE_DEVICE_TYPE(INTEL_28F320J5, intel_28f320j5_device) +DECLARE_DEVICE_TYPE(INTEL_28F640J5, intel_28f640j5_device) +DECLARE_DEVICE_TYPE(SST_39VF400A, sst_39vf400a_device) +DECLARE_DEVICE_TYPE(ATMEL_49F4096, atmel_49f4096_device) +DECLARE_DEVICE_TYPE(CAT28F020, cat28f020_device) +DECLARE_DEVICE_TYPE(TC58FVT800, tc58fvt800_device) #endif // MAME_MACHINE_INTELFSH_H diff --git a/src/devices/sound/dac3350a.cpp b/src/devices/sound/dac3350a.cpp new file mode 100644 index 00000000000..77e91650a64 --- /dev/null +++ b/src/devices/sound/dac3350a.cpp @@ -0,0 +1,332 @@ +// license:BSD-3-Clause +// copyright-holders:windyfairy +/* + Micronas DAC 3550A Stereo Audio DAC + i2c code based on mas3507d + + Accepts 8-bit and 16-bit I2C write operations and has no read operations +*/ + +#include "emu.h" +#include "dac3350a.h" + +#define VERBOSE (LOG_GENERAL) + +#include "logmacro.h" + +enum +{ + CMD_DEV_WRITE = 0x9a, +}; + +enum +{ + IDLE = 0, + STARTED, + NAK, + ACK, + ACK2, +}; + +enum +{ + UNKNOWN = 0, + VALIDATED, + WRONG, +}; + +enum +{ + REG_UNKNOWN = 0, + REG_SR = 1, + REG_AVOL, + REG_GCFG, +}; + +enum +{ + // sample rate control register + SR_LR_SEL_BIT = 4, // L/R-bit + SR_LR_SEL_LEFT = 0, // (WSI = 0 -> left channel + SR_LR_SEL_RIGHT = 1, // (WSI = 0 -> right channel + + SR_SP_SEL_BIT = 3, // delay bit + SR_SP_SEL_NO_DELAY = 0, + SR_SP_SEL_1_BIT_DELAY = 1, + + SR_SRC_BIT = 0, // 3 bits wide, sample rate control + SR_SRC_48 = 0, // 32-48 kHz + SR_SRC_32, // 26-32 kHz + SR_SRC_24, // 20-26 kHz + SR_SRC_16, // 14-20 kHz + SR_SRC_12, // 10-14 kHz + SR_SRC_8, // 8-10 kHz + SR_SRC_A, // autoselect +}; + +enum +{ + // analog volume register + AVOL_DEEM_BIT = 14, // deemphasis on/off + AVOL_DEEM_OFF = 0, + AVOL_DEEM_ON = 1, + + AVOL_L_BIT = 8, // 6 bits wide, analog audio volume level left + AVOL_R_BIT = 0, // 6 bits wide, analog audio volume level right +}; + +enum +{ + // global configuration register + GCFG_SEL_53V_BIT = 6, // select 3V-5V mode + GCFG_SEL_53V_3V = 0, + GCFG_SEL_53V_5V = 1, + + GCFG_PWMD_BIT = 5, // power-mode + GCFG_PWMD_NORMAL = 0, + GCFG_PWMD_LOW_POWER = 1, + + GCFG_INSEL_AUX2_BIT = 4, // AUX2 select + GCFG_INSEL_AUX2_OFF = 0, + GCFG_INSEL_AUX2_ON = 1, + + GCFG_INSEL_AUX1_BIT = 3, // AUX1 select + GCFG_INSEL_AUX1_OFF = 0, + GCFG_INSEL_AUX1_ON = 1, + + GCFG_INSEL_DAC_BIT = 2, // DAC select + GCFG_INSEL_DAC_OFF = 0, + GCFG_INSEL_DAC_ON = 1, + + GCFG_AUX_MS_BIT = 1, // aux-mono/stereo + GCFG_AUX_MS_STEREO = 0, + GCFG_AUX_MS_MONO = 1, + + GCFG_IPRA_BIT = 0, // invert right power amplifier + GCFG_IPRA_NOT_INVERTED = 0, + GCFG_IPRA_INVERTED = 1, +}; + + +DEFINE_DEVICE_TYPE(DAC3350A, dac3350a_device, "dac3350a", "Micronas DAC 3550A Stereo Audio DAC") + +dac3350a_device::dac3350a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, DAC3350A, tag, owner, clock) + , device_sound_interface(mconfig, *this) +{ +} + +void dac3350a_device::device_start() +{ + // TODO: use configured clock for sample rate and respond to device_clock_changed + m_stream = stream_alloc(2, 2, 44100); + + save_item(NAME(m_i2c_bus_state)); + save_item(NAME(m_i2c_bus_address)); + save_item(NAME(m_i2c_scli)); + save_item(NAME(m_i2c_sdai)); + save_item(NAME(m_i2c_bus_curbit)); + save_item(NAME(m_i2c_bus_curval)); + save_item(NAME(m_i2c_bytecount)); + + save_item(NAME(m_i2c_subadr)); + save_item(NAME(m_i2c_data)); + + save_item(NAME(m_dac_enable)); + save_item(NAME(m_volume)); +} + +void dac3350a_device::device_reset() +{ + m_i2c_scli = m_i2c_sdai = 1; + m_i2c_bus_state = IDLE; + m_i2c_bus_address = UNKNOWN; + m_i2c_bus_curbit = -1; + m_i2c_bus_curval = 0; + + m_i2c_subadr = 0; + m_i2c_data = 0; + + m_dac_enable = true; + + std::fill(std::begin(m_volume), std::end(m_volume), 1.0); +} + +void dac3350a_device::i2c_scl_w(int line) +{ + if (line == m_i2c_scli) + return; + + m_i2c_scli = line; + + if (m_i2c_scli) + { + if (m_i2c_bus_state == STARTED) + { + m_i2c_bus_curval |= m_i2c_sdai << m_i2c_bus_curbit; + m_i2c_bus_curbit--; + + if (m_i2c_bus_curbit == -1) + { + if (m_i2c_bus_address == UNKNOWN) + { + if (m_i2c_bus_curval == CMD_DEV_WRITE) + { + m_i2c_bus_state = ACK; + m_i2c_bus_address = VALIDATED; + m_i2c_bus_curval = 0; + } + else + { + m_i2c_bus_state = NAK; + m_i2c_bus_address = WRONG; + } + } + else if (m_i2c_bus_address == VALIDATED) + { + if (m_i2c_bytecount < 3) + { + m_i2c_bus_state = ACK; + + if (m_i2c_bytecount == 0) + { + m_i2c_subadr = m_i2c_bus_curval; + } + else + { + m_i2c_data <<= 8; + m_i2c_data |= m_i2c_bus_curval; + } + + m_i2c_bytecount++; + } + else + { + // Only accept 8-bit and 16-bit writes + m_i2c_bus_state = NAK; + } + } + } + } + else if (m_i2c_bus_state == ACK) + { + m_i2c_bus_state = ACK2; + } + } + else + { + if (m_i2c_bus_state == ACK2) + { + m_i2c_bus_state = STARTED; + m_i2c_bus_curbit = 7; + m_i2c_bus_curval = 0; + } + } +} + +void dac3350a_device::i2c_sda_w(int line) +{ + if (line == m_i2c_sdai) + return; + + m_i2c_sdai = line; + + if (m_i2c_scli) + { + if (m_i2c_sdai) + i2c_device_handle_write(); + + m_i2c_bus_state = m_i2c_sdai ? IDLE : STARTED; + m_i2c_bus_address = UNKNOWN; + m_i2c_bus_curbit = 7; + m_i2c_bus_curval = 0; + } +} + +void dac3350a_device::i2c_device_handle_write() +{ + const auto bytecount = m_i2c_bytecount; + + m_i2c_bytecount = 0; + + if (bytecount < 2) // not a valid command, ignore + return; + + // const int mcs = BIT(m_i2c_subadr, 6, 2); // chip select, 3 = MPEG mode + const int reg_adr = BIT(m_i2c_subadr, 0, 2); + + if (reg_adr == REG_SR) + { + // sample rate control + const int sample_rate = BIT(m_i2c_data, SR_SRC_BIT, 3); + const int delay = BIT(m_i2c_data, SR_SP_SEL_BIT); + const int lr = BIT(m_i2c_data, SR_LR_SEL_BIT); + + LOG("DAC: SR register %d %d %d\n", sample_rate, delay, lr); + } + else if (reg_adr == REG_AVOL) + { + // set volume, requires 2 bytes + if (bytecount <= 2) + logerror("AVOL command requires 2 bytes of data, found %d\n", bytecount); + + const int vol_r = BIT(m_i2c_data, AVOL_R_BIT, 6); + const int vol_l = BIT(m_i2c_data, AVOL_L_BIT, 6); + const int deemph = BIT(m_i2c_data, AVOL_DEEM_BIT); + + m_volume[0] = calculate_volume(vol_l); + m_volume[1] = calculate_volume(vol_r); + + LOG("DAC: AVOL register %d %d %d (%f %f)\n", vol_r, vol_l, deemph, m_volume[0], m_volume[1]); + } + else if (reg_adr == REG_GCFG) + { + // global configuration + const int ipra = BIT(m_i2c_data, GCFG_IPRA_BIT); + const int aux_ms = BIT(m_i2c_data, GCFG_AUX_MS_BIT); + const int insel_dac = BIT(m_i2c_data, GCFG_INSEL_DAC_BIT); + const int insel_aux1 = BIT(m_i2c_data, GCFG_INSEL_AUX1_BIT); + const int insel_aux2 = BIT(m_i2c_data, GCFG_INSEL_AUX2_BIT); + const int pwmd = BIT(m_i2c_data, GCFG_PWMD_BIT); + const int sel_53v = BIT(m_i2c_data, GCFG_SEL_53V_BIT); + + LOG("DAC: GCFG register %d %d %d %d %d %d %d\n", ipra, aux_ms, insel_dac, insel_aux1, insel_aux2, pwmd, sel_53v); + } + else + { + LOG("DAC: Unknown register selected! %d\n", reg_adr); + } +} + +float dac3350a_device::calculate_volume(int val) +{ + if (val == 0) + return 0.0; // mute + + double db = 0; + if (val <= 7) + { + // -75 dB ... -54 dB: 3 dB steps + db = -54 - ((8 - val) * 3); + } + else + { + // -54 dB ... +18 dB: 1.5 dB steps + db = -54 + ((val - 8) * 1.5); + } + + db = std::clamp(db, -75.0, 18.0); // range is +18 dB to -75 dB + + return powf(10.0, db / 20.0); +} + +void dac3350a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +{ + const stream_buffer::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; + + for (int channel = 0; channel < 2 && channel < outputs.size(); channel++) + { + for (int sampindex = 0; sampindex < outputs[channel].samples(); sampindex++) + outputs[channel].put(sampindex, inputs[channel].get(sampindex) * enable_scale * m_volume[channel]); + } +} diff --git a/src/devices/sound/dac3350a.h b/src/devices/sound/dac3350a.h new file mode 100644 index 00000000000..59e5bc90ea7 --- /dev/null +++ b/src/devices/sound/dac3350a.h @@ -0,0 +1,46 @@ +// license:BSD-3-Clause +// copyright-holders:windyfairy +#ifndef MAME_SOUND_DAC3350A_H +#define MAME_SOUND_DAC3350A_H + +#pragma once + +class dac3350a_device : public device_t, public device_sound_interface +{ +public: + dac3350a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + void i2c_scl_w(int line); + void i2c_sda_w(int line); + +protected: + virtual void device_start() override; + virtual void device_reset() override; + + virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + +private: + void i2c_device_handle_write(); + float calculate_volume(int val); + + sound_stream *m_stream; + + uint8_t m_i2c_bus_state; + uint8_t m_i2c_bus_address; + + uint8_t m_i2c_scli, m_i2c_sdai; + int32_t m_i2c_bus_curbit; + uint8_t m_i2c_bus_curval; + uint32_t m_i2c_bytecount; + + uint8_t m_i2c_subadr; + uint16_t m_i2c_data; + + bool m_dac_enable; + + float m_volume[2]; +}; + +DECLARE_DEVICE_TYPE(DAC3350A, dac3350a_device) + +#endif // MAME_SOUND_DAC3350A_H diff --git a/src/devices/sound/mas3507d.cpp b/src/devices/sound/mas3507d.cpp index 3780dd4e792..25f9d2ab1af 100644 --- a/src/devices/sound/mas3507d.cpp +++ b/src/devices/sound/mas3507d.cpp @@ -80,7 +80,6 @@ void mas3507d_device::device_start() save_item(NAME(i2c_io_count)); save_item(NAME(i2c_io_val)); save_item(NAME(i2c_sdao_data)); - save_item(NAME(playback_status)); save_item(NAME(frame_channels)); @@ -95,9 +94,15 @@ void mas3507d_device::device_reset() i2c_bus_address = UNKNOWN; i2c_bus_curbit = -1; i2c_bus_curval = 0; + i2c_bytecount = 0; + i2c_io_bank = 0; + i2c_io_adr = 0; + i2c_io_count = 0; + i2c_io_val = 0; + i2c_sdao_data = 0; is_muted = false; - gain_ll = gain_rr = 0; + gain_ll = gain_rr = 1.0; frame_channels = 2; @@ -344,7 +349,8 @@ int mas3507d_device::gain_to_db(double val) { return round(20 * log10((0x100000 - val) / 0x80000)); } -float mas3507d_device::gain_to_percentage(int val) { +float mas3507d_device::gain_to_percentage(int val) +{ if(val == 0) return 0; // Special case for muting it seems @@ -362,10 +368,6 @@ void mas3507d_device::mem_write(int bank, uint32_t adr, uint32_t val) case 0x107f8: gain_ll = gain_to_percentage(val); LOGCONFIG("MAS3507D: left->left gain = %05x (%d dB, %f%%)\n", val, gain_to_db(val), gain_ll); - - if(!is_muted) { - set_output_gain(0, gain_ll); - } break; case 0x107f9: LOGCONFIG("MAS3507D: left->right gain = %05x (%d dB, %f%%)\n", val, gain_to_db(val), gain_to_percentage(val)); @@ -376,10 +378,6 @@ void mas3507d_device::mem_write(int bank, uint32_t adr, uint32_t val) case 0x107fb: gain_rr = gain_to_percentage(val); LOGCONFIG("MAS3507D: right->right gain = %05x (%d dB, %f%%)\n", val, gain_to_db(val), gain_rr); - - if(!is_muted) { - set_output_gain(1, gain_rr); - } break; default: LOGCONFIG("MAS3507D: %d:%04x = %05x\n", bank, adr, val); break; } @@ -391,8 +389,7 @@ void mas3507d_device::reg_write(uint32_t adr, uint32_t val) case 0x8e: LOGCONFIG("MAS3507D: DCCF = %05x\n", val); break; case 0xaa: LOGCONFIG("MAS3507D: Mute/bypass = %05x\n", val); - set_output_gain(0, val == 1 ? 0 : gain_ll); - set_output_gain(1, val == 1 ? 0 : gain_rr); + is_muted = val == 1; break; case 0xe6: LOGCONFIG("MAS3507D: StartupConfig = %05x\n", val); break; case 0xe7: LOGCONFIG("MAS3507D: Kprescale = %05x\n", val); break; @@ -437,7 +434,7 @@ void mas3507d_device::fill_buffer() mp3data_count--; } - cb_demand(mp3data_count < mp3data.size()); + cb_demand(1); // always request more data when nothing could be decoded to force potentially stale data out of the buffer return; } @@ -454,15 +451,17 @@ void mas3507d_device::fill_buffer() void mas3507d_device::append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount) { - int s1 = scount - pos; - int bytes_per_sample = std::min(frame_channels, 2); // More than 2 channels is unsupported here - - if(s1 > sample_count) - s1 = sample_count; + const int bytes_per_sample = std::min(frame_channels, 2); // More than 2 channels is unsupported here + const int s1 = std::min(scount - pos, sample_count); + const stream_buffer::sample_t sample_scale = 1.0 / 32768.0; + const stream_buffer::sample_t mute_scale = is_muted ? 0.0 : 1.0; for(int i = 0; i < s1; i++) { - outputs[0].put_int(pos, samples[samples_idx * bytes_per_sample], 32768); - outputs[1].put_int(pos, samples[samples_idx * bytes_per_sample + (bytes_per_sample >> 1)], 32768); + const stream_buffer::sample_t lsamp_mixed = stream_buffer::sample_t(samples[samples_idx * bytes_per_sample]) * sample_scale * mute_scale * gain_ll; + const stream_buffer::sample_t rsamp_mixed = stream_buffer::sample_t(samples[samples_idx * bytes_per_sample + (bytes_per_sample >> 1)]) * sample_scale * mute_scale * gain_rr; + + outputs[0].put(pos, lsamp_mixed); + outputs[1].put(pos, rsamp_mixed); samples_idx++; pos++; diff --git a/src/devices/sound/mas3507d.h b/src/devices/sound/mas3507d.h index 4d8eac31539..4402e8941d3 100644 --- a/src/devices/sound/mas3507d.h +++ b/src/devices/sound/mas3507d.h @@ -23,8 +23,6 @@ public: void sid_w(uint8_t byte); - void update_stream() { stream->update(); } - void reset_playback(); protected: @@ -90,8 +88,6 @@ private: bool is_muted; float gain_ll, gain_rr; - uint32_t playback_status; - std::unique_ptr<mp3_audio> mp3dec; }; diff --git a/src/mame/misc/xtom3d.cpp b/src/mame/misc/xtom3d.cpp index b2b50fc80ce..d8dc7aa8608 100644 --- a/src/mame/misc/xtom3d.cpp +++ b/src/mame/misc/xtom3d.cpp @@ -61,10 +61,68 @@ ROM BOARD --------- MX29F1610MC 16M FlashROM (x7) + +--- + +Pump It Up MK-III +SPACE11_3 board (front plane PCB) +----------- +6 pin and 4 pin power connectors (+12V and +5V on both) on back side of PCB +2x 4 pin power headers on front +2 pin COMM header on back side +3 pin PCM header on back side, connects to CN5 on SPACE12_1 board? +2x HD34PIN header on back side, connects to CN2 and CN3 of SPACE12_1 board +2x5 pin header on back side +6 pin Video header (R, G, B, GND, HSYNC, VSYNC) from back side, connecting to VGA header on front side +HS10PIN labeled 1P on front +HS10PIN labeled LAMP on front +HS10PIN labeled 2P on front +3x HS3PIN on front +TEST, SERV, CLR buttons on front +4 pin header unlabeled on front +CN5 JAMMA(?) connector + + + +SPACE12_1 board +----------- +A40MX04 QFP84 CPLD +U6 CSI CAT93C46P 1KB eeproom +U7 Unpopulated 8 pin socket +U8 KS74HCTLS125N +U5, U9, U10, U11, U12, U13, U14 HD74LS14P +U15, U16, U17, U18 ULN2803A +U19, U20, U21, U22 HD74LS245P +U23, U26 L9940 LTV847CD +U24, U25 L9944 LTV847 +U27 Sharp PC817 +U28 Yamaha YMZ280B-F +U29 Yamaha YAC516 +U31, U32 HA17558 +U101 SN75176BP +U100 Unpopulated socket +U102 Unpopulated MAX232 + +J1 connects to main PCB +CN1 PCN96, connects to PIU10 +CN2 34 pin connector +CN3 34 pin connector +CN5 3 pin connector, audio? +CN100 2 pin connector +Unnamed 5 pin connector +DB25PIN Unpopulated header near A40MX04 +HS3PIN Unpopulated header near A40MX04 + +1.8432MHz XTAL near A40MX04 +169NDK19 XTAL (16.9344MHz) near Yamaha YMZ280B-F + **************************************************************************************************/ #include "emu.h" + +#include "xtom3d_piu10.h" + #include "cpu/i386/i386.h" #include "machine/pci.h" #include "machine/pci-ide.h" @@ -382,6 +440,9 @@ INPUT_PORTS_END static INPUT_PORTS_START( pumpitup ) PORT_INCLUDE( xtom3d ) + PORT_MODIFY("SYSTEM") + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Clear") + PORT_MODIFY("IN0") PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 Top-Left step") PORT_PLAYER(1) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Top-Right step") PORT_PLAYER(1) @@ -397,6 +458,9 @@ static INPUT_PORTS_START( pumpitup ) PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("P2 Bottom-Left step") PORT_PLAYER(2) PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("P2 Bottom-Right step") PORT_PLAYER(2) PORT_BIT( 0x00e0, IP_ACTIVE_LOW, IPT_UNUSED ) + + PORT_MODIFY("IN2") + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN2 ) INPUT_PORTS_END ioport_constructor isa16_xtom3d_io_sound::device_input_ports() const @@ -423,6 +487,7 @@ void isa16_xtom3d_io_sound::io_map(address_map &map) { // $2a0-$2a3 sound map(0x00, 0x03).rw("ymz", FUNC(ymz280b_device::read), FUNC(ymz280b_device::write)).umask16(0x00ff); + // map(0x04, 0x07).noprw(); // lights/outputs? map(0x08, 0x09).lr8( NAME([this] (offs_t offset) { return offset & 1 ? m_system->read() : m_in0->read(); @@ -571,6 +636,7 @@ private: // void vblank_assert(int state); static void romdisk_config(device_t *device); + static void piu10_config(device_t *device); // static void cdrom_config(device_t *device); }; @@ -586,6 +652,7 @@ void xtom3d_isa_cards(device_slot_interface &device) device.option_add_internal("oksan_lpc", ISA16_OKSAN_LPC); device.option_add_internal("xtom3d_io_sound", ISA16_XTOM3D_IO_SOUND); device.option_add_internal("pumpitup_io_sound", ISA16_PUMPITUP_IO_SOUND); + device.option_add_internal("pumpitup_piu10", ISA16_PIU10); } void xtom3d_state::romdisk_config(device_t *device) @@ -594,6 +661,13 @@ void xtom3d_state::romdisk_config(device_t *device) romdisk.set_rom_tag("game_rom"); } +void xtom3d_state::piu10_config(device_t *device) +{ + isa16_piu10 &piu10 = *downcast<isa16_piu10 *>(device); + piu10.add_route(0, ":lmicrophone", 0.25); + piu10.add_route(1, ":rmicrophone", 0.25); +} + // TODO: unverified PCI config space void xtom3d_state::xtom3d(machine_config &config) { @@ -671,7 +745,8 @@ void xtom3d_state::pumpitup(machine_config &config) m_pci_ide->subdevice<bus_master_ide_controller_device>("ide1")->slot(0).set_default_option("cdrom"); m_pci_ide->subdevice<bus_master_ide_controller_device>("ide1")->slot(0).set_option_machine_config("cdrom", cdrom_config); - ISA16_SLOT(config.replace(), "isa1", 0, "pci:07.0:isabus", xtom3d_isa_cards, "pumpitup_io_sound", true); + subdevice<isa16_slot_device>("board1")->set_default_option("pumpitup_piu10").set_option_machine_config("pumpitup_piu10", piu10_config); + subdevice<isa16_slot_device>("isa1")->set_default_option("pumpitup_io_sound"); } ROM_START( xtom3d ) @@ -697,13 +772,16 @@ ROM_END #define PUMPITUP_BIOS \ ROM_REGION32_LE(0x20000, "pci:07.0", 0) \ ROM_LOAD( "bios.u22", 0x000000, 0x020000, CRC(f7c58044) SHA1(fd967d009e0d3c8ed9dd7be852946f2b9dee7671) ) \ - ROM_REGION32_LE(0x1000000, "board1:game_rom", ROMREGION_ERASEFF ) \ + ROM_REGION(0x200000, "board1:pumpitup_piu10:flash_u8", ROMREGION_ERASEFF ) \ ROM_LOAD( "piu10.u8", 0x000000, 0x200000, CRC(5911e31a) SHA1(295723b9b7da9e55b5dd5586b23b06355f4837ef) ) \ ROM_REGION(0x400000, "isa1:pumpitup_io_sound:ymz", ROMREGION_ERASEFF ) \ ROM_LOAD( "piu10.u9", 0x000000, 0x200000, CRC(9c436cfa) SHA1(480ea52e74721d1963ced41be5c482b7b913ccd2) ) ROM_START( pumpitup ) PUMPITUP_BIOS + + ROM_REGION( 0x8, "board1:pumpitup_piu10:cat702", 0 ) + ROM_LOAD_OPTIONAL( "cat702.bin", 0x000000, 0x000008, NO_DUMP ) // Dummy entry to make testing later games easier ROM_END ROM_START( pumpit1 ) diff --git a/src/mame/misc/xtom3d_piu10.cpp b/src/mame/misc/xtom3d_piu10.cpp new file mode 100644 index 00000000000..5d29e3b4fdf --- /dev/null +++ b/src/mame/misc/xtom3d_piu10.cpp @@ -0,0 +1,203 @@ +// license:BSD-3-Clause +// copyright-holders:windyfairy +/* + ISA16 PIU10 + + PIU10 000614 + ----------- + HS3PIN labeled POWER + CD-IN 4 pin header but only 3 pins populated + (audio) OUT 4 pin header but only 3 pins populated, markings nearby show pinout of "OUTR GND OUTL GND" + 6 pin power headers in corner + + U1, U2, U3 HD74LS138P + U4, U5, U14 HD74LS245P + U6 HD74LS139P + U7 PST518 + U8, U9, U10 MX 29F1610MC-12 (U10 unpopulated) with optional "MONO" configuration beside it + U11 ATMEL ATF1500A I5JC 0015 + U12 Micronas MAS3507D F10 + U13 Micronas DAC3350A C2 + U15 HD74LS273P + U16 HD74LS125AP + U18, U19 7809CT Linear Voltage Regulator + U20 UTC 78L05 WK + U21, U22 HA17358 + + CN1 PCN96, connects to SPACE12_1 + CN3, CN4 Unpopulated 4 pin headers + + 14.7456MHz XTAL near Micronas chips + + + CAT702 security data: + https://github.com/pumpitupdev/pumptools/blob/b809d8674925d3c6e6b25efa91dccc04a460a62f/src/main/sec/lockchip/lockchip-defs.h + */ + +#include "emu.h" +#include "xtom3d_piu10.h" + + +DEFINE_DEVICE_TYPE(ISA16_PIU10, isa16_piu10, "isa16_piu10", "ISA16 PIU10 for MK-III") + +isa16_piu10::isa16_piu10(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ISA16_PIU10, tag, owner, clock) + , device_isa16_card_interface(mconfig, *this) + , m_cat702(*this, "cat702") + , m_dac3350a(*this, "dac3350a") + , m_mas3507d(*this, "mas3507d") + , m_flash(*this, "flash_u8") +{ +} + +void isa16_piu10::device_start() +{ + set_isa_device(); + + save_item(NAME(m_addr)); + save_item(NAME(m_dest)); + save_item(NAME(m_flash_unlock)); + save_item(NAME(m_mp3_demand)); + save_item(NAME(m_mp3_mpeg_frame_sync)); + save_item(NAME(m_cat702_data)); +} + +void isa16_piu10::device_reset() +{ + m_addr = m_dest = 0; + m_flash_unlock = false; + + m_mp3_demand = 1; + m_mp3_mpeg_frame_sync = 1; + + m_cat702_data = 0; +} + +void isa16_piu10::device_add_mconfig(machine_config &config) +{ + MACRONIX_29F1610MC_16BIT(config, m_flash); + + CAT702_PIU(config, m_cat702, 0); + m_cat702->dataout_handler().set([this] (u16 data) { m_cat702_data = data & 1; }); + + DAC3350A(config, m_dac3350a); + + MAS3507D(config, m_mas3507d); + m_mas3507d->mpeg_frame_sync_cb().set(*this, FUNC(isa16_piu10::mas3507d_mpeg_frame_sync)); + m_mas3507d->demand_cb().set(*this, FUNC(isa16_piu10::mas3507d_demand)); + m_mas3507d->add_route(0, m_dac3350a, 1.0, 0); + m_mas3507d->add_route(1, m_dac3350a, 1.0, 1); +} + +void isa16_piu10::remap(int space_id, offs_t start, offs_t end) +{ + if (space_id == AS_IO) + { + m_isa->install16_device(0x02d0, 0x02df, read16sm_delegate(*this, FUNC(isa16_piu10::read)), write16sm_delegate(*this, FUNC(isa16_piu10::write))); + } +} + +uint16_t isa16_piu10::read(offs_t offset) +{ + switch (offset) + { + case 0x5: // 2da + if (m_dest == 0x008) + { + uint16_t r = 0; + + r |= (m_cat702_data & 1) << 5; + + r |= m_mp3_mpeg_frame_sync << 2; // every 256th transition the game will set the internal playback position timestamp to counter*6.2687998 to sync with the MP3 decoder chip (counter*6.2687998/240 = (1152*counter)/44100) + r |= 1 << 1; // the MP3 data send function loops until this is 1 before sending MP3 data byte + r |= m_mp3_demand << 0; // if not set then MP3 data send function early returns + + return r; + } + else if (m_dest == 0) + { + const uint32_t offs = m_addr; + if (!machine().side_effects_disabled() && m_flash_unlock) + m_addr++; + return m_flash->read(offs); + } + break; + } + + if (!machine().side_effects_disabled()) + logerror("%s: unknown read %d %03x %06x %02x\n", machine().describe_context(), m_flash_unlock, m_dest, m_addr, offset); + + return 0; +} + +void isa16_piu10::write(offs_t offset, uint16_t data) +{ + switch (offset) + { + // address port, bottom 16-bits are location and top 16-bits are target device + case 0x0: // 2d0 + m_addr &= 0xfff00; + m_addr |= data & 0xff; + break; + case 0x1: // 2d2 + m_addr &= 0xf00ff; + m_addr |= (data & 0xff) << 8; + break; + + case 0x2: // 2d4 + m_addr &= 0x0ffff; + m_addr |= (data & 0xf) << 16; + + m_dest &= 0xff0; + m_dest |= (data >> 4) & 0xf; + break; + case 0x3: // 2d6 + m_dest &= 0x00f; + m_dest |= (data & 0xff) << 4; + break; + + // data port + case 0x5: // 2da + if (m_dest == 0x010) + { + m_cat702->write_datain(BIT(data, 5)); + m_cat702->write_clock(BIT(data, 4)); + m_cat702->write_select(BIT(data, 3)); + + m_dac3350a->i2c_sda_w(BIT(data, 1)); + m_dac3350a->i2c_scl_w(BIT(data, 0)); + } + else if (m_dest == 0x008) + { + m_mas3507d->sid_w(data); + } + else if (m_dest == 0 && m_flash_unlock) + { + m_flash->write(m_addr, data); + } + else + { + logerror("%s: unknown write %d %03x %06x %02x %02x\n", machine().describe_context(), m_flash_unlock, m_dest, m_addr, offset, data); + } + break; + + // chip enable, 0 -> 1 transitions + case 0x6: // 2dc + m_flash_unlock = BIT(data, 3); + break; + + default: + logerror("%s: unknown write %d %03x %06x %02x %02x\n", machine().describe_context(), m_flash_unlock, m_dest, m_addr, offset, data); + break; + } +} + +void isa16_piu10::mas3507d_mpeg_frame_sync(int state) +{ + m_mp3_mpeg_frame_sync ^= state; +} + +void isa16_piu10::mas3507d_demand(int state) +{ + m_mp3_demand = state; +} diff --git a/src/mame/misc/xtom3d_piu10.h b/src/mame/misc/xtom3d_piu10.h new file mode 100644 index 00000000000..af482831642 --- /dev/null +++ b/src/mame/misc/xtom3d_piu10.h @@ -0,0 +1,53 @@ +// license:BSD-3-Clause +// copyright-holders:windyfairy +#ifndef MAME_MISC_XTOM3D_PIU10_H +#define MAME_MISC_XTOM3D_PIU10_H + +#pragma once + +#include "bus/isa/isa.h" +#include "machine/cat702.h" +#include "machine/intelfsh.h" +#include "sound/dac3350a.h" +#include "sound/mas3507d.h" + + +class isa16_piu10 : public device_t, public device_isa16_card_interface +{ +public: + isa16_piu10(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + template <typename... T> void add_route(T &&... args) { m_dac3350a.lookup()->add_route(std::forward<T>(args)...); } + +protected: + virtual void device_start() override; + virtual void device_reset() override; + + virtual void device_add_mconfig(machine_config &config) override; + +private: + void remap(int space_id, offs_t start, offs_t end) override; + + uint16_t read(offs_t offset); + void write(offs_t offset, uint16_t data); + + void mas3507d_mpeg_frame_sync(int state); + void mas3507d_demand(int state); + + required_device<cat702_piu_device> m_cat702; + required_device<dac3350a_device> m_dac3350a; + required_device<mas3507d_device> m_mas3507d; + required_device<macronix_29f1610mc_16bit_device> m_flash; + + uint32_t m_addr; + uint16_t m_dest; + bool m_flash_unlock; + + uint8_t m_mp3_mpeg_frame_sync, m_mp3_demand; + + uint8_t m_cat702_data; +}; + +DECLARE_DEVICE_TYPE(ISA16_PIU10, isa16_piu10) + +#endif // MAME_MISC_XTOM3D_PIU10_H diff --git a/src/mame/sony/zn.h b/src/mame/sony/zn.h index a6b8d5dc2f0..accc2f74ef4 100644 --- a/src/mame/sony/zn.h +++ b/src/mame/sony/zn.h @@ -21,7 +21,7 @@ #include "machine/7200fifo.h" #include "machine/at28c16.h" #include "machine/bankdev.h" -#include "cat702.h" +#include "machine/cat702.h" #include "machine/gen_latch.h" #include "machine/mb3773.h" #include "machine/nvram.h" |