src/mess/drivers/fmtowns.c
| r7800 | r7801 | |
| 1 | 1 | /* |
| 2 | 2 | |
| 3 | 3 | Fujitsu FM-Towns |
| 4 | driver by Barry Rodewald |
| 4 | 5 | |
| 5 | 6 | Japanese computer system released in 1989. |
| 6 | 7 | |
| 7 | 8 | CPU: AMD 80386SX(DX?) (80387 available as add-on?) |
| 8 | 9 | Sound: Yamaha YM3438 |
| 9 | 10 | Ricoh RF5c68 |
| 10 | | Video: VGA + some custom extra video hardware |
| 11 | | 320x200 - 640x480 |
| 12 | | 16 - 32768 colours from a possible palette of between 4096 and |
| 13 | | 16.7m colours (depending on video mode) |
| 14 | | 1024 sprites (16x16) |
| 11 | Video: Custom |
| 12 | 16 or 256 colours from a 24-bit palette, or 15-bit high-colour |
| 13 | 1024 sprites (16x16), rendered direct to VRAM |
| 14 | 16 colour text mode, rendered direct to VRAM |
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | Fujitsu FM-Towns Marty |
| r7800 | r7801 | |
| 19 | 19 | Japanese console, based on the FM-Towns computer, using an AMD 80386SX CPU, |
| 20 | 20 | released in 1993 |
| 21 | 21 | |
| 22 | |
| 22 | 23 | Issues: i386 protected mode is far from complete. |
| 23 | 24 | Video emulation is far from complete. |
| 24 | 25 | |
| r7800 | r7801 | |
| 42 | 43 | * 0x0042 : 8253 PIT counter 1 |
| 43 | 44 | * 0x0044 : 8253 PIT counter 2 |
| 44 | 45 | * 0x0046 : 8253 PIT mode port |
| 45 | | * 0x0060 : 8253 PIT ??? |
| 46 | * 0x0060 : 8253 PIT timer control |
| 46 | 47 | * 0x006c RW: returns 0x00? (read) timer? (write) |
| 47 | 48 | * 0x00a0-af: DMA controller 1 (uPD71071) |
| 48 | 49 | * 0x00b0-bf: DMA controller 2 (uPD71071) |
| r7800 | r7801 | |
| 80 | 81 | * IRQ9 - Built-in CD-ROM controller |
| 81 | 82 | * IRQ11 - VSync interrupt |
| 82 | 83 | * IRQ12 - Printer port |
| 83 | | * IRQ13 - Sound (FM?), Mouse |
| 84 | | * IRQ15 - PCM |
| 84 | * IRQ13 - Sound (YM3438/RF5c68), Mouse |
| 85 | * IRQ15 - 16-bit PCM (expansion?) |
| 85 | 86 | * |
| 86 | 87 | * Machine ID list (I/O port 0x31) |
| 87 | 88 | * |
| r7800 | r7801 | |
| 645 | 646 | * Port 0x60 - PIT Timer control |
| 646 | 647 | * On read: bit 0: Timer 0 output level |
| 647 | 648 | * bit 1: Timer 1 output level |
| 648 | | * bits 4-2: Timer masks (timer 2 = sound) |
| 649 | * bits 4-2: Timer masks (timer 2 = beeper) |
| 649 | 650 | * On write: bits 2-0: Timer mask set |
| 650 | 651 | * bit 7: Timer 0 output reset |
| 651 | 652 | */ |
| r7800 | r7801 | |
| 840 | 841 | ret |= 0x0000000f; |
| 841 | 842 | } |
| 842 | 843 | |
| 843 | | //logerror("Mouse: X=%02x Y=%02x state=%i\n",towns_mouse_x,towns_mouse_y,towns_mouse_output); |
| 844 | 844 | // button states are always visible |
| 845 | 845 | state = input_port_read(space->machine,"mouse1"); |
| 846 | 846 | if(!(state & 0x01)) |
| r7800 | r7801 | |
| 850 | 850 | if(towns_pad_mask & 0x10) |
| 851 | 851 | ret |= 0x00000040; |
| 852 | 852 | } |
| 853 | if((porttype & 0xf0) == 0x20) // mouse |
| 854 | { |
| 855 | switch(towns_mouse_output) |
| 856 | { |
| 857 | case MOUSE_X_HIGH: |
| 858 | ret |= ((towns_mouse_x & 0xf0) << 12); |
| 859 | break; |
| 860 | case MOUSE_X_LOW: |
| 861 | ret |= ((towns_mouse_x & 0x0f) << 16); |
| 862 | break; |
| 863 | case MOUSE_Y_HIGH: |
| 864 | ret |= ((towns_mouse_y & 0xf0) << 12); |
| 865 | break; |
| 866 | case MOUSE_Y_LOW: |
| 867 | ret |= ((towns_mouse_y & 0x0f) << 16); |
| 868 | break; |
| 869 | case MOUSE_START: |
| 870 | case MOUSE_SYNC: |
| 871 | default: |
| 872 | if(towns_mouse_output < MOUSE_Y_LOW) |
| 873 | ret |= 0x000f0000; |
| 874 | } |
| 875 | |
| 876 | // button states are always visible |
| 877 | state = input_port_read(space->machine,"mouse1"); |
| 878 | if(!(state & 0x01)) |
| 879 | ret |= 0x00100000; |
| 880 | if(!(state & 0x02)) |
| 881 | ret |= 0x00200000; |
| 882 | if(towns_pad_mask & 0x20) |
| 883 | ret |= 0x00400000; |
| 884 | } |
| 853 | 885 | |
| 854 | 886 | return ret; |
| 855 | 887 | } |
| r7800 | r7801 | |
| 859 | 891 | static UINT8 prev; |
| 860 | 892 | static UINT8 prev_x,prev_y; |
| 861 | 893 | UINT8 current_x,current_y; |
| 894 | UINT32 type = input_port_read(space->machine,"ctrltype"); |
| 862 | 895 | |
| 863 | 896 | if(ACCESSING_BITS_16_23) |
| 864 | 897 | { |
| 865 | 898 | towns_pad_mask = (data & 0x00ff0000) >> 16; |
| 866 | | if((input_port_read(space->machine,"ctrltype") & 0x0f) == 0x02) // mouse |
| 899 | if((type & 0x0f) == 0x02) // mouse |
| 867 | 900 | { |
| 868 | 901 | if((towns_pad_mask & 0x10) != 0 && (prev & 0x10) == 0) |
| 869 | 902 | { |
| r7800 | r7801 | |
| 899 | 932 | } |
| 900 | 933 | prev = towns_pad_mask; |
| 901 | 934 | } |
| 935 | if((type & 0xf0) == 0x20) // mouse |
| 936 | { |
| 937 | if((towns_pad_mask & 0x20) != 0 && (prev & 0x20) == 0) |
| 938 | { |
| 939 | if(towns_mouse_output == MOUSE_START) |
| 940 | { |
| 941 | towns_mouse_output = MOUSE_X_HIGH; |
| 942 | current_x = input_port_read(space->machine,"mouse2"); |
| 943 | current_y = input_port_read(space->machine,"mouse3"); |
| 944 | towns_mouse_x = prev_x - current_x; |
| 945 | towns_mouse_y = prev_y - current_y; |
| 946 | prev_x = current_x; |
| 947 | prev_y = current_y; |
| 948 | } |
| 949 | else |
| 950 | towns_mouse_output++; |
| 951 | timer_adjust_periodic(towns_mouse_timer,ATTOTIME_IN_USEC(600),0,attotime_zero); |
| 952 | } |
| 953 | if((towns_pad_mask & 0x20) == 0 && (prev & 0x20) != 0) |
| 954 | { |
| 955 | if(towns_mouse_output == MOUSE_START) |
| 956 | { |
| 957 | towns_mouse_output = MOUSE_SYNC; |
| 958 | current_x = input_port_read(space->machine,"mouse2"); |
| 959 | current_y = input_port_read(space->machine,"mouse3"); |
| 960 | towns_mouse_x = prev_x - current_x; |
| 961 | towns_mouse_y = prev_y - current_y; |
| 962 | prev_x = current_x; |
| 963 | prev_y = current_y; |
| 964 | } |
| 965 | else |
| 966 | towns_mouse_output++; |
| 967 | timer_adjust_periodic(towns_mouse_timer,ATTOTIME_IN_USEC(600),0,attotime_zero); |
| 968 | } |
| 969 | prev = towns_pad_mask; |
| 970 | } |
| 902 | 971 | } |
| 903 | 972 | } |
| 904 | 973 | |
| r7800 | r7801 | |
| 1830 | 1899 | PORT_CATEGORY_ITEM(0x00,"Nothing",10) |
| 1831 | 1900 | PORT_CATEGORY_ITEM(0x01,"Standard 2-button joystick",11) |
| 1832 | 1901 | PORT_CATEGORY_ITEM(0x02,"Mouse",12) |
| 1833 | | PORT_CATEGORY_CLASS(0xf0,0x10,"Joystick port 2") |
| 1902 | PORT_CATEGORY_CLASS(0xf0,0x20,"Joystick port 2") |
| 1834 | 1903 | PORT_CATEGORY_ITEM(0x00,"Nothing",20) |
| 1835 | 1904 | PORT_CATEGORY_ITEM(0x10,"Standard 2-button joystick",21) |
| 1905 | PORT_CATEGORY_ITEM(0x20,"Mouse",22) |
| 1836 | 1906 | |
| 1837 | 1907 | // Keyboard |
| 1838 | 1908 | PORT_START( "key1" ) // scancodes 0x00-0x1f |
| r7800 | r7801 | |
| 2010 | 2080 | PORT_BIT(0x00000080,IP_ACTIVE_HIGH, IPT_UNUSED) PORT_CATEGORY(21) |
| 2011 | 2081 | |
| 2012 | 2082 | PORT_START("mouse1") // buttons |
| 2013 | | PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Left mouse button") PORT_CODE(MOUSECODE_BUTTON1) PORT_CATEGORY(12) |
| 2014 | | PORT_BIT( 0x00000002, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Right mouse button") PORT_CODE(MOUSECODE_BUTTON2) PORT_CATEGORY(12) |
| 2083 | PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Left mouse button") PORT_CODE(MOUSECODE_BUTTON1) |
| 2084 | PORT_BIT( 0x00000002, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Right mouse button") PORT_CODE(MOUSECODE_BUTTON2) |
| 2015 | 2085 | |
| 2016 | 2086 | PORT_START("mouse2") // X-axis |
| 2017 | | PORT_BIT( 0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CATEGORY(12) |
| 2087 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 2018 | 2088 | |
| 2019 | 2089 | PORT_START("mouse3") // Y-axis |
| 2020 | | PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CATEGORY(12) |
| 2090 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 2021 | 2091 | |
| 2022 | 2092 | INPUT_PORTS_END |
| 2023 | 2093 | |