Previous 199869 Revisions Next

r30595 Thursday 22nd May, 2014 at 15:23:09 UTC by David Haywood
spbactn now uses render to individual bitmaps then mix... fixes a few priority bugs, but there are a lot of uncertain cases
[src/mame/drivers]spbactn.c
[src/mame/video]spbactn.c tecmo_spr.c

trunk/src/mame/video/tecmo_spr.c
r30594r30595
133133      if (source[enable_word] & 0x04)
134134      {
135135         UINT32 priority = (attributes >> 6) & 3;
136         
137         // hack for spbactn which still calls us multi-pass (and uses different bits into the mixer as priority?)
138         if (pri_hack >= 0)
139         {
140            int alt_pri;
141            alt_pri = (source[0] & 0x0030)>>4;
142            if (alt_pri != pri_hack)
143            {
144               source += sourceinc;
145               continue;
146            }
147         }
148         
136                 
149137         UINT32 flipx = (attributes & 1);
150138         UINT32 flipy = (attributes & 2);
151139
r30594r30595
215203               bitmap = (priority >= 2) ? &bitmap_bg : &bitmap_fg;
216204            }
217205         }
218         else if (pri_hack == -2) // render to a single bitmap, with all priority / colour data mixed in for later processing (assumings sprites can't blend sprites we should probably be doing this)
206         else // render to a single bitmap, with all priority / colour data mixed in for later processing (assumings sprites can't blend sprites we should probably be doing this)
219207         {
220208
221209            // this contains the blend bit and the priority bits
222210            color |= (source[attributes_word] & 0x00f0);
223211            bitmap = &bitmap_prihack;
224212         }
225         else // spbactn
226         {
227            // this is nonsense
228            attributes &= ~0x0040;                            /* !!! */
229213
230            if (attributes & 0x0040)
231               color |= 0x0180;
232            else
233               color |= 0x0080;
234
235            bitmap = &bitmap_prihack;
236         }
237
238214         for (row = 0; row < sizey; row++)
239215         {
240216            for (col = 0; col < sizex; col++)
trunk/src/mame/video/spbactn.c
r30594r30595
33#include "includes/spbactn.h"
44
55
6static void blendbitmaps(palette_device &palette,
7      bitmap_rgb32 &dest,bitmap_ind16 &src1,bitmap_ind16 &src2,
8      const rectangle &cliprect)
9{
10   int y,x;
11   const pen_t *paldata = palette.pens();
126
13   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
14   {
15      UINT32 *dd  = &dest.pix32(y);
16      UINT16 *sd1 = &src1.pix16(y);
17      UINT16 *sd2 = &src2.pix16(y);
18
19      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
20      {
21         if (sd2[x])
22         {
23            if (sd2[x] & 0x1000)
24               dd[x] = paldata[sd1[x] & 0x07ff] + paldata[sd2[x]];
25            else
26               dd[x] = paldata[sd2[x]];
27         }
28         else
29            dd[x] = paldata[sd1[x]];
30      }
31   }
32}
33
34
35
367WRITE16_MEMBER(spbactn_state::bg_videoram_w)
378{
389   COMBINE_DATA(&m_bgvideoram[offset]);
r30594r30595
4314{
4415   int attr = m_bgvideoram[tile_index];
4516   int tileno = m_bgvideoram[tile_index+0x2000];
46   SET_TILE_INFO_MEMBER(1, tileno, ((attr & 0x00f0)>>4)+0x80, 0);
17   SET_TILE_INFO_MEMBER(1, tileno, ((attr & 0x00f0)>>4), 0);
4718}
4819
4920
r30594r30595
6233
6334   /* blending */
6435   if (attr & 0x0008)
65      color += 0x00f0;
66   else
67      color |= 0x0080;
36      color += 0x0010;
6837
6938   SET_TILE_INFO_MEMBER(0, tileno, color, 0);
7039}
r30594r30595
149118
150119int spbactn_state::draw_video(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, bool alt_sprites)
151120{
121   m_tile_bitmap_bg.fill(0, cliprect);
152122   m_tile_bitmap_fg.fill(0, cliprect);
153123   m_sprite_bitmap.fill(0, cliprect);
154   
155#if 1
156   m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, TILEMAP_DRAW_OPAQUE, 0);
124   bitmap.fill(0, cliprect);
157125
158
159   if (m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spvideoram, 0, 0, flip_screen(), 0, m_tile_bitmap_bg))
160   {
161      m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, 0, 0);
162   }
163
164   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spvideoram, 0, 0, flip_screen(), 1, m_tile_bitmap_bg);
165   
126   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_tile_bitmap_fg, cliprect, m_spvideoram, 0, 0, flip_screen(), -2, m_sprite_bitmap);
127   m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, 0, 0);
166128   m_fg_tilemap->draw(screen, m_tile_bitmap_fg, cliprect, 0, 0);
167129
168   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spvideoram, 0, 0, flip_screen(), 2, m_tile_bitmap_fg);
169   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spvideoram, 0, 0, flip_screen(), 3, m_tile_bitmap_fg);
170130
171   /* mix & blend the tilemaps and sprites into a 32-bit bitmap */
172   blendbitmaps(m_palette, bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, cliprect);
173#else
174   bitmap.fill(0, cliprect);
175131
176   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_tile_bitmap_fg, cliprect, m_spvideoram, 0, 0, flip_screen(), -2, m_sprite_bitmap);
132   //int frame = (screen.frame_number()) & 1;
133   // note this game has no tx layer, comments relate to other drivers
177134
178
179135   int y, x;
180136   const pen_t *paldata = m_palette->pens();
181137
r30594r30595
183139   {
184140      UINT32 *dd = &bitmap.pix32(y);
185141      UINT16 *sd2 = &m_sprite_bitmap.pix16(y);
142      UINT16 *fg = &m_tile_bitmap_fg.pix16(y);
143      UINT16 *bg = &m_tile_bitmap_bg.pix16(y);
186144
187145      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
188146      {
189         UINT16 pixel = (sd2[x] & 0xff) + 0x800;
147         UINT16 sprpixel = (sd2[x]);
190148
191         if (pixel & 0xf) dd[x] = paldata[pixel];
149         UINT16 sprpri = (sprpixel & 0x0300) >> 8;
150         UINT16 sprbln = (sprpixel & 0x0400) >> 8;
151         sprpixel &= 0xff;
152
153         UINT16 fgpixel = (fg[x]);
154         UINT16 fgbln = (fgpixel & 0x0100) >> 8;
155         fgpixel &= 0xff;
156
157         UINT16 bgpixel = (bg[x]);
158         bgpixel &= 0xff;
159
160         if (sprpixel&0xf)
161         {
162            switch (sprpri)
163            {
164            case 0: // behind all
165           
166
167               if (fgpixel & 0xf) // is the fg used?
168               {
169                  if (fgbln)
170                  {
171                     dd[x] = rand();
172                  }
173                  else
174                  {
175                     // solid FG
176                     dd[x] = paldata[fgpixel + 0x800 + 0x200];
177                  }
178               }
179               else if (bgpixel & 0x0f)
180               {
181                  // solid BG
182                  dd[x] = paldata[bgpixel + 0x800 + 0x300];
183               }
184               else
185               {
186                  if (sprbln)
187                  { // sprite is blended with bgpen?
188                     dd[x] = rand();
189                  }
190                  else
191                  {
192                     // solid sprite
193                     dd[x] = paldata[sprpixel + 0x800 + 0x000];
194                  }
195
196               }
197         
198               break;
199
200            case 1: // above bg, behind tx, fg
201           
202               if (fgpixel & 0xf) // is the fg used?
203               {
204                  if (fgbln)
205                  {
206                     if (sprbln)
207                     {
208                        // needs if bgpixel & 0xf check?
209
210                        // fg is used and blended with sprite, sprite is used and blended with bg?  -- used on 'trail' of ball when ball is under the transparent area
211                        dd[x] = paldata[bgpixel + 0x0000 + 0x300] + paldata[sprpixel + 0x1000 + 0x000]; // WRONG??
212                     }
213                     else
214                     {
215                        // fg is used and blended with opaque sprite                 
216                        dd[x] = paldata[fgpixel + 0x1000 + 0x100] + paldata[sprpixel + 0x000 + 0x000];
217                     }
218                  }
219                  else
220                  {
221                     // fg is used and opaque
222                     dd[x] = paldata[fgpixel + 0x800 + 0x200];
223                  }
224
225               }
226               else
227               {
228                  if (sprbln)
229                  {
230                     // needs if bgpixel & 0xf check?
231
232                     //fg isn't used, sprite is used and blended with bg? -- used on trail of ball / flippers
233                     dd[x] = paldata[bgpixel + 0x0000 + 0x300];/* +paldata[sprpixel + 0x1000 + 0x000];*/  // WRONG??
234                  }
235                  else
236                  {
237                     // fg isn't used, sprite is used and is opaque
238                     dd[x] = paldata[sprpixel + 0x800 + 0x000];
239                  }
240               }
241         
242           
243               break;
244
245            case 2: // above bg,fg, behind tx
246           
247               if (sprbln)
248               {
249                  // unusued by this game?
250                  dd[x] = 0;// rand();
251
252               }
253               else
254               {
255                  dd[x] = paldata[sprpixel + 0x800 + 0x000];
256                  //dd[x] = rand();
257               }
258               break;
259
260            case 3: // above all?
261           
262               if (sprbln)
263               {
264                  // unusued by this game?
265                  dd[x] = rand();
266               }
267               else
268               {
269                  dd[x] = paldata[sprpixel + 0x800 + 0x000];
270               }
271           
272               break;
273
274            }
275         }
276         else // NON SPRITE CASES
277         {
278            if (fgpixel & 0x0f)
279            {
280               if (fgbln)
281               {
282                  // needs if bgpixel & 0xf check?
283                  dd[x] = paldata[fgpixel + 0x1000 + 0x100] + paldata[bgpixel + 0x0000+0x300];
284           
285               }
286               else
287               {
288                  dd[x] = paldata[fgpixel + 0x800 + 0x200];
289               }
290               
291            }
292            else /*if (bgpixel & 0x0f) */
293            {
294               dd[x] = paldata[bgpixel + 0x800 + 0x300];
295            }
296         }
192297      }
193298   }
194299
195#endif
300
196301   return 0;
197302}
198303
trunk/src/mame/drivers/spbactn.c
r30594r30595
363363static GFXDECODE_START( spbactn )
364364   GFXDECODE_ENTRY( "gfx1", 0, fgtilelayout,   0x0200, 16 + 240 )
365365   GFXDECODE_ENTRY( "gfx2", 0, bgtilelayout,   0x0300, 16 + 128 )
366   GFXDECODE_ENTRY( "gfx3", 0, spritelayout,   0x0000, 16 + 384 )
366   GFXDECODE_ENTRY( "gfx3", 0, spritelayout,   0x0000, 0x1000 )
367367GFXDECODE_END
368368
369369

Previous 199869 Revisions Next


© 1997-2024 The MAME Team