From e893c175ea7ac89ba30172dd09960c30777209f7 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Wed, 6 Jul 2022 18:04:05 +0200 Subject: supduck.cpp: used finder for memory bank and other minor cleanups --- src/mame/capcom/supduck.cpp | 182 +++++++++++++++++++++++--------------------- src/mame/misc/39in1.cpp | 4 +- 2 files changed, 96 insertions(+), 90 deletions(-) diff --git a/src/mame/capcom/supduck.cpp b/src/mame/capcom/supduck.cpp index 318d4474da8..8cdc103d312 100644 --- a/src/mame/capcom/supduck.cpp +++ b/src/mame/capcom/supduck.cpp @@ -29,17 +29,33 @@ There are known flyers that show an alternate title of HELL OUT #include "emu.h" + +#include "tigeroad_spr.h" + #include "cpu/z80/z80.h" #include "cpu/m68000/m68000.h" #include "machine/gen_latch.h" #include "sound/okim6295.h" #include "video/bufsprite.h" -#include "tigeroad_spr.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" #include "tilemap.h" + +// configurable logging +#define LOG_UNKWRITE (1U << 1) + +//#define VERBOSE (LOG_GENERAL | LOG_UNKWRITE) + +#include "logmacro.h" + +#define LOGUNKWRITE(...) LOGMASKED(LOG_UNKWRITE, __VA_ARGS__) + + +namespace { + class supduck_state : public driver_device { public: @@ -48,48 +64,52 @@ public: , m_maincpu(*this, "maincpu") , m_audiocpu(*this, "audiocpu") , m_spriteram(*this, "spriteram") - , m_text_videoram(*this, "textvideoram") - , m_fore_videoram(*this, "forevideoram") - , m_back_videoram(*this, "backvideoram") , m_gfxdecode(*this, "gfxdecode") , m_palette(*this, "palette") , m_spritegen(*this, "spritegen") - , m_soundlatch(*this, "soundlatch") + , m_text_videoram(*this, "textvideoram") + , m_fore_videoram(*this, "forevideoram") + , m_back_videoram(*this, "backvideoram") + , m_okibank(*this, "okibank") { } void supduck(machine_config &config); +protected: + // driver_device overrides + virtual void machine_start() override; + + virtual void video_start() override; + private: // devices required_device m_maincpu; required_device m_audiocpu; + required_device m_spriteram; + required_device m_gfxdecode; + required_device m_palette; + required_device m_spritegen; // shared pointers - required_device m_spriteram; required_shared_ptr m_text_videoram; required_shared_ptr m_fore_videoram; required_shared_ptr m_back_videoram; + required_memory_bank m_okibank; - required_device m_gfxdecode; - required_device m_palette; - required_device m_spritegen; - required_device m_soundlatch; - - tilemap_t *m_text_tilemap = nullptr; - tilemap_t *m_fore_tilemap = nullptr; - tilemap_t *m_back_tilemap = nullptr; + tilemap_t *m_text_tilemap = nullptr; + tilemap_t *m_fore_tilemap = nullptr; + tilemap_t *m_back_tilemap = nullptr; uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void text_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); void fore_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); void back_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void supduck_scroll_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void scroll_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void supduck_4000_w(uint16_t data); - void supduck_4002_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void coincounter_w(uint8_t data); - TILEMAP_MAPPER_MEMBER(supduk_tilemap_scan); + TILEMAP_MAPPER_MEMBER(tilemap_scan); void okibank_w(uint8_t data); @@ -97,12 +117,6 @@ private: void oki_map(address_map &map); void sound_map(address_map &map); - // driver_device overrides - virtual void machine_start() override; - virtual void machine_reset() override; - - virtual void video_start() override; - TILE_GET_INFO_MEMBER(get_text_tile_info); TILE_GET_INFO_MEMBER(get_fore_tile_info); TILE_GET_INFO_MEMBER(get_back_tile_info); @@ -111,18 +125,18 @@ private: -TILEMAP_MAPPER_MEMBER(supduck_state::supduk_tilemap_scan) +TILEMAP_MAPPER_MEMBER(supduck_state::tilemap_scan) { // where does each page start? int pagesize = 0x8 * 0x8; int offset = ((col & ~0x7) / 0x8) * (pagesize); - offset += ((row^0x3f) & 0x7)*0x8; + offset += ((row ^ 0x3f) & 0x7) * 0x8; offset += col & 0x7; offset &= 0x3ff; - offset += (((row^0x3f) & ~0x7) / 0x8) * 0x400; + offset += (((row ^ 0x3f) & ~0x7) / 0x8) * 0x400; return offset; @@ -132,8 +146,8 @@ void supduck_state::video_start() { m_text_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(supduck_state::get_text_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); - m_fore_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(supduck_state::get_fore_tile_info)), tilemap_mapper_delegate(*this, FUNC(supduck_state::supduk_tilemap_scan)), 32, 32, 128,64); - m_back_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(supduck_state::get_back_tile_info)), tilemap_mapper_delegate(*this, FUNC(supduck_state::supduk_tilemap_scan)), 32, 32, 128,64); + m_fore_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(supduck_state::get_fore_tile_info)), tilemap_mapper_delegate(*this, FUNC(supduck_state::tilemap_scan)), 32, 32, 128, 64); + m_back_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(supduck_state::get_back_tile_info)), tilemap_mapper_delegate(*this, FUNC(supduck_state::tilemap_scan)), 32, 32, 128, 64); m_text_tilemap->set_transparent_pen(0x3); m_fore_tilemap->set_transparent_pen(0xf); @@ -179,10 +193,9 @@ void supduck_state::back_videoram_w(offs_t offset, uint16_t data, uint16_t mem_m } -TILE_GET_INFO_MEMBER(supduck_state::get_text_tile_info) // same as tigeroad.c +TILE_GET_INFO_MEMBER(supduck_state::get_text_tile_info) // same as tigeroad.cpp { - uint16_t *videoram = m_text_videoram; - int data = videoram[tile_index]; + int data = m_text_videoram[tile_index]; int attr = data >> 8; int code = (data & 0xff) + ((attr & 0xc0) << 2) + ((attr & 0x20) << 5); int color = attr & 0x0f; @@ -193,13 +206,12 @@ TILE_GET_INFO_MEMBER(supduck_state::get_text_tile_info) // same as tigeroad.c TILE_GET_INFO_MEMBER(supduck_state::get_fore_tile_info) { - uint16_t *videoram = m_fore_videoram; - int data = videoram[tile_index]; + int data = m_fore_videoram[tile_index]; int code = data & 0xff; if (data & 0x4000) code |= 0x100; if (data & 0x8000) code |= 0x200; - int color = (data & 0x0f00)>>8; + int color = (data & 0x0f00) >> 8; int flags = (data & 0x2000) ? TILE_FLIPX : 0; flags |=(data & 0x1000) ? TILE_FLIPY : 0; @@ -209,14 +221,13 @@ TILE_GET_INFO_MEMBER(supduck_state::get_fore_tile_info) TILE_GET_INFO_MEMBER(supduck_state::get_back_tile_info) { - uint16_t *videoram = m_back_videoram; - int data = videoram[tile_index]; + int data = m_back_videoram[tile_index]; int code = data & 0xff; if (data & 0x4000) code |= 0x100; if (data & 0x8000) code |= 0x200; - int color = (data & 0x0f00)>>8; + int color = (data & 0x0f00) >> 8; int flags = (data & 0x2000) ? TILE_FLIPX : 0; flags |=(data & 0x1000) ? TILE_FLIPY : 0; @@ -225,21 +236,17 @@ TILE_GET_INFO_MEMBER(supduck_state::get_back_tile_info) -void supduck_state::supduck_4000_w(uint16_t data) +void supduck_state::coincounter_w(uint8_t data) { -} - - -void supduck_state::supduck_4002_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - data &= mem_mask; - - m_soundlatch->write((data>>8)); - m_audiocpu->set_input_line(0, HOLD_LINE); + machine().bookkeeping().coin_counter_w(0, BIT(data, 6)); + machine().bookkeeping().coin_counter_w(1, BIT(data, 7)); + if (data != 0) + LOGUNKWRITE("unknown write at 0xfe4000: %02x\n", data & 0x3f); } -void supduck_state::supduck_scroll_w(offs_t offset, uint16_t data, uint16_t mem_mask) + +void supduck_state::scroll_w(offs_t offset, uint16_t data, uint16_t mem_mask) { data &= mem_mask; @@ -267,18 +274,20 @@ void supduck_state::main_map(address_map &map) map(0x000000, 0x03ffff).rom().nopw(); map(0xfe0000, 0xfe1fff).ram().share("spriteram"); - map(0xfe4000, 0xfe4001).portr("P1_P2").w(FUNC(supduck_state::supduck_4000_w)); - map(0xfe4002, 0xfe4003).portr("SYSTEM").w(FUNC(supduck_state::supduck_4002_w)); + map(0xfe4000, 0xfe4001).portr("P1_P2"); + map(0xfe4000, 0xfe4000).w(FUNC(supduck_state::coincounter_w)); + map(0xfe4002, 0xfe4003).portr("SYSTEM"); + map(0xfe4002, 0xfe4002).w("soundlatch", FUNC(generic_latch_8_device::write)); map(0xfe4004, 0xfe4005).portr("DSW"); - map(0xfe8000, 0xfe8007).w(FUNC(supduck_state::supduck_scroll_w)); + map(0xfe8000, 0xfe8007).w(FUNC(supduck_state::scroll_w)); map(0xfe800e, 0xfe800f).nopw(); // watchdog or irqack - map(0xfec000, 0xfecfff).ram().w(FUNC(supduck_state::text_videoram_w)).share("textvideoram"); - map(0xff0000, 0xff3fff).ram().w(FUNC(supduck_state::back_videoram_w)).share("backvideoram"); - map(0xff4000, 0xff7fff).ram().w(FUNC(supduck_state::fore_videoram_w)).share("forevideoram"); + map(0xfec000, 0xfecfff).ram().w(FUNC(supduck_state::text_videoram_w)).share(m_text_videoram); + map(0xff0000, 0xff3fff).ram().w(FUNC(supduck_state::back_videoram_w)).share(m_back_videoram); + map(0xff4000, 0xff7fff).ram().w(FUNC(supduck_state::fore_videoram_w)).share(m_fore_videoram); map(0xff8000, 0xff87ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0xffc000, 0xffffff).ram(); /* working RAM */ + map(0xffc000, 0xffffff).ram(); // working RAM } void supduck_state::sound_map(address_map &map) @@ -287,20 +296,20 @@ void supduck_state::sound_map(address_map &map) map(0x8000, 0x87ff).ram(); map(0x9000, 0x9000).w(FUNC(supduck_state::okibank_w)); map(0x9800, 0x9800).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); - map(0xa000, 0xa000).r(m_soundlatch, FUNC(generic_latch_8_device::read)); + map(0xa000, 0xa000).r("soundlatch", FUNC(generic_latch_8_device::read)); } void supduck_state::oki_map(address_map &map) { map(0x00000, 0x1ffff).rom(); - map(0x20000, 0x3ffff).bankr("okibank"); + map(0x20000, 0x3ffff).bankr(m_okibank); } void supduck_state::okibank_w(uint8_t data) { // bit 0x80 is written on startup? - membank("okibank")->set_entry(data&0x03); + m_okibank->set_entry(data & 0x03); } @@ -327,7 +336,7 @@ static INPUT_PORTS_START( supduck ) PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 ) - PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* not sure, probably wrong */ + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") // not sure, probably wrong PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_SERVICE1 ) @@ -350,7 +359,7 @@ static INPUT_PORTS_START( supduck ) PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("DIP-A:5") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0010, DEF_STR( On ) ) - PORT_DIPNAME( 0x0020, 0x0020, "Game Sound" ) PORT_DIPLOCATION("DIP-A:6") /* Kills all sounds except for Coin-In */ + PORT_DIPNAME( 0x0020, 0x0020, "Game Sound" ) PORT_DIPLOCATION("DIP-A:6") // Kills all sounds except for Coin-In PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0020, DEF_STR( On ) ) PORT_DIPNAME( 0x00c0, 0x0080, DEF_STR( Lives ) ) PORT_DIPLOCATION("DIP-A:7,8") @@ -385,20 +394,20 @@ INPUT_PORTS_END static const gfx_layout vramlayout= { - 8,8, /* 8*8 characters */ - RGN_FRAC(1,1), /* 1024 character */ - 2, /* 2 bitplanes */ + 8,8, // 8*8 characters + RGN_FRAC(1,1), // 1024 character + 2, // 2 bitplanes { 4,0 }, { STEP4(0,1), STEP4(4*2,1) }, { STEP8(0,4*2*2) }, - 128 /* every character takes 128 consecutive bytes */ + 128 // every character takes 128 consecutive bytes }; // same as the ROM tilemap layout from tigeroad static const gfx_layout tile_layout = { 32, 32, - RGN_FRAC(1, 2), + RGN_FRAC(1,2), 4, { RGN_FRAC(1,2)+4, RGN_FRAC(1,2)+0, 4, 0 }, { STEP4(0,1), STEP4(4*2,1), STEP4(4*2*2*32,1), STEP4(4*2*2*32+4*2,1), @@ -409,31 +418,27 @@ static const gfx_layout tile_layout = static GFXDECODE_START( gfx_supduck ) - GFXDECODE_ENTRY( "gfx1", 0, vramlayout, 768, 64 ) /* colors 768-1023 */ - GFXDECODE_ENTRY( "gfx2", 0, tile_layout, 0, 16 ) /* colors 0- 63 */ - GFXDECODE_ENTRY( "gfx3", 0, tile_layout, 256, 16 ) /* colors 256- 319 */ + GFXDECODE_ENTRY( "chars", 0, vramlayout, 768, 64 ) // colors 768-1023 + GFXDECODE_ENTRY( "fgtiles", 0, tile_layout, 0, 16 ) // colors 0- 63 + GFXDECODE_ENTRY( "bgtiles", 0, tile_layout, 256, 16 ) // colors 256- 319 GFXDECODE_END void supduck_state::machine_start() { - membank("okibank")->configure_entries(0, 4, memregion("okibank")->base(), 0x20000); - membank("okibank")->set_entry(0); -} - -void supduck_state::machine_reset() -{ + m_okibank->configure_entries(0, 4, memregion("okibank")->base(), 0x20000); + m_okibank->set_entry(0); } void supduck_state::supduck(machine_config &config) { - /* basic machine hardware */ - M68000(config, m_maincpu, XTAL(8'000'000)); /* Verified on PCB */ + // basic machine hardware + M68000(config, m_maincpu, XTAL(8'000'000)); // Verified on PCB m_maincpu->set_addrmap(AS_PROGRAM, &supduck_state::main_map); m_maincpu->set_vblank_int("screen", FUNC(supduck_state::irq2_line_hold)); // 2 & 4? - Z80(config, m_audiocpu, XTAL(8'000'000)/4); /* 2MHz - verified on PCB */ + Z80(config, m_audiocpu, XTAL(8'000'000) / 4); // 2MHz - verified on PCB m_audiocpu->set_addrmap(AS_PROGRAM, &supduck_state::sound_map); /* video hardware */ @@ -449,16 +454,16 @@ void supduck_state::supduck(machine_config &config) TIGEROAD_SPRITE(config, m_spritegen, 0); m_spritegen->set_palette(m_palette); - m_spritegen->set_color_base(512); /* colors 512- 767 */ + m_spritegen->set_color_base(512); // colors 512- 767 - PALETTE(config, m_palette).set_format(palette_device::xRGBRRRRGGGGBBBB_bit4, 0x800/2); + PALETTE(config, m_palette).set_format(palette_device::xRGBRRRRGGGGBBBB_bit4, 0x800 / 2); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); - GENERIC_LATCH_8(config, m_soundlatch); + GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, 0); - okim6295_device &oki(OKIM6295(config, "oki", XTAL(8'000'000)/8, okim6295_device::PIN7_HIGH)); // 1MHz - Verified on PCB, pin 7 not verified + okim6295_device &oki(OKIM6295(config, "oki", XTAL(8'000'000) / 8, okim6295_device::PIN7_HIGH)); // 1MHz - Verified on PCB, pin 7 not verified oki.add_route(ALL_OUTPUTS, "mono", 1.0); oki.set_addrmap(0, &supduck_state::oki_map); } @@ -471,23 +476,23 @@ void supduck_state::supduck(machine_config &config) ***************************************************************************/ ROM_START( supduck ) - ROM_REGION( 0x40000, "maincpu", 0 ) /* 68000 code */ + ROM_REGION( 0x40000, "maincpu", 0 ) // 68000 code ROM_LOAD16_BYTE( "5.u16n", 0x00000, 0x20000, CRC(837a559a) SHA1(ed5ad744a4145dfbef56ad2e6eec3ff14c20de1c) ) ROM_LOAD16_BYTE( "6.u16l", 0x00001, 0x20000, CRC(508e9905) SHA1(2da3f12caa29066b4d54b22573cfdfcea8916f99) ) ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "4.su6", 0x00000, 0x8000, CRC(d75863ea) SHA1(497d11b86f4f69134943fc3448d195c6e7acbe8f) ) - ROM_REGION( 0x08000, "gfx1", 0 ) + ROM_REGION( 0x08000, "chars", 0 ) ROM_LOAD( "3.cu15", 0x00000, 0x8000, CRC(b1cacca4) SHA1(b4a486618197cf2b85a121b5640cd773b2d453fc) ) - ROM_REGION( 0x80000, "gfx2", 0 ) + ROM_REGION( 0x80000, "fgtiles", 0 ) ROM_LOAD( "7.uu29", 0x00000, 0x20000, CRC(f3251b20) SHA1(8ebb9b98324de14356c9a57ae8a77dc4118fb5c2) ) ROM_LOAD( "8.uu30", 0x20000, 0x20000, CRC(03c60cbd) SHA1(bf3be7161f69187350eb9d9d4209b93f8b67d0f1) ) ROM_LOAD( "9.uu31", 0x40000, 0x20000, CRC(9b6d3430) SHA1(ade2decc5bcf817498b1198a2244d1c65bc20bea) ) ROM_LOAD( "10.uu32", 0x60000, 0x20000, CRC(beed2616) SHA1(c077a3de4a6d451a568694ab70e85830d585a41d) ) - ROM_REGION( 0x80000, "gfx3", 0 ) + ROM_REGION( 0x80000, "bgtiles", 0 ) ROM_LOAD( "11.ul29", 0x00000, 0x20000, CRC(1b6958a4) SHA1(ca93f898702e14ece24d5cfced38d622d3596d0f) ) ROM_LOAD( "12.ul30", 0x20000, 0x20000, CRC(3e6bd24b) SHA1(f93b5c78d815bd30ecb9cfe2cd257548e467e852) ) ROM_LOAD( "13.ul31", 0x40000, 0x20000, CRC(bff7b7cd) SHA1(2f65cadcfcc02fe31ba721eea9f45d4a729e4374) ) @@ -506,4 +511,7 @@ ROM_START( supduck ) ROM_LOAD( "1.su13", 0x00000, 0x80000, CRC(7fb1ed42) SHA1(77ec86a6454398e329066aa060e9b6a39085ce71) ) // banked sample data ROM_END +} // anonymous namespace + + GAME( 1992, supduck, 0, supduck, supduck, supduck_state, empty_init, ROT0, "Comad", "Super Duck", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/misc/39in1.cpp b/src/mame/misc/39in1.cpp index 731b87ee96d..5e9ea1a5195 100644 --- a/src/mame/misc/39in1.cpp +++ b/src/mame/misc/39in1.cpp @@ -19,7 +19,7 @@ * * International Amusement Machine (I.A.M.) slots from the second half of the * 2000s use very similar PCBs (almost same main components, very similar layout, - * same encryption. + * same encryption). * * TODO: * - PXA255 peripherals @@ -29,8 +29,6 @@ * from the CPLD (probably) * - 19in1, 48in1, 48in1a, 48in1b, 48in1c, 60in1 have more conditional XORs, * encryption isn't completely beaten yet - * - I.A.M. games are all incomplete dumps and they might use different - * hardware features. If they diverge too much, move to own driver. * * * 39in1 notes: -- cgit v1.2.3