How to use bit as conditional?

If you are having problems finding or using cheats for an Emulator (particularly MAME/MESS) or have found a trick that you wish to share this is the place to do it. But please read the Cheat FAQ first.
Post Reply
User avatar
NotAGoodName
Posts: 331
Joined: Wed Feb 18, 2009 7:09 am
Location: MO, USA
Contact:

How to use bit as conditional?

Post by NotAGoodName »

Ok. I need to make a cheat where holding a button engages the cheat. Looks like this:

Code: Select all

  <cheat desc="Moon Jump">
    <script state="run">
      <action condition="maincpu.pb@0823==01|(maincpu.pb@0823 BAND ~01)">maincpu.pb@0660=5F</action>
    </script>
  </cheat>
This almost works except for some stupid reason, MAME is interpreting it exactly like this:

Code: Select all

  <cheat desc="Moon Jump">
    <script state="run">
      <action condition="maincpu.pb@0823 GT 00">maincpu.pb@0660=5F</action>
    </script>
  </cheat>
Ignoring the fact that this behavior is just plain wrong, what's the correct way to do this?
Aww yeah. AMD A10-7850K givin' MAME and MESS systems what for.
User avatar
Pugsy
Posts: 3638
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 12 times
Contact:

Re: How to use bit as conditional?

Post by Pugsy »

Well without knowing what game it is to check I can't be sure but I'd put extra brackets around "01|(maincpu.pb@0823 BAND ~01)"

Code: Select all

<action condition="maincpu.pb@0823==(01|(maincpu.pb@0823 BAND ~01))">maincpu.pb@0660=5F</action>
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.259 XML cheat collection (6 OCTOBER 2023) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/q4dHGZ6K#i-EUiqIjH ... KMz7hnbTfw (ZIP Archive 3.76MB)
User avatar
NotAGoodName
Posts: 331
Joined: Wed Feb 18, 2009 7:09 am
Location: MO, USA
Contact:

Re: How to use bit as conditional?

Post by NotAGoodName »

Thanks, again. That did the trick. I've actually been wondering just what all that meant. Makes more sense, now.

It's for Mega Man 2 on nes.c, MAME Plus. Just this latest release, a few NES games started working so I figured I'd better get on it.
Aww yeah. AMD A10-7850K givin' MAME and MESS systems what for.
Post Reply