This commit is contained in:
thrust26 2024-12-30 12:41:18 +01:00
commit 6d6522ad41
3 changed files with 22 additions and 21 deletions

View File

@ -395,22 +395,24 @@ string Console::formatFromSignature() const
static constexpr uInt8 PAL_60[] = { 'P', 'A', 'L', ' ', '6', '0'};
static constexpr uInt8 PAL__60[] = { 'P', 'A', 'L', '-', '6', '0'};
size_t size;
size_t size = 0;
const ByteBuffer& image = myCart->getImage(size);
if(searchForBytes(image, size, PAL60, 5) ||
searchForBytes(image, size, PAL_60, 6) ||
searchForBytes(image, size, PAL__60, 6))
searchForBytes(image, size, PAL_60, 6) ||
searchForBytes(image, size, PAL__60, 6))
return "PAL60";
// Nothing found
return "AUTO";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Console::searchForBytes(const ByteBuffer& image, size_t imagesize,
const uInt8* signature, uInt32 sigsize) const
const uInt8* signature, uInt32 sigsize)
{
if(imagesize >= sigsize)
{
for(uInt32 i = 0; i < imagesize - sigsize; ++i)
{
uInt32 matches = 0;
@ -422,11 +424,9 @@ bool Console::searchForBytes(const ByteBuffer& image, size_t imagesize,
break;
}
if(matches == sigsize)
{
return true;
}
}
}
return false;
}

View File

@ -426,20 +426,6 @@ class Console : public Serializable, public ConsoleIO
*/
string formatFromSignature() const;
/**
Search the image for the specified byte signature.
@param image A pointer to the ROM image
@param imagesize The size of the ROM image
@param signature The byte sequence to search for
@param sigsize The number of bytes in the signature
@return True if the signature was found, else false
*/
bool searchForBytes(const ByteBuffer& image, size_t imagesize,
const uInt8* signature, uInt32 sigsize) const;
/**
Create the audio queue
*/
@ -457,6 +443,19 @@ class Console : public Serializable, public ConsoleIO
void toggleTIACollision(TIABit bit, string_view bitname,
bool show = true, bool toggle = true) const;
/**
Search the image for the specified byte signature.
@param image A pointer to the ROM image
@param imagesize The size of the ROM image
@param signature The byte sequence to search for
@param sigsize The number of bytes in the signature
@return True if the signature was found, else false
*/
static bool searchForBytes(const ByteBuffer& image, size_t imagesize,
const uInt8* signature, uInt32 sigsize);
private:
// Reference to the osystem object
OSystem& myOSystem;

View File

@ -121,6 +121,7 @@ void FrameManager::setAdjustVSize(Int32 adjustVSize)
void FrameManager::onSetVblank(uInt64 cycles)
{
if (myState == State::waitForVsyncEnd)
{
if (myVblank) // VBLANK switched on
{
myVblankStart = cycles;
@ -129,6 +130,7 @@ void FrameManager::onSetVblank(uInt64 cycles)
{
myVblankCycles += cycles - myVblankStart;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -