mirror of
https://github.com/holub/mame
synced 2025-04-24 17:30:55 +03:00
Popeye: Added sprite ram, background scroll and palette buffering. Unmap $8000 to $87ff for TPP2 as 7f is not populated at the factory. [smf]
This commit is contained in:
parent
4ea2a9009d
commit
21770973ee
@ -154,6 +154,10 @@ void tpp2_state::decrypt_rom()
|
||||
|
||||
INTERRUPT_GEN_MEMBER(tnx1_state::popeye_interrupt)
|
||||
{
|
||||
std::copy(&m_dmasource[0], &m_dmasource[m_dmasource.bytes()], m_sprite_ram.begin());
|
||||
std::copy(&m_dmasource[0], &m_dmasource[3], m_background_scroll);
|
||||
m_palette_bank = m_dmasource[3];
|
||||
|
||||
m_field ^= 1;
|
||||
/* NMIs are enabled by the I register?? How can that be? */
|
||||
if (device.state().state_int(Z80_I) & 1) /* skyskipr: 0/1, popeye: 2/3 but also 0/1 */
|
||||
@ -198,9 +202,7 @@ 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
|
||||
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(0x8c00, 0x8e7f) AM_RAM AM_SHARE("dmasource")
|
||||
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")
|
||||
@ -210,12 +212,12 @@ ADDRESS_MAP_END
|
||||
|
||||
ADDRESS_MAP_START(tpp2_state::maincpu_program_map)
|
||||
AM_IMPORT_FROM(tpp1_state::maincpu_program_map)
|
||||
//AM_RANGE(0x8000, 0x87ff) AM_NOP // 7f (normally unpopulated)
|
||||
AM_RANGE(0x8000, 0x87ff) AM_UNMAP // 7f (unpopulated)
|
||||
AM_RANGE(0x8800, 0x8bff) AM_RAM // 7h
|
||||
AM_RANGE(0xc000, 0xdfff) AM_WRITE(background_w)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
ADDRESS_MAP_START(tpp2np_state::maincpu_program_map)
|
||||
ADDRESS_MAP_START(tpp2_noalu_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
|
||||
@ -819,12 +821,12 @@ ROM_START( popeyejo )
|
||||
ROM_END
|
||||
|
||||
|
||||
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 )
|
||||
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, tpp2_noalu_state, 0, ROT0, "Nintendo", "Popeye (revision D not protected)", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1982, popeyef, popeye, config, popeyef, tpp2_noalu_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, tpp2_noalu_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 )
|
||||
|
@ -11,9 +11,7 @@ public:
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_gfxdecode(*this, "gfxdecode"),
|
||||
m_palette(*this, "palette"),
|
||||
m_background_pos(*this, "background_pos"),
|
||||
m_palettebank(*this, "palettebank"),
|
||||
m_spriteram(*this, "spriteram"),
|
||||
m_dmasource(*this, "dmasource"),
|
||||
m_videoram(*this, "videoram"),
|
||||
m_colorram(*this, "colorram"),
|
||||
m_color_prom(*this, "proms"),
|
||||
@ -27,18 +25,19 @@ protected:
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<gfxdecode_device> m_gfxdecode;
|
||||
required_device<palette_device> m_palette;
|
||||
required_shared_ptr<uint8_t> m_background_pos;
|
||||
required_shared_ptr<uint8_t> m_palettebank;
|
||||
required_shared_ptr<uint8_t> m_spriteram;
|
||||
required_shared_ptr<uint8_t> m_dmasource;
|
||||
required_shared_ptr<uint8_t> m_videoram;
|
||||
required_shared_ptr<uint8_t> m_colorram;
|
||||
required_region_ptr<uint8_t> m_color_prom;
|
||||
required_region_ptr<uint8_t> m_color_prom_spr;
|
||||
|
||||
uint8_t m_background_ram[0x1000];
|
||||
std::unique_ptr<bitmap_ind16> m_sprite_bitmap;
|
||||
std::vector<uint8_t> m_sprite_ram;
|
||||
std::vector<uint8_t> m_background_ram;
|
||||
uint8_t m_background_scroll[3];
|
||||
tilemap_t *m_fg_tilemap;
|
||||
uint8_t m_last_palette;
|
||||
uint8_t m_palette_bank;
|
||||
uint8_t m_palette_bank_cache;
|
||||
int m_field;
|
||||
uint8_t m_prot0;
|
||||
uint8_t m_prot1;
|
||||
@ -95,7 +94,7 @@ protected:
|
||||
virtual DECLARE_WRITE8_MEMBER(background_w) override;
|
||||
};
|
||||
|
||||
class tpp2np_state : public tpp2_state
|
||||
class tpp2_noalu_state : public tpp2_state
|
||||
{
|
||||
using tpp2_state::tpp2_state;
|
||||
protected:
|
||||
|
@ -118,7 +118,7 @@ PALETTE_INIT_MEMBER(tpp1_state, palette_init)
|
||||
m_color_prom[i + 0x20] = m_color_prom[color + 0x20];
|
||||
}
|
||||
|
||||
m_last_palette = -1;
|
||||
m_palette_bank_cache = -1;
|
||||
|
||||
update_palette();
|
||||
}
|
||||
@ -132,16 +132,16 @@ PALETTE_INIT_MEMBER(tnx1_state, palette_init)
|
||||
m_color_prom_spr[i] = m_color_prom_spr[color];
|
||||
}
|
||||
|
||||
m_last_palette = -1;
|
||||
m_palette_bank_cache = -1;
|
||||
|
||||
update_palette();
|
||||
}
|
||||
|
||||
void tnx1_state::update_palette()
|
||||
{
|
||||
if ((*m_palettebank ^ m_last_palette) & 0x08)
|
||||
if ((m_palette_bank ^ m_palette_bank_cache) & 0x08)
|
||||
{
|
||||
uint8_t *color_prom = m_color_prom + 16 * ((*m_palettebank & 0x08) >> 3);
|
||||
uint8_t *color_prom = m_color_prom + 16 * ((m_palette_bank & 0x08) >> 3);
|
||||
|
||||
#if USE_NEW_COLOR
|
||||
std::vector<rgb_t> rgb;
|
||||
@ -178,9 +178,9 @@ void tnx1_state::update_palette()
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((*m_palettebank ^ m_last_palette) & 0x08)
|
||||
if ((m_palette_bank ^ m_palette_bank_cache) & 0x08)
|
||||
{
|
||||
uint8_t *color_prom = m_color_prom + 32 + 16 * ((*m_palettebank & 0x08) >> 3);
|
||||
uint8_t *color_prom = m_color_prom + 32 + 16 * ((m_palette_bank & 0x08) >> 3);
|
||||
|
||||
/* characters */
|
||||
#if USE_NEW_COLOR
|
||||
@ -216,9 +216,9 @@ void tnx1_state::update_palette()
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((*m_palettebank ^ m_last_palette) & 0x07)
|
||||
if ((m_palette_bank ^ m_palette_bank_cache) & 0x07)
|
||||
{
|
||||
uint8_t *color_prom = m_color_prom_spr + 32 * (*m_palettebank & 0x07);
|
||||
uint8_t *color_prom = m_color_prom_spr + 32 * (m_palette_bank & 0x07);
|
||||
|
||||
#if USE_NEW_COLOR
|
||||
/* sprites */
|
||||
@ -251,7 +251,7 @@ void tnx1_state::update_palette()
|
||||
#endif
|
||||
}
|
||||
|
||||
m_last_palette = *m_palettebank;
|
||||
m_palette_bank_cache = m_palette_bank;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(tnx1_state::background_w)
|
||||
@ -305,6 +305,9 @@ TILE_GET_INFO_MEMBER(tnx1_state::get_fg_tile_info)
|
||||
|
||||
void tnx1_state::video_start()
|
||||
{
|
||||
m_background_ram.resize(0x1000);
|
||||
m_sprite_ram.resize(0x400);
|
||||
|
||||
m_sprite_bitmap = std::make_unique<bitmap_ind16>(512, 512);
|
||||
|
||||
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);
|
||||
@ -313,8 +316,11 @@ void tnx1_state::video_start()
|
||||
m_field = 0;
|
||||
|
||||
save_item(NAME(m_field));
|
||||
save_item(NAME(m_last_palette));
|
||||
save_item(NAME(m_palette_bank));
|
||||
save_item(NAME(m_palette_bank_cache));
|
||||
save_item(NAME(m_background_ram));
|
||||
save_item(NAME(m_background_scroll));
|
||||
save_item(NAME(m_sprite_ram));
|
||||
}
|
||||
|
||||
void tnx1_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
@ -333,9 +339,9 @@ void tnx1_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
int flipy;
|
||||
} attributes[64] = { 0 };
|
||||
|
||||
for (int offs = 0; offs < m_spriteram.bytes(); offs += 4)
|
||||
for (int offs = 4; offs < m_dmasource.bytes(); offs += 4)
|
||||
{
|
||||
int sy = 0x200 - (m_spriteram[offs + 1] * 2);
|
||||
int sy = 0x200 - (m_sprite_ram[offs + 1] * 2);
|
||||
int row = y - sy;
|
||||
if (flip_screen())
|
||||
{
|
||||
@ -357,15 +363,15 @@ void tnx1_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
* bit 0 /
|
||||
*/
|
||||
|
||||
struct attribute_memory *a = &attributes[m_spriteram[offs] >> 2];
|
||||
a->sx = m_spriteram[offs] * 2;
|
||||
struct attribute_memory *a = &attributes[m_sprite_ram[offs] >> 2];
|
||||
a->sx = m_sprite_ram[offs] * 2;
|
||||
a->row = row;
|
||||
a->code = ((m_spriteram[offs + 2] & 0x7f)
|
||||
+ ((m_spriteram[offs + 3] & 0x10) << 3)
|
||||
+ ((m_spriteram[offs + 3] & 0x04) << 6)) ^ 0x1ff;
|
||||
a->color = (m_spriteram[offs + 3] & 0x07);
|
||||
a->flipx = (m_spriteram[offs + 2] & 0x80) ? 0xf : 0;
|
||||
a->flipy = (m_spriteram[offs + 3] & 0x08) ? 0xf : 0;
|
||||
a->code = ((m_sprite_ram[offs + 2] & 0x7f)
|
||||
+ ((m_sprite_ram[offs + 3] & 0x10) << 3)
|
||||
+ ((m_sprite_ram[offs + 3] & 0x04) << 6)) ^ 0x1ff;
|
||||
a->color = (m_sprite_ram[offs + 3] & 0x07);
|
||||
a->flipx = (m_sprite_ram[offs + 2] & 0x80) ? 0xf : 0;
|
||||
a->flipy = (m_sprite_ram[offs + 3] & 0x08) ? 0xf : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +424,7 @@ void tnx1_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect
|
||||
if (flip_screen())
|
||||
sy ^= 0x1ff;
|
||||
|
||||
sy -= 0x200 - (2 * m_background_pos[1]);
|
||||
sy -= 0x200 - (2 * m_background_scroll[1]);
|
||||
|
||||
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
|
||||
{
|
||||
@ -427,7 +433,7 @@ void tnx1_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect
|
||||
else
|
||||
{
|
||||
// TODO: confirm the memory layout
|
||||
int sx = x + (2 * (m_background_pos[0] | ((m_background_pos[2] & 1) << 8))) + 0x70;
|
||||
int sx = x + (2 * (m_background_scroll[0] | ((m_background_scroll[2] & 1) << 8))) + 0x70;
|
||||
int shift = (sx & 0x200) / 0x80;
|
||||
|
||||
bitmap.pix16(y, x) = (m_background_ram[((sx / 8) & 0x3f) + ((sy / 8) * 0x40)] >> shift) & 0xf;
|
||||
@ -444,7 +450,7 @@ void tpp1_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect
|
||||
if (flip_screen())
|
||||
sy ^= 0x1ff;
|
||||
|
||||
sy -= 0x200 - (2 * m_background_pos[1]);
|
||||
sy -= 0x200 - (2 * m_background_scroll[1]);
|
||||
|
||||
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
|
||||
{
|
||||
@ -453,7 +459,7 @@ void tpp1_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect
|
||||
else
|
||||
{
|
||||
// TODO: confirm the memory layout
|
||||
int sx = x + (2 * m_background_pos[0]) + 0x70;
|
||||
int sx = x + (2 * m_background_scroll[0]) + 0x70;
|
||||
int shift = (sy & 4);
|
||||
|
||||
bitmap.pix16(y, x) = (m_background_ram[((sx / 8) & 0x3f) + ((sy / 8) * 0x40)] >> shift) & 0xf;
|
||||
@ -470,7 +476,7 @@ void tpp2_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect
|
||||
if (flip_screen())
|
||||
sy ^= 0x1ff;
|
||||
|
||||
sy -= 0x200 - (2 * m_background_pos[1]);
|
||||
sy -= 0x200 - (2 * m_background_scroll[1]);
|
||||
|
||||
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
|
||||
{
|
||||
@ -479,7 +485,7 @@ void tpp2_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect
|
||||
else
|
||||
{
|
||||
// TODO: confirm the memory layout
|
||||
int sx = x + (2 * m_background_pos[0]) + 0x72;
|
||||
int sx = x + (2 * m_background_scroll[0]) + 0x72;
|
||||
int shift = (sy & 4);
|
||||
|
||||
bitmap.pix16(y, x) = (m_background_ram[((sx / 8) & 0x3f) + ((sy / 8) * 0x40)] >> shift) & 0xf;
|
||||
|
Loading…
Reference in New Issue
Block a user