mario.c: fix Monitor switch so it correctly affects both tiles and sprites [Alex Jackson]

This commit is contained in:
Alex W. Jackson 2014-11-09 03:27:54 -05:00
parent e61b72b6aa
commit 14ead4403f
3 changed files with 34 additions and 37 deletions

View File

@ -448,8 +448,8 @@ static const gfx_layout spritelayout =
}; };
static GFXDECODE_START( mario ) static GFXDECODE_START( mario )
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 16 ) GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 32 )
GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 0, 32 ) GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 0, 32 )
GFXDECODE_END GFXDECODE_END
static const gfx_layout spritelayout_bl = static const gfx_layout spritelayout_bl =
@ -466,8 +466,8 @@ static const gfx_layout spritelayout_bl =
}; };
static GFXDECODE_START( mariobl ) static GFXDECODE_START( mariobl )
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 16 ) GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 32 )
GFXDECODE_ENTRY( "gfx2", 0, spritelayout_bl, 0, 32 ) GFXDECODE_ENTRY( "gfx2", 0, spritelayout_bl, 0, 32 )
GFXDECODE_END GFXDECODE_END
static const gfx_layout spritelayout_bl2 = static const gfx_layout spritelayout_bl2 =
@ -521,7 +521,7 @@ static MACHINE_CONFIG_START( mario_base, mario_state )
MCFG_SCREEN_UPDATE_DRIVER(mario_state, screen_update_mario) MCFG_SCREEN_UPDATE_DRIVER(mario_state, screen_update_mario)
MCFG_SCREEN_PALETTE("palette") MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", mario) MCFG_GFXDECODE_ADD("gfxdecode", "palette", mario)
MCFG_PALETTE_ADD("palette", 512) MCFG_PALETTE_ADD("palette", 256)
MCFG_PALETTE_INIT_OWNER(mario_state, mario) MCFG_PALETTE_INIT_OWNER(mario_state, mario)
MACHINE_CONFIG_END MACHINE_CONFIG_END
@ -577,7 +577,7 @@ static MACHINE_CONFIG_START( mariobl, mario_state )
MCFG_SCREEN_UPDATE_DRIVER(mario_state, screen_update_mariobl) MCFG_SCREEN_UPDATE_DRIVER(mario_state, screen_update_mariobl)
MCFG_SCREEN_PALETTE("palette") MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", mariobl) MCFG_GFXDECODE_ADD("gfxdecode", "palette", mariobl)
MCFG_PALETTE_ADD("palette", 512) MCFG_PALETTE_ADD("palette", 256)
MCFG_PALETTE_INIT_OWNER(mario_state, mario) MCFG_PALETTE_INIT_OWNER(mario_state, mario)
/* sound hardware */ /* sound hardware */

View File

@ -31,25 +31,33 @@
#define I8035_MASTER_CLOCK XTAL_11MHz /* verified on pcb: 730Khz */ #define I8035_MASTER_CLOCK XTAL_11MHz /* verified on pcb: 730Khz */
#define I8035_CLOCK (I8035_MASTER_CLOCK) #define I8035_CLOCK (I8035_MASTER_CLOCK)
#define MARIO_PALETTE_LENGTH (256)
class mario_state : public driver_device class mario_state : public driver_device
{ {
public: public:
mario_state(const machine_config &mconfig, device_type type, const char *tag) mario_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag), : driver_device(mconfig, type, tag),
m_spriteram(*this, "spriteram"),
m_videoram(*this, "videoram"),
m_discrete(*this, "discrete"),
m_maincpu(*this, "maincpu"), m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"), m_audiocpu(*this, "audiocpu"),
m_gfxdecode(*this, "gfxdecode"), m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"), m_palette(*this, "palette"),
m_z80dma(*this, "z80dma") { } m_z80dma(*this, "z80dma"),
m_discrete(*this, "discrete"),
m_spriteram(*this, "spriteram"),
m_videoram(*this, "videoram"),
m_monitor(0) { }
/* devices */
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
optional_device<z80dma_device> m_z80dma;
optional_device<discrete_device> m_discrete;
/* memory pointers */ /* memory pointers */
required_shared_ptr<UINT8> m_spriteram;
/* machine states */ required_shared_ptr<UINT8> m_videoram;
/* sound state */ /* sound state */
UINT8 m_last; UINT8 m_last;
@ -61,12 +69,6 @@ public:
UINT8 m_palette_bank; UINT8 m_palette_bank;
UINT16 m_gfx_scroll; UINT16 m_gfx_scroll;
UINT8 m_flip; UINT8 m_flip;
/* driver general */
required_shared_ptr<UINT8> m_spriteram;
required_shared_ptr<UINT8> m_videoram;
optional_device<discrete_device> m_discrete;
tilemap_t *m_bg_tilemap; tilemap_t *m_bg_tilemap;
int m_monitor; int m_monitor;
@ -104,11 +106,6 @@ public:
DECLARE_READ8_MEMBER(memory_read_byte); DECLARE_READ8_MEMBER(memory_read_byte);
DECLARE_WRITE8_MEMBER(memory_write_byte); DECLARE_WRITE8_MEMBER(memory_write_byte);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int is_bootleg); void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int is_bootleg);
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
optional_device<z80dma_device> m_z80dma;
}; };
/*----------- defined in audio/mario.c -----------*/ /*----------- defined in audio/mario.c -----------*/

View File

@ -67,13 +67,13 @@ PALETTE_INIT_MEMBER(mario_state, mario)
const UINT8 *color_prom = memregion("proms")->base(); const UINT8 *color_prom = memregion("proms")->base();
dynamic_array<rgb_t> rgb; dynamic_array<rgb_t> rgb;
compute_res_net_all(rgb, color_prom, mario_decode_info, mario_net_info); if (m_monitor == 0)
palette.set_pen_colors(0, rgb, 256); compute_res_net_all(rgb, color_prom, mario_decode_info, mario_net_info);
compute_res_net_all(rgb, color_prom+256, mario_decode_info, mario_net_info_std); else
palette.set_pen_colors(256, rgb, 256); compute_res_net_all(rgb, color_prom+256, mario_decode_info, mario_net_info_std);
palette.set_pen_colors(0, rgb, 256);
palette.palette()->normalize_range(0, 255); palette.palette()->normalize_range(0, 255);
palette.palette()->normalize_range(256, 511);
} }
WRITE8_MEMBER(mario_state::mario_videoram_w) WRITE8_MEMBER(mario_state::mario_videoram_w)
@ -126,10 +126,7 @@ WRITE8_MEMBER(mario_state::mario_flip_w)
TILE_GET_INFO_MEMBER(mario_state::get_bg_tile_info) TILE_GET_INFO_MEMBER(mario_state::get_bg_tile_info)
{ {
int code = m_videoram[tile_index] + 256 * m_gfx_bank; int code = m_videoram[tile_index] + 256 * m_gfx_bank;
int color; int color = 8 + (m_videoram[tile_index] >> 5) + 16 * m_palette_bank;
color = ((m_videoram[tile_index] >> 2) & 0x38) | 0x40 | (m_palette_bank<<7) | (m_monitor<<8);
color = color >> 2;
SET_TILE_INFO_MEMBER(0, code, color, 0); SET_TILE_INFO_MEMBER(0, code, color, 0);
} }
@ -138,9 +135,12 @@ void mario_state::video_start()
m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(mario_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(mario_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS,
8, 8, 32, 32); 8, 8, 32, 32);
m_gfxdecode->gfx(0)->set_granularity(8);
m_gfx_bank = 0; m_gfx_bank = 0;
m_palette_bank = 0; m_palette_bank = 0;
m_gfx_scroll = 0; m_gfx_scroll = 0;
m_flip = 0;
save_item(NAME(m_gfx_bank)); save_item(NAME(m_gfx_bank));
save_item(NAME(m_palette_bank)); save_item(NAME(m_palette_bank));
save_item(NAME(m_gfx_scroll)); save_item(NAME(m_gfx_scroll));
@ -195,7 +195,7 @@ void mario_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect,
x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */
code = m_spriteram[offs + 2]; code = m_spriteram[offs + 2];
color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor; color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank;
flipx = (m_spriteram[offs + 1] & 0x80); flipx = (m_spriteram[offs + 1] & 0x80);
flipy = (m_spriteram[offs + 1] & 0x40); flipy = (m_spriteram[offs + 1] & 0x40);
@ -220,7 +220,7 @@ void mario_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect,
// x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ // x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */
code = (m_spriteram[offs + 2] & 0x7f) | ((m_spriteram[offs + 1] & 0x40) << 1); // upper tile bit is where the flipy bit goes on mario code = (m_spriteram[offs + 2] & 0x7f) | ((m_spriteram[offs + 1] & 0x40) << 1); // upper tile bit is where the flipy bit goes on mario
color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor; color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank;
flipx = (m_spriteram[offs + 1] & 0x80); flipx = (m_spriteram[offs + 1] & 0x80);
flipy = (m_spriteram[offs + 2] & 0x80); // and the flipy bit is where the upper tile bit is on mario flipy = (m_spriteram[offs + 2] & 0x80); // and the flipy bit is where the upper tile bit is on mario
@ -257,7 +257,7 @@ UINT32 mario_state::screen_update_common(screen_device &screen, bitmap_ind16 &bi
if (t != m_monitor) if (t != m_monitor)
{ {
m_monitor = t; m_monitor = t;
machine().tilemap().mark_all_dirty(); PALETTE_INIT_NAME(mario)(m_palette);
} }
m_bg_tilemap->set_scrolly(0, m_gfx_scroll); m_bg_tilemap->set_scrolly(0, m_gfx_scroll);