Previous 199869 Revisions Next

r31048 Friday 20th June, 2014 at 14:19:38 UTC by David Haywood
move some code around for later (nw)
[src/mame]mame.mak
[src/mame/drivers]deco32.c
[src/mame/includes]deco32.h
[src/mame/video]deco32.c deco_zoomspr.c* deco_zoomspr.h*

trunk/src/mame/includes/deco32.h
r31047r31048
66#include "sound/okim6295.h"
77#include "machine/deco146.h"
88#include "machine/deco104.h"
9#include "video/deco_zoomspr.h"
910
1011class deco32_state : public driver_device
1112{
r31047r31048
2728      m_sprgen(*this, "spritegen"),
2829      m_sprgen1(*this, "spritegen1"),
2930      m_sprgen2(*this, "spritegen2"),
31      m_sprgenzoom(*this, "spritegen_zoom"),
3032      m_eeprom(*this, "eeprom"),
3133      m_oki1(*this, "oki1"),
3234      m_oki2(*this, "oki2"),
r31047r31048
5557   optional_device<decospr_device> m_sprgen;
5658   optional_device<decospr_device> m_sprgen1;
5759   optional_device<decospr_device> m_sprgen2;
60   optional_device<deco_zoomspr_device> m_sprgenzoom;
5861
5962   optional_device<eeprom_serial_93cxx_device> m_eeprom;
6063   optional_device<okim6295_device> m_oki1;
trunk/src/mame/mame.mak
r31047r31048
10271027   $(DRIVERS)/deco_mlc.o $(VIDEO)/deco_mlc.o \
10281028   $(DRIVERS)/deco156.o $(MACHINE)/deco156.o \
10291029   $(DRIVERS)/deco32.o $(VIDEO)/deco32.o $(VIDEO)/dvi.o \
1030   $(VIDEO)/deco_zoomspr.o \
10301031   $(DRIVERS)/decocass.o $(MACHINE)/decocass.o $(MACHINE)/decocass_tape.o $(VIDEO)/decocass.o \
10311032   $(DRIVERS)/deshoros.o \
10321033   $(DRIVERS)/dietgo.o $(VIDEO)/dietgo.o \
trunk/src/mame/video/deco_zoomspr.c
r0r31048
1
2/* the sprites used by DragonGun + Lock 'n' Loaded */
3
4/* probably 186 + 187 custom chips, although there is a 145 too? */
5
6#include "emu.h"
7#include "deco_zoomspr.h"
8
9const device_type DECO_ZOOMSPR = &device_creator<deco_zoomspr_device>;
10
11deco_zoomspr_device::deco_zoomspr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
12   : device_t(mconfig, DECO_ZOOMSPR, "Data East Zooming Sprites", tag, owner, clock, "deco_zoomspr", __FILE__),
13   m_palette(*this),
14   m_gfxdecode(*this)
15{
16}
17
18//-------------------------------------------------
19//  static_set_palette_tag: Set the tag of the
20//  palette device
21//-------------------------------------------------
22
23void deco_zoomspr_device::static_set_palette_tag(device_t &device, const char *tag)
24{
25   downcast<deco_zoomspr_device &>(device).m_palette.set_tag(tag);
26}
27
28//-------------------------------------------------
29//  static_set_gfxdecode_tag: Set the tag of the
30//  gfx decoder
31//-------------------------------------------------
32
33void deco_zoomspr_device::static_set_gfxdecode_tag(device_t &device, const char *tag)
34{
35   downcast<deco_zoomspr_device &>(device).m_gfxdecode.set_tag(tag);
36}
37
38
39void deco_zoomspr_device::device_start()
40{
41}
42
43void deco_zoomspr_device::device_reset()
44{
45}
46
47/******************************************************************************/
48
49
50inline void deco_zoomspr_device::deco_zoomspr_device::dragngun_drawgfxzoom(
51      bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
52      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
53      int transparent_color,
54      int scalex, int scaley,bitmap_ind8 *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int  sprite_screen_height, UINT8 alpha )
55{
56   rectangle myclip;
57
58   if (!scalex || !scaley) return;
59
60   /*
61   scalex and scaley are 16.16 fixed point numbers
62   1<<15 : shrink to 50%
63   1<<16 : uniform scale
64   1<<17 : double to 200%
65   */
66
67   /* KW 991012 -- Added code to force clip to bitmap boundary */
68   myclip = clip;
69   myclip &= dest_bmp.cliprect();
70
71   {
72      if( gfx )
73      {
74         const pen_t *pal = &m_palette->pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors()));
75         const UINT8 *code_base = gfx->get_data(code % gfx->elements());
76
77         if (sprite_screen_width && sprite_screen_height)
78         {
79            /* compute sprite increment per screen pixel */
80            int dx = (gfx->width()<<16)/sprite_screen_width;
81            int dy = (gfx->height()<<16)/sprite_screen_height;
82
83            int ex = sx+sprite_screen_width;
84            int ey = sy+sprite_screen_height;
85
86            int x_index_base;
87            int y_index;
88
89            if( flipx )
90            {
91               x_index_base = (sprite_screen_width-1)*dx;
92               dx = -dx;
93            }
94            else
95            {
96               x_index_base = 0;
97            }
98
99            if( flipy )
100            {
101               y_index = (sprite_screen_height-1)*dy;
102               dy = -dy;
103            }
104            else
105            {
106               y_index = 0;
107            }
108
109            if( sx < clip.min_x)
110            { /* clip left */
111               int pixels = clip.min_x-sx;
112               sx += pixels;
113               x_index_base += pixels*dx;
114            }
115            if( sy < clip.min_y )
116            { /* clip top */
117               int pixels = clip.min_y-sy;
118               sy += pixels;
119               y_index += pixels*dy;
120            }
121            /* NS 980211 - fixed incorrect clipping */
122            if( ex > clip.max_x+1 )
123            { /* clip right */
124               int pixels = ex-clip.max_x-1;
125               ex -= pixels;
126            }
127            if( ey > clip.max_y+1 )
128            { /* clip bottom */
129               int pixels = ey-clip.max_y-1;
130               ey -= pixels;
131            }
132
133            if( ex>sx )
134            { /* skip if inner loop doesn't draw anything */
135               int y;
136
137               /* case 1: no alpha */
138               if (alpha == 0xff)
139               {
140                  if (pri_buffer)
141                  {
142                     for( y=sy; y<ey; y++ )
143                     {
144                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
145                        UINT32 *dest = &dest_bmp.pix32(y);
146                        UINT8 *pri = &pri_buffer->pix8(y);
147
148                        int x, x_index = x_index_base;
149                        for( x=sx; x<ex; x++ )
150                        {
151                           int c = source[x_index>>16];
152                           if( c != transparent_color )
153                           {
154                              if (((1 << pri[x]) & pri_mask) == 0)
155                                 dest[x] = pal[c];
156                              pri[x] = 31;
157                           }
158                           x_index += dx;
159                        }
160
161                        y_index += dy;
162                     }
163                  }
164                  else
165                  {
166                     for( y=sy; y<ey; y++ )
167                     {
168                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
169                        UINT32 *dest = &dest_bmp.pix32(y);
170
171                        int x, x_index = x_index_base;
172                        for( x=sx; x<ex; x++ )
173                        {
174                           int c = source[x_index>>16];
175                           if( c != transparent_color ) dest[x] = pal[c];
176                           x_index += dx;
177                        }
178
179                        y_index += dy;
180                     }
181                  }
182               }
183
184               /* alpha-blended */
185               else
186               {
187                  if (pri_buffer)
188                  {
189                     for( y=sy; y<ey; y++ )
190                     {
191                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
192                        UINT32 *dest = &dest_bmp.pix32(y);
193                        UINT8 *pri = &pri_buffer->pix8(y);
194
195                        int x, x_index = x_index_base;
196                        for( x=sx; x<ex; x++ )
197                        {
198                           int c = source[x_index>>16];
199                           if( c != transparent_color )
200                           {
201                              if (((1 << pri[x]) & pri_mask) == 0)
202                                 dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
203                              pri[x] = 31;
204                           }
205                           x_index += dx;
206                        }
207
208                        y_index += dy;
209                     }
210                  }
211                  else
212                  {
213                     for( y=sy; y<ey; y++ )
214                     {
215                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
216                        UINT32 *dest = &dest_bmp.pix32(y);
217
218                        int x, x_index = x_index_base;
219                        for( x=sx; x<ex; x++ )
220                        {
221                           int c = source[x_index>>16];
222                           if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
223                           x_index += dx;
224                        }
225
226                        y_index += dy;
227                     }
228                  }
229               }
230            }
231         }
232      }
233   }
234}
235
236void deco_zoomspr_device::dragngun_draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata, UINT32* dragngun_sprite_layout_0_ram, UINT32* dragngun_sprite_layout_1_ram, UINT32* dragngun_sprite_lookup_0_ram, UINT32* dragngun_sprite_lookup_1_ram, UINT32 dragngun_sprite_ctrl )
237{
238   const UINT32 *layout_ram;
239   const UINT32 *lookup_ram;
240   int offs;
241
242   /*
243       Sprites are built from main control ram, which references tile
244       layout ram, which finally references tile lookup ram which holds
245       the actual tile indices to draw and index into the banking
246       control.  Tile lookup and tile layout ram are double buffered.
247
248
249       Main sprite control ram, 8 * 32 bit words per sprite, so
250
251       Word 0:
252           0x0400 - Banking control for tile layout RAM + tile lookup ram
253           0x0200 - ?
254           0x01ff - Index into tile layout RAM
255       Word 1 :
256       Word 2 : X base position
257       Word 3 : Y base position
258       Word 4 :
259           0x8000: X flip
260           0x03ff: X size of block in pixels (for scaling)
261       Word 5 :
262           0x8000: Y flip
263           0x03ff: Y size of block in pixels (for scaling)
264       Word 6 :
265           0x1f - colour.
266           0x20 - ?  Used for background at 'frog' boss and title screen dragon.
267           0x40 - ?  priority?
268           0x80 - Alpha blending enable
269       Word 7 :
270
271
272       Tile layout ram, 4 * 32 bit words per sprite, so
273
274       Word 0:
275           0x2000 - Selector for tile lookup bank!?!?!?!?!?!?
276           0x1fff - Index into tile lookup ram (16 bit word based, NOT 32)
277       Word 1:
278           0xff00 - ?
279           0x00f0 - Width
280           0x000f - Height
281       Word 2:
282           0x01ff - X block offset
283       Word 3:
284           0x01ff - Y block offset
285   */
286
287   /* Sprite global disable bit */
288   if (dragngun_sprite_ctrl&0x40000000)
289      return;
290
291   for (offs = 0;offs < 0x800;offs += 8)
292   {
293      int sx,sy,colour,fx,fy,w,h,x,y,bx,by,alpha,scalex,scaley;
294      int zoomx,zoomy;
295      int xpos,ypos;
296
297      scalex=spritedata[offs+4]&0x3ff;
298      scaley=spritedata[offs+5]&0x3ff;
299      if (!scalex || !scaley) /* Zero pixel size in X or Y - skip block */
300         continue;
301
302      if (spritedata[offs+0]&0x400)
303         layout_ram = dragngun_sprite_layout_1_ram + ((spritedata[offs+0]&0x1ff)*4); //CHECK!
304      else
305         layout_ram = dragngun_sprite_layout_0_ram + ((spritedata[offs+0]&0x1ff)*4); //1ff in drag gun code??
306      h = (layout_ram[1]>>0)&0xf;
307      w = (layout_ram[1]>>4)&0xf;
308      if (!h || !w)
309         continue;
310
311      sx = spritedata[offs+2] & 0x3ff;
312      sy = spritedata[offs+3] & 0x3ff;
313      bx = layout_ram[2] & 0x1ff;
314      by = layout_ram[3] & 0x1ff;
315      if (bx&0x100) bx=1-(bx&0xff);
316      if (by&0x100) by=1-(by&0xff); /* '1 - ' is strange, but correct for Dragongun 'Winners' screen. */
317      if (sx >= 512) sx -= 1024;
318      if (sy >= 512) sy -= 1024;
319
320      colour = spritedata[offs+6]&0x1f;
321
322      if (spritedata[offs+6]&0x80)
323         alpha=0x80;
324      else
325         alpha=0xff;
326
327      fx = spritedata[offs+4]&0x8000;
328      fy = spritedata[offs+5]&0x8000;
329
330//      if (spritedata[offs+0]&0x400)
331      if (layout_ram[0]&0x2000)
332         lookup_ram = dragngun_sprite_lookup_1_ram + (layout_ram[0]&0x1fff);
333      else
334         lookup_ram = dragngun_sprite_lookup_0_ram + (layout_ram[0]&0x1fff);
335
336      zoomx=scalex * 0x10000 / (w*16);
337      zoomy=scaley * 0x10000 / (h*16);
338
339      if (!fy)
340         ypos=(sy<<16) - (by*zoomy); /* The block offset scales with zoom, the base position does not */
341      else
342         ypos=(sy<<16) + (by*zoomy) - (16*zoomy);
343
344      for (y=0; y<h; y++) {
345         if (!fx)
346            xpos=(sx<<16) - (bx*zoomx); /* The block offset scales with zoom, the base position does not */
347         else
348            xpos=(sx<<16) + (bx*zoomx) - (16*zoomx);
349
350         for (x=0; x<w; x++) {
351            int bank,sprite;
352
353            sprite = ((*(lookup_ram++))&0x3fff);
354
355            /* High bits of the sprite reference into the sprite control bits for banking */
356            switch (sprite&0x3000) {
357            default:
358            case 0x0000: sprite=(sprite&0xfff) | ((dragngun_sprite_ctrl&0x000f)<<12); break;
359            case 0x1000: sprite=(sprite&0xfff) | ((dragngun_sprite_ctrl&0x00f0)<< 8); break;
360            case 0x2000: sprite=(sprite&0xfff) | ((dragngun_sprite_ctrl&0x0f00)<< 4); break;
361            case 0x3000: sprite=(sprite&0xfff) | ((dragngun_sprite_ctrl&0xf000)<< 0); break;
362            }
363
364            /* Because of the unusual interleaved rom layout, we have to mangle the bank bits
365            even further to suit our gfx decode */
366            switch (sprite&0xf000) {
367            case 0x0000: sprite=0xc000 | (sprite&0xfff); break;
368            case 0x1000: sprite=0xd000 | (sprite&0xfff); break;
369            case 0x2000: sprite=0xe000 | (sprite&0xfff); break;
370            case 0x3000: sprite=0xf000 | (sprite&0xfff); break;
371
372            case 0xc000: sprite=0x0000 | (sprite&0xfff); break;
373            case 0xd000: sprite=0x1000 | (sprite&0xfff); break;
374            case 0xe000: sprite=0x2000 | (sprite&0xfff); break;
375            case 0xf000: sprite=0x3000 | (sprite&0xfff); break;
376            }
377
378            if (sprite&0x8000) bank=4; else bank=3;
379            sprite&=0x7fff;
380
381            if (zoomx!=0x10000 || zoomy!=0x10000)
382               dragngun_drawgfxzoom(
383                  bitmap,cliprect,m_gfxdecode->gfx(bank),
384                  sprite,
385                  colour,
386                  fx,fy,
387                  xpos>>16,ypos>>16,
388                  15,zoomx,zoomy,NULL,0,
389                  ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16), alpha );
390            else
391               m_gfxdecode->gfx(bank)->alpha(bitmap,cliprect,
392                  sprite,
393                  colour,
394                  fx,fy,
395                  xpos>>16,ypos>>16,
396                  15,alpha);
397
398            if (fx)
399               xpos-=zoomx<<4;
400            else
401               xpos+=zoomx<<4;
402         }
403         if (fy)
404            ypos-=zoomy<<4;
405         else
406            ypos+=zoomy<<4;
407      }
408   }
409}
410
Property changes on: trunk/src/mame/video/deco_zoomspr.c
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/mame/video/deco_zoomspr.h
r0r31048
1
2
3class deco_zoomspr_device : public device_t
4{
5public:
6   deco_zoomspr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7
8   static void static_set_palette_tag(device_t &device, const char *tag);
9   static void static_set_gfxdecode_tag(device_t &device, const char *tag);
10
11   void dragngun_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata, UINT32* dragngun_sprite_layout_0_ram, UINT32* dragngun_sprite_layout_1_ram, UINT32* dragngun_sprite_lookup_0_ram, UINT32* dragngun_sprite_lookup_1_ram, UINT32 dragngun_sprite_ctrl);
12
13
14protected:
15   virtual void device_start();
16   virtual void device_reset();
17
18private:
19   required_device<palette_device> m_palette;
20   required_device<gfxdecode_device> m_gfxdecode;
21
22   void dragngun_drawgfxzoom(
23      bitmap_rgb32 &dest_bmp, const rectangle &clip, gfx_element *gfx,
24      UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy,
25      int transparent_color,
26      int scalex, int scaley, bitmap_ind8 *pri_buffer, UINT32 pri_mask, int sprite_screen_width, int  sprite_screen_height, UINT8 alpha);
27
28};
29
30
31extern const device_type DECO_ZOOMSPR;
32
33#define MCFG_DECO_ZOOMSPR_PALETTE(_palette_tag) \
34   deco_zoomspr_device::static_set_palette_tag(*device, "^" _palette_tag);
35
36#define MCFG_DECO_ZOOMSPR_GFXDECODE(_gfxtag) \
37   deco_zoomspr_device::static_set_gfxdecode_tag(*device, "^" _gfxtag);
38
Property changes on: trunk/src/mame/video/deco_zoomspr.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/mame/video/deco32.c
r31047r31048
140140   }
141141}
142142
143/******************************************************************************/
144143
145
146INLINE void dragngun_drawgfxzoom(dragngun_state *state,
147      bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
148      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
149      int transparent_color,
150      int scalex, int scaley,bitmap_ind8 *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int  sprite_screen_height, UINT8 alpha )
151{
152   rectangle myclip;
153
154   if (!scalex || !scaley) return;
155
156   /*
157   scalex and scaley are 16.16 fixed point numbers
158   1<<15 : shrink to 50%
159   1<<16 : uniform scale
160   1<<17 : double to 200%
161   */
162
163   /* KW 991012 -- Added code to force clip to bitmap boundary */
164   myclip = clip;
165   myclip &= dest_bmp.cliprect();
166
167   {
168      if( gfx )
169      {
170         const pen_t *pal = &state->m_palette->pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors()));
171         const UINT8 *code_base = gfx->get_data(code % gfx->elements());
172
173         if (sprite_screen_width && sprite_screen_height)
174         {
175            /* compute sprite increment per screen pixel */
176            int dx = (gfx->width()<<16)/sprite_screen_width;
177            int dy = (gfx->height()<<16)/sprite_screen_height;
178
179            int ex = sx+sprite_screen_width;
180            int ey = sy+sprite_screen_height;
181
182            int x_index_base;
183            int y_index;
184
185            if( flipx )
186            {
187               x_index_base = (sprite_screen_width-1)*dx;
188               dx = -dx;
189            }
190            else
191            {
192               x_index_base = 0;
193            }
194
195            if( flipy )
196            {
197               y_index = (sprite_screen_height-1)*dy;
198               dy = -dy;
199            }
200            else
201            {
202               y_index = 0;
203            }
204
205            if( sx < clip.min_x)
206            { /* clip left */
207               int pixels = clip.min_x-sx;
208               sx += pixels;
209               x_index_base += pixels*dx;
210            }
211            if( sy < clip.min_y )
212            { /* clip top */
213               int pixels = clip.min_y-sy;
214               sy += pixels;
215               y_index += pixels*dy;
216            }
217            /* NS 980211 - fixed incorrect clipping */
218            if( ex > clip.max_x+1 )
219            { /* clip right */
220               int pixels = ex-clip.max_x-1;
221               ex -= pixels;
222            }
223            if( ey > clip.max_y+1 )
224            { /* clip bottom */
225               int pixels = ey-clip.max_y-1;
226               ey -= pixels;
227            }
228
229            if( ex>sx )
230            { /* skip if inner loop doesn't draw anything */
231               int y;
232
233               /* case 1: no alpha */
234               if (alpha == 0xff)
235               {
236                  if (pri_buffer)
237                  {
238                     for( y=sy; y<ey; y++ )
239                     {
240                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
241                        UINT32 *dest = &dest_bmp.pix32(y);
242                        UINT8 *pri = &pri_buffer->pix8(y);
243
244                        int x, x_index = x_index_base;
245                        for( x=sx; x<ex; x++ )
246                        {
247                           int c = source[x_index>>16];
248                           if( c != transparent_color )
249                           {
250                              if (((1 << pri[x]) & pri_mask) == 0)
251                                 dest[x] = pal[c];
252                              pri[x] = 31;
253                           }
254                           x_index += dx;
255                        }
256
257                        y_index += dy;
258                     }
259                  }
260                  else
261                  {
262                     for( y=sy; y<ey; y++ )
263                     {
264                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
265                        UINT32 *dest = &dest_bmp.pix32(y);
266
267                        int x, x_index = x_index_base;
268                        for( x=sx; x<ex; x++ )
269                        {
270                           int c = source[x_index>>16];
271                           if( c != transparent_color ) dest[x] = pal[c];
272                           x_index += dx;
273                        }
274
275                        y_index += dy;
276                     }
277                  }
278               }
279
280               /* alpha-blended */
281               else
282               {
283                  if (pri_buffer)
284                  {
285                     for( y=sy; y<ey; y++ )
286                     {
287                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
288                        UINT32 *dest = &dest_bmp.pix32(y);
289                        UINT8 *pri = &pri_buffer->pix8(y);
290
291                        int x, x_index = x_index_base;
292                        for( x=sx; x<ex; x++ )
293                        {
294                           int c = source[x_index>>16];
295                           if( c != transparent_color )
296                           {
297                              if (((1 << pri[x]) & pri_mask) == 0)
298                                 dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
299                              pri[x] = 31;
300                           }
301                           x_index += dx;
302                        }
303
304                        y_index += dy;
305                     }
306                  }
307                  else
308                  {
309                     for( y=sy; y<ey; y++ )
310                     {
311                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
312                        UINT32 *dest = &dest_bmp.pix32(y);
313
314                        int x, x_index = x_index_base;
315                        for( x=sx; x<ex; x++ )
316                        {
317                           int c = source[x_index>>16];
318                           if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
319                           x_index += dx;
320                        }
321
322                        y_index += dy;
323                     }
324                  }
325               }
326            }
327         }
328      }
329   }
330}
331
332void dragngun_state::dragngun_draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata)
333{
334   const UINT32 *layout_ram;
335   const UINT32 *lookup_ram;
336   int offs;
337
338   /*
339       Sprites are built from main control ram, which references tile
340       layout ram, which finally references tile lookup ram which holds
341       the actual tile indices to draw and index into the banking
342       control.  Tile lookup and tile layout ram are double buffered.
343
344
345       Main sprite control ram, 8 * 32 bit words per sprite, so
346
347       Word 0:
348           0x0400 - Banking control for tile layout RAM + tile lookup ram
349           0x0200 - ?
350           0x01ff - Index into tile layout RAM
351       Word 1 :
352       Word 2 : X base position
353       Word 3 : Y base position
354       Word 4 :
355           0x8000: X flip
356           0x03ff: X size of block in pixels (for scaling)
357       Word 5 :
358           0x8000: Y flip
359           0x03ff: Y size of block in pixels (for scaling)
360       Word 6 :
361           0x1f - colour.
362           0x20 - ?  Used for background at 'frog' boss and title screen dragon.
363           0x40 - ?  priority?
364           0x80 - Alpha blending enable
365       Word 7 :
366
367
368       Tile layout ram, 4 * 32 bit words per sprite, so
369
370       Word 0:
371           0x2000 - Selector for tile lookup bank!?!?!?!?!?!?
372           0x1fff - Index into tile lookup ram (16 bit word based, NOT 32)
373       Word 1:
374           0xff00 - ?
375           0x00f0 - Width
376           0x000f - Height
377       Word 2:
378           0x01ff - X block offset
379       Word 3:
380           0x01ff - Y block offset
381   */
382
383   /* Sprite global disable bit */
384   if (m_dragngun_sprite_ctrl&0x40000000)
385      return;
386
387   for (offs = 0;offs < 0x800;offs += 8)
388   {
389      int sx,sy,colour,fx,fy,w,h,x,y,bx,by,alpha,scalex,scaley;
390      int zoomx,zoomy;
391      int xpos,ypos;
392
393      scalex=spritedata[offs+4]&0x3ff;
394      scaley=spritedata[offs+5]&0x3ff;
395      if (!scalex || !scaley) /* Zero pixel size in X or Y - skip block */
396         continue;
397
398      if (spritedata[offs+0]&0x400)
399         layout_ram = m_dragngun_sprite_layout_1_ram + ((spritedata[offs+0]&0x1ff)*4); //CHECK!
400      else
401         layout_ram = m_dragngun_sprite_layout_0_ram + ((spritedata[offs+0]&0x1ff)*4); //1ff in drag gun code??
402      h = (layout_ram[1]>>0)&0xf;
403      w = (layout_ram[1]>>4)&0xf;
404      if (!h || !w)
405         continue;
406
407      sx = spritedata[offs+2] & 0x3ff;
408      sy = spritedata[offs+3] & 0x3ff;
409      bx = layout_ram[2] & 0x1ff;
410      by = layout_ram[3] & 0x1ff;
411      if (bx&0x100) bx=1-(bx&0xff);
412      if (by&0x100) by=1-(by&0xff); /* '1 - ' is strange, but correct for Dragongun 'Winners' screen. */
413      if (sx >= 512) sx -= 1024;
414      if (sy >= 512) sy -= 1024;
415
416      colour = spritedata[offs+6]&0x1f;
417
418      if (spritedata[offs+6]&0x80)
419         alpha=0x80;
420      else
421         alpha=0xff;
422
423      fx = spritedata[offs+4]&0x8000;
424      fy = spritedata[offs+5]&0x8000;
425
426//      if (spritedata[offs+0]&0x400)
427      if (layout_ram[0]&0x2000)
428         lookup_ram = m_dragngun_sprite_lookup_1_ram + (layout_ram[0]&0x1fff);
429      else
430         lookup_ram = m_dragngun_sprite_lookup_0_ram + (layout_ram[0]&0x1fff);
431
432      zoomx=scalex * 0x10000 / (w*16);
433      zoomy=scaley * 0x10000 / (h*16);
434
435      if (!fy)
436         ypos=(sy<<16) - (by*zoomy); /* The block offset scales with zoom, the base position does not */
437      else
438         ypos=(sy<<16) + (by*zoomy) - (16*zoomy);
439
440      for (y=0; y<h; y++) {
441         if (!fx)
442            xpos=(sx<<16) - (bx*zoomx); /* The block offset scales with zoom, the base position does not */
443         else
444            xpos=(sx<<16) + (bx*zoomx) - (16*zoomx);
445
446         for (x=0; x<w; x++) {
447            int bank,sprite;
448
449            sprite = ((*(lookup_ram++))&0x3fff);
450
451            /* High bits of the sprite reference into the sprite control bits for banking */
452            switch (sprite&0x3000) {
453            default:
454            case 0x0000: sprite=(sprite&0xfff) | ((m_dragngun_sprite_ctrl&0x000f)<<12); break;
455            case 0x1000: sprite=(sprite&0xfff) | ((m_dragngun_sprite_ctrl&0x00f0)<< 8); break;
456            case 0x2000: sprite=(sprite&0xfff) | ((m_dragngun_sprite_ctrl&0x0f00)<< 4); break;
457            case 0x3000: sprite=(sprite&0xfff) | ((m_dragngun_sprite_ctrl&0xf000)<< 0); break;
458            }
459
460            /* Because of the unusual interleaved rom layout, we have to mangle the bank bits
461            even further to suit our gfx decode */
462            switch (sprite&0xf000) {
463            case 0x0000: sprite=0xc000 | (sprite&0xfff); break;
464            case 0x1000: sprite=0xd000 | (sprite&0xfff); break;
465            case 0x2000: sprite=0xe000 | (sprite&0xfff); break;
466            case 0x3000: sprite=0xf000 | (sprite&0xfff); break;
467
468            case 0xc000: sprite=0x0000 | (sprite&0xfff); break;
469            case 0xd000: sprite=0x1000 | (sprite&0xfff); break;
470            case 0xe000: sprite=0x2000 | (sprite&0xfff); break;
471            case 0xf000: sprite=0x3000 | (sprite&0xfff); break;
472            }
473
474            if (sprite&0x8000) bank=4; else bank=3;
475            sprite&=0x7fff;
476
477            if (zoomx!=0x10000 || zoomy!=0x10000)
478               dragngun_drawgfxzoom(this,
479                  bitmap,cliprect,m_gfxdecode->gfx(bank),
480                  sprite,
481                  colour,
482                  fx,fy,
483                  xpos>>16,ypos>>16,
484                  15,zoomx,zoomy,NULL,0,
485                  ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16), alpha );
486            else
487               m_gfxdecode->gfx(bank)->alpha(bitmap,cliprect,
488                  sprite,
489                  colour,
490                  fx,fy,
491                  xpos>>16,ypos>>16,
492                  15,alpha);
493
494            if (fx)
495               xpos-=zoomx<<4;
496            else
497               xpos+=zoomx<<4;
498         }
499         if (fy)
500            ypos-=zoomy<<4;
501         else
502            ypos+=zoomy<<4;
503      }
504   }
505}
506
507144/******************************************************************************/
508145
509146VIDEO_START_MEMBER(deco32_state,captaven)
r31047r31048
616253   // multiple layers of alpha, so rendering to a buffer for layer isn't easy (maybe there are multiple sprite
617254   // chips at work?)
618255   //
619   // really, it needs optimizing .. the raster effects also need fixing properly, they're not correct using
620   // partial updates right now but the old buffering of scroll values was a hack and doesn't work properly
621   // with the concept of generic tilemap code.
622   //
623   // for now we only draw these 2 layers on the last update call
256   // really, it needs optimizing ..
257   // so for now we only draw these 2 layers on the last update call
624258   if (cliprect.max_y == 247)
625259   {
626260      rectangle clip(cliprect.min_x, cliprect.max_x, 8, 247);
627261
628      dragngun_draw_sprites(bitmap,clip,m_spriteram->buffer());
262      m_sprgenzoom->dragngun_draw_sprites(bitmap,clip,m_spriteram->buffer(), m_dragngun_sprite_layout_0_ram, m_dragngun_sprite_layout_1_ram, m_dragngun_sprite_lookup_0_ram, m_dragngun_sprite_lookup_1_ram, m_dragngun_sprite_ctrl );
629263      m_deco_tilegen1->tilemap_1_draw(screen, bitmap, clip, 0, 0);
630264
631265   }
trunk/src/mame/drivers/deco32.c
r31047r31048
20242024   MCFG_DECO16IC_GFXDECODE("gfxdecode")
20252025   MCFG_DECO16IC_PALETTE("palette")
20262026
2027   MCFG_DEVICE_ADD("spritegen_zoom", DECO_ZOOMSPR, 0)
2028   MCFG_DECO_ZOOMSPR_GFXDECODE("gfxdecode")
2029   MCFG_DECO_ZOOMSPR_PALETTE("palette")
2030
20272031   MCFG_GFXDECODE_ADD("gfxdecode", "palette", dragngun)
20282032   MCFG_PALETTE_ADD("palette", 2048)
20292033
r31047r31048
21392143   MCFG_DECO16IC_GFXDECODE("gfxdecode")
21402144   MCFG_DECO16IC_PALETTE("palette")
21412145
2146   MCFG_DEVICE_ADD("spritegen_zoom", DECO_ZOOMSPR, 0)
2147   MCFG_DECO_ZOOMSPR_GFXDECODE("gfxdecode")
2148   MCFG_DECO_ZOOMSPR_PALETTE("palette")
2149
21422150   MCFG_DECO146_ADD("ioprot")
21432151   MCFG_DECO146_SET_SOUNDLATCH_CALLBACK(deco32_state, deco32_sound_cb)
21442152   MCFG_DECO146_SET_INTERFACE_SCRAMBLE_REVERSE

Previous 199869 Revisions Next


© 1997-2024 The MAME Team