MAMEWorld >> Programming
Index   Flat Mode Flat  

any
Lead on, adventurer. Your quest awaits!
Reged: 03/21/06
Posts: 23
Send PM
Re: Need help with Cruis'n World driver
09/07/12 05:52 AM


> question rises anyhow: why should those bits be counted from right to left? By
> convention?
0x0f for example mean that the first 4 bits are set (1) ane the last 4 are not (0), the first bit is the rightmost


> The code works and it's very clear: essentially you "flatten" all the 4 view bits
> (5th to 8th) to "1111" with viewval = (viewval | 0xf0) and then assign the zero to
> the desired view bit with viewval = viewval & 0xef for bit 5, and so on.

It's not the best looking one to see, but in this way it's easy to understand how it work

> Any idea on what's wrong here?

In your code you never reset to 1 the "flag".


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;

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;
}



this shoud work, as you can see I keep a copy of last input read and if it's the same I just return old value, if not i return new data and copy new data to my stored value.







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 16 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 4481