summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/mame/drivers/88games.c1
-rw-r--r--src/mame/drivers/blockhl.c1
-rw-r--r--src/mame/drivers/bottom9.c1
-rw-r--r--src/mame/drivers/chqflag.c24
-rw-r--r--src/mame/drivers/gradius3.c1
-rw-r--r--src/mame/drivers/mainevt.c2
-rw-r--r--src/mame/drivers/spy.c1
-rw-r--r--src/mame/drivers/thunderx.c1
-rw-r--r--src/mame/drivers/tmnt.c5
-rw-r--r--src/mame/drivers/ultraman.c1
-rw-r--r--src/mame/includes/chqflag.h1
-rw-r--r--src/mame/video/k051960.c85
-rw-r--r--src/mame/video/k051960.h16
13 files changed, 71 insertions, 69 deletions
diff --git a/src/mame/drivers/88games.c b/src/mame/drivers/88games.c
index 386909cc5d0..81695376892 100644
--- a/src/mame/drivers/88games.c
+++ b/src/mame/drivers/88games.c
@@ -328,6 +328,7 @@ static MACHINE_CONFIG_START( 88games, _88games_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(_88games_state, sprite_callback)
MCFG_DEVICE_ADD("k051316", K051316, 0)
diff --git a/src/mame/drivers/blockhl.c b/src/mame/drivers/blockhl.c
index bd510d8e43a..3c258d3f7d7 100644
--- a/src/mame/drivers/blockhl.c
+++ b/src/mame/drivers/blockhl.c
@@ -301,6 +301,7 @@ static MACHINE_CONFIG_START( blockhl, blockhl_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(blockhl_state, sprite_callback)
// sound hardware
diff --git a/src/mame/drivers/bottom9.c b/src/mame/drivers/bottom9.c
index 910eef0e07a..d5e1fa3479c 100644
--- a/src/mame/drivers/bottom9.c
+++ b/src/mame/drivers/bottom9.c
@@ -323,6 +323,7 @@ static MACHINE_CONFIG_START( bottom9, bottom9_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(bottom9_state, sprite_callback)
MCFG_DEVICE_ADD("k051316", K051316, 0)
diff --git a/src/mame/drivers/chqflag.c b/src/mame/drivers/chqflag.c
index 06213dea834..4c9761dedf7 100644
--- a/src/mame/drivers/chqflag.c
+++ b/src/mame/drivers/chqflag.c
@@ -23,16 +23,6 @@
#include "chqflag.lh"
-TIMER_DEVICE_CALLBACK_MEMBER(chqflag_state::chqflag_scanline)
-{
- int scanline = param;
-
- if(scanline == 240 && m_k051960->k051960_is_irq_enabled()) // vblank irq
- m_maincpu->set_input_line(KONAMI_IRQ_LINE, HOLD_LINE);
- else if(((scanline % 32) == 0) && (m_k051960->k051960_is_nmi_enabled())) // timer irq
- m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
-}
-
/* these trampolines are less confusing than nested address_map_bank_devices */
READ8_MEMBER(chqflag_state::k051316_1_ramrom_r)
{
@@ -297,9 +287,8 @@ void chqflag_state::machine_reset()
static MACHINE_CONFIG_START( chqflag, chqflag_state )
/* basic machine hardware */
- MCFG_CPU_ADD("maincpu", KONAMI,XTAL_24MHz/8) /* 052001 (verified on pcb) */
+ MCFG_CPU_ADD("maincpu", KONAMI, XTAL_24MHz/2/4) /* 052001 (verified on pcb) */
MCFG_CPU_PROGRAM_MAP(chqflag_map)
- MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", chqflag_state, chqflag_scanline, "screen", 0, 1)
MCFG_CPU_ADD("audiocpu", Z80, XTAL_3_579545MHz) /* verified on pcb */
MCFG_CPU_PROGRAM_MAP(chqflag_sound_map)
@@ -314,12 +303,10 @@ static MACHINE_CONFIG_START( chqflag, chqflag_state )
MCFG_QUANTUM_TIME(attotime::from_hz(600))
/* video hardware */
- //TODO: Vsync 59.17hz Hsync 15.13 / 15.19khz
MCFG_SCREEN_ADD("screen", RASTER)
- MCFG_SCREEN_REFRESH_RATE(60)
- MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
- MCFG_SCREEN_SIZE(64*8, 32*8)
- MCFG_SCREEN_VISIBLE_AREA(12*8, (64-14)*8-1, 2*8, 30*8-1 )
+ MCFG_SCREEN_RAW_PARAMS(XTAL_24MHz/3, 528, 96, 400, 256, 16, 240) // measured Vsync 59.17hz Hsync 15.13 / 15.19khz
+// 6MHz dotclock is more realistic, however needs drawing updates. replace when ready
+// MCFG_SCREEN_RAW_PARAMS(XTAL_24MHz/4, 396, hbend, hbstart, 256, 16, 240)
MCFG_SCREEN_UPDATE_DRIVER(chqflag_state, screen_update_chqflag)
MCFG_SCREEN_PALETTE("palette")
@@ -329,7 +316,10 @@ static MACHINE_CONFIG_START( chqflag, chqflag_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(chqflag_state, sprite_callback)
+ MCFG_K051960_IRQ_HANDLER(INPUTLINE("maincpu", KONAMI_IRQ_LINE))
+ MCFG_K051960_NMI_HANDLER(INPUTLINE("maincpu", INPUT_LINE_NMI))
MCFG_DEVICE_ADD("k051316_1", K051316, 0)
MCFG_GFX_PALETTE("palette")
diff --git a/src/mame/drivers/gradius3.c b/src/mame/drivers/gradius3.c
index 815cbb9dad5..94b4e5f2ed5 100644
--- a/src/mame/drivers/gradius3.c
+++ b/src/mame/drivers/gradius3.c
@@ -307,6 +307,7 @@ static MACHINE_CONFIG_START( gradius3, gradius3_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(gradius3_state, sprite_callback)
MCFG_K051960_PLANEORDER(K051960_PLANEORDER_GRADIUS3)
diff --git a/src/mame/drivers/mainevt.c b/src/mame/drivers/mainevt.c
index 704f07d9eac..840da8b536b 100644
--- a/src/mame/drivers/mainevt.c
+++ b/src/mame/drivers/mainevt.c
@@ -432,6 +432,7 @@ static MACHINE_CONFIG_START( mainevt, mainevt_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(mainevt_state, mainevt_sprite_callback)
/* sound hardware */
@@ -477,6 +478,7 @@ static MACHINE_CONFIG_START( devstors, mainevt_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(mainevt_state, dv_sprite_callback)
MCFG_K051733_ADD("k051733")
diff --git a/src/mame/drivers/spy.c b/src/mame/drivers/spy.c
index 0d1254c7aca..a37a42d0bce 100644
--- a/src/mame/drivers/spy.c
+++ b/src/mame/drivers/spy.c
@@ -519,6 +519,7 @@ static MACHINE_CONFIG_START( spy, spy_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(spy_state, sprite_callback)
/* sound hardware */
diff --git a/src/mame/drivers/thunderx.c b/src/mame/drivers/thunderx.c
index 6dced26d356..0149e610533 100644
--- a/src/mame/drivers/thunderx.c
+++ b/src/mame/drivers/thunderx.c
@@ -663,6 +663,7 @@ static MACHINE_CONFIG_START( scontra, thunderx_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(thunderx_state, sprite_callback)
/* sound hardware */
diff --git a/src/mame/drivers/tmnt.c b/src/mame/drivers/tmnt.c
index 4fd26f6d5ca..0d7c1c1ede7 100644
--- a/src/mame/drivers/tmnt.c
+++ b/src/mame/drivers/tmnt.c
@@ -1992,6 +1992,7 @@ static MACHINE_CONFIG_START( cuebrick, tmnt_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(tmnt_state, mia_sprite_callback)
MCFG_K051960_PLANEORDER(K051960_PLANEORDER_MIA)
@@ -2041,6 +2042,7 @@ static MACHINE_CONFIG_START( mia, tmnt_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(tmnt_state, mia_sprite_callback)
MCFG_K051960_PLANEORDER(K051960_PLANEORDER_MIA)
@@ -2103,6 +2105,7 @@ static MACHINE_CONFIG_START( tmnt, tmnt_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(tmnt_state, tmnt_sprite_callback)
MCFG_K051960_PLANEORDER(K051960_PLANEORDER_MIA)
@@ -2163,6 +2166,7 @@ static MACHINE_CONFIG_START( punkshot, tmnt_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(tmnt_state, punkshot_sprite_callback)
MCFG_K053251_ADD("k053251")
@@ -2632,6 +2636,7 @@ static MACHINE_CONFIG_START( thndrx2, tmnt_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(tmnt_state, thndrx2_sprite_callback)
MCFG_K053251_ADD("k053251")
diff --git a/src/mame/drivers/ultraman.c b/src/mame/drivers/ultraman.c
index e06606002b4..93c6c67f7c6 100644
--- a/src/mame/drivers/ultraman.c
+++ b/src/mame/drivers/ultraman.c
@@ -200,6 +200,7 @@ static MACHINE_CONFIG_START( ultraman, ultraman_state )
MCFG_DEVICE_ADD("k051960", K051960, 0)
MCFG_GFX_PALETTE("palette")
+ MCFG_K051960_SCREEN_TAG("screen")
MCFG_K051960_CB(ultraman_state, sprite_callback)
MCFG_DEVICE_ADD("k051316_1", K051316, 0)
diff --git a/src/mame/includes/chqflag.h b/src/mame/includes/chqflag.h
index 45e5cc4ea8d..79b9aca8f9d 100644
--- a/src/mame/includes/chqflag.h
+++ b/src/mame/includes/chqflag.h
@@ -61,7 +61,6 @@ public:
virtual void machine_start();
virtual void machine_reset();
UINT32 screen_update_chqflag(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- TIMER_DEVICE_CALLBACK_MEMBER(chqflag_scanline);
DECLARE_WRITE8_MEMBER(volume_callback0);
DECLARE_WRITE8_MEMBER(volume_callback1);
K051316_CB_MEMBER(zoom_callback_1);
diff --git a/src/mame/video/k051960.c b/src/mame/video/k051960.c
index ab939945855..96c1acb2faf 100644
--- a/src/mame/video/k051960.c
+++ b/src/mame/video/k051960.c
@@ -24,11 +24,12 @@ The 051960 can also genenrate IRQ, FIRQ and NMI signals.
memory map:
000-007 is for the 051937, but also seen by the 051960
400-7ff is 051960 only
-000 R bit 0 = unknown, looks like a status flag or something
+000 R bit 0 = vblank?
aliens waits for it to be 0 before starting to copy sprite data
thndrx2 needs it to pulse for the startup checks to succeed
-000 W bit 0 = irq enable/acknowledge?
- bit 2 = nmi enable?
+000 W bit 0 = irq acknowledge
+ bit 1 = firq acknowledge?
+ bit 2 = nmi enable/acknowledge
bit 3 = flip screen (applies to sprites only, not tilemaps)
bit 4 = unknown, used by Devastators, TMNT, Aliens, Chequered Flag, maybe others
aliens sets it just after checking bit 0, and before copying
@@ -128,16 +129,18 @@ k051960_device::k051960_device(const machine_config &mconfig, const char *tag, d
: device_t(mconfig, K051960, "K051960 Sprite Generator", tag, owner, clock, "k051960", __FILE__),
device_gfx_interface(mconfig, *this, gfxinfo),
m_ram(NULL),
+ m_sprite_rom(NULL),
+ m_sprite_size(0),
m_screen_tag(NULL),
+ m_screen(NULL),
+ m_scanline_timer(NULL),
m_irq_handler(*this),
m_firq_handler(*this),
m_nmi_handler(*this),
m_romoffset(0),
m_spriteflip(0),
m_readroms(0),
- m_irq_enabled(0),
- m_nmi_enabled(0),
- m_k051937_counter(0)
+ m_nmi_enabled(0)
{
}
@@ -180,16 +183,14 @@ void k051960_device::set_screen_tag(device_t &device, device_t *owner, const cha
void k051960_device::device_start()
{
- if (m_screen_tag != NULL)
- {
- // make sure our screen is started
- screen_device *screen = m_owner->subdevice<screen_device>(m_screen_tag);
- if (!screen->started())
- throw device_missing_dependencies();
+ // make sure our screen is started
+ m_screen = m_owner->subdevice<screen_device>(m_screen_tag);
+ if (!m_screen->started())
+ throw device_missing_dependencies();
- // and register a callback for vblank state
- screen->register_vblank_callback(vblank_state_delegate(FUNC(k051960_device::vblank_callback), this));
- }
+ // allocate scanline timer and start at first scanline
+ m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(k051960_device::scanline_callback), this));
+ m_scanline_timer->adjust(m_screen->time_until_pos(0));
m_sprite_rom = region()->base();
m_sprite_size = region()->bytes();
@@ -214,11 +215,9 @@ void k051960_device::device_start()
save_item(NAME(m_romoffset));
save_item(NAME(m_spriteflip));
save_item(NAME(m_readroms));
+ save_item(NAME(m_nmi_enabled));
save_item(NAME(m_spriterombank));
save_pointer(NAME(m_ram), 0x400);
- save_item(NAME(m_irq_enabled));
- save_item(NAME(m_nmi_enabled));
- save_item(NAME(m_k051937_counter));
}
//-------------------------------------------------
@@ -227,12 +226,9 @@ void k051960_device::device_start()
void k051960_device::device_reset()
{
- m_k051937_counter = 0;
-
m_romoffset = 0;
m_spriteflip = 0;
m_readroms = 0;
- m_irq_enabled = 0;
m_nmi_enabled = 0;
m_spriterombank[0] = 0;
@@ -245,10 +241,21 @@ void k051960_device::device_reset()
DEVICE HANDLERS
*****************************************************************************/
-void k051960_device::vblank_callback(screen_device &screen, bool state)
+TIMER_CALLBACK_MEMBER( k051960_device::scanline_callback )
{
- if (state)
+ // range 0..255
+ UINT8 y = m_screen->vpos();
+
+ // 32v
+ if ((y % 32 == 0) && m_nmi_enabled)
+ m_nmi_handler(ASSERT_LINE);
+
+ // vblank
+ if (y == 240)
m_irq_handler(ASSERT_LINE);
+
+ // wait for next line
+ m_scanline_timer->adjust(m_screen->time_until_pos(y + 1));
}
int k051960_device::k051960_fetchromdata( int byte )
@@ -295,8 +302,7 @@ READ8_MEMBER( k051960_device::k051937_r )
if (m_readroms && offset >= 4 && offset < 8)
return k051960_fetchromdata(offset & 3);
else if (offset == 0)
- /* some games need bit 0 to pulse */
- return (m_k051937_counter++) & 1;
+ return m_screen->vblank() ? 1 : 0; // vblank?
//logerror("%04x: read unknown 051937 address %x\n", space.device().safe_pc(), offset);
return 0;
@@ -308,15 +314,13 @@ WRITE8_MEMBER( k051960_device::k051937_w )
{
//if (data & 0xc2) popmessage("051937 reg 00 = %02x",data);
- /* bit 0 is IRQ enable */
- m_irq_enabled = data & 0x01;
- if (m_irq_enabled)
- m_irq_handler(CLEAR_LINE);
+ if (BIT(data, 0)) m_irq_handler(CLEAR_LINE); // bit 0, irq ack
+ if (BIT(data, 1)) m_firq_handler(CLEAR_LINE); // bit 1, firq ack?
- /* bit 1: probably FIRQ enable */
-
- /* bit 2 is NMI enable */
- m_nmi_enabled = data & 0x04;
+ // bit 2, nmi enable/ack
+ m_nmi_enabled = BIT(data, 2);
+ if (m_nmi_enabled)
+ m_nmi_handler(CLEAR_LINE);
/* bit 3 = flip screen */
m_spriteflip = data & 0x08;
@@ -329,8 +333,9 @@ WRITE8_MEMBER( k051960_device::k051937_w )
}
else if (offset == 1)
{
-// popmessage("%04x: write %02x to 051937 address %x", space.device().safe_pc(), data, offset);
-//logerror("%04x: write %02x to unknown 051937 address %x\n", space.device().safe_pc(), data, offset);
+ // unknown, Devastators writes 02 here in game
+ if (0)
+ logerror("%s: %02x to 051937 address %x\n", machine().describe_context(), data, offset);
}
else if (offset >= 2 && offset < 5)
{
@@ -343,16 +348,6 @@ WRITE8_MEMBER( k051960_device::k051937_w )
}
}
-int k051960_device::k051960_is_irq_enabled( )
-{
- return m_irq_enabled;
-}
-
-int k051960_device::k051960_is_nmi_enabled( )
-{
- return m_nmi_enabled;
-}
-
/*
* Sprite Format
diff --git a/src/mame/video/k051960.h b/src/mame/video/k051960.h
index 9d4efd04ff0..43c9a171856 100644
--- a/src/mame/video/k051960.h
+++ b/src/mame/video/k051960.h
@@ -27,6 +27,9 @@ typedef device_delegate<void (int *code, int *color, int *priority, int *shadow)
#define MCFG_K051960_IRQ_HANDLER(_devcb) \
devcb = &k051960_device::set_irq_handler(*device, DEVCB_##_devcb);
+#define MCFG_K051960_NMI_HANDLER(_devcb) \
+ devcb = &k051960_device::set_nmi_handler(*device, DEVCB_##_devcb);
+
class k051960_device : public device_t,
public device_gfx_interface
@@ -45,6 +48,9 @@ public:
template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object)
{ return downcast<k051960_device &>(device).m_irq_handler.set_callback(object); }
+ template<class _Object> static devcb_base &set_nmi_handler(device_t &device, _Object object)
+ { return downcast<k051960_device &>(device).m_nmi_handler.set_callback(object); }
+
// static configuration
static void set_k051960_callback(device_t &device, k051960_cb_delegate callback) { downcast<k051960_device &>(device).m_k051960_cb = callback; }
static void set_plane_order(device_t &device, int order);
@@ -71,10 +77,8 @@ public:
DECLARE_WRITE8_MEMBER( k051937_w );
void k051960_sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, int min_priority, int max_priority);
- int k051960_is_irq_enabled();
- int k051960_is_nmi_enabled();
- void vblank_callback(screen_device &screen, bool state);
+ TIMER_CALLBACK_MEMBER(scanline_callback);
protected:
// device-level overrides
@@ -89,6 +93,8 @@ private:
UINT32 m_sprite_size;
const char *m_screen_tag;
+ screen_device *m_screen;
+ emu_timer *m_scanline_timer;
k051960_cb_delegate m_k051960_cb;
@@ -99,9 +105,7 @@ private:
UINT8 m_spriterombank[3];
int m_romoffset;
int m_spriteflip, m_readroms;
- int m_irq_enabled, m_nmi_enabled;
-
- int m_k051937_counter;
+ int m_nmi_enabled;
int k051960_fetchromdata( int byte );
};