From 3e04e969af26841aecf328d812d9915890b1590b Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Wed, 10 Oct 2018 19:19:16 +0200 Subject: topcat: remove MCFG, implement irq, fix some minor issues (nw) --- src/devices/bus/hp_dio/hp98543.cpp | 105 ++++++++++++++++++++++++++++--------- src/devices/bus/hp_dio/hp98543.h | 10 +++- src/devices/bus/hp_dio/hp98544.cpp | 56 +++++++++++++++----- src/devices/bus/hp_dio/hp98544.h | 5 +- src/devices/video/topcat.cpp | 6 +-- src/devices/video/topcat.h | 19 ++----- src/emu/xtal.cpp | 1 + 7 files changed, 143 insertions(+), 59 deletions(-) diff --git a/src/devices/bus/hp_dio/hp98543.cpp b/src/devices/bus/hp_dio/hp98543.cpp index 00de8cc43f9..d6ef2a1065d 100644 --- a/src/devices/bus/hp_dio/hp98543.cpp +++ b/src/devices/bus/hp_dio/hp98543.cpp @@ -33,29 +33,35 @@ MACHINE_CONFIG_START(dio16_98543_device::device_add_mconfig) MCFG_SCREEN_VISIBLE_AREA(0, 1024-1, 0, 400-1) MCFG_SCREEN_REFRESH_RATE(70) MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, dio16_98543_device, vblank_w)); - - MCFG_DEVICE_ADD("topcat0", TOPCAT, XTAL(35904000)) - MCFG_TOPCAT_FB_WIDTH(1024) - MCFG_TOPCAT_FB_HEIGHT(400) - MCFG_TOPCAT_PLANEMASK(1) - - MCFG_DEVICE_ADD("topcat1", TOPCAT, XTAL(35904000)) - MCFG_TOPCAT_FB_WIDTH(1024) - MCFG_TOPCAT_FB_HEIGHT(400) - MCFG_TOPCAT_PLANEMASK(2) - - MCFG_DEVICE_ADD("topcat2", TOPCAT, XTAL(35904000)) - MCFG_TOPCAT_FB_WIDTH(1024) - MCFG_TOPCAT_FB_HEIGHT(400) - MCFG_TOPCAT_PLANEMASK(4) - - MCFG_DEVICE_ADD("topcat3", TOPCAT, XTAL(35904000)) - MCFG_TOPCAT_FB_WIDTH(1024) - MCFG_TOPCAT_FB_HEIGHT(400) - MCFG_TOPCAT_PLANEMASK(8) - - MCFG_DEVICE_ADD("nereid", NEREID, 0) + MCFG_SCREEN_RAW_PARAMS(39504000, 1408, 0, 1024, 425, 0, 400); + + topcat_device &topcat0(TOPCAT(config, "topcat0", XTAL(35904000))); + topcat0.set_fb_width(1024); + topcat0.set_fb_height(400); + topcat0.set_planemask(8); + topcat0.irq_out_cb().set(FUNC(dio16_98543_device::int0_w)); + + topcat_device &topcat1(TOPCAT(config, "topcat1", XTAL(35904000))); + topcat1.set_fb_width(1024); + topcat1.set_fb_height(400); + topcat1.set_planemask(8); + topcat1.irq_out_cb().set(FUNC(dio16_98543_device::int1_w)); + + topcat_device &topcat2(TOPCAT(config, "topcat2", XTAL(35904000))); + topcat2.set_fb_width(1024); + topcat2.set_fb_height(400); + topcat2.set_planemask(4); + topcat2.irq_out_cb().set(FUNC(dio16_98543_device::int2_w)); + + topcat_device &topcat3(TOPCAT(config, "topcat3", XTAL(35904000))); + topcat3.set_fb_width(1024); + topcat3.set_fb_height(400); + topcat3.set_planemask(8); + topcat3.irq_out_cb().set(FUNC(dio16_98543_device::int3_w)); + + NEREID(config, "nereid", 0); MACHINE_CONFIG_END + const tiny_rom_entry *dio16_98543_device::device_rom_region() const { return ROM_NAME(hp98543); @@ -118,11 +124,15 @@ void dio16_98543_device::device_reset() READ16_MEMBER(dio16_98543_device::rom_r) { + if (offset == 1) + return m_intreg; return 0xff00 | m_rom[offset]; } WRITE16_MEMBER(dio16_98543_device::rom_w) { + if (offset == 1) + m_intreg = data; } READ16_MEMBER(dio16_98543_device::ctrl_r) @@ -161,11 +171,54 @@ WRITE_LINE_MEMBER(dio16_98543_device::vblank_w) tc->vblank_w(state); } +WRITE_LINE_MEMBER(dio16_98543_device::int0_w) +{ + m_ints[0] = state; + update_int(); +} + +WRITE_LINE_MEMBER(dio16_98543_device::int1_w) +{ + m_ints[1] = state; + update_int(); +} + +WRITE_LINE_MEMBER(dio16_98543_device::int2_w) +{ + m_ints[2] = state; + update_int(); +} + +WRITE_LINE_MEMBER(dio16_98543_device::int3_w) +{ + + m_ints[3] = state; + update_int(); +} + + +void dio16_98543_device::update_int() +{ + bool state = m_ints[0] || m_ints[1] || m_ints[2] || m_ints[3]; + int line = (m_intreg >> 3) & 7; + + if (!(m_intreg & 0x80)) + state = false; + + irq1_out(line == 1 && state); + irq2_out(line == 2 && state); + irq3_out(line == 3 && state); + irq4_out(line == 4 && state); + irq5_out(line == 5 && state); + irq6_out(line == 6 && state); + irq7_out(line == 7 && state); +} + uint32_t dio16_98543_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { int startx[TOPCAT_COUNT], starty[TOPCAT_COUNT]; int endx[TOPCAT_COUNT], endy[TOPCAT_COUNT]; - + bool plane_enabled[TOPCAT_COUNT]; bool changed = false; for (auto& tc: m_topcat) @@ -174,8 +227,10 @@ uint32_t dio16_98543_device::screen_update(screen_device &screen, bitmap_rgb32 & if (!changed) return UPDATE_HAS_NOT_CHANGED; - for (int i = 0; i < TOPCAT_COUNT; i++) + for (int i = 0; i < TOPCAT_COUNT; i++) { m_topcat[i]->get_cursor_pos(startx[i], starty[i], endx[i], endy[i]); + plane_enabled[i] = m_topcat[i]->plane_enabled(); + } for (int y = 0; y < m_v_pix; y++) { uint32_t *scanline = &bitmap.pix32(y); @@ -186,6 +241,8 @@ uint32_t dio16_98543_device::screen_update(screen_device &screen, bitmap_rgb32 & if (y >= starty[i] && y <= endy[i] && x >= startx[i] && x <= endx[i]) { tmp |= 1 << i; } + if (!plane_enabled[i]) + tmp &= ~(1 << i); } *scanline++ = m_nereid->map_color(tmp); } diff --git a/src/devices/bus/hp_dio/hp98543.h b/src/devices/bus/hp_dio/hp98543.h index e676cfe5867..d2cdd27ca89 100644 --- a/src/devices/bus/hp_dio/hp98543.h +++ b/src/devices/bus/hp_dio/hp98543.h @@ -13,7 +13,6 @@ namespace bus { namespace hp_dio { - class dio16_98543_device : public device_t, public device_dio16_card_interface, @@ -49,15 +48,22 @@ protected: private: WRITE_LINE_MEMBER(vblank_w); + WRITE_LINE_MEMBER(int0_w); + WRITE_LINE_MEMBER(int1_w); + WRITE_LINE_MEMBER(int2_w); + WRITE_LINE_MEMBER(int3_w); + const address_space_config m_space_config; void map(address_map &map); - + void update_int(); static constexpr int m_h_pix = 1024; static constexpr int m_v_pix = 400; required_region_ptr m_rom; required_shared_ptr m_vram; + uint8_t m_intreg; + bool m_ints[4]; }; } // namespace bus::hp_dio diff --git a/src/devices/bus/hp_dio/hp98544.cpp b/src/devices/bus/hp_dio/hp98544.cpp index b797c859df4..cebfa814ffd 100644 --- a/src/devices/bus/hp_dio/hp98544.cpp +++ b/src/devices/bus/hp_dio/hp98544.cpp @@ -15,12 +15,7 @@ #define HP98544_SCREEN_NAME "98544_screen" #define HP98544_ROM_REGION "98544_rom" -ROM_START( hp98544 ) - ROM_REGION( 0x2000, HP98544_ROM_REGION, 0 ) - ROM_LOAD( "98544_1818-1999.bin", 0x000000, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) -ROM_END - -//************************************************************************** +//************************************************************************* // GLOBAL VARIABLES //************************************************************************** @@ -29,6 +24,11 @@ DEFINE_DEVICE_TYPE_NS(HPDIO_98544, bus::hp_dio, dio16_98544_device, "dio98544", namespace bus { namespace hp_dio { +ROM_START( hp98544 ) + ROM_REGION( 0x2000, HP98544_ROM_REGION, 0 ) + ROM_LOAD( "98544_1818-1999.bin", 0x000000, 0x002000, CRC(8c7d6480) SHA1(d2bcfd39452c38bc652df39f84c7041cfdf6bd51) ) +ROM_END + //------------------------------------------------- // device_add_mconfig - add device configuration //------------------------------------------------- @@ -36,22 +36,25 @@ namespace bus { MACHINE_CONFIG_START(dio16_98544_device::device_add_mconfig) MCFG_SCREEN_ADD(HP98544_SCREEN_NAME, RASTER) MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, dio16_98544_device, screen_update) - MCFG_SCREEN_SIZE(1024,1024) + MCFG_SCREEN_SIZE(1024,768) MCFG_SCREEN_VISIBLE_AREA(0, 1024-1, 0, 768-1) MCFG_SCREEN_REFRESH_RATE(70) MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, dio16_98544_device, vblank_w)) + MCFG_SCREEN_RAW_PARAMS(64108800, 1408, 0, 1024, 795, 0, 768); - MCFG_DEVICE_ADD("topcat", TOPCAT, XTAL(35904000)) - MCFG_TOPCAT_FB_WIDTH(1024) - MCFG_TOPCAT_FB_HEIGHT(768) - MCFG_TOPCAT_PLANEMASK(1) - + topcat_device &topcat0(TOPCAT(config, "topcat", XTAL(64108800))); + topcat0.set_fb_width(1024); + topcat0.set_fb_height(768); + topcat0.set_planemask(1); + topcat0.irq_out_cb().set(FUNC(dio16_98544_device::int_w)); MACHINE_CONFIG_END //------------------------------------------------- // rom_region - device-specific ROM region //------------------------------------------------- + + const tiny_rom_entry *dio16_98544_device::device_rom_region() const { return ROM_NAME( hp98544 ); @@ -121,18 +124,46 @@ void dio16_98544_device::device_reset() READ16_MEMBER(dio16_98544_device::rom_r) { + if (offset == 1) + return m_intreg; + return 0xff00 | m_rom[offset]; } // the video chip registers live here, so these writes are valid WRITE16_MEMBER(dio16_98544_device::rom_w) { + if (offset == 1) { + m_intreg = data; + } } WRITE_LINE_MEMBER(dio16_98544_device::vblank_w) { m_topcat->vblank_w(state); } + +WRITE_LINE_MEMBER(dio16_98544_device::int_w) +{ + int line = (m_intreg >> 3) & 7; + + if (state) + m_intreg |= 0x40; + else + m_intreg &= ~0x40; + if (!(m_intreg & 0x80)) + state = false; + + irq1_out(line == 1 && state); + irq2_out(line == 2 && state); + irq3_out(line == 3 && state); + irq4_out(line == 4 && state); + irq5_out(line == 5 && state); + irq6_out(line == 6 && state); + irq7_out(line == 7 && state); + +} + uint32_t dio16_98544_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { int startx, starty, endx, endy; @@ -158,5 +189,6 @@ uint32_t dio16_98544_device::screen_update(screen_device &screen, bitmap_rgb32 & return 0; } + } // namespace bus::hp_dio } // namespace bus diff --git a/src/devices/bus/hp_dio/hp98544.h b/src/devices/bus/hp_dio/hp98544.h index ab53db6933c..d009f8589fd 100644 --- a/src/devices/bus/hp_dio/hp98544.h +++ b/src/devices/bus/hp_dio/hp98544.h @@ -45,14 +45,17 @@ public: private: WRITE_LINE_MEMBER(vblank_w); + WRITE_LINE_MEMBER(int_w); + static constexpr int m_v_pix = 768; static constexpr int m_h_pix = 1024; const address_space_config m_space_config; void map(address_map &map); - required_region_ptr m_rom; required_shared_ptr m_vram; + + uint8_t m_intreg; }; } // namespace bus::hp_dio diff --git a/src/devices/video/topcat.cpp b/src/devices/video/topcat.cpp index 2b5b32a6750..3d1bf8f6d24 100644 --- a/src/devices/video/topcat.cpp +++ b/src/devices/video/topcat.cpp @@ -24,11 +24,10 @@ topcat_device::topcat_device(const machine_config &mconfig, const char *tag, dev void topcat_device::device_start() { + m_int_write_func.resolve_safe(); m_cursor_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(topcat_device::cursor_callback), this)); m_cursor_timer->adjust(attotime::from_hz(3)); - m_int_write_func.resolve_safe(); - save_item(NAME(m_vblank)); save_item(NAME(m_wmove_active)); save_item(NAME(m_vert_retrace_intrq)); @@ -355,7 +354,6 @@ WRITE16_MEMBER(topcat_device::ctrl_w) m_changed = true; switch (offset) { case TOPCAT_REG_VBLANK: - m_vblank = data; break; case TOPCAT_REG_WMOVE_ACTIVE: break; @@ -436,7 +434,7 @@ WRITE16_MEMBER(topcat_device::ctrl_w) m_cursor_width = data; break; default: - logerror("unknown register: %02X = %04x\n", offset, data, mem_mask); + logerror("unknown register write: %02X = %04x (mask %04X)\n", offset, data, mem_mask); break; } } diff --git a/src/devices/video/topcat.h b/src/devices/video/topcat.h index bba7d5e077c..492096ee8b5 100644 --- a/src/devices/video/topcat.h +++ b/src/devices/video/topcat.h @@ -5,24 +5,9 @@ #pragma once -#define MCFG_TOPCAT_FB_WIDTH(_pixels) \ - downcast(*device).set_fb_width(_pixels); - -#define MCFG_TOPCAT_FB_HEIGHT(_pixels) \ - downcast(*device).set_fb_height(_pixels); - -#define MCFG_TOPCAT_PLANEMASK(_mask) \ - downcast(*device).set_planemask(_mask); - -#define MCFG_TOPCAT_INT_CB(_write) \ - downcast(*device).set_int_write_cb(DEVCB_##_write); - class topcat_device : public device_t { public: - template devcb_base& set_int_write_cb(Object &&cb) - { return m_int_write_func.set_callback(std::forward(cb)); } - topcat_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); bool has_changed() { bool ret = m_changed; m_changed = false; return ret; }; void set_fb_width(int _pixels) { m_fb_width = _pixels; } @@ -40,6 +25,7 @@ public: bool plane_enabled(); + auto irq_out_cb() { return m_int_write_func.bind(); } protected: topcat_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -98,6 +84,7 @@ private: }; void window_move(); + void execute_rule(bool src, replacement_rule_t rule, bool &dst); void update_cursor(int x, int y, uint16_t ctrl, uint8_t width); @@ -116,7 +103,7 @@ private: m_vram[offset] &= ~m_plane_mask; } - bool get_vram_pixel(int x, int y) { + bool get_vram_pixel(int x, int y) const { return m_vram[y * m_fb_width + x] & m_plane_mask; } diff --git a/src/emu/xtal.cpp b/src/emu/xtal.cpp index ee2c0c1733b..16c1089780d 100644 --- a/src/emu/xtal.cpp +++ b/src/emu/xtal.cpp @@ -361,6 +361,7 @@ const double XTAL::known_xtals[] = { 60'000'000, /* 60_MHz_XTAL ARM610 */ 61'440'000, /* 61.44_MHz_XTAL Donkey Kong */ 64'000'000, /* 64_MHz_XTAL BattleToads */ + 64'108'800, /* 64.108.800_Mhz_XTAL HP Topcat high-res */ 66'666'700, /* 66.6667_MHz_XTAL Later Midway games */ 67'737'600, /* 67.7376_MHz_XTAL PSX-based h/w, Sony ZN1-2-based */ 68'850'000, /* 68.85_MHz_XTAL Wyse WY-50 */ -- cgit v1.2.3