Skip to content

Commit

Permalink
Merge pull request #1206 from comex/amperspocalypse
Browse files Browse the repository at this point in the history
Change a bunch of reference function arguments to pointers.
  • Loading branch information
skidau committed Oct 5, 2014
2 parents 47bf698 + 7f6284c commit 871d308
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 330 deletions.
18 changes: 9 additions & 9 deletions Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp
Expand Up @@ -168,15 +168,15 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar

// Mouse Buttons
for (int i = 0; i < 5; i++)
AddInput(new Button(i, m_state.buttons));
AddInput(new Button(i, &m_state.buttons));

// Mouse Cursor, X-/+ and Y-/+
for (int i = 0; i != 4; ++i)
AddInput(new Cursor(!!(i & 2), !!(i & 1), (&m_state.cursor.x)[!!(i & 2)]));
AddInput(new Cursor(!!(i & 2), !!(i & 1), (i & 2) ? &m_state.cursor.y : &m_state.cursor.x));

// Mouse Axis, X-/+ and Y-/+
for (int i = 0; i != 4; ++i)
AddInput(new Axis(!!(i & 2), !!(i & 1), (&m_state.axis.x)[!!(i & 2)]));
AddInput(new Axis(!!(i & 2), !!(i & 1), (i & 2) ? &m_state.axis.y : &m_state.axis.x));
}

KeyboardMouse::~KeyboardMouse()
Expand Down Expand Up @@ -338,7 +338,7 @@ ControlState KeyboardMouse::Key::GetState() const
return (m_keyboard[m_keycode / 8] & (1 << (m_keycode % 8))) != 0;
}

KeyboardMouse::Button::Button(unsigned int index, unsigned int& buttons)
KeyboardMouse::Button::Button(unsigned int index, unsigned int* buttons)
: m_buttons(buttons), m_index(index)
{
// this will be a problem if we remove the hardcoded five-button limit
Expand All @@ -347,29 +347,29 @@ KeyboardMouse::Button::Button(unsigned int index, unsigned int& buttons)

ControlState KeyboardMouse::Button::GetState() const
{
return ((m_buttons & (1 << m_index)) != 0);
return ((*m_buttons & (1 << m_index)) != 0);
}

KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float& cursor)
KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float* cursor)
: m_cursor(cursor), m_index(index), m_positive(positive)
{
name = std::string("Cursor ") + (char)('X' + m_index) + (m_positive ? '+' : '-');
}

ControlState KeyboardMouse::Cursor::GetState() const
{
return std::max(0.0f, m_cursor / (m_positive ? 1.0f : -1.0f));
return std::max(0.0f, *m_cursor / (m_positive ? 1.0f : -1.0f));
}

KeyboardMouse::Axis::Axis(u8 index, bool positive, const float& axis)
KeyboardMouse::Axis::Axis(u8 index, bool positive, const float* axis)
: m_axis(axis), m_index(index), m_positive(positive)
{
name = std::string("Axis ") + (char)('X' + m_index) + (m_positive ? '+' : '-');
}

ControlState KeyboardMouse::Axis::GetState() const
{
return std::max(0.0f, m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY));
return std::max(0.0f, *m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY));
}

}
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h
Expand Up @@ -54,11 +54,11 @@ class KeyboardMouse : public Core::Device
{
public:
std::string GetName() const override { return name; }
Button(unsigned int index, unsigned int& buttons);
Button(unsigned int index, unsigned int* buttons);
ControlState GetState() const override;

private:
const unsigned int& m_buttons;
const unsigned int* m_buttons;
const unsigned int m_index;
std::string name;
};
Expand All @@ -68,11 +68,11 @@ class KeyboardMouse : public Core::Device
public:
std::string GetName() const override { return name; }
bool IsDetectable() override { return false; }
Cursor(u8 index, bool positive, const float& cursor);
Cursor(u8 index, bool positive, const float* cursor);
ControlState GetState() const override;

private:
const float& m_cursor;
const float* m_cursor;
const u8 m_index;
const bool m_positive;
std::string name;
Expand All @@ -83,11 +83,11 @@ class KeyboardMouse : public Core::Device
public:
std::string GetName() const override { return name; }
bool IsDetectable() override { return false; }
Axis(u8 index, bool positive, const float& axis);
Axis(u8 index, bool positive, const float* axis);
ControlState GetState() const override;

private:
const float& m_axis;
const float* m_axis;
const u8 m_index;
const bool m_positive;
std::string name;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D/Render.cpp
Expand Up @@ -721,7 +721,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
}

u32 xfbCount = 0;
const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, &xfbCount);
if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
{
if (g_ActiveConfig.bDumpFrames && !frame_data.empty())
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/Render.cpp
Expand Up @@ -1385,7 +1385,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
}

u32 xfbCount = 0;
const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbStride, fbHeight, xfbCount);
const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbStride, fbHeight, &xfbCount);
if (g_ActiveConfig.VirtualXFBEnabled() && (!xfbSourceList || xfbCount == 0))
{
DumpFrame(frame_data, w, h);
Expand Down
23 changes: 11 additions & 12 deletions Source/Core/VideoBackends/Software/Clipper.cpp
Expand Up @@ -113,10 +113,9 @@ namespace Clipper
return cmask;
}

static inline void AddInterpolatedVertex(float t, int out, int in, int& numVertices)
static inline void AddInterpolatedVertex(float t, int out, int in, int* numVertices)
{
Vertices[numVertices]->Lerp(t, Vertices[out], Vertices[in]);
numVertices++;
Vertices[(*numVertices)++]->Lerp(t, Vertices[out], Vertices[in]);
}

#define DIFFERENT_SIGNS(x,y) ((x <= 0 && y > 0) || (x > 0 && y <= 0))
Expand All @@ -142,10 +141,10 @@ namespace Clipper
if (DIFFERENT_SIGNS(dp, dpPrev)) { \
if (dp < 0) { \
float t = dp / (dp - dpPrev); \
AddInterpolatedVertex(t, idx, idxPrev, numVertices); \
AddInterpolatedVertex(t, idx, idxPrev, &numVertices); \
} else { \
float t = dpPrev / (dpPrev - dp); \
AddInterpolatedVertex(t, idxPrev, idx, numVertices); \
AddInterpolatedVertex(t, idxPrev, idx, &numVertices); \
} \
outlist[outcount++] = numVertices - 1; \
} \
Expand Down Expand Up @@ -187,7 +186,7 @@ namespace Clipper
} \
}

static void ClipTriangle(int *indices, int &numIndices)
static void ClipTriangle(int *indices, int* numIndices)
{
int mask = 0;

Expand Down Expand Up @@ -229,9 +228,9 @@ namespace Clipper
indices[2] = inlist[2];
for (int j = 3; j < n; ++j)
{
indices[numIndices++] = inlist[0];
indices[numIndices++] = inlist[j - 1];
indices[numIndices++] = inlist[j];
indices[(*numIndices)++] = inlist[0];
indices[(*numIndices)++] = inlist[j - 1];
indices[(*numIndices)++] = inlist[j];
}
}
}
Expand Down Expand Up @@ -276,13 +275,13 @@ namespace Clipper
if (clip_mask[0])
{
indices[0] = numVertices;
AddInterpolatedVertex(t0, 0, 1, numVertices);
AddInterpolatedVertex(t0, 0, 1, &numVertices);
}

if (clip_mask[1])
{
indices[1] = numVertices;
AddInterpolatedVertex(t1, 1, 0, numVertices);
AddInterpolatedVertex(t1, 1, 0, &numVertices);
}
}

Expand Down Expand Up @@ -315,7 +314,7 @@ namespace Clipper
Vertices[2] = v2;
}

ClipTriangle(indices, numIndices);
ClipTriangle(indices, &numIndices);

for (int i = 0; i+3 <= numIndices; i+=3)
{
Expand Down
34 changes: 17 additions & 17 deletions Source/Core/VideoBackends/Software/EfbInterface.cpp
Expand Up @@ -334,57 +334,57 @@ namespace EfbInterface
}
}

static void LogicBlend(u32 srcClr, u32 &dstClr, BlendMode::LogicOp op)
static void LogicBlend(u32 srcClr, u32* dstClr, BlendMode::LogicOp op)
{
switch (op)
{
case BlendMode::CLEAR:
dstClr = 0;
*dstClr = 0;
break;
case BlendMode::AND:
dstClr = srcClr & dstClr;
*dstClr = srcClr & *dstClr;
break;
case BlendMode::AND_REVERSE:
dstClr = srcClr & (~dstClr);
*dstClr = srcClr & (~*dstClr);
break;
case BlendMode::COPY:
dstClr = srcClr;
*dstClr = srcClr;
break;
case BlendMode::AND_INVERTED:
dstClr = (~srcClr) & dstClr;
*dstClr = (~srcClr) & *dstClr;
break;
case BlendMode::NOOP:
// Do nothing
break;
case BlendMode::XOR:
dstClr = srcClr ^ dstClr;
*dstClr = srcClr ^ *dstClr;
break;
case BlendMode::OR:
dstClr = srcClr | dstClr;
*dstClr = srcClr | *dstClr;
break;
case BlendMode::NOR:
dstClr = ~(srcClr | dstClr);
*dstClr = ~(srcClr | *dstClr);
break;
case BlendMode::EQUIV:
dstClr = ~(srcClr ^ dstClr);
*dstClr = ~(srcClr ^ *dstClr);
break;
case BlendMode::INVERT:
dstClr = ~dstClr;
*dstClr = ~*dstClr;
break;
case BlendMode::OR_REVERSE:
dstClr = srcClr | (~dstClr);
*dstClr = srcClr | (~*dstClr);
break;
case BlendMode::COPY_INVERTED:
dstClr = ~srcClr;
*dstClr = ~srcClr;
break;
case BlendMode::OR_INVERTED:
dstClr = (~srcClr) | dstClr;
*dstClr = (~srcClr) | *dstClr;
break;
case BlendMode::NAND:
dstClr = ~(srcClr & dstClr);
*dstClr = ~(srcClr & *dstClr);
break;
case BlendMode::SET:
dstClr = 0xffffffff;
*dstClr = 0xffffffff;
break;
}
}
Expand Down Expand Up @@ -416,7 +416,7 @@ namespace EfbInterface
}
else if (bpmem.blendmode.logicopenable)
{
LogicBlend(*((u32*)color), dstClr, bpmem.blendmode.logicmode);
LogicBlend(*((u32*)color), &dstClr, bpmem.blendmode.logicmode);
}
else
{
Expand Down
11 changes: 6 additions & 5 deletions Source/Core/VideoBackends/Software/Rasterizer.cpp
Expand Up @@ -210,7 +210,7 @@ static void InitSlope(Slope *slope, float f1, float f2, float f3, float DX31, fl
slope->f0 = f1;
}

static inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord)
static inline void CalculateLOD(s32* lodp, bool* linear, u32 texmap, u32 texcoord)
{
FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1];
u8 subTexmap = texmap & 3;
Expand Down Expand Up @@ -240,20 +240,21 @@ static inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord
}

// get LOD in s28.4
lod = FixedLog2(std::max(sDelta, tDelta));
s32 lod = FixedLog2(std::max(sDelta, tDelta));

// bias is s2.5
int bias = tm0.lod_bias;
bias >>= 1;
lod += bias;

linear = ((lod > 0 && (tm0.min_filter & 4)) || (lod <= 0 && tm0.mag_filter));
*linear = ((lod > 0 && (tm0.min_filter & 4)) || (lod <= 0 && tm0.mag_filter));

// order of checks matters
// should be:
// if lod > max then max
// else if lod < min then min
lod = CLAMP(lod, (s32)tm1.min_lod, (s32)tm1.max_lod);
*lodp = lod;
}

static void BuildBlock(s32 blockX, s32 blockY)
Expand Down Expand Up @@ -295,7 +296,7 @@ static void BuildBlock(s32 blockX, s32 blockY)
u32 texcoord = indref & 3;
indref >>= 3;

CalculateLOD(rasterBlock.IndirectLod[i], rasterBlock.IndirectLinear[i], texmap, texcoord);
CalculateLOD(&rasterBlock.IndirectLod[i], &rasterBlock.IndirectLinear[i], texmap, texcoord);
}

for (unsigned int i = 0; i <= bpmem.genMode.numtevstages; i++)
Expand All @@ -307,7 +308,7 @@ static void BuildBlock(s32 blockX, s32 blockY)
u32 texmap = order.getTexMap(stageOdd);
u32 texcoord = order.getTexCoord(stageOdd);

CalculateLOD(rasterBlock.TextureLod[i], rasterBlock.TextureLinear[i], texmap, texcoord);
CalculateLOD(&rasterBlock.TextureLod[i], &rasterBlock.TextureLinear[i], texmap, texcoord);
}
}
}
Expand Down

0 comments on commit 871d308

Please sign in to comment.