Previous 15994 Revisions Next

r777 Wednesday 1st August, 2007 at 17:46:27 UTC by Wilbert Pol
[SMS] Added support for Sega Sports Pad. (bug #1316)
[docs]messnew.txt
[src/mess/drivers]sms.c
[src/mess/machine]sms.c

src/mess/machine/sms.c
r776r777
4242UINT32 last_paddle_read_time;
4343UINT8 paddle_read_state;
4444
45/* Data needed for Sports Pad controller */
46UINT32 last_sports_pad_time_1;
47UINT32 last_sports_pad_time_2;
48UINT8 sports_pad_state_1;
49UINT8 sports_pad_state_2;
50UINT8 sports_pad_last_data_1;
51UINT8 sports_pad_last_data_2;
52UINT8 sports_pad_1_x;
53UINT8 sports_pad_1_y;
54UINT8 sports_pad_2_x;
55UINT8 sports_pad_2_y;
56
4557struct {
4658   UINT8   *ROM;         /* Pointer to ROM image data */
4759   UINT32   size;         /* Size of the ROM image */
r776r777
5971   rapid_fire_state_2 ^= 0xFF;
6072}
6173
74static 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
62115static void sms_get_inputs(void) {
63116   UINT8 data;
64117   UINT32 cpu_cycles = activecpu_gettotalcycles();
r776r777
96149      sms_input_port0 = ( sms_input_port0 & 0xC0 ) | ( data & 0x0F ) | ( paddle_read_state & 0x20 )
97150                      | ( ( readinputport(10) & 0x02 ) << 3 );
98151      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;
99169   }
100170
101171   /* Player 2 */
r776r777
124194      sms_input_port1 = ( sms_input_port1 & 0xF0 ) | ( ( data & 0x0C ) >> 2 ) | ( paddle_read_state & 0x08 )
125195                      | ( ( readinputport(10) & 0x20 ) >> 3 );
126196      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;
127214   }
128215}
129216
r776r777
150237   if ((data & 0x01) && (data & 0x04)) {
151238      smsVersion = (data & 0xA0);
152239   }
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   }
153246}
154247
155248 READ8_HANDLER(sms_version_r) {
r776r777
839932
840933   last_paddle_read_time = 0;
841934   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;
842946}
843947
844948READ8_HANDLER(sms_store_cart_select_r) {
src/mess/drivers/sms.c
r776r777
202202   PORT_START   /* IN10 - Light Phaser and Paddle Control buttons */
203203   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(11) PORT_PLAYER(1)
204204   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)
205207   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CATEGORY(21) PORT_PLAYER(2)
206208   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)
207211
208212   PORT_START   /* IN11 - Controller selection */
209213   PORT_CATEGORY_CLASS( 0x0F, 0x00, "Player 1 Controller" )
210214   PORT_CATEGORY_ITEM( 0x00, DEF_STR( Joystick ), 10 )
211215//   PORT_CATEGORY_ITEM( 0x01, "Light Phaser", 11 )
212216   PORT_CATEGORY_ITEM( 0x02, "Sega Paddle Control", 12 )
217   PORT_CATEGORY_ITEM( 0x03, "Sega Sports Pad", 13 )
213218   PORT_CATEGORY_CLASS( 0xF0, 0x00, "Player 2 Controller" )
214219   PORT_CATEGORY_ITEM( 0x00, DEF_STR( Joystick ), 20 )
215220//   PORT_CATEGORY_ITEM( 0x10, "Light Phaser", 21 )
216221   PORT_CATEGORY_ITEM( 0x20, "Sega Paddle Control", 22 )
222   PORT_CATEGORY_ITEM( 0x30, "Sega Sports Pad", 23 )
217223
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
218236INPUT_PORTS_END
219237
220238static PALETTE_INIT( sms ) {
docs/messnew.txt
r776r777
6060- [SMS] Added support for Sega Paddle Controller.  (part of bug #1318)
6161  [Wilbert Pol]
6262
63- [SMS] Added support for Sega Sports Pad.  (bug #1316) [Wilbert Pol]
64
6365- [THOMSON] Fixed regressions introduced with 6821 changes.  [Antoine Mine]
6466
6567- [THOMSON] Fixed TO8/TO9+ ram bank handler (fixes BASIC 1.0 bug).  [Antoine

Previous 15994 Revisions Next


© 1998-2018 The MESS Team