Unable to compress arm9.bin for Tales of Hearts DS Anime Edition

TheCopulator

New Member
OP
Newbie
Joined
Dec 18, 2023
Messages
4
Trophies
0
Age
36
XP
53
Country
Canada
Rom: Tales of Hearts DS Anime Edition

Hi,

I'm still very new to romhacking. I am currently working on Tales of Hearts DS to translate in English.
Most of the menu text is in arm9.bin. I first used CrystalTile2 to do the following steps
1) Open Crystaltile2, decompress Arm9.bin
2) Translate a string
3) Open Crystaltile2, replace arm9.bin with the compression option

These steps works most of the time. (Sometimes, I do get the infamus, file is too small blabla when compressing arm9.bin), but I had a lot of success with this method.
I was able to translate most of the main menu.

The thing is this method is relatively manual and I would like to have a one click batch file to create a new NDS rom with my arm9.bin translated to test it in Desmume.

I read a lot of different romhacking sites and found out that the arm9.bin file used some kind of BLZ compression than be compress/decompressed using CUE's tool.
So what I did is

1) Unpack the original nds rom using ndstool in a folder
2) Decompress arm9.bin using Cue's tool
blz -d arm9.bin
3)Translate a string
4) Recompress using cue's tool
blz -en9 arm9.bin
5) Create the new rom using ndstool

When I do these steps, the game stays on a black screen when I open it. I'm not even able to see the Namcobandai title.

- Decompresing arm9.bin using Cue's tool works perfectly.
- I already did some test and I'm able to use desmume to open the memory view, find my string and hex edit and this works
- When I say translate a string in my steps, I'm basically hex editing the file with hxd, not updating any pointers and padding with 00s

What I also tried:

1) Take arm9.bin from Tinke
2) Decompress arm9.bin using Cue's tool
blz -d arm9.bin
3)Translate a string
4) Recompress using cue's tool
blz -en9 arm9.bin
5) Replace the file in Tinke and save the rom

Using Tinke will work when I just hex edit a simple string. If I try to update the pointers and update more strings, I'll still get a black screen and the game won't load.

Is it that I'm not using properly cue's tool to recompress the arm9.bin?
Maybe there are some steps required?

Thank you for all your help!
Post automatically merged:

To add more information, The command I uses with ndstool are the following. They have been taken from DSLazy batch files.

- Unpack the rom
ndstool -x TOH_Original.nds -9 NDS_UNPACK/arm9.bin -7 NDS_UNPACK/arm7.bin -y9 NDS_UNPACK/y9.bin -y7 NDS_UNPACK/y7.bin -d NDS_UNPACK/data -y NDS_UNPACK/overlay -t NDS_UNPACK/banner.bin -h NDS_UNPACK/header.bin

- Pack the rom
ndstool -c new.nds -9 NDS_UNPACK/arm9.bin -7 NDS_UNPACK/arm7.bin -y9 NDS_UNPACK/y9.bin -y7 NDS_UNPACK/y7.bin -d NDS_UNPACK/data -y NDS_UNPACK/overlay -t NDS_UNPACK/banner.bin -h NDS_UNPACK/header.bin


Also, I'm not sure if this is the expected behavior but the new size of the rom is lower than the original.
Original: 262144Kb
New: 242 524Kb

Thank you!
 
Last edited by TheCopulator,

mn1712trungson

Member
Newcomer
Joined
Oct 15, 2022
Messages
15
Trophies
1
Age
31
XP
341
Country
Vietnam
Read history.txt inside Cue's GBADS compressors folder.
You need update ARM9 size after compressed with Cue's tools (usually smaller than OG).
ndstool often trims data, making the output file smaller, but usually does not affect the structure.
You can use Tinke (legacy) to resave the file to its original size.
You need the NDS ROM to update the ARM9 size in the ARM9 file:
- get the ARM9 load address (offset 0x0028)
- get the ARM9 autoload (offset 0x0070)
- the offset is the previous dword value @ autoload
- change the sizes in the 1st/2nd/6rd dwords pointed by the offset:
+ 1st: ARM9 decompressed size - 0x18
+ 2nd: ARM9 decompressed size
+ 6rd: ARM9 compressed size (0 if ARM9 is uncompressed)
(do not forget update all values with the load address)

load = *(int *)ROM[0x0028];
auto = *(int *)ROM[0x0070];
offset = *(int *)ARM9[auto - 1*4] - load;
*(int *)ARM9[offset+0*4] = load + ARM9_decompressedsize - 0x18
*(int *)ARM9[offset+1*4] = load + ARM9_decompressedsize
*(int *)ARM9[offset+5*4] = load + ARM9_compressed_size (0 if decompressed)
1703730558780.png

 
Last edited by mn1712trungson,

plasturion

temporary hermit
Member
Joined
Aug 17, 2012
Messages
1,430
Trophies
2
Location
Tree
XP
4,015
Country
Poland
When you get screen freeze after updating pointers (if it's the main reason after file update), probably you didn't calculated new address correctly. Do you add segment of arm9.bin ram location to put absolute value of pointer? commonly it's the fourth byte speaking of low-endian contianing 02h (common location for most games where the arm9.bin begins in ram - 2000000h ), you need that value. However I'm not sure, I'm just guessing, try also revision of your pointers updating method and compare with original ones on your uncompressed output file.
 

TheCopulator

New Member
OP
Newbie
Joined
Dec 18, 2023
Messages
4
Trophies
0
Age
36
XP
53
Country
Canada
Hi @mn1712trungson, thanks a lot for all this information!! I'm sure I didn't update any of the information that you mentioned so I assume you're pointing me in the right direction to fix the issue! I'll be working on that today or tomorrow. Thanks again :)

@plasturio, thanks for your comment. I think I'm updating the pointers correctly because I was able to recompress Arm9.bin with Crystaletile2 at some point and I had updated like 40 different entries in the files and they all worked.

I'll get back to you with what I've found.
 

TheCopulator

New Member
OP
Newbie
Joined
Dec 18, 2023
Messages
4
Trophies
0
Age
36
XP
53
Country
Canada
Hi @mn1712trungson,

Thanks to your advice, I was able to fix the issue. I'm now able to open my patched rom easily and very happy now :D.

For those that are interested, I made a small python function to update the arm9 values based on the instructions.
It is not rocket science but it may help someone

game_iso_path: path to the original iso to read the load and auto value
compressed_arm9_path: path to your arm9 compressed file
decompressed_arm9_path: path to the decompressed version of the arm9 file

And now, I'll be working on some overlays and have some fun.

Thanks again everyone
 

Attachments

  • update_arm9.zip
    519 bytes · Views: 60

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Real Jdbye @ The Real Jdbye:
    rice video is really fast, there are some games i still use it for because they are problematic with gliden64 and other plugins dont run the game properly
  • The Real Jdbye @ The Real Jdbye:
    well maybe just one game. mystical ninja starring goemon
  • The Real Jdbye @ The Real Jdbye:
    something about that game causes slowdown issues with most gpu plugins, even with rice video if i dont use the right settings
    +1
  • RedColoredStars @ RedColoredStars:
    @BigOnYa AutoRCM here too with hekate as reboot to payload. Only time I need to push a payload is going from sysMMC back to emuMMC. But its just plug it into my phone and a second later I'm all set. I have all of my games with online features on sysMMC. Like Mario Kart, Mario Party games, etc.
    +1
  • RedColoredStars @ RedColoredStars:
    Off to watch Nosferatu. Later all. Have a good evening, day, afternoon. Whatever it may be where you are. :)
    +1
  • Xdqwerty @ Xdqwerty:
    @The Real Jdbye, yeah, I wanted to play it but it ran like shit
  • The Real Jdbye @ The Real Jdbye:
    i think you just need to turn framebuffer emulation off in rice video and it fixes the slowdown
  • I @ imafsiry:
    hey red send me tutorial on how to rcm on phone noob
  • I @ imafsiry:
    here
  • SylverReZ @ SylverReZ:
    @imafsiry, There should be a guide somewhere on GBAtemp.
  • SylverReZ @ SylverReZ:
    An app exists for Android called Rekado which is a payload injector for the RCM exploit to work. Don't know if it's still active.
  • Xdqwerty @ Xdqwerty:
    Brb, and if not, good night
  • MrGreenleaves @ MrGreenleaves:
    hi, i have a problem with a game in twligth menu, the game is bleach dark souls, the save get corrups allways no matter if you try with USA version or Europre version, i use my nintendo dsi and my nintendo dxi xl, i have install the lates version of twiligth menu and nds bootstap, someone can helpe me?
  • K3Nv3 @ K3Nv3:
    Why are Sherlock Holmes games so expensive
  • BigOnYa @ BigOnYa:
    That's Elementary, my dear Watson
  • K3Nv3 @ K3Nv3:
    That thing you didn't graduate from?
  • I @ imafsiry:
    Requesting access to USB device...NotFoundError: Failed to execute 'requestDevice' on 'USB': No device selecte @
  • I @ imafsiry:
    thats what shows when i plug it in
  • SylverReZ @ SylverReZ:
    @imafsiry, What method? Phone or RCM Loader?
  • RedColoredStars @ RedColoredStars:
    @imafsiry You just install Rekado to your phone and then plug your Switch into your phone when it's in RCM mode. Rekado should automatically pop up on your phone and ask which payload you want to send.
    +1
  • RedColoredStars @ RedColoredStars:
    @imafsiry You can also set it to auto launch the payload of your choice so no user input is even necessary.
    +1
  • TotalJustice @ TotalJustice:
    thats what i use also. works better if you launch hekate from rekado as you won't need to update the payload
    +1
  • TotalJustice @ TotalJustice:
    as hekate launches the latest payload on the sd card (unless the sent payload is newer)
    TotalJustice @ TotalJustice: as hekate launches the latest payload on the sd card (unless the sent payload is newer)