aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRSDuck <RSDuck@users.noreply.github.com>2021-08-21 01:54:09 +0200
committerRSDuck <RSDuck@users.noreply.github.com>2021-08-21 01:54:45 +0200
commit883fceb6ce99b9c8abcd698ea73663c8c3ded0e0 (patch)
tree7e39b51450a4196e0bed04a4c6c0fd314ff64d9d
parentc23e1583128188130ea63fbbbe415f38d130f364 (diff)
use std::swap 🔃
-rw-r--r--src/ARM.cpp64
-rw-r--r--src/GPU3D_Soft.cpp19
2 files changed, 40 insertions, 43 deletions
diff --git a/src/ARM.cpp b/src/ARM.cpp
index 15dd3ee..fc9c266 100644
--- a/src/ARM.cpp
+++ b/src/ARM.cpp
@@ -17,6 +17,7 @@
*/
#include <stdio.h>
+#include <algorithm>
#include "NDS.h"
#include "DSi.h"
#include "ARM.h"
@@ -392,74 +393,71 @@ void ARM::RestoreCPSR()
void ARM::UpdateMode(u32 oldmode, u32 newmode)
{
- u32 temp;
- #define SWAP(a, b) temp = a; a = b; b = temp;
-
if ((oldmode & 0x1F) == (newmode & 0x1F)) return;
switch (oldmode & 0x1F)
{
case 0x11:
- SWAP(R[8], R_FIQ[0]);
- SWAP(R[9], R_FIQ[1]);
- SWAP(R[10], R_FIQ[2]);
- SWAP(R[11], R_FIQ[3]);
- SWAP(R[12], R_FIQ[4]);
- SWAP(R[13], R_FIQ[5]);
- SWAP(R[14], R_FIQ[6]);
+ std::swap(R[8], R_FIQ[0]);
+ std::swap(R[9], R_FIQ[1]);
+ std::swap(R[10], R_FIQ[2]);
+ std::swap(R[11], R_FIQ[3]);
+ std::swap(R[12], R_FIQ[4]);
+ std::swap(R[13], R_FIQ[5]);
+ std::swap(R[14], R_FIQ[6]);
break;
case 0x12:
- SWAP(R[13], R_IRQ[0]);
- SWAP(R[14], R_IRQ[1]);
+ std::swap(R[13], R_IRQ[0]);
+ std::swap(R[14], R_IRQ[1]);
break;
case 0x13:
- SWAP(R[13], R_SVC[0]);
- SWAP(R[14], R_SVC[1]);
+ std::swap(R[13], R_SVC[0]);
+ std::swap(R[14], R_SVC[1]);
break;
case 0x17:
- SWAP(R[13], R_ABT[0]);
- SWAP(R[14], R_ABT[1]);
+ std::swap(R[13], R_ABT[0]);
+ std::swap(R[14], R_ABT[1]);
break;
case 0x1B:
- SWAP(R[13], R_UND[0]);
- SWAP(R[14], R_UND[1]);
+ std::swap(R[13], R_UND[0]);
+ std::swap(R[14], R_UND[1]);
break;
}
switch (newmode & 0x1F)
{
case 0x11:
- SWAP(R[8], R_FIQ[0]);
- SWAP(R[9], R_FIQ[1]);
- SWAP(R[10], R_FIQ[2]);
- SWAP(R[11], R_FIQ[3]);
- SWAP(R[12], R_FIQ[4]);
- SWAP(R[13], R_FIQ[5]);
- SWAP(R[14], R_FIQ[6]);
+ std::swap(R[8], R_FIQ[0]);
+ std::swap(R[9], R_FIQ[1]);
+ std::swap(R[10], R_FIQ[2]);
+ std::swap(R[11], R_FIQ[3]);
+ std::swap(R[12], R_FIQ[4]);
+ std::swap(R[13], R_FIQ[5]);
+ std::swap(R[14], R_FIQ[6]);
break;
case 0x12:
- SWAP(R[13], R_IRQ[0]);
- SWAP(R[14], R_IRQ[1]);
+ std::swap(R[13], R_IRQ[0]);
+ std::swap(R[14], R_IRQ[1]);
break;
case 0x13:
- SWAP(R[13], R_SVC[0]);
- SWAP(R[14], R_SVC[1]);
+ std::swap(R[13], R_SVC[0]);
+ std::swap(R[14], R_SVC[1]);
break;
case 0x17:
- SWAP(R[13], R_ABT[0]);
- SWAP(R[14], R_ABT[1]);
+ std::swap(R[13], R_ABT[0]);
+ std::swap(R[14], R_ABT[1]);
break;
case 0x1B:
- SWAP(R[13], R_UND[0]);
- SWAP(R[14], R_UND[1]);
+ std::swap(R[13], R_UND[0]);
+ std::swap(R[14], R_UND[1]);
break;
}
diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp
index 282bde1..2f0f825 100644
--- a/src/GPU3D_Soft.cpp
+++ b/src/GPU3D_Soft.cpp
@@ -18,6 +18,7 @@
#include "GPU3D_Soft.h"
+#include <algorithm>
#include <stdio.h>
#include <string.h>
#include "NDS.h"
@@ -756,11 +757,10 @@ void SoftRenderer::RenderShadowMaskScanline(RendererPolygon* rp, s32 y)
rp->SlopeR.EdgeParams_YMajor(&l_edgelen, &l_edgecov);
rp->SlopeL.EdgeParams_YMajor(&r_edgelen, &r_edgecov);
- s32 tmp;
- tmp = xstart; xstart = xend; xend = tmp;
- tmp = wl; wl = wr; wr = tmp;
- tmp = zl; zl = zr; zr = tmp;
- tmp = (s32)l_filledge; l_filledge = r_filledge; r_filledge = (bool)tmp;
+ std::swap(xstart, xend);
+ std::swap(wl, wr);
+ std::swap(zl, zr);
+ std::swap(l_filledge, r_filledge);
}
else
{
@@ -977,11 +977,10 @@ void SoftRenderer::RenderPolygonScanline(RendererPolygon* rp, s32 y)
rp->SlopeR.EdgeParams_YMajor(&l_edgelen, &l_edgecov);
rp->SlopeL.EdgeParams_YMajor(&r_edgelen, &r_edgecov);
- s32 tmp;
- tmp = xstart; xstart = xend; xend = tmp;
- tmp = wl; wl = wr; wr = tmp;
- tmp = zl; zl = zr; zr = tmp;
- tmp = (s32)l_filledge; l_filledge = r_filledge; r_filledge = (bool)tmp;
+ std::swap(xstart, xend);
+ std::swap(wl, wr);
+ std::swap(zl, zr);
+ std::swap(l_filledge, r_filledge);
}
else
{