Fixed a PNG load crash, and added more PNG text chunks when saving snapshots.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2570 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2012-11-11 23:32:25 +00:00
parent 13d36f0860
commit 0616691bc5
10 changed files with 81 additions and 11 deletions

View File

@ -12,13 +12,21 @@
Release History Release History
=========================================================================== ===========================================================================
3.7.4 to 3.8: (December xx, 2012)
* Fixed crash when loading invalid PNG files in ROM browser.
* Snapshots generated by Stella now include more informative info, such
as the build number, platform architecture, TV effects in use, etc.
-Have fun!
3.7.3 to 3.7.4: (October 31, 2012) 3.7.3 to 3.7.4: (October 31, 2012)
* Fixed screen blanking regression in 'Video Chess', and improved * Fixed screen blanking regression in 'Video Chess', and improved
behaviour of ROMs that don't use VSYNC. behaviour of ROMs that don't use VSYNC.
-Have fun!
3.7.2 to 3.7.3: (October 26, 2012) 3.7.2 to 3.7.3: (October 26, 2012)

View File

@ -438,6 +438,32 @@ void FrameBufferGL::scanline(uInt32 row, uInt8* data) const
p_gl.ReadPixels(image.x(), row, image.width(), 1, GL_RGB, GL_UNSIGNED_BYTE, data); p_gl.ReadPixels(image.x(), row, image.width(), 1, GL_RGB, GL_UNSIGNED_BYTE, data);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string FrameBufferGL::effectsInfo() const
{
ostringstream buf;
switch(myFilterType)
{
case kNormal:
buf << "Disabled, normal mode";
break;
case kPhosphor:
buf << "Disabled, phosphor mode";
break;
case kBlarggNormal:
buf << myNTSCFilter.getPreset() << ", scanlines="
<< myTiaSurface->myScanlineIntensityI << "/"
<< (myTiaSurface->myTexFilter[1] == GL_LINEAR ? "inter" : "nointer");
break;
case kBlarggPhosphor:
buf << myNTSCFilter.getPreset() << ", phosphor, scanlines="
<< myTiaSurface->myScanlineIntensityI << "/"
<< (myTiaSurface->myTexFilter[1] == GL_LINEAR ? "inter" : "nointer");
break;
}
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBufferGL::myLibraryLoaded = false; bool FrameBufferGL::myLibraryLoaded = false;

View File

@ -112,6 +112,11 @@ class FrameBufferGL : public FrameBuffer
*/ */
BufferType type() const { return kDoubleBuffer; } BufferType type() const { return kDoubleBuffer; }
/**
This method is called to query the TV effects in use by the FrameBuffer.
*/
string effectsInfo() const;
/** /**
This method is called to get the specified scanline data. This method is called to get the specified scanline data.

View File

@ -242,13 +242,15 @@ void PNGLibrary::png_io_flush(png_structp ctx)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_user_warn(png_structp ctx, png_const_charp str) void PNGLibrary::png_user_warn(png_structp ctx, png_const_charp str)
{ {
cout << "PNGLibrary warning: " << str << endl; const string& msg = string("PNGLibrary warning: ") + str;
throw msg.c_str();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_user_error(png_structp ctx, png_const_charp str) void PNGLibrary::png_user_error(png_structp ctx, png_const_charp str)
{ {
cout << "PNGLibrary error: " << str << endl; const string& msg = string("PNGLibrary error: ") + str;
throw msg.c_str();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -53,7 +53,8 @@ string Snapshot::savePNG(const FrameBuffer& framebuffer, const Properties& props
buf_ptr += pitch; // add pitch buf_ptr += pitch; // add pitch
} }
return saveBufferToPNG(out, buffer, width, height, props); return saveBufferToPNG(out, buffer, width, height,
props, framebuffer.effectsInfo());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -86,13 +87,15 @@ string Snapshot::savePNG(const FrameBuffer& framebuffer, const TIA& tia,
} }
} }
return saveBufferToPNG(out, buffer, width<<1, height, props); return saveBufferToPNG(out, buffer, width << 1, height,
props, framebuffer.effectsInfo());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Snapshot::saveBufferToPNG(ofstream& out, uInt8* buffer, string Snapshot::saveBufferToPNG(ofstream& out, uInt8* buffer,
uInt32 width, uInt32 height, uInt32 width, uInt32 height,
const Properties& props) const Properties& props,
const string& effectsInfo)
{ {
uInt8* compmem = (uInt8*) NULL; uInt8* compmem = (uInt8*) NULL;
@ -130,10 +133,14 @@ string Snapshot::saveBufferToPNG(ofstream& out, uInt8* buffer,
writePNGChunk(out, "IDAT", compmem, compmemsize); writePNGChunk(out, "IDAT", compmem, compmemsize);
// Add some info about this snapshot // Add some info about this snapshot
writePNGText(out, "Software", string("Stella ") + STELLA_VERSION); ostringstream text;
text << "Stella " << STELLA_VERSION << " (Build " << STELLA_BUILD << ") ["
<< BSPF_ARCH << "]";
writePNGText(out, "Software", text.str());
writePNGText(out, "ROM Name", props.get(Cartridge_Name)); writePNGText(out, "ROM Name", props.get(Cartridge_Name));
writePNGText(out, "ROM MD5", props.get(Cartridge_MD5)); writePNGText(out, "ROM MD5", props.get(Cartridge_MD5));
writePNGText(out, "Display Format", props.get(Display_Format)); writePNGText(out, "TV Effects", effectsInfo);
// Finish up // Finish up
writePNGChunk(out, "IEND", 0, 0); writePNGChunk(out, "IEND", 0, 0);

View File

@ -56,7 +56,8 @@ class Snapshot
private: private:
static string saveBufferToPNG(ofstream& out, uInt8* buffer, static string saveBufferToPNG(ofstream& out, uInt8* buffer,
uInt32 width, uInt32 height, uInt32 width, uInt32 height,
const Properties& props); const Properties& props,
const string& effectsInfo);
static void writePNGChunk(ofstream& out, const char* type, uInt8* data, int size); static void writePNGChunk(ofstream& out, const char* type, uInt8* data, int size);
static void writePNGText(ofstream& out, const string& key, const string& text); static void writePNGText(ofstream& out, const string& key, const string& text);
}; };

View File

@ -22,7 +22,7 @@
#include <cstdlib> #include <cstdlib>
#define STELLA_VERSION "3.7.4" #define STELLA_VERSION "3.8_pre"
#define STELLA_BUILD atoi("$Rev$" + 6) #define STELLA_BUILD atoi("$Rev$" + 6)
#endif #endif

View File

@ -110,6 +110,20 @@ string NTSCFilter::setPreset(Preset preset)
return msg; return msg;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::getPreset() const
{
switch(myPreset)
{
case PRESET_COMPOSITE: return "COMPOSITE";
case PRESET_SVIDEO: return "S-VIDEO";
case PRESET_RGB: return "RGB";
case PRESET_BAD: return "BAD ADJUST";
case PRESET_CUSTOM: return "CUSTOM";
default: return "Disabled";
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::setNextAdjustable() string NTSCFilter::setNextAdjustable()
{ {

View File

@ -69,6 +69,9 @@ class NTSCFilter
// The following are meant to be used strictly for toggling from the GUI // The following are meant to be used strictly for toggling from the GUI
string setPreset(Preset preset); string setPreset(Preset preset);
// Get current preset info encoded as a string
string getPreset() const;
// Reinitialises the NTSC filter (automatically called after settings // Reinitialises the NTSC filter (automatically called after settings
// have changed) // have changed)
inline void updateFilter() inline void updateFilter()

View File

@ -325,6 +325,10 @@ class FrameBuffer
*/ */
virtual void enableNTSC(bool enable) { } virtual void enableNTSC(bool enable) { }
virtual bool ntscEnabled() const { return false; } virtual bool ntscEnabled() const { return false; }
/**
This method is called to query the TV effects in use by the FrameBuffer.
*/
virtual string effectsInfo() const { return "None / not available"; }
private: private:
/** /**