Jump to content

[PC] QP Shooting .dat files


nago

Recommended Posts

I'm trying to figure out how to extract the .dat files in QP Shooting to translate it to English.
(Not putting it in the Game Localization category as I do not need help with translation itself)

QP Shooting is a bullet hell game released in 2004. It uses the Luna3D engine (pretty obscure Japanese game engine using DirectX, near impossible to find)


About the Game Engine: 
From the game's main .exe file: Luna3rd Phase 10.20... 2003.07.29
Luna Homepage | twin-tail.jp/contents/luna/index.htm
There's a game called Magical Broom Extreme made by the author of the engine. Might be helpful.
The source code isn't included in "All Package", so you'll have to download that one separately from the rest.
Self Extracting Installer | twin-tail.jp/contents/game/mbx/index.htm

About the Game:
QP Shooting Download (Trial, should be sufficient): daidai.moo.jp/dl.html
Download is at the bottom of the list, 13MB. Right click and open as new tab for the Dropbox link to work.
Presumably compiled with Borland C++.

Checking the .exe in a hex editor shows some things:

  • file names from the inside of the .dat files
    • dat\st_00.txt through st_06.txt
  • as previously listed, it uses Luna3rd Phase 10.20... 2003.07.29
  • along with that, it uses DirectX 8.1

And for the .dat files:

  • some have a LAG/4C 41 47 file header (stg3.dat, stg4.dat, stg5.dat, stg6.dat)
    • BMP converted to LAG (Luna image format)
  • some have legible text, likely for filenames
    • stg3.dat: "bgp_01", etc. (looks like main menu + UI stuff)
    • stg4.dat: "face_mi01", "face_qp01", "face_qp02", "face_yu01", "face_yu02" (face sprites)
      •  the 2 letters before the last 2 numbers are in reference to which character's portrait it is
    • stg5.dat: "cutin_01", "cutin_06"
    • stg6.dat: (presumably) stuff relating to winning and bullet formations
       

The later games made by the same developer use DXArchive from DXLibrary, but it's different for the older games.
I figure I should link it just in case. (Source) / Link to DXLibrary

Link to comment
Share on other sites

There are two sets of .dat files in this game; system files (replay\qprpy_%d2.rpy, config.dat, stag.dat, stag2.dat) which are encrypted and asset files (stag[3-6].dat) which are blobs containing various DirectX compatible image assets

The asset file starts with an 8 byte header followed by the below structure for each asset. The game has a function that loads assets by archive and file name which literally just scans the archive byte-by-byte for the filename

struct {
 char filename[16];
 uint32_t width;
 uint32_t height;
 uint32_t flags; // not 100%
 uint32_t size;
 char data[size];
} asset;

 

The system files are encrypted with the below XOR cipher. The first uint32_t of the file is the length of the file minus the field itself and this is validated within the game as a very basic tamper check

bool DecryptDat(char *filepath, void *output_buffer, int expected_size)
{
  int index;
  FILE *file_ptr;
  char val;
  int size;
  bool success;

  success = 0;
  index = 0;
  size = 0;
  file_ptr = fopen(filepath, 'rb');
  
  if ( !file_ptr )
    return 0;

  // read first uin32_t size field
  fread(&size, 4u, 1u, file_ptr);
  
  if ( size == expected_size )
  {
    while ( index < expected_size )
    {
      val = fgetc(file_ptr);
      val = size++ ^ (16 * val | (val >> 4) & 0xF);
      output_buffer[index++] = val;
    }
	
    success = 1;
  }
  
  fclose(file_ptr);
  return success;
}

Hope this helps

Edited by barncastle
Link to comment
Share on other sites

10 hours ago, barncastle said:

The system files are encrypted with the below XOR cipher. The first uint32_t of the file is the length of the file minus the field itself and this is validated within the game as a very basic tamper check

Sorry, I forgot to mention I'm not very well versed in C or backend code... Usually I only make minor modifications.
Not sure if I need any specific dependencies or what to do to prevent it from throwing errors on debug. I'm using Visual Studio 2022.
 

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...