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

Author Topic: Text Routine  (Read 5421 times)

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Text Routine
« on: June 21, 2013, 11:35:14 pm »
Ok, i have located the text routine in Kawa No Nushi Tsuri. I have also written my dte routine with dte table. The thing is, i am not sure what to do next. I have all the town dialog, battle menus, menus translated and in the game except for the items, fish and animal names.  Really i wanted the dte routine for the animal and fish names. But I am looking at the text routine, and I feel like I am in space looking at all those letters and numbers. I really want to make a quality translation and take my romhacking skills to the next level. Basically, what I am asking is do any of you guys have any examples you can point me to that tackle or are like the problem I am having?
I'll explain more if you need it.

  Note, my 6502 is very minimum and I know I have years ahead of me before i can change that but I really want to expand into that area so i reading and trying out every tutorial i can on the subject. I know about the opcodes but, I am having trouble understanding the logic of how the commands are put together. Anyway, this is beyond the scope of my question. I am just trying to let you guys know where I am at skillwise and my mindset in approaching this problem. Yes, i have read and completed Red Comet's and KingMike's tutorial.

In closing, any help, explanations will be appreciated.

Trax

  • RHDN Patreon Supporter!
  • Hero Member
  • *****
  • Posts: 563
    • View Profile
    • Trax ROM Hacking
Re: Text Routine
« Reply #1 on: June 24, 2013, 01:51:13 pm »
You could detail your problem more and maybe provide pointers of the data you found already. At first sight, I don't think your problem necessitates ASM hacking. If you need more space because your text sequence are increased in length, it's more a question of pointer modification than ASM. But if it's how to locate the data, yes, some ASM analysis may come handy, although it's not about writing your own code, only interpret the code in the game...

I never worked with DTE-style compression, but I can imagine it's not trivial to edit freely since there's no exact byte to letter equivalent. But if you found the text generation routine and made your own table, I'd say you've done most of the job already. Editing text by hand with a hex editor can be tedious, though. If you give me some pointers and variables, I can check the code and see what I can do to help...

Gideon Zhi

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 3529
    • View Profile
    • Aeon Genesis
Re: Text Routine
« Reply #2 on: June 24, 2013, 02:51:27 pm »
An optimized DTE table is usually generated by external tools being run on a script before the build process starts; once a table is built, re-building it generally doesn't help all that much and tends to be more trouble than it's worth. DTE-optimized text tends to happen at the inserter level; you provide (say) Atlas with a script and a table containing all of your DTE values, it figures out how best to encode the text as it inserts, and you end up with DTE-encoded text in the ROM.

That said, I'd like to know how you claim to have "written [your] dte routine with dte table" while your "6502 is very minimum." In my experience these are two contradictory statements! You write the routine in 6502, using 6502, and you need to understand 6502 to write the routine. Uh.

Do you really understand what a DTE table is? Do you want it because your animal and fish names won't fit in the rom, or because they won't fit on the screen? You keep using that word. I don't think it means what you think it means!

Spikeman

  • Hero Member
  • *****
  • Posts: 1063
  • *unce unce unce*
    • View Profile
    • None at the moment, check out my Last.fm page instead?
Re: Text Routine
« Reply #3 on: June 24, 2013, 08:27:32 pm »
But I am looking at the text routine, and I feel like I am in space looking at all those letters and numbers. I really want to make a quality translation and take my romhacking skills to the next level. Basically, what I am asking is do any of you guys have any examples you can point me to that tackle or are like the problem I am having?
I'll explain more if you need it.

Yeah, you're going to have to be a little more specific. What exactly are you trying to do? Is there some problem with the DTE routine you made? Screenshots would help. (Or a patch even.)

Quote
That said, I'd like to know how you claim to have "written [your] dte routine with dte table" while your "6502 is very minimum." In my experience these are two contradictory statements! You write the routine in 6502, using 6502, and you need to understand 6502 to write the routine. Uh.

He said he followed KingMike's tutorial, which I think is plausible that you could get through that tutorial without understanding 6502 very well. That said, I think a DTE hack is the perfect way to get started with ASM - it was my first ASM hack, and I didn't know what I was doing at all when I started, but I got it to work. Let's give the guy a little credit. :)

As far as generating an optimized DTE table, there are several utilities here that can help you with that. Including the one I made back when I did my first DTE hack: http://www.romhacking.net/utilities/404/
Open Source Hacking Projects: Guru Logic Champ, Telefang 2, (Want more? Check out my GitHub!)

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Re: Text Routine
« Reply #4 on: June 24, 2013, 09:57:07 pm »
I am trying to create more text space for the Fish and Animal names without it spilling over.

Right now I am just trying to do the fish names since the animal names are in a different bank and will probably require another routine just for them.

The fish offsets are at $00014F7E.
The fish pointers are right above the text block. And they are kinda weird I think they are done in nibbles.

and the DTE offset  is at $00015D80.

The DTE table is at $00015E10.


As of right now the dte doesn't do anything. I am a tad confused as to why. Maybe 0E was not the text ram byte I was looking for...
you download the patch here.

http://www.bwass.org/bucket/Kawa no Nushi Tsuri (eng) redo.ips

Any help will be appreciated.


------------------------------------------------------------------
Now I realize what's up. I gotta jump from that particular text routine.
« Last Edit: June 24, 2013, 10:08:29 pm by Pikachumanson »

Spikeman

  • Hero Member
  • *****
  • Posts: 1063
  • *unce unce unce*
    • View Profile
    • None at the moment, check out my Last.fm page instead?
Re: Text Routine
« Reply #5 on: June 24, 2013, 10:20:24 pm »
Oh okay, so you haven't implemented the actual DTE routine yet.

Quote
and the DTE offset  is at $00015D80.

What do you mean the DTE offset? Is this the new code or something? And yes, you will have to jump to the new routine - you may also have to edit one or two other parts of the routine. I believe KingMike goes over this in his tutorial?

BTW, I meant a screenshot of the problem you're having in the game. :D
Open Source Hacking Projects: Guru Logic Champ, Telefang 2, (Want more? Check out my GitHub!)

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Re: Text Routine
« Reply #6 on: June 24, 2013, 11:21:35 pm »
Yeah I am tracking down the text routine now.


June 25, 2013, 02:05:02 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Yippee I got it working! Thank you to everyone who replied to this thread. Especially Spikeman!



Just gotta organize my table now.
 

June 27, 2013, 09:53:53 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
All right... so far, I've either got my routine to spit out gibberish or nothing at all.

I was told to place a jump from the text routine from a LDA (whatever), y and an INC statement.

The thing is, When I read KingMike's and Redcomet's Faq they tell me the LDA state should be a B1 statement and if I can't find that then I should use a A1 statement.

The thing is I can't find either in the text routine.  All I can find are AD, A5,A2 and B9 statements.

Let me show you the code where I set a conditional breakpoint that led me to (what I think) is the text routine.
You'll wanna scroll down to  01E587:8D 07 20  STA $2007 = #$98 where the breakpoint occurred for the first that pops up in the game which is I. I also tried this with the second letter n and it stopped in the same place.
 
Code: [Select]
  01E533:A2 03     LDX #$03  ;beginning of routine
  01E535:A5 E3     LDA $00E3 = #$00
  01E537:C9 02     CMP #$02
  01E539:B0 09     BCS $E534
  01E53B:A5 72     LDA $0072 = #$00
  01E53D:F0 05     BEQ $E534
  01E53F:A2 00     LDX #$00
  01E541:4C 4A E5  JMP $E54A
  01E544:A5 E3     LDA $00E3 = #$00
  01E546:C9 02     CMP #$02
  01E548:B0 09     BCS $E543
  01E54A:A5 71     LDA $0071 = #$00
  01E54C:F0 05     BEQ $E543
  01E54E:A2 01     LDX #$01
  01E550:4C 4A E5  JMP $E54A
  01E553:AD 5C 07  LDA $075C = #$00
  01E556:F0 02     BEQ $E54A
  01E558:A2 07     LDX #$07
  01E55A:86 09     STX $0009 = #$07
  01E55C:EE BB 07  INC $07BB = #$48
  01E55F:AD BB 07  LDA $07BB = #$48
  01E562:25 09     AND $0009 = #$07
  01E564:F0 03     BEQ $E559
  01E566:4C D6 E5  JMP $E5D6
01E569:AD BA 07  LDA $07BA = #$00
  01E56C:AA        TAX
  01E56D:18        CLC
  01E56E:69 12     ADC #$12
  01E570:A8        TAY
  01E571:20 FB DB  JSR $DBFB
  01E574:A5 91     LDA $0091 = #$23
  01E576:8D 06 20  STA $2006 = #$E8
  01E579:A5 92     LDA $0092 = #$27
  01E57B:8D 06 20  STA $2006 = #$E8
  01E57E:BD 50 06  LDA $0650,X @ $065F = #$FE
  01E581:8D 07 20  STA $2007 = #$98
  01E584:B9 50 06  LDA $0650,Y @ $06B0 = #$34
  01E587:8D 07 20  STA $2007 = #$98 <----Here is where the breakpoint occured
  01E58A:20 05 DC  JSR $DC05
  01E58D:EE BA 07  INC $07BA = #$00
  01E590:E6 92     INC $0092 = #$27
  01E592:A5 92     LDA $0092 = #$27
  01E594:29 1F     AND #$1F
  01E596:D0 18     BNE $E5A0
  01E598:A5 92     LDA $0092 = #$27
  01E59A:38        SEC
  01E59B:E9 20     SBC #$20
  01E59D:85 92     STA $0092 = #$27
01E59F:A5 91     LDA $0091 = #$23
  01E5A1:C9 24     CMP #$24
  01E5A3:B0 06     BCS $E59B
  01E5A5:18        CLC
  01E5A6:69 04     ADC #$04
  01E5A8:4C 9E E5  JMP $E59E
  01E5AB:38        SEC
  01E5AC:E9 04     SBC #$04
  01E5AE:85 91     STA $0091 = #$23
  01E5B0:CE BC 07  DEC $07BC = #$00
  01E5B3:D0 31     BNE $E5D6
  01E5B5:A9 00     LDA #$00
  01E5B7:8D BA 07  STA $07BA = #$00
  01E5BA:AD FF 07  LDA $07FF = #$00
  01E5BD:C9 04     CMP #$04
  01E5BF:B0 03     BCS $E5B4
  01E5C1:EE FF 07  INC $07FF = #$00
  01E5C4:C9 03     CMP #$03
  01E5C6:B0 0C     BCS $E5C4
  01E5C8:A5 94     LDA $0094 = #$27
01E5CA:18        CLC
  01E5CB:69 40     ADC #$40
  01E5CD:90 07     BCC $E5C6
  01E5CF:E6 93     INC $0093 = #$23
  01E5D1:4C C6 E5  JMP $E5C6
  01E5D4:A5 94     LDA $0094 = #$27
  01E5D6:85 94     STA $0094 = #$27
  01E5D8:85 92     STA $0092 = #$27
  01E5DA:A5 93     LDA $0093 = #$23
  01E5DC:85 91     STA $0091 = #$23
  01E5DE:A9 00     LDA #$00
  01E5E0:8D 8F 07  STA $078F = #$01
  01E5E3:EE B9 07  INC $07B9 = #$00
  01E5E6:60        RTS --------------

Where exactly can I put a jump in this statement, if I can make one at all here?
Should I be looking elsewhere?
« Last Edit: June 27, 2013, 09:53:54 pm by Pikachumanson »

Kunio

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Text Routine
« Reply #7 on: June 29, 2013, 12:38:47 am »
Put a screenshot from where you want to translate
And say what do you want to translate it to
I will take a look at it

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7003
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Text Routine
« Reply #8 on: June 29, 2013, 01:40:42 am »
Code: [Select]
01E569:AD BA 07  LDA $07BA = #$00   ;index into window buffer
  01E56C:AA        TAX                ;X = index to dakuten line of current printed character?
  01E56D:18        CLC
  01E56E:69 12     ADC #$12
  01E570:A8        TAY           ;Y = X+0x12, because each line is 18 characters wide, so the main character will be 18 bytes after the corresponding dakuten
  01E571:20 FB DB  JSR $DBFB
  01E574:A5 91     LDA $0091 = #$23
  01E576:8D 06 20  STA $2006 = #$E8
  01E579:A5 92     LDA $0092 = #$27
  01E57B:8D 06 20  STA $2006 = #$E8
  01E57E:BD 50 06  LDA $0650,X @ $065F = #$FE  ;here it's reading the dakuten line
  01E581:8D 07 20  STA $2007 = #$98        ;and here's it writing one tile to VRAM
  01E584:B9 50 06  LDA $0650,Y @ $06B0 = #$34  ;here its reading the main text line. And the next will write that tile
It's setting X = $07BA, then Y = X+0x12.
I don't know what function $DBFB does, but I'm guessing it's a wait for vblank function?
Apparently the game must be writing the text from ROM to RAM $650, which appears to be the window tilemap, though a bit jumbled. 18 bytes for the dakuten line, then 18 bytes for the text line.
You could probably use the dakuten line to print more text, though you would have deal with the game printing two lines at once. But that's a different issue.
What you need to look at is how the text got INTO RAM $0650-6DF. You need to trace that.
"My watch says 30 chickens" Google, 2018

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Re: Text Routine
« Reply #9 on: June 29, 2013, 01:44:31 am »
@ Kunio The game is already translated. I need coding help.

This is where the text starts. For some reason the game is not bringing up my dte table vales even though the game is reading my routine and highlighted my dte table values in blue when I run the code logger in FCUEX.


@KingMike

I'll get right on that!
Thank you!

Kunio

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Text Routine
« Reply #10 on: July 03, 2013, 04:56:53 pm »
Here you are :



Code: [Select]
@ 0F13B --> Original Code :
07:F12B:B1 12     LDA ($12),Y
07:F12D:C9 FF     CMP #$FF

@ 0F13B --> Jump Code :
07:F12B:4C 00 FF  JMP $FF00
07:F12E:EA        NOP

@ 01FF10 --> DTE Code :
07:FF00:08        PHP //Back up from flags
07:FF01:86 EE     STX $00EE //Back up X reg, EE is a free RAM byte
07:FF03:A5 EF     LDA $00EF //DTE indicator, EF is a free RAM byte
07:FF05:C9 00     CMP #$00 //Check if it is turn of the DTE second character
07:FF07:D0 1A     BNE $FF23 //Jump to DTE second character code
07:FF09:B1 12     LDA ($12),Y //From original game code
07:FF0B:C9 50     CMP #$50 //Compare with DTE low byte
07:FF0D:30 1E     BMI $FF2D //Jump if DTE low byte < 50
07:FF0F:C9 5F     CMP #$5F //Compare with DTE high byte
07:FF11:10 1A     BPL $FF2D //jump if DTE high byte > 5F
07:FF13:C6 12     DEC $0012 //To call the same text counter value for printing DTE second character
07:FF15:38        SEC //Preparation for a subtraction command
07:FF16:E9 50     SBC #$50 //Subtract base from DTE low byte
07:FF18:0A        ASL //Reach to the correct DTE pair in the table
07:FF19:AA        TAX //Transfer the result of 2*(A-50) to X
07:FF1A:E8        INX //Reach to the offset of DTE first character
07:FF1B:86 EF     STX $00EF //Save offset of DTE first character
07:FF1D:BD 3F FF  LDA $FF3F,X //Load DTE first character from table
07:FF20:4C 2D FF  JMP $FF2D //End of Printing DTE first character
07:FF23:A6 EF     LDX $00EF //Load offset of DTE first character
07:FF25:E8        INX //Reach to the offset of DTE second character
07:FF26:BD 3F FF  LDA $FF3F,X //Load DTE second character from table
07:FF29:A2 00     LDX #$00 //Preparation for regular mode
07:FF2B:86 EF     STX $00EF //Switch to regular mode
07:FF2D:A6 EE     LDX $00EE //Restore X reg from back up
07:FF2F:28        PLP //Restore flags from back up
07:FF30:C9 FF     CMP #$FF //From original game code
07:FF32:4C 2F F1  JMP $F12F //End of DTE routine

@ 01FF50 --> DTE Table :
50 : 00 00
51 : 01 01
52 : 02 02
53 : 03 03
54 : 04 04
55 : 05 05
56 : 06 06
57 : 07 07
58 : 08 08
59 : 09 09
5A : 1A 1A
5B : 1B 1B
5C : 1C 1C
5D : 1D 1D
5E : 1E 1E
5F : 1F 1F
« Last Edit: July 04, 2013, 12:26:45 am by Kunio »

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7003
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Text Routine
« Reply #11 on: July 03, 2013, 09:22:47 pm »
Code: [Select]
07:FF13:C6 12     DEC $0012 //To call the same text counter value for printing DTE second character
Note that $12 a 2-byte value, a pointer to the current character in the script.
You need to account for possible underflow (if 0-> FF, decrement $13)

Code: [Select]
dec $12
pha          ;because A is holding the character value, we need to use the PHA instruction to preserve its value because we need to change A for the next instruction
lda $12      ;since apparently DEC doesn't affect the carry flag, you need to
cmp #$FF   ;check if $12 wrapped from 0->FF
bne $02    ;skip ahead 2 bytes, past the next instruction if we don't need to decrement
dec $13    ;decrement high byte if needed
pla          ;restore A to the previous saved value, our text character. ALWAYS remember every PUSH instruction needs a matching PULL before the end of the routine or the game will almost certainly crash.
"My watch says 30 chickens" Google, 2018

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Re: Text Routine
« Reply #12 on: July 04, 2013, 01:58:35 pm »
Thank you very much!