Previous 199869 Revisions Next

r20742 Tuesday 5th February, 2013 at 10:07:08 UTC by Miodrag Milanović
Modernization of drivers part 1 (no whatsnew)
[src/mame/drivers]alpha68k.c amspdwy.c aquarium.c arkanoid.c astrof.c balsente.c bublbobl.c bwing.c missb2.c
[src/mame/includes]1942.h 1943.h 20pacgal.h 40love.h 8080bw.h actfancr.h aeroboto.h aerofgt.h alpha68k.h ambush.h amspdwy.h angelkds.h appoooh.h aquarium.h arabian.h arcadecl.h argus.h arkanoid.h armedf.h astrocde.h astrof.h atarifb.h atarisy1.h aztarac.h bagman.h balsente.h baraduke.h battlane.h battlera.h battlex.h bbusters.h bigevglf.h bigstrkb.h bionicc.h blktiger.h blmbycar.h blockout.h bloodbro.h blueprnt.h bogeyman.h bombjack.h boogwing.h brkthru.h bsktball.h btime.h bublbobl.h buggychl.h bwing.h
[src/mame/machine]balsente.c
[src/mame/video]1942.c 1943.c 20pacgal.c 40love.c 8080bw.c actfancr.c aeroboto.c aerofgt.c alpha68k.c ambush.c amspdwy.c angelkds.c appoooh.c aquarium.c arabian.c arcadecl.c argus.c arkanoid.c armedf.c astrocde.c atarifb.c atarisy1.c aztarac.c bagman.c balsente.c baraduke.c battlane.c battlera.c battlex.c bbusters.c bigevglf.c bigstrkb.c bionicc.c blktiger.c blmbycar.c blockout.c bloodbro.c blueprnt.c bogeyman.c bombjack.c boogwing.c brkthru.c bsktball.c btime.c buggychl.c bwing.c

trunk/src/mame/machine/balsente.c
r20741r20742
1414
1515#define LOG_CEM_WRITES      0
1616
17
18/* local prototypes */
19static void poly17_init(running_machine &machine);
20static void update_grudge_steering(running_machine &machine);
21
22
23
24
2517/*************************************
2618 *
2719 *  Interrupt handling
r20741r20742
5042
5143   /* if this is Grudge Match, update the steering */
5244   if (m_grudge_steering_result & 0x80)
53      update_grudge_steering(machine());
45      update_grudge_steering();
5446
5547   /* if we're a shooter, we do a little more work */
5648   if (m_shooter)
r20741r20742
8577   m_cem_device[5] = m_cem6;
8678
8779   /* create the polynomial tables */
88   poly17_init(machine());
80   poly17_init();
8981
9082   /* register for saving */
9183   for (i = 0; i < 3; i++)
r20741r20742
190182 *
191183 *************************************/
192184
193static void poly17_init(running_machine &machine)
185void balsente_state::poly17_init()
194186{
195   balsente_state *state = machine.driver_data<balsente_state>();
196187   UINT32 i, x = 0;
197188   UINT8 *p, *r;
198189
199190   /* allocate memory */
200   p = state->m_poly17;
201   r = state->m_rand17;
191   p = m_poly17;
192   r = m_rand17;
202193
203194   /* generate the polynomial */
204195   for (i = 0; i < POLY17_SIZE; i++)
r20741r20742
337328 *
338329 *************************************/
339330
340static void m6850_update_io(running_machine &machine)
331void balsente_state::m6850_update_io()
341332{
342   balsente_state *state = machine.driver_data<balsente_state>();
343333   UINT8 new_state;
344334
345335   /* sound -> main CPU communications */
346   if (!(state->m_m6850_sound_status & 0x02))
336   if (!(m_m6850_sound_status & 0x02))
347337   {
348338      /* set the overrun bit if the data in the destination hasn't been read yet */
349      if (state->m_m6850_status & 0x01)
350         state->m_m6850_status |= 0x20;
339      if (m_m6850_status & 0x01)
340         m_m6850_status |= 0x20;
351341
352342      /* copy the sound's output to our input */
353      state->m_m6850_input = state->m_m6850_sound_output;
343      m_m6850_input = m_m6850_sound_output;
354344
355345      /* set the receive register full bit */
356      state->m_m6850_status |= 0x01;
346      m_m6850_status |= 0x01;
357347
358348      /* set the sound's trasmitter register empty bit */
359      state->m_m6850_sound_status |= 0x02;
349      m_m6850_sound_status |= 0x02;
360350   }
361351
362352   /* main -> sound CPU communications */
363   if (state->m_m6850_data_ready)
353   if (m_m6850_data_ready)
364354   {
365355      /* set the overrun bit if the data in the destination hasn't been read yet */
366      if (state->m_m6850_sound_status & 0x01)
367         state->m_m6850_sound_status |= 0x20;
356      if (m_m6850_sound_status & 0x01)
357         m_m6850_sound_status |= 0x20;
368358
369359      /* copy the main CPU's output to our input */
370      state->m_m6850_sound_input = state->m_m6850_output;
360      m_m6850_sound_input = m_m6850_output;
371361
372362      /* set the receive register full bit */
373      state->m_m6850_sound_status |= 0x01;
363      m_m6850_sound_status |= 0x01;
374364
375365      /* set the main CPU's trasmitter register empty bit */
376      state->m_m6850_status |= 0x02;
377      state->m_m6850_data_ready = 0;
366      m_m6850_status |= 0x02;
367      m_m6850_data_ready = 0;
378368   }
379369
380370   /* check for reset states */
381   if ((state->m_m6850_control & 3) == 3)
371   if ((m_m6850_control & 3) == 3)
382372   {
383      state->m_m6850_status = 0x02;
384      state->m_m6850_data_ready = 0;
373      m_m6850_status = 0x02;
374      m_m6850_data_ready = 0;
385375   }
386   if ((state->m_m6850_sound_control & 3) == 3)
387      state->m_m6850_sound_status = 0x02;
376   if ((m_m6850_sound_control & 3) == 3)
377      m_m6850_sound_status = 0x02;
388378
389379   /* check for transmit/receive IRQs on the main CPU */
390380   new_state = 0;
391   if ((state->m_m6850_control & 0x80) && (state->m_m6850_status & 0x21)) new_state = 1;
392   if ((state->m_m6850_control & 0x60) == 0x20 && (state->m_m6850_status & 0x02)) new_state = 1;
381   if ((m_m6850_control & 0x80) && (m_m6850_status & 0x21)) new_state = 1;
382   if ((m_m6850_control & 0x60) == 0x20 && (m_m6850_status & 0x02)) new_state = 1;
393383
394384   /* apply the change */
395   if (new_state && !(state->m_m6850_status & 0x80))
385   if (new_state && !(m_m6850_status & 0x80))
396386   {
397      machine.device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, ASSERT_LINE);
398      state->m_m6850_status |= 0x80;
387      machine().device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, ASSERT_LINE);
388      m_m6850_status |= 0x80;
399389   }
400   else if (!new_state && (state->m_m6850_status & 0x80))
390   else if (!new_state && (m_m6850_status & 0x80))
401391   {
402      machine.device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, CLEAR_LINE);
403      state->m_m6850_status &= ~0x80;
392      machine().device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, CLEAR_LINE);
393      m_m6850_status &= ~0x80;
404394   }
405395
406396   /* check for transmit/receive IRQs on the sound CPU */
407397   new_state = 0;
408   if ((state->m_m6850_sound_control & 0x80) && (state->m_m6850_sound_status & 0x21)) new_state = 1;
409   if ((state->m_m6850_sound_control & 0x60) == 0x20 && (state->m_m6850_sound_status & 0x02)) new_state = 1;
410   if (!(state->m_counter_control & 0x20)) new_state = 0;
398   if ((m_m6850_sound_control & 0x80) && (m_m6850_sound_status & 0x21)) new_state = 1;
399   if ((m_m6850_sound_control & 0x60) == 0x20 && (m_m6850_sound_status & 0x02)) new_state = 1;
400   if (!(m_counter_control & 0x20)) new_state = 0;
411401
412402   /* apply the change */
413   if (new_state && !(state->m_m6850_sound_status & 0x80))
403   if (new_state && !(m_m6850_sound_status & 0x80))
414404   {
415      machine.device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
416      state->m_m6850_sound_status |= 0x80;
405      machine().device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
406      m_m6850_sound_status |= 0x80;
417407   }
418   else if (!new_state && (state->m_m6850_sound_status & 0x80))
408   else if (!new_state && (m_m6850_sound_status & 0x80))
419409   {
420      machine.device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
421      state->m_m6850_sound_status &= ~0x80;
410      machine().device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
411      m_m6850_sound_status &= ~0x80;
422412   }
423413}
424414
r20741r20742
447437
448438      /* clear the overrun and receive buffer full bits */
449439      m_m6850_status &= ~0x21;
450      m6850_update_io(machine());
440      m6850_update_io();
451441   }
452442
453443   return result;
r20741r20742
459449   /* set the output data byte and indicate that we're ready to go */
460450   m_m6850_output = param;
461451   m_m6850_data_ready = 1;
462   m6850_update_io(machine());
452   m6850_update_io();
463453}
464454
465455
r20741r20742
467457{
468458   /* indicate that the transmit buffer is no longer empty and update the I/O state */
469459   m_m6850_status &= ~0x02;
470   m6850_update_io(machine());
460   m6850_update_io();
471461
472462   /* set a timer for 500usec later to actually transmit the data */
473463   /* (this is very important for several games, esp Snacks'n Jaxson) */
r20741r20742
483473      m_m6850_control = data;
484474
485475      /* re-update since interrupt enables could have been modified */
486      m6850_update_io(machine());
476      m6850_update_io();
487477   }
488478
489479   /* output register is at offset 1; set a timer to synchronize the CPUs */
r20741r20742
516506
517507      /* clear the overrun and receive buffer full bits */
518508      m_m6850_sound_status &= ~0x21;
519      m6850_update_io(machine());
509      m6850_update_io();
520510   }
521511
522512   return result;
r20741r20742
537527   }
538528
539529   /* re-update since interrupt enables could have been modified */
540   m6850_update_io(machine());
530   m6850_update_io();
541531}
542532
543533
r20741r20742
846836 *
847837 *************************************/
848838
849static void set_counter_0_ff(timer_device &timer, int newstate)
839void balsente_state::set_counter_0_ff(timer_device &timer, int newstate)
850840{
851   balsente_state *state = timer.machine().driver_data<balsente_state>();
852
853841   /* the flip/flop output is inverted, so if we went high to low, that's a clock */
854   if (state->m_counter_0_ff && !newstate)
842   if (m_counter_0_ff && !newstate)
855843   {
856844      /* only count if gated and non-zero */
857      if (state->m_counter[0].count > 0 && state->m_counter[0].gate)
845      if (m_counter[0].count > 0 && m_counter[0].gate)
858846      {
859         state->m_counter[0].count--;
860         if (state->m_counter[0].count == 0)
861            state->balsente_counter_callback(timer, NULL, 0);
847         m_counter[0].count--;
848         if (m_counter[0].count == 0)
849            balsente_counter_callback(timer, NULL, 0);
862850      }
863851   }
864852
865853   /* remember the new state */
866   state->m_counter_0_ff = newstate;
854   m_counter_0_ff = newstate;
867855}
868856
869857
r20741r20742
967955   if (!(data & 0x10)) set_counter_0_ff(*m_counter_0_timer, 0);
968956
969957   /* bit 5 clears the NMI interrupt; recompute the I/O state now */
970   m6850_update_io(machine());
958   m6850_update_io();
971959}
972960
973961
r20741r20742
11131101}
11141102
11151103
1116static void update_grudge_steering(running_machine &machine)
1104void balsente_state::update_grudge_steering()
11171105{
1118   balsente_state *state = machine.driver_data<balsente_state>();
11191106   UINT8 wheel[3];
11201107   INT8 diff[3];
11211108
11221109   /* read the current steering values */
1123   wheel[0] = state->ioport("AN0")->read();
1124   wheel[1] = state->ioport("AN1")->read();
1125   wheel[2] = state->ioport("AN2")->read();
1110   wheel[0] = ioport("AN0")->read();
1111   wheel[1] = ioport("AN1")->read();
1112   wheel[2] = ioport("AN2")->read();
11261113
11271114   /* diff the values */
1128   diff[0] = wheel[0] - state->m_grudge_last_steering[0];
1129   diff[1] = wheel[1] - state->m_grudge_last_steering[1];
1130   diff[2] = wheel[2] - state->m_grudge_last_steering[2];
1115   diff[0] = wheel[0] - m_grudge_last_steering[0];
1116   diff[1] = wheel[1] - m_grudge_last_steering[1];
1117   diff[2] = wheel[2] - m_grudge_last_steering[2];
11311118
11321119   /* update the last values */
1133   state->m_grudge_last_steering[0] += diff[0];
1134   state->m_grudge_last_steering[1] += diff[1];
1135   state->m_grudge_last_steering[2] += diff[2];
1120   m_grudge_last_steering[0] += diff[0];
1121   m_grudge_last_steering[1] += diff[1];
1122   m_grudge_last_steering[2] += diff[2];
11361123
11371124   /* compute the result */
1138   state->m_grudge_steering_result = 0xff;
1125   m_grudge_steering_result = 0xff;
11391126   if (diff[0])
11401127   {
1141      state->m_grudge_steering_result ^= 0x01;
1142      if (diff[0] > 0) state->m_grudge_steering_result ^= 0x02;
1128      m_grudge_steering_result ^= 0x01;
1129      if (diff[0] > 0) m_grudge_steering_result ^= 0x02;
11431130   }
11441131   if (diff[1])
11451132   {
1146      state->m_grudge_steering_result ^= 0x04;
1147      if (diff[1] > 0) state->m_grudge_steering_result ^= 0x08;
1133      m_grudge_steering_result ^= 0x04;
1134      if (diff[1] > 0) m_grudge_steering_result ^= 0x08;
11481135   }
11491136   if (diff[2])
11501137   {
1151      state->m_grudge_steering_result ^= 0x10;
1152      if (diff[2] > 0) state->m_grudge_steering_result ^= 0x20;
1138      m_grudge_steering_result ^= 0x10;
1139      if (diff[2] > 0) m_grudge_steering_result ^= 0x20;
11531140   }
11541141   logerror("Recomputed steering\n");
11551142}
trunk/src/mame/video/bsktball.c
r20741r20742
2929   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(bsktball_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
3030}
3131
32static void draw_sprites( running_machine &machine,  bitmap_ind16 &bitmap, const rectangle &cliprect )
32void bsktball_state::draw_sprites(  bitmap_ind16 &bitmap, const rectangle &cliprect )
3333{
34   bsktball_state *state = machine.driver_data<bsktball_state>();
3534   int mot;
3635
3736   for (mot = 0; mot < 16; mot++)
3837   {
39      int pic = state->m_motion[mot * 4];
40      int sy = 28 * 8 - state->m_motion[mot * 4 + 1];
41      int sx = state->m_motion[mot * 4 + 2];
42      int color = state->m_motion[mot * 4 + 3];
38      int pic = m_motion[mot * 4];
39      int sy = 28 * 8 - m_motion[mot * 4 + 1];
40      int sx = m_motion[mot * 4 + 2];
41      int color = m_motion[mot * 4 + 3];
4342      int flipx = (pic & 0x80) >> 7;
4443
4544      pic = (pic & 0x3f);
4645      color = (color & 0x3f);
4746
48      drawgfx_transpen(bitmap, cliprect, machine.gfx[1], pic, color, flipx, 0, sx, sy, 0);
47      drawgfx_transpen(bitmap, cliprect, machine().gfx[1], pic, color, flipx, 0, sx, sy, 0);
4948   }
5049}
5150
5251UINT32 bsktball_state::screen_update_bsktball(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
5352{
5453   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
55   draw_sprites(machine(), bitmap, cliprect);
54   draw_sprites(bitmap, cliprect);
5655   return 0;
5756}
trunk/src/mame/video/armedf.c
r20741r20742
256256***************************************************************************/
257257
258258/* custom code to handle color cycling effect, handled by m_spr_pal_clut */
259void armedf_drawgfx(running_machine &machine, bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
259void armedf_state::armedf_drawgfx(bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
260260                     UINT32 code,UINT32 color, UINT32 clut,int flipx,int flipy,int offsx,int offsy,
261261                     int transparent_color)
262262{
263   armedf_state *state = machine.driver_data<armedf_state>();
264263   const pen_t *pal = &gfx->machine().pens[gfx->colorbase() + gfx->granularity() * (color % gfx->colors())];
265264   const UINT8 *source_base = gfx->get_data(code % gfx->elements());
266265   int x_index_base, y_index, sx, sy, ex, ey;
r20741r20742
314313            int x_index = x_index_base;
315314            for (x = sx; x < ex; x++)
316315            {
317               int c = (source[x_index] & ~0xf) | ((state->m_spr_pal_clut[clut*0x10+(source[x_index] & 0xf)]) & 0xf);
316               int c = (source[x_index] & ~0xf) | ((m_spr_pal_clut[clut*0x10+(source[x_index] & 0xf)]) & 0xf);
318317               if (c != transparent_color)
319318                  dest[x] = pal[c];
320319
r20741r20742
327326}
328327
329328
330static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
329void armedf_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
331330{
332   armedf_state *state = machine.driver_data<armedf_state>();
333   UINT16 *buffered_spriteram = state->m_spriteram->buffer();
331   UINT16 *buffered_spriteram = m_spriteram->buffer();
334332   int offs;
335333
336   for (offs = 0; offs < state->m_spriteram->bytes() / 2; offs += 4)
334   for (offs = 0; offs < m_spriteram->bytes() / 2; offs += 4)
337335   {
338336      int code = buffered_spriteram[offs + 1]; /* ??YX?TTTTTTTTTTT */
339337      int flipx = code & 0x2000;
r20741r20742
341339      int color = (buffered_spriteram[offs + 2] >> 8) & 0x1f;
342340      int clut = (buffered_spriteram[offs + 2]) & 0x7f;
343341      int sx = buffered_spriteram[offs + 3];
344      int sy = state->m_sprite_offy + 240 - (buffered_spriteram[offs + 0] & 0x1ff);
342      int sy = m_sprite_offy + 240 - (buffered_spriteram[offs + 0] & 0x1ff);
345343
346      if (state->flip_screen())
344      if (flip_screen())
347345      {
348346         sx = 320 - sx + 176;    /* don't ask where 176 comes from, just tried it out */
349347         sy = 240 - sy + 1;  /* don't ask where 1 comes from, just tried it out */
r20741r20742
353351
354352      if (((buffered_spriteram[offs + 0] & 0x3000) >> 12) == priority)
355353      {
356         armedf_drawgfx(machine,bitmap,cliprect,machine.gfx[3],
354         armedf_drawgfx(bitmap,cliprect,machine().gfx[3],
357355            code & 0xfff,
358356            color,clut,
359357            flipx,flipy,
r20741r20742
393391   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
394392
395393   if (sprite_enable)
396      draw_sprites(machine(), bitmap, cliprect, 2);
394      draw_sprites(bitmap, cliprect, 2);
397395
398396   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
399397
400398   if (sprite_enable)
401      draw_sprites(machine(), bitmap, cliprect, 1);
399      draw_sprites(bitmap, cliprect, 1);
402400
403401   if (sprite_enable)
404      draw_sprites(machine(), bitmap, cliprect, 0);
402      draw_sprites(bitmap, cliprect, 0);
405403
406404   m_tx_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_CATEGORY(0), 0);
407405
trunk/src/mame/video/appoooh.c
r20741r20742
199199   /* bit 7 unknown (used) */
200200}
201201
202static void appoooh_draw_sprites( bitmap_ind16 &dest_bmp, const rectangle &cliprect, gfx_element *gfx, UINT8 *sprite )
202void appoooh_state::appoooh_draw_sprites( bitmap_ind16 &dest_bmp, const rectangle &cliprect, gfx_element *gfx, UINT8 *sprite )
203203{
204   appoooh_state *state = gfx->machine().driver_data<appoooh_state>();
205204   int offs;
206   int flipy = state->flip_screen();
205   int flipy = flip_screen();
207206
208207   for (offs = 0x20 - 4; offs >= 0; offs -= 4)
209208   {
r20741r20742
231230   }
232231}
233232
234static void robowres_draw_sprites( bitmap_ind16 &dest_bmp, const rectangle &cliprect, gfx_element *gfx, UINT8 *sprite )
233void appoooh_state::robowres_draw_sprites( bitmap_ind16 &dest_bmp, const rectangle &cliprect, gfx_element *gfx, UINT8 *sprite )
235234{
236   appoooh_state *state = gfx->machine().driver_data<appoooh_state>();
237235   int offs;
238   int flipy = state->flip_screen();
236   int flipy = flip_screen();
239237
240238   for (offs = 0x20 - 4; offs >= 0; offs -= 4)
241239   {
trunk/src/mame/video/20pacgal.c
r20741r20742
2222 *
2323 *************************************/
2424
25static void get_pens(running_machine &machine, const _20pacgal_state *state, pen_t *pens)
25void _20pacgal_state::get_pens(pen_t *pens)
2626{
2727   offs_t offs;
28   UINT8 *color_prom = machine.root_device().memregion("proms")->base() + (NUM_PENS * state->m_game_selected);
28   UINT8 *color_prom = machine().root_device().memregion("proms")->base() + (NUM_PENS * m_game_selected);
2929
3030   for (offs = 0; offs < NUM_PENS ;offs++)
3131   {
r20741r20742
7373}
7474
7575
76static void do_pen_lookup(running_machine &machine, const _20pacgal_state *state, bitmap_rgb32 &bitmap, const rectangle &cliprect)
76void _20pacgal_state::do_pen_lookup(bitmap_rgb32 &bitmap, const rectangle &cliprect)
7777{
7878   int y, x;
7979   pen_t pens[NUM_PENS + NUM_STAR_PENS];
8080
81   get_pens(machine, state, pens);
81   get_pens(pens);
8282
8383   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
8484      for(x = cliprect.min_x; x <= cliprect.max_x; x++)
r20741r20742
9393 *
9494 *************************************/
9595
96static void draw_sprite(running_machine& machine, const _20pacgal_state *state, bitmap_rgb32 &bitmap, int y, int x,
96void _20pacgal_state::draw_sprite(bitmap_rgb32 &bitmap, int y, int x,
9797                  UINT8 code, UINT8 color, int flip_y, int flip_x)
9898{
9999   int sy;
100100
101101   offs_t pen_base = (color & 0x1f) << 2;
102   pen_base += state->m_sprite_pal_base;
102   pen_base += m_sprite_pal_base;
103103
104104   if (flip_y)
105105      y = y + 0x0f;
r20741r20742
122122         /* address mangling */
123123         gfx_offs = (gfx_offs & 0x1f83) | ((gfx_offs & 0x003c) << 1) | ((gfx_offs & 0x0040) >> 4);
124124
125         data = (state->m_sprite_gfx_ram[gfx_offs + 0] << 24) |
126               (state->m_sprite_gfx_ram[gfx_offs + 1] << 16) |
127               (state->m_sprite_gfx_ram[gfx_offs + 2] << 8) |
128               (state->m_sprite_gfx_ram[gfx_offs + 3] << 0);
125         data = (m_sprite_gfx_ram[gfx_offs + 0] << 24) |
126               (m_sprite_gfx_ram[gfx_offs + 1] << 16) |
127               (m_sprite_gfx_ram[gfx_offs + 2] << 8) |
128               (m_sprite_gfx_ram[gfx_offs + 3] << 0);
129129
130130         /* for each pixel in the row */
131131         for (sx = 0; sx < 0x10; sx++)
r20741r20742
135135               offs_t pen = (data & 0xc0000000) >> 30;
136136               UINT8 col;
137137
138               col = state->m_sprite_color_lookup[pen_base | pen] & 0x0f;
138               col = m_sprite_color_lookup[pen_base | pen] & 0x0f;
139139
140140               /* pen bits A0-A3 */
141141               if (col)
r20741r20742
163163}
164164
165165
166static void draw_sprites(running_machine& machine,const _20pacgal_state *state, bitmap_rgb32 &bitmap)
166void _20pacgal_state::draw_sprites(bitmap_rgb32 &bitmap)
167167{
168168   int offs;
169169
r20741r20742
176176      };
177177      int x, y;
178178
179      UINT8 code = state->m_sprite_ram[offs + 0x000];
180      UINT8 color = state->m_sprite_ram[offs + 0x001];
179      UINT8 code = m_sprite_ram[offs + 0x000];
180      UINT8 color = m_sprite_ram[offs + 0x001];
181181
182      int sx = state->m_sprite_ram[offs + 0x081] - 41 + 0x100*(state->m_sprite_ram[offs + 0x101] & 3);
183      int sy = 256 - state->m_sprite_ram[offs + 0x080] + 1;
182      int sx = m_sprite_ram[offs + 0x081] - 41 + 0x100*(m_sprite_ram[offs + 0x101] & 3);
183      int sy = 256 - m_sprite_ram[offs + 0x080] + 1;
184184
185      int flip_x = (state->m_sprite_ram[offs + 0x100] & 0x01) >> 0;
186      int flip_y = (state->m_sprite_ram[offs + 0x100] & 0x02) >> 1;
187      int size_x = (state->m_sprite_ram[offs + 0x100] & 0x04) >> 2;
188      int size_y = (state->m_sprite_ram[offs + 0x100] & 0x08) >> 3;
185      int flip_x = (m_sprite_ram[offs + 0x100] & 0x01) >> 0;
186      int flip_y = (m_sprite_ram[offs + 0x100] & 0x02) >> 1;
187      int size_x = (m_sprite_ram[offs + 0x100] & 0x04) >> 2;
188      int size_y = (m_sprite_ram[offs + 0x100] & 0x08) >> 3;
189189
190190      sy = sy - (16 * size_y);
191191      sy = (sy & 0xff) - 32;  /* fix wraparound */
192192
193193      /* only Galaga appears to be effected by the global flip state */
194      if (state->m_game_selected && (state->m_flip[0] & 0x01))
194      if (m_game_selected && (m_flip[0] & 0x01))
195195      {
196196         flip_x = !flip_x;
197197         flip_y = !flip_y;
r20741r20742
199199
200200      for (y = 0; y <= size_y; y++)
201201         for (x = 0; x <= size_x; x++)
202            draw_sprite(machine,state, bitmap,
202            draw_sprite(bitmap,
203203                     sy + (16 * y), sx + (16 * x),
204204                     code + code_offs[y ^ (size_y * flip_y)][x ^ (size_x * flip_x)],
205205                     color,
r20741r20742
215215 *
216216 *************************************/
217217
218static void draw_chars(const _20pacgal_state *state, bitmap_rgb32 &bitmap)
218void _20pacgal_state::draw_chars(bitmap_rgb32 &bitmap)
219219{
220220   offs_t offs;
221221
222   int flip = state->m_flip[0] & 0x01;
222   int flip = m_flip[0] & 0x01;
223223
224224   /* for each byte in the video RAM */
225225   for (offs = 0; offs < 0x400; offs++)
r20741r20742
227227      int sy;
228228      int y, x;
229229
230      UINT8 *gfx = &state->m_char_gfx_ram.target()[state->m_video_ram[0x0000 | offs] << 4];
231      UINT32 color_base = (state->m_video_ram[0x0400 | offs] & 0x3f) << 2;
230      UINT8 *gfx = &m_char_gfx_ram.target()[m_video_ram[0x0000 | offs] << 4];
231      UINT32 color_base = (m_video_ram[0x0400 | offs] & 0x3f) << 2;
232232
233233      /* map the offset to (x, y) character coordinates */
234234      if ((offs & 0x03c0) == 0)
r20741r20742
349349 *
350350 */
351351
352static void draw_stars(_20pacgal_state *state, bitmap_rgb32 &bitmap, const rectangle &cliprect )
352void _20pacgal_state::draw_stars(bitmap_rgb32 &bitmap, const rectangle &cliprect )
353353{
354   if ( (state->m_stars_ctrl[0] >> 5) & 1 )
354   if ( (m_stars_ctrl[0] >> 5) & 1 )
355355   {
356356      int clock;
357      UINT16 lfsr =   state->m_stars_seed[0] + state->m_stars_seed[1]*256;
358      UINT8 feedback = (state->m_stars_ctrl[0] >> 6) & 1;
359      UINT16 star_seta = (state->m_stars_ctrl[0] >> 3) & 0x01;
360      UINT16 star_setb = (state->m_stars_ctrl[0] >> 3) & 0x02;
357      UINT16 lfsr =   m_stars_seed[0] + m_stars_seed[1]*256;
358      UINT8 feedback = (m_stars_ctrl[0] >> 6) & 1;
359      UINT16 star_seta = (m_stars_ctrl[0] >> 3) & 0x01;
360      UINT16 star_setb = (m_stars_ctrl[0] >> 3) & 0x02;
361361      int cnt = 0;
362362
363363      /* This is a guess based on galaga star sets */
r20741r20742
409409UINT32 _20pacgal_state::screen_update_20pacgal(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
410410{
411411   bitmap.fill(0, cliprect);
412   draw_stars(this, bitmap,cliprect);
413   draw_chars(this, bitmap);
414   draw_sprites(machine(),this, bitmap);
415   do_pen_lookup(machine(), this, bitmap, cliprect);
412   draw_stars(bitmap,cliprect);
413   draw_chars(bitmap);
414   draw_sprites(bitmap);
415   do_pen_lookup(bitmap, cliprect);
416416
417417   return 0;
418418}
trunk/src/mame/video/actfancr.c
r20741r20742
1111
1212/******************************************************************************/
1313
14static void register_savestate( running_machine &machine )
14void actfancr_state::register_savestate()
1515{
16   actfancr_state *state = machine.driver_data<actfancr_state>();
17   state->save_item(NAME(state->m_flipscreen));
16   save_item(NAME(m_flipscreen));
1817}
1918
2019void actfancr_state::video_start()
2120{
22   register_savestate(machine());
21   register_savestate();
2322}
2423
2524/******************************************************************************/
trunk/src/mame/video/btime.c
r20741r20742
289289}
290290
291291
292static void draw_chars( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 transparency, UINT8 color, int priority )
292void btime_state::draw_chars( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 transparency, UINT8 color, int priority )
293293{
294   btime_state *state = machine.driver_data<btime_state>();
295294   offs_t offs;
296295
297   for (offs = 0; offs < state->m_videoram.bytes(); offs++)
296   for (offs = 0; offs < m_videoram.bytes(); offs++)
298297   {
299298      UINT8 x = 31 - (offs / 32);
300299      UINT8 y = offs % 32;
301300
302      UINT16 code = state->m_videoram[offs] + 256 * (state->m_colorram[offs] & 3);
301      UINT16 code = m_videoram[offs] + 256 * (m_colorram[offs] & 3);
303302
304303      /* check priority */
305304      if ((priority != -1) && (priority != ((code >> 7) & 0x01)))
306305         continue;
307306
308      if (state->flip_screen())
307      if (flip_screen())
309308      {
310309         x = 31 + 16 - x;
311310         y = 33 - y;
312311      }
313312
314      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
313      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
315314            code,
316315            color,
317            state->flip_screen(),state->flip_screen(),
316            flip_screen(),flip_screen(),
318317            8*x,8*y,
319318            transparency ? 0 : -1);
320319   }
321320}
322321
323static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 color,
322void btime_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 color,
324323                     UINT8 sprite_y_adjust, UINT8 sprite_y_adjust_flip_screen,
325324                     UINT8 *sprite_ram, offs_t interleave )
326325{
327   btime_state *state = machine.driver_data<btime_state>();
328326   int i;
329327   offs_t offs;
330328
r20741r20742
342340      flipx = sprite_ram[offs + 0] & 0x04;
343341      flipy = sprite_ram[offs + 0] & 0x02;
344342
345      if (state->flip_screen())
343      if (flip_screen())
346344      {
347345         x = 240 + 128 - x;
348346         y = 256 - y + sprite_y_adjust_flip_screen;
r20741r20742
353351
354352      y = y - sprite_y_adjust;
355353
356      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
354      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
357355            sprite_ram[offs + interleave],
358356            color,
359357            flipx,flipy,
360358            x, y,0);
361359
362      y = y + (state->flip_screen() ? -256 : 256);
360      y = y + (flip_screen() ? -256 : 256);
363361
364362      // Wrap around
365      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
363      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
366364            sprite_ram[offs + interleave],
367365            color,
368366            flipx,flipy,
r20741r20742
371369}
372370
373371
374static void draw_background( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8* tmap, UINT8 color )
372void btime_state::draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8* tmap, UINT8 color )
375373{
376   btime_state *state = machine.driver_data<btime_state>();
377374   int i;
378   const UINT8 *gfx = state->memregion("bg_map")->base();
379   int scroll = -(state->m_bnj_scroll2 | ((state->m_bnj_scroll1 & 0x03) << 8));
375   const UINT8 *gfx = memregion("bg_map")->base();
376   int scroll = -(m_bnj_scroll2 | ((m_bnj_scroll1 & 0x03) << 8));
380377
381378   // One extra iteration for wrap around
382379   for (i = 0; i < 5; i++, scroll += 256)
r20741r20742
395392         int x = 240 - (16 * (offs / 16) + scroll) - 1;
396393         int y = 16 * (offs % 16);
397394
398         if (state->flip_screen())
395         if (flip_screen())
399396         {
400397            x = 240 + 128 - x;
401398            y = 256 - y;
402399         }
403400
404         drawgfx_opaque(bitmap, cliprect,machine.gfx[2],
401         drawgfx_opaque(bitmap, cliprect,machine().gfx[2],
405402               gfx[tileoffset + offs],
406403               color,
407               state->flip_screen(),state->flip_screen(),
404               flip_screen(),flip_screen(),
408405               x,y);
409406      }
410407   }
r20741r20742
429426         start = (start + 1) & 0x03;
430427      }
431428
432      draw_background(machine(), bitmap, cliprect, m_btime_tilemap, 0);
433      draw_chars(machine(), bitmap, cliprect, TRUE, 0, -1);
429      draw_background(bitmap, cliprect, m_btime_tilemap, 0);
430      draw_chars(bitmap, cliprect, TRUE, 0, -1);
434431   }
435432   else
436      draw_chars(machine(), bitmap, cliprect, FALSE, 0, -1);
433      draw_chars(bitmap, cliprect, FALSE, 0, -1);
437434
438   draw_sprites(machine(), bitmap, cliprect, 0, 1, 0, m_videoram, 0x20);
435   draw_sprites(bitmap, cliprect, 0, 1, 0, m_videoram, 0x20);
439436
440437   return 0;
441438}
r20741r20742
443440
444441UINT32 btime_state::screen_update_eggs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
445442{
446   draw_chars(machine(), bitmap, cliprect, FALSE, 0, -1);
447   draw_sprites(machine(), bitmap, cliprect, 0, 0, 0, m_videoram, 0x20);
443   draw_chars(bitmap, cliprect, FALSE, 0, -1);
444   draw_sprites(bitmap, cliprect, 0, 0, 0, m_videoram, 0x20);
448445
449446   return 0;
450447}
r20741r20742
452449
453450UINT32 btime_state::screen_update_lnc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
454451{
455   draw_chars(machine(), bitmap, cliprect, FALSE, 0, -1);
456   draw_sprites(machine(), bitmap, cliprect, 0, 1, 2, m_videoram, 0x20);
452   draw_chars(bitmap, cliprect, FALSE, 0, -1);
453   draw_sprites(bitmap, cliprect, 0, 1, 2, m_videoram, 0x20);
457454
458455   return 0;
459456}
r20741r20742
463460{
464461   if (m_bnj_scroll1 & 0x04)
465462   {
466      draw_background(machine(), bitmap, cliprect, m_zoar_scrollram, m_btime_palette);
467      draw_chars(machine(), bitmap, cliprect, TRUE, m_btime_palette + 1, -1);
463      draw_background(bitmap, cliprect, m_zoar_scrollram, m_btime_palette);
464      draw_chars(bitmap, cliprect, TRUE, m_btime_palette + 1, -1);
468465   }
469466   else
470      draw_chars(machine(), bitmap, cliprect, FALSE, m_btime_palette + 1, -1);
467      draw_chars(bitmap, cliprect, FALSE, m_btime_palette + 1, -1);
471468
472469   /* The order is important for correct priorities */
473   draw_sprites(machine(), bitmap, cliprect, m_btime_palette + 1, 1, 2, m_videoram + 0x1f, 0x20);
474   draw_sprites(machine(), bitmap, cliprect, m_btime_palette + 1, 1, 2, m_videoram, 0x20);
470   draw_sprites(bitmap, cliprect, m_btime_palette + 1, 1, 2, m_videoram + 0x1f, 0x20);
471   draw_sprites(bitmap, cliprect, m_btime_palette + 1, 1, 2, m_videoram, 0x20);
475472
476473   return 0;
477474}
r20741r20742
512509
513510      /* copy the low priority characters followed by the sprites
514511         then the high priority characters */
515      draw_chars(machine(), bitmap, cliprect, TRUE, 0, 1);
516      draw_sprites(machine(), bitmap, cliprect, 0, 0, 0, m_videoram, 0x20);
517      draw_chars(machine(), bitmap, cliprect, TRUE, 0, 0);
512      draw_chars(bitmap, cliprect, TRUE, 0, 1);
513      draw_sprites(bitmap, cliprect, 0, 0, 0, m_videoram, 0x20);
514      draw_chars(bitmap, cliprect, TRUE, 0, 0);
518515   }
519516   else
520517   {
521      draw_chars(machine(), bitmap, cliprect, FALSE, 0, -1);
522      draw_sprites(machine(), bitmap, cliprect, 0, 0, 0, m_videoram, 0x20);
518      draw_chars(bitmap, cliprect, FALSE, 0, -1);
519      draw_sprites(bitmap, cliprect, 0, 0, 0, m_videoram, 0x20);
523520   }
524521
525522   return 0;
r20741r20742
550547            8*sx,8*sy);
551548   }
552549
553   draw_chars(machine(), bitmap, cliprect, TRUE, 0, -1);
554   draw_sprites(machine(), bitmap, cliprect, 0, 1, 0, m_videoram, 0x20);
550   draw_chars(bitmap, cliprect, TRUE, 0, -1);
551   draw_sprites(bitmap, cliprect, 0, 1, 0, m_videoram, 0x20);
555552
556553   return 0;
557554}
r20741r20742
559556
560557UINT32 btime_state::screen_update_disco(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
561558{
562   draw_chars(machine(), bitmap, cliprect, FALSE, m_btime_palette, -1);
563   draw_sprites(machine(), bitmap, cliprect, m_btime_palette, 0, 0, m_spriteram, 1);
559   draw_chars(bitmap, cliprect, FALSE, m_btime_palette, -1);
560   draw_sprites(bitmap, cliprect, m_btime_palette, 0, 0, m_spriteram, 1);
564561
565562   return 0;
566563}
trunk/src/mame/video/bbusters.c
r20741r20742
105105      else if (dy&0x40) code+=32;             \
106106      else if (dx&0x40) code+=16
107107
108INLINE const UINT8 *get_source_ptr(gfx_element *gfx, UINT32 sprite, int dx, int dy, int block)
108inline const UINT8 *bbusters_state::get_source_ptr(gfx_element *gfx, UINT32 sprite, int dx, int dy, int block)
109109{
110110   int code=0;
111111
r20741r20742
143143   return gfx->get_data((sprite+code) % gfx->elements()) + ((dy%16) * gfx->rowbytes());
144144}
145145
146static void bbusters_draw_block(running_machine &machine, bitmap_ind16 &dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block)
146void bbusters_state::bbusters_draw_block(bitmap_ind16 &dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block)
147147{
148   bbusters_state *state = machine.driver_data<bbusters_state>();
149   gfx_element *gfx = machine.gfx[bank];
148   gfx_element *gfx = machine().gfx[bank];
150149   pen_t pen_base = gfx->colorbase() + gfx->granularity() * (color % gfx->colors());
151   UINT32 xinc=(state->m_scale_line_count * 0x10000 ) / size;
150   UINT32 xinc=(m_scale_line_count * 0x10000 ) / size;
152151   UINT8 pixel;
153152   int x_index;
154153   int dy=y;
155   int sx, ex = state->m_scale_line_count;
154   int sx, ex = m_scale_line_count;
156155
157   while (state->m_scale_line_count) {
156   while (m_scale_line_count) {
158157      if (dy>=16 && dy<240) {
159158         UINT16 *destline = &dest.pix16(dy);
160         UINT8 srcline=*state->m_scale_table_ptr;
159         UINT8 srcline=*m_scale_table_ptr;
161160         const UINT8 *srcptr=0;
162161
163162         if (!flipy)
r20741r20742
184183      }
185184
186185      dy++;
187      state->m_scale_table_ptr--;
188      state->m_scale_line_count--;
186      m_scale_table_ptr--;
187      m_scale_line_count--;
189188   }
190189}
191190
192static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const UINT16 *source, int bank, int colval, int colmask)
191void bbusters_state::draw_sprites(bitmap_ind16 &bitmap, const UINT16 *source, int bank, int colval, int colmask)
193192{
194   bbusters_state *state = machine.driver_data<bbusters_state>();
195   const UINT8 *scale_table=state->memregion("user1")->base();
193   const UINT8 *scale_table=memregion("user1")->base();
196194   int offs;
197195
198196   for (offs = 0;offs <0x800 ;offs += 4) {
r20741r20742
237235      switch ((source[offs+0]>>8)&0x3) {
238236         case 0:
239237            scale=source[offs+0]&0x7;
240            state->m_scale_table_ptr = scale_table+0x387f+(0x80*scale);
241            state->m_scale_line_count = 0x10-scale;
242            bbusters_draw_block(machine,bitmap,x,y,16,fx,fy,sprite,colour,bank,block);
238            m_scale_table_ptr = scale_table+0x387f+(0x80*scale);
239            m_scale_line_count = 0x10-scale;
240            bbusters_draw_block(bitmap,x,y,16,fx,fy,sprite,colour,bank,block);
243241            break;
244242         case 1: /* 2 x 2 */
245243            scale=source[offs+0]&0xf;
246            state->m_scale_table_ptr = scale_table+0x707f+(0x80*scale);
247            state->m_scale_line_count = 0x20-scale;
248            bbusters_draw_block(machine,bitmap,x,y,32,fx,fy,sprite,colour,bank,block);
244            m_scale_table_ptr = scale_table+0x707f+(0x80*scale);
245            m_scale_line_count = 0x20-scale;
246            bbusters_draw_block(bitmap,x,y,32,fx,fy,sprite,colour,bank,block);
249247            break;
250248         case 2: /* 64 by 64 block (2 x 2) x 2 */
251249            scale=source[offs+0]&0x1f;
252            state->m_scale_table_ptr = scale_table+0xa07f+(0x80*scale);
253            state->m_scale_line_count = 0x40-scale;
254            bbusters_draw_block(machine,bitmap,x,y,64,fx,fy,sprite,colour,bank,block);
250            m_scale_table_ptr = scale_table+0xa07f+(0x80*scale);
251            m_scale_line_count = 0x40-scale;
252            bbusters_draw_block(bitmap,x,y,64,fx,fy,sprite,colour,bank,block);
255253            break;
256254         case 3: /* 2 x 2 x 2 x 2 */
257255            scale=source[offs+0]&0x3f;
258            state->m_scale_table_ptr = scale_table+0xc07f+(0x80*scale);
259            state->m_scale_line_count = 0x80-scale;
260            bbusters_draw_block(machine,bitmap,x,y,128,fx,fy,sprite,colour,bank,block);
256            m_scale_table_ptr = scale_table+0xc07f+(0x80*scale);
257            m_scale_line_count = 0x80-scale;
258            bbusters_draw_block(bitmap,x,y,128,fx,fy,sprite,colour,bank,block);
261259            break;
262260      }
263261   }
r20741r20742
275273   m_pf2_tilemap->draw(bitmap, cliprect, 0, 0);
276274   //draw_sprites(machine(), bitmap, m_spriteram2->buffer(), 2, 0x8, 0x8);
277275   m_pf1_tilemap->draw(bitmap, cliprect, 0, 0);
278   draw_sprites(machine(), bitmap, m_spriteram2->buffer(), 2, 0, 0);
279   draw_sprites(machine(), bitmap, m_spriteram->buffer(), 1, 0, 0);
276   draw_sprites(bitmap, m_spriteram2->buffer(), 2, 0, 0);
277   draw_sprites(bitmap, m_spriteram->buffer(), 1, 0, 0);
280278   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
281279   return 0;
282280}
r20741r20742
290288
291289   m_pf2_tilemap->draw(bitmap, cliprect, 0, 0);
292290   m_pf1_tilemap->draw(bitmap, cliprect, 0, 0);
293   draw_sprites(machine(), bitmap, m_spriteram->buffer(), 1, 0, 0);
291   draw_sprites(bitmap, m_spriteram->buffer(), 1, 0, 0);
294292   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
295293   return 0;
296294}
trunk/src/mame/video/arcadecl.c
r20741r20742
1212#include "video/atarimo.h"
1313#include "includes/arcadecl.h"
1414
15
16static void arcadecl_bitmap_render(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect);
17
1815/*************************************
1916 *
2017 *  Video system start
r20741r20742
8077UINT32 arcadecl_state::screen_update_arcadecl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
8178{
8279   /* draw the playfield */
83   arcadecl_bitmap_render(machine(), bitmap, cliprect);
80   arcadecl_bitmap_render(bitmap, cliprect);
8481
8582   /* draw and merge the MO */
8683   if (m_has_mo)
r20741r20742
118115 *
119116 *************************************/
120117
121static void arcadecl_bitmap_render(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
118void arcadecl_state::arcadecl_bitmap_render(bitmap_ind16 &bitmap, const rectangle &cliprect)
122119{
123   arcadecl_state *state = machine.driver_data<arcadecl_state>();
124120   int x, y;
125121
126122   /* update any dirty scanlines */
127123   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
128124   {
129      const UINT16 *src = &state->m_bitmap[256 * y];
125      const UINT16 *src = &m_bitmap[256 * y];
130126      UINT16 *dst = &bitmap.pix16(y);
131127
132128      /* regenerate the line */
trunk/src/mame/video/bionicc.c
r20741r20742
188188
189189***************************************************************************/
190190
191static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
191void bionicc_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
192192{
193   bionicc_state *state = machine.driver_data<bionicc_state>();
194   UINT16 *buffered_spriteram = state->m_spriteram->buffer();
193   UINT16 *buffered_spriteram = m_spriteram->buffer();
195194   int offs;
196   gfx_element *gfx = machine.gfx[3];
195   gfx_element *gfx = machine().gfx[3];
197196
198   for (offs = (state->m_spriteram->bytes() - 8) / 2; offs >= 0; offs -= 4)
197   for (offs = (m_spriteram->bytes() - 8) / 2; offs >= 0; offs -= 4)
199198   {
200199      int tile_number = buffered_spriteram[offs] & 0x7ff;
201200      if( tile_number != 0x7ff )
r20741r20742
210209         if (sy > 512 - 16)
211210            sy -= 512;
212211
213         if (state->flip_screen())
212         if (flip_screen())
214213         {
215214            sx = 240 - sx;
216215            sy = 240 - sy;
r20741r20742
233232   m_fg_tilemap->draw(bitmap, cliprect, 1 | TILEMAP_DRAW_LAYER1, 0);   /* nothing in FRONT */
234233   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
235234   m_fg_tilemap->draw(bitmap, cliprect, 0 | TILEMAP_DRAW_LAYER1, 0);
236   draw_sprites(machine(), bitmap, cliprect);
235   draw_sprites(bitmap, cliprect);
237236   m_fg_tilemap->draw(bitmap, cliprect, 0 | TILEMAP_DRAW_LAYER0, 0);
238237   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
239238   return 0;
trunk/src/mame/video/battlex.c
r20741r20742
5858   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(battlex_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
5959}
6060
61static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
61void battlex_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
6262{
63   battlex_state *state = machine.driver_data<battlex_state>();
64   gfx_element *gfx = machine.gfx[1];
65   UINT8 *source = state->m_spriteram;
66   UINT8 *finish = state->m_spriteram + 0x200;
63   gfx_element *gfx = machine().gfx[1];
64   UINT8 *source = m_spriteram;
65   UINT8 *finish = m_spriteram + 0x200;
6766
6867   while (source < finish)
6968   {
r20741r20742
7473      int flipy = source[1] & 0x80;
7574      int flipx = source[1] & 0x40;
7675
77      if (state->flip_screen())
76      if (flip_screen())
7877      {
7978         sx = 240 - sx;
8079         sy = 240 - sy;
r20741r20742
9392{
9493   m_bg_tilemap->set_scrollx(0, m_scroll_lsb | (m_scroll_msb << 8));
9594   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
96   draw_sprites(machine(), bitmap, cliprect);
95   draw_sprites(bitmap, cliprect);
9796
9897   return 0;
9998}
trunk/src/mame/video/alpha68k.c
r20741r20742
88#include "includes/alpha68k.h"
99
1010
11void alpha68k_flipscreen_w( running_machine &machine, int flip )
11void alpha68k_state::alpha68k_flipscreen_w( int flip )
1212{
13   alpha68k_state *state = machine.driver_data<alpha68k_state>();
14   state->m_flipscreen = flip;
13   m_flipscreen = flip;
1514}
1615
17void alpha68k_V_video_bank_w( running_machine &machine, int bank )
16void alpha68k_state::alpha68k_V_video_bank_w( int bank )
1817{
19   alpha68k_state *state = machine.driver_data<alpha68k_state>();
20   state->m_bank_base = bank & 0xf;
18   m_bank_base = bank & 0xf;
2119}
2220
2321WRITE16_MEMBER(alpha68k_state::alpha68k_paletteram_w)
r20741r20742
7068/******************************************************************************/
7169
7270//AT
73static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e )
71void alpha68k_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e )
7472{
75   alpha68k_state *state = machine.driver_data<alpha68k_state>();
76   UINT16 *spriteram = state->m_spriteram;
73   UINT16 *spriteram = m_spriteram;
7774   int offs, mx, my, color, tile, fx, fy, i;
7875
7976   for (offs = s; offs < e; offs += 0x40)
r20741r20742
8582      if (j == 0 && s == 0x7c0)
8683         my++;
8784//ZT
88      if (state->m_flipscreen)
85      if (m_flipscreen)
8986      {
9087         mx = 240 - mx;
9188         my = 240 - my;
r20741r20742
10097         fx = tile & 0x4000;
10198         tile &= 0x3fff;
10299
103         if (state->m_flipscreen)
100         if (m_flipscreen)
104101         {
105102            if (fx) fx = 0; else fx = 1;
106103            if (fy) fy = 0; else fy = 1;
107104         }
108105
109106         if (color)
110            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
107            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
111108               tile,
112109               color,
113110               fx,fy,
114111               mx,my,0);
115112
116         if (state->m_flipscreen)
113         if (m_flipscreen)
117114            my = (my - 16) & 0x1ff;
118115         else
119116            my = (my + 16) & 0x1ff;
r20741r20742
133130
134131   bitmap.fill(2047, cliprect);
135132//AT
136   draw_sprites(machine(), bitmap, cliprect, 0, 0x07c0, 0x0800);
137   draw_sprites(machine(), bitmap, cliprect, 1, 0x0000, 0x0800);
138   draw_sprites(machine(), bitmap, cliprect, 2, 0x0000, 0x0800);
139   draw_sprites(machine(), bitmap, cliprect, 0, 0x0000, 0x07c0);
133   draw_sprites(bitmap, cliprect, 0, 0x07c0, 0x0800);
134   draw_sprites(bitmap, cliprect, 1, 0x0000, 0x0800);
135   draw_sprites(bitmap, cliprect, 2, 0x0000, 0x0800);
136   draw_sprites(bitmap, cliprect, 0, 0x0000, 0x07c0);
140137//ZT
141138   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
142139   return 0;
r20741r20742
213210   }
214211}
215212
216static void draw_sprites_V( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e, int fx_mask, int fy_mask, int sprite_mask )
213void alpha68k_state::draw_sprites_V( bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e, int fx_mask, int fy_mask, int sprite_mask )
217214{
218   alpha68k_state *state = machine.driver_data<alpha68k_state>();
219   UINT16 *spriteram = state->m_spriteram;
215   UINT16 *spriteram = m_spriteram;
220216   int offs, mx, my, color, tile, fx, fy, i;
221217
222218   for (offs = s; offs < e; offs += 0x40)
r20741r20742
229225      if (j == 0 && s == 0x7c0)
230226         my++;
231227//ZT
232      if (state->m_flipscreen)
228      if (m_flipscreen)
233229      {
234230         mx = 240 - mx;
235231         my = 240 - my;
r20741r20742
246242         if (tile > 0x4fff)
247243            continue;
248244
249         if (state->m_flipscreen)
245         if (m_flipscreen)
250246         {
251247            if (fx) fx = 0; else fx = 1;
252248            if (fy) fy = 0; else fy = 1;
253249         }
254250
255251         if (color)
256            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
252            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
257253               tile,
258254               color,
259255               fx,fy,
260256               mx,my,0);
261257
262         if (state->m_flipscreen)
258         if (m_flipscreen)
263259            my = (my - 16) & 0x1ff;
264260         else
265261            my = (my + 16) & 0x1ff;
r20741r20742
282278   /* This appears to be correct priority */
283279   if (m_microcontroller_id == 0x8814) /* Sky Adventure */
284280   {
285      draw_sprites_V(machine(), bitmap, cliprect, 0, 0x07c0, 0x0800, 0, 0x8000, 0x7fff);
286      draw_sprites_V(machine(), bitmap, cliprect, 1, 0x0000, 0x0800, 0, 0x8000, 0x7fff);
281      draw_sprites_V(bitmap, cliprect, 0, 0x07c0, 0x0800, 0, 0x8000, 0x7fff);
282      draw_sprites_V(bitmap, cliprect, 1, 0x0000, 0x0800, 0, 0x8000, 0x7fff);
287283      //AT: *KLUDGE* fixes priest priority in level 1(could be a game bug)
288284      if (spriteram[0x1bde] == 0x24 && (spriteram[0x1bdf] >> 8) == 0x3b)
289285      {
290         draw_sprites_V(machine(), bitmap, cliprect, 2, 0x03c0, 0x0800, 0, 0x8000, 0x7fff);
291         draw_sprites_V(machine(), bitmap, cliprect, 2, 0x0000, 0x03c0, 0, 0x8000, 0x7fff);
286         draw_sprites_V(bitmap, cliprect, 2, 0x03c0, 0x0800, 0, 0x8000, 0x7fff);
287         draw_sprites_V(bitmap, cliprect, 2, 0x0000, 0x03c0, 0, 0x8000, 0x7fff);
292288      }
293289      else
294         draw_sprites_V(machine(), bitmap, cliprect, 2, 0x0000, 0x0800, 0, 0x8000, 0x7fff);
290         draw_sprites_V(bitmap, cliprect, 2, 0x0000, 0x0800, 0, 0x8000, 0x7fff);
295291
296      draw_sprites_V(machine(), bitmap, cliprect, 0, 0x0000, 0x07c0, 0, 0x8000, 0x7fff);
292      draw_sprites_V(bitmap, cliprect, 0, 0x0000, 0x07c0, 0, 0x8000, 0x7fff);
297293   }
298294   else    /* gangwars */
299295   {
300      draw_sprites_V(machine(), bitmap, cliprect, 0, 0x07c0, 0x0800, 0x8000, 0, 0x7fff);
301      draw_sprites_V(machine(), bitmap, cliprect, 1, 0x0000, 0x0800, 0x8000, 0, 0x7fff);
302      draw_sprites_V(machine(), bitmap, cliprect, 2, 0x0000, 0x0800, 0x8000, 0, 0x7fff);
303      draw_sprites_V(machine(), bitmap, cliprect, 0, 0x0000, 0x07c0, 0x8000, 0, 0x7fff);
296      draw_sprites_V(bitmap, cliprect, 0, 0x07c0, 0x0800, 0x8000, 0, 0x7fff);
297      draw_sprites_V(bitmap, cliprect, 1, 0x0000, 0x0800, 0x8000, 0, 0x7fff);
298      draw_sprites_V(bitmap, cliprect, 2, 0x0000, 0x0800, 0x8000, 0, 0x7fff);
299      draw_sprites_V(bitmap, cliprect, 0, 0x0000, 0x07c0, 0x8000, 0, 0x7fff);
304300   }
305301
306302   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
r20741r20742
318314   bitmap.fill(4095, cliprect);
319315
320316   /* This appears to be correct priority */
321   draw_sprites_V(machine(), bitmap, cliprect, 0, 0x07c0, 0x0800, 0x4000, 0x8000, 0x3fff);
322   draw_sprites_V(machine(), bitmap, cliprect, 1, 0x0000, 0x0800, 0x4000, 0x8000, 0x3fff);
323   draw_sprites_V(machine(), bitmap, cliprect, 2, 0x0000, 0x0800, 0x4000, 0x8000, 0x3fff);
324   draw_sprites_V(machine(), bitmap, cliprect, 0, 0x0000, 0x07c0, 0x4000, 0x8000, 0x3fff);
317   draw_sprites_V(bitmap, cliprect, 0, 0x07c0, 0x0800, 0x4000, 0x8000, 0x3fff);
318   draw_sprites_V(bitmap, cliprect, 1, 0x0000, 0x0800, 0x4000, 0x8000, 0x3fff);
319   draw_sprites_V(bitmap, cliprect, 2, 0x0000, 0x0800, 0x4000, 0x8000, 0x3fff);
320   draw_sprites_V(bitmap, cliprect, 0, 0x0000, 0x07c0, 0x4000, 0x8000, 0x3fff);
325321
326322   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
327323   return 0;
r20741r20742
329325
330326/******************************************************************************/
331327//AT
332static void draw_sprites_I( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d, int yshift )
328void alpha68k_state::draw_sprites_I( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d, int yshift )
333329{
334   alpha68k_state *state = machine.driver_data<alpha68k_state>();
335   UINT16 *spriteram = state->m_spriteram;
330   UINT16 *spriteram = m_spriteram;
336331   int data, offs, mx, my, tile, color, fy, i;
337   UINT8 *color_prom = state->memregion("user1")->base();
338   gfx_element *gfx = machine.gfx[0];
332   UINT8 *color_prom = memregion("user1")->base();
333   gfx_element *gfx = machine().gfx[0];
339334
340335   for (offs = 0; offs < 0x400; offs += 0x20)
341336   {
r20741r20742
364359   bitmap.fill(get_black_pen(machine()), cliprect);
365360
366361   /* This appears to be correct priority */
367   draw_sprites_I(machine(), bitmap, cliprect, 2, 0x0800, yshift);
368   draw_sprites_I(machine(), bitmap, cliprect, 3, 0x0c00, yshift);
369   draw_sprites_I(machine(), bitmap, cliprect, 1, 0x0400, yshift);
362   draw_sprites_I(bitmap, cliprect, 2, 0x0800, yshift);
363   draw_sprites_I(bitmap, cliprect, 3, 0x0c00, yshift);
364   draw_sprites_I(bitmap, cliprect, 1, 0x0400, yshift);
370365   return 0;
371366}
372367//ZT
r20741r20742
428423   }
429424}
430425
431static void kyros_video_banking(int *bank, int data)
426void alpha68k_state::kyros_video_banking(int *bank, int data)
432427{
433428   *bank = (data >> 13 & 4) | (data >> 10 & 3);
434429}
435430
436static void jongbou_video_banking(int *bank, int data)
431void alpha68k_state::jongbou_video_banking(int *bank, int data)
437432{
438433   *bank = (data >> 11 & 4) | (data >> 10 & 3);
439434}
440435
441static void kyros_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d )
436void alpha68k_state::kyros_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d )
442437{
443   alpha68k_state *state = machine.driver_data<alpha68k_state>();
444   UINT16 *spriteram = state->m_spriteram;
438   UINT16 *spriteram = m_spriteram;
445439   int offs, mx, my, color, tile, i, bank, fy, fx;
446440   int data;
447   UINT8 *color_prom = state->memregion("user1")->base();
441   UINT8 *color_prom = memregion("user1")->base();
448442
449443//AT
450444   for (offs = 0; offs < 0x400; offs += 0x20)
r20741r20742
453447      my = -(mx >> 8) & 0xff;
454448      mx &= 0xff;
455449
456      if (state->m_flipscreen)
450      if (m_flipscreen)
457451         my = 249 - my;
458452
459453      for (i = 0; i < 0x20; i++)
r20741r20742
467461               fy = data & 0x1000;
468462               fx = 0;
469463
470               if(state->m_flipscreen)
464               if(m_flipscreen)
471465               {
472466                  if (fy) fy = 0; else fy = 1;
473467                  fx = 1;
474468               }
475469
476470               tile = (data >> 3 & 0x400) | (data & 0x3ff);
477               if (state->m_game_id == ALPHA68K_KYROS)
471               if (m_game_id == ALPHA68K_KYROS)
478472                  kyros_video_banking(&bank, data);
479473               else
480474                  jongbou_video_banking(&bank, data);
481475
482               drawgfx_transpen(bitmap, cliprect, machine.gfx[bank], tile, color, fx, fy, mx, my, 0);
476               drawgfx_transpen(bitmap, cliprect, machine().gfx[bank], tile, color, fx, fy, mx, my, 0);
483477            }
484478         }
485479//ZT
486         if (state->m_flipscreen)
480         if (m_flipscreen)
487481            my = (my - 8) & 0xff;
488482         else
489483            my = (my + 8) & 0xff;
r20741r20742
496490   colortable_entry_set_value(machine().colortable, 0x100, *m_videoram & 0xff);
497491   bitmap.fill(0x100, cliprect); //AT
498492
499   kyros_draw_sprites(machine(), bitmap, cliprect, 2, 0x0800);
500   kyros_draw_sprites(machine(), bitmap, cliprect, 3, 0x0c00);
501   kyros_draw_sprites(machine(), bitmap, cliprect, 1, 0x0400);
493   kyros_draw_sprites(bitmap, cliprect, 2, 0x0800);
494   kyros_draw_sprites(bitmap, cliprect, 3, 0x0c00);
495   kyros_draw_sprites(bitmap, cliprect, 1, 0x0400);
502496   return 0;
503497}
504498
505499/******************************************************************************/
506500
507static void sstingry_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d )
501void alpha68k_state::sstingry_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d )
508502{
509503//AT
510   alpha68k_state *state = machine.driver_data<alpha68k_state>();
511   UINT16 *spriteram = state->m_spriteram;
504   UINT16 *spriteram = m_spriteram;
512505   int data, offs, mx, my, color, tile, i, bank, fy, fx;
513506
514507   for (offs = 0; offs < 0x400; offs += 0x20)
r20741r20742
519512      if (mx > 0xf8)
520513         mx -= 0x100;
521514
522      if (state->m_flipscreen)
515      if (m_flipscreen)
523516         my = 249 - my;
524517
525518      for (i = 0; i < 0x20; i++)
r20741r20742
530523            fy = data & 0x1000;
531524            fx = 0;
532525
533            if(state->m_flipscreen)
526            if(m_flipscreen)
534527            {
535528               if (fy) fy = 0; else fy = 1;
536529               fx = 1;
r20741r20742
539532            color = (data >> 7 & 0x18) | (data >> 13 & 7);
540533            tile = data & 0x3ff;
541534            bank = data >> 10 & 3;
542            drawgfx_transpen(bitmap, cliprect, machine.gfx[bank], tile, color, fx, fy, mx, my, 0);
535            drawgfx_transpen(bitmap, cliprect, machine().gfx[bank], tile, color, fx, fy, mx, my, 0);
543536         }
544537//ZT
545         if(state->m_flipscreen)
538         if(m_flipscreen)
546539            my = (my - 8) & 0xff;
547540         else
548541            my = (my + 8) & 0xff;
r20741r20742
555548   colortable_entry_set_value(machine().colortable, 0x100, *m_videoram & 0xff);
556549   bitmap.fill(0x100, cliprect); //AT
557550
558   sstingry_draw_sprites(machine(), bitmap, cliprect, 2, 0x0800);
559   sstingry_draw_sprites(machine(), bitmap, cliprect, 3, 0x0c00);
560   sstingry_draw_sprites(machine(), bitmap, cliprect, 1, 0x0400);
551   sstingry_draw_sprites(bitmap, cliprect, 2, 0x0800);
552   sstingry_draw_sprites(bitmap, cliprect, 3, 0x0c00);
553   sstingry_draw_sprites(bitmap, cliprect, 1, 0x0400);
561554   return 0;
562555}
trunk/src/mame/video/atarisy1.c
r20741r20742
7272   8*8     /* every sprite takes 8 consecutive bytes */
7373};
7474
75
76
7775/*************************************
7876 *
79 *  Prototypes
80 *
81 *************************************/
82
83static void update_timers(running_machine &machine, int scanline);
84static void decode_gfx(running_machine &machine, UINT16 *pflookup, UINT16 *molookup);
85static int get_bank(running_machine &machine, UINT8 prom1, UINT8 prom2, int bpp);
86
87
88
89/*************************************
90 *
9177 *  Tilemap callbacks
9278 *
9379 *************************************/
r20741r20742
165151   int i, size;
166152
167153   /* first decode the graphics */
168   decode_gfx(machine(), m_playfield_lookup, motable);
154   decode_gfx(m_playfield_lookup, motable);
169155
170156   /* initialize the playfield */
171157   m_playfield_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(atarisy1_state::get_playfield_tile_info),this), TILEMAP_SCAN_ROWS,  8,8, 64,64);
r20741r20742
233219
234220   /* motion object bank select */
235221   atarimo_set_bank(0, (newselect >> 3) & 7);
236   update_timers(space.machine(), scanline);
222   state->update_timers(scanline);
237223
238224   /* playfield bank select */
239225   if (diff & 0x0004)
r20741r20742
344330
345331WRITE16_HANDLER( atarisy1_spriteram_w )
346332{
333   atarisy1_state *state = space.machine().driver_data<atarisy1_state>();
347334   int active_bank = atarimo_get_bank(0);
348335   int oldword = atarimo_0_spriteram_r(space, offset, mem_mask);
349336   int newword = oldword;
r20741r20742
358345      {
359346         /* if the timer is in the active bank, update the display list */
360347         atarimo_0_spriteram_w(space, offset, data, 0xffff);
361         update_timers(space.machine(), space.machine().primary_screen->vpos());
348         state->update_timers(space.machine().primary_screen->vpos());
362349      }
363350
364351      /* if we're about to modify data in the active sprite bank, make sure the video is up-to-date */
r20741r20742
402389
403390   /* determine the time of the next one */
404391   m_next_timer_scanline = -1;
405   update_timers(machine(), scanline);
392   update_timers(scanline);
406393}
407394
408395
r20741r20742
427414 *
428415 *************************************/
429416
430static void update_timers(running_machine &machine, int scanline)
417void atarisy1_state::update_timers(int scanline)
431418{
432   atarisy1_state *state = machine.driver_data<atarisy1_state>();
433   address_space &space = state->generic_space();
419   address_space &space = generic_space();
434420   UINT16 mem_mask = 0xffff;
435421   int offset = atarimo_get_bank(0) * 64 * 4;
436422   int link = 0, best = scanline, found = 0;
r20741r20742
475461      best = -1;
476462
477463   /* update the timer */
478   if (best != state->m_next_timer_scanline)
464   if (best != m_next_timer_scanline)
479465   {
480      state->m_next_timer_scanline = best;
466      m_next_timer_scanline = best;
481467
482468      /* set a new one */
483469      if (best != -1)
484         state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos(best), best);
470         m_scanline_timer->adjust(machine().primary_screen->time_until_pos(best), best);
485471      else
486         state->m_scanline_timer->reset();
472         m_scanline_timer->reset();
487473   }
488474}
489475
r20741r20742
548534 *
549535 *************************************/
550536
551static void decode_gfx(running_machine &machine, UINT16 *pflookup, UINT16 *molookup)
537void atarisy1_state::decode_gfx(UINT16 *pflookup, UINT16 *molookup)
552538{
553   atarisy1_state *state = machine.driver_data<atarisy1_state>();
554   UINT8 *prom1 = &state->memregion("proms")->u8(0x000);
555   UINT8 *prom2 = &state->memregion("proms")->u8(0x200);
539   UINT8 *prom1 = &memregion("proms")->u8(0x000);
540   UINT8 *prom2 = &memregion("proms")->u8(0x200);
556541   int obj, i;
557542
558543   /* reset the globals */
559   memset(&state->m_bank_gfx[0][0], 0, sizeof(state->m_bank_gfx));
544   memset(&m_bank_gfx[0][0], 0, sizeof(m_bank_gfx));
560545
561546   /* loop for two sets of objects */
562547   for (obj = 0; obj < 2; obj++)
r20741r20742
579564         offset = *prom1 & PROM1_OFFSET_MASK;
580565
581566         /* determine the bank */
582         bank = get_bank(machine, *prom1, *prom2, bpp);
567         bank = get_bank(*prom1, *prom2, bpp);
583568
584569         /* set the value */
585570         if (obj == 0)
r20741r20742
611596 *
612597 *************************************/
613598
614static int get_bank(running_machine &machine, UINT8 prom1, UINT8 prom2, int bpp)
599int atarisy1_state::get_bank(UINT8 prom1, UINT8 prom2, int bpp)
615600{
616   atarisy1_state *state = machine.driver_data<atarisy1_state>();
617601   const UINT8 *srcdata;
618602   int bank_index, gfx_index;
619603
r20741r20742
639623      return 0;
640624
641625   /* find the bank */
642   if (state->m_bank_gfx[bpp - 4][bank_index])
643      return state->m_bank_gfx[bpp - 4][bank_index];
626   if (m_bank_gfx[bpp - 4][bank_index])
627      return m_bank_gfx[bpp - 4][bank_index];
644628
645629   /* if the bank is out of range, call it 0 */
646   memory_region *tiles = machine.root_device().memregion("tiles");
630   memory_region *tiles = machine().root_device().memregion("tiles");
647631   if (0x80000 * (bank_index - 1) >= tiles->bytes())
648632      return 0;
649633
650634   /* don't have one? let's make it ... first find any empty slot */
651635   for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++)
652      if (machine.gfx[gfx_index] == NULL)
636      if (machine().gfx[gfx_index] == NULL)
653637         break;
654638   assert(gfx_index != MAX_GFX_ELEMENTS);
655639
r20741r20742
658642   switch (bpp)
659643   {
660644   case 4:
661      machine.gfx[gfx_index] = auto_alloc(machine, gfx_element(machine, objlayout_4bpp, srcdata, 0x40, 256));
645      machine().gfx[gfx_index] = auto_alloc(machine(), gfx_element(machine(), objlayout_4bpp, srcdata, 0x40, 256));
662646      break;
663647
664648   case 5:
665      machine.gfx[gfx_index] = auto_alloc(machine, gfx_element(machine, objlayout_5bpp, srcdata, 0x40, 256));
649      machine().gfx[gfx_index] = auto_alloc(machine(), gfx_element(machine(), objlayout_5bpp, srcdata, 0x40, 256));
666650      break;
667651
668652   case 6:
669      machine.gfx[gfx_index] = auto_alloc(machine, gfx_element(machine, objlayout_6bpp, srcdata, 0x40, 256));
653      machine().gfx[gfx_index] = auto_alloc(machine(), gfx_element(machine(), objlayout_6bpp, srcdata, 0x40, 256));
670654      break;
671655
672656   default:
r20741r20742
674658   }
675659
676660   /* set the color information */
677   machine.gfx[gfx_index]->set_granularity(8);
678   state->m_bank_color_shift[gfx_index] = bpp - 3;
661   machine().gfx[gfx_index]->set_granularity(8);
662   m_bank_color_shift[gfx_index] = bpp - 3;
679663
680664   /* set the entry and return it */
681   return state->m_bank_gfx[bpp - 4][bank_index] = gfx_index;
665   return m_bank_gfx[bpp - 4][bank_index] = gfx_index;
682666}
trunk/src/mame/video/aquarium.c
r20741r20742
44#include "includes/aquarium.h"
55
66/* gcpinbal.c modified */
7static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
7void aquarium_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
88{
9   aquarium_state *state = machine.driver_data<aquarium_state>();
109   int offs, chain_pos;
1110   int x, y, curx, cury;
1211   UINT8 col, flipx, flipy, chain;
1312   UINT16 code;
1413
15   for (offs = 0; offs < state->m_spriteram.bytes() / 2; offs += 8)
14   for (offs = 0; offs < m_spriteram.bytes() / 2; offs += 8)
1615   {
17      code = ((state->m_spriteram[offs + 5]) & 0xff) + (((state->m_spriteram[offs + 6]) & 0xff) << 8);
16      code = ((m_spriteram[offs + 5]) & 0xff) + (((m_spriteram[offs + 6]) & 0xff) << 8);
1817      code &= 0x3fff;
1918
20      if (!(state->m_spriteram[offs + 4] &0x80))  /* active sprite ? */
19      if (!(m_spriteram[offs + 4] &0x80))  /* active sprite ? */
2120      {
22         x = ((state->m_spriteram[offs + 0]) &0xff) + (((state->m_spriteram[offs + 1]) & 0xff) << 8);
23         y = ((state->m_spriteram[offs + 2]) &0xff) + (((state->m_spriteram[offs + 3]) & 0xff) << 8);
21         x = ((m_spriteram[offs + 0]) &0xff) + (((m_spriteram[offs + 1]) & 0xff) << 8);
22         y = ((m_spriteram[offs + 2]) &0xff) + (((m_spriteram[offs + 3]) & 0xff) << 8);
2423
2524         /* Treat coords as signed */
2625         if (x & 0x8000)  x -= 0x10000;
2726         if (y & 0x8000)  y -= 0x10000;
2827
29         col = ((state->m_spriteram[offs + 7]) & 0x0f);
30         chain = (state->m_spriteram[offs + 4]) & 0x07;
31         flipy = (state->m_spriteram[offs + 4]) & 0x10;
32         flipx = (state->m_spriteram[offs + 4]) & 0x20;
28         col = ((m_spriteram[offs + 7]) & 0x0f);
29         chain = (m_spriteram[offs + 4]) & 0x07;
30         flipy = (m_spriteram[offs + 4]) & 0x10;
31         flipx = (m_spriteram[offs + 4]) & 0x20;
3332
3433         curx = x;
3534         cury = y;
3635
37         if (((state->m_spriteram[offs + 4]) & 0x08) && flipy)
36         if (((m_spriteram[offs + 4]) & 0x08) && flipy)
3837            cury += (chain * 16);
3938
40         if (!(((state->m_spriteram[offs + 4]) & 0x08)) && flipx)
39         if (!(((m_spriteram[offs + 4]) & 0x08)) && flipx)
4140            curx += (chain * 16);
4241
4342
4443         for (chain_pos = chain; chain_pos >= 0; chain_pos--)
4544         {
46            drawgfx_transpen(bitmap, cliprect,machine.gfx[0],
45            drawgfx_transpen(bitmap, cliprect,machine().gfx[0],
4746                  code,
4847                  col,
4948                  flipx, flipy,
5049                  curx,cury,0);
5150
5251            /* wrap around y */
53            drawgfx_transpen(bitmap, cliprect,machine.gfx[0],
52            drawgfx_transpen(bitmap, cliprect,machine().gfx[0],
5453                  code,
5554                  col,
5655                  flipx, flipy,
r20741r20742
5857
5958            code++;
6059
61            if ((state->m_spriteram[offs + 4]) &0x08)   /* Y chain */
60            if ((m_spriteram[offs + 4]) &0x08)   /* Y chain */
6261            {
6362               if (flipy)
6463                  cury -= 16;
r20741r20742
163162   m_bak_tilemap->draw(bitmap, cliprect, 0, 0);
164163   m_mid_tilemap->draw(bitmap, cliprect, 0, 0);
165164
166   draw_sprites(machine(), bitmap, cliprect, 16);
165   draw_sprites(bitmap, cliprect, 16);
167166
168167   m_bak_tilemap->draw(bitmap, cliprect, 1, 0);
169168   m_mid_tilemap->draw(bitmap, cliprect, 1, 0);
trunk/src/mame/video/angelkds.c
r20741r20742
119119
120120*/
121121
122static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int enable_n)
122void angelkds_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int enable_n)
123123{
124   angelkds_state *state = machine.driver_data<angelkds_state>();
125   const UINT8 *source = state->m_spriteram + 0x100 - 4;
126   const UINT8 *finish = state->m_spriteram;
127   gfx_element *gfx = machine.gfx[3];
124   const UINT8 *source = m_spriteram + 0x100 - 4;
125   const UINT8 *finish = m_spriteram;
126   gfx_element *gfx = machine().gfx[3];
128127
129128   while (source >= finish)
130129   {
r20741r20742
261260   if ((m_layer_ctrl & 0x80) == 0x00)
262261      m_bgtop_tilemap->draw(bitmap, clip, 0, 0);
263262
264   draw_sprites(machine(), bitmap, clip, 0x80);
263   draw_sprites(bitmap, clip, 0x80);
265264
266265   if ((m_layer_ctrl & 0x20) == 0x00)
267266      m_tx_tilemap->draw(bitmap, clip, 0, 0);
r20741r20742
272271   if ((m_layer_ctrl & 0x40) == 0x00)
273272      m_bgbot_tilemap->draw(bitmap, clip, 0, 0);
274273
275   draw_sprites(machine(), bitmap, clip, 0x40);
274   draw_sprites(bitmap, clip, 0x40);
276275
277276   if ((m_layer_ctrl & 0x20) == 0x00)
278277      m_tx_tilemap->draw(bitmap, clip, 0, 0);
trunk/src/mame/video/bagman.c
r20741r20742
107107}
108108
109109
110static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
110void bagman_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
111111{
112   bagman_state *state = machine.driver_data<bagman_state>();
113   UINT8 *spriteram = state->m_spriteram;
112   UINT8 *spriteram = m_spriteram;
114113   int offs;
115114
116   for (offs = state->m_spriteram.bytes() - 4;offs >= 0;offs -= 4)
115   for (offs = m_spriteram.bytes() - 4;offs >= 0;offs -= 4)
117116   {
118117      int sx,sy,flipx,flipy;
119118
r20741r20742
121120      sy = 255 - spriteram[offs + 2] - 16;
122121      flipx = spriteram[offs] & 0x40;
123122      flipy = spriteram[offs] & 0x80;
124      if (state->flip_screen_x())
123      if (flip_screen_x())
125124      {
126125         sx = bitmap.width() - sx - 15;
127126         flipx = !flipx;
128127      }
129      if (state->flip_screen_y())
128      if (flip_screen_y())
130129      {
131130         sy = bitmap.height() - sy - 15;
132131         flipy = !flipy;
r20741r20742
134133
135134      if (spriteram[offs + 2] && spriteram[offs + 3])
136135         drawgfx_transpen(bitmap,
137               cliprect,machine.gfx[1],
136               cliprect,machine().gfx[1],
138137               (spriteram[offs] & 0x3f) + 2 * (spriteram[offs + 1] & 0x20),
139138               spriteram[offs + 1] & 0x1f,
140139               flipx,flipy,
r20741r20742
149148      return 0;
150149
151150   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
152   draw_sprites(machine(), bitmap, cliprect);
151   draw_sprites(bitmap, cliprect);
153152   return 0;
154153}
trunk/src/mame/video/bigevglf.c
r20741r20742
6464   save_pointer(NAME(m_vidram), 0x100 * 0x100 * 4);
6565}
6666
67static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
67void bigevglf_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
6868{
69   bigevglf_state *state = machine.driver_data<bigevglf_state>();
7069   int i, j;
7170   for (i = 0xc0-4; i >= 0; i-= 4)
7271   {
7372      int code, sx, sy;
74      code = state->m_spriteram2[i + 1];
75      sx = state->m_spriteram2[i + 3];
76      sy = 200 - state->m_spriteram2[i];
73      code = m_spriteram2[i + 1];
74      sx = m_spriteram2[i + 3];
75      sy = 200 - m_spriteram2[i];
7776      for (j = 0; j < 16; j++)
78         drawgfx_transpen(bitmap, cliprect, machine.gfx[0],
79            state->m_spriteram1[(code << 4) + j] + ((state->m_spriteram1[0x400 + (code << 4) + j] & 0xf) << 8),
80            state->m_spriteram2[i + 2] & 0xf,
77         drawgfx_transpen(bitmap, cliprect, machine().gfx[0],
78            m_spriteram1[(code << 4) + j] + ((m_spriteram1[0x400 + (code << 4) + j] & 0xf) << 8),
79            m_spriteram2[i + 2] & 0xf,
8180            0,0,
8281            sx + ((j & 1) << 3), sy + ((j >> 1) << 3), 0);
8382   }
r20741r20742
8685UINT32 bigevglf_state::screen_update_bigevglf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
8786{
8887   copybitmap(bitmap, m_tmp_bitmap[m_plane_visible], 0, 0, 0, 0, cliprect);
89   draw_sprites(machine(), bitmap, cliprect);
88   draw_sprites(bitmap, cliprect);
9089   return 0;
9190}
trunk/src/mame/video/1942.c
r20741r20742
187187
188188***************************************************************************/
189189
190static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
190void _1942_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
191191{
192   _1942_state *state = machine.driver_data<_1942_state>();
193192   int offs;
194193
195   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
194   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
196195   {
197196      int i, code, col, sx, sy, dir;
198197
199      code = (state->m_spriteram[offs] & 0x7f) + 4 * (state->m_spriteram[offs + 1] & 0x20)
200            + 2 * (state->m_spriteram[offs] & 0x80);
201      col = state->m_spriteram[offs + 1] & 0x0f;
202      sx = state->m_spriteram[offs + 3] - 0x10 * (state->m_spriteram[offs + 1] & 0x10);
203      sy = state->m_spriteram[offs + 2];
198      code = (m_spriteram[offs] & 0x7f) + 4 * (m_spriteram[offs + 1] & 0x20)
199            + 2 * (m_spriteram[offs] & 0x80);
200      col = m_spriteram[offs + 1] & 0x0f;
201      sx = m_spriteram[offs + 3] - 0x10 * (m_spriteram[offs + 1] & 0x10);
202      sy = m_spriteram[offs + 2];
204203      dir = 1;
205204
206      if (state->flip_screen())
205      if (flip_screen())
207206      {
208207         sx = 240 - sx;
209208         sy = 240 - sy;
r20741r20742
211210      }
212211
213212      /* handle double / quadruple height */
214      i = (state->m_spriteram[offs + 1] & 0xc0) >> 6;
213      i = (m_spriteram[offs + 1] & 0xc0) >> 6;
215214      if (i == 2)
216215         i = 3;
217216
218217      do
219218      {
220         drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
219         drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
221220               code + i,col,
222               state->flip_screen(),state->flip_screen(),
221               flip_screen(),flip_screen(),
223222               sx,sy + 16 * i * dir,15);
224223
225224         i--;
r20741r20742
232231UINT32 _1942_state::screen_update_1942(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
233232{
234233   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
235   draw_sprites(machine(), bitmap, cliprect);
234   draw_sprites(bitmap, cliprect);
236235   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
237236   return 0;
238237}
trunk/src/mame/video/bloodbro.c
r20741r20742
138138   -------X XXXXXXXX
139139   -------- YYYYYYYY */
140140
141static void bloodbro_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
141void bloodbro_state::bloodbro_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
142142{
143   bloodbro_state *state = machine.driver_data<bloodbro_state>();
144   UINT16 *spriteram16 = state->m_spriteram;
143   UINT16 *spriteram16 = m_spriteram;
145144   int offs;
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,x,y,width,height,attributes,tile_number,color,flipx,flipy,pri_mask;
149148
r20741r20742
167166      {
168167         for (y = 0;y <= height;y++)
169168         {
170            pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3],
169            pdrawgfx_transpen(bitmap,cliprect,machine().gfx[3],
171170                  tile_number++,
172171                  color,
173172                  flipx,flipy,
174173                  flipx ? (sx + 16*(width-x)) : (sx + 16*x),flipy ? (sy + 16*(height-y)) : (sy + 16*y),
175                  machine.priority_bitmap,
174                  machine().priority_bitmap,
176175                  pri_mask,15);
177176         }
178177      }
r20741r20742
187186   -------X XXXXXXXX
188187*/
189188
190static void weststry_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
189void bloodbro_state::weststry_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
191190{
192   bloodbro_state *state = machine.driver_data<bloodbro_state>();
193   UINT16 *spriteram16 = state->m_spriteram;
191   UINT16 *spriteram16 = m_spriteram;
194192   int offs;
195193
196194   /* TODO: the last two entries are not sprites - control registers? */
197   for (offs = 0;offs < state->m_spriteram.bytes()/2 - 8;offs += 4)
195   for (offs = 0;offs < m_spriteram.bytes()/2 - 8;offs += 4)
198196   {
199197      int data = spriteram16[offs+2];
200198      int data0 = spriteram16[offs+0];
r20741r20742
213211      /* Remap code 0x800 <-> 0x1000 */
214212      code = (code&0x7ff) | ((code&0x800)<<1) | ((code&0x1000)>>1);
215213
216      pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3],
214      pdrawgfx_transpen(bitmap,cliprect,machine().gfx[3],
217215            code,
218216            color,
219217            flipx,flipy,
220218            sx,sy,
221            machine.priority_bitmap,
219            machine().priority_bitmap,
222220            pri_mask,15);
223221   }
224222}
r20741r20742
236234
237235   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
238236   m_fg_tilemap->draw(bitmap, cliprect, 0,1);
239   bloodbro_draw_sprites(machine(),bitmap,cliprect);
237   bloodbro_draw_sprites(bitmap,cliprect);
240238   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
241239   return 0;
242240}
r20741r20742
252250
253251   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
254252   m_fg_tilemap->draw(bitmap, cliprect, 0,1);
255   weststry_draw_sprites(machine(),bitmap,cliprect);
253   weststry_draw_sprites(bitmap,cliprect);
256254   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
257255   return 0;
258256}
r20741r20742
269267
270268   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
271269   m_fg_tilemap->draw(bitmap, cliprect, 0,1);
272   bloodbro_draw_sprites(machine(),bitmap,cliprect);
270   bloodbro_draw_sprites(bitmap,cliprect);
273271   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
274272   return 0;
275273}
trunk/src/mame/video/bombjack.c
r20741r20742
6868   m_fg_tilemap->set_transparent_pen(0);
6969}
7070
71static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
71void bombjack_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
7272{
73   bombjack_state *state = machine.driver_data<bombjack_state>();
7473   int offs;
7574
76   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
75   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
7776   {
7877/*
7978 abbbbbbb cdefgggg hhhhhhhh iiiiiiii
r20741r20742
9190      int sx,sy,flipx,flipy;
9291
9392
94      sx = state->m_spriteram[offs + 3];
93      sx = m_spriteram[offs + 3];
9594
96      if (state->m_spriteram[offs] & 0x80)
97         sy = 225 - state->m_spriteram[offs + 2];
95      if (m_spriteram[offs] & 0x80)
96         sy = 225 - m_spriteram[offs + 2];
9897      else
99         sy = 241 - state->m_spriteram[offs + 2];
98         sy = 241 - m_spriteram[offs + 2];
10099
101      flipx = state->m_spriteram[offs + 1] & 0x40;
102      flipy = state->m_spriteram[offs + 1] & 0x80;
100      flipx = m_spriteram[offs + 1] & 0x40;
101      flipy = m_spriteram[offs + 1] & 0x80;
103102
104      if (state->flip_screen())
103      if (flip_screen())
105104      {
106         if (state->m_spriteram[offs + 1] & 0x20)
105         if (m_spriteram[offs + 1] & 0x20)
107106         {
108107            sx = 224 - sx;
109108            sy = 224 - sy;
r20741r20742
117116         flipy = !flipy;
118117      }
119118
120      drawgfx_transpen(bitmap,cliprect,machine.gfx[(state->m_spriteram[offs] & 0x80) ? 3 : 2],
121            state->m_spriteram[offs] & 0x7f,
122            state->m_spriteram[offs + 1] & 0x0f,
119      drawgfx_transpen(bitmap,cliprect,machine().gfx[(m_spriteram[offs] & 0x80) ? 3 : 2],
120            m_spriteram[offs] & 0x7f,
121            m_spriteram[offs + 1] & 0x0f,
123122            flipx,flipy,
124123            sx,sy,0);
125124   }
r20741r20742
129128{
130129   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
131130   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
132   draw_sprites(machine(), bitmap, cliprect);
131   draw_sprites(bitmap, cliprect);
133132   return 0;
134133}
trunk/src/mame/video/battlera.c
r20741r20742
232232
233233/******************************************************************************/
234234
235static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &clip,int pri)
235void battlera_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &clip,int pri)
236236{
237   battlera_state *state = machine.driver_data<battlera_state>();
238237   int offs,my,mx,code,code2,fx,fy,cgy=0,cgx,colour,i,yinc;
239238
240239   /* Draw sprites, starting at SATB, draw in _reverse_ order */
241   for (offs=(state->m_HuC6270_registers[19]<<1)+0x200-8; offs>=(state->m_HuC6270_registers[19]<<1); offs-=8)
240   for (offs=(m_HuC6270_registers[19]<<1)+0x200-8; offs>=(m_HuC6270_registers[19]<<1); offs-=8)
242241   {
243      if ((state->m_HuC6270_vram[offs+7]&0x80) && !pri) continue;
244      if (!(state->m_HuC6270_vram[offs+7]&0x80) && pri) continue;
242      if ((m_HuC6270_vram[offs+7]&0x80) && !pri) continue;
243      if (!(m_HuC6270_vram[offs+7]&0x80) && pri) continue;
245244
246      code=state->m_HuC6270_vram[offs+5] + (state->m_HuC6270_vram[offs+4]<<8);
245      code=m_HuC6270_vram[offs+5] + (m_HuC6270_vram[offs+4]<<8);
247246      code=code>>1;
248247
249      my=state->m_HuC6270_vram[offs+1] + (state->m_HuC6270_vram[offs+0]<<8);
250      mx=state->m_HuC6270_vram[offs+3] + (state->m_HuC6270_vram[offs+2]<<8);
248      my=m_HuC6270_vram[offs+1] + (m_HuC6270_vram[offs+0]<<8);
249      mx=m_HuC6270_vram[offs+3] + (m_HuC6270_vram[offs+2]<<8);
251250
252251      mx-=32;
253252      my-=57;
254253
255      fx=state->m_HuC6270_vram[offs+6]&0x8;
256      fy=state->m_HuC6270_vram[offs+6]&0x80;
257      cgx=state->m_HuC6270_vram[offs+6]&1;
258      colour=state->m_HuC6270_vram[offs+7]&0xf;
254      fx=m_HuC6270_vram[offs+6]&0x8;
255      fy=m_HuC6270_vram[offs+6]&0x80;
256      cgx=m_HuC6270_vram[offs+6]&1;
257      colour=m_HuC6270_vram[offs+7]&0xf;
259258
260      switch ((state->m_HuC6270_vram[offs+6]>>4)&3) {
259      switch ((m_HuC6270_vram[offs+6]>>4)&3) {
261260      case 0: cgy=1; break;
262261      case 1: cgy=2; break;
263262      case 2: cgy=0; break; /* Illegal */
r20741r20742
273272      if (fy) { my += 16*(cgy-1); yinc = -16; } /* Swap tile order on Y flips */
274273
275274      for (i=0; i<cgy; i++) {
276         drawgfx_transpen(bitmap,clip,machine.gfx[1],
275         drawgfx_transpen(bitmap,clip,machine().gfx[1],
277276            code,
278277            colour,
279278            fx,fy,
280279            mx,my,0);
281280
282281         if (cgx)
283            drawgfx_transpen(bitmap,clip,machine.gfx[1],
282            drawgfx_transpen(bitmap,clip,machine().gfx[1],
284283                  code2,
285284                  colour,
286285                  fx,fy,
r20741r20742
346345   /* Todo:  Background enable (not used anyway) */
347346
348347   /* Render low priority sprites, if enabled */
349   if (m_sb_enable) draw_sprites(machine(),bitmap,cliprect,0);
348   if (m_sb_enable) draw_sprites(bitmap,cliprect,0);
350349
351350   /* Render background over sprites */
352351   copyscrollbitmap_trans(bitmap,*m_front_bitmap,1,&scrollx,1,&scrolly,cliprect,256);
353352
354353   /* Render high priority sprites, if enabled */
355   if (m_sb_enable) draw_sprites(machine(),bitmap,cliprect,1);
354   if (m_sb_enable) draw_sprites(bitmap,cliprect,1);
356355
357356   return 0;
358357}
trunk/src/mame/video/astrocde.c
r20741r20742
2222#define VERT_OFFSET     (22)                /* pixels from top of screen to top of game area */
2323#define HORZ_OFFSET     (16)                /* pixels from left of screen to left of game area */
2424
25
26
2725/*************************************
2826 *
29 *  Function prototypes
30 *
31 *************************************/
32
33static void init_savestate(running_machine &machine);
34
35
36static void init_sparklestar(running_machine &machine);
37
38
39
40/*************************************
41 *
4227 *  Scanline conversion
4328 *
4429 *************************************/
4530
46INLINE int mame_vpos_to_astrocade_vpos(int scanline)
31inline int astrocde_state::mame_vpos_to_astrocade_vpos(int scanline)
4732{
4833   scanline -= VERT_OFFSET;
4934   if (scanline < 0)
r20741r20742
168153   m_intoff_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(astrocde_state::interrupt_off),this));
169154
170155   /* register for save states */
171   init_savestate(machine());
156   init_savestate();
172157
173158   /* initialize the sparkle and stars */
174159   if (m_video_config & AC_STARS)
175      init_sparklestar(machine());
160      init_sparklestar();
176161}
177162
178163
r20741r20742
187172   m_profpac_videoram = auto_alloc_array(machine(), UINT16, 0x4000 * 4);
188173
189174   /* register for save states */
190   init_savestate(machine());
175   init_savestate();
191176
192177   /* register our specific save state data */
193178   state_save_register_global_pointer(machine(), m_profpac_videoram, 0x4000 * 4);
r20741r20742
204189}
205190
206191
207static void init_savestate(running_machine &machine)
192void astrocde_state::init_savestate()
208193{
209   astrocde_state *state = machine.driver_data<astrocde_state>();
210   state_save_register_global_array(machine, state->m_sparkle);
194   state_save_register_global_array(machine(), m_sparkle);
211195
212   state_save_register_global(machine, state->m_interrupt_enabl);
213   state_save_register_global(machine, state->m_interrupt_vector);
214   state_save_register_global(machine, state->m_interrupt_scanline);
215   state_save_register_global(machine, state->m_vertical_feedback);
216   state_save_register_global(machine, state->m_horizontal_feedback);
196   state_save_register_global(machine(), m_interrupt_enabl);
197   state_save_register_global(machine(), m_interrupt_vector);
198   state_save_register_global(machine(), m_interrupt_scanline);
199   state_save_register_global(machine(), m_vertical_feedback);
200   state_save_register_global(machine(), m_horizontal_feedback);
217201
218   state_save_register_global_array(machine, state->m_colors);
219   state_save_register_global(machine, state->m_colorsplit);
220   state_save_register_global(machine, state->m_bgdata);
221   state_save_register_global(machine, state->m_vblank);
222   state_save_register_global(machine, state->m_video_mode);
202   state_save_register_global_array(machine(), m_colors);
203   state_save_register_global(machine(), m_colorsplit);
204   state_save_register_global(machine(), m_bgdata);
205   state_save_register_global(machine(), m_vblank);
206   state_save_register_global(machine(), m_video_mode);
223207
224   state_save_register_global_array(machine, state->m_funcgen_expand_color);
225   state_save_register_global(machine, state->m_funcgen_control);
226   state_save_register_global(machine, state->m_funcgen_expand_count);
227   state_save_register_global(machine, state->m_funcgen_rotate_count);
228   state_save_register_global_array(machine, state->m_funcgen_rotate_data);
229   state_save_register_global(machine, state->m_funcgen_shift_prev_data);
230   state_save_register_global(machine, state->m_funcgen_intercept);
208   state_save_register_global_array(machine(), m_funcgen_expand_color);
209   state_save_register_global(machine(), m_funcgen_control);
210   state_save_register_global(machine(), m_funcgen_expand_count);
211   state_save_register_global(machine(), m_funcgen_rotate_count);
212   state_save_register_global_array(machine(), m_funcgen_rotate_data);
213   state_save_register_global(machine(), m_funcgen_shift_prev_data);
214   state_save_register_global(machine(), m_funcgen_intercept);
231215
232   state_save_register_global(machine, state->m_pattern_source);
233   state_save_register_global(machine, state->m_pattern_mode);
234   state_save_register_global(machine, state->m_pattern_dest);
235   state_save_register_global(machine, state->m_pattern_skip);
236   state_save_register_global(machine, state->m_pattern_width);
237   state_save_register_global(machine, state->m_pattern_height);
216   state_save_register_global(machine(), m_pattern_source);
217   state_save_register_global(machine(), m_pattern_mode);
218   state_save_register_global(machine(), m_pattern_dest);
219   state_save_register_global(machine(), m_pattern_skip);
220   state_save_register_global(machine(), m_pattern_width);
221   state_save_register_global(machine(), m_pattern_height);
238222}
239223
240224
r20741r20742
377361}
378362
379363
380static void astrocade_trigger_lightpen(running_machine &machine, UINT8 vfeedback, UINT8 hfeedback)
364void astrocde_state::astrocade_trigger_lightpen(UINT8 vfeedback, UINT8 hfeedback)
381365{
382   astrocde_state *state = machine.driver_data<astrocde_state>();
383366   /* both bits 1 and 4 enable lightpen interrupts; bit 4 enables them even in horizontal */
384367   /* blanking regions; we treat them both the same here */
385   if ((state->m_interrupt_enabl & 0x12) != 0)
368   if ((m_interrupt_enabl & 0x12) != 0)
386369   {
387370      /* bit 0 controls the interrupt mode: mode 0 means assert until acknowledged */
388      if ((state->m_interrupt_enabl & 0x01) == 0)
371      if ((m_interrupt_enabl & 0x01) == 0)
389372      {
390         machine.device("maincpu")->execute().set_input_line_and_vector(0, HOLD_LINE, state->m_interrupt_vector & 0xf0);
391         state->m_intoff_timer->adjust(machine.primary_screen->time_until_pos(vfeedback));
373         machine().device("maincpu")->execute().set_input_line_and_vector(0, HOLD_LINE, m_interrupt_vector & 0xf0);
374         m_intoff_timer->adjust(machine().primary_screen->time_until_pos(vfeedback));
392375      }
393376
394377      /* mode 1 means assert for 1 instruction */
395378      else
396379      {
397         machine.device("maincpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, state->m_interrupt_vector & 0xf0);
398         state->m_intoff_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(1));
380         machine().device("maincpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, m_interrupt_vector & 0xf0);
381         m_intoff_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(1));
399382      }
400383
401384      /* latch the feedback registers */
402      state->m_vertical_feedback = vfeedback;
403      state->m_horizontal_feedback = hfeedback;
385      m_vertical_feedback = vfeedback;
386      m_horizontal_feedback = hfeedback;
404387   }
405388}
406389
r20741r20742
441424
442425   /* on some games, the horizontal drive line is conected to the lightpen interrupt */
443426   else if (m_video_config & AC_LIGHTPEN_INTS)
444      astrocade_trigger_lightpen(machine(), astrocade_scanline, 8);
427      astrocade_trigger_lightpen(astrocade_scanline, 8);
445428
446429   /* advance to the next scanline */
447430   scanline++;
r20741r20742
706689 *
707690 *************************************/
708691
709INLINE void increment_source(astrocde_state *state, UINT8 curwidth, UINT8 *u13ff)
692inline void astrocde_state::increment_source(UINT8 curwidth, UINT8 *u13ff)
710693{
711694   /* if the flip-flop at U13 is high and mode.d2 is 1 we can increment */
712695   /* however, if mode.d3 is set and we're on the last byte of a row, the increment is suppressed */
713   if (*u13ff && (state->m_pattern_mode & 0x04) != 0 && (curwidth != 0 || (state->m_pattern_mode & 0x08) == 0))
714      state->m_pattern_source++;
696   if (*u13ff && (m_pattern_mode & 0x04) != 0 && (curwidth != 0 || (m_pattern_mode & 0x08) == 0))
697      m_pattern_source++;
715698
716699   /* if mode.d1 is 1, toggle the flip-flop; otherwise leave it preset */
717   if ((state->m_pattern_mode & 0x02) != 0)
700   if ((m_pattern_mode & 0x02) != 0)
718701      *u13ff ^= 1;
719702}
720703
721704
722INLINE void increment_dest(astrocde_state *state, UINT8 curwidth)
705inline void astrocde_state::increment_dest(UINT8 curwidth)
723706{
724707   /* increment is suppressed for the last byte in a row */
725708   if (curwidth != 0)
726709   {
727710      /* if mode.d5 is 1, we increment */
728      if ((state->m_pattern_mode & 0x20) != 0)
729         state->m_pattern_dest++;
711      if ((m_pattern_mode & 0x20) != 0)
712         m_pattern_dest++;
730713
731714      /* otherwise, we decrement */
732715      else
733         state->m_pattern_dest--;
716         m_pattern_dest--;
734717   }
735718}
736719
737720
738static void execute_blit(address_space &space)
721void astrocde_state::execute_blit(address_space &space)
739722{
740   astrocde_state *state = space.machine().driver_data<astrocde_state>();
741723   /*
742       state->m_pattern_source = counter set U7/U16/U25/U34
743       state->m_pattern_dest = counter set U9/U18/U30/U39
744       state->m_pattern_mode = latch U21
745       state->m_pattern_skip = latch set U30/U39
746       state->m_pattern_width = latch set U32/U41
747       state->m_pattern_height = counter set U31/U40
724       m_pattern_source = counter set U7/U16/U25/U34
725       m_pattern_dest = counter set U9/U18/U30/U39
726       m_pattern_mode = latch U21
727       m_pattern_skip = latch set U30/U39
728       m_pattern_width = latch set U32/U41
729       m_pattern_height = counter set U31/U40
748730
749       state->m_pattern_mode bits:
731       m_pattern_mode bits:
750732           d0 = direction (0 = read from src, write to dest, 1 = read from dest, write to src)
751733           d1 = expand (0 = increment src each pixel, 1 = increment src every other pixel)
752734           d2 = constant (0 = never increment src, 1 = normal src increment)
r20741r20742
760742   int cycles = 0;
761743
762744/*  logerror("Blit: src=%04X mode=%02X dest=%04X skip=%02X width=%02X height=%02X\n",
763            state->m_pattern_source, state->m_pattern_mode, state->m_pattern_dest, state->m_pattern_skip, state->m_pattern_width, state->m_pattern_height);*/
745            m_pattern_source, m_pattern_mode, m_pattern_dest, m_pattern_skip, m_pattern_width, m_pattern_height);*/
764746
765747   /* flip-flop at U13 is cleared at the beginning */
766748   u13ff = 0;
767749
768750   /* it is also forced preset if mode.d1 == 0 */
769   if ((state->m_pattern_mode & 0x02) == 0)
751   if ((m_pattern_mode & 0x02) == 0)
770752      u13ff = 1;
771753
772754   /* loop over height */
r20741r20742
775757      UINT16 carry;
776758
777759      /* loop over width */
778      curwidth = state->m_pattern_width;
760      curwidth = m_pattern_width;
779761      do
780762      {
781763         UINT16 busaddr;
r20741r20742
784766         /* ----- read phase ----- */
785767
786768         /* address is selected between source/dest based on mode.d0 */
787         busaddr = ((state->m_pattern_mode & 0x01) == 0) ? state->m_pattern_source : state->m_pattern_dest;
769         busaddr = ((m_pattern_mode & 0x01) == 0) ? m_pattern_source : m_pattern_dest;
788770
789771         /* if mode.d3 is set, then the last byte fetched per row is forced to 0 */
790         if (curwidth == 0 && (state->m_pattern_mode & 0x08) != 0)
772         if (curwidth == 0 && (m_pattern_mode & 0x08) != 0)
791773            busdata = 0;
792774         else
793775            busdata = space.read_byte(busaddr);
794776
795777         /* increment the appropriate address */
796         if ((state->m_pattern_mode & 0x01) == 0)
797            increment_source(state, curwidth, &u13ff);
778         if ((m_pattern_mode & 0x01) == 0)
779            increment_source(curwidth, &u13ff);
798780         else
799            increment_dest(state, curwidth);
781            increment_dest(curwidth);
800782
801783         /* ----- write phase ----- */
802784
803785         /* address is selected between source/dest based on mode.d0 */
804         busaddr = ((state->m_pattern_mode & 0x01) != 0) ? state->m_pattern_source : state->m_pattern_dest;
786         busaddr = ((m_pattern_mode & 0x01) != 0) ? m_pattern_source : m_pattern_dest;
805787         space.write_byte(busaddr, busdata);
806788
807789         /* increment the appropriate address */
808         if ((state->m_pattern_mode & 0x01) == 0)
809            increment_dest(state, curwidth);
790         if ((m_pattern_mode & 0x01) == 0)
791            increment_dest(curwidth);
810792         else
811            increment_source(state, curwidth, &u13ff);
793            increment_source(curwidth, &u13ff);
812794
813795         /* count 4 cycles (two read, two write) */
814796         cycles += 4;
r20741r20742
816798      } while (curwidth-- != 0);
817799
818800      /* at the end of each row, the skip value is added to the dest value */
819      carry = ((state->m_pattern_dest & 0xff) + state->m_pattern_skip) & 0x100;
820      state->m_pattern_dest = (state->m_pattern_dest & 0xff00) | ((state->m_pattern_dest + state->m_pattern_skip) & 0xff);
801      carry = ((m_pattern_dest & 0xff) + m_pattern_skip) & 0x100;
802      m_pattern_dest = (m_pattern_dest & 0xff00) | ((m_pattern_dest + m_pattern_skip) & 0xff);
821803
822804      /* carry behavior into the top byte is controlled by mode.d4 */
823      if ((state->m_pattern_mode & 0x10) == 0)
824         state->m_pattern_dest += carry;
805      if ((m_pattern_mode & 0x10) == 0)
806         m_pattern_dest += carry;
825807      else
826         state->m_pattern_dest -= carry ^ 0x100;
808         m_pattern_dest -= carry ^ 0x100;
827809
828   } while (state->m_pattern_height-- != 0);
810   } while (m_pattern_height-- != 0);
829811
830812   /* count cycles we ran the bus */
831813   space.device().execute().adjust_icount(-cycles);
r20741r20742
905887    relative to the beginning of time and use that, mod RNG_PERIOD.
906888*/
907889
908static void init_sparklestar(running_machine &machine)
890void astrocde_state::init_sparklestar()
909891{
910   astrocde_state *state = machine.driver_data<astrocde_state>();
911892   UINT32 shiftreg;
912893   int i;
913894
914895   /* reset global sparkle state */
915   state->m_sparkle[0] = state->m_sparkle[1] = state->m_sparkle[2] = state->m_sparkle[3] = 0;
896   m_sparkle[0] = m_sparkle[1] = m_sparkle[2] = m_sparkle[3] = 0;
916897
917898   /* allocate memory for the sparkle/star array */
918   state->m_sparklestar = auto_alloc_array(machine, UINT8, RNG_PERIOD);
899   m_sparklestar = auto_alloc_array(machine(), UINT8, RNG_PERIOD);
919900
920901   /* generate the data for the sparkle/star array */
921902   for (shiftreg = i = 0; i < RNG_PERIOD; i++)
r20741r20742
928909
929910      /* extract the sparkle/star intensity here */
930911      /* this is controlled by the shift register at U17/U19/U18 */
931      state->m_sparklestar[i] = (((shiftreg >> 4) & 1) << 3) |
912      m_sparklestar[i] = (((shiftreg >> 4) & 1) << 3) |
932913                     (((shiftreg >> 12) & 1) << 2) |
933914                     (((shiftreg >> 16) & 1) << 1) |
934915                     (((shiftreg >> 8) & 1) << 0);
r20741r20742
936917      /* determine the star enable here */
937918      /* this is controlled by the shift register at U17/U12/U11 */
938919      if ((shiftreg & 0xff) == 0xfe)
939         state->m_sparklestar[i] |= 0x10;
920         m_sparklestar[i] |= 0x10;
940921   }
941922}
942923
trunk/src/mame/video/40love.c
r20741r20742
131131
132132***************************************************************************/
133133
134static void fortyl_set_scroll_x( running_machine &machine, int offset )
134void fortyl_state::fortyl_set_scroll_x( int offset )
135135{
136   fortyl_state *state = machine.driver_data<fortyl_state>();
137136   int i = offset & ~1;
138   int x = ((state->m_colorram[i] & 0x80) << 1) | state->m_colorram[i + 1];    /* 9 bits signed */
137   int x = ((m_colorram[i] & 0x80) << 1) | m_colorram[i + 1];    /* 9 bits signed */
139138
140   if (state->m_flipscreen)
139   if (m_flipscreen)
141140      x += 0x51;
142141   else
143142      x -= 0x50;
r20741r20742
145144   x &= 0x1ff;
146145   if (x & 0x100) x -= 0x200;              /* sign extend */
147146
148   state->m_bg_tilemap->set_scrollx(offset / 2, x);
147   m_bg_tilemap->set_scrollx(offset / 2, x);
149148}
150149
151150WRITE8_MEMBER(fortyl_state::fortyl_pixram_sel_w)
r20741r20742
162161      m_pix_redraw = 1;
163162
164163      for (offs = 0; offs < 32; offs++)
165         fortyl_set_scroll_x(machine(), offs * 2);
164         fortyl_set_scroll_x(offs * 2);
166165   }
167166}
168167
r20741r20742
174173      return m_pixram1[offset];
175174}
176175
177static void fortyl_plot_pix( running_machine &machine, int offset )
176void fortyl_state::fortyl_plot_pix( int offset )
178177{
179   fortyl_state *state = machine.driver_data<fortyl_state>();
180178   int x, y, i, c, d1, d2;
181179
182180   x = (offset & 0x1f) * 8;
183181   y = (offset >> 5) & 0xff;
184182
185   if (state->m_pixram_sel)
183   if (m_pixram_sel)
186184   {
187      d1 = state->m_pixram2[offset];
188      d2 = state->m_pixram2[offset + 0x2000];
185      d1 = m_pixram2[offset];
186      d2 = m_pixram2[offset + 0x2000];
189187   }
190188   else
191189   {
192      d1 = state->m_pixram1[offset];
193      d2 = state->m_pixram1[offset + 0x2000];
190      d1 = m_pixram1[offset];
191      d2 = m_pixram1[offset + 0x2000];
194192   }
195193
196194   for (i = 0; i < 8; i++)
197195   {
198196      c = ((d2 >> i) & 1) + ((d1 >> i) & 1) * 2;
199      if (state->m_pixram_sel)
200         state->m_tmp_bitmap2->pix16(y, x + i) = state->m_pix_color[c];
197      if (m_pixram_sel)
198         m_tmp_bitmap2->pix16(y, x + i) = m_pix_color[c];
201199      else
202         state->m_tmp_bitmap1->pix16(y, x + i) = state->m_pix_color[c];
200         m_tmp_bitmap1->pix16(y, x + i) = m_pix_color[c];
203201   }
204202}
205203
r20741r20742
210208   else
211209      m_pixram1[offset] = data;
212210
213   fortyl_plot_pix(machine(), offset & 0x1fff);
211   fortyl_plot_pix(offset & 0x1fff);
214212}
215213
216214
r20741r20742
235233      for (i = (offset / 2) * 64; i < (offset / 2) * 64 + 64; i++)
236234         m_bg_tilemap->mark_tile_dirty(i);
237235
238      fortyl_set_scroll_x(machine(), offset);
236      fortyl_set_scroll_x(offset);
239237   }
240238}
241239
r20741r20742
265263    offset  3   xxxxxxxx    x position
266264*/
267265
268static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
266void fortyl_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
269267{
270   fortyl_state *state = machine.driver_data<fortyl_state>();
271   UINT8 *spriteram = state->m_spriteram;
272   UINT8 *spriteram_2 = state->m_spriteram2;
268   UINT8 *spriteram = m_spriteram;
269   UINT8 *spriteram_2 = m_spriteram2;
273270   int offs;
274271
275272   /* spriteram #1 */
276   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
273   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
277274   {
278275      int code, color, sx, sy, flipx, flipy;
279276
280277      sx = spriteram[offs + 3];
281278      sy = spriteram[offs + 0] +1;
282279
283      if (state->m_flipscreen)
280      if (m_flipscreen)
284281         sx = 240 - sx;
285282      else
286283         sy = 242 - sy;
287284
288285      code = (spriteram[offs + 1] & 0x3f) + ((spriteram[offs + 2] & 0x18) << 3);
289      flipx = ((spriteram[offs + 1] & 0x40) >> 6) ^ state->m_flipscreen;
290      flipy = ((spriteram[offs + 1] & 0x80) >> 7) ^ state->m_flipscreen;
286      flipx = ((spriteram[offs + 1] & 0x40) >> 6) ^ m_flipscreen;
287      flipy = ((spriteram[offs + 1] & 0x80) >> 7) ^ m_flipscreen;
291288      color = (spriteram[offs + 2] & 0x07) + 0x08;
292289
293290      if (spriteram[offs + 2] & 0xe0)
294         color = machine.rand() & 0xf;
291         color = machine().rand() & 0xf;
295292
296      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
293      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
297294            code,
298295            color,
299296            flipx,flipy,
300            sx+state->m_xoffset,sy,0);
297            sx+m_xoffset,sy,0);
301298   }
302299
303300   /* spriteram #2 */
304   for (offs = 0; offs < state->m_spriteram2.bytes(); offs += 4)
301   for (offs = 0; offs < m_spriteram2.bytes(); offs += 4)
305302   {
306303      int code, color, sx, sy, flipx, flipy;
307304
308305      sx = spriteram_2[offs + 3];
309306      sy = spriteram_2[offs + 0] +1;
310307
311      if (state->m_flipscreen)
308      if (m_flipscreen)
312309         sx = 240 - sx;
313310      else
314311         sy = 242 - sy;
315312
316313      code = (spriteram_2[offs + 1] & 0x3f) + ((spriteram_2[offs + 2] & 0x18) << 3);
317      flipx = ((spriteram_2[offs + 1] & 0x40) >> 6) ^ state->m_flipscreen;
318      flipy = ((spriteram_2[offs + 1] & 0x80) >> 7) ^ state->m_flipscreen;
314      flipx = ((spriteram_2[offs + 1] & 0x40) >> 6) ^ m_flipscreen;
315      flipy = ((spriteram_2[offs + 1] & 0x80) >> 7) ^ m_flipscreen;
319316      color = (spriteram_2[offs + 2] & 0x07) + 0x08;
320317
321318      if (spriteram_2[offs + 2] & 0xe0)
322         color = machine.rand() & 0xf;
319         color = machine().rand() & 0xf;
323320
324      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
321      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
325322            code,
326323            color,
327324            flipx,flipy,
328            sx+state->m_xoffset,sy,0);
325            sx+m_xoffset,sy,0);
329326   }
330327}
331328
332static void draw_pixram( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
329void fortyl_state::draw_pixram( bitmap_ind16 &bitmap, const rectangle &cliprect )
333330{
334   fortyl_state *state = machine.driver_data<fortyl_state>();
335331   int offs;
336   int f = state->m_flipscreen ^ 1;
332   int f = m_flipscreen ^ 1;
337333
338   if (state->m_pix_redraw)
334   if (m_pix_redraw)
339335   {
340      state->m_pix_redraw = 0;
336      m_pix_redraw = 0;
341337
342338      for (offs = 0; offs < 0x2000; offs++)
343         fortyl_plot_pix(machine, offs);
339         fortyl_plot_pix(offs);
344340   }
345341
346   if (state->m_pixram_sel)
347      copybitmap(bitmap, *state->m_tmp_bitmap1, f, f, state->m_xoffset, 0, cliprect);
342   if (m_pixram_sel)
343      copybitmap(bitmap, *m_tmp_bitmap1, f, f, m_xoffset, 0, cliprect);
348344   else
349      copybitmap(bitmap, *state->m_tmp_bitmap2, f, f, state->m_xoffset, 0, cliprect);
345      copybitmap(bitmap, *m_tmp_bitmap2, f, f, m_xoffset, 0, cliprect);
350346}
351347
352348UINT32 fortyl_state::screen_update_fortyl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
353349{
354   draw_pixram(machine(), bitmap, cliprect);
350   draw_pixram(bitmap, cliprect);
355351
356352   m_bg_tilemap->set_scrolldy(- m_video_ctrl[1] + 1, - m_video_ctrl[1] - 1 );
357353   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
358354
359   draw_sprites(machine(), bitmap, cliprect);
355   draw_sprites(bitmap, cliprect);
360356   return 0;
361357}
trunk/src/mame/video/8080bw.c
r20741r20742
2626}
2727
2828
29static void invadpt2_get_pens( pen_t *pens )
29void _8080bw_state::invadpt2_get_pens( pen_t *pens )
3030{
3131   offs_t i;
3232
r20741r20742
3737}
3838
3939
40static void sflush_get_pens( pen_t *pens )
40void _8080bw_state::sflush_get_pens( pen_t *pens )
4141{
4242   offs_t i;
4343
r20741r20742
5050}
5151
5252
53static void cosmo_get_pens( pen_t *pens )
53void _8080bw_state::cosmo_get_pens( pen_t *pens )
5454{
5555   offs_t i;
5656
r20741r20742
6161}
6262
6363
64INLINE void set_pixel( running_machine &machine, bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color )
64inline void _8080bw_state::set_pixel( bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color )
6565{
66   _8080bw_state *state = machine.driver_data<_8080bw_state>();
67
6866   if (y >= MW8080BW_VCOUNTER_START_NO_VBLANK)
6967   {
70      if (state->m_flip_screen)
68      if (m_flip_screen)
7169         bitmap.pix32(MW8080BW_VBSTART - 1 - (y - MW8080BW_VCOUNTER_START_NO_VBLANK), MW8080BW_HPIXCOUNT - 1 - x) = pens[color];
7270      else
7371         bitmap.pix32(y - MW8080BW_VCOUNTER_START_NO_VBLANK, x) = pens[color];
r20741r20742
7573}
7674
7775
78INLINE void set_8_pixels( running_machine &machine, bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, UINT8 data, pen_t *pens, UINT8 fore_color, UINT8 back_color )
76inline void _8080bw_state::set_8_pixels( bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, UINT8 data, pen_t *pens, UINT8 fore_color, UINT8 back_color )
7977{
8078   int i;
8179
8280   for (i = 0; i < 8; i++)
8381   {
84      set_pixel(machine, bitmap, y, x, pens, (data & 0x01) ? fore_color : back_color);
82      set_pixel(bitmap, y, x, pens, (data & 0x01) ? fore_color : back_color);
8583
8684      x = x + 1;
8785      data = data >> 1;
r20741r20742
9088
9189
9290/* this is needed as this driver doesn't emulate the shift register like mw8080bw does */
93static void clear_extra_columns( running_machine &machine, bitmap_rgb32 &bitmap, pen_t *pens, UINT8 color )
91void _8080bw_state::clear_extra_columns( bitmap_rgb32 &bitmap, pen_t *pens, UINT8 color )
9492{
95   _8080bw_state *state = machine.driver_data<_8080bw_state>();
9693   UINT8 x;
9794
9895   for (x = 0; x < 4; x++)
r20741r20742
10198
10299      for (y = MW8080BW_VCOUNTER_START_NO_VBLANK; y != 0; y++)
103100      {
104         if (state->m_flip_screen)
101         if (m_flip_screen)
105102            bitmap.pix32(MW8080BW_VBSTART - 1 - (y - MW8080BW_VCOUNTER_START_NO_VBLANK), MW8080BW_HPIXCOUNT - 1 - (256 + x)) = pens[color];
106103         else
107104            bitmap.pix32(y - MW8080BW_VCOUNTER_START_NO_VBLANK, 256 + x) = pens[color];
r20741r20742
132129      UINT8 data = m_main_ram[offs];
133130      UINT8 fore_color = m_screen_red ? 1 : color_map_base[color_address] & 0x07;
134131
135      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0);
132      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
136133   }
137134
138   clear_extra_columns(machine(), bitmap, pens, 0);
135   clear_extra_columns(bitmap, pens, 0);
139136
140137   return 0;
141138}
r20741r20742
164161      UINT8 fore_color = m_screen_red ? 1 : color_map_base[color_address] & 0x07;
165162
166163      /* blue background */
167      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 2);
164      set_8_pixels(bitmap, y, x, data, pens, fore_color, 2);
168165   }
169166
170   clear_extra_columns(machine(), bitmap, pens, 2);
167   clear_extra_columns(bitmap, pens, 2);
171168
172169   return 0;
173170}
r20741r20742
204201         back_color = (((back_data & 0x0c) == 0x0c) && m_schaser_background_select) ? 4 : 2;
205202      }
206203
207      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, back_color);
204      set_8_pixels(bitmap, y, x, data, pens, fore_color, back_color);
208205   }
209206
210   clear_extra_columns(machine(), bitmap, pens, m_schaser_background_disable ? 0 : 2);
207   clear_extra_columns(bitmap, pens, m_schaser_background_disable ? 0 : 2);
211208
212209   return 0;
213210}
r20741r20742
229226      UINT8 fore_color = m_colorram[offs & 0x1f9f] & 0x07;
230227
231228      /* blue background */
232      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 2);
229      set_8_pixels(bitmap, y, x, data, pens, fore_color, 2);
233230   }
234231
235   clear_extra_columns(machine(), bitmap, pens, 2);
232   clear_extra_columns(bitmap, pens, 2);
236233
237234   return 0;
238235}
r20741r20742
253250      UINT8 data = m_main_ram[offs];
254251      UINT8 fore_color = m_colorram[offs & 0x1f1f] & 0x07;
255252
256      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0);
253      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
257254   }
258255
259   clear_extra_columns(machine(), bitmap, pens, 0);
256   clear_extra_columns(bitmap, pens, 0);
260257
261258   return 0;
262259}
r20741r20742
296293
297294      if ((color_map_base[color_address] & 0x08) || (cloud_y >= 64))
298295      {
299         set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, back_color);
296         set_8_pixels(bitmap, y, x, data, pens, fore_color, back_color);
300297      }
301298      else
302299      {
r20741r20742
319316               color = (cloud_gfx[cloud_gfx_offs] & bit) ? 7 : back_color;
320317            }
321318
322            set_pixel(machine(), bitmap, y, x, pens, color);
319            set_pixel(bitmap, y, x, pens, color);
323320
324321            x = x + 1;
325322            data = data >> 1;
r20741r20742
327324      }
328325   }
329326
330   clear_extra_columns(machine(), bitmap, pens, 6);
327   clear_extra_columns(bitmap, pens, 6);
331328
332329   return 0;
333330}
r20741r20742
348345      UINT8 data = m_main_ram[offs];
349346      UINT8 fore_color = ~m_colorram[offs & 0x1f9f] & 0x07;
350347
351      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0);
348      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
352349   }
353350
354   clear_extra_columns(machine(), bitmap, pens, 0);
351   clear_extra_columns(bitmap, pens, 0);
355352
356353   return 0;
357354}
r20741r20742
374371      UINT8 data = m_main_ram[offs];
375372      UINT8 fore_color = m_colorram[color_address] & 0x07;
376373
377      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0);
374      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
378375   }
379376
380   clear_extra_columns(machine(), bitmap, pens, 0);
377   clear_extra_columns(bitmap, pens, 0);
381378
382379   return 0;
383380}
r20741r20742
405402      UINT8 data = m_main_ram[offs];
406403      UINT8 fore_color = color_map_base[color_address] & 0x07;
407404
408      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0);
405      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
409406   }
410407
411   clear_extra_columns(machine(), bitmap, pens, 0);
408   clear_extra_columns(bitmap, pens, 0);
412409
413410   return 0;
414411}
r20741r20742
429426      UINT8 data = m_main_ram[offs];
430427      UINT8 fore_color = m_colorram[offs & 0x1f9f] & 0x07;
431428
432      set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0);
429      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
433430   }
434431
435   clear_extra_columns(machine(), bitmap, pens, 0);
432   clear_extra_columns(bitmap, pens, 0);
436433
437434   return 0;
438435}
trunk/src/mame/video/1943.c
r20741r20742
212212   save_item(NAME(m_bg2_on));
213213}
214214
215static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
215void _1943_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
216216{
217   _1943_state *state = machine.driver_data<_1943_state>();
218217   int offs;
219218
220   for (offs = state->m_spriteram.bytes() - 32; offs >= 0; offs -= 32)
219   for (offs = m_spriteram.bytes() - 32; offs >= 0; offs -= 32)
221220   {
222      int attr = state->m_spriteram[offs + 1];
223      int code = state->m_spriteram[offs] + ((attr & 0xe0) << 3);
221      int attr = m_spriteram[offs + 1];
222      int code = m_spriteram[offs] + ((attr & 0xe0) << 3);
224223      int color = attr & 0x0f;
225      int sx = state->m_spriteram[offs + 3] - ((attr & 0x10) << 4);
226      int sy = state->m_spriteram[offs + 2];
224      int sx = m_spriteram[offs + 3] - ((attr & 0x10) << 4);
225      int sy = m_spriteram[offs + 2];
227226
228      if (state->flip_screen())
227      if (flip_screen())
229228      {
230229         sx = 240 - sx;
231230         sy = 240 - sy;
r20741r20742
235234      if (priority)
236235      {
237236         if (color != 0x0a && color != 0x0b)
238            drawgfx_transpen(bitmap, cliprect, machine.gfx[3], code, color, state->flip_screen(), state->flip_screen(), sx, sy, 0);
237            drawgfx_transpen(bitmap, cliprect, machine().gfx[3], code, color, flip_screen(), flip_screen(), sx, sy, 0);
239238      }
240239      else
241240      {
242241         if (color == 0x0a || color == 0x0b)
243            drawgfx_transpen(bitmap, cliprect, machine.gfx[3], code, color, state->flip_screen(), state->flip_screen(), sx, sy, 0);
242            drawgfx_transpen(bitmap, cliprect, machine().gfx[3], code, color, flip_screen(), flip_screen(), sx, sy, 0);
244243      }
245244   }
246245}
r20741r20742
257256      bitmap.fill(get_black_pen(machine()), cliprect);
258257
259258   if (m_obj_on)
260      draw_sprites(machine(), bitmap, cliprect, 0);
259      draw_sprites(bitmap, cliprect, 0);
261260
262261   if (m_bg1_on)
263262      m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
264263
265264   if (m_obj_on)
266      draw_sprites(machine(), bitmap, cliprect, 1);
265      draw_sprites(bitmap, cliprect, 1);
267266
268267   if (m_char_on)
269268      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
trunk/src/mame/video/blockout.c
r20741r20742
88#include "includes/blockout.h"
99
1010
11static void setcolor( running_machine &machine, int color, int rgb )
11void blockout_state::setcolor( int color, int rgb )
1212{
1313   int bit0, bit1, bit2, bit3;
1414   int r, g, b;
r20741r20742
3535   bit3 = (rgb >> 11) & 0x01;
3636   b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
3737
38   palette_set_color(machine, color, MAKE_RGB(r,g,b));
38   palette_set_color(machine(), color, MAKE_RGB(r,g,b));
3939}
4040
4141WRITE16_MEMBER(blockout_state::blockout_paletteram_w)
4242{
4343   COMBINE_DATA(&m_paletteram[offset]);
44   setcolor(machine(), offset, m_paletteram[offset]);
44   setcolor(offset, m_paletteram[offset]);
4545}
4646
4747WRITE16_MEMBER(blockout_state::blockout_frontcolor_w)
4848{
4949   COMBINE_DATA(&m_color);
50   setcolor(machine(), 512, m_color);
50   setcolor(512, m_color);
5151}
5252
5353
r20741r20742
6464   save_item(NAME(m_tmpbitmap));
6565}
6666
67static void update_pixels( running_machine &machine, int x, int y )
67void blockout_state::update_pixels( int x, int y )
6868{
69   blockout_state *state = machine.driver_data<blockout_state>();
7069   UINT16 front, back;
7170   int color;
72   const rectangle &visarea = machine.primary_screen->visible_area();
71   const rectangle &visarea = machine().primary_screen->visible_area();
7372
7473   if (!visarea.contains(x, y))
7574      return;
7675
77   front = state->m_videoram[y * 256 + x / 2];
78   back = state->m_videoram[0x10000 + y * 256 + x / 2];
76   front = m_videoram[y * 256 + x / 2];
77   back = m_videoram[0x10000 + y * 256 + x / 2];
7978
8079   if (front >> 8)
8180      color = front >> 8;
8281   else
8382      color = (back >> 8) + 256;
8483
85   state->m_tmpbitmap.pix16(y, x) = color;
84   m_tmpbitmap.pix16(y, x) = color;
8685
8786   if (front & 0xff)
8887      color = front & 0xff;
8988   else
9089      color = (back & 0xff) + 256;
9190
92   state->m_tmpbitmap.pix16(y, x + 1) = color;
91   m_tmpbitmap.pix16(y, x + 1) = color;
9392}
9493
9594
r20741r20742
9796WRITE16_MEMBER(blockout_state::blockout_videoram_w)
9897{
9998   COMBINE_DATA(&m_videoram[offset]);
100   update_pixels(machine(), (offset % 256) * 2, (offset / 256) % 256);
99   update_pixels((offset % 256) * 2, (offset / 256) % 256);
101100}
102101
103102
trunk/src/mame/video/aztarac.c
r20741r20742
1313
1414
1515
16INLINE void read_vectorram(UINT16 *vectorram, int addr, int *x, int *y, int *c)
16inline void aztarac_state::read_vectorram(UINT16 *vectorram, int addr, int *x, int *y, int *c)
1717{
1818   *c = vectorram[addr] & 0xffff;
1919   *x = vectorram[addr + 0x800] & 0x03ff;
trunk/src/mame/video/blmbycar.c
r20741r20742
157157
158158***************************************************************************/
159159
160static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
160void blmbycar_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
161161{
162   blmbycar_state *state = machine.driver_data<blmbycar_state>();
163162   UINT16 *source, *finish;
164163
165   source = state->m_spriteram + 0x6 / 2;              // !
166   finish = state->m_spriteram + state->m_spriteram.bytes() / 2 - 8 / 2;
164   source = m_spriteram + 0x6 / 2;              // !
165   finish = m_spriteram + m_spriteram.bytes() / 2 - 8 / 2;
167166
168167   /* Find "the end of sprites" marker */
169168
r20741r20742
173172   /* Draw sprites in reverse order for pdrawfgfx */
174173
175174   source -= 8 / 2;
176   finish = state->m_spriteram;
175   finish = m_spriteram;
177176
178177   for ( ; source >= finish; source -= 8 / 2 )
179178   {
r20741r20742
192191      x   = (x & 0x1ff) - 0x10;
193192      y   = 0xf0 - ((y & 0xff)  - (y & 0x100));
194193
195      pdrawgfx_transpen(bitmap, cliprect, machine.gfx[0],
194      pdrawgfx_transpen(bitmap, cliprect, machine().gfx[0],
196195               code,
197196               0x20 + (attr & 0xf),
198197               flipx, flipy,
199198               x, y,
200               machine.priority_bitmap,
199               machine().priority_bitmap,
201200               pri_mask,0);
202201   }
203202}
r20741r20742
247246         m_tilemap_1->draw(bitmap, cliprect, i, i);
248247
249248   if (layers_ctrl & 8)
250      draw_sprites(machine(), bitmap, cliprect);
249      draw_sprites(bitmap, cliprect);
251250
252251   return 0;
253252}
trunk/src/mame/video/bogeyman.c
r20741r20742
9494   m_fg_tilemap->set_transparent_pen(0);
9595}
9696
97static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
97void bogeyman_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
9898{
99   bogeyman_state *state = machine.driver_data<bogeyman_state>();
10099   int offs;
101100
102   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
101   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
103102   {
104      int attr = state->m_spriteram[offs];
103      int attr = m_spriteram[offs];
105104
106105      if (attr & 0x01)
107106      {
108         int code = state->m_spriteram[offs + 1] + ((attr & 0x40) << 2);
107         int code = m_spriteram[offs + 1] + ((attr & 0x40) << 2);
109108         int color = (attr & 0x08) >> 3;
110109         int flipx = !(attr & 0x04);
111110         int flipy = attr & 0x02;
112         int sx = state->m_spriteram[offs + 3];
113         int sy = (240 - state->m_spriteram[offs + 2]) & 0xff;
111         int sx = m_spriteram[offs + 3];
112         int sy = (240 - m_spriteram[offs + 2]) & 0xff;
114113         int multi = attr & 0x10;
115114
116115         if (multi) sy -= 16;
117116
118         if (state->flip_screen())
117         if (flip_screen())
119118         {
120119            sx = 240 - sx;
121120            sy = 240 - sy;
r20741r20742
124123         }
125124
126125         drawgfx_transpen(bitmap, cliprect,
127            machine.gfx[2],
126            machine().gfx[2],
128127            code, color,
129128            flipx, flipy,
130129            sx, sy, 0);
r20741r20742
132131         if (multi)
133132         {
134133            drawgfx_transpen(bitmap,cliprect,
135               machine.gfx[2],
134               machine().gfx[2],
136135               code + 1, color,
137136               flipx, flipy,
138               sx, sy + (state->flip_screen() ? -16 : 16), 0);
137               sx, sy + (flip_screen() ? -16 : 16), 0);
139138         }
140139      }
141140   }
r20741r20742
144143UINT32 bogeyman_state::screen_update_bogeyman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
145144{
146145   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
147   draw_sprites(machine(), bitmap, cliprect);
146   draw_sprites(bitmap, cliprect);
148147   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
149148   return 0;
150149}
trunk/src/mame/video/aeroboto.c
r20741r20742
120120
121121***************************************************************************/
122122
123static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
123void aeroboto_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
124124{
125   aeroboto_state *state = machine.driver_data<aeroboto_state>();
126125   int offs;
127126
128   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
127   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
129128   {
130      int x = state->m_spriteram[offs + 3];
131      int y = 240 - state->m_spriteram[offs];
129      int x = m_spriteram[offs + 3];
130      int y = 240 - m_spriteram[offs];
132131
133      if (state->flip_screen())
132      if (flip_screen())
134133      {
135134         x = 248 - x;
136135         y = 240 - y;
137136      }
138137
139      drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
140            state->m_spriteram[offs + 1],
141            state->m_spriteram[offs + 2] & 0x07,
142            state->flip_screen(), state->flip_screen(),
138      drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
139            m_spriteram[offs + 1],
140            m_spriteram[offs + 2] & 0x07,
141            flip_screen(), flip_screen(),
143142            ((x + 8) & 0xff) - 8, y, 0);
144143   }
145144}
r20741r20742
209208   m_bg_tilemap->set_scrolly(0, *m_vscroll);
210209   m_bg_tilemap->draw(bitmap, splitrect2, 0, 0);
211210
212   draw_sprites(machine(), bitmap, cliprect);
211   draw_sprites(bitmap, cliprect);
213212
214213   // the status display behaves more closely to a 40-line splitscreen than an overlay
215214   m_bg_tilemap->set_scrolly(0, 0);
trunk/src/mame/video/amspdwy.c
r20741r20742
9898
9999***************************************************************************/
100100
101static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
101void amspdwy_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
102102{
103   amspdwy_state *state = machine.driver_data<amspdwy_state>();
104   UINT8 *spriteram = state->m_spriteram;
103   UINT8 *spriteram = m_spriteram;
105104   int i;
106   int max_x = machine.primary_screen->width()  - 1;
107   int max_y = machine.primary_screen->height() - 1;
105   int max_x = machine().primary_screen->width()  - 1;
106   int max_y = machine().primary_screen->height() - 1;
108107
109   for (i = 0; i < state->m_spriteram.bytes() ; i += 4)
108   for (i = 0; i < m_spriteram.bytes() ; i += 4)
110109   {
111110      int y = spriteram[i + 0];
112111      int x = spriteram[i + 1];
r20741r20742
115114      int flipx = attr & 0x80;
116115      int flipy = attr & 0x40;
117116
118      if (state->flip_screen())
117      if (flip_screen())
119118      {
120119         x = max_x - x - 8;
121120         y = max_y - y - 8;
r20741r20742
123122         flipy = !flipy;
124123      }
125124
126      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
125      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
127126//              code + ((attr & 0x18)<<5),
128127            code + ((attr & 0x08)<<5),
129128            attr,
r20741r20742
144143UINT32 amspdwy_state::screen_update_amspdwy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
145144{
146145   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
147   draw_sprites(machine(), bitmap, cliprect);
146   draw_sprites(bitmap, cliprect);
148147   return 0;
149148}
trunk/src/mame/video/atarifb.c
r20741r20742
1414 *
1515 *************************************/
1616
17static void get_tile_info_common( running_machine &machine, tile_data &tileinfo, tilemap_memory_index tile_index, UINT8 *alpha_videoram )
17void atarifb_state::get_tile_info_common( tile_data &tileinfo, tilemap_memory_index tile_index, UINT8 *alpha_videoram )
1818{
1919   int code = alpha_videoram[tile_index] & 0x3f;
2020   int flip = alpha_videoram[tile_index] & 0x40;
r20741r20742
2323   if (disable)
2424      code = 0;   /* I *know* this is a space */
2525
26   SET_TILE_INFO(0, code, 0, (flip ? TILE_FLIPX | TILE_FLIPY : 0));
26   SET_TILE_INFO_MEMBER(0, code, 0, (flip ? TILE_FLIPX | TILE_FLIPY : 0));
2727}
2828
2929
3030TILE_GET_INFO_MEMBER(atarifb_state::alpha1_get_tile_info)
3131{
32   get_tile_info_common(machine(), tileinfo, tile_index, m_alphap1_videoram);
32   get_tile_info_common(tileinfo, tile_index, m_alphap1_videoram);
3333}
3434
3535
3636TILE_GET_INFO_MEMBER(atarifb_state::alpha2_get_tile_info)
3737{
38   get_tile_info_common(machine(), tileinfo, tile_index, m_alphap2_videoram);
38   get_tile_info_common(tileinfo, tile_index, m_alphap2_videoram);
3939}
4040
4141
r20741r20742
9393
9494
9595
96static void draw_playfield_and_alpha( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int playfield_x_offset, int playfield_y_offset )
96void atarifb_state::draw_playfield_and_alpha( bitmap_ind16 &bitmap, const rectangle &cliprect, int playfield_x_offset, int playfield_y_offset )
9797{
98   atarifb_state *state = machine.driver_data<atarifb_state>();
9998   const rectangle bigfield_area(4 * 8, 34 * 8 - 1, 0 * 8, 32 * 8 - 1);
10099
101100   int scroll_x[1];
102101   int scroll_y[1];
103102
104   scroll_x[0] = - *state->m_scroll_register + 32 + playfield_x_offset;
103   scroll_x[0] = - *m_scroll_register + 32 + playfield_x_offset;
105104   scroll_y[0] = 8 + playfield_y_offset;
106105
107   copybitmap(bitmap, state->m_alpha1_tilemap->pixmap(), 0, 0, 35*8, 1*8, cliprect);
108   copybitmap(bitmap, state->m_alpha2_tilemap->pixmap(), 0, 0,  0*8, 1*8, cliprect);
109   copyscrollbitmap(bitmap, state->m_field_tilemap->pixmap(),  1, scroll_x, 1, scroll_y, bigfield_area);
106   copybitmap(bitmap, m_alpha1_tilemap->pixmap(), 0, 0, 35*8, 1*8, cliprect);
107   copybitmap(bitmap, m_alpha2_tilemap->pixmap(), 0, 0,  0*8, 1*8, cliprect);
108   copyscrollbitmap(bitmap, m_field_tilemap->pixmap(),  1, scroll_x, 1, scroll_y, bigfield_area);
110109}
111110
112111
113static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int gfx, int is_soccer )
112void atarifb_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int gfx, int is_soccer )
114113{
115   atarifb_state *state = machine.driver_data<atarifb_state>();
116114   const rectangle bigfield_area(4 * 8, 34 * 8 - 1, 0 * 8, 32 * 8 - 1);
117115
118116   int obj;
r20741r20742
124122      int sx, sy;
125123      int shade = 0;
126124
127      sy = 255 - state->m_spriteram[obj * 2 + 1];
125      sy = 255 - m_spriteram[obj * 2 + 1];
128126      if (sy == 255)
129127         continue;
130128
131      charcode = state->m_spriteram[obj * 2] & 0x3f;
132      flipx = (state->m_spriteram[obj * 2] & 0x40);
133      flipy = (state->m_spriteram[obj * 2] & 0x80);
134      sx = state->m_spriteram[obj * 2 + 0x20] + 8 * 3;
129      charcode = m_spriteram[obj * 2] & 0x3f;
130      flipx = (m_spriteram[obj * 2] & 0x40);
131      flipy = (m_spriteram[obj * 2] & 0x80);
132      sx = m_spriteram[obj * 2 + 0x20] + 8 * 3;
135133
136134      /* Note on Atari Soccer: */
137135      /* There are 3 sets of 2 bits each, where the 2 bits represent */
r20741r20742
139137      /* color of each bit in the sprite, but I haven't implemented it that way. */
140138      if (is_soccer)
141139      {
142         shade = ((state->m_spriteram[obj * 2 + 1 + 0x20]) & 0x07);
140         shade = ((m_spriteram[obj * 2 + 1 + 0x20]) & 0x07);
143141
144         drawgfx_transpen(bitmap, bigfield_area, machine.gfx[gfx + 1],
142         drawgfx_transpen(bitmap, bigfield_area, machine().gfx[gfx + 1],
145143            charcode, shade,
146144            flipx, flipy, sx, sy, 0);
147145
148         shade = ((state->m_spriteram[obj * 2 + 1 + 0x20]) & 0x08) >> 3;
146         shade = ((m_spriteram[obj * 2 + 1 + 0x20]) & 0x08) >> 3;
149147      }
150148
151      drawgfx_transpen(bitmap, bigfield_area, machine.gfx[gfx],
149      drawgfx_transpen(bitmap, bigfield_area, machine().gfx[gfx],
152150            charcode, shade,
153151            flipx, flipy, sx, sy, 0);
154152
r20741r20742
160158         if ((charcode == 0x11) && (sy == 0x07))
161159         {
162160            sy = 0xf1; /* When multiplexed, it's 0x10...why? */
163            drawgfx_transpen(bitmap, bigfield_area, machine.gfx[gfx],
161            drawgfx_transpen(bitmap, bigfield_area, machine().gfx[gfx],
164162               charcode, 0,
165163               flipx, flipy, sx, sy, 0);
166164         }
r20741r20742
171169
172170UINT32 atarifb_state::screen_update_atarifb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
173171{
174   draw_playfield_and_alpha(machine(), bitmap, cliprect, 0, 0);
172   draw_playfield_and_alpha(bitmap, cliprect, 0, 0);
175173
176   draw_sprites(machine(), bitmap, cliprect, 1, 0);
174   draw_sprites(bitmap, cliprect, 1, 0);
177175
178176   return 0;
179177}
r20741r20742
181179
182180UINT32 atarifb_state::screen_update_abaseb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
183181{
184   draw_playfield_and_alpha(machine(), bitmap, cliprect, -8, 0);
182   draw_playfield_and_alpha(bitmap, cliprect, -8, 0);
185183
186   draw_sprites(machine(), bitmap, cliprect, 1, 0);
184   draw_sprites(bitmap, cliprect, 1, 0);
187185
188186   return 0;
189187}
r20741r20742
191189
192190UINT32 atarifb_state::screen_update_soccer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
193191{
194   draw_playfield_and_alpha(machine(), bitmap, cliprect, 0, 8);
192   draw_playfield_and_alpha(bitmap, cliprect, 0, 8);
195193
196   draw_sprites(machine(), bitmap, cliprect, 2, 1);
194   draw_sprites(bitmap, cliprect, 2, 1);
197195
198196   return 0;
199197}
trunk/src/mame/video/boogwing.c
r20741r20742
2020
2121 apparently priority is based on a PROM, that should be used if possible.
2222*/
23static void mix_boogwing(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
23void boogwing_state::mix_boogwing(bitmap_rgb32 &bitmap, const rectangle &cliprect)
2424{
25   boogwing_state *state = machine.driver_data<boogwing_state>();
2625   int y, x;
27   const pen_t *paldata = machine.pens;
26   const pen_t *paldata = machine().pens;
2827   bitmap_ind16 *sprite_bitmap1, *sprite_bitmap2;
2928   bitmap_ind8* priority_bitmap;
3029
31   address_space &space = machine.driver_data()->generic_space();
32   UINT16 priority = decocomn_priority_r(state->m_decocomn, space, 0, 0xffff);
30   address_space &space = machine().driver_data()->generic_space();
31   UINT16 priority = decocomn_priority_r(m_decocomn, space, 0, 0xffff);
3332
34   sprite_bitmap1 = &state->m_sprgen1->get_sprite_temp_bitmap();
35   sprite_bitmap2 = &state->m_sprgen1->get_sprite_temp_bitmap();
36   priority_bitmap = &machine.priority_bitmap;
33   sprite_bitmap1 = &m_sprgen1->get_sprite_temp_bitmap();
34   sprite_bitmap2 = &m_sprgen1->get_sprite_temp_bitmap();
35   priority_bitmap = &machine().priority_bitmap;
3736
3837   UINT32* dstline;
3938   UINT16 *srcline1, *srcline2;
r20741r20742
225224      deco16ic_tilemap_2_draw(m_deco_tilegen1, bitmap, cliprect, 0, 32);
226225   }
227226
228   mix_boogwing(machine(), bitmap,cliprect);
227   mix_boogwing(bitmap,cliprect);
229228
230229   deco16ic_tilemap_1_draw(m_deco_tilegen1, bitmap, cliprect, 0, 0);
231230   return 0;
trunk/src/mame/video/blueprnt.c
r20741r20742
124124}
125125
126126
127static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
127void blueprnt_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
128128{
129   blueprnt_state *state = machine.driver_data<blueprnt_state>();
130129   int offs;
131130
132   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
131   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
133132   {
134      int code = state->m_spriteram[offs + 1];
135      int sx = state->m_spriteram[offs + 3];
136      int sy = 240 - state->m_spriteram[offs];
137      int flipx = state->m_spriteram[offs + 2] & 0x40;
138      int flipy = state->m_spriteram[offs + 2 - 4] & 0x80;    // -4? Awkward, isn't it?
133      int code = m_spriteram[offs + 1];
134      int sx = m_spriteram[offs + 3];
135      int sy = 240 - m_spriteram[offs];
136      int flipx = m_spriteram[offs + 2] & 0x40;
137      int flipy = m_spriteram[offs + 2 - 4] & 0x80;    // -4? Awkward, isn't it?
139138
140      if (state->flip_screen())
139      if (flip_screen())
141140      {
142141         sx = 248 - sx;
143142         sy = 240 - sy;
r20741r20742
146145      }
147146
148147      // sprites are slightly misplaced, regardless of the screen flip
149      drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, 0, flipx, flipy, 2 + sx, sy - 1, 0);
148      drawgfx_transpen(bitmap, cliprect, machine().gfx[1], code, 0, flipx, flipy, 2 + sx, sy - 1, 0);
150149   }
151150}
152151
r20741r20742
163162
164163   bitmap.fill(get_black_pen(machine()), cliprect);
165164   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
166   draw_sprites(machine(), bitmap, cliprect);
165   draw_sprites(bitmap, cliprect);
167166   m_bg_tilemap->draw(bitmap, cliprect, 1, 0);
168167   return 0;
169168}
trunk/src/mame/video/buggychl.c
r20741r20742
7373}
7474
7575
76static void draw_sky( bitmap_ind16 &bitmap, const rectangle &cliprect )
76void buggychl_state::draw_sky( bitmap_ind16 &bitmap, const rectangle &cliprect )
7777{
7878   int x, y;
7979
r20741r20742
8383}
8484
8585
86static void draw_bg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
86void buggychl_state::draw_bg( bitmap_ind16 &bitmap, const rectangle &cliprect )
8787{
88   buggychl_state *state = machine.driver_data<buggychl_state>();
8988   int offs;
9089   int scroll[256];
9190
9291   /* prevent wraparound */
9392   rectangle clip = cliprect;
94   if (state->flip_screen_x()) clip.min_x += 8*8;
93   if (flip_screen_x()) clip.min_x += 8*8;
9594   else clip.max_x -= 8*8;
9695
9796   for (offs = 0; offs < 0x400; offs++)
9897   {
99      int code = state->m_videoram[0x400 + offs];
98      int code = m_videoram[0x400 + offs];
10099
101100      int sx = offs % 32;
102101      int sy = offs / 32;
103102
104      if (state->flip_screen_x())
103      if (flip_screen_x())
105104         sx = 31 - sx;
106      if (state->flip_screen_y())
105      if (flip_screen_y())
107106         sy = 31 - sy;
108107
109      drawgfx_opaque(state->m_tmp_bitmap1, state->m_tmp_bitmap1.cliprect(), machine.gfx[0],
108      drawgfx_opaque(m_tmp_bitmap1, m_tmp_bitmap1.cliprect(), machine().gfx[0],
110109            code,
111110            2,
112            state->flip_screen_x(),state->flip_screen_y(),
111            flip_screen_x(),flip_screen_y(),
113112            8*sx,8*sy);
114113   }
115114
116115   /* first copy to a temp bitmap doing column scroll */
117116   for (offs = 0; offs < 256; offs++)
118      scroll[offs] = -state->m_scrollv[offs / 8];
117      scroll[offs] = -m_scrollv[offs / 8];
119118
120   copyscrollbitmap(state->m_tmp_bitmap2, state->m_tmp_bitmap1, 1, &state->m_bg_scrollx, 256, scroll, state->m_tmp_bitmap2.cliprect());
119   copyscrollbitmap(m_tmp_bitmap2, m_tmp_bitmap1, 1, &m_bg_scrollx, 256, scroll, m_tmp_bitmap2.cliprect());
121120
122121   /* then copy to the screen doing row scroll */
123122   for (offs = 0; offs < 256; offs++)
124      scroll[offs] = -state->m_scrollh[offs];
123      scroll[offs] = -m_scrollh[offs];
125124
126   copyscrollbitmap_trans(bitmap, state->m_tmp_bitmap2, 256, scroll, 0, 0, clip, 32);
125   copyscrollbitmap_trans(bitmap, m_tmp_bitmap2, 256, scroll, 0, 0, clip, 32);
127126}
128127
129128
130static void draw_fg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
129void buggychl_state::draw_fg( bitmap_ind16 &bitmap, const rectangle &cliprect )
131130{
132   buggychl_state *state = machine.driver_data<buggychl_state>();
133131   int offs;
134132
135133   for (offs = 0; offs < 0x400; offs++)
136134   {
137135      int sx = offs % 32;
138136      int sy = offs / 32;
139      int flipx = state->flip_screen_x();
140      int flipy = state->flip_screen_y();
137      int flipx = flip_screen_x();
138      int flipy = flip_screen_y();
141139
142      int code = state->m_videoram[offs];
140      int code = m_videoram[offs];
143141
144142      if (flipx)
145143         sx = 31 - sx;
146144      if (flipy)
147145         sy = 31 - sy;
148146
149      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
147      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
150148            code,
151149            0,
152150            flipx,flipy,
r20741r20742
156154}
157155
158156
159static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
157void buggychl_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
160158{
161   buggychl_state *state = machine.driver_data<buggychl_state>();
162   UINT8 *spriteram = state->m_spriteram;
159   UINT8 *spriteram = m_spriteram;
163160   int offs;
164161   const UINT8 *gfx;
165162
166163   g_profiler.start(PROFILER_USER1);
167164
168   gfx = state->memregion("gfx2")->base();
169   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
165   gfx = memregion("gfx2")->base();
166   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
170167   {
171168      int sx, sy, flipy, zoom, ch, x, px, y;
172169      const UINT8 *lookup;
r20741r20742
179176      zoomy_rom = gfx + (zoom << 6);
180177      zoomx_rom = gfx + 0x2000 + (zoom << 3);
181178
182      lookup = state->m_sprite_lookup + ((spriteram[offs + 2] & 0x7f) << 6);
179      lookup = m_sprite_lookup + ((spriteram[offs + 2] & 0x7f) << 6);
183180
184181      for (y = 0; y < 64; y++)
185182      {
186         int dy = state->flip_screen_y() ? (255 - sy - y) : (sy + y);
183         int dy = flip_screen_y() ? (255 - sy - y) : (sy + y);
187184
188185         if ((dy & ~0xff) == 0)
189186         {
r20741r20742
204201               code = 8 * (lookup[pos] | ((lookup[pos + 1] & 0x07) << 8));
205202               realflipy = (lookup[pos + 1] & 0x80) ? !flipy : flipy;
206203               code += (realflipy ? (charline ^ 7) : charline);
207               pendata = machine.gfx[1]->get_data(code);
204               pendata = machine().gfx[1]->get_data(code);
208205
209206               for (x = 0; x < 16; x++)
210207               {
211208                  int col = pendata[x];
212209                  if (col)
213210                  {
214                     int dx = state->flip_screen_x() ? (255 - sx - px) : (sx + px);
211                     int dx = flip_screen_x() ? (255 - sx - px) : (sx + px);
215212                     if ((dx & ~0xff) == 0)
216                        bitmap.pix16(dy, dx) = state->m_sprite_color_base + col;
213                        bitmap.pix16(dy, dx) = m_sprite_color_base + col;
217214                  }
218215
219216                  /* the following line is almost certainly wrong */
r20741r20742
237234      bitmap.fill(0, cliprect);
238235
239236   if (m_bg_on)
240      draw_bg(machine(), bitmap, cliprect);
237      draw_bg(bitmap, cliprect);
241238
242   draw_sprites(machine(), bitmap, cliprect);
239   draw_sprites(bitmap, cliprect);
243240
244   draw_fg(machine(), bitmap, cliprect);
241   draw_fg(bitmap, cliprect);
245242
246243   return 0;
247244}
trunk/src/mame/video/bigstrkb.c
r20741r20742
66
77/* Sprites */
88
9static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
9void bigstrkb_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
1010{
1111   /*- SPR RAM Format -**
1212
r20741r20742
1616       ( rest unused )
1717   **- End of Comments -*/
1818
19   bigstrkb_state *state = machine.driver_data<bigstrkb_state>();
20   gfx_element *gfx = machine.gfx[2];
21   UINT16 *source = state->m_spriteram;
19   gfx_element *gfx = machine().gfx[2];
20   UINT16 *source = m_spriteram;
2221   UINT16 *finish = source + 0x800/2;
2322
2423   while( source<finish )
r20741r20742
134133   m_tilemap2->draw(bitmap, cliprect, 0,0);
135134   m_tilemap3->draw(bitmap, cliprect, 0,0);
136135
137   draw_sprites(machine(),bitmap,cliprect);
136   draw_sprites(bitmap,cliprect);
138137   m_tilemap->draw(bitmap, cliprect, 0,0);
139138
140139//  popmessage ("Regs %08x %08x %08x %08x",bsb_vidreg2[0],bsb_vidreg2[1],bsb_vidreg2[2],bsb_vidreg2[3]);
trunk/src/mame/video/baraduke.c
r20741r20742
158158}
159159
160160
161static void scroll_w(address_space &space, int layer, int offset, int data)
161void baraduke_state::scroll_w(address_space &space, int layer, int offset, int data)
162162{
163   baraduke_state *state = space.machine().driver_data<baraduke_state>();
164163   switch (offset)
165164   {
166165      case 0: /* high scroll x */
167         state->m_xscroll[layer] = (state->m_xscroll[layer] & 0xff) | (data << 8);
166         m_xscroll[layer] = (m_xscroll[layer] & 0xff) | (data << 8);
168167         break;
169168      case 1: /* low scroll x */
170         state->m_xscroll[layer] = (state->m_xscroll[layer] & 0xff00) | data;
169         m_xscroll[layer] = (m_xscroll[layer] & 0xff00) | data;
171170         break;
172171      case 2: /* scroll y */
173         state->m_yscroll[layer] = data;
172         m_yscroll[layer] = data;
174173         break;
175174   }
176175}
r20741r20742
208207
209208***************************************************************************/
210209
211static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_priority)
210void baraduke_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_priority)
212211{
213   baraduke_state *state = machine.driver_data<baraduke_state>();
214   UINT8 *spriteram = state->m_spriteram + 0x1800;
212   UINT8 *spriteram = m_spriteram + 0x1800;
215213   const UINT8 *source = &spriteram[0x0000];
216214   const UINT8 *finish = &spriteram[0x0800-16];    /* the last is NOT a sprite */
217215
r20741r20742
257255
258256         sy -= 16 * sizey;
259257
260         if (state->flip_screen())
258         if (flip_screen())
261259         {
262260            sx = 496+3 - 16 * sizex - sx;
263261            sy = 240 - 16 * sizey - sy;
r20741r20742
269267         {
270268            for (x = 0;x <= sizex;x++)
271269            {
272               drawgfx_transpen( bitmap, cliprect,machine.gfx[3],
270               drawgfx_transpen( bitmap, cliprect,machine().gfx[3],
273271                  sprite + gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)],
274272                  color,
275273                  flipx,flipy,
r20741r20742
284282}
285283
286284
287static void set_scroll(running_machine &machine, int layer)
285void baraduke_state::set_scroll(int layer)
288286{
289   baraduke_state *state = machine.driver_data<baraduke_state>();
290287   static const int xdisp[2] = { 26, 24 };
291288   int scrollx, scrolly;
292289
293   scrollx = state->m_xscroll[layer] + xdisp[layer];
294   scrolly = state->m_yscroll[layer] + 9;
295   if (state->flip_screen())
290   scrollx = m_xscroll[layer] + xdisp[layer];
291   scrolly = m_yscroll[layer] + 9;
292   if (flip_screen())
296293   {
297294      scrollx = -scrollx + 3;
298295      scrolly = -scrolly;
299296   }
300297
301   state->m_bg_tilemap[layer]->set_scrollx(0, scrollx);
302   state->m_bg_tilemap[layer]->set_scrolly(0, scrolly);
298   m_bg_tilemap[layer]->set_scrollx(0, scrollx);
299   m_bg_tilemap[layer]->set_scrolly(0, scrolly);
303300}
304301
305302
r20741r20742
312309   /* can't use flip_screen_set() because the visible area is asymmetrical */
313310   flip_screen_set_no_update(spriteram[0x07f6] & 0x01);
314311   machine().tilemap().set_flip_all(flip_screen() ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
315   set_scroll(machine(), 0);
316   set_scroll(machine(), 1);
312   set_scroll(0);
313   set_scroll(1);
317314
318315   if (((m_xscroll[0] & 0x0e00) >> 9) == 6)
319316      back = 1;
r20741r20742
321318      back = 0;
322319
323320   m_bg_tilemap[back]->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
324   draw_sprites(machine(), bitmap,cliprect,0);
321   draw_sprites(bitmap,cliprect,0);
325322   m_bg_tilemap[back ^ 1]->draw(bitmap, cliprect, 0,0);
326   draw_sprites(machine(), bitmap,cliprect,1);
323   draw_sprites(bitmap,cliprect,1);
327324
328325   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
329326   return 0;
trunk/src/mame/video/arkanoid.c
r20741r20742
211211   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(arkanoid_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
212212}
213213
214static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
214void arkanoid_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
215215{
216   arkanoid_state *state = machine.driver_data<arkanoid_state>();
217216   int offs;
218217
219   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
218   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
220219   {
221220      int sx, sy, code;
222221
223      sx = state->m_spriteram[offs];
224      sy = 248 - state->m_spriteram[offs + 1];
225      if (state->flip_screen_x())
222      sx = m_spriteram[offs];
223      sy = 248 - m_spriteram[offs + 1];
224      if (flip_screen_x())
226225         sx = 248 - sx;
227      if (state->flip_screen_y())
226      if (flip_screen_y())
228227         sy = 248 - sy;
229228
230      code = state->m_spriteram[offs + 3] + ((state->m_spriteram[offs + 2] & 0x03) << 8) + 1024 * state->m_gfxbank;
229      code = m_spriteram[offs + 3] + ((m_spriteram[offs + 2] & 0x03) << 8) + 1024 * m_gfxbank;
231230
232      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
231      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
233232            2 * code,
234            ((state->m_spriteram[offs + 2] & 0xf8) >> 3) + 32 * state->m_palettebank,
235            state->flip_screen_x(),state->flip_screen_y(),
236            sx,sy + (state->flip_screen_y() ? 8 : -8),0);
237      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
233            ((m_spriteram[offs + 2] & 0xf8) >> 3) + 32 * m_palettebank,
234            flip_screen_x(),flip_screen_y(),
235            sx,sy + (flip_screen_y() ? 8 : -8),0);
236      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
238237            2 * code + 1,
239            ((state->m_spriteram[offs + 2] & 0xf8) >> 3) + 32 * state->m_palettebank,
240            state->flip_screen_x(),state->flip_screen_y(),
238            ((m_spriteram[offs + 2] & 0xf8) >> 3) + 32 * m_palettebank,
239            flip_screen_x(),flip_screen_y(),
241240            sx,sy,0);
242241   }
243242}
r20741r20742
246245UINT32 arkanoid_state::screen_update_arkanoid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
247246{
248247   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
249   draw_sprites(machine(), bitmap, cliprect);
248   draw_sprites(bitmap, cliprect);
250249   return 0;
251250}
252251
trunk/src/mame/video/bwing.c
r20741r20742
2121//****************************************************************************
2222// Local Functions
2323
24static void fill_srxlat( int *xlat )
24void bwing_state::fill_srxlat( int *xlat )
2525{
2626   unsigned base, offset, i;
2727
r20741r20742
240240//****************************************************************************
241241// Realtime
242242
243static void draw_sprites( running_machine &machine, bitmap_ind16 &bmp, const rectangle &clip, UINT8 *ram, int pri )
243void bwing_state::draw_sprites( bitmap_ind16 &bmp, const rectangle &clip, UINT8 *ram, int pri )
244244{
245   bwing_state *state = machine.driver_data<bwing_state>();
246245   int attrib, fx, fy, code, x, y, color, i;
247   gfx_element *gfx = machine.gfx[1];
246   gfx_element *gfx = machine().gfx[1];
248247
249248   for (i = 0; i < 0x200; i += 4)
250249   {
r20741r20742
265264      fy = ~attrib & 0x02;
266265
267266      // normal/cocktail
268      if (state->m_mapmask & 0x20)
267      if (m_mapmask & 0x20)
269268      {
270269         fx = !fx;
271270         fy = !fy;
r20741r20742
311310      bitmap.fill(get_black_pen(machine()), cliprect);
312311
313312   // draw low priority sprites
314   draw_sprites(machine(), bitmap, cliprect, m_spriteram, 0);
313   draw_sprites(bitmap, cliprect, m_spriteram, 0);
315314
316315   // draw foreground
317316   if (!(m_mapmask & 2))
r20741r20742
325324   }
326325
327326   // draw high priority sprites
328   draw_sprites(machine(), bitmap, cliprect, m_spriteram, 1);
327   draw_sprites(bitmap, cliprect, m_spriteram, 1);
329328
330329   // draw text layer
331330//  if (m_mapmask & 4)
trunk/src/mame/video/brkthru.c
r20741r20742
147147
148148
149149#if 0
150static void show_register( bitmap_ind16 &bitmap, int x, int y, UINT32 data )
150void brkthru_state::show_register( bitmap_ind16 &bitmap, int x, int y, UINT32 data )
151151{
152152   char buf[5];
153153
r20741r20742
157157#endif
158158
159159
160static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int prio )
160void brkthru_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int prio )
161161{
162   brkthru_state *state = machine.driver_data<brkthru_state>();
163162   int offs;
164163   /* Draw the sprites. Note that it is important to draw them exactly in this */
165164   /* order, to have the correct priorities. */
r20741r20742
176175       ---- ---- ---- ---- ---- ---- xxxx xxxx = X position
177176   */
178177
179   for (offs = 0;offs < state->m_spriteram.bytes(); offs += 4)
178   for (offs = 0;offs < m_spriteram.bytes(); offs += 4)
180179   {
181      if ((state->m_spriteram[offs] & 0x09) == prio)  /* Enable && Low Priority */
180      if ((m_spriteram[offs] & 0x09) == prio)  /* Enable && Low Priority */
182181      {
183182         int sx, sy, code, color;
184183
185         sx = 240 - state->m_spriteram[offs + 3];
184         sx = 240 - m_spriteram[offs + 3];
186185         if (sx < -7)
187186            sx += 256;
188187
189         sy = 240 - state->m_spriteram[offs + 2];
190         code = state->m_spriteram[offs + 1] + 128 * (state->m_spriteram[offs] & 0x06);
191         color = (state->m_spriteram[offs] & 0xe0) >> 5;
192         if (state->m_flipscreen)
188         sy = 240 - m_spriteram[offs + 2];
189         code = m_spriteram[offs + 1] + 128 * (m_spriteram[offs] & 0x06);
190         color = (m_spriteram[offs] & 0xe0) >> 5;
191         if (m_flipscreen)
193192         {
194193            sx = 240 - sx;
195194            sy = 240 - sy;
196195         }
197196
198         if (state->m_spriteram[offs] & 0x10)    /* double height */
197         if (m_spriteram[offs] & 0x10)    /* double height */
199198         {
200            drawgfx_transpen(bitmap,cliprect,machine.gfx[9],
199            drawgfx_transpen(bitmap,cliprect,machine().gfx[9],
201200                  code & ~1,
202201                  color,
203                  state->m_flipscreen, state->m_flipscreen,
204                  sx, state->m_flipscreen ? sy + 16 : sy - 16,0);
205            drawgfx_transpen(bitmap,cliprect,machine.gfx[9],
202                  m_flipscreen, m_flipscreen,
203                  sx, m_flipscreen ? sy + 16 : sy - 16,0);
204            drawgfx_transpen(bitmap,cliprect,machine().gfx[9],
206205                  code | 1,
207206                  color,
208                  state->m_flipscreen, state->m_flipscreen,
207                  m_flipscreen, m_flipscreen,
209208                  sx,sy,0);
210209
211210            /* redraw with wraparound */
212            drawgfx_transpen(bitmap,cliprect,machine.gfx[9],
211            drawgfx_transpen(bitmap,cliprect,machine().gfx[9],
213212                  code & ~1,
214213                  color,
215                  state->m_flipscreen, state->m_flipscreen,
216                  sx,(state->m_flipscreen ? sy + 16 : sy - 16) + 256,0);
217            drawgfx_transpen(bitmap,cliprect,machine.gfx[9],
214                  m_flipscreen, m_flipscreen,
215                  sx,(m_flipscreen ? sy + 16 : sy - 16) + 256,0);
216            drawgfx_transpen(bitmap,cliprect,machine().gfx[9],
218217                  code | 1,
219218                  color,
220                  state->m_flipscreen, state->m_flipscreen,
219                  m_flipscreen, m_flipscreen,
221220                  sx,sy + 256,0);
222221
223222         }
224223         else
225224         {
226            drawgfx_transpen(bitmap,cliprect,machine.gfx[9],
225            drawgfx_transpen(bitmap,cliprect,machine().gfx[9],
227226                  code,
228227                  color,
229                  state->m_flipscreen, state->m_flipscreen,
228                  m_flipscreen, m_flipscreen,
230229                  sx,sy,0);
231230
232231            /* redraw with wraparound */
233            drawgfx_transpen(bitmap,cliprect,machine.gfx[9],
232            drawgfx_transpen(bitmap,cliprect,machine().gfx[9],
234233                  code,
235234                  color,
236                  state->m_flipscreen, state->m_flipscreen,
235                  m_flipscreen, m_flipscreen,
237236                  sx,sy + 256,0);
238237
239238         }
r20741r20742
247246   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
248247
249248   /* low priority sprites */
250   draw_sprites(machine(), bitmap, cliprect, 0x01);
249   draw_sprites(bitmap, cliprect, 0x01);
251250
252251   /* draw background over low priority sprites */
253252   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
254253
255254   /* high priority sprites */
256   draw_sprites(machine(), bitmap, cliprect, 0x09);
255   draw_sprites(bitmap, cliprect, 0x09);
257256
258257   /* fg layer */
259258   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
trunk/src/mame/video/battlane.c
r20741r20742
139139   m_screen_bitmap.allocate(32 * 8, 32 * 8);
140140}
141141
142static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
142void battlane_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
143143{
144   battlane_state *state = machine.driver_data<battlane_state>();
145144   int offs, attr, code, color, sx, sy, flipx, flipy, dy;
146145
147146   for (offs = 0; offs < 0x100; offs += 4)
r20741r20742
157156          0x01 = Sprite Enable
158157      */
159158
160      attr = state->m_spriteram[offs + 1];
161      code = state->m_spriteram[offs + 3];
159      attr = m_spriteram[offs + 1];
160      code = m_spriteram[offs + 3];
162161
163162      code += 256 * ((attr >> 6) & 0x02);
164163      code += 256 * ((attr >> 5) & 0x01);
r20741r20742
167166      {
168167         color = (attr >> 3) & 0x01;
169168
170         sx = state->m_spriteram[offs + 2];
171         sy = state->m_spriteram[offs];
169         sx = m_spriteram[offs + 2];
170         sy = m_spriteram[offs];
172171
173172         flipx = attr & 0x04;
174173         flipy = attr & 0x02;
175174
176         if (!state->flip_screen())
175         if (!flip_screen())
177176         {
178177            sx = 240 - sx;
179178            sy = 240 - sy;
r20741r20742
182181         }
183182
184183         drawgfx_transpen(bitmap,cliprect,
185            machine.gfx[0],
184            machine().gfx[0],
186185            code,
187186            color,
188187            flipx, flipy,
r20741r20742
193192            dy = flipy ? 16 : -16;
194193
195194            drawgfx_transpen(bitmap,cliprect,
196               machine.gfx[0],
195               machine().gfx[0],
197196               code + 1,
198197               color,
199198               flipx, flipy,
r20741r20742
203202   }
204203}
205204
206static void draw_fg_bitmap( running_machine &machine, bitmap_ind16 &bitmap )
205void battlane_state::draw_fg_bitmap( bitmap_ind16 &bitmap )
207206{
208   battlane_state *state = machine.driver_data<battlane_state>();
209207   int x, y, data;
210208
211209   for (y = 0; y < 32 * 8; y++)
212210   {
213211      for (x = 0; x < 32 * 8; x++)
214212      {
215         data = state->m_screen_bitmap.pix8(y, x);
213         data = m_screen_bitmap.pix8(y, x);
216214
217215         if (data)
218216         {
219            if (state->flip_screen())
217            if (flip_screen())
220218               bitmap.pix16(255 - y, 255 - x) = data;
221219            else
222220               bitmap.pix16(y, x) = data;
r20741r20742
230228   m_bg_tilemap->mark_all_dirty(); // HACK
231229
232230   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
233   draw_sprites(machine(), bitmap, cliprect);
234   draw_fg_bitmap(machine(), bitmap);
231   draw_sprites(bitmap, cliprect);
232   draw_fg_bitmap(bitmap);
235233   return 0;
236234}
trunk/src/mame/video/blktiger.c
r20741r20742
185185
186186***************************************************************************/
187187
188static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
188void blktiger_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
189189{
190   blktiger_state *state = machine.driver_data<blktiger_state>();
191   UINT8 *buffered_spriteram = state->m_spriteram->buffer();
190   UINT8 *buffered_spriteram = m_spriteram->buffer();
192191   int offs;
193192
194193   /* Draw the sprites. */
195   for (offs = state->m_spriteram->bytes() - 4;offs >= 0;offs -= 4)
194   for (offs = m_spriteram->bytes() - 4;offs >= 0;offs -= 4)
196195   {
197196      int attr = buffered_spriteram[offs+1];
198197      int sx = buffered_spriteram[offs + 3] - ((attr & 0x10) << 4);
r20741r20742
201200      int color = attr & 0x07;
202201      int flipx = attr & 0x08;
203202
204      if (state->flip_screen())
203      if (flip_screen())
205204      {
206205         sx = 240 - sx;
207206         sy = 240 - sy;
208207         flipx = !flipx;
209208      }
210209
211      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
210      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
212211            code,
213212            color,
214            flipx,state->flip_screen(),
213            flipx,flip_screen(),
215214            sx,sy,15);
216215   }
217216}
r20741r20742
224223      (m_screen_layout ? m_bg_tilemap8x4 : m_bg_tilemap4x8)->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
225224
226225   if (m_objon)
227      draw_sprites(machine(), bitmap, cliprect);
226      draw_sprites(bitmap, cliprect);
228227
229228   if (m_bgon)
230229      (m_screen_layout ? m_bg_tilemap8x4 : m_bg_tilemap4x8)->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
trunk/src/mame/video/aerofgt.c
r20741r20742
8080
8181
8282
83static void aerofgt_register_state_globals( running_machine &machine )
83void aerofgt_state::aerofgt_register_state_globals(  )
8484{
85   aerofgt_state *state = machine.driver_data<aerofgt_state>();
86   state->save_item(NAME(state->m_gfxbank));
87   state->save_item(NAME(state->m_bank));
88   state->save_item(NAME(state->m_bg1scrollx));
89   state->save_item(NAME(state->m_bg1scrolly));
90   state->save_item(NAME(state->m_bg2scrollx));
91   state->save_item(NAME(state->m_bg2scrolly));
92   state->save_item(NAME(state->m_charpalettebank));
93   state->save_item(NAME(state->m_spritepalettebank));
85   save_item(NAME(m_gfxbank));
86   save_item(NAME(m_bank));
87   save_item(NAME(m_bg1scrollx));
88   save_item(NAME(m_bg1scrolly));
89   save_item(NAME(m_bg2scrollx));
90   save_item(NAME(m_bg2scrolly));
91   save_item(NAME(m_charpalettebank));
92   save_item(NAME(m_spritepalettebank));
9493}
9594
9695VIDEO_START_MEMBER(aerofgt_state,pspikes)
r20741r20742
10099
101100   m_sprite_gfx = 1;
102101
103   aerofgt_register_state_globals(machine());
102   aerofgt_register_state_globals();
104103   save_item(NAME(m_spikes91_lookup));
105104}
106105
r20741r20742
114113   m_spritepalettebank = 0;
115114   m_sprite_gfx = 2;
116115
117   aerofgt_register_state_globals(machine());
116   aerofgt_register_state_globals();
118117}
119118
120119VIDEO_START_MEMBER(aerofgt_state,spinlbrk)
r20741r20742
132131   /* enemy sprites use ROM instead of RAM */
133132   m_spriteram2.set_target(reinterpret_cast<UINT16 *>(memregion("gfx5")->base()), 0x20000);
134133
135   aerofgt_register_state_globals(machine());
134   aerofgt_register_state_globals();
136135}
137136
138137VIDEO_START_MEMBER(aerofgt_state,turbofrc)
r20741r20742
145144   m_spritepalettebank = 0;
146145   m_sprite_gfx = 2;
147146
148   aerofgt_register_state_globals(machine());
147   aerofgt_register_state_globals();
149148}
150149
151150
r20741r20742
190189}
191190
192191
193static void setbank( running_machine &machine, tilemap_t *tmap, int num, int bank )
192void aerofgt_state::setbank( tilemap_t *tmap, int num, int bank )
194193{
195   aerofgt_state *state = machine.driver_data<aerofgt_state>();
196   if (state->m_gfxbank[num] != bank)
194   if (m_gfxbank[num] != bank)
197195   {
198      state->m_gfxbank[num] = bank;
196      m_gfxbank[num] = bank;
199197      tmap->mark_all_dirty();
200198   }
201199}
r20741r20742
204202{
205203   if (ACCESSING_BITS_0_7)
206204   {
207      setbank(machine(), m_bg1_tilemap, 0, (data & 0xf0) >> 4);
208      setbank(machine(), m_bg1_tilemap, 1, data & 0x0f);
205      setbank(m_bg1_tilemap, 0, (data & 0xf0) >> 4);
206      setbank(m_bg1_tilemap, 1, data & 0x0f);
209207   }
210208}
211209
r20741r20742
214212{
215213   if (ACCESSING_BITS_8_15)
216214   {
217      setbank(machine(), m_bg1_tilemap, 0, (data & 0x0100) >> 8);
218      setbank(machine(), m_bg2_tilemap, 1, (data & 0x0800) >> 11);
215      setbank(m_bg1_tilemap, 0, (data & 0x0100) >> 8);
216      setbank(m_bg2_tilemap, 1, (data & 0x0800) >> 11);
219217   }
220218}
221219
r20741r20742
223221{
224222   if (ACCESSING_BITS_0_7)
225223   {
226      setbank(machine(), m_bg1_tilemap, 0, (data & 0x07));
227      setbank(machine(), m_bg2_tilemap, 1, (data & 0x38) >> 3);
224      setbank(m_bg1_tilemap, 0, (data & 0x07));
225      setbank(m_bg2_tilemap, 1, (data & 0x38) >> 3);
228226   }
229227}
230228
r20741r20742
234232
235233   data = COMBINE_DATA(&m_bank[offset]);
236234
237   setbank(machine(), tmap, 4 * offset + 0, (data >> 0) & 0x0f);
238   setbank(machine(), tmap, 4 * offset + 1, (data >> 4) & 0x0f);
239   setbank(machine(), tmap, 4 * offset + 2, (data >> 8) & 0x0f);
240   setbank(machine(), tmap, 4 * offset + 3, (data >> 12) & 0x0f);
235   setbank(tmap, 4 * offset + 0, (data >> 0) & 0x0f);
236   setbank(tmap, 4 * offset + 1, (data >> 4) & 0x0f);
237   setbank(tmap, 4 * offset + 2, (data >> 8) & 0x0f);
238   setbank(tmap, 4 * offset + 3, (data >> 12) & 0x0f);
241239}
242240
243241WRITE16_MEMBER(aerofgt_state::aerofgt_gfxbank_w)
r20741r20742
246244
247245   data = COMBINE_DATA(&m_bank[offset]);
248246
249   setbank(machine(), tmap, 2 * offset + 0, (data >> 8) & 0xff);
250   setbank(machine(), tmap, 2 * offset + 1, (data >> 0) & 0xff);
247   setbank(tmap, 2 * offset + 0, (data >> 8) & 0xff);
248   setbank(tmap, 2 * offset + 1, (data >> 0) & 0xff);
251249}
252250
253251WRITE16_MEMBER(aerofgt_state::aerofgt_bg1scrollx_w)
r20741r20742
422420
423421   m_sprite_gfx = 1;
424422
425   aerofgt_register_state_globals(machine());
423   aerofgt_register_state_globals();
426424
427425   save_item(NAME(m_wbbc97_bitmap_enable));
428426}
r20741r20742
432430{
433431   COMBINE_DATA(&m_rasterram[0x200 / 2]);
434432
435   setbank(machine(), m_bg1_tilemap, 0, (data & 0xf000) >> 12);
436   setbank(machine(), m_bg1_tilemap, 1, (data & 0x0f00) >> 8);
433   setbank(m_bg1_tilemap, 0, (data & 0xf000) >> 12);
434   setbank(m_bg1_tilemap, 1, (data & 0x0f00) >> 8);
437435}
438436
439437// BOOTLEG
r20741r20742
449447}
450448
451449// BOOTLEG
452static void aerfboo2_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
450void aerofgt_state::aerfboo2_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri )
453451{
454   aerofgt_state *state = machine.driver_data<aerofgt_state>();
455452   int attr_start, base, first;
456453
457454   base = chip * 0x0200;
458//  first = 4 * state->m_spriteram3[0x1fe + base];
455//  first = 4 * m_spriteram3[0x1fe + base];
459456   first = 0;
460457
461458   for (attr_start = base + 0x0200 - 4; attr_start >= first + base; attr_start -= 4)
r20741r20742
465462// some other drivers still use this wrong table, they have to be upgraded
466463//      int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
467464
468      if (!(state->m_spriteram3[attr_start + 2] & 0x0080))
465      if (!(m_spriteram3[attr_start + 2] & 0x0080))
469466         continue;
470467
471      pri = state->m_spriteram3[attr_start + 2] & 0x0010;
468      pri = m_spriteram3[attr_start + 2] & 0x0010;
472469
473470      if ( chip_disabled_pri & !pri)
474471         continue;
475472      if ((!chip_disabled_pri) & (pri >> 4))
476473         continue;
477      ox = state->m_spriteram3[attr_start + 1] & 0x01ff;
478      xsize = (state->m_spriteram3[attr_start + 2] & 0x0700) >> 8;
479      zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12;
480      oy = state->m_spriteram3[attr_start + 0] & 0x01ff;
481      ysize = (state->m_spriteram3[attr_start + 2] & 0x7000) >> 12;
482      zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12;
483      flipx = state->m_spriteram3[attr_start + 2] & 0x0800;
484      flipy = state->m_spriteram3[attr_start + 2] & 0x8000;
485      color = (state->m_spriteram3[attr_start + 2] & 0x000f) + 16 * state->m_spritepalettebank;
474      ox = m_spriteram3[attr_start + 1] & 0x01ff;
475      xsize = (m_spriteram3[attr_start + 2] & 0x0700) >> 8;
476      zoomx = (m_spriteram3[attr_start + 1] & 0xf000) >> 12;
477      oy = m_spriteram3[attr_start + 0] & 0x01ff;
478      ysize = (m_spriteram3[attr_start + 2] & 0x7000) >> 12;
479      zoomy = (m_spriteram3[attr_start + 0] & 0xf000) >> 12;
480      flipx = m_spriteram3[attr_start + 2] & 0x0800;
481      flipy = m_spriteram3[attr_start + 2] & 0x8000;
482      color = (m_spriteram3[attr_start + 2] & 0x000f) + 16 * m_spritepalettebank;
486483
487      map_start = state->m_spriteram3[attr_start + 3];
484      map_start = m_spriteram3[attr_start + 3];
488485
489486// aerofgt has this adjustment, but doing it here would break turbo force title screen
490487//      ox += (xsize*zoomx+2)/4;
r20741r20742
512509               sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
513510
514511            if (chip == 0)
515               code = state->m_spriteram1[map_start % (state->m_spriteram1.bytes()/2)];
512               code = m_spriteram1[map_start % (m_spriteram1.bytes()/2)];
516513            else
517               code = state->m_spriteram2[map_start % (state->m_spriteram2.bytes()/2)];
514               code = m_spriteram2[map_start % (m_spriteram2.bytes()/2)];
518515
519            pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + chip],
516            pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx + chip],
520517                        code,
521518                        color,
522519                        flipx,flipy,
523520                        sx,sy,
524521                        zoomx << 11, zoomy << 11,
525                        machine.priority_bitmap,pri ? 0 : 2,15);
522                        machine().priority_bitmap,pri ? 0 : 2,15);
526523            map_start++;
527524         }
528525
r20741r20742
535532}
536533
537534// BOOTLEG
538static void pspikesb_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
535void aerofgt_state::pspikesb_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
539536{
540   aerofgt_state *state = machine.driver_data<aerofgt_state>();
541537   int i;
542538
543   for (i = 4; i < state->m_spriteram3.bytes() / 2; i += 4)
539   for (i = 4; i < m_spriteram3.bytes() / 2; i += 4)
544540   {
545541      int xpos, ypos, color, flipx, flipy, code;
546542
547      if (state->m_spriteram3[i + 3 - 4] & 0x8000)
543      if (m_spriteram3[i + 3 - 4] & 0x8000)
548544         break;
549545
550      xpos = (state->m_spriteram3[i + 2] & 0x1ff) - 34;
551      ypos = 256 - (state->m_spriteram3[i + 3 - 4] & 0x1ff) - 33;
552      code = state->m_spriteram3[i + 0] & 0x1fff;
546      xpos = (m_spriteram3[i + 2] & 0x1ff) - 34;
547      ypos = 256 - (m_spriteram3[i + 3 - 4] & 0x1ff) - 33;
548      code = m_spriteram3[i + 0] & 0x1fff;
553549      flipy = 0;
554      flipx = state->m_spriteram3[i + 1] & 0x0800;
555      color = state->m_spriteram3[i + 1] & 0x000f;
550      flipx = m_spriteram3[i + 1] & 0x0800;
551      color = m_spriteram3[i + 1] & 0x000f;
556552
557      drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx],
553      drawgfx_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx],
558554            code,
559555            color,
560556            flipx,flipy,
561557            xpos,ypos,15);
562558
563559      /* wrap around y */
564      drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx],
560      drawgfx_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx],
565561            code,
566562            color,
567563            flipx,flipy,
r20741r20742
571567}
572568
573569// BOOTLEG
574static void spikes91_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
570void aerofgt_state::spikes91_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
575571{
576   aerofgt_state *state = machine.driver_data<aerofgt_state>();
577572   int i;
578573   UINT8 *lookup;
579   lookup = state->memregion("user1")->base();
580   state->m_spritepalettebank = 1;
574   lookup = memregion("user1")->base();
575   m_spritepalettebank = 1;
581576
582   for (i = state->m_spriteram3.bytes() / 2 - 4; i >= 4; i -= 4)
577   for (i = m_spriteram3.bytes() / 2 - 4; i >= 4; i -= 4)
583578   {
584579      int xpos, ypos, color, flipx, flipy, code, realcode;
585580
586      code = state->m_spriteram3[i + 0] & 0x1fff;
581      code = m_spriteram3[i + 0] & 0x1fff;
587582
588583      if (!code)
589584         continue;
590585
591      xpos = (state->m_spriteram3[i + 2] & 0x01ff) - 16;
592      ypos = 256 - (state->m_spriteram3[i + 1] & 0x00ff) - 26;
586      xpos = (m_spriteram3[i + 2] & 0x01ff) - 16;
587      ypos = 256 - (m_spriteram3[i + 1] & 0x00ff) - 26;
593588      flipy = 0;
594      flipx = state->m_spriteram3[i + 3] & 0x8000;
595      color = ((state->m_spriteram3[i + 3] & 0x00f0) >> 4);
589      flipx = m_spriteram3[i + 3] & 0x8000;
590      color = ((m_spriteram3[i + 3] & 0x00f0) >> 4);
596591
597      code |= state->m_spikes91_lookup * 0x2000;
592      code |= m_spikes91_lookup * 0x2000;
598593
599594      realcode = (lookup[code] << 8) + lookup[0x10000 + code];
600595
601      drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx],
596      drawgfx_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx],
602597            realcode,
603598            color,
604599            flipx,flipy,
605600            xpos,ypos,15);
606601
607602      /* wrap around y */
608      drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx],
603      drawgfx_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx],
609604            realcode,
610605            color,
611606            flipx,flipy,
r20741r20742
614609}
615610
616611// BOOTLEG
617static void aerfboot_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
612void aerofgt_state::aerfboot_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
618613{
619   aerofgt_state *state = machine.driver_data<aerofgt_state>();
620614   int attr_start, last;
621615
622   last = ((state->m_rasterram[0x404 / 2] << 5) - 0x8000) / 2;
616   last = ((m_rasterram[0x404 / 2] << 5) - 0x8000) / 2;
623617
624   for (attr_start = state->m_spriteram3.bytes() / 2 - 4; attr_start >= last; attr_start -= 4)
618   for (attr_start = m_spriteram3.bytes() / 2 - 4; attr_start >= last; attr_start -= 4)
625619   {
626620      int code;
627621      int ox, oy, sx, sy, zoomx, zoomy, flipx, flipy, color, pri;
628622
629      ox = state->m_spriteram3[attr_start + 1] & 0x01ff;
630      oy = state->m_spriteram3[attr_start + 0] & 0x01ff;
631      flipx = state->m_spriteram3[attr_start + 2] & 0x0800;
632      flipy = state->m_spriteram3[attr_start + 2] & 0x8000;
633      color = state->m_spriteram3[attr_start + 2] & 0x000f;
623      ox = m_spriteram3[attr_start + 1] & 0x01ff;
624      oy = m_spriteram3[attr_start + 0] & 0x01ff;
625      flipx = m_spriteram3[attr_start + 2] & 0x0800;
626      flipy = m_spriteram3[attr_start + 2] & 0x8000;
627      color = m_spriteram3[attr_start + 2] & 0x000f;
634628
635      zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12;
636      zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12;
637      pri = state->m_spriteram3[attr_start + 2] & 0x0010;
638      code = state->m_spriteram3[attr_start + 3] & 0x1fff;
629      zoomx = (m_spriteram3[attr_start + 1] & 0xf000) >> 12;
630      zoomy = (m_spriteram3[attr_start + 0] & 0xf000) >> 12;
631      pri = m_spriteram3[attr_start + 2] & 0x0010;
632      code = m_spriteram3[attr_start + 3] & 0x1fff;
639633
640      if (!(state->m_spriteram3[attr_start + 2] & 0x0040))
634      if (!(m_spriteram3[attr_start + 2] & 0x0040))
641635         code |= 0x2000;
642636
643637      zoomx = 32 + zoomx;
r20741r20742
647641
648642      sx = ((ox + 16 + 3) & 0x1ff) - 16;
649643
650      pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + (code >= 0x1000 ? 0 : 1)],
644      pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx + (code >= 0x1000 ? 0 : 1)],
651645            code,
652646            color,
653647            flipx,flipy,
654648            sx,sy,
655649            zoomx << 11,zoomy << 11,
656            machine.priority_bitmap,pri ? 0 : 2,15);
650            machine().priority_bitmap,pri ? 0 : 2,15);
657651
658652   }
659653
660   last = ((state->m_rasterram[0x402 / 2] << 5) - 0x8000) / 2;
654   last = ((m_rasterram[0x402 / 2] << 5) - 0x8000) / 2;
661655
662   for (attr_start = ((state->m_spriteram3.bytes() / 2) / 2) - 4; attr_start >= last; attr_start -= 4)
656   for (attr_start = ((m_spriteram3.bytes() / 2) / 2) - 4; attr_start >= last; attr_start -= 4)
663657   {
664658      int code;
665659      int ox, oy, sx, sy, zoomx, zoomy, flipx, flipy, color, pri;
666660
667      ox = state->m_spriteram3[attr_start + 1] & 0x01ff;
668      oy = state->m_spriteram3[attr_start + 0] & 0x01ff;
669      flipx = state->m_spriteram3[attr_start + 2] & 0x0800;
670      flipy = state->m_spriteram3[attr_start + 2] & 0x8000;
671      color = state->m_spriteram3[attr_start + 2] & 0x000f;
661      ox = m_spriteram3[attr_start + 1] & 0x01ff;
662      oy = m_spriteram3[attr_start + 0] & 0x01ff;
663      flipx = m_spriteram3[attr_start + 2] & 0x0800;
664      flipy = m_spriteram3[attr_start + 2] & 0x8000;
665      color = m_spriteram3[attr_start + 2] & 0x000f;
672666
673      zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12;
674      zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12;
675      pri = state->m_spriteram3[attr_start + 2] & 0x0010;
676      code = state->m_spriteram3[attr_start + 3] & 0x1fff;
667      zoomx = (m_spriteram3[attr_start + 1] & 0xf000) >> 12;
668      zoomy = (m_spriteram3[attr_start + 0] & 0xf000) >> 12;
669      pri = m_spriteram3[attr_start + 2] & 0x0010;
670      code = m_spriteram3[attr_start + 3] & 0x1fff;
677671
678      if (!(state->m_spriteram3[attr_start + 2] & 0x0040))
672      if (!(m_spriteram3[attr_start + 2] & 0x0040))
679673         code |= 0x2000;
680674
681675      zoomx = 32 + zoomx;
r20741r20742
685679
686680      sx = ((ox + 16 + 3) & 0x1ff) - 16;
687681
688      pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + (code >= 0x1000 ? 0 : 1)],
682      pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx + (code >= 0x1000 ? 0 : 1)],
689683            code,
690684            color,
691685            flipx,flipy,
692686            sx,sy,
693687            zoomx << 11,zoomy << 11,
694            machine.priority_bitmap,pri ? 0 : 2,15);
688            machine().priority_bitmap,pri ? 0 : 2,15);
695689
696690   }
697691}
698692
699693// BOOTLEG
700static void wbbc97_draw_bitmap( running_machine &machine, bitmap_rgb32 &bitmap )
694void aerofgt_state::wbbc97_draw_bitmap( bitmap_rgb32 &bitmap )
701695{
702   aerofgt_state *state = machine.driver_data<aerofgt_state>();
703696   int x, y, count;
704697
705698   count = 16; // weird, the bitmap doesn't start at 0?
706699   for (y = 0; y < 256; y++)
707700      for (x = 0; x < 512; x++)
708701      {
709         int color = state->m_bitmapram[count] >> 1;
702         int color = m_bitmapram[count] >> 1;
710703
711704         /* data is GRB; convert to RGB */
712705         rgb_t pen = MAKE_RGB(pal5bit((color & 0x3e0) >> 5), pal5bit((color & 0x7c00) >> 10), pal5bit(color & 0x1f));
713         bitmap.pix32(y, (10 + x - state->m_rasterram[(y & 0x7f)]) & 0x1ff) = pen;
706         bitmap.pix32(y, (10 + x - m_rasterram[(y & 0x7f)]) & 0x1ff) = pen;
714707
715708         count++;
716709         count &= 0x1ffff;
r20741r20742
729722   m_bg1_tilemap->set_scrolly(0, scrolly);
730723
731724   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
732   pspikesb_draw_sprites(machine(), bitmap, cliprect);
725   pspikesb_draw_sprites(bitmap, cliprect);
733726   return 0;
734727}
735728
r20741r20742
749742   m_bg1_tilemap->set_scrolly(0, scrolly);
750743
751744   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
752   spikes91_draw_sprites(machine(), bitmap, cliprect);
745   spikes91_draw_sprites(bitmap, cliprect);
753746
754747   /* we could use a tilemap, but it's easier to just do it here */
755748   count = 0;
r20741r20742
793786   m_bg2_tilemap->draw(bitmap, cliprect, 0, 1);
794787
795788   /* we use the priority buffer so sprites are drawn front to back */
796   aerfboot_draw_sprites(machine(), bitmap, cliprect);
789   aerfboot_draw_sprites(bitmap, cliprect);
797790   return 0;
798791}
799792
r20741r20742
817810   m_bg2_tilemap->draw(bitmap, cliprect, 0, 1);
818811
819812   /* we use the priority buffer so sprites are drawn front to back */
820   aerfboo2_draw_sprites(machine(), bitmap, cliprect, 1, -1); //ship
821   aerfboo2_draw_sprites(machine(), bitmap, cliprect, 1, 0); //intro
822   aerfboo2_draw_sprites(machine(), bitmap, cliprect, 0, -1); //enemy
823   aerfboo2_draw_sprites(machine(), bitmap, cliprect, 0, 0); //enemy
813   aerfboo2_draw_sprites(bitmap, cliprect, 1, -1); //ship
814   aerfboo2_draw_sprites(bitmap, cliprect, 1, 0); //intro
815   aerfboo2_draw_sprites(bitmap, cliprect, 0, -1); //enemy
816   aerfboo2_draw_sprites(bitmap, cliprect, 0, 0); //enemy
824817   return 0;
825818}
826819
r20741r20742
839832
840833   if (m_wbbc97_bitmap_enable)
841834   {
842      wbbc97_draw_bitmap(machine(), bitmap);
835      wbbc97_draw_bitmap(bitmap);
843836      m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
844837   }
845838   else
trunk/src/mame/video/arabian.c
r20741r20742
219219 *
220220 *************************************/
221221
222static void blit_area( running_machine &machine, UINT8 plane, UINT16 src, UINT8 x, UINT8 y, UINT8 sx, UINT8 sy )
222void arabian_state::blit_area( UINT8 plane, UINT16 src, UINT8 x, UINT8 y, UINT8 sx, UINT8 sy )
223223{
224   arabian_state *state = machine.driver_data<arabian_state>();
225   UINT8 *srcdata = &state->m_converted_gfx[src * 4];
224   UINT8 *srcdata = &m_converted_gfx[src * 4];
226225   int i,j;
227226
228227   /* loop over X, then Y */
r20741r20742
236235         UINT8 *base;
237236
238237         /* get a pointer to the bitmap */
239         base = &state->m_main_bitmap[((y + j) & 0xff) * BITMAP_WIDTH + (x & 0xff)];
238         base = &m_main_bitmap[((y + j) & 0xff) * BITMAP_WIDTH + (x & 0xff)];
240239
241240         /* bit 0 means write to upper plane (upper 4 bits of our bitmap) */
242241         if (plane & 0x01)
r20741r20742
283282      int sy    = m_blitter[5];
284283
285284      /* blit it */
286      blit_area(machine(), plane, src, x, y, sx, sy);
285      blit_area(plane, src, x, y, sx, sy);
287286   }
288287}
289288
trunk/src/mame/video/ambush.c
r20741r20742
4848}
4949
5050
51static void draw_chars( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
51void ambush_state::draw_chars( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
5252{
53   ambush_state *state = machine.driver_data<ambush_state>();
5453   int offs, transpen;
5554
5655   transpen = (priority == 0) ? -1 : 0;
5756
58   for (offs = 0; offs < state->m_videoram.bytes(); offs++)
57   for (offs = 0; offs < m_videoram.bytes(); offs++)
5958   {
6059      int code, sx, sy, col;
6160      UINT8 scroll;
r20741r20742
6362      sy = (offs / 32);
6463      sx = (offs % 32);
6564
66      col = state->m_colorram[((sy & 0x1c) << 3) + sx];
65      col = m_colorram[((sy & 0x1c) << 3) + sx];
6766
6867      if (priority & ~col)
6968         continue;
7069
71      scroll = ~state->m_scrollram[sx];
70      scroll = ~m_scrollram[sx];
7271
73      code = state->m_videoram[offs] | ((col & 0x60) << 3);
72      code = m_videoram[offs] | ((col & 0x60) << 3);
7473
75      if (state->flip_screen())
74      if (flip_screen())
7675      {
7776         sx = 31 - sx;
7877         sy = 31 - sy;
7978         scroll = ~scroll - 1;
8079      }
8180
82      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
81      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
8382         code,
84         (col & 0x0f) | ((*state->m_colorbank & 0x03) << 4),
85         state->flip_screen(), state->flip_screen(),
83         (col & 0x0f) | ((*m_colorbank & 0x03) << 4),
84         flip_screen(), flip_screen(),
8685         8 * sx, (8 * sy + scroll) & 0xff, transpen);
8786   }
8887}
r20741r20742
9594   bitmap.fill(0, cliprect);
9695
9796   /* Draw the characters */
98   draw_chars(machine(), bitmap, cliprect, 0x00);
97   draw_chars(bitmap, cliprect, 0x00);
9998
10099   /* Draw the sprites. */
101100   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
r20741r20742
153152   }
154153
155154   /* Draw the foreground priority characters over the sprites */
156   draw_chars(machine(), bitmap, cliprect, 0x10);
155   draw_chars(bitmap, cliprect, 0x10);
157156   return 0;
158157}
trunk/src/mame/video/balsente.c
r20741r20742
119119 *
120120 *************************************/
121121
122static void draw_one_sprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *sprite)
122void balsente_state::draw_one_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *sprite)
123123{
124   balsente_state *state = machine.driver_data<balsente_state>();
125124   int flags = sprite[0];
126125   int image = sprite[1] | ((flags & 7) << 8);
127126   int ypos = sprite[2] + 17 + BALSENTE_VBEND;
r20741r20742
130129   int x, y;
131130
132131   /* get a pointer to the source image */
133   src = &state->m_sprite_data[(64 * image) & state->m_sprite_mask];
132   src = &m_sprite_data[(64 * image) & m_sprite_mask];
134133   if (flags & 0x80) src += 4 * 15;
135134
136135   /* loop over y */
r20741r20742
138137   {
139138      if (ypos >= (16 + BALSENTE_VBEND) && ypos >= cliprect.min_y && ypos <= cliprect.max_y)
140139      {
141         const pen_t *pens = &machine.pens[state->m_palettebank_vis * 256];
142         UINT8 *old = &state->m_expanded_videoram[(ypos - BALSENTE_VBEND) * 256 + xpos];
140         const pen_t *pens = &machine().pens[m_palettebank_vis * 256];
141         UINT8 *old = &m_expanded_videoram[(ypos - BALSENTE_VBEND) * 256 + xpos];
143142         int currx = xpos;
144143
145144         /* standard case */
r20741r20742
214213
215214   /* draw the sprite images */
216215   for (i = 0; i < 40; i++)
217      draw_one_sprite(machine(), bitmap, cliprect, &m_spriteram[(0xe0 + i * 4) & 0xff]);
216      draw_one_sprite(bitmap, cliprect, &m_spriteram[(0xe0 + i * 4) & 0xff]);
218217
219218   return 0;
220219}
trunk/src/mame/video/argus.c
r20741r20742
259259  Initialize and destroy video hardware emulation
260260***************************************************************************/
261261
262static void reset_common(running_machine &machine)
262void argus_state::reset_common()
263263{
264   argus_state *state = machine.driver_data<argus_state>();
265   state->m_bg_status = 0x01;
266   state->m_flipscreen = 0;
267   state->m_palette_intensity = 0;
264   m_bg_status = 0x01;
265   m_flipscreen = 0;
266   m_palette_intensity = 0;
268267}
269268
270269VIDEO_START_MEMBER(argus_state,argus)
r20741r20742
290289   m_bg0_scrollx[0] = 0;
291290   m_bg0_scrollx[1] = 0;
292291   memset(m_dummy_bg0ram, 0, 0x800);
293   reset_common(machine());
292   reset_common();
294293}
295294
296295VIDEO_START_MEMBER(argus_state,valtric)
r20741r20742
309308VIDEO_RESET_MEMBER(argus_state,valtric)
310309{
311310   m_valtric_mosaic = 0x0f;
312   reset_common(machine());
311   reset_common();
313312}
314313
315314VIDEO_START_MEMBER(argus_state,butasan)
r20741r20742
339338   m_butasan_bg1_status = 0x01;
340339   memset(m_butasan_pagedram[0], 0, 0x1000);
341340   memset(m_butasan_pagedram[1], 0, 0x1000);
342   reset_common(machine());
341   reset_common();
343342}
344343
345344
r20741r20742
348347***************************************************************************/
349348
350349/* Write bg0 pattern data to dummy bg0 ram */
351static void argus_write_dummy_rams(running_machine &machine, int dramoffs, int vromoffs)
350void argus_state::argus_write_dummy_rams(int dramoffs, int vromoffs)
352351{
353   argus_state *state = machine.driver_data<argus_state>();
354352   int i;
355353   int voffs;
356354   int offs;
357355
358   UINT8 *VROM1 = state->memregion("user1")->base();       /* "ag_15.bin" */
359   UINT8 *VROM2 = state->memregion("user2")->base();       /* "ag_16.bin" */
356   UINT8 *VROM1 = memregion("user1")->base();       /* "ag_15.bin" */
357   UINT8 *VROM2 = memregion("user2")->base();       /* "ag_16.bin" */
360358
361359   /* offset in pattern data */
362360   offs = VROM1[vromoffs] | (VROM1[vromoffs + 1] << 8);
r20741r20742
365363   voffs = offs * 16;
366364   for (i = 0; i < 8; i++)
367365   {
368      state->m_dummy_bg0ram[dramoffs]     = VROM2[voffs];
369      state->m_dummy_bg0ram[dramoffs + 1] = VROM2[voffs + 1];
370      state->m_bg0_tilemap->mark_tile_dirty(dramoffs >> 1);
366      m_dummy_bg0ram[dramoffs]     = VROM2[voffs];
367      m_dummy_bg0ram[dramoffs + 1] = VROM2[voffs + 1];
368      m_bg0_tilemap->mark_tile_dirty(dramoffs >> 1);
371369      dramoffs += 2;
372370      voffs += 2;
373371   }
374372}
375373
376static void argus_change_palette(running_machine &machine, int color, int lo_offs, int hi_offs)
374void argus_state::argus_change_palette(int color, int lo_offs, int hi_offs)
377375{
378   argus_state *state = machine.driver_data<argus_state>();
379   UINT8 lo = state->m_paletteram[lo_offs];
380   UINT8 hi = state->m_paletteram[hi_offs];
376   UINT8 lo = m_paletteram[lo_offs];
377   UINT8 hi = m_paletteram[hi_offs];
381378   jal_blend_set(color, hi & 0x0f);
382   palette_set_color_rgb(machine, color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4));
379   palette_set_color_rgb(machine(), color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4));
383380}
384381
385static void argus_change_bg_palette(running_machine &machine, int color, int lo_offs, int hi_offs)
382void argus_state::argus_change_bg_palette(int color, int lo_offs, int hi_offs)
386383{
387   argus_state *state = machine.driver_data<argus_state>();
388384   UINT8 r,g,b,lo,hi,ir,ig,ib,ix;
389385   rgb_t rgb,irgb;
390386
391387   /* red,green,blue intensities */
392   ir = pal4bit(state->m_palette_intensity >> 12);
393   ig = pal4bit(state->m_palette_intensity >>  8);
394   ib = pal4bit(state->m_palette_intensity >>  4);
395   ix = state->m_palette_intensity & 0x0f;
388   ir = pal4bit(m_palette_intensity >> 12);
389   ig = pal4bit(m_palette_intensity >>  8);
390   ib = pal4bit(m_palette_intensity >>  4);
391   ix = m_palette_intensity & 0x0f;
396392
397393   irgb = MAKE_RGB(ir,ig,ib);
398394
399   lo = state->m_paletteram[lo_offs];
400   hi = state->m_paletteram[hi_offs];
395   lo = m_paletteram[lo_offs];
396   hi = m_paletteram[hi_offs];
401397
402398   /* red,green,blue component */
403399   r = pal4bit(lo >> 4);
r20741r20742
405401   b = pal4bit(hi >> 4);
406402
407403   /* Grey background enable */
408   if (state->m_bg_status & 2)
404   if (m_bg_status & 2)
409405   {
410406      UINT8 val = (r + g + b) / 3;
411407      rgb = MAKE_RGB(val,val,val);
r20741r20742
417413
418414   rgb = jal_blend_func(rgb,irgb,ix);
419415
420   palette_set_color(machine,color,rgb);
416   palette_set_color(machine(),color,rgb);
421417}
422418
423419
r20741r20742
465461
466462         for (offs = 0x400; offs < 0x500; offs++)
467463         {
468            argus_change_bg_palette(machine(), (offs - 0x400) + 0x080, offs, offs + 0x400);
464            argus_change_bg_palette((offs - 0x400) + 0x080, offs, offs + 0x400);
469465         }
470466      }
471467   }
r20741r20742
484480
485481         for (offs = 0x400; offs < 0x600; offs += 2)
486482         {
487            argus_change_bg_palette(machine(), ((offs - 0x400) >> 1) + 0x100, offs & ~1, offs | 1);
483            argus_change_bg_palette(((offs - 0x400) >> 1) + 0x100, offs & ~1, offs | 1);
488484         }
489485      }
490486   }
r20741r20742
526522   {
527523      offset &= 0x07f;
528524
529      argus_change_palette(machine(), offset, offset, offset + 0x080);
525      argus_change_palette(offset, offset, offset + 0x080);
530526
531527      if (offset == 0x07f || offset == 0x0ff)
532528      {
533529         m_palette_intensity = m_paletteram[0x0ff] | (m_paletteram[0x07f] << 8);
534530
535531         for (offs = 0x400; offs < 0x500; offs++)
536            argus_change_bg_palette(machine(), (offs & 0xff) + 0x080, offs, offs + 0x400);
532            argus_change_bg_palette((offs & 0xff) + 0x080, offs, offs + 0x400);
537533      }
538534   }
539535   else if ((offset >= 0x400 && offset <= 0x4ff) ||
r20741r20742
542538      offs = offset & 0xff;
543539      offset = offs | 0x400;
544540
545      argus_change_bg_palette(machine(), offs + 0x080, offset, offset + 0x400);
541      argus_change_bg_palette(offs + 0x080, offset, offset + 0x400);
546542   }
547543   else if ((offset >= 0x500 && offset <= 0x5ff) ||
548544            (offset >= 0x900 && offset <= 0x9ff))       /* BG1 color */
r20741r20742
550546      offs = offset & 0xff;
551547      offset = offs | 0x500;
552548
553      argus_change_palette(machine(), offs + 0x180, offset, offset + 0x400);
549      argus_change_palette(offs + 0x180, offset, offset + 0x400);
554550   }
555551   else if ((offset >= 0x700 && offset <= 0x7ff) ||
556552            (offset >= 0xb00 && offset <= 0xbff))       /* text color */
r20741r20742
558554      offs = offset & 0xff;
559555      offset = offs | 0x700;
560556
561      argus_change_palette(machine(), offs + 0x280, offset, offset + 0x400);
557      argus_change_palette(offs + 0x280, offset, offset + 0x400);
562558   }
563559}
564560
r20741r20742
568564
569565   if (offset <= 0x1ff)                            /* Sprite color */
570566   {
571      argus_change_palette(machine(), offset >> 1, offset & ~1, offset | 1);
567      argus_change_palette(offset >> 1, offset & ~1, offset | 1);
572568
573569      if (offset == 0x1fe || offset == 0x1ff)
574570      {
r20741r20742
577573         m_palette_intensity = m_paletteram[0x1ff] | (m_paletteram[0x1fe] << 8);
578574
579575         for (offs = 0x400; offs < 0x600; offs += 2)
580            argus_change_bg_palette(machine(), ((offs & 0x1ff) >> 1) + 0x100, offs & ~1, offs | 1);
576            argus_change_bg_palette(((offs & 0x1ff) >> 1) + 0x100, offs & ~1, offs | 1);
581577      }
582578   }
583579   else if (offset >= 0x400 && offset <= 0x5ff)        /* BG color */
584580   {
585      argus_change_bg_palette(machine(), ((offset & 0x1ff) >> 1) + 0x100, offset & ~1, offset | 1);
581      argus_change_bg_palette(((offset & 0x1ff) >> 1) + 0x100, offset & ~1, offset | 1);
586582   }
587583   else if (offset >= 0x600 && offset <= 0x7ff)        /* Text color */
588584   {
589      argus_change_palette(machine(), ((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1);
585      argus_change_palette(((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1);
590586   }
591587}
592588
r20741r20742
596592
597593   if (offset <= 0x1ff)                            /* BG0 color */
598594   {
599      argus_change_palette(machine(), (offset >> 1) + 0x100, offset & ~1, offset | 1);
595      argus_change_palette((offset >> 1) + 0x100, offset & ~1, offset | 1);
600596   }
601597   else if (offset <= 0x23f)                       /* BG1 color */
602598   {
603      argus_change_palette(machine(), ((offset & 0x3f) >> 1) + 0x0c0, offset & ~1, offset | 1);
599      argus_change_palette(((offset & 0x3f) >> 1) + 0x0c0, offset & ~1, offset | 1);
604600   }
605601   else if (offset >= 0x400 && offset <= 0x47f)    /* Sprite color */
606602   {                                               /* 16 colors */
607      argus_change_palette(machine(), (offset & 0x7f) >> 1, offset & ~1, offset | 1);
603      argus_change_palette((offset & 0x7f) >> 1, offset & ~1, offset | 1);
608604   }
609605   else if (offset >= 0x480 && offset <= 0x4ff)    /* Sprite color */
610606   {                                               /* 8  colors */
611607      int offs = (offset & 0x070) | ((offset & 0x00f) >> 1);
612608
613      argus_change_palette(machine(), offs + 0x040, offset & ~1, offset | 1);
614      argus_change_palette(machine(), offs + 0x048, offset & ~1, offset | 1);
609      argus_change_palette(offs + 0x040, offset & ~1, offset | 1);
610      argus_change_palette(offs + 0x048, offset & ~1, offset | 1);
615611   }
616612   else if (offset >= 0x600 && offset <= 0x7ff)    /* Text color */
617613   {
618      argus_change_palette(machine(), ((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1);
614      argus_change_palette(((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1);
619615   }
620616   else if (offset >= 0x240 && offset <= 0x25f)    // dummy
621      argus_change_palette(machine(), ((offset & 0x1f) >> 1) + 0xe0, offset & ~1, offset | 1);
617      argus_change_palette(((offset & 0x1f) >> 1) + 0xe0, offset & ~1, offset | 1);
622618   else if (offset >= 0x500 && offset <= 0x51f)    // dummy
623      argus_change_palette(machine(), ((offset & 0x1f) >> 1) + 0xf0, offset & ~1, offset | 1);
619      argus_change_palette(((offset & 0x1f) >> 1) + 0xf0, offset & ~1, offset | 1);
624620}
625621
626622READ8_MEMBER(argus_state::butasan_bg1ram_r)
r20741r20742
689685  Screen refresh
690686***************************************************************************/
691687
692#define bg0_scrollx (state->m_bg0_scrollx[0] | (state->m_bg0_scrollx[1] << 8))
693#define bg0_scrolly (state->m_bg0_scrolly[0] | (state->m_bg0_scrolly[1] << 8))
694#define bg1_scrollx (state->m_bg1_scrollx[0] | (state->m_bg1_scrollx[1] << 8))
695#define bg1_scrolly (state->m_bg1_scrolly[0] | (state->m_bg1_scrolly[1] << 8))
688#define bg0_scrollx (m_bg0_scrollx[0] | (m_bg0_scrollx[1] << 8))
689#define bg0_scrolly (m_bg0_scrolly[0] | (m_bg0_scrolly[1] << 8))
690#define bg1_scrollx (m_bg1_scrollx[0] | (m_bg1_scrollx[1] << 8))
691#define bg1_scrolly (m_bg1_scrolly[0] | (m_bg1_scrolly[1] << 8))
696692
697static void bg_setting(running_machine &machine)
693void argus_state::bg_setting()
698694{
699   argus_state *state = machine.driver_data<argus_state>();
700   machine.tilemap().set_flip_all(state->m_flipscreen ? TILEMAP_FLIPY|TILEMAP_FLIPX : 0);
695   machine().tilemap().set_flip_all(m_flipscreen ? TILEMAP_FLIPY|TILEMAP_FLIPX : 0);
701696
702   if (!state->m_flipscreen)
697   if (!m_flipscreen)
703698   {
704      if (state->m_bg0_tilemap != NULL)
699      if (m_bg0_tilemap != NULL)
705700      {
706         state->m_bg0_tilemap->set_scrollx(0, bg0_scrollx & 0x1ff);
707         state->m_bg0_tilemap->set_scrolly(0, bg0_scrolly & 0x1ff);
701         m_bg0_tilemap->set_scrollx(0, bg0_scrollx & 0x1ff);
702         m_bg0_tilemap->set_scrolly(0, bg0_scrolly & 0x1ff);
708703      }
709      state->m_bg1_tilemap->set_scrollx(0, bg1_scrollx & 0x1ff);
710      state->m_bg1_tilemap->set_scrolly(0, bg1_scrolly & 0x1ff);
704      m_bg1_tilemap->set_scrollx(0, bg1_scrollx & 0x1ff);
705      m_bg1_tilemap->set_scrolly(0, bg1_scrolly & 0x1ff);
711706   }
712707   else
713708   {
714      if (state->m_bg0_tilemap != NULL)
709      if (m_bg0_tilemap != NULL)
715710      {
716         state->m_bg0_tilemap->set_scrollx(0, (bg0_scrollx + 256) & 0x1ff);
717         state->m_bg0_tilemap->set_scrolly(0, (bg0_scrolly + 256) & 0x1ff);
711         m_bg0_tilemap->set_scrollx(0, (bg0_scrollx + 256) & 0x1ff);
712         m_bg0_tilemap->set_scrolly(0, (bg0_scrolly + 256) & 0x1ff);
718713      }
719      state->m_bg1_tilemap->set_scrollx(0, (bg1_scrollx + 256) & 0x1ff);
720      state->m_bg1_tilemap->set_scrolly(0, (bg1_scrolly + 256) & 0x1ff);
714      m_bg1_tilemap->set_scrollx(0, (bg1_scrollx + 256) & 0x1ff);
715      m_bg1_tilemap->set_scrolly(0, (bg1_scrolly + 256) & 0x1ff);
721716   }
722717}
723718
724static void argus_bg0_scroll_handle(running_machine &machine)
719void argus_state::argus_bg0_scroll_handle()
725720{
726   argus_state *state = machine.driver_data<argus_state>();
727721   int delta;
728722   int dcolumn;
729723
730724   /* Deficit between previous and current scroll value */
731   delta = bg0_scrollx - state->m_prvscrollx;
732   state->m_prvscrollx = bg0_scrollx;
725   delta = bg0_scrollx - m_prvscrollx;
726   m_prvscrollx = bg0_scrollx;
733727
734728   if (delta == 0)
735729      return;
736730
737731   if (delta > 0)
738732   {
739      state->m_lowbitscroll += delta % 16;
733      m_lowbitscroll += delta % 16;
740734      dcolumn = delta / 16;
741735
742      if (state->m_lowbitscroll >= 16)
736      if (m_lowbitscroll >= 16)
743737      {
744738         dcolumn++;
745         state->m_lowbitscroll -= 16;
739         m_lowbitscroll -= 16;
746740      }
747741
748742      if (dcolumn != 0)
r20741r20742
761755         {
762756            for (j = 0; j < 4; j++)
763757            {
764               argus_write_dummy_rams(machine, woffs, roffs);
758               argus_write_dummy_rams(woffs, roffs);
765759               woffs += 16;
766760               roffs += 2;
767761            }
r20741r20742
776770   }
777771   else
778772   {
779      state->m_lowbitscroll += (delta % 16);
773      m_lowbitscroll += (delta % 16);
780774      dcolumn = -(delta / 16);
781775
782      if (state->m_lowbitscroll <= 0)
776      if (m_lowbitscroll <= 0)
783777      {
784778         dcolumn++;
785         state->m_lowbitscroll += 16;
779         m_lowbitscroll += 16;
786780      }
787781
788782      if (dcolumn != 0)
r20741r20742
803797         {
804798            for (j = 0; j < 4; j++)
805799            {
806               argus_write_dummy_rams(machine, woffs, roffs);
800               argus_write_dummy_rams(woffs, roffs);
807801               woffs += 16;
808802               roffs += 2;
809803            }
r20741r20742
816810   }
817811}
818812
819static void argus_draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority)
813void argus_state::argus_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority)
820814{
821   argus_state *state = machine.driver_data<argus_state>();
822   UINT8 *spriteram = state->m_spriteram;
815   UINT8 *spriteram = m_spriteram;
823816   int offs;
824817
825818   /* Draw the sprites */
826   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16)
819   for (offs = 0; offs < m_spriteram.bytes(); offs += 16)
827820   {
828821      if (!(spriteram[offs+15] == 0 && spriteram[offs+11] == 0xf0))
829822      {
r20741r20742
838831         color = spriteram[offs+15] & 0x07;
839832         pri   = (spriteram[offs+15] & 0x08) >> 3;
840833
841         if (state->m_flipscreen)
834         if (m_flipscreen)
842835         {
843836            sx = 240 - sx;
844837            sy = 240 - sy;
r20741r20742
848841
849842         if (priority != pri)
850843            jal_blend_drawgfx(
851                     bitmap,cliprect,machine.gfx[0],
844                     bitmap,cliprect,machine().gfx[0],
852845                     tile,
853846                     color,
854847                     flipx, flipy,
r20741r20742
859852}
860853
861854#if 1
862static void valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
855void argus_state::valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
863856{
864   argus_state *state = screen.machine().driver_data<argus_state>();
865
866   if (state->m_valtric_mosaic!=0x80)
857   if (m_valtric_mosaic!=0x80)
867858   {
868      state->m_mosaic=0x0f-(state->m_valtric_mosaic&0x0f);
869      if (state->m_mosaic!=0) state->m_mosaic++;
870      if (state->m_valtric_mosaic&0x80) state->m_mosaic*=-1;
859      m_mosaic=0x0f-(m_valtric_mosaic&0x0f);
860      if (m_mosaic!=0) m_mosaic++;
861      if (m_valtric_mosaic&0x80) m_mosaic*=-1;
871862   }
872863
873   if (state->m_mosaic==0)
874      state->m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
864   if (m_mosaic==0)
865      m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
875866   else
876867   {
877      state->m_bg1_tilemap->draw(state->m_mosaicbitmap, cliprect, 0, 0);
868      m_bg1_tilemap->draw(m_mosaicbitmap, cliprect, 0, 0);
878869      {
879         int step=state->m_mosaic;
870         int step=m_mosaic;
880871         UINT32 *dest;
881872         int x,y,xx,yy,c=0;
882873         int width = screen.width();
883874         int height = screen.height();
884875
885         if (state->m_mosaic<0)step*=-1;
876         if (m_mosaic<0)step*=-1;
886877
887878         for (y=0;y<width+step;y+=step)
888879            for (x=0;x<height+step;x+=step)
889880            {
890881               if (y < height && x < width)
891                  c=state->m_mosaicbitmap.pix32(y, x);
882                  c=m_mosaicbitmap.pix32(y, x);
892883
893               if (state->m_mosaic<0)
884               if (m_mosaic<0)
894885                  if (y+step-1<height && x+step-1< width)
895                     c = state->m_mosaicbitmap.pix32(y+step-1, x+step-1);
886                     c = m_mosaicbitmap.pix32(y+step-1, x+step-1);
896887
897888               for (yy=0;yy<step;yy++)
898889                  for (xx=0;xx<step;xx++)
r20741r20742
908899   }
909900}
910901#else
911static void valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
902void argus_state::valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
912903{
913904   argus_state *state = screen.machine().driver_data<argus_state>();
914   int step = 0x10 - (state->m_valtric_mosaic & 0x0f);
905   int step = 0x10 - (m_valtric_mosaic & 0x0f);
915906
916907   if (step == 1)
917      state->m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
908      m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
918909   else
919910   {
920      state->m_bg1_tilemap->draw(state->m_mosaicbitmap, cliprect, 0, 0);
911      m_bg1_tilemap->draw(m_mosaicbitmap, cliprect, 0, 0);
921912      {
922913         UINT32 *dest;
923914         int x,y,xx,yy,c=0;
r20741r20742
928919            for (x = 0; x < height+step; x += step)
929920            {
930921               if (y < height && x < width)
931                  c = state->m_mosaicbitmap.pix32(y, x);
922                  c = m_mosaicbitmap.pix32(y, x);
932923
933               if (state->m_valtric_mosaic & 0x80)
924               if (m_valtric_mosaic & 0x80)
934925                  if (y+step-1 < height && x+step-1 < width)
935                     c = state->m_mosaicbitmap.pix32(y+step-1, x+step-1);
926                     c = m_mosaicbitmap.pix32(y+step-1, x+step-1);
936927
937928               for (yy = 0; yy < step; yy++)
938929                  for (xx = 0; xx < step; xx++)
r20741r20742
949940}
950941#endif
951942
952static void valtric_draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
943void argus_state::valtric_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
953944{
954   argus_state *state = machine.driver_data<argus_state>();
955   UINT8 *spriteram = state->m_spriteram;
945   UINT8 *spriteram = m_spriteram;
956946   int offs;
957947
958948   /* Draw the sprites */
959   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16)
949   for (offs = 0; offs < m_spriteram.bytes(); offs += 16)
960950   {
961951      if (!(spriteram[offs+15] == 0 && spriteram[offs+11] == 0xf0))
962952      {
r20741r20742
970960         flipy = spriteram[offs+13] & 0x20;
971961         color = spriteram[offs+15] & 0x0f;
972962
973         if (state->m_flipscreen)
963         if (m_flipscreen)
974964         {
975965            sx = 240 - sx;
976966            sy = 240 - sy;
r20741r20742
979969         }
980970
981971         jal_blend_drawgfx(
982                  bitmap,cliprect,machine.gfx[0],
972                  bitmap,cliprect,machine().gfx[0],
983973                  tile,
984974                  color,
985975                  flipx, flipy,
r20741r20742
989979   }
990980}
991981
992static void butasan_draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
982void argus_state::butasan_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
993983{
994   argus_state *state = machine.driver_data<argus_state>();
995   UINT8 *spriteram = state->m_spriteram;
984   UINT8 *spriteram = m_spriteram;
996985   int offs;
997986
998987   /* Draw the sprites */
999   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16)
988   for (offs = 0; offs < m_spriteram.bytes(); offs += 16)
1000989   {
1001990      int sx, sy, tile, flipx, flipy, color;
1002991      int fx, fy;
r20741r20742
10171006      fx = flipx;
10181007      fy = flipy;
10191008
1020      if (state->m_flipscreen)
1009      if (m_flipscreen)
10211010      {
10221011         sx = 240 - sx;
10231012         sy = 240 - sy;
r20741r20742
10311020         if ((offs >= 0x100 && offs <= 0x2ff) || (offs >= 0x400 && offs <= 0x57f))
10321021         {
10331022            jal_blend_drawgfx(
1034                     bitmap,cliprect,machine.gfx[0],
1023                     bitmap,cliprect,machine().gfx[0],
10351024                     tile,
10361025                     color,
10371026                     flipx, flipy,
r20741r20742
10451034               td = (fx) ? (1 - i) : i;
10461035
10471036               jal_blend_drawgfx(
1048                        bitmap,cliprect,machine.gfx[0],
1037                        bitmap,cliprect,machine().gfx[0],
10491038                        tile + td,
10501039                        color,
10511040                        flipx, flipy,
r20741r20742
10651054                     td = (fx) ? (i * 2) + 1 - j : i * 2 + j;
10661055
10671056                  jal_blend_drawgfx(
1068                           bitmap,cliprect,machine.gfx[0],
1057                           bitmap,cliprect,machine().gfx[0],
10691058                           tile + td,
10701059                           color,
10711060                           flipx, flipy,
r20741r20742
10861075                     td = (fx) ? (i * 4) + 3 - j : i * 4 + j;
10871076
10881077                  jal_blend_drawgfx(
1089                           bitmap,cliprect,machine.gfx[0],
1078                           bitmap,cliprect,machine().gfx[0],
10901079                           tile + td,
10911080                           color,
10921081                           flipx, flipy,
r20741r20742
11001089}
11011090
11021091
1103static void butasan_log_vram(running_machine &machine)
1092void argus_state::butasan_log_vram()
11041093{
11051094#ifdef MAME_DEBUG
1106   argus_state *state = machine.driver_data<argus_state>();
11071095   int offs;
11081096
1109   if (machine.input().code_pressed(KEYCODE_M))
1097   if (machine().input().code_pressed(KEYCODE_M))
11101098   {
1111      UINT8 *spriteram = state->m_spriteram;
1099      UINT8 *spriteram = m_spriteram;
11121100      int i;
11131101      logerror("\nSprite RAM\n");
11141102      logerror("---------------------------------------\n");
11151103      logerror("       +0 +1 +2 +3 +4 +5 +6 +7  +8 +9 +a +b +c +d +e +f\n");
1116      for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16)
1104      for (offs = 0; offs < m_spriteram.bytes(); offs += 16)
11171105      {
11181106         for (i = 0; i < 16; i++)
11191107         {
r20741r20742
11401128            if (i == 0)
11411129            {
11421130               logerror("%04x : ", offs + 0xc400);
1143               logerror("%02x ", state->m_paletteram[offs]);
1131               logerror("%02x ", m_paletteram[offs]);
11441132            }
11451133            else if (i == 7)
1146               logerror("%02x  ", state->m_paletteram[offs + 7]);
1134               logerror("%02x  ", m_paletteram[offs + 7]);
11471135            else if (i == 15)
1148               logerror("%02x\n", state->m_paletteram[offs + 15]);
1136               logerror("%02x\n", m_paletteram[offs + 15]);
11491137            else
1150               logerror("%02x ", state->m_paletteram[offs + i]);
1138               logerror("%02x ", m_paletteram[offs + i]);
11511139         }
11521140      }
11531141   }
r20741r20742
11561144
11571145UINT32 argus_state::screen_update_argus(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
11581146{
1159   bg_setting(machine());
1147   bg_setting();
11601148
11611149   /* scroll BG0 and render tile at proper position */
1162   argus_bg0_scroll_handle(machine());
1150   argus_bg0_scroll_handle();
11631151
11641152   m_bg0_tilemap->draw(bitmap, cliprect, 0, 0);
1165   argus_draw_sprites(machine(), bitmap, cliprect, 0);
1153   argus_draw_sprites(bitmap, cliprect, 0);
11661154   if (m_bg_status & 1)    /* Backgound enable */
11671155      m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
1168   argus_draw_sprites(machine(), bitmap, cliprect, 1);
1156   argus_draw_sprites(bitmap, cliprect, 1);
11691157   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
11701158   return 0;
11711159}
11721160
11731161UINT32 argus_state::screen_update_valtric(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
11741162{
1175   bg_setting(machine());
1163   bg_setting();
11761164
11771165   if (m_bg_status & 1)    /* Backgound enable */
11781166      valtric_draw_mosaic(screen, bitmap, cliprect);
11791167   else
11801168      bitmap.fill(get_black_pen(machine()), cliprect);
1181   valtric_draw_sprites(machine(), bitmap, cliprect);
1169   valtric_draw_sprites(bitmap, cliprect);
11821170   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
11831171   return 0;
11841172}
11851173
11861174UINT32 argus_state::screen_update_butasan(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
11871175{
1188   bg_setting(machine());
1176   bg_setting();
11891177
11901178   if (m_bg_status & 1)    /* Backgound enable */
11911179      m_bg0_tilemap->draw(bitmap, cliprect, 0, 0);
11921180   else
11931181      bitmap.fill(get_black_pen(machine()), cliprect);
11941182   if (m_butasan_bg1_status & 1) m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
1195   butasan_draw_sprites(machine(), bitmap, cliprect);
1183   butasan_draw_sprites(bitmap, cliprect);
11961184   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
11971185
1198   butasan_log_vram(machine());
1186   butasan_log_vram();
11991187   return 0;
12001188}
trunk/src/mame/includes/armedf.h
r20741r20742
8080   DECLARE_VIDEO_START(terraf);
8181   DECLARE_VIDEO_START(armedf);
8282   UINT32 screen_update_armedf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
83   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
84   void armedf_drawgfx(bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
85                  UINT32 code,UINT32 color, UINT32 clut,int flipx,int flipy,int offsx,int offsy,
86                  int transparent_color);
87   
8388};
8489
8590class bigfghtr_state : public armedf_state
trunk/src/mame/includes/blktiger.h
r20741r20742
6363   virtual void machine_reset();
6464   virtual void video_start();
6565   UINT32 screen_update_blktiger(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
66   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6667};
trunk/src/mame/includes/bublbobl.h
r20741r20742
112112   INTERRUPT_GEN_MEMBER(bublbobl_m68705_interrupt);
113113   TIMER_CALLBACK_MEMBER(nmi_callback);
114114   TIMER_CALLBACK_MEMBER(bublbobl_m68705_irq_ack);
115   void configure_banks(  );
115116};
trunk/src/mame/includes/aztarac.h
r20741r20742
2929   virtual void video_start();
3030   INTERRUPT_GEN_MEMBER(aztarac_snd_timed_irq);
3131   IRQ_CALLBACK_MEMBER(aztarac_irq_callback);
32   inline void read_vectorram(UINT16 *vectorram, int addr, int *x, int *y, int *c);
3233};
trunk/src/mame/includes/amspdwy.h
r20741r20742
4444   virtual void machine_reset();
4545   virtual void video_start();
4646   UINT32 screen_update_amspdwy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
47   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
48   UINT8 amspdwy_wheel_r( int index );
4749};
trunk/src/mame/includes/balsente.h
r20741r20742
201201   TIMER_DEVICE_CALLBACK_MEMBER(balsente_interrupt_timer);
202202   TIMER_DEVICE_CALLBACK_MEMBER(balsente_counter_callback);
203203   TIMER_DEVICE_CALLBACK_MEMBER(balsente_clock_counter_0_ff);
204   void draw_one_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *sprite);
205   void poly17_init();
206   void m6850_update_io();
207   void set_counter_0_ff(timer_device &timer, int newstate);
208   void update_grudge_steering();
209   void expand_roms(UINT8 cd_rom_mask);
210   inline void config_shooter_adc(UINT8 shooter, UINT8 adc_shift);
204211};
205212
206213
trunk/src/mame/includes/atarifb.h
r20741r20742
8282   UINT32 screen_update_atarifb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8383   UINT32 screen_update_abaseb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8484   UINT32 screen_update_soccer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
85   void get_tile_info_common( tile_data &tileinfo, tilemap_memory_index tile_index, UINT8 *alpha_videoram );
86   void draw_playfield_and_alpha( bitmap_ind16 &bitmap, const rectangle &cliprect, int playfield_x_offset, int playfield_y_offset );
87   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int gfx, int is_soccer );
8588};
8689
8790/*----------- defined in audio/atarifb.c -----------*/
trunk/src/mame/includes/bwing.h
r20741r20742
7676   virtual void video_start();
7777   UINT32 screen_update_bwing(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7878   INTERRUPT_GEN_MEMBER(bwp3_interrupt);
79   void fill_srxlat( int *xlat );
80   void draw_sprites( bitmap_ind16 &bmp, const rectangle &clip, UINT8 *ram, int pri );
81   void fix_bwp3(  );
7982};
8083
8184/*----------- defined in video/bwing.c -----------*/
trunk/src/mame/includes/bsktball.h
r20741r20742
6262   DECLARE_WRITE8_MEMBER(bsktball_bounce_w);
6363   DECLARE_WRITE8_MEMBER(bsktball_note_w);
6464   DECLARE_WRITE8_MEMBER(bsktball_noise_reset_w);
65   void draw_sprites(  bitmap_ind16 &bitmap, const rectangle &cliprect );
6566};
6667
6768/*----------- defined in audio/bsktball.c -----------*/
trunk/src/mame/includes/1942.h
r20741r20742
4141   virtual void palette_init();
4242   UINT32 screen_update_1942(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4343   TIMER_DEVICE_CALLBACK_MEMBER(c1942_scanline);
44   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4445};
trunk/src/mame/includes/20pacgal.h
r20741r20742
5757   UINT32 screen_update_20pacgal(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5858   INTERRUPT_GEN_MEMBER(vblank_irq);
5959   void set_bankptr();
60   void get_pens(pen_t *pens);
61   void do_pen_lookup(bitmap_rgb32 &bitmap, const rectangle &cliprect);
62   void draw_sprites(bitmap_rgb32 &bitmap);
63   void draw_chars(bitmap_rgb32 &bitmap);
64   void draw_stars(bitmap_rgb32 &bitmap, const rectangle &cliprect );
65   void draw_sprite(bitmap_rgb32 &bitmap, int y, int x,
66                UINT8 code, UINT8 color, int flip_y, int flip_x);
67   
6068};
6169
6270
trunk/src/mame/includes/actfancr.h
r20741r20742
3434   DECLARE_MACHINE_START(triothep);
3535   DECLARE_MACHINE_RESET(triothep);
3636   UINT32 screen_update_actfancr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
37   void register_savestate(  );
3738};
3839
3940
trunk/src/mame/includes/1943.h
r20741r20742
4747   virtual void video_start();
4848   virtual void palette_init();
4949   UINT32 screen_update_1943(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
50   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
5051};
trunk/src/mame/includes/bbusters.h
r20741r20742
5757   UINT32 screen_update_bbuster(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5858   UINT32 screen_update_mechatt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5959   void screen_eof_bbuster(screen_device &screen, bool state);
60   inline const UINT8 *get_source_ptr(gfx_element *gfx, UINT32 sprite, int dx, int dy, int block);
61   void bbusters_draw_block(bitmap_ind16 &dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block);
62   void draw_sprites(bitmap_ind16 &bitmap, const UINT16 *source, int bank, int colval, int colmask);
6063};
trunk/src/mame/includes/arcadecl.h
r20741r20742
2424   DECLARE_MACHINE_RESET(arcadecl);
2525   DECLARE_VIDEO_START(arcadecl);
2626   UINT32 screen_update_arcadecl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
27   void arcadecl_bitmap_render(bitmap_ind16 &bitmap, const rectangle &cliprect);
2728};
trunk/src/mame/includes/bagman.h
r20741r20742
4949   DECLARE_PALETTE_INIT(bagman);
5050   UINT32 screen_update_bagman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5151   INTERRUPT_GEN_MEMBER(vblank_irq);
52   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5253};
5354
5455/*----------- timings -----------*/
trunk/src/mame/includes/brkthru.h
r20741r20742
4747   virtual void palette_init();
4848   UINT32 screen_update_brkthru(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4949   INTERRUPT_GEN_MEMBER(vblank_irq);
50   void show_register( bitmap_ind16 &bitmap, int x, int y, UINT32 data );
51   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int prio );
5052};
trunk/src/mame/includes/argus.h
r20741r20742
8585   UINT32 screen_update_butasan(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
8686   TIMER_DEVICE_CALLBACK_MEMBER(argus_scanline);
8787   TIMER_DEVICE_CALLBACK_MEMBER(butasan_scanline);
88   void reset_common();
89   void argus_write_dummy_rams(int dramoffs, int vromoffs);
90   void argus_change_palette(int color, int lo_offs, int hi_offs);
91   void argus_change_bg_palette(int color, int lo_offs, int hi_offs);
92   void bg_setting();
93   void argus_bg0_scroll_handle();
94   void argus_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority);
95   void valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
96   void valtric_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect);
97   void butasan_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect);
98   void butasan_log_vram();
8899};
trunk/src/mame/includes/40love.h
r20741r20742
9898   UINT32 screen_update_fortyl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9999   TIMER_CALLBACK_MEMBER(nmi_callback);
100100   void redraw_pixels();
101   void fortyl_set_scroll_x( int offset );
102   void fortyl_plot_pix( int offset );
103   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
104   void draw_pixram( bitmap_ind16 &bitmap, const rectangle &cliprect );
101105};
trunk/src/mame/includes/alpha68k.h
r20741r20742
105105   UINT32 screen_update_alpha68k_V(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
106106   UINT32 screen_update_alpha68k_V_sb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
107107   INTERRUPT_GEN_MEMBER(alpha68k_sound_nmi);
108   void alpha68k_flipscreen_w( int flip );
109   void alpha68k_V_video_bank_w( int bank );
110   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e );
111   void draw_sprites_V( bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e, int fx_mask, int fy_mask, int sprite_mask );
112   void draw_sprites_I( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d, int yshift );
113   void kyros_video_banking(int *bank, int data);
114   void jongbou_video_banking(int *bank, int data);
115   void kyros_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d );
116   void sstingry_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d );
108117};
109118
110119/* game_id - used to deal with a few game specific situations */
r20741r20742
116125};
117126
118127
119/*----------- defined in video/alpha68k.c -----------*/
120void alpha68k_V_video_bank_w(running_machine &machine, int bank);
121void alpha68k_flipscreen_w(running_machine &machine, int flip);
trunk/src/mame/includes/aerofgt.h
r20741r20742
111111   UINT32 screen_update_aerfboot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
112112   UINT32 screen_update_aerfboo2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
113113   UINT32 screen_update_wbbc97(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
114   void aerofgt_register_state_globals(  );
115   void setbank( tilemap_t *tmap, int num, int bank );
116   void aerfboo2_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri );
117   void pspikesb_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
118   void spikes91_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
119   void aerfboot_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
120   void wbbc97_draw_bitmap( bitmap_rgb32 &bitmap );
114121};
trunk/src/mame/includes/8080bw.h
r20741r20742
133133   DECLARE_WRITE8_MEMBER(polaris_sh_port_3_w);
134134   
135135   void schaser_reinit_555_time_remain();
136   void invadpt2_get_pens( pen_t *pens );
137   void sflush_get_pens( pen_t *pens );
138   void cosmo_get_pens( pen_t *pens );
139   inline void set_pixel( bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color );
140   inline void set_8_pixels( bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, UINT8 data, pen_t *pens, UINT8 fore_color, UINT8 back_color );
141   void clear_extra_columns( bitmap_rgb32 &bitmap, pen_t *pens, UINT8 color );
136142};
137143
138144
trunk/src/mame/includes/atarisy1.h
r20741r20742
7070   TIMER_DEVICE_CALLBACK_MEMBER(atarisy1_reset_yscroll_callback);
7171   TIMER_DEVICE_CALLBACK_MEMBER(atarisy1_int3off_callback);
7272   TIMER_DEVICE_CALLBACK_MEMBER(atarisy1_int3_callback);
73   void update_timers(int scanline);
74   void decode_gfx(UINT16 *pflookup, UINT16 *molookup);
75   int get_bank(UINT8 prom1, UINT8 prom2, int bpp);
7376};
7477
7578DECLARE_READ16_HANDLER( atarisy1_int3state_r );
trunk/src/mame/includes/aquarium.h
r20741r20742
4747   virtual void machine_reset();
4848   virtual void video_start();
4949   UINT32 screen_update_aquarium(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
50   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs );
51   UINT8 aquarium_snd_bitswap( UINT8 scrambled_data );
5052};
trunk/src/mame/includes/angelkds.h
r20741r20742
6060   virtual void machine_reset();
6161   virtual void video_start();
6262   UINT32 screen_update_angelkds(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
63   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int enable_n);
6364};
trunk/src/mame/includes/arabian.h
r20741r20742
4343   virtual void video_start();
4444   virtual void palette_init();
4545   UINT32 screen_update_arabian(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
46   void blit_area( UINT8 plane, UINT16 src, UINT8 x, UINT8 y, UINT8 sx, UINT8 sy );
4647};
trunk/src/mame/includes/btime.h
r20741r20742
116116   UINT32 screen_update_zoar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
117117   UINT32 screen_update_disco(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
118118   TIMER_DEVICE_CALLBACK_MEMBER(audio_nmi_gen);
119   void draw_chars( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 transparency, UINT8 color, int priority );
120   void draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8* tmap, UINT8 color );
121   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 color,
122                     UINT8 sprite_y_adjust, UINT8 sprite_y_adjust_flip_screen,
123                     UINT8 *sprite_ram, offs_t interleave );
124   
119125};
trunk/src/mame/includes/bigevglf.h
r20741r20742
9393   TIMER_CALLBACK_MEMBER(from_sound_latch_callback);
9494   TIMER_CALLBACK_MEMBER(nmi_callback);
9595   TIMER_CALLBACK_MEMBER(deferred_ls74_w);
96   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
9697};
trunk/src/mame/includes/bloodbro.h
r20741r20742
2929   UINT32 screen_update_bloodbro(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3030   UINT32 screen_update_weststry(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3131   UINT32 screen_update_skysmash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
32   void bloodbro_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
33   void weststry_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3234};
trunk/src/mame/includes/bombjack.h
r20741r20742
4242   UINT32 screen_update_bombjack(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4343   INTERRUPT_GEN_MEMBER(vblank_irq);
4444   TIMER_CALLBACK_MEMBER(soundlatch_callback);
45   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4546};
trunk/src/mame/includes/battlera.h
r20741r20742
4242   virtual void video_start();
4343   UINT32 screen_update_battlera(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444   TIMER_DEVICE_CALLBACK_MEMBER(battlera_irq);
45   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &clip,int pri);
4546};
trunk/src/mame/includes/astrocde.h
r20741r20742
125125   TIMER_CALLBACK_MEMBER(interrupt_off);
126126   TIMER_CALLBACK_MEMBER(scanline_callback);
127127   void profbank_banksw_restore();
128   inline int mame_vpos_to_astrocade_vpos(int scanline);
129   void init_savestate();
130   void astrocade_trigger_lightpen(UINT8 vfeedback, UINT8 hfeedback);
131   inline void increment_source(UINT8 curwidth, UINT8 *u13ff);
132   inline void increment_dest(UINT8 curwidth);
133   void execute_blit(address_space &space);
134   void init_sparklestar();
128135};
129136
130137/*----------- defined in audio/wow.c -----------*/
trunk/src/mame/includes/appoooh.h
r20741r20742
5353   UINT32 screen_update_appoooh(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   UINT32 screen_update_robowres(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   INTERRUPT_GEN_MEMBER(vblank_irq);
56   void appoooh_draw_sprites( bitmap_ind16 &dest_bmp, const rectangle &cliprect, gfx_element *gfx, UINT8 *sprite );
57   void robowres_draw_sprites( bitmap_ind16 &dest_bmp, const rectangle &cliprect, gfx_element *gfx, UINT8 *sprite );
5658};
5759
5860#define CHR1_OFST   0x00  /* palette page of char set #1 */
trunk/src/mame/includes/blockout.h
r20741r20742
3737   virtual void video_start();
3838   UINT32 screen_update_blockout(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3939   TIMER_DEVICE_CALLBACK_MEMBER(blockout_scanline);
40   void setcolor( int color, int rgb );
41   void update_pixels( int x, int y );
4042};
trunk/src/mame/includes/blmbycar.h
r20741r20742
5050   DECLARE_MACHINE_START(watrball);
5151   DECLARE_MACHINE_RESET(watrball);
5252   UINT32 screen_update_blmbycar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
53   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5354};
trunk/src/mame/includes/bogeyman.h
r20741r20742
4646   virtual void video_start();
4747   virtual void palette_init();
4848   UINT32 screen_update_bogeyman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
49   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4950};
trunk/src/mame/includes/aeroboto.h
r20741r20742
6060   virtual void video_start();
6161   UINT32 screen_update_aeroboto(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6262   INTERRUPT_GEN_MEMBER(aeroboto_interrupt);
63   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6364};
trunk/src/mame/includes/bionicc.h
r20741r20742
5252   virtual void video_start();
5353   UINT32 screen_update_bionicc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   TIMER_DEVICE_CALLBACK_MEMBER(bionicc_scanline);
55   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5556};
trunk/src/mame/includes/battlex.h
r20741r20742
3737   virtual void video_start();
3838   UINT32 screen_update_battlex(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3939   INTERRUPT_GEN_MEMBER(battlex_interrupt);
40   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4041};
trunk/src/mame/includes/boogwing.h
r20741r20742
5454   DECLARE_DRIVER_INIT(boogwing);
5555   virtual void video_start();
5656   UINT32 screen_update_boogwing(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
57   void mix_boogwing(bitmap_rgb32 &bitmap, const rectangle &cliprect);
5758};
trunk/src/mame/includes/blueprnt.h
r20741r20742
4444   DECLARE_VIDEO_START(blueprnt);
4545   virtual void palette_init();
4646   UINT32 screen_update_blueprnt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
47   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4748};
trunk/src/mame/includes/buggychl.h
r20741r20742
5757   virtual void palette_init();
5858   UINT32 screen_update_buggychl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5959   TIMER_CALLBACK_MEMBER(nmi_callback);
60   void draw_sky( bitmap_ind16 &bitmap, const rectangle &cliprect );
61   void draw_bg( bitmap_ind16 &bitmap, const rectangle &cliprect );
62   void draw_fg( bitmap_ind16 &bitmap, const rectangle &cliprect );
63   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6064};
trunk/src/mame/includes/bigstrkb.h
r20741r20742
3131   TILE_GET_INFO_MEMBER(get_bsb_tile3_info);
3232   virtual void video_start();
3333   UINT32 screen_update_bigstrkb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
34   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
3435};
trunk/src/mame/includes/ambush.h
r20741r20742
2626   DECLARE_WRITE8_MEMBER(flip_screen_w);
2727   virtual void palette_init();
2828   UINT32 screen_update_ambush(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
29   void draw_chars( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
2930};
trunk/src/mame/includes/baraduke.h
r20741r20742
4040   virtual void palette_init();
4141   UINT32 screen_update_baraduke(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4242   void screen_eof_baraduke(screen_device &screen, bool state);
43   void scroll_w(address_space &space, int layer, int offset, int data);
44   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_priority);
45   void set_scroll(int layer);
4346};
trunk/src/mame/includes/arkanoid.h
r20741r20742
8585   UINT32 screen_update_arkanoid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8686   UINT32 screen_update_hexa(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8787   TIMER_CALLBACK_MEMBER(test);
88   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
89   void arkanoid_bootleg_init(  );
8890};
trunk/src/mame/includes/battlane.h
r20741r20742
4040   virtual void video_start();
4141   UINT32 screen_update_battlane(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4242   INTERRUPT_GEN_MEMBER(battlane_cpu1_interrupt);
43   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
44   void draw_fg_bitmap( bitmap_ind16 &bitmap );
4345};
trunk/src/mame/includes/astrof.h
r20741r20742
7171   UINT32 screen_update_astrof(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
7272   UINT32 screen_update_tomahawk(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
7373   TIMER_DEVICE_CALLBACK_MEMBER(irq_callback);
74   rgb_t make_pen( UINT8 data );
75   void astrof_get_pens( pen_t *pens );
76   void tomahawk_get_pens( pen_t *pens );
77   void astrof_set_video_control_2( UINT8 data );
78   void spfghmk2_set_video_control_2( UINT8 data );
79   void tomahawk_set_video_control_2( UINT8 data );
80   void video_update_common( bitmap_rgb32 &bitmap, const rectangle &cliprect, pen_t *pens );
7481};
7582
7683/*----------- defined in audio/astrof.c -----------*/
trunk/src/mame/drivers/alpha68k.c
r20741r20742
218218{
219219   logerror("tnextspc_unknown_w : PC = %04x - offset = %04x - data = %04x\n", space.device().safe_pc(), offset, data);
220220   if (offset == 0)
221      alpha68k_flipscreen_w(machine(), data & 0x100);
221      alpha68k_flipscreen_w(data & 0x100);
222222}
223223
224224WRITE16_MEMBER(alpha68k_state::alpha_microcontroller_w)
r20741r20742
226226   logerror("%04x:  Alpha write trigger at %04x (%04x)\n", space.device().safe_pc(), offset, data);
227227   /* 0x44 = coin clear signal to microcontroller? */
228228   if (offset == 0x2d && ACCESSING_BITS_0_7)
229      alpha68k_flipscreen_w(machine(), data & 1);
229      alpha68k_flipscreen_w(data & 1);
230230}
231231
232232/******************************************************************************/
r20741r20742
307307   if(ACCESSING_BITS_0_7)
308308      soundlatch_byte_w(space, 0, data & 0xff);
309309   if(ACCESSING_BITS_8_15)
310      alpha68k_V_video_bank_w(machine(), (data >> 8) & 0xff);
310      alpha68k_V_video_bank_w((data >> 8) & 0xff);
311311}
312312//AT
313313WRITE16_MEMBER(alpha68k_state::paddlema_soundlatch_w)
trunk/src/mame/drivers/missb2.c
r20741r20742
4040   DECLARE_MACHINE_RESET(missb2);
4141   UINT32 screen_update_missb2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4242   INTERRUPT_GEN_MEMBER(missb2_interrupt);
43   void configure_banks();
4344};
4445
4546
r20741r20742
571572ROM_END
572573
573574
574static void configure_banks( running_machine& machine )
575void missb2_state::configure_banks()
575576{
576   UINT8 *ROM = machine.root_device().memregion("maincpu")->base();
577   UINT8 *SLAVE = machine.root_device().memregion("slave")->base();
577   UINT8 *ROM = machine().root_device().memregion("maincpu")->base();
578   UINT8 *SLAVE = machine().root_device().memregion("slave")->base();
578579
579   machine.root_device().membank("bank1")->configure_entries(0, 8, &ROM[0x10000], 0x4000);
580   machine().root_device().membank("bank1")->configure_entries(0, 8, &ROM[0x10000], 0x4000);
580581
581582   /* 2009-11 FP: isn't there a way to configure both at once? */
582   machine.root_device().membank("bank2")->configure_entries(0, 7, &SLAVE[0x8000], 0x1000);
583   machine.root_device().membank("bank3")->configure_entries(0, 7, &SLAVE[0x9000], 0x1000);
583   machine().root_device().membank("bank2")->configure_entries(0, 7, &SLAVE[0x8000], 0x1000);
584   machine().root_device().membank("bank3")->configure_entries(0, 7, &SLAVE[0x9000], 0x1000);
584585}
585586
586587DRIVER_INIT_MEMBER(missb2_state,missb2)
587588{
588   configure_banks(machine());
589   configure_banks();
589590   m_video_enable = 0;
590591}
591592
trunk/src/mame/drivers/arkanoid.c
r20741r20742
15721572
15731573/* Driver Initialization */
15741574
1575static void arkanoid_bootleg_init( running_machine &machine )
1575void arkanoid_state::arkanoid_bootleg_init(  )
15761576{
1577   arkanoid_state *state = machine.driver_data<arkanoid_state>();
1578   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xf000, 0xf000, read8_delegate(FUNC(arkanoid_state::arkanoid_bootleg_f000_r),state) );
1579   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xf002, 0xf002, read8_delegate(FUNC(arkanoid_state::arkanoid_bootleg_f002_r),state) );
1580   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xd018, 0xd018, write8_delegate(FUNC(arkanoid_state::arkanoid_bootleg_d018_w),state) );
1581   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xd008, 0xd008, read8_delegate(FUNC(arkanoid_state::arkanoid_bootleg_d008_r),state) );
1577   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xf000, 0xf000, read8_delegate(FUNC(arkanoid_state::arkanoid_bootleg_f000_r),this) );
1578   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xf002, 0xf002, read8_delegate(FUNC(arkanoid_state::arkanoid_bootleg_f002_r),this) );
1579   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xd018, 0xd018, write8_delegate(FUNC(arkanoid_state::arkanoid_bootleg_d018_w),this) );
1580   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xd008, 0xd008, read8_delegate(FUNC(arkanoid_state::arkanoid_bootleg_d008_r),this) );
15821581}
15831582
15841583DRIVER_INIT_MEMBER(arkanoid_state,arkangc)
15851584{
15861585   m_bootleg_id = ARKANGC;
1587   arkanoid_bootleg_init(machine());
1586   arkanoid_bootleg_init();
15881587}
15891588
15901589DRIVER_INIT_MEMBER(arkanoid_state,arkangc2)
15911590{
15921591   m_bootleg_id = ARKANGC2;
1593   arkanoid_bootleg_init(machine());
1592   arkanoid_bootleg_init();
15941593}
15951594
15961595DRIVER_INIT_MEMBER(arkanoid_state,block2)
r20741r20742
16251624   auto_free(machine(), buffer);
16261625
16271626   m_bootleg_id = BLOCK2;
1628   arkanoid_bootleg_init(machine());
1627   arkanoid_bootleg_init();
16291628}
16301629
16311630DRIVER_INIT_MEMBER(arkanoid_state,arkblock)
16321631{
16331632   m_bootleg_id = ARKBLOCK;
1634   arkanoid_bootleg_init(machine());
1633   arkanoid_bootleg_init();
16351634}
16361635
16371636DRIVER_INIT_MEMBER(arkanoid_state,arkbloc2)
16381637{
16391638   m_bootleg_id = ARKBLOC2;
1640   arkanoid_bootleg_init(machine());
1639   arkanoid_bootleg_init();
16411640}
16421641
16431642DRIVER_INIT_MEMBER(arkanoid_state,arkgcbl)
16441643{
16451644   m_bootleg_id = ARKGCBL;
1646   arkanoid_bootleg_init(machine());
1645   arkanoid_bootleg_init();
16471646}
16481647
16491648DRIVER_INIT_MEMBER(arkanoid_state,paddle2)
16501649{
16511650   m_bootleg_id = PADDLE2;
1652   arkanoid_bootleg_init(machine());
1651   arkanoid_bootleg_init();
16531652}
16541653
16551654
trunk/src/mame/drivers/bublbobl.c
r20741r20742
15311531 *
15321532 *************************************/
15331533
1534static void configure_banks( running_machine& machine )
1534void bublbobl_state::configure_banks(  )
15351535{
1536   UINT8 *ROM = machine.root_device().memregion("maincpu")->base();
1537   machine.root_device().membank("bank1")->configure_entries(0, 8, &ROM[0x10000], 0x4000);
1536   UINT8 *ROM = machine().root_device().memregion("maincpu")->base();
1537   machine().root_device().membank("bank1")->configure_entries(0, 8, &ROM[0x10000], 0x4000);
15381538}
15391539
15401540DRIVER_INIT_MEMBER(bublbobl_state,bublbobl)
15411541{
1542   configure_banks(machine());
1542   configure_banks();
15431543
15441544   /* we init this here, so that it does not conflict with tokio init, below */
15451545   m_video_enable = 0;
r20741r20742
15471547
15481548DRIVER_INIT_MEMBER(bublbobl_state,tokio)
15491549{
1550   configure_banks(machine());
1550   configure_banks();
15511551
15521552   /* preemptively enable video, the bit is not mapped for this game and */
15531553   /* I don't know if it even has it. */
trunk/src/mame/drivers/balsente.c
r20741r20742
20672067#define EXPAND_NONE     0x3f
20682068#define SWAP_HALVES     0x80
20692069
2070static void expand_roms(running_machine &machine, UINT8 cd_rom_mask)
2070void balsente_state::expand_roms(UINT8 cd_rom_mask)
20712071{
20722072   /* load AB bank data from 0x10000-0x20000 */
20732073   /* load CD bank data from 0x20000-0x2e000 */
20742074   /* load EF           from 0x2e000-0x30000 */
20752075   /* ROM region must be 0x40000 total */
20762076
2077   UINT8 *temp = auto_alloc_array(machine, UINT8, 0x20000);
2077   UINT8 *temp = auto_alloc_array(machine(), UINT8, 0x20000);
20782078   {
2079      UINT8 *rom = machine.root_device().memregion("maincpu")->base();
2080      UINT32 len = machine.root_device().memregion("maincpu")->bytes();
2079      UINT8 *rom = machine().root_device().memregion("maincpu")->base();
2080      UINT32 len = machine().root_device().memregion("maincpu")->bytes();
20812081      UINT32 base;
20822082
20832083      for (base = 0x10000; base < len; base += 0x30000)
r20741r20742
21292129         memcpy(&rom[base + 0x00000], &ab_base[0x0000], 0x2000);
21302130      }
21312131
2132      auto_free(machine, temp);
2132      auto_free(machine(), temp);
21332133   }
21342134}
21352135
2136INLINE void config_shooter_adc(running_machine &machine, UINT8 shooter, UINT8 adc_shift)
2136inline void balsente_state::config_shooter_adc(UINT8 shooter, UINT8 adc_shift)
21372137{
2138   balsente_state *state = machine.driver_data<balsente_state>();
2139   state->m_shooter = shooter;
2140   state->m_adc_shift = adc_shift;
2138   m_shooter = shooter;
2139   m_adc_shift = adc_shift;
21412140}
21422141
2143DRIVER_INIT_MEMBER(balsente_state,sentetst)  { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 0 /* noanalog */); }
2144DRIVER_INIT_MEMBER(balsente_state,cshift)    { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 0 /* noanalog */); }
2145DRIVER_INIT_MEMBER(balsente_state,gghost)    { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 1); }
2146DRIVER_INIT_MEMBER(balsente_state,hattrick)  { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 0 /* noanalog */); }
2147DRIVER_INIT_MEMBER(balsente_state,otwalls)   { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 0); }
2148DRIVER_INIT_MEMBER(balsente_state,snakepit)  { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 1); }
2149DRIVER_INIT_MEMBER(balsente_state,snakjack)  { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 1); }
2150DRIVER_INIT_MEMBER(balsente_state,stocker)   { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 0); }
2151DRIVER_INIT_MEMBER(balsente_state,triviag1)  { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 0 /* noanalog */); }
2142DRIVER_INIT_MEMBER(balsente_state,sentetst)  { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 0 /* noanalog */); }
2143DRIVER_INIT_MEMBER(balsente_state,cshift)    { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 0 /* noanalog */); }
2144DRIVER_INIT_MEMBER(balsente_state,gghost)    { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 1); }
2145DRIVER_INIT_MEMBER(balsente_state,hattrick)  { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 0 /* noanalog */); }
2146DRIVER_INIT_MEMBER(balsente_state,otwalls)   { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 0); }
2147DRIVER_INIT_MEMBER(balsente_state,snakepit)  { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 1); }
2148DRIVER_INIT_MEMBER(balsente_state,snakjack)  { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 1); }
2149DRIVER_INIT_MEMBER(balsente_state,stocker)   { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 0); }
2150DRIVER_INIT_MEMBER(balsente_state,triviag1)  { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 0 /* noanalog */); }
21522151DRIVER_INIT_MEMBER(balsente_state,triviag2)
21532152{
21542153   UINT8 *rom = machine().root_device().memregion("maincpu")->base();
21552154   memcpy(&rom[0x20000], &rom[0x28000], 0x4000);
21562155   memcpy(&rom[0x24000], &rom[0x28000], 0x4000);
2157   expand_roms(machine(), EXPAND_NONE); config_shooter_adc(machine(), FALSE, 0 /* noanalog */);
2156   expand_roms(EXPAND_NONE); config_shooter_adc(FALSE, 0 /* noanalog */);
21582157}
2159DRIVER_INIT_MEMBER(balsente_state,triviaes)  { expand_roms(machine(), EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); }
2160DRIVER_INIT_MEMBER(balsente_state,gimeabrk)  { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 1); }
2161DRIVER_INIT_MEMBER(balsente_state,minigolf)  { expand_roms(machine(), EXPAND_NONE); config_shooter_adc(machine(), FALSE, 2); }
2162DRIVER_INIT_MEMBER(balsente_state,minigolf2) { expand_roms(machine(), 0x0c);        config_shooter_adc(machine(), FALSE, 2); }
2163DRIVER_INIT_MEMBER(balsente_state,toggle)    { expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 0 /* noanalog */); }
2158DRIVER_INIT_MEMBER(balsente_state,triviaes)  { expand_roms(EXPAND_NONE | SWAP_HALVES); config_shooter_adc(FALSE, 0 /* noanalog */); }
2159DRIVER_INIT_MEMBER(balsente_state,gimeabrk)  { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 1); }
2160DRIVER_INIT_MEMBER(balsente_state,minigolf)  { expand_roms(EXPAND_NONE); config_shooter_adc(FALSE, 2); }
2161DRIVER_INIT_MEMBER(balsente_state,minigolf2) { expand_roms(0x0c);        config_shooter_adc(FALSE, 2); }
2162DRIVER_INIT_MEMBER(balsente_state,toggle)    { expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 0 /* noanalog */); }
21642163DRIVER_INIT_MEMBER(balsente_state,nametune)
21652164{
21662165   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
21672166   space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this));
2168   expand_roms(machine(), EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 0 /* noanalog */);
2167   expand_roms(EXPAND_NONE | SWAP_HALVES); config_shooter_adc(FALSE, 0 /* noanalog */);
21692168}
21702169DRIVER_INIT_MEMBER(balsente_state,nstocker)
21712170{
21722171   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
21732172   space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this));
2174   expand_roms(machine(), EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine(), TRUE, 1);
2173   expand_roms(EXPAND_NONE | SWAP_HALVES); config_shooter_adc(TRUE, 1);
21752174}
21762175DRIVER_INIT_MEMBER(balsente_state,sfootbal)
21772176{
21782177   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
21792178   space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this));
2180   expand_roms(machine(), EXPAND_ALL  | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 0);
2179   expand_roms(EXPAND_ALL  | SWAP_HALVES); config_shooter_adc(FALSE, 0);
21812180}
21822181DRIVER_INIT_MEMBER(balsente_state,spiker)
21832182{
21842183   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
21852184   space.install_readwrite_handler(0x9f80, 0x9f8f, read8_delegate(FUNC(balsente_state::spiker_expand_r),this), write8_delegate(FUNC(balsente_state::spiker_expand_w),this));
21862185   space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this));
2187   expand_roms(machine(), EXPAND_ALL  | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 1);
2186   expand_roms(EXPAND_ALL  | SWAP_HALVES); config_shooter_adc(FALSE, 1);
21882187}
21892188DRIVER_INIT_MEMBER(balsente_state,stompin)
21902189{
21912190   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
21922191   space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this));
2193   expand_roms(machine(), 0x0c | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 32);
2192   expand_roms(0x0c | SWAP_HALVES); config_shooter_adc(FALSE, 32);
21942193}
2195DRIVER_INIT_MEMBER(balsente_state,rescraid)  { expand_roms(machine(), EXPAND_NONE); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); }
2194DRIVER_INIT_MEMBER(balsente_state,rescraid)  { expand_roms(EXPAND_NONE); config_shooter_adc(FALSE, 0 /* noanalog */); }
21962195DRIVER_INIT_MEMBER(balsente_state,grudge)
21972196{
21982197   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
21992198   space.install_read_handler(0x9400, 0x9400, read8_delegate(FUNC(balsente_state::grudge_steering_r),this));
2200   expand_roms(machine(), EXPAND_NONE); config_shooter_adc(machine(), FALSE, 0);
2199   expand_roms(EXPAND_NONE); config_shooter_adc(FALSE, 0);
22012200}
22022201DRIVER_INIT_MEMBER(balsente_state,shrike)
22032202{
r20741r20742
22062205   space.install_write_handler(0x9e01, 0x9e01, write8_delegate(FUNC(balsente_state::shrike_sprite_select_w),this));
22072206   machine().device("68k")->memory().space(AS_PROGRAM).install_readwrite_handler(0x10000, 0x1001f, read16_delegate(FUNC(balsente_state::shrike_io_68k_r),this), write16_delegate(FUNC(balsente_state::shrike_io_68k_w),this));
22082207
2209   expand_roms(machine(), EXPAND_ALL);  config_shooter_adc(machine(), FALSE, 32);
2208   expand_roms(EXPAND_ALL);  config_shooter_adc(FALSE, 32);
22102209}
22112210
22122211
trunk/src/mame/drivers/amspdwy.c
r20741r20742
3434    Or last value when wheel delta = 0
3535*/
3636
37static UINT8 amspdwy_wheel_r( running_machine &machine, int index )
37UINT8 amspdwy_state::amspdwy_wheel_r( int index )
3838{
39   amspdwy_state *state = machine.driver_data<amspdwy_state>();
4039   static const char *const portnames[] = { "WHEEL1", "WHEEL2", "AN1", "AN2" };
41   UINT8 wheel = machine.root_device().ioport(portnames[2 + index])->read();
42   if (wheel != state->m_wheel_old[index])
40   UINT8 wheel = machine().root_device().ioport(portnames[2 + index])->read();
41   if (wheel != m_wheel_old[index])
4342   {
4443      wheel = (wheel & 0x7fff) - (wheel & 0x8000);
45      if (wheel > state->m_wheel_old[index])
46      state->m_wheel_return[index] = ((+wheel) & 0xf) | 0x00;
44      if (wheel > m_wheel_old[index])
45      m_wheel_return[index] = ((+wheel) & 0xf) | 0x00;
4746      else
48      state->m_wheel_return[index] = ((-wheel) & 0xf) | 0x10;
47      m_wheel_return[index] = ((-wheel) & 0xf) | 0x10;
4948
50   state->m_wheel_old[index] = wheel;
49   m_wheel_old[index] = wheel;
5150   }
52   return state->m_wheel_return[index] | machine.root_device().ioport(portnames[index])->read();
51   return m_wheel_return[index] | machine().root_device().ioport(portnames[index])->read();
5352}
5453
5554READ8_MEMBER(amspdwy_state::amspdwy_wheel_0_r)
5655{
57   return amspdwy_wheel_r(machine(), 0);
56   return amspdwy_wheel_r(0);
5857}
5958
6059READ8_MEMBER(amspdwy_state::amspdwy_wheel_1_r)
6160{
62   return amspdwy_wheel_r(machine(), 1);
61   return amspdwy_wheel_r(1);
6362}
6463
6564READ8_MEMBER(amspdwy_state::amspdwy_sound_r)
trunk/src/mame/drivers/astrof.c
r20741r20742
173173}
174174
175175
176static rgb_t make_pen( running_machine &machine, UINT8 data )
176rgb_t astrof_state::make_pen( UINT8 data )
177177{
178   astrof_state *state = machine.driver_data<astrof_state>();
179
180   UINT8 r1_bit = state->m_red_on ? 0x01 : (data >> 0) & 0x01;
181   UINT8 r2_bit = state->m_red_on ? 0x01 : (data >> 1) & 0x01;
178   UINT8 r1_bit = m_red_on ? 0x01 : (data >> 0) & 0x01;
179   UINT8 r2_bit = m_red_on ? 0x01 : (data >> 1) & 0x01;
182180   UINT8 g1_bit = (data >> 2) & 0x01;
183181   UINT8 g2_bit = (data >> 3) & 0x01;
184182   UINT8 b1_bit = (data >> 4) & 0x01;
r20741r20742
194192}
195193
196194
197static void astrof_get_pens( running_machine &machine, pen_t *pens )
195void astrof_state::astrof_get_pens( pen_t *pens )
198196{
199   astrof_state *state = machine.driver_data<astrof_state>();
200197   offs_t i;
201   UINT8 bank = (state->m_astrof_palette_bank ? 0x10 : 0x00);
202   UINT8 config = state->ioport("FAKE")->read_safe(0x00);
203   UINT8 *prom = state->memregion("proms")->base();
198   UINT8 bank = (m_astrof_palette_bank ? 0x10 : 0x00);
199   UINT8 config = ioport("FAKE")->read_safe(0x00);
200   UINT8 *prom = memregion("proms")->base();
204201
205202   /* a common wire hack to the pcb causes the prom halves to be inverted */
206203   /* this results in e.g. astrof background being black */
r20741r20742
226223   for (i = 0; i < ASTROF_NUM_PENS; i++)
227224   {
228225      UINT8 data = prom[bank | i];
229      pens[i] = make_pen(machine, data);
226      pens[i] = make_pen(data);
230227   }
231228}
232229
233230
234static void tomahawk_get_pens( running_machine &machine, pen_t *pens )
231void astrof_state::tomahawk_get_pens( pen_t *pens )
235232{
236233   offs_t i;
237   UINT8 *prom = machine.root_device().memregion("proms")->base();
238   UINT8 config = machine.root_device().ioport("FAKE")->read_safe(0x00);
234   UINT8 *prom = machine().root_device().memregion("proms")->base();
235   UINT8 config = machine().root_device().ioport("FAKE")->read_safe(0x00);
239236
240237   for (i = 0; i < TOMAHAWK_NUM_PENS; i++)
241238   {
r20741r20742
266263
267264      data = prom[pen];
268265
269      pens[i] = make_pen(machine, data);
266      pens[i] = make_pen(data);
270267   }
271268}
272269
r20741r20742
299296}
300297
301298
302static void astrof_set_video_control_2( running_machine &machine, UINT8 data )
299void astrof_state::astrof_set_video_control_2( UINT8 data )
303300{
304   astrof_state *state = machine.driver_data<astrof_state>();
305
306301   /* D0 - OUT0 - goes to edge conn. pin A10 - was perhaps meant to be a start lamp */
307302   /* D1 - OUT1 - goes to edge conn. pin A11 - was perhaps meant to be a start lamp */
308303
309304   /* D2 - selects one of the two palette banks */
310   state->m_astrof_palette_bank = (data & 0x04) ? TRUE : FALSE;
305   m_astrof_palette_bank = (data & 0x04) ? TRUE : FALSE;
311306
312307   /* D3 - turns on the red color gun regardless of the value in the color PROM */
313   state->m_red_on = (data & 0x08) ? TRUE : FALSE;
308   m_red_on = (data & 0x08) ? TRUE : FALSE;
314309
315310   /* D4-D7 - not connected */
316311}
317312
318313WRITE8_MEMBER(astrof_state::astrof_video_control_2_w)
319314{
320   astrof_set_video_control_2(machine(), data);
315   astrof_set_video_control_2(data);
321316   machine().primary_screen->update_partial(machine().primary_screen->vpos());
322317}
323318
324319
325static void spfghmk2_set_video_control_2( running_machine &machine, UINT8 data )
320void astrof_state::spfghmk2_set_video_control_2( UINT8 data )
326321{
327   astrof_state *state = machine.driver_data<astrof_state>();
328
329322   /* D0 - OUT0 - goes to edge conn. pin A10 - was perhaps meant to be a start lamp */
330323   /* D1 - OUT1 - goes to edge conn. pin A11 - was perhaps meant to be a start lamp */
331324
332325   /* D2 - selects one of the two palette banks */
333   state->m_astrof_palette_bank = (data & 0x04) ? TRUE : FALSE;
326   m_astrof_palette_bank = (data & 0x04) ? TRUE : FALSE;
334327
335328   /* D3-D7 - not connected */
336329}
337330
338331WRITE8_MEMBER(astrof_state::spfghmk2_video_control_2_w)
339332{
340   spfghmk2_set_video_control_2(machine(), data);
333   spfghmk2_set_video_control_2(data);
341334   machine().primary_screen->update_partial(machine().primary_screen->vpos());
342335}
343336
344337
345static void tomahawk_set_video_control_2( running_machine &machine, UINT8 data )
338void astrof_state::tomahawk_set_video_control_2( UINT8 data )
346339{
347   astrof_state *state = machine.driver_data<astrof_state>();
348
349340   /* D0 - OUT0 - goes to edge conn. pin A10 - was perhaps meant to be a start lamp */
350341   /* D1 - OUT1 - goes to edge conn. pin A11 - was perhaps meant to be a start lamp */
351342   /* D2 - not connected */
352343
353344   /* D3 - turns on the red color gun regardless of the value in the color PROM */
354   state->m_red_on = (data & 0x08) ? TRUE : FALSE;
345   m_red_on = (data & 0x08) ? TRUE : FALSE;
355346}
356347
357348WRITE8_MEMBER(astrof_state::tomahawk_video_control_2_w)
358349{
359   tomahawk_set_video_control_2(machine(), data);
350   tomahawk_set_video_control_2(data);
360351   machine().primary_screen->update_partial(machine().primary_screen->vpos());
361352}
362353
363354
364static void video_update_common( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, pen_t *pens )
355void astrof_state::video_update_common( bitmap_rgb32 &bitmap, const rectangle &cliprect, pen_t *pens )
365356{
366   astrof_state *state = machine.driver_data<astrof_state>();
367357   offs_t offs;
368358
369   for (offs = 0; offs < state->m_videoram.bytes(); offs++)
359   for (offs = 0; offs < m_videoram.bytes(); offs++)
370360   {
371361      UINT8 data;
372362      int i;
373363
374      UINT8 color = state->m_colorram[offs >> 1];
364      UINT8 color = m_colorram[offs >> 1];
375365
376366      pen_t back_pen = pens[color | 0x00];
377367      pen_t fore_pen = pens[color | 0x01];
r20741r20742
379369      UINT8 y = offs;
380370      UINT8 x = offs >> 8 << 3;
381371
382      if (!state->m_flipscreen)
372      if (!m_flipscreen)
383373         y = ~y;
384374
385375      if ((y <= cliprect.min_y) || (y >= cliprect.max_y))
386376         continue;
387377
388      if (state->m_screen_off)
378      if (m_screen_off)
389379         data = 0;
390380      else
391         data = state->m_videoram[offs];
381         data = m_videoram[offs];
392382
393383      for (i = 0; i < 8; i++)
394384      {
395385         pen_t pen = (data & 0x01) ? fore_pen : back_pen;
396386
397         if (state->m_flipscreen)
387         if (m_flipscreen)
398388            bitmap.pix32(y, 255 - x) = pen;
399389         else
400390            bitmap.pix32(y, x) = pen;
r20741r20742
410400{
411401   pen_t pens[ASTROF_NUM_PENS];
412402
413   astrof_get_pens(machine(), pens);
403   astrof_get_pens(pens);
414404
415   video_update_common(machine(), bitmap, cliprect, pens);
405   video_update_common(bitmap, cliprect, pens);
416406
417407   return 0;
418408}
r20741r20742
422412{
423413   pen_t pens[TOMAHAWK_NUM_PENS];
424414
425   tomahawk_get_pens(machine(), pens);
415   tomahawk_get_pens(pens);
426416
427   video_update_common(machine(), bitmap, cliprect, pens);
417   video_update_common(bitmap, cliprect, pens);
428418
429419   return 0;
430420}
r20741r20742
475465MACHINE_START_MEMBER(astrof_state,astrof)
476466{
477467   /* the 74175 outputs all HI's if not otherwise set */
478   astrof_set_video_control_2(machine(), 0xff);
468   astrof_set_video_control_2(0xff);
479469
480470   m_maincpu = machine().device<cpu_device>("maincpu");
481471   m_samples = machine().device<samples_device>("samples");
r20741r20742
505495MACHINE_START_MEMBER(astrof_state,spfghmk2)
506496{
507497   /* the 74175 outputs all HI's if not otherwise set */
508   spfghmk2_set_video_control_2(machine(), 0xff);
498   spfghmk2_set_video_control_2(0xff);
509499
510500   m_maincpu = machine().device<cpu_device>("maincpu");
511501
r20741r20742
522512MACHINE_START_MEMBER(astrof_state,tomahawk)
523513{
524514   /* the 74175 outputs all HI's if not otherwise set */
525   tomahawk_set_video_control_2(machine(), 0xff);
515   tomahawk_set_video_control_2(0xff);
526516
527517   m_maincpu = machine().device<cpu_device>("maincpu");
528518   m_sn = machine().device("snsnd");
trunk/src/mame/drivers/aquarium.c
r20741r20742
7070   membank("bank1")->set_entry(data & 0x07);
7171}
7272
73static UINT8 aquarium_snd_bitswap( UINT8 scrambled_data )
73UINT8 aquarium_state::aquarium_snd_bitswap( UINT8 scrambled_data )
7474{
7575   UINT8 data = 0;
7676
trunk/src/mame/drivers/bwing.c
r20741r20742
555555//****************************************************************************
556556// Initializations
557557
558static void fix_bwp3( running_machine &machine )
558void bwing_state::fix_bwp3(  )
559559{
560   bwing_state *state = machine.driver_data<bwing_state>();
561   UINT8 *rom = state->m_bwp3_rombase;
562   int i, j = state->m_bwp3_rombase.bytes();
560   UINT8 *rom = m_bwp3_rombase;
561   int i, j = m_bwp3_rombase.bytes();
563562
564563   // swap nibbles
565564   for (i = 0; i < j; i++)
r20741r20742
577576   m_bwp123_membase[1] = memregion("sub")->base();
578577   m_bwp123_membase[2] = memregion("audiocpu")->base();
579578
580   fix_bwp3(machine());
579   fix_bwp3();
581580}
582581
583582//****************************************************************************

Previous 199869 Revisions Next


© 1997-2024 The MAME Team