Previous 199869 Revisions Next

r18422 Wednesday 10th October, 2012 at 16:46:21 UTC by Tafoid
Continued cleanup of Video Systems drivers and associated dependencies.  From Haze (nw)
[src/mame]mame.mak
[src/mame/drivers]aerofgt.c f1gp.c pipedrm.c welltris.c
[src/mame/includes]aerofgt.h f1gp.h fromance.h welltris.h
[src/mame/video]aerofgt.c f1gp.c fromance.c vsystem_spr.c vsystem_spr.h vsystem_spr2.c* vsystem_spr2.h* welltris.c

trunk/src/mame/drivers/welltris.c
r18421r18422
724724   MCFG_GFXDECODE(welltris)
725725   MCFG_PALETTE_LENGTH(2048)
726726
727   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
727728
728729   /* sound hardware */
729730   MCFG_SPEAKER_STANDARD_MONO("mono")
trunk/src/mame/drivers/pipedrm.c
r18421r18422
658658   MCFG_GFXDECODE(pipedrm)
659659   MCFG_PALETTE_LENGTH(2048)
660660
661   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
662
661663   MCFG_VIDEO_START_OVERRIDE(fromance_state,pipedrm)
662664
663665   /* sound hardware */
trunk/src/mame/drivers/aerofgt.c
r18421r18422
13481348   MCFG_GFXDECODE(pspikes)
13491349   MCFG_PALETTE_LENGTH(2048)
13501350
1351   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
1352
13511353   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,pspikes)
13521354
13531355   /* sound hardware */
r18421r18422
14461448   MCFG_GFXDECODE(pspikes)
14471449   MCFG_PALETTE_LENGTH(2048)
14481450
1451   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
1452
14491453   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,pspikes)
14501454
14511455   /* sound hardware */
r18421r18422
14811485   MCFG_GFXDECODE(turbofrc)
14821486   MCFG_PALETTE_LENGTH(1024)
14831487
1488   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
1489
14841490   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,karatblz)
14851491
14861492   /* sound hardware */
r18421r18422
15201526   MCFG_GFXDECODE(turbofrc)
15211527   MCFG_PALETTE_LENGTH(1024)
15221528
1529   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
1530
15231531   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,spinlbrk)
15241532
15251533   /* sound hardware */
r18421r18422
15591567   MCFG_GFXDECODE(turbofrc)
15601568   MCFG_PALETTE_LENGTH(1024)
15611569
1570   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
1571
15621572   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,turbofrc)
15631573
15641574   /* sound hardware */
r18421r18422
15991609   MCFG_GFXDECODE(aerofgtb)
16001610   MCFG_PALETTE_LENGTH(1024)
16011611
1612   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
1613   
16021614   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,turbofrc)
16031615
16041616   /* sound hardware */
r18421r18422
16391651   MCFG_GFXDECODE(aerofgt)
16401652   MCFG_PALETTE_LENGTH(1024)
16411653
1654   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
1655
16421656   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,turbofrc)
16431657
16441658   /* sound hardware */
r18421r18422
17411755   MCFG_GFXDECODE(wbbc97)
17421756   MCFG_PALETTE_LENGTH(2048)
17431757
1758   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
1759
17441760   MCFG_VIDEO_START_OVERRIDE(aerofgt_state,wbbc97)
17451761
17461762   /* sound hardware */
r18421r18422
24952511GAME( 1990, spinlbrk, 0,        spinlbrk, spinlbrk, driver_device, 0, ROT0,   "V-System Co.",     "Spinal Breakers (World)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
24962512GAME( 1990, spinlbrku,spinlbrk, spinlbrk, spinlbrku, driver_device,0, ROT0,   "V-System Co.",     "Spinal Breakers (US)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
24972513GAME( 1990, spinlbrkj,spinlbrk, spinlbrk, spinlbrk, driver_device, 0, ROT0,   "V-System Co.",     "Spinal Breakers (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2514
24982515GAME( 1991, pspikes,  0,        pspikes,  pspikes, driver_device,  0, ROT0,   "Video System Co.", "Power Spikes (World)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
24992516GAME( 1991, pspikesk, pspikes,  pspikes,  pspikes, driver_device,  0, ROT0,   "Video System Co.", "Power Spikes (Korea)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
25002517GAME( 1991, svolly91, pspikes,  pspikes,  pspikes, driver_device,  0, ROT0,   "Video System Co.", "Super Volley '91 (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
r18421r18422
25022519GAME( 1991, spikes91, pspikes,  spikes91, pspikes, driver_device,  0, ROT0,   "bootleg",          "1991 Spikes (Italian bootleg)", GAME_SUPPORTS_SAVE | GAME_NO_SOUND | GAME_NO_COCKTAIL )
25032520GAME( 1991, spikes91a,pspikes,  spikes91, pspikes, driver_device,  0, ROT0,   "bootleg",          "1991 Spikes (Italian bootleg, set 2)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING | GAME_NO_SOUND | GAME_NO_COCKTAIL )
25042521GAME( 1991, pspikesc, pspikes,  pspikesc, pspikesc, driver_device, 0, ROT0,   "bootleg",          "Power Spikes (China)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
2522GAME( 1997, wbbc97,   0,        wbbc97,   wbbc97, driver_device,   0, ROT0,   "Comad",            "Beach Festival World Championship 1997", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) // based on power spikes codebase
2523
25052524GAME( 1991, karatblz, 0,        karatblz, karatblz, driver_device, 0, ROT0,   "Video System Co.", "Karate Blazers (World)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
25062525GAME( 1991, karatblzu,karatblz, karatblz, karatblz, driver_device, 0, ROT0,   "Video System Co.", "Karate Blazers (US)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
25072526GAME( 1991, karatblzj,karatblz, karatblz, karatblz, driver_device, 0, ROT0,   "Video System Co.", "Karate Blazers (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2527
25082528GAME( 1991, turbofrc, 0,        turbofrc, turbofrc, driver_device, 0, ROT270, "Video System Co.", "Turbo Force (old revision)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
25092529// there's also an undumped Turbo Force (new revision). Most notable thing in there is the points value of the rocks in level 6 (5.000 versus 500).
2510GAME( 1992, aerofgt,  0,        aerofgt,  aerofgt, driver_device,  0, ROT270, "Video System Co.", "Aero Fighters", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2511GAME( 1992, aerofgtb, aerofgt,  aerofgtb, aerofgtb, driver_device, 0, ROT270, "Video System Co.", "Aero Fighters (Turbo Force hardware set 1)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2512GAME( 1992, aerofgtc, aerofgt,  aerofgtb, aerofgtb, driver_device, 0, ROT270, "Video System Co.", "Aero Fighters (Turbo Force hardware set 2)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2530
2531// the tiles on these also contain an alt title 'The Final War' for both the title screen and attract logo was it ever used?
2532GAME( 1992, aerofgt,  0,        aerofgt,  aerofgt, driver_device,  0, ROT270, "Video System Co.", "Aero Fighters (World / USA + Canada / Korea / Hong Kong / Taiwan) (newer hardware)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) // this has the newer sprite chip etc. unlike all other games in this driver..
2533GAME( 1992, aerofgtb, aerofgt,  aerofgtb, aerofgtb, driver_device, 0, ROT270, "Video System Co.", "Aero Fighters (Taiwan / Japan, set 1)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL ) // probably intended for Taiwan because the Japanese name is Sonic Wings (below)
2534GAME( 1992, aerofgtc, aerofgt,  aerofgtb, aerofgtb, driver_device, 0, ROT270, "Video System Co.", "Aero Fighters (Taiwan / Japan, set 2)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
25132535GAME( 1992, sonicwi,  aerofgt,  aerofgtb, aerofgtb, driver_device, 0, ROT270, "Video System Co.", "Sonic Wings (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
25142536GAME( 1992, aerfboot, aerofgt,  aerfboot, aerofgtb, driver_device, 0, ROT270, "bootleg",          "Aero Fighters (bootleg set 1)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
25152537GAME( 1992, aerfboo2, aerofgt,  aerfboo2, aerofgtb, driver_device, 0, ROT270, "bootleg",          "Aero Fighters (bootleg set 2)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
2516GAME( 1997, wbbc97,   0,        wbbc97,   wbbc97, driver_device,   0, ROT0,   "Comad",            "Beach Festival World Championship 1997", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2538
trunk/src/mame/drivers/f1gp.c
r18421r18422
476476   MCFG_GFXDECODE(f1gp)
477477   MCFG_PALETTE_LENGTH(2048)
478478
479   MCFG_DEVICE_ADD("vsystem_spr_old", VSYSTEM_SPR2, 0)
480
479481   MCFG_VIDEO_START_OVERRIDE(f1gp_state,f1gp)
480482
481483   MCFG_K053936_ADD("k053936", f1gp_k053936_intf)
r18421r18422
542544   MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1)
543545   MCFG_SCREEN_UPDATE_DRIVER(f1gp_state, screen_update_f1gp2)
544546
547   MCFG_DEVICE_REMOVE("vsystem_spr_old")
548   MCFG_DEVICE_ADD("vsystem_spr", VSYSTEM_SPR, 0)
549
545550   MCFG_DEVICE_REMOVE("k053936")
546551   MCFG_K053936_ADD("k053936", f1gp2_k053936_intf)
547552
trunk/src/mame/video/f1gp.c
r18421r18422
163163
164164***************************************************************************/
165165
166static void f1gp_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int primask )
167{
168   f1gp_state *state = machine.driver_data<f1gp_state>();
169   int attr_start, first;
170   UINT16 *spram = chip ? state->m_spr2vram : state->m_spr1vram;
171166
172   first = 4 * spram[0x1fe];
173
174   for (attr_start = 0x0200 - 8; attr_start >= first; attr_start -= 4)
175   {
176      int map_start;
177      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color/*, pri*/;
178      /* table hand made by looking at the ship explosion in attract mode */
179      /* it's almost a logarithmic scale but not exactly */
180      static const int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
181
182      if (!(spram[attr_start + 2] & 0x0080)) continue;
183
184      ox = spram[attr_start + 1] & 0x01ff;
185      xsize = (spram[attr_start + 2] & 0x0700) >> 8;
186      zoomx = (spram[attr_start + 1] & 0xf000) >> 12;
187      oy = spram[attr_start + 0] & 0x01ff;
188      ysize = (spram[attr_start + 2] & 0x7000) >> 12;
189      zoomy = (spram[attr_start + 0] & 0xf000) >> 12;
190      flipx = spram[attr_start + 2] & 0x0800;
191      flipy = spram[attr_start + 2] & 0x8000;
192      color = (spram[attr_start + 2] & 0x000f);// + 16 * spritepalettebank;
193      //pri = spram[attr_start + 2] & 0x0010;
194      map_start = spram[attr_start + 3];
195
196      zoomx = 16 - zoomtable[zoomx] / 8;
197      zoomy = 16 - zoomtable[zoomy] / 8;
198
199      for (y = 0; y <= ysize; y++)
200      {
201         int sx, sy;
202
203         if (flipy) sy = ((oy + zoomy * (ysize - y) + 16) & 0x1ff) - 16;
204         else sy = ((oy + zoomy * y + 16) & 0x1ff) - 16;
205
206         for (x = 0; x <= xsize; x++)
207         {
208            int code;
209
210            if (flipx) sx = ((ox + zoomx * (xsize - x) + 16) & 0x1ff) - 16;
211            else sx = ((ox + zoomx * x + 16) & 0x1ff) - 16;
212
213            if (chip == 0)
214               code = state->m_spr1cgram[map_start % (state->m_spr1cgram.bytes() / 2)];
215            else
216               code = state->m_spr2cgram[map_start % (state->m_spr2cgram.bytes() / 2)];
217
218            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1 + chip],
219                  code,
220                  color,
221                  flipx,flipy,
222                  sx,sy,
223                  0x1000 * zoomx,0x1000 * zoomy,
224                  machine.priority_bitmap,
225//                      pri ? 0 : 0x2);
226                  primask,15);
227            map_start++;
228         }
229
230         if (xsize == 2) map_start += 1;
231         if (xsize == 4) map_start += 3;
232         if (xsize == 5) map_start += 2;
233         if (xsize == 6) map_start += 1;
234      }
235   }
236}
237
238
239167UINT32 f1gp_state::screen_update_f1gp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
240168{
241169
r18421r18422
248176   /* quick kludge for "continue" screen priority */
249177   if (m_gfxctrl == 0x00)
250178   {
251      f1gp_draw_sprites(machine(), bitmap, cliprect, 0, 0x02);
252      f1gp_draw_sprites(machine(), bitmap, cliprect, 1, 0x02);
179      m_spr_old->f1gp_draw_sprites(m_spr1vram, m_spr2vram, m_spr1cgram,m_spr1cgram.bytes(), m_spr2cgram, m_spr2cgram.bytes(), machine(), bitmap, cliprect, 0, 0x02);
180      m_spr_old->f1gp_draw_sprites(m_spr1vram, m_spr2vram, m_spr1cgram,m_spr1cgram.bytes(), m_spr2cgram, m_spr2cgram.bytes(), machine(), bitmap, cliprect, 1, 0x02);
253181   }
254182   else
255183   {
256      f1gp_draw_sprites(machine(), bitmap, cliprect, 0, 0x00);
257      f1gp_draw_sprites(machine(), bitmap, cliprect, 1, 0x02);
184      m_spr_old->f1gp_draw_sprites(m_spr1vram, m_spr2vram, m_spr1cgram,m_spr1cgram.bytes(), m_spr2cgram, m_spr2cgram.bytes(), machine(), bitmap, cliprect, 0, 0x00);
185      m_spr_old->f1gp_draw_sprites(m_spr1vram, m_spr2vram, m_spr1cgram,m_spr1cgram.bytes(), m_spr2cgram, m_spr2cgram.bytes(), machine(), bitmap, cliprect, 1, 0x02);
258186   }
259187   return 0;
260188}
261189
262190
191UINT32 f1gp_state::screen_update_f1gp2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
192{
193
194   if (m_gfxctrl & 4)   /* blank screen */
195      bitmap.fill(get_black_pen(machine()), cliprect);
196   else
197   {
198      switch (m_gfxctrl & 3)
199      {
200         case 0:
201            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1);
202            m_spr->f1gp2_draw_sprites(m_spritelist, m_sprcgram, m_flipscreen, machine(), bitmap, cliprect);
203            m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
204            break;
205         case 1:
206            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1);
207            m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
208            m_spr->f1gp2_draw_sprites(m_spritelist, m_sprcgram, m_flipscreen, machine(), bitmap, cliprect);
209            break;
210         case 2:
211            m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
212            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, 0, 0, 1);
213            m_spr->f1gp2_draw_sprites(m_spritelist, m_sprcgram, m_flipscreen, machine(), bitmap, cliprect);
214            break;
215#ifdef MAME_DEBUG
216         case 3:
217            popmessage("unsupported priority 3\n");
218#endif
219      }
220   }
221   return 0;
222}
223
224/***************************************************************************
225
226  BOOTLEG SUPPORT
227
228***************************************************************************/
229
230// BOOTLEG
263231static void f1gpb_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect )
264232{
265233   f1gp_state *state = machine.driver_data<f1gp_state>();
r18421r18422
328296   }
329297}
330298
299// BOOTLEG
331300UINT32 f1gp_state::screen_update_f1gpb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
332301{
333302   UINT32 startx, starty;
r18421r18422
355324   return 0;
356325}
357326
358
359static void f1gp2_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
360{
361   f1gp_state *state = machine.driver_data<f1gp_state>();
362   int offs;
363
364   offs = 0;
365   while (offs < 0x0400 && (state->m_spritelist[offs] & 0x4000) == 0)
366   {
367      int attr_start;
368      int map_start;
369      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color;
370
371      attr_start = 4 * (state->m_spritelist[offs++] & 0x01ff);
372
373      ox = state->m_spritelist[attr_start + 1] & 0x01ff;
374      xsize = (state->m_spritelist[attr_start + 1] & 0x0e00) >> 9;
375      zoomx = (state->m_spritelist[attr_start + 1] & 0xf000) >> 12;
376      oy = state->m_spritelist[attr_start + 0] & 0x01ff;
377      ysize = (state->m_spritelist[attr_start + 0] & 0x0e00) >> 9;
378      zoomy = (state->m_spritelist[attr_start + 0] & 0xf000) >> 12;
379      flipx = state->m_spritelist[attr_start + 2] & 0x4000;
380      flipy = state->m_spritelist[attr_start + 2] & 0x8000;
381      color = (state->m_spritelist[attr_start + 2] & 0x1f00) >> 8;
382      map_start = state->m_spritelist[attr_start + 3] & 0x7fff;
383
384// aerofgt has the following adjustment, but doing it here would break the title screen
385//      ox += (xsize*zoomx+2)/4;
386//      oy += (ysize*zoomy+2)/4;
387
388      zoomx = 32 - zoomx;
389      zoomy = 32 - zoomy;
390
391      if (state->m_spritelist[attr_start + 2] & 0x20ff)
392         color = machine.rand();
393
394      for (y = 0; y <= ysize; y++)
395      {
396         int sx,sy;
397
398         if (flipy) sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
399         else sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
400
401         for (x = 0; x <= xsize; x++)
402         {
403            int code;
404
405            if (flipx) sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
406            else sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
407
408            code = state->m_sprcgram[map_start & 0x3fff];
409            map_start++;
410
411            if (state->m_flipscreen)
412               drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1],
413                     code,
414                     color,
415                     !flipx,!flipy,
416                     304-sx,208-sy,
417                     zoomx << 11,zoomy << 11,15);
418            else
419               drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1],
420                     code,
421                     color,
422                     flipx,flipy,
423                     sx,sy,
424                     zoomx << 11,zoomy << 11,15);
425         }
426      }
427   }
428}
429
430
431UINT32 f1gp_state::screen_update_f1gp2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
432{
433
434   if (m_gfxctrl & 4)   /* blank screen */
435      bitmap.fill(get_black_pen(machine()), cliprect);
436   else
437   {
438      switch (m_gfxctrl & 3)
439      {
440         case 0:
441            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1);
442            f1gp2_draw_sprites(machine(), bitmap, cliprect);
443            m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
444            break;
445         case 1:
446            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1);
447            m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
448            f1gp2_draw_sprites(machine(), bitmap, cliprect);
449            break;
450         case 2:
451            m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
452            k053936_zoom_draw(m_k053936, bitmap, cliprect, m_roz_tilemap, 0, 0, 1);
453            f1gp2_draw_sprites(machine(), bitmap, cliprect);
454            break;
455#ifdef MAME_DEBUG
456         case 3:
457            popmessage("unsupported priority 3\n");
458#endif
459      }
460   }
461   return 0;
462}
trunk/src/mame/video/vsystem_spr.c
r18421r18422
11// Video System Sprites
22// todo:
3//  move various vsystem sprite functions here
4//  unify common ones + convert to device  (secondary stage tile lookup differs between games, use callback)
3//  unify these functions (secondary stage tile lookup differs between games, use callback)
54
65//  according to gstriker this is probably the Fujitsu CG10103
76
7// Aero Fighters (newer hardware)
8// Quiz & Variety Sukusuku Inufuku
9// 3 On 3 Dunk Madness
10// Super Slams
11// Formula 1 Grand Prix 2
12// (Lethal) Crash Race
13// Grand Striker
14// V Goal Soccer
15// Tecmo World Cup '94
16// Tao Taido
17
818#include "emu.h"
919#include "vsystem_spr.h"
1020
r18421r18422
401411
402412
403413
414void vsystem_spr_device::draw_sprites_aerofght( UINT16* spriteram3, int spriteram_bytes, UINT16* spriteram1, UINT16* spriteram2, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
415{
416   int offs;
417   priority <<= 12;
418
419   offs = 0;
420   while (offs < 0x0400 && (spriteram3[offs] & 0x8000) == 0)
421   {
422      int attr_start = 4 * (spriteram3[offs] & 0x03ff);
423
424      /* is the way I handle priority correct? Or should I just check bit 13? */
425      if ((spriteram3[attr_start + 2] & 0x3000) == priority)
426      {
427         int map_start;
428         int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color;
429
430         ox = spriteram3[attr_start + 1] & 0x01ff;
431         xsize = (spriteram3[attr_start + 1] & 0x0e00) >> 9;
432         zoomx = (spriteram3[attr_start + 1] & 0xf000) >> 12;
433         oy = spriteram3[attr_start + 0] & 0x01ff;
434         ysize = (spriteram3[attr_start + 0] & 0x0e00) >> 9;
435         zoomy = (spriteram3[attr_start + 0] & 0xf000) >> 12;
436         flipx = spriteram3[attr_start + 2] & 0x4000;
437         flipy = spriteram3[attr_start + 2] & 0x8000;
438         color = (spriteram3[attr_start + 2] & 0x0f00) >> 8;
439         map_start = spriteram3[attr_start + 3] & 0x3fff;
440
441         ox += (xsize * zoomx + 2) / 4;
442         oy += (ysize * zoomy + 2) / 4;
443
444         zoomx = 32 - zoomx;
445         zoomy = 32 - zoomy;
446
447         for (y = 0; y <= ysize; y++)
448         {
449            int sx, sy;
450
451            if (flipy)
452               sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
453            else
454               sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
455
456            for (x = 0; x <= xsize; x++)
457            {
458               int code;
459
460               if (flipx)
461                  sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
462               else
463                  sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
464
465               if (map_start < 0x2000)
466                  code = spriteram1[map_start & 0x1fff] & 0x1fff;
467               else
468                  code = spriteram2[map_start & 0x1fff] & 0x1fff;
469
470               drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[2 + (map_start >= 0x2000 ? 1 : 0)],
471                     code,
472                     color,
473                     flipx,flipy,
474                     sx,sy,
475                     zoomx << 11, zoomy << 11,15);
476               map_start++;
477            }
478         }
479      }
480      offs++;
481   }
482}
483
484
485void vsystem_spr_device::f1gp2_draw_sprites(UINT16* spritelist, UINT16* sprcgram, int flipscreen, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
486{
487   int offs;
488
489   offs = 0;
490   while (offs < 0x0400 && (spritelist[offs] & 0x4000) == 0)
491   {
492      int attr_start;
493      int map_start;
494      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color;
495
496      attr_start = 4 * (spritelist[offs++] & 0x01ff);
497
498      ox = spritelist[attr_start + 1] & 0x01ff;
499      xsize = (spritelist[attr_start + 1] & 0x0e00) >> 9;
500      zoomx = (spritelist[attr_start + 1] & 0xf000) >> 12;
501      oy = spritelist[attr_start + 0] & 0x01ff;
502      ysize = (spritelist[attr_start + 0] & 0x0e00) >> 9;
503      zoomy = (spritelist[attr_start + 0] & 0xf000) >> 12;
504      flipx = spritelist[attr_start + 2] & 0x4000;
505      flipy = spritelist[attr_start + 2] & 0x8000;
506      color = (spritelist[attr_start + 2] & 0x1f00) >> 8;
507      map_start = spritelist[attr_start + 3] & 0x7fff;
508
509// aerofgt has the following adjustment, but doing it here would break the title screen
510//      ox += (xsize*zoomx+2)/4;
511//      oy += (ysize*zoomy+2)/4;
512
513      zoomx = 32 - zoomx;
514      zoomy = 32 - zoomy;
515
516      if (spritelist[attr_start + 2] & 0x20ff)
517         color = machine.rand();
518
519      for (y = 0; y <= ysize; y++)
520      {
521         int sx,sy;
522
523         if (flipy) sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
524         else sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
525
526         for (x = 0; x <= xsize; x++)
527         {
528            int code;
529
530            if (flipx) sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
531            else sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
532
533            code = sprcgram[map_start & 0x3fff];
534            map_start++;
535
536            if (flipscreen)
537               drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1],
538                     code,
539                     color,
540                     !flipx,!flipy,
541                     304-sx,208-sy,
542                     zoomx << 11,zoomy << 11,15);
543            else
544               drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1],
545                     code,
546                     color,
547                     flipx,flipy,
548                     sx,sy,
549                     zoomx << 11,zoomy << 11,15);
550         }
551      }
552   }
553}
554
555
404556/*** Fujitsu CG10103 **********************************************/
405557
406558/*
trunk/src/mame/video/vsystem_spr.h
r18421r18422
2525   void draw_sprites_suprslam( UINT16* spriteram, int spriteram_bytes, UINT16* spriteram2, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect );
2626   void draw_sprites_taotaido( UINT16* spriteram, int spriteram_bytes, UINT16* spriteram2, UINT16* spriteram3, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect );
2727   void draw_sprites_crshrace( UINT16* spriteram, int spriteram_bytes, UINT16* spriteram2, running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int flipscreen);
28   void draw_sprites_aerofght( UINT16* spriteram3, int spriteram_bytes, UINT16* spriteram1, UINT16* spriteram2, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
29   void f1gp2_draw_sprites(UINT16* spritelist, UINT16* sprcgram, int flipscreen, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect );
2830
2931   void CG10103_draw_sprite(running_machine &machine, bitmap_ind16& screen, const rectangle &cliprect, UINT16* spr, int drawpri);
3032   void CG10103_draw(running_machine &machine, int numchip, bitmap_ind16& screen, const rectangle &cliprect, int priority);
trunk/src/mame/video/vsystem_spr2.c
r0r18422
1// Video System Sprites (type 2)
2// todo:
3//  move various vsystem sprite functions here
4//  unify common ones + convert to device
5
6//  this is probably the VS 8904/8905 combo
7
8// Spinal Breakers
9// Power Spikes
10// Karate Blazers
11// Turbo Force
12// Aero Fighters (older hardware types)
13// World Beach Championships 97 (modern Power Spikes bootleg, not original hw)
14// Welltris
15// Formula 1 Grand Prix (1)
16// Pipe Dream
17
18
19#include "emu.h"
20#include "vsystem_spr2.h"
21
22
23const device_type VSYSTEM_SPR2 = &device_creator<vsystem_spr2_device>;
24
25vsystem_spr2_device::vsystem_spr2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
26   : device_t(mconfig, VSYSTEM_SPR2, "vsystem_spr2_device", tag, owner, clock)
27{
28}
29
30
31
32void vsystem_spr2_device::device_start()
33{
34
35}
36
37void vsystem_spr2_device::device_reset()
38{
39
40}
41
42
43
44
45template<class _BitmapClass>
46void vsystem_spr2_device::turbofrc_draw_sprites_common( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, _BitmapClass &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
47{
48   int attr_start, base, first;
49   base = chip * 0x0200;
50   first = 4 * spriteram3[0x1fe + base];
51
52   for (attr_start = base + 0x0200 - 8; attr_start >= first + base; attr_start -= 4)
53   {
54      int map_start;
55      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color, pri;
56// some other drivers still use this wrong table, they have to be upgraded
57//      int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
58
59      if (!(spriteram3[attr_start + 2] & 0x0080))
60         continue;
61
62      pri = spriteram3[attr_start + 2] & 0x0010;
63
64      if ( chip_disabled_pri & !pri)
65         continue;
66
67      if ((!chip_disabled_pri) & (pri >> 4))
68         continue;
69
70      ox = spriteram3[attr_start + 1] & 0x01ff;
71      xsize = (spriteram3[attr_start + 2] & 0x0700) >> 8;
72      zoomx = (spriteram3[attr_start + 1] & 0xf000) >> 12;
73      oy = spriteram3[attr_start + 0] & 0x01ff;
74      ysize = (spriteram3[attr_start + 2] & 0x7000) >> 12;
75      zoomy = (spriteram3[attr_start + 0] & 0xf000) >> 12;
76      flipx = spriteram3[attr_start + 2] & 0x0800;
77      flipy = spriteram3[attr_start + 2] & 0x8000;
78      color = (spriteram3[attr_start + 2] & 0x000f) + 16 * spritepalettebank;
79
80      map_start = spriteram3[attr_start + 3];
81
82// aerofgt has this adjustment, but doing it here would break turbo force title screen
83//      ox += (xsize*zoomx+2)/4;
84//      oy += (ysize*zoomy+2)/4;
85
86      zoomx = 32 - zoomx;
87      zoomy = 32 - zoomy;
88
89      for (y = 0; y <= ysize; y++)
90      {
91         int sx, sy;
92
93         if (flipy)
94            sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
95         else
96            sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
97
98         for (x = 0; x <= xsize; x++)
99         {
100            int code;
101
102            if (flipx)
103               sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
104            else
105               sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
106
107            if (chip == 0)
108               code = spriteram1[map_start % (spriteram1_bytes/2)];
109            else
110               code = spriteram2[map_start % (spriteram2_bytes/2)];
111
112            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[sprite_gfx + chip],
113                      code,
114                      color,
115                      flipx,flipy,
116                      sx,sy,
117                      zoomx << 11, zoomy << 11,
118                      machine.priority_bitmap,pri ? 0 : 2,15);
119            map_start++;
120         }
121
122         if (xsize == 2) map_start += 1;
123         if (xsize == 4) map_start += 3;
124         if (xsize == 5) map_start += 2;
125         if (xsize == 6) map_start += 1;
126      }
127   }
128}
129
130void vsystem_spr2_device::turbofrc_draw_sprites( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
131{ turbofrc_draw_sprites_common( spriteram3, spriteram3_bytes, spriteram1, spriteram1_bytes, spriteram2, spriteram2_bytes, sprite_gfx, spritepalettebank, machine, bitmap, cliprect, chip, chip_disabled_pri ); }
132
133void vsystem_spr2_device::turbofrc_draw_sprites( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
134{ turbofrc_draw_sprites_common( spriteram3, spriteram3_bytes, spriteram1, spriteram1_bytes, spriteram2, spriteram2_bytes, sprite_gfx, spritepalettebank, machine, bitmap, cliprect, chip, chip_disabled_pri ); }
135
136
137template<class _BitmapClass>
138void vsystem_spr2_device::spinlbrk_draw_sprites_common( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, _BitmapClass &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
139{
140   int attr_start, base, first;
141   base = chip * 0x0200;
142   first = 4 * spriteram3[0x1fe + base];
143
144   for (attr_start = base + 0x0200-8; attr_start >= first + base; attr_start -= 4)
145   {
146      int map_start;
147      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color, pri;
148// some other drivers still use this wrong table, they have to be upgraded
149//      int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
150
151      if (!(spriteram3[attr_start + 2] & 0x0080))
152         continue;
153
154      pri = spriteram3[attr_start + 2] & 0x0010;
155
156      if ( chip_disabled_pri & !pri)
157         continue;
158      if ((!chip_disabled_pri) & (pri >> 4))
159         continue;
160
161      ox = spriteram3[attr_start + 1] & 0x01ff;
162      xsize = (spriteram3[attr_start + 2] & 0x0700) >> 8;
163      zoomx = (spriteram3[attr_start + 1] & 0xf000) >> 12;
164      oy = spriteram3[attr_start + 0] & 0x01ff;
165      ysize = (spriteram3[attr_start + 2] & 0x7000) >> 12;
166      zoomy = (spriteram3[attr_start + 0] & 0xf000) >> 12;
167      flipx = spriteram3[attr_start + 2] & 0x0800;
168      flipy = spriteram3[attr_start + 2] & 0x8000;
169      color = (spriteram3[attr_start + 2] & 0x000f) + 16 * spritepalettebank;
170
171      map_start = spriteram3[attr_start + 3];
172
173// aerofgt has this adjustment, but doing it here would break turbo force title screen
174//      ox += (xsize*zoomx+2)/4;
175//      oy += (ysize*zoomy+2)/4;
176
177      zoomx = 32 - zoomx;
178      zoomy = 32 - zoomy;
179
180      for (y = 0; y <= ysize; y++)
181      {
182         int sx, sy;
183
184         if (flipy)
185            sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
186         else
187            sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
188
189         for (x = 0; x <= xsize; x++)
190         {
191            int code;
192
193            if (flipx)
194               sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
195            else
196               sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
197
198            if (chip == 0)
199               code = spriteram1[map_start % (spriteram1_bytes/2)];
200            else
201               code = spriteram2[map_start % (spriteram2_bytes/2)];
202
203            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[sprite_gfx + chip],
204                      code,
205                      color,
206                      flipx,flipy,
207                      sx,sy,
208                      zoomx << 11, zoomy << 11,
209                      machine.priority_bitmap,pri ? 2 : 0,15);
210            map_start++;
211         }
212
213         if (xsize == 2) map_start += 1;
214         if (xsize == 4) map_start += 3;
215         if (xsize == 5) map_start += 2;
216         if (xsize == 6) map_start += 1;
217      }
218   }
219}
220
221void vsystem_spr2_device::spinlbrk_draw_sprites( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
222{ spinlbrk_draw_sprites_common( spriteram3, spriteram3_bytes, spriteram1, spriteram1_bytes, spriteram2, spriteram2_bytes, sprite_gfx, spritepalettebank, machine, bitmap, cliprect, chip, chip_disabled_pri ); }
223
224void vsystem_spr2_device::spinlbrk_draw_sprites( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
225{ spinlbrk_draw_sprites_common( spriteram3, spriteram3_bytes, spriteram1, spriteram1_bytes, spriteram2, spriteram2_bytes, sprite_gfx, spritepalettebank, machine, bitmap, cliprect, chip, chip_disabled_pri ); }
226
227
228
229// like above but no secondary indirection?
230void vsystem_spr2_device::welltris_draw_sprites( UINT16* spriteram, int spritepalettebank, running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
231{
232   static const UINT8 zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
233   int offs;
234   const rectangle &visarea = machine.primary_screen->visible_area();
235
236   /* draw the sprites */
237   for (offs = 0; offs < 0x200 - 4; offs += 4) {
238      int data0 = spriteram[offs + 0];
239      int data1 = spriteram[offs + 1];
240      int data2 = spriteram[offs + 2];
241      int data3 = spriteram[offs + 3];
242      int code = data3 & 0x1fff;
243      int color = (data2 & 0x0f) + (0x10 * spritepalettebank);
244      int y = (data0 & 0x1ff) + 1;
245      int x = (data1 & 0x1ff) + 6;
246      int yzoom = (data0 >> 12) & 15;
247      int xzoom = (data1 >> 12) & 15;
248      int zoomed = (xzoom | yzoom);
249      int ytiles = ((data2 >> 12) & 7) + 1;
250      int xtiles = ((data2 >>  8) & 7) + 1;
251      int yflip = (data2 >> 15) & 1;
252      int xflip = (data2 >> 11) & 1;
253      int xt, yt;
254
255      if (!(spriteram[offs + 2] & 0x0080)) continue;
256
257      /* compute the zoom factor -- stolen from aerofgt.c */
258      xzoom = 16 - zoomtable[xzoom] / 8;
259      yzoom = 16 - zoomtable[yzoom] / 8;
260
261      /* wrap around */
262      if (x > visarea.max_x) x -= 0x200;
263      if (y > visarea.max_y) y -= 0x200;
264
265      /* normal case */
266      if (!xflip && !yflip) {
267         for (yt = 0; yt < ytiles; yt++) {
268            for (xt = 0; xt < xtiles; xt++, code++) {
269               if (!zoomed)
270                  drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, 0, 0,
271                        x + xt * 16, y + yt * 16, 15);
272               else
273                  drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[1], code, color, 0, 0,
274                        x + xt * xzoom, y + yt * yzoom,
275                        0x1000 * xzoom, 0x1000 * yzoom, 15);
276            }
277            if (xtiles == 3) code += 1;
278            if (xtiles == 5) code += 3;
279            if (xtiles == 6) code += 2;
280            if (xtiles == 7) code += 1;
281         }
282      }
283
284      /* xflipped case */
285      else if (xflip && !yflip) {
286         for (yt = 0; yt < ytiles; yt++) {
287            for (xt = 0; xt < xtiles; xt++, code++) {
288               if (!zoomed)
289                  drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, 1, 0,
290                        x + (xtiles - 1 - xt) * 16, y + yt * 16, 15);
291               else
292                  drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[1], code, color, 1, 0,
293                        x + (xtiles - 1 - xt) * xzoom, y + yt * yzoom,
294                        0x1000 * xzoom, 0x1000 * yzoom, 15);
295            }
296            if (xtiles == 3) code += 1;
297            if (xtiles == 5) code += 3;
298            if (xtiles == 6) code += 2;
299            if (xtiles == 7) code += 1;
300         }
301      }
302
303      /* yflipped case */
304      else if (!xflip && yflip) {
305         for (yt = 0; yt < ytiles; yt++) {
306            for (xt = 0; xt < xtiles; xt++, code++) {
307               if (!zoomed)
308                  drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, 0, 1,
309                        x + xt * 16, y + (ytiles - 1 - yt) * 16, 15);
310               else
311                  drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[1], code, color, 0, 1,
312                        x + xt * xzoom, y + (ytiles - 1 - yt) * yzoom,
313                        0x1000 * xzoom, 0x1000 * yzoom, 15);
314            }
315            if (xtiles == 3) code += 1;
316            if (xtiles == 5) code += 3;
317            if (xtiles == 6) code += 2;
318            if (xtiles == 7) code += 1;
319         }
320      }
321
322      /* x & yflipped case */
323      else {
324         for (yt = 0; yt < ytiles; yt++) {
325            for (xt = 0; xt < xtiles; xt++, code++) {
326               if (!zoomed)
327                  drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, 1, 1,
328                        x + (xtiles - 1 - xt) * 16, y + (ytiles - 1 - yt) * 16, 15);
329               else
330                  drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[1], code, color, 1, 1,
331                        x + (xtiles - 1 - xt) * xzoom, y + (ytiles - 1 - yt) * yzoom,
332                        0x1000 * xzoom, 0x1000 * yzoom, 15);
333            }
334            if (xtiles == 3) code += 1;
335            if (xtiles == 5) code += 3;
336            if (xtiles == 6) code += 2;
337            if (xtiles == 7) code += 1;
338         }
339      }
340   }
341}
342
343
344
345void vsystem_spr2_device::f1gp_draw_sprites( UINT16* spr1vram, UINT16* spr2vram, UINT16* spr1cgram, int spr1cgram_bytes, UINT16* spr2cgram, int spr2cgram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int primask )
346{
347   int attr_start, first;
348   UINT16 *spram = chip ? spr2vram : spr1vram;
349
350   first = 4 * spram[0x1fe];
351
352   for (attr_start = 0x0200 - 8; attr_start >= first; attr_start -= 4)
353   {
354      int map_start;
355      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color/*, pri*/;
356      /* table hand made by looking at the ship explosion in attract mode */
357      /* it's almost a logarithmic scale but not exactly */
358      static const int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
359
360      if (!(spram[attr_start + 2] & 0x0080)) continue;
361
362      ox = spram[attr_start + 1] & 0x01ff;
363      xsize = (spram[attr_start + 2] & 0x0700) >> 8;
364      zoomx = (spram[attr_start + 1] & 0xf000) >> 12;
365      oy = spram[attr_start + 0] & 0x01ff;
366      ysize = (spram[attr_start + 2] & 0x7000) >> 12;
367      zoomy = (spram[attr_start + 0] & 0xf000) >> 12;
368      flipx = spram[attr_start + 2] & 0x0800;
369      flipy = spram[attr_start + 2] & 0x8000;
370      color = (spram[attr_start + 2] & 0x000f);// + 16 * spritepalettebank;
371      //pri = spram[attr_start + 2] & 0x0010;
372      map_start = spram[attr_start + 3];
373
374      zoomx = 16 - zoomtable[zoomx] / 8;
375      zoomy = 16 - zoomtable[zoomy] / 8;
376
377      for (y = 0; y <= ysize; y++)
378      {
379         int sx, sy;
380
381         if (flipy) sy = ((oy + zoomy * (ysize - y) + 16) & 0x1ff) - 16;
382         else sy = ((oy + zoomy * y + 16) & 0x1ff) - 16;
383
384         for (x = 0; x <= xsize; x++)
385         {
386            int code;
387
388            if (flipx) sx = ((ox + zoomx * (xsize - x) + 16) & 0x1ff) - 16;
389            else sx = ((ox + zoomx * x + 16) & 0x1ff) - 16;
390
391            if (chip == 0)
392               code = spr1cgram[map_start % (spr1cgram_bytes / 2)];
393            else
394               code = spr2cgram[map_start % (spr2cgram_bytes / 2)];
395
396            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1 + chip],
397                  code,
398                  color,
399                  flipx,flipy,
400                  sx,sy,
401                  0x1000 * zoomx,0x1000 * zoomy,
402                  machine.priority_bitmap,
403//                      pri ? 0 : 0x2);
404                  primask,15);
405            map_start++;
406         }
407
408         if (xsize == 2) map_start += 1;
409         if (xsize == 4) map_start += 3;
410         if (xsize == 5) map_start += 2;
411         if (xsize == 6) map_start += 1;
412      }
413   }
414}
415
416// the same but for an 8-bit system..
417void vsystem_spr2_device::draw_sprites_pipedrm( UINT8* spriteram, int spriteram_bytes, int flipscreen, screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int draw_priority )
418{
419   static const UINT8 zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
420   const rectangle &visarea = screen.visible_area();
421//   UINT8 *spriteram = spriteram;
422   int offs;
423
424   /* draw the sprites */
425   for (offs = 0; offs < spriteram_bytes; offs += 8)
426   {
427      int data2 = spriteram[offs + 4] | (spriteram[offs + 5] << 8);
428      int priority = (data2 >> 4) & 1;
429
430      /* turns out the sprites are the same as in aerofgt.c */
431      if ((data2 & 0x80) && priority == draw_priority)
432      {
433         int data0 = spriteram[offs + 0] | (spriteram[offs + 1] << 8);
434         int data1 = spriteram[offs + 2] | (spriteram[offs + 3] << 8);
435         int data3 = spriteram[offs + 6] | (spriteram[offs + 7] << 8);
436         int code = data3 & 0xfff;
437         int color = data2 & 0x0f;
438         int y = (data0 & 0x1ff) - 6;
439         int x = (data1 & 0x1ff) - 13;
440         int yzoom = (data0 >> 12) & 15;
441         int xzoom = (data1 >> 12) & 15;
442         int zoomed = (xzoom | yzoom);
443         int ytiles = ((data2 >> 12) & 7) + 1;
444         int xtiles = ((data2 >> 8) & 7) + 1;
445         int yflip = (data2 >> 15) & 1;
446         int xflip = (data2 >> 11) & 1;
447         int xt, yt;
448
449         /* compute the zoom factor -- stolen from aerofgt.c */
450         xzoom = 16 - zoomtable[xzoom] / 8;
451         yzoom = 16 - zoomtable[yzoom] / 8;
452
453         /* wrap around */
454         if (x > visarea.max_x)
455            x -= 0x200;
456         if (y > visarea.max_y)
457            y -= 0x200;
458
459         /* flip ? */
460         if (flipscreen)
461         {
462            y = visarea.max_y - y - 16 * ytiles - 4;
463            x = visarea.max_x - x - 16 * xtiles - 24;
464            xflip=!xflip;
465            yflip=!yflip;
466         }
467
468         /* normal case */
469         if (!xflip && !yflip)
470         {
471            for (yt = 0; yt < ytiles; yt++)
472               for (xt = 0; xt < xtiles; xt++, code++)
473                  if (!zoomed)
474                     drawgfx_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 0, 0,
475                           x + xt * 16, y + yt * 16, 15);
476                  else
477                     drawgfxzoom_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 0, 0,
478                           x + xt * xzoom, y + yt * yzoom,
479                           0x1000 * xzoom, 0x1000 * yzoom, 15);
480         }
481
482         /* xflipped case */
483         else if (xflip && !yflip)
484         {
485            for (yt = 0; yt < ytiles; yt++)
486               for (xt = 0; xt < xtiles; xt++, code++)
487                  if (!zoomed)
488                     drawgfx_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 1, 0,
489                           x + (xtiles - 1 - xt) * 16, y + yt * 16, 15);
490                  else
491                     drawgfxzoom_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 1, 0,
492                           x + (xtiles - 1 - xt) * xzoom, y + yt * yzoom,
493                           0x1000 * xzoom, 0x1000 * yzoom, 15);
494         }
495
496         /* yflipped case */
497         else if (!xflip && yflip)
498         {
499            for (yt = 0; yt < ytiles; yt++)
500               for (xt = 0; xt < xtiles; xt++, code++)
501                  if (!zoomed)
502                     drawgfx_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 0, 1,
503                           x + xt * 16, y + (ytiles - 1 - yt) * 16, 15);
504                  else
505                     drawgfxzoom_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 0, 1,
506                           x + xt * xzoom, y + (ytiles - 1 - yt) * yzoom,
507                           0x1000 * xzoom, 0x1000 * yzoom, 15);
508         }
509
510         /* x & yflipped case */
511         else
512         {
513            for (yt = 0; yt < ytiles; yt++)
514               for (xt = 0; xt < xtiles; xt++, code++)
515                  if (!zoomed)
516                     drawgfx_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 1, 1,
517                           x + (xtiles - 1 - xt) * 16, y + (ytiles - 1 - yt) * 16, 15);
518                  else
519                     drawgfxzoom_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 1, 1,
520                           x + (xtiles - 1 - xt) * xzoom, y + (ytiles - 1 - yt) * yzoom,
521                           0x1000 * xzoom, 0x1000 * yzoom, 15);
522         }
523      }
524   }
525}
trunk/src/mame/video/vsystem_spr2.h
r0r18422
1// Video System Sprites
2
3
4class vsystem_spr2_device : public device_t
5{
6public:
7   vsystem_spr2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8   
9   template<class _BitmapClass>
10   void turbofrc_draw_sprites_common( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, _BitmapClass &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri );
11   
12   void turbofrc_draw_sprites( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri );
13   void turbofrc_draw_sprites( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri );
14
15   template<class _BitmapClass>
16   void spinlbrk_draw_sprites_common( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, _BitmapClass &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri );
17   
18   void spinlbrk_draw_sprites( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri );
19   void spinlbrk_draw_sprites( UINT16* spriteram3,  int spriteram3_bytes, UINT16* spriteram1, int spriteram1_bytes, UINT16* spriteram2, int spriteram2_bytes, int sprite_gfx, int spritepalettebank, running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri );
20
21
22   void welltris_draw_sprites( UINT16* spriteram, int spritepalettebank, running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect);
23   void f1gp_draw_sprites( UINT16* spr1vram, UINT16* spr2vram, UINT16* spr1cgram, int spr1cgram_bytes, UINT16* spr2cgram, int spr2cgram_bytes, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int primask );
24   void draw_sprites_pipedrm( UINT8* spriteram, int spriteram_bytes, int flipscreen, screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int draw_priority );
25
26protected:
27   virtual void device_start();
28   virtual void device_reset();
29
30
31private:
32
33
34};
35
36
37extern const device_type VSYSTEM_SPR2;
38
39
40
trunk/src/mame/video/aerofgt.c
r18421r18422
156156   aerofgt_register_state_globals(machine());
157157}
158158
159VIDEO_START_MEMBER(aerofgt_state,wbbc97)
160{
161   m_bg1_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(aerofgt_state::get_pspikes_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
162   /* no bg2 in this game */
163159
164   m_bg1_tilemap->set_transparent_pen(15);
165
166   m_sprite_gfx = 1;
167
168   aerofgt_register_state_globals(machine());
169
170   save_item(NAME(m_wbbc97_bitmap_enable));
171}
172
173160/***************************************************************************
174161
175162  Memory handlers
r18421r18422
208195   }
209196}
210197
211WRITE16_MEMBER(aerofgt_state::pspikesb_gfxbank_w)
212{
213   COMBINE_DATA(&m_rasterram[0x200 / 2]);
214198
215   setbank(machine(), m_bg1_tilemap, 0, (data & 0xf000) >> 12);
216   setbank(machine(), m_bg1_tilemap, 1, (data & 0x0f00) >> 8);
217}
218
219WRITE16_MEMBER(aerofgt_state::spikes91_lookup_w)
220{
221   m_spikes91_lookup = data & 1;
222}
223
224199WRITE16_MEMBER(aerofgt_state::karatblz_gfxbank_w)
225200{
226201   if (ACCESSING_BITS_8_15)
r18421r18422
294269   }
295270}
296271
297WRITE16_MEMBER(aerofgt_state::wbbc97_bitmap_enable_w)
298{
299   COMBINE_DATA(&m_wbbc97_bitmap_enable);
300}
301272
302273/***************************************************************************
303274
r18421r18422
305276
306277***************************************************************************/
307278
308static void aerofgt_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
279
280UINT32 aerofgt_state::screen_update_pspikes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
309281{
310   aerofgt_state *state = machine.driver_data<aerofgt_state>();
311   int offs;
312   priority <<= 12;
282   int i, scrolly;
313283
314   offs = 0;
315   while (offs < 0x0400 && (state->m_spriteram3[offs] & 0x8000) == 0)
316   {
317      int attr_start = 4 * (state->m_spriteram3[offs] & 0x03ff);
284   m_bg1_tilemap->set_scroll_rows(256);
285   scrolly = m_bg1scrolly;
286   for (i = 0; i < 256; i++)
287      m_bg1_tilemap->set_scrollx((i + scrolly) & 0xff, m_rasterram[i]);
288   m_bg1_tilemap->set_scrolly(0, scrolly);
318289
319      /* is the way I handle priority correct? Or should I just check bit 13? */
320      if ((state->m_spriteram3[attr_start + 2] & 0x3000) == priority)
321      {
322         int map_start;
323         int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color;
290   machine().priority_bitmap.fill(0, cliprect);
324291
325         ox = state->m_spriteram3[attr_start + 1] & 0x01ff;
326         xsize = (state->m_spriteram3[attr_start + 1] & 0x0e00) >> 9;
327         zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12;
328         oy = state->m_spriteram3[attr_start + 0] & 0x01ff;
329         ysize = (state->m_spriteram3[attr_start + 0] & 0x0e00) >> 9;
330         zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12;
331         flipx = state->m_spriteram3[attr_start + 2] & 0x4000;
332         flipy = state->m_spriteram3[attr_start + 2] & 0x8000;
333         color = (state->m_spriteram3[attr_start + 2] & 0x0f00) >> 8;
334         map_start = state->m_spriteram3[attr_start + 3] & 0x3fff;
292   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
293   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, -1);
294   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, 0);
295   return 0;
296}
335297
336         ox += (xsize * zoomx + 2) / 4;
337         oy += (ysize * zoomy + 2) / 4;
338298
339         zoomx = 32 - zoomx;
340         zoomy = 32 - zoomy;
299UINT32 aerofgt_state::screen_update_karatblz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
300{
301   m_bg1_tilemap->set_scrollx(0, m_bg1scrollx - 8);
302   m_bg1_tilemap->set_scrolly(0, m_bg1scrolly);
303   m_bg2_tilemap->set_scrollx(0, m_bg2scrollx - 4);
304   m_bg2_tilemap->set_scrolly(0, m_bg2scrolly);
341305
342         for (y = 0; y <= ysize; y++)
343         {
344            int sx, sy;
306   machine().priority_bitmap.fill(0, cliprect);
345307
346            if (flipy)
347               sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
348            else
349               sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
308   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
309   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
350310
351            for (x = 0; x <= xsize; x++)
352            {
353               int code;
354
355               if (flipx)
356                  sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
357               else
358                  sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
359
360               if (map_start < 0x2000)
361                  code = state->m_spriteram1[map_start & 0x1fff] & 0x1fff;
362               else
363                  code = state->m_spriteram2[map_start & 0x1fff] & 0x1fff;
364
365               drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + (map_start >= 0x2000 ? 1 : 0)],
366                     code,
367                     color,
368                     flipx,flipy,
369                     sx,sy,
370                     zoomx << 11, zoomy << 11,15);
371               map_start++;
372            }
373         }
374      }
375      offs++;
376   }
311   /* we use the priority buffer so sprites are drawn front to back */
312   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 1, -1);
313   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 1, 0);
314   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, -1);
315   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, 0);
316   return 0;
377317}
378318
379template<class _BitmapClass>
380static void turbofrc_draw_sprites( running_machine &machine, _BitmapClass &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
319UINT32 aerofgt_state::screen_update_spinlbrk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
381320{
382   aerofgt_state *state = machine.driver_data<aerofgt_state>();
383   int attr_start, base, first;
384   base = chip * 0x0200;
385   first = 4 * state->m_spriteram3[0x1fe + base];
321   int i, scrolly;
386322
387   for (attr_start = base + 0x0200 - 8; attr_start >= first + base; attr_start -= 4)
388   {
389      int map_start;
390      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color, pri;
391// some other drivers still use this wrong table, they have to be upgraded
392//      int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
323   m_bg1_tilemap->set_scroll_rows(512);
324   scrolly = 0;
325   for (i = 0; i < 256; i++)
326      m_bg1_tilemap->set_scrollx((i + scrolly) & 0x1ff, m_rasterram[i] - 8);
327//  m_bg1_tilemap->set_scrolly(0, m_bg1scrolly);
328   m_bg2_tilemap->set_scrollx(0, m_bg2scrollx - 4);
329//  m_bg2_tilemap->set_scrolly(0, m_bg2scrolly);
393330
394      if (!(state->m_spriteram3[attr_start + 2] & 0x0080))
395         continue;
331   machine().priority_bitmap.fill(0, cliprect);
396332
397      pri = state->m_spriteram3[attr_start + 2] & 0x0010;
333   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
334   m_bg2_tilemap->draw(bitmap, cliprect, 0, 1);
398335
399      if ( chip_disabled_pri & !pri)
400         continue;
336   /* we use the priority buffer so sprites are drawn front to back */
337   m_spr_old->spinlbrk_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, 0);
338   m_spr_old->spinlbrk_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, -1);
339   m_spr_old->spinlbrk_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 1, 0);
340   m_spr_old->spinlbrk_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 1, -1);
341   return 0;
342}
401343
402      if ((!chip_disabled_pri) & (pri >> 4))
403         continue;
344UINT32 aerofgt_state::screen_update_turbofrc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
345{
346   int i, scrolly;
404347
405      ox = state->m_spriteram3[attr_start + 1] & 0x01ff;
406      xsize = (state->m_spriteram3[attr_start + 2] & 0x0700) >> 8;
407      zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12;
408      oy = state->m_spriteram3[attr_start + 0] & 0x01ff;
409      ysize = (state->m_spriteram3[attr_start + 2] & 0x7000) >> 12;
410      zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12;
411      flipx = state->m_spriteram3[attr_start + 2] & 0x0800;
412      flipy = state->m_spriteram3[attr_start + 2] & 0x8000;
413      color = (state->m_spriteram3[attr_start + 2] & 0x000f) + 16 * state->m_spritepalettebank;
348   m_bg1_tilemap->set_scroll_rows(512);
349   scrolly = m_bg1scrolly + 2;
350   for (i = 0; i < 256; i++)
351//      m_bg1_tilemap->set_scrollx((i + scrolly) & 0x1ff, m_rasterram[i] - 11);
352      m_bg1_tilemap->set_scrollx((i + scrolly) & 0x1ff, m_rasterram[7] - 11);
353   m_bg1_tilemap->set_scrolly(0, scrolly);
354   m_bg2_tilemap->set_scrollx(0, m_bg2scrollx - 7);
355   m_bg2_tilemap->set_scrolly(0, m_bg2scrolly + 2);
414356
415      map_start = state->m_spriteram3[attr_start + 3];
357   machine().priority_bitmap.fill(0, cliprect);
416358
417// aerofgt has this adjustment, but doing it here would break turbo force title screen
418//      ox += (xsize*zoomx+2)/4;
419//      oy += (ysize*zoomy+2)/4;
359   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
360   m_bg2_tilemap->draw(bitmap, cliprect, 0, 1);
420361
421      zoomx = 32 - zoomx;
422      zoomy = 32 - zoomy;
362   /* we use the priority buffer so sprites are drawn front to back */
363   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 1, -1); //ship
364   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 1, 0); //intro
365   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, -1); //enemy
366   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, 0); //enemy
367   return 0;
368}
423369
424      for (y = 0; y <= ysize; y++)
425      {
426         int sx, sy;
370UINT32 aerofgt_state::screen_update_aerofgt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
371{
372   m_bg1_tilemap->set_scrollx(0, m_rasterram[0x0000] - 18);
373   m_bg1_tilemap->set_scrolly(0, m_bg1scrolly);
374   m_bg2_tilemap->set_scrollx(0, m_rasterram[0x0200] - 20);
375   m_bg2_tilemap->set_scrolly(0, m_bg2scrolly);
427376
428         if (flipy)
429            sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
430         else
431            sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
377   machine().priority_bitmap.fill(0, cliprect);
432378
433         for (x = 0; x <= xsize; x++)
434         {
435            int code;
379   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
436380
437            if (flipx)
438               sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
439            else
440               sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
381   m_spr->draw_sprites_aerofght(m_spriteram3, m_spriteram3.bytes(), m_spriteram1, m_spriteram2, machine(), bitmap, cliprect, 0);
382   m_spr->draw_sprites_aerofght(m_spriteram3, m_spriteram3.bytes(), m_spriteram1, m_spriteram2, machine(), bitmap, cliprect, 1);
441383
442            if (chip == 0)
443               code = state->m_spriteram1[map_start % (state->m_spriteram1.bytes()/2)];
444            else
445               code = state->m_spriteram2[map_start % (state->m_spriteram2.bytes()/2)];
384   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
446385
447            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + chip],
448                      code,
449                      color,
450                      flipx,flipy,
451                      sx,sy,
452                      zoomx << 11, zoomy << 11,
453                      machine.priority_bitmap,pri ? 0 : 2,15);
454            map_start++;
455         }
456
457         if (xsize == 2) map_start += 1;
458         if (xsize == 4) map_start += 3;
459         if (xsize == 5) map_start += 2;
460         if (xsize == 6) map_start += 1;
461      }
462   }
386   m_spr->draw_sprites_aerofght(m_spriteram3, m_spriteram3.bytes(), m_spriteram1, m_spriteram2, machine(), bitmap, cliprect, 2);
387   m_spr->draw_sprites_aerofght(m_spriteram3, m_spriteram3.bytes(), m_spriteram1, m_spriteram2, machine(), bitmap, cliprect, 3);
388   return 0;
463389}
464390
465static void spinlbrk_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
466{
467   aerofgt_state *state = machine.driver_data<aerofgt_state>();
468   int attr_start, base, first;
469   base = chip * 0x0200;
470   first = 4 * state->m_spriteram3[0x1fe + base];
471391
472   for (attr_start = base + 0x0200-8; attr_start >= first + base; attr_start -= 4)
473   {
474      int map_start;
475      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color, pri;
476// some other drivers still use this wrong table, they have to be upgraded
477//      int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
392/***************************************************************************
478393
479      if (!(state->m_spriteram3[attr_start + 2] & 0x0080))
480         continue;
394  BOOTLEG SUPPORT
481395
482      pri = state->m_spriteram3[attr_start + 2] & 0x0010;
396***************************************************************************/
483397
484      if ( chip_disabled_pri & !pri)
485         continue;
486      if ((!chip_disabled_pri) & (pri >> 4))
487         continue;
398// BOOTLEG
399VIDEO_START_MEMBER(aerofgt_state,wbbc97)
400{
401   m_bg1_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(aerofgt_state::get_pspikes_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
402   /* no bg2 in this game */
488403
489      ox = state->m_spriteram3[attr_start + 1] & 0x01ff;
490      xsize = (state->m_spriteram3[attr_start + 2] & 0x0700) >> 8;
491      zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12;
492      oy = state->m_spriteram3[attr_start + 0] & 0x01ff;
493      ysize = (state->m_spriteram3[attr_start + 2] & 0x7000) >> 12;
494      zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12;
495      flipx = state->m_spriteram3[attr_start + 2] & 0x0800;
496      flipy = state->m_spriteram3[attr_start + 2] & 0x8000;
497      color = (state->m_spriteram3[attr_start + 2] & 0x000f) + 16 * state->m_spritepalettebank;
404   m_bg1_tilemap->set_transparent_pen(15);
498405
499      map_start = state->m_spriteram3[attr_start + 3];
406   m_sprite_gfx = 1;
500407
501// aerofgt has this adjustment, but doing it here would break turbo force title screen
502//      ox += (xsize*zoomx+2)/4;
503//      oy += (ysize*zoomy+2)/4;
408   aerofgt_register_state_globals(machine());
504409
505      zoomx = 32 - zoomx;
506      zoomy = 32 - zoomy;
410   save_item(NAME(m_wbbc97_bitmap_enable));
411}
507412
508      for (y = 0; y <= ysize; y++)
509      {
510         int sx, sy;
413// BOOTLEG
414WRITE16_MEMBER(aerofgt_state::pspikesb_gfxbank_w)
415{
416   COMBINE_DATA(&m_rasterram[0x200 / 2]);
511417
512         if (flipy)
513            sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
514         else
515            sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
418   setbank(machine(), m_bg1_tilemap, 0, (data & 0xf000) >> 12);
419   setbank(machine(), m_bg1_tilemap, 1, (data & 0x0f00) >> 8);
420}
516421
517         for (x = 0; x <= xsize; x++)
518         {
519            int code;
422// BOOTLEG
423WRITE16_MEMBER(aerofgt_state::spikes91_lookup_w)
424{
425   m_spikes91_lookup = data & 1;
426}
520427
521            if (flipx)
522               sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
523            else
524               sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
525
526            if (chip == 0)
527               code = state->m_spriteram1[map_start % (state->m_spriteram1.bytes()/2)];
528            else
529               code = state->m_spriteram2[map_start % (state->m_spriteram2.bytes()/2)];
530
531            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + chip],
532                      code,
533                      color,
534                      flipx,flipy,
535                      sx,sy,
536                      zoomx << 11, zoomy << 11,
537                      machine.priority_bitmap,pri ? 2 : 0,15);
538            map_start++;
539         }
540
541         if (xsize == 2) map_start += 1;
542         if (xsize == 4) map_start += 3;
543         if (xsize == 5) map_start += 2;
544         if (xsize == 6) map_start += 1;
545      }
546   }
428// BOOTLEG
429WRITE16_MEMBER(aerofgt_state::wbbc97_bitmap_enable_w)
430{
431   COMBINE_DATA(&m_wbbc97_bitmap_enable);
547432}
548433
434// BOOTLEG
549435static void aerfboo2_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
550436{
551437   aerofgt_state *state = machine.driver_data<aerofgt_state>();
r18421r18422
631517   }
632518}
633519
520// BOOTLEG
634521static void pspikesb_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
635522{
636523   aerofgt_state *state = machine.driver_data<aerofgt_state>();
r18421r18422
666553   }
667554}
668555
556// BOOTLEG
669557static void spikes91_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
670558{
671559   aerofgt_state *state = machine.driver_data<aerofgt_state>();
r18421r18422
708596   }
709597}
710598
599// BOOTLEG
711600static void aerfboot_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
712601{
713602   aerofgt_state *state = machine.driver_data<aerofgt_state>();
r18421r18422
790679   }
791680}
792681
682// BOOTLEG
793683static void wbbc97_draw_bitmap( running_machine &machine, bitmap_rgb32 &bitmap )
794684{
795685   aerofgt_state *state = machine.driver_data<aerofgt_state>();
r18421r18422
810700      }
811701}
812702
813
814UINT32 aerofgt_state::screen_update_pspikes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
815{
816   int i, scrolly;
817
818   m_bg1_tilemap->set_scroll_rows(256);
819   scrolly = m_bg1scrolly;
820   for (i = 0; i < 256; i++)
821      m_bg1_tilemap->set_scrollx((i + scrolly) & 0xff, m_rasterram[i]);
822   m_bg1_tilemap->set_scrolly(0, scrolly);
823
824   machine().priority_bitmap.fill(0, cliprect);
825
826   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
827   turbofrc_draw_sprites(machine(), bitmap, cliprect, 0, -1);
828   turbofrc_draw_sprites(machine(), bitmap, cliprect, 0, 0);
829   return 0;
830}
831
703// BOOTLEG
832704UINT32 aerofgt_state::screen_update_pspikesb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
833705{
834706   int i, scrolly;
r18421r18422
844716   return 0;
845717}
846718
719// BOOTLEG
847720UINT32 aerofgt_state::screen_update_spikes91(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
848721{
849722   int i, scrolly;
r18421r18422
884757   return 0;
885758}
886759
887UINT32 aerofgt_state::screen_update_karatblz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
888{
889   m_bg1_tilemap->set_scrollx(0, m_bg1scrollx - 8);
890   m_bg1_tilemap->set_scrolly(0, m_bg1scrolly);
891   m_bg2_tilemap->set_scrollx(0, m_bg2scrollx - 4);
892   m_bg2_tilemap->set_scrolly(0, m_bg2scrolly);
893
894   machine().priority_bitmap.fill(0, cliprect);
895
896   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
897   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
898
899   /* we use the priority buffer so sprites are drawn front to back */
900   turbofrc_draw_sprites(machine(), bitmap, cliprect, 1, -1);
901   turbofrc_draw_sprites(machine(), bitmap, cliprect, 1, 0);
902   turbofrc_draw_sprites(machine(), bitmap, cliprect, 0, -1);
903   turbofrc_draw_sprites(machine(), bitmap, cliprect, 0, 0);
904   return 0;
905}
906
907UINT32 aerofgt_state::screen_update_spinlbrk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
908{
909   int i, scrolly;
910
911   m_bg1_tilemap->set_scroll_rows(512);
912   scrolly = 0;
913   for (i = 0; i < 256; i++)
914      m_bg1_tilemap->set_scrollx((i + scrolly) & 0x1ff, m_rasterram[i] - 8);
915//  m_bg1_tilemap->set_scrolly(0, m_bg1scrolly);
916   m_bg2_tilemap->set_scrollx(0, m_bg2scrollx - 4);
917//  m_bg2_tilemap->set_scrolly(0, m_bg2scrolly);
918
919   machine().priority_bitmap.fill(0, cliprect);
920
921   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
922   m_bg2_tilemap->draw(bitmap, cliprect, 0, 1);
923
924   /* we use the priority buffer so sprites are drawn front to back */
925   spinlbrk_draw_sprites(machine(), bitmap, cliprect, 0, 0);
926   spinlbrk_draw_sprites(machine(), bitmap, cliprect, 0, -1);
927   spinlbrk_draw_sprites(machine(), bitmap, cliprect, 1, 0);
928   spinlbrk_draw_sprites(machine(), bitmap, cliprect, 1, -1);
929   return 0;
930}
931
932UINT32 aerofgt_state::screen_update_turbofrc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
933{
934   int i, scrolly;
935
936   m_bg1_tilemap->set_scroll_rows(512);
937   scrolly = m_bg1scrolly + 2;
938   for (i = 0; i < 256; i++)
939//      m_bg1_tilemap->set_scrollx((i + scrolly) & 0x1ff, m_rasterram[i] - 11);
940      m_bg1_tilemap->set_scrollx((i + scrolly) & 0x1ff, m_rasterram[7] - 11);
941   m_bg1_tilemap->set_scrolly(0, scrolly);
942   m_bg2_tilemap->set_scrollx(0, m_bg2scrollx - 7);
943   m_bg2_tilemap->set_scrolly(0, m_bg2scrolly + 2);
944
945   machine().priority_bitmap.fill(0, cliprect);
946
947   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
948   m_bg2_tilemap->draw(bitmap, cliprect, 0, 1);
949
950   /* we use the priority buffer so sprites are drawn front to back */
951   turbofrc_draw_sprites(machine(), bitmap, cliprect, 1, -1); //ship
952   turbofrc_draw_sprites(machine(), bitmap, cliprect, 1, 0); //intro
953   turbofrc_draw_sprites(machine(), bitmap, cliprect, 0, -1); //enemy
954   turbofrc_draw_sprites(machine(), bitmap, cliprect, 0, 0); //enemy
955   return 0;
956}
957
958UINT32 aerofgt_state::screen_update_aerofgt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
959{
960   m_bg1_tilemap->set_scrollx(0, m_rasterram[0x0000] - 18);
961   m_bg1_tilemap->set_scrolly(0, m_bg1scrolly);
962   m_bg2_tilemap->set_scrollx(0, m_rasterram[0x0200] - 20);
963   m_bg2_tilemap->set_scrolly(0, m_bg2scrolly);
964
965   machine().priority_bitmap.fill(0, cliprect);
966
967   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
968
969   aerofgt_draw_sprites(machine(), bitmap, cliprect, 0);
970   aerofgt_draw_sprites(machine(), bitmap, cliprect, 1);
971
972   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
973
974   aerofgt_draw_sprites(machine(), bitmap, cliprect, 2);
975   aerofgt_draw_sprites(machine(), bitmap, cliprect, 3);
976   return 0;
977}
978
979
760// BOOTLEG
980761UINT32 aerofgt_state::screen_update_aerfboot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
981762{
982763   int i, scrolly;
r18421r18422
999780   return 0;
1000781}
1001782
783// BOOTLEG
1002784UINT32 aerofgt_state::screen_update_aerfboo2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
1003785{
1004786   int i, scrolly;
r18421r18422
1025807   return 0;
1026808}
1027809
810// BOOTLEG (still uses original sprite type)
1028811UINT32 aerofgt_state::screen_update_wbbc97(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
1029812{
1030813   int i, scrolly;
r18421r18422
1047830      m_bg1_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
1048831   }
1049832
1050   turbofrc_draw_sprites(machine(), bitmap, cliprect, 0, -1);
1051   turbofrc_draw_sprites(machine(), bitmap, cliprect, 0, 0);
833   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, -1);
834   m_spr_old->turbofrc_draw_sprites(m_spriteram3,m_spriteram3.bytes(),m_spriteram1,m_spriteram1.bytes(),m_spriteram2,m_spriteram2.bytes(),m_sprite_gfx,m_spritepalettebank, machine(), bitmap, cliprect, 0, 0);
1052835   return 0;
1053836}
trunk/src/mame/video/welltris.c
r18421r18422
2727}
2828
2929
30/* Sprite Drawing is pretty much the same as fromance.c */
31static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
32{
33   static const UINT8 zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
34   welltris_state *state = machine.driver_data<welltris_state>();
35   int offs;
36   const rectangle &visarea = machine.primary_screen->visible_area();
37
38   /* draw the sprites */
39   for (offs = 0; offs < 0x200 - 4; offs += 4) {
40      int data0 = state->m_spriteram[offs + 0];
41      int data1 = state->m_spriteram[offs + 1];
42      int data2 = state->m_spriteram[offs + 2];
43      int data3 = state->m_spriteram[offs + 3];
44      int code = data3 & 0x1fff;
45      int color = (data2 & 0x0f) + (0x10 * state->m_spritepalettebank);
46      int y = (data0 & 0x1ff) + 1;
47      int x = (data1 & 0x1ff) + 6;
48      int yzoom = (data0 >> 12) & 15;
49      int xzoom = (data1 >> 12) & 15;
50      int zoomed = (xzoom | yzoom);
51      int ytiles = ((data2 >> 12) & 7) + 1;
52      int xtiles = ((data2 >>  8) & 7) + 1;
53      int yflip = (data2 >> 15) & 1;
54      int xflip = (data2 >> 11) & 1;
55      int xt, yt;
56
57      if (!(state->m_spriteram[offs + 2] & 0x0080)) continue;
58
59      /* compute the zoom factor -- stolen from aerofgt.c */
60      xzoom = 16 - zoomtable[xzoom] / 8;
61      yzoom = 16 - zoomtable[yzoom] / 8;
62
63      /* wrap around */
64      if (x > visarea.max_x) x -= 0x200;
65      if (y > visarea.max_y) y -= 0x200;
66
67      /* normal case */
68      if (!xflip && !yflip) {
69         for (yt = 0; yt < ytiles; yt++) {
70            for (xt = 0; xt < xtiles; xt++, code++) {
71               if (!zoomed)
72                  drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, 0, 0,
73                        x + xt * 16, y + yt * 16, 15);
74               else
75                  drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[1], code, color, 0, 0,
76                        x + xt * xzoom, y + yt * yzoom,
77                        0x1000 * xzoom, 0x1000 * yzoom, 15);
78            }
79            if (xtiles == 3) code += 1;
80            if (xtiles == 5) code += 3;
81            if (xtiles == 6) code += 2;
82            if (xtiles == 7) code += 1;
83         }
84      }
85
86      /* xflipped case */
87      else if (xflip && !yflip) {
88         for (yt = 0; yt < ytiles; yt++) {
89            for (xt = 0; xt < xtiles; xt++, code++) {
90               if (!zoomed)
91                  drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, 1, 0,
92                        x + (xtiles - 1 - xt) * 16, y + yt * 16, 15);
93               else
94                  drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[1], code, color, 1, 0,
95                        x + (xtiles - 1 - xt) * xzoom, y + yt * yzoom,
96                        0x1000 * xzoom, 0x1000 * yzoom, 15);
97            }
98            if (xtiles == 3) code += 1;
99            if (xtiles == 5) code += 3;
100            if (xtiles == 6) code += 2;
101            if (xtiles == 7) code += 1;
102         }
103      }
104
105      /* yflipped case */
106      else if (!xflip && yflip) {
107         for (yt = 0; yt < ytiles; yt++) {
108            for (xt = 0; xt < xtiles; xt++, code++) {
109               if (!zoomed)
110                  drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, 0, 1,
111                        x + xt * 16, y + (ytiles - 1 - yt) * 16, 15);
112               else
113                  drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[1], code, color, 0, 1,
114                        x + xt * xzoom, y + (ytiles - 1 - yt) * yzoom,
115                        0x1000 * xzoom, 0x1000 * yzoom, 15);
116            }
117            if (xtiles == 3) code += 1;
118            if (xtiles == 5) code += 3;
119            if (xtiles == 6) code += 2;
120            if (xtiles == 7) code += 1;
121         }
122      }
123
124      /* x & yflipped case */
125      else {
126         for (yt = 0; yt < ytiles; yt++) {
127            for (xt = 0; xt < xtiles; xt++, code++) {
128               if (!zoomed)
129                  drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, 1, 1,
130                        x + (xtiles - 1 - xt) * 16, y + (ytiles - 1 - yt) * 16, 15);
131               else
132                  drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[1], code, color, 1, 1,
133                        x + (xtiles - 1 - xt) * xzoom, y + (ytiles - 1 - yt) * yzoom,
134                        0x1000 * xzoom, 0x1000 * yzoom, 15);
135            }
136            if (xtiles == 3) code += 1;
137            if (xtiles == 5) code += 3;
138            if (xtiles == 6) code += 2;
139            if (xtiles == 7) code += 1;
140         }
141      }
142   }
143}
144
14530void welltris_state::setbank(int num, int bank)
14631{
14732   if (m_gfxbank[num] != bank)
r18421r18422
240125
241126   draw_background(machine(), bitmap, cliprect);
242127   m_char_tilemap->draw(bitmap, cliprect, 0, 0);
243   draw_sprites(machine(), bitmap, cliprect);
128   m_spr_old->welltris_draw_sprites(m_spriteram, m_spritepalettebank, machine(), bitmap, cliprect);
244129   return 0;
245130}
trunk/src/mame/video/fromance.c
r18421r18422
284284
285285
286286
287/*************************************
288 *
289 *  Sprite routines (Pipe Dream)
290 *
291 *************************************/
292287
293static void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int draw_priority )
294{
295   fromance_state *state = screen.machine().driver_data<fromance_state>();
296   static const UINT8 zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
297   const rectangle &visarea = screen.visible_area();
298   UINT8 *spriteram = state->m_spriteram;
299   int offs;
300288
301   /* draw the sprites */
302   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 8)
303   {
304      int data2 = spriteram[offs + 4] | (spriteram[offs + 5] << 8);
305      int priority = (data2 >> 4) & 1;
306
307      /* turns out the sprites are the same as in aerofgt.c */
308      if ((data2 & 0x80) && priority == draw_priority)
309      {
310         int data0 = spriteram[offs + 0] | (spriteram[offs + 1] << 8);
311         int data1 = spriteram[offs + 2] | (spriteram[offs + 3] << 8);
312         int data3 = spriteram[offs + 6] | (spriteram[offs + 7] << 8);
313         int code = data3 & 0xfff;
314         int color = data2 & 0x0f;
315         int y = (data0 & 0x1ff) - 6;
316         int x = (data1 & 0x1ff) - 13;
317         int yzoom = (data0 >> 12) & 15;
318         int xzoom = (data1 >> 12) & 15;
319         int zoomed = (xzoom | yzoom);
320         int ytiles = ((data2 >> 12) & 7) + 1;
321         int xtiles = ((data2 >> 8) & 7) + 1;
322         int yflip = (data2 >> 15) & 1;
323         int xflip = (data2 >> 11) & 1;
324         int xt, yt;
325
326         /* compute the zoom factor -- stolen from aerofgt.c */
327         xzoom = 16 - zoomtable[xzoom] / 8;
328         yzoom = 16 - zoomtable[yzoom] / 8;
329
330         /* wrap around */
331         if (x > visarea.max_x)
332            x -= 0x200;
333         if (y > visarea.max_y)
334            y -= 0x200;
335
336         /* flip ? */
337         if (state->m_flipscreen)
338         {
339            y = visarea.max_y - y - 16 * ytiles - 4;
340            x = visarea.max_x - x - 16 * xtiles - 24;
341            xflip=!xflip;
342            yflip=!yflip;
343         }
344
345         /* normal case */
346         if (!xflip && !yflip)
347         {
348            for (yt = 0; yt < ytiles; yt++)
349               for (xt = 0; xt < xtiles; xt++, code++)
350                  if (!zoomed)
351                     drawgfx_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 0, 0,
352                           x + xt * 16, y + yt * 16, 15);
353                  else
354                     drawgfxzoom_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 0, 0,
355                           x + xt * xzoom, y + yt * yzoom,
356                           0x1000 * xzoom, 0x1000 * yzoom, 15);
357         }
358
359         /* xflipped case */
360         else if (xflip && !yflip)
361         {
362            for (yt = 0; yt < ytiles; yt++)
363               for (xt = 0; xt < xtiles; xt++, code++)
364                  if (!zoomed)
365                     drawgfx_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 1, 0,
366                           x + (xtiles - 1 - xt) * 16, y + yt * 16, 15);
367                  else
368                     drawgfxzoom_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 1, 0,
369                           x + (xtiles - 1 - xt) * xzoom, y + yt * yzoom,
370                           0x1000 * xzoom, 0x1000 * yzoom, 15);
371         }
372
373         /* yflipped case */
374         else if (!xflip && yflip)
375         {
376            for (yt = 0; yt < ytiles; yt++)
377               for (xt = 0; xt < xtiles; xt++, code++)
378                  if (!zoomed)
379                     drawgfx_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 0, 1,
380                           x + xt * 16, y + (ytiles - 1 - yt) * 16, 15);
381                  else
382                     drawgfxzoom_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 0, 1,
383                           x + xt * xzoom, y + (ytiles - 1 - yt) * yzoom,
384                           0x1000 * xzoom, 0x1000 * yzoom, 15);
385         }
386
387         /* x & yflipped case */
388         else
389         {
390            for (yt = 0; yt < ytiles; yt++)
391               for (xt = 0; xt < xtiles; xt++, code++)
392                  if (!zoomed)
393                     drawgfx_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 1, 1,
394                           x + (xtiles - 1 - xt) * 16, y + (ytiles - 1 - yt) * 16, 15);
395                  else
396                     drawgfxzoom_transpen(bitmap, cliprect, screen.machine().gfx[2], code, color, 1, 1,
397                           x + (xtiles - 1 - xt) * xzoom, y + (ytiles - 1 - yt) * yzoom,
398                           0x1000 * xzoom, 0x1000 * yzoom, 15);
399         }
400      }
401   }
402}
403
404
405
406289/*************************************
407290 *
408291 *  Main screen refresh
r18421r18422
433316   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
434317   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
435318
436   draw_sprites(screen, bitmap, cliprect, 0);
437   draw_sprites(screen, bitmap, cliprect, 1);
319   m_spr_old->draw_sprites_pipedrm(m_spriteram, m_spriteram.bytes(), m_flipscreen, screen, bitmap, cliprect, 0);
320   m_spr_old->draw_sprites_pipedrm(m_spriteram, m_spriteram.bytes(), m_flipscreen, screen, bitmap, cliprect, 1);
438321   return 0;
439322}
trunk/src/mame/mame.mak
r18421r18422
15931593
15941594$(MAMEOBJ)/vsystem.a: \
15951595   $(VIDEO)/vsystem_spr.o \
1596   $(VIDEO)/vsystem_spr2.o \
15961597   $(DRIVERS)/aerofgt.o $(VIDEO)/aerofgt.o \
15971598   $(DRIVERS)/crshrace.o $(VIDEO)/crshrace.o \
15981599   $(DRIVERS)/f1gp.o $(VIDEO)/f1gp.o \
trunk/src/mame/includes/f1gp.h
r18421r18422
1#include "video/vsystem_spr.h"
2#include "video/vsystem_spr2.h"
13
24class f1gp_state : public driver_device
35{
r18421r18422
1517      m_spritelist(*this, "spritelist"),
1618      m_spriteram(*this, "spriteram"),
1719      m_fgregs(*this, "fgregs"),
18      m_rozregs(*this, "rozregs"){ }
20      m_rozregs(*this, "rozregs"),
21      m_spr_old(*this, "vsystem_spr_old"),
22      m_spr(*this, "vsystem_spr")
23   { }
1924
2025   /* memory pointers */
2126   required_shared_ptr<UINT16> m_sharedram;
r18421r18422
3035   optional_shared_ptr<UINT16> m_spriteram;
3136   optional_shared_ptr<UINT16> m_fgregs;
3237   optional_shared_ptr<UINT16> m_rozregs;
38
39   /* devices referenced above */
40   optional_device<vsystem_spr2_device> m_spr_old; // f1gp
41   optional_device<vsystem_spr_device> m_spr; // f1gp2
42
43
3344   UINT16 *  m_zoomdata;
3445//      UINT16 *  m_paletteram;    // currently this uses generic palette handling
3546
trunk/src/mame/includes/aerofgt.h
r18421r18422
1#include "video/vsystem_spr.h"
2#include "video/vsystem_spr2.h"
13
24class aerofgt_state : public driver_device
35{
r18421r18422
1113      m_spriteram1(*this, "spriteram1"),
1214      m_spriteram2(*this, "spriteram2"),
1315      m_spriteram3(*this, "spriteram3"),
14      m_tx_tilemap_ram(*this, "tx_tilemap_ram"){ }
16      m_tx_tilemap_ram(*this, "tx_tilemap_ram"),
17      m_spr(*this, "vsystem_spr"),
18      m_spr_old(*this, "vsystem_spr_old")
19   { }
1520
1621   /* memory pointers */
1722   required_shared_ptr<UINT16> m_bg1videoram;
r18421r18422
2429   optional_shared_ptr<UINT16> m_tx_tilemap_ram;
2530//  UINT16 *  m_paletteram;   // currently this uses generic palette handling
2631
32   /* devices referenced above */
33   optional_device<vsystem_spr_device> m_spr; // only the aerofgt parent uses this chip
34   optional_device<vsystem_spr2_device> m_spr_old; // every other (non-bootleg) uses this
35
36
2737   /* video-related */
2838   tilemap_t   *m_bg1_tilemap;
2939   tilemap_t   *m_bg2_tilemap;
r18421r18422
4252   /* misc */
4353   int       m_pending_command;
4454
45   /* devices */
55   /* other devices */
4656   cpu_device *m_audiocpu;
57   
58   /* handlers */
4759   DECLARE_WRITE16_MEMBER(sound_command_w);
4860   DECLARE_WRITE16_MEMBER(turbofrc_sound_command_w);
4961   DECLARE_WRITE16_MEMBER(aerfboot_soundlatch_w);
trunk/src/mame/includes/fromance.h
r18421r18422
77
88***************************************************************************/
99
10#include "video/vsystem_spr2.h"
11
1012class fromance_state : public driver_device
1113{
1214public:
1315   fromance_state(const machine_config &mconfig, device_type type, const char *tag)
1416      : driver_device(mconfig, type, tag),
15        m_videoram(*this, "videoram"),
16        m_spriteram(*this, "spriteram") { }
17      m_videoram(*this, "videoram"),
18      m_spriteram(*this, "spriteram"),
19      m_spr_old(*this, "vsystem_spr_old")
20   { }
1721
1822   /* memory pointers (used by pipedrm) */
1923   optional_shared_ptr<UINT8> m_videoram;
2024   optional_shared_ptr<UINT8> m_spriteram;
2125//  UINT8 *  m_paletteram;    // currently this uses generic palette handling
2226
27   optional_device<vsystem_spr2_device> m_spr_old; // only used by pipe dream, split this state up and clean things...
28
2329   /* video-related */
2430   tilemap_t  *m_bg_tilemap;
2531   tilemap_t  *m_fg_tilemap;
trunk/src/mame/includes/welltris.h
r18421r18422
1#include "video/vsystem_spr2.h"
2
13class welltris_state : public driver_device
24{
35public:
r18421r18422
57      : driver_device(mconfig, type, tag) ,
68      m_spriteram(*this, "spriteram"),
79      m_pixelram(*this, "pixelram"),
8      m_charvideoram(*this, "charvideoram"){ }
10      m_charvideoram(*this, "charvideoram"),
11      m_spr_old(*this, "vsystem_spr_old")
12   { }
913
1014   int m_pending_command;
1115
r18421r18422
1317   required_shared_ptr<UINT16> m_pixelram;
1418   required_shared_ptr<UINT16> m_charvideoram;
1519
20   /* devices referenced above */
21   required_device<vsystem_spr2_device> m_spr_old;
22
1623   tilemap_t *m_char_tilemap;
1724   UINT8 m_gfxbank[8];
1825   UINT16 m_charpalettebank;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team