Romhacking.net

Romhacking => Personal Projects => Topic started by: Vegetaman on February 02, 2010, 08:25:14 pm

Title: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Vegetaman on February 02, 2010, 08:25:14 pm
==UPDATE== (JUNE 6, 2011)

Just a small update; had a request for a Mac/Linux compatible way to figure the checksum (haven't made a full blown command line editor yet; sorry -- it's somewhere on the to do list...), so here's the source code for a small program that should handle it for you in case you want to use the SRAM guide to edit your own file (always remember to make a backup):

https://sites.google.com/site/vegetaman/home/sramchecksum/cpp_code

You can also check my last post in this topic for a copy of the code directly (and yes, I know that the while loop part should really be it's own function with variables -- I did it this way on purpose).

I haven't updated my guide enough to warrant updating on the site, it's mostly superficial stuff right now... Still have plans to work on it, though; I have not forsaken it yet!

 :beer: :thumbsup: :cookie: 8)

==UPDATE== (FEBRUARY 20, 2011)

DOWNLOAD Version 2.2: http://www.mediafire.com/?b7lrwb19s64ybod *NEW*

NEW README: https://sites.google.com/site/vegetaman/home/sramchecksum/readme

Changelog:

- added support for modifying 32 spell slots instead of 24 (run over the lists at your own risk!)
- added the readme file to the .rar package and updated the readme as well

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

==PAST UPDATES==

UPDATE - FEB 19: [just completed a readme.txt]

DOWNLOAD & INSTALL LINK (unzip/unrar and click on setup.exe): http://www.mediafire.com/?ygc6726648ip7x5

README.TXT FILE: https://sites.google.com/site/vegetaman/home/sramchecksum/readme

See my last post in this topic for details.

http://img21.imageshack.us/img21/4120/lufiafinal.jpg

In game screens after use:

http://img44.imageshack.us/img44/2493/elegion.jpg

http://img573.imageshack.us/img573/3265/lufiascrn.png

Hopefully I can get back in to updating it again as more feedback (or bug report) rolls in.

======OLD POST======

I only ask this because I got into hex editing a few years ago due to playing SNES games and doing some programming, and I have been working on a little Lufia & The Fortress of Doom Program (trying to build my C# skills) that takes a ZSNES Save State File and will read out the Gold, Items, Characters, and Stats for that particular save state:

(screenshots and small write-up) http://sites.google.com/site/vegetaman/home/lufia

Anyway, I'm (working on) adding some features to it like being able to take an existing item and change the quantity or turn it into something else, or to add an item where none exists. But is this really "ROM hacking"? I don't see a lot of topics making programs like these (and honestly, once you know the offsets for a game, the programming side is relatively simplistic).

Also, I take it you guys don't do PC games at all? Like I made a program that goes into the Diablo.exe file (v.1.09 only) and pulls out the Unique Item data and makes a text dump file of it.

(screenshots and small write-up) http://sites.google.com/site/vegetaman/home/diablo
(text dump of item uniques) http://sites.google.com/site/vegetaman/home/diablo/uniqueitem

Just wondered if any of this stuff is relevant here, or if I'm a little outside the scope of this place (I think a lot of your graphical and regular ROM hacking is amazingly complicated and my stuff is boringly simplistic by comparison). Also, I have crappy GUI-skills. 

:o

UPDATE #1:

Can somebody move this to the "Personal Projects" forum for me? I'm currently going to focus on Lufia, but I don't think it's necessary for me to make a second topic.

UPDATE #2: (you can read a better version of this update as the current post from me as of Feb 13, 2010)

I took some time to try and figure out the way text is stored in Lufia I (like, text box text), in case I ever wanted to edit what people say. Turns out it is some words or letters and pointers to other words that are in some sort of dictionary. So, after 10 hours of tinkering, this is what I came up with:

http://sites.google.com/site/vegetaman/home/dictionary

And the actual reference dictionary file I made (a sort of key so you can look up words that you just have a pointer to) so you can read through the "ugly looking text dump" and refer to an actual word or name:

http://sites.google.com/site/vegetaman/home/dictionary/masterkey

Still, it is nowhere near complete, and any help would be much appreciated!  :woot!: :crazy: 8) :D

UPDATE #3:

Okay, the Lufia SRAM program is complete. See my latest post (#12, I believe) for info.

http://img21.imageshack.us/img21/4120/lufiafinal.jpg
Title: Re: Are these sorts of projects worthy of this place?
Post by: KingMike on February 02, 2010, 09:56:09 pm
I'd suggest hacking the SRAM instead.
You'll need to hack the checksum value, which would require ASM knowledge to figure out.
But since I like Lufia, I traced the algorithm for you.
Code: [Select]
$00/9429 A0 FC 03    LDY #$03FC              A:0070 X:616E Y:0000
$00/942C A6 1F       LDX $1F    [$00:001F]   A:0070 X:616E Y:03FC
$00/942E A9 02 65    LDA #$6502              A:0070 X:0000 Y:03FC
$00/9431 18          CLC                     A:6502 X:0000 Y:03FC
$00/9432 7D 08 00    ADC $0008,x[$70:0008]   A:6502 X:0000 Y:03FC
$00/9435 E8          INX                     A:4AE7 X:0000 Y:03FC
$00/9436 E8          INX                     A:4AE7 X:0001 Y:03FC
$00/9437 88          DEY                     A:4AE7 X:0002 Y:03FC
$00/9438 D0 F7       BNE $F7    [$9431]      A:4AE7 X:0002 Y:03FB
$00/943A AA          TAX                     A:592C X:07F8 Y:0000
$00/943B 7A          PLY                     A:592C X:592C Y:0000
$00/943C AB          PLB                     A:592C X:592C Y:0000
$00/943D 28          PLP                     A:592C X:592C Y:0000
$00/943E 60          RTS                     A:592C X:592C Y:0000
Save slot 0 is at SRAM 0
Slot 1 is at SRAM $800
Slot 2 is at SRAM $1000
Within the save slot:
Offsets 0-5 = "File0?"
Offsets 6-7 = stored checksum (after calculating the new checksum, store it here)
To calculate the new checksum:
Start with the checksum total $6502. (side note :P )
Beginning with offset 8, read the next little-endian 16-bit value and add it to the total. When the value exceeds $FFFF, drop the leading 1 (so the checksum remains a 16-bit value). Repeat for the remainder of the 2KB save slot (so check for SRAM offsets 8-7FF for slot 1, 808-FFF for slot 2 and 1008-17FF for slot 3).
Title: Re: Are these sorts of projects worthy of this place?
Post by: DarknessSavior on February 02, 2010, 10:39:21 pm
I think the Diablo thing isn't really the kinda thing they do here (though, honestly, I kinda wonder why not. PC game translations are done all the time. Why not PC game apps?)

The Lufia I thing is definitely the right kinda thing, though. Although, usually the programs have to do something other than just list items and stats. I think they might approve it if you submitted it, though.

And don't worry about your GUI skills. There are lots of people here who still think command prompt is the bee's knees, for some reason.  :laugh:

~DS
Title: Re: Are these sorts of projects worthy of this place?
Post by: Vegetaman on February 03, 2010, 01:52:18 am
DarknessSavior - Well, I'm glad to be aboard. I want to develop this program beyond listing things, that was just a jumping off point for this program. However, I see that SRAM is much more direct than doing it to just a simple ZSNES save state (and more useful, too).

Oh, I still use C++ on Linux/Unix frequently, so I'm no stranger to command line (and how much of a PITA in can be). Just using C# to build some skill with it. :) Just figured after reading some modding sites and save state hacking guides on these games that there could be programs made to cut out a lot of extra legwork (plus I could fill in gaps of information that was never discovered or at least put out on the net).

KingMike - Thank you so much for that. Due to my earlier work, I just popped into the SRAM and discovered that, for "File00" (Save Slot 1), the offsets are:

13E -> begin items (listed as item #, quantity #)
1B5 -> end of item list
1B6 -> Hero's Level
1B7 -> Lufia's Level
1B8 -> Aguro's Level
1B9 -> Jerin's Level
1C6 to 1C7 -> Hero HP
1C8 to 1C9 -> Lufia HP
1CA to 1CB -> Aguro HP
1CC to 1CD -> Jerin HP
1CE to 1CF -> Hero MP
...etc...

Well, you get the rest. Anyway, it lends itself quite easily to picking up (very similar to the ZSNES save files, though even more concise, it appears). Never really messed with SRAM before (because of that little checksum dealie, probably, always knew I could edit the ZSNES save files). Seems like everything is little endian (including the pointers for unique item names in Diablo I).

Anyway, I took the ASM information you gave me (and it's been about 4 years since I've touched assembler... I enjoyed it, but it has long been forgotten), and made a little program that compares the file checksum (offset 6-7) to the checksum it calculates for the entire 2KB save slot.

http://img714.imageshack.us/img714/4766/lufiachecksum.png

I've only set it up for File00, but to extend it for File01 and File02 should be easy. This is great, now I just need to make it so it will compute the checksum after I modify something about the game and have it automatically replace it at offset 6-7 for me (right?).

UPDATE #1:

Well, got back around to working on Lufia again last night and this morning. Upgraded the checksum program to do all 3 save slots (I know, unimpressive, I just had to add in an offset incrementer):

http://img40.imageshack.us/img40/5136/sramg.jpg

I got sidetracked making a small program to pull spell names out of Eye of the Beholder (SNES & PC).

http://img694.imageshack.us/img694/4747/eobmagic.jpg

Oh, and could somebody move this to the "personal projects" section? I think I'll be working on this Lufia thing for awhile now.

I'm currently trying to figure out where/how stats are saved. Like, if you change your character level in the SRAM, it shows up that way in game but it doesn't do anything (also, it only shows the last 2 digits, ie. level 255 displays "55". Interestingly, if you set your level to 99, you no longer gain experience because you cannot level further. I am wondering if this means that when you hit level 99 if you can set your SRAM value to say 77 and level up some more (unsure what kind of weird effects this could cause). Just pitching ideas. I seem to recall that if you edit your stats via a save state, the first time you equipped an item or leveled up your stats went back to normal. Oh, and found the offset for gold in the save slot, too.
Title: Re: Are these sorts of projects worthy of this place?
Post by: creaothceann on February 05, 2010, 02:19:08 am
http://img40.imageshack.us/img40/5136/sramg.jpg
Just a note: placing the related checksums (i.e. "given" and "calculated") next to each other vertically makes it much easier to see differences.

I'd put the file selection at the top because that's what the user has to do first.
Title: Re: Are these sorts of projects worthy of this place?
Post by: Vegetaman on February 06, 2010, 04:56:56 am
Just a note: placing the related checksums (i.e. "given" and "calculated") next to each other vertically makes it much easier to see differences.

I'd put the file selection at the top because that's what the user has to do first.

Okay, I just updated my program, and took your advice about where to place the file selector.

http://img31.imageshack.us/img31/6311/veglufiasrm.png

It's starting to come together, I just need to actually make the "change <xxxxx>" buttons functional. And close off a few loopholes that can let people crash the program. And then find some more stuff to add to it.

Any suggestions? The GUI isn't the greatest, but I'm open to any suggestions about it (or features to add to the program).
Title: Re: My Personal Projects (Currently: Lufia & The Fortress of Doom SRAM data)
Post by: creaothceann on February 06, 2010, 04:18:33 pm
You could use advanced controls, like this:

http://www.mediafire.com/file/yrmjyhyncn4/LuSRAM_mockup.7z

(Btw. the tab controls are actually page controls, so they send only an index upon events - there are no separate tabs.)
Title: Re: My Personal Projects (Currently: Lufia & The Fortress of Doom SRAM data)
Post by: Vegetaman on February 08, 2010, 01:03:25 am
Okay, I really like your layout of tab/page controls... I will have to retinker mine. Definitely something to work off of, though. Thanks.  :)

Will try and make it so that both items and equipment and directly moddable. However, at this point, it looks like the only way to increase your stats is to give yourself massive amounts of <name> Potions... As of now, I have yet to figure out how the stats are stored (but the number isn't there directly, from what I can tell). Will have to tinker some more with level-ups and a debugger and comparing two save slots after a level up and see what's getting moved where.

EDIT/UPDATE 1:

Okay, so changing equipment directly does not work. However, you can modify the spell lists and the item lists, and then take care of your characters from there.

http://img51.imageshack.us/img51/5677/testingt.png

http://img705.imageshack.us/img705/6060/spellss.png

This "Elegion" Spell is an extention of flash/bolt/thunder (where it goes elegi/elegio/elegion) except that the spell hits everybody and costs 0 MP. It's like an instant destruction spell. Must've been for playthrough/debugging purposes, as you'd rock the whole game with it. Or for The Sinistrals...

http://img44.imageshack.us/img44/2493/elegion.jpg

Anyway, I know my checksum program works though for what it's supposed to, at any rate.

EDIT/UPDATE 2:

Okay, finally got my GUI all made up. Haven't done the back-end code yet, but should be easy (since I've coded it all two or three times now from scratch).

http://img17.imageshack.us/img17/4875/lufiagui.png
Title: Re: My Personal Projects (Currently: Lufia & The Fortress of Doom SRAM data)
Post by: creaothceann on February 11, 2010, 01:08:11 am
- the SRAM file name isn't related to a particular slot, so I'd put it above the slot selector
- current Gold could go into the "Gold Changer" groupbox (which could be renamed to just "Gold")
- the "Item Slot", "Item Quantity" and "Magic Slot" controls could be converted to comboboxes without editing ability - that way you don't have to parse user input (and selecting a value is easier, imho)
- no "Save" button?
Title: Lufia & The Fortress of Doom Text Dump Dictionary
Post by: Vegetaman on February 13, 2010, 02:40:21 am
I took a brief aside from what I was doing here to try and figure out the Lufia I method of how it stores it's text (I originally wanted to make a text dump). So, the best I can figure out about how the dictionary compression thing works in Lufia I (after around 10 hours of tinkering):

http://sites.google.com/site/vegetaman/home/dictionary

I also created a key that explains what word all the placeholders point to. Here is the dictionary file so you can read through the "ugly looking text dump" and refer to an actual word or name:

http://sites.google.com/site/vegetaman/home/dictionary/masterkey

If anybody knows more about how the algorithm works (or would like to affirm/refute something I have put on my page there), please let me know. The volume of text is too much to paste onto this message board, I think.

- the SRAM file name isn't related to a particular slot, so I'd put it above the slot selector
- current Gold could go into the "Gold Changer" groupbox (which could be renamed to just "Gold")
- the "Item Slot", "Item Quantity" and "Magic Slot" controls could be converted to comboboxes without editing ability - that way you don't have to parse user input (and selecting a value is easier, imho)
- no "Save" button?

-I definitely like the Item Slot/Item Quantity/Magic Slot ideas very much. Makes my life easier in the end.
-I added some other stuff to the Gold Changer box that took up the extra space
-Errr... I was going to have it so when you clicked "add item" it automatically put the item in for you. And then I was thinking about making it auto-fix the checksum every time you do that.

Of course, if anything goes wrong, hopefully everybody made a back-up... And it would be able to completely wreck any .srm file that wasn't for Lufia I as well. Need to come up with some sort of way to validate that it is a Lufia file...
Title: Re: My Personal Projects (Currently: Lufia & The Fortress of Doom Text Dump & SRAM)
Post by: DarknessSavior on February 14, 2010, 06:52:36 pm
Can a mod move this into the "Personal Projects" subforum? Vegetaman is clearly not a Newbie. ^^;

~DS
Title: Re: My Personal Projects (Currently: Lufia & The Fortress of Doom Text Dump & SRAM)
Post by: Vegetaman on February 16, 2010, 06:18:39 pm
Thank you. I'd love for this topic to be moved there.  :)

~STATUS: LUFIA TEXT DUMP~

Anyway, on the Lufia Script/Text Dump front, I used my dictionary to do a text dump of the game... It's good, but not complete:

http://sites.google.com/site/vegetaman/home/dictionary/textdump

Seems like there's some words that are always capitalized in the last dictionary that it misses (names like "Brant"), as well as some extra characters between text boxes that signify something (ie. who is talking, maybe? or some sort of pointer or timer?). Will have to tinker with it more, later. And I also think I've captured all of the text in the game, but when I finish the program I think I will try reading the entire ROM file and see what else pops up.

UPDATE:

Okay, Fixed the text dump program. Now "Brant" and other people's names are proper. Had a programming error for calling the 0c/0d settings. Apparently the "ToUpper" command is picky, so I just concatenated a new string and it works fine now. The textdump has been updated to reflect this.

Still can't figure out how to tell when a new text box should begin so I can trim out the extra crap...

~STATUS: LUFIA SRAM MODIFIER~

On the Lufia SRAM modifier front, I've updated the interface to reflect creaothceann's suggestions, so it now looks like this:

http://img704.imageshack.us/img704/3306/newsram.png

I'm going to have to do validation on the gold box, because I rather people be able to enter in a number that they want (for whatever reason), instead of me limiting them (and populating one of those combo boxes with 4 million numbers would destroy the program, lol).
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: Vegetaman on March 11, 2010, 01:52:17 am
Hey guys, sorry it's been so long since last update. Been busy doing stuff (taking the GRE so I can get into grad school, working on some other computer projects, etc. etc.). Anyway, I've started back into working on my Lufia SRAM project and put the text dump on hold for now, as I can't seem to figure out all the "extra junk" (probably important graphically related stuff) in the gaps between the text boxes.

So, this is where I'm at with the SRAM program currently (I have tweaked the UI a little and added some more back-end code):  :D

http://img704.imageshack.us/img704/7250/lufiamarch2010.png

The only thing I have to do is add the code behind four buttons. Fix Checksum, Update Gold, Add Item, and Add Magic. Shouldn't be too hard, IMO, just need to write the bytes directly to their locations in memory, and I assume it's as easy to write bytes as it is to read 'em. Also, the program is able to pull the Hero Name out of the SRAM file (but I only insert it into the Party Info/Show Magic textboxes; nowhere else).

Hopefully I'll have some semblance of a completed prototype by this weekend. Then I can figure out how to compile the silly thing with all of its dependencies so if other people wanted to try it out, it wouldn't throw all sorts of resource issues (like missing .dlls and such).  :banghead:

EDIT/UPDATE 1:

Okay, so I added functionality to make the "Fix Checksum" button work. As it stands now, when you are all done editing your file, you have to go:

Press "Calculate"
Press "Fix Checksum"
Press "Calculate"

Kind of excessive, I suppose...

EDIT/UPDATE 2:

Did some more Gold tinkering...

(http://img694.imageshack.us/img694/2640/goldyu.jpg)

Maximum gold limit. The counter won't roll over, as far as I can tell, so it's safe to make this the upper limit. It's stored as 3 bytes (0 byte, 256 byte, 65536 byte), so it's pretty easy to manipulate.

EDIT/UPDATE 3:

Interesting glitch I ran across while messing with item updation. If you set a new item you're adding at an item slot that is further away from your last item (like... my last item is Slot 45, but I add Power Oil at Slot 60)... Then every time you go back to your item menu, Power Oil will add one more reference to your item list. Observe:

(http://img691.imageshack.us/img691/8238/glitchi.jpg)

All sorts of little hiccups and glitches, it seems. So far, aside from a few crashes of my program itself (I need to go back and add a lot of error checking), it seems to work really well.

EDIT/UPDATE 4:

Well, for all intents and purposes, the program is done (version 2.1 is the final, it looks like). Just working on a readme.txt file and then I will go back and try to get rid of some of the crashing glitches in case people get "red button syndrome" without entering a proper filename... Then, if I can figure out how to bundle it up with all its necessary includes and such (so we don't get a bunch of .dll missing/random errors/random crashes), I'll be ready to hand the .exe out and let people see if they can have it work on their system. Though since my machine is a Windows Vista x64 box with .NET Framework 3.5... It may be ugly. :'(

On the plus side, it comes in at just around ~1500 lines of code. It could probably be greatly reduced if I made some .dat files (I can think of two hard-coded lists that I could remove that would free up around 900 lines, but all the extra File I/O and data structures would probably not be worth it with such small data sources, so taking out padding and crap, I'd say I wrote 500 lines of meaningful C# code - this being my first big C# project ever), but I think it's pretty efficient as is.

EDIT/UPDATE 5:

Oh, I forgot to put up a screenshot of the final product:  :angel:

http://img21.imageshack.us/img21/4120/lufiafinal.jpg
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: Vegetaman on November 20, 2010, 12:27:53 am
I just wanted to check and see if there was still any interest in this. Life got a bit busy on me these past 8 months... I'd be glad to put up what I've got (the program still has a few bugs), or release the source or something -- if there's any interest. If not, I'll just let this topic die. I guess I could go back and fix some of the lingering bugs (mostly doing with being able to click buttons and wander off to places you shouldn't, but the main functionality of the program is there; there's just some stuff you should not do to your file with it for various reasons).

EDIT:

Note, I am just referring to the SRAM editor. The text dump idea died off a long time ago.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: DarknessSavior on November 20, 2010, 01:11:49 am
You should definitely keep up on this, and don't give up on the text dumper idea either. There are many people here, I imagine, who would love to see a full-fledged Lufia editor released. I am one of them.  :thumbsup:

~DS
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: Jigglysaint on November 20, 2010, 12:15:54 pm
I just wanted to check and see if there was still any interest in this. Life got a bit busy on me these past 8 months... I'd be glad to put up what I've got (the program still has a few bugs), or release the source or something -- if there's any interest. If not, I'll just let this topic die. I guess I could go back and fix some of the lingering bugs (mostly doing with being able to click buttons and wander off to places you shouldn't, but the main functionality of the program is there; there's just some stuff you should not do to your file with it for various reasons).

EDIT:

Note, I am just referring to the SRAM editor. The text dump idea died off a long time ago.

Want to kick it up a notch?  Since yesterday I was messing about in the rom and I have the pointers to the map scripts.  I've been trying to figure out how treasure chests work, and so far it seems that they are part level data and part map script.  I can change the contents no problem, but I can't change the location at which the chests appear.  Changing the map script pointer changes the contents, but not where the contents are.  I also found map data that seems to be used for layers, but erasing that still makes the chests stay put.  I tried search for co-ordinates and that didn't work either.  I also can't seem to get the game to run in the SNES debugger.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: Vegetaman on November 21, 2010, 01:54:01 am
Well, the Lufia SRAM program is about 1500 lines of C# code (granted easily 2/3 of that is probably hard coded lists and other such stuff). And it makes no qualms about overwriting your file; so you have to make back-ups for sure.

The Lufia Text Dump program is equally as long in C#, but I think the premise of how I went about coding it is flawed, so it will require a rethinking and a rework I do believe...

All of my research and thoughts on the subject have been posted for further review, though:

http://sites.google.com/site/vegetaman/home/dictionary/masterkey  <-- all of the "words" available in the ROM (probably the handiest thing I did, IMO). It contains data like this, including both banks of 255 words, that come both in upper and lowercase forms. Of note, I found that Makao is on the place list, and that Elfrea for some reason appears twice.

##|#####|Name
--|-----|-----
00 8e e8 (00)
01 8f e8 Alekia
02 95 e8 Chatam
03 9b e8 Sheran
04 a1 e8 Treck
05 a6 e8 Lorbenia
06 ae e8 Grenoble
07 b6 e8 Kirof
08 bb e8 Medan
09 c0 e8 Surinagal
0a c9 e8 Belgen
0b cf e8 Jenoba
0c d5 e8 Ruan
0d d9 e8 Ranqs
0e de e8 Odel
0f e2 e8 Lyden
10 e7 e8 Arus
11 eb e8 Platina
12 f2 e8 Carbis
13 f8 e8 Bakku
14 fd e8 Linze
15 02 e9 Marse
16 07 e9 Herat
17 0c e9 Soshette
18 14 e9 Epro
19 18 e9 Arubus
1a 1e e9 Frederia
1b 26 e9 Forfeit
1c 2d e9 Makao
1d 32 e9 Elfrea
1e 38 e9 Elfrea
xx 3e e9 <- end of list

http://sites.google.com/site/vegetaman/home/dictionary                    <-- about me working on the program, as well as me showing how I believe the dictionary works with the game

http://sites.google.com/site/vegetaman/home/dictionary/textdump    <-- my initial text dump from the program (needs work, lol)

I think if I would have commented my code, like a good programmer (and also used better naming conventions), it'd be a little easier for me to pick up where I left off... But I'll get there, eventually. (EXAMPLE:)
 
private void button13_Click(object sender, EventArgs e)
        {
            textBox3.Text = "";
            FileStream F = File.OpenRead(textBox8.Text);
            int offset = 0x00;
            if (tabControl1.SelectedTab == tabPage1)
                offset = 0x00;
            else if (tabControl1.SelectedTab == tabPage2)
                offset = 0x800;
            else if (tabControl1.SelectedTab == tabPage3)
                offset = 0x1000;
            F.Seek(0x119 + offset, SeekOrigin.Begin);
            int numheros = 0;
            int lvl;
            heroname = "";
            for (int i = 0; i < 5; i++)
            {
                heroname += Convert.ToChar(F.ReadByte());
            }
            F.Seek(0x1b6 + offset, SeekOrigin.Begin);
            for (int i = 0; i < 4; i++)
            {
                lvl = F.ReadByte();
                if (lvl > 0)
                {
                    numheros++;
                }
            }
            for (int i = 0; i < numheros; i++)
            {
                showStats(i);
            }
            F.Close();
        }
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: Jigglysaint on November 23, 2010, 01:27:33 pm
Er, I should rephrase that.  When I mean map script, I don't mean map text.  I mean the data the game uses for events and things like treasure chests.  I guess I should have said "event data" instead.

Edit:  On second thought, this proves very useful.

Edit:  I'm getting close to figuring out how warps and chests work.  This game is seriously wacked in terms of finding stuff.  I guess that's one reason a proper Lufia editor hasn't been attempted.  So far I found that the contents from A2 07 to Af 07 in ram hold information about warps and chests, but no idea how the game actually goes about collecting this information, or what the info represents.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: Vegetaman on January 26, 2011, 07:31:38 pm
The "mappings" of this game in general is just all sorts of confusing.  :banghead:

Anyway, I've had some e-mail requests, so I figured I'd at least upload what I have of the program (which I haven't worked on in like 9 months) to the internet so people can try it out and use it. I know it has some bugs where it will crash. I make no warranties of the program, yadda yadda, use at your own risk and make sure to back up your .srm file before you modify it. There is no save or restore button on this thing. When you tell it to make a change, it does it automatically on the spot. Add Magic, Add Item, Update Gold, Fix Checksum all will modify your program (I can't remember, but make sure to do Calculate Checksum before you click on Fix Checksum, and then do a Calculate Checksum again to make sure it worked properly). The "HELP" button in the bottom righthand corner may sort of give you some pointers on how to use it, but if you have questions about it - feel free to ask.

Now, my development machine is a Windows Vista (x64) box with Visual Studio 2008 (express), so it probably has .NET framework 2.0 or 3.5, I'm not really sure. I had to make it a click once application since the express version doesn't have a lot of great build options.  :P

Feel free to report bugs and things of that nature, but yes the program can crash due to some unhandled button paths you can go down (but I haven't had any memory leaks or things of that nature, at least).

DOWNLOAD & INSTALL LINK (unzip/unrar and click on setup.exe): http://www.mediafire.com/?ygc6726648ip7x5

One of these days I will post the source code, but it needs some serious cleaning up and tweaking first. I may even just post the whole project file itself so the forms and everything are out there. And I do believe in open source, so I have no problems with people taking my idea and tweaking the daylights out of it.

Somebody e-mailed me a bunch of character EXP offsets and how leveling data is stored, so I am trying to sift through that to see if there is a good way to make a character level editor (but not looking good at this juncture, for how they all work together). So stay tuned; maybe I'll get some free time one of these days.  :cookie: :cookie:

***************************

UPDATE 1:

Had somebody mention a small problem when trying to load the file up in their emulator:

I believe that if you load up your emulator, and then load a save state, it will clear the SRAM and load it with whatever it had in it when that save state was originally made (thus voiding your changes). [can somebody else confirm this?]

So you'd need to load the save state, save the game manually at a cleric, then quit the game and close your emulator. Then modify the files with my program. Then you should be able to load up the game and wait until you get into the saved game slot select screen and select the slot you altered, and the changes should be there.

 :cookie:

http://img21.imageshack.us/img21/4120/lufiafinal.jpg
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JAN 26)
Post by: Vegetaman on February 19, 2011, 11:24:54 am
Ladies and gentlemen, I have finally compiled a readme on how to use this program!

https://sites.google.com/site/vegetaman/home/sramchecksum/readme

DOWNLOAD & INSTALL LINK (unzip/unrar and click on setup.exe): http://www.mediafire.com/?ygc6726648ip7x5

Here is an abbreviated portion of it that tells exactly how to use the program itself:

How to use this program:

STEP 1: INSTALL

1.  Use the setup.exe to install the program (it is a click-once application).

STEP 2: BACKUP

2.  Make a backup copy of the SRAM (.srm) file you intend to edit.

STEP 3: LOAD UP YOUR FILE

3.  Open the SRAM Editor program...
4.  Click on the "..." button and navigate to the SRAM file you want to edit,
    and click okay. This will load the file into my program.
5.  Click on the tab for the save game slot you wish to edit (SLOT 1, SLOT 2,
    or SLOT 3).
6.  Click on "SHOW ITEMS", "SHOW MAGIC", "SHOW GOLD", and "PARTY INFO". This
    will load all the current information about your party into the scrolling
    text boxes.

STEP 4: CHANGE GOLD

7.  Gold is the easiest item to change. All you have to do is put in a number
    between 0 and 16777215 and click on "UPDATE GOLD". If anything was bad
    about the value you input, it will give you a default value of 8675309
    gold. Clicking on "SHOW GOLD" again will show you how much gold you have
    now.

STEP 5: CHANGE ITEMS:

8.  In the Party Items box, find the item you want to give yourself more of,
    or in the case of a new item -- navigate to the first Empty Slot.
9.  Then in the Item Changer box, use the dropdown to select the slot you
    identified (in #8) that your item needs to go into (ITEM SLOT).
10. Now select which item you want to give your character by name (ITEM
    SELECT).
11. Lastly, select how much of a quanity of that item that you want (from 1
    to 99) in that dropdown box (ITEM QUANTITY).
12. Now that you've made all the proper selections, press the "ADD ITEM"
    button.
13. To confirm this worked, you can click SHOW ITEMS again and it should
    reflect your update.

STEP 6: CHANGE MAGIC:

14. In the Party Magic box, find the magic spell you wish to swap out, or
    the first Empty Spell Slot, for a specific character.
15. Now, in the Magic Changer box, select which magic slot you want to change
    (MAGIC SLOT).
16. Now, select which magic spell you want to give them, by name, from the
    Magic Select drop down (MAGIC SELECT).
17. Lastly, select which character will receive this spell (CHARACTER).
    NOTE: Aguro has no magic power, and you cannot give him any magic spells.
18. Now that you have made the selection, press the "ADD MAGIC" button.
19. To confirm this, hit the "SHOW MAGIC" button again, and make sure the
    change is reflected in your Party Magic box.

STEP 7: UPDATE CHECKSUM:

20. Okay, now here is where all the magic happens. Go to the Checksum Checker
    box towards the upper left hand corner of the screen. Click on "CALCULATE",
    which will show you what the Checksum in the file currently is in the top
    box, and it will show you what it thinks the checksum SHOULD be in the
    bottom box -- it will also display "==" if they are equivalent, or "!=" if
    they are not.
21. If you made any changes to the SRAM at all, odds are that your checksum
    is wrong for that save slot. All you have to do is click "FIX CHECKSUM",
    and the value in the evaluated box will get written to the appropriate
    location in the SRAM file.
22. To make sure this change took properly, click "CALCULATE" again, and the
    two boxes should match and you should see a "==" in the bottom center of
    the Checksum Checker.
23. Now, rinse and repeat items 5 through 22 for any other of the save slots
    that you wish to alter!
24. When you are done, you can close the program with the "X" in the upper
    right, or you can click the convenient EXIT button.
25. Now, go back and load up your save file -- and your changes should have
    taken! (see the FAQ about an important note when using an emulator).

NOTE: [IF YOU WANT TO MODIFY SRAM ON YOUR OWN (via a HEX EDITOR)]:

If you want to make your own modifications to SRAM (.srm) but use this program
to fix your checksum, just make your changes to the file BEFORE you load it
up in my program. Then hit "CALCULATE" and "FIX CHECKSUM" on each of the three
save slots, and it should take care of all the magic for you!

Frequently Asked Questions:

Q:

I used your program, then loaded up my game, but it hasn't changed any!

A:

I believe that if you load up your emulator, and then load a save state, it
will clear the SRAM and load it with whatever it had in it when that save
state was originally made (thus voiding your changes). So to avoid this,
you'd need to load the save state, save the game manually at a cleric, then
quit the game and close your emulator. Then modify the files with my program.
Then you should be able to load up the game and wait until you get into the
saved game slot select screen and select the slot you altered, and the
changes should be there. Loading a save state will undoubtedly erase your
SRAM in my opinion.

======================================================

http://img44.imageshack.us/img44/2493/elegion.jpg

http://img573.imageshack.us/img573/3265/lufiascrn.png

Perhaps I can get active in this again and make more and more updates.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: KingMike on February 19, 2011, 12:00:16 pm
I believe that if you load up your emulator, and then load a save state, it will clear the SRAM and load it with whatever it had in it when that save state was originally made (thus voiding your changes). [can somebody else confirm this?]
Yes, some emulators will do that. Those will argue it is for more accurate emulation, since some games could be using the SRAM for non-saving purposes.
So I hear Furai no Shiren is an example of a game that would crash horribly.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
Post by: Vegetaman on February 19, 2011, 10:38:19 pm
I believe that if you load up your emulator, and then load a save state, it will clear the SRAM and load it with whatever it had in it when that save state was originally made (thus voiding your changes). [can somebody else confirm this?]
Yes, some emulators will do that. Those will argue it is for more accurate emulation, since some games could be using the SRAM for non-saving purposes.
So I hear Furai no Shiren is an example of a game that would crash horribly.

Ah, I see. Well that makes sense, but thank you for confirming what I only recently came to realize was the case. Many thanks, sir!

Also... Semi interesting development tonight while working on my SRAM editor and compiling some documentation... Turns out that if you fill up all 32 slots of the Hero's spell list, meaning he does not have an "END OF LIST", he will also gain all of Lufia's spells. And if you fill up her list, you will gain all of Jerin's... There is no space for spells for Aguro, so you can't "give him" magic. Though if you fill up Jerin's list, you will probably go until the first 0x00 character. I need to make a slight update to my SRAM editor to reflect this -- hopefully this will be completed tomorrow.

==UPDATE== (FEBRUARY 20, 2011)

DOWNLOAD Version 2.2: http://www.mediafire.com/?b7lrwb19s64ybod *NEW*

NEW README: https://sites.google.com/site/vegetaman/home/sramchecksum/readme

Changelog:

- added support for modifying 32 spell slots instead of 24 (run over the lists at your own risk!)
- added the readme file to the .rar package and updated the readme as well

I managed to give the Hero 9 pages of spells thanks to this 32 byte run-over method:

(http://img580.imageshack.us/img580/5695/lufiaspells.jpg)

Also, you can give the Hero the "Elf" spell at the start of the game, but if you talk to Artea, the game will lock up when he tries to give Jerin his bow:

(http://img13.imageshack.us/img13/6818/elfwarp.jpg)
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: FEB 20)
Post by: gadesx on February 27, 2011, 07:39:54 am
try to make a editor of lufia 2, the best! xd
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: FEB 20)
Post by: Mew seeker on March 16, 2011, 10:06:31 am
About Elegion, I believe it was used in the Japanese version in the final battle there :
http://www.youtube.com/watch?v=mjrS40mGSFs
Look at about 5:18
From what I see, they changed the final boss moveset for the U.S. version,
making it more evil and hard IMHO as it
Spoiler:
only use spell and confusion against you.
In the Japanese version,
Spoiler:
he use instead moves used by all of the Sinistrals.

In Lufia, you can push the X button IIRC to know the effects of a spell.
However, in the Japanese version, you could do it with all items
including equipment, which gave their weight value right away.
I don't know if you could be interested in it or be able to do it
but just in case I mention it.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: FEB 20)
Post by: KingMike on March 16, 2011, 03:47:12 pm
You could, but when I tried to play the Japanese version, it seemed like the item descriptions were mostly useless (even when I tried to use a dictionary to read them).
My guess is that perhaps the item descriptions were cut for space, as it seemed like they really crunched the data to make it fit into an 8-megabit cartridge (whereas it had been announced as a 12-meg cart, perhaps it was close enough Taito felt it wasn't worth having to buy extra ROM chips).
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: FEB 20)
Post by: Vegetaman on April 02, 2011, 11:15:11 am
That's cool about Elegion -- and I never knew that about X for some reason. I need to go back and try that.

I'm still working on the next phase of my SRAM guide. There are a lot of things I know need to be in SRAM about the game that I am trying to track down:

1. All of the treasure chests.
2. All of the "hidden items" (in book cases, etc.).
3. All of the Scenario Items. [they're not in your regular inventory]
4. Every town you visit for the fist time (for your WARP spell).
5. Status of your level in the Old Cave.
6. Items that go to the Isle of Forfeit.
7. Various other in-game scripting (people who change what they say after you talk to them a few times, different locations for people or Doom Island and those sort of things, etc.).
8. Triggers for various in-game cutscenes (ie. The Hope Ruby).
9. The in-game clock timer.
10. The abilities of The Falcon.

Again, a lot of this will take just a lot of time to sift through, but I think there could be a lot of good information here. It wouldn't surprise me if a lot of event data was just a single bit flag... And there's probably even more stuff buried in SRAM that I haven't even thought about yet.

Anyway, on a final note, just as an exercise for myself, I tried to comment the assembler code for the checksum routine... Did I get anywhere in the ballpark? Something about this just seems off to me (I haven't messed with Assembler in about 5 years):

Code: [Select]

 A0 FC 03    LDY #$03FC            ; load Y immediate with value 0x03FC
 A6 1F       LDX $1F    [$00:001F] ; load X with value at address 0x1F
 A9 02 65    LDA #$6502            ; load Accumulator with 0x6502
 18          CLC                   ; clear the carry flag
 7D 08 00    ADC $0008,x[$70:0008] ; add with carry starting at address 0x0008
 E8          INX                   ; increment the X register
 E8          INX                   ; increment the X register (again)
 88          DEY                   ; decrement the Y register
 D0 F7       BNE $F7    [$9431]    ; repeat until Y hits 0 (branch not equal)
 AA          TAX                   ; transfer the accumulator into X
 7A          PLY                   ; pull the Y register off of the stack
 AB          PLB                   ; pulls a byte off of stack into data bank
 28          PLP                   ; pull processor status off of the stack
 60          RTS                   ; return from subroutine


Thoughts on any of this, anyone?  :cookie: :cookie: :cookie: :cookie:
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: FEB 20)
Post by: KingMike on April 05, 2011, 12:29:24 am
Well, the game clock should be easy to figure out.
Save the game, then backup the SRAM. Reopen the emulator, reload your saved game. Stay at the save point, wait for the time to increase, save again and compare the resulting SRAM.
The "treasure collected" data is likely to be a series of bitflags. To find the area where data is saved in SRAM, leave a treasure alone that's easy to get near a save point, and again do a comparison search of before and after SRAM.
It should only contain the difference of a byte (as well as checksum and maybe clock data). Then if you know the SRAM address for a specific example, you could trace where it comes from in RAM, and then trace the routine that set the flag in RAM (using breakpoints on the SRAM address, which I think should be $70xxxx).
Also using similar methods for the other stuff.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: FEB 20)
Post by: Vegetaman on April 10, 2011, 01:33:05 pm
Well, the game clock should be easy to figure out.
Save the game, then backup the SRAM. Reopen the emulator, reload your saved game. Stay at the save point, wait for the time to increase, save again and compare the resulting SRAM.
The "treasure collected" data is likely to be a series of bitflags. To find the area where data is saved in SRAM, leave a treasure alone that's easy to get near a save point, and again do a comparison search of before and after SRAM.
It should only contain the difference of a byte (as well as checksum and maybe clock data). Then if you know the SRAM address for a specific example, you could trace where it comes from in RAM, and then trace the routine that set the flag in RAM (using breakpoints on the SRAM address, which I think should be $70xxxx).
Also using similar methods for the other stuff.

Indeed, I figured a great many things in there would be bit flags. Just a lot of save game, save SRAM, do event/get chest, save game, compare SRAM. I'd be farther along at this, but after I work all day (I'm an embedded systems C programmer), I don't have a lot of leftover desire to program or fiddle with this stuff when I get home, so I mostly tend to this on my free weekends. I'd like to make a comprehensive guide of all the parts of SRAM in Lufia & The Fortress of Doom so that somebody can do a proper ROMhack of this wonderful game. I like all of your ideas there, though. The treasure chests should be easy to do, since there are plenty of them in towns in castles near save points. Also, the same goes for items hidden in bushes and cupboards and stuff. Makes me wonder how each set of 3 dragon eggs is stored... I would assume all Isle of Forfeit things are bitflags, but for quantity of more than 1 for some items, that wouldn't quite work... Need to investigate all of this further. Thanks for the support and advice as always, KingMike!  :beer: :)
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: FEB 20)
Post by: Vegetaman on June 06, 2011, 10:46:26 pm
I had a request for my SRAM program that was compatible with Linux/MAC, and sadly I have not had time to make a command line version of it (yet -- though I would like to)... So, if you're so inclined, you can use the guide to change the offsets yourself and use this program to calculate what the checksum needs to be (I think it works; I've only tested it a handful of times with the [!] version of the game):


I have written this small program (in C/C++) below to give you a better feeling for how
the checksum algorithm works for this game. I have included comments to try and
make it as straight forward as possible.

Code: [Select]
/* begin file -- main.cpp */

// File name: main.cpp
// Author: Vegetaman
// Date: February 24, 2011
// Purpose: Lufia Checksum

#include <iostream>
#include <fstream>

#define SIZE_OF_SRAM 0x2000                     // SRAM is 8K large
#define LUFIA_SRAM_FILE "C:\\Lufia.srm"         // SRAM file location
#define HALF_OF_2K 0x03FC                       // half of 2048 - 8
#define FILE00_OFFSET 0x0008                    // 8 bytes in
#define FILE01_OFFSET 0x0808                    // 2K + 8 bytes in
#define FILE02_OFFSET 0x1008                    // 4K + 8 bytes in
#define COUNTER_ROLLOVER_VALUE 0xFFFF           // max 16-bit value

using namespace std;

int main(int argc, char *argv[])
{
  FILE *filePtr;                           // file pointer
  unsigned char ArrayOfSRAM[SIZE_OF_SRAM]; // array of char or bytes
  unsigned short accumulator;              // is a 16-bit unsigned integer
  unsigned short register_x;               // will be just like the register X
  unsigned short register_y;               // will be just like the register Y
  filePtr = fopen(LUFIA_SRAM_FILE, "r");   // open file Lufia.srm -- read only

  // NOTE: I am reading the SRAM into an array so I don't have to do all of my
  //       operations from the file, which would be really slow and wasteful...

  fread(ArrayOfSRAM, sizeof(char), SIZE_OF_SRAM, filePtr); // load the array
  fclose(filePtr); // always close your file handle

  // begin the routine of calculating the first 16-bit little endian checksum
  register_x = FILE00_OFFSET; // load the first offset into register X
  register_y = HALF_OF_2K;    // load 0x03FC into register Y
  accumulator = 0x6502;       // load the accumulator with the base value 6502

  while(register_y != 0)      // while Y does not equal 0 (will run 1020 times)
  {
    accumulator += ArrayOfSRAM[register_x];      // get the first/low byte
    register_x++;                                // increment X
    accumulator += ArrayOfSRAM[register_x] << 8; // get the second/high byte
    register_x++;                                // increment X
    accumulator &= 0xFFFF;                       // discarding the carry flag
    register_y--;                                // decrement Y
  }

  // some code to throw the checksum up on the console so that it can be seen
  cout << "Checksum for FILE00: " << dec << accumulator << endl;
  cout << "Little Endian HEX: " << hex << (accumulator & 0xFF) << " ";
  cout << hex << ((accumulator >> 8) & 0xFF) << endl << endl;

  // prepare to calculate the second little endian 16-bit checksum
  register_x = FILE01_OFFSET; // load the first offset into register X
  register_y = HALF_OF_2K;    // load 0x03FC into register Y
  accumulator = 0x6502;       // load the accumulator with the base value 6502

  while(register_y != 0)      // while Y does not equal 0 (will run 1020 times)
  {
    accumulator += ArrayOfSRAM[register_x];      // get the first/low byte
    register_x++;                                // increment X
    accumulator += ArrayOfSRAM[register_x] << 8; // get the second/high byte
    register_x++;                                // increment X
    accumulator &= 0xFFFF;                       // discarding the carry flag
    register_y--;                                // decrement Y
  }

  // some code to throw the checksum up on the console so that it can be seen
  cout << "Checksum for FILE01: " << dec << accumulator << endl;
  cout << "Little Endian HEX: " << hex << (accumulator & 0xFF) << " ";
  cout << hex << ((accumulator >> 8) & 0xFF) << endl << endl;

  // prepare to calculate the third and final little endian 16-bit checksum
  register_x = FILE02_OFFSET; // load the first offset into register X
  register_y = HALF_OF_2K;    // load 0x03FC into register Y
  accumulator = 0x6502;       // load the accumulator with the base value 6502

  while(register_y != 0)      // while Y does not equal 0 (will run 1020 times)
  {
    accumulator += ArrayOfSRAM[register_x];      // get the first/low byte
    register_x++;                                // increment X
    accumulator += ArrayOfSRAM[register_x] << 8; // get the second/high byte
    register_x++;                                // increment X
    accumulator &= 0xFFFF;                       // discarding the carry flag
    register_y--;                                // decrement Y
  }

  // now throw the last checksum up on the console so it can also be seen
  cout << "Checksum for FILE02: " << dec << accumulator << endl;
  cout << "Little Endian HEX: " << hex << (accumulator & 0xFF) << " ";
  cout << hex << ((accumulator >> 8) & 0xFF) << endl << endl;

  // now, hold the program up until the user is done reading...
  cout << "Press ENTER to continue...";  // prompt user
  getchar();                             // wait for "ENTER" key
  return 0;                              // exit with success
}

/* end of file -- main.cpp */

Let me know if this works for you. I have been busy lately, but I DO intend to add more character offset data and stuff to this guide once I get the time to seek out the information... Your support and feedback is, as always, much appreciated!

NOTICE: You will have to change the file link in this line to point to where your Lufia SRAM file (.srm) is located on your local machine:

"#define LUFIA_SRAM_FILE "C:\\Lufia.srm"         // SRAM file location"
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Hiei- on November 10, 2011, 07:44:56 pm
I checked a bit the rom and it's seems the rom handling the text pointers in a weird manneer or is it just me who didn't look at the right place?

The game also seems to have code hardcoded between dialogs, by the way.

So, does someone know how the text pointers of that game works? I would have also liked to do a dump of the text script (I managed to got all the MTE strings and would just need to find the way the pointers are calculated to do a proper dump, I think).

Thanks a lot!
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Vegetaman on November 18, 2011, 09:49:02 pm
I checked a bit the rom and it's seems the rom handling the text pointers in a weird manneer or is it just me who didn't look at the right place?

The game also seems to have code hardcoded between dialogs, by the way.

So, does someone know how the text pointers of that game works? I would have also liked to do a dump of the text script (I managed to got all the MTE strings and would just need to find the way the pointers are calculated to do a proper dump, I think).

Thanks a lot!

I haven't played around with this game in about five months, but early on (maybe two years ago?) I tried to figure out how the text was stored. I have learned a lot more about how this stuff works than before this data was compiled, but some of what I was able to figure out is written down here:

Dictionary Decoded:

https://sites.google.com/site/vegetaman/home/dictionary/masterkey

Notes:

https://sites.google.com/site/vegetaman/home/dictionary

The whole thing with hard coded stuff occurring within dialogs confuses the crap out of me, too. I have to assume it has to do with location information (such as for a character to walk or the camera to pan).

I took the data I did know and made a C# program to decode the text, but the hard coded information made the resulting dump fairly worthless. I was at least able to get large chunks of relevant dictionary information like this, though:

Code: [Select]
Important Codes:
----------------
04 text box close (?)
05 line return
07 character name call
0b place name call
0c lower case dictionary
0d upper case dictionary
20 blank space (" ")
2e period (.)
2b double period (..)
20 - 7f reserved character symbols
00 - 0f reserved flag calls and specials
80 - a9 new textbox (?) [tie to character/position?]
?? time to wait between boxes (?)

(many of the above are just guesses, whereas the below are taken from the ROM more directly)

...snip...

LC|UC|link#|dictionary
--|--|-----|----------
80 c0 42 cb the
81 c1 45 cb you
82 c2 48 cb to
83 c3 4a cb it
84 c4 4c cb of
85 c5 4e cb that
86 c6 52 cb is

Note that the LC is the hex value for lower case and that UC is the hex value for upper case (as in "the" versus "The", IIRC). I spent quite a bit of time on it back in 2010 or so, but finally gave up the ghost to work on the SRAM project, which I still need to get back to...

Trial Text Dump:

https://sites.google.com/site/vegetaman/home/dictionary/textdump

Let me know if you have any more information I don't -- or if you'd like me to explain some of this information I have better.

Code: [Select]
Some examples of the "hard coded" stuff mucking up the text translation
as my program currently stands with some well known dialog from Alekia
Castle towards the start of the game:

usedSinistralRcanWhat? The rumor about
monsters in Sheran?
I can't send anyone
until you've checked it.

canNo matter how many times
you ask, I can't send the
knights until you've checked
to see if the rumor's true.

canSo, the monsters really
attacked Sheran. I wonder
if our kingdom is safe?

whatYour Majesty. Please
organize the detail. This
matter is too serious
to ignore!

canI leave all foreign affairs
in your hands. My first
duty is to protect the
kingdom.

canEstea's been meddling in
military affairs? Well, the
military needs shaking up,
anyway.

canIt is most fortunate that
the Kingdom of Sheran
survived unscathed. You
did well, Hero.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Hiei- on November 21, 2011, 06:58:34 pm
I managed to found the dictionnary easily, it is stored directly in a part of the rom (0x054e19-0x0553CC for the biggest part of it).

You have more or less the same problem as me for the dump, because of the hardcoded values.

Code: [Select]
[CODE_040C32000C]
Hey. You shouldn't let[JUMP]
such a pretty lady run[JUMP]
away like that![END_000C]


Monsters in town?[JUMP]
We have ourselves a[JUMP]
heavy situation here.[END_000C]


Roman's cinnamon tea is[JUMP]
the best. I wish I could[JUMP]
make it, but Roman only[JUMP]
taught [Character_Name_Lufia]. [END_0005]


[CODE_0345000C]
The latest dress designs[JUMP]
are at the biggest shop in[JUMP]
Lorbenia_2. Why don't you go_2[JUMP]
there with [Character_Name_Lufia]?[END_000C]


Hey, [Character_Name_Lufia]. Whatever[JUMP]
happened to [Character_name_written_on_the_entry_name_screen]?[END_000C]


This is a merchant's shop.[END_1C03000C]


This is a weapons shop.[END_1C01000C]


This is an armorer's shop.[END_1C0200065000075000]


[CODE_045006001E000C]
You did well to find this[JUMP]
underground road. It's a[JUMP]
good way to keep out of[JUMP]
the rain.[END_1E00050C0800011C00000C]


Yes. It's really peaceful.[END_000C]


Monsters attacked the[JUMP]
Kingdom of Sheran?[JUMP]
Why is this happening now?[JUMP]
It's been 100 years.[END_000C]


You can't change your[JUMP]
weapon once you're in[JUMP]
battle, so be careful.[END]


[CODE_040C6600040D25000C]
Halt, [Character_name_written_on_the_entry_name_screen]! What is your[JUMP]
business in the castle?[END]


[WAIT]

[CODE_66000CC93F20]
The commander?[JUMP]
Same want_2 always. He's[JUMP]
sleeping in the tower_2room[JUMP]
on the far left side.[END_000C]


What? Monsters attacked[JUMP]
Sheran? Is the kingdom[JUMP]
safe?[END_000C]


When you want to use magic,[JUMP]
select the staff icon with[JUMP]
the cross key and press the[JUMP]
"A" button.[WAIT]

During battle, use the[JUMP]
cross key to choose a spell.[JUMP]
Press the "A" button to[JUMP]
cast it.[END_000C]


Press the "A" button when[JUMP]
in front of the dresser.[JUMP]
Maybe you'll find something.[WAIT]

When you walk around,[JUMP]
touch objects in towns and[JUMP]
villages to find hidden[JUMP]
items.[WAIT]

For example, you could[JUMP]
look around outside[JUMP]
this room.[END_0005]


[CODE_0C0800012E00000C]
Maybe you should ask[JUMP]
the commander first.[JUMP]
He's in the castle.[END_060D000C]


The commander said he[JUMP]
didn't know anything?[JUMP]
Well, if he doesn't,[JUMP]
we sure don't.[END_0005]


[CODE_0C0800013100000C]
Monsters in the Kingdom[JUMP]
of Sheran? The commander[JUMP]
didn't say a word about[JUMP]
that![END_000C]


Fight the monsters?[JUMP]
If I'd known that, I[JUMP]
would have trained more.[END]


[CODE_0410560002010B004300000C]
[Character_Name_Lufia] was crying.[JUMP]
Whoever made her cry must[JUMP]
be cruel and unfeeling.[END_000C]


Did you make up with[JUMP]
[Character_Name_Lufia]?[END_0005]

But a lot of parts are still "not perfect" :

Code: [Select]
I wonder how long this[JUMP]
peace will last.[JUMP]
Life used to be so hard[JUMP]
100 years ago.[END_84]


(ReynaofokAre you thinking about[JUMP]
the past again?[END_89]


What would we do if the[JUMP]
Sinistrals returned?[JUMP]
[Character_Name_Maxim] is dead. Who would[JUMP]
defend us?[END_84]


I'llingReynait.ReynaofokYou're a knight of Alexia,[JUMP]
aren't you? Doesn't [Character_Name_Maxim]'s[JUMP]
blood run in your veins?[JUMP]
Won't that be enough?[END_84]


what........[END_84]


okWe should be getting home[JUMP]
soon. I'll make you some[JUMP]
cinnamon tea. I haven't[JUMP]
made it for a while.[END_89]


Cinnamon tea.[JUMP]
One of your recipes that[JUMP]
actually tastes good.[END_AD]


Oh, you! I'll have you[JUMP]
know that it's very popular[JUMP]
with our guests.[END_28]





*ReynaofokWhat?[END_84]

The problem is, actually, this dump is done without the pointers because I didn't find how they work for this game. Knowing how they work would maybe able to get a good text dump, if the pointers starts at the beginning of the sentences (so, if they ignore the hardcoded values, which give false results because some of the values are the same than ones the dictionnary use).

This dialog is a good example :

Quote
ReynaofI'llI'mReyna(ReynaitjustwhatHmm. That's odd.[JUMP]
Aren't you using......[END_84]

"ReynaofI'llI'mReyna(Reynaitjustwhat" is, in fact, some hardcoded values and the real dialog is just :

Quote
Hmm. That's odd.[JUMP]
Aren't you using......[END_84]

The solution is to edit manually each dialog and/or put something like that in the .tbl file :

Quote
0318842C1884281884142618842818842A=[CODE_0318842C1884281884142618842818842A]\n
071A14080190=[CODE_071A14080190]\n
0345000C=[CODE_0345000C]\n
040005=[END_0005]\n\n\n
04000C=[END_000C]\n\n\n
040C32000C=[CODE_040C32000C]\n
040C6600040D25000C=[CODE_040C6600040D25000C]\n
04103D000C=[END_103D000C]\n\n\n

But it's a very very long and rather boring method :/
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Vegetaman on January 01, 2012, 02:12:47 pm
Interestingly enough, back in 2006 we tried to work out some of this stuff on the gamefaqs Lufia board, with no luck there either. Is there a similar sort of text compression in Lufia II? I know that it was more popular, so if somebody cracked it, then surely it can be backwards related to Lufia I -- a shot in the dark, at least.

The topic in question: http://www.gamefaqs.com/boards/588452-lufia-and-the-fortress-of-doom/30424903

We had a lot of interesting discussions in that topic about monster data from the ROM itself; it is still a pretty good resource IMO.

My New Years Resolution is to work on my SRAM stuff some more this year. I need to get motivated and find some free time.

I just can't figure out the "garbled stuff". It has to be related to character movements or text boxes or something; but why is it hard coded in there? It makes no sense at this point. Perhaps somebody who knew assembler or could watch the text get loaded in the actual game itself would be able to make more sense of it...
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: justin3009 on January 01, 2012, 02:20:07 pm
Best thing to do for noting that stuff is just do a bunch of random stuff that doesn't actually load any VWF dialogue up.

1. Use Geiger's SNES9X Debugger.
2. Click CPU.  Do whatever you need to do before loading any sort of dialogue, even press random buttons just so the code gets ran through once and you won't see it again.
3. Unclick CPU and move around just a tad.
4. Click CPU and move up to an NPC or something and talk to them to load up the dialogue.
5. Once the dialogue's loaded even a little, unmark CPU.
6. Check the log file and go through that and you'll figure out the dialogue stuff a bit more.

I may be assuming wrong if that was unknown but if it was, this can greatly help figuring out certain things.  Maybe not specifically for SRAM but it'll help with the text boxes and character movement, etc..
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Jigglysaint on January 01, 2012, 11:04:59 pm
Interestingly enough, back in 2006 we tried to work out some of this stuff on the gamefaqs Lufia board, with no luck there either. Is there a similar sort of text compression in Lufia II? I know that it was more popular, so if somebody cracked it, then surely it can be backwards related to Lufia I -- a shot in the dark, at least.

The topic in question: http://www.gamefaqs.com/boards/588452-lufia-and-the-fortress-of-doom/30424903

We had a lot of interesting discussions in that topic about monster data from the ROM itself; it is still a pretty good resource IMO.

My New Years Resolution is to work on my SRAM stuff some more this year. I need to get motivated and find some free time.

I just can't figure out the "garbled stuff". It has to be related to character movements or text boxes or something; but why is it hard coded in there? It makes no sense at this point. Perhaps somebody who knew assembler or could watch the text get loaded in the actual game itself would be able to make more sense of it...

Yeah, Lufia 2 uses a dictionary compress too, but the data itself is actually stored in the event code, and the event code is defined for each map.  I think Lufia 1's data works the same as well, which maybe why nobody can find pointers.  If there are pointers, they might be relative pointers(both games use relative pointers for things).  If that's the case then you need to find the start of the data and add the value of the pointer to that address.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: xander on January 02, 2012, 01:08:16 pm
FloBo has released his tools for lufia 1 which he used to translate to german.There is also source and documentation to go along with this which may be of great help.

http://digisalt.de/main.php?ccat=1188&site=1325360294&part=0&lang=GB (http://digisalt.de/main.php?ccat=1188&site=1325360294&part=0&lang=GB)

Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Vegetaman on January 03, 2012, 07:28:44 pm
FloBo has released his tools for lufia 1 which he used to translate to german.There is also source and documentation to go along with this which may be of great help.

http://digisalt.de/main.php?ccat=1188&site=1325360294&part=0&lang=GB (http://digisalt.de/main.php?ccat=1188&site=1325360294&part=0&lang=GB)

Interestingly enough, I read through some of his documentation and he hit the same snag we hit (I think...?). He makes mention of hex code 0x04 being the "end of text box", and it looks like he just marks everything else as "unused characters".

So I'll have to dig deeper into how he's doing it, but it looks like he must be specifically skipping over "junk" data or using some event data to kick him to the text menus... Hmmm... No explanation on what the junk after the "end of text box" code is, though.

Yeah, Lufia 2 uses a dictionary compress too, but the data itself is actually stored in the event code, and the event code is defined for each map.  I think Lufia 1's data works the same as well, which maybe why nobody can find pointers.  If there are pointers, they might be relative pointers(both games use relative pointers for things).  If that's the case then you need to find the start of the data and add the value of the pointer to that address.

Interesting... So the event code for each map is in different databanks, then? Relative pointers are always fun to suss out, since they require THAT much more legwork to uncover.

Best thing to do for noting that stuff is just do a bunch of random stuff that doesn't actually load any VWF dialogue up.

1. Use Geiger's SNES9X Debugger.

I have never tried Geiger's debugger, but it is quite widely hailed around here. I need to give it a whirl.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Hiei- on January 05, 2012, 09:20:14 am
I should have a good dump pretty soon, though gamefaqs already have one.

My friend is working on some tools to hack the game and make a french translation, but his tools use the pointers of the game (to move the texts anywhere in the rom).

He's actually analysing the game to find each value of each bytecode.

The dump will look like that :

Code: [Select]
<Event adr='0001BD58'>
</Event>

<Event adr='0001BD65'>
<Code id='04' value='95'>
<Code id='1C' value='00'>
<Perso 2>[Character_Name_Maxim]! We can't escape!</Text>
<Code id='15' value='0101'>
<Code id='3C' value=''>
<Code id='16' value='00'>
</Event>

<Event adr='0001BD82'>
<Code id='50' value='08'>
<Code id='5F' value='01'>
<Code id='5F' value='02'>
<Code id='5F' value='03'>
<Code id='5F' value='04'>
<Code id='5E' value='01'>
<Code id='3D' value='0026'>
<Code id='3D' value='0025'>
<Code id='3D' value='0024'>
<Code id='3D' value='0023'>
<Code id='3D' value='0027'>
<Code id='3D' value='0028'>
<Code id='3D' value='0029'>
<Code id='3D' value='002B'>
<Code id='3D' value='002C'>
<Code id='3D' value='001F'>
<Code id='3D' value='0103'>
<Code id='3D' value='0102'>
<Code id='3D' value='0106'>
<Code id='3D' value='010F'>
<Code id='3D' value='010E'>
<Code id='3D' value='0111'>
<Code id='3D' value='0119'>
<Code id='3D' value='0120'>
<Code id='3D' value='0309'>
<Code id='3D' value='030C'>
<Code id='3D' value='0315'>
<Code id='3D' value='0320'>
<Code id='3D' value='0317'>
<Code id='3D' value='031A'>
<Code id='3D' value='0326'>
<Code id='3D' value='0324'>
<Code id='3D' value='032A'>
<Code id='3D' value='031D'>
<Code id='3D' value='032C'>
<Code id='3D' value='032D'>
<Code id='3E' value='B957'>
<Code id='3E' value='963E'>
<Code id='3E' value='981C'>
<Code id='3E' value='BA32'>
<Code id='3E' value='9C5C'>
<Code id='3E' value='9D58'>
<Code id='3E' value='9E5F'>
<Code id='3E' value='9F5B'>
<Code id='3E' value='B024'>
<Code id='3E' value='B81D'>
<Code id='57' value='01'>
<Code id='3C' value=''>
<Code id='16' value='00'>
<Code id='69' value='04'>
<Text2>It's so dark.</Text>
<Text2>I feel the energy.</Text>
<Text2>A very dark energy.[NewLine]
Beware! It's powerful.</Text>
<Text2>[Character_Name_Selan]. Light Magic.</Text>
<Text2>As you wish.</Text>
<Code id='54' value='16'>
<Code id='09' value='0E002200'>
<Code id='27' value='010E22'>
<Code id='27' value='020D23'>
<Code id='27' value='030F23'>
<Code id='27' value='040E24'>
<Code id='18' value='02'>
<Code id='5A' value=''>
<Perso 1>Is this the Fortress[NewLine]
of Doom?</Text>
<Perso 2>So cold! It freezes[NewLine]
straight to the heart.</Text>
<Code id='6D' value='02'>
<Code id='3A' value='04'>
<Code id='6B' value='2004'>
<Text1>Welcome, [Character_Name_Maxim].</Text>
<Perso 1>[Character_Name_Daos]? It's you, isn't it?[NewLine]
Show yourself!</Text>
<Code id='83' value=''>
<Code id='B5' value=''>
<Code id='83' value=''>
<Code id='B2' value=''>
<Code id='83' value=''>
<Code id='2D' value='04'>
<Code id='83' value=''>
<Code id='6D' value='02'>
<Code id='3A' value='04'>
<Code id='6B' value='2004'>
<Text1>Approach. My chamber is[NewLine]
above. I await you.</Text>
<Code id='6A' value='3C'>
<Code id='16' value='00'>
</Event>

<Event adr='0001BF1E'>
<Text1>Move the pointer to the[NewLine]
spell. Press the "X" button[NewLine]
to see what the spell can[NewLine]
do.</Text>
</Event>

<Event adr='0001BF5E'>
<Text1>Move the pointer to the[NewLine]
spell. Press the "X" button[NewLine]
to see what the spell can[NewLine]
do.</Text>
</Event>

German tools, as explained in the readme, don't care about the pointers (5 bytes one), so basically they managed to put the translation in the same room where the english text was by recompressing the dictionnary with new values.

By the way, you can easily modify the rom to use a whole new dictionnary instead of the "CAPS-mod" dictionnary.

I can post the modifications that have to be done here if someone is interested.

Original game use a dictionnary, and the values start with "0C". It use another dictionnary which values start with "0D". "0D" are the same than "0C" instead the first letter is in caps.

With a few modifications, you can use a true new dictionnary for "0D", instead of the "CAPS-mod".

Same for the dictionnary "C0-FF" which is a miror of dictionnary "80-BF" and which is working the same way.

With those modifications, you can even extend the length of the dictionnary values, as you expand the rom. So you can have like 14 letters for each value for example, it's not a problem.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Jigglysaint on January 05, 2012, 08:25:09 pm
For Lufia 2, I've got some values.  It's for an unheadered rom but it should be useful for finding data.  At 3E434 I have it listed in my bookmarks as part of the Lizardman boss script.  It's been years since I've played with the game so I don't know what's what, but somewhere should be a code that calls the boss, and the text should be there as well.  3E2BD I have as start of map 06 script, so that might be where the script starts.  I have 76A00 as the start of dictionary pointers, which are relative pointers(which the starting address can easily be found by forming a pointer to the pointer table, searching, and then glancing at the code to see what is loaded after it).  Item pointers are at B4FC3, and are relative.  It should be possible to relocate the code that comes after item data, or relocate item data itself in order to use the extra slots that otherwise glitch and harm the game.  That or just get rid of the Ran-Ran step which basically performs all the animations in the game in an never ending loop(and it calls them all by listing them all).  1380BD has map pointers, not sure if it's the start but a search should reveal that fact easily.  They are relative, and other pointers seem to be there as well, such as the tileset pointers and whatnot.  At 27FCBC I have sprite location pointers for each map.  Each map has it's own scripts defined, and this is the pointer list to where each event is positioned on the map.

That's pretty much it.  I also have some info on partimitars that are used in creating the Ancient Cave.  I think I fiddled with it and made it only give out blue chests in a treasure room setting on each floor.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: xander on January 06, 2012, 02:03:59 am
A lot of interesting notes on lufia 2.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Hiei- on January 06, 2012, 07:56:20 pm
About Lufia 1 :

http://www.hiei-tf.fr/Lufia1_ASM-Hack_Expanded_MTE_dictionaries.zip

If someone want to use those modifications, feel free to do it. Read the texte file of the ZIP archive for more details (Address of the MTE dictionnaries, how to calcul the pointers, etc...).

It can be useful if you want to translate the game in a foreign language and plan to use the german tools, to have more room for your translation (once you used the original MTE dictionnaries of the game, 256+64+16 (336) entries if you ignore the caps mirroring, you'll still have 256 entries left for your translation :)

The original game have 4 compression dictionnaries :

- One offering 16 entries (10-1F in the .tbl file)

- Another offering 64 values (80-BF in the .tbl file) and the same values mirrored to C0-FF in the tbl file (with the first letter in caps for C0-FF values).

- A last one offering 256 values (0C00-0CFF in the .tbl file) and the same values mirrored to 0D00-0DFF in the tbl file (with the first letter in caps for 0D00-0DFF values).

Basically, with the modifications of the IPS patch, the game (automatically expanded to 2 MB) now have :

- One offering 16 entries (10-1F in the .tbl file), but you can put longer entries if you need to. I know the game accept, at least, 14 characters entries, but it can accept probably more. You'll have to try to know the actual limit.

- Another offering 128 values (80-FF in the .tbl file), and you can also use longer entries if you need to.

- Another one offering 256 values (0C00-0CFF in the .tbl file), and you can also use longer entries if you need to.

- A last one offering, again, 256 values (0D00-0DFF in the .tbl file), and you can also use longer entries if you need to.

If some peoples are interested by the log of the modifications, just ask and I'll post it.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Vegetaman on November 29, 2012, 08:14:33 pm
I am bumping this topic only because I felt like I needed to finish the SRAM guide. But in the time that has expired since I last touched this, I was notified that a RAM map has been updated on the site's wiki by Gendou and Alchemic:

http://datacrystal.romhacking.net/wiki/Lufia_%26_the_Fortress_of_Doom:RAM_map

With this being said... Is there anything that seems missing or unclear on how it works from an SRAM point of view at this point as far as character data? Because it looks fairly covered now. But it is my sincere belief that every treasure chest and secret item in this game must have an SRAM bitfield associated with them, so I was going to put that next on my list of things to track down. Anybody have any good tips on where to start looking for that?

Also I finally got around to playing with those dictionary tools from the .ZIP file. Very, very cool.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: KingMike on November 29, 2012, 09:43:14 pm
I see only two bytes listed for EXP ("lo" and "hi" byte), but there definitely should be at least 3 bytes per character.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Vegetaman on November 30, 2012, 12:21:36 am
I see only two bytes listed for EXP ("lo" and "hi" byte), but there definitely should be at least 3 bytes per character.

You're quite right -- it would need 3 bytes to be able to exceed 65535 and go up as high as 0xFFFFFF or 16777215... The same as Gold. Perhaps I should verifying and prove/disprove the information on that page and incorporate what I discover into my guide...

Also, in addition to bitflags for chests opened, there would have to be some for story scenarios and bosses beaten as well... If that SRAM code could be cracked, you may be able to pull off some neat stunts (like... a world without bosses). Of course, it may turn out like when I gave the Hero the Elf spell -- turns out that if you go there without Jerin in your party the game locks up like fort knox.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: badinsults on May 10, 2015, 06:46:54 am
Sorry about the bump, but I have been trying to extract the script for Lufia 1, and was wondering if there was any new progress on this. I have a prototype of the game which has an unpolished version of the script, and it appears that has a different length, so just applying a direct hardcoded event addresses is not going to work.

I have done some investigation on the dialogue window close bytes (0x04). As far as I can tell, dialogue closing is controlled by two bytes, 0x04yy, where yy is the type of dialogue window closing. For example, 0x046C is for closing a dialogue box in the opening scene (which has no background for the text). I'm guessing the mess before each dialogue is a mixture of information related to the type of background box, the way the text scrolls (automatic or user input), where the text box is display, justification, font type, etc. I haven't fully investigated that yet, though.

Edit: it seems that this is only partially true, because some dialogue closings are three bytes (e.g. for dialogues where the next dialogue is a yes/no option, it is 0x040C20)

Edit 2: As originally suspected, the excess bytes control things like the time the message is on screen and stuff. The game basically loads the script chunk as a subprogram, and the extra bytes contain commands that tell the game how to output the text. So in reality, it is not possible to read the text as one huge chunk with a program like Cartographer. You would need something far more involved, which is probably beyond my skill level.
Title: Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)
Post by: Vegetaman on January 21, 2016, 08:54:57 pm
Wow it's been almost five years and I totally feel I need to go back and update this SRAM document finally. Wow, talk about real life getting in the way.

But very interesting about the message box information, badinsults. I wonder if there are other things contained there, such as pauses or movement information for cutscenes, or if it is truly just text and text persistence time? I think we could figure this out!

EDIT:

Oh geeze it's been 6 years almost. Yikes.