Queen's Blade: Spiral Chaos Translation Project ( Hackers needed )

Discussion in 'PSP - Hacking & Homebrew' started by Seryuu, Mar 11, 2015.

  1. JamRules

    JamRules .....

    Member
    7
    Jan 9, 2014
    United States
    Looks good, glad you got it working.
    If you use the gedebugger to step texture until the font comes up and then step primitive until the char is drawn you'll be able to find the vaddr. If you look at this in memory view the order is normally
    U,V,Colour,X,Y,Z (4 bytes each). Putting a memory break point on the x value should lead you to where the values are saved.

    I agree, using ints is better, especially since rendering in factions doesn't work that well on a real PSP.

    Yeah forgot to mention about the font sheet, I had similar problems with Sol Trigger. I haven't looked at the ISO but if there's an obvious font file then good, otherwise use the gedebugger and try to trace which file the texture comes from, not always easy though.
    The debugger should also help tell you the texture format.

    Edit:
    I would also check the hack on a real PSP, the memory alignments are possibly different so it might not work.

    Oh and I know the original code isn't as efficient as it could be since I was just making it up so actions might be redundant. Also the reason I sometimes add values instead of loading from an offset is because I've had problems with PPSSPP not loading opcodes before, no idea why
     
    Last edited by JamRules, Nov 9, 2015
    reinzhart and Final_Agent like this.
  2. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
    This screenshot has all the data. It is about to write "f" in "flame."

    3.

    I google searched CLUT4 (search on Google for CLUT4) but didn't come up with much. What does this mean?

    The tex is 256x16. Well if you multiply those you get 0x1000. How do I find out how big the tex actually is? 0x1000? 0x2000? 0x4000? At the address 0x8b453b0, there are a bunch of zeros. This makes sense because the tex I think is mostly background color with few actual pixels. After some experimenting: Actual retail price = 0x800 (1/2 of 0x1000).

    I also tried looking at 0x8b3c370 which is where it says the CLUT (color look-up table) is located. I messed around with it a bit. The values at the beginning look like colors. I tried changing while live and it did work. I was able to change color and transparency level. There are more colors in use than just black though. I wasn't able to change those. Nevermind. There are different color tables for different stuff and this is the color table for the font (makes sense). I'm guessing this is RGBA.
    4.

    Then I went back and played with the raw texture in RAM (at 0x8b453b0) and got stuff to change as well. I'm not understanding the format in which the texture is stored, though.

    As zero_g mentioned earlier, you can unpack the graphic.bin files the same as you can the "shared.bin" file that has the script. The font might be in there; there are no file labels, though.
     
    reinzhart, Final_Agent and JamRules like this.
  3. JamRules

    JamRules .....

    Member
    7
    Jan 9, 2014
    United States
    The clut 4 could be because it's 4bpp, so 2 pixels for every byte.

    The texture shown in the gedebugger is likely only part of the full font file, normally this is saved at runtime somehow.

    Tracking the save back to the source could be difficult, I've only edited a font sheet once and that was easy as it was in a font folder. If you have a vauge idea where the textures are it might be better to try to convert them all to a format that can easily be viewed. Or use the CLUT shown in ram and look for a matching CLUT in one of the files.

    Edit: I would also check window.bin as guessing from the name this may something to do
    with the UI. There are definitely some textures in there (some for the title image it seems).

    Edit: There are some .DAT textures with the CLUT followed by the pixels,
    there's also some .gim files and .bna files which contain more .gims

    Edit: Looks like shared.bin/00002800.cl5 is a good one to investigate,
    it has a matching CLUT in it and seems sufficiently large

    [​IMG]
     
    Last edited by JamRules, Nov 9, 2015
    reinzhart and Final_Agent like this.
  4. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
    I think I figured it out, but I still don't get it. I need hints about how to solve the next part of the problem.

    CLUT4 stores its data as follows: Starting with the top left of the image, then continuing to the right for the whole row, then the 2nd row from the top continuing for the whole row, and so on.
    Unlike what Wikipedia will tell you, BMP stores its data starting at the bottom left, then continuing right, then the next row from the bottom and so on.

    So I wrote a program that will do this conversion and I got this image:
    testbmp.

    I have no idea what those symbols are to the left of the 'a.' I'm not going to touch them, I don't think we need them.
    That looks really weird, but seems to be what's going on. I looked in the raw hex and the hex for 'i' looks like: 10 0C so it does actually have that gap in there even though it doesn't look like it.
    For this image, I applied false color black to color 0, because actually the image is entirely white and you'd see nothing if not for that.

    Going in CLUT order (x = 0 = LEFT, y = 0 = TOP), the formula is:
    x = offset // 0x80 #integer division operator
    y = offset mod 0x80

    I'm not sure it's necessary to go in BMP order except for that test, so I will try without. I don't think there's a program out there (except for PPSSPP) that will take a CLUT4 tex and color table and display them for you.

    coordinates of letter a: (offsets)
    40 - top left
    48 - top right
    (15 * 128) + 40 - bottom left
    (15 * 128) + 48 - bottom right
    Letter 'b' continues, starting at offset 48

    Pseudocode for: Finding the leftmost non-zero pixel in a letter.
    http://pastebin.com/JaWh5JCP

    Pseudocode for actual shifting:
    http://pastebin.com/LrNYXTiL

    If you put them together, I think it could work. The high level pseudocode goes:
    For each letter:
    1) Find out what column the leftmost non-transparent pixel for that letter is in (and store)
    2) Shift all the pixels for that letter left by an amount equal to the stored "leftmost" value from step 1

    What do you think? Should work, right? Am I going about this the wrong way? I don't think there are image editing programs out there that will do this. I tried GIMP and it doesn't support 4bpp indexed color images.
     

    Attached Files:

    reinzhart, Final_Agent and JamRules like this.
  5. JamRules

    JamRules .....

    Member
    7
    Jan 9, 2014
    United States
    Sounds good, programming something yourself might be the best way to go.

    It might be possible to configure TiledGDD to preview the texture but this doesn't have editing,
    Crystal Tile 2 might allow you to edit it but I haven't used it so I can't say.
    I can't think of any other program that would help you save/edit the tiles easily.

    As for the gaps, have you tried swapping your index orders when rendering?

    index1 = byte/16
    index2 = byte%16 (I think this could be the left side)
     
    reinzhart and Final_Agent like this.
  6. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
    Jams, this is what it looks like after your idea that the "nybble read order" is reversed (reads most significant bits first):
    testbmp.
     
    reinzhart, Seryuu, leecherboy and 2 others like this.
  7. reinzhart

    reinzhart Advanced Member

    Newcomer
    4
    Jun 12, 2014
    Indonesia
    this last 2 page was crazy haha.
    hope this project going forward by this:grog:
     
    JamRules likes this.
  8. Final_Agent

    Final_Agent Member

    Newcomer
    1
    Oct 15, 2015
    Canada
    I've been peering into the GE Debugger and wow, getting the hex locations of textures and seeing the sprite sheets is really neat.

    The last two pages have been pretty crazy yeah, you guys don't cease to amaze. I'm still swimming upstream with my buddies at the moment between free moments, but at the very least, it's incredibly encouraging to know a solution to the font thing exists! Thanks you guys!
     
    reinzhart likes this.
  9. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
    The whole font, in all its naked glory:
    http://imgur.com/J10sgq4

    Still working on this slowly but surely...
    I already got a raw file with the relevant letters left-aligned.
    Next is to insert back that raw file into shared.bin and test.
    After that is to re-adjust spacing lengths.
    And after that is to figure out (and dump) the script.
    And after that is to work on the script inserter.
    Still pretty far away on this one, I'm afraid.

    There are very few programs that will read "BMP with transparency." Literally the only one I found was COLGA, introduced to me by Zero G Monkey.
     
    reinzhart and JamRules like this.
  10. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
    Okay, made a lot of progress. It's the weekend after all and I do this for fun.
    Sorry, I didn't have my system volume up high enough.


    First chapter script:
    https://docs.google.com/spreadsheets/d/1vlByJHjBcBCyzQyaWALYiGIT4D4Bb3Ewbhz7W2VQVFY/edit#gid=0

    Any idea how many chapters there are?

    We're going to do this a bit different for this project. Here is the public version of the script (not for translating). As always, you may make a copy for your own inscrutable purposes. My copy will not be editable.
    @Seryuu, @Final_Agent and @leecherboy are the translators for this project. Will you all please PM me your emails so I can give you edit access? Thanks. You have to be okay with me and the other team members knowing your email. You can make a new email account for this purpose. And then, I would like you all to translate this entire first chapter, it's 460 lines (approx). Probably I will be able to insert it somehow.

    Instructions:
    Translations go in column D. If you really want, you can type in fullwidth characters. I think normal characters will be easier for you and will work, so that's what I'll recommend. And it doesn't matter if half of you pick one way and the other half pick another.
    Names: If applicable, they are in column B. Please don't translate the names. We will do them all at the end.
    Special case 1: A non-name in column B and nothing in column C -> Put translation in column D as normal. See example on line 19.
    Special case 2: A non-name in column B and another non-name in column C -> Put two translations in column D. It's a special case so it won't be that annoying, I promise. See the example I made for you on column 65. You need a pipe character '|' between the translations.

    More on names:
    #M is the male main character, "Jean" by default; #F is the female main character, "Cute" by default.
    I have no idea who the other # characters are.

    Good luck everyone. Let's get started!
     
  11. leecherboy

    leecherboy Member

    Newcomer
    3
    Nov 1, 2015
    Whoa, looks great!

    To answer a few of the questions, there are 33 stages, most of them split into 2 routes (Leina/Tomoe-Nyx/Dragon-Earth/Netherworld, they converge before splitting again), that result in 3 endings. My partner Final Agent should have posted how the stages are distributed among the logs:
    https://docs.google.com/document/d/1Rhg-Wbi2Xu2Ai74-TDKQtYjjoQZkNUZPliWHrFDoB3U/edit

    As for the names, #GA, #GB and #GC are Harpy enemies/recruitable allies, default names: Puia, Rio and Meis. Sames goes for #SA, #SB and #SC, who are the Spiders, default names: Arane, Kaoruko and Rakune. And finally #TA, #TB and #TC are the Triceratops, default: Cerate, Kayla and Montsouris. Maybe you have noticed the stage starts with quotes from these that don't show up when you play, our working theory is that these are battle quotes in case you use these characters.

    We'll start translating stuff, then.
     
  12. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
    Okay, need to expand the ISO (already). I guess just look for patterns to start.
    upload_2015-11-15_16-18-49.

    hex(294512) = 0x47e70

    Rather than move all files, I'll just try to move shared.bin to the end of the ISO. This will make the ISO bigger. I still feel like searching for other files may help with understanding.

    hex(296528) = 0x48650
    hex(362976) = 0x589e0
    hex(363440) = 0x58bb0
    hex(375280) = 0x5b9f0
    hex(381488) = 0x5d230
    hex(386032) = 0x5e3f0
    hex(407744) = 0x638c0

    Searching through EBOOT.BIN for 707e04 in the hex editor, hits at:
    0x1509b0 - Some kind of FAT
    0x15dc88 - Appears to be in the detailed FAT for this file
    0x1627c0 - Some kind of FAT
    ...That's it.

    Then, looping back around to the detailed FAT for shared.bin at 0x15dc88:
    Looks like 24 sub-files in shared.bin. It goes LBA, compressed size, decompressed size.

    Let's move it to 442624 = 0x6c100. I picked this number because it's a nice round number (divides by 16). I noticed they (HobbyJapan) used exclusively this type of number for their LBA start addresses, so why mess with success?
    Move code: http://pastebin.com/YErXQh9T

    Also need to move it to the bottom in File List.txt (created from UMDgen):
    upload_2015-11-15_17-11-31.
    Nothing left to do but try it.
    (Works)

    Now, identifying the script file. 0x17e1b0 (loc of the first script file) is key here.
    Go to shared.bin at that location. Now reverse find for LICE. It's at 0x17D800. Now divide by 0x800 (= 2048, amount of bytes in one LBA) and you get 763. Now do hex(0x6c100 + 763) = 0x6c3fb
    Looking again in the EBOOT, we see this value at 0x15DD00. So this is the entry for the current script file. This file actually has 0xA3 = 163 sub-files in it (ours is one). More on that later. Since shared.bin is at the end of the EBOOT now we have basically infinity space to expand this now.
    Looking again in the EBOOT we see the next file is at 0x6c4f0. The difference (0x6c4f0 - 0x6c3fb) = 245 -> * 2048 = 0x7a800. And the original file is 0x7a240 long which gives 1472 bytes of free space which is not enough. I want to give 100 LBAs more free space which is 200kb (approx.). The steps are:

    1) In the EBOOT, for each entry for shared.bin from 0x6c4f0 onward, we need to add 100 to it.
    2) In shared.bin, at position (0x6c4f0 - 0x6c100) * 0x800 (position of file after "script file" in shared.bin), we need to insert 100 * 0x800 zeros.

    There's still more to go on this problem after this, but I'm confident it will be solved.

    The whole script is 460kb long approx, which means 230k characters. Actually it is not that long because name characters and control codes are included in the count, and you only need to translate names once, even though they appear many times in the script (each occurrence of names was included in the rough count). On second thought, better give 150kb extra space instead.
     
    JamRules and Final_Agent like this.
  13. Abcdfv

    Abcdfv What comes around goes around.

    Member
    6
    Dec 24, 2013
    United States
    Really glad to see so much progress on this! Excited to play this in English.
     
  14. Scorp

    Scorp GBAtemp Regular

    Member
    3
    Sep 23, 2010
    Kazakhstan
    This topic should be put in some knowledge base, as example of how to deal with font matters. Would be invaluable for people who want to learn PSP hacks. That's offtopic, anyway, but I would personally want to learn how to put a software rendered text subtitles over video, have an idea, but never tried. As that's an eye ache to see each time twice recoded videos.
     
    Last edited by Scorp, Nov 16, 2015
    Final_Agent likes this.
  15. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
    The tutorial is missing:
    How to find where the game is adjusting the x (horizontal) font spacing.
    But yeah, once you know that, this topic is very good, I think.

    I imagine it's different for each game, but it wasn't even covered for this game how it was figured out. I'm guessing with great difficulty.

    You probably need an even better programmer than me. The best solution would be to make a png out of the font. BMP supports transparency, but no one supports BMP with transparency. And BMP is easy to understand, PNG is much more difficult.
    For the project, I just used a custom algorithm, not an image editing program, to edit the font, as described earlier.
    By the way, certain letters didn't look good when left aligned, so I aligned the letters to one pixel off the left side.

    If we wanted to edit this font, it'd be difficult, but not impossible. I was thinking false color according to the alpha level - black = transparent, white = opaque, gray = semitransparent. You can then edit with GIMP.
     
  16. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
  17. Scorp

    Scorp GBAtemp Regular

    Member
    3
    Sep 23, 2010
    Kazakhstan
    Well, as I know, this is usually done using the width of the tile, so if you found where it is put in memory, you just trackback this value. Could be tedious though. Maybe there is better way to do it?

    When I was doing similar case, I created a convertor to one big png, which have some defined color - cyanfor example, which was meant to represent width and green color for left spacing. Looked like this if you're curious: http://psp4real.ru/_tr/image2.gif
    After that made a convertor back to custom format. Not really hard thing to do.
     
    Last edited by Scorp, Nov 17, 2015
  18. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    6
    May 17, 2009
    United States
    I made the script dumper:
    http://pastebin.com/K6J9XPkF
    Hopefully it works and gets all relevant strings.

    I also uploaded the first 50 scripts into the Google sheet.
    The bad news is that there are 163 scripts. The good news is that the first script (that is already up) by far is the largest.
     
    leecherboy likes this.
  19. Final_Agent

    Final_Agent Member

    Newcomer
    1
    Oct 15, 2015
    Canada
    By the way, I figured you might wanna check this out Flame.

    It seems to be the UI stuff for the game, profiles, item descriptions, skill names, that kind of thing. All seems to be here as far as I know. But where 'here' is is where I get a little lost.

    Someone dumped this for us during another attempt at trying to get to the files but didn't really elaborate on what he did to find it so we could recreate the dump. It's been sitting around for a while, but I'm hoping it could be sort of useful.
     

    Attached Files:

  20. leecherboy

    leecherboy Member

    Newcomer
    3
    Nov 1, 2015
    163 scripts actually don't sound so bad if you consider that 70 of them are relatively short freetalks we've already been translating independently in video form (example), so we got a pretty good translation of them going already, and 42 of the others are carbon copies freetalks with #GB instead of #GA and so on. That means it's the 50 or so stages which we'll need to focus on.
     
    Abcdfv likes this.
Quick Reply
Draft saved Draft deleted
Loading...