Page 1 of 2

Memory Addresses for Legaia Variables

Posted: Sun Jul 20, 2014 8:20 pm
by garik16
Hey guys, so I'm attempting to speedrun LoL, mainly through a segmented speedrun (not a real time run through the whole thing, but redoing segments between save points till i get the fastest time possible). There's been one guy who attempted to do a tool assisted speedrun of legaia but gave up after a short bit since it was beyond his time capabilities.

One thing he did find was the memory addresses for the Random Battle Counter and how it works. To Quote him:
0007B5FC: Random Encounter

When this memory address hits 0, you will enter a random encounter. It decreases by 42 each time you cross invisible grid lines in the world. If you cross the line by 1 pixel you can go back and forth and get into a random battle in a few frames. (If the world map didn't run at 20 fps) Or run around inside a grid square without touching the edges and never have an encounter.
When you enter a battle the value changes to 600-1400. This is your new starting value when the battle is over. Entering and exiting the world map will increase this to 700-1000, but only if you are already below 480. This can be manipulated easily.



Enemy health:
000ED3D6: Always first enemy
000ED6AA: Always 2nd
000ED97E: 3rd
000EDC52: 4th
0008480E: Vahn HP
00084812: Vahn MP
Tetsu has 999 health and this resets to over 1000 if you bring him below 768.

Position:
000830E8: X Location World Map
000830EC: Y Location World Map
000837A8: X Location Field
000837B4: Y Location Field
As it turns out, his info isn't QUITE correct - the counter goes down at different rates in different areas, which is why some areas have greater rates of random battles than others. But the point is these addresses correspond to certain variables in the game.

I was hoping some of you guys might either know other addresses which contain other variables (I saw meth reference Boss MP around here Before) so that we could possibly figure out more about the game to find out some more exploits or tricks we can pull like the recent juggernaut key skip.

Re: Memory Addresses for Legaia Variables

Posted: Sun Jul 20, 2014 11:45 pm
by Nightshade
Well, one of the big contributions that I have been working on - also for speedrunning purposes - is trying to get a good way to manipulate (read: brute forcing via save scumming) level-ups for each character.

With the number of Magic and Miracle Waters in the game, it should be possible to be able to use Juggernaut magic pretty effectively, even in a speedrun. The key is the Spirit Jewel that you can purchase at the Vidna slots that gives -25% MP consumption; this brings the cost of Juggernaut to 192 MP, which is not impossible for Vahn or Gala to have at level 15, given sufficient quantities of Waters.

What I am trying to do now is get a good set of sequencing in place to figure out what treasure chests to get (and to skip) in the game, how much Slot Machine to play, where to use the Point Card, and how to beat Cort 2.

Re: Memory Addresses for Legaia Variables

Posted: Mon Jul 21, 2014 8:50 am
by meth962
That looks almost word for word of what I wrote before ?: /

What kind of addresses do you want? I have a collection of them.

I could probably breakpoint the memory address for encounters and find the table that the game is pulling the encounter rate for each area. I started writing down the Map names/IDs as I was playing through the game with hacking Terra the wolf in my party. I didn't get too far but that sounds like something I could do at the same time. Or just go through all the map IDs manually :O

Re: Memory Addresses for Legaia Variables

Posted: Mon Jul 21, 2014 8:14 pm
by garik16
meth962 wrote:That looks almost word for word of what I wrote before ?: /

What kind of addresses do you want? I have a collection of them.

I could probably breakpoint the memory address for encounters and find the table that the game is pulling the encounter rate for each area. I started writing down the Map names/IDs as I was playing through the game with hacking Terra the wolf in my party. I didn't get too far but that sounds like something I could do at the same time. Or just go through all the map IDs manually :O
Anything you have might be useful. With an emulator like PSXJin I can watch those addresses during game play pretty easily and might be able to figure things out. Not planning on TASing this game (the encounter manipulation and what not would be too much for my patience) but skips and maybe even boss (Xain) and seru effect manipulation (Nightos) might be possible If i could figure out what controls the RNG of those battles.

Re: Memory Addresses for Legaia Variables

Posted: Mon Jul 21, 2014 8:21 pm
by garik16
Nightshade wrote:Well, one of the big contributions that I have been working on - also for speedrunning purposes - is trying to get a good way to manipulate (read: brute forcing via save scumming) level-ups for each character.

With the number of Magic and Miracle Waters in the game, it should be possible to be able to use Juggernaut magic pretty effectively, even in a speedrun. The key is the Spirit Jewel that you can purchase at the Vidna slots that gives -25% MP consumption; this brings the cost of Juggernaut to 192 MP, which is not impossible for Vahn or Gala to have at level 15, given sufficient quantities of Waters.

What I am trying to do now is get a good set of sequencing in place to figure out what treasure chests to get (and to skip) in the game, how much Slot Machine to play, where to use the Point Card, and how to beat Cort 2.
BTW, I've been posting my speedrun findings in this SDA thread: https://forum.speeddemosarchive.com/pos ... egaia.html

Beating Cort 2 is easily doable in a speedrun even at low level (I did it at levels 25-26) - you just need to suddenly use wonder elixers and/or shield elixers (in my route i collect 4 wonders, 2 shields) all on one character, and that guy can handle cort 2.

That said, this is sort of off topic for this thread.

Re: Memory Addresses for Legaia Variables

Posted: Mon Jul 21, 2014 11:17 pm
by meth962
Hrm, I'm not sure anything I have will directly help you because the RNG is all based on time as a seed (same as most RNG).

The game gets it's RNG from the same part of code every time, for any RNG. It multiplies a fixed number by the value at this memory address:

0x9010 - 4 bytes
or a0009010 depending on your emulator.

Sometimes the number is bit shifted so it only returns 2 bytes instead of 4.

Once the game returns this 'random' number, it is written to the 0x9010 address. So it changes everytime it is called. It can be called 40+ times a frame so that's why it's like a time seeded RNG. Without TASing, I don't think you can learn much from the RNG mechanic.

One place of interest is 0x84140. In memory, that is your entire save file that gets written to the memory card. The game uses it for most things directly except for your stats in battle. It reads your stats and copies them to a battle location (0xeca00) for use during battle. But everything else is there at 0x84140 including your save icon.

0x85750 - the start of the game's flags. For treasures, events, choices, etc.
0x85958 - Inventory

If you think of something specific that might still help, I can look it up.

Re: Memory Addresses for Legaia Variables

Posted: Tue Jul 22, 2014 6:57 am
by garik16
You previously mentioned Boss MP in a post - do you know what address that's in?

Re: Memory Addresses for Legaia Variables

Posted: Tue Jul 22, 2014 10:22 am
by meth962
Sure! Just like the battle location, both enemies and character data is stored under 0xeca00

1st Enemy:
0xed3b0: HP
0xed3b2: Max HP
0xed3b4: MP
0xed3b6: Max MP
0xed3b8: Agility
0xed3ba: (Agility)
0xed3bc: ATK
0xed3be: (ATK)
0xed3c0: UDF
0xed3c2: (UDF)
0xed3c4: LDF
0xed3c6: (LDF)
0xed3c8: SPD
0xed3ca: (SPD)
0xed3cc: INT
0xed3ce: (INT)
0xed3d0: Turn Order
0xed3d7: Flags
0xed420: Name

2nd Enemy:
0xed684: HP
...etc

3rd Enemy:
0xed958: HP
...

4th Enemy:
0xedc2c: HP
...

Re: Memory Addresses for Legaia Variables

Posted: Tue Jul 22, 2014 10:41 pm
by garik16
Hmmm, curious: our memory addresses are close, but don't quite match:
I (well the TASer exileUT) had found Monster 1 HP to be:
000ED3D6
You have:
000ed3b0:

I just tested them both in PSXJin and they both have the same result. So there seem to be duplicate stuff in memory.

Re: Memory Addresses for Legaia Variables

Posted: Tue Jul 22, 2014 11:42 pm
by meth962
Yup both are used actually. They have a max hp, an hp, and then another hp for some stupid reason. :)