News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: The Difficulty Settings Project  (Read 27222 times)

snarfblam

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 589
  • CANT HACK METROID
    • View Profile
    • snarfblam
Re: The Difficulty Settings Project
« Reply #20 on: July 23, 2012, 06:03:37 pm »
Why not pick something you are having trouble figuring out. One of us can check it out, and then explain how we approached the problem.

In the past, there have been situations where as a last resort, I just began disassembling everything. For example, start with the code that changes HP. Use the trace log to see code the routine was called from, and disassemble that. What routine calls that routine, and what other routines do they call? Just keep going until you find the code that handles defense. It gets pretty big and pretty confusing very quickly, so you need to keep detailed, organized notes. It also takes a lot of time.

That can be like digging through a haystack for a needle, though. (The upside is that you find all sorts of other potentially useful stuff along the way.) Like I said, for me it's a last resort. You learn tricks along the way that make help you avoid brute force techniques.

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #21 on: July 25, 2012, 12:58:53 pm »
snarfblam,

Would you mind showing me?  That would be quite helpful.  If I can see how it is done on one instance, it would be helpful everywhere else.

Let's do one example from TMNT2.  Using Tony H's suggestion on the Game Genie earlier on, I found that address 03EC10 controls the amount of damage you take when hit by an enemy.  If I use the Hex Editor to change the value in that address from 9D to 9E, you don't take damage.  However, if I change the value from 9D to 9C, the amount of damage you take increases substantially.  This is what I don't understand:  how could such a small change from the default value make such a massive difference?

I found the location where your current life is stored is 0568.  Using the Trace Logger to find where this value changes, I found where it is repeatedly used, but still can't understand where the new value is coming from.  Note that I used this function with the default 9D value in 03EC10, so make it easier to see changes.

Maybe I'm doing or figuring something wrong here.  But, how would you suggest proceeding with this specific example?  If I can see the reasoning in this instance, I should be able to figure this out elsewhere.

I feel like I'm learning a lot, but I also feel like I still have a lot further to go.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6885
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: The Difficulty Settings Project
« Reply #22 on: July 25, 2012, 03:58:29 pm »
When you're hacking is an ASM instruction. It's actually a 3-byte instruction 9D nn nn
STA $nnnn,x Or in your case, STA $0568,x.
(presumably 0568 is player 1's health and 0569 is player 2's health. X probably holds the player number (0 or 1). so, you are storing a value to RAM address 0568+x)
9C and 9E are undefined instructions on the NES' CPU, so that is why you'd see unexpected results when you change that.
"My watch says 30 chickens" Google, 2018

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #23 on: July 30, 2012, 01:32:57 pm »
Well, another week has now gone by, and I am continuing to make progress.  However, I am running into multiple instances where I just cannot figure something out.  If I was to give a very specific example of something I am having trouble with, along with the code I found that I cannot figure out, would one of you be able to help explain exactly what the code is doing?  I am getting stuck in several spots and can't seem to proceed.

I have had some success this past weekend, though, and have successfully adjusted certain values in several games to do what I wanted.  So, this is going along.  I can at least say that much.


snarfblam

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 589
  • CANT HACK METROID
    • View Profile
    • snarfblam
Re: The Difficulty Settings Project
« Reply #24 on: July 30, 2012, 08:23:41 pm »
You're obviously putting a lot of effort into this. I think we can all appreciate that. If you pick an example, I'll be glad to try and help.

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #25 on: July 31, 2012, 01:10:02 pm »
Actually, I think I've figured it out!  I couldn't figure out why changing a certain value was triggering new code to be run.  Using the Trace Logger, I was able to find two rogue lines of code that ran when changing a value that represents how much life you had, even though those two lines never ran in the original.  But, changing those values to EA to do nothing solved the problem.  So, this is now all figured out.

I am certainly glad to finally have that figured out.  That problem has been vexing me for over a week!

Thanks for the offer to help though, snarfblam.  I do appreciate that.
« Last Edit: August 06, 2012, 08:58:59 am by tog »

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #26 on: August 07, 2012, 02:58:22 pm »
It's been another week now, and I feel like I've made enough progress to start being more specific in my work.  So, I thought I'd list the games I've worked on so far and what I've done with them.

Note that these are the settings I created for the Easy mode.  I haven't started the Medium modes yet.

Castlevania 1 & 3:  Doubled starting life, starting hearts, starting # of lives.  Also, doubled recovery from recovery items and hearts

Journey to Silius:  Doubled starting life, starting # of lives, starting weapon energy.  Also, doubled recovery from recovery pellets, both life and energy

Ninja Gaiden 1, 2, 3:  Doubled starting life & starting # of lives.  Doubled recovery life from recovery items.  Cut Spiritual Power consumption in half.  In #3, doubled # of continues.

TMNT:  Doubled starting life.  Doubled amount of ammo regained from missiles, weapons, rope, and doubled life recovered from pizza.  Doubled amount of damage done to enemies from attacks

TMNT 2:  Doubled starting life & damage done to enemies.

TMNT 3:  Cut energy consumption & damage taken from enemies in half.  Doubled # of starting lives & # of continues.

I've also done a lot of work on the Double Dragon series, but haven't finished yet so I refrained from putting those games on this list.

I am still in the testing process and so am not ready to release anything yet.  But, I am getting there.  It is very true that all games are different.  Each one seems to have its own way of doing things (many of which do not make any sense at all), and sometimes unexpected things happen.  I've had to find and modify a lot of addresses in a few troublesome ones.  But, I've also learned some tricks in the process.

I'll keep at this, so there will be more updates later.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6885
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: The Difficulty Settings Project
« Reply #27 on: August 07, 2012, 03:26:10 pm »
For Ninja Gaiden 3, I'd recommend (if you can) give infinite continues for the "easy" version since that's what the Japanese version had (along with a password system, but I don't think you'd be able to restore that).
"My watch says 30 chickens" Google, 2018

Garoth Moulinoski

  • Hero Member
  • *****
  • Posts: 6290
  • Disliking that smoke.
    • View Profile
    • My Stuff including Super Smash Karts.
Re: The Difficulty Settings Project
« Reply #28 on: August 07, 2012, 04:40:57 pm »
Well, if the original Japanese version had a password system, then you could still compensate for that in the hack. Like, make enemies spawn less often, remove some enemies from certain places where they could give a new player a frustrating death (like an enemy who can hit you and throw you off the side of a platform).
Who will quote me next?
Disclaimer: If it sounds wrong, I may have been posting while asleep.

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #29 on: August 07, 2012, 05:07:55 pm »
I was thinking about the # of continues in Ninja Gaiden 3 when I modified that, being that #1&2 didn't have a finite number of them.  It probably is a good idea to, at minimum, give more than double the number of continues.  I will go ahead and do that.

I don't think I can really give infinite continues, since there is an entire screen that appears after you lose all of your lives that displays the number of continues you have left.  But, if I give enough of them, that shouldn't matter too much.

Any other thoughts?

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6885
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: The Difficulty Settings Project
« Reply #30 on: August 08, 2012, 03:31:04 pm »
More than likely it's possible to give the game infinite just by disabling the line of code that subtracts a continue.
(like, if you know the RAM address that stores the number of continues, set a Breakpoint in FCEUX debugger for when that address is written after a Game Over. It will show the instruction that changes the number of continues.
Spoiler:
DEC $EE at CPU address $CBA7 or ROM address $1CBB7.
It is followed by BPL $CBDA. (branch if positive value) While we probably could just remove that, because the game came here from a jump instruction, it would be more correct to replace these 4 bytes with an explicit jump.
JMP $CBDA: NOP, or 4C DA CB EA)
As to the number you could mod it to not print it, but admittedly that is a more advanced skill that will require a little ASM knowledge.
Spoiler:
Again, use FCEUX trace logger. Run it while the game is loading the Game Over screen. Stop after it appears.
The game had to read our number of continues to print it.
So, open the trace log and do a search for "$00EE".
It turns up in this function:
Code: [Select]
$AB05:BD 23 AB  LDA $AB23,X @ $AB28 = #$00 A:05 X:05 Y:0C S:FB P:nvUbdizC
$AB08:9D EE 05  STA $05EE,X @ $05F3 = #$10 A:00 X:05 Y:0C S:FB P:nvUbdiZC
$AB0B:CA        DEX                        A:00 X:05 Y:0C S:FB P:nvUbdiZC
$AB0C:10 F7     BPL $AB05                  A:00 X:04 Y:0C S:FB P:nvUbdizC
$AB05:BD 23 AB  LDA $AB23,X @ $AB27 = #$00 A:00 X:04 Y:0C S:FB P:nvUbdizC
$AB08:9D EE 05  STA $05EE,X @ $05F2 = #$0A A:00 X:04 Y:0C S:FB P:nvUbdiZC
$AB0B:CA        DEX                        A:00 X:04 Y:0C S:FB P:nvUbdiZC
$AB0C:10 F7     BPL $AB05                  A:00 X:03 Y:0C S:FB P:nvUbdizC
$AB05:BD 23 AB  LDA $AB23,X @ $AB26 = #$00 A:00 X:03 Y:0C S:FB P:nvUbdizC
$AB08:9D EE 05  STA $05EE,X @ $05F1 = #$22 A:00 X:03 Y:0C S:FB P:nvUbdiZC
$AB0B:CA        DEX                        A:00 X:03 Y:0C S:FB P:nvUbdiZC
$AB0C:10 F7     BPL $AB05                  A:00 X:02 Y:0C S:FB P:nvUbdizC
$AB05:BD 23 AB  LDA $AB23,X @ $AB25 = #$0F A:00 X:02 Y:0C S:FB P:nvUbdizC
$AB08:9D EE 05  STA $05EE,X @ $05F0 = #$CB A:0F X:02 Y:0C S:FB P:nvUbdizC
$AB0B:CA        DEX                        A:0F X:02 Y:0C S:FB P:nvUbdizC
$AB0C:10 F7     BPL $AB05                  A:0F X:01 Y:0C S:FB P:nvUbdizC
$AB05:BD 23 AB  LDA $AB23,X @ $AB24 = #$25 A:0F X:01 Y:0C S:FB P:nvUbdizC
$AB08:9D EE 05  STA $05EE,X @ $05EF = #$24 A:25 X:01 Y:0C S:FB P:nvUbdizC
$AB0B:CA        DEX                        A:25 X:01 Y:0C S:FB P:nvUbdizC
$AB0C:10 F7     BPL $AB05                  A:25 X:00 Y:0C S:FB P:nvUbdiZC
$AB05:BD 23 AB  LDA $AB23,X @ $AB23 = #$02 A:25 X:00 Y:0C S:FB P:nvUbdiZC
$AB08:9D EE 05  STA $05EE,X @ $05EE = #$09 A:02 X:00 Y:0C S:FB P:nvUbdizC
$AB0B:CA        DEX                        A:02 X:00 Y:0C S:FB P:nvUbdizC
$AB0C:10 F7     BPL $AB05                  A:02 X:FF Y:0C S:FB P:NvUbdizC
$AB0E:A5 EE     LDA $00EE = #$05           A:02 X:FF Y:0C S:FB P:NvUbdizC
$AB10:8D F2 05  STA $05F2 = #$00           A:05 X:FF Y:0C S:FB P:nvUbdizC
$AB13:A5 EF     LDA $00EF = #$00           A:05 X:FF Y:0C S:FB P:nvUbdizC
$AB15:8D F1 05  STA $05F1 = #$00           A:00 X:FF Y:0C S:FB P:nvUbdiZC
It looks like the game is generating a string at RAM address $05EE. First byte is the string length. The next two bytes are the VRAM address to write to (you can alter it if you want to change the position on the screen), the next two are the hex values for the two "0" tiles (which would be overwritten by the tile numbers for the two digits in the number of continues).
I guess the last zero is an "end" marker.
Since $00EE and $00EF is the two digits for our number of continues, just NOP the codes that write them to the text (replace $AB10-AB12 (which do a hex search on the hex values of the instructions to find out it is ROM address $AB20) with $EA (NOP) as well as AB15-AB17)
Now, ROM address $AB33 is the string that will be printed. So, the simple way to solve the now-unneeded number of continues from being printed is to replace address $AB36-AB37 with a blank tile (such as 3F, which the rest of the screen uses)
Or, examine the code that next reads $05EE, where this string is stored, we see we could just give the string a length of 0 to make it not print.)
« Last Edit: August 08, 2012, 03:39:40 pm by KingMike »
"My watch says 30 chickens" Google, 2018

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #31 on: August 09, 2012, 11:19:22 am »
KingMike,

Thank you very much for that idea and corresponding explanation!  I worked on that, and have successfully removed the # of continues on the screen.  I also gave unlimited continues as well.  So, now, anyone playing this game would be completly unaware that there ever was a finite number of continues.

One other thing I also did on NG2&3 was to stop the game from putting you back several stages if you lose to the final boss.  I have no idea what the developers were thinking-forcing you to go through multiple difficult stages again upon losing to an almost-impossible to beat boss...  But, that is now gone.  If you lose to the final boss, you will merely start at the previous area just like if you lose to any other boss in the game.  I am going to work on this with NG1 as well, but that one is more difficult because of the way the game keeps track of what part of the stage you're on, so give me a little more time with that one.

I guess I do have one other question, though.  Where would I find the code that changes how your life is displayed?  This is the only piece I have left in many games.  In NG, for example, your life is displayed by bars, with each bar representing one unit of health.  Being that I doubled the amount of health you have from 16 to 32, the bar stays full until you drop below 16 units.  I'd like to try to get that changed to full at 32 units if possible.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6885
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: The Difficulty Settings Project
« Reply #32 on: August 09, 2012, 08:28:07 pm »
Going to be incredibly difficult with NG1. I actually tried to make a Game Genie level-select code and I couldn't.
(as I recall, the current level is stored at RAM $006E.)
The game relies on the RAM initialization routine to put that at 0 (representing level 1-1). The level number appears to be changed entirely through INCrement and DECrement instructions (and when it switches a level, it finds and loads the starting map for that level, which is why dying against a boss sends you back to the start of the previous sub-level rather than the last checkpoint). The only code I found to explicitly set the level number is the code that checks when you die. It checks if you are on one of the final boss stages (6-4+) and sends you back to 6-1 if you were.
"My watch says 30 chickens" Google, 2018

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #33 on: August 10, 2012, 08:42:00 am »
Actually, I've figured out how to do this on NG1.  I had to add some code to get this to work, but I saw where the game checks the 006E value to see if you were at 6-4 or above, then executes some code only if you were.  I put a JMP code in that particular code that only runs at 6-4+ to move to an area that wasn't defined (that had only FF values in the code), then put some code in that area to set the 006E & 006F values to have you at the last checkpoint before the boss, then another JMP code at the end of that to move back to after the 006E & 006F values are set with the A and X values.
« Last Edit: August 10, 2012, 08:51:08 am by tog »

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #34 on: August 17, 2012, 09:18:36 am »
I thought I would give another status update on this.

I've completely finished and tested Ninja Gaiden 1, and it is ready to go.  NG2&3 are pretty much done, but I need to do more testing before I can say they are complete.

Would anyone like me to release what I've done on NG1?  This will be my first one, so I'm not sure if anyone wants to see what I have beforehand.  If so, I can do it next week, so just let me know.

An interesting project indeed.
I can join it(NES only). I have no problem with making a in-game difficulty menu(if there's enough empty PRG space left).
I can also make more advanced things like changing  size of hitboxes and such(If needed).

I don't know if you are still interested in doing this or not.  All I've done so far are the Easy modes.  It will likely be a while before I start the Medium modes.  Should we wait until I have everything done before doing anything?  Or, should I just make a separate release for each difficulty setting instead, since that would be easier?

Dizzy9

  • Jr. Member
  • **
  • Posts: 38
    • View Profile
Re: The Difficulty Settings Project
« Reply #35 on: August 17, 2012, 03:56:11 pm »
I don't know if you are still interested in doing this or not.
I was interested at start and made two patches for two games. Right now, I lost part of my enthusiasm.
Since back then I wasn't given a particular title to work on, I picked them on my own.
First one:
Linus Spacehead's Cosmic Crusade Zero Arcade
It's a very simple hack that just turns off all arcade levels in game.
Easy, simple and efficient.

The second hack is more advanced.
Darkwing Duck
This hack adds a menu with four difficulty options:
 Easy
 Normal
 Hard
 Hell
And here's differences between the options:
Easy[/b]
Player HP: 8
Boss HP: 8
Boss Invisibility time(In frames): 10

Normal[/b]
Player HP: 4
Boss HP: 15
Boss Invisibility time(In frames): 30

Hard[/b]
Player HP: 2
Boss HP: 19
Boss Invisibility time(In frames): 46

Hell[/b]
Player HP: 1
Boss HP: 31
Boss Invisibility time(In frames): 80

I wanted to make any HP replenishment to be turned into gold on hell but it's too easy to overclock points counter.

I can release the hacks at any time but I'm not sure what to write about "The Difficulty Settings Project " in my readme.txt.

Quote
All I've done so far are the Easy modes.  It will likely be a while before I start the Medium modes.  Should we wait until I have everything done before doing anything?  Or, should I just make a separate release for each difficulty setting instead, since that would be easier?
Why should I wait for you to finish? Just give me a title, list of things to improve and, if I'll have enough time and experience(I'm not best hacker out there), I'll do it.
You also can ask me to help you with some things, if needed.

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #36 on: August 17, 2012, 05:13:40 pm »
I think we might have had a slight miscommunication with this.  I thought you would be able to produce the in-game difficulty menu with the changes I made per difficulty setting.  Is that something you are still interested in doing?  That is what I was referring to.  The reason I asked about waiting is that I only have the Easy modes done right now and wasn't going to start the Medium modes for a while.

I apologize for the misunderstanding and/or confusion in regards to this.

Anyway, I won't be back here for a few days, so let me know what you think.

Dizzy9

  • Jr. Member
  • **
  • Posts: 38
    • View Profile
Re: The Difficulty Settings Project
« Reply #37 on: August 18, 2012, 12:21:56 pm »
I think we might have had a slight miscommunication with this.  I thought you would be able to produce the in-game difficulty menu with the changes I made per difficulty setting.  Is that something you are still interested in doing?
No.
And I'll tell you why. Hacking in a menu with difficulty selection is done by rewriting some functions to behave differently. What you'll give me(probably) will be ips patches with changed values only.
Let's make an example on typical Boss with HP:
In normal, no hacked, game  it's like this:
0.(At start of Boss fight) Set Boss's HP to (let's say) 10.
1.Check If boss's HP is 0
2.If YES, then kill boss.
3.If NO, then  do Boss logic.

In IPS patches you usually just need to change the step's 0 "10 HP" value. But if there's a possibility of different difficulty then it's more complicated(especially, if there's more than two).

(At start of Boss fight)
0.Check the difficulty setting.
1.Use the number of difficulty to pull the desired Boss's HP value.
3.Set Boss's HP to (let's say) 10.
   Do rest of logic as usual.

See? Even if you give ma all patches then I'll have to find all differences between normal(no hacked) version and patched one.
In other words- working like this just wastes your work 'cause I'll have to write everything from scratch anyway.


tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #38 on: August 20, 2012, 02:21:16 pm »
Okay.  It sounds like putting in a menu would be a lot more trouble than it is worth.  I'll just release one ips file for each difficulty setting then.  That'll work just fine.

I've finished testing NG2&3 now.  So, the entire Ninja Gaiden trilogy is now ready.  If anyone wants me to post these patches right here, just let me know.  Otherwise, I'm going to go switch to something else.

tog

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: The Difficulty Settings Project
« Reply #39 on: August 27, 2012, 02:59:18 pm »
Here is another weekly update I could provide, in case anyone is still interested in and following this.

Most of my work recently has been on the Double Dragon trilogy.  I've finished up and tested Double Dragon 1, so that one is all ready to go.  I've gotten most of Double Dragon 2 completed, but still need to get that one fully tested before I'll be ready to say that one is ready.  I got some work done on Double Dragon 3, but that one is incomplete.  I'll finish DD3 up after finalizing DD2.