Previous 199869 Revisions Next

r20490 Saturday 26th January, 2013 at 14:44:59 UTC by Fabio Priuli
(MESS) nes.c: tagmap cleanups. (nw)

and I know that setting up ports in machine_start is not the approved way, but in this way the changes do not interfere
with my other local changes. I will move them later in the proper place, but this should be enough to kill tagmap lookups.
[src/mess/includes]nes.h
[src/mess/machine]nes.c

trunk/src/mess/machine/nes.c
r20489r20490
304304   m_sound             = machine().device("nessound");
305305   m_cart              = machine().device("cart");
306306   m_io_ctrlsel        = ioport("CTRLSEL");
307   m_io_fckey[0]       = ioport("FCKEY0");
308   m_io_fckey[1]       = ioport("FCKEY1");
309   m_io_fckey[2]       = ioport("FCKEY2");
310   m_io_fckey[3]       = ioport("FCKEY3");
311   m_io_fckey[4]       = ioport("FCKEY4");
312   m_io_fckey[5]       = ioport("FCKEY5");
313   m_io_fckey[6]       = ioport("FCKEY6");
314   m_io_fckey[7]       = ioport("FCKEY7");
315   m_io_fckey[8]       = ioport("FCKEY8");
316   m_io_subkey[0 ]     = ioport("SUBKEY0");
317   m_io_subkey[1 ]     = ioport("SUBKEY1");
318   m_io_subkey[2 ]     = ioport("SUBKEY2");
319   m_io_subkey[3 ]     = ioport("SUBKEY3");
320   m_io_subkey[4 ]     = ioport("SUBKEY4");
321   m_io_subkey[5 ]     = ioport("SUBKEY5");
322   m_io_subkey[6 ]     = ioport("SUBKEY6");
323   m_io_subkey[7 ]     = ioport("SUBKEY7");
324   m_io_subkey[8 ]     = ioport("SUBKEY8");
325   m_io_subkey[9 ]     = ioport("SUBKEY9");
326   m_io_subkey[10]     = ioport("SUBKEY10");
327   m_io_subkey[11]     = ioport("SUBKEY11");
328   m_io_subkey[12]     = ioport("SUBKEY12");
329   m_io_pad[0]         = ioport("PAD1");
330   m_io_pad[1]         = ioport("PAD2");
331   m_io_pad[2]         = ioport("PAD3");
332   m_io_pad[3]         = ioport("PAD4");
333   m_io_cc_left        = ioport("CC_LEFT");
334   m_io_cc_right       = ioport("CC_RIGHT");
335   m_io_zapper1_t      = ioport("ZAPPER1_T");
336   m_io_zapper1_x      = ioport("ZAPPER1_X");
337   m_io_zapper1_y      = ioport("ZAPPER1_Y");
338   m_io_zapper2_t      = ioport("ZAPPER2_T");
339   m_io_zapper2_x      = ioport("ZAPPER2_X");
340   m_io_zapper2_y      = ioport("ZAPPER2_Y");
341   m_io_paddle         = ioport("PADDLE");
307342   m_prg_bank_mem[0]   = membank("bank1");
308343   m_prg_bank_mem[1]   = membank("bank2");
309344   m_prg_bank_mem[2]   = membank("bank3");
r20489r20490
416451   return ret;
417452}
418453
419// row of the keyboard matrix are read 4-bits at time, and gets returned as bit1->bit4
420static UINT8 nes_read_fc_keyboard_line( running_machine &machine, UINT8 scan, UINT8 mode )
421{
422   static const char *const fc_keyport_names[] = { "FCKEY0", "FCKEY1", "FCKEY2", "FCKEY3", "FCKEY4", "FCKEY5", "FCKEY6", "FCKEY7", "FCKEY8" };
423   nes_state *state = machine.driver_data<nes_state>();
424   return ((state->ioport(fc_keyport_names[scan])->read() >> (mode * 4)) & 0x0f) << 1;
425}
426
427static UINT8 nes_read_subor_keyboard_line( running_machine &machine, UINT8 scan, UINT8 mode )
428{
429   static const char *const sub_keyport_names[] = { "SUBKEY0", "SUBKEY1", "SUBKEY2", "SUBKEY3", "SUBKEY4",
430      "SUBKEY5", "SUBKEY6", "SUBKEY7", "SUBKEY8", "SUBKEY9", "SUBKEY10", "SUBKEY11", "SUBKEY12" };
431   nes_state *state = machine.driver_data<nes_state>();
432   return ((state->ioport(sub_keyport_names[scan])->read() >> (mode * 4)) & 0x0f) << 1;
433}
434
435454READ8_MEMBER(nes_state::nes_IN1_r)
436455{
437456   int cfg = m_io_ctrlsel->read();
438457   int ret;
439458
459   // row of the keyboard matrix are read 4-bits at time, and gets returned as bit1->bit4
440460   if ((cfg & 0x000f) == 0x08) // for now we treat the FC keyboard separately from other inputs!
441461   {
442462      if (m_fck_scan < 9)
443         ret = ~nes_read_fc_keyboard_line(machine(), m_fck_scan, m_fck_mode) & 0x1e;
463         ret = ~(((m_io_fckey[m_fck_scan]->read() >> (m_fck_mode * 4)) & 0x0f) << 1) & 0x1e;
444464      else
445465         ret = 0x1e;
446466   }
447467   else if ((cfg & 0x000f) == 0x09)    // for now we treat the Subor keyboard separately from other inputs!
448468   {
449469      if (m_fck_scan < 12)
450         ret = ~nes_read_subor_keyboard_line(machine(), m_fck_scan, m_fck_mode) & 0x1e;
470         ret = ~(((m_io_subkey[m_fck_scan]->read() >> (m_fck_mode * 4)) & 0x0f) << 1) & 0x1e;
451471      else
452472         ret = 0x1e;
453473   }
r20489r20490
513533static void nes_read_input_device( running_machine &machine, int cfg, nes_input *vals, int pad_port, int supports_zapper )
514534{
515535   nes_state *state = machine.driver_data<nes_state>();
516   static const char *const padnames[] = { "PAD1", "PAD2", "PAD3", "PAD4", "CC_LEFT", "CC_RIGHT" };
517536
518537   vals->i0 = 0;
519538   vals->i1 = 0;
r20489r20490
523542   {
524543      case 0x01:  /* gamepad */
525544         if (pad_port >= 0)
526            vals->i0 = machine.root_device().ioport(padnames[pad_port])->read();
545            vals->i0 = state->m_io_pad[pad_port]->read();
527546         break;
528547
529548      case 0x02:  /* zapper 1 */
530549         if (supports_zapper)
531550         {
532            vals->i0 = machine.root_device().ioport("ZAPPER1_T")->read();
533            vals->i1 = machine.root_device().ioport("ZAPPER1_X")->read();
534            vals->i2 = machine.root_device().ioport("ZAPPER1_Y")->read();
551            vals->i0 = state->m_io_zapper1_t->read();
552            vals->i1 = state->m_io_zapper1_x->read();
553            vals->i2 = state->m_io_zapper1_y->read();
535554         }
536555         break;
537556
538557      case 0x03:  /* zapper 2 */
539558         if (supports_zapper)
540559         {
541            vals->i0 = machine.root_device().ioport("ZAPPER2_T")->read();
542            vals->i1 = machine.root_device().ioport("ZAPPER2_X")->read();
543            vals->i2 = machine.root_device().ioport("ZAPPER2_Y")->read();
560            vals->i0 = state->m_io_zapper2_t->read();
561            vals->i1 = state->m_io_zapper2_x->read();
562            vals->i2 = state->m_io_zapper2_y->read();
544563         }
545564         break;
546565
547566      case 0x04:  /* arkanoid paddle */
548567         if (pad_port == 1)
549            vals->i0 = (UINT8) ((UINT8) machine.root_device().ioport("PADDLE")->read() + (UINT8)0x52) ^ 0xff;
568            vals->i0 = (UINT8) ((UINT8) state->m_io_paddle->read() + (UINT8)0x52) ^ 0xff;
550569         break;
551570
552571      case 0x06:  /* crazy climber controller */
553572         if (pad_port == 0)
554573         {
555            state->m_in_0.i0 = machine.root_device().ioport(padnames[4])->read();
556            state->m_in_1.i0 = machine.root_device().ioport(padnames[5])->read();
574            state->m_in_0.i0 = state->m_io_cc_left->read();
575            state->m_in_1.i0 = state->m_io_cc_right->read();
557576         }
558577         break;
559578   }
trunk/src/mess/includes/nes.h
r20489r20490
125125   DECLARE_WRITE8_MEMBER(psg_4015_w);
126126   DECLARE_WRITE8_MEMBER(psg_4017_w);
127127
128   ioport_port       *m_io_ctrlsel;
129   ioport_port       *m_io_fckey[9];
130   ioport_port       *m_io_subkey[13];
131   ioport_port       *m_io_pad[4];
132   ioport_port       *m_io_cc_left;
133   ioport_port       *m_io_cc_right;
134   ioport_port       *m_io_zapper1_t;
135   ioport_port       *m_io_zapper1_x;
136   ioport_port       *m_io_zapper1_y;
137   ioport_port       *m_io_zapper2_t;
138   ioport_port       *m_io_zapper2_x;
139   ioport_port       *m_io_zapper2_y;
140   ioport_port       *m_io_paddle;
141   
128142private:
129143   /* devices */
130144//  cpu_device        *m_maincpu;
r20489r20490
132146//  device_t          *m_sound;
133147   device_t          *m_cart;
134148//  emu_timer         *m_irq_timer;
135   ioport_port       *m_io_ctrlsel;
136149   memory_bank       *m_prg_bank_mem[5];
137150};
138151

Previous 199869 Revisions Next


© 1997-2024 The MAME Team