summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/nes
diff options
context:
space:
mode:
author 0kmg <9137159+0kmg@users.noreply.github.com>2022-04-06 14:14:19 -0800
committer GitHub <noreply@github.com>2022-04-06 18:14:19 -0400
commit9abd5faf4c153970d9b9d6905a0a1b681af899de (patch)
tree6e76e4beb47a6d7e837047b844555e78676b86d4 /src/devices/bus/nes
parentcc579311dfe9f9a435080dc14c1e3aada829656a (diff)
bus/nes: Minor cleanups and simplifications for several Kaiser boards. (#9523)
Diffstat (limited to 'src/devices/bus/nes')
-rw-r--r--src/devices/bus/nes/kaiser.cpp148
-rw-r--r--src/devices/bus/nes/kaiser.h64
-rw-r--r--src/devices/bus/nes/vrc_clones.h2
3 files changed, 91 insertions, 123 deletions
diff --git a/src/devices/bus/nes/kaiser.cpp b/src/devices/bus/nes/kaiser.cpp
index fa1978dcb08..f0f37d2ba2b 100644
--- a/src/devices/bus/nes/kaiser.cpp
+++ b/src/devices/bus/nes/kaiser.cpp
@@ -68,12 +68,12 @@ nes_ks106c_device::nes_ks106c_device(const machine_config &mconfig, const char *
{
}
-nes_ks7058_device::nes_ks7058_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+nes_ks7058_device::nes_ks7058_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_nrom_device(mconfig, NES_KS7058, tag, owner, clock)
{
}
-nes_ks7022_device::nes_ks7022_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+nes_ks7022_device::nes_ks7022_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_nrom_device(mconfig, NES_KS7022, tag, owner, clock), m_latch(0)
{
}
@@ -108,7 +108,7 @@ nes_ks7016b_device::nes_ks7016b_device(const machine_config &mconfig, const char
{
}
-nes_ks7017_device::nes_ks7017_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+nes_ks7017_device::nes_ks7017_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_nrom_device(mconfig, NES_KS7017, tag, owner, clock), m_latch(0), m_irq_count(0), m_irq_status(0), m_irq_enable(0), irq_timer(nullptr)
{
}
@@ -123,12 +123,12 @@ nes_ks7010_device::nes_ks7010_device(const machine_config &mconfig, const char *
{
}
-nes_ks7012_device::nes_ks7012_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+nes_ks7012_device::nes_ks7012_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_nrom_device(mconfig, NES_KS7012, tag, owner, clock)
{
}
-nes_ks7013b_device::nes_ks7013b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+nes_ks7013b_device::nes_ks7013b_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_nrom_device(mconfig, NES_KS7013B, tag, owner, clock)
{
}
@@ -138,13 +138,13 @@ nes_ks7030_device::nes_ks7030_device(const machine_config &mconfig, const char *
{
}
-nes_ks7031_device::nes_ks7031_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+nes_ks7031_device::nes_ks7031_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_nrom_device(mconfig, NES_KS7031, tag, owner, clock)
{
}
-nes_ks7037_device::nes_ks7037_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : nes_nrom_device(mconfig, NES_KS7037, tag, owner, clock)
+nes_ks7037_device::nes_ks7037_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : nes_nrom_device(mconfig, NES_KS7037, tag, owner, clock), m_reg(0)
{
}
@@ -178,7 +178,6 @@ void nes_ks7022_device::device_start()
void nes_ks7022_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);
@@ -201,16 +200,15 @@ void nes_ks7032_device::device_start()
void nes_ks7032_device::pcb_reset()
{
- m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
- chr8(0, m_chr_source);
-
m_latch = 0;
m_irq_enable = 0;
m_irq_count = 0;
m_irq_count_latch = 0;
std::fill(std::begin(m_reg), std::end(m_reg), 0x00);
+
prg_update();
prg8_ef((m_prg_chunks << 1) - 1);
+ chr8(0, m_chr_source);
}
void nes_ks7016_device::device_start()
@@ -225,8 +223,6 @@ void nes_ks7016_device::pcb_reset()
prg8_ab(0x0d ^ m_a15_flip);
prg8_cd(0x0e ^ m_a15_flip);
prg8_ef(0x0f ^ m_a15_flip);
- chr8(0, CHRRAM);
- set_nt_mirroring(PPU_MIRROR_VERT);
m_latch = 0;
}
@@ -245,10 +241,8 @@ void nes_ks7017_device::device_start()
void nes_ks7017_device::pcb_reset()
{
- m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
prg16_89ab(0);
prg16_cdef(2);
- chr8(0, m_chr_source);
m_latch = 0;
m_irq_enable = 0;
@@ -274,24 +268,19 @@ void nes_ks7010_device::pcb_reset()
prg16_89ab(0x05); // all upper banks are fixed
prg16_cdef(0x03);
chr8(0, CHRROM);
- set_nt_mirroring(PPU_MIRROR_VERT);
m_latch = 0;
}
void nes_ks7012_device::pcb_reset()
{
- m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
- prg32(0xff);
- chr8(0, m_chr_source);
+ prg32((m_prg_chunks >> 1) - 1);
}
void nes_ks7013b_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);
}
void nes_ks7030_device::device_start()
@@ -303,8 +292,6 @@ void nes_ks7030_device::device_start()
void nes_ks7030_device::pcb_reset()
{
prg32((m_prg_chunks >> 1) - 1); // not really used...
- chr8(0, CHRRAM);
- set_nt_mirroring(PPU_MIRROR_VERT);
m_reg[0] = m_reg[1] = 0;
}
@@ -318,18 +305,13 @@ void nes_ks7031_device::device_start()
void nes_ks7031_device::pcb_reset()
{
prg32(0); // not really used...
- chr8(0, CHRRAM);
- m_reg[0] = 0;
- m_reg[1] = 0;
- m_reg[2] = 0;
- m_reg[3] = 0;
+ std::fill(std::begin(m_reg), std::end(m_reg), 0x00);
}
void nes_ks7037_device::device_start()
{
common_start();
- save_item(NAME(m_latch));
save_item(NAME(m_reg));
}
@@ -339,10 +321,8 @@ void nes_ks7037_device::pcb_reset()
prg8_ab(0x0e);
prg8_cd(0);
prg8_ef(0x0f);
- chr8(0, CHRRAM);
- std::fill(std::begin(m_reg), std::end(m_reg), 0x00);
- m_latch = 0;
+ m_reg = 0;
}
void nes_ks7057_device::device_start()
@@ -355,7 +335,6 @@ void nes_ks7057_device::pcb_reset()
{
prg8_ab(0x0d);
prg16_cdef(0x07);
- chr8(0, CHRRAM);
std::fill(std::begin(m_reg), std::end(m_reg), 0x00);
}
@@ -397,7 +376,7 @@ void nes_ks7057_device::pcb_reset()
-------------------------------------------------*/
-void nes_ks7058_device::write_h(offs_t offset, uint8_t data)
+void nes_ks7058_device::write_h(offs_t offset, u8 data)
{
LOG_MMC(("ks7058 write_h, offset: %04x, data: %02x\n", offset, data));
@@ -424,18 +403,17 @@ void nes_ks7058_device::write_h(offs_t offset, uint8_t data)
-------------------------------------------------*/
-void nes_ks7022_device::write_h(offs_t offset, uint8_t data)
+void nes_ks7022_device::write_h(offs_t offset, u8 data)
{
LOG_MMC(("ks7022 write_h, offset: %04x, data: %02x\n", offset, data));
if (offset == 0)
set_nt_mirroring(BIT(data, 2) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
-
- if (offset == 0x2000)
+ else if (offset == 0x2000)
m_latch = data & 0x0f;
}
-uint8_t nes_ks7022_device::read_h(offs_t offset)
+u8 nes_ks7022_device::read_h(offs_t offset)
{
LOG_MMC(("ks7022 read_h, offset: %04x\n", offset));
@@ -649,7 +627,7 @@ void nes_ks7017_device::device_timer(emu_timer &timer, device_timer_id id, int p
}
}
-void nes_ks7017_device::write_l(offs_t offset, uint8_t data)
+void nes_ks7017_device::write_l(offs_t offset, u8 data)
{
LOG_MMC(("ks7017 write_l, offset: %04x, data: %02x\n", offset, data));
@@ -665,30 +643,32 @@ void nes_ks7017_device::write_l(offs_t offset, uint8_t data)
}
}
-void nes_ks7017_device::write_ex(offs_t offset, uint8_t data)
+void nes_ks7017_device::write_ex(offs_t offset, u8 data)
{
LOG_MMC(("ks7017 write_ex, offset: %04x, data: %02x\n", offset, data));
- offset += 0x20;
- if (offset == 0x0020) // 0x4020
- m_irq_count = (m_irq_count & 0xff00) | data;
-
- if (offset == 0x0021) // 0x4021
+ offset += 0x4020;
+ switch (offset)
{
- m_irq_count = (m_irq_count & 0x00ff) | (data << 8);
- m_irq_enable = 1;
+ case 0x4020:
+ m_irq_count = (m_irq_count & 0xff00) | data;
+ break;
+ case 0x4021:
+ m_irq_count = (m_irq_count & 0x00ff) | (data << 8);
+ m_irq_enable = 1;
+ break;
+ case 0x4025:
+ set_nt_mirroring(BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
+ break;
}
-
- if (offset == 0x0025) // 0x4025
- set_nt_mirroring(BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
}
-uint8_t nes_ks7017_device::read_ex(offs_t offset)
+u8 nes_ks7017_device::read_ex(offs_t offset)
{
LOG_MMC(("ks7017 read_ex, offset: %04x\n", offset));
- offset += 0x20;
- if (offset == 0x0030) // 0x4030
+ offset += 0x4020;
+ if (offset == 0x4030)
{
int temp = m_irq_status;
m_irq_status &= ~0x01;
@@ -781,7 +761,7 @@ u8 nes_ks7010_device::read_h(offs_t offset)
-------------------------------------------------*/
-void nes_ks7012_device::write_h(offs_t offset, uint8_t data)
+void nes_ks7012_device::write_h(offs_t offset, u8 data)
{
LOG_MMC(("ks7012 write_h, offset: %04x, data: %02x\n", offset, data));
@@ -803,13 +783,13 @@ void nes_ks7012_device::write_h(offs_t offset, uint8_t data)
-------------------------------------------------*/
-void nes_ks7013b_device::write_m(offs_t offset, uint8_t data)
+void nes_ks7013b_device::write_m(offs_t offset, u8 data)
{
LOG_MMC(("ks7013b write_l, offset: %04x, data: %02x\n", offset, data));
prg16_89ab(data);
}
-void nes_ks7013b_device::write_h(offs_t offset, uint8_t data)
+void nes_ks7013b_device::write_h(offs_t offset, u8 data)
{
LOG_MMC(("ks7013b write_h, offset: %04x, data: %02x\n", offset, data));
set_nt_mirroring((data & 1) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
@@ -905,20 +885,20 @@ void nes_ks7030_device::write_h(offs_t offset, u8 data)
-------------------------------------------------*/
-uint8_t nes_ks7031_device::read_m(offs_t offset)
+u8 nes_ks7031_device::read_m(offs_t offset)
{
// LOG_MMC(("ks7031 read_m, offset: %04x\n", offset));
return m_prg[(m_reg[BIT(offset, 11, 2)] * 0x0800) + (offset & 0x7ff)];
}
-uint8_t nes_ks7031_device::read_h(offs_t offset)
+u8 nes_ks7031_device::read_h(offs_t offset)
{
// here the first 32K are accessed, but in 16x2K blocks loaded in reverse order
- int accessed_2k = BIT(offset, 11, 4);
- return m_prg[((0x0f - accessed_2k) * 0x0800) + (offset & 0x7ff)];
+ int accessed_2k = BIT(~offset, 11, 4);
+ return m_prg[accessed_2k * 0x0800 + (offset & 0x7ff)];
}
-void nes_ks7031_device::write_h(offs_t offset, uint8_t data)
+void nes_ks7031_device::write_h(offs_t offset, u8 data)
{
LOG_MMC(("ks7031 write_h, offset: %04x, data: %02x\n", offset, data));
m_reg[BIT(offset, 11, 2)] = data & 0x3f;
@@ -941,17 +921,7 @@ void nes_ks7031_device::write_h(offs_t offset, uint8_t data)
-------------------------------------------------*/
-void nes_ks7037_device::update_prg()
-{
- prg8_89(m_reg[6]);
- prg8_cd(m_reg[7]);
- set_nt_page(0, CIRAM, m_reg[2] & 1, 1);
- set_nt_page(2, CIRAM, m_reg[3] & 1, 1);
- set_nt_page(1, CIRAM, m_reg[4] & 1, 1);
- set_nt_page(3, CIRAM, m_reg[5] & 1, 1);
-}
-
-uint8_t nes_ks7037_device::read_m(offs_t offset)
+u8 nes_ks7037_device::read_m(offs_t offset)
{
// LOG_MMC(("ks7037 read_m, offset: %04x\n", offset));
if (offset < 0x1000)
@@ -960,14 +930,14 @@ uint8_t nes_ks7037_device::read_m(offs_t offset)
return m_prg[0x0f * 0x1000 + (offset & 0x0fff)]; // 4k PRG bank 15 is fixed
}
-void nes_ks7037_device::write_m(offs_t offset, uint8_t data)
+void nes_ks7037_device::write_m(offs_t offset, u8 data)
{
LOG_MMC(("ks7037 write_m, offset: %04x, data: %02x\n", offset, data));
if (offset < 0x1000)
m_prgram[offset] = data;
}
-uint8_t nes_ks7037_device::read_h(offs_t offset)
+u8 nes_ks7037_device::read_h(offs_t offset)
{
// LOG_MMC(("ks7037 read_h, offset: %04x\n", offset));
@@ -977,24 +947,24 @@ uint8_t nes_ks7037_device::read_h(offs_t offset)
return hi_access_rom(offset);
}
-void nes_ks7037_device::write_h(offs_t offset, uint8_t data)
+void nes_ks7037_device::write_h(offs_t offset, u8 data)
{
LOG_MMC(("ks7037 write_h, offset: %04x, data: %02x\n", offset, data));
- if (offset >= 0x3000 && offset < 0x4000)
- m_prgram[0x1000 + (offset & 0x0fff)] = data;
- else
+ switch (offset & 0x7000)
{
- switch (offset & 0x6001)
- {
- case 0x0000:
- m_latch = data & 7;
- break;
- case 0x0001:
- m_reg[m_latch] = data;
- update_prg();
- break;
- }
+ case 0x0000:
+ case 0x1000:
+ if (!(offset & 1))
+ m_reg = data & 7;
+ else if (m_reg >= 6)
+ prg8_x((m_reg & 1) << 1, data);
+ else if (m_reg >= 2)
+ set_nt_page(bitswap<2>(m_reg, 0, 2), CIRAM, data & 1, 1);
+ break;
+ case 0x3000:
+ m_prgram[0x1000 + (offset & 0x0fff)] = data;
+ break;
}
}
diff --git a/src/devices/bus/nes/kaiser.h b/src/devices/bus/nes/kaiser.h
index e0ee325137e..4c19ff2c2a0 100644
--- a/src/devices/bus/nes/kaiser.h
+++ b/src/devices/bus/nes/kaiser.h
@@ -33,9 +33,9 @@ class nes_ks7058_device : public nes_nrom_device
{
public:
// construction/destruction
- nes_ks7058_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nes_ks7058_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;
};
@@ -45,10 +45,10 @@ class nes_ks7022_device : public nes_nrom_device
{
public:
// construction/destruction
- nes_ks7022_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nes_ks7022_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
- virtual uint8_t read_h(offs_t offset) override;
- virtual void write_h(offs_t offset, uint8_t data) override;
+ virtual u8 read_h(offs_t offset) override;
+ virtual void write_h(offs_t offset, u8 data) override;
virtual void pcb_reset() override;
@@ -57,7 +57,7 @@ protected:
virtual void device_start() override;
private:
- uint8_t m_latch;
+ u8 m_latch;
};
@@ -89,7 +89,7 @@ private:
u8 m_latch;
u16 m_irq_count, m_irq_count_latch;
- int m_irq_enable;
+ u8 m_irq_enable;
static const device_timer_id TIMER_IRQ = 0;
emu_timer *irq_timer;
@@ -151,11 +151,11 @@ class nes_ks7017_device : public nes_nrom_device
{
public:
// construction/destruction
- nes_ks7017_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nes_ks7017_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
- virtual uint8_t read_ex(offs_t offset) override;
- virtual void write_ex(offs_t offset, uint8_t data) override;
- virtual void write_l(offs_t offset, uint8_t data) override;
+ virtual u8 read_ex(offs_t offset) override;
+ virtual void write_ex(offs_t offset, u8 data) override;
+ virtual void write_l(offs_t offset, u8 data) override;
virtual void pcb_reset() override;
@@ -165,11 +165,11 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
- uint8_t m_latch;
+ u8 m_latch;
- uint16_t m_irq_count;
- uint8_t m_irq_status;
- int m_irq_enable;
+ u16 m_irq_count;
+ u8 m_irq_status;
+ u8 m_irq_enable;
static const device_timer_id TIMER_IRQ = 0;
emu_timer *irq_timer;
@@ -218,9 +218,9 @@ class nes_ks7012_device : public nes_nrom_device
{
public:
// construction/destruction
- nes_ks7012_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nes_ks7012_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;
};
@@ -232,10 +232,10 @@ class nes_ks7013b_device : public nes_nrom_device
{
public:
// construction/destruction
- nes_ks7013b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nes_ks7013b_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
- virtual void write_m(offs_t offset, uint8_t data) override;
- virtual void write_h(offs_t offset, uint8_t data) override;
+ virtual void write_m(offs_t offset, u8 data) override;
+ virtual void write_h(offs_t offset, u8 data) override;
virtual void pcb_reset() override;
};
@@ -271,11 +271,11 @@ class nes_ks7031_device : public nes_nrom_device
{
public:
// construction/destruction
- nes_ks7031_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nes_ks7031_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
- virtual uint8_t read_m(offs_t offset) override;
- virtual uint8_t read_h(offs_t offset) override;
- virtual void write_h(offs_t offset, uint8_t data) override;
+ virtual u8 read_m(offs_t offset) override;
+ virtual u8 read_h(offs_t offset) override;
+ virtual void write_h(offs_t offset, u8 data) override;
virtual void pcb_reset() override;
@@ -284,7 +284,7 @@ protected:
virtual void device_start() override;
private:
- uint8_t m_reg[4];
+ u8 m_reg[4];
};
@@ -294,12 +294,12 @@ class nes_ks7037_device : public nes_nrom_device
{
public:
// construction/destruction
- nes_ks7037_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nes_ks7037_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
- virtual uint8_t read_m(offs_t offset) override;
- virtual uint8_t read_h(offs_t offset) override;
- virtual void write_m(offs_t offset, uint8_t data) override;
- virtual void write_h(offs_t offset, uint8_t data) override;
+ virtual u8 read_m(offs_t offset) override;
+ virtual u8 read_h(offs_t offset) override;
+ virtual void write_m(offs_t offset, u8 data) override;
+ virtual void write_h(offs_t offset, u8 data) override;
virtual void pcb_reset() override;
@@ -308,9 +308,7 @@ protected:
virtual void device_start() override;
private:
- void update_prg();
- uint8_t m_latch;
- uint8_t m_reg[8];
+ u8 m_reg;
};
diff --git a/src/devices/bus/nes/vrc_clones.h b/src/devices/bus/nes/vrc_clones.h
index 780dc6ae0cb..5ff15d806e4 100644
--- a/src/devices/bus/nes/vrc_clones.h
+++ b/src/devices/bus/nes/vrc_clones.h
@@ -121,7 +121,7 @@ public:
// construction/destruction
nes_cityfight_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;
protected:
// device-level overrides