diff options
Diffstat (limited to 'src/devices/bus/nes/bootleg.cpp')
-rw-r--r-- | src/devices/bus/nes/bootleg.cpp | 513 |
1 files changed, 220 insertions, 293 deletions
diff --git a/src/devices/bus/nes/bootleg.cpp b/src/devices/bus/nes/bootleg.cpp index a2a32d72579..4ce050033d5 100644 --- a/src/devices/bus/nes/bootleg.cpp +++ b/src/devices/bus/nes/bootleg.cpp @@ -24,16 +24,15 @@ #include "bootleg.h" #include "video/ppu2c0x.h" // this has to be included so that IRQ functions can access ppu2c0x_device::BOTTOM_VISIBLE_SCANLINE -#include "screen.h" +#define LOG_HIFREQ (1U << 1) #ifdef NES_PCB_DEBUG -#define VERBOSE 1 +#define VERBOSE (LOG_GENERAL) #else -#define VERBOSE 0 +#define VERBOSE (0) #endif - -#define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0) +#include "logmacro.h" //------------------------------------------------- @@ -78,8 +77,8 @@ nes_sc127_device::nes_sc127_device(const machine_config &mconfig, const char *ta { } -nes_mbaby_device::nes_mbaby_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_nrom_device(mconfig, NES_MARIOBABY, tag, owner, clock), m_latch(0), m_irq_enable(0), irq_timer(nullptr) +nes_mbaby_device::nes_mbaby_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_nrom_device(mconfig, NES_MARIOBABY, tag, owner, clock), m_irq_count(0), m_irq_enable(0), m_latch(0), irq_timer(nullptr) { } @@ -113,18 +112,18 @@ nes_smb2ja_device::nes_smb2ja_device(const machine_config &mconfig, const char * { } -nes_smb2jb_device::nes_smb2jb_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) - : nes_nrom_device(mconfig, type, tag, owner, clock), m_irq_count(0), m_irq_enable(0), m_reg(0), m_bank67(type == NES_SMB2JB ? 0x0f : 0x07), irq_timer(nullptr) +nes_smb2jb_device::nes_smb2jb_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bank67) + : nes_nrom_device(mconfig, type, tag, owner, clock), m_irq_count(0), m_irq_enable(0), m_reg(0), m_bank67(bank67), irq_timer(nullptr) { } nes_smb2jb_device::nes_smb2jb_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : nes_smb2jb_device(mconfig, NES_SMB2JB, tag, owner, clock) + : nes_smb2jb_device(mconfig, NES_SMB2JB, tag, owner, clock, 0x0f) { } nes_n32_4in1_device::nes_n32_4in1_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : nes_smb2jb_device(mconfig, NES_N32_4IN1, tag, owner, clock) + : nes_smb2jb_device(mconfig, NES_N32_4IN1, tag, owner, clock, 0x07) { } @@ -198,7 +197,7 @@ nes_lg25_device::nes_lg25_device(const machine_config &mconfig, const char *tag, { } -nes_lh10_device::nes_lh10_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_lh10_device::nes_lh10_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_LH10, tag, owner, clock), m_latch(0) { } @@ -250,7 +249,6 @@ void nes_sc127_device::device_start() void nes_sc127_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; prg32(0xff); chr8(0, m_chr_source); @@ -261,21 +259,20 @@ void nes_sc127_device::pcb_reset() void nes_mbaby_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); - irq_timer->reset(); - timer_freq = clocks_to_attotime(24576); + irq_timer = timer_alloc(FUNC(nes_mbaby_device::irq_timer_tick), this); + irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_enable)); + save_item(NAME(m_irq_count)); save_item(NAME(m_latch)); } void nes_mbaby_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; prg32((m_prg_chunks - 1) >> 1); - chr8(0, m_chr_source); m_irq_enable = 0; + m_irq_count = 0; m_latch = 0; } @@ -287,7 +284,6 @@ void nes_asn_device::device_start() void nes_asn_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; prg32((m_prg_chunks - 1) >> 1); chr8(0, m_chr_source); @@ -297,7 +293,7 @@ void nes_asn_device::pcb_reset() void nes_smb3p_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_smb3p_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_enable)); @@ -320,7 +316,7 @@ void nes_smb3p_device::pcb_reset() void nes_batmanfs_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_batmanfs_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_enable)); @@ -350,7 +346,6 @@ void nes_btl_dn_device::device_start() void nes_btl_dn_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; prg16_89ab(0); prg16_cdef(m_prg_chunks - 1); chr8(0, m_chr_source); @@ -361,7 +356,7 @@ void nes_btl_dn_device::pcb_reset() void nes_smb2j_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_smb2j_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_enable)); @@ -383,7 +378,7 @@ void nes_smb2j_device::pcb_reset() void nes_smb2ja_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_smb2ja_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_enable)); @@ -405,7 +400,7 @@ void nes_smb2ja_device::pcb_reset() void nes_smb2jb_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_smb2jb_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_enable)); @@ -419,7 +414,6 @@ void nes_smb2jb_device::pcb_reset() prg8_ab(0x09); prg8_cd(0); // switchable bank prg8_ef(0x0b); - chr8(0, CHRRAM); m_irq_enable = 0; m_irq_count = 0; @@ -444,7 +438,6 @@ void nes_0353_device::device_start() void nes_0353_device::pcb_reset() { prg32((m_prg_chunks >> 1) - 1); // fixed 32K bank - chr8(0, CHRRAM); m_reg = 0; } @@ -452,7 +445,7 @@ void nes_0353_device::pcb_reset() void nes_09034a_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_09034a_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_enable)); @@ -462,7 +455,6 @@ void nes_09034a_device::device_start() void nes_09034a_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; prg32(0); chr8(0, m_chr_source); @@ -474,7 +466,7 @@ void nes_09034a_device::pcb_reset() void nes_l001_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_l001_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_count)); @@ -499,7 +491,6 @@ void nes_palthena_device::pcb_reset() prg8_89(0x0c); // 0xa000-0xbfff switchable bank prg16_cdef(m_prg_chunks - 1); - chr8(0, CHRRAM); m_reg = 0; } @@ -512,9 +503,7 @@ void nes_tobidase_device::device_start() void nes_tobidase_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; prg32(2); - chr8(0, m_chr_source); m_latch = 0; } @@ -527,7 +516,6 @@ void nes_whirlwind_device::device_start() void nes_whirlwind_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; prg32((m_prg_chunks >> 1) - 1); // upper PRG: banks are always fixed chr8(0, m_chr_source); @@ -542,8 +530,6 @@ void nes_lh32_device::device_start() void nes_lh32_device::pcb_reset() { - chr8(0, CHRRAM); - prg32((m_prg_chunks - 1) >> 1); // 0xc000-0xdfff reads/writes WRAM m_latch = 0xf; @@ -559,7 +545,6 @@ void nes_lh42_device::pcb_reset() { prg16_89ab(0); prg16_cdef(m_prg_chunks - 1); // Last 16K is fixed - chr8(0, CHRRAM); m_latch = 0; } @@ -574,7 +559,6 @@ void nes_lg25_device::pcb_reset() { prg16_89ab(0); prg16_cdef(m_prg_chunks - 1); // Last 16K is fixed - chr8(0, CHRRAM); m_latch = 0; } @@ -583,7 +567,6 @@ void nes_lh10_device::device_start() { common_start(); save_item(NAME(m_latch)); - save_item(NAME(m_reg)); } void nes_lh10_device::pcb_reset() @@ -592,23 +575,19 @@ void nes_lh10_device::pcb_reset() prg8_ab(0); // 0xc000-0xdfff reads/writes WRAM prg8_ef((m_prg_chunks << 1) - 1); - chr8(0, CHRRAM); - set_nt_mirroring(PPU_MIRROR_VERT); m_latch = 0; - std::fill(std::begin(m_reg), std::end(m_reg), 0x00); } void nes_lh51_device::pcb_reset() { prg32((m_prg_chunks >> 1) - 1); // first 8K is switchable, the rest fixed - chr8(0, CHRRAM); } void nes_lh53_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_lh53_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_enable)); @@ -618,8 +597,6 @@ void nes_lh53_device::device_start() void nes_lh53_device::pcb_reset() { - chr8(0, CHRRAM); - prg8_89(0xc); prg8_ab(0xd); // last 2K are overlaid by WRAM prg8_cd(0xe); // first 6K are overlaid by WRAM @@ -637,8 +614,6 @@ void nes_2708_device::device_start() void nes_2708_device::pcb_reset() { - chr8(0, CHRRAM); - prg32(7); // the upper PRG banks never change, but there are 8K of WRAM overlaid to the ROM area based on reg1 m_reg[0] = 0; @@ -653,28 +628,10 @@ void nes_ac08_device::device_start() void nes_ac08_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - chr8(0, m_chr_source); prg32(0xff); m_latch = 0xff; } -void nes_mmalee_device::device_start() -{ - common_start(); -} - -void nes_mmalee_device::pcb_reset() -{ - chr8(0, CHRROM); - prg32(0); -} - -void nes_rt01_device::device_start() -{ - common_start(); -} - void nes_rt01_device::pcb_reset() { chr2_0(0, CHRROM); @@ -688,7 +645,7 @@ void nes_rt01_device::pcb_reset() void nes_yung08_device::device_start() { common_start(); - irq_timer = timer_alloc(TIMER_IRQ); + irq_timer = timer_alloc(FUNC(nes_yung08_device::irq_timer_tick), this); irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); save_item(NAME(m_irq_count)); @@ -724,7 +681,7 @@ void nes_yung08_device::pcb_reset() -------------------------------------------------*/ -void nes_sc127_device::hblank_irq(int scanline, int vblank, int blanked) +void nes_sc127_device::hblank_irq(int scanline, bool vblank, bool blanked) { if (scanline < ppu2c0x_device::BOTTOM_VISIBLE_SCANLINE && m_irq_enable) { @@ -732,8 +689,8 @@ void nes_sc127_device::hblank_irq(int scanline, int vblank, int blanked) if (!blanked && (m_irq_count == 0)) { - LOG_MMC(("irq fired, scanline: %d\n", scanline)); - hold_irq_line(); + LOG("irq fired, scanline: %d\n", scanline); + set_irq_line(ASSERT_LINE); m_irq_enable = 0; } } @@ -741,7 +698,7 @@ void nes_sc127_device::hblank_irq(int scanline, int vblank, int blanked) void nes_sc127_device::write_h(offs_t offset, uint8_t data) { - LOG_MMC(("sc127 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("sc127 write_h, offset: %04x, data: %02x\n", offset, data); switch (offset) { @@ -768,6 +725,7 @@ void nes_sc127_device::write_h(offs_t offset, uint8_t data) break; case 0x4002: m_irq_enable = 0; + set_irq_line(CLEAR_LINE); break; case 0x4003: m_irq_enable = 1; @@ -793,18 +751,20 @@ void nes_sc127_device::write_h(offs_t offset, uint8_t data) -------------------------------------------------*/ -void nes_mbaby_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_mbaby_device::irq_timer_tick) { - if (id == TIMER_IRQ) + if (m_irq_enable) { - hold_irq_line(); - irq_timer->adjust(attotime::never); + m_irq_count = (m_irq_count + 1) & 0x7fff; // unverified 15-bit counter based on FCEUX + + if (m_irq_count >= 0x6000) + set_irq_line(ASSERT_LINE); } } -void nes_mbaby_device::write_h(offs_t offset, uint8_t data) +void nes_mbaby_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("Mario Baby write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("Mario Baby write_h, offset: %04x, data: %02x\n", offset, data); if (offset >= 0x7000) { @@ -817,25 +777,20 @@ void nes_mbaby_device::write_h(offs_t offset, uint8_t data) set_nt_mirroring(BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); break; case 0x02: - /* Check if IRQ is being enabled */ - if (!m_irq_enable && (data & 0x02)) - { - m_irq_enable = 1; - irq_timer->adjust(timer_freq); - } - if (!(data & 0x02)) + m_irq_enable = BIT(data, 1); + if (!m_irq_enable) { - m_irq_enable = 0; - irq_timer->adjust(attotime::never); + m_irq_count = 0; + set_irq_line(CLEAR_LINE); } break; } } } -uint8_t nes_mbaby_device::read_m(offs_t offset) +u8 nes_mbaby_device::read_m(offs_t offset) { - LOG_MMC(("Mario Baby read_m, offset: %04x\n", offset)); + LOG("Mario Baby read_m, offset: %04x\n", offset); return m_prg[(m_latch * 0x2000) + (offset & 0x1fff)]; } @@ -853,7 +808,7 @@ uint8_t nes_mbaby_device::read_m(offs_t offset) void nes_asn_device::write_h(offs_t offset, uint8_t data) { - LOG_MMC(("Ai Senshi Nicol write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("Ai Senshi Nicol write_h, offset: %04x, data: %02x\n", offset, data); if (offset == 0x0000) chr8(data, CHRROM); @@ -864,7 +819,7 @@ void nes_asn_device::write_h(offs_t offset, uint8_t data) uint8_t nes_asn_device::read_m(offs_t offset) { - LOG_MMC(("Ai Senshi Nicol read_m, offset: %04x\n", offset)); + LOG("Ai Senshi Nicol read_m, offset: %04x\n", offset); return m_prg[((m_latch * 0x2000) + (offset & 0x1fff)) & (m_prg_size - 1)]; } @@ -880,21 +835,18 @@ uint8_t nes_asn_device::read_m(offs_t offset) -------------------------------------------------*/ -void nes_smb3p_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_smb3p_device::irq_timer_tick) { - if (id == TIMER_IRQ) - { - // counter does not stop when interrupts are disabled - if (m_irq_count != 0xffff) - m_irq_count++; - else if (m_irq_enable) - set_irq_line(ASSERT_LINE); - } + // counter does not stop when interrupts are disabled + if (m_irq_count != 0xffff) + m_irq_count++; + if (m_irq_enable && m_irq_count == 0xffff) + set_irq_line(ASSERT_LINE); } void nes_smb3p_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("btl_smb3_w, offset: %04x, data: %02x\n", offset, data)); + LOG("btl_smb3_w, offset: %04x, data: %02x\n", offset, data); switch (offset & 0x0f) { @@ -955,7 +907,7 @@ void nes_smb3p_device::write_h(offs_t offset, u8 data) void nes_btl_cj_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("btl_cj write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("btl_cj write_h, offset: %04x, data: %02x\n", offset, data); if (BIT(offset, 4)) { @@ -966,7 +918,7 @@ void nes_btl_cj_device::write_h(offs_t offset, u8 data) } else { - offset = (offset >> 13) & 0x03; + offset = BIT(offset, 13, 2); if (offset != 3) prg8_x(offset, data & 0x0f); } @@ -985,19 +937,19 @@ void nes_btl_cj_device::write_h(offs_t offset, u8 data) -------------------------------------------------*/ /* Scanline based IRQ ? */ -void nes_btl_dn_device::hblank_irq(int scanline, int vblank, int blanked ) +void nes_btl_dn_device::hblank_irq(int scanline, bool vblank, bool blanked) { if (!m_irq_count || ++m_irq_count < 240) return; m_irq_count = 0; - hold_irq_line(); + set_irq_line(ASSERT_LINE); } void nes_btl_dn_device::write_h(offs_t offset, uint8_t data) { uint8_t bank; - LOG_MMC(("btl_dn write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("btl_dn write_h, offset: %04x, data: %02x\n", offset, data); switch (offset & 0x7003) { @@ -1018,11 +970,12 @@ 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: m_irq_count = data; + set_irq_line(CLEAR_LINE); break; } } @@ -1052,36 +1005,36 @@ void nes_btl_dn_device::write_h(offs_t offset, uint8_t data) u8 nes_whirlwind_device::read_m(offs_t offset) { - LOG_MMC(("whirlwind read_m, offset: %04x\n", offset)); + LOG("whirlwind read_m, offset: %04x\n", offset); return m_prg[((m_reg & m_prg_mask) * 0x2000) + offset]; } void nes_dh08_device::write_h(offs_t offset, u8 data) // submapper 1 { - LOG_MMC(("dh08 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("dh08 write_h, offset: %04x, data: %02x\n", offset, data); if (offset >= 0x7000) m_reg = data; } void nes_le05_device::write_h(offs_t offset, u8 data) // submapper 4 { - LOG_MMC(("le05 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("le05 write_h, offset: %04x, data: %02x\n", offset, data); chr8(data & 1, m_chr_source); } void nes_lh28_lh54_device::write_h(offs_t offset, u8 data) // submapper 3 { - LOG_MMC(("lh28_lh54 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("lh28_lh54 write_h, offset: %04x, data: %02x\n", offset, data); m_reg = data; } void nes_lh31_device::write_h(offs_t offset, u8 data) // submapper 2 { - LOG_MMC(("lh31 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("lh31 write_h, offset: %04x, data: %02x\n", offset, data); if (offset >= 0x6000) { m_reg = data; - chr8(data & (m_vrom_chunks - 1), m_chr_source); + chr8(data, m_chr_source); } } @@ -1097,16 +1050,13 @@ void nes_lh31_device::write_h(offs_t offset, u8 data) // submapper 2 -------------------------------------------------*/ -void nes_smb2j_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_smb2j_device::irq_timer_tick) { - if (id == TIMER_IRQ) + if (m_irq_enable) { - if (m_irq_enable) - { - m_irq_count = (m_irq_count + 1) & 0xfff; - if (!m_irq_count) - set_irq_line(ASSERT_LINE); - } + m_irq_count = (m_irq_count + 1) & 0xfff; + if (!m_irq_count) + set_irq_line(ASSERT_LINE); } } @@ -1137,19 +1087,19 @@ void nes_smb2j_device::write_45(offs_t offset, u8 data) void nes_smb2j_device::write_ex(offs_t offset, u8 data) { - LOG_MMC(("smb2j write_ex, offset: %04x, data: %02x\n", offset, data)); + LOG("smb2j write_ex, offset: %04x, data: %02x\n", offset, data); nes_smb2j_device::write_45(offset + 0x4020, data); } void nes_smb2j_device::write_l(offs_t offset, u8 data) { - LOG_MMC(("smb2j write_l, offset: %04x, data: %02x\n", offset, data)); + LOG("smb2j write_l, offset: %04x, data: %02x\n", offset, data); nes_smb2j_device::write_45(offset + 0x4100, data); } void nes_smb2j_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("smb2j write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("smb2j write_h, offset: %04x, data: %02x\n", offset, data); if (offset == 0x122) // $8122 is also IRQ for YS-612, mask unknown nes_smb2j_device::update_irq(data); @@ -1157,7 +1107,7 @@ void nes_smb2j_device::write_h(offs_t offset, u8 data) u8 nes_smb2j_device::read_l(offs_t offset) { - LOG_MMC(("smb2j read_l, offset: %04x\n", offset)); + LOG("smb2j read_l, offset: %04x\n", offset); offset += 0x100; if (offset >= 0x1000) @@ -1168,7 +1118,7 @@ u8 nes_smb2j_device::read_l(offs_t offset) u8 nes_smb2j_device::read_m(offs_t offset) { - LOG_MMC(("smb2j read_m, offset: %04x\n", offset)); + LOG("smb2j read_m, offset: %04x\n", offset); return m_prg[0x4000 + offset]; } @@ -1184,24 +1134,21 @@ u8 nes_smb2j_device::read_m(offs_t offset) -------------------------------------------------*/ -void nes_smb2ja_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_smb2ja_device::irq_timer_tick) { - if (id == TIMER_IRQ) + if (m_irq_enable) { - if (m_irq_enable) - { - m_irq_count = (m_irq_count + 1) & 0x1fff; // 13-bit counter - if (BIT(m_irq_count, 12)) - set_irq_line(ASSERT_LINE); - else if (!m_irq_count) - set_irq_line(CLEAR_LINE); // CD4020 acknowledges on overflow - } + m_irq_count = (m_irq_count + 1) & 0x1fff; // 13-bit counter + if (BIT(m_irq_count, 12)) + set_irq_line(ASSERT_LINE); + else if (!m_irq_count) + set_irq_line(CLEAR_LINE); // CD4020 acknowledges on overflow } } void nes_smb2ja_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("smb2ja write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("smb2ja write_h, offset: %04x, data: %02x\n", offset, data); switch (offset & 0x6000) { @@ -1221,7 +1168,7 @@ void nes_smb2ja_device::write_h(offs_t offset, u8 data) u8 nes_smb2ja_device::read_m(offs_t offset) { - LOG_MMC(("smb2ja read_m, offset: %04x\n", offset)); + LOG("smb2ja read_m, offset: %04x\n", offset); return m_prg[0x06 * 0x2000 + offset]; // fixed 8K bank } @@ -1239,15 +1186,12 @@ u8 nes_smb2ja_device::read_m(offs_t offset) -------------------------------------------------*/ -void nes_smb2jb_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_smb2jb_device::irq_timer_tick) { - if (id == TIMER_IRQ) + if (m_irq_enable) { - if (m_irq_enable) - { - if (BIT(++m_irq_count, 12)) - set_irq_line(ASSERT_LINE); - } + if (BIT(++m_irq_count, 12)) + set_irq_line(ASSERT_LINE); } } @@ -1272,20 +1216,20 @@ void nes_smb2jb_device::write_45(offs_t offset, u8 data) void nes_smb2jb_device::write_ex(offs_t offset, u8 data) { - LOG_MMC(("smb2jb write_ex, offset: %04x, data: %02x\n", offset, data)); + LOG("smb2jb write_ex, offset: %04x, data: %02x\n", offset, data); write_45(offset + 0x4020, data); } void nes_smb2jb_device::write_l(offs_t offset, u8 data) { - LOG_MMC(("smb2jb write_l, offset: %04x, data: %02x\n", offset, data)); + LOG("smb2jb write_l, offset: %04x, data: %02x\n", offset, data); write_45(offset + 0x4100, data); } u8 nes_smb2jb_device::read_m(offs_t offset) { - LOG_MMC(("smb2jb read_m, offset: %04x\n", offset)); - return m_prg[m_bank67 * 0x2000 + offset]; + LOG("smb2jb read_m, offset: %04x\n", offset); + return m_prg[(m_bank67 * 0x2000 + offset) & (m_prg_size - 1)]; } /*------------------------------------------------- @@ -1308,7 +1252,7 @@ u8 nes_smb2jb_device::read_m(offs_t offset) void nes_n32_4in1_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("n32_4in1 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("n32_4in1 write_h, offset: %04x, data: %02x\n", offset, data); if (offset < 0x2000) { @@ -1333,7 +1277,7 @@ void nes_n32_4in1_device::write_h(offs_t offset, u8 data) prg8_ef(3); } - chr8((data >> 1) & 0x03, CHRROM); + chr8(BIT(data, 1, 2), CHRROM); set_nt_mirroring(BIT(data, 2) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); } } @@ -1352,13 +1296,13 @@ void nes_n32_4in1_device::write_h(offs_t offset, u8 data) u8 nes_0353_device::read_m(offs_t offset) { -// LOG_MMC(("0353 read_m, offset: %04x\n", offset)); + LOGMASKED(LOG_HIFREQ, "0353 read_m, offset: %04x\n", offset); return m_prg[m_reg * 0x2000 + offset]; } void nes_0353_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("0353 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("0353 write_h, offset: %04x, data: %02x\n", offset, data); set_nt_mirroring(BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); m_reg = data & 0x0f; @@ -1388,22 +1332,19 @@ void nes_0353_device::write_h(offs_t offset, u8 data) -------------------------------------------------*/ -void nes_09034a_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_09034a_device::irq_timer_tick) { - if (id == TIMER_IRQ) + if (m_irq_enable) { - if (m_irq_enable) - { - m_irq_count = (m_irq_count + 1) & 0x0fff; - if (!m_irq_count) - set_irq_line(ASSERT_LINE); - } + m_irq_count = (m_irq_count + 1) & 0x0fff; + if (!m_irq_count) + set_irq_line(ASSERT_LINE); } } void nes_09034a_device::write_ex(offs_t offset, u8 data) { - LOG_MMC(("09-034a write_ex, offset: %04x, data: %02x\n", offset, data)); + LOG("09-034a write_ex, offset: %04x, data: %02x\n", offset, data); offset += 0x20; switch (offset) @@ -1424,7 +1365,7 @@ void nes_09034a_device::write_ex(offs_t offset, u8 data) u8 nes_09034a_device::read_ex(offs_t offset) { - LOG_MMC(("09-034a read_ex, offset: %04x, data: %02x\n", offset)); + LOG("09-034a read_ex, offset: %04x, data: %02x\n", offset); offset += 0x20; // SMB2 does not boot with the default open bus reads in this range @@ -1436,7 +1377,7 @@ u8 nes_09034a_device::read_ex(offs_t offset) u8 nes_09034a_device::read_m(offs_t offset) { - LOG_MMC(("09-034a read_m, offset: %04x\n", offset)); + LOG("09-034a read_m, offset: %04x\n", offset); // in 0x6000-0x7fff is mapped the 2nd PRG chip which starts after 32K (hence the +4) return m_prg[(((m_reg + 4) * 0x2000) + offset) & (m_prg_size - 1)]; } @@ -1460,27 +1401,24 @@ u8 nes_09034a_device::read_m(offs_t offset) -------------------------------------------------*/ -void nes_l001_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_l001_device::irq_timer_tick) { - if (id == TIMER_IRQ) + if (BIT(m_irq_count, 15)) { - if (BIT(m_irq_count, 15)) - { - if (++m_irq_count == 0) - set_irq_line(ASSERT_LINE); - } + if (++m_irq_count == 0) + set_irq_line(ASSERT_LINE); } } void nes_l001_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("l-001 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("l-001 write_h, offset: %04x, data: %02x\n", offset, data); switch (offset & 0x6400) { case 0x0000: case 0x2000: - chr1_x((offset >> 11) & 0x07, data, CHRROM); + chr1_x(BIT(offset, 11, 3), data, CHRROM); break; case 0x0400: m_irq_count = (m_irq_count & 0xff00) | data; @@ -1490,11 +1428,11 @@ void nes_l001_device::write_h(offs_t offset, u8 data) set_irq_line(CLEAR_LINE); break; case 0x4000: - set_nt_page((offset >> 11) & 0x03, CIRAM, data & 1, 1); + set_nt_page(BIT(offset, 11, 2), CIRAM, data & 1, 1); break; case 0x6000: if (offset < 0x7800) - prg8_x((offset >> 11) & 0x03, data & 0x1f); + prg8_x(BIT(offset, 11, 2), data & 0x1f); break; } } @@ -1511,20 +1449,17 @@ void nes_l001_device::write_h(offs_t offset, u8 data) -------------------------------------------------*/ -void nes_batmanfs_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_batmanfs_device::irq_timer_tick) { - if (id == TIMER_IRQ) - { - // 10-bit counter does not stop when interrupts are disabled - m_irq_count = (m_irq_count + 1) & 0x3ff; - if (m_irq_enable && !m_irq_count) - set_irq_line(ASSERT_LINE); - } + // 10-bit counter does not stop when interrupts are disabled + m_irq_count = (m_irq_count + 1) & 0x3ff; + if (m_irq_enable && !m_irq_count) + set_irq_line(ASSERT_LINE); } void nes_batmanfs_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("batmanfs write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("batmanfs write_h, offset: %04x, data: %02x\n", offset, data); switch (offset & 0x70) { case 0x00: @@ -1581,7 +1516,7 @@ void nes_batmanfs_device::write_h(offs_t offset, u8 data) u8 nes_palthena_device::read_m(offs_t offset) { -// LOG_MMC(("palthena read_m, offset: %04x\n", offset)); + LOGMASKED(LOG_HIFREQ, "palthena read_m, offset: %04x\n", offset); switch (offset & 0x1f00) { case 0x0000: @@ -1596,7 +1531,7 @@ u8 nes_palthena_device::read_m(offs_t offset) void nes_palthena_device::write_m(offs_t offset, u8 data) { - LOG_MMC(("palthena write_m, offset: %04x, data: %02x\n", offset, data)); + LOG("palthena write_m, offset: %04x, data: %02x\n", offset, data); switch (offset & 0x1f00) { case 0x0000: @@ -1610,8 +1545,8 @@ void nes_palthena_device::write_m(offs_t offset, u8 data) u8 nes_palthena_device::read_h(offs_t offset) { -// LOG_MMC(("palthena read_h, offset: %04x\n", offset)); - u8 page = (offset >> 8); + LOGMASKED(LOG_HIFREQ, "palthena read_h, offset: %04x\n", offset); + u8 page = offset >> 8; if ((page >= 0x40 && page < 0x52) || page == 0x5f) return m_prgram[offset & 0x1fff]; else if (page == 0x02) @@ -1622,8 +1557,8 @@ u8 nes_palthena_device::read_h(offs_t offset) void nes_palthena_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("palthena write_h, offset: %04x, data: %02x\n", offset, data)); - u8 page = (offset >> 8); + LOG("palthena write_h, offset: %04x, data: %02x\n", offset, data); + u8 page = offset >> 8; if ((page >= 0x40 && page < 0x52) || page == 0x5f) m_prgram[offset & 0x1fff] = data; else if (page == 0x02) @@ -1650,7 +1585,7 @@ void nes_palthena_device::write_h(offs_t offset, u8 data) void nes_tobidase_device::write_l(offs_t offset, uint8_t data) { - LOG_MMC(("tobidase write_l, offset: %04x, data: %02x\n", offset, data)); + LOG("tobidase write_l, offset: %04x, data: %02x\n", offset, data); offset += 0x4100; if ((offset & 0x63c0) == 0x41c0) @@ -1659,7 +1594,7 @@ void nes_tobidase_device::write_l(offs_t offset, uint8_t data) uint8_t nes_tobidase_device::read_m(offs_t offset) { - LOG_MMC(("tobidase read_m, offset: %04x\n", offset)); + LOG("tobidase read_m, offset: %04x\n", offset); if (m_latch >= 0x0c) m_latch -= 4; return m_prg[(m_latch * 0x2000) + (offset & 0x1fff)]; @@ -1681,13 +1616,13 @@ uint8_t nes_tobidase_device::read_m(offs_t offset) uint8_t nes_lh32_device::read_m(offs_t offset) { - LOG_MMC(("lh32 read_m, offset: %04x\n", offset)); + LOG("lh32 read_m, offset: %04x\n", offset); return m_prg[(m_latch * 0x2000) + (offset & 0x1fff)]; } uint8_t nes_lh32_device::read_h(offs_t offset) { -// LOG_MMC(("lh32 read_h, offset: %04x\n", offset)); + LOGMASKED(LOG_HIFREQ, "lh32 read_h, offset: %04x\n", offset); if (offset >= 0x4000 && offset < 0x6000) return m_prgram[offset & 0x1fff]; @@ -1697,18 +1632,17 @@ uint8_t nes_lh32_device::read_h(offs_t offset) void nes_lh32_device::write_m(offs_t offset, uint8_t data) { - LOG_MMC(("lh32 write_m, offset: %04x, data: %02x\n", offset, data)); + LOG("lh32 write_m, offset: %04x, data: %02x\n", offset, data); if (offset == 0) // 0x6000 only? { -// printf("write %x\n", data); m_latch = data & 0xf; } } void nes_lh32_device::write_h(offs_t offset, uint8_t data) { - LOG_MMC(("lh32 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("lh32 write_h, offset: %04x, data: %02x\n", offset, data); if (offset >= 0x4000 && offset < 0x6000) m_prgram[offset & 0x1fff] = data; @@ -1722,32 +1656,32 @@ void nes_lh32_device::write_h(offs_t offset, uint8_t data) NES 2.0: mapper 418 - In MAME: Preliminary supported. - - TODO: Investigate garbage tiles on bottom half of - course map screens. This should be car dashboard? + In MAME: Supported. -------------------------------------------------*/ void nes_lh42_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("lh42 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("lh42 write_h, offset: %04x, data: %02x\n", offset, data); - if (BIT(offset, 0)) + switch (offset & 0x6001) { - switch (m_latch) - { - case 1: - set_nt_mirroring(BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); - break; - case 2: - case 3: - prg8_x(m_latch & 1, data & 0x0f); - break; - } + case 0x0000: + m_latch = data & 0x07; + break; + case 0x0001: + switch (m_latch) + { + case 5: + set_nt_mirroring(BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); + break; + case 6: + case 7: + prg8_x(m_latch & 1, data & 0x0f); + break; + } + break; } - else - m_latch = data & 0x03; } /*------------------------------------------------- @@ -1767,23 +1701,26 @@ void nes_lh42_device::write_h(offs_t offset, u8 data) void nes_lg25_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("lg25 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("lg25 write_h, offset: %04x, data: %02x\n", offset, data); - if (BIT(offset, 0)) + switch (offset & 0x6001) { - switch (m_latch) - { - case 1: - set_nt_mirroring(BIT(data, 2) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); - break; - case 2: - case 3: - prg8_x(m_latch & 1, data & 0x0f); - break; - } + case 0x0000: + m_latch = data & 0x07; + break; + case 0x0001: + switch (m_latch) + { + case 5: + set_nt_mirroring(BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); + break; + case 6: + case 7: + prg8_x(m_latch & 1, data & 0x0f); + break; + } + break; } - else - m_latch = data & 0x03; } /*------------------------------------------------- @@ -1801,21 +1738,15 @@ void nes_lg25_device::write_h(offs_t offset, u8 data) -------------------------------------------------*/ -void nes_lh10_device::update_prg() +u8 nes_lh10_device::read_m(offs_t offset) { - prg8_89(m_reg[6]); - prg8_ab(m_reg[7]); + LOG("lh10 read_m, offset: %04x\n", offset); + return m_prg[(0x0e * 0x2000 + offset) & (m_prg_size - 1)]; } -uint8_t nes_lh10_device::read_m(offs_t offset) +u8 nes_lh10_device::read_h(offs_t offset) { - LOG_MMC(("lh10 read_m, offset: %04x\n", offset)); - return m_prg[(0x0e * 0x2000) + (offset & 0x1fff)]; -} - -uint8_t nes_lh10_device::read_h(offs_t offset) -{ -// LOG_MMC(("lh10 read_h, offset: %04x\n", offset)); + LOGMASKED(LOG_HIFREQ, "lh10 read_h, offset: %04x\n", offset); if (offset >= 0x4000 && offset < 0x6000) return m_prgram[offset & 0x1fff]; @@ -1823,24 +1754,28 @@ uint8_t nes_lh10_device::read_h(offs_t offset) return hi_access_rom(offset); } -void nes_lh10_device::write_h(offs_t offset, uint8_t data) +void nes_lh10_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("lh10 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("lh10 write_h, offset: %04x, data: %02x\n", offset, data); - if (offset >= 0x4000 && offset < 0x6000) - m_prgram[offset & 0x1fff] = data; - else + switch (offset & 0x6001) { - switch (offset & 0x6001) - { - case 0x0000: - m_latch = data & 7; - break; - case 0x0001: - m_reg[m_latch] = data; - update_prg(); - break; - } + case 0x0000: + m_latch = data & 7; + break; + case 0x0001: + switch (m_latch) + { + case 6: + case 7: + prg8_x(m_latch & 1, data & 0x0f); + break; + } + break; + case 0x4000: + case 0x4001: + m_prgram[offset & 0x1fff] = data; + break; } } @@ -1863,16 +1798,14 @@ void nes_lh10_device::write_h(offs_t offset, uint8_t data) void nes_lh51_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("lh51 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("lh51 write_h, offset: %04x, data: %02x\n", offset, data); switch (offset & 0x6000) { case 0x0000: - case 0x1000: prg8_89(data & 0x0f); break; case 0x6000: - case 0x7000: set_nt_mirroring(BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); break; } @@ -1892,31 +1825,28 @@ void nes_lh51_device::write_h(offs_t offset, u8 data) -------------------------------------------------*/ -void nes_lh53_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_lh53_device::irq_timer_tick) { - if (id == TIMER_IRQ) + if (m_irq_enable) { - if (m_irq_enable) + m_irq_count++; + if (m_irq_count > 7560)//value from FCEUMM... { - m_irq_count++; - if (m_irq_count > 7560)//value from FCEUMM... - { - m_irq_count = 0; - set_irq_line(ASSERT_LINE); - } + m_irq_count = 0; + set_irq_line(ASSERT_LINE); } } } uint8_t nes_lh53_device::read_m(offs_t offset) { - LOG_MMC(("lh53 read_m, offset: %04x\n", offset)); + LOG("lh53 read_m, offset: %04x\n", offset); return m_prg[m_reg * 0x2000 + offset]; } uint8_t nes_lh53_device::read_h(offs_t offset) { -// LOG_MMC(("lh53 read_h, offset: %04x\n", offset)); + LOGMASKED(LOG_HIFREQ, "lh53 read_h, offset: %04x\n", offset); if (offset >= 0x3800 && offset < 0x5800) return m_prgram[offset - 0x3800]; @@ -1926,7 +1856,7 @@ uint8_t nes_lh53_device::read_h(offs_t offset) void nes_lh53_device::write_h(offs_t offset, uint8_t data) { - LOG_MMC(("lh53 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("lh53 write_h, offset: %04x, data: %02x\n", offset, data); if (offset >= 0x3800 && offset < 0x5800) m_prgram[offset - 0x3800] = data; @@ -1967,7 +1897,7 @@ void nes_lh53_device::write_h(offs_t offset, uint8_t data) uint8_t nes_2708_device::read_m(offs_t offset) { - LOG_MMC(("btl-2708 read_m, offset: %04x\n", offset)); + LOG("btl-2708 read_m, offset: %04x\n", offset); if (!m_reg[1]) return m_prgram[offset]; // lower 8K of WRAM else @@ -1976,14 +1906,14 @@ uint8_t nes_2708_device::read_m(offs_t offset) void nes_2708_device::write_m(offs_t offset, uint8_t data) { - LOG_MMC(("btl-2708 write_m, offset: %04x, data: %02x\n", offset, data)); + LOG("btl-2708 write_m, offset: %04x, data: %02x\n", offset, data); // if (!m_reg[1]) m_prgram[offset] = data; // lower 8K of WRAM } uint8_t nes_2708_device::read_h(offs_t offset) { -// LOG_MMC(("btl-2708 read_h, offset: %04x\n", offset)); + LOGMASKED(LOG_HIFREQ, "btl-2708 read_h, offset: %04x\n", offset); if (offset >= 0x3800 && offset < 0x5800 && !m_reg[1]) return m_prgram[0x2000 + ((offset - 0x3800) & 0x1fff)]; // higher 8K of WRAM @@ -1993,7 +1923,7 @@ uint8_t nes_2708_device::read_h(offs_t offset) void nes_2708_device::write_h(offs_t offset, uint8_t data) { - LOG_MMC(("btl-2708 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("btl-2708 write_h, offset: %04x, data: %02x\n", offset, data); if (offset >= 0x3800 && offset < 0x5800/* && !m_reg[1]*/) m_prgram[0x2000 + ((offset - 0x3800) & 0x1fff)] = data; // higher 8K of WRAM @@ -2030,23 +1960,23 @@ void nes_2708_device::write_h(offs_t offset, uint8_t data) void nes_ac08_device::write_ex(offs_t offset, uint8_t data) { - LOG_MMC(("AC-08 write_ex, offset: %04x, data: %02x\n", offset, data)); + LOG("AC-08 write_ex, offset: %04x, data: %02x\n", offset, data); if (offset == 5) // $4025 set_nt_mirroring(!BIT(data, 3) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); } uint8_t nes_ac08_device::read_m(offs_t offset) { - LOG_MMC(("AC-08 read_m, offset: %04x\n", offset)); + LOG("AC-08 read_m, offset: %04x\n", offset); return m_prg[(m_latch * 0x2000) + (offset & 0x1fff)]; } void nes_ac08_device::write_h(offs_t offset, uint8_t data) { - LOG_MMC(("AC-08 write_h, offset: %04x, data: %02x\n", offset, data)); + LOG("AC-08 write_h, offset: %04x, data: %02x\n", offset, data); if (offset == 1) - m_latch = (data >> 1) & 0x0f; + m_latch = BIT(data, 1, 4); else m_latch = data & 0x0f; // apparently there also is a Castlevania FDS conversion using same board with different banking lines } @@ -2070,7 +2000,7 @@ void nes_ac08_device::write_h(offs_t offset, uint8_t data) uint8_t nes_mmalee_device::read_m(offs_t offset) { - LOG_MMC(("mmalee read_m, offset: %04x\n", offset)); + LOG("mmalee read_m, offset: %04x\n", offset); if (offset < 0x0800) return m_prg[0x8000 + offset]; @@ -2082,7 +2012,7 @@ uint8_t nes_mmalee_device::read_m(offs_t offset) void nes_mmalee_device::write_m(offs_t offset, uint8_t data) { - LOG_MMC(("mmalee write_m, offset: %04x, data: %02x\n", offset, data)); + LOG("mmalee write_m, offset: %04x, data: %02x\n", offset, data); if (!m_prgram.empty() && offset >= 0x1000 && offset < 0x1800) // WRAM only in these 2K m_prgram[offset & 0x7ff] = data; @@ -2106,7 +2036,7 @@ void nes_mmalee_device::write_m(offs_t offset, uint8_t data) uint8_t nes_rt01_device::read_h(offs_t offset) { -// LOG_MMC(("rt01 read_h, offset: %04x\n", offset)); + LOGMASKED(LOG_HIFREQ, "rt01 read_h, offset: %04x\n", offset); if ((offset >= 0x4e80) && (offset < 0x4f00)) return 0xf2 | (machine().rand() & 0x0d); @@ -2128,16 +2058,13 @@ uint8_t nes_rt01_device::read_h(offs_t offset) -------------------------------------------------*/ -void nes_yung08_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(nes_yung08_device::irq_timer_tick) { - if (id == TIMER_IRQ) + if (BIT(m_irq_latch, 0)) { - if (BIT(m_irq_latch, 0)) - { - m_irq_count = (m_irq_count + 1) & 0x0fff; - if (!m_irq_count) - set_irq_line(ASSERT_LINE); - } + m_irq_count = (m_irq_count + 1) & 0x0fff; + if (!m_irq_count) + set_irq_line(ASSERT_LINE); } } @@ -2146,7 +2073,7 @@ void nes_yung08_device::write_45(offs_t offset, u8 data) switch (offset & 0x51ff) { case 0x4022: - prg8_cd(data & 1 ? 3 : 4 + ((data & 0x07) >> 1)); + prg8_cd(data & 1 ? 3 : 4 + BIT(data, 1, 2)); break; case 0x4122: m_irq_latch = data & 0x35; @@ -2161,19 +2088,19 @@ void nes_yung08_device::write_45(offs_t offset, u8 data) void nes_yung08_device::write_ex(offs_t offset, u8 data) { - LOG_MMC(("yung08 write_ex, offset: %04x, data: %02x\n", offset, data)); + LOG("yung08 write_ex, offset: %04x, data: %02x\n", offset, data); write_45(offset + 0x4020, data); } void nes_yung08_device::write_l(offs_t offset, u8 data) { - LOG_MMC(("yung08 write_l, offset: %04x, data: %02x\n", offset, data)); + LOG("yung08 write_l, offset: %04x, data: %02x\n", offset, data); write_45(offset + 0x4100, data); } u8 nes_yung08_device::read_l(offs_t offset) { - LOG_MMC(("yung08 read_l, offset: %04x\n", offset)); + LOG("yung08 read_l, offset: %04x\n", offset); offset += 0x100; if ((offset & 0x11ff) == 0x0122) // 0x4122 return m_irq_latch | 0x8a; @@ -2182,6 +2109,6 @@ u8 nes_yung08_device::read_l(offs_t offset) u8 nes_yung08_device::read_m(offs_t offset) { - LOG_MMC(("yung08 read_m, offset: %04x\n", offset)); + LOG("yung08 read_m, offset: %04x\n", offset); return m_prg[0x02 * 0x2000 + offset]; // fixed to bank #2 } |