Final Fantasy IV DS tabling/compression/script question

Discussion in 'NDS - ROM Hacking and Translations' started by xkappax, Aug 16, 2008.

  1. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    Hello everyone.

    I have decided, as a personal project, to try to hack the script of Final Fantasy IV DS. While this is very much a personal project, it's something I'm really serious about and really want to do. I am trying to make some edits to the script in final fantasy iv ds, and i've run into some snags. I am changing some small things like the characters names, since I grew up in an era where naming your character was very much commonplace.

    I am not really a total n00b, I have a little bit of rom hacking experience. Coupled with my obsessive compulsiveness, I can't really let this rest until I figure it out.

    Basically, I've got the characters renamed already on the menu screen and battle screen (please don't laugh at my names, Karl is a character from my comics, and Sara is my name)


    I also have found some of the text, which would be the "speculation" text. Everytime you go to your menu on the world map, your character has a little thought bubble, and I was able to edit these no problem.


    This is where the problem comes in. I have located what I believe to be the text.. The file is called CAST_EVENT_MSD.dat and it is located in the N folder of the rom (probably for "north america"). If you look at the top line, you can see the name "Cecil" very clearly.

    I can view bits and pieces of the text throughout in what appears to be unicode, but then there are just garbled symbols, too. and this worries me as well.

    to me this looks like this dat files is calling in files that I cannot find anywhere else. Which leads me to believe that this is some sort of compressed file, but when I look at it in the hex editor, I cannot tell if this is compressed or not. It doesn't look like the examples that i've read about in the countless tutorials that I've read.

    Anyway, all of that being said, I was wondering if someone can shed some light on where I need to go from here. Should I be tabling this? Is this compressed? basically what should I be doing to get this script to be to the point where I can edit it?

    thank you all for your help/advice/wisdom in advance.
     
  2. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,712
    Country:
    United Kingdom
    Wow it is very similar to FF3.

    Back on topic in the "worried.jpg" the extensions in the file names have a lz aka lempel ziv aka the most common compression in GBA and DS games.
    While there are occasionally tweaks to the LZ compression most LZ compressed stuff is compatible with the BIOS decompression features, certainly to the extent that it is worth a try). A command line app that serves me well in such events:
    http://gbadev.org/tools.php?showinfo=56
    romhacking.net has recently added a bunch of other GBA (and so DS) compatible LZ compression apps.

    You may have to chop off the start of the file too as sometimes it is only the text that is compressed, unfortunately in these events the starting point is somewhat important so it may take a few goes.

    Compression in this case works but assigning a (short) name to a block (which is bounded by something usually outside the commonly used hex values (in this case the values pre 20hex as they are control codes) and then calling said block when decompressed. This is why the text is halfway readable at the start of the text section (in unicode or a closely related encoding system as you point out) as these form the "library".
     
  3. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    Thank you very much for your quick reply! I was actually kinda relieved to hear that it seemed similar to FF3, because this means that it isn't some weird never before seen compression type, and since that game has been hacked, things are not so hopeless for me afterall.

    I actually read some of your tutorials on the forums and downloaded your pdf and that is what led me to get as far as I actually have. They were wonderfully written! [​IMG]

    To be completely honest, I'm not that great with command line stuff, but I have a friend coming over pretty soon that may be able to help me with it. I've downloaded that application you referenced and am going to have him take a look at it.

    Would it be possible for me to contact you if I have any further questions on compression once I get started trying to decompress this stuff? I promise that I will not barrage you with 10,000 PM's a day begging for assistance.

    thank you so much for your help!
     
  4. javad

    Member javad GBAtemp Regular

    Joined:
    Jul 8, 2007
    Messages:
    255
    Location:
    malta
    Country:
    Malta
    good luck
     
  5. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,712
    Country:
    United Kingdom
    Take a wander over to http://www.romhacking.net/?category=&P...itle=&desc= and try out some of the LZ compression applications they have there, many have fairly nice GUIs.

    You can PM if you want but you will equally get a response if you posted here and there are several other talented rom hackers around these parts who could also help. Not to mention a PM will just sit in and rot in an inbox whereas others are free to learn from posts.

    As for the docs, it is always nice to get feedback. I have rewritten a lot of it but got sidetracked by various videos and games so I am a bit behind where I wanted to be.
     
  6. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    you are my hero. We got it. my friends just got here and they extracted it.

    thank you!

    I might need help getting it back into the rom, but i'll do my best to figure it out!

    Hurray! Seriously, this made my day.
     
  7. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    All right, here we go.

    I was able to get to the script and edit it. I am having a hard time putting it back into the game. ...

    I used the program that was mentioned above to decompress it. It was a .dat file entitled CAST_SCRIPT.MSD.DAT or something to that extent.

    I am able to go in and change all the cecil's to the name I want and all the other names to what I want them to be.

    Then I put them back into the program and told them to go back to a .dat file ...
    the file that i get is smaller than the original, i believe the original is 448k and the new one is 310k ...

    i place this file back in the rom to be packed, and repack it. The game begins just fine, and the first cut scene starts. As soon as the soldier in the first cut scene starts talking, the game freezes.

    any ideas on what I've done wrong? I know that this was said earlier by FAST6191:

    "You may have to chop off the start of the file too as sometimes it is only the text that is compressed, unfortunately in these events the starting point is somewhat important so it may take a few goes."

    I'm not really sure how to chop off the start of the file and was wondering if you could elaborate on this. I can provide screen shots of anything if needed, so please just let me know.

    I'm so close I can taste it!
     
  8. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,712
    Country:
    United Kingdom
    First I assume this is definitely a compression issue, games can crash if you mess up the text (as in encoding and/or pointers).

    The only thing I can think of off the top of my head is the recompression was a different form (there are VRAM and WRAM versions and they are slightly different. http://nocash.emubase.de/gbatek.htm#biosde...essionfunctions (page search from there for "LZ77UnComp"). While the vram version is intended for video only it is treated as a mild suggestion (and vice versa with wram) and I suspect this is what you have fallen foul of. Try using the other method and if that does not work I would consider shifting the start of the file (if you read the link above it says on VRAM
    "data be halfword aligned, data is written in units of 16bits.
    If the size of the compressed data is not a multiple of 4, please adjust it as much as possible by padding with 0. Align the source address to a 4-Byte boundary."
    This means you have to adjust to account for those (it also could explain why the compression went up so much: those limits can often serious affect the compression gains).
    Chapter 3.3 deals with what words, nibbles and whatever else are (there are many other sites but I like this one):
    http://webster.cs.ucr.edu/AoA/Windows/index.html

    re: "chop off the start of the file". I do not know if you have read about narc files (I only mention them as the principle is used a lot in DS roms) but sometimes only the section that has the game info (rather than the storage method info) is compressed so when you try to decompress.
     
  9. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    all right, to clarify a little bit, this is what I seem to have on my hands.
    I'm a graphic designer, not a programmer, so I don't pretend to understand any of this, but I'm trying extremely hard to make this work, regardless.

    This is the process that I followed, first of all.

    I took the file, which is CAST_SCRIPT.MSD.dat from the unpacked rom which I unpacked using DSLazy.
    Following this, We opened that program that you suggested to me to uncompress it using the command prompt.
    We told the program to uncompress it and save it as a .msd file.
    I opened this and I was able to see the script and also edit it.

    Here is where the problem comes in, and I don't know how to proceed any further with this.
    I was able to edit it and the first cut scene plays, but as soon as the soldiers start talking, the game freezes, signifying that I obviously did something wrong.

    I took some screen shots to show things that I am worried about/don't understand and maybe some light can be shed on these things.

    I started going through and I just did a find and replace on every instance of Cecil, just to test things.
    I noticed that even after I've done the find and replace, some instances of Cecil remained when I searched for "Ceci" ... which worried me a lot.

    I also noticed that there were areas with extra characters and weird characters located in the text.

    I also noticed that there were certain passages of text that repeated, and I was unsure why. Here are two screen shots of what seems to be identical text, located at six separate instances throughout the .dat file.

    Back on the subject of the original file, I have located exactly where the script starts or where it looks like it starts in the .dat file.

    While I know I probably should give up the ghost at this point, but I've come so far. It would mean that an entire month's worth of work trying to figure all of this out would be wasted.

    That being said, once again, any help that can be offered would me more than appreciated. As always, if any other information needs to be provided, just post what is needed and I will give what I can.

    Thanks for everything that's been said here already, it's been very helpful.
     
  10. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,712
    Country:
    United Kingdom
    Edit: I have the file now and I am attempting to pull it apart. I will be updating this post as I go. I am using multiple files to try and figure out the format.
    OK SSAM is the standard nitrorom magic code seen in loads of other formats. The number immediately following it is how many files there are in the dat file (flipped for larger files (6d01 becomes 016d or 365 in the case of the CAST_EVENT_MSD.dat).
    F8 is present along with all of the names and there is a digit next to it that gets larger as you go along.
    No readily apparent file locations/sizes.

    From TITLE_Localize.dat
    Code:
    0000000 | 5353 414D 0500 0000 F801 0000 6F00 0000 | SSAM........o...
    0000010 | 7469 746C 655F 6F62 6A5F 3030 2E4E 414E | title_obj_00.NAN
    0000020 | 5200 0000 0000 0000 0000 0000 0000 0000 | R...............
    0000030 | F803 0000 300E 0000 7469 746C 655F 6F62 | ....0...title_ob
    0000040 | 6A5F 3030 2E4E 4342 522E 6C7A 0000 0000 | j_00.NCBR.lz....
    0000050 | 0000 0000 0000 0000 F813 0000 1B01 0000 | ................
    0000060 | 7469 746C 655F 6F62 6A5F 3030 2E4E 4345 | title_obj_00.NCE
    0000070 | 5200 0000 0000 0000 0000 0000 0000 0000 | R...............
    0000080 | F815 0000 7C0F 0000 7469 746C 655F 6F62 | ....|...title_ob
    0000090 | 6A5F 3030 2E4E 4347 522E 6C7A 0000 0000 | j_00.NCGR.lz....
    00000A0 | 0000 0000 0000 0000 F825 0000 7C00 0000 | .........%..|...
    00000B0 | 7469 746C 655F 6F62 6A5F 3030 2E4E 434C | title_obj_00.NCL
    00000C0 | 5200 0000 0000 0000 0000 0000 0000 0000 | R...............
    00000D0 | 0000 0000 0000 0000 0000 0000 0000 0000 | ................
    First file starts at 02C8 (predictably with the RNAN identifier).
    Entire file is 28c8 long.

    Got sidetracked. MSD files are unicode with pointers being fairly basic
    Code:
    0000000 4D53 4441 0000 0100 5401 0000 MSDA....T...
    000000C 0000 0000 51C3 0000 0100 CCCC ....Q.......
    0000018 0010 0000 52C3 0000 0100 CCCC ....R.......
    0000024 0C10 0000 53C3 0000 0100 CCCC ....S.......
    0000030 2210 0000 54C3 0000 0100 CCCC "...T.......
    000003C 3010 0000 55C3 0000 0100 CCCC 0...U.......
    0000048 4610 0000 56C3 0000 0100 CCCC F...V.......
    0000054 5610 0000 57C3 0000 0100 CCCC V...W.......
    0000060 6A10 0000 58C3 0000 0100 CCCC j...X.......
    000006C 7610 0000 59C3 0000 0100 CCCC v...Y.......
    0000078 8210 0000 5AC3 0000 0100 CCCC ....Z.......
    0000084 9810 0000 5BC3 0000 0100 CCCC ....[.......
    First text section at 1000 hex and next at 100C

    Back on track. Redid the layout to make more sense (unusual for DS roms to be like this: normally wildcards are used rather than "fixed width")
    CODE0000000 5353 414D 0500 0000 F801 0000 6F00 0000 7469 746C 655F 6F62 6A5F 3030 2E4E 414E 5200 0000 0000 0000 SSAM........o...title_obj_00.NANR.......
    0000028 0000 0000 0000 0000 F803 0000 300E 0000 7469 746C 655F 6F62 6A5F 3030 2E4E 4342 522E 6C7A 0000 0000 ............0...title_obj_00.NCBR.lz....
    0000050 0000 0000 0000 0000 F813 0000 1B01 0000 7469 746C 655F 6F62 6A5F 3030 2E4E 4345 5200 0000 0000 0000 ................title_obj_00.NCER.......
    0000078 0000 0000 0000 0000 F815 0000 7C0F 0000 7469 746C 655F 6F62 6A5F 3030 2E4E 4347 522E 6C7A 0000 0000 ............|...title_obj_00.NCGR.lz....
    00000A0 0000 0000 0000 0000 F825 0000 7C00 0000 7469 746C 655F 6F62 6A5F 3030 2E4E 434C 5200 0000 0000 0000 .........%..|...title_obj_00.NCLR.......
    00000C8 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    00000F0 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    0000118 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    0000140 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    0000168 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    0000190 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    00001B8 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    00001E0 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    0000208 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    0000230 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    0000258 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    0000280 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ........................................
    00002A8 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 524E 414E FFFE 0001 ................................RNAN....
    00002D0 6F00 0000 1000 0300 4B4E 4241 3C00 0000 0100 0100 1800 0000 2800 0000 3000 0000 0000 0000 0000 0000 o.......KNBA
     
  11. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    As far as that compression goes, what would we have to do to take each file out individually? Would we use the same tool that we used to decompress it in the first place and use a different command, or would I have to do a different process altogether?

    I don't mean to sound like a n00b when it comes to this sort of thing, but while I have been doing romhacking for a little while now, this particular aspect of it is rather new to me. While it is beyond my current realm of expertise, I am more than willing, as I've stated before, to try to learn this.

    I cannot express how thankful I am that you are helping out with this. I seriously would not be able to do this otherwise and I really really appreciate your efforts. I just want to make totally and completely sure you understand how valuable your help and this information is.
     
  12. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,712
    Country:
    United Kingdom
    Compression has long be difficult to deal with (although for the most part it is not quite as bad on the GBA/DS) for rom hackers.

    There are a few apps that can cut up files but is probably easier to use a hex editor.

    Also I am somewhat of an impasse in reverse engineering the file format. It looks like it will either be disassembly or a bit of brute force/in game trials.
     
  13. laurant

    Newcomer laurant Newbie

    Joined:
    Aug 18, 2008
    Messages:
    3
    Country:
    United States
    Hi, I'm xkappax's boyfriend and I've been helping her out with this project and the more I work on it the more interested I get.

    In one of your previous posts you said, "For instance the first file probably starts at or around 0891 hex and is 0198 hex long," and you seem to have almost hit the nail on the head from what I can see. While those two bytes don't seem to point to a location they definitely are the size of the file. The first file is 0891 bytes large while compressed and the second file is 0485 bytes large and so on down the line. The files seem to fall in order in the CAST_EVENT_MSD.dat file with a buffer of zeros between each file.

    I was able to extract the individual files (although I only actually extracted two of them for testing purposes - 365 files is a lot!) and decompress them and they each correspond to the text for a specific scene in the game so I'm pretty sure we've found what we're looking for. I've run into two problems though. First, although I'm not sure if this is a problem, after decompressing the individual files and opening them in a hex editor there is still some random nonsense at the top before getting into the actual text. After the nonsense, though, the text is perfectly clear and appears exactly as it does in the game. My second problem though, and this is the bad one, is that when I recompress the file, even if I make no changes, the file size generally changes by 1 to 5 bytes or so from the original and when I put the newly compressed version into the hex editor the hex is slightly slightly different. When I changed the files and reinserted them into the CAST_EVENT_MSD.dat I made sure that the 10 bytes that signal the start of the event files were located at the same addresses as the original and the game ran fine through the first scene that I changed (albeit without my change displaying for some reason) and froze when I reached the second scene. I'm sure that whatever is causing the file to change, aside from the minor change that I made, is what's responsible for the problem but I just don't know what that is yet. I don't know if it's the decompression, the compression or possibly something else. I know sometimes it's required that the file size be a multiple of 4 bytes large and maybe I'm just not copying the right amount of data when I extract the individual files, although that seems too simple and therefore unlikely. =P

    Is it possible that I'm still "decompressing" something that's not compressed or is it maybe the compressor's algorithm that's causing the change? Any insight that you might have into this matter would be immensely appreciated. We've only gotten as far as we have because of your help and I think we're very close to cracking this thing open.
     
  14. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,712
    Country:
    United Kingdom
    Re: The random garbage at the top, could I get a picture of it but it could well be pointers (I got sidetracked above and reverse engineered the text files that were not compressed). They seem to be the usual identifier (and possibly "format", as in bold, italic...) and pointer stuff.

    For instance the first column after the address is the pointer array (after you swap the bytes around c403 becomes 03c4, ea03 becomes 03ea ........), the next looks to be a ordinal of sorts (load text section 2c4e sort of thing) and I am guessing the next is the format/styling parts but they are all the same so unless I try it or disassemble I am not going to know. Code is the from the babil_minigame.msd file.
    CODE
    0000000 4D53 4441 0000 0100 4F00 0000 ??. O.
    000000C 0000 0000 214E 0000 0100 CCCC ..?. ?
    0000018 C403 0000 224E 0000 0100 CCCC t.?. ?
    0000024 EA03 0000 234E 0000 0100 CCCC ?.?. ?
    0000030 4804 0000 244E 0000 0100 CCCC ?.?. ?
    000003C A804 0000 254E 0000 0100 CCCC ?.?. ?
    0000048 0005 0000 2C4E 0000 0100 CCCC ?.?. ?
    0000054 4C05 0000 2D4E 0000 0100 CCCC ?.?. ?
    0000060 A605 0000 2E4E 0000 0100 CCCC ?.?. ?
    000006C 0006 0000 2F4E 0000 0100 CCCC ?.?. ?
    0000078 6006 0000 364E 0000 0100 CCCC ?.?. ?
    0000084 AE06 0000 374E 0000 0100 CCCC ?.?. ?
    0000090 0C07 0000 384E 0000 0100 CCCC ?.?. ?
    000009C 6807 0000 394E 0000 0100 CCCC ?.?. ?
    00000A8 C207 0000 404E 0000 0100 CCCC ?.?. ?
    00000B4 0608 0000 414E 0000 0100 CCCC ?.?. ?
    00000C0 6608 0000 424E 0000 0100 CCCC ?.?. ?
    [[[[[[[[[[[[[[[[[[[[redacted]]]]]]]]]]]]]]]]]]]]]]
    000039C 7A0F 0000 694F 0000 0100 CCCC ?.?. ?
    00003A8 8C0F 0000 B04F 0000 0100 CCCC ?.?. ?
    00003B4 9E0F 0000 3075 0000 0100 CCCC ?.?. ?
    00003C0 0210 0000 DF30 CB30 B230 FC30 ?.????
    00003CC E030 0030 E130 C330 BB30 FC30 ? ????
    00003D8 B830 0030 7300 7400 6100 7200 ? star
    00003E4 7400 0000 0000 5400 6F00 7500 t..Tou
    00003F0 6300 6800 2000 6F00 6E00 7200 ch onr
    00003FC 7500 7300 6800 6900 6E00 6700 ushing
    0000408 2000 6700 6F00 6200 6C00 6900 gobli
    0000414 6E00 7300 2000 7400 6F00 2000 ns to
    0000420 6100 7400 7400 6100 6300 6B00 attack
    000042C 2000 7400 6800 6500 6D00 2E00 them.
    0000438 2000 5400 6F00 7500 6300 6800 Touch
    0000444 0000 0000 7300 7700 6F00 7200 ..swor
    0000450 6400 2000 6900 6300 6F00 6E00 d icon
    000045C 7300 2000 7400 6F00 2000 7300 s to s
    0000468 6C00 6100 7900 2000 6100 6C00 lay al
    0000474 6C00 2000 6500 6E00 6500 6D00 l enem
    0000480 6900 6500 7300 2000 6F00 6E00 ies on
    000048C 2000 7400 6800 6500 2000 7300 the s
    0000498 6300 7200 6500 6500 6E00 2E00 creen.
    00004A4 0000 0000 4900 6600 2000 7900 ..If y


    Re: crashing. I would be inclined to side with you. Try extracting a file and copying things from another part of the text and not changing the length of sentences, this way it should recompress to the same size. The multiples of things is actually a likely reason for the crashing; doing anything outside of the byte/word/halfword/whatever boundaries for a given takes more CPU time and effort than sticking to the limit and the DS lacks resources but not storage space so the limits are kept (this is also part of the reason compression on the GBA/DS is not quite as nasty as older consoles where space was more of a problem).
    By that time the overall format should be sorted and it will be possible to work around it.

    And yeah several hundred files is a lot. Maybe it is time for us to knock up a script, it will probably be a batch file with some external apps but it will get the job done. Failing that the sources to loads of the other editors (narctool and so on) are available so I will consider abusing one of those.
     
  15. laurant

    Newcomer laurant Newbie

    Joined:
    Aug 18, 2008
    Messages:
    3
    Country:
    United States
    Okay, here's a bit better description of what I did... with screenshots (I was very tired last night when I posted my last post so I apologize if some of it was unclear or hard to follow. Also, I'm sorry about all the boxes in the hex editor. I'm using xkappax's laptop at the moment and it seems to be missing a language pack or something).

    Basically, I located the first compressed file in CAST_EVENT_MSD.dat which seems to start at address 3B08 and end at address 4398. I copied that data and pasted it into a new file in the hex editor and saved it. The resulting file was 2,193 bytes large.

    Here is a screenshot of the beginning of the new file... the same data you'll see at address 3B08 in the original CAST_EVENT_MSD.dat:
    http://www.kappacino.com/ffstuff/file1start_compressed.PNG

    I then used gbalzss to decompress the new file. This seemed to work perfectly except for the nonsense occurring before the actual text.

    Here is a screenshot of the beginning of the decompressed file showing the nonsense at the top and the start of the actual text near the bottom:
    http://www.kappacino.com/ffstuff/file1start_decompressed.PNG

    And here is another screenshot of the decompressed file, this time the bottom to illustrate the end of the text as well as the clear end of the scene:
    http://www.kappacino.com/ffstuff/file1end_decompressed.PNG

    Then I used gbalzss to recompress the, now, decompressed file without making any changes whatsoever.

    Here is a screenshot of the beginning of the recompressed file. You can see that is varies only slightly from the original. The file size ended up being 2,192 bytes... one byte smaller:
    http://www.kappacino.com/ffstuff/file1start_recompressed.PNG

    Something obviously is going wrong in the extraction, decompression or recompression process but what that is, I haven't a clue yet. Last night I did this same thing except I changed Cecil's name to Karl_ (the underscore representing a space to keep the same number of characters) and I reinserted it into CAST_EVENT_MSD.dat. Because the recompressed files were slightly different in size I had to add or a remove some zeros in order to ensure that the files began at the same address as the original, which they did. However, as I said in my last post, the game ran fine through the first scene that I changed but with Cecil's name still reading "Cecil" and not "Karl_" and it wasn't until I reached the second scene that the game froze, although I used the same method to extract, decompress, edit, recompress and reinsert the files.

    But anyway, the main thing that I'm trying to figure out now is what is going wrong that's causing the recompressed file to differ from the original extraction. Once that's taken care of then I'll worry about changing things. I hope that these couple screenshots and my better description of what I did are helpful. Again, if you have any idea what's going wrong here, you're help is much appreciated.

    Thank you again.
     
  16. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    Also, as sort of an addition to laurant's post. ... i noticed something when I was messing around with this file the other night. There is an area in that CAST_EVENT_MSD.dat file that just has the characters names, one right after the other. ... He changed some stuff and it didn't change cecil's name in the top box, and I almost think that this area of text I saw in CAST_EVENT_MSD.dat is the reason why, but I'm not entirely sure.

    As he said above, we are exploring some things, but are still getting some compression issues.
     
  17. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    We are very close. Laurant was able to change the name of the main character in the Mist Cave starting from the Namingway portion to the end of the cave.

    He will post screen shots and an explanation of what he did. I think it might just be a matter of getting the rest of the script out of there now.
     
  18. laurant

    Newcomer laurant Newbie

    Joined:
    Aug 18, 2008
    Messages:
    3
    Country:
    United States
    I successfully changed Cecil's name to Karl_ and ran the game on a DS. Unfortunately I didn't beat the mist dragon (since I was only testing and didn't level up or anything) so I can't be certain that the game won't crash later but I really have no reason to believe it will since I only touched the first file in CAST_EVENT_MSD.dat

    Here are the four pictures. Cecil's name is only said four time during this scene.
    http://www.kappacino.com/ffstuff/DSC01971.png
    http://www.kappacino.com/ffstuff/DSC01972.png
    http://www.kappacino.com/ffstuff/DSC01973.png
    http://www.kappacino.com/ffstuff/DSC01974.png

    After some further review of what I was decompressing, xkappax and I found that parts of the text were repeating even after I extracted the individual file, which I originally thought wasn't happening. So, I basically went in again and started at the same address, 3B08, but this time I only copied the data until address 40FC because after that address you start to see a lot of repeating nonsense and I sort of figured that that might be contributing to the repeating text in the decompressed file. When I decompressed the data between address 3B08 and address 40FC I got a single, clean copy of the text from that scene with the same information at the beginning of the file as before. Then I went through and changed Cecil to Karl_ and recompressed the file. Then I basically just inserted it into the original CAST_EVENT_MSD.dat between addresses 3B08 and 40FC. I also had to delete two 00's that somehow ended up between the stuff I inserted and the start of the remainder of the compressed file (if that makes any sense). Lastly, I scrolled down to check the start address for the second file and compared it to the original value. It was, I believe, three spots too early so I added 00 00 00 in before second file, saved it, packed back to a .nds rom and put it on the DS. As you can see from the pictures the game ran fine up to where I was and the changes actually displayed this time. I'll try the same thing tomorrow with the second file and I'll post the results. Things are starting to look up for this project. With any luck, the second file will work out the same as the first.
     
  19. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,712
    Country:
    United Kingdom
    Nice work. I really like to see improvement hacks.

    Glad you got it sorted too, keep us all apprised of developments.
     
  20. xkappax
    OP

    Newcomer xkappax Member

    Joined:
    Aug 9, 2008
    Messages:
    14
    Country:
    United States
    I thought I'd post an update of sorts. Laurant has everything up to where you get Tellah in your party and it's been tested and it works perfectly so far, so it would seem that all of this did the trick.

    I"m curious about one thing however.
    FAST6191, a few posts back, you wrote:
    "And yeah several hundred files is a lot. Maybe it is time for us to knock up a script, it will probably be a batch file with some external apps but it will get the job done. Failing that the sources to loads of the other editors (narctool and so on) are available so I will consider abusing one of those."

    The way this is going, it seems that it's going to take until next year to get all these files out. As far as making a script to extract the stuff more quickly, what would something like that entail, just out of curiosity?

    Also, there was one other thing. Laurant expressed interest in trying to change the graphics that come up that say "Cecil, Dark Knight" or "Tellah, Sage" or whatever they say. I am going to poke around and try to find where these are located today I think... I am pretty sure that they'd be .lz compressed, but once they are decompressed would I just edit them in Tile Molester or something to that effect? Just wondering cause we were both curious.
     

Share This Page