Merge pull request #4273 from cam900/stadhero_clean

stadhero.cpp : Minor cleanups, Add notes
This commit is contained in:
R. Belmont 2018-11-09 09:46:12 -05:00 committed by GitHub
commit b9a2670388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 68 deletions

View File

@ -18,6 +18,9 @@
HSync = 15.6246kHz
VSync = 57.4434Hz
TODO : RNG issue? Some behavior isn't correct (ex: BGM randomizer).
reference: https://youtu.be/6azneK6uUnA
***************************************************************************/
#include "emu.h"
@ -35,20 +38,9 @@
/******************************************************************************/
WRITE16_MEMBER(stadhero_state::stadhero_control_w)
WRITE16_MEMBER(stadhero_state::int_ack_w)
{
switch (offset<<1)
{
case 4: /* Interrupt ack (VBL - IRQ 5) */
break;
case 6: /* 6502 sound cpu */
m_soundlatch->write(space, 0, data & 0xff);
m_audiocpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero);
break;
default:
logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",m_maincpu->pc(),data,0x30c010+offset);
break;
}
m_maincpu->set_input_line(M68K_IRQ_5, CLEAR_LINE);
}
@ -57,14 +49,14 @@ WRITE16_MEMBER(stadhero_state::stadhero_control_w)
void stadhero_state::main_map(address_map &map)
{
map(0x000000, 0x01ffff).rom();
map(0x200000, 0x2007ff).ram().w(FUNC(stadhero_state::stadhero_pf1_data_w)).share("pf1_data");
map(0x240000, 0x240007).w(m_tilegen1, FUNC(deco_bac06_device::pf_control_0_w)); /* text layer */
map(0x240010, 0x240017).w(m_tilegen1, FUNC(deco_bac06_device::pf_control_1_w));
map(0x260000, 0x261fff).rw(m_tilegen1, FUNC(deco_bac06_device::pf_data_r), FUNC(deco_bac06_device::pf_data_w));
map(0x200000, 0x2007ff).ram().w(FUNC(stadhero_state::pf1_data_w)).share("pf1_data");
map(0x240000, 0x240007).w(m_tilegen, FUNC(deco_bac06_device::pf_control_0_w)); /* text layer */
map(0x240010, 0x240017).w(m_tilegen, FUNC(deco_bac06_device::pf_control_1_w));
map(0x260000, 0x261fff).rw(m_tilegen, FUNC(deco_bac06_device::pf_data_r), FUNC(deco_bac06_device::pf_data_w));
map(0x30c000, 0x30c001).portr("INPUTS");
map(0x30c002, 0x30c003).portr("COIN");
map(0x30c004, 0x30c005).portr("DSW");
map(0x30c000, 0x30c00b).w(FUNC(stadhero_state::stadhero_control_w));
map(0x30c004, 0x30c005).portr("DSW").w(FUNC(stadhero_state::int_ack_w));
map(0x30c007, 0x30c007).w(m_soundlatch, FUNC(generic_latch_8_device::write));
map(0x310000, 0x3107ff).ram().w("palette", FUNC(palette_device::write16)).share("palette");
map(0xff8000, 0xffbfff).ram(); /* Main ram */
map(0xffc000, 0xffc7ff).mirror(0x000800).ram().share("spriteram");
@ -160,37 +152,33 @@ INPUT_PORTS_END
static const gfx_layout charlayout =
{
8,8, /* 8*8 chars */
4096,
RGN_FRAC(1,3),
3, /* 4 bits per pixel */
{ 0x00000*8,0x8000*8,0x10000*8 },
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
{ RGN_FRAC(0,3), RGN_FRAC(1,3), RGN_FRAC(2,3) },
{ STEP8(0,1) },
{ STEP8(0,8) },
8*8 /* every char takes 8 consecutive bytes */
};
static const gfx_layout tile_3bpp =
{
16,16,
2048,
RGN_FRAC(1,3),
3,
{ 0x20000*8, 0x10000*8, 0x00000*8 },
{ 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
0, 1, 2, 3, 4, 5, 6, 7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
{ RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
{ STEP8(16*8,1), STEP8(0,1) },
{ STEP16(0,8) },
16*16
};
static const gfx_layout spritelayout =
{
16,16,
4096,
RGN_FRAC(1,4),
4,
{ 0x60000*8,0x40000*8,0x20000*8,0x00000*8 },
{ 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
0, 1, 2, 3, 4, 5, 6, 7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
{ RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4), RGN_FRAC(0,4) },
{ STEP8(16*8,1), STEP8(0,1) },
{ STEP16(0,8) },
16*16
};
@ -207,37 +195,37 @@ MACHINE_CONFIG_START(stadhero_state::stadhero)
/* basic machine hardware */
MCFG_DEVICE_ADD("maincpu", M68000, 20_MHz_XTAL/2)
MCFG_DEVICE_PROGRAM_MAP(main_map)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", stadhero_state, irq5_line_hold)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", stadhero_state, irq5_line_assert)
MCFG_DEVICE_ADD("audiocpu", M6502, 24_MHz_XTAL/16)
MCFG_DEVICE_PROGRAM_MAP(audio_map)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE(58)
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
MCFG_SCREEN_SIZE(32*8, 32*8)
MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
MCFG_SCREEN_UPDATE_DRIVER(stadhero_state, screen_update_stadhero)
MCFG_SCREEN_PALETTE("palette")
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh(HZ_TO_ATTOSECONDS(58));
screen.set_vblank_time(ATTOSECONDS_IN_USEC(529));
screen.set_size(32*8, 32*8);
screen.set_visarea(0*8, 32*8-1, 1*8, 31*8-1);
screen.set_screen_update(FUNC(stadhero_state::screen_update));
screen.set_palette("palette");
MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_stadhero)
MCFG_PALETTE_ADD("palette", 1024)
MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR)
GFXDECODE(config, m_gfxdecode, "palette", gfx_stadhero);
MCFG_DEVICE_ADD("tilegen1", DECO_BAC06, 0)
MCFG_DECO_BAC06_GFX_REGION_WIDE(1, 1, 2)
MCFG_DECO_BAC06_GFXDECODE("gfxdecode")
PALETTE(config, "palette", 1024).set_format(PALETTE_FORMAT_xxxxBBBBGGGGRRRR);
MCFG_DEVICE_ADD("spritegen", DECO_MXC06, 0)
MCFG_DECO_MXC06_GFX_REGION(2)
MCFG_DECO_MXC06_GFXDECODE("gfxdecode")
DECO_BAC06(config, m_tilegen, 0);
m_tilegen->set_gfx_region_wide(1, 1, 2);
m_tilegen->set_gfxdecode_tag(m_gfxdecode);
DECO_MXC06(config, m_spritegen, 0);
m_spritegen->set_gfx_region(2);
m_spritegen->set_gfxdecode_tag(m_gfxdecode);
/* sound hardware */
SPEAKER(config, "mono").front_center();
MCFG_GENERIC_LATCH_8_ADD("soundlatch")
GENERIC_LATCH_8(config, m_soundlatch, 0);
m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI);
MCFG_DEVICE_ADD("ym1", YM2203, 24_MHz_XTAL/16)
MCFG_SOUND_ROUTE(0, "mono", 0.95)

View File

@ -8,11 +8,11 @@
class stadhero_state : public driver_device
{
public:
stadhero_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
stadhero_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_tilegen1(*this, "tilegen1"),
m_tilegen(*this, "tilegen"),
m_spritegen(*this, "spritegen"),
m_gfxdecode(*this, "gfxdecode"),
m_soundlatch(*this, "soundlatch"),
@ -24,7 +24,7 @@ public:
private:
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<deco_bac06_device> m_tilegen1;
required_device<deco_bac06_device> m_tilegen;
required_device<deco_mxc06_device> m_spritegen;
required_device<gfxdecode_device> m_gfxdecode;
required_device<generic_latch_8_device> m_soundlatch;
@ -34,13 +34,13 @@ private:
tilemap_t *m_pf1_tilemap;
DECLARE_WRITE16_MEMBER(stadhero_control_w);
DECLARE_WRITE16_MEMBER(stadhero_pf1_data_w);
DECLARE_WRITE16_MEMBER(int_ack_w);
DECLARE_WRITE16_MEMBER(pf1_data_w);
virtual void video_start() override;
TILE_GET_INFO_MEMBER(get_pf1_tile_info);
uint32_t screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void audio_map(address_map &map);
void main_map(address_map &map);
};

View File

@ -23,7 +23,7 @@ public:
deco_bac06_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// configuration
void set_gfxdecode_tag(const char *tag) { m_gfxdecode.set_tag(tag); }
template <typename T> void set_gfxdecode_tag(T &&tag) { m_gfxdecode.set_tag(std::forward<T>(tag)); }
void set_gfx_region_wide(int region8x8, int region16x16, int wide)
{
m_gfxregion8x8 = region8x8;

View File

@ -12,7 +12,7 @@ public:
deco_mxc06_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// configuration
void set_gfxdecode_tag(const char *tag) { m_gfxdecode.set_tag(tag); }
template <typename T> void set_gfxdecode_tag(T &&tag) { m_gfxdecode.set_tag(std::forward<T>(tag)); }
void set_gfx_region(int region) { m_gfxregion = region; }
void set_ram_size(int size) { m_ramsize = size; }

View File

@ -20,15 +20,15 @@
/******************************************************************************/
uint32_t stadhero_state::screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
uint32_t stadhero_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
bool flip = m_tilegen1->get_flip_state();
m_tilegen1->set_flip_screen(flip);
bool flip = m_tilegen->get_flip_state();
m_tilegen->set_flip_screen(flip);
m_spritegen->set_flip_screen(flip);
m_pf1_tilemap->set_flip(flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
m_tilegen1->set_bppmultmask(0x8, 0x7);
m_tilegen1->deco_bac06_pf_draw(bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
m_tilegen->set_bppmultmask(0x8, 0x7);
m_tilegen->deco_bac06_pf_draw(bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
m_spritegen->draw_sprites(bitmap, cliprect, m_spriteram, 0x00, 0x00, 0x0f);
m_pf1_tilemap->draw(screen, bitmap, cliprect, 0,0);
return 0;
@ -36,7 +36,7 @@ uint32_t stadhero_state::screen_update_stadhero(screen_device &screen, bitmap_in
/******************************************************************************/
WRITE16_MEMBER(stadhero_state::stadhero_pf1_data_w)
WRITE16_MEMBER(stadhero_state::pf1_data_w)
{
COMBINE_DATA(&m_pf1_data[offset]);
m_pf1_tilemap->mark_tile_dirty(offset);