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