src/mess/drivers/fmtowns.c
| r6725 | r6726 | |
| 157 | 157 | static UINT8 towns_kb_extend; // extended key output |
| 158 | 158 | static emu_timer* towns_kb_timer; |
| 159 | 159 | static UINT8 towns_fm_irq_flag; |
| 160 | static UINT8 towns_pad_mask; |
| 160 | 161 | |
| 161 | 162 | static struct towns_cdrom_controller |
| 162 | 163 | { |
| r6725 | r6726 | |
| 726 | 727 | // TODO: |
| 727 | 728 | } |
| 728 | 729 | |
| 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?) |
| 729 | 732 | static READ32_HANDLER(towns_padport_r) |
| 730 | 733 | { |
| 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"); |
| 734 | 737 | |
| 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; |
| 736 | 767 | } |
| 737 | 768 | |
| 769 | static WRITE32_HANDLER(towns_pad_mask_w) |
| 770 | { |
| 771 | if(ACCESSING_BITS_16_23) |
| 772 | towns_pad_mask = (data & 0x00ff0000) >> 16; |
| 773 | } |
| 774 | |
| 738 | 775 | static READ8_HANDLER( towns_cmos8_r ) |
| 739 | 776 | { |
| 740 | 777 | return towns_cmos[offset]; |
| r6725 | r6726 | |
| 1673 | 1710 | // Joystick / Mouse ports(?) |
| 1674 | 1711 | AM_RANGE(0x04d0,0x04d3) AM_READ(towns_padport_r) |
| 1675 | 1712 | // 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) |
| 1677 | 1714 | AM_RANGE(0x04d8,0x04df) AM_DEVREADWRITE8("fm",ym3438_r,ym3438_w,0x00ff00ff) |
| 1678 | 1715 | AM_RANGE(0x04e0,0x04e3) AM_NOP // R/W -- volume ports |
| 1679 | 1716 | AM_RANGE(0x04e8,0x04ef) AM_READWRITE8(towns_sound_ctrl_r,towns_sound_ctrl_w,0xffffffff) |
| r6725 | r6726 | |
| 1838 | 1875 | PORT_BIT(0x00000002,IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1) |
| 1839 | 1876 | PORT_BIT(0x00000004,IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1) |
| 1840 | 1877 | 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) |
| 1845 | 1882 | |
| 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) |
| 1846 | 1912 | INPUT_PORTS_END |
| 1847 | 1913 | |
| 1848 | 1914 | static TIMER_CALLBACK( towns_vblank_end ) |
| r6725 | r6726 | |
| 1894 | 1960 | towns_update_video_banks(cpu_get_address_space(cputag_get_cpu(machine,"maincpu"),ADDRESS_SPACE_PROGRAM)); |
| 1895 | 1961 | towns_kb_status = 0x18; |
| 1896 | 1962 | towns_kb_irq1_enable = 0; |
| 1963 | towns_pad_mask = 0x7f; |
| 1897 | 1964 | towns_cd.status = 0x01; // CDROM controller ready |
| 1898 | 1965 | towns_cd.buffer_ptr = -1; |
| 1899 | 1966 | timer_adjust_periodic(towns_rtc_timer,attotime_zero,0,ATTOTIME_IN_HZ(1)); |