MAMEWorld >> Programming
View all threads Index   Flat Mode Flat  

baritonomarchetto
MAME Fan
Reged: 11/22/10
Posts: 18
Send PM
Re: Need help with Cruis'n World driver
09/10/12 02:19 PM


Thank you, the code now works 100% !!

One step further: what if i want the first button to cicle between wievs (like it does) AND i want button 2, 3 and 4 work again?

I made some (unsuccesful ) trials. First of all, i tried by re-defining the 3 buttons:


Code:


PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("View Change/View 1") /* view 1 */
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("View 2")/* view 2 */
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_NAME("View 3")/* view 3 */
PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2) PORT_NAME("View 4")/* view 4 */



This, alone, doesn't work (like expected): the function "port1_r" only controls one button.

Then i made a first try (here is the full function with only one button defined but can be easily ported to all the buttons):


Code:


static READ32_HANDLER( port1_r )
{
static UINT8 cur_view = 0;
static UINT8 last_val = 0;
static UINT16 last_data = 0;

UINT16 viewval = readinputport(1); //total actual values stored in memory
UINT8 button_pressed = viewval & 0x0010;
UINT8 button2_pressed = viewval & 0x0020;
// UINT8 button3_pressed = viewval & 0x0040;
// UINT8 button4_pressed = viewval & 0x0080;

if (last_val==button_pressed)
return ((last_data << 16) | last_data);

if (!button_pressed ) // check if button is pressed
{
cur_view++;
if (cur_view == 4)
cur_view = 0;
viewval = (viewval | 0xf0);

switch (cur_view)
{
case 0:
viewval = viewval & 0xef;
break;
case 1:
viewval = viewval & 0xdf;
break;
case 2:
viewval = viewval & 0xbf;
break;
case 3:
viewval = viewval & 0x7f;
break;
}

}

last_val=button_pressed;
last_data = viewval;
return (viewval << 16) | viewval;

if (!button2_pressed ) // check if button "view 2" is pressed
{
cur_view = 1;
viewval = (viewval | 0xf0) & 0xdf;
}
return (viewval << 16) | viewval;
}




Not working: only the "old" cycling is detected.

I made a second try, with the code section controlling the button press like:


Code:


if (!button2_pressed ) // check if button "view 2" is pressed
{
cur_view = 1;
viewval = (viewval | 0xf0) & 0xdf;
}
return (readinputport(1) << 16) | readinputport(1);



Still not working, like before ... consider that the original code (the "4 buttons, one for each view")was


Code:


static READ32_HANDLER( port1_r )
{
return (readinputport(1) << 16) | readinputport(1);
}



What's wrong? Thanks for the lesson !







Entire thread
Subject Posted by Posted on
* Need help with Cruis'n World driver baritonomarchetto 08/27/12 04:12 PM
. * Re: Need help with Cruis'n World driver sz72  08/27/12 08:44 PM
. * Re: Need help with Cruis'n World driver baritonomarchetto  08/28/12 09:23 AM
. * Re: Need help with Cruis'n World driver sz72  08/28/12 01:30 PM
. * Re: Need help with Cruis'n World driver baritonomarchetto  08/28/12 02:01 PM
. * Re: Need help with Cruis'n World driver sz72  08/28/12 03:51 PM
. * Re: Need help with Cruis'n World driver baritonomarchetto  08/28/12 04:19 PM
. * Re: Need help with Cruis'n World driver sz72  08/28/12 06:55 PM
. * Re: Need help with Cruis'n World driver baritonomarchetto  08/29/12 02:27 PM
. * Re: Need help with Cruis'n World driver etabeta  08/29/12 04:04 PM
. * Re: Need help with Cruis'n World driver baritonomarchetto  08/29/12 04:37 PM
. * Re: Need help with Cruis'n World driver etabeta  08/30/12 07:32 AM
. * Re: Need help with Cruis'n World driver baritonomarchetto  08/30/12 05:54 PM
. * Re: Need help with Cruis'n World driver etabeta  08/31/12 08:27 AM
. * Re: Need help with Cruis'n World driver baritonomarchetto  09/03/12 07:21 PM
. * Re: Need help with Cruis'n World driver any  09/06/12 06:04 AM
. * Re: Need help with Cruis'n World driver baritonomarchetto  09/06/12 02:52 PM
. * Re: Need help with Cruis'n World driver any  09/07/12 05:52 AM
. * Re: Need help with Cruis'n World driver baritonomarchetto  09/10/12 02:19 PM
. * Re: Need help with Cruis'n World driver baritonomarchetto  09/13/12 05:05 PM
. * Re: Need help with Cruis'n World driver R. Belmont  09/18/12 05:05 PM
. * Re: Need help with Cruis'n World driver baritonomarchetto  09/18/12 05:28 PM

Extra information Permissions
Moderator:  Pi 
0 registered and 32 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 4512