src/mess/machine/sms.c
| r776 | r777 | |
| 42 | 42 | UINT32 last_paddle_read_time; |
| 43 | 43 | UINT8 paddle_read_state; |
| 44 | 44 | |
| 45 | /* Data needed for Sports Pad controller */ |
| 46 | UINT32 last_sports_pad_time_1; |
| 47 | UINT32 last_sports_pad_time_2; |
| 48 | UINT8 sports_pad_state_1; |
| 49 | UINT8 sports_pad_state_2; |
| 50 | UINT8 sports_pad_last_data_1; |
| 51 | UINT8 sports_pad_last_data_2; |
| 52 | UINT8 sports_pad_1_x; |
| 53 | UINT8 sports_pad_1_y; |
| 54 | UINT8 sports_pad_2_x; |
| 55 | UINT8 sports_pad_2_y; |
| 56 | |
| 45 | 57 | struct { |
| 46 | 58 | UINT8 *ROM; /* Pointer to ROM image data */ |
| 47 | 59 | UINT32 size; /* Size of the ROM image */ |
| r776 | r777 | |
| 59 | 71 | rapid_fire_state_2 ^= 0xFF; |
| 60 | 72 | } |
| 61 | 73 | |
| 74 | static WRITE8_HANDLER( sms_input_write ) { |
| 75 | switch( offset ) { |
| 76 | case 0: |
| 77 | switch( readinputport(11) & 0x0F ) { |
| 78 | case 0x03: /* Sports Pad */ |
| 79 | if ( data != sports_pad_last_data_1 ) { |
| 80 | UINT32 cpu_cycles = activecpu_gettotalcycles(); |
| 81 | |
| 82 | sports_pad_last_data_1 = data; |
| 83 | if ( cpu_cycles - last_sports_pad_time_1 > 512 ) { |
| 84 | sports_pad_state_1 = 3; |
| 85 | sports_pad_1_x = readinputport(12); |
| 86 | sports_pad_1_y = readinputport(13); |
| 87 | } |
| 88 | last_sports_pad_time_1 = cpu_cycles; |
| 89 | sports_pad_state_1 = ( sports_pad_state_1 + 1 ) & 3; |
| 90 | } |
| 91 | break; |
| 92 | } |
| 93 | break; |
| 94 | case 1: |
| 95 | switch( readinputport(11) >> 4 ) { |
| 96 | case 0x03: /* Sports Pad */ |
| 97 | if ( data != sports_pad_last_data_2 ) { |
| 98 | UINT32 cpu_cycles = activecpu_gettotalcycles(); |
| 99 | |
| 100 | sports_pad_last_data_2 = data; |
| 101 | if ( cpu_cycles - last_sports_pad_time_2 > 2048 ) { |
| 102 | sports_pad_state_2 = 3; |
| 103 | sports_pad_2_x = readinputport(14); |
| 104 | sports_pad_2_y = readinputport(15); |
| 105 | } |
| 106 | last_sports_pad_time_2 = cpu_cycles; |
| 107 | sports_pad_state_2 = ( sports_pad_state_2 + 1 ) & 3; |
| 108 | } |
| 109 | break; |
| 110 | } |
| 111 | break; |
| 112 | } |
| 113 | } |
| 114 | |
| 62 | 115 | static void sms_get_inputs(void) { |
| 63 | 116 | UINT8 data; |
| 64 | 117 | UINT32 cpu_cycles = activecpu_gettotalcycles(); |
| r776 | r777 | |
| 96 | 149 | sms_input_port0 = ( sms_input_port0 & 0xC0 ) | ( data & 0x0F ) | ( paddle_read_state & 0x20 ) |
| 97 | 150 | | ( ( readinputport(10) & 0x02 ) << 3 ); |
| 98 | 151 | break; |
| 152 | case 0x03: /* Sega Sports Pad */ |
| 153 | switch( sports_pad_state_1 ) { |
| 154 | case 0: |
| 155 | data = ( sports_pad_1_x >> 4 ) & 0x0F; |
| 156 | break; |
| 157 | case 1: |
| 158 | data = sports_pad_1_x & 0x0F; |
| 159 | break; |
| 160 | case 2: |
| 161 | data = ( sports_pad_1_y >> 4 ) & 0x0F; |
| 162 | break; |
| 163 | case 3: |
| 164 | data = sports_pad_1_y & 0x0F; |
| 165 | break; |
| 166 | } |
| 167 | sms_input_port0 = ( sms_input_port0 & 0xC0 ) | data | ( ( readinputport(10) & 0x0C ) << 2 ); |
| 168 | break; |
| 99 | 169 | } |
| 100 | 170 | |
| 101 | 171 | /* Player 2 */ |
| r776 | r777 | |
| 124 | 194 | sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( ( data & 0x0C ) >> 2 ) | ( paddle_read_state & 0x08 ) |
| 125 | 195 | | ( ( readinputport(10) & 0x20 ) >> 3 ); |
| 126 | 196 | break; |
| 197 | case 0x03: /* Sega Sports Pad */ |
| 198 | switch( sports_pad_state_2 ) { |
| 199 | case 0: |
| 200 | data = sports_pad_2_x & 0x0F; |
| 201 | break; |
| 202 | case 1: |
| 203 | data = ( sports_pad_2_x >> 4 ) & 0x0F; |
| 204 | case 2: |
| 205 | data = sports_pad_2_y & 0x0F; |
| 206 | break; |
| 207 | case 3: |
| 208 | data = ( sports_pad_2_y >> 4 ) & 0x0F; |
| 209 | break; |
| 210 | } |
| 211 | sms_input_port0 = ( sms_input_port0 & 0x3F ) | ( ( data & 0x03 ) << 6 ); |
| 212 | sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( data >> 2 ) | ( ( readinputport(10) & 0xC0 ) >> 4 ); |
| 213 | break; |
| 127 | 214 | } |
| 128 | 215 | } |
| 129 | 216 | |
| r776 | r777 | |
| 150 | 237 | if ((data & 0x01) && (data & 0x04)) { |
| 151 | 238 | smsVersion = (data & 0xA0); |
| 152 | 239 | } |
| 240 | if ( data & 0x08 ) { |
| 241 | sms_input_write( 0, ( data & 0x20 ) >> 5 ); |
| 242 | } |
| 243 | if ( data & 0x02 ) { |
| 244 | sms_input_write( 1, ( data & 0x80 ) >> 7 ); |
| 245 | } |
| 153 | 246 | } |
| 154 | 247 | |
| 155 | 248 | READ8_HANDLER(sms_version_r) { |
| r776 | r777 | |
| 839 | 932 | |
| 840 | 933 | last_paddle_read_time = 0; |
| 841 | 934 | paddle_read_state = 0; |
| 935 | |
| 936 | last_sports_pad_time_1 = 0; |
| 937 | last_sports_pad_time_2 = 0; |
| 938 | sports_pad_state_1 = 0; |
| 939 | sports_pad_state_2 = 0; |
| 940 | sports_pad_last_data_1 = 0; |
| 941 | sports_pad_last_data_2 = 0; |
| 942 | sports_pad_1_x = 0; |
| 943 | sports_pad_1_y = 0; |
| 944 | sports_pad_2_x = 0; |
| 945 | sports_pad_2_y = 0; |
| 842 | 946 | } |
| 843 | 947 | |
| 844 | 948 | READ8_HANDLER(sms_store_cart_select_r) { |
src/mess/drivers/sms.c
| r776 | r777 | |
| 202 | 202 | PORT_START /* IN10 - Light Phaser and Paddle Control buttons */ |
| 203 | 203 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(11) PORT_PLAYER(1) |
| 204 | 204 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(12) PORT_PLAYER(1) |
| 205 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(13) PORT_PLAYER(1) |
| 206 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CATEGORY(13) PORT_PLAYER(1) |
| 205 | 207 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(21) PORT_PLAYER(2) |
| 206 | 208 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(22) PORT_PLAYER(2) |
| 209 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(23) PORT_PLAYER(2) |
| 210 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CATEGORY(23) PORT_PLAYER(2) |
| 207 | 211 | |
| 208 | 212 | PORT_START /* IN11 - Controller selection */ |
| 209 | 213 | PORT_CATEGORY_CLASS( 0x0F, 0x00, "Player 1 Controller" ) |
| 210 | 214 | PORT_CATEGORY_ITEM( 0x00, DEF_STR( Joystick ), 10 ) |
| 211 | 215 | // PORT_CATEGORY_ITEM( 0x01, "Light Phaser", 11 ) |
| 212 | 216 | PORT_CATEGORY_ITEM( 0x02, "Sega Paddle Control", 12 ) |
| 217 | PORT_CATEGORY_ITEM( 0x03, "Sega Sports Pad", 13 ) |
| 213 | 218 | PORT_CATEGORY_CLASS( 0xF0, 0x00, "Player 2 Controller" ) |
| 214 | 219 | PORT_CATEGORY_ITEM( 0x00, DEF_STR( Joystick ), 20 ) |
| 215 | 220 | // PORT_CATEGORY_ITEM( 0x10, "Light Phaser", 21 ) |
| 216 | 221 | PORT_CATEGORY_ITEM( 0x20, "Sega Paddle Control", 22 ) |
| 222 | PORT_CATEGORY_ITEM( 0x30, "Sega Sports Pad", 23 ) |
| 217 | 223 | |
| 224 | PORT_START /* IN12 - Player 1 Sports Pad X axis */ |
| 225 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(40) PORT_RESET PORT_REVERSE PORT_CATEGORY(13) PORT_PLAYER(1) |
| 226 | |
| 227 | PORT_START /* IN13 - Player 1 Sports Pad Y axis */ |
| 228 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(40) PORT_RESET PORT_REVERSE PORT_CATEGORY(13) PORT_PLAYER(1) |
| 229 | |
| 230 | PORT_START /* IN14 - Player 2 Sports Pad X axis */ |
| 231 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(40) PORT_RESET PORT_REVERSE PORT_CATEGORY(23) PORT_PLAYER(2) |
| 232 | |
| 233 | PORT_START /* IN15 - Player 2 Sports Pad Y axis */ |
| 234 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(40) PORT_RESET PORT_REVERSE PORT_CATEGORY(23) PORT_PLAYER(2) |
| 235 | |
| 218 | 236 | INPUT_PORTS_END |
| 219 | 237 | |
| 220 | 238 | static PALETTE_INIT( sms ) { |