News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Summon Night Craft Sword Monogatari - Compression and text help  (Read 4685 times)

paranoodle

  • Guest
I've been wanting to play this game since I found out it existed (sometime around 2008), and after seeing several projects to translate it start and end, I thought I would just try it on my own.

The translation part shouldn't be too much trouble: I know enough Japanese to be able to translate fairly accurately if I'm allowed a dictionary. I've been hitting a few problems with the actual hacking of the ROM, though. Please keep in mind this is my very first attempt at modifying a game, and two days ago I had never touched a hex editor. However, I am currently studying IT, so most things I've used so far I at least knew a little about. I've worked with MIPS (which seems very close to ASM) and hexadecimal in decent amounts.

Now onto the work I've done and my current problem(s):

Since English characters are used in the naming screen, I take it I won't have to create my own font, and that I should get the text to display by using its table codes.
Thanks to Ritchburn's text dump (from GBATemp) I could see where the script was kept, and using breakpoints figured out it was compressed in lz77. I decompressed it and found readable text, very nicely encoded in Shift-JIS.
However,
1. I cannot locate the pointer tables, leading me to think they are possibly compressed as well.
2. There is a lot of non-text between dialogue bits, and I can't figure out what they're for.
3. I have absolutely no idea how to re-compress the text after modifying it in a way that would allow me to insert it again.

I've been told that using Cartographer and Atlas for extracting and inserting the script is the easiest way, but would that still work with compressed text? If not (which I expect is the case), how should I go about this?

If there's anything more you'd need or if there's anything I've done wrong, please tell me! I am also aware this is a bad beginner's project, but it's the one I want to work on and I'm ready to put time and effort into it.

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Summon Night Craft Sword Monogatari - Compression and text help
« Reply #1 on: August 18, 2011, 07:53:46 pm »
Non text between dialog? That is usually control codes.

StorMyu

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Summon Night Craft Sword Monogatari - Compression and text help
« Reply #2 on: August 18, 2011, 10:03:49 pm »
Now onto the work I've done and my current problem(s):

Since English characters are used in the naming screen, I take it I won't have to create my own font, and that I should get the text to display by using its table codes.
from what I remember, the size of the letters will be a problem. (read docs about Variable-width font)

Thanks to Ritchburn's text dump (from GBATemp) I could see where the script was kept, and using breakpoints figured out it was compressed in lz77. I decompressed it and found readable text, very nicely encoded in Shift-JIS.
However,
1. I cannot locate the pointer tables, leading me to think they are possibly compressed as well.
2. There is a lot of non-text between dialogue bits, and I can't figure out what they're for.
3. I have absolutely no idea how to re-compress the text after modifying it in a way that would allow me to insert it again.
1. I can't really help you on that... everything is quite game-specific...
2. You have to try but as Henke said, it's probably just control codes.
3. Check utilities in Romhacking.net and you'll see something for that. but be aware that any file can't be insert back without taking care of other stuff (size / LBA etc)


I've been told that using Cartographer and Atlas for extracting and inserting the script is the easiest way, but would that still work with compressed text? If not (which I expect is the case), how should I go about this?
You can't change compressed text... however you can change them using Cartographer/Atlas and then compress them back...

If there's anything more you'd need or if there's anything I've done wrong, please tell me! I am also aware this is a bad beginner's project, but it's the one I want to work on and I'm ready to put time and effort into it.
Since you have some experience as a programmer, it's not really a "bad" beginner's project.

Spikeman

  • Hero Member
  • *****
  • Posts: 1063
  • *unce unce unce*
    • View Profile
    • None at the moment, check out my Last.fm page instead?
Re: Summon Night Craft Sword Monogatari - Compression and text help
« Reply #3 on: August 18, 2011, 10:32:28 pm »
1. I cannot locate the pointer tables, leading me to think they are possibly compressed as well.
2. There is a lot of non-text between dialogue bits, and I can't figure out what they're for.
3. I have absolutely no idea how to re-compress the text after modifying it in a way that would allow me to insert it again.

1. Best way to do this is debugging. Since you've worked with MIPS, figuring out ARM shouldn't be too difficult. My recommendation is to find a copy of No$GBA debug version, it's by far the best tool for the job. GBATEK should tell you everything you need to know about the hardware, and even about ARM.

Specifically, what I would do in this situation is savestate right before a piece of text in game that you've also found in the script, then do a read breakpoint on the address of the text. Since the text is compressed, it should break in the middle of a BIOS call, which you can press F8 once or twice to escape from. You should find yourself near a SWI call, this is how the game decompresses the text. The cool thing is, if you set a breakpoint just before the SWI call, the source address of the text will already be in r0. You should be able to easily work backwards and see how r0 is being set, usually this involves loading from a pointer table, and some multiplication and addition. This might be confusing at first, but it's a great first project to learn debugging.

2. Like others have said, probably control codes. Only way to find out for sure is set a read breakpoint and see what the game does!

3. There are many apps for this in the utilities section. I use this one: http://www.romhacking.net/utils/433/

You'll have decompress the text you want to change, modify it, and then recompress it. Note that the recompressed text may be larger than what you started with. Make sure you have enough room to reinsert it. (You can always relocate the text to the end of the ROM if needed, there isn't usually a problem with expanding GBA games.)
Open Source Hacking Projects: Guru Logic Champ, Telefang 2, (Want more? Check out my GitHub!)

KC

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Summon Night Craft Sword Monogatari - Compression and text help
« Reply #4 on: August 19, 2011, 01:08:43 am »
Those are indeed control codes, and more. I looked into the game a few years ago, and all the text is embedded into a scripting language which controls more or less everything in the game. Not compressed though. The menus are built with those scripts, the events are handled by it, etc. It's quite big and features stuff like branches and sub function calls. It will definitely need a good bit of reverse engineering and programming. As it's an interpreted script with branches, that of course gets rid of the need for any pointer tables in the file. It will only have a pointer to the beginning of the file, though not an absolute one as the rom includes several archives.
You will also need to write a VWF as the game doesn't natively support it.

Klarth

  • Sr. Member
  • ****
  • Posts: 495
    • View Profile
Re: Summon Night Craft Sword Monogatari - Compression and text help
« Reply #5 on: August 19, 2011, 02:54:08 am »
I've been told that using Cartographer and Atlas for extracting and inserting the script is the easiest way, but would that still work with compressed text? If not (which I expect is the case), how should I go about this?
Judging from KC's input about the game's text features, you won't be able to handle this game with a Cartographer+Atlas duo.  First order of business is to deal with the archives so you can extract/rebuild them.  You can download TableLib as a reference on how to program a simple dumper/inserter in C++ here: http://www.romhacking.net/docs/330/

Minimum you'd have to do utility wise to handle the text, would be to create a dumper that interprets the scripting language, dumps pointers as Atlas embedded pointers, and dumps text.  Or you could opt to create your own inserter too if you want a script that could be slightly neater.  If you end up making progress in the text utilities, but hit a snag with TableLib or Atlas, PM me and I should be able to help you out.

paranoodle

  • Guest
Re: Summon Night Craft Sword Monogatari - Compression and text help
« Reply #6 on: August 20, 2011, 03:16:42 pm »
Thank you everyone for your quick replies!

I'll spend the next few days reading up on C++ to help me then, since I sadly do not have any experience with it (I've only coded with Java). I have a few friends IRL who have done extensive work with it though, so I can easily ask them for help if need be.

For the debugging so far, I've been using VBA-SDL and I haven't encountered any problems, but should I switch to No$GBA?
I've also been using GBATEK as a resource since I started, that site is incredibly useful.