-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from JayFoxRox/scr2wav
Add tool to convert webdemo audio scr files to wav
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# The demo version of Star Wars Episode 1: Racer uses a messed up file format for audio. | ||
# Basically it's just XOR'd with 0x55, 0x55, 0xEE, 0xEE and the name Caesar shifted. | ||
# This script undoes this mess, but the files will still be suffix'd with ".rbq" | ||
|
||
import sys | ||
import os | ||
|
||
for path in sys.argv[1:]: | ||
filename = os.path.basename(path) | ||
real_filename = '' | ||
for s in filename: | ||
c = ord(s) | ||
if (c >= ord('a') and c <= ord('z')): | ||
c = ((c - ord('a') + 25) % 26) + ord('a') | ||
if (c >= ord('A') and c <= ord('Z')): | ||
c = ((c - ord('A') + 25) % 26) + ord('A') | ||
real_filename += '%c' % c | ||
print("Processing %s (%s)" % (filename, real_filename)) | ||
with open(path, 'rb') as in_file: | ||
with open(real_filename, 'wb') as out_file: | ||
data = in_file.read() | ||
real_data = bytes([data[i] ^ (0x55 if ((i % 4) <= 1) else 0xEE) for i in range(len(data))]) | ||
out_file.write(real_data) |