diff --git a/stella/src/debugger/gui/DataGridWidget.cxx b/stella/src/debugger/gui/DataGridWidget.cxx index 69847ea73..c711f387e 100644 --- a/stella/src/debugger/gui/DataGridWidget.cxx +++ b/stella/src/debugger/gui/DataGridWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DataGridWidget.cxx,v 1.10 2007-01-01 18:04:43 stephena Exp $ +// $Id: DataGridWidget.cxx,v 1.11 2007-07-31 15:46:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -170,8 +170,8 @@ void DataGridWidget::setSelectedValue(int value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::setRange(int lower, int upper) { - _lowerBound = MAX(0, lower); - _upperBound = MIN(1 << _bits, upper); + _lowerBound = BSPF_max(0, lower); + _upperBound = BSPF_min(1 << _bits, upper); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/debugger/gui/PromptWidget.cxx b/stella/src/debugger/gui/PromptWidget.cxx index 57c8fa492..1103f9d37 100644 --- a/stella/src/debugger/gui/PromptWidget.cxx +++ b/stella/src/debugger/gui/PromptWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PromptWidget.cxx,v 1.16 2007-06-21 12:27:00 stephena Exp $ +// $Id: PromptWidget.cxx,v 1.17 2007-07-31 15:46:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -731,7 +731,7 @@ void PromptWidget::nextLine() // Call this (at least) when the current line changes or when a new line is added void PromptWidget::updateScrollBuffer() { - int lastchar = MAX(_promptEndPos, _currentPos); + int lastchar = BSPF_max(_promptEndPos, _currentPos); int line = lastchar / _lineWidth; int numlines = (line < _linesInBuffer) ? line + 1 : _linesInBuffer; int firstline = line - numlines + 1; diff --git a/stella/src/emucore/DefProps.hxx b/stella/src/emucore/DefProps.hxx index b37aed662..703179c0c 100644 --- a/stella/src/emucore/DefProps.hxx +++ b/stella/src/emucore/DefProps.hxx @@ -7,7 +7,10 @@ should be made in stella.pro, and then this file should be regenerated and the application recompiled. */ -static const char* DefProps[2722][21] = { + +#define DEF_PROPS_SIZE 2722 + +static const char* DefProps[DEF_PROPS_SIZE][21] = { { "000509d1ed2b8d30a9d94be1b3b5febb", "", "", "Jungle Jane (2003) (Greg Zumwalt) (Pitfall! Hack)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "007d18dedc1f0565f09c42aa61a6f585", "CCE", "", "Worm War I (CCE)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "008543ae43497af015e9428a5e3e874e", "Retroactive", "", "Qb (V2.09) (PAL) (2001) (Retroactive)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" }, diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 16153382f..cf2a1ed31 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -14,7 +14,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.cxx,v 1.203 2007-06-20 16:33:22 stephena Exp $ +// $Id: EventHandler.cxx,v 1.204 2007-07-31 15:46:20 stephena Exp $ //============================================================================ #include @@ -860,7 +860,7 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event) // Grabmouse introduces some lag into the mouse movement, // so we need to fudge the numbers a bit - if(myGrabMouseFlag) x = MIN(w, (int) (x * 1.5)); + if(myGrabMouseFlag) x = BSPF_min(w, (int) (x * 1.5)); int resistance = (int)(1000000.0 * (w - x) / w); myEvent->set(Paddle_Resistance[myPaddleMode], resistance); diff --git a/stella/src/emucore/FSNode.cxx b/stella/src/emucore/FSNode.cxx index c3d6d2e27..a29851c5b 100644 --- a/stella/src/emucore/FSNode.cxx +++ b/stella/src/emucore/FSNode.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FSNode.cxx,v 1.9 2007-01-19 21:53:26 stephena Exp $ +// $Id: FSNode.cxx,v 1.10 2007-07-31 15:46:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -36,7 +36,7 @@ void FSList::sort() min = j; } if (min != i) - SWAP(_data[min], _data[i]); + BSPF_swap(_data[min], _data[i]); } } diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index ee5b7ce1f..b964b85d8 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.cxx,v 1.119 2007-07-11 15:08:10 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.120 2007-07-31 15:46:20 stephena Exp $ //============================================================================ #include @@ -671,7 +671,7 @@ void FrameBuffer::drawString(const GUI::Font* font, const string& s, uInt8 FrameBuffer::getPhosphor(uInt8 c1, uInt8 c2) { if(c2 > c1) - SWAP(c1, c2); + BSPF_swap(c1, c2); return ((c1 - c2) * myPhosphorBlend)/100 + c2; } @@ -779,8 +779,8 @@ VideoMode FrameBuffer::getSavedVidMode() { int lw, lh; myOSystem->settings().getSize("launcherres", lw, lh); - w = MAX(w, lw); - h = MAX(h, lh); + w = BSPF_max(w, lw); + h = BSPF_max(h, lh); } #ifdef DEBUGGER_SUPPORT else if(state == EventHandler::S_DEBUGGER) diff --git a/stella/src/emucore/PropsSet.cxx b/stella/src/emucore/PropsSet.cxx index 4c48effaa..7cdc2e758 100644 --- a/stella/src/emucore/PropsSet.cxx +++ b/stella/src/emucore/PropsSet.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PropsSet.cxx,v 1.33 2007-07-19 16:21:39 stephena Exp $ +// $Id: PropsSet.cxx,v 1.34 2007-07-31 15:46:20 stephena Exp $ //============================================================================ #include @@ -79,7 +79,7 @@ void PropertiesSet::getMD5(const string& md5, Properties& properties, // Otherwise, search the internal database using binary search if(!found) { - int low = 0, high = ARRAYSIZE(DefProps) - 1; + int low = 0, high = DEF_PROPS_SIZE - 1; while(low <= high) { int i = (low + high) / 2; diff --git a/stella/src/emucore/m6502/src/bspf/src/bspf.hxx b/stella/src/emucore/m6502/src/bspf/src/bspf.hxx index b3ac43c8d..124385f6f 100644 --- a/stella/src/emucore/m6502/src/bspf/src/bspf.hxx +++ b/stella/src/emucore/m6502/src/bspf/src/bspf.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: bspf.hxx,v 1.16 2007-07-19 16:21:39 stephena Exp $ +// $Id: bspf.hxx,v 1.17 2007-07-31 15:46:21 stephena Exp $ //============================================================================ #ifndef BSPF_HXX @@ -24,7 +24,7 @@ that need to be defined for different operating systems. @author Bradford W. Mott - @version $Id: bspf.hxx,v 1.16 2007-07-19 16:21:39 stephena Exp $ + @version $Id: bspf.hxx,v 1.17 2007-07-31 15:46:21 stephena Exp $ */ // Types for 8-bit signed and unsigned integers @@ -82,6 +82,12 @@ typedef unsigned int uInt32; #define BSPF_vsnprintf vsnprintf #endif +// Some convenience functions +template inline void BSPF_swap(T &a, T &b) { T tmp = a; a = b; b = tmp; } +template inline T BSPF_abs (T x) { return (x>=0) ? x : -x; } +template inline T BSPF_min (T a, T b) { return (a inline T BSPF_max (T a, T b) { return (a>b) ? a : b; } + #ifdef _WIN32_WCE #include "missing.h" #endif diff --git a/stella/src/gui/CheckListWidget.cxx b/stella/src/gui/CheckListWidget.cxx index ea4d2b2ac..1ceda79ae 100644 --- a/stella/src/gui/CheckListWidget.cxx +++ b/stella/src/gui/CheckListWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CheckListWidget.cxx,v 1.13 2007-01-01 18:04:52 stephena Exp $ +// $Id: CheckListWidget.cxx,v 1.14 2007-07-31 15:46:21 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -31,7 +31,7 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font, // rowheight is determined by largest item on a line, // possibly meaning that number of rows will change - _fontHeight = MAX(_fontHeight, CheckboxWidget::boxSize()); + _fontHeight = BSPF_max(_fontHeight, CheckboxWidget::boxSize()); _rows = h / _fontHeight; // Create a CheckboxWidget for each row in the list diff --git a/stella/src/gui/DialogContainer.cxx b/stella/src/gui/DialogContainer.cxx index 1123a897b..77a05dfbb 100644 --- a/stella/src/gui/DialogContainer.cxx +++ b/stella/src/gui/DialogContainer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DialogContainer.cxx,v 1.36 2007-01-01 18:04:52 stephena Exp $ +// $Id: DialogContainer.cxx,v 1.37 2007-07-31 15:46:21 stephena Exp $ //============================================================================ #include "OSystem.hxx" @@ -210,8 +210,8 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, int x, int y, uInt8 } if(myLastClick.count && (myTime < myLastClick.time + kDoubleClickDelay) - && ABS(myLastClick.x - x) < 3 - && ABS(myLastClick.y - y) < 3) + && BSPF_abs(myLastClick.x - x) < 3 + && BSPF_abs(myLastClick.y - y) < 3) { myLastClick.count++; } diff --git a/stella/src/gui/GuiUtils.hxx b/stella/src/gui/GuiUtils.hxx index 8206a80fa..6dc8138b3 100644 --- a/stella/src/gui/GuiUtils.hxx +++ b/stella/src/gui/GuiUtils.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: GuiUtils.hxx,v 1.26 2007-01-01 18:04:53 stephena Exp $ +// $Id: GuiUtils.hxx,v 1.27 2007-07-31 15:46:21 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,7 +29,7 @@ Probably not very neat, but at least it works ... @author Stephen Anthony - @version $Id: GuiUtils.hxx,v 1.26 2007-01-01 18:04:53 stephena Exp $ + @version $Id: GuiUtils.hxx,v 1.27 2007-07-31 15:46:21 stephena Exp $ */ #define kScrollBarWidth 9 @@ -50,17 +50,4 @@ enum { static const string EmptyString(""); -template inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; } -template inline T ABS (T x) { return (x>=0) ? x : -x; } - -#if !defined(MIN) -template inline T MIN (T a, T b) { return (a inline T MAX (T a, T b) { return (a>b) ? a : b; } -#endif - -#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0]))) - #endif diff --git a/stella/src/gui/Launcher.cxx b/stella/src/gui/Launcher.cxx index c1ed9dd8d..21bce5a0f 100644 --- a/stella/src/gui/Launcher.cxx +++ b/stella/src/gui/Launcher.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Launcher.cxx,v 1.16 2007-07-11 15:08:13 stephena Exp $ +// $Id: Launcher.cxx,v 1.17 2007-07-31 15:46:21 stephena Exp $ //============================================================================ #include @@ -34,14 +34,14 @@ Launcher::Launcher(OSystem* osystem) { int w, h; myOSystem->settings().getSize("launcherres", w, h); - myWidth = MAX(w, 0); - myHeight = MAX(h, 0); + myWidth = BSPF_max(w, 0); + myHeight = BSPF_max(h, 0); // Error check the resolution - myWidth = MAX(myWidth, 320u); - myWidth = MIN(myWidth, osystem->desktopWidth()); - myHeight = MAX(myHeight, 240u); - myHeight = MIN(myHeight, osystem->desktopHeight()); + myWidth = BSPF_max(myWidth, 320u); + myWidth = BSPF_min(myWidth, osystem->desktopWidth()); + myHeight = BSPF_max(myHeight, 240u); + myHeight = BSPF_min(myHeight, osystem->desktopHeight()); myOSystem->settings().setSize("launcherres", myWidth, myHeight); myBaseDialog = new LauncherDialog(myOSystem, this, 0, 0, myWidth, myHeight); diff --git a/stella/src/gui/Rect.hxx b/stella/src/gui/Rect.hxx index f1ba1a750..111c21006 100644 --- a/stella/src/gui/Rect.hxx +++ b/stella/src/gui/Rect.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Rect.hxx,v 1.4 2007-01-01 18:04:54 stephena Exp $ +// $Id: Rect.hxx,v 1.5 2007-07-31 15:46:21 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -22,7 +22,7 @@ #ifndef RECT_HXX #define RECT_HXX -#include "GuiUtils.hxx" +#include "bspf.hxx" namespace GUI { @@ -119,10 +119,10 @@ struct Rect @param r the rectangle to extend by */ void extend(const Rect & r) { - left = MIN(left, r.left); - right = MAX(right, r.right); - top = MIN(top, r.top); - bottom = MAX(bottom, r.bottom); + left = BSPF_min(left, r.left); + right = BSPF_max(right, r.right); + top = BSPF_min(top, r.top); + bottom = BSPF_max(bottom, r.bottom); } /*! @brief extend this rectangle in all four directions by the given number of pixels diff --git a/stella/src/gui/UIDialog.cxx b/stella/src/gui/UIDialog.cxx index 3b9d7101e..d67466dd1 100644 --- a/stella/src/gui/UIDialog.cxx +++ b/stella/src/gui/UIDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: UIDialog.cxx,v 1.4 2007-06-20 16:33:23 stephena Exp $ +// $Id: UIDialog.cxx,v 1.5 2007-07-31 15:46:21 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -158,8 +158,8 @@ void UIDialog::saveConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void UIDialog::setDefaults() { - int w = MIN(instance()->desktopWidth(), (const uInt32) 400); - int h = MIN(instance()->desktopHeight(), (const uInt32) 300); + int w = BSPF_min(instance()->desktopWidth(), (const uInt32) 400); + int h = BSPF_min(instance()->desktopHeight(), (const uInt32) 300); myLauncherWidthSlider->setValue(w); myLauncherWidthLabel->setValue(w); myLauncherHeightSlider->setValue(h); diff --git a/stella/src/gui/Widget.cxx b/stella/src/gui/Widget.cxx index 843067ad4..2c38a98f1 100644 --- a/stella/src/gui/Widget.cxx +++ b/stella/src/gui/Widget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Widget.cxx,v 1.49 2007-06-20 16:33:23 stephena Exp $ +// $Id: Widget.cxx,v 1.50 2007-07-31 15:46:21 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -88,7 +88,7 @@ void Widget::draw() int colorA = kColor; int colorB = kShadowColor; if((_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER) - SWAP(colorA, colorB); + BSPF_swap(colorA, colorB); fb.box(_x, _y, _w, _h, colorA, colorB); _x += 4; _y += 4; diff --git a/stella/src/tools/create_props.pl b/stella/src/tools/create_props.pl index 9413a5a5b..751e1cbb1 100755 --- a/stella/src/tools/create_props.pl +++ b/stella/src/tools/create_props.pl @@ -104,7 +104,9 @@ print OUTFILE " located in the src/tools directory. All properties changes\n"; print OUTFILE " should be made in stella.pro, and then this file should be\n"; print OUTFILE " regenerated and the application recompiled.\n"; print OUTFILE "*/\n"; -print OUTFILE "static const char* DefProps[" . $size . "][" . keys( %proptype ) . "] = {\n"; +print OUTFILE "\n#define DEF_PROPS_SIZE " . $size; +print OUTFILE "\n\n"; +print OUTFILE "static const char* DefProps[DEF_PROPS_SIZE][" . keys( %proptype ) . "] = {\n"; my $idx = 0; for my $key ( sort keys %propset )