Previous 199869 Revisions Next

r20978 Tuesday 12th February, 2013 at 13:26:06 UTC by Miodrag Milanović
Modernization of drivers part 18 (no whatsnew)
[src/mame/drivers]jclub2.c segag80r.c segag80v.c segas32.c seibuspi.c seta.c seta2.c sf.c simpsons.c skullxbo.c slapfght.c snk.c snk6502.c snowbros.c spacefb.c spdodgeb.c speedatk.c splash.c sprint2.c sprint8.c spy.c srmp2.c sshangha.c ssv.c stactics.c starwars.c suna8.c superqix.c suprnova.c suprridr.c system1.c system16.c
[src/mame/includes]sauro.h sbasketb.h scotrsht.h scramble.h sderby.h segag80r.h segag80v.h segas32.h seibuspi.h seicross.h senjyo.h seta.h seta2.h sf.h shadfrce.h shangkid.h shaolins.h shootout.h sidearms.h sidepckt.h silkroad.h simpsons.h skullxbo.h skydiver.h skyfox.h skykid.h skyraid.h slapfght.h slapshot.h snk.h snk6502.h snk68.h snowbros.h solomon.h sonson.h spacefb.h spdodgeb.h speedatk.h speedbal.h speedspn.h splash.h sprcros2.h sprint2.h sprint8.h spy.h srmp2.h srumbler.h sshangha.h sslam.h ssozumo.h sspeedr.h ssrj.h ssv.h st0016.h stactics.h starcrus.h starfire.h starshp1.h starwars.h stfight.h stlforce.h strnskil.h subs.h suna16.h suna8.h superchs.h superqix.h suprloco.h suprnova.h suprridr.h system1.h system16.h
[src/mame/machine]scramble.c segas32.c simpsons.c starwars.c subs.c
[src/mame/video]sauro.c sbasketb.c scotrsht.c sderby.c segag80r.c segag80v.c segas32.c seibuspi.c seicross.c senjyo.c seta.c seta2.c sf.c shadfrce.c shangkid.c shaolins.c shootout.c sidearms.c sidepckt.c silkroad.c simpsons.c skullxbo.c skydiver.c skyfox.c skykid.c skyraid.c slapfght.c slapshot.c snk.c snk68.c solomon.c sonson.c spacefb.c spdodgeb.c speedbal.c speedspn.c splash.c sprcros2.c sprint2.c sprint8.c srumbler.c sslam.c ssozumo.c sspeedr.c ssrj.c ssv.c st0016.c stactics.c starcrus.c starfire.c starshp1.c stfight.c stlforce.c strnskil.c suna16.c suna8.c superchs.c superqix.c suprloco.c suprnova.c suprridr.c system1.c system16.c

trunk/src/mame/drivers/sprint2.c
r20977r20978
2222#include "includes/sprint2.h"
2323#include "sound/discrete.h"
2424
25#define GAME_IS_SPRINT1   (state->m_game == 1)
26#define GAME_IS_SPRINT2   (state->m_game == 2)
27#define GAME_IS_DOMINOS   (state->m_game == 3)
25#define GAME_IS_SPRINT1   (m_game == 1)
26#define GAME_IS_SPRINT2   (m_game == 2)
27#define GAME_IS_DOMINOS   (m_game == 3)
2828
29
30
31
32
3329DRIVER_INIT_MEMBER(sprint2_state,sprint1)
3430{
3531   m_game = 1;
r20977r20978
4339   m_game = 3;
4440}
4541
46
47static int service_mode(running_machine &machine)
42int sprint2_state::service_mode()
4843{
49   sprint2_state *state = machine.driver_data<sprint2_state>();
50   UINT8 v = state->ioport("INB")->read();
44   UINT8 v = ioport("INB")->read();
5145
5246   if (GAME_IS_SPRINT1)
5347   {
r20977r20978
6862
6963INTERRUPT_GEN_MEMBER(sprint2_state::sprint2)
7064{
71   sprint2_state *state = machine().driver_data<sprint2_state>();
7265   device_t *discrete = machine().device("discrete");
7366
7467   /* handle steering wheels */
r20977r20978
109102
110103   /* interrupts and watchdog are disabled during service mode */
111104
112   machine().watchdog_enable(!service_mode(machine()));
105   machine().watchdog_enable(!service_mode());
113106
114   if (!service_mode(machine()))
107   if (!service_mode())
115108      device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
116109}
117110
trunk/src/mame/drivers/system1.c
r20977r20978
394394 *
395395 *************************************/
396396
397static void bank44_custom_w(running_machine &machine, UINT8 data, UINT8 prevdata)
397void system1_state::bank44_custom_w(UINT8 data, UINT8 prevdata)
398398{
399399   /* bank bits are bits 6 and 2 */
400   machine.root_device().membank("bank1")->set_entry(((data & 0x40) >> 5) | ((data & 0x04) >> 2));
400   machine().root_device().membank("bank1")->set_entry(((data & 0x40) >> 5) | ((data & 0x04) >> 2));
401401}
402402
403403
404static void bank0c_custom_w(running_machine &machine, UINT8 data, UINT8 prevdata)
404void system1_state::bank0c_custom_w(UINT8 data, UINT8 prevdata)
405405{
406406   /* bank bits are bits 3 and 2 */
407   machine.root_device().membank("bank1")->set_entry((data & 0x0c) >> 2);
407   machine().root_device().membank("bank1")->set_entry((data & 0x0c) >> 2);
408408}
409409
410410
r20977r20978
418418
419419   /* handle any custom banking or other stuff */
420420   if (m_videomode_custom != NULL)
421      (*m_videomode_custom)(machine(), data, m_videomode_prev);
421      (this->*m_videomode_custom)(data, m_videomode_prev);
422422   m_videomode_prev = data;
423423
424424   /* bit 0 is for the coin counters */
r20977r20978
450450}
451451
452452
453static void dakkochn_custom_w(running_machine &machine, UINT8 data, UINT8 prevdata)
453void system1_state::dakkochn_custom_w(UINT8 data, UINT8 prevdata)
454454{
455   system1_state *state = machine.driver_data<system1_state>();
456455   /* bit 1 toggling on clocks the mux; we store the previous state in the high bit of dakkochn_mux_data */
457456   if ((data & 0x02) && !(prevdata & 0x02))
458      state->m_dakkochn_mux_data = (state->m_dakkochn_mux_data + 1) % 7;
457      m_dakkochn_mux_data = (m_dakkochn_mux_data + 1) % 7;
459458
460459   /* remaining stuff acts like bank0c */
461   bank0c_custom_w(machine, data, prevdata);
460   bank0c_custom_w(data, prevdata);
462461}
463462
464463
r20977r20978
46774676}
46784677DRIVER_INIT_MEMBER(system1_state,bank44)
46794678{
4680   m_videomode_custom = bank44_custom_w;
4679   m_videomode_custom = &system1_state::bank44_custom_w;
46814680}
46824681
46834682DRIVER_INIT_MEMBER(system1_state,bank0c)
46844683{
4685   m_videomode_custom = bank0c_custom_w;
4684   m_videomode_custom = &system1_state::bank0c_custom_w;
46864685}
46874686
46884687DRIVER_INIT_MEMBER(system1_state,regulus)   { DRIVER_INIT_CALL(bank00); regulus_decode(machine(), "maincpu"); }
r20977r20978
47154714
47164715DRIVER_INIT_MEMBER(system1_state,dakkochn)
47174716{
4718   m_videomode_custom = dakkochn_custom_w;
4717   m_videomode_custom = &system1_state::dakkochn_custom_w;
47194718
47204719   mc8123_decrypt_rom(machine(), "maincpu", "key", "bank1", 4);
47214720
trunk/src/mame/drivers/srmp2.c
r20977r20978
247247}
248248
249249
250static UINT8 iox_key_matrix_calc(running_machine &machine,UINT8 p_side)
250UINT8 srmp2_state::iox_key_matrix_calc(UINT8 p_side)
251251{
252252   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7" };
253253   int i, j, t;
r20977r20978
258258
259259      for (t = 0 ; t < 8 ; t ++)
260260      {
261         if (!(machine.root_device().ioport(keynames[j+p_side])->read() & ( 1 << t )))
261         if (!(machine().root_device().ioport(keynames[j+p_side])->read() & ( 1 << t )))
262262         {
263263            return (i + t) | (p_side ? 0x20 : 0x00);
264264         }
r20977r20978
297297      /* both side checks */
298298      if(iox.mux == 1)
299299      {
300         UINT8 p1_side = iox_key_matrix_calc(machine(),0);
301         UINT8 p2_side = iox_key_matrix_calc(machine(),4);
300         UINT8 p1_side = iox_key_matrix_calc(0);
301         UINT8 p2_side = iox_key_matrix_calc(4);
302302
303303         if(p1_side != 0)
304304            return p1_side;
r20977r20978
307307      }
308308
309309      /* check individual input side */
310      return iox_key_matrix_calc(machine(),(iox.mux == 2) ? 0 : 4);
310      return iox_key_matrix_calc((iox.mux == 2) ? 0 : 4);
311311   }
312312
313313   return ioport("SERVICE")->read() & 0xff;
trunk/src/mame/drivers/sf.c
r20977r20978
5252/* The protection of the Japanese (and alt US) version */
5353/* I'd love to see someone dump the 68705 / i8751 roms */
5454
55static void write_dword( address_space &space, offs_t offset, UINT32 data )
55void sf_state::write_dword( address_space &space, offs_t offset, UINT32 data )
5656{
5757   space.write_word(offset, data >> 16);
5858   space.write_word(offset + 2, data);
trunk/src/mame/drivers/snk.c
r20977r20978
576576   // low 6 bits might indicate radius, but it's not clear
577577}
578578
579static int hardflags_check(running_machine &machine, int num)
579int snk_state::hardflags_check(int num)
580580{
581   snk_state *state = machine.driver_data<snk_state>();
582   const UINT8 *sr = &state->m_spriteram[0x800 + 4*num];
581   const UINT8 *sr = &m_spriteram[0x800 + 4*num];
583582   int x = sr[2] + ((sr[3] & 0x80) << 1);
584583   int y = sr[0] + ((sr[3] & 0x10) << 4);
585584
586   int dx = (x - state->m_hf_posx) & 0x1ff;
587   int dy = (y - state->m_hf_posy) & 0x1ff;
585   int dx = (x - m_hf_posx) & 0x1ff;
586   int dy = (y - m_hf_posy) & 0x1ff;
588587
589588   if (dx > 0x20 && dx <= 0x1e0 && dy > 0x20 && dy <= 0x1e0)
590589      return 0;
r20977r20978
592591      return 1;
593592}
594593
595static int hardflags_check8(running_machine &machine, int num)
594int snk_state::hardflags_check8(int num)
596595{
597596   return
598      (hardflags_check(machine, num + 0) << 0) |
599      (hardflags_check(machine, num + 1) << 1) |
600      (hardflags_check(machine, num + 2) << 2) |
601      (hardflags_check(machine, num + 3) << 3) |
602      (hardflags_check(machine, num + 4) << 4) |
603      (hardflags_check(machine, num + 5) << 5) |
604      (hardflags_check(machine, num + 6) << 6) |
605      (hardflags_check(machine, num + 7) << 7);
597      (hardflags_check(num + 0) << 0) |
598      (hardflags_check(num + 1) << 1) |
599      (hardflags_check(num + 2) << 2) |
600      (hardflags_check(num + 3) << 3) |
601      (hardflags_check(num + 4) << 4) |
602      (hardflags_check(num + 5) << 5) |
603      (hardflags_check(num + 6) << 6) |
604      (hardflags_check(num + 7) << 7);
606605}
607606
608READ8_MEMBER(snk_state::hardflags1_r){ return hardflags_check8(machine(), 0*8); }
609READ8_MEMBER(snk_state::hardflags2_r){ return hardflags_check8(machine(), 1*8); }
610READ8_MEMBER(snk_state::hardflags3_r){ return hardflags_check8(machine(), 2*8); }
611READ8_MEMBER(snk_state::hardflags4_r){ return hardflags_check8(machine(), 3*8); }
612READ8_MEMBER(snk_state::hardflags5_r){ return hardflags_check8(machine(), 4*8); }
613READ8_MEMBER(snk_state::hardflags6_r){ return hardflags_check8(machine(), 5*8); }
607READ8_MEMBER(snk_state::hardflags1_r){ return hardflags_check8(0*8); }
608READ8_MEMBER(snk_state::hardflags2_r){ return hardflags_check8(1*8); }
609READ8_MEMBER(snk_state::hardflags3_r){ return hardflags_check8(2*8); }
610READ8_MEMBER(snk_state::hardflags4_r){ return hardflags_check8(3*8); }
611READ8_MEMBER(snk_state::hardflags5_r){ return hardflags_check8(4*8); }
612READ8_MEMBER(snk_state::hardflags6_r){ return hardflags_check8(5*8); }
614613READ8_MEMBER(snk_state::hardflags7_r)
615614{
616615   // apparently the startup tests use bits 0&1 while the game uses bits 4&5
617616   return
618      (hardflags_check(machine(), 6*8 + 0) << 0) |
619      (hardflags_check(machine(), 6*8 + 1) << 1) |
620      (hardflags_check(machine(), 6*8 + 0) << 4) |
621      (hardflags_check(machine(), 6*8 + 1) << 5);
617      (hardflags_check(6*8 + 0) << 0) |
618      (hardflags_check(6*8 + 1) << 1) |
619      (hardflags_check(6*8 + 0) << 4) |
620      (hardflags_check(6*8 + 1) << 5);
622621}
623622
624623
r20977r20978
669668   // low 6 bits might indicate radius, but it's not clear
670669}
671670
672static int turbofront_check(running_machine &machine, int small, int num)
671int snk_state::turbofront_check(int small, int num)
673672{
674   snk_state *state = machine.driver_data<snk_state>();
675   const UINT8 *sr = &state->m_spriteram[0x800*small + 4*num];
673   const UINT8 *sr = &m_spriteram[0x800*small + 4*num];
676674   int x = sr[2] + ((sr[3] & 0x80) << 1);
677675   int y = sr[0] + ((sr[3] & 0x10) << 4);
678676
679   int dx = (x - (small ? state->m_tc16_posx : state->m_tc32_posx)) & 0x1ff;
680   int dy = (y - (small ? state->m_tc16_posy : state->m_tc32_posy)) & 0x1ff;
677   int dx = (x - (small ? m_tc16_posx : m_tc32_posx)) & 0x1ff;
678   int dy = (y - (small ? m_tc16_posy : m_tc32_posy)) & 0x1ff;
681679
682680   if (dx > 0x20 && dx <= 0x1e0 && dy > 0x20 && dy <= 0x1e0)
683681      return 0;
r20977r20978
685683      return 1;
686684}
687685
688static int turbofront_check8(running_machine &machine, int small, int num)
686int snk_state::turbofront_check8(int small, int num)
689687{
690688   return
691      (turbofront_check(machine, small, num + 0) << 0) |
692      (turbofront_check(machine, small, num + 1) << 1) |
693      (turbofront_check(machine, small, num + 2) << 2) |
694      (turbofront_check(machine, small, num + 3) << 3) |
695      (turbofront_check(machine, small, num + 4) << 4) |
696      (turbofront_check(machine, small, num + 5) << 5) |
697      (turbofront_check(machine, small, num + 6) << 6) |
698      (turbofront_check(machine, small, num + 7) << 7);
689      (turbofront_check(small, num + 0) << 0) |
690      (turbofront_check(small, num + 1) << 1) |
691      (turbofront_check(small, num + 2) << 2) |
692      (turbofront_check(small, num + 3) << 3) |
693      (turbofront_check(small, num + 4) << 4) |
694      (turbofront_check(small, num + 5) << 5) |
695      (turbofront_check(small, num + 6) << 6) |
696      (turbofront_check(small, num + 7) << 7);
699697}
700698
701READ8_MEMBER(snk_state::turbocheck16_1_r){ return turbofront_check8(machine(), 1, 0*8); }
702READ8_MEMBER(snk_state::turbocheck16_2_r){ return turbofront_check8(machine(), 1, 1*8); }
703READ8_MEMBER(snk_state::turbocheck16_3_r){ return turbofront_check8(machine(), 1, 2*8); }
704READ8_MEMBER(snk_state::turbocheck16_4_r){ return turbofront_check8(machine(), 1, 3*8); }
705READ8_MEMBER(snk_state::turbocheck16_5_r){ return turbofront_check8(machine(), 1, 4*8); }
706READ8_MEMBER(snk_state::turbocheck16_6_r){ return turbofront_check8(machine(), 1, 5*8); }
707READ8_MEMBER(snk_state::turbocheck16_7_r){ return turbofront_check8(machine(), 1, 6*8); }
708READ8_MEMBER(snk_state::turbocheck16_8_r){ return turbofront_check8(machine(), 1, 7*8); }
709READ8_MEMBER(snk_state::turbocheck32_1_r){ return turbofront_check8(machine(), 0, 0*8); }
710READ8_MEMBER(snk_state::turbocheck32_2_r){ return turbofront_check8(machine(), 0, 1*8); }
711READ8_MEMBER(snk_state::turbocheck32_3_r){ return turbofront_check8(machine(), 0, 2*8); }
712READ8_MEMBER(snk_state::turbocheck32_4_r){ return turbofront_check8(machine(), 0, 3*8); }
699READ8_MEMBER(snk_state::turbocheck16_1_r){ return turbofront_check8(1, 0*8); }
700READ8_MEMBER(snk_state::turbocheck16_2_r){ return turbofront_check8(1, 1*8); }
701READ8_MEMBER(snk_state::turbocheck16_3_r){ return turbofront_check8(1, 2*8); }
702READ8_MEMBER(snk_state::turbocheck16_4_r){ return turbofront_check8(1, 3*8); }
703READ8_MEMBER(snk_state::turbocheck16_5_r){ return turbofront_check8(1, 4*8); }
704READ8_MEMBER(snk_state::turbocheck16_6_r){ return turbofront_check8(1, 5*8); }
705READ8_MEMBER(snk_state::turbocheck16_7_r){ return turbofront_check8(1, 6*8); }
706READ8_MEMBER(snk_state::turbocheck16_8_r){ return turbofront_check8(1, 7*8); }
707READ8_MEMBER(snk_state::turbocheck32_1_r){ return turbofront_check8(0, 0*8); }
708READ8_MEMBER(snk_state::turbocheck32_2_r){ return turbofront_check8(0, 1*8); }
709READ8_MEMBER(snk_state::turbocheck32_3_r){ return turbofront_check8(0, 2*8); }
710READ8_MEMBER(snk_state::turbocheck32_4_r){ return turbofront_check8(0, 3*8); }
713711
714712
715713
trunk/src/mame/drivers/sprint8.c
r20977r20978
1111
1212
1313
14void sprint8_set_collision(running_machine &machine, int n)
14void sprint8_state::sprint8_set_collision(int n)
1515{
16   sprint8_state *state = machine.driver_data<sprint8_state>();
17   if (state->m_collision_reset == 0)
16   if (m_collision_reset == 0)
1817   {
19      machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
18      machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
2019
21      state->m_collision_index = n;
20      m_collision_index = n;
2221   }
2322}
2423
trunk/src/mame/drivers/superqix.c
r20977r20978
342342 * connected to the 68705 which acts as a counter.
343343 */
344344
345static int read_dial(running_machine &machine, int player)
345int superqix_state::read_dial(int player)
346346{
347   superqix_state *state = machine.driver_data<superqix_state>();
348347   int newpos;
349348
350349   /* get the new position and adjust the result */
351   newpos = state->ioport(player ? "DIAL2" : "DIAL1")->read();
352   if (newpos != state->m_oldpos[player])
350   newpos = ioport(player ? "DIAL2" : "DIAL1")->read();
351   if (newpos != m_oldpos[player])
353352   {
354      state->m_sign[player] = ((newpos - state->m_oldpos[player]) & 0x80) >> 7;
355      state->m_oldpos[player] = newpos;
353      m_sign[player] = ((newpos - m_oldpos[player]) & 0x80) >> 7;
354      m_oldpos[player] = newpos;
356355   }
357356
358357   if (player == 0)
359      return ((state->m_oldpos[player] & 1) << 2) | (state->m_sign[player] << 3);
358      return ((m_oldpos[player] & 1) << 2) | (m_sign[player] << 3);
360359   else    // player == 1
361      return ((state->m_oldpos[player] & 1) << 3) | (state->m_sign[player] << 2);
360      return ((m_oldpos[player] & 1) << 3) | (m_sign[player] << 2);
362361}
363362
364363
r20977r20978
446445            break;
447446
448447         case 0x6:
449            m_portA_in = read_dial(machine(), 0);
448            m_portA_in = read_dial(0);
450449            break;
451450
452451         case 0x7:
453            m_portA_in = read_dial(machine(), 1);
452            m_portA_in = read_dial(1);
454453            break;
455454      }
456455   }
r20977r20978
517516}
518517
519518
520static void machine_init_common(running_machine &machine)
519void superqix_state::machine_init_common()
521520{
522   superqix_state *state = machine.driver_data<superqix_state>();
523   state->save_item(NAME(state->m_invert_coin_lockout));
524   state->save_item(NAME(state->m_from_mcu_pending));
525   state->save_item(NAME(state->m_from_z80_pending));
526   state->save_item(NAME(state->m_port1));
527   state->save_item(NAME(state->m_port2));
528   state->save_item(NAME(state->m_port3));
529   state->save_item(NAME(state->m_port3_latch));
530   state->save_item(NAME(state->m_from_mcu));
531   state->save_item(NAME(state->m_from_z80));
532   state->save_item(NAME(state->m_portb));
521   save_item(NAME(m_invert_coin_lockout));
522   save_item(NAME(m_from_mcu_pending));
523   save_item(NAME(m_from_z80_pending));
524   save_item(NAME(m_port1));
525   save_item(NAME(m_port2));
526   save_item(NAME(m_port3));
527   save_item(NAME(m_port3_latch));
528   save_item(NAME(m_from_mcu));
529   save_item(NAME(m_from_z80));
530   save_item(NAME(m_portb));
533531
534532   // hotsmash ???
535   state->save_item(NAME(state->m_portA_in));
536   state->save_item(NAME(state->m_portB_out));
537   state->save_item(NAME(state->m_portC));
533   save_item(NAME(m_portA_in));
534   save_item(NAME(m_portB_out));
535   save_item(NAME(m_portC));
538536}
539537
540538MACHINE_START_MEMBER(superqix_state,superqix)
r20977r20978
542540   /* configure the banks */
543541   machine().root_device().membank("bank1")->configure_entries(0, 4, machine().root_device().memregion("maincpu")->base() + 0x10000, 0x4000);
544542
545   machine_init_common(machine());
543   machine_init_common();
546544}
547545
548546MACHINE_START_MEMBER(superqix_state,pbillian)
r20977r20978
550548   /* configure the banks */
551549   machine().root_device().membank("bank1")->configure_entries(0, 2, machine().root_device().memregion("maincpu")->base() + 0x10000, 0x4000);
552550
553   machine_init_common(machine());
551   machine_init_common();
554552}
555553
556554
trunk/src/mame/drivers/slapfght.c
r20977r20978
18011801   return 0;
18021802}
18031803
1804static void getstar_init( running_machine &machine )
1804void slapfght_state::getstar_init(  )
18051805{
1806   slapfght_state *state = machine.driver_data<slapfght_state>();
1807   machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xe803, 0xe803, read8_delegate(FUNC(slapfght_state::getstar_e803_r),state), write8_delegate(FUNC(slapfght_state::getstar_e803_w),state));
1808   machine.device("maincpu")->memory().space(AS_IO).install_read_handler(0x00, 0x00, read8_delegate(FUNC(slapfght_state::slapfight_port_00_r),state));
1806   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xe803, 0xe803, read8_delegate(FUNC(slapfght_state::getstar_e803_r),this), write8_delegate(FUNC(slapfght_state::getstar_e803_w),this));
1807   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x00, 0x00, read8_delegate(FUNC(slapfght_state::slapfight_port_00_r),this));
18091808}
18101809
18111810DRIVER_INIT_MEMBER(slapfght_state,getstar)
18121811{
18131812   m_getstar_id = GETSTAR;
1814   getstar_init(machine());
1813   getstar_init();
18151814}
18161815
18171816DRIVER_INIT_MEMBER(slapfght_state,getstarj)
18181817{
18191818   m_getstar_id = GETSTARJ;
1820   getstar_init(machine());
1819   getstar_init();
18211820}
18221821
18231822DRIVER_INIT_MEMBER(slapfght_state,gtstarb1)
r20977r20978
18251824   UINT8 *ROM = memregion("maincpu")->base();
18261825
18271826   m_getstar_id = GTSTARB1;
1828   getstar_init(machine());
1827   getstar_init();
18291828
18301829   /* specific handlers for this bootleg */
18311830   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x0, 0x0, read8_delegate(FUNC(slapfght_state::gtstarb1_port_0_read),this));
r20977r20978
18391838DRIVER_INIT_MEMBER(slapfght_state,gtstarb2)
18401839{
18411840   m_getstar_id = GTSTARB2;
1842   getstar_init(machine());
1841   getstar_init();
18431842}
18441843
18451844DRIVER_INIT_MEMBER(slapfght_state,slapfigh)
trunk/src/mame/drivers/seta2.c
r20977r20978
700700   return ret;
701701}
702702
703static void funcube_debug_outputs(running_machine &machine)
703void seta2_state::funcube_debug_outputs()
704704{
705705#ifdef MAME_DEBUG
706//  seta2_state *state = machine.driver_data<seta2_state>();
707//  popmessage("LED: %02x OUT: %02x", (int)*state->m_funcube_leds, (int)*state->m_funcube_outputs);
706//  popmessage("LED: %02x OUT: %02x", (int)*m_funcube_leds, (int)*m_funcube_outputs);
708707#endif
709708}
710709
r20977r20978
721720   set_led_status( machine(), 4, (~data) & 0x40 );
722721   set_led_status( machine(), 5, (~data) & 0x80 );
723722
724   funcube_debug_outputs(space.machine());
723   funcube_debug_outputs();
725724}
726725
727726READ8_MEMBER(seta2_state::funcube_outputs_r)
r20977r20978
744743   // Bit 3: low after coining up, blinks on pay out
745744   set_led_status( machine(), 6, (~data) & 0x08 );
746745
747   funcube_debug_outputs(space.machine());
746   funcube_debug_outputs();
748747}
749748
750749READ8_MEMBER(seta2_state::funcube_battery_r)
trunk/src/mame/drivers/starwars.c
r20977r20978
7070   }
7171
7272   /* reset the matrix processor */
73   starwars_mproc_reset(machine());
73   starwars_mproc_reset();
7474}
7575
7676
r20977r20978
9494 *
9595 *************************************/
9696
97static void esb_slapstic_tweak(address_space &space, offs_t offset)
97void starwars_state::esb_slapstic_tweak(address_space &space, offs_t offset)
9898{
99   starwars_state *state = space.machine().driver_data<starwars_state>();
10099   int new_bank = slapstic_tweak(space, offset);
101100
102101   /* update for the new bank */
103   if (new_bank != state->m_slapstic_current_bank)
102   if (new_bank != m_slapstic_current_bank)
104103   {
105      state->m_slapstic_current_bank = new_bank;
106      memcpy(state->m_slapstic_base, &state->m_slapstic_source[state->m_slapstic_current_bank * 0x2000], 0x2000);
104      m_slapstic_current_bank = new_bank;
105      memcpy(m_slapstic_base, &m_slapstic_source[m_slapstic_current_bank * 0x2000], 0x2000);
107106   }
108107}
109108
r20977r20978
506505{
507506   /* prepare the mathbox */
508507   m_is_esb = 0;
509   starwars_mproc_init(machine());
508   starwars_mproc_init();
510509
511510   /* initialize banking */
512511   membank("bank1")->configure_entries(0, 2, memregion("maincpu")->base() + 0x6000, 0x10000 - 0x6000);
r20977r20978
535534
536535   /* prepare the matrix processor */
537536   m_is_esb = 1;
538   starwars_mproc_init(machine());
537   starwars_mproc_init();
539538
540539   /* initialize banking */
541540   membank("bank1")->configure_entries(0, 2, rom + 0x6000, 0x10000 - 0x6000);
trunk/src/mame/drivers/seibuspi.c
r20977r20978
741741
742742/********************************************************************/
743743
744static UINT8 z80_fifoout_pop(address_space &space)
744UINT8 seibuspi_state::z80_fifoout_pop(address_space &space)
745745{
746   seibuspi_state *state = space.machine().driver_data<seibuspi_state>();
747746   UINT8 r;
748   if (state->m_fifoout_wpos == state->m_fifoout_rpos)
747   if (m_fifoout_wpos == m_fifoout_rpos)
749748   {
750749      logerror("Sound FIFOOUT underflow at %08X\n", space.device().safe_pc());
751750   }
752   r = state->m_fifoout_data[state->m_fifoout_rpos++];
753   if(state->m_fifoout_rpos == FIFO_SIZE)
751   r = m_fifoout_data[m_fifoout_rpos++];
752   if(m_fifoout_rpos == FIFO_SIZE)
754753   {
755      state->m_fifoout_rpos = 0;
754      m_fifoout_rpos = 0;
756755   }
757756
758   if (state->m_fifoout_wpos == state->m_fifoout_rpos)
757   if (m_fifoout_wpos == m_fifoout_rpos)
759758   {
760      state->m_fifoout_read_request = 0;
759      m_fifoout_read_request = 0;
761760   }
762761
763762   return r;
764763}
765764
766static void z80_fifoout_push(address_space &space, UINT8 data)
765void seibuspi_state::z80_fifoout_push(address_space &space, UINT8 data)
767766{
768   seibuspi_state *state = space.machine().driver_data<seibuspi_state>();
769   state->m_fifoout_data[state->m_fifoout_wpos++] = data;
770   if (state->m_fifoout_wpos == FIFO_SIZE)
767   m_fifoout_data[m_fifoout_wpos++] = data;
768   if (m_fifoout_wpos == FIFO_SIZE)
771769   {
772      state->m_fifoout_wpos = 0;
770      m_fifoout_wpos = 0;
773771   }
774   if(state->m_fifoout_wpos == state->m_fifoout_rpos)
772   if(m_fifoout_wpos == m_fifoout_rpos)
775773   {
776774      fatalerror("Sound FIFOOUT overflow at %08X\n", space.device().safe_pc());
777775   }
778776
779   state->m_fifoout_read_request = 1;
777   m_fifoout_read_request = 1;
780778}
781779
782static UINT8 z80_fifoin_pop(address_space &space)
780UINT8 seibuspi_state::z80_fifoin_pop(address_space &space)
783781{
784   seibuspi_state *state = space.machine().driver_data<seibuspi_state>();
785782   UINT8 r;
786   if (state->m_fifoin_wpos == state->m_fifoin_rpos)
783   if (m_fifoin_wpos == m_fifoin_rpos)
787784   {
788785      fatalerror("Sound FIFOIN underflow at %08X\n", space.device().safe_pc());
789786   }
790   r = state->m_fifoin_data[state->m_fifoin_rpos++];
791   if(state->m_fifoin_rpos == FIFO_SIZE)
787   r = m_fifoin_data[m_fifoin_rpos++];
788   if(m_fifoin_rpos == FIFO_SIZE)
792789   {
793      state->m_fifoin_rpos = 0;
790      m_fifoin_rpos = 0;
794791   }
795792
796   if (state->m_fifoin_wpos == state->m_fifoin_rpos)
793   if (m_fifoin_wpos == m_fifoin_rpos)
797794   {
798      state->m_fifoin_read_request = 0;
795      m_fifoin_read_request = 0;
799796   }
800797
801798   return r;
802799}
803800
804static void z80_fifoin_push(address_space &space, UINT8 data)
801void seibuspi_state::z80_fifoin_push(address_space &space, UINT8 data)
805802{
806   seibuspi_state *state = space.machine().driver_data<seibuspi_state>();
807   state->m_fifoin_data[state->m_fifoin_wpos++] = data;
808   if(state->m_fifoin_wpos == FIFO_SIZE)
803   m_fifoin_data[m_fifoin_wpos++] = data;
804   if(m_fifoin_wpos == FIFO_SIZE)
809805   {
810      state->m_fifoin_wpos = 0;
806      m_fifoin_wpos = 0;
811807   }
812   if(state->m_fifoin_wpos == state->m_fifoin_rpos)
808   if(m_fifoin_wpos == m_fifoin_rpos)
813809   {
814810      fatalerror("Sound FIFOIN overflow at %08X\n", space.device().safe_pc());
815811   }
816812
817   state->m_fifoin_read_request = 1;
813   m_fifoin_read_request = 1;
818814}
819815
820816READ32_MEMBER(seibuspi_state::sb_coin_r)
r20977r20978
875871
876872   // tile banks
877873   if( ACCESSING_BITS_16_23 ) {
878      rf2_set_layer_banks(machine(), data >> 16);
874      rf2_set_layer_banks(data >> 16);
879875
880876      eeprom_device *eeprom = downcast<eeprom_device *>(device);
881877      eeprom->write_bit((data & 0x800000) ? 1 : 0);
r20977r20978
900896{
901897   // tile banks
902898   if( ACCESSING_BITS_16_23 ) {
903      rf2_set_layer_banks(machine(), data >> 16);
899      rf2_set_layer_banks(data >> 16);
904900   }
905901
906902logerror("z80 data = %08x mask = %08x\n",data,mem_mask);
r20977r20978
20632059   return m_spimainram[(0x002894c-0x800)/4];
20642060}
20652061
2066static void init_spi(running_machine &machine)
2062void seibuspi_state::init_spi()
20672063{
2068   seibuspi_state *state = machine.driver_data<seibuspi_state>();
2069   state->m_flash[0] = machine.device<intel_e28f008sa_device>("flash0");
2070   state->m_flash[1] = machine.device<intel_e28f008sa_device>("flash1");
2064   m_flash[0] = machine().device<intel_e28f008sa_device>("flash0");
2065   m_flash[1] = machine().device<intel_e28f008sa_device>("flash1");
20712066
2072   seibuspi_text_decrypt(state->memregion("gfx1")->base());
2073   seibuspi_bg_decrypt(state->memregion("gfx2")->base(), state->memregion("gfx2")->bytes());
2074   seibuspi_sprite_decrypt(state->memregion("gfx3")->base(), 0x400000);
2067   seibuspi_text_decrypt(memregion("gfx1")->base());
2068   seibuspi_bg_decrypt(memregion("gfx2")->base(), memregion("gfx2")->bytes());
2069   seibuspi_sprite_decrypt(memregion("gfx3")->base(), 0x400000);
20752070}
20762071
20772072DRIVER_INIT_MEMBER(seibuspi_state,rdft)
20782073{
20792074   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x00298d0, 0x00298d3, read32_delegate(FUNC(seibuspi_state::rdft_speedup_r),this));
20802075
2081   init_spi(machine());
2076   init_spi();
20822077}
20832078
20842079DRIVER_INIT_MEMBER(seibuspi_state,senkyu)
20852080{
20862081   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x0018cb4, 0x0018cb7, read32_delegate(FUNC(seibuspi_state::senkyu_speedup_r),this));
20872082
2088   init_spi(machine());
2083   init_spi();
20892084}
20902085
20912086DRIVER_INIT_MEMBER(seibuspi_state,senkyua)
20922087{
20932088   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x0018c9c, 0x0018c9f, read32_delegate(FUNC(seibuspi_state::senkyua_speedup_r),this));
20942089
2095   init_spi(machine());
2090   init_spi();
20962091}
20972092
20982093DRIVER_INIT_MEMBER(seibuspi_state,batlball)
20992094{
21002095   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x0018db4, 0x0018db7, read32_delegate(FUNC(seibuspi_state::batlball_speedup_r),this));
21012096
2102   init_spi(machine());
2097   init_spi();
21032098}
21042099
21052100DRIVER_INIT_MEMBER(seibuspi_state,ejanhs)
r20977r20978
21072102//  idle skip doesn't work properly?
21082103//  machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x002d224, 0x002d227, read32_delegate(FUNC(seibuspi_state::ejanhs_speedup_r),this));
21092104
2110   init_spi(machine());
2105   init_spi();
21112106}
21122107
21132108DRIVER_INIT_MEMBER(seibuspi_state,viprp1)
21142109{
21152110   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x001e2e0, 0x001e2e3, read32_delegate(FUNC(seibuspi_state::viprp1_speedup_r),this));
21162111
2117   init_spi(machine());
2112   init_spi();
21182113}
21192114
21202115DRIVER_INIT_MEMBER(seibuspi_state,viprp1o)
21212116{
21222117   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x001d49c, 0x001d49f, read32_delegate(FUNC(seibuspi_state::viprp1o_speedup_r),this));
21232118
2124   init_spi(machine());
2119   init_spi();
21252120}
21262121
21272122
21282123
2129static void init_rf2_common(running_machine &machine)
2124void seibuspi_state::init_rf2_common()
21302125{
2131   seibuspi_state *state = machine.driver_data<seibuspi_state>();
2132   state->m_flash[0] = machine.device<intel_e28f008sa_device>("flash0");
2133   state->m_flash[1] = machine.device<intel_e28f008sa_device>("flash1");
2126   m_flash[0] = machine().device<intel_e28f008sa_device>("flash0");
2127   m_flash[1] = machine().device<intel_e28f008sa_device>("flash1");
21342128
2135   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x0282AC, 0x0282AF, read32_delegate(FUNC(seibuspi_state::rf2_speedup_r),state));
2136   seibuspi_rise10_text_decrypt(state->memregion("gfx1")->base());
2137   seibuspi_rise10_bg_decrypt(state->memregion("gfx2")->base(), state->memregion("gfx2")->bytes());
2138   seibuspi_rise10_sprite_decrypt(state->memregion("gfx3")->base(), 0x600000);
2129   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x0282AC, 0x0282AF, read32_delegate(FUNC(seibuspi_state::rf2_speedup_r),this));
2130   seibuspi_rise10_text_decrypt(memregion("gfx1")->base());
2131   seibuspi_rise10_bg_decrypt(memregion("gfx2")->base(), memregion("gfx2")->bytes());
2132   seibuspi_rise10_sprite_decrypt(memregion("gfx3")->base(), 0x600000);
21392133
2140   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x560, 0x563, write32_delegate(FUNC(seibuspi_state::sprite_dma_start_w),state));
2134   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x560, 0x563, write32_delegate(FUNC(seibuspi_state::sprite_dma_start_w),this));
21412135}
21422136
21432137DRIVER_INIT_MEMBER(seibuspi_state,rdft2)
21442138{
2145   init_rf2_common(machine());
2139   init_rf2_common();
21462140}
21472141
21482142DRIVER_INIT_MEMBER(seibuspi_state,rdft2us)
21492143{
2150   init_rf2_common(machine());
2144   init_rf2_common();
21512145}
21522146
21532147
2154static void init_rfjet_common(running_machine &machine)
2148void seibuspi_state::init_rfjet_common()
21552149{
2156   seibuspi_state *state = machine.driver_data<seibuspi_state>();
2157   state->m_flash[0] = machine.device<intel_e28f008sa_device>("flash0");
2158   state->m_flash[1] = machine.device<intel_e28f008sa_device>("flash1");
2150   m_flash[0] = machine().device<intel_e28f008sa_device>("flash0");
2151   m_flash[1] = machine().device<intel_e28f008sa_device>("flash1");
21592152
2160   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x002894c, 0x002894f, read32_delegate(FUNC(seibuspi_state::rfjet_speedup_r),state));
2161   seibuspi_rise11_text_decrypt(state->memregion("gfx1")->base());
2162   seibuspi_rise11_bg_decrypt(state->memregion("gfx2")->base(), state->memregion("gfx2")->bytes());
2163   seibuspi_rise11_sprite_decrypt_rfjet(state->memregion("gfx3")->base(), 0x800000);
2153   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x002894c, 0x002894f, read32_delegate(FUNC(seibuspi_state::rfjet_speedup_r),this));
2154   seibuspi_rise11_text_decrypt(memregion("gfx1")->base());
2155   seibuspi_rise11_bg_decrypt(memregion("gfx2")->base(), memregion("gfx2")->bytes());
2156   seibuspi_rise11_sprite_decrypt_rfjet(memregion("gfx3")->base(), 0x800000);
21642157
2165   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x560, 0x563, write32_delegate(FUNC(seibuspi_state::sprite_dma_start_w),state));
2158   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x560, 0x563, write32_delegate(FUNC(seibuspi_state::sprite_dma_start_w),this));
21662159}
21672160
21682161DRIVER_INIT_MEMBER(seibuspi_state,rfjet)
21692162{
2170   init_rfjet_common(machine());
2163   init_rfjet_common();
21712164}
21722165
21732166/* SYS386 */
21742167
21752168DRIVER_INIT_MEMBER(seibuspi_state,rdft22kc)
21762169{
2177   init_rf2_common(machine());
2170   init_rf2_common();
21782171}
21792172
21802173DRIVER_INIT_MEMBER(seibuspi_state,rfjet2k)
21812174{
2182   init_rfjet_common(machine());
2175   init_rfjet_common();
21832176}
21842177
21852178MACHINE_RESET_MEMBER(seibuspi_state,seibu386)
trunk/src/mame/drivers/suna8.c
r20977r20978
8282                                Brick Zone
8383***************************************************************************/
8484
85static UINT8 *brickzn_decrypt(running_machine &machine)
85UINT8 *suna8_state::brickzn_decrypt()
8686{
87   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
88   UINT8   *RAM    =   machine.root_device().memregion("maincpu")->base();
89   size_t  size    =   machine.root_device().memregion("maincpu")->bytes();
90   UINT8   *decrypt = auto_alloc_array(machine, UINT8, size);
87   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
88   UINT8   *RAM    =   machine().root_device().memregion("maincpu")->base();
89   size_t  size    =   machine().root_device().memregion("maincpu")->bytes();
90   UINT8   *decrypt = auto_alloc_array(machine(), UINT8, size);
9191   int i;
9292
9393   space.set_decrypted_region(0x0000, 0x7fff, decrypt);
r20977r20978
132132DRIVER_INIT_MEMBER(suna8_state,brickzn)
133133{
134134   UINT8   *RAM    =   machine().root_device().memregion("maincpu")->base();
135   UINT8   *decrypt = brickzn_decrypt(machine());
135   UINT8   *decrypt = brickzn_decrypt();
136136   int i;
137137
138138   // Opcodes decrypted as data (to do: activated at run-time)
r20977r20978
171171DRIVER_INIT_MEMBER(suna8_state,brickznv4)
172172{
173173   UINT8   *RAM    =   machine().root_device().memregion("maincpu")->base();
174   UINT8   *decrypt = brickzn_decrypt(machine());
174   UINT8   *decrypt = brickzn_decrypt();
175175   int i;
176176
177177   // Opcodes decrypted as data (to do: activated at run-time)
trunk/src/mame/drivers/suprnova.c
r20977r20978
190190   *x_in = x1r-x2l;
191191}
192192
193static void hit_recalc(running_machine &machine)
193void skns_state::hit_recalc()
194194{
195   skns_state *state = machine.driver_data<skns_state>();
196   hit_t &hit = state->m_hit;
195   hit_t &hit = m_hit;
197196
198197   hit_calc_axis(hit.x1p, hit.x1s, hit.x2p, hit.x2s, hit.org,
199198      &hit.x1_p1, &hit.x1_p2, &hit.x2_p1, &hit.x2_p2,
r20977r20978
287286//      log_write("HIT", adr, data, type);
288287   break;
289288   }
290   hit_recalc(machine());
289   hit_recalc();
291290}
292291
293292WRITE32_MEMBER(skns_state::skns_hit2_w)
r20977r20978
956955   return m_main_ram[0xb7380/4];
957956}
958957
959static void init_skns(running_machine &machine)
958void skns_state::init_skns()
960959{
961960   // init DRC to fastest options
962   sh2drc_set_options(machine.device("maincpu"), SH2DRC_FASTEST_OPTIONS);
961   sh2drc_set_options(machine().device("maincpu"), SH2DRC_FASTEST_OPTIONS);
963962}
964963
965static void set_drc_pcflush(running_machine &machine, UINT32 addr)
964void skns_state::set_drc_pcflush(UINT32 addr)
966965{
967   sh2drc_add_pcflush(machine.device("maincpu"), addr);
966   sh2drc_add_pcflush(machine().device("maincpu"), addr);
968967}
969968
970DRIVER_INIT_MEMBER(skns_state,galpani4)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-5,-1); init_skns(machine());  }
971DRIVER_INIT_MEMBER(skns_state,galpanis)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-5,-1); init_skns(machine());  }
972DRIVER_INIT_MEMBER(skns_state,cyvern)     { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+0,+2); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x604d3c8, 0x604d3cb, read32_delegate(FUNC(skns_state::cyvern_speedup_r),this) );  set_drc_pcflush(machine(), 0x402ebd2);  }
973DRIVER_INIT_MEMBER(skns_state,galpans2)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-1,-1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60fb6bc, 0x60fb6bf, read32_delegate(FUNC(skns_state::galpans2_speedup_r),this) ); set_drc_pcflush(machine(), 0x4049ae2); }
974DRIVER_INIT_MEMBER(skns_state,gutsn)      { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+0,+0); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x600c780, 0x600c783, read32_delegate(FUNC(skns_state::gutsn_speedup_r),this) ); set_drc_pcflush(machine(), 0x402206e); }
975DRIVER_INIT_MEMBER(skns_state,panicstr)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-1,-1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60f19e4, 0x60f19e7, read32_delegate(FUNC(skns_state::panicstr_speedup_r),this) ); set_drc_pcflush(machine(), 0x404e68a);  }
976DRIVER_INIT_MEMBER(skns_state,senknow)    { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+1,+1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60000dc, 0x60000df, read32_delegate(FUNC(skns_state::senknow_speedup_r),this) ); set_drc_pcflush(machine(), 0x4017dce);  }
977DRIVER_INIT_MEMBER(skns_state,puzzloope)  { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-9,-1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6081d38, 0x6081d3b, read32_delegate(FUNC(skns_state::puzzloope_speedup_r),this) ); set_drc_pcflush(machine(), 0x401da14); }
978DRIVER_INIT_MEMBER(skns_state,puzzloopj)  { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-9,-1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6086714, 0x6086717, read32_delegate(FUNC(skns_state::puzzloopj_speedup_r),this) ); set_drc_pcflush(machine(), 0x401dca0); }
979DRIVER_INIT_MEMBER(skns_state,puzzloopa)  { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-9,-1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6085bcc, 0x6085bcf, read32_delegate(FUNC(skns_state::puzzloopa_speedup_r),this) ); set_drc_pcflush(machine(), 0x401d9d4); }
980DRIVER_INIT_MEMBER(skns_state,puzzloopu)  { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-9,-1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6085cec, 0x6085cef, read32_delegate(FUNC(skns_state::puzzloopu_speedup_r),this) ); set_drc_pcflush(machine(), 0x401dab0); }
981DRIVER_INIT_MEMBER(skns_state,jjparads)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+5,+1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6000994, 0x6000997, read32_delegate(FUNC(skns_state::jjparads_speedup_r),this) ); set_drc_pcflush(machine(), 0x4015e84); }
982DRIVER_INIT_MEMBER(skns_state,jjparad2)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+5,+1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6000984, 0x6000987, read32_delegate(FUNC(skns_state::jjparad2_speedup_r),this) ); set_drc_pcflush(machine(), 0x401620a); }
983DRIVER_INIT_MEMBER(skns_state,ryouran)    { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+5,+1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6000a14, 0x6000a17, read32_delegate(FUNC(skns_state::ryouran_speedup_r),this) );  set_drc_pcflush(machine(), 0x40182ce); }
984DRIVER_INIT_MEMBER(skns_state,teljan)     { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+5,+1); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6002fb4, 0x6002fb7, read32_delegate(FUNC(skns_state::teljan_speedup_r),this) ); set_drc_pcflush(machine(), 0x401ba32); }
985DRIVER_INIT_MEMBER(skns_state,sengekis)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-192,-272); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60b74bc, 0x60b74bf, read32_delegate(FUNC(skns_state::sengekis_speedup_r),this) ); set_drc_pcflush(machine(), 0x60006ec); }
986DRIVER_INIT_MEMBER(skns_state,sengekij)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-192,-272); init_skns(machine());machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60b7380, 0x60b7383, read32_delegate(FUNC(skns_state::sengekij_speedup_r),this) ); set_drc_pcflush(machine(), 0x60006ec); }
987DRIVER_INIT_MEMBER(skns_state,sarukani)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-1,-1); init_skns(machine()); set_drc_pcflush(machine(), 0x4013b42); } // Speedup is in skns_io_w()
988DRIVER_INIT_MEMBER(skns_state,galpans3)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-1,-1); init_skns(machine());  }
969DRIVER_INIT_MEMBER(skns_state,galpani4)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-5,-1); init_skns();  }
970DRIVER_INIT_MEMBER(skns_state,galpanis)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-5,-1); init_skns();  }
971DRIVER_INIT_MEMBER(skns_state,cyvern)     { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+0,+2); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x604d3c8, 0x604d3cb, read32_delegate(FUNC(skns_state::cyvern_speedup_r),this) );  set_drc_pcflush(0x402ebd2);  }
972DRIVER_INIT_MEMBER(skns_state,galpans2)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-1,-1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60fb6bc, 0x60fb6bf, read32_delegate(FUNC(skns_state::galpans2_speedup_r),this) ); set_drc_pcflush(0x4049ae2); }
973DRIVER_INIT_MEMBER(skns_state,gutsn)      { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+0,+0); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x600c780, 0x600c783, read32_delegate(FUNC(skns_state::gutsn_speedup_r),this) ); set_drc_pcflush(0x402206e); }
974DRIVER_INIT_MEMBER(skns_state,panicstr)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-1,-1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60f19e4, 0x60f19e7, read32_delegate(FUNC(skns_state::panicstr_speedup_r),this) ); set_drc_pcflush(0x404e68a);  }
975DRIVER_INIT_MEMBER(skns_state,senknow)    { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+1,+1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60000dc, 0x60000df, read32_delegate(FUNC(skns_state::senknow_speedup_r),this) ); set_drc_pcflush(0x4017dce);  }
976DRIVER_INIT_MEMBER(skns_state,puzzloope)  { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-9,-1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6081d38, 0x6081d3b, read32_delegate(FUNC(skns_state::puzzloope_speedup_r),this) ); set_drc_pcflush(0x401da14); }
977DRIVER_INIT_MEMBER(skns_state,puzzloopj)  { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-9,-1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6086714, 0x6086717, read32_delegate(FUNC(skns_state::puzzloopj_speedup_r),this) ); set_drc_pcflush(0x401dca0); }
978DRIVER_INIT_MEMBER(skns_state,puzzloopa)  { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-9,-1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6085bcc, 0x6085bcf, read32_delegate(FUNC(skns_state::puzzloopa_speedup_r),this) ); set_drc_pcflush(0x401d9d4); }
979DRIVER_INIT_MEMBER(skns_state,puzzloopu)  { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-9,-1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6085cec, 0x6085cef, read32_delegate(FUNC(skns_state::puzzloopu_speedup_r),this) ); set_drc_pcflush(0x401dab0); }
980DRIVER_INIT_MEMBER(skns_state,jjparads)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+5,+1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6000994, 0x6000997, read32_delegate(FUNC(skns_state::jjparads_speedup_r),this) ); set_drc_pcflush(0x4015e84); }
981DRIVER_INIT_MEMBER(skns_state,jjparad2)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+5,+1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6000984, 0x6000987, read32_delegate(FUNC(skns_state::jjparad2_speedup_r),this) ); set_drc_pcflush(0x401620a); }
982DRIVER_INIT_MEMBER(skns_state,ryouran)    { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+5,+1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6000a14, 0x6000a17, read32_delegate(FUNC(skns_state::ryouran_speedup_r),this) );  set_drc_pcflush(0x40182ce); }
983DRIVER_INIT_MEMBER(skns_state,teljan)     { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(+5,+1); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x6002fb4, 0x6002fb7, read32_delegate(FUNC(skns_state::teljan_speedup_r),this) ); set_drc_pcflush(0x401ba32); }
984DRIVER_INIT_MEMBER(skns_state,sengekis)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-192,-272); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60b74bc, 0x60b74bf, read32_delegate(FUNC(skns_state::sengekis_speedup_r),this) ); set_drc_pcflush(0x60006ec); }
985DRIVER_INIT_MEMBER(skns_state,sengekij)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-192,-272); init_skns();machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x60b7380, 0x60b7383, read32_delegate(FUNC(skns_state::sengekij_speedup_r),this) ); set_drc_pcflush(0x60006ec); }
986DRIVER_INIT_MEMBER(skns_state,sarukani)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-1,-1); init_skns(); set_drc_pcflush(0x4013b42); } // Speedup is in skns_io_w()
987DRIVER_INIT_MEMBER(skns_state,galpans3)   { machine().device<sknsspr_device>("spritegen")->skns_sprite_kludge(-1,-1); init_skns();  }
989988
990989
991990
trunk/src/mame/drivers/system16.c
r20977r20978
475475
476476/***************************************************************************/
477477
478static void set_tile_bank( running_machine &machine, int data )
478void segas1x_bootleg_state::set_tile_bank( int data )
479479{
480   segas1x_bootleg_state *state = machine.driver_data<segas1x_bootleg_state>();
481   state->m_tile_bank0 = (data >> 4) & 0x0f;
482   state->m_tile_bank1 = data & 0x0f;
480   m_tile_bank0 = (data >> 4) & 0x0f;
481   m_tile_bank1 = data & 0x0f;
483482}
484483
485static void set_fg_page( running_machine &machine, int data )
484void segas1x_bootleg_state::set_fg_page( int data )
486485{
487   segas1x_bootleg_state *state = machine.driver_data<segas1x_bootleg_state>();
488   state->m_fg_page[0] = data >> 12;
489   state->m_fg_page[1] = (data >> 8) & 0x0f;
490   state->m_fg_page[2] = (data >> 4) & 0x0f;
491   state->m_fg_page[3] = data & 0x0f;
486   m_fg_page[0] = data >> 12;
487   m_fg_page[1] = (data >> 8) & 0x0f;
488   m_fg_page[2] = (data >> 4) & 0x0f;
489   m_fg_page[3] = data & 0x0f;
492490}
493491
494static void set_bg_page( running_machine &machine, int data )
492void segas1x_bootleg_state::set_bg_page( int data )
495493{
496   segas1x_bootleg_state *state = machine.driver_data<segas1x_bootleg_state>();
497   state->m_bg_page[0] = data >> 12;
498   state->m_bg_page[1] = (data >> 8) & 0x0f;
499   state->m_bg_page[2] = (data >> 4) & 0x0f;
500   state->m_bg_page[3] = data & 0x0f;
494   m_bg_page[0] = data >> 12;
495   m_bg_page[1] = (data >> 8) & 0x0f;
496   m_bg_page[2] = (data >> 4) & 0x0f;
497   m_bg_page[3] = data & 0x0f;
501498}
502499
503500#ifdef UNUSED_CODE
r20977r20978
536533
537534WRITE16_MEMBER(segas1x_bootleg_state::s16bl_bgpage_w)
538535{
539   set_bg_page(machine(), data);
536   set_bg_page(data);
540537}
541538
542539WRITE16_MEMBER(segas1x_bootleg_state::s16bl_fgpage_w)
543540{
544   set_fg_page(machine(), data);
541   set_fg_page(data);
545542}
546543
547544WRITE16_MEMBER(segas1x_bootleg_state::s16bl_fgscrollx_bank_w)
r20977r20978
550547   int bank = (data & 0xc000) >> 14;
551548
552549   scroll += 0x200;
553   set_tile_bank(machine(), bank);
550   set_tile_bank(bank);
554551
555552   scroll += 3; // so that the character portraits in attract mode are properly aligned (alighnment on character select no longer matches original tho?)
556553   m_fg_scrollx = -scroll;
r20977r20978
636633   AM_RANGE(0x902002, 0x902003) AM_READ_PORT("DSW1")
637634ADDRESS_MAP_END
638635
639static void datsu_set_pages( running_machine &machine )
636void segas1x_bootleg_state::datsu_set_pages(  )
640637{
641   segas1x_bootleg_state *state = machine.driver_data<segas1x_bootleg_state>();
642638   UINT16 page;
643639
644   page = ((state->m_datsu_page[0] & 0x00f0) >>0) |
645         ((state->m_datsu_page[1] & 0x00f0) >>4) |
646         ((state->m_datsu_page[2] & 0x00f0) <<8) |
647         ((state->m_datsu_page[3] & 0x00f0) <<4);
640   page = ((m_datsu_page[0] & 0x00f0) >>0) |
641         ((m_datsu_page[1] & 0x00f0) >>4) |
642         ((m_datsu_page[2] & 0x00f0) <<8) |
643         ((m_datsu_page[3] & 0x00f0) <<4);
648644
649645
650   set_fg_page(machine, page);
646   set_fg_page(page);
651647
652   page = ((state->m_datsu_page[0] & 0x000f) <<4) |
653         ((state->m_datsu_page[1] & 0x000f) <<0) |
654         ((state->m_datsu_page[2] & 0x000f) <<12) |
655         ((state->m_datsu_page[3] & 0x000f) <<8);
648   page = ((m_datsu_page[0] & 0x000f) <<4) |
649         ((m_datsu_page[1] & 0x000f) <<0) |
650         ((m_datsu_page[2] & 0x000f) <<12) |
651         ((m_datsu_page[3] & 0x000f) <<8);
656652
657   set_bg_page(machine, page);
653   set_bg_page(page);
658654}
659655
660656WRITE16_MEMBER(segas1x_bootleg_state::datsu_page0_w)
661657{
662658   COMBINE_DATA(&m_datsu_page[0]);
663   datsu_set_pages(machine());
659   datsu_set_pages();
664660}
665661
666662WRITE16_MEMBER(segas1x_bootleg_state::datsu_page1_w)
667663{
668664   COMBINE_DATA(&m_datsu_page[1]);
669   datsu_set_pages(machine());
665   datsu_set_pages();
670666}
671667
672668WRITE16_MEMBER(segas1x_bootleg_state::datsu_page2_w)
673669{
674670   COMBINE_DATA(&m_datsu_page[2]);
675   datsu_set_pages(machine());
671   datsu_set_pages();
676672}
677673
678674WRITE16_MEMBER(segas1x_bootleg_state::datsu_page3_w)
679675{
680676   COMBINE_DATA(&m_datsu_page[3]);
681   datsu_set_pages(machine());
677   datsu_set_pages();
682678}
683679
684680static ADDRESS_MAP_START( bayrouteb2_map, AS_PROGRAM, 16, segas1x_bootleg_state )
r20977r20978
737733   int scroll = data & 0x1ff;
738734   int bank = (data & 0xc000) >> 14;
739735
740   set_tile_bank(machine(),  bank);
736   set_tile_bank(bank);
741737   scroll += 0x1f6;
742738   scroll &= 0x3ff;
743739   m_fg_scrollx = -scroll;
r20977r20978
780776         ((m_goldnaxeb2_fgpage[3] & 0xf) << 8) |
781777         ((m_goldnaxeb2_fgpage[2] & 0xf) << 12);
782778
783   set_fg_page(machine(), page ^ 0xffff);
779   set_fg_page(page ^ 0xffff);
784780
785781}
786782
r20977r20978
795791         ((m_goldnaxeb2_bgpage[3] & 0xf) << 8) |
796792         ((m_goldnaxeb2_bgpage[2] & 0xf) << 12);
797793
798   set_bg_page(machine(), page ^ 0xffff);
794   set_bg_page(page ^ 0xffff);
799795}
800796
801797static ADDRESS_MAP_START( goldnaxeb2_map, AS_PROGRAM, 16, segas1x_bootleg_state )
trunk/src/mame/drivers/simpsons.c
r20977r20978
112112}
113113
114114#if 0
115static void sound_nmi_callback( running_machine &machine, int param )
115void simpsons_state::sound_nmi_callback( int param )
116116{
117   simpsons_state *state = machine.driver_data<simpsons_state>();
118   state->m_audiocpu->set_input_line(INPUT_LINE_NMI, (state->m_nmi_enabled) ? CLEAR_LINE : ASSERT_LINE );
119   state->m_nmi_enabled = 0;
117   m_audiocpu->set_input_line(INPUT_LINE_NMI, (m_nmi_enabled) ? CLEAR_LINE : ASSERT_LINE );
118   m_nmi_enabled = 0;
120119}
121120#endif
122121
r20977r20978
225224
226225***************************************************************************/
227226
228static void simpsons_objdma( running_machine &machine )
227void simpsons_state::simpsons_objdma(  )
229228{
230   simpsons_state *state = machine.driver_data<simpsons_state>();
231229   int counter, num_inactive;
232230   UINT16 *src, *dst;
233231
234   k053247_get_ram(state->m_k053246, &dst);
235   counter = k053247_get_dy(state->m_k053246);
232   k053247_get_ram(m_k053246, &dst);
233   counter = k053247_get_dy(m_k053246);
236234
237   src = state->m_spriteram;
235   src = m_spriteram;
238236   num_inactive = counter = 256;
239237
240238   do {
r20977r20978
262260{
263261   if (k053246_is_irq_enabled(m_k053246))
264262   {
265      simpsons_objdma(machine());
263      simpsons_objdma();
266264      // 32+256us delay at 8MHz dotclock; artificially shortened since actual V-blank length is unknown
267265      machine().scheduler().timer_set(attotime::from_usec(30), timer_expired_delegate(FUNC(simpsons_state::dmaend_callback),this));
268266   }
trunk/src/mame/drivers/stactics.c
r20977r20978
7373}
7474
7575
76static void move_motor(running_machine &machine, stactics_state *state)
76void stactics_state::move_motor()
7777{
7878      /* monitor motor under joystick control */
79   if (*state->m_motor_on & 0x01)
79   if (*m_motor_on & 0x01)
8080   {
81      int ip3 = machine.root_device().ioport("IN3")->read();
82      int ip4 = machine.root_device().ioport("FAKE")->read();
81      int ip3 = machine().root_device().ioport("IN3")->read();
82      int ip4 = machine().root_device().ioport("FAKE")->read();
8383
8484      /* up */
85      if (((ip4 & 0x01) == 0) && (state->m_vert_pos > -128))
86         state->m_vert_pos--;
85      if (((ip4 & 0x01) == 0) && (m_vert_pos > -128))
86         m_vert_pos--;
8787
8888      /* down */
89      if (((ip4 & 0x02) == 0) && (state->m_vert_pos < 127))
90         state->m_vert_pos++;
89      if (((ip4 & 0x02) == 0) && (m_vert_pos < 127))
90         m_vert_pos++;
9191
9292      /* left */
93      if (((ip3 & 0x20) == 0) && (state->m_horiz_pos < 127))
94         state->m_horiz_pos++;
93      if (((ip3 & 0x20) == 0) && (m_horiz_pos < 127))
94         m_horiz_pos++;
9595
9696      /* right */
97      if (((ip3 & 0x40) == 0) && (state->m_horiz_pos > -128))
98         state->m_horiz_pos--;
97      if (((ip3 & 0x40) == 0) && (m_horiz_pos > -128))
98         m_horiz_pos--;
9999   }
100100
101101      /* monitor motor under self-centering control */
102102   else
103103   {
104      if (state->m_horiz_pos > 0)
105         state->m_horiz_pos--;
106      else if (state->m_horiz_pos < 0)
107         state->m_horiz_pos++;
104      if (m_horiz_pos > 0)
105         m_horiz_pos--;
106      else if (m_horiz_pos < 0)
107         m_horiz_pos++;
108108
109      if (state->m_vert_pos > 0)
110         state->m_vert_pos--;
111      else if (state->m_vert_pos < 0)
112         state->m_vert_pos++;
109      if (m_vert_pos > 0)
110         m_vert_pos--;
111      else if (m_vert_pos < 0)
112         m_vert_pos++;
113113   }
114114}
115115
r20977r20978
150150
151151INTERRUPT_GEN_MEMBER(stactics_state::stactics_interrupt)
152152{
153   move_motor(machine(), this);
153   move_motor();
154154
155155   device.execute().set_input_line(0, HOLD_LINE);
156156}
trunk/src/mame/drivers/segag80r.c
r20977r20978
166166 *
167167 *************************************/
168168
169static offs_t decrypt_offset(address_space &space, offs_t offset)
169offs_t segag80r_state::decrypt_offset(address_space &space, offs_t offset)
170170{
171   segag80r_state *state = space.machine().driver_data<segag80r_state>();
172
173171   /* ignore anything but accesses via opcode $32 (LD $(XXYY),A) */
174172   offs_t pc = space.device().safe_pcbase();
175173   if ((UINT16)pc == 0xffff || space.read_byte(pc) != 0x32)
176174      return offset;
177175
178176   /* fetch the low byte of the address and munge it */
179   return (offset & 0xff00) | (*state->m_decrypt)(pc, space.read_byte(pc + 1));
177   return (offset & 0xff00) | (*m_decrypt)(pc, space.read_byte(pc + 1));
180178}
181179
182180WRITE8_MEMBER(segag80r_state::mainram_w)
r20977r20978
198196 *
199197 *************************************/
200198
201INLINE UINT8 demangle(UINT8 d7d6, UINT8 d5d4, UINT8 d3d2, UINT8 d1d0)
199inline UINT8 segag80r_state::demangle(UINT8 d7d6, UINT8 d5d4, UINT8 d3d2, UINT8 d1d0)
202200{
203201   return ((d7d6 << 7) & 0x80) | ((d7d6 << 2) & 0x40) |
204202         ((d5d4 << 5) & 0x20) | ((d5d4 << 0) & 0x10) |
r20977r20978
14151413 *
14161414 *************************************/
14171415
1418static void monsterb_expand_gfx(running_machine &machine, const char *region)
1416void segag80r_state::monsterb_expand_gfx(const char *region)
14191417{
14201418   UINT8 *temp, *dest;
14211419   int i;
14221420
14231421   /* expand the background ROMs; A11/A12 of each ROM is independently controlled via */
14241422   /* banking */
1425   dest = machine.root_device().memregion(region)->base();
1426   temp = auto_alloc_array(machine, UINT8, 0x4000);
1423   dest = machine().root_device().memregion(region)->base();
1424   temp = auto_alloc_array(machine(), UINT8, 0x4000);
14271425   memcpy(temp, dest, 0x4000);
14281426
14291427   /* 16 effective total banks */
r20977r20978
14321430      memcpy(&dest[0x0000 + i * 0x800], &temp[0x0000 + (i & 3) * 0x800], 0x800);
14331431      memcpy(&dest[0x8000 + i * 0x800], &temp[0x2000 + (i >> 2) * 0x800], 0x800);
14341432   }
1435   auto_free(machine, temp);
1433   auto_free(machine(), temp);
14361434}
14371435
14381436
r20977r20978
15051503
15061504   /* configure video */
15071505   m_background_pcb = G80_BACKGROUND_MONSTERB;
1508   monsterb_expand_gfx(machine(), "gfx1");
1506   monsterb_expand_gfx("gfx1");
15091507
15101508   /* install background board handlers */
15111509   iospace.install_write_handler(0xb8, 0xbd, write8_delegate(FUNC(segag80r_state::monsterb_back_port_w),this));
r20977r20978
15241522
15251523   /* configure video */
15261524   m_background_pcb = G80_BACKGROUND_PIGNEWT;
1527   monsterb_expand_gfx(machine(), "gfx1");
1525   monsterb_expand_gfx("gfx1");
15281526
15291527   /* install background board handlers */
15301528   iospace.install_write_handler(0xb4, 0xb5, write8_delegate(FUNC(segag80r_state::pignewt_back_color_w),this));
r20977r20978
15441542
15451543   /* configure video */
15461544   m_background_pcb = G80_BACKGROUND_PIGNEWT;
1547   monsterb_expand_gfx(machine(), "gfx1");
1545   monsterb_expand_gfx("gfx1");
15481546
15491547   /* install background board handlers */
15501548   iospace.install_write_handler(0xb4, 0xb5, write8_delegate(FUNC(segag80r_state::pignewt_back_color_w),this));
trunk/src/mame/drivers/suprridr.c
r20977r20978
226226   UINT32 ret;
227227
228228   /* screen flip multiplexes controls */
229   if (suprridr_is_screen_flipped(machine()))
229   if (suprridr_is_screen_flipped())
230230      ret = ioport(SUPRRIDR_P2_CONTROL_PORT_TAG)->read();
231231   else
232232      ret = ioport(SUPRRIDR_P1_CONTROL_PORT_TAG)->read();
trunk/src/mame/drivers/skullxbo.c
r20977r20978
5959   }
6060
6161   /* update the playfield and motion objects */
62   skullxbo_scanline_update(machine(), scanline);
62   skullxbo_scanline_update(scanline);
6363}
6464
6565
trunk/src/mame/drivers/spdodgeb.c
r20977r20978
8787
8888
8989#if 0   // default - more sensitive (state change and timing measured on real board?)
90static void mcu63705_update_inputs(running_machine &machine)
90void spdodgeb_state::mcu63705_update_inputs()
9191{
92   spdodgeb_state *state = machine.driver_data<spdodgeb_state>();
9392   int buttons[2];
9493   int p,j;
9594
r20977r20978
9897   {
9998      int curr[2][2];
10099
101      curr[p][0] = state->ioport(p ? "P2" : "P1")->read() & 0x01;
102      curr[p][1] = state->ioport(p ? "P2" : "P1")->read() & 0x02;
100      curr[p][0] = ioport(p ? "P2" : "P1")->read() & 0x01;
101      curr[p][1] = ioport(p ? "P2" : "P1")->read() & 0x02;
103102
104103      for (j = 0;j <= 1;j++)
105104      {
106105         if (curr[p][j] == 0)
107106         {
108            if (state->m_prev[p][j] != 0)
109               state->m_countup[p][j] = 0;
107            if (m_prev[p][j] != 0)
108               m_countup[p][j] = 0;
110109            if (curr[p][j^1])
111               state->m_countup[p][j] = 100;
112            state->m_countup[p][j]++;
113            state->m_running[p] &= ~(1 << j);
110               m_countup[p][j] = 100;
111            m_countup[p][j]++;
112            m_running[p] &= ~(1 << j);
114113         }
115114         else
116115         {
117            if (state->m_prev[p][j] == 0)
116            if (m_prev[p][j] == 0)
118117            {
119               if (state->m_countup[p][j] < 10 && state->m_countdown[p][j] < 5)
120                  state->m_running[p] |= 1 << j;
121               state->m_countdown[p][j] = 0;
118               if (m_countup[p][j] < 10 && m_countdown[p][j] < 5)
119                  m_running[p] |= 1 << j;
120               m_countdown[p][j] = 0;
122121            }
123            state->m_countdown[p][j]++;
122            m_countdown[p][j]++;
124123         }
125124      }
126125
127      state->m_prev[p][0] = curr[p][0];
128      state->m_prev[p][1] = curr[p][1];
126      m_prev[p][0] = curr[p][0];
127      m_prev[p][1] = curr[p][1];
129128   }
130129
131130   /* update jumping and buttons state */
r20977r20978
133132   {
134133      int curr[2];
135134
136      curr[p] = machine.root_device().ioport(p ? "P2" : "P1")->read() & 0x30;
135      curr[p] = machine().root_device().ioport(p ? "P2" : "P1")->read() & 0x30;
137136
138      if (state->m_jumped[p]) buttons[p] = 0; /* jump only momentarily flips the buttons */
137      if (m_jumped[p]) buttons[p] = 0; /* jump only momentarily flips the buttons */
139138      else buttons[p] = curr[p];
140139
141      if (buttons[p] == 0x30) state->m_jumped[p] = 1;
142      if (curr[p] == 0x00) state->m_jumped[p] = 0;
140      if (buttons[p] == 0x30) m_jumped[p] = 1;
141      if (curr[p] == 0x00) m_jumped[p] = 0;
143142
144      state->m_prev[p] = curr[p];
143      m_prev[p] = curr[p];
145144   }
146145
147   state->m_inputs[0] = machine.root_device().ioport("P1")->read() & 0xcf;
148   state->m_inputs[1] = machine.root_device().ioport("P2")->read() & 0x0f;
149   state->m_inputs[2] = state->m_running[0] | buttons[0];
150   state->m_inputs[3] = state->m_running[1] | buttons[1];
146   m_inputs[0] = machine().root_device().ioport("P1")->read() & 0xcf;
147   m_inputs[1] = machine().root_device().ioport("P2")->read() & 0x0f;
148   m_inputs[2] = m_running[0] | buttons[0];
149   m_inputs[3] = m_running[1] | buttons[1];
151150}
152151#else   // alternate - less sensitive
153static void mcu63705_update_inputs(running_machine &machine)
152void spdodgeb_state::mcu63705_update_inputs()
154153{
155   spdodgeb_state *state = machine.driver_data<spdodgeb_state>();
156154#define DBLTAP_TOLERANCE 5
157155
158156#define R 0x01
r20977r20978
166164
167165   for (p=0; p<=1; p++)
168166   {
169      curr_port[p] = state->ioport(p ? "P2" : "P1")->read();
167      curr_port[p] = ioport(p ? "P2" : "P1")->read();
170168      curr_dash[p] = 0;
171169
172170      if (curr_port[p] & R)
173171      {
174         if (!(state->m_last_port[p] & R))
172         if (!(m_last_port[p] & R))
175173         {
176            if (state->m_tapc[p]) curr_dash[p] |= R; else state->m_tapc[p] = DBLTAP_TOLERANCE;
174            if (m_tapc[p]) curr_dash[p] |= R; else m_tapc[p] = DBLTAP_TOLERANCE;
177175         }
178         else if (state->m_last_dash[p] & R) curr_dash[p] |= R;
176         else if (m_last_dash[p] & R) curr_dash[p] |= R;
179177      }
180178      else if (curr_port[p] & L)
181179      {
182         if (!(state->m_last_port[p] & L))
180         if (!(m_last_port[p] & L))
183181         {
184            if (state->m_tapc[p+2]) curr_dash[p] |= L; else state->m_tapc[p+2] = DBLTAP_TOLERANCE;
182            if (m_tapc[p+2]) curr_dash[p] |= L; else m_tapc[p+2] = DBLTAP_TOLERANCE;
185183         }
186         else if (state->m_last_dash[p] & L) curr_dash[p] |= L;
184         else if (m_last_dash[p] & L) curr_dash[p] |= L;
187185      }
188186
189      if (curr_port[p] & A && !(state->m_last_port[p] & A)) curr_dash[p] |= A;
190      if (curr_port[p] & D && !(state->m_last_port[p] & D)) curr_dash[p] |= D;
187      if (curr_port[p] & A && !(m_last_port[p] & A)) curr_dash[p] |= A;
188      if (curr_port[p] & D && !(m_last_port[p] & D)) curr_dash[p] |= D;
191189
192      state->m_last_port[p] = curr_port[p];
193      state->m_last_dash[p] = curr_dash[p];
190      m_last_port[p] = curr_port[p];
191      m_last_dash[p] = curr_dash[p];
194192
195      if (state->m_tapc[p  ]) state->m_tapc[p  ]--;
196      if (state->m_tapc[p+2]) state->m_tapc[p+2]--;
193      if (m_tapc[p  ]) m_tapc[p  ]--;
194      if (m_tapc[p+2]) m_tapc[p+2]--;
197195   }
198196
199   state->m_inputs[0] = curr_port[0] & 0xcf;
200   state->m_inputs[1] = curr_port[1] & 0x0f;
201   state->m_inputs[2] = curr_dash[0];
202   state->m_inputs[3] = curr_dash[1];
197   m_inputs[0] = curr_port[0] & 0xcf;
198   m_inputs[1] = curr_port[1] & 0x0f;
199   m_inputs[2] = curr_dash[0];
200   m_inputs[3] = curr_dash[1];
203201
204202#undef DBLTAP_TOLERANCE
205203#undef R
r20977r20978
229227{
230228//  logerror("CPU #0 PC %04x: write %02x to 63701 control address 3800\n",space.device().safe_pc(),data);
231229   m_mcu63701_command = data;
232   mcu63705_update_inputs(machine());
230   mcu63705_update_inputs();
233231}
234232
235233
trunk/src/mame/drivers/segag80v.c
r20977r20978
184184 *
185185 *************************************/
186186
187static offs_t decrypt_offset(address_space &space, offs_t offset)
187offs_t segag80v_state::decrypt_offset(address_space &space, offs_t offset)
188188{
189   segag80v_state *state = space.machine().driver_data<segag80v_state>();
190
191189   /* ignore anything but accesses via opcode $32 (LD $(XXYY),A) */
192190   offs_t pc = space.device().safe_pcbase();
193191   if ((UINT16)pc == 0xffff || space.read_byte(pc) != 0x32)
194192      return offset;
195193
196194   /* fetch the low byte of the address and munge it */
197   return (offset & 0xff00) | (*state->m_decrypt)(pc, space.read_byte(pc + 1));
195   return (offset & 0xff00) | (*m_decrypt)(pc, space.read_byte(pc + 1));
198196}
199197
200198WRITE8_MEMBER(segag80v_state::mainram_w)
r20977r20978
216214 *
217215 *************************************/
218216
219INLINE UINT8 demangle(UINT8 d7d6, UINT8 d5d4, UINT8 d3d2, UINT8 d1d0)
217inline UINT8 segag80v_state::demangle(UINT8 d7d6, UINT8 d5d4, UINT8 d3d2, UINT8 d1d0)
220218{
221219   return ((d7d6 << 7) & 0x80) | ((d7d6 << 2) & 0x40) |
222220         ((d5d4 << 5) & 0x20) | ((d5d4 << 0) & 0x10) |
trunk/src/mame/drivers/seta.c
r20977r20978
14121412/*------------------------------
14131413    initialize
14141414------------------------------*/
1415static void uPD71054_timer_init( running_machine &machine )
1415void seta_state::uPD71054_timer_init(  )
14161416{
1417   seta_state *state = machine.driver_data<seta_state>();
1418   uPD71054_state *uPD71054 = &state->m_uPD71054;
1417   uPD71054_state *uPD71054 = &m_uPD71054;
14191418   int no;
14201419
14211420   uPD71054->write_select = 0;
r20977r20978
14241423      uPD71054->max[no] = 0xffff;
14251424   }
14261425   for( no = 0; no < USED_TIMER_NUM; no++ ) {
1427      uPD71054->timer[no] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(seta_state::uPD71054_timer_callback),state));
1426      uPD71054->timer[no] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(seta_state::uPD71054_timer_callback),this));
14281427   }
14291428}
14301429
r20977r20978
17871786         machine().tilemap().mark_all_dirty();
17881787      m_tiles_offset = tiles_offset;
17891788
1790      seta_coin_lockout_w(machine(), data);
1789      seta_coin_lockout_w(data);
17911790   }
17921791}
17931792
r20977r20978
30733072WRITE8_MEMBER(seta_state::sub_bankswitch_lockout_w)
30743073{
30753074   sub_bankswitch_w(space,offset,data);
3076   seta_coin_lockout_w(machine(), data);
3075   seta_coin_lockout_w(data);
30773076}
30783077
30793078
r20977r20978
81408139   device.execute().set_input_line(2, HOLD_LINE );
81418140}
81428141
8143MACHINE_START_MEMBER(seta_state,wrofaero){ uPD71054_timer_init(machine()); }
8142MACHINE_START_MEMBER(seta_state,wrofaero){ uPD71054_timer_init(); }
81448143#endif  // __uPD71054_TIMER
81458144
81468145
trunk/src/mame/drivers/spy.c
r20977r20978
160160   membank("bank1")->set_entry(bank);
161161}
162162
163static void spy_collision( running_machine &machine )
163void spy_state::spy_collision(  )
164164{
165165#define MAX_SPRITES 64
166166#define DEF_NEAR_PLANE 0x6400
167167#define NEAR_PLANE_ZOOM 0x0100
168168#define FAR_PLANE_ZOOM 0x0000
169169
170   spy_state *state = machine.driver_data<spy_state>();
171170   int op1, x1, w1, z1, d1, y1, h1;
172171   int op2, x2, w2, z2, d2, y2, h2;
173172   int mode, i, loopend, nearplane;
174173
175   mode = state->m_pmcram[0x1];
176   op1 = state->m_pmcram[0x2];
174   mode = m_pmcram[0x1];
175   op1 = m_pmcram[0x2];
177176   if (op1 == 1)
178177   {
179      x1 = (state->m_pmcram[0x3] << 8) + state->m_pmcram[0x4];
180      w1 = (state->m_pmcram[0x5] << 8) + state->m_pmcram[0x6];
181      z1 = (state->m_pmcram[0x7] << 8) + state->m_pmcram[0x8];
182      d1 = (state->m_pmcram[0x9] << 8) + state->m_pmcram[0xa];
183      y1 = (state->m_pmcram[0xb] << 8) + state->m_pmcram[0xc];
184      h1 = (state->m_pmcram[0xd] << 8) + state->m_pmcram[0xe];
178      x1 = (m_pmcram[0x3] << 8) + m_pmcram[0x4];
179      w1 = (m_pmcram[0x5] << 8) + m_pmcram[0x6];
180      z1 = (m_pmcram[0x7] << 8) + m_pmcram[0x8];
181      d1 = (m_pmcram[0x9] << 8) + m_pmcram[0xa];
182      y1 = (m_pmcram[0xb] << 8) + m_pmcram[0xc];
183      h1 = (m_pmcram[0xd] << 8) + m_pmcram[0xe];
185184
186185      for (i = 16; i < 14 * MAX_SPRITES + 2; i += 14)
187186      {
188         op2 = state->m_pmcram[i];
187         op2 = m_pmcram[i];
189188         if (op2 || mode == 0x0c)
190189         {
191            x2 = (state->m_pmcram[i + 0x1] << 8) + state->m_pmcram[i + 0x2];
192            w2 = (state->m_pmcram[i + 0x3] << 8) + state->m_pmcram[i + 0x4];
193            z2 = (state->m_pmcram[i + 0x5] << 8) + state->m_pmcram[i + 0x6];
194            d2 = (state->m_pmcram[i + 0x7] << 8) + state->m_pmcram[i + 0x8];
195            y2 = (state->m_pmcram[i + 0x9] << 8) + state->m_pmcram[i + 0xa];
196            h2 = (state->m_pmcram[i + 0xb] << 8) + state->m_pmcram[i + 0xc];
190            x2 = (m_pmcram[i + 0x1] << 8) + m_pmcram[i + 0x2];
191            w2 = (m_pmcram[i + 0x3] << 8) + m_pmcram[i + 0x4];
192            z2 = (m_pmcram[i + 0x5] << 8) + m_pmcram[i + 0x6];
193            d2 = (m_pmcram[i + 0x7] << 8) + m_pmcram[i + 0x8];
194            y2 = (m_pmcram[i + 0x9] << 8) + m_pmcram[i + 0xa];
195            h2 = (m_pmcram[i + 0xb] << 8) + m_pmcram[i + 0xc];
197196/*
198197    The mad scientist's laser truck has both a high sprite center and a small height value.
199198    It has to be measured from the ground to detect correctly.
r20977r20978
204203            // what other sprites fall into:
205204            if ((abs(x1 - x2) < w1 + w2) && (abs(z1 - z2) < d1 + d2) && (abs(y1 - y2) < h1 + h2))
206205            {
207               state->m_pmcram[0xf] = 0;
208               state->m_pmcram[i + 0xd] = 0;
206               m_pmcram[0xf] = 0;
207               m_pmcram[i + 0xd] = 0;
209208            }
210209            else
211               state->m_pmcram[i + 0xd] = 1;
210               m_pmcram[i + 0xd] = 1;
212211         }
213212      }
214213   }
r20977r20978
219218    the scale factors from the PMCU code. Plugging 0 and 0x100 to the far and near planes seems
220219    to do the trick though.
221220*/
222      loopend = (state->m_pmcram[0] << 8) + state->m_pmcram[1];
223      nearplane = (state->m_pmcram[2] << 8) + state->m_pmcram[3];
221      loopend = (m_pmcram[0] << 8) + m_pmcram[1];
222      nearplane = (m_pmcram[2] << 8) + m_pmcram[3];
224223
225224      // fail safe
226225      if (loopend > MAX_SPRITES)
r20977r20978
232231
233232      for (i = 4; i < loopend; i += 2)
234233      {
235         op2 = (state->m_pmcram[i] << 8) + state->m_pmcram[i + 1];
234         op2 = (m_pmcram[i] << 8) + m_pmcram[i + 1];
236235         op2 = (op2 * (NEAR_PLANE_ZOOM - FAR_PLANE_ZOOM)) / nearplane + FAR_PLANE_ZOOM;
237         state->m_pmcram[i] = op2 >> 8;
238         state->m_pmcram[i + 1] = op2 & 0xff;
236         m_pmcram[i] = op2 >> 8;
237         m_pmcram[i + 1] = op2 & 0xff;
239238      }
240239
241      memset(state->m_pmcram + loopend, 0, 0x800 - loopend); // clean up for next frame
240      memset(m_pmcram + loopend, 0, 0x800 - loopend); // clean up for next frame
242241   }
243242}
244243
r20977r20978
317316            logerror("\n");
318317         }
319318      }
320      spy_collision(machine());
319      spy_collision();
321320//ZT
322321      m_maincpu->set_input_line(M6809_FIRQ_LINE, HOLD_LINE);
323322   }
trunk/src/mame/drivers/spacefb.c
r20977r20978
143143}
144144
145145
146static void create_interrupt_timer(running_machine &machine)
146void spacefb_state::create_interrupt_timer()
147147{
148   spacefb_state *state = machine.driver_data<spacefb_state>();
149   state->m_interrupt_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(spacefb_state::interrupt_callback),state));
148   m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(spacefb_state::interrupt_callback),this));
150149}
151150
152151
153static void start_interrupt_timer(running_machine &machine)
152void spacefb_state::start_interrupt_timer()
154153{
155   spacefb_state *state = machine.driver_data<spacefb_state>();
156   state->m_interrupt_timer->adjust(machine.primary_screen->time_until_pos(SPACEFB_INT_TRIGGER_COUNT_1));
154   m_interrupt_timer->adjust(machine().primary_screen->time_until_pos(SPACEFB_INT_TRIGGER_COUNT_1));
157155}
158156
159157
r20977r20978
166164
167165void spacefb_state::machine_start()
168166{
169   create_interrupt_timer(machine());
167   create_interrupt_timer();
170168}
171169
172170
r20977r20978
185183   spacefb_port_1_w(space, 0, 0);
186184   spacefb_port_2_w(space, 0, 0);
187185
188   start_interrupt_timer(machine());
186   start_interrupt_timer();
189187}
190188
191189
trunk/src/mame/drivers/ssv.c
r20977r20978
295295      coin_counter_w(machine(), 1, data & 0x04);
296296      coin_counter_w(machine(), 0, data & 0x08);
297297//                        data & 0x40?
298      ssv_enable_video( machine(), data & 0x80);
298      ssv_enable_video(data & 0x80);
299299   }
300300}
301301
r20977r20978
310310      coin_counter_w(machine(), 1, data & 0x04);
311311      coin_counter_w(machine(), 0, data & 0x08);
312312//                        data & 0x40?
313      ssv_enable_video( machine(), data & 0x80);
313      ssv_enable_video(data & 0x80);
314314   }
315315}
316316
r20977r20978
25082508
25092509***************************************************************************/
25102510
2511static void init_ssv(running_machine &machine, int interrupt_ultrax)
2511void ssv_state::init_ssv(int interrupt_ultrax)
25122512{
2513   ssv_state *state = machine.driver_data<ssv_state>();
25142513   int i;
25152514   for (i = 0; i < 16; i++)
2516      state->m_tile_code[i]   =   ( (i & 8) ? (1 << 16) : 0 ) +
2515      m_tile_code[i]   =   ( (i & 8) ? (1 << 16) : 0 ) +
25172516                        ( (i & 4) ? (2 << 16) : 0 ) +
25182517                        ( (i & 2) ? (4 << 16) : 0 ) +
25192518                        ( (i & 1) ? (8 << 16) : 0 ) ;
2520   ssv_enable_video(machine, 1);
2521   state->m_interrupt_ultrax = interrupt_ultrax;
2519   ssv_enable_video(1);
2520   m_interrupt_ultrax = interrupt_ultrax;
25222521}
25232522
2524static void init_hypreac2_common(running_machine &machine)
2523void ssv_state::init_hypreac2_common()
25252524{
2526   ssv_state *state = machine.driver_data<ssv_state>();
25272525   int i;
25282526
25292527   for (i = 0; i < 16; i++)
2530      state->m_tile_code[i]   =   (i << 16);
2528      m_tile_code[i]   =   (i << 16);
25312529}
25322530
25332531// massages the data from the BPMicro-compatible dump to runnable form
2534static void init_st010(running_machine &machine)
2532void ssv_state::init_st010()
25352533{
2536   UINT8 *dspsrc = (UINT8 *)machine.root_device().memregion("st010")->base();
2537   UINT32 *dspprg = (UINT32 *)machine.root_device().memregion("dspprg")->base();
2538   UINT16 *dspdata = (UINT16 *)machine.root_device().memregion("dspdata")->base();
2534   UINT8 *dspsrc = (UINT8 *)machine().root_device().memregion("st010")->base();
2535   UINT32 *dspprg = (UINT32 *)machine().root_device().memregion("dspprg")->base();
2536   UINT16 *dspdata = (UINT16 *)machine().root_device().memregion("dspdata")->base();
25392537
25402538   // copy DSP program
25412539   for (int i = 0; i < 0x10000; i+= 4)
r20977r20978
25512549   }
25522550}
25532551
2554DRIVER_INIT_MEMBER(ssv_state,drifto94)     {    init_ssv(machine(), 0); init_st010(machine());  }
2555DRIVER_INIT_MEMBER(ssv_state,eaglshot)     {    init_ssv(machine(), 0); init_hypreac2_common(machine());    }
2556DRIVER_INIT_MEMBER(ssv_state,gdfs)         {    init_ssv(machine(), 0); }
2557DRIVER_INIT_MEMBER(ssv_state,hypreact)     {    init_ssv(machine(), 0); }
2558DRIVER_INIT_MEMBER(ssv_state,hypreac2)     {    init_ssv(machine(), 0); init_hypreac2_common(machine());    }
2559DRIVER_INIT_MEMBER(ssv_state,janjans1)     {    init_ssv(machine(), 0); }
2560DRIVER_INIT_MEMBER(ssv_state,keithlcy)     {    init_ssv(machine(), 0); }
2561DRIVER_INIT_MEMBER(ssv_state,meosism)       {   init_ssv(machine(), 0); }
2562DRIVER_INIT_MEMBER(ssv_state,mslider)       {   init_ssv(machine(), 0); }
2563DRIVER_INIT_MEMBER(ssv_state,ryorioh)       {   init_ssv(machine(), 0); }
2564DRIVER_INIT_MEMBER(ssv_state,srmp4)        {    init_ssv(machine(), 0);
2552DRIVER_INIT_MEMBER(ssv_state,drifto94)     {    init_ssv(0); init_st010();  }
2553DRIVER_INIT_MEMBER(ssv_state,eaglshot)     {    init_ssv(0); init_hypreac2_common();    }
2554DRIVER_INIT_MEMBER(ssv_state,gdfs)         {    init_ssv(0); }
2555DRIVER_INIT_MEMBER(ssv_state,hypreact)     {    init_ssv(0); }
2556DRIVER_INIT_MEMBER(ssv_state,hypreac2)     {    init_ssv(0); init_hypreac2_common();    }
2557DRIVER_INIT_MEMBER(ssv_state,janjans1)     {    init_ssv(0); }
2558DRIVER_INIT_MEMBER(ssv_state,keithlcy)     {    init_ssv(0); }
2559DRIVER_INIT_MEMBER(ssv_state,meosism)       {   init_ssv(0); }
2560DRIVER_INIT_MEMBER(ssv_state,mslider)       {   init_ssv(0); }
2561DRIVER_INIT_MEMBER(ssv_state,ryorioh)       {   init_ssv(0); }
2562DRIVER_INIT_MEMBER(ssv_state,srmp4)        {    init_ssv(0);
25652563//  ((UINT16 *)machine().root_device().memregion("user1")->base())[0x2b38/2] = 0x037a;   /* patch to see gal test mode */
25662564}
2567DRIVER_INIT_MEMBER(ssv_state,srmp7)        {    init_ssv(machine(), 0); }
2568DRIVER_INIT_MEMBER(ssv_state,stmblade)     {    init_ssv(machine(), 0); init_st010(machine()); }
2569DRIVER_INIT_MEMBER(ssv_state,survarts)     {    init_ssv(machine(), 0); }
2570DRIVER_INIT_MEMBER(ssv_state,dynagear)     {    init_ssv(machine(), 0); }
2571DRIVER_INIT_MEMBER(ssv_state,sxyreact)     {    init_ssv(machine(), 0); init_hypreac2_common(machine());    }
2572DRIVER_INIT_MEMBER(ssv_state,cairblad)     {    init_ssv(machine(), 0); init_hypreac2_common(machine());    }
2573DRIVER_INIT_MEMBER(ssv_state,sxyreac2)     {    init_ssv(machine(), 0); init_hypreac2_common(machine());    }
2574DRIVER_INIT_MEMBER(ssv_state,twineag2)     {    init_ssv(machine(), 1); init_st010(machine());  }
2575DRIVER_INIT_MEMBER(ssv_state,ultrax)        {   init_ssv(machine(), 1); }
2576DRIVER_INIT_MEMBER(ssv_state,vasara)        {   init_ssv(machine(), 0); }
2577DRIVER_INIT_MEMBER(ssv_state,jsk)          {    init_ssv(machine(), 0); }
2565DRIVER_INIT_MEMBER(ssv_state,srmp7)        {    init_ssv(0); }
2566DRIVER_INIT_MEMBER(ssv_state,stmblade)     {    init_ssv(0); init_st010(); }
2567DRIVER_INIT_MEMBER(ssv_state,survarts)     {    init_ssv(0); }
2568DRIVER_INIT_MEMBER(ssv_state,dynagear)     {    init_ssv(0); }
2569DRIVER_INIT_MEMBER(ssv_state,sxyreact)     {    init_ssv(0); init_hypreac2_common();    }
2570DRIVER_INIT_MEMBER(ssv_state,cairblad)     {    init_ssv(0); init_hypreac2_common();    }
2571DRIVER_INIT_MEMBER(ssv_state,sxyreac2)     {    init_ssv(0); init_hypreac2_common();    }
2572DRIVER_INIT_MEMBER(ssv_state,twineag2)     {    init_ssv(1); init_st010();  }
2573DRIVER_INIT_MEMBER(ssv_state,ultrax)        {   init_ssv(1); }
2574DRIVER_INIT_MEMBER(ssv_state,vasara)        {   init_ssv(0); }
2575DRIVER_INIT_MEMBER(ssv_state,jsk)          {    init_ssv(0); }
25782576
25792577
25802578static MACHINE_CONFIG_START( ssv, ssv_state )
trunk/src/mame/drivers/snk6502.c
r20977r20978
303303   m_sasuke_counter += 0x10;
304304}
305305
306static void sasuke_start_counter(running_machine &machine)
306void snk6502_state::sasuke_start_counter()
307307{
308   snk6502_state *state = machine.driver_data<snk6502_state>();
309308
310   state->m_sasuke_counter = 0;
309   m_sasuke_counter = 0;
311310}
312311
313312
r20977r20978
784783   // adjusted (measured through audio recording of pcb)
785784   snk6502_set_music_freq(machine(), 35300);
786785
787   sasuke_start_counter(machine());
786   sasuke_start_counter();
788787}
789788
790789MACHINE_RESET_MEMBER(snk6502_state,satansat)
r20977r20978
793792   // NOTE: this was set before sasuke was adjusted to a lower freq, please don't modify until measured/confirmed on pcb
794793   snk6502_set_music_freq(machine(), 38000);
795794
796   sasuke_start_counter(machine());
795   sasuke_start_counter();
797796}
798797
799798MACHINE_RESET_MEMBER(snk6502_state,vanguard)
trunk/src/mame/drivers/snowbros.c
r20977r20978
405405   return 0x0003;
406406}
407407
408static void sb3_play_music(running_machine &machine, int data)
408void snowbros_state::sb3_play_music(int data)
409409{
410   snowbros_state *state = machine.driver_data<snowbros_state>();
411410   UINT8 *snd;
412411
413412   /* sample is actually played in interrupt function so it loops */
414   state->m_sb3_music = data;
413   m_sb3_music = data;
415414
416415   switch (data)
417416   {
418417      case 0x23:
419418      case 0x26:
420      snd = state->memregion("oki")->base();
419      snd = memregion("oki")->base();
421420      memcpy(snd+0x20000, snd+0x80000+0x00000, 0x20000);
422      state->m_sb3_music_is_playing = 1;
421      m_sb3_music_is_playing = 1;
423422      break;
424423
425424      case 0x24:
426      snd = state->memregion("oki")->base();
425      snd = memregion("oki")->base();
427426      memcpy(snd+0x20000, snd+0x80000+0x20000, 0x20000);
428      state->m_sb3_music_is_playing = 1;
427      m_sb3_music_is_playing = 1;
429428      break;
430429
431430      case 0x25:
r20977r20978
436435      case 0x2b:
437436      case 0x2c:
438437      case 0x2d:
439      snd = state->memregion("oki")->base();
438      snd = memregion("oki")->base();
440439      memcpy(snd+0x20000, snd+0x80000+0x40000, 0x20000);
441      state->m_sb3_music_is_playing = 1;
440      m_sb3_music_is_playing = 1;
442441      break;
443442
444443      case 0x2e:
445      state->m_sb3_music_is_playing = 0;
444      m_sb3_music_is_playing = 0;
446445      break;
447446   }
448447}
449448
450static void sb3_play_sound (okim6295_device *oki, int data)
449void snowbros_state::sb3_play_sound (okim6295_device *oki, int data)
451450{
452451   int status = oki->read_status();
453452
r20977r20978
490489
491490      if (data>=0x22 && data<=0x31)
492491      {
493         sb3_play_music(machine(), data);
492         sb3_play_music(data);
494493      }
495494
496495      if ((data>=0x30) && (data<=0x51))
r20977r20978
500499
501500      if (data>=0x52 && data<=0x5f)
502501      {
503         sb3_play_music(machine(), data-0x30);
502         sb3_play_music(data-0x30);
504503      }
505504
506505   }
trunk/src/mame/drivers/segas32.c
r20977r20978
374374 *
375375 *************************************/
376376
377static void signal_v60_irq(running_machine &machine, int data);
378377static void signal_sound_irq(running_machine &machine, int which);
379378
380379
r20977r20978
406405 *
407406 *************************************/
408407
409static void update_irq_state(running_machine &machine)
408void segas32_state::update_irq_state()
410409{
411   segas32_state *state = machine.driver_data<segas32_state>();
412   UINT8 effirq = state->m_v60_irq_control[7] & ~state->m_v60_irq_control[6] & 0x1f;
410   UINT8 effirq = m_v60_irq_control[7] & ~m_v60_irq_control[6] & 0x1f;
413411   int vector;
414412
415413   /* loop over interrupt vectors, finding the highest priority one with */
r20977r20978
417415   for (vector = 0; vector < 5; vector++)
418416      if (effirq & (1 << vector))
419417      {
420         machine.device("maincpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, vector);
418         machine().device("maincpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, vector);
421419         break;
422420      }
423421
424422   /* if we didn't find any, clear the interrupt line */
425423   if (vector == 5)
426      machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
424      machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
427425}
428426
429427
430static void signal_v60_irq(running_machine &machine, int which)
428void segas32_state::signal_v60_irq(int which)
431429{
432   segas32_state *state = machine.driver_data<segas32_state>();
433430   int i;
434431
435432   /* see if this interrupt input is mapped to any vectors; if so, mark them */
436433   for (i = 0; i < 5; i++)
437      if (state->m_v60_irq_control[i] == which)
438         state->m_v60_irq_control[7] |= 1 << i;
439   update_irq_state(machine);
434      if (m_v60_irq_control[i] == which)
435         m_v60_irq_control[7] |= 1 << i;
436   update_irq_state();
440437}
441438
442439
443440TIMER_DEVICE_CALLBACK_MEMBER(segas32_state::signal_v60_irq_callback)
444441{
445   signal_v60_irq(machine(), param);
442   signal_v60_irq(param);
446443}
447444
448445
449static void int_control_w(address_space &space, int offset, UINT8 data)
446void segas32_state::int_control_w(address_space &space, int offset, UINT8 data)
450447{
451   segas32_state *state = space.machine().driver_data<segas32_state>();
452448   int duration;
453449
454450//  logerror("%06X:int_control_w(%X) = %02X\n", space.device().safe_pc(), offset, data);
r20977r20978
459455      case 2:
460456      case 3:
461457      case 4:         /* vectors */
462         state->m_v60_irq_control[offset] = data;
458         m_v60_irq_control[offset] = data;
463459         break;
464460
465461      case 5:         /* unknown */
466         state->m_v60_irq_control[offset] = data;
462         m_v60_irq_control[offset] = data;
467463         break;
468464
469465      case 6:         /* mask */
470         state->m_v60_irq_control[offset] = data;
471         update_irq_state(space.machine());
466         m_v60_irq_control[offset] = data;
467         update_irq_state();
472468         break;
473469
474470      case 7:         /* acknowledge */
475         state->m_v60_irq_control[offset] &= data;
476         update_irq_state(space.machine());
471         m_v60_irq_control[offset] &= data;
472         update_irq_state();
477473         break;
478474
479475      case 8:
480476      case 9:         /* timer 0 count */
481         state->m_v60_irq_control[offset] = data;
482         duration = state->m_v60_irq_control[8] + ((state->m_v60_irq_control[9] << 8) & 0xf00);
477         m_v60_irq_control[offset] = data;
478         duration = m_v60_irq_control[8] + ((m_v60_irq_control[9] << 8) & 0xf00);
483479         if (duration)
484480         {
485481            attotime period = attotime::from_hz(TIMER_0_CLOCK) * duration;
486            state->m_v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0);
482            m_v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0);
487483         }
488484         break;
489485
490486      case 10:
491487      case 11:        /* timer 1 count */
492         state->m_v60_irq_control[offset] = data;
493         duration = state->m_v60_irq_control[10] + ((state->m_v60_irq_control[11] << 8) & 0xf00);
488         m_v60_irq_control[offset] = data;
489         duration = m_v60_irq_control[10] + ((m_v60_irq_control[11] << 8) & 0xf00);
494490         if (duration)
495491         {
496492            attotime period = attotime::from_hz(TIMER_1_CLOCK) * duration;
497            state->m_v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1);
493            m_v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1);
498494         }
499495         break;
500496
r20977r20978
502498      case 13:
503499      case 14:
504500      case 15:        /* signal IRQ to sound CPU */
505         signal_sound_irq(space.machine(), SOUND_IRQ_V60);
501         signal_sound_irq(machine(),SOUND_IRQ_V60);
506502         break;
507503   }
508504}
r20977r20978
564560
565561TIMER_CALLBACK_MEMBER(segas32_state::end_of_vblank_int)
566562{
567   signal_v60_irq(machine(), MAIN_IRQ_VBSTOP);
568   system32_set_vblank(machine(), 0);
563   signal_v60_irq(MAIN_IRQ_VBSTOP);
564   system32_set_vblank(0);
569565}
570566
571567
572568INTERRUPT_GEN_MEMBER(segas32_state::start_of_vblank_int)
573569{
574   signal_v60_irq(machine(), MAIN_IRQ_VBSTART);
575   system32_set_vblank(machine(), 1);
570   signal_v60_irq(MAIN_IRQ_VBSTART);
571   system32_set_vblank(1);
576572   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0), timer_expired_delegate(FUNC(segas32_state::end_of_vblank_int),this));
577573   if (m_system32_prot_vblank)
578574      (*m_system32_prot_vblank)(&device);
r20977r20978
586582 *
587583 *************************************/
588584
589static UINT16 common_io_chip_r(address_space &space, int which, offs_t offset, UINT16 mem_mask)
585UINT16 segas32_state::common_io_chip_r(address_space &space, int which, offs_t offset, UINT16 mem_mask)
590586{
591   segas32_state *state = space.machine().driver_data<segas32_state>();
592587   static const char *const portnames[2][8] =
593588         {
594589            { "P1_A", "P2_A", "PORTC_A", "PORTD_A", "SERVICE12_A", "SERVICE34_A", "PORTG_A", "PORTH_A" },
r20977r20978
608603      case 0x0c/2:
609604      case 0x0e/2:
610605         /* if the port is configured as an output, return the last thing written */
611         if (state->m_misc_io_data[which][0x1e/2] & (1 << offset))
612            return state->m_misc_io_data[which][offset];
606         if (m_misc_io_data[which][0x1e/2] & (1 << offset))
607            return m_misc_io_data[which][offset];
613608
614609         /* otherwise, return an input port */
615         return state->ioport(portnames[which][offset])->read_safe(0xffff);
610         return ioport(portnames[which][offset])->read_safe(0xffff);
616611
617612      /* 'SEGA' protection */
618613      case 0x10/2:
r20977r20978
627622      /* CNT register & mirror */
628623      case 0x18/2:
629624      case 0x1c/2:
630         return state->m_misc_io_data[which][0x1c/2];
625         return m_misc_io_data[which][0x1c/2];
631626
632627      /* port direction register & mirror */
633628      case 0x1a/2:
634629      case 0x1e/2:
635         return state->m_misc_io_data[which][0x1e/2];
630         return m_misc_io_data[which][0x1e/2];
636631   }
637632   return 0xffff;
638633}
639634
640635
641static void common_io_chip_w(address_space &space, int which, offs_t offset, UINT16 data, UINT16 mem_mask)
636void segas32_state::common_io_chip_w(address_space &space, int which, offs_t offset, UINT16 data, UINT16 mem_mask)
642637{
643   segas32_state *state = space.machine().driver_data<segas32_state>();
644638//  UINT8 old;
645639
646640   /* only LSB matters */
r20977r20978
649643
650644   /* generic implementation */
651645   offset &= 0x1f/2;
652//  old = state->m_misc_io_data[which][offset];
653   state->m_misc_io_data[which][offset] = data;
646//  old = m_misc_io_data[which][offset];
647   m_misc_io_data[which][offset] = data;
654648
655649   switch (offset)
656650   {
r20977r20978
661655      case 0x08/2:
662656      case 0x0a/2:
663657      case 0x0c/2:
664         if (state->m_sw2_output)
665            state->m_sw2_output(which, data);
658         if (m_sw2_output)
659            (this->*m_sw2_output)(which, data);
666660         break;
667661
668662      /* miscellaneous output */
669663      case 0x06/2:
670         if (state->m_sw1_output)
671            state->m_sw1_output(which, data);
664         if (m_sw1_output)
665            (this->*m_sw1_output)(which, data);
672666
673667         if (which == 0)
674668         {
r20977r20978
686680      /* tile banking */
687681      case 0x0e/2:
688682         if (which == 0)
689            state->m_system32_tilebank_external = data;
683            m_system32_tilebank_external = data;
690684         else
691685         {
692686            /* multi-32 EEPROM access */
r20977r20978
699693
700694      /* CNT register */
701695      case 0x1c/2:
702         state->m_system32_displayenable[which] = (data & 0x02);
696         m_system32_displayenable[which] = (data & 0x02);
703697         if (which == 0)
704698            space.machine().device("soundcpu")->execute().set_input_line(INPUT_LINE_RESET, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE);
705699         break;
r20977r20978
801795   {
802796      /* harddunk uses bits 4,5 for output lamps */
803797      if (m_sw3_output)
804         m_sw3_output(0, data & 0xff);
798         (this->*m_sw3_output)(0, data & 0xff);
805799
806800      if (!m_custom_io_w[0].isnull())
807801         (m_custom_io_w[0])(space, offset*2+0, data, mem_mask);
r20977r20978
10431037 *
10441038 *************************************/
10451039
1046static void update_sound_irq_state(running_machine &machine)
1040void segas32_state::update_sound_irq_state()
10471041{
1048   segas32_state *state = machine.driver_data<segas32_state>();
1049   UINT8 effirq = state->m_sound_irq_input & ~state->m_sound_irq_control[3] & 0x07;
1042   UINT8 effirq = m_sound_irq_input & ~m_sound_irq_control[3] & 0x07;
10501043   int vector;
10511044
10521045   /* loop over interrupt vectors, finding the highest priority one with */
r20977r20978
10541047   for (vector = 0; vector < 3; vector++)
10551048      if (effirq & (1 << vector))
10561049      {
1057         machine.device("soundcpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, 2 * vector);
1050         machine().device("soundcpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, 2 * vector);
10581051         break;
10591052      }
10601053
10611054   /* if we didn't find any, clear the interrupt line */
10621055   if (vector == 3)
1063      machine.device("soundcpu")->execute().set_input_line(0, CLEAR_LINE);
1056      machine().device("soundcpu")->execute().set_input_line(0, CLEAR_LINE);
10641057}
10651058
10661059
r20977r20978
10731066   for (i = 0; i < 3; i++)
10741067      if (state->m_sound_irq_control[i] == which)
10751068         state->m_sound_irq_input |= 1 << i;
1076   update_sound_irq_state(machine);
1069   state->update_sound_irq_state();
10771070}
10781071
10791072
r20977r20978
10841077   for (i = 0; i < 3; i++)
10851078      if (state->m_sound_irq_control[i] == which)
10861079         state->m_sound_irq_input &= ~(1 << i);
1087   update_sound_irq_state(machine);
1080   state->update_sound_irq_state();
10881081}
10891082
10901083
r20977r20978
10941087   if (offset & 1)
10951088   {
10961089      m_sound_irq_input &= data;
1097      update_sound_irq_state(machine());
1090      update_sound_irq_state();
10981091   }
10991092
11001093   /* high offsets signal an IRQ to the v60 */
11011094   if (offset & 4)
1102      signal_v60_irq(machine(), MAIN_IRQ_SOUND);
1095      signal_v60_irq(MAIN_IRQ_SOUND);
11031096}
11041097
11051098
11061099WRITE8_MEMBER(segas32_state::sound_int_control_hi_w)
11071100{
11081101   m_sound_irq_control[offset] = data;
1109   update_sound_irq_state(machine());
1102   update_sound_irq_state();
11101103}
11111104
11121105
r20977r20978
40264019 *
40274020 *************************************/
40284021
4029static void segas32_common_init(running_machine &machine, read16_delegate custom_r, write16_delegate custom_w)
4022void segas32_state::segas32_common_init(read16_delegate custom_r, write16_delegate custom_w)
40304023{
4031   segas32_state *state = machine.driver_data<segas32_state>();
40324024   /* reset the custom handlers and other pointers */
4033   state->m_custom_io_r[0] = custom_r;
4034   state->m_custom_io_w[0] = custom_w;
4035   state->m_system32_prot_vblank = NULL;
4036   state->m_sw1_output = NULL;
4037   state->m_sw2_output = NULL;
4038   state->m_sw3_output = NULL;
4025   m_custom_io_r[0] = custom_r;
4026   m_custom_io_w[0] = custom_w;
4027   m_system32_prot_vblank = NULL;
4028   m_sw1_output = NULL;
4029   m_sw2_output = NULL;
4030   m_sw3_output = NULL;
40394031}
40404032
40414033
r20977r20978
40534045 *      switches we need to fix
40544046 *************************************/
40554047
4056static void radm_sw1_output( int which, UINT16 data )
4048void segas32_state::radm_sw1_output( int which, UINT16 data )
40574049{
40584050   if (which == 0)
40594051      output_set_value("Start_lamp", BIT(data, 2));
40604052}
40614053
4062static void radm_sw2_output( int which, UINT16 data )
4054void segas32_state::radm_sw2_output( int which, UINT16 data )
40634055{
40644056   if (which == 0)
40654057   {
r20977r20978
40684060   }
40694061}
40704062
4071static void radr_sw2_output( int which, UINT16 data )
4063void segas32_state::radr_sw2_output( int which, UINT16 data )
40724064{
40734065   if (which == 0)
40744066   {
r20977r20978
40774069   }
40784070}
40794071
4080static void alien3_sw1_output( int which, UINT16 data )
4072void segas32_state::alien3_sw1_output( int which, UINT16 data )
40814073{
40824074   if (which == 0)
40834075   {
r20977r20978
40864078   }
40874079}
40884080
4089static void arescue_sw1_output( int which, UINT16 data )
4081void segas32_state::arescue_sw1_output( int which, UINT16 data )
40904082{
40914083   if (which == 0)
40924084   {
r20977r20978
40954087   }
40964088}
40974089
4098static void f1lap_sw1_output( int which, UINT16 data )
4090void segas32_state::f1lap_sw1_output( int which, UINT16 data )
40994091{
41004092   if (which == 0)
41014093   {
r20977r20978
41044096   }
41054097}
41064098
4107static void jpark_sw1_output( int which, UINT16 data )
4099void segas32_state::jpark_sw1_output( int which, UINT16 data )
41084100{
41094101   if (which == 0)
41104102   {
r20977r20978
41134105   }
41144106}
41154107
4116static void orunners_sw1_output( int which, UINT16 data )
4108void segas32_state::orunners_sw1_output( int which, UINT16 data )
41174109{
41184110   /* note ma = monitor A and mb = Monitor B */
41194111   if (which == 0)
r20977r20978
41304122   }
41314123}
41324124
4133static void orunners_sw2_output( int which, UINT16 data )
4125void segas32_state::orunners_sw2_output( int which, UINT16 data )
41344126{
41354127   /* note ma = monitor A and mb = Monitor B */
41364128   /* also note that the remaining bits are for the game's lcd display */
r20977r20978
41474139   }
41484140}
41494141
4150static void harddunk_sw1_output( int which, UINT16 data )
4142void segas32_state::harddunk_sw1_output( int which, UINT16 data )
41514143{
41524144   if (which == 0)
41534145   {
r20977r20978
41614153   }
41624154}
41634155
4164static void harddunk_sw2_output( int which, UINT16 data )
4156void segas32_state::harddunk_sw2_output( int which, UINT16 data )
41654157{
41664158   if (which == 0)
41674159      output_set_value("Left_Winner_lamp", BIT(data, 0));
r20977r20978
41694161      output_set_value("Right_Winner_lamp", BIT(data, 0));
41704162}
41714163
4172static void harddunk_sw3_output( int which, UINT16 data )
4164void segas32_state::harddunk_sw3_output( int which, UINT16 data )
41734165{
41744166   output_set_value("3P_Start_lamp", BIT(data, 4));
41754167   output_set_value("6P_Start_lamp", BIT(data, 5));
41764168}
41774169
4178static void titlef_sw1_output( int which, UINT16 data )
4170void segas32_state::titlef_sw1_output( int which, UINT16 data )
41794171{
41804172   if (which == 0)
41814173   {
r20977r20978
41894181   }
41904182}
41914183
4192static void titlef_sw2_output( int which, UINT16 data )
4184void segas32_state::titlef_sw2_output( int which, UINT16 data )
41934185{
41944186   if (which == 0)
41954187      output_set_value("Blue_Corner_lamp", BIT(data, 0));
r20977r20978
41974189      output_set_value("Red_Corner_lamp", BIT(data, 0));
41984190}
41994191
4200static void scross_sw1_output( int which, UINT16 data )
4192void segas32_state::scross_sw1_output( int which, UINT16 data )
42014193{
42024194   /* note ma = monitor A and mb = Monitor B */
42034195   if (which == 0)
r20977r20978
42064198      output_set_value("MB_Start_lamp", BIT(data, 2));
42074199}
42084200
4209static void scross_sw2_output( int which, UINT16 data )
4201void segas32_state::scross_sw2_output( int which, UINT16 data )
42104202{
42114203   /* Note:  I'm not an expert on digits, so I didn't know the right map to use, I just added it manually and it seems to work fine. */
42124204   if (which == 0)
r20977r20978
42234215
42244216DRIVER_INIT_MEMBER(segas32_state,alien3)
42254217{
4226   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4227   m_sw1_output = alien3_sw1_output;
4218   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4219   m_sw1_output = &segas32_state::alien3_sw1_output;
42284220}
42294221
42304222READ16_MEMBER(segas32_state::arescue_handshake_r)
r20977r20978
42394231
42404232DRIVER_INIT_MEMBER(segas32_state,arescue)
42414233{
4242   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4234   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
42434235   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa00000, 0xa00007, read16_delegate(FUNC(segas32_state::arescue_dsp_r),this), write16_delegate(FUNC(segas32_state::arescue_dsp_w),this));
42444236
42454237   m_dual_pcb_comms = auto_alloc_array(machine(), UINT16, 0x1000/2);
r20977r20978
42494241   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x810000, 0x810001, read16_delegate(FUNC(segas32_state::arescue_handshake_r),this));
42504242   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x81000e, 0x81000f, read16_delegate(FUNC(segas32_state::arescue_slavebusy_r),this));
42514243
4252   m_sw1_output = arescue_sw1_output;
4244   m_sw1_output = &segas32_state::arescue_sw1_output;
42534245}
42544246
42554247
42564248DRIVER_INIT_MEMBER(segas32_state,arabfgt)
42574249{
4258   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
4250   segas32_common_init(read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
42594251
42604252   /* install protection handlers */
42614253   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xa00100, 0xa0011f, read16_delegate(FUNC(segas32_state::arf_wakeup_protection_r),this));
r20977r20978
42654257
42664258DRIVER_INIT_MEMBER(segas32_state,brival)
42674259{
4268   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
4260   segas32_common_init(read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
42694261
42704262   /* install protection handlers */
42714263   m_system32_protram = auto_alloc_array(machine(), UINT16, 0x1000/2);
r20977r20978
42764268
42774269DRIVER_INIT_MEMBER(segas32_state,darkedge)
42784270{
4279   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
4271   segas32_common_init(read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
42804272
42814273   /* install protection handlers */
42824274   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa00000, 0xa7ffff, read16_delegate(FUNC(segas32_state::darkedge_protection_r),this), write16_delegate(FUNC(segas32_state::darkedge_protection_w),this));
r20977r20978
42854277
42864278DRIVER_INIT_MEMBER(segas32_state,dbzvrvs)
42874279{
4288   segas32_common_init(machine(), read16_delegate(), write16_delegate());
4280   segas32_common_init(read16_delegate(), write16_delegate());
42894281
42904282   /* install protection handlers */
42914283   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa00000, 0xa7ffff, read16_delegate(FUNC(segas32_state::dbzvrvs_protection_r),this), write16_delegate(FUNC(segas32_state::dbzvrvs_protection_w),this));
r20977r20978
43004292
43014293DRIVER_INIT_MEMBER(segas32_state,f1en)
43024294{
4303   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4295   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
43044296
43054297   m_dual_pcb_comms = auto_alloc_array(machine(), UINT16, 0x1000/2);
43064298   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x810000, 0x810fff, read16_delegate(FUNC(segas32_state::dual_pcb_comms_r),this), write16_delegate(FUNC(segas32_state::dual_pcb_comms_w),this));
r20977r20978
43084300
43094301   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x810048, 0x810049, write16_delegate(FUNC(segas32_state::f1en_comms_echo_w),this));
43104302
4311   m_sw1_output = radm_sw1_output;
4303   m_sw1_output = &segas32_state::radm_sw1_output;
43124304}
43134305
43144306
r20977r20978
43164308
43174309DRIVER_INIT_MEMBER(segas32_state,f1lap)
43184310{
4319   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4311   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
43204312
43214313   m_dual_pcb_comms = auto_alloc_array(machine(), UINT16, 0x1000/2);
43224314   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x800000, 0x800fff, read16_delegate(FUNC(segas32_state::dual_pcb_comms_r),this), write16_delegate(FUNC(segas32_state::dual_pcb_comms_w),this));
r20977r20978
43254317//  machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x800048, 0x800049, write16_delegate(FUNC(segas32_state::f1en_comms_echo_w),this));
43264318   m_system32_prot_vblank = f1lap_fd1149_vblank;
43274319
4328   m_sw1_output = f1lap_sw1_output;
4320   m_sw1_output = &segas32_state::f1lap_sw1_output;
43294321}
43304322
43314323
43324324DRIVER_INIT_MEMBER(segas32_state,ga2)
43334325{
4334   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
4326   segas32_common_init(read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
43354327
4336   decrypt_ga2_protrom(machine());
4328   decrypt_ga2_protrom();
43374329   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa00000, 0xa00fff, read16_delegate(FUNC(segas32_state::ga2_dpram_r),this), write16_delegate(FUNC(segas32_state::ga2_dpram_w),this));
43384330}
43394331
43404332
43414333DRIVER_INIT_MEMBER(segas32_state,harddunk)
43424334{
4343   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
4344   m_sw1_output = harddunk_sw1_output;
4345   m_sw2_output = harddunk_sw2_output;
4346   m_sw3_output = harddunk_sw3_output;
4335   segas32_common_init(read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
4336   m_sw1_output = &segas32_state::harddunk_sw1_output;
4337   m_sw2_output = &segas32_state::harddunk_sw2_output;
4338   m_sw3_output = &segas32_state::harddunk_sw3_output;
43474339}
43484340
43494341
43504342DRIVER_INIT_MEMBER(segas32_state,holo)
43514343{
4352   segas32_common_init(machine(), read16_delegate(), write16_delegate());
4344   segas32_common_init(read16_delegate(), write16_delegate());
43534345}
43544346
43554347
r20977r20978
43584350   /* Temp. Patch until we emulate the 'Drive Board', thanks to Malice */
43594351   UINT16 *pROM = (UINT16 *)memregion("maincpu")->base();
43604352
4361   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4353   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
43624354
43634355   pROM[0xC15A8/2] = 0xCD70;
43644356   pROM[0xC15AA/2] = 0xD8CD;
43654357
4366   m_sw1_output = jpark_sw1_output;
4358   m_sw1_output = &segas32_state::jpark_sw1_output;
43674359}
43684360
43694361
43704362DRIVER_INIT_MEMBER(segas32_state,orunners)
43714363{
4372   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::orunners_custom_io_w),this));
4373   m_sw1_output = orunners_sw1_output;
4374   m_sw2_output = orunners_sw2_output;
4364   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::orunners_custom_io_w),this));
4365   m_sw1_output = &segas32_state::orunners_sw1_output;
4366   m_sw2_output = &segas32_state::orunners_sw2_output;
43754367}
43764368
43774369
43784370DRIVER_INIT_MEMBER(segas32_state,radm)
43794371{
4380   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4381   m_sw1_output = radm_sw1_output;
4382   m_sw2_output = radm_sw2_output;
4372   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4373   m_sw1_output = &segas32_state::radm_sw1_output;
4374   m_sw2_output = &segas32_state::radm_sw2_output;
43834375}
43844376
43854377
43864378DRIVER_INIT_MEMBER(segas32_state,radr)
43874379{
4388   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4389   m_sw1_output = radm_sw1_output;
4390   m_sw2_output = radr_sw2_output;
4380   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4381   m_sw1_output = &segas32_state::radm_sw1_output;
4382   m_sw2_output = &segas32_state::radr_sw2_output;
43914383}
43924384
43934385
43944386DRIVER_INIT_MEMBER(segas32_state,scross)
43954387{
4396   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4388   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
43974389   machine().device("soundcpu")->memory().space(AS_PROGRAM).install_write_handler(0xb0, 0xbf, write8_delegate(FUNC(segas32_state::scross_bank_w),this));
43984390
4399   m_sw1_output = scross_sw1_output;
4400   m_sw2_output = scross_sw2_output;
4391   m_sw1_output = &segas32_state::scross_sw1_output;
4392   m_sw2_output = &segas32_state::scross_sw2_output;
44014393}
44024394
44034395
44044396DRIVER_INIT_MEMBER(segas32_state,slipstrm)
44054397{
4406   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
4398   segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::analog_custom_io_w),this));
44074399}
44084400
44094401
44104402DRIVER_INIT_MEMBER(segas32_state,sonic)
44114403{
4412   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::sonic_custom_io_r),this), write16_delegate(FUNC(segas32_state::sonic_custom_io_w),this));
4404   segas32_common_init(read16_delegate(FUNC(segas32_state::sonic_custom_io_r),this), write16_delegate(FUNC(segas32_state::sonic_custom_io_w),this));
44134405
44144406   /* install protection handlers */
44154407   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x20E5C4, 0x20E5C5, write16_delegate(FUNC(segas32_state::sonic_level_load_protection),this));
r20977r20978
44184410
44194411DRIVER_INIT_MEMBER(segas32_state,sonicp)
44204412{
4421   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::sonic_custom_io_r),this), write16_delegate(FUNC(segas32_state::sonic_custom_io_w),this));
4413   segas32_common_init(read16_delegate(FUNC(segas32_state::sonic_custom_io_r),this), write16_delegate(FUNC(segas32_state::sonic_custom_io_w),this));
44224414}
44234415
44244416
44254417DRIVER_INIT_MEMBER(segas32_state,spidman)
44264418{
4427   segas32_common_init(machine(), read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
4419   segas32_common_init(read16_delegate(FUNC(segas32_state::extra_custom_io_r),this), write16_delegate());
44284420}
44294421
44304422
44314423DRIVER_INIT_MEMBER(segas32_state,svf)
44324424{
4433   segas32_common_init(machine(), read16_delegate(), write16_delegate());
4425   segas32_common_init(read16_delegate(), write16_delegate());
44344426}
44354427
44364428
44374429DRIVER_INIT_MEMBER(segas32_state,jleague)
44384430{
4439   segas32_common_init(machine(), read16_delegate(), write16_delegate());
4431   segas32_common_init(read16_delegate(), write16_delegate());
44404432   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x20F700, 0x20F705, write16_delegate(FUNC(segas32_state::jleague_protection_w),this));
44414433}
44424434
44434435
44444436DRIVER_INIT_MEMBER(segas32_state,titlef)
44454437{
4446   segas32_common_init(machine(), read16_delegate(), write16_delegate());
4447   m_sw1_output = titlef_sw1_output;
4448   m_sw2_output = titlef_sw2_output;
4438   segas32_common_init(read16_delegate(), write16_delegate());
4439   m_sw1_output = &segas32_state::titlef_sw1_output;
4440   m_sw2_output = &segas32_state::titlef_sw2_output;
44494441}
44504442
44514443
trunk/src/mame/drivers/speedatk.c
r20977r20978
8282
8383#define MASTER_CLOCK XTAL_12MHz
8484
85static UINT8 iox_key_matrix_calc(running_machine &machine, UINT8 p_side)
85UINT8 speedatk_state::iox_key_matrix_calc(UINT8 p_side)
8686{
8787   static const char *const keynames[] = { "P1_ROW0", "P1_ROW1", "P2_ROW0", "P2_ROW1" };
8888
r20977r20978
9494
9595      for (t = 0 ; t < 8 ; t ++)
9696      {
97         if (!(machine.root_device().ioport(keynames[j+p_side])->read() & ( 1 << t )))
97         if (!(machine().root_device().ioport(keynames[j+p_side])->read() & ( 1 << t )))
9898         {
9999            return (i + t) | (p_side ? 0x20 : 0x00);
100100         }
r20977r20978
125125   /* both side checks */
126126   if(m_mux_data == 1)
127127   {
128      UINT8 p1_side = iox_key_matrix_calc(machine(),0);
129      UINT8 p2_side = iox_key_matrix_calc(machine(),2);
128      UINT8 p1_side = iox_key_matrix_calc(0);
129      UINT8 p2_side = iox_key_matrix_calc(2);
130130
131131      if(p1_side != 0)
132132         return p1_side;
r20977r20978
135135   }
136136
137137   /* check individual input side */
138   return iox_key_matrix_calc(machine(),(m_mux_data == 2) ? 0 : 2);
138   return iox_key_matrix_calc((m_mux_data == 2) ? 0 : 2);
139139}
140140
141141WRITE8_MEMBER(speedatk_state::key_matrix_w)
trunk/src/mame/drivers/splash.c
r20977r20978
142142}
143143
144144
145static void roldfrog_update_irq( running_machine &machine )
145void splash_state::roldfrog_update_irq(  )
146146{
147   splash_state * state = machine.driver_data<splash_state>();
148   int irq = (state->m_sound_irq ? 0x08 : 0) | ((state->m_vblank_irq) ? 0x18 : 0);
149   machine.device("audiocpu")->execute().set_input_line_and_vector(0, irq ? ASSERT_LINE : CLEAR_LINE, 0xc7 | irq);
147   int irq = (m_sound_irq ? 0x08 : 0) | ((m_vblank_irq) ? 0x18 : 0);
148   machine().device("audiocpu")->execute().set_input_line_and_vector(0, irq ? ASSERT_LINE : CLEAR_LINE, 0xc7 | irq);
150149}
151150
152151WRITE8_MEMBER(splash_state::roldfrog_vblank_ack_w)
153152{
154153   m_vblank_irq = 0;
155   roldfrog_update_irq(machine());
154   roldfrog_update_irq();
156155}
157156
158157
r20977r20978
160159{
161160   splash_state * driver_state = device->machine().driver_data<splash_state>();
162161   driver_state->m_sound_irq = state;
163   roldfrog_update_irq(device->machine());
162   driver_state->roldfrog_update_irq();
164163}
165164
166165static ADDRESS_MAP_START( roldfrog_map, AS_PROGRAM, 16, splash_state )
r20977r20978
538537INTERRUPT_GEN_MEMBER(splash_state::roldfrog_interrupt)
539538{
540539   m_vblank_irq = 1;
541   roldfrog_update_irq(machine());
540   roldfrog_update_irq();
542541}
543542
544543static MACHINE_CONFIG_START( roldfrog, splash_state )
trunk/src/mame/drivers/jclub2.c
r20977r20978
147147   UINT32 screen_update_jclub2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
148148   UINT32 screen_update_jclub2o(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
149149   TIMER_DEVICE_CALLBACK_MEMBER(darkhors_irq);
150   void draw_sprites_darkhors(bitmap_ind16 &bitmap, const rectangle &cliprect);
150151};
151152
152153
r20977r20978
189190   m_tmap2->mark_tile_dirty(offset);
190191}
191192
192static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
193void darkhors_state::draw_sprites_darkhors(bitmap_ind16 &bitmap, const rectangle &cliprect)
193194{
194   darkhors_state *state = machine.driver_data<darkhors_state>();
195   UINT32 *s       =   state->m_spriteram;
196   UINT32 *end     =   state->m_spriteram + 0x02000/4;
195   UINT32 *s       =   m_spriteram;
196   UINT32 *end     =   m_spriteram + 0x02000/4;
197197
198198   for ( ; s < end; s += 8/4 )
199199   {
r20977r20978
218218      sy  =   -sy;
219219      sy  +=  0xf8;
220220
221      drawgfx_transpen(   bitmap, cliprect, machine.gfx[0],
221      drawgfx_transpen(   bitmap, cliprect, machine().gfx[0],
222222               code/2, color,
223223               flipx,  flipy,  sx, sy, 0);
224224   }
r20977r20978
258258   m_tmap2->set_scrollx(0, (m_tmapscroll2[0] >> 16) - 5);
259259   m_tmap2->set_scrolly(0, (m_tmapscroll2[0] & 0xffff) - 0xff );
260260   if (layers_ctrl & 2)    m_tmap2->draw(bitmap, cliprect, 0, 0);
261   if (layers_ctrl & 4)    draw_sprites_darkhors(bitmap,cliprect);
261262
262   if (layers_ctrl & 4)    draw_sprites(machine(),bitmap,cliprect);
263263
264264#if DARKHORS_DEBUG
265265#if 0
trunk/src/mame/drivers/sshangha.c
r20977r20978
114114
115115/******************************************************************************/
116116
117INLINE void sshangha_set_color_888(running_machine &machine, pen_t color, int rshift, int gshift, int bshift, UINT32 data)
117inline void sshangha_state::sshangha_set_color_888(pen_t color, int rshift, int gshift, int bshift, UINT32 data)
118118{
119   palette_set_color_rgb(machine, color, (data >> rshift) & 0xff, (data >> gshift) & 0xff, (data >> bshift) & 0xff);
119   palette_set_color_rgb(machine(), color, (data >> rshift) & 0xff, (data >> gshift) & 0xff, (data >> bshift) & 0xff);
120120}
121121
122122
123123WRITE16_MEMBER(sshangha_state::paletteram16_xbgr_word_be_sprites2_w)
124124{
125125   COMBINE_DATA(&m_sprite_paletteram2[offset]);
126   sshangha_set_color_888(machine(), (offset/2)+0x100, 0, 8, 16, m_sprite_paletteram2[(offset) | 1] | (m_sprite_paletteram2[(offset) & ~1] << 16) );
126   sshangha_set_color_888((offset/2)+0x100, 0, 8, 16, m_sprite_paletteram2[(offset) | 1] | (m_sprite_paletteram2[(offset) & ~1] << 16) );
127127}
128128
129129WRITE16_MEMBER(sshangha_state::paletteram16_xbgr_word_be_sprites_w)
r20977r20978
136136   paletteram16_xbgr_word_be_sprites2_w(space,offset,data,mem_mask);
137137
138138   COMBINE_DATA(&m_sprite_paletteram[offset]);
139   sshangha_set_color_888(machine(), (offset/2)+0x000, 0, 8, 16, m_sprite_paletteram[(offset) | 1] | (m_sprite_paletteram[(offset) & ~1] << 16) );
139   sshangha_set_color_888((offset/2)+0x000, 0, 8, 16, m_sprite_paletteram[(offset) | 1] | (m_sprite_paletteram[(offset) & ~1] << 16) );
140140}
141141
142142WRITE16_MEMBER(sshangha_state::paletteram16_xbgr_word_be_tilelow_w)
143143{
144144   COMBINE_DATA(&m_tile_paletteram1[offset]);
145   sshangha_set_color_888(machine(), (offset/2)+0x200, 0, 8, 16, m_tile_paletteram1[(offset) | 1] | (m_tile_paletteram1[(offset) & ~1] << 16) );
145   sshangha_set_color_888((offset/2)+0x200, 0, 8, 16, m_tile_paletteram1[(offset) | 1] | (m_tile_paletteram1[(offset) & ~1] << 16) );
146146}
147147
148148WRITE16_MEMBER(sshangha_state::paletteram16_xbgr_word_be_tilehigh_w)
149149{
150150   COMBINE_DATA(&m_tile_paletteram2[offset]);
151   sshangha_set_color_888(machine(), (offset/2)+0x300, 0, 8, 16, m_tile_paletteram2[(offset) | 1] | (m_tile_paletteram2[(offset) & ~1] << 16) );
151   sshangha_set_color_888((offset/2)+0x300, 0, 8, 16, m_tile_paletteram2[(offset) | 1] | (m_tile_paletteram2[(offset) & ~1] << 16) );
152152}
153153
154154static ADDRESS_MAP_START( sshangha_map, AS_PROGRAM, 16, sshangha_state )
trunk/src/mame/machine/simpsons.c
r20977r20978
1919   ioport("EEPROMOUT")->write(data, 0xff);
2020
2121   m_video_bank = data & 0x03;
22   simpsons_video_banking(machine(), m_video_bank);
22   simpsons_video_banking(m_video_bank);
2323
2424   m_firq_enabled = data & 0x04;
2525}
r20977r20978
6868
6969void simpsons_state::simpsons_postload()
7070{
71   simpsons_video_banking(machine(), m_video_bank);
71   simpsons_video_banking(m_video_bank);
7272}
7373
7474void simpsons_state::machine_start()
r20977r20978
118118   membank("bank2")->configure_entries(2, 6, machine().root_device().memregion("audiocpu")->base() + 0x10000, 0x4000);
119119   membank("bank2")->set_entry(0);
120120
121   simpsons_video_banking(machine(), 0);
121   simpsons_video_banking(0);
122122}
trunk/src/mame/machine/segas32.c
r20977r20978
3333
3434#undef xxxx
3535
36void decrypt_ga2_protrom(running_machine &machine)
36void segas32_state::decrypt_ga2_protrom()
3737{
3838   int i;
39   UINT8 *rom = machine.root_device().memregion("mcu")->base();
40   UINT8* temp = auto_alloc_array(machine, UINT8, 0x100000);
39   UINT8 *rom = machine().root_device().memregion("mcu")->base();
40   UINT8* temp = auto_alloc_array(machine(), UINT8, 0x100000);
4141
4242   // make copy of ROM so original can be overwritten
4343   memcpy(temp, rom, 0x10000);
r20977r20978
4646   for(i = 0; i < 0x10000; i++)
4747      rom[i] = temp[BITSWAP16(i, 14, 11, 15, 12, 13, 4, 3, 7, 5, 10, 2, 8, 9, 6, 1, 0)];
4848
49   auto_free(machine, temp);
49   auto_free(machine(), temp);
5050}
5151
5252WRITE16_MEMBER(segas32_state::ga2_dpram_w)
trunk/src/mame/machine/scramble.c
r20977r20978
101101
102102
103103
104static void cavelon_banksw(running_machine &machine)
104void scramble_state::cavelon_banksw()
105105{
106   scramble_state *state = machine.driver_data<scramble_state>();
107106   /* any read/write access in the 0x8000-0xffff region causes a bank switch.
108107      Only the lower 0x2000 is switched but we switch the whole region
109108      to keep the CPU core happy at the boundaries */
110109
111   state->m_cavelon_bank = !state->m_cavelon_bank;
112   state->membank("bank1")->set_entry(state->m_cavelon_bank);
110   m_cavelon_bank = !m_cavelon_bank;
111   membank("bank1")->set_entry(m_cavelon_bank);
113112}
114113
115114static READ8_HANDLER( cavelon_banksw_r )
116115{
117116   scramble_state *state = space.machine().driver_data<scramble_state>();
118   cavelon_banksw(space.machine());
117   state->cavelon_banksw();
119118
120119   if ((offset >= 0x0100) && (offset <= 0x0103))
121120      return state->m_ppi8255_0->read(space, offset - 0x0100);
r20977r20978
128127static WRITE8_HANDLER( cavelon_banksw_w )
129128{
130129   scramble_state *state = space.machine().driver_data<scramble_state>();
131   cavelon_banksw(space.machine());
130   state->cavelon_banksw();
132131
133132   if ((offset >= 0x0100) && (offset <= 0x0103))
134133      state->m_ppi8255_0->write(space, offset - 0x0100, data);
r20977r20978
277276   /* banked ROM */
278277   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x0000, 0x3fff, "bank1");
279278   membank("bank1")->configure_entries(0, 2, &ROM[0x00000], 0x10000);
280   cavelon_banksw(machine());
279   cavelon_banksw();
281280
282281   /* A15 switches memory banks */
283282   machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x8000, 0xffff, FUNC(cavelon_banksw_r), FUNC(cavelon_banksw_w));
r20977r20978
341340}
342341
343342
344INLINE int bit(int i,int n)
343inline int scramble_state::bit(int i,int n)
345344{
346345   return ((i >> n) & 1);
347346}
trunk/src/mame/machine/subs.c
r20977r20978
3636If D6 is high, it moved left.  If D6 is low, it moved right.
3737Be sure to keep returning a direction until steer_reset is called.
3838***************************************************************************/
39static int subs_steering_1(running_machine &machine)
39int subs_state::subs_steering_1()
4040{
41   subs_state *state = machine.driver_data<subs_state>();
4241   int this_val;
4342   int delta;
4443
45   this_val=state->ioport("DIAL2")->read();
44   this_val=ioport("DIAL2")->read();
4645
47   delta=this_val-state->m_last_val_1;
48   state->m_last_val_1=this_val;
46   delta=this_val-m_last_val_1;
47   m_last_val_1=this_val;
4948   if (delta>128) delta-=256;
5049   else if (delta<-128) delta+=256;
5150   /* Divide by four to make our steering less sensitive */
52   state->m_steering_buf1+=(delta/4);
51   m_steering_buf1+=(delta/4);
5352
54   if (state->m_steering_buf1>0)
53   if (m_steering_buf1>0)
5554   {
56         state->m_steering_buf1--;
57         state->m_steering_val1=0xC0;
55         m_steering_buf1--;
56         m_steering_val1=0xC0;
5857   }
59   else if (state->m_steering_buf1<0)
58   else if (m_steering_buf1<0)
6059   {
61         state->m_steering_buf1++;
62         state->m_steering_val1=0x80;
60         m_steering_buf1++;
61         m_steering_val1=0x80;
6362   }
6463
65   return state->m_steering_val1;
64   return m_steering_val1;
6665}
6766
68static int subs_steering_2(running_machine &machine)
67int subs_state::subs_steering_2()
6968{
70   subs_state *state = machine.driver_data<subs_state>();
7169   int this_val;
7270   int delta;
7371
74   this_val=state->ioport("DIAL1")->read();
72   this_val=ioport("DIAL1")->read();
7573
76   delta=this_val-state->m_last_val_2;
77   state->m_last_val_2=this_val;
74   delta=this_val-m_last_val_2;
75   m_last_val_2=this_val;
7876   if (delta>128) delta-=256;
7977   else if (delta<-128) delta+=256;
8078   /* Divide by four to make our steering less sensitive */
81   state->m_steering_buf2+=(delta/4);
79   m_steering_buf2+=(delta/4);
8280
83   if (state->m_steering_buf2>0)
81   if (m_steering_buf2>0)
8482   {
85      state->m_steering_buf2--;
86      state->m_steering_val2=0xC0;
83      m_steering_buf2--;
84      m_steering_val2=0xC0;
8785   }
88   else if (state->m_steering_buf2<0)
86   else if (m_steering_buf2<0)
8987   {
90      state->m_steering_buf2++;
91      state->m_steering_val2=0x80;
88      m_steering_buf2++;
89      m_steering_val2=0x80;
9290   }
9391
94   return state->m_steering_val2;
92   return m_steering_val2;
9593}
9694
9795/***************************************************************************
r20977r20978
116114      case 0x01:      return ((inport & 0x02) << 6);  /* diag hold */
117115      case 0x02:      return ((inport & 0x04) << 5);  /* slam */
118116      case 0x03:      return ((inport & 0x08) << 4);  /* spare */
119      case 0x04:      return ((subs_steering_1(machine()) & 0x40) << 1);  /* steer dir 1 */
120      case 0x05:      return ((subs_steering_1(machine()) & 0x80) << 0);  /* steer flag 1 */
121      case 0x06:      return ((subs_steering_2(machine()) & 0x40) << 1);  /* steer dir 2 */
122      case 0x07:      return ((subs_steering_2(machine()) & 0x80) << 0);  /* steer flag 2 */
117      case 0x04:      return ((subs_steering_1() & 0x40) << 1);  /* steer dir 1 */
118      case 0x05:      return ((subs_steering_1() & 0x80) << 0);  /* steer flag 1 */
119      case 0x06:      return ((subs_steering_2() & 0x40) << 1);  /* steer dir 2 */
120      case 0x07:      return ((subs_steering_2() & 0x80) << 0);  /* steer flag 2 */
123121   }
124122
125123   return 0;
trunk/src/mame/machine/starwars.c
r20977r20978
149149 *
150150 *************************************/
151151
152void starwars_mproc_init(running_machine &machine)
152void starwars_state::starwars_mproc_init()
153153{
154   starwars_state *state = machine.driver_data<starwars_state>();
155   UINT8 *src = state->memregion("user2")->base();
154   UINT8 *src = memregion("user2")->base();
156155   int cnt, val;
157156
158   state->m_PROM_STR = auto_alloc_array(machine, UINT8, 1024);
159   state->m_PROM_MAS = auto_alloc_array(machine, UINT8, 1024);
160   state->m_PROM_AM = auto_alloc_array(machine, UINT8, 1024);
157   m_PROM_STR = auto_alloc_array(machine(), UINT8, 1024);
158   m_PROM_MAS = auto_alloc_array(machine(), UINT8, 1024);
159   m_PROM_AM = auto_alloc_array(machine(), UINT8, 1024);
161160
162161   for (cnt = 0; cnt < 1024; cnt++)
163162   {
r20977r20978
168167      val |= (src[0x0000 + cnt] << 12) & 0xf000; /* Set MS nibble */
169168
170169      /* perform pre-decoding */
171      state->m_PROM_STR[cnt] = (val >> 8) & 0x00ff;
172      state->m_PROM_MAS[cnt] =  val       & 0x007f;
173      state->m_PROM_AM[cnt]  = (val >> 7) & 0x0001;
170      m_PROM_STR[cnt] = (val >> 8) & 0x00ff;
171      m_PROM_MAS[cnt] =  val       & 0x007f;
172      m_PROM_AM[cnt]  = (val >> 7) & 0x0001;
174173   }
175174
176   state->m_math_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(starwars_state::math_run_clear),state));
175   m_math_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(starwars_state::math_run_clear),this));
177176}
178177
179178
r20977r20978
184183 *
185184 *************************************/
186185
187void starwars_mproc_reset(running_machine &machine)
186void starwars_state::starwars_mproc_reset()
188187{
189   starwars_state *state = machine.driver_data<starwars_state>();
190   state->m_MPA = state->m_BIC = 0;
191   state->m_math_run = 0;
188   m_MPA = m_BIC = 0;
189   m_math_run = 0;
192190}
193191
194192
r20977r20978
199197 *
200198 *************************************/
201199
202static void run_mproc(running_machine &machine)
200void starwars_state::run_mproc()
203201{
204   starwars_state *state = machine.driver_data<starwars_state>();
205202
206203   int RAMWORD = 0;
207204   int MA_byte;
r20977r20978
214211   logerror("Running Matrix Processor...\n");
215212
216213   mptime = 0;
217   state->m_math_run = 1;
214   m_math_run = 1;
218215
219216   /* loop until finished */
220217   while (M_STOP > 0)
r20977r20978
223220      mptime += 5;
224221
225222      /* fetch the current instruction data */
226      IP15_8 = state->m_PROM_STR[state->m_MPA];
227      IP7    = state->m_PROM_AM[state->m_MPA];
228      IP6_0  = state->m_PROM_MAS[state->m_MPA];
223      IP15_8 = m_PROM_STR[m_MPA];
224      IP7    = m_PROM_AM[m_MPA];
225      IP6_0  = m_PROM_MAS[m_MPA];
229226
230227#if (MATHDEBUG)
231      mame_printf_debug("\n(MPA:%x), Strobe: %x, IP7: %d, IP6_0:%x\n",state->m_MPA, IP15_8, IP7, IP6_0);
232      mame_printf_debug("(BIC: %x), A: %x, B: %x, C: %x, ACC: %x\n",state->m_BIC,state->m_A,state->m_B,state->m_C,state->m_ACC);
228      mame_printf_debug("\n(MPA:%x), Strobe: %x, IP7: %d, IP6_0:%x\n",m_MPA, IP15_8, IP7, IP6_0);
229      mame_printf_debug("(BIC: %x), A: %x, B: %x, C: %x, ACC: %x\n",m_BIC,m_A,m_B,m_C,m_ACC);
233230#endif
234231
235232      /* construct the current RAM address */
236233      if (IP7 == 0)
237         MA = (IP6_0 & 3) | ((state->m_BIC & 0x01ff) << 2);  /* MA10-2 set to BIC8-0 */
234         MA = (IP6_0 & 3) | ((m_BIC & 0x01ff) << 2);  /* MA10-2 set to BIC8-0 */
238235      else
239236         MA = IP6_0;
240237
r20977r20978
242239          and apply base address offset */
243240
244241      MA_byte = MA << 1;
245      RAMWORD = (state->m_mathram[MA_byte + 1] & 0x00ff) | ((state->m_mathram[MA_byte] & 0x00ff) << 8);
242      RAMWORD = (m_mathram[MA_byte + 1] & 0x00ff) | ((m_mathram[MA_byte] & 0x00ff) << 8);
246243
247244//      logerror("MATH ADDR: %x, CPU ADDR: %x, RAMWORD: %x\n", MA, MA_byte, RAMWORD);
248245
r20977r20978
264261      /* 0x10 - CLEAR_ACC */
265262      if (IP15_8 & CLEAR_ACC)
266263      {
267         state->m_ACC = 0;
264         m_ACC = 0;
268265      }
269266
270267      /* 0x01 - LAC (also clears lsb)*/
271268      if (IP15_8 & LAC)
272         state->m_ACC = (RAMWORD << 16);
269         m_ACC = (RAMWORD << 16);
273270
274271      /* 0x02 - READ_ACC */
275272      if (IP15_8 & READ_ACC)
276273      {
277         state->m_mathram[MA_byte+1] = ((state->m_ACC >> 16) & 0xff);
278         state->m_mathram[MA_byte  ] = ((state->m_ACC >> 24) & 0xff);
274         m_mathram[MA_byte+1] = ((m_ACC >> 16) & 0xff);
275         m_mathram[MA_byte  ] = ((m_ACC >> 24) & 0xff);
279276      }
280277
281278      /* 0x04 - M_HALT */
r20977r20978
284281
285282      /* 0x08 - INC_BIC */
286283      if (IP15_8 & INC_BIC)
287         state->m_BIC = (state->m_BIC + 1) & 0x1ff; /* Restrict to 9 bits */
284         m_BIC = (m_BIC + 1) & 0x1ff; /* Restrict to 9 bits */
288285
289286      /* 0x20 - LDC*/
290287      if (IP15_8 & LDC)
291288      {
292         state->m_C = RAMWORD;
289         m_C = RAMWORD;
293290
294291         /* This is a serial subtractor - multiplier (74ls384) -
295292          * accumulator. For the full calculation 33 GMCLK pulses
r20977r20978
320317          * takes 33 clock pulses to do a full rotation.
321318          */
322319
323         state->m_ACC += (((INT32)(state->m_A - state->m_B) << 1) * state->m_C) << 1;
320         m_ACC += (((INT32)(m_A - m_B) << 1) * m_C) << 1;
324321
325322         /* A and B are sign extended (requred by the ls384). After
326323          * multiplication they just contain the sign.
327324          */
328         state->m_A = (state->m_A & 0x8000)? 0xffff: 0;
329         state->m_B = (state->m_B & 0x8000)? 0xffff: 0;
325         m_A = (m_A & 0x8000)? 0xffff: 0;
326         m_B = (m_B & 0x8000)? 0xffff: 0;
330327
331328         /* The multiply-add holds the main matrix processor counter
332329          * for 33 cycles
r20977r20978
336333
337334      /* 0x40 - LDB */
338335      if (IP15_8 & LDB)
339         state->m_B = RAMWORD;
336         m_B = RAMWORD;
340337
341338      /* 0x80 - LDA */
342339      if (IP15_8 & LDA)
343         state->m_A = RAMWORD;
340         m_A = RAMWORD;
344341
345342      /*
346343       * Now update the PROM address counter
r20977r20978
348345       * This means that each of the four pages should wrap around rather than
349346       * leaking from one to another.  It may not matter, but I've put it in anyway
350347       */
351      tmp = state->m_MPA + 1;
352      state->m_MPA = (state->m_MPA & 0x0300) | (tmp & 0x00ff); /* New MPA value */
348      tmp = m_MPA + 1;
349      m_MPA = (m_MPA & 0x0300) | (tmp & 0x00ff); /* New MPA value */
353350
354351      M_STOP--; /* Decrease count */
355352   }
356353
357   state->m_math_timer->adjust(attotime::from_hz(MASTER_CLOCK) * mptime, 1);
354   m_math_timer->adjust(attotime::from_hz(MASTER_CLOCK) * mptime, 1);
358355}
359356
360357
r20977r20978
412409   {
413410      case 0: /* mw0 */
414411         m_MPA = data << 2;  /* Set starting PROM address */
415         run_mproc(machine());           /* and run the Matrix Processor */
412         run_mproc();           /* and run the Matrix Processor */
416413         break;
417414
418415      case 1: /* mw1 */
trunk/src/mame/video/suprloco.c
r20977r20978
156156
157157
158158
159INLINE void draw_pixel(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int color,int flip)
159inline void suprloco_state::draw_pixel(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int color,int flip)
160160{
161161   if (flip)
162162   {
r20977r20978
169169}
170170
171171
172static void draw_sprite(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int spr_number)
172void suprloco_state::draw_sprite(bitmap_ind16 &bitmap,const rectangle &cliprect,int spr_number)
173173{
174   suprloco_state *state = machine.driver_data<suprloco_state>();
175   int flip = state->flip_screen();
174   int flip = flip_screen();
176175   int sx,sy,col,row,height,src,adjy,dy;
177176   UINT8 *spr_reg;
178177   UINT8 *gfx2;
r20977r20978
180179   short skip; /* bytes to skip before drawing each row (can be negative) */
181180
182181
183   spr_reg = state->m_spriteram + 0x10 * spr_number;
182   spr_reg = m_spriteram + 0x10 * spr_number;
184183
185184   src = spr_reg[SPR_GFXOFS_LO] + (spr_reg[SPR_GFXOFS_HI] << 8);
186185   skip = spr_reg[SPR_SKIP_LO] + (spr_reg[SPR_SKIP_HI] << 8);
187186
188187   height      = spr_reg[SPR_Y_BOTTOM] - spr_reg[SPR_Y_TOP];
189   pen_base = 0x100 + 0x10 * (spr_reg[SPR_COL]&0x03) + ((state->m_control & 0x20)?0x100:0);
188   pen_base = 0x100 + 0x10 * (spr_reg[SPR_COL]&0x03) + ((m_control & 0x20)?0x100:0);
190189   sx = spr_reg[SPR_X];
191190   sy = spr_reg[SPR_Y_TOP] + 1;
192191
193   if (!state->flip_screen())
192   if (!flip_screen())
194193   {
195194      adjy = sy;
196195      dy = 1;
r20977r20978
201200      dy = -1;
202201   }
203202
204   gfx2 = machine.root_device().memregion("gfx2")->base();
203   gfx2 = machine().root_device().memregion("gfx2")->base();
205204   for (row = 0;row < height;row++,adjy+=dy)
206205   {
207206      int color1,color2,flipx;
r20977r20978
244243   }
245244}
246245
247static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
246void suprloco_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
248247{
249   suprloco_state *state = machine.driver_data<suprloco_state>();
250248   int spr_number;
251249   UINT8 *spr_reg;
252250
253251
254   for (spr_number = 0;spr_number < (state->m_spriteram.bytes() >> 4);spr_number++)
252   for (spr_number = 0;spr_number < (m_spriteram.bytes() >> 4);spr_number++)
255253   {
256      spr_reg = state->m_spriteram + 0x10 * spr_number;
254      spr_reg = m_spriteram + 0x10 * spr_number;
257255      if (spr_reg[SPR_X] != 0xff)
258         draw_sprite(machine, bitmap, cliprect, spr_number);
256         draw_sprite(bitmap, cliprect, spr_number);
259257   }
260258}
261259
262260UINT32 suprloco_state::screen_update_suprloco(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
263261{
264262   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
265   draw_sprites(machine(),bitmap,cliprect);
263   draw_sprites(bitmap,cliprect);
266264   m_bg_tilemap->draw(bitmap, cliprect, 1,0);
267265   return 0;
268266}
trunk/src/mame/video/splash.c
r20977r20978
7676   m_bg_tilemap[offset >> 11]->mark_tile_dirty(((offset << 1) & 0x0fff) >> 1);
7777}
7878
79static void draw_bitmap(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
79void splash_state::draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect)
8080{
81   splash_state *state = machine.driver_data<splash_state>();
8281   int sx,sy,color,count,colxor,bitswap;
8382   colxor = 0; /* splash and some bitmap modes in roldfrog */
8483   bitswap = 0;
8584
86   if (state->m_bitmap_type == 1) /* roldfrog */
85   if (m_bitmap_type == 1) /* roldfrog */
8786   {
88      if (state->m_bitmap_mode[0] == 0x0000)
87      if (m_bitmap_mode[0] == 0x0000)
8988      {
9089         colxor = 0x7f;
9190      }
92      else if (state->m_bitmap_mode[0] == 0x0100)
91      else if (m_bitmap_mode[0] == 0x0100)
9392      {
9493         bitswap = 1;
9594      }
96      else if (state->m_bitmap_mode[0] == 0x0200)
95      else if (m_bitmap_mode[0] == 0x0200)
9796      {
9897         colxor = 0x55;
9998      }
100      else if (state->m_bitmap_mode[0] == 0x0300)
99      else if (m_bitmap_mode[0] == 0x0300)
101100      {
102101         bitswap = 2;
103102         colxor = 0x7f;
104103      }
105      else if (state->m_bitmap_mode[0] == 0x0400)
104      else if (m_bitmap_mode[0] == 0x0400)
106105      {
107106         bitswap = 3;
108107      }
109      else if (state->m_bitmap_mode[0] == 0x0500)
108      else if (m_bitmap_mode[0] == 0x0500)
110109      {
111110         bitswap = 4;
112111      }
113      else if (state->m_bitmap_mode[0] == 0x0600)
112      else if (m_bitmap_mode[0] == 0x0600)
114113      {
115114         bitswap = 5;
116115         colxor = 0x7f;
117116      }
118      else if (state->m_bitmap_mode[0] == 0x0700)
117      else if (m_bitmap_mode[0] == 0x0700)
119118      {
120119         bitswap = 6;
121120         colxor = 0x55;
r20977r20978
127126   {
128127      for (sx=0;sx<512;sx++)
129128      {
130         color = state->m_pixelram[count]&0xff;
129         color = m_pixelram[count]&0xff;
131130         count++;
132131
133132         switch( bitswap )
r20977r20978
204203      400| xxxxxxxx -------- | unused
205204*/
206205
207static void splash_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
206void splash_state::splash_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
208207{
209   splash_state *state = machine.driver_data<splash_state>();
210208   int i;
211   gfx_element *gfx = machine.gfx[1];
209   gfx_element *gfx = machine().gfx[1];
212210
213211   for (i = 0; i < 0x400; i += 4){
214      int sx = state->m_spriteram[i+2] & 0xff;
215      int sy = (240 - (state->m_spriteram[i+1] & 0xff)) & 0xff;
216      int attr = state->m_spriteram[i+3] & 0xff;
217      int attr2 = state->m_spriteram[i+0x400] >> state->m_sprite_attr2_shift;
218      int number = (state->m_spriteram[i] & 0xff) + (attr & 0xf)*256;
212      int sx = m_spriteram[i+2] & 0xff;
213      int sy = (240 - (m_spriteram[i+1] & 0xff)) & 0xff;
214      int attr = m_spriteram[i+3] & 0xff;
215      int attr2 = m_spriteram[i+0x400] >> m_sprite_attr2_shift;
216      int number = (m_spriteram[i] & 0xff) + (attr & 0xf)*256;
219217
220218      if (attr2 & 0x80) sx += 256;
221219
r20977r20978
225223   }
226224}
227225
228static void funystrp_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
226void splash_state::funystrp_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
229227{
230   splash_state *state = machine.driver_data<splash_state>();
231228   int i;
232   gfx_element *gfx = machine.gfx[1];
229   gfx_element *gfx = machine().gfx[1];
233230
234231   for (i = 0; i < 0x400; i += 4){
235      int sx = state->m_spriteram[i+2] & 0xff;
236      int sy = (240 - (state->m_spriteram[i+1] & 0xff)) & 0xff;
237      int attr = state->m_spriteram[i+3] & 0xff;
238      int attr2 = state->m_spriteram[i+0x400] >> state->m_sprite_attr2_shift;
239      int number = (state->m_spriteram[i] & 0xff) + (attr & 0xf)*256;
232      int sx = m_spriteram[i+2] & 0xff;
233      int sy = (240 - (m_spriteram[i+1] & 0xff)) & 0xff;
234      int attr = m_spriteram[i+3] & 0xff;
235      int attr2 = m_spriteram[i+0x400] >> m_sprite_attr2_shift;
236      int number = (m_spriteram[i] & 0xff) + (attr & 0xf)*256;
240237
241238      if (attr2 & 0x80) sx += 256;
242239
r20977r20978
258255   m_bg_tilemap[0]->set_scrolly(0, m_vregs[0]);
259256   m_bg_tilemap[1]->set_scrolly(0, m_vregs[1]);
260257
261   draw_bitmap(machine(), bitmap, cliprect);
258   draw_bitmap(bitmap, cliprect);
262259
263260   m_bg_tilemap[1]->draw(bitmap, cliprect, 0, 0);
264   splash_draw_sprites(machine(), bitmap, cliprect);
261   splash_draw_sprites(bitmap, cliprect);
265262   m_bg_tilemap[0]->draw(bitmap, cliprect, 0, 0);
266263   return 0;
267264}
r20977r20978
272269   m_bg_tilemap[0]->set_scrolly(0, m_vregs[0]);
273270   m_bg_tilemap[1]->set_scrolly(0, m_vregs[1]);
274271
275   draw_bitmap(machine(), bitmap, cliprect);
272   draw_bitmap(bitmap, cliprect);
276273
277274   m_bg_tilemap[1]->draw(bitmap, cliprect, 0, 0);
278275   /*Sprite chip is similar but not the same*/
279   funystrp_draw_sprites(machine(), bitmap, cliprect);
276   funystrp_draw_sprites(bitmap, cliprect);
280277   m_bg_tilemap[0]->draw(bitmap, cliprect, 0, 0);
281278   return 0;
282279}
trunk/src/mame/video/sslam.c
r20977r20978
2222   palette_set_color_rgb(machine(), offset, pal5bit(r), pal5bit(g), pal5bit(b));
2323}
2424
25static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
25void sslam_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
2626{
27   sslam_state *state = machine.driver_data<sslam_state>();
28   gfx_element *gfx = machine.gfx[0];
29   UINT16 *source = state->m_spriteram;
27   gfx_element *gfx = machine().gfx[0];
28   UINT16 *source = m_spriteram;
3029   UINT16 *finish = source + 0x1000/2;
3130
3231   source += 3; // strange
r20977r20978
4443      flipx = source[0] & 0x4000;
4544      number = source[3];
4645
47      xpos -=16; xpos -=7; xpos += state->m_sprites_x_offset;
46      xpos -=16; xpos -=7; xpos += m_sprites_x_offset;
4847      ypos = 0xff - ypos;
4948      ypos -=16; ypos -=7;
5049
r20977r20978
208207      m_md_tilemap->draw(bitmap, cliprect, 0,0);
209208   }
210209
211   draw_sprites(machine(), bitmap,cliprect);
210   draw_sprites(bitmap,cliprect);
212211   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
213212   return 0;
214213}
r20977r20978
225224   m_bg_tilemap->set_scrolly(0, m_regs[1]-240);
226225
227226   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
228   draw_sprites(machine(), bitmap,cliprect);
227   draw_sprites(bitmap,cliprect);
229228   return 0;
230229}
trunk/src/mame/video/sauro.c
r20977r20978
8989   m_palette_bank = 0;
9090}
9191
92static void sauro_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
92void sauro_state::sauro_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
9393{
94   sauro_state *state = machine.driver_data<sauro_state>();
95   UINT8 *spriteram = state->m_spriteram;
94   UINT8 *spriteram = m_spriteram;
9695   int offs,code,sx,sy,color,flipx;
97   int flipy = state->flip_screen();
96   int flipy = flip_screen();
9897
99   for (offs = 3; offs < state->m_spriteram.bytes() - 1; offs += 4)
98   for (offs = 3; offs < m_spriteram.bytes() - 1; offs += 4)
10099   {
101100      sy = spriteram[offs];
102101      if (sy == 0xf8) continue;
r20977r20978
104103      code = spriteram[offs+1] + ((spriteram[offs+3] & 0x03) << 8);
105104      sx = spriteram[offs+2];
106105      sy = 236 - sy;
107      color = ((spriteram[offs+3] >> 4) & 0x0f) | state->m_palette_bank;
106      color = ((spriteram[offs+3] >> 4) & 0x0f) | m_palette_bank;
108107
109108      // I'm not really sure how this bit works
110109      if (spriteram[offs+3] & 0x08)
r20977r20978
129128         sy = 240 - sy;
130129      }
131130
132      drawgfx_transpen(bitmap, cliprect, machine.gfx[2],
131      drawgfx_transpen(bitmap, cliprect, machine().gfx[2],
133132            code,
134133            color,
135134            flipx, flipy,
r20977r20978
141140{
142141   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
143142   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
144   sauro_draw_sprites(machine(), bitmap, cliprect);
143   sauro_draw_sprites(bitmap, cliprect);
145144   return 0;
146145}
147146
r20977r20978
153152         8, 8, 32, 32);
154153}
155154
156static void trckydoc_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
155void sauro_state::trckydoc_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
157156{
158   sauro_state *state = machine.driver_data<sauro_state>();
159   UINT8 *spriteram = state->m_spriteram;
157   UINT8 *spriteram = m_spriteram;
160158   int offs,code,sy,color,flipx,sx;
161   int flipy = state->flip_screen();
159   int flipy = flip_screen();
162160
163161   /* Weird, sprites entries don't start on DWORD boundary */
164   for (offs = 3; offs < state->m_spriteram.bytes() - 1; offs += 4)
162   for (offs = 3; offs < m_spriteram.bytes() - 1; offs += 4)
165163   {
166164      sy = spriteram[offs];
167165
r20977r20978
201199         sy = 240 - sy;
202200      }
203201
204      drawgfx_transpen(bitmap, cliprect,machine.gfx[1],
202      drawgfx_transpen(bitmap, cliprect,machine().gfx[1],
205203            code,
206204            color,
207205            flipx, flipy,
r20977r20978
212210UINT32 sauro_state::screen_update_trckydoc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
213211{
214212   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
215   trckydoc_draw_sprites(machine(), bitmap, cliprect);
213   trckydoc_draw_sprites(bitmap, cliprect);
216214   return 0;
217215}
trunk/src/mame/video/sidepckt.c
r20977r20978
104104
105105***************************************************************************/
106106
107static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
107void sidepckt_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
108108{
109   sidepckt_state *state = machine.driver_data<sidepckt_state>();
110   UINT8 *spriteram = state->m_spriteram;
109   UINT8 *spriteram = m_spriteram;
111110   int offs;
112111
113   for (offs = 0;offs < state->m_spriteram.bytes(); offs += 4)
112   for (offs = 0;offs < m_spriteram.bytes(); offs += 4)
114113   {
115114      int sx,sy,code,color,flipx,flipy;
116115
r20977r20978
123122      flipx = spriteram[offs+1] & 0x08;
124123      flipy = spriteram[offs+1] & 0x04;
125124
126      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
125      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
127126            code,
128127            color,
129128            flipx,flipy,
130129            sx,sy,0);
131130      /* wraparound */
132      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
131      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
133132            code,
134133            color,
135134            flipx,flipy,
r20977r20978
141140UINT32 sidepckt_state::screen_update_sidepckt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
142141{
143142   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0);
144   draw_sprites(machine(), bitmap,cliprect);
143   draw_sprites(bitmap,cliprect);
145144   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0);
146145   return 0;
147146}
trunk/src/mame/video/seta2.c
r20977r20978
211211   }
212212}
213213
214static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
214void seta2_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
215215{
216216   // Sprites list
217217
218   seta2_state *state = machine.driver_data<seta2_state>();
219   // When debugging, use state->m_spriteram here, and run mame -update_in_pause
220   UINT16 *buffered_spriteram16 = state->m_buffered_spriteram;
218   // When debugging, use m_spriteram here, and run mame -update_in_pause
219   UINT16 *buffered_spriteram16 = m_buffered_spriteram;
221220   UINT16 *s1  = buffered_spriteram16 + 0x3000/2;
222   UINT16 *end = &buffered_spriteram16[state->m_spriteram.bytes()/2];
221   UINT16 *end = &buffered_spriteram16[m_spriteram.bytes()/2];
223222
224223//  for ( ; s1 < end; s1+=4 )
225224   for ( ; s1 < buffered_spriteram16 + 0x4000/2; s1+=4 )   // more reasonable (and it cures MAME lockup in e.g. funcube3 boot)
r20977r20978
250249         default:
251250            popmessage("unknown gfxset %x",(num & 0x0700)>>8);
252251            shadow_depth = 0;
253            gfx = machine.gfx[machine.rand()&3];
252            gfx = machine().gfx[machine().rand()&3];
254253            break;
255254         case 0x0700:            // 8bpp tiles (76543210)
256255            shadow_depth = 8;   // ?
257            gfx = machine.gfx[3];
256            gfx = machine().gfx[3];
258257            break;
259258         case 0x0600:            // 6bpp tiles (--543210) (myangel sliding blocks test)
260259            shadow_depth = 6;   // ?
261            gfx = machine.gfx[2];
260            gfx = machine().gfx[2];
262261            break;
263262         case 0x0500:            // 4bpp tiles (3210----)
264263            shadow_depth = 4;   // ?
265            gfx = machine.gfx[1];
264            gfx = machine().gfx[1];
266265            break;
267266         case 0x0400:            // 4bpp tiles (----3210)
268267            shadow_depth = 3;   // reelquak
269            gfx = machine.gfx[0];
268            gfx = machine().gfx[0];
270269            break;
271270//          case 0x0300:
272271//              unknown
273272         case 0x0200:            // 3bpp tiles?  (-----210) (myangel "Graduate Tests")
274273            shadow_depth = 3;   // ?
275            gfx = machine.gfx[4];
274            gfx = machine().gfx[4];
276275            break;
277276         case 0x0100:            // 2bpp tiles??? (--10----) (myangel2 question bubble, myangel endgame)
278277            shadow_depth = 2;   // myangel2
279            gfx = machine.gfx[5];
278            gfx = machine().gfx[5];
280279            break;
281280         case 0x0000:            // no idea!
282281            shadow_depth = 4;   // ?
283            gfx = machine.gfx[0];
282            gfx = machine().gfx[0];
284283            break;
285284      }
286285      if (!use_shadow)
r20977r20978
318317            sx &= 0x3ff;
319318            sy &= 0x1ff;
320319
321            scrollx += state->m_xoffset;
320            scrollx += m_xoffset;
322321            scrollx &= 0x3ff;
323322            scrolly &= 0x1ff;
324323
r20977r20978
333332            if (clip.max_x > cliprect.max_x)    clip.max_x = cliprect.max_x;
334333
335334            // sprite clipping region (y)
336            clip.min_y = ((sy + yoffs) & 0x1ff) - state->m_yoffset;
335            clip.min_y = ((sy + yoffs) & 0x1ff) - m_yoffset;
337336            clip.max_y = clip.min_y + height * 0x10 - 1;
338337
339338            if (clip.min_y > cliprect.max_y)    continue;
r20977r20978
346345            // Draw the rows
347346            for (y = 0; y < (0x40 >> tilesize); y++)
348347            {
349               int py = ((scrolly - (y+1) * (8 << tilesize) + 0x10) & 0x1ff) - 0x10 - state->m_yoffset;
348               int py = ((scrolly - (y+1) * (8 << tilesize) + 0x10) & 0x1ff) - 0x10 - m_yoffset;
350349
351350               for (x = 0; x < 0x40; x++)
352351               {
r20977r20978
410409            sx = (sx & 0x1ff) - (sx & 0x200);
411410
412411            sy &= 0x1ff;
413            sy -= state->m_yoffset;
412            sy -= m_yoffset;
414413
415414            code &= ~((sizex+1) * (sizey+1) - 1);   // see myangel, myangel2 and grdians
416415
r20977r20978
478477   bitmap.fill(machine().pens[0], cliprect);
479478
480479   if ( (m_vregs[0x30/2] & 1) == 0 )   // 1 = BLANK SCREEN
481      draw_sprites(machine(), bitmap, cliprect);
480      draw_sprites(bitmap, cliprect);
482481
483482   return 0;
484483}
trunk/src/mame/video/seta.c
r20977r20978
214214    ---- --1-       Coin #1 Counter
215215    ---- ---0       Coin #0 Counter     */
216216
217void seta_coin_lockout_w(running_machine &machine, int data)
217void seta_state::seta_coin_lockout_w(int data)
218218{
219   seta_state *state = machine.driver_data<seta_state>();
220219   static const char *const seta_nolockout[] =
221220   { "blandia", "eightfrc", "extdwnhl", "gundhara", "kamenrid", "magspeed", "sokonuke", "zingzip", "zombraid"};
222221
223222   /* Only compute seta_coin_lockout when confronted with a new gamedrv */
224   if (!state->m_coin_lockout_initialized)
223   if (!m_coin_lockout_initialized)
225224   {
226      state->m_coin_lockout_initialized = true;
225      m_coin_lockout_initialized = true;
227226      int i;
228227
229      state->m_coin_lockout = 1;
228      m_coin_lockout = 1;
230229      for (i=0; i<ARRAY_LENGTH(seta_nolockout); i++)
231230      {
232         if (strcmp(machine.system().name, seta_nolockout[i]) == 0 ||
233            strcmp(machine.system().parent, seta_nolockout[i]) == 0)
231         if (strcmp(machine().system().name, seta_nolockout[i]) == 0 ||
232            strcmp(machine().system().parent, seta_nolockout[i]) == 0)
234233         {
235            state->m_coin_lockout = 0;
234            m_coin_lockout = 0;
236235            break;
237236         }
238237      }
239238   }
240239
241   coin_counter_w      (machine, 0, (( data) >> 0) & 1 );
242   coin_counter_w      (machine, 1, (( data) >> 1) & 1 );
240   coin_counter_w      (machine(), 0, (( data) >> 0) & 1 );
241   coin_counter_w      (machine(), 1, (( data) >> 1) & 1 );
243242
244243   /* some games haven't the coin lockout device */
245   if (    !state->m_coin_lockout )
244   if (    !m_coin_lockout )
246245      return;
247   coin_lockout_w      (machine, 0, ((~data) >> 2) & 1 );
248   coin_lockout_w      (machine, 1, ((~data) >> 3) & 1 );
246   coin_lockout_w      (machine(), 0, ((~data) >> 2) & 1 );
247   coin_lockout_w      (machine(), 1, ((~data) >> 3) & 1 );
249248}
250249
251250
r20977r20978
267266         if (ACCESSING_BITS_0_7)
268267         {
269268            device_t *x1_010 = machine().device("x1snd");
270            seta_coin_lockout_w (machine(), data & 0x0f);
269            seta_coin_lockout_w (data & 0x0f);
271270            if (x1_010 != NULL)
272271               seta_sound_enable_w (x1_010, data & 0x20);
273272            coin_counter_w(machine(), 0,data & 0x01);
r20977r20978
362361
363362***************************************************************************/
364363
365INLINE void twineagl_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, int offset )
364inline void seta_state::twineagl_tile_info( tile_data &tileinfo, int tile_index, int offset )
366365{
367   seta_state *state = machine.driver_data<seta_state>();
368   UINT16 *vram = state->m_vram_0 + offset;
366   UINT16 *vram = m_vram_0 + offset;
369367   UINT16 code =   vram[ tile_index ];
370368   UINT16 attr =   vram[ tile_index + 0x800 ];
371369   if ((code & 0x3e00) == 0x3e00)
372      code = (code & 0xc07f) | ((state->m_twineagl_tilebank[(code & 0x0180) >> 7] >> 1) << 7);
373   SET_TILE_INFO( 1, (code & 0x3fff), attr & 0x1f, TILE_FLIPXY((code & 0xc000) >> 14) );
370      code = (code & 0xc07f) | ((m_twineagl_tilebank[(code & 0x0180) >> 7] >> 1) << 7);
371   SET_TILE_INFO_MEMBER( 1, (code & 0x3fff), attr & 0x1f, TILE_FLIPXY((code & 0xc000) >> 14) );
374372}
375373
376TILE_GET_INFO_MEMBER(seta_state::twineagl_get_tile_info_0){ twineagl_tile_info( machine(), tileinfo, tile_index, 0x0000 ); }
377TILE_GET_INFO_MEMBER(seta_state::twineagl_get_tile_info_1){ twineagl_tile_info( machine(), tileinfo, tile_index, 0x1000 ); }
374TILE_GET_INFO_MEMBER(seta_state::twineagl_get_tile_info_0){ twineagl_tile_info(tileinfo, tile_index, 0x0000 ); }
375TILE_GET_INFO_MEMBER(seta_state::twineagl_get_tile_info_1){ twineagl_tile_info(tileinfo, tile_index, 0x1000 ); }
378376
379377
380INLINE void get_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, int layer, int offset )
378inline void seta_state::get_tile_info( tile_data &tileinfo, int tile_index, int layer, int offset )
381379{
382   seta_state *state = machine.driver_data<seta_state>();
383380   int gfx = 1 + layer;
384   UINT16 *vram = (layer == 0) ? state->m_vram_0 + offset : state->m_vram_2 + offset;
385   UINT16 *vctrl = (layer == 0) ? state->m_vctrl_0 : state->m_vctrl_2;
381   UINT16 *vram = (layer == 0) ? m_vram_0 + offset : m_vram_2 + offset;
382   UINT16 *vctrl = (layer == 0) ? m_vctrl_0 : m_vctrl_2;
386383   UINT16 code =   vram[ tile_index ];
387384   UINT16 attr =   vram[ tile_index + 0x800 ];
388385
389   if(machine.gfx[gfx + ((vctrl[ 4/2 ] & 0x10) >> state->m_color_mode_shift)] != NULL)
386   if(machine().gfx[gfx + ((vctrl[ 4/2 ] & 0x10) >> m_color_mode_shift)] != NULL)
390387   {
391      gfx += (vctrl[ 4/2 ] & 0x10) >> state->m_color_mode_shift;
388      gfx += (vctrl[ 4/2 ] & 0x10) >> m_color_mode_shift;
392389   }
393390   else
394391   {
395392      popmessage("Missing Color Mode = 1 for Layer = %d. Contact MAMETesters.",layer);
396393   }
397394
398   SET_TILE_INFO( gfx, state->m_tiles_offset + (code & 0x3fff), attr & 0x1f, TILE_FLIPXY((code & 0xc000) >> 14) );
395   SET_TILE_INFO_MEMBER( gfx, m_tiles_offset + (code & 0x3fff), attr & 0x1f, TILE_FLIPXY((code & 0xc000) >> 14) );
399396}
400397
401TILE_GET_INFO_MEMBER(seta_state::get_tile_info_0){ get_tile_info( machine(), tileinfo, tile_index, 0, 0x0000 ); }
402TILE_GET_INFO_MEMBER(seta_state::get_tile_info_1){ get_tile_info( machine(), tileinfo, tile_index, 0, 0x1000 ); }
403TILE_GET_INFO_MEMBER(seta_state::get_tile_info_2){ get_tile_info( machine(), tileinfo, tile_index, 1, 0x0000 ); }
404TILE_GET_INFO_MEMBER(seta_state::get_tile_info_3){ get_tile_info( machine(), tileinfo, tile_index, 1, 0x1000 ); }
398TILE_GET_INFO_MEMBER(seta_state::get_tile_info_0){ get_tile_info(tileinfo, tile_index, 0, 0x0000 ); }
399TILE_GET_INFO_MEMBER(seta_state::get_tile_info_1){ get_tile_info(tileinfo, tile_index, 0, 0x1000 ); }
400TILE_GET_INFO_MEMBER(seta_state::get_tile_info_2){ get_tile_info(tileinfo, tile_index, 1, 0x0000 ); }
401TILE_GET_INFO_MEMBER(seta_state::get_tile_info_3){ get_tile_info(tileinfo, tile_index, 1, 0x1000 ); }
405402
406403
407404WRITE16_MEMBER(seta_state::seta_vram_0_w)
r20977r20978
511508
512509int setac_gfxbank_callback( running_machine &machine, UINT16 code, UINT8 color )
513510{
514   //seta_state *state = machine.driver_data<seta_state>();
515511
516512   int bank    =   (color & 0x06) >> 1;
517513   code = (code & 0x3fff) + (bank * 0x4000);
r20977r20978
704700}
705701
706702
707static void set_pens(running_machine &machine)
703void seta_state::set_pens()
708704{
709   seta_state *state = machine.driver_data<seta_state>();
710705   offs_t i;
711706
712   for (i = 0; i < state->m_paletteram.bytes() / 2; i++)
707   for (i = 0; i < m_paletteram.bytes() / 2; i++)
713708   {
714      UINT16 data = state->m_paletteram[i];
709      UINT16 data = m_paletteram[i];
715710
716711      rgb_t color = MAKE_RGB(pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
717712
718      if (machine.colortable != NULL)
719         colortable_palette_set_color(machine.colortable, i, color);
713      if (machine().colortable != NULL)
714         colortable_palette_set_color(machine().colortable, i, color);
720715      else
721         palette_set_color(machine, i, color);
716         palette_set_color(machine(), i, color);
722717   }
723718
724   if(state->m_paletteram2 != NULL)
719   if(m_paletteram2 != NULL)
725720   {
726      for (i = 0; i < state->m_paletteram2.bytes() / 2; i++)
721      for (i = 0; i < m_paletteram2.bytes() / 2; i++)
727722      {
728         UINT16 data = state->m_paletteram2[i];
723         UINT16 data = m_paletteram2[i];
729724
730725         rgb_t color = MAKE_RGB(pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
731726
732         if (machine.colortable != NULL)
733            colortable_palette_set_color(machine.colortable, i + state->m_paletteram.bytes() / 2, color);
727         if (machine().colortable != NULL)
728            colortable_palette_set_color(machine().colortable, i + m_paletteram.bytes() / 2, color);
734729         else
735            palette_set_color(machine, i + state->m_paletteram.bytes() / 2, color);
730            palette_set_color(machine(), i + m_paletteram.bytes() / 2, color);
736731      }
737732   }
738733}
739734
740735
741static void usclssic_set_pens(running_machine &machine)
736void seta_state::usclssic_set_pens()
742737{
743   seta_state *state = machine.driver_data<seta_state>();
744738   offs_t i;
745739
746740   for (i = 0; i < 0x200; i++)
747741   {
748      UINT16 data = state->m_paletteram[i];
742      UINT16 data = m_paletteram[i];
749743
750744      rgb_t color = MAKE_RGB(pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
751745
752746      if (i >= 0x100)
753         colortable_palette_set_color(machine.colortable, i - 0x100, color);
747         colortable_palette_set_color(machine().colortable, i - 0x100, color);
754748      else
755         colortable_palette_set_color(machine.colortable, i + 0x200, color);
749         colortable_palette_set_color(machine().colortable, i + 0x200, color);
756750   }
757751}
758752
759753
760754
761755
762static void draw_tilemap_palette_effect(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, tilemap_t *tilemap, int scrollx, int scrolly, int gfxnum, int flipscreen)
756void seta_state::draw_tilemap_palette_effect(bitmap_ind16 &bitmap, const rectangle &cliprect, tilemap_t *tilemap, int scrollx, int scrolly, int gfxnum, int flipscreen)
763757{
764758   int y;
765   gfx_element *gfx_tilemap = machine.gfx[gfxnum];
759   gfx_element *gfx_tilemap = machine().gfx[gfxnum];
766760   const bitmap_ind16 &src_bitmap = tilemap->pixmap();
767761   int width_mask, height_mask;
768762   int opaque_mask = gfx_tilemap->granularity() - 1;
r20977r20978
794788            // pixels with the last color are not drawn and the 2nd palette is added to the current bitmap color
795789            if((p & pixel_effect_mask) == pixel_effect_mask)
796790            {
797               dest[x] = machine.total_colors() / 2 + dest[x];
791               dest[x] = machine().total_colors() / 2 + dest[x];
798792            }
799793            else
800794            {
801               dest[x] = machine.pens[p];
795               dest[x] = machine().pens[p];
802796            }
803797         }
804798      }
r20977r20978
819813/* For games without tilemaps */
820814UINT32 seta_state::screen_update_seta_no_layers(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
821815{
822   set_pens(machine());
816   set_pens();
823817   bitmap.fill(0x1f0, cliprect);
824818
825819   machine().device<seta001_device>("spritegen")->seta001_draw_sprites(machine(),bitmap,cliprect,0x1000, 1);
r20977r20978
828822
829823
830824/* For games with 1 or 2 tilemaps */
831void seta_layers_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_bank_size, int sprite_setac )
825void seta_state::seta_layers_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_bank_size, int sprite_setac )
832826{
833   seta_state *state = screen.machine().driver_data<seta_state>();
834827   int layers_ctrl = -1;
835828   int enab_0, enab_1, x_0, x_1=0, y_0, y_1=0;
836829
837830   int order   =   0;
838   int flip    =   screen.machine().device<seta001_device>("spritegen")->is_flipped();
831   int flip    =   machine().device<seta001_device>("spritegen")->is_flipped();
839832
840833   const rectangle &visarea = screen.visible_area();
841834   int vis_dimy = visarea.max_y - visarea.min_y + 1;
842835
843836   // check tilemaps color modes
844837
845   if(state->m_current_tilemap_mode[0] != (state->m_vctrl_0[ 4/2 ] & 0x10))
838   if(m_current_tilemap_mode[0] != (m_vctrl_0[ 4/2 ] & 0x10))
846839   {
847      state->m_current_tilemap_mode[0] = state->m_vctrl_0[ 4/2 ] & 0x10;
848      state->m_tilemap_0->mark_all_dirty();
849      state->m_tilemap_1->mark_all_dirty();
840      m_current_tilemap_mode[0] = m_vctrl_0[ 4/2 ] & 0x10;
841      m_tilemap_0->mark_all_dirty();
842      m_tilemap_1->mark_all_dirty();
850843   }
851844
852   if(state->m_tilemap_2 != NULL && state->m_tilemap_3 != NULL)
845   if(m_tilemap_2 != NULL && m_tilemap_3 != NULL)
853846   {
854      if(state->m_current_tilemap_mode[1] != (state->m_vctrl_2[ 4/2 ] & 0x10))
847      if(m_current_tilemap_mode[1] != (m_vctrl_2[ 4/2 ] & 0x10))
855848      {
856         state->m_current_tilemap_mode[1] = state->m_vctrl_2[ 4/2 ] & 0x10;
857         state->m_tilemap_2->mark_all_dirty();
858         state->m_tilemap_3->mark_all_dirty();
849         m_current_tilemap_mode[1] = m_vctrl_2[ 4/2 ] & 0x10;
850         m_tilemap_2->mark_all_dirty();
851         m_tilemap_3->mark_all_dirty();
859852      }
860853   }
861854
862   flip ^= state->m_tilemaps_flip;
855   flip ^= m_tilemaps_flip;
863856
864857   screen.machine().tilemap().set_flip_all(flip ? (TILEMAP_FLIPX|TILEMAP_FLIPY) : 0 );
865858
866   x_0     =   state->m_vctrl_0[ 0/2 ];
867   y_0     =   state->m_vctrl_0[ 2/2 ];
868   enab_0  =   state->m_vctrl_0[ 4/2 ];
859   x_0     =   m_vctrl_0[ 0/2 ];
860   y_0     =   m_vctrl_0[ 2/2 ];
861   enab_0  =   m_vctrl_0[ 4/2 ];
869862
870863   /* Only one tilemap per layer is enabled! */
871   state->m_tilemap_0->enable((!(enab_0 & 0x0008)) /*&& (enab_0 & 0x0001)*/ );
872   state->m_tilemap_1->enable(( (enab_0 & 0x0008)) /*&& (enab_0 & 0x0001)*/ );
864   m_tilemap_0->enable((!(enab_0 & 0x0008)) /*&& (enab_0 & 0x0001)*/ );
865   m_tilemap_1->enable(( (enab_0 & 0x0008)) /*&& (enab_0 & 0x0001)*/ );
873866
874867   /* the hardware wants different scroll values when flipped */
875868
r20977r20978
879872                   fff0 0260 = -$10, $400-$190 -$10
880873                   ffe8 0272 = -$18, $400-$190 -$18 + $1a      */
881874
882   x_0 += 0x10 - state->m_global_offsets->tilemap_offs[flip ? 1 : 0];
875   x_0 += 0x10 - m_global_offsets->tilemap_offs[flip ? 1 : 0];
883876   y_0 -= (256 - vis_dimy)/2;
884877   if (flip)
885878   {
r20977r20978
887880      y_0 = y_0 - vis_dimy;
888881   }
889882
890   state->m_tilemap_0->set_scrollx(0, x_0);
891   state->m_tilemap_1->set_scrollx(0, x_0);
892   state->m_tilemap_0->set_scrolly(0, y_0);
893   state->m_tilemap_1->set_scrolly(0, y_0);
883   m_tilemap_0->set_scrollx(0, x_0);
884   m_tilemap_1->set_scrollx(0, x_0);
885   m_tilemap_0->set_scrolly(0, y_0);
886   m_tilemap_1->set_scrolly(0, y_0);
894887
895   if (state->m_tilemap_2)
888   if (m_tilemap_2)
896889   {
897      x_1     =   state->m_vctrl_2[ 0/2 ];
898      y_1     =   state->m_vctrl_2[ 2/2 ];
899      enab_1  =   state->m_vctrl_2[ 4/2 ];
890      x_1     =   m_vctrl_2[ 0/2 ];
891      y_1     =   m_vctrl_2[ 2/2 ];
892      enab_1  =   m_vctrl_2[ 4/2 ];
900893
901      state->m_tilemap_2->enable((!(enab_1 & 0x0008)) /*&& (enab_1 & 0x0001)*/ );
902      state->m_tilemap_3->enable(( (enab_1 & 0x0008)) /*&& (enab_1 & 0x0001)*/ );
894      m_tilemap_2->enable((!(enab_1 & 0x0008)) /*&& (enab_1 & 0x0001)*/ );
895      m_tilemap_3->enable(( (enab_1 & 0x0008)) /*&& (enab_1 & 0x0001)*/ );
903896
904      x_1 += 0x10 - state->m_global_offsets->tilemap_offs[flip ? 1 : 0];
897      x_1 += 0x10 - m_global_offsets->tilemap_offs[flip ? 1 : 0];
905898      y_1 -= (256 - vis_dimy)/2;
906899      if (flip)
907900      {
r20977r20978
909902         y_1 = y_1 - vis_dimy;
910903      }
911904
912      state->m_tilemap_2->set_scrollx(0, x_1);
913      state->m_tilemap_3->set_scrollx(0, x_1);
914      state->m_tilemap_2->set_scrolly(0, y_1);
915      state->m_tilemap_3->set_scrolly(0, y_1);
905      m_tilemap_2->set_scrollx(0, x_1);
906      m_tilemap_3->set_scrollx(0, x_1);
907      m_tilemap_2->set_scrolly(0, y_1);
908      m_tilemap_3->set_scrolly(0, y_1);
916909
917      order   =   state->m_vregs[ 2/2 ];
910      order   =   m_vregs[ 2/2 ];
918911   }
919912
920913
r20977r20978
926919   if (screen.machine().input().code_pressed(KEYCODE_A))   msk |= 8;
927920   if (msk != 0) layers_ctrl &= msk;
928921
929   if (state->m_tilemap_2)
922   if (m_tilemap_2)
930923      popmessage("VR:%04X-%04X-%04X L0:%04X L1:%04X",
931         state->m_vregs[0], state->m_vregs[1], state->m_vregs[2], state->m_vctrl_0[4/2], state->m_vctrl_2[4/2]);
932   else if (state->m_tilemap_0)    popmessage("L0:%04X", state->m_vctrl_0[4/2]);
924         m_vregs[0], m_vregs[1], m_vregs[2], m_vctrl_0[4/2], m_vctrl_2[4/2]);
925   else if (m_tilemap_0)    popmessage("L0:%04X", m_vctrl_0[4/2]);
933926}
934927#endif
935928
r20977r20978
937930
938931   if (order & 1)  // swap the layers?
939932   {
940      if (state->m_tilemap_2)
933      if (m_tilemap_2)
941934      {
942         if (layers_ctrl & 2)    state->m_tilemap_2->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
943         if (layers_ctrl & 2)    state->m_tilemap_3->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
935         if (layers_ctrl & 2)    m_tilemap_2->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
936         if (layers_ctrl & 2)    m_tilemap_3->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
944937      }
945938
946939      if (order & 2)  // layer-sprite priority?
r20977r20978
952945            popmessage("Missing palette effect. Contact MAMETesters.");
953946         }
954947
955         if (layers_ctrl & 1)    state->m_tilemap_0->draw(bitmap, cliprect, 0, 0);
956         if (layers_ctrl & 1)    state->m_tilemap_1->draw(bitmap, cliprect, 0, 0);
948         if (layers_ctrl & 1)    m_tilemap_0->draw(bitmap, cliprect, 0, 0);
949         if (layers_ctrl & 1)    m_tilemap_1->draw(bitmap, cliprect, 0, 0);
957950      }
958951      else
959952      {
r20977r20978
962955            popmessage("Missing palette effect. Contact MAMETesters.");
963956         }
964957
965         if (layers_ctrl & 1)    state->m_tilemap_0->draw(bitmap, cliprect, 0, 0);
966         if (layers_ctrl & 1)    state->m_tilemap_1->draw(bitmap, cliprect, 0, 0);
958         if (layers_ctrl & 1)    m_tilemap_0->draw(bitmap, cliprect, 0, 0);
959         if (layers_ctrl & 1)    m_tilemap_1->draw(bitmap, cliprect, 0, 0);
967960
968         if (layers_ctrl & 8)        screen.machine().device<seta001_device>("spritegen")->seta001_draw_sprites(screen.machine(),bitmap,cliprect,sprite_bank_size, sprite_setac);
961         if (layers_ctrl & 8)        machine().device<seta001_device>("spritegen")->seta001_draw_sprites(screen.machine(),bitmap,cliprect,sprite_bank_size, sprite_setac);
969962      }
970963   }
971964   else
972965   {
973      if (layers_ctrl & 1)    state->m_tilemap_0->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
974      if (layers_ctrl & 1)    state->m_tilemap_1->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
966      if (layers_ctrl & 1)    m_tilemap_0->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
967      if (layers_ctrl & 1)    m_tilemap_1->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
975968
976969      if (order & 2)  // layer-sprite priority?
977970      {
978         if (layers_ctrl & 8)        screen.machine().device<seta001_device>("spritegen")->seta001_draw_sprites(screen.machine(),bitmap,cliprect,sprite_bank_size, sprite_setac);
971         if (layers_ctrl & 8)        machine().device<seta001_device>("spritegen")->seta001_draw_sprites(screen.machine(),bitmap,cliprect,sprite_bank_size, sprite_setac);
979972
980         if((order & 4) && state->m_paletteram2 != NULL)
973         if((order & 4) && m_paletteram2 != NULL)
981974         {
982            if(state->m_tilemap_2->enabled())
975            if(m_tilemap_2->enabled())
983976            {
984               draw_tilemap_palette_effect(screen.machine(), bitmap, cliprect, state->m_tilemap_2, x_1, y_1, 2 + ((state->m_vctrl_2[ 4/2 ] & 0x10) >> state->m_color_mode_shift), flip);
977               draw_tilemap_palette_effect(bitmap, cliprect, m_tilemap_2, x_1, y_1, 2 + ((m_vctrl_2[ 4/2 ] & 0x10) >> m_color_mode_shift), flip);
985978            }
986979            else
987980            {
988               draw_tilemap_palette_effect(screen.machine(), bitmap, cliprect, state->m_tilemap_3, x_1, y_1, 2 + ((state->m_vctrl_2[ 4/2 ] & 0x10) >> state->m_color_mode_shift), flip);
981               draw_tilemap_palette_effect(bitmap, cliprect, m_tilemap_3, x_1, y_1, 2 + ((m_vctrl_2[ 4/2 ] & 0x10) >> m_color_mode_shift), flip);
989982            }
990983         }
991984         else
r20977r20978
995988               popmessage("Missing palette effect. Contact MAMETesters.");
996989            }
997990
998            if (state->m_tilemap_2)
991            if (m_tilemap_2)
999992            {
1000               if (layers_ctrl & 2)    state->m_tilemap_2->draw(bitmap, cliprect, 0, 0);
1001               if (layers_ctrl & 2)    state->m_tilemap_3->draw(bitmap, cliprect, 0, 0);
993               if (layers_ctrl & 2)    m_tilemap_2->draw(bitmap, cliprect, 0, 0);
994               if (layers_ctrl & 2)    m_tilemap_3->draw(bitmap, cliprect, 0, 0);
1002995            }
1003996         }
1004997      }
1005998      else
1006999      {
1007         if((order & 4) && state->m_paletteram2 != NULL)
1000         if((order & 4) && m_paletteram2 != NULL)
10081001         {
1009            if(state->m_tilemap_2->enabled())
1002            if(m_tilemap_2->enabled())
10101003            {
1011               draw_tilemap_palette_effect(screen.machine(), bitmap, cliprect, state->m_tilemap_2, x_1, y_1, 2 + ((state->m_vctrl_2[ 4/2 ] & 0x10) >> state->m_color_mode_shift), flip);
1004               draw_tilemap_palette_effect(bitmap, cliprect, m_tilemap_2, x_1, y_1, 2 + ((m_vctrl_2[ 4/2 ] & 0x10) >> m_color_mode_shift), flip);
10121005            }
10131006            else
10141007            {
1015               draw_tilemap_palette_effect(screen.machine(), bitmap, cliprect, state->m_tilemap_3, x_1, y_1, 2 + ((state->m_vctrl_2[ 4/2 ] & 0x10) >> state->m_color_mode_shift), flip);
1008               draw_tilemap_palette_effect(bitmap, cliprect, m_tilemap_3, x_1, y_1, 2 + ((m_vctrl_2[ 4/2 ] & 0x10) >> m_color_mode_shift), flip);
10161009            }
10171010         }
10181011         else
r20977r20978
10221015               popmessage("Missing palette effect. Contact MAMETesters.");
10231016            }
10241017
1025            if (state->m_tilemap_2)
1018            if (m_tilemap_2)
10261019            {
1027               if (layers_ctrl & 2)    state->m_tilemap_2->draw(bitmap, cliprect, 0, 0);
1028               if (layers_ctrl & 2)    state->m_tilemap_3->draw(bitmap, cliprect, 0, 0);
1020               if (layers_ctrl & 2)    m_tilemap_2->draw(bitmap, cliprect, 0, 0);
1021               if (layers_ctrl & 2)    m_tilemap_3->draw(bitmap, cliprect, 0, 0);
10291022            }
10301023         }
10311024
1032         if (layers_ctrl & 8)        screen.machine().device<seta001_device>("spritegen")->seta001_draw_sprites(screen.machine(),bitmap,cliprect,sprite_bank_size, sprite_setac);
1025         if (layers_ctrl & 8) machine().device<seta001_device>("spritegen")->seta001_draw_sprites(screen.machine(),bitmap,cliprect,sprite_bank_size, sprite_setac);
10331026      }
10341027   }
10351028
r20977r20978
10651058
10661059UINT32 seta_state::screen_update_seta(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
10671060{
1068   set_pens(machine());
1061   set_pens();
10691062   return screen_update_seta_layers(screen, bitmap, cliprect);
10701063}
10711064
10721065
10731066UINT32 seta_state::screen_update_usclssic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
10741067{
1075   usclssic_set_pens(machine());
1068   usclssic_set_pens();
10761069   return screen_update_seta_layers(screen, bitmap, cliprect);
10771070}
10781071
trunk/src/mame/video/skykid.c
r20977r20978
176176***************************************************************************/
177177
178178/* the sprite generator IC is the same as Mappy */
179static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
179void skykid_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
180180{
181   skykid_state *state = machine.driver_data<skykid_state>();
182   UINT8 *spriteram = state->m_spriteram + 0x780;
181   UINT8 *spriteram = m_spriteram + 0x780;
183182   UINT8 *spriteram_2 = spriteram + 0x0800;
184183   UINT8 *spriteram_3 = spriteram_2 + 0x0800;
185184   int offs;
r20977r20978
204203      sprite &= ~sizex;
205204      sprite &= ~(sizey << 1);
206205
207      if (state->flip_screen())
206      if (flip_screen())
208207      {
209208         flipx ^= 1;
210209         flipy ^= 1;
r20977r20978
217216      {
218217         for (x = 0;x <= sizex;x++)
219218         {
220            drawgfx_transmask(bitmap,cliprect,machine.gfx[2],
219            drawgfx_transmask(bitmap,cliprect,machine().gfx[2],
221220               sprite + gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)],
222221               color,
223222               flipx,flipy,
224223               sx + 16*x,sy + 16*y,
225               colortable_get_transpen_mask(machine.colortable, machine.gfx[2], color, 0xff));
224               colortable_get_transpen_mask(machine().colortable, machine().gfx[2], color, 0xff));
226225         }
227226      }
228227   }
r20977r20978
252251      // draw low priority tiles
253252      m_tx_tilemap->draw(bitmap, cliprect, pri, 0);
254253
255      draw_sprites(machine(), bitmap, cliprect);
254      draw_sprites(bitmap, cliprect);
256255
257256      // draw the other tiles
258257      for (cat = 0; cat < 0xf; cat++)
r20977r20978
260259   }
261260   else
262261   {
263      draw_sprites(machine(), bitmap, cliprect);
262      draw_sprites(bitmap, cliprect);
264263      m_tx_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_ALL_CATEGORIES, 0);
265264   }
266265
trunk/src/mame/video/sprint8.c
r20977r20978
2828}
2929
3030
31static void set_pens(sprint8_state *state, colortable_t *colortable)
31void sprint8_state::set_pens(sprint8_state *state, colortable_t *colortable)
3232{
3333   int i;
3434
3535   for (i = 0; i < 0x10; i += 8)
3636   {
37      if (*state->m_team & 1)
37      if (*m_team & 1)
3838      {
3939         colortable_palette_set_color(colortable, i + 0, MAKE_RGB(0xff, 0x00, 0x00)); /* red     */
4040         colortable_palette_set_color(colortable, i + 1, MAKE_RGB(0x00, 0x00, 0xff)); /* blue    */
r20977r20978
124124}
125125
126126
127static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
127void sprint8_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
128128{
129   sprint8_state *state = machine.driver_data<sprint8_state>();
130129   int i;
131130
132131   for (i = 0; i < 16; i++)
133132   {
134      UINT8 code = state->m_pos_d_ram[i];
133      UINT8 code = m_pos_d_ram[i];
135134
136      int x = state->m_pos_h_ram[i];
137      int y = state->m_pos_v_ram[i];
135      int x = m_pos_h_ram[i];
136      int y = m_pos_v_ram[i];
138137
139138      if (code & 0x80)
140139         x |= 0x100;
141140
142      drawgfx_transpen(bitmap, cliprect, machine.gfx[2],
141      drawgfx_transpen(bitmap, cliprect, machine().gfx[2],
143142         code ^ 7,
144143         i,
145144         !(code & 0x10), !(code & 0x08),
r20977r20978
150149
151150TIMER_CALLBACK_MEMBER(sprint8_state::sprint8_collision_callback)
152151{
153   sprint8_set_collision(machine(), param);
152   sprint8_set_collision(param);
154153}
155154
156155
r20977r20978
158157{
159158   set_pens(this, machine().colortable);
160159   m_tilemap1->draw(bitmap, cliprect, 0, 0);
161   draw_sprites(machine(), bitmap, cliprect);
160   draw_sprites(bitmap, cliprect);
162161   return 0;
163162}
164163
r20977r20978
176175
177176      m_helper1.fill(0x20, visarea);
178177
179      draw_sprites(machine(), m_helper1, visarea);
178      draw_sprites(m_helper1, visarea);
180179
181180      for (y = visarea.min_y; y <= visarea.max_y; y++)
182181      {
trunk/src/mame/video/seibuspi.c
r20977r20978
2323   }
2424}
2525
26void rf2_set_layer_banks(running_machine &machine, int banks)
26void seibuspi_state::rf2_set_layer_banks(int banks)
2727{
28   seibuspi_state *state = machine.driver_data<seibuspi_state>();
29   if (state->m_rf2_layer_bank[0] != BIT(banks,0))
28   if (m_rf2_layer_bank[0] != BIT(banks,0))
3029   {
31      state->m_rf2_layer_bank[0] = BIT(banks,0);
32      state->m_back_layer->mark_all_dirty();
30      m_rf2_layer_bank[0] = BIT(banks,0);
31      m_back_layer->mark_all_dirty();
3332   }
3433
35   if (state->m_rf2_layer_bank[1] != BIT(banks,1))
34   if (m_rf2_layer_bank[1] != BIT(banks,1))
3635   {
37      state->m_rf2_layer_bank[1] = BIT(banks,1);
38      state->m_mid_layer->mark_all_dirty();
36      m_rf2_layer_bank[1] = BIT(banks,1);
37      m_mid_layer->mark_all_dirty();
3938   }
4039
41   if (state->m_rf2_layer_bank[2] != BIT(banks,2))
40   if (m_rf2_layer_bank[2] != BIT(banks,2))
4241   {
43      state->m_rf2_layer_bank[2] = BIT(banks,2);
44      state->m_fore_layer->mark_all_dirty();
42      m_rf2_layer_bank[2] = BIT(banks,2);
43      m_fore_layer->mark_all_dirty();
4544   }
4645}
4746
r20977r20978
209208   COMBINE_DATA( &m_video_dma_address );
210209}
211210
212static void drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy)
213{
214   seibuspi_state *state = gfx->machine().driver_data<seibuspi_state>();
211void seibuspi_state::drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy)
212{   
215213   const pen_t *pens = &gfx->machine().pens[gfx->colorbase()];
216214   const UINT8 *dp;
217215   int i, j;
r20977r20978
298296   for (j=y1; j <= y2; j++)
299297   {
300298      UINT32 *p = &bitmap.pix32(j);
301      UINT8 trans_pen = (1 << state->m_sprite_bpp) - 1;
299      UINT8 trans_pen = (1 << m_sprite_bpp) - 1;
302300      int dp_i = (py * width) + px;
303301      py += yd;
304302
r20977r20978
307305         UINT8 pen = dp[dp_i];
308306         if (pen != trans_pen)
309307         {
310            int global_pen = pen + (color << state->m_sprite_bpp);
311            UINT8 alpha = state->m_alpha_table[global_pen];
308            int global_pen = pen + (color << m_sprite_bpp);
309            UINT8 alpha = m_alpha_table[global_pen];
312310            if (alpha)
313311            {
314312               p[i] = alpha_blend_r32(p[i], pens[global_pen], 0x7f);
r20977r20978
334332   { 7*16, 6*16, 5*16, 4*16, 3*16, 2*16, 1*16, 0*16 }
335333};
336334
337static void draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int pri_mask)
335void seibuspi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int pri_mask)
338336{
339   seibuspi_state *state = machine.driver_data<seibuspi_state>();
340337   INT16 xpos, ypos;
341338   int tile_num, color;
342339   int width, height;
r20977r20978
344341   int a;
345342   int priority;
346343   int x,y, x1, y1;
347   gfx_element *gfx = machine.gfx[2];
344   gfx_element *gfx = machine().gfx[2];
348345
349   if( state->m_layer_enable & 0x10 )
346   if( m_layer_enable & 0x10 )
350347      return;
351348
352   for( a = (state->m_sprite_dma_length / 4) - 2; a >= 0; a -= 2 ) {
353      tile_num = (state->m_sprite_ram[a + 0] >> 16) & 0xffff;
354      if( state->m_sprite_ram[a + 1] & 0x1000 )
349   for( a = (m_sprite_dma_length / 4) - 2; a >= 0; a -= 2 ) {
350      tile_num = (m_sprite_ram[a + 0] >> 16) & 0xffff;
351      if( m_sprite_ram[a + 1] & 0x1000 )
355352         tile_num |= 0x10000;
356353
357354      if( !tile_num )
358355         continue;
359356
360      priority = (state->m_sprite_ram[a + 0] >> 6) & 0x3;
357      priority = (m_sprite_ram[a + 0] >> 6) & 0x3;
361358      if( pri_mask != priority )
362359         continue;
363360
364      xpos = state->m_sprite_ram[a + 1] & 0x3ff;
361      xpos = m_sprite_ram[a + 1] & 0x3ff;
365362      if( xpos & 0x200 )
366363         xpos |= 0xfc00;
367      ypos = (state->m_sprite_ram[a + 1] >> 16) & 0x1ff;
364      ypos = (m_sprite_ram[a + 1] >> 16) & 0x1ff;
368365      if( ypos & 0x100 )
369366         ypos |= 0xfe00;
370      color = (state->m_sprite_ram[a + 0] & 0x3f);
367      color = (m_sprite_ram[a + 0] & 0x3f);
371368
372      width = ((state->m_sprite_ram[a + 0] >> 8) & 0x7) + 1;
373      height = ((state->m_sprite_ram[a + 0] >> 12) & 0x7) + 1;
374      flip_x = (state->m_sprite_ram[a + 0] >> 11) & 0x1;
375      flip_y = (state->m_sprite_ram[a + 0] >> 15) & 0x1;
369      width = ((m_sprite_ram[a + 0] >> 8) & 0x7) + 1;
370      height = ((m_sprite_ram[a + 0] >> 12) & 0x7) + 1;
371      flip_x = (m_sprite_ram[a + 0] >> 11) & 0x1;
372      flip_y = (m_sprite_ram[a + 0] >> 15) & 0x1;
376373      x1 = 0;
377374      y1 = 0;
378375
r20977r20978
520517}
521518
522519#ifdef UNUSED_FUNCTION
523static void set_rowscroll(tilemap_t *layer, int scroll, INT16* rows)
520void seibuspi_state::set_rowscroll(tilemap_t *layer, int scroll, INT16* rows)
524521{
525   seibuspi_state *state = machine.driver_data<seibuspi_state>();
526522   int i;
527   int x = state->m_spi_scrollram[scroll] & 0xffff;
528   int y = (state->m_spi_scrollram[scroll] >> 16) & 0xffff;
523   int x = m_spi_scrollram[scroll] & 0xffff;
524   int y = (m_spi_scrollram[scroll] >> 16) & 0xffff;
529525   layer->set_scroll_rows(512);
530526   for( i=0; i < 512; i++ ) {
531527      layer->set_scrollx(i, x + rows[i]);
r20977r20978
533529   layer->set_scrolly(0, y);
534530}
535531
536static void set_scroll(tilemap_t *layer, int scroll)
532void seibuspi_state::set_scroll(tilemap_t *layer, int scroll)
537533{
538   seibuspi_state *state = machine.driver_data<seibuspi_state>();
539   int x = state->m_spi_scrollram[scroll] & 0xffff;
540   int y = (state->m_spi_scrollram[scroll] >> 16) & 0xffff;
534   int x = m_spi_scrollram[scroll] & 0xffff;
535   int y = (m_spi_scrollram[scroll] >> 16) & 0xffff;
541536   layer->set_scrollx(0, x);
542537   layer->set_scrolly(0, y);
543538}
544539#endif
545540
546541
547static void combine_tilemap(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tile, int x, int y, int opaque, INT16 *rowscroll)
542void seibuspi_state::combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tile, int x, int y, int opaque, INT16 *rowscroll)
548543{
549   seibuspi_state *state = machine.driver_data<seibuspi_state>();
550544   int i,j;
551545   UINT16 *s;
552546   UINT32 *d;
r20977r20978
574568         if (opaque || (t[i & xscroll_mask] & (TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1)))
575569         {
576570            UINT16 pen = s[i & xscroll_mask];
577            UINT8 alpha = state->m_alpha_table[pen];
571            UINT8 alpha = m_alpha_table[pen];
578572            if (alpha)
579573            {
580               *d = alpha_blend_r32(*d, machine.pens[pen], 0x7f);
574               *d = alpha_blend_r32(*d, machine().pens[pen], 0x7f);
581575            }
582576            else
583577            {
584               *d = machine.pens[pen];
578               *d = machine().pens[pen];
585579            }
586580         }
587581         ++d;
r20977r20978
608602      bitmap.fill(0, cliprect);
609603
610604   if (!(m_layer_enable & 0x1))
611      combine_tilemap(machine(), bitmap, cliprect, m_back_layer, m_spi_scrollram[0] & 0xffff, (m_spi_scrollram[0] >> 16) & 0xffff, 1, back_rowscroll);
605      combine_tilemap(bitmap, cliprect, m_back_layer, m_spi_scrollram[0] & 0xffff, (m_spi_scrollram[0] >> 16) & 0xffff, 1, back_rowscroll);
612606
613   draw_sprites(machine(), bitmap, cliprect, 0);
607   draw_sprites(bitmap, cliprect, 0);
614608
615609   // if fore layer is enabled, draw priority 1 sprites behind mid layer
616610   if (!(m_layer_enable & 0x4))
617      draw_sprites(machine(), bitmap, cliprect, 1);
611      draw_sprites(bitmap, cliprect, 1);
618612
619613   if (!(m_layer_enable & 0x2))
620      combine_tilemap(machine(), bitmap, cliprect, m_mid_layer, m_spi_scrollram[1] & 0xffff, (m_spi_scrollram[1] >> 16) & 0xffff, 0, mid_rowscroll);
614      combine_tilemap(bitmap, cliprect, m_mid_layer, m_spi_scrollram[1] & 0xffff, (m_spi_scrollram[1] >> 16) & 0xffff, 0, mid_rowscroll);
621615
622616   // if fore layer is disabled, draw priority 1 sprites above mid layer
623617   if ((m_layer_enable & 0x4))
624      draw_sprites(machine(), bitmap, cliprect, 1);
618      draw_sprites(bitmap, cliprect, 1);
625619
626   draw_sprites(machine(), bitmap, cliprect, 2);
620   draw_sprites(bitmap, cliprect, 2);
627621
628622   if (!(m_layer_enable & 0x4))
629      combine_tilemap(machine(), bitmap, cliprect, m_fore_layer, m_spi_scrollram[2] & 0xffff, (m_spi_scrollram[2] >> 16) & 0xffff, 0, fore_rowscroll);
623      combine_tilemap(bitmap, cliprect, m_fore_layer, m_spi_scrollram[2] & 0xffff, (m_spi_scrollram[2] >> 16) & 0xffff, 0, fore_rowscroll);
630624
631   draw_sprites(machine(), bitmap, cliprect, 3);
625   draw_sprites(bitmap, cliprect, 3);
632626
633   combine_tilemap(machine(), bitmap, cliprect, m_text_layer, 0, 0, 0, NULL);
627   combine_tilemap(bitmap, cliprect, m_text_layer, 0, 0, 0, NULL);
634628   return 0;
635629}
636630
r20977r20978
655649UINT32 seibuspi_state::screen_update_sys386f2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
656650{
657651   bitmap.fill(0, cliprect);
658   draw_sprites(machine(), bitmap, cliprect, 0);
659   draw_sprites(machine(), bitmap, cliprect, 1);
660   draw_sprites(machine(), bitmap, cliprect, 2);
661   draw_sprites(machine(), bitmap, cliprect, 3);
652   draw_sprites(bitmap, cliprect, 0);
653   draw_sprites(bitmap, cliprect, 1);
654   draw_sprites(bitmap, cliprect, 2);
655   draw_sprites(bitmap, cliprect, 3);
662656   return 0;
663657}
trunk/src/mame/video/suprnova.c
r20977r20978
66
77
88/* draws ROZ with linescroll OR columnscroll to 16-bit indexed bitmap */
9static void suprnova_draw_roz(bitmap_ind16 &bitmap, bitmap_ind8& bitmapflags, const rectangle &cliprect, tilemap_t *tmap, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound, int columnscroll, UINT32* scrollram)
9void skns_state::suprnova_draw_roz(bitmap_ind16 &bitmap, bitmap_ind8& bitmapflags, const rectangle &cliprect, tilemap_t *tmap, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound, int columnscroll, UINT32* scrollram)
1010{
1111   //bitmap_ind16 *destbitmap = bitmap;
1212   bitmap_ind16 &srcbitmap = tmap->pixmap();
r20977r20978
217217}
218218
219219
220static void palette_set_rgb_brightness (running_machine &machine, int offset, UINT8 brightness_r, UINT8 brightness_g, UINT8 brightness_b)
220void skns_state::palette_set_rgb_brightness (int offset, UINT8 brightness_r, UINT8 brightness_g, UINT8 brightness_b)
221221{
222   skns_state *state = machine.driver_data<skns_state>();
223222   int use_bright, r, g, b/*, alpha*/;
224223
225   b = ((state->m_palette_ram[offset] >> 0  ) & 0x1f);
226   g = ((state->m_palette_ram[offset] >> 5  ) & 0x1f);
227   r = ((state->m_palette_ram[offset] >> 10  ) & 0x1f);
224   b = ((m_palette_ram[offset] >> 0  ) & 0x1f);
225   g = ((m_palette_ram[offset] >> 5  ) & 0x1f);
226   r = ((m_palette_ram[offset] >> 10  ) & 0x1f);
228227
229   //alpha = ((state->m_palette_ram[offset] >> 15  ) & 0x1);
228   //alpha = ((m_palette_ram[offset] >> 15  ) & 0x1);
230229
231230   if(offset<(0x40*256)) { // 1st half is for Sprites
232      use_bright = state->m_use_spc_bright;
231      use_bright = m_use_spc_bright;
233232   } else { // V3 bg's
234      use_bright = state->m_use_v3_bright;
233      use_bright = m_use_v3_bright;
235234   }
236235
237236   if(use_bright) {
r20977r20978
247246      r <<= 3;
248247   }
249248
250   palette_set_color(machine,offset,MAKE_RGB(r,g,b));
249   palette_set_color(machine(),offset,MAKE_RGB(r,g,b));
251250}
252251
253252
254static void palette_update(running_machine &machine)
253void skns_state::palette_update()
255254{
256   skns_state *state = machine.driver_data<skns_state>();
257255   int i;
258256
259   if (state->m_palette_updated)
257   if (m_palette_updated)
260258   {
261      if(state->m_spc_changed)
259      if(m_spc_changed)
262260         for(i=0; i<=((0x40*256)-1); i++)
263            palette_set_rgb_brightness (machine, i, state->m_bright_spc_r, state->m_bright_spc_g, state->m_bright_spc_b);
261            palette_set_rgb_brightness (i, m_bright_spc_r, m_bright_spc_g, m_bright_spc_b);
264262
265      if(state->m_v3_changed)
263      if(m_v3_changed)
266264         for(i=(0x40*256); i<=((0x80*256)-1); i++)
267            palette_set_rgb_brightness (machine, i, state->m_bright_v3_r, state->m_bright_v3_g, state->m_bright_v3_b);
268      state->m_palette_updated =0;
265            palette_set_rgb_brightness (i, m_bright_v3_r, m_bright_v3_g, m_bright_v3_b);
266      m_palette_updated =0;
269267   }
270268}
271269
r20977r20978
380378   m_alt_enable_background = m_alt_enable_sprites = 1;
381379}
382380
383static void supernova_draw_a( running_machine &machine, bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_flags, const rectangle &cliprect, int tran )
381void skns_state::supernova_draw_a( bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_flags, const rectangle &cliprect, int tran )
384382{
385   skns_state *state = machine.driver_data<skns_state>();
386   int enable_a  = (state->m_v3_regs[0x10/4] >> 0) & 0x0001;
387   int nowrap_a = (state->m_v3_regs[0x10/4] >> 0) & 0x0004;
383   int enable_a  = (m_v3_regs[0x10/4] >> 0) & 0x0001;
384   int nowrap_a = (m_v3_regs[0x10/4] >> 0) & 0x0004;
388385
389386
390387   UINT32 startx,starty;
r20977r20978
393390
394391   //if(nowrap_a) printf("a\n");
395392
396   if (enable_a && state->m_alt_enable_background)
393   if (enable_a && m_alt_enable_background)
397394   {
398      startx = state->m_v3_regs[0x1c/4];
399      incyy  = state->m_v3_regs[0x30/4]&0x7ffff;
395      startx = m_v3_regs[0x1c/4];
396      incyy  = m_v3_regs[0x30/4]&0x7ffff;
400397      if (incyy&0x40000) incyy = incyy-0x80000; // level 3 boss in sengekis
401      incyx  = state->m_v3_regs[0x2c/4];
402      starty = state->m_v3_regs[0x20/4];
403      incxy  = state->m_v3_regs[0x28/4];
404      incxx  = state->m_v3_regs[0x24/4]&0x7ffff;
398      incyx  = m_v3_regs[0x2c/4];
399      starty = m_v3_regs[0x20/4];
400      incxy  = m_v3_regs[0x28/4];
401      incxx  = m_v3_regs[0x24/4]&0x7ffff;
405402      if (incxx&0x40000) incxx = incxx-0x80000;
406403
407      columnscroll = (state->m_v3_regs[0x0c/4] >> 1) & 0x0001;
404      columnscroll = (m_v3_regs[0x0c/4] >> 1) & 0x0001;
408405
409      suprnova_draw_roz(bitmap,bitmap_flags,cliprect, state->m_tilemap_A, startx << 8,starty << 8,    incxx << 8,incxy << 8,incyx << 8,incyy << 8, !nowrap_a, columnscroll, &state->m_v3slc_ram[0]);
410      //tilemap_copy_bitmap(bitmap, state->m_tilemap_bitmap_lower, state->m_tilemap_bitmapflags_lower);
406      suprnova_draw_roz(bitmap,bitmap_flags,cliprect, m_tilemap_A, startx << 8,starty << 8,    incxx << 8,incxy << 8,incyx << 8,incyy << 8, !nowrap_a, columnscroll, &m_v3slc_ram[0]);
407      //tilemap_copy_bitmap(bitmap, m_tilemap_bitmap_lower, m_tilemap_bitmapflags_lower);
411408   }
412409}
413410
414static void supernova_draw_b( running_machine &machine, bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_flags, const rectangle &cliprect, int tran )
411void skns_state::supernova_draw_b( bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_flags, const rectangle &cliprect, int tran )
415412{
416   skns_state *state = machine.driver_data<skns_state>();
417   int enable_b  = (state->m_v3_regs[0x34/4] >> 0) & 0x0001;
418   int nowrap_b = (state->m_v3_regs[0x34/4] >> 0) & 0x0004;
413   int enable_b  = (m_v3_regs[0x34/4] >> 0) & 0x0001;
414   int nowrap_b = (m_v3_regs[0x34/4] >> 0) & 0x0004;
419415
420416
421417   UINT32 startx,starty;
r20977r20978
424420
425421   //if(nowrap_b) printf("b\n");
426422
427   if (enable_b && state->m_alt_enable_background)
423   if (enable_b && m_alt_enable_background)
428424   {
429      startx = state->m_v3_regs[0x40/4];
430      incyy  = state->m_v3_regs[0x54/4]&0x7ffff;
425      startx = m_v3_regs[0x40/4];
426      incyy  = m_v3_regs[0x54/4]&0x7ffff;
431427      if (incyy&0x40000) incyy = incyy-0x80000;
432      incyx  = state->m_v3_regs[0x50/4];
433      starty = state->m_v3_regs[0x44/4];
434      incxy  = state->m_v3_regs[0x4c/4];
435      incxx  = state->m_v3_regs[0x48/4]&0x7ffff;
428      incyx  = m_v3_regs[0x50/4];
429      starty = m_v3_regs[0x44/4];
430      incxy  = m_v3_regs[0x4c/4];
431      incxx  = m_v3_regs[0x48/4]&0x7ffff;
436432      if (incxx&0x40000) incxx = incxx-0x80000;
437      columnscroll = (state->m_v3_regs[0x0c/4] >> 9) & 0x0001; // selects column scroll or rowscroll
438      suprnova_draw_roz(bitmap,bitmap_flags, cliprect, state->m_tilemap_B, startx << 8,starty << 8,   incxx << 8,incxy << 8,incyx << 8,incyy << 8, !nowrap_b, columnscroll, &state->m_v3slc_ram[0x1000/4]);
433      columnscroll = (m_v3_regs[0x0c/4] >> 9) & 0x0001; // selects column scroll or rowscroll
434      suprnova_draw_roz(bitmap,bitmap_flags, cliprect, m_tilemap_B, startx << 8,starty << 8,   incxx << 8,incxy << 8,incyx << 8,incyy << 8, !nowrap_b, columnscroll, &m_v3slc_ram[0x1000/4]);
439435
440436      //popmessage("%08x %08x %08x %08x %08x %08x", startx, starty, incxx, incyy, incxy, incyx);
441437
r20977r20978
444440
445441UINT32 skns_state::screen_update_skns(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
446442{
447   palette_update(machine());
443   palette_update();
448444
449445   bitmap.fill(get_black_pen(machine()), cliprect);
450446   m_tilemap_bitmap_lower.fill(0);
r20977r20978
463459      //popmessage("pri %d %d\n", supernova_pri_a, supernova_pri_b);
464460
465461      /*if (!supernova_pri_b) { */
466      supernova_draw_b(machine(), m_tilemap_bitmap_lower, m_tilemap_bitmapflags_lower, cliprect,tran);// tran = 1;
467      supernova_draw_a(machine(), m_tilemap_bitmap_higher,m_tilemap_bitmapflags_higher,cliprect,tran);// tran = 1;
462      supernova_draw_b(m_tilemap_bitmap_lower, m_tilemap_bitmapflags_lower, cliprect,tran);// tran = 1;
463      supernova_draw_a(m_tilemap_bitmap_higher,m_tilemap_bitmapflags_higher,cliprect,tran);// tran = 1;
468464
469465      {
470466         int x,y;
trunk/src/mame/video/shootout.c
r20977r20978
8484   m_foreground->set_transparent_pen(0 );
8585}
8686
87static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_bits )
87void shootout_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_bits )
8888{
89   shootout_state *state = machine.driver_data<shootout_state>();
90   UINT8 *spriteram = state->m_spriteram;
91   gfx_element *gfx = machine.gfx[1];
89   UINT8 *spriteram = m_spriteram;
90   gfx_element *gfx = machine().gfx[1];
9291   const UINT8 *source = spriteram+127*4;
9392   int count;
9493
95   state->m_bFlicker = !state->m_bFlicker;
94   m_bFlicker = !m_bFlicker;
9695
9796   for( count=0; count<128; count++ )
9897   {
r20977r20978
107106          -------x    enable
108107      */
109108      if ( attributes & 0x01 ){ /* visible */
110         if( state->m_bFlicker || (attributes&0x02)==0 ){
109         if( m_bFlicker || (attributes&0x02)==0 ){
111110            int priority_mask = (attributes&0x08)?0x2:0;
112111            int sx = (240 - source[2])&0xff;
113112            int sy = (240 - source[0])&0xff;
r20977r20978
116115            int flipx = (attributes & 0x04);
117116            int flipy = 0;
118117
119            if (state->flip_screen()) {
118            if (flip_screen()) {
120119               flipx = !flipx;
121120               flipy = !flipy;
122121            }
r20977r20978
127126
128127               vx = sx;
129128               vy = sy;
130               if (state->flip_screen()) {
129               if (flip_screen()) {
131130                  vx = 240 - vx;
132131                  vy = 240 - vy;
133132               }
r20977r20978
137136                  0 /*color*/,
138137                  flipx,flipy,
139138                  vx,vy,
140                  machine.priority_bitmap,
139                  machine().priority_bitmap,
141140                  priority_mask,0);
142141
143142               number++;
r20977r20978
146145
147146            vx = sx;
148147            vy = sy;
149            if (state->flip_screen()) {
148            if (flip_screen()) {
150149               vx = 240 - vx;
151150               vy = 240 - vy;
152151            }
r20977r20978
156155                  0 /*color*/,
157156                  flipx,flipy,
158157                  vx,vy,
159                  machine.priority_bitmap,
158                  machine().priority_bitmap,
160159                  priority_mask,0);
161160         }
162161      }
r20977r20978
170169
171170   m_background->draw(bitmap, cliprect, 0,0);
172171   m_foreground->draw(bitmap, cliprect, 0,1);
173   draw_sprites(machine(), bitmap,cliprect,3/*bank bits */);
172   draw_sprites(bitmap,cliprect,3/*bank bits */);
174173   return 0;
175174}
176175
r20977r20978
180179
181180   m_background->draw(bitmap, cliprect, 0,0);
182181   m_foreground->draw(bitmap, cliprect, 0,1);
183   draw_sprites(machine(), bitmap,cliprect,2/*bank bits*/);
182   draw_sprites(bitmap,cliprect,2/*bank bits*/);
184183   return 0;
185184}
trunk/src/mame/video/suna8.c
r20977r20978
218218
219219***************************************************************************/
220220
221static void draw_normal_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int which)
221void suna8_state::draw_normal_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect, int which)
222222{
223   suna8_state *state = machine.driver_data<suna8_state>();
224223
225   UINT8 *spriteram = state->m_spriteram + which * 0x2000 * 2;
224   UINT8 *spriteram = m_spriteram + which * 0x2000 * 2;
226225
227226   int i;
228227   int mx = 0; // multisprite x counter
229228
230   int max_x = machine.primary_screen->width() - 8;
231   int max_y = machine.primary_screen->height() - 8;
229   int max_x = machine().primary_screen->width() - 8;
230   int max_y = machine().primary_screen->height() - 8;
232231
233232   for (i = 0x1d00; i < 0x2000; i += 4)
234233   {
r20977r20978
240239      int x       =   spriteram[i + 2];
241240      int bank    =   spriteram[i + 3];
242241
243      if (state->m_text_dim)
242      if (m_text_dim)
244243      {
245244         // Older, simpler hardware: hardhead, rranger
246245         flipx = 0;
r20977r20978
292291            srcy  = (((bank & 0x80)>>4) + (bank & 0x04) + ((~bank >> 4)&2)) * 2;
293292            srcpg = ((code >> 4) & 3) + 4;
294293            gfxbank = (bank & 0x3);
295            switch (state->m_gfxbank_type)
294            switch (m_gfxbank_type)
296295            {
297296               case suna8_state::GFXBANK_TYPE_SPARKMAN:
298297                  break;
r20977r20978
314313                  //      70 56/8/a/c 0e 01 (gfxhi=1)
315314                  //      6f 78/a/c/e 0f 04 ""
316315                  if (gfxbank == 3)
317                     gfxbank += state->m_gfxbank;
316                     gfxbank += m_gfxbank;
318317                  break;
319318            }
320319            colorbank = (bank & 8) >> 3;
r20977r20978
328327            srcy  = (((bank & 0x80)>>4) + (bank & 0x04) + ((~bank >> 4)&3)) * 2;
329328            srcpg = (code >> 4) & 3;
330329            gfxbank = bank & 0x03;
331            switch (state->m_gfxbank_type)
330            switch (m_gfxbank_type)
332331            {
333332               case suna8_state::GFXBANK_TYPE_STARFIGH:
334333                  // starfigh: boss 2 tail, p2 g7:
335334                  //      61 20 1b 27
336335                  if (gfxbank == 3)
337                     gfxbank += state->m_gfxbank;
336                     gfxbank += m_gfxbank;
338337               break;
339338
340339               default:
r20977r20978
374373            if (flipx)  tile_flipx = !tile_flipx;
375374            if (flipy)  tile_flipy = !tile_flipy;
376375
377            if (state->flip_screen())
376            if (flip_screen())
378377            {
379378               sx = max_x - sx;    tile_flipx = !tile_flipx;
380379               sy = max_y - sy;    tile_flipy = !tile_flipy;
381380            }
382381
383            drawgfx_transpen(   bitmap, cliprect, machine.gfx[which],
382            drawgfx_transpen(   bitmap, cliprect, machine().gfx[which],
384383                     tile + (attr & 0x3)*0x100 + gfxbank,
385                     (((attr >> 2) & 0xf) | colorbank) + 0x10 * state->m_palettebank,    // hardhea2 player2
384                     (((attr >> 2) & 0xf) | colorbank) + 0x10 * m_palettebank,    // hardhea2 player2
386385                     tile_flipx, tile_flipy,
387386                     sx, sy, 0xf);
388387         }
r20977r20978
391390   }
392391}
393392
394static void draw_text_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
393void suna8_state::draw_text_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
395394{
396   suna8_state *state = machine.driver_data<suna8_state>();
397   UINT8 *spriteram = state->m_spriteram;
395   UINT8 *spriteram = m_spriteram;
398396   int i;
399397
400   int max_x = machine.primary_screen->width() - 8;
401   int max_y = machine.primary_screen->height() - 8;
398   int max_x = machine().primary_screen->width() - 8;
399   int max_y = machine().primary_screen->height() - 8;
402400
403401   for (i = 0x1900; i < 0x19ff; i += 4)
404402   {
r20977r20978
411409
412410      if (~code & 0x80)   continue;
413411
414      dimx = 2;                   dimy = state->m_text_dim;
412      dimx = 2;                   dimy = m_text_dim;
415413      srcx  = (code & 0xf) * 2;   srcy = (y & 0xf0) / 8;
416414      srcpg = (code >> 4) & 3;
417415
r20977r20978
439437            int sx      =    x + tx * 8;
440438            int sy      =   (y + real_ty * 8) & 0xff;
441439
442            if (state->flip_screen())
440            if (flip_screen())
443441            {
444442               sx = max_x - sx;    flipx = !flipx;
445443               sy = max_y - sy;    flipy = !flipy;
446444            }
447445
448            drawgfx_transpen(   bitmap,cliprect,machine.gfx[0],
446            drawgfx_transpen(   bitmap,cliprect,machine().gfx[0],
449447                     tile + (attr & 0x3)*0x100 + bank,
450448                     (attr >> 2) & 0xf,
451449                     flipx, flipy,
r20977r20978
501499#endif
502500   {
503501      // Normal sprites
504      draw_normal_sprites(machine(), bitmap,cliprect, 0);
502      draw_normal_sprites(bitmap,cliprect, 0);
505503
506504      // More normal sprites (second sprite "chip" in sparkman)
507505      if (machine().gfx[1])
508         draw_normal_sprites(machine(), bitmap,cliprect, 1);
506         draw_normal_sprites(bitmap,cliprect, 1);
509507
510508      // Text sprites (earlier games only)
511509      if (m_text_dim)
512         draw_text_sprites(machine(), bitmap,cliprect);
510         draw_text_sprites(bitmap,cliprect);
513511   }
514512   return 0;
515513}
trunk/src/mame/video/spacefb.c
r20977r20978
9999#define NUM_STARFIELD_PENS  (0x40)
100100
101101
102INLINE void shift_star_generator(spacefb_state *state)
102inline void spacefb_state::shift_star_generator(spacefb_state *state)
103103{
104   state->m_star_shift_reg = ((state->m_star_shift_reg << 1) | (((~state->m_star_shift_reg >> 16) & 0x01) ^ ((state->m_star_shift_reg >> 4) & 0x01))) & 0x1ffff;
104   m_star_shift_reg = ((m_star_shift_reg << 1) | (((~m_star_shift_reg >> 16) & 0x01) ^ ((m_star_shift_reg >> 4) & 0x01))) & 0x1ffff;
105105}
106106
107107
108static void get_starfield_pens(spacefb_state *state, pen_t *pens)
108void spacefb_state::get_starfield_pens(spacefb_state *state, pen_t *pens)
109109{
110110   /* generate the pens based on the various enable bits */
111111   int i;
112112
113   int color_contrast_r   = state->m_port_2 & 0x01;
114   int color_contrast_g   = state->m_port_2 & 0x02;
115   int color_contrast_b   = state->m_port_2 & 0x04;
116   int background_red     = state->m_port_2 & 0x08;
117   int background_blue    = state->m_port_2 & 0x10;
118   int disable_star_field = state->m_port_2 & 0x80;
113   int color_contrast_r   = m_port_2 & 0x01;
114   int color_contrast_g   = m_port_2 & 0x02;
115   int color_contrast_b   = m_port_2 & 0x04;
116   int background_red     = m_port_2 & 0x08;
117   int background_blue    = m_port_2 & 0x10;
118   int disable_star_field = m_port_2 & 0x80;
119119
120120   for (i = 0; i < NUM_STARFIELD_PENS; i++)
121121   {
r20977r20978
126126      UINT8 ra = (((i >> 4) & 0x01) || background_red) && !disable_star_field;
127127      UINT8 rb =  ((i >> 5) & 0x01) && color_contrast_r && !disable_star_field;
128128
129      UINT8 r = combine_3_weights(state->m_color_weights_rg, 0, rb, ra);
130      UINT8 g = combine_3_weights(state->m_color_weights_rg, 0, gb, ga);
131      UINT8 b = combine_2_weights(state->m_color_weights_b,     bb, ba);
129      UINT8 r = combine_3_weights(m_color_weights_rg, 0, rb, ra);
130      UINT8 g = combine_3_weights(m_color_weights_rg, 0, gb, ga);
131      UINT8 b = combine_2_weights(m_color_weights_b,     bb, ba);
132132
133133      pens[i] = MAKE_RGB(r, g, b);
134134   }
135135}
136136
137137
138static void draw_starfield(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
138void spacefb_state::draw_starfield(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
139139{
140140   spacefb_state *state = screen.machine().driver_data<spacefb_state>();
141141   int y;
r20977r20978
162162
163163      for (x = SPACEFB_HBEND; x < SPACEFB_HBSTART; x++)
164164      {
165         if (state->m_object_present_map[(y * bitmap.width()) + x] == 0)
165         if (m_object_present_map[(y * bitmap.width()) + x] == 0)
166166         {
167167            /* draw the star - the 4 possible values come from the effect of the two XOR gates */
168            if (((state->m_star_shift_reg & 0x1c0ff) == 0x0c0b7) ||
169               ((state->m_star_shift_reg & 0x1c0ff) == 0x0c0d7) ||
170               ((state->m_star_shift_reg & 0x1c0ff) == 0x0c0bb) ||
171               ((state->m_star_shift_reg & 0x1c0ff) == 0x0c0db))
172               bitmap.pix32(y, x) = pens[(state->m_star_shift_reg >> 8) & 0x3f];
168            if (((m_star_shift_reg & 0x1c0ff) == 0x0c0b7) ||
169               ((m_star_shift_reg & 0x1c0ff) == 0x0c0d7) ||
170               ((m_star_shift_reg & 0x1c0ff) == 0x0c0bb) ||
171               ((m_star_shift_reg & 0x1c0ff) == 0x0c0db))
172               bitmap.pix32(y, x) = pens[(m_star_shift_reg >> 8) & 0x3f];
173173            else
174174               bitmap.pix32(y, x) = pens[0];
175175         }
r20977r20978
204204#define NUM_SPRITE_PENS (0x40)
205205
206206
207static void get_sprite_pens(running_machine &machine, pen_t *pens)
207void spacefb_state::get_sprite_pens(pen_t *pens)
208208{
209   spacefb_state *state = machine.driver_data<spacefb_state>();
210209   static const double fade_weights[] = { 1.0, 1.5, 2.5, 4.0 };
211   const UINT8 *prom = machine.root_device().memregion("proms")->base();
210   const UINT8 *prom = machine().root_device().memregion("proms")->base();
212211   int i;
213212
214213   for (i = 0; i < NUM_SPRITE_PENS; i++)
215214   {
216      UINT8 data = prom[((state->m_port_0 & 0x40) >> 2) | (i & 0x0f)];
215      UINT8 data = prom[((m_port_0 & 0x40) >> 2) | (i & 0x0f)];
217216
218217      UINT8 r0 = (data >> 0) & 0x01;
219218      UINT8 r1 = (data >> 1) & 0x01;
r20977r20978
226225      UINT8 b1 = (data >> 6) & 0x01;
227226      UINT8 b2 = (data >> 7) & 0x01;
228227
229      UINT8 r = combine_3_weights(state->m_color_weights_rg, r0, r1, r2);
230      UINT8 g = combine_3_weights(state->m_color_weights_rg, g0, g1, g2);
231      UINT8 b = combine_2_weights(state->m_color_weights_b,      b1, b2);
228      UINT8 r = combine_3_weights(m_color_weights_rg, r0, r1, r2);
229      UINT8 g = combine_3_weights(m_color_weights_rg, g0, g1, g2);
230      UINT8 b = combine_2_weights(m_color_weights_b,      b1, b2);
232231
233232      if (i >> 4)
234233      {
r20977r20978
245244}
246245
247246
248static void draw_bullet(running_machine &machine, offs_t offs, pen_t pen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int flip)
247void spacefb_state::draw_bullet(offs_t offs, pen_t pen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int flip)
249248{
250   spacefb_state *state = machine.driver_data<spacefb_state>();
251249   UINT8 sy;
252250
253   UINT8 *gfx = state->memregion("gfx2")->base();
251   UINT8 *gfx = memregion("gfx2")->base();
254252
255   UINT8 code = state->m_videoram[offs + 0x0200] & 0x3f;
256   UINT8 y = ~state->m_videoram[offs + 0x0100] - 2;
253   UINT8 code = m_videoram[offs + 0x0200] & 0x3f;
254   UINT8 y = ~m_videoram[offs + 0x0100] - 2;
257255
258256   for (sy = 0; sy < 4; sy++)
259257   {
260258      UINT8 sx, dy;
261259
262260      UINT8 data = gfx[(code << 2) | sy];
263      UINT8 x = state->m_videoram[offs + 0x0000];
261      UINT8 x = m_videoram[offs + 0x0000];
264262
265263      if (flip)
266264         dy = ~y;
r20977r20978
283281               bitmap.pix32(dy, dx + 0) = pen;
284282               bitmap.pix32(dy, dx + 1) = pen;
285283
286               state->m_object_present_map[(dy * bitmap.width()) + dx + 0] = 1;
287               state->m_object_present_map[(dy * bitmap.width()) + dx + 1] = 1;
284               m_object_present_map[(dy * bitmap.width()) + dx + 0] = 1;
285               m_object_present_map[(dy * bitmap.width()) + dx + 1] = 1;
288286            }
289287
290288            x = x + 1;
r20977r20978
297295}
298296
299297
300static void draw_sprite(running_machine &machine, offs_t offs, pen_t *pens, bitmap_rgb32 &bitmap, const rectangle &cliprect, int flip)
298void spacefb_state::draw_sprite(offs_t offs, pen_t *pens, bitmap_rgb32 &bitmap, const rectangle &cliprect, int flip)
301299{
302   spacefb_state *state = machine.driver_data<spacefb_state>();
303300   UINT8 sy;
304301
305   UINT8 *gfx = state->memregion("gfx1")->base();
302   UINT8 *gfx = memregion("gfx1")->base();
306303
307   UINT8 code = ~state->m_videoram[offs + 0x0200];
308   UINT8 color_base = (~state->m_videoram[offs + 0x0300] & 0x0f) << 2;
309   UINT8 y = ~state->m_videoram[offs + 0x0100] - 2;
304   UINT8 code = ~m_videoram[offs + 0x0200];
305   UINT8 color_base = (~m_videoram[offs + 0x0300] & 0x0f) << 2;
306   UINT8 y = ~m_videoram[offs + 0x0100] - 2;
310307
311308   for (sy = 0; sy < 8; sy++)
312309   {
r20977r20978
315312      UINT8 data1 = gfx[0x0000 | (code << 3) | (sy ^ 0x07)];
316313      UINT8 data2 = gfx[0x0800 | (code << 3) | (sy ^ 0x07)];
317314
318      UINT8 x = state->m_videoram[offs + 0x0000] - 3;
315      UINT8 x = m_videoram[offs + 0x0000] - 3;
319316
320317      if (flip)
321318         dy = ~y;
r20977r20978
341338            bitmap.pix32(dy, dx + 0) = pen;
342339            bitmap.pix32(dy, dx + 1) = pen;
343340
344            state->m_object_present_map[(dy * bitmap.width()) + dx + 0] = (data != 0);
345            state->m_object_present_map[(dy * bitmap.width()) + dx + 1] = (data != 0);
341            m_object_present_map[(dy * bitmap.width()) + dx + 0] = (data != 0);
342            m_object_present_map[(dy * bitmap.width()) + dx + 1] = (data != 0);
346343
347344            x = x + 1;
348345            data1 = data1 >> 1;
r20977r20978
355352}
356353
357354
358static void draw_objects(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
355void spacefb_state::draw_objects(bitmap_rgb32 &bitmap, const rectangle &cliprect)
359356{
360   spacefb_state *state = machine.driver_data<spacefb_state>();
361357   pen_t sprite_pens[NUM_SPRITE_PENS];
362358
363   offs_t offs = (state->m_port_0 & 0x20) ? 0x80 : 0x00;
364   int flip = state->m_port_0 & 0x01;
359   offs_t offs = (m_port_0 & 0x20) ? 0x80 : 0x00;
360   int flip = m_port_0 & 0x01;
365361
366362   /* since the way the schematics show the bullet color
367363      connected is impossible, just use pure red for now */
368364   pen_t bullet_pen = MAKE_RGB(0xff, 0x00, 0x00);
369365
370   get_sprite_pens(machine, sprite_pens);
366   get_sprite_pens(sprite_pens);
371367
372   memset(state->m_object_present_map, 0, bitmap.width() * bitmap.height());
368   memset(m_object_present_map, 0, bitmap.width() * bitmap.height());
373369
374370   while (1)
375371   {
376      if (state->m_videoram[offs + 0x0300] & 0x20)
377         draw_bullet(machine, offs, bullet_pen, bitmap, cliprect, flip);
378      else if (state->m_videoram[offs + 0x0300] & 0x40)
379         draw_sprite(machine, offs, sprite_pens, bitmap, cliprect, flip);
372      if (m_videoram[offs + 0x0300] & 0x20)
373         draw_bullet(offs, bullet_pen, bitmap, cliprect, flip);
374      else if (m_videoram[offs + 0x0300] & 0x40)
375         draw_sprite(offs, sprite_pens, bitmap, cliprect, flip);
380376
381377      /* next object */
382378      offs = offs + 1;
r20977r20978
396392
397393UINT32 spacefb_state::screen_update_spacefb(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
398394{
399   draw_objects(machine(), bitmap, cliprect);
395   draw_objects(bitmap, cliprect);
400396   draw_starfield(screen, bitmap, cliprect);
401397
402398   return 0;
trunk/src/mame/video/shangkid.c
r20977r20978
5757   m_background->mark_tile_dirty(offset&0x7ff );
5858}
5959
60static void draw_sprite(running_machine &machine, const UINT8 *source, bitmap_ind16 &bitmap, const rectangle &cliprect)
60void shangkid_state::draw_sprite(const UINT8 *source, bitmap_ind16 &bitmap, const rectangle &cliprect)
6161{
62   shangkid_state *state = machine.driver_data<shangkid_state>();
6362   gfx_element *gfx;
6463   int transparent_pen;
6564   int bank_index;
r20977r20978
8382   if( xsize==0 && xflip ) xpos -= 16;
8483   if( ysize==0 && yflip==0 ) ypos += 16;
8584
86   if( state->m_gfx_type == 1 )
85   if( m_gfx_type == 1 )
8786   {
8887      /* Shanghai Kid */
8988      switch( bank&0x30 )
r20977r20978
129128      transparent_pen = 7;
130129   }
131130
132   gfx = machine.gfx[1+bank_index];
131   gfx = machine().gfx[1+bank_index];
133132
134133   width = (xscale+1)*2;
135134   height = (yscale+1)*2;
r20977r20978
168167   }
169168}
170169
171static void shangkid_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
170void shangkid_state::shangkid_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
172171{
173   shangkid_state *state = machine.driver_data<shangkid_state>();
174172   const UINT8 *source, *finish;
175173
176   finish = state->m_spriteram;
177   source = state->m_spriteram+0x200;
174   finish = m_spriteram;
175   source = m_spriteram+0x200;
178176   while( source>finish ){
179177      source -= 8;
180      draw_sprite(machine, source, bitmap,cliprect );
178      draw_sprite(source, bitmap,cliprect );
181179   }
182180}
183181
r20977r20978
189187   m_background->set_scrolly(0,m_videoreg[2]+0x10 );
190188
191189   m_background->draw(bitmap, cliprect, 0,0 );
192   shangkid_draw_sprites(machine(), bitmap,cliprect );
190   shangkid_draw_sprites(bitmap,cliprect );
193191   m_background->draw(bitmap, cliprect, 1,0 ); /* high priority tiles */
194192   return 0;
195193}
r20977r20978
231229}
232230
233231
234static void dynamski_draw_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
232void shangkid_state::dynamski_draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
235233{
236   shangkid_state *state = machine.driver_data<shangkid_state>();
237   UINT8 *videoram = state->m_videoram;
234   UINT8 *videoram = m_videoram;
238235   int i;
239236   int sx,sy;
240237   int tile;
r20977r20978
275272         drawgfx_transpen(
276273            bitmap,
277274            cliprect,
278            machine.gfx[0],
275            machine().gfx[0],
279276            tile,
280277            attr & 0x0f,
281278            0,0,//xflip,yflip,
r20977r20978
285282   }
286283}
287284
288static void dynamski_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
285void shangkid_state::dynamski_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
289286{
290   shangkid_state *state = machine.driver_data<shangkid_state>();
291   UINT8 *videoram = state->m_videoram;
287   UINT8 *videoram = m_videoram;
292288   int i;
293289   int sx,sy;
294290   int tile;
r20977r20978
309305      drawgfx_transpen(
310306            bitmap,
311307            cliprect,
312            machine.gfx[1],
308            machine().gfx[1],
313309            bank*0x40 + (tile&0x3f),
314310            color,
315311            tile&0x80,tile&0x40, /* flipx,flipy */
r20977r20978
319315
320316UINT32 shangkid_state::screen_update_dynamski(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
321317{
322   dynamski_draw_background(machine(), bitmap,cliprect, 0 );
323   dynamski_draw_sprites(machine(), bitmap,cliprect );
324   dynamski_draw_background(machine(), bitmap,cliprect, 1 );
318   dynamski_draw_background(bitmap,cliprect, 0 );
319   dynamski_draw_sprites(bitmap,cliprect );
320   dynamski_draw_background(bitmap,cliprect, 1 );
325321   return 0;
326322}
trunk/src/mame/video/sderby.c
r20977r20978
5656}
5757
5858
59static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int codeshift)
59void sderby_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int codeshift)
6060{
61   sderby_state *state = machine.driver_data<sderby_state>();
62   UINT16 *spriteram16 = state->m_spriteram;
61   UINT16 *spriteram16 = m_spriteram;
6362   int offs;
64   int height = machine.gfx[0]->height();
65   int colordiv = machine.gfx[0]->granularity() / 16;
63   int height = machine().gfx[0]->height();
64   int colordiv = machine().gfx[0]->granularity() / 16;
6665
67   for (offs = 4;offs < state->m_spriteram.bytes()/2;offs += 4)
66   for (offs = 4;offs < m_spriteram.bytes()/2;offs += 4)
6867   {
6968      int sx,sy,code,color,flipx;
7069
r20977r20978
7776      code = spriteram16[offs+2] >> codeshift;
7877      color = (spriteram16[offs+1] & 0x3e00) >> 9;
7978
80      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
79      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
8180            code,
8281            color/colordiv+48,
8382            flipx,0,
r20977r20978
10099UINT32 sderby_state::screen_update_sderby(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
101100{
102101   m_tilemap->draw(bitmap, cliprect, 0,0);
103   draw_sprites(machine(), bitmap,cliprect,0);
102   draw_sprites(bitmap,cliprect,0);
104103   m_md_tilemap->draw(bitmap, cliprect, 0,0);
105104   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
106105   return 0;
r20977r20978
110109{
111110   m_tilemap->draw(bitmap, cliprect, 0,0);
112111   m_md_tilemap->draw(bitmap, cliprect, 0,0);
113   draw_sprites(machine(), bitmap,cliprect,0);
112   draw_sprites(bitmap,cliprect,0);
114113   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
115114   return 0;
116115}
trunk/src/mame/video/speedspn.c
r20977r20978
5252}
5353
5454
55static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
55void speedspn_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
5656{
57   speedspn_state *state = machine.driver_data<speedspn_state>();
58   gfx_element *gfx = machine.gfx[1];
59   UINT8 *source = state->m_vidram+ 0x1000;
57   gfx_element *gfx = machine().gfx[1];
58   UINT8 *source = m_vidram+ 0x1000;
6059   UINT8 *finish = source + 0x1000;
6160
6261   while( source<finish )
r20977r20978
104103#endif
105104   m_tilemap->set_scrollx(0, 0x100); // verify
106105   m_tilemap->draw(bitmap, cliprect, 0,0);
107   draw_sprites(machine(), bitmap,cliprect);
106   draw_sprites(bitmap,cliprect);
108107   return 0;
109108}
trunk/src/mame/video/ssrj.c
r20977r20978
224224}
225225
226226
227static void draw_objects(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
227void ssrj_state::draw_objects(bitmap_ind16 &bitmap, const rectangle &cliprect )
228228{
229   ssrj_state *state = machine.driver_data<ssrj_state>();
230229   int i,j,k,x,y;
231230
232231   for(i=0;i<6;i++)
233232   {
234      y = state->m_buffer_spriteram[0x80+20*i];
235      x = state->m_buffer_spriteram[0x80+20*i+2];
236      if (!state->m_buffer_spriteram[0x80+20*i+3])
233      y = m_buffer_spriteram[0x80+20*i];
234      x = m_buffer_spriteram[0x80+20*i+2];
235      if (!m_buffer_spriteram[0x80+20*i+3])
237236      {
238237         for(k=0;k<5;k++,x+=8)
239238         {
r20977r20978
242241               int code;
243242               int offs = (i * 5 + k) * 64 + (31 - j) * 2;
244243
245               code = state->m_vram3[offs] + 256 * state->m_vram3[offs + 1];
244               code = m_vram3[offs] + 256 * m_vram3[offs + 1];
246245               drawgfx_transpen(bitmap,
247                  cliprect,machine.gfx[0],
246                  cliprect,machine().gfx[0],
248247                  code&1023,
249248                  ((code>>12)&0x3)+8,
250249                  code&0x4000,
r20977r20978
272271   m_tilemap1->set_scrollx(0, 0xff-m_scrollram[2] );
273272   m_tilemap1->set_scrolly(0, m_scrollram[0] );
274273   m_tilemap1->draw(bitmap, cliprect, 0, 0);
275   draw_objects(machine(), bitmap, cliprect);
274   draw_objects(bitmap, cliprect);
276275   m_tilemap2->draw(bitmap, cliprect, 0, 0);
277276
278277   if (m_scrollram[0x101] == 0xb) m_tilemap4->draw(bitmap, cliprect, 0, 0);/* hack to display 4th tilemap */
trunk/src/mame/video/seicross.c
r20977r20978
9292   m_bg_tilemap->set_scroll_cols(32);
9393}
9494
95static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
95void seicross_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
9696{
97   seicross_state *state = machine.driver_data<seicross_state>();
98   UINT8 *spriteram = state->m_spriteram;
99   UINT8 *spriteram_2 = state->m_spriteram2;
97   UINT8 *spriteram = m_spriteram;
98   UINT8 *spriteram_2 = m_spriteram2;
10099   int offs;
101100
102   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
101   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
103102   {
104103      int x = spriteram[offs + 3];
105      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
104      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
106105            (spriteram[offs] & 0x3f) + ((spriteram[offs + 1] & 0x10) << 2) + 128,
107106            spriteram[offs + 1] & 0x0f,
108107            spriteram[offs] & 0x40,spriteram[offs] & 0x80,
109108            x,240-spriteram[offs + 2],0);
110109      if(x>0xf0)
111         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
110         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
112111               (spriteram[offs] & 0x3f) + ((spriteram[offs + 1] & 0x10) << 2) + 128,
113112               spriteram[offs + 1] & 0x0f,
114113               spriteram[offs] & 0x40,spriteram[offs] & 0x80,
115114               x-256,240-spriteram[offs + 2],0);
116115   }
117116
118   for (offs = state->m_spriteram2.bytes() - 4; offs >= 0; offs -= 4)
117   for (offs = m_spriteram2.bytes() - 4; offs >= 0; offs -= 4)
119118   {
120119      int x = spriteram_2[offs + 3];
121      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
120      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
122121            (spriteram_2[offs] & 0x3f) + ((spriteram_2[offs + 1] & 0x10) << 2),
123122            spriteram_2[offs + 1] & 0x0f,
124123            spriteram_2[offs] & 0x40,spriteram_2[offs] & 0x80,
125124            x,240-spriteram_2[offs + 2],0);
126125      if(x>0xf0)
127         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
126         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
128127               (spriteram_2[offs] & 0x3f) + ((spriteram_2[offs + 1] & 0x10) << 2),
129128               spriteram_2[offs + 1] & 0x0f,
130129               spriteram_2[offs] & 0x40,spriteram_2[offs] & 0x80,
r20977r20978
140139      m_bg_tilemap->set_scrolly(col, m_row_scroll[col]);
141140
142141   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
143   draw_sprites(machine(), bitmap, cliprect);
142   draw_sprites(bitmap, cliprect);
144143   return 0;
145144}
trunk/src/mame/video/system16.c
r20977r20978
3030#include "video/segaic16.h"
3131
3232
33static void setup_system16_bootleg_spritebanking( running_machine& machine )
33void segas1x_bootleg_state::setup_system16_bootleg_spritebanking(  )
3434{
35   segas1x_bootleg_state *state = machine.driver_data<segas1x_bootleg_state>();
3635
37   if (state->m_spritebank_type == 1)
36   if (m_spritebank_type == 1)
3837   {
3938      static const UINT8 default_banklist[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
4039      int i;
4140      for (i = 0; i < 16; i++)
42         state->m_sprites->set_bank(i, default_banklist[i]);
41         m_sprites->set_bank(i, default_banklist[i]);
4342   }
4443   else
4544   {
4645      static const UINT8 alternate_banklist[] = { 0,255,255,255, 255,255,255,3, 255,255,255,2, 255,1,0,255 };
4746      int i;
4847      for (i = 0; i < 16; i++)
49         state->m_sprites->set_bank(i, alternate_banklist[i]);
48         m_sprites->set_bank(i, alternate_banklist[i]);
5049
5150   }
5251
r20977r20978
159158}
160159#endif
161160
162static void update_page( running_machine &machine )
161void segas1x_bootleg_state::update_page(  )
163162{
164   segas1x_bootleg_state *state = machine.driver_data<segas1x_bootleg_state>();
165163   int all_dirty = 0;
166164   int i, offset;
167165
168   if (state->m_old_tile_bank1 != state->m_tile_bank1)
166   if (m_old_tile_bank1 != m_tile_bank1)
169167   {
170168      all_dirty = 1;
171      state->m_old_tile_bank1 = state->m_tile_bank1;
169      m_old_tile_bank1 = m_tile_bank1;
172170   }
173171
174   if (state->m_old_tile_bank0 != state->m_tile_bank0)
172   if (m_old_tile_bank0 != m_tile_bank0)
175173   {
176174      all_dirty = 1;
177      state->m_old_tile_bank0 = state->m_tile_bank0;
178      state->m_text_layer->mark_all_dirty();
175      m_old_tile_bank0 = m_tile_bank0;
176      m_text_layer->mark_all_dirty();
179177   }
180178
181179   if (all_dirty)
182180   {
183      state->m_background->mark_all_dirty();
184      state->m_foreground->mark_all_dirty();
181      m_background->mark_all_dirty();
182      m_foreground->mark_all_dirty();
185183
186      if (state->m_system18)
184      if (m_system18)
187185      {
188         state->m_background2->mark_all_dirty();
189         state->m_foreground2->mark_all_dirty();
186         m_background2->mark_all_dirty();
187         m_foreground2->mark_all_dirty();
190188      }
191189   }
192190   else {
193191      for (i = 0; i < 4; i++)
194192      {
195193         int page0 = 64 * 32 * i;
196         if (state->m_old_bg_page[i] != state->m_bg_page[i])
194         if (m_old_bg_page[i] != m_bg_page[i])
197195         {
198            state->m_old_bg_page[i] = state->m_bg_page[i];
196            m_old_bg_page[i] = m_bg_page[i];
199197            for (offset = page0; offset < page0 + 64 * 32; offset++)
200198            {
201               state->m_background->mark_tile_dirty(offset);
199               m_background->mark_tile_dirty(offset);
202200            }
203201         }
204202
205         if (state->m_old_fg_page[i] != state->m_fg_page[i])
203         if (m_old_fg_page[i] != m_fg_page[i])
206204         {
207            state->m_old_fg_page[i] = state->m_fg_page[i];
205            m_old_fg_page[i] = m_fg_page[i];
208206            for (offset = page0; offset < page0 + 64 * 32; offset++)
209207            {
210               state->m_foreground->mark_tile_dirty(offset);
208               m_foreground->mark_tile_dirty(offset);
211209            }
212210         }
213211
214         if (state->m_system18)
212         if (m_system18)
215213         {
216            if (state->m_old_bg2_page[i] != state->m_bg2_page[i])
214            if (m_old_bg2_page[i] != m_bg2_page[i])
217215            {
218               state->m_old_bg2_page[i] = state->m_bg2_page[i];
216               m_old_bg2_page[i] = m_bg2_page[i];
219217               for (offset = page0; offset < page0 + 64 * 32; offset++)
220218               {
221                  state->m_background2->mark_tile_dirty(offset);
219                  m_background2->mark_tile_dirty(offset);
222220               }
223221            }
224222
225            if (state->m_old_fg2_page[i] != state->m_fg2_page[i])
223            if (m_old_fg2_page[i] != m_fg2_page[i])
226224            {
227               state->m_old_fg2_page[i] = state->m_fg2_page[i];
225               m_old_fg2_page[i] = m_fg2_page[i];
228226               for (offset = page0; offset < page0 + 64 * 32; offset++)
229227               {
230                  state->m_foreground2->mark_tile_dirty(offset);
228                  m_foreground2->mark_tile_dirty(offset);
231229               }
232230            }
233231         }
r20977r20978
423421      m_system18 = 0;
424422   }
425423
426   setup_system16_bootleg_spritebanking(machine());
424   setup_system16_bootleg_spritebanking();
427425}
428426
429427VIDEO_START_MEMBER(segas1x_bootleg_state,system18old)
r20977r20978
583581VIDEO_START_MEMBER(segas1x_bootleg_state,s16a_bootleg_wb3bl)
584582{
585583   VIDEO_START_CALL_MEMBER(s16a_bootleg);
586   setup_system16_bootleg_spritebanking(machine());
584   setup_system16_bootleg_spritebanking();
587585}
588586
589587VIDEO_START_MEMBER(segas1x_bootleg_state,s16a_bootleg_shinobi)
590588{
591589   VIDEO_START_CALL_MEMBER(s16a_bootleg);
592   setup_system16_bootleg_spritebanking(machine());
590   setup_system16_bootleg_spritebanking();
593591}
594592
595593VIDEO_START_MEMBER(segas1x_bootleg_state,s16a_bootleg_passsht)
596594{
597595   VIDEO_START_CALL_MEMBER(s16a_bootleg);
598   setup_system16_bootleg_spritebanking(machine());
596   setup_system16_bootleg_spritebanking();
599597}
600598
601599// Passing Shot (2 player), Shinobi (Datsu), Wonderboy 3
r20977r20978
769767   // start the sprites drawing
770768   m_sprites->draw_async(cliprect);
771769
772   update_page(machine());
770   update_page();
773771
774772   machine().priority_bitmap.fill(0, cliprect);
775773
r20977r20978
845843   // start the sprites drawing
846844   m_sprites->draw_async(cliprect);
847845
848   update_page(machine());
846   update_page();
849847
850848   machine().priority_bitmap.fill(0);
851849
trunk/src/mame/video/simpsons.c
r20977r20978
9090   else m_xtraram[offset - 0x1000] = data;
9191}
9292
93void simpsons_video_banking( running_machine &machine, int bank )
93void simpsons_state::simpsons_video_banking( int bank )
9494{
95   simpsons_state *state = machine.driver_data<simpsons_state>();
96   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
95   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
9796
9897   if (bank & 1)
9998   {
10099      space.install_read_bank(0x0000, 0x0fff, "bank5");
101      space.install_write_handler(0x0000, 0x0fff, write8_delegate(FUNC(simpsons_state::paletteram_xBBBBBGGGGGRRRRR_byte_be_w), state));
102      state->membank("bank5")->set_base(state->m_generic_paletteram_8);
100      space.install_write_handler(0x0000, 0x0fff, write8_delegate(FUNC(simpsons_state::paletteram_xBBBBBGGGGGRRRRR_byte_be_w), this));
101      membank("bank5")->set_base(m_generic_paletteram_8);
103102   }
104103   else
105      space.install_legacy_readwrite_handler(*state->m_k052109, 0x0000, 0x0fff, FUNC(k052109_r), FUNC(k052109_w));
104      space.install_legacy_readwrite_handler(*m_k052109, 0x0000, 0x0fff, FUNC(k052109_r), FUNC(k052109_w));
106105
107106   if (bank & 2)
108      space.install_readwrite_handler(0x2000, 0x3fff, read8_delegate(FUNC(simpsons_state::simpsons_k053247_r),state), write8_delegate(FUNC(simpsons_state::simpsons_k053247_w),state));
107      space.install_readwrite_handler(0x2000, 0x3fff, read8_delegate(FUNC(simpsons_state::simpsons_k053247_r),this), write8_delegate(FUNC(simpsons_state::simpsons_k053247_w),this));
109108   else
110      space.install_readwrite_handler(0x2000, 0x3fff, read8_delegate(FUNC(simpsons_state::simpsons_k052109_r),state), write8_delegate(FUNC(simpsons_state::simpsons_k052109_w),state));
109      space.install_readwrite_handler(0x2000, 0x3fff, read8_delegate(FUNC(simpsons_state::simpsons_k052109_r),this), write8_delegate(FUNC(simpsons_state::simpsons_k052109_w),this));
111110}
112111
113112
trunk/src/mame/video/starcrus.c
r20977r20978
157157   }
158158}
159159
160static int collision_check_s1s2(running_machine &machine)
160int starcrus_state::collision_check_s1s2()
161161{
162   starcrus_state *state = machine.driver_data<starcrus_state>();
163162   int org_x, org_y;
164163   int sx, sy;
165164   rectangle clip(0, 15, 0, 15);
166165
167   state->m_ship1_vid->fill(0, clip);
168   state->m_ship2_vid->fill(0, clip);
166   m_ship1_vid->fill(0, clip);
167   m_ship2_vid->fill(0, clip);
169168
170169   /* origin is with respect to ship1 */
171170
172   org_x = state->m_s1_x;
173   org_y = state->m_s1_y;
171   org_x = m_s1_x;
172   org_y = m_s1_y;
174173
175174   /* Draw ship 1 */
176   drawgfx_opaque(*state->m_ship1_vid,
175   drawgfx_opaque(*m_ship1_vid,
177176         clip,
178         machine.gfx[8+((state->m_s1_sprite&0x04)>>2)],
179         (state->m_s1_sprite&0x03)^0x03,
177         machine().gfx[8+((m_s1_sprite&0x04)>>2)],
178         (m_s1_sprite&0x03)^0x03,
180179         0,
181         (state->m_s1_sprite&0x08)>>3, (state->m_s1_sprite&0x10)>>4,
182         state->m_s1_x-org_x, state->m_s1_y-org_y);
180         (m_s1_sprite&0x08)>>3, (m_s1_sprite&0x10)>>4,
181         m_s1_x-org_x, m_s1_y-org_y);
183182
184183   /* Draw ship 2 */
185   drawgfx_opaque(*state->m_ship2_vid,
184   drawgfx_opaque(*m_ship2_vid,
186185         clip,
187         machine.gfx[10+((state->m_s2_sprite&0x04)>>2)],
188         (state->m_s2_sprite&0x03)^0x03,
186         machine().gfx[10+((m_s2_sprite&0x04)>>2)],
187         (m_s2_sprite&0x03)^0x03,
189188         0,
190         (state->m_s2_sprite&0x08)>>3, (state->m_s2_sprite&0x10)>>4,
191         state->m_s2_x-org_x, state->m_s2_y-org_y);
189         (m_s2_sprite&0x08)>>3, (m_s2_sprite&0x10)>>4,
190         m_s2_x-org_x, m_s2_y-org_y);
192191
193192   /* Now check for collisions */
194193   for (sy=0;sy<16;sy++)
195194      for (sx=0;sx<16;sx++)
196195      /* Condition 1 - ship 1 = ship 2 */
197      if ((state->m_ship1_vid->pix16(sy, sx) == 1) && (state->m_ship2_vid->pix16(sy, sx) == 1))
196      if ((m_ship1_vid->pix16(sy, sx) == 1) && (m_ship2_vid->pix16(sy, sx) == 1))
198197         return 1;
199198
200199   return 0;
201200}
202201
203static int collision_check_p1p2(running_machine &machine)
202int starcrus_state::collision_check_p1p2()
204203{
205   starcrus_state *state = machine.driver_data<starcrus_state>();
206204   int org_x, org_y;
207205   int sx, sy;
208206   rectangle clip(0, 15, 0, 15);
209207
210208   /* if both are scores, return */
211   if ( ((state->m_p1_sprite & 0x08) == 0) &&
212         ((state->m_p2_sprite & 0x08) == 0) )
209   if ( ((m_p1_sprite & 0x08) == 0) &&
210         ((m_p2_sprite & 0x08) == 0) )
213211   {
214212      return 0;
215213   }
216214
217   state->m_proj1_vid->fill(0, clip);
218   state->m_proj2_vid->fill(0, clip);
215   m_proj1_vid->fill(0, clip);
216   m_proj2_vid->fill(0, clip);
219217
220218   /* origin is with respect to proj1 */
221219
222   org_x = state->m_p1_x;
223   org_y = state->m_p1_y;
220   org_x = m_p1_x;
221   org_y = m_p1_y;
224222
225   if (state->m_p1_sprite & 0x08)  /* if p1 is a projectile */
223   if (m_p1_sprite & 0x08)  /* if p1 is a projectile */
226224   {
227225      /* Draw score/projectile 1 */
228      drawgfx_opaque(*state->m_proj1_vid,
226      drawgfx_opaque(*m_proj1_vid,
229227            clip,
230            machine.gfx[(state->m_p1_sprite&0x0c)>>2],
231            (state->m_p1_sprite&0x03)^0x03,
228            machine().gfx[(m_p1_sprite&0x0c)>>2],
229            (m_p1_sprite&0x03)^0x03,
232230            0,
233231            0,0,
234            state->m_p1_x-org_x, state->m_p1_y-org_y);
232            m_p1_x-org_x, m_p1_y-org_y);
235233   }
236234
237   if (state->m_p2_sprite & 0x08)  /* if p2 is a projectile */
235   if (m_p2_sprite & 0x08)  /* if p2 is a projectile */
238236   {
239237      /* Draw score/projectile 2 */
240      drawgfx_opaque(*state->m_proj2_vid,
238      drawgfx_opaque(*m_proj2_vid,
241239            clip,
242            machine.gfx[4+((state->m_p2_sprite&0x0c)>>2)],
243            (state->m_p2_sprite&0x03)^0x03,
240            machine().gfx[4+((m_p2_sprite&0x0c)>>2)],
241            (m_p2_sprite&0x03)^0x03,
244242            0,
245243            0,0,
246            state->m_p2_x-org_x, state->m_p2_y-org_y);
244            m_p2_x-org_x, m_p2_y-org_y);
247245   }
248246
249247   /* Now check for collisions */
250248   for (sy=0;sy<16;sy++)
251249      for (sx=0;sx<16;sx++)
252250         /* Condition 1 - proj 1 = proj 2 */
253         if ((state->m_proj1_vid->pix16(sy, sx) == 1) && (state->m_proj2_vid->pix16(sy, sx) == 1))
251         if ((m_proj1_vid->pix16(sy, sx) == 1) && (m_proj2_vid->pix16(sy, sx) == 1))
254252            return 1;
255253
256254   return 0;
257255}
258256
259static int collision_check_s1p1p2(running_machine &machine)
257int starcrus_state::collision_check_s1p1p2()
260258{
261   starcrus_state *state = machine.driver_data<starcrus_state>();
262259   int org_x, org_y;
263260   int sx, sy;
264261   rectangle clip(0, 15, 0, 15);
265262
266263   /* if both are scores, return */
267   if ( ((state->m_p1_sprite & 0x08) == 0) &&
268         ((state->m_p2_sprite & 0x08) == 0) )
264   if ( ((m_p1_sprite & 0x08) == 0) &&
265         ((m_p2_sprite & 0x08) == 0) )
269266   {
270267      return 0;
271268   }
272269
273   state->m_ship1_vid->fill(0, clip);
274   state->m_proj1_vid->fill(0, clip);
275   state->m_proj2_vid->fill(0, clip);
270   m_ship1_vid->fill(0, clip);
271   m_proj1_vid->fill(0, clip);
272   m_proj2_vid->fill(0, clip);
276273
277274   /* origin is with respect to ship1 */
278275
279   org_x = state->m_s1_x;
280   org_y = state->m_s1_y;
276   org_x = m_s1_x;
277   org_y = m_s1_y;
281278
282279   /* Draw ship 1 */
283   drawgfx_opaque(*state->m_ship1_vid,
280   drawgfx_opaque(*m_ship1_vid,
284281         clip,
285         machine.gfx[8+((state->m_s1_sprite&0x04)>>2)],
286         (state->m_s1_sprite&0x03)^0x03,
282         machine().gfx[8+((m_s1_sprite&0x04)>>2)],
283         (m_s1_sprite&0x03)^0x03,
287284         0,
288         (state->m_s1_sprite&0x08)>>3, (state->m_s1_sprite&0x10)>>4,
289         state->m_s1_x-org_x, state->m_s1_y-org_y);
285         (m_s1_sprite&0x08)>>3, (m_s1_sprite&0x10)>>4,
286         m_s1_x-org_x, m_s1_y-org_y);
290287
291   if (state->m_p1_sprite & 0x08)  /* if p1 is a projectile */
288   if (m_p1_sprite & 0x08)  /* if p1 is a projectile */
292289   {
293290      /* Draw projectile 1 */
294      drawgfx_opaque(*state->m_proj1_vid,
291      drawgfx_opaque(*m_proj1_vid,
295292            clip,
296            machine.gfx[(state->m_p1_sprite&0x0c)>>2],
297            (state->m_p1_sprite&0x03)^0x03,
293            machine().gfx[(m_p1_sprite&0x0c)>>2],
294            (m_p1_sprite&0x03)^0x03,
298295            0,
299296            0,0,
300            state->m_p1_x-org_x, state->m_p1_y-org_y);
297            m_p1_x-org_x, m_p1_y-org_y);
301298   }
302299
303   if (state->m_p2_sprite & 0x08)  /* if p2 is a projectile */
300   if (m_p2_sprite & 0x08)  /* if p2 is a projectile */
304301   {
305302      /* Draw projectile 2 */
306      drawgfx_opaque(*state->m_proj2_vid,
303      drawgfx_opaque(*m_proj2_vid,
307304            clip,
308            machine.gfx[4+((state->m_p2_sprite&0x0c)>>2)],
309            (state->m_p2_sprite&0x03)^0x03,
305            machine().gfx[4+((m_p2_sprite&0x0c)>>2)],
306            (m_p2_sprite&0x03)^0x03,
310307            0,
311308            0,0,
312            state->m_p2_x-org_x, state->m_p2_y-org_y);
309            m_p2_x-org_x, m_p2_y-org_y);
313310   }
314311
315312   /* Now check for collisions */
316313   for (sy=0;sy<16;sy++)
317314      for (sx=0;sx<16;sx++)
318         if (state->m_ship1_vid->pix16(sy, sx) == 1)
315         if (m_ship1_vid->pix16(sy, sx) == 1)
319316         {
320317            /* Condition 1 - ship 1 = proj 1 */
321            if (state->m_proj1_vid->pix16(sy, sx) == 1)
318            if (m_proj1_vid->pix16(sy, sx) == 1)
322319               return 1;
323320            /* Condition 2 - ship 1 = proj 2 */
324            if (state->m_proj2_vid->pix16(sy, sx) == 1)
321            if (m_proj2_vid->pix16(sy, sx) == 1)
325322               return 1;
326323         }
327324
328325   return 0;
329326}
330327
331static int collision_check_s2p1p2(running_machine &machine)
328int starcrus_state::collision_check_s2p1p2()
332329{
333   starcrus_state *state = machine.driver_data<starcrus_state>();
334330   int org_x, org_y;
335331   int sx, sy;
336332   rectangle clip(0, 15, 0, 15);
337333
338334   /* if both are scores, return */
339   if ( ((state->m_p1_sprite & 0x08) == 0) &&
340         ((state->m_p2_sprite & 0x08) == 0) )
335   if ( ((m_p1_sprite & 0x08) == 0) &&
336         ((m_p2_sprite & 0x08) == 0) )
341337   {
342338      return 0;
343339   }
344340
345   state->m_ship2_vid->fill(0, clip);
346   state->m_proj1_vid->fill(0, clip);
347   state->m_proj2_vid->fill(0, clip);
341   m_ship2_vid->fill(0, clip);
342   m_proj1_vid->fill(0, clip);
343   m_proj2_vid->fill(0, clip);
348344
349345   /* origin is with respect to ship2 */
350346
351   org_x = state->m_s2_x;
352   org_y = state->m_s2_y;
347   org_x = m_s2_x;
348   org_y = m_s2_y;
353349
354350   /* Draw ship 2 */
355   drawgfx_opaque(*state->m_ship2_vid,
351   drawgfx_opaque(*m_ship2_vid,
356352         clip,
357         machine.gfx[10+((state->m_s2_sprite&0x04)>>2)],
358         (state->m_s2_sprite&0x03)^0x03,
353         machine().gfx[10+((m_s2_sprite&0x04)>>2)],
354         (m_s2_sprite&0x03)^0x03,
359355         0,
360         (state->m_s2_sprite&0x08)>>3, (state->m_s2_sprite&0x10)>>4,
361         state->m_s2_x-org_x, state->m_s2_y-org_y);
356         (m_s2_sprite&0x08)>>3, (m_s2_sprite&0x10)>>4,
357         m_s2_x-org_x, m_s2_y-org_y);
362358
363   if (state->m_p1_sprite & 0x08)  /* if p1 is a projectile */
359   if (m_p1_sprite & 0x08)  /* if p1 is a projectile */
364360   {
365361      /* Draw projectile 1 */
366      drawgfx_opaque(*state->m_proj1_vid,
362      drawgfx_opaque(*m_proj1_vid,
367363            clip,
368            machine.gfx[(state->m_p1_sprite&0x0c)>>2],
369            (state->m_p1_sprite&0x03)^0x03,
364            machine().gfx[(m_p1_sprite&0x0c)>>2],
365            (m_p1_sprite&0x03)^0x03,
370366            0,
371367            0,0,
372            state->m_p1_x-org_x, state->m_p1_y-org_y);
368            m_p1_x-org_x, m_p1_y-org_y);
373369   }
374370
375   if (state->m_p2_sprite & 0x08)  /* if p2 is a projectile */
371   if (m_p2_sprite & 0x08)  /* if p2 is a projectile */
376372   {
377373      /* Draw projectile 2 */
378      drawgfx_opaque(*state->m_proj2_vid,
374      drawgfx_opaque(*m_proj2_vid,
379375            clip,
380            machine.gfx[4+((state->m_p2_sprite&0x0c)>>2)],
381            (state->m_p2_sprite&0x03)^0x03,
376            machine().gfx[4+((m_p2_sprite&0x0c)>>2)],
377            (m_p2_sprite&0x03)^0x03,
382378            0,
383379            0,0,
384            state->m_p2_x-org_x, state->m_p2_y-org_y);
380            m_p2_x-org_x, m_p2_y-org_y);
385381   }
386382
387383   /* Now check for collisions */
388384   for (sy=0;sy<16;sy++)
389385      for (sx=0;sx<16;sx++)
390         if (state->m_ship2_vid->pix16(sy, sx) == 1)
386         if (m_ship2_vid->pix16(sy, sx) == 1)
391387         {
392388            /* Condition 1 - ship 2 = proj 1 */
393            if (state->m_proj1_vid->pix16(sy, sx) == 1)
389            if (m_proj1_vid->pix16(sy, sx) == 1)
394390               return 1;
395391            /* Condition 2 - ship 2 = proj 2 */
396            if (state->m_proj2_vid->pix16(sy, sx) == 1)
392            if (m_proj2_vid->pix16(sy, sx) == 1)
397393               return 1;
398394         }
399395
r20977r20978
450446      m_collision_reg = 0x00;
451447
452448      /* Check for collisions between ship1 and ship2 */
453      if (collision_check_s1s2(machine()))
449      if (collision_check_s1s2())
454450      {
455451         m_collision_reg |= 0x08;
456452      }
457453      /* Check for collisions between ship1 and projectiles */
458      if (collision_check_s1p1p2(machine()))
454      if (collision_check_s1p1p2())
459455      {
460456         m_collision_reg |= 0x02;
461457      }
462458      /* Check for collisions between ship1 and projectiles */
463      if (collision_check_s2p1p2(machine()))
459      if (collision_check_s2p1p2())
464460      {
465461         m_collision_reg |= 0x01;
466462      }
467463      /* Check for collisions between ship1 and projectiles */
468464      /* Note: I don't think this is used by the game */
469      if (collision_check_p1p2(machine()))
465      if (collision_check_p1p2())
470466      {
471467         m_collision_reg |= 0x04;
472468      }
trunk/src/mame/video/stactics.c
r20977r20978
173173}
174174
175175
176static void update_beam(stactics_state *state)
176void stactics_state::update_beam()
177177{
178178   /* first, update the firebeam state */
179   state->m_old_beam_state = state->m_beam_state;
180   if (state->m_shot_standby == 0)
181      state->m_beam_state = state->m_beam_state + state->m_beam_states_per_frame;
179   m_old_beam_state = m_beam_state;
180   if (m_shot_standby == 0)
181      m_beam_state = m_beam_state + m_beam_states_per_frame;
182182
183183   /* These are thresholds for the two shots from the LED fire ROM */
184184   /* (Note: There are two more for sound triggers, */
185185   /*        whenever that gets implemented)        */
186   if ((state->m_old_beam_state < 0x8b) & (state->m_beam_state >= 0x8b))
187      state->m_shot_arrive = 1;
186   if ((m_old_beam_state < 0x8b) & (m_beam_state >= 0x8b))
187      m_shot_arrive = 1;
188188
189   if ((state->m_old_beam_state < 0xca) & (state->m_beam_state >= 0xca))
190      state->m_shot_arrive = 1;
189   if ((m_old_beam_state < 0xca) & (m_beam_state >= 0xca))
190      m_shot_arrive = 1;
191191
192   if (state->m_beam_state >= 0x100)
192   if (m_beam_state >= 0x100)
193193   {
194      state->m_beam_state = 0;
195      state->m_shot_standby = 1;
194      m_beam_state = 0;
195      m_shot_standby = 1;
196196   }
197197}
198198
r20977r20978
204204 *
205205 *************************************/
206206
207INLINE int get_pixel_on_plane(UINT8 *videoram, UINT8 y, UINT8 x, UINT8 y_scroll)
207inline int stactics_state::get_pixel_on_plane(UINT8 *videoram, UINT8 y, UINT8 x, UINT8 y_scroll)
208208{
209209   UINT8 code;
210210   UINT8 gfx;
r20977r20978
223223}
224224
225225
226static void draw_background(stactics_state *state, bitmap_ind16 &bitmap, const rectangle &cliprect)
226void stactics_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
227227{
228228   int y;
229229
r20977r20978
238238      for (x = 0; x < 0x100; x++)
239239      {
240240         /* get the pixels for the four planes */
241         int pixel_b = get_pixel_on_plane(state->m_videoram_b, y, x, 0);
242         int pixel_d = get_pixel_on_plane(state->m_videoram_d, y, x, state->m_y_scroll_d);
243         int pixel_e = get_pixel_on_plane(state->m_videoram_e, y, x, state->m_y_scroll_e);
244         int pixel_f = get_pixel_on_plane(state->m_videoram_f, y, x, state->m_y_scroll_f);
241         int pixel_b = get_pixel_on_plane(m_videoram_b, y, x, 0);
242         int pixel_d = get_pixel_on_plane(m_videoram_d, y, x, m_y_scroll_d);
243         int pixel_e = get_pixel_on_plane(m_videoram_e, y, x, m_y_scroll_e);
244         int pixel_f = get_pixel_on_plane(m_videoram_f, y, x, m_y_scroll_f);
245245
246246         /* get the color for this pixel */
247         UINT8 color = state->m_videoram_b[((y >> 3) << 5) | (x >> 3)] >> 4;
247         UINT8 color = m_videoram_b[((y >> 3) << 5) | (x >> 3)] >> 4;
248248
249249         /* assemble the pen index */
250250         int pen = color |
r20977r20978
252252                  (pixel_f << 5) |
253253                  (pixel_e << 6) |
254254                  (pixel_d << 7) |
255                  ((state->m_palette[0] & 0x01) << 8) |
256                  ((state->m_palette[1] & 0x01) << 9);
255                  ((m_palette[0] & 0x01) << 8) |
256                  ((m_palette[1] & 0x01) << 9);
257257
258258         /* compute the effective pixel coordinate after adjusting for the
259259            mirror movement - this is mechanical on the real machine */
260         int sy = y + state->m_vert_pos;
261         int sx = x - state->m_horiz_pos;
260         int sy = y + m_vert_pos;
261         int sx = x - m_horiz_pos;
262262
263263         /* plot if visible */
264264         if ((sy >= 0) && (sy < 0x100) && (sx >= 0) && (sx < 0x100))
r20977r20978
283283};
284284
285285
286static void set_indicator_leds(int data, const char *output_name, int base_index)
286void stactics_state::set_indicator_leds(int data, const char *output_name, int base_index)
287287{
288288   /* decode the data */
289289   data = to_7seg[~data & 0x0f];
r20977r20978
296296}
297297
298298
299static void update_artwork(running_machine &machine, stactics_state *state)
299void stactics_state::update_artwork()
300300{
301301   int i;
302   UINT8 *beam_region = machine.root_device().memregion("user1")->base();
302   UINT8 *beam_region = machine().root_device().memregion("user1")->base();
303303
304304   /* set the lamps first */
305   output_set_indexed_value("base_lamp", 4, state->m_lamps[0] & 0x01);
306   output_set_indexed_value("base_lamp", 3, state->m_lamps[1] & 0x01);
307   output_set_indexed_value("base_lamp", 2, state->m_lamps[2] & 0x01);
308   output_set_indexed_value("base_lamp", 1, state->m_lamps[3] & 0x01);
309   output_set_indexed_value("base_lamp", 0, state->m_lamps[4] & 0x01);
310   output_set_value("start_lamp",   state->m_lamps[5] & 0x01);
311   output_set_value("barrier_lamp", state->m_lamps[6] & 0x01);  /* this needs to flash on/off, not implemented */
305   output_set_indexed_value("base_lamp", 4, m_lamps[0] & 0x01);
306   output_set_indexed_value("base_lamp", 3, m_lamps[1] & 0x01);
307   output_set_indexed_value("base_lamp", 2, m_lamps[2] & 0x01);
308   output_set_indexed_value("base_lamp", 1, m_lamps[3] & 0x01);
309   output_set_indexed_value("base_lamp", 0, m_lamps[4] & 0x01);
310   output_set_value("start_lamp",   m_lamps[5] & 0x01);
311   output_set_value("barrier_lamp", m_lamps[6] & 0x01);  /* this needs to flash on/off, not implemented */
312312
313313   /* laser beam - loop for each LED */
314314   for (i = 0; i < 0x40; i++)
315315   {
316      offs_t beam_data_offs = ((i & 0x08) << 7) | ((i & 0x30) << 4) | state->m_beam_state;
316      offs_t beam_data_offs = ((i & 0x08) << 7) | ((i & 0x30) << 4) | m_beam_state;
317317      UINT8 beam_data = beam_region[beam_data_offs];
318318      int on = (beam_data >> (i & 0x07)) & 0x01;
319319
r20977r20978
322322   }
323323
324324   /* sight LED */
325   output_set_value("sight_led", *state->m_motor_on & 0x01);
325   output_set_value("sight_led", *m_motor_on & 0x01);
326326
327327   /* score display */
328328   for (i = 0x01; i < 0x07; i++)
329      output_set_digit_value(i - 1, to_7seg[~state->m_display_buffer[i] & 0x0f]);
329      output_set_digit_value(i - 1, to_7seg[~m_display_buffer[i] & 0x0f]);
330330
331331   /* credits indicator */
332   set_indicator_leds(state->m_display_buffer[0x07], "credit_led", 0x00);
333   set_indicator_leds(state->m_display_buffer[0x08], "credit_led", 0x04);
332   set_indicator_leds(m_display_buffer[0x07], "credit_led", 0x00);
333   set_indicator_leds(m_display_buffer[0x08], "credit_led", 0x04);
334334
335335   /* barriers indicator */
336   set_indicator_leds(state->m_display_buffer[0x09], "barrier_led", 0x00);
337   set_indicator_leds(state->m_display_buffer[0x0a], "barrier_led", 0x04);
338   set_indicator_leds(state->m_display_buffer[0x0b], "barrier_led", 0x08);
336   set_indicator_leds(m_display_buffer[0x09], "barrier_led", 0x00);
337   set_indicator_leds(m_display_buffer[0x0a], "barrier_led", 0x04);
338   set_indicator_leds(m_display_buffer[0x0b], "barrier_led", 0x08);
339339
340340   /* rounds indicator */
341   set_indicator_leds(state->m_display_buffer[0x0c], "round_led", 0x00);
342   set_indicator_leds(state->m_display_buffer[0x0d], "round_led", 0x04);
343   set_indicator_leds(state->m_display_buffer[0x0e], "round_led", 0x08);
344   set_indicator_leds(state->m_display_buffer[0x0f], "round_led", 0x0c);
341   set_indicator_leds(m_display_buffer[0x0c], "round_led", 0x00);
342   set_indicator_leds(m_display_buffer[0x0d], "round_led", 0x04);
343   set_indicator_leds(m_display_buffer[0x0e], "round_led", 0x08);
344   set_indicator_leds(m_display_buffer[0x0f], "round_led", 0x0c);
345345}
346346
347347
r20977r20978
375375
376376UINT32 stactics_state::screen_update_stactics(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
377377{
378   update_beam(this);
379   draw_background(this, bitmap, cliprect);
380   update_artwork(machine(), this);
378   update_beam();
379   draw_background(bitmap, cliprect);
380   update_artwork();
381381
382382   m_frame_count = (m_frame_count + 1) & 0x0f;
383383
trunk/src/mame/video/skyfox.c
r20977r20978
157157
158158***************************************************************************/
159159
160static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
160void skyfox_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
161161{
162   skyfox_state *state = machine.driver_data<skyfox_state>();
163162   int offs;
164163
165   int width = machine.primary_screen->width();
166   int height = machine.primary_screen->height();
164   int width = machine().primary_screen->width();
165   int height = machine().primary_screen->height();
167166
168167   /* The 32x32 tiles in the 80-ff range are bankswitched */
169   int shift =(state->m_bg_ctrl & 0x80) ? (4 - 1) : 4;
168   int shift =(m_bg_ctrl & 0x80) ? (4 - 1) : 4;
170169
171   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
170   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
172171   {
173172      int xstart, ystart, xend, yend;
174173      int xinc, yinc, dx, dy;
175174      int low_code, high_code, n;
176175
177      int y = state->m_spriteram[offs + 0];
178      int x = state->m_spriteram[offs + 1];
179      int code = state->m_spriteram[offs + 2] + state->m_spriteram[offs + 3] * 256;
176      int y = m_spriteram[offs + 0];
177      int x = m_spriteram[offs + 1];
178      int code = m_spriteram[offs + 2] + m_spriteram[offs + 3] * 256;
180179      int flipx = code & 0x2;
181180      int flipy = code & 0x4;
182181
r20977r20978
193192
194193#define DRAW_SPRITE(DX,DY,CODE) \
195194      drawgfx_transpen(bitmap,\
196            cliprect,machine.gfx[0], \
195            cliprect,machine().gfx[0], \
197196            (CODE), \
198197            0, \
199198            flipx,flipy, \
200199            x + (DX),y + (DY), 0xff);
201      if (state->m_bg_ctrl & 1)   // flipscreen
200      if (m_bg_ctrl & 1)   // flipscreen
202201      {
203202         x = width  - x - (n - 1) * 8;
204203         y = height - y - (n - 1) * 8;
r20977r20978
235234
236235***************************************************************************/
237236
238static void draw_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
237void skyfox_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
239238{
240   skyfox_state *state = machine.driver_data<skyfox_state>();
241   UINT8 *RAM = state->memregion("gfx2")->base();
239   UINT8 *RAM = memregion("gfx2")->base();
242240   int x, y, i;
243241
244242   /* The foreground stars (sprites) move at twice this speed when
245243      the bg scroll rate [e.g. (skyfox_bg_reg >> 1) & 7] is 4 */
246   int pos = (state->m_bg_pos >> 4) & (512 * 2 - 1);
244   int pos = (m_bg_pos >> 4) & (512 * 2 - 1);
247245
248246   for (i = 0 ; i < 0x1000; i++)
249247   {
250248      int pen, offs, j;
251249
252      offs    = (i * 2 + ((state->m_bg_ctrl >> 4) & 0x3) * 0x2000) % 0x8000;
250      offs    = (i * 2 + ((m_bg_ctrl >> 4) & 0x3) * 0x2000) % 0x8000;
253251
254252      pen = RAM[offs];
255253      x = RAM[offs + 1] * 2 + (i & 1) + pos + ((i & 8) ? 512 : 0);
256254      y = ((i / 8) / 2) * 8 + (i % 8);
257255
258      if (state->m_bg_ctrl & 1)   // flipscreen
256      if (m_bg_ctrl & 1)   // flipscreen
259257      {
260258         x = 512 * 2 - (x % (512 * 2));
261259         y = 256     - (y % 256);
r20977r20978
281279UINT32 skyfox_state::screen_update_skyfox(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
282280{
283281   bitmap.fill(255, cliprect); // the bg is black
284   draw_background(machine(), bitmap, cliprect);
285   draw_sprites(machine(), bitmap, cliprect);
282   draw_background(bitmap, cliprect);
283   draw_sprites(bitmap, cliprect);
286284   return 0;
287285}
trunk/src/mame/video/senjyo.c
r20977r20978
156156
157157***************************************************************************/
158158
159static void draw_bgbitmap(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
159void senjyo_state::draw_bgbitmap(bitmap_ind16 &bitmap,const rectangle &cliprect)
160160{
161   senjyo_state *state = machine.driver_data<senjyo_state>();
162161   int x,y,pen,strwid,count;
163162
164163
165   if (state->m_bgstripes == 0xff) /* off */
164   if (m_bgstripes == 0xff) /* off */
166165      bitmap.fill(0, cliprect);
167166   else
168167   {
169      int flip = state->flip_screen();
168      int flip = flip_screen();
170169
171170      pen = 0;
172171      count = 0;
173      strwid = state->m_bgstripes;
172      strwid = m_bgstripes;
174173      if (strwid == 0) strwid = 0x100;
175174      if (flip) strwid ^= 0xff;
176175
r20977r20978
193192   }
194193}
195194
196static void draw_radar(running_machine &machine,bitmap_ind16 &bitmap,const rectangle &cliprect)
195void senjyo_state::draw_radar(bitmap_ind16 &bitmap,const rectangle &cliprect)
197196{
198   senjyo_state *state = machine.driver_data<senjyo_state>();
199197   int offs,x;
200198
201199   for (offs = 0;offs < 0x400;offs++)
202200      for (x = 0;x < 8;x++)
203         if (state->m_radarram[offs] & (1 << x))
201         if (m_radarram[offs] & (1 << x))
204202         {
205203            int sx, sy;
206204
207205            sx = (8 * (offs % 8) + x) + 256-64;
208206            sy = ((offs & 0x1ff) / 8) + 96;
209207
210            if (state->flip_screen())
208            if (flip_screen())
211209            {
212210               sx = 255 - sx;
213211               sy = 255 - sy;
r20977r20978
218216         }
219217}
220218
221static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int priority)
219void senjyo_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int priority)
222220{
223   senjyo_state *state = machine.driver_data<senjyo_state>();
224   UINT8 *spriteram = state->m_spriteram;
221   UINT8 *spriteram = m_spriteram;
225222   int offs;
226223
227   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
224   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
228225   {
229226      int big,sx,sy,flipx,flipy;
230227
231228      if (((spriteram[offs+1] & 0x30) >> 4) == priority)
232229      {
233         if (state->m_is_senjyo) /* Senjyo */
230         if (m_is_senjyo) /* Senjyo */
234231            big = (spriteram[offs] & 0x80);
235232         else    /* Star Force */
236233            big = ((spriteram[offs] & 0xc0) == 0xc0);
r20977r20978
242239         flipx = spriteram[offs+1] & 0x40;
243240         flipy = spriteram[offs+1] & 0x80;
244241
245         if (state->flip_screen())
242         if (flip_screen())
246243         {
247244            flipx = !flipx;
248245            flipy = !flipy;
r20977r20978
260257         }
261258
262259
263         drawgfx_transpen(bitmap,cliprect,machine.gfx[big ? 5 : 4],
260         drawgfx_transpen(bitmap,cliprect,machine().gfx[big ? 5 : 4],
264261               spriteram[offs],
265262               spriteram[offs + 1] & 0x07,
266263               flipx,flipy,
r20977r20978
312309      m_bg3_tilemap->set_scrolly(0, scrolly);
313310   }
314311
315   draw_bgbitmap(machine(), bitmap, cliprect);
316   draw_sprites(machine(), bitmap, cliprect, 0);
312   draw_bgbitmap(bitmap, cliprect);
313   draw_sprites(bitmap, cliprect, 0);
317314   m_bg3_tilemap->draw(bitmap, cliprect, 0, 0);
318   draw_sprites(machine(), bitmap, cliprect, 1);
315   draw_sprites(bitmap, cliprect, 1);
319316   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
320   draw_sprites(machine(), bitmap, cliprect, 2);
317   draw_sprites(bitmap, cliprect, 2);
321318   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
322   draw_sprites(machine(), bitmap, cliprect, 3);
319   draw_sprites(bitmap, cliprect, 3);
323320   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
324   draw_radar(machine(), bitmap, cliprect);
321   draw_radar(bitmap, cliprect);
325322
326323#if 0
327324{
trunk/src/mame/video/strnskil.c
r20977r20978
7878   m_bg_tilemap->set_scroll_rows(32);
7979}
8080
81static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
81void strnskil_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
8282{
83   strnskil_state *state = machine.driver_data<strnskil_state>();
84   UINT8 *spriteram = state->m_spriteram;
83   UINT8 *spriteram = m_spriteram;
8584   int offs;
8685
8786   for (offs = 0x60; offs < 0x100; offs += 4)
8887   {
8988      int code = spriteram[offs + 1];
9089      int color = spriteram[offs + 2] & 0x3f;
91      int flipx = state->flip_screen_x();
92      int flipy = state->flip_screen_y();
90      int flipx = flip_screen_x();
91      int flipy = flip_screen_y();
9392
9493      int sx = spriteram[offs + 3];
9594      int sy = spriteram[offs];
9695      int px, py;
9796
98      if (state->flip_screen())
97      if (flip_screen())
9998      {
10099         px = 240 - sx + 0; /* +2 or +0 ? */
101100         py = sy;
r20977r20978
112111         sx = sx - 256;
113112
114113      drawgfx_transmask(bitmap, cliprect,
115         machine.gfx[1],
114         machine().gfx[1],
116115         code, color,
117116         flipx, flipy,
118117         px, py,
119         colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 0));
118         colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 0));
120119   }
121120}
122121
r20977r20978
142141   }
143142
144143   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
145   draw_sprites(machine(), bitmap, cliprect);
144   draw_sprites(bitmap, cliprect);
146145   return 0;
147146}
trunk/src/mame/video/sonson.c
r20977r20978
135135   m_bg_tilemap->set_scroll_rows(32);
136136}
137137
138static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
138void sonson_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
139139{
140   sonson_state *state = machine.driver_data<sonson_state>();
141   UINT8 *spriteram = state->m_spriteram;
140   UINT8 *spriteram = m_spriteram;
142141   int offs;
143142
144   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
143   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
145144   {
146145      int code = spriteram[offs + 2] + ((spriteram[offs + 1] & 0x20) << 3);
147146      int color = spriteram[offs + 1] & 0x1f;
r20977r20978
150149      int sx = spriteram[offs + 3];
151150      int sy = spriteram[offs + 0];
152151
153      if (state->flip_screen())
152      if (flip_screen())
154153      {
155154         sx = 240 - sx;
156155         sy = 240 - sy;
r20977r20978
159158      }
160159
161160      drawgfx_transpen(bitmap, cliprect,
162         machine.gfx[1],
161         machine().gfx[1],
163162         code, color,
164163         flipx, flipy,
165164         sx, sy, 0);
166165
167166      /* wrap-around */
168      drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, sx - 256, sy, 0);
169      drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, sx, sy - 256, 0);
167      drawgfx_transpen(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, sx - 256, sy, 0);
168      drawgfx_transpen(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, sx, sy - 256, 0);
170169   }
171170}
172171
173172UINT32 sonson_state::screen_update_sonson(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
174173{
175174   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
176   draw_sprites(machine(), bitmap, cliprect);
175   draw_sprites(bitmap, cliprect);
177176   return 0;
178177}
trunk/src/mame/video/shaolins.c
r20977r20978
147147   m_bg_tilemap->set_scroll_cols(32);
148148}
149149
150static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
150void shaolins_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
151151{
152   shaolins_state *state = machine.driver_data<shaolins_state>();
153   UINT8 *spriteram = state->m_spriteram;
152   UINT8 *spriteram = m_spriteram;
154153   int offs;
155154
156   for (offs = state->m_spriteram.bytes() - 32; offs >= 0; offs -= 32 ) /* max 24 sprites */
155   for (offs = m_spriteram.bytes() - 32; offs >= 0; offs -= 32 ) /* max 24 sprites */
157156   {
158157      if (spriteram[offs] && spriteram[offs + 6]) /* stop rogue sprites on high score screen */
159158      {
160159         int code = spriteram[offs + 8];
161         int color = (spriteram[offs + 9] & 0x0f) | (state->m_palettebank << 4);
160         int color = (spriteram[offs + 9] & 0x0f) | (m_palettebank << 4);
162161         int flipx = !(spriteram[offs + 9] & 0x40);
163162         int flipy = spriteram[offs + 9] & 0x80;
164163         int sx = 240 - spriteram[offs + 6];
165164         int sy = 248 - spriteram[offs + 4];
166165
167         if (state->flip_screen())
166         if (flip_screen())
168167         {
169168            sx = 240 - sx;
170169            sy = 248 - sy;
r20977r20978
172171            flipy = !flipy;
173172         }
174173
175         drawgfx_transmask(bitmap, cliprect,machine.gfx[1],
174         drawgfx_transmask(bitmap, cliprect,machine().gfx[1],
176175            code, color,
177176            flipx, flipy,
178177            sx, sy,
179            colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, state->m_palettebank << 5));
178            colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, m_palettebank << 5));
180179      }
181180   }
182181}
r20977r20978
184183UINT32 shaolins_state::screen_update_shaolins(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
185184{
186185   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
187   draw_sprites(machine(), bitmap, cliprect);
186   draw_sprites(bitmap, cliprect);
188187   return 0;
189188}
trunk/src/mame/video/segag80r.c
r20977r20978
2525}
2626
2727
28static void vblank_latch_set(running_machine &machine)
28void segag80r_state::vblank_latch_set()
2929{
30   segag80r_state *state = machine.driver_data<segag80r_state>();
3130   /* set a timer to mimic the 555 timer that drives the EDGINT signal */
3231   /* the 555 is run in monostable mode with R=56000 and C=1000pF */
33   state->m_vblank_latch = 1;
34   machine.scheduler().timer_set(PERIOD_OF_555_MONOSTABLE(CAP_P(1000), RES_K(56)), timer_expired_delegate(FUNC(segag80r_state::vblank_latch_clear),state));
32   m_vblank_latch = 1;
33   machine().scheduler().timer_set(PERIOD_OF_555_MONOSTABLE(CAP_P(1000), RES_K(56)), timer_expired_delegate(FUNC(segag80r_state::vblank_latch_clear),this));
3534
3635   /* latch the current flip state at the same time */
37   state->m_video_flip = state->m_video_control & 1;
36   m_video_flip = m_video_control & 1;
3837}
3938
4039
4140INTERRUPT_GEN_MEMBER(segag80r_state::segag80r_vblank_start)
4241{
43   vblank_latch_set(machine());
42   vblank_latch_set();
4443
4544   /* if interrupts are enabled, clock one */
4645   if (m_video_control & 0x04)
r20977r20978
5049
5150INTERRUPT_GEN_MEMBER(segag80r_state::sindbadm_vblank_start)
5251{
53   vblank_latch_set(machine());
52   vblank_latch_set();
5453
5554   /* interrupts appear to always be enabled, but they have a manual */
5655   /* acknowledge rather than an automatic ack; they are also not masked */
r20977r20978
6665 *
6766 *************************************/
6867
69static void g80_set_palette_entry(running_machine &machine, int entry, UINT8 data)
68void segag80r_state::g80_set_palette_entry(int entry, UINT8 data)
7069{
71   segag80r_state *state = machine.driver_data<segag80r_state>();
7270   int bit0, bit1, bit2;
7371   int r, g, b;
7472
r20977r20978
8179   bit0 = (r >> 0) & 0x01;
8280   bit1 = (r >> 1) & 0x01;
8381   bit2 = (r >> 2) & 0x01;
84   r = combine_3_weights(state->m_rweights, bit0, bit1, bit2);
82   r = combine_3_weights(m_rweights, bit0, bit1, bit2);
8583
8684   /* green component */
8785   bit0 = (g >> 0) & 0x01;
8886   bit1 = (g >> 1) & 0x01;
8987   bit2 = (g >> 2) & 0x01;
90   g = combine_3_weights(state->m_gweights, bit0, bit1, bit2);
88   g = combine_3_weights(m_gweights, bit0, bit1, bit2);
9189
9290   /* blue component */
9391   bit0 = (b >> 0) & 0x01;
9492   bit1 = (b >> 1) & 0x01;
95   b = combine_2_weights(state->m_bweights, bit0, bit1);
93   b = combine_2_weights(m_bweights, bit0, bit1);
9694
97   palette_set_color(machine, entry, MAKE_RGB(r, g, b));
95   palette_set_color(machine(), entry, MAKE_RGB(r, g, b));
9896}
9997
10098
101static void spaceod_bg_init_palette(running_machine &machine)
99void segag80r_state::spaceod_bg_init_palette()
102100{
103101   static const int resistances[2] = { 1800, 1200 };
104102   double trweights[2], tgweights[2], tbweights[2];
r20977r20978
136134      bit1 = (b >> 1) & 0x01;
137135      b = combine_2_weights(tbweights, bit0, bit1);
138136
139      palette_set_color(machine, 64 + i, MAKE_RGB(r, g, b));
137      palette_set_color(machine(), 64 + i, MAKE_RGB(r, g, b));
140138   }
141139}
142140
r20977r20978
204202      /* create a fixed background palette and two tilemaps, one horizontally scrolling */
205203      /* and one vertically scrolling */
206204      case G80_BACKGROUND_SPACEOD:
207         spaceod_bg_init_palette(machine());
205         spaceod_bg_init_palette();
208206         m_spaceod_bg_htilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(segag80r_state::spaceod_get_tile_info),this), tilemap_mapper_delegate(FUNC(segag80r_state::spaceod_scan_rows),this),  8,8, 128,32);
209207         m_spaceod_bg_vtilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(segag80r_state::spaceod_get_tile_info),this), tilemap_mapper_delegate(FUNC(segag80r_state::spaceod_scan_rows),this),  8,8, 32,128);
210208         break;
r20977r20978
256254   {
257255      offset &= 0x3f;
258256      m_generic_paletteram_8[offset] = data;
259      g80_set_palette_entry(machine(), offset, data);
257      g80_set_palette_entry(offset, data);
260258      return;
261259   }
262260
r20977r20978
420418   {
421419      offs_t paloffs = offset & 0x3f;
422420      m_generic_paletteram_8[paloffs | 0x40] = data;
423      g80_set_palette_entry(machine(), paloffs | 0x40, data);
421      g80_set_palette_entry(paloffs | 0x40, data);
424422      /* note that since the background board is not integrated with the main board */
425423      /* writes here also write through to regular videoram */
426424   }
r20977r20978
490488   {
491489      offs_t paloffs = offset & 0x3f;
492490      m_generic_paletteram_8[paloffs | 0x40] = data;
493      g80_set_palette_entry(machine(), paloffs | 0x40, data);
491      g80_set_palette_entry(paloffs | 0x40, data);
494492      return;
495493   }
496494
r20977r20978
573571   {
574572      offs_t paloffs = offset & 0x3f;
575573      m_generic_paletteram_8[paloffs | 0x40] = data;
576      g80_set_palette_entry(machine(), paloffs | 0x40, data);
574      g80_set_palette_entry(paloffs | 0x40, data);
577575      return;
578576   }
579577
r20977r20978
621619 *
622620 *************************************/
623621
624static void draw_videoram(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *transparent_pens)
622void segag80r_state::draw_videoram(bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *transparent_pens)
625623{
626   segag80r_state *state = machine.driver_data<segag80r_state>();
627   UINT8 *videoram = state->m_videoram;
628   int flipmask = state->m_video_flip ? 0x1f : 0x00;
624   UINT8 *videoram = m_videoram;
625   int flipmask = m_video_flip ? 0x1f : 0x00;
629626   int x, y;
630627
631628   /* iterate over the screen and draw visible tiles */
632629   for (y = cliprect.min_y / 8; y <= cliprect.max_y / 8; y++)
633630   {
634      int effy = state->m_video_flip ? 27 - y : y;
631      int effy = m_video_flip ? 27 - y : y;
635632      for (x = cliprect.min_x / 8; x <= cliprect.max_x / 8; x++)
636633      {
637634         int offs = effy * 32 + (x ^ flipmask);
638635         UINT8 tile = videoram[offs];
639636
640637         /* draw the tile */
641         drawgfx_transmask(bitmap, cliprect, machine.gfx[0], tile, tile >> 4, state->m_video_flip, state->m_video_flip, x*8, y*8, transparent_pens[tile >> 4]);
638         drawgfx_transmask(bitmap, cliprect, machine().gfx[0], tile, tile >> 4, m_video_flip, m_video_flip, x*8, y*8, transparent_pens[tile >> 4]);
642639      }
643640   }
644641}
r20977r20978
651648 *
652649 *************************************/
653650
654static void draw_background_spaceod(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
651void segag80r_state::draw_background_spaceod(bitmap_ind16 &bitmap, const rectangle &cliprect)
655652{
656   segag80r_state *state = machine.driver_data<segag80r_state>();
657   bitmap_ind16 &pixmap = (!(state->m_spaceod_bg_control & 0x02) ? state->m_spaceod_bg_htilemap : state->m_spaceod_bg_vtilemap)->pixmap();
658   int flipmask = (state->m_spaceod_bg_control & 0x01) ? 0xff : 0x00;
659   int xoffset = (state->m_spaceod_bg_control & 0x02) ? 0x10 : 0x00;
653   bitmap_ind16 &pixmap = (!(m_spaceod_bg_control & 0x02) ? m_spaceod_bg_htilemap : m_spaceod_bg_vtilemap)->pixmap();
654   int flipmask = (m_spaceod_bg_control & 0x01) ? 0xff : 0x00;
655   int xoffset = (m_spaceod_bg_control & 0x02) ? 0x10 : 0x00;
660656   int xmask = pixmap.width() - 1;
661657   int ymask = pixmap.height() - 1;
662658   int x, y;
r20977r20978
670666   /* now fill in the background wherever there are black pixels */
671667   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
672668   {
673      int effy = (y + state->m_spaceod_vcounter + 22) ^ flipmask;
669      int effy = (y + m_spaceod_vcounter + 22) ^ flipmask;
674670      UINT16 *src = &pixmap.pix16(effy & ymask);
675671      UINT16 *dst = &bitmap.pix16(y);
676672
677673      /* loop over horizontal pixels */
678674      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
679675      {
680         int effx = ((x + state->m_spaceod_hcounter) ^ flipmask) + xoffset;
681         UINT8 fgpix = state->m_generic_paletteram_8[dst[x]];
676         int effx = ((x + m_spaceod_hcounter) ^ flipmask) + xoffset;
677         UINT8 fgpix = m_generic_paletteram_8[dst[x]];
682678         UINT8 bgpix = src[effx & xmask] & 0x3f;
683679
684680         /* the background detect flag is set if:
r20977r20978
687683             - the original tile color == DIP switches
688684         */
689685         if (bgpix != 0 && fgpix != 0 && (dst[x] >> 2) == spaceod_bg_detect_tile_color)
690            state->m_spaceod_bg_detect = 1;
686            m_spaceod_bg_detect = 1;
691687
692688         /* the background graphics are only displayed if:
693689             - fgpix == 0 AND
694690             - !EXTBLK (not blanked) AND
695             - state->m_bg_enable == 0
691             - m_bg_enable == 0
696692         */
697         if (fgpix == 0 && state->m_bg_enable == 0)
698            dst[x] = bgpix | state->m_spaceod_fixed_color | 0x40;
693         if (fgpix == 0 && m_bg_enable == 0)
694            dst[x] = bgpix | m_spaceod_fixed_color | 0x40;
699695      }
700696   }
701697}
r20977r20978
709705 *
710706 *************************************/
711707
712static void draw_background_page_scroll(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
708void segag80r_state::draw_background_page_scroll(bitmap_ind16 &bitmap, const rectangle &cliprect)
713709{
714   segag80r_state *state = machine.driver_data<segag80r_state>();
715   bitmap_ind16 &pixmap = state->m_bg_tilemap->pixmap();
716   int flipmask = (state->m_video_control & 0x08) ? 0xff : 0x00;
710   bitmap_ind16 &pixmap = m_bg_tilemap->pixmap();
711   int flipmask = (m_video_control & 0x08) ? 0xff : 0x00;
717712   int xmask = pixmap.width() - 1;
718713   int ymask = pixmap.height() - 1;
719714   int x, y;
720715
721716   /* if disabled, draw nothing */
722   if (!state->m_bg_enable)
717   if (!m_bg_enable)
723718   {
724719      bitmap.fill(0, cliprect);
725720      return;
r20977r20978
728723   /* now fill in the background wherever there are black pixels */
729724   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
730725   {
731      int effy = state->m_bg_scrolly + (((y ^ flipmask) + (flipmask & 0xe0)) & 0xff);
726      int effy = m_bg_scrolly + (((y ^ flipmask) + (flipmask & 0xe0)) & 0xff);
732727      UINT16 *src = &pixmap.pix16(effy & ymask);
733728      UINT16 *dst = &bitmap.pix16(y);
734729
735730      /* loop over horizontal pixels */
736731      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
737732      {
738         int effx = state->m_bg_scrollx + (x ^ flipmask);
733         int effx = m_bg_scrollx + (x ^ flipmask);
739734         dst[x] = src[effx & xmask];
740735      }
741736   }
r20977r20978
750745 *
751746 *************************************/
752747
753static void draw_background_full_scroll(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
748void segag80r_state::draw_background_full_scroll(bitmap_ind16 &bitmap, const rectangle &cliprect)
754749{
755   segag80r_state *state = machine.driver_data<segag80r_state>();
756   bitmap_ind16 &pixmap = state->m_bg_tilemap->pixmap();
757   int flipmask = (state->m_video_control & 0x08) ? 0x3ff : 0x000;
750   bitmap_ind16 &pixmap = m_bg_tilemap->pixmap();
751   int flipmask = (m_video_control & 0x08) ? 0x3ff : 0x000;
758752   int xmask = pixmap.width() - 1;
759753   int ymask = pixmap.height() - 1;
760754   int x, y;
761755
762756   /* if disabled, draw nothing */
763   if (!state->m_bg_enable)
757   if (!m_bg_enable)
764758   {
765759      bitmap.fill(0, cliprect);
766760      return;
r20977r20978
769763   /* now fill in the background wherever there are black pixels */
770764   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
771765   {
772      int effy = (y + state->m_bg_scrolly) ^ flipmask;
766      int effy = (y + m_bg_scrolly) ^ flipmask;
773767      UINT16 *src = &pixmap.pix16(effy & ymask);
774768      UINT16 *dst = &bitmap.pix16(y);
775769
776770      /* loop over horizontal pixels */
777771      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
778772      {
779         int effx = (x + state->m_bg_scrollx) ^ flipmask;
773         int effx = (x + m_bg_scrollx) ^ flipmask;
780774         dst[x] = src[effx & xmask];
781775      }
782776   }
r20977r20978
800794      /* background: none */
801795      case G80_BACKGROUND_NONE:
802796         memset(transparent_pens, 0, 16);
803         draw_videoram(machine(), bitmap, cliprect, transparent_pens);
797         draw_videoram(bitmap, cliprect, transparent_pens);
804798         break;
805799
806800      /* foreground: visible except where black */
r20977r20978
808802      /* we draw the foreground first, then the background to do collision detection */
809803      case G80_BACKGROUND_SPACEOD:
810804         memset(transparent_pens, 0, 16);
811         draw_videoram(machine(), bitmap, cliprect, transparent_pens);
812         draw_background_spaceod(machine(), bitmap, cliprect);
805         draw_videoram(bitmap, cliprect, transparent_pens);
806         draw_background_spaceod(bitmap, cliprect);
813807         break;
814808
815809      /* foreground: visible except for pen 0 (this disagrees with schematics) */
816810      /* background: page-granular scrolling */
817811      case G80_BACKGROUND_MONSTERB:
818812         memset(transparent_pens, 1, 16);
819         draw_background_page_scroll(machine(), bitmap, cliprect);
820         draw_videoram(machine(), bitmap, cliprect, transparent_pens);
813         draw_background_page_scroll(bitmap, cliprect);
814         draw_videoram(bitmap, cliprect, transparent_pens);
821815         break;
822816
823817      /* foreground: visible except for pen 0 */
824818      /* background: full scrolling */
825819      case G80_BACKGROUND_PIGNEWT:
826820         memset(transparent_pens, 1, 16);
827         draw_background_full_scroll(machine(), bitmap, cliprect);
828         draw_videoram(machine(), bitmap, cliprect, transparent_pens);
821         draw_background_full_scroll(bitmap, cliprect);
822         draw_videoram(bitmap, cliprect, transparent_pens);
829823         break;
830824
831825      /* foreground: visible except for pen 0 */
832826      /* background: page-granular scrolling */
833827      case G80_BACKGROUND_SINDBADM:
834828         memset(transparent_pens, 1, 16);
835         draw_background_page_scroll(machine(), bitmap, cliprect);
836         draw_videoram(machine(), bitmap, cliprect, transparent_pens);
829         draw_background_page_scroll(bitmap, cliprect);
830         draw_videoram(bitmap, cliprect, transparent_pens);
837831         break;
838832   }
839833   return 0;
trunk/src/mame/video/suprridr.c
r20977r20978
121121}
122122
123123
124int suprridr_is_screen_flipped(running_machine &machine)
124int suprridr_state::suprridr_is_screen_flipped()
125125{
126   suprridr_state *state = machine.driver_data<suprridr_state>();
127   return state->m_flipx;  /* or is it flipy? */
126   return m_flipx;  /* or is it flipy? */
128127}
129128
130129
trunk/src/mame/video/sbasketb.c
r20977r20978
131131   m_bg_tilemap->set_scroll_cols(32);
132132}
133133
134static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
134void sbasketb_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
135135{
136   sbasketb_state *state = machine.driver_data<sbasketb_state>();
137   UINT8 *spriteram = state->m_spriteram;
138   int offs = (*state->m_spriteram_select & 0x01) * 0x100;
136   UINT8 *spriteram = m_spriteram;
137   int offs = (*m_spriteram_select & 0x01) * 0x100;
139138   int i;
140139
141140   for (i = 0; i < 64; i++, offs += 4)
r20977r20978
146145      if (sx || sy)
147146      {
148147         int code  =  spriteram[offs + 0] | ((spriteram[offs + 1] & 0x20) << 3);
149         int color = (spriteram[offs + 1] & 0x0f) + 16 * *state->m_palettebank;
148         int color = (spriteram[offs + 1] & 0x0f) + 16 * *m_palettebank;
150149         int flipx =  spriteram[offs + 1] & 0x40;
151150         int flipy =  spriteram[offs + 1] & 0x80;
152151
153         if (state->flip_screen())
152         if (flip_screen())
154153         {
155154            sx = 240 - sx;
156155            sy = 240 - sy;
r20977r20978
159158         }
160159
161160         drawgfx_transpen(bitmap,cliprect,
162            machine.gfx[1],
161            machine().gfx[1],
163162            code, color,
164163            flipx, flipy,
165164            sx, sy, 0);
r20977r20978
175174      m_bg_tilemap->set_scrolly(col, *m_scroll);
176175
177176   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
178   draw_sprites(machine(), bitmap, cliprect);
177   draw_sprites(bitmap, cliprect);
179178   return 0;
180179}
trunk/src/mame/video/skullxbo.c
r20977r20978
187187 *
188188 *************************************/
189189
190void skullxbo_scanline_update(running_machine &machine, int scanline)
190void skullxbo_state::skullxbo_scanline_update(int scanline)
191191{
192   skullxbo_state *state = machine.driver_data<skullxbo_state>();
193   UINT16 *base = &state->m_alpha[(scanline / 8) * 64 + 42];
192   UINT16 *base = &m_alpha[(scanline / 8) * 64 + 42];
194193   int x;
195194
196195   /* keep in range */
197   if (base >= &state->m_alpha[0x7c0])
196   if (base >= &m_alpha[0x7c0])
198197      return;
199198
200199   /* special case: scanline 0 should re-latch the previous raw scroll */
201200   if (scanline == 0)
202201   {
203      int newscroll = (*state->m_yscroll >> 7) & 0x1ff;
204      state->m_playfield_tilemap->set_scrolly(0, newscroll);
202      int newscroll = (*m_yscroll >> 7) & 0x1ff;
203      m_playfield_tilemap->set_scrolly(0, newscroll);
205204      atarimo_set_yscroll(0, newscroll);
206205   }
207206
r20977r20978
219218
220219         /* force a partial update with the previous scroll */
221220         if (scanline > 0)
222            machine.primary_screen->update_partial(scanline - 1);
221            machine().primary_screen->update_partial(scanline - 1);
223222
224223         /* update the new scroll */
225         state->m_playfield_tilemap->set_scrolly(0, newscroll);
224         m_playfield_tilemap->set_scrolly(0, newscroll);
226225         atarimo_set_yscroll(0, newscroll);
227226
228227         /* make sure we change this value so that writes to the scroll register */
229228         /* know whether or not they are a different scroll */
230         *state->m_yscroll = data;
229         *m_yscroll = data;
231230      }
232231   }
233232}
trunk/src/mame/video/snk.c
r20977r20978
703703}
704704
705705
706static void tnk3_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const int xscroll, const int yscroll)
706void snk_state::tnk3_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, const int xscroll, const int yscroll)
707707{
708   snk_state *state = machine.driver_data<snk_state>();
709   UINT8 *spriteram = state->m_spriteram;
710   gfx_element *gfx = machine.gfx[2];
708   UINT8 *spriteram = m_spriteram;
709   gfx_element *gfx = machine().gfx[2];
711710   const int size = gfx->width();
712711   int tile_number, attributes, color, sx, sy;
713712   int xflip,yflip;
r20977r20978
719718   /* sgladiat and tnk3 have 512 tiles, bit 6 is bank and bit 5 is y-flip */
720719   /* athena has 1024 tiles, bit 6 and bit 5 are bank */
721720
722   for (offs = 0; offs < state->m_num_sprites*4; offs += 4)
721   for (offs = 0; offs < m_num_sprites*4; offs += 4)
723722   {
724723      tile_number = spriteram[offs+1];
725724      attributes  = spriteram[offs+3];
r20977r20978
745744         yflip = attributes & 0x20;
746745      }
747746
748      if (state->flip_screen())
747      if (flip_screen())
749748      {
750749         sx = 89 - size - sx;    // this causes slight misalignment in tnk3 but is correct for athena and fitegolf
751750         sy = 262 - size - sy;
r20977r20978
754753      }
755754
756755      sx &= 0x1ff;
757      sy &= state->m_yscroll_mask;    // sgladiat apparently has only 256 pixels of vertical scrolling range
756      sy &= m_yscroll_mask;    // sgladiat apparently has only 256 pixels of vertical scrolling range
758757      if (sx > 512-size) sx -= 512;
759      if (sy > (state->m_yscroll_mask+1)-size) sy -= (state->m_yscroll_mask+1);
758      if (sy > (m_yscroll_mask+1)-size) sy -= (m_yscroll_mask+1);
760759
761760      drawgfx_transtable(bitmap,cliprect,gfx,
762761            tile_number,
763762            color,
764763            xflip,yflip,
765764            sx,sy,
766            state->m_drawmode_table, machine.shadow_table);
765            m_drawmode_table, machine().shadow_table);
767766   }
768767}
769768
r20977r20978
927926   m_bg_tilemap->set_scrolly(0, m_bg_scrolly);
928927
929928   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
930   tnk3_draw_sprites(machine(), bitmap, cliprect, m_sp16_scrollx, m_sp16_scrolly);
929   tnk3_draw_sprites(bitmap, cliprect, m_sp16_scrollx, m_sp16_scrolly);
931930   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
932931
933932   return 0;
trunk/src/mame/video/segas32.c
r20977r20978
198198 *
199199 *************************************/
200200
201struct extents_list
202{
203   UINT8                   scan_extent[256];
204   UINT16                  extent[32][16];
205};
206201
207
208struct cache_entry
209{
210   struct cache_entry *    next;
211   tilemap_t *             tmap;
212   UINT8                   page;
213   UINT8                   bank;
214};
215
216
217
218202/*************************************
219203 *
220 *  Prototypes
221 *
222 *************************************/
223
224
225static void sprite_erase_buffer(segas32_state *state);
226static void sprite_swap_buffers(segas32_state *state);
227static void sprite_render_list(running_machine &machine);
228
229
230
231
232/*************************************
233 *
234204 *  Video start
235205 *
236206 *************************************/
237207
238static void common_start(running_machine &machine, int multi32)
208void segas32_state::common_start(int multi32)
239209{
240   segas32_state *state = machine.driver_data<segas32_state>();
241210   int tmap;
242211
243212   /* remember whether or not we are multi32 */
244   state->m_is_multi32 = multi32;
213   m_is_multi32 = multi32;
245214
246215   /* allocate a copy of spriteram in 32-bit format */
247   state->m_spriteram_32bit = auto_alloc_array(machine, UINT32, 0x20000/4);
216   m_spriteram_32bit = auto_alloc_array(machine(), UINT32, 0x20000/4);
248217
249218   /* allocate the tilemap cache */
250   state->m_cache_head = NULL;
219   m_cache_head = NULL;
251220   for (tmap = 0; tmap < TILEMAP_CACHE_SIZE; tmap++)
252221   {
253      struct cache_entry *entry = auto_alloc(machine, struct cache_entry);
222      struct cache_entry *entry = auto_alloc(machine(), struct cache_entry);
254223
255      entry->tmap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(segas32_state::get_tile_info),state), TILEMAP_SCAN_ROWS,  16,16, 32,16);
224      entry->tmap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(segas32_state::get_tile_info),this), TILEMAP_SCAN_ROWS,  16,16, 32,16);
256225      entry->page = 0xff;
257226      entry->bank = 0;
258      entry->next = state->m_cache_head;
227      entry->next = m_cache_head;
259228      entry->tmap->set_user_data(entry);
260229
261      state->m_cache_head = entry;
230      m_cache_head = entry;
262231   }
263232
264233   /* allocate the bitmaps (a few extra for multi32) */
265234   for (tmap = 0; tmap < 9 + 2 * multi32; tmap++)
266235   {
267      state->m_layer_data[tmap].bitmap = auto_bitmap_ind16_alloc(machine, 416, 224);
268      state->m_layer_data[tmap].transparent = auto_alloc_array_clear(machine, UINT8, 256);
236      m_layer_data[tmap].bitmap = auto_bitmap_ind16_alloc(machine(), 416, 224);
237      m_layer_data[tmap].transparent = auto_alloc_array_clear(machine(), UINT8, 256);
269238   }
270239
271240   /* allocate pre-rendered solid lines of 0's and ffff's */
272   state->m_solid_0000 = auto_alloc_array(machine, UINT16, 512);
273   memset(state->m_solid_0000, 0x00, sizeof(state->m_solid_0000[0]) * 512);
274   state->m_solid_ffff = auto_alloc_array(machine, UINT16, 512);
275   memset(state->m_solid_ffff, 0xff, sizeof(state->m_solid_ffff[0]) * 512);
241   m_solid_0000 = auto_alloc_array(machine(), UINT16, 512);
242   memset(m_solid_0000, 0x00, sizeof(m_solid_0000[0]) * 512);
243   m_solid_ffff = auto_alloc_array(machine(), UINT16, 512);
244   memset(m_solid_ffff, 0xff, sizeof(m_solid_ffff[0]) * 512);
276245
277246   /* initialize videoram */
278   state->m_system32_videoram[0x1ff00/2] = 0x8000;
247   m_system32_videoram[0x1ff00/2] = 0x8000;
279248}
280249
281250
282251VIDEO_START_MEMBER(segas32_state,system32)
283252{
284   common_start(machine(), 0);
253   common_start(0);
285254}
286255
287256
288257VIDEO_START_MEMBER(segas32_state,multi32)
289258{
290   common_start(machine(), 1);
259   common_start(1);
291260}
292261
293262
r20977r20978
313282
314283   /* look for pending commands */
315284   if (m_sprite_control[0] & 2)
316      sprite_erase_buffer(this);
285      sprite_erase_buffer();
317286   if (m_sprite_control[0] & 1)
318287   {
319      sprite_swap_buffers(this);
320      sprite_render_list(machine());
288      sprite_swap_buffers();
289      sprite_render_list();
321290   }
322291   m_sprite_control[0] = 0;
323292}
324293
325294
326void system32_set_vblank(running_machine &machine, int state)
295void segas32_state::system32_set_vblank(int state)
327296{
328   segas32_state *drvstate = machine.driver_data<segas32_state>();
329297   /* at the end of VBLANK is when automatic sprite rendering happens */
330298   if (!state)
331      machine.scheduler().timer_set(attotime::from_usec(50), timer_expired_delegate(FUNC(segas32_state::update_sprites),drvstate), 1);
299      machine().scheduler().timer_set(attotime::from_usec(50), timer_expired_delegate(FUNC(segas32_state::update_sprites),this), 1);
332300}
333301
334302
r20977r20978
339307 *
340308 *************************************/
341309
342INLINE UINT16 xBBBBBGGGGGRRRRR_to_xBGRBBBBGGGGRRRR(UINT16 value)
310inline UINT16 segas32_state::xBBBBBGGGGGRRRRR_to_xBGRBBBBGGGGRRRR(UINT16 value)
343311{
344312   int r = (value >> 0) & 0x1f;
345313   int g = (value >> 5) & 0x1f;
r20977r20978
350318}
351319
352320
353INLINE UINT16 xBGRBBBBGGGGRRRR_to_xBBBBBGGGGGRRRRR(UINT16 value)
321inline UINT16 segas32_state::xBGRBBBBGGGGRRRR_to_xBBBBBGGGGGRRRRR(UINT16 value)
354322{
355323   int r = ((value >> 12) & 0x01) | ((value << 1) & 0x1e);
356324   int g = ((value >> 13) & 0x01) | ((value >> 3) & 0x1e);
r20977r20978
359327}
360328
361329
362INLINE void update_color(running_machine &machine, int offset, UINT16 data)
330inline void segas32_state::update_color(int offset, UINT16 data)
363331{
364332   /* note that since we use this RAM directly, we don't technically need */
365333   /* to call palette_set_color() at all; however, it does give us that */
366334   /* nice display when you hit F4, which is useful for debugging */
367335
368336   /* set the color */
369   palette_set_color_rgb(machine, offset, pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
337   palette_set_color_rgb(machine(), offset, pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
370338}
371339
372340
373INLINE UINT16 common_paletteram_r(address_space &space, int which, offs_t offset)
341inline UINT16 segas32_state::common_paletteram_r(address_space &space, int which, offs_t offset)
374342{
375   segas32_state *state = space.machine().driver_data<segas32_state>();
376343   int convert;
377344
378345   /* the lower half of palette RAM is formatted xBBBBBGGGGGRRRRR */
r20977r20978
383350   offset &= 0x3fff;
384351
385352   if (!convert)
386      return state->m_system32_paletteram[which][offset];
353      return m_system32_paletteram[which][offset];
387354   else
388      return xBBBBBGGGGGRRRRR_to_xBGRBBBBGGGGRRRR(state->m_system32_paletteram[which][offset]);
355      return xBBBBBGGGGGRRRRR_to_xBGRBBBBGGGGRRRR(m_system32_paletteram[which][offset]);
389356}
390357
391358
392static void common_paletteram_w(address_space &space, int which, offs_t offset, UINT16 data, UINT16 mem_mask)
359void segas32_state::common_paletteram_w(address_space &space, int which, offs_t offset, UINT16 data, UINT16 mem_mask)
393360{
394   segas32_state *state = space.machine().driver_data<segas32_state>();
395361   UINT16 value;
396362   int convert;
397363
r20977r20978
403369   offset &= 0x3fff;
404370
405371   /* read, modify, and write the new value, updating the palette */
406   value = state->m_system32_paletteram[which][offset];
372   value = m_system32_paletteram[which][offset];
407373   if (convert) value = xBBBBBGGGGGRRRRR_to_xBGRBBBBGGGGRRRR(value);
408374   COMBINE_DATA(&value);
409375   if (convert) value = xBGRBBBBGGGGRRRR_to_xBBBBBGGGGGRRRRR(value);
410   state->m_system32_paletteram[which][offset] = value;
411   update_color(space.machine(), 0x4000*which + offset, value);
376   m_system32_paletteram[which][offset] = value;
377   update_color(0x4000*which + offset, value);
412378
413379   /* if blending is enabled, writes go to both halves of palette RAM */
414   if (state->m_mixer_control[which][0x4e/2] & 0x0880)
380   if (m_mixer_control[which][0x4e/2] & 0x0880)
415381   {
416382      offset ^= 0x2000;
417383
418384      /* read, modify, and write the new value, updating the palette */
419      value = state->m_system32_paletteram[which][offset];
385      value = m_system32_paletteram[which][offset];
420386      if (convert) value = xBBBBBGGGGGRRRRR_to_xBGRBBBBGGGGRRRR(value);
421387      COMBINE_DATA(&value);
422388      if (convert) value = xBGRBBBBGGGGRRRR_to_xBBBBBGGGGGRRRRR(value);
423      state->m_system32_paletteram[which][offset] = value;
424      update_color(space.machine(), 0x4000*which + offset, value);
389      m_system32_paletteram[which][offset] = value;
390      update_color(0x4000*which + offset, value);
425391   }
426392}
427393
r20977r20978
698664 *
699665 *************************************/
700666
701static tilemap_t *find_cache_entry(segas32_state *state, int page, int bank)
667tilemap_t *segas32_state::find_cache_entry(int page, int bank)
702668{
703   struct cache_entry *entry, *prev;
669   struct segas32_state::cache_entry *entry, *prev;
704670
705671   /* scan the list for a matching entry */
706672   prev = NULL;
707   entry = state->m_cache_head;
673   entry = m_cache_head;
708674   while (1)
709675   {
710676      if (entry->page == page && entry->bank == bank)
r20977r20978
713679         if (prev)
714680         {
715681            prev->next = entry->next;
716            entry->next = state->m_cache_head;
717            state->m_cache_head = entry;
682            entry->next = m_cache_head;
683            m_cache_head = entry;
718684         }
719685         return entry->tmap;
720686      }
r20977r20978
733699
734700   /* move it to the head */
735701   prev->next = entry->next;
736   entry->next = state->m_cache_head;
737   state->m_cache_head = entry;
702   entry->next = m_cache_head;
703   m_cache_head = entry;
738704
739705   return entry->tmap;
740706}
r20977r20978
749715
750716TILE_GET_INFO_MEMBER(segas32_state::get_tile_info)
751717{
752   struct cache_entry *entry = (struct cache_entry *)param;
718   struct segas32_state::cache_entry *entry = (struct segas32_state::cache_entry *)param;
753719   UINT16 data = m_system32_videoram[(entry->page & 0x7f) * 0x200 + tile_index];
754720   SET_TILE_INFO_MEMBER(0, (entry->bank << 13) + (data & 0x1fff), (data >> 4) & 0x1ff, (data >> 14) & 3);
755721}
r20977r20978
762728 *
763729 *************************************/
764730
765static int compute_clipping_extents(screen_device &screen, int enable, int clipout, int clipmask, const rectangle &cliprect, struct extents_list *list)
731int segas32_state::compute_clipping_extents(screen_device &screen, int enable, int clipout, int clipmask, const rectangle &cliprect, struct extents_list *list)
766732{
767   segas32_state *state = screen.machine().driver_data<segas32_state>();
768   int flip = (state->m_system32_videoram[0x1ff00/2] >> 9) & 1;
733   int flip = (m_system32_videoram[0x1ff00/2] >> 9) & 1;
769734   rectangle tempclip;
770735   rectangle clips[5];
771736   int sorted[5];
r20977r20978
792757   {
793758      if (!flip)
794759      {
795         clips[i].min_x = state->m_system32_videoram[0x1ff60/2 + i * 4] & 0x1ff;
796         clips[i].min_y = state->m_system32_videoram[0x1ff62/2 + i * 4] & 0x0ff;
797         clips[i].max_x = (state->m_system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1;
798         clips[i].max_y = (state->m_system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1;
760         clips[i].min_x = m_system32_videoram[0x1ff60/2 + i * 4] & 0x1ff;
761         clips[i].min_y = m_system32_videoram[0x1ff62/2 + i * 4] & 0x0ff;
762         clips[i].max_x = (m_system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1;
763         clips[i].max_y = (m_system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1;
799764      }
800765      else
801766      {
802767         const rectangle &visarea = screen.visible_area();
803768
804         clips[i].max_x = (visarea.max_x + 1) - (state->m_system32_videoram[0x1ff60/2 + i * 4] & 0x1ff);
805         clips[i].max_y = (visarea.max_y + 1) - (state->m_system32_videoram[0x1ff62/2 + i * 4] & 0x0ff);
806         clips[i].min_x = (visarea.max_x + 1) - ((state->m_system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1);
807         clips[i].min_y = (visarea.max_y + 1) - ((state->m_system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1);
769         clips[i].max_x = (visarea.max_x + 1) - (m_system32_videoram[0x1ff60/2 + i * 4] & 0x1ff);
770         clips[i].max_y = (visarea.max_y + 1) - (m_system32_videoram[0x1ff62/2 + i * 4] & 0x0ff);
771         clips[i].min_x = (visarea.max_x + 1) - ((m_system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1);
772         clips[i].min_y = (visarea.max_y + 1) - ((m_system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1);
808773      }
809774      clips[i] &= tempclip;
810775      sorted[i] = i;
r20977r20978
872837 *
873838 *************************************/
874839
875INLINE void get_tilemaps(segas32_state *state, int bgnum, tilemap_t **tilemaps)
840inline void segas32_state::get_tilemaps(int bgnum, tilemap_t **tilemaps)
876841{
877842   int tilebank, page;
878843
879844   /* determine the current tilebank */
880   if (state->m_is_multi32)
881      tilebank = (state->m_system32_tilebank_external >> (2*bgnum)) & 3;
845   if (m_is_multi32)
846      tilebank = (m_system32_tilebank_external >> (2*bgnum)) & 3;
882847   else
883      tilebank = ((state->m_system32_tilebank_external & 1) << 1) | ((state->m_system32_videoram[0x1ff00/2] & 0x400) >> 10);
848      tilebank = ((m_system32_tilebank_external & 1) << 1) | ((m_system32_videoram[0x1ff00/2] & 0x400) >> 10);
884849
885850   /* find the cache entries */
886   page = (state->m_system32_videoram[0x1ff40/2 + 2 * bgnum + 0] >> 0) & 0x7f;
887   tilemaps[0] = find_cache_entry(state, page, tilebank);
888   page = (state->m_system32_videoram[0x1ff40/2 + 2 * bgnum + 0] >> 8) & 0x7f;
889   tilemaps[1] = find_cache_entry(state, page, tilebank);
890   page = (state->m_system32_videoram[0x1ff40/2 + 2 * bgnum + 1] >> 0) & 0x7f;
891   tilemaps[2] = find_cache_entry(state, page, tilebank);
892   page = (state->m_system32_videoram[0x1ff40/2 + 2 * bgnum + 1] >> 8) & 0x7f;
893   tilemaps[3] = find_cache_entry(state, page, tilebank);
851   page = (m_system32_videoram[0x1ff40/2 + 2 * bgnum + 0] >> 0) & 0x7f;
852   tilemaps[0] = find_cache_entry(page, tilebank);
853   page = (m_system32_videoram[0x1ff40/2 + 2 * bgnum + 0] >> 8) & 0x7f;
854   tilemaps[1] = find_cache_entry(page, tilebank);
855   page = (m_system32_videoram[0x1ff40/2 + 2 * bgnum + 1] >> 0) & 0x7f;
856   tilemaps[2] = find_cache_entry(page, tilebank);
857   page = (m_system32_videoram[0x1ff40/2 + 2 * bgnum + 1] >> 8) & 0x7f;
858   tilemaps[3] = find_cache_entry(page, tilebank);
894859}
895860
896861
897static void update_tilemap_zoom(screen_device &screen, struct layer_info *layer, const rectangle &cliprect, int bgnum)
862void segas32_state::update_tilemap_zoom(screen_device &screen, struct segas32_state::layer_info *layer, const rectangle &cliprect, int bgnum)
898863{
899   segas32_state *state = screen.machine().driver_data<segas32_state>();
900864   int clipenable, clipout, clips, clipdraw_start;
901865   bitmap_ind16 &bitmap = *layer->bitmap;
902866   struct extents_list clip_extents;
r20977r20978
908872   int x, y;
909873
910874   /* get the tilemaps */
911   get_tilemaps(state, bgnum, tilemaps);
875   get_tilemaps(bgnum, tilemaps);
912876
913877   /* configure the layer */
914878   opaque = 0;
r20977r20978
917881//if (screen.machine().input().code_pressed(KEYCODE_X) && bgnum == 1) opaque = 1;
918882
919883   /* determine if we're flipped */
920   flip = ((state->m_system32_videoram[0x1ff00/2] >> 9) ^ (state->m_system32_videoram[0x1ff00/2] >> bgnum)) & 1;
884   flip = ((m_system32_videoram[0x1ff00/2] >> 9) ^ (m_system32_videoram[0x1ff00/2] >> bgnum)) & 1;
921885
922886   /* determine the clipping */
923   clipenable = (state->m_system32_videoram[0x1ff02/2] >> (11 + bgnum)) & 1;
924   clipout = (state->m_system32_videoram[0x1ff02/2] >> (6 + bgnum)) & 1;
925   clips = (state->m_system32_videoram[0x1ff06/2] >> (4 * bgnum)) & 0x0f;
887   clipenable = (m_system32_videoram[0x1ff02/2] >> (11 + bgnum)) & 1;
888   clipout = (m_system32_videoram[0x1ff02/2] >> (6 + bgnum)) & 1;
889   clips = (m_system32_videoram[0x1ff06/2] >> (4 * bgnum)) & 0x0f;
926890   clipdraw_start = compute_clipping_extents(screen, clipenable, clipout, clips, cliprect, &clip_extents);
927891
928892   /* extract the X/Y step values (these are in destination space!) */
929   dstxstep = state->m_system32_videoram[0x1ff50/2 + 2 * bgnum] & 0xfff;
930   if (state->m_system32_videoram[0x1ff00/2] & 0x4000)
931      dstystep = state->m_system32_videoram[0x1ff52/2 + 2 * bgnum] & 0xfff;
893   dstxstep = m_system32_videoram[0x1ff50/2 + 2 * bgnum] & 0xfff;
894   if (m_system32_videoram[0x1ff00/2] & 0x4000)
895      dstystep = m_system32_videoram[0x1ff52/2 + 2 * bgnum] & 0xfff;
932896   else
933897      dstystep = dstxstep;
934898
r20977r20978
943907   srcystep = (0x200 << 20) / dstystep;
944908
945909   /* start with the fractional scroll offsets, in source coordinates */
946   srcx_start = (state->m_system32_videoram[0x1ff12/2 + 4 * bgnum] & 0x3ff) << 20;
947   srcx_start += (state->m_system32_videoram[0x1ff10/2 + 4 * bgnum] & 0xff00) << 4;
948   srcy = (state->m_system32_videoram[0x1ff16/2 + 4 * bgnum] & 0x1ff) << 20;
949   srcy += (state->m_system32_videoram[0x1ff14/2 + 4 * bgnum] & 0xfe00) << 4;
910   srcx_start = (m_system32_videoram[0x1ff12/2 + 4 * bgnum] & 0x3ff) << 20;
911   srcx_start += (m_system32_videoram[0x1ff10/2 + 4 * bgnum] & 0xff00) << 4;
912   srcy = (m_system32_videoram[0x1ff16/2 + 4 * bgnum] & 0x1ff) << 20;
913   srcy += (m_system32_videoram[0x1ff14/2 + 4 * bgnum] & 0xfe00) << 4;
950914
951915   /* then account for the destination center coordinates */
952   srcx_start -= ((INT16)(state->m_system32_videoram[0x1ff30/2 + 2 * bgnum] << 6) >> 6) * srcxstep;
953   srcy -= ((INT16)(state->m_system32_videoram[0x1ff32/2 + 2 * bgnum] << 7) >> 7) * srcystep;
916   srcx_start -= ((INT16)(m_system32_videoram[0x1ff30/2 + 2 * bgnum] << 6) >> 6) * srcxstep;
917   srcy -= ((INT16)(m_system32_videoram[0x1ff32/2 + 2 * bgnum] << 7) >> 7) * srcystep;
954918
955919   /* finally, account for destination top,left coordinates */
956920   srcx_start += cliprect.min_x * srcxstep;
r20977r20978
1034998#if 0
1035999   if (dstxstep != 0x200 || dstystep != 0x200)
10361000      popmessage("Zoom=%03X,%03X  Cent=%03X,%03X", dstxstep, dstystep,
1037         state->m_system32_videoram[0x1ff30/2 + 2 * bgnum],
1038         state->m_system32_videoram[0x1ff32/2 + 2 * bgnum]);
1001         m_system32_videoram[0x1ff30/2 + 2 * bgnum],
1002         m_system32_videoram[0x1ff32/2 + 2 * bgnum]);
10391003#endif
10401004}
10411005
r20977r20978
10471011 *
10481012 *************************************/
10491013
1050static void update_tilemap_rowscroll(screen_device &screen, struct layer_info *layer, const rectangle &cliprect, int bgnum)
1014void segas32_state::update_tilemap_rowscroll(screen_device &screen, struct segas32_state::layer_info *layer, const rectangle &cliprect, int bgnum)
10511015{
1052   segas32_state *state = screen.machine().driver_data<segas32_state>();
10531016   int clipenable, clipout, clips, clipdraw_start;
10541017   bitmap_ind16 &bitmap = *layer->bitmap;
10551018   struct extents_list clip_extents;
r20977r20978
10621025   int x, y;
10631026
10641027   /* get the tilemaps */
1065   get_tilemaps(state, bgnum, tilemaps);
1028   get_tilemaps(bgnum, tilemaps);
10661029
10671030   /* configure the layer */
10681031   opaque = 0;
1069//opaque = (state->m_system32_videoram[0x1ff8e/2] >> (8 + bgnum)) & 1;
1032//opaque = (m_system32_videoram[0x1ff8e/2] >> (8 + bgnum)) & 1;
10701033//if (screen.machine().input().code_pressed(KEYCODE_C) && bgnum == 2) opaque = 1;
10711034//if (screen.machine().input().code_pressed(KEYCODE_V) && bgnum == 3) opaque = 1;
10721035
10731036   /* determine if we're flipped */
1074   flip = ((state->m_system32_videoram[0x1ff00/2] >> 9) ^ (state->m_system32_videoram[0x1ff00/2] >> bgnum)) & 1;
1037   flip = ((m_system32_videoram[0x1ff00/2] >> 9) ^ (m_system32_videoram[0x1ff00/2] >> bgnum)) & 1;
10751038
10761039   /* determine the clipping */
1077   clipenable = (state->m_system32_videoram[0x1ff02/2] >> (11 + bgnum)) & 1;
1078   clipout = (state->m_system32_videoram[0x1ff02/2] >> (6 + bgnum)) & 1;
1079   clips = (state->m_system32_videoram[0x1ff06/2] >> (4 * bgnum)) & 0x0f;
1040   clipenable = (m_system32_videoram[0x1ff02/2] >> (11 + bgnum)) & 1;
1041   clipout = (m_system32_videoram[0x1ff02/2] >> (6 + bgnum)) & 1;
1042   clips = (m_system32_videoram[0x1ff06/2] >> (4 * bgnum)) & 0x0f;
10801043   clipdraw_start = compute_clipping_extents(screen, clipenable, clipout, clips, cliprect, &clip_extents);
10811044
10821045   /* determine if row scroll and/or row select is enabled */
1083   rowscroll = (state->m_system32_videoram[0x1ff04/2] >> (bgnum - 2)) & 1;
1084   rowselect = (state->m_system32_videoram[0x1ff04/2] >> bgnum) & 1;
1085   if ((state->m_system32_videoram[0x1ff04/2] >> (bgnum + 2)) & 1)
1046   rowscroll = (m_system32_videoram[0x1ff04/2] >> (bgnum - 2)) & 1;
1047   rowselect = (m_system32_videoram[0x1ff04/2] >> bgnum) & 1;
1048   if ((m_system32_videoram[0x1ff04/2] >> (bgnum + 2)) & 1)
10861049      rowscroll = rowselect = 0;
10871050
10881051   /* get a pointer to the table */
1089   table = &state->m_system32_videoram[(state->m_system32_videoram[0x1ff04/2] >> 10) * 0x400];
1052   table = &m_system32_videoram[(m_system32_videoram[0x1ff04/2] >> 10) * 0x400];
10901053
10911054   /* start with screen-wide X and Y scrolls */
1092   xscroll = (state->m_system32_videoram[0x1ff12/2 + 4 * bgnum] & 0x3ff) - (state->m_system32_videoram[0x1ff30/2 + 2 * bgnum] & 0x1ff);
1093   yscroll = (state->m_system32_videoram[0x1ff16/2 + 4 * bgnum] & 0x1ff);
1055   xscroll = (m_system32_videoram[0x1ff12/2 + 4 * bgnum] & 0x3ff) - (m_system32_videoram[0x1ff30/2 + 2 * bgnum] & 0x1ff);
1056   yscroll = (m_system32_videoram[0x1ff16/2 + 4 * bgnum] & 0x1ff);
10941057
10951058   /* render the tilemap into its bitmap */
10961059   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
r20977r20978
11871150#if 0
11881151   if (rowscroll || rowselect)
11891152      popmessage("Scroll=%d Select=%d  Table@%06X",
1190         rowscroll, rowselect, (state->m_system32_videoram[0x1ff04/2] >> 10) * 0x800);
1153         rowscroll, rowselect, (m_system32_videoram[0x1ff04/2] >> 10) * 0x800);
11911154#endif
11921155}
11931156
r20977r20978
11991162 *
12001163 *************************************/
12011164
1202static void update_tilemap_text(screen_device &screen, struct layer_info *layer, const rectangle &cliprect)
1165void segas32_state::update_tilemap_text(screen_device &screen, struct segas32_state::layer_info *layer, const rectangle &cliprect)
12031166{
1204   segas32_state *state = screen.machine().driver_data<segas32_state>();
12051167   bitmap_ind16 &bitmap = *layer->bitmap;
12061168   UINT16 *tilebase;
12071169   UINT16 *gfxbase;
r20977r20978
12111173   int flip;
12121174
12131175   /* determine if we're flipped */
1214   flip = (state->m_system32_videoram[0x1ff00/2] >> 9) & 1;
1176   flip = (m_system32_videoram[0x1ff00/2] >> 9) & 1;
12151177
12161178   /* determine the base of the tilemap and graphics data */
1217   tilebase = &state->m_system32_videoram[((state->m_system32_videoram[0x1ff5c/2] >> 4) & 0x1f) * 0x800];
1218   gfxbase = &state->m_system32_videoram[(state->m_system32_videoram[0x1ff5c/2] & 7) * 0x2000];
1179   tilebase = &m_system32_videoram[((m_system32_videoram[0x1ff5c/2] >> 4) & 0x1f) * 0x800];
1180   gfxbase = &m_system32_videoram[(m_system32_videoram[0x1ff5c/2] & 7) * 0x2000];
12191181
12201182   /* compute start/end tile numbers */
12211183   startx = cliprect.min_x / 8;
r20977r20978
13591321 *
13601322 *************************************/
13611323
1362static void update_bitmap(screen_device &screen, struct layer_info *layer, const rectangle &cliprect)
1324void segas32_state::update_bitmap(screen_device &screen, struct segas32_state::layer_info *layer, const rectangle &cliprect)
13631325{
1364   segas32_state *state = screen.machine().driver_data<segas32_state>();
13651326   int clipenable, clipout, clips, clipdraw_start;
13661327   bitmap_ind16 &bitmap = *layer->bitmap;
13671328   struct extents_list clip_extents;
r20977r20978
13711332   int bpp;
13721333
13731334   /* configure the layer */
1374   bpp = (state->m_system32_videoram[0x1ff00/2] & 0x0800) ? 8 : 4;
1335   bpp = (m_system32_videoram[0x1ff00/2] & 0x0800) ? 8 : 4;
13751336
13761337   /* determine the clipping */
1377   clipenable = (state->m_system32_videoram[0x1ff02/2] >> 15) & 1;
1378   clipout = (state->m_system32_videoram[0x1ff02/2] >> 10) & 1;
1338   clipenable = (m_system32_videoram[0x1ff02/2] >> 15) & 1;
1339   clipout = (m_system32_videoram[0x1ff02/2] >> 10) & 1;
13791340   clips = 0x10;
13801341   clipdraw_start = compute_clipping_extents(screen, clipenable, clipout, clips, cliprect, &clip_extents);
13811342
13821343   /* determine x/y scroll */
1383   xscroll = state->m_system32_videoram[0x1ff88/2] & 0x1ff;
1384   yscroll = state->m_system32_videoram[0x1ff8a/2] & 0x1ff;
1385   color = (state->m_system32_videoram[0x1ff8c/2] << 4) & 0x1fff0 & ~((1 << bpp) - 1);
1344   xscroll = m_system32_videoram[0x1ff88/2] & 0x1ff;
1345   yscroll = m_system32_videoram[0x1ff8a/2] & 0x1ff;
1346   color = (m_system32_videoram[0x1ff8c/2] << 4) & 0x1fff0 & ~((1 << bpp) - 1);
13861347
13871348   /* loop over target rows */
13881349   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
r20977r20978
14051366               /* 8bpp mode case */
14061367               if (bpp == 8)
14071368               {
1408                  UINT8 *src = (UINT8 *)&state->m_system32_videoram[512/2 * ((y + yscroll) & 0xff)];
1369                  UINT8 *src = (UINT8 *)&m_system32_videoram[512/2 * ((y + yscroll) & 0xff)];
14091370                  for (x = extents[0]; x < extents[1]; x++)
14101371                  {
14111372                     int effx = (x + xscroll) & 0x1ff;
r20977r20978
14191380               /* 4bpp mode case */
14201381               else
14211382               {
1422                  UINT16 *src = &state->m_system32_videoram[512/4 * ((y + yscroll) & 0x1ff)];
1383                  UINT16 *src = &m_system32_videoram[512/4 * ((y + yscroll) & 0x1ff)];
14231384                  for (x = extents[0]; x < extents[1]; x++)
14241385                  {
14251386                     int effx = (x + xscroll) & 0x1ff;
r20977r20978
14631424 *
14641425 *************************************/
14651426
1466static void update_background(segas32_state *state, struct layer_info *layer, const rectangle &cliprect)
1427void segas32_state::update_background(struct segas32_state::layer_info *layer, const rectangle &cliprect)
14671428{
14681429   bitmap_ind16 &bitmap = *layer->bitmap;
14691430   int x, y;
r20977r20978
14741435      int color;
14751436
14761437      /* determine the color */
1477      if (state->m_system32_videoram[0x1ff5e/2] & 0x8000)
1478         color = (state->m_system32_videoram[0x1ff5e/2] & 0x1fff) + y;
1438      if (m_system32_videoram[0x1ff5e/2] & 0x8000)
1439         color = (m_system32_videoram[0x1ff5e/2] & 0x1fff) + y;
14791440      else
1480         color = state->m_system32_videoram[0x1ff5e/2] & 0x1e00;
1441         color = m_system32_videoram[0x1ff5e/2] & 0x1e00;
14811442
14821443      /* if the color doesn't match, fill */
14831444      if (dst[cliprect.min_x] != color)
r20977r20978
14871448}
14881449
14891450
1490static UINT8 update_tilemaps(screen_device &screen, const rectangle &cliprect)
1451UINT8 segas32_state::update_tilemaps(screen_device &screen, const rectangle &cliprect)
14911452{
1492   segas32_state *state = screen.machine().driver_data<segas32_state>();
1493   int enable0 = !(state->m_system32_videoram[0x1ff02/2] & 0x0001) && !(state->m_system32_videoram[0x1ff8e/2] & 0x0002);
1494   int enable1 = !(state->m_system32_videoram[0x1ff02/2] & 0x0002) && !(state->m_system32_videoram[0x1ff8e/2] & 0x0004);
1495   int enable2 = !(state->m_system32_videoram[0x1ff02/2] & 0x0004) && !(state->m_system32_videoram[0x1ff8e/2] & 0x0008) && !(state->m_system32_videoram[0x1ff00/2] & 0x1000);
1496   int enable3 = !(state->m_system32_videoram[0x1ff02/2] & 0x0008) && !(state->m_system32_videoram[0x1ff8e/2] & 0x0010) && !(state->m_system32_videoram[0x1ff00/2] & 0x2000);
1497   int enablet = !(state->m_system32_videoram[0x1ff02/2] & 0x0010) && !(state->m_system32_videoram[0x1ff8e/2] & 0x0001);
1498   int enableb = !(state->m_system32_videoram[0x1ff02/2] & 0x0020) && !(state->m_system32_videoram[0x1ff8e/2] & 0x0020);
1453   int enable0 = !(m_system32_videoram[0x1ff02/2] & 0x0001) && !(m_system32_videoram[0x1ff8e/2] & 0x0002);
1454   int enable1 = !(m_system32_videoram[0x1ff02/2] & 0x0002) && !(m_system32_videoram[0x1ff8e/2] & 0x0004);
1455   int enable2 = !(m_system32_videoram[0x1ff02/2] & 0x0004) && !(m_system32_videoram[0x1ff8e/2] & 0x0008) && !(m_system32_videoram[0x1ff00/2] & 0x1000);
1456   int enable3 = !(m_system32_videoram[0x1ff02/2] & 0x0008) && !(m_system32_videoram[0x1ff8e/2] & 0x0010) && !(m_system32_videoram[0x1ff00/2] & 0x2000);
1457   int enablet = !(m_system32_videoram[0x1ff02/2] & 0x0010) && !(m_system32_videoram[0x1ff8e/2] & 0x0001);
1458   int enableb = !(m_system32_videoram[0x1ff02/2] & 0x0020) && !(m_system32_videoram[0x1ff8e/2] & 0x0020);
14991459
15001460   /* update any tilemaps */
15011461   if (enable0)
1502      update_tilemap_zoom(screen, &state->m_layer_data[MIXER_LAYER_NBG0], cliprect, 0);
1462      update_tilemap_zoom(screen, &m_layer_data[MIXER_LAYER_NBG0], cliprect, 0);
15031463   if (enable1)
1504      update_tilemap_zoom(screen, &state->m_layer_data[MIXER_LAYER_NBG1], cliprect, 1);
1464      update_tilemap_zoom(screen, &m_layer_data[MIXER_LAYER_NBG1], cliprect, 1);
15051465   if (enable2)
1506      update_tilemap_rowscroll(screen, &state->m_layer_data[MIXER_LAYER_NBG2], cliprect, 2);
1466      update_tilemap_rowscroll(screen, &m_layer_data[MIXER_LAYER_NBG2], cliprect, 2);
15071467   if (enable3)
1508      update_tilemap_rowscroll(screen, &state->m_layer_data[MIXER_LAYER_NBG3], cliprect, 3);
1468      update_tilemap_rowscroll(screen, &m_layer_data[MIXER_LAYER_NBG3], cliprect, 3);
15091469   if (enablet)
1510      update_tilemap_text(screen, &state->m_layer_data[MIXER_LAYER_TEXT], cliprect);
1470      update_tilemap_text(screen, &m_layer_data[MIXER_LAYER_TEXT], cliprect);
15111471   if (enableb)
1512      update_bitmap(screen, &state->m_layer_data[MIXER_LAYER_BITMAP], cliprect);
1513   update_background(state, &state->m_layer_data[MIXER_LAYER_BACKGROUND], cliprect);
1472      update_bitmap(screen, &m_layer_data[MIXER_LAYER_BITMAP], cliprect);
1473   update_background(&m_layer_data[MIXER_LAYER_BACKGROUND], cliprect);
15141474
15151475   return (enablet << 0) | (enable0 << 1) | (enable1 << 2) | (enable2 << 3) | (enable3 << 4) | (enableb << 5);
15161476}
r20977r20978
15231483 *
15241484 *************************************/
15251485
1526static void sprite_erase_buffer(segas32_state *state)
1486void segas32_state::sprite_erase_buffer()
15271487{
15281488   /* erase the visible sprite buffer and clear the checksums */
1529   state->m_layer_data[MIXER_LAYER_SPRITES].bitmap->fill(0xffff);
1489   m_layer_data[MIXER_LAYER_SPRITES].bitmap->fill(0xffff);
15301490
15311491   /* for multi32, erase the other buffer as well */
1532   if (state->m_is_multi32)
1533      state->m_layer_data[MIXER_LAYER_MULTISPR].bitmap->fill(0xffff);
1492   if (m_is_multi32)
1493      m_layer_data[MIXER_LAYER_MULTISPR].bitmap->fill(0xffff);
15341494}
15351495
15361496
1537static void sprite_swap_buffers(segas32_state *state)
1497void segas32_state::sprite_swap_buffers()
15381498{
15391499   /* swap between the two sprite buffers */
1540   struct layer_info temp;
1541   temp = state->m_layer_data[MIXER_LAYER_SPRITES];
1542   state->m_layer_data[MIXER_LAYER_SPRITES] = state->m_layer_data[MIXER_LAYER_SPRITES_2];
1543   state->m_layer_data[MIXER_LAYER_SPRITES_2] = temp;
1500   struct segas32_state::layer_info temp;
1501   temp = m_layer_data[MIXER_LAYER_SPRITES];
1502   m_layer_data[MIXER_LAYER_SPRITES] = m_layer_data[MIXER_LAYER_SPRITES_2];
1503   m_layer_data[MIXER_LAYER_SPRITES_2] = temp;
15441504
15451505   /* for multi32, swap the other buffer as well */
1546   if (state->m_is_multi32)
1506   if (m_is_multi32)
15471507   {
1548      temp = state->m_layer_data[MIXER_LAYER_MULTISPR];
1549      state->m_layer_data[MIXER_LAYER_MULTISPR] = state->m_layer_data[MIXER_LAYER_MULTISPR_2];
1550      state->m_layer_data[MIXER_LAYER_MULTISPR_2] = temp;
1508      temp = m_layer_data[MIXER_LAYER_MULTISPR];
1509      m_layer_data[MIXER_LAYER_MULTISPR] = m_layer_data[MIXER_LAYER_MULTISPR_2];
1510      m_layer_data[MIXER_LAYER_MULTISPR_2] = temp;
15511511   }
15521512
15531513   /* latch any pending info */
1554   memcpy(state->m_sprite_control_latched, state->m_sprite_control, sizeof(state->m_sprite_control_latched));
1514   memcpy(m_sprite_control_latched, m_sprite_control, sizeof(m_sprite_control_latched));
15551515}
15561516
15571517
r20977r20978
16521612      }                                                                   \
16531613   }
16541614
1655static int draw_one_sprite(running_machine &machine, UINT16 *data, int xoffs, int yoffs, const rectangle &clipin, const rectangle &clipout)
1615int segas32_state::draw_one_sprite(UINT16 *data, int xoffs, int yoffs, const rectangle &clipin, const rectangle &clipout)
16561616{
1657   segas32_state *state = machine.driver_data<segas32_state>();
16581617   static const int transparency_masks[4][4] =
16591618   {
16601619      { 0x7fff, 0x3fff, 0x1fff, 0x0fff },
r20977r20978
16631622      { 0x1fff, 0x0fff, 0x07ff, 0x03ff }
16641623   };
16651624
1666   bitmap_ind16 &bitmap = *state->m_layer_data[(!state->m_is_multi32 || !(data[3] & 0x0800)) ? MIXER_LAYER_SPRITES_2 : MIXER_LAYER_MULTISPR_2].bitmap;
1667   UINT8 numbanks = machine.root_device().memregion("gfx2")->bytes() / 0x400000;
1668   const UINT32 *spritebase = (const UINT32 *)machine.root_device().memregion("gfx2")->base();
1625   bitmap_ind16 &bitmap = *m_layer_data[(!m_is_multi32 || !(data[3] & 0x0800)) ? MIXER_LAYER_SPRITES_2 : MIXER_LAYER_MULTISPR_2].bitmap;
1626   UINT8 numbanks = machine().root_device().memregion("gfx2")->bytes() / 0x400000;
1627   const UINT32 *spritebase = (const UINT32 *)machine().root_device().memregion("gfx2")->base();
16691628
16701629   int indirect = data[0] & 0x2000;
16711630   int indlocal = data[0] & 0x1000;
1672   int shadow   = (data[0] & 0x0800) && (state->m_sprite_control_latched[0x0a/2] & 1);
1631   int shadow   = (data[0] & 0x0800) && (m_sprite_control_latched[0x0a/2] & 1);
16731632   int fromram  = data[0] & 0x0400;
16741633   int bpp8     = data[0] & 0x0200;
16751634   int transp   = (data[0] & 0x0100) ? 0 : (bpp8 ? 0xff : 0x0f);
r20977r20978
16811640   int adjustx  = (data[0] >> 0) & 3;
16821641   int srch     = (data[1] >> 8);
16831642   int srcw     = bpp8 ? (data[1] & 0x3f) : ((data[1] >> 1) & 0x3f);
1684   int bank     = state->m_is_multi32 ?
1643   int bank     = m_is_multi32 ?
16851644               ((data[3] & 0x2000) >> 13) | ((data[3] & 0x8000) >> 14) :
16861645               ((data[3] & 0x0800) >> 11) | ((data[3] & 0x4000) >> 13);
16871646   int dsth     = data[2] & 0x3ff;
r20977r20978
17021661      goto bail;
17031662
17041663   /* determine the transparency mask for pixels */
1705   transmask = transparency_masks[state->m_sprite_control_latched[0x08/2] & 3][state->m_sprite_control_latched[0x0a/2] & 3];
1664   transmask = transparency_masks[m_sprite_control_latched[0x08/2] & 3][m_sprite_control_latched[0x0a/2] & 3];
17061665   if (bpp8)
17071666      transmask &= 0xfff0;
17081667
17091668   /* create the local palette for the indirect case */
17101669   if (indirect)
17111670   {
1712      UINT16 *src = indlocal ? &data[8] : &state->m_system32_spriteram[8 * (data[7] & 0x1fff)];
1671      UINT16 *src = indlocal ? &data[8] : &m_system32_spriteram[8 * (data[7] & 0x1fff)];
17131672      for (x = 0; x < 16; x++)
1714         indtable[x] = (src[x] & (bpp8 ? 0xfff0 : 0xffff)) | ((state->m_sprite_control_latched[0x0a/2] & 1) ? 0x8000 : 0x0000);
1673         indtable[x] = (src[x] & (bpp8 ? 0xfff0 : 0xffff)) | ((m_sprite_control_latched[0x0a/2] & 1) ? 0x8000 : 0x0000);
17151674   }
17161675
17171676   /* clamp to within the memory region size */
17181677   if (fromram)
17191678   {
1720      spritedata = state->m_spriteram_32bit;
1679      spritedata = m_spriteram_32bit;
17211680      addrmask = (0x20000 / 4) - 1;
17221681   }
17231682   else
r20977r20978
18541813
18551814
18561815
1857static void sprite_render_list(running_machine &machine)
1816void segas32_state::sprite_render_list()
18581817{
1859   segas32_state *state = machine.driver_data<segas32_state>();
18601818   rectangle outerclip, clipin, clipout;
18611819   int xoffs = 0, yoffs = 0;
18621820   int numentries = 0;
r20977r20978
18691827
18701828   /* compute the outer clip */
18711829   outerclip.min_x = outerclip.min_y = 0;
1872   outerclip.max_x = (state->m_sprite_control_latched[0x0c/2] & 1) ? 415 : 319;
1830   outerclip.max_x = (m_sprite_control_latched[0x0c/2] & 1) ? 415 : 319;
18731831   outerclip.max_y = 223;
18741832
18751833   /* initialize the cliprects */
r20977r20978
18811839   while (numentries++ < 0x20000/16)
18821840   {
18831841      /* top two bits are a command */
1884      sprite = &state->m_system32_spriteram[8 * (spritenum & 0x1fff)];
1842      sprite = &m_system32_spriteram[8 * (spritenum & 0x1fff)];
18851843      switch (sprite[0] >> 14)
18861844      {
18871845         /* command 0 = draw sprite */
18881846         case 0:
1889            spritenum += 1 + draw_one_sprite(machine, sprite, xoffs, yoffs, clipin, clipout);
1847            spritenum += 1 + draw_one_sprite(sprite, xoffs, yoffs, clipin, clipout);
18901848            break;
18911849
18921850         /* command 1 = set clipping */
r20977r20978
19451903 *
19461904 *************************************/
19471905
1948INLINE UINT8 compute_color_offsets(segas32_state *state,int which, int layerbit, int layerflag)
1906inline UINT8 segas32_state::compute_color_offsets(int which, int layerbit, int layerflag)
19491907{
1950   int mode = ((state->m_mixer_control[which][0x3e/2] & 0x8000) >> 14) | (layerbit & 1);
1908   int mode = ((m_mixer_control[which][0x3e/2] & 0x8000) >> 14) | (layerbit & 1);
19511909
19521910   switch (mode)
19531911   {
r20977r20978
19651923   }
19661924}
19671925
1968INLINE UINT16 compute_sprite_blend(UINT8 encoding)
1926inline UINT16 segas32_state::compute_sprite_blend(UINT8 encoding)
19691927{
19701928   int value = encoding & 0xf;
19711929
r20977r20978
19861944   }
19871945}
19881946
1989INLINE UINT16 *get_layer_scanline(segas32_state *state, int layer, int scanline)
1947inline UINT16 *segas32_state::get_layer_scanline(int layer, int scanline)
19901948{
1991   if (state->m_layer_data[layer].transparent[scanline])
1992      return (layer == MIXER_LAYER_SPRITES) ? state->m_solid_ffff : state->m_solid_0000;
1993   return &state->m_layer_data[layer].bitmap->pix16(scanline);
1949   if (m_layer_data[layer].transparent[scanline])
1950      return (layer == MIXER_LAYER_SPRITES) ? m_solid_ffff : m_solid_0000;
1951   return &m_layer_data[layer].bitmap->pix16(scanline);
19941952}
19951953
1996static void mix_all_layers(segas32_state *state, int which, int xoffs, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 enablemask)
1954void segas32_state::mix_all_layers(int which, int xoffs, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 enablemask)
19971955{
1998   int blendenable = state->m_mixer_control[which][0x4e/2] & 0x0800;
1999   int blendfactor = (state->m_mixer_control[which][0x4e/2] >> 8) & 7;
1956   int blendenable = m_mixer_control[which][0x4e/2] & 0x0800;
1957   int blendfactor = (m_mixer_control[which][0x4e/2] >> 8) & 7;
20001958   struct mixer_layer_info
20011959   {
20021960      UINT16      palbase;            /* palette base from control reg */
r20977r20978
20201978   /* if we are the second monitor on multi32, swap in the proper sprite bank */
20211979   if (which == 1)
20221980   {
2023      temp_sprite_save = state->m_layer_data[MIXER_LAYER_SPRITES];
2024      state->m_layer_data[MIXER_LAYER_SPRITES] = state->m_layer_data[MIXER_LAYER_MULTISPR];
1981      temp_sprite_save = m_layer_data[MIXER_LAYER_SPRITES];
1982      m_layer_data[MIXER_LAYER_SPRITES] = m_layer_data[MIXER_LAYER_MULTISPR];
20251983   }
20261984
20271985   /* extract the RGB offsets */
2028   rgboffs[0][0] = (INT8)(state->m_mixer_control[which][0x40/2] << 2) >> 2;
2029   rgboffs[0][1] = (INT8)(state->m_mixer_control[which][0x42/2] << 2) >> 2;
2030   rgboffs[0][2] = (INT8)(state->m_mixer_control[which][0x44/2] << 2) >> 2;
2031   rgboffs[1][0] = (INT8)(state->m_mixer_control[which][0x46/2] << 2) >> 2;
2032   rgboffs[1][1] = (INT8)(state->m_mixer_control[which][0x48/2] << 2) >> 2;
2033   rgboffs[1][2] = (INT8)(state->m_mixer_control[which][0x4a/2] << 2) >> 2;
1986   rgboffs[0][0] = (INT8)(m_mixer_control[which][0x40/2] << 2) >> 2;
1987   rgboffs[0][1] = (INT8)(m_mixer_control[which][0x42/2] << 2) >> 2;
1988   rgboffs[0][2] = (INT8)(m_mixer_control[which][0x44/2] << 2) >> 2;
1989   rgboffs[1][0] = (INT8)(m_mixer_control[which][0x46/2] << 2) >> 2;
1990   rgboffs[1][1] = (INT8)(m_mixer_control[which][0x48/2] << 2) >> 2;
1991   rgboffs[1][2] = (INT8)(m_mixer_control[which][0x4a/2] << 2) >> 2;
20341992   rgboffs[2][0] = 0;
20351993   rgboffs[2][1] = 0;
20361994   rgboffs[2][2] = 0;
20371995
20381996   /* determine the sprite grouping parameters first */
2039   switch (state->m_mixer_control[which][0x4c/2] & 0x0f)
1997   switch (m_mixer_control[which][0x4c/2] & 0x0f)
20401998   {
20411999      default:
20422000      case 0x0:   sprgroup_shift = 14;    sprgroup_mask = 0x00;   sprgroup_or = 0x01; break;
r20977r20978
20592017      case 0xe:   sprgroup_shift = 11;    sprgroup_mask = 0x07;   sprgroup_or = 0x00; break;
20602018      case 0xf:   sprgroup_shift = 10;    sprgroup_mask = 0x0f;   sprgroup_or = 0x00; break;
20612019   }
2062   sprshadowmask = (state->m_mixer_control[which][0x4c/2] & 0x04) ? 0x8000 : 0x0000;
2020   sprshadowmask = (m_mixer_control[which][0x4c/2] & 0x04) ? 0x8000 : 0x0000;
20632021   sprpixmask = ((1 << sprgroup_shift) - 1) & 0x3fff;
20642022   sprshadow = 0x7ffe & sprpixmask;
20652023
r20977r20978
20672025   numlayers = 0;
20682026   for (laynum = MIXER_LAYER_TEXT; laynum <= MIXER_LAYER_BITMAP; laynum++)
20692027   {
2070      int priority = state->m_mixer_control[which][0x20/2 + laynum] & 0x0f;
2028      int priority = m_mixer_control[which][0x20/2 + laynum] & 0x0f;
20712029      if ((enablemask & (1 << laynum)) && priority != 0)
20722030      {
20732031         layersort[numlayers].index = laynum;
20742032         layersort[numlayers].effpri = (priority << 3) | (6 - laynum);
2075         layersort[numlayers].palbase = (state->m_mixer_control[which][0x20/2 + laynum] & 0x00f0) << 6;
2076         layersort[numlayers].mixshift = (state->m_mixer_control[which][0x20/2 + laynum] >> 8) & 3;
2077         layersort[numlayers].blendmask = blendenable ? ((state->m_mixer_control[which][0x30/2 + laynum] >> 6) & 0xff) : 0;
2078         layersort[numlayers].sprblendmask = compute_sprite_blend(state->m_mixer_control[which][0x30/2 + laynum] & 0x3f);
2079         layersort[numlayers].coloroffs = compute_color_offsets(state, which, (state->m_mixer_control[which][0x3e/2] >> laynum) & 1, (state->m_mixer_control[which][0x30/2 + laynum] >> 14) & 1);
2033         layersort[numlayers].palbase = (m_mixer_control[which][0x20/2 + laynum] & 0x00f0) << 6;
2034         layersort[numlayers].mixshift = (m_mixer_control[which][0x20/2 + laynum] >> 8) & 3;
2035         layersort[numlayers].blendmask = blendenable ? ((m_mixer_control[which][0x30/2 + laynum] >> 6) & 0xff) : 0;
2036         layersort[numlayers].sprblendmask = compute_sprite_blend(m_mixer_control[which][0x30/2 + laynum] & 0x3f);
2037         layersort[numlayers].coloroffs = compute_color_offsets(which, (m_mixer_control[which][0x3e/2] >> laynum) & 1, (m_mixer_control[which][0x30/2 + laynum] >> 14) & 1);
20802038         numlayers++;
20812039      }
20822040   }
r20977r20978
20842042   /* extract info about the BACKGROUND layer */
20852043   layersort[numlayers].index = MIXER_LAYER_BACKGROUND;
20862044   layersort[numlayers].effpri = (1 << 3) | 0;
2087   layersort[numlayers].palbase = (state->m_mixer_control[which][0x2c/2] & 0x00f0) << 6;
2088   layersort[numlayers].mixshift = (state->m_mixer_control[which][0x2c/2] >> 8) & 3;
2045   layersort[numlayers].palbase = (m_mixer_control[which][0x2c/2] & 0x00f0) << 6;
2046   layersort[numlayers].mixshift = (m_mixer_control[which][0x2c/2] >> 8) & 3;
20892047   layersort[numlayers].blendmask = 0;
20902048   layersort[numlayers].sprblendmask = 0;
2091   layersort[numlayers].coloroffs = compute_color_offsets(state, which, (state->m_mixer_control[which][0x3e/2] >> 8) & 1, (state->m_mixer_control[which][0x3e/2] >> 14) & 1);
2049   layersort[numlayers].coloroffs = compute_color_offsets(which, (m_mixer_control[which][0x3e/2] >> 8) & 1, (m_mixer_control[which][0x3e/2] >> 14) & 1);
20922050   numlayers++;
20932051
20942052   /* now bubble sort the list by effective priority */
r20977r20978
21052063   for (groupnum = 0; groupnum <= sprgroup_mask; groupnum++)
21062064   {
21072065      int effgroup = sprgroup_or | groupnum;
2108      int priority = state->m_mixer_control[which][0x00/2 + effgroup] & 0x0f;
2066      int priority = m_mixer_control[which][0x00/2 + effgroup] & 0x0f;
21092067      int effpri = (priority << 3) | 7;
21102068      int sprindex = numlayers;
21112069      int dstnum = 0;
r20977r20978
21212079      /* build the sprite entry */
21222080      layerorder[groupnum][sprindex].index = MIXER_LAYER_SPRITES;
21232081      layerorder[groupnum][sprindex].effpri = effpri;
2124      if ((state->m_mixer_control[which][0x4c/2] & 3) != 3)
2125         layerorder[groupnum][sprindex].palbase = (state->m_mixer_control[which][0x00/2 + effgroup] & 0x00f0) << 6;
2082      if ((m_mixer_control[which][0x4c/2] & 3) != 3)
2083         layerorder[groupnum][sprindex].palbase = (m_mixer_control[which][0x00/2 + effgroup] & 0x00f0) << 6;
21262084      else
2127         layerorder[groupnum][sprindex].palbase = (state->m_mixer_control[which][0x4c/2] & 0x00f0) << 6;
2128      layerorder[groupnum][sprindex].mixshift = (state->m_mixer_control[which][0x00/2 + effgroup] >> 8) & 3;
2085         layerorder[groupnum][sprindex].palbase = (m_mixer_control[which][0x4c/2] & 0x00f0) << 6;
2086      layerorder[groupnum][sprindex].mixshift = (m_mixer_control[which][0x00/2 + effgroup] >> 8) & 3;
21292087      layerorder[groupnum][sprindex].blendmask = 0;
21302088      layerorder[groupnum][sprindex].sprblendmask = 0;
2131      layerorder[groupnum][sprindex].coloroffs = compute_color_offsets(state, which, (state->m_mixer_control[which][0x3e/2] >> 6) & 1, (state->m_mixer_control[which][0x4c/2] >> 15) & 1);
2089      layerorder[groupnum][sprindex].coloroffs = compute_color_offsets(which, (m_mixer_control[which][0x3e/2] >> 6) & 1, (m_mixer_control[which][0x4c/2] >> 15) & 1);
21322090   }
21332091/*
21342092{
r20977r20978
21442102
21452103   /* based on the sprite controller flip bits, the data is scanned to us in different */
21462104   /* directions; account for this */
2147   if (state->m_sprite_control_latched[0x04/2] & 1)
2105   if (m_sprite_control_latched[0x04/2] & 1)
21482106   {
21492107      sprx_start = cliprect.max_x;
21502108      sprdx = -1;
r20977r20978
21552113      sprdx = 1;
21562114   }
21572115
2158   if (state->m_sprite_control_latched[0x04/2] & 2)
2116   if (m_sprite_control_latched[0x04/2] & 2)
21592117   {
21602118      spry = cliprect.max_y;
21612119      sprdy = -1;
r20977r20978
21732131      UINT16 *layerbase[8];
21742132
21752133      /* get the starting address for each layer */
2176      layerbase[MIXER_LAYER_TEXT] = get_layer_scanline(state, MIXER_LAYER_TEXT, y);
2177      layerbase[MIXER_LAYER_NBG0] = get_layer_scanline(state, MIXER_LAYER_NBG0, y);
2178      layerbase[MIXER_LAYER_NBG1] = get_layer_scanline(state, MIXER_LAYER_NBG1, y);
2179      layerbase[MIXER_LAYER_NBG2] = get_layer_scanline(state, MIXER_LAYER_NBG2, y);
2180      layerbase[MIXER_LAYER_NBG3] = get_layer_scanline(state, MIXER_LAYER_NBG3, y);
2181      layerbase[MIXER_LAYER_BITMAP] = get_layer_scanline(state, MIXER_LAYER_BITMAP, y);
2182      layerbase[MIXER_LAYER_SPRITES] = get_layer_scanline(state, MIXER_LAYER_SPRITES, spry);
2183      layerbase[MIXER_LAYER_BACKGROUND] = get_layer_scanline(state, MIXER_LAYER_BACKGROUND, y);
2134      layerbase[MIXER_LAYER_TEXT] = get_layer_scanline(MIXER_LAYER_TEXT, y);
2135      layerbase[MIXER_LAYER_NBG0] = get_layer_scanline(MIXER_LAYER_NBG0, y);
2136      layerbase[MIXER_LAYER_NBG1] = get_layer_scanline(MIXER_LAYER_NBG1, y);
2137      layerbase[MIXER_LAYER_NBG2] = get_layer_scanline(MIXER_LAYER_NBG2, y);
2138      layerbase[MIXER_LAYER_NBG3] = get_layer_scanline(MIXER_LAYER_NBG3, y);
2139      layerbase[MIXER_LAYER_BITMAP] = get_layer_scanline(MIXER_LAYER_BITMAP, y);
2140      layerbase[MIXER_LAYER_SPRITES] = get_layer_scanline(MIXER_LAYER_SPRITES, spry);
2141      layerbase[MIXER_LAYER_BACKGROUND] = get_layer_scanline(MIXER_LAYER_BACKGROUND, y);
21842142
21852143      /* loop over columns */
21862144      for (x = cliprect.min_x, sprx = sprx_start; x <= cliprect.max_x; x++, sprx += sprdx)
r20977r20978
22252183         }
22262184
22272185         /* adjust the first pixel */
2228         firstpix = state->m_system32_paletteram[which][(first->palbase + ((firstpix >> first->mixshift) & 0xfff0) + (firstpix & 0x0f)) & 0x3fff];
2186         firstpix = m_system32_paletteram[which][(first->palbase + ((firstpix >> first->mixshift) & 0xfff0) + (firstpix & 0x0f)) & 0x3fff];
22292187
22302188         /* compute R, G, B */
22312189         rgbdelta = &rgboffs[first->coloroffs][0];
r20977r20978
22722230               (laynum != MIXER_LAYER_SPRITES || (first->sprblendmask & (1 << sprgroup))))
22732231            {
22742232               /* adjust the second pixel */
2275               secondpix = state->m_system32_paletteram[which][(second->palbase + ((secondpix >> second->mixshift) & 0xfff0) + (secondpix & 0x0f)) & 0x3fff];
2233               secondpix = m_system32_paletteram[which][(second->palbase + ((secondpix >> second->mixshift) & 0xfff0) + (secondpix & 0x0f)) & 0x3fff];
22762234
22772235               /* compute first RGB */
22782236               r *= 7 - blendfactor;
r20977r20978
23232281
23242282   /* if we are the second monitor on multi32, swap back the sprite layer */
23252283   if (which == 1)
2326      state->m_layer_data[MIXER_LAYER_SPRITES] = temp_sprite_save;
2284      m_layer_data[MIXER_LAYER_SPRITES] = temp_sprite_save;
23272285}
23282286
23292287
r20977r20978
23342292 *
23352293 *************************************/
23362294
2337static void print_mixer_data(segas32_state *state, int which)
2295void segas32_state::print_mixer_data(int which)
23382296{
2339   if (++state->m_print_count > 60 * 5)
2297   if (++m_print_count > 60 * 5)
23402298   {
23412299      mame_printf_debug("\n");
2342      mame_printf_debug("OP: %04X\n", state->m_system32_videoram[0x1ff8e/2]);
2300      mame_printf_debug("OP: %04X\n", m_system32_videoram[0x1ff8e/2]);
23432301      mame_printf_debug("SC: %04X %04X %04X %04X - %04X %04X %04X %04X\n",
2344         state->m_sprite_control_latched[0x00],
2345         state->m_sprite_control_latched[0x01],
2346         state->m_sprite_control_latched[0x02],
2347         state->m_sprite_control_latched[0x03],
2348         state->m_sprite_control_latched[0x04],
2349         state->m_sprite_control_latched[0x05],
2350         state->m_sprite_control_latched[0x06],
2351         state->m_sprite_control_latched[0x07]);
2302         m_sprite_control_latched[0x00],
2303         m_sprite_control_latched[0x01],
2304         m_sprite_control_latched[0x02],
2305         m_sprite_control_latched[0x03],
2306         m_sprite_control_latched[0x04],
2307         m_sprite_control_latched[0x05],
2308         m_sprite_control_latched[0x06],
2309         m_sprite_control_latched[0x07]);
23522310      mame_printf_debug("00: %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X\n",
2353         state->m_mixer_control[which][0x00],
2354         state->m_mixer_control[which][0x01],
2355         state->m_mixer_control[which][0x02],
2356         state->m_mixer_control[which][0x03],
2357         state->m_mixer_control[which][0x04],
2358         state->m_mixer_control[which][0x05],
2359         state->m_mixer_control[which][0x06],
2360         state->m_mixer_control[which][0x07],
2361         state->m_mixer_control[which][0x08],
2362         state->m_mixer_control[which][0x09],
2363         state->m_mixer_control[which][0x0a],
2364         state->m_mixer_control[which][0x0b],
2365         state->m_mixer_control[which][0x0c],
2366         state->m_mixer_control[which][0x0d],
2367         state->m_mixer_control[which][0x0e],
2368         state->m_mixer_control[which][0x0f]);
2311         m_mixer_control[which][0x00],
2312         m_mixer_control[which][0x01],
2313         m_mixer_control[which][0x02],
2314         m_mixer_control[which][0x03],
2315         m_mixer_control[which][0x04],
2316         m_mixer_control[which][0x05],
2317         m_mixer_control[which][0x06],
2318         m_mixer_control[which][0x07],
2319         m_mixer_control[which][0x08],
2320         m_mixer_control[which][0x09],
2321         m_mixer_control[which][0x0a],
2322         m_mixer_control[which][0x0b],
2323         m_mixer_control[which][0x0c],
2324         m_mixer_control[which][0x0d],
2325         m_mixer_control[which][0x0e],
2326         m_mixer_control[which][0x0f]);
23692327      mame_printf_debug("20: %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X\n",
2370         state->m_mixer_control[which][0x10],
2371         state->m_mixer_control[which][0x11],
2372         state->m_mixer_control[which][0x12],
2373         state->m_mixer_control[which][0x13],
2374         state->m_mixer_control[which][0x14],
2375         state->m_mixer_control[which][0x15],
2376         state->m_mixer_control[which][0x16],
2377         state->m_mixer_control[which][0x17],
2378         state->m_mixer_control[which][0x18],
2379         state->m_mixer_control[which][0x19],
2380         state->m_mixer_control[which][0x1a],
2381         state->m_mixer_control[which][0x1b],
2382         state->m_mixer_control[which][0x1c],
2383         state->m_mixer_control[which][0x1d],
2384         state->m_mixer_control[which][0x1e],
2385         state->m_mixer_control[which][0x1f]);
2328         m_mixer_control[which][0x10],
2329         m_mixer_control[which][0x11],
2330         m_mixer_control[which][0x12],
2331         m_mixer_control[which][0x13],
2332         m_mixer_control[which][0x14],
2333         m_mixer_control[which][0x15],
2334         m_mixer_control[which][0x16],
2335         m_mixer_control[which][0x17],
2336         m_mixer_control[which][0x18],
2337         m_mixer_control[which][0x19],
2338         m_mixer_control[which][0x1a],
2339         m_mixer_control[which][0x1b],
2340         m_mixer_control[which][0x1c],
2341         m_mixer_control[which][0x1d],
2342         m_mixer_control[which][0x1e],
2343         m_mixer_control[which][0x1f]);
23862344      mame_printf_debug("40: %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X\n",
2387         state->m_mixer_control[which][0x20],
2388         state->m_mixer_control[which][0x21],
2389         state->m_mixer_control[which][0x22],
2390         state->m_mixer_control[which][0x23],
2391         state->m_mixer_control[which][0x24],
2392         state->m_mixer_control[which][0x25],
2393         state->m_mixer_control[which][0x26],
2394         state->m_mixer_control[which][0x27],
2395         state->m_mixer_control[which][0x28],
2396         state->m_mixer_control[which][0x29],
2397         state->m_mixer_control[which][0x2a],
2398         state->m_mixer_control[which][0x2b],
2399         state->m_mixer_control[which][0x2c],
2400         state->m_mixer_control[which][0x2d],
2401         state->m_mixer_control[which][0x2e],
2402         state->m_mixer_control[which][0x2f]);
2403      state->m_print_count = 0;
2345         m_mixer_control[which][0x20],
2346         m_mixer_control[which][0x21],
2347         m_mixer_control[which][0x22],
2348         m_mixer_control[which][0x23],
2349         m_mixer_control[which][0x24],
2350         m_mixer_control[which][0x25],
2351         m_mixer_control[which][0x26],
2352         m_mixer_control[which][0x27],
2353         m_mixer_control[which][0x28],
2354         m_mixer_control[which][0x29],
2355         m_mixer_control[which][0x2a],
2356         m_mixer_control[which][0x2b],
2357         m_mixer_control[which][0x2c],
2358         m_mixer_control[which][0x2d],
2359         m_mixer_control[which][0x2e],
2360         m_mixer_control[which][0x2f]);
2361      m_print_count = 0;
24042362   }
24052363}
24062364
r20977r20978
24382396
24392397   /* do the mixing */
24402398   g_profiler.start(PROFILER_USER3);
2441   mix_all_layers(this, 0, 0, bitmap, cliprect, enablemask);
2399   mix_all_layers(0, 0, bitmap, cliprect, enablemask);
24422400   g_profiler.stop();
24432401
24442402   if (LOG_SPRITES && machine().input().code_pressed(KEYCODE_L))
r20977r20978
24492407
24502408      for (y = visarea.min_y; y <= visarea.max_y; y++)
24512409      {
2452         UINT16 *src = get_layer_scanline(this, MIXER_LAYER_SPRITES, y);
2410         UINT16 *src = get_layer_scanline(MIXER_LAYER_SPRITES, y);
24532411         for (x = visarea.min_x; x <= visarea.max_x; x++)
24542412            fprintf(f, "%04X ", *src++);
24552413         fprintf(f, "\n");
r20977r20978
24592417      f = fopen("nbg0.txt", "w");
24602418      for (y = visarea.min_y; y <= visarea.max_y; y++)
24612419      {
2462         UINT16 *src = get_layer_scanline(this, MIXER_LAYER_NBG0, y);
2420         UINT16 *src = get_layer_scanline(MIXER_LAYER_NBG0, y);
24632421         for (x = visarea.min_x; x <= visarea.max_x; x++)
24642422            fprintf(f, "%04X ", *src++);
24652423         fprintf(f, "\n");
r20977r20978
24692427      f = fopen("nbg1.txt", "w");
24702428      for (y = visarea.min_y; y <= visarea.max_y; y++)
24712429      {
2472         UINT16 *src = get_layer_scanline(this, MIXER_LAYER_NBG1, y);
2430         UINT16 *src = get_layer_scanline(MIXER_LAYER_NBG1, y);
24732431         for (x = visarea.min_x; x <= visarea.max_x; x++)
24742432            fprintf(f, "%04X ", *src++);
24752433         fprintf(f, "\n");
r20977r20978
24792437      f = fopen("nbg2.txt", "w");
24802438      for (y = visarea.min_y; y <= visarea.max_y; y++)
24812439      {
2482         UINT16 *src = get_layer_scanline(this, MIXER_LAYER_NBG2, y);
2440         UINT16 *src = get_layer_scanline(MIXER_LAYER_NBG2, y);
24832441         for (x = visarea.min_x; x <= visarea.max_x; x++)
24842442            fprintf(f, "%04X ", *src++);
24852443         fprintf(f, "\n");
r20977r20978
24892447      f = fopen("nbg3.txt", "w");
24902448      for (y = visarea.min_y; y <= visarea.max_y; y++)
24912449      {
2492         UINT16 *src = get_layer_scanline(this, MIXER_LAYER_NBG3, y);
2450         UINT16 *src = get_layer_scanline(MIXER_LAYER_NBG3, y);
24932451         for (x = visarea.min_x; x <= visarea.max_x; x++)
24942452            fprintf(f, "%04X ", *src++);
24952453         fprintf(f, "\n");
r20977r20978
25302488//  if (showclip != -1)
25312489for (showclip = 0; showclip < 4; showclip++)
25322490   {
2533      int flip = (state->m_system32_videoram[0x1ff00/2] >> 9) & 1;
2534      int clips = (state->m_system32_videoram[0x1ff06/2] >> (4 * showclip)) & 0x0f;
2535      if (((state->m_system32_videoram[0x1ff02/2] >> (11 + showclip)) & 1) && clips)
2491      int flip = (m_system32_videoram[0x1ff00/2] >> 9) & 1;
2492      int clips = (m_system32_videoram[0x1ff06/2] >> (4 * showclip)) & 0x0f;
2493      if (((m_system32_videoram[0x1ff02/2] >> (11 + showclip)) & 1) && clips)
25362494      {
25372495         int i, x, y;
25382496         for (i = 0; i < 4; i++)
r20977r20978
25442502               pen_t white = get_white_pen(screen.machine());
25452503               if (!flip)
25462504               {
2547                  rect.min_x = state->m_system32_videoram[0x1ff60/2 + i * 4] & 0x1ff;
2548                  rect.min_y = state->m_system32_videoram[0x1ff62/2 + i * 4] & 0x0ff;
2549                  rect.max_x = (state->m_system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1;
2550                  rect.max_y = (state->m_system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1;
2505                  rect.min_x = m_system32_videoram[0x1ff60/2 + i * 4] & 0x1ff;
2506                  rect.min_y = m_system32_videoram[0x1ff62/2 + i * 4] & 0x0ff;
2507                  rect.max_x = (m_system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1;
2508                  rect.max_y = (m_system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1;
25512509               }
25522510               else
25532511               {
2554                  rect.max_x = (visarea.max_x + 1) - (state->m_system32_videoram[0x1ff60/2 + i * 4] & 0x1ff);
2555                  rect.max_y = (visarea.max_y + 1) - (state->m_system32_videoram[0x1ff62/2 + i * 4] & 0x0ff);
2556                  rect.min_x = (visarea.max_x + 1) - ((state->m_system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1);
2557                  rect.min_y = (visarea.max_y + 1) - ((state->m_system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1);
2512                  rect.max_x = (visarea.max_x + 1) - (m_system32_videoram[0x1ff60/2 + i * 4] & 0x1ff);
2513                  rect.max_y = (visarea.max_y + 1) - (m_system32_videoram[0x1ff62/2 + i * 4] & 0x0ff);
2514                  rect.min_x = (visarea.max_x + 1) - ((m_system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1);
2515                  rect.min_y = (visarea.max_y + 1) - ((m_system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1);
25582516               }
25592517               sect_rect(&rect, &screen.visible_area());
25602518
r20977r20978
25772535}
25782536#endif
25792537
2580   if (PRINTF_MIXER_DATA) print_mixer_data(this, 0);
2538   if (PRINTF_MIXER_DATA) print_mixer_data(0);
25812539   return 0;
25822540}
25832541
25842542
2585static UINT32 multi32_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int index)
2543UINT32 segas32_state::multi32_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int index)
25862544{
2587   segas32_state *state = screen.machine().driver_data<segas32_state>();
25882545   UINT8 enablemask;
25892546
25902547   /* update the visible area */
2591   if (state->m_system32_videoram[0x1ff00/2] & 0x8000)
2548   if (m_system32_videoram[0x1ff00/2] & 0x8000)
25922549      screen.set_visible_area(0, 52*8-1, 0, 28*8-1);
25932550   else
25942551      screen.set_visible_area(0, 40*8-1, 0, 28*8-1);
25952552
25962553   /* if the display is off, punt */
2597   if (!state->m_system32_displayenable[index])
2554   if (!m_system32_displayenable[index])
25982555   {
25992556      bitmap.fill(get_black_pen(screen.machine()), cliprect);
26002557      return 0;
r20977r20978
26172574
26182575   /* do the mixing */
26192576   g_profiler.start(PROFILER_USER3);
2620   mix_all_layers(state, index, 0, bitmap, cliprect, enablemask);
2577   mix_all_layers(index, 0, bitmap, cliprect, enablemask);
26212578   g_profiler.stop();
26222579
26232580if (PRINTF_MIXER_DATA)
26242581{
2625   if (!screen.machine().input().code_pressed(KEYCODE_M)) print_mixer_data(state, 0);
2626   else print_mixer_data(state, 1);
2582   if (!screen.machine().input().code_pressed(KEYCODE_M)) print_mixer_data(0);
2583   else print_mixer_data(1);
26272584}
26282585   if (LOG_SPRITES && screen.machine().input().code_pressed(KEYCODE_L))
26292586   {
r20977r20978
26332590
26342591      for (y = visarea.min_y; y <= visarea.max_y; y++)
26352592      {
2636         UINT16 *src = get_layer_scanline(state, MIXER_LAYER_SPRITES, y);
2593         UINT16 *src = get_layer_scanline(MIXER_LAYER_SPRITES, y);
26372594         for (x = visarea.min_x; x <= visarea.max_x; x++)
26382595            fprintf(f, "%04X ", *src++);
26392596         fprintf(f, "\n");
trunk/src/mame/video/starfire.c
r20977r20978
213213 *
214214 *************************************/
215215
216static void get_pens(running_machine &machine, pen_t *pens)
216void starfire_state::get_pens(pen_t *pens)
217217{
218218   offs_t offs;
219   starfire_state *state = machine.driver_data<starfire_state>();
220219
221220   for (offs = 0; offs < STARFIRE_NUM_PENS; offs++)
222221   {
223      UINT16 color = state->m_starfire_colors[offs];
222      UINT16 color = m_starfire_colors[offs];
224223
225224      pens[offs] = MAKE_RGB(pal3bit(color >> 6), pal3bit(color >> 3), pal3bit(color >> 0));
226225   }
r20977r20978
231230   pen_t pens[STARFIRE_NUM_PENS];
232231   int y = param;
233232
234   get_pens(machine(), pens);
233   get_pens(pens);
235234
236235   UINT8 *pix = &m_starfire_videoram[y];
237236   UINT8 *col = &m_starfire_colorram[y];
trunk/src/mame/video/stfight.c
r20977r20978
6868}
6969
7070
71static void set_pens(running_machine &machine)
71void stfight_state::set_pens()
7272{
73   stfight_state *state = machine.driver_data<stfight_state>();
7473   int i;
7574
7675   for (i = 0; i < 0x100; i++)
7776   {
78      UINT16 data = state->m_generic_paletteram_8[i] | (state->m_generic_paletteram2_8[i] << 8);
77      UINT16 data = m_generic_paletteram_8[i] | (m_generic_paletteram2_8[i] << 8);
7978      rgb_t color = MAKE_RGB(pal4bit(data >> 4), pal4bit(data >> 0), pal4bit(data >> 8));
8079
81      colortable_palette_set_color(machine.colortable, i, color);
80      colortable_palette_set_color(machine().colortable, i, color);
8281   }
8382}
8483
r20977r20978
240239
241240***************************************************************************/
242241
243static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
242void stfight_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
244243{
245   stfight_state *state = machine.driver_data<stfight_state>();
246244   int offs,sx,sy;
247245
248246   for (offs = 0;offs < 4096;offs += 32)
249247   {
250248      int code;
251      int attr = state->m_sprite_ram[offs+1];
249      int attr = m_sprite_ram[offs+1];
252250      int flipx = attr & 0x10;
253251      int color = attr & 0x0f;
254252      int pri = (attr & 0x20) >> 5;
255253
256      sy = state->m_sprite_ram[offs+2];
257      sx = state->m_sprite_ram[offs+3];
254      sy = m_sprite_ram[offs+2];
255      sx = m_sprite_ram[offs+3];
258256
259257      // non-active sprites have zero y coordinate value
260258      if( sy > 0 )
r20977r20978
267265               sx -= 0x100;
268266         }
269267
270         if (state->flip_screen())
268         if (flip_screen())
271269         {
272270            sx = 240 - sx;
273271            sy = 240 - sy;
274272            flipx = !flipx;
275273         }
276274
277         code = state->m_sprite_base + state->m_sprite_ram[offs];
275         code = m_sprite_base + m_sprite_ram[offs];
278276
279         pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4],
277         pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4],
280278                  code,
281279                  color,
282                  flipx,state->flip_screen(),
280                  flipx,flip_screen(),
283281                  sx,sy,
284                  machine.priority_bitmap,
282                  machine().priority_bitmap,
285283                  pri ? 0x02 : 0,0x0f);
286284      }
287285   }
r20977r20978
290288
291289UINT32 stfight_state::screen_update_stfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
292290{
293   set_pens(machine());
291   set_pens();
294292
295293   machine().priority_bitmap.fill(0, cliprect);
296294
r20977r20978
300298
301299   /* Draw sprites (may be obscured by foreground layer) */
302300   if (m_vh_latch_ram[0x07] & 0x40)
303      draw_sprites(machine(), bitmap,cliprect);
301      draw_sprites(bitmap,cliprect);
304302
305303   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
306304   return 0;
trunk/src/mame/video/shadfrce.c
r20977r20978
9292
9393
9494
95static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
95void shadfrce_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
9696{
9797   /* | ---- ---- hhhf Fe-Y | ---- ---- yyyy yyyy | ---- ---- TTTT TTTT | ---- ---- tttt tttt |
9898      | ---- ---- -pCc cccX | ---- ---- xxxx xxxx | ---- ---- ---- ---- | ---- ---- ---- ---- | */
r20977r20978
108108      P = priority
109109   */
110110
111   shadfrce_state *state = machine.driver_data<shadfrce_state>();
112   gfx_element *gfx = machine.gfx[1];
113   UINT16 *finish = state->m_spvideoram_old;
111   gfx_element *gfx = machine().gfx[1];
112   UINT16 *finish = m_spvideoram_old;
114113   UINT16 *source = finish + 0x2000/2 - 8;
115114   int hcount;
116115   while( source>=finish )
r20977r20978
130129      height++;
131130      if (enable) {
132131         for (hcount=0;hcount<height;hcount++) {
133            pdrawgfx_transpen(bitmap,cliprect,gfx,tile+hcount,pal,flipx,flipy,xpos,ypos-hcount*16-16,machine.priority_bitmap,pri_mask,0);
134            pdrawgfx_transpen(bitmap,cliprect,gfx,tile+hcount,pal,flipx,flipy,xpos-0x200,ypos-hcount*16-16,machine.priority_bitmap,pri_mask,0);
135            pdrawgfx_transpen(bitmap,cliprect,gfx,tile+hcount,pal,flipx,flipy,xpos,ypos-hcount*16-16+0x200,machine.priority_bitmap,pri_mask,0);
136            pdrawgfx_transpen(bitmap,cliprect,gfx,tile+hcount,pal,flipx,flipy,xpos-0x200,ypos-hcount*16-16+0x200,machine.priority_bitmap,pri_mask,0);
132            pdrawgfx_transpen(bitmap,cliprect,gfx,tile+hcount,pal,flipx,flipy,xpos,ypos-hcount*16-16,machine().priority_bitmap,pri_mask,0);
133            pdrawgfx_transpen(bitmap,cliprect,gfx,tile+hcount,pal,flipx,flipy,xpos-0x200,ypos-hcount*16-16,machine().priority_bitmap,pri_mask,0);
134            pdrawgfx_transpen(bitmap,cliprect,gfx,tile+hcount,pal,flipx,flipy,xpos,ypos-hcount*16-16+0x200,machine().priority_bitmap,pri_mask,0);
135            pdrawgfx_transpen(bitmap,cliprect,gfx,tile+hcount,pal,flipx,flipy,xpos-0x200,ypos-hcount*16-16+0x200,machine().priority_bitmap,pri_mask,0);
137136         }
138137      }
139138      source-=8;
r20977r20978
148147   {
149148      m_bg1tilemap->draw(bitmap, cliprect, 0,0);
150149      m_bg0tilemap->draw(bitmap, cliprect, 0,1);
151      draw_sprites(machine(), bitmap,cliprect);
150      draw_sprites(bitmap,cliprect);
152151      m_fgtilemap->draw(bitmap, cliprect, 0,0);
153152   }
154153   else
trunk/src/mame/video/speedbal.c
r20977r20978
7979 *                                   *
8080 *************************************/
8181
82static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
82void speedbal_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
8383{
84   speedbal_state *state = machine.driver_data<speedbal_state>();
85   UINT8 *spriteram = state->m_spriteram;
84   UINT8 *spriteram = m_spriteram;
8685   int x,y,code,color,offset,flipx,flipy;
8786
8887   /* Drawing sprites: 64 in total */
8988
90   for (offset = 0;offset < state->m_spriteram.bytes();offset += 4)
89   for (offset = 0;offset < m_spriteram.bytes();offset += 4)
9190   {
9291      if(!(spriteram[offset + 2] & 0x80))
9392         continue;
r20977r20978
101100
102101      flipx = flipy = 0;
103102
104      if(state->flip_screen())
103      if(flip_screen())
105104      {
106105         x = 246 - x;
107106         y = 238 - y;
108107         flipx = flipy = 1;
109108      }
110109
111      drawgfx_transpen (bitmap,cliprect,machine.gfx[2],
110      drawgfx_transpen (bitmap,cliprect,machine().gfx[2],
112111            code,
113112            color,
114113            flipx,flipy,
r20977r20978
126125{
127126   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
128127   m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
129   draw_sprites(machine(), bitmap, cliprect);
128   draw_sprites(bitmap, cliprect);
130129   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
131130   m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
132131   return 0;
trunk/src/mame/video/solomon.c
r20977r20978
6464   m_fg_tilemap->set_transparent_pen(0);
6565}
6666
67static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
67void solomon_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
6868{
69   solomon_state *state = machine.driver_data<solomon_state>();
70   UINT8 *spriteram = state->m_spriteram;
69   UINT8 *spriteram = m_spriteram;
7170   int offs;
7271
73   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
72   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
7473   {
7574      int code = spriteram[offs] + 16 * (spriteram[offs + 1] & 0x10);
7675      int color = (spriteram[offs + 1] & 0x0e) >> 1;
r20977r20978
7978      int sx = spriteram[offs + 3];
8079      int sy = 241 - spriteram[offs + 2];
8180
82      if (state->flip_screen())
81      if (flip_screen())
8382      {
8483         sx = 240 - sx;
8584         sy = 242 - sy;
r20977r20978
8887      }
8988
9089      drawgfx_transpen(bitmap, cliprect,
91         machine.gfx[2],
90         machine().gfx[2],
9291         code, color,
9392         flipx, flipy,
9493         sx, sy, 0);
r20977r20978
9998{
10099   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
101100   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
102   draw_sprites(machine(), bitmap, cliprect);
101   draw_sprites(bitmap, cliprect);
103102   return 0;
104103}
trunk/src/mame/video/skydiver.c
r20977r20978
162162 *
163163 *************************************/
164164
165static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
165void skydiver_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
166166{
167   skydiver_state *state = machine.driver_data<skydiver_state>();
168167   int pic;
169168
170169
r20977r20978
178177      int color;
179178      int wide;
180179
181      sx = 29*8 - state->m_videoram[pic + 0x0390];
182      sy = 30*8 - state->m_videoram[pic*2 + 0x0398];
183      charcode = state->m_videoram[pic*2 + 0x0399];
180      sx = 29*8 - m_videoram[pic + 0x0390];
181      sy = 30*8 - m_videoram[pic*2 + 0x0398];
182      charcode = m_videoram[pic*2 + 0x0399];
184183      xflip = charcode & 0x10;
185184      yflip = charcode & 0x08;
186      wide = (~pic & 0x02) && state->m_width;
185      wide = (~pic & 0x02) && m_width;
187186      charcode = (charcode & 0x07) | ((charcode & 0x60) >> 2);
188187      color = pic & 0x01;
189188
r20977r20978
192191         sx -= 8;
193192      }
194193
195      drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1],
194      drawgfxzoom_transpen(bitmap,cliprect,machine().gfx[1],
196195         charcode, color,
197196         xflip,yflip,sx,sy,
198197         wide ? 0x20000 : 0x10000, 0x10000,0);
r20977r20978
204203{
205204   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
206205
207   draw_sprites(machine(), bitmap, cliprect);
206   draw_sprites(bitmap, cliprect);
208207   return 0;
209208}
trunk/src/mame/video/spdodgeb.c
r20977r20978
143143
144144#define DRAW_SPRITE( order, sx, sy ) drawgfx_transpen( bitmap, \
145145               cliprect,gfx, \
146               (which+order),color+ 8 * state->m_sprite_palbank,flipx,flipy,sx,sy,0);
146               (which+order),color+ 8 * m_sprite_palbank,flipx,flipy,sx,sy,0);
147147
148static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
148void spdodgeb_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
149149{
150   spdodgeb_state *state = machine.driver_data<spdodgeb_state>();
151   UINT8 *spriteram = state->m_spriteram;
152   gfx_element *gfx = machine.gfx[1];
150   UINT8 *spriteram = m_spriteram;
151   gfx_element *gfx = machine().gfx[1];
153152   UINT8 *src;
154153   int i;
155154
r20977r20978
158157/*  240-SY   Z|F|CLR|WCH WHICH    SX
159158    xxxxxxxx x|x|xxx|xxx xxxxxxxx xxxxxxxx
160159*/
161   for (i = 0;i < state->m_spriteram.bytes();i += 4)
160   for (i = 0;i < m_spriteram.bytes();i += 4)
162161   {
163162      int attr = src[i+1];
164163      int which = src[i+2]+((attr & 0x07)<<8);
r20977r20978
171170      int dy = -16;
172171      int cy;
173172
174      if (state->flip_screen())
173      if (flip_screen())
175174      {
176175         sx = 240 - sx;
177176         sy = 240 - sy;
r20977r20978
190189         break;
191190
192191         case 1: /* double y */
193         if (state->flip_screen()) { if (sy > 240) sy -= 256; } else { if (sy < 0) sy += 256; }
192         if (flip_screen()) { if (sy > 240) sy -= 256; } else { if (sy < 0) sy += 256; }
194193         cy = sy + dy;
195194         which &= ~1;
196195         DRAW_SPRITE(0,sx,cy);
r20977r20978
207206{
208207   m_bg_tilemap->set_scrollx(0,m_lastscroll+5);
209208   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
210   draw_sprites(machine(), bitmap,cliprect);
209   draw_sprites(bitmap,cliprect);
211210   return 0;
212211}
trunk/src/mame/video/ssozumo.c
r20977r20978
136136   m_fg_tilemap->set_transparent_pen(0);
137137}
138138
139static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
139void ssozumo_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
140140{
141   ssozumo_state *state = machine.driver_data<ssozumo_state>();
142   UINT8 *spriteram = state->m_spriteram;
141   UINT8 *spriteram = m_spriteram;
143142   int offs;
144143
145   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
144   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
146145   {
147146      if (spriteram[offs] & 0x01)
148147      {
r20977r20978
153152         int sx = 239 - spriteram[offs + 3];
154153         int sy = (240 - spriteram[offs + 2]) & 0xff;
155154
156         if (state->flip_screen())
155         if (flip_screen())
157156         {
158157            sx = 240 - sx;
159158            sy = 240 - sy;
r20977r20978
162161         }
163162
164163         drawgfx_transpen(bitmap, cliprect,
165            machine.gfx[2],
164            machine().gfx[2],
166165            code, color,
167166            flipx, flipy,
168167            sx, sy, 0);
r20977r20978
174173{
175174   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
176175   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
177   draw_sprites(machine(), bitmap, cliprect);
176   draw_sprites(bitmap, cliprect);
178177   return 0;
179178}
trunk/src/mame/video/snk68.c
r20977r20978
4848
4949***************************************************************************/
5050
51static void common_video_start(running_machine &machine)
51void snk68_state::common_video_start()
5252{
53   snk68_state *state = machine.driver_data<snk68_state>();
5453
55   state->m_fg_tilemap->set_transparent_pen(0);
54   m_fg_tilemap->set_transparent_pen(0);
5655
57   state->m_fg_tilemap->set_scrolldx(0, machine.primary_screen->width() - 256);
58   state->m_fg_tilemap->set_scrolldy(0, machine.primary_screen->height() - 256);
56   m_fg_tilemap->set_scrolldx(0, machine().primary_screen->width() - 256);
57   m_fg_tilemap->set_scrolldy(0, machine().primary_screen->height() - 256);
5958}
6059
6160void snk68_state::video_start()
r20977r20978
6362   m_fg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(snk68_state::get_pow_tile_info),this), TILEMAP_SCAN_COLS, 8, 8, 32, 32);
6463   m_fg_tile_offset = 0;
6564
66   common_video_start(machine());
65   common_video_start();
6766}
6867
6968VIDEO_START_MEMBER(snk68_state,searchar)
7069{
7170   m_fg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(snk68_state::get_searchar_tile_info),this), TILEMAP_SCAN_COLS, 8, 8, 32, 32);
7271
73   common_video_start(machine());
72   common_video_start();
7473}
7574
7675/***************************************************************************
r20977r20978
180179
181180***************************************************************************/
182181
183static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int group)
182void snk68_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int group)
184183{
185   snk68_state *state = machine.driver_data<snk68_state>();
186   UINT16 *spriteram16 = state->m_spriteram;
187   int flipscreen = state->m_flipscreen;
188   int sprite_flip_axis = state->m_sprite_flip_axis;
184   UINT16 *spriteram16 = m_spriteram;
185   int flipscreen = m_flipscreen;
186   int sprite_flip_axis = m_sprite_flip_axis;
189187   const UINT16* tiledata = &spriteram16[0x800*group];
190188
191189   // pow has 0x4000 tiles and independent x/y flipping
192190   // the other games have > 0x4000 tiles and flipping in only one direction
193191   // (globally selected)
194   int const is_pow = (machine.gfx[1]->elements() <= 0x4000);
192   int const is_pow = (machine().gfx[1]->elements() <= 0x4000);
195193   int offs;
196194
197195   for (offs = 0; offs < 0x800; offs += 0x40)
r20977r20978
249247               fy = !fy;
250248            }
251249
252            drawgfx_transpen(bitmap,cliprect, machine.gfx[1],
250            drawgfx_transpen(bitmap,cliprect, machine().gfx[1],
253251                  tile,
254252                  color,
255253                  fx, fy,
r20977r20978
274272   bitmap.fill(0x7ff, cliprect);
275273
276274   /* This appears to be the correct priority order */
277   draw_sprites(machine(), bitmap, cliprect, 2);
278   draw_sprites(machine(), bitmap, cliprect, 3);
279   draw_sprites(machine(), bitmap, cliprect, 1);
275   draw_sprites(bitmap, cliprect, 2);
276   draw_sprites(bitmap, cliprect, 3);
277   draw_sprites(bitmap, cliprect, 1);
280278
281279   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
282280   return 0;
trunk/src/mame/video/ssv.c
r20977r20978
592592
593593/* Draw a tilemap sprite */
594594
595static void draw_row(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int sx, int sy, int scroll)
595void ssv_state::draw_row(bitmap_ind16 &bitmap, const rectangle &cliprect, int sx, int sy, int scroll)
596596{
597   ssv_state *state = machine.driver_data<ssv_state>();
598   UINT16 *spriteram16 = state->m_spriteram;
599   UINT16 *ssv_scroll = state->m_scroll;
597   UINT16 *spriteram16 = m_spriteram;
598   UINT16 *ssv_scroll = m_scroll;
600599   rectangle clip;
601600   int attr, code, color, mode, size, page, shadow;
602601   int x, x1, sx1, flipx, xnum, xstart, xend, xinc;
r20977r20978
678677         attr    =   s3[1];  // code low  bits + color
679678
680679         /* Code's high bits are scrambled */
681         code    +=  state->m_tile_code[(attr & 0x3c00)>>10];
680         code    +=  m_tile_code[(attr & 0x3c00)>>10];
682681         flipy   =   (attr & 0x4000);
683682         flipx   =   (attr & 0x8000);
684683
r20977r20978
708707         {
709708            for (ty = ystart; ty != yend; ty += yinc)
710709            {
711               ssv_drawgfx( bitmap, clip, machine.gfx[gfx],
710               ssv_drawgfx( bitmap, clip, machine().gfx[gfx],
712711                                 code++,
713712                                 color,
714713                                 flipx, flipy,
r20977r20978
724723
725724/* Draw the "background layer" using multiple tilemap sprites */
726725
727static void draw_layer(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int  nr)
726void ssv_state::draw_layer(bitmap_ind16 &bitmap, const rectangle &cliprect, int  nr)
728727{
729728   int sy;
730   for ( sy = 0; sy <= machine.primary_screen->visible_area().max_y; sy += 0x40 )
731      draw_row(machine, bitmap, cliprect, 0, sy, nr);
729   for ( sy = 0; sy <= machine().primary_screen->visible_area().max_y; sy += 0x40 )
730      draw_row(bitmap, cliprect, 0, sy, nr);
732731}
733732
734733/* Draw sprites in the sprites list */
735734
736static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
735void ssv_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
737736{
738737   /* Sprites list */
739   ssv_state *state = machine.driver_data<ssv_state>();
740   UINT16 *ssv_scroll = state->m_scroll;
741   UINT16 *spriteram16 = state->m_spriteram;
738   UINT16 *ssv_scroll = m_scroll;
739   UINT16 *spriteram16 = m_spriteram;
742740
743741   UINT16 *s1  =   spriteram16;
744742   UINT16 *end1    =   spriteram16 + 0x02000/2;
r20977r20978
823821            }
824822
825823            if ((mode & 0x001f) != 0)
826               draw_row(machine, bitmap, cliprect, sx, sy, scroll);
824               draw_row(bitmap, cliprect, sx, sy, scroll);
827825         }
828826         else
829827         {
r20977r20978
844842            attr    =   s2[1];  // code low  bits + color
845843
846844            /* Code's high bits are scrambled */
847            code    +=  state->m_tile_code[(attr & 0x3c00)>>10];
845            code    +=  m_tile_code[(attr & 0x3c00)>>10];
848846            flipy   =   (attr & 0x4000);
849847            flipx   =   (attr & 0x8000);
850848
r20977r20978
934932            {
935933               for (y = ystart; y != yend; y += yinc)
936934               {
937                  ssv_drawgfx( bitmap, cliprect, machine.gfx[gfx],
935                  ssv_drawgfx( bitmap, cliprect, machine().gfx[gfx],
938936                                    code++,
939937                                    color,
940938                                    flipx, flipy,
r20977r20978
944942            }
945943
946944            #ifdef MAME_DEBUG
947            if (machine.input().code_pressed(KEYCODE_Z))    /* Display some info on each sprite */
945            if (machine().input().code_pressed(KEYCODE_Z))    /* Display some info on each sprite */
948946            {   char buf[30];
949947               sprintf(buf, "%02X",/*(s2[2] & ~0x3ff)>>8*/mode>>8);
950               ui_draw_text(&machine.render().ui_container(), buf, sx, sy);
948               ui_draw_text(&machine().render().ui_container(), buf, sx, sy);
951949            }
952950            #endif
953951
r20977r20978
986984   return 0;
987985}
988986
989void ssv_enable_video(running_machine &machine, int enable)
987void ssv_state::ssv_enable_video(int enable)
990988{
991   ssv_state *state = machine.driver_data<ssv_state>();
992989
993   state->m_enable_video = enable;
990   m_enable_video = enable;
994991}
995992
996993UINT32 ssv_state::screen_update_ssv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20977r20978
10351032   if (!m_enable_video)
10361033      return 0;
10371034
1038   draw_layer(machine(), bitmap, clip, 0); // "background layer"
1035   draw_layer(bitmap, clip, 0); // "background layer"
10391036
1040   draw_sprites(machine(), bitmap, clip);  // sprites list
1037   draw_sprites(bitmap, clip);  // sprites list
10411038
10421039
10431040   return 0;
trunk/src/mame/video/segag80v.c
r20977r20978
7676*/
7777
7878
79INLINE int adjust_xy(segag80v_state *state, int rawx, int rawy, int *outx, int *outy)
79inline int segag80v_state::adjust_xy(int rawx, int rawy, int *outx, int *outy)
8080{
8181   int clipped = FALSE;
8282
r20977r20978
101101      *outy &= 0x3ff;
102102
103103   /* convert into .16 values */
104   *outx = (*outx - (state->m_min_x - 512)) << 16;
105   *outy = (*outy - (state->m_min_y - 512)) << 16;
104   *outx = (*outx - (m_min_x - 512)) << 16;
105   *outy = (*outy - (m_min_y - 512)) << 16;
106106   return clipped;
107107}
108108
109109
110static void sega_generate_vector_list(running_machine &machine)
110void segag80v_state::sega_generate_vector_list()
111111{
112   segag80v_state *state = machine.driver_data<segag80v_state>();
113   UINT8 *sintable = state->memregion("proms")->base();
112   UINT8 *sintable = memregion("proms")->base();
114113   double total_time = 1.0 / (double)IRQ_CLOCK;
115114   UINT16 symaddr = 0;
116   UINT8 *vectorram = state->m_vectorram;
115   UINT8 *vectorram = m_vectorram;
117116
118117   vector_clear_list();
119118
r20977r20978
176175         int adjx, adjy, clipped;
177176
178177         /* Add a starting point to the vector list. */
179         clipped = adjust_xy(state, curx, cury, &adjx, &adjy);
178         clipped = adjust_xy(curx, cury, &adjx, &adjy);
180179         if (!clipped)
181            vector_add_point(machine, adjx, adjy, 0, 0);
180            vector_add_point(machine(), adjx, adjy, 0, 0);
182181
183182         /* Loop until we run out of time. */
184183         while (total_time > 0)
r20977r20978
242241               intensity = 0;
243242
244243            /* Loop over the length of the vector. */
245            clipped = adjust_xy(state, curx, cury, &adjx, &adjy);
244            clipped = adjust_xy(curx, cury, &adjx, &adjy);
246245            xaccum = yaccum = 0;
247246            while (length-- != 0 && total_time > 0)
248247            {
r20977r20978
281280               /* Apply the clipping from the DAC circuit. If the values clip */
282281               /* the beam is turned off, but the computations continue right */
283282               /* on going. */
284               newclip = adjust_xy(state, curx, cury, &adjx, &adjy);
283               newclip = adjust_xy(curx, cury, &adjx, &adjy);
285284               if (newclip != clipped)
286285               {
287286                  /* if we're just becoming unclipped, add an empty point */
288287                  if (!newclip)
289                     vector_add_point(machine, adjx, adjy, 0, 0);
288                     vector_add_point(machine(), adjx, adjy, 0, 0);
290289
291290                  /* otherwise, add a colored point */
292291                  else
293                     vector_add_point(machine, adjx, adjy, color, intensity);
292                     vector_add_point(machine(), adjx, adjy, color, intensity);
294293               }
295294               clipped = newclip;
296295
r20977r20978
300299
301300            /* We're done; if we are not clipped, add a final point. */
302301            if (!clipped)
303               vector_add_point(machine, adjx, adjy, color, intensity);
302               vector_add_point(machine(), adjx, adjy, color, intensity);
304303
305304            /* if the high bit of the attribute is set, we break out of   */
306305            /* this loop and fetch another symbol */
r20977r20978
336335
337336UINT32 segag80v_state::screen_update_segag80v(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
338337{
339   sega_generate_vector_list(machine());
338   sega_generate_vector_list();
340339   SCREEN_UPDATE32_CALL(vector);
341340   return 0;
342341}
trunk/src/mame/video/superchs.c
r20977r20978
5353
5454********************************************************/
5555
56static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,const int *primasks,int x_offs,int y_offs)
56void superchs_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,const int *primasks,int x_offs,int y_offs)
5757{
58   superchs_state *state = machine.driver_data<superchs_state>();
59   UINT32 *spriteram32 = state->m_spriteram;
60   UINT16 *spritemap = (UINT16 *)state->memregion("user1")->base();
58   UINT32 *spriteram32 = m_spriteram;
59   UINT16 *spritemap = (UINT16 *)memregion("user1")->base();
6160   int offs, data, tilenum, color, flipx, flipy;
6261   int x, y, priority, dblsize, curx, cury;
6362   int sprites_flipscreen = 0;
r20977r20978
6766
6867   /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
6968      while processing sprite ram and then draw them all at the end */
70   struct tempsprite *sprite_ptr = state->m_spritelist;
69   struct tempsprite *sprite_ptr = m_spritelist;
7170
72   for (offs = (state->m_spriteram.bytes()/4-4);offs >= 0;offs -= 4)
71   for (offs = (m_spriteram.bytes()/4-4);offs >= 0;offs -= 4)
7372   {
7473      data = spriteram32[offs+0];
7574      flipx =    (data & 0x00800000) >> 23;
r20977r20978
164163            }
165164            else
166165            {
167               drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[sprite_ptr->gfx],
166               drawgfxzoom_transpen(bitmap,cliprect,machine().gfx[sprite_ptr->gfx],
168167                     sprite_ptr->code,
169168                     sprite_ptr->color,
170169                     sprite_ptr->flipx,sprite_ptr->flipy,
r20977r20978
179178   }
180179
181180   /* this happens only if primsks != NULL */
182   while (sprite_ptr != state->m_spritelist)
181   while (sprite_ptr != m_spritelist)
183182   {
184183      sprite_ptr--;
185184
186      pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[sprite_ptr->gfx],
185      pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[sprite_ptr->gfx],
187186            sprite_ptr->code,
188187            sprite_ptr->color,
189188            sprite_ptr->flipx,sprite_ptr->flipy,
190189            sprite_ptr->x,sprite_ptr->y,
191190            sprite_ptr->zoomx,sprite_ptr->zoomy,
192            machine.priority_bitmap,sprite_ptr->primask,0);
191            machine().priority_bitmap,sprite_ptr->primask,0);
193192   }
194193}
195194
r20977r20978
225224   if (!machine().input().code_pressed (KEYCODE_C)) tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[2], 0, 2);
226225   if (!machine().input().code_pressed (KEYCODE_V)) tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[3], 0, 4);
227226   if (!machine().input().code_pressed (KEYCODE_B)) tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[4], 0, 8);
228   if (!machine().input().code_pressed (KEYCODE_N)) draw_sprites(machine(), bitmap, cliprect, primasks, 48, -116);
227   if (!machine().input().code_pressed (KEYCODE_N)) draw_sprites(bitmap, cliprect, primasks, 48, -116);
229228#else
230229   tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 0);
231230   tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[1], 0, 1);
232231   tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[2], 0, 2);
233232   tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[3], 0, 4);
234233   tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[4], 0, 8);    /* text layer */
235   draw_sprites(machine(), bitmap, cliprect, primasks, 48, -116);
234   draw_sprites(bitmap, cliprect, primasks, 48, -116);
236235#endif
237236   return 0;
238237}
trunk/src/mame/video/st0016.c
r20977r20978
211211   }
212212}
213213
214static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
214void st0016_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
215215{
216216   /*
217217   object ram :
r20977r20978
256256
257257   */
258258
259   gfx_element *gfx = machine.gfx[st0016_ramgfx];
259   gfx_element *gfx = machine().gfx[st0016_ramgfx];
260260   int i,j,lx,ly,x,y,code,offset,length,sx,sy,color,flipx,flipy,scrollx,scrolly/*,plx,ply*/;
261261
262262
r20977r20978
418418}
419419
420420
421static void st0016_save_init(running_machine &machine)
421void st0016_state::st0016_save_init()
422422{
423   state_save_register_global(machine, st0016_spr_bank);
424   state_save_register_global(machine, st0016_spr2_bank);
425   state_save_register_global(machine, st0016_pal_bank);
426   state_save_register_global(machine, st0016_char_bank);
427   //state_save_register_global(machine, st0016_rom_bank);
428   state_save_register_global_array(machine, st0016_vregs);
429   state_save_register_global_pointer(machine, st0016_charram, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
430   state_save_register_global_pointer(machine, st0016_paletteram, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE);
431   state_save_register_global_pointer(machine, st0016_spriteram, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE);
423   state_save_register_global(machine(), st0016_spr_bank);
424   state_save_register_global(machine(), st0016_spr2_bank);
425   state_save_register_global(machine(), st0016_pal_bank);
426   state_save_register_global(machine(), st0016_char_bank);
427   //state_save_register_global(machine(), st0016_rom_bank);
428   state_save_register_global_array(machine(), st0016_vregs);
429   state_save_register_global_pointer(machine(), st0016_charram, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
430   state_save_register_global_pointer(machine(), st0016_paletteram, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE);
431   state_save_register_global_pointer(machine(), st0016_spriteram, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE);
432432}
433433
434434
r20977r20978
483483
484484   }
485485
486   st0016_save_init(machine());
486   st0016_save_init();
487487}
488488
489489
490static void draw_bgmap(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int priority)
490void st0016_state::draw_bgmap(bitmap_ind16 &bitmap,const rectangle &cliprect, int priority)
491491{
492   gfx_element *gfx = machine.gfx[st0016_ramgfx];
492   gfx_element *gfx = machine().gfx[st0016_ramgfx];
493493   int j;
494494   //for(j=0x40-8;j>=0;j-=8)
495495   for(j=0;j<0x40;j+=8)
r20977r20978
583583
584584void st0016_state::st0016_draw_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
585585{
586   draw_bgmap(machine(), bitmap,cliprect,0);
587   draw_sprites(machine(), bitmap,cliprect);
588   draw_bgmap(machine(), bitmap,cliprect,1);
586   draw_bgmap(bitmap,cliprect,0);
587   draw_sprites(bitmap,cliprect);
588   draw_bgmap(bitmap,cliprect,1);
589589}
590590
591591UINT32 st0016_state::screen_update_st0016(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
trunk/src/mame/video/slapshot.c
r20977r20978
3333            SPRITE DRAW ROUTINES
3434************************************************************/
3535
36static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks, int y_offset )
36void slapshot_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks, int y_offset )
3737{
3838   /*
3939       Sprite format:
r20977r20978
8888       000b - 000f : unused
8989
9090   */
91   slapshot_state *state = machine.driver_data<slapshot_state>();
9291   int x, y, off, extoffs;
9392   int code, color, spritedata, spritecont, flipx, flipy;
9493   int xcurrent, ycurrent, big_sprite = 0;
r20977r20978
101100
102101   /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
103102      while processing sprite ram and then draw them all at the end */
104   struct slapshot_tempsprite *sprite_ptr = state->m_spritelist;
103   struct slapshot_tempsprite *sprite_ptr = m_spritelist;
105104
106105   /* must remember enable status from last frame because driftout fails to
107106      reactivate them from a certain point onwards. */
108   int disabled = state->m_sprites_disabled;
107   int disabled = m_sprites_disabled;
109108
110109   /* must remember master scroll from previous frame because driftout
111110      sometimes doesn't set it. */
112   int master_scrollx = state->m_sprites_master_scrollx;
113   int master_scrolly = state->m_sprites_master_scrolly;
111   int master_scrollx = m_sprites_master_scrollx;
112   int master_scrolly = m_sprites_master_scrolly;
114113
115114   /* must also remember the sprite bank from previous frame. */
116   int area = state->m_sprites_active_area;
115   int area = m_sprites_active_area;
117116
118117   scroll1x = 0;
119118   scroll1y = 0;
r20977r20978
122121   color = 0;
123122
124123   x_offset = 3;   /* Get rid of 0-3 unwanted pixels on edge of screen. */
125   if (state->m_sprites_flipscreen) x_offset = -x_offset;
124   if (m_sprites_flipscreen) x_offset = -x_offset;
126125
127126   /* safety check to avoid getting stuck in bank 2 for games using only one bank */
128127   if (area == 0x8000 &&
129         state->m_spriteram_buffered[(0x8000 + 6) / 2] == 0 &&
130         state->m_spriteram_buffered[(0x8000 + 10) / 2] == 0)
128         m_spriteram_buffered[(0x8000 + 6) / 2] == 0 &&
129         m_spriteram_buffered[(0x8000 + 10) / 2] == 0)
131130      area = 0;
132131
133132
r20977r20978
136135      /* sprites_active_area may change during processing */
137136      int offs = off + area;
138137
139      if (state->m_spriteram_buffered[(offs + 6) / 2] & 0x8000)
138      if (m_spriteram_buffered[(offs + 6) / 2] & 0x8000)
140139      {
141         disabled = state->m_spriteram_buffered[(offs + 10) / 2] & 0x1000;
142         state->m_sprites_flipscreen = state->m_spriteram_buffered[(offs + 10) / 2] & 0x2000;
140         disabled = m_spriteram_buffered[(offs + 10) / 2] & 0x1000;
141         m_sprites_flipscreen = m_spriteram_buffered[(offs + 10) / 2] & 0x2000;
143142         x_offset = 3;   /* Get rid of 0-3 unwanted pixels on edge of screen. */
144         if (state->m_sprites_flipscreen) x_offset = -x_offset;
145         area = 0x8000 * (state->m_spriteram_buffered[(offs + 10) / 2] & 0x0001);
143         if (m_sprites_flipscreen) x_offset = -x_offset;
144         area = 0x8000 * (m_spriteram_buffered[(offs + 10) / 2] & 0x0001);
146145         continue;
147146      }
148147
149148//popmessage("%04x",area);
150149
151150      /* check for extra scroll offset */
152      if ((state->m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0xa000)
151      if ((m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0xa000)
153152      {
154         master_scrollx = state->m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
153         master_scrollx = m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
155154         if (master_scrollx >= 0x800)
156155            master_scrollx -= 0x1000;   /* signed value */
157156
158         master_scrolly = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
157         master_scrolly = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
159158         if (master_scrolly >= 0x800)
160159            master_scrolly -= 0x1000;   /* signed value */
161160      }
162161
163      if ((state->m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0x5000)
162      if ((m_spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0x5000)
164163      {
165         scroll1x = state->m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
164         scroll1x = m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
166165         if (scroll1x >= 0x800)
167166            scroll1x -= 0x1000;   /* signed value */
168167
169         scroll1y = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
168         scroll1y = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
170169         if (scroll1y >= 0x800)
171170            scroll1y -= 0x1000;   /* signed value */
172171      }
r20977r20978
174173      if (disabled)
175174         continue;
176175
177      spritedata = state->m_spriteram_buffered[(offs + 8) / 2];
176      spritedata = m_spriteram_buffered[(offs + 8) / 2];
178177
179178      spritecont = (spritedata & 0xff00) >> 8;
180179
r20977r20978
182181      {
183182         if (big_sprite == 0)   /* are we starting a big sprite ? */
184183         {
185            xlatch = state->m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
186            ylatch = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
184            xlatch = m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
185            ylatch = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
187186            x_no = 0;
188187            y_no = 0;
189            zoomword = state->m_spriteram_buffered[(offs + 2) / 2];
188            zoomword = m_spriteram_buffered[(offs + 2) / 2];
190189            zoomylatch = (zoomword >> 8) & 0xff;
191190            zoomxlatch = (zoomword >> 0) & 0xff;
192191            big_sprite = 1;   /* we have started a new big sprite */
r20977r20978
207206// of anything.
208207      if (big_sprite == 0 || (spritecont & 0xf0) == 0)
209208      {
210         x = state->m_spriteram_buffered[(offs + 4) / 2];
209         x = m_spriteram_buffered[(offs + 4) / 2];
211210
212211// DG: some absolute x values deduced here are 1 too high (scenes when you get
213212// home run in Koshien, and may also relate to BG layer woods and stuff as you
r20977r20978
230229            scrolly = scroll1y + master_scrolly;
231230         }
232231         x &= 0xfff;
233         y = state->m_spriteram_buffered[(offs+6)/2] & 0xfff;
232         y = m_spriteram_buffered[(offs+6)/2] & 0xfff;
234233
235234         xcurrent = x;
236235         ycurrent = y;
r20977r20978
278277      }
279278      else
280279      {
281         zoomword = state->m_spriteram_buffered[(offs+2)/2];
280         zoomword = m_spriteram_buffered[(offs+2)/2];
282281         zoomy = (zoomword >> 8) & 0xff;
283282         zoomx = (zoomword >> 0) & 0xff;
284283         zx = (0x100 - zoomx) / 16;
r20977r20978
298297      {
299298         int i;
300299
301         code = state->m_spriteram_buffered[(offs)/2] & 0xff;
302         i = (state->m_spriteext[(extoffs >> 4)] & 0xff00 );
300         code = m_spriteram_buffered[(offs)/2] & 0xff;
301         i = (m_spriteext[(extoffs >> 4)] & 0xff00 );
303302         code = (i | code);
304303      }
305304
r20977r20978
315314      cury = (y + scrolly) & 0xfff;
316315      if (cury >= 0x800)  cury -= 0x1000;   /* treat it as signed */
317316
318      if (state->m_sprites_flipscreen)
317      if (m_sprites_flipscreen)
319318      {
320319         /* -zx/y is there to fix zoomed sprite coords in screenflip.
321320            drawgfxzoom does not know to draw from flip-side of sprites when
r20977r20978
332331      {
333332         sprite_ptr->code = code;
334333         sprite_ptr->color = color;
335         if (machine.gfx[0]->granularity() == 64)    /* Final Blow, Slapshot are 6bpp */
334         if (machine().gfx[0]->granularity() == 64)    /* Final Blow, Slapshot are 6bpp */
336335            sprite_ptr->color /= 4;
337336         sprite_ptr->flipx = flipx;
338337         sprite_ptr->flipy = flipy;
r20977r20978
349348         }
350349         else
351350         {
352            drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
351            drawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
353352                  sprite_ptr->code,
354353                  sprite_ptr->color,
355354                  sprite_ptr->flipx,sprite_ptr->flipy,
r20977r20978
361360
362361
363362   /* this happens only if primsks != NULL */
364   while (sprite_ptr != state->m_spritelist)
363   while (sprite_ptr != m_spritelist)
365364   {
366365      sprite_ptr--;
367366
368      pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
367      pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
369368            sprite_ptr->code,
370369            sprite_ptr->color,
371370            sprite_ptr->flipx,sprite_ptr->flipy,
372371            sprite_ptr->x,sprite_ptr->y,
373372            sprite_ptr->zoomx,sprite_ptr->zoomy,
374            machine.priority_bitmap,sprite_ptr->primask,0);
373            machine().priority_bitmap,sprite_ptr->primask,0);
375374   }
376375}
377376
378377
379static void taito_handle_sprite_buffering( running_machine &machine )
378void slapshot_state::taito_handle_sprite_buffering(  )
380379{
381   slapshot_state *state = machine.driver_data<slapshot_state>();
382380
383   if (state->m_prepare_sprites)   /* no buffering */
381   if (m_prepare_sprites)   /* no buffering */
384382   {
385      memcpy(state->m_spriteram_buffered, state->m_spriteram, state->m_spriteram.bytes());
386      state->m_prepare_sprites = 0;
383      memcpy(m_spriteram_buffered, m_spriteram, m_spriteram.bytes());
384      m_prepare_sprites = 0;
387385   }
388386}
389387
390static void taito_update_sprites_active_area( running_machine &machine )
388void slapshot_state::taito_update_sprites_active_area(  )
391389{
392   slapshot_state *state = machine.driver_data<slapshot_state>();
393390   int off;
394391
395392   /* if the frame was skipped, we'll have to do the buffering now */
396   taito_handle_sprite_buffering(machine);
393   taito_handle_sprite_buffering();
397394
398395   /* safety check to avoid getting stuck in bank 2 for games using only one bank */
399   if (state->m_sprites_active_area == 0x8000 &&
400         state->m_spriteram_buffered[(0x8000 + 6) / 2] == 0 &&
401         state->m_spriteram_buffered[(0x8000 + 10) / 2] == 0)
402      state->m_sprites_active_area = 0;
396   if (m_sprites_active_area == 0x8000 &&
397         m_spriteram_buffered[(0x8000 + 6) / 2] == 0 &&
398         m_spriteram_buffered[(0x8000 + 10) / 2] == 0)
399      m_sprites_active_area = 0;
403400
404401   for (off = 0; off < 0x4000; off += 16)
405402   {
406403      /* sprites_active_area may change during processing */
407      int offs = off + state->m_sprites_active_area;
404      int offs = off + m_sprites_active_area;
408405
409      if (state->m_spriteram_buffered[(offs + 6) / 2] & 0x8000)
406      if (m_spriteram_buffered[(offs + 6) / 2] & 0x8000)
410407      {
411         state->m_sprites_disabled = state->m_spriteram_buffered[(offs + 10) / 2] & 0x1000;
412         state->m_sprites_active_area = 0x8000 * (state->m_spriteram_buffered[(offs + 10) / 2] & 0x0001);
408         m_sprites_disabled = m_spriteram_buffered[(offs + 10) / 2] & 0x1000;
409         m_sprites_active_area = 0x8000 * (m_spriteram_buffered[(offs + 10) / 2] & 0x0001);
413410         continue;
414411      }
415412
416413      /* check for extra scroll offset */
417      if ((state->m_spriteram_buffered[(offs+4)/2] & 0xf000) == 0xa000)
414      if ((m_spriteram_buffered[(offs+4)/2] & 0xf000) == 0xa000)
418415      {
419         state->m_sprites_master_scrollx = state->m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
420         if (state->m_sprites_master_scrollx >= 0x800)
421            state->m_sprites_master_scrollx -= 0x1000;   /* signed value */
416         m_sprites_master_scrollx = m_spriteram_buffered[(offs + 4) / 2] & 0xfff;
417         if (m_sprites_master_scrollx >= 0x800)
418            m_sprites_master_scrollx -= 0x1000;   /* signed value */
422419
423         state->m_sprites_master_scrolly = state->m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
424         if (state->m_sprites_master_scrolly >= 0x800)
425            state->m_sprites_master_scrolly -= 0x1000;   /* signed value */
420         m_sprites_master_scrolly = m_spriteram_buffered[(offs + 6) / 2] & 0xfff;
421         if (m_sprites_master_scrolly >= 0x800)
422            m_sprites_master_scrolly -= 0x1000;   /* signed value */
426423      }
427424   }
428425}
r20977r20978
432429   // rising edge
433430   if (state)
434431   {
435      taito_update_sprites_active_area(machine());
432      taito_update_sprites_active_area();
436433
437434      m_prepare_sprites = 1;
438435   }
r20977r20978
495492   }
496493#endif
497494
498   taito_handle_sprite_buffering(machine());
495   taito_handle_sprite_buffering();
499496
500497   tc0480scp_tilemap_update(m_tc0480scp);
501498
r20977r20978
555552         if (spritepri[i] < tilepri[(layer[3])]) primasks[i] |= 0xff00;
556553      }
557554
558      draw_sprites(machine(),bitmap,cliprect,primasks,0);
555      draw_sprites(bitmap,cliprect,primasks,0);
559556   }
560557
561558   /*
trunk/src/mame/video/sidearms.c
r20977r20978
161161   m_flipon = m_charon = m_staron = m_objon = m_bgon = 0;
162162}
163163
164static void draw_sprites_region(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int start_offset, int end_offset )
164void sidearms_state::draw_sprites_region(bitmap_ind16 &bitmap, const rectangle &cliprect, int start_offset, int end_offset )
165165{
166   sidearms_state *state = machine.driver_data<sidearms_state>();
167   UINT8 *buffered_spriteram = state->m_spriteram->buffer();
168   gfx_element *gfx = machine.gfx[2];
166   UINT8 *buffered_spriteram = m_spriteram->buffer();
167   gfx_element *gfx = machine().gfx[2];
169168   int offs, attr, color, code, x, y, flipx, flipy;
170169
171   flipy = flipx = state->m_flipon;
170   flipy = flipx = m_flipon;
172171
173172   for (offs = end_offset - 32; offs >= start_offset; offs -= 32)
174173   {
r20977r20978
180179      code = buffered_spriteram[offs] + ((attr << 3) & 0x700);
181180      x = buffered_spriteram[offs + 3] + ((attr << 4) & 0x100);
182181
183      if (state->m_flipon)
182      if (m_flipon)
184183      {
185184         x = (62 * 8) - x;
186185         y = (30 * 8) - y;
r20977r20978
194193   }
195194}
196195
197static void sidearms_draw_starfield( running_machine &machine, bitmap_ind16 &bitmap )
196void sidearms_state::sidearms_draw_starfield( bitmap_ind16 &bitmap )
198197{
199198   int x, y, i;
200199   UINT32 hadd_283, vadd_283, _hflop_74a_n, _hcount_191, _vcount_191;
201200   UINT8 *sf_rom;
202201   UINT16 *lineptr;
203202   int pixadv, lineadv;
204   sidearms_state *state = machine.driver_data<sidearms_state>();
205203
206204   // clear starfield background
207205   lineptr = &bitmap.pix16(16, 64);
r20977r20978
210208   for (i=224; i; i--) { memset(lineptr, 0, 768); lineptr += lineadv; }
211209
212210   // bail if not Side Arms or the starfield has been disabled
213   if (state->m_gameid || !state->m_staron) return;
211   if (m_gameid || !m_staron) return;
214212
215213   // init and cache some global vars in stack frame
216214   hadd_283 = 0;
217215
218   _hflop_74a_n = state->m_hflop_74a_n;
219   _vcount_191 = state->m_vcount_191;
220   _hcount_191 = state->m_hcount_191 & 0xff;
216   _hflop_74a_n = m_hflop_74a_n;
217   _vcount_191 = m_vcount_191;
218   _hcount_191 = m_hcount_191 & 0xff;
221219
222   sf_rom = machine.root_device().memregion("user1")->base();
220   sf_rom = machine().root_device().memregion("user1")->base();
223221
224222#if 0 // old loop (for reference; easier to read)
225223   if (!flipon)
r20977r20978
265263      lineptr += lineadv;
266264   }
267265#else // optimized loop
268   if (!state->m_flipon)
266   if (!m_flipon)
269267   {
270268      lineptr = &bitmap.pix16(16, 64);
271269      pixadv  = 1;
r20977r20978
287285      i = vadd_283<<4 & 0xff0;                // to starfield EPROM A04-A11 (8 bits)
288286      i |= (_hflop_74a_n^(hadd_283>>8)) << 3; // to starfield EPROM A03     (1 bit)
289287      i |= hadd_283>>5 & 7;                   // to starfield EPROM A00-A02 (3 bits)
290      state->m_latch_374 = sf_rom[i + 0x3000];            // lines A12-A13 are always high
288      m_latch_374 = sf_rom[i + 0x3000];            // lines A12-A13 are always high
291289
292290      hadd_283 = _hcount_191 + 63;
293291
r20977r20978
306304            i = vadd_283<<4 & 0xff0;                // to starfield EPROM A04-A11 (8 bits)
307305            i |= (_hflop_74a_n^(hadd_283>>8)) << 3; // to starfield EPROM A03     (1 bit)
308306            i |= hadd_283>>5 & 7;                   // to starfield EPROM A00-A02 (3 bits)
309            state->m_latch_374 = sf_rom[i + 0x3000];            // lines A12-A13 are always high
307            m_latch_374 = sf_rom[i + 0x3000];            // lines A12-A13 are always high
310308         }
311309
312         if ((~((state->m_latch_374^hadd_283)^1) & 0x1f)) continue; // logic rejection 3
310         if ((~((m_latch_374^hadd_283)^1) & 0x1f)) continue; // logic rejection 3
313311
314         *lineptr = (UINT16)(state->m_latch_374>>5 | 0x378); // to color mixer
312         *lineptr = (UINT16)(m_latch_374>>5 | 0x378); // to color mixer
315313      }
316314      lineptr += lineadv;
317315   }
318316#endif
319317}
320318
321static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
319void sidearms_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
322320{
323   sidearms_state *state = machine.driver_data<sidearms_state>();
324321
325   if (state->m_gameid == 2 || state->m_gameid == 3) // Dyger and Whizz have simple front-to-back sprite priority
326      draw_sprites_region(machine, bitmap, cliprect, 0x0000, 0x1000);
322   if (m_gameid == 2 || m_gameid == 3) // Dyger and Whizz have simple front-to-back sprite priority
323      draw_sprites_region(bitmap, cliprect, 0x0000, 0x1000);
327324   else
328325   {
329      draw_sprites_region(machine, bitmap, cliprect, 0x0700, 0x0800);
330      draw_sprites_region(machine, bitmap, cliprect, 0x0e00, 0x1000);
331      draw_sprites_region(machine, bitmap, cliprect, 0x0800, 0x0f00);
332      draw_sprites_region(machine, bitmap, cliprect, 0x0000, 0x0700);
326      draw_sprites_region(bitmap, cliprect, 0x0700, 0x0800);
327      draw_sprites_region(bitmap, cliprect, 0x0e00, 0x1000);
328      draw_sprites_region(bitmap, cliprect, 0x0800, 0x0f00);
329      draw_sprites_region(bitmap, cliprect, 0x0000, 0x0700);
333330   }
334331}
335332
336333UINT32 sidearms_state::screen_update_sidearms(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
337334{
338   sidearms_draw_starfield(machine(), bitmap);
335   sidearms_draw_starfield(bitmap);
339336
340337   m_bg_tilemap->set_scrollx(0, m_bg_scrollx[0] + (m_bg_scrollx[1] << 8 & 0xf00));
341338   m_bg_tilemap->set_scrolly(0, m_bg_scrolly[0] + (m_bg_scrolly[1] << 8 & 0xf00));
r20977r20978
344341      m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
345342
346343   if (m_objon)
347      draw_sprites(machine(), bitmap, cliprect);
344      draw_sprites(bitmap, cliprect);
348345
349346   if (m_charon)
350347      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
trunk/src/mame/video/sprint2.c
r20977r20978
7777}
7878
7979
80static UINT8 collision_check(sprint2_state *state, colortable_t *colortable, rectangle& rect)
80UINT8 sprint2_state::collision_check(colortable_t *colortable, rectangle& rect)
8181{
8282   UINT8 data = 0;
8383
r20977r20978
8787   for (y = rect.min_y; y <= rect.max_y; y++)
8888      for (x = rect.min_x; x <= rect.max_x; x++)
8989      {
90         UINT16 a = colortable_entry_get_value(colortable, state->m_helper.pix16(y, x));
90         UINT16 a = colortable_entry_get_value(colortable, m_helper.pix16(y, x));
9191
9292         if (a == 0)
9393            data |= 0x40;
r20977r20978
100100}
101101
102102
103INLINE int get_sprite_code(UINT8 *video_ram, int n)
103inline int sprint2_state::get_sprite_code(UINT8 *video_ram, int n)
104104{
105105   return video_ram[0x398 + 2 * n + 1] >> 3;
106106}
107INLINE int get_sprite_x(UINT8 *video_ram, int n)
107inline int sprint2_state::get_sprite_x(UINT8 *video_ram, int n)
108108{
109109   return 2 * (248 - video_ram[0x390 + 1 * n]);
110110}
111INLINE int get_sprite_y(UINT8 *video_ram, int n)
111inline int sprint2_state::get_sprite_y(UINT8 *video_ram, int n)
112112{
113113   return 1 * (248 - video_ram[0x398 + 2 * n]);
114114}
r20977r20978
176176            get_sprite_x(video_ram, i),
177177            get_sprite_y(video_ram, i), 1);
178178
179         m_collision[i] |= collision_check(this, machine().colortable, rect);
179         m_collision[i] |= collision_check(machine().colortable, rect);
180180
181181         /* check for sprite-sprite collisions */
182182
r20977r20978
198198            get_sprite_x(video_ram, i),
199199            get_sprite_y(video_ram, i), 1);
200200
201         m_collision[i] |= collision_check(this, machine().colortable, rect);
201         m_collision[i] |= collision_check(machine().colortable, rect);
202202      }
203203   }
204204}
trunk/src/mame/video/sf.c
r20977r20978
116116
117117***************************************************************************/
118118
119INLINE int sf_invert( int nb )
119inline int sf_state::sf_invert( int nb )
120120{
121121   static const int delta[4] = {0x00, 0x18, 0x18, 0x00};
122122   return nb ^ delta[(nb >> 3) & 3];
123123}
124124
125static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect )
125void sf_state::draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect )
126126{
127   sf_state *state = machine.driver_data<sf_state>();
128127   int offs;
129128
130129   for (offs = 0x1000 - 0x20; offs >= 0; offs -= 0x20)
131130   {
132      int c = state->m_objectram[offs];
133      int attr = state->m_objectram[offs + 1];
134      int sy = state->m_objectram[offs + 2];
135      int sx = state->m_objectram[offs + 3];
131      int c = m_objectram[offs];
132      int attr = m_objectram[offs + 1];
133      int sy = m_objectram[offs + 2];
134      int sx = m_objectram[offs + 3];
136135      int color = attr & 0x000f;
137136      int flipx = attr & 0x0100;
138137      int flipy = attr & 0x0200;
r20977r20978
141140      {
142141         int c1, c2, c3, c4, t;
143142
144         if (state->flip_screen())
143         if (flip_screen())
145144         {
146145            sx = 480 - sx;
147146            sy = 224 - sy;
r20977r20978
166165         }
167166
168167         drawgfx_transpen(bitmap,
169               cliprect, machine.gfx[2],
168               cliprect, machine().gfx[2],
170169               sf_invert(c1),
171170               color,
172171               flipx,flipy,
173172               sx,sy, 15);
174173         drawgfx_transpen(bitmap,
175               cliprect, machine.gfx[2],
174               cliprect, machine().gfx[2],
176175               sf_invert(c2),
177176               color,
178177               flipx,flipy,
179178               sx+16,sy, 15);
180179         drawgfx_transpen(bitmap,
181               cliprect, machine.gfx[2],
180               cliprect, machine().gfx[2],
182181               sf_invert(c3),
183182               color,
184183               flipx,flipy,
185184               sx,sy+16, 15);
186185         drawgfx_transpen(bitmap,
187               cliprect, machine.gfx[2],
186               cliprect, machine().gfx[2],
188187               sf_invert(c4),
189188               color,
190189               flipx,flipy,
r20977r20978
192191      }
193192      else
194193      {
195         if (state->flip_screen())
194         if (flip_screen())
196195         {
197196            sx = 496 - sx;
198197            sy = 240 - sy;
r20977r20978
201200         }
202201
203202         drawgfx_transpen(bitmap,
204               cliprect, machine.gfx[2],
203               cliprect, machine().gfx[2],
205204               sf_invert(c),
206205               color,
207206               flipx,flipy,
r20977r20978
221220   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
222221
223222   if (m_sf_active & 0x80)
224      draw_sprites(machine(), bitmap, cliprect);
223      draw_sprites(bitmap, cliprect);
225224
226225   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
227226   return 0;
trunk/src/mame/video/stlforce.c
r20977r20978
8787
8888/* sprites - quite a bit still needs doing .. */
8989
90static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
90void stlforce_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
9191{
92   stlforce_state *state = machine.driver_data<stlforce_state>();
93   const UINT16 *source = state->m_spriteram+0x0;
94   const UINT16 *finish = state->m_spriteram+0x800;
95   gfx_element *gfx = machine.gfx[2];
92   const UINT16 *source = m_spriteram+0x0;
93   const UINT16 *finish = m_spriteram+0x800;
94   gfx_element *gfx = machine().gfx[2];
9695   int ypos, xpos, attr, num;
9796
9897   while (source<finish)
r20977r20978
112111                  num,
113112                  64+attr,
114113                  0,0,
115                  xpos+state->m_sprxoffs,ypos,0 );
114                  xpos+m_sprxoffs,ypos,0 );
116115      }
117116
118117      source += 0x4;
r20977r20978
166165   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
167166   m_mlow_tilemap->draw(bitmap, cliprect, 0,0);
168167   m_mhigh_tilemap->draw(bitmap, cliprect, 0,0);
169   draw_sprites(machine(), bitmap,cliprect);
168   draw_sprites(bitmap,cliprect);
170169   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
171170   return 0;
172171}
trunk/src/mame/video/srumbler.c
r20977r20978
106106
107107***************************************************************************/
108108
109static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
109void srumbler_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
110110{
111   srumbler_state *state = machine.driver_data<srumbler_state>();
112   UINT8 *buffered_spriteram = state->m_spriteram->buffer();
111   UINT8 *buffered_spriteram = m_spriteram->buffer();
113112   int offs;
114113
115114   /* Draw the sprites. */
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      /* SPRITES
119118      =====
r20977r20978
138137      sx = buffered_spriteram[offs + 3] + 0x100 * ( attr & 0x01);
139138      flipy = attr & 0x02;
140139
141      if (state->flip_screen())
140      if (flip_screen())
142141      {
143142         sx = 496 - sx;
144143         sy = 240 - sy;
145144         flipy = !flipy;
146145      }
147146
148      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
147      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
149148            code,
150149            colour,
151            state->flip_screen(),flipy,
150            flip_screen(),flipy,
152151            sx, sy,15);
153152   }
154153}
r20977r20978
157156UINT32 srumbler_state::screen_update_srumbler(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
158157{
159158   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0);
160   draw_sprites(machine(), bitmap,cliprect);
159   draw_sprites(bitmap,cliprect);
161160   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0);
162161   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
163162   return 0;
trunk/src/mame/video/system1.c
r20977r20978
114114 *
115115 *************************************/
116116
117static void video_start_common(running_machine &machine, int pagecount)
117void system1_state::video_start_common(int pagecount)
118118{
119   system1_state *state = machine.driver_data<system1_state>();
120119   int pagenum;
121120
122121   /* allocate memory for the collision arrays */
123   state->m_mix_collide = auto_alloc_array_clear(machine, UINT8, 64);
124   state->m_sprite_collide = auto_alloc_array_clear(machine, UINT8, 1024);
122   m_mix_collide = auto_alloc_array_clear(machine(), UINT8, 64);
123   m_sprite_collide = auto_alloc_array_clear(machine(), UINT8, 1024);
125124
126125   /* allocate memory for videoram */
127   state->m_tilemap_pages = pagecount;
128   state->m_videoram = auto_alloc_array_clear(machine, UINT8, 0x800 * pagecount);
126   m_tilemap_pages = pagecount;
127   m_videoram = auto_alloc_array_clear(machine(), UINT8, 0x800 * pagecount);
129128
130129   /* create the tilemap pages */
131130   for (pagenum = 0; pagenum < pagecount; pagenum++)
132131   {
133      state->m_tilemap_page[pagenum] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(system1_state::tile_get_info),state), TILEMAP_SCAN_ROWS, 8,8, 32,32);
134      state->m_tilemap_page[pagenum]->set_transparent_pen(0);
135      state->m_tilemap_page[pagenum]->set_user_data(state->m_videoram + 0x800 * pagenum);
132      m_tilemap_page[pagenum] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(system1_state::tile_get_info),this), TILEMAP_SCAN_ROWS, 8,8, 32,32);
133      m_tilemap_page[pagenum]->set_transparent_pen(0);
134      m_tilemap_page[pagenum]->set_user_data(m_videoram + 0x800 * pagenum);
136135   }
137136
138137   /* allocate a temporary bitmap for sprite rendering */
139   state->m_sprite_bitmap = auto_bitmap_ind16_alloc(machine, 512, 256);
138   m_sprite_bitmap = auto_bitmap_ind16_alloc(machine(), 512, 256);
140139
141140   /* register for save stats */
142   state_save_register_global(machine, state->m_video_mode);
143   state_save_register_global(machine, state->m_mix_collide_summary);
144   state_save_register_global(machine, state->m_sprite_collide_summary);
145   state->save_pointer(NAME(state->m_videoram), 0x800 * pagecount);
146   state_save_register_global_pointer(machine, state->m_mix_collide, 64);
147   state_save_register_global_pointer(machine, state->m_sprite_collide, 1024);
141   state_save_register_global(machine(), m_video_mode);
142   state_save_register_global(machine(), m_mix_collide_summary);
143   state_save_register_global(machine(), m_sprite_collide_summary);
144   save_pointer(NAME(m_videoram), 0x800 * pagecount);
145   state_save_register_global_pointer(machine(), m_mix_collide, 64);
146   state_save_register_global_pointer(machine(), m_sprite_collide, 1024);
148147}
149148
150149
151150void system1_state::video_start()
152151{
153   video_start_common(machine(), 2);
152   video_start_common(2);
154153}
155154
156155
157156VIDEO_START_MEMBER(system1_state,system2)
158157{
159   video_start_common(machine(), 8);
158   video_start_common(8);
160159}
161160
162161
r20977r20978
238237 *
239238 *************************************/
240239
241INLINE void videoram_wait_states(cpu_device *cpu)
240inline void system1_state::videoram_wait_states(cpu_device *cpu)
242241{
243242   /* The main Z80's CPU clock is halted whenever an access to VRAM happens,
244243      and is only restarted by the FIXST signal, which occurs once every
r20977r20978
359358 *
360359 *************************************/
361360
362static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffset)
361void system1_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffset)
363362{
364   system1_state *state = machine.driver_data<system1_state>();
365   UINT32 gfxbanks = state->memregion("sprites")->bytes() / 0x8000;
366   const UINT8 *gfxbase = state->memregion("sprites")->base();
367   UINT8 *spriteram = state->m_spriteram;
368   int flipscreen = state->flip_screen();
363   UINT32 gfxbanks = memregion("sprites")->bytes() / 0x8000;
364   const UINT8 *gfxbase = memregion("sprites")->base();
365   UINT8 *spriteram = m_spriteram;
366   int flipscreen = flip_screen();
369367   int spritenum;
370368
371369   /* up to 32 sprites total */
r20977r20978
450448                     int prevpix = destbase[effx];
451449
452450                     if ((prevpix & 0x0f) != 0)
453                        state->m_sprite_collide[((prevpix >> 4) & 0x1f) + 32 * spritenum] = state->m_sprite_collide_summary = 1;
451                        m_sprite_collide[((prevpix >> 4) & 0x1f) + 32 * spritenum] = m_sprite_collide_summary = 1;
454452                     destbase[effx] = color1 | palettebase;
455453                  }
456454               }
r20977r20978
471469                     int prevpix = destbase[effx];
472470
473471                     if ((prevpix & 0x0f) != 0)
474                        state->m_sprite_collide[((prevpix >> 4) & 0x1f) + 32 * spritenum] = state->m_sprite_collide_summary = 1;
472                        m_sprite_collide[((prevpix >> 4) & 0x1f) + 32 * spritenum] = m_sprite_collide_summary = 1;
475473                     destbase[effx] = color2 | palettebase;
476474                  }
477475               }
r20977r20978
489487 *
490488 *************************************/
491489
492static void video_update_common(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind16 &fgpixmap, bitmap_ind16 **bgpixmaps, const int *bgrowscroll, int bgyscroll, int spritexoffs)
490void system1_state::video_update_common(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind16 &fgpixmap, bitmap_ind16 **bgpixmaps, const int *bgrowscroll, int bgyscroll, int spritexoffs)
493491{
494   system1_state *state = screen.machine().driver_data<system1_state>();
495   const UINT8 *lookup = state->memregion("proms")->base();
492   const UINT8 *lookup = memregion("proms")->base();
496493   int x, y;
497494
498495   /* first clear the sprite bitmap and draw sprites within this area */
499   state->m_sprite_bitmap->fill(0, cliprect);
500   draw_sprites(screen.machine(), *state->m_sprite_bitmap, cliprect, spritexoffs);
496   m_sprite_bitmap->fill(0, cliprect);
497   draw_sprites(*m_sprite_bitmap, cliprect, spritexoffs);
501498
502499   /* iterate over rows */
503500   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
504501   {
505502      UINT16 *fgbase = &fgpixmap.pix16(y & 0xff);
506      UINT16 *sprbase = &state->m_sprite_bitmap->pix16(y & 0xff);
503      UINT16 *sprbase = &m_sprite_bitmap->pix16(y & 0xff);
507504      UINT16 *dstbase = &bitmap.pix16(y);
508505      int bgy = (y + bgyscroll) & 0x1ff;
509506      int bgxscroll = bgrowscroll[y >> 3 & 0x1f];
r20977r20978
533530
534531         /* compute collisions based on two of the PROM bits */
535532         if (!(lookup_value & 4))
536            state->m_mix_collide[((lookup_value & 8) << 2) | ((sprpix >> 4) & 0x1f)] = state->m_mix_collide_summary = 1;
533            m_mix_collide[((lookup_value & 8) << 2) | ((sprpix >> 4) & 0x1f)] = m_mix_collide_summary = 1;
537534
538535         /* the lower 2 PROM bits select the palette and which pixels */
539536         lookup_value &= 3;
540         if (state->m_video_mode & 0x10)
537         if (m_video_mode & 0x10)
541538            dstbase[x] = 0;
542539         else if (lookup_value == 0)
543540            dstbase[x] = 0x000 | (sprpix & 0x1ff);
trunk/src/mame/video/silkroad.c
r20977r20978
77/* Clean Up */
88/* is theres a bg colour register? */
99
10static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
10void silkroad_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
1111{
12   silkroad_state *state = machine.driver_data<silkroad_state>();
13   gfx_element *gfx = machine.gfx[0];
14   UINT32 *source = state->m_sprram;
12   gfx_element *gfx = machine().gfx[0];
13   UINT32 *source = m_sprram;
1514   UINT32 *finish = source + 0x1000/4;
1615
1716   while( source < finish )
r20977r20978
3736      {
3837         for (wcount=0;wcount<width;wcount++)
3938         {
40            pdrawgfx_transpen(bitmap,cliprect,gfx,tileno+wcount,color,0,0,xpos+wcount*16+8,ypos,machine.priority_bitmap,pri_mask,0);
39            pdrawgfx_transpen(bitmap,cliprect,gfx,tileno+wcount,color,0,0,xpos+wcount*16+8,ypos,machine().priority_bitmap,pri_mask,0);
4140         }
4241      }
4342      else
4443      {
4544         for (wcount=width;wcount>0;wcount--)
4645         {
47            pdrawgfx_transpen(bitmap,cliprect,gfx,tileno+(width-wcount),color,1,0,xpos+wcount*16-16+8,ypos,machine.priority_bitmap,pri_mask,0);
46            pdrawgfx_transpen(bitmap,cliprect,gfx,tileno+(width-wcount),color,1,0,xpos+wcount*16-16+8,ypos,machine().priority_bitmap,pri_mask,0);
4847         }
4948      }
5049
r20977r20978
146145   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
147146   m_fg2_tilemap->draw(bitmap, cliprect, 0,1);
148147   m_fg3_tilemap->draw(bitmap, cliprect, 0,2);
149   draw_sprites(machine(),bitmap,cliprect);
148   draw_sprites(bitmap,cliprect);
150149
151150   if (0)
152151   {
trunk/src/mame/video/suna16.c
r20977r20978
115115
116116***************************************************************************/
117117
118static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 *sprites, int gfx)
118void suna16_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 *sprites, int gfx)
119119{
120   suna16_state *state = machine.driver_data<suna16_state>();
121120   int offs;
122   int max_x = machine.primary_screen->width() - 8;
123   int max_y = machine.primary_screen->height() - 8;
121   int max_x = machine().primary_screen->width() - 8;
122   int max_y = machine().primary_screen->height() - 8;
124123
125124   for ( offs = 0xfc00/2; offs < 0x10000/2 ; offs += 4/2 )
126125   {
r20977r20978
181180
182181            if (flipx)  tile_flipx = !tile_flipx;
183182
184            if (state->flip_screen())
183            if (flip_screen())
185184            {
186185               sx = max_x - sx;
187186               sy = max_y - sy;
r20977r20978
189188               tile_flipy = !tile_flipy;
190189            }
191190
192            drawgfx_transpen(   bitmap, cliprect,machine.gfx[gfx],
191            drawgfx_transpen(   bitmap, cliprect,machine().gfx[gfx],
193192                     (tile & 0x3fff) + bank*0x4000,
194                     attr + (state->m_color_bank << 4),
193                     attr + (m_color_bank << 4),
195194                     tile_flipx, tile_flipy,
196195                     sx, sy,15   );
197196
r20977r20978
218217{
219218   /* Suna Quiz indicates the background is the last pen */
220219   bitmap.fill(0xff, cliprect);
221   draw_sprites(machine(), bitmap, cliprect, m_spriteram, 0);
220   draw_sprites(bitmap, cliprect, m_spriteram, 0);
222221   return 0;
223222}
224223
r20977r20978
237236
238237   /* Suna Quiz indicates the background is the last pen */
239238   bitmap.fill(0xff, cliprect);
240   if (layers_ctrl & 1)    draw_sprites(machine(), bitmap, cliprect, m_spriteram,  0);
241   if (layers_ctrl & 2)    draw_sprites(machine(), bitmap, cliprect, m_spriteram2, 1);
239   if (layers_ctrl & 1)    draw_sprites(bitmap, cliprect, m_spriteram,  0);
240   if (layers_ctrl & 2)    draw_sprites(bitmap, cliprect, m_spriteram2, 1);
242241   return 0;
243242}
trunk/src/mame/video/sspeedr.c
r20977r20978
8080}
8181
8282
83static void draw_track(running_machine &machine, bitmap_ind16 &bitmap)
83void sspeedr_state::draw_track(bitmap_ind16 &bitmap)
8484{
85   sspeedr_state *state = machine.driver_data<sspeedr_state>();
86   const UINT8* p = state->memregion("gfx3")->base();
85   const UINT8* p = memregion("gfx3")->base();
8786
8887   int x;
8988   int y;
9089
9190   for (x = 0; x < 376; x++)
9291   {
93      unsigned counter_x = x + state->m_track_horz + 0x50;
92      unsigned counter_x = x + m_track_horz + 0x50;
9493
9594      int flag = 0;
9695
97      if (state->m_track_ice & 2)
96      if (m_track_ice & 2)
9897      {
9998         flag = 1;
10099      }
101      else if (state->m_track_ice & 4)
100      else if (m_track_ice & 4)
102101      {
103         if (state->m_track_ice & 1)
102         if (m_track_ice & 1)
104103         {
105104            flag = (counter_x <= 0x1ff);
106105         }
r20977r20978
119118
120119      /* upper landscape */
121120
122      for (; y < state->m_track_vert[0]; y++)
121      for (; y < m_track_vert[0]; y++)
123122      {
124         unsigned counter_y = y - state->m_track_vert[0];
123         unsigned counter_y = y - m_track_vert[0];
125124
126125         int offset =
127126            ((counter_y & 0x1f) << 3) |
r20977r20978
140139
141140      /* street */
142141
143      for (; y < 128 + state->m_track_vert[1]; y++)
142      for (; y < 128 + m_track_vert[1]; y++)
144143      {
145144         bitmap.pix16(y, x) = flag ? 15 : 0;
146145      }
r20977r20978
149148
150149      for (; y < 248; y++)
151150      {
152         unsigned counter_y = y - state->m_track_vert[1];
151         unsigned counter_y = y - m_track_vert[1];
153152
154153         int offset =
155154            ((counter_y & 0x1f) << 3) |
r20977r20978
169168}
170169
171170
172static void draw_drones(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
171void sspeedr_state::draw_drones(bitmap_ind16 &bitmap, const rectangle &cliprect)
173172{
174   sspeedr_state *state = machine.driver_data<sspeedr_state>();
175173   static const UINT8 code[6] =
176174   {
177175      0xf, 0x4, 0x3, 0x9, 0x7, 0xc
r20977r20978
184182      int x;
185183      int y;
186184
187      if ((state->m_drones_mask >> i) & 1)
185      if ((m_drones_mask >> i) & 1)
188186      {
189187         continue;
190188      }
191189
192      x = (code[i] << 5) - state->m_drones_horz - 0x50;
190      x = (code[i] << 5) - m_drones_horz - 0x50;
193191
194192      if (x <= -32)
195193      {
196194         x += 0x1c8;
197195      }
198196
199      y = 0xf0 - state->m_drones_vert[i >> 1];
197      y = 0xf0 - m_drones_vert[i >> 1];
200198
201199      drawgfx_transpen(bitmap, cliprect,
202         machine.gfx[1],
203         code[i] ^ state->m_toggle,
200         machine().gfx[1],
201         code[i] ^ m_toggle,
204202         0,
205203         0, 0,
206204         x,
r20977r20978
209207}
210208
211209
212static void draw_driver(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
210void sspeedr_state::draw_driver(bitmap_ind16 &bitmap, const rectangle &cliprect)
213211{
214   sspeedr_state *state = machine.driver_data<sspeedr_state>();
215212   int x;
216213   int y;
217214
218   if (!(state->m_driver_pic & 0x10))
215   if (!(m_driver_pic & 0x10))
219216   {
220217      return;
221218   }
222219
223   x = 0x1e0 - state->m_driver_horz - 0x50;
220   x = 0x1e0 - m_driver_horz - 0x50;
224221
225222   if (x <= -32)
226223   {
227224      x += 0x1c8;
228225   }
229226
230   y = 0xf0 - state->m_driver_vert;
227   y = 0xf0 - m_driver_vert;
231228
232229   drawgfx_transpen(bitmap, cliprect,
233      machine.gfx[0],
234      state->m_driver_pic,
230      machine().gfx[0],
231      m_driver_pic,
235232      0,
236233      0, 0,
237234      x,
r20977r20978
247244
248245UINT32 sspeedr_state::screen_update_sspeedr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
249246{
250   draw_track(machine(), bitmap);
251   draw_drones(machine(), bitmap, cliprect);
252   draw_driver(machine(), bitmap, cliprect);
247   draw_track(bitmap);
248   draw_drones(bitmap, cliprect);
249   draw_driver(bitmap, cliprect);
253250   return 0;
254251}
255252
trunk/src/mame/video/scotrsht.c
r20977r20978
9191}
9292
9393/* Same as Jailbreak + palette bank */
94static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
94void scotrsht_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
9595{
96   scotrsht_state *state = machine.driver_data<scotrsht_state>();
97   UINT8 *spriteram = state->m_spriteram;
96   UINT8 *spriteram = m_spriteram;
9897   int i;
9998
100   for (i = 0; i < state->m_spriteram.bytes(); i += 4)
99   for (i = 0; i < m_spriteram.bytes(); i += 4)
101100   {
102101      int attr = spriteram[i + 1];    // attributes = ?tyxcccc
103102      int code = spriteram[i] + ((attr & 0x40) << 2);
104      int color = (attr & 0x0f) + state->m_palette_bank * 16;
103      int color = (attr & 0x0f) + m_palette_bank * 16;
105104      int flipx = attr & 0x10;
106105      int flipy = attr & 0x20;
107106      int sx = spriteram[i + 2] - ((attr & 0x80) << 1);
108107      int sy = spriteram[i + 3];
109108
110      if (state->flip_screen())
109      if (flip_screen())
111110      {
112111         sx = 240 - sx;
113112         sy = 240 - sy;
r20977r20978
115114         flipy = !flipy;
116115      }
117116
118      drawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy,
117      drawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy,
119118         sx, sy,
120         colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, state->m_palette_bank * 16));
119         colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, m_palette_bank * 16));
121120   }
122121}
123122
r20977r20978
136135      m_bg_tilemap->set_scrolly(col, m_scroll[col]);
137136
138137   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
139   draw_sprites(machine(), bitmap, cliprect);
138   draw_sprites(bitmap, cliprect);
140139   return 0;
141140}
trunk/src/mame/video/superqix.c
r20977r20978
156156
157157***************************************************************************/
158158
159static void pbillian_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
159void superqix_state::pbillian_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
160160{
161   superqix_state *state = machine.driver_data<superqix_state>();
162   UINT8 *spriteram = state->m_spriteram;
161   UINT8 *spriteram = m_spriteram;
163162   int offs;
164163
165   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
164   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
166165   {
167166      int attr = spriteram[offs + 3];
168167      int code = ((spriteram[offs] & 0xfc) >> 2) + 64 * (attr & 0x0f);
r20977r20978
170169      int sx = spriteram[offs + 1] + 256 * (spriteram[offs] & 0x01);
171170      int sy = spriteram[offs + 2];
172171
173      if (state->flip_screen())
172      if (flip_screen())
174173      {
175174         sx = 240 - sx;
176175         sy = 240 - sy;
177176      }
178177
179      drawgfx_transpen(bitmap,cliprect, machine.gfx[1],
178      drawgfx_transpen(bitmap,cliprect, machine().gfx[1],
180179            code,
181180            color,
182            state->flip_screen(), state->flip_screen(),
181            flip_screen(), flip_screen(),
183182            sx, sy, 0);
184183   }
185184}
186185
187static void superqix_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
186void superqix_state::superqix_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
188187{
189   superqix_state *state = machine.driver_data<superqix_state>();
190   UINT8 *spriteram = state->m_spriteram;
188   UINT8 *spriteram = m_spriteram;
191189   int offs;
192190
193   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
191   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
194192   {
195193      int attr = spriteram[offs + 3];
196194      int code = spriteram[offs] + 256 * (attr & 0x01);
r20977r20978
200198      int sx = spriteram[offs + 1];
201199      int sy = spriteram[offs + 2];
202200
203      if (state->flip_screen())
201      if (flip_screen())
204202      {
205203         sx = 240 - sx;
206204         sy = 240 - sy;
r20977r20978
208206         flipy = !flipy;
209207      }
210208
211      drawgfx_transpen(bitmap,cliprect, machine.gfx[2],
209      drawgfx_transpen(bitmap,cliprect, machine().gfx[2],
212210            code,
213211            color,
214212            flipx, flipy,
r20977r20978
219217UINT32 superqix_state::screen_update_pbillian(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
220218{
221219   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
222   pbillian_draw_sprites(machine(), bitmap,cliprect);
220   pbillian_draw_sprites(bitmap,cliprect);
223221
224222   return 0;
225223}
r20977r20978
228226{
229227   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
230228   copybitmap_trans(bitmap,*m_fg_bitmap[m_show_bitmap],flip_screen(),flip_screen(),0,0,cliprect,0);
231   superqix_draw_sprites(machine(), bitmap,cliprect);
229   superqix_draw_sprites(bitmap,cliprect);
232230   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
233231   return 0;
234232}
trunk/src/mame/video/slapfght.c
r20977r20978
122122   m_slapfight_palette_bank = offset;
123123}
124124
125static void slapfght_log_vram(running_machine &machine)
125void slapfght_state::slapfght_log_vram()
126126{
127127#ifdef MAME_DEBUG
128   slapfght_state *state = machine.driver_data<slapfght_state>();
129   if ( machine.input().code_pressed_once(KEYCODE_B) )
128   if ( machine().input().code_pressed_once(KEYCODE_B) )
130129   {
131130      int i;
132131      for (i=0; i<0x800; i++)
133132      {
134         logerror("Offset:%03x   TileRAM:%02x   AttribRAM:%02x   SpriteRAM:%02x\n",i, state->m_slapfight_videoram[i],state->m_slapfight_colorram[i],state->m_spriteram->live()[i]);
133         logerror("Offset:%03x   TileRAM:%02x   AttribRAM:%02x   SpriteRAM:%02x\n",i, m_slapfight_videoram[i],m_slapfight_colorram[i],m_spriteram->live()[i]);
135134      }
136135   }
137136#endif
r20977r20978
142141  Render the Sprites
143142
144143***************************************************************************/
145static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority_to_display )
144void slapfght_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority_to_display )
146145{
147   slapfght_state *state = machine.driver_data<slapfght_state>();
148   UINT8 *buffered_spriteram = state->m_spriteram->buffer();
146   UINT8 *buffered_spriteram = m_spriteram->buffer();
149147   int offs;
150148
151   for (offs = 0;offs < state->m_spriteram->bytes();offs += 4)
149   for (offs = 0;offs < m_spriteram->bytes();offs += 4)
152150   {
153151      int sx, sy;
154152
155153      if ((buffered_spriteram[offs+2] & 0x80) == priority_to_display)
156154      {
157         if (state->m_flipscreen)
155         if (m_flipscreen)
158156         {
159157            sx = 265 - buffered_spriteram[offs+1];
160158            sy = 239 - buffered_spriteram[offs+3];
r20977r20978
165163            sx = buffered_spriteram[offs+1] + 3;
166164            sy = buffered_spriteram[offs+3] - 1;
167165         }
168         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
166         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
169167            buffered_spriteram[offs],
170168            ((buffered_spriteram[offs+2] >> 1) & 3) |
171               ((buffered_spriteram[offs+2] << 2) & 4) | (state->m_slapfight_palette_bank << 3),
172            state->m_flipscreen, state->m_flipscreen,
169               ((buffered_spriteram[offs+2] << 2) & 4) | (m_slapfight_palette_bank << 3),
170            m_flipscreen, m_flipscreen,
173171            sx, sy,0);
174172      }
175173   }
r20977r20978
188186   }
189187
190188   m_pf1_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
191   draw_sprites(machine(), bitmap,cliprect,0);
189   draw_sprites(bitmap,cliprect,0);
192190   m_pf1_tilemap->draw(bitmap, cliprect, 0,0);
193   draw_sprites(machine(), bitmap,cliprect,0x80);
191   draw_sprites(bitmap,cliprect,0x80);
194192
195   slapfght_log_vram(machine());
193   slapfght_log_vram();
196194   return 0;
197195}
198196
r20977r20978
237235
238236   m_fix_tilemap->draw(bitmap, cliprect, 0,0);
239237
240   slapfght_log_vram(machine());
238   slapfght_log_vram();
241239   return 0;
242240}
trunk/src/mame/video/skyraid.c
r20977r20978
1414}
1515
1616
17static void draw_text(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
17void skyraid_state::draw_text(bitmap_ind16 &bitmap, const rectangle &cliprect)
1818{
19   skyraid_state *state = machine.driver_data<skyraid_state>();
20   const UINT8* p = state->m_alpha_num_ram;
19   const UINT8* p = m_alpha_num_ram;
2120
2221   int i;
2322
r20977r20978
2928      y = 136 + 16 * (i ^ 1);
3029
3130      for (x = 0; x < bitmap.width(); x += 16)
32         drawgfx_transpen(bitmap, cliprect, machine.gfx[0], *p++, 0, 0, 0,   x, y, 0);
31         drawgfx_transpen(bitmap, cliprect, machine().gfx[0], *p++, 0, 0, 0,   x, y, 0);
3332   }
3433}
3534
3635
37static void draw_terrain(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
36void skyraid_state::draw_terrain(bitmap_ind16 &bitmap, const rectangle &cliprect)
3837{
39   skyraid_state *state = machine.driver_data<skyraid_state>();
40   const UINT8* p = state->memregion("user1")->base();
38   const UINT8* p = memregion("user1")->base();
4139
4240   int x;
4341   int y;
4442
4543   for (y = 0; y < bitmap.height(); y++)
4644   {
47      int offset = (16 * state->m_scroll + 16 * ((y + 1) / 2)) & 0x7FF;
45      int offset = (16 * m_scroll + 16 * ((y + 1) / 2)) & 0x7FF;
4846
4947      x = 0;
5048
r20977r20978
6563}
6664
6765
68static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
66void skyraid_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
6967{
70   skyraid_state *state = machine.driver_data<skyraid_state>();
7168   int i;
7269
7370   for (i = 0; i < 4; i++)
7471   {
75      int code = state->m_obj_ram[8 + 2 * i + 0] & 15;
76      int flag = state->m_obj_ram[8 + 2 * i + 1] & 15;
77      int vert = state->m_pos_ram[8 + 2 * i + 0];
78      int horz = state->m_pos_ram[8 + 2 * i + 1];
72      int code = m_obj_ram[8 + 2 * i + 0] & 15;
73      int flag = m_obj_ram[8 + 2 * i + 1] & 15;
74      int vert = m_pos_ram[8 + 2 * i + 0];
75      int horz = m_pos_ram[8 + 2 * i + 1];
7976
8077      vert -= 31;
8178
8279      if (flag & 1)
83         drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
80         drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
8481            code ^ 15, code >> 3, 0, 0,
8582            horz / 2, vert, 2);
8683   }
8784}
8885
8986
90static void draw_missiles(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
87void skyraid_state::draw_missiles(bitmap_ind16 &bitmap, const rectangle &cliprect)
9188{
92   skyraid_state *state = machine.driver_data<skyraid_state>();
9389   int i;
9490
9591   /* hardware is restricted to one sprite per scanline */
9692
9793   for (i = 0; i < 4; i++)
9894   {
99      int code = state->m_obj_ram[2 * i + 0] & 15;
100      int vert = state->m_pos_ram[2 * i + 0];
101      int horz = state->m_pos_ram[2 * i + 1];
95      int code = m_obj_ram[2 * i + 0] & 15;
96      int vert = m_pos_ram[2 * i + 0];
97      int horz = m_pos_ram[2 * i + 1];
10298
10399      vert -= 15;
104100      horz -= 31;
105101
106      drawgfx_transpen(bitmap, cliprect, machine.gfx[2],
102      drawgfx_transpen(bitmap, cliprect, machine().gfx[2],
107103         code ^ 15, 0, 0, 0,
108104         horz / 2, vert, 0);
109105   }
110106}
111107
112108
113static void draw_trapezoid(running_machine &machine, bitmap_ind16& dst, bitmap_ind16& src)
109void skyraid_state::draw_trapezoid(bitmap_ind16& dst, bitmap_ind16& src)
114110{
115   const UINT8* p = machine.root_device().memregion("user2")->base();
111   const UINT8* p = machine().root_device().memregion("user2")->base();
116112
117113   int x;
118114   int y;
r20977r20978
138134   rectangle helper_clip = cliprect;
139135   helper_clip &= m_helper.cliprect();
140136
141   draw_terrain(machine(), m_helper, helper_clip);
142   draw_sprites(machine(), m_helper, helper_clip);
143   draw_missiles(machine(), m_helper, helper_clip);
144   draw_trapezoid(machine(), bitmap, m_helper);
145   draw_text(machine(), bitmap, cliprect);
137   draw_terrain(m_helper, helper_clip);
138   draw_sprites(m_helper, helper_clip);
139   draw_missiles(m_helper, helper_clip);
140   draw_trapezoid(bitmap, m_helper);
141   draw_text(bitmap, cliprect);
146142   return 0;
147143}
trunk/src/mame/video/sprcros2.c
r20977r20978
135135   colortable_configure_tilemap_groups(machine().colortable, m_fgtilemap, machine().gfx[2], 0);
136136}
137137
138static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
138void sprcros2_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
139139{
140   sprcros2_state *state = machine.driver_data<sprcros2_state>();
141140   int offs,sx,sy,color,flipx,flipy;
142141
143   for (offs = state->m_spriteram.bytes()-4; offs >= 0; offs -= 4)
142   for (offs = m_spriteram.bytes()-4; offs >= 0; offs -= 4)
144143   {
145      if (state->m_spriteram[offs])
144      if (m_spriteram[offs])
146145      {
147146         //offs
148147         //76543210
r20977r20978
158157         //offs+2   y pos
159158         //offs+3   x pos
160159
161         sx = ((state->m_spriteram[offs+3]+0x10)%0x100)-0x10;
162         sy = 225-(((state->m_spriteram[offs+2]+0x10)%0x100)-0x10);
163         color = (state->m_spriteram[offs+1]&0x38)>>3;
164         flipx = state->m_spriteram[offs+1]&0x02;
160         sx = ((m_spriteram[offs+3]+0x10)%0x100)-0x10;
161         sy = 225-(((m_spriteram[offs+2]+0x10)%0x100)-0x10);
162         color = (m_spriteram[offs+1]&0x38)>>3;
163         flipx = m_spriteram[offs+1]&0x02;
165164         flipy = 0;
166165
167         if (state->m_port7&0x02)
166         if (m_port7&0x02)
168167         {
169168            sx = 224-sx;
170169            sy = 224-sy;
r20977r20978
172171            flipy = !flipy;
173172         }
174173
175         drawgfx_transmask(bitmap,cliprect,machine.gfx[1],
176            state->m_spriteram[offs],
174         drawgfx_transmask(bitmap,cliprect,machine().gfx[1],
175            m_spriteram[offs],
177176            color,
178177            flipx,flipy,
179178            sx,sy,
180            colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 0));
179            colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 0));
181180      }
182181   }
183182}
r20977r20978
185184UINT32 sprcros2_state::screen_update_sprcros2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
186185{
187186   m_bgtilemap->draw(bitmap, cliprect, 0, 0);
188   draw_sprites(machine(), bitmap, cliprect);
187   draw_sprites(bitmap, cliprect);
189188   m_fgtilemap->draw(bitmap, cliprect, 0, 0);
190189   return 0;
191190}
trunk/src/mame/video/starshp1.c
r20977r20978
88#include "includes/starshp1.h"
99
1010
11static void set_pens(starshp1_state *state, colortable_t *colortable)
11void starshp1_state::set_pens(colortable_t *colortable)
1212{
13   colortable_palette_set_color(colortable, state->m_inverse ? 7 : 0, MAKE_RGB(0x00, 0x00, 0x00));
14   colortable_palette_set_color(colortable, state->m_inverse ? 6 : 1, MAKE_RGB(0x1e, 0x1e, 0x1e));
15   colortable_palette_set_color(colortable, state->m_inverse ? 5 : 2, MAKE_RGB(0x4e, 0x4e, 0x4e));
16   colortable_palette_set_color(colortable, state->m_inverse ? 4 : 3, MAKE_RGB(0x6c, 0x6c, 0x6c));
17   colortable_palette_set_color(colortable, state->m_inverse ? 3 : 4, MAKE_RGB(0x93, 0x93, 0x93));
18   colortable_palette_set_color(colortable, state->m_inverse ? 2 : 5, MAKE_RGB(0xb1, 0xb1, 0xb1));
19   colortable_palette_set_color(colortable, state->m_inverse ? 1 : 6, MAKE_RGB(0xe1, 0xe1, 0xe1));
20   colortable_palette_set_color(colortable, state->m_inverse ? 0 : 7, MAKE_RGB(0xff, 0xff, 0xff));
13   colortable_palette_set_color(colortable, m_inverse ? 7 : 0, MAKE_RGB(0x00, 0x00, 0x00));
14   colortable_palette_set_color(colortable, m_inverse ? 6 : 1, MAKE_RGB(0x1e, 0x1e, 0x1e));
15   colortable_palette_set_color(colortable, m_inverse ? 5 : 2, MAKE_RGB(0x4e, 0x4e, 0x4e));
16   colortable_palette_set_color(colortable, m_inverse ? 4 : 3, MAKE_RGB(0x6c, 0x6c, 0x6c));
17   colortable_palette_set_color(colortable, m_inverse ? 3 : 4, MAKE_RGB(0x93, 0x93, 0x93));
18   colortable_palette_set_color(colortable, m_inverse ? 2 : 5, MAKE_RGB(0xb1, 0xb1, 0xb1));
19   colortable_palette_set_color(colortable, m_inverse ? 1 : 6, MAKE_RGB(0xe1, 0xe1, 0xe1));
20   colortable_palette_set_color(colortable, m_inverse ? 0 : 7, MAKE_RGB(0xff, 0xff, 0xff));
2121}
2222
2323
r20977r20978
141141}
142142
143143
144static void draw_starfield(starshp1_state *state, bitmap_ind16 &bitmap)
144void starshp1_state::draw_starfield(bitmap_ind16 &bitmap)
145145{
146146   /*
147147    * The LSFR is reset once per frame at the position of
r20977r20978
154154
155155   for (y = 0; y < bitmap.height(); y++)
156156   {
157      const UINT16* p = state->m_LSFR + (UINT16) (512 * y);
157      const UINT16* p = m_LSFR + (UINT16) (512 * y);
158158
159159      UINT16* pLine = &bitmap.pix16(y);
160160
r20977r20978
165165}
166166
167167
168static int get_sprite_hpos(starshp1_state *state, int i)
168int starshp1_state::get_sprite_hpos(int i)
169169{
170   return 2 * (state->m_hpos_ram[i] ^ 0xff);
170   return 2 * (m_hpos_ram[i] ^ 0xff);
171171}
172static int get_sprite_vpos(starshp1_state *state, int i)
172int starshp1_state::get_sprite_vpos(int i)
173173{
174   return 1 * (state->m_vpos_ram[i] - 0x07);
174   return 1 * (m_vpos_ram[i] - 0x07);
175175}
176176
177177
178static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
178void starshp1_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
179179{
180   starshp1_state *state = machine.driver_data<starshp1_state>();
181180   int i;
182181
183182   for (i = 0; i < 14; i++)
184183   {
185      int code = (state->m_obj_ram[i] & 0xf) ^ 0xf;
184      int code = (m_obj_ram[i] & 0xf) ^ 0xf;
186185
187      drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
186      drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
188187         code % 8,
189188         code / 8,
190189         0, 0,
191         get_sprite_hpos(state, i),
192         get_sprite_vpos(state, i), 0);
190         get_sprite_hpos(i),
191         get_sprite_vpos(i), 0);
193192   }
194193}
195194
196195
197static void draw_spaceship(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
196void starshp1_state::draw_spaceship(bitmap_ind16 &bitmap, const rectangle &cliprect)
198197{
199   starshp1_state *state = machine.driver_data<starshp1_state>();
200   double scaler = -5 * log(1 - state->m_ship_size / 256.0); /* ? */
198   double scaler = -5 * log(1 - m_ship_size / 256.0); /* ? */
201199
202200   unsigned xzoom = 2 * 0x10000 * scaler;
203201   unsigned yzoom = 1 * 0x10000 * scaler;
204202
205   int x = get_sprite_hpos(state, 14);
206   int y = get_sprite_vpos(state, 14);
203   int x = get_sprite_hpos(14);
204   int y = get_sprite_vpos(14);
207205
208206   if (x <= 0)
209      x -= (xzoom * state->m_ship_hoffset) >> 16;
207      x -= (xzoom * m_ship_hoffset) >> 16;
210208
211209   if (y <= 0)
212      y -= (yzoom * state->m_ship_voffset) >> 16;
210      y -= (yzoom * m_ship_voffset) >> 16;
213211
214   drawgfxzoom_transpen(bitmap, cliprect, machine.gfx[2],
215      state->m_ship_picture & 0x03,
216      state->m_ship_explode,
217      state->m_ship_picture & 0x80, 0,
212   drawgfxzoom_transpen(bitmap, cliprect, machine().gfx[2],
213      m_ship_picture & 0x03,
214      m_ship_explode,
215      m_ship_picture & 0x80, 0,
218216      x, y,
219217      xzoom, yzoom, 0);
220218}
221219
222220
223static void draw_phasor(starshp1_state *state, bitmap_ind16 &bitmap)
221void starshp1_state::draw_phasor(bitmap_ind16 &bitmap)
224222{
225223   int i;
226224
227225   for (i = 128; i < 240; i++)
228      if (i >= get_sprite_vpos(state, 13))
226      if (i >= get_sprite_vpos(13))
229227      {
230228         bitmap.pix16(i, 2 * i + 0) = 0x10;
231229         bitmap.pix16(i, 2 * i + 1) = 0x10;
r20977r20978
235233}
236234
237235
238static int get_radius(starshp1_state *state)
236int starshp1_state::get_radius()
239237{
240   return 6 * sqrt((double)state->m_circle_size);  /* size calibrated by hand */
238   return 6 * sqrt((double)m_circle_size);  /* size calibrated by hand */
241239}
242static int get_circle_hpos(starshp1_state *state)
240int starshp1_state::get_circle_hpos()
243241{
244   return 2 * (3 * state->m_circle_hpos / 2 - 64);
242   return 2 * (3 * m_circle_hpos / 2 - 64);
245243}
246static int get_circle_vpos(starshp1_state *state)
244int starshp1_state::get_circle_vpos()
247245{
248   return 1 * (3 * state->m_circle_vpos / 2 - 64);
246   return 1 * (3 * m_circle_vpos / 2 - 64);
249247}
250248
251249
252static void draw_circle_line(running_machine &machine, bitmap_ind16 &bitmap, int x, int y, int l)
250void starshp1_state::draw_circle_line(bitmap_ind16 &bitmap, int x, int y, int l)
253251{
254   starshp1_state *state = machine.driver_data<starshp1_state>();
255252   if (y >= 0 && y <= bitmap.height() - 1)
256253   {
257      const UINT16* p = state->m_LSFR + (UINT16) (512 * y);
254      const UINT16* p = m_LSFR + (UINT16) (512 * y);
258255
259256      UINT16* pLine = &bitmap.pix16(y);
260257
r20977r20978
267264         h2 = bitmap.width() - 1;
268265
269266      for (x = h1; x <= h2; x++)
270         if (state->m_circle_mod)
267         if (m_circle_mod)
271268         {
272269            if (p[x] & 1)
273270               pLine[x] = 0x11;
r20977r20978
278275}
279276
280277
281static void draw_circle(running_machine &machine, bitmap_ind16 &bitmap)
278void starshp1_state::draw_circle(bitmap_ind16 &bitmap)
282279{
283   starshp1_state *state = machine.driver_data<starshp1_state>();
284   int cx = get_circle_hpos(state);
285   int cy = get_circle_vpos(state);
280   int cx = get_circle_hpos();
281   int cy = get_circle_vpos();
286282
287283   int x = 0;
288   int y = get_radius(state);
284   int y = get_radius();
289285
290286   /* Bresenham's circle algorithm */
291287
292   int d = 3 - 2 * get_radius(state);
288   int d = 3 - 2 * get_radius();
293289
294290   while (x <= y)
295291   {
296      draw_circle_line(machine, bitmap, cx, cy - x, y);
297      draw_circle_line(machine, bitmap, cx, cy + x, y);
298      draw_circle_line(machine, bitmap, cx, cy - y, x);
299      draw_circle_line(machine, bitmap, cx, cy + y, x);
292      draw_circle_line(bitmap, cx, cy - x, y);
293      draw_circle_line(bitmap, cx, cy + x, y);
294      draw_circle_line(bitmap, cx, cy - y, x);
295      draw_circle_line(bitmap, cx, cy + y, x);
300296
301297      x++;
302298
r20977r20978
308304}
309305
310306
311static int spaceship_collision(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &rect)
307int starshp1_state::spaceship_collision(bitmap_ind16 &bitmap, const rectangle &rect)
312308{
313   starshp1_state *state = machine.driver_data<starshp1_state>();
314309   int x;
315310   int y;
316311
317312   for (y = rect.min_y; y <= rect.max_y; y++)
318313   {
319      const UINT16* pLine = &state->m_helper.pix16(y);
314      const UINT16* pLine = &m_helper.pix16(y);
320315
321316      for (x = rect.min_x; x <= rect.max_x; x++)
322317         if (pLine[x] != 0)
r20977r20978
327322}
328323
329324
330static int point_in_circle(int x, int y, int center_x, int center_y, int r)
325int starshp1_state::point_in_circle(int x, int y, int center_x, int center_y, int r)
331326{
332327   int dx = abs(x - center_x) / 2;
333328   int dy = abs(y - center_y) / 1;
r20977r20978
336331}
337332
338333
339static int circle_collision(starshp1_state *state, const rectangle &rect)
334int starshp1_state::circle_collision(const rectangle &rect)
340335{
341   int center_x = get_circle_hpos(state);
342   int center_y = get_circle_vpos(state);
336   int center_x = get_circle_hpos();
337   int center_y = get_circle_vpos();
343338
344   int r = get_radius(state);
339   int r = get_radius();
345340
346341   return point_in_circle(rect.min_x, rect.min_y, center_x, center_y, r) ||
347342         point_in_circle(rect.min_x, rect.max_y, center_x, center_y, r) ||
r20977r20978
352347
353348UINT32 starshp1_state::screen_update_starshp1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
354349{
355   set_pens(this, machine().colortable);
350   set_pens(machine().colortable);
356351
357352   bitmap.fill(0, cliprect);
358353
359354   if (m_starfield_kill == 0)
360      draw_starfield(this, bitmap);
355      draw_starfield(bitmap);
361356
362   draw_sprites(machine(), bitmap, cliprect);
357   draw_sprites(bitmap, cliprect);
363358
364359   if (m_circle_kill == 0 && m_circle_mod != 0)
365      draw_circle(machine(), bitmap);
360      draw_circle(bitmap);
366361
367362   if (m_attract == 0)
368      draw_spaceship(machine(), bitmap, cliprect);
363      draw_spaceship(bitmap, cliprect);
369364
370365   if (m_circle_kill == 0 && m_circle_mod == 0)
371      draw_circle(machine(), bitmap);
366      draw_circle(bitmap);
372367
373368   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
374369
375370   if (m_phasor != 0)
376      draw_phasor(this, bitmap);
371      draw_phasor(bitmap);
377372
378373   return 0;
379374}
r20977r20978
387382      rectangle rect;
388383      const rectangle &visarea = machine().primary_screen->visible_area();
389384
390      rect.min_x = get_sprite_hpos(this, 13);
391      rect.min_y = get_sprite_vpos(this, 13);
385      rect.min_x = get_sprite_hpos(13);
386      rect.min_y = get_sprite_vpos(13);
392387      rect.max_x = rect.min_x + machine().gfx[1]->width() - 1;
393388      rect.max_y = rect.min_y + machine().gfx[1]->height() - 1;
394389
r20977r20978
397392      m_helper.fill(0, visarea);
398393
399394      if (m_attract == 0)
400         draw_spaceship(machine(), m_helper, visarea);
395         draw_spaceship(m_helper, visarea);
401396
402      if (circle_collision(this, visarea))
397      if (circle_collision(visarea))
403398         m_collision_latch |= 1;
404399
405      if (circle_collision(this, rect))
400      if (circle_collision(rect))
406401         m_collision_latch |= 2;
407402
408      if (spaceship_collision(machine(), m_helper, rect))
403      if (spaceship_collision(m_helper, rect))
409404         m_collision_latch |= 4;
410405
411      if (spaceship_collision(machine(), m_helper, visarea))
406      if (spaceship_collision(m_helper, visarea))
412407         m_collision_latch |= 8;
413408   }
414409}
trunk/src/mame/includes/scramble.h
r20977r20978
7373   DECLARE_WRITE8_MEMBER(scramble_protection_w);
7474   DECLARE_READ8_MEMBER(scramble_protection_r);
7575   DECLARE_WRITE_LINE_MEMBER(scramble_sh_7474_q_callback);
76   void cavelon_banksw();
77   inline int bit(int i,int n);
7678};
7779
7880
trunk/src/mame/includes/suprridr.h
r20977r20978
4343   UINT32 screen_update_suprridr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444   INTERRUPT_GEN_MEMBER(main_nmi_gen);
4545   TIMER_CALLBACK_MEMBER(delayed_sound_w);
46   int suprridr_is_screen_flipped();
4647};
4748
4849/*----------- defined in video/suprridr.c -----------*/
trunk/src/mame/includes/sbasketb.h
r20977r20978
4444   virtual void palette_init();
4545   UINT32 screen_update_sbasketb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4646   INTERRUPT_GEN_MEMBER(vblank_irq);
47   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4748};
trunk/src/mame/includes/skullxbo.h
r20977r20978
2424   DECLARE_VIDEO_START(skullxbo);
2525   UINT32 screen_update_skullxbo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2626   TIMER_CALLBACK_MEMBER(irq_gen);
27   void skullxbo_scanline_update(int scanline);
2728};
2829
2930/*----------- defined in video/skullxbo.c -----------*/
trunk/src/mame/includes/spacefb.h
r20977r20978
5151   virtual void video_start();
5252   UINT32 screen_update_spacefb(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5353   TIMER_CALLBACK_MEMBER(interrupt_callback);
54   inline void shift_star_generator(spacefb_state *state);
55   void get_starfield_pens(spacefb_state *state, pen_t *pens);
56   void draw_starfield(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
57   void get_sprite_pens(pen_t *pens);
58   void draw_bullet(offs_t offs, pen_t pen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int flip);
59   void draw_sprite(offs_t offs, pen_t *pens, bitmap_rgb32 &bitmap, const rectangle &cliprect, int flip);
60   void draw_objects(bitmap_rgb32 &bitmap, const rectangle &cliprect);
61   void create_interrupt_timer();
62   void start_interrupt_timer();
5463};
5564
5665/*----------- defined in audio/spacefb.c -----------*/
trunk/src/mame/includes/splash.h
r20977r20978
6565   UINT32 screen_update_splash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6666   UINT32 screen_update_funystrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6767   INTERRUPT_GEN_MEMBER(roldfrog_interrupt);
68   void draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect);
69   void splash_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
70   void funystrp_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
71   void roldfrog_update_irq(  );
6872};
trunk/src/mame/includes/starfire.h
r20977r20978
6262   UINT32 screen_update_starfire(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
6363   TIMER_CALLBACK_MEMBER(starfire_scanline_callback);
6464   INTERRUPT_GEN_MEMBER(vblank_int);
65   void get_pens(pen_t *pens);
6566};
trunk/src/mame/includes/subs.h
r20977r20978
5252   DECLARE_WRITE8_MEMBER(subs_crash_w);
5353   DECLARE_WRITE8_MEMBER(subs_explode_w);
5454   DECLARE_WRITE8_MEMBER(subs_noise_reset_w);
55   int subs_steering_1();
56   int subs_steering_2();
5557};
5658
5759/*----------- defined in audio/subs.c -----------*/
trunk/src/mame/includes/shadfrce.h
r20977r20978
4545   UINT32 screen_update_shadfrce(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4646   void screen_eof_shadfrce(screen_device &screen, bool state);
4747   TIMER_DEVICE_CALLBACK_MEMBER(shadfrce_scanline);
48   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
4849};
trunk/src/mame/includes/speedbal.h
r20977r20978
1919   TILE_GET_INFO_MEMBER(get_tile_info_fg);
2020   virtual void video_start();
2121   UINT32 screen_update_speedbal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
22   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
2223};
trunk/src/mame/includes/skydiver.h
r20977r20978
5252   virtual void palette_init();
5353   UINT32 screen_update_skydiver(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   INTERRUPT_GEN_MEMBER(skydiver_interrupt);
55   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5556};
5657
5758/*----------- defined in audio/skydiver.c -----------*/
trunk/src/mame/includes/spdodgeb.h
r20977r20978
4848   virtual void palette_init();
4949   UINT32 screen_update_spdodgeb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5050   TIMER_DEVICE_CALLBACK_MEMBER(spdodgeb_interrupt);
51   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
52   void mcu63705_update_inputs();
5153};
trunk/src/mame/includes/snk6502.h
r20977r20978
6464   INTERRUPT_GEN_MEMBER(satansat_interrupt);
6565   INTERRUPT_GEN_MEMBER(snk6502_interrupt);
6666   TIMER_DEVICE_CALLBACK_MEMBER(sasuke_update_counter);
67   void sasuke_start_counter();
6768};
6869
6970
trunk/src/mame/includes/skykid.h
r20977r20978
4343   UINT32 screen_update_skykid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444   INTERRUPT_GEN_MEMBER(main_vblank_irq);
4545   INTERRUPT_GEN_MEMBER(mcu_vblank_irq);
46   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
4647};
trunk/src/mame/includes/segag80v.h
r20977r20978
5353   virtual void machine_start();
5454   virtual void video_start();
5555   UINT32 screen_update_segag80v(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
56   inline int adjust_xy(int rawx, int rawy, int *outx, int *outy);
57   void sega_generate_vector_list();
58   offs_t decrypt_offset(address_space &space, offs_t offset);
59   inline UINT8 demangle(UINT8 d7d6, UINT8 d5d4, UINT8 d3d2, UINT8 d1d0);
5660};
trunk/src/mame/includes/superchs.h
r20977r20978
3939   DECLARE_DRIVER_INIT(superchs);
4040   virtual void video_start();
4141   UINT32 screen_update_superchs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
42   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,const int *primasks,int x_offs,int y_offs);
4243};
trunk/src/mame/includes/slapshot.h
r20977r20978
6969   INTERRUPT_GEN_MEMBER(slapshot_interrupt);
7070   TIMER_CALLBACK_MEMBER(slapshot_interrupt6);
7171   void reset_sound_region();
72   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks, int y_offset );
73   void taito_handle_sprite_buffering(  );
74   void taito_update_sprites_active_area(  );
7275};
trunk/src/mame/includes/sidearms.h
r20977r20978
5353   virtual void video_start();
5454   UINT32 screen_update_sidearms(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   DECLARE_WRITE_LINE_MEMBER(irqhandler);
56   void draw_sprites_region(bitmap_ind16 &bitmap, const rectangle &cliprect, int start_offset, int end_offset );
57   void sidearms_draw_starfield( bitmap_ind16 &bitmap );
58   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5659};
trunk/src/mame/includes/sderby.h
r20977r20978
3535   virtual void video_start();
3636   UINT32 screen_update_sderby(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3737   UINT32 screen_update_pmroulet(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
38   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int codeshift);
3839};
trunk/src/mame/includes/snk.h
r20977r20978
172172   TIMER_CALLBACK_MEMBER(sgladiat_sndirq_update_callback);
173173   TIMER_CALLBACK_MEMBER(sndirq_update_callback);
174174   DECLARE_WRITE_LINE_MEMBER(ymirq_callback_2);
175   void tnk3_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, const int xscroll, const int yscroll);
176   int hardflags_check(int num);
177   int hardflags_check8(int num);
178   int turbofront_check(int small, int num);
179   int turbofront_check8(int small, int num);
175180};
trunk/src/mame/includes/segas32.h
r20977r20978
55***************************************************************************/
66
77
8typedef void (*sys32_output_callback)(int which, UINT16 data);
9struct layer_info
10{
11   bitmap_ind16 *bitmap;
12   UINT8 *transparent;
13};
148
159
1610class segas32_state : public driver_device
r20977r20978
3125   required_shared_ptr<UINT16> m_system32_videoram;
3226   required_shared_ptr<UINT16> m_system32_spriteram;
3327
28   typedef void (segas32_state::*sys32_output_callback)(int which, UINT16 data);
29
30   struct layer_info
31   {
32      bitmap_ind16 *bitmap;
33      UINT8 *transparent;
34   };
35
36   struct extents_list
37   {
38      UINT8                   scan_extent[256];
39      UINT16                  extent[32][16];
40   };
41
42
43   struct cache_entry
44   {
45      struct cache_entry *    next;
46      tilemap_t *             tmap;
47      UINT8                   page;
48      UINT8                   bank;
49   };   
50   
3451   UINT8 m_v60_irq_control[0x10];
3552   timer_device *m_v60_irq_timer[2];
3653   UINT8 m_sound_irq_control[4];
r20977r20978
181198   TIMER_CALLBACK_MEMBER(end_of_vblank_int);
182199   TIMER_CALLBACK_MEMBER(update_sprites);
183200   TIMER_DEVICE_CALLBACK_MEMBER(signal_v60_irq_callback);
201   void common_start(int multi32);
202   void system32_set_vblank(int state);
203   inline UINT16 xBBBBBGGGGGRRRRR_to_xBGRBBBBGGGGRRRR(UINT16 value);
204   inline UINT16 xBGRBBBBGGGGRRRR_to_xBBBBBGGGGGRRRRR(UINT16 value);
205   inline void update_color(int offset, UINT16 data);
206   inline UINT16 common_paletteram_r(address_space &space, int which, offs_t offset);
207   void common_paletteram_w(address_space &space, int which, offs_t offset, UINT16 data, UINT16 mem_mask);
208   tilemap_t *find_cache_entry(int page, int bank);
209   inline void get_tilemaps(int bgnum, tilemap_t **tilemaps);
210   UINT8 update_tilemaps(screen_device &screen, const rectangle &cliprect);
211   void sprite_erase_buffer();
212   void sprite_swap_buffers();
213   int draw_one_sprite(UINT16 *data, int xoffs, int yoffs, const rectangle &clipin, const rectangle &clipout);
214   void sprite_render_list();
215   inline UINT8 compute_color_offsets(int which, int layerbit, int layerflag);
216   inline UINT16 compute_sprite_blend(UINT8 encoding);
217   inline UINT16 *get_layer_scanline(int layer, int scanline);
218   void mix_all_layers(int which, int xoffs, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 enablemask);
219   void print_mixer_data(int which);
220   UINT32 multi32_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int index);
221   void decrypt_ga2_protrom();
222   void update_irq_state();
223   void signal_v60_irq(int which);
224   void int_control_w(address_space &space, int offset, UINT8 data);
225   UINT16 common_io_chip_r(address_space &space, int which, offs_t offset, UINT16 mem_mask);
226   void common_io_chip_w(address_space &space, int which, offs_t offset, UINT16 data, UINT16 mem_mask);
227   void update_sound_irq_state();
228   void segas32_common_init(read16_delegate custom_r, write16_delegate custom_w);
229   void radm_sw1_output( int which, UINT16 data );
230   void radm_sw2_output( int which, UINT16 data );
231   void radr_sw2_output( int which, UINT16 data );
232   void alien3_sw1_output( int which, UINT16 data );
233   void arescue_sw1_output( int which, UINT16 data );
234   void f1lap_sw1_output( int which, UINT16 data );
235   void jpark_sw1_output( int which, UINT16 data );
236   void orunners_sw1_output( int which, UINT16 data );
237   void orunners_sw2_output( int which, UINT16 data );
238   void harddunk_sw1_output( int which, UINT16 data );
239   void harddunk_sw2_output( int which, UINT16 data );
240   void harddunk_sw3_output( int which, UINT16 data );
241   void titlef_sw1_output( int which, UINT16 data );
242   void titlef_sw2_output( int which, UINT16 data );
243   void scross_sw1_output( int which, UINT16 data );
244   void scross_sw2_output( int which, UINT16 data );
245   int compute_clipping_extents(screen_device &screen, int enable, int clipout, int clipmask, const rectangle &cliprect, struct extents_list *list);
246   void update_tilemap_zoom(screen_device &screen, struct layer_info *layer, const rectangle &cliprect, int bgnum);
247   void update_tilemap_rowscroll(screen_device &screen, struct layer_info *layer, const rectangle &cliprect, int bgnum);
248   void update_tilemap_text(screen_device &screen, struct layer_info *layer, const rectangle &cliprect);
249   void update_bitmap(screen_device &screen, struct layer_info *layer, const rectangle &cliprect);
250   void update_background(struct layer_info *layer, const rectangle &cliprect);
184251};
185252
186253/*----------- defined in machine/segas32.c -----------*/
trunk/src/mame/includes/sslam.h
r20977r20978
5353   UINT32 screen_update_sslam(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   UINT32 screen_update_powerbls(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   TIMER_CALLBACK_MEMBER(music_playback);
56   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5657};
trunk/src/mame/includes/stlforce.h
r20977r20978
4444   TILE_GET_INFO_MEMBER(get_stlforce_tx_tile_info);
4545   virtual void video_start();
4646   UINT32 screen_update_stlforce(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
47   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
4748};
trunk/src/mame/includes/sauro.h
r20977r20978
3939   UINT32 screen_update_trckydoc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4040   UINT32 screen_update_sauro(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4141   INTERRUPT_GEN_MEMBER(sauro_interrupt);
42   void sauro_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
43   void trckydoc_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
4244};
trunk/src/mame/includes/srumbler.h
r20977r20978
2929   virtual void video_start();
3030   UINT32 screen_update_srumbler(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3131   TIMER_DEVICE_CALLBACK_MEMBER(srumbler_interrupt);
32   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3233};
trunk/src/mame/includes/stfight.h
r20977r20978
4949   INTERRUPT_GEN_MEMBER(stfight_vb_interrupt);
5050   TIMER_CALLBACK_MEMBER(stfight_interrupt_1);
5151   DECLARE_WRITE8_MEMBER(stfight_adpcm_control_w);
52   void set_pens();
53   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5254};
5355
5456/*----------- defined in machine/stfight.c -----------*/
trunk/src/mame/includes/silkroad.h
r20977r20978
2929   TILE_GET_INFO_MEMBER(get_fg3_tile_info);
3030   virtual void video_start();
3131   UINT32 screen_update_silkroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
32   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3233};
trunk/src/mame/includes/spy.h
r20977r20978
4646   virtual void video_start();
4747   UINT32 screen_update_spy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4848   INTERRUPT_GEN_MEMBER(spy_interrupt);
49   void spy_collision(  );
4950};
5051
5152/*----------- defined in video/spy.c -----------*/
trunk/src/mame/includes/seta2.h
r20977r20978
7575   INTERRUPT_GEN_MEMBER(samshoot_interrupt);
7676   INTERRUPT_GEN_MEMBER(funcube_sub_timer_irq);
7777   TIMER_DEVICE_CALLBACK_MEMBER(funcube_interrupt);
78   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
79   void funcube_debug_outputs();
7880};
trunk/src/mame/includes/solomon.h
r20977r20978
3232   virtual void video_start();
3333   UINT32 screen_update_solomon(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3434   INTERRUPT_GEN_MEMBER(vblank_irq);
35   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
3536};
trunk/src/mame/includes/scotrsht.h
r20977r20978
2727   virtual void palette_init();
2828   UINT32 screen_update_scotrsht(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2929   INTERRUPT_GEN_MEMBER(scotrsht_interrupt);
30   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
3031};
trunk/src/mame/includes/superqix.h
r20977r20978
8383   TIMER_CALLBACK_MEMBER(mcu_acknowledge_callback);
8484   TIMER_CALLBACK_MEMBER(delayed_z80_mcu_w);
8585   TIMER_CALLBACK_MEMBER(delayed_mcu_z80_w);
86   void pbillian_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
87   void superqix_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
88   int read_dial(int player);
89   void machine_init_common();
8690};
trunk/src/mame/includes/skyfox.h
r20977r20978
3333   virtual void palette_init();
3434   UINT32 screen_update_skyfox(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3535   INTERRUPT_GEN_MEMBER(skyfox_interrupt);
36   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
37   void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect);
3638};
trunk/src/mame/includes/senjyo.h
r20977r20978
8484   UINT32 screen_update_senjyo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8585   INTERRUPT_GEN_MEMBER(senjyo_interrupt);
8686   DECLARE_READ8_MEMBER(pio_pa_r);
87   void draw_bgbitmap(bitmap_ind16 &bitmap,const rectangle &cliprect);
88   void draw_radar(bitmap_ind16 &bitmap,const rectangle &cliprect);
89   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int priority);
8790};
8891
8992/*----------- defined in audio/senjyo.c -----------*/
trunk/src/mame/includes/slapfght.h
r20977r20978
127127   UINT32 screen_update_slapfight(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
128128   INTERRUPT_GEN_MEMBER(vblank_irq);
129129   INTERRUPT_GEN_MEMBER(getstar_interrupt);
130   void slapfght_log_vram();
131   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority_to_display );
132   void getstar_init(  );
130133};
131134
132135
trunk/src/mame/includes/ssozumo.h
r20977r20978
3737   virtual void palette_init();
3838   UINT32 screen_update_ssozumo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3939   INTERRUPT_GEN_MEMBER(sound_timer_irq);
40   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
4041};
trunk/src/mame/includes/sonson.h
r20977r20978
3939   virtual void video_start();
4040   virtual void palette_init();
4141   UINT32 screen_update_sonson(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
42   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4243};
trunk/src/mame/includes/ssv.h
r20977r20978
132132   TIMER_DEVICE_CALLBACK_MEMBER(gdfs_interrupt);
133133   void update_irq_state();
134134   IRQ_CALLBACK_MEMBER(ssv_irq_callback);
135   void draw_row(bitmap_ind16 &bitmap, const rectangle &cliprect, int sx, int sy, int scroll);
136   void draw_layer(bitmap_ind16 &bitmap, const rectangle &cliprect, int  nr);
137   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
138   void ssv_enable_video(int enable);
139   void init_ssv(int interrupt_ultrax);
140   void init_hypreac2_common();
141   void init_st010();
135142};
136143
137144/*----------- defined in video/ssv.c -----------*/
trunk/src/mame/includes/sprcros2.h
r20977r20978
3333   UINT32 screen_update_sprcros2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3434   INTERRUPT_GEN_MEMBER(sprcros2_s_interrupt);
3535   TIMER_DEVICE_CALLBACK_MEMBER(sprcros2_m_interrupt);
36   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
3637};
trunk/src/mame/includes/starshp1.h
r20977r20978
8181   UINT32 screen_update_starshp1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8282   void screen_eof_starshp1(screen_device &screen, bool state);
8383   INTERRUPT_GEN_MEMBER(starshp1_interrupt);
84   void set_pens(colortable_t *colortable);
85   void draw_starfield(bitmap_ind16 &bitmap);
86   int get_sprite_hpos(int i);
87   int get_sprite_vpos(int i);
88   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
89   void draw_spaceship(bitmap_ind16 &bitmap, const rectangle &cliprect);
90   void draw_phasor(bitmap_ind16 &bitmap);
91   int get_radius();
92   int get_circle_hpos();
93   int get_circle_vpos();
94   void draw_circle_line(bitmap_ind16 &bitmap, int x, int y, int l);
95   void draw_circle(bitmap_ind16 &bitmap);
96   int spaceship_collision(bitmap_ind16 &bitmap, const rectangle &rect);
97   int point_in_circle(int x, int y, int center_x, int center_y, int r);
98   int circle_collision(const rectangle &rect);
8499};
85100
86101/*----------- defined in audio/starshp1.c -----------*/
trunk/src/mame/includes/suna8.h
r20977r20978
137137   DECLARE_WRITE8_MEMBER(rranger_play_samples_w);
138138   DECLARE_WRITE8_MEMBER(suna8_samples_number_w);
139139   void play_sample(int index);
140   void draw_normal_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect, int which);
141   void draw_text_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
142   UINT8 *brickzn_decrypt();
140143};
141144
142145/*----------- defined in audio/suna8.c -----------*/
trunk/src/mame/includes/suprloco.h
r20977r20978
2323   virtual void video_start();
2424   virtual void palette_init();
2525   UINT32 screen_update_suprloco(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
26   inline void draw_pixel(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int color,int flip);
27   void draw_sprite(bitmap_ind16 &bitmap,const rectangle &cliprect,int spr_number);
28   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
2629};
trunk/src/mame/includes/sprint2.h
r20977r20978
6767   UINT32 screen_update_sprint2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6868   void screen_eof_sprint2(screen_device &screen, bool state);
6969   INTERRUPT_GEN_MEMBER(sprint2);
70   UINT8 collision_check(colortable_t *colortable, rectangle& rect);
71   inline int get_sprite_code(UINT8 *video_ram, int n);
72   inline int get_sprite_x(UINT8 *video_ram, int n);
73   inline int get_sprite_y(UINT8 *video_ram, int n);
74   int service_mode();
7075};
7176
7277/*----------- defined in audio/sprint2.c -----------*/
trunk/src/mame/includes/system1.h
r20977r20978
1818   optional_shared_ptr<UINT8> m_nob_mcu_status;
1919
2020   UINT8 *m_videoram;
21   void (*m_videomode_custom)(running_machine &machine, UINT8 data, UINT8 prevdata);
21   void (system1_state::*m_videomode_custom)(UINT8 data, UINT8 prevdata);
2222   UINT8 m_mute_xor;
2323   UINT8 m_dakkochn_mux_data;
2424   UINT8 m_videomode_prev;
r20977r20978
113113   TIMER_DEVICE_CALLBACK_MEMBER(soundirq_gen);
114114   TIMER_DEVICE_CALLBACK_MEMBER(mcu_t0_callback);
115115   DECLARE_WRITE8_MEMBER(system1_videoram_bank_w);
116   void video_start_common(int pagecount);
117   inline void videoram_wait_states(cpu_device *cpu);
118   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffset);
119   void video_update_common(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind16 &fgpixmap, bitmap_ind16 **bgpixmaps, const int *bgrowscroll, int bgyscroll, int spritexoffs);
120   void bank44_custom_w(UINT8 data, UINT8 prevdata);
121   void bank0c_custom_w(UINT8 data, UINT8 prevdata);
122   void dakkochn_custom_w(UINT8 data, UINT8 prevdata);
116123};
trunk/src/mame/includes/sidepckt.h
r20977r20978
2929   virtual void video_start();
3030   virtual void palette_init();
3131   UINT32 screen_update_sidepckt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
32   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
3233};
trunk/src/mame/includes/starwars.h
r20977r20978
6767   DECLARE_READ8_MEMBER(r6532_porta_r);
6868   DECLARE_WRITE8_MEMBER(r6532_porta_w);
6969   DECLARE_WRITE_LINE_MEMBER(snd_interrupt);
70   void starwars_mproc_init();
71   void starwars_mproc_reset();
72   void run_mproc();
73   void esb_slapstic_tweak(address_space &space, offs_t offset);
7074};
7175
7276
trunk/src/mame/includes/sspeedr.h
r20977r20978
3737   virtual void palette_init();
3838   UINT32 screen_update_sspeedr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3939   void screen_eof_sspeedr(screen_device &screen, bool state);
40   void draw_track(bitmap_ind16 &bitmap);
41   void draw_drones(bitmap_ind16 &bitmap, const rectangle &cliprect);
42   void draw_driver(bitmap_ind16 &bitmap, const rectangle &cliprect);
4043};
trunk/src/mame/includes/seta.h
r20977r20978
209209   TIMER_DEVICE_CALLBACK_MEMBER(setaroul_interrupt);
210210   TIMER_DEVICE_CALLBACK_MEMBER(crazyfgt_interrupt);
211211   TIMER_DEVICE_CALLBACK_MEMBER(inttoote_interrupt);
212   void seta_coin_lockout_w(int data);
213   inline void twineagl_tile_info( tile_data &tileinfo, int tile_index, int offset );
214   inline void get_tile_info( tile_data &tileinfo, int tile_index, int layer, int offset );
215   void set_pens();
216   void usclssic_set_pens();
217   void draw_tilemap_palette_effect(bitmap_ind16 &bitmap, const rectangle &cliprect, tilemap_t *tilemap, int scrollx, int scrolly, int gfxnum, int flipscreen);
218   void seta_layers_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int sprite_bank_size, int sprite_setac );
219   void uPD71054_timer_init(  );
212220};
213
214/*----------- defined in video/seta.c -----------*/
215void seta_coin_lockout_w(running_machine &machine, int data);
trunk/src/mame/includes/snowbros.h
r20977r20978
11#include "emu.h"
2#include "sound/okim6295.h"
23
34class snowbros_state : public driver_device
45{
r20977r20978
5152   void screen_eof_snowbros(screen_device &screen, bool state);
5253   TIMER_DEVICE_CALLBACK_MEMBER(snowbros_irq);
5354   TIMER_DEVICE_CALLBACK_MEMBER(snowbros3_irq);
55   void sb3_play_music(int data);
56   void sb3_play_sound (okim6295_device *oki, int data);
5457};
trunk/src/mame/includes/skyraid.h
r20977r20978
2828   virtual void palette_init();
2929   UINT32 screen_update_skyraid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3030   DECLARE_WRITE8_MEMBER(skyraid_sound_w);
31   void draw_text(bitmap_ind16 &bitmap, const rectangle &cliprect);
32   void draw_terrain(bitmap_ind16 &bitmap, const rectangle &cliprect);
33   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
34   void draw_missiles(bitmap_ind16 &bitmap, const rectangle &cliprect);
35   void draw_trapezoid(bitmap_ind16& dst, bitmap_ind16& src);
3136};
3237
3338/*----------- defined in audio/skyraid.c -----------*/
trunk/src/mame/includes/seibuspi.h
r20977r20978
117117   UINT32 screen_update_sys386f2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
118118   INTERRUPT_GEN_MEMBER(spi_interrupt);
119119   IRQ_CALLBACK_MEMBER(spi_irq_callback);
120   void rf2_set_layer_banks(int banks);
121   void drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy);
122   void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int pri_mask);
123   void set_rowscroll(tilemap_t *layer, int scroll, INT16* rows);
124   void set_scroll(tilemap_t *layer, int scroll);
125   void combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *tile, int x, int y, int opaque, INT16 *rowscroll);
126   UINT8 z80_fifoout_pop(address_space &space);
127   void z80_fifoout_push(address_space &space, UINT8 data);
128   UINT8 z80_fifoin_pop(address_space &space);
129   void z80_fifoin_push(address_space &space, UINT8 data);
130   void init_spi();
131   void init_rf2_common();
132   void init_rfjet_common();
120133};
121134/*----------- defined in machine/spisprit.c -----------*/
122135void seibuspi_sprite_decrypt(UINT8 *src, int romsize);
trunk/src/mame/includes/speedatk.h
r20977r20978
2727   virtual void video_start();
2828   virtual void palette_init();
2929   UINT32 screen_update_speedatk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
30   UINT8 iox_key_matrix_calc(UINT8 p_side);
3031};
trunk/src/mame/includes/suprnova.h
r20977r20978
138138   void screen_eof_skns(screen_device &screen, bool state);
139139   TIMER_DEVICE_CALLBACK_MEMBER(interrupt_callback);
140140   TIMER_DEVICE_CALLBACK_MEMBER(skns_irq);
141   void suprnova_draw_roz(bitmap_ind16 &bitmap, bitmap_ind8& bitmapflags, const rectangle &cliprect, tilemap_t *tmap, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound, int columnscroll, UINT32* scrollram);
142   void palette_set_rgb_brightness (int offset, UINT8 brightness_r, UINT8 brightness_g, UINT8 brightness_b);
143   void palette_update();
144   void supernova_draw_a( bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_flags, const rectangle &cliprect, int tran );
145   void supernova_draw_b( bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_flags, const rectangle &cliprect, int tran );
146   void hit_recalc();
147   void init_skns();
148   void set_drc_pcflush(UINT32 addr);
141149};
142150
143/*----------- defined in video/suprnova.c -----------*/
144void skns_sprite_kludge(int x, int y);
145void skns_draw_sprites(
146   running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,
147   UINT32* spriteram_source, size_t spriteram_size,
148   UINT8* gfx_source, size_t gfx_length,
149   UINT32* sprite_regs );
trunk/src/mame/includes/shootout.h
r20977r20978
2727   virtual void palette_init();
2828   UINT32 screen_update_shootout(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2929   UINT32 screen_update_shootouj(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
30   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_bits );
3031};
trunk/src/mame/includes/st0016.h
r20977r20978
4040   void st0016_draw_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4141   UINT32 screen_update_st0016(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4242   TIMER_DEVICE_CALLBACK_MEMBER(st0016_int);
43   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
44   void st0016_save_init();
45   void draw_bgmap(bitmap_ind16 &bitmap,const rectangle &cliprect, int priority);
4346};
4447
4548#define ISMACS  (st0016_game&0x80)
trunk/src/mame/includes/shangkid.h
r20977r20978
3232   DECLARE_MACHINE_RESET(shangkid);
3333   UINT32 screen_update_shangkid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3434   UINT32 screen_update_dynamski(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
35   void draw_sprite(const UINT8 *source, bitmap_ind16 &bitmap, const rectangle &cliprect);
36   void shangkid_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
37   void dynamski_draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri );
38   void dynamski_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
3539};
trunk/src/mame/includes/speedspn.h
r20977r20978
2222   TILE_GET_INFO_MEMBER(get_speedspn_tile_info);
2323   virtual void video_start();
2424   UINT32 screen_update_speedspn(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
25   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
2526};
trunk/src/mame/includes/ssrj.h
r20977r20978
3131   virtual void palette_init();
3232   UINT32 screen_update_ssrj(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3333   void screen_eof_ssrj(screen_device &screen, bool state);
34   void draw_objects(bitmap_ind16 &bitmap, const rectangle &cliprect );
3435};
trunk/src/mame/includes/sf.h
r20977r20978
4848   virtual void machine_reset();
4949   virtual void video_start();
5050   UINT32 screen_update_sf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
51   inline int sf_invert( int nb );
52   void draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect );
53   void write_dword( address_space &space, offs_t offset, UINT32 data );
5154};
trunk/src/mame/includes/seicross.h
r20977r20978
3131   virtual void palette_init();
3232   UINT32 screen_update_seicross(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3333   INTERRUPT_GEN_MEMBER(vblank_irq);
34   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
3435};
trunk/src/mame/includes/system16.h
r20977r20978
194194   UINT32 screen_update_s16a_bootleg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
195195   UINT32 screen_update_s16a_bootleg_passht4b(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
196196   INTERRUPT_GEN_MEMBER(sys16_interrupt);
197   void setup_system16_bootleg_spritebanking(  );
198   void update_page(  );
199   void set_tile_bank( int data );
200   void set_fg_page( int data );
201   void set_bg_page( int data );
202   void datsu_set_pages(  );
197203};
trunk/src/mame/includes/simpsons.h
r20977r20978
4545   TIMER_CALLBACK_MEMBER(dmaend_callback);
4646   DECLARE_READ8_MEMBER(simpsons_sound_r);
4747   void simpsons_postload();
48   void simpsons_video_banking( int bank );
49   void sound_nmi_callback( int param );
50   void simpsons_objdma(  );
4851};
4952
5053
5154/*----------- defined in video/simpsons.c -----------*/
52void simpsons_video_banking( running_machine &machine, int select );
53
5455extern void simpsons_tile_callback(running_machine &machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
5556extern void simpsons_sprite_callback(running_machine &machine, int *code,int *color,int *priority_mask);
trunk/src/mame/includes/suna16.h
r20977r20978
4242   UINT32 screen_update_suna16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4343   UINT32 screen_update_bestbest(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444   TIMER_DEVICE_CALLBACK_MEMBER(bssoccer_interrupt);
45   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 *sprites, int gfx);
4546};
trunk/src/mame/includes/starcrus.h
r20977r20978
5151   DECLARE_READ8_MEMBER(starcrus_coll_det_r);
5252   virtual void video_start();
5353   UINT32 screen_update_starcrus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
54   int collision_check_s1s2();
55   int collision_check_p1p2();
56   int collision_check_s1p1p2();
57   int collision_check_s2p1p2();
5458};
trunk/src/mame/includes/stactics.h
r20977r20978
6161   DECLARE_PALETTE_INIT(stactics);
6262   UINT32 screen_update_stactics(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6363   INTERRUPT_GEN_MEMBER(stactics_interrupt);
64   void update_beam();
65   inline int get_pixel_on_plane(UINT8 *videoram, UINT8 y, UINT8 x, UINT8 y_scroll);
66   void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect);
67   void set_indicator_leds(int data, const char *output_name, int base_index);
68   void update_artwork();
69   void move_motor();
6470};
6571/*----------- defined in video/stactics.c -----------*/
6672MACHINE_CONFIG_EXTERN( stactics_video );
trunk/src/mame/includes/strnskil.h
r20977r20978
3232   virtual void palette_init();
3333   UINT32 screen_update_strnskil(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3434   TIMER_DEVICE_CALLBACK_MEMBER(strnskil_irq);
35   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3536};
trunk/src/mame/includes/shaolins.h
r20977r20978
2727   virtual void palette_init();
2828   UINT32 screen_update_shaolins(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2929   TIMER_DEVICE_CALLBACK_MEMBER(shaolins_interrupt);
30   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3031};
trunk/src/mame/includes/sshangha.h
r20977r20978
5858   virtual void machine_reset();
5959   virtual void video_start();
6060   UINT32 screen_update_sshangha(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
61   inline void sshangha_set_color_888(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
6162};
trunk/src/mame/includes/srmp2.h
r20977r20978
4949   UINT32 screen_update_srmp2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5050   UINT32 screen_update_srmp3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5151   UINT32 screen_update_mjyuugi(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
52   UINT8 iox_key_matrix_calc(UINT8 p_side);
5253};
trunk/src/mame/includes/sprint8.h
r20977r20978
4545   DECLARE_WRITE8_MEMBER(sprint8_screech_w);
4646   DECLARE_WRITE8_MEMBER(sprint8_attract_w);
4747   DECLARE_WRITE8_MEMBER(sprint8_motor_w);
48   void set_pens(sprint8_state *state, colortable_t *colortable);
49   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
50   void sprint8_set_collision(int n);
4851};
4952
5053/*----------- defined in drivers/sprint8.c -----------*/
trunk/src/mame/includes/snk68.h
r20977r20978
4444   virtual void video_start();
4545   DECLARE_VIDEO_START(searchar);
4646   UINT32 screen_update_pow(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
47   void common_video_start();
48   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int group);
4749};
trunk/src/mame/includes/segag80r.h
r20977r20978
110110   DECLARE_WRITE8_MEMBER(n7751_command_w);
111111   DECLARE_WRITE8_MEMBER(n7751_rom_control_w);
112112   DECLARE_WRITE8_MEMBER(n7751_p2_w);
113   void vblank_latch_set();
114   void g80_set_palette_entry(int entry, UINT8 data);
115   void spaceod_bg_init_palette();
116   void draw_videoram(bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *transparent_pens);
117   void draw_background_spaceod(bitmap_ind16 &bitmap, const rectangle &cliprect);
118   void draw_background_page_scroll(bitmap_ind16 &bitmap, const rectangle &cliprect);
119   void draw_background_full_scroll(bitmap_ind16 &bitmap, const rectangle &cliprect);
120   offs_t decrypt_offset(address_space &space, offs_t offset);
121   inline UINT8 demangle(UINT8 d7d6, UINT8 d5d4, UINT8 d3d2, UINT8 d1d0);
122   void monsterb_expand_gfx(const char *region);
113123};
114124
115125

Previous 199869 Revisions Next


© 1997-2024 The MAME Team