Removed a bunch of casts, they seem to be fine without them in most cases.
--- a/src/in_2sf/desmume/MMU.cpp
+++ b/src/in_2sf/desmume/MMU.cpp
@@ -41,7 +41,7 @@
* is even, and the one bit is as far left as is consistant
* with that condition.)
*/
- uint64_t squaredbit = static_cast<uint64_t>((static_cast<uint64_t>(~0LL) >> 1) & ~(static_cast<uint64_t>(~0LL) >> 2));
+ uint64_t squaredbit = (~0LL >> 1) & ~(~0LL >> 2);
/* This portable load replaces the loop that used to be
* here, and was donated by legalize@xmission.com
*/
@@ -860,12 +860,12 @@
if (mode)
{
uint64_t v = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8);
- ret = static_cast<uint32_t>(isqrt(v));
+ ret = isqrt(v) & 0xFFFFFFFF;
}
else
{
uint32_t v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8);
- ret = static_cast<uint32_t>(isqrt(v));
+ ret = isqrt(v) & 0xFFFFFFFF;
}
// clear the result while the sqrt unit is busy
@@ -889,20 +889,20 @@
switch (mode)
{
case 0: // 32/32
- num = static_cast<int64_t>(static_cast<int32_t>(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290)));
- den = static_cast<int64_t>(static_cast<int32_t>(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298)));
+ num = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290);
+ den = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298);
MMU.divCycles = nds_timer + 36;
break;
case 1: // 64/32
- case 3: //gbatek says this is same as mode 1
- num = static_cast<int64_t>(T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290));
- den = static_cast<int64_t>(static_cast<int32_t>(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298)));
+ case 3: // gbatek says this is same as mode 1
+ num = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290);
+ den = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298);
MMU.divCycles = nds_timer + 68;
break;
case 2: // 64/64
default:
- num = static_cast<int64_t>(T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290));
- den = static_cast<int64_t>(T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298));
+ num = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290);
+ den = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298);
MMU.divCycles = nds_timer + 68;
}
@@ -912,7 +912,7 @@
mod = num;
// the DIV0 flag in DIVCNT is set only if the full 64bit DIV_DENOM value is zero, even in 32bit mode
- if (!static_cast<uint64_t>(T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298)))
+ if (!T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298))
MMU_new.div.div0 = 1;
}
else
@@ -958,7 +958,7 @@
return this->read16();
case 1:
if (!this->read_flag)
- this->registers[this->reg_selection] = static_cast<uint8_t>(val);
+ this->registers[this->reg_selection] = val & 0xFF;
ret = this->read16();
++this->reg_selection;
this->reg_selection &= 0x7F;
@@ -1128,7 +1128,7 @@
// ZERO 01-dec-2010 : I am no longer sure this approach is correct.. it proved to be wrong for IPC fifo.......
// it seems as if IF bits should always be cached (only the user can clear them)
- MMU.reg_IF_bits[PROCNUM] &= ~(static_cast<uint32_t>(val) << (addr << 3));
+ MMU.reg_IF_bits[PROCNUM] &= ~(val << (addr << 3));
NDS_Reschedule();
}
@@ -1182,7 +1182,7 @@
return MMU.timer[proc][timerIndex];
// for unchained timers, we do not keep the timer up to date. its value will need to be calculated here
- int32_t diff = static_cast<int32_t>(nds.timerCycle[proc][timerIndex] - nds_timer);
+ int32_t diff = (nds.timerCycle[proc][timerIndex] - nds_timer) & 0xFFFFFFFF;
assert(diff >= 0);
if (diff < 0)
printf("NEW EMULOOP BAD NEWS PLEASE REPORT: TIME READ DIFF < 0 (%d) (%d) (%d)\n", diff, timerIndex, MMU.timerMODE[proc][timerIndex]);
@@ -1201,7 +1201,7 @@
else
ret = 65535 - units;
- return static_cast<uint16_t>(ret);
+ return ret & 0xFFFF;
}
static inline void write_timer(int proc, int timerIndex, uint16_t val)
@@ -1311,13 +1311,13 @@
uint32_t valhi = val >> 16;
this->dar = static_cast<EDMADestinationUpdate>((valhi >> 5) & 3);
this->sar = static_cast<EDMASourceUpdate>((valhi >> 7) & 3);
- this->repeatMode = static_cast<uint8_t>(BIT9(valhi));
+ this->repeatMode = BIT9(valhi);
this->bitWidth = static_cast<EDMABitWidth>(BIT10(valhi));
this->_startmode = (valhi >> 11) & 7;
if (this->procnum == ARMCPU_ARM7)
this->_startmode &= 6;
- this->irq = static_cast<uint8_t>(BIT14(valhi));
- this->enable = static_cast<uint8_t>(BIT15(valhi));
+ this->irq = BIT14(valhi);
+ this->enable = BIT15(valhi);
// make sure we don't get any old triggers
if (!wasEnable && this->enable)
@@ -1434,7 +1434,7 @@
dstinc = sz;
break;
case EDMADestinationUpdate_Decrement:
- dstinc = static_cast<uint32_t>(-static_cast<int32_t>(sz));
+ dstinc = -static_cast<int32_t>(sz);
break;
case EDMADestinationUpdate_Fixed:
dstinc = 0;
@@ -1451,7 +1451,7 @@
srcinc = sz;
break;
case EDMASourceUpdate_Decrement:
- srcinc = static_cast<uint32_t>(-static_cast<int32_t>(sz));
+ srcinc = -static_cast<int32_t>(sz);
break;
case EDMASourceUpdate_Fixed:
srcinc = 0;
@@ -1479,7 +1479,7 @@
// we might make another function to do just the raw copy op which can use them with checks
// outside the loop
int time_elapsed = 0;
- for (int32_t i = static_cast<int32_t>(todo); i > 0; --i)
+ for (int32_t i = todo; i > 0; --i)
{
if (sz == 4)
{
@@ -1672,7 +1672,7 @@
case REG_WRAMCNT:
case REG_VRAMCNTH:
case REG_VRAMCNTI:
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA), val);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA, val);
}
MMU.MMU_MEM[ARMCPU_ARM9][adr >> 20][adr & MMU.MMU_MASK[ARMCPU_ARM9][adr >> 20]] = val;
@@ -1761,8 +1761,8 @@
case REG_VRAMCNTE:
case REG_VRAMCNTG:
case REG_VRAMCNTH:
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA), val & 0xFF);
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 1), val >> 8);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA, val & 0xFF);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 1, val >> 8);
break;
case REG_IME:
@@ -1776,7 +1776,7 @@
return;
case REG_IE + 2:
NDS_Reschedule();
- MMU.reg_IE[ARMCPU_ARM9] = (MMU.reg_IE[ARMCPU_ARM9] & 0xFFFF) | (static_cast<uint32_t>(val) << 16);
+ MMU.reg_IE[ARMCPU_ARM9] = (MMU.reg_IE[ARMCPU_ARM9] & 0xFFFF) | (val << 16);
return;
case REG_IF:
REG_IF_WriteWord<ARMCPU_ARM9>(0, val);
@@ -1811,7 +1811,7 @@
MMU_writeToGCControl<ARMCPU_ARM9>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4) & 0xFFFF0000) | val);
return;
case REG_GCROMCTRL + 2:
- MMU_writeToGCControl<ARMCPU_ARM9>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4) & 0xFFFF) | (static_cast<uint32_t>(val) << 16));
+ MMU_writeToGCControl<ARMCPU_ARM9>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4) & 0xFFFF) | (val << 16));
return;
}
@@ -1862,22 +1862,22 @@
switch (adr)
{
case REG_SQRTCNT:
- MMU_new.sqrt.write16(static_cast<uint16_t>(val));
+ MMU_new.sqrt.write16(val & 0xFFFF);
return;
case REG_DIVCNT:
- MMU_new.div.write16(static_cast<uint16_t>(val));
+ MMU_new.div.write16(val & 0xFFFF);
return;
case REG_VRAMCNTA:
case REG_VRAMCNTE:
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA), val & 0xFF);
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 1), (val >> 8) & 0xFF);
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 2), (val >> 16) & 0xFF);
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 3), (val >> 24) & 0xFF);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA, val & 0xFF);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 1, (val >> 8) & 0xFF);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 2, (val >> 16) & 0xFF);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 3, (val >> 24) & 0xFF);
break;
case REG_VRAMCNTH:
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA), val & 0xFF);
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 1), (val >> 8) & 0xFF);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA, val & 0xFF);
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 1, (val >> 8) & 0xFF);
break;
case REG_IME:
@@ -1901,8 +1901,8 @@
case REG_TM3CNTL:
{
int timerIndex = (adr >> 2) & 0x3;
- MMU.timerReload[ARMCPU_ARM9][timerIndex] = static_cast<uint16_t>(val);
- T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & 0xFFF, static_cast<uint16_t>(val));
+ MMU.timerReload[ARMCPU_ARM9][timerIndex] = val & 0xFFFF;
+ T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & 0xFFF, val & 0xFFFF);
write_timer(ARMCPU_ARM9, timerIndex, val >> 16);
return;
}
@@ -1946,7 +1946,7 @@
MMU_IPCSync(ARMCPU_ARM9, val);
return;
case REG_IPCFIFOCNT:
- IPC_FIFOcnt(ARMCPU_ARM9, static_cast<uint16_t>(val));
+ IPC_FIFOcnt(ARMCPU_ARM9, val & 0xFFFF);
return;
case REG_IPCFIFOSEND:
IPC_FIFOsend(ARMCPU_ARM9, val);
@@ -2001,18 +2001,18 @@
//Address is an IO register
if (MMU_new.is_dma(adr))
- return static_cast<uint8_t>(MMU_new.read_dma(ARMCPU_ARM9, 8, adr));
+ return MMU_new.read_dma(ARMCPU_ARM9, 8, adr) & 0xFF;
switch (adr)
{
case REG_IF:
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM9>());
+ return MMU.gen_IF<ARMCPU_ARM9>() & 0xFF;
case REG_IF + 1:
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM9>() >> 8);
+ return (MMU.gen_IF<ARMCPU_ARM9>() >> 8) & 0xFF;
case REG_IF + 2:
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM9>() >> 16);
+ return (MMU.gen_IF<ARMCPU_ARM9>() >> 16) & 0xFF;
case REG_IF + 3:
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM9>() >> 24);
+ return (MMU.gen_IF<ARMCPU_ARM9>() >> 24) & 0xFF;
case REG_WRAMCNT:
return MMU.WRAMCNT;
@@ -2068,7 +2068,7 @@
if ((adr >> 24) == 4)
{
if (MMU_new.is_dma(adr))
- return static_cast<uint16_t>(MMU_new.read_dma(ARMCPU_ARM9, 16, adr));
+ return MMU_new.read_dma(ARMCPU_ARM9, 16, adr) & 0xFFFF;
// Address is an IO register
switch (adr)
@@ -2088,21 +2088,21 @@
return 0;
case REG_IME:
- return static_cast<uint16_t>(MMU.reg_IME[ARMCPU_ARM9]);
+ return MMU.reg_IME[ARMCPU_ARM9] & 0xFFFF;
// WRAMCNT is readable but VRAMCNT is not, so just return WRAM's value
case REG_VRAMCNTG:
return MMU.WRAMCNT << 8;
case REG_IE:
- return static_cast<uint16_t>(MMU.reg_IE[ARMCPU_ARM9]);
+ return MMU.reg_IE[ARMCPU_ARM9] & 0xFFFF;
case REG_IE + 2:
- return static_cast<uint16_t>(MMU.reg_IE[ARMCPU_ARM9] >> 16);
+ return (MMU.reg_IE[ARMCPU_ARM9] >> 16) & 0xFFFF;
case REG_IF:
- return static_cast<uint16_t>(MMU.gen_IF<ARMCPU_ARM9>());
+ return MMU.gen_IF<ARMCPU_ARM9>() & 0xFFFF;
case REG_IF + 2:
- return static_cast<uint16_t>(MMU.gen_IF<ARMCPU_ARM9>() >> 16);
+ return (MMU.gen_IF<ARMCPU_ARM9>() >> 16) & 0xFFFF;
case REG_TM0CNTL:
case REG_TM1CNTL:
@@ -2372,7 +2372,7 @@
else
{
// write
- MMU.powerMan_Reg[reg] = static_cast<uint8_t>(val);
+ MMU.powerMan_Reg[reg] = val & 0xFF;
static const uint32_t PM_SYSTEM_PWR = BIT(6); /*!< \brief Turn the power *off* if set */
@@ -2395,7 +2395,7 @@
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, 0);
break;
}
- T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, static_cast<uint8_t>(val)));
+ T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, val & 0xFF));
return;
case 2:
@@ -2526,7 +2526,7 @@
return;
case REG_IE + 2:
NDS_Reschedule();
- MMU.reg_IE[ARMCPU_ARM7] = (MMU.reg_IE[ARMCPU_ARM7] & 0xFFFF) | (static_cast<uint32_t>(val) << 16);
+ MMU.reg_IE[ARMCPU_ARM7] = (MMU.reg_IE[ARMCPU_ARM7] & 0xFFFF) | (val << 16);
return;
case REG_IF:
@@ -2563,7 +2563,7 @@
MMU_writeToGCControl<ARMCPU_ARM7>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4) & 0xFFFF0000) | val);
return;
case REG_GCROMCTRL + 2:
- MMU_writeToGCControl<ARMCPU_ARM7>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4) & 0xFFFF) | (static_cast<uint32_t>(val) << 16));
+ MMU_writeToGCControl<ARMCPU_ARM7>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4) & 0xFFFF) | (val << 16));
return;
}
@@ -2628,8 +2628,8 @@
case REG_TM3CNTL:
{
int timerIndex = (adr >> 2) & 0x3;
- MMU.timerReload[ARMCPU_ARM7][timerIndex] = static_cast<uint16_t>(val);
- T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & 0xFFF, static_cast<uint16_t>(val));
+ MMU.timerReload[ARMCPU_ARM7][timerIndex] = val & 0xFFFF;
+ T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & 0xFFF, val & 0xFFFF);
write_timer(ARMCPU_ARM7, timerIndex, val >> 16);
return;
}
@@ -2638,7 +2638,7 @@
MMU_IPCSync(ARMCPU_ARM7, val);
return;
case REG_IPCFIFOCNT:
- IPC_FIFOcnt(ARMCPU_ARM7, static_cast<uint16_t>(val));
+ IPC_FIFOcnt(ARMCPU_ARM7, val & 0xFFFF);
return;
case REG_IPCFIFOSEND:
IPC_FIFOsend(ARMCPU_ARM7, val);
@@ -2690,20 +2690,20 @@
if ((adr >> 24) == 4)
{
if (MMU_new.is_dma(adr))
- return static_cast<uint8_t>(MMU_new.read_dma(ARMCPU_ARM7, 8, adr));
+ return MMU_new.read_dma(ARMCPU_ARM7, 8, adr) & 0xFF;
// Address is an IO register
switch (adr)
{
case REG_IF:
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM7>());
+ return MMU.gen_IF<ARMCPU_ARM7>() & 0xFF;
case REG_IF + 1:
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM7>() >> 8);
+ return (MMU.gen_IF<ARMCPU_ARM7>() >> 8) & 0xFF;
case REG_IF + 2:
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM7>() >> 16);
+ return (MMU.gen_IF<ARMCPU_ARM7>() >> 16) & 0xFF;
case REG_IF + 3:
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM7>() >> 24);
+ return (MMU.gen_IF<ARMCPU_ARM7>() >> 24) & 0xFF;
case REG_WRAMSTAT:
return MMU.WRAMCNT;
@@ -2737,22 +2737,22 @@
// Address is an IO register
if (MMU_new.is_dma(adr))
- return static_cast<uint16_t>(MMU_new.read_dma(ARMCPU_ARM7, 16, adr));
+ return MMU_new.read_dma(ARMCPU_ARM7, 16, adr) & 0xFFFF;
switch (adr)
{
case REG_IME:
- return static_cast<uint16_t>(MMU.reg_IME[ARMCPU_ARM7]);
+ return MMU.reg_IME[ARMCPU_ARM7] & 0xFFFF;
case REG_IE:
- return static_cast<uint16_t>(MMU.reg_IE[ARMCPU_ARM7]);
+ return MMU.reg_IE[ARMCPU_ARM7] & 0xFFFF;
case REG_IE + 2:
- return static_cast<uint16_t>(MMU.reg_IE[ARMCPU_ARM7] >> 16);
+ return (MMU.reg_IE[ARMCPU_ARM7] >> 16) & 0xFFFF;
case REG_IF:
- return static_cast<uint16_t>(MMU.gen_IF<ARMCPU_ARM7>());
+ return MMU.gen_IF<ARMCPU_ARM7>() & 0xFFFF;
case REG_IF + 2:
- return static_cast<uint16_t>(MMU.gen_IF<ARMCPU_ARM7>() >> 16);
+ return (MMU.gen_IF<ARMCPU_ARM7>() >> 16) & 0xFFFF;
case REG_TM0CNTL:
case REG_TM1CNTL:
--- a/src/in_2sf/desmume/MMU_timing.h
+++ b/src/in_2sf/desmume/MMU_timing.h
@@ -130,8 +130,8 @@
enum { ASSOCIATIVITY = 1 << ASSOCIATIVESHIFT };
enum { BLOCKSIZE = 1 << BLOCKSIZESHIFT };
enum { TAGSHIFT = SIZESHIFT - ASSOCIATIVESHIFT };
- enum { TAGMASK = static_cast<uint32_t>(~0 << TAGSHIFT) };
- enum { BLOCKMASK = (static_cast<uint32_t>(~0) >> (32 - TAGSHIFT)) & static_cast<uint32_t>(~0 << BLOCKSIZESHIFT) };
+ enum { TAGMASK = ~0 << TAGSHIFT };
+ enum { BLOCKMASK = (~0 >> (32 - TAGSHIFT)) & (~0 << BLOCKSIZESHIFT) };
enum { WORDSIZE = sizeof(uint32_t) };
enum { WORDSPERBLOCK = (1 << BLOCKSIZESHIFT) / WORDSIZE };
enum { DATAPERWORD = WORDSIZE * ASSOCIATIVITY };
--- a/src/in_2sf/desmume/NDSSystem.cpp
+++ b/src/in_2sf/desmume/NDSSystem.cpp
@@ -127,7 +127,7 @@
memcpy(header->logo, MMU.CART_ROM + 192, 156);
header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348);
header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350);
- memcpy(header->reserved, MMU.CART_ROM + 352, std::min(160, static_cast<int>(gameInfo.romsize) - 352));
+ memcpy(header->reserved, MMU.CART_ROM + 352, std::min<size_t>(160, gameInfo.romsize - 352));
return header;
}
@@ -298,10 +298,10 @@
T1WriteQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, MMU.divResult);
T1WriteQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, MMU.divMod);
#else
- T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, static_cast<uint32_t>(MMU.divResult));
- T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A4, static_cast<uint32_t>(MMU.divResult >> 32));
- T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, static_cast<uint32_t>(MMU.divMod));
- T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2AC, static_cast<uint32_t>(MMU.divMod >> 32));
+ T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, MMU.divResult & 0xFFFFFFFF);
+ T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A4, (MMU.divResult >> 32) & 0xFFFFFFFF);
+ T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, MMU.divMod & 0xFFFFFFFF);
+ T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2AC, (MMU.divMod >> 32) & 0xFFFFFFFF);
#endif
MMU.divRunning = false;
}
@@ -556,10 +556,10 @@
}
// write the new vcount
- T1WriteWord(MMU.ARM9_REG, 6, static_cast<uint16_t>(nds.VCount));
- T1WriteWord(MMU.ARM9_REG, 0x1006, static_cast<uint16_t>(nds.VCount));
- T1WriteWord(MMU.ARM7_REG, 6, static_cast<uint16_t>(nds.VCount));
- T1WriteWord(MMU.ARM7_REG, 0x1006, static_cast<uint16_t>(nds.VCount));
+ T1WriteWord(MMU.ARM9_REG, 6, nds.VCount & 0xFFFF);
+ T1WriteWord(MMU.ARM9_REG, 0x1006, nds.VCount & 0xFFFF);
+ T1WriteWord(MMU.ARM7_REG, 6, nds.VCount & 0xFFFF);
+ T1WriteWord(MMU.ARM7_REG, 0x1006, nds.VCount & 0xFFFF);
// turn off hblank status bit
T1WriteWord(MMU.ARM9_REG, 4, T1ReadWord(MMU.ARM9_REG, 4) & 0xFFFD);
@@ -802,9 +802,9 @@
// cast these down to 32bits so that things run faster on 32bit procs
uint64_t nds_timer_base = nds_timer;
- int32_t arm9 = static_cast<int32_t>(nds_arm9_timer - nds_timer);
- int32_t arm7 = static_cast<int32_t>(nds_arm7_timer - nds_timer);
- int32_t s32next = static_cast<int32_t>(next - nds_timer);
+ int32_t arm9 = (nds_arm9_timer - nds_timer) & 0xFFFFFFFF;
+ int32_t arm7 = (nds_arm7_timer - nds_timer) & 0xFFFFFFFF;
+ int32_t s32next = (next - nds_timer) & 0xFFFFFFFF;
#ifdef HAVE_JIT
auto arm9arm7 = CommonSettings.use_jit ? armInnerLoop<true, true, true>(nds_timer_base, s32next, arm9, arm7) : armInnerLoop<true, true, false>(nds_timer_base, s32next, arm9, arm7);
--- a/src/in_2sf/desmume/NDSSystem.h
+++ b/src/in_2sf/desmume/NDSSystem.h
@@ -212,7 +212,7 @@
{
this->resize(size);
memcpy(&this->romdata[0], buf, size);
- this->romsize = static_cast<uint32_t>(size);
+ this->romsize = size;
this->fillGap();
}
--- a/src/in_2sf/desmume/PACKED.h
+++ b/src/in_2sf/desmume/PACKED.h
@@ -1,6 +1,6 @@
#ifndef __GNUC__
-#pragma pack(push, 1)
-#pragma warning(disable : 4103)
+# pragma pack(push, 1)
+# pragma warning(disable : 4103)
#endif
#ifndef __PACKED
--- a/src/in_2sf/desmume/SPU.cpp
+++ b/src/in_2sf/desmume/SPU.cpp
@@ -36,9 +36,9 @@
#include "NDSSystem.h"
#include "matrix.h"
-static inline int16_t read16(uint32_t addr) { return static_cast<int16_t>(_MMU_read16<ARMCPU_ARM7,MMU_AT_DEBUG>(addr)); }
+static inline int16_t read16(uint32_t addr) { return _MMU_read16<ARMCPU_ARM7,MMU_AT_DEBUG>(addr); }
static inline uint8_t read08(uint32_t addr) { return _MMU_read08<ARMCPU_ARM7,MMU_AT_DEBUG>(addr); }
-static inline int8_t read_s8(uint32_t addr) { return static_cast<int8_t>(_MMU_read08<ARMCPU_ARM7,MMU_AT_DEBUG>(addr)); }
+static inline int8_t read_s8(uint32_t addr) { return _MMU_read08<ARMCPU_ARM7,MMU_AT_DEBUG>(addr); }
static const int K_ADPCM_LOOPING_RECOVERY_INDEX = 99999;
static const int COSINE_INTERPOLATION_RESOLUTION = 8192;
@@ -172,7 +172,7 @@
for (i = 0; i < COSINE_INTERPOLATION_RESOLUTION; ++i)
cos_lut[i] = (1.0 - std::cos((static_cast<double>(i) / COSINE_INTERPOLATION_RESOLUTION) * M_PI)) * 0.5;
- SPU_core.reset(new SPU_struct(static_cast<int>(std::ceil(samples_per_hline))));
+ SPU_core.reset(new SPU_struct(std::ceil(samples_per_hline)));
SPU_Reset();
int j;
@@ -350,7 +350,7 @@
thischan.x = 0x7FFF;
}
- thischan.double_totlength_shifted = static_cast<double>(thischan.totlength << format_shift[thischan.format]);
+ thischan.double_totlength_shifted = thischan.totlength << format_shift[thischan.format];
if (thischan.format != 3 && fEqual(thischan.double_totlength_shifted, 0.0))
{
--- a/src/in_2sf/desmume/arm_jit.cpp
+++ b/src/in_2sf/desmume/arm_jit.cpp
@@ -484,7 +484,7 @@
if (!imm) \
imm = 31; \
c.sar(rhs, imm); \
- uint32_t rhs_first = static_cast<int32_t>(cpu->R[REG_POS(i, 0)]) >> imm;
+ uint32_t rhs_first = cpu->R[REG_POS(i, 0)] >> imm;
#define S_ASR_IMM \
JIT_COMMENT("S_ASR_IMM"); \
@@ -512,7 +512,7 @@
} \
else \
c.ror(rhs, imm); \
- uint32_t rhs_first = imm ? ROR(cpu->R[REG_POS(i, 0)], imm) : (static_cast<uint32_t>(cpu->CPSR.bits.C) << 31) | (cpu->R[REG_POS(i, 0)] >> 1);
+ uint32_t rhs_first = imm ? ROR(cpu->R[REG_POS(i, 0)], imm) : (cpu->CPSR.bits.C << 31) | (cpu->R[REG_POS(i, 0)] >> 1);
#define S_ROR_IMM \
JIT_COMMENT("S_ROR_IMM"); \
@@ -2136,7 +2136,7 @@
#ifdef ENABLE_ADVANCED_TIMING
cycles = 0;
#endif
- uintptr_t *func = reinterpret_cast<uintptr_t *>(&JIT_COMPILED_FUNC(adr, PROCNUM));
+ uintptr_t *func = &JIT_COMPILED_FUNC(adr, PROCNUM);
#define OP(j) \
{ \
@@ -2247,7 +2247,7 @@
// same prototype, but we have to handle splitting of a u64 arg manually
GpVar regs_lo = c.newGpVar(kX86VarTypeGpd);
GpVar regs_hi = c.newGpVar(kX86VarTypeGpd);
- c.mov(regs_lo, static_cast<uint32_t>(get_reg_list(bitmask, dir)));
+ c.mov(regs_lo, get_reg_list(bitmask, dir) & 0xFFFFFFFF);
c.mov(regs_hi, get_reg_list(bitmask, dir) >> 32);
X86CompilerFuncCall *ctx = c.call(reinterpret_cast<void *>(op_ldm_stm_tab[PROCNUM][store][dir > 0]));
ctx->setPrototype(ASMJIT_CALL_CONV, FuncBuilder4<uint32_t, uint32_t, uint32_t, uint32_t, int>());
@@ -3685,7 +3685,7 @@
{
Label skip = c.newLabel();
- uint32_t dst = bb_r15 + (static_cast<uint32_t>(static_cast<int8_t>(i & 0xFF)) << 1);
+ uint32_t dst = bb_r15 + ((i & 0xFF) << 1);
c.mov(cpu_ptr(instruct_adr), bb_next_instruction);
@@ -4149,7 +4149,7 @@
#endif
c.endFunc();
- ArmOpCompiled f = reinterpret_cast<ArmOpCompiled>(c.make());
+ ArmOpCompiled f = static_cast<ArmOpCompiled>(c.make());
if(c.getError())
{
fprintf(stderr, "JIT error: %s\n", getErrorString(c.getError()));
@@ -4247,13 +4247,13 @@
#if PROFILER_JIT_LEVEL > 0
static int pcmp(PROFILER_COUNTER_INFO *info1, PROFILER_COUNTER_INFO *info2)
{
- return static_cast<int>(info2->count - info1->count);
+ return info2->count - info1->count;
}
#if PROFILER_JIT_LEVEL > 1
static int pcmp_entry(PROFILER_ENTRY *info1, PROFILER_ENTRY *info2)
{
- return static_cast<int>(info1->cycles - info2->cycles);
+ return info1->cycles - info2->cycles;
}
#endif
#endif
--- a/src/in_2sf/desmume/bios.cpp
+++ b/src/in_2sf/desmume/bios.cpp
@@ -281,16 +281,16 @@
TEMPLATE static uint32_t divide()
{
- int32_t num = static_cast<int32_t>(cpu->R[0]);
- int32_t dnum = static_cast<int32_t>(cpu->R[1]);
+ int32_t num = cpu->R[0];
+ int32_t dnum = cpu->R[1];
if (!dnum)
return 0;
int32_t res = num / dnum;
- cpu->R[0] = static_cast<uint32_t>(res);
- cpu->R[1] = static_cast<uint32_t>(num % dnum);
- cpu->R[3] = static_cast<uint32_t>(std::abs(res));
+ cpu->R[0] = res;
+ cpu->R[1] = num % dnum;
+ cpu->R[3] = std::abs(res);
return 6;
}
@@ -324,7 +324,7 @@
cnt &= 0x1FFFFF;
while (cnt)
{
- _MMU_write16<PROCNUM>(dst, static_cast<uint16_t>(val));
+ _MMU_write16<PROCNUM>(dst, val);
--cnt;
dst += 2;
}
@@ -439,7 +439,7 @@
if (byteCount == 2)
{
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue));
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF);
dest += 2;
byteCount = 0;
byteShift = 0;
@@ -457,7 +457,7 @@
++byteCount;
if (byteCount == 2)
{
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue));
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF);
dest += 2;
byteCount = 0;
byteShift = 0;
@@ -479,7 +479,7 @@
++byteCount;
if (byteCount == 2)
{
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue));
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF);
dest += 2;
byteShift = 0;
byteCount = 0;
@@ -587,7 +587,7 @@
if (byteCount == 2)
{
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue));
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF);
dest += 2;
byteCount = 0;
byteShift = 0;
@@ -609,7 +609,7 @@
if (byteCount == 2)
{
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue));
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF);
dest += 2;
byteCount = 0;
byteShift = 0;
@@ -738,7 +738,7 @@
{
byteCount = 0;
byteShift = 0;
- _MMU_write08<PROCNUM>(dest, static_cast<uint8_t>(writeValue));
+ _MMU_write08<PROCNUM>(dest, writeValue & 0xFF);
writeValue = 0;
dest += 4;
len -= 4;
@@ -801,7 +801,7 @@
{
byteCount = 0;
byteShift = 0;
- _MMU_write08<PROCNUM>(dest, static_cast<uint8_t>(writeValue));
+ _MMU_write08<PROCNUM>(dest, writeValue & 0xFF);
dest += 4;
writeValue = 0;
len -= 4;
@@ -959,7 +959,7 @@
TEMPLATE static uint32_t setHaltCR()
{
- _MMU_write08<PROCNUM>(0x4000300+cpu->proc_ID, static_cast<uint8_t>(cpu->R[0]));
+ _MMU_write08<PROCNUM>(0x4000300+cpu->proc_ID, cpu->R[0] & 0xFF);
return 1;
}
@@ -1010,7 +1010,7 @@
// if this implementation is wrong, then it won't match what the real bios returns,
// and savefiles created with a bios will be invalid when loaded with non-bios (and vice-versa)
- uint16_t crc = static_cast<uint16_t>(cpu->R[0]);
+ uint16_t crc = cpu->R[0] & 0xFFFF;
uint32_t datap = cpu->R[1];
uint32_t size = cpu->R[2] >> 1;
uint16_t currVal = 0;
--- a/src/in_2sf/desmume/cp15.cpp
+++ b/src/in_2sf/desmume/cp15.cpp
@@ -384,7 +384,7 @@
{
// On the NDS bit0,2,7,12..19 are R/W, Bit3..6 are always set, all other bits are always zero.
this->ctrl = (val & 0x000FF085) | 0x00000078;
- MMU.ARM9_RW_MODE = static_cast<uint8_t>(BIT7(val));
+ MMU.ARM9_RW_MODE = BIT7(val);
// zero 31-jan-2010: change from 0x0FFF0000 to 0xFFFF0000 per gbatek
this->cpu->intVector = 0xFFFF0000 * BIT13(val);
this->cpu->LDTBit = !BIT15(val); // TBit
--- a/src/in_2sf/desmume/emufile.h
+++ b/src/in_2sf/desmume/emufile.h
@@ -90,7 +90,7 @@
this->vec->resize(amt);
}
public:
- EMUFILE_MEMORY(std::vector<uint8_t> *underlying) : vec(underlying), ownvec(false), pos(0), len(static_cast<int32_t>(underlying->size())) { }
+ EMUFILE_MEMORY(std::vector<uint8_t> *underlying) : vec(underlying), ownvec(false), pos(0), len(underlying->size()) { }
EMUFILE_MEMORY(uint32_t preallocate) : vec(new std::vector<uint8_t>()), ownvec(true), pos(0), len(0)
{
this->vec->resize(preallocate);
@@ -196,7 +196,7 @@
virtual size_t ftell()
{
- return static_cast<size_t>(::ftell(this->fp));
+ return ::ftell(this->fp);
}
virtual size_t size()
--- a/src/in_2sf/desmume/instructions.h
+++ b/src/in_2sf/desmume/instructions.h
@@ -18,7 +18,7 @@
#ifndef _INSTRUCIONS_H_
#define _INSTRUCIONS_H_
-typedef uint32_t (FASTCALL *OpFunc)(const uint32_t i);
+typedef uint32_t (FASTCALL *OpFunc)(uint32_t i);
extern const OpFunc arm_instructions_set[2][4096];
extern const char* arm_instruction_names[4096];
extern const OpFunc thumb_instructions_set[2][1024];
--- a/src/in_2sf/desmume/mc.cpp
+++ b/src/in_2sf/desmume/mc.cpp
@@ -284,7 +284,7 @@
this->state = RUNNING;
int savetype = save_types[CommonSettings.manualBackupType].media_type;
int savesize = save_types[CommonSettings.manualBackupType].size;
- this->ensure(static_cast<uint32_t>(savesize)); // expand properly if necessary
+ this->ensure(savesize); // expand properly if necessary
this->resize(savesize); // truncate if necessary
this->addr_size = this->addr_size_for_old_save_type(savetype);
}
@@ -356,12 +356,12 @@
// =======================================================================
// =======================================================================
-static int no_gba_unpackSAV(void *in_buf, uint32_t fsize, void *out_buf, uint32_t &size)
+static int no_gba_unpackSAV(const uint8_t *in_buf, uint32_t fsize, uint8_t *out_buf, uint32_t &size)
{
const char no_GBA_HEADER_ID[] = "NocashGbaBackupMediaSavDataFile";
const char no_GBA_HEADER_SRAM_ID[] = "SRAM";
- uint8_t *src = static_cast<uint8_t *>(in_buf);
- uint8_t *dst = static_cast<uint8_t *>(out_buf);
+ const uint8_t *src = in_buf;
+ uint8_t *dst = out_buf;
uint32_t src_pos = 0;
uint32_t dst_pos = 0;
uint32_t size_unpacked = 0;
@@ -379,11 +379,11 @@
if (src[i + 0x40] != no_GBA_HEADER_SRAM_ID[i])
return 2;
- compressMethod = *(reinterpret_cast<uint32_t *>(src + 0x44));
+ compressMethod = *(reinterpret_cast<const uint32_t *>(src + 0x44));
if (!compressMethod) // unpacked
{
- size_unpacked = *(reinterpret_cast<uint32_t *>(src + 0x48));
+ size_unpacked = *(reinterpret_cast<const uint32_t *>(src + 0x48));
src_pos = 0x4C;
for (uint32_t i = 0; i < size_unpacked; ++i)
dst[dst_pos++] = src[src_pos++];
@@ -393,7 +393,7 @@
if (compressMethod == 1) // packed (method 1)
{
- size_unpacked = *(reinterpret_cast<uint32_t *>(src + 0x4C));
+ size_unpacked = *(reinterpret_cast<const uint32_t *>(src + 0x4C));
src_pos = 0x50;
while (true)
@@ -408,7 +408,7 @@
if (cc == 0x80)
{
- uint16_t tsize = *(reinterpret_cast<uint16_t *>(src + src_pos + 1));
+ uint16_t tsize = *(reinterpret_cast<const uint16_t *>(src + src_pos + 1));
for (int t = 0; t < tsize; ++t)
dst[dst_pos++] = src[src_pos];
src_pos += 3;
@@ -433,11 +433,11 @@
return 200;
}
-static uint32_t no_gba_savTrim(void *buf, uint32_t size)
+static uint32_t no_gba_savTrim(uint8_t *buf, uint32_t size)
{
uint32_t rows = size / 16;
uint32_t pos = (size - 16);
- uint8_t *src = static_cast<uint8_t *>(buf);
+ uint8_t *src = buf;
for (unsigned i = 0; i < rows; ++i, pos -= 16)
{
@@ -539,7 +539,7 @@
else
{
// scan for desmume save footer
- int32_t cookieLen = static_cast<int32_t>(strlen(kDesmumeSaveCookie));
+ int32_t cookieLen = strlen(kDesmumeSaveCookie);
auto sigbuf = std::unique_ptr<char[]>(new char[cookieLen]);
inf->fseek(-cookieLen, SEEK_END);
inf->fread(&sigbuf[0], cookieLen);
@@ -610,7 +610,7 @@
return false;
fseek(inf, 0, SEEK_END);
- uint32_t size = static_cast<uint32_t>(ftell(inf));
+ uint32_t size = ftell(inf);
uint32_t left = 0;
if (force_size > 0)
--- a/src/in_2sf/desmume/mem.h
+++ b/src/in_2sf/desmume/mem.h
@@ -43,7 +43,7 @@
{
assert(!(addr & 1));
#ifdef WORDS_BIGENDIAN
- return (static_cast<uint8_t *>(mem)[addr + 1] << 8) | static_cast<uint8_t *>(mem)[addr];
+ return (mem[addr + 1] << 8) | mem[addr];
#else
return *reinterpret_cast<const uint16_t *>(mem + addr);
#endif
@@ -52,7 +52,7 @@
inline uint16_t T1ReadWord(const uint8_t *const mem, uint32_t addr)
{
#ifdef WORDS_BIGENDIAN
- return (static_cast<uint8_t *>(mem)[addr + 1] << 8) | static_cast<uint8_t *>(mem)[addr];
+ return (mem[addr + 1] << 8) | mem[addr];
#else
return *reinterpret_cast<const uint16_t *>(mem + addr);
#endif
@@ -62,7 +62,7 @@
{
assert(!(addr & 3));
#ifdef WORDS_BIGENDIAN
- return mem[addr + 3] << 24 | mem[addr + 2] << 16 | mem[addr + 1] << 8 | mem[addr];
+ return (mem[addr + 3] << 24) | (mem[addr + 2] << 16) | (mem[addr + 1] << 8) | mem[addr];
#else
return *reinterpret_cast<const uint32_t *>(mem + addr);
#endif
@@ -72,7 +72,7 @@
{
addr &= ~3;
#ifdef WORDS_BIGENDIAN
- return mem[addr + 3] << 24 | mem[addr + 2] << 16 | mem[addr + 1] << 8 | mem[addr];
+ return (mem[addr + 3] << 24) | (mem[addr + 2] << 16) | (mem[addr + 1] << 8) | mem[addr];
#else
return *reinterpret_cast<const uint32_t *>(mem + addr);
#endif
@@ -81,8 +81,7 @@
inline uint64_t T1ReadQuad(const uint8_t *const mem, uint32_t addr)
{
#ifdef WORDS_BIGENDIAN
- return uint64_t(mem[addr + 7]) << 56 | uint64_t(mem[addr + 6]) << 48 | uint64_t(mem[addr + 5]) << 40 | uint64_t(mem[addr + 4]) << 32 |
- uint64_t(mem[addr + 3]) << 24 | uint64_t(mem[addr + 2]) << 16 | uint64_t(mem[addr + 1]) << 8 | uint64_t(mem[addr]);
+ return (mem[addr + 7] << 56) | (mem[addr + 6] << 48) | (mem[addr + 5] << 40) | (mem[addr + 4] << 32) | (mem[addr + 3] << 24) | (mem[addr + 2] << 16) | (mem[addr + 1] << 8) | mem[addr];
#else
return *reinterpret_cast<const uint64_t *>(mem + addr);
#endif
@@ -118,7 +117,7 @@
inline void T1WriteQuad(uint8_t *const mem, uint32_t addr, uint64_t val)
{
#ifdef WORDS_BIGENDIAN
- mem[addr + 7] = (val >> 56);
+ mem[addr + 7] = val >> 56;
mem[addr + 6] = (val >> 48) & 0xFF;
mem[addr + 5] = (val >> 40) & 0xFF;
mem[addr + 4] = (val >> 32) & 0xFF;
--- a/src/in_2sf/desmume/metaspu/SndOut.cpp
+++ b/src/in_2sf/desmume/metaspu/SndOut.cpp
@@ -36,7 +36,7 @@
StereoOut16 StereoOut32::DownSample() const
{
- return StereoOut16(static_cast<int16_t>(Left >> SndOutVolumeShift), static_cast<int16_t>(Right >> SndOutVolumeShift));
+ return StereoOut16((Left >> SndOutVolumeShift) & 0xFFFF, (Right >> SndOutVolumeShift) & 0xFFFF);
}
std::unique_ptr<StereoOut32[]> SndBuffer::m_buffer;
--- a/src/in_2sf/desmume/metaspu/SndOut.h
+++ b/src/in_2sf/desmume/metaspu/SndOut.h
@@ -83,7 +83,7 @@
{
}
- StereoOut16(const StereoOut32 &src) : Left(static_cast<int16_t>(src.Left)), Right(static_cast<int16_t>(src.Right))
+ StereoOut16(const StereoOut32 &src) : Left(src.Left & 0xFFFF), Right(src.Right & 0xFFFF)
{
}
--- a/src/in_2sf/desmume/metaspu/SoundTouch/FIFOSampleBuffer.cpp
+++ b/src/in_2sf/desmume/metaspu/SoundTouch/FIFOSampleBuffer.cpp
@@ -58,7 +58,7 @@
this->bufferUnaligned.reset();
this->samplesInBuffer = 0;
this->bufferPos = 0;
- this->channels = static_cast<uint32_t>(numChannels);
+ this->channels = numChannels;
this->ensureCapacity(32); // allocate initial capacity
}
@@ -72,7 +72,7 @@
{
assert(numChannels > 0);
uint32_t usedBytes = this->channels * this->samplesInBuffer;
- this->channels = static_cast<uint32_t>(numChannels);
+ this->channels = numChannels;
this->samplesInBuffer = usedBytes / this->channels;
}
--- a/src/in_2sf/desmume/metaspu/SoundTouch/FIRFilter.cpp
+++ b/src/in_2sf/desmume/metaspu/SoundTouch/FIRFilter.cpp
@@ -159,7 +159,7 @@
assert(this->length == newLength);
this->resultDivFactor = uResultDivFactor;
- this->resultDivider = static_cast<SAMPLETYPE>(std::pow(2.0, static_cast<double>(resultDivFactor)));
+ this->resultDivider = static_cast<SAMPLETYPE>(std::pow(2.0, static_cast<double>(this->resultDivFactor)));
this->filterCoeffs.reset(new SAMPLETYPE[this->length]);
memcpy(this->filterCoeffs.get(), coeffs, this->length * sizeof(SAMPLETYPE));
--- a/src/in_2sf/desmume/metaspu/SoundTouch/RateTransposer.cpp
+++ b/src/in_2sf/desmume/metaspu/SoundTouch/RateTransposer.cpp
@@ -325,7 +325,7 @@
LONG_SAMPLETYPE temp, vol1;
while (this->iSlopeCount <= SCALE)
{
- vol1 = static_cast<LONG_SAMPLETYPE>(SCALE - this->iSlopeCount);
+ vol1 = SCALE - this->iSlopeCount;
temp = vol1 * this->sPrevSampleL + this->iSlopeCount * src[0];
dest[i] = static_cast<SAMPLETYPE>(temp / SCALE);
++i;
@@ -343,7 +343,7 @@
if (used >= nSamples - 1)
goto end;
}
- vol1 = static_cast<LONG_SAMPLETYPE>(SCALE - this->iSlopeCount);
+ vol1 = SCALE - this->iSlopeCount;
temp = src[used] * vol1 + this->iSlopeCount * src[used + 1];
dest[i] = static_cast<SAMPLETYPE>(temp / SCALE);
++i;
@@ -370,7 +370,7 @@
LONG_SAMPLETYPE temp, vol1;
while (this->iSlopeCount <= SCALE)
{
- vol1 = static_cast<LONG_SAMPLETYPE>(SCALE - this->iSlopeCount);
+ vol1 = SCALE - this->iSlopeCount;
temp = vol1 * this->sPrevSampleL + this->iSlopeCount * src[0];
dest[2 * i] = static_cast<SAMPLETYPE>(temp / SCALE);
temp = vol1 * this->sPrevSampleR + this->iSlopeCount * src[1];
@@ -391,7 +391,7 @@
goto end;
}
unsigned srcPos = 2 * used;
- vol1 = static_cast<LONG_SAMPLETYPE>(SCALE - this->iSlopeCount);
+ vol1 = SCALE - this->iSlopeCount;
temp = src[srcPos] * vol1 + this->iSlopeCount * src[srcPos + 2];
dest[2 * i] = static_cast<SAMPLETYPE>(temp / SCALE);
temp = src[srcPos + 1] * vol1 + this->iSlopeCount * src[srcPos + 3];
--- a/src/in_2sf/desmume/metaspu/SoundTouch/SoundTouch.cpp
+++ b/src/in_2sf/desmume/metaspu/SoundTouch/SoundTouch.cpp
@@ -112,8 +112,8 @@
if (numChannels != 1 && numChannels != 2)
throw std::runtime_error("Illegal number of channels");
this->channels = numChannels;
- this->pRateTransposer->setChannels(static_cast<int32_t>(numChannels));
- this->pTDStretch->setChannels(static_cast<int32_t>(numChannels));
+ this->pRateTransposer->setChannels(numChannels);
+ this->pTDStretch->setChannels(numChannels);
}
// Sets new rate control value. Normal rate = 1.0, smaller values
@@ -230,7 +230,7 @@
{
this->bSrateSet = true;
// set sample rate, leave other tempo changer parameters as they are.
- this->pTDStretch->setParameters(static_cast<int32_t>(srate));
+ this->pTDStretch->setParameters(srate);
}
// Adds 'numSamples' pcs of samples from the 'samples' memory position into
@@ -300,7 +300,7 @@
for (int i = 0; i < 128; ++i)
{
this->putSamples(buff, 64);
- if (static_cast<int32_t>(numSamples()) >= nOut)
+ if (static_cast<int32_t>(this->numSamples()) >= nOut)
{
// Enough new samples have appeared into the output!
// As samples come from processing with bigger chunks, now truncate it
--- a/src/in_2sf/desmume/metaspu/SoundTouch/TDStretch.cpp
+++ b/src/in_2sf/desmume/metaspu/SoundTouch/TDStretch.cpp
@@ -167,7 +167,7 @@
// Overlaps samples in 'midBuffer' with the samples in 'pInput'
void TDStretch::overlapMono(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput) const
{
- SAMPLETYPE m1 = static_cast<SAMPLETYPE>(0);
+ SAMPLETYPE m1 = 0;
SAMPLETYPE m2 = static_cast<SAMPLETYPE>(this->overlapLength);
for (int32_t i = 0; i < this->overlapLength; ++i)
@@ -249,7 +249,7 @@
// to 'i'
double corr = this->calcCrossCorr(refPos + this->channels * i, this->pMidBuffer);
// heuristic rule to slightly favour values close to mid of the range
- double tmp = static_cast<double>(2 * i - this->seekLength) / this->seekLength;
+ double tmp = (2.0 * i - this->seekLength) / this->seekLength;
corr = (corr + 0.1) * (1.0 - 0.25 * tmp * tmp);
// Checks for the highest correlation value
@@ -293,9 +293,9 @@
// Calculates correlation value for the mixing position corresponding
// to 'tempOffset'
- double corr = static_cast<double>(this->calcCrossCorr(refPos + this->channels * tempOffset, this->pMidBuffer));
+ double corr = this->calcCrossCorr(refPos + this->channels * tempOffset, this->pMidBuffer);
// heuristic rule to slightly favour values close to mid of the range
- double tmp = static_cast<double>(2 * tempOffset - this->seekLength) / seekLength;
+ double tmp = (2.0 * tempOffset - this->seekLength) / seekLength;
corr = (corr + 0.1) * (1.0 - 0.25 * tmp * tmp);
// Checks for the highest correlation value
@@ -419,8 +419,8 @@
// samples in 'midBuffer' using sliding overlapping
// ... first partially overlap with the end of the previous sequence
// (that's in 'midBuffer')
- this->overlap(this->outputBuffer.ptrEnd(static_cast<uint32_t>(this->overlapLength)), this->inputBuffer.ptrBegin(), static_cast<uint32_t>(offset));
- this->outputBuffer.putSamples(static_cast<uint32_t>(this->overlapLength));
+ this->overlap(this->outputBuffer.ptrEnd(this->overlapLength), this->inputBuffer.ptrBegin(), offset);
+ this->outputBuffer.putSamples(this->overlapLength);
// ... then copy sequence samples from 'inputBuffer' to output:
@@ -431,12 +431,12 @@
if (static_cast<int32_t>(inputBuffer.numSamples()) < offset + temp + this->overlapLength * 2)
continue; // just in case, shouldn't really happen
- this->outputBuffer.putSamples(this->inputBuffer.ptrBegin() + this->channels * (offset + this->overlapLength), static_cast<uint32_t>(temp));
+ this->outputBuffer.putSamples(this->inputBuffer.ptrBegin() + this->channels * (offset + this->overlapLength), temp);
// Copies the end of the current sequence from 'inputBuffer' to
// 'midBuffer' for being mixed with the beginning of the next
// processing sequence and so on
- assert(offset + temp + this->overlapLength * 2 <= static_cast<int>(this->inputBuffer.numSamples()));
+ assert(offset + temp + this->overlapLength * 2 <= static_cast<int32_t>(this->inputBuffer.numSamples()));
memcpy(this->pMidBuffer, this->inputBuffer.ptrBegin() + this->channels * (offset + this->seekWindowLength - this->overlapLength), this->channels * sizeof(SAMPLETYPE) * this->overlapLength);
// Remove the processed samples from the input buffer. Update
@@ -445,7 +445,7 @@
this->skipFract += this->nominalSkip; // real skip size
int ovlSkip = static_cast<int>(skipFract); // rounded to integer skip
this->skipFract -= ovlSkip; // maintain the fraction part, i.e. real vs. integer skip
- this->inputBuffer.receiveSamples(static_cast<uint32_t>(ovlSkip));
+ this->inputBuffer.receiveSamples(ovlSkip);
}
}
@@ -522,7 +522,7 @@
{
for (int32_t i = 0; i < this->overlapLength; ++i)
{
- short temp = static_cast<short>(this->overlapLength - i);
+ short temp = this->overlapLength - i;
int32_t cnt2 = 2 * i;
poutput[cnt2] = (pinput[cnt2] * i + this->pMidBuffer[cnt2] * temp) / this->overlapLength;
poutput[cnt2 + 1] = (pinput[cnt2 + 1] * i + this->pMidBuffer[cnt2 + 1] * temp) / this->overlapLength;
@@ -550,7 +550,7 @@
this->overlapDividerBits = 9;
if (this->overlapDividerBits < 3)
this->overlapDividerBits = 3;
- int32_t newOvl = static_cast<int>std::pow(2, static_cast<int>(this->overlapDividerBits) + 1); // +1 => account for -1 above
+ int32_t newOvl = static_cast<int32_t>(std::pow(2, this->overlapDividerBits + 1)); // +1 => account for -1 above
this->acceptNewOverlapLength(newOvl);
--- a/src/in_2sf/desmume/metaspu/SoundTouch/sse_optimized.cpp
+++ b/src/in_2sf/desmume/metaspu/SoundTouch/sse_optimized.cpp
@@ -140,7 +140,7 @@
norm = 1.0; // to avoid div by zero
float *pvSum = reinterpret_cast<float *>(&vSum);
- return static_cast<double>(pvSum[0] + pvSum[1] + pvSum[2] + pvSum[3]) / norm;
+ return (pvSum[0] + pvSum[1] + pvSum[2] + pvSum[3]) / norm;
/* This is approximately corresponding routine in C-language:
double corr, norm;
@@ -277,7 +277,7 @@
// 2. If it could be guaranteed that 'dest' were always aligned to 16-byte
// boundary, a faster '_mm_store_ps' instruction could be used.
- return static_cast<uint32_t>(count);
+ return count;
/* original routine in C-language. please notice the C-version has differently
organized coefficients though.
--- a/src/in_2sf/desmume/metaspu/Timestretcher.cpp
+++ b/src/in_2sf/desmume/metaspu/Timestretcher.cpp
@@ -259,7 +259,7 @@
// suddenly we'll get several chunks back at once. Thus we use
// data prediction to make the timestretcher more responsive.
- PredictDataWrite(static_cast<int>(SndOutPacketSize / eTempo));
+ PredictDataWrite(SndOutPacketSize / eTempo);
CvtPacketToFloat(sndTempBuffer.get());
pSoundTouch->putSamples(reinterpret_cast<float *>(sndTempBuffer.get()), SndOutPacketSize);
--- a/src/in_2sf/desmume/metaspu/metaspu.cpp
+++ b/src/in_2sf/desmume/metaspu/metaspu.cpp
@@ -124,7 +124,7 @@
this->rollingTotalSize -= this->statsHistory.front();
this->statsHistory.pop();
- float averageSize = static_cast<float>(rollingTotalSize / kAverageSize);
+ float averageSize = rollingTotalSize / kAverageSize;
//static int ctr=0; ctr++; if((ctr&127)==0) printf("avg size: %f curr size: %d rate: %f\n",averageSize,size,rate);
{
float targetRate;
@@ -208,8 +208,8 @@
int outNum = end - cur;
int denom = end - start;
- int lrv = (static_cast<int>(lhs.l) * outNum + static_cast<int>(rhs.l) * inNum) / denom;
- int rrv = (static_cast<int>(lhs.r) * outNum + static_cast<int>(rhs.r) * inNum) / denom;
+ int lrv = (lhs.l * outNum + rhs.l * inNum) / denom;
+ int rrv = (lhs.r * outNum + rhs.r * inNum) / denom;
return ssamp(lrv, rrv);
}
--- a/src/in_2sf/desmume/utils/dlditool.cpp
+++ b/src/in_2sf/desmume/utils/dlditool.cpp
@@ -130,15 +130,15 @@
addr_t readAddr(data_t *mem, addr_t offset)
{
- return static_cast<addr_t>(mem[offset + 0] | (mem[offset + 1] << 8) | (mem[offset + 2] << 16) | (mem[offset + 3] << 24));
+ return mem[offset + 0] | (mem[offset + 1] << 8) | (mem[offset + 2] << 16) | (mem[offset + 3] << 24);
}
void writeAddr(data_t *mem, addr_t offset, addr_t value)
{
- mem[offset + 0] = static_cast<data_t>(value);
- mem[offset + 1] = static_cast<data_t>(value >> 8);
- mem[offset + 2] = static_cast<data_t>(value >> 16);
- mem[offset + 3] = static_cast<data_t>(value >> 24);
+ mem[offset + 0] = value & 0xFF;
+ mem[offset + 1] = (value >> 8) & 0xFF;
+ mem[offset + 2] = (value >> 16) & 0xFF;
+ mem[offset + 3] = (value >> 24) & 0xFF;
}
int stringCaseInsensitiveCompare(const char *str1, const char *str2)