summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author smf- <smf-@users.noreply.github.com>2018-02-12 22:45:57 +0000
committer smf- <smf-@users.noreply.github.com>2018-02-12 22:48:20 +0000
commit68aafe5c10e0df5eee981954a67ac7c0d79bb5f3 (patch)
tree6592ef9e11797bacd25c20c0e31a632a66c762b9
parent534dea91eee1a5b67d8c480d411a10944830f619 (diff)
Popeye: Fixed background alignment in TPP2 sets. Converted machine config, address maps, palette init, background write handler & background drawing to virtual methods. Only include protection device on hardware that has it. [smf]
-rw-r--r--src/mame/drivers/popeye.cpp131
-rw-r--r--src/mame/includes/popeye.h65
-rw-r--r--src/mame/video/popeye.cpp120
3 files changed, 151 insertions, 165 deletions
diff --git a/src/mame/drivers/popeye.cpp b/src/mame/drivers/popeye.cpp
index 2f9c830bf66..46be242e51f 100644
--- a/src/mame/drivers/popeye.cpp
+++ b/src/mame/drivers/popeye.cpp
@@ -115,14 +115,16 @@ NETLIST_END()
-void popeye_state::driver_start()
+void tnx1_state::driver_start()
{
+ decrypt_rom();
+
save_item(NAME(m_prot0));
save_item(NAME(m_prot1));
save_item(NAME(m_prot_shift));
}
-DRIVER_INIT_MEMBER(popeye_state, tnx1)
+void tnx1_state::decrypt_rom()
{
uint8_t *rom = memregion("maincpu")->base();
int len = memregion("maincpu")->bytes();
@@ -134,7 +136,11 @@ DRIVER_INIT_MEMBER(popeye_state, tnx1)
memcpy(rom,&buffer[0],len);
}
-DRIVER_INIT_MEMBER(popeye_state,tpp2)
+void popeyebl_state::decrypt_rom()
+{
+}
+
+void tpp2_state::decrypt_rom()
{
uint8_t *rom = memregion("maincpu")->base();
int len = memregion("maincpu")->bytes();
@@ -146,7 +152,7 @@ DRIVER_INIT_MEMBER(popeye_state,tpp2)
memcpy(rom,&buffer[0],len);
}
-INTERRUPT_GEN_MEMBER(popeye_state::popeye_interrupt)
+INTERRUPT_GEN_MEMBER(tnx1_state::popeye_interrupt)
{
m_field ^= 1;
/* NMIs are enabled by the I register?? How can that be? */
@@ -158,7 +164,7 @@ INTERRUPT_GEN_MEMBER(popeye_state::popeye_interrupt)
/* the protection device simply returns the last two values written shifted left */
/* by a variable amount. */
-READ8_MEMBER(popeye_state::protection_r)
+READ8_MEMBER(tnx1_state::protection_r)
{
if (offset == 0)
{
@@ -171,7 +177,7 @@ READ8_MEMBER(popeye_state::protection_r)
}
}
-WRITE8_MEMBER(popeye_state::protection_w)
+WRITE8_MEMBER(tnx1_state::protection_w)
{
if (offset == 0)
{
@@ -188,7 +194,7 @@ WRITE8_MEMBER(popeye_state::protection_w)
-ADDRESS_MAP_START(popeye_state::tnx1_map)
+ADDRESS_MAP_START(tnx1_state::maincpu_program_map)
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x8bff) AM_WRITENOP // Attempts to initialize this area with 00 on boot
@@ -198,38 +204,29 @@ ADDRESS_MAP_START(popeye_state::tnx1_map)
AM_RANGE(0x8e80, 0x8fff) AM_RAM
AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_SHARE("videoram")
AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_SHARE("colorram")
- AM_RANGE(0xc000, 0xcfff) AM_WRITE(tnx1_bitmap_w)
+ AM_RANGE(0xc000, 0xcfff) AM_WRITE(background_w)
AM_RANGE(0xe000, 0xe001) AM_READWRITE(protection_r,protection_w)
ADDRESS_MAP_END
-ADDRESS_MAP_START(popeye_state::tpp2_map)
- AM_RANGE(0x0000, 0x7fff) AM_ROM
- AM_RANGE(0x8000, 0x87ff) AM_RAM // unpopulated 7f
- AM_RANGE(0x8800, 0x8bff) AM_RAM
- AM_RANGE(0x8c00, 0x8c02) AM_RAM AM_SHARE("background_pos")
- AM_RANGE(0x8c03, 0x8c03) AM_RAM AM_SHARE("palettebank")
- AM_RANGE(0x8c04, 0x8e7f) AM_RAM AM_SHARE("spriteram")
- AM_RANGE(0x8e80, 0x8fff) AM_RAM
- AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_SHARE("videoram")
- AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_SHARE("colorram")
- AM_RANGE(0xc000, 0xdfff) AM_WRITE(tpp2_bitmap_w)
- AM_RANGE(0xe000, 0xe001) AM_READWRITE(protection_r,protection_w)
+ADDRESS_MAP_START(tpp2_state::maincpu_program_map)
+ AM_IMPORT_FROM(tnx1_state::maincpu_program_map)
+ //AM_RANGE(0x8000, 0x87ff) AM_NOP // 7f (normally unpopulated)
+ AM_RANGE(0x8800, 0x8bff) AM_RAM // 7h
+ AM_RANGE(0xc000, 0xdfff) AM_WRITE(background_w)
ADDRESS_MAP_END
-ADDRESS_MAP_START(popeye_state::popeyebl_map)
- AM_RANGE(0x0000, 0x7fff) AM_ROM
- AM_RANGE(0x8000, 0x87ff) AM_RAM
- AM_RANGE(0x8c00, 0x8c02) AM_RAM AM_SHARE("background_pos")
- AM_RANGE(0x8c03, 0x8c03) AM_RAM AM_SHARE("palettebank")
- AM_RANGE(0x8c04, 0x8e7f) AM_RAM AM_SHARE("spriteram")
- AM_RANGE(0x8e80, 0x8fff) AM_RAM
- AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_SHARE("videoram")
- AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_SHARE("colorram")
- AM_RANGE(0xc000, 0xcfff) AM_WRITE(tnx1_bitmap_w)
+ADDRESS_MAP_START(tpp2np_state::maincpu_program_map)
+ AM_IMPORT_FROM(tpp2_state::maincpu_program_map)
+ AM_RANGE(0xe000, 0xe000) AM_READUNMAP AM_WRITENOP // game still writes level number
+ AM_RANGE(0xe001, 0xe001) AM_READNOP AM_WRITEUNMAP // game still reads status but then discards it
+ADDRESS_MAP_END
+
+ADDRESS_MAP_START(popeyebl_state::maincpu_program_map)
+ AM_IMPORT_FROM(tnx1_state::maincpu_program_map)
AM_RANGE(0xe000, 0xe01f) AM_ROM AM_REGION("blprot", 0x00)
ADDRESS_MAP_END
-ADDRESS_MAP_START(popeye_state::popeye_io_map)
+ADDRESS_MAP_START(tnx1_state::maincpu_io_map)
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x01) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
AM_RANGE(0x00, 0x00) AM_READ_PORT("P1")
@@ -239,7 +236,7 @@ ADDRESS_MAP_START(popeye_state::popeye_io_map)
ADDRESS_MAP_END
-CUSTOM_INPUT_MEMBER(popeye_state::dsw1_read)
+CUSTOM_INPUT_MEMBER(tnx1_state::dsw1_read)
{
return ioport("DSW1")->read() >> m_dswbit;
}
@@ -295,7 +292,7 @@ static INPUT_PORTS_START( skyskipr )
PORT_DIPSETTING( 0x08, "A 1/6 B 1/1" )
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )
PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNUSED)
- PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, popeye_state, dsw1_read, nullptr)
+ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, tnx1_state, dsw1_read, nullptr)
PORT_START("DSW1") /* DSW1 */
PORT_DIPNAME( 0x03, 0x01, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:1,2")
@@ -321,7 +318,7 @@ static INPUT_PORTS_START( skyskipr )
PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) )
INPUT_PORTS_END
-CUSTOM_INPUT_MEMBER( popeye_state::pop_field_r )
+CUSTOM_INPUT_MEMBER( tnx1_state::pop_field_r )
{
return m_field ^ 1;
}
@@ -352,7 +349,7 @@ static INPUT_PORTS_START( popeye )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 )
- PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, popeye_state,pop_field_r, nullptr) /* inverted init e/o signal (even odd) */
+ PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, tnx1_state,pop_field_r, nullptr) /* inverted init e/o signal (even odd) */
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN2 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SERVICE1 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 )
@@ -374,7 +371,7 @@ static INPUT_PORTS_START( popeye )
PORT_CONFSETTING( 0x20, "Nintendo Co.,Ltd" )
PORT_CONFSETTING( 0x60, "Nintendo of America" )
// PORT_CONFSETTING( 0x00, "Nintendo of America" )
- PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, popeye_state, dsw1_read, nullptr)
+ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, tnx1_state, dsw1_read, nullptr)
PORT_START("DSW1") /* DSW1 */
PORT_DIPNAME( 0x03, 0x01, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:1,2")
@@ -465,7 +462,7 @@ GFXDECODE_END
-WRITE8_MEMBER(popeye_state::popeye_portB_w)
+WRITE8_MEMBER(tnx1_state::popeye_portB_w)
{
/* bit 0 flips screen */
flip_screen_set(data & 1);
@@ -474,12 +471,12 @@ WRITE8_MEMBER(popeye_state::popeye_portB_w)
m_dswbit = (data & 0x0e) >> 1;
}
-MACHINE_CONFIG_START(popeye_state::tnx1)
+MACHINE_CONFIG_START(tnx1_state::config)
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, XTAL(8'000'000)/2) /* 4 MHz */
- MCFG_CPU_PROGRAM_MAP(tnx1_map)
- MCFG_CPU_IO_MAP(popeye_io_map)
- MCFG_CPU_VBLANK_INT_DRIVER("screen", popeye_state, popeye_interrupt)
+ MCFG_CPU_PROGRAM_MAP(maincpu_program_map)
+ MCFG_CPU_IO_MAP(maincpu_io_map)
+ MCFG_CPU_VBLANK_INT_DRIVER("screen", tnx1_state, popeye_interrupt)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
@@ -487,42 +484,27 @@ MACHINE_CONFIG_START(popeye_state::tnx1)
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
MCFG_SCREEN_SIZE(32*16, 32*16)
MCFG_SCREEN_VISIBLE_AREA(0*16, 32*16-1, 2*16, 30*16-1)
- MCFG_SCREEN_UPDATE_DRIVER(popeye_state, screen_update_tnx1)
+ MCFG_SCREEN_UPDATE_DRIVER(tnx1_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", popeye)
MCFG_PALETTE_ADD("palette", 16+16*2+8*4)
- MCFG_PALETTE_INIT_OWNER(popeye_state, tnx1)
+ MCFG_PALETTE_INIT_OWNER(tnx1_state, palette_init)
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("aysnd", AY8910, XTAL(8'000'000)/4)
MCFG_AY8910_PORT_A_READ_CB(IOPORT("DSW0"))
- MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(popeye_state, popeye_portB_w))
+ MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(tnx1_state, popeye_portB_w))
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
MACHINE_CONFIG_END
-MACHINE_CONFIG_DERIVED(popeye_state::tpp1, tnx1)
- MCFG_SCREEN_MODIFY("screen")
- MCFG_SCREEN_UPDATE_DRIVER(popeye_state, screen_update_tpp1)
-
- MCFG_PALETTE_MODIFY("palette")
- MCFG_PALETTE_INIT_OWNER(popeye_state,tpp1)
-
- MCFG_VIDEO_START_OVERRIDE(popeye_state,tpp1)
-MACHINE_CONFIG_END
-
-MACHINE_CONFIG_DERIVED(popeye_state::tpp2, tpp1)
- MCFG_CPU_MODIFY("maincpu")
- MCFG_CPU_PROGRAM_MAP(tpp2_map)
-
+MACHINE_CONFIG_DERIVED(tpp2_state::config, tpp1_state::config)
MCFG_SOUND_MODIFY("aysnd")
MCFG_SOUND_ROUTES_RESET()
- MCFG_AY8910_OUTPUT_TYPE(AY8910_RESISTOR_OUTPUT) /* Does Sky Skipper have the same filtering? */
+ MCFG_AY8910_OUTPUT_TYPE(AY8910_RESISTOR_OUTPUT) /* Does tnx1, tpp1 & popeyebl have the same filtering? */
MCFG_AY8910_RES_LOADS(2000.0, 2000.0, 2000.0)
- MCFG_AY8910_PORT_A_READ_CB(IOPORT("DSW0"))
- MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(popeye_state, popeye_portB_w))
MCFG_SOUND_ROUTE_EX(0, "snd_nl", 1.0, 0)
MCFG_SOUND_ROUTE_EX(1, "snd_nl", 1.0, 1)
MCFG_SOUND_ROUTE_EX(2, "snd_nl", 1.0, 2)
@@ -542,15 +524,6 @@ MACHINE_CONFIG_DERIVED(popeye_state::tpp2, tpp1)
MACHINE_CONFIG_END
-MACHINE_CONFIG_DERIVED(popeye_state::popeyebl, tpp1)
- MCFG_CPU_MODIFY("maincpu")
- MCFG_CPU_PROGRAM_MAP(popeyebl_map)
-
- MCFG_PALETTE_MODIFY("palette")
- MCFG_PALETTE_INIT_OWNER(popeye_state,popeyebl)
-MACHINE_CONFIG_END
-
-
/***************************************************************************
@@ -845,12 +818,12 @@ ROM_START( popeyejo )
ROM_END
-GAME( 1981, skyskipr, 0, tnx1, skyskipr, popeye_state, tnx1, ROT0, "Nintendo", "Sky Skipper", MACHINE_SUPPORTS_SAVE )
-GAME( 1982, popeye, 0, tpp2, popeye, popeye_state, tpp2, ROT0, "Nintendo", "Popeye (revision D)", MACHINE_SUPPORTS_SAVE )
-GAME( 1982, popeyeu, popeye, tpp2, popeye, popeye_state, tpp2, ROT0, "Nintendo", "Popeye (revision D not protected)", MACHINE_SUPPORTS_SAVE )
-GAME( 1982, popeyef, popeye, tpp2, popeyef, popeye_state, tpp2, ROT0, "Nintendo", "Popeye (revision F)", MACHINE_SUPPORTS_SAVE )
-GAME( 1982, popeyebl, popeye, popeyebl, popeye, popeye_state, 0, ROT0, "bootleg", "Popeye (bootleg set 1)", MACHINE_SUPPORTS_SAVE )
-GAME( 1982, popeyeb2, popeye, popeyebl, popeye, popeye_state, 0, ROT0, "bootleg", "Popeye (bootleg set 2)", MACHINE_SUPPORTS_SAVE )
-GAME( 1982, popeyeb3, popeye, tpp2, popeye, popeye_state, tpp2, ROT0, "bootleg", "Popeye (bootleg set 3)", MACHINE_SUPPORTS_SAVE )
-GAME( 1982, popeyej, popeye, tpp1, popeye, popeye_state, tnx1, ROT0, "Nintendo", "Popeye (Japan)", MACHINE_SUPPORTS_SAVE )
-GAME( 1982, popeyejo, popeye, tpp1, popeye, popeye_state, tnx1, ROT0, "Nintendo", "Popeye (Japan, Older)", MACHINE_SUPPORTS_SAVE )
+GAME( 1981, skyskipr, 0, config, skyskipr, tnx1_state, 0, ROT0, "Nintendo", "Sky Skipper", MACHINE_SUPPORTS_SAVE )
+GAME( 1982, popeye, 0, config, popeye, tpp2_state, 0, ROT0, "Nintendo", "Popeye (revision D)", MACHINE_SUPPORTS_SAVE )
+GAME( 1982, popeyeu, popeye, config, popeye, tpp2np_state, 0, ROT0, "Nintendo", "Popeye (revision D not protected)", MACHINE_SUPPORTS_SAVE )
+GAME( 1982, popeyef, popeye, config, popeyef, tpp2np_state, 0, ROT0, "Nintendo", "Popeye (revision F)", MACHINE_SUPPORTS_SAVE )
+GAME( 1982, popeyebl, popeye, config, popeye, popeyebl_state, 0, ROT0, "bootleg", "Popeye (bootleg set 1)", MACHINE_SUPPORTS_SAVE )
+GAME( 1982, popeyeb2, popeye, config, popeye, popeyebl_state, 0, ROT0, "bootleg", "Popeye (bootleg set 2)", MACHINE_SUPPORTS_SAVE )
+GAME( 1982, popeyeb3, popeye, config, popeye, tpp2np_state, 0, ROT0, "bootleg", "Popeye (bootleg set 3)", MACHINE_SUPPORTS_SAVE )
+GAME( 1982, popeyej, popeye, config, popeye, tpp1_state, 0, ROT0, "Nintendo", "Popeye (Japan)", MACHINE_SUPPORTS_SAVE )
+GAME( 1982, popeyejo, popeye, config, popeye, tpp1_state, 0, ROT0, "Nintendo", "Popeye (Japan, Older)", MACHINE_SUPPORTS_SAVE )
diff --git a/src/mame/includes/popeye.h b/src/mame/includes/popeye.h
index ead1267a99f..fe42de3369c 100644
--- a/src/mame/includes/popeye.h
+++ b/src/mame/includes/popeye.h
@@ -3,10 +3,10 @@
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria, Couriersud
// thanks-to: Marc Lafontaine
-class popeye_state : public driver_device
+class tnx1_state : public driver_device
{
public:
- popeye_state(const machine_config &mconfig, device_type type, const char *tag)
+ tnx1_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_background_pos(*this, "background_pos"),
m_palettebank(*this, "palettebank"),
@@ -31,7 +31,7 @@ public:
required_region_ptr<uint8_t> m_color_prom;
required_region_ptr<uint8_t> m_color_prom_spr;
- uint8_t m_bitmapram[0x1000];
+ uint8_t m_background_ram[0x1000];
std::unique_ptr<bitmap_ind16> m_sprite_bitmap;
tilemap_t *m_fg_tilemap;
uint8_t m_last_palette;
@@ -41,36 +41,59 @@ public:
DECLARE_WRITE8_MEMBER(protection_w);
DECLARE_WRITE8_MEMBER(popeye_videoram_w);
DECLARE_WRITE8_MEMBER(popeye_colorram_w);
- DECLARE_WRITE8_MEMBER(tpp2_bitmap_w);
- DECLARE_WRITE8_MEMBER(tnx1_bitmap_w);
+ virtual DECLARE_WRITE8_MEMBER(background_w);
DECLARE_WRITE8_MEMBER(popeye_portB_w);
DECLARE_CUSTOM_INPUT_MEMBER(dsw1_read);
- DECLARE_DRIVER_INIT(tnx1);
- DECLARE_DRIVER_INIT(tpp2);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
virtual void driver_start() override;
virtual void video_start() override;
- DECLARE_PALETTE_INIT(tpp1);
- DECLARE_VIDEO_START(tpp1);
- DECLARE_PALETTE_INIT(popeyebl);
- DECLARE_PALETTE_INIT(tnx1);
- uint32_t screen_update_tnx1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- uint32_t screen_update_tpp1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+ virtual DECLARE_PALETTE_INIT(palette_init);
+ uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(popeye_interrupt);
DECLARE_CUSTOM_INPUT_MEMBER( pop_field_r );
void update_palette();
+ virtual void decrypt_rom();
+ virtual void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_field(bitmap_ind16 &bitmap, const rectangle &cliprect);
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
- void tpp2(machine_config &config);
- void tpp1(machine_config &config);
- void tnx1(machine_config &config);
- void popeyebl(machine_config &config);
- void popeye_io_map(address_map &map);
- void popeyebl_map(address_map &map);
- void tnx1_map(address_map &map);
- void tpp2_map(address_map &map);
+ virtual void config(machine_config &config);
+ virtual void maincpu_program_map(address_map &map);
+ void maincpu_io_map(address_map &map);
+};
+
+class tpp1_state : public tnx1_state
+{
+ using tnx1_state::tnx1_state;
+ virtual DECLARE_PALETTE_INIT(palette_init) override;
+ virtual void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect) override;
+};
+
+class popeyebl_state : public tpp1_state
+{
+ using tpp1_state::tpp1_state;
+ virtual void decrypt_rom() override;
+public:
+ virtual void maincpu_program_map(address_map &map) override;
+};
+
+class tpp2_state : public tpp1_state
+{
+ using tpp1_state::tpp1_state;
+ virtual void decrypt_rom() override;
+ virtual void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect) override;
+ virtual DECLARE_WRITE8_MEMBER(background_w) override;
+public:
+ virtual void config(machine_config &config) override;
+ virtual void maincpu_program_map(address_map &map) override;
+};
+
+class tpp2np_state : public tpp2_state
+{
+ using tpp2_state::tpp2_state;
+public:
+ virtual void maincpu_program_map(address_map &map) override;
};
diff --git a/src/mame/video/popeye.cpp b/src/mame/video/popeye.cpp
index 14c8519766a..d40b436d46e 100644
--- a/src/mame/video/popeye.cpp
+++ b/src/mame/video/popeye.cpp
@@ -109,7 +109,7 @@ static const res_net_info popeye_7052_obj_net_info =
};
-PALETTE_INIT_MEMBER(popeye_state, tpp1)
+PALETTE_INIT_MEMBER(tpp1_state, palette_init)
{
/* Two of the PROM address pins are tied together */
for (int i = 0; i < 0x20; i++)
@@ -123,21 +123,7 @@ PALETTE_INIT_MEMBER(popeye_state, tpp1)
update_palette();
}
-PALETTE_INIT_MEMBER(popeye_state,popeyebl)
-{
- /* Two of the PROM address pins are tied together */
- for (int i = 0; i < 0x20; i++)
- {
- int color = (i & 0xf) | ((i & 0x8) << 1);
- m_color_prom[i + 0x20] = m_color_prom[color + 0x20];
- }
-
- m_last_palette = -1;
-
- update_palette();
-}
-
-PALETTE_INIT_MEMBER(popeye_state, tnx1)
+PALETTE_INIT_MEMBER(tnx1_state, palette_init)
{
/* Two of the PROM address pins are tied together and one is not connected... */
for (int i = 0;i < 0x100;i++)
@@ -151,7 +137,7 @@ PALETTE_INIT_MEMBER(popeye_state, tnx1)
update_palette();
}
-void popeye_state::update_palette()
+void tnx1_state::update_palette()
{
if ((*m_palettebank ^ m_last_palette) & 0x08)
{
@@ -268,48 +254,48 @@ void popeye_state::update_palette()
m_last_palette = *m_palettebank;
}
-WRITE8_MEMBER(popeye_state::tnx1_bitmap_w)
+WRITE8_MEMBER(tnx1_state::background_w)
{
// TODO: confirm the memory layout
bool lsn = (data & 0x80) == 0;
if (lsn)
{
- m_bitmapram[offset] = (m_bitmapram[offset] & 0xf0) | (data & 0xf);
+ m_background_ram[offset] = (m_background_ram[offset] & 0xf0) | (data & 0xf);
}
else
{
- m_bitmapram[offset] = (m_bitmapram[offset] & 0x0f) | (data << 4);
+ m_background_ram[offset] = (m_background_ram[offset] & 0x0f) | (data << 4);
}
}
-WRITE8_MEMBER(popeye_state::tpp2_bitmap_w)
+WRITE8_MEMBER(tpp2_state::background_w)
{
// TODO: confirm the memory layout
bool lsn = (offset & 0x40) == 0;
offset = (offset & 0x3f) | ((offset & ~0x7f) >> 1);
if (lsn)
{
- m_bitmapram[offset] = (m_bitmapram[offset] & 0xf0) | (data & 0xf);
+ m_background_ram[offset] = (m_background_ram[offset] & 0xf0) | (data & 0xf);
}
else
{
- m_bitmapram[offset] = (m_bitmapram[offset] & 0x0f) | (data << 4);
+ m_background_ram[offset] = (m_background_ram[offset] & 0x0f) | (data << 4);
}
}
-WRITE8_MEMBER(popeye_state::popeye_videoram_w)
+WRITE8_MEMBER(tnx1_state::popeye_videoram_w)
{
m_videoram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
-WRITE8_MEMBER(popeye_state::popeye_colorram_w)
+WRITE8_MEMBER(tnx1_state::popeye_colorram_w)
{
m_colorram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
-TILE_GET_INFO_MEMBER(popeye_state::get_fg_tile_info)
+TILE_GET_INFO_MEMBER(tnx1_state::get_fg_tile_info)
{
int code = m_videoram[tile_index];
int color = m_colorram[tile_index] & 0x0f;
@@ -317,37 +303,21 @@ TILE_GET_INFO_MEMBER(popeye_state::get_fg_tile_info)
SET_TILE_INFO_MEMBER(0, code, color, 0);
}
-void popeye_state::video_start()
-{
- m_sprite_bitmap = std::make_unique<bitmap_ind16>(512, 512);
-
- m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(popeye_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
- m_fg_tilemap->set_transparent_pen(0);
-
- m_field = 0;
-
- save_item(NAME(m_field));
- save_item(NAME(m_last_palette));
- save_item(NAME(*m_sprite_bitmap));
- save_item(NAME(m_bitmapram));
-}
-
-VIDEO_START_MEMBER(popeye_state,tpp1)
+void tnx1_state::video_start()
{
m_sprite_bitmap = std::make_unique<bitmap_ind16>(512, 512);
- m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(popeye_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
+ m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tnx1_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_fg_tilemap->set_transparent_pen(0);
m_field = 0;
save_item(NAME(m_field));
save_item(NAME(m_last_palette));
- save_item(NAME(*m_sprite_bitmap));
- save_item(NAME(m_bitmapram));
+ save_item(NAME(m_background_ram));
}
-void popeye_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
+void tnx1_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_sprite_bitmap->fill(0, cliprect);
@@ -377,7 +347,7 @@ void popeye_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
/*
* offs+3:
- * bit 7 ?
+ * bit 7 ? TODO: figure out why olive oil and wimpy have some of these bits set
* bit 6 ?
* bit 5 ?
* bit 4 MSB of sprite code
@@ -430,7 +400,7 @@ void popeye_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
copybitmap_trans(bitmap, *m_sprite_bitmap, 0, 0, 0, 0, cliprect, 0);
}
-void popeye_state::draw_field(bitmap_ind16 &bitmap, const rectangle &cliprect)
+void tnx1_state::draw_field(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int x;
int y;
@@ -440,10 +410,8 @@ void popeye_state::draw_field(bitmap_ind16 &bitmap, const rectangle &cliprect)
bitmap.pix(y, x) = 0;
}
-uint32_t popeye_state::screen_update_tnx1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+void tnx1_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- update_palette();
-
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
int sy = y;
@@ -455,30 +423,21 @@ uint32_t popeye_state::screen_update_tnx1(screen_device &screen, bitmap_ind16 &b
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
{
if (sy < 0)
- bitmap.pix16(y, x) = m_bitmapram[0x3f] & 0xf; // TODO: find out exactly where the data is fetched from
+ bitmap.pix16(y, x) = m_background_ram[0x3f] & 0xf; // TODO: find out exactly where the data is fetched from
else
{
// TODO: confirm the memory layout
int sx = x + (2 * (m_background_pos[0] | ((m_background_pos[2] & 1) << 8))) + 0x70;
int shift = (sx & 0x200) / 0x80;
- bitmap.pix16(y, x) = (m_bitmapram[((sx / 8) & 0x3f) + ((sy / 8) * 0x40)] >> shift) & 0xf;
+ bitmap.pix16(y, x) = (m_background_ram[((sx / 8) & 0x3f) + ((sy / 8) * 0x40)] >> shift) & 0xf;
}
}
}
-
- draw_sprites(bitmap, cliprect);
- m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
-#if USE_INTERLACE
- draw_field(bitmap, cliprect);
-#endif
- return 0;
}
-uint32_t popeye_state::screen_update_tpp1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+void tpp1_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- update_palette();
-
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
int sy = y;
@@ -490,18 +449,49 @@ uint32_t popeye_state::screen_update_tpp1(screen_device &screen, bitmap_ind16 &b
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
{
if (sy < 0)
- bitmap.pix16(y, x) = m_bitmapram[0x3f] & 0xf; // TODO: find out exactly where the data is fetched from
+ bitmap.pix16(y, x) = m_background_ram[0x3f] & 0xf; // TODO: find out exactly where the data is fetched from
else
{
// TODO: confirm the memory layout
int sx = x + (2 * m_background_pos[0]) + 0x70;
int shift = (sy & 4);
- bitmap.pix16(y, x) = (m_bitmapram[((sx / 8) & 0x3f) + ((sy / 8) * 0x40)] >> shift) & 0xf;
+ bitmap.pix16(y, x) = (m_background_ram[((sx / 8) & 0x3f) + ((sy / 8) * 0x40)] >> shift) & 0xf;
+ }
+ }
+ }
+}
+
+void tpp2_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
+{
+ for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
+ {
+ int sy = y;
+ if (flip_screen())
+ sy ^= 0x1ff;
+
+ sy -= 0x200 - (2 * m_background_pos[1]);
+
+ for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
+ {
+ if (sy < 0)
+ bitmap.pix16(y, x) = m_background_ram[0x3f] & 0xf; // TODO: find out exactly where the data is fetched from
+ else
+ {
+ // TODO: confirm the memory layout
+ int sx = x + (2 * m_background_pos[0]) + 0x72;
+ int shift = (sy & 4);
+
+ bitmap.pix16(y, x) = (m_background_ram[((sx / 8) & 0x3f) + ((sy / 8) * 0x40)] >> shift) & 0xf;
}
}
}
+}
+uint32_t tnx1_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+{
+ update_palette();
+ draw_background(bitmap, cliprect);
draw_sprites(bitmap, cliprect);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
#if USE_INTERLACE