mirror of https://github.com/stella-emu/stella.git
disable user palette option if no file exists (resolves #572)
This commit is contained in:
parent
7a7969ae8a
commit
aa18ce6bcd
|
@ -996,22 +996,11 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Console::loadUserPalette()
|
void Console::loadUserPalette()
|
||||||
{
|
{
|
||||||
const string& palette = myOSystem.paletteFile();
|
if (!myOSystem.checkUserPalette(true))
|
||||||
ifstream in(palette, std::ios::binary);
|
|
||||||
if(!in)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Make sure the contains enough data for the NTSC, PAL and SECAM palettes
|
const string& palette = myOSystem.paletteFile();
|
||||||
// This means 128 colours each for NTSC and PAL, at 3 bytes per pixel
|
ifstream in(palette, std::ios::binary);
|
||||||
// and 8 colours for SECAM at 3 bytes per pixel
|
|
||||||
in.seekg(0, std::ios::end);
|
|
||||||
std::streampos length = in.tellg();
|
|
||||||
in.seekg(0, std::ios::beg);
|
|
||||||
if(length < 128 * 3 * 2 + 8 * 3)
|
|
||||||
{
|
|
||||||
cerr << "ERROR: invalid palette file " << palette << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now that we have valid data, create the user-defined palettes
|
// Now that we have valid data, create the user-defined palettes
|
||||||
std::array<uInt8, 3> pixbuf; // Temporary buffer for one 24-bit pixel
|
std::array<uInt8, 3> pixbuf; // Temporary buffer for one 24-bit pixel
|
||||||
|
|
|
@ -301,6 +301,29 @@ void OSystem::setConfigPaths()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool OSystem::checkUserPalette(bool outputError) const
|
||||||
|
{
|
||||||
|
const string& palette = paletteFile();
|
||||||
|
ifstream in(palette, std::ios::binary);
|
||||||
|
if (!in)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Make sure the contains enough data for the NTSC, PAL and SECAM palettes
|
||||||
|
// This means 128 colours each for NTSC and PAL, at 3 bytes per pixel
|
||||||
|
// and 8 colours for SECAM at 3 bytes per pixel
|
||||||
|
in.seekg(0, std::ios::end);
|
||||||
|
std::streampos length = in.tellg();
|
||||||
|
in.seekg(0, std::ios::beg);
|
||||||
|
if (length < 128 * 3 * 2 + 8 * 3)
|
||||||
|
{
|
||||||
|
if (outputError)
|
||||||
|
cerr << "ERROR: invalid palette file " << palette << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
FBInitStatus OSystem::createFrameBuffer()
|
FBInitStatus OSystem::createFrameBuffer()
|
||||||
{
|
{
|
||||||
|
|
|
@ -287,6 +287,11 @@ class OSystem
|
||||||
*/
|
*/
|
||||||
const string& paletteFile() const { return myPaletteFile; }
|
const string& paletteFile() const { return myPaletteFile; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Checks if a valid a user-defined palette file exists.
|
||||||
|
*/
|
||||||
|
bool checkUserPalette(bool outputError = false) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method should be called to get the full path of the currently
|
This method should be called to get the full path of the currently
|
||||||
loaded ROM.
|
loaded ROM.
|
||||||
|
|
|
@ -116,8 +116,9 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
// TIA Palette
|
// TIA Palette
|
||||||
items.clear();
|
items.clear();
|
||||||
VarList::push_back(items, "Standard", "standard");
|
VarList::push_back(items, "Standard", "standard");
|
||||||
VarList::push_back(items, "Z26", "z26");
|
VarList::push_back(items, "z26", "z26");
|
||||||
VarList::push_back(items, "User", "user");
|
if (instance().checkUserPalette())
|
||||||
|
VarList::push_back(items, "User", "user");
|
||||||
myTIAPalette = new PopUpWidget(myTab, font, xpos, ypos, pwidth,
|
myTIAPalette = new PopUpWidget(myTab, font, xpos, ypos, pwidth,
|
||||||
lineHeight, items, "Palette ", lwidth);
|
lineHeight, items, "Palette ", lwidth);
|
||||||
wid.push_back(myTIAPalette);
|
wid.push_back(myTIAPalette);
|
||||||
|
|
Loading…
Reference in New Issue