Fix callback usage.

This commit is contained in:
Christian Speckner 2021-10-10 00:08:44 +02:00
parent 2921bc29de
commit 6bb055a159
2 changed files with 8 additions and 8 deletions

View File

@ -52,7 +52,7 @@ class Cartridge : public Device
/**
Callback type for general cart messages
*/
using messageCallback = std::function<void(const string&)>;
using messageCallback = std::function<void(const string&)>;
// Maximum size of a ROM cart that Stella can support
static constexpr size_t maxSize() { return 512_KB; }
@ -144,10 +144,10 @@ class Cartridge : public Device
/**
Set the callback for displaying messages
*/
void setMessageCallback(const messageCallback& callback)
void setMessageCallback(messageCallback callback)
{
if(myMsgCallback == nullptr)
myMsgCallback = &callback;
if(!myMsgCallback)
myMsgCallback = callback;
}
#ifdef DEBUGGER_SUPPORT
@ -415,7 +415,7 @@ class Cartridge : public Device
uInt32 myAccessSize;
// Callback to output messages
const messageCallback* myMsgCallback{nullptr};
messageCallback myMsgCallback{nullptr};
private:
// The startup bank to use (where to look for the reset vector address)

View File

@ -306,7 +306,7 @@ void CartridgeAR::loadIntoRAM(uInt8 load)
if(checksum(myHeader.data(), 8) != 0x55)
{
cerr << "WARNING: The Supercharger header checksum is invalid...\n";
(*myMsgCallback)("Supercharger load #" + std::to_string(load) + " done with hearder checksum error");
myMsgCallback("Supercharger load #" + std::to_string(load) + " done with hearder checksum error");
success = false;
}
@ -322,7 +322,7 @@ void CartridgeAR::loadIntoRAM(uInt8 load)
if(!invalidPageChecksumSeen && (sum != 0x55))
{
cerr << "WARNING: Some Supercharger page checksums are invalid...\n";
(*myMsgCallback)("Supercharger load #" + std::to_string(load) + " done with page #"
myMsgCallback("Supercharger load #" + std::to_string(load) + " done with page #"
+ std::to_string(j) + " checksum error");
invalidPageChecksumSeen = true;
}
@ -341,7 +341,7 @@ void CartridgeAR::loadIntoRAM(uInt8 load)
myBankChanged = true;
if(success)
(*myMsgCallback)("Supercharger load #" + std::to_string(load) + " done");
myMsgCallback("Supercharger load #" + std::to_string(load) + " done");
return;
}
}