From cfd5ebbc2e6c038bd3544a2e34db6ad0a698be2d Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Tue, 30 Nov 2021 15:33:01 +0100 Subject: poker72.cpp: updated to use a finder for the memory back and other minor cleanups --- src/mame/drivers/poker72.cpp | 112 ++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 50 deletions(-) diff --git a/src/mame/drivers/poker72.cpp b/src/mame/drivers/poker72.cpp index e4e6f218f82..beb3599a2a3 100644 --- a/src/mame/drivers/poker72.cpp +++ b/src/mame/drivers/poker72.cpp @@ -3,7 +3,7 @@ /************************************************************************************************ Poker Monarch - GFX roms contain + GFX ROMs contain 'Extrema Systems International Ltd' as well as a logo for the company. @@ -19,13 +19,18 @@ *************************************************************************************************/ #include "emu.h" + +#include "cpu/mcs51/mcs51.h" #include "cpu/z80/z80.h" #include "sound/ay8910.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { + class poker72_state : public driver_device { public: @@ -35,7 +40,8 @@ public: m_pal(*this, "pal"), m_maincpu(*this, "maincpu"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") + m_palette(*this, "palette"), + m_rombank(*this, "rombank") { } void poker72(machine_config &config); @@ -49,51 +55,54 @@ protected: private: required_shared_ptr m_vram; required_shared_ptr m_pal; - uint8_t m_tile_bank; required_device m_maincpu; required_device m_gfxdecode; required_device m_palette; + required_memory_bank m_rombank; - void poker72_paletteram_w(offs_t offset, uint8_t data); + uint8_t m_tile_bank; + + void paletteram_w(offs_t offset, uint8_t data); void output_w(uint8_t data); void tile_bank_w(uint8_t data); - void poker72_palette(palette_device &palette) const; - uint32_t screen_update_poker72(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void poker72_map(address_map &map); + void palette(palette_device &palette) const; + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void prg_map(address_map &map); }; void poker72_state::video_start() { + m_tile_bank = 0; + + save_item(NAME(m_tile_bank)); } -uint32_t poker72_state::screen_update_poker72(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +uint32_t poker72_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int x,y,count; + int count = 0; - count = 0; - - for (y=0;y<32;y++) + for (int y = 0; y < 32; y++) { - for (x=0;x<64;x++) + for (int x = 0; x < 64; x++) { - int tile = ((m_vram[count+1] & 0x0f) << 8 ) | (m_vram[count+0] & 0xff); //TODO: tile bank - int fx = (m_vram[count+1] & 0x10); - int fy = (m_vram[count+1] & 0x20); - int color = (m_vram[count+1] & 0xc0) >> 6; + int tile = ((m_vram[count + 1] & 0x0f) << 8 ) | (m_vram[count+0] & 0xff); //TODO: tile bank + int fx = (m_vram[count + 1] & 0x10); + int fy = (m_vram[count + 1] & 0x20); + int color = (m_vram[count + 1] & 0xc0) >> 6; tile|= m_tile_bank << 12; - m_gfxdecode->gfx(0)->opaque(bitmap,cliprect,tile,color,fx,fy,x*8,y*8); + m_gfxdecode->gfx(0)->opaque(bitmap, cliprect, tile, color, fx, fy, x * 8, y * 8); - count+=2; + count += 2; } } return 0; } -void poker72_state::poker72_paletteram_w(offs_t offset, uint8_t data) +void poker72_state::paletteram_w(offs_t offset, uint8_t data) { m_pal[offset] = data; @@ -106,15 +115,15 @@ void poker72_state::poker72_paletteram_w(offs_t offset, uint8_t data) void poker72_state::output_w(uint8_t data) { - printf("%02x\n",data); + logerror("output_w: %02x\n", data); -/* if((data & 0xc) == 0xc) - membank("bank1")->set_entry(2); +/* if ((data & 0xc) == 0xc) + m_rombank->set_entry(2); else*/ - if(data & 8) - membank("bank1")->set_entry(1); + if (data & 8) + m_rombank->set_entry(1); else - membank("bank1")->set_entry(0); + m_rombank->set_entry(0); } void poker72_state::tile_bank_w(uint8_t data) @@ -122,12 +131,12 @@ void poker72_state::tile_bank_w(uint8_t data) m_tile_bank = (data & 4) >> 2; } -void poker72_state::poker72_map(address_map &map) +void poker72_state::prg_map(address_map &map) { - map(0x0000, 0x7fff).bankr("bank1"); + map(0x0000, 0x7fff).bankr(m_rombank); map(0xc000, 0xdfff).ram(); //work ram - map(0xe000, 0xefff).ram().share("vram"); - map(0xf000, 0xfbff).ram().w(FUNC(poker72_state::poker72_paletteram_w)).share("pal"); + map(0xe000, 0xefff).ram().share(m_vram); + map(0xf000, 0xfbff).ram().w(FUNC(poker72_state::paletteram_w)).share(m_pal); map(0xfc00, 0xfdff).ram(); //??? map(0xfe08, 0xfe08).portr("SW1"); map(0xfe09, 0xfe09).portr("IN1"); @@ -333,8 +342,6 @@ static INPUT_PORTS_START( poker72 ) PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) - - INPUT_PORTS_END static const gfx_layout tiles8x8_layout = @@ -351,11 +358,11 @@ static const gfx_layout tiles8x8_layout = static GFXDECODE_START( gfx_poker72 ) - GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout, 0, 16 ) + GFXDECODE_ENTRY( "tiles", 0, tiles8x8_layout, 0, 16 ) GFXDECODE_END -/* default 444 palette for debug purpose */ -void poker72_state::poker72_palette(palette_device &palette) const +// default 444 palette for debug purpose +void poker72_state::palette(palette_device &palette) const { for (int x = 0; x < 0x100; x++) { @@ -368,31 +375,33 @@ void poker72_state::poker72_palette(palette_device &palette) const void poker72_state::machine_reset() { - membank("bank1")->set_entry(0); + m_rombank->set_entry(0); } void poker72_state::poker72(machine_config &config) { - /* basic machine hardware */ - Z80(config, m_maincpu, 8000000); /* ? MHz */ - m_maincpu->set_addrmap(AS_PROGRAM, &poker72_state::poker72_map); + // basic machine hardware + Z80(config, m_maincpu, 8000000); // ? MHz + m_maincpu->set_addrmap(AS_PROGRAM, &poker72_state::prg_map); m_maincpu->set_vblank_int("screen", FUNC(poker72_state::irq0_line_hold)); - /* video hardware */ + I80C51(config, "subcpu", 8000000); // actually 89C51, ? MHz + + // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_refresh_hz(60); screen.set_vblank_time(ATTOSECONDS_IN_USEC(0)); screen.set_size(64*8, 32*8); screen.set_visarea(0, 64*8-1, 0, 32*8-1); - screen.set_screen_update(FUNC(poker72_state::screen_update_poker72)); + screen.set_screen_update(FUNC(poker72_state::screen_update)); screen.set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_poker72); - PALETTE(config, m_palette, FUNC(poker72_state::poker72_palette), 0xe00); + PALETTE(config, m_palette, FUNC(poker72_state::palette), 0xe00); SPEAKER(config, "mono").front_center(); - ay8910_device &ay(AY8910(config, "ay", 8000000/8)); /* ? Mhz */ + ay8910_device &ay(AY8910(config, "ay", 8000000 / 8)); // ? Mhz ay.port_a_read_callback().set_ioport("SW2"); ay.port_b_read_callback().set_ioport("SW3"); ay.add_route(ALL_OUTPUTS, "mono", 0.50); @@ -401,13 +410,13 @@ void poker72_state::poker72(machine_config &config) ROM_START( poker72 ) - ROM_REGION( 0x20000, "roms", 0 ) + ROM_REGION( 0x20000, "maincpu", 0 ) ROM_LOAD( "27010.bin", 0x00000, 0x20000, CRC(62447341) SHA1(e442c1f834a5dd2ab6ab3bdd316dfa86f2ca6647) ) - ROM_REGION( 0x1000, "89c51", 0 ) + ROM_REGION( 0x1000, "subcpu", 0 ) ROM_LOAD( "89c51.bin", 0x00000, 0x1000, CRC(3fdd2148) SHA1(ea39a52482967268c7387aec77cfab1ae5c427fa) ) - ROM_REGION( 0x80000, "gfx1", 0 ) + ROM_REGION( 0x80000, "tiles", 0 ) ROM_LOAD( "270135.bin", 0x00000, 0x20000, CRC(188c96ee) SHA1(7e883454cb080cdc82ce47ac92f51c8d45a55085) ) ROM_LOAD( "270136.bin", 0x20000, 0x20000, CRC(f84c5068) SHA1(49178fe7b12f547a50879002236105a882767ebb) ) ROM_LOAD( "270137.bin", 0x40000, 0x20000, CRC(310281d1) SHA1(c28f97bb3613c0b481ab6e16e215549c44b83c47) ) @@ -416,14 +425,17 @@ ROM_END void poker72_state::init_poker72() { - uint8_t *rom = memregion("roms")->base(); + uint8_t *rom = memregion("maincpu")->base(); - // configure and intialize bank 1 - membank("bank1")->configure_entries(0, 4, memregion("roms")->base(), 0x8000); - membank("bank1")->set_entry(0); + // configure and initialize bank 1 + m_rombank->configure_entries(0, 4, memregion("maincpu")->base(), 0x8000); + m_rombank->set_entry(0); //rom[0x4a9] = 0x28; rom[0x4aa] = 0x00; } +} // Anonymous namespace + + GAME( 1995, poker72, 0, poker72, poker72, poker72_state, init_poker72, ROT0, "Extrema Systems International Ltd.", "Poker Monarch (v2.50)", MACHINE_NOT_WORKING ) -- cgit v1.2.3