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

Author Topic: Removing 'repeated' tiles from translation (WonderSwan)  (Read 4231 times)

USC

  • Submission Reviewer
  • Full Member
  • *****
  • Posts: 238
  • Obviously Outdated
    • View Profile
Removing 'repeated' tiles from translation (WonderSwan)
« on: March 14, 2012, 04:25:03 pm »
Hello,

I'm trying to translate an old Digimon WonderSwan game I saw in the abandoned section. Thanks to the previous hacker and the original WonderSwan's similarity to the GameBoy as far as text and tiles go, I've been able to make some good progress.

I've already fixed the functionality of the name entry screen, so when you click a letter it adds that instead of katakana to the player name. However, the appearance leaves something to be desired...


As you can see, the left-half of the 'a' is appearing next to the 'f'. Ideally I would like to remove this. My question is, is it likely this can be done with just a hex editor (IE: Figure out what the tiles hex addresses are, keep trying combinations like '30 31 01 32' until I find that area, and then change the '01' to remove the duplicated tile), or will actual assembly programming be necessary? I've been trying the hex way without luck, and I'd like to know if I'm going about it wrong or just need to keep struggling.

Any help would be appreciated. Thank you.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6906
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Removing 'repeated' tiles from translation (WonderSwan)
« Reply #1 on: March 14, 2012, 08:43:25 pm »
It looks like it probably is reusing parts of tiles.
Yes, you'd likely need to figure out the corresponding 8x8 tile numbers for each part of a tile, and look for matches.
(although I'm not sure how you'd do this, as I don't know if there are any debugging emulators with tile viewer functionality)
"My watch says 30 chickens" Google, 2018

Romsstar

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Re: Removing 'repeated' tiles from translation (WonderSwan)
« Reply #2 on: March 14, 2012, 08:47:43 pm »
Hmm nice to see that someone is picking up a Digimon Game,
it doesn't happen often :D

Thought I was the only one haha.

But it would be nice if you could name which one it is as we have two in the database.
Anyways the problem you are encountering here is classic.
Obviously Katakanas use all the same width size.

While the ABC is not. Ultimately this will lead to more letters doing this.
Now since we are dealing with the Naming Entry Screen you could check out the width of the Katakana
an example approach would be to check for the letters in a tile viewer (Tile Molester is powerful if you know how to use it.xD)
, figure out the width and then,
set a break or if I'm not mistaken a hook point in a Debugger like http://www.romhacking.net/utilities/338/

This would lead sooner or later to figuring out the tile size. Now if for every letter the tile size is defined singularly, tedious as it might be you could
do a workaround and define for every letter a custom tile size.
If there is one tile size for every letter (which I think is likely) you could try to half it and see if that would work.

If not, I guess this is where ASM would come in as you would have to write a Vfw unless the hacker who abandoned the project has taken care of it.

I haven't seen the game nor do I know which one you are referring to so this is just some very general advice which most likely won't be applicable to the game unless you tell which one it is,
then I might be able to help better.

USC

  • Submission Reviewer
  • Full Member
  • *****
  • Posts: 238
  • Obviously Outdated
    • View Profile
Re: Removing 'repeated' tiles from translation (WonderSwan)
« Reply #3 on: March 16, 2012, 11:24:01 am »
Thanks for all the information!

@King Mike: Yeah, I've gotten spoiled with all the tools available for NES and GameBoy roms; this is a challenge of a different sort.

@Romsstar: Haha, I had a bit of nostalgia, started looking up Digimon and found out a whole series of side story had never been translated, so I wanted to give it a shot. The one I'm currently working on is Tag Tamers, but they all seem to have been built off their predecessor, so figuring out one will help solve the others.
Judging from TLP and the game itself, each 'letter' on the name entry screen is made up of 2x2 tiles, each one an 8 by 8.

I'll need to learn more about tracing and breakpoints I guess (I understand how to set one to stop when the game tries to access a certain address, but I'm not fully understanding how to make it stop when it draws tiles of a certain size). Also, if you don't mind me me asking, what's a Vfw?



Romsstar

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Re: Removing 'repeated' tiles from translation (WonderSwan)
« Reply #4 on: March 16, 2012, 11:53:07 am »
Quote
VWF (Variable Width Font):

Japanese Kanji are always square and of the same size. Latin characters though are of different sizes (e.g.: “w” and “i”). This produces 2 problems: First it just looks bad to have words displayed like “wi zar d.”. The other problem is that you waste a lot of space. Only a limited amount of letters can be displayed per line and in sentences with lots of “i”s and “l”s you’ll run out of space even though you could display a lot more. To get around these problems ROM hackers implement a so-called variable width font. They alter the text drawing code so small characters take only the space they really need. This is a complex hack that requires profound assembly skills.

Taken from the Dictionary of RH.net

I'll take a look at Tag Tamers later then and see if I can help

Spikeman

  • Hero Member
  • *****
  • Posts: 1063
  • *unce unce unce*
    • View Profile
    • None at the moment, check out my Last.fm page instead?
Re: Removing 'repeated' tiles from translation (WonderSwan)
« Reply #5 on: March 16, 2012, 07:11:18 pm »
I don't think writing a VWF applies to the situation here. The letters you're trying to change aren't displayed as sprites are they? What you need to change is the tile map. I'm not entirely certain how tile maps work on Wonderswan, but the general principle should be the same. Looking at the picture, it looks like each character takes up four 8x8 tiles. So "a" might be represented by tiles 00, 01, 02, 03. The problem you're having with "f", is that in the right half of character, tiles 02 and 03 are reused. The solution is to change the tile it uses in the tile map. In this case, it looks like you just need a blank tile, so say you found a blank tile at tile number 1F, you could just change those two tiles in the map to 1F.

A quick search of the document section turns up this: http://www.romhacking.net/documents/366/

Quote
   Tile size       - 8 x 8 dots , 16 bytes/tile (4 col modes) or 32 bytes/tile (16 col modes)
   Map size        - 256 x 256 pixels (32 x 32 tiles)
   Layers          - Two layers - Background and Foreground (top layer)
   Maps locations  - Selectable using port $07
   Tiles locations - Fixed, two banks - one at $4000 , second at $8000
   Map format      - Each position in the map is defined by one word:
                      bits 0 - 8   - Tile number (0-511)
                      bits 9 - 12  - Palette number (0-15)
                      bit 13       - WS = unused / WSC = tile bank
                      bit 14       - Horizontal flip
                      bit 15       - Vertical flip
   Tile formats    - Depends on video mode (port $60)


10. I/O PORTS (port number /initial value / description)
 - $07 - $26 - Determines the location of the foreground and background screens in RAM.
                Format:
                 bits 7-0 : ffffbbbb
                 bit 7-4 - Determines foreground location (address is 0ffff000 00000000)
                 bit 3-0 - Determines background location (address is 0bbbb000 00000000)
 - $60 - $0A - video mode
               Meaning of bits 5-7:
                765
                ---
                111   16 col/tile 'packed' mode   -  tiles like in Genesis, 16 col/tile
                110   16 col/tile 'layered' mode  -  tiles like in GameGear, 16 col/tile
                010    4 col/tile                 -  the same as mono (below) but using color palettes, 4 cols/tile, one tile = 16 bytes, WSC only
                000    4 col/tile mono            -  tiles like in GameBoy,
              [bit 7 = 16/4 color/tile , bit 6 - color/mono mode, bit 5 - 'packed' mode on/off]

So it looks like the best way to find where the tile map is would be to set a breakpoint on port $07, then see where it breaks when the screen is loaded. This will give you the address of the tile map. From there, you can set a breakpoint on the actual tile map data, and see how the game is writing it. Usually, games will just copy the data from a buffer in RAM or straight from the ROM. With any luck it will be straight from the ROM and you'll be able to edit the tile numbers with a hex editor. If it's building the map data in some sort of buffer first, you might have to do some assembly hacking.

If you need any more specific tips, ask away.
Open Source Hacking Projects: Guru Logic Champ, Telefang 2, (Want more? Check out my GitHub!)

Romsstar

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Re: Removing 'repeated' tiles from translation (WonderSwan)
« Reply #6 on: March 17, 2012, 05:57:12 am »
@Spikeman: This might apply to the Box displayed here just as one possible solution but what I think is, that the letters in the Box most likely display also the Font the game uses.
This happened to be the case in the Digimon World Game for PSX for e.g.
And in any case sooner or later a Vwf probably has to be implemented. And that would solve also this issue.

Your suggested solution might work as well.
Although in my opinion it would just double the work doing it for the box first while the Vwf could solve two issues with one hack.
But I might be wrong about it, but with the amount of dialogue the game deals taken into account it will be inevitable to write a Vfw anyways.

USC

  • Submission Reviewer
  • Full Member
  • *****
  • Posts: 238
  • Obviously Outdated
    • View Profile
Re: Removing \'repeated\' tiles from translation (WonderSwan)
« Reply #7 on: March 17, 2012, 09:22:34 am »
Wow, thanks everyone for all your help! I didn't expect this much.

@Spikeman: That's really helpful! The WonderSwan emulator I'm using has a way to turn off layers and the font disappears when you turn off the 'foreground' one, so you're probably right about that. Hopefully I have some time today to really dig into this.

@Romsstar: Actually, the big letters used for the name entry screen are only used there (as far as I know). The 'RYU' in the upper-left corner of my screenshot is the font used in the in-game dialogue boxes, and that all seems to work fine. But I'll definitely need to learn more about Vfws anyway if I want to get better at hacking.

March 20, 2012, 10:12:32 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Hey all. Just an update on my progress.

Thanks to what you've all taught me, I managed to find what hex values the tiles were being represented by (seems there was a four-bit pointer in the pattern '49 08 4A 08 4B 08 4C 08 4D 08', part of the first line of letters). Changing the sequence in a save state fixes the repeated-tile problem on the screen.

However...I can't find this sequence in the actual rom. :(
Well, I can find *that* string multiple times because it's sequential, but they never contain, say, "08 50 08 51 08 FC 08 48 08 53", which is one of the repeated tile areas.

I've tried reversing the bits and using relative search for the 'constant' 08, but to no avail. Is it possible there's some kind of compression being used that I'd have to reverse-engineer?

On the bright side, what I've learned here has helped me clean up a few other hacks I've been working on.
« Last Edit: March 20, 2012, 10:12:32 pm by USC »

xdaniel

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • DigitalZero Domain
Re: Removing 'repeated' tiles from translation (WonderSwan)
« Reply #8 on: March 26, 2012, 12:41:55 pm »
* xdaniel dusts off his account here, as well as his work from, uh... up to 9 years back if the "last modified" date on ex. the Japanese table is to be believed...

In this case, the tilemap comes right after the actual tile data, same as in D-1 Tamers come to think of it. Tile data begins at 0x114DA8, after that, at 0x1159A8 follows the tilemap's width and height (or that's what it looks like; "1A000C00", so 26 tiles wide, 12 tiles high, tho I never tried to change this), and after that, at 0x1159AC, you have the map - two bytes per tile, I believe simply as per WSTech, which Spikeman posted an excerpt of.

Here's a screenshot showing the whole thing; the modified tiles, the map data selected in the hex editor, and the end result:



(...kinda makes me wanna pick up D-1 again, tho I'll just end up abandoning it again after a week or so -.-)
cu xdaniel