dogfgt.cpp: device_finder (nw)

This commit is contained in:
Ivan Vangelista 2018-05-31 17:19:35 +02:00
parent 47f1777f44
commit 15692247ef
3 changed files with 71 additions and 83 deletions

View File

@ -13,21 +13,9 @@ driver by Nicola Salmoria
#include "includes/dogfgt.h" #include "includes/dogfgt.h"
#include "cpu/m6502/m6502.h" #include "cpu/m6502/m6502.h"
#include "sound/ay8910.h"
#include "speaker.h" #include "speaker.h"
READ8_MEMBER(dogfgt_state::sharedram_r)
{
return m_sharedram[offset];
}
WRITE8_MEMBER(dogfgt_state::sharedram_w)
{
m_sharedram[offset] = data;
}
WRITE8_MEMBER(dogfgt_state::subirqtrigger_w) WRITE8_MEMBER(dogfgt_state::subirqtrigger_w)
{ {
/* bit 0 used but unknown */ /* bit 0 used but unknown */
@ -40,20 +28,20 @@ WRITE8_MEMBER(dogfgt_state::sub_irqack_w)
m_subcpu->set_input_line(0, CLEAR_LINE); m_subcpu->set_input_line(0, CLEAR_LINE);
} }
WRITE8_MEMBER(dogfgt_state::dogfgt_soundlatch_w) WRITE8_MEMBER(dogfgt_state::soundlatch_w)
{ {
m_soundlatch = data; m_soundlatch = data;
} }
WRITE8_MEMBER(dogfgt_state::dogfgt_soundcontrol_w) WRITE8_MEMBER(dogfgt_state::soundcontrol_w)
{ {
/* bit 5 goes to 8910 #0 BDIR pin */ /* bit 5 goes to 8910 #0 BDIR pin */
if ((m_last_snd_ctrl & 0x20) == 0x20 && (data & 0x20) == 0x00) if ((m_last_snd_ctrl & 0x20) == 0x20 && (data & 0x20) == 0x00)
machine().device<ay8910_device>("ay1")->data_address_w(space, m_last_snd_ctrl >> 4, m_soundlatch); m_ay[0]->data_address_w(space, m_last_snd_ctrl >> 4, m_soundlatch);
/* bit 7 goes to 8910 #1 BDIR pin */ /* bit 7 goes to 8910 #1 BDIR pin */
if ((m_last_snd_ctrl & 0x80) == 0x80 && (data & 0x80) == 0x00) if ((m_last_snd_ctrl & 0x80) == 0x80 && (data & 0x80) == 0x00)
machine().device<ay8910_device>("ay2")->data_address_w(space, m_last_snd_ctrl >> 6, m_soundlatch); m_ay[1]->data_address_w(space, m_last_snd_ctrl >> 6, m_soundlatch);
m_last_snd_ctrl = data; m_last_snd_ctrl = data;
} }
@ -62,28 +50,28 @@ WRITE8_MEMBER(dogfgt_state::dogfgt_soundcontrol_w)
void dogfgt_state::main_map(address_map &map) void dogfgt_state::main_map(address_map &map)
{ {
map(0x0000, 0x07ff).rw(this, FUNC(dogfgt_state::sharedram_r), FUNC(dogfgt_state::sharedram_w)).share("sharedram"); map(0x0000, 0x07ff).ram().share("sharedram");
map(0x0f80, 0x0fdf).writeonly().share("spriteram"); map(0x0f80, 0x0fdf).writeonly().share("spriteram");
map(0x1000, 0x17ff).w(this, FUNC(dogfgt_state::dogfgt_bgvideoram_w)).share("bgvideoram"); map(0x1000, 0x17ff).w(this, FUNC(dogfgt_state::bgvideoram_w)).share("bgvideoram");
map(0x1800, 0x1800).portr("P1"); map(0x1800, 0x1800).portr("P1");
map(0x1800, 0x1800).w(this, FUNC(dogfgt_state::dogfgt_1800_w)); /* text color, flip screen & coin counters */ map(0x1800, 0x1800).w(this, FUNC(dogfgt_state::_1800_w)); /* text color, flip screen & coin counters */
map(0x1810, 0x1810).portr("P2"); map(0x1810, 0x1810).portr("P2");
map(0x1810, 0x1810).w(this, FUNC(dogfgt_state::subirqtrigger_w)); map(0x1810, 0x1810).w(this, FUNC(dogfgt_state::subirqtrigger_w));
map(0x1820, 0x1820).portr("DSW1"); map(0x1820, 0x1820).portr("DSW1");
map(0x1820, 0x1823).w(this, FUNC(dogfgt_state::dogfgt_scroll_w)); map(0x1820, 0x1823).w(this, FUNC(dogfgt_state::scroll_w));
map(0x1824, 0x1824).w(this, FUNC(dogfgt_state::dogfgt_plane_select_w)); map(0x1824, 0x1824).w(this, FUNC(dogfgt_state::plane_select_w));
map(0x1830, 0x1830).portr("DSW2"); map(0x1830, 0x1830).portr("DSW2");
map(0x1830, 0x1830).w(this, FUNC(dogfgt_state::dogfgt_soundlatch_w)); map(0x1830, 0x1830).w(this, FUNC(dogfgt_state::soundlatch_w));
map(0x1840, 0x1840).w(this, FUNC(dogfgt_state::dogfgt_soundcontrol_w)); map(0x1840, 0x1840).w(this, FUNC(dogfgt_state::soundcontrol_w));
map(0x1870, 0x187f).w(m_palette, FUNC(palette_device::write8)).share("palette"); map(0x1870, 0x187f).w(m_palette, FUNC(palette_device::write8)).share("palette");
map(0x2000, 0x3fff).rw(this, FUNC(dogfgt_state::dogfgt_bitmapram_r), FUNC(dogfgt_state::dogfgt_bitmapram_w)); map(0x2000, 0x3fff).rw(this, FUNC(dogfgt_state::bitmapram_r), FUNC(dogfgt_state::bitmapram_w));
map(0x8000, 0xffff).rom(); map(0x8000, 0xffff).rom();
} }
void dogfgt_state::sub_map(address_map &map) void dogfgt_state::sub_map(address_map &map)
{ {
map(0x0000, 0x07ff).ram(); map(0x0000, 0x07ff).ram();
map(0x2000, 0x27ff).rw(this, FUNC(dogfgt_state::sharedram_r), FUNC(dogfgt_state::sharedram_w)); map(0x2000, 0x27ff).ram().share("sharedram");
map(0x4000, 0x4000).w(this, FUNC(dogfgt_state::sub_irqack_w)); map(0x4000, 0x4000).w(this, FUNC(dogfgt_state::sub_irqack_w));
map(0x8000, 0xffff).rom(); map(0x8000, 0xffff).rom();
} }
@ -242,36 +230,36 @@ void dogfgt_state::machine_reset()
MACHINE_CONFIG_START(dogfgt_state::dogfgt) MACHINE_CONFIG_START(dogfgt_state::dogfgt)
/* basic machine hardware */ /* basic machine hardware */
MCFG_DEVICE_ADD("maincpu", M6502, 1500000) /* 1.5 MHz ???? */ MCFG_DEVICE_ADD(m_maincpu, M6502, 1500000) /* 1.5 MHz ???? */
MCFG_DEVICE_PROGRAM_MAP(main_map) MCFG_DEVICE_PROGRAM_MAP(main_map)
MCFG_DEVICE_PERIODIC_INT_DRIVER(dogfgt_state, irq0_line_hold, 16*60) /* ? controls music tempo */ MCFG_DEVICE_PERIODIC_INT_DRIVER(dogfgt_state, irq0_line_hold, 16*60) /* ? controls music tempo */
MCFG_DEVICE_ADD("sub", M6502, 1500000) /* 1.5 MHz ???? */ MCFG_DEVICE_ADD(m_subcpu, M6502, 1500000) /* 1.5 MHz ???? */
MCFG_DEVICE_PROGRAM_MAP(sub_map) MCFG_DEVICE_PROGRAM_MAP(sub_map)
MCFG_QUANTUM_TIME(attotime::from_hz(6000)) MCFG_QUANTUM_TIME(attotime::from_hz(6000))
/* video hardware */ /* video hardware */
MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_ADD(m_screen, RASTER)
MCFG_SCREEN_REFRESH_RATE(60) MCFG_SCREEN_REFRESH_RATE(60)
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_SIZE(32*8, 32*8)
MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
MCFG_SCREEN_UPDATE_DRIVER(dogfgt_state, screen_update_dogfgt) MCFG_SCREEN_UPDATE_DRIVER(dogfgt_state, screen_update)
MCFG_SCREEN_PALETTE("palette") MCFG_SCREEN_PALETTE("palette")
MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_dogfgt) MCFG_DEVICE_ADD(m_gfxdecode, GFXDECODE, m_palette, gfx_dogfgt)
MCFG_PALETTE_ADD("palette", 16+64) MCFG_PALETTE_ADD(m_palette, 16+64)
MCFG_PALETTE_FORMAT(BBGGGRRR) MCFG_PALETTE_FORMAT(BBGGGRRR)
MCFG_PALETTE_INIT_OWNER(dogfgt_state, dogfgt) MCFG_PALETTE_INIT_OWNER(dogfgt_state, dogfgt)
/* sound hardware */ /* sound hardware */
SPEAKER(config, "mono").front_center(); SPEAKER(config, "mono").front_center();
MCFG_DEVICE_ADD("ay1", AY8910, 1500000) MCFG_DEVICE_ADD(m_ay[0], AY8910, 1500000)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
MCFG_DEVICE_ADD("ay2", AY8910, 1500000) MCFG_DEVICE_ADD(m_ay[1], AY8910, 1500000)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
MACHINE_CONFIG_END MACHINE_CONFIG_END

View File

@ -1,5 +1,6 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Nicola Salmoria // copyright-holders:Nicola Salmoria
#include "sound/ay8910.h"
#include "screen.h" #include "screen.h"
#define PIXMAP_COLOR_BASE (16 + 32) #define PIXMAP_COLOR_BASE (16 + 32)
@ -18,13 +19,30 @@ public:
m_maincpu(*this, "maincpu"), m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"), m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"), m_screen(*this, "screen"),
m_palette(*this, "palette") { } m_palette(*this, "palette"),
m_ay(*this, "ay%u", 0U) { }
void dogfgt(machine_config &config);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
private:
/* memory pointers */ /* memory pointers */
required_shared_ptr<uint8_t> m_bgvideoram; required_shared_ptr<uint8_t> m_bgvideoram;
required_shared_ptr<uint8_t> m_spriteram; required_shared_ptr<uint8_t> m_spriteram;
required_shared_ptr<uint8_t> m_sharedram; required_shared_ptr<uint8_t> m_sharedram;
/* devices */
required_device<cpu_device> m_subcpu;
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
required_device_array<ay8910_device, 2> m_ay;
/* video-related */ /* video-related */
bitmap_ind16 m_pixbitmap; bitmap_ind16 m_pixbitmap;
tilemap_t *m_bg_tilemap; tilemap_t *m_bg_tilemap;
@ -39,33 +57,24 @@ public:
int m_soundlatch; int m_soundlatch;
int m_last_snd_ctrl; int m_last_snd_ctrl;
/* devices */
required_device<cpu_device> m_subcpu;
DECLARE_READ8_MEMBER(sharedram_r);
DECLARE_WRITE8_MEMBER(sharedram_w);
DECLARE_WRITE8_MEMBER(subirqtrigger_w); DECLARE_WRITE8_MEMBER(subirqtrigger_w);
DECLARE_WRITE8_MEMBER(sub_irqack_w); DECLARE_WRITE8_MEMBER(sub_irqack_w);
DECLARE_WRITE8_MEMBER(dogfgt_soundlatch_w); DECLARE_WRITE8_MEMBER(soundlatch_w);
DECLARE_WRITE8_MEMBER(dogfgt_soundcontrol_w); DECLARE_WRITE8_MEMBER(soundcontrol_w);
DECLARE_WRITE8_MEMBER(dogfgt_plane_select_w); DECLARE_WRITE8_MEMBER(plane_select_w);
DECLARE_READ8_MEMBER(dogfgt_bitmapram_r); DECLARE_READ8_MEMBER(bitmapram_r);
DECLARE_WRITE8_MEMBER(internal_bitmapram_w); DECLARE_WRITE8_MEMBER(internal_bitmapram_w);
DECLARE_WRITE8_MEMBER(dogfgt_bitmapram_w); DECLARE_WRITE8_MEMBER(bitmapram_w);
DECLARE_WRITE8_MEMBER(dogfgt_bgvideoram_w); DECLARE_WRITE8_MEMBER(bgvideoram_w);
DECLARE_WRITE8_MEMBER(dogfgt_scroll_w); DECLARE_WRITE8_MEMBER(scroll_w);
DECLARE_WRITE8_MEMBER(dogfgt_1800_w); DECLARE_WRITE8_MEMBER(_1800_w);
TILE_GET_INFO_MEMBER(get_tile_info); TILE_GET_INFO_MEMBER(get_tile_info);
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
DECLARE_PALETTE_INIT(dogfgt); DECLARE_PALETTE_INIT(dogfgt);
uint32_t screen_update_dogfgt(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( bitmap_ind16 &bitmap,const rectangle &cliprect ); void draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect );
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
void dogfgt(machine_config &config);
void main_map(address_map &map); void main_map(address_map &map);
void sub_map(address_map &map); void sub_map(address_map &map);
}; };

View File

@ -16,10 +16,9 @@
PALETTE_INIT_MEMBER(dogfgt_state, dogfgt) PALETTE_INIT_MEMBER(dogfgt_state, dogfgt)
{ {
const uint8_t *color_prom = memregion("proms")->base(); const uint8_t *color_prom = memregion("proms")->base();
int i;
/* first 16 colors are RAM */ /* first 16 colors are RAM */
for (i = 0; i < 64; i++) for (int i = 0; i < 64; i++)
{ {
int bit0, bit1, bit2, r, g, b; int bit0, bit1, bit2, r, g, b;
@ -84,12 +83,12 @@ void dogfgt_state::video_start()
***************************************************************************/ ***************************************************************************/
WRITE8_MEMBER(dogfgt_state::dogfgt_plane_select_w) WRITE8_MEMBER(dogfgt_state::plane_select_w)
{ {
m_bm_plane = data; m_bm_plane = data;
} }
READ8_MEMBER(dogfgt_state::dogfgt_bitmapram_r) READ8_MEMBER(dogfgt_state::bitmapram_r)
{ {
if (m_bm_plane > 2) if (m_bm_plane > 2)
{ {
@ -102,19 +101,17 @@ READ8_MEMBER(dogfgt_state::dogfgt_bitmapram_r)
WRITE8_MEMBER(dogfgt_state::internal_bitmapram_w) WRITE8_MEMBER(dogfgt_state::internal_bitmapram_w)
{ {
int x, y, subx;
m_bitmapram[offset] = data; m_bitmapram[offset] = data;
offset &= (BITMAPRAM_SIZE / 3 - 1); offset &= (BITMAPRAM_SIZE / 3 - 1);
x = 8 * (offset / 256); int x = 8 * (offset / 256);
y = offset % 256; int y = offset % 256;
for (subx = 0; subx < 8; subx++) for (int subx = 0; subx < 8; subx++)
{ {
int i, color = 0; int color = 0;
for (i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
color |= ((m_bitmapram[offset + BITMAPRAM_SIZE / 3 * i] >> subx) & 1) << i; color |= ((m_bitmapram[offset + BITMAPRAM_SIZE / 3 * i] >> subx) & 1) << i;
if (flip_screen()) if (flip_screen())
@ -124,7 +121,7 @@ WRITE8_MEMBER(dogfgt_state::internal_bitmapram_w)
} }
} }
WRITE8_MEMBER(dogfgt_state::dogfgt_bitmapram_w) WRITE8_MEMBER(dogfgt_state::bitmapram_w)
{ {
if (m_bm_plane > 2) if (m_bm_plane > 2)
{ {
@ -135,20 +132,20 @@ WRITE8_MEMBER(dogfgt_state::dogfgt_bitmapram_w)
internal_bitmapram_w(space, offset + BITMAPRAM_SIZE / 3 * m_bm_plane, data); internal_bitmapram_w(space, offset + BITMAPRAM_SIZE / 3 * m_bm_plane, data);
} }
WRITE8_MEMBER(dogfgt_state::dogfgt_bgvideoram_w) WRITE8_MEMBER(dogfgt_state::bgvideoram_w)
{ {
m_bgvideoram[offset] = data; m_bgvideoram[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset & 0x3ff); m_bg_tilemap->mark_tile_dirty(offset & 0x3ff);
} }
WRITE8_MEMBER(dogfgt_state::dogfgt_scroll_w) WRITE8_MEMBER(dogfgt_state::scroll_w)
{ {
m_scroll[offset] = data; m_scroll[offset] = data;
m_bg_tilemap->set_scrollx(0, m_scroll[0] + 256 * m_scroll[1] + 256); m_bg_tilemap->set_scrollx(0, m_scroll[0] + 256 * m_scroll[1] + 256);
m_bg_tilemap->set_scrolly(0, m_scroll[2] + 256 * m_scroll[3]); m_bg_tilemap->set_scrolly(0, m_scroll[2] + 256 * m_scroll[3]);
} }
WRITE8_MEMBER(dogfgt_state::dogfgt_1800_w) WRITE8_MEMBER(dogfgt_state::_1800_w)
{ {
/* bits 0 and 1 are probably text color (not verified because PROM is missing) */ /* bits 0 and 1 are probably text color (not verified because PROM is missing) */
m_pixcolor = ((data & 0x01) << 1) | ((data & 0x02) >> 1); m_pixcolor = ((data & 0x01) << 1) | ((data & 0x02) >> 1);
@ -173,18 +170,14 @@ WRITE8_MEMBER(dogfgt_state::dogfgt_1800_w)
void dogfgt_state::draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect ) void dogfgt_state::draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect )
{ {
int offs; for (int offs = 0; offs < m_spriteram.bytes(); offs += 4)
for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
{ {
if (m_spriteram[offs] & 0x01) if (m_spriteram[offs] & 0x01)
{ {
int sx, sy, flipx, flipy; int sx = m_spriteram[offs + 3];
int sy = (240 - m_spriteram[offs + 2]) & 0xff;
sx = m_spriteram[offs + 3]; int flipx = m_spriteram[offs] & 0x04;
sy = (240 - m_spriteram[offs + 2]) & 0xff; int flipy = m_spriteram[offs] & 0x02;
flipx = m_spriteram[offs] & 0x04;
flipy = m_spriteram[offs] & 0x02;
if (flip_screen()) if (flip_screen())
{ {
sx = 240 - sx; sx = 240 - sx;
@ -203,10 +196,8 @@ void dogfgt_state::draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect
} }
uint32_t dogfgt_state::screen_update_dogfgt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) uint32_t dogfgt_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
int offs;
if (m_lastflip != flip_screen() || m_lastpixcolor != m_pixcolor) if (m_lastflip != flip_screen() || m_lastpixcolor != m_pixcolor)
{ {
address_space &space = m_maincpu->space(AS_PROGRAM); address_space &space = m_maincpu->space(AS_PROGRAM);
@ -214,7 +205,7 @@ uint32_t dogfgt_state::screen_update_dogfgt(screen_device &screen, bitmap_ind16
m_lastflip = flip_screen(); m_lastflip = flip_screen();
m_lastpixcolor = m_pixcolor; m_lastpixcolor = m_pixcolor;
for (offs = 0; offs < BITMAPRAM_SIZE; offs++) for (int offs = 0; offs < BITMAPRAM_SIZE; offs++)
internal_bitmapram_w(space, offs, m_bitmapram[offs]); internal_bitmapram_w(space, offs, m_bitmapram[offs]);
} }