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

sz72
MAME Fan
Reged: 08/20/07
Posts: 78
Send PM
Re: Need help with Cruis'n World driver
08/27/12 08:44 PM


> Hi All,
>
> I am toying with MAME sources, but I am not a programmer, so I am having some issues
> while trying to implement the sequential view change in Cruis’n World.
>
> Aaron wrote some helpful code for the gear handling I used as a template, even if I
> am not a bit by bit guru and most of the code is “supposed to mean” something to me .
>
> Anyhow, I ended up with this code:
>
>
> static READ32_HANDLER( port1_r )
> {
> UINT16 viewval = readinputport(1); //actual value stored in memory
> UINT16 viewdiff = viewval ^ last_port1;
> if ((viewdiff & 0x0010) && !(viewval & 0x0010)) //the button is pressed (?)
> {
> if (view_state==0) {view_state = 4;} //1st view
> else if (view_state==4) {view_state = 2;} //2nd view
> else if (view_state==2) {view_state = 1;} //3rd view
> else if (view_state==1) {view_state = 4;} //1st view
> }
> last_port1 = viewval;
> viewval = (viewval | 0x00f0) ^ (view_state << 4);
> return (viewval << 16) | viewval;
> }
>
>
> This code (for MAME 0.106 but very similar on more recent devs) somehow works
> “in-game”, but when the play finishes I cannot insert the name (hiscore) nor I can
> continue because the game acts like a button (a view change button, I suppose) is
> kept pressed. Notice that this is not related to PORT_BIT being kept HIGH or LOW. I
> think that the problem is in that “return (viewval << 16) | viewval;” being
> returned every single time the code is run.
>
> How can I modify this to let the view change only when the button is pressed, then no
> other inputs are sent? Any idea?
>
> Thanks for the support

In the code you show, the variable view_state changes value only when the number returned by readinputport(1) changes between calls of the port1_r read handler (in particular when bit 4 changes from 1 to 0).
So the view should already change only when the button is pressed.







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 4 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