News: 11 March 2016 - Forum Rules

Author Topic: [NES] Change the text appearance direction to Right-to-Left?  (Read 4599 times)

Kunio

  • Full Member
  • ***
  • Posts: 138
    • View Profile
[NES] Change the text appearance direction to Right-to-Left?
« on: April 22, 2014, 11:23:19 am »
Hi
I want to translate "Captain Tsubasa Vol. II - Super Striker (J) [!].nes" from Japanese to Persian
But there is a problem
Japanese is written from Left-to-Right but Persian is written from Right-to-Left
So for the fist step I have to change the text direction which appears from Left-to-Right to Right-to-Left
I made some progress already :

I go to a page that the text appears gradually from Left-to-Right.
Then I hit the Pause button and then Debug --> Name Table Viewer
By pointing the first character of the sentence I found some nice info : Tile ID : #$4B / PPU address : $2269
Debug --> Debugger --> add --> address : 2269 / Write / PPU Mem --> OK

Then I restart the game and Debug --> Trace Logger --> Start Logging

Then I found this :
LDA $05EB,X @ $05EC A:00 X:01 Y:01
STA $2007           A:4B X:01 Y:01

So 4B (hex value of the character) is coming from $05EC
I set a write break point for $05EC and I found this :
LDA ($4D),Y @ $A2AD A:A2 X:05 Y:00
.
PHA                        A:4B X:22 Y:49
.
PLA                        A:82 X:03 Y:49 S:4D
.
STA $05E9,X @ $05EC A:4B X:03 Y:49

So 4B is coming from $A2AD
Debug --> Hex Editor --> File --> Go Address --> A2AD --> Right Click --> Go Here In Rom File --> $62BD

I change the 4B to 4C to see if the first character changes, and yes that's it!

************************************

Then I set a Read break point for $A2AD, well nothing new I found this already :
LDA ($4D),Y @ $A2AD

Then a write break point for $2006 :

LDA $05EA,X @ $05EA A:02 X:00 Y:02
STA $2006           A:22 X:00 Y:02
LDA $05E9,X @ $05E9 A:22 X:00 Y:02
STA $2006           A:49 X:00 Y:02

$2249 is the PPU address and goes high on showing up every character, so I have to trace $05E9 and #$49
I set a write break point for $05E9 and I found this :
LDY $0053           A:4C X:22 Y:00
.
TYA                        A:22 X:00 Y:49
STA $05E9,X @ $05E9 A:49 X:00 Y:49

This shows that #$49 is coming from $0053
So I set a write break point for $0053 :
LDA $0051           A:22 X:03 Y:00
STA $0053           A:49 X:03 Y:00

Another write break point for $0051 :
LDA $004F           A:22 X:03 Y:00
STA $0051           A:49 X:03 Y:00

Another write break point for $004F :
$84CF:A9 49     LDA #$49                   A:08 X:03 Y:00
$84D1:85 4F     STA $004F = #$49           A:49 X:03 Y:00

Debug --> Hex Editor --> File --> Go Address --> 84CF --> Right Click --> Go Here In Rom File --> $04E0

I change #$49 to #$5C and I expect the sentence appears from somewhere near to the right edge of the screen, Yes that's it!

************************************

As I found before the PPU address goes high on showing up every character so I have to change something to make it go down
I look at ram address while the text appears and I found that $0053 goes high as the text appears so I set a write break point for $0053 :
$84F6:E6 53     INC $0053           A:82 X:05 Y:59

Debug --> Hex Editor --> File --> Go Address --> 84F6 --> Right Click --> Go Here In Rom File --> $0506
So I have to change E6 (INC) to C6 (DEC)
YES it worked! The text appears from Right-to-Left!

************************************

OK it is good so far!
But what is the problem now?
When the page changes the old text won't disappear!
But the new text appears just fine while overwriting the old text!
I seems after the first page, the game tries to clears the original place of the text on the left alignment of the screen.
Should I check for $2007 / $2006 / $2249 (Original PPU address of the) for anything like 00 or FF on them?
Any help would be appreciated.
« Last Edit: April 23, 2014, 12:36:25 pm by Kunio »

Pennywise

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 2428
  • Prepare thyself for holy judgment
    • View Profile
    • Yojimbo's Translations
Re: [NES] Change the text appearance direction to Right-to-Left?
« Reply #1 on: April 22, 2014, 05:20:45 pm »
This is highly game dependent, but the NES PPU was only designed to print left to right and up to down for vertical text. So if the game sets the PPU address for every character printed, it's possible to get around this, but if the game reuses any of the code you modified, it will jack things up. All I can say is that the routine that clears the screen's not working. I would recommend tracing/debugging the unmodified game to see what it does.

Kunio

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: [NES] Change the text appearance direction to Right-to-Left?
« Reply #2 on: April 23, 2014, 10:00:41 am »
Thanks for the answer.
I found out something :
It seems the text clear routine is bind to the PPU address of the first character
I followed the text clear routine and I reach to $04E0

I guess this is how the clear text routine works (X means clear) :
Left Alignment (Normal) :
| ABC.................. |
| XXX.................. |

Right Alignment (Hack) :
| ...............ABC... |
| ...............XXX... |

Inversion (Hack) :
| ..........CBA....... |
| ..............XXX... |

After inverting the text direction the clear routine starts from A and tries to clear forward which is already blank!
The clear routine writes 00 to 2007 in a loop, it uses the fact that PPU address goes high automatically

Any idea how to fix it?

April 23, 2014, 12:21:08 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Finally I had to cheat :  ::)
There is an Arabic translation of this game and it has the Text Direction hack so I compared it with the Original one :

From Original (Captain Tsubasa Vol. II - Super Striker (J) [!].nes)

Code: [Select]
$88B1:A5 54     LDA $0054 = #$09           A:80 X:F8 Y:22 S:4E P:NvUbdizc
$88B3:49 FF     EOR #$FF                   A:09 X:F8 Y:22 S:4E P:nvUbdizc
$88B5:18        CLC                        A:F6 X:F8 Y:22 S:4E P:NvUbdizc
$88B6:69 1F     ADC #$1F                   A:F6 X:F8 Y:22 S:4E P:NvUbdizc
$88B8:AA        TAX                        A:15 X:F8 Y:22 S:4E P:nvUbdizC
$88B9:A0 08     LDY #$08                   A:15 X:15 Y:22 S:4E P:nvUbdizC
$88BB:A5 4F     LDA $004F = #$49           A:15 X:15 Y:08 S:4E P:nvUbdizC
$88BD:29 E0     AND #$E0                   A:49 X:15 Y:08 S:4E P:nvUbdizC
$88BF:05 54     ORA $0054 = #$09           A:40 X:15 Y:08 S:4E P:nvUbdizC
$88C1:85 E6     STA $00E6 = #$10           A:49 X:15 Y:08 S:4E P:nvUbdizC

From Arabic Translation (Captain Tsubasa Vol. II - Super Striker (Ar) [Extraordinary].nes)

Code: [Select]
$88B1:A5 54     LDA $0054 = #$1B           A:80 X:F8 Y:09 S:4E P:NvUbdizc
$88B3:38        SEC                        A:1B X:F8 Y:09 S:4E P:nvUbdizc
$88B4:E9 05     SBC #$05                   A:1B X:F8 Y:09 S:4E P:nvUbdizC
$88B6:AA        TAX                        A:16 X:F8 Y:09 S:4E P:nvUbdizC
$88B7:A0 08     LDY #$08                   A:16 X:16 Y:09 S:4E P:nvUbdizC
$88B9:A5 4F     LDA $004F = #$5B           A:16 X:16 Y:08 S:4E P:nvUbdizC
$88BB:38        SEC                        A:5B X:16 Y:08 S:4E P:nvUbdizC
$88BC:E5 54     SBC $0054 = #$1B           A:5B X:16 Y:08 S:4E P:nvUbdizC
$88BE:18        CLC                        A:40 X:16 Y:08 S:4E P:nvUbdizC
$88BF:69 06     ADC #$06                   A:40 X:16 Y:08 S:4E P:nvUbdizc
$88C1:85 E6     STA $00E6 = #$10           A:46 X:16 Y:08 S:4E P:nvUbdizc

It works fine for me, but I can't understand how it really works, so can anyone explain it for me?
« Last Edit: April 23, 2014, 12:21:08 pm by Kunio »

VicVergil

  • Hero Member
  • *****
  • Posts: 738
    • View Profile
Re: [NES] Change the text appearance direction to Right-to-Left?
« Reply #3 on: April 23, 2014, 12:29:22 pm »
Well, it's an idea but I don't have an idea how to implement it
Write a new routine elsewhere that displays blank/black tiles over the whole surface of the text, regardless of how much text was actually written?

Kunio

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: [NES] Change the text appearance direction to Right-to-Left?
« Reply #4 on: August 08, 2017, 09:35:14 pm »
Here is a video tutorial on how to do this kind of hack, maybe someone find it useful :
https://youtu.be/jEUYBSn2YIk
« Last Edit: August 08, 2017, 09:40:40 pm by Kunio »