Previous 199869 Revisions Next

r21876 Friday 15th March, 2013 at 14:44:00 UTC by Angelo Salese
Added mahjong panel support to Famicom
[src/mess/drivers]nes.c
[src/mess/includes]nes.h
[src/mess/machine]nes.c

trunk/src/mess/drivers/nes.c
r21875r21876
357357
358358INPUT_PORTS_END
359359
360static INPUT_PORTS_START( mahjong_panel )
361   PORT_START("MAH0")
362   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
363
364   PORT_START("MAH1")
365   PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED )
366   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_N ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
367   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_M ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
368   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_L ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
369   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_K ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
370   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_J ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
371   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_I ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
372
373   PORT_START("MAH2")
374   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_H ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
375   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
376   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_F ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
377   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_E ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
378   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_D ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
379   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_C ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
380   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_MAHJONG_B ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
381   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_MAHJONG_A ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
382
383   PORT_START("MAH3")
384   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
385   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_RON ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
386   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_REACH ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
387   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_CHI ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
388   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_PON ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
389   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_KAN ) PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
390   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P1 Mahjong Select") PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
391   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START ) PORT_NAME("P1 Mahjong Start") PORT_CONDITION("CTRLSEL", 0x00f0, EQUALS, 0x0070)
392INPUT_PORTS_END
393
360394static INPUT_PORTS_START( nes )
361395   PORT_INCLUDE( nes_controllers )
362396
r21875r21876
392426   PORT_INCLUDE( nes )
393427   PORT_INCLUDE( fc_keyboard )
394428   PORT_INCLUDE( subor_keyboard )
429   PORT_INCLUDE( mahjong_panel )
395430
396431   PORT_MODIFY("CTRLSEL")  /* Select Controller Type */
397432   PORT_CONFNAME( 0x000f, 0x0001, "P1 Controller")
r21875r21876
401436   PORT_CONFSETTING(  0x0006, "Crazy Climber pad" )
402437   PORT_CONFSETTING(  0x0008, "FC Keyboard" )
403438   PORT_CONFSETTING(  0x0009, "Subor Keyboard" )
439   PORT_CONFNAME( 0x00f0, 0x0010, "P2 Controller")
440   PORT_CONFSETTING(  0x0000, "Unconnected" )
441   PORT_CONFSETTING(  0x0010, "Gamepad" )
442   PORT_CONFSETTING(  0x0030, "Zapper" )
443   PORT_CONFSETTING(  0x0040, "Arkanoid paddle" )
444//  PORT_CONFSETTING(  0x0050, "Family Trainer" )
445   PORT_CONFSETTING(  0x0070, "Mahjong Panel" )
404446
405447   PORT_START("FLIPDISK") /* fake keys */
406448   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Change Disk Side")
trunk/src/mess/machine/nes.c
r21875r21876
7272         m_vrom = m_cartslot->m_cart->get_vrom_base();
7373      if (m_cartslot->m_cart->get_vram_size())
7474         m_vram = auto_alloc_array(machine(), UINT8, m_cartslot->m_cart->get_vram_size());
75     
75
7676      m_pcb_id = m_cartslot->get_pcb_id();
7777      m_hard_mirroring = m_cartslot->m_cart->get_mirroring();
7878      m_four_screen_vram = m_cartslot->m_cart->get_four_screen_vram();
79     
79
8080      // setup memory pointers and related variables
8181      m_prg_ram = m_cartslot->m_cart->get_battery_size() ? 1 : 0;
8282      m_wram_size = m_cartslot->m_cart->get_prgram_size();
r21875r21876
8484      m_mapper_bram_size = m_cartslot->m_cart->get_mapper_bram_size();
8585      m_battery = m_cartslot->m_cart->get_battery_size() ? 1 : 0;
8686      m_battery_size = m_cartslot->m_cart->get_battery_size();
87     
87
8888      if (m_prg_ram)
8989         m_wram = m_cartslot->m_cart->get_prgram_base();
9090      if (m_mapper_ram_size)
r21875r21876
9393         m_battery_ram = m_cartslot->m_cart->get_battery_base();
9494      if (m_mapper_bram_size)
9595         m_mapper_bram = m_cartslot->m_cart->get_mapper_bram_base();
96     
96
9797      // setup the rest of the variables involved
9898      m_chr_open_bus = m_cartslot->get_chr_open_bus();
9999      m_ce_mask = m_cartslot->get_ce_mask();
r21875r21876
136136   {
137137      /* Set up the mapper callbacks */
138138      pcb_handlers_setup();
139     
139
140140      /* Set up the memory handlers for the mapper */
141141      space.install_read_bank(0x8000, 0x9fff, "bank1");
142142      space.install_read_bank(0xa000, 0xbfff, "bank2");
143143      space.install_read_bank(0xc000, 0xdfff, "bank3");
144144      space.install_read_bank(0xe000, 0xffff, "bank4");
145145      space.install_readwrite_bank(0x6000, 0x7fff, "bank5");
146     
146
147147      /* configure banks 1-4 */
148148      for (i = 0; i < 4; i++)
149149      {
r21875r21876
155155         membank(bank_names[i])->set_entry(i);
156156         m_prg_bank[i] = i;
157157      }
158     
158
159159      /* bank 5 configuration is more delicate, since it can have PRG RAM, PRG ROM or SRAM mapped to it */
160160      /* we first map PRG ROM banks, then the battery bank (if a battery is present), and finally PRG RAM (m_wram) */
161161      membank("bank5")->configure_entries(0, prg_banks, m_prg, 0x2000);
162162      m_battery_bank5_start = prg_banks;
163163      m_prgram_bank5_start = prg_banks;
164164      m_empty_bank5_start = prg_banks;
165     
165
166166      /* add battery ram, but only if there's no trainer since they share overlapping memory. */
167167      if (m_battery && !m_trainer)
168168      {
r21875r21876
178178         membank("bank5")->configure_entries(m_prgram_bank5_start, m_wram_size / 0x2000, m_wram, 0x2000);
179179         m_empty_bank5_start += m_wram_size / 0x2000;
180180      }
181     
181
182182      membank("bank5")->configure_entry(m_empty_bank5_start, m_rom + 0x6000);
183     
183
184184      /* if we have any additional PRG RAM, point bank5 to its first bank */
185185      if (m_battery || m_prg_ram)
186186         m_prg_bank[4] = m_battery_bank5_start;
187187      else
188188         m_prg_bank[4] = m_empty_bank5_start; // or shall we point to "maincpu" region at 0x6000? point is that we should never access this region if no sram or wram is present!
189     
189
190190      membank("bank5")->set_entry(m_prg_bank[4]);
191     
191
192192      if (m_four_screen_vram)
193193      {
194194         m_extended_ntram = auto_alloc_array_clear(machine(), UINT8, 0x2000);
195195         save_pointer(NAME(m_extended_ntram), 0x2000);
196196      }
197     
197
198198      if (m_four_screen_vram)
199199         set_nt_mirroring(PPU_MIRROR_4SCREEN);
200200      else
r21875r21876
393393   m_io_zapper2_x      = ioport("ZAPPER2_X");
394394   m_io_zapper2_y      = ioport("ZAPPER2_Y");
395395   m_io_paddle         = ioport("PADDLE");
396   m_io_mahjong[0]     = ioport("MAH0");
397   m_io_mahjong[1]     = ioport("MAH1");
398   m_io_mahjong[2]     = ioport("MAH2");
399   m_io_mahjong[3]     = ioport("MAH3");
396400   m_prg_bank_mem[0]   = membank("bank1");
397401   m_prg_bank_mem[1]   = membank("bank2");
398402   m_prg_bank_mem[2]   = membank("bank3");
r21875r21876
515519      ret = 0x40;
516520
517521      /* Handle data line 0's serial output */
518      ret |= ((m_in_1.i0 >> m_in_1.shift) & 0x01);
522      if((cfg & 0x00f0) == 0x0070)
523         ret |= (((m_in_1.i0 >> m_in_1.shift) & 0x01) << 1);
524      else
525         ret |= ((m_in_1.i0 >> m_in_1.shift) & 0x01);
519526
520527      /* zapper */
521528      if ((cfg & 0x00f0) == 0x0030)
r21875r21876
567574
568575// FIXME: this is getting messier and messier (no pun intended). inputs reading should be simplified and port_categories cleaned up
569576// to also emulate the fact that nothing should be in Port 2 if there is a Crazy Climber pad, etc.
570static void nes_read_input_device( running_machine &machine, int cfg, nes_input *vals, int pad_port, int supports_zapper )
577static void nes_read_input_device( running_machine &machine, int cfg, nes_input *vals, int pad_port, int supports_zapper, int mux_data )
571578{
572579   nes_state *state = machine.driver_data<nes_state>();
573580
r21875r21876
612619            state->m_in_1.i0 = state->m_io_cc_right->read();
613620         }
614621         break;
622
623      case 0x07: /* Mahjong Panel */
624         if(mux_data & 0xf8)
625            logerror("Error: Mahjong panel read with mux data %02x\n",mux_data);
626         else
627            vals->i0 = state->m_io_mahjong[mux_data >> 1]->read();
628         break;
615629   }
616630}
617631
r21875r21876
681695      /* Read the input devices */
682696      if ((cfg & 0x000f) != 0x06)
683697      {
684         nes_read_input_device(machine(), cfg >>  0, &m_in_0, 0,  TRUE);
685         nes_read_input_device(machine(), cfg >>  4, &m_in_1, 1,  TRUE);
686         nes_read_input_device(machine(), cfg >>  8, &m_in_2, 2, FALSE);
687         nes_read_input_device(machine(), cfg >> 12, &m_in_3, 3, FALSE);
698         nes_read_input_device(machine(), cfg >>  0, &m_in_0, 0,  TRUE,data & 0xfe);
699         nes_read_input_device(machine(), cfg >>  4, &m_in_1, 1,  TRUE,data & 0xfe);
700         nes_read_input_device(machine(), cfg >>  8, &m_in_2, 2, FALSE,data & 0xfe);
701         nes_read_input_device(machine(), cfg >> 12, &m_in_3, 3, FALSE,data & 0xfe);
688702      }
689703      else // crazy climber pad
690704      {
691         nes_read_input_device(machine(), 0, &m_in_1, 1,  TRUE);
692         nes_read_input_device(machine(), 0, &m_in_2, 2, FALSE);
693         nes_read_input_device(machine(), 0, &m_in_3, 3, FALSE);
694         nes_read_input_device(machine(), cfg >>  0, &m_in_0, 0,  TRUE);
705         nes_read_input_device(machine(), 0, &m_in_1, 1,  TRUE,data & 0xfe);
706         nes_read_input_device(machine(), 0, &m_in_2, 2, FALSE,data & 0xfe);
707         nes_read_input_device(machine(), 0, &m_in_3, 3, FALSE,data & 0xfe);
708         nes_read_input_device(machine(), cfg >>  0, &m_in_0, 0,  TRUE,data & 0xfe);
695709      }
696710
697711      if (cfg & 0x0f00)
trunk/src/mess/includes/nes.h
r21875r21876
133133   ioport_port       *m_io_fckey[9];
134134   ioport_port       *m_io_subkey[13];
135135   ioport_port       *m_io_pad[4];
136   ioport_port       *m_io_mahjong[4];
136137   ioport_port       *m_io_cc_left;
137138   ioport_port       *m_io_cc_right;
138139   ioport_port       *m_io_zapper1_t;
r21875r21876
154155   memory_bank       *m_prg_bank_mem[5];
155156};
156157
157   
158
158159/*----------- defined in machine/nes.c -----------*/
159160
160161

Previous 199869 Revisions Next


© 1997-2024 The MAME Team