Thursday, February 27, 2020

Don't tell my Wife, but i want to propose to Ghidra

For the last 2 weeks i was breaking my head on an issue where a Kanji was somehow still showing up even after being deleted in the game files.
When you defeat an enemy you get information on how much EXP, Money and Knack Points you receive.
When i went on to translate that, i only found 2 things, the Kanji 技 and P:

I didn't think much of it and just translated it and tested it ingame, but somehow the Kanji 能 was still popping up (AP and KP are just debugging text):



I changed every single hex string that could result in the Kanji, but nomatter what i tried i couldn't remove it from that spot.
So, with my newfound Ghidra skills i decided to tackle this issue again.
First, i looked for my strings:

(At first Ghidra didn't recognize them as strings so i had to manually edit them to show up as a normal string)
I noticed that my strings both had 4 references to 2 functions which looked very similar.
So, i decided to go to the funktions and check out the really cool "Function Graph" tool:


I am by no means a programmer, but this looked like a graph that shows how the EXP screen is build together in code.
I found both of my strings in the graph and i slowly tried to understand what i am looking at.



Since i had 2 reference points again i could figure out that these 2 are probably the code that will display "AP" and "KP" in the EXP screen.
In the middle of those 2, just like ingame where the stupid ass Kanji was giving me troubles, lies code that has a different function put in between:

So, i thought that i could just delete the code and see what happens ingame, maybe the Kanji will finally be gone and i can have a properly translated EXP screen.
I looked at what HEX Address the code is in and just put a lot of 0's in its place:


(I had to do this for 2 functions, it seems like there are 2 different EXP screens in GL6)
It looked like this in Ghidra after doing that:


And lo and behold, it actually worked:


Heres hoping i didn't actually break anything critical in some other part of the game.....
But so far the game didn't crash after killing some monsters.

Knowing that things like this work will help me figure out how to change other parts of the game, for example the equipping screen which is not great right now:


Heres what it looked like in GL5:


I wanted to do a 1 to 1 copy of it, but i couldn't change the line in which the item name is place.
Maybe now i have the chance to just switch it around with the help of Ghidra.

3 comments:

  1. What is the difference? (apart from the style) Maybe I'm blind

    ReplyDelete
  2. Non-programmer...sigh
    Thanks for your effort but now i know this will crash randomly everywhere.

    ReplyDelete
    Replies
    1. Hey Doug, so far i didn't experience any crashes with those changes!

      Delete