Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Editing compressed tiles

Reply to topic
Author Message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14744
  • Location: London
Reply with quote
Editing compressed tiles
Post Posted: Tue Nov 06, 2012 9:58 pm
Last edited by Maxim on Sat Mar 23, 2013 2:05 pm; edited 1 time in total
mk1995 recently asked me for help using my Tile Decoder to edit the font in Alex Kidd in Miracle World to add German accented characters for translation. I thought I'd post it publicly in case it helps others.

However, I'd like to say that Tile Decoder is a bit rubbish - it lacks some simple functionality that would make it a great deal easier to perform this task. There are alternative ways to do it, but I'll just cover this one. Note also that this only covers games using the "Phantasy Star" style compression - which is a lot of them.

1. Locate and decompress the tiles

Get Tile Decoder, drag/drop the ROM onto it and press Search until you find the tiles. I see text in these tile sets:

13332 Title screen
172B1 Font

I'm going to edit the font.

2. Get the tiles in a paletted image

This is a bit annoying. I took a screenshot of the tile decoder. Then I made it an 8-bit image, and arranged the palette so it had the colours in the same places as the palette shown in the decoder: grey in position 1 and red in position 6. Here's that image:



I use Paint Shop Pro 7 for controlling my paletted images.

3. Edit the image in your image editor

Here's what I made - I replaced two tiles with some German characters.



4. Compress it using BMP2Tile

Get BMP2Tile. Load the edited image in it, go to the Tiles tab, deselect "remove duplicates" (we want to keep the tiles in the order they are there) and then save in "Phantasy Star RLE" format.

5. Check the size

Here's the tricky part: you have to make sure the edited tiles are not bigger than the original data, after compression. However, Tile Decoder doesn't tell you how big they were :( What I did was grab a hacked-up version of Tile Decoder I had hanging around that told me that the original font was 1442 bytes - but I can't release that right now. My edited version compresses to 1433 bytes, which is smaller, which is OK. If it's bigger, I might try blanking some other unused characters to improve the compression.

6. Replace the font data in the ROM

In a hex editor, copy the data from the .pscompr file into the ROM at offset 172B1, making sure to use an "overwrite" setting.

7. Test

Load it in an emulator and see what you get:



It works - so I could then work on editing the script to use the replaced punctuation characters and they should then show up.




In conclusion, Tile Decoder is rather lacking - it ought to let me export the decoded tiles to a suitable PNG file, and report the compressed data size, and then BMP2Tile makes it pretty easy to do the rest.
font-german.png (722 B)
font-german.png
akmw-01.png (6.04 KB)
akmw-01.png

  View user's profile Send private message Visit poster's website
  • Joined: 06 May 2012
  • Posts: 53
  • Location: France
Reply with quote
Post Posted: Mon Nov 26, 2012 11:48 am
Hi,

Just to add some information, thanks to Maxim's information you can also do it with Master Tile Converter (http://jmimu.free.fr/mastertileconverter/).
Maybe it's a little more convenient :

- load the ROM
- go to offset 172b1 (or before)
- click on "find next compressed tiles"
- File>Export picture
- edit the BMP file in GIMP or equivalent
- Compression>Compress picture
- say how many tiles you want to compress (since the BMP is 16 tiles wide), check if the size is less than original (all is written in the file name); the file compr_tmp.dat is created
- make sure you are at offset 172b1
- File>Import compressed data, choose compr_tmp.dat
- to update display click on "return to ROM" the "find next compressed tiles"
- File>Save rom (the checksum is upated)
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14744
  • Location: London
Reply with quote
Post Posted: Mon Nov 26, 2012 6:57 pm
Awesome, now I don't have to update my program :)

Bug: mingw10.dll is required. I got it from one of those dodgy DLL websites and it seems not to have a virus in it :)

Some feature requests:

- Read palette from ROM - most games have them as raw data
- Make the scrollbar work (in 16 tiles mode)
- A "bookmark" list. I implemented this in an unreleased tool I have, as a text file with lines like
$1c000 Stage 1

so I can double-click to load that data. Then you can map out the ROM and reload the file later. I had one file per data type (tiles, palette), you might also want some control over the compression etc. It's useful for loading various palettes to see which matches the tiles. The text files were editable from inside the program.
- Non-compiled-in compression support - so people can code up and share codecs for other compression systems. Binary APIs are hard to do cross-platform, so how about a scripting engine (Lua, Python, etc are quite embeddable) to allow people to contribute support for various algorithms?

The compression stage can be tricky to get "optimal" - there are a few things you can do with the PS compression to squeeze a few more bytes than Sega managed. Did you use my code for that? (Did I release it?)

For the false positive matches: are you rejecting places where the bitplanes decode to non-matching lengths? I think my one doesn't and it would clear up many of the bad matches.
  View user's profile Send private message Visit poster's website
  • Joined: 06 May 2012
  • Posts: 53
  • Location: France
Reply with quote
Post Posted: Mon Nov 26, 2012 9:11 pm
Thank you for your remarks.
win_qt_dll.zip has been updated to include mingw10.dll.

I didn't thought about adding palette reading since I don't know how you can find its address. Is it easy to get it from Meka ?
I thought about using this software without knowledge of ROM organization. But it sure is interesting, and even more with a bookmark list.

I don't know what you mean by
Maxim wrote
- Make the scrollbar work (in 16 tiles mode)

I want to make the scrollbar work for compressed data, but you can work without it since the extracted BMP will show all consecutive decompressed data.
For uncompressed data the scrollbar is not precise enough to record the position in the rom with one byte accuracy. Maybe you mean that the scrollbar unity can represent 16 tiles. Good idea!

About new compression support, since it's open source, the simplest way may be to insert it directly to the code. But I have some reorganization to do to simplify that.

For the compression tricks, I tried the naive way and I wasn't as good as yours or SEGA's. So I made some retro-engineering, and now it's equivalent to you I think. I didn't find the source of BMP2Tile. :)

To find compressed data I check if I can decompress 4 bitplans with the same size (and the size is not too small). I may have to check if the length is a multiple of the size of 1 tile. Good idea!
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2006
  • Posts: 80
Reply with quote
Post Posted: Mon Mar 12, 2018 7:57 pm
Can you please add support for the gamegear game The Berlin Wall? I'm interested in editing the font and the title screen. Thank you.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14744
  • Location: London
Reply with quote
Post Posted: Mon Mar 12, 2018 8:36 pm
Do you have any tech info on it? Editing title screens is usually not trivial.
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2006
  • Posts: 80
Reply with quote
Post Posted: Mon Mar 12, 2018 9:50 pm
Maxim wrote
Do you have any tech info on it? Editing title screens is usually not trivial.


Sorry, but I don't have. I can't see any graphics in any tile editor. I've also tried your tool to find compressed tiles but without result. I've also tried master tile converter without luck.
  View user's profile Send private message
  • Joined: 06 May 2012
  • Posts: 53
  • Location: France
Reply with quote
Post Posted: Wed Mar 14, 2018 8:06 pm
Hi,
I took a quick look at it, and as you said there is no "Phantasy Star"-like compressed images in this game.

I'll be glad to add this compression support in MTC if someone finds out how those tiles are compressed, which may require some debugger investigation...
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2006
  • Posts: 80
Reply with quote
Post Posted: Wed Mar 14, 2018 8:32 pm
jmimu wrote
Hi,
I took a quick look at it, and as you said there is no "Phantasy Star"-like compressed images in this game.

I'll be glad to add this compression support in MTC if someone finds out how those tiles are compressed, which may require some debugger investigation...



It would be great if you add support for this game.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14744
  • Location: London
Reply with quote
Post Posted: Wed Mar 14, 2018 11:35 pm
I had a look at it, it's something rather complicated and not like anything I've seen before...
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14744
  • Location: London
Reply with quote
Post Posted: Thu Mar 15, 2018 11:25 pm
I've documented the format at http://www.smspower.org/Development/Compression#BerlinWallLZ if someone wants to have a go. I didn't check how tilemaps are loaded.
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2006
  • Posts: 80
Reply with quote
Post Posted: Sun Mar 18, 2018 10:17 am
Maxim wrote
I've documented the format at http://www.smspower.org/Development/Compression#BerlinWallLZ if someone wants to have a go. I didn't check how tilemaps are loaded.


Thank you. Any chance you'll implement this in your software?
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!