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

Author Topic: [solved]little debug problem (secret of mana)  (Read 4489 times)

Hiei-

  • Sr. Member
  • ****
  • Posts: 373
    • View Profile
[solved]little debug problem (secret of mana)
« on: May 08, 2012, 08:07:54 am »
I did a french translated version of Secret of Mana using the retranslated iphone script (translated from japanese), the rom is expanded, pointers and texts are now in the expanded megabyte and everything is working fine.

I asked a spanish hacker (magno) if I could use his patch (spanish patch) to redo my work on it because his patch is featuring a VWF.

I re-expanded his patch and put again the new pointers/texts at the same location.

Everything seemed to work fine during my tests until I reached the Mana Tree.

For an unknow reason, the game is displaying the wrong text and so skip a lot of events.

I did a trace and found the problem :

Code: [Select]
$C0/371A B9 00 00    LDA $0000,y[$E1:0000]   A:0000 X:000B Y:0000 P:envMxdIZc
For an unknow reason, the spanish patch combined to my hack is jumping to "$E1:0000" (my old patch don't jump to that adress) and it's the actual problem.

To avoid the bug, the game should jump to "$E2:0000" which is the location of the dialog which should be displayed, as well as the good events.

So my question is, how to force the game to jump to "$E2:0000" instead of "$E1:0000" ?

Or if you prefer how to have this instruction :

Code: [Select]
$C0/371A B9 00 00    LDA $0000,y[$E2:0000]   A:0000 X:000B Y:0000 P:envMxdIZc
instead of this actual one :

Code: [Select]
$C0/371A B9 00 00    LDA $0000,y[$E1:0000]   A:0000 X:000B Y:0000 P:envMxdIZc
« Last Edit: May 09, 2012, 03:29:37 am by Hiei- »

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5761
    • View Profile
    • Nightcrawler's Translation Corporation
Re: little debug problem (secret of mana)
« Reply #1 on: May 08, 2012, 09:21:53 am »
You have to look at the instructions leading up to that. It may be the immediately preceding instructions, or it may be a few routines back, but somewhere the DB register is loaded with $E1. You'll need to find out where and see what instructions need to be changed there. Typically a value in the accumulator is pushed and popped to it "pha; plb", but it could happen a variety of ways.

It looks like you're using SNES9x. Turn the squelch option off so you can see the DB register. You'll see it's $E1.

TransCorp - Over 20 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Glory of Heracles IV SFC/SNES Translations

Hiei-

  • Sr. Member
  • ****
  • Posts: 373
    • View Profile
Re: little debug problem (secret of mana)
« Reply #2 on: May 08, 2012, 09:56:13 am »
Code: [Select]
$C0/371A B9 00 00    LDA $0000,y[$E1:0000]   A:0000 X:000D Y:0000 D:0000 DB:E1 S:01EB P:envMxdIZcHC:0308 VC:016 01 FL:4254
Yeah, you're right.

I'll try to trace a while back because a trace like 30 seconds before don't give the line I pasted.

Edit : If someone is better than me at tracing (but maybe I'll find it myself, who knows), here's the actual patch : http://www.hiei-tf.fr/asm-spa.ips (apply it on the "Secret of Mana (U) [!]" rom).

Here's a sram file : http://www.hiei-tf.fr/asm-spa.srm (there is only one slot so you can't load the wrong one).

Put a breakpoint to $E1:0000 and you'll quickly see where the problem occurs.

May 08, 2012, 03:26:07 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Here's what I found :

Code: [Select]
$C0/36DE 5C 4A DD D2 JMP $D2DD4A[$D2:DD4A]   A:008F X:000C Y:0000 D:0000 DB:E1 S:01E9 P:envMxdIzCHC:0878 VC:006 01 FL:7758
$D2/DD4A 8B          PHB                     A:008F X:000C Y:0000 D:0000 DB:E1 S:01E9 P:envMxdIzCHC:0910 VC:006 01 FL:7758
$D2/DD4B 48          PHA                     A:008F X:000C Y:0000 D:0000 DB:E1 S:01E8 P:envMxdIzCHC:0932 VC:006 01 FL:7758
$D2/DD4C A9 7E       LDA #$7E                A:008F X:000C Y:0000 D:0000 DB:E1 S:01E7 P:envMxdIzCHC:0954 VC:006 01 FL:7758
$D2/DD4E 48          PHA                     A:007E X:000C Y:0000 D:0000 DB:E1 S:01E7 P:envMxdIzCHC:0970 VC:006 01 FL:7758
$D2/DD4F AB          PLB                     A:007E X:000C Y:0000 D:0000 DB:E1 S:01E6 P:envMxdIzCHC:0992 VC:006 01 FL:7758
$D2/DD50 68          PLA                     A:007E X:000C Y:0000 D:0000 DB:7E S:01E7 P:envMxdIzCHC:1020 VC:006 01 FL:7758
$D2/DD51 9D 80 93    STA $9380,x[$7E:938C]   A:008F X:000C Y:0000 D:0000 DB:7E S:01E8 P:eNvMxdIzCHC:1082 VC:006 01 FL:7758
$D2/DD54 E8          INX                     A:008F X:000C Y:0000 D:0000 DB:7E S:01E8 P:eNvMxdIzCHC:1114 VC:006 01 FL:7758
$D2/DD55 8E A6 A1    STX $A1A6  [$7E:A1A6]   A:008F X:000D Y:0000 D:0000 DB:7E S:01E8 P:envMxdIzCHC:1128 VC:006 01 FL:7758
$D2/DD58 DA          PHX                     A:008F X:000D Y:0000 D:0000 DB:7E S:01E8 P:envMxdIzCHC:1168 VC:006 01 FL:7758
$D2/DD59 EB          XBA                     A:008F X:000D Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:1198 VC:006 01 FL:7758
$D2/DD5A A9 00       LDA #$00                A:8F00 X:000D Y:0000 D:0000 DB:7E S:01E6 P:envMxdIZCHC:1218 VC:006 01 FL:7758
$D2/DD5C EB          XBA                     A:8F00 X:000D Y:0000 D:0000 DB:7E S:01E6 P:envMxdIZCHC:1234 VC:006 01 FL:7758
$D2/DD5D 38          SEC                     A:008F X:000D Y:0000 D:0000 DB:7E S:01E6 P:eNvMxdIzCHC:1254 VC:006 01 FL:7758
$D2/DD5E E9 80       SBC #$80                A:008F X:000D Y:0000 D:0000 DB:7E S:01E6 P:eNvMxdIzCHC:1268 VC:006 01 FL:7758
$D2/DD60 AA          TAX                     A:000F X:000D Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:1284 VC:006 01 FL:7758
$D2/DD61 BF F4 DD D2 LDA $D2DDF4,x[$D2:DE03] A:000F X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:1298 VC:006 01 FL:7758
$D2/DD65 18          CLC                     A:0007 X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:1338 VC:006 01 FL:7758
$D2/DD66 6D CF A1    ADC $A1CF  [$7E:A1CF]   A:0007 X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzcHC:1352 VC:006 01 FL:7758
$D2/DD69 C9 08       CMP #$08                A:000B X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzcHC:0016 VC:007 01 FL:7758
$D2/DD6B B0 05       BCS $05    [$DD72]      A:000B X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:0032 VC:007 01 FL:7758
$D2/DD72 48          PHA                     A:000B X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:0054 VC:007 01 FL:7758
$D2/DD73 29 07       AND #$07                A:000B X:000F Y:0000 D:0000 DB:7E S:01E5 P:envMxdIzCHC:0076 VC:007 01 FL:7758
$D2/DD75 8D CF A1    STA $A1CF  [$7E:A1CF]   A:0003 X:000F Y:0000 D:0000 DB:7E S:01E5 P:envMxdIzCHC:0092 VC:007 01 FL:7758
$D2/DD78 68          PLA                     A:0003 X:000F Y:0000 D:0000 DB:7E S:01E5 P:envMxdIzCHC:0124 VC:007 01 FL:7758
$D2/DD79 4A          LSR A                   A:000B X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:0152 VC:007 01 FL:7758
$D2/DD7A 4A          LSR A                   A:0005 X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:0166 VC:007 01 FL:7758
$D2/DD7B 4A          LSR A                   A:0002 X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzCHC:0180 VC:007 01 FL:7758
$D2/DD7C 18          CLC                     A:0001 X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzcHC:0194 VC:007 01 FL:7758
$D2/DD7D 6D CE A1    ADC $A1CE  [$7E:A1CE]   A:0001 X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzcHC:0208 VC:007 01 FL:7758
$D2/DD80 8D CE A1    STA $A1CE  [$7E:A1CE]   A:0009 X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzcHC:0240 VC:007 01 FL:7758
$D2/DD83 FA          PLX                     A:0009 X:000F Y:0000 D:0000 DB:7E S:01E6 P:envMxdIzcHC:0272 VC:007 01 FL:7758
$D2/DD84 AD CA A1    LDA $A1CA  [$7E:A1CA]   A:0009 X:000D Y:0000 D:0000 DB:7E S:01E8 P:envMxdIzcHC:0308 VC:007 01 FL:7758
$D2/DD87 CE CA A1    DEC $A1CA  [$7E:A1CA]   A:0020 X:000D Y:0000 D:0000 DB:7E S:01E8 P:envMxdIzcHC:0340 VC:007 01 FL:7758
$D2/DD8A AB          PLB                     A:0020 X:000D Y:0000 D:0000 DB:7E S:01E8 P:envMxdIzcHC:0386 VC:007 01 FL:7758
$D2/DD8B 3A          DEC A                   A:0020 X:000D Y:0000 D:0000 DB:E1 S:01E9 P:eNvMxdIzcHC:0414 VC:007 01 FL:7758
$D2/DD8C D0 2A       BNE $2A    [$DDB8]      A:001F X:000D Y:0000 D:0000 DB:E1 S:01E9 P:envMxdIzcHC:0428 VC:007 01 FL:7758
$D2/DDB8 5C E2 36 C0 JMP $C036E2[$C0:36E2]   A:001F X:000D Y:0000 D:0000 DB:E1 S:01E9 P:envMxdIzcHC:0450 VC:007 01 FL:7758
$C0/36E2 60          RTS                     A:001F X:000D Y:0000 D:0000 DB:E1 S:01E9 P:envMxdIzcHC:0482 VC:007 01 FL:7758

$C0/375E 80 AF       BRA $AF    [$370F]      A:001F X:000D Y:0000 D:0000 DB:E1 S:01EB P:envMxdIzcHC:0524 VC:007 01 FL:7757
$C0/370F AF 00 1D 00 LDA $001D00[$00:1D00]   A:001F X:000D Y:0000 D:0000 DB:E1 S:01EB P:envMxdIzcHC:0546 VC:007 01 FL:7757
$C0/3713 29 80       AND #$80                A:0000 X:000D Y:0000 D:0000 DB:E1 S:01EB P:envMxdIZcHC:0586 VC:007 01 FL:7757
$C0/3715 F0 03       BEQ $03    [$371A]      A:0000 X:000D Y:0000 D:0000 DB:E1 S:01EB P:envMxdIZcHC:0602 VC:007 01 FL:7757
$C0/371A B9 00 00    LDA $0000,y[$E1:0000]   A:0000 X:000D Y:0000 D:0000 DB:E1 S:01EB P:envMxdIZcHC:0624 VC:007 01 FL:7757

More precisely, the "E1" seems to be loaded here :

Code: [Select]
$D2/DD8A AB          PLB                     A:0020 X:000D Y:0000 D:0000 DB:7E S:01E8 P:envMxdIzcHC:0386 VC:007 01 FL:7758
$D2/DD8B 3A          DEC A                   A:0020 X:000D Y:0000 D:0000 DB:E1 S:01E9 P:eNvMxdIzcHC:0414 VC:007 01 FL:7758

How should I do now ? (I don't really know much about ASM hacking  :-[)
« Last Edit: May 08, 2012, 08:28:59 pm by Hiei- »

Vehek

  • Full Member
  • ***
  • Posts: 176
    • View Profile
Re: little debug problem (secret of mana)
« Reply #3 on: May 08, 2012, 11:40:39 pm »
I tried doing a trace and working backward to find the origin of the E1. I found where it was loaded into the DB register, but not its actual origin. I don't think the problem lies there though.
I noticed that this text at $E2:0000 you're having problems with lies in the middle of a script that started in bank E1. This game doesn't appear to have routines to check if it's gone beyond the end of a bank, so it wraps around to the beginning of the bank. Unless you plan on making it so it can detect when the bank is over, you need to make sure no script is split across banks.
« Last Edit: May 09, 2012, 12:13:49 am by Vehek »

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5031
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Re: little debug problem (secret of mana)
« Reply #4 on: May 09, 2012, 12:06:39 am »
I did a french translated version of Secret of Mana using the retranslated iphone script (translated from japanese), the rom is expanded, pointers and texts are now in the expanded megabyte and everything is working fine.

I asked a spanish hacker (magno) if I could use his patch (spanish patch) to redo my work on it because his patch is featuring a VWF.
Would you mind telling me where you got this patch and if it's based on FuSoYa's VWF patch?

I tried editng FuSoYa's patch, and while I had some minimal success (I was able to edit a few test strings, and the weapon names), there was a big problem. The first string in the game (the intro text) is somehow hardcoded. It's still stored in the ROM in a form, but no matter how you change it, it remains the same.

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

Hiei-

  • Sr. Member
  • ****
  • Posts: 373
    • View Profile
Re: little debug problem (secret of mana)
« Reply #5 on: May 09, 2012, 02:54:18 am »
Magno's one isn't based on Fusoya's patch. Fusoya put a protection in his hack to block people of reusing it, that's why you have some problems if you try to edit the rom with Fusoya's modifications.

http://magno.romhackhispano.org/mana.html

I tried doing a trace and working backward to find the origin of the E1. I found where it was loaded into the DB register, but not its actual origin. I don't think the problem lies there though.
I noticed that this text at $E2:0000 you're having problems with lies in the middle of a script that started in bank E1. This game doesn't appear to have routines to check if it's gone beyond the end of a bank, so it wraps around to the beginning of the bank. Unless you plan on making it so it can detect when the bank is over, you need to make sure no script is split across banks.

Oh, you're probably right. I didn't check that... I'll go check and try to modify the pointer if needed and let know you if it worked. It it's just that, silly me...

Edit : Oh my god, silly me, I didn't think about checking that... I manually moved both dialogs which were placed between two banks, fixed the pointers and it's working. Thanks a lottttttttttttttttttttttttttttttttttttttttttttttt  :woot!:
« Last Edit: May 09, 2012, 03:33:23 am by Hiei- »

Gideon Zhi

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 3509
    • View Profile
    • Aeon Genesis
Re: [solved]little debug problem (secret of mana)
« Reply #6 on: May 09, 2012, 12:43:26 pm »
Splitting between two banks is actually a really, really simple hack. In your case, figure out where the game increments Y, and if it ever ticks over from FFFF to 0000, pull the DBR, inc, and push it back. It only gets tricky if you have controls that span multiple bytes, in which case you might just not want to bother with futzing with it that way.

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5031
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Re: [solved]little debug problem (secret of mana)
« Reply #7 on: May 09, 2012, 09:22:38 pm »
Thanks! I'm gonna email him too, see if I can use his patch for my retranslation. :D

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

Hiei-

  • Sr. Member
  • ****
  • Posts: 373
    • View Profile
Re: [solved]little debug problem (secret of mana)
« Reply #8 on: May 10, 2012, 01:49:22 am »
If you want, I can help you once my new version is done (I'm near the end, just need to finalize the auto-reformat of the text and add the english battle messages).

Right now, I can insert the old english script on my patch with only two clicks (or any retranslated script).

Not to mention I already have, in the same format, the japanese script dumped.

Original french script :

Code: [Select]
<Event id='0x022'>
<CallEvent id='0x01f'/>
<Text>Tous : Où est Socrate ?</Text>
<CallEvent id='0x01e'/>
<Text> est[NewLine]
allé à l'île Dorée.</Text>
<WaitTime id='0x00'/>
<CleatText/>
<Text>En partant d'ici, elle est[NewLine]
située au nord-est.</Text>
<JumpEvent id='0x5ff'/>
</Event>

Original english script :

Code: [Select]
<Event id='0x022'>
<CallEvent id='0x01f'/>
<Text>All:Where is Joch?</Text>
<CallEvent id='0x01e'/>
<Text>left for[NewLine]
 the Gold Isle.[NewLine]
 It's northeast of here.</Text>
<JumpEvent id='0x5ff'/>
</Event>

Original japanese script :

Code: [Select]
<Event id='0x022'>
<CallEvent id='0x01f'/>
<Text>『うそっ!?</Text>
<CallEvent id='0x01e'/>
<Text>黄金の島へ[NewLine]
 とでかけたんだな。[NewLine]
 そらとぶほうきでひとっとび!</Text>
<WaitTime id='0x00'/>
<Text>[NewLine]
「え?黄金島?ここから北東[NewLine]
 に行った、海のまん中のまあるい 島なんだな。</Text>
<JumpEvent id='0x5ff'/>
</Event>

Retranslated french script (from japanese) :

Code: [Select]
<Event id='0x022'>
<CallEvent id='0x01f'/>
<Player id='0x1'/><Text> : Encore ?!</Text>
<WaitTime id='0x00'/>
<CleatText/>
<Text>Maître Jach est parti[NewLine]
pour l'île d'or.</Text>
<WaitTime id='0x00'/>
<CleatText/>
<Text>Il a enfourché son balai[NewLine]
magique et s'est envolé,[NewLine]
fiouh !</Text>
<WaitTime id='0x00'/>
<CleatText/>
<Text>L'île d'or est une île ronde
au nord-est d'ici,[NewLine]
au milieu de l'océan !</Text>
<WaitTime id='0x00'/>
<CleatText/>
<Text>Vous ne pouvez pas[NewLine]
la rater !</Text>
<JumpEvent id='0x5ff'/>
</Event>

If it can help you spare a lot of times.

My version have been expanded, so you don't really have to worry about script filesize (and so, the new has a VWF and an auto-format program for the script). It also feature the intro text translation (compressed) and the title screen modification if needed (had to move it somewhere else in the rom because my new title screen were to big).
« Last Edit: May 10, 2012, 02:14:41 am by Hiei- »

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5031
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Re: [solved]little debug problem (secret of mana)
« Reply #9 on: May 10, 2012, 03:41:39 am »
I would actually appreciate that a lot. That way I can just concentrate on translating the script, and not on inserting it and messing with it.

I actually tried cracking open the Spanish translation with a table and whatnot I'd already created for the English versions, and couldn't find any text. I did, however, find some leftover English text. Interesting.

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

Hiei-

  • Sr. Member
  • ****
  • Posts: 373
    • View Profile
Re: [solved]little debug problem (secret of mana)
« Reply #10 on: May 10, 2012, 07:32:23 am »
I can already send you the japanese script, while I am finalizing my patch (as the script part is already done and functionnal).

I'll send you a pm with a link where you can get it.

May 11, 2012, 06:53:57 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Your inbox is full so I'll answer you here :

Quote
Once the dump is translated, I can reinsert it easily, so you'll see the result the day after.

If you mean a program where you click and which automatically reinsert the script, no. Because of the way Magno did his patch, I have to tweak a few things to reinsert the translation in it and it would be pretty long/complicated to explain them (if was working this way in my old patch, but there were no VWF in it).
« Last Edit: May 11, 2012, 06:53:57 am by Hiei- »