Previous 199869 Revisions Next

r20972 Tuesday 12th February, 2013 at 09:06:25 UTC by Miodrag Milanović
Modernization of drivers part 13 (no whatsnew)
[src/mame/audio]n8080.c
[src/mame/drivers]nbmj9195.c neogeo.c ninjakd2.c ninjaw.c niyanpai.c nmk16.c nova2001.c
[src/mame/includes]n8080.h nbmj8688.h nbmj8891.h nbmj8900.h nbmj8991.h nbmj9195.h nemesis.h neogeo.h ninjakd2.h ninjaw.h nitedrvr.h niyanpai.h nmk16.h nova2001.h nycaptor.h
[src/mame/machine]nitedrvr.c
[src/mame/video]n8080.c nbmj8688.c nbmj8891.c nbmj8900.c nbmj8991.c nbmj9195.c nemesis.c neogeo.c ninjakd2.c ninjaw.c nitedrvr.c niyanpai.c nmk16.c nova2001.c nycaptor.c
[src/mess/drivers]ng_aes.c

trunk/src/mame/drivers/ninjaw.c
r20971r20972
325325
326326extern const char layout_darius[];
327327
328static void parse_control( running_machine &machine )   /* assumes Z80 sandwiched between 68Ks */
328void ninjaw_state::parse_control(  )   /* assumes Z80 sandwiched between 68Ks */
329329{
330330   /* bit 0 enables cpu B */
331331   /* however this fails when recovering from a save state
332332      if cpu B is disabled !! */
333   ninjaw_state *state = machine.driver_data<ninjaw_state>();
334   state->m_subcpu->set_input_line(INPUT_LINE_RESET, (state->m_cpua_ctrl & 0x1) ? CLEAR_LINE : ASSERT_LINE);
333   m_subcpu->set_input_line(INPUT_LINE_RESET, (m_cpua_ctrl & 0x1) ? CLEAR_LINE : ASSERT_LINE);
335334
336335}
337336
r20971r20972
341340      data = data >> 8;
342341   m_cpua_ctrl = data;
343342
344   parse_control(machine());
343   parse_control();
345344
346345   logerror("CPU #0 PC %06x: write %04x to cpu control\n", space.device().safe_pc(), data);
347346}
r20971r20972
351350            SOUND
352351*****************************************/
353352
354static void reset_sound_region( running_machine &machine )
353void ninjaw_state::reset_sound_region(  )
355354{
356   ninjaw_state *state = machine.driver_data<ninjaw_state>();
357   state->membank("bank10")->set_entry(state->m_banknum);
355   membank("bank10")->set_entry(m_banknum);
358356}
359357
360358WRITE8_MEMBER(ninjaw_state::sound_bankswitch_w)
361359{
362360   m_banknum = data & 7;
363   reset_sound_region(machine());
361   reset_sound_region();
364362}
365363
366364WRITE16_MEMBER(ninjaw_state::ninjaw_sound_w)
r20971r20972
791789
792790void ninjaw_state::ninjaw_postload()
793791{
794   parse_control(machine());
795   reset_sound_region(machine());
792   parse_control();
793   reset_sound_region();
796794}
797795
798796void ninjaw_state::machine_start()
trunk/src/mame/drivers/niyanpai.c
r20971r20972
4848#include "includes/niyanpai.h"
4949
5050
51static void niyanpai_soundbank_w(running_machine &machine, int data)
51void niyanpai_state::niyanpai_soundbank_w(int data)
5252{
53   UINT8 *SNDROM = machine.root_device().memregion("audiocpu")->base();
53   UINT8 *SNDROM = machine().root_device().memregion("audiocpu")->base();
5454
55   machine.root_device().membank("bank1")->set_base(&SNDROM[0x08000 + (0x8000 * (data & 0x03))]);
55   machine().root_device().membank("bank1")->set_base(&SNDROM[0x08000 + (0x8000 * (data & 0x03))]);
5656}
5757
5858READ8_MEMBER(niyanpai_state::niyanpai_sound_r)
r20971r20972
109109   switch (offset)
110110   {
111111      case 0:         /* PA_0 */
112         niyanpai_soundbank_w(machine(), data & 0x03);
112         niyanpai_soundbank_w(data & 0x03);
113113         break;
114114      case 1:         /* PB_0 */
115115         machine().device<dac_device>("dac1")->write_unsigned8(data);
r20971r20972
264264   SNDROM[0x0213] = 0x00;          // DI -> NOP
265265
266266   // initialize sound rom bank
267   niyanpai_soundbank_w(machine(), 0);
267   niyanpai_soundbank_w(0);
268268
269269   // initialize out coin flag (musobana)
270270   m_musobana_outcoin_flag = 1;
trunk/src/mame/drivers/neogeo.c
r20971r20972
173173   NEOGEO_BANK_AUDIO_CPU_CART_BANK0, NEOGEO_BANK_AUDIO_CPU_CART_BANK1, NEOGEO_BANK_AUDIO_CPU_CART_BANK2, NEOGEO_BANK_AUDIO_CPU_CART_BANK3
174174};
175175
176
177176/*************************************
178177 *
179 *  Forward declerations
180 *
181 *************************************/
182
183static void set_output_latch(running_machine &machine, UINT8 data);
184static void set_output_data(running_machine &machine, UINT8 data);
185
186
187/*************************************
188 *
189178 *  Main CPU interrupt generation
190179 *
191180 *************************************/
r20971r20972
335324}
336325
337326
338static void audio_cpu_assert_nmi(running_machine &machine)
327void neogeo_state::audio_cpu_assert_nmi()
339328{
340   neogeo_state *state = machine.driver_data<neogeo_state>();
341   state->m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
329   m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
342330}
343331
344332WRITE8_MEMBER(neogeo_state::audio_cpu_clear_nmi_w)
r20971r20972
354342 *
355343 *************************************/
356344
357static void select_controller( running_machine &machine, UINT8 data )
345void neogeo_state::select_controller( UINT8 data )
358346{
359   neogeo_state *state = machine.driver_data<neogeo_state>();
360   state->m_controller_select = data;
347   m_controller_select = data;
361348}
362349
363350
r20971r20972
403390{
404391   switch (offset)
405392   {
406   case 0x00: select_controller(machine(), data & 0x00ff); break;
407   case 0x18: if (m_is_mvs) set_output_latch(machine(), data & 0x00ff); break;
408   case 0x20: if (m_is_mvs) set_output_data(machine(), data & 0x00ff); break;
393   case 0x00: select_controller(data & 0x00ff); break;
394   case 0x18: if (m_is_mvs) set_output_latch(data & 0x00ff); break;
395   case 0x20: if (m_is_mvs) set_output_data(data & 0x00ff); break;
409396   case 0x28: upd4990a_control_16_w(m_upd4990a, space, 0, data, mem_mask); break;
410397//  case 0x30: break; // coin counters
411398//  case 0x31: break; // coin counters
r20971r20972
467454 *
468455 *************************************/
469456
470static void set_save_ram_unlock( running_machine &machine, UINT8 data )
457void neogeo_state::set_save_ram_unlock( UINT8 data )
471458{
472   neogeo_state *state = machine.driver_data<neogeo_state>();
473   state->m_save_ram_unlocked = data;
459   m_save_ram_unlocked = data;
474460}
475461
476462
r20971r20972
556542   {
557543      soundlatch_byte_w(space, 0, data >> 8);
558544
559      audio_cpu_assert_nmi(machine());
545      audio_cpu_assert_nmi();
560546
561547      /* boost the interleave to let the audio CPU read the command */
562548      machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(50));
r20971r20972
838824      switch (offset & 0x07)
839825      {
840826      default:
841      case 0x00: neogeo_set_screen_dark(machine(), bit); break;
827      case 0x00: neogeo_set_screen_dark(bit); break;
842828      case 0x01:
843829               if (m_is_cartsys)
844830               {
r20971r20972
859845               }
860846               if (m_has_audio_banking) set_audio_cpu_rom_source(bit); /* this is a guess */
861847               break;
862      case 0x05: neogeo_set_fixed_layer_source(machine(), bit); break;
863      case 0x06: if (m_is_mvs) set_save_ram_unlock(machine(), bit); break;
864      case 0x07: neogeo_set_palette_bank(machine(), bit); break;
848      case 0x05: neogeo_set_fixed_layer_source(bit); break;
849      case 0x06: if (m_is_mvs) set_save_ram_unlock(bit); break;
850      case 0x07: neogeo_set_palette_bank(bit); break;
865851
866852      case 0x02: /* unknown - HC32 middle pin 1 */
867853      case 0x03: /* unknown - uPD4990 pin ? */
r20971r20972
926912 *
927913 *************************************/
928914
929static void set_outputs( running_machine &machine )
915void neogeo_state::set_outputs(  )
930916{
931   neogeo_state *state = machine.driver_data<neogeo_state>();
932917   static const UINT8 led_map[0x10] =
933918      { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x58,0x4c,0x62,0x69,0x78,0x00 };
934919
935920   /* EL */
936   output_set_digit_value(0, led_map[state->m_el_value]);
921   output_set_digit_value(0, led_map[m_el_value]);
937922
938923   /* LED1 */
939   output_set_digit_value(1, led_map[state->m_led1_value >> 4]);
940   output_set_digit_value(2, led_map[state->m_led1_value & 0x0f]);
924   output_set_digit_value(1, led_map[m_led1_value >> 4]);
925   output_set_digit_value(2, led_map[m_led1_value & 0x0f]);
941926
942927   /* LED2 */
943   output_set_digit_value(3, led_map[state->m_led2_value >> 4]);
944   output_set_digit_value(4, led_map[state->m_led2_value & 0x0f]);
928   output_set_digit_value(3, led_map[m_led2_value >> 4]);
929   output_set_digit_value(4, led_map[m_led2_value & 0x0f]);
945930}
946931
947932
948static void set_output_latch( running_machine &machine, UINT8 data )
933void neogeo_state::set_output_latch( UINT8 data )
949934{
950   neogeo_state *state = machine.driver_data<neogeo_state>();
951
952935   /* looks like the LEDs are set on the
953936      falling edge */
954   UINT8 falling_bits = state->m_output_latch & ~data;
937   UINT8 falling_bits = m_output_latch & ~data;
955938
956939   if (falling_bits & 0x08)
957      state->m_el_value = 16 - (state->m_output_data & 0x0f);
940      m_el_value = 16 - (m_output_data & 0x0f);
958941
959942   if (falling_bits & 0x10)
960      state->m_led1_value = ~state->m_output_data;
943      m_led1_value = ~m_output_data;
961944
962945   if (falling_bits & 0x20)
963      state->m_led2_value = ~state->m_output_data;
946      m_led2_value = ~m_output_data;
964947
965948   if (falling_bits & 0xc7)
966      logerror("%s  Unmaped LED write.  Data: %x\n", machine.describe_context(), falling_bits);
949      logerror("%s  Unmaped LED write.  Data: %x\n", machine().describe_context(), falling_bits);
967950
968   state->m_output_latch = data;
951   m_output_latch = data;
969952
970   set_outputs(machine);
953   set_outputs();
971954}
972955
973956
974static void set_output_data( running_machine &machine, UINT8 data )
957void neogeo_state::set_output_data( UINT8 data )
975958{
976   neogeo_state *state = machine.driver_data<neogeo_state>();
977   state->m_output_data = data;
959   m_output_data = data;
978960}
979961
980962
r20971r20972
991973   _set_main_cpu_vector_table_source();
992974   set_audio_cpu_banking();
993975   _set_audio_cpu_rom_source();
994   if (m_is_mvs) set_outputs(machine());
976   if (m_is_mvs) set_outputs();
995977}
996978
997979
trunk/src/mame/drivers/nbmj9195.c
r20971r20972
5252   soundlatch_clear_byte_w(space, 0, 0);
5353}
5454
55static void nbmj9195_outcoin_flag_w(address_space &space, int data)
55void nbmj9195_state::nbmj9195_outcoin_flag_w(int data)
5656{
57   nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>();
5857   // bit0: coin in counter
5958   // bit1: coin out counter
6059   // bit2: hopper
6160   // bit3: coin lockout
6261
63   if (data & 0x04) state->m_outcoin_flag ^= 1;
64   else state->m_outcoin_flag = 1;
62   if (data & 0x04) m_outcoin_flag ^= 1;
63   else m_outcoin_flag = 1;
6564}
6665
6766WRITE8_MEMBER(nbmj9195_state::nbmj9195_inputportsel_w)
r20971r20972
6968   m_inputport = (data ^ 0xff);
7069}
7170
72static int nbmj9195_dipsw_r(running_machine &machine)
71int nbmj9195_state::nbmj9195_dipsw_r()
7372{
74   nbmj9195_state *state = machine.driver_data<nbmj9195_state>();
75   return (((state->ioport("DSWA")->read() & 0xff) | ((state->ioport("DSWB")->read() & 0xff) << 8)) >> state->m_dipswbitsel) & 0x01;
73   return (((ioport("DSWA")->read() & 0xff) | ((ioport("DSWB")->read() & 0xff) << 8)) >> m_dipswbitsel) & 0x01;
7674}
7775
78static void nbmj9195_dipswbitsel_w(address_space &space, int data)
76void nbmj9195_state::nbmj9195_dipswbitsel_w(int data)
7977{
80   nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>();
8178   switch (data & 0xc0)
8279   {
8380      case 0x00:
84         state->m_dipswbitsel = 0;
81         m_dipswbitsel = 0;
8582         break;
8683      case 0x40:
8784         break;
8885      case 0x80:
8986         break;
9087      case 0xc0:
91         state->m_dipswbitsel = ((state->m_dipswbitsel + 1) & 0x0f);
88         m_dipswbitsel = ((m_dipswbitsel + 1) & 0x0f);
9289         break;
9390      default:
9491         break;
9592   }
9693}
9794
98static void mscoutm_inputportsel_w(address_space &space, int data)
95void nbmj9195_state::mscoutm_inputportsel_w( int data)
9996{
100   nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>();
101   state->m_mscoutm_inputport = (data ^ 0xff);
97   m_mscoutm_inputport = (data ^ 0xff);
10298}
10399
104100READ8_MEMBER(nbmj9195_state::mscoutm_dipsw_0_r)
r20971r20972
241237                  portdata = ioport("KEY3")->read();
242238                  break;
243239               case 0x10:
244                  portdata = ((ioport("KEY4")->read() & 0x7f) | (nbmj9195_dipsw_r(machine()) << 7));
240                  portdata = ((ioport("KEY4")->read() & 0x7f) | (nbmj9195_dipsw_r() << 7));
245241                  break;
246242               default:
247243                  portdata = (ioport("KEY0")->read() & ioport("KEY1")->read() & ioport("KEY2")->read() & ioport("KEY3")->read() & (ioport("KEY4")->read() & 0x7f));
r20971r20972
314310      switch (offset)
315311      {
316312         case 0:         /* PA_0 */
317            mscoutm_inputportsel_w(space, data);    // NB22090
313            mscoutm_inputportsel_w(data);    // NB22090
318314            break;
319315         case 1:         /* PB_0 */
320316            break;
321317         case 2:         /* PC_0 */
322318            break;
323319         case 3:         /* PD_0 */
324            nbmj9195_clutsel_w(space, data);
320            nbmj9195_clutsel_w(data);
325321            break;
326322         case 4:         /* PE_0 */
327            nbmj9195_gfxflag2_w(space, data);       // NB22090
323            nbmj9195_gfxflag2_w(data);       // NB22090
328324            break;
329325
330326         case 5:         /* PA_1 */
r20971r20972
356352         case 1:         /* PB_0 */
357353            break;
358354         case 2:         /* PC_0 */
359            nbmj9195_dipswbitsel_w(space, data);
355            nbmj9195_dipswbitsel_w(data);
360356            break;
361357         case 3:         /* PD_0 */
362            nbmj9195_clutsel_w(space, data);
358            nbmj9195_clutsel_w(data);
363359            break;
364360         case 4:         /* PE_0 */
365            nbmj9195_outcoin_flag_w(space, data);
361            nbmj9195_outcoin_flag_w(data);
366362            break;
367363
368364         case 5:         /* PA_1 */
trunk/src/mame/drivers/nova2001.c
r20971r20972
977977
978978******************************************************************************/
979979
980static void lineswap_gfx_roms(running_machine &machine, const char *region, const int bit)
980void nova2001_state::lineswap_gfx_roms(const char *region, const int bit)
981981{
982   const int length = machine.root_device().memregion(region)->bytes();
982   const int length = machine().root_device().memregion(region)->bytes();
983983
984   UINT8* const src = machine.root_device().memregion(region)->base();
984   UINT8* const src = machine().root_device().memregion(region)->base();
985985
986   UINT8* const temp = auto_alloc_array(machine, UINT8, length);
986   UINT8* const temp = auto_alloc_array(machine(), UINT8, length);
987987
988988   const int mask = (1 << (bit + 1)) - 1;
989989
r20971r20972
998998
999999   memcpy(src, temp, length);
10001000
1001   auto_free(machine, temp);
1001   auto_free(machine(), temp);
10021002}
10031003
10041004
r20971r20972
10111011
10121012DRIVER_INIT_MEMBER(nova2001_state,pkunwar)
10131013{
1014   lineswap_gfx_roms(machine(), "gfx1", 13);
1014   lineswap_gfx_roms("gfx1", 13);
10151015}
10161016
10171017DRIVER_INIT_MEMBER(nova2001_state,raiders5)
10181018{
1019   lineswap_gfx_roms(machine(), "gfx1", 13);
1020   lineswap_gfx_roms(machine(), "gfx2", 13);
1019   lineswap_gfx_roms("gfx1", 13);
1020   lineswap_gfx_roms("gfx2", 13);
10211021}
10221022
10231023
trunk/src/mame/drivers/nmk16.c
r20971r20972
727727}
728728
729729/*coin setting MCU simulation*/
730static void mcu_run(running_machine &machine, UINT8 dsw_setting)
730void nmk16_state::mcu_run(UINT8 dsw_setting)
731731{
732   nmk16_state *state = machine.driver_data<nmk16_state>();
733732   UINT16 coin_input;
734733   UINT8 dsw[2];
735734   UINT8 i;
736735
737736   /*Accept the start button but needs some m68k processing first,otherwise you can't start a play with 1 credit inserted*/
738   if(state->m_start_helper & 1 && state->m_mainram[0x9000/2] & 0x0200) /*start 1 */
737   if(m_start_helper & 1 && m_mainram[0x9000/2] & 0x0200) /*start 1 */
739738   {
740      state->m_mainram[0xef00/2]--;
741      state->m_start_helper = state->m_start_helper & 2;
739      m_mainram[0xef00/2]--;
740      m_start_helper = m_start_helper & 2;
742741   }
743   if(state->m_start_helper & 2 && state->m_mainram[0x9000/2] & 0x0100) /*start 2*/
742   if(m_start_helper & 2 && m_mainram[0x9000/2] & 0x0100) /*start 2*/
744743   {
745      state->m_mainram[0xef00/2]--;
746      state->m_start_helper = state->m_start_helper & 1;
744      m_mainram[0xef00/2]--;
745      m_start_helper = m_start_helper & 1;
747746   }
748747
749748   /*needed because of the uncompatibility of the dsw settings.*/
750749   if(dsw_setting) // Thunder Dragon
751750   {
752      dsw[0] = (machine.root_device().ioport("DSW2")->read() & 0x7);
753      dsw[1] = (machine.root_device().ioport("DSW2")->read() & 0x38) >> 3;
751      dsw[0] = (machine().root_device().ioport("DSW2")->read() & 0x7);
752      dsw[1] = (machine().root_device().ioport("DSW2")->read() & 0x38) >> 3;
754753      for(i=0;i<2;i++)
755754      {
756755         switch(dsw[i] & 7)
757756         {
758            case 0: state->m_mainram[0x9000/2]|=0x4000; break; //free play
759            case 1: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 4; break;
760            case 2: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 3; break;
761            case 3: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 2; break;
762            case 4: state->m_coin_count_frac[i] = 4; state->m_coin_count[i] = 1; break;
763            case 5: state->m_coin_count_frac[i] = 3; state->m_coin_count[i] = 1; break;
764            case 6: state->m_coin_count_frac[i] = 2; state->m_coin_count[i] = 1; break;
765            case 7: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 1; break;
757            case 0: m_mainram[0x9000/2]|=0x4000; break; //free play
758            case 1: m_coin_count_frac[i] = 1; m_coin_count[i] = 4; break;
759            case 2: m_coin_count_frac[i] = 1; m_coin_count[i] = 3; break;
760            case 3: m_coin_count_frac[i] = 1; m_coin_count[i] = 2; break;
761            case 4: m_coin_count_frac[i] = 4; m_coin_count[i] = 1; break;
762            case 5: m_coin_count_frac[i] = 3; m_coin_count[i] = 1; break;
763            case 6: m_coin_count_frac[i] = 2; m_coin_count[i] = 1; break;
764            case 7: m_coin_count_frac[i] = 1; m_coin_count[i] = 1; break;
766765         }
767766      }
768767   }
769768   else // Hacha Mecha Fighter
770769   {
771      dsw[0] = (machine.root_device().ioport("DSW1")->read() & 0x0700) >> 8;
772      dsw[1] = (machine.root_device().ioport("DSW1")->read() & 0x3800) >> 11;
770      dsw[0] = (machine().root_device().ioport("DSW1")->read() & 0x0700) >> 8;
771      dsw[1] = (machine().root_device().ioport("DSW1")->read() & 0x3800) >> 11;
773772      for(i=0;i<2;i++)
774773      {
775774         switch(dsw[i] & 7)
776775         {
777            case 0: state->m_mainram[0x9000/2]|=0x4000; break; //free play
778            case 1: state->m_coin_count_frac[i] = 4; state->m_coin_count[i] = 1; break;
779            case 2: state->m_coin_count_frac[i] = 3; state->m_coin_count[i] = 1; break;
780            case 3: state->m_coin_count_frac[i] = 2; state->m_coin_count[i] = 1; break;
781            case 4: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 4; break;
782            case 5: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 3; break;
783            case 6: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 2; break;
784            case 7: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 1; break;
776            case 0: m_mainram[0x9000/2]|=0x4000; break; //free play
777            case 1: m_coin_count_frac[i] = 4; m_coin_count[i] = 1; break;
778            case 2: m_coin_count_frac[i] = 3; m_coin_count[i] = 1; break;
779            case 3: m_coin_count_frac[i] = 2; m_coin_count[i] = 1; break;
780            case 4: m_coin_count_frac[i] = 1; m_coin_count[i] = 4; break;
781            case 5: m_coin_count_frac[i] = 1; m_coin_count[i] = 3; break;
782            case 6: m_coin_count_frac[i] = 1; m_coin_count[i] = 2; break;
783            case 7: m_coin_count_frac[i] = 1; m_coin_count[i] = 1; break;
785784         }
786785      }
787786   }
788787
789788   /*read the coin port*/
790   coin_input = (~(machine.root_device().ioport("IN0")->read()));
789   coin_input = (~(machine().root_device().ioport("IN0")->read()));
791790
792791   if(coin_input & 0x01)//coin 1
793792   {
794      if((state->m_input_pressed & 0x01) == 0)
793      if((m_input_pressed & 0x01) == 0)
795794      {
796         if(state->m_coin_count_frac[0] != 1)
795         if(m_coin_count_frac[0] != 1)
797796         {
798            state->m_mainram[0xef02/2]+=state->m_coin_count[0];
799            if(state->m_coin_count_frac[0] == state->m_mainram[0xef02/2])
797            m_mainram[0xef02/2]+=m_coin_count[0];
798            if(m_coin_count_frac[0] == m_mainram[0xef02/2])
800799            {
801               state->m_mainram[0xef00/2]+=state->m_coin_count[0];
802               state->m_mainram[0xef02/2] = 0;
800               m_mainram[0xef00/2]+=m_coin_count[0];
801               m_mainram[0xef02/2] = 0;
803802            }
804803         }
805804         else
806            state->m_mainram[0xef00/2]+=state->m_coin_count[0];
805            m_mainram[0xef00/2]+=m_coin_count[0];
807806      }
808      state->m_input_pressed = (state->m_input_pressed & 0xfe) | 1;
807      m_input_pressed = (m_input_pressed & 0xfe) | 1;
809808   }
810809   else
811      state->m_input_pressed = (state->m_input_pressed & 0xfe);
810      m_input_pressed = (m_input_pressed & 0xfe);
812811
813812   if(coin_input & 0x02)//coin 2
814813   {
815      if((state->m_input_pressed & 0x02) == 0)
814      if((m_input_pressed & 0x02) == 0)
816815      {
817         if(state->m_coin_count_frac[1] != 1)
816         if(m_coin_count_frac[1] != 1)
818817         {
819            state->m_mainram[0xef02/2]+=state->m_coin_count[1];
820            if(state->m_coin_count_frac[1] == state->m_mainram[0xef02/2])
818            m_mainram[0xef02/2]+=m_coin_count[1];
819            if(m_coin_count_frac[1] == m_mainram[0xef02/2])
821820            {
822               state->m_mainram[0xef00/2]+=state->m_coin_count[1];
823               state->m_mainram[0xef02/2] = 0;
821               m_mainram[0xef00/2]+=m_coin_count[1];
822               m_mainram[0xef02/2] = 0;
824823            }
825824         }
826825         else
827            state->m_mainram[0xef00/2]+=state->m_coin_count[1];
826            m_mainram[0xef00/2]+=m_coin_count[1];
828827      }
829      state->m_input_pressed = (state->m_input_pressed & 0xfd) | 2;
828      m_input_pressed = (m_input_pressed & 0xfd) | 2;
830829   }
831830   else
832      state->m_input_pressed = (state->m_input_pressed & 0xfd);
831      m_input_pressed = (m_input_pressed & 0xfd);
833832
834833   if(coin_input & 0x04)//service 1
835834   {
836      if((state->m_input_pressed & 0x04) == 0)
837         state->m_mainram[0xef00/2]++;
838      state->m_input_pressed = (state->m_input_pressed & 0xfb) | 4;
835      if((m_input_pressed & 0x04) == 0)
836         m_mainram[0xef00/2]++;
837      m_input_pressed = (m_input_pressed & 0xfb) | 4;
839838   }
840839   else
841      state->m_input_pressed = (state->m_input_pressed & 0xfb);
840      m_input_pressed = (m_input_pressed & 0xfb);
842841
843842   /*The 0x9000 ram address is the status */
844   if(state->m_mainram[0xef00/2] > 0 && state->m_mainram[0x9000/2] & 0x8000) //enable start button
843   if(m_mainram[0xef00/2] > 0 && m_mainram[0x9000/2] & 0x8000) //enable start button
845844   {
846845      if(coin_input & 0x08)//start 1
847846      {
848         if((state->m_input_pressed & 0x08) == 0 && (!(state->m_mainram[0x9000/2] & 0x0200))) //start 1
849            state->m_start_helper = 1;
847         if((m_input_pressed & 0x08) == 0 && (!(m_mainram[0x9000/2] & 0x0200))) //start 1
848            m_start_helper = 1;
850849
851         state->m_input_pressed = (state->m_input_pressed & 0xf7) | 8;
850         m_input_pressed = (m_input_pressed & 0xf7) | 8;
852851      }
853852      else
854         state->m_input_pressed = (state->m_input_pressed & 0xf7);
853         m_input_pressed = (m_input_pressed & 0xf7);
855854
856855      if(coin_input & 0x10)//start 2
857856      {
858857         /*Decrease two coins to let two players play with one start 2 button and two credits inserted at the insert coin screen.*/
859         if((state->m_input_pressed & 0x10) == 0 && (!(state->m_mainram[0x9000/2] & 0x0100))) // start 2
860            state->m_start_helper = (state->m_mainram[0x9000/2] == 0x8000) ? (3) : (2);
858         if((m_input_pressed & 0x10) == 0 && (!(m_mainram[0x9000/2] & 0x0100))) // start 2
859            m_start_helper = (m_mainram[0x9000/2] == 0x8000) ? (3) : (2);
861860
862         state->m_input_pressed = (state->m_input_pressed & 0xef) | 0x10;
861         m_input_pressed = (m_input_pressed & 0xef) | 0x10;
863862      }
864863      else
865         state->m_input_pressed = (state->m_input_pressed & 0xef);
864         m_input_pressed = (m_input_pressed & 0xef);
866865   }
867866}
868867
869868TIMER_DEVICE_CALLBACK_MEMBER(nmk16_state::tdragon_mcu_sim)
870869{
871   mcu_run(machine(),1);
870   mcu_run(1);
872871}
873872
874873TIMER_DEVICE_CALLBACK_MEMBER(nmk16_state::hachamf_mcu_sim)
875874{
876   mcu_run(machine(),0);
875   mcu_run(0);
877876}
878877
879878static ADDRESS_MAP_START( tdragon_map, AS_PROGRAM, 16, nmk16_state )
r20971r20972
43434342MACHINE_CONFIG_END
43444343
43454344
4346static UINT8 decode_byte(UINT8 src, const UINT8 *bitp)
4345UINT8 nmk16_state::decode_byte(UINT8 src, const UINT8 *bitp)
43474346{
43484347   UINT8 ret, i;
43494348
r20971r20972
43544353   return ret;
43554354}
43564355
4357static UINT32 bjtwin_address_map_bg0(UINT32 addr)
4356UINT32 nmk16_state::bjtwin_address_map_bg0(UINT32 addr)
43584357{
43594358   return ((addr&0x00004)>> 2) | ((addr&0x00800)>> 10) | ((addr&0x40000)>>16);
43604359}
43614360
43624361
4363static UINT16 decode_word(UINT16 src, const UINT8 *bitp)
4362UINT16 nmk16_state::decode_word(UINT16 src, const UINT8 *bitp)
43644363{
43654364   UINT16 ret, i;
43664365
r20971r20972
43724371}
43734372
43744373
4375static UINT32 bjtwin_address_map_sprites(UINT32 addr)
4374UINT32 nmk16_state::bjtwin_address_map_sprites(UINT32 addr)
43764375{
43774376   return ((addr&0x00010)>> 4) | ((addr&0x20000)>>16) | ((addr&0x100000)>>18);
43784377}
43794378
43804379
4381static void decode_gfx(running_machine &machine)
4380void nmk16_state::decode_gfx()
43824381{
43834382   /* GFX are scrambled.  We decode them here.  (BIG Thanks to Antiriad for descrambling info) */
43844383   UINT8 *rom;
r20971r20972
44114410
44124411
44134412   /* background */
4414   rom = machine.root_device().memregion("gfx2")->base();
4415   len = machine.root_device().memregion("gfx2")->bytes();
4413   rom = machine().root_device().memregion("gfx2")->base();
4414   len = machine().root_device().memregion("gfx2")->bytes();
44164415   for (A = 0;A < len;A++)
44174416   {
44184417      rom[A] = decode_byte( rom[A], decode_data_bg[bjtwin_address_map_bg0(A)]);
44194418   }
44204419
44214420   /* sprites */
4422   rom = machine.root_device().memregion("gfx3")->base();
4423   len = machine.root_device().memregion("gfx3")->bytes();
4421   rom = machine().root_device().memregion("gfx3")->base();
4422   len = machine().root_device().memregion("gfx3")->bytes();
44244423   for (A = 0;A < len;A += 2)
44254424   {
44264425      UINT16 tmp = decode_word( rom[A+1]*256 + rom[A], decode_data_sprite[bjtwin_address_map_sprites(A)]);
r20971r20972
44294428   }
44304429}
44314430
4432static void decode_tdragonb(running_machine &machine)
4431void nmk16_state::decode_tdragonb()
44334432{
44344433   /* Descrambling Info Again Taken from Raine, Huge Thanks to Antiriad and the Raine Team for
44354434      going Open Source, best of luck in future development. */
r20971r20972
44494448      {0x7,0x6,0x5,0x3,0x4,0x2,0x1,0x0},
44504449   };
44514450
4452   rom = machine.root_device().memregion("maincpu")->base();
4453   len = machine.root_device().memregion("maincpu")->bytes();
4451   rom = machine().root_device().memregion("maincpu")->base();
4452   len = machine().root_device().memregion("maincpu")->bytes();
44544453   for (A = 0;A < len;A += 2)
44554454   {
44564455      int h = A+NATIVE_ENDIAN_VALUE_LE_BE(1,0), l = A+NATIVE_ENDIAN_VALUE_LE_BE(0,1);
r20971r20972
44594458      rom[l] = tmp & 0xff;
44604459   }
44614460
4462   rom = machine.root_device().memregion("gfx2")->base();
4463   len = machine.root_device().memregion("gfx2")->bytes();
4461   rom = machine().root_device().memregion("gfx2")->base();
4462   len = machine().root_device().memregion("gfx2")->bytes();
44644463   for (A = 0;A < len;A++)
44654464   {
44664465      rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]);
44674466   }
44684467
4469   rom = machine.root_device().memregion("gfx3")->base();
4470   len = machine.root_device().memregion("gfx3")->bytes();
4468   rom = machine().root_device().memregion("gfx3")->base();
4469   len = machine().root_device().memregion("gfx3")->bytes();
44714470   for (A = 0;A < len;A++)
44724471   {
44734472      rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]);
44744473   }
44754474}
44764475
4477static void decode_ssmissin(running_machine &machine)
4476void nmk16_state::decode_ssmissin()
44784477{
44794478   /* Like Thunder Dragon Bootleg without the Program Rom Swapping */
44804479   UINT8 *rom;
r20971r20972
44864485      {0x7,0x6,0x5,0x3,0x4,0x2,0x1,0x0},
44874486   };
44884487
4489   rom = machine.root_device().memregion("gfx2")->base();
4490   len = machine.root_device().memregion("gfx2")->bytes();
4488   rom = machine().root_device().memregion("gfx2")->base();
4489   len = machine().root_device().memregion("gfx2")->bytes();
44914490   for (A = 0;A < len;A++)
44924491   {
44934492      rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]);
44944493   }
44954494
4496   rom = machine.root_device().memregion("gfx3")->base();
4497   len = machine.root_device().memregion("gfx3")->bytes();
4495   rom = machine().root_device().memregion("gfx3")->base();
4496   len = machine().root_device().memregion("gfx3")->bytes();
44984497   for (A = 0;A < len;A++)
44994498   {
45004499      rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]);
r20971r20972
45044503
45054504DRIVER_INIT_MEMBER(nmk16_state,nmk)
45064505{
4507   decode_gfx(machine());
4506   decode_gfx();
45084507}
45094508
45104509DRIVER_INIT_MEMBER(nmk16_state,hachamf)
r20971r20972
45204519
45214520DRIVER_INIT_MEMBER(nmk16_state,tdragonb)
45224521{
4523   decode_tdragonb(machine());
4522   decode_tdragonb();
45244523}
45254524
45264525DRIVER_INIT_MEMBER(nmk16_state,tdragon)
r20971r20972
45374536
45384537DRIVER_INIT_MEMBER(nmk16_state,ssmissin)
45394538{
4540   decode_ssmissin(machine());
4539   decode_ssmissin();
45414540}
45424541
45434542DRIVER_INIT_MEMBER(nmk16_state,bjtwin)
trunk/src/mame/drivers/ninjakd2.c
r20971r20972
14161416
14171417******************************************************************************/
14181418
1419static void lineswap_gfx_roms(running_machine &machine, const char *region, const int bit)
1419void ninjakd2_state::lineswap_gfx_roms(const char *region, const int bit)
14201420{
1421   const int length = machine.root_device().memregion(region)->bytes();
1422   UINT8* const src = machine.root_device().memregion(region)->base();
1423   UINT8* const temp = auto_alloc_array(machine, UINT8, length);
1421   const int length = machine().root_device().memregion(region)->bytes();
1422   UINT8* const src = machine().root_device().memregion(region)->base();
1423   UINT8* const temp = auto_alloc_array(machine(), UINT8, length);
14241424   const int mask = (1 << (bit + 1)) - 1;
14251425
14261426   for (int sa = 0; sa < length; sa++)
r20971r20972
14301430   }
14311431
14321432   memcpy(src, temp, length);
1433   auto_free(machine, temp);
1433   auto_free(machine(), temp);
14341434}
14351435
1436static void gfx_unscramble(running_machine &machine)
1436void ninjakd2_state::gfx_unscramble()
14371437{
1438   lineswap_gfx_roms(machine, "gfx1", 13);     // fg tiles
1439   lineswap_gfx_roms(machine, "gfx2", 14);     // sprites
1440   lineswap_gfx_roms(machine, "gfx3", 14);     // bg tiles
1438   lineswap_gfx_roms("gfx1", 13);     // fg tiles
1439   lineswap_gfx_roms("gfx2", 14);     // sprites
1440   lineswap_gfx_roms("gfx3", 14);     // bg tiles
14411441}
14421442
14431443
r20971r20972
14451445{
14461446   mc8123_decrypt_rom(machine(), "soundcpu", "user1", NULL, 0);
14471447
1448   gfx_unscramble(machine());
1448   gfx_unscramble();
14491449}
14501450
14511451DRIVER_INIT_MEMBER(ninjakd2_state,bootleg)
r20971r20972
14531453   address_space &space = machine().device("soundcpu")->memory().space(AS_PROGRAM);
14541454   space.set_decrypted_region(0x0000, 0x7fff, machine().root_device().memregion("soundcpu")->base() + 0x10000);
14551455
1456   gfx_unscramble(machine());
1456   gfx_unscramble();
14571457}
14581458
14591459DRIVER_INIT_MEMBER(ninjakd2_state,mnight)
14601460{
1461   gfx_unscramble(machine());
1461   gfx_unscramble();
14621462}
14631463
14641464/*****************************************************************************/
trunk/src/mame/audio/n8080.c
r20971r20972
275275   {
276276      if (data & ~state->m_prev_snd_data & 0x10)
277277      {
278         spacefev_start_red_cannon(machine);
278         state->spacefev_start_red_cannon();
279279      }
280280
281281      state->m_spacefev_red_screen = data & 0x08;
trunk/src/mame/machine/nitedrvr.c
r20971r20972
1818change in-between can affect the direction you move.
1919***************************************************************************/
2020
21static int nitedrvr_steering( running_machine &machine )
21int nitedrvr_state::nitedrvr_steering( )
2222{
23   nitedrvr_state *state = machine.driver_data<nitedrvr_state>();
24   int this_val = state->ioport("STEER")->read();
25   int delta = this_val - state->m_last_steering_val;
23   int this_val = ioport("STEER")->read();
24   int delta = this_val - m_last_steering_val;
2625
27   state->m_last_steering_val = this_val;
26   m_last_steering_val = this_val;
2827
2928   if (delta > 128)
3029      delta -= 256;
r20971r20972
3231      delta += 256;
3332
3433   /* Divide by four to make our steering less sensitive */
35   state->m_steering_buf += (delta / 4);
34   m_steering_buf += (delta / 4);
3635
37   if (state->m_steering_buf > 0)
36   if (m_steering_buf > 0)
3837   {
39      state->m_steering_buf--;
40      state->m_steering_val = 0xc0;
38      m_steering_buf--;
39      m_steering_val = 0xc0;
4140   }
42   else if (state->m_steering_buf < 0)
41   else if (m_steering_buf < 0)
4342   {
44      state->m_steering_buf++;
45      state->m_steering_val = 0x80;
43      m_steering_buf++;
44      m_steering_val = 0x80;
4645   }
4746   else
4847   {
49      state->m_steering_val = 0x00;
48      m_steering_val = 0x00;
5049   }
5150
52   return state->m_steering_val;
51   return m_steering_val;
5352}
5453
5554/***************************************************************************
r20971r20972
121120         else
122121            return 0x70;
123122      case 0x03:                      /* Remap our steering */
124         return (ioport("DSW2")->read() | nitedrvr_steering(machine()));
123         return (ioport("DSW2")->read() | nitedrvr_steering());
125124      default:
126125         return 0xff;
127126   }
trunk/src/mame/includes/ninjakd2.h
r20971r20972
9797   UINT32 screen_update_omegaf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9898   void screen_eof_ninjakd2(screen_device &screen, bool state);
9999   INTERRUPT_GEN_MEMBER(ninjakd2_interrupt);
100   void robokid_get_bg_tile_info( tile_data& tileinfo, tilemap_memory_index const tile_index, int const gfxnum, const UINT8* const videoram);
101   void bg_ctrl(int offset, int data, tilemap_t* tilemap);
102   void draw_sprites( bitmap_ind16 &bitmap);
103   void erase_sprites( bitmap_ind16 &bitmap);
104   void update_sprites();
105   void lineswap_gfx_roms(const char *region, const int bit);
106   void gfx_unscramble();
100107};
trunk/src/mame/includes/nbmj8891.h
r20971r20972
7575   DECLARE_VIDEO_START(nbmj8891_1layer);
7676   UINT32 screen_update_nbmj8891(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7777   TIMER_CALLBACK_MEMBER(blitter_timer_callback);
78   void nbmj8891_vramflip(int vram);
79   void update_pixel0(int x, int y);
80   void update_pixel1(int x, int y);
81   void nbmj8891_gfxdraw();
7882};
trunk/src/mame/includes/nbmj8688.h
r20971r20972
9191   UINT32 screen_update_mbmj8688_lcd0(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9292   UINT32 screen_update_mbmj8688_lcd1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9393   TIMER_CALLBACK_MEMBER(blitter_timer_callback);
94   void update_pixel(int x, int y);
95   void writeram_low(int x, int y, int color);
96   void writeram_high(int x, int y, int color);
97   void mbmj8688_gfxdraw(int gfxtype);
98   void common_video_start();
99   void nbmj8688_HD61830B_instr_w(address_space &space,int offset,int data,int chip);
100   void nbmj8688_HD61830B_data_w(address_space &space,int offset,int data,int chip);
94101};
trunk/src/mame/includes/neogeo.h
r20971r20972
291291   void _set_main_cpu_vector_table_source();
292292   void optimize_sprite_data();
293293   void draw_fixed_layer( bitmap_rgb32 &bitmap, int scanline );
294   void set_videoram_offset( UINT16 data );
295   UINT16 get_videoram_data(  );
296   void set_videoram_data( UINT16 data);
297   void set_videoram_modulo( UINT16 data);
298   UINT16 get_videoram_modulo(  );
299   void compute_rgb_weights(  );
300   pen_t get_pen( UINT16 data );
301   void neogeo_set_palette_bank( UINT8 data );
302   void neogeo_set_screen_dark( UINT8 data );
303   void set_auto_animation_speed( UINT8 data);
304   void set_auto_animation_disabled( UINT8 data);
305   UINT8 neogeo_get_auto_animation_counter(  );
306   void create_auto_animation_timer(  );
307   void start_auto_animation_timer(  );
308   void neogeo_set_fixed_layer_source( UINT8 data );
309   inline int rows_to_height(int rows);
310   inline int sprite_on_scanline(int scanline, int y, int rows);
311   void draw_sprites( bitmap_rgb32 &bitmap, int scanline );
312   void parse_sprites( int scanline );
313   void create_sprite_line_timer(  );
314   void start_sprite_line_timer(  );
315   UINT16 get_video_control(  );
316   void audio_cpu_assert_nmi();
317   void select_controller( UINT8 data );
318   void set_save_ram_unlock( UINT8 data );
319   void set_outputs(  );
320   void set_output_latch( UINT8 data );
321   void set_output_data( UINT8 data );
294322};
295323
296324
r20971r20972
383411void samsho5b_vx_decrypt(running_machine &machine);
384412void matrimbl_decrypt(running_machine &machine);
385413
386/*----------- defined in video/neogeo.c -----------*/
387
388void neogeo_set_palette_bank(running_machine &machine, UINT8 data);
389void neogeo_set_screen_dark(running_machine &machine, UINT8 data);
390
391void neogeo_set_fixed_layer_source(running_machine &machine, UINT8 data);
392
393UINT8 neogeo_get_auto_animation_counter(running_machine &machine);
trunk/src/mame/includes/nbmj8991.h
r20971r20972
5454   UINT32 screen_update_nbmj8991_type1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   UINT32 screen_update_nbmj8991_type2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5656   TIMER_CALLBACK_MEMBER(blitter_timer_callback);
57   void nbmj8991_vramflip();
58   void update_pixel(int x, int y);
59   void nbmj8991_gfxdraw();
5760};
trunk/src/mame/includes/nbmj8900.h
r20971r20972
4646   virtual void video_start();
4747   UINT32 screen_update_nbmj8900(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4848   TIMER_CALLBACK_MEMBER(blitter_timer_callback);
49   void nbmj8900_vramflip(int vram);
50   void update_pixel0(int x, int y);
51   void update_pixel1(int x, int y);
52   void nbmj8900_gfxdraw();
4953};
trunk/src/mame/includes/n8080.h
r20971r20972
8686   TIMER_DEVICE_CALLBACK_MEMBER(rst2_tick);
8787   TIMER_DEVICE_CALLBACK_MEMBER(spacefev_vco_voltage_timer);
8888   TIMER_DEVICE_CALLBACK_MEMBER(helifire_dac_volume_timer);
89   void spacefev_start_red_cannon(  );
90   void helifire_next_line(  );
8991};
9092
91/*----------- defined in video/n8080.c -----------*/
92void spacefev_start_red_cannon(running_machine &machine);
93
9493/*----------- defined in audio/n8080.c -----------*/
9594
9695MACHINE_CONFIG_EXTERN( spacefev_sound );
trunk/src/mame/includes/ninjaw.h
r20971r20972
4949   UINT32 screen_update_ninjaw_middle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5050   UINT32 screen_update_ninjaw_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5151   void ninjaw_postload();
52   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int x_offs, int y_offs );
53   void parse_control(  )   /* assumes Z80 sandwiched between 68Ks */;
54   void reset_sound_region(  );
55   UINT32 update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffs, device_t *tc0100scn);
5256};
trunk/src/mame/includes/nemesis.h
r20971r20972
9090   TIMER_DEVICE_CALLBACK_MEMBER(konamigt_interrupt);
9191   TIMER_DEVICE_CALLBACK_MEMBER(gx400_interrupt);
9292   void nemesis_postload();
93   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
9394};
trunk/src/mame/includes/nitedrvr.h
r20971r20972
5959   virtual void video_start();
6060   UINT32 screen_update_nitedrvr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6161   TIMER_DEVICE_CALLBACK_MEMBER(nitedrvr_crash_toggle_callback);
62   void draw_box( bitmap_ind16 &bitmap, int bx, int by, int ex, int ey );
63   void draw_roadway( bitmap_ind16 &bitmap );
64   int nitedrvr_steering(  );
6265};
6366
6467/*----------- defined in audio/nitedrvr.c -----------*/
trunk/src/mame/includes/nycaptor.h
r20971r20972
105105   DECLARE_MACHINE_RESET(ta7630);
106106   UINT32 screen_update_nycaptor(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
107107   TIMER_CALLBACK_MEMBER(nmi_callback);
108   int nycaptor_spot(  );
109   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri );
110   void nycaptor_setmask(  );
108111};
trunk/src/mame/includes/nbmj9195.h
r20971r20972
113113   UINT32 screen_update_nbmj9195(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
114114   INTERRUPT_GEN_MEMBER(ctc0_trg1);
115115   TIMER_CALLBACK_MEMBER(blitter_timer_callback);
116   int nbmj9195_blitter_r(int offset, int vram);
117   void nbmj9195_blitter_w(int offset, int data, int vram);
118   void nbmj9195_clutsel_w(int data);
119   void nbmj9195_clut_w(int offset, int data, int vram);
120   void nbmj9195_gfxflag2_w(int data);
121   void nbmj9195_vramflip(int vram);
122   void update_pixel(int vram, int x, int y);
123   void nbmj9195_gfxdraw(int vram);
124   void nbmj9195_outcoin_flag_w(int data);
125   int nbmj9195_dipsw_r();
126   void nbmj9195_dipswbitsel_w(int data);
127   void mscoutm_inputportsel_w(int data);
116128};
117
118/*----------- defined in video/nbmj9195.c -----------*/
119void nbmj9195_clutsel_w(address_space &space, int data);
120void nbmj9195_gfxflag2_w(address_space &space, int data);
trunk/src/mame/includes/niyanpai.h
r20971r20972
8282   UINT32 screen_update_niyanpai(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8383   INTERRUPT_GEN_MEMBER(niyanpai_interrupt);
8484   TIMER_CALLBACK_MEMBER(blitter_timer_callback);
85   int niyanpai_blitter_r(int vram, int offset);
86   void niyanpai_blitter_w(int vram, int offset, int data);
87   void niyanpai_clutsel_w(int vram, int data);
88   void niyanpai_clut_w(int vram, int offset, int data);
89   void niyanpai_vramflip(int vram);
90   void update_pixel(int vram, int x, int y);
91   void niyanpai_gfxdraw(int vram);
92   void niyanpai_soundbank_w(int data);
8593};
trunk/src/mame/includes/nmk16.h
r20971r20972
147147   TIMER_DEVICE_CALLBACK_MEMBER(hachamf_mcu_sim);
148148   TIMER_DEVICE_CALLBACK_MEMBER(nmk16_scanline);
149149   TIMER_DEVICE_CALLBACK_MEMBER(manybloc_scanline);
150   void nmk16_video_init();
151   inline void nmk16_draw_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr);
152   inline void nmk16_draw_sprite_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr);
153   void nmk16_draw_sprites_swap(bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl);
154   void nmk16_draw_sprites_swap_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl);
155   void nmk16_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
156   void nmk16_draw_sprites_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
157   int nmk16_bg_spr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
158   int nmk16_bg_fg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
159   int nmk16_bg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
160   int nmk16_bg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
161   int nmk16_bioshipbg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
162   int nmk16_bg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]);
163   int nmk16_bg_sprswapflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]);
164   int nmk16_complexbg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]);
165   void video_update(bitmap_ind16 &bitmap, const rectangle &cliprect,int dsw_flipscreen,int xoffset, int yoffset,int attr_mask);
166   void redhawki_video_update(bitmap_ind16 &bitmap, const rectangle &cliprect );
167   void mcu_run(UINT8 dsw_setting);
168   UINT8 decode_byte(UINT8 src, const UINT8 *bitp);
169   UINT32 bjtwin_address_map_bg0(UINT32 addr);
170   UINT16 decode_word(UINT16 src, const UINT8 *bitp);
171   UINT32 bjtwin_address_map_sprites(UINT32 addr);
172   void decode_gfx();
173   void decode_tdragonb();
174   void decode_ssmissin();
150175};
trunk/src/mame/includes/nova2001.h
r20971r20972
4444   UINT32 screen_update_ninjakun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4545   UINT32 screen_update_pkunwar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4646   UINT32 screen_update_raiders5(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
47   void nova2001_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
48   void pkunwar_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
49   void lineswap_gfx_roms(const char *region, const int bit);
4750};
trunk/src/mame/video/ninjaw.c
r20971r20972
1414            SPRITE DRAW ROUTINE
1515************************************************************/
1616
17static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int x_offs, int y_offs )
17void ninjaw_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int x_offs, int y_offs )
1818{
19   ninjaw_state *state = machine.driver_data<ninjaw_state>();
20   UINT16 *spriteram = state->m_spriteram;
19   UINT16 *spriteram = m_spriteram;
2120   int offs, data, tilenum, color, flipx, flipy;
2221   int x, y, priority, curx, cury;
2322   int code;
r20971r20972
2625   int unknown = 0;
2726#endif
2827
29   for (offs = (state->m_spriteram.bytes() / 2) - 4; offs >= 0; offs -= 4)
28   for (offs = (m_spriteram.bytes() / 2) - 4; offs >= 0; offs -= 4)
3029   {
3130      data = spriteram[offs + 2];
3231      tilenum = data & 0x7fff;
r20971r20972
7877      cury = y;
7978      code = tilenum;
8079
81      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
80      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
8281            code, color,
8382            flipx, flipy,
8483            curx, cury, 0);
r20971r20972
9594                SCREEN REFRESH
9695**************************************************************/
9796
98static UINT32 update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffs, device_t *tc0100scn)
97UINT32 ninjaw_state::update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffs, device_t *tc0100scn)
9998{
10099   UINT8 layer[3], nodraw;
101100
r20971r20972
114113      bitmap.fill(get_black_pen(screen.machine()), cliprect);
115114
116115   /* Sprites can be under/over the layer below text layer */
117   draw_sprites(screen.machine(), bitmap, cliprect, 1, xoffs, 8); // draw sprites with priority 1 which are under the mid layer
116   draw_sprites(bitmap, cliprect, 1, xoffs, 8); // draw sprites with priority 1 which are under the mid layer
118117
119118   // draw middle layer
120119   tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, layer[1], 0, 0);
121120
122   draw_sprites(screen.machine(),bitmap,cliprect,0,xoffs,8); // draw sprites with priority 0 which are over the mid layer
121   draw_sprites(bitmap,cliprect,0,xoffs,8); // draw sprites with priority 0 which are over the mid layer
123122
124123   // draw top(text) layer
125124   tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, layer[2], 0, 0);
trunk/src/mame/video/nova2001.c
r20971r20972
254254 *
255255 *************************************/
256256
257static void nova2001_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
257void nova2001_state::nova2001_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
258258{
259   nova2001_state *state = machine.driver_data<nova2001_state>();
260   UINT8 *spriteram = state->m_spriteram;
261   gfx_element *gfx = machine.gfx[0];
259   UINT8 *spriteram = m_spriteram;
260   gfx_element *gfx = machine().gfx[0];
262261   int offs;
263262
264263   for (offs = 0; offs < 0x800; offs += 32)
r20971r20972
276275         continue;
277276      }
278277
279      if (state->flip_screen())
278      if (flip_screen())
280279      {
281280         sx = 240 - sx;
282281         sy = 240 - sy;
r20971r20972
292291   }
293292}
294293
295static void pkunwar_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
294void nova2001_state::pkunwar_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
296295{
297   nova2001_state *state = machine.driver_data<nova2001_state>();
298   UINT8 *spriteram = state->m_spriteram;
299   gfx_element *gfx = machine.gfx[0];
296   UINT8 *spriteram = m_spriteram;
297   gfx_element *gfx = machine().gfx[0];
300298   int offs;
301299
302300   for (offs = 0; offs < 0x800; offs += 32)
r20971r20972
314312         continue;
315313      }
316314
317      if (state->flip_screen())
315      if (flip_screen())
318316      {
319317         sx = 240 - sx;
320318         sy = 240 - sy;
r20971r20972
343341{
344342   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
345343
346   nova2001_draw_sprites(machine(), bitmap, cliprect);
344   nova2001_draw_sprites(bitmap, cliprect);
347345
348346   // according to the schematics, fg category 0 should be drawn behind sprites,
349347   // but it doesn't look right that way
r20971r20972
357355{
358356   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0);
359357
360   pkunwar_draw_sprites(machine(), bitmap, cliprect);
358   pkunwar_draw_sprites(bitmap, cliprect);
361359
362360   m_bg_tilemap->draw(bitmap, cliprect, 1, 0);
363361
r20971r20972
370368
371369   m_fg_tilemap->draw(bitmap, cliprect, 1, 0);
372370
373   nova2001_draw_sprites(machine(), bitmap, cliprect);
371   nova2001_draw_sprites(bitmap, cliprect);
374372
375373   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
376374
r20971r20972
381379{
382380   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
383381
384   pkunwar_draw_sprites(machine(), bitmap, cliprect);
382   pkunwar_draw_sprites(bitmap, cliprect);
385383
386384   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
387385
trunk/src/mame/video/n8080.c
r20971r20972
4444}
4545
4646
47void spacefev_start_red_cannon( running_machine &machine )
47void n8080_state::spacefev_start_red_cannon(  )
4848{
49   n8080_state *state = machine.driver_data<n8080_state>();
50
51   state->m_spacefev_red_cannon = 1;
52   state->m_cannon_timer->adjust(attotime::from_usec(550 * 68 * 10));
49   m_spacefev_red_cannon = 1;
50   m_cannon_timer->adjust(attotime::from_usec(550 * 68 * 10));
5351}
5452
5553
r20971r20972
6058}
6159
6260
63static void helifire_next_line( running_machine &machine )
61void n8080_state::helifire_next_line(  )
6462{
65   n8080_state *state = machine.driver_data<n8080_state>();
63   m_helifire_mv++;
6664
67   state->m_helifire_mv++;
68
69   if (state->m_helifire_sc % 4 == 2)
65   if (m_helifire_sc % 4 == 2)
7066   {
71      state->m_helifire_mv %= 256;
67      m_helifire_mv %= 256;
7268   }
7369   else
7470   {
75      if (state->flip_screen())
76         state->m_helifire_mv %= 255;
71      if (flip_screen())
72         m_helifire_mv %= 255;
7773      else
78         state->m_helifire_mv %= 257;
74         m_helifire_mv %= 257;
7975   }
8076
81   if (state->m_helifire_mv == 128)
77   if (m_helifire_mv == 128)
8278   {
83      state->m_helifire_sc++;
79      m_helifire_sc++;
8480   }
8581}
8682
r20971r20972
331327
332328      /* next line */
333329
334      helifire_next_line(machine());
330      helifire_next_line();
335331   }
336332
337333   m_helifire_mv = saved_mv;
r20971r20972
376372
377373      for (i = 0; i < 256; i++)
378374      {
379         helifire_next_line(machine());
375         helifire_next_line();
380376      }
381377   }
382378}
trunk/src/mame/video/ninjakd2.c
r20971r20972
7373   return (col & 0x0f) | ((row & 0x1f) << 4) | ((col & 0x70) << 5);
7474}
7575
76static void robokid_get_bg_tile_info(running_machine& machine, tile_data& tileinfo, tilemap_memory_index const tile_index, int const gfxnum, const UINT8* const videoram)
76void ninjakd2_state::robokid_get_bg_tile_info( tile_data& tileinfo, tilemap_memory_index const tile_index, int const gfxnum, const UINT8* const videoram)
7777{
7878   int const lo = videoram[(tile_index << 1)];
7979   int const hi = videoram[(tile_index << 1) | 1];
8080   int const tile = ((hi & 0x10) << 7) | ((hi & 0x20) << 5) | ((hi & 0xc0) << 2) | lo;
8181   int const color = hi & 0x0f;
8282
83   SET_TILE_INFO(
83   SET_TILE_INFO_MEMBER(
8484         gfxnum,
8585         tile,
8686         color,
r20971r20972
8989
9090TILE_GET_INFO_MEMBER(ninjakd2_state::robokid_get_bg0_tile_info)
9191{
92   robokid_get_bg_tile_info(machine(), tileinfo, tile_index, 2, m_robokid_bg0_videoram);
92   robokid_get_bg_tile_info(tileinfo, tile_index, 2, m_robokid_bg0_videoram);
9393}
9494
9595TILE_GET_INFO_MEMBER(ninjakd2_state::robokid_get_bg1_tile_info)
9696{
97   robokid_get_bg_tile_info(machine(), tileinfo, tile_index, 3, m_robokid_bg1_videoram);
97   robokid_get_bg_tile_info(tileinfo, tile_index, 3, m_robokid_bg1_videoram);
9898}
9999
100100TILE_GET_INFO_MEMBER(ninjakd2_state::robokid_get_bg2_tile_info)
101101{
102   robokid_get_bg_tile_info(machine(), tileinfo, tile_index, 4, m_robokid_bg2_videoram);
102   robokid_get_bg_tile_info(tileinfo, tile_index, 4, m_robokid_bg2_videoram);
103103}
104104
105105
r20971r20972
283283}
284284
285285
286static void bg_ctrl(int offset, int data, tilemap_t* tilemap)
286void ninjakd2_state::bg_ctrl(int offset, int data, tilemap_t* tilemap)
287287{
288288   int scrollx = tilemap->scrollx(0);
289289   int scrolly = tilemap->scrolly(0);
r20971r20972
335335 *
336336 *************************************/
337337
338static void draw_sprites(running_machine& machine, bitmap_ind16 &bitmap)
338void ninjakd2_state::draw_sprites( bitmap_ind16 &bitmap)
339339{
340   ninjakd2_state *state = machine.driver_data<ninjakd2_state>();
341   gfx_element* const gfx = machine.gfx[1];
342   int const big_xshift = state->m_robokid_sprites ? 1 : 0;
343   int const big_yshift = state->m_robokid_sprites ? 0 : 1;
340   gfx_element* const gfx = machine().gfx[1];
341   int const big_xshift = m_robokid_sprites ? 1 : 0;
342   int const big_yshift = m_robokid_sprites ? 0 : 1;
344343
345   UINT8* sprptr = &state->m_spriteram[11];
344   UINT8* sprptr = &m_spriteram[11];
346345   int sprites_drawn = 0;
347346
348347   /* The sprite generator draws exactly 96 16x16 sprites per frame. When big
r20971r20972
368367         // Ninja Kid II doesn't use the 'big' feature so it might not be available on the board
369368         int const big = (sprptr[2] & 0x04) >> 2;
370369
371         if (state->flip_screen())
370         if (flip_screen())
372371         {
373372            sx = 240 - 16*big - sx;
374373            sy = 240 - 16*big - sy;
r20971r20972
428427// This is very hackish.
429428// (Is there a possibility that software can't select it but hardware can?)
430429
431static void erase_sprites(running_machine& machine, bitmap_ind16 &bitmap)
430void ninjakd2_state::erase_sprites( bitmap_ind16 &bitmap)
432431{
433   ninjakd2_state *state = machine.driver_data<ninjakd2_state>();
434
435432   // if sprite overdraw is disabled, clear the sprite framebuffer
436   if (!state->m_next_sprite_overdraw_enabled)
433   if (!m_next_sprite_overdraw_enabled)
437434   {
438      state->m_sprites_bitmap.fill(0xf);
435      m_sprites_bitmap.fill(0xf);
439436   }
440437   else
441438   {
442      for (int y = 0; y < state->m_sprites_bitmap.height(); ++y)
439      for (int y = 0; y < m_sprites_bitmap.height(); ++y)
443440      {
444         for (int x = 0; x < state->m_sprites_bitmap.width(); ++x)
441         for (int x = 0; x < m_sprites_bitmap.width(); ++x)
445442         {
446            UINT16* const ptr = &state->m_sprites_bitmap.pix16(y, x);
447            if ( (*state->m_stencil_compare_function)(*ptr) ) *ptr = 0xf;
443            UINT16* const ptr = &m_sprites_bitmap.pix16(y, x);
444            if ( (*m_stencil_compare_function)(*ptr) ) *ptr = 0xf;
448445         }
449446      }
450447   }
451448}
452449
453450
454static void update_sprites(running_machine& machine)
451void ninjakd2_state::update_sprites()
455452{
456   ninjakd2_state *state = machine.driver_data<ninjakd2_state>();
457
458453   ////// Before modified, this was written.
459454      // we want to erase the sprites with the old setting and draw them with the
460455      // new one. Not doing this causes a glitch in Ninja Kid II when taking the top
461456      // exit from stage 3.
462457   ////// The glitch is correct behavior.
463   erase_sprites(machine, state->m_sprites_bitmap);
464   draw_sprites(machine, state->m_sprites_bitmap);
458   erase_sprites(m_sprites_bitmap);
459   draw_sprites(m_sprites_bitmap);
465460}
466461
467462
r20971r20972
469464{
470465   // updating sprites here instead than in screen_eof avoids a palette glitch
471466   // at the end of the "rainbow sky" screens.
472   update_sprites(machine());
467   update_sprites();
473468   m_sprites_updated = 1;
474469
475470   bitmap.fill(0, cliprect);
r20971r20972
483478
484479UINT32 ninjakd2_state::screen_update_robokid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
485480{
486   update_sprites(machine());
481   update_sprites();
487482   m_sprites_updated = 1;
488483
489484   bitmap.fill(0, cliprect);
r20971r20972
499494
500495UINT32 ninjakd2_state::screen_update_omegaf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
501496{
502   update_sprites(machine());
497   update_sprites();
503498   m_sprites_updated = 1;
504499
505500   bitmap.fill(0, cliprect);
r20971r20972
520515   if (state)
521516   {
522517      if (!m_sprites_updated)
523         update_sprites(machine());
518         update_sprites();
524519
525520      m_sprites_updated = 0;
526521   }
trunk/src/mame/video/nbmj8891.c
r20971r20972
1111#include "includes/nbmj8891.h"
1212
1313
14static void nbmj8891_vramflip(running_machine &machine, int vram);
15static void nbmj8891_gfxdraw(running_machine &machine);
16
17
1814/******************************************************************************
1915
2016
r20971r20972
115111      case 0x04:  m_blitter_sizex = data; break;
116112      case 0x05:  m_blitter_sizey = data;
117113               /* writing here also starts the blit */
118               nbmj8891_gfxdraw(machine());
114               nbmj8891_gfxdraw();
119115               break;
120116      case 0x06:  m_blitter_direction_x = (data & 0x01) ? 1 : 0;
121117               m_blitter_direction_y = (data & 0x02) ? 1 : 0;
122118               m_flipscreen = (data & 0x04) ? 1 : 0;
123119               m_dispflag = (data & 0x08) ? 0 : 1;
124               if (m_gfxdraw_mode) nbmj8891_vramflip(machine(), 1);
125               nbmj8891_vramflip(machine(), 0);
120               if (m_gfxdraw_mode) nbmj8891_vramflip(1);
121               nbmj8891_vramflip(0);
126122               break;
127123      case 0x07:  break;
128124   }
r20971r20972
143139
144140WRITE8_MEMBER(nbmj8891_state::nbmj8891_taiwanmb_gfxdraw_w)
145141{
146//  nbmj8891_gfxdraw(machine());
142//  nbmj8891_gfxdraw();
147143}
148144
149145WRITE8_MEMBER(nbmj8891_state::nbmj8891_taiwanmb_gfxflag_w)
150146{
151147   m_flipscreen = (data & 0x04) ? 1 : 0;
152148
153   nbmj8891_vramflip(machine(), 0);
149   nbmj8891_vramflip(0);
154150}
155151
156152WRITE8_MEMBER(nbmj8891_state::nbmj8891_taiwanmb_mcu_w)
r20971r20972
226222         m_blitter_sizey ^= 0x00;
227223      }
228224
229      nbmj8891_gfxdraw(machine());
225      nbmj8891_gfxdraw();
230226   }
231227
232228//  m_blitter_direction_x = 0;                // for debug
r20971r20972
267263
268264
269265******************************************************************************/
270void nbmj8891_vramflip(running_machine &machine, int vram)
266void nbmj8891_state::nbmj8891_vramflip(int vram)
271267{
272   nbmj8891_state *state = machine.driver_data<nbmj8891_state>();
273268   int x, y;
274269   UINT8 color1, color2;
275270   UINT8 *vidram;
276271
277   int width = machine.primary_screen->width();
278   int height = machine.primary_screen->height();
272   int width = machine().primary_screen->width();
273   int height = machine().primary_screen->height();
279274
280   if (state->m_flipscreen == state->m_flipscreen_old) return;
275   if (m_flipscreen == m_flipscreen_old) return;
281276
282   vidram = vram ? state->m_videoram1 : state->m_videoram0;
277   vidram = vram ? m_videoram1 : m_videoram0;
283278
284279   for (y = 0; y < (height / 2); y++)
285280   {
r20971r20972
292287      }
293288   }
294289
295   state->m_flipscreen_old = state->m_flipscreen;
296   state->m_screen_refresh = 1;
290   m_flipscreen_old = m_flipscreen;
291   m_screen_refresh = 1;
297292}
298293
299294
300static void update_pixel0(running_machine &machine, int x, int y)
295void nbmj8891_state::update_pixel0(int x, int y)
301296{
302   nbmj8891_state *state = machine.driver_data<nbmj8891_state>();
303   UINT8 color = state->m_videoram0[(y * machine.primary_screen->width()) + x];
304   state->m_tmpbitmap0.pix16(y, x) = color;
297   UINT8 color = m_videoram0[(y * machine().primary_screen->width()) + x];
298   m_tmpbitmap0.pix16(y, x) = color;
305299}
306300
307static void update_pixel1(running_machine &machine, int x, int y)
301void nbmj8891_state::update_pixel1(int x, int y)
308302{
309   nbmj8891_state *state = machine.driver_data<nbmj8891_state>();
310   UINT8 color = state->m_videoram1[(y * machine.primary_screen->width()) + x];
311   state->m_tmpbitmap1.pix16(y, x) = (color == 0x7f) ? 0xff : color;
303   UINT8 color = m_videoram1[(y * machine().primary_screen->width()) + x];
304   m_tmpbitmap1.pix16(y, x) = (color == 0x7f) ? 0xff : color;
312305}
313306
314307TIMER_CALLBACK_MEMBER(nbmj8891_state::blitter_timer_callback)
r20971r20972
316309   nb1413m3_busyflag = 1;
317310}
318311
319static void nbmj8891_gfxdraw(running_machine &machine)
312void nbmj8891_state::nbmj8891_gfxdraw()
320313{
321   nbmj8891_state *state = machine.driver_data<nbmj8891_state>();
322   UINT8 *GFX = state->memregion("gfx1")->base();
323   int width = machine.primary_screen->width();
314   UINT8 *GFX = memregion("gfx1")->base();
315   int width = machine().primary_screen->width();
324316
325317   int x, y;
326318   int dx1, dx2, dy1, dy2;
r20971r20972
333325
334326   nb1413m3_busyctr = 0;
335327
336   startx = state->m_blitter_destx + state->m_blitter_sizex;
337   starty = state->m_blitter_desty + state->m_blitter_sizey;
328   startx = m_blitter_destx + m_blitter_sizex;
329   starty = m_blitter_desty + m_blitter_sizey;
338330
339   if (state->m_blitter_direction_x)
331   if (m_blitter_direction_x)
340332   {
341      sizex = state->m_blitter_sizex ^ 0xff;
333      sizex = m_blitter_sizex ^ 0xff;
342334      skipx = 1;
343335   }
344336   else
345337   {
346      sizex = state->m_blitter_sizex;
338      sizex = m_blitter_sizex;
347339      skipx = -1;
348340   }
349341
350   if (state->m_blitter_direction_y)
342   if (m_blitter_direction_y)
351343   {
352      sizey = state->m_blitter_sizey ^ 0xff;
344      sizey = m_blitter_sizey ^ 0xff;
353345      skipy = 1;
354346   }
355347   else
356348   {
357      sizey = state->m_blitter_sizey;
349      sizey = m_blitter_sizey;
358350      skipy = -1;
359351   }
360352
361   gfxlen = machine.root_device().memregion("gfx1")->bytes();
362   gfxaddr = (state->m_gfxrom << 17) + (state->m_blitter_src_addr << 1);
353   gfxlen = machine().root_device().memregion("gfx1")->bytes();
354   gfxaddr = (m_gfxrom << 17) + (m_blitter_src_addr << 1);
363355
364356   for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--)
365357   {
r20971r20972
378370         // for hanamomo font type
379371         if (nb1413m3_type == NB1413M3_HANAMOMO)
380372         {
381            if ((state->ioport("FONTTYPE")->read()) == 0x00)
373            if ((ioport("FONTTYPE")->read()) == 0x00)
382374            {
383375               if ((gfxaddr >= 0x20000) && (gfxaddr < 0x28000))
384376               {
r20971r20972
390382         dx1 = (2 * x + 0) & 0x1ff;
391383         dx2 = (2 * x + 1) & 0x1ff;
392384
393         if (state->m_gfxdraw_mode)
385         if (m_gfxdraw_mode)
394386         {
395387            // 2 layer type
396388            dy1 = y & 0xff;
397            dy2 = (y + state->m_scrolly) & 0xff;
389            dy2 = (y + m_scrolly) & 0xff;
398390         }
399391         else
400392         {
401393            // 1 layer type
402            dy1 = (y + state->m_scrolly) & 0xff;
394            dy1 = (y + m_scrolly) & 0xff;
403395            dy2 = 0;
404396         }
405397
406         if (!state->m_flipscreen)
398         if (!m_flipscreen)
407399         {
408400            dx1 ^= 0x1ff;
409401            dx2 ^= 0x1ff;
r20971r20972
411403            dy2 ^= 0xff;
412404         }
413405
414         if (state->m_blitter_direction_x)
406         if (m_blitter_direction_x)
415407         {
416408            // flip
417409            color1 = (color & 0x0f) >> 0;
r20971r20972
424416            color2 = (color & 0x0f) >> 0;
425417         }
426418
427         color1 = state->m_clut[((state->m_clutsel & 0x7f) << 4) + color1];
428         color2 = state->m_clut[((state->m_clutsel & 0x7f) << 4) + color2];
419         color1 = m_clut[((m_clutsel & 0x7f) << 4) + color1];
420         color2 = m_clut[((m_clutsel & 0x7f) << 4) + color2];
429421
430         if ((!state->m_gfxdraw_mode) || (state->m_vram & 0x01))
422         if ((!m_gfxdraw_mode) || (m_vram & 0x01))
431423         {
432424            // layer 1
433425            if (color1 != 0xff)
434426            {
435               state->m_videoram0[(dy1 * width) + dx1] = color1;
436               update_pixel0(machine, dx1, dy1);
427               m_videoram0[(dy1 * width) + dx1] = color1;
428               update_pixel0(dx1, dy1);
437429            }
438430            if (color2 != 0xff)
439431            {
440               state->m_videoram0[(dy1 * width) + dx2] = color2;
441               update_pixel0(machine, dx2, dy1);
432               m_videoram0[(dy1 * width) + dx2] = color2;
433               update_pixel0(dx2, dy1);
442434            }
443435         }
444         if (state->m_gfxdraw_mode && (state->m_vram & 0x02))
436         if (m_gfxdraw_mode && (m_vram & 0x02))
445437         {
446438            // layer 2
447            if (state->m_vram & 0x08)
439            if (m_vram & 0x08)
448440            {
449441               // transparent enable
450442               if (color1 != 0xff)
451443               {
452                  state->m_videoram1[(dy2 * width) + dx1] = color1;
453                  update_pixel1(machine, dx1, dy2);
444                  m_videoram1[(dy2 * width) + dx1] = color1;
445                  update_pixel1(dx1, dy2);
454446               }
455447               if (color2 != 0xff)
456448               {
457                  state->m_videoram1[(dy2 * width) + dx2] = color2;
458                  update_pixel1(machine, dx2, dy2);
449                  m_videoram1[(dy2 * width) + dx2] = color2;
450                  update_pixel1(dx2, dy2);
459451               }
460452            }
461453            else
462454            {
463455               // transparent disable
464               state->m_videoram1[(dy2 * width) + dx1] = color1;
465               update_pixel1(machine, dx1, dy2);
466               state->m_videoram1[(dy2 * width) + dx2] = color2;
467               update_pixel1(machine, dx2, dy2);
456               m_videoram1[(dy2 * width) + dx1] = color1;
457               update_pixel1(dx1, dy2);
458               m_videoram1[(dy2 * width) + dx2] = color2;
459               update_pixel1(dx2, dy2);
468460            }
469461         }
470462
r20971r20972
473465   }
474466
475467   nb1413m3_busyflag = 0;
476   machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8891_state::blitter_timer_callback),state));
468   machine().scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8891_state::blitter_timer_callback),this));
477469}
478470
479471/******************************************************************************
r20971r20972
530522      m_screen_refresh = 0;
531523      for (y = 0; y < height; y++)
532524         for (x = 0; x < width; x++)
533            update_pixel0(machine(), x, y);
525            update_pixel0(x, y);
534526
535527      if (m_gfxdraw_mode)
536528         for (y = 0; y < height; y++)
537529            for (x = 0; x < width; x++)
538               update_pixel1(machine(), x, y);
530               update_pixel1(x, y);
539531   }
540532
541533   if (m_dispflag)
trunk/src/mame/video/nbmj8688.c
r20971r20972
1111#include "includes/nbmj8688.h"
1212
1313
14static void mbmj8688_gfxdraw(running_machine &machine, int gfxtype);
15
16
1714/* the blitter can copy data both in "direct" mode, where every byte of the source
1815   data is copied verbatim to video RAM *twice* (thus doubling the pixel width),
1916   and in "lookup" mode, where the source byte is taken 4 bits at a time and indexed
r20971r20972
123120      case 0x04:  m_blitter_sizex = data; break;
124121      case 0x05:  m_blitter_sizey = data;
125122               /* writing here also starts the blit */
126               mbmj8688_gfxdraw(machine(), m_mjsikaku_gfxmode);
123               mbmj8688_gfxdraw(m_mjsikaku_gfxmode);
127124               break;
128125      case 0x06:  m_blitter_direction_x = (data & 0x01) ? 1 : 0;
129126               m_blitter_direction_y = (data & 0x02) ? 1 : 0;
r20971r20972
246243}
247244
248245
249static void update_pixel(nbmj8688_state *state, int x, int y)
246void nbmj8688_state::update_pixel(int x, int y)
250247{
251   int color = state->m_mjsikaku_videoram[(y * 512) + x];
252   state->m_mjsikaku_tmpbitmap->pix16(y, x) = color;
248   int color = m_mjsikaku_videoram[(y * 512) + x];
249   m_mjsikaku_tmpbitmap->pix16(y, x) = color;
253250}
254251
255static void writeram_low(nbmj8688_state *state, int x, int y, int color)
252void nbmj8688_state::writeram_low(int x, int y, int color)
256253{
257   state->m_mjsikaku_videoram[(y * 512) + x] &= 0xff00;
258   state->m_mjsikaku_videoram[(y * 512) + x] |= color;
259   update_pixel(state, x, y);
254   m_mjsikaku_videoram[(y * 512) + x] &= 0xff00;
255   m_mjsikaku_videoram[(y * 512) + x] |= color;
256   update_pixel(x, y);
260257}
261258
262static void writeram_high(nbmj8688_state *state, int x, int y, int color)
259void nbmj8688_state::writeram_high(int x, int y, int color)
263260{
264   state->m_mjsikaku_videoram[(y * 512) + x] &= 0x00ff;
265   state->m_mjsikaku_videoram[(y * 512) + x] |= color << 8;
266   update_pixel(state, x, y);
261   m_mjsikaku_videoram[(y * 512) + x] &= 0x00ff;
262   m_mjsikaku_videoram[(y * 512) + x] |= color << 8;
263   update_pixel(x, y);
267264}
268265
269266TIMER_CALLBACK_MEMBER(nbmj8688_state::blitter_timer_callback)
r20971r20972
271268   nb1413m3_busyflag = 1;
272269}
273270
274static void mbmj8688_gfxdraw(running_machine &machine, int gfxtype)
271void nbmj8688_state::mbmj8688_gfxdraw(int gfxtype)
275272{
276   nbmj8688_state *state = machine.driver_data<nbmj8688_state>();
277   UINT8 *GFX = state->memregion("gfx1")->base();
273   UINT8 *GFX = memregion("gfx1")->base();
278274
279275   int x, y;
280276   int dx1, dx2, dy;
r20971r20972
287283
288284   if (gfxtype == GFXTYPE_PURE_12BIT)
289285   {
290      if (state->m_mjsikaku_gfxflag2 & 0x20) return;
286      if (m_mjsikaku_gfxflag2 & 0x20) return;
291287   }
292288
293289   nb1413m3_busyctr = 0;
294290
295   startx = state->m_blitter_destx + state->m_blitter_sizex;
296   starty = state->m_blitter_desty + state->m_blitter_sizey;
291   startx = m_blitter_destx + m_blitter_sizex;
292   starty = m_blitter_desty + m_blitter_sizey;
297293
298   if (state->m_blitter_direction_x)
294   if (m_blitter_direction_x)
299295   {
300      sizex = state->m_blitter_sizex ^ 0xff;
296      sizex = m_blitter_sizex ^ 0xff;
301297      skipx = 1;
302298   }
303299   else
304300   {
305      sizex = state->m_blitter_sizex;
301      sizex = m_blitter_sizex;
306302      skipx = -1;
307303   }
308304
309   if (state->m_blitter_direction_y)
305   if (m_blitter_direction_y)
310306   {
311      sizey = state->m_blitter_sizey ^ 0xff;
307      sizey = m_blitter_sizey ^ 0xff;
312308      skipy = 1;
313309   }
314310   else
315311   {
316      sizey = state->m_blitter_sizey;
312      sizey = m_blitter_sizey;
317313      skipy = -1;
318314   }
319315
320   gfxlen = machine.root_device().memregion("gfx1")->bytes();
321   gfxaddr = (state->m_mjsikaku_gfxrom << 17) + (state->m_blitter_src_addr << 1);
316   gfxlen = machine().root_device().memregion("gfx1")->bytes();
317   gfxaddr = (m_mjsikaku_gfxrom << 17) + (m_blitter_src_addr << 1);
322318
323319//popmessage("ADDR:%08X DX:%03d DY:%03d SX:%03d SY:%03d", gfxaddr, startx, starty, sizex, sizey);
324320//logerror("ADDR:%08X DX:%03d DY:%03d SX:%03d SY:%03d\n", gfxaddr, startx, starty, sizex, sizey);
325//if (state->m_blitter_direction_x|state->m_blitter_direction_y) popmessage("ADDR:%08X FX:%01d FY:%01d", gfxaddr, state->m_blitter_direction_x, state->m_blitter_direction_y);
321//if (m_blitter_direction_x|m_blitter_direction_y) popmessage("ADDR:%08X FX:%01d FY:%01d", gfxaddr, m_blitter_direction_x, m_blitter_direction_y);
326322
327323   for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--)
328324   {
r20971r20972
340336
341337         dx1 = (2 * x + 0) & 0x1ff;
342338         dx2 = (2 * x + 1) & 0x1ff;
343         dy = (y + state->m_mjsikaku_scrolly) & 0xff;
339         dy = (y + m_mjsikaku_scrolly) & 0xff;
344340
345         if (state->m_mjsikaku_flipscreen)
341         if (m_mjsikaku_flipscreen)
346342         {
347343            dx1 ^= 0x1ff;
348344            dx2 ^= 0x1ff;
r20971r20972
351347
352348         if (gfxtype == GFXTYPE_HYBRID_16BIT)
353349         {
354            if (state->m_mjsikaku_gfxflag3 & 0x40)
350            if (m_mjsikaku_gfxflag3 & 0x40)
355351            {
356352               // direct mode
357353
358               if (state->m_mjsikaku_gfxflag3 & 0x80)
354               if (m_mjsikaku_gfxflag3 & 0x80)
359355               {
360356                  /* least significant bits */
361357                  if (color != 0xff)
362358                  {
363                     writeram_low(state, dx1, dy, color);
364                     writeram_low(state, dx2, dy, color);
359                     writeram_low(dx1, dy, color);
360                     writeram_low(dx2, dy, color);
365361                  }
366362               }
367363               else
r20971r20972
369365                  /* most significant bits */
370366                  if (color != 0xff)
371367                  {
372                     writeram_high(state, dx1, dy, color);
373                     writeram_high(state, dx2, dy, color);
368                     writeram_high(dx1, dy, color);
369                     writeram_high(dx2, dy, color);
374370                  }
375371               }
376372            }
r20971r20972
380376               // lookup table mode
381377
382378               // unknown flag (seiha, seiham)
383            //  if (state->m_mjsikaku_gfxflag3 & 0x80) return;
379            //  if (m_mjsikaku_gfxflag3 & 0x80) return;
384380
385381               // unknown (seiha, seiham, iemoto, ojousan)
386               if (!(state->m_mjsikaku_gfxflag2 & 0x20)) return;
382               if (!(m_mjsikaku_gfxflag2 & 0x20)) return;
387383
388               if (state->m_blitter_direction_x)
384               if (m_blitter_direction_x)
389385               {
390386                  // flip
391387                  color1 = (color & 0x0f) >> 0;
r20971r20972
398394                  color2 = (color & 0x0f) >> 0;
399395               }
400396
401               color1 = (state->m_clut[color1] << 8) | ((state->m_clut[color1 | 0x10] & 0x0f) << 4);
402               color2 = (state->m_clut[color2] << 8) | ((state->m_clut[color2 | 0x10] & 0x0f) << 4);
397               color1 = (m_clut[color1] << 8) | ((m_clut[color1 | 0x10] & 0x0f) << 4);
398               color2 = (m_clut[color2] << 8) | ((m_clut[color2 | 0x10] & 0x0f) << 4);
403399
404400               if (color1 != 0xfff0)
405401               {
406402                  /* extend color from 12-bit to 16-bit */
407403                  color1 = (color1 & 0xffc0) | ((color1 & 0x20) >> 1) | ((color1 & 0x10) >> 2);
408                  state->m_mjsikaku_videoram[(dy * 512) + dx1] = color1;
409                  update_pixel(state, dx1, dy);
404                  m_mjsikaku_videoram[(dy * 512) + dx1] = color1;
405                  update_pixel(dx1, dy);
410406               }
411407
412408               if (color2 != 0xfff0)
413409               {
414410                  /* extend color from 12-bit to 16-bit */
415411                  color2 = (color2 & 0xffc0) | ((color2 & 0x20) >> 1) | ((color2 & 0x10) >> 2);
416                  state->m_mjsikaku_videoram[(dy * 512) + dx2] = color2;
417                  update_pixel(state, dx2, dy);
412                  m_mjsikaku_videoram[(dy * 512) + dx2] = color2;
413                  update_pixel(dx2, dy);
418414               }
419415            }
420416         }
r20971r20972
422418         {
423419            /* 12-bit palette with 4-to-12 bit lookup table */
424420
425            if (state->m_blitter_direction_x)
421            if (m_blitter_direction_x)
426422            {
427423               // flip
428424               color1 = (color & 0x0f) >> 0;
r20971r20972
435431               color2 = (color & 0x0f) >> 0;
436432            }
437433
438            color1 = state->m_clut[color1] | ((state->m_clut[color1 | 0x10] & 0x0f) << 8);
439            color2 = state->m_clut[color2] | ((state->m_clut[color2 | 0x10] & 0x0f) << 8);
434            color1 = m_clut[color1] | ((m_clut[color1 | 0x10] & 0x0f) << 8);
435            color2 = m_clut[color2] | ((m_clut[color2 | 0x10] & 0x0f) << 8);
440436
441437            if (color1 != 0x0fff)
442438            {
443               state->m_mjsikaku_videoram[(dy * 512) + dx1] = color1;
444               update_pixel(state, dx1, dy);
439               m_mjsikaku_videoram[(dy * 512) + dx1] = color1;
440               update_pixel(dx1, dy);
445441            }
446442            if (color2 != 0x0fff)
447443            {
448               state->m_mjsikaku_videoram[(dy * 512) + dx2] = color2;
449               update_pixel(state, dx2, dy);
444               m_mjsikaku_videoram[(dy * 512) + dx2] = color2;
445               update_pixel(dx2, dy);
450446            }
451447         }
452448         else
453449         {
454            if (gfxtype == GFXTYPE_HYBRID_12BIT && (state->m_mjsikaku_gfxflag2 & 0x20))
450            if (gfxtype == GFXTYPE_HYBRID_12BIT && (m_mjsikaku_gfxflag2 & 0x20))
455451            {
456452               /* 4096 colors mode, wedged in on top of normal mode
457453                  Here we affect only the 4 least significant bits, the others are
458454                  changed as usual.
459455                */
460456
461               if (state->m_mjsikaku_gfxflag2 & 0x10)
457               if (m_mjsikaku_gfxflag2 & 0x10)
462458               {
463459                  // 4096 colors low mode (2nd draw upper)
464                  color = state->m_clut[((color & 0xf0) >> 4)];
460                  color = m_clut[((color & 0xf0) >> 4)];
465461               }
466462               else
467463               {
468464                  // 4096 colors low mode (1st draw lower)
469                  color = state->m_clut[((color & 0x0f) >> 0)];
465                  color = m_clut[((color & 0x0f) >> 0)];
470466               }
471467
472468               if (color != 0xff)
473469               {
474470                  color &= 0x0f;
475                  writeram_high(state, dx1, dy, color);
476                  writeram_high(state, dx2, dy, color);
471                  writeram_high(dx1, dy, color);
472                  writeram_high(dx2, dy, color);
477473               }
478474            }
479475            else
480476            {
481               if (state->m_mjsikaku_gfxflag2 & 0x04)
477               if (m_mjsikaku_gfxflag2 & 0x04)
482478               {
483479                  // direct mode
484480
r20971r20972
488484               {
489485                  // lookup table mode
490486
491                  if (state->m_blitter_direction_x)
487                  if (m_blitter_direction_x)
492488                  {
493489                     // flip
494490                     color1 = (color & 0x0f) >> 0;
r20971r20972
501497                     color2 = (color & 0x0f) >> 0;
502498                  }
503499
504                  color1 = state->m_clut[color1];
505                  color2 = state->m_clut[color2];
500                  color1 = m_clut[color1];
501                  color2 = m_clut[color2];
506502               }
507503
508               if (gfxtype == GFXTYPE_PURE_16BIT && !(state->m_mjsikaku_gfxflag2 & 0x20))
504               if (gfxtype == GFXTYPE_PURE_16BIT && !(m_mjsikaku_gfxflag2 & 0x20))
509505               {
510506                  /* 16-bit palette most significant bits */
511                  if (color1 != 0xff) writeram_high(state, dx1, dy, color1);
512                  if (color2 != 0xff) writeram_high(state, dx2, dy, color2);
507                  if (color1 != 0xff) writeram_high(dx1, dy, color1);
508                  if (color2 != 0xff) writeram_high(dx2, dy, color2);
513509               }
514510               else
515511               {
516512                  /* 8-bit palette or 16-bit palette least significant bits */
517                  if (color1 != 0xff) writeram_low(state, dx1, dy, color1);
518                  if (color2 != 0xff) writeram_low(state, dx2, dy, color2);
513                  if (color1 != 0xff) writeram_low(dx1, dy, color1);
514                  if (color2 != 0xff) writeram_low(dx2, dy, color2);
519515               }
520516            }
521517         }
r20971r20972
527523   nb1413m3_busyflag = 0;
528524
529525   if (gfxtype == GFXTYPE_8BIT)
530      machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8688_state::blitter_timer_callback),state));
526      machine().scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8688_state::blitter_timer_callback),this));
531527   else
532      machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8688_state::blitter_timer_callback),state));
528      machine().scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8688_state::blitter_timer_callback),this));
533529}
534530
535531
r20971r20972
538534
539535******************************************************************************/
540536
541static void common_video_start(running_machine &machine)
537void nbmj8688_state::common_video_start()
542538{
543   nbmj8688_state *state = machine.driver_data<nbmj8688_state>();
544   state->m_mjsikaku_tmpbitmap = auto_bitmap_ind16_alloc(machine, 512, 256);
545   state->m_mjsikaku_videoram = auto_alloc_array_clear(machine, UINT16, 512 * 256);
546   state->m_clut = auto_alloc_array(machine, UINT8, 0x20);
539   m_mjsikaku_tmpbitmap = auto_bitmap_ind16_alloc(machine(), 512, 256);
540   m_mjsikaku_videoram = auto_alloc_array_clear(machine(), UINT16, 512 * 256);
541   m_clut = auto_alloc_array(machine(), UINT8, 0x20);
547542
548   state->m_mjsikaku_scrolly = 0;  // reset because crystalg/crystal2 don't write to this register
543   m_mjsikaku_scrolly = 0;  // reset because crystalg/crystal2 don't write to this register
549544}
550545
551546VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_8bit)
552547{
553548   m_mjsikaku_gfxmode = GFXTYPE_8BIT;
554   common_video_start(machine());
549   common_video_start();
555550}
556551
557552VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_hybrid_12bit)
558553{
559554   m_mjsikaku_gfxmode = GFXTYPE_HYBRID_12BIT;
560   common_video_start(machine());
555   common_video_start();
561556}
562557
563558VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_pure_12bit)
564559{
565560   m_mjsikaku_gfxmode = GFXTYPE_PURE_12BIT;
566   common_video_start(machine());
561   common_video_start();
567562}
568563
569564VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_hybrid_16bit)
570565{
571566   m_mjsikaku_gfxmode = GFXTYPE_HYBRID_16BIT;
572   common_video_start(machine());
567   common_video_start();
573568}
574569
575570VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_pure_16bit)
576571{
577572   m_mjsikaku_gfxmode = GFXTYPE_PURE_16BIT;
578   common_video_start(machine());
573   common_video_start();
579574}
580575
581576VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_pure_16bit_LCD)
r20971r20972
585580   m_HD61830B_ram[0] = auto_alloc_array(machine(), UINT8, 0x10000);
586581   m_HD61830B_ram[1] = auto_alloc_array(machine(), UINT8, 0x10000);
587582
588   common_video_start(machine());
583   common_video_start();
589584}
590585
591586
r20971r20972
596591
597592******************************************************************************/
598593
599static void nbmj8688_HD61830B_instr_w(address_space &space,int offset,int data,int chip)
594void nbmj8688_state::nbmj8688_HD61830B_instr_w(address_space &space,int offset,int data,int chip)
600595{
601   nbmj8688_state *state = space.machine().driver_data<nbmj8688_state>();
602   state->m_HD61830B_instr[chip] = data;
596   m_HD61830B_instr[chip] = data;
603597}
604598
605static void nbmj8688_HD61830B_data_w(address_space &space,int offset,int data,int chip)
599void nbmj8688_state::nbmj8688_HD61830B_data_w(address_space &space,int offset,int data,int chip)
606600{
607   nbmj8688_state *state = space.machine().driver_data<nbmj8688_state>();
608   switch (state->m_HD61830B_instr[chip])
601   switch (m_HD61830B_instr[chip])
609602   {
610603      case 0x0a:  // set cursor address (low order)
611         state->m_HD61830B_addr[chip] = (state->m_HD61830B_addr[chip] & 0xff00) | data;
604         m_HD61830B_addr[chip] = (m_HD61830B_addr[chip] & 0xff00) | data;
612605         break;
613606      case 0x0b:  // set cursor address (high order)
614         state->m_HD61830B_addr[chip] = (state->m_HD61830B_addr[chip] & 0x00ff) | (data << 8);
607         m_HD61830B_addr[chip] = (m_HD61830B_addr[chip] & 0x00ff) | (data << 8);
615608         break;
616609      case 0x0c:  // write display data
617         state->m_HD61830B_ram[chip][state->m_HD61830B_addr[chip]++] = data;
610         m_HD61830B_ram[chip][m_HD61830B_addr[chip]++] = data;
618611         break;
619612      default:
620logerror("HD61830B unsupported instruction %02x %02x\n",state->m_HD61830B_instr[chip],data);
613logerror("HD61830B unsupported instruction %02x %02x\n",m_HD61830B_instr[chip],data);
621614         break;
622615   }
623616}
r20971r20972
678671      {
679672         for (x = 0; x < 512; x++)
680673         {
681            update_pixel(this, x, y);
674            update_pixel(x, y);
682675         }
683676      }
684677   }
trunk/src/mame/video/nbmj8991.c
r20971r20972
1010#include "includes/nb1413m3.h"
1111#include "includes/nbmj8991.h"
1212
13
14static void nbmj8991_vramflip(running_machine &machine);
15static void nbmj8991_gfxdraw(running_machine &machine);
16static void update_pixel(running_machine &machine, int x, int y);
17
18
1913/******************************************************************************
2014
2115
r20971r20972
8983      case 0x04:  m_blitter_sizex = data; break;
9084      case 0x05:  m_blitter_sizey = data;
9185               /* writing here also starts the blit */
92               nbmj8991_gfxdraw(machine());
86               nbmj8991_gfxdraw();
9387               break;
9488      case 0x06:  m_blitter_direction_x = (data & 0x01) ? 1 : 0;
9589               m_blitter_direction_y = (data & 0x02) ? 1 : 0;
9690               m_flipscreen = (data & 0x04) ? 0 : 1;
9791               m_dispflag = (data & 0x10) ? 0 : 1;
98               nbmj8991_vramflip(machine());
92               nbmj8991_vramflip();
9993               break;
10094      case 0x07:  break;
10195      case 0x10:  m_blitter_destx = (m_blitter_destx & 0xff00) | data; break;
r20971r20972
134128
135129
136130******************************************************************************/
137static void nbmj8991_vramflip(running_machine &machine)
131void nbmj8991_state::nbmj8991_vramflip()
138132{
139   nbmj8991_state *state = machine.driver_data<nbmj8991_state>();
140133   int x, y;
141134   UINT8 color1, color2;
142   int width = machine.primary_screen->width();
143   int height = machine.primary_screen->height();
135   int width = machine().primary_screen->width();
136   int height = machine().primary_screen->height();
144137
145   if (state->m_flipscreen == state->m_flipscreen_old) return;
138   if (m_flipscreen == m_flipscreen_old) return;
146139
147140   for (y = 0; y < height / 2; y++)
148141   {
149142      for (x = 0; x < width / 2; x++)
150143      {
151144         // rotate 180 degrees (   0,   0) - ( 511, 511)
152         color1 = state->m_videoram[(y * width) + x];
153         color2 = state->m_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)];
154         state->m_videoram[(y * width) + x] = color2;
155         state->m_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)] = color1;
145         color1 = m_videoram[(y * width) + x];
146         color2 = m_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)];
147         m_videoram[(y * width) + x] = color2;
148         m_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)] = color1;
156149         // rotate 180 degrees ( 512,   0) - (1023, 511)
157         color1 = state->m_videoram[(y * width) + (x + (width / 2))];
158         color2 = state->m_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))];
159         state->m_videoram[(y * width) + (x + (width / 2))] = color2;
160         state->m_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))] = color1;
150         color1 = m_videoram[(y * width) + (x + (width / 2))];
151         color2 = m_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))];
152         m_videoram[(y * width) + (x + (width / 2))] = color2;
153         m_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))] = color1;
161154      }
162155   }
163156
164   state->m_flipscreen_old = state->m_flipscreen;
165   state->m_screen_refresh = 1;
157   m_flipscreen_old = m_flipscreen;
158   m_screen_refresh = 1;
166159}
167160
168static void update_pixel(running_machine &machine, int x, int y)
161void nbmj8991_state::update_pixel(int x, int y)
169162{
170   nbmj8991_state *state = machine.driver_data<nbmj8991_state>();
171   UINT8 color = state->m_videoram[(y * machine.primary_screen->width()) + x];
172   state->m_tmpbitmap.pix16(y, x) = color;
163   UINT8 color = m_videoram[(y * machine().primary_screen->width()) + x];
164   m_tmpbitmap.pix16(y, x) = color;
173165}
174166
175167TIMER_CALLBACK_MEMBER(nbmj8991_state::blitter_timer_callback)
r20971r20972
177169   nb1413m3_busyflag = 1;
178170}
179171
180static void nbmj8991_gfxdraw(running_machine &machine)
172void nbmj8991_state::nbmj8991_gfxdraw()
181173{
182   nbmj8991_state *state = machine.driver_data<nbmj8991_state>();
183   UINT8 *GFX = state->memregion("gfx1")->base();
184   int width = machine.primary_screen->width();
174   UINT8 *GFX = memregion("gfx1")->base();
175   int width = machine().primary_screen->width();
185176
186177   int x, y;
187178   int dx1, dx2, dy;
r20971r20972
194185
195186   nb1413m3_busyctr = 0;
196187
197   if (state->m_blitter_direction_x)
188   if (m_blitter_direction_x)
198189   {
199      startx = state->m_blitter_destx;
200      sizex = state->m_blitter_sizex ^ 0xff;
190      startx = m_blitter_destx;
191      sizex = m_blitter_sizex ^ 0xff;
201192      skipx = 1;
202193   }
203194   else
204195   {
205      startx = state->m_blitter_destx + state->m_blitter_sizex;
206      sizex = state->m_blitter_sizex;
196      startx = m_blitter_destx + m_blitter_sizex;
197      sizex = m_blitter_sizex;
207198      skipx = -1;
208199   }
209200
210   if (state->m_blitter_direction_y)
201   if (m_blitter_direction_y)
211202   {
212      starty = state->m_blitter_desty;
213      sizey = state->m_blitter_sizey ^ 0xff;
203      starty = m_blitter_desty;
204      sizey = m_blitter_sizey ^ 0xff;
214205      skipy = 1;
215206   }
216207   else
217208   {
218      starty = state->m_blitter_desty + state->m_blitter_sizey;
219      sizey = state->m_blitter_sizey;
209      starty = m_blitter_desty + m_blitter_sizey;
210      sizey = m_blitter_sizey;
220211      skipy = -1;
221212   }
222213
223   gfxlen = machine.root_device().memregion("gfx1")->bytes();
224   gfxaddr = (state->m_gfxrom << 17) + (state->m_blitter_src_addr << 1);
214   gfxlen = machine().root_device().memregion("gfx1")->bytes();
215   gfxaddr = (m_gfxrom << 17) + (m_blitter_src_addr << 1);
225216
226217   for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--)
227218   {
r20971r20972
241232         dx2 = (2 * x + 1) & 0x3ff;
242233         dy = y & 0x1ff;
243234
244         if (!state->m_flipscreen)
235         if (!m_flipscreen)
245236         {
246237            dx1 ^= 0x1ff;
247238            dx2 ^= 0x1ff;
248239            dy ^= 0x1ff;
249240         }
250241
251         if (state->m_blitter_direction_x)
242         if (m_blitter_direction_x)
252243         {
253244            // flip
254245            color1 = (color & 0x0f) >> 0;
r20971r20972
261252            color2 = (color & 0x0f) >> 0;
262253         }
263254
264         color1 = state->m_clut[((state->m_clutsel & 0x7f) * 0x10) + color1];
265         color2 = state->m_clut[((state->m_clutsel & 0x7f) * 0x10) + color2];
255         color1 = m_clut[((m_clutsel & 0x7f) * 0x10) + color1];
256         color2 = m_clut[((m_clutsel & 0x7f) * 0x10) + color2];
266257
267258         if (color1 != 0xff)
268259         {
269            state->m_videoram[(dy * width) + dx1] = color1;
270            update_pixel(machine, dx1, dy);
260            m_videoram[(dy * width) + dx1] = color1;
261            update_pixel(dx1, dy);
271262         }
272263         if (color2 != 0xff)
273264         {
274            state->m_videoram[(dy * width) + dx2] = color2;
275            update_pixel(machine, dx2, dy);
265            m_videoram[(dy * width) + dx2] = color2;
266            update_pixel(dx2, dy);
276267         }
277268
278269         nb1413m3_busyctr++;
r20971r20972
280271   }
281272
282273   nb1413m3_busyflag = 0;
283   machine.scheduler().timer_set(attotime::from_nsec(1650) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8991_state::blitter_timer_callback),state));
274   machine().scheduler().timer_set(attotime::from_nsec(1650) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8991_state::blitter_timer_callback),this));
284275}
285276
286277/******************************************************************************
r20971r20972
311302
312303      for (y = 0; y < height; y++)
313304         for (x = 0; x < width; x++)
314            update_pixel(machine(), x, y);
305            update_pixel(x, y);
315306   }
316307
317308   if (m_dispflag)
r20971r20972
350341
351342      for (y = 0; y < height; y++)
352343         for (x = 0; x < width; x++)
353            update_pixel(machine(), x, y);
344            update_pixel(x, y);
354345   }
355346
356347   if (nb1413m3_inputport & 0x20)
trunk/src/mame/video/nbmj8900.c
r20971r20972
1111#include "includes/nbmj8900.h"
1212
1313
14static void nbmj8900_vramflip(running_machine &machine, int vram);
15static void nbmj8900_gfxdraw(running_machine &machine);
16
17
1814/******************************************************************************
1915
2016
r20971r20972
117113      case 0x04:  m_blitter_sizex = data; break;
118114      case 0x05:  m_blitter_sizey = data;
119115               /* writing here also starts the blit */
120               nbmj8900_gfxdraw(machine());
116               nbmj8900_gfxdraw();
121117               break;
122118      case 0x06:  m_blitter_direction_x = (data & 0x01) ? 1 : 0;
123119               m_blitter_direction_y = (data & 0x02) ? 1 : 0;
124120               m_flipscreen = (data & 0x04) ? 1 : 0;
125121               m_dispflag = (data & 0x08) ? 0 : 1;
126               if (m_gfxdraw_mode) nbmj8900_vramflip(machine(), 1);
127               nbmj8900_vramflip(machine(), 0);
122               if (m_gfxdraw_mode) nbmj8900_vramflip(1);
123               nbmj8900_vramflip(0);
128124               break;
129125      case 0x07:  break;
130126   }
r20971r20972
160156
161157
162158******************************************************************************/
163void nbmj8900_vramflip(running_machine &machine, int vram)
159void nbmj8900_state::nbmj8900_vramflip(int vram)
164160{
165   nbmj8900_state *state = machine.driver_data<nbmj8900_state>();
166161   int x, y;
167162   unsigned char color1, color2;
168163   unsigned char *vidram;
169   int width = machine.primary_screen->width();
170   int height = machine.primary_screen->height();
164   int width = machine().primary_screen->width();
165   int height = machine().primary_screen->height();
171166
172   if (state->m_flipscreen == state->m_flipscreen_old) return;
167   if (m_flipscreen == m_flipscreen_old) return;
173168
174   vidram = vram ? state->m_videoram1 : state->m_videoram0;
169   vidram = vram ? m_videoram1 : m_videoram0;
175170
176171   for (y = 0; y < (height / 2); y++)
177172   {
r20971r20972
184179      }
185180   }
186181
187   state->m_flipscreen_old = state->m_flipscreen;
188   state->m_screen_refresh = 1;
182   m_flipscreen_old = m_flipscreen;
183   m_screen_refresh = 1;
189184}
190185
191186
192static void update_pixel0(running_machine &machine, int x, int y)
187void nbmj8900_state::update_pixel0(int x, int y)
193188{
194   nbmj8900_state *state = machine.driver_data<nbmj8900_state>();
195   UINT8 color = state->m_videoram0[(y * state->m_screen_width) + x];
196   state->m_tmpbitmap0.pix16(y, x) = machine.pens[color];
189   UINT8 color = m_videoram0[(y * m_screen_width) + x];
190   m_tmpbitmap0.pix16(y, x) = machine().pens[color];
197191}
198192
199static void update_pixel1(running_machine &machine, int x, int y)
193void nbmj8900_state::update_pixel1(int x, int y)
200194{
201   nbmj8900_state *state = machine.driver_data<nbmj8900_state>();
202   UINT8 color = state->m_videoram1[(y * state->m_screen_width) + x];
203   state->m_tmpbitmap1.pix16(y, x) = machine.pens[color];
195   UINT8 color = m_videoram1[(y * m_screen_width) + x];
196   m_tmpbitmap1.pix16(y, x) = machine().pens[color];
204197}
205198
206199TIMER_CALLBACK_MEMBER(nbmj8900_state::blitter_timer_callback)
r20971r20972
208201   nb1413m3_busyflag = 1;
209202}
210203
211static void nbmj8900_gfxdraw(running_machine &machine)
204void nbmj8900_state::nbmj8900_gfxdraw()
212205{
213   nbmj8900_state *state = machine.driver_data<nbmj8900_state>();
214   unsigned char *GFX = state->memregion("gfx")->base();
206   unsigned char *GFX = memregion("gfx")->base();
215207
216208   int x, y;
217209   int dx1, dx2, dy1, dy2;
r20971r20972
224216
225217   nb1413m3_busyctr = 0;
226218
227   startx = state->m_blitter_destx + state->m_blitter_sizex;
228   starty = state->m_blitter_desty + state->m_blitter_sizey;
219   startx = m_blitter_destx + m_blitter_sizex;
220   starty = m_blitter_desty + m_blitter_sizey;
229221
230   if (state->m_blitter_direction_x)
222   if (m_blitter_direction_x)
231223   {
232      sizex = state->m_blitter_sizex ^ 0xff;
224      sizex = m_blitter_sizex ^ 0xff;
233225      skipx = 1;
234226   }
235227   else
236228   {
237      sizex = state->m_blitter_sizex;
229      sizex = m_blitter_sizex;
238230      skipx = -1;
239231   }
240232
241   if (state->m_blitter_direction_y)
233   if (m_blitter_direction_y)
242234   {
243      sizey = state->m_blitter_sizey ^ 0xff;
235      sizey = m_blitter_sizey ^ 0xff;
244236      skipy = 1;
245237   }
246238   else
247239   {
248      sizey = state->m_blitter_sizey;
240      sizey = m_blitter_sizey;
249241      skipy = -1;
250242   }
251243
252   gfxaddr = (state->m_gfxrom << 17) + (state->m_blitter_src_addr << 1);
244   gfxaddr = (m_gfxrom << 17) + (m_blitter_src_addr << 1);
253245
254246   for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--)
255247   {
256248      for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--)
257249      {
258         if ((gfxaddr > (machine.root_device().memregion("gfx")->bytes() - 1)))
250         if ((gfxaddr > (machine().root_device().memregion("gfx")->bytes() - 1)))
259251         {
260252#ifdef MAME_DEBUG
261253            popmessage("GFXROM ADDRESS OVER!!");
262254#endif
263            gfxaddr &= (machine.root_device().memregion("gfx")->bytes() - 1);
255            gfxaddr &= (machine().root_device().memregion("gfx")->bytes() - 1);
264256         }
265257
266258         color = GFX[gfxaddr++];
r20971r20972
274266         dx1 = (2 * x + 0) & 0x1ff;
275267         dx2 = (2 * x + 1) & 0x1ff;
276268
277         if (state->m_gfxdraw_mode)
269         if (m_gfxdraw_mode)
278270         {
279271            // 2 layer type
280272            dy1 = y & 0xff;
281            dy2 = (y + state->m_scrolly) & 0xff;
273            dy2 = (y + m_scrolly) & 0xff;
282274         }
283275         else
284276         {
285277            // 1 layer type
286            dy1 = (y + state->m_scrolly) & 0xff;
278            dy1 = (y + m_scrolly) & 0xff;
287279            dy2 = 0;
288280         }
289281
290         if (!state->m_flipscreen)
282         if (!m_flipscreen)
291283         {
292284            dx1 ^= 0x1ff;
293285            dx2 ^= 0x1ff;
r20971r20972
295287            dy2 ^= 0xff;
296288         }
297289
298         if (state->m_blitter_direction_x)
290         if (m_blitter_direction_x)
299291         {
300292            // flip
301293            color1 = (color & 0x0f) >> 0;
r20971r20972
308300            color2 = (color & 0x0f) >> 0;
309301         }
310302
311         color1 = state->m_clut[((state->m_clutsel & 0x7f) << 4) + color1];
312         color2 = state->m_clut[((state->m_clutsel & 0x7f) << 4) + color2];
303         color1 = m_clut[((m_clutsel & 0x7f) << 4) + color1];
304         color2 = m_clut[((m_clutsel & 0x7f) << 4) + color2];
313305
314         if ((!state->m_gfxdraw_mode) || (state->m_vram & 0x01))
306         if ((!m_gfxdraw_mode) || (m_vram & 0x01))
315307         {
316308            // layer 1
317309            if (color1 != 0xff)
318310            {
319               state->m_videoram0[(dy1 * state->m_screen_width) + dx1] = color1;
320               update_pixel0(machine, dx1, dy1);
311               m_videoram0[(dy1 * m_screen_width) + dx1] = color1;
312               update_pixel0(dx1, dy1);
321313            }
322314            if (color2 != 0xff)
323315            {
324               state->m_videoram0[(dy1 * state->m_screen_width) + dx2] = color2;
325               update_pixel0(machine, dx2, dy1);
316               m_videoram0[(dy1 * m_screen_width) + dx2] = color2;
317               update_pixel0(dx2, dy1);
326318            }
327319         }
328         if (state->m_gfxdraw_mode && (state->m_vram & 0x02))
320         if (m_gfxdraw_mode && (m_vram & 0x02))
329321         {
330322            // layer 2
331            if (state->m_vram & 0x08)
323            if (m_vram & 0x08)
332324            {
333325               // transparent enable
334326               if (color1 != 0xff)
335327               {
336                  state->m_videoram1[(dy2 * state->m_screen_width) + dx1] = color1;
337                  update_pixel1(machine, dx1, dy2);
328                  m_videoram1[(dy2 * m_screen_width) + dx1] = color1;
329                  update_pixel1(dx1, dy2);
338330               }
339331               if (color2 != 0xff)
340332               {
341                  state->m_videoram1[(dy2 * state->m_screen_width) + dx2] = color2;
342                  update_pixel1(machine, dx2, dy2);
333                  m_videoram1[(dy2 * m_screen_width) + dx2] = color2;
334                  update_pixel1(dx2, dy2);
343335               }
344336            }
345337            else
346338            {
347339               // transparent disable
348               state->m_videoram1[(dy2 * state->m_screen_width) + dx1] = color1;
349               update_pixel1(machine, dx1, dy2);
350               state->m_videoram1[(dy2 * state->m_screen_width) + dx2] = color2;
351               update_pixel1(machine, dx2, dy2);
340               m_videoram1[(dy2 * m_screen_width) + dx1] = color1;
341               update_pixel1(dx1, dy2);
342               m_videoram1[(dy2 * m_screen_width) + dx2] = color2;
343               update_pixel1(dx2, dy2);
352344            }
353345         }
354346
r20971r20972
357349   }
358350
359351   nb1413m3_busyflag = 0;
360   machine.scheduler().timer_set(attotime::from_nsec(2500) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8900_state::blitter_timer_callback),state));
352   machine().scheduler().timer_set(attotime::from_nsec(2500) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8900_state::blitter_timer_callback),this));
361353}
362354
363355/******************************************************************************
r20971r20972
396388      {
397389         for (x = 0; x < m_screen_width; x++)
398390         {
399            update_pixel0(machine(), x, y);
391            update_pixel0(x, y);
400392         }
401393      }
402394      if (m_gfxdraw_mode)
r20971r20972
405397         {
406398            for (x = 0; x < m_screen_width; x++)
407399            {
408               update_pixel1(machine(), x, y);
400               update_pixel1(x, y);
409401            }
410402         }
411403      }
trunk/src/mame/video/nmk16.c
r20971r20972
108108
109109***************************************************************************/
110110
111static void nmk16_video_init(running_machine &machine)
111void nmk16_state::nmk16_video_init()
112112{
113   nmk16_state *state = machine.driver_data<nmk16_state>();
114   state->m_spriteram_old = auto_alloc_array_clear(machine, UINT16, 0x1000/2);
115   state->m_spriteram_old2 = auto_alloc_array_clear(machine, UINT16, 0x1000/2);
113   m_spriteram_old = auto_alloc_array_clear(machine(), UINT16, 0x1000/2);
114   m_spriteram_old2 = auto_alloc_array_clear(machine(), UINT16, 0x1000/2);
116115
117   state->m_videoshift = 0;        /* 256x224 screen, no shift */
118   state->m_background_bitmap = NULL;
119   state->m_simple_scroll = 1;
116   m_videoshift = 0;        /* 256x224 screen, no shift */
117   m_background_bitmap = NULL;
118   m_simple_scroll = 1;
120119}
121120
122121
r20971r20972
128127   m_bg_tilemap0->set_transparent_pen(15);
129128   m_tx_tilemap->set_transparent_pen(15);
130129
131   nmk16_video_init(machine());
130   nmk16_video_init();
132131   m_background_bitmap = auto_bitmap_ind16_alloc(machine(),8192,512);
133132   m_bioship_background_bank=0;
134133   m_redraw_bitmap = 1;
r20971r20972
144143   m_fg_tilemap->set_transparent_pen(15);
145144   m_tx_tilemap->set_transparent_pen(15);
146145
147   nmk16_video_init(machine());
146   nmk16_video_init();
148147}
149148
150149VIDEO_START_MEMBER(nmk16_state,macross)
r20971r20972
154153
155154   m_tx_tilemap->set_transparent_pen(15);
156155
157   nmk16_video_init(machine());
156   nmk16_video_init();
158157}
159158
160159VIDEO_START_MEMBER(nmk16_state,gunnail)
r20971r20972
165164   m_tx_tilemap->set_transparent_pen(15);
166165   m_bg_tilemap0->set_scroll_rows(512);
167166
168   nmk16_video_init(machine());
167   nmk16_video_init();
169168   m_videoshift = 64;  /* 384x224 screen, leftmost 64 pixels have to be retrieved */
170169                  /* from the other side of the tilemap (!) */
171170   m_simple_scroll = 0;
r20971r20972
182181
183182   m_tx_tilemap->set_transparent_pen(15);
184183
185   nmk16_video_init(machine());
184   nmk16_video_init();
186185   m_videoshift = 64;  /* 384x224 screen, leftmost 64 pixels have to be retrieved */
187186                  /* from the other side of the tilemap (!) */
188187}
r20971r20972
197196{
198197   m_bg_tilemap0 = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(nmk16_state::bjtwin_get_bg_tile_info),this),TILEMAP_SCAN_COLS,8,8,64,32);
199198
200   nmk16_video_init(machine());
199   nmk16_video_init();
201200   m_videoshift = 64;  /* 384x224 screen, leftmost 64 pixels have to be retrieved */
202201                  /* from the other side of the tilemap (!) */
203202}
r20971r20972
389388
390389// manybloc uses extra flip bits on the sprites, but these break other games
391390
392static inline void nmk16_draw_sprite(nmk16_state *state, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr)
391inline void nmk16_state::nmk16_draw_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr)
393392{
394393   if ((spr[0] & 0x0001))
395394   {
396   int sx    = (spr[4] & 0x1FF) + state->m_videoshift;
395   int sx    = (spr[4] & 0x1FF) + m_videoshift;
397396   int sy    =  spr[6] & 0x1FF;
398397   int code  =  spr[3];
399398   int color =  spr[7];
r20971r20972
406405   if(pri != priority)
407406      return;
408407
409   if (state->flip_screen())
408   if (flip_screen())
410409   {
411410      sx = 368 - sx;
412411      sy = 240 - sy;
r20971r20972
420419      xx = w;
421420      do
422421      {
423      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
422      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
424423         code,
425424         color,
426         state->flip_screen(), state->flip_screen(),
425         flip_screen(), flip_screen(),
427426         ((x + 16) & 0x1FF) - 16,sy & 0x1FF,15);
428427      code++;
429428      x += delta;
r20971r20972
434433   }
435434}
436435
437static inline void nmk16_draw_sprite_flipsupported(nmk16_state *state, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr)
436inline void nmk16_state::nmk16_draw_sprite_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr)
438437{
439438   if ((spr[0] & 0x0001))
440439   {
441   int sx    = (spr[4] & 0x1FF) + state->m_videoshift;
440   int sx    = (spr[4] & 0x1FF) + m_videoshift;
442441   int sy    =  spr[6] & 0x1FF;
443442   int code  =  spr[3];
444443   int color =  spr[7];
r20971r20972
454453   if(pri != priority)
455454      return;
456455
457   flipx ^= state->flip_screen();
458   flipy ^= state->flip_screen();
456   flipx ^= flip_screen();
457   flipy ^= flip_screen();
459458
460   if (state->flip_screen())
459   if (flip_screen())
461460   {
462461      sx = 368 - sx;
463462      sy = 240 - sy;
r20971r20972
472471      xx = w;
473472      do
474473      {
475      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
474      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
476475         code,
477476         color,
478477         flipx, flipy,
r20971r20972
485484   }
486485}
487486
488static void nmk16_draw_sprites_swap(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl)
487void nmk16_state::nmk16_draw_sprites_swap(bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl)
489488{
490   nmk16_state *state = machine.driver_data<nmk16_state>();
491489   int i, prio;
492490
493491   // Priority level (4 levels, 0x100 sprites)
r20971r20972
497495      for ( i = 0; i < 0x100; i++ )
498496      {
499497         int spr = BITSWAP8(i, bittbl[0], bittbl[1], bittbl[2], bittbl[3], bittbl[4], bittbl[5], bittbl[6], bittbl[7]);
500         nmk16_draw_sprite(state, machine, bitmap, cliprect, prio, state->m_spriteram_old2 + (spr * 8));
498         nmk16_draw_sprite(bitmap, cliprect, prio, m_spriteram_old2 + (spr * 8));
501499   }
502500   }
503501}
504502
505static void nmk16_draw_sprites_swap_flipsupported(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl)
503void nmk16_state::nmk16_draw_sprites_swap_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl)
506504{
507   nmk16_state *state = machine.driver_data<nmk16_state>();
508505   int i, prio;
509506
510507   // Priority level (4 levels, 0x100 sprites)
r20971r20972
514511      for ( i = 0; i < 0x100; i++ )
515512      {
516513         int spr = BITSWAP8(i, bittbl[0], bittbl[1], bittbl[2], bittbl[3], bittbl[4], bittbl[5], bittbl[6], bittbl[7]);
517         nmk16_draw_sprite_flipsupported(state, machine, bitmap, cliprect, prio, state->m_spriteram_old2 + (spr * 16/2));
514         nmk16_draw_sprite_flipsupported(bitmap, cliprect, prio, m_spriteram_old2 + (spr * 16/2));
518515   }
519516   }
520517}
521518
522static void nmk16_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
519void nmk16_state::nmk16_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
523520{
524   nmk16_state *state = machine.driver_data<nmk16_state>();
525521   int offs;
526522
527523   for (offs = 0;offs < 0x1000/2;offs += 8)
528524   {
529      nmk16_draw_sprite(state, machine, bitmap, cliprect, priority, state->m_spriteram_old2 + offs);
525      nmk16_draw_sprite(bitmap, cliprect, priority, m_spriteram_old2 + offs);
530526   }
531527}
532528
533static void nmk16_draw_sprites_flipsupported(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
529void nmk16_state::nmk16_draw_sprites_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
534530{
535   nmk16_state *state = machine.driver_data<nmk16_state>();
536531   int offs;
537532
538533   for (offs = 0;offs < 0x1000/2;offs += 8)
539534   {
540      if (state->m_spriteram_old2[offs] & 0x0001)
535      if (m_spriteram_old2[offs] & 0x0001)
541536      {
542         nmk16_draw_sprite_flipsupported(state, machine, bitmap, cliprect, priority, state->m_spriteram_old2 + offs);
537         nmk16_draw_sprite_flipsupported(bitmap, cliprect, priority, m_spriteram_old2 + offs);
543538      }
544539   }
545540}
r20971r20972
552547
553548***************************************************************************/
554549
555int nmk16_bg_spr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
550int nmk16_state::nmk16_bg_spr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
556551{
557   nmk16_state *state = screen.machine().driver_data<nmk16_state>();
558   state->m_bg_tilemap0->set_scrollx(0,-state->m_videoshift);
552   m_bg_tilemap0->set_scrollx(0,-m_videoshift);
559553
560   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
554   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
561555
562   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3);
563   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2);
564   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1);
565   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0);
556   nmk16_draw_sprites(bitmap,cliprect,3);
557   nmk16_draw_sprites(bitmap,cliprect,2);
558   nmk16_draw_sprites(bitmap,cliprect,1);
559   nmk16_draw_sprites(bitmap,cliprect,0);
566560   return 0;
567561}
568562
569int nmk16_bg_fg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
563int nmk16_state::nmk16_bg_fg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
570564{
571   nmk16_state *state = screen.machine().driver_data<nmk16_state>();
572   state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift);
565   m_tx_tilemap->set_scrollx(0,-m_videoshift);
573566
574   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
575   state->m_fg_tilemap->draw(bitmap, cliprect, 0,0);
567   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
568   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
576569
577   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3);
578   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2);
579   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1);
580   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0);
570   nmk16_draw_sprites(bitmap,cliprect,3);
571   nmk16_draw_sprites(bitmap,cliprect,2);
572   nmk16_draw_sprites(bitmap,cliprect,1);
573   nmk16_draw_sprites(bitmap,cliprect,0);
581574
582   state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
575   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
583576   return 0;
584577}
585578
586int nmk16_bg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
579int nmk16_state::nmk16_bg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
587580{
588   nmk16_state *state = screen.machine().driver_data<nmk16_state>();
589   state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift);
581   m_tx_tilemap->set_scrollx(0,-m_videoshift);
590582
591   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
583   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
592584
593   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3);
594   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2);
595   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1);
596   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0);
585   nmk16_draw_sprites(bitmap,cliprect,3);
586   nmk16_draw_sprites(bitmap,cliprect,2);
587   nmk16_draw_sprites(bitmap,cliprect,1);
588   nmk16_draw_sprites(bitmap,cliprect,0);
597589
598   state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
590   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
599591   return 0;
600592}
601593
602int nmk16_bg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
594int nmk16_state::nmk16_bg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
603595{
604   nmk16_state *state = screen.machine().driver_data<nmk16_state>();
605   state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift);
596   m_tx_tilemap->set_scrollx(0,-m_videoshift);
606597
607   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
598   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
608599
609   nmk16_draw_sprites_flipsupported(screen.machine(), bitmap,cliprect,3);
610   nmk16_draw_sprites_flipsupported(screen.machine(), bitmap,cliprect,2);
611   nmk16_draw_sprites_flipsupported(screen.machine(), bitmap,cliprect,1);
612   nmk16_draw_sprites_flipsupported(screen.machine(), bitmap,cliprect,0);
600   nmk16_draw_sprites_flipsupported(bitmap,cliprect,3);
601   nmk16_draw_sprites_flipsupported(bitmap,cliprect,2);
602   nmk16_draw_sprites_flipsupported(bitmap,cliprect,1);
603   nmk16_draw_sprites_flipsupported(bitmap,cliprect,0);
613604
614   state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
605   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
615606   return 0;
616607}
617608
618int nmk16_bioshipbg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
609int nmk16_state::nmk16_bioshipbg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
619610{
620   nmk16_state *state = screen.machine().driver_data<nmk16_state>();
621   UINT16 *tilerom = (UINT16 *)state->memregion("gfx5")->base();
622   int scrollx=-(state->m_bioship_scroll[1] + state->m_bioship_scroll[0]*256);
623   int scrolly=-(state->m_bioship_scroll[3] + state->m_bioship_scroll[2]*256);
611   UINT16 *tilerom = (UINT16 *)memregion("gfx5")->base();
612   int scrollx=-(m_bioship_scroll[1] + m_bioship_scroll[0]*256);
613   int scrolly=-(m_bioship_scroll[3] + m_bioship_scroll[2]*256);
624614
625   state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift);
615   m_tx_tilemap->set_scrollx(0,-m_videoshift);
626616
627   if (state->m_redraw_bitmap)
617   if (m_redraw_bitmap)
628618   {
629      int bank = state->m_bioship_background_bank * 0x2000;
619      int bank = m_bioship_background_bank * 0x2000;
630620      int sx=0, sy=0, offs;
631      state->m_redraw_bitmap=0;
621      m_redraw_bitmap=0;
632622
633623      /* Draw background from tile rom */
634624      for (offs = 0;offs <0x1000;offs++) {
r20971r20972
636626            int numtile = data&0xfff;
637627            int color = (data&0xf000)>>12;
638628
639            drawgfx_opaque(*state->m_background_bitmap,state->m_background_bitmap->cliprect(),screen.machine().gfx[3],
629            drawgfx_opaque(*m_background_bitmap,m_background_bitmap->cliprect(),screen.machine().gfx[3],
640630                  numtile,
641631                  color,
642632                  0,0,   /* no flip */
r20971r20972
645635            data = tilerom[offs+0x1000+bank];
646636            numtile = data&0xfff;
647637            color = (data&0xf000)>>12;
648            drawgfx_opaque(*state->m_background_bitmap,state->m_background_bitmap->cliprect(),screen.machine().gfx[3],
638            drawgfx_opaque(*m_background_bitmap,m_background_bitmap->cliprect(),screen.machine().gfx[3],
649639                  numtile,
650640                  color,
651641                  0,0,   /* no flip */
r20971r20972
656646      }
657647   }
658648
659   copyscrollbitmap(bitmap,*state->m_background_bitmap,1,&scrollx,1,&scrolly,cliprect);
660   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
649   copyscrollbitmap(bitmap,*m_background_bitmap,1,&scrollx,1,&scrolly,cliprect);
650   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
661651
662   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3);
663   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2);
664   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1);
665   nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0);
652   nmk16_draw_sprites(bitmap,cliprect,3);
653   nmk16_draw_sprites(bitmap,cliprect,2);
654   nmk16_draw_sprites(bitmap,cliprect,1);
655   nmk16_draw_sprites(bitmap,cliprect,0);
666656
667   state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
657   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
668658   return 0;
669659}
670660
671int nmk16_bg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8])
661int nmk16_state::nmk16_bg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8])
672662{
673   nmk16_state *state = screen.machine().driver_data<nmk16_state>();
674   state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift);
663   m_tx_tilemap->set_scrollx(0,-m_videoshift);
675664
676   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
665   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
677666
678   nmk16_draw_sprites_swap(screen.machine(), bitmap,cliprect, bittbl);
667   nmk16_draw_sprites_swap(bitmap,cliprect, bittbl);
679668
680   state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
669   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
681670   return 0;
682671}
683672
684int nmk16_bg_sprswapflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8])
673int nmk16_state::nmk16_bg_sprswapflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8])
685674{
686   nmk16_state *state = screen.machine().driver_data<nmk16_state>();
687   state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift);
675   m_tx_tilemap->set_scrollx(0,-m_videoshift);
688676
689   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
677   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
690678
691   nmk16_draw_sprites_swap_flipsupported(screen.machine(), bitmap,cliprect, bittbl);
679   nmk16_draw_sprites_swap_flipsupported(bitmap,cliprect, bittbl);
692680
693   state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
681   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
694682   return 0;
695683}
696684
697int nmk16_complexbg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8])
685int nmk16_state::nmk16_complexbg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8])
698686{
699   nmk16_state *state = screen.machine().driver_data<nmk16_state>();
700   state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift);
687   m_tx_tilemap->set_scrollx(0,-m_videoshift);
701688
702689   // the hardware supports per-scanline X *and* Y scroll which isn't
703690   // supported by tilemaps so we have to draw the tilemap one line at a time
704   if (!state->m_simple_scroll)
691   if (!m_simple_scroll)
705692   {
706693   int i=16;
707694   int y1;
r20971r20972
709696   y1 = cliprect.min_y;
710697      while (y1 <= cliprect.max_y)
711698      {
712         int const yscroll = state->m_gunnail_scrollramy[0] + state->m_gunnail_scrollramy[y1];
699         int const yscroll = m_gunnail_scrollramy[0] + m_gunnail_scrollramy[y1];
713700         int tilemap_bank_select;
714         tilemap_t* bg_tilemap = state->m_bg_tilemap0;
701         tilemap_t* bg_tilemap = m_bg_tilemap0;
715702
716703         bgclip.min_y = y1;
717704         bgclip.max_y = y1;
718705
719706
720         tilemap_bank_select = (state->m_gunnail_scrollram[0]&0x3000)>>12;
707         tilemap_bank_select = (m_gunnail_scrollram[0]&0x3000)>>12;
721708         switch (tilemap_bank_select)
722709         {
723            case 0: if (state->m_bg_tilemap0) bg_tilemap = state->m_bg_tilemap0; break;
724            case 1: if (state->m_bg_tilemap1) bg_tilemap = state->m_bg_tilemap1; break;
725            case 2: if (state->m_bg_tilemap2) bg_tilemap = state->m_bg_tilemap2; break;
726            case 3: if (state->m_bg_tilemap3) bg_tilemap = state->m_bg_tilemap3; break;
710            case 0: if (m_bg_tilemap0) bg_tilemap = m_bg_tilemap0; break;
711            case 1: if (m_bg_tilemap1) bg_tilemap = m_bg_tilemap1; break;
712            case 2: if (m_bg_tilemap2) bg_tilemap = m_bg_tilemap2; break;
713            case 3: if (m_bg_tilemap3) bg_tilemap = m_bg_tilemap3; break;
727714         }
728715
729716         bg_tilemap->set_scroll_rows(512);
730717
731718         bg_tilemap->set_scrolly(0, yscroll);
732         bg_tilemap->set_scrollx((i + yscroll) & 0x1ff, state->m_gunnail_scrollram[0] + state->m_gunnail_scrollram[i] - state->m_videoshift);
719         bg_tilemap->set_scrollx((i + yscroll) & 0x1ff, m_gunnail_scrollram[0] + m_gunnail_scrollram[i] - m_videoshift);
733720
734721         bg_tilemap->draw(bitmap, bgclip, 0,0);
735722
r20971r20972
739726   }
740727   else
741728   {
742      UINT16 yscroll = ((state->m_gunnail_scrollram[2]&0xff)<<8) | ((state->m_gunnail_scrollram[3]&0xff)<<0);
743      UINT16 xscroll = ((state->m_gunnail_scrollram[0]&0xff)<<8) | ((state->m_gunnail_scrollram[1]&0xff)<<0);
729      UINT16 yscroll = ((m_gunnail_scrollram[2]&0xff)<<8) | ((m_gunnail_scrollram[3]&0xff)<<0);
730      UINT16 xscroll = ((m_gunnail_scrollram[0]&0xff)<<8) | ((m_gunnail_scrollram[1]&0xff)<<0);
744731      int tilemap_bank_select;
745      tilemap_t* bg_tilemap = state->m_bg_tilemap0;
732      tilemap_t* bg_tilemap = m_bg_tilemap0;
746733
747734      //popmessage( "scroll %04x, %04x", yscroll,xscroll);
748735
749736      tilemap_bank_select = (xscroll&0x3000)>>12;
750737      switch (tilemap_bank_select)
751738      {
752         case 0: if (state->m_bg_tilemap0) bg_tilemap = state->m_bg_tilemap0; break;
753         case 1: if (state->m_bg_tilemap1) bg_tilemap = state->m_bg_tilemap1; break;
754         case 2: if (state->m_bg_tilemap2) bg_tilemap = state->m_bg_tilemap2; break;
755         case 3: if (state->m_bg_tilemap3) bg_tilemap = state->m_bg_tilemap3; break;
739         case 0: if (m_bg_tilemap0) bg_tilemap = m_bg_tilemap0; break;
740         case 1: if (m_bg_tilemap1) bg_tilemap = m_bg_tilemap1; break;
741         case 2: if (m_bg_tilemap2) bg_tilemap = m_bg_tilemap2; break;
742         case 3: if (m_bg_tilemap3) bg_tilemap = m_bg_tilemap3; break;
756743      }
757744
758745      bg_tilemap->set_scroll_rows(1);
759746
760747      bg_tilemap->set_scrolly(0, yscroll);
761      bg_tilemap->set_scrollx(0, xscroll - state->m_videoshift);
748      bg_tilemap->set_scrollx(0, xscroll - m_videoshift);
762749
763750      bg_tilemap->draw(bitmap, cliprect, 0,0);
764751   }
765752
766   nmk16_draw_sprites_swap(screen.machine(), bitmap,cliprect, bittbl);
753   nmk16_draw_sprites_swap(bitmap,cliprect, bittbl);
767754
768   state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
755   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
769756   return 0;
770757}
771758
r20971r20972
934921
935922***************************************************************************/
936923
937static void video_update(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,
924void nmk16_state::video_update(bitmap_ind16 &bitmap, const rectangle &cliprect,
938925   int dsw_flipscreen,         // 1 = Horizontal and vertical screen flip are hardwired to 2 dip switches
939926   int xoffset, int yoffset,   // bg_tilemap0 offsets
940927   int attr_mask               // "sprite active" mask
941928   )
942929{
943   nmk16_state *state = machine.driver_data<nmk16_state>();
944
945
946
947930   if (dsw_flipscreen)
948931   {
949      state->flip_screen_x_set(~state->ioport("DSW1")->read() & 0x0100);
950      state->flip_screen_y_set(~state->ioport("DSW1")->read() & 0x0200);
932      flip_screen_x_set(~ioport("DSW1")->read() & 0x0100);
933      flip_screen_y_set(~ioport("DSW1")->read() & 0x0200);
951934   }
952935
953936
954   state->m_bg_tilemap0->set_scrollx(0, state->m_afega_scroll_0[1] + xoffset);
955   state->m_bg_tilemap0->set_scrolly(0, state->m_afega_scroll_0[0] + yoffset);
937   m_bg_tilemap0->set_scrollx(0, m_afega_scroll_0[1] + xoffset);
938   m_bg_tilemap0->set_scrolly(0, m_afega_scroll_0[0] + yoffset);
956939
957   state->m_tx_tilemap->set_scrollx(0, state->m_afega_scroll_1[1]);
958   state->m_tx_tilemap->set_scrolly(0, state->m_afega_scroll_1[0]);
940   m_tx_tilemap->set_scrollx(0, m_afega_scroll_1[1]);
941   m_tx_tilemap->set_scrolly(0, m_afega_scroll_1[0]);
959942
960943
961   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
944   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
962945
963   nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,3);
964   nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,2);
965   nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,1);
966   nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,0);
946   nmk16_draw_sprites_flipsupported(bitmap,cliprect,3);
947   nmk16_draw_sprites_flipsupported(bitmap,cliprect,2);
948   nmk16_draw_sprites_flipsupported(bitmap,cliprect,1);
949   nmk16_draw_sprites_flipsupported(bitmap,cliprect,0);
967950
968   state->m_tx_tilemap->draw(bitmap, cliprect, 0,0);
951   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
969952}
970953
971static void redhawki_video_update(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
954void nmk16_state::redhawki_video_update(bitmap_ind16 &bitmap, const rectangle &cliprect )
972955{
973   nmk16_state *state = machine.driver_data<nmk16_state>();
974956
957   m_bg_tilemap0->set_scrollx(0, m_afega_scroll_1[0]&0xff);
958   m_bg_tilemap0->set_scrolly(0, m_afega_scroll_1[1]&0xff);
975959
976   state->m_bg_tilemap0->set_scrollx(0, state->m_afega_scroll_1[0]&0xff);
977   state->m_bg_tilemap0->set_scrolly(0, state->m_afega_scroll_1[1]&0xff);
960   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
978961
979   state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
980
981   nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,3);
982   nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,2);
983   nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,1);
984   nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,0);
962   nmk16_draw_sprites_flipsupported(bitmap,cliprect,3);
963   nmk16_draw_sprites_flipsupported(bitmap,cliprect,2);
964   nmk16_draw_sprites_flipsupported(bitmap,cliprect,1);
965   nmk16_draw_sprites_flipsupported(bitmap,cliprect,0);
985966}
986967
987UINT32 nmk16_state::screen_update_afega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){    video_update(machine(),bitmap,cliprect, 1, -0x100,+0x000, 0x0001);  return 0; }
988UINT32 nmk16_state::screen_update_bubl2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(machine(),bitmap,cliprect, 0, -0x100,+0x000, 0x0001);  return 0; } // no flipscreen support, I really would confirmation from the schematics
989UINT32 nmk16_state::screen_update_redhawkb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(machine(),bitmap,cliprect, 0, +0x000,+0x100, 0x0001);  return 0; }
990UINT32 nmk16_state::screen_update_redhawki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ redhawki_video_update(machine(),bitmap,cliprect); return 0;} // strange scroll regs
968UINT32 nmk16_state::screen_update_afega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)   { video_update(bitmap,cliprect, 1, -0x100,+0x000, 0x0001);  return 0; }
969UINT32 nmk16_state::screen_update_bubl2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(bitmap,cliprect, 0, -0x100,+0x000, 0x0001);  return 0; } // no flipscreen support, I really would confirmation from the schematics
970UINT32 nmk16_state::screen_update_redhawkb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(bitmap,cliprect, 0, +0x000,+0x100, 0x0001);  return 0; }
971UINT32 nmk16_state::screen_update_redhawki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ redhawki_video_update(bitmap,cliprect); return 0;} // strange scroll regs
991972
992973UINT32 nmk16_state::screen_update_firehawk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
993974{
r20971r20972
996977
997978   m_bg_tilemap0->draw(bitmap, cliprect, 0,0);
998979
999   nmk16_draw_sprites_flipsupported(machine(), bitmap,cliprect,3);
1000   nmk16_draw_sprites_flipsupported(machine(), bitmap,cliprect,2);
1001   nmk16_draw_sprites_flipsupported(machine(), bitmap,cliprect,1);
1002   nmk16_draw_sprites_flipsupported(machine(), bitmap,cliprect,0);
980   nmk16_draw_sprites_flipsupported(bitmap,cliprect,3);
981   nmk16_draw_sprites_flipsupported(bitmap,cliprect,2);
982   nmk16_draw_sprites_flipsupported(bitmap,cliprect,1);
983   nmk16_draw_sprites_flipsupported(bitmap,cliprect,0);
1003984
1004985   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
1005986   return 0;
trunk/src/mame/video/nitedrvr.c
r20971r20972
3535   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(nitedrvr_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
3636}
3737
38static void draw_box( bitmap_ind16 &bitmap, int bx, int by, int ex, int ey )
38void nitedrvr_state::draw_box( bitmap_ind16 &bitmap, int bx, int by, int ex, int ey )
3939{
4040   int x, y;
4141
r20971r20972
4949   return;
5050}
5151
52static void draw_roadway( running_machine &machine, bitmap_ind16 &bitmap )
52void nitedrvr_state::draw_roadway( bitmap_ind16 &bitmap )
5353{
54   nitedrvr_state *state = machine.driver_data<nitedrvr_state>();
5554   int roadway;
5655
5756   for (roadway = 0; roadway < 16; roadway++)
5857   {
5958      int bx, by, ex, ey;
6059
61      bx = state->m_hvc[roadway];
62      by = state->m_hvc[roadway + 16];
63      ex = bx + ((state->m_hvc[roadway + 32] & 0xf0) >> 4);
64      ey = by + (16 - (state->m_hvc[roadway + 32] & 0x0f));
60      bx = m_hvc[roadway];
61      by = m_hvc[roadway + 16];
62      ex = bx + ((m_hvc[roadway + 32] & 0xf0) >> 4);
63      ey = by + (16 - (m_hvc[roadway + 32] & 0x0f));
6564
6665      draw_box(bitmap, bx, by, ex, ey);
6766   }
r20971r20972
7069UINT32 nitedrvr_state::screen_update_nitedrvr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
7170{
7271   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
73   draw_roadway(machine(), bitmap);
72   draw_roadway(bitmap);
7473   return 0;
7574}
trunk/src/mame/video/nycaptor.c
r20971r20972
1515 spot number isn't set to 0 in main menu ; lives - yes
1616 sprites in main menu req priority 'type' 0
1717*/
18static int nycaptor_spot( running_machine &machine )
18int nycaptor_state::nycaptor_spot(  )
1919{
20   nycaptor_state *state = machine.driver_data<nycaptor_state>();
21
22   if (state->m_gametype == 0 || state->m_gametype == 2)
23      return state->m_sharedram[0x299] ? state->m_sharedram[0x298] : 0;
20   if (m_gametype == 0 || m_gametype == 2)
21      return m_sharedram[0x299] ? m_sharedram[0x298] : 0;
2422   else
2523      return 0;
2624
r20971r20972
4442
4543   tileinfo.group = 0;
4644
47   if ((!nycaptor_spot(machine())) && (pal == 6))
45   if ((!nycaptor_spot()) && (pal == 6))
4846      tileinfo.group = 1;
4947
50   if (((nycaptor_spot(machine()) == 3) && (pal == 8)) || ((nycaptor_spot(machine()) == 1) && (pal == 0xc)))
48   if (((nycaptor_spot() == 3) && (pal == 8)) || ((nycaptor_spot() == 1) && (pal == 0xc)))
5149      tileinfo.group = 2;
5250
53   if ((nycaptor_spot(machine()) == 1) && (tileinfo.category == 2))
51   if ((nycaptor_spot() == 1) && (tileinfo.category == 2))
5452      tileinfo.group = 3;
5553
5654#if NYCAPTOR_DEBUG
5755   if (m_mask & (1 << tileinfo.category))
5856   {
59      if (nycaptor_spot(machine()))
57      if (nycaptor_spot())
6058         pal = 0xe;
6159      else
6260         pal = 4;
r20971r20972
151149   m_bg_tilemap->set_scrolly(offset, data);
152150}
153151
154static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
152void nycaptor_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
155153{
156   nycaptor_state *state = machine.driver_data<nycaptor_state>();
157154   int i;
158155
159156   for (i = 0; i < 0x20; i++)
160157   {
161      int pr = state->m_spriteram[0x9f - i];
158      int pr = m_spriteram[0x9f - i];
162159      int offs = (pr & 0x1f) * 4;
163160      int code, sx, sy, flipx, flipy, pal, priori;
164161
165      code = state->m_spriteram[offs + 2] + ((state->m_spriteram[offs + 1] & 0x10) << 4);//1 bit wolny = 0x20
166      pal  = state->m_spriteram[offs + 1] & 0x0f;
167      sx   = state->m_spriteram[offs + 3];
168      sy   = 240 - state->m_spriteram[offs + 0];
162      code = m_spriteram[offs + 2] + ((m_spriteram[offs + 1] & 0x10) << 4);//1 bit wolny = 0x20
163      pal  = m_spriteram[offs + 1] & 0x0f;
164      sx   = m_spriteram[offs + 3];
165      sy   = 240 - m_spriteram[offs + 0];
169166      priori = (pr & 0xe0) >> 5;
170167
171168      if (priori == pri)
172169      {
173170#if NYCAPTOR_DEBUG
174         if (state->m_mask & (1 << (pri + 4))) pal = 0xd;
171         if (m_mask & (1 << (pri + 4))) pal = 0xd;
175172#endif
176         flipx = BIT(state->m_spriteram[offs + 1], 6);
177         flipy = BIT(state->m_spriteram[offs + 1], 7);
173         flipx = BIT(m_spriteram[offs + 1], 6);
174         flipy = BIT(m_spriteram[offs + 1], 7);
178175
179         drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
176         drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
180177               code,
181178               pal,
182179               flipx,flipy,
183180               sx,sy,15);
184181
185         if (state->m_spriteram[offs + 3] > 240)
182         if (m_spriteram[offs + 3] > 240)
186183         {
187            sx = (state->m_spriteram[offs + 3] - 256);
188            drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
184            sx = (m_spriteram[offs + 3] - 256);
185            drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
189186               code,
190187               pal,
191188               flipx,flipy,
r20971r20972
210207
211208#define mKEY_MASK(x,y) if (machine.input().code_pressed_once(x)) { state->m_mask |= y; state->m_bg_tilemap->mark_all_dirty(); }
212209
213static void nycaptor_setmask( running_machine &machine )
210void nycaptor_state::nycaptor_setmask(  )
214211{
215   nycaptor_state *state = machine.driver_data<nycaptor_state>();
216
217212   mKEY_MASK(KEYCODE_Q, 1); /* bg */
218213   mKEY_MASK(KEYCODE_W, 2);
219214   mKEY_MASK(KEYCODE_E, 4);
r20971r20972
228223   mKEY_MASK(KEYCODE_J, 0x400);
229224   mKEY_MASK(KEYCODE_K, 0x800);
230225
231   if (machine.input().code_pressed_once(KEYCODE_Z)){state->m_mask = 0; state->m_bg_tilemap->mark_all_dirty();} /* disable */
232   if (machine.input().code_pressed_once(KEYCODE_X)){state->m_mask |= 0x1000; state->m_bg_tilemap->mark_all_dirty();} /* no layers */
226   if (machine().input().code_pressed_once(KEYCODE_Z)){m_mask = 0; m_bg_tilemap->mark_all_dirty();} /* disable */
227   if (machine().input().code_pressed_once(KEYCODE_X)){m_mask |= 0x1000; m_bg_tilemap->mark_all_dirty();} /* no layers */
233228}
234229#endif
235230
r20971r20972
258253   }
259254   else
260255#endif
261   switch (nycaptor_spot(machine()) & 3)
256   switch (nycaptor_spot() & 3)
262257   {
263258   case 0:
264259      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 3, 0);
265      draw_sprites(machine(), bitmap, cliprect, 6);
260      draw_sprites(bitmap, cliprect, 6);
266261      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 3, 0);
267262      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 2, 0);
268263      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 2, 0);
269264      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1, 0);
270      draw_sprites(machine(), bitmap, cliprect, 3);
265      draw_sprites(bitmap, cliprect, 3);
271266      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1, 0);
272      draw_sprites(machine(), bitmap, cliprect, 0);
273      draw_sprites(machine(), bitmap, cliprect, 2);
267      draw_sprites(bitmap, cliprect, 0);
268      draw_sprites(bitmap, cliprect, 2);
274269      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0, 0);
275      draw_sprites(machine(), bitmap, cliprect, 1);
270      draw_sprites(bitmap, cliprect, 1);
276271      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0, 0);
277272      break;
278273
279274   case 1:
280275      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 3, 0);
281      draw_sprites(machine(), bitmap, cliprect, 3);
276      draw_sprites(bitmap, cliprect, 3);
282277      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 3, 0);
283      draw_sprites(machine(), bitmap, cliprect, 2);
278      draw_sprites(bitmap, cliprect, 2);
284279      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 2, 0);
285280      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1, 0);
286      draw_sprites(machine(), bitmap, cliprect, 1);
281      draw_sprites(bitmap, cliprect, 1);
287282      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1, 0);
288283      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 2, 0);
289      draw_sprites(machine(), bitmap, cliprect, 0);
284      draw_sprites(bitmap, cliprect, 0);
290285      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0, 0);
291286      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0, 0);
292287      break;
r20971r20972
295290      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 3, 0);
296291      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 3, 0);
297292      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1, 0);
298      draw_sprites(machine(), bitmap, cliprect, 1);
293      draw_sprites(bitmap, cliprect, 1);
299294      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1, 0);
300295      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 2, 0);
301296      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 2, 0);
302      draw_sprites(machine(), bitmap, cliprect, 0);
297      draw_sprites(bitmap, cliprect, 0);
303298      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0, 0);
304299      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0, 0);
305300      break;
306301
307302   case 3:
308303      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1, 0);
309      draw_sprites(machine(), bitmap, cliprect, 1);
304      draw_sprites(bitmap, cliprect, 1);
310305      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1, 0);
311      draw_sprites(machine(), bitmap, cliprect, 0);
306      draw_sprites(bitmap, cliprect, 0);
312307      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0, 0);
313308      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0, 0);
314309      break;
trunk/src/mame/video/nbmj9195.c
r20971r20972
1010#include "emu.h"
1111#include "includes/nbmj9195.h"
1212
13
14static void nbmj9195_vramflip(running_machine &machine, int vram);
15static void nbmj9195_gfxdraw(running_machine &machine, int vram);
16
17
1813/******************************************************************************
1914
2015
r20971r20972
6863
6964
7065******************************************************************************/
71static int nbmj9195_blitter_r(address_space &space, int offset, int vram)
66int nbmj9195_state::nbmj9195_blitter_r(int offset, int vram)
7267{
73   nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>();
7468   int ret;
75   UINT8 *GFXROM = state->memregion("gfx1")->base();
69   UINT8 *GFXROM = memregion("gfx1")->base();
7670
7771   switch (offset)
7872   {
79      case 0x00:  ret = 0xfe | ((state->m_nb19010_busyflag & 0x01) ^ 0x01); break;    // NB19010 Busy Flag
80      case 0x01:  ret = GFXROM[state->m_blitter_src_addr[vram]]; break;           // NB19010 GFX-ROM Read
73      case 0x00:  ret = 0xfe | ((m_nb19010_busyflag & 0x01) ^ 0x01); break;    // NB19010 Busy Flag
74      case 0x01:  ret = GFXROM[m_blitter_src_addr[vram]]; break;           // NB19010 GFX-ROM Read
8175      default:    ret = 0xff; break;
8276   }
8377
8478   return ret;
8579}
8680
87static void nbmj9195_blitter_w(address_space &space, int offset, int data, int vram)
81void nbmj9195_state::nbmj9195_blitter_w(int offset, int data, int vram)
8882{
89   nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>();
9083   int new_line;
9184
9285   switch (offset)
9386   {
94      case 0x00:  state->m_blitter_direction_x[vram] = (data & 0x01) ? 1 : 0;
95               state->m_blitter_direction_y[vram] = (data & 0x02) ? 1 : 0;
96               state->m_clutmode[vram] = (data & 0x04) ? 1 : 0;
87      case 0x00:  m_blitter_direction_x[vram] = (data & 0x01) ? 1 : 0;
88               m_blitter_direction_y[vram] = (data & 0x02) ? 1 : 0;
89               m_clutmode[vram] = (data & 0x04) ? 1 : 0;
9790            //  if (data & 0x08) popmessage("Unknown GFX Flag!! (0x08)");
98               state->m_transparency[vram] = (data & 0x10) ? 1 : 0;
91               m_transparency[vram] = (data & 0x10) ? 1 : 0;
9992            //  if (data & 0x20) popmessage("Unknown GFX Flag!! (0x20)");
100               state->m_flipscreen[vram] = (data & 0x40) ? 0 : 1;
101               state->m_dispflag[vram] = (data & 0x80) ? 1 : 0;
102               nbmj9195_vramflip(space.machine(), vram);
93               m_flipscreen[vram] = (data & 0x40) ? 0 : 1;
94               m_dispflag[vram] = (data & 0x80) ? 1 : 0;
95               nbmj9195_vramflip(vram);
10396               break;
104      case 0x01:  state->m_scrollx[vram] = (state->m_scrollx[vram] & 0x0100) | data; break;
105      case 0x02:  state->m_scrollx[vram] = (state->m_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100);
106               new_line = space.machine().primary_screen->vpos();
107               if (state->m_flipscreen[vram])
97      case 0x01:  m_scrollx[vram] = (m_scrollx[vram] & 0x0100) | data; break;
98      case 0x02:  m_scrollx[vram] = (m_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100);
99               new_line = machine().primary_screen->vpos();
100               if (m_flipscreen[vram])
108101               {
109                  for ( ; state->m_scanline[vram] < new_line; state->m_scanline[vram]++)
110                     state->m_scrollx_raster[vram][state->m_scanline[vram]] = (((-state->m_scrollx[vram]) - 0x4e)  & 0x1ff) << 1;
102                  for ( ; m_scanline[vram] < new_line; m_scanline[vram]++)
103                     m_scrollx_raster[vram][m_scanline[vram]] = (((-m_scrollx[vram]) - 0x4e)  & 0x1ff) << 1;
111104               }
112105               else
113106               {
114                  for ( ; state->m_scanline[vram] < new_line; state->m_scanline[vram]++)
115                     state->m_scrollx_raster[vram][(state->m_scanline[vram] ^ 0x1ff)] = (((-state->m_scrollx[vram]) - 0x4e)  & 0x1ff) << 1;
107                  for ( ; m_scanline[vram] < new_line; m_scanline[vram]++)
108                     m_scrollx_raster[vram][(m_scanline[vram] ^ 0x1ff)] = (((-m_scrollx[vram]) - 0x4e)  & 0x1ff) << 1;
116109               }
117110               break;
118      case 0x03:  state->m_scrolly[vram] = (state->m_scrolly[vram] & 0x0100) | data; break;
119      case 0x04:  state->m_scrolly[vram] = (state->m_scrolly[vram] & 0x00ff) | ((data << 8) & 0x0100); break;
120      case 0x05:  state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0xffff00) | data; break;
121      case 0x06:  state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0xff00ff) | (data << 8); break;
122      case 0x07:  state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0x00ffff) | (data << 16); break;
123      case 0x08:  state->m_blitter_sizex[vram] = data; break;
124      case 0x09:  state->m_blitter_sizey[vram] = data; break;
125      case 0x0a:  state->m_blitter_destx[vram] = (state->m_blitter_destx[vram]  & 0xff00) | data; break;
126      case 0x0b:  state->m_blitter_destx[vram] = (state->m_blitter_destx[vram]  & 0x00ff) | (data << 8); break;
127      case 0x0c:  state->m_blitter_desty[vram] = (state->m_blitter_desty[vram]  & 0xff00) | data; break;
128      case 0x0d:  state->m_blitter_desty[vram] = (state->m_blitter_desty[vram]  & 0x00ff) | (data << 8);
129               nbmj9195_gfxdraw(space.machine(), vram);
111      case 0x03:  m_scrolly[vram] = (m_scrolly[vram] & 0x0100) | data; break;
112      case 0x04:  m_scrolly[vram] = (m_scrolly[vram] & 0x00ff) | ((data << 8) & 0x0100); break;
113      case 0x05:  m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0xffff00) | data; break;
114      case 0x06:  m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0xff00ff) | (data << 8); break;
115      case 0x07:  m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0x00ffff) | (data << 16); break;
116      case 0x08:  m_blitter_sizex[vram] = data; break;
117      case 0x09:  m_blitter_sizey[vram] = data; break;
118      case 0x0a:  m_blitter_destx[vram] = (m_blitter_destx[vram]  & 0xff00) | data; break;
119      case 0x0b:  m_blitter_destx[vram] = (m_blitter_destx[vram]  & 0x00ff) | (data << 8); break;
120      case 0x0c:  m_blitter_desty[vram] = (m_blitter_desty[vram]  & 0xff00) | data; break;
121      case 0x0d:  m_blitter_desty[vram] = (m_blitter_desty[vram]  & 0x00ff) | (data << 8);
122               nbmj9195_gfxdraw(vram);
130123               break;
131124      default:    break;
132125   }
133126}
134127
135void nbmj9195_clutsel_w(address_space &space, int data)
128void nbmj9195_state::nbmj9195_clutsel_w(int data)
136129{
137   nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>();
138   state->m_clutsel = data;
130   m_clutsel = data;
139131}
140132
141static void nbmj9195_clut_w(address_space &space, int offset, int data, int vram)
133void nbmj9195_state::nbmj9195_clut_w(int offset, int data, int vram)
142134{
143   nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>();
144   state->m_clut[vram][((state->m_clutsel & 0xff) * 0x10) + (offset & 0x0f)] = data;
135   m_clut[vram][((m_clutsel & 0xff) * 0x10) + (offset & 0x0f)] = data;
145136}
146137
147void nbmj9195_gfxflag2_w(address_space &space, int data)
138void nbmj9195_state::nbmj9195_gfxflag2_w(int data)
148139{
149   nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>();
150   state->m_gfxflag2 = data;
140   m_gfxflag2 = data;
151141}
152142
153143/******************************************************************************
154144
155145
156146******************************************************************************/
157static void nbmj9195_vramflip(running_machine &machine, int vram)
147void nbmj9195_state::nbmj9195_vramflip(int vram)
158148{
159   nbmj9195_state *state = machine.driver_data<nbmj9195_state>();
160149   int x, y;
161150   UINT16 color1, color2;
162   int width = machine.primary_screen->width();
163   int height = machine.primary_screen->height();
151   int width = machine().primary_screen->width();
152   int height = machine().primary_screen->height();
164153
165   if (state->m_flipscreen[vram] == state->m_flipscreen_old[vram]) return;
154   if (m_flipscreen[vram] == m_flipscreen_old[vram]) return;
166155
167156   for (y = 0; y < (height / 2); y++)
168157   {
169158      for (x = 0; x < width; x++)
170159      {
171         color1 = state->m_videoram[vram][(y * width) + x];
172         color2 = state->m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)];
173         state->m_videoram[vram][(y * width) + x] = color2;
174         state->m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1;
160         color1 = m_videoram[vram][(y * width) + x];
161         color2 = m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)];
162         m_videoram[vram][(y * width) + x] = color2;
163         m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1;
175164      }
176165   }
177166
178   if (state->m_gfxdraw_mode == 2)
167   if (m_gfxdraw_mode == 2)
179168   {
180169      for (y = 0; y < (height / 2); y++)
181170      {
182171         for (x = 0; x < width; x++)
183172         {
184            color1 = state->m_videoworkram[vram][(y * width) + x];
185            color2 = state->m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)];
186            state->m_videoworkram[vram][(y * width) + x] = color2;
187            state->m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1;
173            color1 = m_videoworkram[vram][(y * width) + x];
174            color2 = m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)];
175            m_videoworkram[vram][(y * width) + x] = color2;
176            m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1;
188177         }
189178      }
190179   }
191180
192   state->m_flipscreen_old[vram] = state->m_flipscreen[vram];
193   state->m_screen_refresh = 1;
181   m_flipscreen_old[vram] = m_flipscreen[vram];
182   m_screen_refresh = 1;
194183}
195184
196static void update_pixel(running_machine &machine, int vram, int x, int y)
185void nbmj9195_state::update_pixel(int vram, int x, int y)
197186{
198   nbmj9195_state *state = machine.driver_data<nbmj9195_state>();
199   UINT16 color = state->m_videoram[vram][(y * machine.primary_screen->width()) + x];
200   state->m_tmpbitmap[vram].pix16(y, x) = color;
187   UINT16 color = m_videoram[vram][(y * machine().primary_screen->width()) + x];
188   m_tmpbitmap[vram].pix16(y, x) = color;
201189}
202190
203191TIMER_CALLBACK_MEMBER(nbmj9195_state::blitter_timer_callback)
r20971r20972
205193   m_nb19010_busyflag = 1;
206194}
207195
208static void nbmj9195_gfxdraw(running_machine &machine, int vram)
196void nbmj9195_state::nbmj9195_gfxdraw(int vram)
209197{
210   nbmj9195_state *state = machine.driver_data<nbmj9195_state>();
211   UINT8 *GFX = state->memregion("gfx1")->base();
212   int width = machine.primary_screen->width();
198   UINT8 *GFX = memregion("gfx1")->base();
199   int width = machine().primary_screen->width();
213200
214201   int x, y;
215202   int dx1, dx2, dy;
r20971r20972
220207   UINT16 color, color1, color2;
221208   int gfxaddr, gfxlen;
222209
223   state->m_nb19010_busyctr = 0;
210   m_nb19010_busyctr = 0;
224211
225   if ((state->m_gfxdraw_mode == 2) && (state->m_clutmode[vram]))
212   if ((m_gfxdraw_mode == 2) && (m_clutmode[vram]))
226213   {
227214      // NB22090 clut256 mode
228      state->m_blitter_sizex[vram] = GFX[((state->m_blitter_src_addr[vram] + 0) & 0x00ffffff)];
229      state->m_blitter_sizey[vram] = GFX[((state->m_blitter_src_addr[vram] + 1) & 0x00ffffff)];
215      m_blitter_sizex[vram] = GFX[((m_blitter_src_addr[vram] + 0) & 0x00ffffff)];
216      m_blitter_sizey[vram] = GFX[((m_blitter_src_addr[vram] + 1) & 0x00ffffff)];
230217   }
231218
232   if (state->m_blitter_direction_x[vram])
219   if (m_blitter_direction_x[vram])
233220   {
234      startx = state->m_blitter_destx[vram];
235      sizex = state->m_blitter_sizex[vram];
221      startx = m_blitter_destx[vram];
222      sizex = m_blitter_sizex[vram];
236223      skipx = 1;
237224   }
238225   else
239226   {
240      startx = state->m_blitter_destx[vram] + state->m_blitter_sizex[vram];
241      sizex = state->m_blitter_sizex[vram];
227      startx = m_blitter_destx[vram] + m_blitter_sizex[vram];
228      sizex = m_blitter_sizex[vram];
242229      skipx = -1;
243230   }
244231
245   if (state->m_blitter_direction_y[vram])
232   if (m_blitter_direction_y[vram])
246233   {
247      starty = state->m_blitter_desty[vram];
248      sizey = state->m_blitter_sizey[vram];
234      starty = m_blitter_desty[vram];
235      sizey = m_blitter_sizey[vram];
249236      skipy = 1;
250237   }
251238   else
252239   {
253      starty = state->m_blitter_desty[vram] + state->m_blitter_sizey[vram];
254      sizey = state->m_blitter_sizey[vram];
240      starty = m_blitter_desty[vram] + m_blitter_sizey[vram];
241      sizey = m_blitter_sizey[vram];
255242      skipy = -1;
256243   }
257244
258   gfxlen = machine.root_device().memregion("gfx1")->bytes();
259   gfxaddr = ((state->m_blitter_src_addr[vram] + 2) & 0x00ffffff);
245   gfxlen = machine().root_device().memregion("gfx1")->bytes();
246   gfxaddr = ((m_blitter_src_addr[vram] + 2) & 0x00ffffff);
260247
261248   for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--)
262249   {
r20971r20972
277264         dx2 = (2 * x + 1) & 0x3ff;
278265         dy = y & 0x1ff;
279266
280         if (!state->m_flipscreen[vram])
267         if (!m_flipscreen[vram])
281268         {
282269            dx1 ^= 0x3ff;
283270            dx2 ^= 0x3ff;
284271            dy ^= 0x1ff;
285272         }
286273
287         if (state->m_blitter_direction_x[vram])
274         if (m_blitter_direction_x[vram])
288275         {
289276            // flip
290277            color1 = (color & 0x0f) >> 0;
r20971r20972
297284            color2 = (color & 0x0f) >> 0;
298285         }
299286
300         if ((state->m_gfxdraw_mode == 2) && (state->m_clutmode[vram]))
287         if ((m_gfxdraw_mode == 2) && (m_clutmode[vram]))
301288         {
302289            // clut256 mode
303290
304            if (state->m_gfxflag2 & 0xc0)
291            if (m_gfxflag2 & 0xc0)
305292            {
306293               // clut256 mode 1st(low)
307               state->m_videoworkram[vram][(dy * width) + dx1] &= 0x00f0;
308               state->m_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f;
309               state->m_videoworkram[vram][(dy * width) + dx2] &= 0x00f0;
310               state->m_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f;
294               m_videoworkram[vram][(dy * width) + dx1] &= 0x00f0;
295               m_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f;
296               m_videoworkram[vram][(dy * width) + dx2] &= 0x00f0;
297               m_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f;
311298
312299               continue;
313300            }
314301            else
315302            {
316303               // clut256 mode 2nd(high)
317               state->m_videoworkram[vram][(dy * width) + dx1] &= 0x000f;
318               state->m_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4;
319               state->m_videoworkram[vram][(dy * width) + dx2] &= 0x000f;
320               state->m_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4;
304               m_videoworkram[vram][(dy * width) + dx1] &= 0x000f;
305               m_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4;
306               m_videoworkram[vram][(dy * width) + dx2] &= 0x000f;
307               m_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4;
321308
322               state->m_videoworkram[vram][(dy * width) + dx1] += state->m_clut[vram][(state->m_clutsel * 0x10)];
323               state->m_videoworkram[vram][(dy * width) + dx2] += state->m_clut[vram][(state->m_clutsel * 0x10)];
309               m_videoworkram[vram][(dy * width) + dx1] += m_clut[vram][(m_clutsel * 0x10)];
310               m_videoworkram[vram][(dy * width) + dx2] += m_clut[vram][(m_clutsel * 0x10)];
324311            }
325312
326            color1 = state->m_videoworkram[vram][(dy * width) + dx1];
327            color2 = state->m_videoworkram[vram][(dy * width) + dx2];
313            color1 = m_videoworkram[vram][(dy * width) + dx1];
314            color2 = m_videoworkram[vram][(dy * width) + dx2];
328315         }
329316         else
330317         {
331318            // clut16 mode
332            color1 = state->m_clut[vram][(state->m_clutsel * 0x10) + color1];
333            color2 = state->m_clut[vram][(state->m_clutsel * 0x10) + color2];
319            color1 = m_clut[vram][(m_clutsel * 0x10) + color1];
320            color2 = m_clut[vram][(m_clutsel * 0x10) + color2];
334321         }
335322
336         if (state->m_gfxdraw_mode == 2)
323         if (m_gfxdraw_mode == 2)
337324         {
338325            color1 |= (0x0100 * vram);
339326            color2 |= (0x0100 * vram);
340327         }
341328
342         if (((color1 & 0x00ff) != 0x00ff) || (!state->m_transparency[vram]))
329         if (((color1 & 0x00ff) != 0x00ff) || (!m_transparency[vram]))
343330         {
344            state->m_videoram[vram][(dy * width) + dx1] = color1;
345            update_pixel(machine, vram, dx1, dy);
331            m_videoram[vram][(dy * width) + dx1] = color1;
332            update_pixel(vram, dx1, dy);
346333         }
347         if (((color2 & 0x00ff) != 0x00ff) || (!state->m_transparency[vram]))
334         if (((color2 & 0x00ff) != 0x00ff) || (!m_transparency[vram]))
348335         {
349            state->m_videoram[vram][(dy * width) + dx2] = color2;
350            update_pixel(machine, vram, dx2, dy);
336            m_videoram[vram][(dy * width) + dx2] = color2;
337            update_pixel(vram, dx2, dy);
351338         }
352339
353         state->m_nb19010_busyctr++;
340         m_nb19010_busyctr++;
354341      }
355342   }
356343
357   if ((state->m_gfxdraw_mode == 2) && (state->m_clutmode[vram]))
344   if ((m_gfxdraw_mode == 2) && (m_clutmode[vram]))
358345   {
359346      // NB22090 clut256 mode
360      state->m_blitter_src_addr[vram] = gfxaddr;
347      m_blitter_src_addr[vram] = gfxaddr;
361348   }
362349
363   state->m_nb19010_busyflag = 0;
350   m_nb19010_busyflag = 0;
364351
365352   /* 1650ns per count */
366   machine.scheduler().timer_set(attotime::from_nsec(state->m_nb19010_busyctr * 1650), timer_expired_delegate(FUNC(nbmj9195_state::blitter_timer_callback),state));
353   machine().scheduler().timer_set(attotime::from_nsec(m_nb19010_busyctr * 1650), timer_expired_delegate(FUNC(nbmj9195_state::blitter_timer_callback),this));
367354}
368355
369356/******************************************************************************
370357
371358
372359******************************************************************************/
373WRITE8_MEMBER(nbmj9195_state::nbmj9195_blitter_0_w){ nbmj9195_blitter_w(space, offset, data, 0); }
374WRITE8_MEMBER(nbmj9195_state::nbmj9195_blitter_1_w){ nbmj9195_blitter_w(space, offset, data, 1); }
360WRITE8_MEMBER(nbmj9195_state::nbmj9195_blitter_0_w){ nbmj9195_blitter_w(offset, data, 0); }
361WRITE8_MEMBER(nbmj9195_state::nbmj9195_blitter_1_w){ nbmj9195_blitter_w(offset, data, 1); }
375362
376READ8_MEMBER(nbmj9195_state::nbmj9195_blitter_0_r){ return nbmj9195_blitter_r(space, offset, 0); }
377READ8_MEMBER(nbmj9195_state::nbmj9195_blitter_1_r){ return nbmj9195_blitter_r(space, offset, 1); }
363READ8_MEMBER(nbmj9195_state::nbmj9195_blitter_0_r){ return nbmj9195_blitter_r(offset, 0); }
364READ8_MEMBER(nbmj9195_state::nbmj9195_blitter_1_r){ return nbmj9195_blitter_r(offset, 1); }
378365
379WRITE8_MEMBER(nbmj9195_state::nbmj9195_clut_0_w){ nbmj9195_clut_w(space, offset, data, 0); }
380WRITE8_MEMBER(nbmj9195_state::nbmj9195_clut_1_w){ nbmj9195_clut_w(space, offset, data, 1); }
366WRITE8_MEMBER(nbmj9195_state::nbmj9195_clut_0_w){ nbmj9195_clut_w(offset, data, 0); }
367WRITE8_MEMBER(nbmj9195_state::nbmj9195_clut_1_w){ nbmj9195_clut_w(offset, data, 1); }
381368
382369/******************************************************************************
383370
r20971r20972
453440      for (y = 0; y < height; y++)
454441         for (x = 0; x < width; x++)
455442         {
456            update_pixel(machine(), 0, x, y);
443            update_pixel(0, x, y);
457444
458445            if (m_gfxdraw_mode)
459               update_pixel(machine(), 1, x, y);
446               update_pixel(1, x, y);
460447         }
461448   }
462449
trunk/src/mame/video/niyanpai.c
r20971r20972
99#include "emu.h"
1010#include "includes/niyanpai.h"
1111
12
13static void niyanpai_vramflip(running_machine &machine, int vram);
14static void niyanpai_gfxdraw(running_machine &machine, int vram);
15
16
1712/******************************************************************************
1813
1914
r20971r20972
6257
6358
6459******************************************************************************/
65static int niyanpai_blitter_r(running_machine &machine, int vram, int offset)
60int niyanpai_state::niyanpai_blitter_r(int vram, int offset)
6661{
67   niyanpai_state *state = machine.driver_data<niyanpai_state>();
6862   int ret;
69   UINT8 *GFXROM = state->memregion("gfx1")->base();
63   UINT8 *GFXROM = memregion("gfx1")->base();
7064
7165   switch (offset)
7266   {
73      case 0x00:  ret = 0xfe | ((state->m_nb19010_busyflag & 0x01) ^ 0x01); break;    // NB19010 Busy Flag
74      case 0x01:  ret = GFXROM[state->m_blitter_src_addr[vram]]; break;           // NB19010 GFX-ROM Read
67      case 0x00:  ret = 0xfe | ((m_nb19010_busyflag & 0x01) ^ 0x01); break;    // NB19010 Busy Flag
68      case 0x01:  ret = GFXROM[m_blitter_src_addr[vram]]; break;           // NB19010 GFX-ROM Read
7569      default:    ret = 0xff; break;
7670   }
7771
7872   return ret;
7973}
8074
81static void niyanpai_blitter_w(running_machine &machine, int vram, int offset, int data)
75void niyanpai_state::niyanpai_blitter_w(int vram, int offset, int data)
8276{
83   niyanpai_state *state = machine.driver_data<niyanpai_state>();
8477   switch (offset)
8578   {
86      case 0x00:  state->m_blitter_direction_x[vram] = (data & 0x01) ? 1 : 0;
87               state->m_blitter_direction_y[vram] = (data & 0x02) ? 1 : 0;
88               state->m_clutmode[vram] = (data & 0x04) ? 1 : 0;
79      case 0x00:  m_blitter_direction_x[vram] = (data & 0x01) ? 1 : 0;
80               m_blitter_direction_y[vram] = (data & 0x02) ? 1 : 0;
81               m_clutmode[vram] = (data & 0x04) ? 1 : 0;
8982            //  if (data & 0x08) popmessage("Unknown GFX Flag!! (0x08)");
90               state->m_transparency[vram] = (data & 0x10) ? 1 : 0;
83               m_transparency[vram] = (data & 0x10) ? 1 : 0;
9184            //  if (data & 0x20) popmessage("Unknown GFX Flag!! (0x20)");
92               state->m_flipscreen[vram] = (data & 0x40) ? 0 : 1;
93               state->m_dispflag[vram] = (data & 0x80) ? 1 : 0;
94               niyanpai_vramflip(machine, vram);
85               m_flipscreen[vram] = (data & 0x40) ? 0 : 1;
86               m_dispflag[vram] = (data & 0x80) ? 1 : 0;
87               niyanpai_vramflip(vram);
9588               break;
96      case 0x01:  state->m_scrollx[vram] = (state->m_scrollx[vram] & 0x0100) | data; break;
97      case 0x02:  state->m_scrollx[vram] = (state->m_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100); break;
98      case 0x03:  state->m_scrolly[vram] = (state->m_scrolly[vram] & 0x0100) | data; break;
99      case 0x04:  state->m_scrolly[vram] = (state->m_scrolly[vram] & 0x00ff) | ((data << 8) & 0x0100); break;
100      case 0x05:  state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0xffff00) | data; break;
101      case 0x06:  state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0xff00ff) | (data << 8); break;
102      case 0x07:  state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0x00ffff) | (data << 16); break;
103      case 0x08:  state->m_blitter_sizex[vram] = data; break;
104      case 0x09:  state->m_blitter_sizey[vram] = data; break;
105      case 0x0a:  state->m_blitter_destx[vram] = (state->m_blitter_destx[vram]  & 0xff00) | data; break;
106      case 0x0b:  state->m_blitter_destx[vram] = (state->m_blitter_destx[vram]  & 0x00ff) | (data << 8); break;
107      case 0x0c:  state->m_blitter_desty[vram] = (state->m_blitter_desty[vram]  & 0xff00) | data; break;
108      case 0x0d:  state->m_blitter_desty[vram] = (state->m_blitter_desty[vram]  & 0x00ff) | (data << 8);
109               niyanpai_gfxdraw(machine, vram);
89      case 0x01:  m_scrollx[vram] = (m_scrollx[vram] & 0x0100) | data; break;
90      case 0x02:  m_scrollx[vram] = (m_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100); break;
91      case 0x03:  m_scrolly[vram] = (m_scrolly[vram] & 0x0100) | data; break;
92      case 0x04:  m_scrolly[vram] = (m_scrolly[vram] & 0x00ff) | ((data << 8) & 0x0100); break;
93      case 0x05:  m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0xffff00) | data; break;
94      case 0x06:  m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0xff00ff) | (data << 8); break;
95      case 0x07:  m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0x00ffff) | (data << 16); break;
96      case 0x08:  m_blitter_sizex[vram] = data; break;
97      case 0x09:  m_blitter_sizey[vram] = data; break;
98      case 0x0a:  m_blitter_destx[vram] = (m_blitter_destx[vram]  & 0xff00) | data; break;
99      case 0x0b:  m_blitter_destx[vram] = (m_blitter_destx[vram]  & 0x00ff) | (data << 8); break;
100      case 0x0c:  m_blitter_desty[vram] = (m_blitter_desty[vram]  & 0xff00) | data; break;
101      case 0x0d:  m_blitter_desty[vram] = (m_blitter_desty[vram]  & 0x00ff) | (data << 8);
102               niyanpai_gfxdraw(vram);
110103               break;
111104      default:    break;
112105   }
113106}
114107
115static void niyanpai_clutsel_w(running_machine &machine, int vram, int data)
108void niyanpai_state::niyanpai_clutsel_w(int vram, int data)
116109{
117   niyanpai_state *state = machine.driver_data<niyanpai_state>();
118   state->m_clutsel[vram] = data;
110   m_clutsel[vram] = data;
119111}
120112
121static void niyanpai_clut_w(running_machine &machine, int vram, int offset, int data)
113void niyanpai_state::niyanpai_clut_w(int vram, int offset, int data)
122114{
123   niyanpai_state *state = machine.driver_data<niyanpai_state>();
124   state->m_clut[vram][((state->m_clutsel[vram] & 0xff) * 0x10) + (offset & 0x0f)] = data;
115   m_clut[vram][((m_clutsel[vram] & 0xff) * 0x10) + (offset & 0x0f)] = data;
125116}
126117
127118/******************************************************************************
128119
129120
130121******************************************************************************/
131static void niyanpai_vramflip(running_machine &machine, int vram)
122void niyanpai_state::niyanpai_vramflip(int vram)
132123{
133   niyanpai_state *state = machine.driver_data<niyanpai_state>();
134124   int x, y;
135125   UINT16 color1, color2;
136   int width = machine.primary_screen->width();
137   int height = machine.primary_screen->height();
126   int width = machine().primary_screen->width();
127   int height = machine().primary_screen->height();
138128
139   if (state->m_flipscreen[vram] == state->m_flipscreen_old[vram]) return;
129   if (m_flipscreen[vram] == m_flipscreen_old[vram]) return;
140130
141131   for (y = 0; y < (height / 2); y++)
142132   {
143133      for (x = 0; x < width; x++)
144134      {
145         color1 = state->m_videoram[vram][(y * width) + x];
146         color2 = state->m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)];
147         state->m_videoram[vram][(y * width) + x] = color2;
148         state->m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1;
135         color1 = m_videoram[vram][(y * width) + x];
136         color2 = m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)];
137         m_videoram[vram][(y * width) + x] = color2;
138         m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1;
149139      }
150140   }
151141
r20971r20972
153143   {
154144      for (x = 0; x < width; x++)
155145      {
156         color1 = state->m_videoworkram[vram][(y * width) + x];
157         color2 = state->m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)];
158         state->m_videoworkram[vram][(y * width) + x] = color2;
159         state->m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1;
146         color1 = m_videoworkram[vram][(y * width) + x];
147         color2 = m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)];
148         m_videoworkram[vram][(y * width) + x] = color2;
149         m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1;
160150      }
161151   }
162152
163   state->m_flipscreen_old[vram] = state->m_flipscreen[vram];
164   state->m_screen_refresh = 1;
153   m_flipscreen_old[vram] = m_flipscreen[vram];
154   m_screen_refresh = 1;
165155}
166156
167static void update_pixel(running_machine &machine, int vram, int x, int y)
157void niyanpai_state::update_pixel(int vram, int x, int y)
168158{
169   niyanpai_state *state = machine.driver_data<niyanpai_state>();
170   UINT16 color = state->m_videoram[vram][(y * machine.primary_screen->width()) + x];
171   state->m_tmpbitmap[vram].pix16(y, x) = color;
159   UINT16 color = m_videoram[vram][(y * machine().primary_screen->width()) + x];
160   m_tmpbitmap[vram].pix16(y, x) = color;
172161}
173162
174163TIMER_CALLBACK_MEMBER(niyanpai_state::blitter_timer_callback)
r20971r20972
176165   m_nb19010_busyflag = 1;
177166}
178167
179static void niyanpai_gfxdraw(running_machine &machine, int vram)
168void niyanpai_state::niyanpai_gfxdraw(int vram)
180169{
181   niyanpai_state *state = machine.driver_data<niyanpai_state>();
182   UINT8 *GFX = state->memregion("gfx1")->base();
183   int width = machine.primary_screen->width();
170   UINT8 *GFX = memregion("gfx1")->base();
171   int width = machine().primary_screen->width();
184172
185173   int x, y;
186174   int dx1, dx2, dy;
r20971r20972
191179   UINT16 color, color1, color2;
192180   int gfxaddr, gfxlen;
193181
194   state->m_nb19010_busyctr = 0;
182   m_nb19010_busyctr = 0;
195183
196   if (state->m_clutmode[vram])
184   if (m_clutmode[vram])
197185   {
198186      // NB22090 clut256 mode
199      state->m_blitter_sizex[vram] = GFX[((state->m_blitter_src_addr[vram] + 0) & 0x00ffffff)];
200      state->m_blitter_sizey[vram] = GFX[((state->m_blitter_src_addr[vram] + 1) & 0x00ffffff)];
187      m_blitter_sizex[vram] = GFX[((m_blitter_src_addr[vram] + 0) & 0x00ffffff)];
188      m_blitter_sizey[vram] = GFX[((m_blitter_src_addr[vram] + 1) & 0x00ffffff)];
201189   }
202190
203   if (state->m_blitter_direction_x[vram])
191   if (m_blitter_direction_x[vram])
204192   {
205      startx = state->m_blitter_destx[vram];
206      sizex = state->m_blitter_sizex[vram];
193      startx = m_blitter_destx[vram];
194      sizex = m_blitter_sizex[vram];
207195      skipx = 1;
208196   }
209197   else
210198   {
211      startx = state->m_blitter_destx[vram] + state->m_blitter_sizex[vram];
212      sizex = state->m_blitter_sizex[vram];
199      startx = m_blitter_destx[vram] + m_blitter_sizex[vram];
200      sizex = m_blitter_sizex[vram];
213201      skipx = -1;
214202   }
215203
216   if (state->m_blitter_direction_y[vram])
204   if (m_blitter_direction_y[vram])
217205   {
218      starty = state->m_blitter_desty[vram];
219      sizey = state->m_blitter_sizey[vram];
206      starty = m_blitter_desty[vram];
207      sizey = m_blitter_sizey[vram];
220208      skipy = 1;
221209   }
222210   else
223211   {
224      starty = state->m_blitter_desty[vram] + state->m_blitter_sizey[vram];
225      sizey = state->m_blitter_sizey[vram];
212      starty = m_blitter_desty[vram] + m_blitter_sizey[vram];
213      sizey = m_blitter_sizey[vram];
226214      skipy = -1;
227215   }
228216
229   gfxlen = machine.root_device().memregion("gfx1")->bytes();
230   gfxaddr = ((state->m_blitter_src_addr[vram] + 2) & 0x00ffffff);
217   gfxlen = machine().root_device().memregion("gfx1")->bytes();
218   gfxaddr = ((m_blitter_src_addr[vram] + 2) & 0x00ffffff);
231219
232220   for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--)
233221   {
r20971r20972
248236         dx2 = (2 * x + 1) & 0x3ff;
249237         dy = y & 0x1ff;
250238
251         if (!state->m_flipscreen[vram])
239         if (!m_flipscreen[vram])
252240         {
253241            dx1 ^= 0x3ff;
254242            dx2 ^= 0x3ff;
255243            dy ^= 0x1ff;
256244         }
257245
258         if (state->m_blitter_direction_x[vram])
246         if (m_blitter_direction_x[vram])
259247         {
260248            // flip
261249            color1 = (color & 0x0f) >> 0;
r20971r20972
268256            color2 = (color & 0x0f) >> 0;
269257         }
270258
271         if (state->m_clutmode[vram])
259         if (m_clutmode[vram])
272260         {
273261            // clut256 mode
274262
275            if (state->m_clutsel[vram] & 0x80)
263            if (m_clutsel[vram] & 0x80)
276264            {
277265               // clut256 mode 1st(low)
278               state->m_videoworkram[vram][(dy * width) + dx1] &= 0x00f0;
279               state->m_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f;
280               state->m_videoworkram[vram][(dy * width) + dx2] &= 0x00f0;
281               state->m_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f;
266               m_videoworkram[vram][(dy * width) + dx1] &= 0x00f0;
267               m_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f;
268               m_videoworkram[vram][(dy * width) + dx2] &= 0x00f0;
269               m_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f;
282270
283271               continue;
284272            }
285273            else
286274            {
287275               // clut256 mode 2nd(high)
288               state->m_videoworkram[vram][(dy * width) + dx1] &= 0x000f;
289               state->m_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4;
290               state->m_videoworkram[vram][(dy * width) + dx2] &= 0x000f;
291               state->m_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4;
276               m_videoworkram[vram][(dy * width) + dx1] &= 0x000f;
277               m_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4;
278               m_videoworkram[vram][(dy * width) + dx2] &= 0x000f;
279               m_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4;
292280
293      //          state->m_videoworkram[vram][(dy * width) + dx1] += state->m_clut[vram][(state->m_clutsel[vram] * 0x10)];
294      //          state->m_videoworkram[vram][(dy * width) + dx2] += state->m_clut[vram][(state->m_clutsel[vram] * 0x10)];
281      //          m_videoworkram[vram][(dy * width) + dx1] += m_clut[vram][(m_clutsel[vram] * 0x10)];
282      //          m_videoworkram[vram][(dy * width) + dx2] += m_clut[vram][(m_clutsel[vram] * 0x10)];
295283            }
296284
297            color1 = state->m_videoworkram[vram][(dy * width) + dx1];
298            color2 = state->m_videoworkram[vram][(dy * width) + dx2];
285            color1 = m_videoworkram[vram][(dy * width) + dx1];
286            color2 = m_videoworkram[vram][(dy * width) + dx2];
299287         }
300288         else
301289         {
302290            // clut16 mode
303            color1 = state->m_clut[vram][(state->m_clutsel[vram] * 0x10) + color1];
304            color2 = state->m_clut[vram][(state->m_clutsel[vram] * 0x10) + color2];
291            color1 = m_clut[vram][(m_clutsel[vram] * 0x10) + color1];
292            color2 = m_clut[vram][(m_clutsel[vram] * 0x10) + color2];
305293         }
306294
307295         color1 |= (0x0100 * vram);
308296         color2 |= (0x0100 * vram);
309297
310         if (((color1 & 0x00ff) != 0x00ff) || (!state->m_transparency[vram]))
298         if (((color1 & 0x00ff) != 0x00ff) || (!m_transparency[vram]))
311299         {
312            state->m_videoram[vram][(dy * width) + dx1] = color1;
313            update_pixel(machine, vram, dx1, dy);
300            m_videoram[vram][(dy * width) + dx1] = color1;
301            update_pixel(vram, dx1, dy);
314302         }
315         if (((color2 & 0x00ff) != 0x00ff) || (!state->m_transparency[vram]))
303         if (((color2 & 0x00ff) != 0x00ff) || (!m_transparency[vram]))
316304         {
317            state->m_videoram[vram][(dy * width) + dx2] = color2;
318            update_pixel(machine, vram, dx2, dy);
305            m_videoram[vram][(dy * width) + dx2] = color2;
306            update_pixel(vram, dx2, dy);
319307         }
320308
321         state->m_nb19010_busyctr++;
309         m_nb19010_busyctr++;
322310      }
323311   }
324312
325   if (state->m_clutmode[vram])
313   if (m_clutmode[vram])
326314   {
327315      // NB22090 clut256 mode
328      state->m_blitter_src_addr[vram] = gfxaddr;
316      m_blitter_src_addr[vram] = gfxaddr;
329317   }
330318
331   state->m_nb19010_busyflag = 0;
332   machine.scheduler().timer_set(attotime::from_nsec(1000 * state->m_nb19010_busyctr), timer_expired_delegate(FUNC(niyanpai_state::blitter_timer_callback),state));
319   m_nb19010_busyflag = 0;
320   machine().scheduler().timer_set(attotime::from_nsec(1000 * m_nb19010_busyctr), timer_expired_delegate(FUNC(niyanpai_state::blitter_timer_callback),this));
333321}
334322
335323/******************************************************************************
336324
337325
338326******************************************************************************/
339WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_0_w){ niyanpai_blitter_w(machine(), 0, offset, data); }
340WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_1_w){ niyanpai_blitter_w(machine(), 1, offset, data); }
341WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_2_w){ niyanpai_blitter_w(machine(), 2, offset, data); }
327WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_0_w){ niyanpai_blitter_w(0, offset, data); }
328WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_1_w){ niyanpai_blitter_w(1, offset, data); }
329WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_2_w){ niyanpai_blitter_w(2, offset, data); }
342330
343READ16_MEMBER(niyanpai_state::niyanpai_blitter_0_r){ return niyanpai_blitter_r(machine(), 0, offset); }
344READ16_MEMBER(niyanpai_state::niyanpai_blitter_1_r){ return niyanpai_blitter_r(machine(), 1, offset); }
345READ16_MEMBER(niyanpai_state::niyanpai_blitter_2_r){ return niyanpai_blitter_r(machine(), 2, offset); }
331READ16_MEMBER(niyanpai_state::niyanpai_blitter_0_r){ return niyanpai_blitter_r(0, offset); }
332READ16_MEMBER(niyanpai_state::niyanpai_blitter_1_r){ return niyanpai_blitter_r(1, offset); }
333READ16_MEMBER(niyanpai_state::niyanpai_blitter_2_r){ return niyanpai_blitter_r(2, offset); }
346334
347WRITE16_MEMBER(niyanpai_state::niyanpai_clut_0_w){ niyanpai_clut_w(machine(), 0, offset, data); }
348WRITE16_MEMBER(niyanpai_state::niyanpai_clut_1_w){ niyanpai_clut_w(machine(), 1, offset, data); }
349WRITE16_MEMBER(niyanpai_state::niyanpai_clut_2_w){ niyanpai_clut_w(machine(), 2, offset, data); }
335WRITE16_MEMBER(niyanpai_state::niyanpai_clut_0_w){ niyanpai_clut_w(0, offset, data); }
336WRITE16_MEMBER(niyanpai_state::niyanpai_clut_1_w){ niyanpai_clut_w(1, offset, data); }
337WRITE16_MEMBER(niyanpai_state::niyanpai_clut_2_w){ niyanpai_clut_w(2, offset, data); }
350338
351WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_0_w){ niyanpai_clutsel_w(machine(), 0, data); }
352WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_1_w){ niyanpai_clutsel_w(machine(), 1, data); }
353WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_2_w){ niyanpai_clutsel_w(machine(), 2, data); }
339WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_0_w){ niyanpai_clutsel_w(0, data); }
340WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_1_w){ niyanpai_clutsel_w(1, data); }
341WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_2_w){ niyanpai_clutsel_w(2, data); }
354342
355343/******************************************************************************
356344
r20971r20972
397385      for (y = 0; y < height; y++)
398386         for (x = 0; x < width; x++)
399387         {
400            update_pixel(machine(), 0, x, y);
401            update_pixel(machine(), 1, x, y);
402            update_pixel(machine(), 2, x, y);
388            update_pixel(0, x, y);
389            update_pixel(1, x, y);
390            update_pixel(2, x, y);
403391         }
404392   }
405393
trunk/src/mame/video/neogeo.c
r20971r20972
1818 *
1919 *************************************/
2020
21static void set_videoram_offset( running_machine &machine, UINT16 data )
21void neogeo_state::set_videoram_offset( UINT16 data )
2222{
23   neogeo_state *state = machine.driver_data<neogeo_state>();
24   state->m_videoram_offset = data;
23   m_videoram_offset = data;
2524
2625   /* the read happens right away */
27   state->m_videoram_read_buffer = state->m_videoram[state->m_videoram_offset];
26   m_videoram_read_buffer = m_videoram[m_videoram_offset];
2827}
2928
3029
31static UINT16 get_videoram_data( running_machine &machine )
30UINT16 neogeo_state::get_videoram_data(  )
3231{
33   neogeo_state *state = machine.driver_data<neogeo_state>();
34   return state->m_videoram_read_buffer;
32   return m_videoram_read_buffer;
3533}
3634
3735
38static void set_videoram_data( running_machine &machine, UINT16 data)
36void neogeo_state::set_videoram_data( UINT16 data)
3937{
40   neogeo_state *state = machine.driver_data<neogeo_state>();
41   state->m_videoram[state->m_videoram_offset] = data;
38   m_videoram[m_videoram_offset] = data;
4239
4340   /* auto increment/decrement the current offset - A15 is NOT effected */
44   state->m_videoram_offset = (state->m_videoram_offset & 0x8000) | ((state->m_videoram_offset + state->m_videoram_modulo) & 0x7fff);
41   m_videoram_offset = (m_videoram_offset & 0x8000) | ((m_videoram_offset + m_videoram_modulo) & 0x7fff);
4542
4643   /* read next value right away */
47   state->m_videoram_read_buffer = state->m_videoram[state->m_videoram_offset];
44   m_videoram_read_buffer = m_videoram[m_videoram_offset];
4845}
4946
5047
51static void set_videoram_modulo( running_machine &machine, UINT16 data)
48void neogeo_state::set_videoram_modulo( UINT16 data)
5249{
53   neogeo_state *state = machine.driver_data<neogeo_state>();
54   state->m_videoram_modulo = data;
50   m_videoram_modulo = data;
5551}
5652
5753
58static UINT16 get_videoram_modulo( running_machine &machine )
54UINT16 neogeo_state::get_videoram_modulo(  )
5955{
60   neogeo_state *state = machine.driver_data<neogeo_state>();
61   return state->m_videoram_modulo;
56   return m_videoram_modulo;
6257}
6358
6459
r20971r20972
6964 *
7065 *************************************/
7166
72static void compute_rgb_weights( running_machine &machine )
67void neogeo_state::compute_rgb_weights(  )
7368{
74   neogeo_state *state = machine.driver_data<neogeo_state>();
7569   static const int resistances[] = { 220, 470, 1000, 2200, 3900 };
7670
7771   /* compute four sets of weights - with or without the pulldowns -
7872      ensuring that we use the same scaler for all */
7973
8074   double scaler = compute_resistor_weights(0, 0xff, -1,
81                        5, resistances, state->m_rgb_weights_normal, 0, 0,
75                        5, resistances, m_rgb_weights_normal, 0, 0,
8276                        0, 0, 0, 0, 0,
8377                        0, 0, 0, 0, 0);
8478
8579   compute_resistor_weights(0, 0xff, scaler,
86                        5, resistances, state->m_rgb_weights_normal_bit15, 8200, 0,
80                        5, resistances, m_rgb_weights_normal_bit15, 8200, 0,
8781                        0, 0, 0, 0, 0,
8882                        0, 0, 0, 0, 0);
8983
9084   compute_resistor_weights(0, 0xff, scaler,
91                        5, resistances, state->m_rgb_weights_dark, 150, 0,
85                        5, resistances, m_rgb_weights_dark, 150, 0,
9286                        0, 0, 0, 0, 0,
9387                        0, 0, 0, 0, 0);
9488
9589   compute_resistor_weights(0, 0xff, scaler,
96                        5, resistances, state->m_rgb_weights_dark_bit15, 1 / ((1.0 / 8200) + (1.0 / 150)), 0,
90                        5, resistances, m_rgb_weights_dark_bit15, 1 / ((1.0 / 8200) + (1.0 / 150)), 0,
9791                        0, 0, 0, 0, 0,
9892                        0, 0, 0, 0, 0);
9993}
10094
10195
102static pen_t get_pen( running_machine &machine, UINT16 data )
96pen_t neogeo_state::get_pen( UINT16 data )
10397{
104   neogeo_state *state = machine.driver_data<neogeo_state>();
10598   double *weights;
10699   UINT8 r, g, b;
107100
108   if (state->m_screen_dark)
101   if (m_screen_dark)
109102   {
110103      if (data & 0x8000)
111         weights = state->m_rgb_weights_dark_bit15;
104         weights = m_rgb_weights_dark_bit15;
112105      else
113         weights = state->m_rgb_weights_dark;
106         weights = m_rgb_weights_dark;
114107   }
115108   else
116109   {
117110      if (data & 0x8000)
118         weights = state->m_rgb_weights_normal_bit15;
111         weights = m_rgb_weights_normal_bit15;
119112      else
120         weights = state->m_rgb_weights_normal;
113         weights = m_rgb_weights_normal;
121114   }
122115
123116   r = combine_5_weights(weights,
r20971r20972
150143   int i;
151144
152145   for (i = 0; i < NUM_PENS; i++)
153      m_pens[i] = get_pen(machine(), m_palettes[m_palette_bank][i]);
146      m_pens[i] = get_pen(m_palettes[m_palette_bank][i]);
154147}
155148
156149
157void neogeo_set_palette_bank( running_machine &machine, UINT8 data )
150void neogeo_state::neogeo_set_palette_bank( UINT8 data )
158151{
159   neogeo_state *state = machine.driver_data<neogeo_state>();
160   if (data != state->m_palette_bank)
152   if (data != m_palette_bank)
161153   {
162      state->m_palette_bank = data;
154      m_palette_bank = data;
163155
164      state->regenerate_pens();
156      regenerate_pens();
165157   }
166158}
167159
168160
169void neogeo_set_screen_dark( running_machine &machine, UINT8 data )
161void neogeo_state::neogeo_set_screen_dark( UINT8 data )
170162{
171   neogeo_state *state = machine.driver_data<neogeo_state>();
172   if (data != state->m_screen_dark)
163   if (data != m_screen_dark)
173164   {
174      state->m_screen_dark = data;
165      m_screen_dark = data;
175166
176      state->regenerate_pens();
167      regenerate_pens();
177168   }
178169}
179170
r20971r20972
190181
191182   COMBINE_DATA(addr);
192183
193   m_pens[offset] = get_pen(machine(), *addr);
184   m_pens[offset] = get_pen(*addr);
194185}
195186
196187
r20971r20972
201192 *
202193 *************************************/
203194
204static void set_auto_animation_speed( running_machine &machine, UINT8 data)
195void neogeo_state::set_auto_animation_speed( UINT8 data)
205196{
206   neogeo_state *state = machine.driver_data<neogeo_state>();
207   state->m_auto_animation_speed = data;
197   m_auto_animation_speed = data;
208198}
209199
210200
211static void set_auto_animation_disabled( running_machine &machine, UINT8 data)
201void neogeo_state::set_auto_animation_disabled( UINT8 data)
212202{
213   neogeo_state *state = machine.driver_data<neogeo_state>();
214   state->m_auto_animation_disabled = data;
203   m_auto_animation_disabled = data;
215204}
216205
217206
218UINT8 neogeo_get_auto_animation_counter( running_machine &machine )
207UINT8 neogeo_state::neogeo_get_auto_animation_counter(  )
219208{
220   neogeo_state *state = machine.driver_data<neogeo_state>();
221   return state->m_auto_animation_counter;
209   return m_auto_animation_counter;
222210}
223211
224212
r20971r20972
236224}
237225
238226
239static void create_auto_animation_timer( running_machine &machine )
227void neogeo_state::create_auto_animation_timer(  )
240228{
241   neogeo_state *state = machine.driver_data<neogeo_state>();
242   state->m_auto_animation_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(neogeo_state::auto_animation_timer_callback),state));
229   m_auto_animation_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(neogeo_state::auto_animation_timer_callback),this));
243230}
244231
245232
246static void start_auto_animation_timer( running_machine &machine )
233void neogeo_state::start_auto_animation_timer(  )
247234{
248   neogeo_state *state = machine.driver_data<neogeo_state>();
249   state->m_auto_animation_timer->adjust(machine.primary_screen->time_until_pos(NEOGEO_VSSTART));
235   m_auto_animation_timer->adjust(machine().primary_screen->time_until_pos(NEOGEO_VSSTART));
250236}
251237
252238
r20971r20972
257243 *
258244 *************************************/
259245
260void neogeo_set_fixed_layer_source( running_machine &machine, UINT8 data )
246void neogeo_state::neogeo_set_fixed_layer_source( UINT8 data )
261247{
262   neogeo_state *state = machine.driver_data<neogeo_state>();
263   state->m_fixed_layer_source = data;
248   m_fixed_layer_source = data;
264249}
265250
266251
r20971r20972
376361};
377362
378363
379INLINE int rows_to_height(int rows)
364inline int neogeo_state::rows_to_height(int rows)
380365{
381366   if ((rows == 0) || (rows > 0x20))
382367      rows = 0x20;
r20971r20972
385370}
386371
387372
388INLINE int sprite_on_scanline(int scanline, int y, int rows)
373inline int neogeo_state::sprite_on_scanline(int scanline, int y, int rows)
389374{
390375   /* check if the current scanline falls inside this sprite,
391376      two possible scenerios, wrap around or not */
r20971r20972
396381}
397382
398383
399static void draw_sprites( running_machine &machine, bitmap_rgb32 &bitmap, int scanline )
384void neogeo_state::draw_sprites( bitmap_rgb32 &bitmap, int scanline )
400385{
401   neogeo_state *state = machine.driver_data<neogeo_state>();
402386   int sprite_index;
403387   int max_sprite_index;
404388
r20971r20972
411395
412396   /* select the active list */
413397   if (scanline & 0x01)
414      sprite_list = &state->m_videoram[0x8680];
398      sprite_list = &m_videoram[0x8680];
415399   else
416      sprite_list = &state->m_videoram[0x8600];
400      sprite_list = &m_videoram[0x8600];
417401
418402   /* optimization -- find last non-zero entry and only draw that many +1
419403      sprite.  This is not 100% correct as the hardware will keep drawing
r20971r20972
431415   for (sprite_index = 0; sprite_index <= max_sprite_index; sprite_index++)
432416   {
433417      UINT16 sprite_number = sprite_list[sprite_index] & 0x01ff;
434      UINT16 y_control = state->m_videoram[0x8200 | sprite_number];
435      UINT16 zoom_control = state->m_videoram[0x8000 | sprite_number];
418      UINT16 y_control = m_videoram[0x8200 | sprite_number];
419      UINT16 zoom_control = m_videoram[0x8000 | sprite_number];
436420
437421      /* if chained, go to next X coordinate and get new X zoom */
438422      if (y_control & 0x40)
r20971r20972
444428      else
445429      {
446430         y = 0x200 - (y_control >> 7);
447         x = state->m_videoram[0x8400 | sprite_number] >> 7;
431         x = m_videoram[0x8400 | sprite_number] >> 7;
448432         zoom_y = zoom_control & 0xff;
449433         zoom_x = (zoom_control >> 8) & 0x0f;
450434         rows = y_control & 0x3f;
r20971r20972
487471            }
488472         }
489473
490         sprite_y_and_tile = state->m_region_zoomy[(zoom_y << 8) | zoom_line];
474         sprite_y_and_tile = m_region_zoomy[(zoom_y << 8) | zoom_line];
491475         sprite_y = sprite_y_and_tile & 0x0f;
492476         tile = sprite_y_and_tile >> 4;
493477
r20971r20972
498482         }
499483
500484         attr_and_code_offs = (sprite_number << 6) | (tile << 1);
501         attr = state->m_videoram[attr_and_code_offs + 1];
502         code = ((attr << 12) & 0x70000) | state->m_videoram[attr_and_code_offs];
485         attr = m_videoram[attr_and_code_offs + 1];
486         code = ((attr << 12) & 0x70000) | m_videoram[attr_and_code_offs];
503487
504488         /* substitute auto animation bits */
505         if (!state->m_auto_animation_disabled)
489         if (!m_auto_animation_disabled)
506490         {
507491            if (attr & 0x0008)
508               code = (code & ~0x07) | (state->m_auto_animation_counter & 0x07);
492               code = (code & ~0x07) | (m_auto_animation_counter & 0x07);
509493            else if (attr & 0x0004)
510               code = (code & ~0x03) | (state->m_auto_animation_counter & 0x03);
494               code = (code & ~0x03) | (m_auto_animation_counter & 0x03);
511495         }
512496
513497         /* vertical flip? */
r20971r20972
517501         zoom_x_table = zoom_x_tables[zoom_x];
518502
519503         /* compute offset in gfx ROM and mask it to the number of bits available */
520         gfx = &state->m_sprite_gfx[((code << 8) | (sprite_y << 4)) & state->m_sprite_gfx_address_mask];
504         gfx = &m_sprite_gfx[((code << 8) | (sprite_y << 4)) & m_sprite_gfx_address_mask];
521505
522         line_pens = &state->m_pens[attr >> 8 << 4];
506         line_pens = &m_pens[attr >> 8 << 4];
523507
524508         /* horizontal flip? */
525509         if (attr & 0x0001)
r20971r20972
585569}
586570
587571
588static void parse_sprites( running_machine &machine, int scanline )
572void neogeo_state::parse_sprites( int scanline )
589573{
590   neogeo_state *state = machine.driver_data<neogeo_state>();
591574   UINT16 sprite_number;
592575   int y = 0;
593576   int rows = 0;
r20971r20972
597580
598581   /* select the active list */
599582   if (scanline & 0x01)
600      sprite_list = &state->m_videoram[0x8680];
583      sprite_list = &m_videoram[0x8680];
601584   else
602      sprite_list = &state->m_videoram[0x8600];
585      sprite_list = &m_videoram[0x8600];
603586
604587   /* scan all sprites */
605588   for (sprite_number = 0; sprite_number < MAX_SPRITES_PER_SCREEN; sprite_number++)
606589   {
607      UINT16 y_control = state->m_videoram[0x8200 | sprite_number];
590      UINT16 y_control = m_videoram[0x8200 | sprite_number];
608591
609592      /* if not chained, get Y position and height, otherwise use previous values */
610593      if (~y_control & 0x40)
r20971r20972
646629   if (scanline != 0)
647630      machine().primary_screen->update_partial(scanline - 1);
648631
649   parse_sprites(machine(), scanline);
632   parse_sprites(scanline);
650633
651634   /* let's come back at the beginning of the next line */
652635   scanline = (scanline + 1) % NEOGEO_VTOTAL;
r20971r20972
655638}
656639
657640
658static void create_sprite_line_timer( running_machine &machine )
641void neogeo_state::create_sprite_line_timer(  )
659642{
660   neogeo_state *state = machine.driver_data<neogeo_state>();
661   state->m_sprite_line_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(neogeo_state::sprite_line_timer_callback),state));
643   m_sprite_line_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(neogeo_state::sprite_line_timer_callback),this));
662644}
663645
664646
665static void start_sprite_line_timer( running_machine &machine )
647void neogeo_state::start_sprite_line_timer(  )
666648{
667   neogeo_state *state = machine.driver_data<neogeo_state>();
668   state->m_sprite_line_timer->adjust(machine.primary_screen->time_until_pos(0));
649   m_sprite_line_timer->adjust(machine().primary_screen->time_until_pos(0));
669650}
670651
671652
r20971r20972
733714 *
734715 *************************************/
735716
736static UINT16 get_video_control( running_machine &machine )
717UINT16 neogeo_state::get_video_control(  )
737718{
738719   UINT16 ret;
739720   UINT16 v_counter;
r20971r20972
760741   */
761742
762743   /* the vertical counter chain goes from 0xf8 - 0x1ff */
763   v_counter = machine.primary_screen->vpos() + 0x100;
744   v_counter = machine().primary_screen->vpos() + 0x100;
764745
765746   if (v_counter >= 0x200)
766747      v_counter = v_counter - NEOGEO_VTOTAL;
767748
768   ret = (v_counter << 7) | (neogeo_get_auto_animation_counter(machine) & 0x0007);
749   ret = (v_counter << 7) | (neogeo_get_auto_animation_counter() & 0x0007);
769750
770   if (VERBOSE) logerror("%s: video_control read (%04x)\n", machine.describe_context(), ret);
751   if (VERBOSE) logerror("%s: video_control read (%04x)\n", machine().describe_context(), ret);
771752
772753   return ret;
773754}
r20971r20972
778759   /* this does much more than this, but I'm not sure exactly what */
779760   if (VERBOSE) logerror("%s: video control write %04x\n", machine().describe_context(), data);
780761
781   set_auto_animation_speed(machine(), data >> 8);
782   set_auto_animation_disabled(machine(), data & 0x0008);
762   set_auto_animation_speed(data >> 8);
763   set_auto_animation_disabled(data & 0x0008);
783764
784765   neogeo_set_display_position_interrupt_control(data & 0x00f0);
785766}
r20971r20972
798779      {
799780      default:
800781      case 0x00:
801      case 0x01: ret = get_videoram_data(machine()); break;
802      case 0x02: ret = get_videoram_modulo(machine()); break;
803      case 0x03: ret = get_video_control(machine()); break;
782      case 0x01: ret = get_videoram_data(); break;
783      case 0x02: ret = get_videoram_modulo(); break;
784      case 0x03: ret = get_video_control(); break;
804785      }
805786   }
806787
r20971r20972
819800
820801      switch (offset)
821802      {
822      case 0x00: set_videoram_offset(machine(), data); break;
823      case 0x01: set_videoram_data(machine(), data); break;
824      case 0x02: set_videoram_modulo(machine(), data); break;
803      case 0x00: set_videoram_offset(data); break;
804      case 0x01: set_videoram_data(data); break;
805      case 0x02: set_videoram_modulo(data); break;
825806      case 0x03: set_video_control(data); break;
826807      case 0x04: neogeo_set_display_counter_msb(data); break;
827808      case 0x05: neogeo_set_display_counter_lsb(data); break;
r20971r20972
853834   memset(m_pens, 0x00, NUM_PENS * sizeof(pen_t));
854835   memset(m_videoram, 0x00, 0x20000);
855836
856   compute_rgb_weights(machine());
857   create_sprite_line_timer(machine());
858   create_auto_animation_timer(machine());
837   compute_rgb_weights();
838   create_sprite_line_timer();
839   create_auto_animation_timer();
859840   optimize_sprite_data();
860841
861842   /* initialize values that are not modified on a reset */
r20971r20972
897878
898879void neogeo_state::video_reset()
899880{
900   start_sprite_line_timer(machine());
901   start_auto_animation_timer(machine());
881   start_sprite_line_timer();
882   start_auto_animation_timer();
902883   optimize_sprite_data();
903884}
904885
r20971r20972
915896   /* fill with background color first */
916897   bitmap.fill(m_pens[0x0fff], cliprect);
917898
918   if (m_has_sprite_bus) draw_sprites(machine(), bitmap, cliprect.min_y);
899   if (m_has_sprite_bus) draw_sprites(bitmap, cliprect.min_y);
919900
920901   if (m_has_text_bus) draw_fixed_layer(bitmap, cliprect.min_y);
921902
trunk/src/mame/video/nemesis.c
r20971r20972
311311}
312312
313313
314static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
314void nemesis_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
315315{
316316   /*
317317    *  16 bytes per sprite, in memory from 56000-56fff
r20971r20972
328328    *  byte    E : not used.
329329    */
330330
331   nemesis_state *state = machine.driver_data<nemesis_state>();
332   UINT16 *spriteram = state->m_spriteram;
331   UINT16 *spriteram = m_spriteram;
333332   int address;    /* start of sprite in spriteram */
334333   int sx; /* sprite X-pos */
335334   int sy; /* sprite Y-pos */
r20971r20972
345344
346345   for (priority = 256 - 1; priority >= 0; priority--)
347346   {
348      for (address = state->m_spriteram_words - 8; address >= 0; address -= 8)
347      for (address = m_spriteram_words - 8; address >= 0; address -= 8)
349348      {
350349         if((spriteram[address] & 0xff) != priority)
351350            continue;
r20971r20972
379378            if (zoom)
380379            {
381380               zoom = ((1 << 16) * 0x80 / zoom) + 0x02ab;
382               if (state->m_flipscreen)
381               if (m_flipscreen)
383382               {
384383                  sx = 256 - ((zoom * w) >> 16) - sx;
385384                  sy = 256 - ((zoom * h) >> 16) - sy;
r20971r20972
387386                  flipy = !flipy;
388387               }
389388
390               pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[char_type],
389               pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[char_type],
391390                  code,
392391                  color,
393392                  flipx,flipy,
394393                  sx,sy,
395394                  zoom,zoom,
396                  machine.priority_bitmap,0xffcc,0 );
395                  machine().priority_bitmap,0xffcc,0 );
397396            }
398397         }
399398      }
r20971r20972
452451      }
453452   }
454453
455   draw_sprites(machine(),bitmap,cliprect);
454   draw_sprites(bitmap,cliprect);
456455
457456   return 0;
458457}
trunk/src/mess/drivers/ng_aes.c
r20971r20972
11561156   m_recurse = 0;
11571157
11581158   /* AES apparently always uses the cartridge's fixed bank mode */
1159   neogeo_set_fixed_layer_source(machine(),1);
1159   neogeo_set_fixed_layer_source(1);
11601160
11611161   NeoSpriteRAM = memregion("sprites")->base();
11621162   YM2610ADPCMAROM = memregion("ymsnd")->base();

Previous 199869 Revisions Next


© 1997-2024 The MAME Team