From e99969f33300106edb90e428bb93ba084a1a8f3a Mon Sep 17 00:00:00 2001 From: David Haywood Date: Thu, 21 Jun 2018 17:28:13 +0100 Subject: [PATCH] misc device finder / private members (nw) (#3681) * misc device finder / private members (nw) * more (nw) --- src/mame/drivers/jongkyo.cpp | 51 ++++++------- src/mame/drivers/namcos86.cpp | 3 +- src/mame/drivers/nsmpoker.cpp | 11 +-- src/mame/drivers/pachifev.cpp | 11 +-- src/mame/drivers/pinkiri8.cpp | 38 +++++----- src/mame/drivers/system1.cpp | 11 +-- src/mame/includes/namcos86.h | 20 +++-- src/mame/includes/system1.h | 135 ++++++++++++++++++---------------- 8 files changed, 146 insertions(+), 134 deletions(-) diff --git a/src/mame/drivers/jongkyo.cpp b/src/mame/drivers/jongkyo.cpp index 07d8327cbeb..7b8f5b7e889 100644 --- a/src/mame/drivers/jongkyo.cpp +++ b/src/mame/drivers/jongkyo.cpp @@ -42,15 +42,30 @@ class jongkyo_state : public driver_device public: jongkyo_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_videoram(*this, "videoram"), - m_maincpu(*this, "maincpu") { } + m_maincpu(*this, "maincpu"), + m_bank1(*this, "bank1"), + m_bank1d(*this, "bank1d"), + m_bank0d(*this, "bank0d"), + m_mainregion(*this, "maincpu"), + m_videoram(*this, "videoram") + { } + void jongkyo(machine_config &config); + + void init_jongkyo(); + +private: /* misc */ uint8_t m_rom_bank; uint8_t m_mux_data; uint8_t m_flip_screen; /* memory pointers */ + required_device m_maincpu; + required_memory_bank m_bank1; + required_memory_bank m_bank1d; + required_memory_bank m_bank0d; + required_region_ptr m_mainregion; required_shared_ptr m_videoram; uint8_t m_videoram2[0x4000]; DECLARE_WRITE8_MEMBER(bank_select_w); @@ -60,14 +75,11 @@ public: DECLARE_WRITE8_MEMBER(unknown_w); DECLARE_READ8_MEMBER(input_1p_r); DECLARE_READ8_MEMBER(input_2p_r); - void init_jongkyo(); virtual void machine_start() override; virtual void machine_reset() override; virtual void video_start() override; DECLARE_PALETTE_INIT(jongkyo); uint32_t screen_update_jongkyo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - required_device m_maincpu; - void jongkyo(machine_config &config); void decrypted_opcodes_map(address_map &map); void jongkyo_memmap(address_map &map); void jongkyo_portmap(address_map &map); @@ -145,8 +157,8 @@ WRITE8_MEMBER(jongkyo_state::bank_select_w) if (offset & 1) m_rom_bank |= mask; - membank("bank1")->set_entry(m_rom_bank); - membank("bank1d")->set_entry(m_rom_bank); + m_bank1->set_entry(m_rom_bank); + m_bank1d->set_entry(m_rom_bank); } WRITE8_MEMBER(jongkyo_state::mux_w) @@ -567,36 +579,25 @@ ROM_END void jongkyo_state::init_jongkyo() { - uint8_t *rom = memregion("maincpu")->base(); - /* first of all, do a simple bitswap */ for (int i = 0x6000; i < 0x8c00; ++i) { - rom[i] = bitswap<8>(rom[i], 7,6,5,3,4,2,1,0); + m_mainregion[i] = bitswap<8>(m_mainregion[i], 7,6,5,3,4,2,1,0); } uint8_t *opcodes = auto_alloc_array(machine(), uint8_t, 0x6c00+0x400*8); - segacrpt_z80_device* cpu = (segacrpt_z80_device*)machine().device(":maincpu"); - - if (!cpu) - { - fatalerror("can't find cpu!\n"); - } - else - { - cpu->set_region_p(rom); - cpu->set_decrypted_p(opcodes); - } + m_maincpu->set_region_p(m_mainregion); + m_maincpu->set_decrypted_p(opcodes); /* then do the standard Sega decryption */ - - membank("bank1")->configure_entries(0, 8, rom+0x6c00, 0x400); - membank("bank1d")->configure_entries(0, 8, opcodes+0x6c00, 0x400); - membank("bank0d")->set_base(opcodes); + m_bank1->configure_entries(0, 8, m_mainregion+0x6c00, 0x400); + m_bank1d->configure_entries(0, 8, opcodes+0x6c00, 0x400); + m_bank0d->set_base(opcodes); } + /************************************* * * Game driver diff --git a/src/mame/drivers/namcos86.cpp b/src/mame/drivers/namcos86.cpp index 173eba135ea..9c86075904b 100644 --- a/src/mame/drivers/namcos86.cpp +++ b/src/mame/drivers/namcos86.cpp @@ -180,7 +180,6 @@ TODO: #include "cpu/m6809/m6809.h" #include "cpu/m6800/m6801.h" #include "sound/ym2151.h" -#include "sound/n63701x.h" #include "screen.h" #include "speaker.h" @@ -304,7 +303,7 @@ WRITE8_MEMBER(namcos86_state::cus115_w) case 1: case 2: case 3: - machine().device("namco2")->namco_63701x_w(space, (offset & 0x1e00) >> 9,data); + m_63701x->namco_63701x_w(space, (offset & 0x1e00) >> 9,data); break; case 4: diff --git a/src/mame/drivers/nsmpoker.cpp b/src/mame/drivers/nsmpoker.cpp index 7d136a9683c..36b4be77172 100644 --- a/src/mame/drivers/nsmpoker.cpp +++ b/src/mame/drivers/nsmpoker.cpp @@ -78,6 +78,9 @@ public: m_maincpu(*this, "maincpu"), m_gfxdecode(*this, "gfxdecode") { } + void nsmpoker(machine_config &config); + +private: required_shared_ptr m_videoram; required_shared_ptr m_colorram; tilemap_t *m_bg_tilemap; @@ -90,9 +93,8 @@ public: virtual void machine_reset() override; uint32_t screen_update_nsmpoker(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(nsmpoker_interrupt); - required_device m_maincpu; + required_device m_maincpu; required_device m_gfxdecode; - void nsmpoker(machine_config &config); void nsmpoker_map(address_map &map); void nsmpoker_portmap(address_map &map); }; @@ -406,9 +408,8 @@ GFXDECODE_END void nsmpoker_state::machine_reset() { // Disable auto wait state generation by raising the READY line on reset - tms9995_device* cpu = static_cast(machine().device("maincpu")); - cpu->ready_line(ASSERT_LINE); - cpu->reset_line(ASSERT_LINE); + m_maincpu->ready_line(ASSERT_LINE); + m_maincpu->reset_line(ASSERT_LINE); } /************************* diff --git a/src/mame/drivers/pachifev.cpp b/src/mame/drivers/pachifev.cpp index 7ca4614a2d5..b615ad0de8d 100644 --- a/src/mame/drivers/pachifev.cpp +++ b/src/mame/drivers/pachifev.cpp @@ -96,6 +96,9 @@ public: : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu") { } + void pachifev(machine_config &config); + +private: /* controls related */ int m_power; int m_max_power; @@ -112,8 +115,7 @@ public: virtual void machine_start() override; virtual void machine_reset() override; DECLARE_WRITE_LINE_MEMBER(vblank_w); - required_device m_maincpu; - void pachifev(machine_config &config); + required_device m_maincpu; void pachifev_cru(address_map &map); void pachifev_map(address_map &map); }; @@ -288,11 +290,10 @@ WRITE_LINE_MEMBER(pachifev_state::pf_adpcm_int) void pachifev_state::machine_reset() { - tms9995_device* cpu = static_cast(machine().device("maincpu")); // Pulling down the line on RESET configures the CPU to insert one wait // state on external memory accesses - cpu->ready_line(CLEAR_LINE); - cpu->reset_line(ASSERT_LINE); + m_maincpu->ready_line(CLEAR_LINE); + m_maincpu->reset_line(ASSERT_LINE); m_power=0; m_max_power=0; diff --git a/src/mame/drivers/pinkiri8.cpp b/src/mame/drivers/pinkiri8.cpp index b38f19e61a2..e7c9c751a72 100644 --- a/src/mame/drivers/pinkiri8.cpp +++ b/src/mame/drivers/pinkiri8.cpp @@ -45,6 +45,23 @@ Dumped by Chackn #include "screen.h" #include "speaker.h" +/* VDP device to give us our own memory map */ +class janshi_vdp_device : public device_t, public device_memory_interface +{ +public: + janshi_vdp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + void map(address_map &map); + +protected: + virtual void device_validity_check(validity_checker &valid) const override; + virtual void device_start() override; + virtual void device_reset() override; + virtual space_config_vector memory_space_config() const override; + +private: + address_space_config m_space_config; +}; class pinkiri8_state : public driver_device { @@ -61,6 +78,7 @@ public: m_janshi_paletteram2(*this, "janshivdp:paletteram2"), m_janshi_crtc_regs(*this, "janshivdp:crtc_regs"), m_maincpu(*this, "maincpu"), + m_vdp(*this, "janshivdp"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette") { } @@ -105,29 +123,13 @@ private: uint8_t m_prot_index; required_device m_maincpu; + required_device m_vdp; required_device m_gfxdecode; required_device m_palette; }; -/* VDP device to give us our own memory map */ -class janshi_vdp_device : public device_t, public device_memory_interface -{ -public: - janshi_vdp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - - void map(address_map &map); - -protected: - virtual void device_validity_check(validity_checker &valid) const override; - virtual void device_start() override; - virtual void device_reset() override; - virtual space_config_vector memory_space_config() const override; - -private: - address_space_config m_space_config; -}; void janshi_vdp_device::map(address_map &map) @@ -428,7 +430,7 @@ WRITE8_MEMBER(pinkiri8_state::pinkiri8_vram_w) case 3: { - address_space &vdp_space = machine().device("janshivdp")->space(); + address_space &vdp_space = m_vdp->space(); if (LOG_VRAM) printf("%02x ", data); m_prev_writes++; diff --git a/src/mame/drivers/system1.cpp b/src/mame/drivers/system1.cpp index b7c3a373d22..3a2a70f6ed4 100644 --- a/src/mame/drivers/system1.cpp +++ b/src/mame/drivers/system1.cpp @@ -223,7 +223,6 @@ seem to have access to. #include "includes/system1.h" #include "cpu/mcs51/mcs51.h" -#include "machine/z80pio.h" #include "machine/segacrpt_device.h" #include "machine/mc8123.h" #include "sound/sn76496.h" @@ -526,8 +525,6 @@ WRITE8_MEMBER(system1_state::sound_control_w) READ8_MEMBER(system1_state::sound_data_r) { - z80pio_device *pio = machine().device("pio"); - /* if we have an 8255 PPI, get the data from the port and toggle the ack */ if (m_ppi8255 != nullptr) { @@ -537,11 +534,11 @@ READ8_MEMBER(system1_state::sound_data_r) } /* if we have a Z80 PIO, get the data from the port and toggle the strobe */ - else if (pio != nullptr) + else if (m_pio != nullptr) { - uint8_t data = pio->port_read(z80pio_device::PORT_A); - pio->strobe(z80pio_device::PORT_A, false); - pio->strobe(z80pio_device::PORT_A, true); + uint8_t data = m_pio->port_read(z80pio_device::PORT_A); + m_pio->strobe(z80pio_device::PORT_A, false); + m_pio->strobe(z80pio_device::PORT_A, true); return data; } diff --git a/src/mame/includes/namcos86.h b/src/mame/includes/namcos86.h index 9de1b956abf..eb0e6c4ebe7 100644 --- a/src/mame/includes/namcos86.h +++ b/src/mame/includes/namcos86.h @@ -2,6 +2,7 @@ // copyright-holders:Nicola Salmoria #include "machine/watchdog.h" #include "sound/namco.h" +#include "sound/n63701x.h" #include "emupal.h" class namcos86_state : public driver_device @@ -15,6 +16,7 @@ public: , m_cus30(*this, "namco") , m_gfxdecode(*this, "gfxdecode") , m_palette(*this, "palette") + , m_63701x(*this, "namco2") , m_rthunder_videoram1(*this, "videoram1") , m_rthunder_videoram2(*this, "videoram2") , m_rthunder_spriteram(*this, "spriteram") @@ -22,6 +24,15 @@ public: , m_leds(*this, "led%u", 0U) { } + void genpeitd(machine_config &config); + void wndrmomo(machine_config &config); + void roishtar(machine_config &config); + void rthunder(machine_config &config); + void hopmappy(machine_config &config); + + void init_namco86(); + +private: DECLARE_WRITE8_MEMBER(bankswitch1_w); DECLARE_WRITE8_MEMBER(bankswitch1_ext_w); DECLARE_WRITE8_MEMBER(bankswitch2_w); @@ -50,7 +61,6 @@ public: TILE_GET_INFO_MEMBER(get_tile_info2); TILE_GET_INFO_MEMBER(get_tile_info3); - void init_namco86(); DECLARE_PALETTE_INIT(namcos86); uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -58,11 +68,6 @@ public: void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void scroll_w(address_space &space, int offset, int data, int layer); - void genpeitd(machine_config &config); - void wndrmomo(machine_config &config); - void roishtar(machine_config &config); - void rthunder(machine_config &config); - void hopmappy(machine_config &config); void common_mcu_map(address_map &map); void cpu1_map(address_map &map); void genpeitd_cpu2_map(address_map &map); @@ -77,7 +82,6 @@ public: void wndrmomo_cpu2_map(address_map &map); void wndrmomo_mcu_map(address_map &map); -protected: virtual void machine_start() override; virtual void video_start() override; @@ -87,6 +91,7 @@ protected: required_device m_cus30; required_device m_gfxdecode; required_device m_palette; + optional_device m_63701x; required_shared_ptr m_rthunder_videoram1; required_shared_ptr m_rthunder_videoram2; required_shared_ptr m_rthunder_spriteram; @@ -103,7 +108,6 @@ protected: const uint8_t *m_tile_address_prom; int m_copy_sprites; -private: inline void get_tile_info(tile_data &tileinfo,int tile_index,int layer,uint8_t *vram); void set_scroll(int layer); }; diff --git a/src/mame/includes/system1.h b/src/mame/includes/system1.h index b5822ba415b..5c8a77f4bd4 100644 --- a/src/mame/includes/system1.h +++ b/src/mame/includes/system1.h @@ -2,6 +2,7 @@ // copyright-holders:Jarek Parchanski, Nicola Salmoria, Mirko Buffoni #include "cpu/z80/z80.h" +#include "machine/z80pio.h" #include "machine/gen_latch.h" #include "machine/i8255.h" #include "machine/segacrp2_device.h" @@ -15,6 +16,7 @@ public: system1_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_ppi8255(*this, "ppi8255"), + m_pio(*this, "pio"), m_ram(*this, "ram"), m_spriteram(*this, "spriteram"), m_paletteram(*this, "palette"), @@ -35,7 +37,75 @@ public: m_banked_decrypted_opcodes(nullptr) { } + void sys1ppix_315_5051(machine_config &config); + void sys1ppisx_315_5064(machine_config &config); + void sys2_317_0007(machine_config &config); + void sys1piox_315_5110(machine_config &config); + void sys1piox_315_5065(machine_config &config); + void sys2m(machine_config &config); + void sys1ppix_315_5178(machine_config &config); + void sys1ppix_315_5179(machine_config &config); + void sys1piox_315_5093(machine_config &config); + void sys2_315_5176(machine_config &config); + void sys2(machine_config &config); + void sys2_315_5177(machine_config &config); + void nob(machine_config &config); + void sys1ppisx_315_5041(machine_config &config); + void sys1piox_315_5132(machine_config &config); + void sys1piox_315_5162(machine_config &config); + void sys1piox_315_5133(machine_config &config); + void sys1pioxb(machine_config &config); + void sys1ppi(machine_config &config); + void sys1piox_315_5135(machine_config &config); + void sys2rowxboot(machine_config &config); + void sys1piox_315_5102(machine_config &config); + void sys1piosx_315_spat(machine_config &config); + void sys2x(machine_config &config); + void sys1piox_315_5051(machine_config &config); + void sys1piox_315_5098(machine_config &config); + void sys1piosx_315_5099(machine_config &config); + void sys2xboot(machine_config &config); + void sys2xb(machine_config &config); + void nobm(machine_config &config); + void mcu(machine_config &config); + void sys2_317_0006(machine_config &config); + void sys1piox_317_0006(machine_config &config); + void sys1ppix_315_5033(machine_config &config); + void sys1pio(machine_config &config); + void sys1pios(machine_config &config); + void sys2rowm(machine_config &config); + void sys1ppix_315_5098(machine_config &config); + void sys1ppix_315_5048(machine_config &config); + void sys2row(machine_config &config); + void sys1ppis(machine_config &config); + void sys1ppix_315_5065(machine_config &config); + void sys1piox_315_5177(machine_config &config); + void sys1piox_315_5155(machine_config &config); + void sys2rowxb(machine_config &config); + + void init_bank00(); + void init_bank0c(); + void init_bank44(); + + void init_nobb(); + void init_dakkochn(); + void init_bootleg(); + void init_shtngmst(); + void init_blockgal(); + void init_nob(); + void init_myherok(); + void init_ufosensi(); + void init_wbml(); + void init_bootsys2(); + void init_bootsys2d(); + void init_choplift(); + + DECLARE_CUSTOM_INPUT_MEMBER(dakkochn_mux_data_r); + DECLARE_CUSTOM_INPUT_MEMBER(dakkochn_mux_status_r); + +private: optional_device m_ppi8255; + optional_device m_pio; required_shared_ptr m_ram; required_shared_ptr m_spriteram; required_shared_ptr m_paletteram; @@ -89,27 +159,8 @@ public: DECLARE_READ8_MEMBER(system1_videoram_r); DECLARE_WRITE8_MEMBER(system1_videoram_w); DECLARE_WRITE8_MEMBER(system1_paletteram_w); - DECLARE_CUSTOM_INPUT_MEMBER(dakkochn_mux_data_r); - DECLARE_CUSTOM_INPUT_MEMBER(dakkochn_mux_status_r); DECLARE_WRITE8_MEMBER(sound_control_w); - void init_bank00(); - void init_bank0c(); - void init_bank44(); - - void init_nobb(); - void init_dakkochn(); - void init_bootleg(); - void init_shtngmst(); - void init_blockgal(); - void init_nob(); - void init_myherok(); - void init_ufosensi(); - void init_wbml(); - void init_bootsys2(); - void init_bootsys2d(); - void init_choplift(); - TILE_GET_INFO_MEMBER(tile_get_info); virtual void machine_start() override; virtual void machine_reset() override; @@ -145,51 +196,7 @@ public: optional_memory_bank m_bank1d; std::unique_ptr m_banked_decrypted_opcodes; - void sys1ppix_315_5051(machine_config &config); - void sys1ppisx_315_5064(machine_config &config); - void sys2_317_0007(machine_config &config); - void sys1piox_315_5110(machine_config &config); - void sys1piox_315_5065(machine_config &config); - void sys2m(machine_config &config); - void sys1ppix_315_5178(machine_config &config); - void sys1ppix_315_5179(machine_config &config); - void sys1piox_315_5093(machine_config &config); - void sys2_315_5176(machine_config &config); - void sys2(machine_config &config); - void sys2_315_5177(machine_config &config); - void nob(machine_config &config); - void sys1ppisx_315_5041(machine_config &config); - void sys1piox_315_5132(machine_config &config); - void sys1piox_315_5162(machine_config &config); - void sys1piox_315_5133(machine_config &config); - void sys1pioxb(machine_config &config); - void sys1ppi(machine_config &config); - void sys1piox_315_5135(machine_config &config); - void sys2rowxboot(machine_config &config); - void sys1piox_315_5102(machine_config &config); - void sys1piosx_315_spat(machine_config &config); - void sys2x(machine_config &config); - void sys1piox_315_5051(machine_config &config); - void sys1piox_315_5098(machine_config &config); - void sys1piosx_315_5099(machine_config &config); - void sys2xboot(machine_config &config); - void sys2xb(machine_config &config); - void nobm(machine_config &config); - void mcu(machine_config &config); - void sys2_317_0006(machine_config &config); - void sys1piox_317_0006(machine_config &config); - void sys1ppix_315_5033(machine_config &config); - void sys1pio(machine_config &config); - void sys1pios(machine_config &config); - void sys2rowm(machine_config &config); - void sys1ppix_315_5098(machine_config &config); - void sys1ppix_315_5048(machine_config &config); - void sys2row(machine_config &config); - void sys1ppis(machine_config &config); - void sys1ppix_315_5065(machine_config &config); - void sys1piox_315_5177(machine_config &config); - void sys1piox_315_5155(machine_config &config); - void sys2rowxb(machine_config &config); + void banked_decrypted_opcodes_map(address_map &map); void decrypted_opcodes_map(address_map &map); void mcu_io_map(address_map &map);