Previous 199869 Revisions Next

r36586 Monday 23rd March, 2015 at 16:05:27 UTC by David Haywood
use existing sprite device for 'thedeep'
(thanks to Osso for pointing it out)
[src/mame/drivers]thedeep.c
[src/mame/includes]thedeep.h
[src/mame/video]decmxc06.c decmxc06.h thedeep.c

trunk/src/mame/drivers/thedeep.c
r245097r245098
436436   MCFG_PALETTE_ADD("palette", 512)
437437   MCFG_PALETTE_INIT_OWNER(thedeep_state, thedeep)
438438
439   MCFG_DEVICE_ADD("spritegen", DECO_MXC06, 0)
440   deco_mxc06_device::set_gfx_region(*device, 0);
441   MCFG_DECO_MXC06_GFXDECODE("gfxdecode")
442   MCFG_DECO_MXC06_PALETTE("palette")
443   MCFG_DECO_MXC06_RAMSIZE(0x400)
439444
440445   /* sound hardware */
441446   MCFG_SPEAKER_STANDARD_MONO("mono")
trunk/src/mame/includes/thedeep.h
r245097r245098
1#include "video/decmxc06.h"
2
3
14class thedeep_state : public driver_device
25{
36public:
r245097r245098
1215      m_vram_0(*this, "vram_0"),
1316      m_vram_1(*this, "vram_1"),
1417      m_scroll(*this, "scroll"),
15      m_scroll2(*this, "scroll2")  { }
18      m_scroll2(*this, "scroll2"),
19      m_spritegen(*this, "spritegen")
20      { }
1621
1722   required_device<cpu_device> m_maincpu;
1823   required_device<cpu_device> m_audiocpu;
r245097r245098
2530   required_shared_ptr<UINT8> m_vram_1;
2631   required_shared_ptr<UINT8> m_scroll;
2732   required_shared_ptr<UINT8> m_scroll2;
33   required_device<deco_mxc06_device> m_spritegen;
2834
2935   int m_nmi_enable;
3036   UINT8 m_protection_command;
r245097r245098
5965   DECLARE_PALETTE_INIT(thedeep);
6066
6167   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
62   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
6368
6469   INTERRUPT_GEN_MEMBER(mcu_irq);
6570   TIMER_DEVICE_CALLBACK_MEMBER(interrupt);
trunk/src/mame/video/decmxc06.c
r245097r245098
5151   : device_t(mconfig, DECO_MXC06, "DECO MXC06 Sprite", tag, owner, clock, "deco_mxc06", __FILE__),
5252      device_video_interface(mconfig, *this),
5353      m_gfxregion(0),
54      m_ramsize(0x800),
5455      m_gfxdecode(*this),
5556      m_palette(*this)
5657{
r245097r245098
7374   int offs;
7475
7576   offs = 0;
76   while (offs < 0x800 / 2)
77   while (offs < m_ramsize / 2)
7778   {
7879      int sx, sy, code, color, w, h, flipx, flipy, incy, flash, mult, x, y;
7980
r245097r245098
109110      else
110111         mult = -16;
111112
113     
114      // thedeep strongly suggests that this check goes here, otherwise the radar breaks
115      if (!(spriteram[offs] & 0x8000))
116      {
117         offs += 4;
118         continue;
119      }
120     
121
112122      for (x = 0; x < w; x++)
113123      {
114124         // maybe, birdie try appears to specify the base code for each part..
115125         code = spriteram[offs + 1] & 0x1fff;
116126
117         code &= ~(h-1);
127         code &= ~(h - 1);
118128
119129         if (flipy)
120130            incy = -1;
121131         else
122132         {
123            code += h-1;
133            code += h - 1;
124134            incy = 1;
125135         }
126136
127137         for (y = 0; y < h; y++)
128138         {
129            if (spriteram[offs] & 0x8000)
130139            {
131140               int draw = 0;
132141               if (!flash || (m_screen->frame_number() & 1))
133142               {
134                  if (m_priority_type==0) // most cases
143                  if (m_priority_type == 0) // most cases
135144                  {
136145                     if ((color & pri_mask) == pri_val)
137146                     {
138147                        draw = 1;
139148                     }
140149                  }
141                  else if (m_priority_type==1) // vaportra
150                  else if (m_priority_type == 1) // vaportra
142151                  {
143152                     if (pri_mask && (color >= pri_val))
144153                        continue;
r245097r245098
152161
153162               if (draw)
154163               {
155                  m_gfxdecode->gfx(m_gfxregion)->transpen(bitmap,cliprect,
164                  m_gfxdecode->gfx(m_gfxregion)->transpen(bitmap, cliprect,
156165                     code - y * incy,
157166                     color & col_mask,
158                     flipx,flipy,
159                     sx + (mult * x),sy + (mult * y),0);
167                     flipx, flipy,
168                     sx + (mult * x), sy + (mult * y), 0);
160169               }
161170            }
162171         }
163172
164173         offs += 4;
165         if (offs >= 0x800 / 2)
166               return;
174         if (offs >= m_ramsize / 2)
175            return;
176   
177
167178      }
168179   }
169180}
r245097r245098
175186   int offs;
176187
177188   offs = 0;
178   while (offs < 0x800 / 2)
189   while (offs < m_ramsize / 2)
179190   {
180191      int sx, sy, code, color, flipx, flipy;
181192
trunk/src/mame/video/decmxc06.h
r245097r245098
1111   static void static_set_gfxdecode_tag(device_t &device, const char *tag);
1212   static void static_set_palette_tag(device_t &device, const char *tag);
1313   static void set_gfx_region(device_t &device, int region);
14   static void set_ram_size(device_t &device, int size)
15   {
16      deco_mxc06_device &dev = downcast<deco_mxc06_device &>(device);
17      dev.m_ramsize = size;
18   }
1419
20
1521   void set_gfxregion(int region) { m_gfxregion = region; };
1622   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram16, int pri_mask, int pri_val, int col_mask );
1723   void draw_sprites_bootleg( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram, int pri_mask, int pri_val, int col_mask );
r245097r245098
2329
2430   UINT8 m_gfxregion;
2531   int m_priority_type; // just so we can support the existing drivers without converting everything to pdrawgfx just yet
32   int m_ramsize;
2633
2734private:
2835   required_device<gfxdecode_device> m_gfxdecode;
r245097r245098
3643
3744#define MCFG_DECO_MXC06_PALETTE(_palette_tag) \
3845   deco_mxc06_device::static_set_palette_tag(*device, "^" _palette_tag);
46
47#define MCFG_DECO_MXC06_RAMSIZE(_size) \
48   deco_mxc06_device::set_ram_size(*device, _size);
trunk/src/mame/video/thedeep.c
r245097r245098
109109
110110/***************************************************************************
111111
112                                Sprites Drawing
113
114Offset:     Bits:       Value:
115
116    0                   Y (low bits, 0 is bottom)
117
118    1       7-------    Enable
119            -6------    Flip Y
120            --5-----    Flip X ? (unused)
121            ---43---    Height: 1,2,4 or 8 tiles
122            -----21-    Width: 1,2,4 or 8 tiles*
123            -------0    Y (High bit)
124
125    2                   Code (low bits)
126
127    3                   Code (high bits)
128
129    4                   X (low bits, 0 is right)
130
131    5       7654----    Color
132            ----321-
133            -------0    X (High bit)
134
135    6                   Unused
136
137    7                   Unused
138
139* a sprite of width N uses N consecutive sprites. The first one specifies
140  all the data, the following ones only the tile code and color.
141
142***************************************************************************/
143
144void thedeep_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
145{
146   UINT8 *s = m_spriteram, *end = s + m_spriteram.bytes();
147
148   while (s < end)
149   {
150      int code,color,sx,sy,flipx,flipy,nx,ny,x,y,attr;
151
152      attr    =    s[1];
153      if (!(attr & 0x80)) {   s+=8;   continue;   }
154
155      sx      =    s[4];
156      sy      =    s[0];
157
158      color   =    s[5];
159
160      flipx   =   attr & 0x00;    // ?
161      flipy   =   attr & 0x40;
162
163      nx = 1 << ((attr & 0x06) >> 1);
164      ny = 1 << ((attr & 0x18) >> 3);
165
166      if (color & 1)  sx -= 256;
167      if (attr  & 1)  sy -= 256;
168
169      if (flip_screen())
170      {
171         flipx = !flipx;
172         flipy = !flipy;
173         sy = sy - 8;
174      }
175      else
176      {
177         sx = 240 - sx;
178         sy = 240 - sy - ny * 16 + 16;
179      }
180
181      for (x = 0; (x < nx) && (s < end);  x++,s+=8)
182      {
183         code    =    s[2] + (s[3] << 8);
184         color   =    s[5] >> 4;
185
186         for (y = 0; y < ny; y++)
187         {
188            m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
189                  code + (flipy ? (ny - y - 1) :  y),
190                  color,
191                  flipx,flipy,
192                  sx + x * (flipx ? 16 : -16), sy + y * 16,0 );
193         }
194      }
195   }
196}
197
198
199/***************************************************************************
200
201112                                Screen Drawing
202113
203114***************************************************************************/
r245097r245098
219130   bitmap.fill(m_palette->black_pen(), cliprect);
220131
221132   m_tilemap_0->draw(screen, bitmap, cliprect, 0,0);
222   draw_sprites(bitmap,cliprect);
133   m_spritegen->draw_sprites(bitmap, cliprect,  reinterpret_cast<UINT16 *>(m_spriteram.target()), 0x00, 0x00, 0x0f);
223134   m_tilemap_1->draw(screen, bitmap, cliprect, 0,0);
224135   return 0;
225136}
137


Previous 199869 Revisions Next


© 1997-2024 The MAME Team