diff --git a/hash/nes.xml b/hash/nes.xml index cdac34a5442..7531f607d1e 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -44844,7 +44844,7 @@ Also notice that VRAM, WRAM & mirror are probably incorrect for some of these se - + @@ -45193,10 +45193,10 @@ Also notice that VRAM, WRAM & mirror are probably incorrect for some of these se - + - + @@ -46075,7 +46075,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + @@ -46134,7 +46134,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + @@ -48629,10 +48629,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -48684,10 +48684,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -49707,10 +49707,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -49768,10 +49768,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -49804,10 +49804,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -49825,10 +49825,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -49845,7 +49845,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + @@ -50007,10 +50007,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -50890,10 +50890,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -51793,10 +51793,10 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + - + @@ -53567,8 +53567,8 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx 19?? HES - - + + @@ -60682,8 +60682,9 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - - + + + @@ -60776,8 +60777,9 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx 19?? Hacker International - - + + + @@ -60969,8 +60971,8 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - - + + @@ -61008,8 +61010,8 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx Hacker International - - + + @@ -63456,7 +63458,6 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - diff --git a/src/devices/bus/nes/act53.cpp b/src/devices/bus/nes/act53.cpp index 2c0dee10afc..6693f32a9fa 100644 --- a/src/devices/bus/nes/act53.cpp +++ b/src/devices/bus/nes/act53.cpp @@ -112,7 +112,7 @@ void nes_action53_device::pcb_reset() void nes_action53_device::update_prg() { u16 prg_lo, prg_hi; - u8 size = (m_reg[2] & 0x30) >> 4; // Game size + u8 size = BIT(m_reg[2], 4, 2); // Game size u16 mask = ~0 << (size + 1); // Bits to be taken from PRG regs u8 b32k = !BIT(m_reg[2], 3); // 32K mode bit u16 outer = m_reg[3] << 1; // Outer PRG reg bits diff --git a/src/devices/bus/nes/aladdin.cpp b/src/devices/bus/nes/aladdin.cpp index c3b4430fe12..00b444cd395 100644 --- a/src/devices/bus/nes/aladdin.cpp +++ b/src/devices/bus/nes/aladdin.cpp @@ -245,7 +245,7 @@ void nes_algq_rom_device::write_prg(uint32_t offset, uint8_t data) // m_hibank = 3rd page inside the block if (offset < 0x4000) { - m_bank_base = ((data >> 3) & 3) << 2; + m_bank_base = (data & 0x18) >> 1; m_lobank = m_bank_base | (m_lobank & 3); m_hibank = m_bank_base | 3; } diff --git a/src/devices/bus/nes/ave.cpp b/src/devices/bus/nes/ave.cpp index 836cdaed9df..f2fc091306b 100644 --- a/src/devices/bus/nes/ave.cpp +++ b/src/devices/bus/nes/ave.cpp @@ -154,7 +154,8 @@ void nes_nina006_device::write_l(offs_t offset, uint8_t data) { LOG_MMC(("nina-006 write_l, offset: %04x, data: %02x\n", offset, data)); - if (!(offset & 0x0100)) + offset += 0x100; + if (BIT(offset, 8)) // $41xx, $43xx, ... $5fxx { prg32(data >> 3); chr8(data & 7, CHRROM); diff --git a/src/devices/bus/nes/bandai.cpp b/src/devices/bus/nes/bandai.cpp index 933ea5da251..da9f3403fcd 100644 --- a/src/devices/bus/nes/bandai.cpp +++ b/src/devices/bus/nes/bandai.cpp @@ -207,32 +207,28 @@ void nes_fjump2_device::pcb_reset() void nes_oekakids_device::nt_w(offs_t offset, uint8_t data) { - int page = ((offset & 0xc00) >> 10); - #if 0 if (!(offset & 0x1000) && (offset & 0x3ff) < 0x3c0) { - m_latch = (offset & 0x300) >> 8; + m_latch = BIT(offset, 8, 2); chr4_0(m_reg | m_latch, CHRRAM); } #endif - m_nt_access[page][offset & 0x3ff] = data; + device_nes_cart_interface::nt_w(offset, data); } uint8_t nes_oekakids_device::nt_r(offs_t offset) { - int page = ((offset & 0xc00) >> 10); - #if 0 if (!(offset & 0x1000) && (offset & 0x3ff) < 0x3c0) { - m_latch = (offset & 0x300) >> 8; + m_latch = BIT(offset, 8, 2); chr4_0(m_reg | m_latch, CHRRAM); } #endif - return m_nt_access[page][offset & 0x3ff]; + return device_nes_cart_interface::nt_r(offset); } void nes_oekakids_device::update_chr() @@ -247,7 +243,7 @@ void nes_oekakids_device::ppu_latch(offs_t offset) #if 0 if ((offset & 0x3000) == 0x2000) { - m_latch = (offset & 0x300) >> 8; + m_latch = BIT(offset, 8, 2); update_chr(); } #endif diff --git a/src/devices/bus/nes/benshieng.cpp b/src/devices/bus/nes/benshieng.cpp index 2b3c7818f58..9fadad83386 100644 --- a/src/devices/bus/nes/benshieng.cpp +++ b/src/devices/bus/nes/benshieng.cpp @@ -31,9 +31,8 @@ DEFINE_DEVICE_TYPE(NES_BENSHIENG, nes_benshieng_device, "nes_benshieng", "NES Cart Benshieng PCB") -nes_benshieng_device::nes_benshieng_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_nrom_device(mconfig, NES_BENSHIENG, tag, owner, clock) - , m_dipsetting(0) +nes_benshieng_device::nes_benshieng_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_nrom_device(mconfig, NES_BENSHIENG, tag, owner, clock), m_dipsetting(0) { } @@ -44,20 +43,17 @@ void nes_benshieng_device::device_start() { common_start(); save_item(NAME(m_dipsetting)); - save_item(NAME(m_mmc_prg_bank)); - save_item(NAME(m_mmc_vrom_bank)); } void nes_benshieng_device::pcb_reset() { - m_dipsetting = 0; + for (int i = 0; i < 4; i++) + { + prg8_x(i, 0x0f); + chr2_x(2 * i, 0x00, CHRROM); + } - m_mmc_prg_bank[0] = 0xff; - m_mmc_prg_bank[1] = 0xff; - m_mmc_prg_bank[2] = 0xff; - m_mmc_prg_bank[3] = 0xff; - memset(m_mmc_vrom_bank, 0, sizeof(m_mmc_vrom_bank)); - update_banks(); + m_dipsetting = 0; } @@ -72,35 +68,27 @@ void nes_benshieng_device::pcb_reset() Games: a few 4 in 1 multicarts + NES 2.0: mapper 286 + -------------------------------------------------*/ -void nes_benshieng_device::update_banks() +void nes_benshieng_device::write_h(offs_t offset, u8 data) { - prg8_89(m_mmc_prg_bank[0]); - prg8_ab(m_mmc_prg_bank[1]); - prg8_cd(m_mmc_prg_bank[2]); - prg8_ef(m_mmc_prg_bank[3]); - chr2_0(m_mmc_vrom_bank[0], CHRROM); - chr2_2(m_mmc_vrom_bank[1], CHRROM); - chr2_4(m_mmc_vrom_bank[2], CHRROM); - chr2_6(m_mmc_vrom_bank[3], CHRROM); -} - -void nes_benshieng_device::write_h(offs_t offset, uint8_t data) -{ - uint8_t helper = (offset & 0xc00) >> 10; LOG_MMC(("benshieng write_h, offset: %04x, data: %02x\n", offset, data)); // m_mmc_dipsetting = ioport("CARTDIPS")->read(); + u8 bank = BIT(offset, 10, 2); + switch (offset & 0x7000) { case 0x0000: - m_mmc_vrom_bank[helper] = offset & 0x1f; + case 0x1000: + chr2_x(2 * bank, offset & 0x1f, CHRROM); break; case 0x2000: - if (BIT(offset, m_dipsetting + 4)) // mmc_dipsetting is always zero atm, given we have no way to add cart-based DIPs - m_mmc_prg_bank[helper] = offset & 0x0f; + case 0x3000: + if (BIT(offset, m_dipsetting + 4)) // m_dipsetting is always zero atm, given we have no way to add cart-based DIPs + prg8_x(bank, offset & 0x0f); break; } - update_banks(); } diff --git a/src/devices/bus/nes/benshieng.h b/src/devices/bus/nes/benshieng.h index 599de5a6e9c..2292b57a270 100644 --- a/src/devices/bus/nes/benshieng.h +++ b/src/devices/bus/nes/benshieng.h @@ -14,9 +14,9 @@ class nes_benshieng_device : public nes_nrom_device { public: // construction/destruction - nes_benshieng_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_benshieng_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual void write_h(offs_t offset, uint8_t data) override; + virtual void write_h(offs_t offset, u8 data) override; virtual void pcb_reset() override; @@ -25,10 +25,7 @@ protected: virtual void device_start() override; private: - void update_banks(); - uint8_t m_dipsetting; - uint8_t m_mmc_prg_bank[4]; - uint8_t m_mmc_vrom_bank[4]; + u8 m_dipsetting; }; diff --git a/src/devices/bus/nes/bootleg.cpp b/src/devices/bus/nes/bootleg.cpp index ea482a93052..f7881ada45b 100644 --- a/src/devices/bus/nes/bootleg.cpp +++ b/src/devices/bus/nes/bootleg.cpp @@ -1019,7 +1019,7 @@ void nes_btl_dn_device::write_h(offs_t offset, uint8_t data) case 0x5002: case 0x6000: case 0x6002: - bank = ((offset & 0x7000) - 0x3000) / 0x0800 + ((offset & 0x0002) >> 1); + bank = 2 * (BIT(offset, 12, 3) - 3) + BIT(offset, 1); chr1_x(bank, data, CHRROM); break; case 0x7000: diff --git a/src/devices/bus/nes/hes.cpp b/src/devices/bus/nes/hes.cpp index 946ea1f9585..b23ad6c9f74 100644 --- a/src/devices/bus/nes/hes.cpp +++ b/src/devices/bus/nes/hes.cpp @@ -33,26 +33,12 @@ DEFINE_DEVICE_TYPE(NES_HES, nes_hes_device, "nes_hes", "NES Cart HES PCB") -nes_hes_device::nes_hes_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_hes_device::nes_hes_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_HES, tag, owner, clock) { } -void nes_hes_device::device_start() -{ - common_start(); -} - -void nes_hes_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg32(0); - chr8(0, m_chr_source); -} - - - /*------------------------------------------------- mapper specific handlers -------------------------------------------------*/ @@ -69,19 +55,19 @@ void nes_hes_device::pcb_reset() iNES: mapper 113 - In MESS: Supported. + In MAME: Supported. -------------------------------------------------*/ -void nes_hes_device::write_l(offs_t offset, uint8_t data) +void nes_hes_device::write_l(offs_t offset, u8 data) { LOG_MMC(("hes write_l, offset: %04x, data: %02x\n", offset, data)); - if (!(offset & 0x100)) + offset += 0x100; + if (BIT(offset, 8)) // $41xx, $43xx, ... $5fxx { - prg32((data & 0x38) >> 3); - chr8((data & 0x07) | ((data & 0x40) >> 3), CHRROM); - if (m_pcb_ctrl_mirror) - set_nt_mirroring(BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); + prg32(BIT(data, 3, 3)); + chr8(bitswap<4>(data, 6, 2, 1, 0), CHRROM); + set_nt_mirroring(BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); } } diff --git a/src/devices/bus/nes/hes.h b/src/devices/bus/nes/hes.h index ea72578ad98..24577f416cb 100644 --- a/src/devices/bus/nes/hes.h +++ b/src/devices/bus/nes/hes.h @@ -14,15 +14,9 @@ class nes_hes_device : public nes_nrom_device { public: // construction/destruction - nes_hes_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_hes_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual void write_l(offs_t offset, uint8_t data) override; - - virtual void pcb_reset() override; - -protected: - // device-level overrides - virtual void device_start() override; + virtual void write_l(offs_t offset, u8 data) override; }; diff --git a/src/devices/bus/nes/jaleco.cpp b/src/devices/bus/nes/jaleco.cpp index 71d5210ac8a..8de9ccacb92 100644 --- a/src/devices/bus/nes/jaleco.cpp +++ b/src/devices/bus/nes/jaleco.cpp @@ -513,9 +513,9 @@ void nes_ss88006_device::ss88006_write(offs_t offset, uint8_t data) case 0x3000: case 0x3001: case 0x3002: case 0x3003: case 0x4000: case 0x4001: case 0x4002: case 0x4003: case 0x5000: case 0x5001: case 0x5002: case 0x5003: - bank = ((offset & 0x7000) - 0x2000) / 0x0800 + ((offset & 0x0002) >> 1); + bank = 2 * (BIT(offset, 12, 3) - 2) + BIT(offset, 1); if (offset & 0x0001) - m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x0f)<< 4); + m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x0f) << 4); else m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f); @@ -575,7 +575,7 @@ void nes_ss88006_adpcm_device::ss88006_adpcm_write(offs_t offset, uint8_t data, { // printf("sample write: data: %02x\n", data); if ((m_latch & 2) && !(data & 2)) - dev.start((data >> 2) & 0x1f, (data >> 2) & 0x1f); + dev.start(BIT(data, 2, 5), BIT(data, 2, 5)); } m_latch = data; break; diff --git a/src/devices/bus/nes/mmc3_clones.cpp b/src/devices/bus/nes/mmc3_clones.cpp index aac3ec7ec5c..d38bb934354 100644 --- a/src/devices/bus/nes/mmc3_clones.cpp +++ b/src/devices/bus/nes/mmc3_clones.cpp @@ -2253,7 +2253,7 @@ void nes_fk23c_device::chr_cb(int start, int bank, int source) void nes_fk23c_device::fk23c_set_prg() { if ((m_reg[0] & 0x07) == 4) - prg32((m_reg[1] & 0x7f) >> 1); + prg32(BIT(m_reg[1], 1, 6)); else if ((m_reg[0] & 0x07) == 3) { prg16_89ab(m_reg[1] & 0x7f); @@ -3328,7 +3328,7 @@ void nes_bmc_411120c_device::write_m(offs_t offset, u8 data) { m_reg = offset; if (BIT(m_reg, 3)) - prg32((m_reg & 0x07) << 2 | (m_reg & 0x30) >> 4); + prg32(bitswap<5>(m_reg, 2, 1, 0, 5, 4)); else { m_prg_base = (m_reg & 0x07) << 4; diff --git a/src/devices/bus/nes/multigame.cpp b/src/devices/bus/nes/multigame.cpp index bbfae735e59..1b66b581ed2 100644 --- a/src/devices/bus/nes/multigame.cpp +++ b/src/devices/bus/nes/multigame.cpp @@ -130,7 +130,7 @@ ioport_constructor nes_bmc_8157_device::device_input_ports() const // LIVE DEVICE //************************************************************************** -nes_action52_device::nes_action52_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_action52_device::nes_action52_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_ACTION52, tag, owner, clock) { } @@ -230,7 +230,7 @@ nes_bmc_970630c_device::nes_bmc_970630c_device(const machine_config &mconfig, co { } -nes_ntd03_device::nes_ntd03_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_ntd03_device::nes_ntd03_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_NTD03, tag, owner, clock) { } @@ -535,18 +535,6 @@ nes_bmc_82ab_device::nes_bmc_82ab_device(const machine_config &mconfig, const ch -void nes_action52_device::device_start() -{ - common_start(); -} - -void nes_action52_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg32(0); - chr8(0, m_chr_source); -} - void nes_caltron6in1_device::device_start() { common_start(); @@ -788,18 +776,6 @@ void nes_bmc_970630c_device::pcb_reset() m_latch = 0; } -void nes_ntd03_device::device_start() -{ - common_start(); -} - -void nes_ntd03_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg32(0); - chr8(0, m_chr_source); -} - void nes_bmc_ctc09_device::pcb_reset() { // nes_slot's pcb_start sets us up in the main menu. Soft reset is empty so @@ -1301,24 +1277,17 @@ void nes_bmc_th22913_device::pcb_reset() -------------------------------------------------*/ -void nes_action52_device::write_h(offs_t offset, uint8_t data) +void nes_action52_device::write_h(offs_t offset, u8 data) { - uint8_t pmode = offset & 0x20; - int pbank = (offset & 0x1fc0) >> 6; - int cbank = (data & 0x03) | ((offset & 0x0f) << 2); LOG_MMC(("ae_act52_w, offset: %04x, data: %02x\n", offset, data)); + u8 bank = BIT(offset, 6, 7); + u8 mode = !BIT(offset, 5); + prg16_89ab(bank & ~mode); + prg16_cdef(bank | mode); + + chr8((data & 0x03) | (offset & 0x0f) << 2, CHRROM); set_nt_mirroring(BIT(offset, 13) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); - - chr8(cbank, CHRROM); - - if (pmode) - { - prg16_89ab(pbank); - prg16_cdef(pbank); - } - else - prg32(pbank >> 1); } /*------------------------------------------------- @@ -1431,8 +1400,8 @@ void nes_rumblestat_device::write_h(offs_t offset, uint8_t data) // this pcb is subject to bus conflict data = account_bus_conflict(offset, data); - m_prg = (m_prg & ~0x01) | (data & 0x01); - m_chr = (m_chr & ~0x07) | ((data & 0x70) >> 4); + m_prg = (m_prg & ~0x01) | BIT(data, 0); + m_chr = (m_chr & ~0x07) | BIT(data, 4, 3); prg32(m_prg); chr8(m_chr, CHRROM); } @@ -1600,7 +1569,7 @@ void nes_t262_device::write_h(offs_t offset, u8 data) set_nt_mirroring(BIT(m_latch, 1) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); } - u8 bank = (m_latch & 0x300) >> 3 | (m_latch & 0x60) >> 2 | (data & 0x07); // NesDev shows the high bit here, but is it correct? So far no cart is large enough to use this. + u8 bank = bitswap<4>(m_latch, 9, 8, 6, 5) << 3 | (data & 0x07); // NesDev shows the high bit here, but is it correct? So far no cart is large enough to use this. u8 mode = BIT(m_latch, 0); if (BIT(m_latch, 7)) // NROM mode { @@ -1657,7 +1626,7 @@ void nes_sgun20in1_device::write_h(offs_t offset, u8 data) { case 0x0000: case 0x7000: - offset = (offset >> 2) & (m_prg_mask >> 1); + offset >>= 2; prg16_89ab(offset); prg16_cdef(offset); chr8(offset, CHRROM); @@ -1691,7 +1660,7 @@ void nes_vt5201_device::write_h(offs_t offset, u8 data) { m_latch = offset >> 8; - u8 bank = (offset >> 4) & 0x07; + u8 bank = BIT(offset, 4, 3); u8 mode = !BIT(offset, 7); prg16_89ab(bank & ~mode); prg16_cdef(bank | mode); @@ -1875,7 +1844,7 @@ void nes_bmc_970630c_device::write_h(offs_t offset, u8 data) { LOG_MMC(("bmc_970630c write_h, offset: %04x, data: %02x\n", offset, data)); - u8 bank = (offset >> 2) & 0x1f; + u8 bank = BIT(offset, 2, 5); if (BIT(offset, 9)) // NROM mode { u8 mode = !BIT(offset, 0); @@ -1914,23 +1883,17 @@ u8 nes_bmc_970630c_device::read_h(offs_t offset) -------------------------------------------------*/ -void nes_ntd03_device::write_h(offs_t offset, uint8_t data) +void nes_ntd03_device::write_h(offs_t offset, u8 data) { - uint8_t pbank = (offset >> 10) & 0x1e; - uint8_t cbank = ((offset & 0x300) >> 5) | (offset & 0x07); LOG_MMC(("ntd03 write_h, offset: %04x, data: %02x\n", offset, data)); - if (BIT(offset, 7)) - { - prg16_89ab(pbank | BIT(offset, 6)); - prg16_cdef(pbank | BIT(offset, 6)); - } - else - prg32(pbank >> 1); + u8 bank = bitswap<5>(offset, 14, 13, 12, 11, 6); + u8 mode = !BIT(offset, 7); + prg16_89ab(bank & ~mode); + prg16_cdef(bank | mode); + chr8(bitswap<5>(offset, 9, 8, 2, 1, 0), CHRROM); set_nt_mirroring(BIT(offset, 10) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); - - chr8(cbank, CHRROM); } /*------------------------------------------------- @@ -2028,7 +1991,7 @@ void nes_bmc_gkb_device::write_h(offs_t offset, u8 data) prg16_89ab(bank & ~mode); prg16_cdef(bank | mode); - chr8((offset >> 3) & 0x07, CHRROM); + chr8(BIT(offset, 3, 3), CHRROM); set_nt_mirroring(BIT(offset, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); } @@ -2051,7 +2014,7 @@ void nes_bmc_gkcxin1_device::write_h(offs_t offset, u8 data) { LOG_MMC(("bmc_gkcxin1 write_h, offset: %04x, data: %02x\n", offset, data)); - prg32((offset >> 3) & 0x03); + prg32(BIT(offset, 3, 2)); chr8(offset & 0x07, CHRROM); } @@ -2367,14 +2330,13 @@ void nes_bmc_tj03_device::write_h(offs_t offset, u8 data) Games: Super 40-in-1 - In MESS: Partially Supported (some games, like Galaxian, have + In MAME: Partially Supported (some games, like Galaxian, have issues) -------------------------------------------------*/ void nes_bmc_ws_device::write_m(offs_t offset, uint8_t data) { - uint8_t mmc_helper; LOG_MMC(("bmc_ws write_m, offset: %04x, data: %02x\n", offset, data)); if (offset < 0x1000) @@ -2386,9 +2348,9 @@ void nes_bmc_ws_device::write_m(offs_t offset, uint8_t data) { m_latch = data & 0x20; set_nt_mirroring(BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); - mmc_helper = (~data & 0x08) >> 3; - prg16_89ab(data & ~mmc_helper); - prg16_cdef(data | mmc_helper); + u8 mode = !BIT(data, 3); + prg16_89ab(data & ~mode); + prg16_cdef(data | mode); } break; case 1: @@ -2415,8 +2377,8 @@ void nes_bmc_11160_device::write_h(offs_t offset, u8 data) { LOG_MMC(("bmc_11160 write_h, offset: %04x, data: %02x\n", offset, data)); - prg32((data & 0x30) >> 4); - chr8(((data & 0x30) >> 2) | (data & 0x03), CHRROM); + prg32(BIT(data, 4, 2)); + chr8(bitswap<4>(data, 5, 4, 1, 0), CHRROM); set_nt_mirroring(BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); } @@ -2470,7 +2432,8 @@ void nes_bmc_2751_device::write_h(offs_t offset, u8 data) u8 mode = BIT(offset, 7); prg16_89ab(bank & ~mode); prg16_cdef(bank | mode); - chr8((offset >> 1) & 0x07, CHRROM); + + chr8(BIT(offset, 1, 3), CHRROM); set_nt_mirroring(BIT(offset, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); } @@ -2572,7 +2535,7 @@ void nes_bmc_s700_device::write_h(offs_t offset, u8 data) { LOG_MMC(("bmc_s700 write_h, offset: %04x, data: %02x\n", offset, data)); - u8 bank = (offset & 0x40) | ((offset >> 8) & 0x3f); + u8 bank = (offset & 0x40) | BIT(offset, 8, 6); u8 mode = !BIT(offset, 5); prg16_89ab(bank & ~mode); prg16_cdef(bank | mode); @@ -2674,8 +2637,8 @@ void nes_bmc_22games_device::write_h(offs_t offset, u8 data) void nes_bmc_64y2k_device::set_prg() { - uint8_t helper1 = (m_reg[1] & 0x1f); - uint8_t helper2 = (helper1 << 1) | ((m_reg[1] & 0x40) >> 6); + uint8_t helper1 = m_reg[1] & 0x1f; + uint8_t helper2 = (helper1 << 1) | BIT(m_reg[1], 6); if (m_reg[0] & 0x80) { @@ -2704,7 +2667,7 @@ void nes_bmc_64y2k_device::write_l(offs_t offset, uint8_t data) case 0x1003: m_reg[offset & 0x03] = data; set_prg(); - chr8(((m_reg[0] >> 1) & 0x03) | (m_reg[2] << 2), CHRROM); + chr8(BIT(m_reg[0], 1, 2) | (m_reg[2] << 2), CHRROM); break; } if (offset == 0x1000) /* write to reg[0] also sets mirroring */ @@ -2886,16 +2849,17 @@ void nes_bmc_31in1_device::write_h(offs_t offset, u8 data) iNES: mapper 203 - In MESS: Supported. + In MAME: Supported. -------------------------------------------------*/ -void nes_bmc_35in1_device::write_h(offs_t offset, uint8_t data) +void nes_bmc_35in1_device::write_h(offs_t offset, u8 data) { LOG_MMC(("bmc_35in1 write_h, offset: %04x, data: %02x\n", offset, data)); - prg16_89ab((data >> 2) & 0x03); - prg16_cdef((data >> 2) & 0x03); + u8 bank = BIT(data, 2, 2); + prg16_89ab(bank); + prg16_cdef(bank); chr8(data & 0x03, CHRROM); } @@ -3067,7 +3031,7 @@ void nes_bmc_72in1_device::write_h(offs_t offset, u8 data) LOG_MMC(("bmc_72in1 write_h, offset: %04x, data: %02x\n", offset, data)); u8 high = (offset >> 8) & 0x40; - u8 bank = high | ((offset >> 6) & 0x3f); + u8 bank = high | BIT(offset, 6, 6); u8 mode = !BIT(offset, 12); prg16_89ab(bank & ~mode); prg16_cdef(bank | mode); @@ -3127,7 +3091,7 @@ void nes_bmc_150in1_device::write_h(offs_t offset, u8 data) { LOG_MMC(("bmc_150in1 write_h, offset: %04x, data: %02x\n", offset, data)); - u8 bank = (offset >> 1) & 0x07; + u8 bank = BIT(offset, 1, 3); u8 mode = (bank & 0x06) == 0x06; prg16_89ab(bank & ~mode); prg16_cdef(bank | mode); @@ -3152,7 +3116,7 @@ void nes_bmc_150in1_device::write_h(offs_t offset, u8 data) void nes_bmc_500in1_device::write_h(offs_t offset, u8 data) { LOG_MMC(("bmc500in1 write_h, offset: %04x, data: %02x\n", offset, data)); - prg32((offset >> 2) & 0x07); + prg32(BIT(offset, 2, 3)); chr8(offset & 0x07, CHRROM); } @@ -3366,7 +3330,7 @@ void nes_bmc_lc160_device::write_h(offs_t offset, u8 data) LOG_MMC(("bmc_lc160 write_h, offset: %04x, data: %02x\n", offset, data)); if (offset >= 0x4000) { - u8 bank = (offset >> 2) & 0x3f; + u8 bank = BIT(offset, 2, 6); u8 mode = !BIT(offset, 1); prg16_89ab(bank & ~mode); prg16_cdef(bank | mode); @@ -3489,7 +3453,7 @@ void nes_bmc_891227_device::write_h(offs_t offset, u8 data) LOG_MMC(("bmc_891227 write_h, offset: %04x, data: %02x\n", offset, data)); if (offset < 0x4000) - data = (data & 0x80) >> 2 | (data & 0x60) << 1 | (data & 0x1f); + data = bitswap<8>(data, 6, 5, 7, 4, 3, 2, 1, 0); nes_bmc_ctc12in1_device::write_h(offset, data); @@ -3618,7 +3582,7 @@ void nes_n625092_device::write_h(offs_t offset, u8 data) m_latch[BIT(offset, 14)] = offset; - u8 bank = (m_latch[0] & 0x200) >> 3 | (m_latch[0] & 0xe0) >> 2 | (m_latch[1] & 0x07); + u8 bank = bitswap<4>(m_latch[0], 9, 7, 6, 5) << 3 | (m_latch[1] & 0x07); u8 mode = BIT(m_latch[0], 1); if (mode && BIT(m_latch[0], 8)) // UNROM mode { diff --git a/src/devices/bus/nes/multigame.h b/src/devices/bus/nes/multigame.h index ca167fa609a..668ed6384aa 100644 --- a/src/devices/bus/nes/multigame.h +++ b/src/devices/bus/nes/multigame.h @@ -14,15 +14,9 @@ class nes_action52_device : public nes_nrom_device { public: // construction/destruction - nes_action52_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_action52_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual void write_h(offs_t offset, uint8_t data) override; - - virtual void pcb_reset() override; - -protected: - // device-level overrides - virtual void device_start() override; + virtual void write_h(offs_t offset, u8 data) override; }; @@ -393,15 +387,9 @@ class nes_ntd03_device : public nes_nrom_device { public: // construction/destruction - nes_ntd03_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_ntd03_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual void write_h(offs_t offset, uint8_t data) override; - - virtual void pcb_reset() override; - -protected: - // device-level overrides - virtual void device_start() override; + virtual void write_h(offs_t offset, u8 data) override; }; diff --git a/src/devices/bus/nes/namcot.cpp b/src/devices/bus/nes/namcot.cpp index 36c2320f2ca..62bc832563b 100644 --- a/src/devices/bus/nes/namcot.cpp +++ b/src/devices/bus/nes/namcot.cpp @@ -466,7 +466,7 @@ void nes_namcot340_device::n340_hiwrite(offs_t offset, uint8_t data) case 0x1000: case 0x1800: case 0x2000: case 0x2800: case 0x3000: case 0x3800: - chr1_x(offset / 0x800, data, CHRROM); + chr1_x(offset >> 11, data, CHRROM); break; case 0x4000: // no cart found with wram, so it is not clear if this could work as in Namcot-175... @@ -611,7 +611,7 @@ uint8_t nes_namcot163_device::read_m(offs_t offset) void nes_namcot163_device::write_m(offs_t offset, uint8_t data) { // the pcb can separately protect each 2KB chunk of the external wram from writes - int bank = (offset & 0x1800) >> 11; + int bank = BIT(offset, 11, 2); if (!m_battery.empty() && !BIT(m_wram_protect, bank)) m_battery[offset & (m_battery.size() - 1)] = data; } diff --git a/src/devices/bus/nes/nes_slot.cpp b/src/devices/bus/nes/nes_slot.cpp index 2274c2dba9f..5e9365d97ea 100644 --- a/src/devices/bus/nes/nes_slot.cpp +++ b/src/devices/bus/nes/nes_slot.cpp @@ -529,10 +529,8 @@ void device_nes_cart_interface::nt_w(offs_t offset, uint8_t data) { int page = BIT(offset, 10, 2); - if (!m_nt_writable[page]) - return; - - m_nt_access[page][offset & 0x3ff] = data; + if (m_nt_writable[page]) + m_nt_access[page][offset & 0x3ff] = data; } uint8_t device_nes_cart_interface::nt_r(offs_t offset) diff --git a/src/devices/bus/nes/pirate.cpp b/src/devices/bus/nes/pirate.cpp index 00ebe8ec71e..2b9bec4b7ee 100644 --- a/src/devices/bus/nes/pirate.cpp +++ b/src/devices/bus/nes/pirate.cpp @@ -680,7 +680,7 @@ void nes_43272_device::write_h(offs_t offset, uint8_t data) LOG_MMC(("unl_43272 write_h, offset: %04x, data: %02x\n", offset, data)); if ((m_latch & 0x81) == 0x81) - prg32((m_latch & 0x38) >> 3); + prg32(BIT(m_latch, 3, 3)); m_latch = offset & 0xffff; } @@ -778,7 +778,7 @@ uint8_t nes_fujiya_device::read_m(offs_t offset) offset += 0x6000; if (offset == 0x7001 || offset == 0x7777) - return m_latch | ((offset >> 8) & 0x7f); + return m_latch | (BIT(offset, 8, 7)); return get_open_bus(); } diff --git a/src/devices/bus/nes/sachen.cpp b/src/devices/bus/nes/sachen.cpp index 9b0ad2b7a32..c72dab79d5f 100644 --- a/src/devices/bus/nes/sachen.cpp +++ b/src/devices/bus/nes/sachen.cpp @@ -628,7 +628,7 @@ void nes_sachen_74x374_device::write_l(offs_t offset, uint8_t data) chr8(m_mmc_vrom_bank, CHRROM); break; case 0x07: - set_mirror((data >> 1) & 0x03); + set_mirror(BIT(data, 1, 2)); break; default: break; diff --git a/src/devices/bus/nes/subor.cpp b/src/devices/bus/nes/subor.cpp index 0fa25b2b5bb..39424e0e529 100644 --- a/src/devices/bus/nes/subor.cpp +++ b/src/devices/bus/nes/subor.cpp @@ -185,12 +185,10 @@ void nes_subor2_device::ppu_latch(offs_t offset) uint8_t nes_subor2_device::nt_r(offs_t offset) { - int page = ((offset & 0xc00) >> 10); + // Nametable reads report the current page; this seems to work without issues + m_page = BIT(offset, 10, 2); - /* Nametable reads report the current page; this seems to work without issues */ - m_page = page; - - return m_nt_access[page][offset & 0x3ff]; + return device_nes_cart_interface::nt_r(offset); } /*------------------------------------------------- @@ -254,7 +252,7 @@ void nes_subor0_device::write_h(offs_t offset, uint8_t data) uint8_t subor_helper1, subor_helper2; LOG_MMC("subor0 write_h, offset: %04x, data: %02x\n", offset, data); - m_reg[(offset >> 13) & 0x03] = data; + m_reg[BIT(offset, 13, 2)] = data; subor_helper1 = ((m_reg[0] ^ m_reg[1]) << 1) & 0x20; subor_helper2 = ((m_reg[2] ^ m_reg[3]) << 0) & 0x1f; @@ -284,7 +282,7 @@ void nes_subor1_device::write_h(offs_t offset, uint8_t data) uint8_t subor_helper1, subor_helper2; LOG_MMC("subor1 write_h, offset: %04x, data: %02x\n", offset, data); - m_reg[(offset >> 13) & 0x03] = data; + m_reg[BIT(offset, 13, 2)] = data; subor_helper1 = ((m_reg[0] ^ m_reg[1]) << 1) & 0x20; subor_helper2 = ((m_reg[2] ^ m_reg[3]) << 0) & 0x1f; diff --git a/src/devices/bus/nes/waixing.cpp b/src/devices/bus/nes/waixing.cpp index 2f5f8b5faef..9270c92ca8a 100644 --- a/src/devices/bus/nes/waixing.cpp +++ b/src/devices/bus/nes/waixing.cpp @@ -1113,8 +1113,8 @@ void nes_waixing_dq8_device::write_h(offs_t offset, uint8_t data) void nes_waixing_wxzs2_device::write_h(offs_t offset, uint8_t data) { - uint8_t flip = (data & 0x80) >> 7; - uint8_t helper = (data & 0x7f) << 1; + uint8_t flip = BIT(data, 7); + uint8_t helper = data << 1; LOG_MMC(("waixing_wxzs2 write_h, offset: %04x, data: %02x\n", offset, data)); @@ -1167,13 +1167,12 @@ void nes_waixing_wxzs2_device::write_h(offs_t offset, uint8_t data) void nes_waixing_fs304_device::write_l(offs_t offset, uint8_t data) { LOG_MMC(("fs304 write_l, offset: %04x, data: %02x\n", offset, data)); - int bank; - offset += 0x100; + offset += 0x100; if (offset >= 0x1000) { - m_reg[(offset >> 8) & 3] = data; - bank = ((m_reg[2] & 0x0f) << 4) | BIT(m_reg[1], 1) | (m_reg[0] & 0x0e); + m_reg[BIT(offset, 8, 2)] = data; + int bank = ((m_reg[2] & 0x0f) << 4) | BIT(m_reg[1], 1) | (m_reg[0] & 0x0e); prg32(bank); chr8(0, CHRRAM); } diff --git a/src/devices/bus/nes_ctrl/hori.cpp b/src/devices/bus/nes_ctrl/hori.cpp index 9a2d4d0ff65..7b1351af3fd 100644 --- a/src/devices/bus/nes_ctrl/hori.cpp +++ b/src/devices/bus/nes_ctrl/hori.cpp @@ -5,9 +5,9 @@ Nintendo Family Computer Hori Twin and 4 Players adapters In general these adapters work by reading pin 13 (the Famicom sees - this in memory location $4016, bit 1) of their subports. It is not - clear if other lines are pass-thru. For the moment we only emulate - joypads connected to these ports, which only use pin 13 when read. + this in memory location $4016, bit 1) of their subports. Other + input pins are not connected so various specialty controllers are + incompatible with these adapters. The Hori Twin passes subport 1's input directly through to $4016 bit 1. It reroutes subport 2's to $4017 bit 1. Incidentally, HAL @@ -137,6 +137,9 @@ u8 nes_hori4p_device::read_exp(offs_t offset) u8 ret = 0; int mode4p = m_cfg->read(); + if (m_strobe) + reset_regs(); + if (m_count[offset] < 16 || !mode4p) // read from P1/P2 for first byte, P3/P4 for second byte if in 4P mode { int port = 2 * (BIT(m_count[offset], 3) & mode4p) + offset; @@ -146,6 +149,7 @@ u8 nes_hori4p_device::read_exp(offs_t offset) { ret = (m_sig[offset] & 1) << 1; m_sig[offset] >>= 1; + m_sig[offset] |= 0x80; // reads beyond signature are always 1 } m_count[offset]++;