Settings a byte X-amount of times

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
Lurendrejer
Posts: 51
Joined: Sat Sep 03, 2005 5:52 pm
Location: Denmark

Settings a byte X-amount of times

Post by Lurendrejer »

I need something that can:

do this:
<action condition="maincpu.pb@011B46A0==60">maincpu.pb@011B46A0=20</action>

<Param> amount of times.

eg. if param=3, then it should only change 60 to 20 three times and after that just let 60 skip to 68. It seems no matter what i do, it just doesn't do it right.
User avatar
Pugsy
Posts: 3675
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 15 times
Contact:

Re: Settings a byte X-amount of times

Post by Pugsy »

Something like this you mean?

Code: Select all

    <script state="on">
      <action>temp0 =0</action>
    </script>
    <script state="run">
      <action condition="maincpu.pb@011B46A0==60 AND temp0 LT param">maincpu.pb@011B46A0=20, temp0=temp0+1</action>
    </script>
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
User avatar
NotAGoodName
Posts: 331
Joined: Wed Feb 18, 2009 7:09 am
Location: MO, USA
Contact:

Re: Settings a byte X-amount of times

Post by NotAGoodName »

I'm not sure what you're up to, but if you really can't find another condition to base this on, there's a way to do it. You need to have a free address handy that NOTHING uses. Good luck finding a safe one on an arcade machine.


Example:

Code: Select all

  <cheat desc="Your Cheat">
    <param min="0" max="999" step="1"/>
    <script state="on">
      <action>maincpu.pb@BEEFDEAD=00</action>
    </script>
    <script state="run">
      <action condition="maincpu.pb@DEADBEEF==59">maincpu.pb@BEEFDEAD=(maincpu.pb@BEEFDEAD) + 1</action>
      <action condition="maincpu.pb@DEADBEEF==60 and maincpu.pb@BEEFDEAD LT (param)+1">maincpu.pb@DEADBEEF=20</action>
    </script>
  </cheat>
In the example. BEEFDEAD is your dummy address. DEADBEEF is the real address. You add one to the loop right before the value is changed. Once the loop is complete, the cheat will never reactivate until it is reset because nothing resets the loop address at BEEFDEAD to 0.


*edit*
Or you could be smart like Pugsy and use a temp variable.
Aww yeah. AMD A10-7850K givin' MAME and MESS systems what for.
Lurendrejer
Posts: 51
Joined: Sat Sep 03, 2005 5:52 pm
Location: Denmark

Re: Settings a byte X-amount of times

Post by Lurendrejer »

I guess i'm not smart then, cause i have actually been fidling around with doing something like you (notagoodname) and resetting the value based on some condition that fits. I'll check your solution out pugsy, and thank you :)
Lurendrejer
Posts: 51
Joined: Sat Sep 03, 2005 5:52 pm
Location: Denmark

Re: Settings a byte X-amount of times

Post by Lurendrejer »

I ended up with this - I'll check if it works later.

Instead of free addresses to make a latter with x-amount of opponents this ought to replay the latter again, again and again until the variable check tells it not to.
The other two addresses that gets set simply changes the on-screen counter to 8 when it reaches 0 - if goes above nine or below zero, it just displays garbage.

<cheat desc="Number of RR-Opponents">
<parameter>
<item value="0x01">16</item>
<item value="0x02">24</item>
<item value="0x03">32</item>
<item value="0x04">40</item>
</parameter>
<script state="on">
<action>temp0 =0</action>
</script>
<script state="run">
<action condition="maincpu.pb@011B46A0==60 AND temp0 LT param">maincpu.pb@011B46A0=20, temp0=temp0+1</action>
<action condition="maincpu.pb@010B29E0==01">maincpu.pb@010B29E0=09</action>
<action condition="maincpu.pb@010F44C0==01">maincpu.pb@010F44C0=09</action>
</script>
</cheat>
User avatar
Pugsy
Posts: 3675
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 15 times
Contact:

Re: Settings a byte X-amount of times

Post by Pugsy »

Remember though this cheat will only poke the value a maximum of param times and it will poke it no more unless you turn the cheat off and on. I can't see any situation were I'd want that - but it's what you asked for...

So you may wish to have a condition that'll reset temp0 to 0 when it's safe to do so.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
Lurendrejer
Posts: 51
Joined: Sat Sep 03, 2005 5:52 pm
Location: Denmark

Re: Settings a byte X-amount of times

Post by Lurendrejer »

I'm using a condition-based thingie to reset the variable based on an animation played before the match starts.

I hope i'm doing it right, the syntax is : <action condition="maincpu.pb@011B4720!=00">temp0 =0</action>

right?
User avatar
Pugsy
Posts: 3675
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 15 times
Contact:

Re: Settings a byte X-amount of times

Post by Pugsy »

Yes, looks fine to put in the "run" script
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
Post Reply