diff options
Diffstat (limited to 'src')
119 files changed, 3109 insertions, 1204 deletions
diff --git a/src/devices/bus/nes/bootleg.cpp b/src/devices/bus/nes/bootleg.cpp index 2758b6aff6c..4903f85ccf1 100644 --- a/src/devices/bus/nes/bootleg.cpp +++ b/src/devices/bus/nes/bootleg.cpp @@ -107,17 +107,17 @@ nes_btl_dn_device::nes_btl_dn_device(const machine_config &mconfig, const char * { } -nes_smb2j_device::nes_smb2j_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_smb2j_device::nes_smb2j_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_SMB2J, tag, owner, clock), m_irq_count(0), m_irq_enable(0), irq_timer(nullptr) { } -nes_smb2ja_device::nes_smb2ja_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_smb2ja_device::nes_smb2ja_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_SMB2JA, tag, owner, clock), m_irq_count(0), m_irq_enable(0), irq_timer(nullptr) { } -nes_smb2jb_device::nes_smb2jb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_smb2jb_device::nes_smb2jb_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_SMB2JB, tag, owner, clock), m_irq_count(0), m_irq_enable(0), irq_timer(nullptr) { } @@ -381,12 +381,11 @@ void nes_smb2j_device::device_start() void nes_smb2j_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - chr8(0, m_chr_source); prg8_89(1); prg8_ab(0); - prg8_cd(0); + prg8_cd(4); // switchable bank prg8_ef(9); + chr8(0, CHRROM); m_irq_enable = 0; m_irq_count = 0; @@ -404,12 +403,11 @@ void nes_smb2ja_device::device_start() void nes_smb2ja_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg8_89(0xfc); - prg8_ab(0xfd); - prg8_cd(0xfe); - prg8_ef(0xff); - chr8(0, m_chr_source); + prg8_89(4); + prg8_ab(5); + prg8_cd(0); // switchable bank + prg8_ef(7); + chr8(0, CHRROM); m_irq_enable = 0; m_irq_count = 0; @@ -427,12 +425,11 @@ void nes_smb2jb_device::device_start() void nes_smb2jb_device::pcb_reset() { - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; prg8_89(0x08); prg8_ab(0x09); - prg8_cd(0); + prg8_cd(0); // switchable bank prg8_ef(0x0b); - chr8(0, m_chr_source); + chr8(0, CHRRAM); m_irq_enable = 0; m_irq_count = 0; @@ -1161,7 +1158,7 @@ void nes_lh31_device::write_h(offs_t offset, u8 data) // submapper 2 Bootleg Board SMB2J - Games: Super Mario Bros. 2 Pirate (LF36) + Games: Super Mario Bros. 2 Pirates (TONY-I, YS-612) iNES: mapper 43 @@ -1175,54 +1172,59 @@ void nes_smb2j_device::device_timer(emu_timer &timer, device_timer_id id, int pa { if (m_irq_enable) { - if (m_irq_count == 0xfff) - { - hold_irq_line(); - m_irq_enable = 0; - m_irq_count = 0; - } - else - m_irq_count++; + m_irq_count = (m_irq_count + 1) & 0xfff; + if (!m_irq_count) + set_irq_line(ASSERT_LINE); } } } -void nes_smb2j_device::write_l(offs_t offset, uint8_t data) +void nes_smb2j_device::update_irq(u8 data) { - LOG_MMC(("smb2j write_l, offset: %04x, data: %02x\n", offset, data)); - offset += 0x100; - - if (offset == 0x122) // $4122 - m_irq_enable = data & 3; // maybe also m_irq_count = 0?!? + m_irq_enable = BIT(data, 0); + if (!m_irq_enable) + { + set_irq_line(CLEAR_LINE); + m_irq_count = 0; + } } -void nes_smb2j_device::write_h(offs_t offset, uint8_t data) +void nes_smb2j_device::write_45(offs_t offset, u8 data) { - LOG_MMC(("smb2j write_h, offset: %04x, data: %02x\n", offset, data)); + static const u8 bank[8] = {4, 3, 4, 4, 4, 7, 5, 6}; - if (offset == 0x122) // $8122 too? - m_irq_enable = data & 3; + switch (offset & 0x71ff) + { + case 0x4022: + prg8_cd(bank[data & 0x07]); + break; + case 0x4122: + nes_smb2j_device::update_irq(data); + break; + } } -void nes_smb2j_device::write_ex(offs_t offset, uint8_t data) +void nes_smb2j_device::write_ex(offs_t offset, u8 data) { LOG_MMC(("smb2j write_ex, offset: %04x, data: %02x\n", offset, data)); + nes_smb2j_device::write_45(offset + 0x4020, data); +} - if (offset == 2) - { - int temp; +void nes_smb2j_device::write_l(offs_t offset, u8 data) +{ + LOG_MMC(("smb2j write_l, offset: %04x, data: %02x\n", offset, data)); + nes_smb2j_device::write_45(offset + 0x4100, data); +} - // According to hardware tests - if (data & 1) - temp = 3; - else - temp = 4 + ((data & 7) >> 1); +void nes_smb2j_device::write_h(offs_t offset, u8 data) +{ + LOG_MMC(("smb2j write_h, offset: %04x, data: %02x\n", offset, data)); - prg8_cd(temp); - } + if (offset == 0x122) // $8122 is also IRQ for YS-612, mask unknown + nes_smb2j_device::update_irq(data); } -uint8_t nes_smb2j_device::read_l(offs_t offset) +u8 nes_smb2j_device::read_l(offs_t offset) { LOG_MMC(("smb2j read_l, offset: %04x\n", offset)); offset += 0x100; @@ -1233,7 +1235,7 @@ uint8_t nes_smb2j_device::read_l(offs_t offset) return get_open_bus(); // open bus } -uint8_t nes_smb2j_device::read_m(offs_t offset) +u8 nes_smb2j_device::read_m(offs_t offset) { LOG_MMC(("smb2j read_m, offset: %04x\n", offset)); return m_prg[0x4000 + offset]; @@ -1241,9 +1243,9 @@ uint8_t nes_smb2j_device::read_m(offs_t offset) /*------------------------------------------------- - BTL-SMB2A + BTL-SMB2JA - Games: Super Mario Bros. 2 Pirate (Jpn version of SMB2) + Games: Super Mario Bros. 2 Pirates (LF36, Hey Sung, 1990 SMB4) iNES: mapper 40 @@ -1257,19 +1259,16 @@ void nes_smb2ja_device::device_timer(emu_timer &timer, device_timer_id id, int p { if (m_irq_enable) { - if (m_irq_count == 0xfff) - { - hold_irq_line(); - m_irq_enable = 0; - m_irq_count = 0; - } - else - m_irq_count++; + 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, uint8_t data) +void nes_smb2ja_device::write_h(offs_t offset, u8 data) { LOG_MMC(("smb2ja write_h, offset: %04x, data: %02x\n", offset, data)); @@ -1278,6 +1277,7 @@ void nes_smb2ja_device::write_h(offs_t offset, uint8_t data) case 0x0000: m_irq_enable = 0; m_irq_count = 0; + set_irq_line(CLEAR_LINE); break; case 0x2000: m_irq_enable = 1; @@ -1288,23 +1288,23 @@ void nes_smb2ja_device::write_h(offs_t offset, uint8_t data) } } -uint8_t nes_smb2ja_device::read_m(offs_t offset) +u8 nes_smb2ja_device::read_m(offs_t offset) { LOG_MMC(("smb2ja read_m, offset: %04x\n", offset)); - return m_prg[(0xfe * 0x2000 + (offset & 0x1fff)) & (m_prg_size - 1)]; + return m_prg[0x06 * 0x2000 + offset]; // fixed 8K bank } /*------------------------------------------------- - BTL-SMB2B + BTL-SMB2JB (PCB 761214) - Games: Super Mario Bros. 2 Pirate (Jpn version of SMB2) + Games: Super Mario Bros. 2 Pirate (N-32) This was marked as Alt. Levels. is it true? iNES: mapper 50 - In MAME: Partially supported. + In MAME: Supported. -------------------------------------------------*/ @@ -1314,55 +1314,46 @@ void nes_smb2jb_device::device_timer(emu_timer &timer, device_timer_id id, int p { if (m_irq_enable) { - if (m_irq_count == 0xfff) - { - hold_irq_line(); - m_irq_enable = 0; - m_irq_count = 0; - } - else - m_irq_count++; + if (BIT(++m_irq_count, 12)) + set_irq_line(ASSERT_LINE); } } } -void nes_smb2jb_device::write_l(offs_t offset, uint8_t data) +void nes_smb2jb_device::write_45(offs_t offset, u8 data) { - uint8_t prg; - LOG_MMC(("smb2jb write_l, offset: %04x, data: %02x\n", offset, data)); - offset += 0x100; - - switch (offset & 0x1e0) + switch (offset & 0x4120) { - case 0x020: - case 0x0a0: - prg = (data & 0x08) | ((data & 0x06) >> 1) | ((data & 0x01) << 2); - prg8_cd(prg); + case 0x4020: + prg8_cd(bitswap<4>(data, 3, 0, 2, 1)); break; - case 0x120: - case 0x1a0: - m_irq_enable = data & 0x01; + case 0x4120: + m_irq_enable = BIT(data, 0); + if (!m_irq_enable) + { + set_irq_line(CLEAR_LINE); + m_irq_count = 0; + } break; } } -uint8_t nes_smb2jb_device::read_m(offs_t offset) +void nes_smb2jb_device::write_ex(offs_t offset, u8 data) { - LOG_MMC(("smb2jb read_m, offset: %04x\n", offset)); - return m_prg[((0x0f * 0x2000) + (offset & 0x1fff)) & (m_prg_size - 1)]; + LOG_MMC(("smb2jb write_ex, offset: %04x, data: %02x\n", offset, data)); + write_45(offset + 0x4020, data); } -/* This goes to 0x4020-0x403f & 0x40a0-0x40bf */ -void nes_smb2jb_device::write_ex(offs_t offset, uint8_t data) +void nes_smb2jb_device::write_l(offs_t offset, u8 data) { - uint8_t prg; - LOG_MMC(("smb2jb write_ex, offset: %04x, data: %02x\n", offset, data)); + LOG_MMC(("smb2jb write_l, offset: %04x, data: %02x\n", offset, data)); + write_45(offset + 0x4100, data); +} - if ((offset < 0x20) || (offset >= 0x80 && offset < 0xa0)) - { - prg = (data & 0x08) | ((data & 0x06) >> 1) | ((data & 0x01) << 2); - prg8_cd(prg); - } +u8 nes_smb2jb_device::read_m(offs_t offset) +{ + LOG_MMC(("smb2jb read_m, offset: %04x\n", offset)); + return m_prg[0x0f * 0x2000 + offset]; } /*------------------------------------------------- diff --git a/src/devices/bus/nes/bootleg.h b/src/devices/bus/nes/bootleg.h index a11092e1925..a53ffa6e4e6 100644 --- a/src/devices/bus/nes/bootleg.h +++ b/src/devices/bus/nes/bootleg.h @@ -168,13 +168,13 @@ class nes_smb2j_device : public nes_nrom_device { public: // construction/destruction - nes_smb2j_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_smb2j_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual uint8_t read_l(offs_t offset) override; - virtual uint8_t read_m(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 void write_h(offs_t offset, uint8_t data) override; + virtual u8 read_l(offs_t offset) override; + virtual u8 read_m(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 write_h(offs_t offset, u8 data) override; virtual void pcb_reset() override; @@ -184,7 +184,9 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; private: - uint16_t m_irq_count; + void update_irq(u8 data); + void write_45(offs_t offset, u8 data); + u16 m_irq_count; int m_irq_enable; static const device_timer_id TIMER_IRQ = 0; @@ -198,9 +200,10 @@ class nes_smb2ja_device : public nes_nrom_device { public: // construction/destruction - nes_smb2ja_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual uint8_t read_m(offs_t offset) override; - virtual void write_h(offs_t offset, uint8_t data) override; + nes_smb2ja_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + virtual u8 read_m(offs_t offset) override; + virtual void write_h(offs_t offset, u8 data) override; virtual void pcb_reset() override; @@ -210,7 +213,7 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; private: - uint16_t m_irq_count; + u16 m_irq_count; int m_irq_enable; static const device_timer_id TIMER_IRQ = 0; @@ -224,10 +227,11 @@ class nes_smb2jb_device : public nes_nrom_device { public: // construction/destruction - nes_smb2jb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual uint8_t read_m(offs_t offset) override; - virtual void write_l(offs_t offset, uint8_t data) override; - virtual void write_ex(offs_t offset, uint8_t data) override; + nes_smb2jb_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + virtual u8 read_m(offs_t offset) override; + virtual void write_l(offs_t offset, u8 data) override; + virtual void write_ex(offs_t offset, u8 data) override; virtual void pcb_reset() override; @@ -237,7 +241,8 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; private: - uint16_t m_irq_count; + void write_45(offs_t offset, u8 data); + u16 m_irq_count; int m_irq_enable; static const device_timer_id TIMER_IRQ = 0; diff --git a/src/devices/bus/nes/mmc3_clones.cpp b/src/devices/bus/nes/mmc3_clones.cpp index e9bd7de2e22..7de58b6a127 100644 --- a/src/devices/bus/nes/mmc3_clones.cpp +++ b/src/devices/bus/nes/mmc3_clones.cpp @@ -53,6 +53,10 @@ DEFINE_DEVICE_TYPE(NES_SACHEN_SHERO, nes_sachen_shero_device, "nes_shero", DEFINE_DEVICE_TYPE(NES_FCGJ8IN1, nes_fcgj8in1_device, "nes_fcgj8in1", "NES Cart BMC FC Genjin 8 in 1 PCB") DEFINE_DEVICE_TYPE(NES_FK23C, nes_fk23c_device, "nes_fk23c", "NES Cart FK23C PCB") DEFINE_DEVICE_TYPE(NES_FK23CA, nes_fk23ca_device, "nes_fk23ca", "NES Cart FK23CA PCB") +DEFINE_DEVICE_TYPE(NES_NT639, nes_nt639_device, "nes_nt639", "NES Cart NT-639 PCB") +DEFINE_DEVICE_TYPE(NES_RESETTXROM0, nes_resettxrom0_device, "nes_resettxrom0", "NES Cart BMC RESET-TXROM 128K/128K PCB") +DEFINE_DEVICE_TYPE(NES_RESETTXROM1, nes_resettxrom1_device, "nes_resettxrom1", "NES Cart BMC RESET-TXROM 256K/128K PCB") +DEFINE_DEVICE_TYPE(NES_RESETTXROM2, nes_resettxrom2_device, "nes_resettxrom2", "NES Cart BMC RESET-TXROM 128K/256K PCB") DEFINE_DEVICE_TYPE(NES_S24IN1SC03, nes_s24in1sc03_device, "nes_s24in1c03", "NES Cart Super 24 in 1 SC-03 PCB") DEFINE_DEVICE_TYPE(NES_BMC_8IN1, nes_bmc_8in1_device, "nes_bmc_8in1", "NES Cart BMC GRM070 8 in 1 PCB") DEFINE_DEVICE_TYPE(NES_BMC_15IN1, nes_bmc_15in1_device, "nes_bmc_15in1", "NES Cart BMC 15 in 1 PCB") @@ -108,13 +112,33 @@ nes_8237_device::nes_8237_device(const machine_config &mconfig, const char *tag, { } -nes_sglionk_device::nes_sglionk_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_txrom_device(mconfig, NES_SG_LIONK, tag, owner, clock), m_reg(0), m_reg_enabled(0) +nes_sglionk_device::nes_sglionk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, const u8 *reg_table, const u16 *addr_table) + : nes_txrom_device(mconfig, type, tag, owner, clock) + , m_mmc3_mode(true) + , m_reg_table(reg_table) + , m_addr_table(addr_table) { } -nes_sgboog_device::nes_sgboog_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_txrom_device(mconfig, NES_SG_BOOG, tag, owner, clock), m_mode(0) +nes_sglionk_device::nes_sglionk_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_sglionk_device(mconfig, + NES_SG_LIONK, + tag, + owner, + clock, + (const u8 []) {0, 3, 1, 5, 6, 7, 2, 4}, + (const u16 []) {0xa001, 0xa000, 0x8000, 0xc000, 0x8001, 0xc001, 0xe000, 0xe001}) +{ +} + +nes_sgboog_device::nes_sgboog_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_sglionk_device(mconfig, + NES_SG_BOOG, + tag, + owner, + clock, + (const u8 []) {0, 2, 5, 3, 6, 1, 7, 4}, + (const u16 []) {0xa001, 0x8001, 0x8000, 0xc001, 0xa000, 0xc000, 0xe000, 0xe001}) { } @@ -198,6 +222,31 @@ nes_fk23ca_device::nes_fk23ca_device(const machine_config &mconfig, const char * { } +nes_nt639_device::nes_nt639_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_txrom_device(mconfig, NES_NT639, tag, owner, clock) +{ +} + +nes_resettxrom0_device::nes_resettxrom0_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int prg_shift, int chr_shift) + : nes_txrom_device(mconfig, type, tag, owner, clock), m_count(-1), m_prg_shift(prg_shift), m_chr_shift(chr_shift) +{ +} + +nes_resettxrom0_device::nes_resettxrom0_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_resettxrom0_device(mconfig, NES_RESETTXROM0, tag, owner, clock, 4, 7) +{ +} + +nes_resettxrom1_device::nes_resettxrom1_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_resettxrom0_device(mconfig, NES_RESETTXROM1, tag, owner, clock, 5, 7) +{ +} + +nes_resettxrom2_device::nes_resettxrom2_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_resettxrom0_device(mconfig, NES_RESETTXROM2, tag, owner, clock, 4, 8) +{ +} + nes_s24in1sc03_device::nes_s24in1sc03_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : nes_txrom_device(mconfig, NES_S24IN1SC03, tag, owner, clock) { @@ -332,18 +381,18 @@ void nes_8237_device::pcb_reset() void nes_sglionk_device::device_start() { mmc3_start(); - save_item(NAME(m_reg)); - save_item(NAME(m_reg_enabled)); + save_item(NAME(m_mmc3_mode)); } void nes_sglionk_device::pcb_reset() { m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - m_reg = m_reg_enabled = 0; + m_mmc3_mode = true; mmc3_common_initialize(0xff, 0xff, 0); } +/* void nes_sgboog_device::device_start() { mmc3_start(); @@ -363,6 +412,7 @@ void nes_sgboog_device::pcb_reset() set_prg(m_prg_base, m_prg_mask); set_chr(m_chr_source, m_chr_base, m_chr_mask); } +*/ void nes_kasing_device::device_start() { @@ -520,6 +570,31 @@ void nes_fk23ca_device::pcb_reset() fk23c_set_chr(); } +void nes_nt639_device::pcb_reset() +{ + m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; + mmc3_common_initialize(0x0f, 0xff, 0); +} + +// These reset-based PCBs are emulated here with no additional handlers +void nes_resettxrom0_device::device_start() +{ + mmc3_start(); + save_item(NAME(m_count)); +} + +void nes_resettxrom0_device::pcb_reset() +{ + m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; + mmc3_common_initialize((1 << m_prg_shift) - 1, (1 << m_chr_shift) - 1, 0); + + m_count = (m_count + 1) & 3; + m_prg_base = m_count << m_prg_shift; + m_chr_base = m_count << m_chr_shift; + set_prg(m_prg_base, m_prg_mask); + set_chr(m_chr_source, m_chr_base, m_chr_mask); +} + void nes_s24in1sc03_device::device_start() { mmc3_start(); @@ -996,89 +1071,78 @@ void nes_8237_device::write_h(offs_t offset, uint8_t data) Bootleg Board by Super Game - Games: The Lion King + Games: The Lion King, Aladdin, Boogerman - MMC3 clone. + MMC3 clone with register and address scrambling and + a few extra banking modes by writing 0x6000-0x7fff. iNES: mapper 114 - In MESS: Supported. + In MAME: Supported. + + TODO: pocohon and sdkong should also work on this device. -------------------------------------------------*/ -void nes_sglionk_device::write_m(offs_t offset, uint8_t data) +void nes_sglionk_device::prg_cb(int start, int bank) { - LOG_MMC(("sglionk write_m, offset: %04x, data: %02x\n", offset, data)); - - m_reg = data; - - if (m_reg & 0x80) - { - prg16_89ab(data & 0x1f); - prg16_cdef(data & 0x1f); - } - else - set_prg(m_prg_base, m_prg_mask); - + if (m_mmc3_mode) + nes_txrom_device::prg_cb(start, bank); } -void nes_sglionk_device::write_h(offs_t offset, uint8_t data) +void nes_sglionk_device::write_m(offs_t offset, u8 data) { - static const uint8_t conv_table[8] = {0, 3, 1, 5, 6, 7, 2, 4}; - LOG_MMC(("sglionk write_h, offset: %04x, data: %02x\n", offset, data)); + LOG_MMC(("sglionk write_m, offset: %04x, data: %02x\n", offset, data)); - if (offset < 0x6000) + if (BIT(offset, 0)) { - switch (offset & 0x6000) - { - case 0x0000: - set_nt_mirroring(BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); - break; - case 0x2000: - m_reg_enabled = 1; - data = (data & 0xc0) | conv_table[data & 0x07]; - txrom_write(0x0000, data); - break; - case 0x4000: - if (m_reg_enabled && (m_reg & 0x80) == 0) - { - m_reg_enabled = 0; - txrom_write(0x0001, data); - } - break; - } + m_chr_base = BIT(data, 0) << 8; + set_chr(m_chr_source, m_chr_base, m_chr_mask); } else { - switch (offset & 0x03) + m_mmc3_mode = !BIT(data, 7); + if (m_mmc3_mode) + set_prg(m_prg_base, m_prg_mask); + else { - case 0x02: - txrom_write(0x6000, data); - break; - case 0x03: - txrom_write(0x6001, data); - txrom_write(0x4000, data); - txrom_write(0x4001, data); - break; + u8 bank = data & 0x0f; + u8 mode = BIT(data, 5); + prg16_89ab(bank & ~mode); + prg16_cdef(bank | mode); } } } +void nes_sglionk_device::write_h(offs_t offset, u8 data) +{ + LOG_MMC(("sglionk write_h, offset: %04x, data: %02x\n", offset, data)); + + u16 addr = m_addr_table[bitswap<3>(offset, 14, 13, 0)]; + if (addr == 0x8000) + data = (data & 0xc0) | m_reg_table[data & 0x07]; + txrom_write(addr & 0x6001, data); +} + /*------------------------------------------------- Bootleg Board by Super Game - Games: Boogerman, Mortal Kombat III + Games: Mortal Kombat III - MMC3 clone. Also, it probably needs a hack to support both - variants (Boogerman & MK3). + MMC3 clone. iNES: mapper 215 In MESS: Preliminary support. - -------------------------------------------------*/ + FIXME: Set "booger" has moved to sglionk's mapper 114 implementation. We have + three competing implementations left for mapper 215: 8237_device, gc6in1, and + this commented out sgboog, plus unimplemented 8237a is a similar variant. None + of them work for all the mapper 215 games (old sgboog games never worked!) + -------------------------------------------------*/ +/* void nes_sgboog_device::prg_cb(int start, int bank) { if (!(m_reg[0] & 0x80)) // if this is != 0 we should never even arrive here @@ -1215,6 +1279,7 @@ void nes_sgboog_device::write_h(offs_t offset, uint8_t data) else txrom_write(offset, data); } +*/ /*------------------------------------------------- @@ -2044,6 +2109,35 @@ void nes_fk23c_device::write_h(offs_t offset, uint8_t data) /*------------------------------------------------- + BMC-NT-639 + + Unknown Bootleg Multigame Board + Games: 2 in 1 Mortal Kombat VI/VII + + NES 2.0: mapper 291 + + In MAME: Supported. + + -------------------------------------------------*/ + +void nes_nt639_device::write_m(offs_t offset, u8 data) +{ + LOG_MMC(("nt639 write_m, offset: %04x, data: %02x\n", offset, data)); + + if (BIT(data, 5)) + prg32(bitswap<3>(data, 6, 2, 1)); + else + { + m_prg_base = (data & 0x40) >> 2; + set_prg(m_prg_base, m_prg_mask); + } + + m_chr_base = (data & 0x40) << 2; + set_chr(m_chr_source, m_chr_base, m_chr_mask); +} + +/*------------------------------------------------- + Board BMC-SUPER24IN1SC03 Games: Super 24-in-1 diff --git a/src/devices/bus/nes/mmc3_clones.h b/src/devices/bus/nes/mmc3_clones.h index 65ae5ede1ec..6f71cd90295 100644 --- a/src/devices/bus/nes/mmc3_clones.h +++ b/src/devices/bus/nes/mmc3_clones.h @@ -129,25 +129,41 @@ class nes_sglionk_device : public nes_txrom_device { public: // construction/destruction - nes_sglionk_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_sglionk_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 prg_cb(int start, int bank) override; virtual void pcb_reset() override; protected: + // construction/destruction + nes_sglionk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, const u8 *reg_table, const u16 *addr_table); + // device-level overrides virtual void device_start() override; private: - uint8_t m_reg; - int m_reg_enabled; + bool m_mmc3_mode; + const u8 *m_reg_table; + const u16 *m_addr_table; }; // ======================> nes_sgboog_device +class nes_sgboog_device : public nes_sglionk_device +{ +public: + // construction/destruction + nes_sgboog_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); +}; + + +/* +// ======================> nes_sgboog_device + class nes_sgboog_device : public nes_txrom_device { public: @@ -171,6 +187,7 @@ private: uint8_t m_reg[3]; uint8_t m_mode; }; +*/ // ======================> nes_kasing_device @@ -487,6 +504,63 @@ public: }; +// ======================> nes_nt639_device + +class nes_nt639_device : public nes_txrom_device +{ +public: + // construction/destruction + nes_nt639_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + virtual void write_m(offs_t offset, u8 data) override; + + virtual void pcb_reset() override; +}; + + +// ======================> nes_resettxrom0_device + +class nes_resettxrom0_device : public nes_txrom_device +{ +public: + // construction/destruction + nes_resettxrom0_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + virtual void pcb_reset() override; + +protected: + // construction/destruction + nes_resettxrom0_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int prg_shift, int chr_shift); + + // device-level overrides + virtual void device_start() override; + +private: + int m_count; + int m_prg_shift, m_chr_shift; +}; + + +// ======================> nes_resettxrom1_device + +class nes_resettxrom1_device : public nes_resettxrom0_device +{ +public: + // construction/destruction + nes_resettxrom1_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); +}; + + +// ======================> nes_resettxrom2_device + +class nes_resettxrom2_device : public nes_resettxrom0_device +{ +public: + // construction/destruction + nes_resettxrom2_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); +}; + + // ======================> nes_s24in1sc03_device class nes_s24in1sc03_device : public nes_txrom_device @@ -849,6 +923,10 @@ DECLARE_DEVICE_TYPE(NES_A9746, nes_a9746_device) DECLARE_DEVICE_TYPE(NES_FCGJ8IN1, nes_fcgj8in1_device) DECLARE_DEVICE_TYPE(NES_FK23C, nes_fk23c_device) DECLARE_DEVICE_TYPE(NES_FK23CA, nes_fk23ca_device) +DECLARE_DEVICE_TYPE(NES_NT639, nes_nt639_device) +DECLARE_DEVICE_TYPE(NES_RESETTXROM0, nes_resettxrom0_device) +DECLARE_DEVICE_TYPE(NES_RESETTXROM1, nes_resettxrom1_device) +DECLARE_DEVICE_TYPE(NES_RESETTXROM2, nes_resettxrom2_device) DECLARE_DEVICE_TYPE(NES_S24IN1SC03, nes_s24in1sc03_device) DECLARE_DEVICE_TYPE(NES_BMC_8IN1, nes_bmc_8in1_device) DECLARE_DEVICE_TYPE(NES_BMC_15IN1, nes_bmc_15in1_device) diff --git a/src/devices/bus/nes/multigame.cpp b/src/devices/bus/nes/multigame.cpp index 5cd84e0034a..c0771641b1b 100644 --- a/src/devices/bus/nes/multigame.cpp +++ b/src/devices/bus/nes/multigame.cpp @@ -53,6 +53,7 @@ DEFINE_DEVICE_TYPE(NES_BMC_GB63, nes_bmc_gb63_device, "nes_bmc_gb63" DEFINE_DEVICE_TYPE(NES_BMC_GKA, nes_bmc_gka_device, "nes_bmc_gka", "NES Cart BMC GK-A PCB") DEFINE_DEVICE_TYPE(NES_BMC_GKB, nes_bmc_gkb_device, "nes_bmc_gkb", "NES Cart BMC GK-B PCB") DEFINE_DEVICE_TYPE(NES_BMC_GKCXIN1, nes_bmc_gkcxin1_device, "nes_bmc_gkcxin1", "NES Cart BMC GKCXIN1 PCB") +DEFINE_DEVICE_TYPE(NES_BMC_K1029, nes_bmc_k1029_device, "nes_bmc_k1029", "NES Cart BMC K-1029 PCB") DEFINE_DEVICE_TYPE(NES_BMC_K3036, nes_bmc_k3036_device, "nes_bmc_k3036", "NES Cart BMC K-3036 PCB") DEFINE_DEVICE_TYPE(NES_BMC_K3046, nes_bmc_k3046_device, "nes_bmc_k3046", "NES Cart BMC K-3046 PCB") DEFINE_DEVICE_TYPE(NES_BMC_SA005A, nes_bmc_sa005a_device, "nes_bmc_sa005a", "NES Cart BMC SA005-A PCB") @@ -77,7 +78,6 @@ DEFINE_DEVICE_TYPE(NES_BMC_64IN1, nes_bmc_64in1_device, "nes_bmc_64in1 DEFINE_DEVICE_TYPE(NES_BMC_70IN1, nes_bmc_70in1_device, "nes_bmc_70in1", "NES Cart BMC 70 in 1 PCB") DEFINE_DEVICE_TYPE(NES_BMC_72IN1, nes_bmc_72in1_device, "nes_bmc_72in1", "NES Cart BMC 72 in 1 PCB") DEFINE_DEVICE_TYPE(NES_BMC_76IN1, nes_bmc_76in1_device, "nes_bmc_76in1", "NES Cart BMC 76 in 1 PCB") -DEFINE_DEVICE_TYPE(NES_BMC_110IN1, nes_bmc_110in1_device, "nes_bmc_110in1", "NES Cart BMC 110 in 1 PCB") DEFINE_DEVICE_TYPE(NES_BMC_150IN1, nes_bmc_150in1_device, "nes_bmc_150in1", "NES Cart BMC 150 in 1 PCB") DEFINE_DEVICE_TYPE(NES_BMC_190IN1, nes_bmc_190in1_device, "nes_bmc_190in1", "NES Cart BMC 190 in 1 PCB") DEFINE_DEVICE_TYPE(NES_BMC_500IN1, nes_bmc_500in1_device, "nes_bmc_500in1", "NES Cart BMC 500 in 1 PCB") @@ -357,7 +357,7 @@ nes_bmc_70in1_device::nes_bmc_70in1_device(const machine_config &mconfig, const { } -nes_bmc_72in1_device::nes_bmc_72in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_bmc_72in1_device::nes_bmc_72in1_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_BMC_72IN1, tag, owner, clock) { } @@ -367,11 +367,6 @@ nes_bmc_76in1_device::nes_bmc_76in1_device(const machine_config &mconfig, const { } -nes_bmc_110in1_device::nes_bmc_110in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_nrom_device(mconfig, NES_BMC_110IN1, tag, owner, clock) -{ -} - nes_bmc_150in1_device::nes_bmc_150in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : nes_nrom_device(mconfig, NES_BMC_150IN1, tag, owner, clock) { @@ -432,6 +427,11 @@ nes_bmc_60311c_device::nes_bmc_60311c_device(const machine_config &mconfig, cons { } +nes_bmc_k1029_device::nes_bmc_k1029_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_vram_protect_device(mconfig, NES_BMC_K1029, tag, owner, clock) +{ +} + nes_bmc_th22913_device::nes_bmc_th22913_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_vram_protect_device(mconfig, NES_BMC_TH22913, tag, owner, clock) { @@ -1013,13 +1013,7 @@ void nes_bmc_70in1_device::pcb_reset() void nes_bmc_72in1_device::device_start() { common_start(); -} - -void nes_bmc_72in1_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg32(0); - chr8(0, m_chr_source); + save_item(NAME(m_extra_ram)); } void nes_bmc_76in1_device::device_start() @@ -1036,20 +1030,6 @@ void nes_bmc_76in1_device::pcb_reset() m_reg[0] = m_reg[1] = 0; } -void nes_bmc_110in1_device::device_start() -{ - common_start(); -} - -void nes_bmc_110in1_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg16_89ab(0); - prg16_cdef(1); - chr8(0, m_chr_source); - set_nt_mirroring(PPU_MIRROR_VERT); -} - void nes_bmc_150in1_device::device_start() { common_start(); @@ -1181,6 +1161,7 @@ void nes_vram_protect_device::device_start() void nes_vram_protect_device::pcb_reset() { + prg32(0); chr8(0, CHRRAM); m_vram_protect = false; } @@ -2662,38 +2643,49 @@ uint8_t nes_bmc_70in1_device::read_h(offs_t offset) /*------------------------------------------------- - BMC-72IN1 + BMC-72IN1, BMC-110IN1 Unknown Bootleg Multigame Board Games: 72 in 1, 115 in 1 and other multigame carts - iNES: mapper 225 + iNES: mappers 225, 255 - In MESS: Supported. + In MAME: Supported. -------------------------------------------------*/ -void nes_bmc_72in1_device::write_h(offs_t offset, uint8_t data) +u8 nes_bmc_72in1_device::read_l(offs_t offset) { - int hi_bank = offset & 0x40; - int size_16 = offset & 0x1000; - int bank = (offset & 0xf80) >> 7; + LOG_MMC(("bmc_72in1 read_l, offset: %04x\n", offset)); + + offset += 0x100; + if (offset >= 0x1800) // 4 nibbles of RAM mirrored above 0x5800 + return m_extra_ram[offset & 0x03]; + + return get_open_bus(); +} + +void nes_bmc_72in1_device::write_l(offs_t offset, u8 data) +{ + LOG_MMC(("bmc_72in1 write_l, offset: %04x, data: %02x\n", offset, data)); + + offset += 0x100; + if (offset >= 0x1800) // 4 nibbles of RAM mirrored above 0x5800 + m_extra_ram[offset & 0x03] = data & 0x0f; +} +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)); - chr8(offset, CHRROM); - set_nt_mirroring((offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); - if (size_16) - { - bank <<= 1; - if (hi_bank) - bank ++; + u8 high = (offset >> 8) & 0x40; + u8 bank = high | ((offset >> 6) & 0x3f); + u8 mode = !BIT(offset, 12); + prg16_89ab(bank & ~mode); + prg16_cdef(bank | mode); - prg16_89ab(bank); - prg16_cdef(bank); - } - else - prg32(bank); + chr8(high | (offset & 0x3f), CHRROM); + set_nt_mirroring(BIT(offset, 13) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); } /*------------------------------------------------- @@ -2724,33 +2716,6 @@ void nes_bmc_76in1_device::write_h(offs_t offset, u8 data) /*------------------------------------------------- - BMC-110IN1 - - Known Boards: Unknown Bootleg Board - Games: 110 in 1 - - iNES: mapper 255 - - In MESS: Preliminary support. - - -------------------------------------------------*/ - -void nes_bmc_110in1_device::write_h(offs_t offset, uint8_t data) -{ - uint8_t helper1 = (offset >> 12) ? 0 : 1; - uint8_t helper2 = ((offset >> 8) & 0x40) | ((offset >> 6) & 0x3f); - - LOG_MMC(("bmc_110in1 write_h, offset: %04x, data: %02x\n", offset, data)); - - set_nt_mirroring((offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); - prg16_89ab(helper1 & ~helper2); - prg16_cdef(helper1 | helper2); - chr8(((offset >> 8) & 0x40) | (offset & 0x3f), CHRROM); -} - - -/*------------------------------------------------- - BMC-150IN1 Unknown Bootleg Multigame Board @@ -3127,8 +3092,8 @@ void nes_bmc_60311c_device::update_banks() prg16_cdef(m_reg[1] | BIT(m_reg[0], 0)); } - m_vram_protect = BIT(m_reg[0], 2); set_nt_mirroring(BIT(m_reg[0], 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); + m_vram_protect = BIT(m_reg[0], 2); } void nes_bmc_60311c_device::write_m(offs_t offset, u8 data) @@ -3147,6 +3112,53 @@ void nes_bmc_60311c_device::write_h(offs_t offset, u8 data) /*------------------------------------------------- + BMC-K-1029 + + Games: 100 in 1 Contra Function 16, 168 in 1 + + iNES: mapper 15 + + In MAME: Supported. + + TODO: Contra games in 100-in-1 endlessly loop the + second level played regardless of starting level. + BTANB? Bad dump? FCEUX exhibits the same behavior. + + -------------------------------------------------*/ + +void nes_bmc_k1029_device::write_h(offs_t offset, u8 data) +{ + LOG_MMC(("bmc_k1029 write_h, offset: %04x, data: %02x\n", offset, data)); + + u8 bank = data & 0x3f; + switch (offset & 3) + { + case 0: + prg32(bank >> 1); + break; + case 1: + prg16_89ab(bank); + prg16_cdef(bank | 0x07); + break; + case 2: + bank = bank << 1 | BIT(data, 7); + prg8_89(bank); + prg8_ab(bank); + prg8_cd(bank); + prg8_ef(bank); + break; + case 3: + prg16_89ab(bank); + prg16_cdef(bank); + break; + } + + set_nt_mirroring(BIT(data, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); + m_vram_protect = BIT(offset, 0) == BIT(offset, 1); +} + +/*------------------------------------------------- + BMC-TH2291-3, BMC-CH-011 Games: Powerful 250 in 1, Powerful 255 in 1 diff --git a/src/devices/bus/nes/multigame.h b/src/devices/bus/nes/multigame.h index 32d3c1f3d21..63728ea60dc 100644 --- a/src/devices/bus/nes/multigame.h +++ b/src/devices/bus/nes/multigame.h @@ -887,15 +887,20 @@ class nes_bmc_72in1_device : public nes_nrom_device { public: // construction/destruction - nes_bmc_72in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_bmc_72in1_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 u8 read_l(offs_t offset) override; + virtual void write_l(offs_t offset, u8 data) override; + virtual void write_h(offs_t offset, u8 data) override; - virtual void pcb_reset() override; +// virtual void pcb_reset() override; protected: // device-level overrides virtual void device_start() override; + +private: + u8 m_extra_ram[4]; }; @@ -920,24 +925,6 @@ private: }; -// ======================> nes_bmc_110in1_device - -class nes_bmc_110in1_device : public nes_nrom_device -{ -public: - // construction/destruction - nes_bmc_110in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t 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; -}; - - // ======================> nes_bmc_150in1_device class nes_bmc_150in1_device : public nes_nrom_device @@ -1167,6 +1154,18 @@ private: }; +// ======================> nes_bmc_k1029_device + +class nes_bmc_k1029_device : public nes_vram_protect_device +{ +public: + // construction/destruction + nes_bmc_k1029_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + virtual void write_h(offs_t offset, u8 data) override; +}; + + // ======================> nes_bmc_th22913_device class nes_bmc_th22913_device : public nes_vram_protect_device @@ -1207,6 +1206,7 @@ DECLARE_DEVICE_TYPE(NES_BMC_GB63, nes_bmc_gb63_device) DECLARE_DEVICE_TYPE(NES_BMC_GKA, nes_bmc_gka_device) DECLARE_DEVICE_TYPE(NES_BMC_GKB, nes_bmc_gkb_device) DECLARE_DEVICE_TYPE(NES_BMC_GKCXIN1, nes_bmc_gkcxin1_device) +DECLARE_DEVICE_TYPE(NES_BMC_K1029, nes_bmc_k1029_device) DECLARE_DEVICE_TYPE(NES_BMC_K3036, nes_bmc_k3036_device) DECLARE_DEVICE_TYPE(NES_BMC_K3046, nes_bmc_k3046_device) DECLARE_DEVICE_TYPE(NES_BMC_SA005A, nes_bmc_sa005a_device) @@ -1231,7 +1231,6 @@ DECLARE_DEVICE_TYPE(NES_BMC_64IN1, nes_bmc_64in1_device) DECLARE_DEVICE_TYPE(NES_BMC_70IN1, nes_bmc_70in1_device) DECLARE_DEVICE_TYPE(NES_BMC_72IN1, nes_bmc_72in1_device) DECLARE_DEVICE_TYPE(NES_BMC_76IN1, nes_bmc_76in1_device) -DECLARE_DEVICE_TYPE(NES_BMC_110IN1, nes_bmc_110in1_device) DECLARE_DEVICE_TYPE(NES_BMC_150IN1, nes_bmc_150in1_device) DECLARE_DEVICE_TYPE(NES_BMC_190IN1, nes_bmc_190in1_device) DECLARE_DEVICE_TYPE(NES_BMC_500IN1, nes_bmc_500in1_device) diff --git a/src/devices/bus/nes/nes_carts.cpp b/src/devices/bus/nes/nes_carts.cpp index 0c969ebff85..ae3cb766378 100644 --- a/src/devices/bus/nes/nes_carts.cpp +++ b/src/devices/bus/nes/nes_carts.cpp @@ -379,6 +379,7 @@ void nes_cart(device_slot_interface &device) device.option_add_internal("bmc_gka", NES_BMC_GKA); device.option_add_internal("bmc_gkb", NES_BMC_GKB); device.option_add_internal("bmc_gkcxin1", NES_BMC_GKCXIN1); + device.option_add_internal("bmc_k1029", NES_BMC_K1029); device.option_add_internal("bmc_k3006", NES_BMC_K3006); device.option_add_internal("bmc_k3036", NES_BMC_K3036); device.option_add_internal("bmc_k3046", NES_BMC_K3046); @@ -405,7 +406,6 @@ void nes_cart(device_slot_interface &device) device.option_add_internal("bmc_72in1", NES_BMC_72IN1); device.option_add_internal("bmc_76in1", NES_BMC_76IN1); device.option_add_internal("bmc_s42in1", NES_BMC_76IN1); - device.option_add_internal("bmc_110in1", NES_BMC_110IN1); device.option_add_internal("bmc_150in1", NES_BMC_150IN1); device.option_add_internal("bmc_190in1", NES_BMC_190IN1); device.option_add_internal("bmc_500in1", NES_BMC_500IN1); @@ -422,6 +422,10 @@ void nes_cart(device_slot_interface &device) device.option_add_internal("fcgj8in1", NES_FCGJ8IN1); device.option_add_internal("fk23c", NES_FK23C); device.option_add_internal("fk23ca", NES_FK23CA); + device.option_add_internal("nt639", NES_NT639); + device.option_add_internal("resettxrom0", NES_RESETTXROM0); + device.option_add_internal("resettxrom1", NES_RESETTXROM1); + device.option_add_internal("resettxrom2", NES_RESETTXROM2); device.option_add_internal("s24in1c03", NES_S24IN1SC03); device.option_add_internal("bmc_8in1", NES_BMC_8IN1); device.option_add_internal("bmc_15in1", NES_BMC_15IN1); diff --git a/src/devices/bus/nes/nes_ines.hxx b/src/devices/bus/nes/nes_ines.hxx index 5c89eed246b..e76002bbcf6 100644 --- a/src/devices/bus/nes/nes_ines.hxx +++ b/src/devices/bus/nes/nes_ines.hxx @@ -47,7 +47,7 @@ static const nes_mmc mmc_list[] = { 12, REXSOFT_DBZ5 }, { 13, STD_CPROM }, { 14, REXSOFT_SL1632 }, - { 15, WAIXING_WXZS2 }, + { 15, BMC_K1029 }, { 16, BANDAI_LZ93EX2 }, // with 24c02 { 17, FFE8_BOARD }, { 18, JALECO_SS88006 }, @@ -288,7 +288,7 @@ static const nes_mmc mmc_list[] = { 252, WAIXING_SGZ }, // 253 Super 8-in-1 99 King Fighter?? - Unsupported { 254, BTL_PIKACHUY2K }, - { 255, BMC_110IN1 }, + { 255, BMC_72IN1 }, // NES 2.0 // 256 OneBus Famiclones @@ -318,7 +318,7 @@ static const nes_mmc mmc_list[] = // 280 Unused // 281 seems to be mc_sh4b and many other JY multicarts not in nes.xml? // 282 more JY multicarts not in nes.xml? - // 283 RCM_GS2004 and RCM_GS2013 (why are these RCM?), these are in nes.xml + { 283, RCM_GS2004 }, // and RCM_GS2013 // 284 UNL_DRIPGAME, not in nes.xml { 285, BMC_A65AS }, { 286, BMC_BENSHIENG }, @@ -326,7 +326,7 @@ static const nes_mmc mmc_list[] = { 288, BMC_GKCXIN1 }, { 289, BMC_60311C }, { 290, BMC_NTD_03 }, - // 291 Kasheng 2-in-1 multicarts not yet in nes.xml? + { 291, BMC_NT639 }, // { 292, UNL_DRAGONFIGHTER }, in nes.xml, not emulated yet // 293 NewStar multicarts, do we have these in nes.xml? // 294 variant of mapper 134? @@ -348,7 +348,7 @@ static const nes_mmc mmc_list[] = // 310 variant of mapper 125? // 311 Unused (previously assigned in error to a bad SMB2 pirate dump) { 312, KAISER_KS7013B }, // Highway Star FDS conversion - // { 313, BMC_RESETTXROM }, various multicarts, not in nes.xml? + { 313, BMC_RESETTXROM0 }, { 314, BMC_64IN1NR }, // 315 820732C and 830134C multicarts, not in nes.xml? // 316 Unused @@ -513,7 +513,7 @@ static const nes_mmc mmc_list[] = // 550 JY-015 multicart // 551 variant of mapper 178, likely shenghuo, jingkzx, xiaokecq, zgfyun in nes.xml // 552 TAITO_X1_017, this is a correction of mapper 82. We should drop 82 and only support the accurate dumps of 552? - // { 553, SACHEN_3013 }, // Dong Dong Nao 1 + { 553, SACHEN_3013 }, // Dong Dong Nao 1 { 554, KAISER_KS7010 }, // Akumajo Dracula FDS conversion // 555 retroUSB re-release of 1991 Nintendo Campus Challenge // 556 JY-215 multicart @@ -896,6 +896,20 @@ void nes_cart_slot_device::call_load_ines() m_pcb_id = UNL_DH08; break; + case RCM_GS2004: + if (prg_size >= 0x50000) + m_pcb_id = RCM_GS2013; + break; + + case BMC_RESETTXROM0: + if (submapper == 1) + m_pcb_id = BMC_RESETTXROM1; + else if (submapper == 2) + m_pcb_id = BMC_RESETTXROM2; + else if (submapper > 2) + logerror("Unimplemented NES 2.0 submapper: %d\n", submapper); + break; + case HES_BOARD: if (crc_hack) m_cart->set_pcb_ctrl_mirror(true); // Mapper 113 is used for 2 diff boards @@ -1207,6 +1221,7 @@ const char * nes_cart_slot_device::get_default_card_ines(get_default_card_softwa if (crc_hack) pcb_id = BTL_AISENSHINICOL; // Mapper 42 is used for 2 diff boards break; + case UNL_LH28_LH54: // Mapper 108 is used for 4 diff boards if (ROM[5]) pcb_id = (ROM[5] == 2) ? UNL_LE05 : UNL_LH31; @@ -1214,6 +1229,17 @@ const char * nes_cart_slot_device::get_default_card_ines(get_default_card_softwa pcb_id = UNL_DH08; break; + case RCM_GS2004: // Mapper 283 is used for 2 diff boards + if (ROM[4] >= 20) + pcb_id = RCM_GS2013; + break; + + case BMC_RESETTXROM0: // Mapper 313 is used for 3 diff boards + if (submapper == 1) + pcb_id = BMC_RESETTXROM1; + if (submapper == 2) + pcb_id = BMC_RESETTXROM2; + break; } return nes_get_slot(pcb_id); diff --git a/src/devices/bus/nes/nes_pcb.hxx b/src/devices/bus/nes/nes_pcb.hxx index a4fb1ac8f60..c70f93fca04 100644 --- a/src/devices/bus/nes/nes_pcb.hxx +++ b/src/devices/bus/nes/nes_pcb.hxx @@ -264,6 +264,7 @@ static const nes_pcb pcb_list[] = { "bmc_gka", BMC_GKA }, { "bmc_gkb", BMC_GKB }, { "bmc_gkcxin1", BMC_GKCXIN1 }, + { "bmc_k1029", BMC_K1029 }, { "bmc_k3006", BMC_K3006 }, { "bmc_k3036", BMC_K3036 }, { "bmc_k3046", BMC_K3046 }, @@ -286,7 +287,6 @@ static const nes_pcb pcb_list[] = { "bmc_72in1", BMC_72IN1 }, { "bmc_76in1", BMC_76IN1 }, { "bmc_s42in1", BMC_76IN1 }, - { "bmc_110in1", BMC_110IN1 }, { "bmc_150in1", BMC_150IN1 }, { "bmc_190in1", BMC_190IN1 }, { "bmc_500in1", BMC_500IN1 }, @@ -299,6 +299,10 @@ static const nes_pcb pcb_list[] = { "fcgj8in1", BMC_FCGENJIN_8IN1 }, { "fk23c", BMC_FK23C }, { "fk23ca", BMC_FK23CA }, + { "nt639", BMC_NT639 }, + { "resettxrom0", BMC_RESETTXROM0 }, + { "resettxrom1", BMC_RESETTXROM1 }, + { "resettxrom2", BMC_RESETTXROM2 }, { "s24in1c03", BMC_S24IN1SC03 }, { "bmc_8in1", BMC_8IN1 }, { "bmc_15in1", BMC_15IN1 }, diff --git a/src/devices/bus/nes/nes_slot.h b/src/devices/bus/nes/nes_slot.h index 91f820365c4..c18e4153b22 100644 --- a/src/devices/bus/nes/nes_slot.h +++ b/src/devices/bus/nes/nes_slot.h @@ -93,16 +93,17 @@ enum BMC_36IN1, BMC_21IN1, BMC_150IN1, BMC_35IN1, BMC_64IN1, BMC_8IN1, BMC_15IN1, BMC_SUPERHIK_300IN1, BMC_SUPERGUN_20IN1, BMC_GOLDENCARD_6IN1, BMC_72IN1, BMC_SUPER_42IN1, BMC_76IN1, - BMC_31IN1, BMC_22GAMES, BMC_20IN1, BMC_110IN1, + BMC_31IN1, BMC_22GAMES, BMC_20IN1, BMC_70IN1, BMC_500IN1, BMC_800IN1, BMC_1200IN1, BMC_GKA, BMC_GKB, BMC_GKCXIN1, BMC_VT5201, BMC_BENSHIENG, BMC_60311C, BMC_80013B, BMC_810544C, BMC_830425C, BMC_850437C, - BMC_NTD_03, BMC_G63IN1, BMC_FCGENJIN_8IN1, BMC_FK23C, BMC_FK23CA, + BMC_NT639, BMC_NTD_03, BMC_G63IN1, BMC_FCGENJIN_8IN1, BMC_FK23C, BMC_FK23CA, BMC_PJOY84, BMC_TH22913, BMC_11160, BMC_G146, BMC_2751, BMC_8157, BMC_830118C, BMC_830832C, BMC_841101C, BMC_411120C, BMC_GOLD150, BMC_GOLD260, BMC_SUPER22, - BMC_12IN1, BMC_4IN1RESET, BMC_42IN1RESET, BMC_LITTLECOM160, - BMC_CTC09, BMC_K3006, BMC_K3036, BMC_K3046, BMC_SA005A, BMC_TJ03, + BMC_12IN1, BMC_4IN1RESET, BMC_42IN1RESET, BMC_LITTLECOM160, BMC_CTC09, + BMC_K1029, BMC_K3006, BMC_K3036, BMC_K3046, BMC_SA005A, BMC_TJ03, + BMC_RESETTXROM0, BMC_RESETTXROM1, BMC_RESETTXROM2, // Unlicensed UNL_8237, UNL_CC21, UNL_AX5705, UNL_KN42, UNL_KOF97, UNL_N625092, UNL_SC127, UNL_SMB2J, UNL_T230, UNL_MMALEE, diff --git a/src/devices/bus/nes/rcm.cpp b/src/devices/bus/nes/rcm.cpp index fdd07830381..f3adba8a49d 100644 --- a/src/devices/bus/nes/rcm.cpp +++ b/src/devices/bus/nes/rcm.cpp @@ -8,14 +8,14 @@ Here we emulate the following PCBs + * RCM GS2004 [mapper 283] + * RCM GS2013 [mapper 283 also] * RCM GS2015 [mapper 216] - * RCM GS2004 - * RCM GS2013 * RCM Tetris Family 9in1 [mapper 61] - * RCM 3D Block + * RCM 3D Block [mapper 355] TODO: - - investigate why 3D Block does not work + - implement PIC16C54 protection for 3D Block ***********************************************************************************************************/ @@ -38,9 +38,9 @@ // constructor //------------------------------------------------- -DEFINE_DEVICE_TYPE(NES_GS2015, nes_gs2015_device, "nes_g2015", "NES Cart RCM GS-2015 PCB") -DEFINE_DEVICE_TYPE(NES_GS2004, nes_gs2004_device, "nes_g2004", "NES Cart RCM GS-2004 PCB") -DEFINE_DEVICE_TYPE(NES_GS2013, nes_gs2013_device, "nes_g2013", "NES Cart RCM GS-2013 PCB") +DEFINE_DEVICE_TYPE(NES_GS2004, nes_gs2004_device, "nes_gs2004", "NES Cart RCM GS-2004 PCB") +DEFINE_DEVICE_TYPE(NES_GS2013, nes_gs2013_device, "nes_gs2013", "NES Cart RCM GS-2013 PCB") +DEFINE_DEVICE_TYPE(NES_GS2015, nes_gs2015_device, "nes_gs2015", "NES Cart RCM GS-2015 PCB") DEFINE_DEVICE_TYPE(NES_TF9IN1, nes_tf9_device, "nes_tetrisfam", "NES Cart RCM Tetris Family 9 in 1 PCB") DEFINE_DEVICE_TYPE(NES_3DBLOCK, nes_3dblock_device, "nes_3dblock", "NES Cart RCM 3D Block PCB") @@ -50,17 +50,22 @@ nes_gs2015_device::nes_gs2015_device(const machine_config &mconfig, const char * { } -nes_gs2004_device::nes_gs2004_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_nrom_device(mconfig, NES_GS2004, tag, owner, clock) +nes_gs2004_device::nes_gs2004_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int bank) + : nes_nrom_device(mconfig, type, tag, owner, clock), m_base(bank * 0x2000) { } -nes_gs2013_device::nes_gs2013_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_nrom_device(mconfig, NES_GS2013, tag, owner, clock) +nes_gs2004_device::nes_gs2004_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_gs2004_device(mconfig, NES_GS2004, tag, owner, clock, 0x20) { } -nes_tf9_device::nes_tf9_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +nes_gs2013_device::nes_gs2013_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_gs2004_device(mconfig, NES_GS2013, tag, owner, clock, 0x1f) +{ +} + +nes_tf9_device::nes_tf9_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nes_nrom_device(mconfig, NES_TF9IN1, tag, owner, clock) { } @@ -85,42 +90,6 @@ void nes_gs2015_device::pcb_reset() chr8(0, m_chr_source); } -void nes_gs2004_device::device_start() -{ - common_start(); -} - -void nes_gs2004_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg32(0xff); - chr8(0, m_chr_source); -} - -void nes_gs2013_device::device_start() -{ - common_start(); -} - -void nes_gs2013_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg32(0xff); - chr8(0, m_chr_source); -} - -void nes_tf9_device::device_start() -{ - common_start(); -} - -void nes_tf9_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg32(0); - chr8(0, m_chr_source); -} - void nes_3dblock_device::device_start() { common_start(); @@ -157,7 +126,8 @@ void nes_3dblock_device::pcb_reset() iNES: mapper 216 - In MESS: Supported. + In MAME: Partially supported. Bonza games have some + sort of card inputs for gambling purposes. -------------------------------------------------*/ @@ -177,41 +147,26 @@ uint8_t nes_gs2015_device::read_m(offs_t offset) /*------------------------------------------------- - Board BMC-GS2004 + Boards BMC-GS2004, BMC-GS2013 + + Games: Tetris Family 6-in-1, 5-in-1, 12-in-1 - Games: Tetris Family 6-in-1 + NES 2.0: mapper 283 - In MESS: Preliminary Support. It also misses WRAM handling - (we need reads from 0x6000-0x7fff) + In MAME: Supported. -------------------------------------------------*/ -void nes_gs2004_device::write_h(offs_t offset, uint8_t data) +u8 nes_gs2004_device::read_m(offs_t offset) { - LOG_MMC(("gs2004 write_h, offset: %04x, data: %02x\n", offset, data)); - - prg32(data); + LOG_MMC(("gs2004 read_m, offset: %04x\n", offset)); + return m_prg[m_base + offset]; // fixed base differs per device } -/*------------------------------------------------- - - Board BMC-GS2013 - - Games: Tetris Family 12-in-1 - - In MESS: Preliminary Support. It also misses WRAM handling - (we need reads from 0x6000-0x7fff) - - -------------------------------------------------*/ - -void nes_gs2013_device::write_h(offs_t offset, uint8_t data) +void nes_gs2004_device::write_h(offs_t offset, u8 data) { - LOG_MMC(("gs2013 write_h, offset: %04x, data: %02x\n", offset, data)); - - if (data & 0x08) - prg32(data & 0x09); - else - prg32(data & 0x07); + LOG_MMC(("gs2004 write_h, offset: %04x, data: %02x\n", offset, data)); + prg32(data); } /*------------------------------------------------- @@ -220,35 +175,22 @@ void nes_gs2013_device::write_h(offs_t offset, uint8_t data) Games: Tetris Family 9 in 1, 20 in 1 - Simple Mapper: prg/chr/nt are swapped depending on the offset - of writes in 0x8000-0xffff. offset&0x80 set NT mirroring, - when (offset&0x30) is 0,3 prg32 is set; when it is 1,2 - two 16k prg banks are set. See below for the values used in - these banks. - iNES: mapper 61 - In MESS: Supported. + In MAME: Supported. -------------------------------------------------*/ -void nes_tf9_device::write_h(offs_t offset, uint8_t data) +void nes_tf9_device::write_h(offs_t offset, u8 data) { LOG_MMC(("tetrisfam write_h, offset: %04x, data: %02x\n", offset, data)); - switch (offset & 0x30) - { - case 0x00: - case 0x30: - prg32(offset & 0x0f); - break; - case 0x10: - case 0x20: - prg16_89ab(((offset & 0x0f) << 1) | ((offset & 0x20) >> 4)); - prg16_cdef(((offset & 0x0f) << 1) | ((offset & 0x20) >> 4)); - break; - } - set_nt_mirroring(BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); + u8 bank = (offset & 0x0f) << 1 | BIT(offset, 5); + u8 mode = !BIT(offset, 4); + prg16_89ab(bank & ~mode); + prg16_cdef(bank | mode); + + set_nt_mirroring(BIT(offset, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); } /*------------------------------------------------- @@ -257,7 +199,7 @@ void nes_tf9_device::write_h(offs_t offset, uint8_t data) Games: 3-D Block Hwang Shinwei version - iNES: + NES 2.0: mapper 355 In MESS: Very Preliminary Support. What is the purpose of the writes to $4800-$4900-$4a00? These writes diff --git a/src/devices/bus/nes/rcm.h b/src/devices/bus/nes/rcm.h index 005869fe09c..0581d299f20 100644 --- a/src/devices/bus/nes/rcm.h +++ b/src/devices/bus/nes/rcm.h @@ -34,33 +34,27 @@ class nes_gs2004_device : public nes_nrom_device { public: // construction/destruction - nes_gs2004_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_gs2004_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; + virtual u8 read_m(offs_t offset) override; + virtual void write_h(offs_t offset, u8 data) override; protected: - // device-level overrides - virtual void device_start() override; + // construction/destruction + nes_gs2004_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int bank); + +private: + u32 m_base; }; // ======================> nes_gs2013_device -class nes_gs2013_device : public nes_nrom_device +class nes_gs2013_device : public nes_gs2004_device { public: // construction/destruction - nes_gs2013_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t 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; + nes_gs2013_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); }; @@ -70,15 +64,9 @@ class nes_tf9_device : public nes_nrom_device { public: // construction/destruction - nes_tf9_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - - virtual void write_h(offs_t offset, uint8_t data) override; - - virtual void pcb_reset() override; + nes_tf9_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); -protected: - // device-level overrides - virtual void device_start() override; + virtual void write_h(offs_t offset, u8 data) override; }; @@ -106,9 +94,9 @@ private: // device type definition -DECLARE_DEVICE_TYPE(NES_GS2015, nes_gs2015_device) DECLARE_DEVICE_TYPE(NES_GS2004, nes_gs2004_device) DECLARE_DEVICE_TYPE(NES_GS2013, nes_gs2013_device) +DECLARE_DEVICE_TYPE(NES_GS2015, nes_gs2015_device) DECLARE_DEVICE_TYPE(NES_TF9IN1, nes_tf9_device) DECLARE_DEVICE_TYPE(NES_3DBLOCK, nes_3dblock_device) diff --git a/src/devices/bus/nes/sunsoft.cpp b/src/devices/bus/nes/sunsoft.cpp index 926b1933c91..c5baffe74ea 100644 --- a/src/devices/bus/nes/sunsoft.cpp +++ b/src/devices/bus/nes/sunsoft.cpp @@ -16,7 +16,7 @@ * Sunsoft-5B [mapper 69] TODO: - - check 1-line glitches due to IRQ in Sunsoft-3 + - 1-line glitches in Fantasy Zone II (Sunsoft-3) seem to be PPU timing related. The cycle-based IRQ timer below "should" be ok. ***********************************************************************************************************/ @@ -136,6 +136,7 @@ void nes_sunsoft_3_device::pcb_reset() prg16_89ab(0); prg16_cdef(m_prg_chunks - 1); chr8(0, m_chr_source); + m_irq_toggle = 0; m_irq_count = 0; m_irq_enable = 0; @@ -256,28 +257,20 @@ void nes_sunsoft_2_device::write_h(offs_t offset, uint8_t data) Sunsoft-3 board emulation - The two games using this board have incompatible mirroring - wiring, making necessary two distinct mappers & pcb_id + Games: Fantasy Zone II, Mito Koumon II - Sekai Manyuki iNES: mapper 67 -------------------------------------------------*/ - void nes_sunsoft_3_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { if (id == TIMER_IRQ) { - if (m_irq_enable) + if (m_irq_enable && --m_irq_count == 0xffff) { - if (!m_irq_count) - { - set_irq_line(ASSERT_LINE); - m_irq_count = 0xffff; - m_irq_enable = 0; - } - else - m_irq_count--; + set_irq_line(ASSERT_LINE); + m_irq_enable = 0; } } } @@ -289,18 +282,11 @@ void nes_sunsoft_3_device::write_h(offs_t offset, uint8_t data) switch (offset & 0x7800) { case 0x0800: - chr2_0(data, CHRROM); - break; case 0x1800: - chr2_2(data, CHRROM); - break; case 0x2800: - chr2_4(data, CHRROM); - break; case 0x3800: - chr2_6(data, CHRROM); + chr2_x((offset >> 11) & 0x06, data & 0x3f, CHRROM); break; - case 0x4000: case 0x4800: m_irq_toggle ^= 1; if (m_irq_toggle) @@ -311,7 +297,6 @@ void nes_sunsoft_3_device::write_h(offs_t offset, uint8_t data) case 0x5800: m_irq_enable = BIT(data, 4); m_irq_toggle = 0; - set_irq_line(CLEAR_LINE); break; case 0x6800: switch (data & 3) @@ -323,10 +308,10 @@ void nes_sunsoft_3_device::write_h(offs_t offset, uint8_t data) } break; case 0x7800: - prg16_89ab(data); + prg16_89ab(data & 0x0f); break; default: - LOG_MMC(("Sunsoft 3 write_h uncaught write, offset: %04x, data: %02x\n", offset, data)); + set_irq_line(CLEAR_LINE); break; } } diff --git a/src/devices/bus/nes/sunsoft.h b/src/devices/bus/nes/sunsoft.h index c02b94647cf..6eb3f6b7af4 100644 --- a/src/devices/bus/nes/sunsoft.h +++ b/src/devices/bus/nes/sunsoft.h @@ -61,6 +61,7 @@ protected: // device-level overrides virtual void device_start() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + private: uint16_t m_irq_count; int m_irq_enable, m_irq_toggle; @@ -96,6 +97,7 @@ protected: int m_reg, m_latch1, m_latch2, m_wram_enable; }; + // ======================> nes_sunsoft_fme7_device class nes_sunsoft_fme7_device : public nes_nrom_device diff --git a/src/devices/bus/nes/waixing.cpp b/src/devices/bus/nes/waixing.cpp index 2aba7b3f412..2020c4ddc80 100644 --- a/src/devices/bus/nes/waixing.cpp +++ b/src/devices/bus/nes/waixing.cpp @@ -1208,9 +1208,12 @@ void nes_waixing_dq8_device::write_h(offs_t offset, uint8_t data) Games: Wai Xing Zhan Shi 2 (aka Phantasy Star 2), Bao Xiao Tien Guo, Bio Hazard, Pokemon Gold, Subor (R) - iNES: mapper 15 - - In MESS: Supported + FIXME: This used to be mapper 15. NesDev research says the + only two games found on board K-1029 (now in multigame.cpp) + are the two Contra multicarts. All other Waixing games + appear to be ROM hacks to work with mapper 15. Games on + this device need to be reassigned to correct device and/or + replaced with original dumps that match the original boards. -------------------------------------------------*/ diff --git a/src/devices/bus/saitek_osa/maestro.cpp b/src/devices/bus/saitek_osa/maestro.cpp index 6e9353ec1d9..fc755dd023c 100644 --- a/src/devices/bus/saitek_osa/maestro.cpp +++ b/src/devices/bus/saitek_osa/maestro.cpp @@ -224,7 +224,10 @@ void saitekosa_analyst_device::device_add_mconfig(machine_config &config) // video hardware HD44780(config, m_lcd, 0); m_lcd->set_lcd_size(2, 8); +} +void saitekosa_analyst_device::device_config_complete() +{ auto *screen = subdevice<screen_device>("^screen"); screen->set_size(6 * 16 + 3, 16); screen->set_visarea_full(); diff --git a/src/devices/bus/saitek_osa/maestro.h b/src/devices/bus/saitek_osa/maestro.h index b5739789af8..fee4b497d03 100644 --- a/src/devices/bus/saitek_osa/maestro.h +++ b/src/devices/bus/saitek_osa/maestro.h @@ -72,6 +72,7 @@ public: protected: virtual const tiny_rom_entry *device_rom_region() const override; virtual void device_add_mconfig(machine_config &config) override; + virtual void device_config_complete() override; private: required_device<hd44780_device> m_lcd; diff --git a/src/devices/bus/snes/rom21.cpp b/src/devices/bus/snes/rom21.cpp index 8cc1f6fddb6..9bf43d05894 100644 --- a/src/devices/bus/snes/rom21.cpp +++ b/src/devices/bus/snes/rom21.cpp @@ -128,8 +128,8 @@ uint8_t sns_rom21_srtc_device::srtc_weekday( uint32_t year, uint32_t month, uint uint32_t sum = 0; // Number of days passed since epoch year = std::max(1900U, year); - month = std::max(1U, std::min(12U, month)); - day = std::max(1U, std::min(31U, day)); + month = std::clamp(month, 1U, 12U); + day = std::clamp(day, 1U, 31U); while (y < year) { diff --git a/src/devices/bus/sunmouse/hlemouse.cpp b/src/devices/bus/sunmouse/hlemouse.cpp index e3d11558f75..97bae888600 100644 --- a/src/devices/bus/sunmouse/hlemouse.cpp +++ b/src/devices/bus/sunmouse/hlemouse.cpp @@ -53,7 +53,7 @@ INPUT_PORTS_END uint8_t extract_delta_byte(int32_t &delta) { - int32_t const result(std::min<int32_t>(std::max<int32_t>(delta, -120), 127)); + int32_t const result(std::clamp<int32_t>(delta, -120, 127)); delta -= result; return uint8_t(int8_t(result)); } diff --git a/src/devices/cpu/alto2/a2mouse.cpp b/src/devices/cpu/alto2/a2mouse.cpp index 677ef24f87c..3747abb71ea 100644 --- a/src/devices/cpu/alto2/a2mouse.cpp +++ b/src/devices/cpu/alto2/a2mouse.cpp @@ -148,7 +148,7 @@ INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_motion_x ) { int16_t ox = static_cast<int16_t>(oldval); int16_t nx = static_cast<int16_t>(newval); - m_mouse.dx = std::min(std::max(0, m_mouse.dx + (nx - ox)), 639); + m_mouse.dx = std::clamp(m_mouse.dx + (nx - ox), 0, 639); } /** @@ -162,7 +162,7 @@ INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_motion_y ) { int16_t oy = static_cast<int16_t>(oldval); int16_t ny = static_cast<int16_t>(newval); - m_mouse.dy = std::min(std::max(0, m_mouse.dy + (ny - oy)), 824); + m_mouse.dy = std::clamp(m_mouse.dy + (ny - oy), 0, 824); } /** diff --git a/src/devices/cpu/arc/arc.cpp b/src/devices/cpu/arc/arc.cpp index 70a2b274b57..46ac82a84fb 100644 --- a/src/devices/cpu/arc/arc.cpp +++ b/src/devices/cpu/arc/arc.cpp @@ -34,6 +34,13 @@ std::unique_ptr<util::disasm_interface> arc_cpu_device::create_disassembler() /*****************************************************************************/ +device_memory_interface::space_config_vector arc_cpu_device::memory_space_config() const +{ + return space_config_vector { + std::make_pair(AS_PROGRAM, &m_program_config) + }; +} + /*****************************************************************************/ void arc_cpu_device::unimplemented_opcode(uint16_t op) diff --git a/src/devices/cpu/dsp16/dsp16.cpp b/src/devices/cpu/dsp16/dsp16.cpp index d7da812acf2..20d63898968 100644 --- a/src/devices/cpu/dsp16/dsp16.cpp +++ b/src/devices/cpu/dsp16/dsp16.cpp @@ -1778,7 +1778,7 @@ s64 dsp16_device_base::dau_saturate(u16 a) const if (m_core->dau_auc_sat(a)) return m_core->dau_a[a]; else - return std::min<s64>(std::max<s64>(m_core->dau_a[a], std::numeric_limits<s32>::min()), std::numeric_limits<s32>::max()); + return std::clamp<s64>(m_core->dau_a[a], std::numeric_limits<s32>::min(), std::numeric_limits<s32>::max()); } inline bool dsp16_device_base::op_dau_con(u16 op, bool inc) diff --git a/src/devices/cpu/pdp8/pdp8dasm.cpp b/src/devices/cpu/pdp8/pdp8dasm.cpp index 3fdbc139249..dca8fadf4e2 100644 --- a/src/devices/cpu/pdp8/pdp8dasm.cpp +++ b/src/devices/cpu/pdp8/pdp8dasm.cpp @@ -638,10 +638,10 @@ void pdp8_disassembler::dasm_opr_group2(std::ostream &stream, u16 opr) { if (BIT(opr, 7)) stream << "CLA"; - else if (opr == 07400) + else if (opr == 0400) stream << "NOP"; - if ((opr & 0176) == 0) - stream << "!200"; + if ((opr & 0170) == 0) + stream << "!400"; } } diff --git a/src/devices/cpu/pps41/mm78.cpp b/src/devices/cpu/pps41/mm78.cpp index 99550886a45..5eae6f0b672 100644 --- a/src/devices/cpu/pps41/mm78.cpp +++ b/src/devices/cpu/pps41/mm78.cpp @@ -12,7 +12,7 @@ #include "pps41d.h" -DEFINE_DEVICE_TYPE(MM78, mm78_device, "mm78", "Rockwell MM78") // 2KB bytes ROM, 128 nibbles RAM +DEFINE_DEVICE_TYPE(MM78, mm78_device, "mm78", "Rockwell MM78") // 2KB ROM, 128 nibbles RAM DEFINE_DEVICE_TYPE(MM78L, mm78l_device, "mm78l", "Rockwell MM78L") // low-power DEFINE_DEVICE_TYPE(MM77, mm77_device, "mm77", "Rockwell MM77") // 1.3KB ROM, 96 nibbles RAM DEFINE_DEVICE_TYPE(MM77L, mm77l_device, "mm77l", "Rockwell MM77L") // 1.5KB ROM, low-power diff --git a/src/devices/machine/nscsi_bus.cpp b/src/devices/machine/nscsi_bus.cpp index 987e8951c27..2909742d1ba 100644 --- a/src/devices/machine/nscsi_bus.cpp +++ b/src/devices/machine/nscsi_bus.cpp @@ -263,6 +263,7 @@ void nscsi_full_device::device_reset() scsi_bus->data_w(scsi_refid, 0); scsi_bus->ctrl_w(scsi_refid, 0, S_ALL); scsi_bus->ctrl_wait(scsi_refid, S_SEL|S_BSY|S_RST, S_ALL); + sense(false, SK_NO_SENSE); } void nscsi_full_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) diff --git a/src/devices/sound/aica.cpp b/src/devices/sound/aica.cpp index 21d5fa081d0..abb5326f43c 100644 --- a/src/devices/sound/aica.cpp +++ b/src/devices/sound/aica.cpp @@ -22,8 +22,8 @@ #include <algorithm> -static constexpr s32 clip16(int x) { return std::min(32767, std::max(-32768, x)); } -static constexpr s32 clip18(int x) { return std::min(131071, std::max(-131072, x)); } +static constexpr s32 clip16(int x) { return std::clamp(x, -32768, 32767); } +static constexpr s32 clip18(int x) { return std::clamp(x, -131072, 131071); } #define SHIFT 12 #define FIX(v) ((u32)((float)(1 << SHIFT) * (v))) diff --git a/src/devices/sound/aicadsp.cpp b/src/devices/sound/aicadsp.cpp index 20faff8e5b8..a59c99b5bef 100644 --- a/src/devices/sound/aicadsp.cpp +++ b/src/devices/sound/aicadsp.cpp @@ -214,9 +214,9 @@ void AICADSP::step() //Shifter s32 SHIFTED = 0; //24 bit if (SHIFT == 0) - SHIFTED = std::max<s32>(std::min<s32>(ACC, 0x007FFFFF), -0x00800000); + SHIFTED = std::clamp<s32>(ACC, -0x00800000, 0x007FFFFF); else if (SHIFT == 1) - SHIFTED = std::max<s32>(std::min<s32>(ACC * 2, 0x007FFFFF), -0x00800000); + SHIFTED = std::clamp<s32>(ACC * 2, -0x00800000, 0x007FFFFF); else if (SHIFT == 2) { SHIFTED = ACC * 2; diff --git a/src/devices/sound/cem3394.cpp b/src/devices/sound/cem3394.cpp index e0c74635648..0a4ba228827 100644 --- a/src/devices/sound/cem3394.cpp +++ b/src/devices/sound/cem3394.cpp @@ -171,7 +171,7 @@ double cem3394_device::filter(double input, double cutoff) double cem3394_device::filter(double input, double cutoff) { // clamp cutoff to useful range, 50Hz-20kHz - cutoff = std::min(std::max(cutoff, 50.0), 20000.0); + cutoff = std::clamp(cutoff, 50.0, 20000.0); // clamp resonance to below 1.0 to prevent runaway behavior; when clamping, // also apply an (arbitrary) scale factor to the output since we're close @@ -222,7 +222,7 @@ double cem3394_device::filter(double input, double cutoff) double cem3394_device::filter(double input, double cutoff) { // clamp cutoff to useful range, 50Hz-20kHz - cutoff = std::min(std::max(cutoff, 50.0), 20000.0); + cutoff = std::clamp(cutoff, 50.0, 20000.0); // clamp resonance to 0.95 to prevent infinite gain double r = 4.0 * std::min(res, 0.95); diff --git a/src/devices/sound/dmadac.cpp b/src/devices/sound/dmadac.cpp index 384449fca9b..ae2ebce61ad 100644 --- a/src/devices/sound/dmadac.cpp +++ b/src/devices/sound/dmadac.cpp @@ -23,8 +23,6 @@ #define DEFAULT_SAMPLE_RATE (48000) -#define BUFFER_SIZE 32768 - /************************************* * @@ -38,8 +36,7 @@ void dmadac_sound_device::device_start() { - /* reset the state */ - m_volume = 1.0; + initialize_state(); /* allocate a stream channel */ m_channel = stream_alloc(0, 1, DEFAULT_SAMPLE_RATE); @@ -49,11 +46,18 @@ void dmadac_sound_device::device_start() save_item(NAME(m_bufout)); save_item(NAME(m_volume)); save_item(NAME(m_enabled)); - save_item(NAME(m_frequency)); save_item(NAME(m_buffer)); } +void dmadac_sound_device::initialize_state() +{ + /* reset the state */ + m_volume = 1.0; + m_bufin = m_bufout = 0; + m_enabled = 0; + std::fill_n(m_buffer.begin(), BUFFER_SIZE, 0); +} /************************************* * @@ -83,66 +87,6 @@ void dmadac_sound_device::flush() m_channel->update(); } -void dmadac_sound_device::transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, int16_t *data) -{ - int j; - - /* loop over all channels and accumulate the data */ - constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; - if (m_enabled) - { - int maxin = (m_bufout + BUFFER_SIZE - 1) % BUFFER_SIZE; - int16_t *src = data + channel * channel_spacing; - int curin = m_bufin; - - /* copy the data */ - for (j = 0; j < total_frames && curin != maxin; j++) - { - m_buffer[curin] = stream_buffer::sample_t(*src) * sample_scale; - curin = (curin + 1) % BUFFER_SIZE; - src += frame_spacing; - } - m_bufin = curin; - - /* log overruns */ - if (j != total_frames) - logerror("dmadac_transfer: buffer overrun (short %d frames)\n", total_frames - j); - } - - // FIXME: this line has rotted and can no longer compile - it should be fixed and uncommented or removed - //LOG("dmadac_transfer - %d samples, %d effective, %d in buffer\n", total_frames, int(total_frames * double(DEFAULT_SAMPLE_RATE) / dmadac[first_channel].frequency), dmadac[first_channel].curinpos - dmadac[first_channel].curoutpos); -} - -void dmadac_sound_device::transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, stream_buffer::sample_t *data) -{ - int j; - - /* loop over all channels and accumulate the data */ - if (m_enabled) - { - int maxin = (m_bufout + BUFFER_SIZE - 1) % BUFFER_SIZE; - stream_buffer::sample_t *src = data + channel * channel_spacing; - int curin = m_bufin; - - /* copy the data */ - for (j = 0; j < total_frames && curin != maxin; j++) - { - m_buffer[curin] = *src; - curin = (curin + 1) % BUFFER_SIZE; - src += frame_spacing; - } - m_bufin = curin; - - /* log overruns */ - if (j != total_frames) - logerror("dmadac_transfer: buffer overrun (short %d frames)\n", total_frames - j); - } - - // FIXME: this line has rotted and can no longer compile - it should be fixed and uncommented or removed - //LOG("dmadac_transfer - %d samples, %d effective, %d in buffer\n", total_frames, int(total_frames * double(DEFAULT_SAMPLE_RATE) / dmadac[first_channel].frequency), dmadac[first_channel].curinpos - dmadac[first_channel].curoutpos); -} - - /************************************* * @@ -226,8 +170,7 @@ dmadac_sound_device::dmadac_sound_device(const machine_config &mconfig, const ch m_bufin(0), m_bufout(0), m_volume(0), - m_enabled(0), - m_frequency(0) + m_enabled(0) { } diff --git a/src/devices/sound/dmadac.h b/src/devices/sound/dmadac.h index eb73d338eb9..6cbe8312231 100644 --- a/src/devices/sound/dmadac.h +++ b/src/devices/sound/dmadac.h @@ -18,9 +18,35 @@ class dmadac_sound_device : public device_t, public device_sound_interface public: dmadac_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + void initialize_state(); void flush(); - void transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, int16_t *data); - void transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, stream_buffer::sample_t *data); + + template <typename T> void transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, T* data) { + int j; + + constexpr stream_buffer::sample_t sample_scale = 1.0 / double(std::numeric_limits<T>::max()); + + if (m_enabled) + { + int maxin = (m_bufout + BUFFER_SIZE - 1) % BUFFER_SIZE; + T* src = data + channel * channel_spacing; + int curin = m_bufin; + + /* copy the data */ + for (j = 0; j < total_frames && curin != maxin; j++) + { + m_buffer[curin] = stream_buffer::sample_t(*src) * sample_scale; + curin = (curin + 1) % BUFFER_SIZE; + src += frame_spacing; + } + m_bufin = curin; + + /* log overruns */ + if (j != total_frames) + logerror("dmadac_transfer: buffer overrun (short %d frames)\n", total_frames - j); + } + } + void enable(uint8_t enable); void set_frequency(double frequency); void set_volume(uint16_t volume); @@ -43,7 +69,8 @@ private: /* per-channel parameters */ stream_buffer::sample_t m_volume; uint8_t m_enabled; - double m_frequency; + + static constexpr int BUFFER_SIZE = 32768; }; DECLARE_DEVICE_TYPE(DMADAC, dmadac_sound_device) diff --git a/src/devices/sound/huc6230.cpp b/src/devices/sound/huc6230.cpp index 31e143fea8c..50a28a37cbb 100644 --- a/src/devices/sound/huc6230.cpp +++ b/src/devices/sound/huc6230.cpp @@ -18,8 +18,6 @@ #include "emu.h" #include "huc6230.h" -constexpr int clamp(int val, int min, int max) { return std::min(max, std::max(min, val)); } - void huc6230_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { @@ -35,8 +33,8 @@ void huc6230_device::sound_stream_update(sound_stream &stream, std::vector<read_ if (!channel->m_playing) continue; - samp0 = clamp(samp0 + ((channel->m_output * channel->m_lvol) >> 3), -32768, 32767); - samp1 = clamp(samp1 + ((channel->m_output * channel->m_rvol) >> 3), -32768, 32767); + samp0 = std::clamp(samp0 + ((channel->m_output * channel->m_lvol) >> 3), -32768, 32767); + samp1 = std::clamp(samp1 + ((channel->m_output * channel->m_rvol) >> 3), -32768, 32767); } outputs[0].put_int(i, samp0, 32768); diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp index 868bcb70bc4..d432442aa1c 100644 --- a/src/devices/sound/ics2115.cpp +++ b/src/devices/sound/ics2115.cpp @@ -23,9 +23,11 @@ #include "emu.h" #include "ics2115.h" + #include <algorithm> #include <cmath> + //#define ICS2115_DEBUG //#define ICS2115_ISOLATE 6 @@ -201,9 +203,33 @@ device_memory_interface::space_config_vector ics2115_device::memory_space_config } -//TODO: improve using next-state logic from column 126 of patent 5809466 +/* + Using next-state logic from column 126 of patent 5809466. + VOL(L) = vol.acc + VINC = vol.inc + DIR = invert + BC = boundary cross (start or end ) + BLEN = bi directional loop enable + LEN loop enable + UVOL LEN BLEN DIR BC Next VOL(L) + 0 x x x x VOL(L) // no change no vol envelope + 1 x x 0 0 VOL(L) + VINC // foward dir no bc + 1 x x 1 0 VOL(L) - VINC // invert no bc + 1 0 x x 1 VOL(L) // no env len no vel envelope + ---------------------------------------------------------------------------- + 1 1 0 0 1 start - ( end - (VOL(L) + VINC) ) + 1 1 0 1 1 end + ( (VOL(L) - VINC) - start) + 1 1 1 0 1 end + (end - (VOL(L) + VINC) ) // here + 1 1 1 1 1 start - ( (VOL(L) - VINC)- start) +*/ int ics2115_device::ics2115_voice::update_volume_envelope() { + + // test for boundary cross + bool bc = false; + if (vol.acc >= vol.end || vol.acc <= vol.end) + bc = true; + int ret = 0; if (vol_ctrl.bitflags.done || vol_ctrl.bitflags.stop) return ret; @@ -233,13 +259,23 @@ int ics2115_device::ics2115_voice::update_volume_envelope() if (vol_ctrl.bitflags.loop) { - if (vol_ctrl.bitflags.loop_bidir) - vol_ctrl.bitflags.invert = !vol_ctrl.bitflags.invert; - - if (vol_ctrl.bitflags.invert) - vol.acc = vol.end + vol.left; - else - vol.acc = vol.start - vol.left; + if (bc) + { + if (!vol_ctrl.bitflags.loop_bidir) + { + if (!vol_ctrl.bitflags.invert) + vol.acc = vol.start - (vol.end - (vol.acc + vol.incr)); // uvol = 1* len = 1* blen = 0 dir = 0 bc = 1* start - ( end - (VOL(L) + VINC) ) + else + vol.acc = vol.end + ((vol.acc - vol.incr) - vol.start); // 1 1 blen = 0 dir = 1 1 end + ( (VOL(L) - VINC) - start) + } + else + { + if (!vol_ctrl.bitflags.invert) + vol.acc = vol.end + (vol.end - (vol.acc + vol.incr)); // 1 1 blen = 1 dir = 0 1 end + (end - (VOL(L) + VINC) ) + else + vol.acc = vol.start - ((vol.acc - vol.incr) - vol.start); // 1 1 beln = 1 dir = 1 1 start - ( (VOL(L) - VINC)- start) + } + } } else vol_ctrl.bitflags.done = true; diff --git a/src/devices/sound/qsoundhle.cpp b/src/devices/sound/qsoundhle.cpp index 913d22baed1..a9595a4b00d 100644 --- a/src/devices/sound/qsoundhle.cpp +++ b/src/devices/sound/qsoundhle.cpp @@ -416,7 +416,7 @@ int16_t qsound_hle_device::qsound_voice::update(qsound_hle_device &dsp, int32_t if ((new_phase >> 12) >= m_end_addr) new_phase -= (m_loop_len << 12); - new_phase = std::min<int32_t>(std::max<int32_t>(new_phase, -0x8000000), 0x7FFFFFF); + new_phase = std::clamp<int32_t>(new_phase, -0x8000000, 0x7FFFFFF); m_addr = new_phase >> 12; m_phase = (new_phase << 4)&0xffff; @@ -465,10 +465,10 @@ int16_t qsound_hle_device::qsound_adpcm::update(qsound_hle_device &dsp, int16_t if (step <= 0) delta = -delta; delta += curr_sample; - delta = std::min<int32_t>(std::max<int32_t>(delta, -32768), 32767); + delta = std::clamp<int32_t>(delta, -32768, 32767); m_step_size = (dsp.read_dsp_rom(DATA_ADPCM_TAB + 8 + step) * m_step_size) >> 6; - m_step_size = std::min<int16_t>(std::max<int16_t>(m_step_size, 1), 2000); + m_step_size = std::clamp<int16_t>(m_step_size, 1, 2000); return (delta * m_cur_vol) >> 16; } @@ -504,7 +504,7 @@ void qsound_hle_device::state_normal_update() else m_echo.m_length = m_echo.m_end_pos - DELAY_BASE_OFFSET; - m_echo.m_length = std::min<int16_t>(std::max<int16_t>(m_echo.m_length, 0), 1024); + m_echo.m_length = std::clamp<int16_t>(m_echo.m_length, 0, 1024); // update PCM voices int32_t echo_input = 0; @@ -534,8 +534,8 @@ void qsound_hle_device::state_normal_update() wet -= (m_voice_output[i] * (int16_t)read_dsp_rom(pan_index + PAN_TABLE_WET)); } // Saturate accumulated voices - dry = (std::min<int32_t>(std::max<int32_t>(dry, -0x1fffffff), 0x1fffffff)) << 2; - wet = (std::min<int32_t>(std::max<int32_t>(wet, -0x1fffffff), 0x1fffffff)) << 2; + dry = std::clamp<int32_t>(dry, -0x1fffffff, 0x1fffffff) << 2; + wet = std::clamp<int32_t>(wet, -0x1fffffff, 0x1fffffff) << 2; // Apply FIR filter on 'wet' input wet = m_filter[ch].apply(wet >> 16); @@ -549,7 +549,7 @@ void qsound_hle_device::state_normal_update() // DSP round function output = (output + 0x2000) & ~0x3fff; - m_out[ch] = (std::min<int32_t>(std::max<int32_t>(output >> 14, -0x7fff), 0x7fff)); + m_out[ch] = std::clamp<int32_t>(output >> 14, -0x7fff, 0x7fff); if (m_delay_update) { diff --git a/src/devices/sound/rolandpcm.cpp b/src/devices/sound/rolandpcm.cpp index d3393785f88..41f8f351e38 100644 --- a/src/devices/sound/rolandpcm.cpp +++ b/src/devices/sound/rolandpcm.cpp @@ -24,9 +24,6 @@ #include "rolandpcm.h" -constexpr int clamp16(int16_t val, int16_t min, int16_t max) { return std::min(max, std::max(min, val)); } - - DEFINE_DEVICE_TYPE(MB87419_MB87420, mb87419_mb87420_device, "mb87419_mb87420", "Roland MB87419/MB87420 PCM") mb87419_mb87420_device::mb87419_mb87420_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) @@ -307,7 +304,7 @@ void mb87419_mb87420_device::sound_stream_update(sound_stream &stream, std::vect chn.smpl_nxt += decode_sample((int8_t)read_byte(addr)); // This was verified to be independent from play_dir. // until the decoding is fixed, we prevent overflow bugs (due to DC offsets when looping) this way - chn.smpl_nxt = clamp16(chn.smpl_nxt, -0x7FF, +0x7FF); + chn.smpl_nxt = std::clamp<int16_t>(chn.smpl_nxt, -0x7FF, +0x7FF); } bool reachedEnd = false; diff --git a/src/devices/sound/scsp.cpp b/src/devices/sound/scsp.cpp index b340da3d237..57fbf951c51 100644 --- a/src/devices/sound/scsp.cpp +++ b/src/devices/sound/scsp.cpp @@ -436,13 +436,13 @@ TIMER_CALLBACK_MEMBER(scsp_device::timerC_cb) int scsp_device::Get_AR(int base, int R) { int Rate = base + (R << 1); - return m_ARTABLE[std::min(63, std::max(0, Rate))]; + return m_ARTABLE[std::clamp(Rate, 0, 63)]; } int scsp_device::Get_DR(int base, int R) { int Rate = base + (R << 1); - return m_DRTABLE[std::min(63, std::max(0, Rate))]; + return m_DRTABLE[std::clamp(Rate, 0, 63)]; } void scsp_device::Compute_EG(SCSP_SLOT *slot) diff --git a/src/devices/sound/scspdsp.cpp b/src/devices/sound/scspdsp.cpp index 4ed21455110..d34ab084694 100644 --- a/src/devices/sound/scspdsp.cpp +++ b/src/devices/sound/scspdsp.cpp @@ -224,9 +224,9 @@ void SCSPDSP::Step() //Shifter s32 SHIFTED = 0; //24 bit if (SHIFT == 0) - SHIFTED = std::max<s32>(std::min<s32>(ACC, 0x007FFFFF), -0x00800000); + SHIFTED = std::clamp<s32>(ACC, -0x00800000, 0x007FFFFF); else if (SHIFT == 1) - SHIFTED = std::max<s32>(std::min<s32>(ACC * 2, 0x007FFFFF), -0x00800000); + SHIFTED = std::clamp<s32>(ACC * 2, -0x00800000, 0x007FFFFF); else if (SHIFT == 2) { SHIFTED = ACC * 2; diff --git a/src/devices/sound/spu.cpp b/src/devices/sound/spu.cpp index 6cfba4fc5bc..7cc987a8067 100644 --- a/src/devices/sound/spu.cpp +++ b/src/devices/sound/spu.cpp @@ -2207,7 +2207,7 @@ bool spu_device::update_envelope(const int v) break; case 4: // release - voice[v].env_level=(std::min)(1.0f,(std::max)(0.0f,voice[v].env_level)); + voice[v].env_level=std::clamp(voice[v].env_level,0.0f,1.0f); voice[v].env_delta=voice[v].env_rr; if (voice[v].env_rr == -0.0f) // 0.0 release means infinite time { diff --git a/src/devices/sound/zsg2.cpp b/src/devices/sound/zsg2.cpp index 2fa01cfb3a5..518d765ccc3 100644 --- a/src/devices/sound/zsg2.cpp +++ b/src/devices/sound/zsg2.cpp @@ -275,7 +275,7 @@ void zsg2_device::filter_samples(zchan *ch) ch->emphasis_filter_state += raw_samples[i]-((ch->emphasis_filter_state+EMPHASIS_ROUNDING)>>EMPHASIS_FILTER_SHIFT); int32_t sample = ch->emphasis_filter_state >> EMPHASIS_OUTPUT_SHIFT; - ch->samples[i+1] = std::min<int32_t>(std::max<int32_t>(sample, -32768), 32767); + ch->samples[i+1] = std::clamp<int32_t>(sample, -32768, 32767); } } diff --git a/src/devices/video/hd44780.cpp b/src/devices/video/hd44780.cpp index 8d6db247ba7..a2fdb2d3032 100644 --- a/src/devices/video/hd44780.cpp +++ b/src/devices/video/hd44780.cpp @@ -70,6 +70,7 @@ hd44780_device::hd44780_device(const machine_config &mconfig, device_type type, , m_rw_input(0) , m_db_input(0) , m_enabled(false) + , m_function_set_at_any_time(false) { } @@ -487,7 +488,7 @@ void hd44780_device::control_write(u8 data) else if (BIT(m_ir, 5)) { // function set - if (!m_first_cmd && m_data_len == (BIT(m_ir, 4) ? 8 : 4) && (m_char_size != (BIT(m_ir, 2) ? 10 : 8) || m_num_line != (BIT(m_ir, 3) + 1))) + if (!m_function_set_at_any_time && !m_first_cmd && m_data_len == (BIT(m_ir, 4) ? 8 : 4) && (m_char_size != (BIT(m_ir, 2) ? 10 : 8) || m_num_line != (BIT(m_ir, 3) + 1))) { logerror("HD44780: function set cannot be executed after other instructions unless the interface data length is changed\n"); return; diff --git a/src/devices/video/hd44780.h b/src/devices/video/hd44780.h index b8d79236955..a69e816db21 100644 --- a/src/devices/video/hd44780.h +++ b/src/devices/video/hd44780.h @@ -33,6 +33,7 @@ public: void set_lcd_size(int lines, int chars) { m_lines = lines; m_chars = chars; } template <typename... T> void set_pixel_update_cb(T &&... args) { m_pixel_update_cb.set(std::forward<T>(args)...); } void set_busy_factor(float f) { m_busy_factor = f; } // it's a workaround for inaccurate busy flag emulation + void set_function_set_at_any_time(bool v = true) { m_function_set_at_any_time = v; } // device interface void write(offs_t offset, u8 data); @@ -135,6 +136,7 @@ private: bool m_nibble; int m_charset_type; u8 m_render_buf[80 * 16]; + bool m_function_set_at_any_time; enum { DDRAM, CGRAM }; }; diff --git a/src/devices/video/vector.cpp b/src/devices/video/vector.cpp index b344801dd9f..9f4a35f4bf5 100644 --- a/src/devices/video/vector.cpp +++ b/src/devices/video/vector.cpp @@ -108,7 +108,7 @@ void vector_device::add_point(int x, int y, rgb_t color, int intensity) { point *newpoint; - intensity = std::max(0, std::min(255, intensity)); + intensity = std::clamp(intensity, 0, 255); m_min_intensity = intensity > 0 ? std::min(m_min_intensity, intensity) : m_min_intensity; m_max_intensity = intensity > 0 ? std::max(m_max_intensity, intensity) : m_max_intensity; @@ -119,7 +119,7 @@ void vector_device::add_point(int x, int y, rgb_t color, int intensity) intensity -= (int)(intensity * random * vector_options::s_flicker); - intensity = std::max(0, std::min(255, intensity)); + intensity = std::clamp(intensity, 0, 255); } newpoint = &m_vector_list[m_vector_index]; diff --git a/src/emu/debug/dvmemory.cpp b/src/emu/debug/dvmemory.cpp index 3ae8008f0a2..fea8def590e 100644 --- a/src/emu/debug/dvmemory.cpp +++ b/src/emu/debug/dvmemory.cpp @@ -25,22 +25,21 @@ const debug_view_memory::memory_view_pos debug_view_memory::s_memory_pos_table[12] = { - /* 0 bytes per chunk: */ { 0, { 0 } }, - /* 1 byte per chunk: 00 11 22 33 44 55 66 77 */ { 3, { 0x04, 0x00, 0x80 } }, - /* 2 bytes per chunk: 0011 2233 4455 6677 */ { 6, { 0x8c, 0x0c, 0x08, 0x04, 0x00, 0x80 } }, - /* 3 bytes per chunk: */ { 0, { 0 } }, - /* 4 bytes per chunk: 00112233 44556677 */ { 12, { 0x9c, 0x9c, 0x1c, 0x18, 0x14, 0x10, 0x0c, 0x08, 0x04, 0x00, 0x80, 0x80 } }, - /* 5 bytes per chunk: */ { 0, { 0 } }, - /* 6 bytes per chunk: */ { 0, { 0 } }, - /* 7 bytes per chunk: */ { 0, { 0 } }, - /* 8 bytes per chunk: 0011223344556677 */ { 24, { 0xbc, 0xbc, 0xbc, 0xbc, 0x3c, 0x38, 0x34, 0x30, 0x2c, 0x28, 0x24, 0x20, 0x1c, 0x18, 0x14, 0x10, 0x0c, 0x08, 0x04, 0x00, 0x80, 0x80, 0x80, 0x80 } }, - /* 32 bit floating point: */ { 16, { 0 } }, - /* 64 bit floating point: */ { 32, { 0 } }, - /* 80 bit floating point: */ { 32, { 0 } }, + /* 0 bytes per chunk: */ { 0, 0, { 0 } }, + /* 1 byte per chunk: 00 11 22 33 44 55 66 77 */ { 1, 3, { 0x04, 0x00, 0x80 } }, + /* 2 bytes per chunk: 0011 2233 4455 6677 */ { 2, 6, { 0x8c, 0x0c, 0x08, 0x04, 0x00, 0x80 } }, + /* 3 bytes per chunk: */ { 0, 0, { 0 } }, + /* 4 bytes per chunk: 00112233 44556677 */ { 4, 12, { 0x9c, 0x9c, 0x1c, 0x18, 0x14, 0x10, 0x0c, 0x08, 0x04, 0x00, 0x80, 0x80 } }, + /* 5 bytes per chunk: */ { 0, 0, { 0 } }, + /* 6 bytes per chunk: */ { 0, 0, { 0 } }, + /* 7 bytes per chunk: */ { 0, 0, { 0 } }, + /* 8 bytes per chunk: 0011223344556677 */ { 8, 24, { 0xbc, 0xbc, 0xbc, 0xbc, 0x3c, 0x38, 0x34, 0x30, 0x2c, 0x28, 0x24, 0x20, 0x1c, 0x18, 0x14, 0x10, 0x0c, 0x08, 0x04, 0x00, 0x80, 0x80, 0x80, 0x80 } }, + /* 32 bit floating point: */ { 4, 16, { 0 } }, + /* 64 bit floating point: */ { 8, 32, { 0 } }, + /* 80 bit floating point: */ { 10, 32, { 0 } }, }; - //************************************************************************** // DEBUG VIEW MEMORY SOURCE //************************************************************************** @@ -107,7 +106,7 @@ debug_view_memory::debug_view_memory(running_machine &machine, debug_view_osd_up m_chunks_per_row(16), m_bytes_per_chunk(1), m_steps_per_chunk(1), - m_data_format(1), + m_data_format(data_format::HEX_8BIT), m_reverse_view(false), m_ascii_view(true), m_no_translation(false), @@ -214,7 +213,24 @@ void debug_view_memory::view_notify(debug_view_notification type) m_bytes_per_chunk = source.m_prefsize; if (m_bytes_per_chunk > 8) m_bytes_per_chunk = 8; - m_data_format = m_bytes_per_chunk; + switch (m_bytes_per_chunk) + { + case 1: + m_data_format = data_format::HEX_8BIT; + break; + + case 2: + m_data_format = data_format::HEX_16BIT; + break; + + case 4: + m_data_format = data_format::HEX_32BIT; + break; + + case 8: + m_data_format = data_format::HEX_64BIT; + break; + } m_steps_per_chunk = source.m_space ? source.m_space->byte_to_address(m_bytes_per_chunk) : m_bytes_per_chunk; if (source.m_space != nullptr) m_expression.set_context(&source.m_space->device().debug()->symtable()); @@ -264,7 +280,7 @@ static inline float u64_to_double(u64 value) void debug_view_memory::generate_row(debug_view_char *destmin, debug_view_char *destmax, debug_view_char *destrow, offs_t address) { // get positional data - const memory_view_pos &posdata = s_memory_pos_table[m_data_format]; + const memory_view_pos &posdata = get_posdata(m_data_format); int spacing = posdata.m_spacing; // generate the address @@ -277,7 +293,7 @@ void debug_view_memory::generate_row(debug_view_char *destmin, debug_view_char * // generate the data and the ascii string std::string chunkascii; - if (m_data_format <= 8) + if (is_hex_format(m_data_format)) { for (int chunknum = 0; chunknum < m_chunks_per_row; chunknum++) { @@ -310,7 +326,7 @@ void debug_view_memory::generate_row(debug_view_char *destmin, debug_view_char * extFloat80_t chunkdata80 = { 0, 0 }; bool ismapped; - if (m_data_format != 11) + if (m_data_format != data_format::FLOAT_80BIT) ismapped = read(m_bytes_per_chunk, address + chunknum * m_steps_per_chunk, chunkdata); else ismapped = read(m_bytes_per_chunk, address + chunknum * m_steps_per_chunk, chunkdata80); @@ -318,17 +334,21 @@ void debug_view_memory::generate_row(debug_view_char *destmin, debug_view_char * if (ismapped) switch (m_data_format) { - case 9: + case data_format::FLOAT_32BIT: sprintf(valuetext, "%.8g", u32_to_float(u32(chunkdata))); break; - case 10: + case data_format::FLOAT_64BIT: sprintf(valuetext, "%.24g", u64_to_double(chunkdata)); break; - case 11: + case data_format::FLOAT_80BIT: + { float64_t f64 = extF80M_to_f64(&chunkdata80); sprintf(valuetext, "%.24g", u64_to_double(f64.v)); break; } + default: + break; + } else { valuetext[0] = '*'; @@ -621,10 +641,10 @@ void debug_view_memory::recompute() // compute the section widths m_section[0].m_width = 1 + 8 + 1; - if (m_data_format <= 8) + if (is_hex_format(m_data_format)) m_section[1].m_width = 1 + 3 * m_bytes_per_row + 1; else { - const memory_view_pos &posdata = s_memory_pos_table[m_data_format]; + const memory_view_pos &posdata = get_posdata(m_data_format); m_section[1].m_width = 1 + posdata.m_spacing * m_chunks_per_row + 1; } @@ -693,11 +713,11 @@ debug_view_memory::cursor_pos debug_view_memory::get_cursor_pos(const debug_view { // start with the base address for this row cursor_pos pos; - const memory_view_pos &posdata = s_memory_pos_table[m_data_format]; + const memory_view_pos &posdata = get_posdata(m_data_format); pos.m_address = m_byte_offset + cursor.y * m_bytes_per_chunk * m_chunks_per_row; // determine the X position within the middle section, clamping as necessary - if (m_data_format <= 8) { + if (is_hex_format(m_data_format)) { int xposition = cursor.x - m_section[1].m_pos - 1; if (xposition < 0) xposition = 0; @@ -744,7 +764,7 @@ debug_view_memory::cursor_pos debug_view_memory::get_cursor_pos(const debug_view void debug_view_memory::set_cursor_pos(cursor_pos pos) { - const memory_view_pos &posdata = s_memory_pos_table[m_data_format]; + const memory_view_pos &posdata = get_posdata(m_data_format); // offset the address by the byte offset if (pos.m_address < m_byte_offset) @@ -759,7 +779,7 @@ void debug_view_memory::set_cursor_pos(cursor_pos pos) if (m_reverse_view) chunknum = m_chunks_per_row - 1 - chunknum; - if (m_data_format <= 8) { + if (is_hex_format(m_data_format)) { // scan within the chunk to find the shift for (m_cursor.x = 0; m_cursor.x < posdata.m_spacing; m_cursor.x++) if (posdata.m_shift[m_cursor.x] == pos.m_shift) @@ -965,15 +985,15 @@ void debug_view_memory::set_chunks_per_row(u32 rowchunks) //------------------------------------------------- // set_data_format - specify what kind of values -// are shown, 1-8 8-64 bits, 9 32bit floating point +// are shown //------------------------------------------------- -void debug_view_memory::set_data_format(int format) +void debug_view_memory::set_data_format(data_format format) { cursor_pos pos; // should never be - if ((format <= 0) || (format > 11)) + if (!is_valid_format(format)) return; // no need to change if (format == m_data_format) @@ -981,45 +1001,33 @@ void debug_view_memory::set_data_format(int format) pos = begin_update_and_get_cursor_pos(); const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source); - if ((format <= 8) && (m_data_format <= 8)) { - + if (is_hex_format(format) && is_hex_format(m_data_format)) { pos.m_address += (pos.m_shift / 8) ^ ((source.m_endianness == ENDIANNESS_LITTLE) ? 0 : (m_bytes_per_chunk - 1)); pos.m_shift %= 8; - m_bytes_per_chunk = format; + m_bytes_per_chunk = get_posdata(format).m_bytes; m_steps_per_chunk = source.m_space ? source.m_space->byte_to_address(m_bytes_per_chunk) : m_bytes_per_chunk; - m_chunks_per_row = m_bytes_per_row / format; + m_chunks_per_row = m_bytes_per_row / m_bytes_per_chunk; if (m_chunks_per_row < 1) m_chunks_per_row = 1; pos.m_shift += 8 * ((pos.m_address % m_bytes_per_chunk) ^ ((source.m_endianness == ENDIANNESS_LITTLE) ? 0 : (m_bytes_per_chunk - 1))); pos.m_address -= pos.m_address % m_bytes_per_chunk; } else { - if (format <= 8) { + if (is_hex_format(format)) { m_supports_cursor = true; m_edit_enabled = true; - - m_bytes_per_chunk = format; } else { m_supports_cursor = false; m_edit_enabled = false; m_cursor_visible = false; - - switch (format) - { - case 9: - m_bytes_per_chunk = 4; - break; - case 10: - m_bytes_per_chunk = 8; - break; - case 11: - m_bytes_per_chunk = 10; - break; - } } + + m_bytes_per_chunk = get_posdata(format).m_bytes; m_chunks_per_row = m_bytes_per_row / m_bytes_per_chunk; + if (m_chunks_per_row < 1) + m_chunks_per_row = 1; m_steps_per_chunk = source.m_space ? source.m_space->byte_to_address(m_bytes_per_chunk) : m_bytes_per_chunk; pos.m_shift = 0; pos.m_address -= pos.m_address % m_bytes_per_chunk; diff --git a/src/emu/debug/dvmemory.h b/src/emu/debug/dvmemory.h index 8aa5df7cbeb..da92ae43bf7 100644 --- a/src/emu/debug/dvmemory.h +++ b/src/emu/debug/dvmemory.h @@ -55,10 +55,24 @@ class debug_view_memory : public debug_view // construction/destruction debug_view_memory(running_machine &machine, debug_view_osd_update_func osdupdate, void *osdprivate); + struct memory_view_pos; + public: + enum class data_format + { + HEX_8BIT = 1, + HEX_16BIT = 2, + HEX_32BIT = 4, + HEX_64BIT = 8, + FLOAT_32BIT = 9, + FLOAT_64BIT = 10, + FLOAT_80BIT = 11 + }; + static bool is_valid_format(data_format format) { return int(format) >= 0 && int(format) < std::size(s_memory_pos_table) && get_posdata(format).m_bytes != 0; } + // getters const char *expression() const { return m_expression.string(); } - int get_data_format() { flush_updates(); return m_data_format; } + data_format get_data_format() { flush_updates(); return m_data_format; } u32 chunks_per_row() { flush_updates(); return m_chunks_per_row; } bool reverse() const { return m_reverse_view; } bool ascii() const { return m_ascii_view; } @@ -68,7 +82,7 @@ public: // setters void set_expression(const std::string &expression); void set_chunks_per_row(u32 rowchunks); - void set_data_format(int format); // 1-8 current values 9 32bit floating point + void set_data_format(data_format format); void set_reverse(bool reverse); void set_ascii(bool reverse); void set_physical(bool physical); @@ -88,6 +102,10 @@ private: u8 m_shift; }; + // data format helpers + static bool is_hex_format(data_format format) { return int(format) <= 8; } + static const memory_view_pos &get_posdata(data_format format) { return s_memory_pos_table[int(format)]; } + // internal helpers void enumerate_sources(); void recompute(); @@ -111,7 +129,7 @@ private: u32 m_chunks_per_row; // number of chunks displayed per line u8 m_bytes_per_chunk; // bytes per chunk u8 m_steps_per_chunk; // bytes per chunk - int m_data_format; // 1-8 current values 9 32bit floating point + data_format m_data_format; // 1-8 current values 9 32bit floating point bool m_reverse_view; // reverse-endian view? bool m_ascii_view; // display ASCII characters? bool m_no_translation; // don't run addresses through the cpu translation hook @@ -131,8 +149,9 @@ private: struct memory_view_pos { - u8 m_spacing; /* spacing between each entry */ - u8 m_shift[24]; /* shift for each character */ + u8 m_bytes; // bytes per entry + u8 m_spacing; // spacing between each entry + u8 m_shift[24]; // shift for each character }; static const memory_view_pos s_memory_pos_table[12]; // table for rendering at different data formats diff --git a/src/frontend/mame/cheat.cpp b/src/frontend/mame/cheat.cpp index 61cda1cf475..bc266cc6aae 100644 --- a/src/frontend/mame/cheat.cpp +++ b/src/frontend/mame/cheat.cpp @@ -1264,7 +1264,8 @@ std::string &cheat_manager::get_output_string(int row, ui::text_layout::text_jus row = (row < 0) ? (m_numlines + row) : (row - 1); // clamp within range - row = std::min(std::max(row, 0), m_numlines - 1); + assert(m_numlines > 0); + row = std::clamp(row, 0, m_numlines - 1); // return the appropriate string m_justify[row] = justify; diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp index 794eae4bdef..b18b3aa22af 100644 --- a/src/frontend/mame/ui/utils.cpp +++ b/src/frontend/mame/ui/utils.cpp @@ -306,7 +306,7 @@ protected: // try to load filters from a file if (value && file) { - unsigned const cnt(unsigned((std::max)(std::min(int(MAX), std::atoi(value)), 0))); + unsigned const cnt(std::clamp<int>(std::atoi(value), 0, MAX)); for (unsigned i = 0; cnt > i; ++i) { typename Base::ptr flt(static_cast<Impl &>(*this).create(*file, indent + 1)); diff --git a/src/lib/util/timeconv.h b/src/lib/util/timeconv.h index 2eb495a70aa..f9d1b070012 100644 --- a/src/lib/util/timeconv.h +++ b/src/lib/util/timeconv.h @@ -181,13 +181,10 @@ private: static int clamp_or_throw(int value, int minimum, int maximum, bool clamp, const char *out_of_range_message) { - if (value < minimum || value > maximum) - { - if (clamp) - value = std::min(std::max(value, minimum), maximum); - else - throw std::out_of_range(out_of_range_message); - } + if (clamp) + value = std::clamp(value, minimum, maximum); + else if (value < minimum || value > maximum) + throw std::out_of_range(out_of_range_message); return value; } diff --git a/src/mame/arcade.flt b/src/mame/arcade.flt index cfdbef8c6cc..dc8033dea1b 100644 --- a/src/mame/arcade.flt +++ b/src/mame/arcade.flt @@ -925,6 +925,7 @@ olibochu.cpp omegrace.cpp oneshot.cpp onetwo.cpp +opercoin.cpp opwolf.cpp orbit.cpp othello.cpp diff --git a/src/mame/drivers/astrcorp.cpp b/src/mame/drivers/astrcorp.cpp index e6a0b2bc31d..166453de9dc 100644 --- a/src/mame/drivers/astrcorp.cpp +++ b/src/mame/drivers/astrcorp.cpp @@ -38,7 +38,6 @@ TODO: it is suspected there's a ROM overlay provided by the protection device; - winbingo and clones, zulu: these should be at the same state of the two above, but don't show anything on screen; - magibomba, westvent: need a redump of one of the program ROMs; -- dinodino: decryption should be on par with the others but code jumps early into the weeds after RTE. *************************************************************************************************************/ @@ -97,6 +96,7 @@ protected: // memory pointers required_shared_ptr<u16> m_spriteram; + TIMER_DEVICE_CALLBACK_MEMBER(skilldrp_scanline_cb); void draw_sprites_w(offs_t offset, u16 data, u16 mem_mask = ~0); void eeprom_w(u8 data); void showhand_outputs_w(offs_t offset, u16 data, u16 mem_mask = ~0); @@ -107,7 +107,6 @@ protected: u8 m_screen_enable; private: - // video-related bitmap_ind16 m_bitmap; u16 m_sprite_dma; @@ -115,7 +114,6 @@ private: output_finder<7> m_lamps; u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - TIMER_DEVICE_CALLBACK_MEMBER(skilldrp_scanline_cb); void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -152,6 +150,7 @@ public: { } void astoneage(machine_config &config); + void dinodino(machine_config &config); void magibombd(machine_config &config); void init_astoneage(); void init_dinodino(); @@ -167,6 +166,7 @@ private: TIMER_DEVICE_CALLBACK_MEMBER(astoneage_scanline_cb); void astoneage_map(address_map &map); + void dinodino_map(address_map &map); void magibombd_map(address_map &map); void ramdac_map(address_map &map); @@ -523,6 +523,23 @@ void astoneage_state::astoneage_map(address_map &map) map(0xe00001, 0xe00001).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write)); } +void astoneage_state::dinodino_map(address_map &map) +{ + map(0x000000, 0x03ffff).rom().mirror(0x800000); // POST checks for ROM crc at mirror + map(0x900000, 0x903fff).ram().share("nvram"); // battery + map(0xb00000, 0xb00fff).ram().share("spriteram"); + map(0xb02000, 0xb02001).w(FUNC(astoneage_state::draw_sprites_w)); + map(0xb04000, 0xb04001).portr("INPUTS"); + map(0xb08001, 0xb08001).w(FUNC(astoneage_state::eeprom_w)); + map(0xb0a000, 0xb0a001).w(FUNC(astoneage_state::skilldrp_outputs_w)); + map(0xb0e000, 0xb0e001).portr("EEPROMIN"); + map(0xc80000, 0xc801ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); + // unknown location +// map(0x500001, 0x500001).w(FUNC(astoneage_state::screen_enable_w)); + map(0x580001, 0x580001).w(FUNC(astoneage_state::oki_bank_w)); + map(0xe00001, 0xe00001).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write)); +} + void astoneage_state::magibombd_map(address_map &map) // seems to use old style palette instead of ramdac { map(0x000000, 0x03ffff).rom().mirror(0x800000); @@ -816,6 +833,14 @@ void astoneage_state::magibombd(machine_config &config) config.device_remove("ramdac"); } +void astoneage_state::dinodino(machine_config &config) +{ + magibombd(config); + + m_maincpu->set_addrmap(AS_PROGRAM, &astoneage_state::dinodino_map); + TIMER(config.replace(), "scantimer").configure_scanline(FUNC(astoneage_state::skilldrp_scanline_cb), "screen", 0, 1); +} + /*************************************************************************** ROMs Loading ***************************************************************************/ @@ -1857,7 +1882,7 @@ GAME( 2001, magibombc, magibomb, magibombb, magibomb, magibomb_state, init_mag GAME( 2001?, magibombe, magibomb, magibombb, magibomb, magibomb_state, init_magibomb, ROT0, "Astro Corp.", "Magic Bomb (Ver. A3.1A)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // Heavier encryption -GAME( 2005, dinodino, 0, magibombd, skilldrp, astoneage_state, init_dinodino, ROT0, "Astro Corp.", "Dino Dino (Ver. A1.1)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // 13/01.2005 10:59 +GAME( 2005, dinodino, 0, dinodino, skilldrp, astoneage_state, init_dinodino, ROT0, "Astro Corp.", "Dino Dino (Ver. A1.1)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // 13/01.2005 10:59 GAME( 2005, astoneag, 0, astoneage, skilldrp, astoneage_state, init_astoneage, ROT0, "Astro Corp.", "Stone Age (Astro, Ver. ENG.03.A)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // 2005/02/21 GAME( 2005, magibombd, magibomb, magibombd, skilldrp, astoneage_state, init_magibombd, ROT0, "Astro Corp.", "Magic Bomb (Ver. AA.72D, 14/11/05)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) GAME( 2006, winbingo, 0, magibombd, skilldrp, astoneage_state, init_winbingo, ROT0, "Astro Corp.", "Win Win Bingo (set 1)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // 15:47:48 Feb 23 2006 diff --git a/src/mame/drivers/ceres.cpp b/src/mame/drivers/ceres.cpp index c55add94f5c..02255ced38d 100644 --- a/src/mame/drivers/ceres.cpp +++ b/src/mame/drivers/ceres.cpp @@ -282,7 +282,7 @@ INPUT_CHANGED_MEMBER(ceres1_state::mouse_x) else if (delta < -0x80) delta += 0x100; - m_mouse_x = std::max(0, std::min(m_mouse_x + delta, 1023)); + m_mouse_x = std::clamp(m_mouse_x + delta, 0, 1023); } INPUT_CHANGED_MEMBER(ceres1_state::mouse_y) @@ -294,7 +294,7 @@ INPUT_CHANGED_MEMBER(ceres1_state::mouse_y) else if (delta < -0x80) delta += 0x100; - m_mouse_y = std::max(0, std::min(m_mouse_y - delta, 799)); + m_mouse_y = std::clamp(m_mouse_y - delta, 0, 799); } static INPUT_PORTS_START(ceres1) diff --git a/src/mame/drivers/champbas.cpp b/src/mame/drivers/champbas.cpp index 082ef6625f1..76d74bf4829 100644 --- a/src/mame/drivers/champbas.cpp +++ b/src/mame/drivers/champbas.cpp @@ -226,6 +226,8 @@ void champbas_state::champbb2j_map(address_map &map) void champbas_state::tbasebal_map(address_map &map) { champbas_map(map); + map(0x6000, 0x63ff).ram(); + map(0x6800, 0x6fff).rom(); map(0x7800, 0x7fff).rom(); } @@ -650,7 +652,16 @@ void champbas_state::tbasebal(machine_config &config) /* basic machine hardware */ m_maincpu->set_addrmap(AS_PROGRAM, &champbas_state::tbasebal_map); - M68705P3(config, "mcu", XTAL(18'432'000)/6); // ?Mhz + m_mainlatch->q_out_cb<6>().set([this](int state){ logerror("%s latch bit 6 w: %02x\n", machine().describe_context(), state); }); // to M68705? the code here seems the same as champbb2 + m_mainlatch->q_out_cb<7>().set([this](int state){ logerror("%s latch bit 7 w: %02x\n", machine().describe_context(), state); }); // " + + m68705p_device &mcu(M68705P3(config, "mcu", XTAL(18'432'000) / 6)); // ?Mhz + mcu.porta_r().set_log("MCU port A r"); + mcu.porta_w().set([this](uint8_t data){ logerror("%s MCU port A w: %02x\n", machine().describe_context(), data); }); + mcu.portb_r().set_log("MCU port B r"); + mcu.portb_w().set([this](uint8_t data){ logerror("%s MCU port B w: %02x\n", machine().describe_context(), data); }); + mcu.portc_r().set_log("MCU port C r"); + mcu.portc_w().set([this](uint8_t data){ logerror("%s MCU port C w: %02x\n", machine().describe_context(), data); }); } diff --git a/src/mame/drivers/cv1k.cpp b/src/mame/drivers/cv1k.cpp index ada42e2e459..b58e729c2d4 100644 --- a/src/mame/drivers/cv1k.cpp +++ b/src/mame/drivers/cv1k.cpp @@ -571,7 +571,8 @@ ROM_END ROM_START( espgal2 ) ROM_REGION( 0x400000, "maincpu", ROMREGION_ERASEFF) - ROM_LOAD16_WORD_SWAP( "u4", 0x000000, 0x200000, CRC(09c908bb) SHA1(7d6031fd3542b3e1d296ff218feb40502fd78694) ) /* (2005/11/14 MASTER VER) */ + ROM_LOAD16_WORD_SWAP( "u4_alt", 0x000000, 0x200000, CRC(843608b8) SHA1(2f5fcd38e76df531a923cd9956104cef5185aaa9) ) // newer PCB revision, updated FPGA firmware, no changes in game code or data + ROM_LOAD16_WORD_SWAP( "u4", 0x000000, 0x200000, CRC(09c908bb) SHA1(7d6031fd3542b3e1d296ff218feb40502fd78694) ) /* (2005/11/14 MASTER VER) */ ROM_RELOAD(0x200000,0x200000) ROM_REGION( 0x8400000, "game", ROMREGION_ERASEFF) diff --git a/src/mame/drivers/decmate2.cpp b/src/mame/drivers/decmate2.cpp index ea7b1420a31..42917992b20 100644 --- a/src/mame/drivers/decmate2.cpp +++ b/src/mame/drivers/decmate2.cpp @@ -975,7 +975,7 @@ ROM_START(decmate2) ROMX_LOAD("23-391e2.e114", 0x1000, 0x0800, CRC(3a09ada1) SHA1(3093bd926d49c2fd62a773e8019e3755aa165ae9), ROM_BIOS(1) | ROM_SKIP(1)) ROMX_LOAD("23-392e2.e115", 0x0001, 0x0800, CRC(19901cb6) SHA1(82a642d2b5b56250611f69321d0251e27fa639fc), ROM_BIOS(1) | ROM_SKIP(1)) ROM_SYSTEM_BIOS(2, "31z", "31Z (3732)") // Regenerated from source code listing - ROMX_LOAD("23-358e2.e113", 0x0000, 0x0800, BAD_DUMP CRC(e6b9ab4d) SHA1(12533bab586b7bc753fae3ce1959bc5ced3905f5), ROM_BIOS(2) | ROM_SKIP(1)) + ROMX_LOAD("23-358e2.e113", 0x0000, 0x0800, BAD_DUMP CRC(459231ea) SHA1(608342b7129d54a2a0f4a8e0645dad1ae26fccf4), ROM_BIOS(2) | ROM_SKIP(1)) ROMX_LOAD("23-359e2.e114", 0x1000, 0x0800, BAD_DUMP CRC(3d1825b7) SHA1(753af9657eef1a284801c9765f4899563d3d9a20), ROM_BIOS(2) | ROM_SKIP(1)) ROMX_LOAD("23-360e2.e115", 0x0001, 0x0800, BAD_DUMP CRC(ed8162e6) SHA1(4ab993c00a5afc6465153ca4f52faa76e02a0ef3), ROM_BIOS(2) | ROM_SKIP(1)) diff --git a/src/mame/drivers/dmv.cpp b/src/mame/drivers/dmv.cpp index 7235a10a386..8ea2ee409e1 100644 --- a/src/mame/drivers/dmv.cpp +++ b/src/mame/drivers/dmv.cpp @@ -362,6 +362,9 @@ UPD7220_DRAW_TEXT_LINE_MEMBER( dmv_state::hgdc_draw_text ) { uint8_t tile_data = m_chargen->base()[(tile*16+yi) & 0x7ff]; + if((attr & 2) && (m_screen->frame_number() & 0x10)) // FIXME: blink freq + tile_data = 0; + if(cursor_on && cursor_addr == addr+x) //TODO tile_data^=0xff; diff --git a/src/mame/drivers/enigma2.cpp b/src/mame/drivers/enigma2.cpp index 53350bda7d3..56a96075269 100644 --- a/src/mame/drivers/enigma2.cpp +++ b/src/mame/drivers/enigma2.cpp @@ -19,6 +19,7 @@ enigma2b (1981) TODO: - enigma2 - Star blinking frequency + - enigma2 - Sound is incorrectly emulated (see MT07777) - enigma2a + enigma2b - bad sound ROM? @@ -124,13 +125,16 @@ DIP Switches *********************************************************************/ #include "emu.h" -#include "cpu/z80/z80.h" #include "cpu/i8085/i8085.h" +#include "cpu/z80/z80.h" #include "sound/ay8910.h" #include "emupal.h" #include "screen.h" #include "speaker.h" + +namespace { + #define LOG_PROT (0) /* these values provide a fairly low refresh rate of around 53Hz, but @@ -613,25 +617,25 @@ static INPUT_PORTS_START( enigma2 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START("DSW") - PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("DSW:1,2") + PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("DSW:!1,!2") PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x01, "4" ) PORT_DIPSETTING( 0x02, "5" ) PORT_DIPSETTING( 0x03, "6" ) - PORT_DIPNAME( 0x1c, 0x00, "Skill Level" ) PORT_DIPLOCATION("DSW:6,7,8") + PORT_DIPNAME( 0x1c, 0x00, "Skill Level" ) PORT_DIPLOCATION("DSW:!6,!7,!8") PORT_DIPSETTING( 0x00, "1" ) PORT_DIPSETTING( 0x04, "2" ) PORT_DIPSETTING( 0x0c, "3" ) PORT_DIPSETTING( 0x08, "4" ) PORT_DIPSETTING( 0x10, "5" ) PORT_DIPSETTING( 0x14, "6" ) - PORT_DIPNAME( 0x20, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("DSW:3") + PORT_DIPNAME( 0x20, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("DSW:!3") PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x20, DEF_STR( Cocktail ) ) - PORT_DIPNAME( 0x40, 0x40, "Number of Invaders" ) PORT_DIPLOCATION("DSW:5") + PORT_DIPNAME( 0x40, 0x40, "Number of Invaders" ) PORT_DIPLOCATION("DSW:!5") PORT_DIPSETTING( 0x40, "16" ) PORT_DIPSETTING( 0x00, "32" ) - PORT_DIPNAME( 0x80, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("DSW:4") + PORT_DIPNAME( 0x80, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("DSW:!4") PORT_DIPSETTING( 0x80, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) @@ -818,6 +822,7 @@ void enigma2_state::init_enigma2() } } +} // Anonymous namespace GAME( 1981, enigma2, 0, enigma2, enigma2, enigma2_state, init_enigma2, ROT270, "Game Plan (Zilec Electronics license)", "Enigma II", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/epos.cpp b/src/mame/drivers/epos.cpp index fe622b00d38..e3d87ad6a5b 100644 --- a/src/mame/drivers/epos.cpp +++ b/src/mame/drivers/epos.cpp @@ -456,8 +456,8 @@ static INPUT_PORTS_START( beastf ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) @@ -466,8 +466,8 @@ static INPUT_PORTS_START( beastf ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(2) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(2) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(2) - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) INPUT_PORTS_END diff --git a/src/mame/drivers/gfamily.cpp b/src/mame/drivers/gfamily.cpp index 813583e5e59..82bbf562818 100644 --- a/src/mame/drivers/gfamily.cpp +++ b/src/mame/drivers/gfamily.cpp @@ -3,7 +3,7 @@ /* Games Family P4-4P (Pentium 4 - 4 Players) -PC with Chinese Windows 2000 Pro and several emulators, including: +PC with Chinese Windows 2000 Pro and several emulators, including (programs may change on other revisions): -MAME v0.78 (Dec 30 2003) -MAME v0.96u3 (May 25 2005) -MAME v0.106 (May 16 2006) @@ -11,22 +11,12 @@ PC with Chinese Windows 2000 Pro and several emulators, including: -FB Alpha v0.2.94.98 -ZiNc 1.1 -PC motherboard plus an additional PCB for JAMMA, inputs and basic config (and protection). - -PC board: - CPU: Intel Celeron 1.7GHz / 128kb / 400MHz SL6SC - RAM: 256MB-DDR400 - PCB: 04/082006-SiS-651-6A6IXRMAC-00, Realtec ALC655 audio, Realtec RTL8201BL Ethernet (25.000 MHz xtal), Winbond W83194BG-648 (14.31818 MHz xtal) - BIOS: 686 AMIBIOS (c) 2006 AY36 8897 - -I/O board: +PC motherboard plus an additional PCB for JAMMA, inputs and basic config (and protection) with: Atmel AT89C2051 (near a 4 dipswitches bank and a 6.000 MHz xtal) Microchip CF745 (near another 4 dipswitches bank and a 4.000 MHz xtal) 2 x Microchip PIC12F508 Altera Max EPM7128SQC100-10 CPLD -Newer versions use the same I/O board, but with different PC motherboards with faster CPUs (seen with Pentium 4 2.40GHz/512/533 SL6DV). - */ #include "emu.h" @@ -85,7 +75,7 @@ void gfamily_state::machine_reset() void gfamily_state::gfamily(machine_config &config) { // Basic machine hardware - PENTIUM4(config, m_maincpu, 1'700'000'000); // Actually an Intel Celeron SL6SC 1.7GHz + PENTIUM4(config, m_maincpu, 1'700'000'000); // Actually an Intel Celeron SL6SC 1.7GHz (with the config found with the default BIOS) m_maincpu->set_addrmap(AS_PROGRAM, &gfamily_state::gfamily_map); // Video hardware @@ -104,15 +94,29 @@ void gfamily_state::gfamily(machine_config &config) ***************************************************************************/ ROM_START( gmfamily ) + + /* Different PC motherboards with different configurations. + By now, we're throwing all known BIOSes here. */ ROM_REGION(0x80000, "bios", 0) - ROM_LOAD("686_amibios_ay36_8897.bin", 0x00000, 0x80000, CRC(e04c5750) SHA1(240ca6b270bdebf129e4ce43e79275aa067b6ada) ) + + /* CPU: Intel Celeron 1.7GHz / 128kb / 400MHz SL6SC + RAM: 256MB-DDR400 + PCB: Realtec ALC655 audio, Realtec RTL8201BL Ethernet (25.000 MHz xtal), Winbond W83194BG-648 (14.31818 MHz xtal) */ + ROM_SYSTEM_BIOS(0, "ay36_8897", "04/082006-SiS-651-6A6IXRMAC-00") + ROMX_LOAD("686_amibios_ay36_8897.bin", 0x00000, 0x80000, CRC(e04c5750) SHA1(240ca6b270bdebf129e4ce43e79275aa067b6ada), ROM_BIOS(0)) + + /* CPU: Pentium 4 2.40GHz/512/533 SL6DV + RAM: 512MB + PCB: ECS (Elitegroup) 651-M v2.4. Seems like a later low-cost version of the consumer v2.0 motherboard. */ + ROM_SYSTEM_BIOS(1, "sy_sis651", "05/13/2005-SiS-651-6A6IXE19C-00") + ROMX_LOAD("award_i6a6ixe19.bin", 0x00000, 0x40000, CRC(95fa392c) SHA1(40f557339649c47e6c3d941670604e0559edf8db), ROM_BIOS(1)) // Winbond W49F002UP12N // PICs and MCUs from the I/O board, all of them protected ROM_REGION(0x10000, "unsorted", 0) - ROM_LOAD("at89c2051.u3", 0x0000, 0x4000, NO_DUMP ) // 2 Kbytes internal ROM - ROM_LOAD("cf745.u2", 0x4000, 0x2000, NO_DUMP ) // 1 Kbytes internal ROM - ROM_LOAD("pic12f508.u0", 0x6000, 0x2000, NO_DUMP ) // 1 Kbytes internal ROM - ROM_LOAD("pic12f508.u6", 0x8000, 0x2000, NO_DUMP ) // 1 Kbytes internal ROM + ROM_LOAD("at89c2051.u3", 0x0000, 0x4000, NO_DUMP) // 2 Kbytes internal ROM + ROM_LOAD("cf745.u2", 0x4000, 0x2000, NO_DUMP) // 1 Kbytes internal ROM + ROM_LOAD("pic12f508.u0", 0x6000, 0x2000, NO_DUMP) // 1 Kbytes internal ROM + ROM_LOAD("pic12f508.u6", 0x8000, 0x2000, NO_DUMP) // 1 Kbytes internal ROM DISK_REGION( "ide:0:hdd:image" ) // From a Norton Ghost recovery image DISK_IMAGE( "gamesfamily_1.1", 0, SHA1(cd6b8d19f430c510a95a838d7b8c578f89ccf834) ) diff --git a/src/mame/drivers/gm1000.cpp b/src/mame/drivers/gm1000.cpp new file mode 100644 index 00000000000..a7fa3a80860 --- /dev/null +++ b/src/mame/drivers/gm1000.cpp @@ -0,0 +1,123 @@ +// license:BSD-3-Clause +// copyright-holders:AJR +/******************************************************************************* + + Skeleton driver for Suzuki BH-1000/Hammond GM-1000 sound module. + +*******************************************************************************/ + +#include "emu.h" +//#include "bus/midi/midi.h" +#include "cpu/m37710/m37710.h" +#include "machine/nvram.h" +#include "video/hd44780.h" +#include "emupal.h" +#include "screen.h" + +namespace { + +class gm1000_state : public driver_device +{ +public: + gm1000_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_nvram(*this, "nvram", 0x800, ENDIANNESS_LITTLE) + { + } + + void gm1000(machine_config &config); + +private: + HD44780_PIXEL_UPDATE(lcd_pixel_update); + + void mem_map(address_map &map); + + required_device<m37702s1_device> m_maincpu; + memory_share_creator<u8> m_nvram; +}; + +HD44780_PIXEL_UPDATE(gm1000_state::lcd_pixel_update) +{ + if (x < 5 && y < 8 && line < 2 && pos < 24) + bitmap.pix(line * 8 + y, pos * 6 + x) = state; +} + + +void gm1000_state::mem_map(address_map &map) +{ + map(0x000400, 0x000403).rw("lcdc", FUNC(hd44780_device::read), FUNC(hd44780_device::write)).umask16(0x00ff); + map(0x004000, 0x007fff).ram(); + map(0x008000, 0x03ffff).rom().region("program", 0x8000); + map(0x040000, 0x04ffff).rom().region("program", 0); + map(0x050000, 0x050fff).lrw8( + [this](offs_t offset) { return m_nvram[offset]; }, "nvram_r", + [this](offs_t offset, u8 data) { m_nvram[offset] = data; }, "nvram_w").umask16(0x00ff); + map(0x064000, 0x06efff).ram(); + map(0x070002, 0x070005).nopr(); +} + + +static INPUT_PORTS_START(gm1000) + // Keycode assignments are rather arbitrary and do not at all reflect the panel layout + PORT_START("P4") + PORT_BIT(0x0f, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_LEFT) PORT_NAME("Parameter " UTF8_LEFT) + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_RIGHT) PORT_NAME("Parameter " UTF8_RIGHT) + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_DOWN) PORT_NAME("Data " UTF8_LEFT) + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_UP) PORT_NAME("Data " UTF8_RIGHT) + + PORT_START("P6") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_BACKSPACE) PORT_NAME("All Mute") + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_BACKSLASH) PORT_NAME("P. Mute") + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_RSHIFT) PORT_NAME("P. Monitor") + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_ENTER) PORT_NAME("Display") + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_COMMA) PORT_NAME("Part " UTF8_LEFT) + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_STOP) PORT_NAME("Part " UTF8_RIGHT) + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_OPENBRACE) PORT_NAME("Instrument " UTF8_LEFT) + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_NAME("Instrument " UTF8_RIGHT) +INPUT_PORTS_END + +void gm1000_state::gm1000(machine_config &config) +{ + M37702S1(config, m_maincpu, 4'000'000); // unknown clock; type guessed + m_maincpu->set_addrmap(AS_PROGRAM, &gm1000_state::mem_map); + m_maincpu->p4_in_cb().set_ioport("P4"); + m_maincpu->p6_in_cb().set_ioport("P6"); + m_maincpu->an0_cb().set_constant(0xc0); // battery voltage + m_maincpu->an2_cb().set_constant(0x80); // ? + + NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); + + screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); + screen.set_refresh_hz(60); + screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */ + screen.set_screen_update("lcdc", FUNC(hd44780_device::screen_update)); + screen.set_size(6*24, 8*2); + screen.set_visarea_full(); + screen.set_palette("palette"); + screen.set_color(rgb_t::green()); + + PALETTE(config, "palette", palette_device::MONOCHROME_INVERTED); + + hd44780_device &lcdc(HD44780(config, "lcdc", 0)); + lcdc.set_lcd_size(2, 24); + lcdc.set_pixel_update_cb(FUNC(gm1000_state::lcd_pixel_update)); + lcdc.set_function_set_at_any_time(true); +} + +ROM_START(gm1000) + ROM_REGION16_LE(0x40000, "program", 0) + ROM_LOAD16_BYTE("bh1_mgs71a__u6_sysl__v2.1_bf66.u6", 0x00000, 0x20000, CRC(d003880c) SHA1(5cf727c42dd1b903c0048f147b461676e8c35faf)) // MX27C1000-90 + ROM_LOAD16_BYTE("bh1_mgs71a__u7_sysh__v2.1_2fac.u7", 0x00001, 0x20000, CRC(989417a1) SHA1(3de4f10a2e7cde5eb93f04bd75db36e194b1d991)) // MX27C1000-90 + + ROM_REGION(0x800000, "waves", 0) // DIP42 mask ROMs "© SUZUKI 1993" + ROM_LOAD("319-35006_wd06__m531602c-53.u13", 0x000000, 0x200000, NO_DUMP) + ROM_LOAD("319-35007_wd07__m531602c-52.u14", 0x200000, 0x200000, NO_DUMP) + ROM_LOAD("319-35008_wd08__m531602c-54.u15", 0x200000, 0x200000, NO_DUMP) + ROM_LOAD("319-35009_wd09__m531602c-55.u16", 0x200000, 0x200000, NO_DUMP) +ROM_END + +} // anonymous namespace + +SYST(1994, gm1000, 0, 0, gm1000, gm1000, gm1000_state, empty_init, "Suzuki (Hammond license)", "GM-1000 GM Sound Module", MACHINE_IS_SKELETON) diff --git a/src/mame/drivers/hh_hmcs40.cpp b/src/mame/drivers/hh_hmcs40.cpp index 7bf023b2408..43fc3096735 100644 --- a/src/mame/drivers/hh_hmcs40.cpp +++ b/src/mame/drivers/hh_hmcs40.cpp @@ -113,7 +113,7 @@ TODO: games may manipulate VFD plate brightness by strobing it longer/shorter, eg. cgalaxn when a ship explodes. - bzaxxon 3D effect is difficult to simulate -- improve/redo SVGs of: bzaxxon, bpengo, bbtime +- improve/redo SVGs of: bzaxxon, bbtime ***************************************************************************/ @@ -1165,8 +1165,8 @@ ROM_START( bpengo ) ROM_LOAD( "hd38820a63", 0x0000, 0x1000, CRC(ebd6bc64) SHA1(0a322c47b9553a2739a85908ce64b9650cf93d49) ) ROM_CONTINUE( 0x1e80, 0x0100 ) - ROM_REGION( 744461, "screen", 0) - ROM_LOAD( "bpengo.svg", 0, 744461, BAD_DUMP CRC(2b9abaa5) SHA1(c70a6ac1fa757fdd3ababfe6e00573ef1410c1eb) ) + ROM_REGION( 565069, "screen", 0) + ROM_LOAD( "bpengo.svg", 0, 565069, CRC(fb25ffeb) SHA1(fb4db5120f1e35e39c7fb2da4af3aa63417efaf1) ) ROM_END diff --git a/src/mame/drivers/hh_tms1k.cpp b/src/mame/drivers/hh_tms1k.cpp index 24bde2e39a6..8493a40b9a5 100644 --- a/src/mame/drivers/hh_tms1k.cpp +++ b/src/mame/drivers/hh_tms1k.cpp @@ -53,6 +53,7 @@ on Joerg Woerner's datamath.org: http://www.datamath.org/IC_List.htm @MP1204 TMS1100 1980, Entex Baseball 3 (6007) *MP1209 TMS1100 1980, U.S. Games Space Cruiser/Strategy Football @MP1211 TMS1100 1980, Entex Space Invader (6012) + *MP1215 TMS1100 1980, Tiger Playmaker @MP1218 TMS1100 1980, Entex Basketball 2 (6010) @MP1219 TMS1100 1980, U.S. Games Super Sports-4 @MP1221 TMS1100 1980, Entex Raise The Devil (6011) @@ -122,6 +123,7 @@ on Joerg Woerner's datamath.org: http://www.datamath.org/IC_List.htm @MP6101B TMS0980 1979, Parker Brothers Stop Thief *MP6354 ? 1982, Tsukuda The Dracula (? note: 40-pin, VFD-capable) *MP6361 ? 1983, Defender Strikes (? note: VFD-capable) + *MP7302 TMS1400 1980, Tiger Deluxe Football with Instant Replay @MP7304 TMS1400 1982, Tiger 7 in 1 Sports Stadium (model 7-555) @MP7313 TMS1400 1980, Parker Brothers Bank Shot @MP7314 TMS1400 1980, Parker Brothers Split Second @@ -158,6 +160,7 @@ ROM source notes when dumped from another publisher, but confident it's the same - palmf31: Toshiba BC-8018B - ti1250: Texas Instruments TI-1200 - ti25503: Texas Instruments TI-1265 +- ti5100: loose 1979 TMS1073NL chip TODO: - verify output PLA and microinstructions PLA for MCUs that have been dumped @@ -274,6 +277,7 @@ TODO: #include "ti1680.lh" #include "ti25503.lh" #include "ti30.lh" +#include "ti5100.lh" #include "timaze.lh" #include "tisr16.lh" #include "tithermos.lh" @@ -10472,6 +10476,158 @@ ROM_END /*************************************************************************** + TI-5100, more (see below) + * TMS1070 MCU label TMS1073NL or TMC1073NL (die label 1070B, 1073) + * 11-digit 7seg VFD (1 custom digit) + + This chip was also used in 3rd-party calculators, such as Toshiba BC-1015, + Panasonic JE1601U, Radio Shack EC2001, Triumph-Adler D100. The original + TI version did not have the 3 buttons at R4. + +***************************************************************************/ + +class ti5100_state : public hh_tms1k_state +{ +public: + ti5100_state(const machine_config &mconfig, device_type type, const char *tag) : + hh_tms1k_state(mconfig, type, tag) + { } + + void ti5100(machine_config &config); + +private: + void update_display(); + void write_o(u16 data); + void write_r(u16 data); + u8 read_k(); +}; + +// handlers + +void ti5100_state::update_display() +{ + // extra segment on R10 + m_display->matrix(m_r, (m_r >> 2 & 0x100) | m_o); +} + +void ti5100_state::write_r(u16 data) +{ + // R0-R10: input mux, select digit + m_r = m_inp_mux = data; + update_display(); +} + +void ti5100_state::write_o(u16 data) +{ + // O0-O7: digit segments + m_o = data; + update_display(); +} + +u8 ti5100_state::read_k() +{ + // K: multiplexed inputs + return read_inputs(11); +} + +// config + +static INPUT_PORTS_START( ti5100 ) + PORT_START("IN.0") // R0 + PORT_BIT( 0x07, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_CONFNAME( 0x08, 0x00, "K" ) // constant mode + PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) + PORT_CONFSETTING( 0x08, DEF_STR( On ) ) + + PORT_START("IN.1") // R1 + PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_UNUSED ) + + PORT_START("IN.2") // R2 + PORT_BIT( 0x07, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_CONFNAME( 0x08, 0x00, "DP" ) // display point + PORT_CONFSETTING( 0x00, "F" ) + PORT_CONFSETTING( 0x08, "2" ) + + PORT_START("IN.3") // R3 + PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_UNUSED ) + + PORT_START("IN.4") // R4 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // clear all? + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_X) PORT_NAME("EX") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_G) PORT_NAME("GPM") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_D) PORT_NAME(UTF8_CAPITAL_DELTA"%") + + PORT_START("IN.5") // R5 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_CODE(KEYCODE_DEL) PORT_NAME("C/CE") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_C) PORT_NAME("CM") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_N) PORT_NAME("N") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_SLASH) PORT_NAME("%") + + PORT_START("IN.6") // R6 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_0_PAD) PORT_NAME("0") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("1") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("4") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_NAME("7") + + PORT_START("IN.7") // R7 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // duplicate of R8 0x01 + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("2") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("5") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("8") + + PORT_START("IN.8") // R8 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_STOP) PORT_CODE(KEYCODE_DEL_PAD) PORT_NAME(".") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("3") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("6") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_9_PAD) PORT_NAME("9") + + PORT_START("IN.9") // R9 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // duplicate of R9 0x02 + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_PLUS_PAD) PORT_NAME("+=") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_MINUS_PAD) PORT_NAME("-=") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_ASTERISK) PORT_NAME(UTF8_MULTIPLY) + + PORT_START("IN.10") // R10 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_HOME) PORT_NAME("M+=") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_INSERT) PORT_NAME("M-=") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_END) PORT_NAME("RM") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_SLASH_PAD) PORT_NAME(UTF8_DIVIDE) +INPUT_PORTS_END + +void ti5100_state::ti5100(machine_config &config) +{ + /* basic machine hardware */ + TMS1070(config, m_maincpu, 250000); // approximation + m_maincpu->k().set(FUNC(ti5100_state::read_k)); + m_maincpu->o().set(FUNC(ti5100_state::write_o)); + m_maincpu->r().set(FUNC(ti5100_state::write_r)); + + /* video hardware */ + PWM_DISPLAY(config, m_display).set_size(11, 9); + m_display->set_segmask(0x7ff, 0xff); + config.set_default_layout(layout_ti5100); + + /* no sound! */ +} + +// roms + +ROM_START( ti5100 ) + ROM_REGION( 0x0400, "maincpu", 0 ) + ROM_LOAD( "tms1073nl", 0x0000, 0x0400, CRC(94185933) SHA1(d2d9432f857b8530ac399f5097c6d412f06d8814) ) + + ROM_REGION( 867, "maincpu:mpla", 0 ) + ROM_LOAD( "tms1000_ti5100_micro.pla", 0, 867, CRC(31b43e95) SHA1(6864e4c20f3affffcd3810dcefbc9484dd781547) ) + ROM_REGION( 365, "maincpu:opla", 0 ) + ROM_LOAD( "tms1000_ti5100_output.pla", 0, 365, CRC(11f6f0f4) SHA1(f25cf6bd284ab4614746b2e3f98d42d2585e425a) ) +ROM_END + + + + + +/*************************************************************************** + TMC098x series Majestic-line calculators TI-30, SR-40, TI-15(less buttons) and several by Koh-I-Noor @@ -13113,6 +13269,7 @@ COMP( 1975, ti1250, 0, 0, ti1250, ti1250, ti1250_state, emp COMP( 1976, ti125076, ti1250, 0, ti1270, ti1250, ti1250_state, empty_init, "Texas Instruments", "TI-1250 (1976 version)", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) COMP( 1976, ti1270, 0, 0, ti1270, ti1270, ti1250_state, empty_init, "Texas Instruments", "TI-1270", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) COMP( 1976, ti25503, 0, 0, ti25503, ti25503, ti25503_state, empty_init, "Texas Instruments", "TI-2550 III", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) +CONS( 1976, ti5100, 0, 0, ti5100, ti5100, ti5100_state, empty_init, "Texas Instruments", "TI-5100", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) COMP( 1976, ti30, 0, 0, ti30, ti30, ti30_state, empty_init, "Texas Instruments", "TI-30", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) COMP( 1976, tibusan, 0, 0, ti30, tibusan, ti30_state, empty_init, "Texas Instruments", "TI Business Analyst", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) COMP( 1977, tiprog, 0, 0, ti30, tiprog, ti30_state, empty_init, "Texas Instruments", "TI Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) diff --git a/src/mame/drivers/kncljoe.cpp b/src/mame/drivers/kncljoe.cpp index d5581cbb948..c0eed4f5049 100644 --- a/src/mame/drivers/kncljoe.cpp +++ b/src/mame/drivers/kncljoe.cpp @@ -2,11 +2,10 @@ // copyright-holders:Ernesto Corvi /*************************************************************************** -Knuckle Joe - (c) 1985 Seibu Kaihatsu ( Taito License ) +Knuckle Joe - (c) 1985 Seibu Kaihatsu (Taito license) driver by Ernesto Corvi -Notes: This board seems to be an Irem design. The sound hardware is modified the 6803-based one used by the classic Irem games. There's only one AY 3-8910 chip and no MSM5205. There are also two @@ -15,15 +14,12 @@ The video hardware is pretty much like Irem games too. The only strange thing is that the screen is flipped vertically. TODO: -- sprite vs. sprite priority especially on ground level +- accurate screen timing (raw params), attract mode doesn't 1:1 match PCB -Updates: -- proper sound hw emulation (TS 070308) -- you can't play anymore after you die (clock speed too low, check XTAL) -- scrolling in bike levels (scroll register overflow) -- sprites disappearing at left screen edge (bad clipping) -- artifacts in stage 3 and others(clear sprite mem at bank switch?) -(081503AT) +BTANB: +- attract mode demo play stops playing and lets the timer run out +- player sprite 1-scanline glitch at the lower part of motorcycle level +- player sprite may briefly turn into garbage after a boss fight ***************************************************************************/ @@ -31,7 +27,6 @@ Updates: #include "includes/kncljoe.h" #include "cpu/z80/z80.h" -#include "cpu/m6800/m6801.h" #include "sound/sn76496.h" #include "speaker.h" @@ -256,13 +251,13 @@ void kncljoe_state::kncljoe(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &kncljoe_state::main_map); m_maincpu->set_vblank_int("screen", FUNC(kncljoe_state::irq0_line_hold)); - m6803_cpu_device &soundcpu(M6803(config, "soundcpu", XTAL(3'579'545))); /* verified on pcb */ - soundcpu.set_addrmap(AS_PROGRAM, &kncljoe_state::sound_map); - soundcpu.in_p1_cb().set(FUNC(kncljoe_state::m6803_port1_r)); - soundcpu.out_p1_cb().set(FUNC(kncljoe_state::m6803_port1_w)); - soundcpu.in_p2_cb().set(FUNC(kncljoe_state::m6803_port2_r)); - soundcpu.out_p2_cb().set(FUNC(kncljoe_state::m6803_port2_w)); - soundcpu.set_periodic_int(FUNC(kncljoe_state::sound_nmi), attotime::from_hz((double)3970)); //measured 3.970 kHz + M6803(config, m_soundcpu, XTAL(3'579'545)); /* verified on pcb */ + m_soundcpu->set_addrmap(AS_PROGRAM, &kncljoe_state::sound_map); + m_soundcpu->in_p1_cb().set(FUNC(kncljoe_state::m6803_port1_r)); + m_soundcpu->out_p1_cb().set(FUNC(kncljoe_state::m6803_port1_w)); + m_soundcpu->in_p2_cb().set(FUNC(kncljoe_state::m6803_port2_r)); + m_soundcpu->out_p2_cb().set(FUNC(kncljoe_state::m6803_port2_w)); + m_soundcpu->set_periodic_int(FUNC(kncljoe_state::sound_nmi), attotime::from_hz(3970)); // measured 3.970 kHz /* video hardware */ SCREEN(config, m_screen, SCREEN_TYPE_RASTER); diff --git a/src/mame/drivers/konamigx.cpp b/src/mame/drivers/konamigx.cpp index 56860289279..27c9db9a02d 100644 --- a/src/mame/drivers/konamigx.cpp +++ b/src/mame/drivers/konamigx.cpp @@ -2181,39 +2181,6 @@ ROM_START( salmndr2a ) ROM_LOAD( "salmndr2a.nv", 0x0000, 0x080, CRC(3a98a8f9) SHA1(08c2d164620a4d8ad902d502acea8ad621931198) ) ROM_END -/* Magical Twinbee */ -ROM_START( mtwinbee ) - /* main program */ - ROM_REGION( 0x800000, "maincpu", 0 ) - GX_BIOS - ROM_LOAD32_WORD_SWAP( "424eaa02.31b", 0x200002, 512*1024, CRC(34659905) SHA1(011df093502644ab7ceb7fd1fbca41d09af89566) ) - ROM_LOAD32_WORD_SWAP( "424eaa04.27b", 0x200000, 512*1024, CRC(f42d3139) SHA1(e03006b4a87a70dfba9ec5e4857442424269986c) ) - - /* sound program */ - ROM_REGION( 0x40000, "soundcpu", 0 ) - ROM_LOAD16_BYTE("424a06.9c", 0x000000, 128*1024, CRC(a4760e14) SHA1(78dbd309f3f7fa61e92c9554e594449a7d4eed5a) ) - ROM_LOAD16_BYTE("424a07.7c", 0x000001, 128*1024, CRC(fa90d7e2) SHA1(6b6dee29643309005834416bdfdb18d74f34cb1b) ) - - /* tiles */ - ROM_REGION( 0x500000, "k056832", ROMREGION_ERASE00 ) - TILE_WORD_ROM_LOAD( "424a14.17h", 0x000000, 2*1024*1024, CRC(b1d9fce8) SHA1(143ed2f03ac10a0f18d878c0ee0509a5714e4664) ) - TILE_BYTE_ROM_LOAD( "424a12.13g", 0x000004, 512*1024, CRC(7f9cb8b1) SHA1(f5e18d70fcb572bb85f9b064995fc0ab0bb581e8) ) - - /* sprites */ - ROM_REGION( 0x500000, "k055673", ROMREGION_ERASE00 ) - ROM_LOAD32_WORD( "424a11.25g", 0x000000, 2*1024*1024, CRC(29592688) SHA1(a4b44e9153988a510915af83116e3c18dd15642f) ) - ROM_LOAD32_WORD( "424a10.28g", 0x000002, 2*1024*1024, CRC(cf24e5e3) SHA1(095bf2ae4f47c6e4768515ae5e22c982fbc660a5) ) - ROM_LOAD( "424a09.30g", 0x400000, 1*1024*1024, CRC(daa07224) SHA1(198cafa3d0ead2aa2593be066c6f372e66c11c44) ) - - /* sound data */ - ROM_REGION( 0x400000, "k054539", 0 ) - ROM_LOAD( "424a17.9g", 0x000000, 2*1024*1024, CRC(e9dd9692) SHA1(c289019c8d1dd71b3cec26479c39b649de804707) ) - ROM_LOAD( "424a18.7g", 0x200000, 2*1024*1024, CRC(0f0d9f3a) SHA1(57f6b113b80f06964b7e672ad517c1654c5569c5) ) - - ROM_REGION16_BE( 0x80, "eeprom", 0 ) // default eeprom to prevent game booting with error - ROM_LOAD( "mtwinbee.nv", 0x0000, 0x080, CRC(942b4323) SHA1(2f6799bf187510355df5e52c4d416f5c5e70fa05) ) -ROM_END - /* Twinbee Yahhoo! */ ROM_START( tbyahhoo ) /* main program */ @@ -2276,6 +2243,39 @@ ROM_START( daiskiss ) ROM_LOAD( "535a22.9g", 0x000000, 2*1024*1024, CRC(7ee59acb) SHA1(782bf15f205e9fe7bd069f6445eb8187837dee32) ) ROM_END +/* Magical Twinbee */ +ROM_START( mtwinbee ) + /* main program */ + ROM_REGION( 0x800000, "maincpu", 0 ) + GX_BIOS + ROM_LOAD32_WORD_SWAP( "424eaa02.31b", 0x200002, 512*1024, CRC(34659905) SHA1(011df093502644ab7ceb7fd1fbca41d09af89566) ) + ROM_LOAD32_WORD_SWAP( "424eaa04.27b", 0x200000, 512*1024, CRC(f42d3139) SHA1(e03006b4a87a70dfba9ec5e4857442424269986c) ) + + /* sound program */ + ROM_REGION( 0x40000, "soundcpu", 0 ) + ROM_LOAD16_BYTE("424a06.9c", 0x000000, 128*1024, CRC(a4760e14) SHA1(78dbd309f3f7fa61e92c9554e594449a7d4eed5a) ) + ROM_LOAD16_BYTE("424a07.7c", 0x000001, 128*1024, CRC(fa90d7e2) SHA1(6b6dee29643309005834416bdfdb18d74f34cb1b) ) + + /* tiles */ + ROM_REGION( 0x500000, "k056832", ROMREGION_ERASE00 ) + TILE_WORD_ROM_LOAD( "424a14.17h", 0x000000, 2*1024*1024, CRC(b1d9fce8) SHA1(143ed2f03ac10a0f18d878c0ee0509a5714e4664) ) + TILE_BYTE_ROM_LOAD( "424a12.13g", 0x000004, 512*1024, CRC(7f9cb8b1) SHA1(f5e18d70fcb572bb85f9b064995fc0ab0bb581e8) ) + + /* sprites */ + ROM_REGION( 0x500000, "k055673", ROMREGION_ERASE00 ) + ROM_LOAD32_WORD( "424a11.25g", 0x000000, 2*1024*1024, CRC(29592688) SHA1(a4b44e9153988a510915af83116e3c18dd15642f) ) + ROM_LOAD32_WORD( "424a10.28g", 0x000002, 2*1024*1024, CRC(cf24e5e3) SHA1(095bf2ae4f47c6e4768515ae5e22c982fbc660a5) ) + ROM_LOAD( "424a09.30g", 0x400000, 1*1024*1024, CRC(daa07224) SHA1(198cafa3d0ead2aa2593be066c6f372e66c11c44) ) + + /* sound data */ + ROM_REGION( 0x400000, "k054539", 0 ) + ROM_LOAD( "424a17.9g", 0x000000, 2*1024*1024, CRC(e9dd9692) SHA1(c289019c8d1dd71b3cec26479c39b649de804707) ) + ROM_LOAD( "424a18.7g", 0x200000, 2*1024*1024, CRC(0f0d9f3a) SHA1(57f6b113b80f06964b7e672ad517c1654c5569c5) ) + + ROM_REGION16_BE( 0x80, "eeprom", 0 ) // default eeprom to prevent game booting with error + ROM_LOAD( "mtwinbee.nv", 0x0000, 0x080, CRC(942b4323) SHA1(2f6799bf187510355df5e52c4d416f5c5e70fa05) ) +ROM_END + /* Sexy Parodius version JAA (Japan) */ ROM_START( sexyparo ) /* main program */ @@ -4042,8 +4042,8 @@ GAME( 1994, gokuparo, fantjour, gokuparo, gokuparo, konamigx_state, init_ko GAME( 1994, crzcross, konamigx, gokuparo, puzldama, konamigx_state, init_posthack, ROT0, "Konami", "Crazy Cross (ver EAA)", MACHINE_IMPERFECT_GRAPHICS ) GAME( 1994, puzldama, crzcross, gokuparo, puzldama, konamigx_state, init_posthack, ROT0, "Konami", "Taisen Puzzle-dama (ver JAA)", MACHINE_IMPERFECT_GRAPHICS ) -GAME( 1995, mtwinbee, konamigx, tbyahhoo, gokuparo, konamigx_state, init_posthack, ROT0, "Konami", "Magical Twin Bee (ver EAA)", MACHINE_IMPERFECT_GRAPHICS ) -GAME( 1995, tbyahhoo, mtwinbee, tbyahhoo, gokuparo, konamigx_state, init_posthack, ROT0, "Konami", "Twin Bee Yahhoo! (ver JAA)", MACHINE_IMPERFECT_GRAPHICS ) +GAME( 1995, tbyahhoo, konamigx, tbyahhoo, gokuparo, konamigx_state, init_posthack, ROT0, "Konami", "Twin Bee Yahhoo! (ver JAA)", MACHINE_IMPERFECT_GRAPHICS ) +GAME( 1995, mtwinbee, tbyahhoo, tbyahhoo, gokuparo, konamigx_state, init_posthack, ROT0, "Konami", "Magical Twin Bee (ver EAA)", MACHINE_IMPERFECT_GRAPHICS ) GAME( 1995, tkmmpzdm, konamigx, konamigx_6bpp, tokkae, konamigx_state, init_konamigx, ROT0, "Konami", "Tokimeki Memorial Taisen Puzzle-dama (ver JAB)", MACHINE_IMPERFECT_GRAPHICS ) diff --git a/src/mame/drivers/missbamby.cpp b/src/mame/drivers/missbamby.cpp index a9afe458f1c..a7a7a73ab44 100644 --- a/src/mame/drivers/missbamby.cpp +++ b/src/mame/drivers/missbamby.cpp @@ -2,7 +2,7 @@ // copyright-holders: /* -Skeleton driver for Cirsa "Mini Super Fruits" and clones. +Skeleton driver for Cirsa "Mini Super Fruits" slot machines and clones. Known games on this hardware: ________________________________________________________________________ | Dumped | Game | Manufacturer | Notes | @@ -15,66 +15,19 @@ Known games on this hardware: | NO | St.-Tropez | Video Game | | | NO | Cocktails | Video Game | | | NO | Gold Mini II | Video Game | | - +-------------------------------------------------+--------------------+ -*/ -/* -Miss Bamby - Automatics Pasqual - _____________________________________________________________ - | _______ | - | |_PROM_| ____________ | - | __________________ | EMPTY | | - | | M5L8085AP | |_SOCKET____| | - | |_________________| ____________ | - | ______________ | ROM1 | | - | XTAL |M5L8212P | |___________| | - | __ 6.144 |____________| ____________ | - | |R| | ROM0 | | - __| |___________| | -|__| ________ ________ ___________________ ____________ | -|__| |ULN2003A |ULN2003A | M5L8155P | |_D5101LC__| | -|__| |__________________| ____________ | -|__| ________ _________ |_D5101LC__| | -|__| _______ |74LS393| |74LS74B1 | -|__| |7407N | ________ | -|__| ________ ________ |GD4001B| | -|__| |74LS14_| |74LS153| _________ | -|__| ____ | BATT | | -|__| _______ ___________________ |D | | 3.6V | | -|__| |LM380N| | AY-3-8910 | |I | |_________| | -|__| |__________________| |P | ______ | -|__| 8 dips->|S__| LM311N | - |____________________________________________________________| + +--------+-------------------+--------------------+--------------------+ + +Two unrelated games with similar hardware also on this driver: + _________________________________________________________ + |Name |Company | Description | + +-------+--------+--------------------------------------| + |Trebol | Regama | Pinball | + |Basket | Igoa | Electromechanical basketball machine | + +-------+--------+--------------------------------------+ -Golden Winner - Reben - _____________________________________________________________ - | _______ | - | DM74S188N ____________ | - | __________________ | EMPTY | | - | | NEC D8085AC | |_SOCKET____| | - | |_________________| ____________ | - | ______________ | ROM-B | | - | XTAL |INS/DP8212N | |___________| | - | __ 6.000 |____________| ____________ | - | |R| | ROM-A | | - __| |___________| | -|__| ________ ________ ___________________ ____________ | -|__| |_L203B_| |_L203B_| | NEC D8155HC | |MCM51L01P45| | -|__| |__________________| ____________ | -|__| ________ _________ |SCL 5101E-1| | -|__| _______ |74LS393N |DM7474N| | -|__| |7407N | ________ | -|__| ________ ________ |GD4001B| | -|__| SN74LS14N DM74LS153N | -|__| ____ | -|__| _______ ___________________ |D | | -|__| |LM380N| | AY-3-8910 | |I | | -|__| |__________________| |P | ______ | -|__| 8 dips->|S__| CA311E | - |____________________________________________________________| */ #include "emu.h" -#include "emupal.h" #include "speaker.h" #include "cpu/i8085/i8085.h" #include "machine/i8155.h" @@ -95,6 +48,7 @@ public: void missbamby(machine_config &config); void gldwinner(machine_config &config); + void igoabasket(machine_config &config); private: required_device<cpu_device> m_maincpu; @@ -187,6 +141,15 @@ void missbamby_state::gldwinner(machine_config &config) psg.add_route(ALL_OUTPUTS, "mono", 1.0); // guess } +void missbamby_state::igoabasket(machine_config &config) +{ + missbamby(config); + + // Two 8155 on the Basket PCB + I8155(config, "i8155b", 6_MHz_XTAL/2); // NEC D8155HC, guessed divisor +} + + // Cirsa PCB 810601 A ROM_START( minisupf ) ROM_REGION(0x4000, "maincpu", 0) @@ -208,6 +171,33 @@ ROM_START( luckyplr ) ROM_LOAD( "lucky_player_18sa030n.bin", 0x00, 0x20, CRC(cf80f260) SHA1(b965017aa871454c54f6175fee486eea810a9c2e) ) ROM_END +/* Miss Bamby - Automatics Pasqual + _____________________________________________________________ + | _______ | + | |_PROM_| ____________ | + | __________________ | EMPTY | | + | | M5L8085AP | |_SOCKET____| | + | |_________________| ____________ | + | ______________ | ROM1 | | + | XTAL |M5L8212P | |___________| | + | __ 6.144 |____________| ____________ | + | |R| | ROM0 | | + __| |___________| | +|__| ________ ________ ___________________ ____________ | +|__| |ULN2003A |ULN2003A | M5L8155P | |_D5101LC__| | +|__| |__________________| ____________ | +|__| ________ _________ |_D5101LC__| | +|__| _______ |74LS393| |74LS74B1 | +|__| |7407N | ________ | +|__| ________ ________ |GD4001B| | +|__| |74LS14_| |74LS153| _________ | +|__| ____ | BATT | | +|__| _______ ___________________ |D | | 3.6V | | +|__| |LM380N| | AY-3-8910 | |I | |_________| | +|__| |__________________| |P | ______ | +|__| 8 dips->|S__| LM311N | + |____________________________________________________________| +*/ ROM_START( msbamby ) ROM_REGION(0x4000, "maincpu", 0) ROM_LOAD( "1.bin", 0x0000, 0x2000, CRC(7b5efbd9) SHA1(abb4b4432021945aee474c4bdd83979f6460c671) ) @@ -228,6 +218,33 @@ ROM_START( goldfrts ) ROM_LOAD( "golden_fruits_18sa030n.bin", 0x00, 0x20, CRC(fa7822eb) SHA1(586705f64a5fb95e5dd1c7bfc929dccfebc3ec49) ) // Same as Mini Super Fruits ROM_END +/* Golden Winner - Reben. PCB without battery, 6 MHz xtal + _____________________________________________________________ + | _______ | + | DM74S188N ____________ | + | __________________ | EMPTY | | + | | NEC D8085AC | |_SOCKET____| | + | |_________________| ____________ | + | ______________ | ROM-B | | + | XTAL |INS/DP8212N | |___________| | + | __ 6.000 |____________| ____________ | + | |R| | ROM-A | | + __| |___________| | +|__| ________ ________ ___________________ ____________ | +|__| |_L203B_| |_L203B_| | NEC D8155HC | |MCM51L01P45| | +|__| |__________________| ____________ | +|__| ________ _________ |SCL 5101E-1| | +|__| _______ |74LS393N |DM7474N| | +|__| |7407N | ________ | +|__| ________ ________ |GD4001B| | +|__| SN74LS14N DM74LS153N | +|__| ____ | +|__| _______ ___________________ |D | | +|__| |LM380N| | AY-3-8910 | |I | | +|__| |__________________| |P | ______ | +|__| 8 dips->|S__| CA311E | + |____________________________________________________________| +*/ ROM_START( gwinner ) ROM_REGION(0x4000, "maincpu", 0) ROM_LOAD( "reben_sa_gw-a_chk_8811_crc_2677.bin", 0x0000, 0x1000, CRC(ffcb4ba0) SHA1(2bc0dfc2b35a3a6cc3addf69a4c8916cc54347e4) ) @@ -246,22 +263,67 @@ ROM_START( unkslot ) ROM_LOAD( "n83s23n.bin", 0x00, 0x20, CRC(ea598b2c) SHA1(c0d6367ed2381a4a0f22780773ff4777569e88ab) ) ROM_END -// PINBALL -// CPU: 1 x I8085A -// IO: 1 x I8155 -// Sound: 1 x AY8910 +/* Pinball from the Spanish company "Regama S.A." + CPU: 1 x I8085A + IO: 1 x I8155 + Sound: 1 x AY8910 +*/ ROM_START( trebol ) ROM_REGION(0x4000, "maincpu", 0) ROM_LOAD( "m69.bin", 0x0000, 0x2000, CRC(8fb8cd39) SHA1(4ed505d06b489ce83316fdaa39f7ce128011fb4b) ) ROM_END +/* "Basket" electromechanical machine from the Spanish company IGOA S.A. + Similar hardware, with two 8155. + Two empty EPROM sockets on the dumped PCB + ____________________________________________________ + | _________ | + | | 8xDips | |__ + | _____________ _________________ __| + | | EMPTY | | GI AY-3-8910A | __| + | |_____________| |_________________| __| + | _____________ _________________ __| + | | EMPTY | | NEC D8155HC | __| + | |_____________| |_________________| __| + | _____________ _______ _________ ________ __| + | | EPROM | |DM7417N SN74LS373N |ULN2003R| __| + | |_____________| _________________ ________ __| + | ____________ | M5L8085AP | |ULN2003A| __| + | | HM6116LP-3 | |_________________| | + | |____________| ________ |__ + | ________ Xtal SN74LS14N __| + | 82S123AN 6.144 MHz _________________ __| + | ________ | NEC D8155HC | __| + | 74LS393N |_________________| __| + | ________ ________ __| + | PAL16R4ACN |TC4011BP| __| + | _____ __| + | __________ NE555N ________ __| + | | BATT 5V | |ULN2803A __| + | |_________| __| + | __ | + | (__) <- Button | + |____________________________________________________| +*/ +ROM_START( basket ) + ROM_REGION(0x8000, "maincpu", 0) + ROM_LOAD( "igoa_sa_ba2.81_chk_69d2_mod_basket.bin", 0x0000, 0x8000, CRC(3d52419d) SHA1(5f097391bcad72c8d0f029ef21ca38d903cef140) ) + + ROM_REGION(0x20, "prom", 0) + ROM_LOAD( "82s123an.bin", 0x00, 0x20, NO_DUMP ) + + ROM_REGION(0x104, "plds", 0) + ROM_LOAD( "pal16r4acn.bin", 0x000, 0x104, NO_DUMP ) +ROM_END + } // Anonymous namespace -GAME( 1981, minisupf, 0, missbamby, c_810601a, missbamby_state, empty_init, ROT0, "Cirsa", "Mini Super Fruits", MACHINE_IS_SKELETON_MECHANICAL ) -GAME( 1981, luckyplr, 0, missbamby, missbamby, missbamby_state, empty_init, ROT0, "Cirsa", "Lucky Player", MACHINE_IS_SKELETON_MECHANICAL ) -GAME( 198?, msbamby, 0, missbamby, missbamby, missbamby_state, empty_init, ROT0, "Automatics Pasqual", "Miss Bamby", MACHINE_IS_SKELETON_MECHANICAL ) -GAME( 198?, goldfrts, 0, missbamby, c_810601a, missbamby_state, empty_init, ROT0, "Video Game", "Golden Fruits", MACHINE_IS_SKELETON_MECHANICAL ) -GAME( 198?, unkslot, 0, missbamby, missbamby, missbamby_state, empty_init, ROT0, "<unknown>", "unknown MGA or Costa Net slot machine", MACHINE_IS_SKELETON_MECHANICAL ) -GAME( 1983, gwinner, 0, gldwinner, missbamby, missbamby_state, empty_init, ROT0, "Reben SA", "Golden Winner", MACHINE_IS_SKELETON_MECHANICAL ) -GAME( 1985, trebol, 0, missbamby, missbamby, missbamby_state, empty_init, ROT0, "Regama", "Trebol", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 1981, minisupf, 0, missbamby, c_810601a, missbamby_state, empty_init, ROT0, "Cirsa", "Mini Super Fruits", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 1981, luckyplr, 0, missbamby, missbamby, missbamby_state, empty_init, ROT0, "Cirsa", "Lucky Player", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 198?, msbamby, 0, missbamby, missbamby, missbamby_state, empty_init, ROT0, "Automatics Pasqual", "Miss Bamby", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 198?, goldfrts, 0, missbamby, c_810601a, missbamby_state, empty_init, ROT0, "Video Game", "Golden Fruits", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 198?, unkslot, 0, missbamby, missbamby, missbamby_state, empty_init, ROT0, "<unknown>", "unknown MGA or Costa Net slot machine", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 1983, gwinner, 0, gldwinner, missbamby, missbamby_state, empty_init, ROT0, "Reben SA", "Golden Winner", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 1985, trebol, 0, missbamby, missbamby, missbamby_state, empty_init, ROT0, "Regama", "Trebol", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 1987?, basket, 0, igoabasket, missbamby, missbamby_state, empty_init, ROT0, "Igoa S.A.", "Basket", MACHINE_IS_SKELETON_MECHANICAL ) // v2.0 on ROM string, v2.81 on EPROM label diff --git a/src/mame/drivers/namcona1.cpp b/src/mame/drivers/namcona1.cpp index cc270b6a861..bd9b2a84bc9 100644 --- a/src/mame/drivers/namcona1.cpp +++ b/src/mame/drivers/namcona1.cpp @@ -14,11 +14,12 @@ NA-1 Games: - Emeraldia (C358) NA-2 Games: -- Knuckle Heads (C3??) +- Knuckle Heads (C360) - Numan Athletics (C359) - Emeraldia (C358) - Nettou! Gekitou! Quiztou!! (C365) - X-Day 2 (C394) +- Zelos (no keycus) To Do: @@ -28,7 +29,7 @@ To Do: area is uninitialized, the game software automatically writes these values there, but then hangs. *cgangpzl, cgangpzlj, exvania, exvaniaj, knckheadjp, quiztou -- xday2: unemulated printer and RTC devices (check test mode game options), also battery always returns NG +- xday2: unemulated printer and RTC devices (check test mode game options) - X-Day 2: Rom board M112 @@ -587,7 +588,7 @@ void namcona1_state::namcona1_main_map(address_map &map) map(0xf00000, 0xf01fff).ram().w(FUNC(namcona1_state::paletteram_w)).share("paletteram"); map(0xf40000, 0xf7ffff).rw(FUNC(namcona1_state::gfxram_r), FUNC(namcona1_state::gfxram_w)).share("cgram"); map(0xff0000, 0xffbfff).ram().w(FUNC(namcona1_state::videoram_w)).share("videoram"); - map(0xffd000, 0xffdfff).ram(); /* unknown */ + map(0xffc000, 0xffdfff).ram(); /* expects RAM here for some games or it won't boot*/ map(0xffe000, 0xffefff).ram().share("scroll"); /* scroll registers */ map(0xfff000, 0xffffff).ram().share("spriteram"); /* spriteram */ } @@ -597,6 +598,25 @@ void namcona1_state::namcona1_c219_map(address_map &map) map(0x000000, 0x07ffff).ram().share("workram"); } +void namcona2_state::zelos_ctrl_w(u16 data) +{ + // bit 15 to 7 are set during I/O test when switching between the 9 'windows'. Output test? Maybe which 'window' screen to update? + // at least bit 4 to 1 are used, too + + m_zelos_ctrl = data; + + //if (data & 0x007f) + // logerror("zelos_ctrl_w: %04x\n", data); +} + +void namcona2_state::zelos_main_map(address_map &map) +{ + namcona1_main_map(map); + + map(0xd00000, 0xd00001).w(FUNC(namcona2_state::zelos_ctrl_w)); + // map(0xd40000, 0xd40001).w(FUNC(namcona2_state::)); // bit 1 alternatively set and cleared in test mode +} + u8 xday2_namcona2_state::printer_r() { // --xx ---- printer status related, if bit 5 held 1 long enough causes printer error @@ -880,7 +900,6 @@ static INPUT_PORTS_START(namcona1_quiz) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_SERVICE1) INPUT_PORTS_END - /***************************************************************************/ static const gfx_layout cg_layout_8bpp = @@ -1055,6 +1074,13 @@ void namcona2_state::namcona2(machine_config &config) // m_maincpu->set_addrmap(AS_PROGRAM, &namcona2_state::namcona2_main_map); } +void namcona2_state::zelos(machine_config &config) +{ + namcona2(config); + + m_maincpu->set_addrmap(AS_PROGRAM, &namcona2_state::zelos_main_map); +} + void xday2_namcona2_state::xday2(machine_config &config) { namcona_base(config); @@ -1084,6 +1110,7 @@ void namcona2_state::init_knckhead() { m_gametype = NAMCO_KNCKHEAD; } void namcona2_state::init_numanath() { m_gametype = NAMCO_NUMANATH; } void namcona2_state::init_quiztou() { m_gametype = NAMCO_QUIZTOU; } void xday2_namcona2_state::init_xday2() { m_gametype = NAMCO_XDAY2; } +void namcona2_state::init_zelos() { m_gametype = -1; save_item(NAME(m_zelos_ctrl)); } ROM_START(bkrtmaq) ROM_REGION(0x200000, "maincpu", 0) @@ -1425,6 +1452,16 @@ ROM_START(xday2) ROM_LOAD16_BYTE("xds1-dat3.8c", 0x400000, 0x200000, CRC(8980acc4) SHA1(ecd94a3d3a38923e8e322cd8863671af26e30812)) ROM_END +// an 8-liner game that runs on several Namco NA-2 PCBs. Cabinet pic shows 9 screens (one per reel, called windows in IO test) + 5 screens (one per terminal) +ROM_START(zelos) + ROM_REGION(0x200000, "maincpu", ROMREGION_ERASEFF) + ROM_LOAD16_BYTE("zs1 slp 1b.6c", 0x000001, 0x080000, CRC(d71df137) SHA1(457d3e7cb352b44706567e8346dcde82393d13c1)) + ROM_LOAD16_BYTE("zs1 slp 0b.6f", 0x000000, 0x080000, CRC(5807ef9e) SHA1(5dde8d71637de480d1d679d88b25509c229c6056)) + + ROM_REGION16_BE(0x800000, "maskrom", ROMREGION_ERASE00) + // not populated +ROM_END + // NA-1 (C69 MCU) GAME(1992, bkrtmaq, 0, namcona1, namcona1_quiz, namcona1_state, init_bkrtmaq, ROT0, "Namco", "Bakuretsu Quiz Ma-Q Dai Bouken (Japan)", MACHINE_SUPPORTS_SAVE | MACHINE_NO_COCKTAIL) GAME(1992, cgangpzl, 0, namcona1, namcona1_joy, namcona1_state, init_cgangpzl, ROT0, "Namco", "Cosmo Gang the Puzzle (US)", MACHINE_SUPPORTS_SAVE | MACHINE_NO_COCKTAIL) @@ -1449,3 +1486,4 @@ GAME(1993, numanath, 0, namcona2, namcona1_joy, namcona2_state, init_ GAME(1993, numanathj, numanath, namcona2, namcona1_joy, namcona2_state, init_numanath, ROT0, "Namco", "Numan Athletics (Japan)", MACHINE_SUPPORTS_SAVE | MACHINE_NO_COCKTAIL) GAME(1993, quiztou, 0, namcona2, namcona1_quiz, namcona2_state, init_quiztou, ROT0, "Namco", "Nettou! Gekitou! Quiztou!! (Japan)", MACHINE_SUPPORTS_SAVE | MACHINE_NO_COCKTAIL) GAME(1995, xday2, 0, xday2, namcona1_joy, xday2_namcona2_state, init_xday2, ROT0, "Namco", "X-Day 2 (Japan)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE | MACHINE_NO_COCKTAIL) +GAME(1994, zelos, 0, zelos, namcona1_joy, namcona2_state, init_zelos, ROT0, "Namco", "Zelos (Japan, main unit)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE | MACHINE_NO_COCKTAIL) // waits for communication with the terminals diff --git a/src/mame/drivers/naomi.cpp b/src/mame/drivers/naomi.cpp index 250d4ee200e..1f5cf9a8365 100644 --- a/src/mame/drivers/naomi.cpp +++ b/src/mame/drivers/naomi.cpp @@ -585,7 +585,7 @@ Marvel Vs. Capcom 2 New Age of Heroes (Export, Rev A) 841-0007C-02 23085A Marvel Vs. Capcom 2 New Age of Heroes (Korea, Rev A) 841-0007C-03 23085A 14 (64Mb)* present 317-5058-COM *(+2x 32Mb) have factory wire-mod connecting IC13S serial EEPROM CLK pin to IC11 ROM /OE pin MushiKing The King of Beetles (2K3 2ND Ver. 1.003-, World) 840-0150C 24217 6 (64Mb) present 317-0394-COM requires 610-0669 barcode reader, 838-14245-92 "MAPLE/232C CONVERT BD" (MIE-based), 838-14243 "RFID CHIP R/W BD" and RFID chip MushiKing The King of Beetles (2K3 2ND Ver. 1.002-, World) 840-0150C 24217 6 (64Mb) present 317-0394-COM requires 610-0669 barcode reader, 838-14245-92 "MAPLE/232C CONVERT BD" (MIE-based), 838-14243 "RFID CHIP R/W BD" and RFID chip -MushiKing The King of Beetles (2K3 2ND Ver. 1.000-, Korea) 840-0155C none 6 (64Mb) present 317-0???-COM requires 610-0669 barcode reader, 838-14245-92 "MAPLE/232C CONVERT BD" (MIE-based), 838-14243 "RFID CHIP R/W BD" and RFID chip +MushiKing The King of Beetles (2K3 2ND Ver. 1.000-, Korea) 840-0155C 24265 6 (64Mb) present 317-0394-COM requires 610-0669 barcode reader, 838-14245-92 "MAPLE/232C CONVERT BD" (MIE-based), 838-14243 "RFID CHIP R/W BD" and RFID chip Quiz Ah Megamisama 840-0030C 23227 16 (64Mb) present 317-0280-JPN Shootout Pool 840-0098C 23844 4 (64Mb) present 317-0336-COM requires regular 837-13551 and 837-13938 rotary JVS boards /Shootout Pool Prize (Export) / diff --git a/src/mame/drivers/opercoin.cpp b/src/mame/drivers/opercoin.cpp new file mode 100644 index 00000000000..52ff7f8fb29 --- /dev/null +++ b/src/mame/drivers/opercoin.cpp @@ -0,0 +1,89 @@ +// license:BSD-3-Clause +// copyright-holders: + +/* +Skeleton driver for Oper Coin "Multi Baby" slot machine. + ___________________________________________________________________ + | ········ ········ ···· | + | _________ _________ _________ _________ _________ | + | |________| · |________| |_EMPTY__| |_EMPTY__| · |________| | + | · _____ · ..| + | · |BATT| · ..| + | · |_6V_| · ..| + | ________ ________ ________ ________ ________ | + | |74LS259| |74LS259| |74LS259| |74LS259| |74LS259| | + |.. ······ ······ ······ ·| + |.. ________ ________ ________ ________ ________ ·| + |..|74LS259| |74LS259| |74LS259| |74LS259| |74LS259| ·| + |.. ___ ________ | + |.. |EM| |TC538BP| | + |.. |PT| ________ | + |.. |Y | |TC538BP| _____________ | + |.. |__| ________ | EMPTY | | + | ___ |74LS74APC |____________| ________ | + | |EM| ________ ______________|SCL4011BE ________________ ____| + | |PT| |74LS363| | EPROM | ________ | GI AY-3-8910 ||4x || + | |Y | ________ |_____________||_74LS02| |_______________||DIPS| + | |__|Xtal|74LS138| ________________ | + |·___ 8.000 | Z80A CPU | ________ · | + |·| |MHz ::::::: |_______________| |ULN28030 · | + |·| |<- ULN2803A ·········· · | + |·|__| ······ ········ ········ · | + |__________________________________________________________________| + +*/ + +#include "emu.h" +#include "speaker.h" +#include "cpu/z80/z80.h" +#include "sound/ay8910.h" + +namespace { + +class multibaby_state : public driver_device +{ +public: + multibaby_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu") + { + } + + void multibaby(machine_config &config); + +private: + required_device<cpu_device> m_maincpu; + + virtual void machine_start() override; +}; + +static INPUT_PORTS_START( multibaby ) + PORT_START("DSW1") + PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1") + PORT_DIPUNKNOWN_DIPLOC(0x02, 0x02, "SW1:2") + PORT_DIPUNKNOWN_DIPLOC(0x04, 0x04, "SW1:3") + PORT_DIPUNKNOWN_DIPLOC(0x08, 0x08, "SW1:4") +INPUT_PORTS_END + +void multibaby_state::machine_start() +{ +} + +void multibaby_state::multibaby(machine_config &config) +{ + Z80(config, m_maincpu, 8.000_MHz_XTAL / 2); + + SPEAKER(config, "mono").front_center(); + ay8910_device &psg(AY8910(config, "psg", 8.000_MHz_XTAL / 4)); // Divisor unknown + psg.port_a_read_callback().set_ioport("DSW1"); + psg.add_route(ALL_OUTPUTS, "mono", 1.0); // Guess +} + +ROM_START( multibaby ) + ROM_REGION(0x4000, "maincpu", 0) + ROM_LOAD( "oc_multi_baby_b-1923.ic13", 0x000, 0x4000, CRC(5d1bffe2) SHA1(536492b093dd247ba0440d499920d526ee7ea439) ) +ROM_END + +} // Anonymous namespace + +GAME( 1990, multibaby, 0, multibaby, multibaby, multibaby_state, empty_init, ROT0, "Oper Coin", "Multi Baby", MACHINE_IS_SKELETON_MECHANICAL ) diff --git a/src/mame/drivers/pcipc.cpp b/src/mame/drivers/pcipc.cpp index cdf7d2d3104..957e71f264a 100644 --- a/src/mame/drivers/pcipc.cpp +++ b/src/mame/drivers/pcipc.cpp @@ -536,7 +536,7 @@ void pcipc_state::pcipc(machine_config &config) i82371sb_ide_device &ide(I82371SB_IDE(config, ":pci:07.1", 0)); ide.irq_pri().set(":pci:07.0", FUNC(i82371sb_isa_device::pc_irq14_w)); - ide.irq_sec().set(":pci:07.0", FUNC(i82371sb_isa_device::pc_irq15_w)); + ide.irq_sec().set(":pci:07.0", FUNC(i82371sb_isa_device::pc_mirq0_w)); // MGA2064W(config, ":pci:12.0", 0); VIRGEDX_PCI(config, ":pci:12.0", 0); // use VIRGEDX_PCI for its VESA 2.0 BIOS diff --git a/src/mame/drivers/pgm.cpp b/src/mame/drivers/pgm.cpp index 4f2b075e888..7383b538ec4 100644 --- a/src/mame/drivers/pgm.cpp +++ b/src/mame/drivers/pgm.cpp @@ -2487,6 +2487,42 @@ ROM_START( killbld106 ) ROM_LOAD( "pgm_m0300.u1", 0x400000, 0x400000, CRC(93159695) SHA1(50c5976c9b681bd3d1ebefa3bfa9fe6e72dcb96f) ) ROM_END +ROM_START( killbld100 ) // was dumped from a Taiwanese board + ROM_REGION( 0x600000, "maincpu", 0 ) /* 68000 Code */ + PGM_68K_BIOS + ROM_LOAD16_BYTE( "kb_u3_v100.u3", 0x100001, 0x080000, CRC(ba3233a9) SHA1(d41f00c0c83ead8567b2e4ebf3fd7b8525f06b73) ) + ROM_LOAD16_BYTE( "kb_u6_v100.u6", 0x100000, 0x080000, CRC(55ae1d39) SHA1(931411c0d7d02a636010bb5f7f312906de32d839) ) + ROM_LOAD16_BYTE( "kb_u4_v100.u4", 0x200001, 0x080000, CRC(d56a8407) SHA1(1c43c62ec9e3b11f77d9c14647797493f7b8f960) ) + ROM_LOAD16_BYTE( "kb_u5_v100.u5", 0x200000, 0x080000, CRC(99afff2b) SHA1(4167efc81daf365e632177bb26650c95dcc32ccb) ) + + ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data */ + ROM_LOAD( "kb_u2_v100.u2", 0x000000, 0x010000, CRC(6fbbdcb7) SHA1(2928b66cd605d38a5d4e5876890e52af89dfadc4) ) + + ROM_REGION( 0xa00000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */ + PGM_VIDEO_BIOS + ROM_LOAD( "pgm_t0300.u14", 0x180000, 0x400000, CRC(0922f7d9) SHA1(4302b4b7369e13f315fad14f7d6cad1321101d24) ) + + ROM_REGION16_LE( 0x2000000, "sprcol", 0 ) /* Sprite Colour Data */ + ROM_LOAD( "pgm_a0300.u9", 0x0000000, 0x0400000, CRC(3f9455d3) SHA1(3718ce00ad93975383aafc14e5a74dc297b011a1) ) + ROM_LOAD( "pgm_a0301.u10", 0x0400000, 0x0400000, CRC(92776889) SHA1(6d677837fefff47bfd1c6166322f69f89989a5e2) ) + ROM_LOAD( "pgm_a0303.u11", 0x0800000, 0x0400000, CRC(33f5cc69) SHA1(9cacd5058d4bb25b77f71658bbbbd4b38d0a6b6a) ) + ROM_LOAD( "pgm_a0306.u12", 0x0c00000, 0x0400000, CRC(cc018a8e) SHA1(37752d46f238fb57c0ab5a4f96b1e013f2077347) ) + ROM_LOAD( "pgm_a0307.u2", 0x1000000, 0x0400000, CRC(bc772e39) SHA1(079cc42a190cb916f02b59bca8fa90e524acefe9) ) +// ROM_LOAD( "pgm_a0302.u3", 0x1400000, 0x0200000, CRC(a4810e38) SHA1(c31fe641feab2c93795fc35bf71d4f37af1056d4) ) // from lord of gun! unused.. +// ROM_LOAD( "pgm_a0304.u4", 0x1600000, 0x0200000, CRC(3096de1c) SHA1(d010990d21cfda9cb8ab5b4bc0e329c23b7719f5) ) // from lord of gun! unused.. +// ROM_LOAD( "pgm_a0305.u5", 0x1800000, 0x0200000, CRC(2234531e) SHA1(58a82e31a1c0c1a4dd026576319f4e7ecffd140e) ) // from lord of gun! unused.. + + ROM_REGION16_LE( 0x1000000, "sprmask", 0 ) /* Sprite Masks + Colour Indexes */ + ROM_LOAD( "pgm_b0300.u13", 0x0000000, 0x0400000, CRC(7f876981) SHA1(43555a200929ad5ecc42137fc9aeb42dc4f50d20) ) + ROM_LOAD( "pgm_b0302.u14", 0x0400000, 0x0400000, CRC(eea9c502) SHA1(04b3972c7111ea59a3cceab6ad124080c4ce3520) ) + ROM_LOAD( "pgm_b0303.u15", 0x0800000, 0x0200000, CRC(77a9652e) SHA1(2342f643d37945fbda224a5034c013796e5134ca) ) +// ROM_LOAD( "pgm_b0301.u8", 0x0a00000, 0x0200000, CRC(400abe33) SHA1(20de1eb626424ea41bd55eb3cecd6b50be744ee0) ) // from lord of gun! unused.. + + ROM_REGION( 0x800000, "ics", 0 ) /* Samples - (8 bit mono 11025Hz) - */ + PGM_AUDIO_BIOS + ROM_LOAD( "pgm_m0300.u1", 0x400000, 0x400000, CRC(93159695) SHA1(50c5976c9b681bd3d1ebefa3bfa9fe6e72dcb96f) ) +ROM_END + /* Puzzle Star @@ -5364,6 +5400,7 @@ GAME( 1997, drgw2100hk, drgw2, pgm_012_025_drgw2, pgm, pgm_012_ GAME( 1998, killbld, pgm, pgm_022_025_killbld, killbld, pgm_022_025_state, init_killbld, ROT0, "IGS", "The Killing Blade / Ao Jian Kuang Dao (ver. 109, Chinese Board)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) /* region provided by protection device */ GAME( 1998, killbld104, killbld, pgm_022_025_killbld, killbld, pgm_022_025_state, init_killbld, ROT0, "IGS", "The Killing Blade / Ao Jian Kuang Dao (ver. 104)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) /* region provided by protection device */ GAME( 1998, killbld106, killbld, pgm_022_025_killbld, killbld, pgm_022_025_state, init_killbld, ROT0, "IGS", "The Killing Blade / Ao Jian Kuang Dao (ver. 106)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) /* region provided by protection device */ +GAME( 1998, killbld100, killbld, pgm_022_025_killbld, killbld, pgm_022_025_state, init_killbld, ROT0, "IGS", "The Killing Blade / Ao Jian Kuang Dao (ver. 100)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) /* region provided by protection device */ //中國龍3/Zhōngguó lóng 3 (China, Taiwan, Japan; Traditional chinese only in title screen) //東方之珠3/Dung1Fong1 Zi1 Zyu1 3 (Hong Kong)/dongbang jiju 3 (Korea) diff --git a/src/mame/drivers/rfslotsmcs48.cpp b/src/mame/drivers/rfslotsmcs48.cpp index 235ac52ccc4..803c22f4aca 100644 --- a/src/mame/drivers/rfslotsmcs48.cpp +++ b/src/mame/drivers/rfslotsmcs48.cpp @@ -11,7 +11,7 @@ | |4xDSW| ·| | ·| | ___________ ___________ ___________ ___________ ___________ ___________ ·| -| | SN74154N | | D8245C | | D8245C | | D8245C | | D8245C | | D8245C | ·| +| | SN74154N | | D8243C | | D8243C | | D8243C | | D8243C | | D8243C | ·| | |__________| |__________| |__________| |__________| |__________| |__________| ·| | ·| | XTAL | @@ -19,11 +19,11 @@ | |LM380N| CD4051BCN |6xDSW| 74LS00PC |7402PC| | Intel P8035L | __| | |_______________| |·|| | ___________ ___________ |·|| -| ________________ |55101L-1PC| |55101L-1PC| ___________ ___________ |·|| +| ________________ |S5101L-1PC| |S5101L-1PC| ___________ ___________ |·|| | | Intel D8748 | | EPROM | | AMD P8212 | |_|| | |_______________| ___________ ___________ |___________| |___________| | -| XTAL |55101L-1PC| |55101L-1PC| ·| -| 4.0000 MHz ·| +| XTAL |S5101L-1PC| |S5101L-1PC| ·| +| 4.0000 MHz LED-> O ·| | ·| | RF-3115 ·| | BATTERY ·| @@ -33,6 +33,8 @@ #include "emu.h" #include "cpu/mcs48/mcs48.h" +#include "machine/i8212.h" +#include "sound/ay8910.h" #include "speaker.h" namespace @@ -45,14 +47,21 @@ public: : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") , m_audiocpu(*this, "audiocpu") + , m_audiosubcpu(*this, "audiosubcpu") + , m_aysnd1(*this, "aysnd1") + , m_aysnd2(*this, "aysnd2") { } void ajofrin(machine_config &config); + void babyfrts(machine_config &config); protected: required_device<i8035_device> m_maincpu; - required_device<i8748_device> m_audiocpu; + optional_device<i8748_device> m_audiocpu; + optional_device<i8035_device> m_audiosubcpu; + optional_device<ay8910_device> m_aysnd1; + optional_device<ay8910_device> m_aysnd2; }; INPUT_PORTS_START(ajofrin) @@ -64,19 +73,89 @@ void rfslotsmcs48_state::ajofrin(machine_config &config) I8748(config, m_audiocpu, 4_MHz_XTAL); + I8212(config, "i8212"); + SPEAKER(config, "mono").front_center(); } -// Found just one PCB, probably missing some more boards (sound, I/O, etc.) +void rfslotsmcs48_state::babyfrts(machine_config &config) +{ + // Main PCB + + I8035(config, m_maincpu, 6_MHz_XTAL); + + I8212(config, "i8212"); + + // Audio PCB + + I8035(config, m_audiosubcpu, 6_MHz_XTAL); + + I8212(config, "i8212_2"); + + SPEAKER(config, "mono").front_center(); + + AY8910(config, m_aysnd1, 6_MHz_XTAL / 4).add_route(ALL_OUTPUTS, "mono", 0.50); // Divider unknown + AY8910(config, m_aysnd2, 6_MHz_XTAL / 4).add_route(ALL_OUTPUTS, "mono", 0.50); // Divider unknown +} + +// Found just one PCB, may be missing some more boards (extra sound, I/O, etc.) ROM_START(ajofrin) ROM_REGION(0x1000, "maincpu", 0) ROM_LOAD("ajofr_90percent_4k.bin", 0x0000, 0x1000, CRC(9e1fd7fe) SHA1(e7a5a2a10d17537edb039ac0f53358ee35465c90)) - ROM_REGION(0x400, "audiocpu", 0) - ROM_LOAD( "ajo_d8748.bin", 0x000, 0x400, CRC(414dc0e3) SHA1(016ed2aa36b36a637163ac7cba0a944a258c02a4)) + ROM_REGION(0x0400, "audiocpu", 0) + ROM_LOAD( "ajo_d8748.bin", 0x0000, 0x0400, CRC(414dc0e3) SHA1(016ed2aa36b36a637163ac7cba0a944a258c02a4)) +ROM_END + +/* It's an upgrade from "babyfrts25" for accepting 100 pts coins instead of just 25 pts ones. + Standard RF-3115 PCB but: + -Two S5101 static RAM chips (instead of 4, one empty socket in the middle) + -Four NEC D8243C (instead of 5, two empty sockets). + -No D8748 (the socket is empty), uses an external PCB (RF 53/3131) for sound with this layout: + ___________________________________ + | __________________________ | + | |·························| | + | Xtal | + | 6.000 MHz | + | _____________________ | + | _______ | AM8035PC | | + | DM7486N |____________________| | + | | + | ____________ ____________ | + | |Intel D8212| |2532 EPROM | | + | |___________| |___________| | + | | + | _____________________ | + | | GI AY-3-8910 | | + | |____________________| | + | _____________________ | + | | GI AY-3-8910 | | + | |____________________| | + | _______ | + | |· · · ·| | + |__________________________________| + +*/ +ROM_START(babyfrts) + ROM_REGION(0x1000, "maincpu", 0) + ROM_LOAD("bbr_cpu_100pts.bin", 0x0000, 0x1000, CRC(22c47a4d) SHA1(051c82b20a823047119a6d5460c07df601e44a2e)) + + ROM_REGION(0x1000, "audiocpu", 0) + ROM_LOAD( "bbs_100pts_sonido.bin", 0x0000, 0x1000, CRC(c84e20d3) SHA1(ab9457d3877a10bc54485a4954ef5b4d006ed3be)) +ROM_END + +// Same PCBs configuration as "babyfrts" +ROM_START(babyfrts25) + ROM_REGION(0x1000, "maincpu", 0) + ROM_LOAD("baby_8.3_av_25pts.bin", 0x0000, 0x1000, CRC(af45e046) SHA1(d4896f428a2061ad6bc12eed7d56eca4182d237d)) + + ROM_REGION(0x1000, "audiocpu", 0) + ROM_LOAD( "bbs_25pts_sonido.bin", 0x0000, 0x1000, CRC(384dc9b4) SHA1(0a3ab8a7dfba958858b06d23850d1a8a2b9a348f)) ROM_END } // anonymous namespace -// YEAR NAME PARENT MACHINE INPUT CLASS INIT ROT COMPANY FULLNAME FLAGS -GAME( 1981, ajofrin, 0, ajofrin, ajofrin, rfslotsmcs48_state, empty_init, ROT0, "Recreativos Franco", "Ajofrin City", MACHINE_IS_SKELETON_MECHANICAL ) +// YEAR NAME PARENT MACHINE INPUT CLASS INIT ROT COMPANY FULLNAME FLAGS +GAME( 1981, ajofrin, 0, ajofrin, ajofrin, rfslotsmcs48_state, empty_init, ROT0, "Recreativos Franco", "Ajofrin City", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 198?, babyfrts, 0, babyfrts, ajofrin, rfslotsmcs48_state, empty_init, ROT0, "Recreativos Franco", "Baby Fruits (100 pts version)", MACHINE_IS_SKELETON_MECHANICAL ) +GAME( 198?, babyfrts25, babyfrts, babyfrts, ajofrin, rfslotsmcs48_state, empty_init, ROT0, "Recreativos Franco", "Baby Fruits (25 pts version)", MACHINE_IS_SKELETON_MECHANICAL ) diff --git a/src/mame/drivers/skylncr.cpp b/src/mame/drivers/skylncr.cpp index c81da189b8a..73bdf0467fb 100644 --- a/src/mame/drivers/skylncr.cpp +++ b/src/mame/drivers/skylncr.cpp @@ -166,6 +166,7 @@ public: void init_miaction(); void init_olymp(); void init_sonikfig(); + void init_speedway(); void init_superb2k(); READ_LINE_MEMBER(mbutrfly_prot_r); @@ -2168,6 +2169,23 @@ ROM_START( olymp ) ROM_LOAD16_BYTE( "u58", 0x40001, 0x20000, CRC(f939f3f0) SHA1(0a089f78ca66d1e660cb854bbf5b0eb38e317a19) ) ROM_END +ROM_START( speedway ) // runs on a Rolla PCB with small sub board with main CPU, ROM and Altera EPM. Hack of Leader, extremely similar and still has Leader strings. + ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) + ROM_LOAD( "v3.bin", 0x00000, 0x10000, CRC(ef777180) SHA1(f1a554677543082eb7df2e204d0d4c987b7c6bbb) ) //TMS 27C512 + + ROM_REGION( 0x80000, "gfx1", 0 ) // all HN27C301AG + ROM_LOAD16_BYTE( "1.u29", 0x00000, 0x20000, CRC(3b360aac) SHA1(a6f31deea53deb8a7da2804c979390ed91ee9f50) ) // 1xxxxxxxxxxxxxxxx = 0xFF + ROM_LOAD16_BYTE( "2.u31", 0x00001, 0x20000, CRC(a491bdcf) SHA1(793faa829de50f67a44541136b66407ee9744971) ) + ROM_LOAD16_BYTE( "3.u33", 0x40000, 0x20000, CRC(935fc941) SHA1(12e5f7fea932a86298928b70b342e0825a3caca1) ) + ROM_LOAD16_BYTE( "4.u35", 0x40001, 0x20000, CRC(aa8164ce) SHA1(027fa9743ad9d80bd86e59d684180f75dc6d60a0) ) + + ROM_REGION( 0x80000, "gfx2", 0 ) // all HN27C301AG. Still has Bordun and Butterfly GFX in here. + ROM_LOAD16_BYTE( "5.u52", 0x00000, 0x20000, CRC(df984dbc) SHA1(7ea27465f9fd537fbdc1e13ca5842f656cbc2897) ) + ROM_LOAD16_BYTE( "6.u54", 0x00001, 0x20000, CRC(37fbdc4d) SHA1(8db83c43e7c43c2da5a39b86edff416c35fa275e) ) + ROM_LOAD16_BYTE( "7.u56", 0x40000, 0x20000, CRC(328f7912) SHA1(7f05217a18cfb316972cf96711276205e8098ee6) ) + ROM_LOAD16_BYTE( "8.u58", 0x40001, 0x20000, CRC(b93b221f) SHA1(efd6962a0f5e150c60d258fea116d726228dc39c) ) +ROM_END + /********************************** * Driver Init * **********************************/ @@ -2267,7 +2285,7 @@ void skylncr_state::init_superb2k() // TODO: very preliminary, just enough to re // descramble addresses. At a first glance, swaps seem to change if address line bits 13 or 14 are set (possibly 15 too, but not verified yet) // the scrambled address line bits appear to be 1, 3, 6, 9 and 12 - // it's possible XORs and are data lines swaps are involved, too, at least for opcodes + // it's possible XORs and data lines swaps are involved, too, at least for opcodes for (int i = 0x00000; i < 0x10000; i++) { switch (i & 0x6000) @@ -2280,6 +2298,47 @@ void skylncr_state::init_superb2k() // TODO: very preliminary, just enough to re } } +void skylncr_state::init_speedway() // TODO: complete this. These XORs and ranges have been derived by comparing this dump with leader, of which it's clearly a hack. +{ + uint8_t *const ROM = memregion("maincpu")->base(); + + for (int x = 0x0000; x < 0x10000; x++) + m_decrypted_opcodes[x] = ROM[x]; + + for (int x = 0x000d; x < 0x5000; x++) + { + ROM[x] = ROM[x] ^ 0x41; + m_decrypted_opcodes[x] = ROM[x]; + } + + for (int x = 0x5000; x < 0x53c2; x++) + m_decrypted_opcodes[x] = ROM[x] ^ 0x12; + + for (int x = 0x5400; x < 0x8000; x++) + { + ROM[x] = ROM[x] ^ 0x41; + m_decrypted_opcodes[x] = ROM[x]; + } + + for (int x = 0xc000; x < 0xc300; x++) + { + ROM[x] = ROM[x] ^ 0x08; + m_decrypted_opcodes[x] = ROM[x]; + } + + for (int x = 0xc300; x < 0xc368; x++) + m_decrypted_opcodes[x] = ROM[x] ^ 0x12; + + for (int x = 0xf690; x < 0xf74f; x++) + m_decrypted_opcodes[x] = ROM[x] ^ 0x12; + + for (int x = 0xf74f; x < 0x10000; x++) + { + ROM[x] = ROM[x] ^ 0x08; + m_decrypted_opcodes[x] = ROM[x]; + } +} + } // Anonymous namespace @@ -2293,6 +2352,7 @@ GAME( 1995, butrfly, 0, skylncr, skylncr, skylncr_state, empty_init, GAME( 1999, mbutrfly, 0, mbutrfly, mbutrfly, skylncr_state, init_mbutrfly, ROT0, "Bordun International", "Magical Butterfly (version U350C, protected)", MACHINE_SUPPORTS_SAVE ) GAME( 1995, madzoo, 0, skylncr, skylncr, skylncr_state, empty_init, ROT0, "Bordun International", "Mad Zoo (version U450C)", MACHINE_SUPPORTS_SAVE ) GAME( 1995, leader, 0, skylncr, leader, skylncr_state, empty_init, ROT0, "bootleg", "Leader (version Z 2E, Greece)", MACHINE_SUPPORTS_SAVE ) +GAME( 199?, speedway, 0, olymp, leader, skylncr_state, init_speedway, ROT0, "hack (Drivers)", "Speedway", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // Incomplete decryption (?) GAME( 199?, gallag50, 0, skylncr, gallag50, skylncr_state, empty_init, ROT0, "bootleg", "Gallag Video Game / Petalouda (Butterfly, x50)", MACHINE_SUPPORTS_SAVE ) GAME( 199?, neraidou, 0, neraidou, neraidou, skylncr_state, empty_init, ROT0, "bootleg", "Neraidoula", MACHINE_SUPPORTS_SAVE ) GAME( 199?, miaction, 0, skylncr, skylncr, skylncr_state, init_miaction, ROT0, "Vegas", "Missing In Action", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/srmp6.cpp b/src/mame/drivers/srmp6.cpp index df8257e30f7..67303b6704f 100644 --- a/src/mame/drivers/srmp6.cpp +++ b/src/mame/drivers/srmp6.cpp @@ -164,7 +164,7 @@ static inline u8 get_fade(int c, int f) // same as CPS3? { f &= 0x3f; c = (f & 0x20) ? (c + (((0x1f - c) * (f & 0x1f)) / 0x1f)) : ((c * f) / 0x1f); - c = std::max(0, std::min(0x1f, c)); + c = std::clamp(c, 0, 0x1f); } return c; } diff --git a/src/mame/drivers/taito_b.cpp b/src/mame/drivers/taito_b.cpp index 952eac18fbd..1d24ff7a20c 100644 --- a/src/mame/drivers/taito_b.cpp +++ b/src/mame/drivers/taito_b.cpp @@ -3055,24 +3055,6 @@ ROM_START( rambo3p ) /* Is this set a prototype or possible bootleg? */ ROM_LOAD( "r3-a4.rom", 0x60000, 0x20000, CRC(9cf4c21b) SHA1(756fc6bbc798a39a18eab3829e032cac8fe3f8ed) ) ROM_END -ROM_START( bublbust ) // Purportedly a location test version, but has the same version number and build date as the released Japanese set below - ROM_REGION( 0x80000, "maincpu", 0 ) // 512k for 68000 code - located on Taito C0503005B main board - ROM_LOAD16_BYTE( "p.bobble_prg_h_usa_6-15_c681.ic18", 0x00000, 0x40000, CRC(ba83e398) SHA1(2512ea5a805f0e5c470c4d216d679f3dc3c4aa82) ) // hand written label P.Bobble PRG H USA 6/15 C681 - "Bobble" written in Kanji - ROM_LOAD16_BYTE( "p.bobble_prg_l_usa_6-15_e9e1.ic2", 0x00001, 0x40000, CRC(a12cb3f2) SHA1(06271d3a0af101a959e6e777f1f9e99bae1e6076) ) // hand written label P.Bobble PRG L USA 6/15 E9E1 - "Bobble" written in Kanji - - ROM_REGION( 0x20000, "audiocpu", 0 ) // 128k for Z80 code - located on Taito C0503005B main board - ROM_LOAD( "prg_snd.ic27", 0x00000, 0x20000, CRC(2f288fe0) SHA1(4ba707f4b3a1ca0e573652d1c733ee889f9fef8a) ) // hand written label PRG SND IC 27 - no checksum listed - - ROM_REGION( 0x100000, "tc0180vcu", 0 ) // located on Taito C0503002A ROM PCB - ROM_LOAD16_BYTE( "p.bobble_chr-1l_6-14_eaa0.ic11_ch_1_0l", 0x00000, 0x40000, CRC(8d3fa2f0) SHA1(3d36944e35081740469df61a40e538eb94ea2ef6) ) // hand written label P.Bobble CHR 1L 6/14 EAA0 - "Bobble" written in Kanji - ROM_LOAD16_BYTE( "p.bobble_chr-1h_6-14_1515.ic12_ch_1_0h", 0x00001, 0x40000, CRC(a2eb4d32) SHA1(571811a543af50cc5e0f1d7aad9fc388919e93e6) ) // hand written label P.Bobble CHR 1H 6/14 1515 - "Bobble" written in Kanji - ROM_LOAD16_BYTE( "p.bobble_chr-0l_6-14_86d5.ic7_ch_0_0l", 0x80000, 0x40000, CRC(80f1aab0) SHA1(f5cdb93aa702fb8ba91eaf8f470b6e2a61a581b5) ) // hand written label P.Bobble CHR 0L 6/14 86D5 - "Bobble" written in Kanji - ROM_LOAD16_BYTE( "p.bobble_chr-0h_6-14_d180.ic8_ch_0_0h", 0x80001, 0x40000, CRC(d773cac8) SHA1(b008a21c39650a28cba402cd1c4de0567e275bc9) ) // hand written label P.Bobble CHR 0H 6/14 D180 - "Bobble" written in Kanji - - ROM_REGION( 0x100000, "ymsnd:adpcma", 0 ) // located on Taito C0503002A ROM PCB - Half the size of the Japanese ADPCMA sample ROM - ROM_LOAD( "ach0-kaigai.ic15_ach_0", 0x00000, 0x80000, CRC(f203ae52) SHA1(d41b880ef17eea6614e2911318db5cd070473381) ) // hand written ??? -ROM_END - ROM_START( pbobble ) ROM_REGION( 0x80000, "maincpu", 0 ) /* 512k for 68000 code */ ROM_LOAD16_BYTE( "pb-1c18.bin", 0x00000, 0x40000, CRC(5de14f49) SHA1(91d537748f26e19a5c32de4b8dad341750de39ef) ) @@ -3089,6 +3071,24 @@ ROM_START( pbobble ) ROM_LOAD( "pb-ic15.bin", 0x000000, 0x100000, CRC(0840cbc4) SHA1(1adbd7aef44fa80832f63dfb8efdf69fd7256a57) ) ROM_END +ROM_START( bublbust ) // Purportedly a location test version, but has the same version number and build date as the released Japanese set below + ROM_REGION( 0x80000, "maincpu", 0 ) // 512k for 68000 code - located on Taito C0503005B main board + ROM_LOAD16_BYTE( "p.bobble_prg_h_kyotsu_6-15_c681.ic18", 0x00000, 0x40000, CRC(ba83e398) SHA1(2512ea5a805f0e5c470c4d216d679f3dc3c4aa82) ) // hand written label P.ボブル PRG H 共通 6/15 C681 + ROM_LOAD16_BYTE( "p.bobble_prg_l_usa_6-15_e9e1.ic2", 0x00001, 0x40000, CRC(a12cb3f2) SHA1(06271d3a0af101a959e6e777f1f9e99bae1e6076) ) // hand written label P.ボブル PRG L USA 6/15 E9E1 + + ROM_REGION( 0x20000, "audiocpu", 0 ) // 128k for Z80 code - located on Taito C0503005B main board + ROM_LOAD( "prg_snd.ic27", 0x00000, 0x20000, CRC(2f288fe0) SHA1(4ba707f4b3a1ca0e573652d1c733ee889f9fef8a) ) // hand written label PRG SND IC 27 - no checksum listed + + ROM_REGION( 0x100000, "tc0180vcu", 0 ) // located on Taito C0503002A ROM PCB + ROM_LOAD16_BYTE( "p.bobble_chr-1l_6-14_eaa0.ic11_ch_1_0l", 0x00000, 0x40000, CRC(8d3fa2f0) SHA1(3d36944e35081740469df61a40e538eb94ea2ef6) ) // hand written label P.ボブル CHR 1L 6/14 EAA0 + ROM_LOAD16_BYTE( "p.bobble_chr-1h_6-14_1515.ic12_ch_1_0h", 0x00001, 0x40000, CRC(a2eb4d32) SHA1(571811a543af50cc5e0f1d7aad9fc388919e93e6) ) // hand written label P.ボブル CHR 1H 6/14 1515 + ROM_LOAD16_BYTE( "p.bobble_chr-0l_6-14_86d5.ic7_ch_0_0l", 0x80000, 0x40000, CRC(80f1aab0) SHA1(f5cdb93aa702fb8ba91eaf8f470b6e2a61a581b5) ) // hand written label P.ボブル CHR 0L 6/14 86D5 + ROM_LOAD16_BYTE( "p.bobble_chr-0h_6-14_d180.ic8_ch_0_0h", 0x80001, 0x40000, CRC(d773cac8) SHA1(b008a21c39650a28cba402cd1c4de0567e275bc9) ) // hand written label P.ボブル CHR 0H 6/14 D180 (label torn, checksum illegible besides final 0) + + ROM_REGION( 0x100000, "ymsnd:adpcma", 0 ) // located on Taito C0503002A ROM PCB - Half the size of the Japanese ADPCMA sample ROM + ROM_LOAD( "cr40-kaigai-7bec.ic15_ach_0", 0x00000, 0x80000, CRC(f203ae52) SHA1(d41b880ef17eea6614e2911318db5cd070473381) ) // hand written label CR40 海外 7BEC +ROM_END + ROM_START( spacedx ) ROM_REGION( 0x80000, "maincpu", 0 ) /* 512k for 68000 code */ ROM_LOAD16_BYTE( "d89-06", 0x00000, 0x40000, CRC(7122751e) SHA1(4b4eb58af28f1988ff102251407449d0affbd4c2) ) @@ -3574,8 +3574,8 @@ GAME( 1993, ryujina, ryujin, selfeena, ryujin, taitob_state, init_taito_b, GAME( 1993, qzshowby, 0, qzshowby, qzshowby, taitob_state, init_taito_b, ROT0, "Taito Corporation", "Quiz Sekai wa SHOW by shobai (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1994, bublbust, 0, pbobble, pbobble, taitob_state, init_taito_b, ROT0, "Taito America Corporation", "Bubble Buster (USA, B-System)", MACHINE_SUPPORTS_SAVE ) // PUZZLE VER 2.0A 1994/06/15 15:28:30 - Location test but same build as Japan release? -GAME( 1994, pbobble, bublbust,pbobble, pbobble, taitob_state, init_taito_b, ROT0, "Taito Corporation", "Puzzle Bobble (Japan, B-System)", MACHINE_SUPPORTS_SAVE ) // PUZZLE VER 2.0J 1994/06/15 15:28:30 +GAME( 1994, pbobble, 0, pbobble, pbobble, taitob_state, init_taito_b, ROT0, "Taito Corporation", "Puzzle Bobble (Japan, B-System)", MACHINE_SUPPORTS_SAVE ) // PUZZLE VER 2.0J 1994/06/15 15:28:30 +GAME( 1994, bublbust, pbobble, pbobble, pbobble, taitob_state, init_taito_b, ROT0, "Taito America Corporation", "Bubble Buster (USA, B-System)", MACHINE_SUPPORTS_SAVE ) // PUZZLE VER 2.0A 1994/06/15 15:28:30 - Location test but same build as Japan release? GAME( 1994, spacedx, 0, spacedx, pbobble, taitob_state, init_taito_b, ROT0, "Taito Corporation", "Space Invaders DX (US, v2.1)", MACHINE_SUPPORTS_SAVE ) GAME( 1994, spacedxj, spacedx, spacedx, pbobble, taitob_state, init_taito_b, ROT0, "Taito Corporation", "Space Invaders DX (Japan, v2.1)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/taito_f2.cpp b/src/mame/drivers/taito_f2.cpp index f637c6b6fbd..71714997687 100644 --- a/src/mame/drivers/taito_f2.cpp +++ b/src/mame/drivers/taito_f2.cpp @@ -2562,7 +2562,9 @@ static INPUT_PORTS_START( yuyugogo ) PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW2:4" ) PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW2:5" ) PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW2:6" ) - PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW2:7" ) + PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SW2:7") + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW2:8" ) PORT_START("IN0") diff --git a/src/mame/drivers/taito_f3.cpp b/src/mame/drivers/taito_f3.cpp index 3138dc16e99..c9fb676644e 100644 --- a/src/mame/drivers/taito_f3.cpp +++ b/src/mame/drivers/taito_f3.cpp @@ -203,7 +203,7 @@ void taito_f3_state::f3_map(address_map &map) map(0xc80100, 0xc80103).w(FUNC(taito_f3_state::sound_reset_1_w)); } -void taito_f3_state::bubsympb_oki_w(u8 data) +void taito_f3_state::bubsympb_oki_w(u8 data) // TODO: this is wrong. PCB reference: https://www.youtube.com/watch?v=UbgPg8qUDig { //printf("write %08x %08x\n",data,mem_mask); const u8 bank = data & 0xf; @@ -213,7 +213,7 @@ void taito_f3_state::bubsympb_oki_w(u8 data) } else { - logerror("unknown oki bank write %02x at %08x", bank, m_maincpu->pc()); + logerror("unknown oki bank write %02x at %08x\n", bank, m_maincpu->pc()); } //printf("oki bank w %08x\n",data); } @@ -2413,10 +2413,38 @@ ROM_START( bubsymphb ) ROM_LOAD ("bsb_d11b.bin", 0x000000, 0x080000, CRC(d0607829) SHA1(546c629ec22bb98202c7127ccb77df0b8f3a1966) ) ROM_REGION( 0x100000, "oki" , ROMREGION_ERASE00 ) // OKI6295 samples - ROM_LOAD("bsb_d11.bin", 0x000000, 0x080000, CRC(26bdc617) SHA1(993e7a52128fdd58f22d95521a629beb71ca7b91) ) // I haven't verified this dump.. but given how bad the rest is I'm not confident + ROM_LOAD("bsb_d11.bin", 0x000000, 0x080000, CRC(26bdc617) SHA1(993e7a52128fdd58f22d95521a629beb71ca7b91) ) ROM_RELOAD(0x80000,0x80000) ROM_END +ROM_START( bubsymphba ) // extremely similar to bubsymphb (i.e. the only differences in the program ROMs are copyright removals). 2 PCB set: 70121 MAIN + ROM board + ROM_REGION( 0x200000, "maincpu", 0 ) + ROM_LOAD32_BYTE( "2-27c2000.bin", 0x000000, 0x40000, CRC(b26728fa) SHA1(accd2530a5d0aa8baa4598a8312e8c8fd283008f) ) + ROM_LOAD32_BYTE( "3-27c2000.bin", 0x000001, 0x40000, CRC(d7406de1) SHA1(7d064b249ff576058b762bf2b8dd6dc55bb88ec6) ) + ROM_LOAD32_BYTE( "4-27c2000.bin", 0x000002, 0x40000, CRC(5a45a291) SHA1(54a53b3c1c057dabbca5e72b289a4f0f96048311) ) + ROM_LOAD32_BYTE( "5-27c2000.bin", 0x000003, 0x40000, CRC(aad3806b) SHA1(5999c0dd78374b3adc2223ff76478eb2604fc8b8) ) + + ROM_REGION( 0x300000, "sprites" , ROMREGION_ERASE00) + ROM_LOAD16_WORD_SWAP( "8-27c4000.bin", 0x080000, 0x080000, CRC(22d7eeb5) SHA1(30aa4493c5bc98d9256817b9e3341b20d2b76f1f) ) + ROM_LOAD16_WORD_SWAP( "9-27c4000.bin", 0x100000, 0x080000, CRC(b8f7b1c6) SHA1(c51aa9168eab4083b5ce0e6c0da6ad6416bd17bd) ) + ROM_LOAD16_WORD_SWAP( "10-27c4000.bin", 0x180000, 0x080000, CRC(d4981f73) SHA1(25c574aae85e185e01ba451dd15a4b4e14314f78) ) + ROM_LOAD16_WORD_SWAP( "7-27c4000.bin", 0x200000, 0x080000, CRC(c1c35f7b) SHA1(9e7c821d9f717c56f9cc32f724046a40cc5e336e) ) + ROM_LOAD16_WORD_SWAP( "6-27c4000.bin", 0x280000, 0x080000, CRC(35a60e28) SHA1(29504c9c2308443aa0b2cd1cd489fcb95737821a) ) + + ROM_REGION( 0x200000, "tilemap" , 0) + ROM_LOAD32_BYTE( "11-27c4000.bin", 0x000000, 0x080000, CRC(69f814b1) SHA1(9daaaff3652798006fa5432890bdc7c64fbb84c4) ) + ROM_LOAD32_BYTE( "12-27c4000.bin", 0x000001, 0x080000, CRC(95add6ec) SHA1(5e33624921438bbf785313bd04b1860bd91097d3) ) + ROM_LOAD32_BYTE( "13-27c4000.bin", 0x000002, 0x080000, CRC(5d87b202) SHA1(1625be0d8222388066694cd56c69b5768edd9513) ) + ROM_LOAD32_BYTE( "14-27c4000.bin", 0x000003, 0x080000, CRC(8be51e5a) SHA1(69ea6c778eaea246bd763c93f087b6ae1ebf2e1e) ) + + ROM_REGION( 0x080000, "tilemap_hi", 0 ) + ROM_LOAD( "15-27c4000.bin", 0x000000, 0x080000, CRC(45b3cf43) SHA1(f97684b69a56717b1e712dac1f8ff924d3775de0) ) + + ROM_REGION( 0x100000, "oki" , ROMREGION_ERASE00 ) + ROM_LOAD( "1-27c4000.bin", 0x000000, 0x080000, CRC(26bdc617) SHA1(993e7a52128fdd58f22d95521a629beb71ca7b91) ) + ROM_RELOAD( 0x80000, 0x80000 ) +ROM_END + ROM_START( bubsymphu ) ROM_REGION( 0x200000, "maincpu", 0 ) /* 68020 code */ ROM_LOAD32_BYTE("d90-12", 0x000000, 0x40000, CRC(9e523996) SHA1(c49a426f9865f96e8021c8ed9a6ac094c5e586b1) ) @@ -4686,7 +4714,8 @@ GAME( 1994, bublbob2p, bublbob2, f3_224a, f3, taito_f3_state, init_bubsymph, RO GAME( 1994, bubsymphe, bublbob2, f3_224a, f3, taito_f3_state, init_bubsymph, ROT0, "Taito Corporation Japan", "Bubble Symphony (Ver 2.5O 1994/10/05)", 0 ) GAME( 1994, bubsymphu, bublbob2, f3_224a, f3, taito_f3_state, init_bubsymph, ROT0, "Taito America Corporation", "Bubble Symphony (Ver 2.5A 1994/10/05)", 0 ) GAME( 1994, bubsymphj, bublbob2, f3_224a, f3, taito_f3_state, init_bubsymph, ROT0, "Taito Corporation", "Bubble Symphony (Ver 2.5J 1994/10/05)", 0 ) -GAME( 1994, bubsymphb, bublbob2, bubsympb,f3, taito_f3_state, init_bubsympb, ROT0, "bootleg", "Bubble Symphony (bootleg with OKI6295)", MACHINE_NOT_WORKING ) // backgrounds don't display +GAME( 1994, bubsymphb, bublbob2, bubsympb,f3, taito_f3_state, init_bubsympb, ROT0, "bootleg", "Bubble Symphony (bootleg with OKI6295)", MACHINE_IMPERFECT_SOUND | MACHINE_NOT_WORKING ) // backgrounds don't display, OKI banking is wrong +GAME( 1994, bubsymphba, bublbob2, bubsympb,f3, taito_f3_state, init_bubsympb, ROT0, "bootleg (SOFTV)", "Seoul Symphony (Bubble Symphony bootleg with OKI6295)", MACHINE_IMPERFECT_SOUND | MACHINE_NOT_WORKING ) // backgrounds don't display, OKI banking is wrong GAME( 1994, spcinvdj, spacedx, f3, f3, taito_f3_state, init_spcinvdj, ROT0, "Taito Corporation", "Space Invaders DX (Ver 2.6J 1994/09/14) (F3 Version)", 0 ) GAME( 1994, pwrgoal, 0, f3_224a, f3, taito_f3_state, init_hthero95, ROT0, "Taito Corporation Japan", "Taito Power Goal (Ver 2.5O 1994/11/03)", 0 ) GAME( 1994, hthero95, pwrgoal, f3_224a, f3, taito_f3_state, init_hthero95, ROT0, "Taito Corporation", "Hat Trick Hero '95 (Ver 2.5J 1994/11/03)", 0 ) diff --git a/src/mame/drivers/viper.cpp b/src/mame/drivers/viper.cpp index fc743fcf438..dcbc4dd5c97 100644 --- a/src/mame/drivers/viper.cpp +++ b/src/mame/drivers/viper.cpp @@ -16,7 +16,7 @@ IRQ0: ??? (Task 4) IRQ1: unused IRQ2: ??? Possibly UART? Accesses registers at 0xffe00008...f - IRQ3: ??? (Task 5, sound?) + IRQ3: Sound (Task 5) IRQ4: Voodoo3 Currently only for User Interrupt Command, maybe a more extensive handler gets installed later? I2C: ??? (no task switch) what drives this? network? U13 (ADC838) test fails if I2C doesn't work @@ -37,6 +37,13 @@ 0x08: unknown mem pointer, task stack pointer? 0x0c: pointer to task PC (also top of stack?) + Sound: + 0x00001320: A flag that's used when sound effects(?) are being played + 0x00001324: Pointer to the data cache buffer to be used for loading and mixing BGM/SE. + Each buffer is 0x800 bytes in size and the game will switch between the two every IRQ3(?). + The original audio typically seems to be ADPCM which is then decoded and mixed in software. + 0x00001330: L/R channel PCM data when a sound effect is played? Seems to be the last result when mixing down buffers. + 0x00000310: Global timer 0 IRQ handler 0x00000320: Global timer 1 IRQ handler @@ -75,27 +82,45 @@ TODO: - needs a proper way to dump security dongles, anything but p9112 has placeholder ROM for ds2430. + - figure out why games randomly crash (IRQ related?) + + Other notes: + - "Distribution error" means there's a region mismatch. + - Games that hang randomly seem to hang on IRQ16 possibly? You can see "IRQ16 taken" but it hangs before you see "IRQ16 cleared". + - Hold TEST while booting (from the very start) to initialize the RTC for most games. + - It seems that p911 has 3 unique regional images: U/E, K/A, and J. If you try booting, for example, U region on a K/A image, it won't find some files and will error out with "distribution error". Game status: - ppp2nd Boots in-game, no sound or DVD support, crashes when going into song selection screen - boxingm Goes to attract mode when ran with memory card check. Coins up. - code1d,b RTC self check bad - gticlub2,ea Attract mode works. Coins up. Hangs in car selection. - jpark3 POST?: Shows "Now loading..." then black screen (sets global timer 1 on EPIC) - with IRQ3 crashes at first 3d frame - mocapglf Sensor I/O error - mocapb,j Crash after self checks - p911 "Distribution error" - p911e,j,uc,kc Hangs at POST, with IRQ3 it crashes at first 3d frame - p9112 RTC self check bad + boxingm Goes in-game. Controllers are not emulated. Various graphical glitches. + jpark3 Goes in-game. Controllers are not emulated. Various graphical glitches. + mocapb,j Goes in-game. Controllers are not emulated. Various graphical glitches. Random crashes. + ppp2nd,a Fully playable with graphical glitches. No network or DVD support. Crashes when returning to game mode from test menu. + p911(all) Goes in-game. Controllers are not emulated. Various graphical glitches. + tsurugi,j Goes in-game. Controllers are not emulated. Various graphical glitches. + + gticlub2,ea Attract mode works. Coins up. Hangs in various places. Will crash with "network error" after stage is selected. + thrild2,a Attract mode with partial graphics. Coins up. Hangs in various places. + + sscopefh Graphics heavily glitched. Gun controller is not emulated. Sensor error and hopper error stop it from working. + + mfightc,c Requires touch panel emulation. Gets stuck at "Waiting for central monitor, checking serial...". + xtrial Hangs at "Please set the time for the bookkeeping" message. + + p9112 RTC self check bad. + The game checks the checksum of 0x157d4d0-0x157d4ee against the checksum that should be at 0x157d4ee-0x157d4ef, + but this part of memory is never written to after its initial clearing on boot. + If 0xffff is placed at 0x157d4ee then the game will pass the RTC check. + The game will later complain about "Hardware Error: Security Key Error" if you try starting the game. + code1d,b Can boot but crashes randomly and quickly so it's hard to do anything. + + mocapglf Security code error sscopex/sogeki Security code error - sscopefh Needs gun inputs. - thrild2,a Attract mode with partial graphics. Coins up. Hangs in car selection screen. - thrild2c Inf loop on blue screen - tsurugi Goes to attract mode when ran with memory card check. Coins up. - tsurugij No NVRAM - wcombat Stuck on network check - xtrial Attract mode. Hangs. - mfightc,c Passes POST. Waits for network connection from main unit? Spams writes to 0xffe08000 (8-bit) + + wcombat Can boot into a test menu by using a combination of dipswitches, but it says "serial check bad". Can't boot normally. + wcombatu Bootable when dipsw 4 is set to on. Controls not implemented so it's not possible to pass nickname selection screen. Freezes when test button is pressed. + thrild2c,ac Inf loop on blue screen + + =========================================================================================================================== @@ -286,6 +311,16 @@ Player 2 gun connects to the same pin numbers on the solder side. Jurassic Park III also uses 2 additional buttons for escaping left and right. These are wired to buttons on the Jamma connector. +Additionally on the 28-WAY connector is... +Pin 7 parts side - Serial TX +Pin 7 solder side - Serial RX +Pin 8 solder side - GND (used by serial) + +Pin 9 parts side - SP_LP (outputs to SP-F, front speaker) +Pin 9 solder side - SP_LN +Pin 9 parts side - SP_RP (output splits into SP-BL and SP-BR, rear speaker(s)) +Pin 9 solder side - SP_RN + Measurements ------------ @@ -355,6 +390,7 @@ some other components. It will be documented at a later date. #include "machine/lpci.h" #include "machine/timekpr.h" #include "machine/timer.h" +#include "sound/dmadac.h" #include "video/voodoo_banshee.h" #include "emupal.h" #include "screen.h" @@ -385,7 +421,8 @@ public: m_workram(*this, "workram"), m_ds2430_rom(*this, "ds2430"), m_io_ports(*this, "IN%u", 0U), - m_io_ppp_sensors(*this, "SENSOR%u", 1U) + m_io_ppp_sensors(*this, "SENSOR%u", 1U), + m_dmadac(*this, { "dacr", "dacl" }) { } @@ -395,7 +432,6 @@ public: void init_viper(); void init_vipercf(); void init_viperhd(); - void init_viperppp(); DECLARE_READ_LINE_MEMBER(ds2430_unk_r); @@ -458,6 +494,10 @@ private: uint16_t m_unk_serial_data_r; uint8_t m_unk_serial_regs[0x80]; uint64_t m_e00008_data; + uint32_t m_sound_buffer_offset; + bool m_sound_irq_enabled; + + TIMER_DEVICE_CALLBACK_MEMBER(sound_timer_callback); // MPC8240 EPIC, to be device-ified enum @@ -574,6 +614,7 @@ private: required_region_ptr<uint8_t> m_ds2430_rom; required_ioport_array<8> m_io_ports; optional_ioport_array<4> m_io_ppp_sensors; + required_device_array<dmadac_sound_device, 2> m_dmadac; uint32_t mpc8240_pci_r(int function, int reg, uint32_t mem_mask); void mpc8240_pci_w(int function, int reg, uint32_t data, uint32_t mem_mask); @@ -2074,7 +2115,8 @@ void viper_state::viper_map(address_map &map) map(0xffe00008, 0xffe0000f).rw(FUNC(viper_state::e00008_r), FUNC(viper_state::e00008_w)); map(0xffe08000, 0xffe08007).noprw(); map(0xffe10000, 0xffe10007).r(FUNC(viper_state::input_r)); - map(0xffe28000, 0xffe28007).nopw(); // ppp2nd lamps + map(0xffe28000, 0xffe28007).nopw(); // ppp2nd leds + map(0xffe28008, 0xffe2801f).nopw(); // boxingm reads and writes here to read the pad sensor values map(0xffe30000, 0xffe31fff).rw("m48t58", FUNC(timekeeper_device::read), FUNC(timekeeper_device::write)); map(0xffe40000, 0xffe4000f).noprw(); map(0xffe50000, 0xffe50007).w(FUNC(viper_state::unk2_w)); @@ -2084,12 +2126,14 @@ void viper_state::viper_map(address_map &map) map(0xffe88000, 0xffe88007).w(FUNC(viper_state::unk1b_w)); map(0xffe98000, 0xffe98007).noprw(); map(0xffe9a000, 0xffe9bfff).ram(); // World Combat uses this + map(0xffea0000, 0xffea0007).noprw(); // Gun sensor? Read heavily by p9112 map(0xfff00000, 0xfff3ffff).rom().region("user1", 0); // Boot ROM } void viper_state::viper_ppp_map(address_map &map) { viper_map(map); + map(0xff400108, 0xff40012f).nopw(); // ppp2nd lamps map(0xff400200, 0xff40023f).r(FUNC(viper_state::ppp_sensor_r)); } @@ -2114,10 +2158,10 @@ static INPUT_PORTS_START( viper ) PORT_DIPNAME( 0x02, 0x02, "DIP3" ) PORT_DIPLOCATION("SW:3") PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_DIPNAME( 0x04, 0x00, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW:2") - PORT_DIPSETTING( 0x04, DEF_STR( Yes ) ) - PORT_DIPSETTING( 0x00, DEF_STR( No ) ) - PORT_DIPNAME( 0x08, 0x00, "DIP1" ) PORT_DIPLOCATION("SW:1") + PORT_DIPNAME( 0x04, 0x04, "DIP2" ) PORT_DIPLOCATION("SW:2") + PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_DIPNAME( 0x08, 0x08, "DIP1" ) PORT_DIPLOCATION("SW:1") PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) @@ -2127,7 +2171,7 @@ static INPUT_PORTS_START( viper ) PORT_START("IN3") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW ) /* Test Button */ + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Test Button") PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) @@ -2229,6 +2273,14 @@ INPUT_PORTS_END INPUT_PORTS_START( thrild2 ) PORT_INCLUDE( viper ) + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x04, 0x00, "Calibrate Controls On Boot" ) PORT_DIPLOCATION("SW:2") // Game crashes during boot when this is on + PORT_DIPSETTING( 0x04, DEF_STR( Yes ) ) + PORT_DIPSETTING( 0x00, DEF_STR( No ) ) + PORT_DIPNAME( 0x08, 0x00, "Memory Card Check On Boot" ) PORT_DIPLOCATION("SW:1") + PORT_DIPSETTING( 0x08, DEF_STR( On ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) + PORT_MODIFY("IN3") PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Shift Down") @@ -2256,10 +2308,15 @@ INPUT_PORTS_END INPUT_PORTS_START( boxingm ) PORT_INCLUDE( viper ) + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x04, 0x04, "Calibrate Pads On Boot" ) PORT_DIPLOCATION("SW:2") + PORT_DIPSETTING( 0x04, DEF_STR( Yes ) ) + PORT_DIPSETTING( 0x00, DEF_STR( No ) ) + PORT_MODIFY("IN4") - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("BodyPad L") - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Select R") PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Select L") + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Select R") + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("BodyPad L") PORT_MODIFY("IN5") PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("BodyPad R") @@ -2283,15 +2340,88 @@ INPUT_PORTS_END INPUT_PORTS_START( p911 ) PORT_INCLUDE( viper ) + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x04, 0x00, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW:2") + PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) + PORT_DIPSETTING( 0x04, DEF_STR( No ) ) + PORT_DIPNAME( 0x08, 0x00, "Memory Card Check On Boot" ) PORT_DIPLOCATION("SW:1") + PORT_DIPSETTING( 0x08, DEF_STR( On ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) + PORT_MODIFY("IN4") PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gun Trigger") PORT_MODIFY("IN5") - // one of these is P2 SHT2 (checks and fails serial if pressed) - PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) // P2 SHT2 (checks and fails serial if pressed) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END +INPUT_PORTS_START( mfightc ) + PORT_INCLUDE( viper ) + + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x01, 0x00, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW:2") + PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) + PORT_DIPSETTING( 0x01, DEF_STR( No ) ) + + PORT_MODIFY("IN4") + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // If off, will get stuck after RTC OK + + PORT_MODIFY("IN5") + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // if off tries to check UART +INPUT_PORTS_END + +INPUT_PORTS_START( mocapglf ) + PORT_INCLUDE( viper ) + + PORT_MODIFY("IN4") + PORT_DIPNAME( 0x40, 0x40, "Show Diagnostics On Boot" ) // Shows UART status, lamp status, and accelerometer values + PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) + PORT_DIPSETTING( 0x40, DEF_STR( No ) ) + +INPUT_PORTS_END + +INPUT_PORTS_START( mocapb ) + PORT_INCLUDE( viper ) + + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x08, 0x00, "Memory Card Check On Boot" ) PORT_DIPLOCATION("SW:1") + PORT_DIPSETTING( 0x08, DEF_STR( On ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) + + PORT_MODIFY("IN4") + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Left Button") + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Right Button") + + PORT_MODIFY("IN5") + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) // P2 SHT2 (checks and fails serial if pressed) +INPUT_PORTS_END + +INPUT_PORTS_START( sscopefh ) + PORT_INCLUDE( viper ) + + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x04, 0x00, "DIP2" ) PORT_DIPLOCATION("SW:2") // Without this switched on, the screen will be static + PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_DIPNAME( 0x08, 0x00, "Memory Card Check On Boot" ) PORT_DIPLOCATION("SW:1") + PORT_DIPSETTING( 0x08, DEF_STR( On ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) + + PORT_MODIFY("IN3") + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Refill Key") + + PORT_MODIFY("IN4") + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_NAME("Credit 2 Pounds") // Currency probably changes between regions + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN4 ) PORT_NAME("Credit 1 Pound") // Can be used in refill mode to insert coins into the hopper + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN5 ) PORT_NAME("Credit 0.50 Pounds") + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gun Trigger") + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN6 ) PORT_NAME("Credit 0.20 Pounds") + + PORT_MODIFY("IN5") + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) // P2 SHT2 (checks and fails serial if pressed) +INPUT_PORTS_END + INPUT_PORTS_START( tsurugi ) PORT_INCLUDE( viper ) @@ -2304,6 +2434,58 @@ INPUT_PORTS_START( tsurugi ) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // sensor grip (1) horizontal (0) vertical INPUT_PORTS_END +INPUT_PORTS_START( wcombat ) + PORT_INCLUDE( viper ) + + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x01, 0x00, "DIP4" ) PORT_DIPLOCATION("SW:4") // Skip device check? wcombatu is playable when this is set + PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_DIPNAME( 0x04, 0x04, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW:2") + PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) + PORT_DIPSETTING( 0x04, DEF_STR( No ) ) + PORT_DIPNAME( 0x08, 0x00, "Memory Card Check On Boot" ) PORT_DIPLOCATION("SW:1") + PORT_DIPSETTING( 0x08, DEF_STR( On ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) + + PORT_MODIFY("IN3") + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) + + PORT_MODIFY("IN4") + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // X flip screen +INPUT_PORTS_END + +INPUT_PORTS_START( xtrial ) + PORT_INCLUDE( viper ) + + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x04, 0x00, "Calibrate Controls On Boot" ) PORT_DIPLOCATION("SW:2") // Game crashes during boot when this is on + PORT_DIPSETTING( 0x04, DEF_STR( Yes ) ) + PORT_DIPSETTING( 0x00, DEF_STR( No ) ) + PORT_DIPNAME( 0x08, 0x00, "Memory Card Check On Boot" ) PORT_DIPLOCATION("SW:1") // Crashes at 45% when card checks are enabled + PORT_DIPSETTING( 0x08, DEF_STR( On ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) +INPUT_PORTS_END + +INPUT_PORTS_START( code1d ) + PORT_INCLUDE( viper ) + + PORT_MODIFY("IN2") + PORT_DIPNAME( 0x01, 0x00, "DIP4" ) PORT_DIPLOCATION("SW:4") // Unknown, but without this set the game won't display anything besides a blue screen + PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_DIPNAME( 0x04, 0x00, "Calibrate Controls On Boot" ) PORT_DIPLOCATION("SW:2") // Game crashes during boot when this is on + PORT_DIPSETTING( 0x04, DEF_STR( Yes ) ) + PORT_DIPSETTING( 0x00, DEF_STR( No ) ) + PORT_DIPNAME( 0x08, 0x00, "Memory Card Check On Boot" ) PORT_DIPLOCATION("SW:1") + PORT_DIPSETTING( 0x08, DEF_STR( On ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) + + PORT_MODIFY("IN4") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Action Button") + +INPUT_PORTS_END + /*****************************************************************************/ INTERRUPT_GEN_MEMBER(viper_state::viper_vblank) @@ -2324,7 +2506,39 @@ WRITE_LINE_MEMBER(viper_state::voodoo_vblank) WRITE_LINE_MEMBER(viper_state::voodoo_pciint) { if (state) + { + // This is a hack. + // There's no obvious (to me) trigger for when it's safe to start the audio interrupts, but after testing all of the games that can boot, it's safe to start audio interrupts once pciint is triggering. + m_sound_irq_enabled = true; + mpc8240_interrupt(MPC8240_IRQ4); + } +} + +TIMER_DEVICE_CALLBACK_MEMBER(viper_state::sound_timer_callback) +{ + if (!m_sound_irq_enabled) + { + // If IRQ3 is triggered too soon into the boot process then it'll freeze on the blue boot screen. + return; + } + + mpc8240_interrupt(MPC8240_IRQ3); + + // Get samples from memory + int32_t* samplePtr = (int32_t*)(m_workram + (m_sound_buffer_offset >> 3)); + for (int i = 0; i < 2; i++) + { + m_dmadac[i]->transfer( + i, + 1, + 2, + 0x800 / 4 / 2, // Each buffer is 0x800 bytes in size, containing stereo 32-bit audio + samplePtr + ); + } + + m_sound_buffer_offset ^= 0x800; } void viper_state::machine_start() @@ -2346,6 +2560,8 @@ void viper_state::machine_start() save_item(NAME(m_unk_serial_data)); save_item(NAME(m_unk_serial_data_r)); save_item(NAME(m_unk_serial_regs)); + save_item(NAME(m_sound_buffer_offset)); + save_item(NAME(m_sound_irq_enabled)); save_item(NAME(m_ds2430_unk_status)); save_item(NAME(m_ds2430_data)); @@ -2398,6 +2614,16 @@ void viper_state::machine_reset() identify_device[51] = 0x0200; /* 51: PIO data transfer cycle timing mode */ identify_device[67] = 0x00f0; /* 67: minimum PIO transfer cycle time without flow control */ + m_sound_buffer_offset = 0xfff800; // The games swap between 0xfff800 and 0xfff000 every IRQ3 call + m_sound_irq_enabled = false; + + for (int i = 0; i < 2; i++) + { + m_dmadac[i]->initialize_state(); + m_dmadac[i]->set_frequency(44100); + m_dmadac[i]->enable(1); + } + m_ds2430_unk_status = 1; } @@ -2439,8 +2665,16 @@ void viper_state::viper(machine_config &config) /* sound hardware */ SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); + DMADAC(config, "dacl").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + DMADAC(config, "dacr").add_route(ALL_OUTPUTS, "rspeaker", 1.0); M48T58(config, "m48t58", 0); + + // Each IRQ3 will update the data buffers with 256 samples, and the playback rate is always 44100hz. + // The frequency is picked such that the DMADAC buffer should never overflow or underflow. + // Note that adjusting this value has gameplay consequences for ppp2nd: the gameplay's note and animation timings are tied directly to values updated using IRQ3, + // so having IRQ3 trigger too quickly or too slowly will mean that the gameplay will either be too fast or too slow. + TIMER(config, "sound_timer").configure_periodic(FUNC(viper_state::sound_timer_callback), attotime::from_hz(44100.0 / 256)); } void viper_state::viper_ppp(machine_config &config) @@ -2475,7 +2709,8 @@ void viper_state::init_vipercf() uint16_t viper_state::ppp_sensor_r(offs_t offset) { - switch(offset) { + switch(offset) + { case 0x06: return m_io_ppp_sensors[0]->read(); case 0x0e: return m_io_ppp_sensors[1]->read(); case 0x16: return m_io_ppp_sensors[2]->read(); @@ -2678,23 +2913,36 @@ ROM_START(p911) //* ROM_LOAD("ds2430.u3", 0x00, 0x28, BAD_DUMP CRC(f1511505) SHA1(ed7cd9b2763b3e377df9663943160f9871f65105)) ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00) /* M48T58 Timekeeper NVRAM */ - ROM_LOAD("a00uad_nvram.u39", 0x000000, 0x2000, CRC(cca056ca) SHA1(de1a00d84c1311d48bbe6d24f5b36e22ecf5e85a)) + ROM_LOAD("a00aae_nvram.u39", 0x000000, 0x2000, BAD_DUMP CRC(9ecd75a3) SHA1(f9db35b91d4ef7fd61f21382fc62a6428d0b0c52)) + + DISK_REGION( "ata:0:hdd:image" ) + DISK_IMAGE( "a00uad02", 0, SHA1(6acb8dc41920e7025b87034a3a62b185ef0109d9) ) // Actually is AAE/KAE +ROM_END + +ROM_START(p911k) //* + VIPER_BIOS + + ROM_REGION(0x28, "ds2430", ROMREGION_ERASE00) /* DS2430 */ + ROM_LOAD("ds2430.u3", 0x00, 0x28, BAD_DUMP CRC(f1511505) SHA1(ed7cd9b2763b3e377df9663943160f9871f65105)) + + ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00) /* M48T58 Timekeeper NVRAM */ + ROM_LOAD("a00kae_nvram.u39", 0x000000, 0x2000, BAD_DUMP CRC(157e0361) SHA1(a4e301f1c73d148b3c18c9c02b67692ffdd6a664)) DISK_REGION( "ata:0:hdd:image" ) - DISK_IMAGE( "a00uad02", 0, SHA1(6acb8dc41920e7025b87034a3a62b185ef0109d9) ) + DISK_IMAGE( "a00uad02", 0, SHA1(6acb8dc41920e7025b87034a3a62b185ef0109d9) ) // Actually is AAE/KAE ROM_END -ROM_START(p911uc) //* +ROM_START(p911ac) //* VIPER_BIOS ROM_REGION(0x28, "ds2430", ROMREGION_ERASE00) /* DS2430 */ ROM_LOAD("ds2430.u3", 0x00, 0x28, BAD_DUMP CRC(f1511505) SHA1(ed7cd9b2763b3e377df9663943160f9871f65105)) ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00) /* M48T58 Timekeeper NVRAM */ - ROM_LOAD("a00uac_nvram.u39", 0x000000, 0x2000, NO_DUMP ) + ROM_LOAD("a00aac_nvram.u39", 0x000000, 0x2000, BAD_DUMP CRC(d65742ce) SHA1(20055c0b701c62b0f01cfe619d07bd9532cc3b45)) DISK_REGION( "ata:0:hdd:image" ) - DISK_IMAGE( "a00uac02", 0, SHA1(b268789416dbf8886118a634b911f0ee254970de) ) + DISK_IMAGE( "a00uac02", 0, SHA1(b268789416dbf8886118a634b911f0ee254970de) ) // a00uac02 and a00kac02 are the same image ROM_END ROM_START(p911kc) //* @@ -2710,17 +2958,30 @@ ROM_START(p911kc) //* DISK_IMAGE( "a00kac02", 0, SHA1(b268789416dbf8886118a634b911f0ee254970de) ) ROM_END -ROM_START(p911e) //* +ROM_START(p911ud) //* VIPER_BIOS ROM_REGION(0x28, "ds2430", ROMREGION_ERASE00) /* DS2430 */ ROM_LOAD("ds2430.u3", 0x00, 0x28, BAD_DUMP CRC(f1511505) SHA1(ed7cd9b2763b3e377df9663943160f9871f65105)) ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00) /* M48T58 Timekeeper NVRAM */ - ROM_LOAD("a00eaa_nvram.u39", 0x000000, 0x2000, CRC(4f3497b6) SHA1(3045c54f98dff92cdf3a1fc0cd4c76ba82d632d7) ) + ROM_LOAD("a00uad_nvram.u39", 0x000000, 0x2000, BAD_DUMP CRC(c4f44a70) SHA1(d7946606bf72ca7a6f391c4832205ae6fb1ebd95) ) + + DISK_REGION( "ata:0:hdd:image" ) + DISK_IMAGE( "a00eaa02", 0, SHA1(81565a2dce2e2b0a7927078a784354948af1f87c) ) // Is actually UAD/EAD +ROM_END + +ROM_START(p911ed) //* + VIPER_BIOS + + ROM_REGION(0x28, "ds2430", ROMREGION_ERASE00) /* DS2430 */ + ROM_LOAD("ds2430.u3", 0x00, 0x28, BAD_DUMP CRC(f1511505) SHA1(ed7cd9b2763b3e377df9663943160f9871f65105)) + + ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00) /* M48T58 Timekeeper NVRAM */ + ROM_LOAD("a00ead_nvram.u39", 0x000000, 0x2000, BAD_DUMP CRC(0314fc96) SHA1(cbf421bb37f0a122944fbccf8f4c80380c89e094) ) DISK_REGION( "ata:0:hdd:image" ) - DISK_IMAGE( "a00eaa02", 0, SHA1(81565a2dce2e2b0a7927078a784354948af1f87c) ) + DISK_IMAGE( "a00eaa02", 0, SHA1(81565a2dce2e2b0a7927078a784354948af1f87c) ) // Is actually UAD/EAD ROM_END ROM_START(p911ea) @@ -2903,7 +3164,7 @@ ROM_START(tsurugij) //* ROM_LOAD("ds2430.u3", 0x00, 0x28, BAD_DUMP CRC(f1511505) SHA1(ed7cd9b2763b3e377df9663943160f9871f65105)) ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00) /* M48T58 Timekeeper NVRAM */ - ROM_LOAD("a30jac_nvram.u39", 0x00000, 0x2000, NO_DUMP ) + ROM_LOAD("a30jac_nvram.u39", 0x00000, 0x2000, BAD_DUMP CRC(0e2c0e61) SHA1(d77670e214f618652e67fa91e644750894a0c5c7)) DISK_REGION( "ata:0:hdd:image" ) DISK_IMAGE( "a30c02", 0, SHA1(533b5669b00884a800df9ba29651777a76559862) ) @@ -2919,7 +3180,7 @@ ROM_START(tsurugie) ROM_LOAD("nvram.u39", 0x000000, 0x2000, NO_DUMP ) DISK_REGION( "ata:0:hdd:image" ) - DISK_IMAGE( "a30eab02", 0, SHA1(fcc5b69f89e246f26ca4b8546cc409d3488bbdd9) ) + DISK_IMAGE( "a30eab02", 0, SHA1(fcc5b69f89e246f26ca4b8546cc409d3488bbdd9) ) // Incomplete dump? Is half the size of the other dumps ROM_END /* This CF card has sticker C22D02 */ @@ -3074,7 +3335,7 @@ ROM_START(mfightcc) //* ROM_LOAD("ds2430.u3", 0x00, 0x28, BAD_DUMP CRC(f1511505) SHA1(ed7cd9b2763b3e377df9663943160f9871f65105)) ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00) /* M48T58 Timekeeper NVRAM */ - ROM_LOAD("c09jac_nvram.u39", 0x00000, 0x2000, NO_DUMP ) + ROM_LOAD("c09jac_nvram.u39", 0x00000, 0x2000, BAD_DUMP CRC(2d100e2b) SHA1(209764130ec3279fe17fe98de6cd0780b80c148f)) DISK_REGION( "ata:0:hdd:image" ) DISK_IMAGE( "c09c04", 0, SHA1(bf5f7447d74399d34edd4eb6dfcca7f6fc2154f2) ) @@ -3089,44 +3350,46 @@ ROM_END /* Viper BIOS */ GAME(1999, kviper, 0, viper, viper, viper_state, init_viper, ROT0, "Konami", "Konami Viper BIOS", MACHINE_IS_BIOS_ROOT) -GAME(2001, ppp2nd, kviper, viper_ppp, ppp2nd, viper_state, init_viperhd, ROT0, "Konami", "ParaParaParadise 2nd Mix (JAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, ppp2nda, ppp2nd, viper_ppp, ppp2nd, viper_state, init_viperhd, ROT0, "Konami", "ParaParaParadise 2nd Mix (AAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) - -GAME(2001, boxingm, kviper, viper, boxingm, viper_state, init_vipercf, ROT0, "Konami", "Boxing Mania: Ashita no Joe (ver JAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2000, code1d, kviper, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Code One Dispatch (ver D)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2000, code1db, code1d, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Code One Dispatch (ver B)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, gticlub2, kviper, viper, gticlub2, viper_state, init_vipercf, ROT0, "Konami", "GTI Club: Corso Italiano (ver JAB)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, gticlub2ea,gticlub2, viper, gticlub2ea, viper_state, init_vipercf, ROT0, "Konami", "GTI Club: Corso Italiano (ver EAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, jpark3, kviper, viper, jpark3, viper_state, init_vipercf, ROT0, "Konami", "Jurassic Park 3 (ver EBC)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, jpark3u, jpark3, viper, jpark3, viper_state, init_vipercf, ROT0, "Konami", "Jurassic Park 3 (ver UA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, mocapglf, kviper, viper, viper, viper_state, init_vipercf, ROT90, "Konami", "Mocap Golf (ver UAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, mocapb, kviper, viper, viper, viper_state, init_vipercf, ROT90, "Konami", "Mocap Boxing (ver AAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, mocapbj, mocapb, viper, viper, viper_state, init_vipercf, ROT90, "Konami", "Mocap Boxing (ver JAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, p911, kviper, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 (ver UAD)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, p911uc, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 (ver UAC)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, p911kc, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 (ver KAC)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, p911e, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 24/7 (ver EAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, p911ea, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 24/7 (ver EAA, alt)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, p911j, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Keisatsukan Shinjuku 24ji (ver JAC)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, p9112, kviper, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 2 (VER. UAA:B)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, sscopex, kviper, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Silent Scope EX (ver UAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, sogeki, sscopex, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Sogeki (ver JAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, sscopefh, kviper, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Silent Scope Fortune Hunter", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, thrild2, kviper, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver EBB)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, thrild2j, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver JAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, thrild2a, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver AAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, thrild2ab, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver AAA, alt)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, thrild2ac, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver AAA, alt 2)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2001, thrild2c, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver EAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, tsurugi, kviper, viper, tsurugi, viper_state, init_vipercf, ROT0, "Konami", "Tsurugi (ver EAB)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, tsurugie, tsurugi, viper, tsurugi, viper_state, init_vipercf, ROT0, "Konami", "Tsurugi (ver EAB, alt)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, tsurugij, tsurugi, viper, tsurugi, viper_state, init_vipercf, ROT0, "Konami", "Tsurugi (ver JAC)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, wcombat, kviper, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "World Combat (ver AAD:B)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, wcombatb, wcombat, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "World Combat (ver AAD:B, alt)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, wcombatk, wcombat, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "World Combat (ver KBC:B)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, wcombatu, wcombat, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "World Combat / Warzaid (ver UCD:B)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, wcombatj, wcombat, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "World Combat (ver JAA)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, xtrial, kviper, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Xtrial Racing (ver JAB)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) - -GAME(2002, mfightc, kviper, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Mahjong Fight Club (ver JAD)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) -GAME(2002, mfightcc, mfightc, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Mahjong Fight Club (ver JAC)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND) +GAME(2001, ppp2nd, kviper, viper_ppp, ppp2nd, viper_state, init_viperhd, ROT0, "Konami", "ParaParaParadise 2nd Mix (JAA)", MACHINE_NOT_WORKING) +GAME(2001, ppp2nda, ppp2nd, viper_ppp, ppp2nd, viper_state, init_viperhd, ROT0, "Konami", "ParaParaParadise 2nd Mix (AAA)", MACHINE_NOT_WORKING) + +GAME(2001, boxingm, kviper, viper, boxingm, viper_state, init_vipercf, ROT0, "Konami", "Boxing Mania: Ashita no Joe (ver JAA)", MACHINE_NOT_WORKING) +GAME(2000, code1d, kviper, viper, code1d, viper_state, init_vipercf, ROT0, "Konami", "Code One Dispatch Ver 1.21 (ver UAD)", MACHINE_NOT_WORKING) +GAME(2000, code1db, code1d, viper, code1d, viper_state, init_vipercf, ROT0, "Konami", "Code One Dispatch Ver 1.16 (ver UAB)", MACHINE_NOT_WORKING) +GAME(2001, gticlub2, kviper, viper, gticlub2, viper_state, init_vipercf, ROT0, "Konami", "GTI Club: Corso Italiano (ver JAB)", MACHINE_NOT_WORKING) +GAME(2001, gticlub2ea,gticlub2, viper, gticlub2ea, viper_state, init_vipercf, ROT0, "Konami", "GTI Club: Corso Italiano (ver EAA)", MACHINE_NOT_WORKING) +GAME(2001, jpark3, kviper, viper, jpark3, viper_state, init_vipercf, ROT0, "Konami", "Jurassic Park 3 (ver EBC)", MACHINE_NOT_WORKING) +GAME(2001, jpark3u, jpark3, viper, jpark3, viper_state, init_vipercf, ROT0, "Konami", "Jurassic Park 3 (ver UBC)", MACHINE_NOT_WORKING) +GAME(2001, mocapglf, kviper, viper, mocapglf, viper_state, init_vipercf, ROT90, "Konami", "Mocap Golf (ver UAA)", MACHINE_NOT_WORKING) +GAME(2001, mocapb, kviper, viper, mocapb, viper_state, init_vipercf, ROT90, "Konami", "Mocap Boxing (ver AAB)", MACHINE_NOT_WORKING) +GAME(2001, mocapbj, mocapb, viper, mocapb, viper_state, init_vipercf, ROT90, "Konami", "Mocap Boxing (ver JAA)", MACHINE_NOT_WORKING) +GAME(2001, p911, kviper, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 (ver AAE)", MACHINE_NOT_WORKING) +GAME(2001, p911k, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 (ver KAE)", MACHINE_NOT_WORKING) +GAME(2001, p911ac, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 (ver AAC)", MACHINE_NOT_WORKING) +GAME(2001, p911kc, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 (ver KAC)", MACHINE_NOT_WORKING) +GAME(2001, p911ud, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 24/7 (ver UAD)", MACHINE_NOT_WORKING) +GAME(2001, p911ed, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 24/7 (ver EAD)", MACHINE_NOT_WORKING) +GAME(2001, p911ea, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 24/7 (ver EAD, alt)", MACHINE_NOT_WORKING) +GAME(2001, p911j, p911, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Keisatsukan Shinjuku 24ji (ver JAE)", MACHINE_NOT_WORKING) +GAME(2001, p9112, kviper, viper, p911, viper_state, init_vipercf, ROT90, "Konami", "Police 911 2 (VER. UAA:B)", MACHINE_NOT_WORKING) +GAME(2001, sscopex, kviper, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Silent Scope EX (ver UAA)", MACHINE_NOT_WORKING) +GAME(2001, sogeki, sscopex, viper, viper, viper_state, init_vipercf, ROT0, "Konami", "Sogeki (ver JAA)", MACHINE_NOT_WORKING) +GAME(2002, sscopefh, kviper, viper, sscopefh, viper_state, init_vipercf, ROT0, "Konami", "Silent Scope Fortune Hunter (ver EAA)", MACHINE_NOT_WORKING) +GAME(2001, thrild2, kviper, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver EBB)", MACHINE_NOT_WORKING) +GAME(2001, thrild2j, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver JAA)", MACHINE_NOT_WORKING) +GAME(2001, thrild2a, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver AAA)", MACHINE_NOT_WORKING) +GAME(2001, thrild2ab, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver AAA, alt)", MACHINE_NOT_WORKING) +GAME(2001, thrild2ac, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver AAA, alt 2)", MACHINE_NOT_WORKING) +GAME(2001, thrild2c, thrild2, viper, thrild2, viper_state, init_vipercf, ROT0, "Konami", "Thrill Drive 2 (ver EAA)", MACHINE_NOT_WORKING) +GAME(2002, tsurugi, kviper, viper, tsurugi, viper_state, init_vipercf, ROT0, "Konami", "Tsurugi (ver EAB)", MACHINE_NOT_WORKING) +GAME(2002, tsurugie, tsurugi, viper, tsurugi, viper_state, init_vipercf, ROT0, "Konami", "Tsurugi (ver EAB, alt)", MACHINE_NOT_WORKING) +GAME(2002, tsurugij, tsurugi, viper, tsurugi, viper_state, init_vipercf, ROT0, "Konami", "Tsurugi (ver JAC)", MACHINE_NOT_WORKING) +GAME(2002, wcombat, kviper, viper, wcombat, viper_state, init_vipercf, ROT0, "Konami", "World Combat (ver AAD:B)", MACHINE_NOT_WORKING) +GAME(2002, wcombatb, wcombat, viper, wcombat, viper_state, init_vipercf, ROT0, "Konami", "World Combat (ver AAD:B, alt)", MACHINE_NOT_WORKING) +GAME(2002, wcombatk, wcombat, viper, wcombat, viper_state, init_vipercf, ROT0, "Konami", "World Combat (ver KBC:B)", MACHINE_NOT_WORKING) +GAME(2002, wcombatu, wcombat, viper, wcombat, viper_state, init_vipercf, ROT0, "Konami", "World Combat / Warzaid (ver UCD:B)", MACHINE_NOT_WORKING) +GAME(2002, wcombatj, wcombat, viper, wcombat, viper_state, init_vipercf, ROT0, "Konami", "World Combat (ver JAA)", MACHINE_NOT_WORKING) +GAME(2002, xtrial, kviper, viper, xtrial, viper_state, init_vipercf, ROT0, "Konami", "Xtrial Racing (ver JAB)", MACHINE_NOT_WORKING) + +GAME(2002, mfightc, kviper, viper, mfightc, viper_state, init_vipercf, ROT0, "Konami", "Mahjong Fight Club (ver JAD)", MACHINE_NOT_WORKING) +GAME(2002, mfightcc, mfightc, viper, mfightc, viper_state, init_vipercf, ROT0, "Konami", "Mahjong Fight Club (ver JAC)", MACHINE_NOT_WORKING) diff --git a/src/mame/drivers/vsmileb.cpp b/src/mame/drivers/vsmileb.cpp index 96c5f6af26f..a02d265063c 100644 --- a/src/mame/drivers/vsmileb.cpp +++ b/src/mame/drivers/vsmileb.cpp @@ -4,6 +4,22 @@ V-Tech V.Smile Baby console emulation + System is currently marked as not-working due to severe audio issues, as + narration-related voice clips are all cut off too early in every game. + + The issue appears to be due to improper handling of the "Fast Rampdown" + feature in the SPG2xx audio device, but due to the poor quality of SunPlus + developer documentation, it's unclear as to what part of the implementation + is wrong. + + If the Fast Rampdown feature is disabled in the audio device entirely, + voice clips play out without issue. + + Although bad audio is not usually a reason for marking a driver as + non-working, due to the nature of the V.Smile Baby and its target users, + having properly-narrated voices is critical to the overall experience of + the system. + *******************************************************************************/ #include "emu.h" @@ -103,9 +119,9 @@ static INPUT_PORTS_START( vsmileb ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmileb_state, pad_button_changed, vsmileb_state::BUTTON_EXIT) PORT_NAME("Exit") PORT_START("MODE") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Play Time") PORT_CHANGED_MEMBER(DEVICE_SELF, vsmileb_state, sw_mode<0x0400>, 0) // three-position function switch - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Watch & Learn") PORT_CHANGED_MEMBER(DEVICE_SELF, vsmileb_state, sw_mode<0x0800>, 0) - PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Learn & Explore") PORT_CHANGED_MEMBER(DEVICE_SELF, vsmileb_state, sw_mode<0x0c00>, 0) + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_CODE(KEYCODE_1) PORT_NAME("Play Time") PORT_CHANGED_MEMBER(DEVICE_SELF, vsmileb_state, sw_mode<0x0400>, 0) // three-position function switch + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_CODE(KEYCODE_2) PORT_NAME("Watch & Learn") PORT_CHANGED_MEMBER(DEVICE_SELF, vsmileb_state, sw_mode<0x0800>, 0) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_CODE(KEYCODE_3) PORT_NAME("Learn & Explore") PORT_CHANGED_MEMBER(DEVICE_SELF, vsmileb_state, sw_mode<0x0c00>, 0) PORT_START("LOGO") PORT_DIPNAME( 0x10, 0x10, "VTech Intro" ) @@ -180,12 +196,12 @@ ROM_START( vsmilebfp ) ROM_LOAD16_WORD_SWAP( "vsmilebabybios_france_patoune.bin", 0x000000, 0x800000, CRC(57757602) SHA1(a7495e1c6b2edaeb63bf1c658575689304f15804) ) ROM_END -// year, name, parent, compat, machine, input, class, init, company, fullname, flags -CONS( 2005, vsmileb, 0, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (USA)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) -CONS( 2005, vsmilebsw ,vsmileb, 0, vsmilebp,vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (Sweden)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) +// year, name, parent, compat, machine, input, class, init, company, fullname, flags +CONS( 2005, vsmileb, 0, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (USA)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NOT_WORKING ) +CONS( 2005, vsmilebsw, vsmileb, 0, vsmilebp, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (Sweden)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NOT_WORKING ) // These have a game in the BIOS ROM, supplied as a 'Romless cart' with the device, so probably triggers a switch. Currently always banked in. -CONS( 2005, vsmilebs, vsmileb, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (Spain, with 'Aventuras en el Bosque de los Cien Acres')", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) -CONS( 2005, vsmilebg, vsmileb, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (Germany, with 'Puuhs Hundert-Morgen-Wald')", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) -CONS( 2005, vsmilebf, vsmileb, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (France, with 'Winnie et ses amis dans la Foret des Reves Bleus')", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) -CONS( 2005, vsmilebfp, vsmileb, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (France, with 'En Ville avec l'ourson Patoune')", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) +CONS( 2005, vsmilebs, vsmileb, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (Spain, with 'Aventuras en el Bosque de los Cien Acres')", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NOT_WORKING ) +CONS( 2005, vsmilebg, vsmileb, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (Germany, with 'Puuhs Hundert-Morgen-Wald')", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NOT_WORKING ) +CONS( 2005, vsmilebf, vsmileb, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (France, with 'Winnie et ses amis dans la Foret des Reves Bleus')", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NOT_WORKING ) +CONS( 2005, vsmilebfp, vsmileb, 0, vsmileb, vsmileb, vsmileb_state, empty_init, "VTech", "V.Smile Baby (France, with 'En Ville avec l'ourson Patoune')", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS | MACHINE_NOT_WORKING ) diff --git a/src/mame/drivers/ympsr16.cpp b/src/mame/drivers/ympsr16.cpp new file mode 100644 index 00000000000..8ca257be9cc --- /dev/null +++ b/src/mame/drivers/ympsr16.cpp @@ -0,0 +1,143 @@ +// license:BSD-3-Clause +// copyright-holders:AJR +/******************************************************************************* + + Skeleton driver for Yamaha PSR-16 & related keyboards. + + These are based on the YM3420AD or YM3420BF "CPU and FM Tone Generator", + a 65C02-based SoC which includes 256 bytes of internal RAM, 16 KB of + internal ROM (enabled only on PSR-36?), a MIDI UART and a DAC. + +*******************************************************************************/ + +#include "emu.h" +//#include "bus/midi/midi.h" +#include "cpu/m6502/m65c02.h" + +namespace { + +class yamaha_psr16_state : public driver_device +{ +public: + yamaha_psr16_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + { + } + + void psr16(machine_config &config); + void psr36(machine_config &config); + void pss680(machine_config &config); + +private: + u8 busy_r(); + + void common_map(address_map &map); + void psr16_map(address_map &map); + void psr36_map(address_map &map); + void pss680_map(address_map &map); + + required_device<cpu_device> m_maincpu; +}; + + +u8 yamaha_psr16_state::busy_r() +{ + // Code waits for bit 7 of $0200 to go low before writing to $02XX + return 0; +} + +void yamaha_psr16_state::common_map(address_map &map) +{ + map(0x0000, 0x00ff).mirror(0x100).ram(); + map(0x0200, 0x0200).r(FUNC(yamaha_psr16_state::busy_r)); + map(0x0310, 0x0312).nopw(); + map(0x0318, 0x0318).nopr(); + map(0x0319, 0x031a).nopw(); + map(0x031b, 0x031b).nopr(); + map(0x0327, 0x0327).nopw(); +} + +void yamaha_psr16_state::psr16_map(address_map &map) +{ + common_map(map); + map(0xc000, 0xffff).rom().region("program", 0); +} + +void yamaha_psr16_state::psr36_map(address_map &map) +{ + common_map(map); + map(0x2000, 0x27ff).ram(); + map(0x4000, 0x7fff).rom().region("program", 0x4000); + map(0x8000, 0xbfff).rom().region("program", 0); + map(0xc000, 0xffff).rom().region("maincpu", 0); +} + +void yamaha_psr16_state::pss680_map(address_map &map) +{ + common_map(map); + map(0x1800, 0x1802).nopw(); + map(0x1810, 0x1811).nopr(); + map(0x2000, 0x3fff).ram(); + map(0x4000, 0x7fff).rom().region("program", 0x8000); + map(0x8000, 0xffff).rom().region("program", 0); +} + + + +static INPUT_PORTS_START(psr16) +INPUT_PORTS_END + +void yamaha_psr16_state::psr16(machine_config &config) +{ + M65C02(config, m_maincpu, 2'000'000); + m_maincpu->set_addrmap(AS_PROGRAM, &yamaha_psr16_state::psr16_map); +} + +void yamaha_psr16_state::psr36(machine_config &config) +{ + psr16(config); + m_maincpu->set_addrmap(AS_PROGRAM, &yamaha_psr16_state::psr36_map); +} + +void yamaha_psr16_state::pss680(machine_config &config) +{ + psr16(config); + m_maincpu->set_addrmap(AS_PROGRAM, &yamaha_psr16_state::pss680_map); +} + +ROM_START(psr16) + ROM_REGION(0x4000, "program", 0) + ROM_LOAD("yamaha_xe988a0_7247-h001.bin", 0x0000, 0x4000, CRC(20c5c0b2) SHA1(d7a066b680b7d4cfded62d4d50808c21784774d0)) // 28-pin mask ROM +ROM_END + +ROM_START(psr36) + ROM_REGION(0x4000, "maincpu", 0) + ROM_LOAD("ym3420bf_internal.bin", 0x0000, 0x4000, NO_DUMP) + ROM_FILL(0x3ffa, 1, 0x07) + ROM_FILL(0x3ffb, 1, 0x40) + ROM_FILL(0x3ffc, 1, 0x00) + ROM_FILL(0x3ffd, 1, 0x40) + ROM_FILL(0x3ffe, 1, 0x04) + ROM_FILL(0x3fff, 1, 0x40) + + ROM_REGION(0x20000, "program", 0) + ROM_LOAD("yamaha_xe137c0_7247-h005.bin", 0x00000, 0x20000, CRC(b9566cd5) SHA1(e35979299de2442d62e039d45b54bf77e9571f49)) // 28-pin mask ROM (second 32K is copy of first 32K; last half is all zero fill) + + ROM_REGION(0x20000, "waves", 0) + ROM_LOAD("yamaha_xe137b0_4881-7554.bin", 0x00000, 0x20000, CRC(6fe1382e) SHA1(82320d0a6c14825d790c0d67263786f767b7c318)) // 28-pin mask ROM (drum samples) +ROM_END + +ROM_START(pss680) + ROM_REGION(0x40000, "program", 0) + ROM_LOAD("yamaha_xe416d0-093.bin", 0x00000, 0x40000, CRC(150d1392) SHA1(d578324cfae73cd5f6c628eb3044be07684bc5d0)) // 32-pin mask ROM + + ROM_REGION(0x40000, "waves", 0) + ROM_LOAD("yamaha_xe405b0-070.bin", 0x00000, 0x40000, CRC(53336c52) SHA1(6bcad44fc93cfa5cd603cf24adfd736a911d3509)) // 32-pin mask ROM +ROM_END + +} // anonymous namespace + +SYST(1988, psr16, 0, 0, psr16, psr16, yamaha_psr16_state, empty_init, "Yamaha", "PSR-16", MACHINE_IS_SKELETON) +SYST(1988, psr36, 0, 0, psr36, psr16, yamaha_psr16_state, empty_init, "Yamaha", "PSR-36", MACHINE_IS_SKELETON) +SYST(1988, pss680, 0, 0, pss680, psr16, yamaha_psr16_state, empty_init, "Yamaha", "PSS-680", MACHINE_IS_SKELETON) diff --git a/src/mame/drivers/ympsr40.cpp b/src/mame/drivers/ympsr40.cpp new file mode 100644 index 00000000000..3b14fb7cbc0 --- /dev/null +++ b/src/mame/drivers/ympsr40.cpp @@ -0,0 +1,64 @@ +// license:BSD-3-Clause +// copyright-holders:AJR +/******************************************************************************* + + Skeleton driver for Yamaha PSR-40 PortaSound keyboard. + +*******************************************************************************/ + +#include "emu.h" +#include "cpu/z80/z80.h" +#include "machine/i8255.h" +#include "machine/nvram.h" + +namespace { + +class yamaha_psr40_state : public driver_device +{ +public: + yamaha_psr40_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + { + } + + void psr40(machine_config &config); + +private: + void mem_map(address_map &map); + + required_device<cpu_device> m_maincpu; +}; + + +void yamaha_psr40_state::mem_map(address_map &map) +{ + map(0x0000, 0x7fff).rom().region("program", 0); + map(0x8000, 0x87ff).mirror(0x1800).ram().share("nvram"); + //map(0xa000, 0xa01f).mirror(0x1fe0).rw("ge7", FUNC(ig10771_device::read), FUNC(ig10771_device::write)); + map(0xa01e, 0xa01f).nopr(); + map(0xc000, 0xc003).mirror(0x1ffc).rw("ppi", FUNC(i8255_device::read), FUNC(i8255_device::write)); +} + + +static INPUT_PORTS_START(psr40) +INPUT_PORTS_END + +void yamaha_psr40_state::psr40(machine_config &config) +{ + Z80(config, m_maincpu, 4'000'000); // unknown clock + m_maincpu->set_addrmap(AS_PROGRAM, &yamaha_psr40_state::mem_map); + + NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); // TC5517APL + battery? + + I8255(config, "ppi"); +} + +ROM_START(psr40) + ROM_REGION(0x8000, "program", 0) + ROM_LOAD("yamaha_xa004a0_6133-7836.ic4", 0x0000, 0x8000, CRC(7ac4a729) SHA1(e792aabe816d8c46bcc683f0e9220ca50c0faaac)) // 28-pin custom-marked ROM +ROM_END + +} // anonymous namespace + +SYST(1985, psr40, 0, 0, psr40, psr40, yamaha_psr40_state, empty_init, "Yamaha", "PSR-40", MACHINE_IS_SKELETON) diff --git a/src/mame/includes/kncljoe.h b/src/mame/includes/kncljoe.h index 331d95499c1..b73796af13f 100644 --- a/src/mame/includes/kncljoe.h +++ b/src/mame/includes/kncljoe.h @@ -2,16 +2,19 @@ // copyright-holders:Ernesto Corvi /************************************************************************* - Knuckle Joe + Knuckle Joe *************************************************************************/ -#ifndef MAME_INCLUDES_BLOODBRO_H -#define MAME_INCLUDES_BLOODBRO_H + +#ifndef MAME_INCLUDES_KNCLJOE_H +#define MAME_INCLUDES_KNCLJOE_H #pragma once +#include "cpu/m6800/m6801.h" #include "machine/gen_latch.h" #include "sound/ay8910.h" + #include "emupal.h" #include "screen.h" #include "tilemap.h" @@ -53,7 +56,7 @@ private: /* devices */ required_device<cpu_device> m_maincpu; - required_device<cpu_device> m_soundcpu; + required_device<m6803_cpu_device> m_soundcpu; required_device<gfxdecode_device> m_gfxdecode; required_device<screen_device> m_screen; required_device<palette_device> m_palette; @@ -82,4 +85,4 @@ private: void sound_map(address_map &map); }; -#endif // MAME_INCLUDES_BLOODBRO_H +#endif // MAME_INCLUDES_KNCLJOE_H diff --git a/src/mame/includes/namcona1.h b/src/mame/includes/namcona1.h index 3e3907e62cd..66b8657f41d 100644 --- a/src/mame/includes/namcona1.h +++ b/src/mame/includes/namcona1.h @@ -188,11 +188,19 @@ public: void c70(machine_config &config); void namcona2(machine_config &config); + void zelos(machine_config &config); void init_knckhead(); void init_emeralda(); void init_numanath(); void init_quiztou(); + void init_zelos(); + +private: + u16 m_zelos_ctrl; + + void zelos_ctrl_w(u16 data); + void zelos_main_map(address_map &map); }; class xday2_namcona2_state : public namcona2_state diff --git a/src/mame/layout/ti5100.lay b/src/mame/layout/ti5100.lay new file mode 100644 index 00000000000..94a31f840bf --- /dev/null +++ b/src/mame/layout/ti5100.lay @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<!-- +license:CC0 +--> +<mamelayout version="2"> + +<!-- define elements --> + + <element name="blackd"><disk><color red="0" green="0" blue="0" /></disk></element> + + <element name="digit" defstate="0"> + <led7seg><color red="0.2" green="1.0" blue="0.85" /></led7seg> + </element> + + <element name="seg_dp" defstate="0"> + <disk state="0"><color red="0.0235" green="0.1255" blue="0.1059" /></disk> + <disk state="1"><color red="0.2" green="1.0" blue="0.85" /></disk> + </element> + <element name="seg_r" defstate="0"> + <rect state="0"><color red="0.0235" green="0.1255" blue="0.1059" /></rect> + <rect state="1"><color red="0.2" green="1.0" blue="0.85" /></rect> + </element> + + <element name="seg_left" defstate="0"> + <text string="←" state="1"><color red="0.2" green="1.0" blue="0.85" /></text> + <text string="←" state="0"><color red="0.0235" green="0.1255" blue="0.1059" /></text> + </element> + <element name="seg_m" defstate="0"> + <text state="1" string="M"><color red="0.2" green="1.0" blue="0.85" /></text> + <text state="0" string="M"><color red="0.0235" green="0.1255" blue="0.1059" /></text> + </element> + + +<!-- build screen --> + + <view name="Internal Layout"> + <bounds left="9.6" right="130.5" top="0" bottom="15" /> + + <repeat count="10"> + <param name="i" start="9" increment="-1" /> + <param name="x1" start="20" increment="11" /> + <param name="x2" start="28.3" increment="11" /> + <param name="x3" start="29.2" increment="11" /> + <element name="digit~i~" ref="digit"><bounds x="~x1~" y="0" width="10" height="15" /></element> + + <!-- add dp/comma segments --> + <element ref="blackd"><bounds x="~x2~" y="13.3" width="2.1" height="2.1" /></element> + <element name="~i~.7" ref="seg_dp"><bounds x="~x3~" y="11.6" width="1.5" height="1.5" /></element> + <element name="~i~.8" ref="seg_r"><bounds x="~x3~" y="13.5" width="0.75" height="1.5" /></element> + </repeat> + + <element name="10.1" ref="seg_m"><bounds x="8.7" y="-0.7" width="10" height="8" /></element> + <element name="10.0" ref="seg_left"><bounds x="8.7" y="7.2" width="10" height="6.5" /></element> + <element name="10.6" ref="seg_r"><bounds x="10.6" y="6.85" width="6" height="1.3" /></element> + + </view> +</mamelayout> diff --git a/src/mame/mame.lst b/src/mame/mame.lst index 408b3c604b0..fd5cbd3fd1d 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -15325,6 +15325,9 @@ nfsug // Need For Speed: Underground Install (2 Discs) @source:gluck2.cpp gluck2 // 1992 Yung Yu / CYE +@source:gm1000.cpp +gm1000 // + @source:gmaster.cpp gmaster // Hartung Gamemaster @@ -16557,6 +16560,7 @@ ti1270 // Texas Instruments ti1680 // Texas Instruments ti25503 // Texas Instruments ti30 // Texas Instruments +ti5100 // Texas Instruments tibusan // Texas Instruments timaze // Texas Instruments tiprog // Texas Instruments @@ -23569,6 +23573,7 @@ bublpong // bootleg on enhanced hardware missb2 // bootleg on enhanced hardware @source:missbamby.cpp +basket // (c) 198? IGOA S.A. goldfrts // gwinner // (c) 1983 Reben luckyplr // (c) 1981 Cirsa @@ -31458,6 +31463,7 @@ swcourtb // bootleg (Playmark?) swcourtj // (c) 1992 (Japan) tinklpit // (c) 1993 (Japan) xday2 // (c) 1995 (Japan) +zelos // (c) 199? (Japan) @source:namconb1.cpp gslgr94j // (c) 1994 (Japan) @@ -33382,6 +33388,9 @@ onetwoe // (c) 1997 Barko c5000 // 1981 c8002 // +@source:opercoin.cpp +multibaby // (c) 1990 oper Coin + @source:opwolf.cpp opwolf // B20 (c) 1987 Taito Corporation Japan (World) opwolfa // B20 (c) 1987 Taito Corporation Japan (World) @@ -34665,6 +34674,7 @@ ketarrs151 // hack ketb // ketbl // killbld // (c) 1998 The Killing Blade +killbld100 // killbld104 // killbld106 // killbldp // (c) 2004 Killing Blade Plus @@ -36050,7 +36060,9 @@ rf51w14cg // (c) 2003 Recreativos Franco unkrfslt // @source:rfslotsmcs48.cpp -ajofrin // (c) 198? Recreativos Franco +ajofrin // (c) 1981 Recreativos Franco +babyfrts // (c) 198? Recreativos Franco +babyfrts25 // (c) 198? recreativos Franco @source:rfslotspcpent.cpp rfsantafeg // (c) 2014 Recreativos Franco @@ -38419,6 +38431,7 @@ rolla // score5 // Z Games skylncr // (c) 1995 Bordun International sonikfig // Z Games +speedway // sstar97 // (c) 199? Bordun International superb2k // Random Games tigerslt // Bootleg? @@ -40143,6 +40156,7 @@ bublbob2 // 1994.?? D90 (c) 1994 Taito Corporation Japan bublbob2o // 1994.?? D90 (c) 1994 Taito Corporation Japan (World) bublbob2p // prototype bubsymphb // bootleg +bubsymphba // bootleg bubsymphe // 1994.?? D90 (c) 1994 Taito Corporation Japan (Europe) bubsymphj // 1994.10 D90 (c) 1994 Taito Corporation (Japan) bubsymphu // 1994.10 D90 (c) 1994 Taito America Corporation (US) @@ -42095,11 +42109,13 @@ mocapbj // 2001 mocapglf // 2001 p911 // 2001 p9112 // 2001 -p911e // 2001 +p911ac // 2001 p911ea // 2001 +p911ed // 2001 p911j // 2001 +p911k // 2001 p911kc // 2001 -p911uc // 2001 +p911ud // 2001 ppp2nd // 2001 ppp2nda // 2001 sogeki // 2001 @@ -43443,6 +43459,14 @@ mu100 // 1997 MU-100 mu100r // 1997 MU-100 Rackable version mu100b // 1998 MU-100B +@source:ympsr16.cpp +psr16 // 1988 PSR-16 +psr36 // 1988 PSR-36 +pss680 // 1988 PSS-680 + +@source:ympsr40.cpp +psr40 // 1985 PSR-40 + @source:ympsr60.cpp psr60 // 1985 PSR-60 psr70 // 1985 PSR-70 diff --git a/src/mame/mess.flt b/src/mame/mess.flt index 7fb74ae0944..392158760b4 100644 --- a/src/mame/mess.flt +++ b/src/mame/mess.flt @@ -371,6 +371,7 @@ gimix.cpp gizmondo.cpp gkidabc.cpp glcx.cpp +gm1000.cpp gmaster.cpp gnat10.cpp goupil.cpp @@ -1194,6 +1195,8 @@ ymmu100.cpp ymmu5.cpp ymmu50.cpp ymmu80.cpp +ympsr16.cpp +ympsr40.cpp ympsr60.cpp ympsr340.cpp ymsy35.cpp diff --git a/src/mame/video/3dom2_te.cpp b/src/mame/video/3dom2_te.cpp index 7aa79a67924..ecacdfbe6e7 100644 --- a/src/mame/video/3dom2_te.cpp +++ b/src/mame/video/3dom2_te.cpp @@ -1502,21 +1502,6 @@ uint32_t nr_invert(uint32_t num, uint32_t & shift_amount) //------------------------------------------------- -// clamp - -//------------------------------------------------- - -uint32_t clamp(int32_t v, int32_t min, int32_t max) -{ - if (v < min) - return min; - else if (v > max) - return max; - - return v; -} - - -//------------------------------------------------- // walk_edges - //------------------------------------------------- @@ -1664,10 +1649,10 @@ void m2_te_device::walk_edges(uint32_t wrange) } // Clamp to 8.11 - r = clamp(r, 0, 0x0007ffff); - g = clamp(g, 0, 0x0007ffff); - b = clamp(b, 0, 0x0007ffff); - a = clamp(a, 0, 0x0007ffff); + r = std::clamp<int32_t>(r, 0, 0x0007ffff); + g = std::clamp<int32_t>(g, 0, 0x0007ffff); + b = std::clamp<int32_t>(b, 0, 0x0007ffff); + a = std::clamp<int32_t>(a, 0, 0x0007ffff); } if (!(m_es.es_cntl & TEMASTER_MODE_DTEXT)) @@ -1684,8 +1669,8 @@ void m2_te_device::walk_edges(uint32_t wrange) } // Clamp to 10.13 - uw = clamp(uw, 0, 0x007fffff); - vw = clamp(vw, 0, 0x007fffff); + uw = std::clamp<int32_t>(uw, 0, 0x007fffff); + vw = std::clamp<int32_t>(vw, 0, 0x007fffff); } if (!(m_es.es_cntl & ESCNTL_PERSPECTIVEOFF)) @@ -1696,7 +1681,7 @@ void m2_te_device::walk_edges(uint32_t wrange) w += step_back ? m_es.slope_w - m_es.ddx_w : m_es.slope_w; // Clamp to 0.23 - w = clamp(w, 0, 0x007fffff); + w = std::clamp<int32_t>(w, 0, 0x007fffff); } // Update Y @@ -1924,8 +1909,8 @@ void m2_te_device::addr_calc(uint32_t u, uint32_t v, uint32_t lod, u_max &= u_mask; v_max &= v_mask; - u0 = clamp(u0, 0, u_max); - v0 = clamp(v0, 0, v_max); + u0 = std::min(u0, u_max); + v0 = std::min(v0, v_max); // LOD uint32_t lodmax = m_tm.tex_addr_cntl & TXTADDRCNTL_LODMAX_MASK; @@ -3256,17 +3241,17 @@ void m2_te_device::walk_span(uint32_t wrange, bool omit_right, } // Clamp to 11.8 - r = clamp(r, 0, 0x0007ffff); - g = clamp(g, 0, 0x0007ffff); - b = clamp(b, 0, 0x0007ffff); - a = clamp(a, 0, 0x0007ffff); + r = std::clamp<int32_t>(r, 0, 0x0007ffff); + g = std::clamp<int32_t>(g, 0, 0x0007ffff); + b = std::clamp<int32_t>(b, 0, 0x0007ffff); + a = std::clamp<int32_t>(a, 0, 0x0007ffff); // Clamp to 10.13 - uw = clamp(uw, 0, 0x007fffff); - vw = clamp(vw, 0, 0x007fffff); + uw = std::clamp<int32_t>(uw, 0, 0x007fffff); + vw = std::clamp<int32_t>(vw, 0, 0x007fffff); // Clamp to 0.23 - w = clamp(w, 0, 0x007fffff); + w = std::clamp<int32_t>(w, 0, 0x007fffff); #if TEST_TIMING g_statistics[STAT_PIXELS_PROCESSED]++; diff --git a/src/mame/video/astrocde.cpp b/src/mame/video/astrocde.cpp index 98cff92b8dc..4b4367b2959 100644 --- a/src/mame/video/astrocde.cpp +++ b/src/mame/video/astrocde.cpp @@ -113,9 +113,9 @@ void astrocde_state::astrocade_palette(palette_device &palette) const int b = (by + y) * 255; // clamp and store - r = (std::min)((std::max)(r, 0), 255); - g = (std::min)((std::max)(g, 0), 255); - b = (std::min)((std::max)(b, 0), 255); + r = std::clamp(r, 0, 255); + g = std::clamp(g, 0, 255); + b = std::clamp(b, 0, 255); palette.set_pen_color(color * 16 + luma, rgb_t(r, g, b)); } } diff --git a/src/mame/video/avgdvg.cpp b/src/mame/video/avgdvg.cpp index b40d5fd67ac..4a1a1f4cd04 100644 --- a/src/mame/video/avgdvg.cpp +++ b/src/mame/video/avgdvg.cpp @@ -16,8 +16,10 @@ #include "emu.h" #include "avgdvg.h" + #include "screen.h" + /************************************* * * Macros and defines @@ -847,12 +849,12 @@ int avg_mhavoc_device::handler_7() // mhavoc_strobe3 const u8 b = bit0 * 0xcb; int x = m_xpos; - int y = m_ypos; - apply_flipping(x, y); + int y = m_ypos; + apply_flipping(x, y); - vg_add_point_buf( - x, - y, + vg_add_point_buf( + x, + y, rgb_t(r, g, b), (((m_int_latch >> 1) == 1) ? m_intensity : m_int_latch & 0xe) << 4); } diff --git a/src/mame/video/kncljoe.cpp b/src/mame/video/kncljoe.cpp index ccbcc5ab44f..8293836e2ce 100644 --- a/src/mame/video/kncljoe.cpp +++ b/src/mame/video/kncljoe.cpp @@ -2,7 +2,7 @@ // copyright-holders:Ernesto Corvi /*************************************************************************** -Knuckle Joe - (c) 1985 Taito Corporation + Knuckle Joe ***************************************************************************/ @@ -120,7 +120,6 @@ void kncljoe_state::kncljoe_videoram_w(offs_t offset, uint8_t data) void kncljoe_state::kncljoe_control_w(uint8_t data) { - int i; /* 0x01 screen flip 0x02 coin counter#1 @@ -137,27 +136,19 @@ void kncljoe_state::kncljoe_control_w(uint8_t data) machine().bookkeeping().coin_counter_w(0, data & 0x02); machine().bookkeeping().coin_counter_w(1, data & 0x20); - i = (data & 0x10) >> 4; - if (m_tile_bank != i) + if (m_tile_bank != BIT(data, 4)) { - m_tile_bank = i; + m_tile_bank = BIT(data, 4); m_bg_tilemap->mark_all_dirty(); } - i = (data & 0x04) >> 2; - if (m_sprite_bank != i) - { - m_sprite_bank = i; - memset(memregion("maincpu")->base() + 0xf100, 0, 0x180); - } + m_sprite_bank = BIT(data, 2); } void kncljoe_state::kncljoe_scroll_w(offs_t offset, uint8_t data) { - int scrollx; - m_scrollregs[offset] = data; - scrollx = m_scrollregs[0] | m_scrollregs[1] << 8; + int scrollx = m_scrollregs[0] | m_scrollregs[1] << 8; m_bg_tilemap->set_scrollx(0, scrollx); m_bg_tilemap->set_scrollx(1, scrollx); m_bg_tilemap->set_scrollx(2, scrollx); @@ -174,48 +165,33 @@ void kncljoe_state::kncljoe_scroll_w(offs_t offset, uint8_t data) void kncljoe_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) { - uint8_t *spriteram = m_spriteram; - rectangle clip = cliprect; gfx_element *gfx = m_gfxdecode->gfx(1 + m_sprite_bank); - int i, j; - static const int pribase[4]={0x0180, 0x0080, 0x0100, 0x0000}; - const rectangle &visarea = m_screen->visible_area(); - /* score covers sprites */ - if (m_flipscreen) - { - if (clip.max_y > visarea.max_y - 64) - clip.max_y = visarea.max_y - 64; - } - else + for (int i = 0; i < 4; i++) { - if (clip.min_y < visarea.min_y + 64) - clip.min_y = visarea.min_y + 64; - } + // clip vertical strip for each layer + rectangle clip = cliprect; + clip.min_y = m_flipscreen ? (192 - i * 64) : (i * 64 + 1); + clip.max_y = clip.min_y + 64; + clip &= cliprect; - for (i = 0; i < 4; i++) - for (j = 0x7c; j >= 0; j -= 4) + for (int j = 0x7c; j >= 0; j -= 4) { - int offs = pribase[i] + j; - int sy = spriteram[offs]; - int sx = spriteram[offs + 3]; - int code = spriteram[offs + 2]; - int attr = spriteram[offs + 1]; + int offs = bitswap<2>(~i, 0, 1) << 7 | j; + int sy = m_spriteram[offs] + 1; + int sx = m_spriteram[offs + 3]; + int attr = m_spriteram[offs + 1]; + int code = m_spriteram[offs + 2] | ((attr & 0x10) << 5) | ((attr & 0x20) << 3); int flipx = attr & 0x40; int flipy = !(attr & 0x80); int color = attr & 0x0f; - if (attr & 0x10) - code += 512; - if (attr & 0x20) - code += 256; - if (m_flipscreen) { flipx = !flipx; flipy = !flipy; sx = 240 - sx; - sy = 240 - sy; + sy = 241 - sy; } if (sx >= 256-8) @@ -227,6 +203,7 @@ void kncljoe_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprec flipx,flipy, sx,sy,0); } + } } uint32_t kncljoe_state::screen_update_kncljoe(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) diff --git a/src/mame/video/tc0780fpa.cpp b/src/mame/video/tc0780fpa.cpp index 431478cafa2..565a4b41442 100644 --- a/src/mame/video/tc0780fpa.cpp +++ b/src/mame/video/tc0780fpa.cpp @@ -1,5 +1,5 @@ // license:LGPL-2.1+ -// copyright-holders:Ville Linde, Angelo Salese, hap +// copyright-holders:Ville Linde, Angelo Salese // Taito TC0780FPA Polygon Renderer @@ -125,7 +125,7 @@ void tc0780fpa_renderer::render_texture_scan(int32_t scanline, const extent_t &e } else { - iu = (tex_base_x + (((int)u >> 4) & 0x3f)) & 0x7ff; + iu = (tex_base_x + (((int)u >> 4) & ((0x08 << tex_wrap_x) - 1))) & 0x7ff; } if (!tex_wrap_y) @@ -134,7 +134,7 @@ void tc0780fpa_renderer::render_texture_scan(int32_t scanline, const extent_t &e } else { - iv = (tex_base_y + (((int)v >> 4) & 0x3f)) & 0x7ff; + iv = (tex_base_y + (((int)v >> 4) & ((0x08 << tex_wrap_y) - 1))) & 0x7ff; } texel = m_texture[(iv * 2048) + iu]; @@ -156,7 +156,6 @@ void tc0780fpa_renderer::render_texture_scan(int32_t scanline, const extent_t &e void tc0780fpa_renderer::render(uint16_t *polygon_fifo, int length) { vertex_t vert[4]; - int i; uint16_t cmd = polygon_fifo[0]; @@ -207,7 +206,7 @@ void tc0780fpa_renderer::render(uint16_t *polygon_fifo, int length) // 0x0b: Vertex 3 X // 0x0c: Vertex 3 Z - for (i=0; i < 3; i++) + for (int i=0; i < 3; i++) { vert[i].p[1] = polygon_fifo[ptr++]; vert[i].y = (int16_t)(polygon_fifo[ptr++]); @@ -261,12 +260,12 @@ void tc0780fpa_renderer::render(uint16_t *polygon_fifo, int length) extra.tex_base_x = ((texbase >> 0) & 0xff) << 4; extra.tex_base_y = ((texbase >> 8) & 0xff) << 4; - extra.tex_wrap_x = (cmd & 0xc0) ? 1 : 0; - extra.tex_wrap_y = (cmd & 0x30) ? 1 : 0; + extra.tex_wrap_x = (cmd >> 6) & 3; + extra.tex_wrap_y = (cmd >> 4) & 3; - for (i=0; i < 3; i++) + for (int i=0; i < 3; i++) { - vert[i].p[3] = polygon_fifo[ptr++] + 0.5; // palette + vert[i].p[3] = polygon_fifo[ptr++] + 0.5; // palette vert[i].p[2] = (int16_t)(polygon_fifo[ptr++]); vert[i].p[1] = (int16_t)(polygon_fifo[ptr++]); vert[i].y = (int16_t)(polygon_fifo[ptr++]); @@ -302,7 +301,7 @@ void tc0780fpa_renderer::render(uint16_t *polygon_fifo, int length) // 0x0f: Vertex 4 X // 0x10: Vertex 4 Z - for (i=0; i < 4; i++) + for (int i=0; i < 4; i++) { vert[i].p[1] = polygon_fifo[ptr++]; vert[i].y = (int16_t)(polygon_fifo[ptr++]); @@ -363,12 +362,12 @@ void tc0780fpa_renderer::render(uint16_t *polygon_fifo, int length) extra.tex_base_x = ((texbase >> 0) & 0xff) << 4; extra.tex_base_y = ((texbase >> 8) & 0xff) << 4; - extra.tex_wrap_x = (cmd & 0xc0) ? 1 : 0; - extra.tex_wrap_y = (cmd & 0x30) ? 1 : 0; + extra.tex_wrap_x = (cmd >> 6) & 3; + extra.tex_wrap_y = (cmd >> 4) & 3; - for (i=0; i < 4; i++) + for (int i=0; i < 4; i++) { - vert[i].p[3] = polygon_fifo[ptr++] + 0.5; // palette + vert[i].p[3] = polygon_fifo[ptr++] + 0.5; // palette vert[i].p[2] = (int16_t)(polygon_fifo[ptr++]); vert[i].p[1] = (int16_t)(polygon_fifo[ptr++]); vert[i].y = (int16_t)(polygon_fifo[ptr++]); @@ -376,7 +375,7 @@ void tc0780fpa_renderer::render(uint16_t *polygon_fifo, int length) vert[i].p[0] = (uint16_t)(polygon_fifo[ptr++]); } - if (vert[0].p[0] < 0x8000 && vert[1].p[0] < 0x8000 && vert[2].p[0] < 0x8000 && vert[3].p[0] < 0x8000) + if (vert[0].p[0] < 0xc000 && vert[1].p[0] < 0xc000 && vert[2].p[0] < 0xc000 && vert[3].p[0] < 0xc000) { render_polygon<4, 4>(m_cliprect, render_delegate(&tc0780fpa_renderer::render_texture_scan, this), vert); } diff --git a/src/mame/video/xbox_nv2a.cpp b/src/mame/video/xbox_nv2a.cpp index 48811fe5afa..1354cf2382c 100644 --- a/src/mame/video/xbox_nv2a.cpp +++ b/src/mame/video/xbox_nv2a.cpp @@ -4319,7 +4319,7 @@ float nv2a_renderer::combiner_map_input_function(Combiner::MapFunction code, flo case 0: // unsigned identity return std::max(0.0f, value); case 1: // unsigned invert - return 1.0f - std::min(std::max(value, 0.0f), 1.0f); + return 1.0f - std::clamp(value, 0.0f, 1.0f); case 2: // expand normal return 2.0f * std::max(0.0f, value) - 1.0f; case 3: // expand negate @@ -4348,9 +4348,9 @@ void nv2a_renderer::combiner_map_input_function_array(Combiner::MapFunction code data[2] = std::max(0.0f, data[2]); break; case 1: - data[0] = 1.0f - std::min(std::max(data[0], 0.0f), 1.0f); - data[1] = 1.0f - std::min(std::max(data[1], 0.0f), 1.0f); - data[2] = 1.0f - std::min(std::max(data[2], 0.0f), 1.0f); + data[0] = 1.0f - std::clamp(data[0], 0.0f, 1.0f); + data[1] = 1.0f - std::clamp(data[1], 0.0f, 1.0f); + data[2] = 1.0f - std::clamp(data[2], 0.0f, 1.0f); break; case 2: data[0] = 2.0f * std::max(0.0f, data[0]) - 1.0f; @@ -4697,9 +4697,9 @@ void nv2a_renderer::combiner_compute_rgb_outputs(int id, int stage_number) m = 0; combiner_function_AB(id, combiner.work[id].functions.RGBop1); } - combiner.work[id].functions.RGBop1[0] = std::max(std::min((combiner.work[id].functions.RGBop1[0] + bias) * scale, 1.0f), -1.0f); - combiner.work[id].functions.RGBop1[1] = std::max(std::min((combiner.work[id].functions.RGBop1[1] + bias) * scale, 1.0f), -1.0f); - combiner.work[id].functions.RGBop1[2] = std::max(std::min((combiner.work[id].functions.RGBop1[2] + bias) * scale, 1.0f), -1.0f); + combiner.work[id].functions.RGBop1[0] = std::clamp((combiner.work[id].functions.RGBop1[0] + bias) * scale, -1.0f, 1.0f); + combiner.work[id].functions.RGBop1[1] = std::clamp((combiner.work[id].functions.RGBop1[1] + bias) * scale, -1.0f, 1.0f); + combiner.work[id].functions.RGBop1[2] = std::clamp((combiner.work[id].functions.RGBop1[2] + bias) * scale, -1.0f, 1.0f); // second if (combiner.setup.stage[n].mapout_rgb.CD_dotproduct) { m = m | 1; @@ -4707,18 +4707,18 @@ void nv2a_renderer::combiner_compute_rgb_outputs(int id, int stage_number) } else combiner_function_CD(id, combiner.work[id].functions.RGBop2); - combiner.work[id].functions.RGBop2[0] = std::max(std::min((combiner.work[id].functions.RGBop2[0] + bias) * scale, 1.0f), -1.0f); - combiner.work[id].functions.RGBop2[1] = std::max(std::min((combiner.work[id].functions.RGBop2[1] + bias) * scale, 1.0f), -1.0f); - combiner.work[id].functions.RGBop2[2] = std::max(std::min((combiner.work[id].functions.RGBop2[2] + bias) * scale, 1.0f), -1.0f); + combiner.work[id].functions.RGBop2[0] = std::clamp((combiner.work[id].functions.RGBop2[0] + bias) * scale, -1.0f, 1.0f); + combiner.work[id].functions.RGBop2[1] = std::clamp((combiner.work[id].functions.RGBop2[1] + bias) * scale, -1.0f, 1.0f); + combiner.work[id].functions.RGBop2[2] = std::clamp((combiner.work[id].functions.RGBop2[2] + bias) * scale, -1.0f, 1.0f); // third if (m == 0) { if (combiner.setup.stage[n].mapout_rgb.muxsum) combiner_function_ABmuxCD(id, combiner.work[id].functions.RGBop3); else combiner_function_ABsumCD(id, combiner.work[id].functions.RGBop3); - combiner.work[id].functions.RGBop3[0] = std::max(std::min((combiner.work[id].functions.RGBop3[0] + bias) * scale, 1.0f), -1.0f); - combiner.work[id].functions.RGBop3[1] = std::max(std::min((combiner.work[id].functions.RGBop3[1] + bias) * scale, 1.0f), -1.0f); - combiner.work[id].functions.RGBop3[2] = std::max(std::min((combiner.work[id].functions.RGBop3[2] + bias) * scale, 1.0f), -1.0f); + combiner.work[id].functions.RGBop3[0] = std::clamp((combiner.work[id].functions.RGBop3[0] + bias) * scale, -1.0f, 1.0f); + combiner.work[id].functions.RGBop3[1] = std::clamp((combiner.work[id].functions.RGBop3[1] + bias) * scale, -1.0f, 1.0f); + combiner.work[id].functions.RGBop3[2] = std::clamp((combiner.work[id].functions.RGBop3[2] + bias) * scale, -1.0f, 1.0f); } } @@ -4749,10 +4749,10 @@ void nv2a_renderer::combiner_compute_alpha_outputs(int id, int stage_number) } // first combiner.work[id].functions.Aop1 = combiner.work[id].variables.A[3] * combiner.work[id].variables.B[3]; - combiner.work[id].functions.Aop1 = std::max(std::min((combiner.work[id].functions.Aop1 + bias) * scale, 1.0f), -1.0f); + combiner.work[id].functions.Aop1 = std::clamp((combiner.work[id].functions.Aop1 + bias) * scale, -1.0f, 1.0f); // second combiner.work[id].functions.Aop2 = combiner.work[id].variables.C[3] * combiner.work[id].variables.D[3]; - combiner.work[id].functions.Aop2 = std::max(std::min((combiner.work[id].functions.Aop2 + bias) * scale, 1.0f), -1.0f); + combiner.work[id].functions.Aop2 = std::clamp((combiner.work[id].functions.Aop2 + bias) * scale, -1.0f, 1.0f); // third if (combiner.setup.stage[n].mapout_alpha.muxsum) { if (combiner.work[id].registers.spare0[3] >= 0.5f) @@ -4762,7 +4762,7 @@ void nv2a_renderer::combiner_compute_alpha_outputs(int id, int stage_number) } else combiner.work[id].functions.Aop3 = combiner.work[id].variables.A[3] * combiner.work[id].variables.B[3] + combiner.work[id].variables.C[3] * combiner.work[id].variables.D[3]; - combiner.work[id].functions.Aop3 = std::max(std::min((combiner.work[id].functions.Aop3 + bias) * scale, 1.0f), -1.0f); + combiner.work[id].functions.Aop3 = std::clamp((combiner.work[id].functions.Aop3 + bias) * scale, -1.0f, 1.0f); } WRITE_LINE_MEMBER(nv2a_renderer::vblank_callback) diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp index 23cc8ef66ba..8fe382a8d72 100644 --- a/src/osd/modules/debugger/debugimgui.cpp +++ b/src/osd/modules/debugger/debugimgui.cpp @@ -844,23 +844,23 @@ void debug_imgui::draw_memory(debug_area* view_ptr, bool* opened) auto* mem = downcast<debug_view_memory*>(view_ptr->view); bool physical = mem->physical(); bool rev = mem->reverse(); - int format = mem->get_data_format(); + debug_view_memory::data_format format = mem->get_data_format(); uint32_t chunks = mem->chunks_per_row(); - if(ImGui::MenuItem("1-byte chunks", nullptr,(format == 1) ? true : false)) - mem->set_data_format(1); - if(ImGui::MenuItem("2-byte chunks", nullptr,(format == 2) ? true : false)) - mem->set_data_format(2); - if(ImGui::MenuItem("4-byte chunks", nullptr,(format == 4) ? true : false)) - mem->set_data_format(4); - if(ImGui::MenuItem("8-byte chunks", nullptr,(format == 8) ? true : false)) - mem->set_data_format(8); - if(ImGui::MenuItem("32-bit floating point", nullptr,(format == 9) ? true : false)) - mem->set_data_format(9); - if(ImGui::MenuItem("64-bit floating point", nullptr,(format == 10) ? true : false)) - mem->set_data_format(10); - if(ImGui::MenuItem("80-bit floating point", nullptr,(format == 11) ? true : false)) - mem->set_data_format(11); + if(ImGui::MenuItem("1-byte chunks", nullptr,(format == debug_view_memory::data_format::HEX_8BIT) ? true : false)) + mem->set_data_format(debug_view_memory::data_format::HEX_8BIT); + if(ImGui::MenuItem("2-byte chunks", nullptr,(format == debug_view_memory::data_format::HEX_16BIT) ? true : false)) + mem->set_data_format(debug_view_memory::data_format::HEX_16BIT); + if(ImGui::MenuItem("4-byte chunks", nullptr,(format == debug_view_memory::data_format::HEX_32BIT) ? true : false)) + mem->set_data_format(debug_view_memory::data_format::HEX_32BIT); + if(ImGui::MenuItem("8-byte chunks", nullptr,(format == debug_view_memory::data_format::HEX_64BIT) ? true : false)) + mem->set_data_format(debug_view_memory::data_format::HEX_64BIT); + if(ImGui::MenuItem("32-bit floating point", nullptr,(format == debug_view_memory::data_format::FLOAT_32BIT) ? true : false)) + mem->set_data_format(debug_view_memory::data_format::FLOAT_32BIT); + if(ImGui::MenuItem("64-bit floating point", nullptr,(format == debug_view_memory::data_format::FLOAT_64BIT) ? true : false)) + mem->set_data_format(debug_view_memory::data_format::FLOAT_64BIT); + if(ImGui::MenuItem("80-bit floating point", nullptr,(format == debug_view_memory::data_format::FLOAT_80BIT) ? true : false)) + mem->set_data_format(debug_view_memory::data_format::FLOAT_80BIT); ImGui::Separator(); if(ImGui::MenuItem("Logical addresses", nullptr,!physical)) mem->set_physical(false); diff --git a/src/osd/modules/debugger/osx/memoryview.mm b/src/osd/modules/debugger/osx/memoryview.mm index 0db48236b79..17d0ea639d4 100644 --- a/src/osd/modules/debugger/osx/memoryview.mm +++ b/src/osd/modules/debugger/osx/memoryview.mm @@ -35,7 +35,7 @@ if (action == @selector(showChunkSize:)) { - [item setState:((tag == memview->get_data_format()) ? NSOnState : NSOffState)]; + [item setState:((tag == int(memview->get_data_format())) ? NSOnState : NSOffState)]; return YES; } else if (action == @selector(showPhysicalAddresses:)) @@ -176,7 +176,7 @@ - (IBAction)showChunkSize:(id)sender { - downcast<debug_view_memory *>(view)->set_data_format([sender tag]); + downcast<debug_view_memory *>(view)->set_data_format(debug_view_memory::data_format([sender tag])); } @@ -206,7 +206,7 @@ debug_view_memory *const memView = downcast<debug_view_memory *>(view); node->set_attribute_int("reverse", memView->reverse() ? 1 : 0); node->set_attribute_int("addressmode", memView->physical() ? 1 : 0); - node->set_attribute_int("dataformat", memView->get_data_format()); + node->set_attribute_int("dataformat", int(memView->get_data_format())); node->set_attribute_int("rowchunks", memView->chunks_per_row()); } @@ -216,43 +216,60 @@ debug_view_memory *const memView = downcast<debug_view_memory *>(view); memView->set_reverse(0 != node->get_attribute_int("reverse", memView->reverse() ? 1 : 0)); memView->set_physical(0 != node->get_attribute_int("addressmode", memView->physical() ? 1 : 0)); - memView->set_data_format(node->get_attribute_int("dataformat", memView->get_data_format())); + memView->set_data_format(debug_view_memory::data_format(node->get_attribute_int("dataformat", int(memView->get_data_format())))); memView->set_chunks_per_row(node->get_attribute_int("rowchunks", memView->chunks_per_row())); } - (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { - NSInteger tag; - for (tag = 1; tag <= 8; tag <<= 1) { - NSString *title = [NSString stringWithFormat:@"%ld-byte Chunks", (long)tag]; - NSMenuItem *chunkItem = [menu insertItemWithTitle:title - action:@selector(showChunkSize:) - keyEquivalent:[NSString stringWithFormat:@"%ld", (long)tag] - atIndex:index++]; - [chunkItem setTarget:self]; - [chunkItem setTag:tag]; - } + NSMenuItem *chunkItem1 = [menu insertItemWithTitle:@"1-byte Chunks" + action:@selector(showChunkSize:) + keyEquivalent:@"1" + atIndex:index++]; + [chunkItem1 setTarget:self]; + [chunkItem1 setTag:int(debug_view_memory::data_format::HEX_8BIT)]; + + NSMenuItem *chunkItem2 = [menu insertItemWithTitle:@"2-byte Chunks" + action:@selector(showChunkSize:) + keyEquivalent:@"2" + atIndex:index++]; + [chunkItem2 setTarget:self]; + [chunkItem2 setTag:int(debug_view_memory::data_format::HEX_16BIT)]; - NSMenuItem *chunkItem = [menu insertItemWithTitle:@"32-bit floats" + NSMenuItem *chunkItem4 = [menu insertItemWithTitle:@"4-byte Chunks" + action:@selector(showChunkSize:) + keyEquivalent:@"4" + atIndex:index++]; + [chunkItem4 setTarget:self]; + [chunkItem4 setTag:int(debug_view_memory::data_format::HEX_32BIT)]; + + NSMenuItem *chunkItem8 = [menu insertItemWithTitle:@"8-byte Chunks" + action:@selector(showChunkSize:) + keyEquivalent:@"8" + atIndex:index++]; + [chunkItem8 setTarget:self]; + [chunkItem8 setTag:int(debug_view_memory::data_format::HEX_64BIT)]; + + NSMenuItem *chunkItem9 = [menu insertItemWithTitle:@"32-bit floats" action:@selector(showChunkSize:) keyEquivalent:@"F" atIndex:index++]; - [chunkItem setTarget:self]; - [chunkItem setTag:9]; + [chunkItem9 setTarget:self]; + [chunkItem9 setTag:int(debug_view_memory::data_format::FLOAT_32BIT)]; - NSMenuItem *chunkItem2 = [menu insertItemWithTitle:@"64-bit floats" + NSMenuItem *chunkItem10 = [menu insertItemWithTitle:@"64-bit floats" action:@selector(showChunkSize:) keyEquivalent:@"D" atIndex:index++]; - [chunkItem2 setTarget:self]; - [chunkItem2 setTag:10]; + [chunkItem10 setTarget:self]; + [chunkItem10 setTag:int(debug_view_memory::data_format::FLOAT_64BIT)]; - NSMenuItem *chunkItem3 = [menu insertItemWithTitle:@"80-bit floats" + NSMenuItem *chunkItem11 = [menu insertItemWithTitle:@"80-bit floats" action:@selector(showChunkSize:) keyEquivalent:@"E" atIndex:index++]; - [chunkItem3 setTarget:self]; - [chunkItem3 setTag:11]; + [chunkItem11 setTarget:self]; + [chunkItem11 setTag:int(debug_view_memory::data_format::FLOAT_80BIT)]; [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp index 9989ac6d66d..c4b4ce9a429 100644 --- a/src/osd/modules/debugger/qt/memorywindow.cpp +++ b/src/osd/modules/debugger/qt/memorywindow.cpp @@ -178,13 +178,13 @@ void MemoryWindow::memoryRegionChanged(int index) debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view()); switch (memView->get_data_format()) { - case 1: dataFormatMenuItem("formatActOne")->setChecked(true); break; - case 2: dataFormatMenuItem("formatActTwo")->setChecked(true); break; - case 4: dataFormatMenuItem("formatActFour")->setChecked(true); break; - case 8: dataFormatMenuItem("formatActEight")->setChecked(true); break; - case 9: dataFormatMenuItem("formatAct32bitFloat")->setChecked(true); break; - case 10: dataFormatMenuItem("formatAct64bitFloat")->setChecked(true); break; - case 11: dataFormatMenuItem("formatAct80bitFloat")->setChecked(true); break; + case debug_view_memory::data_format::HEX_8BIT: dataFormatMenuItem("formatActOne")->setChecked(true); break; + case debug_view_memory::data_format::HEX_16BIT: dataFormatMenuItem("formatActTwo")->setChecked(true); break; + case debug_view_memory::data_format::HEX_32BIT: dataFormatMenuItem("formatActFour")->setChecked(true); break; + case debug_view_memory::data_format::HEX_64BIT: dataFormatMenuItem("formatActEight")->setChecked(true); break; + case debug_view_memory::data_format::FLOAT_32BIT: dataFormatMenuItem("formatAct32bitFloat")->setChecked(true); break; + case debug_view_memory::data_format::FLOAT_64BIT: dataFormatMenuItem("formatAct64bitFloat")->setChecked(true); break; + case debug_view_memory::data_format::FLOAT_80BIT: dataFormatMenuItem("formatAct80bitFloat")->setChecked(true); break; default: break; } } @@ -214,19 +214,19 @@ void MemoryWindow::formatChanged(QAction* changedTo) debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view()); if (changedTo->text() == "1-byte chunks") - memView->set_data_format(1); + memView->set_data_format(debug_view_memory::data_format::HEX_8BIT); else if (changedTo->text() == "2-byte chunks") - memView->set_data_format(2); + memView->set_data_format(debug_view_memory::data_format::HEX_16BIT); else if (changedTo->text() == "4-byte chunks") - memView->set_data_format(4); + memView->set_data_format(debug_view_memory::data_format::HEX_32BIT); else if (changedTo->text() == "8-byte chunks") - memView->set_data_format(8); + memView->set_data_format(debug_view_memory::data_format::HEX_64BIT); else if (changedTo->text() == "32 bit floating point") - memView->set_data_format(9); + memView->set_data_format(debug_view_memory::data_format::FLOAT_32BIT); else if (changedTo->text() == "64 bit floating point") - memView->set_data_format(10); + memView->set_data_format(debug_view_memory::data_format::FLOAT_64BIT); else if (changedTo->text() == "80 bit floating point") - memView->set_data_format(11); + memView->set_data_format(debug_view_memory::data_format::FLOAT_80BIT); m_memTable->viewport()->update(); } diff --git a/src/osd/modules/debugger/win/memoryviewinfo.cpp b/src/osd/modules/debugger/win/memoryviewinfo.cpp index 9575a128c33..15dc46ebb98 100644 --- a/src/osd/modules/debugger/win/memoryviewinfo.cpp +++ b/src/osd/modules/debugger/win/memoryviewinfo.cpp @@ -9,8 +9,6 @@ #include "emu.h" #include "memoryviewinfo.h" -#include "debug/dvmemory.h" - #include "strconv.h" @@ -25,7 +23,7 @@ memoryview_info::~memoryview_info() } -uint8_t memoryview_info::data_format() const +debug_view_memory::data_format memoryview_info::data_format() const { return view<debug_view_memory>()->get_data_format(); } @@ -54,7 +52,7 @@ void memoryview_info::set_expression(const std::string &string) view<debug_view_memory>()->set_expression(string); } -void memoryview_info::set_data_format(uint8_t dataformat) +void memoryview_info::set_data_format(debug_view_memory::data_format dataformat) { view<debug_view_memory>()->set_data_format(dataformat); } diff --git a/src/osd/modules/debugger/win/memoryviewinfo.h b/src/osd/modules/debugger/win/memoryviewinfo.h index 7766da9ac30..95436e507e6 100644 --- a/src/osd/modules/debugger/win/memoryviewinfo.h +++ b/src/osd/modules/debugger/win/memoryviewinfo.h @@ -11,9 +11,10 @@ #pragma once #include "debugwin.h" - #include "debugviewinfo.h" +#include "debug/dvmemory.h" + #include <string> @@ -23,13 +24,13 @@ public: memoryview_info(debugger_windows_interface &debugger, debugwin_info &owner, HWND parent); virtual ~memoryview_info(); - uint8_t data_format() const; + debug_view_memory::data_format data_format() const; uint32_t chunks_per_row() const; bool reverse() const; bool physical() const; void set_expression(const std::string &string); - void set_data_format(uint8_t dataformat); + void set_data_format(debug_view_memory::data_format dataformat); void set_chunks_per_row(uint32_t rowchunks); void set_reverse(bool reverse); void set_physical(bool physical); diff --git a/src/osd/modules/debugger/win/memorywininfo.cpp b/src/osd/modules/debugger/win/memorywininfo.cpp index 18f28252f12..a103b3b353b 100644 --- a/src/osd/modules/debugger/win/memorywininfo.cpp +++ b/src/osd/modules/debugger/win/memorywininfo.cpp @@ -180,13 +180,13 @@ void memorywin_info::update_menu() auto *const memview = downcast<memoryview_info *>(m_views[0].get()); HMENU const menu = GetMenu(window()); - CheckMenuItem(menu, ID_1_BYTE_CHUNKS, MF_BYCOMMAND | (memview->data_format() == 1 ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(menu, ID_2_BYTE_CHUNKS, MF_BYCOMMAND | (memview->data_format() == 2 ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(menu, ID_4_BYTE_CHUNKS, MF_BYCOMMAND | (memview->data_format() == 4 ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(menu, ID_8_BYTE_CHUNKS, MF_BYCOMMAND | (memview->data_format() == 8 ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(menu, ID_FLOATING_POINT_32BIT, MF_BYCOMMAND | (memview->data_format() == 9 ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(menu, ID_FLOATING_POINT_64BIT, MF_BYCOMMAND | (memview->data_format() == 10 ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(menu, ID_FLOATING_POINT_80BIT, MF_BYCOMMAND | (memview->data_format() == 11 ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, ID_1_BYTE_CHUNKS, MF_BYCOMMAND | (memview->data_format() == debug_view_memory::data_format::HEX_8BIT ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, ID_2_BYTE_CHUNKS, MF_BYCOMMAND | (memview->data_format() == debug_view_memory::data_format::HEX_16BIT ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, ID_4_BYTE_CHUNKS, MF_BYCOMMAND | (memview->data_format() == debug_view_memory::data_format::HEX_32BIT ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, ID_8_BYTE_CHUNKS, MF_BYCOMMAND | (memview->data_format() == debug_view_memory::data_format::HEX_64BIT ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, ID_FLOATING_POINT_32BIT, MF_BYCOMMAND | (memview->data_format() == debug_view_memory::data_format::FLOAT_32BIT ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, ID_FLOATING_POINT_64BIT, MF_BYCOMMAND | (memview->data_format() == debug_view_memory::data_format::FLOAT_64BIT ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, ID_FLOATING_POINT_80BIT, MF_BYCOMMAND | (memview->data_format() == debug_view_memory::data_format::FLOAT_80BIT ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(menu, ID_LOGICAL_ADDRESSES, MF_BYCOMMAND | (memview->physical() ? MF_UNCHECKED : MF_CHECKED)); CheckMenuItem(menu, ID_PHYSICAL_ADDRESSES, MF_BYCOMMAND | (memview->physical() ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(menu, ID_REVERSE_VIEW, MF_BYCOMMAND | (memview->reverse() ? MF_CHECKED : MF_UNCHECKED)); @@ -220,31 +220,31 @@ bool memorywin_info::handle_command(WPARAM wparam, LPARAM lparam) switch (LOWORD(wparam)) { case ID_1_BYTE_CHUNKS: - memview->set_data_format(1); + memview->set_data_format(debug_view_memory::data_format::HEX_8BIT); return true; case ID_2_BYTE_CHUNKS: - memview->set_data_format(2); + memview->set_data_format(debug_view_memory::data_format::HEX_16BIT); return true; case ID_4_BYTE_CHUNKS: - memview->set_data_format(4); + memview->set_data_format(debug_view_memory::data_format::HEX_32BIT); return true; case ID_8_BYTE_CHUNKS: - memview->set_data_format(8); + memview->set_data_format(debug_view_memory::data_format::HEX_64BIT); return true; case ID_FLOATING_POINT_32BIT: - memview->set_data_format(9); + memview->set_data_format(debug_view_memory::data_format::FLOAT_32BIT); return true; case ID_FLOATING_POINT_64BIT: - memview->set_data_format(10); + memview->set_data_format(debug_view_memory::data_format::FLOAT_64BIT); return true; case ID_FLOATING_POINT_80BIT: - memview->set_data_format(11); + memview->set_data_format(debug_view_memory::data_format::FLOAT_80BIT); return true; case ID_LOGICAL_ADDRESSES: diff --git a/src/osd/modules/render/bgfx/chain.cpp b/src/osd/modules/render/bgfx/chain.cpp index 6ff13cffebb..8dbd72a0067 100644 --- a/src/osd/modules/render/bgfx/chain.cpp +++ b/src/osd/modules/render/bgfx/chain.cpp @@ -169,5 +169,5 @@ void bgfx_chain::insert_effect(uint32_t index, bgfx_effect *effect, std::string const uint32_t screen_width = chains.targets().width(TARGET_STYLE_GUEST, m_screen_index); const uint32_t screen_height = chains.targets().height(TARGET_STYLE_GUEST, m_screen_index); m_targets.destroy_target("screen", m_screen_index); - m_targets.create_target("screen", bgfx::TextureFormat::RGBA8, screen_width, screen_height, TARGET_STYLE_GUEST, true, false, 1, m_screen_index); + m_targets.create_target("screen", bgfx::TextureFormat::BGRA8, screen_width, screen_height, TARGET_STYLE_GUEST, true, false, 1, m_screen_index); } diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp index 43bc463a5e1..26cba0d4f94 100644 --- a/src/osd/modules/render/bgfx/chainmanager.cpp +++ b/src/osd/modules/render/bgfx/chainmanager.cpp @@ -47,6 +47,7 @@ chain_manager::chain_manager(running_machine& machine, osd_options& options, tex , m_slider_notifier(slider_notifier) , m_screen_count(0) { + m_converters.clear(); refresh_available_chains(); parse_chain_selections(options.bgfx_screen_chains()); init_texture_converters(); @@ -462,14 +463,15 @@ uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive * } } - bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::RGBA8; + bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8; uint16_t pitch = prim.m_rowpixels; + int convert_stride = 1; const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, prim.m_flags & PRIMFLAG_TEXFORMAT_MASK, - prim.m_rowpixels, tex_height, prim.m_prim->texture.palette, prim.m_prim->texture.base, &pitch); + prim.m_rowpixels, tex_height, prim.m_prim->texture.palette, prim.m_prim->texture.base, pitch, convert_stride); if (texture == nullptr) { - bgfx_texture *texture = new bgfx_texture(full_name, dst_format, tex_width, tex_height, mem, BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT, pitch, prim.m_rowpixels); + bgfx_texture *texture = new bgfx_texture(full_name, dst_format, tex_width, tex_height, mem, BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT, pitch, prim.m_rowpixels, convert_stride); m_textures.add_provider(full_name, texture); if (prim.m_prim->texture.palette) diff --git a/src/osd/modules/render/bgfx/inputpair.cpp b/src/osd/modules/render/bgfx/inputpair.cpp index 9b430607cb8..4f185db86ab 100644 --- a/src/osd/modules/render/bgfx/inputpair.cpp +++ b/src/osd/modules/render/bgfx/inputpair.cpp @@ -42,6 +42,7 @@ bgfx_input_pair::bgfx_input_pair(int index, std::string sampler, std::string tex bgfx_input_pair::~bgfx_input_pair() { + m_slider_state.reset(); } void bgfx_input_pair::bind(bgfx_effect *effect, const int32_t screen) const @@ -58,14 +59,14 @@ void bgfx_input_pair::bind(bgfx_effect *effect, const int32_t screen) const bgfx_uniform *tex_size = effect->uniform("u_tex_size" + std::to_string(m_index)); if (tex_size && provider) { - float values[2] = { float(provider->width()), float(provider->height()) }; + float values[2] = { float(provider->rowpixels()), float(provider->height()) }; tex_size->set(values, sizeof(float) * 2); } bgfx_uniform *inv_tex_size = effect->uniform("u_inv_tex_size" + std::to_string(m_index)); if (inv_tex_size && provider) { - float values[2] = { 1.0f / float(provider->width()), 1.0f / float(provider->height()) }; + float values[2] = { 1.0f / float(provider->rowpixels()), 1.0f / float(provider->height()) }; inv_tex_size->set(values, sizeof(float) * 2); } diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc index 82236d954a3..c152bfa8fe3 100644 --- a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc +++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc @@ -9,11 +9,28 @@ $input v_color0, v_texcoord0 SAMPLER2D(s_tex, 0); SAMPLER2D(s_pal, 1); +uniform vec4 u_tex_size0; +uniform vec4 u_inv_tex_size0; uniform vec4 u_inv_tex_size1; void main() { - vec2 palette_uv = texture2D(s_tex, v_texcoord0).rg; - palette_uv.xy = (palette_uv.xy * vec2(256.0, 256.0)) * u_inv_tex_size1.xy; + // Logic taken from fs_blit_yuy16.sc - we need to do this, because + // the D3D9 BGFX backend claims to support RG8, but does so in + // a faulty way by using A8L8, which is not an appropriate format + // for representing an RG8 texture. + + vec2 half_texel = u_inv_tex_size0.xy * vec2(0.5, 0.5); + + vec2 original_uv = v_texcoord0.xy * u_tex_size0.xy; + float mod_val = mod(original_uv.x, 2.0); + vec2 rounded_uv = vec2(original_uv.x - mod_val, original_uv.y); + vec4 srcpix = texture2D(s_tex, rounded_uv * u_inv_tex_size0.xy + half_texel.x); + + vec2 palette_uv = (srcpix.ra * vec2(256.0, 256.0)) * u_inv_tex_size1.xy; + if (mod_val < 1.0) + palette_uv = (srcpix.bg * vec2(256.0, 256.0)) * u_inv_tex_size1.xy; + gl_FragColor = vec4(texture2D(s_pal, palette_uv).rgb, 1.0) * v_color0; + //gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0; } diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_yuy16.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_yuy16.sc index 21f3b8816fc..91e3c3ed462 100644 --- a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_yuy16.sc +++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_yuy16.sc @@ -8,8 +8,6 @@ $input v_color0, v_texcoord0 // Samplers SAMPLER2D(s_tex, 0); -#define round(X) floor((X)+0.5) - uniform vec4 u_tex_size0; uniform vec4 u_inv_tex_size0; @@ -23,17 +21,17 @@ vec3 ycc_to_rgb(float y, float cb, float cr) void main() { - vec2 size_minus_one = u_tex_size0.xy - vec2(1.0, 1.0); - vec2 original_uv = round(v_texcoord0.xy * size_minus_one); + vec2 half_texel = u_inv_tex_size0.xy * vec2(0.5, 0.5); + + vec2 original_uv = v_texcoord0.xy * u_tex_size0.xy; float mod_val = mod(original_uv.x, 2.0); - vec2 rounded_uv = round(vec2(original_uv.x - mod_val, original_uv.y)); - vec2 next_uv = rounded_uv + vec2(1.0, 0.0); - vec2 srcpix0 = texture2D(s_tex, rounded_uv / size_minus_one).rg; - vec2 srcpix1 = texture2D(s_tex, next_uv / size_minus_one).rg; - float cr = srcpix1.r; - float cb = srcpix0.r; + vec2 rounded_uv = vec2(original_uv.x - mod_val, original_uv.y); + vec4 srcpix = texture2D(s_tex, rounded_uv * u_inv_tex_size0.xy + half_texel.x); + + float cr = srcpix.r; + float cb = srcpix.b; if (mod_val < 1.0) - gl_FragColor = vec4(ycc_to_rgb(srcpix0.g, cb, cr), 1.0) * v_color0; + gl_FragColor = vec4(ycc_to_rgb(srcpix.g, cb, cr), 1.0) * v_color0; else - gl_FragColor = vec4(ycc_to_rgb(srcpix1.g, cb, cr), 1.0) * v_color0; + gl_FragColor = vec4(ycc_to_rgb(srcpix.a, cb, cr), 1.0) * v_color0; } diff --git a/src/osd/modules/render/bgfx/target.cpp b/src/osd/modules/render/bgfx/target.cpp index cb912aba9ef..ff814ed649a 100644 --- a/src/osd/modules/render/bgfx/target.cpp +++ b/src/osd/modules/render/bgfx/target.cpp @@ -30,16 +30,24 @@ bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uin { m_width *= m_scale; m_height *= m_scale; + uint32_t wrap_mode = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP; uint32_t filter_mode = filter ? (BGFX_SAMPLER_MIN_ANISOTROPIC | BGFX_SAMPLER_MAG_ANISOTROPIC) : (BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT); + uint32_t depth_flags = wrap_mode | (BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT); - m_textures = new bgfx::TextureHandle[m_page_count]; + m_textures = new bgfx::TextureHandle[m_page_count * 2]; m_targets = new bgfx::FrameBufferHandle[m_page_count]; for (int page = 0; page < m_page_count; page++) { m_textures[page] = bgfx::createTexture2D(m_width, m_height, false, 1, format, wrap_mode | filter_mode | BGFX_TEXTURE_RT); assert(m_textures[page].idx != 0xffff); - m_targets[page] = bgfx::createFrameBuffer(1, &m_textures[page], false); + + m_textures[m_page_count + page] = bgfx::createTexture2D(m_width, m_height, false, 1, bgfx::TextureFormat::D24, depth_flags | BGFX_TEXTURE_RT); + assert(m_textures[m_page_count + page].idx != 0xffff); + + bgfx::TextureHandle handles[2] = { m_textures[page], m_textures[m_page_count + page] }; + m_targets[page] = bgfx::createFrameBuffer(2, handles, false); + assert(m_targets[page].idx != 0xffff); } @@ -64,7 +72,7 @@ bgfx_target::bgfx_target(void *handle, uint16_t width, uint16_t height) , m_page_count(0) { m_targets = new bgfx::FrameBufferHandle[1]; - m_targets[0] = bgfx::createFrameBuffer(handle, width, height); + m_targets[0] = bgfx::createFrameBuffer(handle, width, height, bgfx::TextureFormat::Count, bgfx::TextureFormat::D24); // No backing texture } @@ -81,6 +89,7 @@ bgfx_target::~bgfx_target() for (int page = 0; page < m_page_count; page++) { bgfx::destroy(m_targets[page]); + bgfx::destroy(m_textures[m_page_count + page]); bgfx::destroy(m_textures[page]); } delete [] m_textures; diff --git a/src/osd/modules/render/bgfx/target.h b/src/osd/modules/render/bgfx/target.h index be6e5884d22..15a12731c4f 100644 --- a/src/osd/modules/render/bgfx/target.h +++ b/src/osd/modules/render/bgfx/target.h @@ -44,11 +44,12 @@ public: uint32_t screen_index() const { return m_screen; } // bgfx_texture_handle_provider + virtual bgfx::TextureHandle texture() const override; + virtual bool is_target() const override { return true; } virtual uint16_t width() const override { return m_width; } virtual uint16_t height() const override { return m_height; } virtual uint16_t rowpixels() const override { return m_width; } - virtual bgfx::TextureHandle texture() const override; - virtual bool is_target() const override { return true; } + virtual int convert_stride() const override { return 1; } private: std::string m_name; diff --git a/src/osd/modules/render/bgfx/targetmanager.cpp b/src/osd/modules/render/bgfx/targetmanager.cpp index adc2ca5acee..3cc90e1fa84 100644 --- a/src/osd/modules/render/bgfx/targetmanager.cpp +++ b/src/osd/modules/render/bgfx/targetmanager.cpp @@ -47,11 +47,14 @@ target_manager::~target_manager() bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t style, bool double_buffer, bool filter, uint16_t scale, uint32_t screen) { - auto* target = new bgfx_target(name, format, width, height, style, double_buffer, filter, scale, screen); std::string full_name = name + std::to_string(screen); - m_targets[full_name] = target; + auto iter = m_targets.find(full_name); + if (iter != m_targets.end()) + destroy_target(name, screen); + bgfx_target *target = new bgfx_target(name, format, width, height, style, double_buffer, filter, scale, screen); + m_targets[full_name] = target; m_textures.add_provider(full_name, target); return target; @@ -60,10 +63,10 @@ bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat void target_manager::destroy_target(std::string name, uint32_t screen) { std::string full_name = (screen < 0) ? name : (name + std::to_string(screen)); - if (m_targets[full_name] != nullptr) + if (m_targets.find(full_name) != m_targets.end()) { delete m_targets[full_name]; - m_targets[full_name] = nullptr; + m_targets.erase(full_name); m_textures.remove_provider(full_name); } } @@ -78,12 +81,11 @@ bgfx_target* target_manager::create_backbuffer(void *handle, uint16_t width, uin bgfx_target* target_manager::target(uint32_t screen, std::string name) { std::string full_name = name + std::to_string(screen); - bgfx_target* target = m_targets[full_name]; - if (target == nullptr) + if (m_targets.find(full_name) != m_targets.end()) { osd_printf_verbose("Warning: Attempting to retrieve a nonexistent target '%s' for screen %d\n", name, screen); } - return target; + return m_targets[full_name]; } bool target_manager::update_target_sizes(uint32_t screen, uint16_t width, uint16_t height, uint32_t style) @@ -133,8 +135,8 @@ void target_manager::rebuild_targets(uint32_t screen, uint32_t style) const uint16_t scale = target->scale(); const uint16_t width(sizes[screen].width()); const uint16_t height(sizes[screen].height()); - delete target; + destroy_target(name, screen); create_target(name, format, width, height, style, double_buffered, filter, scale, screen); } } @@ -165,7 +167,7 @@ void target_manager::create_target_if_nonexistent(uint32_t screen, std::string n { if (style == TARGET_STYLE_CUSTOM) return; - if (m_targets[name + std::to_string(screen)] != nullptr) + if (m_targets.find(name + std::to_string(screen)) != m_targets.end()) { return; } @@ -174,7 +176,7 @@ void target_manager::create_target_if_nonexistent(uint32_t screen, std::string n uint16_t width(sizes[screen].width()); uint16_t height(sizes[screen].height()); - create_target(name, bgfx::TextureFormat::RGBA8, width, height, style, double_buffered, filter, 1, screen); + create_target(name, bgfx::TextureFormat::BGRA8, width, height, style, double_buffered, filter, 1, screen); } uint16_t target_manager::width(uint32_t style, uint32_t screen) diff --git a/src/osd/modules/render/bgfx/targetreader.cpp b/src/osd/modules/render/bgfx/targetreader.cpp index 71b82383a59..e201f3c5f6e 100644 --- a/src/osd/modules/render/bgfx/targetreader.cpp +++ b/src/osd/modules/render/bgfx/targetreader.cpp @@ -60,7 +60,7 @@ bgfx_target* target_reader::read_from_value(const Value& value, std::string pref break; } - return chains.targets().create_target(target_name, bgfx::TextureFormat::RGBA8, width, height, mode, double_buffer, bilinear, scale, screen_index); + return chains.targets().create_target(target_name, bgfx::TextureFormat::BGRA8, width, height, mode, double_buffer, bilinear, scale, screen_index); } bool target_reader::validate_parameters(const Value& value, std::string prefix) diff --git a/src/osd/modules/render/bgfx/texture.cpp b/src/osd/modules/render/bgfx/texture.cpp index 85f1d3645fb..34efd738679 100644 --- a/src/osd/modules/render/bgfx/texture.cpp +++ b/src/osd/modules/render/bgfx/texture.cpp @@ -15,6 +15,8 @@ bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, u , m_format(format) , m_width(width) , m_height(height) + , m_rowpixels(width) + , m_convert_stride(1) { bgfx::TextureInfo info; bgfx::calcTextureSize(info, width, height, 1, false, false, 1, format); @@ -32,17 +34,18 @@ bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, u } } -bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, const bgfx::Memory* data, uint32_t flags, uint16_t pitch, uint16_t rowpixels) +bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, const bgfx::Memory* data, uint32_t flags, uint16_t pitch, uint16_t rowpixels, int convert_stride) : m_name(name) , m_format(format) , m_width(width) , m_height(height) , m_rowpixels(rowpixels ? rowpixels : width) + , m_convert_stride(convert_stride) { bgfx::TextureInfo info; - bgfx::calcTextureSize(info, m_rowpixels, height, 1, false, false, 1, format); - m_texture = bgfx::createTexture2D(m_rowpixels, height, false, 1, format, flags, nullptr); - bgfx::updateTexture2D(m_texture, 0, 0, 0, 0, m_rowpixels, height, data, pitch); + bgfx::calcTextureSize(info, m_rowpixels / m_convert_stride, height, 1, false, false, 1, format); + m_texture = bgfx::createTexture2D(m_rowpixels / m_convert_stride, height, false, 1, format, flags, nullptr); + bgfx::updateTexture2D(m_texture, 0, 0, 0, 0, m_rowpixels / m_convert_stride, height, data, pitch); } bgfx_texture::~bgfx_texture() @@ -52,5 +55,5 @@ bgfx_texture::~bgfx_texture() void bgfx_texture::update(const bgfx::Memory *data, uint16_t pitch) { - bgfx::updateTexture2D(m_texture, 0, 0, 0, 0, m_width, m_height, data, pitch); + bgfx::updateTexture2D(m_texture, 0, 0, 0, 0, m_rowpixels / m_convert_stride, m_height, data, pitch); } diff --git a/src/osd/modules/render/bgfx/texture.h b/src/osd/modules/render/bgfx/texture.h index dc96e9acd77..4a5d6636f5b 100644 --- a/src/osd/modules/render/bgfx/texture.h +++ b/src/osd/modules/render/bgfx/texture.h @@ -21,7 +21,7 @@ class bgfx_texture : public bgfx_texture_handle_provider { public: bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t flags, void* data); - bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, const bgfx::Memory* data, uint32_t flags = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP, uint16_t pitch = UINT16_MAX, uint16_t rowpixels = 0); + bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, const bgfx::Memory* data, uint32_t flags = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP, uint16_t pitch = UINT16_MAX, uint16_t rowpixels = 0, int convert_stride = 1); virtual ~bgfx_texture(); // Getters @@ -29,11 +29,12 @@ public: bgfx::TextureFormat::Enum format() const { return m_format; } // bgfx_texture_handle_provider + virtual bgfx::TextureHandle texture() const override { return m_texture; } + virtual bool is_target() const override { return false; } virtual uint16_t width() const override { return m_width; } virtual uint16_t height() const override { return m_height; } virtual uint16_t rowpixels() const override { return m_rowpixels; } - virtual bgfx::TextureHandle texture() const override { return m_texture; } - virtual bool is_target() const override { return false; } + virtual int convert_stride() const override { return m_convert_stride; } void update(const bgfx::Memory *data, uint16_t pitch = UINT16_MAX); @@ -43,6 +44,7 @@ protected: uint16_t m_width; uint16_t m_height; uint16_t m_rowpixels; + int m_convert_stride; bgfx::TextureHandle m_texture; }; diff --git a/src/osd/modules/render/bgfx/texturehandleprovider.h b/src/osd/modules/render/bgfx/texturehandleprovider.h index b4b3f561d44..03387040d7c 100644 --- a/src/osd/modules/render/bgfx/texturehandleprovider.h +++ b/src/osd/modules/render/bgfx/texturehandleprovider.h @@ -25,6 +25,7 @@ public: virtual uint16_t width() const = 0; virtual uint16_t height() const = 0; virtual uint16_t rowpixels() const = 0; + virtual int convert_stride() const = 0; }; #endif // __DRAWBGFX_TEXTURE_HANDLE_PROVIDER__ diff --git a/src/osd/modules/render/bgfx/texturemanager.cpp b/src/osd/modules/render/bgfx/texturemanager.cpp index d0bcbcb476d..6c760c10203 100644 --- a/src/osd/modules/render/bgfx/texturemanager.cpp +++ b/src/osd/modules/render/bgfx/texturemanager.cpp @@ -87,7 +87,7 @@ bgfx_texture* texture_manager::create_png_texture(std::string path, std::string { texture_name += std::to_string(screen); } - bgfx_texture* texture = create_texture(texture_name, bgfx::TextureFormat::RGBA8, width, height, data, flags); + bgfx_texture* texture = create_texture(texture_name, bgfx::TextureFormat::BGRA8, width, height, data, flags); delete [] data; @@ -122,8 +122,9 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form { bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8; uint16_t pitch = width; - const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, &pitch); - bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch); + int convert_stride = 1; + const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, pitch, convert_stride); + bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)(rowpixels / convert_stride), (uint16_t)height, mem, pitch); return handle; } } @@ -150,8 +151,9 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form { bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8; uint16_t pitch = width; - const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, &pitch); - bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch); + int convert_stride = 1; + const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, pitch, convert_stride); + bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)(rowpixels / convert_stride), (uint16_t)height, mem, pitch); return handle; } } @@ -161,9 +163,10 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8; uint16_t pitch = width; - const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, &pitch); + int convert_stride = 1; + const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, rowpixels, height, palette, base, pitch, convert_stride); handle = bgfx::createTexture2D(width, height, false, 1, dst_format, flags, nullptr); - bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch); + bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)(rowpixels / convert_stride), (uint16_t)height, mem, pitch); m_mame_textures[key] = { handle, seqid, width, height }; return handle; @@ -201,6 +204,6 @@ void texture_manager::remove_provider(std::string name, bool delete_provider) { delete m_textures[name]; } - m_textures[name] = nullptr; + m_textures.erase(name); } } diff --git a/src/osd/modules/render/bgfxutil.cpp b/src/osd/modules/render/bgfxutil.cpp index 9d2bef27901..f0d01e4fa86 100644 --- a/src/osd/modules/render/bgfxutil.cpp +++ b/src/osd/modules/render/bgfxutil.cpp @@ -14,29 +14,29 @@ #include "render.h" -const bgfx::Memory* bgfx_util::mame_texture_data_to_bgfx_texture_data(bgfx::TextureFormat::Enum &dst_format, uint32_t src_format, int rowpixels, int height, const rgb_t *palette, void *base, uint16_t *out_pitch) +const bgfx::Memory* bgfx_util::mame_texture_data_to_bgfx_texture_data(bgfx::TextureFormat::Enum &dst_format, uint32_t src_format, int rowpixels, int height, const rgb_t *palette, void *base, uint16_t &out_pitch, int &convert_stride) { bgfx::TextureInfo info; switch (src_format) { case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTE16): case PRIMFLAG_TEXFORMAT(TEXFORMAT_YUY16): - dst_format = bgfx::TextureFormat::RG8; - if (out_pitch) - *out_pitch = rowpixels * 2; + dst_format = bgfx::TextureFormat::BGRA8; + convert_stride = 2; + out_pitch = rowpixels * 2; break; case PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32): case PRIMFLAG_TEXFORMAT(TEXFORMAT_RGB32): dst_format = bgfx::TextureFormat::BGRA8; - if (out_pitch) - *out_pitch = rowpixels * 4; + convert_stride = 1; + out_pitch = rowpixels * 4; break; } - bgfx::calcTextureSize(info, rowpixels, height, 1, false, false, 1, dst_format); + bgfx::calcTextureSize(info, rowpixels / convert_stride, height, 1, false, false, 1, dst_format); return bgfx::copy(base, info.storageSize); } -const bgfx::Memory* bgfx_util::mame_texture_data_to_argb32(uint32_t src_format, int width, int height, int rowpixels, const rgb_t *palette, void *base) +const bgfx::Memory* bgfx_util::mame_texture_data_to_bgra32(uint32_t src_format, int width, int height, int rowpixels, const rgb_t *palette, void *base) { const bgfx::Memory* mem = bgfx::alloc(rowpixels * height * 4); auto* dst = reinterpret_cast<uint32_t*>(mem->data); @@ -48,19 +48,19 @@ const bgfx::Memory* bgfx_util::mame_texture_data_to_argb32(uint32_t src_format, switch (src_format) { case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTE16): - copy_util::copyline_palette16(dst, src16, width, palette); + copy_util::copyline_palette16_to_bgra(dst, src16, width, palette); src16 += rowpixels; break; case PRIMFLAG_TEXFORMAT(TEXFORMAT_YUY16): - copy_util::copyline_yuy16_to_argb(dst, src16, width, palette, 1); + copy_util::copyline_yuy16_to_bgra(dst, src16, width, palette, 1); src16 += rowpixels; break; case PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32): - copy_util::copyline_argb32(dst, src32, width, palette); + copy_util::copyline_argb32_to_bgra(dst, src32, width, palette); src32 += rowpixels; break; case PRIMFLAG_TEXFORMAT(TEXFORMAT_RGB32): - copy_util::copyline_rgb32(dst, src32, width, palette); + copy_util::copyline_rgb32_to_bgra(dst, src32, width, palette); src32 += rowpixels; break; default: diff --git a/src/osd/modules/render/bgfxutil.h b/src/osd/modules/render/bgfxutil.h index 2f961f6551e..010321bd6bd 100644 --- a/src/osd/modules/render/bgfxutil.h +++ b/src/osd/modules/render/bgfxutil.h @@ -11,8 +11,8 @@ class bgfx_util { public: - static const bgfx::Memory* mame_texture_data_to_bgfx_texture_data(bgfx::TextureFormat::Enum &dst_format, uint32_t format, int width, int height, const rgb_t *palette, void *base, uint16_t *out_pitch = nullptr); - static const bgfx::Memory* mame_texture_data_to_argb32(uint32_t src_format, int width, int height, int rowpixels, const rgb_t *palette, void *base); + static const bgfx::Memory* mame_texture_data_to_bgfx_texture_data(bgfx::TextureFormat::Enum &dst_format, uint32_t format, int rowpixels, int height, const rgb_t *palette, void *base, uint16_t &out_pitch, int &convert_stride); + static const bgfx::Memory* mame_texture_data_to_bgra32(uint32_t src_format, int width, int height, int rowpixels, const rgb_t *palette, void *base); static uint64_t get_blend_state(uint32_t blend); }; diff --git a/src/osd/modules/render/copyutil.h b/src/osd/modules/render/copyutil.h index 715fcba0dca..295b5a10200 100644 --- a/src/osd/modules/render/copyutil.h +++ b/src/osd/modules/render/copyutil.h @@ -24,6 +24,15 @@ public: } } + static inline void copyline_palette16_to_bgra(uint32_t *dst, const uint16_t *src, int width, const rgb_t *palette) + { + for (int x = 0; x < width; x++) + { + rgb_t srcpixel = palette[*src++]; + *dst++ = 0xff000000 | (srcpixel.r() << 16) | (srcpixel.g() << 8) | srcpixel.b(); + } + } + static inline void copyline_rgb32(uint32_t *dst, const uint32_t *src, int width, const rgb_t *palette) { int x; @@ -49,6 +58,32 @@ public: } } + static inline void copyline_rgb32_to_bgra(uint32_t *dst, const uint32_t *src, int width, const rgb_t *palette) + { + int x; + + // palette (really RGB map) case + if (palette != nullptr) + { + for (x = 0; x < width; x++) + { + rgb_t srcpix = *src++; + uint32_t val = 0xff000000 | palette[0x200 + srcpix.b()] | palette[0x100 + srcpix.g()] | palette[srcpix.r()]; + *dst++ = (val & 0xff00ff00) | ((val & 0x000000ff) << 16) | ((val & 0x00ff0000) >> 16); + } + } + + // direct case + else + { + for (x = 0; x < width; x++) + { + rgb_t srcpix = *src++; + *dst++ = 0xff000000 | (srcpix.r() << 16) | (srcpix.g() << 8) | srcpix.b(); + } + } + } + static inline void copyline_argb32(uint32_t *dst, const uint32_t *src, int width, const rgb_t *palette) { int x; @@ -73,6 +108,31 @@ public: } } + static inline void copyline_argb32_to_bgra(uint32_t *dst, const uint32_t *src, int width, const rgb_t *palette) + { + int x; + // palette (really RGB map) case + if (palette != nullptr) + { + for (x = 0; x < width; x++) + { + rgb_t srcpix = *src++; + uint32_t val = (srcpix & 0xff000000) | palette[0x200 + srcpix.b()] | palette[0x100 + srcpix.g()] | palette[srcpix.r()]; + *dst++ = (val & 0xff00ff00) | ((val & 0x000000ff) << 16) | ((val & 0x00ff0000) >> 16); + } + } + + // direct case + else + { + for (x = 0; x < width; x++) + { + rgb_t srcpix = *src++; + *dst++ = (srcpix.a() << 24) | (srcpix.r() << 16) | (srcpix.g() << 8) | srcpix.b(); + } + } + } + static inline uint32_t ycc_to_rgb(uint8_t y, uint8_t cb, uint8_t cr) { /* original equations: @@ -116,14 +176,12 @@ public: static inline void copyline_yuy16_to_argb(uint32_t *dst, const uint16_t *src, int width, const rgb_t *palette, int xprescale) { - int x; - assert(width % 2 == 0); // palette (really RGB map) case if (palette != nullptr) { - for (x = 0; x < width / 2; x++) + for (int x = 0; x < width / 2; x++) { uint16_t srcpix0 = *src++; uint16_t srcpix1 = *src++; @@ -139,7 +197,7 @@ public: // direct case else { - for (x = 0; x < width; x += 2) + for (int x = 0; x < width; x += 2) { uint16_t srcpix0 = *src++; uint16_t srcpix1 = *src++; @@ -152,6 +210,55 @@ public: } } } + + static inline void copyline_yuy16_to_bgra(uint32_t *dst, const uint16_t *src, int width, const rgb_t *palette, int xprescale) + { + assert(width % 2 == 0); + + // palette (really RGB map) case + if (palette != nullptr) + { + for (int x = 0; x < width / 2; x++) + { + uint16_t srcpix0 = *src++; + uint16_t srcpix1 = *src++; + uint8_t cb = srcpix0 & 0xff; + uint8_t cr = srcpix1 & 0xff; + for (int x2 = 0; x2 < xprescale; x2++) + { + uint32_t val = ycc_to_rgb(palette[0x000 + (srcpix0 >> 8)], cb, cr); + *dst++ = (val & 0xff00ff00) | ((val & 0x000000ff) << 16) | ((val & 0x00ff0000) >> 16); + } + for (int x2 = 0; x2 < xprescale; x2++) + { + uint32_t val = ycc_to_rgb(palette[0x000 + (srcpix1 >> 8)], cb, cr); + *dst++ = (val & 0xff00ff00) | ((val & 0x000000ff) << 16) | ((val & 0x00ff0000) >> 16); + } + } + } + + // direct case + else + { + for (int x = 0; x < width; x += 2) + { + uint16_t srcpix0 = *src++; + uint16_t srcpix1 = *src++; + uint8_t cb = srcpix0 & 0xff; + uint8_t cr = srcpix1 & 0xff; + for (int x2 = 0; x2 < xprescale; x2++) + { + uint32_t val = ycc_to_rgb(srcpix0 >> 8, cb, cr); + *dst++ = (val & 0xff00ff00) | ((val & 0x000000ff) << 16) | ((val & 0x00ff0000) >> 16); + } + for (int x2 = 0; x2 < xprescale; x2++) + { + uint32_t val = ycc_to_rgb(srcpix1 >> 8, cb, cr); + *dst++ = (val & 0xff00ff00) | ((val & 0x000000ff) << 16) | ((val & 0x00ff0000) >> 16); + } + } + } + } }; #endif // __RENDER_COPYUTIL__ diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp index 4b1087826b5..0137e23acce 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.cpp +++ b/src/osd/modules/render/d3d/d3dhlsl.cpp @@ -1098,9 +1098,9 @@ rgb_t shaders::apply_color_convolution(rgb_t color) b = chroma[2] * saturation + luma; return rgb_t( - std::max(0, std::min(255, int(r * 255.0f))), - std::max(0, std::min(255, int(g * 255.0f))), - std::max(0, std::min(255, int(b * 255.0f)))); + std::clamp(int(r * 255.0f), 0, 255), + std::clamp(int(g * 255.0f), 0, 255), + std::clamp(int(b * 255.0f), 0, 255)); } int shaders::color_convolution_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum) diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp index 5695e4a2c7c..3f99bfc09f0 100644 --- a/src/osd/modules/render/drawbgfx.cpp +++ b/src/osd/modules/render/drawbgfx.cpp @@ -108,8 +108,7 @@ renderer_bgfx::renderer_bgfx(std::shared_ptr<osd_window> w) renderer_bgfx::~renderer_bgfx() { bgfx::reset(0, 0, BGFX_RESET_NONE); - //bgfx::touch(0); - //bgfx::frame(); + if (m_avi_writer != nullptr && m_avi_writer->recording()) { m_avi_writer->stop(); @@ -125,6 +124,9 @@ renderer_bgfx::~renderer_bgfx() } // Cleanup. + if (m_ortho_view) + delete m_ortho_view; + delete m_chains; delete m_effects; delete m_shaders; @@ -349,7 +351,7 @@ int renderer_bgfx::create() m_sliders_dirty = true; uint32_t flags = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT; - m_texture_cache = m_textures->create_texture("#cache", bgfx::TextureFormat::RGBA8, CACHE_SIZE, CACHE_SIZE, nullptr, flags); + m_texture_cache = m_textures->create_texture("#cache", bgfx::TextureFormat::BGRA8, CACHE_SIZE, CACHE_SIZE, nullptr, flags); memset(m_white, 0xff, sizeof(uint32_t) * 16 * 16); m_texinfo.push_back(rectangle_packer::packable_rectangle(WHITE_HASH, PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32), 16, 16, 16, nullptr, m_white)); @@ -391,8 +393,8 @@ void renderer_bgfx::record() else { m_avi_writer->record(m_options.bgfx_avi_name()); - m_avi_target = m_targets->create_target("avibuffer", bgfx::TextureFormat::RGBA8, m_width[0], m_height[0], TARGET_STYLE_CUSTOM, false, true, 1, 0); - m_avi_texture = bgfx::createTexture2D(m_width[0], m_height[0], false, 1, bgfx::TextureFormat::RGBA8, BGFX_TEXTURE_BLIT_DST | BGFX_TEXTURE_READ_BACK); + m_avi_target = m_targets->create_target("avibuffer", bgfx::TextureFormat::BGRA8, m_width[0], m_height[0], TARGET_STYLE_CUSTOM, false, true, 1, 0); + m_avi_texture = bgfx::createTexture2D(m_width[0], m_height[0], false, 1, bgfx::TextureFormat::BGRA8, BGFX_TEXTURE_BLIT_DST | BGFX_TEXTURE_READ_BACK); if (m_avi_view == nullptr) { @@ -599,9 +601,9 @@ void renderer_bgfx::render_textured_quad(render_primitive* prim, bgfx::Transient bgfx::TextureHandle texture = BGFX_INVALID_HANDLE; if (is_screen) { - const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_argb32(prim->flags & PRIMFLAG_TEXFORMAT_MASK + const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgra32(prim->flags & PRIMFLAG_TEXFORMAT_MASK , tex_width, tex_height, prim->texture.rowpixels, prim->texture.palette, prim->texture.base); - texture = bgfx::createTexture2D(tex_width, tex_height, false, 1, bgfx::TextureFormat::RGBA8, texture_flags, mem); + texture = bgfx::createTexture2D(tex_width, tex_height, false, 1, bgfx::TextureFormat::BGRA8, texture_flags, mem); } else { @@ -1164,10 +1166,11 @@ void renderer_bgfx::process_atlas_packs(std::vector<std::vector<rectangle_packer continue; } m_hash_to_entry[rect.hash()] = rect; - bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::RGBA8; + bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8; uint16_t pitch = rect.width(); - const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, rect.format(), rect.rowpixels(), rect.height(), rect.palette(), rect.base(), &pitch); - bgfx::updateTexture2D(m_texture_cache->texture(), 0, 0, rect.x(), rect.y(), rect.width(), rect.height(), mem, pitch); + int convert_stride = 1; + const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, rect.format(), rect.rowpixels(), rect.height(), rect.palette(), rect.base(), pitch, convert_stride); + bgfx::updateTexture2D(m_texture_cache->texture(), 0, 0, rect.x(), rect.y(), rect.width() / convert_stride, rect.height(), mem, pitch); } } } diff --git a/src/osd/modules/sound/coreaudio_sound.cpp b/src/osd/modules/sound/coreaudio_sound.cpp index dd9c953ceb5..dcc74ec5fe9 100644 --- a/src/osd/modules/sound/coreaudio_sound.cpp +++ b/src/osd/modules/sound/coreaudio_sound.cpp @@ -83,7 +83,7 @@ private: EFFECT_COUNT_MAX = 10 }; - uint32_t clamped_latency() const { return unsigned(std::max(std::min(m_audio_latency, int(LATENCY_MAX)), int(LATENCY_MIN))); } + uint32_t clamped_latency() const { return unsigned(std::clamp<int>(m_audio_latency, LATENCY_MIN, LATENCY_MAX)); } uint32_t buffer_avail() const { return ((m_writepos >= m_playpos) ? m_buffer_size : 0) + m_playpos - m_writepos; } uint32_t buffer_used() const { return ((m_playpos > m_writepos) ? m_buffer_size : 0) + m_writepos - m_playpos; } @@ -320,7 +320,7 @@ void sound_coreaudio::update_audio_stream(bool is_throttled, int16_t const *buff void sound_coreaudio::set_mastervolume(int attenuation) { - int const clamped_attenuation = std::max(std::min(attenuation, 0), -32); + int const clamped_attenuation = std::clamp(attenuation, -32, 0); m_scale = (-32 == clamped_attenuation) ? 0 : (int32_t)(pow(10.0, clamped_attenuation / 20.0) * 128); } diff --git a/src/osd/modules/sound/direct_sound.cpp b/src/osd/modules/sound/direct_sound.cpp index 45c3d8a0d44..fcdc13e07df 100644 --- a/src/osd/modules/sound/direct_sound.cpp +++ b/src/osd/modules/sound/direct_sound.cpp @@ -359,7 +359,7 @@ void sound_direct_sound::update_audio_stream( void sound_direct_sound::set_mastervolume(int attenuation) { // clamp the attenuation to 0-32 range - attenuation = std::max(std::min(attenuation, 0), -32); + attenuation = std::clamp(attenuation, -32, 0); // set the master volume if (m_stream_buffer) diff --git a/src/osd/modules/sound/pa_sound.cpp b/src/osd/modules/sound/pa_sound.cpp index 41645318672..c71852df8e8 100644 --- a/src/osd/modules/sound/pa_sound.cpp +++ b/src/osd/modules/sound/pa_sound.cpp @@ -192,7 +192,7 @@ int sound_pa::init(osd_options const &options) m_skip_threshold_ticks = 0; m_osd_tps = osd_ticks_per_second(); m_buffer_min_ct = INT_MAX; - m_audio_latency = std::min<int>(std::max<int>(m_audio_latency, LATENCY_MIN), LATENCY_MAX); + m_audio_latency = std::clamp<int>(m_audio_latency, LATENCY_MIN, LATENCY_MAX); try { m_ab = new audio_buffer<s16>(m_sample_rate, 2); diff --git a/src/osd/modules/sound/sdl_sound.cpp b/src/osd/modules/sound/sdl_sound.cpp index 5ff8f2e6821..19689541858 100644 --- a/src/osd/modules/sound/sdl_sound.cpp +++ b/src/osd/modules/sound/sdl_sound.cpp @@ -284,7 +284,7 @@ void sound_sdl::update_audio_stream(bool is_throttled, const int16_t *buffer, in void sound_sdl::set_mastervolume(int _attenuation) { // clamp the attenuation to 0-32 range - attenuation = std::max(std::min(_attenuation, 0), -32); + attenuation = std::clamp(_attenuation, -32, 0); if (stream_in_initialized) { @@ -373,7 +373,7 @@ int sound_sdl::init(const osd_options &options) sdl_xfer_samples = obtained.samples; // pin audio latency - audio_latency = std::max(std::min(m_audio_latency, MAX_AUDIO_LATENCY), 1); + audio_latency = std::clamp(m_audio_latency, 1, MAX_AUDIO_LATENCY); // compute the buffer sizes stream_buffer_size = (sample_rate() * 2 * sizeof(int16_t) * (2 + audio_latency)) / 30; diff --git a/src/osd/modules/sound/xaudio2_sound.cpp b/src/osd/modules/sound/xaudio2_sound.cpp index 9c76e16c07b..40697ac9aaf 100644 --- a/src/osd/modules/sound/xaudio2_sound.cpp +++ b/src/osd/modules/sound/xaudio2_sound.cpp @@ -419,7 +419,7 @@ void sound_xaudio2::set_mastervolume(int attenuation) HRESULT result; // clamp the attenuation to 0-32 range - attenuation = std::max(std::min(attenuation, 0), -32); + attenuation = std::clamp(attenuation, -32, 0); // Ranges from 1.0 to XAUDIO2_MAX_VOLUME_LEVEL indicate additional gain // Ranges from 0 to 1.0 indicate a reduced volume level diff --git a/src/osd/osdcore.cpp b/src/osd/osdcore.cpp index 51a9aaf207c..f883e50f321 100644 --- a/src/osd/osdcore.cpp +++ b/src/osd/osdcore.cpp @@ -6,7 +6,7 @@ #include <chrono> #if defined(SDLMAME_ANDROID) -#include <SDL2/SDL.h> +#include <android/log.h> #endif #ifdef _WIN32 @@ -66,7 +66,7 @@ void osd_output::pop(osd_output *delegate) void osd_vprintf_error(util::format_argument_pack<std::ostream> const &args) { #if defined(SDLMAME_ANDROID) - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "%s", util::string_format(args).c_str()); + __android_log_write(ANDROID_LOG_ERROR, "%s", util::string_format(args).c_str()); #else if (m_ptr >= 0) m_stack[m_ptr]->output_callback(OSD_OUTPUT_CHANNEL_ERROR, args); #endif @@ -81,7 +81,7 @@ void osd_vprintf_error(util::format_argument_pack<std::ostream> const &args) void osd_vprintf_warning(util::format_argument_pack<std::ostream> const &args) { #if defined(SDLMAME_ANDROID) - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "%s", util::string_format(args).c_str()); + __android_log_write(ANDROID_LOG_WARN, "%s", util::string_format(args).c_str()); #else if (m_ptr >= 0) m_stack[m_ptr]->output_callback(OSD_OUTPUT_CHANNEL_WARNING, args); #endif @@ -96,7 +96,7 @@ void osd_vprintf_warning(util::format_argument_pack<std::ostream> const &args) void osd_vprintf_info(util::format_argument_pack<std::ostream> const &args) { #if defined(SDLMAME_ANDROID) - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "%s", util::string_format(args).c_str()); + __android_log_write(ANDROID_LOG_INFO, "%s", util::string_format(args).c_str()); #else if (m_ptr >= 0) m_stack[m_ptr]->output_callback(OSD_OUTPUT_CHANNEL_INFO, args); #endif @@ -111,7 +111,7 @@ void osd_vprintf_info(util::format_argument_pack<std::ostream> const &args) void osd_vprintf_verbose(util::format_argument_pack<std::ostream> const &args) { #if defined(SDLMAME_ANDROID) - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_VERBOSE, "%s", util::string_format(args).c_str()); + __android_log_write( ANDROID_LOG_VERBOSE, "%s", util::string_format(args).c_str()); #else if (m_ptr >= 0) m_stack[m_ptr]->output_callback(OSD_OUTPUT_CHANNEL_VERBOSE, args); #endif @@ -126,7 +126,7 @@ void osd_vprintf_verbose(util::format_argument_pack<std::ostream> const &args) void osd_vprintf_debug(util::format_argument_pack<std::ostream> const &args) { #if defined(SDLMAME_ANDROID) - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "%s", util::string_format(args).c_str()); + __android_log_write(ANDROID_LOG_DEBUG, "%s", util::string_format(args).c_str()); #else if (m_ptr >= 0) m_stack[m_ptr]->output_callback(OSD_OUTPUT_CHANNEL_DEBUG, args); #endif diff --git a/src/tools/srcclean.cpp b/src/tools/srcclean.cpp index 7f52c3c6feb..052d2a37334 100644 --- a/src/tools/srcclean.cpp +++ b/src/tools/srcclean.cpp @@ -38,6 +38,9 @@ may have spacing adjusted in a way that affects behaviour when uncommented + Known JSON limitations: + * Doesn't detect invalid numbers or literals + Known XML limitations: * No special handling for CDATA * No special handling for processing instructions @@ -102,14 +105,20 @@ protected: static constexpr char32_t HORIZONTAL_TAB = 0x0000'0009U; static constexpr char32_t LINE_FEED = 0x0000'000aU; static constexpr char32_t VERTICAL_TAB = 0x0000'000bU; + static constexpr char32_t FORM_FEED = 0x0000'000cU; + static constexpr char32_t C0_CONTROL_LAST = 0x0000'001fU; static constexpr char32_t SPACE = 0x0000'0020U; static constexpr char32_t DOUBLE_QUOTE = 0x0000'0022U; static constexpr char32_t SINGLE_QUOTE = 0x0000'0027U; + static constexpr char32_t ASTERISK = 0x0000'002aU; static constexpr char32_t HYPHEN_MINUS = 0x0000'002dU; + static constexpr char32_t SLASH = 0x0000'002fU; static constexpr char32_t QUESTION_MARK = 0x0000'003fU; static constexpr char32_t BACKSLASH = 0x0000'005cU; static constexpr char32_t BASIC_LATIN_LAST = 0x0000'007fU; static constexpr char32_t CYRILLIC_SUPPLEMENT_LAST = 0x0000'052fU; + static constexpr char32_t LINE_SEPARATOR = 0x0000'2028U; + static constexpr char32_t PARAGRAPH_SEPARATOR = 0x0000'2029U; template <typename OutputIt> cleaner_base(OutputIt &&output, newline newline_mode, unsigned tab_width); @@ -825,8 +834,6 @@ protected: void output_character(char32_t ch); private: - static constexpr char32_t ASTERISK = 0x0000'002aU; - static constexpr char32_t SLASH = 0x0000'002fU; static constexpr char32_t UPPERCASE_FIRST = 0x0000'0041U; static constexpr char32_t UPPERCASE_B = 0x0000'0042U; static constexpr char32_t UPPERCASE_X = 0x0000'0058U; @@ -1741,6 +1748,289 @@ void lua_cleaner::process_long_string_constant(char32_t ch) /*************************************************************************** + JSON DATA CLEANER CLASS +***************************************************************************/ + +class json_cleaner : public cleaner_base +{ +public: + template <typename OutputIt> + json_cleaner(OutputIt &&output, newline newline_mode, unsigned tab_width); + + virtual bool affected() const override; + virtual void summarise(std::ostream &os) const override; + +protected: + void output_character(char32_t ch); + +private: + enum class parse_state + { + DEFAULT, + COMMENT, + LINE_COMMENT, + STRING_CONSTANT + }; + + virtual void process_characters(char32_t const *begin, char32_t const *end) override; + virtual void input_complete() override; + + void process_default(char32_t ch); + void process_comment(char32_t ch); + void process_line_comment(char32_t ch); + void process_text(char32_t ch); + + parse_state m_parse_state = parse_state::DEFAULT; + std::uint64_t m_input_line = 1U; + bool m_escape = false; + std::uint64_t m_comment_line = 0U; + + std::uint64_t m_tabs_escaped = 0U; + std::uint64_t m_newlines_escaped = 0U; + std::uint64_t m_form_feeds_escaped = 0U; + std::uint64_t m_line_separators_escaped = 0U; + std::uint64_t m_paragraph_separators_escaped = 0U; + std::uint64_t m_c0_control_escaped = 0U; + std::uint64_t m_non_ascii = 0U; +}; + + +template <typename OutputIt> +json_cleaner::json_cleaner( + OutputIt &&output, + newline newline_mode, + unsigned tab_width) + : cleaner_base(std::forward<OutputIt>(output), newline_mode, tab_width) +{ +} + + +bool json_cleaner::affected() const +{ + return + cleaner_base::affected() || + m_tabs_escaped || + m_newlines_escaped || + m_form_feeds_escaped || + m_line_separators_escaped || + m_paragraph_separators_escaped || + m_c0_control_escaped || + m_non_ascii; +} + + +void json_cleaner::summarise(std::ostream &os) const +{ + cleaner_base::summarise(os); + if (m_tabs_escaped) + util::stream_format(os, "%1$u tab(s) escaped\n", m_tabs_escaped); + if (m_newlines_escaped) + util::stream_format(os, "%1$u line feed(s) escaped\n", m_newlines_escaped); + if (m_form_feeds_escaped) + util::stream_format(os, "%1$u form feed(s) escaped\n", m_form_feeds_escaped); + if (m_line_separators_escaped) + util::stream_format(os, "%1$u line separator(s) escaped\n", m_line_separators_escaped); + if (m_paragraph_separators_escaped) + util::stream_format(os, "%1$u paragraph separator(s) escaped\n", m_paragraph_separators_escaped); + if (m_c0_control_escaped) + util::stream_format(os, "%1$u C0 control character(s) escaped\n", m_c0_control_escaped); + if (m_non_ascii) + util::stream_format(os, "%1$u non-ASCII character(s) replaced\n", m_non_ascii); +} + + +void json_cleaner::output_character(char32_t ch) +{ + switch (m_parse_state) + { + case parse_state::DEFAULT: + if (BASIC_LATIN_LAST < ch) + { + ++m_non_ascii; + ch = QUESTION_MARK; + } + break; + case parse_state::COMMENT: + case parse_state::LINE_COMMENT: + case parse_state::STRING_CONSTANT: + break; + } + + cleaner_base::output_character(ch); +} + + +void json_cleaner::process_characters(char32_t const *begin, char32_t const *end) +{ + while (begin != end) + { + char32_t const ch(*begin++); + switch (m_parse_state) + { + case parse_state::DEFAULT: + process_default(ch); + break; + case parse_state::COMMENT: + process_comment(ch); + break; + case parse_state::LINE_COMMENT: + process_line_comment(ch); + break; + case parse_state::STRING_CONSTANT: + process_text(ch); + break; + } + + if (LINE_FEED == ch) + ++m_input_line; + } +} + + +void json_cleaner::input_complete() +{ + switch (m_parse_state) + { + case parse_state::COMMENT: + throw std::runtime_error(util::string_format("unterminated multi-line comment beginning on line %1$u", m_comment_line)); + case parse_state::STRING_CONSTANT: + throw std::runtime_error(util::string_format("unterminated string literal on line %1$u", m_input_line)); + default: + break; + } +} + + +void json_cleaner::process_default(char32_t ch) +{ + switch (ch) + { + case DOUBLE_QUOTE: + m_parse_state = parse_state::STRING_CONSTANT; + break; + case ASTERISK: + if (m_escape) + { + m_parse_state = parse_state::COMMENT; + m_comment_line = m_input_line; + set_tab_limit(); + } + break; + case SLASH: + if (m_escape) + m_parse_state = parse_state::LINE_COMMENT; + break; + } + m_escape = (SLASH == ch) && !m_escape; + output_character(ch); +} + + +void json_cleaner::process_comment(char32_t ch) +{ + switch (ch) + { + case SLASH: + if (m_escape) + { + m_parse_state = parse_state::DEFAULT; + m_comment_line = 0U; + output_character(ch); + reset_tab_limit(); + } + else + { + output_character(ch); + } + m_escape = false; + break; + default: + m_escape = ASTERISK == ch; + output_character(ch); + } +} + + +void json_cleaner::process_line_comment(char32_t ch) +{ + switch (ch) + { + case LINE_FEED: + m_parse_state = parse_state::DEFAULT; + [[fallthrough]]; + default: + output_character(ch); + } +} + + +void json_cleaner::process_text(char32_t ch) +{ + switch (ch) + { + case HORIZONTAL_TAB: + ++m_tabs_escaped; + if (!m_escape) + output_character(BACKSLASH); + output_character(char32_t(std::uint8_t('t'))); + break; + case LINE_FEED: + ++m_newlines_escaped; + if (!m_escape) + output_character(BACKSLASH); + output_character(char32_t(std::uint8_t('n'))); + break; + case FORM_FEED: + ++m_form_feeds_escaped; + if (!m_escape) + output_character(BACKSLASH); + output_character(char32_t(std::uint8_t('f'))); + break; + case LINE_SEPARATOR: + ++m_line_separators_escaped; + if (!m_escape) + output_character(BACKSLASH); + output_character(char32_t(std::uint8_t('u'))); + output_character(char32_t(std::uint8_t('2'))); + output_character(char32_t(std::uint8_t('0'))); + output_character(char32_t(std::uint8_t('2'))); + output_character(char32_t(std::uint8_t('8'))); + break; + case PARAGRAPH_SEPARATOR: + ++m_paragraph_separators_escaped; + if (!m_escape) + output_character(BACKSLASH); + output_character(char32_t(std::uint8_t('u'))); + output_character(char32_t(std::uint8_t('2'))); + output_character(char32_t(std::uint8_t('0'))); + output_character(char32_t(std::uint8_t('2'))); + output_character(char32_t(std::uint8_t('9'))); + break; + default: + if (C0_CONTROL_LAST >= ch) + { + ++m_c0_control_escaped; + if (!m_escape) + output_character(BACKSLASH); + output_character(char32_t(std::uint8_t('u'))); + output_character(char32_t(std::uint8_t('0'))); + output_character(char32_t(std::uint8_t('0'))); + output_character(char32_t(std::uint8_t('0') + (ch / 0x10U))); + output_character(char32_t(std::uint8_t('0') + (ch % 0x10U))); + } + else + { + output_character(ch); + if (!m_escape && (DOUBLE_QUOTE == ch)) + m_parse_state = parse_state::DEFAULT; + } + } + m_escape = (BACKSLASH == ch) && !m_escape; +} + + + +/*************************************************************************** XML DATA CLEANER CLASS ***************************************************************************/ @@ -1894,6 +2184,13 @@ bool is_lua_source_extension(char const *ext) } +bool is_json_extension(char const *ext) +{ + return + !core_stricmp(ext, ".json"); +} + + bool is_xml_extension(char const *ext) { return @@ -1974,12 +2271,15 @@ int main(int argc, char *argv[]) char const *const ext(std::strrchr(argv[i], '.')); bool const is_c_file(ext && is_c_source_extension(ext)); bool const is_lua_file(ext && is_lua_source_extension(ext)); + bool const is_json_file(ext && is_json_extension(ext)); bool const is_xml_file(ext && is_xml_extension(ext)); std::unique_ptr<cleaner_base> cleaner; if (is_c_file) cleaner = std::make_unique<cpp_cleaner>(std::back_inserter(output), newline_mode, 4U); else if (is_lua_file) cleaner = std::make_unique<lua_cleaner>(std::back_inserter(output), newline_mode, 4U); + else if (is_json_file) + cleaner = std::make_unique<json_cleaner>(std::back_inserter(output), newline_mode, 4U); else if (is_xml_file) cleaner = std::make_unique<xml_cleaner>(std::back_inserter(output), newline_mode, 4U); else |