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 !