Romhacking.net

Romhacking => ROM Hacking Discussion => Topic started by: Choppasmith on August 18, 2018, 12:15:55 PM

Title: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on August 18, 2018, 12:15:55 PM
So I recently was able to rip the script from DQ I-III mobile and I wanted to try to update the DW games with it. Obviously I know it can't be 1:1 but I wanted to edit item names and the script and get it as close to "Modern DQ" as much as possible.

The thing that's really stumping me are item names. Yeah I read Silver X's document and understand that the game doesn't use standard pointers but rather a long string separated by FF hex and then split into two sections 

Bamboo{FF}Club{FF}Copper{FF}Hand{FF}Broad{FF}Flame{FF}Erdrick's{FF}Clothes{FF}Leather{FF}Chain{FF}Half{FF}Full{FF}Magic{FF}Erdrick's{FF}Small{FF}Large{FF}Silver{FF}Herb{FF}Torch{FF}Dragon's{FF}Wings{FF}Magic{FF}Fairy{FF}Ball of{FF}Tablet{FF}Fairy{FF}Silver{FF}Staff of{FF}Stones of{FF}Gwaelin's{FF}Rainbow{FF}Cursed{FF}Death{FF}Fighter's{FF}Erdrick's{FF}Secret{FF}

Pole{FF}{FF}Sword{FF}Axe{FF}Sword{FF}Sword{FF}Sword{FF}{FF}Armor{FF}Mail{FF}Plate{FF}Plate{FF}Armor{FF}Armor{FF}Shield{FF}Shield{FF}Shield{FF}{FF}{FF}Scale{FF}{FF}Key{FF}Water{FF}Light{FF}{FF}Flute{FF}Harp{FF}Rain{FF}Sunlight{FF}Love{FF}Drop{FF}Belt{FF}Necklace{FF}Ring{FF}Token{FF}Passage{FF}


I figured both sections go in order. But when I try to edit them it seems like the order is completely mixed up.

(https://i.imgur.com/Zpg08Hq.png)
(https://i.imgur.com/blH2ckh.png)
(https://i.imgur.com/jMoZZRj.png)

What really makes it complicated is trying to add a second line to previously 1 line items (Herb and Club -> Medicinal Herb and Oaken Club) and removing 1 line to 2 lined items (Stones of Sunlight -> Sunstone) Also for space, I tried removing the seemingly unused item Secret Passage (bare with me, while I've played DQ1 recently it's been many MANY years since I've played DW1). But I simply just removed the text and kept it as two FF bytes much like Club's second line. Unless it's just one of those weird things that just wasn't mean to work.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on August 19, 2018, 12:45:34 PM
You might enjoy reading through some other forum posts about Dragon Warrior, particularly this thread (http://www.romhacking.net/forum/index.php?topic=26135.msg360304#msg360304).

Both sections do go in order, with the first section giving the first line of text and the second section giving the second line of text (if the second line isn't "", the game automatically prefixes the second line with a space; this also happens when both "lines" are displayed side-by-side, e.g. "Thou hast found the Magic Key.").

Each of the sub-strings is terminated by $FF, so "Bamboo" goes with "Pole", "Club" goes with "", "Copper" goes with "Sword", etc. If you want to switch between using one line and two lines, it's as easy as e.g.

Stick{FF}King of{FF}Copper{FF}...

{FF}Clubs{FF}Sword{FF}...

to get "Stick" instead of "Bamboo Pole" and "King of Clubs" instead of "Club".

One thing to watch out for is that those two sections are actually four sections - the game also keeps pointers to the start of "Cursed" and "Belt", so if you don't update those pointers too, the final five items (including "Secret Passage", which actually is used) will probably show up incorrectly.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on August 19, 2018, 12:59:44 PM
Funny enough, you posted JUST before I was about to double post an update.

Good news is, I figured out how to match all the items and got it to work. Bad news is, the last two items after the two cursed items (Fighter's Ring (now Warrior's Ring) and Erdrick's Token (Now Mark of Erdrick) can't seem to load ANYTHING past the cursed items text (there's now nothing there as they're now one-lined items

(https://i.imgur.com/PIjqTFn.png)
(https://i.imgur.com/KkYmZ76.png)

QuoteOne thing to watch out for is that those two sections are actually four sections - the game also keeps pointers to the start of "Cursed" and "Belt", so if you don't update those pointers too, the final five items (including "Secret Passage", which actually is used) will probably show up incorrectly.

Yeah I thought something was kinda fishy there as when I tried renaming the first Cursed item it, part of "Rainbow" (for Rainbow drop) was showing up. How do I adjust the pointers for that then? (sorry still a bit of a romhacking n00b here)

Also, thanks for letting me know about Secret Passage, I pretty much removed it for space, but I'll have to find a way to get something back in there.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on August 19, 2018, 04:33:58 PM
Quote from: Choppasmith on August 19, 2018, 12:59:44 PM
Funny enough, you posted JUST before I was about to double post an update.
:P.

Quote from: Choppasmith on August 19, 2018, 12:59:44 PM
Good news is, I figured out how to match all the items and got it to work. Bad news is, the last two items after the two cursed items (Fighter's Ring (now Warrior's Ring) and Erdrick's Token (Now Mark of Erdrick) can't seem to load ANYTHING past the cursed items text (there's now nothing there as they're now one-lined items
Congratulations on figuring it out! For your bad news, though, I'm not sure exactly what you mean. Can you give an example?

Quote from: Choppasmith on August 19, 2018, 12:59:44 PM
Yeah I thought something was kinda fishy there as when I tried renaming the first Cursed item it, part of "Rainbow" (for Rainbow drop) was showing up. How do I adjust the pointers for that then? (sorry still a bit of a romhacking n00b here)

Also, thanks for letting me know about Secret Passage, I pretty much removed it for space, but I'll have to find a way to get something back in there.
The pointers you'll care about are at 0x6842-0x6851 (the text order is different from the pointer order, so I've sorted the pointers below by text address instead of pointer address), and you can update them the same way you'd update any other pointer (e.g. if "Item list part 2, line 1" originally started at 0x7B9F and you now need it to start at 0x7BA0 [+1 byte], then you'd change the value of the pointer at 0x6848 from 8F BB to 90 BB [+1 byte]).


Pointer Address   What it points to
0x6844Item list part 1, line 1
0x6848Item list part 2, line 1
0x6846Item list part 1, line 2
0x684AItem list part 2, line 2
0x684EMonster list, line 1
0x6850Monster list, line 2
0x684CPrice list
0x6842Spell list

There's also plenty of free space available in that area - you've got all the way down to 0x7FE7, which gives you 300+ extra bytes to work with, which ought to be more than enough for your purposes.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on August 19, 2018, 06:39:58 PM
Quote from: abw on August 19, 2018, 04:33:58 PM
:P.


Seriously, I hit reply and got the notification that someone replied XD

Quote
Congratulations on figuring it out! For your bad news, though, I'm not sure exactly what you mean. Can you give an example?

Yeah, just look at the top screenshot above. It should be Warrior's Ring and Mark of Erdrick but instead it's stuck loading Pledge and Drop, the last two words before the cursed items.


QuoteThe pointers you'll care about are at 0x6842-0x6851 (the text order is different from the pointer order, so I've sorted the pointers below by text address instead of pointer address), and you can update them the same way you'd update any other pointer (e.g. if "Item list part 2, line 1" originally started at 0x7B9F and you now need it to start at 0x7BFA [+1 byte], then you'd change the value of the pointer at 0x6848 from 8F BB to 90 BB [+1 byte]).


Pointer Address   What it points to
0x6844Item list part 1, line 1
0x6848Item list part 2, line 1
0x6846Item list part 1, line 2
0x686AItem list part 2, line 2
0x686EMonster list, line 1
0x6850Monster list, line 2
0x684CPrice list
0x6842Spell list

There's also plenty of free space available in that area - you've got all the way down to 0x7FE7, which gives you 300+ extra bytes to work with, which ought to be more than enough for your purposes.

Oh WOW. Thanks for this, so I presume 3FF0 is the magic number to find pointers for NES (or at least this game) I was used to FFF80 from working in Fortune Street on PS2 kinda went in blind on what to expect and then Silver X's doc said the weren't really any pointers here so I got confused.

I'm wondering about Monsters since I plan to edit Monster Names next. How are those split? I see all the names huddled together but then after Dragonlord, there's stuff like RED with a bunch of padding with other short words. Are these for certain palette swap monsters like the Red Slime? Is it like the items and weapons where they go together? How does that work?

HUGE thanks for the help though. Don't think I could've figured out out on my own.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on August 19, 2018, 08:27:14 PM
Quote from: Choppasmith on August 19, 2018, 06:39:58 PM
Yeah, just look at the top screenshot above.
Ah, okay, I wasn't sure how much/which parts of that was working vs. not working. My first guess would be that the pointer for "Item list part 2, line 2" at 0x686A isn't pointing to the start of your new (Cursed) "Belt" text. Do your new versions of the Cursed Belt and Death Necklace items show up correctly?

Quote from: Choppasmith on August 19, 2018, 06:39:58 PM
Oh WOW. Thanks for this, so I presume 3FF0 is the magic number to find pointers for NES (or at least this game) I was used to FFF80 from working in Fortune Street on PS2 kinda went in blind on what to expect and then Silver X's doc said the weren't really any pointers here so I got confused.
You really should read through that Dragon Warrior 1 Spanish Translation (http://www.romhacking.net/forum/index.php?topic=26135.0) thread, as it covers a lot of stuff you're going to want to know if you're planning to edit all of the text in this game. Among sundry other points, the topics covered include NES memory mapping (how to figure out that $3FF0 offset), what's going on with Dragon Warrior's pointers (there are pointers to some things, but after following a pointer the game starts counting end tokens to find the string it wants), and some examples of how to figure out where data is coming from and what pointers need to be updated (e.g. the item list). :beer:

Quote from: Choppasmith on August 19, 2018, 06:39:58 PM
[Are Monster Names] like the items and weapons where they go together?
Yup, monster names work just like item names - there's one section for the first line of text, and then a second section for the second line of text, so you'll have e.g.

...Warlock{FF}Metal{FF}Wolf{FF}...

...{FF}Scorpion{FF}{FF}...

where "Warlock" goes with "", "Metal" goes with "Scorpion", "Wolf" goes with "", etc.

Quote from: Choppasmith on August 19, 2018, 06:39:58 PM
HUGE thanks for the help though. Don't think I could've figured out out on my own.
No worries - I've done a bunch of work on this game recently, so it's still fairly fresh in my memory ;). You probably could have figured it out on your own, it would have just taken a bit longer!

P.S. I fixed a typo in my previous post; I wanted to say 0x7BA0 but my fingers typed 0x7BFA for some reason :o.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on August 21, 2018, 10:10:55 AM
Thank you so much, it's working great now

(https://i.imgur.com/OuZFo5f.png)
(https://i.imgur.com/j1QjWS7.png)
(https://i.imgur.com/QAZ3Tc9.png)

I had to get sort of creative with the prestidigitator (previously magician) I was worried having a name that long on one line would lead to overflow, so I just split it with presti - (with a space before the dash) on the first line and digitator on the second line.

(https://i.imgur.com/VqYSPuo.png)

Looks kinda funky, but at least it's not "messy". What do you think?

Quote from: abw on August 19, 2018, 08:27:14 PM

P.S. I fixed a typo in my previous post; I wanted to say 0x7BA0 but my fingers typed 0x7BFA for some reason :o.

You made another one in your post above I think you mean to put 4A and 4E in a couple of your pointers not 6A and 6E ;)

Now I'm going to start doing a lot of the menu and ui stuff and then dialog. The latter might be really tricky, it's kinda early to say but the official mobile script seems bigger for a lot of dialog. There's some interesting differences though. For one, there's a lot of text in DW for menu stuff with glorious Olde English messages when it's straightforward, plain English in DW Mobile. However a lot of the script for actual character dialog is more robust. I can try and describe, but better just to show you

Opening dialog with the King

Dragon Warrior:

QuoteDescendant of Erdrick, listen now to my words

It is told that in ages past Erdrick fought demons with a Ball of Light

Then came the Dragonlord who stole the precious globe and hid it in the darkness

Now, ь, thou must help us recover the Ball of Light and restore peace to our land

The Dragonlord must be defeated

Take now whatever thou may find in these Treasure Chests to aid thee in thy quest

Then speak with the guards, for they have much knowledge that may aid thee

May the light shine upon thee, ь


Dragon Quest Mobile (sorry a lot of messy formatting from my script rip)

QuoteKing: <3F<07! Scion of the bloodline of Erdrick, hero of legend! Long have I awaited thy coming!<1A<0C
<11King: In days of yore, thy revered ancestor did receive of the Almighty Goddess the Sphere of Light.<1A<0C
<11King: By its power was our world rid of the menace which did beset it.<1A<0C
<11King: Yet, alas, some few years past, there did arise a new threatâ€"the Dragonlord.<1A<0C
<11King: With his cunning, he did steal away the Sphere of Light from us, plunging the land into darkness once more.<1A<0C
<11King: Should this state of affairs be suffered to continue, the night must surely take unrelenting hold, and our realm perish.<1A<0C
<11King: So I say unto thee, <07 of the bloodline of heroes, vanquish the accursed Dragonlord, and reclaim the Sphere of Light!<1A<0C
<11King: In the chests o'er yonder wilt thou find items to aid thee on thy quest. Take what thou wilt, with my blessing.<1A<0C
<11King: Partake thee also of the wisdom of those loyal subjects gathered here in my throne room.<1A<0C
<11King: Doubt not but that their knowledge will serve thee as well as any shield.<1A<0C
<11King: May the Goddess guide thee to victory, and return thee unto us ere long, brave <07!<0C

I HAVE been reading that Spanish translation thread and if there's a way to get more space for dialog, I might have to look into that. Too early to say right now though.

BONUS FUN FACT! S-E actually programmed dialog for groups of monsters despite not being used.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: werewolfslayr925 on August 21, 2018, 03:08:50 PM
Boy am I late to this thread.

QuoteSilver X's document

I looked through this as well, but, unfortunately, it didn't help me much either.

Choppasmith, I have some notes that may (or may not) help you. Hacking this game was a perpetual reminder that I suck at programming, and I tried to take notes as often as possible, especially once I got something working right. If you want, send me a PM and we can swap/compare notes. Maybe we can even get some updated documentation out there.

Regarding your translation, there's a program that Psyklax gave me that someone else (KingMike?) developed that may help you with the dialogue. I didn't need it because the Spanish translation is small enough to fit into the localized character count.

I stopped my hack after finally getting the $%^&ing enemy names and item names to agree with me. All I have left are translating menus, translating credits, and testing. After seeing abw publish a Latin translation (of all things) and you updating the text, I may as well get back into it and get a third translation out there.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on August 21, 2018, 08:48:08 PM
Quote from: Choppasmith on August 21, 2018, 10:10:55 AM
I had to get sort of creative with the prestidigitator (previously magician) I was worried having a name that long on one line would lead to overflow, so I just split it with presti - (with a space before the dash) on the first line and digitator on the second line.
It looks like monster names have a limit of 11 characters hardcoded at 0x78B8; changing that value to e.g. $0F doesn't appear to break anything immediately, but you'd want to do some more testing/analysis to be sure using that much extra space was safe. Assuming it doesn't start overwriting otherwise reserved memory, you might get some awkward line wraps, but monster names are only ever displayed inside the combat dialogue window, which is more than wide enough to fit a 15-character name without breaking the visual layout, so you should be okay.

Quote from: Choppasmith on August 21, 2018, 10:10:55 AM
You made another one in your post above I think you mean to put 4A and 4E in a couple of your pointers not 6A and 6E ;)
Dammit, I'm getting sloppy in my old age :banghead:. I've fixed those too - thanks for pointing them out!

Quote from: Choppasmith on August 21, 2018, 10:10:55 AM
Now I'm going to start doing a lot of the menu and ui stuff and then dialog. The latter might be really tricky, it's kinda early to say but the official mobile script seems bigger for a lot of dialog.
There's an Atlas insert script for the menus in the Spanish thread, so that should help. There's no extra space immediately after the existing main dialogue (the very next byte is code), but if the new script does end up being longer than the current script, you can find some tips on adding DTE elsewhere on the forum (http://www.romhacking.net/forum/index.php?topic=24943.0), which will likely get you a compression rate of somewhere between 30% - 40%. Hopefully that'll be enough; if not... well, cross that bridge if/when you get to it.

Quote from: Choppasmith on August 21, 2018, 10:10:55 AM
There's some interesting differences though.
Haha. I've never played any of the remakes, but that's some pretty awesome dialogue right there :D.

Quote from: werewolfslayr925 on August 21, 2018, 03:08:50 PM
I stopped my hack after finally getting the $%^&ing enemy names and item names to agree with me. All I have left are translating menus, translating credits, and testing. After seeing abw publish a Latin translation (of all things) and you updating the text, I may as well get back into it and get a third translation out there.
Yeah, I was sort of wondering what had happened with your translation - it sounded like you were very close to being finished but were running out of steam. Hopefully you'll be able to polish it off without too many more hurdles!
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on August 22, 2018, 01:26:04 PM
Quote from: abw on August 21, 2018, 08:48:08 PM
It looks like monster names have a limit of 11 characters hardcoded at 0x78B8; changing that value to e.g. $0F doesn't appear to break anything immediately, but you'd want to do some more testing/analysis to be sure using that much extra space was safe. Assuming it doesn't start overwriting otherwise reserved memory, you might get some awkward line wraps, but monster names are only ever displayed inside the combat dialogue window, which is more than wide enough to fit a 15-character name without breaking the visual layout, so you should be okay.

Can confirm after a few battles, it does indeed work!

(https://i.imgur.com/EU9V7Zr.png)

I didn't think the game would be good at automatically moving text to a new line.

QuoteHaha. I've never played any of the remakes, but that's some pretty awesome dialogue right there :D.

Yeah the richer dialog is definitely a reason I wanted to try this, it's pretty great. DQ Builders seems to use the mobile translation word for word, so I thought the consistency would be a good reason too.

(http://www.siliconera.com/wordpress/wp-content/uploads/2016/10/dqb_thumb.jpg)


Quick question about your Latin translation though, how did you make the new logo? I'm mostly curious in regards to font and such. I'd love to be able to be able to restore the original logo in there, but I read an old post by Psyklax (http://www.romhacking.net/forum/index.php?topic=24269.msg342202#msg342202) about just how unfeasible it would be. And I thought why not just go the easy route and just replace the WARRIOR with QUEST. Only problem is I can't seem to find a font that looks anything like the Dragon Warrior title screen font that would look good. Yours looks great though, and I'm just curious what you did there.

Edit: If anything, right now I need to find out where the pointers for main text are. I thought maybe the way the text was organized in the DW1 text editor program would give me an idea of where certain pointers were but that doesn't seem to be the case. Unless it's ALL one pointer? But given the weird way items were done, I doubt it.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on August 22, 2018, 06:28:09 PM
Quote from: Choppasmith on August 22, 2018, 01:26:04 PM
Can confirm after a few battles, it does indeed work!
Yeah, I thought it looked like it works based on some casual testing, but you'll want to keep an eye on it - I didn't check through all of the relevant code to make sure that change was actually safe, so if you see weird stuff happening later on, keep this in mind as a possible cause.

Quote from: Choppasmith on August 22, 2018, 01:26:04 PM
I didn't think the game would be good at automatically moving text to a new line.
There is a control code for forcing a line break, but the game also automatically wraps text within the dialogue windows (not the menu windows, though). As long as you're not using a language that loves stringing really long words together (*cough*Latin*cough*), the existing line wrapping should be just fine.

Quote from: Choppasmith on August 22, 2018, 01:26:04 PM
[H]ow did you make the new logo? I'm mostly curious in regards to font and such.
The logo was pretty annoying to create, but I blame most of that on yy-chr obstinately refusing to maintain palette indices during copy/paste. For the font, basically I just started with the existing logo, kept the letters I could reuse, created the missing letters based on the existing letters (e.g. the new "m" is just the old "n" with a copy of the curvy part of the "n" pasted beside itself), and then started squishing letters horizontally until they fit in the available screen and CHR space (e.g. the old "D" was 16 pixels wide, but the new "D" is only 10 pixels wide, and the bottom half of the two "L"s are actually the same tile drawn twice). Glad you liked it!  :beer:

Quote from: Choppasmith on August 22, 2018, 01:26:04 PM
I'd love to be able to be able to restore the original logo in there, but I read an old post by Psyklax (http://www.romhacking.net/forum/index.php?topic=24269.msg342202#msg342202) about just how unfeasible it would be.
The English logo uses all the tiles from $74 to $A8 (or up to $AC if you cannibalize the spackled background, or $AE if you also ditch the borders), the rest of that CHR bank appears to be in use for other things, and it looks like the Japanese logo uses a lot of tiles (112), so it probably would take a fair bit of work to transplant the Japanese logo directly. You could maybe try shrinking it, but I'm not sure how far you'd have to go before the entire logo fit.

Quote from: Choppasmith on August 22, 2018, 01:26:04 PM
Edit: If anything, right now I need to find out where the pointers for main text are.
The dialogue pointer system is also explained somewhere in one of the Spanish translation threads; a quick summary is that the pointer table is at 0x8012-0x8037 and each pointer points to a group of 16 strings, where each of the 16 strings is itself terminated by $FC.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on August 22, 2018, 07:47:59 PM
Quote from: abw on August 22, 2018, 06:28:09 PM
The dialogue pointer system is also explained somewhere in one of the Spanish translation threads; a quick summary is that the pointer table is at 0x8012-0x8037 and each pointer points to a group of 16 strings, where each of the 16 strings is itself terminated by $FC.
Apologies, I looked through the thread earlier and didn't see anything. I'll look through it again thanks.

Edit: Though, now knowing where the pointers are, I can always go backwards and dump each set of dialog that way. 
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on August 24, 2018, 08:28:46 AM
Quote from: Choppasmith on August 22, 2018, 07:47:59 PM
Apologies, I looked through the thread earlier and didn't see anything. I'll look through it again thanks.

Edit: Though, now knowing where the pointers are, I can always go backwards and dump each set of dialog that way.
No worries - there's plenty of info available, but it's spread out over many posts across several different threads and mixed in with a bunch of other stuff you likely wouldn't care about, so it's kind of annoying to track down and easy to miss little important parts. Somebody ought to pull it all together into a cohesive whole and put it somewhere, like in a document or on the wiki. I'll see if I can put some time into that next week.

I'm sure you'll notice this once you try dumping the dialogue, but one other thing to be aware of is that the final pointer only has 10 strings instead of the usual 16.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on August 24, 2018, 10:16:42 AM
Quote from: abw on August 24, 2018, 08:28:46 AM
No worries - there's plenty of info available, but it's spread out over many posts across several different threads and mixed in with a bunch of other stuff you likely wouldn't care about, so it's kind of annoying to track down and easy to miss little important parts. Somebody ought to pull it all together into a cohesive whole and put it somewhere, like in a document or on the wiki. I'll see if I can put some time into that next week.

I'm sure you'll notice this once you try dumping the dialogue, but one other thing to be aware of is that the final pointer only has 10 strings instead of the usual 16.

Speaking of dumping, I've decided to try the Pointer Tables program to rip the script for editing and then put it back in. I'm sort of baffled. I thought from the pointer locations I could simply reverse the bytes, subtract 3FF0 and that would be the address of the corresponding set of strings, but it didn't work. Yet I extracted the script just fine with pointer tables. Not a big deal, but I'm wondering what i did wrong there.

By chance though, do you know how long each individual string can be? I ran into some NPC dialog that's much MUCH longer with the official Mobile script.

Original:
Where oh where can I find Princess Gwaelin?

Mobile Script:
O Princess... Princess, where art thou...?<1A<0C
Could it be that the foul fiends who took thee have taken thy young life also...?<1A<0C
...Nay!<0D0F We cannotâ€"we must notâ€"surrender to despair!<1A<0C
Brave <07, I pritheeâ€"forget all that I said. Henceforth, hope, and hope alone, shall guide me!

I know I have to worry about the overall script length, but right now I'm just trying to find the corresponding strings (unlike items and monster names, the two versions are NOT in the same order) and figured i could always edit later if need be (in the above case just use the first sentence).
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on August 27, 2018, 09:17:29 PM
Quote from: Choppasmith on August 24, 2018, 10:16:42 AM
Speaking of dumping, I've decided to try the Pointer Tables program to rip the script for editing and then put it back in. I'm sort of baffled. I thought from the pointer locations I could simply reverse the bytes, subtract 3FF0 and that would be the address of the corresponding set of strings, but it didn't work. Yet I extracted the script just fine with pointer tables. Not a big deal, but I'm wondering what i did wrong there.
Yeah, Pointer Tables seems to do a decent job with this script. If you ever need to manually calculate the offset, just remember that the offset you need changes based on which ROM bank the data is stored in and which RAM bank it gets accessed from, so for data in ROM bank 1 (e.g. the item list) accessed from RAM bank 0, you have an offset of $4000 * ROM bank - $4000 * RAM bank - $8000 + $10 = $4000 * 1 - $4000 * 0 - $8000 + $10 = -$3FF0, but for data in ROM bank 2 (e.g. the main dialogue) accessed from RAM bank 0, you have an offset of $4000 * 2 - $4000 * 0 - $8000 + $10 = $10, assuming the game uses banks of size $4000 like Dragon Warrior does.

Quote from: Choppasmith on August 24, 2018, 10:16:42 AM
By chance though, do you know how long each individual string can be? I ran into some NPC dialog that's much MUCH longer with the official Mobile script.
A quick test shows that the game will quite happily spew the entire main dialogue out as a single string, so you don't need to worry much about individual string lengths, just the total script size.

Quote from: Choppasmith on August 24, 2018, 10:16:42 AM
[R]ight now I'm just trying to find the corresponding strings (unlike items and monster names, the two versions are NOT in the same order)
At least there are only 298 strings to match up here, so it's not so bad. Just imagine trying to do the same thing in DQVIII, for example *shudders*.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on September 11, 2018, 11:22:29 PM
Well it's all done! It's about 15K larger than the original (going by text dump sizes), so yeah, might have to ask Psyklax about the DTE routine he made.

Quick question for you though abw, if you can. I'm modifying the 1.0 ROM and according to TCRF, the big difference between the 1.0 ROM and the revision 1.1 ROM is that when taking damage in battle the message says "Thy Hits decreased by #" it was later changed to Hit Points.

Now from reading the old Spanish translation thread there's a code used for experience (and hit points in the 1.1 version) where after the word there's an "F0" byte that prints either point or points based on the number. But for Hits, there's a code "EF" after "Hit" do you know if this could be an "add or omit an S based on number" code? I don't think it works the same way as the F0 byte used for Experience Points and later Hit Points. If it is a code for adding an S, I'd hope to use it for changing gold treasure chest to "Obtained # gold piece/s" and the Gwaelin's Love/Princess' Pledge Item to indicate pace or paces.

Edit: So I figured I'd just check it out myself really quick and yes, placing EF after a word DOES place an s depending on the number in the string. Praise be!

(https://i.imgur.com/HtghY2i.png)
(https://i.imgur.com/e9IUdH3.png)

It was a quick and sloppy hex edit. Yes there ARE two spaces after pace<EF>.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on September 23, 2018, 02:02:25 PM
Quote from: abw on August 24, 2018, 08:28:46 AM
Somebody ought to pull [the useful info spread out over recent Dragon Warrior threads] all together into a cohesive whole and put it somewhere, like in a document or on the wiki.
FYI, I went through a bunch of those posts, pulled out some stuff that looked interesting/relevant, added a few other things I've learned, and updated the wiki's ROM map page (http://datacrystal.romhacking.net/wiki/Dragon_Warrior:ROM_map) with the results. Feel free to add anything I overlooked :beer:!

Edit: fixed link (apparently BBCode hates protocol-relative links :().
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on September 23, 2018, 02:48:46 PM
Quote from: abw on September 23, 2018, 02:02:25 PM
FYI, I went through a bunch of those posts, pulled out some stuff that looked interesting/relevant, added a few other things I've learned, and updated the wiki's ROM map page (https://www.romhacking.net//datacrystal.romhacking.net/wiki/Dragon_Warrior:ROM_map) with the results. Feel free to add anything I overlooked :beer:!

Oh neat, I didn't realize there was a byte for adding quick pauses for dialog. Considering the mobile script has them and thinking the NES game didn't I just used the Line Break/Wait for player input byte to simulate a pause... I'll have to go over my script again and try adding a few.

Also, you missed my EF byte above (adding or omitting an S based on number value in a string).

BTW, while you're here. I got the IPS patch from Psyklax to add DTE compression, but I couldn't find anything (unless I stupidly missed it in the Spanish translation thread) on how to make changes in the ROM to actually use it? I used DTE OPT to find my most common combinations, but I guess there's a table added in to the ROM I have to update?
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Psyklax on September 24, 2018, 02:33:26 AM
Quote from: Choppasmith on September 23, 2018, 02:48:46 PM
BTW, while you're here. I got the IPS patch from Psyklax to add DTE compression, but I couldn't find anything (unless I stupidly missed it in the Spanish translation thread) on how to make changes in the ROM to actually use it? I used DTE OPT to find my most common combinations, but I guess there's a table added in to the ROM I have to update?

Sorry, I didn't see your new PM. I wrote the DTE thing a few months ago, so I'll need to look at it again later today. Basically, DTE-Opt (thanks KingMike for such a simple yet useful tool) gives you a list of the most common combos in order of occurrence (the text file you sent in the PM is not what you use). I think it just appears in the command prompt when you run it, so I use a batch file and capture the output to a text file.

Anyway, once you know your pairs, you can put them in your table file, then use something like Pointer Tables to insert your text into the ROM. Of course, you then need to insert your list of pairs into the ROM so that the game knows what they are.

I can't actually remember where to put the table, but the easiest thing is to just give me your new text and I'll try to insert it. I picked a part of the ROM that shouldn't be used by anything else. Later today I'll be able to look at my files and figure it out.

I admit that I didn't provide much documentation on what I did, but it's because I didn't really think about it being used much by people. Maybe I should make a formal version with documentation and put it in the Utilities section? :huh:
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on September 24, 2018, 09:46:48 PM
Quote from: Choppasmith on September 23, 2018, 02:48:46 PM
Also, you missed my EF byte above (adding or omitting an S based on number value in a string).
Ah, yes, I didn't update any of the text table stuff.

Quote from: Choppasmith on September 23, 2018, 02:48:46 PM
BTW, while you're here. I got the IPS patch from Psyklax to add DTE compression, but I couldn't find anything (unless I stupidly missed it in the Spanish translation thread) on how to make changes in the ROM to actually use it? I used DTE OPT to find my most common combinations, but I guess there's a table added in to the ROM I have to update?
Psyklax can confirm this, but if you're looking at the DTE code Psyklax posted in the Dragon Warrior 1 in Spanish (http://www.romhacking.net/forum/index.php?topic=24943.msg343735#msg343735) thread, that code goes looking for the DTE table starting at RAM $BEF0 (ROM 0x7F00) and wants the entries arranged as "entry 1 byte 1, entry 1 byte 2, entry 2 byte 1, entry 2 byte 2, etc.", with DTE entries starting at 80 in your table file. The original script compressed by about 40%, so it might just be enough to fit your larger script in!
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on September 25, 2018, 12:13:04 AM
Quote from: Psyklax on September 24, 2018, 02:33:26 AM
Sorry, I didn't see your new PM. I wrote the DTE thing a few months ago, so I'll need to look at it again later today. Basically, DTE-Opt (thanks KingMike for such a simple yet useful tool) gives you a list of the most common combos in order of occurrence (the text file you sent in the PM is not what you use). I think it just appears in the command prompt when you run it, so I use a batch file and capture the output to a text file.

Anyway, once you know your pairs, you can put them in your table file, then use something like Pointer Tables to insert your text into the ROM. Of course, you then need to insert your list of pairs into the ROM so that the game knows what they are.

I can't actually remember where to put the table, but the easiest thing is to just give me your new text and I'll try to insert it. I picked a part of the ROM that shouldn't be used by anything else. Later today I'll be able to look at my files and figure it out.

I admit that I didn't provide much documentation on what I did, but it's because I didn't really think about it being used much by people. Maybe I should make a formal version with documentation and put it in the Utilities section? :huh:

Well here's the finished script if you want to try it yourself

http://www.mediafire.com/file/s72aa472q2ll1uf/dw1_script.txt/file

I also tweaked your table a little bit. Mainly adding the special EF byte and changing the enemy name byte with a space to [ANME] to avoid confusion with the [NME] byte. The former is just used for the opening "Monster" draws near text and adds an A or An at the beginning.

00=0
01=1
02=2
03=3
04=4
05=5
06=6
07=7
08=8
09=9
0A=a
0B=b
0C=c
0D=d
0E=e
0F=f
10=g
11=h
12=i
13=j
14=k
15=l
16=m
17=n
18=o
19=p
1A=q
1B=r
1C=s
1D=t
1E=u
1F=v
20=w
21=x
22=y
23=z
24=A
25=B
26=C
27=D
28=E
29=F
2A=G
2B=H
2C=I
2D=J
2E=K
2F=L
30=M
31=N
32=O
33=P
34=Q
35=R
36=S
37=T
38=U
39=V
3A=W
3B=X
3C=Y
3D=Z
3E="
3F=""
40=}
41=*
44=:
45=_
47=.
48=,
49=-
4B=?
4C=!
4D=;
4E=)
4F=(
50={
52=.}
53='
54=`
57=[57]
5F=
60=[60]
EF=[S]
F0=[PNT]
F1=[ANME]
F3=[XP]
F4=[NME]
F5=[NUM]
F6=[SPL]
F7=[INV]
F8=[ME]
FB=@
FC=%
FD=&
FF=[ITM]


And yeah I don't know why dteopt doesn't just make a "list" like it does in the command prompt. It's much easier to read than the "chart".

Quote from: abw on September 24, 2018, 09:46:48 PM
Ah, yes, I didn't update any of the text table stuff.
Psyklax can confirm this, but if you're looking at the DTE code Psyklax posted in the Dragon Warrior 1 in Spanish (http://www.romhacking.net/forum/index.php?topic=24943.msg343735#msg343735) thread, that code goes looking for the DTE table starting at RAM $BEF0 (ROM 0x7F00) and wants the entries arranged as "entry 1 byte 1, entry 1 byte 2, entry 2 byte 1, entry 2 byte 2, etc.", with DTE entries starting at 80 in your table file. The original script compressed by about 40%, so it might just be enough to fit your larger script in!

Bear with me, I'm still a little confused. Starting at 7FF0 are a bunch FF bytes. So I'd put the various two letter combinations there and then update the table file starting at 80=?

So for example, if the first one I want to put in is "th", I'd put in t and h at 7F00 and 7F01 and then add 80=th to my table file. Is that right?
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on September 25, 2018, 06:00:21 PM
Quote from: Choppasmith on September 25, 2018, 12:13:04 AM
The former is just used for the opening "Monster" draws near text and adds an A or An at the beginning.
Oh, that reminds me - the game code for this treats O and Y as consonants, not vowels, so if you renamed any monsters to start with those letters and wanted "An" instead of "A", you'll need a very tiny ASM hack to fix that.

Quote from: Choppasmith on September 25, 2018, 12:13:04 AM
So for example, if the first one I want to put in is "th", I'd put in t and h at 7F00 and 7F01 and then add 80=th to my table file. Is that right?
Yes, except that after trying this out again, I remembered that the DTE table entries actually start at 81 instead of 80, so you'd have 81=th in your table file instead. However...

Quote from: Choppasmith on September 25, 2018, 12:13:04 AM
Well here's the finished script if you want to try it yourself
Alas, the original game only gives you a total of 15,495 bytes of script space, but DTE or dictionary compression is only going to get your script down to 17,000 - 18,000 bytes. Even 7-zip only compresses the script down to ~ 12,000 bytes. None of the existing ROM banks have enough free space to hold 2,000 - 3,000 bytes of surplus script, so I think you're going to need better compression (something around 50% rather than the 40% DTE/dictionary/Huffman give) or ROM expansion here.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on September 26, 2018, 03:21:38 PM
Quote from: abw on September 25, 2018, 06:00:21 PM
Oh, that reminds me - the game code for this treats O and Y as consonants, not vowels, so if you renamed any monsters to start with those letters and wanted "An" instead of "A", you'll need a very tiny ASM hack to fix that.

Now THAT I spotted in the Spanish translation thread. Thankfully shouldn't apply to me.

Quote
Alas, the original game only gives you a total of 15,495 bytes of script space, but DTE or dictionary compression is only going to get your script down to 17,000 - 18,000 bytes. Even 7-zip only compresses the script down to ~ 12,000 bytes. None of the existing ROM banks have enough free space to hold 2,000 - 3,000 bytes of surplus script, so I think you're going to need better compression (something around 50% rather than the 40% DTE/dictionary/Huffman give) or ROM expansion here.

Yeah, I thought I'd try it in case your calculations were off and yeah, gave me a message that I'm about 5,000 bytes over the limit. Even trying to trim a lot of the script only reduced it by about a K.

Bummer :/
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on September 27, 2018, 09:56:13 PM
Well, probably the easiest way to go here is to expand the ROM (insert 0x10000 bytes at 0xC010, update the iNES header to specify 8 PRG banks [set 0x4 to $08]). After that, it looks like changing a mere 18 bytes (19 if you count the iNES header change) is enough to get the game to flip between reading from the original and expanded banks as appropriate.

When reading text, the relevant bank swaps are controlled from:
0x7558 (when finding the pointer to the right group of strings)
0x756E (when scanning through the group of strings looking for the start of the desired string)
0x7689 (when reading the desired string)

There's no need to change the first bank swap, since storing all the pointers in the original bank isn't a problem. For the other two bank swaps, there's a convenient block of 4 bytes that do the same thing in both places, so those are ideal spots to overwrite with a hook to some new code located in some unused space in the fixed bank (original bank 3, new bank 7):

0x756C and 0x7689:
EA        NOP
20 54 FF  JSR $FF54
Alas, by the time that code runs, the memory that told us which string the game wanted to read has already been overwritten, but there's a completely pointless AND #$F0 (pointless because it's immediately followed by 4 LSRs and there are some ASLs before the next time C matters) back when that information was still available, so we can steal that to store the high byte of the string number in an unused byte of RAM:
0x7544:
86 E1     STX $E1
In the new code to handle selecting which bank to read from, we just read that high byte of the string number (i.e. 0 or 1) and add 2 (to get 2 or 3) to get the bank to read from, then do the LDX from the code that we overwrote to hook in to this new code:
0x1FF64:
A5 E1     LDA $E1
18        CLC
69 02     ADC #$02
A2 9F     LDX #$9F
60        RTS
After that, you'll want to insert the first 256 strings into the original bank (2, a.k.a. 0x8010-0xC00F; they'll all fit with DTE compression), the other 42 into the new bank (3, a.k.a. 0xC010-0x1000F), and... voilà! I played around with it for a couple of minutes and everything seemed to be working okay, though you'll definitely want to add some more breaks in the text, since some of the longer sections take up more than a full window and cause the first line(s) to scroll out of view pretty quickly.

Edited to correct which byte to alter to update the PRG size.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on September 28, 2018, 12:43:37 AM
Quote from: abw on September 27, 2018, 09:56:13 PMAfter that, you'll want to insert the first 256 strings into the original bank (2, a.k.a. 0x8010-0xC00F; they'll all fit with DTE compression), the other 42 into the new bank (3, a.k.a. 0xC010-0x1000F), and... voilà! I played around with it for a couple of minutes and everything seemed to be working okay, though you'll definitely want to add some more breaks in the text, since some of the longer sections take up more than a full window and cause the first line(s) to scroll out of view pretty quickly.

Okay so, you lost me here a bit.

So even if we split the text up into two different banks, pointers can stay in the same exact place, right? I counted the first 256, and unless I'm mistaken that takes me up to the end of the 8030 string (last string being "The [NME] breathes fire!) when I use pointer tables to insert the script it says I'm still over the limit by 1492 bytes. Maybe I just miscounted should I go back a set?

EDIT: Oh wait, I'm looking in the ROM and I can see the last line at c290, maybe I just got that message because it goes past the original limit? Or did I do something wrong there?

Also if I'm going to use PT to insert the rest of the script can I just make a copy of the script with the rest of the strings and just change the Text Start and Text End values to something like C010-1000F or is there a better program to insert a DTE script with for this kind of case?
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on September 28, 2018, 08:47:46 AM
Yeah, you can keep all of the pointers at 0x8012-0x8037. Splitting the pointers between banks would have cost more in code than the 6 bytes of data we'd regain, so I didn't bother, and it doesn't hurt to keep them all together anyway. 256 strings divided by 16 strings per pointer = 16 pointers, so that's everything down to the end of the 0x8030 pointer a.k.a. the start of the 0x8032 pointer.

I was actually using abcde, but pretty much any program including Pointer Tables should work just as well here. For Pointer Tables, I gave it a try by splitting the script into 2 files and updating each file's header:
Quote from: File #1
Table Start:   8012
Table End:   8031
Text Start:   8038
Text End:   BCBF
XOffset:   10

...
and then the first 16 pointers + text

Quote from: File #2
Table Start:   8032
Table End:   8037
Text Start:   C038
Text End:   FCBF

...
(note the lack of XOffset) and then the last 3 pointers + text. I get the exact same output ROM using either program, so use whichever one you want :beer:.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on September 30, 2018, 07:49:51 PM
Quote from: abw on September 28, 2018, 08:47:46 AM
Yeah, you can keep all of the pointers at 0x8012-0x8037. Splitting the pointers between banks would have cost more in code than the 6 bytes of data we'd regain, so I didn't bother, and it doesn't hurt to keep them all together anyway. 256 strings divided by 16 strings per pointer = 16 pointers, so that's everything down to the end of the 0x8030 pointer a.k.a. the start of the 0x8032 pointer.

I was actually using abcde, but pretty much any program including Pointer Tables should work just as well here. For Pointer Tables, I gave it a try by splitting the script into 2 files and updating each file's header:and then the first 16 pointers + text
(note the lack of XOffset) and then the last 3 pointers + text. I get the exact same output ROM using either program, so use whichever one you want :beer:.

Sorry for the late reply. Very busy work week (a big reason I appreciate the help as I just don't have much spare time to just "figure it out on my own"). I still don't know what I'm doing wrong. I split the script at the right part and it still says I'm 1,492 bytes over the limit (inserting the second part is fine and well UNDER the limit). Loaded up the rom in FCEU and just get a blank screen.

What am I doing wrong?
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on September 30, 2018, 08:58:49 PM
Eh, no worries, we've all been there. It's important to remember this is just a hobby, not a full-time job.

As for the hack, there's a bunch of moving parts here, so it might help to isolate which step is going wrong. Starting from a clean ROM, try redoing each step and checking to make sure the game still works after each step is completed. You should be able to
1) expand the ROM file and update the iNES header
2) apply the DTE code changes
3) insert the script split across both banks; all the script from the original bank should display properly (including the "What luck!" when you open a treasure chest), but the code will still assume pointers to the script in the new bank are pointing to the old bank, so those will display incorrectly (including the King's opening speech when you start a new game)
4) apply the bank swaping code changes; I should have mentioned that those changes were for the PRG1 version, so if you're using the PRG0 version, you might need to adjust the addresses or the actual changes to match the differences between the two versions
5) apply any other changes you've made, e.g. item/spell/monster names, menus, graphics, etc.

For your DTE table, make sure the end tokens (FC/FF) stay as single bytes and don't get included in some DTE combination; the DTE patch only applies while reading the desired string, not while scanning through the group of strings to find the desired string. Also make sure your table file actually has the DTE entries - it sounds obvious, but forgetting to include those would be an explanation for why your script was still too large.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on September 30, 2018, 09:13:20 PM
Quote from: abw on September 30, 2018, 08:58:49 PM
Eh, no worries, we've all been there. It's important to remember this is just a hobby, not a full-time job.

As for the hack, there's a bunch of moving parts here, so it might help to isolate which step is going wrong. Starting from a clean ROM, try redoing each step and checking to make sure the game still works after each step is completed. You should be able to
1) expand the ROM file and update the iNES header
2) apply the DTE code changes
3) insert the script split across both banks; all the script from the original bank should display properly (including the "What luck!" when you open a treasure chest), but the code will still assume pointers to the script in the new bank are pointing to the old bank, so those will display incorrectly (including the King's opening speech when you start a new game)
4) apply the bank swaping code changes; I should have mentioned that those changes were for the PRG1 version, so if you're using the PRG0 version, you might need to adjust the addresses or the actual changes to match the differences between the two versions
5) apply any other changes you've made, e.g. item/spell/monster names, menus, graphics, etc.

For your DTE table, make sure the end tokens (FC/FF) stay as single bytes and don't get included in some DTE combination; the DTE patch only applies while reading the desired string, not while scanning through the group of strings to find the desired string. Also make sure your table file actually has the DTE entries - it sounds obvious, but forgetting to include those would be an explanation for why your script was still too large.

Okay, so I guess it's the first step messing me up.

I take a clean ROM, change x05 from 02 to 08. Using HxD, I go to address C010 and select Insert Bytes: Value= 10000. Save and test and I get a blank screen.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on September 30, 2018, 10:03:48 PM
Quote from: Choppasmith on September 30, 2018, 09:13:20 PM
change x05 from 02 to 08
:banghead: Sorry, that was my fault, butterfingers again - PRG size is byte 0x04 of the iNES header, not 0x05 (that's CHR size). I've updated my earlier post for posterity.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 02, 2018, 11:44:35 AM
Okay so I was able to expand the size of the rom and add the DTE patch and the ROM loaded just fine, but once I insert the script with pointer tables the big part script a, shows me that it's 1492 bytes OVER the text limit. I load the ROM up and get a blank screen.

For reference my two script files look like this at the beginning

Table Start: 8012
Table End: 8031
Text Start: 8038
Text End: BCBF
XOffset: 10

Table Type: 0
Text Type: 0
Custom PT: T0 T1

PT Line Command:
-----------------


and

Table Start: 8032
Table End: 8037
Text Start: C038
Text End: FCBF

Table Type: 0
Text Type: 0
Custom PT: T0 T1

PT Line Command:
-----------------


Either PT isn't "compressing the text" or I have another number off.


EDIT: Changing tracks a bit

Just for giggles I thought I'd make a DW1 title screen mockup in Photoshop to get a good idea of what changing Warrior into Quest would look like. PS can automatically center things and it looks like we'd just have to move everything one tile over for it to look centered (I'll probably just use the existing TM tiles)

(https://i.imgur.com/2TkTV31.png)

I'm not sure how the Dragon popping out of the logo would work if we do end up moving everything over a space. Your explanation for how the title screen works make sense to me, it's more the pixel editing that seems more daunting to me but I'd want to give it a try though.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on October 03, 2018, 05:33:04 PM
Alright, I tried this again from scratch using Pointer Tables and it does work for me, though I added 2 steps to the list:
2a) You'll also need to add the DTE entries to the ROM, not just your table file.
3a) Despite its name, Pointer Tables doesn't actually update any pointer tables, so you need to do that manually :'( (or switch to something else that will automatically update pointers for you, e.g. Atlas).

I compared Pointer Tables' output for a table with no DTE and a table with DTE. For the table with no DTE, I got a total length of 23764 (x5CD4), 8268 bytes over the original text limit, and for my table with DTE, I got a total length of 14619 (x391B), 877 bytes under the original text limit. So, maybe the problem is with the choice of DTE entries? Here's the full table I used:

00=0
01=1
02=2
03=3
04=4
05=5
06=6
07=7
08=8
09=9
0A=a
0B=b
0C=c
0D=d
0E=e
0F=f
10=g
11=h
12=i
13=j
14=k
15=l
16=m
17=n
18=o
19=p
1A=q
1B=r
1C=s
1D=t
1E=u
1F=v
20=w
21=x
22=y
23=z
24=A
25=B
26=C
27=D
28=E
29=F
2A=G
2B=H
2C=I
2D=J
2E=K
2F=L
30=M
31=N
32=O
33=P
34=Q
35=R
36=S
37=T
38=U
39=V
3A=W
3B=X
3C=Y
3D=Z
3E="
3F=""
40=}
41=*
44=:
45=_
47=.
48=,
49=-
4B=?
4C=!
4D=;
4E=)
4F=(
50={
52=.}
53='
54=`
57=[57]
5F=
60=[60]
EF=[S]
F0=[PNT]
F1=[ANME]
F3=[XP]
F4=[NME]
F5=[NUM]
F6=[SPL]
F7=[INV]
F8=[ME]
FB=@
FC=%
FD=&
FF=[ITM]

81= t
82=e
83=t
84=s
85=er
86=in
87=ou
88=y
89=,
8A=d
8B=an
8C=ar
8D=of
8E=he
8F=re
90=o
91=st
92=on
93=ha
94=th
95=en
96=or
97=ll
98=&@
99= m
9A=.}
9B=es
9C=om
9D=hi
9E= a
9F=Th
A0=gh
A1= s
A2=ri
A3=el
A4=ra
A5=ow
A6=!}
A7= w
A8=le
A9=la
AA= d
AB= b
AC=_.
AD=se
AE=it
AF= f
B0=!
B1=no
B2=un
B3=ch
B4=ea
B5=ed
B6=ur
B7=ol
B8=wa
B9= p
BA=de
BB=il
BC= c
BD=ce
BE=is
BF=?}
C0=at
C1=ck
C2=ak
C3=ve
C4=al
C5= h
C6=ay
C7=bl
C8=us
C9=.
CA=as
CB=g
CC=ld
CD={I
CE=oo
CF=ag
D0=fa
D1=me
D2=wi
D3=be
D4=ne
D5=os
D6= g
D7=ic
D8= i
D9=ev
DA={W
DB=ir
DC=id
DD=te
DE=?
DF=fr
E0=ru
E1=up
E2=am
E3=et
E4=ly
E5=qu
E6='t
E7=.@
E8=em
E9=li
EA=to
EB=we
EC=ey
ED=mi
EE=ro

I also made the unfortunate discovery that Pointer Tables will quite happily overwrite data beyond the Text End address, so you'll basically have to restart the entire build process from the beginning after every failed Pointer Tables insert :(.

Quote from: Choppasmith on October 02, 2018, 11:44:35 AM
Just for giggles I thought I'd make a DW1 title screen mockup in Photoshop to get a good idea of what changing Warrior into Quest would look like.
Nice! If you do need to shift the dragon (or the sparkle that flashes between the I and O of WARRIOR), it probably wouldn't be too much work, but I'd say to wait to cross that bridge until you get to it - the original placement might still work for the updated title.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 04, 2018, 03:03:53 PM
(https://i.imgur.com/3zqHjDO.png)

(https://media.giphy.com/media/GIEXgLDfghUSQ/giphy.gif)

(seriously I'm thrilled, things are finally falling into place and I couldn't be happier!)

Aside from the other bank. Just have to put my monster/item/spell name changes back in and we're pretty much good to go. I think your DTE entries were simply better than mine (I think I underestimated that period+end line or end quote + endline entries would probably not work right and focused solely on letters and that kept my size up)

So looking back, you said the newly added space used to be bank 3 and is now bank 7? Is that how I would calculate the pointers for the last few strings (using your little equation on the previous page)?
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on October 04, 2018, 05:13:40 PM
:woot!: :woot!: :woot!:

Yeah, based on DTE-Opt's description, it looks like it ignores everything besides [A-Za-z], which means you lose out on 7 of the best 10 combos in your script, among other things. For reference, I generated my list using ScriptCrunch (http://www.romhacking.net/utilities/405/). Based on the way the game counts strings, you can get away with including end-of-line in your DTE table, but not end-of-string.

For the monster/item/spell name changes, you can insert those normally, just remember that Psyklax's patch puts the DTE code starting at 0x7EB0, a.k.a. immediately after the end of the original spell list, so if your total monster/item/spell list is longer than the original, you'll need to adjust the DTE patch to compensate.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 05, 2018, 01:22:35 AM
Quote from: abw on October 04, 2018, 05:13:40 PM
:woot!: :woot!: :woot!:

Yeah, based on DTE-Opt's description, it looks like it ignores everything besides [A-Za-z], which means you lose out on 7 of the best 10 combos in your script, among other things. For reference, I generated my list using ScriptCrunch (http://www.romhacking.net/utilities/405/). Based on the way the game counts strings, you can get away with including end-of-line in your DTE table, but not end-of-string.

For the monster/item/spell name changes, you can insert those normally, just remember that Psyklax's patch puts the DTE code starting at 0x7EB0, a.k.a. immediately after the end of the original spell list, so if your total monster/item/spell list is longer than the original, you'll need to adjust the DTE patch to compensate.

Oh, I didn't realize the DTE code was in all that extra space after those. That might be tricky. Will compression work for those? Otherwise, I wonder if we could move the DTE code and entries to,all that new free space added.

Also how do I add the pointers for the rest of the dialog? I know for the first, big part you take the address, subtract 10 and then reverse the bytes, but is the math different because the text is in a completely different area?
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Psyklax on October 05, 2018, 06:32:15 AM
Sorry, I tuned out of the thread a bit, but yes, my DTE patch goes directly after the item list because there isn't much space elsewhere. If you're expanding the ROM, though, I'd question the need to even use DTE. But again, maybe I missed something...
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 05, 2018, 09:50:32 AM
Quote from: Psyklax on October 05, 2018, 06:32:15 AM
Sorry, I tuned out of the thread a bit, but yes, my DTE patch goes directly after the item list because there isn't much space elsewhere. If you're expanding the ROM, though, I'd question the need to even use DTE. But again, maybe I missed something...

Well unless I'm missing something, my script is 30k, we added 10k to the rom, the existing space for the script is 15k so we still wouldn't be able to fit it in. Only thing I could think of is moving the item/spell/monster list to the new area.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on October 05, 2018, 04:34:01 PM
I'm just about to run out the door here, so apologies for the brevity:

Quote from: Choppasmith on October 05, 2018, 01:22:35 AM
Oh, I didn't realize the DTE code was in all that extra space after those. That might be tricky. Will compression work for those? Otherwise, I wonder if we could move the DTE code and entries to,all that new free space added.
The code for printing out the monster/item/spell names doesn't run through the DTE code, so you'd have to make some further ASM changes to add DTE to those.

Quote from: Choppasmith on October 05, 2018, 01:22:35 AM
Also how do I add the pointers for the rest of the dialog? I know for the first, big part you take the address, subtract 10 and then reverse the bytes, but is the math different because the text is in a completely different area?
$4010 is the offset you're looking for. The first pointer in the extra bank should start at RAM $8028 (28 80).

Quote from: Psyklax on October 05, 2018, 06:32:15 AM
If you're expanding the ROM, though, I'd question the need to even use DTE. But again, maybe I missed something...
Yeah, with all the extra space DTE shouldn't be necessary, unless you care about patch size. If you aren't splitting the script based on the high byte of the pointer number, the ASM for remembering which pointer the game wanted and for deciding which bank to read from will both need tweaking. I haven't tried it, but something like this might work:

0x7544
4A      LSR
4A      LSR
4A      LSR
4A      LSR
85 1B    STA $1B
8A      TXA
0A      ASL
0A      ASL
0A      ASL
0A      ASL
65 1B    ADC $1B
18      CLC
69 01    ADC #$01
85 31    STA $31
85 E1    STA $E1

0x1FF64:
LDA $E1
CMP #$09
LDA #$02
BCS +
LDA #$03
+:
LDX #$9F
RTS


Quote from: Choppasmith on October 05, 2018, 09:50:32 AM
we added 10k to the rom
We added $10000 (hexadecimal) to the ROM, not 10000 (decimal) - that's 65,536 bytes a.k.a. 64 KB :P.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 08, 2018, 07:53:20 AM
Quote from: abw on October 05, 2018, 04:34:01 PM
I'm just about to run out the door here, so apologies for the brevity:
The code for printing out the monster/item/spell names doesn't run through the DTE code, so you'd have to make some further ASM changes to add DTE to those.
$4010 is the offset you're looking for. The first pointer in the extra bank should start at RAM $8028 (28 80).

Thanks for this. I did a double take because it's so close to the first dialog pointer, I thought maybe you were mistaken.

In any case worked great. I found at least one mismatched npc line so far, so I'll have to go over my script and make sure my formatting is right.

Quote from: abw on October 05, 2018, 04:34:01 PMIf you aren't splitting the script based on the high byte of the pointer number, the ASM for remembering which pointer the game wanted and for deciding which bank to read from will both need tweaking. I haven't tried it, but something like this might work:

0x7544
4A      LSR
4A      LSR
4A      LSR
4A      LSR
85 1B    STA $1B
8A      TXA
0A      ASL
0A      ASL
0A      ASL
0A      ASL
65 1B    ADC $1B
18      CLC
69 01    ADC #$01
85 31    STA $31
85 E1    STA $E1

0x1FF64:
LDA $E1
CMP #$09
LDA #$02
BCS +
LDA #$03
+:
LDX #$9F
RTS


So is this basically a revision of your code posted earlier in the thread?

Quote from: abw on October 05, 2018, 04:34:01 PM
We added $10000 (hexadecimal) to the ROM, not 10000 (decimal) - that's 65,536 bytes a.k.a. 64 KB :P.

Oof, my bad.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on October 08, 2018, 04:29:38 PM
Quote from: Choppasmith on October 08, 2018, 07:53:20 AM
Thanks for this. I did a double take because it's so close to the first dialog pointer, I thought maybe you were mistaken.
Probably it would make more sense to change the Text Start for the second bank to C010 (no need to waste the first $28 bytes) and then the first pointer into that bank would be to RAM $8000.

Quote from: Choppasmith on October 08, 2018, 07:53:20 AM
So is this basically a revision of your code posted earlier in the thread?
Basically, but it only replaces some of the earlier code and wasn't quite working. Here's a complete version that should actually work; note that without the DTE, you'll need to insert the text for the first 9 pointers into the original bank and the text for the last 10 pointers into the new bank.

0x7544 (remember pointer number so we can use it later):

4A        LSR
4A        LSR
4A        LSR
4A        LSR
85 1B     STA $1B
8A        TXA
0A        ASL
0A        ASL
0A        ASL
0A        ASL
65 1B     ADC $1B
18        CLC
69 01     ADC #$01
85 31     STA $31
85 E1     STA $E1


0x756C and 0x7689 (JSR to code to decide which bank to read from):

EA        NOP
20 54 FF  JSR $FF54


0x1FF64 (read from expanded ROM bank when pointer number >= #$0A; requires splitting script at the start of the 10th pointer):

A5 E1     LDA $E1
C9 0A     CMP #$0A
A9 02     LDA #$02
90 02     BCC $FF5E
A9 03     LDA #$03
A2 9F     LDX #$9F
60        RTS


Quote from: Choppasmith on October 08, 2018, 07:53:20 AM
Oof, my bad.
No problem, it's a mistake I've been guilty of making on more than one occasion :P.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 09, 2018, 11:59:03 AM
Quote from: abw on October 08, 2018, 04:29:38 PM

0x7544 (remember pointer number so we can use it later):

4A        LSR
4A        LSR
4A        LSR
4A        LSR
85 1B     STA $1B
8A        TXA
0A        ASL
0A        ASL
0A        ASL
0A        ASL
65 1B     ADC $1B
18        CLC
69 01     ADC #$01
85 31     STA $31
85 E1     STA $E1



Just to be sure, are you certain this isn't 7546? Because that's where your original code started?

EDIT: Thought I'd just start fresh. Not sure what happened but I got some wildly mixed up dialog (second part of the script, second bank)

(https://i.imgur.com/eahYLWf.png)

Also, this should be one of the lines from the first script in the old bank

(https://i.imgur.com/7eDuLl3.png)

EDIT 2: Yep seems to be a pointer mixup. Fixing now.

EDIT 3: A few pointers needed to be corrected, but it seems it's just not loading from the second bank. The king's speech is from text from the first bank. Stuff actually from the first bank is loading fine now.

Here's how my current hex values looks

(https://i.imgur.com/QiMdv2N.png)

(https://i.imgur.com/TrEM8Ox.png)
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on October 09, 2018, 07:22:06 PM
Quote from: Choppasmith on October 09, 2018, 11:59:03 AM
Just to be sure, are you certain this isn't 7546? Because that's where your original code started?
Yup, 0x7544, same as before. Basically I'm just stealing the two bytes from the useless AND #$F0 and using them after the STA $31 (or after the ADC #$01 would have the same effect but make a smaller patch), which meant shifting all the intervening code up by two bytes.

Quote from: Choppasmith on October 09, 2018, 11:59:03 AM
Here's how my current hex values looks [...]

(https://i.imgur.com/TrEM8Ox.png)
0x1FF66 should be C9 (CMP immediate), not 69 (ADC immediate), which would definitely prevent text from the second bank from loading.

(*feels better about not being the only one who makes typos* :D)
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 10, 2018, 06:04:47 PM
Yeah I find I make some really baffling typos too. When correcting my pointers I had that was supposed to be something E8 and I had EA (because I guess in my brain, 8 and A sound the same??)

I was JUST about to post another troubled screen and found I had just messed up on a pointer in a similar way.

At this point I'm mostly done! Like you said earlier in this thread there might be some dialog that might need/not need a line break. But otherwise things are looking good! Thank you so much for your help!

A couple more things though, if you'll humor me.

The menu needs a couple tweaks. Namely, I'd like to change Defense into Defence (British Spelling) and just for completion's sake change LV into Lv (like the mobile port). But that's easy peasy considering it's just one letter. What might be hard is ADDING the u to Armor on the menu screen. I looked in the Spanish translation and you provided pointers and how each menu item seems to have a special string of code affecting window size and such, but it looks like there's no EXTRA space in that section. I COULD shorten ATTACK POWER AND DEFENSE POWER removing the latter POWER (Which would be accurate to the mobile port anyway) but that would leave up a lot of space and I don't see how each string "ends". What should I do here?

The other thing is just because I'm curious. COULD there be a way we can get the full name of the spell "Holy Protection" on the menu? I just have it as "Protect" right now with the wearing off message referring to the full name. I just wonder if we could either:

-Widen the menu to fit it.
-Keep it abbreviated on the menu but would show up in full when cast ("Hero casts Holy Protection!").
-Have it use two lines on the menu

Now this isn't a big deal, I have absolutely no qualms keeping it as is. I just thought I'd ask because you know your stuff :)

Lastly, I've taken a stab at using YY CHR to try and get my new logo in (well changing QUEST into WARRIOR anyway). I setup a custom pattern to have all the logo tiles arranged together. I have the W setup like this

12
34

For some weird reason, it won't let me edit tile number 4 in this case. It just reverts back instantly after clicking. Any idea what I'm doing wrong? 
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on October 10, 2018, 11:58:21 PM
Quote from: Choppasmith on October 10, 2018, 06:04:47 PM
At this point I'm mostly done! Like you said earlier in this thread there might be some dialog that might need/not need a line break. But otherwise things are looking good! Thank you so much for your help!
Hurray! It's more fun when there are more people working on related projects for the same game, right?

Quote from: Choppasmith on October 10, 2018, 06:04:47 PM
What might be hard is ADDING the u to Armor on the menu screen. I looked in the Spanish translation and you provided pointers and how each menu item seems to have a special string of code affecting window size and such, but it looks like there's no EXTRA space in that section. I COULD shorten ATTACK POWER AND DEFENSE POWER removing the latter POWER (Which would be accurate to the mobile port anyway) but that would leave up a lot of space and I don't see how each string "ends". What should I do here?
I put a couple of notes about this on the wiki (https://datacrystal.romhacking.net/wiki/Dragon_Warrior:ROM_map#Menu_Format) for reference. Basically, each of the menu strings ends once the menu has read enough data to fill the available space, where the amount of available space is determined by the first 3 bytes of the menu string. Try messing around with a menu for a bit and you should get the hang of it pretty quickly.

The existing menu data is indeed pretty tight on free space, and it's sandwiched between the menu pointer table and some ASM. If you wanted to remove the POWERs, that would definitely give you more than enough space to add one letter. Otherwise, probably the next best place to steal space from is the message speed menu; if you switch it from single-spaced to double-spaced, you can free up 6 newline bytes and the only visible difference is the text shifting down one line:


#W16($6F94)
<$81><$07><$12><$74><$00><$86>
[border newline]
Which Message[newline]
Speed Do You[newline]
Want To Use?[newline]
      FAST[newline]
      NORMAL[newline]
      SLOW[newline]


Quote from: Choppasmith on October 10, 2018, 06:04:47 PM
The other thing is just because I'm curious. COULD there be a way we can get the full name of the spell "Holy Protection" on the menu? I just have it as "Protect" right now with the wearing off message referring to the full name. I just wonder if we could either:

-Widen the menu to fit it.
-Keep it abbreviated on the menu but would show up in full when cast ("Hero casts Holy Protection!").
-Have it use two lines on the menu
The item and spell menus are a bit special in that their contents are dynamically generated, so there'd be some further changes required in order to get everything working properly. I haven't really looked at that part of the code before, so I'm not sure how hard the changes would be, but probably any of these options is achievable.



Edit:
Whichever option you decide to go with, you're going to want to display the full spell name when casting it. As it turns out, the upper limit on the number of bytes to display for spell names is set at 0x77E9, so if you change that from #$09 (length of "STOPSPELL") to #$0F (length of "Holy Protection"), that's one step down. Showing "Holy Prot" in the menu and "Holy Protection" in the dialogue isn't such a horrible effect and is pretty good value for a 1-byte hack.

If you want to expand the spell menu to fit all of "Holy Protection" on one line, setting the menu width to $12 and changing its position to $26 makes it big enough to hold 15-tile spell names, and then changing 0x648B from #$09 to #$0F fixes up the text alignment issues that would otherwise result. Unfortunately, monster sprites show up in front of the spell menu, so it looks kind of bad in battle. I have a feeling it would take a lot of work to fix that without affecting the final boss fight, but maybe I'm wrong.

I like the idea of displaying the spell names on two lines like the item names; you'd only need to widen the spell menu by 2 tiles, which shouldn't interfere with regular battles. You'd lose visibility of some letters during the final battle, but I don't know whether that's a good thing or a bad thing. You can probably leverage a lot of the code for displaying the item list, but if you replicate the structure of the item list, there's going to be enough things shifting places that I think you'll want to switch to working with a fully labelled disassembly rather than making small patches like we have been.



Quote from: Choppasmith on October 10, 2018, 06:04:47 PM
For some weird reason, [YY-CHR] won't let me edit tile number 4 in this case. It just reverts back instantly after clicking. Any idea what I'm doing wrong?
That's just plain weird and I have no help to offer here :P.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 19, 2018, 11:04:26 PM
Quote from: abw on October 10, 2018, 11:58:21 PM
Hurray! It's more fun when there are more people working on related projects for the same game, right?

Absolutely! It's great everything just happened to come together when it did. This is shaping up to be better than I hoped for!

Also. Title screen! My first one ever, so I'm happy with it! Ended up using Tile Molester instead. Worked much better for me.

(https://i.imgur.com/GvPRw5e.png)

Quote from: abw on October 10, 2018, 11:58:21 PM
Edit:
Whichever option you decide to go with, you're going to want to display the full spell name when casting it. As it turns out, the upper limit on the number of bytes to display for spell names is set at 0x77E9, so if you change that from #$09 (length of "STOPSPELL") to #$0F (length of "Holy Protection"), that's one step down. Showing "Holy Prot" in the menu and "Holy Protection" in the dialogue isn't such a horrible effect and is pretty good value for a 1-byte hack.

If you want to expand the spell menu to fit all of "Holy Protection" on one line, setting the menu width to $12 and changing its position to $26 makes it big enough to hold 15-tile spell names, and then changing 0x648B from #$09 to #$0F fixes up the text alignment issues that would otherwise result. Unfortunately, monster sprites show up in front of the spell menu, so it looks kind of bad in battle. I have a feeling it would take a lot of work to fix that without affecting the final boss fight, but maybe I'm wrong.

I like the idea of displaying the spell names on two lines like the item names; you'd only need to widen the spell menu by 2 tiles, which shouldn't interfere with regular battles. You'd lose visibility of some letters during the final battle, but I don't know whether that's a good thing or a bad thing. You can probably leverage a lot of the code for displaying the item list, but if you replicate the structure of the item list, there's going to be enough things shifting places that I think you'll want to switch to working with a fully labelled disassembly rather than making small patches like we have been.

Since I'm hoping this thread can serve as a resource for future DW hacks, would you mind giving me a quick rundown as to how you find these values? Namely stuff like Spell and Monster Name length? When I get to DW2 and 3, I'd love to be able to find simple values like that myself as to save a little time and trouble from the more adept romhackers such as yourself.

Okay almost there! SO CLOSE!

I wanted to do a quick little Title Screen text change. Add a 2018 Square Enix credit (it IS their translation technically speaking and it gives it a nice "Official" feel which is what I'm going for with this hack). But also change the Nintendo license line to Hack by Choppasmith and drop the trademark line for space. I saw in the translation thread there's basically no room before the palette data. I was really careful to make sure I dumped and edited the text before 3FC5. But I can't seem to avoid glitches

(https://i.imgur.com/Co0QWzi.png)

It might be Pointer Tables doing, but I can't see anything "wrong" here:

(https://i.imgur.com/NgLjV38.png)

Unaltered on the left, altered on the right.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on October 20, 2018, 03:38:15 PM
Quote from: Choppasmith on October 19, 2018, 11:04:26 PM
Also. Title screen! My first one ever, so I'm happy with it! Ended up using Tile Molester instead. Worked much better for me.

(https://i.imgur.com/GvPRw5e.png)
Looking good! :beer:

Quote from: Choppasmith on October 19, 2018, 11:04:26 PM
Since I'm hoping this thread can serve as a resource for future DW hacks, would you mind giving me a quick rundown as to how you find these values? Namely stuff like Spell and Monster Name length? When I get to DW2 and 3, I'd love to be able to find simple values like that myself as to save a little time and trouble from the more adept romhackers such as yourself.
FCEUX's Debugger and/or Trace Logger tells all :P. I wrote up a description of tracking down the item list and its pointer in the Dragon Warrior 1 Spanish Translation (http://www.romhacking.net/forum/index.php?topic=26135.msg358879#msg358879) thread; the same principles apply here, but since we already know where the spell list is located, we can start with a read breakpoint there and skip the whole "trace from the PPU back to the ROM" process. For the spell list length, setting a read breakpoint on e.g. $BE56 for HEAL and then casting that spell shows

01:A866:A0 00     LDY #$00
01:A868:AE E2 64  LDX $64E2 = #$09
>01:A86B:B1 A1     LDA ($A1),Y @ $BE56 = #$2B
01:A86D:C9 FF     CMP #$FF
01:A86F:F0 07     BEQ $A878
01:A871:9D C9 64  STA $64C9,X @ $64D2 = #$5F
01:A874:C8        INY
01:A875:CA        DEX
01:A876:D0 F3     BNE $A86B
01:A878:60        RTS -----------------------------------------

so the game stops reading from ($A1),Y once it reads #$FF (end of list item) or when X reaches #$00; X comes from $64E2, so setting a write breakpoint there and casting the spell again eventually leads us to

01:B7D8:A9 09     LDA #$09
>01:B7DA:8D E2 64  STA $64E2 = #$01

as the last time the game writes to $64E2 before reading the spell name. The game actually uses $64E2 for a lot of other things before it gets to reading the spell name, so you can either throw in some "Forbid" breakpoints to weed out false positives or generate a trace log and start searching backwards. You can follow the same process when tracking down pretty much anything, although it gets harder to do when the way in which the game's code uses the data is complicated.

Quote from: Choppasmith on October 19, 2018, 11:04:26 PM
I wanted to do a quick little Title Screen text change. Add a 2018 Square Enix credit (it IS their translation technically speaking and it gives it a nice "Official" feel which is what I'm going for with this hack). But also change the Nintendo license line to Hack by Choppasmith and drop the trademark line for space. I saw in the translation thread there's basically no room before the palette data. I was really careful to make sure I dumped and edited the text before 3FC5. But I can't seem to avoid glitches
It looks like there is a bit of free space immediately following the end of the title screen data at 0x3DFA, so you could use that if you wanted to, but the original data is also kind of inefficient, so you could free up an extra $44 bytes by combining adjacent RLEs of the same byte (e.g. the original has <$F7><$20><$5F><$FC> immediately followed by <$F7><$20><$5F><$FC>, but <$F7><$40><$5F><$FC> does the exact same thing [i.e. print two rows of spaces] in 4 fewer bytes) and taking out all of the useless <$FC> control codes (the last <$FC> is the only one that matters). 68 bytes is more than enough space for a couple of text changes on this screen even without dropping the "TM TRADEMARK TO NINTENDO".

The title screen display code basically works by reading a continuous stream of bytes starting from RAM $BDCB (ROM 0x3DDB), expanding RLE sequences (control code <$F7>) as necessary, and writing them to the PPU starting from $2000 (Name Table #0; tilemap data) until it reaches PPU $2400 (Name Table #1); along the way, it'll also fill up Attribute Table #0 (palette data) starting at PPU $23C0. Control code <$FC> is a "maybe end" token - it checks to see whether the next PPU address to write to is $24?? and exits the title screen display code when it is, otherwise it does nothing. So there's nothing special about 0x3FC5, that's just the point where the PPU writing process happens to reach PPU $23C0.

Each screen line is 32 tiles wide, but on the "HACK BY CHOPPASMITH" line, you're writing 6 spaces + 19 letters + 11 spaces = 36 tiles, which is 4 tiles too many, so try reducing 0x3F9D from $0B to $07. Where things really start going sideways, though, is 0x3FAE. At that point you write the final (off-screen, but you can see it in FCEUX's Name Table Viewer) row of tilemap data using $FF (one of the Dragonlord's tiles) instead of $5F (space) and then start writing a bunch of $FFs to the palette data. You should have a mostly pink screen at that point, but your screenshot shows a bunch of splotches, so something else is going on somewhere. I'd recommend grabbing my title screen insert script from the Dragon Warrior 1 Spanish Translation (http://www.romhacking.net/forum/index.php?topic=26135.msg360842#msg360842) thread and either adapting that to Pointer Tables or switch to Atlas for inserting; if you use Atlas, you'll need to tell it what table file to use with e.g.

#VAR(Table, TABLE)
#ADDTBL("dw.tbl", Table)
#ACTIVETBL(Table)
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: Choppasmith on October 20, 2018, 11:30:43 PM
Quote from: abw on October 20, 2018, 03:38:15 PM
Looking good! :beer:
FCEUX's Debugger and/or Trace Logger tells all :P. I wrote up a description of tracking down the item list and its pointer in the Dragon Warrior 1 Spanish Translation (http://www.romhacking.net/forum/index.php?topic=26135.msg358879#msg358879) thread; the same principles apply here, but since we already know where the spell list is located, we can start with a read breakpoint there and skip the whole "trace from the PPU back to the ROM" process. For the spell list length, setting a read breakpoint on e.g. $B5E6 for HEAL and then casting that spell shows

01:A866:A0 00     LDY #$00
01:A868:AE E2 64  LDX $64E2 = #$09
>01:A86B:B1 A1     LDA ($A1),Y @ $BE56 = #$2B
01:A86D:C9 FF     CMP #$FF
01:A86F:F0 07     BEQ $A878
01:A871:9D C9 64  STA $64C9,X @ $64D2 = #$5F
01:A874:C8        INY
01:A875:CA        DEX
01:A876:D0 F3     BNE $A86B
01:A878:60        RTS -----------------------------------------

so the game stops reading from ($A1),Y once it reads #$FF (end of list item) or when X reaches #$00; X comes from $64E2, so setting a write breakpoint there and casting the spell again eventually leads us to

01:B7D8:A9 09     LDA #$09
>01:B7DA:8D E2 64  STA $64E2 = #$01

as the last time the game writes to $64E2 before reading the spell name. The game actually uses $64E2 for a lot of other things before it gets to reading the spell name, so you can either throw in some "Forbid" breakpoints to weed out false positives or generate a trace log and start searching backwards. You can follow the same process when tracking down pretty much anything, although it gets harder to do when the way in which the game's code uses the data is complicated.
It looks like there is a bit of free space immediately following the end of the title screen data at 0x3DFA, so you could use that if you wanted to, but the original data is also kind of inefficient, so you could free up an extra $44 bytes by combining adjacent RLEs of the same byte (e.g. the original has <$F7><$20><$5F><$FC> immediately followed by <$F7><$20><$5F><$FC>, but <$F7><$40><$5F><$FC> does the exact same thing [i.e. print two rows of spaces] in 4 fewer bytes) and taking out all of the useless <$FC> control codes (the last <$FC> is the only one that matters). 68 bytes is more than enough space for a couple of text changes on this screen even without dropping the "TM TRADEMARK TO NINTENDO".

The title screen display code basically works by reading a continuous stream of bytes starting from RAM $BDCB (ROM 0x3DDB), expanding RLE sequences (control code <$F7>) as necessary, and writing them to the PPU starting from $2000 (Name Table #0; tilemap data) until it reaches PPU $2400 (Name Table #1); along the way, it'll also fill up Attribute Table #0 (palette data) starting at PPU $23C0. Control code <$FC> is a "maybe end" token - it checks to see whether the next PPU address to write to is $24?? and exits the title screen display code when it is, otherwise it does nothing. So there's nothing special about 0x3FC5, that's just the point where the PPU writing process happens to reach PPU $23C0.

Each screen line is 32 tiles wide, but on the "HACK BY CHOPPASMITH" line, you're writing 6 spaces + 19 letters + 11 spaces = 36 tiles, which is 4 tiles too many, so try reducing 0x3F9D from $0B to $07. Where things really start going sideways, though, is 0x3FAE. At that point you write the final (off-screen, but you can see it in FCEUX's Name Table Viewer) row of tilemap data using $FF (one of the Dragonlord's tiles) instead of $5F (space) and then start writing a bunch of $FFs to the palette data. You should have a mostly pink screen at that point, but your screenshot shows a bunch of splotches, so something else is going on somewhere. I'd recommend grabbing my title screen insert script from the Dragon Warrior 1 Spanish Translation (http://www.romhacking.net/forum/index.php?topic=26135.msg360842#msg360842) thread and either adapting that to Pointer Tables or switch to Atlas for inserting; if you use Atlas, you'll need to tell it what table file to use with e.g.

#VAR(Table, TABLE)
#ADDTBL("dw.tbl", Table)
#ACTIVETBL(Table)


Thank you so much for the explanation  :beer:. A quick question about menu windows. So I see that there are a few bytes before the text for each window and these affect the sizing and such. For example with the main field menu you have these bytes appearing before COMMAND

05 10 16 08 21 8B

I know the 10 here is window width, 16 is the X position of the window, and 21 is cursor position. I wanted to try to to make the window one more space wider to try and add an S to SPELL (SPELLS). But when I try and do that the little corner graphic gets moved to the next line and messes up the whole window. Any idea what I'm doing wrong here?

Also I ended up using your script with Atlas, I got it to where it's 4 bytes under the limit, but, I'm still getting a little glitch.

(https://i.imgur.com/uyEHtCq.png)

That's certainly closer than I was before.

I thought I'd try making everything from 3FB0 to 4010 match up with the original. Thinking maybe it really is picky on size or something, but that seemed to just make it worse.

(https://i.imgur.com/VSfx63N.png)

It may not look all that different but FCEU started stuttering once this loaded, but when I switched to a different ROM it was fine again.

For reference, here's how I used your Atlas Script

#VAR(Table, TABLE)
#ADDTBL("dw.tbl", Table)
#ACTIVETBL(Table)





#JMP($3DDC, $3FD9)
// Title Screen data starts being written to PPU $2000.
// Control code F7 takes 2 bytes (A, B) as parameters and means "write byte B A times" so e.g. F7 04 5F results in 5F 5F 5F 5F being written to the PPU; it's a simple RLE compression.
// Control code FC does nothing useful until we reach PPU $2400, at which point it signals the end of the title screen data; as such, only the final FC actually matters.
// There are also some other inefficiencies in the original data that you can take advantage of if you need more space for text.

// 4 rows of spaces
<$F7><$80><$5F><$FC>
// 1 row of spaces
<$F7><$20><$5F><$FC>
// top border
<$F7><$20><$AD><$FC>
// speckled background
<$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$FC>
<$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$FC>
<$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$FC>
<$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$FC>

// speckled background with DRAGON WARRIOR graphics
<$A9><$AA><$A9><$74><$75><$76><$77><$78><$79><$7A><$7B><$7C><$7D><$7E><$7F><$80><$81><$82><$83><$84><$85><$86><$85><$86><$87><$88><$89><$8A><$8B><$8C><$A9><$AA><$FC>
<$AB><$AC><$AB><$8D><$8E><$8F><$90><$91><$92><$93><$94><$95><$96><$97><$98><$99><$9A><$9B><$9C><$9D><$9E><$9F><$9E><$9F><$A0><$A1><$A2><$A3><$AB><$AC><$AB><$AC><$FC>
<$A9><$AA><$A9><$AA><$A9><$AA><$A4><$A5><$A9><$A6><$A7><$AA><$A9><$AA><$A9><$AA><$A9><$A8><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$FC>

// speckled background
<$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$FC>
<$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$A9><$AA><$FC>
<$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$AB><$AC><$FC>
// bottom border
<$F7><$20><$AE><$FC>
// 2 rows of spaces
<$F7><$40><$5F><$FC>

// 63=-
<$F7><$0A><$5F><$63>PUSH START<$63><$F7><$0A><$5F><$FC>
// 1 row of spaces
<$F7><$20><$5F><$FC>
// 62=<copyright symbol>
<$F7><$0B><$5F><$62>1986 ENIX<$F7><$0B><$5F><$FC>
// 1 row of spaces
<$F7><$20><$5F><$FC>
<$F7><$0B><$5F><$62>2018 SQUARE ENIX<$F7><$05><$5F><$FC>
// 1 row of spaces
<$F7><$20><$5F><$FC>
<$F7><$06><$5F>HACK BY CHOPPASMITH<$F7><$07><$5F><$FC>
// 1 row of spaces
<$F7><$20><$5F><$FC>
<$F7><$04><$5F>TRADEMARK OF NINTENDO<$F7><$07><$5F><$FC>
// 2 rowS of spaces
<$F7><$40><$5F><$FC>

// At this point we've reached PPU $23C0, so this is palette data instead of tilemap data
<$F7><$08><$FF>
<$F7><$08><$05>
<$F7><$10><$00><$FC>
<$F7><$08><$A5>
<$F7><$08><$FF><$FC>
<$F7><$10><$FF><$FC>
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: KingMike on October 21, 2018, 02:41:07 AM
I think you have messed up your tile count somewhere, as that looks like AT data is written at the wrong spot, possibly one of your tile counts was off by 1, seeing as the AT corruption seems to be one byte (covering a 32x32 pixel region) off.

Not sure if you're remembering that the blank left side of the screen still needs one tile printed underneath the blanking counted for.
Title: Re: Help editing Item Names (and other text) in Dragon Warrior (NES)
Post by: abw on October 21, 2018, 11:43:12 AM
Quote from: Choppasmith on October 20, 2018, 11:30:43 PM
A quick question about menu windows.
I put a couple of notes about this on the wiki (http://datacrystal.romhacking.net/wiki/Dragon_Warrior:ROM_map#Menu_Format) for reference. The data for the main COMMAND menu actually starts one byte earlier:

#W16($6F82)
// menu setup parameters:
// 80 = has a cursor, double spaced
// 05 = 5 (double-spaced) lines tall
// 10 = 16 tiles wide
// 16 = top-left corner at (12, 2)
// 08 = second column cursor offset is left edge of menu + 8
// 21 = cursor starts at top-left corner of menu + (1, 2)
<$80><$05><$10><$16><$08><$21>
<$8B>COMMAND<$88>
<$81>TALK<$84>SPELL
<$81>STATUS<$82>ITEM<$80>
<$81>STAIRS<$82>DOOR<$80>
<$81>SEARCH<$82>TAKE<$80>

As you've observed, the game really doesn't like odd-width menus, so you'll have to expand its width by 2 and then fix up the spacing of its contents to match the new width.

Quote from: Choppasmith on October 20, 2018, 11:30:43 PM
Also I ended up using your script with Atlas, I got it to where it's 4 bytes under the limit, but, I'm still getting a little glitch.
Quote from: KingMike on October 21, 2018, 02:41:07 AM
I think you have messed up your tile count somewhere, as that looks like AT data is written at the wrong spot, possibly one of your tile counts was off by 1, seeing as the AT corruption seems to be one byte (covering a 32x32 pixel region) off.
Yup, KingMike called it - the "©2018 SQUARE ENIX" line prints 33 tiles instead of 32, so all the palette data gets shifted by 1 byte. Try <$F7><$0B><$5F><$62>2018 SQUARE ENIX<$F7><$04><$5F><$FC> instead, and then probably adjust the centering of the "TRADEMARK OF NINTENDO" line.