diff options
Diffstat (limited to 'src')
61 files changed, 2543 insertions, 1245 deletions
diff --git a/src/devices/cpu/rii/riidasm.cpp b/src/devices/cpu/rii/riidasm.cpp index ab27b3fa291..cad53e121c9 100644 --- a/src/devices/cpu/rii/riidasm.cpp +++ b/src/devices/cpu/rii/riidasm.cpp @@ -321,6 +321,7 @@ offs_t riscii_disassembler::disassemble(std::ostream &stream, offs_t pc, const r case 0x2700: util::stream_format(stream, "%-8s", "RPT"); format_register(stream, opcode & 0x00ff); + words |= STEP_OVER | step_over_extra(1); break; case 0x2b00: diff --git a/src/devices/cpu/rii/riscii.cpp b/src/devices/cpu/rii/riscii.cpp index ea1b95594ab..89c3eb533ea 100644 --- a/src/devices/cpu/rii/riscii.cpp +++ b/src/devices/cpu/rii/riscii.cpp @@ -10,7 +10,8 @@ first generation of PIC-like microcontrollers, the EM78 series, has 13-bit opcodes.) - Currently this device is just a stub with no actual execution core. + Currently the execution core is mostly complete, though interrupts and + on-chip peripherals are completely unemulated. ***************************************************************************/ @@ -21,10 +22,37 @@ // device type definitions DEFINE_DEVICE_TYPE(RISCII, riscii_series_device, "riscii", "Elan RISC II") +ALLOW_SAVE_TYPE(riscii_series_device::exec_state); + + +//************************************************************************** +// DEVICE CONSTRUCTION AND INITIALIZATION +//************************************************************************** void riscii_series_device::regs_map(address_map &map) { - map(0x0000, 0x007f).mirror(m_bankmask << 8).ram(); // TODO: special function registers + // 0x00 (INDF0) is not physically implemented + map(0x0001, 0x0001).rw(FUNC(riscii_series_device::fsr0_r), FUNC(riscii_series_device::fsr0_w)); + map(0x0002, 0x0002).rw(FUNC(riscii_series_device::pcl_r), FUNC(riscii_series_device::pcl_w)); + map(0x0003, 0x0003).rw(FUNC(riscii_series_device::pcm_r), FUNC(riscii_series_device::pcm_w)); + map(0x0004, 0x0004).rw(FUNC(riscii_series_device::pch_r), FUNC(riscii_series_device::pch_w)); + map(0x0005, 0x0005).rw(FUNC(riscii_series_device::bsr_r), FUNC(riscii_series_device::bsr_w)); + map(0x0006, 0x0006).rw(FUNC(riscii_series_device::stkptr_r), FUNC(riscii_series_device::stkptr_w)); + map(0x0007, 0x0007).rw(FUNC(riscii_series_device::bsr1_r), FUNC(riscii_series_device::bsr1_w)); + // 0x08 (INDF1) is not physically implemented + map(0x0009, 0x0009).rw(FUNC(riscii_series_device::fsr1_r), FUNC(riscii_series_device::fsr1_w)); + map(0x000a, 0x000a).rw(FUNC(riscii_series_device::acc_r), FUNC(riscii_series_device::acc_w)); + map(0x000b, 0x000b).rw(FUNC(riscii_series_device::tabptrl_r), FUNC(riscii_series_device::tabptrl_w)); + map(0x000c, 0x000c).rw(FUNC(riscii_series_device::tabptrm_r), FUNC(riscii_series_device::tabptrm_w)); + map(0x000d, 0x000d).rw(FUNC(riscii_series_device::tabptrh_r), FUNC(riscii_series_device::tabptrh_w)); + map(0x000e, 0x000e).rw(FUNC(riscii_series_device::cpucon_r), FUNC(riscii_series_device::cpucon_w)); + map(0x000f, 0x000f).rw(FUNC(riscii_series_device::status_r), FUNC(riscii_series_device::status_w)); + map(0x0010, 0x0010).ram(); // TODO: TRL2 + map(0x0011, 0x0011).rw(FUNC(riscii_series_device::prodl_r), FUNC(riscii_series_device::prodl_w)); + map(0x0012, 0x0012).rw(FUNC(riscii_series_device::prodh_r), FUNC(riscii_series_device::prodh_w)); + map(0x0013, 0x0029).ram(); // TODO: other special function registers + map(0x002b, 0x002b).rw(FUNC(riscii_series_device::post_id_r), FUNC(riscii_series_device::post_id_w)); + map(0x002c, 0x007f).ram(); // TODO: other special function registers for (unsigned b = 0; b <= m_maxbank; b++) map(0x0080 | (b << 8), 0x00ff | (b << 8)).ram(); } @@ -40,21 +68,25 @@ riscii_series_device::riscii_series_device(const machine_config &mconfig, device , m_regs_config("register", ENDIANNESS_LITTLE, 8, 8 + bankbits, 0, address_map_constructor(FUNC(riscii_series_device::regs_map), this)) , m_program(nullptr) , m_regs(nullptr) + , m_cache(nullptr) , m_prgbits(prgbits) , m_bankmask((1 << bankbits) - 1) , m_maxbank(maxbank) , m_pc(0) , m_acc(0) - , m_fsr0(0) - , m_bsr(0) + , m_fsr{0, 0} + , m_bsr{0, 0} , m_tabptr(0) , m_stkptr(0) , m_cpucon(0) , m_status(0) + , m_prod(0) + , m_post_id(0) , m_icount(0) + , m_exec_state(EXEC_CYCLE1) + , m_repeat(0) + , m_curreg(0) { - m_fsr1.w = 0; - m_prod.w = 0; } riscii_series_device::riscii_series_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) @@ -74,54 +106,1048 @@ void riscii_series_device::device_start() { m_program = &space(AS_PROGRAM); m_regs = &space(AS_DATA); + m_cache = m_program->cache<1, -1, ENDIANNESS_LITTLE>(); set_icountptr(m_icount); state_add(RII_PC, "PC", m_pc).mask((1 << m_prgbits) - 1); - state_add(STATE_GENPC, "GENPC", m_pc).callimport().noshow(); - state_add(STATE_GENPCBASE, "CURPC", m_pc).callimport().noshow(); + state_add(STATE_GENPC, "GENPC", m_pc).mask((1 << m_prgbits) - 1).noshow(); + state_add(STATE_GENPCBASE, "CURPC", m_ppc).mask((1 << m_prgbits) - 1).noshow(); + state_add(RII_REPEAT, "REPEAT", m_repeat); state_add(RII_ACC, "ACC", m_acc); - state_add(RII_BSR, "BSR", m_bsr).mask(m_bankmask); - state_add(RII_FSR0, "FSR0", m_fsr0); - state_add(RII_BSR1, "BSR1", m_fsr1.b.h).mask(m_bankmask); - state_add(RII_FSR1, "FSR1", m_fsr1.b.l); // TODO: high bit forced to 1 + state_add(RII_BSR, "BSR", m_bsr[0]).mask(m_bankmask); + state_add(RII_FSR0, "FSR0", m_fsr[0]); + state_add(RII_BSR1, "BSR1", m_bsr[1]).mask(m_bankmask); + state_add(RII_FSR1, "FSR1", m_fsr[1]); // TODO: high bit forced to 1 state_add(RII_TABPTR, "TABPTR", m_tabptr).mask(0x800000 + (1 << (m_prgbits + 1)) - 1); state_add(RII_STKPTR, "STKPTR", m_stkptr); state_add(RII_CPUCON, "CPUCON", m_cpucon).mask(0x9f); state_add(RII_STATUS, "STATUS", m_status); - state_add(RII_PROD, "PROD", m_prod.w); + state_add(STATE_GENFLAGS, "CURFLAGS", m_status).noshow().formatstr("%8s"); + state_add(RII_PROD, "PROD", m_prod); + state_add(RII_POST_ID, "POST_ID", m_post_id); save_item(NAME(m_pc)); + save_item(NAME(m_ppc)); save_item(NAME(m_acc)); - save_item(NAME(m_fsr0)); save_item(NAME(m_bsr)); - save_item(NAME(m_fsr1.w)); + save_item(NAME(m_fsr)); save_item(NAME(m_tabptr)); save_item(NAME(m_stkptr)); save_item(NAME(m_cpucon)); save_item(NAME(m_status)); - save_item(NAME(m_prod.w)); + save_item(NAME(m_prod)); + save_item(NAME(m_post_id)); + save_item(NAME(m_exec_state)); + save_item(NAME(m_repeat)); + save_item(NAME(m_curreg)); } void riscii_series_device::device_reset() { - m_pc = 0x00000; - m_fsr0 = 0x00; - m_bsr = 0x00; - m_fsr1.w = 0x0080; + m_pc = m_ppc = 0x00000; + m_fsr[0] = 0x00; + m_bsr[0] = 0x00; + m_fsr[1] = 0x80; + m_bsr[1] = 0x00; m_tabptr = 0x000000; m_stkptr = 0x00; m_cpucon &= 0x01; + m_status |= 0xc0; + m_post_id = 0xf0; + m_exec_state = EXEC_CYCLE1; + m_repeat = 0x00; +} + + +//************************************************************************** +// REGISTER HANDLERS +//************************************************************************** + +u8 riscii_series_device::fsr0_r() +{ + return m_fsr[0]; +} + +void riscii_series_device::fsr0_w(u8 data) +{ + m_fsr[0] = data; +} + +u8 riscii_series_device::bsr_r() +{ + return m_bsr[0]; +} + +void riscii_series_device::bsr_w(u8 data) +{ + m_bsr[0] = data & m_bankmask; +} + +u8 riscii_series_device::fsr1_r() +{ + return m_fsr[1]; +} + +void riscii_series_device::fsr1_w(u8 data) +{ + m_fsr[1] = data | 0x80; +} + +u8 riscii_series_device::bsr1_r() +{ + return m_bsr[1]; +} + +void riscii_series_device::bsr1_w(u8 data) +{ + m_bsr[1] = data & m_bankmask; +} + +u8 riscii_series_device::pcl_r() +{ + return m_pc & 0x000ff; +} + +void riscii_series_device::pcl_w(u8 data) +{ + m_pc = (m_pc & 0xfff00) | data; +} + +u8 riscii_series_device::pcm_r() +{ + return (m_pc & 0x0ff00) >> 8; +} + +void riscii_series_device::pcm_w(u8 data) +{ + m_pc = (m_pc & 0xf00ff) | u32(data) << 8; +} + +u8 riscii_series_device::pch_r() +{ + return (m_pc & 0xf0000) >> 16; +} + +void riscii_series_device::pch_w(u8 data) +{ + if (m_prgbits > 16) + m_pc = (m_pc & 0x0ffff) | u32(data & ((1 << (m_prgbits - 16)) - 1)) << 16; +} + +u8 riscii_series_device::tabptrl_r() +{ + return m_tabptr & 0x0000ff; +} + +void riscii_series_device::tabptrl_w(u8 data) +{ + m_tabptr = (m_tabptr & 0xffff00) | data; +} + +u8 riscii_series_device::tabptrm_r() +{ + return (m_tabptr & 0x00ff00) >> 8; +} + +void riscii_series_device::tabptrm_w(u8 data) +{ + m_tabptr = (m_tabptr & 0xff00ff) | u32(data) << 8; +} + +u8 riscii_series_device::tabptrh_r() +{ + return (m_tabptr & 0xff0000) >> 16; +} + +void riscii_series_device::tabptrh_w(u8 data) +{ + m_tabptr = (m_tabptr & 0x00ffff) | u32(data & (0x80 | ((1 << (m_prgbits - 15)) - 1))) << 16; +} + +u8 riscii_series_device::acc_r() +{ + return m_acc; +} + +void riscii_series_device::acc_w(u8 data) +{ + m_acc = data; +} + +u8 riscii_series_device::stkptr_r() +{ + return m_stkptr; +} + +void riscii_series_device::stkptr_w(u8 data) +{ + m_stkptr = data; +} + +u8 riscii_series_device::cpucon_r() +{ + return m_cpucon; +} + +void riscii_series_device::cpucon_w(u8 data) +{ + m_cpucon = data & 0x9f; +} + +u8 riscii_series_device::status_r() +{ + return m_status; +} + +void riscii_series_device::status_w(u8 data) +{ + m_status = (m_status & 0xc0) | (data & 0x3f); +} + +u8 riscii_series_device::prodl_r() +{ + return m_prod & 0x00ff; +} + +void riscii_series_device::prodl_w(u8 data) +{ + m_prod = (m_prod & 0xff00) | data; +} + +u8 riscii_series_device::prodh_r() +{ + return m_prod >> 8; +} + +void riscii_series_device::prodh_w(u8 data) +{ + m_prod = (m_prod & 0x00ff) | u16(data) << 8; +} + +u8 riscii_series_device::post_id_r() +{ + return m_post_id; +} + +void riscii_series_device::post_id_w(u8 data) +{ + m_post_id = data; +} + + +//************************************************************************** +// MEMORY HELPERS +//************************************************************************** + +u16 riscii_series_device::get_banked_address(u8 reg) +{ + if (reg == 0x00) + { + // INDF0 address comes from BSR and FSR0 + u16 bfsr0 = u16(m_bsr[0]) << 8 | m_fsr[0]; + if (BIT(m_post_id, 0)) + { + // Auto increment/decrement (no carry into BSR) + if (BIT(m_post_id, 4)) + ++m_fsr[0]; + else + --m_fsr[0]; + } + return bfsr0; + } + else if (reg == 0x08) + { + // INDF1 address comes from BSR1 and FSR1 + u16 bfsr1 = u16(m_bsr[1]) << 8 | m_fsr[1]; + if (BIT(m_post_id, 1)) + { + // Auto increment/decrement (carry into BSR1) + if (BIT(m_post_id, 5)) + { + m_fsr[1] = (m_fsr[1] + 1) | 0x80; + if (m_fsr[1] == 0x80) + ++m_bsr[1]; + } + else + { + m_fsr[1] = (m_fsr[1] - 1) | 0x80; + if (m_fsr[1] == 0xff) + --m_bsr[1]; + } + } + return bfsr1; + } + else if (reg >= 0x80) + return u16(m_bsr[0]) << 8 | reg; + else + return reg; +} + + +//************************************************************************** +// EXECUTION CORE +//************************************************************************** + +void riscii_series_device::execute_move(u8 dstreg, u8 srcreg) +{ + u8 tmp = m_regs->read_byte(get_banked_address(srcreg)); + m_regs->write_byte(get_banked_address(dstreg), tmp); +} + +void riscii_series_device::execute_add(u8 reg, bool a, bool c) +{ + u16 addr = get_banked_address(reg); + s8 data = m_regs->read_byte(addr); + s16 tmp = s16(data) + s8(m_acc) + (c ? m_status & 0x01 : 0); + bool dc = (data & 0x0f) + (m_acc & 0x0f) + (c ? m_status & 0x01 : 0) >= 0x10; + if (a) + acc_w(tmp & 0xff); + else + m_regs->write_byte(addr, tmp & 0xff); + m_status = (m_status & 0xc0) + | (BIT(tmp, 8) ? 0x01 : 0x00) + | (dc ? 0x02 : 0x00) + | ((tmp & 0xff) == 0 ? 0x04 : 0x00) + | ((tmp < 0) != BIT(tmp, 7) ? 0x08 : 0x00) + | (tmp <= 0 ? 0x10 : 0x00) + | (tmp >= 0 ? 0x20 : 0x00); +} + +void riscii_series_device::execute_sub(u8 reg, bool a, bool c) +{ + u16 addr = get_banked_address(reg); + s8 data = m_regs->read_byte(addr); + s16 tmp = s16(data) - s8(m_acc) - (c ? ~m_status & 0x01 : 0); + bool dc = (data & 0x0f) >= (m_acc & 0x0f) + (c ? ~m_status & 0x01 : 0); + if (a) + acc_w(tmp & 0xff); + else + m_regs->write_byte(addr, tmp & 0xff); + m_status = (m_status & 0xc0) + | (BIT(tmp, 8) ? 0x00 : 0x01) // borrow is inverted + | (dc ? 0x02 : 0x00) + | ((tmp & 0xff) == 0 ? 0x04 : 0x00) + | ((tmp < 0) != BIT(tmp, 7) ? 0x08 : 0x00) + | (tmp <= 0 ? 0x10 : 0x00) + | (tmp >= 0 ? 0x20 : 0x00); +} + +void riscii_series_device::execute_add_imm(u8 data, bool c) +{ + s16 tmp = s16(s8(data)) + s8(m_acc) + (c ? m_status & 0x01 : 0); + bool dc = (data & 0x0f) + (m_acc & 0x0f) + (c ? m_status & 0x01 : 0) >= 0x10; + acc_w(tmp & 0xff); + m_status = (m_status & 0xc0) + | (BIT(tmp, 8) ? 0x01 : 0x00) + | (dc ? 0x02 : 0x00) + | ((tmp & 0xff) == 0 ? 0x04 : 0x00) + | ((tmp < 0) != BIT(tmp, 7) ? 0x08 : 0x00) + | (tmp <= 0 ? 0x10 : 0x00) + | (tmp >= 0 ? 0x20 : 0x00); +} + +void riscii_series_device::execute_sub_imm(u8 data, bool c) +{ + s16 tmp = s16(s8(data)) - s8(m_acc) - (c ? ~m_status & 0x01 : 0); + bool dc = (data & 0x0f) + (m_acc & 0x0f) + (c ? ~m_status & 0x01 : 0) >= 0x10; + acc_w(tmp & 0xff); + m_status = (m_status & 0xc0) + | (BIT(tmp, 8) ? 0x00 : 0x01) // borrow is inverted + | (dc ? 0x02 : 0x00) + | ((tmp & 0xff) == 0 ? 0x04 : 0x00) + | ((tmp < 0) != BIT(tmp, 7) ? 0x08 : 0x00) + | (tmp <= 0 ? 0x10 : 0x00) + | (tmp >= 0 ? 0x20 : 0x00); +} + +void riscii_series_device::execute_adddc(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 data = m_regs->read_byte(addr); + u16 tmp = u16(data) + m_acc + (m_status & 0x01); + bool dc = (data & 0x0f) + (m_acc & 0x0f) + (m_status & 0x01) >= 0x0a; + if (dc) + tmp += 0x06; + if ((tmp & 0x1ff) >= 0xa0) + tmp += 0x60; + if (a) + acc_w(tmp & 0xff); + else + m_regs->write_byte(addr, tmp & 0xff); + m_status = (m_status & 0xf8) + | (BIT(tmp, 8) ? 0x01 : 0x00) + | (dc ? 0x02 : 0x00) + | ((tmp & 0xff) == 0 ? 0x04 : 0x00); +} + +void riscii_series_device::execute_subdb(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 data = m_regs->read_byte(addr); + u16 tmp = u16(data) - m_acc - (~m_status & 0x01); + bool dc = (data & 0x0f) + (~m_acc & 0x0f) + (m_status & 0x01) >= 0x0a; + if (dc) + tmp -= 0x06; + if ((tmp & 0x1ff) >= 0xa0) + tmp -= 0x60; + if (a) + acc_w(tmp & 0xff); + else + m_regs->write_byte(addr, tmp & 0xff); + m_status = (m_status & 0xf8) + | (BIT(tmp, 8) ? 0x00 : 0x01) // borrow is inverted + | (dc ? 0x02 : 0x00) + | ((tmp & 0xff) == 0 ? 0x04 : 0x00); +} + +void riscii_series_device::execute_mul(u8 reg) +{ + m_prod = u16(m_acc) * m_regs->read_byte(get_banked_address(reg)); +} + +void riscii_series_device::execute_mul_imm(u8 data) +{ + m_prod = u16(m_acc) * data; +} + +void riscii_series_device::execute_or(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_acc | m_regs->read_byte(addr); + if (a) + acc_w(tmp); + else + m_regs->write_byte(addr, tmp); + if (tmp == 0) + m_status |= 0x04; + else + m_status &= 0xfb; +} + +void riscii_series_device::execute_and(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_acc & m_regs->read_byte(addr); + if (a) + acc_w(tmp); + else + m_regs->write_byte(addr, tmp); + if (tmp == 0) + m_status |= 0x04; + else + m_status &= 0xfb; +} + +void riscii_series_device::execute_xor(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_acc ^ m_regs->read_byte(addr); + if (a) + acc_w(tmp); + else + m_regs->write_byte(addr, tmp); + if (tmp == 0) + m_status |= 0x04; + else + m_status &= 0xfb; +} + +void riscii_series_device::execute_com(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 tmp = ~m_regs->read_byte(addr); + if (a) + acc_w(tmp); + else + m_regs->write_byte(addr, tmp); + if (tmp == 0) + m_status |= 0x04; + else + m_status &= 0xfb; +} + +void riscii_series_device::execute_clr(u8 reg) +{ + m_regs->write_byte(get_banked_address(reg), 0); + m_status |= 0x04; +} + +void riscii_series_device::execute_rrc(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u16 tmp = m_regs->read_byte(addr) | u16(m_status & 0x01) << 8; + if (a) + acc_w(tmp >> 1); + else + m_regs->write_byte(addr, tmp >> 1); + m_status = (m_status & 0xfe) | (tmp & 0x01); +} + +void riscii_series_device::execute_rlc(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u16 tmp = u16(m_regs->read_byte(addr)) << 1 | (m_status & 0x01); + if (a) + acc_w(tmp & 0xff); + else + m_regs->write_byte(addr, tmp & 0xff); + m_status = (m_status & 0xfe) | (tmp >> 8); +} + +void riscii_series_device::execute_shra(u8 reg) +{ + u8 tmp = m_regs->read_byte(get_banked_address(reg)); + acc_w((tmp >> 1) | (m_status & 0x01) << 7); +} + +void riscii_series_device::execute_shla(u8 reg) +{ + u8 tmp = m_regs->read_byte(get_banked_address(reg)); + acc_w((tmp << 1) | (m_status & 0x01)); +} + +void riscii_series_device::execute_jump(u32 addr) +{ + m_pc = addr; +} + +void riscii_series_device::execute_call(u32 addr) +{ + m_stkptr -= 2; + u16 stkaddr = u16(m_maxbank - (BIT(m_stkptr, 7) ? 0 : 1)) << 8 | 0x80 | (m_stkptr & 0x7e); + m_regs->write_word(stkaddr, swapendian_int16(m_pc & 0xffff)); + execute_jump(addr); +} + +void riscii_series_device::execute_jcc(bool condition) +{ + if (condition) + m_exec_state = static_cast<exec_state>(EXEC_L0JMP + (m_pc >> 16)); + else + m_exec_state = EXEC_NOJMP; +} + +void riscii_series_device::execute_jdnz(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_regs->read_byte(addr) - 1; + if (a) + acc_w(tmp); + else + m_regs->write_byte(addr, tmp); + execute_jcc(tmp != 0); +} + +void riscii_series_device::execute_jinz(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_regs->read_byte(addr) + 1; + if (a) + acc_w(tmp); + else + m_regs->write_byte(addr, tmp); + execute_jcc(tmp != 0); +} + +void riscii_series_device::set_z_acc(u8 tmp) +{ + acc_w(tmp); + if (tmp == 0) + m_status |= 0x04; + else + m_status &= 0xfb; +} + +void riscii_series_device::execute_load(u8 reg) +{ + set_z_acc(m_regs->read_byte(get_banked_address(reg))); +} + +void riscii_series_device::execute_store(u8 reg) +{ + m_regs->write_byte(get_banked_address(reg), m_acc); +} + +void riscii_series_device::execute_test(u8 reg) +{ + u8 tmp = m_regs->read_byte(get_banked_address(reg)); + if (tmp == 0) + m_status |= 0x04; + else + m_status &= 0xfb; +} + +void riscii_series_device::execute_swap(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_regs->read_byte(addr); + if (a) + acc_w((tmp >> 4) | (tmp << 4)); + else + m_regs->write_byte(addr, (tmp >> 4) | (tmp << 4)); +} + +void riscii_series_device::execute_jbc(u8 reg, int b) +{ + execute_jcc(!BIT(m_regs->read_byte(get_banked_address(reg)), b)); +} + +void riscii_series_device::execute_jbs(u8 reg, int b) +{ + execute_jcc(BIT(m_regs->read_byte(get_banked_address(reg)), b)); +} + +void riscii_series_device::execute_bc(u8 reg, int b) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_regs->read_byte(addr) & ~(1 << b); + m_regs->write_byte(addr, tmp); +} + +void riscii_series_device::execute_bs(u8 reg, int b) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_regs->read_byte(addr) | (1 << b); + m_regs->write_byte(addr, tmp); +} + +void riscii_series_device::execute_btg(u8 reg, int b) +{ + u16 addr = get_banked_address(reg); + u8 tmp = m_regs->read_byte(addr) ^ (1 << b); + m_regs->write_byte(addr, tmp); +} + +void riscii_series_device::execute_inc(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u16 tmp = u16(m_regs->read_byte(addr)) + 1; + if (a) + acc_w(tmp & 0xff); + else + m_regs->write_byte(addr, tmp & 0xff); + m_status = (m_status & 0xfa) | ((tmp & 0xff) == 0 ? 0x04 : 0x00) | (tmp >> 8); +} + +void riscii_series_device::execute_dec(u8 reg, bool a) +{ + u16 addr = get_banked_address(reg); + u16 tmp = (u16(m_regs->read_byte(addr)) - 1) & 0x1ff; + if (a) + acc_w(tmp & 0xff); + else + m_regs->write_byte(addr, tmp & 0xff); + m_status = (m_status & 0xfa) | ((tmp & 0xff) == 0 ? 0x04 : 0x00) | (tmp >> 8); +} + +void riscii_series_device::execute_rpt(u8 reg) +{ + m_repeat = m_regs->read_byte(get_banked_address(reg)) - 1; +} + +void riscii_series_device::execute_ret(bool inte) +{ + u16 stkaddr = u16(m_maxbank - (BIT(m_stkptr, 7) ? 0 : 1)) << 8 | 0x80 | (m_stkptr & 0x7e); + execute_jump((m_pc & 0xf0000) | swapendian_int16(m_regs->read_word(stkaddr))); + m_stkptr += 2; + if (inte) + m_cpucon |= 0x04; +} + +void riscii_series_device::execute_wdtc() +{ + logerror("WDTC (PC = %05X)\n", m_ppc); +} + +void riscii_series_device::execute_slep() +{ + logerror("SLEP (PC = %05X)\n", m_ppc); +} + +void riscii_series_device::execute_undef(u16 opcode) +{ + logerror("Undefined opcode %04Xh encountered (PC = %05X)\n", opcode, m_ppc); +} + +void riscii_series_device::execute_cycle1(u16 opcode) +{ + if (BIT(opcode, 15)) + { + if (BIT(opcode, 14)) + { + if (BIT(opcode, 13)) + execute_call((m_pc & 0x3e000) | (opcode & 0x1fff)); + else + execute_jump((m_pc & 0x3e000) | (opcode & 0x1fff)); + } + else + { + if (BIT(opcode, 13)) + execute_move(opcode & 0x00ff, (opcode & 0x1f00) >> 8); + else + execute_move((opcode & 0x1f00) >> 8, opcode & 0x00ff); + } + } + else switch (opcode & 0xff00) + { + case 0x0000: + if (opcode == 0x0001) + execute_wdtc(); + else if (opcode == 0x0002) + execute_slep(); + else if ((opcode & 0x00e0) == 0x0020) + m_exec_state = static_cast<exec_state>((BIT(opcode, 4) ? EXEC_L0CALL : EXEC_L0JMP) + (opcode & 0x000f)); + else if (opcode != 0x0000) // NOP + execute_undef(opcode); + break; + + case 0x0200: case 0x0300: + execute_or(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x0400: case 0x0500: + execute_and(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x0600: case 0x0700: + execute_xor(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x0800: case 0x0900: + execute_com(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x0a00: case 0x0b00: + execute_rrc(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x0c00: case 0x0d00: + execute_rlc(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x0e00: case 0x0f00: + execute_swap(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x1000: case 0x1100: + execute_add(opcode & 0x00ff, !BIT(opcode, 8), false); + break; + + case 0x1200: case 0x1300: + execute_add(opcode & 0x00ff, !BIT(opcode, 8), true); + break; + + case 0x1400: case 0x1500: + execute_adddc(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x1600: case 0x1700: + execute_sub(opcode & 0x00ff, !BIT(opcode, 8), false); + break; + + case 0x1800: case 0x1900: + execute_sub(opcode & 0x00ff, !BIT(opcode, 8), true); + break; + + case 0x1a00: case 0x1b00: + execute_subdb(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x1c00: case 0x1d00: + execute_inc(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x1e00: case 0x1f00: + execute_dec(opcode & 0x00ff, !BIT(opcode, 8)); + break; + + case 0x2000: + execute_load(opcode & 0x00ff); + break; + + case 0x2100: + execute_store(opcode & 0x00ff); + break; + + case 0x2200: + execute_shra(opcode & 0x00ff); + break; + + case 0x2300: + execute_shla(opcode & 0x00ff); + break; + + case 0x2400: + execute_clr(opcode & 0x00ff); + break; + + case 0x2500: + execute_test(opcode & 0x00ff); + break; + + case 0x2600: + execute_mul(opcode & 0x00ff); + break; + + case 0x2700: + execute_rpt(opcode & 0x00ff); + break; + + case 0x2b00: + if ((opcode & 0x00fe) == 0x00fe) + execute_ret(BIT(opcode, 0)); + else + execute_undef(opcode); + break; + + case 0x2c00: + m_curreg = opcode & 0x00ff; + m_exec_state = EXEC_TBRD0; + break; + + case 0x2d00: + m_curreg = opcode & 0x00ff; + m_exec_state = EXEC_TBRD1; + break; + + case 0x2e00: + m_curreg = opcode & 0x00ff; + m_exec_state = EXEC_TBRD2; + break; + + case 0x2f00: + m_curreg = opcode & 0x00ff; + m_exec_state = EXEC_TBRDA; + break; + + case 0x3000: case 0x3100: case 0x3200: case 0x3300: + case 0x3400: case 0x3500: case 0x3600: case 0x3700: + case 0x3800: case 0x3900: case 0x3a00: case 0x3b00: + case 0x3c00: case 0x3d00: case 0x3e00: case 0x3f00: + execute_call(opcode & 0x0fff); + break; + + case 0x4000: + tabptrl_w(opcode & 0x00ff); + break; + + case 0x4100: + tabptrm_w(opcode & 0x00ff); + break; + + case 0x4200: + tabptrh_w(opcode & 0x00ff); + break; + + case 0x4300: + bsr_w(opcode & 0x00ff); + break; + + case 0x4400: + set_z_acc(m_acc | (opcode & 0x00ff)); + break; + + case 0x4500: + set_z_acc(m_acc & opcode & 0x00ff); + break; + + case 0x4600: + set_z_acc(m_acc ^ (opcode & 0x00ff)); + break; + + case 0x4700: + execute_jcc(m_acc >= (opcode & 0x00ff)); + break; + + case 0x4800: + execute_jcc(m_acc <= (opcode & 0x00ff)); + break; + + case 0x4900: + execute_jcc(m_acc == (opcode & 0x00ff)); + break; + + case 0x4a00: + execute_add_imm(opcode & 0x00ff, false); + break; + + case 0x4b00: + execute_add_imm(opcode & 0x00ff, true); + break; + + case 0x4c00: + execute_sub_imm(opcode & 0x00ff, false); + break; + + case 0x4d00: + execute_sub_imm(opcode & 0x00ff, true); + break; + + case 0x4e00: + acc_w(opcode & 0x00ff); + break; + + case 0x4f00: + execute_mul_imm(opcode & 0x00ff); + break; + + case 0x5000: + execute_jdnz(opcode & 0x00ff, true); + break; + + case 0x5100: + execute_jdnz(opcode & 0x00ff, false); + break; + + case 0x5200: + execute_jinz(opcode & 0x00ff, true); + break; + + case 0x5300: + execute_jinz(opcode & 0x00ff, false); + break; + + case 0x5500: + execute_jcc(m_acc >= m_regs->read_byte(get_banked_address(opcode & 0x00ff))); + break; + + case 0x5600: + execute_jcc(m_acc <= m_regs->read_byte(get_banked_address(opcode & 0x00ff))); + break; + + case 0x5700: + execute_jcc(m_acc == m_regs->read_byte(get_banked_address(opcode & 0x00ff))); + break; + + case 0x5800: case 0x5900: case 0x5a00: case 0x5b00: + case 0x5c00: case 0x5d00: case 0x5e00: case 0x5f00: + execute_jbc(opcode & 0x00ff, (opcode & 0x0700) >> 8); + break; + + case 0x6000: case 0x6100: case 0x6200: case 0x6300: + case 0x6400: case 0x6500: case 0x6600: case 0x6700: + execute_jbs(opcode & 0x00ff, (opcode & 0x0700) >> 8); + break; + + case 0x6800: case 0x6900: case 0x6a00: case 0x6b00: + case 0x6c00: case 0x6d00: case 0x6e00: case 0x6f00: + execute_bc(opcode & 0x00ff, (opcode & 0x0700) >> 8); + break; + + case 0x7000: case 0x7100: case 0x7200: case 0x7300: + case 0x7400: case 0x7500: case 0x7600: case 0x7700: + execute_bs(opcode & 0x00ff, (opcode & 0x0700) >> 8); + break; + + case 0x7800: case 0x7900: case 0x7a00: case 0x7b00: + case 0x7c00: case 0x7d00: case 0x7e00: case 0x7f00: + execute_btg(opcode & 0x00ff, (opcode & 0x0700) >> 8); + break; + + default: + execute_undef(opcode); + break; + } +} + +void riscii_series_device::execute_tbrd(u32 ptr) +{ + u16 addr = get_banked_address(m_curreg); + u16 data = m_program->read_word(ptr >> 1); + if (BIT(ptr, 0)) + m_regs->write_byte(addr, data >> 8); + else + m_regs->write_byte(addr, data); + if (m_repeat != 0) + --m_repeat; + else + m_exec_state = EXEC_CYCLE1; } void riscii_series_device::execute_run() { - debugger_instruction_hook(m_pc); + while (m_icount > 0) + { + switch (m_exec_state) + { + case EXEC_CYCLE1: + m_ppc = m_pc; + debugger_instruction_hook(m_pc); + if (m_repeat != 0) + { + execute_cycle1(m_cache->read_word(m_pc++)); + if (m_exec_state == EXEC_CYCLE1) + { + --m_repeat; + m_pc = m_ppc; + } + } + else + execute_cycle1(m_cache->read_word(m_pc++)); + break; + + case EXEC_TBRD0: + execute_tbrd(m_tabptr); + break; - m_icount = 0; + case EXEC_TBRD1: + execute_tbrd(m_tabptr++); + break; + + case EXEC_TBRD2: + execute_tbrd(m_tabptr--); + break; + + case EXEC_TBRDA: + execute_tbrd(m_tabptr + m_acc); + break; + + case EXEC_L0JMP: case EXEC_L1JMP: case EXEC_L2JMP: case EXEC_L3JMP: + case EXEC_L4JMP: case EXEC_L5JMP: case EXEC_L6JMP: case EXEC_L7JMP: + case EXEC_L8JMP: case EXEC_L9JMP: case EXEC_LAJMP: case EXEC_LBJMP: + case EXEC_LCJMP: case EXEC_LDJMP: case EXEC_LEJMP: case EXEC_LFJMP: + execute_jump(u32(m_exec_state - EXEC_L0JMP) << 16 | m_cache->read_word(m_pc++)); + m_exec_state = EXEC_CYCLE1; + break; + + case EXEC_L0CALL: case EXEC_L1CALL: case EXEC_L2CALL: case EXEC_L3CALL: + case EXEC_L4CALL: case EXEC_L5CALL: case EXEC_L6CALL: case EXEC_L7CALL: + case EXEC_L8CALL: case EXEC_L9CALL: case EXEC_LACALL: case EXEC_LBCALL: + case EXEC_LCCALL: case EXEC_LDCALL: case EXEC_LECALL: case EXEC_LFCALL: + execute_call(u32(m_exec_state - EXEC_L0CALL) << 16 | m_cache->read_word(m_pc++)); + m_exec_state = EXEC_CYCLE1; + break; + + case EXEC_NOJMP: + (void)m_cache->read_word(m_pc++); + m_exec_state = EXEC_CYCLE1; + break; + } + + m_icount--; + } } void riscii_series_device::execute_set_input(int inputnum, int state) { // TODO } + +void riscii_series_device::state_string_export(const device_state_entry &entry, std::string &str) const +{ + switch (entry.index()) + { + case STATE_GENFLAGS: + str = string_format("%c%c%c%c%c%c%c%c", + BIT(m_status, 7) ? '.' : 'T', // /TO + BIT(m_status, 6) ? '.' : 'P', // /PD + BIT(m_status, 5) ? 'G' : '.', // SGE + BIT(m_status, 4) ? 'L' : '.', // SLE + BIT(m_status, 3) ? 'V' : '.', // OV + BIT(m_status, 2) ? 'Z' : '.', + BIT(m_status, 1) ? 'D' : '.', // auxiliary carry + BIT(m_status, 0) ? 'C' : '.'); + break; + } +} diff --git a/src/devices/cpu/rii/riscii.h b/src/devices/cpu/rii/riscii.h index 869a3f551ce..f00b378fd5b 100644 --- a/src/devices/cpu/rii/riscii.h +++ b/src/devices/cpu/rii/riscii.h @@ -19,6 +19,7 @@ public: enum { RII_PC, + RII_REPEAT, RII_ACC, RII_FSR0, RII_FSR1, @@ -28,7 +29,8 @@ public: RII_STKPTR, RII_CPUCON, RII_STATUS, - RII_PROD + RII_PROD, + RII_POST_ID }; // construction/destruction @@ -51,7 +53,107 @@ protected: // device_memory_interface overrides virtual space_config_vector memory_space_config() const override; + // device_state_interface overrides + virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; + private: + // register handlers + u8 fsr0_r(); + void fsr0_w(u8 data); + u8 bsr_r(); + void bsr_w(u8 data); + u8 fsr1_r(); + void fsr1_w(u8 data); + u8 bsr1_r(); + void bsr1_w(u8 data); + u8 pcl_r(); + void pcl_w(u8 data); + u8 pcm_r(); + void pcm_w(u8 data); + u8 pch_r(); + void pch_w(u8 data); + u8 tabptrl_r(); + void tabptrl_w(u8 data); + u8 tabptrm_r(); + void tabptrm_w(u8 data); + u8 tabptrh_r(); + void tabptrh_w(u8 data); + u8 acc_r(); + void acc_w(u8 data); + u8 stkptr_r(); + void stkptr_w(u8 data); + u8 cpucon_r(); + void cpucon_w(u8 data); + u8 status_r(); + void status_w(u8 data); + u8 prodl_r(); + void prodl_w(u8 data); + u8 prodh_r(); + void prodh_w(u8 data); + u8 post_id_r(); + void post_id_w(u8 data); + + // memory helpers + u16 get_banked_address(u8 reg); + + // execution + void execute_move(u8 dstreg, u8 srcreg); + void execute_add(u8 reg, bool a, bool c); + void execute_sub(u8 reg, bool a, bool c); + void execute_add_imm(u8 data, bool c); + void execute_sub_imm(u8 data, bool c); + void execute_adddc(u8 reg, bool a); + void execute_subdb(u8 reg, bool a); + void execute_mul(u8 reg); + void execute_mul_imm(u8 data); + void execute_or(u8 reg, bool a); + void execute_and(u8 reg, bool a); + void execute_xor(u8 reg, bool a); + void execute_com(u8 reg, bool a); + void execute_clr(u8 reg); + void execute_rrc(u8 reg, bool a); + void execute_rlc(u8 reg, bool a); + void execute_shra(u8 reg); + void execute_shla(u8 reg); + void execute_jump(u32 addr); + void execute_call(u32 addr); + void execute_jcc(bool condition); + void execute_jdnz(u8 reg, bool a); + void execute_jinz(u8 reg, bool a); + void set_z_acc(u8 tmp); + void execute_load(u8 reg); + void execute_store(u8 reg); + void execute_test(u8 reg); + void execute_swap(u8 reg, bool a); + void execute_jbc(u8 reg, int b); + void execute_jbs(u8 reg, int b); + void execute_bc(u8 reg, int b); + void execute_bs(u8 reg, int b); + void execute_btg(u8 reg, int b); + void execute_inc(u8 reg, bool a); + void execute_dec(u8 reg, bool a); + void execute_rpt(u8 reg); + void execute_ret(bool inte); + void execute_wdtc(); + void execute_slep(); + void execute_undef(u16 opcode); + void execute_cycle1(u16 opcode); + void execute_tbrd(u32 ptr); + + enum exec_state : u8 { + EXEC_CYCLE1, + EXEC_TBRD0, EXEC_TBRD1, EXEC_TBRD2, EXEC_TBRDA, + EXEC_NOJMP, + EXEC_L0JMP, EXEC_L1JMP, EXEC_L2JMP, EXEC_L3JMP, + EXEC_L4JMP, EXEC_L5JMP, EXEC_L6JMP, EXEC_L7JMP, + EXEC_L8JMP, EXEC_L9JMP, EXEC_LAJMP, EXEC_LBJMP, + EXEC_LCJMP, EXEC_LDJMP, EXEC_LEJMP, EXEC_LFJMP, + EXEC_L0CALL, EXEC_L1CALL, EXEC_L2CALL, EXEC_L3CALL, + EXEC_L4CALL, EXEC_L5CALL, EXEC_L6CALL, EXEC_L7CALL, + EXEC_L8CALL, EXEC_L9CALL, EXEC_LACALL, EXEC_LBCALL, + EXEC_LCCALL, EXEC_LDCALL, EXEC_LECALL, EXEC_LFCALL + }; + void regs_map(address_map &map); // address spaces @@ -59,6 +161,7 @@ private: address_space_config m_regs_config; address_space *m_program; address_space *m_regs; + memory_access_cache<1, -1, ENDIANNESS_LITTLE> *m_cache; // model-specific parameters const unsigned m_prgbits; @@ -67,18 +170,22 @@ private: // internal state u32 m_pc; + u32 m_ppc; u8 m_acc; - u8 m_fsr0; - u8 m_bsr; - PAIR16 m_fsr1; + u8 m_fsr[2]; + u8 m_bsr[2]; u32 m_tabptr; u8 m_stkptr; u8 m_cpucon; u8 m_status; - PAIR16 m_prod; + u16 m_prod; + u8 m_post_id; // execution sequencing s32 m_icount; + exec_state m_exec_state; + u8 m_repeat; + u8 m_curreg; }; DECLARE_DEVICE_TYPE(RISCII, riscii_series_device) diff --git a/src/devices/machine/i8251.cpp b/src/devices/machine/i8251.cpp index b9972693ac5..b78ee829cb9 100644 --- a/src/devices/machine/i8251.cpp +++ b/src/devices/machine/i8251.cpp @@ -1,8 +1,8 @@ // license:BSD-3-Clause -// copyright-holders:smf +// copyright-holders:smf, Robbbert /********************************************************************* - i8251.c + i8251.cpp Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code NEC uPD71051 is a clone @@ -10,6 +10,12 @@ The V53/V53A use a customized version with only the Asynchronous mode and a split command / mode register +To Do: +- BRKDET: if, in Async mode, 16 low RxD bits in succession are clocked in, + the SYNDET pin & status must go high. It will go low upon a + status read, same as what happens with sync. + +- SYNC/BISYNC with PARITY is not tested, and therefore possibly buggy. *********************************************************************/ @@ -86,6 +92,11 @@ void i8251_device::device_start() save_item(NAME(m_status)); save_item(NAME(m_command)); save_item(NAME(m_mode_byte)); + save_item(NAME(m_delayed_tx_en)); + save_item(NAME(m_sync1)); + save_item(NAME(m_sync2)); + save_item(NAME(m_sync8)); + save_item(NAME(m_sync16)); save_item(NAME(m_cts)); save_item(NAME(m_dsr)); save_item(NAME(m_rxd)); @@ -96,6 +107,11 @@ void i8251_device::device_start() save_item(NAME(m_br_factor)); save_item(NAME(m_rx_data)); save_item(NAME(m_tx_data)); + save_item(NAME(m_syndet_pin)); + save_item(NAME(m_hunt_on)); + save_item(NAME(m_ext_syn_set)); + save_item(NAME(m_rxd_bits)); + save_item(NAME(m_data_bits_count)); } @@ -684,8 +700,6 @@ void i8251_device::mode_w(uint8_t data) receive_register_reset(); m_txc_count = 0; - - // m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY; } void i8251_device::sync1_w(uint8_t data) diff --git a/src/devices/machine/i8251.h b/src/devices/machine/i8251.h index 15d1543c03d..44f912eaa60 100644 --- a/src/devices/machine/i8251.h +++ b/src/devices/machine/i8251.h @@ -109,12 +109,9 @@ private: /* flags controlling how i8251_control_w operates */ uint8_t m_flags; - /* offset into sync_bytes used during sync byte transfer */ - //uint8_t m_sync_byte_offset; - /* number of sync bytes written so far */ + /* number of sync bytes programmed for sync mode (1 or 2) ; 0 = async mode */ uint8_t m_sync_byte_count; /* the sync bytes written */ - //uint8_t m_sync_bytes[2]; u8 m_sync1; u16 m_sync2; /* status of i8251 */ diff --git a/src/devices/sound/ay8910.cpp b/src/devices/sound/ay8910.cpp index e3ee55dde50..3d396c3cd00 100644 --- a/src/devices/sound/ay8910.cpp +++ b/src/devices/sound/ay8910.cpp @@ -903,7 +903,7 @@ u16 ay8910_device::mix_3D() u32 env_mask = (1 << (chan + 15)); if (m_feature & PSG_HAS_EXPANDED_MODE) { - if (!is_expnaded_mode()) + if (!is_expanded_mode()) { env_volume >>= 1; env_mask = 0; @@ -920,7 +920,7 @@ u16 ay8910_device::mix_3D() } else { - const u32 tone_mask = is_expnaded_mode() ? (1 << (chan + 15)) : 0; + const u32 tone_mask = is_expanded_mode() ? (1 << (chan + 15)) : 0; indx |= tone_mask | (m_vol_enabled[chan] ? tone_volume(tone) << (chan*5) : 0); } } @@ -946,17 +946,17 @@ void ay8910_device::ay8910_write_reg(int r, int v) { case AY_AFINE: case AY_ACOARSE: - coarse = m_regs[AY_ACOARSE] & (is_expnaded_mode() ? 0xff : 0xf); + coarse = m_regs[AY_ACOARSE] & (is_expanded_mode() ? 0xff : 0xf); m_tone[0].set_period(m_regs[AY_AFINE], coarse); break; case AY_BFINE: case AY_BCOARSE: - coarse = m_regs[AY_BCOARSE] & (is_expnaded_mode() ? 0xff : 0xf); + coarse = m_regs[AY_BCOARSE] & (is_expanded_mode() ? 0xff : 0xf); m_tone[1].set_period(m_regs[AY_BFINE], coarse); break; case AY_CFINE: case AY_CCOARSE: - coarse = m_regs[AY_CCOARSE] & (is_expnaded_mode() ? 0xff : 0xf); + coarse = m_regs[AY_CCOARSE] & (is_expanded_mode() ? 0xff : 0xf); m_tone[2].set_period(m_regs[AY_CFINE], coarse); break; case AY_NOISEPER: @@ -1208,7 +1208,7 @@ void ay8910_device::sound_stream_update(sound_stream &stream, stream_sample_t ** u32 env_volume = envelope->volume; if (m_feature & PSG_HAS_EXPANDED_MODE) { - if (!is_expnaded_mode()) + if (!is_expanded_mode()) { env_volume >>= 1; if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field @@ -1234,7 +1234,7 @@ void ay8910_device::sound_stream_update(sound_stream &stream, stream_sample_t ** } else { - if (is_expnaded_mode()) + if (is_expanded_mode()) *(buf[chan]++) = m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]; else *(buf[chan]++) = m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]; @@ -1618,7 +1618,7 @@ ay8910_device::ay8910_device(const machine_config &mconfig, const char *tag, dev } ay8910_device::ay8910_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, - psg_type_t psg_type, int streams, int ioports, int config) + psg_type_t psg_type, int streams, int ioports, int feature) : device_t(mconfig, type, tag, owner, clock), device_sound_interface(mconfig, *this), m_type(psg_type), @@ -1633,13 +1633,13 @@ ay8910_device::ay8910_device(const machine_config &mconfig, device_type type, co m_count_noise(0), m_rng(0), m_mode(0), - m_env_step_mask((!(config & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? 0x0f : 0x1f), - m_step( (!(config & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? 32 : 16), - m_zero_is_off( (!(config & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? 1 : 0), - m_par( (!(config & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? &ay8910_param : &ym2149_param), - m_par_env( (!(config & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? &ay8910_param : &ym2149_param_env), + m_env_step_mask((!(feature & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? 0x0f : 0x1f), + m_step( (!(feature & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? 32 : 16), + m_zero_is_off( (!(feature & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? 1 : 0), + m_par( (!(feature & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? &ay8910_param : &ym2149_param), + m_par_env( (!(feature & PSG_HAS_EXPANDED_MODE)) && (psg_type == PSG_TYPE_AY) ? &ay8910_param : &ym2149_param_env), m_flags(AY8910_LEGACY_OUTPUT), - m_feature(config), + m_feature(feature), m_port_a_read_cb(*this), m_port_b_read_cb(*this), m_port_a_write_cb(*this), diff --git a/src/devices/sound/ay8910.h b/src/devices/sound/ay8910.h index 685e8d837e5..146c1926522 100644 --- a/src/devices/sound/ay8910.h +++ b/src/devices/sound/ay8910.h @@ -126,7 +126,7 @@ public: protected: ay8910_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, - u32 clock, psg_type_t psg_type, int streams, int ioports, int config = PSG_DEFAULT); + u32 clock, psg_type_t psg_type, int streams, int ioports, int feature = PSG_DEFAULT); // device-level overrides virtual void device_start() override; @@ -261,17 +261,17 @@ private: // inlines inline bool tone_enable(int chan) { return BIT(m_regs[AY_ENABLE], chan); } - inline u8 tone_volume(tone_t *tone) { return tone->volume & (is_expnaded_mode() ? 0x1f : 0x0f); } - inline u8 tone_envelope(tone_t *tone) { return (tone->volume >> (is_expnaded_mode() ? 5 : 4)) & ((m_feature & PSG_EXTENDED_ENVELOPE) ? 3 : 1); } - inline u8 tone_duty(tone_t *tone) { return is_expnaded_mode() ? (tone->duty & 0x8 ? 0x8 : tone->duty) : 0x4; } - inline u8 get_envelope_chan(int chan) { return is_expnaded_mode() ? chan : 0; } + inline u8 tone_volume(tone_t *tone) { return tone->volume & (is_expanded_mode() ? 0x1f : 0x0f); } + inline u8 tone_envelope(tone_t *tone) { return (tone->volume >> (is_expanded_mode() ? 5 : 4)) & ((m_feature & PSG_EXTENDED_ENVELOPE) ? 3 : 1); } + inline u8 tone_duty(tone_t *tone) { return is_expanded_mode() ? (tone->duty & 0x8 ? 0x8 : (tone->duty & 0xf)) : 0x4; } + inline u8 get_envelope_chan(int chan) { return is_expanded_mode() ? chan : 0; } inline bool noise_enable(int chan) { return BIT(m_regs[AY_ENABLE], 3 + chan); } - inline u8 noise_period() { return is_expnaded_mode() ? m_regs[AY_NOISEPER] & 0xff : (m_regs[AY_NOISEPER] & 0x1f) << 1; } + inline u8 noise_period() { return is_expanded_mode() ? m_regs[AY_NOISEPER] & 0xff : (m_regs[AY_NOISEPER] & 0x1f) << 1; } inline u8 noise_output() { return m_rng & 1; } - inline bool is_expnaded_mode() { return ((m_feature & PSG_HAS_EXPANDED_MODE) && ((m_mode & 0xe) == 0xa)); } - inline u8 get_register_bank() { return is_expnaded_mode() ? (m_mode & 0x1) << 4 : 0; } + inline bool is_expanded_mode() { return ((m_feature & PSG_HAS_EXPANDED_MODE) && ((m_mode & 0xe) == 0xa)); } + inline u8 get_register_bank() { return is_expanded_mode() ? (m_mode & 0x1) << 4 : 0; } // internal helpers void set_type(psg_type_t psg_type); diff --git a/src/devices/sound/multipcm.cpp b/src/devices/sound/multipcm.cpp index e1aa70bddb6..ccad2612989 100644 --- a/src/devices/sound/multipcm.cpp +++ b/src/devices/sound/multipcm.cpp @@ -92,53 +92,53 @@ void multipcm_device::init_sample(sample_t *sample, uint32_t index) sample->m_lfo_amplitude_reg = read_byte(address + 11) & 0xf; } -int32_t multipcm_device::envelope_generator_update(slot_t *slot) +int32_t multipcm_device::envelope_generator_update(slot_t &slot) { - switch(slot->m_envelope_gen.m_state) + switch(slot.m_envelope_gen.m_state) { case state_t::ATTACK: - slot->m_envelope_gen.m_volume += slot->m_envelope_gen.m_attack_rate; - if (slot->m_envelope_gen.m_volume >= (0x3ff << EG_SHIFT)) + slot.m_envelope_gen.m_volume += slot.m_envelope_gen.m_attack_rate; + if (slot.m_envelope_gen.m_volume >= (0x3ff << EG_SHIFT)) { - slot->m_envelope_gen.m_state = state_t::DECAY1; - if (slot->m_envelope_gen.m_decay1_rate >= (0x400 << EG_SHIFT)) //Skip DECAY1, go directly to DECAY2 + slot.m_envelope_gen.m_state = state_t::DECAY1; + if (slot.m_envelope_gen.m_decay1_rate >= (0x400 << EG_SHIFT)) //Skip DECAY1, go directly to DECAY2 { - slot->m_envelope_gen.m_state = state_t::DECAY2; + slot.m_envelope_gen.m_state = state_t::DECAY2; } - slot->m_envelope_gen.m_volume = 0x3ff << EG_SHIFT; + slot.m_envelope_gen.m_volume = 0x3ff << EG_SHIFT; } break; case state_t::DECAY1: - slot->m_envelope_gen.m_volume -= slot->m_envelope_gen.m_decay1_rate; - if (slot->m_envelope_gen.m_volume <= 0) + slot.m_envelope_gen.m_volume -= slot.m_envelope_gen.m_decay1_rate; + if (slot.m_envelope_gen.m_volume <= 0) { - slot->m_envelope_gen.m_volume = 0; + slot.m_envelope_gen.m_volume = 0; } - if (slot->m_envelope_gen.m_volume >> EG_SHIFT <= (slot->m_envelope_gen.m_decay_level << 6)) + if (slot.m_envelope_gen.m_volume >> EG_SHIFT <= (slot.m_envelope_gen.m_decay_level << 6)) { - slot->m_envelope_gen.m_state = state_t::DECAY2; + slot.m_envelope_gen.m_state = state_t::DECAY2; } break; case state_t::DECAY2: - slot->m_envelope_gen.m_volume -= slot->m_envelope_gen.m_decay2_rate; - if (slot->m_envelope_gen.m_volume <= 0) + slot.m_envelope_gen.m_volume -= slot.m_envelope_gen.m_decay2_rate; + if (slot.m_envelope_gen.m_volume <= 0) { - slot->m_envelope_gen.m_volume = 0; + slot.m_envelope_gen.m_volume = 0; } break; case state_t::RELEASE: - slot->m_envelope_gen.m_volume -= slot->m_envelope_gen.m_release_rate; - if (slot->m_envelope_gen.m_volume <= 0) + slot.m_envelope_gen.m_volume -= slot.m_envelope_gen.m_release_rate; + if (slot.m_envelope_gen.m_volume <= 0) { - slot->m_envelope_gen.m_volume = 0; - slot->m_playing = false; + slot.m_envelope_gen.m_volume = 0; + slot.m_playing = false; } break; default: return 1 << TL_SHIFT; } - return m_linear_to_exp_volume[slot->m_envelope_gen.m_volume >> EG_SHIFT]; + return m_linear_to_exp_volume[slot.m_envelope_gen.m_volume >> EG_SHIFT]; } uint32_t multipcm_device::get_rate(uint32_t *steps, uint32_t rate, uint32_t val) @@ -159,28 +159,28 @@ uint32_t multipcm_device::get_rate(uint32_t *steps, uint32_t rate, uint32_t val) return steps[r]; } -void multipcm_device::envelope_generator_calc(slot_t *slot) +void multipcm_device::envelope_generator_calc(slot_t &slot) { - int32_t octave = ((slot->m_regs[3] >> 4) - 1) & 0xf; + int32_t octave = ((slot.m_regs[3] >> 4) - 1) & 0xf; if (octave & 8) { octave = octave - 16; } int32_t rate; - if (slot->m_sample.m_key_rate_scale != 0xf) + if (slot.m_sample.m_key_rate_scale != 0xf) { - rate = (octave + slot->m_sample.m_key_rate_scale) * 2 + ((slot->m_regs[3] >> 3) & 1); + rate = (octave + slot.m_sample.m_key_rate_scale) * 2 + ((slot.m_regs[3] >> 3) & 1); } else { rate = 0; } - slot->m_envelope_gen.m_attack_rate = get_rate(m_attack_step, rate, slot->m_sample.m_attack_reg); - slot->m_envelope_gen.m_decay1_rate = get_rate(m_decay_release_step, rate, slot->m_sample.m_decay1_reg); - slot->m_envelope_gen.m_decay2_rate = get_rate(m_decay_release_step, rate, slot->m_sample.m_decay2_reg); - slot->m_envelope_gen.m_release_rate = get_rate(m_decay_release_step, rate, slot->m_sample.m_release_reg); - slot->m_envelope_gen.m_decay_level = 0xf - slot->m_sample.m_decay_level; + slot.m_envelope_gen.m_attack_rate = get_rate(m_attack_step.get(), rate, slot.m_sample.m_attack_reg); + slot.m_envelope_gen.m_decay1_rate = get_rate(m_decay_release_step.get(), rate, slot.m_sample.m_decay1_reg); + slot.m_envelope_gen.m_decay2_rate = get_rate(m_decay_release_step.get(), rate, slot.m_sample.m_decay2_reg); + slot.m_envelope_gen.m_release_rate = get_rate(m_decay_release_step.get(), rate, slot.m_sample.m_release_reg); + slot.m_envelope_gen.m_decay_level = 0xf - slot.m_sample.m_decay_level; } @@ -228,8 +228,8 @@ const float multipcm_device::AMPLITUDE_SCALE_LIMIT[8] = // In Decibels void multipcm_device::lfo_init() { - m_pitch_table = auto_alloc_array_clear(machine(), int32_t, 256); - m_amplitude_table = auto_alloc_array_clear(machine(), int32_t, 256); + m_pitch_table = make_unique_clear<int32_t[]>(256); + m_amplitude_table = make_unique_clear<int32_t[]>(256); for (int32_t i = 0; i < 256; ++i) { if (i < 64) @@ -259,12 +259,12 @@ void multipcm_device::lfo_init() } } - m_pitch_scale_tables = auto_alloc_array_clear(machine(), int32_t*, 8); - m_amplitude_scale_tables = auto_alloc_array_clear(machine(), int32_t*, 8); + m_pitch_scale_tables = make_unique_clear<std::unique_ptr<int32_t[]>[]>(8); + m_amplitude_scale_tables = make_unique_clear<std::unique_ptr<int32_t[]>[]>(8); for (int32_t table = 0; table < 8; ++table) { float limit = PHASE_SCALE_LIMIT[table]; - m_pitch_scale_tables[table] = auto_alloc_array_clear(machine(), int32_t, 256); + m_pitch_scale_tables[table] = make_unique_clear<int32_t[]>(256); for(int32_t i = -128; i < 128; ++i) { const float value = (limit * (float)i) / 128.0f; @@ -273,7 +273,7 @@ void multipcm_device::lfo_init() } limit = -AMPLITUDE_SCALE_LIMIT[table]; - m_amplitude_scale_tables[table] = auto_alloc_array_clear(machine(), int32_t, 256); + m_amplitude_scale_tables[table] = make_unique_clear<int32_t[]>(256); for(int32_t i = 0; i < 256; ++i) { const float value = (limit * (float)i) / 256.0f; @@ -289,53 +289,53 @@ uint32_t multipcm_device::value_to_fixed(const uint32_t bits, const float value) return uint32_t(float_shift * value); } -int32_t multipcm_device::pitch_lfo_step(lfo_t *lfo) +int32_t multipcm_device::pitch_lfo_step(lfo_t &lfo) { - lfo->m_phase += lfo->m_phase_step; - int32_t p = lfo->m_table[(lfo->m_phase >> LFO_SHIFT) & 0xff]; - p = lfo->m_scale[p]; + lfo.m_phase += lfo.m_phase_step; + int32_t p = lfo.m_table[(lfo.m_phase >> LFO_SHIFT) & 0xff]; + p = lfo.m_scale[p]; return p << (TL_SHIFT - LFO_SHIFT); } -int32_t multipcm_device::amplitude_lfo_step(lfo_t *lfo) +int32_t multipcm_device::amplitude_lfo_step(lfo_t &lfo) { - lfo->m_phase += lfo->m_phase_step; - int32_t p = lfo->m_table[(lfo->m_phase >> LFO_SHIFT) & 0xff]; - p = lfo->m_scale[p]; + lfo.m_phase += lfo.m_phase_step; + int32_t p = lfo.m_table[(lfo.m_phase >> LFO_SHIFT) & 0xff]; + p = lfo.m_scale[p]; return p << (TL_SHIFT - LFO_SHIFT); } -void multipcm_device::lfo_compute_step(lfo_t *lfo, uint32_t lfo_frequency, uint32_t lfo_scale, int32_t amplitude_lfo) +void multipcm_device::lfo_compute_step(lfo_t &lfo, uint32_t lfo_frequency, uint32_t lfo_scale, int32_t amplitude_lfo) { float step = (float)LFO_FREQ[lfo_frequency] * 256.0f / (float)m_rate; - lfo->m_phase_step = uint32_t(float(1 << LFO_SHIFT) * step); + lfo.m_phase_step = uint32_t(float(1 << LFO_SHIFT) * step); if (amplitude_lfo) { - lfo->m_table = m_amplitude_table; - lfo->m_scale = m_amplitude_scale_tables[lfo_scale]; + lfo.m_table = m_amplitude_table.get(); + lfo.m_scale = m_amplitude_scale_tables[lfo_scale].get(); } else { - lfo->m_table = m_pitch_table; - lfo->m_scale = m_pitch_scale_tables[lfo_scale]; + lfo.m_table = m_pitch_table.get(); + lfo.m_scale = m_pitch_scale_tables[lfo_scale].get(); } } -void multipcm_device::write_slot(slot_t *slot, int32_t reg, uint8_t data) +void multipcm_device::write_slot(slot_t &slot, int32_t reg, uint8_t data) { - slot->m_regs[reg] = data; + slot.m_regs[reg] = data; switch(reg) { case 0: // PANPOT - slot->m_pan = (data >> 4) & 0xf; + slot.m_pan = (data >> 4) & 0xf; break; case 1: // Sample { //according to YMF278 sample write causes some base params written to the regs (envelope+lfos) //the game should never change the sample while playing. sample_t sample; - init_sample(&sample, slot->m_regs[1] | ((slot->m_regs[2] & 1) << 8)); + init_sample(&sample, slot.m_regs[1] | ((slot.m_regs[2] & 1) << 8)); write_slot(slot, 6, sample.m_lfo_vibrato_reg); write_slot(slot, 7, sample.m_lfo_amplitude_reg); break; @@ -343,8 +343,8 @@ void multipcm_device::write_slot(slot_t *slot, int32_t reg, uint8_t data) case 2: //Pitch case 3: { - uint32_t oct = ((slot->m_regs[3] >> 4) - 1) & 0xf; - uint32_t pitch = ((slot->m_regs[3] & 0xf) << 6) | (slot->m_regs[2] >> 2); + uint32_t oct = ((slot.m_regs[3] >> 4) - 1) & 0xf; + uint32_t pitch = ((slot.m_regs[3] & 0xf) << 6) | (slot.m_regs[2] >> 2); pitch = m_freq_step_table[pitch]; if (oct & 0x8) { @@ -354,68 +354,68 @@ void multipcm_device::write_slot(slot_t *slot, int32_t reg, uint8_t data) { pitch <<= oct; } - slot->m_step = pitch / m_rate; + slot.m_step = pitch / m_rate; } break; case 4: //KeyOn/Off (and more?) if (data & 0x80) //KeyOn { - init_sample(&slot->m_sample, slot->m_regs[1] | ((slot->m_regs[2] & 1) << 8)); - slot->m_playing = true; - slot->m_base = slot->m_sample.m_start; - slot->m_offset = 0; - slot->m_prev_sample = 0; - slot->m_total_level = slot->m_dest_total_level << TL_SHIFT; + init_sample(&slot.m_sample, slot.m_regs[1] | ((slot.m_regs[2] & 1) << 8)); + slot.m_playing = true; + slot.m_base = slot.m_sample.m_start; + slot.m_offset = 0; + slot.m_prev_sample = 0; + slot.m_total_level = slot.m_dest_total_level << TL_SHIFT; envelope_generator_calc(slot); - slot->m_envelope_gen.m_state = state_t::ATTACK; - slot->m_envelope_gen.m_volume = 0; + slot.m_envelope_gen.m_state = state_t::ATTACK; + slot.m_envelope_gen.m_volume = 0; } else { - if (slot->m_playing) + if (slot.m_playing) { - if (slot->m_sample.m_release_reg != 0xf) + if (slot.m_sample.m_release_reg != 0xf) { - slot->m_envelope_gen.m_state = state_t::RELEASE; + slot.m_envelope_gen.m_state = state_t::RELEASE; } else { - slot->m_playing = false; + slot.m_playing = false; } } } break; case 5: // TL + Interpolation - slot->m_dest_total_level = (data >> 1) & 0x7f; + slot.m_dest_total_level = (data >> 1) & 0x7f; if (!(data & 1)) //Interpolate TL { - if ((slot->m_total_level >> TL_SHIFT) > slot->m_dest_total_level) + if ((slot.m_total_level >> TL_SHIFT) > slot.m_dest_total_level) { - slot->m_total_level_step = m_total_level_steps[0]; // decrease + slot.m_total_level_step = m_total_level_steps[0]; // decrease } else { - slot->m_total_level_step = m_total_level_steps[1]; // increase + slot.m_total_level_step = m_total_level_steps[1]; // increase } } else { - slot->m_total_level = slot->m_dest_total_level << TL_SHIFT; + slot.m_total_level = slot.m_dest_total_level << TL_SHIFT; } break; case 6: // LFO frequency + Pitch LFO if (data) { - lfo_compute_step(&(slot->m_pitch_lfo), (slot->m_regs[6] >> 3) & 7, slot->m_regs[6] & 7, 0); - lfo_compute_step(&(slot->m_amplitude_lfo), (slot->m_regs[6] >> 3) & 7, slot->m_regs[7] & 7, 1); + lfo_compute_step(slot.m_pitch_lfo, (slot.m_regs[6] >> 3) & 7, slot.m_regs[6] & 7, 0); + lfo_compute_step(slot.m_amplitude_lfo, (slot.m_regs[6] >> 3) & 7, slot.m_regs[7] & 7, 1); } break; case 7: // Amplitude LFO if (data) { - lfo_compute_step(&(slot->m_pitch_lfo), (slot->m_regs[6] >> 3) & 7, slot->m_regs[6] & 7, 0); - lfo_compute_step(&(slot->m_amplitude_lfo), (slot->m_regs[6] >> 3) & 7, slot->m_regs[7] & 7, 1); + lfo_compute_step(slot.m_pitch_lfo, (slot.m_regs[6] >> 3) & 7, slot.m_regs[6] & 7, 0); + lfo_compute_step(slot.m_amplitude_lfo, (slot.m_regs[6] >> 3) & 7, slot.m_regs[7] & 7, 1); } break; } @@ -431,7 +431,7 @@ WRITE8_MEMBER( multipcm_device::write ) switch(offset) { case 0: //Data write - write_slot(m_slots + m_cur_slot, m_address, data); + write_slot(m_slots[m_cur_slot], m_address, data); break; case 1: m_cur_slot = VALUE_TO_CHANNEL[data & 0x1f]; @@ -481,8 +481,8 @@ void multipcm_device::device_start() m_stream = machine().sound().stream_alloc(*this, 0, 2, m_rate); // Volume + pan table - m_left_pan_table = auto_alloc_array_clear(machine(), int32_t, 0x800); - m_right_pan_table = auto_alloc_array_clear(machine(), int32_t, 0x800); + m_left_pan_table = make_unique_clear<int32_t[]>(0x800); + m_right_pan_table = make_unique_clear<int32_t[]>(0x800); for (int32_t level = 0; level < 0x80; ++level) { const float vol_db = (float)level * (-24.0f) / 64.0f; @@ -535,7 +535,7 @@ void multipcm_device::device_start() } //Pitch steps - m_freq_step_table = auto_alloc_array_clear(machine(), uint32_t, 0x400); + m_freq_step_table = make_unique_clear<uint32_t[]>(0x400); for (int32_t i = 0; i < 0x400; ++i) { const float fcent = m_rate * (1024.0f + (float)i) / 1024.0f; @@ -543,8 +543,8 @@ void multipcm_device::device_start() } // Envelope steps - m_attack_step = auto_alloc_array_clear(machine(), uint32_t, 0x40); - m_decay_release_step = auto_alloc_array_clear(machine(), uint32_t, 0x40); + m_attack_step = make_unique_clear<uint32_t[]>(0x40); + m_decay_release_step = make_unique_clear<uint32_t[]>(0x40); const double attack_rate_to_decay_rate = 14.32833; for (int32_t i = 4; i < 0x40; ++i) { @@ -557,12 +557,12 @@ void multipcm_device::device_start() m_decay_release_step[0] = m_decay_release_step[1] = m_decay_release_step[2] = m_decay_release_step[3] = 0; // Total level interpolation steps - m_total_level_steps = auto_alloc_array_clear(machine(), int32_t, 2); + m_total_level_steps = make_unique_clear<int32_t[]>(2); m_total_level_steps[0] = -(float)(0x80 << TL_SHIFT) / (78.2f * 44100.0f / 1000.0f); // lower m_total_level_steps[1] = (float)(0x80 << TL_SHIFT) / (78.2f * 2 * 44100.0f / 1000.0f); // raise // build the linear->exponential ramps - m_linear_to_exp_volume = auto_alloc_array_clear(machine(), int32_t, 0x400); + m_linear_to_exp_volume = make_unique_clear<int32_t[]>(0x400); for(int32_t i = 0; i < 0x400; ++i) { const float db = -(96.0f - (96.0f * (float)i / (float)0x400)); @@ -574,7 +574,7 @@ void multipcm_device::device_start() save_item(NAME(m_address)); // Slots - m_slots = auto_alloc_array_clear(machine(), slot_t, 28); + m_slots = make_unique_clear<slot_t[]>(28); for (int32_t slot = 0; slot < 28; ++slot) { m_slots[slot].m_slot_index = slot; @@ -663,41 +663,41 @@ void multipcm_device::sound_stream_update(sound_stream &stream, stream_sample_t int32_t smpr = 0; for (int32_t sl = 0; sl < 28; ++sl) { - slot_t *slot = m_slots + sl; - if (slot->m_playing) + slot_t &slot = m_slots[sl]; + if (slot.m_playing) { - uint32_t vol = (slot->m_total_level >> TL_SHIFT) | (slot->m_pan << 7); - uint32_t adr = slot->m_offset >> TL_SHIFT; - uint32_t step = slot->m_step; - int32_t csample = (int16_t) (read_byte(slot->m_base + adr) << 8); - int32_t fpart = slot->m_offset & ((1 << TL_SHIFT) - 1); - int32_t sample = (csample * fpart + slot->m_prev_sample * ((1 << TL_SHIFT) - fpart)) >> TL_SHIFT; - - if (slot->m_regs[6] & 7) // Vibrato enabled + uint32_t vol = (slot.m_total_level >> TL_SHIFT) | (slot.m_pan << 7); + uint32_t adr = slot.m_offset >> TL_SHIFT; + uint32_t step = slot.m_step; + int32_t csample = (int16_t) (read_byte(slot.m_base + adr) << 8); + int32_t fpart = slot.m_offset & ((1 << TL_SHIFT) - 1); + int32_t sample = (csample * fpart + slot.m_prev_sample * ((1 << TL_SHIFT) - fpart)) >> TL_SHIFT; + + if (slot.m_regs[6] & 7) // Vibrato enabled { - step = step * pitch_lfo_step(&(slot->m_pitch_lfo)); + step = step * pitch_lfo_step(slot.m_pitch_lfo); step >>= TL_SHIFT; } - slot->m_offset += step; - if (slot->m_offset >= (slot->m_sample.m_end << TL_SHIFT)) + slot.m_offset += step; + if (slot.m_offset >= (slot.m_sample.m_end << TL_SHIFT)) { - slot->m_offset = slot->m_sample.m_loop << TL_SHIFT; + slot.m_offset = slot.m_sample.m_loop << TL_SHIFT; } - if (adr ^ (slot->m_offset >> TL_SHIFT)) + if (adr ^ (slot.m_offset >> TL_SHIFT)) { - slot->m_prev_sample = csample; + slot.m_prev_sample = csample; } - if ((slot->m_total_level >> TL_SHIFT) != slot->m_dest_total_level) + if ((slot.m_total_level >> TL_SHIFT) != slot.m_dest_total_level) { - slot->m_total_level += slot->m_total_level_step; + slot.m_total_level += slot.m_total_level_step; } - if (slot->m_regs[7] & 7) // Tremolo enabled + if (slot.m_regs[7] & 7) // Tremolo enabled { - sample = sample * amplitude_lfo_step(&(slot->m_amplitude_lfo)); + sample = sample * amplitude_lfo_step(slot.m_amplitude_lfo); sample >>= TL_SHIFT; } diff --git a/src/devices/sound/multipcm.h b/src/devices/sound/multipcm.h index 7e8a38502a7..1072a1846ed 100644 --- a/src/devices/sound/multipcm.h +++ b/src/devices/sound/multipcm.h @@ -92,24 +92,24 @@ private: // internal state sound_stream *m_stream; - slot_t *m_slots; + std::unique_ptr<slot_t[]> m_slots; uint32_t m_cur_slot; uint32_t m_address; float m_rate; - uint32_t *m_attack_step; - uint32_t *m_decay_release_step; // Envelope step tables - uint32_t *m_freq_step_table; // Frequency step table + std::unique_ptr<uint32_t[]> m_attack_step; + std::unique_ptr<uint32_t[]> m_decay_release_step; // Envelope step tables + std::unique_ptr<uint32_t[]> m_freq_step_table; // Frequency step table - int32_t *m_left_pan_table; - int32_t *m_right_pan_table; - int32_t *m_linear_to_exp_volume; - int32_t *m_total_level_steps; + std::unique_ptr<int32_t[]> m_left_pan_table; + std::unique_ptr<int32_t[]> m_right_pan_table; + std::unique_ptr<int32_t[]> m_linear_to_exp_volume; + std::unique_ptr<int32_t[]> m_total_level_steps; - int32_t *m_pitch_table; - int32_t **m_pitch_scale_tables; - int32_t *m_amplitude_table; - int32_t **m_amplitude_scale_tables; + std::unique_ptr<int32_t[]> m_pitch_table; + std::unique_ptr<std::unique_ptr<int32_t[]>[]> m_pitch_scale_tables; + std::unique_ptr<int32_t[]> m_amplitude_table; + std::unique_ptr<std::unique_ptr<int32_t[]>[]> m_amplitude_scale_tables; uint32_t value_to_fixed(const uint32_t bits, const float value); @@ -117,16 +117,16 @@ private: // Internal LFO functions void lfo_init(); - void lfo_compute_step(lfo_t *lfo, uint32_t lfo_frequency, uint32_t LFOS, int32_t amplitude_lfo); - int32_t pitch_lfo_step(lfo_t *lfo); - int32_t amplitude_lfo_step(lfo_t *lfo); + void lfo_compute_step(lfo_t &lfo, uint32_t lfo_frequency, uint32_t LFOS, int32_t amplitude_lfo); + int32_t pitch_lfo_step(lfo_t &lfo); + int32_t amplitude_lfo_step(lfo_t &lfo); // Internal envelope functions - int32_t envelope_generator_update(slot_t *slot); - void envelope_generator_calc(slot_t *slot); + int32_t envelope_generator_update(slot_t &slot); + void envelope_generator_calc(slot_t &slot); uint32_t get_rate(uint32_t *steps, uint32_t rate, uint32_t val); - void write_slot(slot_t *slot, int32_t reg, uint8_t data); + void write_slot(slot_t &slot, int32_t reg, uint8_t data); int16_t clamp_to_int16(int32_t value); diff --git a/src/devices/video/zeus2.cpp b/src/devices/video/zeus2.cpp index 971b676374a..99cb29aa8b2 100644 --- a/src/devices/video/zeus2.cpp +++ b/src/devices/video/zeus2.cpp @@ -71,12 +71,12 @@ TIMER_CALLBACK_MEMBER(zeus2_device::int_timer_callback) void zeus2_device::device_start() { /* allocate memory for "wave" RAM */ - waveram = auto_alloc_array(machine(), uint32_t, WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8/4); + m_waveram = std::make_unique<uint32_t[]>(WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8/4); m_frameColor = std::make_unique<uint32_t[]>(WAVERAM1_WIDTH * WAVERAM1_HEIGHT * 2); m_frameDepth = std::make_unique<int32_t[]>(WAVERAM1_WIDTH * WAVERAM1_HEIGHT * 2); /* initialize polygon engine */ - poly = auto_alloc(machine(), zeus2_renderer(this)); + poly = std::make_unique<zeus2_renderer>(this); m_vblank.resolve_safe(); m_irq.resolve_safe(); @@ -116,7 +116,7 @@ void zeus2_device::device_start() save_item(NAME(zeus_texbase)); save_item(NAME(zeus_quad_size)); save_item(NAME(m_useZOffset)); - save_pointer(NAME(waveram), WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8 / 4); + save_pointer(NAME(m_waveram), WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8 / 4); save_pointer(NAME(m_frameColor), WAVERAM1_WIDTH * WAVERAM1_HEIGHT * 2); save_pointer(NAME(m_frameDepth), WAVERAM1_WIDTH * WAVERAM1_HEIGHT * 2); save_item(NAME(m_pal_table)); @@ -171,7 +171,7 @@ void zeus2_device::device_stop() myfile.open(fileName.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); if (myfile.is_open()) - myfile.write((char *)waveram, WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 2 * sizeof(uint32_t)); + myfile.write((char *)m_waveram.get(), WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 2 * sizeof(uint32_t)); myfile.close(); #endif @@ -1107,7 +1107,7 @@ if (subregdata_count[which] < 256) { //int blockNum = ((m_renderRegs[0x9] >> 16) * 1024 + (m_renderRegs[0x9] & 0xffff)); int blockNum = m_renderRegs[0x9]; - void *dataPtr = (void *)(&waveram[blockNum * 2]); + void *dataPtr = (void *)(&m_waveram[blockNum * 2]); if (logit) logerror("\t(R%02X) = %06x PAL Control Load Table Byte Addr = %08X", which, value, blockNum * 8); m_curPalTableSrc = m_renderRegs[0x9]; diff --git a/src/devices/video/zeus2.h b/src/devices/video/zeus2.h index 82ef892f667..a33d8f4e475 100644 --- a/src/devices/video/zeus2.h +++ b/src/devices/video/zeus2.h @@ -63,8 +63,8 @@ struct zeus2_poly_extra_data * Macros *************************************/ -#define WAVERAM_BLOCK0(blocknum) ((void *)((uint8_t *)waveram + 8 * (blocknum))) -#define WAVERAM_BLOCK0_EXT(blocknum) ((void *)((uint8_t *)m_state->waveram + 8 * (blocknum))) +#define WAVERAM_BLOCK0(blocknum) ((void *)((uint8_t *)m_waveram.get() + 8 * (blocknum))) +#define WAVERAM_BLOCK0_EXT(blocknum) ((void *)((uint8_t *)m_state->m_waveram.get() + 8 * (blocknum))) #define WAVERAM_PTR8(base, bytenum) ((uint8_t *)(base) + BYTE4_XOR_LE(bytenum)) #define WAVERAM_READ8(base, bytenum) (*WAVERAM_PTR8(base, bytenum)) @@ -124,7 +124,7 @@ public: uint32_t m_zeusbase[0x80]; uint32_t m_renderRegs[0x50]; - zeus2_renderer* poly; + std::unique_ptr<zeus2_renderer> poly; rectangle zeus_cliprect; @@ -136,7 +136,7 @@ public: int zeus_quad_size; bool m_useZOffset; - uint32_t *waveram; + std::unique_ptr<uint32_t[]> m_waveram; std::unique_ptr<uint32_t[]> m_frameColor; std::unique_ptr<int32_t[]> m_frameDepth; uint32_t m_pal_table[0x100]; diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 9ef8b5bcbb3..c61afae5126 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -1400,18 +1400,18 @@ void debugger_commands::execute_bplist(int ref, const std::vector<std::string> & /* loop over all CPUs */ for (device_t &device : device_iterator(m_machine.root_device())) - if (device.debug()->breakpoint_first() != nullptr) + if (!device.debug()->breakpoint_list().empty()) { m_console.printf("Device '%s' breakpoints:\n", device.tag()); /* loop over the breakpoints */ - for (device_debug::breakpoint *bp = device.debug()->breakpoint_first(); bp != nullptr; bp = bp->next()) + for (const device_debug::breakpoint &bp : device.debug()->breakpoint_list()) { - buffer = string_format("%c%4X @ %0*X", bp->enabled() ? ' ' : 'D', bp->index(), device.debug()->logaddrchars(), bp->address()); - if (std::string(bp->condition()).compare("1") != 0) - buffer.append(string_format(" if %s", bp->condition())); - if (std::string(bp->action()).compare("") != 0) - buffer.append(string_format(" do %s", bp->action())); + buffer = string_format("%c%4X @ %0*X", bp.enabled() ? ' ' : 'D', bp.index(), device.debug()->logaddrchars(), bp.address()); + if (std::string(bp.condition()).compare("1") != 0) + buffer.append(string_format(" if %s", bp.condition())); + if (std::string(bp.action()).compare("") != 0) + buffer.append(string_format(" do %s", bp.action())); m_console.printf("%s\n", buffer.c_str()); printed++; } @@ -1700,16 +1700,16 @@ void debugger_commands::execute_rplist(int ref, const std::vector<std::string> & /* loop over all CPUs */ for (device_t &device : device_iterator(m_machine.root_device())) - if (device.debug()->registerpoint_first() != nullptr) + if (!device.debug()->registerpoint_list().empty()) { m_console.printf("Device '%s' registerpoints:\n", device.tag()); /* loop over the breakpoints */ - for (device_debug::registerpoint *rp = device.debug()->registerpoint_first(); rp != nullptr; rp = rp->next()) + for (const device_debug::registerpoint &rp : device.debug()->registerpoint_list()) { - buffer = string_format("%c%4X if %s", rp->enabled() ? ' ' : 'D', rp->index(), rp->condition()); - if (rp->action() != nullptr) - buffer.append(string_format(" do %s", rp->action())); + buffer = string_format("%c%4X if %s", rp.enabled() ? ' ' : 'D', rp.index(), rp.condition()); + if (rp.action() != nullptr) + buffer.append(string_format(" do %s", rp.action())); m_console.printf("%s\n", buffer.c_str()); printed++; } diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index e49c5bfdb61..01e0a91647b 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -1297,8 +1297,8 @@ device_debug::device_debug(device_t &device) , m_total_cycles(0) , m_last_total_cycles(0) , m_pc_history_index(0) - , m_bplist(nullptr) - , m_rplist(nullptr) + , m_bplist() + , m_rplist() , m_triggered_breakpoint(nullptr) , m_triggered_watchpoint(nullptr) , m_trace(nullptr) @@ -1922,23 +1922,33 @@ void device_debug::halt_on_next_instruction_impl(util::format_argument_pack<std: } //------------------------------------------------- +// breakpoint_find - return a breakpoint at the +// given address, or nullptr if none exists there +//------------------------------------------------- + +const device_debug::breakpoint *device_debug::breakpoint_find(offs_t address) const +{ + for (const breakpoint &bp : m_bplist) + if (bp.address() == address) + return &bp; + + return nullptr; +} + +//------------------------------------------------- // breakpoint_set - set a new breakpoint, // returning its index //------------------------------------------------- int device_debug::breakpoint_set(offs_t address, const char *condition, const char *action) { - // allocate a new one + // allocate a new one and hook it into our list u32 id = m_device.machine().debugger().cpu().get_breakpoint_index(); - breakpoint *bp = auto_alloc(m_device.machine(), breakpoint(this, m_symtable, id, address, condition, action)); - - // hook it into our list - bp->m_next = m_bplist; - m_bplist = bp; + m_bplist.emplace_front(this, m_symtable, id, address, condition, action); // update the flags and return the index breakpoint_update_flags(); - return bp->m_index; + return m_bplist.front().m_index; } @@ -1950,12 +1960,10 @@ int device_debug::breakpoint_set(offs_t address, const char *condition, const ch bool device_debug::breakpoint_clear(int index) { // scan the list to see if we own this breakpoint - for (breakpoint **bp = &m_bplist; *bp != nullptr; bp = &(*bp)->m_next) - if ((*bp)->m_index == index) + for (auto bbp = m_bplist.before_begin(); std::next(bbp) != m_bplist.end(); ++bbp) + if (std::next(bbp)->m_index == index) { - breakpoint *deleteme = *bp; - *bp = deleteme->m_next; - auto_free(m_device.machine(), deleteme); + m_bplist.erase_after(bbp); breakpoint_update_flags(); return true; } @@ -1971,9 +1979,9 @@ bool device_debug::breakpoint_clear(int index) void device_debug::breakpoint_clear_all() { - // clear the head until we run out - while (m_bplist != nullptr) - breakpoint_clear(m_bplist->index()); + // clear the list + m_bplist.clear(); + breakpoint_update_flags(); } @@ -1985,10 +1993,10 @@ void device_debug::breakpoint_clear_all() bool device_debug::breakpoint_enable(int index, bool enable) { // scan the list to see if we own this breakpoint - for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->next()) - if (bp->m_index == index) + for (breakpoint &bp : m_bplist) + if (bp.m_index == index) { - bp->m_enabled = enable; + bp.m_enabled = enable; breakpoint_update_flags(); return true; } @@ -2006,8 +2014,8 @@ bool device_debug::breakpoint_enable(int index, bool enable) void device_debug::breakpoint_enable_all(bool enable) { // apply the enable to all breakpoints we own - for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->next()) - breakpoint_enable(bp->index(), enable); + for (breakpoint &bp : m_bplist) + breakpoint_enable(bp.index(), enable); } @@ -2107,15 +2115,11 @@ int device_debug::registerpoint_set(const char *condition, const char *action) { // allocate a new one u32 id = m_device.machine().debugger().cpu().get_registerpoint_index(); - registerpoint *rp = auto_alloc(m_device.machine(), registerpoint(m_symtable, id, condition, action)); - - // hook it into our list - rp->m_next = m_rplist; - m_rplist = rp; + m_rplist.emplace_front(m_symtable, id, condition, action); // update the flags and return the index breakpoint_update_flags(); - return rp->m_index; + return m_rplist.front().m_index; } @@ -2127,12 +2131,10 @@ int device_debug::registerpoint_set(const char *condition, const char *action) bool device_debug::registerpoint_clear(int index) { // scan the list to see if we own this registerpoint - for (registerpoint **rp = &m_rplist; *rp != nullptr; rp = &(*rp)->m_next) - if ((*rp)->m_index == index) + for (auto brp = m_rplist.before_begin(); std::next(brp) != m_rplist.end(); ++brp) + if (std::next(brp)->m_index == index) { - registerpoint *deleteme = *rp; - *rp = deleteme->m_next; - auto_free(m_device.machine(), deleteme); + m_rplist.erase_after(brp); breakpoint_update_flags(); return true; } @@ -2148,9 +2150,9 @@ bool device_debug::registerpoint_clear(int index) void device_debug::registerpoint_clear_all() { - // clear the head until we run out - while (m_rplist != nullptr) - registerpoint_clear(m_rplist->index()); + // clear the list + m_rplist.clear(); + breakpoint_update_flags(); } @@ -2162,10 +2164,10 @@ void device_debug::registerpoint_clear_all() bool device_debug::registerpoint_enable(int index, bool enable) { // scan the list to see if we own this conditionpoint - for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->next()) - if (rp->m_index == index) + for (registerpoint &rp : m_rplist) + if (rp.m_index == index) { - rp->m_enabled = enable; + rp.m_enabled = enable; breakpoint_update_flags(); return true; } @@ -2183,8 +2185,8 @@ bool device_debug::registerpoint_enable(int index, bool enable) void device_debug::registerpoint_enable_all(bool enable) { // apply the enable to all registerpoints we own - for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->next()) - registerpoint_enable(rp->index(), enable); + for (registerpoint &rp : m_rplist) + registerpoint_enable(rp.index(), enable); } @@ -2506,8 +2508,8 @@ void device_debug::breakpoint_update_flags() { // see if there are any enabled breakpoints m_flags &= ~DEBUG_FLAG_LIVE_BP; - for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->m_next) - if (bp->m_enabled) + for (breakpoint &bp : m_bplist) + if (bp.m_enabled) { m_flags |= DEBUG_FLAG_LIVE_BP; break; @@ -2516,9 +2518,9 @@ void device_debug::breakpoint_update_flags() if ( ! ( m_flags & DEBUG_FLAG_LIVE_BP ) ) { // see if there are any enabled registerpoints - for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->m_next) + for (registerpoint &rp : m_rplist) { - if (rp->m_enabled) + if (rp.m_enabled) { m_flags |= DEBUG_FLAG_LIVE_BP; } @@ -2541,43 +2543,43 @@ void device_debug::breakpoint_check(offs_t pc) debugger_cpu& debugcpu = m_device.machine().debugger().cpu(); // see if we match - for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->m_next) - if (bp->hit(pc)) + for (breakpoint &bp : m_bplist) + if (bp.hit(pc)) { // halt in the debugger by default debugcpu.set_execution_stopped(); // if we hit, evaluate the action - if (!bp->m_action.empty()) - m_device.machine().debugger().console().execute_command(bp->m_action, false); + if (!bp.m_action.empty()) + m_device.machine().debugger().console().execute_command(bp.m_action, false); // print a notification, unless the action made us go again if (debugcpu.is_stopped()) { - m_device.machine().debugger().console().printf("Stopped at breakpoint %X\n", bp->m_index); - m_triggered_breakpoint = bp; + m_device.machine().debugger().console().printf("Stopped at breakpoint %X\n", bp.m_index); + m_triggered_breakpoint = &bp; } break; } // see if we have any matching registerpoints - for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->m_next) + for (registerpoint &rp : m_rplist) { - if (rp->hit()) + if (rp.hit()) { // halt in the debugger by default debugcpu.set_execution_stopped(); // if we hit, evaluate the action - if (!rp->m_action.empty()) + if (!rp.m_action.empty()) { - m_device.machine().debugger().console().execute_command(rp->m_action, false); + m_device.machine().debugger().console().execute_command(rp.m_action, false); } // print a notification, unless the action made us go again if (debugcpu.is_stopped()) { - m_device.machine().debugger().console().printf("Stopped at registerpoint %X\n", rp->m_index); + m_device.machine().debugger().console().printf("Stopped at registerpoint %X\n", rp.m_index); } break; } @@ -2723,7 +2725,6 @@ device_debug::breakpoint::breakpoint(device_debug* debugInterface, const char *condition, const char *action) : m_debugInterface(debugInterface), - m_next(nullptr), m_index(index), m_enabled(true), m_address(address), @@ -3091,8 +3092,7 @@ void device_debug::watchpoint::triggered(read_or_write type, offs_t address, u64 //------------------------------------------------- device_debug::registerpoint::registerpoint(symbol_table &symbols, int index, const char *condition, const char *action) - : m_next(nullptr), - m_index(index), + : m_index(index), m_enabled(true), m_condition(&symbols, (condition != nullptr) ? condition : "1"), m_action((action != nullptr) ? action : "") diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 0feeee51386..26653eb2baa 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -57,7 +57,6 @@ public: // getters const device_debug *debugInterface() const { return m_debugInterface; } - breakpoint *next() const { return m_next; } int index() const { return m_index; } bool enabled() const { return m_enabled; } offs_t address() const { return m_address; } @@ -71,7 +70,6 @@ public: // internals bool hit(offs_t pc); const device_debug * m_debugInterface; // the interface we were created from - breakpoint * m_next; // next in the list int m_index; // user reported index bool m_enabled; // enabled? offs_t m_address; // execution address @@ -147,7 +145,6 @@ public: registerpoint(symbol_table &symbols, int index, const char *condition, const char *action = nullptr); // getters - registerpoint *next() const { return m_next; } int index() const { return m_index; } bool enabled() const { return m_enabled; } const char *condition() const { return m_condition.original_string(); } @@ -157,7 +154,6 @@ public: // internals bool hit(); - registerpoint * m_next; // next in the list int m_index; // user reported index bool m_enabled; // enabled? parsed_expression m_condition; // condition @@ -217,7 +213,8 @@ public: } // breakpoints - breakpoint *breakpoint_first() const { return m_bplist; } + const std::forward_list<breakpoint> &breakpoint_list() const { return m_bplist; } + const breakpoint *breakpoint_find(offs_t address) const; int breakpoint_set(offs_t address, const char *condition = nullptr, const char *action = nullptr); bool breakpoint_clear(int index); void breakpoint_clear_all(); @@ -237,7 +234,7 @@ public: watchpoint *triggered_watchpoint(void) { watchpoint *ret = m_triggered_watchpoint; m_triggered_watchpoint = nullptr; return ret; } // registerpoints - registerpoint *registerpoint_first() const { return m_rplist; } + const std::forward_list<registerpoint> ®isterpoint_list() const { return m_rplist; } int registerpoint_set(const char *condition, const char *action = nullptr); bool registerpoint_clear(int index); void registerpoint_clear_all(); @@ -340,9 +337,9 @@ private: u32 m_pc_history_index; // current history index // breakpoints and watchpoints - breakpoint * m_bplist; // list of breakpoints + std::forward_list<breakpoint> m_bplist; // list of breakpoints std::vector<std::vector<std::unique_ptr<watchpoint>>> m_wplist; // watchpoint lists for each address space - registerpoint * m_rplist; // list of registerpoints + std::forward_list<registerpoint> m_rplist; // list of registerpoints breakpoint * m_triggered_breakpoint; // latest breakpoint that was triggered watchpoint * m_triggered_watchpoint; // latest watchpoint that was triggered diff --git a/src/emu/debug/dvbpoints.cpp b/src/emu/debug/dvbpoints.cpp index 3b76c7d26fe..d86ce1150cc 100644 --- a/src/emu/debug/dvbpoints.cpp +++ b/src/emu/debug/dvbpoints.cpp @@ -167,7 +167,7 @@ void debug_view_breakpoints::view_click(const int button, const debug_view_xy& p return; // Enable / disable - m_buffer[bpIndex]->setEnabled(!m_buffer[bpIndex]->enabled()); + const_cast<device_debug::breakpoint &>(*m_buffer[bpIndex]).setEnabled(!m_buffer[bpIndex]->enabled()); machine().debug_view().update_all(DVT_DISASSEMBLY); } @@ -193,8 +193,8 @@ void debug_view_breakpoints::gather_breakpoints() { // Collect device_debug &debugInterface = *source.device()->debug(); - for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != nullptr; bp = bp->next()) - m_buffer.push_back(bp); + for (const device_debug::breakpoint &bp : debugInterface.breakpoint_list()) + m_buffer.push_back(&bp); } // And now for the sort @@ -268,7 +268,7 @@ void debug_view_breakpoints::view_update() int bpi = row + m_topleft.y - 1; if ((bpi < m_buffer.size()) && (bpi >= 0)) { - device_debug::breakpoint *const bp = m_buffer[bpi]; + const device_debug::breakpoint *const bp = m_buffer[bpi]; linebuf.clear(); linebuf.rdbuf()->clear(); diff --git a/src/emu/debug/dvbpoints.h b/src/emu/debug/dvbpoints.h index 2d3ae38fa58..2cba6cd3081 100644 --- a/src/emu/debug/dvbpoints.h +++ b/src/emu/debug/dvbpoints.h @@ -49,7 +49,7 @@ private: // internal state bool (*m_sortType)(const device_debug::breakpoint *, const device_debug::breakpoint *); - std::vector<device_debug::breakpoint *> m_buffer; + std::vector<const device_debug::breakpoint *> m_buffer; }; #endif // MAME_EMU_DEBUG_DVBPOINTS_H diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp index 35550e75c01..667542483a4 100644 --- a/src/emu/debug/dvdisasm.cpp +++ b/src/emu/debug/dvdisasm.cpp @@ -353,8 +353,8 @@ void debug_view_disasm::complete_information(const debug_view_disasm_source &sou dasm.m_is_pc = adr == pc; dasm.m_is_bp = false; - for(device_debug::breakpoint *bp = source.device()->debug()->breakpoint_first(); bp != nullptr; bp = bp->next()) - if(adr ==(bp->address() & source.m_space.logaddrmask())) { + for(const device_debug::breakpoint &bp : source.device()->debug()->breakpoint_list()) + if(adr == (bp.address() & source.m_space.logaddrmask())) { dasm.m_is_bp = true; break; } diff --git a/src/emu/emu.h b/src/emu/emu.h index 9c9b2c78e4e..35a5d6a3f60 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -19,6 +19,7 @@ #define __EMU_H__ #include <list> +#include <forward_list> #include <vector> #include <memory> #include <map> diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp index bf79d9258ea..7d154787c0c 100644 --- a/src/emu/natkeyboard.cpp +++ b/src/emu/natkeyboard.cpp @@ -585,17 +585,10 @@ void natural_keyboard::post_coded(const std::string &text, const attotime &rate) void natural_keyboard::paste() { // retrieve the clipboard text - char *text = osd_get_clipboard_text(); + std::string text = osd_get_clipboard_text(); - // was a result returned? - if (text != nullptr) - { - // post the text - post_utf8(text); - - // free the string - free(text); - } + // post the text + post_utf8(text); } diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 5412f182304..7b45fd92c59 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -1479,16 +1479,14 @@ void lua_engine::initialize() "bpclr", &device_debug::breakpoint_clear, "bplist", [this](device_debug &dev) { sol::table table = sol().create_table(); - device_debug::breakpoint *list = dev.breakpoint_first(); - while(list) + for(const device_debug::breakpoint &bpt : dev.breakpoint_list()) { sol::table bp = sol().create_table(); - bp["enabled"] = list->enabled(); - bp["address"] = list->address(); - bp["condition"] = list->condition(); - bp["action"] = list->action(); - table[list->index()] = bp; - list = list->next(); + bp["enabled"] = bpt.enabled(); + bp["address"] = bpt.address(); + bp["condition"] = bpt.condition(); + bp["action"] = bpt.action(); + table[bpt.index()] = bp; } return table; }, diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 4269e674f84..27987bbc9c9 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -917,15 +917,8 @@ void mame_ui_manager::decrease_frameskip() bool mame_ui_manager::can_paste() { - // retrieve the clipboard text - char *text = osd_get_clipboard_text(); - - // free the string if allocated - if (text != nullptr) - free(text); - - // did we have text? - return text != nullptr; + // check to see if the clipboard is not empty + return !osd_get_clipboard_text().empty(); } diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 80f27c0ab89..08c7a309ea6 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -230,8 +230,8 @@ maketree: $(sort $(OBJDIRS)) native: $(MAKE) CEXTRAFLAGS="-march=native -msse4.2 -Wall -Wpedantic -Wsign-compare -Wextra " -gcc5: - $(MAKE) CC=g++-5 LD=g++-5 CEXTRAFLAGS="-march=native -msse4.2 -Wall -Wpedantic -Wsign-compare -Wextra " +gcc9: + $(MAKE) CC=g++-9 LD=g++-9 CEXTRAFLAGS="-march=native -msse4.2 -Wall -Wpedantic -Wsign-compare -Wextra " clang: $(MAKE) CC=clang++-9 LD=clang++-9 CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-padded -Wno-weak-vtables -Wno-unused-template -Wno-missing-variable-declarations -Wno-float-equal -Wconversion -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-exit-time-destructors" diff --git a/src/lib/netlist/plib/pfmtlog.cpp b/src/lib/netlist/plib/pfmtlog.cpp index a58ecd3113a..a42546629cf 100644 --- a/src/lib/netlist/plib/pfmtlog.cpp +++ b/src/lib/netlist/plib/pfmtlog.cpp @@ -15,7 +15,7 @@ #include <cstdlib> #include <cstring> #include <iostream> -#include <locale> +#include <clocale> namespace plib { @@ -26,6 +26,10 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) std::array<char, 2048> buf = {0}; std::size_t sl; bool found_abs = false; + pstring old_locale(std::setlocale(LC_ALL, nullptr)); + + if (old_locale != "C") + std::setlocale(LC_ALL, "C"); m_arg++; @@ -97,6 +101,8 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) m_str = m_str.substr(0, p) + pstring(buf.data()) + m_str.substr(p + sl); va_end(ap); } while (found_abs); + if (old_locale != "C") + std::setlocale(LC_ALL, old_locale.c_str()); return *this; } diff --git a/src/mame/drivers/aci_ggm.cpp b/src/mame/drivers/aci_ggm.cpp index 976927445de..5814963e2c8 100644 --- a/src/mame/drivers/aci_ggm.cpp +++ b/src/mame/drivers/aci_ggm.cpp @@ -38,10 +38,9 @@ Other games: TODO: - what's VIA PB0 for? game toggles it once per irq - identify XTAL (2MHz CPU/VIA is correct, compared to video reference) -- add display AP segment, is it used anywhere? +- confirm display AP segment, is it used anywhere? - verify cartridge pinout, right now assume A0-A15 (max known cart size is 24KB). Boris/Sargon cartridge is A0-A11 and 2 CS lines, Steinitz uses the whole range. -- add option to auto-switch keypad overlays - (probably won't) add chesspieces to artwork? this machine supports more board games than just chess: checkers, reversi, and even a blackjack game @@ -84,6 +83,7 @@ public: void ggm(machine_config &config); DECLARE_INPUT_CHANGED_MEMBER(reset_switch) { update_reset(newval); } + DECLARE_CUSTOM_INPUT_MEMBER(overlay_r) { u8 data = m_inputs[5]->read(); return (data == 0xf) ? m_overlay : data; } protected: virtual void machine_start() override; @@ -97,7 +97,7 @@ private: required_device<dac_bit_interface> m_dac; required_device<generic_slot_device> m_cart; required_device<timer_device> m_ca1_off; - required_ioport_array<6> m_inputs; + required_ioport_array<4+3> m_inputs; void main_map(address_map &map); @@ -120,6 +120,7 @@ private: u8 m_shift_data; u8 m_shift_clock; u32 m_cart_mask; + u8 m_overlay; }; void ggm_state::machine_start() @@ -177,6 +178,10 @@ DEVICE_IMAGE_LOAD_MEMBER(ggm_state::cartridge) m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); + // keypad overlay + std::string overlay(image.get_feature("overlay")); + m_overlay = std::stoul(overlay, nullptr, 0) & 0xf; + // extra ram (optional) if (image.get_feature("ram")) m_maincpu->space(AS_PROGRAM).install_ram(0x0800, 0x0fff, nullptr); @@ -266,7 +271,7 @@ void ggm_state::main_map(address_map &map) ******************************************************************************/ #define OVERLAY(val) \ - PORT_CONDITION("IN.5", 0x01, EQUALS, val) + PORT_CONDITION("IN.6", 0x0f, EQUALS, val) static INPUT_PORTS_START( overlay_boris ) // actually most of the Chess games have a similar overlay PORT_MODIFY("IN.0") @@ -298,6 +303,66 @@ static INPUT_PORTS_START( overlay_boris ) // actually most of the Chess games ha PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x01) PORT_CODE(KEYCODE_ENTER) PORT_CODE(KEYCODE_ENTER_PAD) PORT_NAME("Enter") INPUT_PORTS_END +static INPUT_PORTS_START( overlay_morphy ) // only changed "9" to "Audio" + PORT_MODIFY("IN.0") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_0_PAD) PORT_NAME("0") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_A) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("A.1 / Pawn") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_B) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("B.2 / Knight") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_C) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("C.3 / Bishop") + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_D) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("D.4 / Rook") + + PORT_MODIFY("IN.1") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_E) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("E.5 / Queen") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_F) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("F.6 / King") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_G) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_NAME("G.7") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_H) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("H.8") + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_U) PORT_NAME("Audio") + + PORT_MODIFY("IN.2") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_SPACE) PORT_CODE(KEYCODE_MINUS) PORT_NAME("-") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_W) PORT_NAME("B/W") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_K) PORT_NAME("Rank") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_T) PORT_NAME("Time") + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_DEL) PORT_CODE(KEYCODE_BACKSPACE) PORT_NAME("CE") + + PORT_MODIFY("IN.3") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_L) PORT_NAME("Level") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_I) PORT_NAME("Halt / Hint") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_S) PORT_NAME("Best") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_R) PORT_NAME("Restore") + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x02) PORT_CODE(KEYCODE_ENTER) PORT_CODE(KEYCODE_ENTER_PAD) PORT_NAME("Enter") +INPUT_PORTS_END + +static INPUT_PORTS_START( overlay_steinitz ) + PORT_MODIFY("IN.0") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_0_PAD) PORT_CODE(KEYCODE_Y) PORT_NAME("Display / 0") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_A) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("A.1 / Pawn") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_B) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("B.2 / Knight") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_C) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("C.3 / Bishop") + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_D) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("D.4 / Rook") + + PORT_MODIFY("IN.1") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_E) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("E.5 / Queen") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_F) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("F.6 / King") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_G) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_NAME("G.7") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_H) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("H.8") + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_9_PAD) PORT_CODE(KEYCODE_U) PORT_NAME("Audio / 9") + + PORT_MODIFY("IN.2") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_V) PORT_CODE(KEYCODE_LEFT) PORT_CODE(KEYCODE_RIGHT) PORT_NAME("Review / Left / Right") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_W) PORT_NAME("B/W") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_K) PORT_NAME("Rank") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_T) PORT_NAME("Time / Change") + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_DEL) PORT_CODE(KEYCODE_BACKSPACE) PORT_NAME("CE") + + PORT_MODIFY("IN.3") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_L) PORT_NAME("Level") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_I) PORT_NAME("Halt / Hint / Look") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_S) PORT_NAME("Best / Score") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_R) PORT_NAME("Restore / Timing") + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x03) PORT_CODE(KEYCODE_ENTER) PORT_CODE(KEYCODE_ENTER_PAD) PORT_NAME("Enter") +INPUT_PORTS_END + static INPUT_PORTS_START( ggm ) PORT_START("IN.0") PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x00) PORT_CODE(KEYCODE_X) PORT_NAME("Keypad 4-2") @@ -328,6 +393,8 @@ static INPUT_PORTS_START( ggm ) PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) OVERLAY(0x00) PORT_CODE(KEYCODE_B) PORT_NAME("Keypad 4-5") PORT_INCLUDE( overlay_boris ) + PORT_INCLUDE( overlay_morphy ) + PORT_INCLUDE( overlay_steinitz ) PORT_START("IN.4") PORT_CONFNAME( 0x01, 0x00, "Version" ) // factory-set @@ -336,9 +403,15 @@ static INPUT_PORTS_START( ggm ) PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_CODE(KEYCODE_F1) PORT_TOGGLE PORT_CHANGED_MEMBER(DEVICE_SELF, ggm_state, reset_switch, 0) PORT_NAME("Memory Switch") PORT_START("IN.5") - PORT_CONFNAME( 0x01, 0x01, "Keypad Overlay" ) + PORT_CONFNAME( 0x0f, 0x0f, "Keypad Overlay" ) PORT_CONFSETTING( 0x00, "None" ) + PORT_CONFSETTING( 0x0f, "Auto" ) // get param from softwarelist PORT_CONFSETTING( 0x01, "Boris 2.5" ) + PORT_CONFSETTING( 0x02, "Morphy" ) + PORT_CONFSETTING( 0x03, "Steinitz" ) + + PORT_START("IN.6") + PORT_BIT(0x0f, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_CUSTOM_MEMBER(DEVICE_SELF, ggm_state, overlay_r, nullptr) INPUT_PORTS_END diff --git a/src/mame/drivers/balsente.cpp b/src/mame/drivers/balsente.cpp index 393e2fbd169..f4c3f8bc33b 100644 --- a/src/mame/drivers/balsente.cpp +++ b/src/mame/drivers/balsente.cpp @@ -45,11 +45,11 @@ * Trivial Pursuit (Volumen III, Spanish, Maibesa license) * Trivial Pursuit (Volumen II, Spanish, Maibesa license) * Trivial Pursuit (Volumen IV, Spanish, Maibesa hardware) + * Trivial Pursuit (Volumen V, Spanish, Maibesa hardware) Looking for ROMs for these: * Euro Stocker * Trivial Pursuit (Volumen I, Spanish, Maibesa) - * Trivial Pursuit (Volumen V, Spanish, Maibesa) [probably running on Maibesa hardware] Known bugs: * CEM3394 emulation is not perfect diff --git a/src/mame/drivers/blackt96.cpp b/src/mame/drivers/blackt96.cpp index b27ff71a5a1..fd169f16b03 100644 --- a/src/mame/drivers/blackt96.cpp +++ b/src/mame/drivers/blackt96.cpp @@ -39,6 +39,7 @@ D.G.R.M. NO 1947 Notes: 68000 clock 9.000MHz [18/2] M6295 clocks 1.000MHz [8/8] pin 7 high + PIC16C57 clock 4.000MHz [8/2] 2008-07 @@ -480,11 +481,11 @@ void blackt96_state::tile_callback(int &tile, int& fx, int& fy, int& region) void blackt96_state::blackt96(machine_config &config) { - M68000(config, m_maincpu, 18000000 /2); + M68000(config, m_maincpu, 18_MHz_XTAL / 2); m_maincpu->set_addrmap(AS_PROGRAM, &blackt96_state::blackt96_map); m_maincpu->set_vblank_int("screen", FUNC(blackt96_state::irq1_line_hold)); - pic16c57_device &audiocpu(PIC16C57(config, "audiocpu", 8000000)); /* ? */ + pic16c57_device &audiocpu(PIC16C57(config, "audiocpu", 8_MHz_XTAL / 2)); audiocpu.write_a().set(FUNC(blackt96_state::blackt96_soundio_port_a_w)); audiocpu.read_b().set(FUNC(blackt96_state::blackt96_soundio_port_b_r)); audiocpu.write_b().set(FUNC(blackt96_state::blackt96_soundio_port_b_w)); @@ -512,12 +513,12 @@ void blackt96_state::blackt96(machine_config &config) SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); - OKIM6295(config, m_oki[0], 8000000/8, okim6295_device::PIN7_HIGH); // music + OKIM6295(config, m_oki[0], 8_MHz_XTAL / 8, okim6295_device::PIN7_HIGH); // music m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.47); m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.47); m_oki[0]->set_addrmap(0, &blackt96_state::oki1_map); - OKIM6295(config, m_oki[1], 8000000/8, okim6295_device::PIN7_HIGH); // sfx + OKIM6295(config, m_oki[1], 8_MHz_XTAL / 8, okim6295_device::PIN7_HIGH); // sfx m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.47); m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.47); } diff --git a/src/mame/drivers/deco_mlc.cpp b/src/mame/drivers/deco_mlc.cpp index 687d233f865..4aaafca563a 100644 --- a/src/mame/drivers/deco_mlc.cpp +++ b/src/mame/drivers/deco_mlc.cpp @@ -96,8 +96,8 @@ skullfng - slowdowns not verified from real PCB, Random hangs sometimes Graphic TODO: - blending, raster effect features isn't fully emulated currently - Not verified : Can sprites effect 8bpp and alpha blending simultaneously? + blending, raster effect features isn't fully emulated, verified currently + Not verified : Can sprites effect 8bpp and shadowing simultaneously? Not verified what palette highest bits actually doing Driver by Bryan McPhail, bmcphail@tendril.co.uk, thank you to Avedis and The Guru. @@ -141,7 +141,8 @@ WRITE32_MEMBER(deco_mlc_state::mlc_44001c_w) READ32_MEMBER(deco_mlc_state::mlc_200070_r) { - m_vbl_i ^=0xffffffff; + if (!machine().side_effects_disabled()) + m_vbl_i ^= 0xffffffff; //logerror("vbl r %08x\n", m_maincpu->pc()); // Todo: Vblank probably in $10 return m_vbl_i; @@ -171,15 +172,18 @@ READ32_MEMBER(deco_mlc_state::mlc_scanline_r) WRITE32_MEMBER(deco_mlc_state::eeprom_w) { - if (ACCESSING_BITS_8_15) { - uint8_t ebyte=(data>>8)&0xff; -// if (ebyte&0x80) { + if (ACCESSING_BITS_8_15) + { + const u8 ebyte = (data >> 8) & 0xff; +// if (ebyte & 0x80) +// { m_eeprom->clk_write((ebyte & 0x2) ? ASSERT_LINE : CLEAR_LINE); m_eeprom->di_write(ebyte & 0x1); m_eeprom->cs_write((ebyte & 0x4) ? ASSERT_LINE : CLEAR_LINE); // } } - else if (ACCESSING_BITS_0_7) { + else if (ACCESSING_BITS_0_7) + { /* Master volume control (TODO: probably logaritmic) */ m_ymz->set_output_gain(0, (255.0 - data) / 255.0); m_ymz->set_output_gain(1, (255.0 - data) / 255.0); @@ -222,30 +226,30 @@ WRITE32_MEMBER(deco_mlc_state::irq_ram_w) Word 3 : Unknown(Always 0) */ - switch (offset*4) + switch (offset * 4) { case 0x10: /* IRQ ack. Value written doesn't matter */ m_maincpu->set_input_line(m_irqLevel, CLEAR_LINE); return; case 0x14: /* Prepare scanline interrupt */ - if(m_irq_ram[0x14/4] == -1) // TODO: likely to be anything that doesn't fit into the screen v-pos range. + if(m_irq_ram[0x14 / 4] == -1) // TODO: likely to be anything that doesn't fit into the screen v-pos range. m_raster_irq_timer->adjust(attotime::never); else - m_raster_irq_timer->adjust(m_screen->time_until_pos(m_irq_ram[0x14/4])); - //logerror("prepare scanline to fire at %d (currently on %d)\n", m_irq_ram[0x14/4], m_screen->vpos()); + m_raster_irq_timer->adjust(m_screen->time_until_pos(m_irq_ram[0x14 / 4])); + //logerror("prepare scanline to fire at %d (currently on %d)\n", m_irq_ram[0x14 / 4], m_screen->vpos()); return; default: break; }; -// logerror("irqw %04x %04x (%d)\n", offset * 4, data&0xffff, scanline); +// logerror("irqw %04x %04x (%d)\n", offset * 4, data & 0xffff, scanline); } READ32_MEMBER( deco_mlc_state::spriteram_r ) { - uint32_t retdata = 0; + u32 retdata = 0; if (ACCESSING_BITS_16_31) { @@ -278,8 +282,8 @@ READ16_MEMBER( deco_mlc_state::sh96_protection_region_0_146_r ) { int real_address = 0 + (offset *2); int deco146_addr = bitswap<32>(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff; - uint8_t cs = 0; - uint16_t data = m_deco146->read_data( deco146_addr, cs ); + u8 cs = 0; + u16 data = m_deco146->read_data( deco146_addr, cs ); return data; } @@ -287,7 +291,7 @@ WRITE16_MEMBER( deco_mlc_state::sh96_protection_region_0_146_w ) { int real_address = 0 + (offset *2); int deco146_addr = bitswap<32>(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff; - uint8_t cs = 0; + u8 cs = 0; m_deco146->write_data( deco146_addr, data, mem_mask, cs ); } @@ -912,22 +916,19 @@ ROM_END void deco_mlc_state::descramble_sound( ) { /* the same as simpl156 / heavy smash? */ - uint8_t *rom = memregion("ymz")->base(); + u8 *rom = memregion("ymz")->base(); int length = memregion("ymz")->bytes(); - std::vector<uint8_t> buf(length); + std::vector<u8> buf(length); - uint32_t x; - - for (x=0;x<length;x++) + for (u32 x = 0; x < length; x++) { - uint32_t addr; - - addr = bitswap<24> (x,23,22,21,0, 20, - 19,18,17,16, - 15,14,13,12, - 11,10,9, 8, - 7, 6, 5, 4, - 3, 2, 1 ); + const u32 addr = bitswap<24>(x, + 23,22,21,0, 20, + 19,18,17,16, + 15,14,13,12, + 11,10,9, 8, + 7, 6, 5, 4, + 3, 2, 1 ); buf[addr] = rom[x]; } @@ -937,10 +938,10 @@ void deco_mlc_state::descramble_sound( ) READ32_MEMBER(deco_mlc_state::avengrgs_speedup_r) { - uint32_t a=m_mainram[0x89a0/4]; - uint32_t p=m_maincpu->pc(); + const u32 a = m_mainram[0x89a0 / 4]; + const u32 p = m_maincpu->pc(); - if ((p==0x3234 || p==0x32dc) && (a&1)) m_maincpu->spin_until_interrupt(); + if ((p == 0x3234 || p == 0x32dc) && (a & 1)) m_maincpu->spin_until_interrupt(); return a; } @@ -955,7 +956,7 @@ void deco_mlc_state::init_avengrgs() dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_pcflush(0x32dc); dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0100000, 0x01088ff, 0, &m_mainram[0]); - dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0108a00, 0x011ffff, 0, &m_mainram[0x8a00/4]); + dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0108a00, 0x011ffff, 0, &m_mainram[0x8a00 / 4]); dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0200080, 0x02000ff, 0, &m_clip_ram[0]); dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0280000, 0x029ffff, 0, &m_vram[0]); diff --git a/src/mame/drivers/ertictac.cpp b/src/mame/drivers/ertictac.cpp index 2686577a556..475ba24611e 100644 --- a/src/mame/drivers/ertictac.cpp +++ b/src/mame/drivers/ertictac.cpp @@ -9,7 +9,7 @@ original driver by Tomasz Slanina, Steve Ellenoff, Nicola Salmoria rewrite to use AA functions by R. Belmont & Angelo Salese - special thanks to Tom Walker (author of the Acorn Archimedes Arculator emulator) + special thanks to Sarah Walker (author of the Acorn Archimedes Arculator emulator) TODO (specific issues only): - Sound is currently ugly in both games, recognizable but still nowhere near perfection diff --git a/src/mame/drivers/hh_sm510.cpp b/src/mame/drivers/hh_sm510.cpp index 108c584bdcd..b61de6e5090 100644 --- a/src/mame/drivers/hh_sm510.cpp +++ b/src/mame/drivers/hh_sm510.cpp @@ -4721,7 +4721,7 @@ ROM_START( gnw_bfight ) ROM_LOAD( "bf-107.program", 0x0000, 0x1000, CRC(4c8d07ed) SHA1(a8974dff85d5f3bacaadb71b86e9b30994b6d129) ) ROM_REGION( 0x100, "maincpu:melody", 0 ) - ROM_LOAD( "bf-107.melody", 0x000, 0x100, BAD_DUMP CRC(aadc22a1) SHA1(f6e5572232eb9e83f6833073e1e1e99776245c50) ) // decap needed for verification + ROM_LOAD( "bf-107.melody", 0x000, 0x100, BAD_DUMP CRC(ffddf9ed) SHA1(e9cb3a340924363eeef5ab453c452b9cc69207b9) ) // decap needed for verification ROM_REGION( 558341, "screen", 0) ROM_LOAD( "gnw_bfight.svg", 0, 558341, CRC(f0d61fe8) SHA1(b0b56224a967e4b26836c0f7e3015d13b42ae5cc) ) diff --git a/src/mame/drivers/riscpc.cpp b/src/mame/drivers/riscpc.cpp index 9bece06ee4d..a1b1d7e0c99 100644 --- a/src/mame/drivers/riscpc.cpp +++ b/src/mame/drivers/riscpc.cpp @@ -5,7 +5,7 @@ Acorn Archimedes 7000/7000+ very preliminary driver by Angelo Salese, - based on work by Tomasz Slanina and Tom Walker + based on work by Tomasz Slanina and Sarah Walker TODO: - Move device implementations into specific files; diff --git a/src/mame/includes/archimds.h b/src/mame/includes/archimds.h index ea3ecb87623..2e13bb33219 100644 --- a/src/mame/includes/archimds.h +++ b/src/mame/includes/archimds.h @@ -146,6 +146,7 @@ private: emu_timer *m_vbl_timer; uint8_t m_floppy_select; bool check_floppy_ready(); + uint8_t m_joy_serial_data; }; /* IOC registers */ diff --git a/src/mame/includes/deco_mlc.h b/src/mame/includes/deco_mlc.h index 0483fa96288..4df1ba20ee6 100644 --- a/src/mame/includes/deco_mlc.h +++ b/src/mame/includes/deco_mlc.h @@ -51,25 +51,26 @@ private: optional_device<deco146_device> m_deco146; required_device<timer_device> m_raster_irq_timer; - required_shared_ptr<uint32_t> m_mainram; - required_shared_ptr<uint32_t> m_irq_ram; - required_shared_ptr<uint32_t> m_clip_ram; - required_shared_ptr<uint32_t> m_vram; + required_shared_ptr<u32> m_mainram; + required_shared_ptr<u32> m_irq_ram; + required_shared_ptr<u32> m_clip_ram; + required_shared_ptr<u32> m_vram; - required_region_ptr<uint8_t> m_gfx2; + required_region_ptr<u8> m_gfx2; int m_irqLevel; - uint32_t m_mlc_raster_table_1[4*256]; - uint32_t m_mlc_raster_table_2[4*256]; - uint32_t m_mlc_raster_table_3[4*256]; - uint32_t m_vbl_i; + u32 m_mlc_raster_table_1[4*256]; + u32 m_mlc_raster_table_2[4*256]; + u32 m_mlc_raster_table_3[4*256]; + u32 m_vbl_i; int m_lastScanline[9]; - uint32_t m_colour_mask; - uint32_t m_shadow_mask; + u32 m_colour_mask; + u32 m_shadow_mask; + u32 m_shadow_shift; - std::unique_ptr<uint16_t[]> m_spriteram; - std::unique_ptr<uint16_t[]> m_spriteram_spare; - std::unique_ptr<uint16_t[]> m_buffered_spriteram; + std::unique_ptr<u16[]> m_spriteram; + std::unique_ptr<u16[]> m_spriteram_spare; + std::unique_ptr<u16[]> m_buffered_spriteram; DECLARE_READ32_MEMBER(mlc_440008_r); DECLARE_READ32_MEMBER(mlc_44001c_r); @@ -89,15 +90,15 @@ private: DECLARE_READ16_MEMBER( sh96_protection_region_0_146_r ); DECLARE_WRITE16_MEMBER( sh96_protection_region_0_146_w ); - uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); DECLARE_WRITE_LINE_MEMBER(screen_vblank_mlc); TIMER_DEVICE_CALLBACK_MEMBER(interrupt_gen); - void draw_sprites( const rectangle &cliprect, int scanline, uint32_t* dest); - void drawgfxzoomline(uint32_t* dest,const rectangle &clip,gfx_element *gfx, - uint32_t code1,uint32_t code2, uint32_t color,int flipx,int sx, + void draw_sprites( const rectangle &cliprect, int scanline, u32* dest, u8* pri); + void drawgfxzoomline(u32* dest, u8* pri,const rectangle &clip,gfx_element *gfx, + u32 code1,u32 code2, u32 color,int flipx,int sx, int transparent_color,int use8bpp, - int scalex, int alpha, int srcline, int shadowMode, int alphaMode); - void descramble_sound( ); + int scalex, int srcline, int shadowMode); + void descramble_sound(); void avengrgs_map(address_map &map); void decomlc_map(address_map &map); diff --git a/src/mame/includes/midzeus.h b/src/mame/includes/midzeus.h index c94f86fea88..b33f7481b45 100644 --- a/src/mame/includes/midzeus.h +++ b/src/mame/includes/midzeus.h @@ -12,9 +12,58 @@ #include "emupal.h" #include "screen.h" #include "machine/midwayic.h" +#include "video/poly.h" + +/************************************* + * + * Type definitions + * + *************************************/ + +struct mz_poly_extra_data +{ + const void * palbase; + const void * texbase; + uint16_t solidcolor; + uint16_t voffset; + int16_t zoffset; + uint16_t transcolor; + uint16_t texwidth; + uint16_t color; + uint32_t alpha; + uint32_t ctrl_word; + bool blend_enable; + bool depth_test_enable; + bool depth_write_enable; + uint32_t blend; + uint8_t (*get_texel)(const void *, int, int, int); +}; + + +class midzeus_state; + +class midzeus_renderer : public poly_manager<float, mz_poly_extra_data, 4, 10000> +{ +public: + midzeus_renderer(midzeus_state &state); + + void render_poly(int32_t scanline, const extent_t& extent, const mz_poly_extra_data& object, int threadid); + void render_poly_solid_fixedz(int32_t scanline, const extent_t& extent, const mz_poly_extra_data& object, int threadid); + + void zeus_draw_quad(int long_fmt, const uint32_t *databuffer, uint32_t texdata, bool logit); + void zeus_draw_debug_quad(const rectangle& rect, const vertex_t* vert); + +private: + midzeus_state& m_state; +}; + +typedef midzeus_renderer::vertex_t poly_vertex; + class midzeus_state : public driver_device { + friend class midzeus_renderer; + public: midzeus_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), @@ -127,4 +176,33 @@ private: void log_fifo_command(const uint32_t *data, int numwords, const char *suffix); void log_waveram(uint32_t length_and_base); void update_gun_irq(); + + void *waveram0_ptr_from_block_addr(uint32_t addr); + void *waveram0_ptr_from_expanded_addr(uint32_t addr); + void *waveram1_ptr_from_expanded_addr(uint32_t addr); + void *waveram0_ptr_from_texture_addr(uint32_t addr, int width); + void waveram_plot_depth(int y, int x, uint16_t color, uint16_t depth); + void waveram_plot(int y, int x, uint16_t color); + void waveram_plot_check_depth(int y, int x, uint16_t color, uint16_t depth); + void waveram_plot_check_depth_nowrite(int y, int x, uint16_t color, uint16_t depth); + + std::unique_ptr<midzeus_renderer> m_poly; + uint8_t m_log_fifo; + + uint32_t m_zeus_fifo[20]; + uint8_t m_zeus_fifo_words; + int16_t m_zeus_matrix[3][3]; + int32_t m_zeus_point[3]; + int16_t m_zeus_light[3]; + void *m_zeus_renderbase; + uint32_t m_zeus_palbase; + uint32_t m_zeus_unkbase; + int m_zeus_enable_logging; + uint32_t m_zeus_objdata; + rectangle m_zeus_cliprect; + + std::unique_ptr<uint32_t[]> m_waveram[2]; + int m_yoffs; + int m_texel_width; + int m_is_mk4b; }; diff --git a/src/mame/includes/model1.h b/src/mame/includes/model1.h index 361e42ed672..be4c1baca19 100644 --- a/src/mame/includes/model1.h +++ b/src/mame/includes/model1.h @@ -390,11 +390,11 @@ private: }; std::unique_ptr<view_t> m_view; - point_t *m_pointdb; + std::unique_ptr<point_t[]> m_pointdb; point_t *m_pointpt; - quad_t *m_quaddb; + std::unique_ptr<quad_t[]> m_quaddb; quad_t *m_quadpt; - quad_t **m_quadind; + std::unique_ptr<quad_t *[]> m_quadind; offs_t m_pushpc; u32 m_copro_hle_active_list_pos, m_copro_hle_active_list_length; typedef void (model1_state::*tgp_func)(); diff --git a/src/mame/includes/model2.h b/src/mame/includes/model2.h index dbcecfd7abc..bd8f437a753 100644 --- a/src/mame/includes/model2.h +++ b/src/mame/includes/model2.h @@ -71,7 +71,7 @@ public: std::unique_ptr<uint16_t[]> m_colorxlat; std::unique_ptr<uint16_t[]> m_lumaram; uint8_t m_gamma_table[256]; - model2_renderer *m_poly; + std::unique_ptr<model2_renderer> m_poly; /* Public for access by the ioports */ DECLARE_CUSTOM_INPUT_MEMBER(daytona_gearbox_r); @@ -139,8 +139,8 @@ protected: uint32_t m_geo_read_start_address; uint32_t m_geo_write_start_address; - raster_state *m_raster; - geo_state *m_geo; + std::unique_ptr<raster_state> m_raster; + std::unique_ptr<geo_state> m_geo; bitmap_rgb32 m_sys24_bitmap; // uint32_t m_soundack; void model2_check_irq_state(); @@ -760,4 +760,59 @@ struct quad_m2 uint8_t luma; }; +/******************************************* + * + * Hardware 3D Rasterizer Internal State + * + *******************************************/ + +#define MAX_TRIANGLES 32768 + +struct raster_state +{ +// uint32_t mode; /* bit 0 = Test Mode, bit 2 = Switch 60Hz(1)/30Hz(0) operation */ + uint16_t *texture_rom; /* Texture ROM pointer */ + uint32_t texture_rom_mask; /* Texture ROM mask */ + int16_t viewport[4]; /* View port (startx,starty,endx,endy) */ + int16_t center[4][2]; /* Centers (eye 0[x,y],1[x,y],2[x,y],3[x,y]) */ + uint16_t center_sel; /* Selected center */ + uint32_t reverse; /* Left/Right Reverse */ + float z_adjust; /* ZSort Mode */ + float triangle_z; /* Current Triangle z value */ + uint8_t master_z_clip; /* Master Z-Clip value */ + uint32_t cur_command; /* Current command */ + uint32_t command_buffer[32]; /* Command buffer */ + uint32_t command_index; /* Command buffer index */ + triangle tri_list[MAX_TRIANGLES]; /* Triangle list */ + uint32_t tri_list_index; /* Triangle list index */ + triangle *tri_sorted_list[0x10000]; /* Sorted Triangle list */ + uint16_t min_z; /* Minimum sortable Z value */ + uint16_t max_z; /* Maximum sortable Z value */ + uint16_t texture_ram[0x10000]; /* Texture RAM pointer */ + uint8_t log_ram[0x40000]; /* Log RAM pointer */ +}; + +/******************************************* + * + * Geometry Engine Internal State + * + *******************************************/ + +struct geo_state +{ + raster_state * raster; + uint32_t mode; /* bit 0 = Enable Specular, bit 1 = Calculate Normals */ + uint32_t * polygon_rom; /* Polygon ROM pointer */ + uint32_t polygon_rom_mask; /* Polygon ROM mask */ + float matrix[12]; /* Current Transformation Matrix */ + poly_vertex focus; /* Focus (x,y) */ + poly_vertex light; /* Light Vector */ + float lod; /* LOD */ + float coef_table[32]; /* Distane Coefficient table */ + texture_parameter texture_parameters[32]; /* Texture parameters */ + uint32_t polygon_ram0[0x8000]; /* Fast Polygon RAM pointer */ + uint32_t polygon_ram1[0x8000]; /* Slow Polygon RAM pointer */ + model2_state *state; +}; + #endif // MAME_INCLUDES_MODEL2_H diff --git a/src/mame/includes/slapshot.h b/src/mame/includes/slapshot.h index c39c55de977..9463402b898 100644 --- a/src/mame/includes/slapshot.h +++ b/src/mame/includes/slapshot.h @@ -81,7 +81,7 @@ private: optional_ioport m_io_service; /* video-related */ - slapshot_tempsprite *m_spritelist; + std::unique_ptr<slapshot_tempsprite[]> m_spritelist; bool m_sprites_disabled; s32 m_sprites_active_area; s32 m_sprites_master_scrollx; diff --git a/src/mame/includes/taito_f3.h b/src/mame/includes/taito_f3.h index 00e0f44cd82..2b2cb2758c0 100644 --- a/src/mame/includes/taito_f3.h +++ b/src/mame/includes/taito_f3.h @@ -13,6 +13,8 @@ #include "screen.h" #include "tilemap.h" +struct F3config; + /* This it the best way to allow game specific kludges until the system is fully understood */ enum { /* Early F3 class games, these are not cartridge games and system features may be different */ @@ -276,11 +278,11 @@ protected: u8 *m_tsrc_s[5]; u32 m_x_count[5]; u32 m_x_zoom[5]; - struct tempsprite *m_spritelist; - const struct tempsprite *m_sprite_end; - struct f3_playfield_line_inf *m_pf_line_inf; - struct f3_spritealpha_line_inf *m_sa_line_inf; - const struct F3config *m_game_config; + std::unique_ptr<tempsprite[]> m_spritelist; + const tempsprite *m_sprite_end; + std::unique_ptr<f3_playfield_line_inf[]> m_pf_line_inf; + std::unique_ptr<f3_spritealpha_line_inf[]> m_sa_line_inf; + const F3config *m_game_config; int (taito_f3_state::*m_dpix_n[8][16])(u32 s_pix); int (taito_f3_state::**m_dpix_lp[5])(u32 s_pix); int (taito_f3_state::**m_dpix_sp[9])(u32 s_pix); @@ -371,8 +373,8 @@ protected: inline void dpix_1_sprite(u32 s_pix); inline void dpix_bg(u32 bgcolor); void init_alpha_blend_func(); - inline void draw_scanlines(bitmap_rgb32 &bitmap, int xsize, s16 *draw_line_num, const struct f3_playfield_line_inf **line_t, const int *sprite, u32 orient, int skip_layer_num); - void visible_tile_check(struct f3_playfield_line_inf *line_t, int line, u32 x_index_fx, u32 y_index, u16 *pf_data_n); + inline void draw_scanlines(bitmap_rgb32 &bitmap, int xsize, s16 *draw_line_num, const f3_playfield_line_inf **line_t, const int *sprite, u32 orient, int skip_layer_num); + void visible_tile_check(f3_playfield_line_inf *line_t, int line, u32 x_index_fx, u32 y_index, u16 *pf_data_n); void calculate_clip(int y, u16 pri, u32* clip0, u32* clip1, int *line_enable); void get_spritealphaclip_info(); void get_line_ram_info(tilemap_t *tmap, int sx, int sy, int pos, u16 *pf_data_n); diff --git a/src/mame/layout/aci_ggm.lay b/src/mame/layout/aci_ggm.lay index 60a53704335..f51f070d9a5 100644 --- a/src/mame/layout/aci_ggm.lay +++ b/src/mame/layout/aci_ggm.lay @@ -5,9 +5,16 @@ <!-- define elements --> + <element name="blackb"><rect><color red="0" green="0" blue="0" /></rect></element> <element name="black"><rect><color red="0.16" green="0.16" blue="0.16" /></rect></element> <element name="disk_white"><disk><color red="0.73" green="0.73" blue="0.73" /></disk></element> <element name="brown"><rect><color red="0.25" green="0.1" blue="0.05" /></rect></element> + <element name="yellow"><rect><color red="0.8" green="0.7" blue="0.4" /></rect></element> + + <element name="red_s3" defstate="0"><rect state="3"><color red="0.8" green="0.1" blue="0.15" /></rect></element> + <element name="green_s3" defstate="0"><rect state="3"><color red="0.3" green="0.8" blue="0.2" /></rect></element> + <element name="brown_s3" defstate="0"><rect state="3"><color red="0.25" green="0.1" blue="0.05" /></rect></element> + <element name="brown_nb" defstate="0xf"><rect state="0"><color red="0.25" green="0.1" blue="0.05" /></rect></element> <element name="digit" defstate="0"> <led14seg><color red="0.2" green="1.0" blue="0.85" /></led14seg> @@ -42,118 +49,99 @@ <rect state="1"><color red="0" green="0" blue="0" /></rect> </element> + <element name="nothing" defstate="0"><text string=" "/></element> + <element name="text_r1"><text string="MEM"><color red="0.3" green="0.3" blue="0.3" /></text></element> <element name="text_r2"><text string="ON"><color red="0.3" green="0.3" blue="0.3" /></text></element> - <element name="text_boris01"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="RESTORE"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris02"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="G.7"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris03"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="H.8"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris04"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="9"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris05"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="CE"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris06a"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="HALT /" align="1"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris06b"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="HINT" align="1"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris07"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="D.4"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris08"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="E.5"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris09"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="F.6"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris10"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="TIME"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris11"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string=".BEST"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris12"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="A.1"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris13"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="B.2"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris14"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="C.3"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris15"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="RANK"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris16"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="LEVEL"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris17"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="0"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris18"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="-"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris19"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="B/W"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> - <element name="text_boris20"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="ENTER"><color red="0.8" green="0.7" blue="0.4" /></text> - </element> + <element name="text_boris01" defstate="0"><text state="1" string="RESTORE"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris02" defstate="0"><text state="1" string="G.7"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris03" defstate="0"><text state="1" string="H.8"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris04" defstate="0"><text state="1" string="9"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris05" defstate="0"><text state="1" string="CE"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris06a" defstate="0"><text state="1" string="HALT /" align="1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris06b" defstate="0"><text state="1" string="HINT" align="1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris07" defstate="0"><text state="1" string="D.4"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris08" defstate="0"><text state="1" string="E.5"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris09" defstate="0"><text state="1" string="F.6"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris10" defstate="0"><text state="1" string="TIME"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris11" defstate="0"><text state="1" string=".BEST"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris12" defstate="0"><text state="1" string="A.1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris13" defstate="0"><text state="1" string="B.2"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris14" defstate="0"><text state="1" string="C.3"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris15" defstate="0"><text state="1" string="RANK"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris16" defstate="0"><text state="1" string="LEVEL"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris17" defstate="0"><text state="1" string="0"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris18" defstate="0"><text state="1" string="-"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris19" defstate="0"><text state="1" string="B/W"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_boris20" defstate="0"><text state="1" string="ENTER"><color red="0.55" green="0.6" blue="0.35" /></text></element> + + <element name="text_morphy01" defstate="0"><text state="2" string="RESTORE"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy02" defstate="0"><text state="2" string="G.7"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy03" defstate="0"><text state="2" string="H.8"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy04" defstate="0"><text state="2" string="AUDIO"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy05" defstate="0"><text state="2" string="CE"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy06a" defstate="0"><text state="2" string="HALT /" align="1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy06b" defstate="0"><text state="2" string="HINT" align="1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy07" defstate="0"><text state="2" string="D.4"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy08" defstate="0"><text state="2" string="E.5"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy09" defstate="0"><text state="2" string="F.6"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy10" defstate="0"><text state="2" string="TIME"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy11" defstate="0"><text state="2" string=".BEST"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy12" defstate="0"><text state="2" string="A.1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy13" defstate="0"><text state="2" string="B.2"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy14" defstate="0"><text state="2" string="C.3"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy15" defstate="0"><text state="2" string="RANK"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy16" defstate="0"><text state="2" string="LEVEL"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy17" defstate="0"><text state="2" string="0"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy18" defstate="0"><text state="2" string="-"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy19" defstate="0"><text state="2" string="B/W"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_morphy20" defstate="0"><text state="2" string="ENTER"><color red="0.55" green="0.6" blue="0.35" /></text></element> + + <element name="text_steinitz01a" defstate="0"><text state="3" string="RESTORE"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz01b" defstate="0"><text state="3" string="TIMING"><color red="0.05" green="0.7" blue="0.15" /></text></element> + <element name="text_steinitz02" defstate="0"><text state="3" string="G.7"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz03" defstate="0"><text state="3" string="H.8"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz04a" defstate="0"><text state="3" string="AUDIO"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz04b" defstate="0"><text state="3" string="9"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz05" defstate="0"><text state="3" string="CE"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz06a" defstate="0"><text state="3" string="HALT /" align="1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz06b" defstate="0"><text state="3" string="HINT" align="1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz06c" defstate="0"><text state="3" string="LOOK"><color red="0.05" green="0.7" blue="0.15" /></text></element> + <element name="text_steinitz07" defstate="0"><text state="3" string="D.4"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz08" defstate="0"><text state="3" string="E.5"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz09" defstate="0"><text state="3" string="F.6"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz10a" defstate="0"><text state="3" string="TIME"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz10b" defstate="0"><text state="3" string="CHANGE"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz11a" defstate="0"><text state="3" string="BEST"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz11b" defstate="0"><text state="3" string="SCORE"><color red="0.05" green="0.7" blue="0.15" /></text></element> + <element name="text_steinitz12" defstate="0"><text state="3" string="A.1"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz13" defstate="0"><text state="3" string="B.2"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz14" defstate="0"><text state="3" string="C.3"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz15" defstate="0"><text state="3" string="RANK"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz16" defstate="0"><text state="3" string="LEVEL"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz17a" defstate="0"><text state="3" string="DISPLAY"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz17b" defstate="0"><text state="3" string="0"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz18a" defstate="0"><text state="3" string="←"><color red="0.05" green="0.7" blue="0.15" /></text></element> + <element name="text_steinitz18b" defstate="0"><text state="3" string="→"><color red="0.55" green="0.0" blue="0.1" /></text></element> + <element name="text_steinitz18c" defstate="0"><text state="3" string="REVIEW"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz19" defstate="0"><text state="3" string="B/W"><color red="0.55" green="0.6" blue="0.35" /></text></element> + <element name="text_steinitz20" defstate="0"><text state="3" string="ENTER"><color red="0.55" green="0.6" blue="0.35" /></text></element> + + <element name="digitp" defstate="9224"><led14seg><color red="0.75" green="0.1" blue="0.15" /></led14seg></element> + <element name="digitn" defstate="3244"><led14seg><color red="0.75" green="0.1" blue="0.15" /></led14seg></element> + <element name="digitb" defstate="14398"><led14seg><color red="0.75" green="0.1" blue="0.15" /></led14seg></element> + <element name="digitr" defstate="510"><led14seg><color red="0.75" green="0.1" blue="0.15" /></led14seg></element> + <element name="digitq" defstate="7132"><led14seg><color red="0.75" green="0.1" blue="0.15" /></led14seg></element> + <element name="digitk" defstate="7166"><led14seg><color red="0.75" green="0.1" blue="0.15" /></led14seg></element> + + <element name="digitpi" defstate="7159"><led14seg><color red="0" green="0" blue="0.0" /></led14seg></element> + <element name="digitni" defstate="13139"><led14seg><color red="0" green="0" blue="0.0" /></led14seg></element> + <element name="digitbi" defstate="1985"><led14seg><color red="0" green="0" blue="0.0" /></led14seg></element> + <element name="digitri" defstate="15873"><led14seg><color red="0" green="0" blue="0.0" /></led14seg></element> + <element name="digitqi" defstate="9251"><led14seg><color red="0" green="0" blue="0.0" /></led14seg></element> + <element name="digitki" defstate="9217"><led14seg><color red="0" green="0" blue="0.0" /></led14seg></element> - <element name="text_borisp"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="[P]"><color red="0.8" green="0.1" blue="0.15" /></text> - </element> - <element name="text_borisn"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="[N]"><color red="0.8" green="0.1" blue="0.15" /></text> - </element> - <element name="text_borisb"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="[B]"><color red="0.8" green="0.1" blue="0.15" /></text> - </element> - <element name="text_borisr"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="[R]"><color red="0.8" green="0.1" blue="0.15" /></text> - </element> - <element name="text_borisq"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="[Q]"><color red="0.8" green="0.1" blue="0.15" /></text> - </element> - <element name="text_borisk"> - <rect><color red="0.25" green="0.1" blue="0.05" /></rect> - <text string="[K]"><color red="0.8" green="0.1" blue="0.15" /></text> - </element> <!-- groups --> @@ -176,80 +164,204 @@ </repeat> </group> - <group name="buttons_base"> + + <group name="buttons"> <bounds x="0" y="0" width="19.5" height="13.5" /> + <!-- input listeners --> + <element ref="nothing" inputtag="IN.3" inputmask="0x08"><bounds x="0" y="0" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.1" inputmask="0x04"><bounds x="4" y="0" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.1" inputmask="0x08"><bounds x="8" y="0" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.1" inputmask="0x10"><bounds x="12" y="0" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.2" inputmask="0x10"><bounds x="16" y="0" width="3.5" height="3" /></element> + + <element ref="nothing" inputtag="IN.3" inputmask="0x02"><bounds x="0" y="3.5" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.0" inputmask="0x10"><bounds x="4" y="3.5" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.1" inputmask="0x01"><bounds x="8" y="3.5" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.1" inputmask="0x02"><bounds x="12" y="3.5" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.2" inputmask="0x08"><bounds x="16" y="3.5" width="3.5" height="3" /></element> + + <element ref="nothing" inputtag="IN.3" inputmask="0x04"><bounds x="0" y="7" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.0" inputmask="0x02"><bounds x="4" y="7" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.0" inputmask="0x04"><bounds x="8" y="7" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.0" inputmask="0x08"><bounds x="12" y="7" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.2" inputmask="0x04"><bounds x="16" y="7" width="3.5" height="3" /></element> + + <element ref="nothing" inputtag="IN.3" inputmask="0x01"><bounds x="0" y="10.5" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.0" inputmask="0x01"><bounds x="4" y="10.5" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.2" inputmask="0x01"><bounds x="8" y="10.5" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.2" inputmask="0x02"><bounds x="12" y="10.5" width="3.5" height="3" /></element> + <element ref="nothing" inputtag="IN.3" inputmask="0x10"><bounds x="16" y="10.5" width="3.5" height="3" /></element> + + <!-- buttons base --> <repeat count="4"> <param name="y" start="0" increment="3.5" /> <repeat count="5"> <param name="x" start="0" increment="4" /> - <bezel element="~basecolor~"><bounds x="~x~" y="~y~" width="3.5" height="3" /></bezel> + <element ref="yellow"><bounds x="~x~" y="~y~" width="3.5" height="3" /></element> </repeat> </repeat> - </group> - - <group name="buttons_boris"> - <bounds x="0" y="0" width="19.5" height="13.5" /> - <bezel element="text_boris01"><bounds x="0.1" y="0.9" width="3.3" height="1" /></bezel> - <bezel element="text_boris02"><bounds x="4.1" y="0.01" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris03"><bounds x="8.1" y="0.01" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris04"><bounds x="12.1" y="0.4" width="3.3" height="1.9" /></bezel> - <bezel element="text_boris05"><bounds x="16.1" y="0.6" width="3.3" height="1.5" /></bezel> - - <bezel element="text_boris06a"><bounds x="0.6" y="4.0" width="2.8" height="1" /></bezel> - <bezel element="text_boris06b"><bounds x="0.6" y="5.0" width="2.8" height="1" /></bezel> - <bezel element="text_boris07"><bounds x="4.1" y="3.51" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris08"><bounds x="8.1" y="3.51" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris09"><bounds x="12.1" y="3.51" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris10"><bounds x="16.1" y="4.4" width="3.3" height="1" /></bezel> - - <bezel element="text_boris11"><bounds x="0.1" y="7.9" width="3.3" height="1" /></bezel> - <bezel element="text_boris12"><bounds x="4.1" y="7.01" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris13"><bounds x="8.1" y="7.01" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris14"><bounds x="12.1" y="7.01" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris15"><bounds x="16.1" y="7.9" width="3.3" height="1" /></bezel> - - <bezel element="text_boris16"><bounds x="0.1" y="11.4" width="3.3" height="1" /></bezel> - <bezel element="text_boris17"><bounds x="4.1" y="10.9" width="3.3" height="1.9" /></bezel> - <bezel element="text_boris18"><bounds x="8.1" y="10.9" width="3.3" height="1.9" /></bezel> - <bezel element="text_boris19"><bounds x="12.1" y="11.1" width="3.3" height="1.5" /></bezel> - <bezel element="text_boris20"><bounds x="16.1" y="11.4" width="3.3" height="1" /></bezel> - - <bezel element="text_borisp"><bounds x="4.1" y="8.3" width="3.3" height="1.5" /></bezel> - <bezel element="text_borisn"><bounds x="8.1" y="8.3" width="3.3" height="1.5" /></bezel> - <bezel element="text_borisb"><bounds x="12.1" y="8.3" width="3.3" height="1.5" /></bezel> - <bezel element="text_borisr"><bounds x="4.1" y="4.8" width="3.3" height="1.5" /></bezel> - <bezel element="text_borisq"><bounds x="8.1" y="4.8" width="3.3" height="1.5" /></bezel> - <bezel element="text_borisk"><bounds x="12.1" y="4.8" width="3.3" height="1.5" /></bezel> - </group> - - <group name="buttons_click"> - <bounds x="0" y="0" width="19.5" height="13.5" /> + <repeat count="4"> + <param name="y" start="0.15" increment="3.5" /> + <repeat count="5"> + <param name="x" start="0.15" increment="4" /> + <element ref="brown"><bounds x="~x~" y="~y~" width="3.2" height="2.7" /></element> + </repeat> + </repeat> - <bezel element="hl" inputtag="IN.3" inputmask="0x08"><bounds x="0" y="0" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.1" inputmask="0x04"><bounds x="4" y="0" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.1" inputmask="0x08"><bounds x="8" y="0" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.1" inputmask="0x10"><bounds x="12" y="0" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.2" inputmask="0x10"><bounds x="16" y="0" width="3.5" height="3" /><color alpha="0.22" /></bezel> - - <bezel element="hl" inputtag="IN.3" inputmask="0x02"><bounds x="0" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.0" inputmask="0x10"><bounds x="4" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.1" inputmask="0x01"><bounds x="8" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.1" inputmask="0x02"><bounds x="12" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.2" inputmask="0x08"><bounds x="16" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - - <bezel element="hl" inputtag="IN.3" inputmask="0x04"><bounds x="0" y="7" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.0" inputmask="0x02"><bounds x="4" y="7" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.0" inputmask="0x04"><bounds x="8" y="7" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.0" inputmask="0x08"><bounds x="12" y="7" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.2" inputmask="0x04"><bounds x="16" y="7" width="3.5" height="3" /><color alpha="0.22" /></bezel> - - <bezel element="hl" inputtag="IN.3" inputmask="0x01"><bounds x="0" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.0" inputmask="0x01"><bounds x="4" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.2" inputmask="0x01"><bounds x="8" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.2" inputmask="0x02"><bounds x="12" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> - <bezel element="hl" inputtag="IN.3" inputmask="0x10"><bounds x="16" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></bezel> + <!-- chess symbols --> + <element ref="blackb"><bounds x="5.25" y="4.85" width="1" height="1.3" /></element> + <element ref="blackb"><bounds x="9.25" y="4.85" width="1" height="1.3" /></element> + <element ref="blackb"><bounds x="13.25" y="4.85" width="1" height="1.3" /></element> + <element ref="blackb"><bounds x="5.25" y="8.35" width="1" height="1.3" /></element> + <element ref="blackb"><bounds x="9.25" y="8.35" width="1" height="1.3" /></element> + <element ref="blackb"><bounds x="13.25" y="8.35" width="1" height="1.3" /></element> + + <element name="digitr" ref="digitr"><bounds x="5.25" y="4.85" width="1" height="1.3" /></element> + <element name="digitq" ref="digitq"><bounds x="9.25" y="4.85" width="1" height="1.3" /></element> + <element name="digitk" ref="digitk"><bounds x="13.25" y="4.85" width="1" height="1.3" /></element> + <element name="digitp" ref="digitp"><bounds x="5.25" y="8.35" width="1" height="1.3" /></element> + <element name="digitn" ref="digitn"><bounds x="9.25" y="8.35" width="1" height="1.3" /></element> + <element name="digitb" ref="digitb"><bounds x="13.25" y="8.35" width="1" height="1.3" /></element> + + <element name="digitri" ref="digitri"><bounds x="5.25" y="4.85" width="1" height="1.3" /></element> + <element name="digitqi" ref="digitqi"><bounds x="9.25" y="4.85" width="1" height="1.3" /></element> + <element name="digitki" ref="digitki"><bounds x="13.25" y="4.85" width="1" height="1.3" /></element> + <element name="digitpi" ref="digitpi"><bounds x="5.25" y="8.35" width="1" height="1.3" /></element> + <element name="digitni" ref="digitni"><bounds x="9.25" y="8.35" width="1" height="1.3" /></element> + <element name="digitbi" ref="digitbi"><bounds x="13.25" y="8.35" width="1" height="1.3" /></element> + + <element ref="brown" blend="add"><bounds x="5.25" y="4.85" width="1" height="1.3" /></element> + <element ref="brown" blend="add"><bounds x="9.25" y="4.85" width="1" height="1.3" /></element> + <element ref="brown" blend="add"><bounds x="13.25" y="4.85" width="1" height="1.3" /></element> + <element ref="brown" blend="add"><bounds x="5.25" y="8.35" width="1" height="1.3" /></element> + <element ref="brown" blend="add"><bounds x="9.25" y="8.35" width="1" height="1.3" /></element> + <element ref="brown" blend="add"><bounds x="13.25" y="8.35" width="1" height="1.3" /></element> + + <element ref="brown_nb" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="5.25" y="4.85" width="1" height="1.3" /></element> + <element ref="brown_nb" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="9.25" y="4.85" width="1" height="1.3" /></element> + <element ref="brown_nb" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="13.25" y="4.85" width="1" height="1.3" /></element> + <element ref="brown_nb" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="5.25" y="8.35" width="1" height="1.3" /></element> + <element ref="brown_nb" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="9.25" y="8.35" width="1" height="1.3" /></element> + <element ref="brown_nb" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="13.25" y="8.35" width="1" height="1.3" /></element> + + <!-- boris overlay --> + <element ref="text_boris01" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="1.0" width="3.3" height="0.8" /></element> + <element ref="text_boris02" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="0.1" width="3.3" height="1.3" /></element> + <element ref="text_boris03" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="0.1" width="3.3" height="1.3" /></element> + <element ref="text_boris04" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="0.5" width="3.3" height="1.7" /></element> + <element ref="text_boris05" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="0.7" width="3.3" height="1.3" /></element> + + <element ref="text_boris06a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.9" y="4.25" width="2.8" height="0.8" /></element> + <element ref="text_boris06b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.9" y="4.95" width="2.8" height="0.8" /></element> + <element ref="text_boris07" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_boris08" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_boris09" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_boris10" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="4.5" width="3.3" height="0.8" /></element> + + <element ref="text_boris11" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="8.0" width="3.3" height="0.8" /></element> + <element ref="text_boris12" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_boris13" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_boris14" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_boris15" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="8.0" width="3.3" height="0.8" /></element> + + <element ref="text_boris16" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="11.5" width="3.3" height="0.8" /></element> + <element ref="text_boris17" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="11.0" width="3.3" height="1.7" /></element> + <element ref="text_boris18" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="11.0" width="3.3" height="1.7" /></element> + <element ref="text_boris19" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="11.2" width="3.3" height="1.3" /></element> + <element ref="text_boris20" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="11.5" width="3.3" height="0.8" /></element> + + <!-- morphy overlay --> + <element ref="text_morphy01" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="1.0" width="3.3" height="0.8" /></element> + <element ref="text_morphy02" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="0.1" width="3.3" height="1.3" /></element> + <element ref="text_morphy03" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="0.1" width="3.3" height="1.3" /></element> + <element ref="text_morphy04" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="1.0" width="3.3" height="0.8" /></element> + <element ref="text_morphy05" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="0.7" width="3.3" height="1.3" /></element> + + <element ref="text_morphy06a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.9" y="4.25" width="2.8" height="0.8" /></element> + <element ref="text_morphy06b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.9" y="4.95" width="2.8" height="0.8" /></element> + <element ref="text_morphy07" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_morphy08" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_morphy09" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_morphy10" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="4.5" width="3.3" height="0.8" /></element> + + <element ref="text_morphy11" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="8.0" width="3.3" height="0.8" /></element> + <element ref="text_morphy12" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_morphy13" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_morphy14" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_morphy15" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="8.0" width="3.3" height="0.8" /></element> + + <element ref="text_morphy16" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="11.5" width="3.3" height="0.8" /></element> + <element ref="text_morphy17" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="11.0" width="3.3" height="1.7" /></element> + <element ref="text_morphy18" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="11.0" width="3.3" height="1.7" /></element> + <element ref="text_morphy19" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="11.2" width="3.3" height="1.3" /></element> + <element ref="text_morphy20" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="11.5" width="3.3" height="0.8" /></element> + + <!-- steinitz overlay --> + <element ref="red_s3" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="16.15" y="7.15" width="3.2" height="2.7" /></element> + <element ref="brown_s3" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="16.3" y="7.3" width="2.9" height="2.4" /></element> + + <element ref="green_s3" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="0.15" y="10.65" width="3.2" height="2.7" /></element> + <element ref="brown_s3" inputtag="IN.6" inputmask="0x0f" inputraw="1"><bounds x="0.3" y="10.8" width="2.9" height="2.4" /></element> + + <element ref="text_steinitz01a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="0.5" width="3.3" height="0.8" /></element> + <element ref="text_steinitz01b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="1.5" width="3.3" height="0.8" /></element> + <element ref="text_steinitz02" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="0.1" width="3.3" height="1.3" /></element> + <element ref="text_steinitz03" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="0.1" width="3.3" height="1.3" /></element> + <element ref="text_steinitz04a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="0.5" width="3.3" height="0.8" /></element> + <element ref="text_steinitz04b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="1.5" width="3.3" height="1.1" /></element> + <element ref="text_steinitz05" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="0.7" width="3.3" height="1.3" /></element> + + <element ref="text_steinitz06a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.9" y="3.75" width="2.8" height="0.8" /></element> + <element ref="text_steinitz06b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.9" y="4.45" width="2.8" height="0.8" /></element> + <element ref="text_steinitz06c" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="5.4" width="3.3" height="0.8" /></element> + <element ref="text_steinitz07" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_steinitz08" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_steinitz09" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="3.6" width="3.3" height="1.3" /></element> + <element ref="text_steinitz10a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="4.0" width="3.3" height="0.8" /></element> + <element ref="text_steinitz10b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="5.0" width="3.3" height="0.8" /></element> + + <element ref="text_steinitz11a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="7.5" width="3.3" height="0.8" /></element> + <element ref="text_steinitz11b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="8.5" width="3.3" height="0.8" /></element> + <element ref="text_steinitz12" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_steinitz13" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_steinitz14" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="7.1" width="3.3" height="1.3" /></element> + <element ref="text_steinitz15" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="8.0" width="3.3" height="0.8" /></element> + + <element ref="text_steinitz16" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="0.1" y="11.0" width="3.3" height="0.8" /></element> + <element ref="text_steinitz17a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="11.0" width="3.3" height="0.8" /></element> + <element ref="text_steinitz17b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="4.1" y="12.0" width="3.3" height="1.1" /></element> + <element ref="text_steinitz18a" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="10.25" width="3.3" height="1.5" /></element> + <element ref="text_steinitz18b" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="10.8" width="3.3" height="1.5" /></element> + <element ref="text_steinitz18c" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="8.1" y="12.2" width="3.3" height="0.8" /></element> + <element ref="text_steinitz19" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="12.1" y="11.2" width="3.3" height="1.3" /></element> + <element ref="text_steinitz20" inputtag="IN.6" inputmask="0x0f" inputraw="1" blend="add"><bounds x="16.1" y="11.5" width="3.3" height="0.8" /></element> + + <!-- input highlights --> + <element ref="hl" inputtag="IN.3" inputmask="0x08"><bounds x="0" y="0" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.1" inputmask="0x04"><bounds x="4" y="0" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.1" inputmask="0x08"><bounds x="8" y="0" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.1" inputmask="0x10"><bounds x="12" y="0" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.2" inputmask="0x10"><bounds x="16" y="0" width="3.5" height="3" /><color alpha="0.22" /></element> + + <element ref="hl" inputtag="IN.3" inputmask="0x02"><bounds x="0" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.0" inputmask="0x10"><bounds x="4" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.1" inputmask="0x01"><bounds x="8" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.1" inputmask="0x02"><bounds x="12" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.2" inputmask="0x08"><bounds x="16" y="3.5" width="3.5" height="3" /><color alpha="0.22" /></element> + + <element ref="hl" inputtag="IN.3" inputmask="0x04"><bounds x="0" y="7" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.0" inputmask="0x02"><bounds x="4" y="7" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.0" inputmask="0x04"><bounds x="8" y="7" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.0" inputmask="0x08"><bounds x="12" y="7" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.2" inputmask="0x04"><bounds x="16" y="7" width="3.5" height="3" /><color alpha="0.22" /></element> + + <element ref="hl" inputtag="IN.3" inputmask="0x01"><bounds x="0" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.0" inputmask="0x01"><bounds x="4" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.2" inputmask="0x01"><bounds x="8" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.2" inputmask="0x02"><bounds x="12" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></element> + <element ref="hl" inputtag="IN.3" inputmask="0x10"><bounds x="16" y="10.5" width="3.5" height="3" /><color alpha="0.22" /></element> </group> <group name="mem_switch"> @@ -264,26 +376,12 @@ <!-- build screen --> - <view name="Internal Layout, Boris 2.5"> - <bounds left="-5" right="104" top="-2" bottom="93" /> - <group ref="display"><bounds x="0" y="0" width="88" height="19" /></group> - <bezel element="black"><bounds x="-6" y="23" width="111" height="1.5" /></bezel> - - <param name="basecolor" value="brown" /> - <group ref="buttons_base"><bounds x="0" y="30" width="88" height="60.92" /></group> - <group ref="buttons_boris"><bounds x="0" y="30" width="88" height="60.92" /></group> - <group ref="buttons_click"><bounds x="0" y="30" width="88" height="60.92" /></group> - <group ref="mem_switch"><bounds x="87" y="28" width="18" height="19.2" /></group> - </view> - - <view name="Internal Layout, No Overlay"> + <view name="Internal Layout"> <bounds left="-5" right="104" top="-2" bottom="93" /> <group ref="display"><bounds x="0" y="0" width="88" height="19" /></group> <bezel element="black"><bounds x="-6" y="23" width="111" height="1.5" /></bezel> - <param name="basecolor" value="brown" /> - <group ref="buttons_base"><bounds x="0" y="30" width="88" height="60.92" /></group> - <group ref="buttons_click"><bounds x="0" y="30" width="88" height="60.92" /></group> + <group ref="buttons"><bounds x="0" y="30" width="88" height="60.92" /></group> <group ref="mem_switch"><bounds x="87" y="28" width="18" height="19.2" /></group> </view> diff --git a/src/mame/machine/archimds.cpp b/src/mame/machine/archimds.cpp index f79739dd7f7..319c963afa5 100644 --- a/src/mame/machine/archimds.cpp +++ b/src/mame/machine/archimds.cpp @@ -612,6 +612,8 @@ WRITE32_MEMBER( archimedes_state::ioc_ctrl_w ) ---- --x- I2C clock ---- ---x I2C data */ + + //m_ioc_regs[CONTROL] = data & 0x38; //if(data & 0x40) // popmessage("Muting sound, contact MAME/MESSdev"); break; @@ -839,6 +841,38 @@ WRITE32_MEMBER(archimedes_state::archimedes_ioc_w) { switch(ioc_addr & 0xfffc) { + // serial joy port (!JS application) + case 0x10: + { + // compared to RTFM they reversed bits 0-3 (or viceversa, dunno what came out first) + // for pragmatic convenience we bitswap here, but this should really be a slot option at some point. + // TODO: understand how player 2 inputs routes, related somehow to CONTROL bit 6 (cfr. blitz in SW list) + // TODO: paradr2k polls here with bit 7 and fails detection (Vertical Twist) + uint8_t cur_joy_in = bitswap<8>(m_joy[0].read_safe(0xff),7,6,5,4,0,1,2,3); + + m_joy_serial_data = (data & 0xff) ^ 0xff; + bool serial_on = false; + + if (m_joy_serial_data == 0x20) + serial_on = true; + else if (m_joy_serial_data & cur_joy_in) + serial_on = true; + + + // wants printer irq for some reason (connected on parallel?) + if (serial_on == true) + { + archimedes_request_irq_a(ARCHIMEDES_IRQA_PRINTER_BUSY); + //m_ioc_regs[CONTROL] |= 0x40; + } + else + { + archimedes_clear_irq_a(ARCHIMEDES_IRQA_PRINTER_BUSY); + //m_ioc_regs[CONTROL] &= ~0x40; + } + + return; + } case 0x18: // latch B /* ---- x--- floppy controller reset @@ -962,8 +996,8 @@ WRITE32_MEMBER(archimedes_state::archimedes_vidc_w) g = (val & 0x00f0) >> 4; r = (val & 0x000f) >> 0; - if(reg == 0x40 && val & 0xfff) - logerror("WARNING: border color write here (PC=%08x)!\n",m_maincpu->pc()); + //if(reg == 0x40 && val & 0xfff) + // logerror("WARNING: border color write here (PC=%08x)!\n",m_maincpu->pc()); m_palette->set_pen_color(reg >> 2, pal4bit(r), pal4bit(g), pal4bit(b) ); diff --git a/src/mame/nl.lst b/src/mame/nl.lst index 0b10bf7215d..06b9c762942 100644 --- a/src/mame/nl.lst +++ b/src/mame/nl.lst @@ -66,9 +66,6 @@ popeyeu // (c) 1982 popeyef // (c) 1982 popeyebl // bootleg -@source:prodigy.cpp -prodigy // ACI Destiny Prodigy, 1981 - @source:testpat.cpp tp1983 tp1985 diff --git a/src/mame/video/deco_mlc.cpp b/src/mame/video/deco_mlc.cpp index 6c60a5f6e7b..08f1c48e749 100644 --- a/src/mame/video/deco_mlc.cpp +++ b/src/mame/video/deco_mlc.cpp @@ -20,27 +20,32 @@ void deco_mlc_state::video_start() { int max_color = (0x800 / m_gfxdecode->gfx(0)->granularity()); - m_colour_mask=max_color - 1; - m_shadow_mask=max_color << 1; + m_colour_mask = max_color - 1; + m_shadow_mask = max_color | (max_color << 1); + for (int s = 0; s <= 8; s++) + { + if (BIT(m_gfxdecode->gfx(0)->granularity(), s)) + m_shadow_shift = 11 - s; + } -// temp_bitmap = std::make_unique<bitmap_rgb32>(512, 512 ); - m_buffered_spriteram = std::make_unique<uint16_t[]>(0x3000/4); - m_spriteram_spare = std::make_unique<uint16_t[]>(0x3000/4); - m_spriteram = std::make_unique<uint16_t[]>(0x3000/4); +// temp_bitmap = std::make_unique<bitmap_rgb32>(512, 512); + m_buffered_spriteram = std::make_unique<u16[]>(0x3000 / 4); + m_spriteram_spare = std::make_unique<u16[]>(0x3000 / 4); + m_spriteram = std::make_unique<u16[]>(0x3000 / 4); - save_pointer(NAME(m_spriteram), 0x3000/4); - save_pointer(NAME(m_spriteram_spare), 0x3000/4); - save_pointer(NAME(m_buffered_spriteram), 0x3000/4); + save_pointer(NAME(m_spriteram), 0x3000 / 4); + save_pointer(NAME(m_spriteram_spare), 0x3000 / 4); + save_pointer(NAME(m_buffered_spriteram), 0x3000 / 4); } -void deco_mlc_state::drawgfxzoomline(uint32_t* dest,const rectangle &clip,gfx_element *gfx, - uint32_t code1,uint32_t code2, uint32_t color,int flipx,int sx, +void deco_mlc_state::drawgfxzoomline(u32* dest, u8* pri,const rectangle &clip,gfx_element *gfx, + u32 code1,u32 code2, u32 color,int flipx,int sx, int transparent_color,int use8bpp, - int scalex, int alpha, int srcline, int shadowMode, int alphaMode ) + int scalex, int srcline, int shadowMode ) { if (!scalex) return; - uint32_t shadowval = shadowMode ? 0xffffffff : 0; + const u32 alphaMode = m_irq_ram[0x04 / 4] & 0xc0; /* scalex and scaley are 16.16 fixed point numbers @@ -51,22 +56,21 @@ void deco_mlc_state::drawgfxzoomline(uint32_t* dest,const rectangle &clip,gfx_el /* KW 991012 -- Added code to force clip to bitmap boundary */ + const int sprite_screen_width = (scalex * 16 + (sx & 0xffff)) >> 16; - int sprite_screen_width = (scalex*16+(sx&0xffff))>>16; - - sx>>=16; + sx >>= 16; if (sprite_screen_width) { /* compute sprite increment per screen pixel */ - int dx = (16<<16)/sprite_screen_width; + int dx = (16 << 16) / sprite_screen_width; - int ex = sx+sprite_screen_width; + int ex = sx + sprite_screen_width; int x_index_base; - if( flipx ) + if (flipx) { - x_index_base = (sprite_screen_width-1)*dx; + x_index_base = (sprite_screen_width - 1) * dx; dx = -dx; } else @@ -74,53 +78,61 @@ void deco_mlc_state::drawgfxzoomline(uint32_t* dest,const rectangle &clip,gfx_el x_index_base = 0; } - if( sx < clip.left()) + if (sx < clip.left()) { /* clip left */ - int pixels = clip.left()-sx; + int pixels = clip.left() - sx; sx += pixels; - x_index_base += pixels*dx; + x_index_base += pixels * dx; } /* NS 980211 - fixed incorrect clipping */ - if( ex > clip.right()+1 ) + if (ex > clip.right() + 1) { /* clip right */ - int pixels = ex-clip.right()-1; + int pixels = ex-clip.right() - 1; ex -= pixels; } - if( ex>sx ) + if (ex>sx) { /* skip if inner loop doesn't draw anything */ const pen_t *pal = &m_palette->pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors())); - const uint8_t *code_base1 = gfx->get_data(code1 % gfx->elements()); - const uint8_t *code_base2 = gfx->get_data(code2 % gfx->elements()); - const uint8_t *source1 = code_base1 + (srcline) * gfx->rowbytes(); - const uint8_t *source2 = code_base2 + (srcline) * gfx->rowbytes(); - /* no alpha */ - if ((alpha == 0xff) && (!shadowMode)) - { + const u8 *code_base1 = gfx->get_data(code1 % gfx->elements()); + const u8 *code_base2 = gfx->get_data(code2 % gfx->elements()); + const u8 *source1 = code_base1 + (srcline) * gfx->rowbytes(); + const u8 *source2 = code_base2 + (srcline) * gfx->rowbytes(); + // alphaMode & 0xc0 = 0xc0 : Shadow, 0 : Alpha or Pre-shadowed, Other bits unknown + if (shadowMode && (alphaMode & 0xc0)) + { /* TODO : 8bpp and shadow can use simultaneously? */ int x, x_index = x_index_base; - - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - int c = source1[x_index>>16]; - if (use8bpp) - c=(c<<4)|source2[x_index>>16]; - - if( c != transparent_color ) dest[x] = pal[c]; + if (!(pri[x] & 0x80)) + { + int c = source1[x_index >> 16]; + if (use8bpp) + c = (c << 4) | source2[x_index >> 16]; + if (c != transparent_color) + pri[x] |= shadowMode; // Mark it shadow / hilighted + } x_index += dx; } } else - { /* TODO : 8bpp and alpha can use simultaneously? */ + { int x, x_index = x_index_base; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - int c = source1[x_index>>16]; - if (use8bpp) - c=(c<<4)|source2[x_index>>16]; - - // alphaMode & 0xc0 = 0xc0 : Shadow, 0 : Alpha, Other bits unknown - if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], (alphaMode & 0xc0) ? shadowval : pal[c], shadowMode ? 0x80 : alpha); + if (!(pri[x] & 0x80)) + { + int c = source1[x_index >> 16]; + if (use8bpp) + c = (c << 4) | source2[x_index >> 16]; + + if (c != transparent_color) + { + dest[x] = pal[c]; + pri[x] |= 0x80 | shadowMode; // Mark it drawn + } + } x_index += dx; } } @@ -129,34 +141,29 @@ void deco_mlc_state::drawgfxzoomline(uint32_t* dest,const rectangle &clip,gfx_el } -void deco_mlc_state::draw_sprites( const rectangle &cliprect, int scanline, uint32_t* dest) +void deco_mlc_state::draw_sprites(const rectangle &cliprect, int scanline, u32* dest, u8* pri) { - uint32_t *index_ptr=nullptr; - int offs,fx=0,fy=0,x,y,color,colorOffset,sprite,indx,h,w,bx,by,fx1,fy1; + u32 *index_ptr = nullptr; + int sprite,h,w,fx1,fy1; int xoffs,yoffs; - uint8_t *rom = m_gfx2 + 0x20000, *index_ptr8; - uint8_t *rawrom = m_gfx2; - int blockIsTilemapIndex=0; - int sprite2=0,indx2=0,use8bppMode=0; - int yscale,xscale; - int alpha; - int useIndicesInRom=0; - int hibits=0; - int tileFormat=0; - int rasterMode=0; - int shadowMode=0; - - int clipper=0; + const u8 *rom = m_gfx2 + 0x20000, *index_ptr8; + const u8 *rawrom = m_gfx2; + int blockIsTilemapIndex = 0; + int sprite2 = 0,indx2 = 0,use8bppMode = 0; + int useIndicesInRom = 0; + int hibits = 0; + int tileFormat = 0; + rectangle user_clip; - uint16_t* spriteram=m_buffered_spriteram.get(); + const u16* spriteram = m_buffered_spriteram.get(); //printf("%d - (%08x %08x %08x) (%08x %08x %08x) (%08x %08x %08x)\n", scanline, m_irq_ram[6], m_irq_ram[7], m_irq_ram[8], m_irq_ram[9], m_irq_ram[10], m_irq_ram[11] , m_irq_ram[12] , m_irq_ram[13] , m_irq_ram[14]); - for (offs = (0x3000/4)-8; offs>=0; offs-=8) + for (int offs = 0; offs < (0x3000 / 4); offs += 8) { - if ((spriteram[offs+0]&0x8000)==0) + if ((spriteram[offs + 0] & 0x8000) == 0) continue; - if ((spriteram[offs+1]&0x2000) && (m_screen->frame_number() & 1)) + if ((spriteram[offs + 1] & 0x2000) && (m_screen->frame_number() & 1)) continue; /* @@ -198,18 +205,17 @@ void deco_mlc_state::draw_sprites( const rectangle &cliprect, int scanline, uint Word 3: 0xffff - Low-bits of tile index */ - y = spriteram[offs+2]&0x7ff; - x = spriteram[offs+3]&0x7ff; + int y = spriteram[offs + 2] & 0x7ff; + int x = spriteram[offs + 3] & 0x7ff; - if (x&0x400) x=-(0x400-(x&0x3ff)); - if (y&0x400) y=-(0x400-(y&0x3ff)); + if (x & 0x400) x = -(0x400 - (x & 0x3ff)); + if (y & 0x400) y = -(0x400 - (y & 0x3ff)); - fx = spriteram[offs+1]&0x8000; - fy = spriteram[offs+1]&0x4000; - color = spriteram[offs+1]&0xff; - - int raster_select = (spriteram[offs+1]&0x0180)>>7; + int fx = spriteram[offs + 1] & 0x8000; + int fy = spriteram[offs + 1] & 0x4000; + int color = spriteram[offs + 1] & 0xff; + const int raster_select = (spriteram[offs + 1] & 0x0180)>>7; // there are 3 different sets of raster values, must be a way to selects // between them? furthermore avengrgs doesn't even enable this @@ -220,124 +226,123 @@ void deco_mlc_state::draw_sprites( const rectangle &cliprect, int scanline, uint // have the scroll effect applied to them. all clip windows are the same // so there is no reason to select a clip window other than to be using it // to select a set of raster-set scroll regs? - rasterMode = (spriteram[offs+1]>>10)&0x1; - + int rasterMode = (spriteram[offs + 1] >> 10) & 0x1; - clipper = (spriteram[offs+1]>>8)&0x3; + int clipper = (spriteram[offs + 1] >> 8) & 0x3; - indx = spriteram[offs+0]&0x3fff; - yscale = spriteram[offs+4]&0x3ff; - xscale = spriteram[offs+5]&0x3ff; - colorOffset = 0; + int indx = spriteram[offs + 0] & 0x3fff; + int yscale = spriteram[offs + 4] & 0x3ff; + int xscale = spriteram[offs + 5] & 0x3ff; + int colorOffset = 0; /* Clip windows - this mapping seems odd, but is correct for Skull Fang and StadHr96, however there are space for 8 clipping windows, where is the high bit? (Or is it ~0x400?) */ - clipper=((clipper&2)>>1)|((clipper&1)<<1); // Swap low two bits - + clipper = ((clipper & 2) >> 1) | ((clipper & 1) << 1); // Swap low two bits - int upperclip = (spriteram[offs+1]>>10)&0x2; + int upperclip = (spriteram[offs + 1] >> 10) & 0x2; // this is used on some ingame gfx in stadhr96 // to clip the images of your guys on the bases if (upperclip) clipper |= 0x4; + int min_y = m_clip_ram[(clipper * 4) + 0]; + int max_y = m_clip_ram[(clipper * 4) + 1]; - int min_y = m_clip_ram[(clipper*4)+0]; - int max_y = m_clip_ram[(clipper*4)+1]; - - if ((scanline<min_y) || (scanline>max_y)) + if ((scanline < min_y) || (scanline > max_y)) continue; - - user_clip.setx(m_clip_ram[(clipper*4)+2], m_clip_ram[(clipper*4)+3]); + user_clip.setx(m_clip_ram[(clipper * 4) + 2], m_clip_ram[(clipper * 4) + 3]); user_clip &= cliprect; /* Any colours out of range (for the bpp value) trigger 'shadow' mode */ - shadowMode = (color & (m_shadow_mask)) ? 1 : 0; // shadow mode (OK for skullfng) - if ((color & (m_colour_mask+1)) || (shadowMode)) - alpha=0x80; - else - alpha=0xff; + int shadowMode = (color & m_shadow_mask) >> m_shadow_shift; // shadow mode (OK for skullfng) - color&=m_colour_mask; + color &= m_colour_mask; /* If this bit is set, combine this block with the next one */ - if (spriteram[offs+1]&0x1000) { - use8bppMode=1; + if (spriteram[offs + 1] & 0x1000) + { + use8bppMode = 1; /* In 8bpp the palette base is stored in the next block */ - if (offs-8>=0) { - color = (spriteram[offs+1-8]&0x7f); - indx2 = spriteram[offs+0-8]&0x3fff; + if (offs - 8 >= 0) + { + color = (spriteram[offs + 1 - 8] & 0x7f); + indx2 = spriteram[offs + 0 - 8] & 0x3fff; } - } else - use8bppMode=0; + } + else + use8bppMode = 0; - /* Lookup tiles/size in sprite index ram OR in the lookup rom */ - if (spriteram[offs+0]&0x4000) { - index_ptr8=rom + indx*8; /* Byte ptr */ - h=(index_ptr8[1]>>0)&0xf; - w=(index_ptr8[3]>>0)&0xf; + /* Lookup tiles / size in sprite index ram OR in the lookup rom */ + if (spriteram[offs + 0] & 0x4000) + { + index_ptr8 = rom + indx * 8; /* Byte ptr */ + h = (index_ptr8[1] >> 0) & 0xf; + w = (index_ptr8[3] >> 0) & 0xf; - if (!h) h=16; - if (!w) w=16; + if (!h) h = 16; + if (!w) w = 16; - sprite = (index_ptr8[7]<<8)|index_ptr8[6]; - sprite |= (index_ptr8[4]&3)<<16; + sprite = (index_ptr8[7] << 8) | index_ptr8[6]; + sprite |= (index_ptr8[4] & 3) << 16; - if (use8bppMode) { - uint8_t* index_ptr28=rom + indx2*8; - sprite2=(index_ptr28[7]<<8)|index_ptr28[6]; + if (use8bppMode) + { + const u8* index_ptr28 = rom + indx2 * 8; + sprite2 = (index_ptr28[7] << 8) | index_ptr28[6]; } //unused byte 5 - yoffs=index_ptr8[0]&0xff; - xoffs=index_ptr8[2]&0xff; + yoffs = index_ptr8[0] & 0xff; + xoffs = index_ptr8[2] & 0xff; - fy1=(index_ptr8[1]&0x10)>>4; - fx1=(index_ptr8[3]&0x10)>>4; + fy1 = (index_ptr8[1] & 0x10) >> 4; + fx1 = (index_ptr8[3] & 0x10) >> 4; - tileFormat=index_ptr8[4]&0x80; + tileFormat = index_ptr8[4] & 0x80; - if (index_ptr8[4]&0xc0) - blockIsTilemapIndex=1; + if (index_ptr8[4] & 0xc0) + blockIsTilemapIndex = 1; else - blockIsTilemapIndex=0; + blockIsTilemapIndex = 0; - useIndicesInRom=0; - - } else { - indx&=0x1fff; - index_ptr=m_vram + indx*4; - h=(index_ptr[0]>>8)&0xf; - w=(index_ptr[1]>>8)&0xf; + useIndicesInRom = 0; + } + else + { + indx &= 0x1fff; + index_ptr = m_vram + indx * 4; + h = (index_ptr[0] >> 8) & 0xf; + w = (index_ptr[1] >> 8) & 0xf; - if (!h) h=16; - if (!w) w=16; + if (!h) h = 16; + if (!w) w = 16; - if (use8bppMode) { - uint32_t* index_ptr2=m_vram + ((indx2*4)&0x7fff); - sprite2=((index_ptr2[2]&0x3)<<16) | (index_ptr2[3]&0xffff); + if (use8bppMode) + { + u32* index_ptr2 = m_vram + ((indx2 * 4) & 0x7fff); + sprite2 = ((index_ptr2[2] & 0x3) << 16) | (index_ptr2[3] & 0xffff); } - sprite = ((index_ptr[2]&0x3)<<16) | (index_ptr[3]&0xffff); - if (index_ptr[2]&0xc0) - blockIsTilemapIndex=1; + sprite = ((index_ptr[2] & 0x3) << 16) | (index_ptr[3] & 0xffff); + if (index_ptr[2] & 0xc0) + blockIsTilemapIndex = 1; else - blockIsTilemapIndex=0; + blockIsTilemapIndex = 0; - tileFormat=index_ptr[2]&0x80; + tileFormat = index_ptr[2] & 0x80; - hibits=(index_ptr[2]&0x3c)<<10; - useIndicesInRom=index_ptr[2]&3; + hibits = (index_ptr[2] & 0x3c) << 10; + useIndicesInRom = index_ptr[2] & 3; - yoffs=index_ptr[0]&0xff; - xoffs=index_ptr[1]&0xff; + yoffs = index_ptr[0] & 0xff; + xoffs = index_ptr[1] & 0xff; - fy1=(index_ptr[0]&0x1000)>>12; - fx1=(index_ptr[1]&0x1000)>>12; + fy1 = (index_ptr[0] & 0x1000) >> 12; + fx1 = (index_ptr[1] & 0x1000) >> 12; } - if(fx1) fx^=0x8000; - if(fy1) fy^=0x4000; + if (fx1) fx ^= 0x8000; + if (fy1) fy ^= 0x4000; int extra_x_scale = 0x100; @@ -358,164 +363,161 @@ void deco_mlc_state::draw_sprites( const rectangle &cliprect, int scanline, uint // YYY = duplicate bits of yyy? // ZZZ = (sometimes) duplicate bits of zzz - if (raster_select==1 || raster_select==2 || raster_select==3) + if (raster_select == 1 || raster_select == 2 || raster_select == 3) { - shadowMode = 0; // TODO : Raster enable and shadow mode can't use simultaneously? + //shadowMode = 0; // TODO : Raster enable and shadow mode can use simultaneously? int irq_base_reg; /* 6, 9, 12 are possible */ - if (raster_select== 1) irq_base_reg = 6; // OK upper screen.. left? - else if (raster_select== 2) irq_base_reg = 9; // OK upper screen.. main / center + if (raster_select == 1) irq_base_reg = 6; // OK upper screen.. left? + else if (raster_select == 2) irq_base_reg = 9; // OK upper screen.. main / center else irq_base_reg = 12; - int extra_y_off = m_irq_ram[irq_base_reg+0] & 0x7ff; - int extra_x_off = m_irq_ram[irq_base_reg+1] & 0x7ff; - extra_x_scale = (m_irq_ram[irq_base_reg+2]>>0) & 0x3ff; + int extra_y_off = m_irq_ram[irq_base_reg + 0] & 0x7ff; + int extra_x_off = m_irq_ram[irq_base_reg + 1] & 0x7ff; + extra_x_scale = (m_irq_ram[irq_base_reg + 2] >> 0) & 0x3ff; if (extra_x_off & 0x400) { extra_x_off -= 0x800; } if (extra_y_off & 0x400) { extra_y_off -= 0x800; } - x += extra_x_off; y += extra_y_off; } - else if (raster_select==0x0) + else if (raster_select == 0x0) { // possibly disabled? } } + const int yscale_frac = (yscale << 8); + const int real_h = h * 16; + xscale *= extra_x_scale; - int ybase=y<<16; - int yinc=(yscale<<8)*16; + int ybase = y << 16; + const int yinc = yscale_frac * 16; if (fy) - ybase+=(yoffs-15) * (yscale<<8) - ((h-1)*yinc); + ybase += (yoffs - 15) * yscale_frac - ((h - 1) * yinc); else - ybase-=yoffs * (yscale<<8); + ybase -= yoffs * yscale_frac; - int xbase=x<<16; - int xinc=(xscale)*16; + int xbase = x << 16; + const int xinc = xscale * 16; if (fx) - xbase+=(xoffs-15) * (xscale) - ((w-1)*xinc); + xbase += (xoffs - 15) * xscale - ((w - 1) * xinc); else - xbase-=xoffs * (xscale); - - - int full_realybase = ybase; - int full_sprite_screen_height = ((yscale<<8)*(h*16)+(0)); - int full_sprite_screen_height_unscaled = ((1)*(h*16)+(0)); - + xbase -= xoffs * xscale; + const int full_realybase = ybase; + const int full_sprite_screen_height = (yscale_frac * real_h + 0); + const int full_sprite_screen_height_unscaled = (1 * real_h + 0); if (!full_sprite_screen_height_unscaled) continue; - - int ratio = full_sprite_screen_height / full_sprite_screen_height_unscaled; + const int ratio = full_sprite_screen_height / full_sprite_screen_height_unscaled; if (!ratio) continue; - int bby = scanline - (full_realybase>>16); + const int bby = scanline - (full_realybase >> 16); if (bby < 0) continue; - if (bby >= full_sprite_screen_height>>16) + if (bby >= full_sprite_screen_height >> 16) continue; - - // color = machine().rand(); - int srcline = ((bby<<16) / ratio); - - by = srcline >> 4; + int srcline = ((bby << 16) / ratio); + const int by = srcline >> 4; - srcline &=0xf; - if( fy ) + srcline &= 0xf; + if (fy) { srcline = 15 - srcline; } - - for (bx=0; bx<w; bx++) { - int realxbase = xbase + bx * xinc; + for (int bx = 0; bx < w; bx++) + { + const int realxbase = xbase + bx * xinc; int count = 0; if (fx) { if (fy) - count = (h-1-by) * w + (w-1-bx); + count = (h - 1 - by) * w + (w - 1 - bx); else - count = by * w + (w-1-bx); + count = by * w + (w - 1 - bx); } else { if (fy) - count = (h-1-by) * w + bx; + count = (h - 1 - by) * w + bx; else count = by * w + bx; } - int tile=sprite + count; - int tile2=sprite2 + count; + int tile = sprite + count; + int tile2 = sprite2 + count; - if (blockIsTilemapIndex) { + if (blockIsTilemapIndex) + { if (useIndicesInRom) { - const uint8_t* ptr=rawrom+(tile*2); - tile=(*ptr) + ((*(ptr+1))<<8); + const u8* ptr = rawrom + (tile * 2); + tile = (*ptr) + ((*(ptr + 1)) << 8); - if (use8bppMode) { - const uint8_t* ptr2=rawrom+(tile2*2); - tile2=(*ptr2) + ((*(ptr2+1))<<8); + if (use8bppMode) + { + const u8* ptr2 = rawrom + (tile2 * 2); + tile2 = (*ptr2) + ((*(ptr2 + 1)) << 8); } else { - tile2=0; + tile2 = 0; } if (tileFormat) { - colorOffset=(tile&0xf000)>>12; - tile=(tile&0x0fff)|hibits; - tile2=(tile2&0x0fff)|hibits; + colorOffset = (tile & 0xf000) >> 12; + tile = (tile & 0x0fff) | hibits; + tile2 = (tile2 & 0x0fff) | hibits; } else { - colorOffset=0; - tile=(tile&0xffff)|(hibits<<2); - tile2=(tile2&0xffff)|(hibits<<2); + colorOffset = 0; + tile = (tile & 0xffff) | (hibits << 2); + tile2 = (tile2 & 0xffff) | (hibits << 2); } } else { - const uint32_t* ptr=m_vram + ((tile)&0x7fff); - tile=(*ptr)&0xffff; + const u32* ptr = m_vram + (tile & 0x7fff); + tile = (*ptr) & 0xffff; if (tileFormat) { - colorOffset=(tile&0xf000)>>12; - tile=(tile&0x0fff)|hibits; + colorOffset = (tile & 0xf000) >> 12; + tile = (tile & 0x0fff) | hibits; } else { - colorOffset=0; - tile=(tile&0xffff)|(hibits<<2); + colorOffset = 0; + tile = (tile & 0xffff) | (hibits << 2); } - tile2=0; + tile2 = 0; } } - drawgfxzoomline(dest,user_clip,m_gfxdecode->gfx(0), + drawgfxzoomline(dest,pri,user_clip,m_gfxdecode->gfx(0), tile,tile2, color + colorOffset,fx,realxbase, 0, - use8bppMode,(xscale),alpha, srcline, - shadowMode, m_irq_ram[0x04/4]); + use8bppMode,xscale, srcline, + shadowMode); } @@ -534,28 +536,44 @@ WRITE_LINE_MEMBER(deco_mlc_state::screen_vblank_mlc) lookup table. Without buffering incorrect one frame glitches are seen in several places, especially in Hoops. */ - std::copy(&m_spriteram[0], &m_spriteram[0x3000/4], &m_buffered_spriteram[0]); + std::copy(&m_spriteram[0], &m_spriteram[0x3000 / 4], &m_buffered_spriteram[0]); } } -uint32_t deco_mlc_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +u32 deco_mlc_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { // temp_bitmap->fill(0, cliprect); + screen.priority().fill(0, cliprect); bitmap.fill(m_palette->pen(0), cliprect); /* Pen 0 fill colour confirmed from Skull Fang level 2 */ - for (int i=cliprect.top();i<=cliprect.bottom();i++) + for (int i = cliprect.top(); i <= cliprect.bottom(); i++) { - uint32_t *dest = &bitmap.pix32(i); + u32 *dest = &bitmap.pix32(i); + u8 *pri = &screen.priority().pix8(i); /* printf("%d -", i); - for (int j=0;j<0x20;j++) + for (int j = 0; j < 0x20; j++) { printf("%08x, ",m_irq_ram[j]); } printf("\n"); */ - draw_sprites(cliprect, i, dest); + draw_sprites(cliprect, i, dest, pri); + for (int x = cliprect.left(); x <= cliprect.right(); x++) + { + u32 col = dest[x]; + const u8 shadow_flag = pri[x] & 3; + if ((shadow_flag & 3) && (shadow_flag != 3)) + { + if (shadow_flag & 1) // shadow + col = (col & 0xff000000) | ((col & 0xfefefe) >> 1); + else if (shadow_flag & 2) // hilight + col = (col & 0xff000000) | ((col & 0xfefefe) >> 1) | 0x808080; + + dest[x] = col; + } + } } return 0; } diff --git a/src/mame/video/exidy440.cpp b/src/mame/video/exidy440.cpp index c3a09628098..57ad8a06d80 100644 --- a/src/mame/video/exidy440.cpp +++ b/src/mame/video/exidy440.cpp @@ -462,7 +462,7 @@ uint32_t topsecex_state::screen_update_topsecex(screen_device &screen, bitmap_in void exidy440_state::exidy440_video(machine_config &config) { - PALETTE(config, m_palette). set_entries(256); + PALETTE(config, m_palette).set_entries(512); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_video_attributes(VIDEO_ALWAYS_UPDATE); diff --git a/src/mame/video/midzeus.cpp b/src/mame/video/midzeus.cpp index 6032119a7bd..5e069383921 100644 --- a/src/mame/video/midzeus.cpp +++ b/src/mame/video/midzeus.cpp @@ -8,7 +8,6 @@ #include "emu.h" #include "includes/midzeus.h" -#include "video/poly.h" #include "video/rgbutil.h" @@ -39,77 +38,6 @@ /************************************* * - * Type definitions - * - *************************************/ - -struct mz_poly_extra_data -{ - const void * palbase; - const void * texbase; - uint16_t solidcolor; - uint16_t voffset; - int16_t zoffset; - uint16_t transcolor; - uint16_t texwidth; - uint16_t color; - uint32_t alpha; - uint32_t ctrl_word; - bool blend_enable; - bool depth_test_enable; - bool depth_write_enable; - uint32_t blend; - uint8_t (*get_texel)(const void *, int, int, int); -}; - - -class midzeus_renderer : public poly_manager<float, mz_poly_extra_data, 4, 10000> -{ -public: - midzeus_renderer(midzeus_state &state); - - void render_poly(int32_t scanline, const extent_t& extent, const mz_poly_extra_data& object, int threadid); - void render_poly_solid_fixedz(int32_t scanline, const extent_t& extent, const mz_poly_extra_data& object, int threadid); - - void zeus_draw_quad(int long_fmt, const uint32_t *databuffer, uint32_t texdata, bool logit); - void zeus_draw_debug_quad(const rectangle& rect, const vertex_t* vert); - -private: - midzeus_state& m_state; -}; - -typedef midzeus_renderer::vertex_t poly_vertex; - - -/************************************* - * - * Global variables - * - *************************************/ - -static midzeus_renderer *poly; -static uint8_t log_fifo; - -static uint32_t zeus_fifo[20]; -static uint8_t zeus_fifo_words; -static int16_t zeus_matrix[3][3]; -static int32_t zeus_point[3]; -static int16_t zeus_light[3]; -static void *zeus_renderbase; -static uint32_t zeus_palbase; -static uint32_t zeus_unkbase; -static int zeus_enable_logging; -static uint32_t zeus_objdata; -static rectangle zeus_cliprect; - -static uint32_t *waveram[2]; -static int yoffs; -static int texel_width; -static int is_mk4b; - - -/************************************* - * * Function prototypes * *************************************/ @@ -126,8 +54,8 @@ static inline uint8_t get_texel_alt_8bit(const void *base, int y, int x, int wid * *************************************/ -#define WAVERAM_BLOCK0(blocknum) ((void *)((uint8_t *)waveram[0] + 8 * (blocknum))) -#define WAVERAM_BLOCK1(blocknum) ((void *)((uint8_t *)waveram[1] + 8 * (blocknum))) +#define WAVERAM_BLOCK0(blocknum) ((void *)((uint8_t *)m_waveram[0].get() + 8 * (blocknum))) +#define WAVERAM_BLOCK1(blocknum) ((void *)((uint8_t *)m_waveram[1].get() + 8 * (blocknum))) #define WAVERAM_PTR8(base, bytenum) ((uint8_t *)(base) + BYTE4_XOR_LE(bytenum)) #define WAVERAM_READ8(base, bytenum) (*WAVERAM_PTR8(base, bytenum)) @@ -160,25 +88,25 @@ static inline uint8_t get_texel_alt_8bit(const void *base, int y, int x, int wid * *************************************/ -static inline void *waveram0_ptr_from_block_addr(uint32_t addr) +inline void *midzeus_state::waveram0_ptr_from_block_addr(uint32_t addr) { uint32_t blocknum = (addr % WAVERAM0_WIDTH) + ((addr >> 12) % WAVERAM0_HEIGHT) * WAVERAM0_WIDTH; return WAVERAM_BLOCK0(blocknum); } -static inline void *waveram0_ptr_from_expanded_addr(uint32_t addr) +inline void *midzeus_state::waveram0_ptr_from_expanded_addr(uint32_t addr) { uint32_t blocknum = (addr % WAVERAM0_WIDTH) + ((addr >> 16) % WAVERAM0_HEIGHT) * WAVERAM0_WIDTH; return WAVERAM_BLOCK0(blocknum); } -static inline void *waveram1_ptr_from_expanded_addr(uint32_t addr) +inline void *midzeus_state::waveram1_ptr_from_expanded_addr(uint32_t addr) { uint32_t blocknum = (addr % WAVERAM1_WIDTH) + ((addr >> 16) % WAVERAM1_HEIGHT) * WAVERAM1_WIDTH; return WAVERAM_BLOCK1(blocknum); } -static inline void *waveram0_ptr_from_texture_addr(uint32_t addr, int width) +inline void *midzeus_state::waveram0_ptr_from_texture_addr(uint32_t addr, int width) { uint32_t blocknum = (((addr & ~1) * width) / 8) % (WAVERAM0_WIDTH * WAVERAM0_HEIGHT); return WAVERAM_BLOCK0(blocknum); @@ -192,42 +120,42 @@ static inline void *waveram0_ptr_from_texture_addr(uint32_t addr, int width) * *************************************/ -static inline void waveram_plot_depth(int y, int x, uint16_t color, uint16_t depth) +inline void midzeus_state::waveram_plot_depth(int y, int x, uint16_t color, uint16_t depth) { - if (zeus_cliprect.contains(x, y)) + if (m_zeus_cliprect.contains(x, y)) { - WAVERAM_WRITEPIX(zeus_renderbase, y, x, color); - WAVERAM_WRITEDEPTH(zeus_renderbase, y, x, depth); + WAVERAM_WRITEPIX(m_zeus_renderbase, y, x, color); + WAVERAM_WRITEDEPTH(m_zeus_renderbase, y, x, depth); } } #ifdef UNUSED_FUNCTION -static inline void waveram_plot(int y, int x, uint16_t color) +inline void midzeus_state::waveram_plot(int y, int x, uint16_t color) { - if (zeus_cliprect.contains(x, y)) - WAVERAM_WRITEPIX(zeus_renderbase, y, x, color); + if (m_zeus_cliprect.contains(x, y)) + WAVERAM_WRITEPIX(m_zeus_renderbase, y, x, color); } -static inline void waveram_plot_check_depth(int y, int x, uint16_t color, uint16_t depth) +inline void midzeus_state::waveram_plot_check_depth(int y, int x, uint16_t color, uint16_t depth) { - if (zeus_cliprect.contains(x, y)) + if (m_zeus_cliprect.contains(x, y)) { - uint16_t *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x); + uint16_t *depthptr = WAVERAM_PTRDEPTH(m_zeus_renderbase, y, x); if (depth <= *depthptr) { - WAVERAM_WRITEPIX(zeus_renderbase, y, x, color); + WAVERAM_WRITEPIX(m_zeus_renderbase, y, x, color); *depthptr = depth; } } } -static inline void waveram_plot_check_depth_nowrite(int y, int x, uint16_t color, uint16_t depth) +inline void midzeus_state::waveram_plot_check_depth_nowrite(int y, int x, uint16_t color, uint16_t depth) { - if (zeus_cliprect.contains(x, y)) + if (m_zeus_cliprect.contains(x, y)) { - uint16_t *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, y, x); + uint16_t *depthptr = WAVERAM_PTRDEPTH(m_zeus_renderbase, y, x); if (depth <= *depthptr) - WAVERAM_WRITEPIX(zeus_renderbase, y, x, color); + WAVERAM_WRITEPIX(m_zeus_renderbase, y, x, color); } } #endif @@ -281,40 +209,40 @@ VIDEO_START_MEMBER(midzeus_state,midzeus) int i; /* allocate memory for "wave" RAM */ - waveram[0] = auto_alloc_array(machine(), uint32_t, WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8/4); - waveram[1] = auto_alloc_array(machine(), uint32_t, WAVERAM1_WIDTH * WAVERAM1_HEIGHT * 8/4); + m_waveram[0] = std::make_unique<uint32_t[]>(WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8/4); + m_waveram[1] = std::make_unique<uint32_t[]>(WAVERAM1_WIDTH * WAVERAM1_HEIGHT * 8/4); /* initialize a 5-5-5 palette */ for (i = 0; i < 32768; i++) m_palette->set_pen_color(i, pal5bit(i >> 10), pal5bit(i >> 5), pal5bit(i >> 0)); /* initialize polygon engine */ - poly = auto_alloc(machine(), midzeus_renderer(*this)); + m_poly = std::make_unique<midzeus_renderer>(*this); /* we need to cleanup on exit */ machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&midzeus_state::exit_handler, this)); - yoffs = 0; - texel_width = 256; - zeus_renderbase = waveram[1]; + m_yoffs = 0; + m_texel_width = 256; + m_zeus_renderbase = m_waveram[1].get(); /* state saving */ - save_item(NAME(zeus_fifo)); - save_item(NAME(zeus_fifo_words)); - save_item(NAME(zeus_matrix)); - save_item(NAME(zeus_point)); - save_item(NAME(zeus_light)); - save_item(NAME(zeus_palbase)); - save_item(NAME(zeus_objdata)); - save_item(NAME(zeus_cliprect.min_x)); - save_item(NAME(zeus_cliprect.max_x)); - save_item(NAME(zeus_cliprect.min_y)); - save_item(NAME(zeus_cliprect.max_y)); - save_pointer(NAME(waveram[0]), WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8 / sizeof(waveram[0][0])); - save_pointer(NAME(waveram[1]), WAVERAM1_WIDTH * WAVERAM1_HEIGHT * 8 / sizeof(waveram[1][0])); + save_item(NAME(m_zeus_fifo)); + save_item(NAME(m_zeus_fifo_words)); + save_item(NAME(m_zeus_matrix)); + save_item(NAME(m_zeus_point)); + save_item(NAME(m_zeus_light)); + save_item(NAME(m_zeus_palbase)); + save_item(NAME(m_zeus_objdata)); + save_item(NAME(m_zeus_cliprect.min_x)); + save_item(NAME(m_zeus_cliprect.max_x)); + save_item(NAME(m_zeus_cliprect.min_y)); + save_item(NAME(m_zeus_cliprect.max_y)); + save_pointer(NAME(m_waveram[0]), WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8 / sizeof(m_waveram[0][0])); + save_pointer(NAME(m_waveram[1]), WAVERAM1_WIDTH * WAVERAM1_HEIGHT * 8 / sizeof(m_waveram[1][0])); /* hack */ - is_mk4b = strcmp(machine().system().name, "mk4b") == 0; + m_is_mk4b = strcmp(machine().system().name, "mk4b") == 0; } @@ -348,7 +276,7 @@ uint32_t midzeus_state::screen_update_midzeus(screen_device &screen, bitmap_ind1 { int x, y; - poly->wait("VIDEO_UPDATE"); + m_poly->wait("VIDEO_UPDATE"); /* normal update case */ if (!machine().input().code_pressed(KEYCODE_V)) @@ -368,24 +296,24 @@ uint32_t midzeus_state::screen_update_midzeus(screen_device &screen, bitmap_ind1 { const void *base; - if (machine().input().code_pressed(KEYCODE_DOWN)) yoffs += machine().input().code_pressed(KEYCODE_LSHIFT) ? 0x40 : 1; - if (machine().input().code_pressed(KEYCODE_UP)) yoffs -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 0x40 : 1; - if (machine().input().code_pressed(KEYCODE_LEFT) && texel_width > 4) { texel_width >>= 1; while (machine().input().code_pressed(KEYCODE_LEFT)) ; } - if (machine().input().code_pressed(KEYCODE_RIGHT) && texel_width < 512) { texel_width <<= 1; while (machine().input().code_pressed(KEYCODE_RIGHT)) ; } + if (machine().input().code_pressed(KEYCODE_DOWN)) m_yoffs += machine().input().code_pressed(KEYCODE_LSHIFT) ? 0x40 : 1; + if (machine().input().code_pressed(KEYCODE_UP)) m_yoffs -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 0x40 : 1; + if (machine().input().code_pressed(KEYCODE_LEFT) && m_texel_width > 4) { m_texel_width >>= 1; while (machine().input().code_pressed(KEYCODE_LEFT)) ; } + if (machine().input().code_pressed(KEYCODE_RIGHT) && m_texel_width < 512) { m_texel_width <<= 1; while (machine().input().code_pressed(KEYCODE_RIGHT)) ; } - if (yoffs < 0) yoffs = 0; - base = waveram0_ptr_from_block_addr(yoffs << 12); + if (m_yoffs < 0) m_yoffs = 0; + base = waveram0_ptr_from_block_addr(m_yoffs << 12); for (y = cliprect.min_y; y <= cliprect.max_y; y++) { uint16_t *dest = &bitmap.pix16(y); for (x = cliprect.min_x; x <= cliprect.max_x; x++) { - uint8_t tex = get_texel_8bit(base, y, x, texel_width); + uint8_t tex = get_texel_8bit(base, y, x, m_texel_width); dest[x] = (tex << 8) | tex; } } - popmessage("offs = %06X", yoffs << 12); + popmessage("offs = %06X", m_yoffs << 12); } return 0; @@ -471,7 +399,7 @@ READ32_MEMBER(midzeus_state::zeus_r) WRITE32_MEMBER(midzeus_state::zeus_w) { - bool logit = zeus_enable_logging || ((offset < 0xb0 || offset > 0xb7) && (offset < 0xe0 || offset > 0xe1)); + bool logit = m_zeus_enable_logging || ((offset < 0xb0 || offset > 0xb7) && (offset < 0xe0 || offset > 0xe1)); if (logit) logerror("%06X:zeus_w", m_maincpu->pc()); @@ -502,20 +430,20 @@ void midzeus_state::zeus_pointer_w(uint32_t which, uint32_t data, bool logit) case 0x018000: if (logit) logerror(" -- setptr(objdata)\n"); - zeus_objdata = data; + m_zeus_objdata = data; break; // case 0x00c040: -- set in model data in invasn case 0x00c040: if (logit) logerror(" -- setptr(palbase)\n"); - zeus_palbase = data; + m_zeus_palbase = data; break; case 0x02c0f0: if (logit) logerror(" -- setptr(unkbase)\n"); - zeus_unkbase = data; + m_zeus_unkbase = data; break; @@ -656,7 +584,7 @@ void midzeus_state::zeus_register_update(offs_t offset) // m_zeusbase[0x46] = ??? = 0x00000000 // m_zeusbase[0x4c] = ??? = 0x00808080 (brightness?) // m_zeusbase[0x4e] = ??? = 0x00808080 (brightness?) - mz_poly_extra_data& extra = poly->object_data_alloc(); + mz_poly_extra_data& extra = m_poly->object_data_alloc(); poly_vertex vert[4]; vert[0].x = (int16_t)m_zeusbase[0x08]; @@ -671,8 +599,8 @@ void midzeus_state::zeus_register_update(offs_t offset) extra.solidcolor = m_zeusbase[0x00]; extra.zoffset = 0x7fff; - poly->zeus_draw_debug_quad(zeus_cliprect, vert); - poly->wait("Normal"); + m_poly->zeus_draw_debug_quad(m_zeus_cliprect, vert); + m_poly->wait("Normal"); } else logerror("Execute unknown command\n"); @@ -680,15 +608,15 @@ void midzeus_state::zeus_register_update(offs_t offset) break; case 0x70: - zeus_point[0] = m_zeusbase[0x70] << 16; + m_zeus_point[0] = m_zeusbase[0x70] << 16; break; case 0x72: - zeus_point[1] = m_zeusbase[0x72] << 16; + m_zeus_point[1] = m_zeusbase[0x72] << 16; break; case 0x74: - zeus_point[2] = m_zeusbase[0x74] << 16; + m_zeus_point[2] = m_zeusbase[0x74] << 16; break; case 0x80: @@ -704,7 +632,7 @@ void midzeus_state::zeus_register_update(offs_t offset) case 0x84: /* MK4: Written in tandem with 0xcc */ /* MK4: Writes either 0x80 (and 0x000000 to 0xcc) or 0x00 (and 0x800000 to 0xcc) */ - zeus_renderbase = waveram1_ptr_from_expanded_addr(m_zeusbase[0x84] << 16); + m_zeus_renderbase = waveram1_ptr_from_expanded_addr(m_zeusbase[0x84] << 16); break; case 0xb0: @@ -745,7 +673,7 @@ void midzeus_state::zeus_register_update(offs_t offset) else src = (const uint32_t *)waveram0_ptr_from_expanded_addr(m_zeusbase[0xb4]); - poly->wait("vram_read"); + m_poly->wait("vram_read"); m_zeusbase[0xb0] = WAVERAM_READ32(src, 0); m_zeusbase[0xb2] = WAVERAM_READ32(src, 1); } @@ -766,22 +694,22 @@ void midzeus_state::zeus_register_update(offs_t offset) if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal) { m_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS(MIDZEUS_VIDEO_CLOCK / 8.0 / (htotal * vtotal))); - zeus_cliprect = visarea; - zeus_cliprect.max_x -= zeus_cliprect.min_x; - zeus_cliprect.min_x = 0; + m_zeus_cliprect = visarea; + m_zeus_cliprect.max_x -= m_zeus_cliprect.min_x; + m_zeus_cliprect.min_x = 0; } } break; case 0xcc: m_screen->update_partial(m_screen->vpos()); - log_fifo = machine().input().code_pressed(KEYCODE_L); + m_log_fifo = machine().input().code_pressed(KEYCODE_L); break; case 0xe0: - zeus_fifo[zeus_fifo_words++] = m_zeusbase[0xe0]; - if (zeus_fifo_process(zeus_fifo, zeus_fifo_words)) - zeus_fifo_words = 0; + m_zeus_fifo[m_zeus_fifo_words++] = m_zeusbase[0xe0]; + if (zeus_fifo_process(m_zeus_fifo, m_zeus_fifo_words)) + m_zeus_fifo_words = 0; break; } } @@ -805,23 +733,23 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) case 0x01: if (numwords < 2 && data[0] != 0) return false; - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, ""); - zeus_pointer_w(data[0] & 0xffffff, data[1], log_fifo); + zeus_pointer_w(data[0] & 0xffffff, data[1], m_log_fifo); break; /* 0x13: render model based on previously set information */ case 0x13: /* invasn */ - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, ""); - zeus_draw_model((m_zeusbase[0x06] << 16), log_fifo); + zeus_draw_model((m_zeusbase[0x06] << 16), m_log_fifo); break; /* 0x17: write 16-bit value to low registers */ case 0x17: - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, " -- reg16"); - zeus_register16_w((data[0] >> 16) & 0x7f, data[0], log_fifo); + zeus_register16_w((data[0] >> 16) & 0x7f, data[0], m_log_fifo); break; /* 0x18: write 32-bit value to low registers */ @@ -829,15 +757,15 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) case 0x18: if (numwords < 2) return false; - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, " -- reg32"); - zeus_register32_w((data[0] >> 16) & 0x7f, data[1], log_fifo); + zeus_register32_w((data[0] >> 16) & 0x7f, data[1], m_log_fifo); break; /* 0x1A/0x1B: sync pipeline(?) */ case 0x1a: case 0x1b: - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, " -- sync\n"); break; @@ -851,7 +779,7 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) /* requires 8 words total */ if (numwords < 8) return false; - if (log_fifo) + if (m_log_fifo) { log_fifo_command(data, numwords, ""); logerror("\n\t\tmatrix ( %04X %04X %04X ) ( %04X %04X %04X ) ( %04X %04X %04X )\n\t\tvector %8.2f %8.2f %8.5f\n", @@ -864,14 +792,14 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) } /* extract the matrix from the raw data */ - zeus_matrix[0][0] = data[2]; zeus_matrix[0][1] = data[2] >> 16; zeus_matrix[0][2] = data[0]; - zeus_matrix[1][0] = data[3]; zeus_matrix[1][1] = data[3] >> 16; zeus_matrix[1][2] = data[1] >> 16; - zeus_matrix[2][0] = data[4]; zeus_matrix[2][1] = data[4] >> 16; zeus_matrix[2][2] = data[1]; + m_zeus_matrix[0][0] = data[2]; m_zeus_matrix[0][1] = data[2] >> 16; m_zeus_matrix[0][2] = data[0]; + m_zeus_matrix[1][0] = data[3]; m_zeus_matrix[1][1] = data[3] >> 16; m_zeus_matrix[1][2] = data[1] >> 16; + m_zeus_matrix[2][0] = data[4]; m_zeus_matrix[2][1] = data[4] >> 16; m_zeus_matrix[2][2] = data[1]; /* extract the translation point from the raw data */ - zeus_point[0] = data[5]; - zeus_point[1] = data[6]; - zeus_point[2] = data[7]; + m_zeus_point[0] = data[5]; + m_zeus_point[1] = data[6]; + m_zeus_point[2] = data[7]; } /* double matrix form */ @@ -883,7 +811,7 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) /* requires 13 words total */ if (numwords < 13) return false; - if (log_fifo) + if (m_log_fifo) { log_fifo_command(data, numwords, ""); logerror("\n\t\tmatrix ( %04X %04X %04X ) ( %04X %04X %04X ) ( %04X %04X %04X )\n\t\tmatrix ( %04X %04X %04X ) ( %04X %04X %04X ) ( %04X %04X %04X )\n\t\tvector %8.2f %8.2f %8.5f\n", @@ -909,20 +837,20 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) matrix2[2][0] = data[5]; matrix2[2][1] = data[6]; matrix2[2][2] = data[7]; /* multiply them together to get the final matrix */ - zeus_matrix[0][0] = ((int64_t)(matrix1[0][0] * matrix2[0][0]) + (int64_t)(matrix1[0][1] * matrix2[1][0]) + (int64_t)(matrix1[0][2] * matrix2[2][0])) >> 16; - zeus_matrix[0][1] = ((int64_t)(matrix1[0][0] * matrix2[0][1]) + (int64_t)(matrix1[0][1] * matrix2[1][1]) + (int64_t)(matrix1[0][2] * matrix2[2][1])) >> 16; - zeus_matrix[0][2] = ((int64_t)(matrix1[0][0] * matrix2[0][2]) + (int64_t)(matrix1[0][1] * matrix2[1][2]) + (int64_t)(matrix1[0][2] * matrix2[2][2])) >> 16; - zeus_matrix[1][0] = ((int64_t)(matrix1[1][0] * matrix2[0][0]) + (int64_t)(matrix1[1][1] * matrix2[1][0]) + (int64_t)(matrix1[1][2] * matrix2[2][0])) >> 16; - zeus_matrix[1][1] = ((int64_t)(matrix1[1][0] * matrix2[0][1]) + (int64_t)(matrix1[1][1] * matrix2[1][1]) + (int64_t)(matrix1[1][2] * matrix2[2][1])) >> 16; - zeus_matrix[1][2] = ((int64_t)(matrix1[1][0] * matrix2[0][2]) + (int64_t)(matrix1[1][1] * matrix2[1][2]) + (int64_t)(matrix1[1][2] * matrix2[2][2])) >> 16; - zeus_matrix[2][0] = ((int64_t)(matrix1[2][0] * matrix2[0][0]) + (int64_t)(matrix1[2][1] * matrix2[1][0]) + (int64_t)(matrix1[2][2] * matrix2[2][0])) >> 16; - zeus_matrix[2][1] = ((int64_t)(matrix1[2][0] * matrix2[0][1]) + (int64_t)(matrix1[2][1] * matrix2[1][1]) + (int64_t)(matrix1[2][2] * matrix2[2][1])) >> 16; - zeus_matrix[2][2] = ((int64_t)(matrix1[2][0] * matrix2[0][2]) + (int64_t)(matrix1[2][1] * matrix2[1][2]) + (int64_t)(matrix1[2][2] * matrix2[2][2])) >> 16; + m_zeus_matrix[0][0] = ((int64_t)(matrix1[0][0] * matrix2[0][0]) + (int64_t)(matrix1[0][1] * matrix2[1][0]) + (int64_t)(matrix1[0][2] * matrix2[2][0])) >> 16; + m_zeus_matrix[0][1] = ((int64_t)(matrix1[0][0] * matrix2[0][1]) + (int64_t)(matrix1[0][1] * matrix2[1][1]) + (int64_t)(matrix1[0][2] * matrix2[2][1])) >> 16; + m_zeus_matrix[0][2] = ((int64_t)(matrix1[0][0] * matrix2[0][2]) + (int64_t)(matrix1[0][1] * matrix2[1][2]) + (int64_t)(matrix1[0][2] * matrix2[2][2])) >> 16; + m_zeus_matrix[1][0] = ((int64_t)(matrix1[1][0] * matrix2[0][0]) + (int64_t)(matrix1[1][1] * matrix2[1][0]) + (int64_t)(matrix1[1][2] * matrix2[2][0])) >> 16; + m_zeus_matrix[1][1] = ((int64_t)(matrix1[1][0] * matrix2[0][1]) + (int64_t)(matrix1[1][1] * matrix2[1][1]) + (int64_t)(matrix1[1][2] * matrix2[2][1])) >> 16; + m_zeus_matrix[1][2] = ((int64_t)(matrix1[1][0] * matrix2[0][2]) + (int64_t)(matrix1[1][1] * matrix2[1][2]) + (int64_t)(matrix1[1][2] * matrix2[2][2])) >> 16; + m_zeus_matrix[2][0] = ((int64_t)(matrix1[2][0] * matrix2[0][0]) + (int64_t)(matrix1[2][1] * matrix2[1][0]) + (int64_t)(matrix1[2][2] * matrix2[2][0])) >> 16; + m_zeus_matrix[2][1] = ((int64_t)(matrix1[2][0] * matrix2[0][1]) + (int64_t)(matrix1[2][1] * matrix2[1][1]) + (int64_t)(matrix1[2][2] * matrix2[2][1])) >> 16; + m_zeus_matrix[2][2] = ((int64_t)(matrix1[2][0] * matrix2[0][2]) + (int64_t)(matrix1[2][1] * matrix2[1][2]) + (int64_t)(matrix1[2][2] * matrix2[2][2])) >> 16; /* extract the translation point from the raw data */ - zeus_point[0] = data[10]; - zeus_point[1] = data[11]; - zeus_point[2] = data[12]; + m_zeus_point[0] = data[10]; + m_zeus_point[1] = data[11]; + m_zeus_point[2] = data[12]; } break; @@ -932,15 +860,15 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) case 0x2e: if (numwords < 2) return false; - if (log_fifo) + if (m_log_fifo) { log_fifo_command(data, numwords, ""); logerror(" -- light xyz = %d,%d,%d\n", (int16_t)data[1], (int16_t)(data[1] >> 16), (int16_t)data[0]); } - zeus_light[0] = (int16_t)(data[1] & 0xffff); - zeus_light[1] = (int16_t)(data[1] >> 16); - zeus_light[2] = (int16_t)(data[0] & 0xffff); + m_zeus_light[0] = (int16_t)(data[1] & 0xffff); + m_zeus_light[1] = (int16_t)(data[1] >> 16); + m_zeus_light[2] = (int16_t)(data[0] & 0xffff); break; /* 0x25: display control? */ /* 0x28: same for mk4b */ @@ -948,7 +876,7 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) case 0x25: { /* 0x25 is used differently in mk4b. What determines this? */ - if (is_mk4b) + if (m_is_mk4b) { if (numwords < 2) return false; @@ -961,21 +889,21 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) if (numwords < 4 || ((data[0] & 0x808000) && numwords < 10)) return false; - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, " -- alt. quad and hack screen clear\n"); if ((numwords < 10) && (data[0] & 0xffff7f) == 0) { /* not right -- just a hack */ int x, y; - for (y = zeus_cliprect.min_y; y <= zeus_cliprect.max_y; y++) - for (x = zeus_cliprect.min_x; x <= zeus_cliprect.max_x; x++) + for (y = m_zeus_cliprect.min_y; y <= m_zeus_cliprect.max_y; y++) + for (x = m_zeus_cliprect.min_x; x <= m_zeus_cliprect.max_x; x++) waveram_plot_depth(y, x, 0, 0x7fff); } else { uint32_t texdata = (m_zeusbase[0x06] << 16) | (m_zeusbase[0x00] >> 16); - poly->zeus_draw_quad(false, data, texdata, log_fifo); + m_poly->zeus_draw_quad(false, data, texdata, m_log_fifo); } break; @@ -983,7 +911,7 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) /* 0x70: same for mk4 */ case 0x2d: case 0x70: - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, "\n"); break; @@ -991,15 +919,15 @@ int midzeus_state::zeus_fifo_process(const uint32_t *data, int numwords) case 0x67: if (numwords < 3) return false; - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, ""); - zeus_objdata = data[1]; - zeus_draw_model(data[2], log_fifo); + m_zeus_objdata = data[1]; + zeus_draw_model(data[2], m_log_fifo); break; default: printf("Unknown command %08X\n", data[0]); - if (log_fifo) + if (m_log_fifo) log_fifo_command(data, numwords, "\n"); break; } @@ -1021,16 +949,16 @@ void midzeus_state::zeus_draw_model(uint32_t texdata, bool logit) int model_done = false; if (logit) - logerror(" -- model @ %08X\n", zeus_objdata); + logerror(" -- model @ %08X\n", m_zeus_objdata); - while (zeus_objdata != 0 && !model_done) + while (m_zeus_objdata != 0 && !model_done) { - const void *base = waveram0_ptr_from_block_addr(zeus_objdata); - int count = zeus_objdata >> 24; + const void *base = waveram0_ptr_from_block_addr(m_zeus_objdata); + int count = m_zeus_objdata >> 24; int curoffs; /* reset the objdata address */ - zeus_objdata = 0; + m_zeus_objdata = 0; /* loop until we run out of data */ for (curoffs = 0; curoffs <= count; curoffs++) @@ -1089,7 +1017,7 @@ void midzeus_state::zeus_draw_model(uint32_t texdata, bool logit) case 0x25: /* mk4 */ case 0x28: /* mk4r1 */ case 0x30: /* invasn */ - poly->zeus_draw_quad(true, databuffer, texdata, logit); + m_poly->zeus_draw_quad(true, databuffer, texdata, logit); break; default: @@ -1132,6 +1060,9 @@ void midzeus_renderer::zeus_draw_quad(int long_fmt, const uint32_t *databuffer, int xy_offset = long_fmt ? 2 : 1; + int16_t (*zeus_matrix)[3] = m_state.m_zeus_matrix; + int32_t *zeus_point = m_state.m_zeus_point; + for (uint32_t i = 0; i < 4; i++) { uint32_t ixy = databuffer[xy_offset + i*2]; @@ -1143,7 +1074,6 @@ void midzeus_renderer::zeus_draw_quad(int long_fmt, const uint32_t *databuffer, uint8_t v = iuvz >> 24; int64_t x, y, z; - x = (int64_t)(xo * zeus_matrix[0][0]) + (int64_t)(yo * zeus_matrix[0][1]) + (int64_t)(zo * zeus_matrix[0][2]) + zeus_point[0]; y = (int64_t)(xo * zeus_matrix[1][0]) + (int64_t)(yo * zeus_matrix[1][1]) + (int64_t)(zo * zeus_matrix[1][2]) + zeus_point[1]; z = (int64_t)(xo * zeus_matrix[2][0]) + (int64_t)(yo * zeus_matrix[2][1]) + (int64_t)(zo * zeus_matrix[2][2]) + zeus_point[2]; @@ -1202,7 +1132,7 @@ void midzeus_renderer::zeus_draw_quad(int long_fmt, const uint32_t *databuffer, } } - numverts = poly->zclip_if_less(4, &vert[0], &clipvert[0], 4, 512.0f); + numverts = m_state.m_poly->zclip_if_less(4, &vert[0], &clipvert[0], 4, 512.0f); if (numverts < 3) return; @@ -1230,7 +1160,7 @@ void midzeus_renderer::zeus_draw_quad(int long_fmt, const uint32_t *databuffer, clipvert[i].y += 0.0005f; } - mz_poly_extra_data& extra = poly->object_data_alloc(); + mz_poly_extra_data& extra = m_state.m_poly->object_data_alloc(); if (ctrl_word & 0x01000000) { @@ -1238,7 +1168,7 @@ void midzeus_renderer::zeus_draw_quad(int long_fmt, const uint32_t *databuffer, extra.texwidth = 512 >> texwshift; extra.voffset = ctrl_word & 0xffff; - extra.texbase = waveram0_ptr_from_texture_addr(texbase, extra.texwidth); + extra.texbase = m_state.waveram0_ptr_from_texture_addr(texbase, extra.texwidth); if (tex_type == 1) { @@ -1263,12 +1193,12 @@ void midzeus_renderer::zeus_draw_quad(int long_fmt, const uint32_t *databuffer, extra.depth_test_enable = !(m_state.m_zeusbase[0x04] & 0x800); extra.depth_write_enable = m_state.m_zeusbase[0x04] & 0x200; extra.transcolor = ((ctrl_word >> 16) & 1) ? 0 : 0x100; - extra.palbase = waveram0_ptr_from_block_addr(zeus_palbase); + extra.palbase = m_state.waveram0_ptr_from_block_addr(m_state.m_zeus_palbase); // Note: Before being upgraded to the new polygon rasterizing code, this function call was // a poly_render_quad_fan. It appears as though the new code defaults to a fan if // the template argument is 4, but keep an eye out for missing quads. - poly->render_polygon<4>(zeus_cliprect, + m_state.m_poly->render_polygon<4>(m_state.m_zeus_cliprect, render_delegate(&midzeus_renderer::render_poly, this), 4, clipvert); @@ -1276,7 +1206,7 @@ void midzeus_renderer::zeus_draw_quad(int long_fmt, const uint32_t *databuffer, void midzeus_renderer::zeus_draw_debug_quad(const rectangle& rect, const vertex_t *vert) { - poly->render_polygon<4>(rect, render_delegate(&midzeus_renderer::render_poly_solid_fixedz, this), 0, vert); + m_state.m_poly->render_polygon<4>(rect, render_delegate(&midzeus_renderer::render_poly_solid_fixedz, this), 0, vert); } @@ -1303,7 +1233,7 @@ void midzeus_renderer::render_poly(int32_t scanline, const extent_t& extent, con for (uint32_t x = extent.startx; x < extent.stopx; x++) { - uint16_t *depthptr = WAVERAM_PTRDEPTH(zeus_renderbase, scanline, x); + uint16_t *depthptr = WAVERAM_PTRDEPTH(m_state.m_zeus_renderbase, scanline, x); int32_t depth = (curz >> 16) + object.zoffset; if (depth > 0x7fff) @@ -1385,7 +1315,7 @@ void midzeus_renderer::render_poly(int32_t scanline, const extent_t& extent, con // Destination enable? if (object.blend & 0x00800000) { - uint16_t dst = WAVERAM_READPIX(zeus_renderbase, scanline, x); + uint16_t dst = WAVERAM_READPIX(m_state.m_zeus_renderbase, scanline, x); dstr = (dst >> 10) & 0x1f; dstg = (dst >> 5) & 0x1f; @@ -1479,7 +1409,7 @@ void midzeus_renderer::render_poly(int32_t scanline, const extent_t& extent, con outg >>= 3; outb >>= 3; - WAVERAM_WRITEPIX(zeus_renderbase, scanline, x, (outr << 10) | (outg << 5) | outb); + WAVERAM_WRITEPIX(m_state.m_zeus_renderbase, scanline, x, (outr << 10) | (outg << 5) | outb); if (object.depth_write_enable) *depthptr = depth; @@ -1502,7 +1432,7 @@ void midzeus_renderer::render_poly_solid_fixedz(int32_t scanline, const extent_t int x; for (x = extent.startx; x < extent.stopx; x++) - waveram_plot_depth(scanline, x, color, depth); + m_state.waveram_plot_depth(scanline, x, color, depth); } diff --git a/src/mame/video/model1.cpp b/src/mame/video/model1.cpp index 9cf4db2c057..a5301c2b3d6 100644 --- a/src/mame/video/model1.cpp +++ b/src/mame/video/model1.cpp @@ -451,20 +451,20 @@ int model1_state::quad_t::compare(const model1_state::quad_t* other) const void model1_state::sort_quads() const { - const int count = m_quadpt - m_quaddb; + const int count = m_quadpt - &m_quaddb[0]; for (int i = 0; i < count; i++) { - m_quadind[i] = m_quaddb + i; + m_quadind[i] = &m_quaddb[i]; } - qsort(m_quadind, count, sizeof(model1_state::quad_t*), comp_quads); + qsort(&m_quadind[0], count, sizeof(model1_state::quad_t*), comp_quads); } void model1_state::unsort_quads() const { - const int count = m_quadpt - m_quaddb; + const int count = m_quadpt - &m_quaddb[0]; for (int i = 0; i < count; i++) { - m_quadind[i] = m_quaddb + i; + m_quadind[i] = &m_quaddb[i]; } } @@ -472,7 +472,7 @@ void model1_state::unsort_quads() const void model1_state::draw_quads(bitmap_rgb32 &bitmap, const rectangle &cliprect) { view_t *view = m_view.get(); - int count = m_quadpt - m_quaddb; + int count = m_quadpt - &m_quaddb[0]; /* clip to the cliprect */ int save_x1 = view->x1; @@ -1176,15 +1176,15 @@ int model1_state::skip_direct(int list_offset) const void model1_state::draw_objects(bitmap_rgb32 &bitmap, const rectangle &cliprect) { - if (m_quadpt != m_quaddb) + if (m_quadpt != &m_quaddb[0]) { LOG_TGP(("VIDEO: sort&draw\n")); sort_quads(); draw_quads(bitmap, cliprect); } - m_quadpt = m_quaddb; - m_pointpt = m_pointdb; + m_quadpt = &m_quaddb[0]; + m_pointpt = &m_pointdb[0]; } @@ -1199,8 +1199,8 @@ int model1_state::draw_direct(bitmap_rgb32 &bitmap, const rectangle &cliprect, i unsort_quads(); draw_quads(bitmap, cliprect); - m_quadpt = m_quaddb; - m_pointpt = m_pointdb; + m_quadpt = &m_quaddb[0]; + m_pointpt = &m_pointdb[0]; return list_offset; } @@ -1568,12 +1568,12 @@ void model1_state::video_start() m_poly_ram = make_unique_clear<uint32_t[]>(0x400000); m_tgp_ram = make_unique_clear<uint16_t[]>(0x100000-0x40000); - m_pointdb = auto_alloc_array_clear(machine(), model1_state::point_t, 1000000*2); - m_quaddb = auto_alloc_array_clear(machine(), model1_state::quad_t, 1000000); - m_quadind = auto_alloc_array_clear(machine(), model1_state::quad_t *, 1000000); + m_pointdb = make_unique_clear<model1_state::point_t[]>(1000000*2); + m_quaddb = make_unique_clear<model1_state::quad_t[]>(1000000); + m_quadind = make_unique_clear<model1_state::quad_t *[]>(1000000); - m_pointpt = m_pointdb; - m_quadpt = m_quaddb; + m_pointpt = &m_pointdb[0]; + m_quadpt = &m_quaddb[0]; m_listctl[0] = m_listctl[1] = 0; m_clipfn[0].m_isclipped = &model1_state::fclip_isc_bottom; diff --git a/src/mame/video/model2.cpp b/src/mame/video/model2.cpp index e84d78bb020..f63991d2ea3 100644 --- a/src/mame/video/model2.cpp +++ b/src/mame/video/model2.cpp @@ -101,62 +101,6 @@ /******************************************* * - * Hardware 3D Rasterizer Internal State - * - *******************************************/ - -#define MAX_TRIANGLES 32768 - -struct raster_state -{ -// uint32_t mode; /* bit 0 = Test Mode, bit 2 = Switch 60Hz(1)/30Hz(0) operation */ - uint16_t *texture_rom; /* Texture ROM pointer */ - uint32_t texture_rom_mask; /* Texture ROM mask */ - int16_t viewport[4]; /* View port (startx,starty,endx,endy) */ - int16_t center[4][2]; /* Centers (eye 0[x,y],1[x,y],2[x,y],3[x,y]) */ - uint16_t center_sel; /* Selected center */ - uint32_t reverse; /* Left/Right Reverse */ - float z_adjust; /* ZSort Mode */ - float triangle_z; /* Current Triangle z value */ - uint8_t master_z_clip; /* Master Z-Clip value */ - uint32_t cur_command; /* Current command */ - uint32_t command_buffer[32]; /* Command buffer */ - uint32_t command_index; /* Command buffer index */ - triangle tri_list[MAX_TRIANGLES]; /* Triangle list */ - uint32_t tri_list_index; /* Triangle list index */ - triangle *tri_sorted_list[0x10000]; /* Sorted Triangle list */ - uint16_t min_z; /* Minimum sortable Z value */ - uint16_t max_z; /* Maximum sortable Z value */ - uint16_t texture_ram[0x10000]; /* Texture RAM pointer */ - uint8_t log_ram[0x40000]; /* Log RAM pointer */ -}; - -/******************************************* - * - * Geometry Engine Internal State - * - *******************************************/ - -struct geo_state -{ - raster_state * raster; - uint32_t mode; /* bit 0 = Enable Specular, bit 1 = Calculate Normals */ - uint32_t * polygon_rom; /* Polygon ROM pointer */ - uint32_t polygon_rom_mask; /* Polygon ROM mask */ - float matrix[12]; /* Current Transformation Matrix */ - poly_vertex focus; /* Focus (x,y) */ - poly_vertex light; /* Light Vector */ - float lod; /* LOD */ - float coef_table[32]; /* Distane Coefficient table */ - texture_parameter texture_parameters[32]; /* Texture parameters */ - uint32_t polygon_ram0[0x8000]; /* Fast Polygon RAM pointer */ - uint32_t polygon_ram1[0x8000]; /* Slow Polygon RAM pointer */ - model2_state *state; -}; - - -/******************************************* - * * Generic 3D Math Functions * *******************************************/ @@ -341,7 +285,7 @@ inline bool model2_state::check_culling( raster_state *raster, uint32_t attr, fl void model2_state::raster_init( memory_region *texture_rom ) { - m_raster = auto_alloc_clear(machine(), <raster_state>()); + m_raster = make_unique_clear<raster_state>(); m_raster->texture_rom = (uint16_t *)texture_rom->base(); m_raster->texture_rom_mask = (texture_rom->bytes() / 2) - 1; @@ -826,7 +770,7 @@ void model2_state::model2_3d_process_triangle( raster_state *raster, uint32_t at void model2_renderer::model2_3d_render(triangle *tri, const rectangle &cliprect) { - model2_renderer *poly = m_state.m_poly; + model2_renderer *poly = m_state.m_poly.get(); m2_poly_extra_data& extra = poly->object_data_alloc(); uint8_t renderer; @@ -942,7 +886,7 @@ inline void model2_state::model2_3d_project( triangle *tri ) /* 3D Rasterizer frame start: Resets frame variables */ void model2_state::model2_3d_frame_start( void ) { - raster_state *raster = m_raster; + raster_state *raster = m_raster.get(); /* reset the triangle list index */ raster->tri_list_index = 0; @@ -957,7 +901,7 @@ void model2_state::model2_3d_frame_start( void ) void model2_state::model2_3d_frame_end( bitmap_rgb32 &bitmap, const rectangle &cliprect ) { - raster_state *raster = m_raster; + raster_state *raster = m_raster.get(); int32_t z; /* if we have nothing to render, bail */ @@ -1216,10 +1160,10 @@ void model2_state::model2_3d_push( raster_state *raster, uint32_t input ) void model2_state::geo_init(memory_region *polygon_rom) { - m_geo = auto_alloc_clear(machine(), <geo_state>()); + m_geo = make_unique_clear<geo_state>(); m_geo->state = this; - m_geo->raster = m_raster; + m_geo->raster = m_raster.get(); m_geo->polygon_rom = (uint32_t *)polygon_rom->base(); m_geo->polygon_rom_mask = (polygon_rom->bytes() / 4) - 1; @@ -2599,7 +2543,7 @@ void model2_state::geo_parse( void ) } /* process it */ - input = geo_process_command( m_geo, opcode, input, &end_code ); + input = geo_process_command( m_geo.get(), opcode, input, &end_code ); } } @@ -2614,7 +2558,7 @@ void model2_state::video_start() m_sys24_bitmap.allocate(width, height+4); - m_poly = auto_alloc(machine(), model2_renderer(*this)); + m_poly = std::make_unique<model2_renderer>(*this); /* initialize the hardware rasterizer */ raster_init( memregion("textures") ); diff --git a/src/mame/video/slapshot.cpp b/src/mame/video/slapshot.cpp index a74e083b99e..37827d8d650 100644 --- a/src/mame/video/slapshot.cpp +++ b/src/mame/video/slapshot.cpp @@ -10,7 +10,7 @@ void slapshot_state::video_start() { m_spriteram_delayed = std::make_unique<u16[]>(m_spriteram.bytes() / 2); m_spriteram_buffered = std::make_unique<u16[]>(m_spriteram.bytes() / 2); - m_spritelist = auto_alloc_array(machine(), struct slapshot_tempsprite, 0x400); + m_spritelist = std::make_unique<slapshot_tempsprite[]>(0x400); m_sprites_disabled = true; m_sprites_active_area = 0; @@ -91,7 +91,7 @@ void slapshot_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, c /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ - struct slapshot_tempsprite *sprite_ptr = m_spritelist; + slapshot_tempsprite *sprite_ptr = &m_spritelist[0]; /* must remember enable status from last frame because driftout fails to reactivate them from a certain point onwards. */ @@ -341,7 +341,7 @@ void slapshot_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, c /* this happens only if primsks != nullptr */ - while (sprite_ptr != m_spritelist) + while (sprite_ptr != &m_spritelist[0]) { sprite_ptr--; diff --git a/src/mame/video/taito_f3.cpp b/src/mame/video/taito_f3.cpp index ab993ed068e..2d1ae3b058e 100644 --- a/src/mame/video/taito_f3.cpp +++ b/src/mame/video/taito_f3.cpp @@ -227,7 +227,7 @@ struct F3config int sprite_lag; }; -static const struct F3config f3_config_table[] = +static const F3config f3_config_table[] = { /* Name Extend Lag */ { RINGRAGE, 0, 2 }, @@ -459,7 +459,7 @@ WRITE_LINE_MEMBER(taito_f3_state::screen_vblank) void taito_f3_state::video_start() { - const struct F3config *pCFG = &f3_config_table[0]; + const F3config *pCFG = &f3_config_table[0]; m_alpha_level_2as = 127; m_alpha_level_2ad = 127; @@ -552,12 +552,12 @@ void taito_f3_state::video_start() } m_spriteram16_buffered = std::make_unique<u16[]>(0x10000 / 2); - m_spritelist = auto_alloc_array(machine(), struct tempsprite, 0x400); - m_sprite_end = m_spritelist; + m_spritelist = std::make_unique<tempsprite[]>(0x400); + m_sprite_end = &m_spritelist[0]; m_vram_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(taito_f3_state::get_tile_info_text), this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); m_pixel_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(taito_f3_state::get_tile_info_pixel), this), TILEMAP_SCAN_COLS, 8, 8, 64, 32); - m_pf_line_inf = auto_alloc_array(machine(), struct f3_playfield_line_inf, 5); - m_sa_line_inf = auto_alloc_array(machine(), struct f3_spritealpha_line_inf, 1); + m_pf_line_inf = std::make_unique<f3_playfield_line_inf[]>(5); + m_sa_line_inf = std::make_unique<f3_spritealpha_line_inf[]>(1); m_screen->register_screen_bitmap(m_pri_alp_bitmap); m_tile_opaque_sp = std::make_unique<u8[]>(m_gfxdecode->gfx(2)->elements()); for (int i = 0; i < 8; i++) @@ -1276,7 +1276,7 @@ void taito_f3_state::init_alpha_blend_func() #define GET_PIXMAP_POINTER(pf_num) \ { \ - const struct f3_playfield_line_inf *line_tmp = line_t[pf_num]; \ + const f3_playfield_line_inf *line_tmp = line_t[pf_num]; \ m_src[pf_num] = line_tmp->src[y]; \ m_src_s[pf_num] = line_tmp->src_s[y]; \ m_src_e[pf_num] = line_tmp->src_e[y]; \ @@ -1331,7 +1331,7 @@ void taito_f3_state::init_alpha_blend_func() inline void taito_f3_state::draw_scanlines( bitmap_rgb32 &bitmap, int xsize, s16 *draw_line_num, - const struct f3_playfield_line_inf **line_t, + const f3_playfield_line_inf **line_t, const int *sprite, u32 orient, int skip_layer_num) @@ -1449,7 +1449,7 @@ inline void taito_f3_state::draw_scanlines( /******************************************************************************/ void taito_f3_state::visible_tile_check( - struct f3_playfield_line_inf *line_t, + f3_playfield_line_inf *line_t, int line, u32 x_index_fx,u32 y_index, u16 *pf_data_n) @@ -1521,7 +1521,7 @@ void taito_f3_state::visible_tile_check( void taito_f3_state::calculate_clip(int y, u16 pri, u32 *clip0, u32 *clip1, int *line_enable) { - const struct f3_spritealpha_line_inf *sa_line_t = &m_sa_line_inf[0]; + const f3_spritealpha_line_inf *sa_line_t = &m_sa_line_inf[0]; switch (pri) { @@ -1625,7 +1625,7 @@ void taito_f3_state::calculate_clip(int y, u16 pri, u32 *clip0, u32 *clip1, int void taito_f3_state::get_spritealphaclip_info() { - struct f3_spritealpha_line_inf *line_t = &m_sa_line_inf[0]; + f3_spritealpha_line_inf *line_t = &m_sa_line_inf[0]; int y, y_end, y_inc; @@ -1722,7 +1722,7 @@ void taito_f3_state::get_spritealphaclip_info() /* sx and sy are 16.16 fixed point numbers */ void taito_f3_state::get_line_ram_info(tilemap_t *tmap, int sx, int sy, int pos, u16 *pf_data_n) { - struct f3_playfield_line_inf *line_t = &m_pf_line_inf[pos]; + f3_playfield_line_inf *line_t = &m_pf_line_inf[pos]; int y_start, y_end, y_inc; int line_base, zoom_base, col_base, pri_base, inc; @@ -1925,8 +1925,8 @@ void taito_f3_state::get_line_ram_info(tilemap_t *tmap, int sx, int sy, int pos, void taito_f3_state::get_vram_info(tilemap_t *vram_tilemap, tilemap_t *pixel_tilemap, int sx, int sy) { - const struct f3_spritealpha_line_inf *sprite_alpha_line_t = &m_sa_line_inf[0]; - struct f3_playfield_line_inf *line_t = &m_pf_line_inf[4]; + const f3_spritealpha_line_inf *sprite_alpha_line_t = &m_sa_line_inf[0]; + f3_playfield_line_inf *line_t = &m_pf_line_inf[4]; int y_start, y_end, y_inc; int pri_base, inc; @@ -2075,11 +2075,11 @@ void taito_f3_state::scanline_draw(bitmap_rgb32 &bitmap, const rectangle &clipre u8 sprite_alpha_check; u8 sprite_alpha_all_2a; int layer_tmp[5]; - struct f3_playfield_line_inf *pf_line_inf = m_pf_line_inf; - struct f3_spritealpha_line_inf *sa_line_inf = m_sa_line_inf; + f3_playfield_line_inf *pf_line_inf = m_pf_line_inf.get(); + f3_spritealpha_line_inf *sa_line_inf = m_sa_line_inf.get(); int count_skip_layer = 0; int sprite[6] = {0, 0, 0, 0, 0, 0}; - const struct f3_playfield_line_inf *line_t[5]; + const f3_playfield_line_inf *line_t[5]; /* find same status of scanlines */ pri[0] = pf_line_inf[0].pri[y_start]; @@ -2735,7 +2735,7 @@ void taito_f3_state::get_sprite_info(const u16 *spriteram16_ptr) int x_addition_left = 8, y_addition_left = 8; - struct tempsprite *sprite_ptr = m_spritelist; + tempsprite *sprite_ptr = &m_spritelist[0]; int total_sprites = 0; @@ -3008,7 +3008,7 @@ void taito_f3_state::get_sprite_info(const u16 *spriteram16_ptr) void taito_f3_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect) { - const struct tempsprite *sprite_ptr; + const tempsprite *sprite_ptr; gfx_element *sprite_gfx = m_gfxdecode->gfx(2); sprite_ptr = m_sprite_end; @@ -3017,7 +3017,7 @@ void taito_f3_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprec // if sprites use more than 4bpp, the bottom bits of the color code must be masked out. // This fixes (at least) stage 1 battle ships and attract mode explosions in Ray Force. - while (sprite_ptr != m_spritelist) + while (sprite_ptr != &m_spritelist[0]) { sprite_ptr--; diff --git a/src/osd/modules/debugger/debuggdbstub.cpp b/src/osd/modules/debugger/debuggdbstub.cpp index 4028dd3b994..4c7e4e3707e 100644 --- a/src/osd/modules/debugger/debuggdbstub.cpp +++ b/src/osd/modules/debugger/debuggdbstub.cpp @@ -977,13 +977,9 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_s(const char *buf) //------------------------------------------------------------------------- static bool remove_breakpoint(device_debug *debug, uint64_t address, int /*kind*/) { - device_debug::breakpoint *bp = debug->breakpoint_first(); - while ( bp != nullptr ) - { - if ( bp->address() == address ) - return debug->breakpoint_clear(bp->index()); - bp = bp->next(); - } + const device_debug::breakpoint *bp = debug->breakpoint_find(address); + if (bp != nullptr) + return debug->breakpoint_clear(bp->index()); return false; } diff --git a/src/osd/modules/debugger/osx/debugconsole.mm b/src/osd/modules/debugger/osx/debugconsole.mm index b6c02c67224..1bd285e8c3b 100644 --- a/src/osd/modules/debugger/osx/debugconsole.mm +++ b/src/osd/modules/debugger/osx/debugconsole.mm @@ -237,8 +237,7 @@ if ([dasmView cursorVisible] && (machine->debugger().cpu().get_visible_cpu() == &device)) { offs_t const address = [dasmView selectedAddress]; - device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address - forDevice:device]; + const device_debug::breakpoint *bp = [dasmView source]->device()->debug()->breakpoint_find(address); // if it doesn't exist, add a new one NSString *command; @@ -255,8 +254,7 @@ device_t &device = *[dasmView source]->device(); if ([dasmView cursorVisible] && (machine->debugger().cpu().get_visible_cpu() == &device)) { - device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] - forDevice:device]; + const device_debug::breakpoint *bp = [dasmView source]->device()->debug()->breakpoint_find([dasmView selectedAddress]); if (bp != nullptr) { NSString *command; @@ -566,11 +564,10 @@ BOOL const haveCursor = [dasmView cursorVisible]; BOOL const isCurrent = (machine->debugger().cpu().get_visible_cpu() == [dasmView source]->device()); - device_debug::breakpoint *breakpoint = nullptr; + const device_debug::breakpoint *breakpoint = nullptr; if (haveCursor) { - breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] - forDevice:*[dasmView source]->device()]; + breakpoint = [dasmView source]->device()->debug()->breakpoint_find([dasmView selectedAddress]); } if (action == @selector(debugToggleBreakpoint:)) diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.h b/src/osd/modules/debugger/osx/debugwindowhandler.h index 4feeff267c9..c48bbb031b2 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.h +++ b/src/osd/modules/debugger/osx/debugwindowhandler.h @@ -45,8 +45,6 @@ enum + (void)addCommonActionItems:(NSMenu *)menu; + (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame; -+ (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device; - - (id)initWithMachine:(running_machine &)m title:(NSString *)t; - (void)activate; diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.mm b/src/osd/modules/debugger/osx/debugwindowhandler.mm index 1f483139452..27d487c86ff 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.mm +++ b/src/osd/modules/debugger/osx/debugwindowhandler.mm @@ -134,14 +134,6 @@ NSString *const MAMESaveDebuggerConfigurationNotification = @"MAMESaveDebuggerCo } -+ (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device { - device_debug *const cpuinfo = device.debug(); - device_debug::breakpoint *bp = cpuinfo->breakpoint_first(); - while ((bp != nullptr) && (address != bp->address())) bp = bp->next(); - return bp; -} - - - (id)initWithMachine:(running_machine &)m title:(NSString *)t { if (!(self = [super init])) return nil; diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.mm b/src/osd/modules/debugger/osx/disassemblyviewer.mm index 5c9c1c8aa23..eb039f4ca17 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.mm +++ b/src/osd/modules/debugger/osx/disassemblyviewer.mm @@ -176,7 +176,7 @@ { device_t &device = *[dasmView source]->device(); offs_t const address = [dasmView selectedAddress]; - device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device]; + const device_debug::breakpoint *bp = device.debug()->breakpoint_find(address); // if it doesn't exist, add a new one if (bp == nullptr) @@ -203,7 +203,7 @@ { device_t &device = *[dasmView source]->device(); offs_t const address = [dasmView selectedAddress]; - device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device]; + const device_debug::breakpoint *bp = device.debug()->breakpoint_find(address); if (bp != nullptr) { device.debug()->breakpoint_enable(bp->index(), !bp->enabled()); @@ -252,11 +252,10 @@ BOOL const inContextMenu = ([item menu] == [dasmView menu]); BOOL const haveCursor = [dasmView cursorVisible]; - device_debug::breakpoint *breakpoint = nullptr; + const device_debug::breakpoint *breakpoint = nullptr; if (haveCursor) { - breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] - forDevice:*[dasmView source]->device()]; + breakpoint = [dasmView source]->device()->debug()->breakpoint_find([dasmView selectedAddress]); } if (action == @selector(debugToggleBreakpoint:)) diff --git a/src/osd/modules/debugger/qt/dasmwindow.cpp b/src/osd/modules/debugger/qt/dasmwindow.cpp index 396f97c78bf..5c575b400b1 100644 --- a/src/osd/modules/debugger/qt/dasmwindow.cpp +++ b/src/osd/modules/debugger/qt/dasmwindow.cpp @@ -143,26 +143,17 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo) device_debug *const cpuinfo = device->debug(); // Find an existing breakpoint at this address - int32_t bpindex = -1; - for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - bp != nullptr; - bp = bp->next()) - { - if (address == bp->address()) - { - bpindex = bp->index(); - break; - } - } + const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address); // If none exists, add a new one - if (bpindex == -1) + if (bp == nullptr) { - bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr); + int32_t bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr); m_machine->debugger().console().printf("Breakpoint %X set\n", bpindex); } else { + int32_t bpindex = bp->index(); cpuinfo->breakpoint_clear(bpindex); m_machine->debugger().console().printf("Breakpoint %X cleared\n", bpindex); } @@ -183,9 +174,7 @@ void DasmWindow::enableBreakpointAtCursor(bool changedTo) device_debug *const cpuinfo = device->debug(); // Find an existing breakpoint at this address - device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - while ((bp != nullptr) && (bp->address() != address)) - bp = bp->next(); + const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address); if (bp != nullptr) { @@ -241,9 +230,7 @@ void DasmWindow::dasmViewUpdated() device_debug *const cpuinfo = device->debug(); // Find an existing breakpoint at this address - device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - while ((bp != nullptr) && (bp->address() != address)) - bp = bp->next(); + const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address); if (bp != nullptr) { diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp index fffe3577e9e..6a79ebf955d 100644 --- a/src/osd/modules/debugger/qt/mainwindow.cpp +++ b/src/osd/modules/debugger/qt/mainwindow.cpp @@ -220,27 +220,17 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo) device_debug *const cpuinfo = dasmView->source()->device()->debug(); // Find an existing breakpoint at this address - int32_t bpindex = -1; - for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - bp != nullptr; - bp = bp->next()) - { - if (address == bp->address()) - { - bpindex = bp->index(); - break; - } - } + const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address); // If none exists, add a new one std::string command; - if (bpindex == -1) + if (bp == nullptr) { command = string_format("bpset 0x%X", address); } else { - command = string_format("bpclear 0x%X", bpindex); + command = string_format("bpclear 0x%X", bp->index()); } m_machine->debugger().console().execute_command(command.c_str(), true); } @@ -258,9 +248,7 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo) device_debug *const cpuinfo = dasmView->source()->device()->debug(); // Find an existing breakpoint at this address - device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - while ((bp != nullptr) && (bp->address() != address)) - bp = bp->next(); + const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address); if (bp != nullptr) { @@ -418,9 +406,7 @@ void MainWindow::dasmViewUpdated() device_debug *const cpuinfo = device->debug(); // Find an existing breakpoint at this address - device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - while ((bp != nullptr) && (bp->address() != address)) - bp = bp->next(); + const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address); if (bp != nullptr) { diff --git a/src/osd/modules/debugger/win/disasmbasewininfo.cpp b/src/osd/modules/debugger/win/disasmbasewininfo.cpp index ef4c5122ba6..c466e059f23 100644 --- a/src/osd/modules/debugger/win/disasmbasewininfo.cpp +++ b/src/osd/modules/debugger/win/disasmbasewininfo.cpp @@ -115,9 +115,7 @@ void disasmbasewin_info::update_menu() device_debug *const debug = dasmview->source_device()->debug(); // first find an existing breakpoint at this address - device_debug::breakpoint *bp = debug->breakpoint_first(); - while ((bp != nullptr) && (bp->address() != address)) - bp = bp->next(); + const device_debug::breakpoint *bp = debug->breakpoint_find(address); if (bp == nullptr) { @@ -166,28 +164,21 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam) { offs_t const address = dasmview->selected_address(); device_debug *const debug = dasmview->source_device()->debug(); - int32_t bpindex = -1; // first find an existing breakpoint at this address - for (device_debug::breakpoint *bp = debug->breakpoint_first(); bp != nullptr; bp = bp->next()) - { - if (address == bp->address()) - { - bpindex = bp->index(); - break; - } - } + const device_debug::breakpoint *bp = debug->breakpoint_find(address); // if it doesn't exist, add a new one if (!is_main_console()) { - if (bpindex == -1) + if (bp == nullptr) { - bpindex = debug->breakpoint_set(address, nullptr, nullptr); + int32_t bpindex = debug->breakpoint_set(address, nullptr, nullptr); machine().debugger().console().printf("Breakpoint %X set\n", bpindex); } else { + int32_t bpindex = bp->index(); debug->breakpoint_clear(bpindex); machine().debugger().console().printf("Breakpoint %X cleared\n", bpindex); } @@ -197,10 +188,10 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam) else if (dasmview->source_is_visible_cpu()) { std::string command; - if (bpindex == -1) + if (bp == nullptr) command = string_format("bpset 0x%X", address); else - command = string_format("bpclear 0x%X", bpindex); + command = string_format("bpclear 0x%X", bp->index()); machine().debugger().console().execute_command(command.c_str(), true); } } @@ -213,9 +204,7 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam) device_debug *const debug = dasmview->source_device()->debug(); // first find an existing breakpoint at this address - device_debug::breakpoint *bp = debug->breakpoint_first(); - while ((bp != nullptr) && (bp->address() != address)) - bp = bp->next(); + const device_debug::breakpoint *bp = debug->breakpoint_find(address); // if it doesn't exist, add a new one if (bp != nullptr) diff --git a/src/osd/modules/lib/osdlib.h b/src/osd/modules/lib/osdlib.h index d080d1edd85..d126ed7f2ce 100644 --- a/src/osd/modules/lib/osdlib.h +++ b/src/osd/modules/lib/osdlib.h @@ -54,14 +54,9 @@ int osd_setenv(const char *name, const char *value, int overwrite); /*----------------------------------------------------------------------------- - osd_get_clipboard_text: retrieves text from the clipboard - - Return value: - - the returned string needs to be free-ed! + osd_get_clipboard_text: retrieves text from the clipboard -----------------------------------------------------------------------------*/ - -char *osd_get_clipboard_text(void); +std::string osd_get_clipboard_text(void); /*----------------------------------------------------------------------------- dynamic_module: load functions from optional shared libraries diff --git a/src/osd/modules/lib/osdlib_macosx.cpp b/src/osd/modules/lib/osdlib_macosx.cpp index b476261df41..372293ec1a3 100644 --- a/src/osd/modules/lib/osdlib_macosx.cpp +++ b/src/osd/modules/lib/osdlib_macosx.cpp @@ -116,22 +116,23 @@ void osd_break_into_debugger(const char *message) // osd_get_clipboard_text //============================================================ -char *osd_get_clipboard_text(void) +std::string osd_get_clipboard_text(void) { + std::string result; + bool has_result = false; OSStatus err; PasteboardRef pasteboard_ref; err = PasteboardCreate(kPasteboardClipboard, &pasteboard_ref); if (err) - return nullptr; + return result; PasteboardSynchronize(pasteboard_ref); ItemCount item_count; err = PasteboardGetItemCount(pasteboard_ref, &item_count); - char *result = nullptr; // core expects a malloced C string of uft8 data - for (UInt32 item_index = 1; (item_index <= item_count) && !result; item_index++) + for (UInt32 item_index = 1; (item_index <= item_count) && !has_result; item_index++) { PasteboardItemID item_id; err = PasteboardGetItemIdentifier(pasteboard_ref, item_index, &item_id); @@ -144,7 +145,7 @@ char *osd_get_clipboard_text(void) continue; CFIndex const flavor_count = CFArrayGetCount(flavor_type_array); - for (CFIndex flavor_index = 0; (flavor_index < flavor_count) && !result; flavor_index++) + for (CFIndex flavor_index = 0; (flavor_index < flavor_count) && !has_result; flavor_index++) { CFStringRef const flavor_type = (CFStringRef)CFArrayGetValueAtIndex(flavor_type_array, flavor_index); @@ -171,12 +172,9 @@ char *osd_get_clipboard_text(void) CFIndex const length = CFDataGetLength(data_ref); CFRange const range = CFRangeMake(0, length); - result = reinterpret_cast<char *>(malloc(length + 1)); - if (result) - { - CFDataGetBytes(data_ref, range, reinterpret_cast<unsigned char *>(result)); - result[length] = 0; - } + result.resize(length); + CFDataGetBytes(data_ref, range, reinterpret_cast<unsigned char *>(&result[0])); + has_result = true; CFRelease(data_ref); } diff --git a/src/osd/modules/lib/osdlib_unix.cpp b/src/osd/modules/lib/osdlib_unix.cpp index ba3eec9662c..178fb4594cb 100644 --- a/src/osd/modules/lib/osdlib_unix.cpp +++ b/src/osd/modules/lib/osdlib_unix.cpp @@ -100,24 +100,23 @@ void osd_break_into_debugger(const char *message) } #ifdef SDLMAME_ANDROID -char *osd_get_clipboard_text(void) +std::string osd_get_clipboard_text(void) { - return nullptr; + return std::string(); } #else //============================================================ // osd_get_clipboard_text //============================================================ -char *osd_get_clipboard_text(void) +std::string osd_get_clipboard_text(void) { - char *result = nullptr; + std::string result; if (SDL_HasClipboardText()) { char *temp = SDL_GetClipboardText(); - result = (char *) malloc(strlen(temp) + 1); - strcpy(result, temp); + result.assign(temp); SDL_free(temp); } return result; diff --git a/src/osd/modules/lib/osdlib_uwp.cpp b/src/osd/modules/lib/osdlib_uwp.cpp index 7bfb594f9c7..8d20c552cab 100644 --- a/src/osd/modules/lib/osdlib_uwp.cpp +++ b/src/osd/modules/lib/osdlib_uwp.cpp @@ -129,7 +129,7 @@ void osd_break_into_debugger(const char *message) // get_clipboard_text_by_format //============================================================ -static char *get_clipboard_text_by_format(UINT format, std::string (*convert)(LPCVOID data)) +static bool get_clipboard_text_by_format(std::string &result_text, UINT format, std::string (*convert)(LPCVOID data)) { DataPackageView^ dataPackageView; IAsyncOperation<String^>^ getTextOp; @@ -139,7 +139,8 @@ static char *get_clipboard_text_by_format(UINT format, std::string (*convert)(LP getTextOp = dataPackageView->GetTextAsync(); clipboardText = getTextOp->GetResults(); - return (char *)convert(clipboardText->Data()).c_str(); + result_text = convert(clipboardText->Data()); + return !result_text.empty(); } //============================================================ @@ -164,14 +165,16 @@ static std::string convert_ansi(LPCVOID data) // osd_get_clipboard_text //============================================================ -char *osd_get_clipboard_text(void) +std::string osd_get_clipboard_text(void) { - // try to access unicode text - char *result = get_clipboard_text_by_format(CF_UNICODETEXT, convert_wide); + std::string result; - // try to access ANSI text - if (result == nullptr) - result = get_clipboard_text_by_format(CF_TEXT, convert_ansi); + // try to access unicode text + if (!get_clipboard_text_by_format(result, CF_UNICODETEXT, convert_wide)) + { + // try to access ANSI text + get_clipboard_text_by_format(result, CF_TEXT, convert_ansi); + } return result; } diff --git a/src/osd/modules/lib/osdlib_win32.cpp b/src/osd/modules/lib/osdlib_win32.cpp index fb4b29e62af..911f95c3bfe 100644 --- a/src/osd/modules/lib/osdlib_win32.cpp +++ b/src/osd/modules/lib/osdlib_win32.cpp @@ -134,9 +134,9 @@ void osd_break_into_debugger(const char *message) // get_clipboard_text_by_format //============================================================ -static char *get_clipboard_text_by_format(UINT format, std::string (*convert)(LPCVOID data)) +static bool get_clipboard_text_by_format(std::string &result_text, UINT format, std::string (*convert)(LPCVOID data)) { - char *result = nullptr; + bool result = false; HANDLE data_handle; LPVOID data; @@ -155,12 +155,8 @@ static char *get_clipboard_text_by_format(UINT format, std::string (*convert)(LP if (data != nullptr) { // invoke the convert - std::string s = (*convert)(data); - - // copy the string - result = (char *) malloc(s.size() + 1); - if (result != nullptr) - memcpy(result, s.data(), (s.size() + 1) * sizeof(*result)); + result_text = (*convert)(data); + result = true; // unlock the data GlobalUnlock(data_handle); @@ -196,14 +192,16 @@ static std::string convert_ansi(LPCVOID data) // osd_get_clipboard_text //============================================================ -char *osd_get_clipboard_text(void) +std::string osd_get_clipboard_text(void) { - // try to access unicode text - char *result = get_clipboard_text_by_format(CF_UNICODETEXT, convert_wide); + std::string result; - // try to access ANSI text - if (result == nullptr) - result = get_clipboard_text_by_format(CF_TEXT, convert_ansi); + // try to access unicode text + if (!get_clipboard_text_by_format(result, CF_UNICODETEXT, convert_wide)) + { + // try to access ANSI text + get_clipboard_text_by_format(result, CF_TEXT, convert_ansi); + } return result; } diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h index d64ca04c578..22179f9da45 100644 --- a/src/osd/osdcore.h +++ b/src/osd/osdcore.h @@ -752,13 +752,8 @@ void osd_break_into_debugger(const char *message); /*----------------------------------------------------------------------------- osd_get_clipboard_text: retrieves text from the clipboard - - Return value: - - the returned string needs to be osd_free()-ed! - -----------------------------------------------------------------------------*/ -char *osd_get_clipboard_text(void); +std::string osd_get_clipboard_text(void); /*************************************************************************** |