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

Author Topic: JRPGs: DoubleXP/DoubleGold  (Read 5071 times)

Psyklax

  • Sr. Member
  • ****
  • Posts: 485
    • View Profile
    • Psyklax Translations
Re: JRPGs: DoubleXP/DoubleGold
« Reply #80 on: January 07, 2018, 08:56:04 pm »
could I use your EXP/Gold formula edit for my own project?

Uh, in what way? You're hacking one of the games I've done? Well, you could just write in your readme file "hey guys, my hack will be better if you use this guy's patch as well" with a link or something? If I can see what you're actually doing then maybe I'll let you put my hack into yours with a credit, but I'd like to know where it's going first. :)

By the way, here's a bunch of patches for you guys! ;)

http://s346165667.websitehome.co.uk/psyktrans/2x-20180107,zip

Dragon Warrior 3 on GBC is done, but I'm still figuring out the SNES version. It appears the code refers to specific positions in the stack, which is a TERRIBLE idea, because when I did a subroutine jump, it knocked the stack pointer by one, thus crashing the game. Who the hell programmed that?!

Anyway, there's also an updated patch for Final Fantasy 3 (NES) which halves the time to increase your job level (thanks for the heads up, Reiska!), and I removed the fast running feature I used to have - I've gone off the idea. :) I also finally fixed Dragon Warrior 2 (NES) so I'll be completing that game soon. :D

I must point out to everyone in the thread that all of these patches are preliminary: I've not officially released any of them, because I want to iron out any kinks.

Shadic

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
Re: JRPGs: DoubleXP/DoubleGold
« Reply #81 on: January 13, 2018, 10:02:41 pm »
Uh, in what way? You're hacking one of the games I've done? Well, you could just write in your readme file "hey guys, my hack will be better if you use this guy's patch as well" with a link or something? If I can see what you're actually doing then maybe I'll let you put my hack into yours with a credit, but I'd like to know where it's going first. :)
I'm just doing a "modernization" patch of my own, updating names, exp/gold gain, shop costs, etc. But a few values (Metal Slime, Gold Golem) would ideally go over the 255 limit.

Psyklax

  • Sr. Member
  • ****
  • Posts: 485
    • View Profile
    • Psyklax Translations
Re: JRPGs: DoubleXP/DoubleGold
« Reply #82 on: January 14, 2018, 03:30:39 am »
I'm just doing a "modernization" patch of my own, updating names, exp/gold gain, shop costs, etc. But a few values (Metal Slime, Gold Golem) would ideally go over the 255 limit.

I'm a bit confused: are you saying you want to set those enemies to give you more than 255? Because the game code doesn't support that. Open FCEUX and set an execute breakpoint for $EA0A, and you'll see that the game stores one byte for the XP total to $00, and stores zero to $01. But if you change $00 and $01 to FF, you'll get 65,535, so it's clearly possible to get more than 255 from an encounter. The problem is, the game ignores the most significant byte when loading the XP total, so if the enemy is 144 normally and doubled, you only get 32 (because 256 is ignored). Of course I could change the routine so that the carry flag is also considered, which would solve the problem.

Anyway, time for an update! :)

Thanks to KingMike's assistance, I've made an update to my Final Fantasy 6 (SNES) patch! Now when you get later in the game and earn Magic Points for your Esper stuff, you'll earn double. I'd never have been able to do it without someone providing me with a late-in-the-game save file, so big thanks to KingMike for stepping up! ;)

Also in the pack is Dragon Quest 3 (SNES), which complements my previous patches for DW3 on GBC and NES. I think I may have to take another look at my DW3 NES patch, since it was one of the first ones I did and I want to make sure it's okay, given what I've been learning since then.

http://s346165667.websitehome.co.uk/psyktrans/2xp-20180114.zip

I've now reached the point where I think I'll officially release a few patches. I've now completed Dragon Warrior/Quest 1 and 2 on NES, SNES and GBC, so I know the patches work correctly.

Also, when you reach the last shrine before the final castle in DW2, FAQs will sensibly recommend that you reach level 30 before trying. Well, I made it there in the 20s and really couldn't be bothered to grind at that stage, even with double XP. So I used my hacking skills to make Game Genie codes that will give you super XP from a battle, then turned them off when I was up to the level I wanted. :) And I'll share them with you now!

On Dragon Warrior 2 (NES), there's an internal check to allow you to earn no more than 9,999 XP from any battle, even though there isn't a single battle in the game that could earn you anything close to that. So I just replaced the branch instruction with one that does the opposite (ie load 9,999 XP if you get LESS than that, not MORE).

EUSPEPEP - gives 9,999 XP for every fight

Of course, if 9,999 isn't enough, you can use these two codes to change 9,999 to the maximum of 65,535.

NNSOKOYE + NNVPOPYX - gives 65,535 XP for every fight (with EUSPEPEP)

(for testing purposes, I used just the first patch to play through the entire game from scratch. :D It didn't take nearly as long, obviously)

For the Game Boy Color version, I've also made a Game Genie code, but this one always gives you 65,535 XP. The GBC version also includes a maximum routine, so this code replaces the jump instruction with a load instruction, meaning the code just continues to load the maximum into the XP total.

26D-67B-2AA - gives 65,535 XP for every fight

As for the SNES version, I used Pro Action Replay to patch the RAM, whereas Game Genie patches the ROM. It just puts 255 in $7E0ED9, which is where the most significant byte of the XP total is kept. Therefore, you always earn a MINIMUM of 65,535 for each fight, as well as adding the least significant byte.

7E0ED9FF - gives minimum 65,535 XP for every fight

Have fun with the patches, and the codes! :)

Shadic

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
Re: JRPGs: DoubleXP/DoubleGold
« Reply #83 on: January 14, 2018, 01:19:25 pm »
I'm a bit confused: are you saying you want to set those enemies to give you more than 255? Because the game code doesn't support that. Open FCEUX and set an execute breakpoint for $EA0A, and you'll see that the game stores one byte for the XP total to $00, and stores zero to $01. But if you change $00 and $01 to FF, you'll get 65,535, so it's clearly possible to get more than 255 from an encounter. The problem is, the game ignores the most significant byte when loading the XP total, so if the enemy is 144 normally and doubled, you only get 32 (because 256 is ignored). Of course I could change the routine so that the carry flag is also considered, which would solve the problem.

Oh. Well... Crap.  :-\

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6267
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: JRPGs: DoubleXP/DoubleGold
« Reply #84 on: January 14, 2018, 08:31:54 pm »
I find it hilarious that, as I recall, in the first SNES SD Gundam Gaiden, the game's equivalent to the Metal Slime appears in Chapter 3. I think it was worth like 35,000 EXP and attacked in groups, making it really easy to hit the 65,535 EXP per battle gain limit.
Quote
Sir Howard Stringer, chief executive of Sony, on Christmas sales of the PS3:
"It's a little fortuitous that the Wii is running out of hardware."

Psyklax

  • Sr. Member
  • ****
  • Posts: 485
    • View Profile
    • Psyklax Translations
Re: JRPGs: DoubleXP/DoubleGold
« Reply #85 on: January 15, 2018, 08:36:28 am »
Oh. Well... Crap.  :-\

I think you missed the part where I said "I could change the routine so that the carry flag is also considered, which would solve the problem". :D I would just have to do an arithmetic shift on the byte in $00, then rotate the carry into $01 (if none of that makes sense, don't worry, it's assembly maths stuff ;) ).

Let's do it right now, shall we? :D

Open the game in FCEUX (or in a hex editor) and go to $EA1F in the ROM. There are four bytes we're interested in: A9 00 85 01, which means "LDA #$00; STA $01", or "load the Accumulator with the number zero, and store it in $01 in RAM". This is an odd bit of programming: it's as if the game accommodates using a 16-bit value for the XP in battles, but explicitly doesn't use it, instead writing zero to the most significant byte. Fortunately, we CAN use it! :)

Change A9 00 85 01 to 20 60 FF EA, which means "JSR $FF60; NOP", or "jump to the subroutine at $FF60, then do nothing for a cycle". We need three bytes to make the jump, but we're replacing two instructions that use two bytes each, so there's one byte we don't need. We just replace it with an instruction that tells it to do nothing. So now we're ready, we put our subroutine at $FF60 (in RAM), which in this particular ROM will be at $FF70, so go there.

You'll see a bunch of FFs, meaning there's some empty space for us. Type 06 00 26 01 60, which means "ASL $00; ROL $01; RTS", or "do an arithmetic shift left on what's in $00; rotate left on what's in $01; go back to where you were in the program". An arithmetic shift moves the bits either left or right, and moves the highest (or lowest) bit into the carry. Learn about binary, bits and bytes if that still makes no sense. :) Rotate does the same thing but the difference is that ASL puts zero in the lowest position, which ROL puts the Carry into the lowest position. So if your first byte is doubled and goes over 255, that activates the Carry flag, and the second byte then gets that Carry added to it. Make sense? :)

Anyway, let's give it a try. Enter those two things, then get into a fight with a Slime. Normally that gives you 1 XP, now it gives you 2. Yay! But let's go further. The XP for that encounter is stored at $106 in RAM, so go there when you get into a fight and (if it's a Slime) it'll have $01 stored there. Try changing it to $81 (129 in decimal). If everything goes right, it should give you 258 when you win. Give it a try. ;)

Of course, you'll need to do something similar with the Gold as well (I'll have a look at that later if you're interested). Also, if you're fiddling with "exp/gold gain, shop costs, etc", you might need to take them into account, if you're always earning double from battles. And don't forget that you'll still earn a maximum of 510 using this method. If you want to make it quadruple instead of double, you'll need a few more bytes of instructions. Still, I think 510 should be enough. :)

Happy hacking! ;)

Shadic

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
Re: JRPGs: DoubleXP/DoubleGold
« Reply #86 on: January 15, 2018, 04:29:50 pm »
Thank you very much for walking me through this.. It's very helpful.  :thumbsup:

Unfortunately, I did what you said and it appears to be working for monsters below 255 EXP, it doesn't surpass that limit.

Here's a video showing the discrepancy between what it says (Adding 510) EXP, and what it does (adds 254).

Psyklax

  • Sr. Member
  • ****
  • Posts: 485
    • View Profile
    • Psyklax Translations
Re: JRPGs: DoubleXP/DoubleGold
« Reply #87 on: January 16, 2018, 03:29:53 am »
discrepancy

Ah, I see. I should've paid more attention to what I was doing. :)

It seems like it says on-screen how much you get, but what you actually receive is different. I'll have a look at it, and the Gold as well. It's most likely that it's filling your XP with the untouched value at $106, while the values used in $00 and $01 are just for text purposes.

Shadic

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
Re: JRPGs: DoubleXP/DoubleGold
« Reply #88 on: January 17, 2018, 01:03:52 am »
I've also seen this while using the DW1 Mass Data Editor, actually. For most items it'll modify item cost without issue, but certain objects (it's been some time, but I believe Herb, Torch, Dragon's Scale, and Wings), editing the items away from their base values can cause strange discrepancies as well!

Psyklax

  • Sr. Member
  • ****
  • Posts: 485
    • View Profile
    • Psyklax Translations
Re: JRPGs: DoubleXP/DoubleGold
« Reply #89 on: January 17, 2018, 05:21:48 am »
I've also seen this while using the DW1 Mass Data Editor, actually. For most items it'll modify item cost without issue, but certain objects (it's been some time, but I believe Herb, Torch, Dragon's Scale, and Wings), editing the items away from their base values can cause strange discrepancies as well!

I don't think that's related. In fact, I don't know why you may have had problems with that, but if you're serious about hacking then you'd dump those tools. Ain't nothin' you can't do with a good debugging emulator, a hex editor, and some knowhow. ;)

I'm looking again at the game: the problem I had is that making $00 and $01 have my 16-bit number is fine to write on the screen, but of course the game doesn't care about $01 when adding to your actual experience. At $EA17, the routine (after telling you how much you XP you earned) loads the value in $00, adds it to your experience total, then replaces it with the new total. If it goes over $FF (255) then it adds one to the most significant byte. If the MSB goes over $FF, then it loads $FF to both, because that's the maximum XP for the game (65,535). Of course, there's nothing to stop you using a 24-bit number for your total XP, but I don't think it's worth the effort. If you want to see this routine in action, add a breakpoint in the debugger for "execute" at EA17, then win a fight.

Now, that's all well and good, but we need to add $01 to the MSB, in addition to all I just mentioned. The simple answer is to continue what I did earlier: do a jump and include an instruction to add $01 to $BB (the MSB of your experience). The tricky bit is deciding in what order to do things. We need four operations: add $00 to $BA, increase $BB (if necessary), add $01 to $BB, put $FF in $BA and $BB (if necessary). I'm working on the routine now and I'll edit this post when I'm done. :D

EDIT: okay, here we go. :) First thing to mention: this requires changing the previous double XP patch I gave you, and it ONLY works for the XP, not the Gold, so it's a bit limited.

At $EA29 in the ROM, put 20 54 FF 50 0C, which jumps to my new routine, and on returning, skips all the code that was copied to that routine.

Then, at $FF64, put this: 18 65 BA 85 BA 90 04 E6 BB F0 09 A5 01 18 65 BB 85 BB 90 06 A9 FF 85 BA 85 BB 60 (copy-paste it in there). It'll be a pain to explain everything in this, but most of it is copied from the original routine in the game. It just adds a new part to add $01 to $BB. I'm sure I could use fewer bytes in this part and change something in the other part, but for now it'll do.

You can test that this works by doing an execute breakpoint to $EA13, then when it stops, changing $00 and $01 to whatever you want, and it should add the right amount to your XP total. I'll need to fiddle with it a bit more to do double XP again.

EDIT2: Aha! I've finished my routine, and it's so nice I think I'll use it in my final version of my patch, even though it's not really necessary (because no enemies in the original game give you more than 127 of either). It uses two routines that cover both XP and Gold, one to double them and another to make sure the 2nd byte is used. I'll post later.

EDIT3: Changed my mind, I'll properly release it as a patch and add it to the RHDN database. :) Hopefully later today, if I find the time.
« Last Edit: January 18, 2018, 09:16:18 am by Psyklax »