Jump to content

Unpacking and repacking an .scr (script) file for old Japanese games.


Habanero

Recommended Posts

I wasn't sure if I should post this here, or if in the translation help forum. I originally made a thread for this on Zenhax, but since that's dead (and it's been a couple years so I've forgotten everything), I'll make a thread here.

I have an old OoP Japanese PC game called Vampire Hurts, which uses .scr files for its dialogue. Now, I actually have a tool and its source code (presumably from that old Zenhax thread made it) that's titled Vampire Hurts Translation Tool, which will dump the scripts of the SCR files into TXT. The problem I'm having is that I don't know how to repack them into SCR files for dialogue replacement. The "Merge Text" feature doesn't repack it. Since this is an old game, I'm expecting hex/full-width text limitations. Can someone please see if the source code can be modified to repack, or something like a Quick BMS script to repack it?

Here's a MEGA folder with the tool and an SCR file from the very beginning of the game. The files are too small for the QuickBMS file cutter.

Here's a view of the file in a hex editor.

65BQsHL.png

 

Any help would be appreciated. Thanks.

Link to comment
Share on other sites

  • 3 weeks later...

Hi, I wrote python code that I belive will help with making strings wider.

It just extracts contained data and builds it back. Maybe it can help you with limitations cause it changing pointers when building new file.

Maybe it won't work at all, I didn't test it cause I don't have this game

Spoiler
import os

def extract():
    pointers = []
    with open(filename, "rb") as f:
        f = f.read()
        qty = int.from_bytes(f[0:1], byteorder="little")
        for p in range(0, qty):
            pointers.append(int.from_bytes(f[4*p+2:4*p+6], byteorder="little"))
        pointers.append(len(f))
        mydir = filename[:-4]+"/"
        if not os.path.isdir(mydir): os.mkdir(mydir)
        for p in range(0, qty):
            with open(mydir+filename+str(p), "wb") as f2:
                f2.write(f[pointers[p]:pointers[p+1]])
                print("Extracted:\t"+mydir+filename+str(p))
            

def build():
    pointers = []
    files = os.listdir(foldername)
    data = []
    length = len(files)*4
    length = length + 2
    pointers.append(length)
    
    with open(foldername[:-1]+".scr", "wb") as f2:
        for f in files:
            fN = f
            with open(foldername+f, "rb") as f:
                print(foldername+fN+" imported!")
                f = f.read()
                data.append(f)
                length = length + len(f)
                pointers.append(length)
        f2.write(len(files).to_bytes(2, byteorder="little"))
        pointers.pop(len(pointers)-1)
        for p in pointers:
            f2.write(p.to_bytes(4, byteorder="little"))
        for piece in data:
            f2.write(piece)
    print(foldername[:-1]+".scr created!")
                
while True:
    option = input("type e for extract, type b to build file:\t")

    match option:
        case "e":
            filename = input("gimme filename:\t")
            if not os.path.isfile(filename):
                print("Can't find file "+filename)
            else: extract()
        case "b":
            foldername = input("gimme foldername with scr data:\t")
            foldername = foldername+"/"
            if not os.path.isdir(foldername):
                print("Can't find folder")
            else: build()
        case _:
            print("What?")
            

 

 

Edited by r88
Link to comment
Share on other sites

2 hours ago, r88 said:

Hi, I wrote python code that I belive will help with making strings wider.

It just extracts contained data and builds it back. Maybe it can help you with limitations cause it changing pointers when building new file.

Maybe it won't work at all, I didn't test it cause I don't have this game

  Reveal hidden contents
import os

def extract():
    pointers = []
    with open(filename, "rb") as f:
        f = f.read()
        qty = int.from_bytes(f[0:1], byteorder="little")
        for p in range(0, qty):
            pointers.append(int.from_bytes(f[4*p+2:4*p+6], byteorder="little"))
        pointers.append(len(f))
        mydir = filename[:-4]+"/"
        if not os.path.isdir(mydir): os.mkdir(mydir)
        for p in range(0, qty):
            with open(mydir+filename+str(p), "wb") as f2:
                f2.write(f[pointers[p]:pointers[p+1]])
                print("Extracted:\t"+mydir+filename+str(p))
            

def build():
    pointers = []
    files = os.listdir(foldername)
    data = []
    length = len(files)*4
    length = length + 2
    pointers.append(length)
    
    with open(foldername[:-1]+".scr", "wb") as f2:
        for f in files:
            fN = f
            with open(foldername+f, "rb") as f:
                print(foldername+fN+" imported!")
                f = f.read()
                data.append(f)
                length = length + len(f)
                pointers.append(length)
        f2.write(len(files).to_bytes(2, byteorder="little"))
        pointers.pop(len(pointers)-1)
        for p in pointers:
            f2.write(p.to_bytes(4, byteorder="little"))
        for piece in data:
            f2.write(piece)
    print(foldername[:-1]+".scr created!")
                
while True:
    option = input("type e for extract, type b to build file:\t")

    match option:
        case "e":
            filename = input("gimme filename:\t")
            if not os.path.isfile(filename):
                print("Can't find file "+filename)
            else: extract()
        case "b":
            foldername = input("gimme foldername with scr data:\t")
            foldername = foldername+"/"
            if not os.path.isdir(foldername):
                print("Can't find folder")
            else: build()
        case _:
            print("What?")
            

 

 

Thanks for the script! I'll test it soon and get back to you.

Link to comment
Share on other sites

  • 1 month later...

I'm also trying to repackage tetris.scr, it looks different.
I have the script to extract, but I just want to repackage the extracted files into scr format.
Can you help me.
Thanks.

tetris.zip

Edited by Romario
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...