mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
prehisle.cpp : Cleanups
Cleanup handlers, Fix some namings, Fix scroll, Cleanup gfxdecode Move non-video related save state into machine_start
This commit is contained in:
parent
44e0aa6191
commit
1512fcdde6
@ -38,25 +38,31 @@ void prehisle_state::prehisle_map(address_map &map)
|
||||
map(0x0a0000, 0x0a07ff).ram().share("spriteram");
|
||||
map(0x0b0000, 0x0b3fff).ram().w(FUNC(prehisle_state::fg_vram_w)).share("fg_vram");
|
||||
map(0x0d0000, 0x0d07ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
|
||||
map(0x0e0000, 0x0e00ff).r(FUNC(prehisle_state::control_r));
|
||||
map(0x0f0000, 0x0ff0ff).w(FUNC(prehisle_state::control_w));
|
||||
map(0x0f0070, 0x0ff071).w(FUNC(prehisle_state::soundcmd_w));
|
||||
map(0x0e0010, 0x0e0011).portr("P2"); // Player 2
|
||||
map(0x0e0020, 0x0e0021).portr("COIN"); // Coins, Tilt, Service
|
||||
map(0x0e0041, 0x0e0041).lr8("P1_r", [this]() -> u8 { return m_io_p1->read() ^ m_invert_controls; }); // Player 1
|
||||
map(0x0e0042, 0x0e0043).portr("DSW0"); // DIPs
|
||||
map(0x0e0044, 0x0e0045).portr("DSW1"); // DIPs + VBLANK
|
||||
map(0x0f0000, 0x0f0001).w(FUNC(prehisle_state::fg_scrolly_w));
|
||||
map(0x0f0010, 0x0f0011).w(FUNC(prehisle_state::fg_scrollx_w));
|
||||
map(0x0f0020, 0x0f0021).w(FUNC(prehisle_state::bg_scrolly_w));
|
||||
map(0x0f0030, 0x0f0031).w(FUNC(prehisle_state::bg_scrollx_w));
|
||||
map(0x0f0046, 0x0f0047).lw16("invert_controls_w", [this](u16 data){ m_invert_controls = data ? 0xff : 0x00; });
|
||||
map(0x0f0050, 0x0f0051).lw16("coin_counter_1_w", [this](u16 data){ machine().bookkeeping().coin_counter_w(0, data & 1); });
|
||||
map(0x0f0052, 0x0f0053).lw16("coin_counter_2_w", [this](u16 data){ machine().bookkeeping().coin_counter_w(1, data & 1); });
|
||||
map(0x0f0060, 0x0f0061).lw16("flip_screen_w", [this](u16 data){ flip_screen_set(data & 0x01); });
|
||||
map(0x0f0070, 0x0f0071).w(FUNC(prehisle_state::soundcmd_w));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
WRITE8_MEMBER(prehisle_state::D7759_write_port_0_w)
|
||||
WRITE8_MEMBER(prehisle_state::upd_port_w)
|
||||
{
|
||||
m_upd7759->port_w(data);
|
||||
m_upd7759->start_w(0);
|
||||
m_upd7759->start_w(1);
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(prehisle_state::D7759_upd_reset_w)
|
||||
{
|
||||
m_upd7759->reset_w(BIT(data, 7));
|
||||
}
|
||||
|
||||
void prehisle_state::prehisle_sound_map(address_map &map)
|
||||
{
|
||||
map(0x0000, 0xefff).rom();
|
||||
@ -70,8 +76,8 @@ void prehisle_state::prehisle_sound_io_map(address_map &map)
|
||||
map.global_mask(0xff);
|
||||
map(0x00, 0x00).rw("ymsnd", FUNC(ym3812_device::status_port_r), FUNC(ym3812_device::control_port_w));
|
||||
map(0x20, 0x20).w("ymsnd", FUNC(ym3812_device::write_port_w));
|
||||
map(0x40, 0x40).w(FUNC(prehisle_state::D7759_write_port_0_w));
|
||||
map(0x80, 0x80).w(FUNC(prehisle_state::D7759_upd_reset_w));
|
||||
map(0x40, 0x40).w(FUNC(prehisle_state::upd_port_w));
|
||||
map(0x80, 0x80).lw8("upd_reset", [this](u8 data){ m_upd7759->reset_w(BIT(data, 7)); } );
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@ -156,59 +162,52 @@ INPUT_PORTS_END
|
||||
static const gfx_layout charlayout =
|
||||
{
|
||||
8,8, /* 8*8 characters */
|
||||
1024,
|
||||
RGN_FRAC(1,1),
|
||||
4, /* 4 bits per pixel */
|
||||
{ 0, 1, 2, 3 },
|
||||
{ 0, 4, 8, 12, 16, 20, 24, 28},
|
||||
{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
|
||||
{ STEP4(0,1) },
|
||||
{ STEP8(0,4) },
|
||||
{ STEP8(0,4*8) },
|
||||
32*8 /* every char takes 32 consecutive bytes */
|
||||
};
|
||||
|
||||
static const gfx_layout tilelayout =
|
||||
{
|
||||
16,16, /* 16*16 sprites */
|
||||
0x800,
|
||||
RGN_FRAC(1,1),
|
||||
4, /* 4 bits per pixel */
|
||||
{ 0, 1, 2, 3 },
|
||||
{ 0,4,8,12,16,20,24,28,
|
||||
0+64*8,4+64*8,8+64*8,12+64*8,16+64*8,20+64*8,24+64*8,28+64*8 },
|
||||
{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
|
||||
8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
|
||||
128*8 /* every sprite takes 64 consecutive bytes */
|
||||
};
|
||||
|
||||
static const gfx_layout spritelayout =
|
||||
{
|
||||
16,16, /* 16*16 sprites */
|
||||
5120,
|
||||
4, /* 4 bits per pixel */
|
||||
{ 0, 1, 2, 3 },
|
||||
{ 0,4,8,12,16,20,24,28,
|
||||
0+64*8,4+64*8,8+64*8,12+64*8,16+64*8,20+64*8,24+64*8,28+64*8 },
|
||||
{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
|
||||
8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
|
||||
{ STEP4(0,1) },
|
||||
{ STEP8(0,4), STEP8(4*8*16,4) },
|
||||
{ STEP16(0,4*8) },
|
||||
128*8 /* every sprite takes 64 consecutive bytes */
|
||||
};
|
||||
|
||||
static GFXDECODE_START( gfx_prehisle )
|
||||
GFXDECODE_ENTRY( "chars", 0, charlayout, 0, 16 )
|
||||
GFXDECODE_ENTRY( "chars", 0, charlayout, 0, 16 )
|
||||
GFXDECODE_ENTRY( "bgtiles", 0, tilelayout, 768, 16 )
|
||||
GFXDECODE_ENTRY( "fgtiles", 0, tilelayout, 512, 16 )
|
||||
GFXDECODE_ENTRY( "sprites", 0, spritelayout, 256, 16 )
|
||||
GFXDECODE_ENTRY( "sprites", 0, tilelayout, 256, 16 )
|
||||
GFXDECODE_END
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
void prehisle_state::machine_start()
|
||||
{
|
||||
/* register for saving */
|
||||
save_item(NAME(m_invert_controls));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
MACHINE_CONFIG_START(prehisle_state::prehisle)
|
||||
|
||||
/* basic machine hardware */
|
||||
MCFG_DEVICE_ADD("maincpu", M68000, XTAL(18'000'000)/2) /* verified on pcb */
|
||||
MCFG_DEVICE_PROGRAM_MAP(prehisle_map)
|
||||
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", prehisle_state, irq4_line_hold)
|
||||
M68000(config, m_maincpu, XTAL(18'000'000)/2); /* verified on pcb */
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &prehisle_state::prehisle_map);
|
||||
m_maincpu->set_vblank_int("screen", FUNC(prehisle_state::irq4_line_hold));
|
||||
|
||||
MCFG_DEVICE_ADD("audiocpu", Z80, XTAL(4'000'000)) /* verified on pcb */
|
||||
MCFG_DEVICE_PROGRAM_MAP(prehisle_sound_map)
|
||||
MCFG_DEVICE_IO_MAP(prehisle_sound_io_map)
|
||||
Z80(config, m_audiocpu, XTAL(4'000'000)); /* verified on pcb */
|
||||
m_audiocpu->set_addrmap(AS_PROGRAM, &prehisle_state::prehisle_sound_map);
|
||||
m_audiocpu->set_addrmap(AS_IO, &prehisle_state::prehisle_sound_io_map);
|
||||
|
||||
/* video hardware */
|
||||
MCFG_SCREEN_ADD("screen", RASTER)
|
||||
@ -216,13 +215,11 @@ MACHINE_CONFIG_START(prehisle_state::prehisle)
|
||||
// give a theoretical refresh rate of 59.1856Hz while the measured
|
||||
// rate on a snk68.c with very similar hardware board is 59.16Hz.
|
||||
MCFG_SCREEN_RAW_PARAMS(XTAL(24'000'000)/4, 384, 0, 256, 264, 16, 240)
|
||||
MCFG_SCREEN_UPDATE_DRIVER(prehisle_state, screen_update_prehisle)
|
||||
MCFG_SCREEN_UPDATE_DRIVER(prehisle_state, screen_update)
|
||||
MCFG_SCREEN_PALETTE("palette")
|
||||
|
||||
MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_prehisle)
|
||||
MCFG_PALETTE_ADD("palette", 1024)
|
||||
MCFG_PALETTE_FORMAT(RRRRGGGGBBBBxxxx)
|
||||
|
||||
GFXDECODE(config, m_gfxdecode, m_palette, gfx_prehisle);
|
||||
PALETTE(config, m_palette, 1024).set_format(PALETTE_FORMAT_RRRRGGGGBBBBxxxx);
|
||||
|
||||
/* sound hardware */
|
||||
SPEAKER(config, "mono").front_center();
|
||||
|
@ -8,12 +8,13 @@
|
||||
class prehisle_state : public driver_device
|
||||
{
|
||||
public:
|
||||
prehisle_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
prehisle_state(const machine_config &mconfig, device_type type, const char *tag) :
|
||||
driver_device(mconfig, type, tag),
|
||||
m_tx_vram(*this, "tx_vram"),
|
||||
m_spriteram(*this, "spriteram"),
|
||||
m_fg_vram(*this, "fg_vram"),
|
||||
m_tilemap_rom(*this, "bgtilemap"),
|
||||
m_io_p1(*this, "P1"),
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_audiocpu(*this, "audiocpu"),
|
||||
m_upd7759(*this, "upd"),
|
||||
@ -28,7 +29,13 @@ private:
|
||||
required_shared_ptr<uint16_t> m_spriteram;
|
||||
required_shared_ptr<uint16_t> m_fg_vram;
|
||||
required_region_ptr<uint8_t> m_tilemap_rom;
|
||||
uint16_t m_invert_controls;
|
||||
|
||||
required_ioport m_io_p1;
|
||||
uint8_t m_invert_controls;
|
||||
uint16_t m_bg_scrollx;
|
||||
uint16_t m_bg_scrolly;
|
||||
uint16_t m_fg_scrollx;
|
||||
uint16_t m_fg_scrolly;
|
||||
|
||||
tilemap_t *m_bg_tilemap;
|
||||
tilemap_t *m_fg_tilemap;
|
||||
@ -37,15 +44,17 @@ private:
|
||||
DECLARE_WRITE16_MEMBER(soundcmd_w);
|
||||
DECLARE_WRITE16_MEMBER(fg_vram_w);
|
||||
DECLARE_WRITE16_MEMBER(tx_vram_w);
|
||||
DECLARE_READ16_MEMBER(control_r);
|
||||
DECLARE_WRITE16_MEMBER(control_w);
|
||||
DECLARE_WRITE8_MEMBER(D7759_write_port_0_w);
|
||||
DECLARE_WRITE8_MEMBER(D7759_upd_reset_w);
|
||||
void fg_scrolly_w(offs_t offset, u16 data, u16 mem_mask);
|
||||
void fg_scrollx_w(offs_t offset, u16 data, u16 mem_mask);
|
||||
void bg_scrolly_w(offs_t offset, u16 data, u16 mem_mask);
|
||||
void bg_scrollx_w(offs_t offset, u16 data, u16 mem_mask);
|
||||
DECLARE_WRITE8_MEMBER(upd_port_w);
|
||||
TILE_GET_INFO_MEMBER(get_bg_tile_info);
|
||||
TILE_GET_INFO_MEMBER(get_fg_tile_info);
|
||||
TILE_GET_INFO_MEMBER(get_tx_tile_info);
|
||||
virtual void machine_start() override;
|
||||
virtual void video_start() override;
|
||||
uint32_t screen_update_prehisle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
|
||||
required_device<cpu_device> m_maincpu;
|
||||
|
@ -25,38 +25,31 @@ WRITE16_MEMBER(prehisle_state::tx_vram_w)
|
||||
m_tx_tilemap->mark_tile_dirty(offset);
|
||||
}
|
||||
|
||||
READ16_MEMBER(prehisle_state::control_r)
|
||||
void prehisle_state::fg_scrolly_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
{
|
||||
switch (offset)
|
||||
{
|
||||
case 0x08: return ioport("P2")->read(); // Player 2
|
||||
case 0x10: return ioport("COIN")->read(); // Coins, Tilt, Service
|
||||
case 0x20: return ioport("P1")->read() ^ m_invert_controls; // Player 1
|
||||
case 0x21: return ioport("DSW0")->read(); // DIPs
|
||||
case 0x22: return ioport("DSW1")->read(); // DIPs + VBLANK
|
||||
default: return 0;
|
||||
}
|
||||
COMBINE_DATA(&m_fg_scrolly);
|
||||
m_fg_tilemap->set_scrolly(0, m_fg_scrolly);
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(prehisle_state::control_w)
|
||||
void prehisle_state::fg_scrollx_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
{
|
||||
int scroll = 0;
|
||||
|
||||
COMBINE_DATA(&scroll);
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
case 0x00: m_fg_tilemap->set_scrolly(0, scroll); break;
|
||||
case 0x08: m_fg_tilemap->set_scrollx(0, scroll); break;
|
||||
case 0x10: m_bg_tilemap->set_scrolly(0, scroll); break;
|
||||
case 0x18: m_bg_tilemap->set_scrollx(0, scroll); break;
|
||||
case 0x23: m_invert_controls = data ? 0x00ff : 0x0000; break;
|
||||
case 0x28: machine().bookkeeping().coin_counter_w(0, data & 1); break;
|
||||
case 0x29: machine().bookkeeping().coin_counter_w(1, data & 1); break;
|
||||
case 0x30: flip_screen_set(data & 0x01); break;
|
||||
}
|
||||
COMBINE_DATA(&m_fg_scrollx);
|
||||
m_fg_tilemap->set_scrollx(0, m_fg_scrollx);
|
||||
}
|
||||
|
||||
void prehisle_state::bg_scrolly_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
{
|
||||
COMBINE_DATA(&m_bg_scrolly);
|
||||
m_bg_tilemap->set_scrolly(0, m_bg_scrolly);
|
||||
}
|
||||
|
||||
void prehisle_state::bg_scrollx_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
{
|
||||
COMBINE_DATA(&m_bg_scrollx);
|
||||
m_bg_tilemap->set_scrollx(0, m_bg_scrollx);
|
||||
}
|
||||
|
||||
|
||||
/* tile layout
|
||||
0 xxxx.... color
|
||||
0 ....x... flip x
|
||||
@ -131,7 +124,10 @@ void prehisle_state::video_start()
|
||||
m_tx_tilemap->set_transparent_pen(15);
|
||||
|
||||
/* register for saving */
|
||||
save_item(NAME(m_invert_controls));
|
||||
save_item(NAME(m_bg_scrollx));
|
||||
save_item(NAME(m_bg_scrolly));
|
||||
save_item(NAME(m_fg_scrollx));
|
||||
save_item(NAME(m_fg_scrolly));
|
||||
}
|
||||
|
||||
/* sprite layout
|
||||
@ -150,14 +146,14 @@ void prehisle_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, c
|
||||
|
||||
for (int offs = 1024 - 4; offs >= 0; offs -= 4)
|
||||
{
|
||||
int const attr = spriteram16[offs + 2];
|
||||
int const code = attr & 0x1fff;
|
||||
int const color = spriteram16[offs + 3] >> 12;
|
||||
int const priority = (color < 0x4) ? 0 : GFX_PMASK_1; // correct?
|
||||
uint16_t const attr = spriteram16[offs + 2];
|
||||
uint16_t const code = attr & 0x1fff;
|
||||
uint16_t const color = spriteram16[offs + 3] >> 12;
|
||||
uint32_t const priority = (color < 0x4) ? 0 : GFX_PMASK_1; // correct?
|
||||
bool flipx = attr & 0x4000;
|
||||
bool flipy = attr & 0x8000;
|
||||
int sx = spriteram16[offs + 1] & 0x1ff;
|
||||
int sy = spriteram16[offs] & 0x1ff;
|
||||
int16_t sx = spriteram16[offs + 1] & 0x1ff;
|
||||
int16_t sy = spriteram16[offs] & 0x1ff;
|
||||
|
||||
// coordinates are 9-bit signed
|
||||
if (sx & 0x100) sx = -0x100 + (sx & 0xff);
|
||||
@ -181,7 +177,7 @@ void prehisle_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, c
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t prehisle_state::screen_update_prehisle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
uint32_t prehisle_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
screen.priority().fill(0, cliprect);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user