Previous 199869 Revisions Next

r31062 Saturday 21st June, 2014 at 17:17:33 UTC by David Haywood
work in progress (nw)
[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
r31061r31062
214214   
215215   DECO16IC_BANK_CB_MEMBER(bank_1_callback);
216216   DECO16IC_BANK_CB_MEMBER(bank_2_callback);
217
218   bitmap_rgb32 m_temp_render_bitmap;
219
217220};
trunk/src/mame/video/deco_zoomspr.c
r31061r31062
5151      bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
5252      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
5353      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 )
54      int scalex, int scaley,bitmap_ind8 *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int  sprite_screen_height, UINT8 alpha,
55      bitmap_ind8 &pri_bitmap, bitmap_rgb32 &temp_bitmap,
56      int priority)
5557{
5658   rectangle myclip;
5759
r31061r31062
6668
6769   /* KW 991012 -- Added code to force clip to bitmap boundary */
6870   myclip = clip;
69   myclip &= dest_bmp.cliprect();
71   myclip &= temp_bitmap.cliprect();
7072
7173   {
7274      if( gfx )
r31061r31062
137139               /* case 1: no alpha */
138140               if (alpha == 0xff)
139141               {
140                  if (pri_buffer)
141142                  {
142143                     for( y=sy; y<ey; y++ )
143144                     {
144145                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
145                        UINT32 *dest = &dest_bmp.pix32(y);
146                        UINT8 *pri = &pri_buffer->pix8(y);
146                        UINT32 *dest = &temp_bitmap.pix32(y);
147                        UINT8 *pri = &pri_bitmap.pix8(y);
147148
149
148150                        int x, x_index = x_index_base;
149151                        for( x=sx; x<ex; x++ )
150152                        {
151153                           int c = source[x_index>>16];
152                           if( c != transparent_color )
154                           if (c != transparent_color)
153155                           {
154                              if (((1 << pri[x]) & pri_mask) == 0)
156                              if (priority >= pri[x])
157                              {
155158                                 dest[x] = pal[c];
156                              pri[x] = 31;
159                                 dest[x] |= 0xff000000;
160                              }
161                              else // sprites can have a 'masking' effect on other sprites
162                              {
163                                 dest[x] = 0x00000000;
164                              }
157165                           }
158                           x_index += dx;
159                        }
160166
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];
176167                           x_index += dx;
177168                        }
178169
r31061r31062
184175               /* alpha-blended */
185176               else
186177               {
187                  if (pri_buffer)
188178                  {
189179                     for( y=sy; y<ey; y++ )
190180                     {
191181                        const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes();
192                        UINT32 *dest = &dest_bmp.pix32(y);
193                        UINT8 *pri = &pri_buffer->pix8(y);
182                        UINT32 *dest = &temp_bitmap.pix32(y);
183                        UINT8 *pri = &pri_bitmap.pix8(y);
184                        UINT32 *tmapcolor = &dest_bmp.pix32(y);
194185
186                       
195187                        int x, x_index = x_index_base;
196188                        for( x=sx; x<ex; x++ )
197189                        {
198190                           int c = source[x_index>>16];
199                           if( c != transparent_color )
191                           if (c != transparent_color)
200192                           {
201                              if (((1 << pri[x]) & pri_mask) == 0)
202                                 dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
203                              pri[x] = 31;
193                              if (priority >= pri[x])
194                              {
195                                 if ((dest[x] & 0xff000000) == 0x00000000)
196                                    dest[x] = alpha_blend_r32(tmapcolor[x] & 0x00ffffff, pal[c] & 0x00ffffff, alpha); // if nothing has been drawn pull the pixel from the tilemap to blend with
197                                 else
198                                    dest[x] = alpha_blend_r32(dest[x] & 0x00ffffff, pal[c] & 0x00ffffff, alpha); // otherwise blend with what was previously drawn
199
200                                 dest[x] |= 0xff000000;
201                              }
202                              else // sprites can have a 'masking' effect on other sprites
203                              {
204                                 dest[x] = 0x00000000;
205                              }
204206                           }
205                           x_index += dx;
206                        }
207207
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);
223208                           x_index += dx;
224209                        }
225210
r31061r31062
233218   }
234219}
235220
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 )
221void 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, bitmap_ind8 &pri_bitmap, bitmap_rgb32 &temp_bitmap)
237222{
238223   const UINT32 *layout_ram;
239224   const UINT32 *lookup_ram;
240225   int offs;
226   temp_bitmap.fill(0x00000000, cliprect);
241227
242228   /*
243229       Sprites are built from main control ram, which references tile
r31061r31062
319305
320306      colour = spritedata[offs+6]&0x1f;
321307
308      int priority = (spritedata[offs + 6] & 0x60) >> 5;
309      /*
310      if (priority == 0) priority = 1;
311      else if (priority == 1) priority = 1;
312      else if (priority == 2) priority = 1;
313      else if (priority == 3) priority = 1;
314      */
315      priority = 7;
316
322317      if (spritedata[offs+6]&0x80)
323318         alpha=0x80;
324319      else
r31061r31062
378373            if (sprite&0x8000) bank=4; else bank=3;
379374            sprite&=0x7fff;
380375
381            if (zoomx!=0x10000 || zoomy!=0x10000)
382376               dragngun_drawgfxzoom(
383377                  bitmap,cliprect,m_gfxdecode->gfx(bank),
384378                  sprite,
r31061r31062
386380                  fx,fy,
387381                  xpos>>16,ypos>>16,
388382                  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);
383                  ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16), alpha,
384                  pri_bitmap, temp_bitmap,
385                  priority
386                  );
397387
388
398389            if (fx)
399390               xpos-=zoomx<<4;
400391            else
r31061r31062
406397            ypos+=zoomy<<4;
407398      }
408399   }
400     
401   for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
402   {
403      UINT32 *src = &temp_bitmap.pix32(y);
404      UINT32 *dst = &bitmap.pix32(y);
405
406      for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
407      {
408         UINT32 srcpix = src[x];
409
410         if ((srcpix & 0xff000000) == 0xff000000)
411         {
412            dst[x] = srcpix & 0x00ffffff;
413         }
414      }
415
416   }
417
409418}
410419
trunk/src/mame/video/deco_zoomspr.h
r31061r31062
88   static void static_set_palette_tag(device_t &device, const char *tag);
99   static void static_set_gfxdecode_tag(device_t &device, const char *tag);
1010
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);
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, bitmap_ind8 &pri_bitmap, bitmap_rgb32 &temp_bitmap);
1212
1313
1414protected:
r31061r31062
2323      bitmap_rgb32 &dest_bmp, const rectangle &clip, gfx_element *gfx,
2424      UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy,
2525      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);
26      int scalex, int scaley, bitmap_ind8 *pri_buffer, UINT32 pri_mask, int sprite_screen_width, int  sprite_screen_height, UINT8 alpha, bitmap_ind8 &pri_bitmap, bitmap_rgb32 &temp_bitmap,
27      int priority);
2728
2829};
2930
trunk/src/mame/video/deco32.c
r31061r31062
159159{
160160   m_dirty_palette = auto_alloc_array(machine(), UINT8, 4096);
161161
162
163   m_screen->register_screen_bitmap(m_temp_render_bitmap);
164
162165   memset(m_dirty_palette,0,4096);
163166
164167   save_item(NAME(m_dragngun_sprite_ctrl));
165168   m_has_ace_ram=0;
169
170
166171}
167172
168173VIDEO_START_MEMBER(dragngun_state,lockload)
r31061r31062
237242
238243UINT32 dragngun_state::screen_update_dragngun(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
239244{
245   screen.priority().fill(0, cliprect);
240246   bitmap.fill(m_palette->black_pen(), cliprect);
241247
242248   m_deco_tilegen1->pf_update(m_pf1_rowscroll, m_pf2_rowscroll);
r31061r31062
244250
245251   //m_deco_tilegen1->set_pf3_8bpp_mode(1); // despite being 8bpp this doesn't require the same shifting as captaven, why not?
246252
247   m_deco_tilegen2->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); // it uses pf3 in 8bpp mode instead, like captaven
248   m_deco_tilegen2->tilemap_1_draw(screen, bitmap, cliprect, 0, 0);
249   m_deco_tilegen1->tilemap_2_draw(screen, bitmap, cliprect, 0, 0);
253   m_deco_tilegen2->tilemap_2_draw(screen, bitmap, cliprect, 0, 1); // it uses pf3 in 8bpp mode instead, like captaven
254   m_deco_tilegen2->tilemap_1_draw(screen, bitmap, cliprect, 0, 2);
255   m_deco_tilegen1->tilemap_2_draw(screen, bitmap, cliprect, 0, 4);
256   m_deco_tilegen1->tilemap_1_draw(screen, bitmap, cliprect, 0, 8);
250257
251258   // zooming sprite draw is very slow, and sprites are buffered.. however, one of the levels attempts to use
252259   // partial updates for every line, which causes things to be very slow... the sprites appear to support
r31061r31062
259266   {
260267      rectangle clip(cliprect.min_x, cliprect.max_x, 8, 247);
261268
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 );
263      m_deco_tilegen1->tilemap_1_draw(screen, bitmap, clip, 0, 0);
269      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, screen.priority(), m_temp_render_bitmap );
264270
265271   }
266272
trunk/src/mame/drivers/deco32.c
r31061r31062
21462146   MCFG_DEVICE_ADD("spritegen_zoom", DECO_ZOOMSPR, 0)
21472147   MCFG_DECO_ZOOMSPR_GFXDECODE("gfxdecode")
21482148   MCFG_DECO_ZOOMSPR_PALETTE("palette")
2149
2149   
21502150   MCFG_DECO146_ADD("ioprot")
21512151   MCFG_DECO146_SET_SOUNDLATCH_CALLBACK(deco32_state, deco32_sound_cb)
21522152   MCFG_DECO146_SET_INTERFACE_SCRAMBLE_REVERSE

Previous 199869 Revisions Next


© 1997-2024 The MAME Team