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.cpp103
1 files changed, 42 insertions, 61 deletions
diff --git a/src/devices/bus/nes/namcot.cpp b/src/devices/bus/nes/namcot.cpp
index 4e0951bf92a..67d321fc137 100644
--- a/src/devices/bus/nes/namcot.cpp
+++ b/src/devices/bus/nes/namcot.cpp
@@ -8,7 +8,7 @@
Here we emulate the following PCBs
- * Namcot 3433 & 3443 (aka DxROM) [mapper 88, 204, 154]
+ * Namcot 3433 & 3443 (aka DxROM) [mapper 88, 206, 154]
* Namcot 3446 [mapper 76]
* Namcot 3425 [mapper 95]
* Namcot 163 [mapper 19]
@@ -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);
@@ -296,7 +289,6 @@ void nes_namcot3433_device::dxrom_write(offs_t offset, uint8_t data)
}
}
-
/*-------------------------------------------------
Namcot 3446 board emulation
@@ -311,33 +303,25 @@ 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);
- // NEStopia does not have this!
if (offset >= 0x2000)
- {
- if (!(offset & 1))
- set_nt_mirroring(BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
return;
- }
- switch (offset & 1)
+ if (offset & 1)
{
- case 1:
- switch (m_latch & 0x07)
+ switch (m_latch & 0x07)
{
case 2: chr2_0(data, CHRROM); break;
case 3: chr2_2(data, CHRROM); break;
case 4: chr2_4(data, CHRROM); break;
case 5: chr2_6(data, CHRROM); break;
- case 6: BIT(m_latch, 6) ? prg8_cd(data) : prg8_89(data); break;
+ case 6: prg8_89(data); break;
case 7: prg8_ab(data); break;
}
- break;
- case 0:
- m_latch = data;
- break;
}
+ else
+ m_latch = data;
}
/*-------------------------------------------------
@@ -356,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;
@@ -408,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)
@@ -447,17 +428,19 @@ 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)
{
case 0x1000:
return m_irq_count & 0xff;
- set_irq_line(CLEAR_LINE);
+ set_irq_line(CLEAR_LINE); // FIXME: unreachable
+ [[fallthrough]];
case 0x1800:
- return (m_irq_count >> 8) & 0xff;
- set_irq_line(CLEAR_LINE);
+ return m_irq_count >> 8;
+ set_irq_line(CLEAR_LINE); // FIXME: unreachable
+ [[fallthrough]];
default:
return 0x00;
}
@@ -465,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)
{
@@ -473,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...
@@ -520,7 +503,7 @@ void nes_namcot340_device::n340_hiwrite(offs_t offset, uint8_t data)
iNES: mapper 210
- In MESS: Supported
+ In MAME: Supported
-------------------------------------------------*/
@@ -531,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)
@@ -544,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)
{
@@ -573,7 +556,7 @@ void nes_namcot175_device::write_h(offs_t offset, uint8_t data)
iNES: mapper 19
- In MESS: Supported
+ In MAME: Supported
-------------------------------------------------*/
@@ -612,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)
@@ -641,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)
@@ -663,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)
{
@@ -673,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);