src/mess/machine/sms.c
| r770 | r771 | |
| 30 | 30 | UINT8 ggSIO[5] = { 0x7F, 0xFF, 0x00, 0xFF, 0x00 }; |
| 31 | 31 | UINT8 sms_store_control = 0; |
| 32 | 32 | |
| 33 | UINT8 sms_input_port0; |
| 34 | UINT8 sms_input_port1; |
| 35 | |
| 33 | 36 | /* Data needed for Rapid Fire Unit support */ |
| 34 | 37 | mame_timer *rapid_fire_timer; |
| 35 | 38 | UINT8 rapid_fire_state_1; |
| 36 | 39 | UINT8 rapid_fire_state_2; |
| 37 | 40 | |
| 41 | /* Data needed for Paddle Control controller */ |
| 42 | UINT32 last_paddle_read_time; |
| 43 | UINT8 paddle_read_state; |
| 44 | |
| 38 | 45 | struct { |
| 39 | 46 | UINT8 *ROM; /* Pointer to ROM image data */ |
| 40 | 47 | UINT32 size; /* Size of the ROM image */ |
| r770 | r771 | |
| 52 | 59 | rapid_fire_state_2 ^= 0xFF; |
| 53 | 60 | } |
| 54 | 61 | |
| 62 | static void sms_get_inputs(void) { |
| 63 | UINT8 data; |
| 64 | UINT32 cpu_cycles = activecpu_gettotalcycles(); |
| 65 | |
| 66 | sms_input_port0 = 0xFF; |
| 67 | sms_input_port1 = 0xFF; |
| 68 | |
| 69 | if ( cpu_cycles - last_paddle_read_time > 256 ) { |
| 70 | paddle_read_state ^= 0xFF; |
| 71 | last_paddle_read_time = cpu_cycles; |
| 72 | } |
| 73 | |
| 74 | /* Player 1 */ |
| 75 | switch( readinputport(11) & 0x0F ) { |
| 76 | case 0x00: /* Joystick */ |
| 77 | data = readinputport(0); |
| 78 | /* Rapid Fire setting for Button A */ |
| 79 | if ( readinputport(7) & 0x01 ) { |
| 80 | data = ( data & 0xEF ) | ( rapid_fire_state_1 & 0x10 ); |
| 81 | } |
| 82 | /* Check Rapid Fire setting for Button B */ |
| 83 | if ( readinputport(7) & 0x02 ) { |
| 84 | data = ( data & 0xDF ) | ( rapid_fire_state_1 & 0x20 ); |
| 85 | } |
| 86 | sms_input_port0 = ( sms_input_port0 & 0xC0 ) | ( data & 0x3F ); |
| 87 | break; |
| 88 | case 0x01: /* Light Phaser */ |
| 89 | break; |
| 90 | case 0x02: /* Paddle Control */ |
| 91 | /* Get button A state */ |
| 92 | data = readinputport(8); |
| 93 | if ( paddle_read_state ) { |
| 94 | data = data >> 4; |
| 95 | } |
| 96 | sms_input_port0 = ( sms_input_port0 & 0xC0 ) | ( data & 0x0F ) | ( paddle_read_state & 0x20 ) |
| 97 | | ( ( readinputport(10) & 0x02 ) << 3 ); |
| 98 | break; |
| 99 | } |
| 100 | |
| 101 | /* Player 2 */ |
| 102 | switch( readinputport(11) >> 4 ) { |
| 103 | case 0x00: /* Joystick */ |
| 104 | data = readinputport(0); |
| 105 | sms_input_port0 = ( sms_input_port0 & 0x3F ) | ( data & 0xC0 ); |
| 106 | data = readinputport(1); |
| 107 | if ( readinputport(7) & 0x04 ) { |
| 108 | data = ( data & 0xFB ) | ( rapid_fire_state_2 & 0x04 ); |
| 109 | } |
| 110 | if ( readinputport(7) & 0x08 ) { |
| 111 | data = ( data & 0xF7 ) | ( rapid_fire_state_2 & 0x08 ); |
| 112 | } |
| 113 | sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( data & 0x0F ); |
| 114 | break; |
| 115 | case 0x01: /* Light Phaser */ |
| 116 | break; |
| 117 | case 0x02: /* Paddle Control */ |
| 118 | /* Get button A state */ |
| 119 | data = readinputport(9); |
| 120 | if ( paddle_read_state ) { |
| 121 | data = data >> 4; |
| 122 | } |
| 123 | sms_input_port0 = ( sms_input_port0 & 0x3F ) | ( ( data & 0x03 ) << 6 ); |
| 124 | sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( ( data & 0x0C ) >> 2 ) | ( paddle_read_state & 0x08 ) |
| 125 | | ( ( readinputport(10) & 0x20 ) >> 3 ); |
| 126 | break; |
| 127 | } |
| 128 | } |
| 129 | |
| 55 | 130 | WRITE8_HANDLER(sms_fm_detect_w) { |
| 56 | 131 | if ( HAS_FM ) { |
| 57 | 132 | smsFMDetect = (data & 0x01); |
| r770 | r771 | |
| 65 | 140 | if ( biosPort & IO_CHIP ) { |
| 66 | 141 | return 0xFF; |
| 67 | 142 | } else { |
| 68 | | UINT8 data = readinputport(0); |
| 69 | | /* Rapid Fire setting for Button A */ |
| 70 | | if ( readinputport(7) & 0x01 ) { |
| 71 | | data = ( data & 0xEF ) | ( rapid_fire_state_1 & 0x10 ); |
| 72 | | } |
| 73 | | /* Check Rapid Fire setting for Button B */ |
| 74 | | if ( readinputport(7) & 0x02 ) { |
| 75 | | data = ( data & 0xDF ) | ( rapid_fire_state_1 & 0x20 ); |
| 76 | | } |
| 77 | | return data; |
| 143 | sms_get_inputs(); |
| 144 | return sms_input_port0; |
| 78 | 145 | } |
| 79 | 146 | } |
| 80 | 147 | } |
| r770 | r771 | |
| 101 | 168 | } |
| 102 | 169 | |
| 103 | 170 | /* Merge version data with input port #2 data */ |
| 104 | | temp = (temp & 0xC0) | (readinputport(1) & 0x3F); |
| 171 | sms_get_inputs(); |
| 172 | temp = (temp & 0xC0) | (sms_input_port1 & 0x3F); |
| 105 | 173 | |
| 106 | | /* Rapid Fire setting for Button A */ |
| 107 | | if ( readinputport(7) & 0x04 ) { |
| 108 | | temp = ( temp & 0xFB ) | ( rapid_fire_state_2 & 0x04 ); |
| 109 | | } |
| 110 | | /* Check Rapid Fire setting for Button B */ |
| 111 | | if ( readinputport(7) & 0x08 ) { |
| 112 | | temp = ( temp & 0xF7 ) | ( rapid_fire_state_2 & 0x08 ); |
| 113 | | } |
| 114 | | |
| 115 | 174 | return (temp); |
| 116 | 175 | } |
| 117 | 176 | |
| r770 | r771 | |
| 142 | 201 | if (biosPort & IO_CHIP) { |
| 143 | 202 | return (0xFF); |
| 144 | 203 | } else { |
| 145 | | UINT8 data = readinputport(0); |
| 146 | | /* Rapid Fire setting for Button A */ |
| 147 | | if ( readinputport(7) & 0x01 ) { |
| 148 | | data = ( data & 0xEF ) | ( rapid_fire_state_1 & 0x10 ); |
| 149 | | } |
| 150 | | /* Check Rapid Fire setting for Button B */ |
| 151 | | if ( readinputport(7) & 0x02 ) { |
| 152 | | data = ( data & 0xDF ) | ( rapid_fire_state_1 & 0x20 ); |
| 153 | | } |
| 154 | | return data; |
| 204 | sms_get_inputs(); |
| 205 | return sms_input_port0; |
| 155 | 206 | } |
| 156 | 207 | } |
| 157 | 208 | |
| r770 | r771 | |
| 785 | 836 | rapid_fire_state_2 = 0; |
| 786 | 837 | rapid_fire_timer = mame_timer_alloc( rapid_fire_callback ); |
| 787 | 838 | mame_timer_adjust( rapid_fire_timer, MAME_TIME_IN_HZ(10), 0, MAME_TIME_IN_HZ(10) ); |
| 839 | |
| 840 | last_paddle_read_time = 0; |
| 841 | paddle_read_state = 0; |
| 788 | 842 | } |
| 789 | 843 | |
| 790 | 844 | READ8_HANDLER(sms_store_cart_select_r) { |
src/mess/drivers/sms.c
| r770 | r771 | |
| 140 | 140 | INPUT_PORTS_START( sms ) |
| 141 | 141 | |
| 142 | 142 | PORT_START /* IN0 */ |
| 143 | | PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(1) PORT_8WAY |
| 144 | | PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1) PORT_8WAY |
| 145 | | PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1) PORT_8WAY |
| 146 | | PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1) PORT_8WAY |
| 147 | | PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1) |
| 148 | | PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1) |
| 149 | | PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(2) PORT_8WAY |
| 150 | | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(2) PORT_8WAY |
| 143 | PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_CATEGORY(10) PORT_PLAYER(1) PORT_8WAY |
| 144 | PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_CATEGORY(10) PORT_PLAYER(1) PORT_8WAY |
| 145 | PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_CATEGORY(10) PORT_PLAYER(1) PORT_8WAY |
| 146 | PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_CATEGORY(10) PORT_PLAYER(1) PORT_8WAY |
| 147 | PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 148 | PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 149 | PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_CATEGORY(20) PORT_PLAYER(2) PORT_8WAY |
| 150 | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_CATEGORY(20) PORT_PLAYER(2) PORT_8WAY |
| 151 | 151 | |
| 152 | 152 | PORT_START /* IN1 */ |
| 153 | | PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(2) PORT_8WAY |
| 154 | | PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(2) PORT_8WAY |
| 155 | | PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2) |
| 156 | | PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(2) |
| 153 | PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_CATEGORY(20) PORT_PLAYER(2) PORT_8WAY |
| 154 | PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_CATEGORY(20) PORT_PLAYER(2) PORT_8WAY |
| 155 | PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CATEGORY(21) PORT_PLAYER(2) |
| 156 | PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CATEGORY(21) PORT_PLAYER(2) |
| 157 | 157 | PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) /* Software Reset bit */ |
| 158 | 158 | PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 159 | 159 | PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r770 | r771 | |
| 170 | 170 | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_START ) /* Game Gear START */ |
| 171 | 171 | |
| 172 | 172 | PORT_START /* IN3 - Light phaser X - player 1 */ |
| 173 | | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR( X, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1) |
| 173 | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR( X, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_CATEGORY(11) PORT_PLAYER(1) |
| 174 | 174 | |
| 175 | 175 | PORT_START /* IN4 - Light phaser Y - player 1 */ |
| 176 | | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR( Y, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1) |
| 176 | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR( Y, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_CATEGORY(11) PORT_PLAYER(1) |
| 177 | 177 | |
| 178 | 178 | PORT_START /* IN5 - Light phaser X - player 2 */ |
| 179 | | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR( X, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEUDELTA(15) PORT_PLAYER(2) |
| 179 | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR( X, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEUDELTA(15) PORT_CATEGORY(21) PORT_PLAYER(2) |
| 180 | 180 | |
| 181 | 181 | PORT_START /* IN6 - Light phaser Y - player 2 */ |
| 182 | | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR( Y, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(25) PORT_PLAYER(2) |
| 182 | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR( Y, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(25) PORT_CATEGORY(21) PORT_PLAYER(2) |
| 183 | 183 | |
| 184 | 184 | PORT_START /* IN7 - Rapid Fire Unit */ |
| 185 | 185 | PORT_DIPNAME( 0x03, 0x00, "Rapid Fire Unit - Player 1" ) |
| r770 | r771 | |
| 193 | 193 | PORT_DIPSETTING( 0x08, "Button B" ) |
| 194 | 194 | PORT_DIPSETTING( 0x0C, "Button A+B" ) |
| 195 | 195 | |
| 196 | PORT_START /* IN8 - Paddle player 1 */ |
| 197 | PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_SENSITIVITY(40) PORT_KEYDELTA(20) PORT_CENTERDELTA(0) PORT_MINMAX(0,255) PORT_CATEGORY(12) PORT_PLAYER(1) |
| 198 | |
| 199 | PORT_START /* IN9 - Paddle player 2 */ |
| 200 | PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_SENSITIVITY(40) PORT_KEYDELTA(20) PORT_CENTERDELTA(0) PORT_MINMAX(0,255) PORT_CATEGORY(22) PORT_PLAYER(2) |
| 201 | |
| 202 | PORT_START /* IN10 - Light Phaser and Paddle Control buttons */ |
| 203 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(11) PORT_PLAYER(1) |
| 204 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(12) PORT_PLAYER(1) |
| 205 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(21) PORT_PLAYER(2) |
| 206 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(22) PORT_PLAYER(2) |
| 207 | |
| 208 | PORT_START /* IN11 - Controller selection */ |
| 209 | PORT_CATEGORY_CLASS( 0x0F, 0x00, "Player 1 Controller" ) |
| 210 | PORT_CATEGORY_ITEM( 0x00, DEF_STR( Joystick ), 10 ) |
| 211 | // PORT_CATEGORY_ITEM( 0x01, "Light Phaser", 11 ) |
| 212 | PORT_CATEGORY_ITEM( 0x02, "Sega Paddle Control", 12 ) |
| 213 | PORT_CATEGORY_CLASS( 0xF0, 0x00, "Player 2 Controller" ) |
| 214 | PORT_CATEGORY_ITEM( 0x00, DEF_STR( Joystick ), 20 ) |
| 215 | // PORT_CATEGORY_ITEM( 0x10, "Light Phaser", 21 ) |
| 216 | PORT_CATEGORY_ITEM( 0x20, "Sega Paddle Control", 22 ) |
| 217 | |
| 196 | 218 | INPUT_PORTS_END |
| 197 | 219 | |
| 198 | 220 | static PALETTE_INIT( sms ) { |