From 8b7043d74a065f1a45ec68369e4461335904d34c Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 6 Dec 2015 18:12:17 +0000 Subject: [PATCH] More bugfixes as indicated by Coverity. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3235 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/common/FBSurfaceSDL2.cxx | 4 +- src/common/FrameBufferSDL2.cxx | 54 +------------- src/common/FrameBufferSDL2.hxx | 3 +- src/common/Version.hxx | 2 +- src/common/stella_icon.hxx | 66 +++++++++++++++++ src/debugger/CartDebug.cxx | 2 +- src/debugger/DebuggerParser.cxx | 9 +-- src/debugger/gui/PromptWidget.cxx | 4 +- src/debugger/gui/PromptWidget.hxx | 4 +- src/emucore/KidVid.cxx | 10 +-- src/emucore/NullDev.hxx | 4 +- src/emucore/Props.cxx | 4 +- src/emucore/TIA.cxx | 119 ++++++++++++++---------------- src/emucore/TIA.hxx | 3 + src/emucore/Thumbulator.cxx | 9 ++- src/gui/VideoDialog.cxx | 2 +- 16 files changed, 157 insertions(+), 142 deletions(-) create mode 100644 src/common/stella_icon.hxx diff --git a/src/common/FBSurfaceSDL2.cxx b/src/common/FBSurfaceSDL2.cxx index 677c91ac4..487064ad6 100644 --- a/src/common/FBSurfaceSDL2.cxx +++ b/src/common/FBSurfaceSDL2.cxx @@ -189,8 +189,8 @@ void FBSurfaceSDL2::reload() void FBSurfaceSDL2::resize(uInt32 width, uInt32 height) { // We will only resize when necessary, and not using static textures - if((myTexAccess == SDL_TEXTUREACCESS_STATIC) || - (int(width) <= mySurface->w && int(height) <= mySurface->h)) + if((myTexAccess == SDL_TEXTUREACCESS_STATIC) || (mySurface && + int(width) <= mySurface->w && int(height) <= mySurface->h)) return; // don't need to resize at all if(mySurface) diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index a3ef73310..204d1f23a 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -276,58 +276,10 @@ void FrameBufferSDL2::postFrameUpdate() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSDL2::setWindowIcon() { -#ifndef BSPF_MAC_OSX // Currently not needed for OSX - #include "stella.xpm" // The Stella icon +#ifndef BSPF_MAC_OSX // Currently not needed for OSX +#include "stella_icon.hxx" // The Stella icon - // Set the window icon - uInt32 w, h, ncols, nbytes; - uInt32 rgba[256], icon[32 * 32]; - uInt8 mask[32][4]; - - sscanf(stella_icon[0], "%2u %2u %2u %2u", &w, &h, &ncols, &nbytes); - if((w != 32) || (h != 32) || (ncols > 255) || (nbytes > 1)) - { - myOSystem.logMessage("ERROR: Couldn't load the application icon.", 0); - return; - } - - for(uInt32 i = 0; i < ncols; i++) - { - uInt8 code; - char color[32]; - uInt32 col; - - sscanf(stella_icon[1 + i], "%c c %s", &code, color); - if(!strcmp(color, "None")) - col = 0x00000000; - else if(!strcmp(color, "black")) - col = 0xFF000000; - else if (color[0] == '#') - { - sscanf(color + 1, "%06x", &col); - col |= 0xFF000000; - } - else - { - myOSystem.logMessage("ERROR: Couldn't load the application icon.", 0); - return; - } - rgba[code] = col; - } - - memset(mask, 0, sizeof(mask)); - for(h = 0; h < 32; h++) - { - const char* line = stella_icon[1 + ncols + h]; - for(w = 0; w < 32; w++) - { - icon[w + 32 * h] = rgba[int(line[w])]; - if(rgba[int(line[w])] & 0xFF000000) - mask[h][w >> 3] |= 1 << (7 - (w & 0x07)); - } - } - - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(icon, 32, 32, 32, + SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(stella_icon, 32, 32, 32, 32 * 4, 0xFF0000, 0x00FF00, 0x0000FF, 0xFF000000); SDL_SetWindowIcon(myWindow, surface); SDL_FreeSurface(surface); diff --git a/src/common/FrameBufferSDL2.hxx b/src/common/FrameBufferSDL2.hxx index 31efe9b4d..d9928f577 100644 --- a/src/common/FrameBufferSDL2.hxx +++ b/src/common/FrameBufferSDL2.hxx @@ -145,7 +145,8 @@ class FrameBufferSDL2 : public FrameBuffer @param h The requested height of the new surface. @param data If non-null, use the given data values as a static surface */ - unique_ptr createSurface(uInt32 w, uInt32 h, const uInt32* data) const override; + unique_ptr createSurface(uInt32 w, uInt32 h, const uInt32* data) + const override; /** Grabs or ungrabs the mouse based on the given boolean value. diff --git a/src/common/Version.hxx b/src/common/Version.hxx index 2c3ed1ea8..9a3870902 100644 --- a/src/common/Version.hxx +++ b/src/common/Version.hxx @@ -22,7 +22,7 @@ #include -#define STELLA_VERSION "4.6.7" +#define STELLA_VERSION "4.7_pre" #define STELLA_BUILD atoi("$Rev$" + 6) #endif diff --git a/src/common/stella_icon.hxx b/src/common/stella_icon.hxx new file mode 100644 index 000000000..ccb300437 --- /dev/null +++ b/src/common/stella_icon.hxx @@ -0,0 +1,66 @@ +static uInt32 stella_icon[] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, + 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, + 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, + 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, + 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 +}; diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 778347c07..73ca8bf70 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -831,7 +831,7 @@ string CartDebug::loadConfigFile() { // Skip leading space int c = in.peek(); - while(c == ' ' && c == '\t') + while(c == ' ' || c == '\t') { in.get(); c = in.peek(); diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 4bd0da6a5..7308a6079 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -203,8 +203,8 @@ int DebuggerParser::decipher_arg(const string& str) } if(arg.substr(0, 1) == "\\") { - bin = true; dec = false; + bin = true; arg.erase(0, 1); } else if(arg.substr(0, 1) == "#") { dec = true; @@ -216,11 +216,6 @@ int DebuggerParser::decipher_arg(const string& str) arg.erase(0, 1); } - // sanity check mutually exclusive options: - if(derefByte && derefWord) return -1; - if(lobyte && hibyte) return -1; - if(bin && dec) return -1; - // Special cases (registers): const CpuState& state = static_cast(debugger.cpuDebug().getState()); if(arg == "a") result = state.A; @@ -1015,7 +1010,7 @@ void DebuggerParser::executeJump() // The specific address we want may not exist (it may be part of a data section) // If so, scroll backward a little until we find it while(((line = debugger.cartDebug().addressToLine(address)) == -1) && - ((address & 0xFFF) >= 0)) + (address >= 0)) address--; if(line >= 0 && address >= 0) diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index c6ec3ea00..3b4dc6a49 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -634,9 +634,9 @@ void PromptWidget::killLastWord() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PromptWidget::addToHistory(const char *str) +void PromptWidget::addToHistory(const char* str) { - strcpy(_history[_historyIndex], str); + strncpy(_history[_historyIndex], str, kLineBufferSize-1); _historyIndex = (_historyIndex + 1) % kHistorySize; _historyLine = 0; diff --git a/src/debugger/gui/PromptWidget.hxx b/src/debugger/gui/PromptWidget.hxx index 023bbf169..83071689e 100644 --- a/src/debugger/gui/PromptWidget.hxx +++ b/src/debugger/gui/PromptWidget.hxx @@ -36,8 +36,8 @@ class PromptWidget : public Widget, public CommandSender virtual ~PromptWidget(); public: - int printf(const char *format, ...); - int vprintf(const char *format, va_list argptr); + int printf(const char* format, ...); + int vprintf(const char* format, va_list argptr); void print(const string& str); void printPrompt(); bool saveBuffer(string& filename); diff --git a/src/emucore/KidVid.cxx b/src/emucore/KidVid.cxx index 27e170934..f5fe8abbd 100644 --- a/src/emucore/KidVid.cxx +++ b/src/emucore/KidVid.cxx @@ -196,7 +196,7 @@ cerr << "opened file: " << kvNameTable[i] << endl; else { cerr << "opened file: " << "kvshared.wav" << endl; - fseek(mySampleFile, 45, SEEK_SET); +// fseek(mySampleFile, 45, SEEK_SET); myFileOpened = true; } } @@ -232,9 +232,9 @@ void KidVid::setNextSong() mySongCounter = ourSongStart[temp+1] - ourSongStart[temp]; if(mySharedData) - fseek(mySharedSampleFile, ourSongStart[temp], SEEK_SET); + ; // fseek(mySharedSampleFile, ourSongStart[temp], SEEK_SET); else - fseek(mySampleFile, ourSongStart[temp], SEEK_SET); + ; // fseek(mySampleFile, ourSongStart[temp], SEEK_SET); myFilePointer++; myTapeBusy = true; @@ -250,10 +250,10 @@ void KidVid::setNextSong() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void KidVid::getNextSampleByte() { -#if 1 - static int oddeven = 0; +// static int oddeven = 0; if(mySongCounter == 0) mySampleByte = 0x80; +#if 0 else { oddeven = oddeven^1; diff --git a/src/emucore/NullDev.hxx b/src/emucore/NullDev.hxx index 4df422ded..9561d6793 100644 --- a/src/emucore/NullDev.hxx +++ b/src/emucore/NullDev.hxx @@ -90,7 +90,7 @@ class NullDevice : public Device @return The byte at the specified address */ uInt8 peek(uInt16 address) override { - cerr << hex << "NullDevice: peek(" << address << ")\n"; + cerr << "NullDevice: peek(" << address << ")\n"; return 0; } @@ -103,7 +103,7 @@ class NullDevice : public Device @return True if the poke changed the device address space, else false */ bool poke(uInt16 address, uInt8 value) override { - cerr << hex << "NullDevice: poke(" << address << "," << value << ")\n"; + cerr << "NullDevice: poke(" << address << "," << value << ")\n"; return false; } diff --git a/src/emucore/Props.cxx b/src/emucore/Props.cxx index 0502f3b19..0e5aa9ad4 100644 --- a/src/emucore/Props.cxx +++ b/src/emucore/Props.cxx @@ -42,13 +42,13 @@ void Properties::set(PropertyType key, const string& value) if(key != LastPropType) { myProperties[key] = value; + if(BSPF_equalsIgnoreCase(myProperties[key], "AUTO-DETECT")) + myProperties[key] = "AUTO"; switch(key) { case Cartridge_Type: case Display_Format: - if(BSPF_equalsIgnoreCase(myProperties[key], "AUTO-DETECT")) - myProperties[key] = "AUTO"; case Cartridge_Sound: case Console_LeftDifficulty: case Console_RightDifficulty: diff --git a/src/emucore/TIA.cxx b/src/emucore/TIA.cxx index a78df2465..5c7257818 100644 --- a/src/emucore/TIA.cxx +++ b/src/emucore/TIA.cxx @@ -50,40 +50,17 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings) myFrameYStart(34), myFrameHeight(210), myMaximumNumberOfScanlines(262), - myStartScanline(0), - myColorLossEnabled(false), - myPartialFrameFlag(false), - myAutoFrameEnabled(false), - myFrameCounter(0), - myPALFrameCounter(0), - myBitsEnabled(true), - myCollisionsEnabled(true), - myJitterEnabled(false), - myNextFrameJitter(0), - myCurrentFrameJitter(0) - + myStartScanline(0) { // Allocate buffers for two frame buffers myCurrentFrameBuffer = new uInt8[160 * 320]; myPreviousFrameBuffer = new uInt8[160 * 320]; - // Make sure all TIA bits are enabled - enableBits(true); - - // Turn off debug colours (this also sets up the PriorityEncoder) - toggleFixedColors(0); - // Compute all of the mask tables TIATables::computeAllTables(); - // Zero audio registers - myAUDV0 = myAUDV1 = myAUDF0 = myAUDF1 = myAUDC0 = myAUDC1 = 0; - - // Should undriven pins be randomly pulled high or low? - myTIAPinsDriven = mySettings.getBool("tiadriven"); - - // Enable scanline jittering - myJitterEnabled = mySettings.getBool("tv.jitter"); + // Set initial state + initialize(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -94,61 +71,41 @@ TIA::~TIA() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TIA::reset() +void TIA::initialize() { - // Reset the sound device - mySound.reset(); + myFramePointer = nullptr; + myFramePointerOffset = myFramePointerClocks = myStopDisplayOffset = 0; - // Currently no objects are enabled or selectively disabled - myEnabledObjects = 0; - myDisabledObjects = 0xFF; - myAllowHMOVEBlanks = true; + myClockWhenFrameStarted = myClockStartDisplay = myClockStopDisplay = + myClockAtLastUpdate = myClocksToEndOfScanLine = myVSYNCFinishClock = 0; - // Some default values for the registers - myVSYNC = myVBLANK = 0; - myNUSIZ0 = myNUSIZ1 = 0; + myScanlineCountForLastFrame = myStartScanline = 0; + + myVSYNC = myVBLANK = myNUSIZ0 = myNUSIZ1 = 0; + + myPlayfieldPriorityAndScore = myCTRLPF = 0; myColor[P0Color] = myColor[P1Color] = myColor[PFColor] = myColor[BKColor] = 0; myColor[M0Color] = myColor[M1Color] = myColor[BLColor] = myColor[HBLANKColor] = 0; + myColorPtr = nullptr; - myPlayfieldPriorityAndScore = 0; - myCTRLPF = 0; myREFP0 = myREFP1 = false; myPF = 0; - myGRP0 = myGRP1 = myDGRP0 = myDGRP1 = 0; + myGRP0 = myGRP1 = myDGRP0 = myDGRP1 = myCurrentGRP0 = myCurrentGRP1 = 0; myENAM0 = myENAM1 = myENABL = myDENABL = false; myHMP0 = myHMP1 = myHMM0 = myHMM1 = myHMBL = 0; myVDELP0 = myVDELP1 = myVDELBL = myRESMP0 = myRESMP1 = false; + myCollision = 0; myCollisionEnabledMask = 0xFFFFFFFF; myPOSP0 = myPOSP1 = myPOSM0 = myPOSM1 = myPOSBL = 0; - // Some default values for the "current" variables - myCurrentGRP0 = 0; - myCurrentGRP1 = 0; - - myMotionClockP0 = 0; - myMotionClockP1 = 0; - myMotionClockM0 = 0; - myMotionClockM1 = 0; - myMotionClockBL = 0; + myMotionClockP0 = myMotionClockP1 = myMotionClockM0 = + myMotionClockM1 = myMotionClockBL = 0; + myStartP0 = myStartP1 = myStartM0 = myStartM1 = 0; mySuppressP0 = mySuppressP1 = 0; - myHMP0mmr = myHMP1mmr = myHMM0mmr = myHMM1mmr = myHMBLmmr = false; - myCurrentHMOVEPos = myPreviousHMOVEPos = 0x7FFFFFFF; - myHMOVEBlankEnabled = false; - - enableBits(true); - - myDumpEnabled = false; - myDumpDisabledCycle = 0; - myINPT4 = myINPT5 = 0x80; - - myFrameCounter = myPALFrameCounter = 0; - myScanlineCountForLastFrame = 0; - myNextFrameJitter = myCurrentFrameJitter = 0; - myP0Mask = &TIATables::PxMask[0][0][0]; myP1Mask = &TIATables::PxMask[0][0][0]; myM0Mask = &TIATables::MxMask[0][0][0]; @@ -156,9 +113,43 @@ void TIA::reset() myBLMask = &TIATables::BLMask[0][0]; myPFMask = TIATables::PFMask[0]; - // Recalculate the size of the display + myAUDV0 = myAUDV1 = myAUDF0 = myAUDF1 = myAUDC0 = myAUDC1 = 0; + + myDumpEnabled = false; + myDumpDisabledCycle = 0; + myINPT4 = myINPT5 = 0x80; + + myCurrentHMOVEPos = myPreviousHMOVEPos = 0x7FFFFFFF; + myHMOVEBlankEnabled = false; + myAllowHMOVEBlanks = true; + + myTIAPinsDriven = mySettings.getBool("tiadriven"); + + myEnabledObjects = 0; + myDisabledObjects = 0xFF; + + myColorLossEnabled = myPartialFrameFlag = myAutoFrameEnabled = false; + + myFrameCounter = myPALFrameCounter = 0; + myFramerate = 60.0; + + myBitsEnabled = myCollisionsEnabled = true; + myJitterEnabled = mySettings.getBool("tv.jitter"); + myNextFrameJitter = myCurrentFrameJitter = 0; + + // Make sure all TIA bits are enabled + enableBits(true); + + // Turn off debug colours (this also sets up the PriorityEncoder) toggleFixedColors(0); - frameReset(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIA::reset() +{ + initialize(); // Set initial state + mySound.reset(); // Reset the sound device + frameReset(); // Recalculate the size of the display } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/TIA.hxx b/src/emucore/TIA.hxx index d49b99c9f..c301de298 100644 --- a/src/emucore/TIA.hxx +++ b/src/emucore/TIA.hxx @@ -362,6 +362,9 @@ class TIA : public Device */ void enableCollisions(bool mode); + // Reset all instance variables to the initial state + void initialize(); + // Update the current frame buffer to the specified color clock void updateFrame(Int32 clock); diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index c6100c5f2..0889f6d63 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -58,7 +58,14 @@ using namespace Common; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thumbulator::Thumbulator(const uInt16* rom_ptr, uInt16* ram_ptr, bool traponfatal) : rom(rom_ptr), - ram(ram_ptr) + ram(ram_ptr), + halfadd(0), + cpsr(0), + mamcr(0), + instructions(0), + fetches(0), + reads(0), + writes(0) { trapFatalErrors(traponfatal); } diff --git a/src/gui/VideoDialog.cxx b/src/gui/VideoDialog.cxx index 36a2c4eb1..413b37ae5 100644 --- a/src/gui/VideoDialog.cxx +++ b/src/gui/VideoDialog.cxx @@ -617,7 +617,7 @@ void VideoDialog::handleCommand(CommandSender* sender, int cmd, case kTVModeChanged: handleTVModeChange(NTSCFilter::Preset(myTVMode->getSelectedTag().toInt())); - + break; case kTVSharpChanged: myTVSharpLabel->setValue(myTVSharp->getValue()); break; case kTVHueChanged: myTVHueLabel->setValue(myTVHue->getValue());