Previous 15994 Revisions Next

r771 Tuesday 31st July, 2007 at 19:52:13 UTC by Wilbert Pol
[SMS] Added support for Sega Paddle Controller.
[docs]messnew.txt
[src/mess/drivers]sms.c
[src/mess/machine]sms.c

src/mess/machine/sms.c
r770r771
3030UINT8 ggSIO[5] = { 0x7F, 0xFF, 0x00, 0xFF, 0x00 };
3131UINT8 sms_store_control = 0;
3232
33UINT8 sms_input_port0;
34UINT8 sms_input_port1;
35
3336/* Data needed for Rapid Fire Unit support */
3437mame_timer   *rapid_fire_timer;
3538UINT8 rapid_fire_state_1;
3639UINT8 rapid_fire_state_2;
3740
41/* Data needed for Paddle Control controller */
42UINT32 last_paddle_read_time;
43UINT8 paddle_read_state;
44
3845struct {
3946   UINT8   *ROM;         /* Pointer to ROM image data */
4047   UINT32   size;         /* Size of the ROM image */
r770r771
5259   rapid_fire_state_2 ^= 0xFF;
5360}
5461
62static 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
55130WRITE8_HANDLER(sms_fm_detect_w) {
56131   if ( HAS_FM ) {
57132      smsFMDetect = (data & 0x01);
r770r771
65140      if ( biosPort & IO_CHIP ) {
66141         return 0xFF;
67142      } 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;
78145      }
79146   }
80147}
r770r771
101168   }
102169
103170   /* 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);
105173
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
115174   return (temp);
116175}
117176
r770r771
142201   if (biosPort & IO_CHIP) {
143202      return (0xFF);
144203   } 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;
155206   }
156207}
157208
r770r771
785836   rapid_fire_state_2 = 0;
786837   rapid_fire_timer = mame_timer_alloc( rapid_fire_callback );
787838   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;
788842}
789843
790844READ8_HANDLER(sms_store_cart_select_r) {
src/mess/drivers/sms.c
r770r771
140140INPUT_PORTS_START( sms )
141141
142142   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
151151
152152   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)
157157   PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) /* Software Reset bit */
158158   PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
159159   PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
r770r771
170170   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_START ) /* Game Gear START */
171171
172172   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)
174174
175175   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)
177177
178178   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)
180180
181181   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)
183183
184184   PORT_START   /* IN7 - Rapid Fire Unit */
185185   PORT_DIPNAME( 0x03, 0x00, "Rapid Fire Unit - Player 1" )
r770r771
193193   PORT_DIPSETTING( 0x08, "Button B" )
194194   PORT_DIPSETTING( 0x0C, "Button A+B" )
195195
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
196218INPUT_PORTS_END
197219
198220static PALETTE_INIT( sms ) {
docs/messnew.txt
r770r771
5151
5252- [SMS] Added support for Sega Rapid Fire Unit.  (bug #1317) [Wilbert Pol]
5353
54- [SMS] Added support for Sega Paddle Controller.  (part of bug #1318)
55  [Wilbert Pol]
56
5457- [THOMSON] Fixed regressions introduced with 6821 changes.  [Antoine Mine]
5558
5659- [THOMSON] Fixed TO8/TO9+ ram bank handler (fixes BASIC 1.0 bug).  [Antoine

Previous 15994 Revisions Next


© 1998-2018 The MESS Team