dkong: Invincibility [fix] and more...

This forum is the archive of arcade cheats that have already been added to the current or the next release of the cheat file.
Post Reply
User avatar
aycaramba
Posts: 9
Joined: Thu Jan 29, 2009 12:23 pm

dkong: Invincibility [fix] and more...

Post by aycaramba »

As reported by Shima Pong - who is as wise as he is humble - the current invincibility cheat makes you die when you turn it off. I also notice that you can't grab the hammer, and being invincible with the hammer is really fun!

Code: Select all

        <cheat desc="Invincibility">
                <script state="on">
                        <action>temp0 = main.mw@1c57</action>
                        <action>temp1 = main.mw@2780</action>
                        <action>temp2 = main.mw@2819</action>
                        <action>temp3 = main.mw@2a1c</action>
                        <action>main.mw@1c57 = 1801</action>
                        <action>main.mw@2780 = 1804</action>
                        <action>main.mw@2819 = 1801</action>
                        <action>main.mw@2a1c = 1801</action>
                </script>
                <script state="off">
                        <action>main.mw@1c57 = temp0</action>
                        <action>main.mw@2780 = temp1</action>
                        <action>main.mw@2819 = temp2</action>
                        <action>main.mw@2a1c = temp3</action>
                </script>
        </cheat>
It may be a personal preference, but I set up my infinite lives cheat to return me to the number I had before it was turned on:

Code: Select all

        <cheat desc="Infinite Lives">
                <script state="on">
                        <action>temp0 = main.mb@12fc</action>
                        <action>temp1 = main.md@06c7</action>
                        <action>main.mb@12fc = 00</action><!-- never have lives subtracted -->
                        <action>main.md@06c7 = 0000063e</action><!-- always display maximum -->
                </script>
                <script state="off">
                        <action>main.mb@12fc = temp0</action>
                        <action>main.md@06c7 = temp1</action>
                </script>
        </cheat>
The bonus timer cheat was the hardest to get right. Again, I want to be able to return the bonus I had before it was turned on. The current cheat affects game play, since you don't get that first wild barrel when the it's turned on. It also doesn't save you if the timer has already reached zero, although you have 4 seconds left to live.

My version freezes the timer, and you can resume if you choose, even at zero.

Code: Select all

        <cheat desc="Freeze Bonus Timer">
                <script state="on">
                        <action>temp0 = main.mb@06a9</action>
                        <action>main.mb@06a9 = 00</action>
                        <action>main.pb@6386 = 00</action>
                </script>
                <script state="run">
                        <action condition="(main.pb@62b1 == 1)">main.pb@62b1 = main.pb@62b0 - 1</action>
                </script>
                <script state="off">
                        <action>main.mb@06a9 = temp0</action>
                        <action>temp1 = (main.pb@638c - (main.pb@638c / 10) * 6)</action>
                        <action condition="(main.pb@6200 != 0)">main.pb@62b1 = temp1</action>
                        <action condition="(main.pb@6200 != 0) AND (temp1 == 0)">main.pb@6386 = 02</action>
                </script>
        </cheat>
The starting level selector puts you on the right level, but the screen progression is that of level 1 (barrels, rivets). If I'm skipping to L2 for elevators, there aren't any. This is better:

Code: Select all

        <cheat desc="Select Starting Level">
                <parameter min="2" max="99" step="1"/>
                <script state="change">
                        <action>main.mb@095e = (param)</action>
                        <action condition="(param == 2)">main.mb@095f = 67</action>
                        <action condition="(param == 3)">main.mb@095f = 6A</action>
                        <action condition="(param == 4)">main.mb@095f = 6E</action>
                        <action condition="(param GT 4)">main.mb@095f = 73</action>
                </script>
                <script state="off">
                        <action>main.mb@095e = 01</action>
                        <action>main.mb@095f = 65</action>
                </script>
        </cheat>
Finally, I thought I'd mention that a lot of the examples I've seen seem to like the format:
1. [on] Save temp variables.
2. [run] Change bytes.
3. [off] Restore from temp variables.
A good example is the kill screen fix. It's a one-shot, but since all of the code is in "run", it gets reapplied every frame. It shouldn't have a run state:

Code: Select all

        <cheat desc="Fix Kill Screen Bug">
                <comment>Fixes the timer bug on level 22. See donhodges com how_high_can_you_get htm</comment>
                <script state="on">
                        <action>temp0 = main.mq@0F7D</action>
                        <action>temp1 = main.mq@0F85</action>
                        <action>main.mq@0F7D = 3E47043E023805FE</action>
                        <action>main.mq@0F85 = 000218FC100AC628</action>
                </script>
                <script state="off">
                        <action>main.mq@0F7D = temp0</action>
                        <action>main.mq@0F85 = temp1</action>
                </script>
        </cheat>
I shortened it a bit to fit into two qwords. (I had to remove the U-R-L punctuation to post that. Maybe an admin can put it back.)

Any advice on these is welcome. I'm guessing at the new format sometimes. I'll post updates here myself if I find any improvements.
User avatar
Pugsy
Posts: 3686
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: dkong: Invincibility [fix] and more...

Post by Pugsy »

aycaramba wrote:As reported by Shima Pong - who is as wise as he is humble - the current invincibility cheat makes you die when you turn it off. I also notice that you can't grab the hammer, and being invincible with the hammer is really fun!

Code: Select all

        <cheat desc="Invincibility">
                <script state="on">
                        <action>temp0 = main.mw@1c57</action>
                        <action>temp1 = main.mw@2780</action>
                        <action>temp2 = main.mw@2819</action>
                        <action>temp3 = main.mw@2a1c</action>
                        <action>main.mw@1c57 = 1801</action>
                        <action>main.mw@2780 = 1804</action>
                        <action>main.mw@2819 = 1801</action>
                        <action>main.mw@2a1c = 1801</action>
                </script>
                <script state="off">
                        <action>main.mw@1c57 = temp0</action>
                        <action>main.mw@2780 = temp1</action>
                        <action>main.mw@2819 = temp2</action>
                        <action>main.mw@2a1c = temp3</action>
                </script>
        </cheat>
I had done a little work on a fixed dkong cheat a few weeks back but I hadn't got round to looking at falling/jumping off platforms. I think this reduced cheat poking just 2 addresses should work just fine. I'll give you full credit for this cheat - nice job btw.

Code: Select all

	<cheat desc="Invincibility">
		<script state="on">
			<action>temp0 =main.mw@1C57 AND temp1 =main.mb@2817</action>
		</script>
		<script state="run">
			<action>main.mw@1C57=1801</action> <!-- Falling -->
			<action>main.mb@2817=C9</action> <!-- Collisions -->
		</script>
		<script state="off">
			<action>main.mw@1C57=temp0 AND main.mb@2817=temp1 </action>
		</script>
	</cheat>
It may be a personal preference, but I set up my infinite lives cheat to return me to the number I had before it was turned on:
Yes that's a personal preference, the cheat file(s) don't return the value back to the original value to try to stick to the original guidelines for the cheats laid out by Marc Lafontaine (the programmer of the very first MAME cheat engine {0.129}).
The bonus timer cheat was the hardest to get right. Again, I want to be able to return the bonus I had before it was turned on. The current cheat affects game play, since you don't get that first wild barrel when the it's turned on. It also doesn't save you if the timer has already reached zero, although you have 4 seconds left to live.

My version freezes the timer, and you can resume if you choose, even at zero.

Code: Select all

        <cheat desc="Freeze Bonus Timer">
                <script state="on">
                        <action>temp0 = main.mb@06a9</action>
                        <action>main.mb@06a9 = 00</action>
                        <action>main.pb@6386 = 00</action>
                </script>
                <script state="run">
                        <action condition="(main.pb@62b1 == 1)">main.pb@62b1 = main.pb@62b0 - 1</action>
                </script>
                <script state="off">
                        <action>main.mb@06a9 = temp0</action>
                        <action>temp1 = (main.pb@638c - (main.pb@638c / 10) * 6)</action>
                        <action condition="(main.pb@6200 != 0)">main.pb@62b1 = temp1</action>
                        <action condition="(main.pb@6200 != 0) AND (temp1 == 0)">main.pb@6386 = 02</action>
                </script>
        </cheat>

The starting level selector puts you on the right level, but the screen progression is that of level 1 (barrels, rivets). If I'm skipping to L2 for elevators, there aren't any. This is better:

Code: Select all

        <cheat desc="Select Starting Level">
                <parameter min="2" max="99" step="1"/>
                <script state="change">
                        <action>main.mb@095e = (param)</action>
                        <action condition="(param == 2)">main.mb@095f = 67</action>
                        <action condition="(param == 3)">main.mb@095f = 6A</action>
                        <action condition="(param == 4)">main.mb@095f = 6E</action>
                        <action condition="(param GT 4)">main.mb@095f = 73</action>
                </script>
                <script state="off">
                        <action>main.mb@095e = 01</action>
                        <action>main.mb@095f = 65</action>
                </script>
        </cheat>
Both are nice fixes,thanks I'll add them.
Finally, I thought I'd mention that a lot of the examples I've seen seem to like the format:
1. [on] Save temp variables.
2. [run] Change bytes.
3. [off] Restore from temp variables.
A good example is the kill screen fix. It's a one-shot, but since all of the code is in "run", it gets reapplied every frame. It shouldn't have a run state:

Code: Select all

        <cheat desc="Fix Kill Screen Bug">
                <comment>Fixes the timer bug on level 22. See donhodges com how_high_can_you_get htm</comment>
                <script state="on">
                        <action>temp0 = main.mq@0F7D</action>
                        <action>temp1 = main.mq@0F85</action>
                        <action>main.mq@0F7D = 3E47043E023805FE</action>
                        <action>main.mq@0F85 = 000218FC100AC628</action>
                </script>
                <script state="off">
                        <action>main.mq@0F7D = temp0</action>
                        <action>main.mq@0F85 = temp1</action>
                </script>
        </cheat>
I shortened it a bit to fit into two qwords. (I had to remove the U-R-L punctuation to post that. Maybe an admin can put it back.)
There should never be a cheat with just "on" and "off" scripts.

All cheats that modify ROM code should be of "run" type - this is was a standard rule with the old cheats and as the conversion from old type to new type is automated and as the cheats work there is no reason to change them.

Additionally the one-shot type in the new cheat-engine is not handled ideally/correctly. It should be SET and not ON/OFF - if this gets fixed somewhere later down the line then the ROM "on" and "off" cheat you posted above will not function as it currently does ("off" will either get activated straight after "on" or not be available at all).
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
aycaramba
Posts: 9
Joined: Thu Jan 29, 2009 12:23 pm

I can still die

Post by aycaramba »

There are 4 ways to die in Donkey Kong, not counting the timer. The two you haven't patched only occur on elevators. Walking on the floor kills you, even if you survive the fall, and hitting your head on the bottom of an elevator will kill you. Have you ever hit the bottom corner of an elevator while jumping on and died? It can be hard to get, because if you get more side than bottom, you'll bounce off and fall instead. It's easy to test once you're invincible to the floor, because you can just jump under the down elevator.

I also got the following error when activating your version, "Error executing expression "temp0 =main.mw@1C57 AND temp1 =main.mb@2817": not an lvalue". The problem is that "AND" has more precedence than an assignment (=). You can still put them on the same line if you use a comma instead of AND (or parentheses), although clarity keeps me from doing this very often.

Code: Select all

   <cheat desc="Invincibility">
      <script state="on">
         <action>temp0 = main.mw@1C57</action>
         <action>temp1 = main.mb@2817</action>
         <action>temp2 = main.mb@277F</action>
         <action>temp3 = main.mb@2A1B</action>
         <action>main.mw@1C57 = 0118</action> <!-- Falling -->
         <action>main.mb@2817 = C9</action> <!-- Collisions -->
         <action>main.mb@277F = C9</action> <!-- Floor of Elevators -->
         <action>main.mb@2A1B = C9</action> <!-- Hitting your head -->
      </script>
      <script state="off">
         <action>main.mw@1C57 = temp0</action>
         <action>main.mb@2817 = temp1</action>
         <action>main.mb@277F = temp2</action>
         <action>main.mb@2A1B = temp3</action>
      </script>
   </cheat>
Notice I switched the byte order in the 1C57 line. That was my typo in the original post. I didn't catch it, because it worked anyway.

I still don't agree with putting code into "run" unnecessarily. It's fine for conversions, but with new cheats why follow old rules when the engine has changed drastically? Maybe one-shot was the wrong term for the kill screen fix. There are "set" cheats (only "on"), "write-once" cheats ("on" and "off"), and "write-many" cheats ("run"). I guess "one-shot" is the first type. The kill screen fix only needs to be written once, but you still have the option to turn it off. The same is true of invincibility above.

If things are going to change in the future, then I must be misunderstanding. The current rules I'm working with are from this comment by Aaron Giles:

"Switching from ?Off? to another state first executes the ?on? script followed by the ?change? script. Switching to ?Off? from another state executes the ?off? script. While not off, the ?run? script is executed each frame."
User avatar
aycaramba
Posts: 9
Joined: Thu Jan 29, 2009 12:23 pm

Post by aycaramba »

Oh, you're lurking? If you don't have much time to reply, I just wanted to be sure you realized that the additional two lines are required for "Invincibility". I have tested this. I hope you will include them.

Thanks.
User avatar
Pugsy
Posts: 3686
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Post by Pugsy »

No fear I did grab them, thanks. I was in the process of making a post a few days ago but a windows update forced a reboot along with my thoughts.

I appreciate your point with the script states, and it's possibly the way things will eventually get done. I do have my reasons, all of which don't hold water. But I still add as many cheats as possible into cheat.dat as it's still the best way of maintaining the xml cheat files. There's only a few cheats (like your 'Freeze Bonus Timer') that will only work with the new cheat format...and people still post in the old format as basic RAM cheat finding still only works in the old cheat engine.
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
jym
Posts: 91
Joined: Mon Nov 19, 2001 1:00 am
Location: Taiwan

Post by jym »

aycaramba, very thanks your cheat data.
Post Reply