Previous 15994 Revisions Next

r6726 Thursday 24th December, 2009 at 00:11:48 UTC by Barry Rodewald
[FMTOWNS] Improved controller inputs. Still not perfect, though.
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r6725r6726
157157static UINT8 towns_kb_extend;  // extended key output
158158static emu_timer* towns_kb_timer;
159159static UINT8 towns_fm_irq_flag;
160static UINT8 towns_pad_mask;
160161
161162static struct towns_cdrom_controller
162163{
r6725r6726
726727   // TODO:
727728}
728729
730// Controller ports
731// Joysticks are multiplexed, with fire buttons available when bits 0 and 1 of port 0x4d6 are high. (bits 2 and 3 for second port?)
729732static READ32_HANDLER(towns_padport_r)
730733{
731   logerror("PADPORT: read mask %08x\n",mem_mask);
732   if(ACCESSING_BITS_0_7)
733      return input_port_read(space->machine,"joy1");;
734   UINT32 ret = 0;
735   UINT8 extra1 = input_port_read(space->machine,"joy1_ex");
736   UINT8 extra2 = input_port_read(space->machine,"joy2_ex");
734737
735   return 0x00;
738   if(towns_pad_mask & 0x10)
739      ret |= (input_port_read(space->machine,"joy1") & 0x3f) | 0x00000040;
740   else
741      ret |= 0x0000003f;
742
743   if(towns_pad_mask & 0x20)
744      ret |= ((input_port_read(space->machine,"joy2") & 0x3f) << 16) | 0x00400000;
745   else
746      ret |= 0x003f0000;
747   
748   if(extra1 & 0x01) // Run button = left+right
749      ret &= ~0x0000000c;
750   if(extra2 & 0x01)
751      ret &= ~0x000c0000;
752   if(extra1 & 0x02) // Select button = up+down
753      ret &= ~0x00000003;
754   if(extra2 & 0x02)
755      ret &= ~0x00030000;
756
757   if((extra1 & 0x10) && (towns_pad_mask & 0x01))
758      ret &= ~0x00000010;
759   if((extra1 & 0x20) && (towns_pad_mask & 0x02))
760      ret &= ~0x00000020;
761   if((extra2 & 0x10) && (towns_pad_mask & 0x04))
762      ret &= ~0x00100000;
763   if((extra2 & 0x20) && (towns_pad_mask & 0x08))
764      ret &= ~0x00200000;
765
766   return ret;
736767}
737768
769static WRITE32_HANDLER(towns_pad_mask_w)
770{
771   if(ACCESSING_BITS_16_23)
772      towns_pad_mask = (data & 0x00ff0000) >> 16;
773}
774
738775static READ8_HANDLER( towns_cmos8_r )
739776{
740777   return towns_cmos[offset];
r6725r6726
16731710  // Joystick / Mouse ports(?)
16741711  AM_RANGE(0x04d0,0x04d3) AM_READ(towns_padport_r)
16751712  // Sound (YM3438 [FM], RF5c68 [PCM])
1676  AM_RANGE(0x04d4,0x04d7) AM_NOP  // R/W  -- (0x4d5) mute?
1713  AM_RANGE(0x04d4,0x04d7) AM_WRITE(towns_pad_mask_w)
16771714  AM_RANGE(0x04d8,0x04df) AM_DEVREADWRITE8("fm",ym3438_r,ym3438_w,0x00ff00ff)
16781715  AM_RANGE(0x04e0,0x04e3) AM_NOP  // R/W  -- volume ports
16791716  AM_RANGE(0x04e8,0x04ef) AM_READWRITE8(towns_sound_ctrl_r,towns_sound_ctrl_w,0xffffffff)
r6725r6726
18381875    PORT_BIT(0x00000002,IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1)
18391876    PORT_BIT(0x00000004,IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1)
18401877    PORT_BIT(0x00000008,IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1)
1841    PORT_BIT(0x00000010,IP_ACTIVE_LOW, IPT_START) PORT_PLAYER(1)
1842    PORT_BIT(0x00000020,IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
1843    PORT_BIT(0x00000040,IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1)
1844    PORT_BIT(0x00000080,IP_ACTIVE_HIGH, IPT_UNUSED) PORT_PLAYER(1)
1878    PORT_BIT(0x00000010,IP_ACTIVE_LOW, IPT_UNUSED)
1879    PORT_BIT(0x00000020,IP_ACTIVE_LOW, IPT_UNUSED)
1880    PORT_BIT(0x00000040,IP_ACTIVE_HIGH, IPT_UNUSED)
1881    PORT_BIT(0x00000080,IP_ACTIVE_HIGH, IPT_UNUSED)
18451882
1883  PORT_START("joy1_ex")
1884    PORT_BIT(0x00000001,IP_ACTIVE_HIGH, IPT_START) PORT_NAME("1P Run") PORT_PLAYER(1)
1885    PORT_BIT(0x00000002,IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("1P Select") PORT_PLAYER(1)
1886    PORT_BIT(0x00000004,IP_ACTIVE_LOW, IPT_UNUSED)
1887    PORT_BIT(0x00000008,IP_ACTIVE_LOW, IPT_UNUSED)
1888    PORT_BIT(0x00000010,IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(1)
1889    PORT_BIT(0x00000020,IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(1)
1890    PORT_BIT(0x00000040,IP_ACTIVE_HIGH, IPT_UNUSED)
1891    PORT_BIT(0x00000080,IP_ACTIVE_HIGH, IPT_UNUSED)
1892
1893  PORT_START("joy2")
1894    PORT_BIT(0x00000001,IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(2)
1895    PORT_BIT(0x00000002,IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(2)
1896    PORT_BIT(0x00000004,IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(2)
1897    PORT_BIT(0x00000008,IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(2)
1898    PORT_BIT(0x00000010,IP_ACTIVE_LOW, IPT_UNUSED)
1899    PORT_BIT(0x00000020,IP_ACTIVE_LOW, IPT_UNUSED)
1900    PORT_BIT(0x00000040,IP_ACTIVE_HIGH, IPT_UNUSED)
1901    PORT_BIT(0x00000080,IP_ACTIVE_HIGH, IPT_UNUSED)
1902
1903  PORT_START("joy2_ex")
1904    PORT_BIT(0x00000001,IP_ACTIVE_HIGH, IPT_START) PORT_NAME("2P Run") PORT_PLAYER(2)
1905    PORT_BIT(0x00000002,IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("2P Select") PORT_PLAYER(2)
1906    PORT_BIT(0x00000004,IP_ACTIVE_LOW, IPT_UNUSED)
1907    PORT_BIT(0x00000008,IP_ACTIVE_LOW, IPT_UNUSED)
1908    PORT_BIT(0x00000010,IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(2)
1909    PORT_BIT(0x00000020,IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(2)
1910    PORT_BIT(0x00000040,IP_ACTIVE_HIGH, IPT_UNUSED)
1911    PORT_BIT(0x00000080,IP_ACTIVE_HIGH, IPT_UNUSED)
18461912INPUT_PORTS_END
18471913
18481914static TIMER_CALLBACK( towns_vblank_end )
r6725r6726
18941960   towns_update_video_banks(cpu_get_address_space(cputag_get_cpu(machine,"maincpu"),ADDRESS_SPACE_PROGRAM));
18951961   towns_kb_status = 0x18;
18961962   towns_kb_irq1_enable = 0;
1963   towns_pad_mask = 0x7f;
18971964   towns_cd.status = 0x01;  // CDROM controller ready
18981965   towns_cd.buffer_ptr = -1;
18991966   timer_adjust_periodic(towns_rtc_timer,attotime_zero,0,ATTOTIME_IN_HZ(1));

Previous 15994 Revisions Next


© 1998-2018 The MESS Team