summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author mamehaze <mamehaze@users.noreply.github.com>2015-03-23 16:05:27 +0000
committer mamehaze <mamehaze@users.noreply.github.com>2015-03-23 16:05:27 +0000
commit277cb84661e0628121fff3ec0082cfddf5a4ca92 (patch)
tree961b16364e63740c12775ccb14e61545260bef63
parent7ea90b986d7be32c897e7ec9074363fda8c653e5 (diff)
use existing sprite device for 'thedeep'
(thanks to Osso for pointing it out)
-rw-r--r--src/mame/drivers/thedeep.c5
-rw-r--r--src/mame/includes/thedeep.h9
-rw-r--r--src/mame/video/decmxc06.c35
-rw-r--r--src/mame/video/decmxc06.h10
-rw-r--r--src/mame/video/thedeep.c92
5 files changed, 47 insertions, 104 deletions
diff --git a/src/mame/drivers/thedeep.c b/src/mame/drivers/thedeep.c
index cc3db30a16d..b28bb92237d 100644
--- a/src/mame/drivers/thedeep.c
+++ b/src/mame/drivers/thedeep.c
@@ -436,6 +436,11 @@ static MACHINE_CONFIG_START( thedeep, thedeep_state )
MCFG_PALETTE_ADD("palette", 512)
MCFG_PALETTE_INIT_OWNER(thedeep_state, thedeep)
+ MCFG_DEVICE_ADD("spritegen", DECO_MXC06, 0)
+ deco_mxc06_device::set_gfx_region(*device, 0);
+ MCFG_DECO_MXC06_GFXDECODE("gfxdecode")
+ MCFG_DECO_MXC06_PALETTE("palette")
+ MCFG_DECO_MXC06_RAMSIZE(0x400)
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
diff --git a/src/mame/includes/thedeep.h b/src/mame/includes/thedeep.h
index 301bb0c8b0d..948f278ac60 100644
--- a/src/mame/includes/thedeep.h
+++ b/src/mame/includes/thedeep.h
@@ -1,3 +1,6 @@
+#include "video/decmxc06.h"
+
+
class thedeep_state : public driver_device
{
public:
@@ -12,7 +15,9 @@ public:
m_vram_0(*this, "vram_0"),
m_vram_1(*this, "vram_1"),
m_scroll(*this, "scroll"),
- m_scroll2(*this, "scroll2") { }
+ m_scroll2(*this, "scroll2"),
+ m_spritegen(*this, "spritegen")
+ { }
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
@@ -25,6 +30,7 @@ public:
required_shared_ptr<UINT8> m_vram_1;
required_shared_ptr<UINT8> m_scroll;
required_shared_ptr<UINT8> m_scroll2;
+ required_device<deco_mxc06_device> m_spritegen;
int m_nmi_enable;
UINT8 m_protection_command;
@@ -59,7 +65,6 @@ public:
DECLARE_PALETTE_INIT(thedeep);
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(mcu_irq);
TIMER_DEVICE_CALLBACK_MEMBER(interrupt);
diff --git a/src/mame/video/decmxc06.c b/src/mame/video/decmxc06.c
index 3b908b6df80..61cc9d03d93 100644
--- a/src/mame/video/decmxc06.c
+++ b/src/mame/video/decmxc06.c
@@ -51,6 +51,7 @@ deco_mxc06_device::deco_mxc06_device(const machine_config &mconfig, const char *
: device_t(mconfig, DECO_MXC06, "DECO MXC06 Sprite", tag, owner, clock, "deco_mxc06", __FILE__),
device_video_interface(mconfig, *this),
m_gfxregion(0),
+ m_ramsize(0x800),
m_gfxdecode(*this),
m_palette(*this)
{
@@ -73,7 +74,7 @@ void deco_mxc06_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cli
int offs;
offs = 0;
- while (offs < 0x800 / 2)
+ while (offs < m_ramsize / 2)
{
int sx, sy, code, color, w, h, flipx, flipy, incy, flash, mult, x, y;
@@ -109,36 +110,44 @@ void deco_mxc06_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cli
else
mult = -16;
+
+ // thedeep strongly suggests that this check goes here, otherwise the radar breaks
+ if (!(spriteram[offs] & 0x8000))
+ {
+ offs += 4;
+ continue;
+ }
+
+
for (x = 0; x < w; x++)
{
// maybe, birdie try appears to specify the base code for each part..
code = spriteram[offs + 1] & 0x1fff;
- code &= ~(h-1);
+ code &= ~(h - 1);
if (flipy)
incy = -1;
else
{
- code += h-1;
+ code += h - 1;
incy = 1;
}
for (y = 0; y < h; y++)
{
- if (spriteram[offs] & 0x8000)
{
int draw = 0;
if (!flash || (m_screen->frame_number() & 1))
{
- if (m_priority_type==0) // most cases
+ if (m_priority_type == 0) // most cases
{
if ((color & pri_mask) == pri_val)
{
draw = 1;
}
}
- else if (m_priority_type==1) // vaportra
+ else if (m_priority_type == 1) // vaportra
{
if (pri_mask && (color >= pri_val))
continue;
@@ -152,18 +161,20 @@ void deco_mxc06_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cli
if (draw)
{
- m_gfxdecode->gfx(m_gfxregion)->transpen(bitmap,cliprect,
+ m_gfxdecode->gfx(m_gfxregion)->transpen(bitmap, cliprect,
code - y * incy,
color & col_mask,
- flipx,flipy,
- sx + (mult * x),sy + (mult * y),0);
+ flipx, flipy,
+ sx + (mult * x), sy + (mult * y), 0);
}
}
}
offs += 4;
- if (offs >= 0x800 / 2)
- return;
+ if (offs >= m_ramsize / 2)
+ return;
+
+
}
}
}
@@ -175,7 +186,7 @@ void deco_mxc06_device::draw_sprites_bootleg( bitmap_ind16 &bitmap, const rectan
int offs;
offs = 0;
- while (offs < 0x800 / 2)
+ while (offs < m_ramsize / 2)
{
int sx, sy, code, color, flipx, flipy;
diff --git a/src/mame/video/decmxc06.h b/src/mame/video/decmxc06.h
index e7d5013b03f..114ffd865d6 100644
--- a/src/mame/video/decmxc06.h
+++ b/src/mame/video/decmxc06.h
@@ -11,6 +11,12 @@ public:
static void static_set_gfxdecode_tag(device_t &device, const char *tag);
static void static_set_palette_tag(device_t &device, const char *tag);
static void set_gfx_region(device_t &device, int region);
+ static void set_ram_size(device_t &device, int size)
+ {
+ deco_mxc06_device &dev = downcast<deco_mxc06_device &>(device);
+ dev.m_ramsize = size;
+ }
+
void set_gfxregion(int region) { m_gfxregion = region; };
void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram16, int pri_mask, int pri_val, int col_mask );
@@ -23,6 +29,7 @@ protected:
UINT8 m_gfxregion;
int m_priority_type; // just so we can support the existing drivers without converting everything to pdrawgfx just yet
+ int m_ramsize;
private:
required_device<gfxdecode_device> m_gfxdecode;
@@ -36,3 +43,6 @@ extern const device_type DECO_MXC06;
#define MCFG_DECO_MXC06_PALETTE(_palette_tag) \
deco_mxc06_device::static_set_palette_tag(*device, "^" _palette_tag);
+
+#define MCFG_DECO_MXC06_RAMSIZE(_size) \
+ deco_mxc06_device::set_ram_size(*device, _size);
diff --git a/src/mame/video/thedeep.c b/src/mame/video/thedeep.c
index f810cb7da58..2c081a9a05b 100644
--- a/src/mame/video/thedeep.c
+++ b/src/mame/video/thedeep.c
@@ -109,95 +109,6 @@ void thedeep_state::video_start()
/***************************************************************************
- Sprites Drawing
-
-Offset: Bits: Value:
-
- 0 Y (low bits, 0 is bottom)
-
- 1 7------- Enable
- -6------ Flip Y
- --5----- Flip X ? (unused)
- ---43--- Height: 1,2,4 or 8 tiles
- -----21- Width: 1,2,4 or 8 tiles*
- -------0 Y (High bit)
-
- 2 Code (low bits)
-
- 3 Code (high bits)
-
- 4 X (low bits, 0 is right)
-
- 5 7654---- Color
- ----321-
- -------0 X (High bit)
-
- 6 Unused
-
- 7 Unused
-
-* a sprite of width N uses N consecutive sprites. The first one specifies
- all the data, the following ones only the tile code and color.
-
-***************************************************************************/
-
-void thedeep_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
-{
- UINT8 *s = m_spriteram, *end = s + m_spriteram.bytes();
-
- while (s < end)
- {
- int code,color,sx,sy,flipx,flipy,nx,ny,x,y,attr;
-
- attr = s[1];
- if (!(attr & 0x80)) { s+=8; continue; }
-
- sx = s[4];
- sy = s[0];
-
- color = s[5];
-
- flipx = attr & 0x00; // ?
- flipy = attr & 0x40;
-
- nx = 1 << ((attr & 0x06) >> 1);
- ny = 1 << ((attr & 0x18) >> 3);
-
- if (color & 1) sx -= 256;
- if (attr & 1) sy -= 256;
-
- if (flip_screen())
- {
- flipx = !flipx;
- flipy = !flipy;
- sy = sy - 8;
- }
- else
- {
- sx = 240 - sx;
- sy = 240 - sy - ny * 16 + 16;
- }
-
- for (x = 0; (x < nx) && (s < end); x++,s+=8)
- {
- code = s[2] + (s[3] << 8);
- color = s[5] >> 4;
-
- for (y = 0; y < ny; y++)
- {
- m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
- code + (flipy ? (ny - y - 1) : y),
- color,
- flipx,flipy,
- sx + x * (flipx ? 16 : -16), sy + y * 16,0 );
- }
- }
- }
-}
-
-
-/***************************************************************************
-
Screen Drawing
***************************************************************************/
@@ -219,7 +130,8 @@ UINT32 thedeep_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap,
bitmap.fill(m_palette->black_pen(), cliprect);
m_tilemap_0->draw(screen, bitmap, cliprect, 0,0);
- draw_sprites(bitmap,cliprect);
+ m_spritegen->draw_sprites(bitmap, cliprect, reinterpret_cast<UINT16 *>(m_spriteram.target()), 0x00, 0x00, 0x0f);
m_tilemap_1->draw(screen, bitmap, cliprect, 0,0);
return 0;
}
+