summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar hap <happppp@users.noreply.github.com>2019-12-23 23:46:25 +0100
committerGravatarGravatar hap <happppp@users.noreply.github.com>2019-12-23 23:46:41 +0100
commite5b54b7038f353e7ef3da75f4721fa554b6a4af6 (patch)
tree7cb02155c0f3c38e52ca6ad4f545154338d7c8f0
parentcd5e994b86e7b552ca3974c6ef7985680b0d40b0 (diff)
kungfur: styling (nw)
-rw-r--r--src/mame/drivers/kungfur.cpp194
1 files changed, 109 insertions, 85 deletions
diff --git a/src/mame/drivers/kungfur.cpp b/src/mame/drivers/kungfur.cpp
index 47451a95ea0..aa506984c4c 100644
--- a/src/mame/drivers/kungfur.cpp
+++ b/src/mame/drivers/kungfur.cpp
@@ -60,14 +60,19 @@ mae(forward), migi(right), ushiro(back), hidari(left)
***************************************************************************/
#include "emu.h"
+
#include "cpu/m6809/m6809.h"
#include "machine/i8255.h"
#include "sound/msm5205.h"
+
#include "speaker.h"
+// internal artwork
#include "kungfur.lh"
+namespace {
+
class kungfur_state : public driver_device
{
public:
@@ -80,50 +85,76 @@ public:
m_lamps(*this, "lamp%u", 0U)
{ }
+ // machine drivers
void kungfur(machine_config &config);
-private:
- DECLARE_WRITE8_MEMBER(kungfur_output_w);
- DECLARE_WRITE8_MEMBER(kungfur_latch1_w);
- DECLARE_WRITE8_MEMBER(kungfur_latch2_w);
- DECLARE_WRITE8_MEMBER(kungfur_latch3_w);
- DECLARE_WRITE8_MEMBER(kungfur_control_w);
- DECLARE_WRITE8_MEMBER(kungfur_adpcm1_w);
- DECLARE_WRITE8_MEMBER(kungfur_adpcm2_w);
- INTERRUPT_GEN_MEMBER(kungfur_irq);
- DECLARE_WRITE_LINE_MEMBER(kfr_adpcm1_int);
- DECLARE_WRITE_LINE_MEMBER(kfr_adpcm2_int);
- void kungfur_map(address_map &map);
-
- uint8_t m_latch[3];
- uint8_t m_control;
- uint32_t m_adpcm_pos[2];
- uint8_t m_adpcm_data[2];
- uint8_t m_adpcm_sel[2];
+protected:
virtual void machine_start() override;
virtual void machine_reset() override;
+
+private:
+ // devices/pointers
required_device<cpu_device> m_maincpu;
required_device<msm5205_device> m_adpcm1;
required_device<msm5205_device> m_adpcm2;
output_finder<14> m_digits;
output_finder<8> m_lamps;
+
+ // address maps
+ void main_map(address_map &map);
+
+ // I/O handlers
+ INTERRUPT_GEN_MEMBER(interrupt);
+ DECLARE_WRITE8_MEMBER(output_w);
+ DECLARE_WRITE8_MEMBER(latch1_w);
+ DECLARE_WRITE8_MEMBER(latch2_w);
+ DECLARE_WRITE8_MEMBER(latch3_w);
+ DECLARE_WRITE8_MEMBER(control_w);
+ DECLARE_WRITE8_MEMBER(adpcm1_w);
+ DECLARE_WRITE8_MEMBER(adpcm2_w);
+ DECLARE_WRITE_LINE_MEMBER(adpcm1_int);
+ DECLARE_WRITE_LINE_MEMBER(adpcm2_int);
+
+ u8 m_control = 0;
+ u8 m_digit_data[3] = { 0, 0, 0 };
+
+ u32 m_adpcm_pos[2] = { 0, 0 };
+ u8 m_adpcm_data[2] = { 0, 0 };
+ u8 m_adpcm_sel[2] = { 0, 0 };
};
+void kungfur_state::machine_start()
+{
+ m_digits.resolve();
+ m_lamps.resolve();
+
+ // register for savestates
+ save_item(NAME(m_control));
+ save_item(NAME(m_digit_data));
+
+ save_item(NAME(m_adpcm_pos));
+ save_item(NAME(m_adpcm_data));
+ save_item(NAME(m_adpcm_sel));
+}
-INTERRUPT_GEN_MEMBER(kungfur_state::kungfur_irq)
+void kungfur_state::machine_reset()
{
- if (m_control & 0x10)
- device.execute().set_input_line(M6809_IRQ_LINE, ASSERT_LINE);
+ m_control = 0;
}
-/***************************************************************************
- I/O
+/******************************************************************************
+ I/O
+******************************************************************************/
-***************************************************************************/
+INTERRUPT_GEN_MEMBER(kungfur_state::interrupt)
+{
+ if (m_control & 0x10)
+ device.execute().set_input_line(M6809_IRQ_LINE, ASSERT_LINE);
+}
-WRITE8_MEMBER(kungfur_state::kungfur_output_w)
+WRITE8_MEMBER(kungfur_state::output_w)
{
// d0-d2: output led7seg
static const u8 lut_digits[24] =
@@ -136,14 +167,14 @@ WRITE8_MEMBER(kungfur_state::kungfur_output_w)
{
u8 offs = i << 3 | (data & 7);
if (lut_digits[offs])
- m_digits[lut_digits[offs] - 1] = m_latch[i];
+ m_digits[lut_digits[offs] - 1] = m_digit_data[i];
}
// 2.6 goes to level lamps
if ((data & 7) == 6)
{
for (u8 i = 0; i < 5; i++)
- m_lamps[i] = BIT(m_latch[2], i);
+ m_lamps[i] = BIT(m_digit_data[2], i);
}
// d7: game-over lamp, d3-d4: marquee lamps
@@ -158,23 +189,23 @@ WRITE8_MEMBER(kungfur_state::kungfur_output_w)
// lamp output latches
-WRITE8_MEMBER(kungfur_state::kungfur_latch1_w)
+WRITE8_MEMBER(kungfur_state::latch1_w)
{
- m_latch[0] = data;
+ m_digit_data[0] = data;
}
-WRITE8_MEMBER(kungfur_state::kungfur_latch2_w)
+WRITE8_MEMBER(kungfur_state::latch2_w)
{
- m_latch[1] = data;
+ m_digit_data[1] = data;
}
-WRITE8_MEMBER(kungfur_state::kungfur_latch3_w)
+WRITE8_MEMBER(kungfur_state::latch3_w)
{
- m_latch[2] = data;
+ m_digit_data[2] = data;
}
-WRITE8_MEMBER(kungfur_state::kungfur_control_w)
+WRITE8_MEMBER(kungfur_state::control_w)
{
// d0-d3: N/C
// d4: irq ack
@@ -200,31 +231,31 @@ WRITE8_MEMBER(kungfur_state::kungfur_control_w)
}
// adpcm latches
-WRITE8_MEMBER(kungfur_state::kungfur_adpcm1_w)
+WRITE8_MEMBER(kungfur_state::adpcm1_w)
{
m_adpcm_data[0] = data;
}
-WRITE8_MEMBER(kungfur_state::kungfur_adpcm2_w)
+WRITE8_MEMBER(kungfur_state::adpcm2_w)
{
m_adpcm_data[1] = data;
}
// adpcm callbacks
-WRITE_LINE_MEMBER(kungfur_state::kfr_adpcm1_int)
+WRITE_LINE_MEMBER(kungfur_state::adpcm1_int)
{
- uint8_t *ROM = memregion("adpcm1")->base();
- uint8_t data = ROM[m_adpcm_pos[0] & 0x1ffff];
+ u8 *ROM = memregion("adpcm1")->base();
+ u8 data = ROM[m_adpcm_pos[0] & 0x1ffff];
m_adpcm1->write_data(m_adpcm_sel[0] ? data & 0xf : data >> 4 & 0xf);
m_adpcm_pos[0] += m_adpcm_sel[0];
m_adpcm_sel[0] ^= 1;
}
-WRITE_LINE_MEMBER(kungfur_state::kfr_adpcm2_int)
+WRITE_LINE_MEMBER(kungfur_state::adpcm2_int)
{
- uint8_t *ROM = memregion("adpcm2")->base();
- uint8_t data = ROM[m_adpcm_pos[1] & 0x3ffff];
+ u8 *ROM = memregion("adpcm2")->base();
+ u8 data = ROM[m_adpcm_pos[1] & 0x3ffff];
m_adpcm2->write_data(m_adpcm_sel[1] ? data & 0xf : data >> 4 & 0xf);
m_adpcm_pos[1] += m_adpcm_sel[1];
@@ -232,22 +263,26 @@ WRITE_LINE_MEMBER(kungfur_state::kfr_adpcm2_int)
}
-void kungfur_state::kungfur_map(address_map &map)
+
+/******************************************************************************
+ Address Maps
+******************************************************************************/
+
+void kungfur_state::main_map(address_map &map)
{
map(0x0000, 0x07ff).ram();
- map(0x4000, 0x4000).w(FUNC(kungfur_state::kungfur_adpcm1_w));
- map(0x4004, 0x4004).w(FUNC(kungfur_state::kungfur_adpcm2_w));
+ map(0x4000, 0x4000).w(FUNC(kungfur_state::adpcm1_w));
+ map(0x4004, 0x4004).w(FUNC(kungfur_state::adpcm2_w));
map(0x4008, 0x400b).rw("ppi8255_0", FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x400c, 0x400f).rw("ppi8255_1", FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0xc000, 0xffff).rom();
}
-/***************************************************************************
-
- Inputs
-***************************************************************************/
+/******************************************************************************
+ Input Ports
+******************************************************************************/
static INPUT_PORTS_START( kungfur )
PORT_START("IN0")
@@ -275,52 +310,33 @@ static INPUT_PORTS_START( kungfur )
INPUT_PORTS_END
-/***************************************************************************
-
- Machine Config
-
-***************************************************************************/
-
-void kungfur_state::machine_start()
-{
- m_digits.resolve();
- m_lamps.resolve();
-
- save_item(NAME(m_control));
- save_item(NAME(m_latch));
-
- save_item(NAME(m_adpcm_pos));
- save_item(NAME(m_adpcm_data));
- save_item(NAME(m_adpcm_sel));
-}
-void kungfur_state::machine_reset()
-{
- m_control = 0;
-}
+/******************************************************************************
+ Machine Drivers
+******************************************************************************/
void kungfur_state::kungfur(machine_config &config)
{
/* basic machine hardware */
MC6809(config, m_maincpu, 4000000); // 4MHz?
- m_maincpu->set_addrmap(AS_PROGRAM, &kungfur_state::kungfur_map);
+ m_maincpu->set_addrmap(AS_PROGRAM, &kungfur_state::main_map);
const attotime irq_period = attotime::from_hz(4000000 / 0x1000); // = 976.5Hz, accurate
- m_maincpu->set_periodic_int(FUNC(kungfur_state::kungfur_irq), irq_period);
+ m_maincpu->set_periodic_int(FUNC(kungfur_state::interrupt), irq_period);
i8255_device &ppi0(I8255A(config, "ppi8255_0"));
// $4008 - always $83 (PPI mode 0, ports B & lower C as input)
- ppi0.out_pa_callback().set(FUNC(kungfur_state::kungfur_output_w));
+ ppi0.out_pa_callback().set(FUNC(kungfur_state::output_w));
ppi0.tri_pa_callback().set_constant(0);
ppi0.in_pb_callback().set_ioport("IN0");
ppi0.in_pc_callback().set_ioport("IN1");
- ppi0.out_pc_callback().set(FUNC(kungfur_state::kungfur_control_w));
+ ppi0.out_pc_callback().set(FUNC(kungfur_state::control_w));
i8255_device &ppi1(I8255A(config, "ppi8255_1"));
// $400c - always $80 (PPI mode 0, all ports as output)
- ppi1.out_pa_callback().set(FUNC(kungfur_state::kungfur_latch1_w));
- ppi1.out_pb_callback().set(FUNC(kungfur_state::kungfur_latch2_w));
- ppi1.out_pc_callback().set(FUNC(kungfur_state::kungfur_latch3_w));
+ ppi1.out_pa_callback().set(FUNC(kungfur_state::latch1_w));
+ ppi1.out_pb_callback().set(FUNC(kungfur_state::latch2_w));
+ ppi1.out_pc_callback().set(FUNC(kungfur_state::latch3_w));
/* no video! */
@@ -328,22 +344,21 @@ void kungfur_state::kungfur(machine_config &config)
SPEAKER(config, "mono").front_center(); // 2 speakers, but likely mono sound mix
MSM5205(config, m_adpcm1, 384_kHz_XTAL); // clock verified with recording
- m_adpcm1->vck_legacy_callback().set(FUNC(kungfur_state::kfr_adpcm1_int));
+ m_adpcm1->vck_legacy_callback().set(FUNC(kungfur_state::adpcm1_int));
m_adpcm1->set_prescaler_selector(msm5205_device::S48_4B);
m_adpcm1->add_route(ALL_OUTPUTS, "mono", 1.0);
MSM5205(config, m_adpcm2, 384_kHz_XTAL); // clock verified with recording
- m_adpcm2->vck_legacy_callback().set(FUNC(kungfur_state::kfr_adpcm2_int));
+ m_adpcm2->vck_legacy_callback().set(FUNC(kungfur_state::adpcm2_int));
m_adpcm2->set_prescaler_selector(msm5205_device::S48_4B);
m_adpcm2->add_route(ALL_OUTPUTS, "mono", 1.0);
}
-/***************************************************************************
-
- Game driver(s)
-***************************************************************************/
+/******************************************************************************
+ ROM Definitions
+******************************************************************************/
ROM_START( kungfur )
ROM_REGION( 0x10000, "maincpu", 0 )
@@ -359,4 +374,13 @@ ROM_START( kungfur )
ROM_LOAD( "kr6.bin", 0x20000, 0x10000, CRC(9ea75d4a) SHA1(57445ccb961acb11a25cdac81f2e543d92bcb7f9) )
ROM_END
-GAMEL( 1987, kungfur, 0, kungfur, kungfur, kungfur_state, empty_init, ROT0, "Namco", "Kung-Fu Roushi", MACHINE_SUPPORTS_SAVE, layout_kungfur )
+} // anonymous namespace
+
+
+
+/******************************************************************************
+ Drivers
+******************************************************************************/
+
+/* YEAR NAME PARENT MACHINE INPUT CLASS INIT MONITOR COMPANY, FULLNAME, FLAGS */
+GAMEL( 1987, kungfur, 0, kungfur, kungfur, kungfur_state, empty_init, ROT0, "Namco", "Kung-Fu Roushi", MACHINE_SUPPORTS_SAVE, layout_kungfur )