mirror of https://github.com/stella-emu/stella.git
Revert "Convert more defines to static constexpr."
This reverts commit 58382db331
.
Mistakenly checked in debug code for another part of the codebase.
This commit is contained in:
parent
58382db331
commit
61d6d89a21
|
@ -36,11 +36,11 @@ FSNodeZIP::FSNodeZIP(const string& p)
|
||||||
_zipFile = p.substr(0, pos+4);
|
_zipFile = p.substr(0, pos+4);
|
||||||
|
|
||||||
// Expand '~' to the users 'home' directory
|
// Expand '~' to the users 'home' directory
|
||||||
if(_zipFile[0] == '~')
|
if (_zipFile[0] == '~')
|
||||||
{
|
{
|
||||||
#if defined(BSPF_UNIX) || defined(BSPF_MACOS)
|
#if defined(BSPF_UNIX) || defined(BSPF_MACOS)
|
||||||
const char* const home = std::getenv("HOME"); // NOLINT (not thread safe)
|
const char* const home = std::getenv("HOME"); // NOLINT (not thread safe)
|
||||||
if(home != nullptr)
|
if (home != nullptr)
|
||||||
_zipFile.replace(0, 1, home);
|
_zipFile.replace(0, 1, home);
|
||||||
#elif defined(BSPF_WINDOWS)
|
#elif defined(BSPF_WINDOWS)
|
||||||
_zipFile.replace(0, 1, HomeFinder::getHomePath());
|
_zipFile.replace(0, 1, HomeFinder::getHomePath());
|
||||||
|
@ -267,24 +267,12 @@ size_t FSNodeZIP::write(const stringstream& buffer) const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
AbstractFSNodePtr FSNodeZIP::getParent() const
|
AbstractFSNodePtr FSNodeZIP::getParent() const
|
||||||
{
|
{
|
||||||
cerr << "zip : " << _zipFile << endl
|
|
||||||
<< "vp : " << _virtualPath << endl
|
|
||||||
<< "path: " << _path << endl
|
|
||||||
<< "name: " << _name << endl;
|
|
||||||
if(_virtualPath.empty())
|
if(_virtualPath.empty())
|
||||||
{
|
|
||||||
if(_realNode)
|
|
||||||
cerr << "parent: " << _realNode->getParent()->getPath();
|
|
||||||
else
|
|
||||||
cerr << "parent: nullptr";
|
|
||||||
cerr << "\n\n\n";
|
|
||||||
return _realNode ? _realNode->getParent() : nullptr;
|
return _realNode ? _realNode->getParent() : nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
const char* const start = _path.c_str();
|
const char* const start = _path.c_str();
|
||||||
const char* const end = lastPathComponent(_path);
|
const char* const end = lastPathComponent(_path);
|
||||||
|
|
||||||
cerr << "new zip: " << string(start, end - start - 1) << "\n\n\n";
|
|
||||||
return make_unique<FSNodeZIP>(string(start, end - start - 1));
|
return make_unique<FSNodeZIP>(string(start, end - start - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,14 @@ void ZipHandler::open(const string& filename)
|
||||||
// Open the file and initialize it
|
// Open the file and initialize it
|
||||||
if(!ptr->open())
|
if(!ptr->open())
|
||||||
throw runtime_error(errorMessage(ZipError::FILE_ERROR));
|
throw runtime_error(errorMessage(ZipError::FILE_ERROR));
|
||||||
ptr->initialize();
|
try
|
||||||
|
{
|
||||||
|
ptr->initialize();
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
myZip = std::move(ptr);
|
myZip = std::move(ptr);
|
||||||
|
|
||||||
|
@ -93,7 +100,7 @@ std::tuple<string, size_t> ZipHandler::next()
|
||||||
{
|
{
|
||||||
if(hasNext())
|
if(hasNext())
|
||||||
{
|
{
|
||||||
const ZipHeader* const header = myZip->nextFile();
|
const ZipHeader* header = myZip->nextFile();
|
||||||
if(!header)
|
if(!header)
|
||||||
throw runtime_error(errorMessage(ZipError::FILE_CORRUPT));
|
throw runtime_error(errorMessage(ZipError::FILE_CORRUPT));
|
||||||
else if(header->uncompressedLength == 0)
|
else if(header->uncompressedLength == 0)
|
||||||
|
@ -200,8 +207,8 @@ void ZipHandler::addToCache()
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
ZipHandler::ZipFile::ZipFile(const string& filename)
|
ZipHandler::ZipFile::ZipFile(const string& filename)
|
||||||
: myFilename{filename},
|
: myFilename(filename),
|
||||||
myBuffer{make_unique<uInt8[]>(DECOMPRESS_BUFSIZE)}
|
myBuffer(make_unique<uInt8[]>(DECOMPRESS_BUFSIZE))
|
||||||
{
|
{
|
||||||
std::fill(myBuffer.get(), myBuffer.get() + DECOMPRESS_BUFSIZE, 0);
|
std::fill(myBuffer.get(), myBuffer.get() + DECOMPRESS_BUFSIZE, 0);
|
||||||
}
|
}
|
||||||
|
@ -226,26 +233,33 @@ bool ZipHandler::ZipFile::open()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void ZipHandler::ZipFile::initialize()
|
void ZipHandler::ZipFile::initialize()
|
||||||
{
|
{
|
||||||
// Read ecd data
|
try
|
||||||
readEcd();
|
{
|
||||||
|
// Read ecd data
|
||||||
|
readEcd();
|
||||||
|
|
||||||
// Verify that we can work with this zipfile (no disk spanning allowed)
|
// Verify that we can work with this zipfile (no disk spanning allowed)
|
||||||
if(myEcd.diskNumber != myEcd.cdStartDiskNumber ||
|
if(myEcd.diskNumber != myEcd.cdStartDiskNumber ||
|
||||||
myEcd.cdDiskEntries != myEcd.cdTotalEntries)
|
myEcd.cdDiskEntries != myEcd.cdTotalEntries)
|
||||||
throw runtime_error(errorMessage(ZipError::UNSUPPORTED));
|
throw runtime_error(errorMessage(ZipError::UNSUPPORTED));
|
||||||
|
|
||||||
// Allocate memory for the central directory
|
// Allocate memory for the central directory
|
||||||
myCd = make_unique<uInt8[]>(myEcd.cdSize + 1);
|
myCd = make_unique<uInt8[]>(myEcd.cdSize + 1);
|
||||||
if(myCd == nullptr)
|
if(myCd == nullptr)
|
||||||
throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY));
|
throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY));
|
||||||
|
|
||||||
// Read the central directory
|
// Read the central directory
|
||||||
uInt64 read_length = 0;
|
uInt64 read_length = 0;
|
||||||
const bool success = readStream(myCd, myEcd.cdStartDiskOffset, myEcd.cdSize, read_length);
|
const bool success = readStream(myCd, myEcd.cdStartDiskOffset, myEcd.cdSize, read_length);
|
||||||
if(!success)
|
if(!success)
|
||||||
throw runtime_error(errorMessage(ZipError::FILE_ERROR));
|
throw runtime_error(errorMessage(ZipError::FILE_ERROR));
|
||||||
else if(read_length != myEcd.cdSize)
|
else if(read_length != myEcd.cdSize)
|
||||||
throw runtime_error(errorMessage(ZipError::FILE_TRUNCATED));
|
throw runtime_error(errorMessage(ZipError::FILE_TRUNCATED));
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -292,7 +306,7 @@ void ZipHandler::ZipFile::readEcd()
|
||||||
if(offset >= 0)
|
if(offset >= 0)
|
||||||
{
|
{
|
||||||
// Extract ECD info
|
// Extract ECD info
|
||||||
const EcdReader reader(buffer.get() + offset);
|
EcdReader const reader(buffer.get() + offset);
|
||||||
myEcd.diskNumber = reader.thisDiskNo();
|
myEcd.diskNumber = reader.thisDiskNo();
|
||||||
myEcd.cdStartDiskNumber = reader.dirStartDisk();
|
myEcd.cdStartDiskNumber = reader.dirStartDisk();
|
||||||
myEcd.cdDiskEntries = reader.dirDiskEntries();
|
myEcd.cdDiskEntries = reader.dirDiskEntries();
|
||||||
|
@ -334,7 +348,7 @@ const ZipHandler::ZipHeader* ZipHandler::ZipFile::nextFile()
|
||||||
{
|
{
|
||||||
// Make sure we have enough data
|
// Make sure we have enough data
|
||||||
// If we're at or past the end, we're done
|
// If we're at or past the end, we're done
|
||||||
const CentralDirEntryReader reader(myCd.get() + myCdPos);
|
CentralDirEntryReader const reader(myCd.get() + myCdPos);
|
||||||
if(!reader.signatureCorrect() || ((myCdPos + reader.totalLength()) > myEcd.cdSize))
|
if(!reader.signatureCorrect() || ((myCdPos + reader.totalLength()) > myEcd.cdSize))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -366,26 +380,33 @@ void ZipHandler::ZipFile::decompress(const ByteBuffer& out, uInt64 length)
|
||||||
if(myHeader.startDiskNumber != myEcd.diskNumber)
|
if(myHeader.startDiskNumber != myEcd.diskNumber)
|
||||||
throw runtime_error(errorMessage(ZipError::UNSUPPORTED));
|
throw runtime_error(errorMessage(ZipError::UNSUPPORTED));
|
||||||
|
|
||||||
// Get the compressed data offset
|
try
|
||||||
const uInt64 offset = getCompressedDataOffset();
|
|
||||||
|
|
||||||
// Handle compression types
|
|
||||||
switch(myHeader.compression)
|
|
||||||
{
|
{
|
||||||
case 0:
|
// Get the compressed data offset
|
||||||
decompressDataType0(offset, out, length);
|
const uInt64 offset = getCompressedDataOffset();
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
// Handle compression types
|
||||||
decompressDataType8(offset, out, length);
|
switch(myHeader.compression)
|
||||||
break;
|
{
|
||||||
|
case 0:
|
||||||
|
decompressDataType0(offset, out, length);
|
||||||
|
break;
|
||||||
|
|
||||||
case 14:
|
case 8:
|
||||||
// FIXME - LZMA format not yet supported
|
decompressDataType8(offset, out, length);
|
||||||
throw runtime_error(errorMessage(ZipError::LZMA_UNSUPPORTED));
|
break;
|
||||||
|
|
||||||
default:
|
case 14:
|
||||||
throw runtime_error(errorMessage(ZipError::UNSUPPORTED));
|
// FIXME - LZMA format not yet supported
|
||||||
|
throw runtime_error(errorMessage(ZipError::LZMA_UNSUPPORTED));
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw runtime_error(errorMessage(ZipError::UNSUPPORTED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +414,7 @@ void ZipHandler::ZipFile::decompress(const ByteBuffer& out, uInt64 length)
|
||||||
uInt64 ZipHandler::ZipFile::getCompressedDataOffset()
|
uInt64 ZipHandler::ZipFile::getCompressedDataOffset()
|
||||||
{
|
{
|
||||||
// Don't support a number of features
|
// Don't support a number of features
|
||||||
const GeneralFlagReader flags(myHeader.bitFlag);
|
GeneralFlagReader const flags(myHeader.bitFlag);
|
||||||
if(myHeader.startDiskNumber != myEcd.diskNumber ||
|
if(myHeader.startDiskNumber != myEcd.diskNumber ||
|
||||||
myHeader.versionNeeded > 63 || flags.patchData() ||
|
myHeader.versionNeeded > 63 || flags.patchData() ||
|
||||||
flags.encrypted() || flags.strongEncryption())
|
flags.encrypted() || flags.strongEncryption())
|
||||||
|
@ -441,7 +462,7 @@ void ZipHandler::ZipFile::decompressDataType8(
|
||||||
stream.opaque = Z_NULL;
|
stream.opaque = Z_NULL;
|
||||||
stream.avail_in = 0;
|
stream.avail_in = 0;
|
||||||
stream.next_out = reinterpret_cast<Bytef *>(out.get());
|
stream.next_out = reinterpret_cast<Bytef *>(out.get());
|
||||||
stream.avail_out = static_cast<uInt32>(length);
|
stream.avail_out = static_cast<uInt32>(length); // TODO - use zip64
|
||||||
|
|
||||||
// Initialize the decompressor
|
// Initialize the decompressor
|
||||||
int zerr = inflateInit2(&stream, -MAX_WBITS);
|
int zerr = inflateInit2(&stream, -MAX_WBITS);
|
||||||
|
@ -471,7 +492,7 @@ void ZipHandler::ZipFile::decompressDataType8(
|
||||||
|
|
||||||
// Fill out the input data
|
// Fill out the input data
|
||||||
stream.next_in = myBuffer.get();
|
stream.next_in = myBuffer.get();
|
||||||
stream.avail_in = static_cast<uInt32>(read_length);
|
stream.avail_in = static_cast<uInt32>(read_length); // TODO - use zip64
|
||||||
input_remaining -= read_length;
|
input_remaining -= read_length;
|
||||||
|
|
||||||
// Add a dummy byte at end of compressed data
|
// Add a dummy byte at end of compressed data
|
||||||
|
|
|
@ -300,7 +300,7 @@ class ZipHandler
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr size_t DECOMPRESS_BUFSIZE = 128_KB;
|
static constexpr size_t DECOMPRESS_BUFSIZE = 128_KB;
|
||||||
static constexpr size_t CACHE_SIZE = 64; // number of open files to cache
|
static constexpr size_t CACHE_SIZE = 16; // number of open files to cache
|
||||||
|
|
||||||
ZipFilePtr myZip;
|
ZipFilePtr myZip;
|
||||||
std::array<ZipFilePtr, CACHE_SIZE> myZipCache;
|
std::array<ZipFilePtr, CACHE_SIZE> myZipCache;
|
||||||
|
|
|
@ -274,7 +274,7 @@ void Thumbulator::dump_counters() const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Thumbulator::dump_regs()
|
void Thumbulator::dump_regs()
|
||||||
{
|
{
|
||||||
for(int cnt = 0; cnt <= 12; ++cnt)
|
for (int cnt = 0; cnt <= 12; cnt++)
|
||||||
{
|
{
|
||||||
statusMsg << "R" << std::dec << std::setfill(' ') << std::setw(2) << std::left << cnt
|
statusMsg << "R" << std::dec << std::setfill(' ') << std::setw(2) << std::left << cnt
|
||||||
<< "= " << Base::HEX8 << reg_norm[cnt];
|
<< "= " << Base::HEX8 << reg_norm[cnt];
|
||||||
|
|
|
@ -34,6 +34,17 @@ class Cartridge;
|
||||||
#define UNSAFE_OPTIMIZATIONS
|
#define UNSAFE_OPTIMIZATIONS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ROMADDMASK 0x7FFFF
|
||||||
|
#define RAMADDMASK 0x7FFF
|
||||||
|
|
||||||
|
#define ROMSIZE (ROMADDMASK+1) // 512KB
|
||||||
|
#define RAMSIZE (RAMADDMASK+1) // 32KB
|
||||||
|
|
||||||
|
#define CPSR_N (1u<<31)
|
||||||
|
#define CPSR_Z (1u<<30)
|
||||||
|
#define CPSR_C (1u<<29)
|
||||||
|
#define CPSR_V (1u<<28)
|
||||||
|
|
||||||
#ifdef DEBUGGER_SUPPORT
|
#ifdef DEBUGGER_SUPPORT
|
||||||
#define THUMB_CYCLE_COUNT
|
#define THUMB_CYCLE_COUNT
|
||||||
#define COUNT_OPS
|
#define COUNT_OPS
|
||||||
|
@ -324,19 +335,7 @@ class Thumbulator
|
||||||
|
|
||||||
ConfigureFor configuration;
|
ConfigureFor configuration;
|
||||||
|
|
||||||
Cartridge* myCartridge{nullptr};
|
Cartridge* myCartridge;
|
||||||
|
|
||||||
static constexpr uInt32
|
|
||||||
ROMADDMASK = 0x7FFFF,
|
|
||||||
RAMADDMASK = 0x7FFF,
|
|
||||||
|
|
||||||
ROMSIZE = ROMADDMASK + 1, // 512KB
|
|
||||||
RAMSIZE = RAMADDMASK + 1, // 32KB
|
|
||||||
|
|
||||||
CPSR_N = 1u << 31,
|
|
||||||
CPSR_Z = 1u << 30,
|
|
||||||
CPSR_C = 1u << 29,
|
|
||||||
CPSR_V = 1u << 28;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
Loading…
Reference in New Issue