Previous 199869 Revisions Next

r20833 Friday 8th February, 2013 at 14:27:23 UTC by Miodrag Milanović
Modernization of drivers part 11 (no whatsnew)
[src/mame/drivers]ataxx.c legionna.c leland.c lordgun.c lwings.c
[src/mame/includes]labyrunr.h ladybug.h ladyfrog.h lasso.h lastduel.h lazercmd.h legionna.h leland.h lemmings.h lethalj.h liberate.h lkage.h lockon.h lordgun.h lsasquad.h lwings.h
[src/mame/machine]leland.c
[src/mame/video]labyrunr.c ladybug.c ladyfrog.c lasso.c lastduel.c lazercmd.c legionna.c leland.c lemmings.c lethalj.c liberate.c lkage.c lockon.c lordgun.c lsasquad.c lwings.c redclash.c

trunk/src/mame/machine/leland.c
r20832r20833
4444 *
4545 *************************************/
4646
47static int dial_compute_value(running_machine &machine, int new_val, int indx)
47int leland_state::dial_compute_value(int new_val, int indx)
4848{
49   leland_state *state = machine.driver_data<leland_state>();
50   int delta = new_val - (int)state->m_dial_last_input[indx];
51   UINT8 result = state->m_dial_last_result[indx] & 0x80;
49   int delta = new_val - (int)m_dial_last_input[indx];
50   UINT8 result = m_dial_last_result[indx] & 0x80;
5251
53   state->m_dial_last_input[indx] = new_val;
52   m_dial_last_input[indx] = new_val;
5453
5554   if (delta > 0x80)
5655      delta -= 0x100;
r20832r20833
6766
6867   if (delta > 0x1f)
6968      delta = 0x1f;
70   result |= (state->m_dial_last_result[indx] + delta) & 0x1f;
69   result |= (m_dial_last_result[indx] + delta) & 0x1f;
7170
72   state->m_dial_last_result[indx] = result;
71   m_dial_last_result[indx] = result;
7372   return result;
7473}
7574
r20832r20833
8483READ8_MEMBER(leland_state::cerberus_dial_1_r)
8584{
8685   int original = ioport("IN0")->read();
87   int modified = dial_compute_value(machine(), ioport("AN0")->read(), 0);
86   int modified = dial_compute_value(ioport("AN0")->read(), 0);
8887   return (original & 0xc0) | ((modified & 0x80) >> 2) | (modified & 0x1f);
8988}
9089
r20832r20833
9291READ8_MEMBER(leland_state::cerberus_dial_2_r)
9392{
9493   int original = ioport("IN0")->read();
95   int modified = dial_compute_value(machine(), ioport("AN1")->read(), 1);
94   int modified = dial_compute_value(ioport("AN1")->read(), 1);
9695   return (original & 0xc0) | ((modified & 0x80) >> 2) | (modified & 0x1f);
9796}
9897
r20832r20833
133132 *
134133 *************************************/
135134
136static void update_dangerz_xy(running_machine &machine)
135void leland_state::update_dangerz_xy()
137136{
138   leland_state *state = machine.driver_data<leland_state>();
139   UINT8 newy = state->ioport("AN0")->read();
140   UINT8 newx = state->ioport("AN1")->read();
141   int deltay = newy - state->m_dial_last_input[0];
142   int deltax = newx - state->m_dial_last_input[1];
137   UINT8 newy = ioport("AN0")->read();
138   UINT8 newx = ioport("AN1")->read();
139   int deltay = newy - m_dial_last_input[0];
140   int deltax = newx - m_dial_last_input[1];
143141
144142   if (deltay <= -128) deltay += 256;
145143   else if (deltay >= 128) deltay -= 256;
146144   if (deltax <= -128) deltax += 256;
147145   else if (deltax >= 128) deltax -= 256;
148146
149   state->m_dangerz_y += deltay;
150   state->m_dangerz_x += deltax;
151   if (state->m_dangerz_y < 0) state->m_dangerz_y = 0;
152   else if (state->m_dangerz_y >= 1024) state->m_dangerz_y = 1023;
153   if (state->m_dangerz_x < 0) state->m_dangerz_x = 0;
154   else if (state->m_dangerz_x >= 1024) state->m_dangerz_x = 1023;
147   m_dangerz_y += deltay;
148   m_dangerz_x += deltax;
149   if (m_dangerz_y < 0) m_dangerz_y = 0;
150   else if (m_dangerz_y >= 1024) m_dangerz_y = 1023;
151   if (m_dangerz_x < 0) m_dangerz_x = 0;
152   else if (m_dangerz_x >= 1024) m_dangerz_x = 1023;
155153
156   state->m_dial_last_input[0] = newy;
157   state->m_dial_last_input[1] = newx;
154   m_dial_last_input[0] = newy;
155   m_dial_last_input[1] = newx;
158156}
159157
160158
161159READ8_MEMBER(leland_state::dangerz_input_y_r)
162160{
163   update_dangerz_xy(machine());
161   update_dangerz_xy();
164162   return m_dangerz_y & 0xff;
165163}
166164
167165
168166READ8_MEMBER(leland_state::dangerz_input_x_r)
169167{
170   update_dangerz_xy(machine());
168   update_dangerz_xy();
171169   return m_dangerz_x & 0xff;
172170}
173171
174172
175173READ8_MEMBER(leland_state::dangerz_input_upper_r)
176174{
177   update_dangerz_xy(machine());
175   update_dangerz_xy();
178176   return ((m_dangerz_y >> 2) & 0xc0) | ((m_dangerz_x >> 8) & 0x03);
179177}
180178
r20832r20833
204202
205203READ8_MEMBER(leland_state::redline_wheel_1_r)
206204{
207   return dial_compute_value(machine(), ioport("AN0")->read(), 0);
205   return dial_compute_value(ioport("AN0")->read(), 0);
208206}
209207
210208
211209READ8_MEMBER(leland_state::redline_wheel_2_r)
212210{
213   return dial_compute_value(machine(), ioport("AN1")->read(), 1);
211   return dial_compute_value(ioport("AN1")->read(), 1);
214212}
215213
216214
r20832r20833
223221
224222READ8_MEMBER(leland_state::offroad_wheel_1_r)
225223{
226   return dial_compute_value(machine(), ioport("AN3")->read(), 0);
224   return dial_compute_value(ioport("AN3")->read(), 0);
227225}
228226
229227
230228READ8_MEMBER(leland_state::offroad_wheel_2_r)
231229{
232   return dial_compute_value(machine(), ioport("AN4")->read(), 1);
230   return dial_compute_value(ioport("AN4")->read(), 1);
233231}
234232
235233
236234READ8_MEMBER(leland_state::offroad_wheel_3_r)
237235{
238   return dial_compute_value(machine(), ioport("AN5")->read(), 2);
236   return dial_compute_value(ioport("AN5")->read(), 2);
239237}
240238
241239
r20832r20833
250248{
251249   static const char *const tracknames[] = { "AN0", "AN1", "AN2", "AN3" };
252250
253   return dial_compute_value(machine(), ioport(tracknames[offset])->read(), offset);
251   return dial_compute_value(ioport(tracknames[offset])->read(), offset);
254252}
255253
256254
r20832r20833
265263{
266264   static const char *const tracknames[] = { "AN0", "AN1", "AN2" };
267265
268   return dial_compute_value(machine(), ioport(tracknames[offset])->read(), offset);
266   return dial_compute_value(ioport(tracknames[offset])->read(), offset);
269267}
270268
271269
r20832r20833
355353   /* initialize the master banks */
356354   m_master_length = memregion("master")->bytes();
357355   m_master_base = memregion("master")->base();
358   (*m_update_master_bank)(machine());
356   (this->*m_update_master_bank)();
359357
360358   /* initialize the slave banks */
361359   m_slave_length = memregion("slave")->bytes();
r20832r20833
399397   /* initialize the master banks */
400398   m_master_length = memregion("master")->bytes();
401399   m_master_base = memregion("master")->base();
402   ataxx_bankswitch(machine());
400   ataxx_bankswitch();
403401
404402   /* initialize the slave banks */
405403   m_slave_length = memregion("slave")->bytes();
r20832r20833
466464      if ((m_alternate_bank ^ data) & 0x0f)
467465         logerror("%04X:alternate_bank = %02X\n", space.device().safe_pc(), data & 0x0f);
468466   m_alternate_bank = data & 15;
469   (*m_update_master_bank)(machine());
467   (this->*m_update_master_bank)();
470468
471469   /* sound control is in the rest */
472470   leland_80186_control_w(machine().device("custom"), space, offset, data);
r20832r20833
474472
475473
476474/* bankswitching for Cerberus */
477void cerberus_bankswitch(running_machine &machine)
475void leland_state::cerberus_bankswitch()
478476{
479477   /* no bankswitching */
480478}
481479
482480
483481/* bankswitching for Mayhem 2002, Power Play, World Series Baseball, and Alley Master */
484void mayhem_bankswitch(running_machine &machine)
482void leland_state::mayhem_bankswitch()
485483{
486   leland_state *state = machine.driver_data<leland_state>();
487484   UINT8 *address;
488485
489   state->m_battery_ram_enable = ((state->m_sound_port_bank & 0x24) == 0);
486   m_battery_ram_enable = ((m_sound_port_bank & 0x24) == 0);
490487
491   address = (!(state->m_sound_port_bank & 0x04)) ? &state->m_master_base[0x10000] : &state->m_master_base[0x1c000];
492   state->membank("bank1")->set_base(address);
488   address = (!(m_sound_port_bank & 0x04)) ? &m_master_base[0x10000] : &m_master_base[0x1c000];
489   membank("bank1")->set_base(address);
493490
494   address = state->m_battery_ram_enable ? state->m_battery_ram : &address[0x8000];
495   state->membank("bank2")->set_base(address);
491   address = m_battery_ram_enable ? m_battery_ram : &address[0x8000];
492   membank("bank2")->set_base(address);
496493}
497494
498495
499496/* bankswitching for Danger Zone */
500void dangerz_bankswitch(running_machine &machine)
497void leland_state::dangerz_bankswitch()
501498{
502   leland_state *state = machine.driver_data<leland_state>();
503499   UINT8 *address;
504500
505   state->m_battery_ram_enable = ((state->m_top_board_bank & 0x80) != 0);
501   m_battery_ram_enable = ((m_top_board_bank & 0x80) != 0);
506502
507   address = (!(state->m_alternate_bank & 1)) ? &state->m_master_base[0x02000] : &state->m_master_base[0x12000];
508   state->membank("bank1")->set_base(address);
503   address = (!(m_alternate_bank & 1)) ? &m_master_base[0x02000] : &m_master_base[0x12000];
504   membank("bank1")->set_base(address);
509505
510   address = state->m_battery_ram_enable ? state->m_battery_ram : &address[0x8000];
511   state->membank("bank2")->set_base(address);
506   address = m_battery_ram_enable ? m_battery_ram : &address[0x8000];
507   membank("bank2")->set_base(address);
512508}
513509
514510
515511/* bankswitching for Baseball the Season II, Super Baseball, and Strike Zone */
516void basebal2_bankswitch(running_machine &machine)
512void leland_state::basebal2_bankswitch()
517513{
518   leland_state *state = machine.driver_data<leland_state>();
519514   UINT8 *address;
520515
521   state->m_battery_ram_enable = (state->m_top_board_bank & 0x80);
516   m_battery_ram_enable = (m_top_board_bank & 0x80);
522517
523   if (!state->m_battery_ram_enable)
524      address = (!(state->m_sound_port_bank & 0x04)) ? &state->m_master_base[0x10000] : &state->m_master_base[0x1c000];
518   if (!m_battery_ram_enable)
519      address = (!(m_sound_port_bank & 0x04)) ? &m_master_base[0x10000] : &m_master_base[0x1c000];
525520   else
526      address = (!(state->m_top_board_bank & 0x40)) ? &state->m_master_base[0x28000] : &state->m_master_base[0x30000];
527   state->membank("bank1")->set_base(address);
521      address = (!(m_top_board_bank & 0x40)) ? &m_master_base[0x28000] : &m_master_base[0x30000];
522   membank("bank1")->set_base(address);
528523
529   address = state->m_battery_ram_enable ? state->m_battery_ram : &address[0x8000];
530   state->membank("bank2")->set_base(address);
524   address = m_battery_ram_enable ? m_battery_ram : &address[0x8000];
525   membank("bank2")->set_base(address);
531526}
532527
533528
534529/* bankswitching for Red Line Racer */
535void redline_bankswitch(running_machine &machine)
530void leland_state::redline_bankswitch()
536531{
537   leland_state *state = machine.driver_data<leland_state>();
538532   static const UINT32 bank_list[] = { 0x10000, 0x18000, 0x02000, 0x02000 };
539533   UINT8 *address;
540534
541   state->m_battery_ram_enable = ((state->m_alternate_bank & 3) == 1);
535   m_battery_ram_enable = ((m_alternate_bank & 3) == 1);
542536
543   address = &state->m_master_base[bank_list[state->m_alternate_bank & 3]];
544   state->membank("bank1")->set_base(address);
537   address = &m_master_base[bank_list[m_alternate_bank & 3]];
538   membank("bank1")->set_base(address);
545539
546   address = state->m_battery_ram_enable ? state->m_battery_ram : &state->m_master_base[0xa000];
547   state->membank("bank2")->set_base(address);
540   address = m_battery_ram_enable ? m_battery_ram : &m_master_base[0xa000];
541   membank("bank2")->set_base(address);
548542}
549543
550544
551545/* bankswitching for Viper, Quarterback, Team Quarterback, and All American Football */
552void viper_bankswitch(running_machine &machine)
546void leland_state::viper_bankswitch()
553547{
554   leland_state *state = machine.driver_data<leland_state>();
555548   static const UINT32 bank_list[] = { 0x02000, 0x10000, 0x18000, 0x02000 };
556549   UINT8 *address;
557550
558   state->m_battery_ram_enable = ((state->m_alternate_bank & 0x04) != 0);
551   m_battery_ram_enable = ((m_alternate_bank & 0x04) != 0);
559552
560   address = &state->m_master_base[bank_list[state->m_alternate_bank & 3]];
561   if (bank_list[state->m_alternate_bank & 3] >= state->m_master_length)
553   address = &m_master_base[bank_list[m_alternate_bank & 3]];
554   if (bank_list[m_alternate_bank & 3] >= m_master_length)
562555   {
563      logerror("%s:Master bank %02X out of range!\n", machine.describe_context(), state->m_alternate_bank & 3);
564      address = &state->m_master_base[bank_list[0]];
556      logerror("%s:Master bank %02X out of range!\n", machine().describe_context(), m_alternate_bank & 3);
557      address = &m_master_base[bank_list[0]];
565558   }
566   state->membank("bank1")->set_base(address);
559   membank("bank1")->set_base(address);
567560
568   address = state->m_battery_ram_enable ? state->m_battery_ram : &state->m_master_base[0xa000];
569   state->membank("bank2")->set_base(address);
561   address = m_battery_ram_enable ? m_battery_ram : &m_master_base[0xa000];
562   membank("bank2")->set_base(address);
570563}
571564
572565
573566/* bankswitching for Super Offroad, Super Offroad Track Pack, and Pig Out */
574void offroad_bankswitch(running_machine &machine)
567void leland_state::offroad_bankswitch()
575568{
576   leland_state *state = machine.driver_data<leland_state>();
577569   static const UINT32 bank_list[] = { 0x02000, 0x02000, 0x10000, 0x18000, 0x20000, 0x28000, 0x30000, 0x38000 };
578570   UINT8 *address;
579571
580   state->m_battery_ram_enable = ((state->m_alternate_bank & 7) == 1);
572   m_battery_ram_enable = ((m_alternate_bank & 7) == 1);
581573
582   address = &state->m_master_base[bank_list[state->m_alternate_bank & 7]];
583   if (bank_list[state->m_alternate_bank & 7] >= state->m_master_length)
574   address = &m_master_base[bank_list[m_alternate_bank & 7]];
575   if (bank_list[m_alternate_bank & 7] >= m_master_length)
584576   {
585      logerror("%s:Master bank %02X out of range!\n", machine.describe_context(), state->m_alternate_bank & 7);
586      address = &state->m_master_base[bank_list[0]];
577      logerror("%s:Master bank %02X out of range!\n", machine().describe_context(), m_alternate_bank & 7);
578      address = &m_master_base[bank_list[0]];
587579   }
588   state->membank("bank1")->set_base(address);
580   membank("bank1")->set_base(address);
589581
590   address = state->m_battery_ram_enable ? state->m_battery_ram : &state->m_master_base[0xa000];
591   state->membank("bank2")->set_base(address);
582   address = m_battery_ram_enable ? m_battery_ram : &m_master_base[0xa000];
583   membank("bank2")->set_base(address);
592584}
593585
594586
595587/* bankswitching for Ataxx, WSF, Indy Heat, and Brute Force */
596void ataxx_bankswitch(running_machine &machine)
588void leland_state::ataxx_bankswitch()
597589{
598   leland_state *state = machine.driver_data<leland_state>();
599590   static const UINT32 bank_list[] =
600591   {
601592      0x02000, 0x18000, 0x20000, 0x28000, 0x30000, 0x38000, 0x40000, 0x48000,
r20832r20833
603594   };
604595   UINT8 *address;
605596
606   state->m_battery_ram_enable = ((state->m_master_bank & 0x30) == 0x10);
597   m_battery_ram_enable = ((m_master_bank & 0x30) == 0x10);
607598
608   address = &state->m_master_base[bank_list[state->m_master_bank & 15]];
609   if (bank_list[state->m_master_bank & 15] >= state->m_master_length)
599   address = &m_master_base[bank_list[m_master_bank & 15]];
600   if (bank_list[m_master_bank & 15] >= m_master_length)
610601   {
611      logerror("%s:Master bank %02X out of range!\n", machine.describe_context(), state->m_master_bank & 15);
612      address = &state->m_master_base[bank_list[0]];
602      logerror("%s:Master bank %02X out of range!\n", machine().describe_context(), m_master_bank & 15);
603      address = &m_master_base[bank_list[0]];
613604   }
614   state->membank("bank1")->set_base(address);
605   membank("bank1")->set_base(address);
615606
616   if (state->m_battery_ram_enable)
617      address = state->m_battery_ram;
618   else if ((state->m_master_bank & 0x30) == 0x20)
619      address = &state->m_ataxx_qram[(state->m_master_bank & 0xc0) << 8];
607   if (m_battery_ram_enable)
608      address = m_battery_ram;
609   else if ((m_master_bank & 0x30) == 0x20)
610      address = &m_ataxx_qram[(m_master_bank & 0xc0) << 8];
620611   else
621      address = &state->m_master_base[0xa000];
622   state->membank("bank2")->set_base(address);
612      address = &m_master_base[0xa000];
613   membank("bank2")->set_base(address);
623614
624   state->m_wcol_enable = ((state->m_master_bank & 0x30) == 0x30);
615   m_wcol_enable = ((m_master_bank & 0x30) == 0x30);
625616}
626617
627618
r20832r20833
632623 *
633624 *************************************/
634625
635void leland_init_eeprom(running_machine &machine, UINT8 default_val, const UINT16 *data, UINT8 serial_offset, UINT8 serial_type)
626void leland_state::leland_init_eeprom(UINT8 default_val, const UINT16 *data, UINT8 serial_offset, UINT8 serial_type)
636627{
637628   UINT8 xorval = (serial_type == SERIAL_TYPE_ADD_XOR || serial_type == SERIAL_TYPE_ENCRYPT_XOR) ? 0xff : 0x00;
638629   UINT8 eeprom_data[64*2];
r20832r20833
743734 *
744735 *************************************/
745736
746void ataxx_init_eeprom(running_machine &machine, const UINT16 *data)
737void leland_state::ataxx_init_eeprom(const UINT16 *data)
747738{
748739   UINT8 eeprom_data[128*2];
749740   UINT8 serial_offset = 0;
r20832r20833
918909
919910--------------------------------------------------------------------*/
920911
921static int keycard_r(running_machine &machine)
912int leland_state::keycard_r()
922913{
923   leland_state *state = machine.driver_data<leland_state>();
924914   int result = 0;
925915
926   if (LOG_KEYCARDS_FULL) logerror("  (%s:keycard_r)\n", machine.describe_context());
916   if (LOG_KEYCARDS_FULL) logerror("  (%s:keycard_r)\n", machine().describe_context());
927917
928918   /* if we have a valid keycard read state, we're reading from the keycard */
929   if (state->m_keycard_state & 0x80)
919   if (m_keycard_state & 0x80)
930920   {
931921      /* clock in new data */
932      if (state->m_keycard_bit == 1)
922      if (m_keycard_bit == 1)
933923      {
934         state->m_keycard_shift = 0xff;  /* no data, but this is where we would clock it in */
935         if (LOG_KEYCARDS) logerror("  (clocked in %02X)\n", state->m_keycard_shift);
924         m_keycard_shift = 0xff;  /* no data, but this is where we would clock it in */
925         if (LOG_KEYCARDS) logerror("  (clocked in %02X)\n", m_keycard_shift);
936926      }
937927
938928      /* clock in the bit */
939      result = (~state->m_keycard_shift & 1) << ((state->m_keycard_state >> 4) & 3);
929      result = (~m_keycard_shift & 1) << ((m_keycard_state >> 4) & 3);
940930      if (LOG_KEYCARDS) logerror("  (read %02X)\n", result);
941931   }
942932   return result;
943933}
944934
945static void keycard_w(running_machine &machine, int data)
935void leland_state::keycard_w(int data)
946936{
947   leland_state *state = machine.driver_data<leland_state>();
948937   int new_state = data & 0xb0;
949938   int new_clock = data & 0x40;
950939
951   if (LOG_KEYCARDS_FULL) logerror("  (%s:keycard_w=%02X)\n", machine.describe_context(), data);
940   if (LOG_KEYCARDS_FULL) logerror("  (%s:keycard_w=%02X)\n", machine().describe_context(), data);
952941
953942   /* check for going active */
954   if (!state->m_keycard_state && new_state)
943   if (!m_keycard_state && new_state)
955944   {
956      state->m_keycard_command[0] = state->m_keycard_command[1] = state->m_keycard_command[2] = 0;
945      m_keycard_command[0] = m_keycard_command[1] = m_keycard_command[2] = 0;
957946      if (LOG_KEYCARDS) logerror("keycard going active (state=%02X)\n", new_state);
958947   }
959948
960949   /* check for going inactive */
961   else if (state->m_keycard_state && !new_state)
950   else if (m_keycard_state && !new_state)
962951   {
963      state->m_keycard_command[0] = state->m_keycard_command[1] = state->m_keycard_command[2] = 0;
952      m_keycard_command[0] = m_keycard_command[1] = m_keycard_command[2] = 0;
964953      if (LOG_KEYCARDS) logerror("keycard going inactive\n");
965954   }
966955
967956   /* check for clocks */
968   else if (state->m_keycard_state == new_state)
957   else if (m_keycard_state == new_state)
969958   {
970959      /* work off of falling edge */
971      if (!new_clock && state->m_keycard_clock)
960      if (!new_clock && m_keycard_clock)
972961      {
973         state->m_keycard_shift >>= 1;
974         state->m_keycard_bit = (state->m_keycard_bit + 1) & 7;
962         m_keycard_shift >>= 1;
963         m_keycard_bit = (m_keycard_bit + 1) & 7;
975964      }
976965
977966      /* look for a bit write */
978      else if (!new_clock && !state->m_keycard_clock && !(data & 0x80))
967      else if (!new_clock && !m_keycard_clock && !(data & 0x80))
979968      {
980969         if (LOG_KEYCARDS) logerror("  (write %02X)\n", data);
981970
982         state->m_keycard_shift &= ~0x80;
971         m_keycard_shift &= ~0x80;
983972         if (data & (1 << ((new_state >> 4) & 3)))
984            state->m_keycard_shift |= 0x80;
973            m_keycard_shift |= 0x80;
985974
986975         /* clock out the data on the last bit */
987         if (state->m_keycard_bit == 7)
976         if (m_keycard_bit == 7)
988977         {
989            if (LOG_KEYCARDS) logerror("  (clocked out %02X)\n", state->m_keycard_shift);
990            state->m_keycard_command[0] = state->m_keycard_command[1];
991            state->m_keycard_command[1] = state->m_keycard_command[2];
992            state->m_keycard_command[2] = state->m_keycard_shift;
993            if (state->m_keycard_command[0] == 0x62 && state->m_keycard_command[1] == 0x00 && state->m_keycard_command[2] == 0x80)
978            if (LOG_KEYCARDS) logerror("  (clocked out %02X)\n", m_keycard_shift);
979            m_keycard_command[0] = m_keycard_command[1];
980            m_keycard_command[1] = m_keycard_command[2];
981            m_keycard_command[2] = m_keycard_shift;
982            if (m_keycard_command[0] == 0x62 && m_keycard_command[1] == 0x00 && m_keycard_command[2] == 0x80)
994983            {
995984               if (LOG_KEYCARDS) logerror("  (got command $62)\n");
996985            }
r20832r20833
1002991   else
1003992   {
1004993      /* only an error if the selected bit changes; read/write transitions are okay */
1005      if ((new_state & 0x30) != (state->m_keycard_state & 0x30))
1006         if (LOG_KEYCARDS) logerror("ERROR: Caught keycard state transition %02X -> %02X\n", state->m_keycard_state, new_state);
994      if ((new_state & 0x30) != (m_keycard_state & 0x30))
995         if (LOG_KEYCARDS) logerror("ERROR: Caught keycard state transition %02X -> %02X\n", m_keycard_state, new_state);
1007996   }
1008997
1009   state->m_keycard_state = new_state;
1010   state->m_keycard_clock = new_clock;
998   m_keycard_state = new_state;
999   m_keycard_clock = new_clock;
10111000}
10121001
10131002
r20832r20833
10341023         break;
10351024
10361025      case 0x02:  /* FF = keycard serial data read */
1037         result = keycard_r(machine());
1026         result = keycard_r();
10381027
10391028         /* bit 7 indicates the analog input is busy for some games */
10401029         result &= ~0x80;
r20832r20833
10621051            if ((m_top_board_bank ^ data) & 0xc0)
10631052               logerror("%04X:top_board_bank = %02X\n", space.device().safe_pc(), data & 0xc0);
10641053         m_top_board_bank = data & 0xc0;
1065         (*m_update_master_bank)(machine());
1054         (this->*m_update_master_bank)();
10661055         break;
10671056
10681057      case 0x02:  /* FF = keycard data write */
1069         keycard_w(machine(), data);
1058         keycard_w(data);
10701059         break;
10711060   }
10721061}
r20832r20833
12011190            if ((m_master_bank ^ data) & 0xff)
12021191               logerror("%04X:master_bank = %02X\n", space.device().safe_pc(), data & 0xff);
12031192         m_master_bank = data;
1204         ataxx_bankswitch(machine());
1193         ataxx_bankswitch();
12051194         break;
12061195
12071196      case 0x05:  /* /SLV0 */
r20832r20833
13221311      if ((m_sound_port_bank ^ data) & 0x24)
13231312         logerror("%s:sound_port_bank = %02X\n", machine().describe_context(), data & 0x24);
13241313   m_sound_port_bank = data & 0x24;
1325   (*m_update_master_bank)(machine());
1314   (this->*m_update_master_bank)();
13261315}
13271316
13281317
r20832r20833
14081397 *************************************/
14091398
14101399/* also called by Ataxx */
1411void leland_rotate_memory(running_machine &machine, const char *cpuname)
1400void leland_state::leland_rotate_memory(const char *cpuname)
14121401{
14131402   int startaddr = 0x10000;
1414   int banks = (machine.root_device().memregion(cpuname)->bytes() - startaddr) / 0x8000;
1415   UINT8 *ram = machine.root_device().memregion(cpuname)->base();
1403   int banks = (machine().root_device().memregion(cpuname)->bytes() - startaddr) / 0x8000;
1404   UINT8 *ram = machine().root_device().memregion(cpuname)->base();
14161405   UINT8 temp[0x2000];
14171406   int i;
14181407
trunk/src/mame/includes/lazercmd.h
r20832r20833
5959   UINT32 screen_update_lazercmd(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6060   TIMER_DEVICE_CALLBACK_MEMBER(lazercmd_timer);
6161   TIMER_DEVICE_CALLBACK_MEMBER(bbonk_timer);
62   int vert_scale(int data);
63   void plot_pattern( bitmap_ind16 &bitmap, int x, int y );
6264};
trunk/src/mame/includes/lemmings.h
r20832r20833
5151   virtual void video_start();
5252   UINT32 screen_update_lemmings(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5353   void screen_eof_lemmings(screen_device &screen, bool state);
54   void lemmings_copy_bitmap(bitmap_rgb32& bitmap, bitmap_ind16& srcbitmap, int* xscroll, int* yscroll, const rectangle& cliprect);
5455};
trunk/src/mame/includes/lastduel.h
r20832r20833
6262   UINT32 screen_update_madgear(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6363   TIMER_DEVICE_CALLBACK_MEMBER(lastduel_timer_cb);
6464   TIMER_DEVICE_CALLBACK_MEMBER(madgear_timer_cb);
65   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri );
6566};
trunk/src/mame/includes/lethalj.h
r20832r20833
3030   DECLARE_DRIVER_INIT(cclownz);
3131   virtual void video_start();
3232   TIMER_CALLBACK_MEMBER(gen_ext1_int);
33   inline void get_crosshair_xy(int player, int *x, int *y);
3334};
3435
3536/*----------- defined in video/lethalj.c -----------*/
trunk/src/mame/includes/lwings.h
r20832r20833
6262   UINT32 screen_update_trojan(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6363   INTERRUPT_GEN_MEMBER(lwings_interrupt);
6464   INTERRUPT_GEN_MEMBER(avengers_interrupt);
65   inline int is_sprite_on( UINT8 *buffered_spriteram, int offs );
66   void lwings_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
67   void trojan_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
68   int avengers_fetch_paldata(  );
6569};
trunk/src/mame/includes/lordgun.h
r20832r20833
6868   TILE_GET_INFO_MEMBER(get_tile_info_3);
6969   virtual void video_start();
7070   UINT32 screen_update_lordgun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
71   inline void get_tile_info(tile_data &tileinfo, tilemap_memory_index tile_index, int _N_);
72   inline void lordgun_vram_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _N_);
73   void lorddgun_calc_gun_scr(int i);
74   void lordgun_update_gun(int i);
75   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
7176};
7277
7378/*----------- defined in video/lordgun.c -----------*/
7479float lordgun_crosshair_mapper(const ioport_field *field, float linear_value);
75void lordgun_update_gun(running_machine &machine, int i);
trunk/src/mame/includes/liberate.h
r20832r20833
6969   UINT32 screen_update_prosoccr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7070   INTERRUPT_GEN_MEMBER(deco16_interrupt);
7171   INTERRUPT_GEN_MEMBER(prosport_interrupt);
72   void debug_print(bitmap_ind16 &bitmap);
73   void liberate_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
74   void prosport_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
75   void boomrang_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri );
76   void prosoccr_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
7277};
trunk/src/mame/includes/lkage.h
r20832r20833
8484   virtual void video_start();
8585   UINT32 screen_update_lkage(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8686   TIMER_CALLBACK_MEMBER(nmi_callback);
87   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
8788};
trunk/src/mame/includes/leland.h
r20832r20833
5050   UINT8 m_sound_port_bank;
5151   UINT8 m_alternate_bank;
5252   UINT8 m_master_bank;
53   void (*m_update_master_bank)(running_machine &machine);
53   void (leland_state::*m_update_master_bank)();
5454   UINT32 m_xrom1_addr;
5555   UINT32 m_xrom2_addr;
5656   UINT8 m_battery_ram_enable;
r20832r20833
152152   DECLARE_READ8_MEMBER(leland_sound_port_r);
153153   DECLARE_WRITE8_MEMBER(leland_sound_port_w);
154154   DECLARE_WRITE8_MEMBER(leland_gfx_port_w);
155   void leland_video_addr_w(address_space &space, int offset, int data, int num);
156   int leland_vram_port_r(address_space &space, int offset, int num);
157   void leland_vram_port_w(address_space &space, int offset, int data, int num);
158   int dial_compute_value(int new_val, int indx);
159   void update_dangerz_xy();
160   void cerberus_bankswitch();
161   void mayhem_bankswitch();
162   void dangerz_bankswitch();
163   void basebal2_bankswitch();
164   void redline_bankswitch();
165   void viper_bankswitch();
166   void offroad_bankswitch();
167   void ataxx_bankswitch();
168   void leland_init_eeprom(UINT8 default_val, const UINT16 *data, UINT8 serial_offset, UINT8 serial_type);
169   void ataxx_init_eeprom(const UINT16 *data);
170   int keycard_r();
171   void keycard_w(int data);
172   void leland_rotate_memory(const char *cpuname);
173   void init_master_ports(UINT8 mvram_base, UINT8 io_base);
155174};
156175
157176
r20832r20833
163182#define SERIAL_TYPE_ENCRYPT     3
164183#define SERIAL_TYPE_ENCRYPT_XOR 4
165184
166void cerberus_bankswitch(running_machine &machine);
167void mayhem_bankswitch(running_machine &machine);
168void dangerz_bankswitch(running_machine &machine);
169void basebal2_bankswitch(running_machine &machine);
170void redline_bankswitch(running_machine &machine);
171void viper_bankswitch(running_machine &machine);
172void offroad_bankswitch(running_machine &machine);
173void ataxx_bankswitch(running_machine &machine);
174
175185void leland_init_eeprom(running_machine &machine, UINT8 default_val, const UINT16 *data, UINT8 serial_offset, UINT8 serial_type);
176186void ataxx_init_eeprom(running_machine &machine, const UINT16 *data);
177187
trunk/src/mame/includes/ladyfrog.h
r20832r20833
6060   DECLARE_VIDEO_START(ladyfrog_common);
6161   UINT32 screen_update_ladyfrog(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6262   TIMER_CALLBACK_MEMBER(nmi_callback);
63   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6364};
trunk/src/mame/includes/legionna.h
r20832r20833
5252   UINT32 screen_update_legionna(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5353   UINT32 screen_update_godzilla(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   UINT32 screen_update_grainbow(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
55   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
56   void descramble_legionnaire_gfx(UINT8* src);
5557};
5658
5759/*----------- defined in video/legionna.c -----------*/
trunk/src/mame/includes/lsasquad.h
r20832r20833
6262   UINT32 screen_update_lsasquad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6363   UINT32 screen_update_daikaiju(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6464   TIMER_CALLBACK_MEMBER(nmi_callback);
65   void draw_layer( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *scrollram );
66   int draw_layer_daikaiju( bitmap_ind16 &bitmap, const rectangle &cliprect, int offs, int  * previd, int type );
67   void drawbg( bitmap_ind16 &bitmap, const rectangle &cliprect, int type );
68   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6569};
trunk/src/mame/includes/ladybug.h
r20832r20833
8181   UINT32 screen_update_redclash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8282   void screen_eof_sraider(screen_device &screen, bool state);
8383   void screen_eof_redclash(screen_device &screen, bool state);
84   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
8485};
8586
8687/*----------- defined in video/redclash.c -----------*/
trunk/src/mame/includes/labyrunr.h
r20832r20833
4444   UINT32 screen_update_labyrunr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4545   INTERRUPT_GEN_MEMBER(labyrunr_vblank_interrupt);
4646   INTERRUPT_GEN_MEMBER(labyrunr_timer_interrupt);
47   void set_pens(  );
4748};
trunk/src/mame/includes/lasso.h
r20832r20833
6868   UINT32 screen_update_lasso(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6969   UINT32 screen_update_chameleo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7070   UINT32 screen_update_wwjgtin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
71   rgb_t get_color( int data );
72   void wwjgtin_set_last_four_colors( colortable_t *colortable );
73   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int reverse );
74   void draw_lasso( bitmap_ind16 &bitmap, const rectangle &cliprect );
7175};
trunk/src/mame/includes/lockon.h
r20832r20833
109109   void screen_eof_lockon(screen_device &screen, bool state);
110110   TIMER_CALLBACK_MEMBER(cursor_callback);
111111   TIMER_CALLBACK_MEMBER(bufend_callback);
112   void scene_draw(  );
113   void ground_draw(  );
114   void objects_draw(  );
115   void rotate_draw( bitmap_ind16 &bitmap, const rectangle &cliprect );
116   void hud_draw( bitmap_ind16 &bitmap, const rectangle &cliprect );
112117};
trunk/src/mame/video/lethalj.c
r20832r20833
2020 *
2121 *************************************/
2222
23INLINE void get_crosshair_xy(running_machine &machine, int player, int *x, int *y)
23inline void lethalj_state::get_crosshair_xy(int player, int *x, int *y)
2424{
2525   static const char *const gunnames[] = { "LIGHT0_X", "LIGHT0_Y", "LIGHT1_X", "LIGHT1_Y" };
26   const rectangle &visarea = machine.primary_screen->visible_area();
26   const rectangle &visarea = machine().primary_screen->visible_area();
2727   int width = visarea.width();
2828   int height = visarea.height();
2929
30   *x = ((machine.root_device().ioport(gunnames[player * 2])->read_safe(0x00) & 0xff) * width) / 255;
31   *y = ((machine.root_device().ioport(gunnames[1 + player * 2])->read_safe(0x00) & 0xff) * height) / 255;
30   *x = ((machine().root_device().ioport(gunnames[player * 2])->read_safe(0x00) & 0xff) * width) / 255;
31   *y = ((machine().root_device().ioport(gunnames[1 + player * 2])->read_safe(0x00) & 0xff) * height) / 255;
3232}
3333
3434
r20832r20833
4949      case 4:
5050      case 5:
5151         /* latch the crosshair position */
52         get_crosshair_xy(machine(), offset - 4, &beamx, &beamy);
52         get_crosshair_xy(offset - 4, &beamx, &beamy);
5353         m_gunx = beamx;
5454         m_guny = beamy;
5555         m_blank_palette = 1;
trunk/src/mame/video/liberate.c
r20832r20833
1515#include "includes/liberate.h"
1616
1717#if 0
18void debug_print(bitmap_ind16 &bitmap)
18void liberate_state::debug_print(bitmap_ind16 &bitmap)
1919{
2020   int i, j;
2121   char buf[20 * 16];
r20832r20833
278278
279279/***************************************************************************/
280280
281static void liberate_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
281void liberate_state::liberate_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
282282{
283   liberate_state *state = machine.driver_data<liberate_state>();
284   UINT8 *spriteram = state->m_spriteram;
283   UINT8 *spriteram = m_spriteram;
285284   int offs;
286285
287286   /* Sprites */
r20832r20833
314313      if (multi && fy == 0)
315314         sy -= 16;
316315
317      if (state->flip_screen())
316      if (flip_screen())
318317      {
319318         sy = 240 - sy;
320319         sx = 240 - sx;
r20832r20833
333332            sy2 = sy + 16;
334333      }
335334
336      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
335      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
337336               code,
338337               color,
339338               fx,fy,
340339               sx,sy,0);
341340      if (multi)
342         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
341         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
343342               code+1,
344343               color,
345344               fx,fy,
r20832r20833
347346   }
348347}
349348
350static void prosport_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
349void liberate_state::prosport_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
351350{
352   liberate_state *state = machine.driver_data<liberate_state>();
353351   int offs, multi, fx, fy, sx, sy, sy2, code, code2, color, gfx_region;
354   UINT8 *spriteram = state->m_spriteram;
352   UINT8 *spriteram = m_spriteram;
355353
356354   for (offs = 0x000; offs < 0x800; offs += 4)
357355   {
r20832r20833
361359      code = spriteram[offs + 1] + ((spriteram[offs + 0] & 0x3) << 8);
362360      code2 = code + 1;
363361
364      if(state->m_io_ram[0] & 0x40) //dynamic ram-based gfxs for Pro Golf
362      if(m_io_ram[0] & 0x40) //dynamic ram-based gfxs for Pro Golf
365363         gfx_region = 3 + 4;
366364      else
367         gfx_region = ((state->m_io_ram[0] & 0x30) >> 4) + 4;
365         gfx_region = ((m_io_ram[0] & 0x30) >> 4) + 4;
368366
369367
370368      multi = spriteram[offs + 0] & 0x10;
r20832r20833
376374//      sy = (240 - spriteram[offs + 2]);//-16;
377375      sy = 240 - sy;
378376
379      color = 1;//(state->m_io_ram[4] & 2) + 1;//(spriteram[offs + 0] & 0x4) >> 2;
377      color = 1;//(m_io_ram[4] & 2) + 1;//(spriteram[offs + 0] & 0x4) >> 2;
380378
381379      fy = spriteram[offs + 0] & 0x02;
382380      fx = spriteram[offs + 0] & 0x04;
r20832r20833
385383//      if (multi) sy -= 16;
386384      if ((fy && multi) || (fx && multi)) { code2 = code; code++; }
387385
388      if (state->flip_screen())
386      if (flip_screen())
389387      {
390388         sy = 240 - sy;
391389         sx = 240 - sx;
r20832r20833
398396         sy2 = sy + 16;
399397      }
400398
401      drawgfx_transpen(bitmap,cliprect,machine.gfx[gfx_region],
399      drawgfx_transpen(bitmap,cliprect,machine().gfx[gfx_region],
402400            code,
403401            color,
404402            fx,fy,
405403            sx,sy,0);
406404      if (multi)
407         drawgfx_transpen(bitmap,cliprect,machine.gfx[gfx_region],
405         drawgfx_transpen(bitmap,cliprect,machine().gfx[gfx_region],
408406            code2,
409407            color,
410408            fx,fy,
r20832r20833
412410   }
413411}
414412
415static void boomrang_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
413void liberate_state::boomrang_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
416414{
417   liberate_state *state = machine.driver_data<liberate_state>();
418   UINT8 *spriteram = state->m_spriteram;
415   UINT8 *spriteram = m_spriteram;
419416   int offs, multi, fx, fy, sx, sy, sy2, code, code2, color;
420417
421418   for (offs = 0x000; offs < 0x800; offs += 4)
r20832r20833
446443//      if (multi) sy -= 16;
447444      if (fy && multi) { code2 = code; code++; }
448445
449      if (state->flip_screen())
446      if (flip_screen())
450447      {
451448         sy = 240 - sy;
452449         sx = 240 - sx;
r20832r20833
459456         sy2 = sy + 16;
460457      }
461458
462      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
459      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
463460            code,
464461            color,
465462            fx,fy,
466463            sx,sy,0);
467464      if (multi)
468         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
465         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
469466            code2,
470467            color,
471468            fx,fy,
r20832r20833
473470   }
474471}
475472
476static void prosoccr_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
473void liberate_state::prosoccr_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
477474{
478   liberate_state *state = machine.driver_data<liberate_state>();
479   UINT8 *spriteram = state->m_spriteram;
475   UINT8 *spriteram = m_spriteram;
480476   int offs, code, fx, fy, sx, sy;
481477
482478   for (offs = 0x000; offs < 0x400; offs += 4)
r20832r20833
490486      fx = spriteram[offs + 0] & 4;
491487      fy = spriteram[offs + 0] & 2;
492488
493      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
489      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
494490            code,
495491            0,
496492            fx,fy,
r20832r20833
511507      m_back_tilemap->draw(bitmap, cliprect, 0, 0);
512508
513509   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
514   prosoccr_draw_sprites(machine(), bitmap, cliprect);
510   prosoccr_draw_sprites(bitmap, cliprect);
515511
516512   return 0;
517513}
r20832r20833
554550            tile, 1, 0, 0, 248 - 8 * mx, 8 * my, 0);
555551   }
556552
557   prosport_draw_sprites(machine(), bitmap, cliprect);
553   prosport_draw_sprites(bitmap, cliprect);
558554
559555   return 0;
560556}
r20832r20833
569565   else
570566      m_back_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
571567
572   boomrang_draw_sprites(machine(),bitmap,cliprect,8);
568   boomrang_draw_sprites(bitmap,cliprect,8);
573569   if (!m_background_disable)
574570      m_back_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
575571
576   boomrang_draw_sprites(machine(), bitmap, cliprect, 0);
572   boomrang_draw_sprites(bitmap, cliprect, 0);
577573   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
578574   return 0;
579575}
r20832r20833
588584   else
589585      m_back_tilemap->draw(bitmap, cliprect, 0, 0);
590586
591   liberate_draw_sprites(machine(), bitmap, cliprect);
587   liberate_draw_sprites(bitmap, cliprect);
592588   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
593589   return 0;
594590}
trunk/src/mame/video/lordgun.c
r20832r20833
6161***************************************************************************/
6262
6363
64INLINE void get_tile_info(running_machine &machine, tile_data &tileinfo, tilemap_memory_index tile_index, int _N_)
64inline void lordgun_state::get_tile_info(tile_data &tileinfo, tilemap_memory_index tile_index, int _N_)
6565{
66   lordgun_state *state = machine.driver_data<lordgun_state>();
67   UINT16 attr = state->m_vram[_N_][tile_index * 2 + 0 ];
68   UINT16 code = state->m_vram[_N_][ tile_index * 2 + 1 ];
66   UINT16 attr = m_vram[_N_][tile_index * 2 + 0 ];
67   UINT16 code = m_vram[_N_][ tile_index * 2 + 1 ];
6968   UINT16 pri  = (attr & 0x0e00) >> 9;
70   SET_TILE_INFO( _N_, code, ((attr & 0x0030) >> 4) + 0x10 + 0x4 * ((_N_ + 1) & 3) + pri*0x800/0x40, TILE_FLIPXY(attr >> 14));
69   SET_TILE_INFO_MEMBER( _N_, code, ((attr & 0x0030) >> 4) + 0x10 + 0x4 * ((_N_ + 1) & 3) + pri*0x800/0x40, TILE_FLIPXY(attr >> 14));
7170}
7271
73TILE_GET_INFO_MEMBER(lordgun_state::get_tile_info_0){ get_tile_info(machine(), tileinfo, tile_index, 0); }
74TILE_GET_INFO_MEMBER(lordgun_state::get_tile_info_1){ get_tile_info(machine(), tileinfo, tile_index, 1); }
75TILE_GET_INFO_MEMBER(lordgun_state::get_tile_info_2){ get_tile_info(machine(), tileinfo, tile_index, 2); }
76TILE_GET_INFO_MEMBER(lordgun_state::get_tile_info_3){ get_tile_info(machine(), tileinfo, tile_index, 3); }
72TILE_GET_INFO_MEMBER(lordgun_state::get_tile_info_0){ get_tile_info(tileinfo, tile_index, 0); }
73TILE_GET_INFO_MEMBER(lordgun_state::get_tile_info_1){ get_tile_info(tileinfo, tile_index, 1); }
74TILE_GET_INFO_MEMBER(lordgun_state::get_tile_info_2){ get_tile_info(tileinfo, tile_index, 2); }
75TILE_GET_INFO_MEMBER(lordgun_state::get_tile_info_3){ get_tile_info(tileinfo, tile_index, 3); }
7776
78INLINE void lordgun_vram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int _N_)
77inline void lordgun_state::lordgun_vram_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _N_)
7978{
80   lordgun_state *state = space.machine().driver_data<lordgun_state>();
81   COMBINE_DATA(&state->m_vram[_N_][offset]);
82   state->m_tilemap[_N_]->mark_tile_dirty(offset/2);
79   COMBINE_DATA(&m_vram[_N_][offset]);
80   m_tilemap[_N_]->mark_tile_dirty(offset/2);
8381}
8482
85WRITE16_MEMBER(lordgun_state::lordgun_vram_0_w){ lordgun_vram_w(space, offset, data, mem_mask, 0); }
86WRITE16_MEMBER(lordgun_state::lordgun_vram_1_w){ lordgun_vram_w(space, offset, data, mem_mask, 1); }
87WRITE16_MEMBER(lordgun_state::lordgun_vram_2_w){ lordgun_vram_w(space, offset, data, mem_mask, 2); }
88WRITE16_MEMBER(lordgun_state::lordgun_vram_3_w){ lordgun_vram_w(space, offset, data, mem_mask, 3); }
83WRITE16_MEMBER(lordgun_state::lordgun_vram_0_w){ lordgun_vram_w(offset, data, mem_mask, 0); }
84WRITE16_MEMBER(lordgun_state::lordgun_vram_1_w){ lordgun_vram_w(offset, data, mem_mask, 1); }
85WRITE16_MEMBER(lordgun_state::lordgun_vram_2_w){ lordgun_vram_w(offset, data, mem_mask, 2); }
86WRITE16_MEMBER(lordgun_state::lordgun_vram_3_w){ lordgun_vram_w(offset, data, mem_mask, 3); }
8987
9088/***************************************************************************
9189
r20832r20833
182180   return lordgun_gun_x_table[x] * 1.0f / 0x1BF;
183181}
184182
185static void lorddgun_calc_gun_scr(running_machine &machine, int i)
183void lordgun_state::lorddgun_calc_gun_scr(int i)
186184{
187   lordgun_state *state = machine.driver_data<lordgun_state>();
188//  popmessage("%03x, %02x", machine, "LIGHT0_X"), state->ioport("LIGHT0_Y")->read());
185//  popmessage("%03x, %02x", machine, "LIGHT0_X"), ioport("LIGHT0_Y")->read());
189186
190   int x = state->ioport(gunnames[i])->read() - 0x3c;
187   int x = ioport(gunnames[i])->read() - 0x3c;
191188
192189   if ( (x < 0) || (x > sizeof(lordgun_gun_x_table)/sizeof(lordgun_gun_x_table[0])) )
193190      x = 0;
194191
195   state->m_gun[i].scr_x = lordgun_gun_x_table[x];
196   state->m_gun[i].scr_y = state->ioport(gunnames[i+2])->read();
192   m_gun[i].scr_x = lordgun_gun_x_table[x];
193   m_gun[i].scr_y = ioport(gunnames[i+2])->read();
197194}
198195
199void lordgun_update_gun(running_machine &machine, int i)
196void lordgun_state::lordgun_update_gun(int i)
200197{
201   lordgun_state *state = machine.driver_data<lordgun_state>();
202   const rectangle &visarea = machine.primary_screen->visible_area();
198   const rectangle &visarea = machine().primary_screen->visible_area();
203199
204   state->m_gun[i].hw_x = state->ioport(gunnames[i])->read();
205   state->m_gun[i].hw_y = state->ioport(gunnames[i+2])->read();
200   m_gun[i].hw_x = ioport(gunnames[i])->read();
201   m_gun[i].hw_y = ioport(gunnames[i+2])->read();
206202
207   lorddgun_calc_gun_scr(machine, i);
203   lorddgun_calc_gun_scr(i);
208204
209   if (!visarea.contains(state->m_gun[i].scr_x, state->m_gun[i].scr_y))
210      state->m_gun[i].hw_x = state->m_gun[i].hw_y = 0;
205   if (!visarea.contains(m_gun[i].scr_x, m_gun[i].scr_y))
206      m_gun[i].hw_x = m_gun[i].hw_y = 0;
211207}
212208
213209
r20832r20833
235231
236232***************************************************************************/
237233
238static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
234void lordgun_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
239235{
240   lordgun_state *state = machine.driver_data<lordgun_state>();
241   UINT16 *s       =   state->m_spriteram;
242   UINT16 *end     =   state->m_spriteram + state->m_spriteram.bytes()/2;
236   UINT16 *s       =   m_spriteram;
237   UINT16 *end     =   m_spriteram + m_spriteram.bytes()/2;
243238
244239   for ( ; s < end; s += 8/2 )
245240   {
r20832r20833
278273      {
279274         for (x = x0; x != x1; x += dx)
280275         {
281            drawgfx_transpen(   bitmap, cliprect, machine.gfx[4],
276            drawgfx_transpen(   bitmap, cliprect, machine().gfx[4],
282277                           code, color + pri * 0x800/0x40,
283278                           flipx, flipy,
284279                           sx + x * 0x10, sy + y * 0x10,
r20832r20833
373368   if (layers_ctrl & 2)    m_tilemap[1]->draw(*m_bitmaps[1], cliprect, 0, 0);
374369   if (layers_ctrl & 4)    m_tilemap[2]->draw(*m_bitmaps[2], cliprect, 0, 0);
375370   if (layers_ctrl & 8)    m_tilemap[3]->draw(*m_bitmaps[3], cliprect, 0, 0);
376   if (layers_ctrl & 16)   draw_sprites(machine(), *m_bitmaps[4], cliprect);
371   if (layers_ctrl & 16)   draw_sprites(*m_bitmaps[4], cliprect);
377372
378373   // copy to screen bitmap
379374
trunk/src/mame/video/ladyfrog.c
r20832r20833
8989   m_bg_tilemap->set_scrolly(offset, data);
9090}
9191
92static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
92void ladyfrog_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
9393{
94   ladyfrog_state *state = machine.driver_data<ladyfrog_state>();
9594   int i;
9695   for (i = 0; i < 0x20; i++)
9796   {
98      int pr = state->m_spriteram[0x9f - i];
97      int pr = m_spriteram[0x9f - i];
9998      int offs = (pr & 0x1f) * 4;
10099      {
101100         int code, sx, sy, flipx, flipy, pal;
102         code = state->m_spriteram[offs + 2] + ((state->m_spriteram[offs + 1] & 0x10) << 4) + state->m_spritetilebase;
103         pal = state->m_spriteram[offs + 1] & 0x0f;
104         sx = state->m_spriteram[offs + 3];
105         sy = 238 - state->m_spriteram[offs + 0];
106         flipx = ((state->m_spriteram[offs + 1] & 0x40)>>6);
107         flipy = ((state->m_spriteram[offs + 1] & 0x80)>>7);
108         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
101         code = m_spriteram[offs + 2] + ((m_spriteram[offs + 1] & 0x10) << 4) + m_spritetilebase;
102         pal = m_spriteram[offs + 1] & 0x0f;
103         sx = m_spriteram[offs + 3];
104         sy = 238 - m_spriteram[offs + 0];
105         flipx = ((m_spriteram[offs + 1] & 0x40)>>6);
106         flipy = ((m_spriteram[offs + 1] & 0x80)>>7);
107         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
109108               code,
110109               pal,
111110               flipx,flipy,
112111               sx,sy,15);
113112
114         if (state->m_spriteram[offs + 3] > 240)
113         if (m_spriteram[offs + 3] > 240)
115114         {
116            sx = (state->m_spriteram[offs + 3] - 256);
117            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
115            sx = (m_spriteram[offs + 3] - 256);
116            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
118117                  code,
119118                  pal,
120119                  flipx,flipy,
r20832r20833
154153UINT32 ladyfrog_state::screen_update_ladyfrog(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
155154{
156155   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
157   draw_sprites(machine(), bitmap, cliprect);
156   draw_sprites(bitmap, cliprect);
158157   return 0;
159158}
trunk/src/mame/video/lwings.c
r20832r20833
157157
158158***************************************************************************/
159159
160INLINE int is_sprite_on( UINT8 *buffered_spriteram, int offs )
160inline int lwings_state::is_sprite_on( UINT8 *buffered_spriteram, int offs )
161161{
162162   int sx, sy;
163163
r20832r20833
167167   return sx || sy;
168168}
169169
170static void lwings_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
170void lwings_state::lwings_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
171171{
172   lwings_state *state = machine.driver_data<lwings_state>();
173   UINT8 *buffered_spriteram = state->m_spriteram->buffer();
172   UINT8 *buffered_spriteram = m_spriteram->buffer();
174173   int offs;
175174
176   for (offs = state->m_spriteram->bytes() - 4; offs >= 0; offs -= 4)
175   for (offs = m_spriteram->bytes() - 4; offs >= 0; offs -= 4)
177176   {
178177      if (is_sprite_on(buffered_spriteram, offs))
179178      {
r20832r20833
188187         flipx = buffered_spriteram[offs + 1] & 0x02;
189188         flipy = buffered_spriteram[offs + 1] & 0x04;
190189
191         if (state->flip_screen())
190         if (flip_screen())
192191         {
193192            sx = 240 - sx;
194193            sy = 240 - sy;
r20832r20833
196195            flipy = !flipy;
197196         }
198197
199         drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
198         drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
200199               code,color,
201200               flipx,flipy,
202201               sx,sy,15);
r20832r20833
204203   }
205204}
206205
207static void trojan_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
206void lwings_state::trojan_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
208207{
209   lwings_state *state = machine.driver_data<lwings_state>();
210   UINT8 *buffered_spriteram = state->m_spriteram->buffer();
208   UINT8 *buffered_spriteram = m_spriteram->buffer();
211209   int offs;
212210
213   for (offs = state->m_spriteram->bytes() - 4; offs >= 0; offs -= 4)
211   for (offs = m_spriteram->bytes() - 4; offs >= 0; offs -= 4)
214212   {
215213      if (is_sprite_on(buffered_spriteram, offs))
216214      {
r20832r20833
226224               ((buffered_spriteram[offs + 1] & 0x80) << 3);
227225         color = (buffered_spriteram[offs + 1] & 0x0e) >> 1;
228226
229         if (state->m_bg2_avenger_hw)
227         if (m_bg2_avenger_hw)
230228         {
231229            flipx = 0;                                      /* Avengers */
232230            flipy = ~buffered_spriteram[offs + 1] & 0x10;
r20832r20833
237235            flipy = 1;
238236         }
239237
240         if (state->flip_screen())
238         if (flip_screen())
241239         {
242240            sx = 240 - sx;
243241            sy = 240 - sy;
r20832r20833
245243            flipy = !flipy;
246244         }
247245
248         drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
246         drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
249247               code,color,
250248               flipx,flipy,
251249               sx,sy,15);
r20832r20833
256254UINT32 lwings_state::screen_update_lwings(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
257255{
258256   m_bg1_tilemap->draw(bitmap, cliprect, 0, 0);
259   lwings_draw_sprites(machine(), bitmap, cliprect);
257   lwings_draw_sprites(bitmap, cliprect);
260258   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
261259   return 0;
262260}
r20832r20833
265263{
266264   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
267265   m_bg1_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
268   trojan_draw_sprites(machine(), bitmap, cliprect);
266   trojan_draw_sprites(bitmap, cliprect);
269267   m_bg1_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
270268   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
271269   return 0;
trunk/src/mame/video/legionna.c
r20832r20833
245245
246246*************************************************************************/
247247
248static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
248void legionna_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
249249{
250   legionna_state *state = machine.driver_data<legionna_state>();
251   UINT16 *spriteram16 = state->m_spriteram;
250   UINT16 *spriteram16 = m_spriteram;
252251   int offs,fx,fy,x,y,color,sprite,cur_pri;
253252   int dx,dy,ax,ay;
254253   int pri_mask;
r20832r20833
260259
261260      pri_mask = 0;
262261
263      if (state->m_has_extended_priority)
262      if (m_has_extended_priority)
264263      {
265264         cur_pri = (spriteram16[offs+1] & 0xc000) >> 14;
266265
r20832r20833
310309
311310      sprite &= 0x3fff;
312311
313      if (state->m_has_extended_banking)
312      if (m_has_extended_banking)
314313      {
315314         if(data & 0x0040)
316315         {
r20832r20833
360359            for (ax=0; ax<dx; ax++)
361360               for (ay=0; ay<dy; ay++)
362361               {
363                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3],
362                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[3],
364363                  sprite++,
365                  color,fx,fy,(x+ax*16)+state->m_sprite_xoffs,y+ay*16+state->m_sprite_yoffs,
366                  machine.priority_bitmap,pri_mask, 15);
364                  color,fx,fy,(x+ax*16)+m_sprite_xoffs,y+ay*16+m_sprite_yoffs,
365                  machine().priority_bitmap,pri_mask, 15);
367366               }
368367         }
369368         else
r20832r20833
371370            for (ax=0; ax<dx; ax++)
372371               for (ay=0; ay<dy; ay++)
373372               {
374                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3],
373                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[3],
375374                  sprite++,
376                  color,fx,fy,(x+ax*16)+state->m_sprite_xoffs,y+(dy-ay-1)*16+state->m_sprite_yoffs,
377                  machine.priority_bitmap,pri_mask,15);
375                  color,fx,fy,(x+ax*16)+m_sprite_xoffs,y+(dy-ay-1)*16+m_sprite_yoffs,
376                  machine().priority_bitmap,pri_mask,15);
378377               }
379378         }
380379      }
r20832r20833
385384            for (ax=0; ax<dx; ax++)
386385               for (ay=0; ay<dy; ay++)
387386               {
388                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3],
387                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[3],
389388                  sprite++,
390                  color,fx,fy,(x+(dx-ax-1)*16)+state->m_sprite_xoffs,y+ay*16+state->m_sprite_yoffs,
391                  machine.priority_bitmap,pri_mask,15);
389                  color,fx,fy,(x+(dx-ax-1)*16)+m_sprite_xoffs,y+ay*16+m_sprite_yoffs,
390                  machine().priority_bitmap,pri_mask,15);
392391               }
393392         }
394393         else
r20832r20833
396395            for (ax=0; ax<dx; ax++)
397396               for (ay=0; ay<dy; ay++)
398397               {
399                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3],
398                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[3],
400399                  sprite++,
401                  color,fx,fy,(x+(dx-ax-1)*16)+state->m_sprite_xoffs,y+(dy-ay-1)*16+state->m_sprite_yoffs,
402                  machine.priority_bitmap,pri_mask, 15);
400                  color,fx,fy,(x+(dx-ax-1)*16)+m_sprite_xoffs,y+(dy-ay-1)*16+m_sprite_yoffs,
401                  machine().priority_bitmap,pri_mask, 15);
403402               }
404403         }
405404      }
r20832r20833
430429   if (!(m_layer_disable&0x0002)) m_background_layer->draw(bitmap, cliprect, 0, 1);
431430   if (!(m_layer_disable&0x0001)) m_text_layer->draw(bitmap, cliprect, 0, 2);
432431
433   draw_sprites(machine(),bitmap,cliprect);
432   draw_sprites(bitmap,cliprect);
434433
435434
436435   return 0;
r20832r20833
460459   if (!(m_layer_disable&0x0004)) m_foreground_layer->draw(bitmap, cliprect, 0,1);
461460   if (!(m_layer_disable&0x0008)) m_text_layer->draw(bitmap, cliprect, 0,2);
462461
463   draw_sprites(machine(),bitmap,cliprect);
462   draw_sprites(bitmap,cliprect);
464463
465464   return 0;
466465}
r20832r20833
492491   if(!(m_layer_disable & 8))
493492      m_text_layer->draw(bitmap, cliprect, 0,8);
494493
495   draw_sprites(machine(),bitmap,cliprect);
494   draw_sprites(bitmap,cliprect);
496495
497496   return 0;
498497}
trunk/src/mame/video/leland.c
r20832r20833
129129 *
130130 *************************************/
131131
132static void leland_video_addr_w(address_space &space, int offset, int data, int num)
132void leland_state::leland_video_addr_w(address_space &space, int offset, int data, int num)
133133{
134   leland_state *drvstate = space.machine().driver_data<leland_state>();
135   struct vram_state_data *state = drvstate->m_vram_state + num;
134   struct vram_state_data *state = m_vram_state + num;
136135
137136   if (!offset)
138137      state->m_addr = (state->m_addr & 0xfe00) | ((data << 1) & 0x01fe);
r20832r20833
148147 *
149148 *************************************/
150149
151static int leland_vram_port_r(address_space &space, int offset, int num)
150int leland_state::leland_vram_port_r(address_space &space, int offset, int num)
152151{
153   leland_state *drvstate = space.machine().driver_data<leland_state>();
154   struct vram_state_data *state = drvstate->m_vram_state + num;
152   struct vram_state_data *state = m_vram_state + num;
155153   int addr = state->m_addr;
156154   int inc = (offset >> 2) & 2;
157155   int ret;
r20832r20833
159157   switch (offset & 7)
160158   {
161159      case 3: /* read hi/lo (alternating) */
162         ret = drvstate->m_video_ram[addr];
160         ret = m_video_ram[addr];
163161         addr += inc & (addr << 1);
164162         addr ^= 1;
165163         break;
166164
167165      case 5: /* read hi */
168         ret = drvstate->m_video_ram[addr | 1];
166         ret = m_video_ram[addr | 1];
169167         addr += inc;
170168         break;
171169
172170      case 6: /* read lo */
173         ret = drvstate->m_video_ram[addr & ~1];
171         ret = m_video_ram[addr & ~1];
174172         addr += inc;
175173         break;
176174
r20832r20833
196194 *
197195 *************************************/
198196
199static void leland_vram_port_w(address_space &space, int offset, int data, int num)
197void leland_state::leland_vram_port_w(address_space &space, int offset, int data, int num)
200198{
201   leland_state *drvstate = space.machine().driver_data<leland_state>();
202   UINT8 *video_ram = drvstate->m_video_ram;
203   struct vram_state_data *state = drvstate->m_vram_state + num;
199   UINT8 *video_ram = m_video_ram;
200   struct vram_state_data *state = m_vram_state + num;
204201   int addr = state->m_addr;
205202   int inc = (offset >> 2) & 2;
206203   int trans = (offset >> 4) & num;
trunk/src/mame/video/lkage.c
r20832r20833
9797}
9898
9999
100static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
100void lkage_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
101101{
102   lkage_state *state = machine.driver_data<lkage_state>();
103   const UINT8 *source = state->m_spriteram;
102   const UINT8 *source = m_spriteram;
104103   const UINT8 *finish = source + 0x60;
105104
106105   while (source < finish)
r20832r20833
118117      int flipx = attributes & 0x01;
119118      int flipy = attributes & 0x02;
120119      int height = (attributes & 0x08) ? 2 : 1;
121      int sx = source[0] - 15 + state->m_sprite_dx;
120      int sx = source[0] - 15 + m_sprite_dx;
122121      int sy = 256 - 16 * height - source[1];
123122      int sprite_number = source[3] + ((attributes & 0x04) << 6);
124123      int y;
r20832r20833
132131         priority_mask = 0xf0;
133132      }
134133
135      if (state->flip_screen_x())
134      if (flip_screen_x())
136135      {
137136         sx = 239 - sx - 24;
138137         flipx = !flipx;
139138      }
140      if (state->flip_screen_y())
139      if (flip_screen_y())
141140      {
142141         sy = 254 - 16 * height - sy;
143142         flipy = !flipy;
r20832r20833
152151         pdrawgfx_transpen(
153152            bitmap,
154153            cliprect,
155            machine.gfx[1],
154            machine().gfx[1],
156155            sprite_number ^ y,
157156            color,
158157            flipx,flipy,
159158            sx&0xff,
160159            sy + 16*y,
161            machine.priority_bitmap,
160            machine().priority_bitmap,
162161            priority_mask,0 );
163162      }
164163      source += 4;
r20832r20833
213212      m_bg_tilemap->draw(bitmap, cliprect, 0, 1);
214213      m_fg_tilemap->draw(bitmap, cliprect, 0, (m_vreg[1] & 2) ? 2 : 4);
215214      m_tx_tilemap->draw(bitmap, cliprect, 0, 4);
216      draw_sprites(machine(), bitmap, cliprect);
215      draw_sprites(bitmap, cliprect);
217216   }
218217   else
219218   {
trunk/src/mame/video/lsasquad.c
r20832r20833
11#include "emu.h"
22#include "includes/lsasquad.h"
33
4static void draw_layer( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *scrollram )
4void lsasquad_state::draw_layer( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *scrollram )
55{
6   lsasquad_state *state = machine.driver_data<lsasquad_state>();
76   int offs, scrollx, scrolly;
87
98   scrollx = scrollram[3];
r20832r20833
1514
1615      base = 64 * scrollram[offs + 1];
1716      sx = 8 * (offs / 4) + scrollx;
18      if (state->flip_screen())
17      if (flip_screen())
1918         sx = 248 - sx;
2019
2120      sx &= 0xff;
r20832r20833
2524         int attr;
2625
2726         sy = 8 * y + scrolly;
28         if (state->flip_screen())
27         if (flip_screen())
2928            sy = 248 - sy;
3029         sy &= 0xff;
3130
32         attr = state->m_videoram[base + 2 * y + 1];
33         code = state->m_videoram[base + 2 * y] + ((attr & 0x0f) << 8);
31         attr = m_videoram[base + 2 * y + 1];
32         code = m_videoram[base + 2 * y] + ((attr & 0x0f) << 8);
3433         color = attr >> 4;
3534
36         drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
35         drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
3736               code,
3837               color,
39               state->flip_screen(),state->flip_screen(),
38               flip_screen(),flip_screen(),
4039               sx,sy,15);
4140         if (sx > 248)   /* wraparound */
42            drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
41            drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
4342                  code,
4443                  color,
45                  state->flip_screen(),state->flip_screen(),
44                  flip_screen(),flip_screen(),
4645                  sx-256,sy,15);
4746      }
4847   }
4948}
5049
51static int draw_layer_daikaiju( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int offs, int  * previd, int type )
50int lsasquad_state::draw_layer_daikaiju( bitmap_ind16 &bitmap, const rectangle &cliprect, int offs, int  * previd, int type )
5251{
53   lsasquad_state *state = machine.driver_data<lsasquad_state>();
5452   int id, scrollx, scrolly, initoffs, globalscrollx;
5553   int stepx = 0;
5654
5755   initoffs = offs;
5856   globalscrollx = 0;
5957
60   id = state->m_scrollram[offs + 2];
58   id = m_scrollram[offs + 2];
6159
6260   for( ; offs < 0x400; offs += 4)
6361   {
6462      int base, y, sx, sy, code, color;
6563
6664         //id change
67      if (id != state->m_scrollram[offs + 2])
65      if (id != m_scrollram[offs + 2])
6866      {
6967         *previd = id;
7068         return offs;
7169      }
7270      else
7371      {
74         id = state->m_scrollram[offs + 2];
72         id = m_scrollram[offs + 2];
7573      }
7674
7775      //skip empty (??) column, potential probs with 1st column in scrollram (scroll 0, tile 0, id 0)
78      if ((state->m_scrollram[offs + 0] | state->m_scrollram[offs + 1] | state->m_scrollram[offs + 2] | state->m_scrollram[offs + 3]) == 0)
76      if ((m_scrollram[offs + 0] | m_scrollram[offs + 1] | m_scrollram[offs + 2] | m_scrollram[offs + 3]) == 0)
7977         continue;
8078
8179      //local scroll x/y
82      scrolly = -state->m_scrollram[offs + 0];
83      scrollx =  state->m_scrollram[offs + 3];
80      scrolly = -m_scrollram[offs + 0];
81      scrollx =  m_scrollram[offs + 3];
8482
8583      //check for global x scroll used in bg layer in game (starts at offset 0 in scrollram
8684      // and game name/logo on title screen (starts in the middle of scrollram, but with different
r20832r20833
9997         }
10098      }
10199
102      base = 64 * state->m_scrollram[offs + 1];
100      base = 64 * m_scrollram[offs + 1];
103101      sx = scrollx + stepx;
104102
105      if (state->flip_screen())
103      if (flip_screen())
106104         sx = 248 - sx;
107105      sx &= 0xff;
108106
r20832r20833
111109         int attr;
112110
113111         sy = 8 * y + scrolly;
114         if (state->flip_screen())
112         if (flip_screen())
115113            sy = 248 - sy;
116114         sy &= 0xff;
117115
118         attr = state->m_videoram[base + 2 * y + 1];
119         code = state->m_videoram[base + 2 * y] + ((attr & 0x0f) << 8);
116         attr = m_videoram[base + 2 * y + 1];
117         code = m_videoram[base + 2 * y] + ((attr & 0x0f) << 8);
120118         color = attr >> 4;
121119
122120         if ((type == 0 && color != 0x0d) || (type != 0 && color == 0x0d))
123121         {
124            drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
122            drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
125123               code,
126124               color,
127               state->flip_screen(),state->flip_screen(),
125               flip_screen(),flip_screen(),
128126               sx,sy,15);
129127            if (sx > 248)   /* wraparound */
130               drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
128               drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
131129                  code,
132130                  color,
133                  state->flip_screen(),state->flip_screen(),
131                  flip_screen(),flip_screen(),
134132                  sx-256,sy,15);
135133         }
136134      }
r20832r20833
138136   return offs;
139137}
140138
141static void drawbg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int type )
139void lsasquad_state::drawbg( bitmap_ind16 &bitmap, const rectangle &cliprect, int type )
142140{
143   lsasquad_state *state = machine.driver_data<lsasquad_state>();
144141   int i = 0;
145142   int id = -1;
146143
147144   while (i < 0x400)
148145   {
149      if (!(state->m_scrollram[i + 2] & 1))
146      if (!(m_scrollram[i + 2] & 1))
150147      {
151         i = draw_layer_daikaiju(machine, bitmap, cliprect, i, &id, type);
148         i = draw_layer_daikaiju(bitmap, cliprect, i, &id, type);
152149      }
153150      else
154151      {
155         id = state->m_scrollram[i + 2];
152         id = m_scrollram[i + 2];
156153         i += 4;
157154      }
158155   }
159156}
160157
161static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
158void lsasquad_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
162159{
163   lsasquad_state *state = machine.driver_data<lsasquad_state>();
164   UINT8 *spriteram = state->m_spriteram;
160   UINT8 *spriteram = m_spriteram;
165161   int offs;
166162
167   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
163   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
168164   {
169165      int sx, sy, attr, code, color, flipx, flipy;
170166
r20832r20833
176172      flipx = attr & 0x40;
177173      flipy = attr & 0x80;
178174
179      if (state->flip_screen())
175      if (flip_screen())
180176      {
181177         sx = 240 - sx;
182178         sy = 240 - sy;
r20832r20833
184180         flipy = !flipy;
185181      }
186182
187      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
183      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
188184            code,
189185            color,
190186            flipx,flipy,
191187            sx,sy,15);
192188      /* wraparound */
193      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
189      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
194190            code,
195191            color,
196192            flipx,flipy,
r20832r20833
202198{
203199   bitmap.fill(511, cliprect);
204200
205   draw_layer(machine(), bitmap, cliprect, m_scrollram + 0x000);
206   draw_layer(machine(), bitmap, cliprect, m_scrollram + 0x080);
207   draw_sprites(machine(), bitmap, cliprect);
208   draw_layer(machine(), bitmap, cliprect, m_scrollram + 0x100);
201   draw_layer(bitmap, cliprect, m_scrollram + 0x000);
202   draw_layer(bitmap, cliprect, m_scrollram + 0x080);
203   draw_sprites(bitmap, cliprect);
204   draw_layer(bitmap, cliprect, m_scrollram + 0x100);
209205   return 0;
210206}
211207
r20832r20833
213209UINT32 lsasquad_state::screen_update_daikaiju(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
214210{
215211   bitmap.fill(511, cliprect);
216   drawbg(machine(), bitmap, cliprect, 0); // bottom
217   draw_sprites(machine(), bitmap, cliprect);
218   drawbg(machine(), bitmap, cliprect, 1); // top = palette $d ?
212   drawbg(bitmap, cliprect, 0); // bottom
213   draw_sprites(bitmap, cliprect);
214   drawbg(bitmap, cliprect, 1); // top = palette $d ?
219215   return 0;
220216}
trunk/src/mame/video/labyrunr.c
r20832r20833
4141}
4242
4343
44static void set_pens( running_machine &machine )
44void labyrunr_state::set_pens(  )
4545{
46   labyrunr_state *state = machine.driver_data<labyrunr_state>();
4746   int i;
4847
4948   for (i = 0x00; i < 0x100; i += 2)
5049   {
51      UINT16 data = state->m_paletteram[i | 1] | (state->m_paletteram[i] << 8);
50      UINT16 data = m_paletteram[i | 1] | (m_paletteram[i] << 8);
5251
5352      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
5453
55      colortable_palette_set_color(machine.colortable, i >> 1, color);
54      colortable_palette_set_color(machine().colortable, i >> 1, color);
5655   }
5756}
5857
r20832r20833
181180   UINT8 ctrl_0 = k007121_ctrlram_r(m_k007121, space, 0);
182181   rectangle finalclip0, finalclip1;
183182
184   set_pens(machine());
183   set_pens();
185184
186185   machine().priority_bitmap.fill(0, cliprect);
187186   bitmap.fill(get_black_pen(machine()), cliprect);
trunk/src/mame/video/ladybug.c
r20832r20833
224224   m_bg_tilemap->set_transparent_pen(0);
225225}
226226
227static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
227void ladybug_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
228228{
229   ladybug_state *state = machine.driver_data<ladybug_state>();
230   UINT8 *spriteram = state->m_spriteram;
229   UINT8 *spriteram = m_spriteram;
231230   int offs;
232231
233   for (offs = state->m_spriteram.bytes() - 2 * 0x40; offs >= 2 * 0x40; offs -= 0x40)
232   for (offs = m_spriteram.bytes() - 2 * 0x40; offs >= 2 * 0x40; offs -= 0x40)
234233   {
235234      int i = 0;
236235
r20832r20833
257256         if (spriteram[offs + i] & 0x80)
258257         {
259258            if (spriteram[offs + i] & 0x40) /* 16x16 */
260               drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
259               drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
261260                     (spriteram[offs + i + 1] >> 2) + 4 * (spriteram[offs + i + 2] & 0x10),
262261                     spriteram[offs + i + 2] & 0x0f,
263262                     spriteram[offs + i] & 0x20,spriteram[offs + i] & 0x10,
264263                     spriteram[offs + i + 3],
265264                     offs / 4 - 8 + (spriteram[offs + i] & 0x0f),0);
266265            else    /* 8x8 */
267               drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
266               drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
268267                     spriteram[offs + i + 1] + 16 * (spriteram[offs + i + 2] & 0x10),
269268                     spriteram[offs + i + 2] & 0x0f,
270269                     spriteram[offs + i] & 0x20,spriteram[offs + i] & 0x10,
r20832r20833
294293   }
295294
296295   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
297   draw_sprites(machine(), bitmap, cliprect);
296   draw_sprites(bitmap, cliprect);
298297   return 0;
299298}
300299
r20832r20833
357356   m_bg_tilemap->draw(bitmap, cliprect, 0, flip_screen());
358357
359358   // now the sprites
360   draw_sprites(machine(), bitmap, cliprect);
359   draw_sprites(bitmap, cliprect);
361360
362361   return 0;
363362}
trunk/src/mame/video/lockon.c
r20832r20833
163163   m_scroll_v = data & 0x81ff;
164164}
165165
166static void scene_draw( running_machine &machine )
166void lockon_state::scene_draw(  )
167167{
168   lockon_state *state = machine.driver_data<lockon_state>();
169168   UINT32 y;
170169
171170   /* 3bpp characters */
172   const UINT8 *const gfx1 = state->memregion("gfx2")->base();
171   const UINT8 *const gfx1 = memregion("gfx2")->base();
173172   const UINT8 *const gfx2 = gfx1 + 0x10000;
174173   const UINT8 *const gfx3 = gfx1 + 0x20000;
175174   const UINT8 *const clut = gfx1 + 0x30000;
r20832r20833
185184      UINT16 *bmpaddr;
186185      UINT32 ram_mask = 0x7ff;
187186
188      y_offs = (y + state->m_scroll_v) & 0x1ff;
187      y_offs = (y + m_scroll_v) & 0x1ff;
189188
190189      /* Clamp - stops tilemap wrapping when screen is rotated */
191      if (BIT(state->m_scroll_v, 15) && y_offs & 0x100)
190      if (BIT(m_scroll_v, 15) && y_offs & 0x100)
192191         ram_mask = 0x7;
193192
194      x_offs = (state->m_scroll_h - 8) & 0x1ff;
193      x_offs = (m_scroll_h - 8) & 0x1ff;
195194      y_gran = y_offs & 7;
196195
197196      if (x_offs & 7)
198197      {
199198         UINT32 tileidx;
200199         UINT16 addr = ((y_offs & ~7) << 3) + ((x_offs >> 3) & 0x3f);
201         UINT16 ram_val = state->m_scene_ram[addr & ram_mask];
200         UINT16 ram_val = m_scene_ram[addr & ram_mask];
202201
203202         colour = (clut[ram_val & 0x7fff] & 0x3f) << 3;
204203         tileidx = ((ram_val & 0x0fff) << 3) + y_gran;
r20832r20833
208207         d2 = *(gfx3 + tileidx);
209208      }
210209
211      bmpaddr = &state->m_back_buffer->pix16(y);
210      bmpaddr = &m_back_buffer->pix16(y);
212211
213212      for (x = 0; x < FRAMEBUFFER_MAX_X; ++x)
214213      {
r20832r20833
219218         {
220219            UINT32 tileidx;
221220            UINT16 addr = ((y_offs & ~7) << 3) + ((x_offs >> 3) & 0x3f);
222            UINT16 ram_val = state->m_scene_ram[addr & ram_mask];
221            UINT16 ram_val = m_scene_ram[addr & ram_mask];
223222
224223            colour = (clut[ram_val & 0x7fff] & 0x3f) << 3;
225224            tileidx = ((ram_val & 0x0fff) << 3) + y_gran;
r20832r20833
299298   rom_data3 = gfx_rom[gfx_addr + 0x20000];                                             \
300299}
301300
302static void ground_draw( running_machine &machine )
301void lockon_state::ground_draw(  )
303302{
304   lockon_state *state = machine.driver_data<lockon_state>();
305303
306304   /* ROM pointers */
307   const UINT8 *const gfx_rom  = state->memregion("gfx4")->base();
308   const UINT8 *const lut_rom  = gfx_rom + 0x30000 + ((state->m_ground_ctrl >> 2) & 0x3 ? 0x10000 : 0);
305   const UINT8 *const gfx_rom  = memregion("gfx4")->base();
306   const UINT8 *const lut_rom  = gfx_rom + 0x30000 + ((m_ground_ctrl >> 2) & 0x3 ? 0x10000 : 0);
309307   const UINT8 *const clut_rom = gfx_rom + 0x50000;
310308
311   UINT32 lut_a15_14   = (state->m_ground_ctrl & 0x3) << 14;
312   UINT32 clut_a14_12 = (state->m_ground_ctrl & 0x70) << 8;
313   UINT32 gfx_a15 = (state->m_ground_ctrl & 0x40) << 9;
309   UINT32 lut_a15_14   = (m_ground_ctrl & 0x3) << 14;
310   UINT32 clut_a14_12 = (m_ground_ctrl & 0x70) << 8;
311   UINT32 gfx_a15 = (m_ground_ctrl & 0x40) << 9;
314312   UINT32 offs = 3;
315313   UINT32 y;
316314
317315   /* TODO: Clean up and emulate CS of GFX ROMs? */
318316   for (y = 0; y < FRAMEBUFFER_MAX_Y; ++y)
319317   {
320      UINT16 *bmpaddr = &state->m_back_buffer->pix16(y);
318      UINT16 *bmpaddr = &m_back_buffer->pix16(y);
321319      UINT8 ls163;
322320      UINT32 clut_addr;
323321      UINT32 gfx_addr;
r20832r20833
328326      UINT32 x;
329327
330328      /* Draw this line? */
331      if (!(state->m_ground_ram[offs] & 0x8000))
329      if (!(m_ground_ram[offs] & 0x8000))
332330      {
333         UINT32 gfx_a2_0  =  state->m_ground_ram[offs] & 0x0007;
334         UINT32 gfx_a6_5  = (state->m_ground_ram[offs] & 0x0018) << 2;
335         UINT32 clut_a4_3 = (state->m_ground_ram[offs] & 0x0018) >> 1;
336         UINT8   tz2213_x  = state->m_ground_ram[offs + 1] & 0xff;
337         UINT8   tz2213_dx = state->m_ground_ram[offs + 2] & 0xff;
331         UINT32 gfx_a2_0  =  m_ground_ram[offs] & 0x0007;
332         UINT32 gfx_a6_5  = (m_ground_ram[offs] & 0x0018) << 2;
333         UINT32 clut_a4_3 = (m_ground_ram[offs] & 0x0018) >> 1;
334         UINT8   tz2213_x  = m_ground_ram[offs + 1] & 0xff;
335         UINT8   tz2213_dx = m_ground_ram[offs + 2] & 0xff;
338336
339         UINT32 lut_address = lut_a15_14 + ((state->m_ground_ram[offs] & 0x7fe0) >> 1);
340         UINT32 cy = state->m_ground_ram[offs + 2] & 0x0100;
337         UINT32 lut_address = lut_a15_14 + ((m_ground_ram[offs] & 0x7fe0) >> 1);
338         UINT32 cy = m_ground_ram[offs + 2] & 0x0100;
341339         UINT32 color;
342340         UINT32 gpbal2_0_prev;
343341
344         ls163 = state->m_ground_ram[offs + 1] >> 8;
342         ls163 = m_ground_ram[offs + 1] >> 8;
345343
346344         gpbal2_0_prev = ((ls163 & 3) << 1) | BIT(tz2213_x, 7);
347345
r20832r20833
379377      offs += 3;
380378
381379      /* End of list marker */
382      if (state->m_ground_ram[offs + 2] & 0x8000)
380      if (m_ground_ram[offs + 2] & 0x8000)
383381      {
384         state->m_bufend_timer->adjust(attotime::from_hz(FRAMEBUFFER_CLOCK) * (FRAMEBUFFER_MAX_X * y));
382         m_bufend_timer->adjust(attotime::from_hz(FRAMEBUFFER_CLOCK) * (FRAMEBUFFER_MAX_X * y));
385383      }
386384   }
387385}
r20832r20833
418416   if (px < FRAMEBUFFER_MAX_X)                          \
419417   if (COLOR != 0xf)                                    \
420418   {                                                    \
421      UINT8 clr = state->m_obj_pal_ram[(pal << 4) + COLOR];     \
419      UINT8 clr = m_obj_pal_ram[(pal << 4) + COLOR];     \
422420      UINT16 *pix = (line + px);                       \
423421      if (!(clr == 0xff && ((*pix & 0xe00) == 0xa00))) \
424422         *pix = 0x400 + clr;          \
r20832r20833
426424   px = (px + 1) & 0x7ff;                               \
427425} while(0)
428426
429static void objects_draw( running_machine &machine )
427void lockon_state::objects_draw(  )
430428{
431429   UINT32 offs;
432   lockon_state *state = machine.driver_data<lockon_state>();
433430
434   const UINT8  *const romlut = state->memregion("user1")->base();
435   const UINT16 *const chklut = (UINT16*)state->memregion("user2")->base();
436   const UINT8  *const gfxrom = state->memregion("gfx5")->base();
437   const UINT8  *const sproms = state->memregion("proms")->base() + 0x800;
431   const UINT8  *const romlut = memregion("user1")->base();
432   const UINT16 *const chklut = (UINT16*)memregion("user2")->base();
433   const UINT8  *const gfxrom = memregion("gfx5")->base();
434   const UINT8  *const sproms = memregion("proms")->base() + 0x800;
438435
439   for (offs = 0; offs < state->m_object_ram.bytes(); offs += 4)
436   for (offs = 0; offs < m_object_ram.bytes(); offs += 4)
440437   {
441438      UINT32 y;
442439      UINT32 xpos;
r20832r20833
452449      UINT32 opsta15_8;
453450
454451      /* Retrieve the object attributes */
455      ypos    = state->m_object_ram[offs] & 0x03ff;
456      xpos    = state->m_object_ram[offs + 3] & 0x07ff;
457      ysize   = (state->m_object_ram[offs] >> 10) & 0x3;
458      xsize   = (state->m_object_ram[offs] >> 12) & 0x3;
459      yflip   = BIT(state->m_object_ram[offs], 14);
460      xflip   = BIT(state->m_object_ram[offs], 15);
461      scale   = state->m_object_ram[offs + 1] & 0xff;
462      pal = (state->m_object_ram[offs + 1] >> 8) & 0x7f;
463      opsta   = state->m_object_ram[offs + 2];
452      ypos    = m_object_ram[offs] & 0x03ff;
453      xpos    = m_object_ram[offs + 3] & 0x07ff;
454      ysize   = (m_object_ram[offs] >> 10) & 0x3;
455      xsize   = (m_object_ram[offs] >> 12) & 0x3;
456      yflip   = BIT(m_object_ram[offs], 14);
457      xflip   = BIT(m_object_ram[offs], 15);
458      scale   = m_object_ram[offs + 1] & 0xff;
459      pal = (m_object_ram[offs + 1] >> 8) & 0x7f;
460      opsta   = m_object_ram[offs + 2];
464461
465      if (state->m_iden)
462      if (m_iden)
466463      {
467         state->m_obj_pal_ram[(pal << 4) + state->m_obj_pal_addr] = state->m_obj_pal_latch;
464         m_obj_pal_ram[(pal << 4) + m_obj_pal_addr] = m_obj_pal_latch;
468465         break;
469466      }
470467
r20832r20833
484481         UINT32 tile;
485482         UINT8   cnt;
486483         UINT32 yidx;
487         UINT16 *line = &state->m_back_buffer->pix16(y);
484         UINT16 *line = &m_back_buffer->pix16(y);
488485         UINT32 px = xpos;
489486
490487         /* Outside the limits? */
r20832r20833
595592      }
596593
597594      /* Check for the end of list marker */
598      if (state->m_object_ram[offs + 1] & 0x8000)
595      if (m_object_ram[offs + 1] & 0x8000)
599596         return;
600597   }
601598}
r20832r20833
607604   {
608605      m_obj_pal_latch = data & 0xff;
609606      m_obj_pal_addr = offset & 0xf;
610      objects_draw(machine());
607      objects_draw();
611608   }
612609}
613610
r20832r20833
684681   if (carry) --CNT;                    \
685682} while(0)
686683
687static void rotate_draw( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
684void lockon_state::rotate_draw( bitmap_ind16 &bitmap, const rectangle &cliprect )
688685{
689   lockon_state *state = machine.driver_data<lockon_state>();
690686   UINT32 y;
691687
692688   /* Counters */
693   UINT32 cxy = state->m_xsal & 0xff;
694   UINT32 cyy = state->m_ysal & 0x1ff;
689   UINT32 cxy = m_xsal & 0xff;
690   UINT32 cyy = m_ysal & 0x1ff;
695691
696692   /* Accumulator values and deltas */
697   UINT8 axy  = state->m_x0ll & 0xff;
698   UINT8 daxy = state->m_dx0ll & 0xff;
699   UINT8 ayy  = state->m_y0ll & 0xff;
700   UINT8 dayy = state->m_dy0ll & 0xff;
701   UINT8 dayx = state->m_dyll & 0xff;
702   UINT8 daxx = state->m_dxll & 0xff;
693   UINT8 axy  = m_x0ll & 0xff;
694   UINT8 daxy = m_dx0ll & 0xff;
695   UINT8 ayy  = m_y0ll & 0xff;
696   UINT8 dayy = m_dy0ll & 0xff;
697   UINT8 dayx = m_dyll & 0xff;
698   UINT8 daxx = m_dxll & 0xff;
703699
704   UINT32 xy_up = BIT(state->m_xsal, 8);
705   UINT32 yx_up = BIT(state->m_dyll, 9);
706   UINT32 axx_en  = !BIT(state->m_dxll, 8);
707   UINT32 ayx_en  = !BIT(state->m_dyll, 8);
708   UINT32 axy_en  = !BIT(state->m_dx0ll, 8);
709   UINT32 ayy_en  = !BIT(state->m_dy0ll, 8);
700   UINT32 xy_up = BIT(m_xsal, 8);
701   UINT32 yx_up = BIT(m_dyll, 9);
702   UINT32 axx_en  = !BIT(m_dxll, 8);
703   UINT32 ayx_en  = !BIT(m_dyll, 8);
704   UINT32 axy_en  = !BIT(m_dx0ll, 8);
705   UINT32 ayy_en  = !BIT(m_dy0ll, 8);
710706
711707   for (y = 0; y <= cliprect.max_y; ++y)
712708   {
r20832r20833
725721         cx &= 0x1ff;
726722         cy &= 0x1ff;
727723
728         *dst++ = state->m_front_buffer->pix16(cy, cx);
724         *dst++ = m_front_buffer->pix16(cy, cx);
729725
730726         if (axx_en)
731727            INCREMENT(axx, cx);
r20832r20833
789785
790786*******************************************************************************************/
791787
792static void hud_draw( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
788void lockon_state::hud_draw( bitmap_ind16 &bitmap, const rectangle &cliprect )
793789{
794   lockon_state *state = machine.driver_data<lockon_state>();
795   UINT8   *tile_rom = state->memregion("gfx3")->base();
790   UINT8   *tile_rom = memregion("gfx3")->base();
796791   UINT32 offs;
797792
798   for (offs = 0x0; offs <= state->m_hud_ram.bytes(); offs += 2)
793   for (offs = 0x0; offs <= m_hud_ram.bytes(); offs += 2)
799794   {
800795      UINT32 y;
801796      UINT32 y_pos;
r20832r20833
808803      UINT32 rom_a12_7;
809804
810805      /* End of sprite list marker */
811      if (state->m_hud_ram[offs + 1] & 0x8000)
806      if (m_hud_ram[offs + 1] & 0x8000)
812807         break;
813808
814      y_pos   = state->m_hud_ram[offs] & 0x1ff;
815      x_pos   = state->m_hud_ram[offs + 1] & 0x1ff;
816      x_size = (state->m_hud_ram[offs + 1] >> 12) & 7;
817      code    = (state->m_hud_ram[offs] >> 9) & 0x7f;
818      colour = 0x200 + ((state->m_hud_ram[offs + 1] >> 9) & 7);
809      y_pos   = m_hud_ram[offs] & 0x1ff;
810      x_pos   = m_hud_ram[offs + 1] & 0x1ff;
811      x_size = (m_hud_ram[offs + 1] >> 12) & 7;
812      code    = (m_hud_ram[offs] >> 9) & 0x7f;
813      colour = 0x200 + ((m_hud_ram[offs + 1] >> 9) & 7);
819814      layout = (code >> 5) & 3;
820815
821816      rom_a12_7 = (code & 0xfe) << 6;
r20832r20833
923918   }
924919
925920   /* Scan out the frame buffer in rotated order */
926   rotate_draw(machine(), bitmap, cliprect);
921   rotate_draw(bitmap, cliprect);
927922
928923   /* Draw the character tilemap */
929924   m_tilemap->draw(bitmap, cliprect, 0, 0);
930925
931926   /* Draw the HUD */
932   hud_draw(machine(), bitmap, cliprect);
927   hud_draw(bitmap, cliprect);
933928
934929   return 0;
935930}
r20832r20833
945940      m_back_buffer = tmp;
946941
947942      /* Draw the frame buffer layers */
948      scene_draw(machine());
949      ground_draw(machine());
950      objects_draw(machine());
943      scene_draw();
944      ground_draw();
945      objects_draw();
951946   }
952947}
trunk/src/mame/video/lazercmd.c
r20832r20833
1616/*     2      4 + 5      10      14 + 15 */
1717/*     3      6 + 7      11      16 + 17 */
1818/*     4      8 + 9      12      18 + 19 */
19static int vert_scale(int data)
19int lazercmd_state::vert_scale(int data)
2020{
2121   return ((data & 0x07) << 1) + ((data & 0xf8) >> 3) * VERT_CHR;
2222}
r20832r20833
2424/* plot a bitmap marker */
2525/* hardware has 2 marker sizes 2x2 and 4x2 selected by jumper */
2626/* meadows lanes normaly use 2x2 pixels and lazer command uses either */
27static void plot_pattern( running_machine &machine, bitmap_ind16 &bitmap, int x, int y )
27void lazercmd_state::plot_pattern( bitmap_ind16 &bitmap, int x, int y )
2828{
2929   int xbit, ybit, size;
3030
3131   size = 2;
32   if (machine.root_device().ioport("DSW")->read() & 0x40)
32   if (machine().root_device().ioport("DSW")->read() & 0x40)
3333   {
3434      size = 4;
3535   }
r20832r20833
7575
7676   x = m_marker_x - 1;             /* normal video lags marker by 1 pixel */
7777   y = vert_scale(m_marker_y) - VERT_CHR; /* first line used as scratch pad */
78   plot_pattern(machine(), bitmap, x, y);
78   plot_pattern(bitmap, x, y);
7979
8080   return 0;
8181}
trunk/src/mame/video/lemmings.c
r20832r20833
107107}
108108
109109
110void lemmings_copy_bitmap(running_machine &machine, bitmap_rgb32& bitmap, bitmap_ind16& srcbitmap, int* xscroll, int* yscroll, const rectangle& cliprect)
110void lemmings_state::lemmings_copy_bitmap(bitmap_rgb32& bitmap, bitmap_ind16& srcbitmap, int* xscroll, int* yscroll, const rectangle& cliprect)
111111{
112112   int y,x;
113   const pen_t *paldata = machine.pens;
113   const pen_t *paldata = machine().pens;
114114
115115   for (y=cliprect.min_y; y<cliprect.max_y;y++)
116116   {
r20832r20833
144144   /* Pixel layer can be windowed in hardware (two player mode) */
145145   if ((m_control_data[6] & 2) == 0)
146146   {
147      lemmings_copy_bitmap(machine(), bitmap, m_bitmap0, &x1, &y, cliprect);
147      lemmings_copy_bitmap(bitmap, m_bitmap0, &x1, &y, cliprect);
148148   }
149149   else
150150   {
151151      rect.max_x = 159;
152152      rect.min_x = 0;
153      lemmings_copy_bitmap(machine(), bitmap, m_bitmap0, &x0, &y, rect);
153      lemmings_copy_bitmap(bitmap, m_bitmap0, &x0, &y, rect);
154154
155155      rect.max_x = 319;
156156      rect.min_x = 160;
157      lemmings_copy_bitmap(machine(), bitmap, m_bitmap0, &x1, &y, rect);
157      lemmings_copy_bitmap(bitmap, m_bitmap0, &x1, &y, rect);
158158   }
159159
160160   m_sprgen2->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0800, 0x0800, 0x200, 0xff);
trunk/src/mame/video/lasso.c
r20832r20833
3838
3939***************************************************************************/
4040
41static rgb_t get_color( int data )
41rgb_t lasso_state::get_color( int data )
4242{
4343   int bit0, bit1, bit2;
4444   int r, g, b;
r20832r20833
104104}
105105
106106
107static void wwjgtin_set_last_four_colors( running_machine &machine, colortable_t *colortable )
107void lasso_state::wwjgtin_set_last_four_colors( colortable_t *colortable )
108108{
109   lasso_state *state = machine.driver_data<lasso_state>();
110109   int i;
111110
112111   /* the last palette entries can be changed */
113112   for(i = 0; i < 3; i++)
114      colortable_palette_set_color(colortable, 0x3d + i, get_color(state->m_last_colors[i]));
113      colortable_palette_set_color(colortable, 0x3d + i, get_color(m_last_colors[i]));
115114}
116115
117116
r20832r20833
260259 *
261260 *************************************/
262261
263static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int reverse )
262void lasso_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int reverse )
264263{
265   lasso_state *state = machine.driver_data<lasso_state>();
266264   const UINT8 *finish, *source;
267265   int inc;
268266
269267   if (reverse)
270268   {
271      source = state->m_spriteram;
272      finish = state->m_spriteram + state->m_spriteram.bytes();
269      source = m_spriteram;
270      finish = m_spriteram + m_spriteram.bytes();
273271      inc = 4;
274272   }
275273   else
276274   {
277      source = state->m_spriteram + state->m_spriteram.bytes() - 4;
278      finish = state->m_spriteram - 4;
275      source = m_spriteram + m_spriteram.bytes() - 4;
276      finish = m_spriteram - 4;
279277      inc = -4;
280278   }
281279
r20832r20833
289287      flipx = source[1] & 0x40;
290288      flipy = source[1] & 0x80;
291289
292      if (state->flip_screen_x())
290      if (flip_screen_x())
293291      {
294292         sx = 240 - sx;
295293         flipx = !flipx;
296294      }
297295
298      if (state->flip_screen_y())
296      if (flip_screen_y())
299297         flipy = !flipy;
300298      else
301299         sy = 240 - sy;
r20832r20833
303301      code = source[1] & 0x3f;
304302      color = source[2] & 0x0f;
305303
306      drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
307            code | ((UINT16)state->m_gfxbank << 6),
304      drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
305            code | ((UINT16)m_gfxbank << 6),
308306            color,
309307            flipx, flipy,
310308            sx,sy,0);
r20832r20833
314312}
315313
316314
317static void draw_lasso( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
315void lasso_state::draw_lasso( bitmap_ind16 &bitmap, const rectangle &cliprect )
318316{
319   lasso_state *state = machine.driver_data<lasso_state>();
320317   offs_t offs;
321318   pen_t pen = 0x3f;
322319
r20832r20833
327324      UINT8 x;
328325      UINT8 y = offs >> 5;
329326
330      if (state->flip_screen_y())
327      if (flip_screen_y())
331328         y = ~y;
332329
333330      if ((y < cliprect.min_y) || (y > cliprect.max_y))
334331         continue;
335332
336333      x = (offs & 0x1f) << 3;
337      data = state->m_bitmap_ram[offs];
334      data = m_bitmap_ram[offs];
338335
339      if (state->flip_screen_x())
336      if (flip_screen_x())
340337         x = ~x;
341338
342339      for (bit = 0; bit < 8; bit++)
r20832r20833
344341         if ((data & 0x80) && (x >= cliprect.min_x) && (x <= cliprect.max_x))
345342            bitmap.pix16(y, x) = pen;
346343
347         if (state->flip_screen_x())
344         if (flip_screen_x())
348345            x = x - 1;
349346         else
350347            x = x + 1;
r20832r20833
361358   bitmap.fill(0, cliprect);
362359
363360   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
364   draw_lasso(machine(), bitmap, cliprect);
365   draw_sprites(machine(), bitmap, cliprect, 0);
361   draw_lasso(bitmap, cliprect);
362   draw_sprites(bitmap, cliprect, 0);
366363
367364   return 0;
368365}
r20832r20833
373370   bitmap.fill(0, cliprect);
374371
375372   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
376   draw_sprites(machine(), bitmap, cliprect, 0);
373   draw_sprites(bitmap, cliprect, 0);
377374
378375   return 0;
379376}
r20832r20833
382379UINT32 lasso_state::screen_update_wwjgtin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
383380{
384381   colortable_palette_set_color(machine().colortable, 0, get_color(*m_back_color));
385   wwjgtin_set_last_four_colors(machine(), machine().colortable);
382   wwjgtin_set_last_four_colors(machine().colortable);
386383
387384   m_track_tilemap->set_scrollx(0, m_track_scroll[0] + m_track_scroll[1] * 256);
388385   m_track_tilemap->set_scrolly(0, m_track_scroll[2] + m_track_scroll[3] * 256);
r20832r20833
392389   else
393390      bitmap.fill(get_black_pen(machine()), cliprect);
394391
395   draw_sprites(machine(), bitmap, cliprect, 1);   // reverse order
392   draw_sprites(bitmap, cliprect, 1);   // reverse order
396393   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
397394
398395   return 0;
trunk/src/mame/video/lastduel.c
r20832r20833
197197
198198***************************************************************************/
199199
200static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
200void lastduel_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
201201{
202   lastduel_state *state = machine.driver_data<lastduel_state>();
203202
204   UINT16 *buffered_spriteram16 = state->m_spriteram->buffer();
203   UINT16 *buffered_spriteram16 = m_spriteram->buffer();
205204   int offs;
206205
207   if (!state->m_sprite_pri_mask)
206   if (!m_sprite_pri_mask)
208207      if (pri == 1)
209208         return; /* only low priority sprites in lastduel */
210209
r20832r20833
213212      int attr, sy, sx, flipx, flipy, code, color;
214213
215214      attr = buffered_spriteram16[offs + 1];
216      if (state->m_sprite_pri_mask)   /* only madgear seems to have this */
215      if (m_sprite_pri_mask)   /* only madgear seems to have this */
217216      {
218         if (pri == 1 && (attr & state->m_sprite_pri_mask))
217         if (pri == 1 && (attr & m_sprite_pri_mask))
219218            continue;
220         if (pri == 0 && !(attr & state->m_sprite_pri_mask))
219         if (pri == 0 && !(attr & m_sprite_pri_mask))
221220            continue;
222221      }
223222
r20832r20833
228227         sy -= 0x200;
229228
230229      flipx = attr & 0x20;
231      flipy = attr & state->m_sprite_flipy_mask;  /* 0x40 for lastduel, 0x80 for madgear */
230      flipy = attr & m_sprite_flipy_mask;  /* 0x40 for lastduel, 0x80 for madgear */
232231      color = attr & 0x0f;
233232
234      if (state->flip_screen())
233      if (flip_screen())
235234      {
236235         sx = 496 - sx;
237236         sy = 240 - sy;
r20832r20833
240239      }
241240
242241      drawgfx_transpen(bitmap,cliprect,
243            machine.gfx[0],
242            machine().gfx[0],
244243            code,
245244            color,
246245            flipx,flipy,
r20832r20833
252251{
253252   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
254253   m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
255   draw_sprites(machine(), bitmap, cliprect, 0);
254   draw_sprites(bitmap, cliprect, 0);
256255   m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
257   draw_sprites(machine(), bitmap, cliprect, 1);
256   draw_sprites(bitmap, cliprect, 1);
258257   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
259258   return 0;
260259}
r20832r20833
264263   if (m_tilemap_priority)
265264   {
266265      m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_OPAQUE, 0);
267      draw_sprites(machine(), bitmap, cliprect, 0);
266      draw_sprites(bitmap, cliprect, 0);
268267      m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
269268      m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
270      draw_sprites(machine(), bitmap, cliprect, 1);
269      draw_sprites(bitmap, cliprect, 1);
271270   }
272271   else
273272   {
274273      m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
275274      m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
276      draw_sprites(machine(), bitmap, cliprect, 0);
275      draw_sprites(bitmap, cliprect, 0);
277276      m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
278      draw_sprites(machine(), bitmap, cliprect, 1);
277      draw_sprites(bitmap, cliprect, 1);
279278   }
280279   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
281280   return 0;
trunk/src/mame/video/redclash.c
r20832r20833
427427{
428428   bitmap.fill(get_black_pen(machine()), cliprect);
429429   redclash_draw_stars(machine(), bitmap, cliprect, 0x60, 0, 0x00, 0xff);
430   draw_sprites(machine(), bitmap, cliprect);
430   ::draw_sprites(machine(), bitmap, cliprect);
431431   draw_bullets(machine(), bitmap, cliprect);
432432   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
433433   return 0;
trunk/src/mame/drivers/lordgun.c
r20832r20833
181181   // Update light guns positions
182182   for (i = 0; i < 2; i++)
183183      if ( (data & (0x04 << i)) && !(m_old & (0x04 << i)) )
184         lordgun_update_gun(machine(), i);
184         lordgun_update_gun(i);
185185
186186   // latch the bit
187187   eeprom->write_bit(data & 0x40);
trunk/src/mame/drivers/lwings.c
r20832r20833
131131   m_palette_pen = data * 64;
132132}
133133
134static int avengers_fetch_paldata( running_machine &machine )
134int lwings_state::avengers_fetch_paldata(  )
135135{
136   lwings_state *state = machine.driver_data<lwings_state>();
137136
138137   static const char pal_data[] =
139138   /* page 1: 0x03,0x02,0x01,0x00 */
r20832r20833
196195   "0000000000000000" "6474667676660100" "7696657575650423" "88A8647474645473"
197196   "0000000000000000" "0001070701050004" "0003060603040303" "0005050505040302";
198197
199   int bank = state->m_palette_pen / 64;
200   int offs = state->m_palette_pen % 64;
198   int bank = m_palette_pen / 64;
199   int offs = m_palette_pen % 64;
201200   int page = bank / 4;                    /* 0..7 */
202201   int base = (3 - (bank & 3));            /* 0..3 */
203202   int row = offs & 0xf;                   /* 0..15 */
r20832r20833
218217
219218   result = digit0 * 16 + digit1;
220219
221   if ((state->m_palette_pen & 0x3f) != 0x3f)
222      state->m_palette_pen++;
220   if ((m_palette_pen & 0x3f) != 0x3f)
221      m_palette_pen++;
223222
224223   return result;
225224}
r20832r20833
236235   if (space.device().safe_pc() == 0x7c7)
237236   {
238237      /* palette data */
239      return avengers_fetch_paldata(machine());
238      return avengers_fetch_paldata();
240239   }
241240
242241   /*  Point to Angle Function
trunk/src/mame/drivers/ataxx.c
r20832r20833
707707
708708DRIVER_INIT_MEMBER(leland_state,ataxx)
709709{
710   leland_rotate_memory(machine(), "master");
711   leland_rotate_memory(machine(), "slave");
710   leland_rotate_memory("master");
711   leland_rotate_memory("slave");
712712
713713   /* set up additional input ports */
714714   machine().device("master")->memory().space(AS_IO).install_read_handler(0x00, 0x03, read8_delegate(FUNC(leland_state::ataxx_trackball_r),this));
r20832r20833
717717
718718DRIVER_INIT_MEMBER(leland_state,ataxxj)
719719{
720   leland_rotate_memory(machine(), "master");
721   leland_rotate_memory(machine(), "slave");
720   leland_rotate_memory("master");
721   leland_rotate_memory("slave");
722722
723723   /* set up additional input ports */
724724   machine().device("master")->memory().space(AS_IO).install_read_handler(0x00, 0x03, read8_delegate(FUNC(leland_state::ataxx_trackball_r),this));
r20832r20833
727727
728728DRIVER_INIT_MEMBER(leland_state,wsf)
729729{
730   leland_rotate_memory(machine(), "master");
731   leland_rotate_memory(machine(), "slave");
730   leland_rotate_memory("master");
731   leland_rotate_memory("slave");
732732
733733   /* set up additional input ports */
734734   machine().device("master")->memory().space(AS_IO).install_read_port(0x0d, 0x0d, "P1_P2");
r20832r20833
739739
740740DRIVER_INIT_MEMBER(leland_state,indyheat)
741741{
742   leland_rotate_memory(machine(), "master");
743   leland_rotate_memory(machine(), "slave");
742   leland_rotate_memory("master");
743   leland_rotate_memory("slave");
744744
745745   /* set up additional input ports */
746746   machine().device("master")->memory().space(AS_IO).install_read_handler(0x00, 0x02, read8_delegate(FUNC(leland_state::indyheat_wheel_r),this));
r20832r20833
756756
757757DRIVER_INIT_MEMBER(leland_state,brutforc)
758758{
759   leland_rotate_memory(machine(), "master");
760   leland_rotate_memory(machine(), "slave");
759   leland_rotate_memory("master");
760   leland_rotate_memory("slave");
761761
762762   /* set up additional input ports */
763763   machine().device("master")->memory().space(AS_IO).install_read_port(0x0d, 0x0d, "P2");
r20832r20833
768768
769769DRIVER_INIT_MEMBER(leland_state,asylum)
770770{
771   leland_rotate_memory(machine(), "master");
772   leland_rotate_memory(machine(), "slave");
771   leland_rotate_memory("master");
772   leland_rotate_memory("slave");
773773
774774   /* asylum appears to have some extra RAM for the slave CPU */
775775   machine().device("slave")->memory().space(AS_PROGRAM).install_ram(0xf000, 0xfffb);
trunk/src/mame/drivers/legionna.c
r20832r20833
908908};
909909
910910
911static void descramble_legionnaire_gfx(running_machine &machine, UINT8* src)
911void legionna_state::descramble_legionnaire_gfx(UINT8* src)
912912{
913913   UINT8 *buffer;
914914   int len = 0x10000;
915915
916916   /*  rearrange gfx */
917   buffer = auto_alloc_array(machine, UINT8, len);
917   buffer = auto_alloc_array(machine(), UINT8, len);
918918   {
919919      int i;
920920      for (i = 0;i < len; i++)
r20832r20833
928928         3,2,1,0)];
929929      }
930930      memcpy(src,buffer,len);
931      auto_free(machine, buffer);
931      auto_free(machine(), buffer);
932932   }
933933
934934}
r20832r20833
23402340
23412341DRIVER_INIT_MEMBER(legionna_state,legiongfx)
23422342{
2343   descramble_legionnaire_gfx( machine(), machine().root_device().memregion("gfx5")->base() );
2343   descramble_legionnaire_gfx(machine().root_device().memregion("gfx5")->base() );
23442344}
23452345
23462346
trunk/src/mame/drivers/leland.c
r20832r20833
19781978 *
19791979 *************************************/
19801980
1981static void init_master_ports(running_machine &machine, UINT8 mvram_base, UINT8 io_base)
1981void leland_state::init_master_ports(UINT8 mvram_base, UINT8 io_base)
19821982{
1983   leland_state *state = machine.driver_data<leland_state>();
19841983   /* set up the master CPU VRAM I/O */
1985   machine.device("master")->memory().space(AS_IO).install_readwrite_handler(mvram_base, mvram_base + 0x1f, read8_delegate(FUNC(leland_state::leland_mvram_port_r),state), write8_delegate(FUNC(leland_state::leland_mvram_port_w),state));
1984   machine().device("master")->memory().space(AS_IO).install_readwrite_handler(mvram_base, mvram_base + 0x1f, read8_delegate(FUNC(leland_state::leland_mvram_port_r),this), write8_delegate(FUNC(leland_state::leland_mvram_port_w),this));
19861985
19871986   /* set up the master CPU I/O ports */
1988   machine.device("master")->memory().space(AS_IO).install_read_handler(io_base, io_base + 0x1f, read8_delegate(FUNC(leland_state::leland_master_input_r),state));
1989   machine.device("master")->memory().space(AS_IO).install_write_handler(io_base, io_base + 0x0f, write8_delegate(FUNC(leland_state::leland_master_output_w),state));
1987   machine().device("master")->memory().space(AS_IO).install_read_handler(io_base, io_base + 0x1f, read8_delegate(FUNC(leland_state::leland_master_input_r),this));
1988   machine().device("master")->memory().space(AS_IO).install_write_handler(io_base, io_base + 0x0f, write8_delegate(FUNC(leland_state::leland_master_output_w),this));
19901989}
19911990
19921991
19931992DRIVER_INIT_MEMBER(leland_state,cerberus)
19941993{
19951994   /* master CPU bankswitching */
1996   m_update_master_bank = cerberus_bankswitch;
1995   m_update_master_bank = &leland_state::cerberus_bankswitch;
19971996   membank("bank1")->set_base(memregion("master")->base() + 0x2000);
19981997   membank("bank2")->set_base(memregion("master")->base() + 0xa000);
19991998   membank("bank3")->set_base(memregion("slave")->base() + 0x2000);
20001999
20012000   /* set up the master CPU I/O ports */
2002   init_master_ports(machine(), 0x40, 0x80);
2001   init_master_ports(0x40, 0x80);
20032002
20042003   /* set up additional input ports */
20052004   machine().device("master")->memory().space(AS_IO).install_read_handler(0x80, 0x80, read8_delegate(FUNC(leland_state::cerberus_dial_1_r),this));
r20832r20833
20102009DRIVER_INIT_MEMBER(leland_state,mayhem)
20112010{
20122011   /* master CPU bankswitching */
2013   m_update_master_bank = mayhem_bankswitch;
2012   m_update_master_bank = &leland_state::mayhem_bankswitch;
20142013
20152014   /* set up the master CPU I/O ports */
2016   init_master_ports(machine(), 0x00, 0xc0);
2015   init_master_ports(0x00, 0xc0);
20172016}
20182017
20192018
20202019DRIVER_INIT_MEMBER(leland_state,powrplay)
20212020{
20222021   /* master CPU bankswitching */
2023   m_update_master_bank = mayhem_bankswitch;
2022   m_update_master_bank = &leland_state::mayhem_bankswitch;
20242023
20252024   /* set up the master CPU I/O ports */
2026   init_master_ports(machine(), 0x40, 0x80);
2025   init_master_ports(0x40, 0x80);
20272026}
20282027
20292028
20302029DRIVER_INIT_MEMBER(leland_state,wseries)
20312030{
20322031   /* master CPU bankswitching */
2033   m_update_master_bank = mayhem_bankswitch;
2032   m_update_master_bank = &leland_state::mayhem_bankswitch;
20342033
20352034   /* set up the master CPU I/O ports */
2036   init_master_ports(machine(), 0x40, 0x80);
2035   init_master_ports(0x40, 0x80);
20372036}
20382037
20392038
20402039DRIVER_INIT_MEMBER(leland_state,alleymas)
20412040{
20422041   /* master CPU bankswitching */
2043   m_update_master_bank = mayhem_bankswitch;
2042   m_update_master_bank = &leland_state::mayhem_bankswitch;
20442043
20452044   /* set up the master CPU I/O ports */
2046   init_master_ports(machine(), 0x00, 0xc0);
2045   init_master_ports(0x00, 0xc0);
20472046
20482047   /* kludge warning: the game uses location E0CA to determine if the joysticks are available */
20492048   /* it gets cleared by the code, but there is no obvious way for the value to be set to a */
r20832r20833
20552054DRIVER_INIT_MEMBER(leland_state,upyoural)
20562055{
20572056   /* master CPU bankswitching */
2058   m_update_master_bank = mayhem_bankswitch;
2057   m_update_master_bank = &leland_state::mayhem_bankswitch;
20592058
20602059   /* set up the master CPU I/O ports */
2061   init_master_ports(machine(), 0x00, 0xc0);
2060   init_master_ports(0x00, 0xc0);
20622061}
20632062
20642063
20652064DRIVER_INIT_MEMBER(leland_state,dangerz)
20662065{
20672066   /* master CPU bankswitching */
2068   m_update_master_bank = dangerz_bankswitch;
2067   m_update_master_bank = &leland_state::dangerz_bankswitch;
20692068
20702069   /* set up the master CPU I/O ports */
2071   init_master_ports(machine(), 0x40, 0x80);
2070   init_master_ports(0x40, 0x80);
20722071
20732072   /* set up additional input ports */
20742073   machine().device("master")->memory().space(AS_IO).install_read_handler(0xf4, 0xf4, read8_delegate(FUNC(leland_state::dangerz_input_upper_r),this));
r20832r20833
20802079DRIVER_INIT_MEMBER(leland_state,basebal2)
20812080{
20822081   /* master CPU bankswitching */
2083   m_update_master_bank = basebal2_bankswitch;
2082   m_update_master_bank = &leland_state::basebal2_bankswitch;
20842083
20852084   /* set up the master CPU I/O ports */
2086   init_master_ports(machine(), 0x00, 0xc0);
2085   init_master_ports(0x00, 0xc0);
20872086}
20882087
20892088
20902089DRIVER_INIT_MEMBER(leland_state,dblplay)
20912090{
20922091   /* master CPU bankswitching */
2093   m_update_master_bank = basebal2_bankswitch;
2092   m_update_master_bank = &leland_state::basebal2_bankswitch;
20942093
20952094   /* set up the master CPU I/O ports */
2096   init_master_ports(machine(), 0x80, 0x40);
2095   init_master_ports(0x80, 0x40);
20972096}
20982097
20992098
21002099DRIVER_INIT_MEMBER(leland_state,strkzone)
21012100{
21022101   /* master CPU bankswitching */
2103   m_update_master_bank = basebal2_bankswitch;
2102   m_update_master_bank = &leland_state::basebal2_bankswitch;
21042103
21052104   /* set up the master CPU I/O ports */
2106   init_master_ports(machine(), 0x00, 0x40);
2105   init_master_ports(0x00, 0x40);
21072106}
21082107
21092108
21102109DRIVER_INIT_MEMBER(leland_state,redlin2p)
21112110{
21122111   /* master CPU bankswitching */
2113   m_update_master_bank = redline_bankswitch;
2112   m_update_master_bank = &leland_state::redline_bankswitch;
21142113
2115   leland_rotate_memory(machine(), "master");
2114   leland_rotate_memory("master");
21162115
21172116   /* set up the master CPU I/O ports */
2118   init_master_ports(machine(), 0x00, 0xc0);
2117   init_master_ports(0x00, 0xc0);
21192118
21202119   /* set up additional input ports */
21212120   machine().device("master")->memory().space(AS_IO).install_read_handler(0xc0, 0xc0, read8_delegate(FUNC(leland_state::redline_pedal_1_r),this));
r20832r20833
21282127DRIVER_INIT_MEMBER(leland_state,quarterb)
21292128{
21302129   /* master CPU bankswitching */
2131   m_update_master_bank = viper_bankswitch;
2130   m_update_master_bank = &leland_state::viper_bankswitch;
21322131
2133   leland_rotate_memory(machine(), "master");
2132   leland_rotate_memory("master");
21342133
21352134   /* set up the master CPU I/O ports */
2136   init_master_ports(machine(), 0x40, 0x80);
2135   init_master_ports(0x40, 0x80);
21372136}
21382137
21392138
21402139DRIVER_INIT_MEMBER(leland_state,viper)
21412140{
21422141   /* master CPU bankswitching */
2143   m_update_master_bank = viper_bankswitch;
2142   m_update_master_bank = &leland_state::viper_bankswitch;
21442143
2145   leland_rotate_memory(machine(), "master");
2146   leland_rotate_memory(machine(), "slave");
2147   leland_rotate_memory(machine(), "slave");
2144   leland_rotate_memory("master");
2145   leland_rotate_memory("slave");
2146   leland_rotate_memory("slave");
21482147
21492148   /* set up the master CPU I/O ports */
2150   init_master_ports(machine(), 0x00, 0xc0);
2149   init_master_ports(0x00, 0xc0);
21512150
21522151   /* set up additional input ports */
21532152   machine().device("master")->memory().space(AS_IO).install_read_handler(0xa4, 0xa4, read8_delegate(FUNC(leland_state::dangerz_input_upper_r),this));
r20832r20833
21592158DRIVER_INIT_MEMBER(leland_state,teamqb)
21602159{
21612160   /* master CPU bankswitching */
2162   m_update_master_bank = viper_bankswitch;
2161   m_update_master_bank = &leland_state::viper_bankswitch;
21632162
2164   leland_rotate_memory(machine(), "master");
2165   leland_rotate_memory(machine(), "slave");
2166   leland_rotate_memory(machine(), "slave");
2163   leland_rotate_memory("master");
2164   leland_rotate_memory("slave");
2165   leland_rotate_memory("slave");
21672166
21682167   /* set up the master CPU I/O ports */
2169   init_master_ports(machine(), 0x40, 0x80);
2168   init_master_ports(0x40, 0x80);
21702169
21712170   /* set up additional input ports */
21722171   machine().device("master")->memory().space(AS_IO).install_read_port(0x7c, 0x7c, "IN4");
r20832r20833
21772176DRIVER_INIT_MEMBER(leland_state,aafb)
21782177{
21792178   /* master CPU bankswitching */
2180   m_update_master_bank = viper_bankswitch;
2179   m_update_master_bank = &leland_state::viper_bankswitch;
21812180
2182   leland_rotate_memory(machine(), "master");
2183   leland_rotate_memory(machine(), "slave");
2184   leland_rotate_memory(machine(), "slave");
2181   leland_rotate_memory("master");
2182   leland_rotate_memory("slave");
2183   leland_rotate_memory("slave");
21852184
21862185   /* set up the master CPU I/O ports */
2187   init_master_ports(machine(), 0x00, 0xc0);
2186   init_master_ports(0x00, 0xc0);
21882187
21892188   /* set up additional input ports */
21902189   machine().device("master")->memory().space(AS_IO).install_read_port(0x7c, 0x7c, "IN4");
r20832r20833
21952194DRIVER_INIT_MEMBER(leland_state,aafbb)
21962195{
21972196   /* master CPU bankswitching */
2198   m_update_master_bank = viper_bankswitch;
2197   m_update_master_bank = &leland_state::viper_bankswitch;
21992198
2200   leland_rotate_memory(machine(), "master");
2201   leland_rotate_memory(machine(), "slave");
2202   leland_rotate_memory(machine(), "slave");
2199   leland_rotate_memory("master");
2200   leland_rotate_memory("slave");
2201   leland_rotate_memory("slave");
22032202
22042203   /* set up the master CPU I/O ports */
2205   init_master_ports(machine(), 0x80, 0x40);
2204   init_master_ports(0x80, 0x40);
22062205
22072206   /* set up additional input ports */
22082207   machine().device("master")->memory().space(AS_IO).install_read_port(0x7c, 0x7c, "IN4");
r20832r20833
22132212DRIVER_INIT_MEMBER(leland_state,aafbd2p)
22142213{
22152214   /* master CPU bankswitching */
2216   m_update_master_bank = viper_bankswitch;
2215   m_update_master_bank = &leland_state::viper_bankswitch;
22172216
2218   leland_rotate_memory(machine(), "master");
2219   leland_rotate_memory(machine(), "slave");
2220   leland_rotate_memory(machine(), "slave");
2217   leland_rotate_memory("master");
2218   leland_rotate_memory("slave");
2219   leland_rotate_memory("slave");
22212220
22222221   /* set up the master CPU I/O ports */
2223   init_master_ports(machine(), 0x00, 0x40);
2222   init_master_ports(0x00, 0x40);
22242223
22252224   /* set up additional input ports */
22262225   machine().device("master")->memory().space(AS_IO).install_read_port(0x7c, 0x7c, "IN4");
r20832r20833
22312230DRIVER_INIT_MEMBER(leland_state,offroad)
22322231{
22332232   /* master CPU bankswitching */
2234   m_update_master_bank = offroad_bankswitch;
2233   m_update_master_bank = &leland_state::offroad_bankswitch;
22352234
2236   leland_rotate_memory(machine(), "master");
2237   leland_rotate_memory(machine(), "slave");
2238   leland_rotate_memory(machine(), "slave");
2235   leland_rotate_memory("master");
2236   leland_rotate_memory("slave");
2237   leland_rotate_memory("slave");
22392238
22402239   /* set up the master CPU I/O ports */
2241   init_master_ports(machine(), 0x00, 0xc0);
2242   init_master_ports(machine(), 0x40, 0x80);   /* yes, this is intentional */
2240   init_master_ports(0x00, 0xc0);
2241   init_master_ports(0x40, 0x80);   /* yes, this is intentional */
22432242
22442243   /* set up additional input ports */
22452244   machine().device("master")->memory().space(AS_IO).install_read_handler(0xf8, 0xf8, read8_delegate(FUNC(leland_state::offroad_wheel_3_r),this));
r20832r20833
22512250DRIVER_INIT_MEMBER(leland_state,offroadt)
22522251{
22532252   /* master CPU bankswitching */
2254   m_update_master_bank = offroad_bankswitch;
2253   m_update_master_bank = &leland_state::offroad_bankswitch;
22552254
2256   leland_rotate_memory(machine(), "master");
2257   leland_rotate_memory(machine(), "slave");
2258   leland_rotate_memory(machine(), "slave");
2255   leland_rotate_memory("master");
2256   leland_rotate_memory("slave");
2257   leland_rotate_memory("slave");
22592258
22602259   /* set up the master CPU I/O ports */
2261   init_master_ports(machine(), 0x80, 0x40);
2260   init_master_ports(0x80, 0x40);
22622261
22632262   /* set up additional input ports */
22642263   machine().device("master")->memory().space(AS_IO).install_read_handler(0xf8, 0xf8, read8_delegate(FUNC(leland_state::offroad_wheel_3_r),this));
r20832r20833
22702269DRIVER_INIT_MEMBER(leland_state,pigout)
22712270{
22722271   /* master CPU bankswitching */
2273   m_update_master_bank = offroad_bankswitch;
2272   m_update_master_bank = &leland_state::offroad_bankswitch;
22742273
2275   leland_rotate_memory(machine(), "master");
2276   leland_rotate_memory(machine(), "slave");
2277   leland_rotate_memory(machine(), "slave");
2274   leland_rotate_memory("master");
2275   leland_rotate_memory("slave");
2276   leland_rotate_memory("slave");
22782277
22792278   /* set up the master CPU I/O ports */
2280   init_master_ports(machine(), 0x00, 0x40);
2279   init_master_ports(0x00, 0x40);
22812280
22822281   /* set up additional input ports */
22832282   machine().device("master")->memory().space(AS_IO).install_read_port(0x7f, 0x7f, "IN4");

Previous 199869 Revisions Next


© 1997-2024 The MAME Team