Previous 199869 Revisions Next

r21023 Wednesday 13th February, 2013 at 10:24:35 UTC by Miodrag Milanović
Modernization of drivers part 19 (no whatsnew)
[src/mame/drivers]taito_b.c taito_l.c taito_z.c taitojc.c tank8.c tceptor.c tecmosys.c tetrisp2.c thedeep.c thief.c thunderx.c tigeroad.c tmnt.c toaplan1.c toaplan2.c topspeed.c triplhnt.c tubep.c tumbleb.c tumblep.c turbo.c twin16.c twincobr.c wardner.c
[src/mame/includes]tagteam.h tail2nos.h taito_b.h taito_f2.h taito_h.h taito_l.h taito_o.h taito_z.h taitoair.h taitojc.h taitosj.h tank8.h tankbatt.h tankbust.h targeth.h tbowl.h tceptor.h tecmo.h tecmosys.h tehkanwc.h terracre.h tetrisp2.h thedeep.h thief.h thoop2.h thunderx.h tiamc1.h tigeroad.h timelimt.h timeplt.h tmnt.h tnzs.h toaplan1.h toaplan2.h toki.h topspeed.h toypop.h tp84.h trackfld.h travrusa.h triplhnt.h tryout.h tsamurai.h tubep.h tumbleb.h tumblep.h tunhunt.h turbo.h tutankhm.h twin16.h twincobr.h
[src/mame/machine]tnzs.c toaplan1.c twincobr.c
[src/mame/video]tagteam.c tail2nos.c taito_b.c taito_f2.c taito_h.c taito_l.c taito_o.c taito_z.c taitoair.c taitojc.c taitosj.c tank8.c tankbatt.c tankbust.c targeth.c tbowl.c tceptor.c tecmo.c tecmosys.c tehkanwc.c terracre.c tetrisp2.c thedeep.c thief.c thoop2.c tiamc1.c tigeroad.c timelimt.c timeplt.c toaplan1.c toaplan2.c toki.c topspeed.c toypop.c tp84.c trackfld.c travrusa.c triplhnt.c tryout.c tsamurai.c tubep.c tumbleb.c tunhunt.c turbo.c tutankhm.c twin16.c twincobr.c

trunk/src/mame/video/tiamc1.c
r21022r21023
152152   machine().gfx[0]->set_source(m_charram);
153153}
154154
155static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
155void tiamc1_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
156156{
157   tiamc1_state *state = machine.driver_data<tiamc1_state>();
158157   int offs;
159158
160159   for (offs = 0; offs < 16; offs++)
161160   {
162161      int flipx, flipy, sx, sy, spritecode;
163162
164      sx = state->m_spriteram_x[offs] ^ 0xff;
165      sy = state->m_spriteram_y[offs] ^ 0xff;
166      flipx = !(state->m_spriteram_a[offs] & 0x08);
167      flipy = !(state->m_spriteram_a[offs] & 0x02);
168      spritecode = state->m_spriteram_n[offs] ^ 0xff;
163      sx = m_spriteram_x[offs] ^ 0xff;
164      sy = m_spriteram_y[offs] ^ 0xff;
165      flipx = !(m_spriteram_a[offs] & 0x08);
166      flipy = !(m_spriteram_a[offs] & 0x02);
167      spritecode = m_spriteram_n[offs] ^ 0xff;
169168
170      if (!(state->m_spriteram_a[offs] & 0x01))
171         drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
169      if (!(m_spriteram_a[offs] & 0x01))
170         drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
172171            spritecode,
173172            0,
174173            flipx, flipy,
r21022r21023
200199      m_bg_tilemap1->draw(bitmap, cliprect, 0, 0);
201200
202201
203   draw_sprites(machine(), bitmap, cliprect);
202   draw_sprites(bitmap, cliprect);
204203
205204   return 0;
206205}
trunk/src/mame/video/toaplan2.c
r21022r21023
5555***************************************************************************/
5656
5757
58static void truxton2_create_tx_tilemap(running_machine &machine)
58void toaplan2_state::truxton2_create_tx_tilemap()
5959{
60   toaplan2_state *state = machine.driver_data<toaplan2_state>();
6160
62   state->m_tx_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(toaplan2_state::get_text_tile_info),state), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
63   state->m_tx_tilemap->set_scroll_rows(8*32); /* line scrolling */
64   state->m_tx_tilemap->set_scroll_cols(1);
65   state->m_tx_tilemap->set_transparent_pen(0);
61   m_tx_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(toaplan2_state::get_text_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
62   m_tx_tilemap->set_scroll_rows(8*32); /* line scrolling */
63   m_tx_tilemap->set_scroll_cols(1);
64   m_tx_tilemap->set_transparent_pen(0);
6665}
6766
68static void register_state_save(running_machine &machine)
67void toaplan2_state::register_state_save()
6968{
70   toaplan2_state *state = machine.driver_data<toaplan2_state>();
7169
72   state->save_item(NAME(state->m_tx_flip));
70   save_item(NAME(m_tx_flip));
7371}
7472
7573void toaplan2_state::truxton2_postload()
r21022r21023
9997      m_vdp1->custom_priority_bitmap = &m_custom_priority_bitmap;
10098   }
10199
102   register_state_save(machine());
100   register_state_save();
103101}
104102
105103VIDEO_START_MEMBER(toaplan2_state,truxton2)
r21022r21023
110108   machine().gfx[2]->set_source(reinterpret_cast<UINT8 *>(m_tx_gfxram16.target()));
111109   machine().save().register_postload(save_prepost_delegate(FUNC(toaplan2_state::truxton2_postload), this));
112110
113   truxton2_create_tx_tilemap(machine());
111   truxton2_create_tx_tilemap();
114112   m_tx_tilemap->set_scrolldx(0x1d4 +1, 0x2a);
115113}
116114
r21022r21023
119117   VIDEO_START_CALL_MEMBER( toaplan2 );
120118
121119   /* Create the Text tilemap for this game */
122   truxton2_create_tx_tilemap(machine());
120   truxton2_create_tx_tilemap();
123121
124122   /* This bootleg has additional layer offsets on the VDP */
125123   m_vdp0->bg.extra_xoffset.normal  = -0x1d6  -26;
r21022r21023
144142   VIDEO_START_CALL_MEMBER( toaplan2 );
145143
146144   /* Create the Text tilemap for this game */
147   truxton2_create_tx_tilemap(machine());
145   truxton2_create_tx_tilemap();
148146   m_tx_tilemap->set_scrolldx(0x1d4, 0x2a);
149147}
150148
r21022r21023
153151   VIDEO_START_CALL_MEMBER( toaplan2 );
154152
155153   /* Create the Text tilemap for this game */
156   truxton2_create_tx_tilemap(machine());
154   truxton2_create_tx_tilemap();
157155   m_tx_tilemap->set_scrolldx(0x04, 0x2a);
158156}
159157
r21022r21023
168166   machine().gfx[2]->set_source(reinterpret_cast<UINT8 *>(m_tx_gfxram16.target()));
169167   machine().save().register_postload(save_prepost_delegate(FUNC(toaplan2_state::truxton2_postload), this));
170168
171   truxton2_create_tx_tilemap(machine());
169   truxton2_create_tx_tilemap();
172170   m_tx_tilemap->set_scrolldx(0x1d4, 0x2a);
173171
174172   /* Has special banking */
trunk/src/mame/video/tankbust.c
r21022r21023
176176    offset  3   xxxxxxxx    x position (8 LSB bits)
177177*/
178178
179static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
179void tankbust_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
180180{
181   tankbust_state *state = machine.driver_data<tankbust_state>();
182   UINT8 *spriteram = state->m_spriteram;
181   UINT8 *spriteram = m_spriteram;
183182   int offs;
184183
185   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
184   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
186185   {
187186      int code,color,sx,sy,flipx,flipy;
188187
r21022r21023
211210
212211      if ((spriteram[offs+1]!=4)) //otherwise - ghost sprites
213212      {
214         drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
213         drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
215214            code, color,
216215            flipx,flipy,
217216            sx,sy,0);
r21022r21023
237236#endif
238237
239238   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
240   draw_sprites(machine(), bitmap, cliprect);
239   draw_sprites(bitmap, cliprect);
241240   m_bg_tilemap->draw(bitmap, cliprect, 1, 0);
242241
243242   m_txt_tilemap->draw(bitmap, cliprect, 0,0);
trunk/src/mame/video/tetrisp2.c
r21022r21023
790790}
791791
792792// scrambled palettes?
793static inline int mypal(int x)
793inline int stepstag_state::mypal(int x)
794794{
795795//  return pal5bit(x >> 3);
796796   return pal5bit((x^0xff) >> 3);
trunk/src/mame/video/taitoair.c
r21022r21023
6969  Screen refresh
7070***************************************************************************/
7171
72static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
72void taitoair_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
7373{
7474   /* Y chain size is 16/32?/64/64? pixels. X chain size
7575      is always 64 pixels. */
7676
77   taitoair_state *state = machine.driver_data<taitoair_state>();
78   address_space &space = machine.driver_data()->generic_space();
77   address_space &space = machine().driver_data()->generic_space();
7978   static const int size[] = { 1, 2, 4, 4 };
8079   int x0, y0, x, y, dx, dy, ex, ey, zx, zy;
8180   int ysize;
r21022r21023
9089      if (offs <  0x01b0 && priority == 0)    continue;
9190      if (offs >= 0x01b0 && priority == 1)    continue;
9291
93      x0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
94      y0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
95      zoomx     = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
96      zoomy     = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 2, 0xffff) & 0x007f);
97      tile_offs = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
98      ysize     = size[(tc0080vco_sprram_r(state->m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
92      x0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
93      y0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
94      zoomx     = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
95      zoomy     = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 2, 0xffff) & 0x007f);
96      tile_offs = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
97      ysize     = size[(tc0080vco_sprram_r(m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
9998
10099      if (tile_offs)
101100      {
r21022r21023
131130         if (x0 >= 0x200) x0 -= 0x400;
132131         if (y0 >= 0x200) y0 -= 0x400;
133132
134         if (tc0080vco_flipscreen_r(state->m_tc0080vco))
133         if (tc0080vco_flipscreen_r(m_tc0080vco))
135134         {
136135            x0 = 497 - x0;
137136            y0 = 498 - y0;
r21022r21023
154153               {
155154                  int tile, color, flipx, flipy;
156155
157                  tile  = tc0080vco_cram_0_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
158                  color = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
159                  flipx = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
160                  flipy = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
156                  tile  = tc0080vco_cram_0_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
157                  color = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
158                  flipx = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
159                  flipy = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
161160
162                  if (tc0080vco_flipscreen_r(state->m_tc0080vco))
161                  if (tc0080vco_flipscreen_r(m_tc0080vco))
163162                  {
164163                     flipx ^= 0x0040;
165164                     flipy ^= 0x0080;
166165                  }
167166
168167                  drawgfxzoom_transpen( bitmap, cliprect,
169                           machine.gfx[0],
168                           machine().gfx[0],
170169                           tile,
171170                           color,
172171                           flipx, flipy,
r21022r21023
183182   }
184183}
185184
186static void fill_slope( bitmap_ind16 &bitmap, const rectangle &cliprect, int color, INT32 x1, INT32 x2, INT32 sl1, INT32 sl2, INT32 y1, INT32 y2, INT32 *nx1, INT32 *nx2 )
185void taitoair_state::fill_slope( bitmap_ind16 &bitmap, const rectangle &cliprect, int color, INT32 x1, INT32 x2, INT32 sl1, INT32 sl2, INT32 y1, INT32 y2, INT32 *nx1, INT32 *nx2 )
187186{
188187   if (y1 > cliprect.max_y)
189188      return;
r21022r21023
258257   *nx2 = x2;
259258}
260259
261static void fill_poly( bitmap_ind16 &bitmap, const rectangle &cliprect, const struct taitoair_poly *q )
260void taitoair_state::fill_poly( bitmap_ind16 &bitmap, const rectangle &cliprect, const struct taitoair_poly *q )
262261{
263262   INT32 sl1, sl2, cury, limy, x1, x2;
264263   int pmin, pmax, i, ps1, ps2;
r21022r21023
441440}
442441
443442
444void multVecMtx(const INT16* vec4, const float* m, float* result)
443void taitoair_state::multVecMtx(const INT16* vec4, const float* m, float* result)
445444{
446445#define M(row,col)  m[col*4+row]
447446   result[0] = vec4[0]*M(0,0) + vec4[1]*M(1,0) + vec4[2]*M(2,0) + vec4[3]*M(3,0);
r21022r21023
455454#undef M
456455}
457456
458int projectEyeCoordToScreen(float* projectionMatrix,
459                        const int Res,
460                        INT16* eyePoint3d,
461                        int type)
457int taitoair_state::projectEyeCoordToScreen(float* projectionMatrix,const int Res,INT16* eyePoint3d,int type)
462458{
463459   /* Return (-1, -1) if the eye point is behind camera */
464460   int res = -10000;
r21022r21023
483479   return res;
484480}
485481
486void airInfernoFrustum(const INT16 leftExtent, const INT16 bottomExtent, float* m)
482void taitoair_state::airInfernoFrustum(const INT16 leftExtent, const INT16 bottomExtent, float* m)
487483{
488484   /* Hard-coded near and far clipping planes :( */
489485   float nearZ = 1.0f;
r21022r21023
598594
599595   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 0, 0, 0);
600596
601   draw_sprites(machine(), bitmap, cliprect, 0);
597   draw_sprites(bitmap, cliprect, 0);
602598
603599   copybitmap_trans(bitmap, *m_framebuffer[1], 0, 0, 0, 0, cliprect, 0);
604600
605601   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 1, 0, 0);
606602
607   draw_sprites(machine(), bitmap, cliprect, 1);
603   draw_sprites(bitmap, cliprect, 1);
608604
609605   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 2, 0, 0);
610606
trunk/src/mame/video/tceptor.c
r21022r21023
8787
8888/*******************************************************************/
8989
90INLINE int get_tile_addr(int tile_index)
90inline int tceptor_state::get_tile_addr(int tile_index)
9191{
9292   int x = tile_index / 28;
9393   int y = tile_index % 28;
r21022r21023
224224
225225/*******************************************************************/
226226
227static void decode_bg(running_machine &machine, const char * region)
227void tceptor_state::decode_bg(const char * region)
228228{
229   tceptor_state *state = machine.driver_data<tceptor_state>();
230229   static const gfx_layout bg_layout =
231230   {
232231      8, 8,
r21022r21023
238237      128
239238   };
240239
241   int gfx_index = state->m_bg;
242   UINT8 *src = machine.root_device().memregion(region)->base() + 0x8000;
240   int gfx_index = m_bg;
241   UINT8 *src = machine().root_device().memregion(region)->base() + 0x8000;
243242   UINT8 *buffer;
244243   int len = 0x8000;
245244   int i;
246245
247   buffer = auto_alloc_array(machine, UINT8, len);
246   buffer = auto_alloc_array(machine(), UINT8, len);
248247
249248   /* expand rom tc2-19.10d */
250249   for (i = 0; i < len / 2; i++)
r21022r21023
254253   }
255254
256255   memcpy(src, buffer, len);
257   auto_free(machine, buffer);
256   auto_free(machine(), buffer);
258257
259258   /* decode the graphics */
260   machine.gfx[gfx_index] = auto_alloc(machine, gfx_element(machine, bg_layout, machine.root_device().memregion(region)->base(), 64, 2048));
259   machine().gfx[gfx_index] = auto_alloc(machine(), gfx_element(machine(), bg_layout, machine().root_device().memregion(region)->base(), 64, 2048));
261260}
262261
263static void decode_sprite(running_machine &machine, int gfx_index, const gfx_layout *layout, const void *data)
262void tceptor_state::decode_sprite(int gfx_index, const gfx_layout *layout, const void *data)
264263{
265264   /* decode the graphics */
266   machine.gfx[gfx_index] = auto_alloc(machine, gfx_element(machine, *layout, (const UINT8 *)data, 64, 1024));
265   machine().gfx[gfx_index] = auto_alloc(machine(), gfx_element(machine(), *layout, (const UINT8 *)data, 64, 1024));
267266}
268267
269268// fix sprite order
270static void decode_sprite16(running_machine &machine, const char * region)
269void tceptor_state::decode_sprite16(const char * region)
271270{
272   tceptor_state *state = machine.driver_data<tceptor_state>();
273271   static const gfx_layout spr16_layout =
274272   {
275273      16, 16,
r21022r21023
287285      2*16*16
288286   };
289287
290   UINT8 *src = machine.root_device().memregion(region)->base();
291   int len = machine.root_device().memregion(region)->bytes();
288   UINT8 *src = machine().root_device().memregion(region)->base();
289   int len = machine().root_device().memregion(region)->bytes();
292290   UINT8 *dst;
293291   int i, y;
294292
295   dst = auto_alloc_array(machine, UINT8, len);
293   dst = auto_alloc_array(machine(), UINT8, len);
296294
297295   for (i = 0; i < len / (4*4*16); i++)
298296      for (y = 0; y < 16; y++)
r21022r21023
311309               4);
312310      }
313311
314   decode_sprite(machine, state->m_sprite16, &spr16_layout, dst);
312   decode_sprite(m_sprite16, &spr16_layout, dst);
315313}
316314
317315// fix sprite order
318static void decode_sprite32(running_machine &machine, const char * region)
316void tceptor_state::decode_sprite32(const char * region)
319317{
320   tceptor_state *state = machine.driver_data<tceptor_state>();
321318   static const gfx_layout spr32_layout =
322319   {
323320      32, 32,
r21022r21023
339336      2*32*32
340337   };
341338
342   UINT8 *src = machine.root_device().memregion(region)->base();
343   int len = machine.root_device().memregion(region)->bytes();
339   UINT8 *src = machine().root_device().memregion(region)->base();
340   int len = machine().root_device().memregion(region)->bytes();
344341   int total = spr32_layout.total;
345342   int size = spr32_layout.charincrement / 8;
346343   UINT8 *dst;
347344   int i;
348345
349   dst = auto_alloc_array(machine, UINT8, len);
346   dst = auto_alloc_array(machine(), UINT8, len);
350347
351348   memset(dst, 0, len);
352349
r21022r21023
361358      memcpy(&dst[size * (i + total)], &src[size * (code + total)], size);
362359   }
363360
364   decode_sprite(machine, state->m_sprite32, &spr32_layout, dst);
361   decode_sprite(m_sprite32, &spr32_layout, dst);
365362}
366363
367364void tceptor_state::video_start()
r21022r21023
377374   assert(gfx_index + 4 <= MAX_GFX_ELEMENTS);
378375
379376   m_bg = gfx_index++;
380   decode_bg(machine(), "gfx2");
377   decode_bg("gfx2");
381378
382379   m_sprite16 = gfx_index++;
383   decode_sprite16(machine(), "gfx3");
380   decode_sprite16("gfx3");
384381
385382   m_sprite32 = gfx_index++;
386   decode_sprite32(machine(), "gfx4");
383   decode_sprite32("gfx4");
387384
388385   /* allocate temp bitmaps */
389386   machine().primary_screen->register_screen_bitmap(m_temp_bitmap);
r21022r21023
430427    z: zoom y
431428*/
432429
433static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_priority)
430void tceptor_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_priority)
434431{
435   tceptor_state *state = machine.driver_data<tceptor_state>();
436   UINT16 *mem1 = &state->m_sprite_ram_buffered[0x000/2];
437   UINT16 *mem2 = &state->m_sprite_ram_buffered[0x100/2];
432   UINT16 *mem1 = &m_sprite_ram_buffered[0x000/2];
433   UINT16 *mem2 = &m_sprite_ram_buffered[0x100/2];
438434   int need_mask = 0;
439435   int i;
440436
r21022r21023
456452
457453         if (mem2[0 + i] & 0x2000)
458454         {
459            gfx = state->m_sprite32;
455            gfx = m_sprite32;
460456            code = mem1[0 + i] & 0x3ff;
461457
462458         }
463459         else
464460         {
465            gfx = state->m_sprite16;
461            gfx = m_sprite16;
466462            code = mem1[0 + i] & 0x1ff;
467463            scaley *= 2;
468464         }
469465
470         if (state->m_is_mask_spr[color])
466         if (m_is_mask_spr[color])
471467         {
472468            if (!need_mask)
473469               // backup previous bitmap
474               copybitmap(state->m_temp_bitmap, bitmap, 0, 0, 0, 0, cliprect);
470               copybitmap(m_temp_bitmap, bitmap, 0, 0, 0, 0, cliprect);
475471
476472            need_mask = 1;
477473         }
r21022r21023
485481
486482         drawgfxzoom_transmask(bitmap,
487483                  cliprect,
488                  machine.gfx[gfx],
484                  machine().gfx[gfx],
489485                  code,
490486                  color,
491487                  flipx, flipy,
492488                  x, y,
493489                  scalex,
494490                  scaley,
495                  colortable_get_transpen_mask(machine.colortable, machine.gfx[gfx], color, SPR_TRANS_COLOR));
491                  colortable_get_transpen_mask(machine().colortable, machine().gfx[gfx], color, SPR_TRANS_COLOR));
496492      }
497493   }
498494
r21022r21023
503499
504500      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
505501         for (y = cliprect.min_y; y <= cliprect.max_y; y++)
506            if (colortable_entry_get_value(machine.colortable, bitmap.pix16(y, x)) == SPR_MASK_COLOR)
502            if (colortable_entry_get_value(machine().colortable, bitmap.pix16(y, x)) == SPR_MASK_COLOR)
507503               // restore pixel
508               bitmap.pix16(y, x) = state->m_temp_bitmap.pix16(y, x);
504               bitmap.pix16(y, x) = m_temp_bitmap.pix16(y, x);
509505   }
510506}
511507
r21022r21023
534530   {
535531      m_c45_road->draw(bitmap, cliprect, pri * 2);
536532      m_c45_road->draw(bitmap, cliprect, pri * 2 + 1);
537      draw_sprites(machine(), bitmap, cliprect, pri);
533      draw_sprites(bitmap, cliprect, pri);
538534   }
539535
540536   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
trunk/src/mame/video/tagteam.c
r21022r21023
140140         8, 8, 32, 32);
141141}
142142
143static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
143void tagteam_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
144144{
145   tagteam_state *state = machine.driver_data<tagteam_state>();
146145   int offs;
147146
148147   for (offs = 0; offs < 0x20; offs += 4)
149148   {
150      int spritebank = (state->m_videoram[offs] & 0x30) << 4;
151      int code = state->m_videoram[offs + 1] + 256 * spritebank;
152      int color = state->m_palettebank << 1 | 1;
153      int flipx = state->m_videoram[offs] & 0x04;
154      int flipy = state->m_videoram[offs] & 0x02;
155      int sx = 240 - state->m_videoram[offs + 3];
156      int sy = 240 - state->m_videoram[offs + 2];
149      int spritebank = (m_videoram[offs] & 0x30) << 4;
150      int code = m_videoram[offs + 1] + 256 * spritebank;
151      int color = m_palettebank << 1 | 1;
152      int flipx = m_videoram[offs] & 0x04;
153      int flipy = m_videoram[offs] & 0x02;
154      int sx = 240 - m_videoram[offs + 3];
155      int sy = 240 - m_videoram[offs + 2];
157156
158      if (!(state->m_videoram[offs] & 0x01)) continue;
157      if (!(m_videoram[offs] & 0x01)) continue;
159158
160      if (state->flip_screen())
159      if (flip_screen())
161160      {
162161         sx = 240 - sx;
163162         sy = 240 - sy;
r21022r21023
166165      }
167166
168167      drawgfx_transpen(bitmap, cliprect,
169         machine.gfx[1],
168         machine().gfx[1],
170169         code, color,
171170         flipx, flipy,
172171         sx, sy, 0);
173172
174173      /* Wrap around */
175174
176      code = state->m_videoram[offs + 0x20] + 256 * spritebank;
177      color = state->m_palettebank;
178      sy += (state->flip_screen() ? -256 : 256);
175      code = m_videoram[offs + 0x20] + 256 * spritebank;
176      color = m_palettebank;
177      sy += (flip_screen() ? -256 : 256);
179178
180179      drawgfx_transpen(bitmap, cliprect,
181         machine.gfx[1],
180         machine().gfx[1],
182181         code, color,
183182         flipx, flipy,
184183         sx, sy, 0);
r21022r21023
188187UINT32 tagteam_state::screen_update_tagteam(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
189188{
190189   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
191   draw_sprites(machine(), bitmap, cliprect);
190   draw_sprites(bitmap, cliprect);
192191   return 0;
193192}
trunk/src/mame/video/timelimt.c
r21022r21023
109109}
110110
111111
112static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
112void timelimt_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
113113{
114   timelimt_state *state = machine.driver_data<timelimt_state>();
115   UINT8 *spriteram = state->m_spriteram;
114   UINT8 *spriteram = m_spriteram;
116115   int offs;
117116
118   for( offs = state->m_spriteram.bytes(); offs >= 0; offs -= 4 )
117   for( offs = m_spriteram.bytes(); offs >= 0; offs -= 4 )
119118   {
120119      int sy = 240 - spriteram[offs];
121120      int sx = spriteram[offs+3];
r21022r21023
127126      code += ( attr & 0x80 ) ? 0x40 : 0x00;
128127      code += ( attr & 0x40 ) ? 0x80 : 0x00;
129128
130      drawgfx_transpen( bitmap, cliprect,machine.gfx[2],
129      drawgfx_transpen( bitmap, cliprect,machine().gfx[2],
131130            code,
132131            attr & 7,
133132            flipx,flipy,
r21022r21023
142141   m_bg_tilemap->set_scrolly(0, m_scrolly);
143142   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
144143
145   draw_sprites(machine(), bitmap, cliprect);
144   draw_sprites(bitmap, cliprect);
146145
147146   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
148147   return 0;
trunk/src/mame/video/tail2nos.c
r21022r21023
136136
137137***************************************************************************/
138138
139static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
139void tail2nos_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
140140{
141   tail2nos_state *state = machine.driver_data<tail2nos_state>();
142   UINT16 *spriteram = state->m_spriteram;
141   UINT16 *spriteram = m_spriteram;
143142   int offs;
144143
145144
146   for (offs = 0; offs < state->m_spriteram.bytes() / 2; offs += 4)
145   for (offs = 0; offs < m_spriteram.bytes() / 2; offs += 4)
147146   {
148147      int sx, sy, flipx, flipy, code, color;
149148
r21022r21023
159158      flipy = spriteram[offs + 2] & 0x0800;
160159
161160      drawgfx_transpen(bitmap,/* placement relative to zoom layer verified on the real thing */
162            cliprect,machine.gfx[1],
161            cliprect,machine().gfx[1],
163162            code,
164163            40 + color,
165164            flipx,flipy,
r21022r21023
172171   if (m_video_enable)
173172   {
174173      k051316_zoom_draw(m_k051316, bitmap, cliprect, 0, 0);
175      draw_sprites(machine(), bitmap, cliprect);
174      draw_sprites(bitmap, cliprect);
176175      m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
177176   }
178177   else
trunk/src/mame/video/turbo.c
r21022r21023
88#include "includes/turbo.h"
99#include "video/resnet.h"
1010
11
12
13struct sprite_info
14{
15   UINT16  ve;                 /* VE0-15 signals for this row */
16   UINT8   lst;                /* LST0-7 signals for this row */
17   UINT32  latched[8];         /* latched pixel data */
18   UINT8   plb[8];             /* latched PLB state */
19   UINT32  offset[8];          /* current offset for this row */
20   UINT32  frac[8];            /* leftover fraction */
21   UINT32  step[8];            /* stepping value */
22};
23
2411static const UINT32 sprite_expand[16] =
2512{
2613   0x00000000, 0x00000001, 0x00000100, 0x00000101,
r21022r21023
220207 *
221208 *************************************/
222209
223INLINE UINT32 sprite_xscale(UINT8 dacinput, double vr1, double vr2, double cext)
210inline UINT32 turbo_state::sprite_xscale(UINT8 dacinput, double vr1, double vr2, double cext)
224211{
225212   /* compute the effective pixel clock for this sprite */
226213   /* thanks to Frank Palazzolo for figuring out this logic */
r21022r21023
275262 *
276263 *************************************/
277264
278static void turbo_prepare_sprites(running_machine &machine, turbo_state *state, UINT8 y, sprite_info *info)
265void turbo_state::turbo_prepare_sprites(UINT8 y, sprite_info *info)
279266{
280   const UINT8 *pr1119 = machine.root_device().memregion("proms")->base() + 0x200;
267   const UINT8 *pr1119 = machine().root_device().memregion("proms")->base() + 0x200;
281268   int sprnum;
282269
283270   /* initialize the line enable signals to 0 */
r21022r21023
287274   /* compute the sprite information, which was done on the previous scanline during HBLANK */
288275   for (sprnum = 0; sprnum < 16; sprnum++)
289276   {
290      UINT8 *rambase = &state->m_spriteram[sprnum * 0x10];
277      UINT8 *rambase = &m_spriteram[sprnum * 0x10];
291278      int level = sprnum & 7;
292279      UINT8 clo, chi;
293280      UINT32 sum;
r21022r21023
335322                 VR1 = 310 Ohm
336323                 VR2 = 910 Ohm
337324         */
338         info->step[level] = sprite_xscale(xscale, 1.0e3 * machine.root_device().ioport("VR1")->read() / 100.0, 1.0e3 * machine.root_device().ioport("VR2")->read() / 100.0, 100e-12);
325         info->step[level] = sprite_xscale(xscale, 1.0e3 * machine().root_device().ioport("VR1")->read() / 100.0, 1.0e3 * machine().root_device().ioport("VR2")->read() / 100.0, 100e-12);
339326      }
340327   }
341328}
342329
343330
344static UINT32 turbo_get_sprite_bits(const UINT8 *sprite_gfxdata, UINT8 road, sprite_info *sprinfo)
331UINT32 turbo_state::turbo_get_sprite_bits(const UINT8 *sprite_gfxdata, UINT8 road, sprite_info *sprinfo)
345332{
346333   UINT8 sprlive = sprinfo->lst;
347334   UINT32 sprdata = 0;
r21022r21023
427414
428415      /* compute the sprite information; we use y-1 since this info was computed during HBLANK */
429416      /* on the previous scanline */
430      turbo_prepare_sprites(machine(), this, y, &sprinfo);
417      turbo_prepare_sprites(y, &sprinfo);
431418
432419      /* loop over columns */
433420      for (x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE)
r21022r21023
632619
633620*/
634621
635static void subroc3d_prepare_sprites(running_machine &machine, turbo_state *state, UINT8 y, sprite_info *info)
622void turbo_state::subroc3d_prepare_sprites(UINT8 y, sprite_info *info)
636623{
637   const UINT8 *pr1449 = machine.root_device().memregion("proms")->base() + 0x300;
624   const UINT8 *pr1449 = machine().root_device().memregion("proms")->base() + 0x300;
638625   int sprnum;
639626
640627   /* initialize the line enable signals to 0 */
r21022r21023
644631   /* compute the sprite information, which was done on the previous scanline during HBLANK */
645632   for (sprnum = 0; sprnum < 16; sprnum++)
646633   {
647      UINT8 *rambase = &state->m_spriteram[sprnum * 8];
634      UINT8 *rambase = &m_spriteram[sprnum * 8];
648635      int level = sprnum & 7;
649636      UINT8 clo, chi;
650637      UINT32 sum;
r21022r21023
692679}
693680
694681
695static UINT32 subroc3d_get_sprite_bits(const UINT8 *sprite_gfxdata, sprite_info *sprinfo, UINT8 *plb)
682UINT32 turbo_state::subroc3d_get_sprite_bits(const UINT8 *sprite_gfxdata, sprite_info *sprinfo, UINT8 *plb)
696683{
697684   /* see logic on each sprite:
698685       END = (CDA == 1 && (CDA ^ CDB) == 0 && (CDC ^ CDD) == 0)
r21022r21023
767754
768755      /* compute the sprite information; we use y-1 since this info was computed during HBLANK */
769756      /* on the previous scanline */
770      subroc3d_prepare_sprites(machine(), this, y, &sprinfo);
757      subroc3d_prepare_sprites(y, &sprinfo);
771758
772759      /* loop over columns */
773760      for (x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE)
r21022r21023
849836 *
850837 *************************************/
851838
852static void buckrog_prepare_sprites(running_machine &machine, turbo_state *state, UINT8 y, sprite_info *info)
839void turbo_state::buckrog_prepare_sprites(UINT8 y, sprite_info *info)
853840{
854   const UINT8 *pr5196 = machine.root_device().memregion("proms")->base() + 0x100;
841   const UINT8 *pr5196 = machine().root_device().memregion("proms")->base() + 0x100;
855842   int sprnum;
856843
857844   /* initialize the line enable signals to 0 */
r21022r21023
861848   /* compute the sprite information, which was done on the previous scanline during HBLANK */
862849   for (sprnum = 0; sprnum < 16; sprnum++)
863850   {
864      UINT8 *rambase = &state->m_spriteram[sprnum * 8];
851      UINT8 *rambase = &m_spriteram[sprnum * 8];
865852      int level = sprnum & 7;
866853      UINT8 clo, chi;
867854      UINT32 sum;
r21022r21023
910897}
911898
912899
913static UINT32 buckrog_get_sprite_bits(const UINT8 *sprite_gfxdata, sprite_info *sprinfo, UINT8 *plb)
900UINT32 turbo_state::buckrog_get_sprite_bits(const UINT8 *sprite_gfxdata, sprite_info *sprinfo, UINT8 *plb)
914901{
915902   /* see logic on each sprite:
916903       END = (CDA == 1 && (CDA ^ CDB) == 0 && (CDC ^ CDD) == 0)
r21022r21023
985972
986973      /* compute the sprite information; we use y-1 since this info was computed during HBLANK */
987974      /* on the previous scanline */
988      buckrog_prepare_sprites(machine(), this, y, &sprinfo);
975      buckrog_prepare_sprites(y, &sprinfo);
989976
990977      /* loop over columns */
991978      for (x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE)
trunk/src/mame/video/tsamurai.c
r21022r21023
126126
127127***************************************************************************/
128128
129static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
129void tsamurai_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
130130{
131   tsamurai_state *state = machine.driver_data<tsamurai_state>();
132   UINT8 *spriteram = state->m_spriteram;
133   gfx_element *gfx = machine.gfx[2];
131   UINT8 *spriteram = m_spriteram;
132   gfx_element *gfx = machine().gfx[2];
134133   const UINT8 *source = spriteram+32*4-4;
135134   const UINT8 *finish = spriteram; /* ? */
136   state->m_flicker = 1-state->m_flicker;
135   m_flicker = 1-m_flicker;
137136
138137   while( source>=finish )
139138   {
r21022r21023
165164      /* So I'm using this specific check. -kal 11 jul 2002 */
166165//      if(sprite_type == 1) sy=sy+2;
167166
168      if( state->flip_screen() )
167      if( flip_screen() )
169168      {
170169         drawgfx_transpen( bitmap,cliprect,gfx,
171170            sprite_number&0x7f,
r21022r21023
208207   */
209208   bitmap.fill(m_bgcolor, cliprect);
210209   m_background->draw(bitmap, cliprect, 0,0);
211   draw_sprites(machine(), bitmap,cliprect);
210   draw_sprites(bitmap,cliprect);
212211   m_foreground->draw(bitmap, cliprect, 0,0);
213212   return 0;
214213}
r21022r21023
260259   #endif
261260
262261   m_foreground->draw(bitmap, cliprect, 0,0);
263   draw_sprites(machine(),bitmap,cliprect);
262   draw_sprites(bitmap,cliprect);
264263   return 0;
265264}
trunk/src/mame/video/taito_h.c
r21022r21023
7070  Screen refresh
7171***************************************************************************/
7272
73static void syvalion_draw_sprites( running_machine &machine,bitmap_ind16 &bitmap, const rectangle &cliprect )
73void taitoh_state::syvalion_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
7474{
7575   /* Y chain size is 16/32?/64/64? pixels. X chain size
7676      is always 64 pixels. */
7777
78   taitoh_state *state = machine.driver_data<taitoh_state>();
79   address_space &space = machine.driver_data()->generic_space();
78   address_space &space = machine().driver_data()->generic_space();
8079   static const int size[] = { 1, 2, 4, 4 };
8180   int x0, y0, x, y, dx, ex, zx;
8281   int ysize;
r21022r21023
8786
8887   for (offs = 0x03f8 / 2; offs >= 0; offs -= 0x008 / 2)
8988   {
90      x0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
91      y0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
92      zoomx     = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
93      tile_offs = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
94      ysize     = size[(tc0080vco_sprram_r(state->m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
89      x0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
90      y0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
91      zoomx     = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
92      tile_offs = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
93      ysize     = size[(tc0080vco_sprram_r(m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
9594
9695      if (tile_offs)
9796      {
r21022r21023
113112         if (x0 >= 0x200) x0 -= 0x400;
114113         if (y0 >= 0x200) y0 -= 0x400;
115114
116         if (tc0080vco_flipscreen_r(state->m_tc0080vco))
115         if (tc0080vco_flipscreen_r(m_tc0080vco))
117116         {
118117            x0 = 497 - x0;
119118            y0 = 498 - y0;
r21022r21023
135134               {
136135                  int tile, color, flipx, flipy;
137136
138                  tile  = tc0080vco_cram_0_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
139                  color = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
140                  flipx = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
141                  flipy = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
137                  tile  = tc0080vco_cram_0_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
138                  color = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
139                  flipx = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
140                  flipy = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
142141
143                  if (tc0080vco_flipscreen_r(state->m_tc0080vco))
142                  if (tc0080vco_flipscreen_r(m_tc0080vco))
144143                  {
145144                     flipx ^= 0x0040;
146145                     flipy ^= 0x0080;
147146                  }
148147
149148                  drawgfxzoom_transpen( bitmap, cliprect,
150                           machine.gfx[0],
149                           machine().gfx[0],
151150                           tile,
152151                           color,
153152                           flipx, flipy,
r21022r21023
164163   }
165164}
166165
167static void recordbr_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
166void taitoh_state::recordbr_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
168167{
169168   /* Y chain size is 16/32?/64/64? pixels. X chain size
170169      is always 64 pixels. */
171170
172   taitoh_state *state = machine.driver_data<taitoh_state>();
173   address_space &space = machine.driver_data()->generic_space();
171   address_space &space = machine().driver_data()->generic_space();
174172   static const int size[] = { 1, 2, 4, 4 };
175173   int x0, y0, x, y, dx, dy, ex, ey, zx, zy;
176174   int ysize;
r21022r21023
184182      if (offs <  0x01b0 && priority == 0)    continue;
185183      if (offs >= 0x01b0 && priority == 1)    continue;
186184
187      x0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
188      y0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
189      zoomx     = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
190      zoomy     = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 2, 0xffff) & 0x007f);
191      tile_offs = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
192      ysize     = size[(tc0080vco_sprram_r(state->m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
185      x0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
186      y0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
187      zoomx     = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
188      zoomy     = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 2, 0xffff) & 0x007f);
189      tile_offs = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
190      ysize     = size[(tc0080vco_sprram_r(m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
193191
194192      if (tile_offs)
195193      {
r21022r21023
225223         if (x0 >= 0x200) x0 -= 0x400;
226224         if (y0 >= 0x200) y0 -= 0x400;
227225
228         if (tc0080vco_flipscreen_r(state->m_tc0080vco))
226         if (tc0080vco_flipscreen_r(m_tc0080vco))
229227         {
230228            x0 = 497 - x0;
231229            y0 = 498 - y0;
r21022r21023
248246               {
249247                  int tile, color, flipx, flipy;
250248
251                  tile  = tc0080vco_cram_0_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
252                  color = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
253                  flipx = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
254                  flipy = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
249                  tile  = tc0080vco_cram_0_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
250                  color = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
251                  flipx = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
252                  flipy = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
255253
256                  if (tc0080vco_flipscreen_r(state->m_tc0080vco))
254                  if (tc0080vco_flipscreen_r(m_tc0080vco))
257255                  {
258256                     flipx ^= 0x0040;
259257                     flipy ^= 0x0080;
260258                  }
261259
262260                  drawgfxzoom_transpen( bitmap, cliprect,
263                           machine.gfx[0],
261                           machine().gfx[0],
264262                           tile,
265263                           color,
266264                           flipx, flipy,
r21022r21023
277275   }
278276}
279277
280static void dleague_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
278void taitoh_state::dleague_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
281279{
282280   /* Y chain size is 16/32?/64/64? pixels. X chain size
283281      is always 64 pixels. */
284282
285   taitoh_state *state = machine.driver_data<taitoh_state>();
286   address_space &space = machine.driver_data()->generic_space();
283   address_space &space = machine().driver_data()->generic_space();
287284   static const int size[] = { 1, 2, 4, 4 };
288285   int x0, y0, x, y, dx, ex, zx;
289286   int ysize;
r21022r21023
295292
296293   for (offs = 0x03f8 / 2; offs >= 0; offs -= 0x008 / 2)
297294   {
298      x0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
299      y0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
300      zoomx     = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
301      tile_offs = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
302      pribit    = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 0, 0xffff) & 0x1000) >> 12;
303      ysize     = size[(tc0080vco_sprram_r(state->m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
295      x0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
296      y0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
297      zoomx     = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
298      tile_offs = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
299      pribit    = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 0, 0xffff) & 0x1000) >> 12;
300      ysize     = size[(tc0080vco_sprram_r(m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
304301
305302      if (tile_offs)
306303      {
r21022r21023
320317            zx = (dx + ex) << 12;
321318         }
322319
323         if (tc0080vco_scrram_r(state->m_tc0080vco, space, 0x0002, 0xffff) & 0x8000)
320         if (tc0080vco_scrram_r(m_tc0080vco, space, 0x0002, 0xffff) & 0x8000)
324321            pribit = 1;
325322
326323         if (x0 >= 0x200) x0 -= 0x400;
327324         if (y0 >= 0x200) y0 -= 0x400;
328325
329         if (tc0080vco_flipscreen_r(state->m_tc0080vco))
326         if (tc0080vco_flipscreen_r(m_tc0080vco))
330327         {
331328            x0 = 497 - x0;
332329            y0 = 498 - y0;
r21022r21023
350347                  {
351348                     int tile, color, flipx, flipy;
352349
353                     tile  = tc0080vco_cram_0_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
354                     color = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
355                     flipx = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
356                     flipy = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
350                     tile  = tc0080vco_cram_0_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
351                     color = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
352                     flipx = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
353                     flipy = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
357354
358355
359                     if (tc0080vco_flipscreen_r(state->m_tc0080vco))
356                     if (tc0080vco_flipscreen_r(m_tc0080vco))
360357                     {
361358                        flipx ^= 0x0040;
362359                        flipy ^= 0x0080;
363360                     }
364361
365362                     drawgfxzoom_transpen( bitmap, cliprect,
366                              machine.gfx[0],
363                              machine().gfx[0],
367364                              tile,
368365                              color,
369366                              flipx, flipy,
r21022r21023
383380
384381
385382
386static void taitoh_log_vram(running_machine &machine)
383void taitoh_state::taitoh_log_vram()
387384{
388385#ifdef MAME_DEBUG
389386   // null function: the necessary pointers are now internal to taitoic.c
r21022r21023
398395{
399396   tc0080vco_tilemap_update(m_tc0080vco);
400397
401   taitoh_log_vram(machine());
398   taitoh_log_vram();
402399
403400   bitmap.fill(0, cliprect);
404401
405402   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
406403   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 1, 0, 0);
407   syvalion_draw_sprites(machine(), bitmap,cliprect);
404   syvalion_draw_sprites(bitmap,cliprect);
408405   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 2, 0, 0);
409406
410407   return 0;
r21022r21023
415412{
416413   tc0080vco_tilemap_update(m_tc0080vco);
417414
418   taitoh_log_vram(machine());
415   taitoh_log_vram();
419416
420417   bitmap.fill(0, cliprect);
421418
r21022r21023
423420   if (!machine().input().code_pressed(KEYCODE_A))
424421      tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
425422   if (!machine().input().code_pressed(KEYCODE_S))
426      recordbr_draw_sprites(machine(), bitmap, cliprect, 0);
423      recordbr_draw_sprites(bitmap, cliprect, 0);
427424   if (!machine().input().code_pressed(KEYCODE_D))
428425      tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 1, 0, 0);
429426   if (!machine().input().code_pressed(KEYCODE_F))
430      recordbr_draw_sprites(machine(), bitmap, cliprect, 1);
427      recordbr_draw_sprites(bitmap, cliprect, 1);
431428#else
432429   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
433   recordbr_draw_sprites(machine(), bitmap, cliprect, 0);
430   recordbr_draw_sprites(bitmap, cliprect, 0);
434431   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 1, 0, 0);
435   recordbr_draw_sprites(machine(), bitmap, cliprect, 1);
432   recordbr_draw_sprites(bitmap, cliprect, 1);
436433#endif
437434
438435   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 2, 0, 0);
r21022r21023
444441{
445442   tc0080vco_tilemap_update(m_tc0080vco);
446443
447   taitoh_log_vram(machine());
444   taitoh_log_vram();
448445
449446   bitmap.fill(0, cliprect);
450447
r21022r21023
459456      dleague_draw_sprites(machine(), bitmap, cliprect, 1);
460457#else
461458   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
462   dleague_draw_sprites (machine(), bitmap, cliprect, 0);
459   dleague_draw_sprites (bitmap, cliprect, 0);
463460   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 1, 0, 0);
464   dleague_draw_sprites (machine(), bitmap, cliprect, 1);
461   dleague_draw_sprites (bitmap, cliprect, 1);
465462#endif
466463
467464   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 2, 0, 0);
trunk/src/mame/video/tp84.c
r21022r21023
149149}
150150
151151
152static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
152void tp84_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
153153{
154   tp84_state *state = machine.driver_data<tp84_state>();
155154   int offs;
156   int palette_base = ((*state->m_palette_bank & 0x07) << 4);
155   int palette_base = ((*m_palette_bank & 0x07) << 4);
157156
158157   for (offs = 0x5c; offs >= 0; offs -= 4)
159158   {
160      int x = state->m_spriteram[offs];
161      int y = 240 - state->m_spriteram[offs + 3];
159      int x = m_spriteram[offs];
160      int y = 240 - m_spriteram[offs + 3];
162161
163      int code = state->m_spriteram[offs + 1];
164      int color = palette_base | (state->m_spriteram[offs + 2] & 0x0f);
165      int flip_x = ~state->m_spriteram[offs + 2] & 0x40;
166      int flip_y =  state->m_spriteram[offs + 2] & 0x80;
162      int code = m_spriteram[offs + 1];
163      int color = palette_base | (m_spriteram[offs + 2] & 0x0f);
164      int flip_x = ~m_spriteram[offs + 2] & 0x40;
165      int flip_y =  m_spriteram[offs + 2] & 0x80;
167166
168      drawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flip_x, flip_y, x, y,
169            colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, palette_base));
167      drawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flip_x, flip_y, x, y,
168            colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, palette_base));
170169
171170   }
172171}
r21022r21023
189188   }
190189
191190   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
192   draw_sprites(machine(), bitmap, cliprect);
191   draw_sprites(bitmap, cliprect);
193192
194193   /* draw top status region */
195194   clip.min_x = visarea.min_x;
trunk/src/mame/video/tecmosys.c
r21022r21023
7070}
7171
7272
73INLINE void set_color_555_tecmo(running_machine &machine, pen_t color, int rshift, int gshift, int bshift, UINT16 data)
73inline void tecmosys_state::set_color_555_tecmo(pen_t color, int rshift, int gshift, int bshift, UINT16 data)
7474{
75   palette_set_color_rgb(machine, color, pal5bit(data >> rshift), pal5bit(data >> gshift), pal5bit(data >> bshift));
75   palette_set_color_rgb(machine(), color, pal5bit(data >> rshift), pal5bit(data >> gshift), pal5bit(data >> bshift));
7676}
7777
7878WRITE16_MEMBER(tecmosys_state::tilemap_paletteram16_xGGGGGRRRRRBBBBB_word_w)
7979{
8080   COMBINE_DATA(&m_tilemap_paletteram16[offset]);
81   set_color_555_tecmo(machine(), offset+0x4000, 5, 10, 0, m_tilemap_paletteram16[offset]);
81   set_color_555_tecmo(offset+0x4000, 5, 10, 0, m_tilemap_paletteram16[offset]);
8282}
8383
8484WRITE16_MEMBER(tecmosys_state::bg0_tilemap_lineram_w)
r21022r21023
101101
102102
103103
104static void tecmosys_render_sprites_to_bitmap(running_machine &machine, bitmap_rgb32 &bitmap, UINT16 extrax, UINT16 extray )
104void tecmosys_state::tecmosys_render_sprites_to_bitmap(bitmap_rgb32 &bitmap, UINT16 extrax, UINT16 extray )
105105{
106   tecmosys_state *state = machine.driver_data<tecmosys_state>();
107   UINT8 *gfxsrc    = state->memregion       ( "gfx1" )->base();
106   UINT8 *gfxsrc    = memregion       ( "gfx1" )->base();
108107   int i;
109108
110109   /* render sprites (with priority information) to temp bitmap */
111   state->m_sprite_bitmap.fill(0x0000);
110   m_sprite_bitmap.fill(0x0000);
112111   /* there are multiple spritelists in here, to allow for buffering */
113   for (i=(state->m_spritelist*0x4000)/2;i<((state->m_spritelist+1)*0x4000)/2;i+=8)
112   for (i=(m_spritelist*0x4000)/2;i<((m_spritelist+1)*0x4000)/2;i+=8)
114113   {
115114      int xcnt,ycnt;
116115      int drawx, drawy;
r21022r21023
125124      int priority;
126125      int zoomx, zoomy;
127126
128      x = state->m_spriteram[i+0]+386;
129      y = (state->m_spriteram[i+1]+1);
127      x = m_spriteram[i+0]+386;
128      y = (m_spriteram[i+1]+1);
130129
131130      x-= extrax;
132131      y-= extray;
r21022r21023
137136      if (x&0x200) x-=0x400;
138137      if (y&0x100) y-=0x200;
139138
140      address =  state->m_spriteram[i+5]| ((state->m_spriteram[i+4]&0x000f)<<16);
139      address =  m_spriteram[i+5]| ((m_spriteram[i+4]&0x000f)<<16);
141140
142141      address<<=8;
143142
144      flipx = (state->m_spriteram[i+4]&0x0040)>>6;
145      flipy = (state->m_spriteram[i+4]&0x0080)>>7; // used by some move effects in tkdensho
143      flipx = (m_spriteram[i+4]&0x0040)>>6;
144      flipy = (m_spriteram[i+4]&0x0080)>>7; // used by some move effects in tkdensho
146145
147      zoomx = (state->m_spriteram[i+2] & 0x0fff)>>0; // zoom?
148      zoomy = (state->m_spriteram[i+3] & 0x0fff)>>0; // zoom?
146      zoomx = (m_spriteram[i+2] & 0x0fff)>>0; // zoom?
147      zoomy = (m_spriteram[i+3] & 0x0fff)>>0; // zoom?
149148
150149      if ((!zoomx) || (!zoomy)) continue;
151150
152      ysize =  ((state->m_spriteram[i+6] & 0x00ff))*16;
153      xsize =  (((state->m_spriteram[i+6] & 0xff00)>>8))*16;
151      ysize =  ((m_spriteram[i+6] & 0x00ff))*16;
152      xsize =  (((m_spriteram[i+6] & 0xff00)>>8))*16;
154153
155      colour =  ((state->m_spriteram[i+4] & 0x3f00))>>8;
154      colour =  ((m_spriteram[i+4] & 0x3f00))>>8;
156155
157      priority = ((state->m_spriteram[i+4] & 0x0030))>>4;
156      priority = ((m_spriteram[i+4] & 0x0030))>>4;
158157
159      if (state->m_spriteram[i+4] & 0x8000) continue;
158      if (m_spriteram[i+4] & 0x8000) continue;
160159
161160      for (ycnt = 0; ycnt < ysize; ycnt++)
162161      {
r21022r21023
178177            {
179178               UINT8 data;
180179
181               dstptr = &state->m_sprite_bitmap.pix16(drawy, drawx);
180               dstptr = &m_sprite_bitmap.pix16(drawy, drawx);
182181
183182
184183               data =  (gfxsrc[address]);
r21022r21023
193192   }
194193}
195194
196static void tecmosys_tilemap_copy_to_compose(tecmosys_state *state, UINT16 pri)
195void tecmosys_state::tecmosys_tilemap_copy_to_compose(UINT16 pri)
197196{
198197   int y,x;
199198   UINT16 *srcptr;
200199   UINT16 *dstptr;
201200   for (y=0;y<240;y++)
202201   {
203      srcptr = &state->m_tmp_tilemap_renderbitmap.pix16(y);
204      dstptr = &state->m_tmp_tilemap_composebitmap.pix16(y);
202      srcptr = &m_tmp_tilemap_renderbitmap.pix16(y);
203      dstptr = &m_tmp_tilemap_composebitmap.pix16(y);
205204      for (x=0;x<320;x++)
206205      {
207206         if ((srcptr[x]&0xf)!=0x0)
r21022r21023
210209   }
211210}
212211
213static void tecmosys_do_final_mix(running_machine &machine, bitmap_rgb32 &bitmap)
212void tecmosys_state::tecmosys_do_final_mix(bitmap_rgb32 &bitmap)
214213{
215   tecmosys_state *state = machine.driver_data<tecmosys_state>();
216   const pen_t *paldata = machine.pens;
214   const pen_t *paldata = machine().pens;
217215   int y,x;
218216   UINT16 *srcptr;
219217   UINT16 *srcptr2;
r21022r21023
221219
222220   for (y=0;y<240;y++)
223221   {
224      srcptr = &state->m_tmp_tilemap_composebitmap.pix16(y);
225      srcptr2 = &state->m_sprite_bitmap.pix16(y);
222      srcptr = &m_tmp_tilemap_composebitmap.pix16(y);
223      srcptr2 = &m_sprite_bitmap.pix16(y);
226224
227225      dstptr = &bitmap.pix32(y);
228226      for (x=0;x<320;x++)
r21022r21023
236234         pri = srcptr[x] & 0xc000;
237235         pri2 = srcptr2[x] & 0xc000;
238236
239         penvalue = state->m_tilemap_paletteram16[srcptr[x]&0x7ff];
237         penvalue = m_tilemap_paletteram16[srcptr[x]&0x7ff];
240238         colour =   paldata[(srcptr[x]&0x7ff) | 0x4000];
241239
242240         if (srcptr2[x]&0x3fff)
243241         {
244            penvalue2 = state->m_generic_paletteram_16[srcptr2[x]&0x3fff];
242            penvalue2 = m_generic_paletteram_16[srcptr2[x]&0x3fff];
245243            colour2 = paldata[srcptr2[x]&0x3fff];
246244         }
247245         else
248246         {
249            penvalue2 = state->m_tilemap_paletteram16[srcptr[x]&0x7ff];
247            penvalue2 = m_tilemap_paletteram16[srcptr[x]&0x7ff];
250248            colour2 =   paldata[(srcptr[x]&0x7ff) | 0x4000];
251249         }
252250
r21022r21023
299297
300298   m_tmp_tilemap_renderbitmap.fill(0, cliprect);
301299   m_bg0tilemap->draw(m_tmp_tilemap_renderbitmap, cliprect, 0,0);
302   tecmosys_tilemap_copy_to_compose(this, 0x0000);
300   tecmosys_tilemap_copy_to_compose(0x0000);
303301
304302   m_tmp_tilemap_renderbitmap.fill(0, cliprect);
305303   m_bg1tilemap->draw(m_tmp_tilemap_renderbitmap, cliprect, 0,0);
306   tecmosys_tilemap_copy_to_compose(this, 0x4000);
304   tecmosys_tilemap_copy_to_compose(0x4000);
307305
308306   m_tmp_tilemap_renderbitmap.fill(0, cliprect);
309307   m_bg2tilemap->draw(m_tmp_tilemap_renderbitmap, cliprect, 0,0);
310   tecmosys_tilemap_copy_to_compose(this, 0x8000);
308   tecmosys_tilemap_copy_to_compose(0x8000);
311309
312310   m_tmp_tilemap_renderbitmap.fill(0, cliprect);
313311   m_txt_tilemap->draw(m_tmp_tilemap_renderbitmap, cliprect, 0,0);
314   tecmosys_tilemap_copy_to_compose(this, 0xc000);
312   tecmosys_tilemap_copy_to_compose(0xc000);
315313
316314
317   tecmosys_do_final_mix(machine(), bitmap);
315   tecmosys_do_final_mix(bitmap);
318316
319317   // prepare sprites for NEXT frame - causes 1 frame palette errors, but prevents sprite lag in tkdensho, which is correct?
320   tecmosys_render_sprites_to_bitmap(machine(), bitmap, m_880000regs[0x0], m_880000regs[0x1]);
318   tecmosys_render_sprites_to_bitmap(bitmap, m_880000regs[0x0], m_880000regs[0x1]);
321319
322320   return 0;
323321}
trunk/src/mame/video/taitosj.c
r21022r21023
1111#include "includes/taitosj.h"
1212
1313
14#define GLOBAL_FLIP_X           (*state->m_video_mode & 0x01)
15#define GLOBAL_FLIP_Y           (*state->m_video_mode & 0x02)
16#define SPRITE_RAM_PAGE_OFFSET  ((*state->m_video_mode & 0x04) ? 0x80 : 0x00)
17#define SPRITES_ON              (*state->m_video_mode & 0x80)
14#define GLOBAL_FLIP_X           (*m_video_mode & 0x01)
15#define GLOBAL_FLIP_Y           (*m_video_mode & 0x02)
16#define SPRITE_RAM_PAGE_OFFSET  ((*m_video_mode & 0x04) ? 0x80 : 0x00)
17#define SPRITES_ON              (*m_video_mode & 0x80)
1818#define TRANSPARENT_PEN         (0x40)
1919
2020
2121
2222static const int layer_enable_mask[3] = { 0x10, 0x20, 0x40 };
2323
24typedef void (*copy_layer_func_t)(running_machine &, bitmap_ind16 &,
25                           const rectangle &, int, int *, rectangle *);
2624
27
2825/***************************************************************************
2926
3027  I call the three layers with the conventional names "front", "middle" and
r21022r21023
9087
9188***************************************************************************/
9289
93static void set_pens(running_machine &machine)
90void taitosj_state::set_pens()
9491{
95   taitosj_state *state = machine.driver_data<taitosj_state>();
9692   static const int resistances[3] = { 1000, 470, 270 };
9793   double rweights[3], gweights[3], bweights[3];
9894   int i;
r21022r21023
109105      int r, g, b, val;
110106
111107      /* red component */
112      val = state->m_paletteram[(i << 1) | 0x01];
108      val = m_paletteram[(i << 1) | 0x01];
113109      bit0 = (~val >> 6) & 0x01;
114110      bit1 = (~val >> 7) & 0x01;
115      val = state->m_paletteram[(i << 1) | 0x00];
111      val = m_paletteram[(i << 1) | 0x00];
116112      bit2 = (~val >> 0) & 0x01;
117113      r = combine_3_weights(rweights, bit0, bit1, bit2);
118114
119115      /* green component */
120      val = state->m_paletteram[(i << 1) | 0x01];
116      val = m_paletteram[(i << 1) | 0x01];
121117      bit0 = (~val >> 3) & 0x01;
122118      bit1 = (~val >> 4) & 0x01;
123119      bit2 = (~val >> 5) & 0x01;
124120      g = combine_3_weights(gweights, bit0, bit1, bit2);
125121
126122      /* blue component */
127      val = state->m_paletteram[(i << 1) | 0x01];
123      val = m_paletteram[(i << 1) | 0x01];
128124      bit0 = (~val >> 0) & 0x01;
129125      bit1 = (~val >> 1) & 0x01;
130126      bit2 = (~val >> 2) & 0x01;
131127      b = combine_3_weights(bweights, bit0, bit1, bit2);
132128
133      palette_set_color(machine, i, MAKE_RGB(r, g, b));
129      palette_set_color(machine(), i, MAKE_RGB(r, g, b));
134130   }
135131}
136132
r21022r21023
140136
141137***************************************************************************/
142138
143static void compute_draw_order(running_machine &machine)
139void taitosj_state::compute_draw_order()
144140{
145   taitosj_state *state = machine.driver_data<taitosj_state>();
146141   int i;
147   UINT8 *color_prom = state->memregion("proms")->base();
142   UINT8 *color_prom = memregion("proms")->base();
148143
149144   /* do a simple conversion of the PROM into layer priority order. Note that */
150145   /* this is a simplification, which assumes the PROM encodes a sensible priority */
r21022r21023
165160
166161         mask |= (1 << data);    /* in next loop, we'll see which of the remaining */
167162                           /* layers has top priority when this one is transparent */
168         state->m_draw_order[i][j] = data;
163         m_draw_order[i][j] = data;
169164      }
170165   }
171166}
r21022r21023
191186   machine().gfx[2]->set_source(m_characterram + 0x1800);
192187   machine().gfx[3]->set_source(m_characterram + 0x1800);
193188
194   compute_draw_order(machine());
189   compute_draw_order();
195190}
196191
197192
r21022r21023
251246}
252247
253248
254INLINE int get_sprite_xy(taitosj_state *state, UINT8 which, UINT8* sx, UINT8* sy)
249inline int taitosj_state::get_sprite_xy(UINT8 which, UINT8* sx, UINT8* sy)
255250{
256251   offs_t offs = which * 4;
257252
258   *sx =       state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 0] - 1;
259   *sy = 240 - state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 1];
253   *sx =       m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 0] - 1;
254   *sy = 240 - m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 1];
260255
261256   return (*sy < 240);
262257}
263258
264259
265INLINE gfx_element *get_sprite_gfx_element(running_machine &machine, UINT8 which)
260inline gfx_element * taitosj_state::get_sprite_gfx_element(UINT8 which)
266261{
267   taitosj_state *state = machine.driver_data<taitosj_state>();
268262   offs_t offs = which * 4;
269263
270   return machine.gfx[(state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x40) ? 3 : 1];
264   return machine().gfx[(m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x40) ? 3 : 1];
271265}
272266
273267
274static int check_sprite_sprite_bitpattern(running_machine &machine,
275                                 int sx1, int sy1, int which1,
276                                 int sx2, int sy2, int which2)
268int taitosj_state::check_sprite_sprite_bitpattern(int sx1, int sy1, int which1,int sx2, int sy2, int which2)
277269{
278   taitosj_state *state = machine.driver_data<taitosj_state>();
279270   int x, y, minx, miny, maxx = 16, maxy = 16;
280271
281272   offs_t offs1 = which1 * 4;
r21022r21023
309300   }
310301
311302   /* draw the sprites into separate bitmaps and check overlapping region */
312   state->m_sprite_layer_collbitmap1.fill(TRANSPARENT_PEN);
313   drawgfx_transpen(state->m_sprite_sprite_collbitmap1, state->m_sprite_sprite_collbitmap1.cliprect(), get_sprite_gfx_element(machine, which1),
314         state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 3] & 0x3f,
303   m_sprite_layer_collbitmap1.fill(TRANSPARENT_PEN);
304   drawgfx_transpen(m_sprite_sprite_collbitmap1, m_sprite_sprite_collbitmap1.cliprect(), get_sprite_gfx_element(which1),
305         m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 3] & 0x3f,
315306         0,
316         state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x01,
317         state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x02,
307         m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x01,
308         m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x02,
318309         sx1, sy1, 0);
319310
320   state->m_sprite_sprite_collbitmap2.fill(TRANSPARENT_PEN);
321   drawgfx_transpen(state->m_sprite_sprite_collbitmap2, state->m_sprite_sprite_collbitmap2.cliprect(), get_sprite_gfx_element(machine, which2),
322         state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 3] & 0x3f,
311   m_sprite_sprite_collbitmap2.fill(TRANSPARENT_PEN);
312   drawgfx_transpen(m_sprite_sprite_collbitmap2, m_sprite_sprite_collbitmap2.cliprect(), get_sprite_gfx_element(which2),
313         m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 3] & 0x3f,
323314         0,
324         state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x01,
325         state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x02,
315         m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x01,
316         m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x02,
326317         sx2, sy2, 0);
327318
328319   for (y = miny; y < maxy; y++)
329320      for (x = minx; x < maxx; x++)
330         if ((state->m_sprite_sprite_collbitmap1.pix16(y, x) != TRANSPARENT_PEN) &&
331            (state->m_sprite_sprite_collbitmap2.pix16(y, x) != TRANSPARENT_PEN))
321         if ((m_sprite_sprite_collbitmap1.pix16(y, x) != TRANSPARENT_PEN) &&
322            (m_sprite_sprite_collbitmap2.pix16(y, x) != TRANSPARENT_PEN))
332323            return 1;  /* collided */
333324
334325   return 0;
335326}
336327
337328
338static void check_sprite_sprite_collision(running_machine &machine)
329void taitosj_state::check_sprite_sprite_collision()
339330{
340   taitosj_state *state = machine.driver_data<taitosj_state>();
341331   if (SPRITES_ON)
342332   {
343333      int which1;
r21022r21023
350340
351341         if ((which1 >= 0x10) && (which1 <= 0x17)) continue; /* no sprites here */
352342
353         if (!get_sprite_xy(state, which1, &sx1, &sy1)) continue;
343         if (!get_sprite_xy(which1, &sx1, &sy1)) continue;
354344
355345         for (which2 = which1 + 1; which2 < 0x20; which2++)
356346         {
r21022r21023
358348
359349            if ((which2 >= 0x10) && (which2 <= 0x17)) continue;   /* no sprites here */
360350
361            if (!get_sprite_xy(state, which2, &sx2, &sy2)) continue;
351            if (!get_sprite_xy(which2, &sx2, &sy2)) continue;
362352
363353            /* quickly rule out any pairs that cannot be touching */
364354            if ((abs((INT8)sx1 - (INT8)sx2) < 16) &&
r21022r21023
366356            {
367357               int reg;
368358
369               if (!check_sprite_sprite_bitpattern(machine, sx1, sy1, which1, sx2, sy2, which2))  continue;
359               if (!check_sprite_sprite_bitpattern(sx1, sy1, which1, sx2, sy2, which2))  continue;
370360
371361               /* mark sprite as collided */
372362               /* note that only the sprite with the higher number is marked */
r21022r21023
379369                  reg = which1 >> 3;
380370                  if (reg == 3)  reg = 2;
381371
382                  state->m_collision_reg[reg] |= (1 << (which1 & 0x07));
372                  m_collision_reg[reg] |= (1 << (which1 & 0x07));
383373               }
384374               else
385375               {
386376                  reg = which2 >> 3;
387377                  if (reg == 3)  reg = 2;
388378
389                  state->m_collision_reg[reg] |= (1 << (which2 & 0x07));
379                  m_collision_reg[reg] |= (1 << (which2 & 0x07));
390380               }
391381            }
392382         }
r21022r21023
395385}
396386
397387
398static void calculate_sprite_areas(running_machine &machine, int *sprites_on, rectangle *sprite_areas)
388void taitosj_state::calculate_sprite_areas(int *sprites_on, rectangle *sprite_areas)
399389{
400   taitosj_state *state = machine.driver_data<taitosj_state>();
401390   int which;
402   int width = machine.primary_screen->width();
403   int height = machine.primary_screen->height();
391   int width = machine().primary_screen->width();
392   int height = machine().primary_screen->height();
404393
405394   for (which = 0; which < 0x20; which++)
406395   {
r21022r21023
408397
409398      if ((which >= 0x10) && (which <= 0x17)) continue;   /* no sprites here */
410399
411      if (get_sprite_xy(state, which, &sx, &sy))
400      if (get_sprite_xy(which, &sx, &sy))
412401      {
413402         int minx, miny, maxx, maxy;
414403
r21022r21023
446435}
447436
448437
449static int check_sprite_layer_bitpattern(running_machine &machine, int which, rectangle *sprite_areas)
438int taitosj_state::check_sprite_layer_bitpattern(int which, rectangle *sprite_areas)
450439{
451   taitosj_state *state = machine.driver_data<taitosj_state>();
452440   int y, x;
453441   offs_t offs = which * 4;
454442   int result = 0;  /* no collisions */
455443
456   int check_layer_1 = *state->m_video_mode & layer_enable_mask[0];
457   int check_layer_2 = *state->m_video_mode & layer_enable_mask[1];
458   int check_layer_3 = *state->m_video_mode & layer_enable_mask[2];
444   int check_layer_1 = *m_video_mode & layer_enable_mask[0];
445   int check_layer_2 = *m_video_mode & layer_enable_mask[1];
446   int check_layer_3 = *m_video_mode & layer_enable_mask[2];
459447
460448   int minx = sprite_areas[which].min_x;
461449   int miny = sprite_areas[which].min_y;
462450   int maxx = sprite_areas[which].max_x + 1;
463451   int maxy = sprite_areas[which].max_y + 1;
464452
465   int flip_x = (state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01) ^ GLOBAL_FLIP_X;
466   int flip_y = (state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02) ^ GLOBAL_FLIP_Y;
453   int flip_x = (m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01) ^ GLOBAL_FLIP_X;
454   int flip_y = (m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02) ^ GLOBAL_FLIP_Y;
467455
468456   /* draw sprite into a bitmap and check if layers collide */
469   state->m_sprite_layer_collbitmap1.fill(TRANSPARENT_PEN);
470   drawgfx_transpen(state->m_sprite_layer_collbitmap1, state->m_sprite_layer_collbitmap1.cliprect(),get_sprite_gfx_element(machine, which),
471         state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f,
457   m_sprite_layer_collbitmap1.fill(TRANSPARENT_PEN);
458   drawgfx_transpen(m_sprite_layer_collbitmap1, m_sprite_layer_collbitmap1.cliprect(),get_sprite_gfx_element(which),
459         m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f,
472460         0,
473461         flip_x, flip_y,
474462         0,0,0);
475463
476464   for (y = miny; y < maxy; y++)
477465      for (x = minx; x < maxx; x++)
478         if (state->m_sprite_layer_collbitmap1.pix16(y - miny, x - minx) != TRANSPARENT_PEN) /* is there anything to check for ? */
466         if (m_sprite_layer_collbitmap1.pix16(y - miny, x - minx) != TRANSPARENT_PEN) /* is there anything to check for ? */
479467         {
480            if (check_layer_1 && (state->m_sprite_layer_collbitmap2[0].pix16(y, x) != TRANSPARENT_PEN))
468            if (check_layer_1 && (m_sprite_layer_collbitmap2[0].pix16(y, x) != TRANSPARENT_PEN))
481469               result |= 0x01;  /* collided with layer 1 */
482470
483            if (check_layer_2 && (state->m_sprite_layer_collbitmap2[1].pix16(y, x) != TRANSPARENT_PEN))
471            if (check_layer_2 && (m_sprite_layer_collbitmap2[1].pix16(y, x) != TRANSPARENT_PEN))
484472               result |= 0x02;  /* collided with layer 2 */
485473
486            if (check_layer_3 && (state->m_sprite_layer_collbitmap2[2].pix16(y, x) != TRANSPARENT_PEN))
474            if (check_layer_3 && (m_sprite_layer_collbitmap2[2].pix16(y, x) != TRANSPARENT_PEN))
487475               result |= 0x04;  /* collided with layer 3 */
488476         }
489477
r21022r21023
491479}
492480
493481
494static void check_sprite_layer_collision(running_machine &machine, int *sprites_on, rectangle *sprite_areas)
482void taitosj_state::check_sprite_layer_collision(int *sprites_on, rectangle *sprite_areas)
495483{
496   taitosj_state *state = machine.driver_data<taitosj_state>();
497484   if (SPRITES_ON)
498485   {
499486      int which;
r21022r21023
504491         if ((which >= 0x10) && (which <= 0x17)) continue;   /* no sprites here */
505492
506493         if (sprites_on[which])
507            state->m_collision_reg[3] |= check_sprite_layer_bitpattern(machine, which, sprite_areas);
494            m_collision_reg[3] |= check_sprite_layer_bitpattern(which, sprite_areas);
508495      }
509496   }
510497}
511498
512499
513static void draw_layers(running_machine &machine)
500void taitosj_state::draw_layers()
514501{
515   taitosj_state *state = machine.driver_data<taitosj_state>();
516502   offs_t offs;
517503
518   state->m_layer_bitmap[0].fill(TRANSPARENT_PEN);
519   state->m_layer_bitmap[1].fill(TRANSPARENT_PEN);
520   state->m_layer_bitmap[2].fill(TRANSPARENT_PEN);
504   m_layer_bitmap[0].fill(TRANSPARENT_PEN);
505   m_layer_bitmap[1].fill(TRANSPARENT_PEN);
506   m_layer_bitmap[2].fill(TRANSPARENT_PEN);
521507
522508   for (offs = 0; offs < 0x0400; offs++)
523509   {
r21022r21023
527513      if (GLOBAL_FLIP_X) sx = 31 - sx;
528514      if (GLOBAL_FLIP_Y) sy = 31 - sy;
529515
530      drawgfx_transpen(state->m_layer_bitmap[0],state->m_layer_bitmap[0].cliprect(),machine.gfx[state->m_colorbank[0] & 0x08 ? 2 : 0],
531            state->m_videoram_1[offs],
532            state->m_colorbank[0] & 0x07,
516      drawgfx_transpen(m_layer_bitmap[0],m_layer_bitmap[0].cliprect(),machine().gfx[m_colorbank[0] & 0x08 ? 2 : 0],
517            m_videoram_1[offs],
518            m_colorbank[0] & 0x07,
533519            GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
534520            8*sx,8*sy,0);
535521
536      drawgfx_transpen(state->m_layer_bitmap[1],state->m_layer_bitmap[1].cliprect(),machine.gfx[state->m_colorbank[0] & 0x80 ? 2 : 0],
537            state->m_videoram_2[offs],
538            (state->m_colorbank[0] >> 4) & 0x07,
522      drawgfx_transpen(m_layer_bitmap[1],m_layer_bitmap[1].cliprect(),machine().gfx[m_colorbank[0] & 0x80 ? 2 : 0],
523            m_videoram_2[offs],
524            (m_colorbank[0] >> 4) & 0x07,
539525            GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
540526            8*sx,8*sy,0);
541527
542      drawgfx_transpen(state->m_layer_bitmap[2],state->m_layer_bitmap[2].cliprect(),machine.gfx[state->m_colorbank[1] & 0x08 ? 2 : 0],
543            state->m_videoram_3[offs],
544            state->m_colorbank[1] & 0x07,
528      drawgfx_transpen(m_layer_bitmap[2],m_layer_bitmap[2].cliprect(),machine().gfx[m_colorbank[1] & 0x08 ? 2 : 0],
529            m_videoram_3[offs],
530            m_colorbank[1] & 0x07,
545531            GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
546532            8*sx,8*sy,0);
547533   }
548534}
549535
550536
551static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap)
537void taitosj_state::draw_sprites(bitmap_ind16 &bitmap)
552538{
553   taitosj_state *state = machine.driver_data<taitosj_state>();
554539   /*
555540      sprite visibility area is missing 4 pixels from the sides, surely to reduce
556541      wraparound side effects. This was verified on a real Elevator Action.
r21022r21023
574559
575560         if ((which >= 0x10) && (which <= 0x17)) continue;   /* no sprites here */
576561
577         if (get_sprite_xy(state, which, &sx, &sy))
562         if (get_sprite_xy(which, &sx, &sy))
578563         {
579            int code = state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f;
580            int color = 2 * ((state->m_colorbank[1] >> 4) & 0x03) + ((state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] >> 2) & 0x01);
581            int flip_x = state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01;
582            int flip_y = state->m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02;
564            int code = m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f;
565            int color = 2 * ((m_colorbank[1] >> 4) & 0x03) + ((m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] >> 2) & 0x01);
566            int flip_x = m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01;
567            int flip_y = m_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02;
583568
584569            if (GLOBAL_FLIP_X)
585570            {
r21022r21023
593578               flip_y = !flip_y;
594579            }
595580
596            drawgfx_transpen(bitmap, GLOBAL_FLIP_X ? spritevisibleareaflip : spritevisiblearea,get_sprite_gfx_element(machine, which), code, color,
581            drawgfx_transpen(bitmap, GLOBAL_FLIP_X ? spritevisibleareaflip : spritevisiblearea,get_sprite_gfx_element(which), code, color,
597582                  flip_x, flip_y, sx, sy,0);
598583
599584            /* draw with wrap around. The horizontal games (eg. sfposeid) need this */
600            drawgfx_transpen(bitmap, GLOBAL_FLIP_X ? spritevisibleareaflip : spritevisiblearea,get_sprite_gfx_element(machine, which), code, color,
585            drawgfx_transpen(bitmap, GLOBAL_FLIP_X ? spritevisibleareaflip : spritevisiblearea,get_sprite_gfx_element(which), code, color,
601586                  flip_x, flip_y, sx - 0x100, sy,0);
602587         }
603588      }
r21022r21023
605590}
606591
607592
608static void taitosj_copy_layer(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,
609                        int which, int *sprites_on, rectangle *sprite_areas)
593void taitosj_state::taitosj_copy_layer(bitmap_ind16 &bitmap, const rectangle &cliprect,int which, int *sprites_on, rectangle *sprite_areas)
610594{
611   taitosj_state *state = machine.driver_data<taitosj_state>();
612595   static const int fudge1[3] = { 3,  1, -1 };
613596   static const int fudge2[3] = { 8, 10, 12 };
614597
615   if (*state->m_video_mode & layer_enable_mask[which])
598   if (*m_video_mode & layer_enable_mask[which])
616599   {
617600      int i, scrollx, scrolly[32];
618601
619      scrollx = state->m_scroll[2 * which];
602      scrollx = m_scroll[2 * which];
620603
621604      if (GLOBAL_FLIP_X)
622605         scrollx =  (scrollx & 0xf8) + ((scrollx + fudge1[which]) & 7) + fudge2[which];
r21022r21023
625608
626609      if (GLOBAL_FLIP_Y)
627610         for (i = 0;i < 32;i++)
628            scrolly[31 - i] =  state->m_colscrolly[32 * which + i] + state->m_scroll[2 * which + 1];
611            scrolly[31 - i] =  m_colscrolly[32 * which + i] + m_scroll[2 * which + 1];
629612      else
630613         for (i = 0;i < 32;i++)
631            scrolly[i]      = -state->m_colscrolly[32 * which + i] - state->m_scroll[2 * which + 1];
614            scrolly[i]      = -m_colscrolly[32 * which + i] - m_scroll[2 * which + 1];
632615
633      copyscrollbitmap_trans(bitmap, state->m_layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, TRANSPARENT_PEN);
616      copyscrollbitmap_trans(bitmap, m_layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, TRANSPARENT_PEN);
634617
635618      /* store parts covered with sprites for sprites/layers collision detection */
636619      for (i = 0; i < 0x20; i++)
r21022r21023
638621         if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */
639622
640623         if (sprites_on[i])
641            copyscrollbitmap(state->m_sprite_layer_collbitmap2[which], state->m_layer_bitmap[which], 1, &scrollx, 32, scrolly, sprite_areas[i]);
624            copyscrollbitmap(m_sprite_layer_collbitmap2[which], m_layer_bitmap[which], 1, &scrollx, 32, scrolly, sprite_areas[i]);
642625      }
643626   }
644627}
645628
646629
647static void kikstart_copy_layer(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,
648                        int which, int *sprites_on, rectangle *sprite_areas)
630void taitosj_state::kikstart_copy_layer(bitmap_ind16 &bitmap, const rectangle &cliprect,int which, int *sprites_on, rectangle *sprite_areas)
649631{
650   taitosj_state *state = machine.driver_data<taitosj_state>();
651   if (*state->m_video_mode & layer_enable_mask[which])
632   if (*m_video_mode & layer_enable_mask[which])
652633   {
653634      int i, scrolly, scrollx[32 * 8];
654635
r21022r21023
657638            switch (which)
658639            {
659640            case 0: scrollx[32 * 8 - i] = 0 ;break;
660            case 1: scrollx[32 * 8 - i] = state->m_kikstart_scrollram[i] + ((state->m_scroll[2 * which] + 0x0a) & 0xff);break;
661            case 2: scrollx[32 * 8 - i] = state->m_kikstart_scrollram[0x100 + i] + ((state->m_scroll[2 * which] + 0xc) & 0xff);break;
641            case 1: scrollx[32 * 8 - i] = m_kikstart_scrollram[i] + ((m_scroll[2 * which] + 0x0a) & 0xff);break;
642            case 2: scrollx[32 * 8 - i] = m_kikstart_scrollram[0x100 + i] + ((m_scroll[2 * which] + 0xc) & 0xff);break;
662643            }
663644         else
664645            switch (which)
665646            {
666647            case 0: scrollx[i] = 0 ;break;
667            case 1: scrollx[i] = 0xff - state->m_kikstart_scrollram[i - 1] - ((state->m_scroll[2 * which] - 0x10) & 0xff);break;
668            case 2: scrollx[i] = 0xff - state->m_kikstart_scrollram[0x100 + i - 1] - ((state->m_scroll[2 * which] - 0x12) & 0xff);break;
648            case 1: scrollx[i] = 0xff - m_kikstart_scrollram[i - 1] - ((m_scroll[2 * which] - 0x10) & 0xff);break;
649            case 2: scrollx[i] = 0xff - m_kikstart_scrollram[0x100 + i - 1] - ((m_scroll[2 * which] - 0x12) & 0xff);break;
669650            }
670651
671      scrolly = state->m_scroll[2 * which + 1];   /* always 0 */
672      copyscrollbitmap_trans(bitmap, state->m_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, TRANSPARENT_PEN);
652      scrolly = m_scroll[2 * which + 1];   /* always 0 */
653      copyscrollbitmap_trans(bitmap, m_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, TRANSPARENT_PEN);
673654
674655      /* store parts covered with sprites for sprites/layers collision detection */
675656      for (i = 0; i < 0x20; i++)
r21022r21023
677658         if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */
678659
679660         if (sprites_on[i])
680            copyscrollbitmap(state->m_sprite_layer_collbitmap2[which], state->m_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, sprite_areas[i]);
661            copyscrollbitmap(m_sprite_layer_collbitmap2[which], m_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, sprite_areas[i]);
681662      }
682663   }
683664}
684665
685666
686static void copy_layer(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,
687                  copy_layer_func_t copy_layer_func, int which, int *sprites_on, rectangle *sprite_areas)
667void taitosj_state::copy_layer(bitmap_ind16 &bitmap, const rectangle &cliprect,copy_layer_func_t copy_layer_func, int which, int *sprites_on, rectangle *sprite_areas)
688668{
689669   if (which == 0)
690      draw_sprites(machine, bitmap);
670      draw_sprites(bitmap);
691671   else
692      copy_layer_func(machine, bitmap, cliprect, which - 1, sprites_on, sprite_areas);
672      (this->*copy_layer_func)(bitmap, cliprect, which - 1, sprites_on, sprite_areas);
693673}
694674
695675
696static void copy_layers(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,
697                  copy_layer_func_t copy_layer_func, int *sprites_on, rectangle *sprite_areas)
676void taitosj_state::copy_layers(bitmap_ind16 &bitmap, const rectangle &cliprect,copy_layer_func_t copy_layer_func, int *sprites_on, rectangle *sprite_areas)
698677{
699   taitosj_state *state = machine.driver_data<taitosj_state>();
700678   int i = 0;
701679
702680   /* fill the screen with the background color */
703   bitmap.fill(8 * (state->m_colorbank[1] & 0x07), cliprect);
681   bitmap.fill(8 * (m_colorbank[1] & 0x07), cliprect);
704682
705683   for (i = 0; i < 4; i++)
706684   {
707      int which = state->m_draw_order[*state->m_video_priority & 0x1f][i];
685      int which = m_draw_order[*m_video_priority & 0x1f][i];
708686
709      copy_layer(machine, bitmap, cliprect, copy_layer_func, which, sprites_on, sprite_areas);
687      copy_layer(bitmap, cliprect, copy_layer_func, which, sprites_on, sprite_areas);
710688   }
711689}
712690
713691
714static void check_collision(running_machine &machine, int *sprites_on, rectangle *sprite_areas)
692void taitosj_state::check_collision(int *sprites_on, rectangle *sprite_areas)
715693{
716   check_sprite_sprite_collision(machine);
694   check_sprite_sprite_collision();
717695
718   check_sprite_layer_collision(machine, sprites_on, sprite_areas);
696   check_sprite_layer_collision(sprites_on, sprite_areas);
719697
720698   /*check_layer_layer_collision();*/  /* not implemented !!! */
721699}
722700
723701
724static int video_update_common(running_machine &machine, bitmap_ind16 &bitmap,
725                        const rectangle &cliprect, copy_layer_func_t copy_layer_func)
702int taitosj_state::video_update_common(bitmap_ind16 &bitmap, const rectangle &cliprect, copy_layer_func_t copy_layer_func)
726703{
727704   int sprites_on[0x20];           /* 1 if sprite is active */
728705   rectangle sprite_areas[0x20];   /* areas on bitmap (sprite locations) */
729706
730   set_pens(machine);
707   set_pens();
731708
732   draw_layers(machine);
709   draw_layers();
733710
734   calculate_sprite_areas(machine, sprites_on, sprite_areas);
711   calculate_sprite_areas(sprites_on, sprite_areas);
735712
736   copy_layers(machine, bitmap, cliprect, copy_layer_func, sprites_on, sprite_areas);
713   copy_layers(bitmap, cliprect, copy_layer_func, sprites_on, sprite_areas);
737714
738715   /*check_sprite_layer_collision() uses drawn bitmaps, so it must me called _AFTER_ draw_layers() */
739   check_collision(machine, sprites_on, sprite_areas);
716   check_collision(sprites_on, sprite_areas);
740717
741718   return 0;
742719}
r21022r21023
744721
745722UINT32 taitosj_state::screen_update_taitosj(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
746723{
747   return video_update_common(machine(), bitmap, cliprect, taitosj_copy_layer);
724   return video_update_common(bitmap, cliprect, &taitosj_state::taitosj_copy_layer);
748725}
749726
750727
751728UINT32 taitosj_state::screen_update_kikstart(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
752729{
753   return video_update_common(machine(), bitmap, cliprect, kikstart_copy_layer);
730   return video_update_common(bitmap, cliprect, &taitosj_state::kikstart_copy_layer);
754731}
trunk/src/mame/video/topspeed.c
r21022r21023
2626
2727********************************************************************************/
2828
29static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
29void topspeed_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
3030{
31   topspeed_state *state = machine.driver_data<topspeed_state>();
32   UINT16 *spriteram = state->m_spriteram;
31   UINT16 *spriteram = m_spriteram;
3332   int offs, map_offset, x, y, curx, cury, sprite_chunk;
34   UINT16 *spritemap = state->m_spritemap;
33   UINT16 *spritemap = m_spritemap;
3534   UINT16 data, tilenum, code, color;
3635   UINT8 flipx, flipy, priority, bad_chunks;
3736   UINT8 j, k, px, py, zx, zy, zoomx, zoomy;
r21022r21023
9291         zx = x + (((k + 1) * zoomx) / 8) - curx;
9392         zy = y + (((j + 1) * zoomy) / 16) - cury;
9493
95         pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
94         pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
9695               code,
9796               color,
9897               flipx,flipy,
9998               curx,cury,
10099               zx<<12,zy<<13,
101               machine.priority_bitmap,primasks[priority],0);
100               machine().priority_bitmap,primasks[priority],0);
102101      }
103102
104103      if (bad_chunks)
r21022r21023
181180   if (m_dislayer[4] == 0)
182181#endif
183182
184   draw_sprites(machine(), bitmap,cliprect);
183   draw_sprites(bitmap,cliprect);
185184   return 0;
186185}
trunk/src/mame/video/toki.c
r21022r21023
163163***************************************************************************/
164164
165165
166static void toki_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
166void toki_state::toki_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
167167{
168   toki_state *state = machine.driver_data<toki_state>();
169168   int x,y,xoffs,yoffs,tile,flipx,flipy,color,offs;
170169   UINT16 *sprite_word;
171170
172   for (offs = (state->m_spriteram->bytes()/2)-4;offs >= 0;offs -= 4)
171   for (offs = (m_spriteram->bytes()/2)-4;offs >= 0;offs -= 4)
173172   {
174      sprite_word = &state->m_spriteram->buffer()[offs];
173      sprite_word = &m_spriteram->buffer()[offs];
175174
176175      if ((sprite_word[2] != 0xf000) && (sprite_word[0] != 0xffff))
177176      {
r21022r21023
190189         flipy   = 0;
191190         tile    = (sprite_word[1] & 0xfff) + ((sprite_word[2] & 0x8000) >> 3);
192191
193         if (state->flip_screen()) {
192         if (flip_screen()) {
194193            x=240-x;
195194            y=240-y;
196195            if (flipx) flipx=0; else flipx=1;
197196            flipy=1;
198197         }
199198
200         drawgfx_transpen (bitmap,cliprect,machine.gfx[1],
199         drawgfx_transpen (bitmap,cliprect,machine().gfx[1],
201200               tile,
202201               color,
203202               flipx,flipy,
r21022r21023
207206}
208207
209208
210static void tokib_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
209void toki_state::tokib_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
211210{
212   toki_state *state = machine.driver_data<toki_state>();
213211   int x,y,tile,flipx,color,offs;
214212   UINT16 *sprite_word;
215213
216   for (offs = 0;offs < state->m_spriteram->bytes() / 2;offs += 4)
214   for (offs = 0;offs < m_spriteram->bytes() / 2;offs += 4)
217215   {
218      sprite_word = &state->m_spriteram->buffer()[offs];
216      sprite_word = &m_spriteram->buffer()[offs];
219217
220218      if (sprite_word[0] == 0xf100)
221219         break;
r21022r21023
235233         tile    = sprite_word[1] & 0x1fff;
236234         color   = sprite_word[2] >> 12;
237235
238         drawgfx_transpen (bitmap,cliprect,machine.gfx[1],
236         drawgfx_transpen (bitmap,cliprect,machine().gfx[1],
239237               tile,
240238               color,
241239               flipx,0,
r21022r21023
279277      m_foreground_layer->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
280278      m_background_layer->draw(bitmap, cliprect, 0,0);
281279   }
282   toki_draw_sprites(machine(), bitmap,cliprect);
280   toki_draw_sprites(bitmap,cliprect);
283281   m_text_layer->draw(bitmap, cliprect, 0,0);
284282   return 0;
285283}
r21022r21023
301299      m_background_layer->draw(bitmap, cliprect, 0,0);
302300   }
303301
304   tokib_draw_sprites(machine(), bitmap,cliprect);
302   tokib_draw_sprites(bitmap,cliprect);
305303   m_text_layer->draw(bitmap, cliprect, 0,0);
306304   return 0;
307305}
trunk/src/mame/video/thedeep.c
r21022r21023
143143
144144***************************************************************************/
145145
146static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
146void thedeep_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
147147{
148   thedeep_state *state = machine.driver_data<thedeep_state>();
149   UINT8 *s = state->m_spriteram, *end = s + state->m_spriteram.bytes();
148   UINT8 *s = m_spriteram, *end = s + m_spriteram.bytes();
150149
151150   while (s < end)
152151   {
r21022r21023
169168      if (color & 1)  sx -= 256;
170169      if (attr  & 1)  sy -= 256;
171170
172      if (state->flip_screen())
171      if (flip_screen())
173172      {
174173         flipx = !flipx;
175174         flipy = !flipy;
r21022r21023
188187
189188         for (y = 0; y < ny; y++)
190189         {
191            drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
190            drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
192191                  code + (flipy ? (ny - y - 1) :  y),
193192                  color,
194193                  flipx,flipy,
r21022r21023
222221   bitmap.fill(get_black_pen(machine()), cliprect);
223222
224223   m_tilemap_0->draw(bitmap, cliprect, 0,0);
225   draw_sprites(machine(), bitmap,cliprect);
224   draw_sprites(bitmap,cliprect);
226225   m_tilemap_1->draw(bitmap, cliprect, 0,0);
227226   return 0;
228227}
trunk/src/mame/video/tumbleb.c
r21022r21023
116116   return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x60) << 5);
117117}
118118
119INLINE void get_bg_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base)
119inline void tumbleb_state::get_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base)
120120{
121   tumbleb_state *state = machine.driver_data<tumbleb_state>();
122121   int data = gfx_base[tile_index];
123122
124   SET_TILE_INFO(
123   SET_TILE_INFO_MEMBER(
125124         gfx_bank,
126         (data & 0x0fff) | (state->m_tilebank >> 2),
125         (data & 0x0fff) | (m_tilebank >> 2),
127126         data >> 12,
128127         0);
129128}
130129
131TILE_GET_INFO_MEMBER(tumbleb_state::get_bg1_tile_info){ get_bg_tile_info(machine(), tileinfo, tile_index, 2, m_pf1_data); }
132TILE_GET_INFO_MEMBER(tumbleb_state::get_bg2_tile_info){ get_bg_tile_info(machine(), tileinfo, tile_index, 1, m_pf2_data); }
130TILE_GET_INFO_MEMBER(tumbleb_state::get_bg1_tile_info){ get_bg_tile_info(tileinfo, tile_index, 2, m_pf1_data); }
131TILE_GET_INFO_MEMBER(tumbleb_state::get_bg2_tile_info){ get_bg_tile_info(tileinfo, tile_index, 1, m_pf2_data); }
133132
134133TILE_GET_INFO_MEMBER(tumbleb_state::get_fg_tile_info)
135134{
r21022r21023
142141         0);
143142}
144143
145INLINE void get_fncywld_bg_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base)
144inline void tumbleb_state::get_fncywld_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base)
146145{
147146   int data = gfx_base[tile_index * 2];
148147   int attr = gfx_base[tile_index * 2 + 1];
149148
150   SET_TILE_INFO(
149   SET_TILE_INFO_MEMBER(
151150         gfx_bank,
152151         data & 0x1fff,
153152         attr & 0x1f,
154153         0);
155154}
156155
157TILE_GET_INFO_MEMBER(tumbleb_state::get_fncywld_bg1_tile_info){ get_fncywld_bg_tile_info(machine(), tileinfo, tile_index, 2, m_pf1_data); }
158TILE_GET_INFO_MEMBER(tumbleb_state::get_fncywld_bg2_tile_info){ get_fncywld_bg_tile_info(machine(), tileinfo, tile_index, 1, m_pf2_data); }
156TILE_GET_INFO_MEMBER(tumbleb_state::get_fncywld_bg1_tile_info){ get_fncywld_bg_tile_info(tileinfo, tile_index, 2, m_pf1_data); }
157TILE_GET_INFO_MEMBER(tumbleb_state::get_fncywld_bg2_tile_info){ get_fncywld_bg_tile_info(tileinfo, tile_index, 1, m_pf2_data); }
159158
160159TILE_GET_INFO_MEMBER(tumbleb_state::get_fncywld_fg_tile_info)
161160{
r21022r21023
170169}
171170
172171
173INLINE void pangpang_get_bg_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base )
172inline void tumbleb_state::pangpang_get_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base )
174173{
175174   int data = gfx_base[tile_index * 2 + 1];
176175   int attr = gfx_base[tile_index * 2];
177176
178   SET_TILE_INFO(
177   SET_TILE_INFO_MEMBER(
179178         gfx_bank,
180179         data & 0x1fff,
181180         (attr >>12) & 0xf,
182181         0);
183182}
184183
185INLINE void pangpang_get_bg2x_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base )
184inline void tumbleb_state::pangpang_get_bg2x_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base )
186185{
187186   int data = gfx_base[tile_index * 2 + 1];
188187   int attr = gfx_base[tile_index * 2];
189188
190   SET_TILE_INFO(
189   SET_TILE_INFO_MEMBER(
191190         gfx_bank,
192191         (data & 0xfff) + 0x1000,
193192         (attr >>12) & 0xf,
r21022r21023
195194}
196195
197196
198TILE_GET_INFO_MEMBER(tumbleb_state::pangpang_get_bg1_tile_info){ pangpang_get_bg_tile_info(machine(), tileinfo, tile_index, 2, m_pf1_data); }
199TILE_GET_INFO_MEMBER(tumbleb_state::pangpang_get_bg2_tile_info){ pangpang_get_bg2x_tile_info(machine(), tileinfo, tile_index, 1, m_pf2_data); }
197TILE_GET_INFO_MEMBER(tumbleb_state::pangpang_get_bg1_tile_info){ pangpang_get_bg_tile_info(tileinfo, tile_index, 2, m_pf1_data); }
198TILE_GET_INFO_MEMBER(tumbleb_state::pangpang_get_bg2_tile_info){ pangpang_get_bg2x_tile_info(tileinfo, tile_index, 1, m_pf2_data); }
200199
201200TILE_GET_INFO_MEMBER(tumbleb_state::pangpang_get_fg_tile_info)
202201{
r21022r21023
283282
284283/******************************************************************************/
285284
286void tumbleb_draw_common(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pf1x_offs, int pf1y_offs, int pf2x_offs, int pf2y_offs)
285void tumbleb_state::tumbleb_draw_common(bitmap_ind16 &bitmap, const rectangle &cliprect, int pf1x_offs, int pf1y_offs, int pf2x_offs, int pf2y_offs)
287286{
288   tumbleb_state *state = machine.driver_data<tumbleb_state>();
289287
290   state->m_pf1_tilemap->set_scrollx(0, state->m_control_0[1] + pf1x_offs);
291   state->m_pf1_tilemap->set_scrolly(0, state->m_control_0[2] + pf1y_offs);
292   state->m_pf1_alt_tilemap->set_scrollx(0, state->m_control_0[1] + pf1x_offs);
293   state->m_pf1_alt_tilemap->set_scrolly(0, state->m_control_0[2] + pf1y_offs);
294   state->m_pf2_tilemap->set_scrollx(0, state->m_control_0[3] + pf2x_offs);
295   state->m_pf2_tilemap->set_scrolly(0, state->m_control_0[4] + pf2y_offs);
288   m_pf1_tilemap->set_scrollx(0, m_control_0[1] + pf1x_offs);
289   m_pf1_tilemap->set_scrolly(0, m_control_0[2] + pf1y_offs);
290   m_pf1_alt_tilemap->set_scrollx(0, m_control_0[1] + pf1x_offs);
291   m_pf1_alt_tilemap->set_scrolly(0, m_control_0[2] + pf1y_offs);
292   m_pf2_tilemap->set_scrollx(0, m_control_0[3] + pf2x_offs);
293   m_pf2_tilemap->set_scrolly(0, m_control_0[4] + pf2y_offs);
296294
297   state->m_pf2_tilemap->draw(bitmap, cliprect, 0, 0);
295   m_pf2_tilemap->draw(bitmap, cliprect, 0, 0);
298296
299   if (state->m_control_0[6] & 0x80)
300      state->m_pf1_tilemap->draw(bitmap, cliprect, 0, 0);
297   if (m_control_0[6] & 0x80)
298      m_pf1_tilemap->draw(bitmap, cliprect, 0, 0);
301299   else
302      state->m_pf1_alt_tilemap->draw(bitmap, cliprect, 0, 0);
300      m_pf1_alt_tilemap->draw(bitmap, cliprect, 0, 0);
303301
304   machine.device<decospr_device>("spritegen")->draw_sprites(bitmap, cliprect, state->m_spriteram, state->m_spriteram.bytes()/2);
302   machine().device<decospr_device>("spritegen")->draw_sprites(bitmap, cliprect, m_spriteram, m_spriteram.bytes()/2);
305303}
306304
307305UINT32 tumbleb_state::screen_update_tumblepb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r21022r21023
321319   else
322320      offs2 = -5;
323321
324   tumbleb_draw_common(machine(),bitmap,cliprect, offs2, 0, offs, 0);
322   tumbleb_draw_common(bitmap,cliprect, offs2, 0, offs, 0);
325323
326324   return 0;
327325}
r21022r21023
343341   else
344342      offs2 = -5;
345343
346   tumbleb_draw_common(machine(),bitmap,cliprect, offs2, 0, offs, 0);
344   tumbleb_draw_common(bitmap,cliprect, offs2, 0, offs, 0);
347345   return 0;
348346}
349347
r21022r21023
364362   else
365363      offs2 = -5;
366364
367   tumbleb_draw_common(machine(),bitmap,cliprect, offs2, 0, offs, 0);
365   tumbleb_draw_common(bitmap,cliprect, offs2, 0, offs, 0);
368366   return 0;
369367}
370368
r21022r21023
378376   offsy = 2;
379377   offsx2 = -5;
380378
381   tumbleb_draw_common(machine(),bitmap,cliprect, offsx2, 0, offsx, offsy);
379   tumbleb_draw_common(bitmap,cliprect, offsx2, 0, offsx, offsy);
382380
383381   return 0;
384382}
r21022r21023
402400   else
403401      offs2 = 8;
404402
405   tumbleb_draw_common(machine(),bitmap,cliprect, offs2, 0, offs, 0);
403   tumbleb_draw_common(bitmap,cliprect, offs2, 0, offs, 0);
406404   return 0;
407405}
408406
r21022r21023
415413   offs = -1;
416414   offs2 = -2;
417415
418   tumbleb_draw_common(machine(),bitmap,cliprect, offs2, 0, offs, 0);
416   tumbleb_draw_common(bitmap,cliprect, offs2, 0, offs, 0);
419417
420418   return 0;
421419}
r21022r21023
429427   offs = -1;
430428   offs2 = -5; // foreground scroll..
431429
432   tumbleb_draw_common(machine(),bitmap,cliprect, offs2, -16, offs, 0);
430   tumbleb_draw_common(bitmap,cliprect, offs2, -16, offs, 0);
433431
434432   m_sprgen->draw_sprites(bitmap, cliprect, m_spriteram, m_spriteram.bytes()/2);
435433   return 0;
r21022r21023
452450   else
453451      offs2 = -5;
454452
455   tumbleb_draw_common(machine(),bitmap,cliprect, offs2, 0, offs, 0);
453   tumbleb_draw_common(bitmap,cliprect, offs2, 0, offs, 0);
456454
457455   return 0;
458456}
r21022r21023
474472   else
475473      offs2 = -5;
476474
477   tumbleb_draw_common(machine(),bitmap,cliprect, offs2, 0, offs, 0);
475   tumbleb_draw_common(bitmap,cliprect, offs2, 0, offs, 0);
478476   return 0;
479477}
480478
trunk/src/mame/video/tigeroad.c
r21022r21023
6464   }
6565}
6666
67static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
67void tigeroad_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
6868{
69   tigeroad_state *state = machine.driver_data<tigeroad_state>();
70   UINT16 *source = &state->m_spriteram->buffer()[state->m_spriteram->bytes()/2] - 4;
71   UINT16 *finish = state->m_spriteram->buffer();
69   UINT16 *source = &m_spriteram->buffer()[m_spriteram->bytes()/2] - 4;
70   UINT16 *finish = m_spriteram->buffer();
7271
7372   // TODO: The Track Map should probably be drawn on top of the background tilemap...
7473   //       Also convert the below into a for loop!
r21022r21023
8988         if (sx > 0x100) sx -= 0x200;
9089         if (sy > 0x100) sy -= 0x200;
9190
92         if (state->flip_screen())
91         if (flip_screen())
9392         {
9493            sx = 240 - sx;
9594            sy = 240 - sy;
r21022r21023
9897         }
9998
10099         drawgfx_transpen(bitmap, cliprect,
101            machine.gfx[2],
100            machine().gfx[2],
102101            tile_number,
103102            color,
104103            flipx, flipy,
r21022r21023
158157UINT32 tigeroad_state::screen_update_tigeroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
159158{
160159   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
161   draw_sprites(machine(), bitmap, cliprect, 0);
160   draw_sprites(bitmap, cliprect, 0);
162161   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
163   //draw_sprites(machine(), bitmap, cliprect, 1); draw priority sprites?
162   //draw_sprites(bitmap, cliprect, 1); draw priority sprites?
164163   m_fg_tilemap->draw(bitmap, cliprect, 0, 2);
165164   return 0;
166165}
trunk/src/mame/video/taito_z.c
r21022r21023
143143********************************************************/
144144
145145
146static void contcirc_draw_sprites_16x8( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
146void taitoz_state::contcirc_draw_sprites_16x8( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
147147{
148   taitoz_state *state = machine.driver_data<taitoz_state>();
149   UINT16 *spritemap = (UINT16 *)state->memregion("user1")->base();
150   UINT16 *spriteram = state->m_spriteram;
148   UINT16 *spritemap = (UINT16 *)memregion("user1")->base();
149   UINT16 *spriteram = m_spriteram;
151150   int offs, data, tilenum, color, flipx, flipy;
152151   int x, y, priority, curx, cury;
153152   int sprites_flipscreen = 0;
r21022r21023
156155   int bad_chunks;
157156   static const int primasks[2] = { 0xf0, 0xfc };
158157
159   for (offs = 0; offs < state->m_spriteram.bytes() / 2; offs += 4)
158   for (offs = 0; offs < m_spriteram.bytes() / 2; offs += 4)
160159   {
161160      data = spriteram[offs + 0];
162161      zoomy = (data & 0xfe00) >> 9;
r21022r21023
223222            flipy = !flipy;
224223         }
225224
226         pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
225         pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
227226               code,
228227               color,
229228               flipx,flipy,
230229               curx,cury,
231               zx<<12,zy<<13,machine.priority_bitmap,primasks[priority],0);
230               zx<<12,zy<<13,machine().priority_bitmap,primasks[priority],0);
232231      }
233232
234233      if (bad_chunks)
r21022r21023
238237
239238
240239
241static void chasehq_draw_sprites_16x16( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
240void taitoz_state::chasehq_draw_sprites_16x16( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
242241{
243   taitoz_state *state = machine.driver_data<taitoz_state>();
244   UINT16 *spritemap = (UINT16 *)state->memregion("user1")->base();
245   UINT16 *spriteram = state->m_spriteram;
242   UINT16 *spritemap = (UINT16 *)memregion("user1")->base();
243   UINT16 *spriteram = m_spriteram;
246244   int offs, data, tilenum, color, flipx, flipy;
247245   int x, y, priority, curx, cury;
248246   int sprites_flipscreen = 0;
r21022r21023
251249   int bad_chunks;
252250   static const int primasks[2] = { 0xf0, 0xfc };
253251
254   for (offs = state->m_spriteram.bytes() / 2 - 4; offs >= 0; offs -= 4)
252   for (offs = m_spriteram.bytes() / 2 - 4; offs >= 0; offs -= 4)
255253   {
256254      data = spriteram[offs + 0];
257255      zoomy = (data & 0xfe00) >> 9;
r21022r21023
321319               flipy = !flipy;
322320            }
323321
324            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
322            pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
325323                  code,
326324                  color,
327325                  flipx,flipy,
328326                  curx,cury,
329327                  zx<<12,zy<<12,
330                  machine.priority_bitmap,primasks[priority],0);
328                  machine().priority_bitmap,primasks[priority],0);
331329         }
332330      }
333331      else if ((zoomx - 1) & 0x20)    /* 64x128 sprites, $40000-$5ffff in spritemap rom, OBJB */
r21022r21023
364362               flipy = !flipy;
365363            }
366364
367            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[2],
365            pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[2],
368366                  code,
369367                  color,
370368                  flipx,flipy,
371369                  curx,cury,
372370                  zx<<12,zy<<12,
373                  machine.priority_bitmap,primasks[priority],0);
371                  machine().priority_bitmap,primasks[priority],0);
374372         }
375373      }
376374      else if (!((zoomx - 1) & 0x60)) /* 32x128 sprites, $60000-$7ffff in spritemap rom, OBJB */
r21022r21023
407405               flipy = !flipy;
408406            }
409407
410            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[2],
408            pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[2],
411409                  code,
412410                  color,
413411                  flipx,flipy,
414412                  curx,cury,
415413                  zx<<12,zy<<12,
416                  machine.priority_bitmap,primasks[priority],0);
414                  machine().priority_bitmap,primasks[priority],0);
417415         }
418416      }
419417
r21022r21023
424422
425423
426424
427static void bshark_draw_sprites_16x8( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
425void taitoz_state::bshark_draw_sprites_16x8( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
428426{
429   taitoz_state *state = machine.driver_data<taitoz_state>();
430   UINT16 *spritemap = (UINT16 *)state->memregion("user1")->base();
431   UINT16 *spriteram = state->m_spriteram;
427   UINT16 *spritemap = (UINT16 *)memregion("user1")->base();
428   UINT16 *spriteram = m_spriteram;
432429   int offs, data, tilenum, color, flipx, flipy;
433430   int x, y, priority, curx, cury;
434431   int sprites_flipscreen = 0;
r21022r21023
437434   int bad_chunks;
438435   static const int primasks[2] = { 0xf0, 0xfc };
439436
440   for (offs = state->m_spriteram.bytes() / 2 - 4; offs >= 0; offs -= 4)
437   for (offs = m_spriteram.bytes() / 2 - 4; offs >= 0; offs -= 4)
441438   {
442439      data = spriteram[offs + 0];
443440      zoomy = (data & 0x7e00) >> 9;
r21022r21023
504501            flipy = !flipy;
505502         }
506503
507         pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
504         pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
508505               code,
509506               color,
510507               flipx,flipy,
511508               curx,cury,
512509               zx<<12,zy<<13,
513               machine.priority_bitmap,primasks[priority],0);
510               machine().priority_bitmap,primasks[priority],0);
514511      }
515512
516513      if (bad_chunks)
r21022r21023
520517
521518
522519
523static void sci_draw_sprites_16x8( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
520void taitoz_state::sci_draw_sprites_16x8( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
524521{
525   taitoz_state *state = machine.driver_data<taitoz_state>();
526   UINT16 *spritemap = (UINT16 *)state->memregion("user1")->base();
527   UINT16 *spriteram = state->m_spriteram;
522   UINT16 *spritemap = (UINT16 *)memregion("user1")->base();
523   UINT16 *spriteram = m_spriteram;
528524   int offs, start_offs, data, tilenum, color, flipx, flipy;
529525   int x, y, priority, curx, cury;
530526   int sprites_flipscreen = 0;
r21022r21023
539535   // reversing it now only gives us sprite updates on alternate
540536   // frames. So we probably have to partly buffer spriteram?
541537
542   start_offs = (state->m_sci_spriteframe & 1) * 0x800;
538   start_offs = (m_sci_spriteframe & 1) * 0x800;
543539   start_offs = 0x800 - start_offs;
544540
545541   for (offs = (start_offs + 0x800 - 4); offs >= start_offs; offs -= 4)
r21022r21023
609605            flipy = !flipy;
610606         }
611607
612         pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
608         pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
613609               code,
614610               color,
615611               flipx,flipy,
616612               curx,cury,
617613               zx<<12,zy<<13,
618               machine.priority_bitmap,primasks[priority],0);
614               machine().priority_bitmap,primasks[priority],0);
619615      }
620616
621617      if (bad_chunks)
r21022r21023
625621
626622
627623
628static void aquajack_draw_sprites_16x8(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int y_offs)
624void taitoz_state::aquajack_draw_sprites_16x8(bitmap_ind16 &bitmap,const rectangle &cliprect,int y_offs)
629625{
630   taitoz_state *state = machine.driver_data<taitoz_state>();
631   UINT16 *spritemap = (UINT16 *)state->memregion("user1")->base();
632   UINT16 *spriteram = state->m_spriteram;
626   UINT16 *spritemap = (UINT16 *)memregion("user1")->base();
627   UINT16 *spriteram = m_spriteram;
633628   int offs, data, tilenum, color, flipx, flipy;
634629   int x, y, priority, curx, cury;
635630   int sprites_flipscreen = 0;
r21022r21023
638633   int bad_chunks;
639634   static const int primasks[2] = { 0xf0, 0xfc };
640635
641   for (offs = 0; offs < state->m_spriteram.bytes() / 2; offs += 4)
636   for (offs = 0; offs < m_spriteram.bytes() / 2; offs += 4)
642637   {
643638      data = spriteram[offs + 0];
644639      zoomy = (data & 0x7e00) >> 9;
r21022r21023
704699            flipy = !flipy;
705700         }
706701
707         pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
702         pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
708703               code,
709704               color,
710705               flipx,flipy,
711706               curx,cury,
712707               zx<<12,zy<<13,
713               machine.priority_bitmap,primasks[priority],0);
708               machine().priority_bitmap,primasks[priority],0);
714709      }
715710
716711      if (bad_chunks)
r21022r21023
720715
721716
722717
723static void spacegun_draw_sprites_16x8(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int y_offs)
718void taitoz_state::spacegun_draw_sprites_16x8(bitmap_ind16 &bitmap,const rectangle &cliprect,int y_offs)
724719{
725   taitoz_state *state = machine.driver_data<taitoz_state>();
726   UINT16 *spritemap = (UINT16 *)state->memregion("user1")->base();
727   UINT16 *spriteram = state->m_spriteram;
720   UINT16 *spritemap = (UINT16 *)memregion("user1")->base();
721   UINT16 *spriteram = m_spriteram;
728722   int offs, data, tilenum, color, flipx, flipy;
729723   int x, y, priority, curx, cury;
730724   int sprites_flipscreen = 0;
r21022r21023
733727   int bad_chunks;
734728   static const int primasks[2] = { 0xf0, 0xfc };
735729
736   for (offs = 0; offs < state->m_spriteram.bytes() / 2 - 4; offs += 4)
730   for (offs = 0; offs < m_spriteram.bytes() / 2 - 4; offs += 4)
737731   {
738732      data = spriteram[offs + 0];
739733      zoomy = (data & 0xfe00) >> 9;
r21022r21023
799793            flipy = !flipy;
800794         }
801795
802         pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
796         pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
803797               code,
804798               color,
805799               flipx,flipy,
806800               curx,cury,
807801               zx<<12,zy<<13,
808               machine.priority_bitmap,primasks[priority],0);
802               machine().priority_bitmap,primasks[priority],0);
809803      }
810804
811805      if (bad_chunks)
r21022r21023
856850   tc0150rod_draw(m_tc0150rod, bitmap, cliprect, -3, m_road_palbank << 6, 1, 0, 1, 2); // -6
857851   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[2], 0, 4);
858852
859   contcirc_draw_sprites_16x8(machine(), bitmap, cliprect, 5); // 7
853   contcirc_draw_sprites_16x8(bitmap, cliprect, 5); // 7
860854   return 0;
861855}
862856
r21022r21023
883877   tc0150rod_draw(m_tc0150rod, bitmap, cliprect, -1, 0xc0, 0, 0, 1, 2);
884878   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[2], 0, 4);
885879
886   chasehq_draw_sprites_16x16(machine(), bitmap, cliprect, 7);
880   chasehq_draw_sprites_16x16(bitmap, cliprect, 7);
887881   return 0;
888882}
889883
r21022r21023
908902   tc0150rod_draw(m_tc0150rod, bitmap, cliprect, -1, 0xc0, 0, 1, 1, 2);
909903   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[2], 0, 4);
910904
911   bshark_draw_sprites_16x8(machine(), bitmap, cliprect, 8);
905   bshark_draw_sprites_16x8(bitmap, cliprect, 8);
912906   return 0;
913907}
914908
r21022r21023
933927   tc0150rod_draw(m_tc0150rod, bitmap, cliprect, -1, 0xc0, 0, 0, 1, 2);
934928   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[2], 0, 4);
935929
936   sci_draw_sprites_16x8(machine(), bitmap, cliprect, 6);
930   sci_draw_sprites_16x8(bitmap, cliprect, 6);
937931   return 0;
938932}
939933
r21022r21023
958952   tc0150rod_draw(m_tc0150rod, bitmap, cliprect, -1, 0, 2, 1, 1, 2);
959953   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[2], 0, 4);
960954
961   aquajack_draw_sprites_16x8(machine(), bitmap, cliprect, 3);
955   aquajack_draw_sprites_16x8(bitmap, cliprect, 3);
962956   return 0;
963957}
964958
r21022r21023
982976   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[1], 0, 2);
983977   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[2], 0, 4);
984978
985   spacegun_draw_sprites_16x8(machine(), bitmap, cliprect, 4);
979   spacegun_draw_sprites_16x8(bitmap, cliprect, 4);
986980
987981   return 0;
988982}
r21022r21023
10131007   tc0480scp_tilemap_draw(m_tc0480scp, bitmap, cliprect, layer[2], 0, 1);
10141008
10151009   tc0150rod_draw(m_tc0150rod, bitmap, cliprect, -1, 0xc0, 0, 0, 1, 2);
1016   bshark_draw_sprites_16x8(machine(), bitmap, cliprect, 7);
1010   bshark_draw_sprites_16x8(bitmap, cliprect, 7);
10171011
10181012   /* This layer used for the big numeric displays */
10191013   tc0480scp_tilemap_draw(m_tc0480scp, bitmap, cliprect, layer[3], 0, 4);
r21022r21023
10491043   tc0480scp_tilemap_draw(m_tc0480scp, bitmap, cliprect, layer[3], 0, 2);
10501044
10511045   tc0150rod_draw(m_tc0150rod, bitmap, cliprect, -1, 0xc0, 0, 0, 1, 2);
1052   sci_draw_sprites_16x8(machine(), bitmap, cliprect, 7);
1046   sci_draw_sprites_16x8(bitmap, cliprect, 7);
10531047
10541048   tc0480scp_tilemap_draw(m_tc0480scp, bitmap, cliprect, layer[4], 0, 4);
10551049   return 0;
trunk/src/mame/video/toypop.c
r21022r21023
165165      m_bg_image[2*offset+1] = (data & 0xf) | ((data & 0xf0) << 4);
166166}
167167
168static void draw_background(running_machine &machine, bitmap_ind16 &bitmap)
168void toypop_state::draw_background(bitmap_ind16 &bitmap)
169169{
170   toypop_state *state = machine.driver_data<toypop_state>();
171   pen_t pen_base = 0x300 + 0x10*state->m_palettebank;
170   pen_t pen_base = 0x300 + 0x10*m_palettebank;
172171
173172   // copy the background image from RAM (0x190200-0x19FDFF) to bitmap
174   if (state->m_bitmapflip)
173   if (m_bitmapflip)
175174   {
176175      int offs = 0xFDFE/2;
177176      for (int y = 0; y < 224; y++)
r21022r21023
179178         UINT16 *scanline = &bitmap.pix16(y);
180179         for (int x = 0; x < 288; x+=2)
181180         {
182            UINT16 data = state->m_bg_image[offs];
181            UINT16 data = m_bg_image[offs];
183182            scanline[x]   = pen_base | (data & 0x0f);
184183            scanline[x+1] = pen_base | (data >> 8);
185184            offs--;
r21022r21023
194193         UINT16 *scanline = &bitmap.pix16(y);
195194         for (int x = 0; x < 288; x+=2)
196195         {
197            UINT16 data = state->m_bg_image[offs];
196            UINT16 data = m_bg_image[offs];
198197            scanline[x]   = pen_base | (data >> 8);
199198            scanline[x+1] = pen_base | (data & 0x0f);
200199            offs++;
r21022r21023
212211***************************************************************************/
213212
214213
215void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base)
214void toypop_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base)
216215{
217   toypop_state *state = machine.driver_data<toypop_state>();
218216   UINT8 *spriteram = spriteram_base + 0x780;
219217   UINT8 *spriteram_2 = spriteram + 0x800;
220218   UINT8 *spriteram_3 = spriteram_2 + 0x800;
r21022r21023
245243         sy -= 16 * sizey;
246244         sy = (sy & 0xff) - 32;  // fix wraparound
247245
248         if (state->flip_screen())
246         if (flip_screen())
249247         {
250248            flipx ^= 1;
251249            flipy ^= 1;
r21022r21023
256254         {
257255            for (int x = 0;x <= sizex;x++)
258256            {
259               drawgfx_transmask(bitmap,cliprect,machine.gfx[1],
257               drawgfx_transmask(bitmap,cliprect,machine().gfx[1],
260258                  sprite + gfx_offs[y ^ (sizey & flipy)][x ^ (sizex & flipx)],
261259                  color,
262260                  flipx,flipy,
263261                  sx + 16*x,sy + 16*y,
264                  colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 0xff));
262                  colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 0xff));
265263            }
266264         }
267265      }
r21022r21023
271269
272270UINT32 toypop_state::screen_update_toypop(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
273271{
274   draw_background(machine(), bitmap);
272   draw_background(bitmap);
275273   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
276   draw_sprites(machine(), bitmap, cliprect, m_spriteram);
274   draw_sprites(bitmap, cliprect, m_spriteram);
277275   return 0;
278276}
trunk/src/mame/video/taito_f2.c
r21022r21023
2626
2727/***********************************************************************************/
2828
29static void taitof2_core_vh_start (running_machine &machine, int sprite_type, int hide, int flip_hide )
29void taitof2_state::taitof2_core_vh_start (int sprite_type, int hide, int flip_hide )
3030{
3131   int i;
32   taitof2_state *state = machine.driver_data<taitof2_state>();
33   state->m_sprite_type = sprite_type;
34   state->m_hide_pixels = hide;
35   state->m_flip_hide_pixels = flip_hide;
32   m_sprite_type = sprite_type;
33   m_hide_pixels = hide;
34   m_flip_hide_pixels = flip_hide;
3635
37   state->m_spriteram_delayed = auto_alloc_array(machine, UINT16, state->m_spriteram.bytes() / 2);
38   state->m_spriteram_buffered = auto_alloc_array(machine, UINT16, state->m_spriteram.bytes() / 2);
39   state->m_spritelist = auto_alloc_array(machine, struct f2_tempsprite, 0x400);
36   m_spriteram_delayed = auto_alloc_array(machine(), UINT16, m_spriteram.bytes() / 2);
37   m_spriteram_buffered = auto_alloc_array(machine(), UINT16, m_spriteram.bytes() / 2);
38   m_spritelist = auto_alloc_array(machine(), struct f2_tempsprite, 0x400);
4039
4140   for (i = 0; i < 8; i ++)
4241   {
43      state->m_spritebank_buffered[i] = 0x400 * i;
44      state->m_spritebank[i] = state->m_spritebank_buffered[i];
42      m_spritebank_buffered[i] = 0x400 * i;
43      m_spritebank[i] = m_spritebank_buffered[i];
4544   }
4645
47   state->m_sprites_disabled = 1;
48   state->m_sprites_active_area = 0;
49   state->m_sprites_flipscreen = 0;
46   m_sprites_disabled = 1;
47   m_sprites_active_area = 0;
48   m_sprites_flipscreen = 0;
5049
51   state->m_sprites_master_scrollx = 0;
52   state->m_sprites_master_scrolly = 0;
50   m_sprites_master_scrollx = 0;
51   m_sprites_master_scrolly = 0;
5352
54   state->m_spriteblendmode = 0;
55   state->m_prepare_sprites = 0;
53   m_spriteblendmode = 0;
54   m_prepare_sprites = 0;
5655
57   state->m_game = 0;  /* means NOT footchmp */
56   m_game = 0;  /* means NOT footchmp */
5857
59   state->save_item(NAME(state->m_spritebank));
60   state->save_item(NAME(state->m_spritebank_buffered));
61   state->save_item(NAME(state->m_sprites_disabled));
62   state->save_item(NAME(state->m_sprites_active_area));
63   state->save_item(NAME(state->m_sprites_flipscreen));
64   state->save_item(NAME(state->m_sprites_master_scrollx));
65   state->save_item(NAME(state->m_sprites_master_scrolly));
66   state->save_item(NAME(state->m_tilepri));
67   state->save_item(NAME(state->m_spritepri));
68   state->save_item(NAME(state->m_spriteblendmode));
69   state->save_item(NAME(state->m_prepare_sprites));
70   state->save_pointer(NAME(state->m_spriteram_delayed), state->m_spriteram.bytes() / 2);
71   state->save_pointer(NAME(state->m_spriteram_buffered), state->m_spriteram.bytes() / 2);
58   save_item(NAME(m_spritebank));
59   save_item(NAME(m_spritebank_buffered));
60   save_item(NAME(m_sprites_disabled));
61   save_item(NAME(m_sprites_active_area));
62   save_item(NAME(m_sprites_flipscreen));
63   save_item(NAME(m_sprites_master_scrollx));
64   save_item(NAME(m_sprites_master_scrolly));
65   save_item(NAME(m_tilepri));
66   save_item(NAME(m_spritepri));
67   save_item(NAME(m_spriteblendmode));
68   save_item(NAME(m_prepare_sprites));
69   save_pointer(NAME(m_spriteram_delayed), m_spriteram.bytes() / 2);
70   save_pointer(NAME(m_spriteram_buffered), m_spriteram.bytes() / 2);
7271}
7372
7473/**************************************************************************************/
r21022r21023
7776
7877VIDEO_START_MEMBER(taitof2_state,taitof2_default)
7978{
80   taitof2_core_vh_start(machine(), 0, 0, 0);
79   taitof2_core_vh_start(0, 0, 0);
8180}
8281
8382VIDEO_START_MEMBER(taitof2_state,taitof2_megab)/* Megab, Liquidk */
8483{
85   taitof2_core_vh_start(machine(), 0, 3, 3);
84   taitof2_core_vh_start(0, 3, 3);
8685}
8786
8887VIDEO_START_MEMBER(taitof2_state,taitof2_quiz)/* Quiz Crayons, Quiz Jinsei */
8988{
90   taitof2_core_vh_start(machine(), 3, 3, 3);
89   taitof2_core_vh_start(3, 3, 3);
9190}
9291
9392VIDEO_START_MEMBER(taitof2_state,taitof2_finalb)
9493{
95   taitof2_core_vh_start(machine(), 0, 1, 1);
94   taitof2_core_vh_start(0, 1, 1);
9695}
9796
9897VIDEO_START_MEMBER(taitof2_state,taitof2_ssi)
9998{
100   taitof2_core_vh_start(machine(), 0, 3, 3);
99   taitof2_core_vh_start(0, 3, 3);
101100}
102101
103102VIDEO_START_MEMBER(taitof2_state,taitof2_growl)
104103{
105   taitof2_core_vh_start(machine(), 0, 3, 3);
104   taitof2_core_vh_start(0, 3, 3);
106105}
107106
108107VIDEO_START_MEMBER(taitof2_state,taitof2_ninjak)
109108{
110   taitof2_core_vh_start(machine(), 0, 0, 0);
109   taitof2_core_vh_start(0, 0, 0);
111110}
112111
113112VIDEO_START_MEMBER(taitof2_state,taitof2_qzchikyu)
114113{
115   taitof2_core_vh_start(machine(), 0, 0, 4);
114   taitof2_core_vh_start(0, 0, 4);
116115}
117116
118117VIDEO_START_MEMBER(taitof2_state,taitof2_solfigtr)
119118{
120   taitof2_core_vh_start(machine(), 0, 3, -3);
119   taitof2_core_vh_start(0, 3, -3);
121120}
122121
123122VIDEO_START_MEMBER(taitof2_state,taitof2_koshien)
124123{
125   taitof2_core_vh_start(machine(), 0, 1,  - 1);
124   taitof2_core_vh_start(0, 1,  - 1);
126125}
127126
128127VIDEO_START_MEMBER(taitof2_state,taitof2_gunfront)
129128{
130   taitof2_core_vh_start(machine(), 0, 3, 3);
129   taitof2_core_vh_start(0, 3, 3);
131130}
132131
133132VIDEO_START_MEMBER(taitof2_state,taitof2_thundfox)
134133{
135   taitof2_core_vh_start(machine(), 0, 3, -3);
134   taitof2_core_vh_start(0, 3, -3);
136135}
137136
138137VIDEO_START_MEMBER(taitof2_state,taitof2_mjnquest)
139138{
140   taitof2_core_vh_start(machine(), 0, 0, 0);
139   taitof2_core_vh_start(0, 0, 0);
141140
142141   tc0100scn_set_bg_tilemask(m_tc0100scn, 0x7fff);
143142}
144143
145144VIDEO_START_MEMBER(taitof2_state,taitof2_footchmp)
146145{
147   taitof2_core_vh_start(machine(), 0, 3, 3);
146   taitof2_core_vh_start(0, 3, 3);
148147
149148   m_game = FOOTCHMP;
150149}
151150
152151VIDEO_START_MEMBER(taitof2_state,taitof2_hthero)
153152{
154   taitof2_core_vh_start(machine(), 0, 3, 3);
153   taitof2_core_vh_start(0, 3, 3);
155154
156155   m_game = FOOTCHMP;
157156}
158157
159158VIDEO_START_MEMBER(taitof2_state,taitof2_deadconx)
160159{
161   taitof2_core_vh_start(machine(), 0, 3, 3);
160   taitof2_core_vh_start(0, 3, 3);
162161}
163162
164163VIDEO_START_MEMBER(taitof2_state,taitof2_deadconxj)
165164{
166   taitof2_core_vh_start(machine(), 0, 3, 3);
165   taitof2_core_vh_start(0, 3, 3);
167166}
168167
169168VIDEO_START_MEMBER(taitof2_state,taitof2_metalb)
170169{
171   taitof2_core_vh_start(machine(), 0, 3, 3);
170   taitof2_core_vh_start(0, 3, 3);
172171}
173172
174173VIDEO_START_MEMBER(taitof2_state,taitof2_yuyugogo)
175174{
176   taitof2_core_vh_start(machine(), 1, 3, 3);
175   taitof2_core_vh_start(1, 3, 3);
177176}
178177
179178VIDEO_START_MEMBER(taitof2_state,taitof2_yesnoj)
180179{
181   taitof2_core_vh_start(machine(), 0, 3, 3);
180   taitof2_core_vh_start(0, 3, 3);
182181}
183182
184183VIDEO_START_MEMBER(taitof2_state,taitof2_dinorex)
185184{
186   taitof2_core_vh_start(machine(), 3, 3, 3);
185   taitof2_core_vh_start(3, 3, 3);
187186}
188187
189188VIDEO_START_MEMBER(taitof2_state,taitof2_dondokod)/* dondokod, cameltry */
190189{
191190   m_pivot_xdisp = -16;
192191   m_pivot_ydisp = 0;
193   taitof2_core_vh_start(machine(), 0, 3, 3);
192   taitof2_core_vh_start(0, 3, 3);
194193}
195194
196195VIDEO_START_MEMBER(taitof2_state,taitof2_pulirula)
197196{
198197   m_pivot_xdisp = -10;    /* alignment seems correct (see level 2, falling */
199198   m_pivot_ydisp = 16; /* block of ice after armour man) */
200   taitof2_core_vh_start(machine(), 2, 3, 3);
199   taitof2_core_vh_start(2, 3, 3);
201200}
202201
203202VIDEO_START_MEMBER(taitof2_state,taitof2_driftout)
204203{
205204   m_pivot_xdisp = -16;
206205   m_pivot_ydisp = 16;
207   taitof2_core_vh_start(machine(), 0, 3, 3);
206   taitof2_core_vh_start(0, 3, 3);
208207}
209208
210209
r21022r21023
271270   m_spritebank_buffered[7] = m_spritebank_buffered[6] + 0x400;
272271}
273272
274static void taito_f2_tc360_spritemixdraw( running_machine &machine, bitmap_ind16 &dest_bmp, const rectangle &clip, gfx_element *gfx,
273void taitof2_state::taito_f2_tc360_spritemixdraw( bitmap_ind16 &dest_bmp, const rectangle &clip, gfx_element *gfx,
275274      UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy, int scalex, int scaley )
276275{
277   taitof2_state *state = machine.driver_data<taitof2_state>();
278276   int pal_base = gfx->colorbase() + gfx->granularity() * (color % gfx->colors());
279277   const UINT8 *source_base = gfx->get_data(code % gfx->elements());
280278   bitmap_ind8 &priority_bitmap = gfx->machine().priority_bitmap;
r21022r21023
360358                  UINT8 tilemap_priority = 0, sprite_priority = 0;
361359
362360                  // Get tilemap priority (0 - 0xf) for this destination pixel
363                  if (pri[x] & 0x10) tilemap_priority = state->m_tilepri[4];
364                  else if (pri[x] & 0x8) tilemap_priority = state->m_tilepri[3];
365                  else if (pri[x] & 0x4) tilemap_priority = state->m_tilepri[2];
366                  else if (pri[x] & 0x2) tilemap_priority = state->m_tilepri[1];
367                  else if (pri[x] & 0x1) tilemap_priority = state->m_tilepri[0];
361                  if (pri[x] & 0x10) tilemap_priority = m_tilepri[4];
362                  else if (pri[x] & 0x8) tilemap_priority = m_tilepri[3];
363                  else if (pri[x] & 0x4) tilemap_priority = m_tilepri[2];
364                  else if (pri[x] & 0x2) tilemap_priority = m_tilepri[1];
365                  else if (pri[x] & 0x1) tilemap_priority = m_tilepri[0];
368366
369367                  // Get sprite priority (0 - 0xf) for this source pixel
370368                  if ((color & 0xc0) == 0xc0)
371                     sprite_priority = state->m_spritepri[3];
369                     sprite_priority = m_spritepri[3];
372370                  else if ((color & 0xc0) == 0x80)
373                     sprite_priority = state->m_spritepri[2];
371                     sprite_priority = m_spritepri[2];
374372                  else if ((color & 0xc0) == 0x40)
375                     sprite_priority = state->m_spritepri[1];
373                     sprite_priority = m_spritepri[1];
376374                  else if ((color & 0xc0) == 0x00)
377                     sprite_priority = state->m_spritepri[0];
375                     sprite_priority = m_spritepri[0];
378376
379377                  // Blend mode 1 - Sprite under tilemap, use sprite palette with tilemap data
380                  if ((state->m_spriteblendmode & 0xc0) == 0xc0 && sprite_priority == (tilemap_priority - 1))
378                  if ((m_spriteblendmode & 0xc0) == 0xc0 && sprite_priority == (tilemap_priority - 1))
381379                  {
382380                     dest[x] = ((pal_base + c) & 0xfff0) | (dest[x] & 0xf);
383381                  }
384382                  // Blend mode 1 - Sprite over tilemap, use sprite data with tilemap palette
385                  else if ((state->m_spriteblendmode & 0xc0) == 0xc0 && sprite_priority == (tilemap_priority + 1))
383                  else if ((m_spriteblendmode & 0xc0) == 0xc0 && sprite_priority == (tilemap_priority + 1))
386384                  {
387385                     if (dest[x] & 0xf)
388386                        dest[x] = (dest[x] & 0xfff0) | ((pal_base + c) & 0xf);
r21022r21023
390388                        dest[x] = pal_base + c;
391389                  }
392390                  // Blend mode 2 - Sprite under tilemap, use sprite data with tilemap palette
393                  else if ((state->m_spriteblendmode & 0xc0) == 0x80 && sprite_priority == (tilemap_priority - 1))
391                  else if ((m_spriteblendmode & 0xc0) == 0x80 && sprite_priority == (tilemap_priority - 1))
394392                  {
395393                     dest[x] = (dest[x] & 0xffef);
396394                  }
397395                  // Blend mode 2 - Sprite over tilemap, alternate sprite palette, confirmed in Pulirula level 2
398                  else if ((state->m_spriteblendmode & 0xc0) == 0x80 && sprite_priority == (tilemap_priority + 1))
396                  else if ((m_spriteblendmode & 0xc0) == 0x80 && sprite_priority == (tilemap_priority + 1))
399397                  {
400398                     dest[x] = ((pal_base + c) & 0xffef); // Pulirula level 2, Liquid Kids attract mode
401399                  }
r21022r21023
417415   }
418416}
419417
420static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks, int uses_tc360_mixer )
418void taitof2_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks, int uses_tc360_mixer )
421419{
422420   /*
423421       Sprite format:
r21022r21023
476474   non zoom parts.
477475
478476   */
479   taitof2_state *state = machine.driver_data<taitof2_state>();
480477   int i, x, y, off, extoffs;
481478   int code, color, spritedata, spritecont, flipx, flipy;
482479   int xcurrent, ycurrent, big_sprite = 0;
r21022r21023
489486
490487   /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
491488      while processing sprite ram and then draw them all at the end */
492   struct f2_tempsprite *sprite_ptr = state->m_spritelist;
489   struct f2_tempsprite *sprite_ptr = m_spritelist;
493490
494491   /* must remember enable status from last frame because driftout fails to
495492      reactivate them from a certain point onwards. */
496   int disabled = state->m_sprites_disabled;
493   int disabled = m_sprites_disabled;
497494
498495   /* must remember master scroll from previous frame because driftout
499496      sometimes doesn't set it. */
500   int master_scrollx = state->m_sprites_master_scrollx;
501   int master_scrolly = state->m_sprites_master_scrolly;
497   int master_scrollx = m_sprites_master_scrollx;
498   int master_scrolly = m_sprites_master_scrolly;
502499
503500   /* must also remember the sprite bank from previous frame. */
504   int area = state->m_sprites_active_area;
501   int area = m_sprites_active_area;
505502
506503   scroll1x = 0;
507504   scroll1y = 0;
r21022r21023
509506   xcurrent = ycurrent = 0;
510507   color = 0;
511508
512   f2_x_offset = state->m_hide_pixels;   /* Get rid of 0-3 unwanted pixels on edge of screen. */
513   if (state->m_sprites_flipscreen)
514      f2_x_offset = -state->m_flip_hide_pixels;       // was -f2_x_offset
509   f2_x_offset = m_hide_pixels;   /* Get rid of 0-3 unwanted pixels on edge of screen. */
510   if (m_sprites_flipscreen)
511      f2_x_offset = -m_flip_hide_pixels;       // was -f2_x_offset
515512
516513   /* safety check to avoid getting stuck in bank 2 for games using only one bank */
517   if (area == 0x8000 && state->m_spriteram_buffered[(0x8000 + 6) / 2] == 0 && state->m_spriteram_buffered[(0x8000 + 10) / 2] == 0)
514   if (area == 0x8000 && m_spriteram_buffered[(0x8000 + 6) / 2] == 0 && m_spriteram_buffered[(0x8000 + 10) / 2] == 0)
518515      area = 0;
519516
520517   for (off = 0; off < 0x4000; off += 16)
r21022r21023
522519      /* sprites_active_area may change during processing */
523520      int offs = off + area;
524521
525      if (state->m_spriteram_buffered[(offs + 6) / 2] & 0x8000)
522      if (m_spriteram_buffered[(offs + 6) / 2] & 0x8000)
526523      {
527         disabled = state->m_spriteram_buffered[(offs + 10) / 2] & 0x1000;
528         state->m_sprites_flipscreen = state->m_spriteram_buffered[(offs + 10) / 2] & 0x2000;
524         disabled = m_spriteram_buffered[(offs + 10) / 2] & 0x1000;
525         m_sprites_flipscreen = m_spriteram_buffered[(offs + 10) / 2] & 0x2000;
529526
530527         /* Get rid of 0-3 unwanted pixels on edge of screen. */
531         f2_x_offset = state->m_hide_pixels;
532         if (state->m_sprites_flipscreen)
533            f2_x_offset = -state->m_flip_hide_pixels;       // was -f2_x_offset
528         f2_x_offset = m_hide_pixels;
529         if (m_sprites_flipscreen)
530            f2_x_offset = -m_flip_hide_pixels;       // was -f2_x_offset
534531
535         if (state->m_game == FOOTCHMP)
536            area = 0x8000 * (state->m_spriteram_buffered[(offs + 6) / 2] & 0x0001);
532         if (m_game == FOOTCHMP)
533            area = 0x8000 * (m_spriteram_buffered[(offs + 6) / 2] & 0x0001);
537534         else
538            area = 0x8000 * (state->m_spriteram_buffered[(offs + 10) / 2] & 0x0001);
535            area = 0x8000 * (m_spriteram_buffered[(offs + 10) / 2] & 0x0001);
539536         continue;
540537      }
541538
542539//popmessage("%04x",area);
543540
544541      /* check for extra scroll offset */
545      if ((state->m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0xa000)
542      if ((m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0xa000)
546543      {
547         master_scrollx = state->m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
544         master_scrollx = m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
548545         if (master_scrollx >= 0x800)
549546            master_scrollx -= 0x1000;   /* signed value */
550547
551         master_scrolly = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
548         master_scrolly = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
552549         if (master_scrolly >= 0x800)
553550            master_scrolly -= 0x1000;   /* signed value */
554551      }
555552
556      if ((state->m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0x5000)
553      if ((m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0x5000)
557554      {
558         scroll1x = state->m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
555         scroll1x = m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
559556         if (scroll1x >= 0x800)
560557            scroll1x -= 0x1000;   /* signed value */
561558
562         scroll1y = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
559         scroll1y = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
563560         if (scroll1y >= 0x800)
564561            scroll1y -= 0x1000;   /* signed value */
565562      }
r21022r21023
567564      if (disabled)
568565         continue;
569566
570      spritedata = state->m_spriteram_buffered[(offs + 8) / 2];
567      spritedata = m_spriteram_buffered[(offs + 8) / 2];
571568
572569      spritecont = (spritedata & 0xff00) >> 8;
573570
r21022r21023
575572      {
576573         if (big_sprite == 0)   /* are we starting a big sprite ? */
577574         {
578            xlatch = state->m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
579            ylatch = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
575            xlatch = m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
576            ylatch = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
580577            x_no = 0;
581578            y_no = 0;
582            zoomword = state->m_spriteram_buffered[(offs + 2) / 2];
579            zoomword = m_spriteram_buffered[(offs + 2) / 2];
583580            zoomylatch = (zoomword >> 8) & 0xff;
584581            zoomxlatch = (zoomword >> 0) & 0xff;
585582            big_sprite = 1;   /* we have started a new big sprite */
r21022r21023
600597// of anything.
601598      if (big_sprite == 0 || (spritecont & 0xf0) == 0)
602599      {
603         x = state->m_spriteram_buffered[(offs + 4) / 2];
600         x = m_spriteram_buffered[(offs + 4) / 2];
604601
605602// Some absolute x values deduced here are 1 too high (scenes when you get
606603// home run in Koshien, and may also relate to BG layer woods and stuff as you
r21022r21023
623620            scrolly = scroll1y + master_scrolly;
624621         }
625622         x &= 0xfff;
626         y = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
623         y = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
627624
628625         xcurrent = x;
629626         ycurrent = y;
r21022r21023
675672      }
676673      else
677674      {
678         zoomword = state->m_spriteram_buffered[(offs + 2) / 2];
675         zoomword = m_spriteram_buffered[(offs + 2) / 2];
679676         zoomy = (zoomword >> 8) & 0xff;
680677         zoomx = (zoomword >> 0) & 0xff;
681678         zx = (0x100 - zoomx) / 16;
r21022r21023
693690      /* spriteram[0x4000-7fff] has no corresponding extension area */
694691      if (extoffs >= 0x8000) extoffs -= 0x4000;
695692
696      if (state->m_sprite_type == 0)
693      if (m_sprite_type == 0)
697694      {
698         code = state->m_spriteram_buffered[(offs) / 2] & 0x1fff;
695         code = m_spriteram_buffered[(offs) / 2] & 0x1fff;
699696         i = (code & 0x1c00) >> 10;
700         code = state->m_spritebank[i] + (code & 0x3ff);
697         code = m_spritebank[i] + (code & 0x3ff);
701698      }
702699
703      if (state->m_sprite_type == 1)   /* Yuyugogo */
700      if (m_sprite_type == 1)   /* Yuyugogo */
704701      {
705         code = state->m_spriteram_buffered[(offs) / 2] & 0x3ff;
706         i = (state->m_sprite_extension[(extoffs >> 4)] & 0x3f ) << 10;
702         code = m_spriteram_buffered[(offs) / 2] & 0x3ff;
703         i = (m_sprite_extension[(extoffs >> 4)] & 0x3f ) << 10;
707704         code = (i | code);
708705      }
709706
710      if (state->m_sprite_type == 2)   /* Pulirula */
707      if (m_sprite_type == 2)   /* Pulirula */
711708      {
712         code = state->m_spriteram_buffered[(offs) / 2] & 0xff;
713         i = (state->m_sprite_extension[(extoffs >> 4)] & 0xff00 );
709         code = m_spriteram_buffered[(offs) / 2] & 0xff;
710         i = (m_sprite_extension[(extoffs >> 4)] & 0xff00 );
714711         code = (i | code);
715712      }
716713
717      if (state->m_sprite_type == 3)   /* Dinorex and a few quizzes */
714      if (m_sprite_type == 3)   /* Dinorex and a few quizzes */
718715      {
719         code = state->m_spriteram_buffered[(offs) / 2] & 0xff;
720         i = (state->m_sprite_extension[(extoffs >> 4)] & 0xff ) << 8;
716         code = m_spriteram_buffered[(offs) / 2] & 0xff;
717         i = (m_sprite_extension[(extoffs >> 4)] & 0xff ) << 8;
721718         code = (i | code);
722719      }
723720
r21022r21023
732729      cury = (y + scrolly) & 0xfff;
733730      if (cury >= 0x800)  cury -= 0x1000;   /* treat it as signed */
734731
735      if (state->m_sprites_flipscreen)
732      if (m_sprites_flipscreen)
736733      {
737734         /* -zx/y is there to fix zoomed sprite coords in screenflip.
738735            drawgfxzoom does not know to draw from flip-side of sprites when
r21022r21023
747744      {
748745         sprite_ptr->code = code;
749746         sprite_ptr->color = color;
750         if (machine.gfx[0]->granularity() == 64)    /* Final Blow is 6-bit deep */
747         if (machine().gfx[0]->granularity() == 64)    /* Final Blow is 6-bit deep */
751748            sprite_ptr->color /= 4;
752749         sprite_ptr->flipx = flipx;
753750         sprite_ptr->flipy = flipy;
r21022r21023
765762         }
766763         else
767764         {
768            drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
765            drawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
769766                  sprite_ptr->code,
770767                  sprite_ptr->color,
771768                  sprite_ptr->flipx,sprite_ptr->flipy,
r21022r21023
777774
778775
779776   /* this happens only if primsks != NULL */
780   while (sprite_ptr != state->m_spritelist)
777   while (sprite_ptr != m_spritelist)
781778   {
782779      sprite_ptr--;
783780
784781      if (!uses_tc360_mixer)
785         pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
782         pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
786783               sprite_ptr->code,
787784               sprite_ptr->color,
788785               sprite_ptr->flipx,sprite_ptr->flipy,
789786               sprite_ptr->x,sprite_ptr->y,
790787               sprite_ptr->zoomx,sprite_ptr->zoomy,
791               machine.priority_bitmap,sprite_ptr->primask,0);
788               machine().priority_bitmap,sprite_ptr->primask,0);
792789      else
793         taito_f2_tc360_spritemixdraw(machine, bitmap,cliprect,machine.gfx[0],
790         taito_f2_tc360_spritemixdraw(bitmap,cliprect,machine().gfx[0],
794791               sprite_ptr->code,
795792               sprite_ptr->color,
796793               sprite_ptr->flipx,sprite_ptr->flipy,
r21022r21023
800797}
801798
802799
803static void update_spritebanks( running_machine &machine )
800void taitof2_state::update_spritebanks(  )
804801{
805   taitof2_state *state = machine.driver_data<taitof2_state>();
806802   int i;
807803#if 1
808804   for (i = 0; i < 8; i ++)
809805   {
810      state->m_spritebank[i] = state->m_spritebank_buffered[i];
806      m_spritebank[i] = m_spritebank_buffered[i];
811807   }
812808#else
813809   /* this makes footchmp blobbing worse! */
814810   for (i = 0; i < 8; i ++)
815811   {
816      state->m_spritebank[i] = state->m_spritebank_eof[i];
817      state->m_spritebank_eof[i] = state->m_spritebank_buffered[i];
812      m_spritebank[i] = m_spritebank_eof[i];
813      m_spritebank_eof[i] = m_spritebank_buffered[i];
818814   }
819815#endif
820816}
821817
822static void taitof2_handle_sprite_buffering( running_machine &machine )
818void taitof2_state::taitof2_handle_sprite_buffering(  )
823819{
824   taitof2_state *state = machine.driver_data<taitof2_state>();
825820
826   if (state->m_prepare_sprites)   /* no buffering */
821   if (m_prepare_sprites)   /* no buffering */
827822   {
828      memcpy(state->m_spriteram_buffered, state->m_spriteram, state->m_spriteram.bytes());
829      state->m_prepare_sprites = 0;
823      memcpy(m_spriteram_buffered, m_spriteram, m_spriteram.bytes());
824      m_prepare_sprites = 0;
830825   }
831826}
832827
833static void taitof2_update_sprites_active_area( running_machine &machine )
828void taitof2_state::taitof2_update_sprites_active_area(  )
834829{
835   taitof2_state *state = machine.driver_data<taitof2_state>();
836830   int off;
837831
838   update_spritebanks(machine);
832   update_spritebanks();
839833
840834   /* if the frame was skipped, we'll have to do the buffering now */
841   taitof2_handle_sprite_buffering(machine);
835   taitof2_handle_sprite_buffering();
842836
843837   /* safety check to avoid getting stuck in bank 2 for games using only one bank */
844   if (state->m_sprites_active_area == 0x8000 &&
845         state->m_spriteram_buffered[(0x8000 + 6) / 2] == 0 &&
846         state->m_spriteram_buffered[(0x8000 + 10) / 2] == 0)
847      state->m_sprites_active_area = 0;
838   if (m_sprites_active_area == 0x8000 &&
839         m_spriteram_buffered[(0x8000 + 6) / 2] == 0 &&
840         m_spriteram_buffered[(0x8000 + 10) / 2] == 0)
841      m_sprites_active_area = 0;
848842
849843   for (off = 0; off < 0x4000; off += 16)
850844   {
851845      /* sprites_active_area may change during processing */
852      int offs = off + state->m_sprites_active_area;
846      int offs = off + m_sprites_active_area;
853847
854      if (state->m_spriteram_buffered[(offs + 6) / 2] & 0x8000)
848      if (m_spriteram_buffered[(offs + 6) / 2] & 0x8000)
855849      {
856         state->m_sprites_disabled = state->m_spriteram_buffered[(offs + 10) / 2] & 0x1000;
857         if (state->m_game == FOOTCHMP)
858            state->m_sprites_active_area = 0x8000 * (state->m_spriteram_buffered[(offs + 6) / 2] & 0x0001);
850         m_sprites_disabled = m_spriteram_buffered[(offs + 10) / 2] & 0x1000;
851         if (m_game == FOOTCHMP)
852            m_sprites_active_area = 0x8000 * (m_spriteram_buffered[(offs + 6) / 2] & 0x0001);
859853         else
860            state->m_sprites_active_area = 0x8000 * (state->m_spriteram_buffered[(offs + 10) / 2] & 0x0001);
854            m_sprites_active_area = 0x8000 * (m_spriteram_buffered[(offs + 10) / 2] & 0x0001);
861855         continue;
862856      }
863857
864858      /* check for extra scroll offset */
865      if ((state->m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0xa000)
859      if ((m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0xa000)
866860      {
867         state->m_sprites_master_scrollx = state->m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
868         if (state->m_sprites_master_scrollx >= 0x800)
869            state->m_sprites_master_scrollx -= 0x1000;   /* signed value */
861         m_sprites_master_scrollx = m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
862         if (m_sprites_master_scrollx >= 0x800)
863            m_sprites_master_scrollx -= 0x1000;   /* signed value */
870864
871         state->m_sprites_master_scrolly = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
872         if (state->m_sprites_master_scrolly >= 0x800)
873            state->m_sprites_master_scrolly -= 0x1000;   /* signed value */
865         m_sprites_master_scrolly = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
866         if (m_sprites_master_scrolly >= 0x800)
867            m_sprites_master_scrolly -= 0x1000;   /* signed value */
874868      }
875869   }
876870}
r21022r21023
881875   // rising edge
882876   if (state)
883877   {
884      taitof2_update_sprites_active_area(machine());
878      taitof2_update_sprites_active_area();
885879
886880      m_prepare_sprites = 1;
887881   }
r21022r21023
895889      UINT16 *spriteram = m_spriteram;
896890      int i;
897891
898      taitof2_update_sprites_active_area(machine());
892      taitof2_update_sprites_active_area();
899893
900894      m_prepare_sprites = 0;
901895      memcpy(m_spriteram_buffered, m_spriteram_delayed, m_spriteram.bytes());
r21022r21023
913907      UINT16 *spriteram = m_spriteram;
914908      int i;
915909
916      taitof2_update_sprites_active_area(machine());
910      taitof2_update_sprites_active_area();
917911
918912      m_prepare_sprites = 0;
919913      memcpy(m_spriteram_buffered, m_spriteram_delayed, m_spriteram.bytes());
r21022r21023
931925      UINT16 *spriteram = m_spriteram;
932926      int i;
933927
934      taitof2_update_sprites_active_area(machine());
928      taitof2_update_sprites_active_area();
935929
936930      m_prepare_sprites = 0;
937931      memcpy(m_spriteram_buffered, m_spriteram_delayed, m_spriteram.bytes());
r21022r21023
956950      UINT16 *spriteram = m_spriteram;
957951      int i;
958952
959      taitof2_update_sprites_active_area(machine());
953      taitof2_update_sprites_active_area();
960954
961955      m_prepare_sprites = 0;
962956      memcpy(m_spriteram_buffered, m_spriteram_delayed, m_spriteram.bytes());
r21022r21023
977971/* SSI */
978972UINT32 taitof2_state::screen_update_taitof2_ssi(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
979973{
980   taitof2_handle_sprite_buffering(machine());
974   taitof2_handle_sprite_buffering();
981975
982976   /* SSI only uses sprites, the tilemap registers are not even initialized.
983977      (they are in Majestic 12, but the tilemaps are not used anyway) */
984978   machine().priority_bitmap.fill(0, cliprect);
985979   bitmap.fill(0, cliprect);
986   draw_sprites(machine(), bitmap, cliprect, NULL, 0);
980   draw_sprites(bitmap, cliprect, NULL, 0);
987981   return 0;
988982}
989983
990984
991985UINT32 taitof2_state::screen_update_taitof2_yesnoj(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
992986{
993   taitof2_handle_sprite_buffering(machine());
987   taitof2_handle_sprite_buffering();
994988
995989   tc0100scn_tilemap_update(m_tc0100scn);
996990
997991   machine().priority_bitmap.fill(0, cliprect);
998992   bitmap.fill(0, cliprect);   /* wrong color? */
999   draw_sprites(machine(), bitmap, cliprect, NULL, 0);
993   draw_sprites(bitmap, cliprect, NULL, 0);
1000994   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, tc0100scn_bottomlayer(m_tc0100scn), 0, 0);
1001995   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, tc0100scn_bottomlayer(m_tc0100scn) ^ 1, 0, 0);
1002996   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, 2, 0, 0);
r21022r21023
10061000
10071001UINT32 taitof2_state::screen_update_taitof2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
10081002{
1009   taitof2_handle_sprite_buffering(machine());
1003   taitof2_handle_sprite_buffering();
10101004
10111005   tc0100scn_tilemap_update(m_tc0100scn);
10121006
r21022r21023
10141008   bitmap.fill(0, cliprect);   /* wrong color? */
10151009   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, tc0100scn_bottomlayer(m_tc0100scn), 0, 0);
10161010   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, tc0100scn_bottomlayer(m_tc0100scn) ^ 1, 0, 0);
1017   draw_sprites(machine(), bitmap, cliprect, NULL, 0);
1011   draw_sprites(bitmap, cliprect, NULL, 0);
10181012   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, 2, 0, 0);
10191013   return 0;
10201014}
r21022r21023
10251019   address_space &space = machine().driver_data()->generic_space();
10261020   int layer[3];
10271021
1028   taitof2_handle_sprite_buffering(machine());
1022   taitof2_handle_sprite_buffering();
10291023
10301024   tc0100scn_tilemap_update(m_tc0100scn);
10311025
r21022r21023
10501044   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[1], 0, 2);
10511045   tc0100scn_tilemap_draw(m_tc0100scn, bitmap, cliprect, layer[2], 0, 4);
10521046
1053   draw_sprites(machine(), bitmap, cliprect, NULL, 1);
1047   draw_sprites(bitmap, cliprect, NULL, 1);
10541048   return 0;
10551049}
10561050
10571051
10581052
1059static void draw_roz_layer( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 priority)
1053void taitof2_state::draw_roz_layer( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 priority)
10601054{
1061   taitof2_state *state = machine.driver_data<taitof2_state>();
10621055
1063   if (state->m_tc0280grd != NULL)
1064      tc0280grd_zoom_draw(state->m_tc0280grd, bitmap, cliprect, state->m_pivot_xdisp, state->m_pivot_ydisp, priority);
1056   if (m_tc0280grd != NULL)
1057      tc0280grd_zoom_draw(m_tc0280grd, bitmap, cliprect, m_pivot_xdisp, m_pivot_ydisp, priority);
10651058
1066   if (state->m_tc0430grw != NULL)
1067      tc0430grw_zoom_draw(state->m_tc0430grw, bitmap, cliprect, state->m_pivot_xdisp, state->m_pivot_ydisp, priority);
1059   if (m_tc0430grw != NULL)
1060      tc0430grw_zoom_draw(m_tc0430grw, bitmap, cliprect, m_pivot_xdisp, m_pivot_ydisp, priority);
10681061}
10691062
10701063UINT32 taitof2_state::screen_update_taitof2_pri_roz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r21022r21023
10771070   int i,j;
10781071   int roz_base_color = (tc0360pri_r(m_tc0360pri, space, 1) & 0x3f) << 2;
10791072
1080   taitof2_handle_sprite_buffering(machine());
1073   taitof2_handle_sprite_buffering();
10811074
10821075   if (m_tc0280grd != NULL)
10831076      tc0280grd_tilemap_update(m_tc0280grd, roz_base_color);
r21022r21023
11131106   {
11141107      if (rozpri == i)
11151108      {
1116         draw_roz_layer(machine(), bitmap, cliprect, 1 << drawn);
1109         draw_roz_layer(bitmap, cliprect, 1 << drawn);
11171110         m_tilepri[drawn] = i;
11181111         drawn++;
11191112      }
r21022r21023
11291122      }
11301123   }
11311124
1132   draw_sprites(machine(), bitmap, cliprect, NULL, 1);
1125   draw_sprites(bitmap, cliprect, NULL, 1);
11331126   return 0;
11341127}
11351128
r21022r21023
11441137   int layer[2][3];
11451138   int drawn[2];
11461139
1147   taitof2_handle_sprite_buffering(machine());
1140   taitof2_handle_sprite_buffering();
11481141
11491142   tc0100scn_tilemap_update(m_tc0100scn_1);
11501143   tc0100scn_tilemap_update(m_tc0100scn_2);
r21022r21023
12201213         if (spritepri[i] < tilepri[1][1]) primasks[i] |= 0xff00;
12211214      }
12221215
1223      draw_sprites(machine(), bitmap,cliprect,primasks,0);
1216      draw_sprites(bitmap,cliprect,primasks,0);
12241217   }
12251218
12261219
r21022r21023
12791272   UINT8 layer[5], invlayer[4];
12801273   UINT16 priority;
12811274
1282   taitof2_handle_sprite_buffering(machine());
1275   taitof2_handle_sprite_buffering();
12831276
12841277   tc0480scp_tilemap_update(m_tc0480scp);
12851278
r21022r21023
13181311   tc0480scp_tilemap_draw(m_tc0480scp, bitmap, cliprect, layer[3], 0, 8);
13191312   tc0480scp_tilemap_draw(m_tc0480scp, bitmap, cliprect, layer[4], 0, 16);
13201313
1321   draw_sprites(machine(), bitmap, cliprect, NULL, 1);
1314   draw_sprites(bitmap, cliprect, NULL, 1);
13221315   return 0;
13231316}
13241317
r21022r21023
13321325   UINT8 spritepri[4];
13331326   UINT16 priority;
13341327
1335   taitof2_handle_sprite_buffering(machine());
1328   taitof2_handle_sprite_buffering();
13361329
13371330   tc0480scp_tilemap_update(m_tc0480scp);
13381331
r21022r21023
13771370         if (spritepri[i] < tilepri[(layer[3])]) primasks[i] |= 0xff00;
13781371      }
13791372
1380      draw_sprites(machine(), bitmap, cliprect, primasks, 0);
1373      draw_sprites(bitmap, cliprect, primasks, 0);
13811374   }
13821375
13831376   /*
trunk/src/mame/video/taito_l.c
r21022r21023
139139   return m_cur_ctrl;
140140}
141141
142void taitol_chardef14_m( running_machine &machine, int offset )
142void taitol_state::taitol_chardef14_m( int offset )
143143{
144   machine.gfx[2]->mark_dirty(offset / 32 + 0);
144   machine().gfx[2]->mark_dirty(offset / 32 + 0);
145145}
146146
147void taitol_chardef15_m( running_machine &machine, int offset )
147void taitol_state::taitol_chardef15_m( int offset )
148148{
149   machine.gfx[2]->mark_dirty(offset / 32 + 128);
149   machine().gfx[2]->mark_dirty(offset / 32 + 128);
150150}
151151
152void taitol_chardef16_m( running_machine &machine, int offset )
152void taitol_state::taitol_chardef16_m( int offset )
153153{
154   machine.gfx[2]->mark_dirty(offset / 32 + 256);
154   machine().gfx[2]->mark_dirty(offset / 32 + 256);
155155}
156156
157void taitol_chardef17_m( running_machine &machine, int offset )
157void taitol_state::taitol_chardef17_m( int offset )
158158{
159   machine.gfx[2]->mark_dirty(offset / 32 + 384);
159   machine().gfx[2]->mark_dirty(offset / 32 + 384);
160160}
161161
162void taitol_chardef1c_m( running_machine &machine, int offset )
162void taitol_state::taitol_chardef1c_m( int offset )
163163{
164   machine.gfx[2]->mark_dirty(offset / 32 + 512);
164   machine().gfx[2]->mark_dirty(offset / 32 + 512);
165165}
166166
167void taitol_chardef1d_m( running_machine &machine, int offset )
167void taitol_state::taitol_chardef1d_m( int offset )
168168{
169   machine.gfx[2]->mark_dirty(offset / 32 + 640);
169   machine().gfx[2]->mark_dirty(offset / 32 + 640);
170170}
171171
172void taitol_chardef1e_m( running_machine &machine, int offset )
172void taitol_state::taitol_chardef1e_m( int offset )
173173{
174   machine.gfx[2]->mark_dirty(offset / 32 + 768);
174   machine().gfx[2]->mark_dirty(offset / 32 + 768);
175175}
176176
177void taitol_chardef1f_m( running_machine &machine, int offset )
177void taitol_state::taitol_chardef1f_m( int offset )
178178{
179   machine.gfx[2]->mark_dirty(offset / 32 + 896);
179   machine().gfx[2]->mark_dirty(offset / 32 + 896);
180180}
181181
182void taitol_bg18_m( running_machine &machine, int offset )
182void taitol_state::taitol_bg18_m( int offset )
183183{
184   taitol_state *state = machine.driver_data<taitol_state>();
185   state->m_bg18_tilemap->mark_tile_dirty(offset / 2);
184   m_bg18_tilemap->mark_tile_dirty(offset / 2);
186185}
187186
188void taitol_bg19_m( running_machine &machine, int offset )
187void taitol_state::taitol_bg19_m( int offset )
189188{
190   taitol_state *state = machine.driver_data<taitol_state>();
191   state->m_bg19_tilemap->mark_tile_dirty(offset / 2);
189   m_bg19_tilemap->mark_tile_dirty(offset / 2);
192190}
193191
194void taitol_char1a_m( running_machine &machine, int offset )
192void taitol_state::taitol_char1a_m( int offset )
195193{
196   taitol_state *state = machine.driver_data<taitol_state>();
197   state->m_ch1a_tilemap->mark_tile_dirty(offset / 2);
194   m_ch1a_tilemap->mark_tile_dirty(offset / 2);
198195}
199196
200void taitol_obj1b_m( running_machine &machine, int offset )
197void taitol_state::taitol_obj1b_m( int offset )
201198{
202199#if 0
203200   if (offset >= 0x3f0 && offset <= 0x3ff)
r21022r21023
230227                 plgirs2 bullets and raimais big bosses.
231228*/
232229
233static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
230void taitol_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
234231{
235   taitol_state *state = machine.driver_data<taitol_state>();
236232   int offs;
237233
238234   /* at spriteram + 0x3f0 and 03f8 are the tilemap control registers; spriteram + 0x3e8 seems to be unused */
r21022r21023
240236   {
241237      int code, color, sx, sy, flipx, flipy;
242238
243      color = state->m_buff_spriteram[offs + 2] & 0x0f;
244      code = state->m_buff_spriteram[offs] | (state->m_buff_spriteram[offs + 1] << 8);
239      color = m_buff_spriteram[offs + 2] & 0x0f;
240      code = m_buff_spriteram[offs] | (m_buff_spriteram[offs + 1] << 8);
245241
246      code |= (state->m_horshoes_gfxbank & 0x03) << 10;
242      code |= (m_horshoes_gfxbank & 0x03) << 10;
247243
248      sx = state->m_buff_spriteram[offs + 4] | ((state->m_buff_spriteram[offs + 5] & 1) << 8);
249      sy = state->m_buff_spriteram[offs + 6];
244      sx = m_buff_spriteram[offs + 4] | ((m_buff_spriteram[offs + 5] & 1) << 8);
245      sy = m_buff_spriteram[offs + 6];
250246      if (sx >= 320)
251247         sx -= 512;
252      flipx = state->m_buff_spriteram[offs + 3] & 0x01;
253      flipy = state->m_buff_spriteram[offs + 3] & 0x02;
248      flipx = m_buff_spriteram[offs + 3] & 0x01;
249      flipy = m_buff_spriteram[offs + 3] & 0x02;
254250
255      if (state->m_flipscreen)
251      if (m_flipscreen)
256252      {
257253         sx = 304 - sx;
258254         sy = 240 - sy;
r21022r21023
260256         flipy = !flipy;
261257      }
262258
263      pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
259      pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
264260            code,
265261            color,
266262            flipx,flipy,
267263            sx,sy,
268            machine.priority_bitmap,
264            machine().priority_bitmap,
269265            (color & 0x08) ? 0xaa : 0x00,0);
270266   }
271267}
r21022r21023
302298      else                    /* split priority */
303299         m_bg18_tilemap->draw(bitmap, cliprect, 0,1);
304300
305      draw_sprites(machine(), bitmap, cliprect);
301      draw_sprites(bitmap, cliprect);
306302
307303      m_ch1a_tilemap->draw(bitmap, cliprect, 0, 0);
308304   }
trunk/src/mame/video/timeplt.c
r21022r21023
171171 *
172172 *************************************/
173173
174static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
174void timeplt_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
175175{
176   timeplt_state *state = machine.driver_data<timeplt_state>();
177   UINT8 *spriteram = state->m_spriteram;
178   UINT8 *spriteram_2 = state->m_spriteram2;
176   UINT8 *spriteram = m_spriteram;
177   UINT8 *spriteram_2 = m_spriteram2;
179178   int offs;
180179
181180   for (offs = 0x3e;offs >= 0x10;offs -= 2)
r21022r21023
188187      int flipx = ~spriteram_2[offs] & 0x40;
189188      int flipy = spriteram_2[offs] & 0x80;
190189
191      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
190      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
192191            code,
193192            color,
194193            flipx,flipy,
r21022r21023
207206UINT32 timeplt_state::screen_update_timeplt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
208207{
209208   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
210   draw_sprites(machine(), bitmap, cliprect);
209   draw_sprites(bitmap, cliprect);
211210   m_bg_tilemap->draw(bitmap, cliprect, 1, 0);
212211   return 0;
213212}
trunk/src/mame/video/thoop2.c
r21022r21023
9898
9999***************************************************************************/
100100
101static void thoop2_sort_sprites(running_machine &machine)
101void thoop2_state::thoop2_sort_sprites()
102102{
103   thoop2_state *state = machine.driver_data<thoop2_state>();
104103   int i;
105104
106   state->m_sprite_count[0] = 0;
107   state->m_sprite_count[1] = 0;
108   state->m_sprite_count[2] = 0;
109   state->m_sprite_count[3] = 0;
110   state->m_sprite_count[4] = 0;
105   m_sprite_count[0] = 0;
106   m_sprite_count[1] = 0;
107   m_sprite_count[2] = 0;
108   m_sprite_count[3] = 0;
109   m_sprite_count[4] = 0;
111110
112111   for (i = 3; i < (0x1000 - 6)/2; i += 4){
113      int color = (state->m_spriteram[i+2] & 0x7e00) >> 9;
114      int priority = (state->m_spriteram[i] & 0x3000) >> 12;
112      int color = (m_spriteram[i+2] & 0x7e00) >> 9;
113      int priority = (m_spriteram[i] & 0x3000) >> 12;
115114
116115      /* palettes 0x38-0x3f are used for high priority sprites in Big Karnak */
117116      if (color >= 0x38){
118         state->m_sprite_table[4][state->m_sprite_count[4]] = i;
119         state->m_sprite_count[4]++;
117         m_sprite_table[4][m_sprite_count[4]] = i;
118         m_sprite_count[4]++;
120119      }
121120
122121      /* save sprite number in the proper array for later */
123      state->m_sprite_table[priority][state->m_sprite_count[priority]] = i;
124      state->m_sprite_count[priority]++;
122      m_sprite_table[priority][m_sprite_count[priority]] = i;
123      m_sprite_count[priority]++;
125124   }
126125}
127126
r21022r21023
144143      3  | xxxxxxxx xxxxxx-- | sprite code (low bits)
145144*/
146145
147static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri)
146void thoop2_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri)
148147{
149   thoop2_state *state = machine.driver_data<thoop2_state>();
150148   int j, x, y, ex, ey;
151   gfx_element *gfx = machine.gfx[0];
149   gfx_element *gfx = machine().gfx[0];
152150
153151   static const int x_offset[2] = {0x0,0x2};
154152   static const int y_offset[2] = {0x0,0x1};
155153
156   for (j = 0; j < state->m_sprite_count[pri]; j++){
157      int i = state->m_sprite_table[pri][j];
158      int sx = state->m_spriteram[i+2] & 0x01ff;
159      int sy = (240 - (state->m_spriteram[i] & 0x00ff)) & 0x00ff;
160      int number = state->m_spriteram[i+3];
161      int color = (state->m_spriteram[i+2] & 0x7e00) >> 9;
162      int attr = (state->m_spriteram[i] & 0xfe00) >> 9;
154   for (j = 0; j < m_sprite_count[pri]; j++){
155      int i = m_sprite_table[pri][j];
156      int sx = m_spriteram[i+2] & 0x01ff;
157      int sy = (240 - (m_spriteram[i] & 0x00ff)) & 0x00ff;
158      int number = m_spriteram[i+3];
159      int color = (m_spriteram[i+2] & 0x7e00) >> 9;
160      int attr = (m_spriteram[i] & 0xfe00) >> 9;
163161
164162      int xflip = attr & 0x20;
165163      int yflip = attr & 0x40;
r21022r21023
202200   m_pant[1]->set_scrolly(0, m_vregs[2]);
203201   m_pant[1]->set_scrollx(0, m_vregs[3]);
204202
205   thoop2_sort_sprites(machine());
203   thoop2_sort_sprites();
206204
207205   bitmap.fill(0, cliprect );
208206
209207   m_pant[1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 3,0);
210208   m_pant[0]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 3,0);
211   draw_sprites(machine(), bitmap,cliprect,3);
209   draw_sprites(bitmap,cliprect,3);
212210   m_pant[1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 3,0);
213211   m_pant[0]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 3,0);
214212
215213   m_pant[1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 2,0);
216214   m_pant[0]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 2,0);
217   draw_sprites(machine(), bitmap,cliprect,2);
215   draw_sprites(bitmap,cliprect,2);
218216   m_pant[1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 2,0);
219217   m_pant[0]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 2,0);
220218
221219   m_pant[1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1,0);
222220   m_pant[0]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1,0);
223   draw_sprites(machine(), bitmap,cliprect,1);
221   draw_sprites(bitmap,cliprect,1);
224222   m_pant[1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1,0);
225223   m_pant[0]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1,0);
226224
227225   m_pant[1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0,0);
228226   m_pant[0]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0,0);
229   draw_sprites(machine(), bitmap,cliprect,0);
227   draw_sprites(bitmap,cliprect,0);
230228   m_pant[1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0,0);
231229   m_pant[0]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0,0);
232230
233   draw_sprites(machine(), bitmap,cliprect,4);
231   draw_sprites(bitmap,cliprect,4);
234232   return 0;
235233}
trunk/src/mame/video/tubep.c
r21022r21023
429429}
430430
431431
432static void draw_sprite(running_machine &machine)
432void tubep_state::draw_sprite()
433433{
434   tubep_state *state = machine.driver_data<tubep_state>();
435434   UINT32  XDOT;
436435   UINT32  YDOT;
437   UINT8 * romCxx  = state->memregion("user2")->base()+0x00000;
436   UINT8 * romCxx  = memregion("user2")->base()+0x00000;
438437   UINT8 * romD10  = romCxx+0x10000;
439438   UINT8 * romEF13 = romCxx+0x12000;
440439   UINT8 * romHI2  = romCxx+0x14000;
441440
442441
443   for (YDOT=0; (YDOT^state->m_YSize) != 0x00; YDOT++)
442   for (YDOT=0; (YDOT^m_YSize) != 0x00; YDOT++)
444443   {
445444   /* upper part of the schematic */
446      UINT32 ls273_e12 = romD10[ state->m_romD_addr | YDOT ] & 0x7f;
447      UINT32 romEF_addr_now = state->m_romEF_addr | ls273_e12;
445      UINT32 ls273_e12 = romD10[ m_romD_addr | YDOT ] & 0x7f;
446      UINT32 romEF_addr_now = m_romEF_addr | ls273_e12;
448447      UINT32 E16_add_a = romEF13[ romEF_addr_now ] |
449448                     ((romEF13[0x1000 + romEF_addr_now ]&0x0f)<<8);
450      UINT32 F16_add_b = E16_add_a + state->m_E16_add_b;
449      UINT32 F16_add_b = E16_add_a + m_E16_add_b;
451450
452451   /* lower part of the schematic */
453      UINT32 romHI_addr = (YDOT) | (state->m_romHI_addr_mid) | (((state->m_romHI_addr_msb + 0x800) )&0x1800);
452      UINT32 romHI_addr = (YDOT) | (m_romHI_addr_mid) | (((m_romHI_addr_msb + 0x800) )&0x1800);
454453      UINT32 ls273_g4 = romHI2[ romHI_addr ];
455454      UINT32 ls273_j4 = romHI2[0x2000+ romHI_addr ];
456      UINT32 ls86_gh5 = ls273_g4 ^ state->m_VINV;
457      UINT32 ls86_ij5 = ls273_j4 ^ state->m_VINV;
455      UINT32 ls86_gh5 = ls273_g4 ^ m_VINV;
456      UINT32 ls86_ij5 = ls273_j4 ^ m_VINV;
458457
459      UINT32 ls157_gh7= state->m_ls273_g6 | (state->m_mark_2);
460      UINT32 ls157_ij7= state->m_ls273_j6 | (state->m_mark_1);
461      UINT32 ls283_gh8= (state->m_VINV & 1) + ls86_gh5 + ((ls86_gh5 & 0x80)<<1) + ls157_gh7;
462      UINT32 ls283_ij8= (state->m_VINV & 1) + ls86_ij5 + ((ls86_ij5 & 0x80)<<1) + ls157_ij7;
458      UINT32 ls157_gh7= m_ls273_g6 | (m_mark_2);
459      UINT32 ls157_ij7= m_ls273_j6 | (m_mark_1);
460      UINT32 ls283_gh8= (m_VINV & 1) + ls86_gh5 + ((ls86_gh5 & 0x80)<<1) + ls157_gh7;
461      UINT32 ls283_ij8= (m_VINV & 1) + ls86_ij5 + ((ls86_ij5 & 0x80)<<1) + ls157_ij7;
463462
464463      UINT32 ls273_g9 = ls283_gh8;
465464      UINT32 ls273_j9 = ls283_ij8;
466465
467      for (XDOT=0; (XDOT^state->m_XSize) != 0x00; XDOT++)
466      for (XDOT=0; (XDOT^m_XSize) != 0x00; XDOT++)
468467      {
469468   /* upper part of the schematic */
470         UINT32 romD10_out = romD10[ state->m_romD_addr | XDOT ];
469         UINT32 romD10_out = romD10[ m_romD_addr | XDOT ];
471470         UINT32 F16_add_a = (romD10_out & 0x7e) >>1;
472471         UINT32 romCxx_addr = (F16_add_a + F16_add_b ) & 0xffff;
473472         UINT32 romCxx_out = romCxx[ romCxx_addr ];
474473
475474         UINT32 colorram_addr_lo = (romD10_out&1) ? (romCxx_out>>4)&0x0f: (romCxx_out>>0)&0x0f;
476475
477         UINT8 sp_data = state->m_sprite_colorsharedram[ state->m_colorram_addr_hi | colorram_addr_lo ] & 0x0f; /* 2114 4-bit RAM */
476         UINT8 sp_data = m_sprite_colorsharedram[ m_colorram_addr_hi | colorram_addr_lo ] & 0x0f; /* 2114 4-bit RAM */
478477
479478   /* lower part of the schematic */
480         romHI_addr = (XDOT) | (state->m_romHI_addr_mid) | (state->m_romHI_addr_msb);
479         romHI_addr = (XDOT) | (m_romHI_addr_mid) | (m_romHI_addr_msb);
481480         ls273_g4 = romHI2[ romHI_addr ];
482481         ls273_j4 = romHI2[0x2000+ romHI_addr ];
483         ls86_gh5 = ls273_g4 ^ state->m_HINV;
484         ls86_ij5 = ls273_j4 ^ state->m_HINV;
482         ls86_gh5 = ls273_g4 ^ m_HINV;
483         ls86_ij5 = ls273_j4 ^ m_HINV;
485484
486485         ls157_gh7= ls273_g9;
487486         ls157_ij7= ls273_j9;
488         ls283_gh8= (state->m_HINV & 1) + ls86_gh5 + ((ls86_gh5 & 0x80)<<1) + ls157_gh7;
489         ls283_ij8= (state->m_HINV & 1) + ls86_ij5 + ((ls86_ij5 & 0x80)<<1) + ls157_ij7;
487         ls283_gh8= (m_HINV & 1) + ls86_gh5 + ((ls86_gh5 & 0x80)<<1) + ls157_gh7;
488         ls283_ij8= (m_HINV & 1) + ls86_ij5 + ((ls86_ij5 & 0x80)<<1) + ls157_ij7;
490489
491490
492491         if ( !((ls283_gh8&256) | (ls283_ij8&256)) ) /* skip wrapped sprite area - PAL12L6 (PLA019 in Roller Jammer schematics)*/
493492         {
494            if ( state->m_spritemap[ (ls283_gh8&255) + (ls283_ij8&255)*256 + state->m_DISP*256*256 ] == 0x0f )
495               state->m_spritemap[ (ls283_gh8&255) + (ls283_ij8&255)*256 + state->m_DISP*256*256 ] = sp_data;
493            if ( m_spritemap[ (ls283_gh8&255) + (ls283_ij8&255)*256 + m_DISP*256*256 ] == 0x0f )
494               m_spritemap[ (ls283_gh8&255) + (ls283_ij8&255)*256 + m_DISP*256*256 ] = sp_data;
496495         }
497496      }
498497   }
r21022r21023
561560         machine().scheduler().timer_set( attotime::from_hz(19968000/8) * ((m_XSize+1)*(m_YSize+1)), timer_expired_delegate(FUNC(tubep_state::sprite_timer_callback),this));
562561
563562         /* 3.clear of /SINT starts sprite drawing circuit */
564         draw_sprite(machine());
563         draw_sprite();
565564         break;
566565      }
567566   }
568567}
569568
570void tubep_vblank_end(running_machine &machine)
569void tubep_state::tubep_vblank_end()
571570{
572   tubep_state *state = machine.driver_data<tubep_state>();
573   state->m_DISP = state->m_DISP ^ 1;
574   /* logerror("EOF: DISP after this is=%i, and clearing it now.\n", state->m_DISP); */
571   m_DISP = m_DISP ^ 1;
572   /* logerror("EOF: DISP after this is=%i, and clearing it now.\n", m_DISP); */
575573   /* clear the new frame (the one that was (just) displayed)*/
576   memset(state->m_spritemap+state->m_DISP*256*256, 0x0f, 256*256);
574   memset(m_spritemap+m_DISP*256*256, 0x0f, 256*256);
577575}
578576
579577
trunk/src/mame/video/triplhnt.c
r21022r21023
2626
2727TIMER_CALLBACK_MEMBER(triplhnt_state::triplhnt_hit_callback)
2828{
29   triplhnt_set_collision(machine(), param);
29   triplhnt_set_collision(param);
3030}
3131
3232
33static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
33void triplhnt_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
3434{
35   triplhnt_state *state = machine.driver_data<triplhnt_state>();
3635   int i;
3736
3837   int hit_line = 999;
r21022r21023
4241   {
4342      rectangle rect;
4443
45      int j = (state->m_orga_ram[i] & 15) ^ 15;
44      int j = (m_orga_ram[i] & 15) ^ 15;
4645
4746      /* software sorts sprites by x and stores order in orga RAM */
4847
49      int hpos = state->m_hpos_ram[j] ^ 255;
50      int vpos = state->m_vpos_ram[j] ^ 255;
51      int code = state->m_code_ram[j] ^ 255;
48      int hpos = m_hpos_ram[j] ^ 255;
49      int vpos = m_vpos_ram[j] ^ 255;
50      int code = m_code_ram[j] ^ 255;
5251
5352      if (hpos == 255)
5453         continue;
5554
5655      /* sprite placement might be wrong */
5756
58      if (state->m_sprite_zoom)
57      if (m_sprite_zoom)
5958      {
6059         rect.set(hpos - 16, hpos - 16 + 63, 196 - vpos, 196 - vpos + 63);
6160      }
r21022r21023
6665
6766      /* render sprite to auxiliary bitmap */
6867
69      drawgfx_opaque(state->m_helper, cliprect, machine.gfx[state->m_sprite_zoom],
70         2 * code + state->m_sprite_bank, 0, code & 8, 0,
68      drawgfx_opaque(m_helper, cliprect, machine().gfx[m_sprite_zoom],
69         2 * code + m_sprite_bank, 0, code & 8, 0,
7170         rect.min_x, rect.min_y);
7271
7372      rect &= cliprect;
r21022r21023
8281         {
8382            for (y = rect.min_y; y <= rect.max_y; y++)
8483            {
85               pen_t a = state->m_helper.pix16(y, x);
84               pen_t a = m_helper.pix16(y, x);
8685               pen_t b = bitmap.pix16(y, x);
8786
8887               if (a == 2 && b == 7)
r21022r21023
9998   }
10099
101100   if (hit_line != 999 && hit_code != 999)
102      machine.scheduler().timer_set(machine.primary_screen->time_until_pos(hit_line), timer_expired_delegate(FUNC(triplhnt_state::triplhnt_hit_callback),state), hit_code);
101      machine().scheduler().timer_set(machine().primary_screen->time_until_pos(hit_line), timer_expired_delegate(FUNC(triplhnt_state::triplhnt_hit_callback),this), hit_code);
103102}
104103
105104
r21022r21023
111110
112111   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
113112
114   draw_sprites(machine(), bitmap, cliprect);
113   draw_sprites(bitmap, cliprect);
115114
116115   address_space &space = machine().driver_data()->generic_space();
117116   discrete_sound_w(discrete, space, TRIPLHNT_BEAR_ROAR_DATA, m_playfield_ram[0xfa] & 15);
trunk/src/mame/video/tankbatt.c
r21022r21023
8080   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tankbatt_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
8181}
8282
83static void draw_bullets(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
83void tankbatt_state::draw_bullets(bitmap_ind16 &bitmap, const rectangle &cliprect)
8484{
85   tankbatt_state *state = machine.driver_data<tankbatt_state>();
8685   int offs;
8786
88   for (offs = 0;offs < state->m_bulletsram.bytes();offs += 2)
87   for (offs = 0;offs < m_bulletsram.bytes();offs += 2)
8988   {
9089      int color = 0xff;   /* cyan, same color as the tanks */
91      int x = state->m_bulletsram[offs + 1];
92      int y = 255 - state->m_bulletsram[offs] - 2;
90      int x = m_bulletsram[offs + 1];
91      int y = 255 - m_bulletsram[offs] - 2;
9392
94      drawgfx_opaque(bitmap,cliprect,machine.gfx[1],
93      drawgfx_opaque(bitmap,cliprect,machine().gfx[1],
9594         0,  /* this is just a square, generated by the hardware */
9695         color,
9796         0,0,
r21022r21023
102101UINT32 tankbatt_state::screen_update_tankbatt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
103102{
104103   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
105   draw_bullets(machine(), bitmap, cliprect);
104   draw_bullets(bitmap, cliprect);
106105   return 0;
107106}
trunk/src/mame/video/twin16.c
r21022r21023
142142   m_sprite_busy = 0;
143143}
144144
145static int twin16_set_sprite_timer( running_machine &machine )
145int twin16_state::twin16_set_sprite_timer(  )
146146{
147   twin16_state *state = machine.driver_data<twin16_state>();
148   if (state->m_sprite_busy) return 1;
147   if (m_sprite_busy) return 1;
149148
150149   // sprite system busy, maybe a dma? time is guessed, assume 4 scanlines
151   state->m_sprite_busy = 1;
152   state->m_sprite_timer->adjust(machine.primary_screen->frame_period() / machine.primary_screen->height() * 4);
150   m_sprite_busy = 1;
151   m_sprite_timer->adjust(machine().primary_screen->frame_period() / machine().primary_screen->height() * 4);
153152
154153   return 0;
155154}
156155
157void twin16_spriteram_process( running_machine &machine )
156void twin16_state::twin16_spriteram_process(  )
158157{
159   twin16_state *state = machine.driver_data<twin16_state>();
160   UINT16 *spriteram16 = state->m_spriteram->live();
161   UINT16 dx = state->m_scrollx[0];
162   UINT16 dy = state->m_scrolly[0];
158   UINT16 *spriteram16 = m_spriteram->live();
159   UINT16 dx = m_scrollx[0];
160   UINT16 dy = m_scrolly[0];
163161
164162   const UINT16 *source = &spriteram16[0x0000];
165163   const UINT16 *finish = &spriteram16[0x1800];
166164
167   twin16_set_sprite_timer(machine);
165   twin16_set_sprite_timer();
168166   memset(&spriteram16[0x1800],0xff,0x800*sizeof(UINT16));
169167
170168   while( source<finish )
r21022r21023
213211      }
214212      source += 0x50/2;
215213   }
216   state->m_need_process_spriteram = 0;
214   m_need_process_spriteram = 0;
217215}
218216
219static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap )
217void twin16_state::draw_sprites( bitmap_ind16 &bitmap )
220218{
221   twin16_state *state = machine.driver_data<twin16_state>();
222   const UINT16 *source = 0x1800+state->m_spriteram->buffer() + 0x800 - 4;
223   const UINT16 *finish = 0x1800+state->m_spriteram->buffer();
219   const UINT16 *source = 0x1800+m_spriteram->buffer() + 0x800 - 4;
220   const UINT16 *finish = 0x1800+m_spriteram->buffer();
224221
225222   for (; source >= finish; source -= 4)
226223   {
r21022r21023
241238         int flipx = attributes&0x0100;
242239         int priority = (attributes&0x4000)?TWIN16_SPRITE_PRI_L1:TWIN16_SPRITE_PRI_L2;
243240
244         if( state->m_custom_video ) {
241         if( m_custom_video ) {
245242            /* fround board */
246            pen_data = state->m_gfx_rom + 0x80000;
243            pen_data = m_gfx_rom + 0x80000;
247244         }
248245         else
249246         {
r21022r21023
251248            {
252249               /* bank select */
253250               case 0:
254                  pen_data = state->m_gfx_rom;
251                  pen_data = m_gfx_rom;
255252                  break;
256253
257254               case 1:
258                  pen_data = state->m_gfx_rom + 0x40000;
255                  pen_data = m_gfx_rom + 0x40000;
259256                  break;
260257
261258               case 2:
262                  pen_data = state->m_gfx_rom + 0x80000;
259                  pen_data = m_gfx_rom + 0x80000;
263260                  if( code&0x4000 ) pen_data += 0x40000;
264261                  break;
265262
266263               case 3:
267                  pen_data = state->m_sprite_gfx_ram;
264                  pen_data = m_sprite_gfx_ram;
268265                  break;
269266            }
270267            code &= 0xfff;
r21022r21023
277274
278275         pen_data += code*0x40;
279276
280         if( state->m_video_register&TWIN16_SCREEN_FLIPY )
277         if( m_video_register&TWIN16_SCREEN_FLIPY )
281278         {
282279            if (ypos>65000) ypos=ypos-65536; /* Bit hacky */
283280            ypos = 256-ypos-height;
284281            flipy = !flipy;
285282         }
286         if( state->m_video_register&TWIN16_SCREEN_FLIPX )
283         if( m_video_register&TWIN16_SCREEN_FLIPX )
287284         {
288285            if (xpos>65000) xpos=xpos-65536; /* Bit hacky */
289286            xpos = 320-xpos-width;
r21022r21023
299296            if( sy>=16 && sy<256-16 )
300297            {
301298               UINT16 *dest = &bitmap.pix16(sy);
302               UINT8 *pdest = &machine.priority_bitmap.pix8(sy);
299               UINT8 *pdest = &machine().priority_bitmap.pix8(sy);
303300
304301               for( x=0; x<width; x++ )
305302               {
r21022r21023
314311
315312                        if (pdest[sx]<priority) {
316313                           if (shadow) {
317                              dest[sx] = machine.shadow_table[dest[sx]];
314                              dest[sx] = machine().shadow_table[dest[sx]];
318315                              pdest[sx]|=TWIN16_SPRITE_CAST_SHADOW;
319316                           }
320317                           else {
r21022r21023
323320                        }
324321                        else if (!shadow && pdest[sx]&TWIN16_SPRITE_CAST_SHADOW && (pdest[sx]&0xf)<priority) {
325322                           // shadow cast onto sprite below, evident in devilw lava level
326                           dest[sx] = machine.shadow_table[pal_base + pen];
323                           dest[sx] = machine().shadow_table[pal_base + pen];
327324                           pdest[sx]^=TWIN16_SPRITE_CAST_SHADOW;
328325                        }
329326
r21022r21023
339336
340337
341338
342static void draw_layer( running_machine &machine, bitmap_ind16 &bitmap, int opaque )
339void twin16_state::draw_layer( bitmap_ind16 &bitmap, int opaque )
343340{
344   twin16_state *state = machine.driver_data<twin16_state>();
345   UINT16 *videoram = state->m_videoram;
341   UINT16 *videoram = m_videoram;
346342   const UINT16 *gfx_base;
347343   const UINT16 *source = videoram;
348344   int i, xxor, yxor;
349345   int bank_table[4];
350346   int dx, dy, palette;
351   int tile_flipx = state->m_video_register&TWIN16_TILE_FLIPX;
352   int tile_flipy = state->m_video_register&TWIN16_TILE_FLIPY;
347   int tile_flipx = m_video_register&TWIN16_TILE_FLIPX;
348   int tile_flipy = m_video_register&TWIN16_TILE_FLIPY;
353349
354   if( ((state->m_video_register&TWIN16_PLANE_ORDER)?1:0) != opaque ) {
350   if( ((m_video_register&TWIN16_PLANE_ORDER)?1:0) != opaque ) {
355351      source += 0x1000;
356      dx = state->m_scrollx[2];
357      dy = state->m_scrolly[2];
352      dx = m_scrollx[2];
353      dy = m_scrolly[2];
358354      palette = 1;
359355   }
360356   else {
361357      source += 0x0000;
362      dx = state->m_scrollx[1];
363      dy = state->m_scrolly[1];
358      dx = m_scrollx[1];
359      dy = m_scrolly[1];
364360      palette = 0;
365361   }
366362
367   if( state->m_custom_video ) {
363   if( m_custom_video ) {
368364      /* fround board */
369      gfx_base = state->m_gfx_rom;
370      bank_table[3] = (state->m_gfx_bank>>(4*3))&0xf;
371      bank_table[2] = (state->m_gfx_bank>>(4*2))&0xf;
372      bank_table[1] = (state->m_gfx_bank>>(4*1))&0xf;
373      bank_table[0] = (state->m_gfx_bank>>(4*0))&0xf;
365      gfx_base = m_gfx_rom;
366      bank_table[3] = (m_gfx_bank>>(4*3))&0xf;
367      bank_table[2] = (m_gfx_bank>>(4*2))&0xf;
368      bank_table[1] = (m_gfx_bank>>(4*1))&0xf;
369      bank_table[0] = (m_gfx_bank>>(4*0))&0xf;
374370   }
375371   else {
376      gfx_base = state->m_tile_gfx_ram;
372      gfx_base = m_tile_gfx_ram;
377373      bank_table[0] = 0;
378374      bank_table[1] = 1;
379375      bank_table[2] = 2;
380376      bank_table[3] = 3;
381377   }
382378
383   if( state->m_video_register&TWIN16_SCREEN_FLIPX )
379   if( m_video_register&TWIN16_SCREEN_FLIPX )
384380   {
385381      dx = 256-dx-64;
386382      tile_flipx = !tile_flipx;
387383   }
388384
389   if( state->m_video_register&TWIN16_SCREEN_FLIPY )
385   if( m_video_register&TWIN16_SCREEN_FLIPY )
390386   {
391387      dy = 256-dy;
392388      tile_flipy = !tile_flipy;
r21022r21023
402398      int sy = (i/64)*8;
403399      int xpos,ypos;
404400
405      if( state->m_video_register&TWIN16_SCREEN_FLIPX ) sx = 63*8 - sx;
406      if( state->m_video_register&TWIN16_SCREEN_FLIPY ) sy = 63*8 - sy;
401      if( m_video_register&TWIN16_SCREEN_FLIPX ) sx = 63*8 - sx;
402      if( m_video_register&TWIN16_SCREEN_FLIPY ) sy = 63*8 - sy;
407403
408404      xpos = (sx-dx)&0x1ff;
409405      ypos = (sy-dy)&0x1ff;
r21022r21023
434430            {
435431               const UINT16 *gfxptr = gfx_data + ((y - ypos) ^ yxor) * 2;
436432               UINT16 *dest = &bitmap.pix16(y);
437               UINT8 *pdest = &machine.priority_bitmap.pix8(y);
433               UINT8 *pdest = &machine().priority_bitmap.pix8(y);
438434
439435               for (x = x1; x <= x2; x++)
440436               {
r21022r21023
451447            {
452448               const UINT16 *gfxptr = gfx_data + ((y - ypos) ^ yxor) * 2;
453449               UINT16 *dest = &bitmap.pix16(y);
454               UINT8 *pdest = &machine.priority_bitmap.pix8(y);
450               UINT8 *pdest = &machine().priority_bitmap.pix8(y);
455451
456452               for (x = x1; x <= x2; x++)
457453               {
r21022r21023
520516   if (m_video_register&TWIN16_SCREEN_FLIPY) text_flip|=TILEMAP_FLIPY;
521517
522518   machine().priority_bitmap.fill(0, cliprect);
523   draw_layer( machine(), bitmap, 1 );
524   draw_layer( machine(), bitmap, 0 );
525   draw_sprites( machine(), bitmap );
519   draw_layer( bitmap, 1 );
520   draw_layer( bitmap, 0 );
521   draw_sprites( bitmap );
526522
527523   if (text_flip) m_text_tilemap->set_flip(text_flip);
528524   m_text_tilemap->draw(bitmap, cliprect, 0, 0);
r21022r21023
534530   // rising edge
535531   if (state)
536532   {
537      twin16_set_sprite_timer(machine());
533      twin16_set_sprite_timer();
538534
539      if (twin16_spriteram_process_enable(machine())) {
540         if (m_need_process_spriteram) twin16_spriteram_process(machine());
535      if (twin16_spriteram_process_enable()) {
536         if (m_need_process_spriteram) twin16_spriteram_process();
541537         m_need_process_spriteram = 1;
542538
543539         /* if the sprite preprocessor is used, sprite ram is copied to an external buffer first,
trunk/src/mame/video/tutankhm.c
r21022r21023
3737 *
3838 *************************************/
3939
40static void get_pens( running_machine &machine, pen_t *pens )
40void tutankhm_state::get_pens( pen_t *pens )
4141{
42   tutankhm_state *state = machine.driver_data<tutankhm_state>();
4342   offs_t i;
4443
4544   for (i = 0; i < NUM_PENS; i++)
4645   {
47      UINT8 data = state->m_paletteram[i];
46      UINT8 data = m_paletteram[i];
4847
4948      pens[i] = MAKE_RGB(pal3bit(data >> 0), pal3bit(data >> 3), pal2bit(data >> 6));
5049   }
r21022r21023
6463   pen_t pens[NUM_PENS];
6564   int x, y;
6665
67   get_pens(machine(), pens);
66   get_pens( pens);
6867
6968   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
7069   {
trunk/src/mame/video/targeth.c
r21022r21023
101101      3  | xx------ -------- | not used?
102102*/
103103
104static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
104void targeth_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
105105{
106   targeth_state *state = machine.driver_data<targeth_state>();
107106   int i;
108   gfx_element *gfx = machine.gfx[0];
107   gfx_element *gfx = machine().gfx[0];
109108
110109   for (i = 3; i < (0x1000 - 6)/2; i += 4){
111      int sx = state->m_spriteram[i+2] & 0x03ff;
112      int sy = (240 - (state->m_spriteram[i] & 0x00ff)) & 0x00ff;
113      int number = state->m_spriteram[i+3] & 0x3fff;
114      int color = (state->m_spriteram[i+2] & 0x7c00) >> 10;
115      int attr = (state->m_spriteram[i] & 0xfe00) >> 9;
110      int sx = m_spriteram[i+2] & 0x03ff;
111      int sy = (240 - (m_spriteram[i] & 0x00ff)) & 0x00ff;
112      int number = m_spriteram[i+3] & 0x3fff;
113      int color = (m_spriteram[i+2] & 0x7c00) >> 10;
114      int attr = (m_spriteram[i] & 0xfe00) >> 9;
116115
117116      int xflip = attr & 0x20;
118117      int yflip = attr & 0x40;
r21022r21023
139138
140139   m_pant[1]->draw(bitmap, cliprect, 0,0);
141140   m_pant[0]->draw(bitmap, cliprect, 0,0);
142   draw_sprites(machine(), bitmap,cliprect);
141   draw_sprites(bitmap,cliprect);
143142
144143   return 0;
145144}
trunk/src/mame/video/tunhunt.c
r21022r21023
138138        8-E             Lines (as normal) background
139139        F               Hilight 3
140140*/
141static void set_pens(running_machine &machine)
141void tunhunt_state::set_pens()
142142{
143143/*
144144    The actual contents of the color proms (unused by this driver)
r21022r21023
152152    0020:   00 f0 f0 f0 b0 b0 00 f0
153153            00 f0 f0 00 b0 00 f0 f0
154154*/
155   //const UINT8 *color_prom = machine.root_device().memregion( "proms" )->base();
156   tunhunt_state *state = machine.driver_data<tunhunt_state>();
155   //const UINT8 *color_prom = machine().root_device().memregion( "proms" )->base();
157156   int color;
158157   int shade;
159158   int i;
r21022r21023
161160
162161   for( i=0; i<16; i++ )
163162   {
164      color = state->m_generic_paletteram_8[i];
163      color = m_generic_paletteram_8[i];
165164      shade = 0xf^(color>>4);
166165
167166      color &= 0xf; /* hue select */
r21022r21023
193192      green   = APPLY_SHADE(green,shade);
194193      blue    = APPLY_SHADE(blue,shade);
195194
196      colortable_palette_set_color( machine.colortable,i,MAKE_RGB(red,green,blue) );
195      colortable_palette_set_color( machine().colortable,i,MAKE_RGB(red,green,blue) );
197196   }
198197}
199198
200static void draw_motion_object(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
199void tunhunt_state::draw_motion_object(bitmap_ind16 &bitmap, const rectangle &cliprect)
201200{
202201/*
203202 *      VSTRLO  0x1202
r21022r21023
210209 *          always 0x00?
211210 */
212211
213   tunhunt_state *state = machine.driver_data<tunhunt_state>();
214   bitmap_ind16 &tmpbitmap = state->m_tmpbitmap;
215   UINT8 *spriteram = state->m_spriteram;
216   UINT8 *tunhunt_ram = state->m_workram;
212   bitmap_ind16 &tmpbitmap = m_tmpbitmap;
213   UINT8 *spriteram = m_spriteram;
214   UINT8 *tunhunt_ram = m_workram;
217215   //int skip = tunhunt_ram[MOBST];
218216   int x0 = 255-tunhunt_ram[MOBJV];
219217   int y0 = 255-tunhunt_ram[MOBJH];
r21022r21023
269267   );
270268}
271269
272static void draw_box(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
270void tunhunt_state::draw_box(bitmap_ind16 &bitmap, const rectangle &cliprect)
273271{
274272/*
275273    This is unnecessarily slow, but the box priorities aren't completely understood,
r21022r21023
289287        1280: 07 03 00      01  07 06 04 05 02 07 03 00     09 0a   0b 0c       palette select
290288        ->hue 06 02 ff      60  06 05 03 04 01 06 02 ff     d2 00   c2 ff
291289*/
292   tunhunt_state *state = machine.driver_data<tunhunt_state>();
293   UINT8 *tunhunt_ram = state->m_workram;
290   UINT8 *tunhunt_ram = m_workram;
294291   int span,x,y;
295292   int color;
296293//  rectangle bbox;
r21022r21023
323320}
324321
325322/* "shell" graphics are 16x16 pixel tiles used for player shots and targeting cursor */
326static void draw_shell(running_machine &machine,
327      bitmap_ind16 &bitmap,
323void tunhunt_state::draw_shell(bitmap_ind16 &bitmap,
328324      const rectangle &cliprect,
329325      int picture_code,
330326      int hposition,
r21022r21023
341337         for( sy=0; sy<256; sy+=16 )
342338         {
343339            drawgfx_transpen( bitmap, cliprect,
344               machine.gfx[1],
340               machine().gfx[1],
345341               picture_code,
346342               0, /* color */
347343               0,0, /* flip */
r21022r21023
366362
367363   */
368364   drawgfx_transpen( bitmap, cliprect,
369         machine.gfx[1],
365         machine().gfx[1],
370366         picture_code,
371367         0, /* color */
372368         0,0, /* flip */
r21022r21023
375371
376372UINT32 tunhunt_state::screen_update_tunhunt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
377373{
378   set_pens(machine());
374   set_pens();
379375
380   draw_box(machine(), bitmap, cliprect);
376   draw_box(bitmap, cliprect);
381377
382   draw_motion_object(machine(), bitmap, cliprect);
378   draw_motion_object(bitmap, cliprect);
383379
384   draw_shell(machine(), bitmap, cliprect,
380   draw_shell(bitmap, cliprect,
385381      m_workram[SHL0PC],  /* picture code */
386382      m_workram[SHEL0H],  /* hposition */
387383      m_workram[SHL0V],   /* vstart */
r21022r21023
389385      m_workram[SHL0ST],  /* vstretch */
390386      m_control&0x08 ); /* hstretch */
391387
392   draw_shell(machine(), bitmap, cliprect,
388   draw_shell(bitmap, cliprect,
393389      m_workram[SHL1PC],  /* picture code */
394390      m_workram[SHEL1H],  /* hposition */
395391      m_workram[SHL1V],   /* vstart */
trunk/src/mame/video/tbowl.c
r21022r21023
119119}
120120
121121
122void tbowl_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int xscroll, UINT8* spriteram)
122void tbowl_state::tbowl_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect, int xscroll, UINT8* spriteram)
123123{
124124   int offs;
125125   static const UINT8 layout[8][8] =
r21022r21023
162162
163163               sx -= xscroll;
164164
165               drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
165               drawgfx_transpen(bitmap,cliprect,machine().gfx[3],
166166                     code + layout[y][x],
167167                     color,
168168                     flipx,flipy,
169169                     sx,sy,0 );
170170
171171               /* wraparound */
172               drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
172               drawgfx_transpen(bitmap,cliprect,machine().gfx[3],
173173                     code + layout[y][x],
174174                     color,
175175                     flipx,flipy,
176176                     sx,sy-0x200,0 );
177177
178178               /* wraparound */
179               drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
179               drawgfx_transpen(bitmap,cliprect,machine().gfx[3],
180180                     code + layout[y][x],
181181                     color,
182182                     flipx,flipy,
183183                     sx-0x400,sy,0 );
184184
185185               /* wraparound */
186               drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
186               drawgfx_transpen(bitmap,cliprect,machine().gfx[3],
187187                     code + layout[y][x],
188188                     color,
189189                     flipx,flipy,
r21022r21023
208208
209209   bitmap.fill(0x100, cliprect); /* is there a register controling the colour? looks odd when screen is blank */
210210   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
211   tbowl_draw_sprites(machine(), bitmap,cliprect, 0, m_spriteram);
211   tbowl_draw_sprites(bitmap,cliprect, 0, m_spriteram);
212212   m_bg2_tilemap->draw(bitmap, cliprect, 0,0);
213213   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
214214
r21022r21023
226226
227227   bitmap.fill(0x100, cliprect); /* is there a register controling the colour? looks odd when screen is blank */
228228   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
229   tbowl_draw_sprites(machine(), bitmap,cliprect, 32*8, m_spriteram);
229   tbowl_draw_sprites(bitmap,cliprect, 32*8, m_spriteram);
230230   m_bg2_tilemap->draw(bitmap, cliprect, 0,0);
231231   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
232232
trunk/src/mame/video/twincobr.c
r21022r21023
8585    Start the video hardware emulation.
8686***************************************************************************/
8787
88static void twincobr_create_tilemaps(running_machine &machine)
88void twincobr_state::twincobr_create_tilemaps()
8989{
90   twincobr_state *state = machine.driver_data<twincobr_state>();
90   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_bg_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,64);
91   m_fg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_fg_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,64);
92   m_tx_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_tx_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
9193
92   state->m_bg_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_bg_tile_info),state),TILEMAP_SCAN_ROWS,8,8,64,64);
93   state->m_fg_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_fg_tile_info),state),TILEMAP_SCAN_ROWS,8,8,64,64);
94   state->m_tx_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(twincobr_state::get_tx_tile_info),state),TILEMAP_SCAN_ROWS,8,8,64,32);
95
96   state->m_fg_tilemap->set_transparent_pen(0);
97   state->m_tx_tilemap->set_transparent_pen(0);
94   m_fg_tilemap->set_transparent_pen(0);
95   m_tx_tilemap->set_transparent_pen(0);
9896}
9997
10098VIDEO_START_MEMBER(twincobr_state,toaplan0)
r21022r21023
104102   m_bgvideoram_size = 0x2000; /* banked two times 0x1000 */
105103   m_fgvideoram_size = 0x1000;
106104
107   twincobr_create_tilemaps(machine());
105   twincobr_create_tilemaps();
108106
109107   m_txvideoram16 = auto_alloc_array_clear(machine(), UINT16, m_txvideoram_size);
110108   m_fgvideoram16 = auto_alloc_array_clear(machine(), UINT16, m_fgvideoram_size);
111109   m_bgvideoram16 = auto_alloc_array_clear(machine(), UINT16, m_bgvideoram_size);
112110
113111   m_display_on = 0;
114   twincobr_display(machine(), m_display_on);
112   twincobr_display(m_display_on);
115113
116114   state_save_register_global_pointer(machine(), m_txvideoram16, m_txvideoram_size);
117115   state_save_register_global_pointer(machine(), m_fgvideoram16, m_fgvideoram_size);
r21022r21023
137135
138136void twincobr_state::twincobr_restore_screen()
139137{
140   twincobr_display(machine(), m_display_on);
141   twincobr_flipscreen(machine(), m_flip_screen);
138   twincobr_display(m_display_on);
139   twincobr_flipscreen(m_flip_screen);
142140}
143141
144142
r21022r21023
146144    Video I/O interface
147145***************************************************************************/
148146
149void twincobr_display(running_machine &machine, int enable)
147void twincobr_state::twincobr_display(int enable)
150148{
151   twincobr_state *state = machine.driver_data<twincobr_state>();
152149
153   state->m_display_on = enable;
154   state->m_bg_tilemap->enable(enable);
155   state->m_fg_tilemap->enable(enable);
156   state->m_tx_tilemap->enable(enable);
150   m_display_on = enable;
151   m_bg_tilemap->enable(enable);
152   m_fg_tilemap->enable(enable);
153   m_tx_tilemap->enable(enable);
157154}
158155
159void twincobr_flipscreen(running_machine &machine, int flip)
156void twincobr_state::twincobr_flipscreen(int flip)
160157{
161   twincobr_state *state = machine.driver_data<twincobr_state>();
162158
163   machine.tilemap().set_flip_all((flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0));
164   state->m_flip_screen = flip;
159   machine().tilemap().set_flip_all((flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0));
160   m_flip_screen = flip;
165161   if (flip) {
166      state->m_scroll_x = 0x008;
167      state->m_scroll_y = 0x0c5;
162      m_scroll_x = 0x008;
163      m_scroll_y = 0x0c5;
168164   }
169165   else {
170      state->m_scroll_x = 0x037;
171      state->m_scroll_y = 0x01e;
166      m_scroll_x = 0x037;
167      m_scroll_y = 0x01e;
172168   }
173169}
174170
r21022r21023
352348    Ugly sprite hack for Wardner when hero is in shop
353349***************************************************************************/
354350
355static void wardner_sprite_priority_hack(running_machine &machine)
351void twincobr_state::wardner_sprite_priority_hack()
356352{
357   twincobr_state *state = machine.driver_data<twincobr_state>();
358353
359   if (state->m_fgscrollx != state->m_bgscrollx) {
360      UINT16 *buffered_spriteram16 = reinterpret_cast<UINT16 *>(state->m_spriteram8->buffer());
361      if ((state->m_fgscrollx==0x1c9) || (state->m_flip_screen && (state->m_fgscrollx==0x17a))) { /* in the shop ? */
354   if (m_fgscrollx != m_bgscrollx) {
355      UINT16 *buffered_spriteram16 = reinterpret_cast<UINT16 *>(m_spriteram8->buffer());
356      if ((m_fgscrollx==0x1c9) || (m_flip_screen && (m_fgscrollx==0x17a))) { /* in the shop ? */
362357         int wardner_hack = buffered_spriteram16[0x0b04/2];
363358      /* sprite position 0x6300 to 0x8700 -- hero on shop keeper (normal) */
364359      /* sprite position 0x3900 to 0x5e00 -- hero on shop keeper (flip) */
r21022r21023
382377
383378
384379
385static void twincobr_log_vram(running_machine &machine)
380void twincobr_state::twincobr_log_vram()
386381{
387382#ifdef MAME_DEBUG
388   twincobr_state *state = machine.driver_data<twincobr_state>();
389383
390   if ( machine.input().code_pressed(KEYCODE_M) )
384   if ( machine().input().code_pressed(KEYCODE_M) )
391385   {
392386      offs_t tile_voffs;
393387      int tcode[4];
394      while (machine.input().code_pressed(KEYCODE_M)) ;
388      while (machine().input().code_pressed(KEYCODE_M)) ;
395389      logerror("Scrolls             BG-X BG-Y  FG-X FG-Y  TX-X  TX-Y\n");
396      logerror("------>             %04x %04x  %04x %04x  %04x  %04x\n",state->m_bgscrollx,state->m_bgscrolly,state->m_fgscrollx,state->m_fgscrolly,state->m_txscrollx,state->m_txscrolly);
397      for ( tile_voffs = 0; tile_voffs < (state->m_txvideoram_size/2); tile_voffs++ )
390      logerror("------>             %04x %04x  %04x %04x  %04x  %04x\n",m_bgscrollx,m_bgscrolly,m_fgscrollx,m_fgscrolly,m_txscrollx,m_txscrolly);
391      for ( tile_voffs = 0; tile_voffs < (m_txvideoram_size/2); tile_voffs++ )
398392      {
399         tcode[1] = state->m_bgvideoram16[tile_voffs];
400         tcode[2] = state->m_fgvideoram16[tile_voffs];
401         tcode[3] = state->m_txvideoram16[tile_voffs];
393         tcode[1] = m_bgvideoram16[tile_voffs];
394         tcode[2] = m_fgvideoram16[tile_voffs];
395         tcode[3] = m_txvideoram16[tile_voffs];
402396         logerror("$(%04x)  (Col-Tile) BG1:%01x-%03x  FG1:%01x-%03x  TX1:%02x-%03x\n", tile_voffs,
403397                     tcode[1] & 0xf000 >> 12, tcode[1] & 0x0fff,
404398                     tcode[2] & 0xf000 >> 12, tcode[2] & 0x0fff,
405399                     tcode[3] & 0xf800 >> 11, tcode[3] & 0x07ff);
406400      }
407      for ( tile_voffs = (state->m_txvideoram_size/2); tile_voffs < (state->m_fgvideoram_size/2); tile_voffs++ )
401      for ( tile_voffs = (m_txvideoram_size/2); tile_voffs < (m_fgvideoram_size/2); tile_voffs++ )
408402      {
409         tcode[1] = state->m_bgvideoram16[tile_voffs];
410         tcode[2] = state->m_fgvideoram16[tile_voffs];
403         tcode[1] = m_bgvideoram16[tile_voffs];
404         tcode[2] = m_fgvideoram16[tile_voffs];
411405         logerror("$(%04x)  (Col-Tile) BG1:%01x-%03x  FG1:%01x-%03x\n", tile_voffs,
412406                     tcode[1] & 0xf000 >> 12, tcode[1] & 0x0fff,
413407                     tcode[2] & 0xf000 >> 12, tcode[2] & 0x0fff);
414408      }
415      for ( tile_voffs = (state->m_fgvideoram_size/2); tile_voffs < (state->m_bgvideoram_size/2); tile_voffs++ )
409      for ( tile_voffs = (m_fgvideoram_size/2); tile_voffs < (m_bgvideoram_size/2); tile_voffs++ )
416410      {
417         tcode[1] = state->m_bgvideoram16[tile_voffs];
411         tcode[1] = m_bgvideoram16[tile_voffs];
418412         logerror("$(%04x)  (Col-Tile) BG1:%01x-%03x\n", tile_voffs,
419413                     tcode[1] & 0xf000 >> 12, tcode[1] & 0x0fff);
420414      }
r21022r21023
427421    Sprite Handlers
428422***************************************************************************/
429423
430static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
424void twincobr_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
431425{
432   twincobr_state *state = machine.driver_data<twincobr_state>();
433426   int offs;
434427
435   if (state->m_display_on)
428   if (m_display_on)
436429   {
437430      UINT16 *buffered_spriteram16;
438431      UINT32 bytes;
439      if (state->m_spriteram16 != NULL)
432      if (m_spriteram16 != NULL)
440433      {
441         buffered_spriteram16 = state->m_spriteram16->buffer();
442         bytes = state->m_spriteram16->bytes();
434         buffered_spriteram16 = m_spriteram16->buffer();
435         bytes = m_spriteram16->bytes();
443436      }
444437      else
445438      {
446         buffered_spriteram16 = reinterpret_cast<UINT16 *>(state->m_spriteram8->buffer());
447         bytes = state->m_spriteram8->bytes();
439         buffered_spriteram16 = reinterpret_cast<UINT16 *>(m_spriteram8->buffer());
440         bytes = m_spriteram8->bytes();
448441      }
449442      for (offs = 0;offs < bytes/2;offs += 4)
450443      {
r21022r21023
461454               flipx = attribute & 0x100;
462455               if (flipx) sx -= 14;        /* should really be 15 */
463456               flipy = attribute & 0x200;
464               drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
457               drawgfx_transpen(bitmap,cliprect,machine().gfx[3],
465458                  sprite,
466459                  color,
467460                  flipx,flipy,
r21022r21023
479472
480473UINT32 twincobr_state::screen_update_toaplan0(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
481474{
482   twincobr_log_vram(machine());
475   twincobr_log_vram();
483476
484   if (m_wardner_sprite_hack) wardner_sprite_priority_hack(machine());
477   if (m_wardner_sprite_hack) wardner_sprite_priority_hack();
485478
486479   bitmap.fill(0, cliprect);
487480
488481   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
489   draw_sprites(machine(), bitmap,cliprect,0x0400);
482   draw_sprites(bitmap,cliprect,0x0400);
490483   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
491   draw_sprites(machine(), bitmap,cliprect,0x0800);
484   draw_sprites(bitmap,cliprect,0x0800);
492485   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
493   draw_sprites(machine(), bitmap,cliprect,0x0c00);
486   draw_sprites(bitmap,cliprect,0x0c00);
494487   return 0;
495488}
496489
trunk/src/mame/video/tryout.c
r21022r21023
176176   m_fg_tilemap->set_transparent_pen(0);
177177}
178178
179static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
179void tryout_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
180180{
181   tryout_state *state = machine.driver_data<tryout_state>();
182   UINT8 *spriteram = state->m_spriteram;
183   UINT8 *spriteram_2 = state->m_spriteram2;
181   UINT8 *spriteram = m_spriteram;
182   UINT8 *spriteram_2 = m_spriteram2;
184183   int offs,fx,fy,x,y,color,sprite,inc;
185184
186185   for (offs = 0;offs < 0x7f;offs += 4)
r21022r21023
196195      fy = 0;
197196      inc = 16;
198197
199      if (state->flip_screen())
198      if (flip_screen())
200199      {
201200         x = 240 - x;
202201         fx = !fx;
r21022r21023
210209      /* Double Height */
211210      if(spriteram[offs] & 0x10)
212211      {
213         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
212         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
214213            sprite,
215214            color,fx,fy,x,y + inc,0);
216215
217         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
216         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
218217            sprite+1,
219218            color,fx,fy,x,y,0);
220219      }
221220      else
222221      {
223         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
222         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
224223            sprite,
225224            color,fx,fy,x,y,0);
226225      }
r21022r21023
253252   {
254253      m_bg_tilemap->draw(bitmap, cliprect, 0,0);
255254      m_fg_tilemap->draw(bitmap, cliprect, 0,0);
256      draw_sprites(machine(), bitmap,cliprect);
255      draw_sprites(bitmap,cliprect);
257256   }
258257
259258//  popmessage("%02x %02x %02x %02x",m_gfx_control[0],m_gfx_control[1],m_gfx_control[2],scrollx);
trunk/src/mame/video/taito_o.c
r21022r21023
2525};
2626
2727
28static void parentj_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
28void taitoo_state::parentj_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
2929{
3030   /* Y chain size is 16/32?/64/64? pixels. X chain size
3131      is always 64 pixels. */
3232
33   taitoo_state *state = machine.driver_data<taitoo_state>();
34   address_space &space = machine.driver_data()->generic_space();
33   address_space &space = machine().driver_data()->generic_space();
3534   static const int size[] = { 1, 2, 4, 4 };
3635   int x0, y0, x, y, dx, dy, ex, ey, zx, zy;
3736   int ysize;
r21022r21023
4544      if (offs <  0x01b0 && priority == 0)    continue;
4645      if (offs >= 0x01b0 && priority == 1)    continue;
4746
48      x0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
49      y0        =  tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
50      zoomx     = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
51      zoomy     = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 2, 0xffff) & 0x007f);
52      tile_offs = (tc0080vco_sprram_r(state->m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
53      ysize     = size[(tc0080vco_sprram_r(state->m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
47      x0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 1, 0xffff) & 0x3ff;
48      y0        =  tc0080vco_sprram_r(m_tc0080vco, space, offs + 0, 0xffff) & 0x3ff;
49      zoomx     = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 2, 0xffff) & 0x7f00) >> 8;
50      zoomy     = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 2, 0xffff) & 0x007f);
51      tile_offs = (tc0080vco_sprram_r(m_tc0080vco, space, offs + 3, 0xffff) & 0x1fff) << 2;
52      ysize     = size[(tc0080vco_sprram_r(m_tc0080vco, space, offs, 0xffff) & 0x0c00) >> 10];
5453
5554      if (tile_offs)
5655      {
r21022r21023
8685         if (x0 >= 0x200) x0 -= 0x400;
8786         if (y0 >= 0x200) y0 -= 0x400;
8887
89         if (tc0080vco_flipscreen_r(state->m_tc0080vco))
88         if (tc0080vco_flipscreen_r(m_tc0080vco))
9089         {
9190            x0 = 497 - x0;
9291            y0 = 498 - y0;
r21022r21023
109108               {
110109                  int tile, color, flipx, flipy;
111110
112                  tile  = tc0080vco_cram_0_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
113                  color = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
114                  flipx = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
115                  flipy = tc0080vco_cram_1_r(state->m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
111                  tile  = tc0080vco_cram_0_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x7fff;
112                  color = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x001f;
113                  flipx = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0040;
114                  flipy = tc0080vco_cram_1_r(m_tc0080vco, space, tile_offs, 0xffff) & 0x0080;
116115
117                  if (tc0080vco_flipscreen_r(state->m_tc0080vco))
116                  if (tc0080vco_flipscreen_r(m_tc0080vco))
118117                  {
119118                     flipx ^= 0x0040;
120119                     flipy ^= 0x0080;
121120                  }
122121
123122                  drawgfxzoom_transpen( bitmap, cliprect,
124                           machine.gfx[0],
123                           machine().gfx[0],
125124                           tile,
126125                           color,
127126                           flipx, flipy,
r21022r21023
147146
148147   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
149148
150   parentj_draw_sprites(machine(), bitmap, cliprect, 0);
151   parentj_draw_sprites(machine(), bitmap, cliprect, 1);
149   parentj_draw_sprites(bitmap, cliprect, 0);
150   parentj_draw_sprites(bitmap, cliprect, 1);
152151
153152   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 1, 0, 0);
154153   tc0080vco_tilemap_draw(m_tc0080vco, bitmap, cliprect, 2, 0, 0);
trunk/src/mame/video/terracre.c
r21022r21023
2727   SET_TILE_INFO_MEMBER( 0,data&0xff,0,0 );
2828}
2929
30static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
30void terracre_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
3131{
32   terracre_state *state = machine.driver_data<terracre_state>();
33   const UINT8 *spritepalettebank = state->memregion("user1")->base();
34   gfx_element *pGfx = machine.gfx[2];
35   const UINT16 *pSource = state->m_spriteram;
32   const UINT8 *spritepalettebank = memregion("user1")->base();
33   gfx_element *pGfx = machine().gfx[2];
34   const UINT16 *pSource = m_spriteram;
3635   int i;
3736   int transparent_pen;
3837
r21022r21023
7473         color += 16 * (spritepalettebank[(tile>>1)&0xff] & 0x0f);
7574      }
7675
77      if (state->flip_screen())
76      if (flip_screen())
7877      {
7978            sx=240-sx;
8079            sy=240-sy;
r21022r21023
201200   else
202201      m_background->draw(bitmap, cliprect, 0, 0 );
203202
204   draw_sprites(machine(), bitmap,cliprect );
203   draw_sprites(bitmap,cliprect );
205204   m_foreground->draw(bitmap, cliprect, 0, 0 );
206205   return 0;
207206}
trunk/src/mame/video/trackfld.c
r21022r21023
187187
188188
189189
190static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
190void trackfld_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
191191{
192   trackfld_state *state = machine.driver_data<trackfld_state>();
193   UINT8 *spriteram = state->m_spriteram;
194   UINT8 *spriteram_2 = state->m_spriteram2;
192   UINT8 *spriteram = m_spriteram;
193   UINT8 *spriteram_2 = m_spriteram2;
195194   int offs;
196195
197   for (offs = state->m_spriteram.bytes() - 2; offs >= 0; offs -= 2)
196   for (offs = m_spriteram.bytes() - 2; offs >= 0; offs -= 2)
198197   {
199198      int attr = spriteram_2[offs];
200199      int code = spriteram[offs + 1];
201200      int color = attr & 0x0f;
202      if (!state->m_sprites_gfx_banked)
201      if (!m_sprites_gfx_banked)
203202         if (attr&1) code|=0x100; // extra tile# bit for the yiear conversion, trackfld doesn't have this many sprites so it will just get masked
204203      int flipx = ~attr & 0x40;
205204      int flipy = attr & 0x80;
206205      int sx = spriteram[offs] - 1;
207206      int sy = 240 - spriteram_2[offs + 1];
208207
209      if (state->flip_screen())
208      if (flip_screen())
210209      {
211210         sy = 240 - sy;
212211         flipy = !flipy;
r21022r21023
225224
226225
227226      drawgfx_transmask(bitmap, cliprect,
228         machine.gfx[0],
229         code + state->m_sprite_bank1 + state->m_sprite_bank2, color,
227         machine().gfx[0],
228         code + m_sprite_bank1 + m_sprite_bank2, color,
230229         flipx, flipy,
231230         sx, sy,
232         colortable_get_transpen_mask(machine.colortable, machine.gfx[0], color, 0));
231         colortable_get_transpen_mask(machine().colortable, machine().gfx[0], color, 0));
233232
234233      /* redraw with wraparound */
235234      drawgfx_transmask(bitmap,cliprect,
236         machine.gfx[0],
237         code + state->m_sprite_bank1 + state->m_sprite_bank2, color,
235         machine().gfx[0],
236         code + m_sprite_bank1 + m_sprite_bank2, color,
238237         flipx, flipy,
239238         sx - 256, sy,
240         colortable_get_transpen_mask(machine.colortable, machine.gfx[0], color, 0));
239         colortable_get_transpen_mask(machine().colortable, machine().gfx[0], color, 0));
241240   }
242241}
243242
r21022r21023
255254   }
256255
257256   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
258   draw_sprites(machine(), bitmap, cliprect);
257   draw_sprites(bitmap, cliprect);
259258   return 0;
260259}
trunk/src/mame/video/thief.c
r21022r21023
146146
147147/***************************************************************************/
148148
149static UINT16 fetch_image_addr( coprocessor_t &thief_coprocessor ){
149UINT16 thief_state::fetch_image_addr( coprocessor_t &thief_coprocessor )
150{
150151   int addr = thief_coprocessor.param[IMAGE_ADDR_LO]+256*thief_coprocessor.param[IMAGE_ADDR_HI];
151152   /* auto-increment */
152153   thief_coprocessor.param[IMAGE_ADDR_LO]++;
trunk/src/mame/video/travrusa.c
r21022r21023
246246}
247247
248248
249static void set_scroll( running_machine &machine )
249void travrusa_state::set_scroll(  )
250250{
251   travrusa_state *state = machine.driver_data<travrusa_state>();
252251   int i;
253252
254253   for (i = 0; i <= 2; i++)
255      state->m_bg_tilemap->set_scrollx(i, state->m_scrollx[0] + 256 * state->m_scrollx[1]);
254      m_bg_tilemap->set_scrollx(i, m_scrollx[0] + 256 * m_scrollx[1]);
256255
257   state->m_bg_tilemap->set_scrollx(3, 0);
256   m_bg_tilemap->set_scrollx(3, 0);
258257}
259258
260259WRITE8_MEMBER(travrusa_state::travrusa_scroll_x_low_w)
261260{
262261   m_scrollx[0] = data;
263   set_scroll(machine());
262   set_scroll();
264263}
265264
266265WRITE8_MEMBER(travrusa_state::travrusa_scroll_x_high_w)
267266{
268267   m_scrollx[1] = data;
269   set_scroll(machine());
268   set_scroll();
270269}
271270
272271
r21022r21023
289288
290289***************************************************************************/
291290
292static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
291void travrusa_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
293292{
294   travrusa_state *state = machine.driver_data<travrusa_state>();
295293   int offs;
296294   const rectangle spritevisiblearea(1*8, 31*8-1, 0*8, 24*8-1);
297295   const rectangle spritevisibleareaflip(1*8, 31*8-1, 8*8, 32*8-1);
298296   rectangle clip = cliprect;
299   if (state->flip_screen())
297   if (flip_screen())
300298      clip &= spritevisibleareaflip;
301299   else
302300      clip &= spritevisiblearea;
303301
304302
305   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
303   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
306304   {
307      int sx = ((state->m_spriteram[offs + 3] + 8) & 0xff) - 8;
308      int sy = 240 - state->m_spriteram[offs];
309      int code = state->m_spriteram[offs + 2];
310      int attr = state->m_spriteram[offs + 1];
305      int sx = ((m_spriteram[offs + 3] + 8) & 0xff) - 8;
306      int sy = 240 - m_spriteram[offs];
307      int code = m_spriteram[offs + 2];
308      int attr = m_spriteram[offs + 1];
311309      int flipx = attr & 0x40;
312310      int flipy = attr & 0x80;
313311
314      if (state->flip_screen())
312      if (flip_screen())
315313      {
316314         sx = 240 - sx;
317315         sy = 240 - sy;
r21022r21023
319317         flipy = !flipy;
320318      }
321319
322      drawgfx_transpen(bitmap, clip, machine.gfx[1],
320      drawgfx_transpen(bitmap, clip, machine().gfx[1],
323321            code,
324322            attr & 0x0f,
325323            flipx, flipy,
r21022r21023
331329UINT32 travrusa_state::screen_update_travrusa(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
332330{
333331   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
334   draw_sprites(machine(), bitmap,cliprect);
332   draw_sprites(bitmap,cliprect);
335333   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
336334   return 0;
337335}
trunk/src/mame/video/tecmo.c
r21022r21023
156156
157157***************************************************************************/
158158
159static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
159void tecmo_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
160160{
161   tecmo_state *state = machine.driver_data<tecmo_state>();
162   UINT8 *spriteram = state->m_spriteram;
161   UINT8 *spriteram = m_spriteram;
163162   int offs;
164163   static const UINT8 layout[8][8] =
165164   {
r21022r21023
173172      {42,43,46,47,58,59,62,63}
174173   };
175174
176   for (offs = state->m_spriteram.bytes()-8;offs >= 0;offs -= 8)
175   for (offs = m_spriteram.bytes()-8;offs >= 0;offs -= 8)
177176   {
178177      int flags = spriteram[offs+3];
179178      int priority = flags>>6;
r21022r21023
184183         int code,xpos,ypos,flipx,flipy,priority_mask,x,y;
185184         int size = spriteram[offs + 2] & 3;
186185
187         if (state->m_video_type != 0)   /* gemini, silkworm */
186         if (m_video_type != 0)   /* gemini, silkworm */
188187            code = which + ((bank & 0xf8) << 5);
189188         else                        /* rygar */
190189            code = which + ((bank & 0xf0) << 4);
r21022r21023
197196         flipx = bank & 1;
198197         flipy = bank & 2;
199198
200         if (state->flip_screen())
199         if (flip_screen())
201200         {
202201            xpos = 256 - (8 * size) - xpos;
203202            ypos = 256 - (8 * size) - ypos;
r21022r21023
221220            {
222221               int sx = xpos + 8*(flipx?(size-1-x):x);
223222               int sy = ypos + 8*(flipy?(size-1-y):y);
224               pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
223               pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
225224                     code + layout[y][x],
226225                     flags & 0xf,
227226                     flipx,flipy,
228227                     sx,sy,
229                     machine.priority_bitmap,
228                     machine().priority_bitmap,
230229                     priority_mask,0);
231230            }
232231         }
r21022r21023
243242   m_fg_tilemap->draw(bitmap, cliprect, 0,2);
244243   m_tx_tilemap->draw(bitmap, cliprect, 0,4);
245244
246   draw_sprites(machine(), bitmap,cliprect);
245   draw_sprites(bitmap,cliprect);
247246   return 0;
248247}
trunk/src/mame/video/taito_b.c
r21022r21023
2323   COMBINE_DATA(&m_pixel_scroll[offset]);
2424}
2525
26static void hitice_clear_pixel_bitmap( running_machine &machine )
26void taitob_state::hitice_clear_pixel_bitmap(  )
2727{
2828   int i;
29   taitob_state *state = machine.driver_data<taitob_state>();
30   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
29   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
3130
3231   for (i = 0; i < 0x40000; i++)
33      state->hitice_pixelram_w(space, i, 0, 0xffff);
32      hitice_pixelram_w(space, i, 0, 0xffff);
3433}
3534
3635WRITE16_MEMBER(taitob_state::realpunc_video_ctrl_w)
r21022r21023
9594VIDEO_RESET_MEMBER(taitob_state,hitice)
9695{
9796   /* kludge: clear the bitmap on startup */
98   hitice_clear_pixel_bitmap(machine());
97   hitice_clear_pixel_bitmap();
9998}
10099
101100
r21022r21023
127126}
128127
129128
130static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
129void taitob_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
131130{
132131/*  Sprite format: (16 bytes per sprite)
133132  offs:             bits:
r21022r21023
158157  000c - 000f: unused
159158*/
160159
161   taitob_state *state = machine.driver_data<taitob_state>();
162160   int x, y, xlatch = 0, ylatch = 0, x_no = 0, y_no = 0, x_num = 0, y_num = 0, big_sprite = 0;
163161   int offs, code, color, flipx, flipy;
164162   UINT32 data, zoomx, zoomy, zx, zy, zoomxlatch = 0, zoomylatch = 0;
165163
166164   for (offs = (0x1980 - 16) / 2; offs >=0; offs -= 8)
167165   {
168      code = state->m_spriteram[offs];
166      code = m_spriteram[offs];
169167
170      color = state->m_spriteram[offs + 1];
168      color = m_spriteram[offs + 1];
171169      flipx = color & 0x4000;
172170      flipy = color & 0x8000;
173171#if 0
r21022r21023
180178#endif
181179      color = (color & 0x3f) * 16;
182180
183      x = state->m_spriteram[offs + 2] & 0x3ff;
184      y = state->m_spriteram[offs + 3] & 0x3ff;
181      x = m_spriteram[offs + 2] & 0x3ff;
182      y = m_spriteram[offs + 3] & 0x3ff;
185183      if (x >= 0x200)  x -= 0x400;
186184      if (y >= 0x200)  y -= 0x400;
187185
188      data = state->m_spriteram[offs + 5];
186      data = m_spriteram[offs + 5];
189187      if (data)
190188      {
191189         if (!big_sprite)
r21022r21023
196194            y_no  = 0;
197195            xlatch = x;
198196            ylatch = y;
199            data = state->m_spriteram[offs + 4];
197            data = m_spriteram[offs + 4];
200198            zoomxlatch = (data >> 8) & 0xff;
201199            zoomylatch = (data >> 0) & 0xff;
202200            big_sprite = 1;
203201         }
204202      }
205203
206      data = state->m_spriteram[offs + 4];
204      data = m_spriteram[offs + 4];
207205      zoomx = (data >> 8) & 0xff;
208206      zoomy = (data >> 0) & 0xff;
209207      zx = (0x100 - zoomx) / 16;
r21022r21023
236234
237235      if ( zoomx || zoomy )
238236      {
239         drawgfxzoom_transpen_raw(bitmap, cliprect, machine.gfx[1],
237         drawgfxzoom_transpen_raw(bitmap, cliprect, machine().gfx[1],
240238            code,
241239            color,
242240            flipx,flipy,
r21022r21023
245243      }
246244      else
247245      {
248         drawgfx_transpen_raw (bitmap,cliprect,machine.gfx[1],
246         drawgfx_transpen_raw (bitmap,cliprect,machine().gfx[1],
249247            code,
250248            color,
251249            flipx,flipy,
r21022r21023
256254}
257255
258256
259static void draw_framebuffer( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
257void taitob_state::draw_framebuffer( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
260258{
261   taitob_state *state = machine.driver_data<taitob_state>();
262259   rectangle myclip = cliprect;
263260   int x, y;
264   address_space &space = machine.driver_data()->generic_space();
265   UINT8 video_control = tc0180vcu_get_videoctrl(state->m_tc0180vcu, space, 0);
266   UINT8 framebuffer_page = tc0180vcu_get_fb_page(state->m_tc0180vcu, space, 0);
261   address_space &space = machine().driver_data()->generic_space();
262   UINT8 video_control = tc0180vcu_get_videoctrl(m_tc0180vcu, space, 0);
263   UINT8 framebuffer_page = tc0180vcu_get_fb_page(m_tc0180vcu, space, 0);
267264
268265g_profiler.start(PROFILER_USER1);
269266
r21022r21023
282279         /*popmessage("1. X[%3i;%3i] Y[%3i;%3i]", myclip.min_x, myclip.max_x, myclip.min_y, myclip.max_y);*/
283280         for (y = myclip.min_y; y <= myclip.max_y; y++)
284281         {
285            UINT16 *src = &state->m_framebuffer[framebuffer_page]->pix16(y, myclip.min_x);
282            UINT16 *src = &m_framebuffer[framebuffer_page]->pix16(y, myclip.min_x);
286283            UINT16 *dst;
287284
288285            dst = &bitmap.pix16(bitmap.height()-1-y, myclip.max_x);
r21022r21023
292289               UINT16 c = *src++;
293290
294291               if (c != 0)
295                  *dst = state->m_b_sp_color_base + c;
292                  *dst = m_b_sp_color_base + c;
296293
297294               dst--;
298295            }
r21022r21023
302299      {
303300         for (y = myclip.min_y; y <= myclip.max_y; y++)
304301         {
305            UINT16 *src = &state->m_framebuffer[framebuffer_page]->pix16(y, myclip.min_x);
302            UINT16 *src = &m_framebuffer[framebuffer_page]->pix16(y, myclip.min_x);
306303            UINT16 *dst = &bitmap.pix16(y, myclip.min_x);
307304
308305            for (x = myclip.min_x; x <= myclip.max_x; x++)
r21022r21023
310307               UINT16 c = *src++;
311308
312309               if (c != 0)
313                  *dst = state->m_b_sp_color_base + c;
310                  *dst = m_b_sp_color_base + c;
314311
315312               dst++;
316313            }
r21022r21023
324321         /*popmessage("3. X[%3i;%3i] Y[%3i;%3i]", myclip.min_x, myclip.max_x, myclip.min_y, myclip.max_y);*/
325322         for (y = myclip.min_y ;y <= myclip.max_y; y++)
326323         {
327            UINT16 *src = &state->m_framebuffer[framebuffer_page]->pix16(y, myclip.min_x);
324            UINT16 *src = &m_framebuffer[framebuffer_page]->pix16(y, myclip.min_x);
328325            UINT16 *dst;
329326
330327            dst = &bitmap.pix16(bitmap.height()-1-y, myclip.max_x);
r21022r21023
334331               UINT16 c = *src++;
335332
336333               if (c != 0 && (c & 0x10) == priority)
337                  *dst = state->m_b_sp_color_base + c;
334                  *dst = m_b_sp_color_base + c;
338335
339336               dst--;
340337            }
r21022r21023
344341      {
345342         for (y = myclip.min_y; y <= myclip.max_y; y++)
346343         {
347            UINT16 *src = &state->m_framebuffer[framebuffer_page]->pix16(y, myclip.min_x);
344            UINT16 *src = &m_framebuffer[framebuffer_page]->pix16(y, myclip.min_x);
348345            UINT16 *dst = &bitmap.pix16(y, myclip.min_x);
349346
350347            for (x = myclip.min_x; x <= myclip.max_x; x++)
r21022r21023
352349               UINT16 c = *src++;
353350
354351               if (c != 0 && (c & 0x10) == priority)
355                  *dst = state->m_b_sp_color_base + c;
352                  *dst = m_b_sp_color_base + c;
356353
357354               dst++;
358355            }
r21022r21023
376373   /* Draw playfields */
377374   tc0180vcu_tilemap_draw(m_tc0180vcu, bitmap, cliprect, 0, 1);
378375
379   draw_framebuffer(machine(), bitmap, cliprect, 1);
376   draw_framebuffer(bitmap, cliprect, 1);
380377
381378   tc0180vcu_tilemap_draw(m_tc0180vcu, bitmap, cliprect, 1, 0);
382379
r21022r21023
389386      copyscrollbitmap_trans(bitmap, *m_pixel_bitmap, 1, &scrollx, 1, &scrolly, cliprect, m_b_fg_color_base * 16);
390387   }
391388
392   draw_framebuffer(machine(), bitmap, cliprect, 0);
389   draw_framebuffer(bitmap, cliprect, 0);
393390
394391   tc0180vcu_tilemap_draw(m_tc0180vcu, bitmap, cliprect, 2, 0);
395392
r21022r21023
415412   /* Draw the palettized playfields to an indexed bitmap */
416413   tc0180vcu_tilemap_draw(m_tc0180vcu, *m_realpunc_bitmap, cliprect, 0, 1);
417414
418   draw_framebuffer(machine(), *m_realpunc_bitmap, cliprect, 1);
415   draw_framebuffer(*m_realpunc_bitmap, cliprect, 1);
419416
420417   tc0180vcu_tilemap_draw(m_tc0180vcu, *m_realpunc_bitmap, cliprect, 1, 0);
421418
422419   if (m_realpunc_video_ctrl & 0x0001)
423      draw_framebuffer(machine(), *m_realpunc_bitmap, cliprect, 0);
420      draw_framebuffer(*m_realpunc_bitmap, cliprect, 0);
424421
425422   /* Copy the intermediate bitmap to the output bitmap, applying the palette */
426423   for (y = 0; y <= cliprect.max_y; y++)
r21022r21023
471468   m_realpunc_bitmap->fill(0, cliprect);
472469
473470   if (!(m_realpunc_video_ctrl & 0x0001))
474      draw_framebuffer(machine(), *m_realpunc_bitmap, cliprect, 0);
471      draw_framebuffer(*m_realpunc_bitmap, cliprect, 0);
475472
476473   tc0180vcu_tilemap_draw(m_tc0180vcu, *m_realpunc_bitmap, cliprect, 2, 0);
477474
r21022r21023
508505         tc0180vcu_set_fb_page(m_tc0180vcu, space, 0, framebuffer_page);
509506      }
510507
511      draw_sprites(machine(), *m_framebuffer[framebuffer_page], machine().primary_screen->visible_area());
508      draw_sprites(*m_framebuffer[framebuffer_page], machine().primary_screen->visible_area());
512509   }
513510}
trunk/src/mame/video/toaplan1.c
r21022r21023
206206
207207***************************************************************************/
208208
209static void toaplan1_create_tilemaps(running_machine &machine)
209void toaplan1_state::toaplan1_create_tilemaps()
210210{
211   toaplan1_state *state = machine.driver_data<toaplan1_state>();
212211
213   state->m_pf1_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(toaplan1_state::get_pf1_tile_info),state), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
214   state->m_pf2_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(toaplan1_state::get_pf2_tile_info),state), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
215   state->m_pf3_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(toaplan1_state::get_pf3_tile_info),state), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
216   state->m_pf4_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(toaplan1_state::get_pf4_tile_info),state), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
212   m_pf1_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(toaplan1_state::get_pf1_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
213   m_pf2_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(toaplan1_state::get_pf2_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
214   m_pf3_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(toaplan1_state::get_pf3_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
215   m_pf4_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(toaplan1_state::get_pf4_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
217216
218   state->m_pf1_tilemap->set_transparent_pen(0);
219   state->m_pf2_tilemap->set_transparent_pen(0);
220   state->m_pf3_tilemap->set_transparent_pen(0);
221   state->m_pf4_tilemap->set_transparent_pen(0);
217   m_pf1_tilemap->set_transparent_pen(0);
218   m_pf2_tilemap->set_transparent_pen(0);
219   m_pf3_tilemap->set_transparent_pen(0);
220   m_pf4_tilemap->set_transparent_pen(0);
222221
223   memset(state->m_empty_tile, 0x00, sizeof(state->m_empty_tile));
222   memset(m_empty_tile, 0x00, sizeof(m_empty_tile));
224223}
225224
226225
227static void toaplan1_paletteram_alloc(running_machine &machine)
226void toaplan1_state::toaplan1_paletteram_alloc()
228227{
229   toaplan1_state *state = machine.driver_data<toaplan1_state>();
230228
231   UINT32 bytes = (state->m_colorram1.bytes() + state->m_colorram2.bytes())/2;
232   state->m_generic_paletteram_16.allocate(bytes);
229   UINT32 bytes = (m_colorram1.bytes() + m_colorram2.bytes())/2;
230   m_generic_paletteram_16.allocate(bytes);
233231}
234232
235static void toaplan1_vram_alloc(running_machine &machine)
233void toaplan1_state::toaplan1_vram_alloc()
236234{
237   toaplan1_state *state = machine.driver_data<toaplan1_state>();
238235
239   state->m_pf1_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
240   state->m_pf2_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
241   state->m_pf3_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
242   state->m_pf4_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
236   m_pf1_tilevram16 = auto_alloc_array_clear(machine(), UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
237   m_pf2_tilevram16 = auto_alloc_array_clear(machine(), UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
238   m_pf3_tilevram16 = auto_alloc_array_clear(machine(), UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
239   m_pf4_tilevram16 = auto_alloc_array_clear(machine(), UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
243240
244   state->save_pointer(NAME(state->m_pf1_tilevram16), TOAPLAN1_TILEVRAM_SIZE/2);
245   state->save_pointer(NAME(state->m_pf2_tilevram16), TOAPLAN1_TILEVRAM_SIZE/2);
246   state->save_pointer(NAME(state->m_pf3_tilevram16), TOAPLAN1_TILEVRAM_SIZE/2);
247   state->save_pointer(NAME(state->m_pf4_tilevram16), TOAPLAN1_TILEVRAM_SIZE/2);
241   save_pointer(NAME(m_pf1_tilevram16), TOAPLAN1_TILEVRAM_SIZE/2);
242   save_pointer(NAME(m_pf2_tilevram16), TOAPLAN1_TILEVRAM_SIZE/2);
243   save_pointer(NAME(m_pf3_tilevram16), TOAPLAN1_TILEVRAM_SIZE/2);
244   save_pointer(NAME(m_pf4_tilevram16), TOAPLAN1_TILEVRAM_SIZE/2);
248245
249246#ifdef MAME_DEBUG
250   state->m_display_pf1 = 1;
251   state->m_display_pf2 = 1;
252   state->m_display_pf3 = 1;
253   state->m_display_pf4 = 1;
254   state->m_displog = 0;
247   m_display_pf1 = 1;
248   m_display_pf2 = 1;
249   m_display_pf3 = 1;
250   m_display_pf4 = 1;
251   m_displog = 0;
255252#endif
256253}
257254
258static void toaplan1_spritevram_alloc(running_machine &machine)
255void toaplan1_state::toaplan1_spritevram_alloc()
259256{
260   toaplan1_state *state = machine.driver_data<toaplan1_state>();
261257
262   state->m_spriteram.allocate(TOAPLAN1_SPRITERAM_SIZE/2);
263   state->m_buffered_spriteram = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITERAM_SIZE/2);
264   state->m_spritesizeram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITESIZERAM_SIZE/2);
265   state->m_buffered_spritesizeram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITESIZERAM_SIZE/2);
258   m_spriteram.allocate(TOAPLAN1_SPRITERAM_SIZE/2);
259   m_buffered_spriteram = auto_alloc_array_clear(machine(), UINT16, TOAPLAN1_SPRITERAM_SIZE/2);
260   m_spritesizeram16 = auto_alloc_array_clear(machine(), UINT16, TOAPLAN1_SPRITESIZERAM_SIZE/2);
261   m_buffered_spritesizeram16 = auto_alloc_array_clear(machine(), UINT16, TOAPLAN1_SPRITESIZERAM_SIZE/2);
266262
267   state->save_pointer(NAME(state->m_buffered_spriteram), TOAPLAN1_SPRITERAM_SIZE/2);
268   state->save_pointer(NAME(state->m_spritesizeram16), TOAPLAN1_SPRITESIZERAM_SIZE/2);
269   state->save_pointer(NAME(state->m_buffered_spritesizeram16), TOAPLAN1_SPRITESIZERAM_SIZE/2);
263   save_pointer(NAME(m_buffered_spriteram), TOAPLAN1_SPRITERAM_SIZE/2);
264   save_pointer(NAME(m_spritesizeram16), TOAPLAN1_SPRITESIZERAM_SIZE/2);
265   save_pointer(NAME(m_buffered_spritesizeram16), TOAPLAN1_SPRITESIZERAM_SIZE/2);
270266}
271267
272static void toaplan1_set_scrolls(running_machine &machine)
268void toaplan1_state::toaplan1_set_scrolls()
273269{
274   toaplan1_state *state = machine.driver_data<toaplan1_state>();
275270
276   state->m_pf1_tilemap->set_scrollx(0, (state->m_pf1_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs1));
277   state->m_pf2_tilemap->set_scrollx(0, (state->m_pf2_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs2));
278   state->m_pf3_tilemap->set_scrollx(0, (state->m_pf3_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs3));
279   state->m_pf4_tilemap->set_scrollx(0, (state->m_pf4_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs4));
280   state->m_pf1_tilemap->set_scrolly(0, (state->m_pf1_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
281   state->m_pf2_tilemap->set_scrolly(0, (state->m_pf2_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
282   state->m_pf3_tilemap->set_scrolly(0, (state->m_pf3_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
283   state->m_pf4_tilemap->set_scrolly(0, (state->m_pf4_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
271   m_pf1_tilemap->set_scrollx(0, (m_pf1_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs1));
272   m_pf2_tilemap->set_scrollx(0, (m_pf2_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs2));
273   m_pf3_tilemap->set_scrollx(0, (m_pf3_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs3));
274   m_pf4_tilemap->set_scrollx(0, (m_pf4_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs4));
275   m_pf1_tilemap->set_scrolly(0, (m_pf1_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
276   m_pf2_tilemap->set_scrolly(0, (m_pf2_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
277   m_pf3_tilemap->set_scrolly(0, (m_pf3_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
278   m_pf4_tilemap->set_scrolly(0, (m_pf4_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
284279}
285280
286281void toaplan1_state::rallybik_flipscreen()
r21022r21023
297292   toaplan1_bcu_flipscreen_w(space, 0, m_bcu_flipscreen, 0xffff);
298293}
299294
300static void register_common(running_machine &machine)
295void toaplan1_state::register_common()
301296{
302   toaplan1_state *state = machine.driver_data<toaplan1_state>();
303297
304   state->save_item(NAME(state->m_scrollx_offs1));
305   state->save_item(NAME(state->m_scrollx_offs2));
306   state->save_item(NAME(state->m_scrollx_offs3));
307   state->save_item(NAME(state->m_scrollx_offs4));
308   state->save_item(NAME(state->m_scrolly_offs));
298   save_item(NAME(m_scrollx_offs1));
299   save_item(NAME(m_scrollx_offs2));
300   save_item(NAME(m_scrollx_offs3));
301   save_item(NAME(m_scrollx_offs4));
302   save_item(NAME(m_scrolly_offs));
309303
310   state->save_item(NAME(state->m_bcu_flipscreen));
311   state->save_item(NAME(state->m_fcu_flipscreen));
312   state->save_item(NAME(state->m_reset));
304   save_item(NAME(m_bcu_flipscreen));
305   save_item(NAME(m_fcu_flipscreen));
306   save_item(NAME(m_reset));
313307
314   state->save_item(NAME(state->m_pf1_scrollx));
315   state->save_item(NAME(state->m_pf1_scrolly));
316   state->save_item(NAME(state->m_pf2_scrollx));
317   state->save_item(NAME(state->m_pf2_scrolly));
318   state->save_item(NAME(state->m_pf3_scrollx));
319   state->save_item(NAME(state->m_pf3_scrolly));
320   state->save_item(NAME(state->m_pf4_scrollx));
321   state->save_item(NAME(state->m_pf4_scrolly));
308   save_item(NAME(m_pf1_scrollx));
309   save_item(NAME(m_pf1_scrolly));
310   save_item(NAME(m_pf2_scrollx));
311   save_item(NAME(m_pf2_scrolly));
312   save_item(NAME(m_pf3_scrollx));
313   save_item(NAME(m_pf3_scrolly));
314   save_item(NAME(m_pf4_scrollx));
315   save_item(NAME(m_pf4_scrolly));
322316
323   state->save_item(NAME(state->m_tiles_offsetx));
324   state->save_item(NAME(state->m_tiles_offsety));
325   state->save_item(NAME(state->m_pf_voffs));
326   state->save_item(NAME(state->m_spriteram_offs));
317   save_item(NAME(m_tiles_offsetx));
318   save_item(NAME(m_tiles_offsety));
319   save_item(NAME(m_pf_voffs));
320   save_item(NAME(m_spriteram_offs));
327321}
328322
329323
330324VIDEO_START_MEMBER(toaplan1_state,rallybik)
331325{
332   toaplan1_create_tilemaps(machine());
333   toaplan1_paletteram_alloc(machine());
334   toaplan1_vram_alloc(machine());
326   toaplan1_create_tilemaps();
327   toaplan1_paletteram_alloc();
328   toaplan1_vram_alloc();
335329
336330   m_buffered_spriteram = auto_alloc_array_clear(machine(), UINT16, m_spriteram.bytes()/2);
337331   save_pointer(NAME(m_buffered_spriteram), m_spriteram.bytes()/2);
r21022r21023
346340   m_fcu_flipscreen = 0;
347341   m_reset = 0;
348342
349   register_common(machine());
343   register_common();
350344
351345   machine().save().register_postload(save_prepost_delegate(FUNC(toaplan1_state::rallybik_flipscreen), this));
352346}
353347
354348VIDEO_START_MEMBER(toaplan1_state,toaplan1)
355349{
356   toaplan1_create_tilemaps(machine());
357   toaplan1_paletteram_alloc(machine());
358   toaplan1_vram_alloc(machine());
359   toaplan1_spritevram_alloc(machine());
350   toaplan1_create_tilemaps();
351   toaplan1_paletteram_alloc();
352   toaplan1_vram_alloc();
353   toaplan1_spritevram_alloc();
360354
361355   m_scrollx_offs1 = 0x1ef + 6;
362356   m_scrollx_offs2 = 0x1ef + 4;
r21022r21023
368362   m_fcu_flipscreen = 0;
369363   m_reset = 1;
370364
371   register_common(machine());
365   register_common();
372366
373367   machine().save().register_postload(save_prepost_delegate(FUNC(toaplan1_state::toaplan1_flipscreen), this));
374368}
r21022r21023
398392      logerror("Tiles_offsety now = %08x\n", m_tiles_offsety);
399393   }
400394   m_reset = 1;
401   toaplan1_set_scrolls(machine());
395   toaplan1_set_scrolls();
402396}
403397
404398WRITE16_MEMBER(toaplan1_state::rallybik_bcu_flipscreen_w)
r21022r21023
424418         m_scrollx_offs4 = 0x00d + 0;
425419         m_scrolly_offs  = 0x111;
426420      }
427      toaplan1_set_scrolls(machine());
421      toaplan1_set_scrolls();
428422   }
429423}
430424
r21022r21023
454448         m_scrollx_offs4 = 0x1ef + 0;
455449         m_scrolly_offs  = 0x101;
456450      }
457      toaplan1_set_scrolls(machine());
451      toaplan1_set_scrolls();
458452   }
459453}
460454
r21022r21023
706700
707701
708702
709static void toaplan1_log_vram(running_machine &machine)
703void toaplan1_state::toaplan1_log_vram()
710704{
711705#ifdef MAME_DEBUG
712   toaplan1_state *state = machine.driver_data<toaplan1_state>();
713706
714   if ( machine.input().code_pressed(KEYCODE_M) )
707   if ( machine().input().code_pressed(KEYCODE_M) )
715708   {
716      UINT16 *spriteram16 = state->m_spriteram;
717      UINT16 *buffered_spriteram16 = state->m_buffered_spriteram;
709      UINT16 *spriteram16 = m_spriteram;
710      UINT16 *buffered_spriteram16 = m_buffered_spriteram;
718711      offs_t sprite_voffs;
719      while (machine.input().code_pressed(KEYCODE_M)) ;
720      if (state->m_spritesizeram16)           /* FCU controller */
712      while (machine().input().code_pressed(KEYCODE_M)) ;
713      if (m_spritesizeram16)           /* FCU controller */
721714      {
722715         int schar,sattr,sxpos,sypos,bschar,bsattr,bsxpos,bsypos;
723         UINT16 *size  = (UINT16 *)(state->m_spritesizeram16);
724         UINT16 *bsize = (UINT16 *)(state->m_buffered_spritesizeram16);
716         UINT16 *size  = (UINT16 *)(m_spritesizeram16);
717         UINT16 *bsize = (UINT16 *)(m_buffered_spritesizeram16);
725718         logerror("Scrolls    PF1-X  PF1-Y     PF2-X  PF2-Y     PF3-X  PF3-Y     PF4-X  PF4-Y\n");
726719         logerror("------>    #%04x  #%04x     #%04x  #%04x     #%04x  #%04x     #%04x  #%04x\n",
727            state->m_pf1_scrollx, state->m_pf1_scrolly, state->m_pf2_scrollx, state->m_pf2_scrolly, state->m_pf3_scrollx, state->m_pf3_scrolly, state->m_pf4_scrollx, state->m_pf4_scrolly);
728         for ( sprite_voffs = 0; sprite_voffs < state->m_spriteram.bytes()/2; sprite_voffs += 4 )
720            m_pf1_scrollx, m_pf1_scrolly, m_pf2_scrollx, m_pf2_scrolly, m_pf3_scrollx, m_pf3_scrolly, m_pf4_scrollx, m_pf4_scrolly);
721         for ( sprite_voffs = 0; sprite_voffs < m_spriteram.bytes()/2; sprite_voffs += 4 )
729722         {
730723            bschar = buffered_spriteram16[sprite_voffs];
731724            bsattr = buffered_spriteram16[sprite_voffs + 1];
r21022r21023
745738         int schar,sattr,sxpos,sypos,bschar,bsattr,bsxpos,bsypos;
746739         logerror("Scrolls    PF1-X  PF1-Y     PF2-X  PF2-Y     PF3-X  PF3-Y     PF4-X  PF4-Y\n");
747740         logerror("------>    #%04x  #%04x     #%04x  #%04x     #%04x  #%04x     #%04x  #%04x\n",
748            state->m_pf1_scrollx, state->m_pf1_scrolly, state->m_pf2_scrollx, state->m_pf2_scrolly, state->m_pf3_scrollx, state->m_pf3_scrolly, state->m_pf4_scrollx, state->m_pf4_scrolly);
749         for ( sprite_voffs = 0; sprite_voffs < state->m_spriteram.bytes()/2; sprite_voffs += 4 )
741            m_pf1_scrollx, m_pf1_scrolly, m_pf2_scrollx, m_pf2_scrolly, m_pf3_scrollx, m_pf3_scrolly, m_pf4_scrollx, m_pf4_scrolly);
742         for ( sprite_voffs = 0; sprite_voffs < m_spriteram.bytes()/2; sprite_voffs += 4 )
750743         {
751744            bschar = buffered_spriteram16[sprite_voffs];
752745            bsattr = buffered_spriteram16[sprite_voffs + 1];
r21022r21023
763756      }
764757   }
765758
766   if ( machine.input().code_pressed(KEYCODE_SLASH) )
759   if ( machine().input().code_pressed(KEYCODE_SLASH) )
767760   {
768      UINT16 *size  = (UINT16 *)(state->m_spritesizeram16);
769      UINT16 *bsize = (UINT16 *)(state->m_buffered_spritesizeram16);
761      UINT16 *size  = (UINT16 *)(m_spritesizeram16);
762      UINT16 *bsize = (UINT16 *)(m_buffered_spritesizeram16);
770763      offs_t offs;
771      while (machine.input().code_pressed(KEYCODE_SLASH)) ;
772      if (state->m_spritesizeram16)           /* FCU controller */
764      while (machine().input().code_pressed(KEYCODE_SLASH)) ;
765      if (m_spritesizeram16)           /* FCU controller */
773766      {
774767         logerror("Scrolls    PF1-X  PF1-Y     PF2-X  PF2-Y     PF3-X  PF3-Y     PF4-X  PF4-Y\n");
775768         logerror("------>    #%04x  #%04x     #%04x  #%04x     #%04x  #%04x     #%04x  #%04x\n",
776            state->m_pf1_scrollx, state->m_pf1_scrolly, state->m_pf2_scrollx, state->m_pf2_scrolly, state->m_pf3_scrollx, state->m_pf3_scrolly, state->m_pf4_scrollx, state->m_pf4_scrolly);
769            m_pf1_scrollx, m_pf1_scrolly, m_pf2_scrollx, m_pf2_scrolly, m_pf3_scrollx, m_pf3_scrolly, m_pf4_scrollx, m_pf4_scrolly);
777770         for ( offs = 0; offs < (TOAPLAN1_SPRITESIZERAM_SIZE/2); offs +=4 )
778771         {
779772            logerror("SizeOffs:%04x   now:%04x %04x %04x %04x    next: %04x %04x %04x %04x\n", offs,
r21022r21023
785778      }
786779   }
787780
788   if ( machine.input().code_pressed(KEYCODE_N) )
781   if ( machine().input().code_pressed(KEYCODE_N) )
789782   {
790783      offs_t tile_voffs;
791784      int tchar[5], tattr[5];
792      while (machine.input().code_pressed(KEYCODE_N)) ;   /* BCU controller */
785      while (machine().input().code_pressed(KEYCODE_N)) ;   /* BCU controller */
793786      logerror("Scrolls    PF1-X  PF1-Y     PF2-X  PF2-Y     PF3-X  PF3-Y     PF4-X  PF4-Y\n");
794787      logerror("------>    #%04x  #%04x     #%04x  #%04x     #%04x  #%04x     #%04x  #%04x\n",
795         state->m_pf1_scrollx, state->m_pf1_scrolly, state->m_pf2_scrollx, state->m_pf2_scrolly, state->m_pf3_scrollx, state->m_pf3_scrolly, state->m_pf4_scrollx, state->m_pf4_scrolly);
788         m_pf1_scrollx, m_pf1_scrolly, m_pf2_scrollx, m_pf2_scrolly, m_pf3_scrollx, m_pf3_scrolly, m_pf4_scrollx, m_pf4_scrolly);
796789      for ( tile_voffs = 0; tile_voffs < (TOAPLAN1_TILEVRAM_SIZE/2); tile_voffs += 2 )
797790      {
798         tchar[1] = state->m_pf1_tilevram16[tile_voffs + 1];
799         tattr[1] = state->m_pf1_tilevram16[tile_voffs];
800         tchar[2] = state->m_pf2_tilevram16[tile_voffs + 1];
801         tattr[2] = state->m_pf2_tilevram16[tile_voffs];
802         tchar[3] = state->m_pf3_tilevram16[tile_voffs + 1];
803         tattr[3] = state->m_pf3_tilevram16[tile_voffs];
804         tchar[4] = state->m_pf4_tilevram16[tile_voffs + 1];
805         tattr[4] = state->m_pf4_tilevram16[tile_voffs];
791         tchar[1] = m_pf1_tilevram16[tile_voffs + 1];
792         tattr[1] = m_pf1_tilevram16[tile_voffs];
793         tchar[2] = m_pf2_tilevram16[tile_voffs + 1];
794         tattr[2] = m_pf2_tilevram16[tile_voffs];
795         tchar[3] = m_pf3_tilevram16[tile_voffs + 1];
796         tattr[3] = m_pf3_tilevram16[tile_voffs];
797         tchar[4] = m_pf4_tilevram16[tile_voffs + 1];
798         tattr[4] = m_pf4_tilevram16[tile_voffs];
806799//          logerror("PF3 offs:%04x   Tile:%04x  Attr:%04x\n", tile_voffs, tchar, tattr);
807800         logerror("$(%04x)  Attr-Tile PF1:%04x-%04x  PF2:%04x-%04x  PF3:%04x-%04x  PF4:%04x-%04x\n", tile_voffs,
808801                           tattr[1], tchar[1],  tattr[2], tchar[2],
r21022r21023
810803      }
811804   }
812805
813   if ( machine.input().code_pressed(KEYCODE_W) )
806   if ( machine().input().code_pressed(KEYCODE_W) )
814807   {
815      while (machine.input().code_pressed(KEYCODE_W)) ;
808      while (machine().input().code_pressed(KEYCODE_W)) ;
816809      logerror("Mark here\n");
817810   }
818   if ( machine.input().code_pressed(KEYCODE_E) )
811   if ( machine().input().code_pressed(KEYCODE_E) )
819812   {
820      while (machine.input().code_pressed(KEYCODE_E)) ;
821      state->m_displog += 1;
822      state->m_displog &= 1;
813      while (machine().input().code_pressed(KEYCODE_E)) ;
814      m_displog += 1;
815      m_displog &= 1;
823816   }
824   if (state->m_displog)
817   if (m_displog)
825818   {
826819      logerror("Scrolls    PF1-X  PF1-Y     PF2-X  PF2-Y     PF3-X  PF3-Y     PF4-X  PF4-Y\n");
827820      logerror("------>    #%04x  #%04x     #%04x  #%04x     #%04x  #%04x     #%04x  #%04x\n",
828         state->m_pf1_scrollx, state->m_pf1_scrolly, state->m_pf2_scrollx, state->m_pf2_scrolly, state->m_pf3_scrollx, state->m_pf3_scrolly, state->m_pf4_scrollx, state->m_pf4_scrolly);
821         m_pf1_scrollx, m_pf1_scrolly, m_pf2_scrollx, m_pf2_scrolly, m_pf3_scrollx, m_pf3_scrolly, m_pf4_scrollx, m_pf4_scrolly);
829822   }
830   if ( machine.input().code_pressed(KEYCODE_B) )
823   if ( machine().input().code_pressed(KEYCODE_B) )
831824   {
832//      while (machine.input().code_pressed(KEYCODE_B)) ;
833      state->m_scrollx_offs1 += 0x1; state->m_scrollx_offs2 += 0x1; state->m_scrollx_offs3 += 0x1; state->m_scrollx_offs4 += 0x1;
834      logerror("Scrollx_offs now = %08x\n", state->m_scrollx_offs4);
835      state->m_pf1_tilemap->set_scrollx(0, (state->m_pf1_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs1));
836      state->m_pf2_tilemap->set_scrollx(0, (state->m_pf2_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs2));
837      state->m_pf3_tilemap->set_scrollx(0, (state->m_pf3_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs3));
838      state->m_pf4_tilemap->set_scrollx(0, (state->m_pf4_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs4));
825//      while (machine().input().code_pressed(KEYCODE_B)) ;
826      m_scrollx_offs1 += 0x1; m_scrollx_offs2 += 0x1; m_scrollx_offs3 += 0x1; m_scrollx_offs4 += 0x1;
827      logerror("Scrollx_offs now = %08x\n", m_scrollx_offs4);
828      m_pf1_tilemap->set_scrollx(0, (m_pf1_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs1));
829      m_pf2_tilemap->set_scrollx(0, (m_pf2_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs2));
830      m_pf3_tilemap->set_scrollx(0, (m_pf3_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs3));
831      m_pf4_tilemap->set_scrollx(0, (m_pf4_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs4));
839832   }
840   if ( machine.input().code_pressed(KEYCODE_V) )
833   if ( machine().input().code_pressed(KEYCODE_V) )
841834   {
842//      while (machine.input().code_pressed(KEYCODE_V)) ;
843      state->m_scrollx_offs1 -= 0x1; state->m_scrollx_offs2 -= 0x1; state->m_scrollx_offs3 -= 0x1; state->m_scrollx_offs4 -= 0x1;
844      logerror("Scrollx_offs now = %08x\n", state->m_scrollx_offs4);
845      state->m_pf1_tilemap->set_scrollx(0, (state->m_pf1_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs1));
846      state->m_pf2_tilemap->set_scrollx(0, (state->m_pf2_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs2));
847      state->m_pf3_tilemap->set_scrollx(0, (state->m_pf3_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs3));
848      state->m_pf4_tilemap->set_scrollx(0, (state->m_pf4_scrollx >> 7) - (state->m_tiles_offsetx - state->m_scrollx_offs4));
835//      while (machine().input().code_pressed(KEYCODE_V)) ;
836      m_scrollx_offs1 -= 0x1; m_scrollx_offs2 -= 0x1; m_scrollx_offs3 -= 0x1; m_scrollx_offs4 -= 0x1;
837      logerror("Scrollx_offs now = %08x\n", m_scrollx_offs4);
838      m_pf1_tilemap->set_scrollx(0, (m_pf1_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs1));
839      m_pf2_tilemap->set_scrollx(0, (m_pf2_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs2));
840      m_pf3_tilemap->set_scrollx(0, (m_pf3_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs3));
841      m_pf4_tilemap->set_scrollx(0, (m_pf4_scrollx >> 7) - (m_tiles_offsetx - m_scrollx_offs4));
849842   }
850   if ( machine.input().code_pressed(KEYCODE_C) )
843   if ( machine().input().code_pressed(KEYCODE_C) )
851844   {
852//      while (machine.input().code_pressed(KEYCODE_C)) ;
853      state->m_scrolly_offs += 0x1;
854      logerror("Scrolly_offs now = %08x\n", state->m_scrolly_offs);
855      state->m_pf1_tilemap->set_scrolly(0, (state->m_pf1_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
856      state->m_pf2_tilemap->set_scrolly(0, (state->m_pf2_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
857      state->m_pf3_tilemap->set_scrolly(0, (state->m_pf3_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
858      state->m_pf4_tilemap->set_scrolly(0, (state->m_pf4_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
845//      while (machine().input().code_pressed(KEYCODE_C)) ;
846      m_scrolly_offs += 0x1;
847      logerror("Scrolly_offs now = %08x\n", m_scrolly_offs);
848      m_pf1_tilemap->set_scrolly(0, (m_pf1_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
849      m_pf2_tilemap->set_scrolly(0, (m_pf2_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
850      m_pf3_tilemap->set_scrolly(0, (m_pf3_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
851      m_pf4_tilemap->set_scrolly(0, (m_pf4_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
859852   }
860   if ( machine.input().code_pressed(KEYCODE_X) )
853   if ( machine().input().code_pressed(KEYCODE_X) )
861854   {
862//      while (machine.input().code_pressed(KEYCODE_X)) ;
863      state->m_scrolly_offs -= 0x1;
864      logerror("Scrolly_offs now = %08x\n", state->m_scrolly_offs);
865      state->m_pf1_tilemap->set_scrolly(0, (state->m_pf1_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
866      state->m_pf2_tilemap->set_scrolly(0, (state->m_pf2_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
867      state->m_pf3_tilemap->set_scrolly(0, (state->m_pf3_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
868      state->m_pf4_tilemap->set_scrolly(0, (state->m_pf4_scrolly >> 7) - (state->m_tiles_offsety - state->m_scrolly_offs));
855//      while (machine().input().code_pressed(KEYCODE_X)) ;
856      m_scrolly_offs -= 0x1;
857      logerror("Scrolly_offs now = %08x\n", m_scrolly_offs);
858      m_pf1_tilemap->set_scrolly(0, (m_pf1_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
859      m_pf2_tilemap->set_scrolly(0, (m_pf2_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
860      m_pf3_tilemap->set_scrolly(0, (m_pf3_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
861      m_pf4_tilemap->set_scrolly(0, (m_pf4_scrolly >> 7) - (m_tiles_offsety - m_scrolly_offs));
869862   }
870863
871   if ( machine.input().code_pressed(KEYCODE_L) )      /* Turn Playfield 4 on/off */
864   if ( machine().input().code_pressed(KEYCODE_L) )      /* Turn Playfield 4 on/off */
872865   {
873      while (machine.input().code_pressed(KEYCODE_L)) ;
874      state->m_display_pf4 += 1;
875      state->m_display_pf4 &= 1;
876      state->m_pf4_tilemap->enable(state->m_display_pf4);
866      while (machine().input().code_pressed(KEYCODE_L)) ;
867      m_display_pf4 += 1;
868      m_display_pf4 &= 1;
869      m_pf4_tilemap->enable(m_display_pf4);
877870   }
878   if ( machine.input().code_pressed(KEYCODE_K) )      /* Turn Playfield 3 on/off */
871   if ( machine().input().code_pressed(KEYCODE_K) )      /* Turn Playfield 3 on/off */
879872   {
880      while (machine.input().code_pressed(KEYCODE_K)) ;
881      state->m_display_pf3 += 1;
882      state->m_display_pf3 &= 1;
883      state->m_pf3_tilemap->enable(state->m_display_pf3);
873      while (machine().input().code_pressed(KEYCODE_K)) ;
874      m_display_pf3 += 1;
875      m_display_pf3 &= 1;
876      m_pf3_tilemap->enable(m_display_pf3);
884877   }
885   if ( machine.input().code_pressed(KEYCODE_J) )      /* Turn Playfield 2 on/off */
878   if ( machine().input().code_pressed(KEYCODE_J) )      /* Turn Playfield 2 on/off */
886879   {
887      while (machine.input().code_pressed(KEYCODE_J)) ;
888      state->m_display_pf2 += 1;
889      state->m_display_pf2 &= 1;
890      state->m_pf2_tilemap->enable(state->m_display_pf2);
880      while (machine().input().code_pressed(KEYCODE_J)) ;
881      m_display_pf2 += 1;
882      m_display_pf2 &= 1;
883      m_pf2_tilemap->enable(m_display_pf2);
891884   }
892   if ( machine.input().code_pressed(KEYCODE_H) )      /* Turn Playfield 1 on/off */
885   if ( machine().input().code_pressed(KEYCODE_H) )      /* Turn Playfield 1 on/off */
893886   {
894      while (machine.input().code_pressed(KEYCODE_H)) ;
895      state->m_display_pf1 += 1;
896      state->m_display_pf1 &= 1;
897      state->m_pf1_tilemap->enable(state->m_display_pf1);
887      while (machine().input().code_pressed(KEYCODE_H)) ;
888      m_display_pf1 += 1;
889      m_display_pf1 &= 1;
890      m_pf1_tilemap->enable(m_display_pf1);
898891   }
899892#endif
900893}
r21022r21023
1002995}
1003996
1004997
1005static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
998void toaplan1_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
1006999{
1007   toaplan1_state *state = machine.driver_data<toaplan1_state>();
1008   UINT16 *source = (UINT16 *)state->m_buffered_spriteram;
1009   UINT16 *size   = (UINT16 *)state->m_buffered_spritesizeram16;
1010   int fcu_flipscreen = state->m_fcu_flipscreen;
1000   UINT16 *source = (UINT16 *)m_buffered_spriteram;
1001   UINT16 *size   = (UINT16 *)m_buffered_spritesizeram16;
1002   int fcu_flipscreen = m_fcu_flipscreen;
10111003   int offs;
10121004
1013   for (offs = state->m_spriteram.bytes()/2 - 4; offs >= 0; offs -= 4)
1005   for (offs = m_spriteram.bytes()/2 - 4; offs >= 0; offs -= 4)
10141006   {
10151007      if (!(source[offs] & 0x8000))
10161008      {
r21022r21023
10391031         /****** flip the sprite layer ******/
10401032         if (fcu_flipscreen)
10411033         {
1042            const rectangle &visarea = machine.primary_screen->visible_area();
1034            const rectangle &visarea = machine().primary_screen->visible_area();
10431035
10441036            sx_base = visarea.width() - (sx_base + 8);  /* visarea.x = 320 */
10451037            sy_base = visarea.height() - (sy_base + 8); /* visarea.y = 240 */
r21022r21023
10561048               if (fcu_flipscreen) sx = sx_base - dim_x;
10571049               else                sx = sx_base + dim_x;
10581050
1059               toaplan1_draw_sprite_custom(bitmap,cliprect,machine.gfx[1],
1051               toaplan1_draw_sprite_custom(bitmap,cliprect,machine().gfx[1],
10601052                                    sprite,color,
10611053                                    fcu_flipscreen,fcu_flipscreen,
10621054                                    sx,sy,
r21022r21023
10701062}
10711063
10721064
1073static void rallybik_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
1065void toaplan1_state::rallybik_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
10741066{
1075   toaplan1_state *state = machine.driver_data<toaplan1_state>();
1076   UINT16 *buffered_spriteram16 = state->m_buffered_spriteram;
1067   UINT16 *buffered_spriteram16 = m_buffered_spriteram;
10771068   int offs;
10781069
1079   for (offs = 0; offs < state->m_spriteram.bytes()/2; offs += 4)
1070   for (offs = 0; offs < m_spriteram.bytes()/2; offs += 4)
10801071   {
10811072      int attrib, sx, sy, flipx, flipy;
10821073      int sprite, color;
r21022r21023
10931084            flipx = attrib & 0x100;
10941085            if (flipx) sx -= 15;
10951086            flipy = attrib & 0x200;
1096            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
1087            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
10971088               sprite,
10981089               color,
10991090               flipx,flipy,
r21022r21023
11121103{
11131104   int priority;
11141105
1115   toaplan1_log_vram(machine());
1106   toaplan1_log_vram();
11161107
11171108   bitmap.fill(0x120, cliprect);
11181109
r21022r21023
11251116      m_pf3_tilemap->draw(bitmap, cliprect, priority, 0);
11261117      m_pf2_tilemap->draw(bitmap, cliprect, priority, 0);
11271118      m_pf1_tilemap->draw(bitmap, cliprect, priority, 0);
1128      rallybik_draw_sprites(machine(), bitmap,cliprect,priority << 8);
1119      rallybik_draw_sprites(bitmap,cliprect,priority << 8);
11291120   }
11301121
11311122   return 0;
r21022r21023
11351126{
11361127   int priority;
11371128
1138   toaplan1_log_vram(machine());
1129   toaplan1_log_vram();
11391130
11401131   machine().priority_bitmap.fill(0, cliprect);
11411132   bitmap.fill(0x120, cliprect);
r21022r21023
11521143      m_pf1_tilemap->draw(bitmap, cliprect, priority, priority, 0);
11531144   }
11541145
1155   draw_sprites(machine(), bitmap, cliprect);
1146   draw_sprites(bitmap, cliprect);
11561147   return 0;
11571148}
11581149
trunk/src/mame/video/tank8.c
r21022r21023
3434}
3535
3636
37static void set_pens(tank8_state *state, colortable_t *colortable)
37void tank8_state::set_pens(colortable_t *colortable)
3838{
39   if (*state->m_team & 0x01)
39   if (*m_team & 0x01)
4040   {
4141      colortable_palette_set_color(colortable, 0, MAKE_RGB(0xff, 0x00, 0x00)); /* red     */
4242      colortable_palette_set_color(colortable, 1, MAKE_RGB(0x00, 0x00, 0xff)); /* blue    */
r21022r21023
113113}
114114
115115
116static int get_x_pos(tank8_state *state, int n)
116int tank8_state::get_x_pos(int n)
117117{
118   return 498 - state->m_pos_h_ram[n] - 2 * (state->m_pos_d_ram[n] & 128); /* ? */
118   return 498 - m_pos_h_ram[n] - 2 * (m_pos_d_ram[n] & 128); /* ? */
119119}
120120
121121
122static int get_y_pos(tank8_state *state, int n)
122int tank8_state::get_y_pos(int n)
123123{
124   return 2 * state->m_pos_v_ram[n] - 62;
124   return 2 * m_pos_v_ram[n] - 62;
125125}
126126
127127
128static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
128void tank8_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
129129{
130   tank8_state *state = machine.driver_data<tank8_state>();
131130   int i;
132131
133132   for (i = 0; i < 8; i++)
134133   {
135      UINT8 code = ~state->m_pos_d_ram[i];
134      UINT8 code = ~m_pos_d_ram[i];
136135
137      int x = get_x_pos(state, i);
138      int y = get_y_pos(state, i);
136      int x = get_x_pos(i);
137      int y = get_y_pos(i);
139138
140      drawgfx_transpen(bitmap, cliprect, machine.gfx[(code & 0x04) ? 2 : 3],
139      drawgfx_transpen(bitmap, cliprect, machine().gfx[(code & 0x04) ? 2 : 3],
141140         code & 0x03,
142141         i,
143142         code & 0x10,
r21022r21023
148147}
149148
150149
151static void draw_bullets(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
150void tank8_state::draw_bullets(bitmap_ind16 &bitmap, const rectangle &cliprect)
152151{
153   tank8_state *state = machine.driver_data<tank8_state>();
154152   int i;
155153
156154   for (i = 0; i < 8; i++)
157155   {
158      int x = get_x_pos(state, 8 + i);
159      int y = get_y_pos(state, 8 + i);
156      int x = get_x_pos(8 + i);
157      int y = get_y_pos(8 + i);
160158
161159      x -= 4; /* ? */
162160
r21022r21023
170168
171169TIMER_CALLBACK_MEMBER(tank8_state::tank8_collision_callback)
172170{
173   tank8_set_collision(machine(), param);
171   tank8_set_collision(param);
174172}
175173
176174
177175UINT32 tank8_state::screen_update_tank8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
178176{
179   set_pens(this, machine().colortable);
177   set_pens(machine().colortable);
180178   m_tilemap->draw(bitmap, cliprect, 0, 0);
181179
182   draw_sprites(machine(), bitmap, cliprect);
183   draw_bullets(machine(), bitmap, cliprect);
180   draw_sprites(bitmap, cliprect);
181   draw_bullets(bitmap, cliprect);
184182   return 0;
185183}
186184
r21022r21023
199197      m_helper2.fill(8, visarea);
200198      m_helper3.fill(8, visarea);
201199
202      draw_sprites(machine(), m_helper2, visarea);
203      draw_bullets(machine(), m_helper3, visarea);
200      draw_sprites(m_helper2, visarea);
201      draw_bullets(m_helper3, visarea);
204202
205203      for (y = visarea.min_y; y <= visarea.max_y; y++)
206204      {
r21022r21023
262260               if (p1[x] == 0x11)
263261                  index |= 0x20;
264262
265               if (y - get_y_pos(this, sprite_num) >= 8)
263               if (y - get_y_pos(sprite_num) >= 8)
266264                  index |= 0x40; /* collision on bottom side */
267265
268               if (x - get_x_pos(this, sprite_num) >= 8)
266               if (x - get_x_pos(sprite_num) >= 8)
269267                  index |= 0x80; /* collision on right side */
270268            }
271269
trunk/src/mame/video/tehkanwc.c
r21022r21023
113113   bit 7 = enable (0 = display off)
114114 */
115115
116static void gridiron_draw_led(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 led,int player)
116void tehkanwc_state::gridiron_draw_led(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 led,int player)
117117{
118118   if (led&0x80)
119119      output_set_digit_value(player, led&0x7f);
r21022r21023
121121      output_set_digit_value(player, 0x00);
122122}
123123
124static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
124void tehkanwc_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
125125{
126   tehkanwc_state *state = machine.driver_data<tehkanwc_state>();
127   UINT8 *spriteram = state->m_spriteram;
126   UINT8 *spriteram = m_spriteram;
128127   int offs;
129128
130   for (offs = 0;offs < state->m_spriteram.bytes();offs += 4)
129   for (offs = 0;offs < m_spriteram.bytes();offs += 4)
131130   {
132131      int attr = spriteram[offs + 1];
133132      int code = spriteram[offs] + ((attr & 0x08) << 5);
r21022r21023
137136      int sx = spriteram[offs + 2] + ((attr & 0x20) << 3) - 128;
138137      int sy = spriteram[offs + 3];
139138
140      if (state->flip_screen_x())
139      if (flip_screen_x())
141140      {
142141         sx = 240 - sx;
143142         flipx = !flipx;
144143      }
145144
146      if (state->flip_screen_y())
145      if (flip_screen_y())
147146      {
148147         sy = 240 - sy;
149148         flipy = !flipy;
150149      }
151150
152      drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
151      drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
153152         code, color, flipx, flipy, sx, sy, 0);
154153   }
155154}
r21022r21023
159158   m_bg_tilemap->set_scrollx(0, m_scroll_x[0] + 256 * m_scroll_x[1]);
160159   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
161160   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
162   draw_sprites(machine(), bitmap, cliprect);
161   draw_sprites(bitmap, cliprect);
163162   m_fg_tilemap->draw(bitmap, cliprect, 1, 0);
164   gridiron_draw_led(machine(), bitmap, cliprect, m_led0, 0);
165   gridiron_draw_led(machine(), bitmap, cliprect, m_led1, 1);
163   gridiron_draw_led(bitmap, cliprect, m_led0, 0);
164   gridiron_draw_led(bitmap, cliprect, m_led1, 1);
166165   return 0;
167166}
trunk/src/mame/video/taitojc.c
r21022r21023
110110
111111*/
112112
113static void draw_object(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 w1, UINT32 w2, UINT8 bank_type)
113void taitojc_state::draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 w1, UINT32 w2, UINT8 bank_type)
114114{
115   taitojc_state *state = machine.driver_data<taitojc_state>();
116115   int x, y, width, height, palette;
117116   int i, j;
118117   int x1, x2, y1, y2;
r21022r21023
143142
144143   /* TODO: untangle this! */
145144   if(address >= 0xff000)
146      v = (UINT8*)&state->m_objlist[(address-0xff000)/4];
145      v = (UINT8*)&m_objlist[(address-0xff000)/4];
147146   if(address >= 0xfc000)
148      v = (UINT8*)&state->m_char_ram[(address-0xfc000)/4];
147      v = (UINT8*)&m_char_ram[(address-0xfc000)/4];
149148   else if(address >= 0xf8000)
150      v = (UINT8*)&state->m_tile_ram[(address-0xf8000)/4];
149      v = (UINT8*)&m_tile_ram[(address-0xf8000)/4];
151150   else
152      v = (UINT8*)&state->m_vram[address/4];
151      v = (UINT8*)&m_vram[address/4];
153152
154153   /* guess, but it's probably doable via a vreg ... */
155154   if ((width == 0 || height == 0) && bank_type == 2)
r21022r21023
265264   }
266265}
267266
268static void draw_object_bank(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 bank_type, UINT8 pri)
267void taitojc_state::draw_object_bank(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 bank_type, UINT8 pri)
269268{
270   taitojc_state *state = machine.driver_data<taitojc_state>();
271269   UINT16 start_offs;
272270//  UINT8 double_xy;
273271   int i;
274272
275273   start_offs = ((bank_type+1)*0x400)/4;
276//  double_xy = (state->m_objlist[(0xd1c+bank_type*0x10)/4] & 0x20000000) >> 29;
274//  double_xy = (m_objlist[(0xd1c+bank_type*0x10)/4] & 0x20000000) >> 29;
277275
278276   /* probably a core bug in there (otherwise objects sticks on screen in Densha de Go) */
279   if(bank_type == 1 && (!(state->m_objlist[0xfc4/4] & 0x2000)))
277   if(bank_type == 1 && (!(m_objlist[0xfc4/4] & 0x2000)))
280278      return;
281279
282280   for (i=start_offs-2; i >= (start_offs-0x400/4); i-=2)
283281   {
284      UINT32 w1 = state->m_objlist[i + 0];
285      UINT32 w2 = state->m_objlist[i + 1];
282      UINT32 w1 = m_objlist[i + 0];
283      UINT32 w2 = m_objlist[i + 1];
286284
287285      if (((w2 & 0x200000) >> 21) == pri)
288286      {
289         draw_object(machine, bitmap, cliprect, w1, w2, bank_type);
287         draw_object(bitmap, cliprect, w1, w2, bank_type);
290288      }
291289   }
292290}
r21022r21023
325323   bitmap.fill(0, cliprect);
326324
327325   // low priority objects
328   draw_object_bank(machine(), bitmap, cliprect, 0, 0);
329   draw_object_bank(machine(), bitmap, cliprect, 1, 0);
330   draw_object_bank(machine(), bitmap, cliprect, 2, 0);
326   draw_object_bank(bitmap, cliprect, 0, 0);
327   draw_object_bank(bitmap, cliprect, 1, 0);
328   draw_object_bank(bitmap, cliprect, 2, 0);
331329
332330   // 3D layer
333331   copybitmap_trans(bitmap, m_framebuffer, 0, 0, 0, 0, cliprect, 0);
334332
335333   // high priority objects
336   draw_object_bank(machine(), bitmap, cliprect, 0, 1);
337   draw_object_bank(machine(), bitmap, cliprect, 1, 1);
338   draw_object_bank(machine(), bitmap, cliprect, 2, 1);
334   draw_object_bank(bitmap, cliprect, 0, 1);
335   draw_object_bank(bitmap, cliprect, 1, 1);
336   draw_object_bank(bitmap, cliprect, 2, 1);
339337
340338   // text layer
341339   if (m_objlist[0xfc4/4] & 0x10000)
r21022r21023
753751   wait("Finished render");
754752}
755753
756void taitojc_clear_frame(running_machine &machine)
754void taitojc_state::taitojc_clear_frame()
757755{
758   taitojc_state *state = machine.driver_data<taitojc_state>();
759756
760   state->m_framebuffer.fill(0, machine.primary_screen->visible_area());
761   state->m_zbuffer.fill(0xffff, machine.primary_screen->visible_area());
757   m_framebuffer.fill(0, machine().primary_screen->visible_area());
758   m_zbuffer.fill(0xffff, machine().primary_screen->visible_area());
762759}
trunk/src/mame/includes/targeth.h
r21022r21023
2222   virtual void video_start();
2323   UINT32 screen_update_targeth(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2424   TIMER_DEVICE_CALLBACK_MEMBER(targeth_interrupt);
25   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
2526};
trunk/src/mame/includes/tunhunt.h
r21022r21023
2525   virtual void video_start();
2626   virtual void palette_init();
2727   UINT32 screen_update_tunhunt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
28   void set_pens();
29   void draw_motion_object(bitmap_ind16 &bitmap, const rectangle &cliprect);
30   void draw_box(bitmap_ind16 &bitmap, const rectangle &cliprect);
31   void draw_shell(bitmap_ind16 &bitmap, const rectangle &cliprect, int picture_code,
32      int hposition,int vstart,int vstop,int vstretch,int hstretch);
2833};
trunk/src/mame/includes/toaplan1.h
r21022r21023
147147   void rallybik_flipscreen();
148148   void toaplan1_flipscreen();
149149   void demonwld_restore_dsp();
150   void toaplan1_create_tilemaps();
151   void toaplan1_paletteram_alloc();
152   void toaplan1_vram_alloc();
153   void toaplan1_spritevram_alloc();
154   void toaplan1_set_scrolls();
155   void register_common();
156   void toaplan1_log_vram();
157   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
158   void rallybik_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
159   void demonwld_dsp(int enable);
160   void toaplan1_driver_savestate();
161   void demonwld_driver_savestate();
162   void vimana_driver_savestate();
150163};
151164
152165
trunk/src/mame/includes/tehkanwc.h
r21022r21023
4848   virtual void video_start();
4949   UINT32 screen_update_tehkanwc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5050   TIMER_CALLBACK_MEMBER(reset_callback);
51   void gridiron_draw_led(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 led,int player);
52   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5153};
trunk/src/mame/includes/toypop.h
r21022r21023
5454   INTERRUPT_GEN_MEMBER(toypop_sound_timer_irq);
5555   INTERRUPT_GEN_MEMBER(toypop_m68000_interrupt);
5656   TIMER_CALLBACK_MEMBER(namcoio_run);
57   void draw_background(bitmap_ind16 &bitmap);
58   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base);
5759};
trunk/src/mame/includes/taito_o.h
r21022r21023
2121   virtual void machine_start();
2222   UINT32 screen_update_parentj(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2323   TIMER_DEVICE_CALLBACK_MEMBER(parentj_interrupt);
24   void parentj_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
2425};
trunk/src/mame/includes/toaplan2.h
r21022r21023
133133   INTERRUPT_GEN_MEMBER(bbakraid_snd_interrupt);
134134   TIMER_CALLBACK_MEMBER(toaplan2_raise_irq);
135135   void truxton2_postload();
136   void truxton2_create_tx_tilemap();
137   void register_state_save();
138   void toaplan2_vblank_irq(int irq_line);
136139};
trunk/src/mame/includes/tankbust.h
r21022r21023
4646   INTERRUPT_GEN_MEMBER(vblank_irq);
4747   TIMER_CALLBACK_MEMBER(soundlatch_callback);
4848   TIMER_CALLBACK_MEMBER(soundirqline_callback);
49   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
4950};
trunk/src/mame/includes/tetrisp2.h
r21022r21023
114114   TIMER_CALLBACK_MEMBER(rockn_timer_sub_level4_callback);
115115   TIMER_CALLBACK_MEMBER(rockn_timer_level1_callback);
116116   TIMER_CALLBACK_MEMBER(rockn_timer_sub_level1_callback);
117   void init_rockn_timer();
117118};
118119
119120class stepstag_state : public tetrisp2_state
r21022r21023
136137   UINT32 screen_update_stepstag_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
137138   UINT32 screen_update_stepstag_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
138139   UINT32 screen_update_stepstag_mid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
140   inline int mypal(int x);
139141};
trunk/src/mame/includes/taitoair.h
r21022r21023
8484   virtual void video_start();
8585   UINT32 screen_update_taitoair(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8686   void reset_sound_region();
87   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
88   void fill_slope( bitmap_ind16 &bitmap, const rectangle &cliprect, int color, INT32 x1, INT32 x2, INT32 sl1, INT32 sl2, INT32 y1, INT32 y2, INT32 *nx1, INT32 *nx2 );
89   void multVecMtx(const INT16* vec4, const float* m, float* result);
90   void airInfernoFrustum(const INT16 leftExtent, const INT16 bottomExtent, float* m);
91   void fill_poly( bitmap_ind16 &bitmap, const rectangle &cliprect, const struct taitoair_poly *q );
92   int projectEyeCoordToScreen(float* projectionMatrix,const int Res,INT16* eyePoint3d,int type);
8793};
trunk/src/mame/includes/turbo.h
r21022r21023
9292   UINT8       m_buckrog_myship;
9393   int m_last_sound_a;
9494
95   struct sprite_info
96   {
97      UINT16  ve;                 /* VE0-15 signals for this row */
98      UINT8   lst;                /* LST0-7 signals for this row */
99      UINT32  latched[8];         /* latched pixel data */
100      UINT8   plb[8];             /* latched PLB state */
101      UINT32  offset[8];          /* current offset for this row */
102      UINT32  frac[8];            /* leftover fraction */
103      UINT32  step[8];            /* stepping value */
104   };
105
95106   DECLARE_WRITE8_MEMBER(scanlines_w);
96107   DECLARE_WRITE8_MEMBER(digit_w);
97108   DECLARE_READ8_MEMBER(turbo_collision_r);
r21022r21023
140151   DECLARE_WRITE8_MEMBER(subroc3d_sound_c_w);
141152   DECLARE_WRITE8_MEMBER(buckrog_sound_a_w);
142153   DECLARE_WRITE8_MEMBER(buckrog_sound_b_w);
154   inline UINT32 sprite_xscale(UINT8 dacinput, double vr1, double vr2, double cext);
155   void turbo_prepare_sprites(UINT8 y, sprite_info *info);
156   UINT32 turbo_get_sprite_bits(const UINT8 *sprite_gfxdata, UINT8 road, sprite_info *sprinfo);
157   void subroc3d_prepare_sprites(UINT8 y, sprite_info *info);
158   UINT32 subroc3d_get_sprite_bits(const UINT8 *sprite_gfxdata, sprite_info *sprinfo, UINT8 *plb);
159   void buckrog_prepare_sprites(UINT8 y, sprite_info *info);
160   UINT32 buckrog_get_sprite_bits(const UINT8 *sprite_gfxdata, sprite_info *sprinfo, UINT8 *plb);
161   void turbo_rom_decode();
143162};
144163
145164
trunk/src/mame/includes/thoop2.h
r21022r21023
2121   TILE_GET_INFO_MEMBER(get_tile_info_thoop2_screen1);
2222   virtual void video_start();
2323   UINT32 screen_update_thoop2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
24   void thoop2_sort_sprites();
25   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri);
2426};
trunk/src/mame/includes/taito_b.h
r21022r21023
9595   TIMER_CALLBACK_MEMBER(selfeena_interrupt4);
9696   TIMER_CALLBACK_MEMBER(sbm_interrupt5);
9797   TIMER_CALLBACK_MEMBER(realpunc_interrupt3);
98   void hitice_clear_pixel_bitmap(  );
99   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
100   void draw_framebuffer( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
101   void ryujin_patch(void);
102   void sbm_patch(void);
98103};
trunk/src/mame/includes/timelimt.h
r21022r21023
3030   virtual void palette_init();
3131   UINT32 screen_update_timelimt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3232   INTERRUPT_GEN_MEMBER(timelimt_irq);
33   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3334};
trunk/src/mame/includes/twin16.h
r21022r21023
6666   INTERRUPT_GEN_MEMBER(CPUA_interrupt);
6767   INTERRUPT_GEN_MEMBER(CPUB_interrupt);
6868   TIMER_CALLBACK_MEMBER(twin16_sprite_tick);
69   int twin16_set_sprite_timer(  );
70   void twin16_spriteram_process(  );
71   void draw_sprites( bitmap_ind16 &bitmap );
72   void draw_layer( bitmap_ind16 &bitmap, int opaque );
73   int twin16_spriteram_process_enable(  );
74   void gfx_untangle(  );
6975};
7076
7177/*----------- defined in drivers/twin16.c -----------*/
trunk/src/mame/includes/tmnt.h
r21022r21023
145145   INTERRUPT_GEN_MEMBER(lgtnfght_interrupt);
146146   INTERRUPT_GEN_MEMBER(tmnt_vblank_irq);
147147   TIMER_CALLBACK_MEMBER(nmi_callback);
148   void sound_nmi_callback( int param );
149   inline UINT32 tmnt2_get_word( UINT32 addr );
150   void tmnt2_put_word( address_space &space, UINT32 addr, UINT16 data );
148151};
149152
150153
trunk/src/mame/includes/tail2nos.h
r21022r21023
4040   virtual void video_start();
4141   UINT32 screen_update_tail2nos(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4242   void tail2nos_postload();
43   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4344};
4445
4546/*----------- defined in video/tail2nos.c -----------*/
trunk/src/mame/includes/tryout.h
r21022r21023
3535   virtual void video_start();
3636   virtual void palette_init();
3737   UINT32 screen_update_tryout(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
38   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
3839};
trunk/src/mame/includes/tsamurai.h
r21022r21023
6161   UINT32 screen_update_vsgongf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6262   INTERRUPT_GEN_MEMBER(samurai_interrupt);
6363   INTERRUPT_GEN_MEMBER(vsgongf_sound_interrupt);
64   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
6465};
trunk/src/mame/includes/taitojc.h
r21022r21023
162162   UINT32 screen_update_taitojc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
163163   UINT32 screen_update_dendego(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
164164   INTERRUPT_GEN_MEMBER(taitojc_vblank);
165   void draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 w1, UINT32 w2, UINT8 bank_type);
166   void draw_object_bank(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 bank_type, UINT8 pri);
167   void taitojc_clear_frame();
168   void debug_dsp_command();
169   UINT8 mcu_comm_reg_r(address_space &space, int reg);
170   void mcu_comm_reg_w(address_space &space, int reg, UINT8 data);
165171};
166172
167173
trunk/src/mame/includes/tecmosys.h
r21022r21023
8282   UINT32 screen_update_tecmosys(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
8383   void tecmosys_prot_init(int which);
8484   void tecmosys_prot_reset();
85   inline void set_color_555_tecmo(pen_t color, int rshift, int gshift, int bshift, UINT16 data);
86   void tecmosys_render_sprites_to_bitmap(bitmap_rgb32 &bitmap, UINT16 extrax, UINT16 extray );
87   void tecmosys_tilemap_copy_to_compose(UINT16 pri);
88   void tecmosys_do_final_mix(bitmap_rgb32 &bitmap);
89   void tecmosys_descramble();
8590};
trunk/src/mame/includes/topspeed.h
r21022r21023
6161   TIMER_CALLBACK_MEMBER(topspeed_cpub_interrupt6);
6262   DECLARE_WRITE8_MEMBER(topspeed_tc0140syt_comm_w);
6363   void topspeed_postload();
64   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
65   void parse_control(  )   /* assumes Z80 sandwiched between 68Ks */;
66   void reset_sound_region(  );
6467};
trunk/src/mame/includes/thunderx.h
r21022r21023
5353   UINT32 screen_update_scontra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   INTERRUPT_GEN_MEMBER(scontra_interrupt);
5555   TIMER_CALLBACK_MEMBER(thunderx_firq_callback);
56   void run_collisions( int s0, int e0, int s1, int e1, int cm, int hm );
57   void calculate_collisions(  );
5658};
5759
5860
trunk/src/mame/includes/tceptor.h
r21022r21023
6767   INTERRUPT_GEN_MEMBER(m6809_vb_interrupt);
6868   INTERRUPT_GEN_MEMBER(m68k_vb_interrupt);
6969   INTERRUPT_GEN_MEMBER(mcu_vb_interrupt);
70   inline int get_tile_addr(int tile_index);
71   void decode_bg(const char * region);
72   void decode_sprite(int gfx_index, const gfx_layout *layout, const void *data);
73   void decode_sprite16(const char * region);
74   void decode_sprite32(const char * region);
75   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_priority);
76   inline UINT8 fix_input0(UINT8 in1, UINT8 in2);
77   inline UINT8 fix_input1(UINT8 in1, UINT8 in2);
7078};
trunk/src/mame/includes/tigeroad.h
r21022r21023
2828   TILEMAP_MAPPER_MEMBER(tigeroad_tilemap_scan);
2929   virtual void video_start();
3030   UINT32 screen_update_tigeroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
31   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
32   void f1dream_protection_w(address_space &space);
3133};
trunk/src/mame/includes/tnzs.h
r21022r21023
101101   INTERRUPT_GEN_MEMBER(arknoid2_interrupt);
102102   TIMER_CALLBACK_MEMBER(kludge_callback);
103103   void tnzs_postload();
104   void mcu_reset(  );
105   void mcu_handle_coins( int coin );
104106};
trunk/src/mame/includes/tp84.h
r21022r21023
4242   virtual void palette_init();
4343   UINT32 screen_update_tp84(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444   INTERRUPT_GEN_MEMBER(sub_vblank_irq);
45   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
4546};
trunk/src/mame/includes/tubep.h
r21022r21023
8181   TIMER_CALLBACK_MEMBER(tubep_scanline_callback);
8282   TIMER_CALLBACK_MEMBER(rjammer_scanline_callback);
8383   TIMER_CALLBACK_MEMBER(sprite_timer_callback);
84   void draw_sprite();
85   void tubep_vblank_end();
86   void tubep_setup_save_state();
8487};
8588
8689
trunk/src/mame/includes/tagteam.h
r21022r21023
2929   virtual void palette_init();
3030   UINT32 screen_update_tagteam(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3131   INTERRUPT_GEN_MEMBER(sound_timer_irq);
32   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3233};
trunk/src/mame/includes/toki.h
r21022r21023
4040   virtual void video_start();
4141   UINT32 screen_update_toki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4242   UINT32 screen_update_tokib(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
43   void toki_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
44   void tokib_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
4345};
trunk/src/mame/includes/taito_f2.h
r21022r21023
145145   INTERRUPT_GEN_MEMBER(taitof2_interrupt);
146146   TIMER_CALLBACK_MEMBER(taitof2_interrupt6);
147147   void reset_driveout_sound_region();
148   void taitof2_core_vh_start (int sprite_type, int hide, int flip_hide );
149   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks, int uses_tc360_mixer );
150   void update_spritebanks(  );
151   void taitof2_handle_sprite_buffering(  );
152   void taitof2_update_sprites_active_area(  );
153   void draw_roz_layer( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 priority);
154   void taito_f2_tc360_spritemixdraw(bitmap_ind16 &dest_bmp, const rectangle &clip, gfx_element *gfx,
155      UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy, int scalex, int scaley );
148156};
trunk/src/mame/includes/tbowl.h
r21022r21023
5353   virtual void video_start();
5454   UINT32 screen_update_tbowl_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   UINT32 screen_update_tbowl_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
56   void tbowl_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect, int xscroll, UINT8* spriteram);
5657};
trunk/src/mame/includes/taito_h.h
r21022r21023
3131   UINT32 screen_update_recordbr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3232   UINT32 screen_update_dleague(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3333   void reset_sound_region();
34   void syvalion_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
35   void recordbr_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
36   void dleague_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
37   void taitoh_log_vram();
3438};
trunk/src/mame/includes/tumblep.h
r21022r21023
3636   DECLARE_DRIVER_INIT(tumblep);
3737   virtual void machine_start();
3838   UINT32 screen_update_tumblep(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
39   void tumblep_patch_code(UINT16 offset);
3940};
trunk/src/mame/includes/taitosj.h
r21022r21023
1818      m_collision_reg(*this, "collision_reg"),
1919      m_kikstart_scrollram(*this, "kikstart_scroll"){ }
2020
21   typedef void (taitosj_state::*copy_layer_func_t)(bitmap_ind16 &,   
22                           const rectangle &, int, int *, rectangle *);
2123   UINT8 m_sndnmi_disable;
2224   UINT8 m_input_port_4_f0;
2325   UINT8 m_kikstart_gears[2];
r21022r21023
9597   TIMER_CALLBACK_MEMBER(taitosj_mcu_status_real_w);
9698   void init_common();
9799   void reset_common();
100   void set_pens();
101   void compute_draw_order();
102   inline int get_sprite_xy(UINT8 which, UINT8* sx, UINT8* sy);
103   inline gfx_element *get_sprite_gfx_element(UINT8 which);
104   void check_sprite_sprite_collision();
105   void calculate_sprite_areas(int *sprites_on, rectangle *sprite_areas);
106   int check_sprite_layer_bitpattern(int which, rectangle *sprite_areas);
107   void check_sprite_layer_collision(int *sprites_on, rectangle *sprite_areas);
108   void draw_layers();
109   void draw_sprites(bitmap_ind16 &bitmap);
110   void check_collision(int *sprites_on, rectangle *sprite_areas);
111   int check_sprite_sprite_bitpattern(int sx1, int sy1, int which1,int sx2, int sy2, int which2);
112   void taitosj_copy_layer(bitmap_ind16 &bitmap, const rectangle &cliprect,int which, int *sprites_on, rectangle *sprite_areas);
113   void kikstart_copy_layer(bitmap_ind16 &bitmap, const rectangle &cliprect,int which, int *sprites_on, rectangle *sprite_areas);
114   void copy_layer(bitmap_ind16 &bitmap, const rectangle &cliprect,copy_layer_func_t copy_layer_func, int which, int *sprites_on, rectangle *sprite_areas);
115   void copy_layers(bitmap_ind16 &bitmap, const rectangle &cliprect,copy_layer_func_t copy_layer_func, int *sprites_on, rectangle *sprite_areas);
116   int video_update_common(bitmap_ind16 &bitmap, const rectangle &cliprect, copy_layer_func_t copy_layer_func);
98117};
trunk/src/mame/includes/tiamc1.h
r21022r21023
3434   virtual void video_start();
3535   virtual void palette_init();
3636   UINT32 screen_update_tiamc1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
37   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3738};
3839
3940
trunk/src/mame/includes/triplhnt.h
r21022r21023
5252   virtual void palette_init();
5353   UINT32 screen_update_triplhnt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   TIMER_CALLBACK_MEMBER(triplhnt_hit_callback);
55   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
56   void triplhnt_set_collision(int code);
57   void triplhnt_update_misc(address_space &space, int offset);
5558};
5659
5760
trunk/src/mame/includes/tankbatt.h
r21022r21023
3131   virtual void palette_init();
3232   UINT32 screen_update_tankbatt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3333   INTERRUPT_GEN_MEMBER(tankbatt_interrupt);
34   void draw_bullets(bitmap_ind16 &bitmap, const rectangle &cliprect);
3435};
trunk/src/mame/includes/tutankhm.h
r21022r21023
3333   DECLARE_MACHINE_RESET(tutankhm);
3434   UINT32 screen_update_tutankhm(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
3535   INTERRUPT_GEN_MEMBER(tutankhm_interrupt);
36   void get_pens( pen_t *pens );
3637};
trunk/src/mame/includes/thief.h
r21022r21023
1#include "sound/samples.h"
2
13struct coprocessor_t {
24   UINT8 *context_ram;
35   UINT8 bank;
r21022r21023
3537   virtual void video_start();
3638   UINT32 screen_update_thief(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3739   INTERRUPT_GEN_MEMBER(thief_interrupt);
40   UINT16 fetch_image_addr( coprocessor_t &thief_coprocessor );
41   void tape_set_audio( samples_device *samples, int track, int bOn );
42   void tape_set_motor( samples_device *samples, int bOn );
3843};
trunk/src/mame/includes/thedeep.h
r21022r21023
5252   UINT32 screen_update_thedeep(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5353   INTERRUPT_GEN_MEMBER(thedeep_mcu_irq);
5454   TIMER_DEVICE_CALLBACK_MEMBER(thedeep_interrupt);
55   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
56   void thedeep_maincpu_bankswitch(UINT8 bank_trig);
5557};
trunk/src/mame/includes/twincobr.h
r21022r21023
109109   INTERRUPT_GEN_MEMBER(wardner_interrupt);
110110   void twincobr_restore_screen();
111111   void twincobr_restore_dsp();
112   void twincobr_create_tilemaps();
113   void twincobr_display(int enable);
114   void twincobr_flipscreen(int flip);
115   void wardner_sprite_priority_hack();
116   void twincobr_log_vram();
117   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
118   void twincobr_dsp(int enable);
119   void toaplan0_control_w(int offset, int data);
120   void toaplan0_coin_dsp_w(address_space &space, int offset, int data);
121   void twincobr_driver_savestate();
112122};
113123
114124
trunk/src/mame/includes/tumbleb.h
r21022r21023
11
22#include "video/decospr.h"
3#include "sound/okim6295.h"
34
4
55class tumbleb_state : public driver_device
66{
77public:
r21022r21023
109109   UINT32 screen_update_sdfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
110110   INTERRUPT_GEN_MEMBER(tumbleb2_interrupt);
111111   void tumbleb_tilemap_redraw();
112   inline void get_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base);
113   inline void get_fncywld_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base);
114   inline void pangpang_get_bg_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base );
115   inline void pangpang_get_bg2x_tile_info( tile_data &tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base );
116   void tumbleb_draw_common(bitmap_ind16 &bitmap, const rectangle &cliprect, int pf1x_offs, int pf1y_offs, int pf2x_offs, int pf2y_offs);
117   void tumbleb2_set_music_bank( int bank );
118   void tumbleb2_play_sound( okim6295_device *oki, int data );
119   void process_tumbleb2_music_command( okim6295_device *oki, int data );
120   void tumblepb_patch_code(UINT16 offset);
121   void tumblepb_gfx_rearrange(int rgn);
122   void suprtrio_decrypt_code();
123   void suprtrio_decrypt_gfx();
112124};
trunk/src/mame/includes/taito_z.h
r21022r21023
8989   TIMER_CALLBACK_MEMBER(taitoz_interrupt6);
9090   TIMER_CALLBACK_MEMBER(taitoz_cpub_interrupt5);
9191   void taitoz_postload();
92   void contcirc_draw_sprites_16x8( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs );
93   void chasehq_draw_sprites_16x16( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs );
94   void bshark_draw_sprites_16x8( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs );
95   void sci_draw_sprites_16x8( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs );
96   void aquajack_draw_sprites_16x8(bitmap_ind16 &bitmap,const rectangle &cliprect,int y_offs);
97   void spacegun_draw_sprites_16x8(bitmap_ind16 &bitmap,const rectangle &cliprect,int y_offs);
98   void parse_cpu_control(  );
99   void reset_sound_region(  );
92100};
trunk/src/mame/includes/tecmo.h
r21022r21023
4949   DECLARE_MACHINE_RESET(rygar);
5050   DECLARE_VIDEO_START(tecmo);
5151   UINT32 screen_update_tecmo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
52   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
5253};
trunk/src/mame/includes/terracre.h
r21022r21023
3737   virtual void palette_init();
3838   DECLARE_MACHINE_START(amazon);
3939   UINT32 screen_update_amazon(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
40   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
4041};
trunk/src/mame/includes/trackfld.h
r21022r21023
6969   INTERRUPT_GEN_MEMBER(vblank_irq);
7070   INTERRUPT_GEN_MEMBER(vblank_nmi);
7171   INTERRUPT_GEN_MEMBER(yieartf_timer_irq);
72   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
7273};
trunk/src/mame/includes/tank8.h
r21022r21023
6262   UINT32 screen_update_tank8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6363   void screen_eof_tank8(screen_device &screen, bool state);
6464   TIMER_CALLBACK_MEMBER(tank8_collision_callback);
65   void set_pens(colortable_t *colortable);
66   inline int get_x_pos(int n);
67   inline int get_y_pos(int n);
68   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
69   void draw_bullets(bitmap_ind16 &bitmap, const rectangle &cliprect);
70   void tank8_set_collision(int index);
6571};
6672
6773/*----------- defined in audio/tank8.c -----------*/
6874
6975DISCRETE_SOUND_EXTERN( tank8 );
70
71/*----------- defined in drivers/tank8.c -----------*/
72void tank8_set_collision(running_machine &machine, int index);
trunk/src/mame/includes/taito_l.h
r21022r21023
2121   int m_flipscreen;
2222
2323   /* misc */
24   void (*m_current_notifier[4])(running_machine &, int);
24   void (taitol_state::*m_current_notifier[4])(int);
2525   UINT8 *m_current_base[4];
2626
2727   int m_cur_rombank;
r21022r21023
123123   void screen_eof_taitol(screen_device &screen, bool state);
124124   TIMER_DEVICE_CALLBACK_MEMBER(vbl_interrupt);
125125   IRQ_CALLBACK_MEMBER(irq_callback);
126   void taitol_chardef14_m( int offset );
127   void taitol_chardef15_m( int offset );
128   void taitol_chardef16_m( int offset );
129   void taitol_chardef17_m( int offset );
130   void taitol_chardef1c_m( int offset );
131   void taitol_chardef1d_m( int offset );
132   void taitol_chardef1e_m( int offset );
133   void taitol_chardef1f_m( int offset );
134   void taitol_bg18_m( int offset );
135   void taitol_bg19_m( int offset );
136   void taitol_char1a_m( int offset );
137   void taitol_obj1b_m( int offset );
138   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
139   void palette_notifier(int addr);
140   void state_register(  );
141   void taito_machine_reset();
142   void bank_w(address_space &space, offs_t offset, UINT8 data, int banknum );
126143};
127
128/*----------- defined in video/taito_l.c -----------*/
129
130void taitol_chardef14_m(running_machine &machine, int offset);
131void taitol_chardef15_m(running_machine &machine, int offset);
132void taitol_chardef16_m(running_machine &machine, int offset);
133void taitol_chardef17_m(running_machine &machine, int offset);
134void taitol_chardef1c_m(running_machine &machine, int offset);
135void taitol_chardef1d_m(running_machine &machine, int offset);
136void taitol_chardef1e_m(running_machine &machine, int offset);
137void taitol_chardef1f_m(running_machine &machine, int offset);
138void taitol_bg18_m(running_machine &machine, int offset);
139void taitol_bg19_m(running_machine &machine, int offset);
140void taitol_char1a_m(running_machine &machine, int offset);
141void taitol_obj1b_m(running_machine &machine, int offset);
trunk/src/mame/includes/travrusa.h
r21022r21023
2525   virtual void palette_init();
2626   DECLARE_PALETTE_INIT(shtrider);
2727   UINT32 screen_update_travrusa(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
28   void set_scroll(  );
29   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
2830};
trunk/src/mame/includes/timeplt.h
r21022r21023
5252   DECLARE_VIDEO_START(chkun);
5353   UINT32 screen_update_timeplt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   INTERRUPT_GEN_MEMBER(timeplt_interrupt);
55   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5556};
trunk/src/mame/drivers/taito_l.c
r21022r21023
6565
6666static const struct
6767{
68   void (*notifier)(running_machine &, int);
68   void (taitol_state::*notifier)(int);
6969   UINT32 offset;
7070} rambank_modify_notifiers[12] =
7171{
72   { taitol_chardef14_m, 0x0000 }, // 14
73   { taitol_chardef15_m, 0x1000 }, // 15
74   { taitol_chardef16_m, 0x2000 }, // 16
75   { taitol_chardef17_m, 0x3000 }, // 17
72   { &taitol_state::taitol_chardef14_m, 0x0000 }, // 14
73   { &taitol_state::taitol_chardef15_m, 0x1000 }, // 15
74   { &taitol_state::taitol_chardef16_m, 0x2000 }, // 16
75   { &taitol_state::taitol_chardef17_m, 0x3000 }, // 17
7676
77   { taitol_bg18_m, 0x8000 },      // 18
78   { taitol_bg19_m, 0x9000 },      // 19
79   { taitol_char1a_m, 0xa000 },    // 1a
80   { taitol_obj1b_m, 0xb000 },     // 1b
77   { &taitol_state::taitol_bg18_m, 0x8000 },      // 18
78   { &taitol_state::taitol_bg19_m, 0x9000 },      // 19
79   { &taitol_state::taitol_char1a_m, 0xa000 },    // 1a
80   { &taitol_state::taitol_obj1b_m, 0xb000 },     // 1b
8181
82   { taitol_chardef1c_m, 0x4000 }, // 1c
83   { taitol_chardef1d_m, 0x5000 }, // 1d
84   { taitol_chardef1e_m, 0x6000 }, // 1e
85   { taitol_chardef1f_m, 0x7000 }, // 1f
82   { &taitol_state::taitol_chardef1c_m, 0x4000 }, // 1c
83   { &taitol_state::taitol_chardef1d_m, 0x5000 }, // 1d
84   { &taitol_state::taitol_chardef1e_m, 0x6000 }, // 1e
85   { &taitol_state::taitol_chardef1f_m, 0x7000 }, // 1f
8686};
8787
8888
89static void palette_notifier(running_machine &machine, int addr)
89void taitol_state::palette_notifier(int addr)
9090{
91   taitol_state *state = machine.driver_data<taitol_state>();
92   UINT8 *p = state->m_palette_ram + (addr & ~1);
91   UINT8 *p = m_palette_ram + (addr & ~1);
9392   UINT8 byte0 = *p++;
9493   UINT8 byte1 = *p;
9594
r21022r21023
9796
9897   if (addr > 0x200)
9998   {
100      logerror("%s:Large palette ? %03x\n", machine.describe_context(), addr);
99      logerror("%s:Large palette ? %03x\n", machine().describe_context(), addr);
101100   }
102101   else
103102   {
104103      //      r = g = b = ((addr & 0x1e) != 0)*255;
105      palette_set_color_rgb(machine, addr / 2, pal4bit(byte0), pal4bit(byte0 >> 4), pal4bit(byte1));
104      palette_set_color_rgb(machine(), addr / 2, pal4bit(byte0), pal4bit(byte0 >> 4), pal4bit(byte1));
106105   }
107106}
108107
109108static const UINT8 puzznic_mcu_reply[] = { 0x50, 0x1f, 0xb6, 0xba, 0x06, 0x03, 0x47, 0x05, 0x00 };
110109
111static void state_register( running_machine &machine )
110void taitol_state::state_register(  )
112111{
113   taitol_state *state = machine.driver_data<taitol_state>();
114112
115   state->save_item(NAME(state->m_irq_adr_table));
116   state->save_item(NAME(state->m_irq_enable));
117   state->save_item(NAME(state->m_cur_rambank));
118   state->save_item(NAME(state->m_cur_rombank));
119   state->save_item(NAME(state->m_cur_rombank2));
113   save_item(NAME(m_irq_adr_table));
114   save_item(NAME(m_irq_enable));
115   save_item(NAME(m_cur_rambank));
116   save_item(NAME(m_cur_rombank));
117   save_item(NAME(m_cur_rombank2));
120118
121   state->save_item(NAME(state->m_adpcm_pos));
122   state->save_item(NAME(state->m_adpcm_data));
123   state->save_item(NAME(state->m_trackx));
124   state->save_item(NAME(state->m_tracky));
125   state->save_item(NAME(state->m_mux_ctrl));
126   state->save_item(NAME(state->m_extport));
127   state->save_item(NAME(state->m_last_irq_level));
128   state->save_item(NAME(state->m_high));
129   state->save_item(NAME(state->m_high2));
119   save_item(NAME(m_adpcm_pos));
120   save_item(NAME(m_adpcm_data));
121   save_item(NAME(m_trackx));
122   save_item(NAME(m_tracky));
123   save_item(NAME(m_mux_ctrl));
124   save_item(NAME(m_extport));
125   save_item(NAME(m_last_irq_level));
126   save_item(NAME(m_high));
127   save_item(NAME(m_high2));
130128
131   state->save_item(NAME(state->m_mcu_pos));
132   state->save_item(NAME(state->m_mcu_reply_len));
133   state->save_item(NAME(state->m_last_data_adr));
134   state->save_item(NAME(state->m_last_data));
135   state->save_item(NAME(state->m_cur_bank));
129   save_item(NAME(m_mcu_pos));
130   save_item(NAME(m_mcu_reply_len));
131   save_item(NAME(m_last_data_adr));
132   save_item(NAME(m_last_data));
133   save_item(NAME(m_cur_bank));
136134
137   state->save_item(NAME(state->m_bankc));
138   state->save_item(NAME(state->m_horshoes_gfxbank));
139   state->save_item(NAME(state->m_cur_ctrl));
140   state->save_item(NAME(state->m_flipscreen));
135   save_item(NAME(m_bankc));
136   save_item(NAME(m_horshoes_gfxbank));
137   save_item(NAME(m_cur_ctrl));
138   save_item(NAME(m_flipscreen));
141139}
142140
143141MACHINE_START_MEMBER(taitol_state,taito_l)
r21022r21023
149147   save_item(NAME(m_palette_ram));
150148   save_item(NAME(m_empty_ram));
151149
152   state_register(machine());
150   state_register();
153151}
154152
155static void taito_machine_reset(running_machine &machine)
153void taitol_state::taito_machine_reset()
156154{
157   taitol_state *state = machine.driver_data<taitol_state>();
158155   int i;
159156
160157   for (i = 0; i < 3; i++)
161      state->m_irq_adr_table[i] = 0;
158      m_irq_adr_table[i] = 0;
162159
163   state->m_irq_enable = 0;
160   m_irq_enable = 0;
164161
165162   for (i = 0; i < 4; i++)
166163   {
167      state->m_cur_rambank[i] = 0x80;
168      state->m_current_notifier[i] = palette_notifier;
169      state->m_current_base[i] = state->m_palette_ram;
170      state->membank(bankname[i])->set_base(state->m_current_base[i]);
164      m_cur_rambank[i] = 0x80;
165      m_current_notifier[i] = &taitol_state::palette_notifier;
166      m_current_base[i] = m_palette_ram;
167      membank(bankname[i])->set_base(m_current_base[i]);
171168   }
172169
173   state->m_cur_rombank = state->m_cur_rombank2 = 0;
174   state->membank("bank1")->set_base(machine.root_device().memregion("maincpu")->base());
170   m_cur_rombank = m_cur_rombank2 = 0;
171   membank("bank1")->set_base(machine().root_device().memregion("maincpu")->base());
175172
176   machine.gfx[2]->set_source(state->m_rambanks);
173   machine().gfx[2]->set_source(m_rambanks);
177174
178   state->m_adpcm_pos = 0;
179   state->m_adpcm_data = -1;
180   state->m_trackx = state->m_tracky = 0;
181   state->m_mux_ctrl = 0;
182   state->m_extport = 0;
183   state->m_last_irq_level = 0;
184   state->m_high = 0;
185   state->m_high2 = 0;
175   m_adpcm_pos = 0;
176   m_adpcm_data = -1;
177   m_trackx = m_tracky = 0;
178   m_mux_ctrl = 0;
179   m_extport = 0;
180   m_last_irq_level = 0;
181   m_high = 0;
182   m_high2 = 0;
186183
187   state->m_mcu_reply = puzznic_mcu_reply;
184   m_mcu_reply = puzznic_mcu_reply;
188185
189   state->m_mcu_pos = state->m_mcu_reply_len = 0;
190   state->m_last_data_adr = state->m_last_data = 0;
191   state->m_cur_bank = 1;
186   m_mcu_pos = m_mcu_reply_len = 0;
187   m_last_data_adr = m_last_data = 0;
188   m_cur_bank = 1;
192189
193190   /* video related */
194   state->m_bankc[0] = state->m_bankc[1] = state->m_bankc[2] = state->m_bankc[3] = 0;
195   state->m_horshoes_gfxbank = 0;
196   state->m_cur_ctrl = 0;
197   state->m_flipscreen = 0;
191   m_bankc[0] = m_bankc[1] = m_bankc[2] = m_bankc[3] = 0;
192   m_horshoes_gfxbank = 0;
193   m_cur_ctrl = 0;
194   m_flipscreen = 0;
198195}
199196
200197
201198MACHINE_RESET_MEMBER(taitol_state,fhawk)
202199{
203   taito_machine_reset(machine());
200   taito_machine_reset();
204201   m_porte0_tag = NULL;
205202   m_porte1_tag = NULL;
206203   m_portf0_tag = NULL;
r21022r21023
209206
210207MACHINE_RESET_MEMBER(taitol_state,raimais)
211208{
212   taito_machine_reset(machine());
209   taito_machine_reset();
213210   m_porte0_tag = NULL;
214211   m_porte1_tag = NULL;
215212   m_portf0_tag = NULL;
r21022r21023
218215
219216MACHINE_RESET_MEMBER(taitol_state,champwr)
220217{
221   taito_machine_reset(machine());
218   taito_machine_reset();
222219   m_porte0_tag = NULL;
223220   m_porte1_tag = NULL;
224221   m_portf0_tag = NULL;
r21022r21023
228225
229226MACHINE_RESET_MEMBER(taitol_state,kurikint)
230227{
231   taito_machine_reset(machine());
228   taito_machine_reset();
232229   m_porte0_tag = NULL;
233230   m_porte1_tag = NULL;
234231   m_portf0_tag = NULL;
r21022r21023
237234
238235MACHINE_RESET_MEMBER(taitol_state,evilston)
239236{
240   taito_machine_reset(machine());
237   taito_machine_reset();
241238   m_porte0_tag = NULL;
242239   m_porte1_tag = NULL;
243240   m_portf0_tag = NULL;
r21022r21023
246243
247244MACHINE_RESET_MEMBER(taitol_state,puzznic)
248245{
249   taito_machine_reset(machine());
246   taito_machine_reset();
250247   m_porte0_tag = "DSWA";
251248   m_porte1_tag = "DSWB";
252249   m_portf0_tag = "IN0";
r21022r21023
255252
256253MACHINE_RESET_MEMBER(taitol_state,plotting)
257254{
258   taito_machine_reset(machine());
255   taito_machine_reset();
259256   m_porte0_tag = "DSWA";
260257   m_porte1_tag = "DSWB";
261258   m_portf0_tag = "IN0";
r21022r21023
264261
265262MACHINE_RESET_MEMBER(taitol_state,palamed)
266263{
267   taito_machine_reset(machine());
264   taito_machine_reset();
268265   m_porte0_tag = "DSWA";
269266   m_porte1_tag = NULL;
270267   m_portf0_tag = "DSWB";
r21022r21023
273270
274271MACHINE_RESET_MEMBER(taitol_state,cachat)
275272{
276   taito_machine_reset(machine());
273   taito_machine_reset();
277274   m_porte0_tag = "DSWA";
278275   m_porte1_tag = NULL;
279276   m_portf0_tag = "DSWB";
r21022r21023
282279
283280MACHINE_RESET_MEMBER(taitol_state,horshoes)
284281{
285   taito_machine_reset(machine());
282   taito_machine_reset();
286283   m_porte0_tag = "DSWA";
287284   m_porte1_tag = "DSWB";
288285   m_portf0_tag = "IN0";
r21022r21023
409406      }
410407      else if (data == 0x80)
411408      {
412         m_current_notifier[offset] = palette_notifier;
409         m_current_notifier[offset] = &taitol_state::palette_notifier;
413410         m_current_base[offset] = m_palette_ram;
414411      }
415412      else
r21022r21023
427424   return m_cur_rambank[offset];
428425}
429426
430static void bank_w(address_space &space, offs_t offset, UINT8 data, int banknum )
427void taitol_state::bank_w(address_space &space, offs_t offset, UINT8 data, int banknum )
431428{
432   taitol_state *state = space.machine().driver_data<taitol_state>();
433
434   if (state->m_current_base[banknum][offset] != data)
429   if (m_current_base[banknum][offset] != data)
435430   {
436      state->m_current_base[banknum][offset] = data;
437      if (state->m_current_notifier[banknum])
438         state->m_current_notifier[banknum](space.machine(), offset);
431      m_current_base[banknum][offset] = data;
432      if (m_current_notifier[banknum])
433         (this->*m_current_notifier[banknum])(offset);
439434   }
440435}
441436
trunk/src/mame/drivers/triplhnt.c
r21022r21023
2323}
2424
2525
26void triplhnt_set_collision(running_machine &machine, int code)
26void triplhnt_state::triplhnt_set_collision(int code)
2727{
28   triplhnt_state *state = machine.driver_data<triplhnt_state>();
29   state->m_hit_code = code;
28   m_hit_code = code;
3029
31   machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE);
30   machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
3231}
3332
3433
35static void triplhnt_update_misc(address_space &space, int offset)
34void triplhnt_state::triplhnt_update_misc(address_space &space, int offset)
3635{
37   triplhnt_state *state = space.machine().driver_data<triplhnt_state>();
3836   samples_device *samples = space.machine().device<samples_device>("samples");
3937   device_t *discrete = space.machine().device("discrete");
4038   UINT8 is_witch_hunt;
r21022r21023
5149
5250   if (offset & 1)
5351   {
54      state->m_misc_flags |= 1 << bit;
52      m_misc_flags |= 1 << bit;
5553
5654      if (bit == 5)
5755      {
58         state->m_cmos[state->m_cmos_latch] = state->m_da_latch;
56         m_cmos[m_cmos_latch] = m_da_latch;
5957      }
6058   }
6159   else
6260   {
63      state->m_misc_flags &= ~(1 << bit);
61      m_misc_flags &= ~(1 << bit);
6462   }
6563
66   state->m_sprite_zoom = (state->m_misc_flags >> 4) & 1;
67   state->m_sprite_bank = (state->m_misc_flags >> 7) & 1;
64   m_sprite_zoom = (m_misc_flags >> 4) & 1;
65   m_sprite_bank = (m_misc_flags >> 7) & 1;
6866
69   set_led_status(space.machine(), 0, state->m_misc_flags & 0x02);
67   set_led_status(space.machine(), 0, m_misc_flags & 0x02);
7068
71   coin_lockout_w(space.machine(), 0, !(state->m_misc_flags & 0x08));
72   coin_lockout_w(space.machine(), 1, !(state->m_misc_flags & 0x08));
69   coin_lockout_w(space.machine(), 0, !(m_misc_flags & 0x08));
70   coin_lockout_w(space.machine(), 1, !(m_misc_flags & 0x08));
7371
74   discrete_sound_w(discrete, space, TRIPLHNT_SCREECH_EN, state->m_misc_flags & 0x04); // screech
75   discrete_sound_w(discrete, space, TRIPLHNT_LAMP_EN, state->m_misc_flags & 0x02);    // Lamp is used to reset noise
76   discrete_sound_w(discrete, space, TRIPLHNT_BEAR_EN, state->m_misc_flags & 0x80);    // bear
72   discrete_sound_w(discrete, space, TRIPLHNT_SCREECH_EN, m_misc_flags & 0x04); // screech
73   discrete_sound_w(discrete, space, TRIPLHNT_LAMP_EN, m_misc_flags & 0x02);    // Lamp is used to reset noise
74   discrete_sound_w(discrete, space, TRIPLHNT_BEAR_EN, m_misc_flags & 0x80);    // bear
7775
7876   is_witch_hunt = space.machine().root_device().ioport("0C09")->read() == 0x40;
79   bit = ~state->m_misc_flags & 0x40;
77   bit = ~m_misc_flags & 0x40;
8078
8179   /* if we're not playing the sample yet, start it */
8280   if (!samples->playing(0))
trunk/src/mame/drivers/taitojc.c
r21022r21023
387387
388388#if DEBUG_DSP
389389
390static void debug_dsp_command(running_machine &machine)
390void taitojc_state::debug_dsp_command()
391391{
392   taitojc_state *state = machine.driver_data<taitojc_state>();
393   UINT16 *cmd = &state->m_dsp_shared_ram[0x1fc0/2];
392   UINT16 *cmd = &m_dsp_shared_ram[0x1fc0/2];
394393
395394   switch (cmd[0])
396395   {
r21022r21023
429428#endif
430429               for (i=0; i < ll; i++)
431430               {
432                  UINT16 d = state->m_dsp_shared_ram[saddr++];
431                  UINT16 d = m_dsp_shared_ram[saddr++];
433432                  if (daddr >= 0x8000 && daddr < 0x10000)
434433                  {
435                     state->m_debug_dsp_ram[daddr-0x8000] = d;
434                     m_debug_dsp_ram[daddr-0x8000] = d;
436435                  }
437436                  daddr++;
438437
r21022r21023
472471            while (!end)
473472            {
474473               int i;
475               UINT16 cmd = state->m_debug_dsp_ram[addr++];
474               UINT16 cmd = m_debug_dsp_ram[addr++];
476475               int length = cmd & 0xff;
477476
478477               if ((cmd >> 11) == 6)
r21022r21023
481480               printf("   %04X (%02X): ", cmd, cmd >> 11);
482481               for (i=0; i < length; i++)
483482               {
484                  printf("%04X ", state->m_debug_dsp_ram[addr+i]);
483                  printf("%04X ", m_debug_dsp_ram[addr+i]);
485484               }
486485               printf("\n");
487486
r21022r21023
569568
570569
571570
572static UINT8 mcu_comm_reg_r(address_space &space, int reg)
571UINT8 taitojc_state::mcu_comm_reg_r(address_space &space, int reg)
573572{
574   taitojc_state *state = space.machine().driver_data<taitojc_state>();
575573   UINT8 r = 0;
576574
577575   switch (reg)
578576   {
579577      case 0x03:
580578      {
581         r = state->m_mcu_data_main;
579         r = m_mcu_data_main;
582580         break;
583581      }
584582      case 0x04:
585583      {
586         r = state->m_mcu_comm_main | 0x14;
584         r = m_mcu_comm_main | 0x14;
587585         break;
588586      }
589587      default:
r21022r21023
596594   return r;
597595}
598596
599static void mcu_comm_reg_w(address_space &space, int reg, UINT8 data)
597void taitojc_state::mcu_comm_reg_w(address_space &space, int reg, UINT8 data)
600598{
601   taitojc_state *state = space.machine().driver_data<taitojc_state>();
602
603599   switch (reg)
604600   {
605601      case 0x00:
606602      {
607         state->m_mcu_data_hc11 = data;
608         state->m_mcu_comm_hc11 &= ~0x04;
609         state->m_mcu_comm_main &= ~0x20;
603         m_mcu_data_hc11 = data;
604         m_mcu_comm_hc11 &= ~0x04;
605         m_mcu_comm_main &= ~0x20;
610606         break;
611607      }
612608      case 0x04:
r21022r21023
996992{
997993   if (offset == 0)
998994   {
999      taitojc_clear_frame(machine());
995      taitojc_clear_frame();
1000996      m_renderer->render_polygons(machine(), m_polygon_fifo, m_polygon_fifo_ptr);
1001997
1002998      m_polygon_fifo_ptr = 0;
trunk/src/mame/drivers/toaplan2.c
r21022r21023
482482   m_main_cpu->execute().set_input_line(param, HOLD_LINE);
483483}
484484
485static void toaplan2_vblank_irq(running_machine &machine, int irq_line)
485void toaplan2_state::toaplan2_vblank_irq(int irq_line)
486486{
487   toaplan2_state *state = machine.driver_data<toaplan2_state>();
488487   // the IRQ appears to fire at line 0xe6
489   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(0xe6), timer_expired_delegate(FUNC(toaplan2_state::toaplan2_raise_irq),state), irq_line);
488   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0xe6), timer_expired_delegate(FUNC(toaplan2_state::toaplan2_raise_irq),this), irq_line);
490489}
491490
492INTERRUPT_GEN_MEMBER(toaplan2_state::toaplan2_vblank_irq1){ toaplan2_vblank_irq(machine(), 1); }
493INTERRUPT_GEN_MEMBER(toaplan2_state::toaplan2_vblank_irq2){ toaplan2_vblank_irq(machine(), 2); }
494INTERRUPT_GEN_MEMBER(toaplan2_state::toaplan2_vblank_irq4){ toaplan2_vblank_irq(machine(), 4); }
491INTERRUPT_GEN_MEMBER(toaplan2_state::toaplan2_vblank_irq1){ toaplan2_vblank_irq(1); }
492INTERRUPT_GEN_MEMBER(toaplan2_state::toaplan2_vblank_irq2){ toaplan2_vblank_irq(2); }
493INTERRUPT_GEN_MEMBER(toaplan2_state::toaplan2_vblank_irq4){ toaplan2_vblank_irq(4); }
495494
496495
497496READ16_MEMBER(toaplan2_state::video_count_r)
trunk/src/mame/drivers/tumblep.c
r21022r21023
372372/******************************************************************************/
373373
374374#if TUMBLEP_HACK
375void tumblep_patch_code(UINT16 offset)
375void ::tumblep_patch_code(UINT16 offset)
376376{
377377   /* A hack which enables all Dip Switches effects */
378   UINT16 *RAM = (UINT16 *)machine.root_device().memregion("maincpu")->base();
378   UINT16 *RAM = (UINT16 *)machine().root_device().memregion("maincpu")->base();
379379   RAM[(offset + 0)/2] = 0x0240;
380380   RAM[(offset + 2)/2] = 0xffff;   // andi.w  #$f3ff, D0
381381}
trunk/src/mame/drivers/thedeep.c
r21022r21023
187187
188188***************************************************************************/
189189
190static void thedeep_maincpu_bankswitch(running_machine &machine,UINT8 bank_trig)
190void thedeep_state::thedeep_maincpu_bankswitch(UINT8 bank_trig)
191191{
192   thedeep_state *state = machine.driver_data<thedeep_state>();
193192   UINT8 *rom;
194193   int new_rombank = bank_trig & 3;
195194
196   if (state->m_rombank == new_rombank)
195   if (m_rombank == new_rombank)
197196      return;
198   state->m_rombank = new_rombank;
199   rom = state->memregion("maincpu")->base();
200   state->membank("bank1")->set_base(rom + 0x10000 + state->m_rombank * 0x4000);
197   m_rombank = new_rombank;
198   rom = memregion("maincpu")->base();
199   membank("bank1")->set_base(rom + 0x10000 + m_rombank * 0x4000);
201200   /* there's code which falls through from the fixed ROM to bank #1, I have to */
202201   /* copy it there otherwise the CPU bank switching support will not catch it. */
203   memcpy(rom + 0x08000, rom + 0x10000 + state->m_rombank * 0x4000, 0x4000);
202   memcpy(rom + 0x08000, rom + 0x10000 + m_rombank * 0x4000, 0x4000);
204203
205204}
206205
207206WRITE8_MEMBER(thedeep_state::thedeep_p1_w)
208207{
209208   flip_screen_set((data & 1) ^ 1);
210   thedeep_maincpu_bankswitch(machine(),(data & 6) >> 1);
209   thedeep_maincpu_bankswitch((data & 6) >> 1);
211210   logerror("P1 %02x\n",data);
212211}
213212
trunk/src/mame/drivers/taito_z.c
r21022r21023
979979#include "contcirc.lh"
980980#include "dblaxle.lh"
981981
982static void parse_cpu_control( running_machine &machine )
982void taitoz_state::parse_cpu_control(  )
983983{
984984   /* bit 0 enables cpu B */
985   taitoz_state *state = machine.driver_data<taitoz_state>();
986   state->m_subcpu->set_input_line(INPUT_LINE_RESET, (state->m_cpua_ctrl & 0x1) ? CLEAR_LINE : ASSERT_LINE);
985   m_subcpu->set_input_line(INPUT_LINE_RESET, (m_cpua_ctrl & 0x1) ? CLEAR_LINE : ASSERT_LINE);
987986}
988987
989988WRITE16_MEMBER(taitoz_state::cpua_ctrl_w)
r21022r21023
994993   data &= 0xff;
995994
996995   m_cpua_ctrl = data;
997   parse_cpu_control(machine());
996   parse_cpu_control();
998997}
999998
1000999WRITE16_MEMBER(taitoz_state::chasehq_cpua_ctrl_w)
r21022r21023
14041403                        SOUND
14051404*****************************************************/
14061405
1407static void reset_sound_region( running_machine &machine )
1406void taitoz_state::reset_sound_region(  )
14081407{
1409   taitoz_state *state = machine.driver_data<taitoz_state>();
1410   state->membank("bank10")->set_entry(state->m_banknum);
1408   membank("bank10")->set_entry(m_banknum);
14111409}
14121410
14131411WRITE8_MEMBER(taitoz_state::sound_bankswitch_w)
14141412{
14151413   m_banknum = data & 7;
1416   reset_sound_region(machine());
1414   reset_sound_region();
14171415}
14181416
14191417WRITE16_MEMBER(taitoz_state::taitoz_sound_w)
r21022r21023
30273025
30283026void taitoz_state::taitoz_postload()
30293027{
3030   parse_cpu_control(machine());
3031   reset_sound_region(machine());
3028   parse_cpu_control();
3029   reset_sound_region();
30323030}
30333031
30343032MACHINE_START_MEMBER(taitoz_state,bshark)
r21022r21023
51865184
51875185DRIVER_INIT_MEMBER(taitoz_state,taitoz)
51885186{
5189   machine().save().register_postload(save_prepost_delegate(FUNC(parse_cpu_control), &machine()));
5187   machine().save().register_postload(save_prepost_delegate(FUNC(taitoz_state::parse_cpu_control), this));
51905188}
51915189
51925190DRIVER_INIT_MEMBER(taitoz_state,bshark)
trunk/src/mame/drivers/twin16.c
r21022r21023
6161
6262
6363
64int twin16_spriteram_process_enable( running_machine &machine )
64int twin16_state::twin16_spriteram_process_enable(  )
6565{
66   twin16_state *state = machine.driver_data<twin16_state>();
67   return (state->m_CPUA_register & 0x40) == 0;
66   return (m_CPUA_register & 0x40) == 0;
6867}
6968
7069/******************************************************************************************/
r21022r21023
125124         machine().device("audiocpu")->execute().set_input_line_and_vector(0, HOLD_LINE, 0xff);
126125
127126      if ((old & 0x40) && (m_CPUA_register & 0x40) == 0)
128         twin16_spriteram_process(machine());
127         twin16_spriteram_process();
129128
130129      if ((old & 0x10) == 0 && (m_CPUA_register & 0x10))
131130         machine().device("sub")->execute().set_input_line(M68K_IRQ_6, HOLD_LINE);
r21022r21023
12981297
12991298/* Driver Initialization */
13001299
1301static void gfx_untangle( running_machine &machine )
1300void twin16_state::gfx_untangle(  )
13021301{
1303   twin16_state *state = machine.driver_data<twin16_state>();
13041302   // sprite, tile data
13051303   int i;
1306   UINT16 *temp = auto_alloc_array(machine, UINT16, 0x200000/2);
1304   UINT16 *temp = auto_alloc_array(machine(), UINT16, 0x200000/2);
13071305
1308   state->m_gfx_rom = (UINT16 *)state->memregion("gfx2")->base();
1309   memcpy( temp, state->m_gfx_rom, 0x200000 );
1306   m_gfx_rom = (UINT16 *)memregion("gfx2")->base();
1307   memcpy( temp, m_gfx_rom, 0x200000 );
13101308
13111309   for( i=0; i<0x080000; i++ )
13121310   {
1313      state->m_gfx_rom[i*2+0] = temp[i+0x080000];
1314      state->m_gfx_rom[i*2+1] = temp[i];
1311      m_gfx_rom[i*2+0] = temp[i+0x080000];
1312      m_gfx_rom[i*2+1] = temp[i];
13151313   }
1316   auto_free( machine, temp );
1314   auto_free( machine(), temp );
13171315}
13181316
13191317DRIVER_INIT_MEMBER(twin16_state,twin16)
13201318{
1321   gfx_untangle(machine());
1319   gfx_untangle();
13221320   m_custom_video = 0;
13231321}
13241322
13251323DRIVER_INIT_MEMBER(twin16_state,fround)
13261324{
1327   gfx_untangle(machine());
1325   gfx_untangle();
13281326   m_custom_video = 1;
13291327}
13301328
13311329DRIVER_INIT_MEMBER(twin16_state,cuebrickj)
13321330{
1333   gfx_untangle(machine());
1331   gfx_untangle();
13341332
13351333   machine().device<nvram_device>("nvram")->set_base(m_cuebrickj_nvram, 0x400*0x20);
13361334}
trunk/src/mame/drivers/tecmosys.c
r21022r21023
628628   ROM_LOAD( "ae500w07.ad1", 0x080000, 0x080000, CRC(3734f92c) SHA1(048555b5aa89eaf983305c439ba08d32b4a1bb80) )
629629ROM_END
630630
631static void tecmosys_descramble(running_machine &machine)
631void tecmosys_state::tecmosys_descramble()
632632{
633   UINT8 *gfxsrc  = machine.root_device().memregion( "gfx1" )->base();
634   size_t srcsize = machine.root_device().memregion( "gfx1" )->bytes();
633   UINT8 *gfxsrc  = machine().root_device().memregion( "gfx1" )->base();
634   size_t srcsize = machine().root_device().memregion( "gfx1" )->bytes();
635635   int i;
636636
637637   for (i=0; i < srcsize; i+=4)
r21022r21023
652652
653653DRIVER_INIT_MEMBER(tecmosys_state,deroon)
654654{
655   tecmosys_descramble(machine());
655   tecmosys_descramble();
656656   tecmosys_prot_init(0); // machine/tecmosys.c
657657}
658658
659659DRIVER_INIT_MEMBER(tecmosys_state,tkdensho)
660660{
661   tecmosys_descramble(machine());
661   tecmosys_descramble();
662662   tecmosys_prot_init(1);
663663}
664664
665665DRIVER_INIT_MEMBER(tecmosys_state,tkdensha)
666666{
667   tecmosys_descramble(machine());
667   tecmosys_descramble();
668668   tecmosys_prot_init(2);
669669}
670670
trunk/src/mame/drivers/tmnt.c
r21022r21023
296296#if 0
297297static int sound_nmi_enabled;
298298
299static void sound_nmi_callback( int param )
299void tmnt_state::sound_nmi_callback( int param )
300300{
301   machine.device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, ( sound_nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE );
301   machine().device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, ( sound_nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE );
302302
303303   sound_nmi_enabled = 0;
304304}
r21022r21023
742742
743743
744744#if 1
745INLINE UINT32 tmnt2_get_word( running_machine &machine, UINT32 addr )
745inline UINT32 tmnt_state::tmnt2_get_word( UINT32 addr )
746746{
747   tmnt_state *state = machine.driver_data<tmnt_state>();
748747
749748   if (addr <= 0x07ffff / 2)
750      return(state->m_tmnt2_rom[addr]);
749      return(m_tmnt2_rom[addr]);
751750   else if (addr >= 0x104000 / 2 && addr <= 0x107fff / 2)
752      return(state->m_sunset_104000[addr - 0x104000 / 2]);
751      return(m_sunset_104000[addr - 0x104000 / 2]);
753752   else if (addr >= 0x180000 / 2 && addr <= 0x183fff / 2)
754      return(state->m_spriteram[addr - 0x180000 / 2]);
753      return(m_spriteram[addr - 0x180000 / 2]);
755754   return 0;
756755}
757756
758static void tmnt2_put_word( address_space &space, UINT32 addr, UINT16 data )
757void tmnt_state::tmnt2_put_word( address_space &space, UINT32 addr, UINT16 data )
759758{
760   tmnt_state *state = space.machine().driver_data<tmnt_state>();
761
762759   UINT32 offs;
763760   if (addr >= 0x180000 / 2 && addr <= 0x183fff / 2)
764761   {
765      state->m_spriteram[addr - 0x180000 / 2] = data;
762      m_spriteram[addr - 0x180000 / 2] = data;
766763      offs = addr - 0x180000 / 2;
767764      if (!(offs & 0x0031))
768765      {
769766         offs = ((offs & 0x000e) >> 1) | ((offs & 0x1fc0) >> 3);
770         k053245_word_w(state->m_k053245, space, offs, data, 0xffff);
767         k053245_word_w(m_k053245, space, offs, data, 0xffff);
771768      }
772769   }
773770   else if (addr >= 0x104000 / 2 && addr <= 0x107fff / 2)
774      state->m_sunset_104000[addr - 0x104000 / 2] = data;
771      m_sunset_104000[addr - 0x104000 / 2] = data;
775772}
776773
777774WRITE16_MEMBER(tmnt_state::tmnt2_1c0800_w)
r21022r21023
797794   zlock    = (mcu[8] & 0xff) == 0x0001;
798795
799796   for (i = 0; i < 4; i++)
800      src[i] = tmnt2_get_word(machine(), src_addr + i);
797      src[i] = tmnt2_get_word(src_addr + i);
801798   for (i = 0; i < 24; i++) mod[i] =
802      tmnt2_get_word(machine(), mod_addr + i);
799      tmnt2_get_word(mod_addr + i);
803800
804801   code = src[0];          // code
805802
trunk/src/mame/drivers/topspeed.c
r21022r21023
294294   COMBINE_DATA(&m_sharedram[offset]);
295295}
296296
297static void parse_control( running_machine &machine )   /* assumes Z80 sandwiched between 68Ks */
297void topspeed_state::parse_control(  )   /* assumes Z80 sandwiched between 68Ks */
298298{
299299   /* bit 0 enables cpu B */
300300   /* however this fails when recovering from a save state
301301      if cpu B is disabled !! */
302   topspeed_state *state = machine.driver_data<topspeed_state>();
303   state->m_subcpu->set_input_line(INPUT_LINE_RESET, (state->m_cpua_ctrl &0x1) ? CLEAR_LINE : ASSERT_LINE);
302   m_subcpu->set_input_line(INPUT_LINE_RESET, (m_cpua_ctrl &0x1) ? CLEAR_LINE : ASSERT_LINE);
304303}
305304
306305WRITE16_MEMBER(topspeed_state::cpua_ctrl_w)
r21022r21023
310309
311310   m_cpua_ctrl = data;
312311
313   parse_control(machine());
312   parse_control();
314313
315314   logerror("CPU #0 PC %06x: write %04x to cpu control\n", space.device().safe_pc(), data);
316315}
r21022r21023
407406                        SOUND
408407*****************************************************/
409408
410static void reset_sound_region( running_machine &machine )
409void topspeed_state::reset_sound_region(  )
411410{
412   topspeed_state *state = machine.driver_data<topspeed_state>();
413   state->membank("bank10")->set_entry(state->m_banknum);
411   membank("bank10")->set_entry(m_banknum);
414412}
415413
416414WRITE8_MEMBER(topspeed_state::sound_bankswitch_w)/* assumes Z80 sandwiched between 68Ks */
417415{
418416   m_banknum = data & 7;
419   reset_sound_region(machine());
417   reset_sound_region();
420418}
421419
422420WRITE8_MEMBER(topspeed_state::topspeed_tc0140syt_comm_w)
r21022r21023
674672
675673void topspeed_state::topspeed_postload()
676674{
677   parse_control(machine());
678   reset_sound_region(machine());
675   parse_control();
676   reset_sound_region();
679677}
680678
681679void topspeed_state::machine_start()
trunk/src/mame/drivers/thunderx.c
r21022r21023
178178// +3 : x (2 pixel units) of center of object
179179// +4 : y (2 pixel units) of center of object
180180
181static void run_collisions( running_machine &machine, int s0, int e0, int s1, int e1, int cm, int hm )
181void thunderx_state::run_collisions( int s0, int e0, int s1, int e1, int cm, int hm )
182182{
183   thunderx_state *state = machine.driver_data<thunderx_state>();
184183   UINT8* p0;
185184   UINT8* p1;
186185   int ii, jj;
187186
188   p0 = &state->m_pmcram[16 + 5 * s0];
187   p0 = &m_pmcram[16 + 5 * s0];
189188   for (ii = s0; ii < e0; ii++, p0 += 5)
190189   {
191190      int l0, r0, b0, t0;
r21022r21023
199198      t0 = p0[4] - p0[2];
200199      b0 = p0[4] + p0[2];
201200
202      p1 = &state->m_pmcram[16 + 5 * s1];
201      p1 = &m_pmcram[16 + 5 * s1];
203202      for (jj = s1; jj < e1; jj++,p1 += 5)
204203      {
205204         int l1,r1,b1,t1;
r21022r21023
230229//
231230// emulates K052591 collision detection
232231
233static void calculate_collisions( running_machine &machine )
232void thunderx_state::calculate_collisions(  )
234233{
235   thunderx_state *state = machine.driver_data<thunderx_state>();
236234   int X0,Y0;
237235   int X1,Y1;
238236   int CM,HM;
r21022r21023
256254   // hit mask is 40 to set bit on object 0 and object 1
257255   // hit mask is 20 to set bit on object 1 only
258256
259   Y0 = state->m_pmcram[0];
260   Y0 = (Y0 << 8) + state->m_pmcram[1];
257   Y0 = m_pmcram[0];
258   Y0 = (Y0 << 8) + m_pmcram[1];
261259   Y0 = (Y0 - 15) / 5;
262   Y1 = (state->m_pmcram[2] - 15) / 5;
260   Y1 = (m_pmcram[2] - 15) / 5;
263261
264   if (state->m_pmcram[5] < 16)
262   if (m_pmcram[5] < 16)
265263   {
266264      // US Thunder Cross uses this form
267      X0 = state->m_pmcram[5];
268      X0 = (X0 << 8) + state->m_pmcram[6];
265      X0 = m_pmcram[5];
266      X0 = (X0 << 8) + m_pmcram[6];
269267      X0 = (X0 - 16) / 5;
270      X1 = (state->m_pmcram[7] - 16) / 5;
268      X1 = (m_pmcram[7] - 16) / 5;
271269   }
272270   else
273271   {
274272      // Japan Thunder Cross uses this form
275      X0 = (state->m_pmcram[5] - 16) / 5;
276      X1 = (state->m_pmcram[6] - 16) / 5;
273      X0 = (m_pmcram[5] - 16) / 5;
274      X1 = (m_pmcram[6] - 16) / 5;
277275   }
278276
279   CM = state->m_pmcram[3];
280   HM = state->m_pmcram[4];
277   CM = m_pmcram[3];
278   HM = m_pmcram[4];
281279
282   run_collisions(machine, X0, Y0, X1, Y1, CM, HM);
280   run_collisions(X0, Y0, X1, Y1, CM, HM);
283281}
284282
285283READ8_MEMBER(thunderx_state::thunderx_1f98_r)
r21022r21023
300298   /* bit 2 = do collision detection when 0->1 */
301299   if ((data & 4) && !(m_1f98_data & 4))
302300   {
303      calculate_collisions(machine());
301      calculate_collisions();
304302
305303      /* 100 cycle delay is arbitrary */
306304      machine().scheduler().timer_set(downcast<cpu_device *>(&space.device())->cycles_to_attotime(100), timer_expired_delegate(FUNC(thunderx_state::thunderx_firq_callback),this));
trunk/src/mame/drivers/tank8.c
r21022r21023
1111
1212
1313
14void tank8_set_collision(running_machine &machine, int index)
14void tank8_state::tank8_set_collision(int index)
1515{
16   tank8_state *state = machine.driver_data<tank8_state>();
17   machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
16   machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
1817
19   state->m_collision_index = index;
18   m_collision_index = index;
2019}
2120
2221
trunk/src/mame/drivers/tigeroad.c
r21022r21023
79790x0003, 0x0080, 0x0006, 0x0060, 0x0000, 0x00e0, 0x000a, 0x00c0, 0x0003, 0x0080, 0x0006, 0x0060, 0x0000, 0x00e0, 0x000a, 0x00c0,
80800x0003, 0x0080, 0x0006, 0x0060, 0x0000, 0x00e0, 0x000a, 0x00c0, 0x0003, 0x0080, 0x0006, 0x0060, 0x0000, 0x00e0, 0x000a, 0x00c0 };
8181
82static void f1dream_protection_w(address_space &space)
82void tigeroad_state::f1dream_protection_w(address_space &space)
8383{
84   tigeroad_state *state = space.machine().driver_data<tigeroad_state>();
8584   int indx;
8685   int value = 255;
8786   int prevpc = space.device().safe_pcbase();
r21022r21023
8988   if (prevpc == 0x244c)
9089   {
9190      /* Called once, when a race is started.*/
92      indx = state->m_ram16[0x3ff0/2];
93      state->m_ram16[0x3fe6/2] = f1dream_2450_lookup[indx];
94      state->m_ram16[0x3fe8/2] = f1dream_2450_lookup[++indx];
95      state->m_ram16[0x3fea/2] = f1dream_2450_lookup[++indx];
96      state->m_ram16[0x3fec/2] = f1dream_2450_lookup[++indx];
91      indx = m_ram16[0x3ff0/2];
92      m_ram16[0x3fe6/2] = f1dream_2450_lookup[indx];
93      m_ram16[0x3fe8/2] = f1dream_2450_lookup[++indx];
94      m_ram16[0x3fea/2] = f1dream_2450_lookup[++indx];
95      m_ram16[0x3fec/2] = f1dream_2450_lookup[++indx];
9796   }
9897   else if (prevpc == 0x613a)
9998   {
10099      /* Called for every sprite on-screen.*/
101      if (state->m_ram16[0x3ff6/2] < 15)
100      if (m_ram16[0x3ff6/2] < 15)
102101      {
103         indx = f1dream_613ea_lookup[state->m_ram16[0x3ff6/2]] - state->m_ram16[0x3ff4/2];
102         indx = f1dream_613ea_lookup[m_ram16[0x3ff6/2]] - m_ram16[0x3ff4/2];
104103         if (indx > 255)
105104         {
106105            indx <<= 4;
107            indx += state->m_ram16[0x3ff6/2] & 0x00ff;
106            indx += m_ram16[0x3ff6/2] & 0x00ff;
108107            value = f1dream_613eb_lookup[indx];
109108         }
110109      }
111110
112      state->m_ram16[0x3ff2/2] = value;
111      m_ram16[0x3ff2/2] = value;
113112   }
114113   else if (prevpc == 0x17b70)
115114   {
116115      /* Called only before a real race, not a time trial.*/
117      if (state->m_ram16[0x3ff0/2] >= 0x04) indx = 128;
118      else if (state->m_ram16[0x3ff0/2] > 0x02) indx = 96;
119      else if (state->m_ram16[0x3ff0/2] == 0x02) indx = 64;
120      else if (state->m_ram16[0x3ff0/2] == 0x01) indx = 32;
116      if (m_ram16[0x3ff0/2] >= 0x04) indx = 128;
117      else if (m_ram16[0x3ff0/2] > 0x02) indx = 96;
118      else if (m_ram16[0x3ff0/2] == 0x02) indx = 64;
119      else if (m_ram16[0x3ff0/2] == 0x01) indx = 32;
121120      else indx = 0;
122121
123      indx += state->m_ram16[0x3fee/2];
122      indx += m_ram16[0x3fee/2];
124123      if (indx < 128)
125124      {
126         state->m_ram16[0x3fe6/2] = f1dream_17b74_lookup[indx];
127         state->m_ram16[0x3fe8/2] = f1dream_17b74_lookup[++indx];
128         state->m_ram16[0x3fea/2] = f1dream_17b74_lookup[++indx];
129         state->m_ram16[0x3fec/2] = f1dream_17b74_lookup[++indx];
125         m_ram16[0x3fe6/2] = f1dream_17b74_lookup[indx];
126         m_ram16[0x3fe8/2] = f1dream_17b74_lookup[++indx];
127         m_ram16[0x3fea/2] = f1dream_17b74_lookup[++indx];
128         m_ram16[0x3fec/2] = f1dream_17b74_lookup[++indx];
130129      }
131130      else
132131      {
133         state->m_ram16[0x3fe6/2] = 0x00ff;
134         state->m_ram16[0x3fe8/2] = 0x00ff;
135         state->m_ram16[0x3fea/2] = 0x00ff;
136         state->m_ram16[0x3fec/2] = 0x00ff;
132         m_ram16[0x3fe6/2] = 0x00ff;
133         m_ram16[0x3fe8/2] = 0x00ff;
134         m_ram16[0x3fea/2] = 0x00ff;
135         m_ram16[0x3fec/2] = 0x00ff;
137136      }
138137   }
139138   else if ((prevpc == 0x27f8) || (prevpc == 0x511a) || (prevpc == 0x5142) || (prevpc == 0x516a))
140139   {
141140      /* The main CPU stuffs the byte for the soundlatch into 0xfffffd.*/
142      state->soundlatch_byte_w(space,2,state->m_ram16[0x3ffc/2]);
141      soundlatch_byte_w(space,2,m_ram16[0x3ffc/2]);
143142   }
144143}
145144
trunk/src/mame/drivers/twincobr.c
r21022r21023
10811081
10821082DRIVER_INIT_MEMBER(twincobr_state,twincobr)
10831083{
1084   twincobr_driver_savestate(machine());
1084   twincobr_driver_savestate();
10851085}
10861086
10871087
trunk/src/mame/drivers/turbo.c
r21022r21023
15271527 *
15281528 *************************************/
15291529
1530static void turbo_rom_decode(running_machine &machine)
1530void turbo_state::turbo_rom_decode()
15311531{
15321532   /*
15331533    * The table is arranged this way (second half is mirror image of first)
r21022r21023
16131613      2,1,2,1  /* 0x5000-0x5fff */
16141614   };
16151615
1616   UINT8 *RAM = machine.root_device().memregion("maincpu")->base();
1616   UINT8 *RAM = machine().root_device().memregion("maincpu")->base();
16171617   int offs, i, j;
16181618   UINT8 src;
16191619
r21022r21023
16371637
16381638DRIVER_INIT_MEMBER(turbo_state,turbo_enc)
16391639{
1640   turbo_rom_decode(machine());
1640   turbo_rom_decode();
16411641}
16421642
16431643
trunk/src/mame/drivers/taito_b.c
r21022r21023
27432743MACHINE_CONFIG_END
27442744
27452745#if 0
2746static void ryujin_patch(void)
2746void taitob_state::ryujin_patch(void)
27472747{
2748   UINT16 *rom = (UINT16*)machine.root_device().memregion("maincpu")->base();
2748   UINT16 *rom = (UINT16*)machine().root_device().memregion("maincpu")->base();
27492749   rom[ 0x62/2 ] = 1;
27502750   //0 (already in rom) - Taito Corporation 1993
27512751   //1 - Taito America corp with blue FBI logo
r21022r21023
27962796MACHINE_CONFIG_END
27972797
27982798#if 0
2799static void sbm_patch(void)
2799void taitob_state::sbm_patch(void)
28002800{
2801   UINT16 *rom = (UINT16*)machine.root_device().memregion("maincpu")->base();
2801   UINT16 *rom = (UINT16*)machine().root_device().memregion("maincpu")->base();
28022802   rom[ 0x7ffff/2 ] = 2; //US version
28032803}
28042804#endif
trunk/src/mame/drivers/tceptor.c
r21022r21023
9595
9696
9797/* fix dsw/input data to memory mapped data */
98static UINT8 fix_input0(UINT8 in1, UINT8 in2)
98UINT8 tceptor_state::fix_input0(UINT8 in1, UINT8 in2)
9999{
100100   UINT8 r = 0;
101101
r21022r21023
111111   return r;
112112}
113113
114static UINT8 fix_input1(UINT8 in1, UINT8 in2)
114UINT8 tceptor_state::fix_input1(UINT8 in1, UINT8 in2)
115115{
116116   UINT8 r = 0;
117117
trunk/src/mame/drivers/toaplan1.c
r21022r21023
25152515
25162516DRIVER_INIT_MEMBER(toaplan1_state,toaplan1)
25172517{
2518   toaplan1_driver_savestate(machine());
2518   toaplan1_driver_savestate();
25192519}
25202520
25212521DRIVER_INIT_MEMBER(toaplan1_state,demonwld)
25222522{
2523   toaplan1_driver_savestate(machine());
2524   demonwld_driver_savestate(machine());
2523   toaplan1_driver_savestate();
2524   demonwld_driver_savestate();
25252525}
25262526
25272527DRIVER_INIT_MEMBER(toaplan1_state,vimana)
25282528{
2529   toaplan1_driver_savestate(machine());
2530   vimana_driver_savestate(machine());
2529   toaplan1_driver_savestate();
2530   vimana_driver_savestate();
25312531}
25322532
25332533
trunk/src/mame/drivers/tubep.c
r21022r21023
283283   if (scanline == 16)
284284   {
285285      logerror("/nmi CPU#3\n");
286      tubep_vblank_end(machine()); /* switch buffered sprite RAM page */
286      tubep_vblank_end(); /* switch buffered sprite RAM page */
287287      machine().device("mcu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
288288   }
289289   /* CPU #3 MS2010-A NMI */
r21022r21023
323323 *
324324 *************************************/
325325
326static void tubep_setup_save_state(running_machine &machine)
326void tubep_state::tubep_setup_save_state()
327327{
328   tubep_state *state = machine.driver_data<tubep_state>();
329328   /* Set up save state */
330   state_save_register_global(machine, state->m_sound_latch);
331   state_save_register_global(machine, state->m_ls74);
332   state_save_register_global(machine, state->m_ls377);
329   state_save_register_global(machine(), m_sound_latch);
330   state_save_register_global(machine(), m_ls74);
331   state_save_register_global(machine(), m_ls377);
333332}
334333
335334
r21022r21023
339338   /* Create interrupt timer */
340339   m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tubep_state::tubep_scanline_callback),this));
341340
342   tubep_setup_save_state(machine());
341   tubep_setup_save_state();
343342}
344343
345344
r21022r21023
465464   if (scanline == 16)
466465   {
467466      logerror("/nmi CPU#3\n");
468      tubep_vblank_end(machine()); /* switch buffered sprite RAM page */
467      tubep_vblank_end(); /* switch buffered sprite RAM page */
469468      machine().device("mcu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
470469   }
471470   /* CPU #3 MS2010-A NMI */
r21022r21023
502501   /* Create interrupt timer */
503502   m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tubep_state::rjammer_scanline_callback),this));
504503
505   tubep_setup_save_state(machine());
504   tubep_setup_save_state();
506505}
507506
508507MACHINE_RESET_MEMBER(tubep_state,rjammer)
trunk/src/mame/drivers/tetrisp2.c
r21022r21023
12681268   machine().device("sub")->execute().set_input_line(1, HOLD_LINE);
12691269}
12701270
1271static void init_rockn_timer(running_machine &machine)
1271void tetrisp2_state::init_rockn_timer()
12721272{
1273   tetrisp2_state *state = machine.driver_data<tetrisp2_state>();
1274   machine.scheduler().timer_pulse(attotime::from_msec(32), timer_expired_delegate(FUNC(tetrisp2_state::rockn_timer_level1_callback),state));
1275   state->m_rockn_timer_l4 = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(tetrisp2_state::rockn_timer_level4_callback),state));
1273   machine().scheduler().timer_pulse(attotime::from_msec(32), timer_expired_delegate(FUNC(tetrisp2_state::rockn_timer_level1_callback),this));
1274   m_rockn_timer_l4 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tetrisp2_state::rockn_timer_level4_callback),this));
12761275
1277   state_save_register_global_array(machine, state->m_systemregs);
1278   state_save_register_global_array(machine, state->m_rocknms_sub_systemregs);
1279   state_save_register_global(machine, state->m_rockn_protectdata);
1280   state_save_register_global(machine, state->m_rockn_adpcmbank);
1281   state_save_register_global(machine, state->m_rockn_soundvolume);
1276   state_save_register_global_array(machine(), m_systemregs);
1277   state_save_register_global_array(machine(), m_rocknms_sub_systemregs);
1278   state_save_register_global(machine(), m_rockn_protectdata);
1279   state_save_register_global(machine(), m_rockn_adpcmbank);
1280   state_save_register_global(machine(), m_rockn_soundvolume);
12821281}
12831282
12841283DRIVER_INIT_MEMBER(tetrisp2_state,rockn)
12851284{
1286   init_rockn_timer(machine());
1285   init_rockn_timer();
12871286   m_rockn_protectdata = 1;
12881287}
12891288
12901289DRIVER_INIT_MEMBER(tetrisp2_state,rockn1)
12911290{
1292   init_rockn_timer(machine());
1291   init_rockn_timer();
12931292   m_rockn_protectdata = 1;
12941293}
12951294
12961295DRIVER_INIT_MEMBER(tetrisp2_state,rockn2)
12971296{
1298   init_rockn_timer(machine());
1297   init_rockn_timer();
12991298   m_rockn_protectdata = 2;
13001299}
13011300
13021301DRIVER_INIT_MEMBER(tetrisp2_state,rocknms)
13031302{
1304   init_rockn_timer(machine());
1303   init_rockn_timer();
13051304
13061305   machine().scheduler().timer_pulse(attotime::from_msec(32), timer_expired_delegate(FUNC(tetrisp2_state::rockn_timer_sub_level1_callback),this));
13071306   m_rockn_timer_sub_l4 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tetrisp2_state::rockn_timer_sub_level4_callback),this));
r21022r21023
13121311
13131312DRIVER_INIT_MEMBER(tetrisp2_state,rockn3)
13141313{
1315   init_rockn_timer(machine());
1314   init_rockn_timer();
13161315   m_rockn_protectdata = 4;
13171316}
13181317
13191318DRIVER_INIT_MEMBER(stepstag_state,stepstag)
13201319{
1321   init_rockn_timer(machine());        // used
1320   init_rockn_timer();        // used
13221321   m_rockn_protectdata = 1;    // unused?
13231322}
13241323
trunk/src/mame/drivers/wardner.c
r21022r21023
597597DRIVER_INIT_MEMBER(wardner_state,wardner)
598598{
599599   m_ROM = machine().root_device().memregion("maincpu")->base();
600   twincobr_driver_savestate(machine());   /* Save-State stuff in src/machine/twincobr.c */
600   twincobr_driver_savestate();   /* Save-State stuff in src/machine/twincobr.c */
601601}
602602
603603
trunk/src/mame/drivers/tumbleb.c
r21022r21023
466466};
467467
468468/* we use channels 1,2,3 for sound effects, and channel 4 for music */
469static void tumbleb2_set_music_bank( running_machine &machine, int bank )
469void tumbleb_state::tumbleb2_set_music_bank( int bank )
470470{
471   UINT8 *oki = machine.root_device().memregion("oki")->base();
471   UINT8 *oki = machine().root_device().memregion("oki")->base();
472472   memcpy(&oki[0x38000], &oki[0x80000 + 0x38000 + 0x8000 * bank], 0x8000);
473473}
474474
475static void tumbleb2_play_sound( okim6295_device *oki, int data )
475void tumbleb_state::tumbleb2_play_sound( okim6295_device *oki, int data )
476476{
477477   int status = oki->read_status();
478478
r21022r21023
505505// bank 7 = how to play?
506506// bank 8 = boss???
507507
508static void process_tumbleb2_music_command( okim6295_device *oki, int data )
508void tumbleb_state::process_tumbleb2_music_command( okim6295_device *oki, int data )
509509{
510   tumbleb_state *state = oki->machine().driver_data<tumbleb_state>();
511510   int status = oki->read_status();
512511
513512   if (data == 1) // stop?
r21022r21023
515514      if (BIT(status, 3))
516515      {
517516         oki->write_command(0x40);       /* Stop playing music */
518         state->m_music_is_playing = 0;
517         m_music_is_playing = 0;
519518      }
520519   }
521520   else
522521   {
523      if (state->m_music_is_playing != data)
522      if (m_music_is_playing != data)
524523      {
525         state->m_music_is_playing = data;
524         m_music_is_playing = data;
526525         oki->write_command(0x40); // stop the current music
527526         switch (data)
528527         {
529528            case 0x04: // map screen
530               state->m_music_bank = 1;
531               state->m_music_command = 0x38;
529               m_music_bank = 1;
530               m_music_command = 0x38;
532531               break;
533532
534533            case 0x05: // america
535               state->m_music_bank = 6;
536               state->m_music_command = 0x38;
534               m_music_bank = 6;
535               m_music_command = 0x38;
537536               break;
538537
539538            case 0x06: // asia
540               state->m_music_bank = 2;
541               state->m_music_command = 0x38;
539               m_music_bank = 2;
540               m_music_command = 0x38;
542541               break;
543542
544543            case 0x07: // africa/egypt -- don't seem to have a tune for this one
545               state->m_music_bank = 4;
546               state->m_music_command = 0x38;
544               m_music_bank = 4;
545               m_music_command = 0x38;
547546               break;
548547
549548            case 0x08: // antartica
550               state->m_music_bank = 3;
551               state->m_music_command = 0x38;
549               m_music_bank = 3;
550               m_music_command = 0x38;
552551               break;
553552
554553            case 0x09: // brazil / south america
555               state->m_music_bank = 4;
556               state->m_music_command = 0x38;
554               m_music_bank = 4;
555               m_music_command = 0x38;
557556               break;
558557
559558            case 0x0a: // japan -- don't seem to have a tune
560               state->m_music_bank = 2;
561               state->m_music_command = 0x38;
559               m_music_bank = 2;
560               m_music_command = 0x38;
562561               break;
563562
564563            case 0x0b: // australia
565               state->m_music_bank = 5;
566               state->m_music_command = 0x38;
564               m_music_bank = 5;
565               m_music_command = 0x38;
567566               break;
568567
569568            case 0x0c: // france/europe
570               state->m_music_bank = 6;
571               state->m_music_command = 0x38;
569               m_music_bank = 6;
570               m_music_command = 0x38;
572571               break;
573572
574573            case 0x0d: // how to play
575               state->m_music_bank = 7;
576               state->m_music_command = 0x38;
574               m_music_bank = 7;
575               m_music_command = 0x38;
577576               break;
578577
579578            case 0x0f: // stage clear
580               state->m_music_bank = 0;
581               state->m_music_command = 0x33;
579               m_music_bank = 0;
580               m_music_command = 0x33;
582581               break;
583582
584583            case 0x10: // boss stage
585               state->m_music_bank = 8;
586               state->m_music_command = 0x38;
584               m_music_bank = 8;
585               m_music_command = 0x38;
587586               break;
588587
589588            case 0x12: // world clear
590               state->m_music_bank = 0;
591               state->m_music_command = 0x34;
589               m_music_bank = 0;
590               m_music_command = 0x34;
592591               break;
593592
594593            default: // anything else..
595               state->m_music_bank = 8;
596               state->m_music_command = 0x38;
594               m_music_bank = 8;
595               m_music_command = 0x38;
597596               break;
598597         }
599598
600         tumbleb2_set_music_bank(oki->machine(), state->m_music_bank);
599         tumbleb2_set_music_bank(m_music_bank);
601600         tumbleb2_playmusic(oki);
602601      }
603602   }
r21022r21023
31923191/******************************************************************************/
31933192
31943193#if TUMBLEP_HACK
3195void tumblepb_patch_code(running_machine &machine, UINT16 offset)
3194void tumbleb_state::tumblepb_patch_code(UINT16 offset)
31963195{
31973196   /* A hack which enables all Dip Switches effects */
3198   UINT16 *RAM = (UINT16 *)machine.root_device().memregion("maincpu")->base();
3197   UINT16 *RAM = (UINT16 *)machine().root_device().memregion("maincpu")->base();
31993198   RAM[(offset + 0)/2] = 0x0240;
32003199   RAM[(offset + 2)/2] = 0xffff;   // andi.w  #$f3ff, D0
32013200}
32023201#endif
32033202
32043203
3205static void tumblepb_gfx_rearrange(running_machine &machine, int rgn)
3204void tumbleb_state::tumblepb_gfx_rearrange(int rgn)
32063205{
32073206   UINT8* rom;
32083207   int len;
32093208
32103209   if (rgn == 1)
32113210   {
3212      rom = machine.root_device().memregion("tilegfx")->base();
3213      len = machine.root_device().memregion("tilegfx")->bytes();
3211      rom = machine().root_device().memregion("tilegfx")->base();
3212      len = machine().root_device().memregion("tilegfx")->bytes();
32143213   }
32153214   else
32163215   {
3217      rom = machine.root_device().memregion("sprgfx")->base();
3218      len = machine.root_device().memregion("sprgfx")->bytes();
3216      rom = machine().root_device().memregion("sprgfx")->base();
3217      len = machine().root_device().memregion("sprgfx")->bytes();
32193218   }
32203219
32213220   int i;
r21022r21023
32373236
32383237DRIVER_INIT_MEMBER(tumbleb_state,tumblepb)
32393238{
3240   tumblepb_gfx_rearrange(machine(), 1);
3239   tumblepb_gfx_rearrange(1);
32413240
32423241   #if TUMBLEP_HACK
3243   tumblepb_patch_code(machine(), 0x000132);
3242   tumblepb_patch_code(0x000132);
32443243   #endif
32453244}
32463245
32473246DRIVER_INIT_MEMBER(tumbleb_state,tumblepba)
32483247{
32493248   // rearrange the bg data instead of the sprite data on this one!
3250   tumblepb_gfx_rearrange(machine(), 2);
3249   tumblepb_gfx_rearrange(2);
32513250}
32523251
32533252DRIVER_INIT_MEMBER(tumbleb_state,tumbleb2)
32543253{
3255   tumblepb_gfx_rearrange(machine(), 1);
3254   tumblepb_gfx_rearrange(1);
32563255
32573256   #if TUMBLEP_HACK
3258   tumblepb_patch_code(machine(), 0x000132);
3257   tumblepb_patch_code(0x000132);
32593258   #endif
32603259   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x100000, 0x100001, write16_delegate(FUNC(tumbleb_state::tumbleb2_soundmcu_w),this));
32613260
r21022r21023
32633262
32643263DRIVER_INIT_MEMBER(tumbleb_state,jumpkids)
32653264{
3266   tumblepb_gfx_rearrange(machine(), 1);
3265   tumblepb_gfx_rearrange(1);
32673266
32683267   #if TUMBLEP_HACK
3269   tumblepb_patch_code(machine(), 0x00013a);
3268   tumblepb_patch_code(0x00013a);
32703269   #endif
32713270}
32723271
32733272DRIVER_INIT_MEMBER(tumbleb_state,fncywld)
32743273{
3275   tumblepb_gfx_rearrange(machine(), 1);
3274   tumblepb_gfx_rearrange(1);
32763275
32773276   #if FNCYWLD_HACK
32783277   /* This is a hack to allow you to use the extra features
r21022r21023
32943293
32953294DRIVER_INIT_MEMBER(tumbleb_state,bcstory)
32963295{
3297   tumblepb_gfx_rearrange(machine(), 1);
3296   tumblepb_gfx_rearrange(1);
32983297   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x180008, 0x180009, read16_delegate(FUNC(tumbleb_state::bcstory_1a0_read),this)); // io should be here??
32993298}
33003299
r21022r21023
33083307   for (i = 0; i < len / 2; i++)
33093308      m_mainram[0x000/2 + i] = PROTDATA[i];
33103309
3311   tumblepb_gfx_rearrange(machine(), 1);
3310   tumblepb_gfx_rearrange(1);
33123311
33133312}
33143313
33153314
3316static void suprtrio_decrypt_code(running_machine &machine)
3315void tumbleb_state::suprtrio_decrypt_code()
33173316{
3318   UINT16 *rom = (UINT16 *)machine.root_device().memregion("maincpu")->base();
3319   UINT16 *buf = auto_alloc_array(machine, UINT16, 0x80000/2);
3317   UINT16 *rom = (UINT16 *)machine().root_device().memregion("maincpu")->base();
3318   UINT16 *buf = auto_alloc_array(machine(), UINT16, 0x80000/2);
33203319   int i;
33213320
33223321   /* decrypt main ROMs */
r21022r21023
33283327      if ((i & 3) == 0) j ^= 0x08;
33293328      rom[i] = buf[j];
33303329   }
3331   auto_free(machine, buf);
3330   auto_free(machine(), buf);
33323331}
33333332
3334static void suprtrio_decrypt_gfx(running_machine &machine)
3333void tumbleb_state::suprtrio_decrypt_gfx()
33353334{
3336   UINT16 *rom = (UINT16 *)machine.root_device().memregion("tilegfx")->base();
3337   UINT16 *buf = auto_alloc_array(machine, UINT16, 0x100000/2);
3335   UINT16 *rom = (UINT16 *)machine().root_device().memregion("tilegfx")->base();
3336   UINT16 *buf = auto_alloc_array(machine(), UINT16, 0x100000/2);
33383337   int i;
33393338
33403339   /* decrypt tiles */
r21022r21023
33453344      if (i & 1) j ^= 0x04;
33463345      rom[i] = buf[j];
33473346   }
3348   auto_free(machine, buf);
3347   auto_free(machine(), buf);
33493348}
33503349
33513350DRIVER_INIT_MEMBER(tumbleb_state,suprtrio)
33523351{
3353   suprtrio_decrypt_code(machine());
3354   suprtrio_decrypt_gfx(machine());
3352   suprtrio_decrypt_code();
3353   suprtrio_decrypt_gfx();
33553354}
33563355
33573356DRIVER_INIT_MEMBER(tumbleb_state,chokchok)
r21022r21023
33673366
33683367DRIVER_INIT_MEMBER(tumbleb_state,wlstar)
33693368{
3370   tumblepb_gfx_rearrange(machine(), 1);
3369   tumblepb_gfx_rearrange(1);
33713370
33723371   /* slightly different banking */
33733372   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x100002, 0x100003, write16_delegate(FUNC(tumbleb_state::wlstar_tilebank_w),this));
r21022r21023
33833382
33843383DRIVER_INIT_MEMBER(tumbleb_state,dquizgo)
33853384{
3386   tumblepb_gfx_rearrange(machine(), 1);
3385   tumblepb_gfx_rearrange(1);
33873386}
33883387
33893388
trunk/src/mame/drivers/thief.c
r21022r21023
5959   kTalkTrack, kCrashTrack
6060};
6161
62static void tape_set_audio( samples_device *samples, int track, int bOn )
62void thief_state::tape_set_audio( samples_device *samples, int track, int bOn )
6363{
6464   samples->set_volume(track, bOn ? 1.0 : 0.0 );
6565}
6666
67static void tape_set_motor( samples_device *samples, int bOn )
67void thief_state::tape_set_motor( samples_device *samples, int bOn )
6868{
6969   if( bOn )
7070   {
trunk/src/mame/machine/toaplan1.c
r21022r21023
128128}
129129
130130
131static void demonwld_dsp(running_machine &machine, int enable)
131void toaplan1_state::demonwld_dsp(int enable)
132132{
133   toaplan1_state *state = machine.driver_data<toaplan1_state>();
134133
135   state->m_dsp_on = enable;
134   m_dsp_on = enable;
136135   if (enable)
137136   {
138137      logerror("Turning DSP on and 68000 off\n");
139      machine.device("dsp")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
140      machine.device("dsp")->execute().set_input_line(0, ASSERT_LINE); /* TMS32010 INT */
141      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
138      machine().device("dsp")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
139      machine().device("dsp")->execute().set_input_line(0, ASSERT_LINE); /* TMS32010 INT */
140      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
142141   }
143142   else
144143   {
145144      logerror("Turning DSP off\n");
146      machine.device("dsp")->execute().set_input_line(0, CLEAR_LINE); /* TMS32010 INT */
147      machine.device("dsp")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
145      machine().device("dsp")->execute().set_input_line(0, CLEAR_LINE); /* TMS32010 INT */
146      machine().device("dsp")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
148147   }
149148}
150149
151150void toaplan1_state::demonwld_restore_dsp()
152151{
153   demonwld_dsp(machine(), m_dsp_on);
152   demonwld_dsp(m_dsp_on);
154153}
155154
156155WRITE16_MEMBER(toaplan1_state::demonwld_dsp_ctrl_w)
r21022r21023
163162   {
164163      switch (data)
165164      {
166         case 0x00:  demonwld_dsp(machine(), 1); break;  /* Enable the INT line to the DSP */
167         case 0x01:  demonwld_dsp(machine(), 0); break;  /* Inhibit the INT line to the DSP */
165         case 0x00:  demonwld_dsp(1); break;  /* Enable the INT line to the DSP */
166         case 0x01:  demonwld_dsp(0); break;  /* Inhibit the INT line to the DSP */
168167         default:    logerror("68000:%04x  Writing unknown command %08x to %08x\n",space.device().safe_pcbase() ,data ,0xe0000a + offset); break;
169168      }
170169   }
r21022r21023
380379   coin_lockout_global_w(machine(), 0);
381380}
382381
383void toaplan1_driver_savestate(running_machine &machine)
382void toaplan1_state::toaplan1_driver_savestate()
384383{
385   toaplan1_state *state = machine.driver_data<toaplan1_state>();
386384
387   state->save_item(NAME(state->m_intenable));
388   state->save_item(NAME(state->m_coin_count));
389   state->save_item(NAME(state->m_unk_reset_port));
385   save_item(NAME(m_intenable));
386   save_item(NAME(m_coin_count));
387   save_item(NAME(m_unk_reset_port));
390388}
391389
392390MACHINE_RESET_MEMBER(toaplan1_state,zerowing)/* Hack for ZeroWing and OutZone. See the video driver */
r21022r21023
403401   m_dsp_execute = 0;
404402}
405403
406void demonwld_driver_savestate(running_machine &machine)
404void toaplan1_state::demonwld_driver_savestate()
407405{
408   toaplan1_state *state = machine.driver_data<toaplan1_state>();
409406
410   state->save_item(NAME(state->m_dsp_on));
411   state->save_item(NAME(state->m_dsp_addr_w));
412   state->save_item(NAME(state->m_main_ram_seg));
413   state->save_item(NAME(state->m_dsp_BIO));
414   state->save_item(NAME(state->m_dsp_execute));
415   machine.save().register_postload(save_prepost_delegate(FUNC(toaplan1_state::demonwld_restore_dsp), state));
407   save_item(NAME(m_dsp_on));
408   save_item(NAME(m_dsp_addr_w));
409   save_item(NAME(m_main_ram_seg));
410   save_item(NAME(m_dsp_BIO));
411   save_item(NAME(m_dsp_execute));
412   machine().save().register_postload(save_prepost_delegate(FUNC(toaplan1_state::demonwld_restore_dsp), this));
416413}
417414
418415MACHINE_RESET_MEMBER(toaplan1_state,vimana)
r21022r21023
423420   m_vimana_latch = 0;
424421}
425422
426void vimana_driver_savestate(running_machine &machine)
423void toaplan1_state::vimana_driver_savestate()
427424{
428   toaplan1_state *state = machine.driver_data<toaplan1_state>();
429425
430   state->save_item(NAME(state->m_vimana_coins[0]));
431   state->save_item(NAME(state->m_vimana_coins[1]));
432   state->save_item(NAME(state->m_vimana_credits));
433   state->save_item(NAME(state->m_vimana_latch));
426   save_item(NAME(m_vimana_coins[0]));
427   save_item(NAME(m_vimana_coins[1]));
428   save_item(NAME(m_vimana_credits));
429   save_item(NAME(m_vimana_latch));
434430}
trunk/src/mame/machine/tnzs.c
r21022r21023
117117}
118118
119119
120static void mcu_reset( running_machine &machine )
120void tnzs_state::mcu_reset(  )
121121{
122   tnzs_state *state = machine.driver_data<tnzs_state>();
123122
124   state->m_mcu_initializing = 3;
125   state->m_mcu_coinage_init = 0;
126   state->m_mcu_coinage[0] = 1;
127   state->m_mcu_coinage[1] = 1;
128   state->m_mcu_coinage[2] = 1;
129   state->m_mcu_coinage[3] = 1;
130   state->m_mcu_coins_a = 0;
131   state->m_mcu_coins_b = 0;
132   state->m_mcu_credits = 0;
133   state->m_mcu_reportcoin = 0;
134   state->m_mcu_command = 0;
123   m_mcu_initializing = 3;
124   m_mcu_coinage_init = 0;
125   m_mcu_coinage[0] = 1;
126   m_mcu_coinage[1] = 1;
127   m_mcu_coinage[2] = 1;
128   m_mcu_coinage[3] = 1;
129   m_mcu_coins_a = 0;
130   m_mcu_coins_b = 0;
131   m_mcu_credits = 0;
132   m_mcu_reportcoin = 0;
133   m_mcu_command = 0;
135134}
136135
137static void mcu_handle_coins( running_machine &machine, int coin )
136void tnzs_state::mcu_handle_coins( int coin )
138137{
139   tnzs_state *state = machine.driver_data<tnzs_state>();
140138
141139   /* The coin inputs and coin counters are managed by the i8742 mcu. */
142140   /* Here we simulate it. */
r21022r21023
144142   /* Coin/Play settings must also be taken into consideration */
145143
146144   if (coin & 0x08)    /* tilt */
147      state->m_mcu_reportcoin = coin;
148   else if (coin && coin != state->m_insertcoin)
145      m_mcu_reportcoin = coin;
146   else if (coin && coin != m_insertcoin)
149147   {
150148      if (coin & 0x01)    /* coin A */
151149      {
152150//          logerror("Coin dropped into slot A\n");
153         coin_counter_w(machine,0,1); coin_counter_w(machine,0,0); /* Count slot A */
154         state->m_mcu_coins_a++;
155         if (state->m_mcu_coins_a >= state->m_mcu_coinage[0])
151         coin_counter_w(machine(),0,1); coin_counter_w(machine(),0,0); /* Count slot A */
152         m_mcu_coins_a++;
153         if (m_mcu_coins_a >= m_mcu_coinage[0])
156154         {
157            state->m_mcu_coins_a -= state->m_mcu_coinage[0];
158            state->m_mcu_credits += state->m_mcu_coinage[1];
159            if (state->m_mcu_credits >= 9)
155            m_mcu_coins_a -= m_mcu_coinage[0];
156            m_mcu_credits += m_mcu_coinage[1];
157            if (m_mcu_credits >= 9)
160158            {
161               state->m_mcu_credits = 9;
162               coin_lockout_global_w(machine, 1); /* Lock all coin slots */
159               m_mcu_credits = 9;
160               coin_lockout_global_w(machine(), 1); /* Lock all coin slots */
163161            }
164162            else
165163            {
166               coin_lockout_global_w(machine, 0); /* Unlock all coin slots */
164               coin_lockout_global_w(machine(), 0); /* Unlock all coin slots */
167165            }
168166         }
169167      }
r21022r21023
171169      if (coin & 0x02)    /* coin B */
172170      {
173171//          logerror("Coin dropped into slot B\n");
174         coin_counter_w(machine,1,1); coin_counter_w(machine,1,0); /* Count slot B */
175         state->m_mcu_coins_b++;
176         if (state->m_mcu_coins_b >= state->m_mcu_coinage[2])
172         coin_counter_w(machine(),1,1); coin_counter_w(machine(),1,0); /* Count slot B */
173         m_mcu_coins_b++;
174         if (m_mcu_coins_b >= m_mcu_coinage[2])
177175         {
178            state->m_mcu_coins_b -= state->m_mcu_coinage[2];
179            state->m_mcu_credits += state->m_mcu_coinage[3];
180            if (state->m_mcu_credits >= 9)
176            m_mcu_coins_b -= m_mcu_coinage[2];
177            m_mcu_credits += m_mcu_coinage[3];
178            if (m_mcu_credits >= 9)
181179            {
182               state->m_mcu_credits = 9;
183               coin_lockout_global_w(machine, 1); /* Lock all coin slots */
180               m_mcu_credits = 9;
181               coin_lockout_global_w(machine(), 1); /* Lock all coin slots */
184182            }
185183            else
186184            {
187               coin_lockout_global_w(machine, 0); /* Unlock all coin slots */
185               coin_lockout_global_w(machine(), 0); /* Unlock all coin slots */
188186            }
189187         }
190188      }
r21022r21023
192190      if (coin & 0x04)    /* service */
193191      {
194192//          logerror("Coin dropped into service slot C\n");
195         state->m_mcu_credits++;
193         m_mcu_credits++;
196194      }
197195
198      state->m_mcu_reportcoin = coin;
196      m_mcu_reportcoin = coin;
199197   }
200198   else
201199   {
202      if (state->m_mcu_credits < 9)
203         coin_lockout_global_w(machine, 0); /* Unlock all coin slots */
200      if (m_mcu_credits < 9)
201         coin_lockout_global_w(machine(), 0); /* Unlock all coin slots */
204202
205      state->m_mcu_reportcoin = 0;
203      m_mcu_reportcoin = 0;
206204   }
207   state->m_insertcoin = coin;
205   m_insertcoin = coin;
208206}
209207
210208
r21022r21023
629627         coin |= ((ioport("COIN2")->read() & 1) << 1);
630628         coin |= ((ioport("IN2")->read() & 3) << 2);
631629         coin ^= 0x0c;
632         mcu_handle_coins(machine(), coin);
630         mcu_handle_coins(coin);
633631         break;
634632      default:
635633         break;
r21022r21023
647645      case MCU_EXTRMATN:
648646      case MCU_DRTOPPEL:
649647      case MCU_PLUMPOP:
650         mcu_reset(machine());
648         mcu_reset();
651649         break;
652650      default:
653651         break;
r21022r21023
772770      case MCU_PLUMPOP:
773771            /* bit 2 resets the mcu */
774772            if (data & 0x04)
775               mcu_reset(machine());
773               mcu_reset();
776774            break;
777775      default:
778776            break;
trunk/src/mame/machine/twincobr.c
r21022r21023
174174}
175175
176176
177static void twincobr_dsp(running_machine &machine, int enable)
177void twincobr_state::twincobr_dsp(int enable)
178178{
179   twincobr_state *state = machine.driver_data<twincobr_state>();
180   state->m_dsp_on = enable;
179   m_dsp_on = enable;
181180   if (enable) {
182181      LOG(("Turning DSP on and main CPU off\n"));
183      machine.device("dsp")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
184      machine.device("dsp")->execute().set_input_line(0, ASSERT_LINE); /* TMS32010 INT */
185      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
182      machine().device("dsp")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
183      machine().device("dsp")->execute().set_input_line(0, ASSERT_LINE); /* TMS32010 INT */
184      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
186185   }
187186   else {
188187      LOG(("Turning DSP off\n"));
189      machine.device("dsp")->execute().set_input_line(0, CLEAR_LINE); /* TMS32010 INT */
190      machine.device("dsp")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
188      machine().device("dsp")->execute().set_input_line(0, CLEAR_LINE); /* TMS32010 INT */
189      machine().device("dsp")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
191190   }
192191}
193192
194193void twincobr_state::twincobr_restore_dsp()
195194{
196   twincobr_dsp(machine(), m_dsp_on);
195   twincobr_dsp(m_dsp_on);
197196}
198197
199198
200static void toaplan0_control_w(running_machine &machine, int offset, int data)
199void twincobr_state::toaplan0_control_w(int offset, int data)
201200{
202   twincobr_state *state = machine.driver_data<twincobr_state>();
203   LOG(("%s:Writing %08x to %08x.\n",machine.describe_context(),data,toaplan_port_type[state->m_toaplan_main_cpu] - offset));
201   LOG(("%s:Writing %08x to %08x.\n",machine().describe_context(),data,toaplan_port_type[m_toaplan_main_cpu] - offset));
204202
205   if (state->m_toaplan_main_cpu == 1) {
206      if (data == 0x0c) { data = 0x1c; state->m_wardner_sprite_hack=0; }  /* Z80 ? */
207      if (data == 0x0d) { data = 0x1d; state->m_wardner_sprite_hack=1; }  /* Z80 ? */
203   if (m_toaplan_main_cpu == 1) {
204      if (data == 0x0c) { data = 0x1c; m_wardner_sprite_hack=0; }  /* Z80 ? */
205      if (data == 0x0d) { data = 0x1d; m_wardner_sprite_hack=1; }  /* Z80 ? */
208206   }
209207
210208   switch (data) {
211      case 0x0004: state->m_intenable = 0; break;
212      case 0x0005: state->m_intenable = 1; break;
213      case 0x0006: twincobr_flipscreen(machine, 0); break;
214      case 0x0007: twincobr_flipscreen(machine, 1); break;
215      case 0x0008: state->m_bg_ram_bank = 0x0000; break;
216      case 0x0009: state->m_bg_ram_bank = 0x1000; break;
217      case 0x000a: state->m_fg_rom_bank = 0x0000; break;
218      case 0x000b: state->m_fg_rom_bank = 0x1000; break;
219      case 0x000c: twincobr_dsp(machine, 1); break;    /* Enable the INT line to the DSP */
220      case 0x000d: twincobr_dsp(machine, 0); break;    /* Inhibit the INT line to the DSP */
221      case 0x000e: twincobr_display(machine, 0); break; /* Turn display off */
222      case 0x000f: twincobr_display(machine, 1); break; /* Turn display on */
209      case 0x0004: m_intenable = 0; break;
210      case 0x0005: m_intenable = 1; break;
211      case 0x0006: twincobr_flipscreen(0); break;
212      case 0x0007: twincobr_flipscreen(1); break;
213      case 0x0008: m_bg_ram_bank = 0x0000; break;
214      case 0x0009: m_bg_ram_bank = 0x1000; break;
215      case 0x000a: m_fg_rom_bank = 0x0000; break;
216      case 0x000b: m_fg_rom_bank = 0x1000; break;
217      case 0x000c: twincobr_dsp(1); break;    /* Enable the INT line to the DSP */
218      case 0x000d: twincobr_dsp(0); break;    /* Inhibit the INT line to the DSP */
219      case 0x000e: twincobr_display(0); break; /* Turn display off */
220      case 0x000f: twincobr_display(1); break; /* Turn display on */
223221   }
224222}
225223
r21022r21023
227225{
228226   if (ACCESSING_BITS_0_7)
229227   {
230      toaplan0_control_w(machine(), offset, data & 0xff);
228      toaplan0_control_w(offset, data & 0xff);
231229   }
232230}
233231
234232WRITE8_MEMBER(twincobr_state::wardner_control_w)
235233{
236   toaplan0_control_w(machine(), offset, data);
234   toaplan0_control_w(offset, data);
237235}
238236
239237
r21022r21023
251249}
252250
253251
254static void toaplan0_coin_dsp_w(address_space &space, int offset, int data)
252void twincobr_state::toaplan0_coin_dsp_w(address_space &space, int offset, int data)
255253{
256   twincobr_state *state = space.machine().driver_data<twincobr_state>();
257254   if (data > 1)
258      LOG(("%s:Writing %08x to %08x.\n",space.machine().describe_context(),data,toaplan_port_type[state->m_toaplan_main_cpu] - offset));
255      LOG(("%s:Writing %08x to %08x.\n",machine().describe_context(),data,toaplan_port_type[m_toaplan_main_cpu] - offset));
259256   switch (data) {
260      case 0x08: coin_counter_w(space.machine(), 0,0); break;
261      case 0x09: coin_counter_w(space.machine(), 0,1); break;
262      case 0x0a: coin_counter_w(space.machine(), 1,0); break;
263      case 0x0b: coin_counter_w(space.machine(), 1,1); break;
264      case 0x0c: coin_lockout_w(space.machine(), 0,1); break;
265      case 0x0d: coin_lockout_w(space.machine(), 0,0); break;
266      case 0x0e: coin_lockout_w(space.machine(), 1,1); break;
267      case 0x0f: coin_lockout_w(space.machine(), 1,0); break;
257      case 0x08: coin_counter_w(machine(), 0,0); break;
258      case 0x09: coin_counter_w(machine(), 0,1); break;
259      case 0x0a: coin_counter_w(machine(), 1,0); break;
260      case 0x0b: coin_counter_w(machine(), 1,1); break;
261      case 0x0c: coin_lockout_w(machine(), 0,1); break;
262      case 0x0d: coin_lockout_w(machine(), 0,0); break;
263      case 0x0e: coin_lockout_w(machine(), 1,1); break;
264      case 0x0f: coin_lockout_w(machine(), 1,0); break;
268265      /****** The following apply to Flying Shark/Wardner only ******/
269266      case 0x00:  /* This means assert the INT line to the DSP */
270267               LOG(("Turning DSP on and main CPU off\n"));
271               space.machine().device("dsp")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
272               space.machine().device("dsp")->execute().set_input_line(0, ASSERT_LINE); /* TMS32010 INT */
273               space.machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
268               machine().device("dsp")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
269               machine().device("dsp")->execute().set_input_line(0, ASSERT_LINE); /* TMS32010 INT */
270               machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
274271               break;
275272      case 0x01:  /* This means inhibit the INT line to the DSP */
276273               LOG(("Turning DSP off\n"));
277               space.machine().device("dsp")->execute().set_input_line(0, CLEAR_LINE); /* TMS32010 INT */
278               space.machine().device("dsp")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
274               machine().device("dsp")->execute().set_input_line(0, CLEAR_LINE); /* TMS32010 INT */
275               machine().device("dsp")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
279276               break;
280277   }
281278}
r21022r21023
303300MACHINE_RESET_MEMBER(twincobr_state,twincobr)
304301{
305302   m_toaplan_main_cpu = 0;     /* 68000 */
306   twincobr_display(machine(), 0);
303   twincobr_display(0);
307304   m_intenable = 0;
308305   m_dsp_addr_w = 0;
309306   m_main_ram_seg = 0;
r21022r21023
318315   MACHINE_RESET_CALL_MEMBER(twincobr);
319316
320317   m_toaplan_main_cpu = 1;     /* Z80 */
321   twincobr_display(machine(), 1);
318   twincobr_display(1);
322319}
323320
324void twincobr_driver_savestate(running_machine &machine)
321void twincobr_state::twincobr_driver_savestate()
325322{
326   twincobr_state *state = machine.driver_data<twincobr_state>();
327323
328   state_save_register_global(machine, state->m_toaplan_main_cpu);
329   state_save_register_global(machine, state->m_intenable);
330   state_save_register_global(machine, state->m_dsp_on);
331   state_save_register_global(machine, state->m_dsp_addr_w);
332   state_save_register_global(machine, state->m_main_ram_seg);
333   state_save_register_global(machine, state->m_dsp_BIO);
334   state_save_register_global(machine, state->m_dsp_execute);
335   state_save_register_global(machine, state->m_fsharkbt_8741);
336   state_save_register_global(machine, state->m_wardner_membank);
324   state_save_register_global(machine(), m_toaplan_main_cpu);
325   state_save_register_global(machine(), m_intenable);
326   state_save_register_global(machine(), m_dsp_on);
327   state_save_register_global(machine(), m_dsp_addr_w);
328   state_save_register_global(machine(), m_main_ram_seg);
329   state_save_register_global(machine(), m_dsp_BIO);
330   state_save_register_global(machine(), m_dsp_execute);
331   state_save_register_global(machine(), m_fsharkbt_8741);
332   state_save_register_global(machine(), m_wardner_membank);
337333
338   machine.save().register_postload(save_prepost_delegate(FUNC(twincobr_state::twincobr_restore_dsp), state));
334   machine().save().register_postload(save_prepost_delegate(FUNC(twincobr_state::twincobr_restore_dsp), this));
339335}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team