diff --git a/src/mame/drivers/cedar_magnet.cpp b/src/mame/drivers/cedar_magnet.cpp index 4c545df2b14..ef1eae39cea 100644 --- a/src/mame/drivers/cedar_magnet.cpp +++ b/src/mame/drivers/cedar_magnet.cpp @@ -133,27 +133,28 @@ class cedar_magnet_state : public driver_device { public: cedar_magnet_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_bank0(*this, "bank0"), - m_sub_ram_bankdev(*this, "mb_sub_ram"), - m_sub_pal_bankdev(*this, "mb_sub_pal"), - m_ram0(*this, "ram0"), - m_pal_r(*this, "pal_r"), - m_pal_g(*this, "pal_g"), - m_pal_b(*this, "pal_b"), - m_ic48_pio(*this, "z80pio_ic48"), - m_ic49_pio(*this, "z80pio_ic49"), - m_ic48_pio_pa_val(0xff), - m_ic48_pio_pb_val(0xff), - m_ic49_pio_pb_val(0xff), - m_address1hack(-1), - m_address2hack(-1), - m_palette(*this, "palette"), - m_maincpu(*this, "maincpu"), - m_cedsound(*this, "cedtop"), - m_cedplane0(*this, "cedplane0"), - m_cedplane1(*this, "cedplane1"), - m_cedsprite(*this, "cedsprite") + : driver_device(mconfig, type, tag) + , m_bank0(*this, "bank0") + , m_sub_ram_bankdev(*this, "mb_sub_ram") + , m_sub_pal_bankdev(*this, "mb_sub_pal") + , m_ram0(*this, "ram0") + , m_pal_r(*this, "pal_r") + , m_pal_g(*this, "pal_g") + , m_pal_b(*this, "pal_b") + , m_ic48_pio(*this, "z80pio_ic48") + , m_ic49_pio(*this, "z80pio_ic49") + , m_io_coin(*this, "COIN%u", 1U) + , m_ic48_pio_pa_val(0xff) + , m_ic48_pio_pb_val(0xff) + , m_ic49_pio_pb_val(0xff) + , m_address1hack(-1) + , m_address2hack(-1) + , m_palette(*this, "palette") + , m_maincpu(*this, "maincpu") + , m_cedsound(*this, "cedtop") + , m_cedplane0(*this, "cedplane0") + , m_cedplane1(*this, "cedplane1") + , m_cedsprite(*this, "cedsprite") { } @@ -164,54 +165,56 @@ private: required_device m_sub_ram_bankdev; required_device m_sub_pal_bankdev; - required_shared_ptr m_ram0; - required_shared_ptr m_pal_r; - required_shared_ptr m_pal_g; - required_shared_ptr m_pal_b; + required_shared_ptr m_ram0; + required_shared_ptr m_pal_r; + required_shared_ptr m_pal_g; + required_shared_ptr m_pal_b; required_device m_ic48_pio; required_device m_ic49_pio; - uint8_t ic48_pio_pa_r(); - void ic48_pio_pa_w(uint8_t data); + optional_ioport_array<2> m_io_coin; - uint8_t ic48_pio_pb_r(); - void ic48_pio_pb_w(uint8_t data); + u8 ic48_pio_pa_r(); + void ic48_pio_pa_w(u8 data); - uint8_t ic49_pio_pb_r(); - void ic49_pio_pb_w(uint8_t data); + u8 ic48_pio_pb_r(); + void ic48_pio_pb_w(u8 data); + + u8 ic49_pio_pb_r(); + void ic49_pio_pb_w(u8 data); // 1x range ports - void port18_w(uint8_t data); - void port19_w(uint8_t data); - void port1b_w(uint8_t data); + void port18_w(u8 data); + void port19_w(u8 data); + void port1b_w(u8 data); - uint8_t port18_r(); - uint8_t port19_r(); - uint8_t port1a_r(); + u8 port18_r(); + u8 port19_r(); + u8 port1a_r(); // 7x range ports - void rambank_palbank_w(uint8_t data); - void palupload_w(uint8_t data); - void paladdr_w(uint8_t data); - uint8_t watchdog_r(); - uint8_t port7c_r(); + void rambank_palbank_w(u8 data); + void palupload_w(u8 data); + void paladdr_w(u8 data); + u8 watchdog_r(); + u8 port7c_r(); // other ports - uint8_t other_cpu_r(offs_t offset); - void other_cpu_w(offs_t offset, uint8_t data); + u8 other_cpu_r(offs_t offset); + void other_cpu_w(offs_t offset, u8 data); - uint8_t m_paladdr; + u8 m_paladdr; int m_palbank; - uint8_t m_ic48_pio_pa_val; - uint8_t m_ic48_pio_pb_val; - uint8_t m_ic49_pio_pb_val; + u8 m_ic48_pio_pa_val; + u8 m_ic48_pio_pb_val; + u8 m_ic49_pio_pb_val; void set_palette(int offset); - void palette_r_w(offs_t offset, uint8_t data); - void palette_g_w(offs_t offset, uint8_t data); - void palette_b_w(offs_t offset, uint8_t data); + void palette_r_w(offs_t offset, u8 data); + void palette_g_w(offs_t offset, u8 data); + void palette_b_w(offs_t offset, u8 data); void handle_sub_board_cpu_lines(cedar_magnet_board_interface &dev, int old_data, int data); INTERRUPT_GEN_MEMBER(irq); @@ -222,7 +225,7 @@ private: virtual void machine_start() override; virtual void machine_reset() override; virtual void video_start() override; - uint32_t screen_update_cedar_magnet(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); required_device m_palette; required_device m_maincpu; @@ -317,7 +320,7 @@ void cedar_magnet_state::cedar_bank0(address_map &map) ***********************/ -void cedar_magnet_state::rambank_palbank_w(uint8_t data) +void cedar_magnet_state::rambank_palbank_w(u8 data) { // ---- --xx // xx = program bank @@ -329,17 +332,17 @@ void cedar_magnet_state::rambank_palbank_w(uint8_t data) m_sub_pal_bankdev->set_bank(palbank); } -void cedar_magnet_state::palupload_w(uint8_t data) +void cedar_magnet_state::palupload_w(u8 data) { m_sub_pal_bankdev->write8(m_paladdr, data); } -void cedar_magnet_state::paladdr_w(uint8_t data) +void cedar_magnet_state::paladdr_w(u8 data) { m_paladdr = data; } -uint8_t cedar_magnet_state::watchdog_r() +u8 cedar_magnet_state::watchdog_r() { // watchdog return 0x00; @@ -352,7 +355,7 @@ uint8_t cedar_magnet_state::watchdog_r() ***********************/ -uint8_t cedar_magnet_state::port7c_r() +u8 cedar_magnet_state::port7c_r() { //logerror("%s: port7c_r\n", machine().describe_context()); return 0x01; @@ -366,20 +369,20 @@ uint8_t cedar_magnet_state::port7c_r() ***********************/ -uint8_t cedar_magnet_state::port18_r() +u8 cedar_magnet_state::port18_r() { // logerror("%s: port18_r\n", machine().describe_context()); return 0x00; } -void cedar_magnet_state::port18_w(uint8_t data) +void cedar_magnet_state::port18_w(u8 data) { // logerror("%s: port18_w %02x\n", machine().describe_context(), data); } -uint8_t cedar_magnet_state::port19_r() +u8 cedar_magnet_state::port19_r() { - uint8_t ret = 0x00; + u8 ret = 0x00; // logerror("%s: port19_r\n", machine().describe_context()); // 9496 in a,($19) @@ -390,19 +393,19 @@ uint8_t cedar_magnet_state::port19_r() return ret; } -uint8_t cedar_magnet_state::port1a_r() +u8 cedar_magnet_state::port1a_r() { // logerror("%s: port1a_r\n", machine().describe_context()); return 0x00; } -void cedar_magnet_state::port19_w(uint8_t data) +void cedar_magnet_state::port19_w(u8 data) { // logerror("%s: port19_w %02x\n", machine().describe_context(), data); } -void cedar_magnet_state::port1b_w(uint8_t data) +void cedar_magnet_state::port1b_w(u8 data) { // logerror("%s: port1b_w %02x\n", machine().describe_context(), data); } @@ -418,27 +421,26 @@ void cedar_magnet_state::set_palette(int offset) m_palette->set_pen_color(offset^0xff, pal4bit(m_pal_r[offset]), pal4bit(m_pal_g[offset]), pal4bit(m_pal_b[offset])); } -void cedar_magnet_state::palette_r_w(offs_t offset, uint8_t data) +void cedar_magnet_state::palette_r_w(offs_t offset, u8 data) { m_pal_r[offset] = data; set_palette(offset); } -void cedar_magnet_state::palette_g_w(offs_t offset, uint8_t data) +void cedar_magnet_state::palette_g_w(offs_t offset, u8 data) { m_pal_g[offset] = data; set_palette(offset); } -void cedar_magnet_state::palette_b_w(offs_t offset, uint8_t data) +void cedar_magnet_state::palette_b_w(offs_t offset, u8 data) { m_pal_b[offset] = data; set_palette(offset); } -uint32_t cedar_magnet_state::screen_update_cedar_magnet(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +u32 cedar_magnet_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - bitmap.fill(m_palette->black_pen(), cliprect); int pal = (m_palbank >> 6); @@ -460,7 +462,7 @@ void cedar_magnet_state::video_start() ***********************/ -uint8_t cedar_magnet_state::other_cpu_r(offs_t offset) +u8 cedar_magnet_state::other_cpu_r(offs_t offset) { int bankbit0 = (m_ic48_pio_pa_val & 0x60) >> 5; int plane0select = (m_ic48_pio_pa_val & 0x07) >> 0; @@ -471,7 +473,7 @@ uint8_t cedar_magnet_state::other_cpu_r(offs_t offset) int unk2 = (m_ic49_pio_pb_val & 0x03) >> 0; int cpus_accessed = 0; - uint8_t ret = 0x00; + u8 ret = 0x00; int offset2 = offset + windowbank * 0x4000; @@ -509,7 +511,7 @@ uint8_t cedar_magnet_state::other_cpu_r(offs_t offset) return ret; } -void cedar_magnet_state::other_cpu_w(offs_t offset, uint8_t data) +void cedar_magnet_state::other_cpu_w(offs_t offset, u8 data) { int bankbit0 = (m_ic48_pio_pa_val & 0x60) >> 5; int plane0select = (m_ic48_pio_pa_val & 0x07) >> 0; @@ -579,11 +581,11 @@ void cedar_magnet_state::handle_sub_board_cpu_lines(cedar_magnet_board_interface ***********************/ -uint8_t cedar_magnet_state::ic48_pio_pa_r() // 0x20 +u8 cedar_magnet_state::ic48_pio_pa_r() // 0x20 { - uint8_t ret = m_ic48_pio_pa_val & ~0x08; + u8 ret = m_ic48_pio_pa_val & ~0x08; - ret |= ioport("COIN1")->read()<<3; + ret |= m_io_coin[0]->read()<<3; if (!m_cedplane0->is_running()) ret &= ~0x01; // interrupt source stuff?? @@ -593,7 +595,7 @@ uint8_t cedar_magnet_state::ic48_pio_pa_r() // 0x20 return ret; } -void cedar_magnet_state::ic48_pio_pa_w(uint8_t data) // 0x20 +void cedar_magnet_state::ic48_pio_pa_w(u8 data) // 0x20 { int oldplane0select = (m_ic48_pio_pa_val & 0x07) >> 0; @@ -621,11 +623,11 @@ void cedar_magnet_state::ic48_pio_pa_w(uint8_t data) // 0x20 } -uint8_t cedar_magnet_state::ic48_pio_pb_r() // 0x22 +u8 cedar_magnet_state::ic48_pio_pb_r() // 0x22 { - uint8_t ret = m_ic48_pio_pb_val & ~0x80; + u8 ret = m_ic48_pio_pb_val & ~0x80; - ret |= ioport("COIN2")->read()<<7; + ret |= m_io_coin[1]->read()<<7; if (!m_cedsprite->is_running()) ret &= ~0x10; if (!m_cedplane1->is_running()) ret &= ~0x01; @@ -634,7 +636,7 @@ uint8_t cedar_magnet_state::ic48_pio_pb_r() // 0x22 return ret; } -void cedar_magnet_state::ic48_pio_pb_w(uint8_t data) // 0x22 +void cedar_magnet_state::ic48_pio_pb_w(u8 data) // 0x22 { int oldplane1select = (m_ic48_pio_pb_val & 0x07) >> 0; int oldspriteselect = (m_ic48_pio_pb_val & 0x70) >> 4; @@ -667,9 +669,9 @@ void cedar_magnet_state::ic48_pio_pb_w(uint8_t data) // 0x22 ***********************/ -uint8_t cedar_magnet_state::ic49_pio_pb_r() // 0x42 +u8 cedar_magnet_state::ic49_pio_pb_r() // 0x42 { - uint8_t ret = m_ic49_pio_pb_val; + u8 ret = m_ic49_pio_pb_val; if (!m_cedsound->is_running()) ret &= ~0x10; @@ -677,7 +679,7 @@ uint8_t cedar_magnet_state::ic49_pio_pb_r() // 0x42 return ret; } -void cedar_magnet_state::ic49_pio_pb_w(uint8_t data) // 0x42 +void cedar_magnet_state::ic49_pio_pb_w(u8 data) // 0x42 { int oldsoundselect = (m_ic49_pio_pb_val & 0x70) >> 4; @@ -799,7 +801,7 @@ void cedar_magnet_state::cedar_magnet(machine_config &config) screen.set_vblank_time(ATTOSECONDS_IN_USEC(0)); screen.set_size(256, 256); screen.set_visarea(0, 256-8-1, 0, 192-1); - screen.set_screen_update(FUNC(cedar_magnet_state::screen_update_cedar_magnet)); + screen.set_screen_update(FUNC(cedar_magnet_state::screen_update)); screen.set_palette(m_palette); PALETTE(config, m_palette).set_entries(0x400); diff --git a/src/mame/machine/cedar_magnet_board.cpp b/src/mame/machine/cedar_magnet_board.cpp index 8eeffb690dc..2cffb11abb3 100644 --- a/src/mame/machine/cedar_magnet_board.cpp +++ b/src/mame/machine/cedar_magnet_board.cpp @@ -17,7 +17,7 @@ void cedar_magnet_board_interface::write_cpu_bus(int offset, u8 data) ap.write_byte(offset, data); } -uint8_t cedar_magnet_board_interface::read_cpu_bus(int offset) +u8 cedar_magnet_board_interface::read_cpu_bus(int offset) { address_space &ap = m_cpu->space(AS_PROGRAM); return ap.read_byte(offset); diff --git a/src/mame/machine/cedar_magnet_board.h b/src/mame/machine/cedar_magnet_board.h index b0684e9bbdc..6ec96309687 100644 --- a/src/mame/machine/cedar_magnet_board.h +++ b/src/mame/machine/cedar_magnet_board.h @@ -21,7 +21,7 @@ public: u8 *ram() { return &m_ram[0]; } virtual u8 read_cpu_bus(int offset); - virtual void write_cpu_bus(int offset, uint8_t data); + virtual void write_cpu_bus(int offset, u8 data); void irq_hold(); void halt_assert(); diff --git a/src/mame/machine/cedar_magnet_flop.cpp b/src/mame/machine/cedar_magnet_flop.cpp index a4b520261ff..3bd1c84f108 100644 --- a/src/mame/machine/cedar_magnet_flop.cpp +++ b/src/mame/machine/cedar_magnet_flop.cpp @@ -12,6 +12,7 @@ DEFINE_DEVICE_TYPE(CEDAR_MAGNET_FLOP, cedar_magnet_flop_device, "cedmag_flop", " cedar_magnet_flop_device::cedar_magnet_flop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CEDAR_MAGNET_FLOP, tag, owner, clock) + , m_disk(*this, "disk") { } @@ -36,27 +37,26 @@ void cedar_magnet_flop_device::device_reset() m_floptrk = 0; } -READ8_MEMBER(cedar_magnet_flop_device::port60_r) +u8 cedar_magnet_flop_device::port60_r() { - uint8_t ret = m_flopstat; + u8 ret = m_flopstat; return ret; } -READ8_MEMBER(cedar_magnet_flop_device::port61_r) +u8 cedar_magnet_flop_device::port61_r() { - uint8_t ret = m_curtrack; + u8 ret = m_curtrack; return ret; } -READ8_MEMBER(cedar_magnet_flop_device::port63_r) +u8 cedar_magnet_flop_device::port63_r() { - uint8_t ret = machine().rand(); + u8 ret = machine().rand(); // printf("%s: port63_r (DATA) (%02x)\n", machine().describe_context().c_str(), ret); if ((m_flopcmd&0xf0) == 0x90) // reading data { - uint8_t *flop = memregion("disk")->base(); int side = (m_flopcmd & 0x02)>>1; int read_offset_base = (m_flopsec * 0x400) + (m_curtrack * 0x3000) + (side * 0x1800); @@ -67,7 +67,7 @@ READ8_MEMBER(cedar_magnet_flop_device::port63_r) m_flopstat |= 0x05; int read_offset = read_offset_base + m_secoffs; - ret = flop[read_offset]; + ret = m_disk[read_offset]; if (m_secoffs == 0) { @@ -102,7 +102,7 @@ READ8_MEMBER(cedar_magnet_flop_device::port63_r) return ret; } -WRITE8_MEMBER(cedar_magnet_flop_device::port60_w) +void cedar_magnet_flop_device::port60_w(u8 data) { //printf("%s: port60_w (COMMAND) %02x\n", machine().describe_context().c_str(), data); m_flopcmd = data; @@ -149,7 +149,7 @@ WRITE8_MEMBER(cedar_magnet_flop_device::port60_w) } -WRITE8_MEMBER(cedar_magnet_flop_device::port62_w) +void cedar_magnet_flop_device::port62_w(u8 data) { //printf("%s: port62_w (SECTOR) %02x\n", machine().describe_context().c_str(), data); m_flopsec = data; @@ -162,14 +162,13 @@ WRITE8_MEMBER(cedar_magnet_flop_device::port62_w) m_flopsec -= 200; } -WRITE8_MEMBER(cedar_magnet_flop_device::port63_w) +void cedar_magnet_flop_device::port63_w(u8 data) { //printf("%s: port63_w (DATA) %02x\n", machine().describe_context().c_str(), data); m_flopdat = data; if ((m_flopcmd & 0xf0) == 0xb0) // writing data { - uint8_t *flop = memregion("disk")->base(); int side = (m_flopcmd & 0x02)>>1; int read_offset_base = (m_flopsec * 0x400) + (m_curtrack * 0x3000) + (side * 0x1800); @@ -180,7 +179,7 @@ WRITE8_MEMBER(cedar_magnet_flop_device::port63_w) m_flopstat |= 0x05; int read_offset = read_offset_base + m_secoffs; - flop[read_offset] = data; + m_disk[read_offset] = data; if (m_secoffs == 0) { @@ -206,10 +205,10 @@ WRITE8_MEMBER(cedar_magnet_flop_device::write) { switch (offset & 3) { - case 0x00:port60_w(space, offset, data);break; + case 0x00:port60_w(data);break; // case 0x01:port61_w(space, offset, data);break; - case 0x02:port62_w(space, offset, data);break; - case 0x03:port63_w(space, offset, data);break; + case 0x02:port62_w(data);break; + case 0x03:port63_w(data);break; default:break; } } @@ -218,10 +217,10 @@ READ8_MEMBER(cedar_magnet_flop_device::read) { switch (offset & 3) { - case 0x00: return port60_r(space, offset); - case 0x01: return port61_r(space, offset); + case 0x00: return port60_r(); + case 0x01: return port61_r(); //case 0x02: return port62_r(space, offset); - case 0x03: return port63_r(space, offset); + case 0x03: return port63_r(); default: return 0x00; } diff --git a/src/mame/machine/cedar_magnet_flop.h b/src/mame/machine/cedar_magnet_flop.h index 72e75a7dcfb..acd45263115 100644 --- a/src/mame/machine/cedar_magnet_flop.h +++ b/src/mame/machine/cedar_magnet_flop.h @@ -16,13 +16,13 @@ public: // construction/destruction cedar_magnet_flop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - DECLARE_READ8_MEMBER(port60_r); - DECLARE_READ8_MEMBER(port61_r); - DECLARE_READ8_MEMBER(port63_r); + u8 port60_r(); + u8 port61_r(); + u8 port63_r(); - DECLARE_WRITE8_MEMBER(port60_w); - DECLARE_WRITE8_MEMBER(port62_w); - DECLARE_WRITE8_MEMBER(port63_w); + void port60_w(u8 data); + void port62_w(u8 data); + void port63_w(u8 data); DECLARE_READ8_MEMBER(read); DECLARE_WRITE8_MEMBER(write); @@ -33,13 +33,14 @@ protected: virtual void device_reset() override; private: - uint8_t m_flopdat; - uint8_t m_flopcmd; - uint8_t m_flopsec; - uint8_t m_flopstat; - uint8_t m_floptrk; + required_region_ptr m_disk; + u8 m_flopdat; + u8 m_flopcmd; + u8 m_flopsec; + u8 m_flopstat; + u8 m_floptrk; - uint8_t m_curtrack; + u8 m_curtrack; int m_secoffs; }; diff --git a/src/mame/machine/cedar_magnet_plane.cpp b/src/mame/machine/cedar_magnet_plane.cpp index 12f3596a8ba..094d25ddeab 100644 --- a/src/mame/machine/cedar_magnet_plane.cpp +++ b/src/mame/machine/cedar_magnet_plane.cpp @@ -9,14 +9,13 @@ DEFINE_DEVICE_TYPE(CEDAR_MAGNET_PLANE, cedar_magnet_plane_device, "cedmag_plane", "Cedar Plane") -cedar_magnet_plane_device::cedar_magnet_plane_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +cedar_magnet_plane_device::cedar_magnet_plane_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, CEDAR_MAGNET_PLANE, tag, owner, clock) , cedar_magnet_board_interface(mconfig, *this, "planecpu", "ram") { } - void cedar_magnet_plane_device::cedar_magnet_plane_map(address_map &map) { map(0x0000, 0xffff).ram().share("ram"); @@ -37,11 +36,9 @@ void cedar_magnet_plane_device::cedar_magnet_plane_io(address_map &map) } - - -WRITE8_MEMBER(cedar_magnet_plane_device::plane_portcc_w) +void cedar_magnet_plane_device::plane_portcc_w(u8 data) { - m_framebuffer[((m_curline&0xff)*0x100)+(m_lineoffset&0xff)] = data; + m_framebuffer[((m_curline & 0xff) * 0x100) + (m_lineoffset & 0xff)] = data; // counters simply wrap when they reach the maximum, don't move onto next row/colummn (confirmed by xain) if (m_pio0_pa_data&0x01) @@ -54,18 +51,17 @@ WRITE8_MEMBER(cedar_magnet_plane_device::plane_portcc_w) } } -WRITE8_MEMBER(cedar_magnet_plane_device::plane_portcd_w) +void cedar_magnet_plane_device::plane_portcd_w(u8 data) { m_lineoffset = data; } -WRITE8_MEMBER(cedar_magnet_plane_device::plane_portce_w) +void cedar_magnet_plane_device::plane_portce_w(u8 data) { m_curline = data; - } -WRITE8_MEMBER(cedar_magnet_plane_device::plane_portcf_w) +void cedar_magnet_plane_device::plane_portcf_w(u8 data) { // does it have a meaning or is it just some kind of watchdog? m_cf_data = data; @@ -93,7 +89,7 @@ void cedar_magnet_plane_device::device_add_mconfig(machine_config &config) } -READ8_MEMBER(cedar_magnet_plane_device::pio0_pa_r) +u8 cedar_magnet_plane_device::pio0_pa_r() { // this is read // logerror("%s: pio0_pa_r\n", machine().describe_context()); @@ -101,7 +97,7 @@ READ8_MEMBER(cedar_magnet_plane_device::pio0_pa_r) } -WRITE8_MEMBER(cedar_magnet_plane_device::pio0_pa_w) +void cedar_magnet_plane_device::pio0_pa_w(u8 data) { m_pio0_pa_data = data; @@ -114,43 +110,44 @@ WRITE8_MEMBER(cedar_magnet_plane_device::pio0_pa_w) // 321 = always set after startup? } -WRITE8_MEMBER(cedar_magnet_plane_device::pio0_pb_w) +void cedar_magnet_plane_device::pio0_pb_w(u8 data) { m_pio0_pb_data = data; } -WRITE8_MEMBER(cedar_magnet_plane_device::pio1_pa_w) +void cedar_magnet_plane_device::pio1_pa_w(u8 data) { m_scrollx = data; } -WRITE8_MEMBER(cedar_magnet_plane_device::pio1_pb_w) +void cedar_magnet_plane_device::pio1_pb_w(u8 data) { m_scrolly = data; } void cedar_magnet_plane_device::device_start() { - save_item(NAME(m_framebuffer)); + m_framebuffer = make_unique_clear(0x10000); + save_pointer(NAME(m_framebuffer), 0x10000); } -uint32_t cedar_magnet_plane_device::draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palbase) +u32 cedar_magnet_plane_device::draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palbase) { int count = 0; if (!(m_pio0_pa_data & 0x40)) return 0; - for (int y = 0;y < 256;y++) + for (int y = 0; y < 256;y++) { - uint16_t *dst = &bitmap.pix16((y-m_scrolly)&0xff); + u16 *dst = &bitmap.pix16((y - m_scrolly) & 0xff); for (int x = 0; x < 256;x++) { - uint8_t pix = m_framebuffer[count]; + u8 pix = m_framebuffer[count]; count++; - if (pix) dst[(x-m_scrollx)&0xff] = pix + palbase*0x100; + if (pix) dst[(x - m_scrollx) & 0xff] = pix + palbase * 0x100; } } diff --git a/src/mame/machine/cedar_magnet_plane.h b/src/mame/machine/cedar_magnet_plane.h index 99cf6a5f37f..8e706ef6af8 100644 --- a/src/mame/machine/cedar_magnet_plane.h +++ b/src/mame/machine/cedar_magnet_plane.h @@ -15,16 +15,16 @@ class cedar_magnet_plane_device : public device_t, public cedar_magnet_board_int { public: // construction/destruction - cedar_magnet_plane_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + cedar_magnet_plane_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - DECLARE_WRITE8_MEMBER(plane_portcc_w); - DECLARE_WRITE8_MEMBER(plane_portcd_w); - DECLARE_WRITE8_MEMBER(plane_portce_w); - DECLARE_WRITE8_MEMBER(plane_portcf_w); + void plane_portcc_w(u8 data); + void plane_portcd_w(u8 data); + void plane_portce_w(u8 data); + void plane_portcf_w(u8 data); INTERRUPT_GEN_MEMBER(vblank_irq); - uint32_t draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palbase); + u32 draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palbase); void cedar_magnet_plane_io(address_map &map); void cedar_magnet_plane_map(address_map &map); @@ -33,28 +33,28 @@ protected: virtual void device_start() override; private: - uint8_t m_framebuffer[0x10000]; + std::unique_ptr m_framebuffer; int m_curline; int m_lineoffset; - uint8_t m_pio0_pa_data; - uint8_t m_pio0_pb_data; - uint8_t m_scrollx; - uint8_t m_scrolly; + u8 m_pio0_pa_data; + u8 m_pio0_pb_data; + u8 m_scrollx; + u8 m_scrolly; int m_direction; - uint8_t m_cd_data; - uint8_t m_cf_data; + u8 m_cd_data; + u8 m_cf_data; - DECLARE_READ8_MEMBER(pio0_pa_r); - DECLARE_WRITE8_MEMBER(pio0_pa_w); + u8 pio0_pa_r(); + void pio0_pa_w(u8 data); // DECLARE_READ8_MEMBER(pio0_pb_r); - DECLARE_WRITE8_MEMBER(pio0_pb_w); + void pio0_pb_w(u8 data); // DECLARE_READ8_MEMBER(pio1_pa_r); - DECLARE_WRITE8_MEMBER(pio1_pa_w); + void pio1_pa_w(u8 data); // DECLARE_READ8_MEMBER(pio1_pb_r); - DECLARE_WRITE8_MEMBER(pio1_pb_w); + void pio1_pb_w(u8 data); }; #endif // MAME_MACHINE_CEDAR_MAGNET_PLANE_H diff --git a/src/mame/machine/cedar_magnet_sprite.cpp b/src/mame/machine/cedar_magnet_sprite.cpp index a871fd3b7ab..3be7bd8466f 100644 --- a/src/mame/machine/cedar_magnet_sprite.cpp +++ b/src/mame/machine/cedar_magnet_sprite.cpp @@ -13,13 +13,11 @@ DEFINE_DEVICE_TYPE(CEDAR_MAGNET_SPRITE, cedar_magnet_sprite_device, "cedmag_sprite", "Cedar Sprite") -cedar_magnet_sprite_device::cedar_magnet_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, CEDAR_MAGNET_SPRITE, tag, owner, clock), - cedar_magnet_board_interface(mconfig, *this, "spritecpu", "ram"), - m_sprite_ram_bankdev(*this, "sp_sub_ram"), - m_pio0(*this, "z80pio0"), - m_pio1(*this, "z80pio1"), - m_pio2(*this, "z80pio2") +cedar_magnet_sprite_device::cedar_magnet_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, CEDAR_MAGNET_SPRITE, tag, owner, clock) + , cedar_magnet_board_interface(mconfig, *this, "spritecpu", "ram") + , m_sprite_ram_bankdev(*this, "sp_sub_ram") + , m_pio(*this, "z80pio%u", 0U) { } @@ -30,7 +28,7 @@ void cedar_magnet_sprite_device::cedar_magnet_sprite_sub_ram_map(address_map &ma map(0x00000, 0x3ffff).ram().share("ram"); } -READ8_MEMBER(cedar_magnet_sprite_device::exzisus_hack_r) +u8 cedar_magnet_sprite_device::exzisus_hack_r(offs_t offset) { //printf("exzisus_hack_r\n"); int pc = m_cpu->pc(); @@ -43,7 +41,7 @@ READ8_MEMBER(cedar_magnet_sprite_device::exzisus_hack_r) } else { - return m_ram[0x400 + offset + (pio2_pb_data & 0x3)*0x10000]; + return m_ram[0x400 + offset + (m_pio2_pb_data & 0x3) * 0x10000]; } } @@ -78,7 +76,7 @@ void cedar_magnet_sprite_device::cedar_magnet_sprite_io(address_map &map) void cedar_magnet_sprite_device::do_blit() { // printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); -// printf("~~~~~~~~~~~~~~~~~ drawing sprite with x:%02x y:%02x code:%04x size:%02x unk:%02x\n", m_loweraddr, m_upperaddr, (m_spritecodehigh << 8) | m_spritecodelow, m_spritesize, pio0_pb_data); +// printf("~~~~~~~~~~~~~~~~~ drawing sprite with x:%02x y:%02x code:%04x size:%02x unk:%02x\n", m_loweraddr, m_upperaddr, (m_spritecodehigh << 8) | m_spritecodelow, m_spritesize, m_pio0_pb_data); // printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); int ysize = 0; @@ -99,8 +97,7 @@ void cedar_magnet_sprite_device::do_blit() ysize = xsize = 64; // m_spritesize - // pio0_pb_data - + // m_pio0_pb_data int source = (m_spritecodehigh << 8) | m_spritecodelow; @@ -109,16 +106,16 @@ void cedar_magnet_sprite_device::do_blit() source &= ~0x3f; - for (int y = 0;y < ysize;y++) + for (int y = 0; y < ysize; y++) { - for (int x = 0;x < xsize;x++) + for (int x = 0; x < xsize; x++) { int xpos = (m_loweraddr + x); int ypos = (m_upperaddr + y); - uint8_t data = m_ram[source + ((m_uppersprite & 0x3) * 0x10000)]; + u8 data = m_ram[source + ((m_uppersprite & 0x3) * 0x10000)]; - if (!(pio0_pb_data & 0x02)) + if (!(m_pio0_pb_data & 0x02)) data = machine().rand(); source++; @@ -128,7 +125,7 @@ void cedar_magnet_sprite_device::do_blit() // without this some sprites incorrectly wraparound on the volcano table. if (!erase) { - if (!(pio0_pb_data & 0x40)) + if (!(m_pio0_pb_data & 0x40)) { if (xpos >= 0xff-64) continue; @@ -159,7 +156,7 @@ void cedar_magnet_sprite_device::do_blit() } } -WRITE8_MEMBER(cedar_magnet_sprite_device::sprite_port80_w) +void cedar_magnet_sprite_device::sprite_port80_w(u8 data) { m_spritecodelow = data; // printf("%s:sprite numlow / trigger %02x\n", machine().describe_context().c_str(), data); @@ -167,28 +164,28 @@ WRITE8_MEMBER(cedar_magnet_sprite_device::sprite_port80_w) do_blit(); } -WRITE8_MEMBER(cedar_magnet_sprite_device::sprite_port84_w) +void cedar_magnet_sprite_device::sprite_port84_w(u8 data) { m_spritecodehigh = data; m_high_write = 1; // printf("%s:sprite numhigh %02x\n", machine().describe_context().c_str(), data); } -WRITE8_MEMBER(cedar_magnet_sprite_device::sprite_port88_w) +void cedar_magnet_sprite_device::sprite_port88_w(u8 data) { // frequent // printf("%s:sprite_y_coordinate %02x\n", machine().describe_context().c_str(), data); m_upperaddr = data; } -WRITE8_MEMBER(cedar_magnet_sprite_device::pio2_pa_w) +void cedar_magnet_sprite_device::pio2_pa_w(u8 data) { // frequent // printf("%s:sprite_x_coordinate %02x\n", machine().describe_context().c_str(), data); m_loweraddr = data; } -WRITE8_MEMBER(cedar_magnet_sprite_device::sprite_port8c_w) +void cedar_magnet_sprite_device::sprite_port8c_w(u8 data) { int address = (m_upperaddr << 8) | m_loweraddr; m_framebuffer[address] = data; @@ -196,7 +193,7 @@ WRITE8_MEMBER(cedar_magnet_sprite_device::sprite_port8c_w) } // possible watchdog? -WRITE8_MEMBER(cedar_magnet_sprite_device::sprite_port9c_w) +void cedar_magnet_sprite_device::sprite_port9c_w(u8 data) { // printf("%s:sprite_port9c_w %02x\n", machine().describe_context().c_str(), data); } @@ -207,33 +204,33 @@ void cedar_magnet_sprite_device::device_add_mconfig(machine_config &config) spritecpu.set_addrmap(AS_PROGRAM, &cedar_magnet_sprite_device::cedar_magnet_sprite_map); spritecpu.set_addrmap(AS_IO, &cedar_magnet_sprite_device::cedar_magnet_sprite_io); - Z80PIO(config, m_pio0, 4000000/2); -// m_pio0->out_int_callback().set_inputline("maincpu", INPUT_LINE_IRQ0); - m_pio0->in_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio0_pa_r)); - m_pio0->out_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio0_pa_w)); -// m_pio0->in_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio0_pb_r)); - m_pio0->out_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio0_pb_w)); + Z80PIO(config, m_pio[0], 4000000/2); +// m_pio[0]->out_int_callback().set_inputline("maincpu", INPUT_LINE_IRQ0); + m_pio[0]->in_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio0_pa_r)); + m_pio[0]->out_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio0_pa_w)); +// m_pio[0]->in_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio0_pb_r)); + m_pio[0]->out_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio0_pb_w)); - Z80PIO(config, m_pio1, 4000000/2); -// m_pio1->out_int_callback().set_inputline("maincpu", INPUT_LINE_IRQ0); -// m_pio1->in_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio1_pa_r)); - m_pio1->out_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio1_pa_w)); -// m_pio1->in_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio1_pb_r)); - m_pio1->out_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio1_pb_w)); + Z80PIO(config, m_pio[1], 4000000/2); +// m_pio[1]->out_int_callback().set_inputline("maincpu", INPUT_LINE_IRQ0); +// m_pio[1]->in_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio1_pa_r)); + m_pio[1]->out_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio1_pa_w)); +// m_pio[1]->in_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio1_pb_r)); + m_pio[1]->out_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio1_pb_w)); - Z80PIO(config, m_pio2, 4000000/2); -// m_pio2->out_int_callback().set_inputline("maincpu", INPUT_LINE_IRQ0); -// m_pio2->in_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio2_pa_r)); - m_pio2->out_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio2_pa_w)); -// m_pio2->in_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio2_pb_r)); - m_pio2->out_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio2_pb_w)); + Z80PIO(config, m_pio[2], 4000000/2); +// m_pio[2]->out_int_callback().set_inputline("maincpu", INPUT_LINE_IRQ0); +// m_pio[2]->in_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio2_pa_r)); + m_pio[2]->out_pa_callback().set(FUNC(cedar_magnet_sprite_device::pio2_pa_w)); +// m_pio[2]->in_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio2_pb_r)); + m_pio[2]->out_pb_callback().set(FUNC(cedar_magnet_sprite_device::pio2_pb_w)); ADDRESS_MAP_BANK(config, m_sprite_ram_bankdev).set_map(&cedar_magnet_sprite_device::cedar_magnet_sprite_sub_ram_map).set_options(ENDIANNESS_LITTLE, 8, 18, 0x10000); } -READ8_MEMBER(cedar_magnet_sprite_device::pio0_pa_r) +u8 cedar_magnet_sprite_device::pio0_pa_r() { // actually read // printf("%s: pio0_pa_r\n", machine().describe_context().c_str()); @@ -241,30 +238,29 @@ READ8_MEMBER(cedar_magnet_sprite_device::pio0_pa_r) } - -WRITE8_MEMBER(cedar_magnet_sprite_device::pio0_pa_w) +void cedar_magnet_sprite_device::pio0_pa_w(u8 data) { m_spritesize = data; } -WRITE8_MEMBER(cedar_magnet_sprite_device::pio0_pb_w) +void cedar_magnet_sprite_device::pio0_pb_w(u8 data) { - pio0_pb_data = data; + m_pio0_pb_data = data; //printf("%s: pio0_pb_w %02x\n", machine().describe_context().c_str(), data); } -WRITE8_MEMBER(cedar_magnet_sprite_device::pio1_pa_w) +void cedar_magnet_sprite_device::pio1_pa_w(u8 data) { //printf("%s: pio1_pa_w %02x\n", machine().describe_context().c_str(), data); } -WRITE8_MEMBER(cedar_magnet_sprite_device::pio1_pb_w) +void cedar_magnet_sprite_device::pio1_pb_w(u8 data) { //printf("%s: pio1_pb_w %02x\n", machine().describe_context().c_str(), data); } -WRITE8_MEMBER(cedar_magnet_sprite_device::pio2_pb_w) +void cedar_magnet_sprite_device::pio2_pb_w(u8 data) { // this feels like a hack // the game writes here when creating the sprite list so that it can access the correct gfd data @@ -277,7 +273,7 @@ WRITE8_MEMBER(cedar_magnet_sprite_device::pio2_pb_w) } - pio2_pb_data = data; + m_pio2_pb_data = data; //printf("%s: ******************************************* BANK? **** pio2_pb_w %02x\n", machine().describe_context().c_str(), data); // yes, it ends up banking the ram right out from under itself during startup execution... // during this time the main cpu is waiting in a loop, after which it copies the startup code again, and reboots it. @@ -287,6 +283,8 @@ WRITE8_MEMBER(cedar_magnet_sprite_device::pio2_pb_w) void cedar_magnet_sprite_device::device_start() { + m_framebuffer = make_unique_clear(0x10000); + save_pointer(NAME(m_framebuffer), 0x10000); } @@ -294,32 +292,31 @@ void cedar_magnet_sprite_device::device_reset() { halt_assert(); m_sprite_ram_bankdev->set_bank(0); - pio2_pb_data = 0x00; + m_pio2_pb_data = 0x00; m_spritesize = 0xff; } -uint32_t cedar_magnet_sprite_device::draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palbase) +u32 cedar_magnet_sprite_device::draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palbase) { // printf("-----------------------------------------------------------------------------------------------------------\n"); // printf("--------------------------------------------- FRAME -------------------------------------------------------\n"); // printf("-----------------------------------------------------------------------------------------------------------\n"); - uint8_t* mem = m_framebuffer; int count = 0; // if (!(m_m_spritesize & 0x40)) // return 0; - for (int y = 0;y < 256;y++) + for (int y = 0; y < 256; y++) { - uint16_t *dst = &bitmap.pix16((y)&0xff); + uint16_t *dst = &bitmap.pix16((y) & 0xff); - for (int x = 0; x < 256;x++) + for (int x = 0; x < 256; x++) { - uint8_t pix = mem[count]; + u8 pix = m_framebuffer[count]; count++; - if (pix) dst[(x)&0xff] = pix + palbase*0x100; + if (pix) dst[(x) & 0xff] = pix + palbase * 0x100; } } diff --git a/src/mame/machine/cedar_magnet_sprite.h b/src/mame/machine/cedar_magnet_sprite.h index c0211a61e3f..3ca8be63d43 100644 --- a/src/mame/machine/cedar_magnet_sprite.h +++ b/src/mame/machine/cedar_magnet_sprite.h @@ -18,19 +18,19 @@ class cedar_magnet_sprite_device : public device_t, public cedar_magnet_board_in { public: // construction/destruction - cedar_magnet_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + cedar_magnet_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - DECLARE_WRITE8_MEMBER(sprite_port80_w); - DECLARE_WRITE8_MEMBER(sprite_port84_w); - DECLARE_WRITE8_MEMBER(sprite_port88_w); - DECLARE_WRITE8_MEMBER(sprite_port8c_w); - DECLARE_WRITE8_MEMBER(sprite_port9c_w); + void sprite_port80_w(u8 data); + void sprite_port84_w(u8 data); + void sprite_port88_w(u8 data); + void sprite_port8c_w(u8 data); + void sprite_port9c_w(u8 data); - DECLARE_READ8_MEMBER(exzisus_hack_r); + u8 exzisus_hack_r(offs_t offset); INTERRUPT_GEN_MEMBER(irq); - uint32_t draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palbase); + u32 draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palbase); void cedar_magnet_sprite_io(address_map &map); void cedar_magnet_sprite_map(address_map &map); @@ -43,40 +43,38 @@ protected: private: void do_blit(); - uint8_t m_framebuffer[0x10000]; - uint8_t pio2_pb_data; + std::unique_ptr m_framebuffer; + u8 m_pio2_pb_data; required_device m_sprite_ram_bankdev; - uint8_t m_upperaddr; - uint8_t m_loweraddr; + u8 m_upperaddr; + u8 m_loweraddr; - uint8_t m_spritesize; - uint8_t pio0_pb_data; - uint8_t m_spritecodelow; - uint8_t m_spritecodehigh; + u8 m_spritesize; + u8 m_pio0_pb_data; + u8 m_spritecodelow; + u8 m_spritecodehigh; int m_high_write; - uint8_t m_uppersprite; + u8 m_uppersprite; - DECLARE_READ8_MEMBER(pio0_pa_r); - DECLARE_WRITE8_MEMBER(pio0_pa_w); + u8 pio0_pa_r(); + void pio0_pa_w(u8 data); // DECLARE_READ8_MEMBER(pio0_pb_r); - DECLARE_WRITE8_MEMBER(pio0_pb_w); + void pio0_pb_w(u8 data); // DECLARE_READ8_MEMBER(pio1_pa_r); - DECLARE_WRITE8_MEMBER(pio1_pa_w); + void pio1_pa_w(u8 data); // DECLARE_READ8_MEMBER(pio1_pb_r); - DECLARE_WRITE8_MEMBER(pio1_pb_w); + void pio1_pb_w(u8 data); // DECLARE_READ8_MEMBER(pio2_pa_r); - DECLARE_WRITE8_MEMBER(pio2_pa_w); + void pio2_pa_w(u8 data); // DECLARE_READ8_MEMBER(pio2_pb_r); - DECLARE_WRITE8_MEMBER(pio2_pb_w); + void pio2_pb_w(u8 data); - required_device m_pio0; - required_device m_pio1; - required_device m_pio2; + required_device_array m_pio; }; #endif // MAME_MACHINE_CEDAR_MAGNET_SPRITE_H