Natsuiro High School: Seishun Hakusho (.cat & .gtf)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
ssringo
Posts: 23
Joined: Sat Dec 19, 2015 2:28 am

Natsuiro High School: Seishun Hakusho (.cat & .gtf)

Post by ssringo »

Random T Bush created a script that (apparently) works with the models from this game but there isn't a working script to extract the archives (apparently someone sent him extracted files but hasn't shared the script as far as I can tell). I've tried scripts that work for other games from the company that use this format but none work. The thread with his import script can be found here. He has stated he'll get around to looking at extraction at some point but he already has a lot of stuff he's working on so I was hoping someone else might take a look. Uploaded a .rar of several models from the "chara" folder. They are in .cat and .gtf format.

http://www.mediafire.com/file/6onurbq1w93nhyp/NHS.rar
happydance
Posts: 81
Joined: Sun Jul 10, 2016 11:07 am

Re: Natsuiro High School: Seishun Hakusho (.cat & .gtf)

Post by happydance »

I tried to learn making BMS scripts since I was localizing this game to English, still haven't finish though but here's the noob script I've made

Code: Select all

# Natsuiro Highschool .cat files
# by froid_san/happydance

endian big
get NAMEZ basename
get head1 long
get FILENUM long
set filetbloff 0xC
xmath packFILENUMoff "FILENUM * 3 * 4 + filetbloff"

for i = 0 < FILENUM
   goto filetbloff
   get fileoff long
   savepos filetbloff
   goto packFILENUMoff
   get packFILENUM long
   savepos packFILENUMoff
   xmath packfiletbloff "fileoff + 20"
   goto packfiletbloff
   
      for j = 0 < PACKFILENUM
      get OFFSET long
      math OFFSET + fileoff
      putarray 0 j OFFSET
      next j
      
      savepos sizepos
      goto sizepos

      for j = 0 < packFILENUM
      get SIZE long
      putarray 1 j SIZE
      next j
      
      savepos nameoff
      goto nameoff #0x3c
      
      get nonameoff long
      if nonameoff == 0x00000000
         goto OFFSET
         get FILEHEADER long
         
         if FILEHEADER == 0x30646d74
            set EXT string .tmd2
            elseif FILEHEADER == 0x316F6D74
            set EXT string .tmo2
            elseif FILEHEADER == 0x020200ff
            set EXT string .gtf
            elseif FILEHEADER == 0x89504E47
            set EXT string .png
         else
            set EXT string .bin
         endif   
      
      else
      
         goto nameoff
         for j = 0 < packFILENUM
         get nameoff long
         math nameoff + fileoff
         goto nameoff
         get name line
         putarray 2 j name
         next j
         
      endif
      
         if nonameoff == 0x00000000
            for j = 0 < packFILENUM
            getarray offset 0 j
   `         getarray size 1 j
            string NAME p= "%s_%06d%s" NAMEZ j EXT
            log NAME OFFSET SIZE
            next j
            
         else
         
            for j = 0 < packFILENUM
            getarray offset 0 j
   `         getarray size 1 j
            getarray name 2 j
            log NAME OFFSET SIZE
            next j
            
         endif
         
next i


not sure if this is the latest script and haven't fully tested it yet since I'm focusing on the game's script and another game now and I also don't know how the file naming Random T Bush script would accept, I just made a BASENAME+0000+EXT as a file name. BTW there's a GTF to DDS out here, I could link it here if you haven't found it yet.
ssringo
Posts: 23
Joined: Sat Dec 19, 2015 2:28 am

Re: Natsuiro High School: Seishun Hakusho (.cat & .gtf)

Post by ssringo »

First off, big thank you for the script. Seriously. It extracted the files but didn't work with RTB's script. I thought that the reason the files your script kicked out didn't work was because there were 3 parts whereas for previous Tamsoft game scripts, they kicked out a single file. I had a reply typed up stating as much when I thought to try combining the 3 files. Unsurprisingly, it didn't work either as combining through the command prompt is for text and binary files apparently (thanks google). But my futile attempts at being smart finally led to understanding a comment RTB made about the .cat files. "you can just crop the files to the "0dmt" headers ". I looked at the files your script kicked out in notepad plus and noticed they started with "0dmt". I then opened the .cat file and found "0dmt", deleted everything prior to the first result, saved as .tmd (the format his script uses) and tried importing. It worked, correct weights and all.

TL;DR: Apparently all a script needs to do is delete everything prior to the first "0dmt" header?

As for the gtf files, I noticed not long ago that noesis reads the gtf files just fine so we're good on that front :)

I feel a bit like an idiot for not figuring it out sooner. Though I still don't know how to make a script do that.

EDIT: I forgot to mention that your script is still useful. There are .cat files that are archives of .gtf files which your script extract just fine.
happydance
Posts: 81
Joined: Sun Jul 10, 2016 11:07 am

Re: Natsuiro High School: Seishun Hakusho (.cat & .gtf)

Post by happydance »

oh, so the 0x to 0x3 (0dmt) is not needed? I really got no clue since I have no idea about game models and translating the game does not require me to modify the model files. I just made the extractor for get a proper look of the files inside the cat.

Though I'm interested on the Bar Macaroon sign board inside the game since I can't find it in any of the GTF to edit the image and was thinking maybe it was a model file. So might check the models now, and thanks for the heads up for the model viewer! :)