TMapSP

Discussion of the technical aspects of patching Sakura Taisen.
Post Reply
User avatar
NoahSteam
Site Admin
Posts: 55
Joined: Mon Jun 18, 2018 11:16 pm

TMapSP

Post by NoahSteam » Wed Jul 11, 2018 3:40 am

Image

TMapSP.bin has a bunch of sprites used during the overhead theater view. These are once again 4bit images. The addresses and the sizes for them are stored in a lookup table in SAKURA at 0x0001EBF4. Here is how the data for the images is stored in the SAKURA file:

Code: Select all

struct SakuraLut
{
     unsigned short addressInTmapSP;
     unsigned char  reserved1;
     unsigned char  reserved2;
     unsigned char  width;   //Width has to be multiplied by 8 to get the actual width of the image
     unsigned char  height;
     unsigned char  reserved3;
     unsigned char  reserved4;
};
And here is the actual lookup table within SAKURA.
Image

Fitting It All Into Memory
There is a slight difficulty into translating these images because of the way everything is loaded into memory. Unfortunately there is a file loaded almost directly after TMapSP into memory. So when creating translated images, we have to make sure that the sum of all of the new images doesn't exceed the original size of the TMapSP file, otherwise when the next file loads, it will overwrite the end of the new TMapSP file.

You see, TMAPSP.bin will be loaded at 0x00244000 and it is is 0xCF5F bytes long. Meaning it ends at 0x00250F5F. The next file (the face file) is loaded at 0x00251000. This mean we only have a 161 bytes to expand on.

This appeared to create a bit of a challenge because some of the translated images have to be much longer than the original images which only had a few kanji characters in them. For example the following image is translated as "Night Watchman's Room".
Image

Try fitting all of that in that little box!

At first I tried changing the address at which the next file is loaded but this didn't completely work and it would have actually required me to shift other files as well. Instead I went back to translating all of the images and reducing the boxes as much as I could white still keeping the font at a good size and seeing how close that got me. Then I realized that there is a bunch of dead space at the bottom of the images, usually 4 pixels. So I just went ahead and reduced the images form widthX24 to widthX20. That got some space back. Another thing was that there are two images which end up translating to "To 1st Floor". Instead of writing them both out to TMapSP, I just wrote out one and pointed both entries in SAKURA to that. At the end, the translated TMapSP file sits at 0xCBEF bytes, which is actually smaller than the original :)

Btw, this is how the image above ended up when translated. Notice the unnecessary green transparent pixels have been removed.
Image

Post Reply