Previous 199869 Revisions Next

r33296 Sunday 9th November, 2014 at 08:27:54 UTC by Alex W. Jackson
mario.c: fix Monitor switch so it correctly affects both tiles and sprites [Alex Jackson]
[src/mame/drivers]mario.c
[src/mame/includes]mario.h
[src/mame/video]mario.c

trunk/src/mame/drivers/mario.c
r241807r241808
448448};
449449
450450static GFXDECODE_START( mario )
451   GFXDECODE_ENTRY( "gfx1", 0, charlayout,      0, 16 )
452   GFXDECODE_ENTRY( "gfx2", 0, spritelayout,     0, 32 )
451   GFXDECODE_ENTRY( "gfx1", 0, charlayout,   0, 32 )
452   GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 0, 32 )
453453GFXDECODE_END
454454
455455static const gfx_layout spritelayout_bl =
r241807r241808
466466};
467467
468468static GFXDECODE_START( mariobl )
469   GFXDECODE_ENTRY( "gfx1", 0, charlayout,      0, 16 )
470   GFXDECODE_ENTRY( "gfx2", 0, spritelayout_bl,     0, 32 )
469   GFXDECODE_ENTRY( "gfx1", 0, charlayout,      0, 32 )
470   GFXDECODE_ENTRY( "gfx2", 0, spritelayout_bl, 0, 32 )
471471GFXDECODE_END
472472
473473static const gfx_layout spritelayout_bl2 =
r241807r241808
521521   MCFG_SCREEN_UPDATE_DRIVER(mario_state, screen_update_mario)
522522   MCFG_SCREEN_PALETTE("palette")
523523   MCFG_GFXDECODE_ADD("gfxdecode", "palette", mario)
524   MCFG_PALETTE_ADD("palette", 512)
524   MCFG_PALETTE_ADD("palette", 256)
525525   MCFG_PALETTE_INIT_OWNER(mario_state, mario)
526526
527527MACHINE_CONFIG_END
r241807r241808
577577   MCFG_SCREEN_UPDATE_DRIVER(mario_state, screen_update_mariobl)
578578   MCFG_SCREEN_PALETTE("palette")
579579   MCFG_GFXDECODE_ADD("gfxdecode", "palette", mariobl)
580   MCFG_PALETTE_ADD("palette", 512)
580   MCFG_PALETTE_ADD("palette", 256)
581581   MCFG_PALETTE_INIT_OWNER(mario_state, mario)
582582
583583   /* sound hardware */
trunk/src/mame/includes/mario.h
r241807r241808
3131#define I8035_MASTER_CLOCK      XTAL_11MHz /* verified on pcb: 730Khz */
3232#define I8035_CLOCK             (I8035_MASTER_CLOCK)
3333
34#define MARIO_PALETTE_LENGTH    (256)
35
3634class mario_state : public driver_device
3735{
3836public:
3937   mario_state(const machine_config &mconfig, device_type type, const char *tag)
4038      : driver_device(mconfig, type, tag),
41      m_spriteram(*this, "spriteram"),
42      m_videoram(*this, "videoram"),
43      m_discrete(*this, "discrete"),
39     
4440      m_maincpu(*this, "maincpu"),
4541      m_audiocpu(*this, "audiocpu"),
4642      m_gfxdecode(*this, "gfxdecode"),
4743      m_palette(*this, "palette"),
48      m_z80dma(*this, "z80dma") { }
44      m_z80dma(*this, "z80dma"),
45      m_discrete(*this, "discrete"),
46      m_spriteram(*this, "spriteram"),
47      m_videoram(*this, "videoram"),
48      m_monitor(0) { }
4949
50   /* devices */
51   required_device<cpu_device> m_maincpu;
52   optional_device<cpu_device> m_audiocpu;
53   required_device<gfxdecode_device> m_gfxdecode;
54   required_device<palette_device> m_palette;
55   optional_device<z80dma_device> m_z80dma;
56   optional_device<discrete_device> m_discrete;
57
5058   /* memory pointers */
59   required_shared_ptr<UINT8> m_spriteram;
60   required_shared_ptr<UINT8> m_videoram;
5161
52   /* machine states */
53
5462   /* sound state */
5563   UINT8   m_last;
5664   UINT8   m_portT;
r241807r241808
6169   UINT8   m_palette_bank;
6270   UINT16  m_gfx_scroll;
6371   UINT8   m_flip;
64
65   /* driver general */
66
67   required_shared_ptr<UINT8> m_spriteram;
68   required_shared_ptr<UINT8> m_videoram;
69   optional_device<discrete_device> m_discrete;
7072   tilemap_t *m_bg_tilemap;
7173   int m_monitor;
7274
r241807r241808
104106   DECLARE_READ8_MEMBER(memory_read_byte);
105107   DECLARE_WRITE8_MEMBER(memory_write_byte);
106108   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int is_bootleg);
107   required_device<cpu_device> m_maincpu;
108   optional_device<cpu_device> m_audiocpu;
109   required_device<gfxdecode_device> m_gfxdecode;
110   required_device<palette_device> m_palette;
111   optional_device<z80dma_device> m_z80dma;
112109};
113110
114111/*----------- defined in audio/mario.c -----------*/
trunk/src/mame/video/mario.c
r241807r241808
6767   const UINT8 *color_prom = memregion("proms")->base();
6868   dynamic_array<rgb_t> rgb;
6969
70   compute_res_net_all(rgb, color_prom, mario_decode_info, mario_net_info);
70   if (m_monitor == 0)
71      compute_res_net_all(rgb, color_prom, mario_decode_info, mario_net_info);
72   else
73      compute_res_net_all(rgb, color_prom+256, mario_decode_info, mario_net_info_std);
74
7175   palette.set_pen_colors(0, rgb, 256);
72   compute_res_net_all(rgb, color_prom+256, mario_decode_info, mario_net_info_std);
73   palette.set_pen_colors(256, rgb, 256);
74
7576   palette.palette()->normalize_range(0, 255);
76   palette.palette()->normalize_range(256, 511);
7777}
7878
7979WRITE8_MEMBER(mario_state::mario_videoram_w)
r241807r241808
126126TILE_GET_INFO_MEMBER(mario_state::get_bg_tile_info)
127127{
128128   int code = m_videoram[tile_index] + 256 * m_gfx_bank;
129   int color;
130
131   color =  ((m_videoram[tile_index] >> 2) & 0x38) | 0x40 | (m_palette_bank<<7) | (m_monitor<<8);
132   color = color >> 2;
129   int color = 8 + (m_videoram[tile_index] >> 5) + 16 * m_palette_bank;
133130   SET_TILE_INFO_MEMBER(0, code, color, 0);
134131}
135132
r241807r241808
138135   m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(mario_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS,
139136         8, 8, 32, 32);
140137
138   m_gfxdecode->gfx(0)->set_granularity(8);
139
141140   m_gfx_bank = 0;
142141   m_palette_bank = 0;
143142   m_gfx_scroll = 0;
143   m_flip = 0;
144144   save_item(NAME(m_gfx_bank));
145145   save_item(NAME(m_palette_bank));
146146   save_item(NAME(m_gfx_scroll));
r241807r241808
195195            x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */
196196
197197            code = m_spriteram[offs + 2];
198            color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor;
198            color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank;
199199            flipx = (m_spriteram[offs + 1] & 0x80);
200200            flipy = (m_spriteram[offs + 1] & 0x40);
201201
r241807r241808
220220         //  x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */
221221
222222            code = (m_spriteram[offs + 2] & 0x7f) | ((m_spriteram[offs + 1] & 0x40) << 1); // upper tile bit is where the flipy bit goes on mario
223            color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor;
223            color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank;
224224            flipx = (m_spriteram[offs + 1] & 0x80);
225225            flipy = (m_spriteram[offs + 2] & 0x80); // and the flipy bit is where the upper tile bit is on mario
226226
r241807r241808
257257   if (t != m_monitor)
258258   {
259259      m_monitor = t;
260      machine().tilemap().mark_all_dirty();
260      PALETTE_INIT_NAME(mario)(m_palette);
261261   }
262262
263263   m_bg_tilemap->set_scrolly(0, m_gfx_scroll);


Previous 199869 Revisions Next


© 1997-2024 The MAME Team