Ao no Kanata no Four Rhythm - script.rom

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
tnpj
Posts: 5
Joined: Mon Oct 17, 2016 9:56 am

Ao no Kanata no Four Rhythm - script.rom

Post by tnpj »

Hello, all. I'm having trouble analyzing the script file for Aokana (PS Vita). All game files are stored with the .rom extension, so it's obvious they're all compressed archives. I'm only interested in the script file, as I only want to translate the text, not alter anything else. Any help on extracting it would be greatly appreciated!

script.rom file: http://www72.zippyshare.com/v/YAgALkD8/file.html
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Ao no Kanata no Four Rhythm - script.rom

Post by aluigi »

I guess the only solution is offzip -a
tnpj
Posts: 5
Joined: Mon Oct 17, 2016 9:56 am

Re: Ao no Kanata no Four Rhythm - script.rom

Post by tnpj »

Thank you very much, aluigi! I was able to unpack the files using your tool. However, I am presented with 200+ .dcv files which I am equally confused with. Looking at the hex, I can see that there are supposed to be sub-folders and files within the script.rom. Thinking that, I applied your tool on the larger .dcv output files, but it failed each time, claiming there is no valid zip data to be found.

Now I'm truly stumped =/

Edit: Tried the tool on another .rom file. This time, I was given some .dat and .gxt files as the ouput! I will look into how to extract the .dat file now :)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Ao no Kanata no Four Rhythm - script.rom

Post by aluigi »

These DCVM files seem a sort of RIFF-like format, so they are composed by chunks with information like STOR, PTBL, PSTR, FTBL, CODE and STBL.
CODE is the biggest chunk so I think the others are just references to the data stored there.
But I don't think the data there is useful, feel free to check it with a hex editor.
tnpj
Posts: 5
Joined: Mon Oct 17, 2016 9:56 am

Re: Ao no Kanata no Four Rhythm - script.rom

Post by tnpj »

Yes, I noticed STOR, PTBL and others recurring in the hex of every file.
I checked most of the .dcv files and it seems they hold information on what and when to open other files (images, textures, audio, etc.) and not the scripts that I thought it would contain.
Thanks for all your help, aluigi. I'll try to figure this out!
aaa801
Posts: 48
Joined: Wed Oct 12, 2016 12:22 pm

Re: Ao no Kanata no Four Rhythm - script.rom

Post by aaa801 »

So as far as i can figure out
1024 alligned,
if the payload is more than 1024 bytes its compressed with gzip and stored like
0xA6190100
u32 compressedSize
u32 decompressedSize
followed by the gz stream

otherwise it just stores the raw file with no header..

Also i have no idea on the header of the file.. looks scary and doesn't seem to contain refs to the actual amount of files etc
aaa801
Posts: 48
Joined: Wed Oct 12, 2016 12:22 pm

Re: Ao no Kanata no Four Rhythm - script.rom

Post by aaa801 »

Dodgy quickbms script for it ;)

Code: Select all

goto 0x400

for FILEID = 0

   getdstring magic 0x4

   if magic == "DCVM"
      print "dcvm"
      
      savepos OFF
      math OFF - 4
      goto OFF
      log FILEID OFF 1024
      math OFF + 1024
      goto OFF
   else
      print "gz"
      get compressedSize long
      get decompressedSize long
      
      savepos OFF
      clog FILEID OFF compressedSize decompressedSize
      math compressedSize + OFF
      goto compressedSize
   endif
   

   
   padding 0x400
   
next FILEID


aaa801
Posts: 48
Joined: Wed Oct 12, 2016 12:22 pm

Re: Ao no Kanata no Four Rhythm - script.rom

Post by aaa801 »

Made a script for the pack files in inside the rodata/etc files

Code: Select all

idstring "PACK"
get unknown1 long
get ALIGNMENT long

padding ALIGNMENT
idstring "DATA"
get ofsbtmp long
savepos ofsbPos
math ofsbPos - 8
math ofsbPos + ofsbtmp
goto ofsbPos

get MAX_OFFSET asize
math MAX_OFFSET - 8//take off 8 for the ints at the end

//read ofsb data
OFFSET = 0
FILES = 0
HASNAMES = 0
Do
   getdstring magic 0x4
   
   if magic == "OFSB"
      print "reading OFSB"
      get lengthOfOFSB long
      get entries long
      math entries + 2//2 unknown entries
      For i = 0 < entries
         get unknownlong long
         print "unknown long %unknownlong%"
      Next i
      padding lengthOfOFSB
   else if magic == "SIZE"
      print "reading sizes"
      get lengthOfSize long
      get entries long
      math FILES + entries
      For i = 0 < entries
         get fileLength long
         PutArray i 0 fileLength
         print "file length %fileLength%"
      Next i
      padding lengthOfSize
   else if magic == "COMP"
      print "reading comp"
      get lengthOfComp long
      get entries long
      print "skipping comp as unknown structure"
      padding lengthOfComp
   else if magic == "NAME"
      math HASNAMES + 1
      print "reading names"
      get lengthOfName long
      For i = 0 < entries
         get fileName string
         PutArray i 1 fileName
         print "file name %fileName%"
      Next i
      padding lengthOfName   
   else
      print "o noes %magic%"
   endif
   savepos OFFSET
While OFFSET < MAX_OFFSET

GetArray testvar 0 0
print %testvar%


//goto start of first data file
fileDataPos = ALIGNMENT
math fileDataPos + ALIGNMENT
goto fileDataPos

savepos OFFSET

for currentFile = 0 < FILES

   fileName = currentFile
   if HASNAMES == 1
      GetArray fileName currentFile 1
   endif
   GetArray fileLength currentFile 0
   print "%fileName% %fileLength%"
   
   savePos tmpPos
   get firstByte byte
   get secondByte byte
   goto tmpPos
   
   if firstByte == 120 && secondByte == 218
      comtype unzip_dynamic
      clog fileName OFFSET fileLength fileLength
   else
      log fileName OFFSET fileLength
   endif
   
   savePos tmpOffset
   math tmpOffset + fileLength
   goto tmpOffset
   padding ALIGNMENT

savepos OFFSET
print "%OFFSET% %ofsbPos%"

next currentFile