From b3720a2bf115ca7108d894d0ca738edf1d3e5ff4 Mon Sep 17 00:00:00 2001 From: angelosa Date: Sat, 18 Nov 2023 04:03:06 +0100 Subject: taito/dinoking.cpp: add basic hookups --- src/mame/taito/dinoking.cpp | 119 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 113 insertions(+), 6 deletions(-) diff --git a/src/mame/taito/dinoking.cpp b/src/mame/taito/dinoking.cpp index b1f49b912c0..25e8d535f84 100644 --- a/src/mame/taito/dinoking.cpp +++ b/src/mame/taito/dinoking.cpp @@ -3,6 +3,12 @@ /* +TODO: +- irq 1 +- blitter transfers +- i/o +- hangs at PC=288c + Taito mid-2000s medal hardware Currently two games are dumped: @@ -18,11 +24,13 @@ XTALs: 20 MHz near CPU and sound chip, 25 MHz near video chip #include "emu.h" -#include "screen.h" -#include "speaker.h" #include "cpu/h8/h8s2357.h" +#include "machine/timer.h" #include "sound/okim9810.h" +#include "emupal.h" +#include "screen.h" +#include "speaker.h" namespace { @@ -32,6 +40,8 @@ public: dinoking_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") + , m_screen(*this, "screen") + , m_palette(*this, "palette") { } @@ -40,27 +50,124 @@ public: protected: private: - void mem_map(address_map &map); - required_device m_maincpu; + required_device m_screen; + required_device m_palette; + + u8 m_irq_cause = 0, m_irq_mask = 0; + void irq_check(u8 irq_type); + TIMER_DEVICE_CALLBACK_MEMBER(scanline); + void status_w(offs_t offset, u8 data); + u8 status_r(offs_t offset); + + void mem_map(address_map &map); + u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); }; +u32 dinoking_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + return 0; +} + +u8 dinoking_state::status_r(offs_t offset) +{ + if (offset == 1) + return m_irq_cause; + + return m_irq_mask; +} -void dinoking_state::mem_map(address_map &map) +void dinoking_state::irq_check(u8 irq_type) { - map(0x000000, 0x1fffff).rom().region("maincpu", 0); + m_irq_cause |= irq_type; + + if (m_irq_cause & m_irq_mask) + m_maincpu->set_input_line(1, ASSERT_LINE); + else + m_maincpu->set_input_line(1, CLEAR_LINE); +} + + +void dinoking_state::status_w(offs_t offset, u8 data) +{ + if (offset == 1) + { + m_irq_cause &= ~data; + irq_check(0); + } + + if (offset == 0) + { + m_irq_mask = data; + irq_check(0); + } } +void dinoking_state::mem_map(address_map &map) +{ + map.unmap_value_high(); + map(0x000000, 0x1fffff).rom().region("maincpu", 0); + map(0x400000, 0x4fffff).ram(); + + map(0x61fcb8, 0x61fcb9).rw(FUNC(dinoking_state::status_r), FUNC(dinoking_state::status_w)); + map(0x61fcd2, 0x61fcd3).lrw8( + NAME([] () { + // read in irq service 0x4, blitter status? + return 0; + }), + NAME([this] (offs_t offset, u8 data) { + // blitter irq, after some time PC=4ce + if (offset && data == 8) + irq_check(0x04); + }) + ); + + map(0x800001, 0x800001).w("oki", FUNC(okim9810_device::tmp_register_w)); + map(0x800000, 0x800000).w("oki", FUNC(okim9810_device::write)); + map(0x800002, 0x800002).r("oki", FUNC(okim9810_device::read)); + +} static INPUT_PORTS_START( dinoking ) INPUT_PORTS_END +TIMER_DEVICE_CALLBACK_MEMBER(dinoking_state::scanline) +{ + int scanline = param; + + if (scanline == 240) + { + // checked bits in irq service = 0x3e + // bit 5 has no meaning, just clears in service. + irq_check(0x10); + } +} + + void dinoking_state::dinoking(machine_config &config) { H8S2394(config, m_maincpu, 20_MHz_XTAL); m_maincpu->set_addrmap(AS_PROGRAM, &dinoking_state::mem_map); + TIMER(config, "scantimer").configure_scanline(FUNC(dinoking_state::scanline), "screen", 0, 1); + + SCREEN(config, m_screen, SCREEN_TYPE_RASTER); + m_screen->set_refresh_hz(60); + m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0)); + m_screen->set_size(32*8, 32*8); + m_screen->set_visarea(0*8, 32*8-1, 2*8, 30*8-1); + m_screen->set_screen_update(FUNC(dinoking_state::screen_update)); + m_screen->set_palette(m_palette); + + PALETTE(config, m_palette, palette_device::RGB_555); + + SPEAKER(config, "lspeaker").front_left(); + SPEAKER(config, "rspeaker").front_right(); + + okim9810_device &oki(OKIM9810(config, "oki", XTAL(4'096'000))); + oki.add_route(0, "lspeaker", 0.80); + oki.add_route(1, "rspeaker", 0.80); } -- cgit v1.2.3