News: 11 March 2016 - Forum Rules

Author Topic: Battle of Olympus - Rebalanced + SRAM Saving  (Read 20740 times)

8.bit.fan

  • Sr. Member
  • ****
  • Posts: 317
    • View Profile
    • 8-bit fan's Hacking Projects
Battle of Olympus - Rebalanced + SRAM Saving
« on: July 19, 2017, 02:54:39 pm »
Hi Everyone,
Since I'm taking a break from hacking MM games, I thought I'd try to hack my other NES favorites and try to "modernize" them. And since I really only have experience hacking MM games, I'd consider myself pretty much a complete newbie in the hacking scene and could use some help!

So, is anyone here familiar with hacking The Battle of Olympus for the NES?

I've always wanted to hack the game to make it more accessible to novice players or just make it more casually playable. I love the game, but some of the in-game items costs quite a bit and grinding for olives can be very time consuming at times and can take the fun out of the game. Not to mention you lose 1/2 of the olives when you die.

Just wondering if anyone knows how to, or where in the hex to edit, to increase the drop rate of olives in the game? Or how to remove losing 1/2 the olives when you die?

Thanks in advance and any help or if anyone can point me in the right direction would be much appreciated! :)

Once I can figure out how to do the above, I'd also like to add an SRAM option instead of the cumbersome password system...but that'll be for later as I don't even know if I can accomplish the above.

Cheers! :)

8-bit fan

UPDATE 7/24/2017:

The beta is ready for anyone that wants to check it out.
Here's the IPS:
http://www.romhacking.net/scratchpad/8112/
https://drive.google.com/open?id=0B3c4zWxe_g5ONmVjY0pyVGxKb0E

Things done so far:
1) 1/8 of olives taken away instead of 1/2 upon death.
2) Increased olives/bay leaves drop rate.
3) Save Game when speaking to the gods.
4) Load Game by hitting START at the password input screen.

I was able to change the text at the password screen to tell the player to hit START to LOAD GAME. I also wanted to change the text when speaking to the gods to tell the user that the game has been saved, but I can't seem to find where in the ROM that's located.

Does anyone know how to change:
   
Quote
"Hear the word of the gods. Don't forget it."
to:
   
Quote
"Hear the word of the gods. Game Saved."
?

I've also play tested it for a while and everything seems to be in working order, and you still have the option to use your own passwords!  :D

What I'd like to do still:
1) Further optimize the LOAD function. Having an empty password screen while hitting START to LOAD the game seems a little weird. Because I do want to keep the option to input your own password, I'd like to somehow have the saved game password autofill on the password screen.
2) Text change at the gods from "Don't forget it" to "Game Saved".
3) Remove gap at the shore in Argolis so that the player can access the Dolphin in the area.


Any suggestions and/or input are welcomed and much appreciated! :)




Thanks!! :)

8-bit fan


Update 7/26/2017:
Latest version(0.9) IPS:
https://drive.google.com/open?id=0B3c4zWxe_g5OUWJiV3FqNE5wMUk


Update 7/27/2017:
Here's the latest version(0.99) IPS:
https://drive.google.com/open?id=0B3c4zWxe_g5OaUZtcklSS3JITkk

Things completed:
1) 1/8 olives penalty instead of 1/2 upon death.
2) Increased olives drop rate by 2x, bay leaves remain the same - this is for the most part.
3) Save Game when speaking to the gods.
4) Load Game by hitting START at the password input screen.
5) Texts additions, changes, and added credits to those that helped with the hack!

Cheers!  :beer:
« Last Edit: July 27, 2017, 04:41:34 pm by 8.bit.fan »
In the year of 200X, a super robot named Mega Man...
http://www.8bitfan.info/
FF4 Ultima Discord: https://discord.gg/4MqjwJt

nesrocks

  • Hero Member
  • *****
  • Posts: 732
    • View Profile
    • nesrocks.com
Re: Battle of Olympus - Hacking Help
« Reply #1 on: July 19, 2017, 03:26:55 pm »
Never hacked the game, but to eliminate the losing half olives when dying you can try this:
First you locate the RAM adress for the olive counter.
Then you set fceux's debugger to stop on writes to that counter.
When you die you should get to a routine that writes to that address after manipulating it's value to be halved. Simply change the write to EA EA (or EA EA EA).

8.bit.fan

  • Sr. Member
  • ****
  • Posts: 317
    • View Profile
    • 8-bit fan's Hacking Projects
Re: Battle of Olympus - Hacking Help
« Reply #2 on: July 19, 2017, 03:47:43 pm »
Never hacked the game, but to eliminate the losing half olives when dying you can try this:
First you locate the RAM adress for the olive counter.
Then you set fceux's debugger to stop on writes to that counter.
When you die you should get to a routine that writes to that address after manipulating it's value to be halved. Simply change the write to EA EA (or EA EA EA).
Thanks for the reply and help nesrocks!
As a newbie, this is a bit way over my head, but I understand the concept on what I need to do. I just need to learn how to use the "tools" to get the RAM address, routine, etc. I'm using FCEUX and got all the debugging windows open...I'll play around with it a bit.

Thanks again! And thanks for the great Super Pitfall hack! I love what you did with it and play it all the time! :)

8-bit fan
In the year of 200X, a super robot named Mega Man...
http://www.8bitfan.info/
FF4 Ultima Discord: https://discord.gg/4MqjwJt

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7183
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Battle of Olympus - Hacking Help
« Reply #3 on: July 19, 2017, 04:40:26 pm »
There are cheat-maker tutorials that will tell you how to find the RAM address.

But the simple thing is:
(I think FCEUX has a "Cheat Finder", so I'll describe it.)
Load up the cheat finder once. Click Start or something.
Play the game until your olive count changes.
Then open up the Cheat Finder and click the button for new value being higher/lower than it was the first time.
Repeat the last two until you get just one or a few results.
"My watch says 30 chickens" Google, 2018

8.bit.fan

  • Sr. Member
  • ****
  • Posts: 317
    • View Profile
    • 8-bit fan's Hacking Projects
Re: Battle of Olympus - Hacking Help
« Reply #4 on: July 19, 2017, 04:57:53 pm »
There are cheat-maker tutorials that will tell you how to find the RAM address.

But the simple thing is:
(I think FCEUX has a "Cheat Finder", so I'll describe it.)
Load up the cheat finder once. Click Start or something.
Play the game until your olive count changes.
Then open up the Cheat Finder and click the button for new value being higher/lower than it was the first time.
Repeat the last two until you get just one or a few results.
Hi KingMike,
Thanks so much for the help and the step by step instruction!
I'll give this a try! :)

8-bit fan
In the year of 200X, a super robot named Mega Man...
http://www.8bitfan.info/
FF4 Ultima Discord: https://discord.gg/4MqjwJt

Psyklax

  • Hero Member
  • *****
  • Posts: 1112
    • View Profile
    • Psyklax Translations
Re: Battle of Olympus - Hacking Help
« Reply #5 on: July 19, 2017, 05:02:38 pm »
open up the Cheat Finder and click the button for new value being higher/lower than it was the first time.
Repeat the last two until you get just one or a few results.

Not to mention that something like olive count will probably be obvious - it'll probably be the same number but in hexadecimal rather than decimal, so 25 would be 19 for example (I've never played the game, just making an educated guess).

As for what nesrocks said, in case it's not clear, he's saying you need to find an instruction that halves the olive count (so breakpoint on a write to that olive count address) and replace it with NOP instructions (No OPeration), which is EA. Therefore the game will ignore the halving instruction. It'll be quite simple, really. :) Well, probably.

8.bit.fan

  • Sr. Member
  • ****
  • Posts: 317
    • View Profile
    • 8-bit fan's Hacking Projects
Re: Battle of Olympus - Hacking Help
« Reply #6 on: July 19, 2017, 05:17:34 pm »
Thanks everyone! I found the RAM location where # of Olives is stored! :)
I was able to "freeze" it and manually set it to an arbitrary number to test this out also. Now to change to instruction...

Not to mention that something like olive count will probably be obvious - it'll probably be the same number but in hexadecimal rather than decimal, so 25 would be 19 for example (I've never played the game, just making an educated guess).

As for what nesrocks said, in case it's not clear, he's saying you need to find an instruction that halves the olive count (so breakpoint on a write to that olive count address) and replace it with NOP instructions (No OPeration), which is EA. Therefore the game will ignore the halving instruction. It'll be quite simple, really. :) Well, probably.
Hi Psyklax!
Thanks for the help! :)
So looks like the first thing I'll need to find is where in the HEX the instruction that halves the olives is located. After thinking about this, removing the penalty entirely might make it too easy, so instead, I might try to change it from removing 1/2 olives to removing 1/10 olives or just 5 olives.

I'll keep working on this...

8-bit fan

July 19, 2017, 05:55:58 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
I'd like to thank everyone for your pointers and help. I was able to remove the instruction to half the olives when you die for the game! :D

Thank you all so much! When I do release this hack, I will put everyone's name in the credits for sure! :)

Now, let's see if I can play with the numbers to make take away 1/10 of the olives instead...

8-bit fan
« Last Edit: July 19, 2017, 05:55:58 pm by 8.bit.fan »
In the year of 200X, a super robot named Mega Man...
http://www.8bitfan.info/
FF4 Ultima Discord: https://discord.gg/4MqjwJt

nesrocks

  • Hero Member
  • *****
  • Posts: 732
    • View Profile
    • nesrocks.com
Re: Battle of Olympus - Hacking Help
« Reply #7 on: July 19, 2017, 06:03:48 pm »
That was fast, congrats  :beer:

There probably won't be enough bytes to replace a halving instruction with a 1/10 instruction. Halving is a 1 byte instruction called LSR. Since there is no 1 byte long instruction to 1/5 or 1/10 it is easy to see why it would be a problem to do anything else to the value. The thing about hacking the assembly like this is that you need to write over bytes, you can't insert them. And in this case you want to write over bytes that are no longer useful to you, meaning just the LSR one.

So if you really want to do 1/5 or 1/10 you'd need to point it to an empty space in the ROM (using a JSR instruction), do the new math there and send the code back to continue the original routine (using an RTS instruction), which is a bit more advanced.

Your other options:
1 - make it so the olives drop more often, as you said earlier
2 - collecting an olive give more than 1 olive (two). This could maybe make it too easy too, but not as easy as losing nothing on death.
3 - change the price of things. This could be easier to do, but requires going through everything that costs olives and rebalancing.
« Last Edit: July 19, 2017, 06:12:36 pm by nesrocks »

Psyklax

  • Hero Member
  • *****
  • Posts: 1112
    • View Profile
    • Psyklax Translations
Re: Battle of Olympus - Hacking Help
« Reply #8 on: July 19, 2017, 06:06:24 pm »
Just a quick update from me. :D I just spent the last ten minutes doing what was suggested already (and in that time I've seen that you've already done something on this! :D ). I found that the olive count is stored in $E0 and $E1 - for some reason it uses a byte for each digit, perhaps it's easier to print on-screen or something, but if you change $E0 to something in hex and leave $E1 at 0, it'll change to that number when you pause/unpause (it goes through a routine of printing the numbers correctly.

So I gave myself olives then killed myself, and because I'd set a breakpoint (FCEUX's debugger, Add Breakpoint, read or write $E0-E1), I saw the operations that halve the olive count (FYI, the key operation is LSR or Logical Shift Right, meaning the eight bits in a byte shift one position to the right, effectively halving the number). So when the time came to write the two new numbers to memory, I just changed the operations to EA EA, instead of 85 E0 and 85 E1. Voila, you no longer lose any olives at all. :)

Of course, your suggestion of only losing 10% would require more hacking, as you'll have to modify the mathematical operation. And that'll take a little longer than the last ten minutes I've spent on this. :D

Still, I hope I've given you a start on this. Assembly language on the NES is relatively simple, and FCEUX makes hacking sooo much easier.

EDIT: crikey, I just read all of your post, you did figure it out pretty fast. :D Well, never mind then. ;)

nesrocks

  • Hero Member
  • *****
  • Posts: 732
    • View Profile
    • nesrocks.com
Re: Battle of Olympus - Hacking Help
« Reply #9 on: July 19, 2017, 06:16:53 pm »
This page is a gold mine for you:
http://tasvideos.org/GameResources/NES/BattleOfOlympus.html

I did a TAS of this game 10 years ago, and it has been updated by Arc recently (he credited me on his new TAS, which was nice). Anyway, someone wrote the details of some of the game's inner mechanics in that page, including exactly how the item drop RNG works, so bingo :)

abw

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Re: Battle of Olympus - Hacking Help
« Reply #10 on: July 19, 2017, 06:45:19 pm »
Your other options:
[...]
3 - change the price of things. This could be easier to do, but requires going through everything that costs olives and rebalancing.
As it happens, Battle of Olympus hardcoded the prices of items into its script, so this would also involve updating the sections of the script where NPCs tell you how much things cost (e.g. Hephaestos says "I'll give you my Sword for 70 olives."), and if you have to start by figuring out how the game's text engine works, successfully making dialogue changes is going to require some very non-trivial effort. The good news in this case is that if all you want to do is make in-place edits to a couple of numbers, you only need to modify a couple of bytes; I'd be willing to help with that if you end up going this route.

8.bit.fan

  • Sr. Member
  • ****
  • Posts: 317
    • View Profile
    • 8-bit fan's Hacking Projects
Re: Battle of Olympus - Hacking Help
« Reply #11 on: July 19, 2017, 07:42:44 pm »
Alright!
Thanks nesrocks and Psyklax for the explanation on the LSR instruction! And, like you've said, since LSR to half the olives is as easy as 1 instruction, removing 1/10 would require more coding, and I'm not quite there yet. So I figured, if the instruction uses LSR operation, I can just use that for the tens digit, and overwrite the singles digit with the result, effectively removing 5% of the olives. So I guess it's a good thing that they split up the 2 digits! Anyhow, so it's not quite 10% but it's better than no penalty at all! The only problem is, if youhave less than 10 olives, you'll end up with zero olives. This is fine as getting your olives back up over 10 isn't bad, and if you already have more than 10 olives then you're all set. However, though, this feels incomplete and kind of "hacky"(pun not intented ;)). What do you all think?

That was fast, congrats  :beer:

There probably won't be enough bytes to replace a halving instruction with a 1/10 instruction. Halving is a 1 byte instruction called LSR. Since there is no 1 byte long instruction to 1/5 or 1/10 it is easy to see why it would be a problem to do anything else to the value. The thing about hacking the assembly like this is that you need to write over bytes, you can't insert them. And in this case you want to write over bytes that are no longer useful to you, meaning just the LSR one.

So if you really want to do 1/5 or 1/10 you'd need to point it to an empty space in the ROM (using a JSR instruction), do the new math there and send the code back to continue the original routine (using an RTS instruction), which is a bit more advanced.

Your other options:
1 - make it so the olives drop more often, as you said earlier
2 - collecting an olive give more than 1 olive (two). This could maybe make it too easy too, but not as easy as losing nothing on death.
3 - change the price of things. This could be easier to do, but requires going through everything that costs olives and rebalancing.
Thanks, nesrocks! :)
Your other suggestions are great too!
1-I'll see if I can make olives drop more often. I also thought about increasing healing of Bay Leaves from 1 to 2. But that, again, might make the game too easy.
2-I also thought about this. This would definitely make it much easier at the beginning and maybe too easy like you said.
3-Agreed on the rebalancing. So I'd rather not mess with this for now.

This page is a gold mine for you:
http://tasvideos.org/GameResources/NES/BattleOfOlympus.html

I did a TAS of this game 10 years ago, and it has been updated by Arc recently (he credited me on his new TAS, which was nice). Anyway, someone wrote the details of some of the game's inner mechanics in that page, including exactly how the item drop RNG works, so bingo :)
This is awesome!
Thank you so much for this!
Now let's see if I can mess with the drop rate. :)

Just a quick update from me. :D I just spent the last ten minutes doing what was suggested already (and in that time I've seen that you've already done something on this! :D ). I found that the olive count is stored in $E0 and $E1 - for some reason it uses a byte for each digit, perhaps it's easier to print on-screen or something, but if you change $E0 to something in hex and leave $E1 at 0, it'll change to that number when you pause/unpause (it goes through a routine of printing the numbers correctly.

So I gave myself olives then killed myself, and because I'd set a breakpoint (FCEUX's debugger, Add Breakpoint, read or write $E0-E1), I saw the operations that halve the olive count (FYI, the key operation is LSR or Logical Shift Right, meaning the eight bits in a byte shift one position to the right, effectively halving the number). So when the time came to write the two new numbers to memory, I just changed the operations to EA EA, instead of 85 E0 and 85 E1. Voila, you no longer lose any olives at all. :)

Of course, your suggestion of only losing 10% would require more hacking, as you'll have to modify the mathematical operation. And that'll take a little longer than the last ten minutes I've spent on this. :D

Still, I hope I've given you a start on this. Assembly language on the NES is relatively simple, and FCEUX makes hacking sooo much easier.

EDIT: crikey, I just read all of your post, you did figure it out pretty fast. :D Well, never mind then. ;)
Thanks, Psyklax! :)
I also found it weird that they split up the 2 digits, but because of this I was able to "hack" the calculations so that the olives are removed by a 5% upon continue so it's not all bad! And agreed, FCEUX makes this much easier. Thanks again for the pointers!

As it happens, Battle of Olympus hardcoded the prices of items into its script, so this would also involve updating the sections of the script where NPCs tell you how much things cost (e.g. Hephaestos says "I'll give you my Sword for 70 olives."), and if you have to start by figuring out how the game's text engine works, successfully making dialogue changes is going to require some very non-trivial effort. The good news in this case is that if all you want to do is make in-place edits to a couple of numbers, you only need to modify a couple of bytes; I'd be willing to help with that if you end up going this route.
Hi abw and thanks for the info and your offer to help! :)
I might go this route, depending on how far I get with the olives drop rate I mentioned above. Thanks in advance!

8-bit fan

July 19, 2017, 08:01:17 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Hmmm...actually I did my math all wrong. It's not 5%, it's actually just 1/2 of the tens digit. So if you had 48 olives, you'll end up with 42. If you had 29 olives, you'll end up with 21. So this formula is not very good...  :-\

July 19, 2017, 08:05:32 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Would an operation of removing a static amount of olives be just as simple as an LSR one?
« Last Edit: July 19, 2017, 08:05:32 pm by 8.bit.fan »
In the year of 200X, a super robot named Mega Man...
http://www.8bitfan.info/
FF4 Ultima Discord: https://discord.gg/4MqjwJt

nesrocks

  • Hero Member
  • *****
  • Posts: 732
    • View Profile
    • nesrocks.com
Re: Battle of Olympus - Hacking Help
« Reply #12 on: July 19, 2017, 08:10:54 pm »
Can you post the code the game uses or the ROM address this takes place in?
For subtraction you use SBC. In total it takes 3 bytes.

18    SEC  (set the carry flag to true. in general this needs to be done before subtraction)
E9 02    SBC #02 (subtract the accumulator by 2)

The problem is this needs to break to a routine that does the decimal math to the tens digit when it goes under 0, because when you subtract to the ones digit and it goes under 0 it has extra things to do. Which is why it would be good to see the game's code.
« Last Edit: July 19, 2017, 08:22:19 pm by nesrocks »

8.bit.fan

  • Sr. Member
  • ****
  • Posts: 317
    • View Profile
    • 8-bit fan's Hacking Projects
Re: Battle of Olympus - Hacking Help
« Reply #13 on: July 19, 2017, 08:17:45 pm »
Sure, the ROM location for the 2 instructions:

01C287-01C288 : 85 E0
01C289-01C28A : A5 02
01C28B-01C28C : 85 E1
01C28D-01C28E : A5 EF

E0 is for the singles digit and E1 is for the tens digit for the amount of olives. Yeah they split up the 2 digits.

Thanks in advance! :)
In the year of 200X, a super robot named Mega Man...
http://www.8bitfan.info/
FF4 Ultima Discord: https://discord.gg/4MqjwJt

nesrocks

  • Hero Member
  • *****
  • Posts: 732
    • View Profile
    • nesrocks.com
Re: Battle of Olympus - Hacking Help
« Reply #14 on: July 19, 2017, 08:57:56 pm »
Code: [Select]
07:C269:20 6A D7  JSR $D76A
This sub routine ($D76A) is fed the accumulator value and returns that decimal number * 10 converted to hex. So if you have 80 + olives, this will return a number of #50 which is 80 in hex. Then it adds to the ones digit (which don't need to be converted to hex because 0-9 are directly equal to their hex equivalents) and does the LSR to the result, halving it. So now you have the total number of olives, in hex, halved.

Code: [Select]
07:C274:20 85 D7  JSR $D785
Then this one does the opposite and returns the ones digit on the accumulator and the tens digit on address $2, and then passes those to $E0 and $E1 respectively.

What this means is that this whole area can be replaced with new math:

Code: [Select]
07:C265:A5 E1     LDA $00E1 = #$08
 07:C267:A2 0A     LDX #$0A
 07:C269:20 6A D7  JSR multiply
 07:C26C:A5 03     LDA $0003 = #$00
 07:C26E:18        CLC
 07:C26F:65 E0     ADC $00E0 = #$06
 07:C271:4A        LSR
 07:C272:A2 0A     LDX #$0A
 07:C274:20 85 D7  JSR divide
 07:C277:85 E0     STA $00E0 = #$06
 07:C279:A5 02     LDA $0002 = #$00
 07:C27B:85 E1     STA $00E1 = #$08

That's 24 bytes!

So what I usually do here is change all of those to EA and then start writing. Just so you get the feel of "I can do anything!" try this:
Code: [Select]
07:C265: A9 09 LDA #$09
 07:C267: 85 E0 STA $00E0
 07:C269: 85 E0 STA $00E1
(fill the rest with EA up to C27C)

One important thing to notice is that if you were writing assembly code the correct way, you'd write LDA #09 and the compiler would transform that to A9 09 for you, because you're using LDA in immediate mode (you're feeding it a direct value, indicated by #). If you wrote LDA $09 (notice the $ instead of #) you'd be telling it to load the value stored on address $9 and copy it to the accumulator which would compile A5 09 instead of A9 09. But we're doing things backwards here, so you need to pay attention to which type of LDA you want (A5, A9 or others). http://www.6502.org/tutorials/6502opcodes.html
« Last Edit: July 20, 2017, 11:14:38 pm by nesrocks »

8.bit.fan

  • Sr. Member
  • ****
  • Posts: 317
    • View Profile
    • 8-bit fan's Hacking Projects
Re: Battle of Olympus - Hacking Help
« Reply #15 on: July 19, 2017, 09:12:09 pm »
Code: [Select]
07:C269:20 6A D7  JSR $D76A
This sub routine ($D76A) is fed the accumulator value and returns that decimal number * 10 converted to hex. So if you have 80 + olives, this will return a number of #50 which is 80 in hex. Then it adds to the ones digit (which don't need to be converted to hex because 0-9 are directly equal to their hex equivalents) and does the LSR to the result, halving it. So now you have the total number of olives, in hex, halved.

Code: [Select]
07:C274:20 85 D7  JSR $D785
Then this one does the opposite and returns the ones digit on the accumulator and the tens digit on address $2, and then passes those to $E0 and $E1 respectively.

What this means is that this whole area can be replaced with new math:

Code: [Select]
07:C265:A5 E1     LDA $00E1 = #$08
 07:C267:A2 0A     LDX #$0A
 07:C269:20 6A D7  JSR dec to hex
 07:C26C:A5 03     LDA $0003 = #$00
 07:C26E:18        CLC
 07:C26F:65 E0     ADC $00E0 = #$06
 07:C271:4A        LSR
 07:C272:A2 0A     LDX #$0A
 07:C274:20 85 D7  JSR hex to dec
 07:C277:85 E0     STA $00E0 = #$06
 07:C279:A5 02     LDA $0002 = #$00
 07:C27B:85 E1     STA $00E1 = #$08

That's 24 bytes!

So what I usually do here is change all of those to EA and then start writing. Just so you get the feel of "I can do anything!" try this:
Code: [Select]
07:C265: A9 09 LDA #09
 07:C267: 85 E0 STA $E0
 07:C269: 85 E0 STA $E1
(fill the rest with EA up to C27C)

One important thing to notice is that if you were writing assembly code the correct way, you'd write LDA #09 and the compiler would transform that to A9 09 for you, because you're using LDA in immediate mode (you're feeding it a direct value, indicated by #). If you wrote LDA $09 you'd be telling it to load the value stored on address $9 and copy it to the accumulator which would compile A5 09 instead of A9 09. But we're doing things backwards here, so you need to pay attention to which type of LDA you want (A5, A9 or others). http://www.6502.org/tutorials/6502opcodes.html
This is very helpful nesrocks! Thanks a bunch again!! :D
I actually just started looking at this on FCEUX and I realized that I neglected to do a "Read" Breakpoint(I only did the Write Breakpoint before). After that I was able to see the entire operation. And right now I'm looking up NES instruction codes to learn this whole thing: https://wiki.nesdev.com/w/index.php/CPU_unofficial_opcodes

Ok time to try out what you gave me!

I'll be hitting the road soon so I'll report back later on tonight.

Cheers! :)

8-bit fan

July 19, 2017, 09:15:03 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Just saw the last part you added. Yeah, this whole thing is really going over my head at the moment. But I'm determined to learn this and do this hack!

Thanks for the explanation! :)
In the year of 200X, a super robot named Mega Man...
http://www.8bitfan.info/
FF4 Ultima Discord: https://discord.gg/4MqjwJt

nesrocks

  • Hero Member
  • *****
  • Posts: 732
    • View Profile
    • nesrocks.com
Re: Battle of Olympus - Hacking Help
« Reply #16 on: July 19, 2017, 09:15:18 pm »
Alright, good luck, but in general you can ignore those unofficial opcodes and stick to the official ones  :thumbsup:

Psyklax

  • Hero Member
  • *****
  • Posts: 1112
    • View Profile
    • Psyklax Translations
Re: Battle of Olympus - Hacking Help
« Reply #17 on: July 20, 2017, 02:41:24 am »
Quick side note: at ROM location $1FC80 there's a whole heap of FFs, which means it's probably empty. This would be a good place to Jump to a Sub Routine (JSR) where you can do your extra maths. The JSR command requires 3 bytes, which wouldn't be difficult to do. If I were you, I'd suggest you to replace one or two other commands with 20 70 FC (or 'JSR $FC70', which is the address in ROM) and then use 60 (RTS, ReTurn from Subroutine) to get back again.

As for the maths, I don't really know how to reduce by 10% with the operations available, though I'm sure I could figure it out if I looked hard enough. Taking 5 away would be very straightforward, however, and nesrocks already mentioned that. However, as he also said, if you, say take away 5 from 4 it goes below zero, looping back to 255, which means you'd need to do something about that. Again, needs some working out. :)

However, everything's possible! You just need to persevere enough. ;)

8.bit.fan

  • Sr. Member
  • ****
  • Posts: 317
    • View Profile
    • 8-bit fan's Hacking Projects
Re: Battle of Olympus - Hacking Help
« Reply #18 on: July 20, 2017, 05:02:02 am »
Alright, good luck, but in general you can ignore those unofficial opcodes and stick to the official ones  :thumbsup:
Thanks nesrocks! Will do! :)
Quick side note: at ROM location $1FC80 there's a whole heap of FFs, which means it's probably empty. This would be a good place to Jump to a Sub Routine (JSR) where you can do your extra maths. The JSR command requires 3 bytes, which wouldn't be difficult to do. If I were you, I'd suggest you to replace one or two other commands with 20 70 FC (or 'JSR $FC70', which is the address in ROM) and then use 60 (RTS, ReTurn from Subroutine) to get back again.

As for the maths, I don't really know how to reduce by 10% with the operations available, though I'm sure I could figure it out if I looked hard enough. Taking 5 away would be very straightforward, however, and nesrocks already mentioned that. However, as he also said, if you, say take away 5 from 4 it goes below zero, looping back to 255, which means you'd need to do something about that. Again, needs some working out. :)

However, everything's possible! You just need to persevere enough. ;)
Thanks Psyklax! Very helpful and I did exactly just that, to use the empty spaces for the routine. :)

I've been trying at this for 5 hour straight now, and am still having trouble with checking to see if the subtraction will end with a negative number. I think I've decided on a -10 olives penalty, so I wrote a sub routine that ignores the singles digit, and subtract 1 from the tens digit. However, I can't seem to figure out how to ignore the subtract if the tens digit is less than 1. I know I'm supposed to use the "Branching" operation, but can't seem to get the syntax right.

I have to get some rest now. I'll get back on this tomorrow. If you guys have any pointers, I'm all ears! :D

Thanks again and will check back tomorrow!

8-bit fan

July 20, 2017, 05:12:33 am - (Auto Merged - Double Posts are not allowed before 7 days.)
This is what I have for the routine:
Quote
A5 E1 18 C9 01 B0 E9 01 90 EA 85 E1
I'm guessing I'm probably using the Branching(B0 90) operations wrong...
« Last Edit: July 20, 2017, 05:12:33 am by 8.bit.fan »
In the year of 200X, a super robot named Mega Man...
http://www.8bitfan.info/
FF4 Ultima Discord: https://discord.gg/4MqjwJt

Psyklax

  • Hero Member
  • *****
  • Posts: 1112
    • View Profile
    • Psyklax Translations
Re: Battle of Olympus - Hacking Help
« Reply #19 on: July 20, 2017, 06:11:38 am »
Okay, taking away ten is easier I think, because of how the game splits the digits.

Your code isn't quite right, though, so let me step you through it. You've loaded the tens digit into the Accumulator, but then comparing it to $01. Surely you want to compare it to $00, as in "don't take away ten if they have less than ten"? So what you should do is LDA $E1 (A5 E1) then BEQ (F0) but remember than Branch operations are relative, and you've written it incorrectly. The number after a Branch is how many bytes to skip (or, more correctly, how much to add to the Program Counter), so you can finish that once you've written the code after it.

Since you don't need to CMP $00, because it will already be set, you can just BEQ immediately. So it's saying "load the tens digit, and get outta there if it equals zero". Then you can clear the carry as you did, and subtract $01, then return from the subroutine.

So what I would do is this:
A5 E1 F0 03 18 E9 01 60
which loads $E1, checks if it's zero, leaves the routine if so, and if not it clears the carry then subtracts 1 and finally leaves the routine. I ought to check if this works actually... :D

EDIT: WAIT! I've checked and corrected my code! :)

Basically, at $1C287 I inserted
A5 E1 F0 02 C6 E1
which is similar to what I suggested before, but this time it uses a two-byte operation, DECrement (DEC), to reduce what's already at $E1 by one, then ontinues the main program. If it's already zero, it just skips that and does nothing. I tested it and it seems to work fine. :) Didn't even have to jump to a subroutine. :)
« Last Edit: July 20, 2017, 06:31:30 am by Psyklax »