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

Author Topic: [Technical] Uncompressing Legend of the Mystical Ninja main font [partly solved]  (Read 1753 times)

jackic

  • Jr. Member
  • **
  • Posts: 24
    • View Profile
Greetings,

I am trying to translate this game and I would like to add proper spanish punctuation to the dialog font.

I am not that knowledgeable when it comes to compression and I had partial success using the "Konami SNES decompressor" tool found in this very site, I managed to find, extract, modify and reinsert without issue one of the game's fonts, the one located at 0x78000. But I can't find the main one used on the game's dialogs.

Could anybody give me a hand here? I really don't know if all the game assets use the same compression but I have had success extracting several different graphics in this game with the same tool.

Any help / tips would be greatly appreciated.

Thanks.
« Last Edit: December 13, 2018, 09:41:41 am by jackic »

phonymike

  • Jr. Member
  • **
  • Posts: 19
    • View Profile
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font
« Reply #1 on: November 27, 2018, 06:23:02 pm »
tools used: Geiger's Snes9x, vSNES, and Lunar Address.


I used snes9x to make a savestate when the font was on screen. Then used vSNES MemViewer to see that the font in VRAM was at location A000.
Since VRAM locations are double the location we write to, we're looking for writes to location 5000 in the next step.

Using snes9x, under Special Tracing, click DMA with the game running. Lots of logs fill up the console but we're looking for VRAM 5000.

Code: [Select]
DMA[0]: CPU->PPU Mode:1 0x7E2000->0x2118 Bytes:400 (inc) V:054 VRAM: 5000 (1,0) word
DMA copies the decompressed font from location $7E2000 to $2118 (VRAM), so the game must write to $7E2000 as it's decompressing the font. So set a write breakpoint for $7E2000 to catch where the game is getting this data. Click Show Hex in snes9x and view the RAM starting from 7E2000. Each time you click run with this breakpoint you'll see this temporary buffer fill with new uncompressed data.



Back into vSNES, using the HexEditor, click B: VRAM at the top to view VRAM, and type in address A000. Now you can see the uncompressed data as it will be in VRAM.

As you look in the Hex Editor in snes9x, keep clicking Run until you see data like it is in vSNES. I set the $7E2000 write breakpoint at the title screen, press start, then click Run 44 times before the data in snes9x matches that of vSNES. Looks like there's a lot of compressed stuff in this game.

In the log window of snes9x, all the writes are coming from code located somewhere at $009Fxx and $00A0xx which is most likely the decompression routine. For the decompression routine to know what to decompress, the game must give it the source ROM location somewhere.



So I go to the title screen, enable the $7E2000 write breakpoint, and click Run 43 times. Then with Trace Once checked, I click CPU under Logging, and click Run again. Make sure the data popped up in the Hex Editor, then uncheck CPU to stop logging.

Looking at the log, we're looking for ROM reads, you'll see the game load a 16 bit value ($B8B0) and then an 8 bit value ($0F) from ROM address $02:8206. Use Lunar Address to verify that it's a ROM location, it'll give you a PC file location if it is. Snes9x will tell you this game is a slowrom lorom btw. That ROM address looks like some sort of pointer table.

Code: [Select]
$00/9F48 BF 00 00 02 LDA $020000,x[$02:8206] A:0000 X:8206 Y:FFFE D:1C00 DB:7E S:1ED6 P:eNvmxdIzc
$00/9F4C 85 00       STA $00    [$00:1C00]   A:B8B0 X:8206 Y:FFFE D:1C00 DB:7E S:1ED6 P:eNvmxdIzc
$00/9F4E E8          INX                     A:B8B0 X:8206 Y:FFFE D:1C00 DB:7E S:1ED6 P:eNvmxdIzc
$00/9F4F E8          INX                     A:B8B0 X:8207 Y:FFFE D:1C00 DB:7E S:1ED6 P:eNvmxdIzc
$00/9F50 E2 20       SEP #$20                A:B8B0 X:8208 Y:FFFE D:1C00 DB:7E S:1ED6 P:eNvmxdIzc
$00/9F52 BF 00 00 02 LDA $020000,x[$02:8208] A:B8B0 X:8208 Y:FFFE D:1C00 DB:7E S:1ED6 P:eNvMxdIzc
$00/9F56 85 1F       STA $1F    [$00:1C1F]   A:B80F X:8208 Y:FFFE D:1C00 DB:7E S:1ED6 P:envMxdIzc
$00/9F58 29 7F       AND #$7F                A:B80F X:8208 Y:FFFE D:1C00 DB:7E S:1ED6 P:envMxdIzc
$00/9F5A 85 02       STA $02    [$00:1C02]   A:B80F X:8208 Y:FFFE D:1C00 DB:7E S:1ED6 P:envMxdIzc


So the 16 bit address is stored at $00:1C00, and the 8 bit bank stored at $00:1C02. In SNES memory that makes a 3 byte pointer to the start of the compressed data.

Code: [Select]
$00/9F63 A7 00       LDA [$00]  [$0F:B8B0]   A:B80F X:8209 Y:FFFE D:1C00 DB:7E S:1ED6 P:eNvmxdIzc



So after all that your compressed font data is at snes memory address $0F:B8B0. Use Lunar Address to get the pc file location that Konami SNES Decompressor wants.

jackic

  • Jr. Member
  • **
  • Posts: 24
    • View Profile
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font
« Reply #2 on: November 27, 2018, 10:22:28 pm »
Thank you so much for all the trouble you went through to help me!

I did not know where to start, now I do XP.

SO fat, I could extract the font you pointed out, the one from the intro, but this game has 3 of them and with that one now I have two of them.

I tried to replicate the method you explained but some things I just can not understand, I guess I have to read more, I tried vsnes but it doesn't like my snes9x save states, I tried geigers snes9x but it won't run on my computer because of a weird visual basic error. So I tried  bizhawk that is the only debugger I have handily, so far, the only thing I know for sure, I think, is that the font I need is decompressed at 8400 in vram.




So I'm guessing that we are looking for writes to 4200? I snatched my wife's computer and Geiger's snes9x seems to work there but my life is on the line if I am caught using this laptop...

This is what I found in the log so far:

DMA[0]: CPU->PPU Mode:1 0x7E2000->0x2118 Bytes:400 (inc) V:054 VRAM: 4200 (1,0) word
$00/9F3E 97 03       STA [$03],y[$7E:2000]   A:0000 X:0000 Y:0000 P:envmxdIZc
$00/9FE5 91 03       STA ($03),y[$7E:2000]   A:0000 X:0021 Y:0000 P:envMxdIzC

So far so good but I don't seem to be able to keep going and I really do not understand some of the concepts as I am really a noob, no, even noobs think I am iliterate when it comes to romhacking XD.

I will try again tomorrow, first to replicate your results and then find the other font but, would you be so kind as to help me out finding that particular font?

Thanks againg

Mauron

  • Sr. Member
  • ****
  • Posts: 477
    • View Profile
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font
« Reply #3 on: November 27, 2018, 10:31:31 pm »
This may address your error with Gieger's debugger: http://geigercount.net/crypt/vcredist_x86.exe
Mauron wuz here.

jackic

  • Jr. Member
  • **
  • Posts: 24
    • View Profile
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font
« Reply #4 on: November 28, 2018, 06:54:40 am »
This may address your error with Gieger's debugger: http://geigercount.net/crypt/vcredist_x86.exe

This has actually solved my problem, I installed the vcredist from microsoft's website but it did not work, that one, on the other hand, did. Thanks a bunch!

Also:



I followed the instructions by the book but I didn't get the same results as you BUT, your lessons gave me an idea of how to tackle the problem and with a bit of bruteforcing, now I have all the three fonts at my disposal, I already modified and inserte one of them:



Thanks, I'll make sure to give you proper credit!

FlashPV

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Terminus Traductions
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font [solved]
« Reply #5 on: November 29, 2018, 09:25:05 am »
It would be cool to swap the title screen with a variant of the japanese version.

VicVergil

  • Hero Member
  • *****
  • Posts: 707
    • View Profile
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font [solved]
« Reply #6 on: December 01, 2018, 11:18:48 am »
Do you still have the results of your research about compressed graphics offsets, if you want to share them?

It would be cool to swap the title screen with a variant of the japanese version.

Two of the Game Boy Color games had English localizations with a logo that's very similar to the Japanese version and properly resized to fit the tiny GB screen. Only problem is that it's squished horizontally, but that affords space on the bottom of the logo for the game's subtitle. That design can be reused probably.

jackic

  • Jr. Member
  • **
  • Posts: 24
    • View Profile
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font [solved]
« Reply #7 on: December 01, 2018, 09:00:48 pm »
Sure,

these are the file offsets I found so far:

78000 font 1, menus
78f44 Ingame font, it has upper and lowercase letters even the though the game doesn't use the latter.
7b8b0 16x16 font game intro and credits
90000 1P/2P WINS graphics
8c4ef Lottery Graphics, does garble the graphics if reinserted even without modification so maybe the address is not correct
70000 STORE sign graphics

Graphics I haven't found and I really would like to modify:

1 player / 2 player / options menu, I have a table for that but I don't have enough letters for a spanish translation
The curtains on the inventory screen say KID YING and DR YANG instead of Goemon and Ebisumaru, this is the one I want to find the most as I REALLY want to get rid of that YING / YANG nonsense.

Any help on that will be greatly apreciated.

Thanks.

VicVergil

  • Hero Member
  • *****
  • Posts: 707
    • View Profile
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font [solved]
« Reply #8 on: December 02, 2018, 06:44:51 pm »
Thanks a lot.

The first ingame font you meant was originally a full hiragana + katakana + english upper case (similar in typography to Nintendo's official font for Super Mario Bros, in turn inspired by an Atari game) in the Japanese version.

In the US version, they wanted to use just the hiragana + katakana area to overwrite with a full (thin) english font, and used an incomplete lower font missing vowels because it's used in the password screen and Nintendo's guidelines mandated no vowels to prevent players from forming profanity words in passwords. That lowercase font is useless for a translation so to make one you have to change the old english upper case font they left untouched and unused in the US version.

You might as well change back the pizza graphics to rice balls and the various shops they scrubbed clean of all text, or food names.

jackic

  • Jr. Member
  • **
  • Posts: 24
    • View Profile
Re: [Technical] Uncompressing Legend of the Mystical Ninja main font [solved]
« Reply #9 on: December 03, 2018, 06:16:44 am »
Thanks a lot.

 That lowercase font is useless for a translation so to make one you have to change the old english upper case font they left untouched and unused in the US version.

I already modified that font(all the fonts actually), adding the missing letters and also adding tilde and Ñ, ¡, ¿ symbols.

You might as well change back the pizza graphics to rice balls and the various shops they scrubbed clean of all text, or food names.

If I find all the graphics involved, I will. So far I have the icons on the ingame inventory but I can't find the shop ones.

Thanks.
« Last Edit: December 03, 2018, 10:10:10 am by jackic »