Previous 199869 Revisions Next

r18606 Friday 19th October, 2012 at 16:11:13 UTC by Tafoid
VSystem:  This gets us down to a single set of functions for one of the sprite chips, a couple of games still rely on some undesirable behaviour (multiple calls for different priorities) but we're all going through the same code now at least, and those cases can be cleaned up later.  From Haze (nw)
[src/mame/drivers]aerofgt.c crshrace.c f1gp.c gstriker.c inufuku.c suprslam.c taotaido.c
[src/mame/includes]aerofgt.h
[src/mame/video]aerofgt.c crshrace.c f1gp.c gstriker.c inufuku.c suprslam.c taotaido.c vsystem_spr.c vsystem_spr.h

trunk/src/mame/drivers/suprslam.c
r18605r18606
338338   MCFG_PALETTE_LENGTH(0x800)
339339
340340   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
341   MCFG_VSYSTEM_SPR_SET_TILE_INDIRECT( suprslam_state, suprslam_tile_callback )
342   MCFG_VSYSTEM_SPR_SET_GFXREGION(1)
341343
342344   MCFG_K053936_ADD("k053936", suprslam_k053936_intf)
343345
trunk/src/mame/drivers/aerofgt.c
r18605r18606
16541654   MCFG_PALETTE_LENGTH(1024)
16551655
16561656   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
1657   MCFG_VSYSTEM_SPR_SET_TILE_INDIRECT( aerofgt_state, aerofgt_tile_callback )
1658   MCFG_VSYSTEM_SPR_SET_GFXREGION(2)
16571659
1658   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,aerofgt)
1660   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,turbofrc)
16591661
16601662   /* sound hardware */
16611663   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
trunk/src/mame/drivers/taotaido.c
r18605r18606
355355   MCFG_PALETTE_LENGTH(0x800)
356356
357357   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
358   MCFG_VSYSTEM_SPR_SET_TILE_INDIRECT( taotaido_state, taotaido_tile_callback )
359   MCFG_VSYSTEM_SPR_SET_GFXREGION(0)
358360
359361   /* sound hardware */
360362   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
trunk/src/mame/drivers/crshrace.c
r18605r18606
482482   MCFG_PALETTE_LENGTH(2048)
483483
484484   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
485   MCFG_VSYSTEM_SPR_SET_TILE_INDIRECT( crshrace_state, crshrace_tile_callback )
486   MCFG_VSYSTEM_SPR_SET_GFXREGION(2)
485487
486488   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
487489   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram2")
trunk/src/mame/drivers/inufuku.c
r18605r18606
397397   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
398398   vsystem_spr_device::set_offsets(*device, 0,1); // reference videos confirm at least the +1 against tilemaps in 3on3dunk (the highscore header text and black box are meant to be 1 pixel misaligned, although there is currently a priority bug there too)
399399   vsystem_spr_device::set_pdraw(*device, true);
400   MCFG_VSYSTEM_SPR_SET_TILE_INDIRECT( inufuku_state, inufuku_tile_callback )
401   MCFG_VSYSTEM_SPR_SET_GFXREGION(2)
400402
401403   MCFG_GFXDECODE(inufuku)
402404   MCFG_PALETTE_LENGTH(4096)
trunk/src/mame/drivers/f1gp.c
r18605r18606
547547
548548   MCFG_DEVICE_REMOVE("vsystem_spr_old")
549549   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
550   MCFG_VSYSTEM_SPR_SET_TILE_INDIRECT( f1gp_state, f1gp2_tile_callback )
551   MCFG_VSYSTEM_SPR_SET_GFXREGION(1)
550552
551553   MCFG_DEVICE_REMOVE("k053936")
552554   MCFG_K053936_ADD("k053936", f1gp2_k053936_intf)
trunk/src/mame/drivers/gstriker.c
r18605r18606
561561   MCFG_PALETTE_LENGTH(0x800)
562562
563563   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
564   MCFG_VSYSTEM_SPR_SET_GFXREGION(2)
565   MCFG_VSYSTEM_SPR_SET_PALBASE(0x10)
566   MCFG_VSYSTEM_SPR_SET_PALMASK(0x1f)
567   MCFG_VSYSTEM_SPR_SET_TRANSPEN(0)
564568
565569   MCFG_VIDEO_START_OVERRIDE(gstriker_state,gstriker)
566570
r18605r18606
576580
577581static MACHINE_CONFIG_DERIVED( twrldc94, gstriker )
578582   MCFG_VIDEO_START_OVERRIDE(gstriker_state, twrldc94 )
583
584   MCFG_DEVICE_MODIFY("vsystem_spr")
585   MCFG_VSYSTEM_SPR_SET_PALBASE(0x60)
586
579587MACHINE_CONFIG_END
580588
581589
r18605r18606
601609   MCFG_PALETTE_LENGTH(0x2000)
602610
603611   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
612   MCFG_VSYSTEM_SPR_SET_GFXREGION(2)
613   MCFG_VSYSTEM_SPR_SET_PALBASE(0x00)
604614
605615   MCFG_VIDEO_START_OVERRIDE(gstriker_state,vgoalsoc)
606616
trunk/src/mame/includes/aerofgt.h
r18605r18606
9898   DECLARE_VIDEO_START(spinlbrk);
9999   DECLARE_VIDEO_START(turbofrc);
100100   DECLARE_VIDEO_START(wbbc97);
101   DECLARE_VIDEO_START(aerofgt);
102101   UINT32 screen_update_pspikes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
103102   UINT32 screen_update_spikes91(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
104103   UINT32 screen_update_pspikesb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
trunk/src/mame/video/gstriker.c
r18605r18606
340340   //  needs sprite orthogonality
341341   MB60553_draw(machine(), 0, bitmap,cliprect, 0);
342342
343   m_spr->CG10103_draw(machine(), 0, bitmap, cliprect, 0);
343   m_spr->draw_sprites(m_CG10103_vram, 0x2000, machine(), bitmap, cliprect, 0x2, 0x0);
344344
345345   VS920A_draw(this, 0, bitmap, cliprect, 0);
346346
347   m_spr->CG10103_draw(machine(), 0, bitmap, cliprect, 1);
347   m_spr->draw_sprites(m_CG10103_vram, 0x2000, machine(), bitmap, cliprect, 0x2, 0x2);
348348
349349#if 0
350350   popmessage("%04x %04x %04x %04x %04x %04x %04x %04x",
r18605r18606
378378   MB60553_set_gfx_region(this, 0, 1);
379379   MB60553_set_pal_base(this, 0, 0);
380380   MB60553_get_tilemap(this, 0)->set_transparent_pen(0xf);
381
382   // Initialize the sprite generator
383   m_spr->CG10103_set_ram(m_CG10103_vram);
384   m_spr->CG10103_set_gfx_region(2);
385   m_spr->CG10103_set_pal_base(0x10);
386   m_spr->CG10103_set_transpen(0x0);
387381}
388382
389383VIDEO_START_MEMBER(gstriker_state,twrldc94)
r18605r18606
402396   MB60553_set_gfx_region(this, 0, 1);
403397   MB60553_set_pal_base(this, 0, 0x50);
404398   MB60553_get_tilemap(this, 0)->set_transparent_pen(0xf);
405
406   // Initialize the sprite generator
407   m_spr->CG10103_set_ram(m_CG10103_vram);
408   m_spr->CG10103_set_gfx_region(2);
409   m_spr->CG10103_set_pal_base(0x60);
410   m_spr->CG10103_set_transpen(0x0);
411399}
412400
413401VIDEO_START_MEMBER(gstriker_state,vgoalsoc)
r18605r18606
426414   MB60553_set_gfx_region(this, 0, 1);
427415   MB60553_set_pal_base(this, 0, 0x20);
428416   MB60553_get_tilemap(this, 0)->set_transparent_pen(0xf);
429
430   // Initialize the sprite generator
431   m_spr->CG10103_set_ram(m_CG10103_vram);
432   m_spr->CG10103_set_gfx_region(2);
433   m_spr->CG10103_set_pal_base(0x00);
434   m_spr->CG10103_set_transpen(0xf);
435417}
trunk/src/mame/video/suprslam.c
r18605r18606
6262   m_screen_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(suprslam_state::get_suprslam_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
6363
6464   m_screen_tilemap->set_transparent_pen(15);
65
66   vsystem_spr_device::set_tile_indirect_callback(m_spr, vsystem_tile_indirection_delegate(FUNC(suprslam_state::suprslam_tile_callback), this)); // can this be moved to the MACHINE_CONFIG?
6765}
6866
6967UINT32 suprslam_state::screen_update_suprslam(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r18605r18606
7371   bitmap.fill(get_black_pen(machine()), cliprect);
7472   k053936_zoom_draw(m_k053936, bitmap, cliprect, m_bg_tilemap, 0, 0, 1);
7573   if(!(m_spr_ctrl[0] & 8))
76      m_spr->draw_sprites_suprslam(m_spriteram, m_spriteram.bytes(), machine(), bitmap, cliprect);
74      m_spr->draw_sprites(m_spriteram, m_spriteram.bytes(), machine(), bitmap, cliprect);
7775   m_screen_tilemap->draw(bitmap, cliprect, 0, 0);
7876   if(m_spr_ctrl[0] & 8)
79      m_spr->draw_sprites_suprslam(m_spriteram, m_spriteram.bytes(), machine(), bitmap, cliprect);
77      m_spr->draw_sprites(m_spriteram, m_spriteram.bytes(), machine(), bitmap, cliprect);
8078   return 0;
8179}
8280
trunk/src/mame/video/aerofgt.c
r18605r18606
166166}
167167
168168
169VIDEO_START_MEMBER(aerofgt_state,aerofgt)
170{
171   m_bg1_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(aerofgt_state::get_bg1_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
172   m_bg2_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(aerofgt_state::get_bg2_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
173169
174   m_bg2_tilemap->set_transparent_pen(15);
175170
176   m_spritepalettebank = 0;
177   m_sprite_gfx = 2;
178171
179   aerofgt_register_state_globals(machine());
180172
181   vsystem_spr_device::set_tile_indirect_callback(m_spr, vsystem_tile_indirection_delegate(FUNC(aerofgt_state::aerofgt_tile_callback), this)); // can this be moved to the MACHINE_CONFIG?
182}
183
184
185
186
187173/***************************************************************************
188174
189175  Memory handlers
r18605r18606
408394
409395   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
410396
411   m_spr->draw_sprites_aerofght(m_spriteram3, m_spriteram3.bytes(), machine(), bitmap, cliprect, 0);
412   m_spr->draw_sprites_aerofght(m_spriteram3, m_spriteram3.bytes(), machine(), bitmap, cliprect, 1);
397   m_spr->draw_sprites(m_spriteram3, m_spriteram3.bytes(), machine(), bitmap, cliprect, 0x03, 0x00);
398   m_spr->draw_sprites(m_spriteram3, m_spriteram3.bytes(), machine(), bitmap, cliprect, 0x03, 0x01);
413399
414400   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
415401
416   m_spr->draw_sprites_aerofght(m_spriteram3, m_spriteram3.bytes(), machine(), bitmap, cliprect, 2);
417   m_spr->draw_sprites_aerofght(m_spriteram3, m_spriteram3.bytes(), machine(), bitmap, cliprect, 3);
402   m_spr->draw_sprites(m_spriteram3, m_spriteram3.bytes(), machine(), bitmap, cliprect, 0x03, 0x02);
403   m_spr->draw_sprites(m_spriteram3, m_spriteram3.bytes(), machine(), bitmap, cliprect, 0x03, 0x03);
418404   return 0;
419405}
420406
trunk/src/mame/video/f1gp.c
r18605r18606
9090   m_fg_tilemap->set_scrolldx(-80, 0);
9191   m_fg_tilemap->set_scrolldy(-26, 0);
9292
93   vsystem_spr_device::set_tile_indirect_callback(m_spr, vsystem_tile_indirection_delegate(FUNC(f1gp_state::f1gp2_tile_callback), this)); // can this be moved to the MACHINE_CONFIG?
9493}
9594
9695
r18605r18606
210209      {
211210         case 0:
212211            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1);
213            m_spr->f1gp2_draw_sprites(m_spritelist, m_flipscreen, machine(), bitmap, cliprect);
212            m_spr->draw_sprites(m_spritelist, 0x2000, machine(), bitmap, cliprect);
214213            m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
215214            break;
216215         case 1:
217216            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1);
218217            m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
219            m_spr->f1gp2_draw_sprites(m_spritelist, m_flipscreen, machine(), bitmap, cliprect);
218            m_spr->draw_sprites(m_spritelist, 0x2000, machine(), bitmap, cliprect);
220219            break;
221220         case 2:
222221            m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
223222            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, 0, 0, 1);
224            m_spr->f1gp2_draw_sprites(m_spritelist, m_flipscreen, machine(), bitmap, cliprect);
223            m_spr->draw_sprites(m_spritelist, 0x2000, machine(), bitmap, cliprect);
225224            break;
226225#ifdef MAME_DEBUG
227226         case 3:
trunk/src/mame/video/vsystem_spr.c
r18605r18606
11// Video System Sprites
22// todo:
3//  unify these functions (secondary stage lookup differs between games, use callback)
3//  update drivers which call multiple priority passes to use the pdrawgfx version (aerofgt, gstriker)
44
55//  according to gstriker this is probably the Fujitsu CG10103
66
r18605r18606
7777   m_xoffs = 0;
7878   m_yoffs = 0;
7979   m_pdraw = false;
80   m_gfx_region = -1;
81   m_pal_mask = 0x3f;
8082
8183   m_newtilecb =  vsystem_tile_indirection_delegate(FUNC(vsystem_spr_device::tile_callback_noindirect), this);
8284}
r18605r18606
8890
8991
9092// static
91void vsystem_spr_device::set_tile_indirect_callback(device_t &device,vsystem_tile_indirection_delegate newtilecb)
93void vsystem_spr_device::set_tile_indirect_cb(device_t &device,vsystem_tile_indirection_delegate newtilecb)
9294{
9395   vsystem_spr_device &dev = downcast<vsystem_spr_device &>(device);
9496   dev.m_newtilecb = newtilecb;
r18605r18606
110112   dev.m_pdraw = pdraw;
111113}
112114
113void vsystem_spr_device::device_start()
115// static
116void vsystem_spr_device::CG10103_set_gfx_region(device_t &device, int gfx_region)
114117{
118   vsystem_spr_device &dev = downcast<vsystem_spr_device &>(device);
119   dev.m_gfx_region = gfx_region;
120}
115121
122// static
123void vsystem_spr_device::CG10103_set_pal_base(device_t &device, int pal_base)
124{
125   vsystem_spr_device &dev = downcast<vsystem_spr_device &>(device);
126   dev.m_pal_base = pal_base;
116127}
117128
129// static
130void vsystem_spr_device::set_pal_mask(device_t &device, int pal_mask)
131{
132   vsystem_spr_device &dev = downcast<vsystem_spr_device &>(device);
133   dev.m_pal_mask = pal_mask;
134}
135
136// static
137void vsystem_spr_device::CG10103_set_transpen(device_t &device, int transpen)
138{
139   vsystem_spr_device &dev = downcast<vsystem_spr_device &>(device);
140   dev.m_transpen = transpen;
141}
142
143
144void vsystem_spr_device::device_start()
145{
146   // bind our handler
147   m_newtilecb.bind_relative_to(*owner());
148}
149
118150void vsystem_spr_device::device_reset()
119151{
120152
r18605r18606
162194}
163195
164196
165void vsystem_spr_device::common_sprite_drawgfx(int gfxrgn, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
197void vsystem_spr_device::common_sprite_drawgfx( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
166198{
167   gfx_element *gfx = machine.gfx[gfxrgn];
199   gfx_element *gfx = machine.gfx[m_gfx_region];
168200   int priority_mask = 0x00;
169201
170202   curr_sprite.oy += m_yoffs;
r18605r18606
225257
226258
227259
228void vsystem_spr_device::draw_sprites_inufuku( UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
260void vsystem_spr_device::draw_sprites( UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int prihack_mask, int prihack_val )
229261{
230262   int offs;
231263   int end = 0;
232264
265   // find the end of the list
233266   for (offs = 0; offs < (spriteram_bytes / 16 ); offs++)
234267   {
235268      if (spriteram[offs] & 0x4000) break;
236269   }
237270   end = offs;
238271
239   for (offs = end - 1; offs >= 0; offs--)
272   // decide our drawing order (if we're using pdrawgfx we must go in reverse)
273   int first, last, inc;
274   if (m_pdraw)
240275   {
276      first = end - 1;
277      last = -1;
278      inc = -1;
279   }
280   else
281   {
282      first = 0;
283      last = end;
284      inc = 1;
285   }
286
287   // draw
288   offs = first;
289   while (offs != last)
290   {
241291      if ((spriteram[offs] & 0x8000) == 0x0000)
242292      {
243293         int attr_start;
r18605r18606
246296
247297         get_sprite_attributes(&spriteram[attr_start]);
248298
249         curr_sprite.map &= 0x7fff;
299         curr_sprite.color &= m_pal_mask;
250300
251         common_sprite_drawgfx(2, machine, bitmap, cliprect);
301         // hack for aero fighters and other which still call us multiple times with different priorities instead of using the pdrawgfx version
302         if (prihack_mask != -1)
303         {
304            if ((curr_sprite.pri & prihack_mask) == prihack_val)
305               common_sprite_drawgfx(machine, bitmap, cliprect);
306         }
307         else
308         {
309            common_sprite_drawgfx(machine, bitmap, cliprect);
310         }
252311      }
253   }
254}
255312
256
257void vsystem_spr_device::draw_sprites_suprslam( UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
258{
259   UINT16 *source = spriteram;
260   UINT16 *source2 = spriteram;
261   UINT16 *finish = source + 0x2000/2;
262
263   while (source < finish)
264   {
265      UINT32 sprnum = source[0] & 0x03ff;
266      if (source[0] == 0x4000) break;
267      sprnum *= 4;
268      source++;
269
270
271      get_sprite_attributes(&source2[sprnum]);
272
273      curr_sprite.map &= 0x7fff;               
274
275      common_sprite_drawgfx(1, machine, bitmap, cliprect);
313      offs+=inc;
276314   }
277315}
278316
279317
280318
281void vsystem_spr_device::draw_sprite_taotaido( UINT16* spriteram, int spriteram_bytes, running_machine &machine, UINT16 spriteno, bitmap_ind16 &bitmap, const rectangle &cliprect )
282{
283   UINT16 *source = &spriteram[spriteno*4];
284319
285   get_sprite_attributes(&source[0]);
286
287   curr_sprite.map &= 0xffff;
288   curr_sprite.color &= 0x1f;
289
290   common_sprite_drawgfx(0, machine, bitmap, cliprect);
291}
292
293void vsystem_spr_device::draw_sprites_taotaido( UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
294{
295   UINT16 *source = spriteram;
296   UINT16 *finish = spriteram + spriteram_bytes/2;
297
298   while( source<finish )
299   {
300      if (source[0] == 0x4000) break;
301
302      draw_sprite_taotaido(spriteram, spriteram_bytes, machine, source[0]&0x3ff, bitmap, cliprect);
303
304      source++;
305   }
306}
307
308
309
310void vsystem_spr_device::draw_sprites_crshrace(UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int flipscreen)
311{
312   int offs;
313
314   offs = 0;
315   while (offs < 0x0400 && (spriteram[offs] & 0x4000) == 0)
316   {
317      int attr_start;
318
319      attr_start = 4 * (spriteram[offs++] & 0x03ff);
320
321      get_sprite_attributes(&spriteram[attr_start]);
322
323      curr_sprite.color &= 0x1f;
324      curr_sprite.map &= 0x7fff;
325
326      common_sprite_drawgfx(2, machine, bitmap, cliprect);
327   }
328}
329
330
331
332void vsystem_spr_device::draw_sprites_aerofght( UINT16* spriteram3, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
333{
334   int offs;
335   pri <<= 12;
336
337   offs = 0;
338   while (offs < 0x0400 && (spriteram3[offs] & 0x8000) == 0)
339   {
340      int attr_start = 4 * (spriteram3[offs] & 0x03ff);
341
342      /* is the way I handle pri correct? Or should I just check bit 13? */
343      if ((spriteram3[attr_start + 2] & 0x3000) == pri)
344      {
345         get_sprite_attributes(&spriteram3[attr_start]);
346
347         curr_sprite.color &=0x1f;
348         curr_sprite.map &= 0x3fff;
349   
350         common_sprite_drawgfx(2, machine, bitmap, cliprect);
351
352      }
353      offs++;
354   }
355}
356
357
358void vsystem_spr_device::f1gp2_draw_sprites(UINT16* spritelist, int flipscreen, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
359{
360   int offs;
361
362   offs = 0;
363   while (offs < 0x0400 && (spritelist[offs] & 0x4000) == 0)
364   {
365      int attr_start;
366
367      attr_start = 4 * (spritelist[offs++] & 0x01ff);
368
369      get_sprite_attributes(&spritelist[attr_start]);
370
371      curr_sprite.color &= 0x1f;
372      curr_sprite.map &= 0x7fff;
373
374      common_sprite_drawgfx(1, machine, bitmap, cliprect);
375   }
376}
377
378
379void vsystem_spr_device::CG10103_draw_sprite(running_machine &machine, bitmap_ind16& bitmap, const rectangle &cliprect, UINT16* spr, int drawpri)
380{
381   get_sprite_attributes(&spr[0]);
382   curr_sprite.color &=0x1f;
383   curr_sprite.pri >>= 1;
384
385   // Check if we want to draw this sprite now
386   if (curr_sprite.pri != drawpri)
387      return;
388
389   common_sprite_drawgfx(m_gfx_region, machine, bitmap, cliprect);
390}
391
392
393void vsystem_spr_device::CG10103_draw(running_machine &machine, int numchip, bitmap_ind16& screen, const rectangle &cliprect, int pri)
394{
395   UINT16* splist;
396   int i;
397
398   splist = m_vram;
399
400   // Parse the sorting list
401   for (i=0;i<0x400;i++)
402   {
403      UINT16 cmd = *splist++;
404
405      // End of list
406      if (cmd & 0x4000)
407         break;
408
409      if (!(cmd & 0x8000))
410      {
411         // Extract sprite index
412         int num = cmd & 0x3FF;
413
414         // Draw the sprite
415         CG10103_draw_sprite(machine, screen, cliprect, m_vram + num*4, pri);
416      }
417   }
418}
419
420
421
422void vsystem_spr_device::CG10103_set_pal_base(int pal_base)
423{
424   m_pal_base = pal_base;
425}
426
427void vsystem_spr_device::CG10103_set_gfx_region(int gfx_region)
428{
429   m_gfx_region = gfx_region;
430}
431
432void vsystem_spr_device::CG10103_set_transpen(int transpen)
433{
434   m_transpen = transpen;
435}
436
437void vsystem_spr_device::CG10103_set_ram(UINT16* vram)
438{
439   m_vram = vram;
440}
trunk/src/mame/video/vsystem_spr.h
r18605r18606
11// Video System Sprites
22
33
4typedef delegate<UINT32 (UINT32)> vsystem_tile_indirection_delegate;
4typedef device_delegate<UINT32 (UINT32)> vsystem_tile_indirection_delegate;
55
6#define MCFG_VSYSTEM_SPR_SET_TILE_INDIRECT( _class, _method) \
7   vsystem_spr_device::set_tile_indirect_cb(*device, vsystem_tile_indirection_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0)); \
8
9#define MCFG_VSYSTEM_SPR_SET_GFXREGION( _rgn ) \
10   vsystem_spr_device::CG10103_set_gfx_region(*device, _rgn); \
11
12#define MCFG_VSYSTEM_SPR_SET_PALBASE( _palbase ) \
13   vsystem_spr_device::CG10103_set_pal_base(*device, _palbase); \
14
15#define MCFG_VSYSTEM_SPR_SET_PALMASK( _palmask ) \
16   vsystem_spr_device::set_pal_mask(*device, _palmask); \
17   
18#define MCFG_VSYSTEM_SPR_SET_TRANSPEN( _transpen ) \
19   vsystem_spr_device::CG10103_set_transpen(*device, _transpen); \
20
21
622/*** CG10103 **********************************************/
723
824class vsystem_spr_device : public device_t
r18605r18606
1228
1329   static void set_offsets(device_t &device, int xoffs, int yoffs);
1430   static void set_pdraw(device_t &device, bool pdraw);
15   static void set_tile_indirect_callback(device_t &device,vsystem_tile_indirection_delegate newtilecb);
31   static void set_tile_indirect_cb(device_t &device,vsystem_tile_indirection_delegate newtilecb);
32   static void CG10103_set_gfx_region(device_t &device, int gfx_region);
33   static void CG10103_set_pal_base(device_t &device, int pal_base);
34   static void set_pal_mask(device_t &device, int pal_mask);
35   static void CG10103_set_transpen(device_t &device, int transpen);
1636
1737   UINT32 tile_callback_noindirect(UINT32 tile);
1838   vsystem_tile_indirection_delegate m_newtilecb;
r18605r18606
2242
2343   UINT16* m_vram;
2444   UINT16 m_pal_base;
45   UINT16 m_pal_mask;
2546   UINT8 m_gfx_region;
2647   UINT8 m_transpen;
2748
r18605r18606
4162   } curr_sprite;
4263
4364   void get_sprite_attributes(UINT16* ram);
44   void common_sprite_drawgfx(int gfxrgn, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect);
65   void common_sprite_drawgfx(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect);
4566
46   void draw_sprites_inufuku(  UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect );
47   void draw_sprites_suprslam( UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect );
48   void draw_sprite_taotaido( UINT16* spriteram, int spriteram_bytes,  running_machine &machine, UINT16 spriteno, bitmap_ind16 &bitmap, const rectangle &cliprect );
49   void draw_sprites_taotaido( UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect );
50   void draw_sprites_crshrace( UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int flipscreen);
51   void draw_sprites_aerofght( UINT16* spriteram3, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
52   void f1gp2_draw_sprites(UINT16* spritelist, int flipscreen, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect );
67   void draw_sprites(  UINT16* spriteram, int spriteram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int prihack_mask = -1, int prihack_val = -1 );
5368
54   void CG10103_draw_sprite(running_machine &machine, bitmap_ind16& screen, const rectangle &cliprect, UINT16* spr, int drawpri);
55   void CG10103_draw(running_machine &machine, int numchip, bitmap_ind16& screen, const rectangle &cliprect, int priority);
56   void CG10103_set_pal_base(int pal_base);
57   void CG10103_set_gfx_region(int gfx_region);
58   void CG10103_set_transpen(int transpen);
59   void CG10103_set_ram(UINT16* vram);
6069
6170protected:
6271   virtual void device_start();
trunk/src/mame/video/taotaido.c
r18605r18606
105105   m_spriteram2_old = auto_alloc_array(machine(), UINT16, 0x10000/2);
106106   m_spriteram2_older = auto_alloc_array(machine(), UINT16, 0x10000/2);
107107
108   vsystem_spr_device::set_tile_indirect_callback(m_spr, vsystem_tile_indirection_delegate(FUNC(taotaido_state::taotaido_tile_callback), this)); // can this be moved to the MACHINE_CONFIG?
109108}
110109
111110
r18605r18606
131130      m_bg_tilemap->draw(bitmap, clip, 0,0);
132131   }
133132
134   m_spr->draw_sprites_taotaido(m_spriteram_older, m_spriteram.bytes(), machine(), bitmap,cliprect);
133   m_spr->draw_sprites(m_spriteram_older, m_spriteram.bytes(), machine(), bitmap,cliprect);
135134   return 0;
136135}
137136
trunk/src/mame/video/crshrace.c
r18605r18606
4646   m_tilemap1->set_transparent_pen(0x0f);
4747   m_tilemap2->set_transparent_pen(0xff);
4848
49   vsystem_spr_device::set_tile_indirect_callback(m_spr, vsystem_tile_indirection_delegate(FUNC(crshrace_state::crshrace_tile_callback), this)); // can this be moved to the MACHINE_CONFIG?
5049}
5150
5251
r18605r18606
131130   switch (m_gfxctrl & 0xfb)
132131   {
133132      case 0x00:   /* high score screen */
134         m_spr->draw_sprites_crshrace(m_spriteram->buffer(), 0x2000,  machine(), bitmap, cliprect, m_flipscreen);
133         m_spr->draw_sprites(m_spriteram->buffer(), 0x2000,  machine(), bitmap, cliprect);
135134         draw_bg(machine(), bitmap, cliprect);
136135         draw_fg(machine(), bitmap, cliprect);
137136         break;
r18605r18606
139138      case 0x02:
140139         draw_bg(machine(), bitmap, cliprect);
141140         draw_fg(machine(), bitmap, cliprect);
142         m_spr->draw_sprites_crshrace(m_spriteram->buffer(), 0x2000,  machine(), bitmap, cliprect, m_flipscreen);
141         m_spr->draw_sprites(m_spriteram->buffer(), 0x2000,  machine(), bitmap, cliprect);
143142         break;
144143      default:
145144         popmessage("gfxctrl = %02x", m_gfxctrl);
trunk/src/mame/video/inufuku.c
r18605r18606
126126
127127   m_spriteram1_old = auto_alloc_array_clear(machine(), UINT16, m_spriteram1.bytes()/2);
128128
129   vsystem_spr_device::set_tile_indirect_callback(m_spr, vsystem_tile_indirection_delegate(FUNC(inufuku_state::inufuku_tile_callback), this)); // can this be moved to the MACHINE_CONFIG?
130129}
131130
132131
r18605r18606
161160   m_tx_tilemap->set_scrolly(0, m_tx_scrolly);
162161   m_tx_tilemap->draw(bitmap, cliprect, 0, 4);
163162
164   m_spr->draw_sprites_inufuku( m_spriteram1_old, m_spriteram1.bytes(), machine(), bitmap, cliprect );
163   m_spr->draw_sprites( m_spriteram1_old, m_spriteram1.bytes(), machine(), bitmap, cliprect );
165164   return 0;
166165}
167166

Previous 199869 Revisions Next


© 1997-2024 The MAME Team