From ddefb71baf28d4984c3a4c082db5c92ac97e4c0b Mon Sep 17 00:00:00 2001 From: Arthur Moore Date: Thu, 12 Mar 2015 06:00:01 -0400 Subject: [PATCH] Fixed compilation issues for vbam and gvbam Note: They will NOT run correctly if attempting to use filters in anything other than 32 bit mode --- src/filters/filters.hpp | 2 +- src/filters/sdl.cpp | 16 +------- src/gtk/filters.cpp | 46 ++++++++++----------- src/gtk/filters.h | 6 +-- src/gtk/screenarea.cpp | 18 +-------- src/gtk/screenarea.h | 1 - src/sdl/SDL.cpp | 10 ++--- src/sdl/filters.cpp | 88 +++++++++++++---------------------------- src/sdl/filters.h | 4 +- 9 files changed, 65 insertions(+), 126 deletions(-) diff --git a/src/filters/filters.hpp b/src/filters/filters.hpp index e60908ff..84e128ea 100644 --- a/src/filters/filters.hpp +++ b/src/filters/filters.hpp @@ -231,7 +231,7 @@ void hq4x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *pOut, //sdl.cpp //Don't even know if these work or not -extern bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth); +extern bool sdlStretchInit(int sizeMultiplier, int srcWidth); extern void sdlStretch1x(u8*,u32,u8*,u32,int,int); extern void sdlStretch2x(u8*,u32,u8*,u32,int,int); diff --git a/src/filters/sdl.cpp b/src/filters/sdl.cpp index 7ae7ede2..64bf98b6 100644 --- a/src/filters/sdl.cpp +++ b/src/filters/sdl.cpp @@ -404,24 +404,12 @@ void (*sdlStretcher24[4])(u8 *, u8 *, int) = { #endif // C_CORE -bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth) +bool sdlStretchInit(int sizeMultiplier, int srcWidth) { #ifndef C_CORE sdlMakeStretcher(srcWidth, sizeMultiplier); #else - switch(colorDepth) { - case 16: - sdlStretcher = sdlStretcher16[sizeMultiplier]; - break; - case 24: - sdlStretcher = sdlStretcher24[sizeMultiplier]; - break; - case 32: - sdlStretcher = sdlStretcher32[sizeMultiplier]; - break; - default: - return false; - } + sdlStretcher = sdlStretcher32[sizeMultiplier]; #endif return true; } diff --git a/src/gtk/filters.cpp b/src/gtk/filters.cpp index 6cbf96f9..fcd1c820 100644 --- a/src/gtk/filters.cpp +++ b/src/gtk/filters.cpp @@ -25,40 +25,40 @@ namespace VBA struct { char m_csName[30]; int m_iEnlargeFactor; - Filter m_apvFunc[2]; + Filter m_apvFunc; } static const astFilters[] = { - { N_("None"), 1, { 0, 0 } }, - { N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } }, - { N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } }, - { N_("Super Eagle"), 2, { SuperEagle, SuperEagle32 } }, - { N_("Pixelate"), 2, { Pixelate, Pixelate32 } }, - { N_("AdvanceMAME Scale2x"), 2, { AdMame2x, AdMame2x32 } }, - { N_("Bilinear"), 2, { Bilinear, Bilinear32 } }, - { N_("Bilinear Plus"), 2, { BilinearPlus, BilinearPlus32 } }, - { N_("Scanlines"), 2, { Scanlines, Scanlines32 } }, - { N_("TV Mode"), 2, { ScanlinesTV, ScanlinesTV32 } }, - { N_("lq2x"), 2, { lq2x, lq2x32 } }, - { N_("hq2x"), 2, { hq2x, hq2x32 } }, - { N_("hq3x"), 2, { hq3x16, hq3x32 } }, - { N_("hq4x"), 2, { hq4x16, hq4x32 } } + { N_("None"), 1, 0 }, + { N_("2xSaI"), 2, _2xSaI32 }, + { N_("Super 2xSaI"), 2, Super2xSaI32 }, + { N_("Super Eagle"), 2, SuperEagle32 }, + { N_("Pixelate"), 2, Pixelate32 }, + { N_("AdvanceMAME Scale2x"), 2, AdMame2x32 }, + { N_("Bilinear"), 2, Bilinear32 }, + { N_("Bilinear Plus"), 2, BilinearPlus32 }, + { N_("Scanlines"), 2, Scanlines32 }, + { N_("TV Mode"), 2, ScanlinesTV32 }, + { N_("lq2x"), 2, lq2x32 }, + { N_("hq2x"), 2, hq2x32 }, + { N_("hq3x"), 2, hq3x32 }, + { N_("hq4x"), 2, hq4x32 } }; struct { char m_csName[30]; - FilterIB m_apvFunc[2]; + FilterIB m_apvFunc; } static const astFiltersIB[] = { - { N_("None"), { 0, 0 } }, - { N_("Smart interframe blending"), { SmartIB, SmartIB32 } }, - { N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } } + { N_("None"), 0 }, + { N_("Smart interframe blending"), SmartIB32 }, + { N_("Interframe motion blur"), MotionBlurIB32 } }; -Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth) +Filter pvGetFilter(EFilter _eFilter) { - return astFilters[_eFilter].m_apvFunc[_eDepth]; + return astFilters[_eFilter].m_apvFunc; } const char* pcsGetFilterName(const EFilter _eFilter) @@ -66,9 +66,9 @@ const char* pcsGetFilterName(const EFilter _eFilter) return gettext(astFilters[_eFilter].m_csName); } -FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth) +FilterIB pvGetFilterIB(EFilterIB _eFilterIB) { - return astFiltersIB[_eFilterIB].m_apvFunc[_eDepth]; + return astFiltersIB[_eFilterIB].m_apvFunc; } const char* pcsGetFilterIBName(const EFilterIB _eFilterIB) diff --git a/src/gtk/filters.h b/src/gtk/filters.h index 32b3c421..4f8893ca 100644 --- a/src/gtk/filters.h +++ b/src/gtk/filters.h @@ -27,7 +27,7 @@ namespace VBA { -typedef void (*Filter)(u8 *, u32, u8 *, u8 *, u32, int, int); +typedef void (*Filter)(u8 *, u32, u8 *, u32, int, int); typedef void (*FilterIB)(u8 *, u32, int, int); enum EFilter @@ -65,10 +65,10 @@ enum EFilterDepth FilterDepth32 }; -Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth); +Filter pvGetFilter(EFilter _eFilter); const char* pcsGetFilterName(const EFilter _eFilter); -FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth); +FilterIB pvGetFilterIB(EFilterIB _eFilterIB); const char* pcsGetFilterIBName(const EFilterIB _eFilterIB); } // namespace VBA diff --git a/src/gtk/screenarea.cpp b/src/gtk/screenarea.cpp index cb0e181c..60099aad 100644 --- a/src/gtk/screenarea.cpp +++ b/src/gtk/screenarea.cpp @@ -28,7 +28,6 @@ ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) : m_vFilter2x(NULL), m_vFilterIB(NULL), m_puiPixels(NULL), - m_puiDelta(NULL), m_iScaledWidth(_iWidth), m_iScaledHeight(_iHeight), m_bEnableRender(true), @@ -64,11 +63,6 @@ ScreenArea::~ScreenArea() delete[] m_puiPixels; } - if (m_puiDelta) - { - delete[] m_puiDelta; - } - if (m_poEmptyCursor != NULL) { delete m_poEmptyCursor; @@ -102,7 +96,7 @@ void ScreenArea::vSetScale(int _iScale) void ScreenArea::vSetFilter(EFilter _eFilter) { - m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32); + m_vFilter2x = pvGetFilter(_eFilter); m_iFilterScale = 1; if (m_vFilter2x != NULL) @@ -115,7 +109,7 @@ void ScreenArea::vSetFilter(EFilter _eFilter) void ScreenArea::vSetFilterIB(EFilterIB _eFilterIB) { - m_vFilterIB = pvGetFilterIB(_eFilterIB, FilterDepth32); + m_vFilterIB = pvGetFilterIB(_eFilterIB); } void ScreenArea::vStartCursorTimeout() @@ -192,7 +186,6 @@ void ScreenArea::vDrawPixels(u8 * _puiData) { m_vFilter2x(_puiData + iSrcPitch, iSrcPitch, - m_puiDelta, (u8 *)m_puiPixels, iScaledPitch, m_iWidth, @@ -211,18 +204,11 @@ void ScreenArea::vUpdateSize() delete[] m_puiPixels; } - if (m_puiDelta) - { - delete[] m_puiDelta; - } - m_iScaledWidth = m_iFilterScale * m_iWidth; m_iScaledHeight = m_iFilterScale * m_iHeight; m_puiPixels = new u32[(m_iScaledWidth + 1) * m_iScaledHeight]; - m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32)]; memset(m_puiPixels, 0, (m_iScaledWidth + 1) * m_iScaledHeight * sizeof(u32)); - memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32)); vOnSizeUpdated(); diff --git a/src/gtk/screenarea.h b/src/gtk/screenarea.h index 65b60190..8b191a79 100644 --- a/src/gtk/screenarea.h +++ b/src/gtk/screenarea.h @@ -59,7 +59,6 @@ protected: Filter m_vFilter2x; FilterIB m_vFilterIB; u32 * m_puiPixels; - u8 * m_puiDelta; int m_iScaledWidth; int m_iScaledHeight; bool m_bEnableRender; diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index 68cafd0e..9f811947 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -1547,7 +1547,7 @@ void sdlPollEvents() while (!filterFunction) { filter = (Filter)((filter + 1) % kInvalidFilter); - filterFunction = initFilter(filter, systemColorDepth, srcWidth); + filterFunction = initFilter(filter, srcWidth); } if (getFilterEnlargeFactor(filter) != filter_enlarge) sdlInitVideo(); @@ -2292,7 +2292,7 @@ int main(int argc, char **argv) sdlInitVideo(); - filterFunction = initFilter(filter, systemColorDepth, srcWidth); + filterFunction = initFilter(filter, srcWidth); if (!filterFunction) { fprintf(stderr,"Unable to init filter '%s'\n", getFilterName(filter)); exit(-1); @@ -2316,7 +2316,7 @@ int main(int argc, char **argv) memset(delta, 255, delta_size); } - ifbFunction = initIFBFilter(ifbType, systemColorDepth); + ifbFunction = initIFBFilter(ifbType); emulating = 1; renderedFrames = 0; @@ -2477,7 +2477,7 @@ void systemDrawScreen() if (ifbFunction) ifbFunction(pix + srcPitch, srcPitch, srcWidth, srcHeight); - filterFunction(pix + srcPitch, srcPitch, delta, screen, + filterFunction(pix + srcPitch, srcPitch, screen, destPitch, srcWidth, srcHeight); drawScreenMessage(screen, destPitch, 10, destHeight - 20, 3000); @@ -2698,7 +2698,7 @@ void systemGbBorderOn() sdlInitVideo(); - filterFunction = initFilter(filter, systemColorDepth, srcWidth); + filterFunction = initFilter(filter, srcWidth); } bool systemReadJoypads() diff --git a/src/sdl/filters.cpp b/src/sdl/filters.cpp index 9261ab1d..9b99230a 100644 --- a/src/sdl/filters.cpp +++ b/src/sdl/filters.cpp @@ -25,29 +25,27 @@ struct FilterDesc { char name[30]; int enlargeFactor; - FilterFunc func16; - FilterFunc func24; FilterFunc func32; }; const FilterDesc Filters[] = { - { "Stretch 1x", 1, sdlStretch1x, sdlStretch1x, sdlStretch1x }, - { "Stretch 2x", 2, sdlStretch2x, sdlStretch2x, sdlStretch2x }, - { "2xSaI", 2, _2xSaI, 0, _2xSaI32 }, - { "Super 2xSaI", 2, Super2xSaI, 0, Super2xSaI32 }, - { "Super Eagle", 2, SuperEagle, 0, SuperEagle32 }, - { "Pixelate", 2, Pixelate, 0, Pixelate32 }, - { "AdvanceMAME Scale2x", 2, AdMame2x, 0, AdMame2x32 }, - { "Bilinear", 2, Bilinear, 0, Bilinear32 }, - { "Bilinear Plus", 2, BilinearPlus, 0, BilinearPlus32 }, - { "Scanlines", 2, Scanlines, 0, Scanlines32 }, - { "TV Mode", 2, ScanlinesTV, 0, ScanlinesTV32 }, - { "lq2x", 2, lq2x, 0, lq2x32 }, - { "hq2x", 2, hq2x, 0, hq2x32 }, - { "Stretch 3x", 3, sdlStretch3x, sdlStretch3x, sdlStretch3x }, - { "hq3x", 3, hq3x16, 0, hq3x32_32 }, - { "Stretch 4x", 4, sdlStretch4x, sdlStretch4x, sdlStretch4x }, - { "hq4x", 4, hq4x16, 0, hq4x32_32 } + { "Stretch 1x", 1, sdlStretch1x }, + { "Stretch 2x", 2, sdlStretch2x }, + { "2xSaI", 2, _2xSaI32 }, + { "Super 2xSaI", 2, Super2xSaI32 }, + { "Super Eagle", 2, SuperEagle32 }, + { "Pixelate", 2, Pixelate32 }, + { "AdvanceMAME Scale2x", 2, AdMame2x32 }, + { "Bilinear", 2, Bilinear32 }, + { "Bilinear Plus", 2, BilinearPlus32 }, + { "Scanlines", 2, Scanlines32 }, + { "TV Mode", 2, ScanlinesTV32 }, + { "lq2x", 2, lq2x32 }, + { "hq2x", 2, hq2x32 }, + { "Stretch 3x", 3, sdlStretch3x }, + { "hq3x", 3, hq3x32 }, + { "Stretch 4x", 4, sdlStretch4x }, + { "hq4x", 4, hq4x32 } }; int getFilterEnlargeFactor(const Filter f) @@ -60,50 +58,32 @@ char* getFilterName(const Filter f) return (char*)Filters[f].name; } -FilterFunc initFilter(const Filter f, const int colorDepth, const int srcWidth) +FilterFunc initFilter(const Filter f, const int srcWidth) { - FilterFunc func; - - switch (colorDepth) { - case 15: - case 16: - func = Filters[f].func16; - break; - case 24: - func = Filters[f].func24; - break; - case 32: - func = Filters[f].func32; - break; - default: - func = 0; - break; - } + FilterFunc func = Filters[f].func32; if (func) switch (f) { case kStretch1x: - sdlStretchInit(colorDepth, 0, srcWidth); + sdlStretchInit(0, srcWidth); break; case kStretch2x: - sdlStretchInit(colorDepth, 1, srcWidth); + sdlStretchInit(1, srcWidth); break; case kStretch3x: - sdlStretchInit(colorDepth, 2, srcWidth); + sdlStretchInit(2, srcWidth); break; case kStretch4x: - sdlStretchInit(colorDepth, 3, srcWidth); + sdlStretchInit(3, srcWidth); break; case k2xSaI: case kSuper2xSaI: case kSuperEagle: - if (colorDepth == 15) Init_2xSaI(555); - else if (colorDepth == 16) Init_2xSaI(565); - else Init_2xSaI(colorDepth); + Init_2xSaI(32); break; case khq2x: case klq2x: - hq2x_init(colorDepth); + hq2x_init(32); break; default: break; @@ -124,23 +104,9 @@ const IFBFilterDesc IFBFilters[] = { { "Smart interframe blending", SmartIB, SmartIB32 } }; -IFBFilterFunc initIFBFilter(const IFBFilter f, const int colorDepth) +IFBFilterFunc initIFBFilter(const IFBFilter f) { - IFBFilterFunc func; - - switch (colorDepth) { - case 15: - case 16: - func = IFBFilters[f].func16; - break; - case 32: - func = IFBFilters[f].func32; - break; - case 24: - default: - func = 0; - break; - } + IFBFilterFunc func = IFBFilters[f].func32; return func; } diff --git a/src/sdl/filters.h b/src/sdl/filters.h index 29743471..e1867934 100644 --- a/src/sdl/filters.h +++ b/src/sdl/filters.h @@ -33,7 +33,7 @@ enum Filter { kStretch1x, kStretch2x, k2xSaI, kSuper2xSaI, kSuperEagle, kPixelat klq2x, khq2x, kStretch3x, khq3x, kStretch4x, khq4x, kInvalidFilter }; // Initialize a filter and get the corresponding filter function pointer -FilterFunc initFilter(const Filter f, const int colorDepth, const int srcWidth); +FilterFunc initFilter(const Filter f, const int srcWidth); // Get the enlarge factor of a filter int getFilterEnlargeFactor(const Filter f); @@ -52,7 +52,7 @@ enum IFBFilter { kIFBNone, kIBMotionBlur, kIBSmart, kInvalidIFBFilter }; typedef void(*IFBFilterFunc)(u8*, u32, int, int); // Initialize an IFB filter and get the corresponding filter function pointer -IFBFilterFunc initIFBFilter(const IFBFilter f, const int colorDepth); +IFBFilterFunc initIFBFilter(const IFBFilter f); // Get the display name for an IFB filter char* getIFBFilterName(const IFBFilter f);