summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/nes/namcot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/nes/namcot.cpp')
-rw-r--r--src/devices/bus/nes/namcot.cpp76
1 files changed, 32 insertions, 44 deletions
diff --git a/src/devices/bus/nes/namcot.cpp b/src/devices/bus/nes/namcot.cpp
index 1e6b96f058e..67d321fc137 100644
--- a/src/devices/bus/nes/namcot.cpp
+++ b/src/devices/bus/nes/namcot.cpp
@@ -28,12 +28,11 @@
#include "speaker.h"
#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"
//-------------------------------------------------
@@ -98,7 +97,6 @@ void nes_namcot3433_device::device_start()
void nes_namcot3433_device::pcb_reset()
{
- m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
prg16_89ab(m_prg_chunks - 2);
prg16_cdef(m_prg_chunks - 1);
chr8(0, m_chr_source);
@@ -114,7 +112,6 @@ void nes_namcot3446_device::device_start()
void nes_namcot3446_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);
@@ -131,7 +128,6 @@ void nes_namcot3425_device::device_start()
void nes_namcot3425_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);
@@ -143,7 +139,7 @@ void nes_namcot3425_device::pcb_reset()
void nes_namcot340_device::device_start()
{
common_start();
- irq_timer = timer_alloc(TIMER_IRQ);
+ irq_timer = timer_alloc(FUNC(nes_namcot340_device::irq_timer_tick), this);
irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1));
save_item(NAME(m_irq_enable));
@@ -156,7 +152,6 @@ void nes_namcot340_device::device_start()
void nes_namcot340_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);
@@ -169,7 +164,7 @@ void nes_namcot340_device::pcb_reset()
void nes_namcot175_device::device_start()
{
common_start();
- irq_timer = timer_alloc(TIMER_IRQ);
+ irq_timer = timer_alloc(FUNC(nes_namcot175_device::irq_timer_tick), this);
irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1));
save_item(NAME(m_irq_enable));
@@ -183,7 +178,6 @@ void nes_namcot175_device::device_start()
void nes_namcot175_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);
@@ -197,7 +191,7 @@ void nes_namcot175_device::pcb_reset()
void nes_namcot163_device::device_start()
{
common_start();
- irq_timer = timer_alloc(TIMER_IRQ);
+ irq_timer = timer_alloc(FUNC(nes_namcot163_device::irq_timer_tick), this);
irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1));
save_item(NAME(m_irq_enable));
@@ -231,7 +225,6 @@ void nes_namcot163_device::device_start()
void nes_namcot163_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);
@@ -267,7 +260,7 @@ void nes_namcot163_device::pcb_reset()
void nes_namcot3433_device::dxrom_write(offs_t offset, uint8_t data)
{
- LOG_MMC(("dxrom_write, offset: %04x, data: %02x\n", offset, data));
+ LOG("dxrom_write, offset: %04x, data: %02x\n", offset, data);
if (!(offset & 1) && m_pcb_ctrl_mirror)
set_nt_mirroring(BIT(data, 6) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
@@ -310,7 +303,7 @@ void nes_namcot3433_device::dxrom_write(offs_t offset, uint8_t data)
void nes_namcot3446_device::write_h(offs_t offset, uint8_t data)
{
- LOG_MMC(("namcot3446 write_h, offset: %04x, data: %02x\n", offset, data));
+ LOG("namcot3446 write_h, offset: %04x, data: %02x\n", offset, data);
if (offset >= 0x2000)
return;
@@ -347,7 +340,7 @@ void nes_namcot3446_device::write_h(offs_t offset, uint8_t data)
void nes_namcot3425_device::write_h(offs_t offset, uint8_t data)
{
uint8_t mode;
- LOG_MMC(("namcot3425 write_h, offset: %04x, data: %02x\n", offset, data));
+ LOG("namcot3425 write_h, offset: %04x, data: %02x\n", offset, data);
if (offset >= 0x2000)
return;
@@ -399,27 +392,24 @@ void nes_namcot3425_device::write_h(offs_t offset, uint8_t data)
iNES: mapper 210
- In MESS: Supported
+ In MAME: Supported
-------------------------------------------------*/
-void nes_namcot340_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(nes_namcot340_device::irq_timer_tick)
{
- if (id == TIMER_IRQ)
+ if (m_irq_enable)
{
- if (m_irq_enable)
- {
- if (m_irq_count == 0x7fff) // counter does not wrap to 0!
- set_irq_line(ASSERT_LINE);
- else
- m_irq_count++;
- }
+ if (m_irq_count == 0x7fff) // counter does not wrap to 0!
+ set_irq_line(ASSERT_LINE);
+ else
+ m_irq_count++;
}
}
void nes_namcot340_device::n340_lowrite(offs_t offset, uint8_t data)
{
- LOG_MMC(("n340_lowrite, offset: %04x, data: %02x\n", offset, data));
+ LOG("n340_lowrite, offset: %04x, data: %02x\n", offset, data);
offset += 0x100;
switch (offset & 0x1800)
@@ -438,7 +428,7 @@ void nes_namcot340_device::n340_lowrite(offs_t offset, uint8_t data)
uint8_t nes_namcot340_device::n340_loread(offs_t offset)
{
- LOG_MMC(("n340_loread, offset: %04x\n", offset));
+ LOG("n340_loread, offset: %04x\n", offset);
offset += 0x100;
switch (offset & 0x1800)
@@ -448,7 +438,7 @@ uint8_t nes_namcot340_device::n340_loread(offs_t offset)
set_irq_line(CLEAR_LINE); // FIXME: unreachable
[[fallthrough]];
case 0x1800:
- return (m_irq_count >> 8) & 0xff;
+ return m_irq_count >> 8;
set_irq_line(CLEAR_LINE); // FIXME: unreachable
[[fallthrough]];
default:
@@ -458,7 +448,7 @@ uint8_t nes_namcot340_device::n340_loread(offs_t offset)
void nes_namcot340_device::n340_hiwrite(offs_t offset, uint8_t data)
{
- LOG_MMC(("n340_hiwrite, offset: %04x, data: %02x\n", offset, data));
+ LOG("n340_hiwrite, offset: %04x, data: %02x\n", offset, data);
switch (offset & 0x7800)
{
@@ -466,7 +456,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...
@@ -513,7 +503,7 @@ void nes_namcot340_device::n340_hiwrite(offs_t offset, uint8_t data)
iNES: mapper 210
- In MESS: Supported
+ In MAME: Supported
-------------------------------------------------*/
@@ -524,7 +514,7 @@ uint8_t nes_namcot175_device::read_m(offs_t offset)
if (!m_battery.empty() && !m_wram_protect)
return m_battery[offset & (m_battery.size() - 1)];
- return get_open_bus(); // open bus
+ return get_open_bus();
}
void nes_namcot175_device::write_m(offs_t offset, uint8_t data)
@@ -537,7 +527,7 @@ void nes_namcot175_device::write_m(offs_t offset, uint8_t data)
void nes_namcot175_device::write_h(offs_t offset, uint8_t data)
{
- LOG_MMC(("namcot175 write_h, offset: %04x, data: %02x\n", offset, data));
+ LOG("namcot175 write_h, offset: %04x, data: %02x\n", offset, data);
switch (offset & 0x7800)
{
@@ -566,7 +556,7 @@ void nes_namcot175_device::write_h(offs_t offset, uint8_t data)
iNES: mapper 19
- In MESS: Supported
+ In MAME: Supported
-------------------------------------------------*/
@@ -605,20 +595,20 @@ uint8_t nes_namcot163_device::read_m(offs_t offset)
if (!m_battery.empty() && offset < m_battery.size())
return m_battery[offset & (m_battery.size() - 1)];
- return get_open_bus(); // open bus
+ return get_open_bus();
}
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;
}
void nes_namcot163_device::write_l(offs_t offset, uint8_t data)
{
- LOG_MMC(("namcot163 write_l, offset: %04x, data: %02x\n", offset, data));
+ LOG("namcot163 write_l, offset: %04x, data: %02x\n", offset, data);
offset += 0x100;
switch (offset & 0x1800)
@@ -634,7 +624,7 @@ void nes_namcot163_device::write_l(offs_t offset, uint8_t data)
uint8_t nes_namcot163_device::read_l(offs_t offset)
{
- LOG_MMC(("namcot163 read_l, offset: %04x\n", offset));
+ LOG("namcot163 read_l, offset: %04x\n", offset);
offset += 0x100;
switch (offset & 0x1800)
@@ -656,8 +646,7 @@ void nes_namcot163_device::set_mirror(uint8_t page, uint8_t data)
void nes_namcot163_device::write_h(offs_t offset, uint8_t data)
{
- int page;
- LOG_MMC(("namcot163 write_h, offset: %04x, data: %02x\n", offset, data));
+ LOG("namcot163 write_h, offset: %04x, data: %02x\n", offset, data);
switch (offset & 0x7800)
{
@@ -666,14 +655,13 @@ void nes_namcot163_device::write_h(offs_t offset, uint8_t data)
case 0x2000: case 0x2800:
case 0x3000: case 0x3800:
m_chr_bank = data;
- chr1_x(offset / 0x800, m_chr_bank, CHRROM);
+ chr1_x(offset >> 11, m_chr_bank, CHRROM);
break;
case 0x4000:
case 0x4800:
case 0x5000:
case 0x5800:
- page = (offset & 0x1800) >> 11;
- set_mirror(page, data);
+ set_mirror(BIT(offset, 11, 2), data);
break;
case 0x6000:
m_namco163snd->disable_w((data & 0x40) ? ASSERT_LINE : CLEAR_LINE);