jywjyw / bravefencer-hack

1 stars 0 forks source link

How to use this tool? #2

Open FlavioGarciaDev opened 3 years ago

FlavioGarciaDev commented 3 years ago

I'm not familiar with Java source code, can you make a compiled version? Will this work with the US version of the game to extract the texts?

jywjyw commented 3 years ago

I'm not familiar with Java source code, can you make a compiled version? Will this work with the US version of the game to extract the texts?

You can run src/main/java/brm/dump/Dump.java with eclipse, it can extract US version texts to excel file. It's not a tool easy to use, I use it to extract English and Japanese texts, then import translated texts to Japan version disk. So, if you want to modify US version disk,you should develop lots of code. But if you only need extracted English texts, I can send to you later.

natsamtan246 commented 1 year ago

Oh I see this is already answered. I wish I could code as well as you, but maybe looking at the code you wrote will help. Is importing the translated text harder than reversing what you did to extract it?

jywjyw commented 1 year ago

Yes, importing is a hard work. The translated text cannot be longer than that before translation. Besides, there are lots of work to do. For example, replace Japanese picture, modify assembly code…

I have a question. if you use English,why you want to research it? Just play the game.

在 2023-01-27 07:23:43,natsamtan246 @.***> 写道:

Oh I see this is already answered. I wish I could code as well as you, but maybe looking at the code you wrote will help. Is importing the translated text harder than reversing what you did to extract it?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

natsamtan246 commented 1 year ago

Haha, yeah, you make a good point. It's one of my favorite games, so getting a better grasp of the coding within it is something I find interesting. A romhack or something has always interested me. I don't have the skill for that though, so changing the text to say something funny could be fun in the meantime, haha. However, I think a lot of people want to edit the text in the English version as well, for translation to other languages. If I were to find a way, I could certainly help them as well. I just have very little understanding of coding things, and it seems the specific things you need to know for game hacking isn't very easy to just learn that and only that.

Why did you have to modify assembly code for this if I may ask.

Yes, importing is a hard work. The translated text cannot be longer than that before translation. Besides, there are lots of work to do. For example, replace Japanese picture, modify assembly code… I have a question. if you use English,why you want to research it? Just play the game. 在 2023-01-27 07:23:43,natsamtan246 @.> 写道: Oh I see this is already answered. I wish I could code as well as you, but maybe looking at the code you wrote will help. Is importing the translated text harder than reversing what you did to extract it? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

jywjyw commented 1 year ago

It's my most favorite game too. Actually, I have spent more than one year on these codes, include studying hacking technique.

It's neccessary to modify assembly code in almost every PSX translation project, you can see it in directory "src/main/resources/asm". For example, on game HUD, Chinese characters are larger than Japanese characters(only about 6*6 pixels), just modifying the asset is not enough.

As I said, if you want to edit text in English version, you have lots of work to do:

  1. split ROM files (*.CD)
  2. decompress
  3. extract texts to excel
  4. edit texts in excel
  5. import excel
  6. compress
  7. rebuild file chunks to "*.CD" I only care about extracting English text, which is used to make our translators more accurate when translating Japanese text. Different versions of ROM are very different,you should complete step 4/5/6/7 by yourself

Haha, yeah, you make a good point. It's one of my favorite games, so getting a better grasp of the coding within it is something I find interesting. A romhack or something has always interested me. I don't have the skill for that though, so changing the text to say something funny could be fun in the meantime, haha. However, I think a lot of people want to edit the text in the English version as well, for translation to other languages. If I were to find a way, I could certainly help them as well. I just have very little understanding of coding things, and it seems the specific things you need to know for game hacking isn't very easy to just learn that and only that.

Why did you have to modify assembly code for this if I may ask.

Yes, importing is a hard work. The translated text cannot be longer than that before translation. Besides, there are lots of work to do. For example, replace Japanese picture, modify assembly code… I have a question. if you use English,why you want to research it? Just play the game. 在 2023-01-27 07:23:43,natsamtan246 @.**> 写道: Oh I see this is already answered. I wish I could code as well as you, but maybe looking at the code you wrote will help. Is importing the translated text harder than reversing what you did to extract it? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.**>

jywjyw commented 1 year ago

I added English texts, here : https://github.com/jywjyw/bravefencer-hack/blob/master/translation/brm-jp.xlsx

natsamtan246 commented 1 year ago

Oh wow, a whole year? I understand why you don't want to do all the work for us then, haha. Any resources you can provide for learning stuff? I assume they would all be in Chinese though, but a translator might work.

Oh I see, that's really cool, could you not do that with hex editing as well? Or does the game run some sort of checksum so you can't edit it directly very easily?

There is a tool online that does step one. You have a resource for step 2 about LZSS compression, I don't understand it very well. Is it different for the Japanese game versus the English game? Or do they use the same compression? As for the rest of the steps, they will take research. I would gladly take any resources you have that would help in those last few steps if you have any.

Thank you for English texts. It was cool to see how you formatted it. I assume that helped you with importing it. And it shows some of the command codes that I would need, so thanks.

It's my most favorite game too. Actually, I have spent more than one year on these codes, include studying hacking technique.

It's neccessary to modify assembly code in almost every PSX translation project, you can see it in directory "src/main/resources/asm". For example, on game HUD, Chinese characters are larger than Japanese characters(only about 6*6 pixels), just modifying the asset is not enough.

As I said, if you want to edit text in English version, you have lots of work to do:

  1. split ROM files (*.CD)
  2. decompress
  3. extract texts to excel
  4. edit texts in excel
  5. import excel
  6. compress
  7. rebuild file chunks to "*.CD" I only care about extracting English text, which is used to make our translators more accurate when translating Japanese text. Different versions of ROM are very different,you should complete step 4/5/6/7 by yourself
jywjyw commented 1 year ago

Oh I see, that's really cool, could you not do that with hex editing as well? Or does the game run some sort of checksum so you can't edit it directly very easily?

HEX editor is required to verify my assumptions. It's possible to dump RAM and edit, because RAM data are already decompressed. But it's impossible to edit ROM in HEX editor directly, because of :

  1. File chunk has header;
  2. Compression mechanism;
  3. PSX CD has its own checksum;

There is a tool online that does step one.

Unneccessary, just use "brm.dump.CdSplitter.java"

You have a resource for step 2 about LZSS compression, I don't understand it very well. Is it different for the Japanese game versus the English game? Or do they use the same compression?

JP and EN version are all using LZSS compression, but maybe they've different arguments. I can't confirm that "brm.hack.Compresser.java" is suitable for EN version, you can test by "brm.dump.Uncompresser.java" and "brm.hack.Compresser.java". Maybe the compressed text length exceeds the limit.

In this game, we cannot modify the sentence length, the translated sentence length cannot exceed the pre-translation length. It is important to be aware of this, otherwise you'll waste a lot of effort.

Any resources you can provide for learning stuff? I assume they would all be in Chinese though, but a translator might work.

  1. https://pan.baidu.com/s/1kSgZlhZ-mrod9wCxCk_sGw?pwd=b4zi <<PS汉化教程.exe>>(PSX Game Translation Tutorial). Only for Chinese beginner, I doubt it's not very useful for you.
  2. https://fabiensanglard.net/doom_psx/psx.pdf For advanced programmer. Learn to it if you need asm hack.

I would gladly take any resources you have that would help in those last few steps if you have any.

I have some important tools:

  1. https://www.romhacking.net/utilities/475 . It's a PSX emulator and debugger, it can only run on WINXP, so install VMWARE and WINXP first and prepare to spend LOOOOTS of time on it :(
  2. https://www.romhacking.net/utilities/818 . It's an enhanced HEX editor, useful for Chinese programmer because it can display Chinese charset.
natsamtan246 commented 1 year ago

HEX editor is required to verify my assumptions. It's possible to dump RAM and edit, because RAM data are already decompressed. But it's impossible to edit ROM in HEX editor directly, because of :

  1. File chunk has header;
  2. Compression mechanism;
  3. PSX CD has its own checksum;

Oh I see, I kind of figured that might happen... I know people patch roms and stuff, but I have no idea how all that works yet, haha. I assume you can bypass a lot of restrictions using emulators as they probably don't need all the proper stuff to run the game correctly.

Unneccessary, just use "brm.dump.CdSplitter.java"

JP and EN version are all using LZSS compression, but maybe they've different arguments. I can't confirm that "brm.hack.Compresser.java" is suitable for EN version, you can test by "brm.dump.Uncompresser.java" and "brm.hack.Compresser.java". Maybe the compressed text length exceeds the limit.

In this game, we cannot modify the sentence length, the translated sentence length cannot exceed the pre-translation length. It is important to be aware of this, otherwise you'll waste a lot of effort.

Okay, I will give it a try! So, I'm making progress, I'm not super knowledgeable in java, so I'm trying my best to understand. I finally found conf.properties and set it to the correct directories. It doesn't seem to split the English rom when I run CdSplitter.java directly in Eclipse even with the correct directories and an English rom in brmen. I'm unsure if I need a specific rom or file type. I don't want to bother you with a million questions and my lack of progress, so I will continue to try, don't feel the need to reply. I'm assuming I need to use the "test" function in Eclipse to run the CdSplitter program with the specific file name. I accidentally found your tests, lzss, compressor, and extractor tests, and set them to run. Your test 4 in the compressor test was missing a couple slashes on line 109. I ran all the tests with the files extracted from PowerIso but renamed to match your schema. I was able to get them all to run without errors, but I don't understand what they do yet, haha. I think my.LZSSTest was to test your understanding of the algorithm needed, not necessarily anything to test to see if the compression/decompression worked on a specific file. I believe my.ExtracterTest test was your way of testing if your CdSplitter.java functioned the same as other file extractors like PowerIso. However I placed the exact same file at both locations for the comparison and somehow failed still: java uncompressed: ae77ba6ca9d40da30571c2a874a4a778, 5882897 c uncompressed: 135827c51785b1829dedf206bf237107, 832265 expected:<[ae77ba6ca9d40da30571c2a874a4a778]> but was:<[135827c51785b1829dedf206bf237107]> I'm guessing it's cause your method of splitting is somehow different that other methods.

As for my.CompressorTest, I might be able to change the compressor function to the decompressor function and make it work that way. I however need to figure out the CdSplitter program first, which I assume I just need to make a test that can run it on the file I need it to.

  1. https://pan.baidu.com/s/1kSgZlhZ-mrod9wCxCk_sGw?pwd=b4zi <<PS汉化教程.exe>>(PSX Game Translation Tutorial). Only for Chinese beginner, I doubt it's not very useful for you.
  2. https://fabiensanglard.net/doom_psx/psx.pdf For advanced programmer. Learn to it if you need asm hack.

I have some important tools:

  1. https://www.romhacking.net/utilities/475 . It's a PSX emulator and debugger, it can only run on WINXP, so install VMWARE and WINXP first and prepare to spend LOOOOTS of time on it :(
  2. https://www.romhacking.net/utilities/818 . It's an enhanced HEX editor, useful for Chinese programmer because it can display Chinese charset.

Thank you very much! That HEX editor is cool. I can't download the Baidu stuff cause it seems to want me to have an account, but I can't make one overseas. If you think I don't need it though, then I probably don't need it, but I do appreciate the help!

jywjyw commented 1 year ago

I finally found conf.properties and set it to the correct directories. It doesn't seem to split the English rom when I run CdSplitter.java directly in Eclipse even with the correct directories and an English rom in brmen.

Use ISOBuster software to copy *.CD and SLUS_007.26 from EN-ISO to "endir", Don't forget to pull newest code, I changed something a few days ago. Change variables in conf.properties(endir,desktop) to your own directories. Right click the Main Method Body of CdSplitter.java (see below codes), "Run As ...Java Application", wait for seconds, you'll see some files generating in your "desktop" directory

public class CdSplitter {
    public static void main(String[] args) throws IOException {
        //split Japanese ROM
//      CdSplitter splitter=new CdSplitter(Conf.desktop+"brmjp\\");
//      splitter.split(Conf.jpdir);

        //split English ROM
        CdSplitter splitter=new CdSplitter(Conf.desktop+"brmen\\");
        splitter.split(Conf.endir);
    }
}

Regarding the issue of compression, I remember something, When I decompress the raw file from EN-ISO, then compressed it by "Compresser.java", my compressed file length is longer than raw file. I can know how to decompress through debugger, but I don't know how SquareSoft compress it. Although "Compress.java" works fine, I think it needs improvement for EN-ISO, but it's difficult for me.

natsamtan246 commented 1 year ago

Use ISOBuster software to copy *.CD and SLUS_007.26 from EN-ISO to "endir", Don't forget to pull newest code, I changed something a few days ago. Change variables in conf.properties(endir,desktop) to your own directories. Right click the Main Method Body of CdSplitter.java (see below codes), "Run As ...Java Application", wait for seconds, you'll see some files generating in your "desktop" directory

public class CdSplitter {
  public static void main(String[] args) throws IOException {
      //split Japanese ROM
//        CdSplitter splitter=new CdSplitter(Conf.desktop+"brmjp\\");
//        splitter.split(Conf.jpdir);

      //split English ROM
      CdSplitter splitter=new CdSplitter(Conf.desktop+"brmen\\");
      splitter.split(Conf.endir);
  }
}

Oh wow, thank you for the help! I don't know why, but for some reason when I seen that in your code, I just thought it was old code you felt like leaving in but commented out. I didn't even consider uncommenting that part back in to use it. I see CdSplitter also decompresses the files, huh. I did have the extracted files in the endir but I didn't think about the uncommenting thing, haha. Also, I think you want (Conf.desktop+"\\brmen\\") if you want it to go to User\desktop\brmen\ and not User\desktopbrmen\ .

Regarding the issue of compression, I remember something, When I decompress the raw file from EN-ISO, then compressed it by "Compresser.java", my compressed file length is longer than raw file. I can know how to decompress through debugger, but I don't know how SquareSoft compress it. Although "Compress.java" works fine, I think it needs improvement for EN-ISO, but it's difficult for me.

Oh I see! That's so smart to decompress through debugger, I didn't even consider the possibility. Don't worry, you've helped so much already, I'm sure I can figure out how to improve the compressor! At least hopefully, haha. I guess one thing I need to figure out is if your compressor recompresses the whole file or if it only compresses the new text and then replaces only the compressed unedited text in the compressed file with the compressed new text. I would assume it's the latter since you can't increase the length of the sentences, so I think that implies the edited and unedited compressed texts are merely swapped within the already compressed file.

Although since you said "raw file" that makes me think it does the whole file, which if that's the case, I have no idea how you keep the text in exactly the correct spot and the correct size without trial and error.

jywjyw commented 1 year ago

I guess one thing I need to figure out is if your compressor recompresses the whole file or if it only compresses the new text and then replaces only the compressed unedited text in the compressed file with the compressed new text. I would assume it's the latter since you can't increase the length of the sentences, so I think that implies the edited and unedited compressed texts are merely swapped within the already compressed file.

Although since you said "raw file" that makes me think it does the whole file, which if that's the case, I have no idea how you keep the text in exactly the correct spot and the correct size without trial and error.

Sorry, my English is poor, I don't quite understand your question. I will give you an example, hope it can help you.

When SC01.CD is splitted, you can see 85 directories or files (maybe each directory represents a game scene?). In directory "001", the file called "0.4" contains game dialogs and some codes. I call it *.4, means it's a compressed file type in ROM. You can open file "0.4" by crystalTile2.exe, choose a charset table (use "src/main/resource/charset1_en") and enable it, then, you can find some dialogs on address 0x60E00. I have uploaded a new file 'translation/brm-en.xlsx', it contains dialog addresses.

You can research "0.4" in hex editor, SquareSoft mixed dialog texts and function codes together. So it's IMPOSSIBLE to change each dialog text's length.

When rebuild the ROM, since we know where is dialog and how long is it in brm-en.xlsx, the dialog parts of file "0.4" will be replaced to new ones, then whole file "0.4" will be compressed, the compressed file length cannot be greater than a specified value. The "specified value" is stored in "brmen/SC01/001/headers.bin"

noanj commented 1 year ago

Hey hello. How can everyone use your software? I need to extract the menu font and dialog font for the US version.

jywjyw commented 1 year ago

Hey hello. How can everyone use your software? I need to extract the menu font and dialog font for the US version.

This is not a tool that can be used directly by clicking on it, but a set of codes for developers to use. It can dump some pictures, such as menu font, but only for JP version.
Dialog font of this game is not texture, you should use emulator to capture dialog font. Using emulator is easier than using code. 未命名1图片

menuFont