From a6cb1cedc5c1d37c3025e47b709d4ef9f43036b5 Mon Sep 17 00:00:00 2001 From: angelosa Date: Sat, 15 Jun 2024 21:59:06 +0200 Subject: alba/albazg.cpp: cleanups --- src/mame/alba/albazg.cpp | 183 +++++++++++++++++++++------------------------ src/mame/misc/chance32.cpp | 10 +-- 2 files changed, 87 insertions(+), 106 deletions(-) diff --git a/src/mame/alba/albazg.cpp b/src/mame/alba/albazg.cpp index 3298ba6489b..5635b77a5a5 100644 --- a/src/mame/alba/albazg.cpp +++ b/src/mame/alba/albazg.cpp @@ -4,8 +4,6 @@ ZG board (c) 1991 Alba -driver by Angelo Salese - Notes: -The name of this hardware is "Alba ZG board",a newer revision of the "Alba ZC board" used by Hanaroku (seta/albazc.cpp driver). Test mode says clearly that this is @@ -63,15 +61,16 @@ namespace { class albazg_state : public driver_device { public: - albazg_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_cus_ram(*this, "cus_ram"), - m_videoram(*this, "videoram"), - m_colorram(*this, "colorram"), - m_rombank(*this, "rombank"), - m_in(*this, "IN%u", 0U), - m_maincpu(*this, "maincpu"), - m_gfxdecode(*this, "gfxdecode") + albazg_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_custom_ram(*this, "custom_ram") + , m_video_ram(*this, "video_ram") + , m_attr_ram(*this, "attr_ram") + , m_rombank(*this, "rombank") + , m_gfxdecode(*this, "gfxdecode") + , m_key_in(*this, "P1_IN%u", 0U) + , m_coin_in(*this, "COIN") { } virtual void yumefuda(machine_config &config); @@ -83,58 +82,56 @@ protected: private: void vram_w(offs_t offset, uint8_t data); - void cram_w(offs_t offset, uint8_t data); + void attr_w(offs_t offset, uint8_t data); uint8_t custom_ram_r(offs_t offset); void custom_ram_w(offs_t offset, uint8_t data); void prot_lock_w(uint8_t data); - uint8_t mux_r(); - void mux_w(uint8_t data); + uint8_t key_matrix_r(); + void key_matrix_w(uint8_t data); void output_w(uint8_t data); - TILE_GET_INFO_MEMBER(get_bg_tile_info); + TILE_GET_INFO_MEMBER(get_tile_info); uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); void main_map(address_map &map); - void port_map(address_map &map); - - // memory pointers - required_shared_ptr m_cus_ram; - required_shared_ptr m_videoram; - required_shared_ptr m_colorram; - required_memory_bank m_rombank; - - // video-related - tilemap_t *m_bg_tilemap; + void main_io(address_map &map); - // misc - required_ioport_array<7> m_in; - uint8_t m_mux_data; - uint8_t m_bank; - uint8_t m_prot_lock; + tilemap_t *m_tilemap = nullptr; + uint8_t m_port_select = 0; + uint8_t m_prot_lock = 0; required_device m_maincpu; + required_shared_ptr m_custom_ram; + required_shared_ptr m_video_ram; + required_shared_ptr m_attr_ram; + required_memory_bank m_rombank; required_device m_gfxdecode; + + required_ioport_array<6> m_key_in; + required_ioport m_coin_in; }; -TILE_GET_INFO_MEMBER(albazg_state::get_bg_tile_info) +TILE_GET_INFO_MEMBER(albazg_state::get_tile_info) { - int code = m_videoram[tile_index]; - int color = m_colorram[tile_index]; - - tileinfo.set(0, - code + ((color & 0xf8) << 3), - color & 0x7, - 0); + const u8 attr = m_attr_ram[tile_index]; + const u16 code = m_video_ram[tile_index] | ((attr & 0xf8) << 3); + + tileinfo.set( + 0, + code, + attr & 0x7, + 0 + ); } void albazg_state::video_start() { - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(albazg_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + m_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(albazg_state::get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); } uint32_t albazg_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + m_tilemap->draw(screen, bitmap, cliprect, 0, 0); return 0; } @@ -147,28 +144,28 @@ GFXDECODE_END void albazg_state::vram_w(offs_t offset, uint8_t data) { - m_videoram[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset); + m_video_ram[offset] = data; + m_tilemap->mark_tile_dirty(offset); } -void albazg_state::cram_w(offs_t offset, uint8_t data) +void albazg_state::attr_w(offs_t offset, uint8_t data) { - m_colorram[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset); + m_attr_ram[offset] = data; + m_tilemap->mark_tile_dirty(offset); } // Custom RAM (Thrash Protection) uint8_t albazg_state::custom_ram_r(offs_t offset) { LOGPROTRAM("Custom RAM read at %02x PC = %x\n", offset + 0xaf80, m_maincpu->pc()); - return m_cus_ram[offset];// ^ 0x55; + return m_custom_ram[offset];// ^ 0x55; } void albazg_state::custom_ram_w(offs_t offset, uint8_t data) { LOGPROTRAM("Custom RAM write at %02x : %02x PC = %x\n", offset + 0xaf80, data, m_maincpu->pc()); if (m_prot_lock) - m_cus_ram[offset] = data; + m_custom_ram[offset] = data; } // this might be used as NVRAM commands btw @@ -178,47 +175,43 @@ void albazg_state::prot_lock_w(uint8_t data) m_prot_lock = data; } -uint8_t albazg_state::mux_r() +uint8_t albazg_state::key_matrix_r() { - switch(m_mux_data) + u8 res = (m_coin_in->read() & 0xf) | 0xf0; + + for (int i = 0; i < 6; i++) { - case 0x00: return m_in[0]->read(); - case 0x01: return m_in[1]->read(); - case 0x02: return m_in[2]->read(); - case 0x04: return m_in[3]->read(); - case 0x08: return m_in[4]->read(); - case 0x10: return m_in[5]->read(); - case 0x20: return m_in[6]->read(); + // TODO: unverified (and likely not working) multi select + // (both games just access this one bit at a time, selects with 0x00 for accessing coin section above) + if (BIT(m_port_select, i)) + { + res &= 0xf; + res |= m_key_in[i]->read() & 0xf0; + } } - return 0xff; + return res; } -void albazg_state::mux_w(uint8_t data) +void albazg_state::key_matrix_w(uint8_t data) { - uint8_t new_bank = (data & 0xc0) >> 6; - //0x10000 "Learn Mode" //0x12000 gameplay //0x14000 bonus game //0x16000 ? - if (m_bank != new_bank) - { - m_bank = new_bank; - m_rombank->set_entry(m_bank); - } + m_rombank->set_entry((data & 0xc0) >> 6); - m_mux_data = data & ~0xc0; + m_port_select = data & ~0xc0; } void albazg_state::output_w(uint8_t data) { - machine().bookkeeping().coin_counter_w(0, ~data & 4); - machine().bookkeeping().coin_counter_w(1, ~data & 2); + machine().bookkeeping().coin_counter_w(0, BIT(~data, 2)); + machine().bookkeeping().coin_counter_w(1, BIT(~data, 1)); machine().bookkeeping().coin_lockout_global_w(data & 1); - //data & 0x10 hopper-c (active LOW) - //data & 0x08 divider (active HIGH) - flip_screen_set(~data & 0x20); + //BIT(data, 4) hopper-c (active LOW) + //BIT(data, 3) divider (active HIGH) + flip_screen_set(BIT(~data, 5)); } /***************************************************************************************/ @@ -229,22 +222,22 @@ void albazg_state::main_map(address_map &map) map(0x8000, 0x9fff).bankr(m_rombank); map(0xa7fc, 0xa7fc).w(FUNC(albazg_state::prot_lock_w)); map(0xa7ff, 0xa7ff).portw("EEPROMOUT"); - map(0xaf80, 0xafff).rw(FUNC(albazg_state::custom_ram_r), FUNC(albazg_state::custom_ram_w)).share(m_cus_ram); + map(0xaf80, 0xafff).rw(FUNC(albazg_state::custom_ram_r), FUNC(albazg_state::custom_ram_w)).share(m_custom_ram); map(0xb000, 0xb07f).ram().w("palette", FUNC(palette_device::write8)).share("palette"); map(0xb080, 0xb0ff).ram().w("palette", FUNC(palette_device::write8_ext)).share("palette_ext"); - map(0xc000, 0xc3ff).ram().w(FUNC(albazg_state::vram_w)).share(m_videoram); - map(0xd000, 0xd3ff).ram().w(FUNC(albazg_state::cram_w)).share(m_colorram); + map(0xc000, 0xc3ff).ram().w(FUNC(albazg_state::vram_w)).share(m_video_ram); + map(0xd000, 0xd3ff).ram().w(FUNC(albazg_state::attr_w)).share(m_attr_ram); map(0xe000, 0xffff).ram(); } -void albazg_state::port_map(address_map &map) +void albazg_state::main_io(address_map &map) { map.global_mask(0xff); map(0x00, 0x00).w("crtc", FUNC(mc6845_device::address_w)); map(0x01, 0x01).w("crtc", FUNC(mc6845_device::register_w)); map(0x40, 0x40).r("aysnd", FUNC(ay8910_device::data_r)); map(0x40, 0x41).w("aysnd", FUNC(ay8910_device::address_data_w)); - map(0x80, 0x83).rw("ppi8255_0", FUNC(i8255_device::read), FUNC(i8255_device::write)); + map(0x80, 0x83).rw("ppi", FUNC(i8255_device::read), FUNC(i8255_device::write)); map(0xc0, 0xc0).w("watchdog", FUNC(watchdog_timer_device::reset_w)); } @@ -261,14 +254,14 @@ static INPUT_PORTS_START( yumefuda ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, do_read) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START("IN0") + PORT_START("COIN") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 Flip-Flop") PORT_CODE(KEYCODE_Y) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_NAME("Coupon") PORT_IMPULSE(2) //coupon PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_NAME("Note") PORT_IMPULSE(2) //note PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2) PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START("IN1") + PORT_START("P1_IN0") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_HANAFUDA_A ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x08) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_HANAFUDA_B ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x08) @@ -279,7 +272,7 @@ static INPUT_PORTS_START( yumefuda ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("P1 Start") PORT_CONDITION("DSW2", 0x08, EQUALS, 0x00) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x00) - PORT_START("IN2") + PORT_START("P1_IN1") PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_HANAFUDA_E ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x08) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_HANAFUDA_NO ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x08) @@ -290,7 +283,7 @@ static INPUT_PORTS_START( yumefuda ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_HANAFUDA_A ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x00) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_HANAFUDA_D ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x00) - PORT_START("IN3") + PORT_START("P1_IN2") PORT_BIT( 0x9f, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("P1 Start") PORT_CONDITION("DSW2", 0x08, EQUALS, 0x08) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 BET Button") PORT_CODE(KEYCODE_3) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x08) @@ -298,17 +291,17 @@ static INPUT_PORTS_START( yumefuda ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_HANAFUDA_E ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x00) // Some bits of these three are actually used if you use the Royal Panel type - PORT_START("IN4") + PORT_START("P1_IN3") PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START("IN5") + PORT_START("P1_IN4") PORT_BIT( 0x9f, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x08) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x08) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_HANAFUDA_NO ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x00) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_HANAFUDA_YES ) PORT_CONDITION("DSW2", 0x08, EQUALS, 0x00) - PORT_START("IN6") + PORT_START("P1_IN5") PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START( "EEPROMOUT" ) @@ -351,40 +344,34 @@ INPUT_PORTS_END void albazg_state::machine_start() { - uint8_t *ROM = memregion("maincpu")->base(); - - m_rombank->configure_entries(0, 4, &ROM[0x8000], 0x2000); + m_rombank->configure_entries(0, 4, memregion("maincpu")->base() + 0x8000, 0x2000); - save_item(NAME(m_mux_data)); - save_item(NAME(m_bank)); + save_item(NAME(m_port_select)); save_item(NAME(m_prot_lock)); } void albazg_state::machine_reset() { - m_mux_data = 0; - m_bank = -1; + m_port_select = 0; m_prot_lock = 0; } void albazg_state::yumefuda(machine_config &config) { - // basic machine hardware Z80(config, m_maincpu, 12_MHz_XTAL / 2); // unknown divider m_maincpu->set_addrmap(AS_PROGRAM, &albazg_state::main_map); - m_maincpu->set_addrmap(AS_IO, &albazg_state::port_map); + m_maincpu->set_addrmap(AS_IO, &albazg_state::main_io); m_maincpu->set_vblank_int("screen", FUNC(albazg_state::irq0_line_hold)); EEPROM_93C46_16BIT(config, "eeprom"); WATCHDOG_TIMER(config, "watchdog").set_vblank_count("screen", 8); // timing is unknown - i8255_device &ppi(I8255A(config, "ppi8255_0")); - ppi.out_pa_callback().set(FUNC(albazg_state::mux_w)); + i8255_device &ppi(I8255A(config, "ppi")); + ppi.out_pa_callback().set(FUNC(albazg_state::key_matrix_w)); ppi.in_pb_callback().set_ioport("SYSTEM"); - ppi.in_pc_callback().set(FUNC(albazg_state::mux_r)); + ppi.in_pc_callback().set(FUNC(albazg_state::key_matrix_r)); - // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_refresh_hz(60); screen.set_vblank_time(ATTOSECONDS_IN_USEC(0)); @@ -392,7 +379,7 @@ void albazg_state::yumefuda(machine_config &config) screen.set_visarea_full(); screen.set_screen_update(FUNC(albazg_state::screen_update)); - hd6845s_device &crtc(HD6845S(config, "crtc", 12_MHz_XTAL / 16)); // hand tuned to get ~60 fps + hd6845s_device &crtc(HD6845S(config, "crtc", 12_MHz_XTAL / 16)); // hand tuned to get ~60 fps crtc.set_screen("screen"); crtc.set_show_border_area(false); crtc.set_char_width(8); @@ -400,8 +387,6 @@ void albazg_state::yumefuda(machine_config &config) GFXDECODE(config, m_gfxdecode, "palette", gfx_yumefuda); PALETTE(config, "palette").set_format(palette_device::xRGB_555, 0x80); - - // sound hardware SPEAKER(config, "mono").front_center(); ay8910_device &aysnd(AY8910(config, "aysnd", 12_MHz_XTAL / 16)); // guessed to use the same xtal as the crtc diff --git a/src/mame/misc/chance32.cpp b/src/mame/misc/chance32.cpp index 8b8f0ab266e..76592cf755b 100644 --- a/src/mame/misc/chance32.cpp +++ b/src/mame/misc/chance32.cpp @@ -85,8 +85,8 @@ private: template TILE_GET_INFO_MEMBER(chance32_state::get_tile_info) { - int code = (m_vram[N][tile_index * 2 + 1] << 8) | m_vram[N][tile_index * 2]; - int flip = (~code >> 12) & 1; + const u16 code = (m_vram[N][tile_index * 2 + 1] << 8) | m_vram[N][tile_index * 2]; + const u8 flip = (~code >> 12) & 1; tileinfo.set( N, code & 0x0fff, @@ -455,13 +455,11 @@ void chance32_state::machine_reset() void chance32_state::chance32(machine_config &config) { - /* basic machine hardware */ Z80(config, m_maincpu, 12000000/2); m_maincpu->set_addrmap(AS_PROGRAM, &chance32_state::main_map); m_maincpu->set_addrmap(AS_IO, &chance32_state::main_io); m_maincpu->set_vblank_int("screen", FUNC(chance32_state::irq0_line_hold)); - /* video hardware */ screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_refresh_hz(52.786); // screen.set_refresh_hz(60); @@ -470,8 +468,7 @@ void chance32_state::chance32(machine_config &config) screen.set_visarea(0, 35*16-1, 0, 29*8-1); screen.set_screen_update(FUNC(chance32_state::screen_update)); - /* 52.786 Hz (similar to Major Poker) */ - hd6845s_device &crtc(HD6845S(config, "crtc", 12000000/16)); + hd6845s_device &crtc(HD6845S(config, "crtc", 12000000/16)); // 52.786 Hz (similar to Major Poker) crtc.set_screen("screen"); crtc.set_show_border_area(false); crtc.set_char_width(16); @@ -479,7 +476,6 @@ void chance32_state::chance32(machine_config &config) GFXDECODE(config, m_gfxdecode, "palette", gfx_chance32); PALETTE(config, "palette").set_format(palette_device::xGRB_555, 0x800); - /* sound hardware */ SPEAKER(config, "mono").front_center(); /* clock at 1050 kHz match the 8000 Hz samples stored inside the ROM */ -- cgit v1.2.3