Previous 199869 Revisions Next

r30576 Tuesday 20th May, 2014 at 21:54:03 UTC by David Haywood
more function collapse adjustments prior to trying to proper refactoring (nw)
[src/mame/drivers]spbactn.c
[src/mame/video]gaiden.c spbactn.c tecmo16.c tecmo_spr.c tecmo_spr.h

trunk/src/mame/drivers/spbactn.c
r30575r30576
477477
478478   MCFG_DEVICE_ADD("spritegen", TECMO_SPRITE, 0)
479479   MCFG_TECMO_SPRITE_GFX_REGION(2)
480   MCFG_TECMO_SPRITE_ALT_FORMAT
480481
481482   /* sound hardware  - different? */
482483   MCFG_SPEAKER_STANDARD_MONO("mono")
trunk/src/mame/video/tecmo16.c
r30575r30576
250250   m_tx_tilemap->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4);
251251
252252   /* draw sprites into a 16-bit bitmap */
253   if (m_game_is_riot) m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 0, 0, flip_screen());
254   else m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 2, 0, flip_screen());
253   if (m_game_is_riot) m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 0, 0, flip_screen(), -1, m_sprite_bitmap);
254   else m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 2, 0, flip_screen(), -1, m_sprite_bitmap);
255255
256256
257257   /* mix & blend the tilemaps and sprites into a 32-bit bitmap */
trunk/src/mame/video/tecmo_spr.c
r30575r30576
1919tecmo_spr_device::tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2020   : device_t(mconfig, TECMO_SPRITE, "Teccmo 16-bit Sprite", tag, owner, clock, "tecmo_spr", __FILE__),
2121      device_video_interface(mconfig, *this),
22      m_gfxregion(0)
22      m_gfxregion(0),
23      m_altformat(0)
2324{
2425}
2526
r30575r30576
3738{
3839   tecmo_spr_device &dev = downcast<tecmo_spr_device &>(device);
3940   dev.m_gfxregion = gfxregion;
40//  printf("decospr_device::set_gfx_region()\n");
4141}
4242
43void tecmo_spr_device::set_alt_format(device_t &device)
44{
45   tecmo_spr_device &dev = downcast<tecmo_spr_device &>(device);
46   dev.m_altformat = 1;
47}
4348
49
4450static const UINT8 layout[8][8] =
4551{
4652   { 0, 1, 4, 5,16,17,20,21},
r30575r30576
7379 *    5,6,7|                  | unused
7480 */
7581
76/* sprite format (galspnbl):
77 *
78 *  word        bit                 usage
79 * --------+-fedcba9876543210-+----------------
80 *    0    | ---------------x | flip x
81 *         | --------------x- | flip y
82 *         | -------------x-- | enable
83 *         | ----------xx---- | priority?
84 *         | ---------x------ | flicker?
85 *    1    | xxxxxxxxxxxxxxxx | code
86 *    2    | --------xxxx---- | color
87 *         | --------------xx | size: 8x8, 16x16, 32x32, 64x64
88 *    3    | xxxxxxxxxxxxxxxx | y position
89 *    4    | xxxxxxxxxxxxxxxx | x position
90 *    5,6,7|                  | unused
91 */
82#define NUM_SPRITES 256
9283
93
94/* from gals pinball (which was in turn from ninja gaiden) */
95int tecmo_spr_device::spbactn_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites, UINT16* spriteram)
84int tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen, int pri_hack, bitmap_ind16 &bitmap_prihack )
9685{
97   int count = 0;
98   int offs;
86   gfx_element *gfx = gfxdecode->gfx(m_gfxregion);
87   const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram;
88   int count = NUM_SPRITES;
89   int drawn = 0;
90   int screenwidth = screen.width();
9991
100   for (offs = (0x1000 - 16) / 2; offs >= 0; offs -= 8)
101   {
102      int sx, sy, code, color, size, attr, flipx, flipy;
103      int col, row;
10492
105      attr = spriteram[offs];
93   int attributes_word = 0;
94   int tilenumber_word = 1;
95   int colour_word = 2;
96   int yposition_word = 3;
97   int xposition_word = 4;
98   int enable_word = attributes_word;
10699
107      int pri = (spriteram[offs] & 0x0030);
108//      int pri = (spriteram[offs+2] & 0x0030);
109
110
111      if ((attr & 0x0004) &&
112         ((pri & 0x0030) >> 4) == priority)
113      {
114         flipx = attr & 0x0001;
115         flipy = attr & 0x0002;
116
117         code = spriteram[offs + 1];
118
119         if (alt_sprites)
120         {
121            color = spriteram[offs + 0];
122         }
123         else
124         {
125            color = spriteram[offs + 2];
126         }
127
128         size = 1 << (spriteram[offs + 2] & 0x0003);               /* 1,2,4,8 */
129         color = (color & 0x00f0) >> 4;
130
131         sx = spriteram[offs + 4];
132         sy = spriteram[offs + 3];
133
134         attr &= ~0x0040;                            /* !!! */
135
136         if (attr & 0x0040)
137            color |= 0x0180;
138         else
139            color |= 0x0080;
140
141
142         for (row = 0; row < size; row++)
143         {
144            for (col = 0; col < size; col++)
145            {
146               int x = sx + 8 * (flipx ? (size - 1 - col) : col);
147               int y = sy + 8 * (flipy ? (size - 1 - row) : row);
148
149                  gfxdecode->gfx(m_gfxregion)->transpen_raw(bitmap,cliprect,
150                  code + layout[row][col],
151                  gfxdecode->gfx(m_gfxregion)->colorbase() + color * gfxdecode->gfx(2)->granularity(),
152                  flipx, flipy,
153                  x, y,
154                  0);
155            }
156         }
157
158         count++;
159      }
100   if (m_altformat) // spbactn proto, this isn't right.. there are more changes I think
101   {
102      colour_word = 0;
103      attributes_word = 2;
160104   }
161105
162   return count;
163}
106   int xmask;
164107
108   if (screenwidth == 512)
109      xmask = 512;
110   else
111      xmask = 256;
165112
166
167#define NUM_SPRITES 256
168
169void tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen )
170{
171   gfx_element *gfx = gfxdecode->gfx(m_gfxregion);
172   const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram;
173   int count = NUM_SPRITES;
174
175113   /* draw all sprites from front to back */
176114   while (count--)
177115   {
178      UINT32 attributes = source[0];
116      UINT32 attributes = source[attributes_word];
179117      UINT32 priority_mask;
180118      int col,row;
181119
182      if (attributes & 0x04)
120      if (source[enable_word] & 0x04)
183121      {
184122         UINT32 priority = (attributes >> 6) & 3;
123         
124         // hack for spbactn which still calls us multi-pass (and uses different bits into the mixer as priority?)
125         if (pri_hack != -1)
126         {
127            int alt_pri;
128            alt_pri = (source[0] & 0x0030)>>4;
129            if (alt_pri != pri_hack)
130            {
131               source -= 8;
132               continue;
133            }
134         }
135         
185136         UINT32 flipx = (attributes & 1);
186137         UINT32 flipy = (attributes & 2);
187138
188         UINT32 color = source[2];
139         UINT32 color = source[colour_word];
189140         UINT32 sizex = 1 << ((color >> 0) & 3);                     /* 1,2,4,8 */
190141         UINT32 sizey = 1 << ((color >> sprite_sizey) & 3); /* 1,2,4,8 */
191142
192         /* raiga needs something like this */
193         UINT32 number = (source[1]);
143         /* raiga & fstarfrc need something like this */
144         UINT32 number = (source[tilenumber_word]);
194145
195146         if (sizex >= 2) number &= ~0x01;
196147         if (sizey >= 2) number &= ~0x02;
r30575r30576
199150         if (sizex >= 8) number &= ~0x10;
200151         if (sizey >= 8) number &= ~0x20;
201152
202         int ypos = (source[3] + spr_offset_y) & 0x01ff;
203         int xpos = source[4] & 0x01ff;
153         int ypos = (source[yposition_word] + spr_offset_y) & 0x01ff;
154         int xpos = source[xposition_word] & ((xmask*2)-1);
204155
205156         color = (color >> 4) & 0x0f;
206157
207158         /* wraparound */
208         if (xpos >= 256)
209            xpos -= 512;
159         if (xpos >= xmask)
160            xpos -= (xmask*2);
210161         if (ypos >= 256)
211162            ypos -= 512;
212163
r30575r30576
234185            case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa;   break;  /* obscured by bg and fg  */
235186         }
236187
188         bitmap_ind16* bitmap;
237189
238         /* blending */
239         if (attributes & 0x20)
190
191
192         if (pri_hack == -1)
240193         {
241            color |= 0x80;
194            /* blending */
195            if (attributes & 0x20)
196            {
197               color |= 0x80;
198               bitmap = &bitmap_sp;
199            }
200            else
201            {
202               bitmap = (priority >= 2) ? &bitmap_bg : &bitmap_fg;
203            }
204         }
205         else // spbactn
206         {
207            // this is nonsense
208            attributes &= ~0x0040;                            /* !!! */
242209
243            for (row = 0; row < sizey; row++)
210            if (attributes & 0x0040)
211               color |= 0x0180;
212            else
213               color |= 0x0080;
214
215            bitmap = &bitmap_prihack;
216         }
217
218         for (row = 0; row < sizey; row++)
219         {
220            for (col = 0; col < sizex; col++)
244221            {
245               for (col = 0; col < sizex; col++)
246               {
247                  int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
248                  int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
222               int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
223               int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
249224
250                  gfx->prio_transpen_raw(bitmap_sp,cliprect,
225               if (pri_hack == -1)
226               {
227                  gfx->prio_transpen_raw(*bitmap, cliprect,
251228                     number + layout[row][col],
252229                     gfx->colorbase() + color * gfx->granularity(),
253230                     flipx, flipy,
254231                     sx, sy,
255232                     screen.priority(), priority_mask, 0);
256233               }
257            }
258         }
259         else
260         {
261            bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg;
262
263            for (row = 0; row < sizey; row++)
264            {
265               for (col = 0; col < sizex; col++)
234               else // spbactn
266235               {
267                  int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
268                  int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
269
270                  gfx->prio_transpen_raw(bitmap,cliprect,
236                  gfx->transpen_raw(*bitmap, cliprect,
271237                     number + layout[row][col],
272238                     gfx->colorbase() + color * gfx->granularity(),
273239                     flipx, flipy,
274240                     sx, sy,
275                     screen.priority(), priority_mask, 0);
241                     0);
276242               }
277243            }
278         }
244         }   
245
246         drawn++;
247
279248      }
280249      source -= 8;
281250   }
251
252   return drawn;
282253}
283254
255// comad bootleg of spbactn
284256
257/* sprite format (galspnbl):
258 *
259 *  word        bit                 usage
260 * --------+-fedcba9876543210-+----------------
261 *    0    | ---------------x | flip x
262 *         | --------------x- | flip y
263 *         | -------------x-- | enable
264 *         | ----------xx---- | priority?
265 *         | ---------x------ | flicker?
266 *    1    | xxxxxxxxxxxxxxxx | code
267 *    2    | --------xxxx---- | color
268 *         | --------------xx | size: 8x8, 16x16, 32x32, 64x64
269 *    3    | xxxxxxxxxxxxxxxx | y position
270 *    4    | xxxxxxxxxxxxxxxx | x position
271 *    5,6,7|                  | unused
272 */
285273
286
287// comad bootleg of spbactn
288274void tecmo_spr_device::galspnbl_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes )
289275{
290276   int offs;
r30575r30576
321307                  color,
322308                  flipx,flipy,
323309                  x,y,0);
310
324311            }
325312         }
326313      }
trunk/src/mame/video/tecmo_spr.h
r30575r30576
88public:
99   tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
1010   static void set_gfx_region(device_t &device, int gfxregion);
11   static void set_alt_format(device_t &device);
1112
1213   void galspnbl_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes );
13   void gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flipscreen );
14   int spbactn_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites, UINT16* spriteram);
14   int gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flipscreen, int pri_hack, bitmap_ind16 &bitmap_prihack );
1515
1616
1717protected:
r30575r30576
1919   virtual void device_reset();
2020
2121   UINT8 m_gfxregion;
22   int m_altformat; // the super pinball action proto has some differences
23
2224private:
2325};
2426
r30575r30576
2830#define MCFG_TECMO_SPRITE_GFX_REGION(_region) \
2931   tecmo_spr_device::set_gfx_region(*device, _region);
3032
33#define MCFG_TECMO_SPRITE_ALT_FORMAT \
34   tecmo_spr_device::set_alt_format(*device);
trunk/src/mame/video/spbactn.c
r30575r30576
153153   m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, TILEMAP_DRAW_OPAQUE, 0);
154154
155155
156
157   if (m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, cliprect, 0, alt_sprites, m_spvideoram))
156   if (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(), 0, m_tile_bitmap_bg))
158157   {
159158      m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, 0, 0);
160159   }
161160
162   m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, cliprect, 1, alt_sprites, m_spvideoram);
163
161   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(), 1, m_tile_bitmap_bg);
162   
164163   m_fg_tilemap->draw(screen, m_tile_bitmap_fg, cliprect, 0, 0);
165164
165   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_tile_bitmap_fg);
166   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(), 3, m_tile_bitmap_fg);
166167
167   m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_fg, cliprect, 2, alt_sprites, m_spvideoram);
168   m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_fg, cliprect, 3, alt_sprites, m_spvideoram);
169
170168   /* mix & blend the tilemaps and sprites into a 32-bit bitmap */
171169   blendbitmaps(m_palette, bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, cliprect);
172170   return 0;
trunk/src/mame/video/gaiden.c
r30575r30576
377377   m_text_layer->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4);
378378
379379   /* draw sprites into a 16-bit bitmap */
380   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen());
380   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen(), -1, m_sprite_bitmap);
381381
382382   /* mix & blend the tilemaps and sprites into a 32-bit bitmap */
383383   blendbitmaps(bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect);
r30575r30576
402402   m_text_layer->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4);
403403
404404   /* draw sprites into a 16-bit bitmap */
405   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen());
405   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen(), -1, m_sprite_bitmap);
406406
407407   /* mix & blend the tilemaps and sprites into a 32-bit bitmap */
408408   blendbitmaps(bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team