MAMEWorld >> Programming
Previous thread Previous  View all threads Index   Next thread Next   Flat Mode Flat  

etabeta
Reged: 08/25/04
Posts: 2035
Send PM
Re: Need help with Cruis'n World driver
08/29/12 04:04 PM


I think that the problem with the original code was that you were still returning the view_state bit even when the button was not pressed and the game was not expecting that (input_port reads the corresponding bit as 1 only when you press the button, then it reads 0... it's the internal game code that takes care of checking frequently enough if the bit is 0 or 1)

> You got the point
>
> unfortunately i don't know how to implement the feature the way you suggested ...
> could you post some code to teach me something? It would be very appreciated

1. change the input port to get only a single bit (say 0x10) [i.e. remove the other button inputs]

2. assuming the input is 1 when button is pressed and 0 when is de-pressed (if not, you have to slightly modify the parts where you test the 0x10 bit...), use something along the lines of


Code:


static READ32_HANDLER( port1_r )
{
static UINT8 cur_view = 0;
UINT16 viewval = readinputport(1); //actual value stored in memory
UINT8 button_pressed = viewval & 0x0010;

if (button_pressed) // check if button is pressed
{
cur_view++;
if (cur_view == 4)
cur_view = 0;
}
viewval = (viewval & ~0x10) | (button_pressed << cur_view); // remove the fake button bit and add the correct view bit to the input
return (viewval << 16) | viewval;
}



notice that in more recent versions cur_value would become an element of the driver class, but given you talk about very old MAME, a static variable should do the job







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