Hacking Blaze Union

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
Blaze_Union_key_visual.jpg

Tactics / strategy game for PSP.

flame1234 called for help!
...but no help came.

I tried QuickBMS. This script: http://aluigi.altervista.org/bms/cpk.bms
Results: Cannot unpack the whole fie.

I tried CriPakTools: https://github.com/esperknight/CriPakTools
Results: A bunch of files with numbers, but no names. 3339 of them. to be specific.
I used the precompiled binary which isn't the latest version. I don't know how to compile code.

For the first time, I realized some of these files contain the text. For example #2149 is Map 1. SHIFT-JIS encoded.

Anyway, how do you unpack the text?
--------------------------------------------------
I am completely unfamiliar with CPK. I have to look at some CPKs and the BMS script that unpacks them to know what's going on.

I found this discussion: http://zenhax.com/viewtopic.php?t=1067
The creator of BMS is saying filenames aren't stored in the CPK file for G Generation Overworld PSP CPK file.

Here's some discussion about CPK. But I couldn't really follow it.
http://www.romhacking.net/forum/index.php?topic=18454.0
--------------------------------------------------
So it's possible that this game uses file numbers rather than file names, right?

EsperKnight's tool has a function to insert files, so I think I'll try it.
 
Last edited by flame1234,
  • Like
Reactions: Pablitox

Scorp

Well-Known Member
Member
Joined
Sep 23, 2010
Messages
248
Trophies
0
XP
296
Country
Kazakhstan
@flame1234 there is no filenames in this archive, so that's correct that you do not see the names. You can pack it back with leaked version of CriPack I believe (at least worked for me for all the other things I ever tried).
For text unpack no other way apart going in debugger and see how it unpacks it... I am not really sure if I can help you debugging the text routine (as kind of hard to debug via touch tablet :)), but should not be too hard - dump the memory, find the text and put a write breakpoint there => so you would get where it get extracted. At least I think so.
 

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
Test 1: Rebuild and reinsert
Well, it's not that easy, but I was able to do it. Not much to show here. I used the "move to end of ISO" trick, see here for the details.
The new data.cpk is lots bigger (+10%) than the original. Should I be worried about this? The game seems to be able to read it.
The game seems to know the LBA of data.cpk without having to be told (unlike some other games I worked on). I wonder how that works.
Next: CriPackedFileMaker: The windows application is super slow and the command-line version is super fast. What's up with that?

Test 2: Replace w/ SHIFT-JIS (success)
ULJM05503_00000.jpg

Test 3: Replace w/ fullwidth English (success)
ULJM05503_00001.jpg

Test 4 *holds breath*: Replace w/ halfwidth English (partial success)
ULJM05503_00002.jpg

My actual string here was abcdefghijklmnopqrstuvwx
It seems characters that would go outside the dialog box will not display.
 
Last edited by flame1234,

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
This is what the localized Yggdra Union (the previous game) looks like:
ULUS10368_00000.jpg

I don't think I can do this without VWF. It doesn't look very good as is.
I think I can create script dumps quite easily. I don't know where the game is reading character data from. I might even be able to do variable-length insert, it doesn't look all that hard.
The character name might be an image, I'm not sure.

Next tasks:
1) Find where the x-offset is computed. I'll struggle with this one- there's no easy way.
2) Find the font file and edit it (left-align the characters).

#2 I think I can make some progress on.
The PTX files look like image files, BMP files to be specific. File # 2148 is an example (but there are a lot of them). I see a color table and a bitmap. What I don't understand is the PTX header. Is there an image x and y size in the header somewhere? I didn't see anything obvious.
For #2148, the file size is 0x4720 and the bitmap size is 0x4600. Here's the header:
1.PNG


Offset 0: Signature
????
Offset 0x18: Start of color table?
Offset 0x1F: Start of bitmap data?
 

Scorp

Well-Known Member
Member
Joined
Sep 23, 2010
Messages
248
Trophies
0
XP
296
Country
Kazakhstan
The new data.cpk is lots bigger (+10%) than the original. Should I be worried about this? The game seems to be able to read it.
The game seems to know the LBA of data.cpk without having to be told (unlike some other games I worked on). I wonder how that works.
My guess is that Cri library provide access by file number, so no matter how you changed ISO (I think you can even rebuild it from scratch using isotools) or repacked cpk - it should work.
And you better not use GUI version, I always use console one with .bat files, works perfectly and quite fast.

For characters limit there could be an output buffer for string, limited one, as from your screenshots looks like there is more space available, but it does not output.

PTX looks like a texture package. Seems to figure out the important values you should use the GE Debugger in PPSSPP, I believe Jamrules explained in other thread how to find out the actual placement.

VFW is really not hard, when you can find the actual font output. But are you sure this is not the VFW already? As looks like PSP standard font, not custom one.
 
Last edited by Scorp,

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
PTX
Offset 0: Signature
Offset 0x04: ???
Offset 0x06: Related to image width. Seems to always be 0x08 number "aligned" to 0x10. Also seems to be "how wide the PSP thinks the texture is"
Offset 0x08: Related to image with. Actual width, maybe? And then it is padded to the 0x06 number?
Offset 0x0A: Image height
Offset 0x0C: ???
Offset 0x18: Start of color table
Offset 0x1F: Start of bitmap data

In #2147 (see header above) there are 0x4600 worth of bitmap data. 0xA0 * 0x70 = 0x4600.
Okay, so what is going on? Really, you should multiply 0xA0 and 0x6C, getting 0x4380. You are 0x280 short. 0x280 is four "rows" worth (0x280 / 0xA0 = 4)

The font file starts at #0003 offset 0x045C50, at least I think that's the font. There's 0x1fc00 of space between the end of the color table and the start of the next file in this multi-file archive. I think the entire space is used; none of that space is really empty.
2.PNG

For this file there is 4 bits per pixel.
I think the right calculation is (0x200 * 0x1F4) / 2 = 0x1F400. The divide by 2 is because 1 byte provides 2 pixels for CLUT4. So I am 0x800 short, equal to eight "rows" worth (0x800 * 2 / 0x200 = 8).

Any idea what offset 0x10 in the header is?
EDIT: 0x10 is number of colors.

I guess nothing to do but try it. But I still don't get it.
 
Last edited by flame1234,

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
Anyone know about swizzling? Probably all images are swizzled. I can't do anything until I figure out unswizzle / swizzle.
I searched and found this: http://forums.ppsspp.org/showthread.php?tid=3799
So I have to examine the PPSSPP source code to learn how to do this?

Code: http://pastebin.com/ssqjar9W (Python 3)
Needs as input PTX files (have to extract those yourself).
Stitches the color table and bitmap from a PTX file into a BMP file.

logo.png


This is what it should look like:
3.PNG

Those little boxes are 16 pixels wide and 12 tall.
Edit: It now seems like 16x8 tiles.
 
Last edited by flame1234,

Scorp

Well-Known Member
Member
Joined
Sep 23, 2010
Messages
248
Trophies
0
XP
296
Country
Kazakhstan
By me this is not swizzle, more like tiled image. Try to use TiledGGD with different tile setting to see if this is it.
 
  • Like
Reactions: flame1234

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
I was having some trouble with TiledGGD at first, but now I feel like I'm almost there.
How do you change "panel size" in TiledGGD? That's what I need to change. The panel size is 384x160 but I don't know how to change it from the default (64x128).
It's definitely showing a piece of the real image with the correct colors (but not even close to the whole thing).

Edit: Figured it out, you have to use the arrow keys; there's no menu option.
4.png
 
Last edited by flame1234,
  • Like
Reactions: JamRules

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
It's the font!
font.png

I now think that unknown_5 from the posted program is a flag for "number of bytes per tile row." Flag 0x06 means 16 bytes per tile row.
Both of these images have 16 bytes per tile row and they both have an unknown_5 of 0x06. This font image is a 4bpp which means the tiles are actually 32x8 pixels.

No, that's not it. Having trouble figuring this out. Both of these images are 16 bytes per tile row. Tiles are always 8 pixels tall.
------------------
EDIT: Figured out unknown_1 and unknown_2.
2 ^ unknown_1 is the x-width of the texture mode needed to contain the image. 128, 256 and 512 are the usual expanded values.
2 ^ unknown_2 is the y-width of the texture mode needed to contain the image.

For some reason I had to switch the R and B values in the color table in order to get the image to look right in my image viewer program. It looked right from the start in TiledGDD. I am guessing the reason for this is: I picked "Big-Endian" order in TiledGDD for the color table and my system reads the color table in little-endian order (going in byte order, BGRA) which is why it looks wrong in my image viewer program.
 
Last edited by flame1234,

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
I adjusted the font so it's aligned left.
ULJM05503_00003.jpgULJM05503_00002.jpg

It is drawing all tiles at once (not one at a time).
5.png

I'll try the suggested method. I've never done this before, so I'm not too confident it will work.
There is 18 pixel spacing between the letters right now. Odd, because the letter tiles themselves are 20x20. So the 18 (0x12) will be something to look out for.
 
Last edited by flame1234,

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
This is like all new information, so I should probably make a tutorial about it.

Here it says vaddr=
That's important.

That says where the coords for the rectangles you're drawing are.
It is actually drawing 16 rectangles (=16 letters), not 32. I don't know why it says 32.
Now we need to look at what's going on with the rectangle specifications over at the VADDR.
6.png


This game moves rectangle data around every couple frames, but this set matches.
0x20 bytes describes 1 rectangle draw.
For the first row, 0x0:0x4 describes x and y coordinate for the upper-left of the rectangle in the texture. 0xC:0x10 describes x and y coordinate for the upper-left of the rectangle in the frame.
The second row describes the lower-right coordinates for both the texture and the frame in this same way.
7.png

In this data you can clearly see: At 0x08AEDD48, the x-offset for the frame is 0x1C. And at 0x08AEDD68, the x-offset for the frame (for the next rectangle) is 0x2E. And 0x2E - 0x1C = 0x12 = 18, the x-distance between letters.

So, if you just set your breakpoint on the VADDR, you can find out where the x-offset comes from.
Pretty cool, right?
----------------------------------------
0x088A380C This subroutine is preparing the rectangle draw for the GPU to do later.
0x088A3858 It loads the value (-2) which I think may be used for spacing purposes. It think it's possible to change the fixed width to something smaller. I did it in memory and it worked.

I think at 0x0889B3A4 it is copying the rectangle draw somewhere else in memory from

Problems still to solve:
For the VWF: How do I find out which letter is being drawn? The game must know which letter is being drawn. It has to know letter index number at a minimum.
How do I get the game to draw more than 16 letters per line?
 

Scorp

Well-Known Member
Member
Joined
Sep 23, 2010
Messages
248
Trophies
0
XP
296
Country
Kazakhstan
@flame1234, basically you have to find where is X coord of the next letter is being put . I do not have a game myself, so cannot tell, how it draws. It if draws all in one line - then probably it first prepares a texture with whole text. In this case there is width and height for that texture, that's what you have to find out to change width => this would allow to use more than 16 symbols. Alternatively there could be a buffer with length of 16 symbols => same story, have to change it.

Game not really need an index number. It can just use the code it got from text and use that as index number to point for a letter in font image. But, having in mind you have normal Shift-JIS text - this is not your case and there should be a table to match Shift-JIS codes with actual positions in font image.
 
Last edited by Scorp,

flame1234

Well-Known Member
OP
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States


You can see my hacking notes here:
http://datacrystal.romhacking.net/wiki/Blaze_Union:ROM_map

I was able to figure out the script format.

The next thing will be to try a variable-width font. As a first step for this I modified the font so that the letters are aligned to the left side of their tiles. Also, in the font I replaced kanji character 哀 with apostrophe and 愛 with period, because the font did not have those characters.

I also need to work on the tutorial text.
 

riesyukira

Well-Known Member
Member
Joined
Jun 2, 2016
Messages
105
Trophies
0
Age
38
XP
723
Country
Good Work dood! Its been years but I'm glad you're still working on this!
It's quite unfortunate that the Union Series has already been forgotten to obscurity despite it being a good atlus/sting title!

I still can't figure out why Atlus didn't bring Blaze and Gloria Union to the west, they're well known to frequently bring unpopular titles to the west and having the other 2 locked up abroad still makes no sense to me..
 

Raijinili

New Member
Newbie
Joined
Apr 27, 2019
Messages
1
Trophies
0
Age
36
XP
92
Country
United States
I just put up notes and code for the image file formats for Yggdra Union, a game by the same devs on the same console in the same series. It's on GitHub, under
Code:
/Raijinili/stingfiles
(I can't post links as a new member.)

I haven't put it up on Data Crystal, since I'm not familiar with the style.

My work isn't very useful for translation work, and more needs to be done to get it useful for modding, but I hope having the notes up will help someone eventually.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Maximumbeans @ Maximumbeans: butte