diff options
author | 2018-06-22 19:33:22 -0400 | |
---|---|---|
committer | 2018-06-22 19:33:22 -0400 | |
commit | ddddc308102b8f9319db6b2676bbb4e88d669a8c (patch) | |
tree | b9a060407139dce87ad8dd05dee065c238f06f18 | |
parent | 9c7f1303b2a46192ac8fdca7b4695d693d290137 (diff) |
bus/nes: Eliminate remaining machine().device usage the ugly way (nw)
-rw-r--r-- | src/devices/bus/nes/mmc5.cpp | 25 | ||||
-rw-r--r-- | src/devices/bus/nes/mmc5.h | 7 | ||||
-rw-r--r-- | src/devices/bus/nes/nanjing.cpp | 7 | ||||
-rw-r--r-- | src/devices/bus/nes/nanjing.h | 5 |
4 files changed, 31 insertions, 13 deletions
diff --git a/src/devices/bus/nes/mmc5.cpp b/src/devices/bus/nes/mmc5.cpp index bcecffd1ecb..3fb4a29e0a7 100644 --- a/src/devices/bus/nes/mmc5.cpp +++ b/src/devices/bus/nes/mmc5.cpp @@ -48,6 +48,12 @@ nes_exrom_device::nes_exrom_device(const machine_config &mconfig, const char *ta , m_irq_status(0), m_irq_enable(0), m_mult1(0), m_mult2(0), m_mmc5_scanline(0), m_vrom_page_a(0), m_vrom_page_b(0), m_floodtile(0), m_floodattr(0) , m_prg_mode(0), m_chr_mode(0), m_wram_protect_1(0), m_wram_protect_2(0), m_exram_control(0), m_wram_base(0), m_last_chr(0), m_ex1_chr(0) , m_split_chr(0), m_ex1_bank(0), m_high_chr(0), m_split_scr(0), m_split_rev(0), m_split_ctrl(0), m_split_yst(0), m_split_bank(0), m_vcount(0) + , m_ppu(*this, ":ppu") // FIXME: this dependency should not exist + , m_sound(*this, ":maincpu:nesapu") // FIXME: this is a hack, it should have extra channels, not pass to the existing APU!!! +{ +} + +nes_exrom_device::~nes_exrom_device() { } @@ -272,8 +278,7 @@ void nes_exrom_device::set_mirror(int page, int src) inline bool nes_exrom_device::in_split() { - ppu2c0x_device *ppu = machine().device<ppu2c0x_device>("ppu"); - int tile = ppu->get_tilenum(); + int tile = m_ppu->get_tilenum(); if (tile < 34) { @@ -309,8 +314,7 @@ READ8_MEMBER(nes_exrom_device::nt_r) // but it does not work yet if (m_split_scr && !(m_exram_control & 0x02) && in_split()) { - ppu2c0x_device *ppu = machine().device<ppu2c0x_device>("ppu"); - int tile = ppu->get_tilenum(); + int tile = m_ppu->get_tilenum(); if ((offset & 0x3ff) >= 0x3c0) { @@ -399,22 +403,21 @@ inline uint8_t nes_exrom_device::bg_ex1_chr_r(uint32_t offset) READ8_MEMBER(nes_exrom_device::chr_r) { int bank = offset >> 10; - ppu2c0x_device *ppu = machine().device<ppu2c0x_device>("ppu"); // Extended Attribute Mode (Ex1) does affect BG drawing even for 8x16 sprites (JustBreed uses it extensively!) // However, if a game enables Ex1 but does not write a new m_ex1_bank, I'm not sure here we get the correct behavior - if (m_exram_control == 1 && ppu->get_draw_phase() == PPU_DRAW_BG && m_ex1_chr) + if (m_exram_control == 1 && m_ppu->get_draw_phase() == PPU_DRAW_BG && m_ex1_chr) return bg_ex1_chr_r(offset & 0xfff); - if (m_split_scr && !(m_exram_control & 0x02) && in_split() && ppu->get_draw_phase() == PPU_DRAW_BG && m_split_chr) + if (m_split_scr && !(m_exram_control & 0x02) && in_split() && m_ppu->get_draw_phase() == PPU_DRAW_BG && m_split_chr) return split_chr_r(offset & 0xfff); - if (ppu->is_sprite_8x16()) + if (m_ppu->is_sprite_8x16()) { - if (ppu->get_draw_phase() == PPU_DRAW_OAM) + if (m_ppu->get_draw_phase() == PPU_DRAW_OAM) return base_chr_r(bank & 7, offset & 0x1fff); - if (ppu->get_draw_phase() == PPU_DRAW_BG) + if (m_ppu->get_draw_phase() == PPU_DRAW_BG) return base_chr_r((bank & 3) + 8, offset & 0x1fff); } @@ -467,8 +470,6 @@ WRITE8_MEMBER(nes_exrom_device::write_l) if ((offset >= 0x1000) && (offset <= 0x1015)) { - // SOUND (this is a hack, it should have extra channels, not pass to the existing APU!!!) - nesapu_device *m_sound = machine().device<nesapu_device>("maincpu:nesapu"); m_sound->write(space, offset & 0x1f, data); return; } diff --git a/src/devices/bus/nes/mmc5.h b/src/devices/bus/nes/mmc5.h index d677b875771..e78bd36aa2f 100644 --- a/src/devices/bus/nes/mmc5.h +++ b/src/devices/bus/nes/mmc5.h @@ -8,6 +8,9 @@ #include "nxrom.h" +class ppu2c0x_device; +class nesapu_device; + // ======================> nes_exrom_device class nes_exrom_device : public nes_nrom_device @@ -15,6 +18,7 @@ class nes_exrom_device : public nes_nrom_device public: // construction/destruction nes_exrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + ~nes_exrom_device(); virtual DECLARE_READ8_MEMBER(read_l) override; virtual DECLARE_READ8_MEMBER(read_m) override; @@ -86,6 +90,9 @@ protected: uint8_t m_ram_hi_banks[4]; // int m_nes_vram_sprite[8]; + + required_device<ppu2c0x_device> m_ppu; + required_device<nesapu_device> m_sound; }; diff --git a/src/devices/bus/nes/nanjing.cpp b/src/devices/bus/nes/nanjing.cpp index 77a699f7a7c..26a7e20f97c 100644 --- a/src/devices/bus/nes/nanjing.cpp +++ b/src/devices/bus/nes/nanjing.cpp @@ -38,6 +38,11 @@ nes_nanjing_device::nes_nanjing_device(const machine_config &mconfig, const char , m_count(0) , m_latch1(0) , m_latch2(0) + , m_ppu(*this, ":ppu") // FIXME: this dependency should not exist +{ +} + +nes_nanjing_device::~nes_nanjing_device() { } @@ -138,7 +143,7 @@ WRITE8_MEMBER(nes_nanjing_device::write_l) case 0x000: case 0x200: m_reg[BIT(offset, 9)] = data; - if (!BIT(m_reg[0], 7) && machine().device<ppu2c0x_device>("ppu")->get_current_scanline() <= 127) + if (!BIT(m_reg[0], 7) && m_ppu->get_current_scanline() <= 127) chr8(0, CHRRAM); break; case 0x300: diff --git a/src/devices/bus/nes/nanjing.h b/src/devices/bus/nes/nanjing.h index f7a7d508f5f..a231872a124 100644 --- a/src/devices/bus/nes/nanjing.h +++ b/src/devices/bus/nes/nanjing.h @@ -8,6 +8,8 @@ #include "nxrom.h" +class ppu2c0x_device; + // ======================> nes_nanjing_device class nes_nanjing_device : public nes_nrom_device @@ -15,6 +17,7 @@ class nes_nanjing_device : public nes_nrom_device public: // construction/destruction nes_nanjing_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + ~nes_nanjing_device(); virtual DECLARE_READ8_MEMBER(read_l) override; virtual DECLARE_WRITE8_MEMBER(write_l) override; @@ -30,6 +33,8 @@ private: uint8_t m_count; uint8_t m_reg[2]; uint8_t m_latch1, m_latch2; + + required_device<ppu2c0x_device> m_ppu; }; |