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

Author Topic: Dragon Warrior 1, 2 & 3 Hacking Discussion  (Read 148953 times)

abw

  • Hero Member
  • *****
  • Posts: 554
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #240 on: July 24, 2020, 08:43:10 am »
After having just "optimized" my dictionary, entirely pleased with myself for freeing up 50 characters, now I'm here pulling my jaw up off the floor.

You have clearly bound your soul to a demon in exchange for these powers.
Despite what some people might claim it stands for, CS really means Computer Sorcery :P

So I implemented your patch that fixes indenting. I inserted the $60 byte after the line before each new speaker I want indented correctly. In all cases but one, it's working fine. For this princess line, it for some reason isn't indenting her saying the word "father!". Can't figure this out.
My first guess would be that it has to do with that line of text taking up exactly 1 line of the window. It should fit without wrapping, but probably the extra [60] isn't considered whitespace and is preventing that. Try moving the [60] around a bit, taking it out, or adding a regular space before it; if none of that works, changing the length of the line by even 1 tile should also do the trick.

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #241 on: July 24, 2020, 10:19:42 am »
So I did my best to follow along with your debugger notes. I gained some helpful familiarity with the process of searching through trace logger data. Did I follow all your logic? Not even close. I'd probably need a more real-time interactive form of communication than forum posting for that, where I could ask questions and clear up my confusion on each step in your thought process. But there is research I can do on my own which can potentially help with this kind of thing.

In spite of not following all the logic, I made the change of 07 to 06 as you suggested after locating that sequence at rom address 0x042BE. It shifted the indent as you suggested. Yay! But, it's still chopping off the 11th character of "Destruction", and was probably programmed to do so so that the "n" wouldn't overwrite the right border. It would seem that there is another step involved in fixing this.



July 24, 2020, 10:42:11 am - (Auto Merged - Double Posts are not allowed before 7 days.)
I took your suggestion of playing around with the [60] for that princess line. Yes, it does seem that that specific line length creates a problem with your patch.

Princess:[ ‘]But father![' ][60][wait][line] was the initial format causing the problem.

I moved the byte to:

Princess:[ ‘]But father![' ][wait][line][60] and got this:



Not any better. So then, I tried this:

Princess:[ ‘]But father![' ][wait][60][line] and got this:



Probably the best result so far but it adds an extra line of spacing. I'm not exceptionally fond of inconsistent line spacing. Last, I tried:

Princess:[ ‘]But father![' ][wait][60] but it produced this result again:



I don't love the idea of changing the "But father!" text and might prefer to live with the extra spacer line. Will have to think on it. The line length is part of the text engine, and it would probably be pretty hard to change it in this case without changing it universally. Hmmm...
« Last Edit: July 24, 2020, 10:46:02 am by Chicken Knife »

abw

  • Hero Member
  • *****
  • Posts: 554
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #242 on: July 24, 2020, 08:46:58 pm »
So I did my best to follow along with your debugger notes. I gained some helpful familiarity with the process of searching through trace logger data. Did I follow all your logic? Not even close. I'd probably need a more real-time interactive form of communication than forum posting for that, where I could ask questions and clear up my confusion on each step in your thought process. But there is research I can do on my own which can potentially help with this kind of thing.
No worries - the more you use it the better you'll get!

In spite of not following all the logic, I made the change of 07 to 06 as you suggested after locating that sequence at rom address 0x042BE. It shifted the indent as you suggested. Yay! But, it's still chopping off the 11th character of "Destruction", and was probably programmed to do so so that the "n" wouldn't overwrite the right border. It would seem that there is another step involved in fixing this.
Yay! But yes, it does look like there's a maximum length being set somewhere else that would have to be updated too. The good news is that that length will be set somewhere in your trace log!

I took your suggestion of playing around with the [60] for that princess line. Yes, it does seem that that specific line length creates a problem with your patch.
[...]
I don't love the idea of changing the "But father!" text and might prefer to live with the extra spacer line. Will have to think on it. The line length is part of the text engine, and it would probably be pretty hard to change it in this case without changing it universally. Hmmm...
How about adding a space between the colon and opening quote? I see you've mostly gone with no space between them (except for the line when the princess meets her father after regaining her form), but that change would fix this one line, and if you're lucky it won't break any of the other lines. In my translation, I preserved the interlaced speech and narrative structure but put them on separate lines since there's a delay between turning the flag for the speech sound effect off and the speech sound effect stopping, so I didn't have to deal with any of this :P.

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #243 on: July 25, 2020, 12:07:30 am »
Quote
Yay! But yes, it does look like there's a maximum length being set somewhere else that would have to be updated too. The good news is that that length will be set somewhere in your trace log!
You are a sly one. I'll give it the ol' college try, but you can probably expect more questions about this.

Quote
How about adding a space between the colon and opening quote? I see you've mostly gone with no space between them (except for the line when the princess meets her father after regaining her form), but that change would fix this one line, and if you're lucky it won't break any of the other lines. In my translation, I preserved the interlaced speech and narrative structure but put them on separate lines since there's a delay between turning the flag for the speech sound effect off and the speech sound effect stopping, so I didn't have to deal with any of this :P.
Putting a line opcode right after the colon creates a very pleasant visual and solves the Princess problem.  :woot!:

Unfortunately, a new issue seems to be popping up that doesn't seem to correspond to the previous issue.



Here's the text that relates to this line:

[FD]Soldier:[line][ ‘]Never mind me. I would request an audience with the king immediately[.’][wait][line]
[ ‘]I bring terrible news that must be reported![' ][60][wait][line]
Guards:[line][ ‘]We understand. Let us help you up[.’][end]

July 25, 2020, 09:04:09 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Actually, it's most likely related to the previous issue. We are probably hitting that magic number again with the final line. I'll try to rephrase, perhaps. More opportunity to do so here.

PS, if I understand this correctly, I could probably plug the [60] earlier in the line and it shouldn't cause any problems. When I get home and can play around, I'll try the Solider:[60][line]. That would seem to be a pretty safe placement method in general considering the line for the speaker is going to always be short.
« Last Edit: July 25, 2020, 09:16:30 am by Chicken Knife »

abw

  • Hero Member
  • *****
  • Posts: 554
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #244 on: July 25, 2020, 10:27:22 am »
You are a sly one. I'll give it the ol' college try, but you can probably expect more questions about this.
The line length control isn't too far astray from the path we were on, basically just 1 CTRL+F away.

Putting a line opcode right after the colon creates a very pleasant visual and solves the Princess problem.  :woot!:
Yay!

Unfortunately, a new issue seems to be popping up that doesn't seem to correspond to the previous issue.
It looks like the [60] and the [wait] don't play well with each other, which is another issue I never had to deal with in my text :P. Since both of your lines are fairly short, one option would be to take out the [wait] and just have e.g.
Code: [Select]
[FD]Soldier:[line]‘Never mind me. I would request an audience with the king immediately[.’][wait][line]
‘I bring terrible news that must be reported!’[line][60][line]
Guards:[line]‘We understand. Let us help you up[.’][end]

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #245 on: July 25, 2020, 04:38:57 pm »
Quote
The line length control isn't too far astray from the path we were on, basically just 1 CTRL+F away.

The fact that Control F doesn't work in the case logger window makes me want to scream. Neither does the ability to select all and copy / paste. I attempted to save the code logger data to a file, produced a CDL file, opened it in Notepad++ and everything says NULL. Wonderful experience.

So I retreated from that and tried doing searches for the line length in the rom area around 0x0428A where the indent spacing is stored. First I searched all the 0A bytes (representing the current value of 10) before and after that address. None of those were the one. Then, I thought it might start the counting from the beginning of the line, so I started searching things like 0E / 0F / 10. Nope, nope and nope.

Quote
It looks like the [60] and the [wait] don't play well with each other, which is another issue I never had to deal with in my text :P. Since both of your lines are fairly short, one option would be to take out the [wait] and just have e.g.
I use the wait command quite liberally. A change in speaker will always be marked by a button input in my scripts, so that's pretty non-negotiable. But the good news is that I was able to do a bit of rewording for that soldier and I'm just as happy with the result. I revised the dialogue with the princess talking to her father's spirit, and that is working fine. Will probably push out an update in a bit which doesn't yet include your revised dictionary. I had enough free characters to do what needs to be done for now, but I will make it a point to revise all that before the next playthrough I do, since I will inevitably want to rewrite pieces of text and I'm sure I would enjoy all that space to work with.

I appreciate all your attention with these questions btw. I'm probably going to keep coming with them relentlessly over the next few weeks. If it becomes too much, let me know. The good thing is that there are some areas I'm actually making progress on by myself, like the nametable work needed for the title screen. Therefore, I can keep myself occupied, and it's not too bad of a start / stop / start / stop situation.
« Last Edit: July 25, 2020, 04:46:06 pm by Chicken Knife »

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 504
  • I am the baldest romhacker
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #246 on: July 25, 2020, 05:02:23 pm »
CDL is a binary file, not a text file. It contains several flags for each byte of rom, such as code and data flags, marks code/data in debugger and highlights bytes in hex editor.

CDL is produced by code/data logger, not by trace logger. Trace logger can output to a text file (like I said before).

No, actually I said that in another thread  >:D
« Last Edit: July 26, 2020, 03:51:07 am by Cyneprepou4uk »
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

abw

  • Hero Member
  • *****
  • Posts: 554
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #247 on: July 25, 2020, 11:25:34 pm »
The fact that Control F doesn't work in the case logger window makes me want to scream. Neither does the ability to select all and copy / paste. I attempted to save the code logger data to a file, produced a CDL file, opened it in Notepad++ and everything says NULL. Wonderful experience.
I'm sure having the Trace Logger log to its own little window must be useful in some situations, but I always log to a file instead and then view the output in a fully-featured text editor.

So I retreated from that and tried doing searches for the line length in the rom area around 0x0428A where the indent spacing is stored. First I searched all the 0A bytes (representing the current value of 10) before and after that address. None of those were the one. Then, I thought it might start the counting from the beginning of the line, so I started searching things like 0E / 0F / 10. Nope, nope and nope.
It actually is a #$0A - the key there is to look at the end condition for the item name copy loop that's too short and find out what sets it; in this case the loop exits when $78 == 0, and $78 gets set to #$0A based on $01:$8705, which in the trace logs comes a mere 4 lines after updating the write position for the second row.

I use the wait command quite liberally. A change in speaker will always be marked by a button input in my scripts, so that's pretty non-negotiable. But the good news is that I was able to do a bit of rewording for that soldier and I'm just as happy with the result.
Fair enough - it definitely wasn't a perfect solution, but I'm glad to hear you've come up with something that works out!

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #248 on: July 27, 2020, 07:36:30 am »
Ok! I got the Trace Logger file outputting and yes, that's a much better way of utilizing the data. After tracking down that line limiting byte and changing it from 0A to 0B, I ended up realizing that the top line was also unnecessarily limited to 12 characters when it has space for 13. So I used largely the same process, adjusted the limit from 0C to 0D, and got a nice surprise afterwards:



But the good news is, that was an easy fix. The line two start point needed to be adjusted from 06 down to 05. And voila, a perfect VAULT window  :woot!:



Now, onto the next smallish thing:

I went back to your advice from weeks ago about how to change the case insensitive Erdrick name restriction to Roto. Here is what you advised.

Quote
This one is pretty easy to track down - if you watch RAM with a table file open while entering "Erdrick", you'll see the name being stored starting at $0009; from there, a read breakpoint will (after a few other hits) get you to the code for comparing the entered name against "Erdrick"... case insensitively ;).
Seeing the letters Erdrick magically appear with a table file loaded into RAM at $0009 was admittedly pretty easy (and neat!), along with setting the read breakpoint.

The part that wasn't so easy was getting 10,000 hits on that breakpoint and not being able to make heads or tails of which one was relevant.

I also have a hard time conceptualizing how the game would store this hybrid upper case / lower case data to reference, so I'm not sure what I'll be ultimately looking for.

Any help with this one would be appreciated!
« Last Edit: July 27, 2020, 08:07:04 am by Chicken Knife »

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 504
  • I am the baldest romhacker
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #249 on: July 27, 2020, 08:06:34 am »
Use forbit breakpoints on hit locations to disable unnecessary ones.

If the game stores letters in some format similar to ascii, where lowercase is +20, then it can check both cases by ORA 20 the entered letter and comparing result to a forbitten lowercase letter.

iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #250 on: July 27, 2020, 08:13:28 am »
Use forbit breakpoints on hit locations to disable unnecessary ones.

If the game stores letters in some format similar to ascii, where lowercase is +20, then it can check both cases by ORA 20 the entered letter and comparing result to a forbitten letter.
I assume you mean forbid breakpoint. I'm not sure what that does, but I imagine it restricts it? Would I just check the forbid box off in the dubugger and that's it?

As for the ORA thing, in my table file 10=f and 2A=F, so that doesn't look like a difference of $20

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 504
  • I am the baldest romhacker
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #251 on: July 27, 2020, 08:19:34 am »
Yes, forbid. It prevents R/W/X breakpoints from getting hit on a specific location. You can double click on cpu address where it hits and add a corresponding checkmark.

Then probably it has to check for both cases sepatately. Maybe by using ADC / SBC 1A

One more option is to set breakpoints to another address of 0009,X range. Since code will most likely be checking name within a loop, an instruction that is gonna trigger a breakpoint for 000B will be working with 0009,X, not with 000B directly.

Actually, no, I don't think this would help much in your particular case.
« Last Edit: July 27, 2020, 08:42:39 am by Cyneprepou4uk »
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

abw

  • Hero Member
  • *****
  • Posts: 554
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #252 on: July 27, 2020, 05:27:21 pm »
And voila, a perfect VAULT window  :woot!:
Congratulations!

If the game stores letters in some format similar to ascii, where lowercase is +20, then it can check both cases by ORA 20 the entered letter and comparing result to a forbitten lowercase letter.
Yeah, ASCII is cool that way, but DW2's character mapping does not have that property, so DW2 ends up explicitly comparing the first letter against "E" and "e", then the second letter against "R" and "r", etc.

The part that wasn't so easy was getting 10,000 hits on that breakpoint and not being able to make heads or tails of which one was relevant.
If you set your breakpoint just before hitting "END", I think the second hit is the one you'll want.

One more option is to set breakpoints to another address of 0009,X range. Since code will most likely be checking name within a loop, an instruction that is gonna trigger a breakpoint for 000B will be working with 0009,X, not with 000B directly.

Actually, no, I don't think this would help much in your particular case.
As it happens, this also works fairly well - a read breakpoint on e.g. $000A will fire a little too late to see the check on $0009, but the rest of the code is all located in the same area and is easily visible in the debugger or trace log.

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #253 on: July 28, 2020, 06:52:04 am »
Quote
f12338  A:06 X:00 Y:70 S:E0 P:nvUbdIzC                                $CBA9:E9 01     SBC #$01
f12338  A:05 X:00 Y:70 S:E0 P:nvUbdIzC                                $CBAB:D0 F6     BNE $CBA3
f12338  A:05 X:00 Y:70 S:E0 P:nvUbdIzC                                $CBA3:48        PHA
f12338  A:05 X:00 Y:70 S:DF P:nvUbdIzC $CBA4:E9 01     SBC #$01
f12338  A:04 X:00 Y:70 S:DF P:nvUbdIzC $CBA6:D0 FC     BNE $CBA4
f12338  A:04 X:00 Y:70 S:DF P:nvUbdIzC $CBA4:E9 01     SBC #$01
f12338  A:03 X:00 Y:70 S:DF P:nvUbdIzC $CBA6:D0 FC     BNE $CBA4
f12338  A:03 X:00 Y:70 S:DF P:nvUbdIzC $CBA4:E9 01     SBC #$01
f12338  A:02 X:00 Y:70 S:DF P:nvUbdIzC $CBA6:D0 FC     BNE $CBA4
f12338  A:02 X:00 Y:70 S:DF P:nvUbdIzC $CBA4:E9 01     SBC #$01
f12338  A:01 X:00 Y:70 S:DF P:nvUbdIzC $CBA6:D0 FC     BNE $CBA4
f12338  A:01 X:00 Y:70 S:DF P:nvUbdIzC $CBA4:E9 01     SBC #$01
f12338  A:00 X:00 Y:70 S:DF P:nvUbdIZC $CBA6:D0 FC     BNE $CBA4
f12338  A:00 X:00 Y:70 S:DF P:nvUbdIZC $CBA8:68        PLA
f12338  A:05 X:00 Y:70 S:E0 P:nvUbdIzC                                $CBA9:E9 01     SBC #$01
f12338  A:04 X:00 Y:70 S:E0 P:nvUbdIzC                                $CBAB:D0 F6     BNE $CBA3
f12338  A:04 X:00 Y:70 S:E0 P:nvUbdIzC                                $CBA3:48        PHA
f12338  A:04 X:00 Y:70 S:DF P:nvUbdIzC $CBA4:E9 01     SBC #$01
Doing my best to analyze some of these lines of code, and if I were to make a wildly uneducated guess, the letter checking may have something to do with this stuff? If I follow these addresses back to the hex editor, I'm still not seeing anything intelligible to me indicating what I need to change.

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 504
  • I am the baldest romhacker
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #254 on: July 28, 2020, 07:46:35 am »
It doesn't look like name checking at all.

This is the best you could find? Seriously?

Here is what you need to do. While entering a name, set read breakpoint to 0009, and forbid every location where it triggers. Then confirm entered name, and one of the new breakpoint hits is gonna be what you are looking for.
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #255 on: July 28, 2020, 08:15:35 am »
@Cyneprepou4uk
Quote
This is the best you could find? Seriously?
I'm obviously very new and very uncomfortable with making these kinds of attempts to sort through code. If you're not going to be patient and respectful in your way of offering help, I'd rather not have it.

Furthermore, you're making a lot of assumptions about what I already understand in the way you explain things.

For instance, "forbid every location where it triggers". I have no idea what this means. "what you are looking for" - I have no idea what I'm looking for, technically speaking, so I doubt I'll recognize it.

If you aspire to be a teacher of new rom hackers, I suggest some changes to your approach.

« Last Edit: July 28, 2020, 08:21:09 am by Chicken Knife »

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 504
  • I am the baldest romhacker
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #256 on: July 28, 2020, 08:25:35 am »
You are looking for code which checks for a specific name.

Lets say your 0009 breakpoint got hit at 0F:89AB. Double click at 89AB. An "add breakpoint" window will be open, it'll already have 89AB and some condition written there, you just need to enable "forbid" checkmark and press OK.

There, now your 0009 breakpoint won't trigger at 89AB. Do the same with other hits.



Quote
If you aspire to be a teacher of new rom hackers, I suggest some changes to your approach.


I expect readers to try something on their own. For example:
Quote
You can double click on cpu address where it hits and add a corresponding checkmark.
Obviously you didn't do that. Or is my english that bad?

Also, I don't spend much time right away on explaining things in details, because most of the time people don't do anything, so it will be a waste for me.
« Last Edit: July 28, 2020, 08:32:48 am by Cyneprepou4uk »
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #257 on: July 28, 2020, 09:21:30 am »
Quote
You can double click on cpu address where it hits and add a corresponding checkmark.
I somehow overlooked that step. It certainly wasn't intentional, and I don't need to be scolded for it, or have assumptions made that I'm not trying to be independent. There are some technically complex things that I've done and am doing right now that I'm not even talking about because I grasp those things and don't need the help. That's my ultimate goal with all of this stuff.

Quote
Also, I don't spend much time right away on explaining things in details, because most of the time people don't do anything, so it will be a waste for me.
If you have any degree of familiarity with my forum activity for the last two years, it should be clear that I am committed to learning and doing. Abw's communications may also sometimes exceed my technical comprehension, but he has been consistently respectful and generous with advice and help. Some might say too generous, but I have learned things along the way in spite of (or perhaps, because of) that generosity.

If the day comes when abw starts getting tired of dealing with my limited technical capacity, he is certainly welcome to speak up, and I will respect that. But in the meantime, I prefer to wait for answers that show respect both to me and to the commitment that I've demonstrated.
« Last Edit: July 28, 2020, 09:50:50 am by Chicken Knife »

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 504
  • I am the baldest romhacker
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #258 on: July 28, 2020, 10:14:53 am »
Well, I'm not wiping your snots and showing respect while giving answers  >:D

Ask your questions about what you still don't understand if you want to get this thing done.

Or you can wait for abw to come here once a day, I don't really care.
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
Re: Dragon Warrior 1, 2 & 3 Hacking Discussion
« Reply #259 on: July 28, 2020, 10:37:57 am »
Quote
Well, I'm not wiping your snots and showing respect while giving answers
At this point, I'm probably just as interested in learning about hacking from you as you are in learning about respect from me.

We'd probably be better off just staying out of each other's way from here.