mirror of https://github.com/AxioDL/amuse.git
Fix in Rogue Squadron 3 detection
This commit is contained in:
parent
917e607df5
commit
5bee3361b7
115
driver/main.cpp
115
driver/main.cpp
|
@ -30,121 +30,6 @@ static inline void SNPrintf(boo::SystemChar* str, size_t maxlen, const boo::Syst
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static amuse::IntrusiveAudioGroupData LoadFromArgs(int argc, const boo::SystemChar** argv,
|
||||
std::string& descOut, bool& good)
|
||||
{
|
||||
if (argc > 1)
|
||||
{
|
||||
/* First attempt single-file case */
|
||||
std::experimental::optional<athena::io::FileReader> r;
|
||||
r.emplace(argv[1], 32 * 1024, false);
|
||||
if (!r->hasError())
|
||||
{
|
||||
char testBuf[6];
|
||||
if (r->readBytesToBuf(testBuf, 6) == 6)
|
||||
{
|
||||
if (!memcmp(testBuf, "Audio/", 6))
|
||||
{
|
||||
/* Metroid Prime 1 container */
|
||||
r->seek(0, athena::SeekOrigin::Begin);
|
||||
r->readString();
|
||||
descOut = "Metroid Prime (" + r->readString() + ")";
|
||||
|
||||
std::unique_ptr<uint8_t[]> pool = r->readUBytes(r->readUint32Big());
|
||||
std::unique_ptr<uint8_t[]> proj = r->readUBytes(r->readUint32Big());
|
||||
std::unique_ptr<uint8_t[]> samp = r->readUBytes(r->readUint32Big());
|
||||
std::unique_ptr<uint8_t[]> sdir = r->readUBytes(r->readUint32Big());
|
||||
|
||||
good = true;
|
||||
return {proj.release(), pool.release(), sdir.release(), samp.release()};
|
||||
}
|
||||
else if (amuse::SBig(*reinterpret_cast<uint32_t*>(testBuf)) == 0x1)
|
||||
{
|
||||
/* Metroid Prime 2 container */
|
||||
r->seek(0, athena::SeekOrigin::Begin);
|
||||
r->readUint32Big();
|
||||
descOut = "Metroid Prime 2 (" + r->readString() + ")";
|
||||
|
||||
r->readUint16Big();
|
||||
uint32_t poolSz = r->readUint32Big();
|
||||
uint32_t projSz = r->readUint32Big();
|
||||
uint32_t sdirSz = r->readUint32Big();
|
||||
uint32_t sampSz = r->readUint32Big();
|
||||
|
||||
std::unique_ptr<uint8_t[]> pool = r->readUBytes(poolSz);
|
||||
std::unique_ptr<uint8_t[]> proj = r->readUBytes(projSz);
|
||||
std::unique_ptr<uint8_t[]> sdir = r->readUBytes(sdirSz);
|
||||
std::unique_ptr<uint8_t[]> samp = r->readUBytes(sampSz);
|
||||
|
||||
good = true;
|
||||
return {proj.release(), pool.release(), sdir.release(), samp.release()};
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Now attempt multi-file case */
|
||||
boo::SystemChar path[1024];
|
||||
|
||||
/* Project */
|
||||
SNPrintf(path, 1024, _S("%s.pro"), argv[1]);
|
||||
r.emplace(path, 32 * 1024, false);
|
||||
if (r->hasError())
|
||||
{
|
||||
SNPrintf(path, 1024, _S("%s.proj"), argv[1]);
|
||||
r.emplace(path, 32 * 1024, false);
|
||||
if (r->hasError())
|
||||
return {nullptr, nullptr, nullptr, nullptr};
|
||||
}
|
||||
std::unique_ptr<uint8_t[]> proj = r->readUBytes(r->length());
|
||||
|
||||
/* Pool */
|
||||
SNPrintf(path, 1024, _S("%s.poo"), argv[1]);
|
||||
r.emplace(path, 32 * 1024, false);
|
||||
if (r->hasError())
|
||||
{
|
||||
SNPrintf(path, 1024, _S("%s.pool"), argv[1]);
|
||||
r.emplace(path, 32 * 1024, false);
|
||||
if (r->hasError())
|
||||
return {nullptr, nullptr, nullptr, nullptr};
|
||||
}
|
||||
std::unique_ptr<uint8_t[]> pool = r->readUBytes(r->length());
|
||||
|
||||
/* Sdir */
|
||||
SNPrintf(path, 1024, _S("%s.sdi"), argv[1]);
|
||||
r.emplace(path, 32 * 1024, false);
|
||||
if (r->hasError())
|
||||
{
|
||||
SNPrintf(path, 1024, _S("%s.sdir"), argv[1]);
|
||||
r.emplace(path, 32 * 1024, false);
|
||||
if (r->hasError())
|
||||
return {nullptr, nullptr, nullptr, nullptr};
|
||||
}
|
||||
std::unique_ptr<uint8_t[]> sdir = r->readUBytes(r->length());
|
||||
|
||||
/* Samp */
|
||||
SNPrintf(path, 1024, _S("%s.sam"), argv[1]);
|
||||
r.emplace(path, 32 * 1024, false);
|
||||
if (r->hasError())
|
||||
{
|
||||
SNPrintf(path, 1024, _S("%s.samp"), argv[1]);
|
||||
r.emplace(path, 32 * 1024, false);
|
||||
if (r->hasError())
|
||||
return {nullptr, nullptr, nullptr, nullptr};
|
||||
}
|
||||
std::unique_ptr<uint8_t[]> samp = r->readUBytes(r->length());
|
||||
|
||||
descOut = "4 RAW Chunk Files";
|
||||
good = true;
|
||||
return {proj.release(), pool.release(), sdir.release(), samp.release()};
|
||||
}
|
||||
}
|
||||
|
||||
return {nullptr, nullptr, nullptr, nullptr};
|
||||
}
|
||||
#endif
|
||||
|
||||
struct AppCallback;
|
||||
|
||||
struct EventCallback : boo::IWindowCallback
|
||||
|
|
|
@ -481,36 +481,24 @@ static std::vector<std::pair<std::string, IntrusiveAudioGroupData>> LoadRS1PC(FI
|
|||
proj.reset(new uint8_t[entry.decompSz]);
|
||||
FSeek(fp, entry.offset, SEEK_SET);
|
||||
fread(proj.get(), 1, entry.decompSz, fp);
|
||||
FILE* wfp = fopen("/Users/jacko/Desktop/RS.proj", "wb");
|
||||
fwrite(proj.get(), 1, entry.decompSz, wfp);
|
||||
fclose(wfp);
|
||||
}
|
||||
else if (!strncmp("pool_SND", entry.name, 16))
|
||||
{
|
||||
pool.reset(new uint8_t[entry.decompSz]);
|
||||
FSeek(fp, entry.offset, SEEK_SET);
|
||||
fread(pool.get(), 1, entry.decompSz, fp);
|
||||
FILE* wfp = fopen("/Users/jacko/Desktop/RS.pool", "wb");
|
||||
fwrite(pool.get(), 1, entry.decompSz, wfp);
|
||||
fclose(wfp);
|
||||
}
|
||||
else if (!strncmp("sdir_SND", entry.name, 16))
|
||||
{
|
||||
sdir.reset(new uint8_t[entry.decompSz]);
|
||||
FSeek(fp, entry.offset, SEEK_SET);
|
||||
fread(sdir.get(), 1, entry.decompSz, fp);
|
||||
FILE* wfp = fopen("/Users/jacko/Desktop/RS.sdir", "wb");
|
||||
fwrite(sdir.get(), 1, entry.decompSz, wfp);
|
||||
fclose(wfp);
|
||||
}
|
||||
else if (!strncmp("samp_SND", entry.name, 16))
|
||||
{
|
||||
samp.reset(new uint8_t[entry.decompSz]);
|
||||
FSeek(fp, entry.offset, SEEK_SET);
|
||||
fread(samp.get(), 1, entry.decompSz, fp);
|
||||
FILE* wfp = fopen("/Users/jacko/Desktop/RS.samp", "wb");
|
||||
fwrite(samp.get(), 1, entry.decompSz, wfp);
|
||||
fclose(wfp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -724,6 +712,8 @@ static bool ValidateRS2(FILE* fp)
|
|||
RS2FSTEntry entry;
|
||||
fread(&entry, 1, 64, fp);
|
||||
entry.swapBig();
|
||||
if (!entry.offset)
|
||||
return false; /* This is to reject RS3 data */
|
||||
if (!strncmp("data", entry.name, 32))
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue