From 7dad6eea08cbaff5a8f5eb810995d1324eb7b279 Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 16 Feb 2015 20:54:17 +0100 Subject: added AMI_S2152 F_out pin --- src/emu/cpu/amis2000/amis2000.c | 32 ++++++++++++++++++++++++++++++-- src/emu/cpu/amis2000/amis2000.h | 16 ++++++++++++++++ src/emu/cpu/amis2000/amis2000op.inc | 25 +++++++++++++++++++++++++ src/mess/drivers/wildfire.c | 34 +++++++++++++++++++++++++--------- 4 files changed, 96 insertions(+), 11 deletions(-) diff --git a/src/emu/cpu/amis2000/amis2000.c b/src/emu/cpu/amis2000/amis2000.c index 3171e0a403f..ac680096275 100644 --- a/src/emu/cpu/amis2000/amis2000.c +++ b/src/emu/cpu/amis2000/amis2000.c @@ -179,6 +179,22 @@ void amis2000_base_device::device_start() } +void amis2152_cpu_device::device_start() +{ + amis2000_base_device::device_start(); + + m_d2f_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(amis2152_cpu_device::d2f_timer_cb), this)); + + // zerofill + m_d2f_latch = 0; + m_fout_state = 0; + + // register for savestates + save_item(NAME(m_d2f_latch)); + save_item(NAME(m_fout_state)); +} + + //------------------------------------------------- // device_reset - device-specific reset @@ -191,9 +207,21 @@ void amis2000_base_device::device_reset() m_skip = false; // clear i/o + m_a = 0x1fff; + m_write_a(0, m_a, 0xffff); m_d_polarity = 0; - m_d = 0; d_latch_out(false); - m_a = 0; m_write_a(0, 0, 0xffff); + m_d = 0; + d_latch_out(false); +} + + +void amis2152_cpu_device::device_reset() +{ + amis2000_base_device::device_reset(); + + // start d2f timer + m_write_f(0); + d2f_timer_clock(); } diff --git a/src/emu/cpu/amis2000/amis2000.h b/src/emu/cpu/amis2000/amis2000.h index 9fbfc4a09ee..dc5bce68d68 100644 --- a/src/emu/cpu/amis2000/amis2000.h +++ b/src/emu/cpu/amis2000/amis2000.h @@ -208,6 +208,22 @@ class amis2152_cpu_device : public amis2000_base_device { public: amis2152_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // digital-to-frequency converter + UINT8 m_d2f_latch; + emu_timer *m_d2f_timer; + int m_fout_state; + + void d2f_timer_clock(); + TIMER_CALLBACK_MEMBER(d2f_timer_cb); + + // opcode handlers + virtual void op_szk(); }; diff --git a/src/emu/cpu/amis2000/amis2000op.inc b/src/emu/cpu/amis2000/amis2000op.inc index b9e6c2753c4..694ff86d172 100644 --- a/src/emu/cpu/amis2000/amis2000op.inc +++ b/src/emu/cpu/amis2000/amis2000op.inc @@ -490,3 +490,28 @@ void amis2000_base_device::op_rf2() // RF2: reset flag 2 m_f &= ~0x02; } + + + +// AMI S2152 specific handlers + +void amis2152_cpu_device::d2f_timer_clock() +{ + // schedule next timeout (frequency is guessed) + attotime base = attotime::from_hz(unscaled_clock() / 4 / 64); + m_d2f_timer->adjust(base * (0x10 - m_d2f_latch)); +} + +TIMER_CALLBACK_MEMBER(amis2152_cpu_device::d2f_timer_cb) +{ + m_write_f(m_fout_state); + m_fout_state ^= 1; + + d2f_timer_clock(); +} + +void amis2152_cpu_device::op_szk() +{ + // instead of SZK: ???: load d2f latch with ACC(?) + m_d2f_latch = m_acc; +} diff --git a/src/mess/drivers/wildfire.c b/src/mess/drivers/wildfire.c index c1fd9b54bcd..f203a9efbe0 100644 --- a/src/mess/drivers/wildfire.c +++ b/src/mess/drivers/wildfire.c @@ -13,7 +13,7 @@ TODO: - - bad sound (probably MCU related) + - bad sound, A12 seems to strobe too fast - when the game strobes a led faster, it should appear brighter, for example when the ball hits one of the bumpers - some 7segs digits are wrong (mcu on-die decoder is customizable?) @@ -46,6 +46,7 @@ public: UINT8 m_d; UINT16 m_a; + UINT8 m_f; UINT16 m_display_state[0x10]; UINT16 m_display_cache[0x10]; @@ -53,10 +54,12 @@ public: DECLARE_WRITE8_MEMBER(write_d); DECLARE_WRITE16_MEMBER(write_a); + DECLARE_WRITE_LINE_MEMBER(write_f); TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); - void display_update(); bool index_is_7segled(int index); + void display_update(); + void sound_update(); virtual void machine_start(); }; @@ -104,7 +107,7 @@ void wildfire_state::display_update() for (int i = 0; i < 0x10; i++) { // update current state - m_display_state[i] = (~m_a >> i & 1) ? m_d : 0; + m_display_state[i] = (m_a >> i & 1) ? m_d : 0; active_state[i] = 0; @@ -163,14 +166,24 @@ WRITE8_MEMBER(wildfire_state::write_d) WRITE16_MEMBER(wildfire_state::write_a) { - // A12: enable speaker out - // this is in combination with the MCU K4-pin, how? - m_speaker->level_w(data >> 12 & 1); - // A0-A2: select 7segleds // A3-A11: select other leds - m_a = data; + m_a = data ^ 0x1fff; // active-low display_update(); + + // A12: enable speaker + sound_update(); +} + +WRITE_LINE_MEMBER(wildfire_state::write_f) +{ + m_f = (state) ? 1 : 0; + sound_update(); +} + +void wildfire_state::sound_update() +{ + m_speaker->level_w(m_a >> 12 & m_f); } @@ -206,6 +219,7 @@ void wildfire_state::machine_start() m_d = 0; m_a = 0; + m_f = 0; // register for savestates save_item(NAME(m_display_state)); @@ -214,16 +228,18 @@ void wildfire_state::machine_start() save_item(NAME(m_d)); save_item(NAME(m_a)); + save_item(NAME(m_f)); } static MACHINE_CONFIG_START( wildfire, wildfire_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", AMI_S2150, MASTER_CLOCK) + MCFG_CPU_ADD("maincpu", AMI_S2152, MASTER_CLOCK) MCFG_AMI_S2000_READ_I_CB(IOPORT("IN1")) MCFG_AMI_S2000_WRITE_D_CB(WRITE8(wildfire_state, write_d)) MCFG_AMI_S2000_WRITE_A_CB(WRITE16(wildfire_state, write_a)) + MCFG_AMI_S2152_FOUT_CB(WRITELINE(wildfire_state, write_f)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", wildfire_state, display_decay_tick, attotime::from_msec(1)) -- cgit v1.2.3