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

Author Topic: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JUN 6)  (Read 24120 times)

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
==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
« Last Edit: June 06, 2011, 11:26:57 pm by Vegetaman »

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6927
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Are these sorts of projects worthy of this place?
« Reply #1 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).
"My watch says 30 chickens" Google, 2018

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5031
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Re: Are these sorts of projects worthy of this place?
« Reply #2 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
Red Comet: :'( Poor DS. Nobody loves him like RC does. :'(
Sliver-X: LET ME INFRINGE UPON IT WITH MY MOUTH
DSRH - Currently working on: Demon's Blazon, Romancing SaGa, FFIV EasyType.
http://www.youtube.com/user/DarknessSavior

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Re: Are these sorts of projects worthy of this place?
« Reply #3 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.
« Last Edit: February 04, 2010, 02:24:18 pm by Vegetaman »

creaothceann

  • Hero Member
  • *****
  • Posts: 2619
  • SPINESHARK
    • View Profile
    • creaothceann's website
Re: Are these sorts of projects worthy of this place?
« Reply #4 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.

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Re: Are these sorts of projects worthy of this place?
« Reply #5 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).

creaothceann

  • Hero Member
  • *****
  • Posts: 2619
  • SPINESHARK
    • View Profile
    • creaothceann's website
Re: My Personal Projects (Currently: Lufia & The Fortress of Doom SRAM data)
« Reply #6 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.)

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Re: My Personal Projects (Currently: Lufia & The Fortress of Doom SRAM data)
« Reply #7 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
« Last Edit: February 09, 2010, 11:45:52 pm by Vegetaman »

creaothceann

  • Hero Member
  • *****
  • Posts: 2619
  • SPINESHARK
    • View Profile
    • creaothceann's website
Re: My Personal Projects (Currently: Lufia & The Fortress of Doom SRAM data)
« Reply #8 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?

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Lufia & The Fortress of Doom Text Dump Dictionary
« Reply #9 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...

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5031
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Can a mod move this into the "Personal Projects" subforum? Vegetaman is clearly not a Newbie. ^^;

~DS
Red Comet: :'( Poor DS. Nobody loves him like RC does. :'(
Sliver-X: LET ME INFRINGE UPON IT WITH MY MOUTH
DSRH - Currently working on: Demon's Blazon, Romancing SaGa, FFIV EasyType.
http://www.youtube.com/user/DarknessSavior

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
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).
« Last Edit: February 17, 2010, 03:54:51 am by Vegetaman »

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
« Reply #12 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...



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:



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
« Last Edit: March 18, 2010, 01:13:03 am by Vegetaman »

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
« Reply #13 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.

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5031
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
« Reply #14 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
Red Comet: :'( Poor DS. Nobody loves him like RC does. :'(
Sliver-X: LET ME INFRINGE UPON IT WITH MY MOUTH
DSRH - Currently working on: Demon's Blazon, Romancing SaGa, FFIV EasyType.
http://www.youtube.com/user/DarknessSavior

Jigglysaint

  • Sr. Member
  • ****
  • Posts: 316
  • Corruptomancer
    • View Profile
    • Stuff Jigglysaint has done(like discover the Crocomire in MZM)
Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
« Reply #15 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.

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
« Reply #16 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();
        }

Jigglysaint

  • Sr. Member
  • ****
  • Posts: 316
  • Corruptomancer
    • View Profile
    • Stuff Jigglysaint has done(like discover the Crocomire in MZM)
Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
« Reply #17 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.
« Last Edit: November 25, 2010, 04:10:12 pm by Jigglysaint »

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor
« Reply #18 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
« Last Edit: February 12, 2011, 11:42:14 am by Vegetaman »

Vegetaman

  • Jr. Member
  • **
  • Posts: 79
  • Child of Doom
    • View Profile
Re: Lufia & The Fortress of Doom Text Dump & SRAM Editor (UPDATE: JAN 26)
« Reply #19 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.
« Last Edit: February 19, 2011, 05:05:40 pm by Vegetaman »