News: 11 March 2016 - Forum Rules

Author Topic: PS2 ASM/Debugging help  (Read 3193 times)

Nakago

  • Jr. Member
  • **
  • Posts: 21
    • View Profile
PS2 ASM/Debugging help
« on: August 01, 2016, 06:13:51 pm »
I'm not sure if this topic belongs here.
I need help with ps2 assembly and debugging.
I'm currently working with Super Robot Wars Alpha 3.
What I need help with are the following;
Redirecting values that have a fixed address, but no pointer values to that particular address.
The english translation for some words are larger than the space available. I'm trying to move individual lines to higher or lower addresses
from the original address. No luck here.
Tracing values, like the stage numbers in the scenario chart. I've tried changing the japanese words the english, but the values for the numbers are fixed.
The end result would look like this St52e instead of Stage.
Ascii to shift jis mapping, I want to understand more of this. Ascii support was added, but there are some bugs in a few of the characters giving me something other than the intended character.
There are also some other bugs I've encountered and I'm not sure how it happened. Some units ended up with some extra attacks that weren't there in the
unmodified version.

-Nakago

BlackDog61

  • Hero Member
  • *****
  • Posts: 784
    • View Profile
    • Super Robot Wars A Portable translation thread
Re: PS2 ASM/Debugging help
« Reply #1 on: August 03, 2016, 01:40:51 am »
Hi there, Nakago!

Could you give us a more concrete example of where you're trying to modify the text into English?
For instance, are you trying to change the display of the "last finished stage" in the intermission menu?
If I write about that for a second, basedon how it works in SRW AP, there's usually a "printf" instruction used, so you get 2 parts (I'm not sure if you know printf):
- a format string, such as "Stage %d"
- the value or values of the data to be applied to that format string,in that case the stage number somewhere in memory in decimal format.

In other words, you want to edit the format string without removing the "%d" part (which indicates an integer number in this case. there's also %s which indicates another text, typically used for something like "Best pilot: %s" and the name of the pilot is passed as another argument to printf.)

Let me know if that's something you already know of or not. If not then we could take a deeper dive into it. If you already know this, then please give a more concrete example so we can try and help eachother further.

Edit: How's your work with shared.bin going?

Nakago

  • Jr. Member
  • **
  • Posts: 21
    • View Profile
Re: PS2 ASM/Debugging help
« Reply #2 on: August 04, 2016, 06:37:42 pm »
The stage number in the scenario chart is in the HB.BIN file at address 0x00013B20 in the hex editor and ps2dis. 0x0081D8C0 in pcsx2dis, however the instructions appear as unknown instructions.

I've been editing the following files: HB.BIN (Scenario Chart Data), STAGE.BIN, BVC.BIN (Battle Dialogue Data), MTZKN_PT.BIN (Character Guide Data), MTZKN_RT.BIN (Robot Encyclopedia Data), and the main elf file. SRWA3 does not have a SHARED.BIN file.
.
From the main elf file I want to redirect some values which are fixed to a specific address, like Birthday, Blood Type, etc when you select you main character.
The location for these values are not long enough and will attach the adjacent value to itself (ex. BirthdayBlood Type). 第%s話 and Final Stage locations in the main elf file are also in fixed location with not enough room to make edits.
I've tried looking up information on the jal instruction, no luck here.

Someone has helped me add ascii support and vfw, but I have not heard from him in a while.
As for the ascii values, somehow ended up mapping to the main character's saved name (: appears as Kusuha and ; appears as Mizuha, same thing with these two < >, and 0-9 don't work).  I also want to map the accented vowels extended ascii values to the shift jis values of the stuff I've edited. So far, I've edited the FTALL.P04 file to include accented vowels, but are mapped to the shift jis values.  0x81B8=ä, 0x81B9=ë, 0x81BA=ï, 0x81BB=ö, 0x81BC=ü, 0x81BD=ñ, 0x81C8=á, 0x81C9=é, 0x81CA=í, 0x81CB=ó, 0x81CC=ú. I want to understand this process better. I also like to experiment by adding support to other games.
Then there are the alignment issues on the intermission menu, as well as some other bugs.

If you have a google account, pm me and I'll post a private patch as well as my save file on my google drive and add you to share.

Are there any similar programs to ida pro? The free version seems to crash too much.
Are there any guides for the debugger in pcsx2 1.4.0 and newer versions? So far, I've been using pcsx2dis for testing purposes.

-Nakago








BlackDog61

  • Hero Member
  • *****
  • Posts: 784
    • View Profile
    • Super Robot Wars A Portable translation thread
Re: PS2 ASM/Debugging help
« Reply #3 on: August 05, 2016, 03:00:30 am »
The stage number in the scenario chart is in the HB.BIN file at address 0x00013B20 in the hex editor and ps2dis. 0x0081D8C0 in pcsx2dis, however the instructions appear as unknown instructions.
I'm not sure but it's quite possible this be a data file, instead of an instruction file, isn't it? (It would be great because, in general, I haven't had to change much for data files - only pointer tables or headers, not code. It has been simpler - for AP at least.)

I've been editing the following files: HB.BIN (Scenario Chart Data), STAGE.BIN, BVC.BIN (Battle Dialogue Data), MTZKN_PT.BIN (Character Guide Data), MTZKN_RT.BIN (Robot Encyclopedia Data), and the main elf file. SRWA3 does not have a SHARED.BIN file.
Oh, OK. That was wishful thinking on my end then.

From the main elf file I want to redirect some values which are fixed to a specific address, like Birthday, Blood Type, etc when you select you main character.
The location for these values are not long enough and will attach the adjacent value to itself (ex. BirthdayBlood Type). 第%s話 and Final Stage locations in the main elf file are also in fixed location with not enough room to make edits.
I've tried looking up information on the jal instruction, no luck here.
OK. Well it's not going to be "just" jal instructions, is it? For AP I had to modify instructions that calculate the location of the memory to be read. It's like you know the resulting address in RAM, and you have to find the instruction (typically a load, an add, or equivalent) that will point to it from code.
I also found cases when the full address was in the code,as an operand to an instruction.

Either way, I've found myself doing the following for AP:
- Find a place in memory you can use, either because it's part of another file that is always loaded into memory (and you can extend it), or you actually make the game load your own file into memory. This file will host your text (thus removing the limitations in size you mentioned.)
- Repoint code to those memory addresses where you load your text. You can be lucky here if there are pointers, but as you mentioned, in the executables those pointers can be embedded in ASM instructions (either directly as full 32-bit operands, or as the result of a calculation using constants of lower size, for instance the upper and lower half-words). It's a bit tedious to locate them all, but it works.

Someone has helped me add ascii support and vfw, but I have not heard from him in a while.
Wow, that's nice!

As for the ascii values, somehow ended up mapping to the main character's saved name (: appears as Kusuha and ; appears as Mizuha, same thing with these two < >, and 0-9 don't work).  I also want to map the accented vowels extended ascii values to the shift jis values of the stuff I've edited. So far, I've edited the FTALL.P04 file to include accented vowels, but are mapped to the shift jis values.  0x81B8=ä, 0x81B9=ë, 0x81BA=ï, 0x81BB=ö, 0x81BC=ü, 0x81BD=ñ, 0x81C8=á, 0x81C9=é, 0x81CA=í, 0x81CB=ó, 0x81CC=ú. I want to understand this process better. I also like to experiment by adding support to other games.
Not sure i can help here.

Then there are the alignment issues on the intermission menu, as well as some other bugs.
Yeah, alignment / positioning on menu screens has proven to be the most time-consuming task for AP. Took me 3 months - and i guess AP has fewer pieces of info per screen than Alpha 3. Also, it's not just positioning: in general, you have to be clever to find a way to squeeze info into screens. (Ex: I used graphics instead of letters for terrains to spare some pixels.) Sometimes you even have to remove info from a screen (as a last resort).

If you have a google account, pm me and I'll post a private patch as well as my save file on my google drive and add you to share.
I'll be PM'ing you about it. My time's limited, unfortunately, (and so is my skill) but a good chat is often an option.

Are there any similar programs to ida pro? The free version seems to crash too much.
Are there any guides for the debugger in pcsx2 1.4.0 and newer versions? So far, I've been using pcsx2dis for testing purposes.
IDA pro is often considered as the star of disassemblers. I've often been told the paid version is worth every penny (butI haven't tried it).
As for myself, I prefer a good debugger, especially when programmers created it with a view to translation support. i'm told there have been significant contributions in that area for pcsx2 (I think) and that you have to try the recent builds (not just the released ones). Have you triedrebuilding from source or getting a nightly build? (I don't know in what form they are available.)

Rai

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • The official webpage for my Super Robot Taisen Alpha translation project.
Re: PS2 ASM/Debugging help
« Reply #4 on: August 06, 2016, 02:06:52 pm »
The stage number in the scenario chart is in the HB.BIN file at address 0x00013B20 in the hex editor and ps2dis. 0x0081D8C0 in pcsx2dis, however the instructions appear as unknown instructions.

I've been editing the following files: HB.BIN (Scenario Chart Data), STAGE.BIN, BVC.BIN (Battle Dialogue Data), MTZKN_PT.BIN (Character Guide Data), MTZKN_RT.BIN (Robot Encyclopedia Data), and the main elf file. SRWA3 does not have a SHARED.BIN file.
.
From the main elf file I want to redirect some values which are fixed to a specific address, like Birthday, Blood Type, etc when you select you main character.
The location for these values are not long enough and will attach the adjacent value to itself (ex. BirthdayBlood Type). 第%s話 and Final Stage locations in the main elf file are also in fixed location with not enough room to make edits.
I've tried looking up information on the jal instruction, no luck here.

Someone has helped me add ascii support and vfw, but I have not heard from him in a while.
As for the ascii values, somehow ended up mapping to the main character's saved name (: appears as Kusuha and ; appears as Mizuha, same thing with these two < >, and 0-9 don't work).  I also want to map the accented vowels extended ascii values to the shift jis values of the stuff I've edited. So far, I've edited the FTALL.P04 file to include accented vowels, but are mapped to the shift jis values.  0x81B8=ä, 0x81B9=ë, 0x81BA=ï, 0x81BB=ö, 0x81BC=ü, 0x81BD=ñ, 0x81C8=á, 0x81C9=é, 0x81CA=í, 0x81CB=ó, 0x81CC=ú. I want to understand this process better. I also like to experiment by adding support to other games.
Then there are the alignment issues on the intermission menu, as well as some other bugs.

If you have a google account, pm me and I'll post a private patch as well as my save file on my google drive and add you to share.

Are there any similar programs to ida pro? The free version seems to crash too much.
Are there any guides for the debugger in pcsx2 1.4.0 and newer versions? So far, I've been using pcsx2dis for testing purposes.

-Nakago
The fixed location thing sounds like a pointer issue.

Sorry you haven't heard from me. I've been very busy with things in my personal life.

For a decent stable PS2 debugger, I would download the latest Orphis build of PCSX2.

You can get it here.

I use a combination of PCSX2dis and the Orphis builds, to debug the game. Those "unknown instructions" should display in the Orphis build.

SRW PS2 games require a lot of hacking. But once I get the things done in my personal life; I'll have a lot more time to look at Alpha 3.

If it will help; I have the project folder. It contains commented logs of the game's code and my own custom code.

PM me if you want me to send you it.