Skip to content

Commit 415efcc

Browse files
committed
FREESCAPE: added code to decrypt some driller releases for atari
1 parent 70c94e3 commit 415efcc

File tree

3 files changed

+88
-22
lines changed

3 files changed

+88
-22
lines changed

engines/freescape/detection.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,20 @@ static const ADGameDescription gameDescriptions[] = {
157157
ADGF_NO_FLAGS,
158158
GUIO4(GUIO_NOMIDI, GUIO_RENDEREGA, GUIO_RENDERCGA, GAMEOPTION_AUTOMATIC_DRILLING)
159159
},
160-
{
160+
{ // Retail release
161+
"driller",
162+
"",
163+
{
164+
{"x.prg", 0, "d002983a8b652f25b18a09425db78c4c", 293159},
165+
{"playseq.prg", 0, "535e9f6baf132831aa7fa066a06f242e", 973},
166+
AD_LISTEND
167+
},
168+
Common::EN_ANY,
169+
Common::kPlatformAtariST,
170+
GF_ATARI_RETAIL,
171+
GUIO2(GUIO_NOMIDI, GAMEOPTION_AUTOMATIC_DRILLING)
172+
},
173+
{ // Budget release
161174
"driller",
162175
"",
163176
{
@@ -167,7 +180,7 @@ static const ADGameDescription gameDescriptions[] = {
167180
},
168181
Common::EN_ANY,
169182
Common::kPlatformAtariST,
170-
ADGF_NO_FLAGS,
183+
GF_ATARI_BUDGET,
171184
GUIO2(GUIO_NOMIDI, GAMEOPTION_AUTOMATIC_DRILLING)
172185
},
173186
{
@@ -340,7 +353,7 @@ static const ADGameDescription gameDescriptions[] = {
340353
"spacestationoblivion",
341354
"",
342355
{
343-
{"x.prg", 0, "10c556ee637bf03bcc1a051277542102", 293264},
356+
{"x.prg", 0, "bf546ee243c38f51d9beb25c203ccb93", 292624},
344357
AD_LISTEND
345358
},
346359
Common::EN_ANY,

engines/freescape/freescape.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ enum DrillerReleaseFlags {
427427
GF_CPC_RETAIL2 = (1 << 6),
428428
GF_CPC_BUDGET = (1 << 7),
429429
GF_CPC_VIRTUALWORLDS = (1 << 8),
430+
GF_ATARI_RETAIL = (1 << 9),
431+
GF_ATARI_BUDGET = (1 << 10),
430432
};
431433

432434
class DrillerEngine : public FreescapeEngine {
@@ -509,6 +511,8 @@ class DrillerEngine : public FreescapeEngine {
509511

510512
uint32 getPixel8bitTitleImage(int index);
511513
void renderPixels8bitTitleImage(Graphics::ManagedSurface *surface, int &i, int &j, int pixels);
514+
515+
Common::SeekableReadStream *decryptFileAtari(const Common::String filename);
512516
};
513517

514518
class DarkEngine : public FreescapeEngine {

engines/freescape/games/driller/atari.cpp

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,83 @@
1919
*
2020
*/
2121
#include "common/file.h"
22+
#include "common/memstream.h"
2223

2324
#include "freescape/freescape.h"
2425
#include "freescape/language/8bitDetokeniser.h"
2526

2627
namespace Freescape {
2728

28-
void DrillerEngine::loadAssetsAtariFullGame() {
29+
Common::SeekableReadStream *DrillerEngine::decryptFileAtari(const Common::String filename) {
2930
Common::File file;
30-
file.open("x.prg");
31-
31+
file.open(filename);
3232
if (!file.isOpen())
33-
error("Failed to open 'x.prg' executable for AtariST");
34-
35-
_border = loadAndConvertNeoImage(&file, 0x1371a);
36-
byte *palette = (byte *)malloc(16 * 3);
37-
for (int i = 0; i < 16; i++) { // gray scale palette
38-
palette[i * 3 + 0] = i * (255 / 16);
39-
palette[i * 3 + 1] = i * (255 / 16);
40-
palette[i * 3 + 2] = i * (255 / 16);
33+
error("Failed to open %s", filename.c_str());
34+
35+
int size = file.size();
36+
byte *encryptedBuffer = (byte *)malloc(size);
37+
file.read(encryptedBuffer, size);
38+
file.close();
39+
40+
byte *a6 = encryptedBuffer + 0x118;
41+
byte *a5 = encryptedBuffer + size - 4;
42+
uint64 key = 0xb9f11bce;
43+
44+
while (a6 <= a5) {
45+
uint64 d0 = (a6[0] << 24) | (a6[1] << 16) | (a6[2] << 8) | a6[3];
46+
d0 += key;
47+
d0 = uint32(d0);
48+
49+
a6[0] = byte((d0 >> 24) & 0xFF);
50+
a6[1] = byte((d0 >> 16) & 0xFF);
51+
a6[2] = byte((d0 >> 8) & 0xFF);
52+
a6[3] = byte(d0 & 0xFF);
53+
54+
key += 0x51684624;
55+
key = uint32(key);
56+
a6 += 4;
57+
}
58+
59+
return (new Common::MemoryReadStream(encryptedBuffer, size));
60+
}
61+
62+
void DrillerEngine::loadAssetsAtariFullGame() {
63+
64+
if (_variant & GF_ATARI_RETAIL) {
65+
Common::SeekableReadStream *stream = decryptFileAtari("x.prg");
66+
67+
_border = loadAndConvertNeoImage(stream, 0x14b96);
68+
_title = loadAndConvertNeoImage(stream, 0x1c916);
69+
70+
loadFonts(stream, 0x8a92);
71+
loadMessagesFixedSize(stream, 0xda22, 14, 20);
72+
loadGlobalObjects(stream, 0xd116, 8);
73+
load8bitBinary(stream, 0x2afb8, 16);
74+
loadPalettes(stream, 0x2ab76);
75+
//loadSoundsFx(&file, 0x30da6, 25);
76+
} else if (_variant & GF_ATARI_BUDGET) {
77+
Common::File file;
78+
file.open("x.prg");
79+
80+
if (!file.isOpen())
81+
error("Failed to open 'x.prg' executable for AtariST");
82+
83+
_border = loadAndConvertNeoImage(&file, 0x1371a);
84+
byte *palette = (byte *)malloc(16 * 3);
85+
for (int i = 0; i < 16; i++) { // gray scale palette
86+
palette[i * 3 + 0] = i * (255 / 16);
87+
palette[i * 3 + 1] = i * (255 / 16);
88+
palette[i * 3 + 2] = i * (255 / 16);
89+
}
90+
_title = loadAndConvertNeoImage(&file, 0x10, palette);
91+
92+
loadFonts(&file, 0x8a32);
93+
loadMessagesFixedSize(&file, 0xc5d8, 14, 20);
94+
loadGlobalObjects(&file, 0xbccc, 8);
95+
load8bitBinary(&file, 0x29b3c, 16);
96+
loadPalettes(&file, 0x296fa);
97+
loadSoundsFx(&file, 0x30da6, 25);
4198
}
42-
_title = loadAndConvertNeoImage(&file, 0x10, palette);
43-
44-
loadFonts(&file, 0x8a32);
45-
loadMessagesFixedSize(&file, 0xc5d8, 14, 20);
46-
loadGlobalObjects(&file, 0xbccc, 8);
47-
load8bitBinary(&file, 0x29b3c, 16);
48-
loadPalettes(&file, 0x296fa);
49-
loadSoundsFx(&file, 0x30da6, 25);
5099
}
51100

52101
void DrillerEngine::loadAssetsAtariDemo() {

0 commit comments

Comments
 (0)