| ... | ... |
@@ -41,7 +41,7 @@ static uint64_t isqrt(uint64_t x) |
| 41 | 41 |
* is even, and the one bit is as far left as is consistant |
| 42 | 42 |
* with that condition.) |
| 43 | 43 |
*/ |
| 44 |
- uint64_t squaredbit = static_cast<uint64_t>((static_cast<uint64_t>(~0LL) >> 1) & ~(static_cast<uint64_t>(~0LL) >> 2)); |
|
| 44 |
+ uint64_t squaredbit = (~0LL >> 1) & ~(~0LL >> 2); |
|
| 45 | 45 |
/* This portable load replaces the loop that used to be |
| 46 | 46 |
* here, and was donated by legalize@xmission.com |
| 47 | 47 |
*/ |
| ... | ... |
@@ -860,12 +860,12 @@ static void execsqrt() |
| 860 | 860 |
if (mode) |
| 861 | 861 |
{
|
| 862 | 862 |
uint64_t v = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8); |
| 863 |
- ret = static_cast<uint32_t>(isqrt(v)); |
|
| 863 |
+ ret = isqrt(v) & 0xFFFFFFFF; |
|
| 864 | 864 |
} |
| 865 | 865 |
else |
| 866 | 866 |
{
|
| 867 | 867 |
uint32_t v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8); |
| 868 |
- ret = static_cast<uint32_t>(isqrt(v)); |
|
| 868 |
+ ret = isqrt(v) & 0xFFFFFFFF; |
|
| 869 | 869 |
} |
| 870 | 870 |
|
| 871 | 871 |
// clear the result while the sqrt unit is busy |
| ... | ... |
@@ -889,20 +889,20 @@ static void execdiv() |
| 889 | 889 |
switch (mode) |
| 890 | 890 |
{
|
| 891 | 891 |
case 0: // 32/32 |
| 892 |
- num = static_cast<int64_t>(static_cast<int32_t>(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290))); |
|
| 893 |
- den = static_cast<int64_t>(static_cast<int32_t>(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298))); |
|
| 892 |
+ num = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); |
|
| 893 |
+ den = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); |
|
| 894 | 894 |
MMU.divCycles = nds_timer + 36; |
| 895 | 895 |
break; |
| 896 | 896 |
case 1: // 64/32 |
| 897 |
- case 3: //gbatek says this is same as mode 1 |
|
| 898 |
- num = static_cast<int64_t>(T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290)); |
|
| 899 |
- den = static_cast<int64_t>(static_cast<int32_t>(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298))); |
|
| 897 |
+ case 3: // gbatek says this is same as mode 1 |
|
| 898 |
+ num = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); |
|
| 899 |
+ den = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); |
|
| 900 | 900 |
MMU.divCycles = nds_timer + 68; |
| 901 | 901 |
break; |
| 902 | 902 |
case 2: // 64/64 |
| 903 | 903 |
default: |
| 904 |
- num = static_cast<int64_t>(T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290)); |
|
| 905 |
- den = static_cast<int64_t>(T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298)); |
|
| 904 |
+ num = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); |
|
| 905 |
+ den = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); |
|
| 906 | 906 |
MMU.divCycles = nds_timer + 68; |
| 907 | 907 |
} |
| 908 | 908 |
|
| ... | ... |
@@ -912,7 +912,7 @@ static void execdiv() |
| 912 | 912 |
mod = num; |
| 913 | 913 |
|
| 914 | 914 |
// the DIV0 flag in DIVCNT is set only if the full 64bit DIV_DENOM value is zero, even in 32bit mode |
| 915 |
- if (!static_cast<uint64_t>(T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298))) |
|
| 915 |
+ if (!T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298)) |
|
| 916 | 916 |
MMU_new.div.div0 = 1; |
| 917 | 917 |
} |
| 918 | 918 |
else |
| ... | ... |
@@ -958,7 +958,7 @@ uint16_t DSI_TSC::write16(uint16_t val) |
| 958 | 958 |
return this->read16(); |
| 959 | 959 |
case 1: |
| 960 | 960 |
if (!this->read_flag) |
| 961 |
- this->registers[this->reg_selection] = static_cast<uint8_t>(val); |
|
| 961 |
+ this->registers[this->reg_selection] = val & 0xFF; |
|
| 962 | 962 |
ret = this->read16(); |
| 963 | 963 |
++this->reg_selection; |
| 964 | 964 |
this->reg_selection &= 0x7F; |
| ... | ... |
@@ -1128,7 +1128,7 @@ template<int PROCNUM> static void REG_IF_WriteByte(uint32_t addr, uint8_t val) |
| 1128 | 1128 |
// ZERO 01-dec-2010 : I am no longer sure this approach is correct.. it proved to be wrong for IPC fifo....... |
| 1129 | 1129 |
// it seems as if IF bits should always be cached (only the user can clear them) |
| 1130 | 1130 |
|
| 1131 |
- MMU.reg_IF_bits[PROCNUM] &= ~(static_cast<uint32_t>(val) << (addr << 3)); |
|
| 1131 |
+ MMU.reg_IF_bits[PROCNUM] &= ~(val << (addr << 3)); |
|
| 1132 | 1132 |
NDS_Reschedule(); |
| 1133 | 1133 |
} |
| 1134 | 1134 |
|
| ... | ... |
@@ -1182,7 +1182,7 @@ static inline uint16_t read_timer(int proc, int timerIndex) |
| 1182 | 1182 |
return MMU.timer[proc][timerIndex]; |
| 1183 | 1183 |
|
| 1184 | 1184 |
// for unchained timers, we do not keep the timer up to date. its value will need to be calculated here |
| 1185 |
- int32_t diff = static_cast<int32_t>(nds.timerCycle[proc][timerIndex] - nds_timer); |
|
| 1185 |
+ int32_t diff = (nds.timerCycle[proc][timerIndex] - nds_timer) & 0xFFFFFFFF; |
|
| 1186 | 1186 |
assert(diff >= 0); |
| 1187 | 1187 |
if (diff < 0) |
| 1188 | 1188 |
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 @@ static inline uint16_t read_timer(int proc, int timerIndex) |
| 1201 | 1201 |
else |
| 1202 | 1202 |
ret = 65535 - units; |
| 1203 | 1203 |
|
| 1204 |
- return static_cast<uint16_t>(ret); |
|
| 1204 |
+ return ret & 0xFFFF; |
|
| 1205 | 1205 |
} |
| 1206 | 1206 |
|
| 1207 | 1207 |
static inline void write_timer(int proc, int timerIndex, uint16_t val) |
| ... | ... |
@@ -1311,13 +1311,13 @@ void DmaController::write32(uint32_t val) |
| 1311 | 1311 |
uint32_t valhi = val >> 16; |
| 1312 | 1312 |
this->dar = static_cast<EDMADestinationUpdate>((valhi >> 5) & 3); |
| 1313 | 1313 |
this->sar = static_cast<EDMASourceUpdate>((valhi >> 7) & 3); |
| 1314 |
- this->repeatMode = static_cast<uint8_t>(BIT9(valhi)); |
|
| 1314 |
+ this->repeatMode = BIT9(valhi); |
|
| 1315 | 1315 |
this->bitWidth = static_cast<EDMABitWidth>(BIT10(valhi)); |
| 1316 | 1316 |
this->_startmode = (valhi >> 11) & 7; |
| 1317 | 1317 |
if (this->procnum == ARMCPU_ARM7) |
| 1318 | 1318 |
this->_startmode &= 6; |
| 1319 |
- this->irq = static_cast<uint8_t>(BIT14(valhi)); |
|
| 1320 |
- this->enable = static_cast<uint8_t>(BIT15(valhi)); |
|
| 1319 |
+ this->irq = BIT14(valhi); |
|
| 1320 |
+ this->enable = BIT15(valhi); |
|
| 1321 | 1321 |
|
| 1322 | 1322 |
// make sure we don't get any old triggers |
| 1323 | 1323 |
if (!wasEnable && this->enable) |
| ... | ... |
@@ -1434,7 +1434,7 @@ template<int PROCNUM> void DmaController::doCopy() |
| 1434 | 1434 |
dstinc = sz; |
| 1435 | 1435 |
break; |
| 1436 | 1436 |
case EDMADestinationUpdate_Decrement: |
| 1437 |
- dstinc = static_cast<uint32_t>(-static_cast<int32_t>(sz)); |
|
| 1437 |
+ dstinc = -static_cast<int32_t>(sz); |
|
| 1438 | 1438 |
break; |
| 1439 | 1439 |
case EDMADestinationUpdate_Fixed: |
| 1440 | 1440 |
dstinc = 0; |
| ... | ... |
@@ -1451,7 +1451,7 @@ template<int PROCNUM> void DmaController::doCopy() |
| 1451 | 1451 |
srcinc = sz; |
| 1452 | 1452 |
break; |
| 1453 | 1453 |
case EDMASourceUpdate_Decrement: |
| 1454 |
- srcinc = static_cast<uint32_t>(-static_cast<int32_t>(sz)); |
|
| 1454 |
+ srcinc = -static_cast<int32_t>(sz); |
|
| 1455 | 1455 |
break; |
| 1456 | 1456 |
case EDMASourceUpdate_Fixed: |
| 1457 | 1457 |
srcinc = 0; |
| ... | ... |
@@ -1479,7 +1479,7 @@ template<int PROCNUM> void DmaController::doCopy() |
| 1479 | 1479 |
// we might make another function to do just the raw copy op which can use them with checks |
| 1480 | 1480 |
// outside the loop |
| 1481 | 1481 |
int time_elapsed = 0; |
| 1482 |
- for (int32_t i = static_cast<int32_t>(todo); i > 0; --i) |
|
| 1482 |
+ for (int32_t i = todo; i > 0; --i) |
|
| 1483 | 1483 |
{
|
| 1484 | 1484 |
if (sz == 4) |
| 1485 | 1485 |
{
|
| ... | ... |
@@ -1672,7 +1672,7 @@ void FASTCALL _MMU_ARM9_write08(uint32_t adr, uint8_t val) |
| 1672 | 1672 |
case REG_WRAMCNT: |
| 1673 | 1673 |
case REG_VRAMCNTH: |
| 1674 | 1674 |
case REG_VRAMCNTI: |
| 1675 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA), val); |
|
| 1675 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA, val); |
|
| 1676 | 1676 |
} |
| 1677 | 1677 |
|
| 1678 | 1678 |
MMU.MMU_MEM[ARMCPU_ARM9][adr >> 20][adr & MMU.MMU_MASK[ARMCPU_ARM9][adr >> 20]] = val; |
| ... | ... |
@@ -1761,8 +1761,8 @@ void FASTCALL _MMU_ARM9_write16(uint32_t adr, uint16_t val) |
| 1761 | 1761 |
case REG_VRAMCNTE: |
| 1762 | 1762 |
case REG_VRAMCNTG: |
| 1763 | 1763 |
case REG_VRAMCNTH: |
| 1764 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA), val & 0xFF); |
|
| 1765 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 1), val >> 8); |
|
| 1764 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA, val & 0xFF); |
|
| 1765 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 1, val >> 8); |
|
| 1766 | 1766 |
break; |
| 1767 | 1767 |
|
| 1768 | 1768 |
case REG_IME: |
| ... | ... |
@@ -1776,7 +1776,7 @@ void FASTCALL _MMU_ARM9_write16(uint32_t adr, uint16_t val) |
| 1776 | 1776 |
return; |
| 1777 | 1777 |
case REG_IE + 2: |
| 1778 | 1778 |
NDS_Reschedule(); |
| 1779 |
- MMU.reg_IE[ARMCPU_ARM9] = (MMU.reg_IE[ARMCPU_ARM9] & 0xFFFF) | (static_cast<uint32_t>(val) << 16); |
|
| 1779 |
+ MMU.reg_IE[ARMCPU_ARM9] = (MMU.reg_IE[ARMCPU_ARM9] & 0xFFFF) | (val << 16); |
|
| 1780 | 1780 |
return; |
| 1781 | 1781 |
case REG_IF: |
| 1782 | 1782 |
REG_IF_WriteWord<ARMCPU_ARM9>(0, val); |
| ... | ... |
@@ -1811,7 +1811,7 @@ void FASTCALL _MMU_ARM9_write16(uint32_t adr, uint16_t val) |
| 1811 | 1811 |
MMU_writeToGCControl<ARMCPU_ARM9>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4) & 0xFFFF0000) | val); |
| 1812 | 1812 |
return; |
| 1813 | 1813 |
case REG_GCROMCTRL + 2: |
| 1814 |
- MMU_writeToGCControl<ARMCPU_ARM9>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4) & 0xFFFF) | (static_cast<uint32_t>(val) << 16)); |
|
| 1814 |
+ MMU_writeToGCControl<ARMCPU_ARM9>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4) & 0xFFFF) | (val << 16)); |
|
| 1815 | 1815 |
return; |
| 1816 | 1816 |
} |
| 1817 | 1817 |
|
| ... | ... |
@@ -1862,22 +1862,22 @@ void FASTCALL _MMU_ARM9_write32(uint32_t adr, uint32_t val) |
| 1862 | 1862 |
switch (adr) |
| 1863 | 1863 |
{
|
| 1864 | 1864 |
case REG_SQRTCNT: |
| 1865 |
- MMU_new.sqrt.write16(static_cast<uint16_t>(val)); |
|
| 1865 |
+ MMU_new.sqrt.write16(val & 0xFFFF); |
|
| 1866 | 1866 |
return; |
| 1867 | 1867 |
case REG_DIVCNT: |
| 1868 |
- MMU_new.div.write16(static_cast<uint16_t>(val)); |
|
| 1868 |
+ MMU_new.div.write16(val & 0xFFFF); |
|
| 1869 | 1869 |
return; |
| 1870 | 1870 |
|
| 1871 | 1871 |
case REG_VRAMCNTA: |
| 1872 | 1872 |
case REG_VRAMCNTE: |
| 1873 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA), val & 0xFF); |
|
| 1874 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 1), (val >> 8) & 0xFF); |
|
| 1875 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 2), (val >> 16) & 0xFF); |
|
| 1876 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 3), (val >> 24) & 0xFF); |
|
| 1873 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA, val & 0xFF); |
|
| 1874 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 1, (val >> 8) & 0xFF); |
|
| 1875 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 2, (val >> 16) & 0xFF); |
|
| 1876 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 3, (val >> 24) & 0xFF); |
|
| 1877 | 1877 |
break; |
| 1878 | 1878 |
case REG_VRAMCNTH: |
| 1879 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA), val & 0xFF); |
|
| 1880 |
- MMU_VRAMmapControl(static_cast<uint8_t>(adr - REG_VRAMCNTA + 1), (val >> 8) & 0xFF); |
|
| 1879 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA, val & 0xFF); |
|
| 1880 |
+ MMU_VRAMmapControl(adr - REG_VRAMCNTA + 1, (val >> 8) & 0xFF); |
|
| 1881 | 1881 |
break; |
| 1882 | 1882 |
|
| 1883 | 1883 |
case REG_IME: |
| ... | ... |
@@ -1901,8 +1901,8 @@ void FASTCALL _MMU_ARM9_write32(uint32_t adr, uint32_t val) |
| 1901 | 1901 |
case REG_TM3CNTL: |
| 1902 | 1902 |
{
|
| 1903 | 1903 |
int timerIndex = (adr >> 2) & 0x3; |
| 1904 |
- MMU.timerReload[ARMCPU_ARM9][timerIndex] = static_cast<uint16_t>(val); |
|
| 1905 |
- T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & 0xFFF, static_cast<uint16_t>(val)); |
|
| 1904 |
+ MMU.timerReload[ARMCPU_ARM9][timerIndex] = val & 0xFFFF; |
|
| 1905 |
+ T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & 0xFFF, val & 0xFFFF); |
|
| 1906 | 1906 |
write_timer(ARMCPU_ARM9, timerIndex, val >> 16); |
| 1907 | 1907 |
return; |
| 1908 | 1908 |
} |
| ... | ... |
@@ -1946,7 +1946,7 @@ void FASTCALL _MMU_ARM9_write32(uint32_t adr, uint32_t val) |
| 1946 | 1946 |
MMU_IPCSync(ARMCPU_ARM9, val); |
| 1947 | 1947 |
return; |
| 1948 | 1948 |
case REG_IPCFIFOCNT: |
| 1949 |
- IPC_FIFOcnt(ARMCPU_ARM9, static_cast<uint16_t>(val)); |
|
| 1949 |
+ IPC_FIFOcnt(ARMCPU_ARM9, val & 0xFFFF); |
|
| 1950 | 1950 |
return; |
| 1951 | 1951 |
case REG_IPCFIFOSEND: |
| 1952 | 1952 |
IPC_FIFOsend(ARMCPU_ARM9, val); |
| ... | ... |
@@ -2001,18 +2001,18 @@ uint8_t FASTCALL _MMU_ARM9_read08(uint32_t adr) |
| 2001 | 2001 |
//Address is an IO register |
| 2002 | 2002 |
|
| 2003 | 2003 |
if (MMU_new.is_dma(adr)) |
| 2004 |
- return static_cast<uint8_t>(MMU_new.read_dma(ARMCPU_ARM9, 8, adr)); |
|
| 2004 |
+ return MMU_new.read_dma(ARMCPU_ARM9, 8, adr) & 0xFF; |
|
| 2005 | 2005 |
|
| 2006 | 2006 |
switch (adr) |
| 2007 | 2007 |
{
|
| 2008 | 2008 |
case REG_IF: |
| 2009 |
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM9>()); |
|
| 2009 |
+ return MMU.gen_IF<ARMCPU_ARM9>() & 0xFF; |
|
| 2010 | 2010 |
case REG_IF + 1: |
| 2011 |
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM9>() >> 8); |
|
| 2011 |
+ return (MMU.gen_IF<ARMCPU_ARM9>() >> 8) & 0xFF; |
|
| 2012 | 2012 |
case REG_IF + 2: |
| 2013 |
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM9>() >> 16); |
|
| 2013 |
+ return (MMU.gen_IF<ARMCPU_ARM9>() >> 16) & 0xFF; |
|
| 2014 | 2014 |
case REG_IF + 3: |
| 2015 |
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM9>() >> 24); |
|
| 2015 |
+ return (MMU.gen_IF<ARMCPU_ARM9>() >> 24) & 0xFF; |
|
| 2016 | 2016 |
|
| 2017 | 2017 |
case REG_WRAMCNT: |
| 2018 | 2018 |
return MMU.WRAMCNT; |
| ... | ... |
@@ -2068,7 +2068,7 @@ uint16_t FASTCALL _MMU_ARM9_read16(uint32_t adr) |
| 2068 | 2068 |
if ((adr >> 24) == 4) |
| 2069 | 2069 |
{
|
| 2070 | 2070 |
if (MMU_new.is_dma(adr)) |
| 2071 |
- return static_cast<uint16_t>(MMU_new.read_dma(ARMCPU_ARM9, 16, adr)); |
|
| 2071 |
+ return MMU_new.read_dma(ARMCPU_ARM9, 16, adr) & 0xFFFF; |
|
| 2072 | 2072 |
|
| 2073 | 2073 |
// Address is an IO register |
| 2074 | 2074 |
switch (adr) |
| ... | ... |
@@ -2088,21 +2088,21 @@ uint16_t FASTCALL _MMU_ARM9_read16(uint32_t adr) |
| 2088 | 2088 |
return 0; |
| 2089 | 2089 |
|
| 2090 | 2090 |
case REG_IME: |
| 2091 |
- return static_cast<uint16_t>(MMU.reg_IME[ARMCPU_ARM9]); |
|
| 2091 |
+ return MMU.reg_IME[ARMCPU_ARM9] & 0xFFFF; |
|
| 2092 | 2092 |
|
| 2093 | 2093 |
// WRAMCNT is readable but VRAMCNT is not, so just return WRAM's value |
| 2094 | 2094 |
case REG_VRAMCNTG: |
| 2095 | 2095 |
return MMU.WRAMCNT << 8; |
| 2096 | 2096 |
|
| 2097 | 2097 |
case REG_IE: |
| 2098 |
- return static_cast<uint16_t>(MMU.reg_IE[ARMCPU_ARM9]); |
|
| 2098 |
+ return MMU.reg_IE[ARMCPU_ARM9] & 0xFFFF; |
|
| 2099 | 2099 |
case REG_IE + 2: |
| 2100 |
- return static_cast<uint16_t>(MMU.reg_IE[ARMCPU_ARM9] >> 16); |
|
| 2100 |
+ return (MMU.reg_IE[ARMCPU_ARM9] >> 16) & 0xFFFF; |
|
| 2101 | 2101 |
|
| 2102 | 2102 |
case REG_IF: |
| 2103 |
- return static_cast<uint16_t>(MMU.gen_IF<ARMCPU_ARM9>()); |
|
| 2103 |
+ return MMU.gen_IF<ARMCPU_ARM9>() & 0xFFFF; |
|
| 2104 | 2104 |
case REG_IF + 2: |
| 2105 |
- return static_cast<uint16_t>(MMU.gen_IF<ARMCPU_ARM9>() >> 16); |
|
| 2105 |
+ return (MMU.gen_IF<ARMCPU_ARM9>() >> 16) & 0xFFFF; |
|
| 2106 | 2106 |
|
| 2107 | 2107 |
case REG_TM0CNTL: |
| 2108 | 2108 |
case REG_TM1CNTL: |
| ... | ... |
@@ -2372,7 +2372,7 @@ void FASTCALL _MMU_ARM7_write16(uint32_t adr, uint16_t val) |
| 2372 | 2372 |
else |
| 2373 | 2373 |
{
|
| 2374 | 2374 |
// write |
| 2375 |
- MMU.powerMan_Reg[reg] = static_cast<uint8_t>(val); |
|
| 2375 |
+ MMU.powerMan_Reg[reg] = val & 0xFF; |
|
| 2376 | 2376 |
|
| 2377 | 2377 |
static const uint32_t PM_SYSTEM_PWR = BIT(6); /*!< \brief Turn the power *off* if set */ |
| 2378 | 2378 |
|
| ... | ... |
@@ -2395,7 +2395,7 @@ void FASTCALL _MMU_ARM7_write16(uint32_t adr, uint16_t val) |
| 2395 | 2395 |
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, 0); |
| 2396 | 2396 |
break; |
| 2397 | 2397 |
} |
| 2398 |
- T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, static_cast<uint8_t>(val))); |
|
| 2398 |
+ T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, val & 0xFF)); |
|
| 2399 | 2399 |
return; |
| 2400 | 2400 |
|
| 2401 | 2401 |
case 2: |
| ... | ... |
@@ -2526,7 +2526,7 @@ void FASTCALL _MMU_ARM7_write16(uint32_t adr, uint16_t val) |
| 2526 | 2526 |
return; |
| 2527 | 2527 |
case REG_IE + 2: |
| 2528 | 2528 |
NDS_Reschedule(); |
| 2529 |
- MMU.reg_IE[ARMCPU_ARM7] = (MMU.reg_IE[ARMCPU_ARM7] & 0xFFFF) | (static_cast<uint32_t>(val) << 16); |
|
| 2529 |
+ MMU.reg_IE[ARMCPU_ARM7] = (MMU.reg_IE[ARMCPU_ARM7] & 0xFFFF) | (val << 16); |
|
| 2530 | 2530 |
return; |
| 2531 | 2531 |
|
| 2532 | 2532 |
case REG_IF: |
| ... | ... |
@@ -2563,7 +2563,7 @@ void FASTCALL _MMU_ARM7_write16(uint32_t adr, uint16_t val) |
| 2563 | 2563 |
MMU_writeToGCControl<ARMCPU_ARM7>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4) & 0xFFFF0000) | val); |
| 2564 | 2564 |
return; |
| 2565 | 2565 |
case REG_GCROMCTRL + 2: |
| 2566 |
- MMU_writeToGCControl<ARMCPU_ARM7>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4) & 0xFFFF) | (static_cast<uint32_t>(val) << 16)); |
|
| 2566 |
+ MMU_writeToGCControl<ARMCPU_ARM7>((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4) & 0xFFFF) | (val << 16)); |
|
| 2567 | 2567 |
return; |
| 2568 | 2568 |
} |
| 2569 | 2569 |
|
| ... | ... |
@@ -2628,8 +2628,8 @@ void FASTCALL _MMU_ARM7_write32(uint32_t adr, uint32_t val) |
| 2628 | 2628 |
case REG_TM3CNTL: |
| 2629 | 2629 |
{
|
| 2630 | 2630 |
int timerIndex = (adr >> 2) & 0x3; |
| 2631 |
- MMU.timerReload[ARMCPU_ARM7][timerIndex] = static_cast<uint16_t>(val); |
|
| 2632 |
- T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & 0xFFF, static_cast<uint16_t>(val)); |
|
| 2631 |
+ MMU.timerReload[ARMCPU_ARM7][timerIndex] = val & 0xFFFF; |
|
| 2632 |
+ T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & 0xFFF, val & 0xFFFF); |
|
| 2633 | 2633 |
write_timer(ARMCPU_ARM7, timerIndex, val >> 16); |
| 2634 | 2634 |
return; |
| 2635 | 2635 |
} |
| ... | ... |
@@ -2638,7 +2638,7 @@ void FASTCALL _MMU_ARM7_write32(uint32_t adr, uint32_t val) |
| 2638 | 2638 |
MMU_IPCSync(ARMCPU_ARM7, val); |
| 2639 | 2639 |
return; |
| 2640 | 2640 |
case REG_IPCFIFOCNT: |
| 2641 |
- IPC_FIFOcnt(ARMCPU_ARM7, static_cast<uint16_t>(val)); |
|
| 2641 |
+ IPC_FIFOcnt(ARMCPU_ARM7, val & 0xFFFF); |
|
| 2642 | 2642 |
return; |
| 2643 | 2643 |
case REG_IPCFIFOSEND: |
| 2644 | 2644 |
IPC_FIFOsend(ARMCPU_ARM7, val); |
| ... | ... |
@@ -2690,20 +2690,20 @@ uint8_t FASTCALL _MMU_ARM7_read08(uint32_t adr) |
| 2690 | 2690 |
if ((adr >> 24) == 4) |
| 2691 | 2691 |
{
|
| 2692 | 2692 |
if (MMU_new.is_dma(adr)) |
| 2693 |
- return static_cast<uint8_t>(MMU_new.read_dma(ARMCPU_ARM7, 8, adr)); |
|
| 2693 |
+ return MMU_new.read_dma(ARMCPU_ARM7, 8, adr) & 0xFF; |
|
| 2694 | 2694 |
|
| 2695 | 2695 |
// Address is an IO register |
| 2696 | 2696 |
|
| 2697 | 2697 |
switch (adr) |
| 2698 | 2698 |
{
|
| 2699 | 2699 |
case REG_IF: |
| 2700 |
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM7>()); |
|
| 2700 |
+ return MMU.gen_IF<ARMCPU_ARM7>() & 0xFF; |
|
| 2701 | 2701 |
case REG_IF + 1: |
| 2702 |
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM7>() >> 8); |
|
| 2702 |
+ return (MMU.gen_IF<ARMCPU_ARM7>() >> 8) & 0xFF; |
|
| 2703 | 2703 |
case REG_IF + 2: |
| 2704 |
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM7>() >> 16); |
|
| 2704 |
+ return (MMU.gen_IF<ARMCPU_ARM7>() >> 16) & 0xFF; |
|
| 2705 | 2705 |
case REG_IF + 3: |
| 2706 |
- return static_cast<uint8_t>(MMU.gen_IF<ARMCPU_ARM7>() >> 24); |
|
| 2706 |
+ return (MMU.gen_IF<ARMCPU_ARM7>() >> 24) & 0xFF; |
|
| 2707 | 2707 |
|
| 2708 | 2708 |
case REG_WRAMSTAT: |
| 2709 | 2709 |
return MMU.WRAMCNT; |
| ... | ... |
@@ -2737,22 +2737,22 @@ uint16_t FASTCALL _MMU_ARM7_read16(uint32_t adr) |
| 2737 | 2737 |
// Address is an IO register |
| 2738 | 2738 |
|
| 2739 | 2739 |
if (MMU_new.is_dma(adr)) |
| 2740 |
- return static_cast<uint16_t>(MMU_new.read_dma(ARMCPU_ARM7, 16, adr)); |
|
| 2740 |
+ return MMU_new.read_dma(ARMCPU_ARM7, 16, adr) & 0xFFFF; |
|
| 2741 | 2741 |
|
| 2742 | 2742 |
switch (adr) |
| 2743 | 2743 |
{
|
| 2744 | 2744 |
case REG_IME: |
| 2745 |
- return static_cast<uint16_t>(MMU.reg_IME[ARMCPU_ARM7]); |
|
| 2745 |
+ return MMU.reg_IME[ARMCPU_ARM7] & 0xFFFF; |
|
| 2746 | 2746 |
|
| 2747 | 2747 |
case REG_IE: |
| 2748 |
- return static_cast<uint16_t>(MMU.reg_IE[ARMCPU_ARM7]); |
|
| 2748 |
+ return MMU.reg_IE[ARMCPU_ARM7] & 0xFFFF; |
|
| 2749 | 2749 |
case REG_IE + 2: |
| 2750 |
- return static_cast<uint16_t>(MMU.reg_IE[ARMCPU_ARM7] >> 16); |
|
| 2750 |
+ return (MMU.reg_IE[ARMCPU_ARM7] >> 16) & 0xFFFF; |
|
| 2751 | 2751 |
|
| 2752 | 2752 |
case REG_IF: |
| 2753 |
- return static_cast<uint16_t>(MMU.gen_IF<ARMCPU_ARM7>()); |
|
| 2753 |
+ return MMU.gen_IF<ARMCPU_ARM7>() & 0xFFFF; |
|
| 2754 | 2754 |
case REG_IF + 2: |
| 2755 |
- return static_cast<uint16_t>(MMU.gen_IF<ARMCPU_ARM7>() >> 16); |
|
| 2755 |
+ return (MMU.gen_IF<ARMCPU_ARM7>() >> 16) & 0xFFFF; |
|
| 2756 | 2756 |
|
| 2757 | 2757 |
case REG_TM0CNTL: |
| 2758 | 2758 |
case REG_TM1CNTL: |
| ... | ... |
@@ -130,8 +130,8 @@ private: |
| 130 | 130 |
enum { ASSOCIATIVITY = 1 << ASSOCIATIVESHIFT };
|
| 131 | 131 |
enum { BLOCKSIZE = 1 << BLOCKSIZESHIFT };
|
| 132 | 132 |
enum { TAGSHIFT = SIZESHIFT - ASSOCIATIVESHIFT };
|
| 133 |
- enum { TAGMASK = static_cast<uint32_t>(~0 << TAGSHIFT) };
|
|
| 134 |
- enum { BLOCKMASK = (static_cast<uint32_t>(~0) >> (32 - TAGSHIFT)) & static_cast<uint32_t>(~0 << BLOCKSIZESHIFT) };
|
|
| 133 |
+ enum { TAGMASK = ~0 << TAGSHIFT };
|
|
| 134 |
+ enum { BLOCKMASK = (~0 >> (32 - TAGSHIFT)) & (~0 << BLOCKSIZESHIFT) };
|
|
| 135 | 135 |
enum { WORDSIZE = sizeof(uint32_t) };
|
| 136 | 136 |
enum { WORDSPERBLOCK = (1 << BLOCKSIZESHIFT) / WORDSIZE };
|
| 137 | 137 |
enum { DATAPERWORD = WORDSIZE * ASSOCIATIVITY };
|
| ... | ... |
@@ -127,7 +127,7 @@ std::unique_ptr<NDS_header> NDS_getROMHeader() |
| 127 | 127 |
memcpy(header->logo, MMU.CART_ROM + 192, 156); |
| 128 | 128 |
header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348); |
| 129 | 129 |
header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350); |
| 130 |
- memcpy(header->reserved, MMU.CART_ROM + 352, std::min(160, static_cast<int>(gameInfo.romsize) - 352)); |
|
| 130 |
+ memcpy(header->reserved, MMU.CART_ROM + 352, std::min<size_t>(160, gameInfo.romsize - 352)); |
|
| 131 | 131 |
|
| 132 | 132 |
return header; |
| 133 | 133 |
} |
| ... | ... |
@@ -298,10 +298,10 @@ struct TSequenceItem_divider : public TSequenceItem |
| 298 | 298 |
T1WriteQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, MMU.divResult); |
| 299 | 299 |
T1WriteQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, MMU.divMod); |
| 300 | 300 |
#else |
| 301 |
- T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, static_cast<uint32_t>(MMU.divResult)); |
|
| 302 |
- T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A4, static_cast<uint32_t>(MMU.divResult >> 32)); |
|
| 303 |
- T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, static_cast<uint32_t>(MMU.divMod)); |
|
| 304 |
- T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2AC, static_cast<uint32_t>(MMU.divMod >> 32)); |
|
| 301 |
+ T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, MMU.divResult & 0xFFFFFFFF); |
|
| 302 |
+ T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A4, (MMU.divResult >> 32) & 0xFFFFFFFF); |
|
| 303 |
+ T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, MMU.divMod & 0xFFFFFFFF); |
|
| 304 |
+ T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2AC, (MMU.divMod >> 32) & 0xFFFFFFFF); |
|
| 305 | 305 |
#endif |
| 306 | 306 |
MMU.divRunning = false; |
| 307 | 307 |
} |
| ... | ... |
@@ -556,10 +556,10 @@ static void execHardware_hstart() |
| 556 | 556 |
} |
| 557 | 557 |
|
| 558 | 558 |
// write the new vcount |
| 559 |
- T1WriteWord(MMU.ARM9_REG, 6, static_cast<uint16_t>(nds.VCount)); |
|
| 560 |
- T1WriteWord(MMU.ARM9_REG, 0x1006, static_cast<uint16_t>(nds.VCount)); |
|
| 561 |
- T1WriteWord(MMU.ARM7_REG, 6, static_cast<uint16_t>(nds.VCount)); |
|
| 562 |
- T1WriteWord(MMU.ARM7_REG, 0x1006, static_cast<uint16_t>(nds.VCount)); |
|
| 559 |
+ T1WriteWord(MMU.ARM9_REG, 6, nds.VCount & 0xFFFF); |
|
| 560 |
+ T1WriteWord(MMU.ARM9_REG, 0x1006, nds.VCount & 0xFFFF); |
|
| 561 |
+ T1WriteWord(MMU.ARM7_REG, 6, nds.VCount & 0xFFFF); |
|
| 562 |
+ T1WriteWord(MMU.ARM7_REG, 0x1006, nds.VCount & 0xFFFF); |
|
| 563 | 563 |
|
| 564 | 564 |
// turn off hblank status bit |
| 565 | 565 |
T1WriteWord(MMU.ARM9_REG, 4, T1ReadWord(MMU.ARM9_REG, 4) & 0xFFFD); |
| ... | ... |
@@ -802,9 +802,9 @@ template<bool FORCE> void NDS_exec(int32_t) |
| 802 | 802 |
|
| 803 | 803 |
// cast these down to 32bits so that things run faster on 32bit procs |
| 804 | 804 |
uint64_t nds_timer_base = nds_timer; |
| 805 |
- int32_t arm9 = static_cast<int32_t>(nds_arm9_timer - nds_timer); |
|
| 806 |
- int32_t arm7 = static_cast<int32_t>(nds_arm7_timer - nds_timer); |
|
| 807 |
- int32_t s32next = static_cast<int32_t>(next - nds_timer); |
|
| 805 |
+ int32_t arm9 = (nds_arm9_timer - nds_timer) & 0xFFFFFFFF; |
|
| 806 |
+ int32_t arm7 = (nds_arm7_timer - nds_timer) & 0xFFFFFFFF; |
|
| 807 |
+ int32_t s32next = (next - nds_timer) & 0xFFFFFFFF; |
|
| 808 | 808 |
|
| 809 | 809 |
#ifdef HAVE_JIT |
| 810 | 810 |
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); |
| ... | ... |
@@ -36,9 +36,9 @@ static const double M_PI = 3.14159265358979323846; |
| 36 | 36 |
#include "NDSSystem.h" |
| 37 | 37 |
#include "matrix.h" |
| 38 | 38 |
|
| 39 |
-static inline int16_t read16(uint32_t addr) { return static_cast<int16_t>(_MMU_read16<ARMCPU_ARM7,MMU_AT_DEBUG>(addr)); }
|
|
| 39 |
+static inline int16_t read16(uint32_t addr) { return _MMU_read16<ARMCPU_ARM7,MMU_AT_DEBUG>(addr); }
|
|
| 40 | 40 |
static inline uint8_t read08(uint32_t addr) { return _MMU_read08<ARMCPU_ARM7,MMU_AT_DEBUG>(addr); }
|
| 41 |
-static inline int8_t read_s8(uint32_t addr) { return static_cast<int8_t>(_MMU_read08<ARMCPU_ARM7,MMU_AT_DEBUG>(addr)); }
|
|
| 41 |
+static inline int8_t read_s8(uint32_t addr) { return _MMU_read08<ARMCPU_ARM7,MMU_AT_DEBUG>(addr); }
|
|
| 42 | 42 |
|
| 43 | 43 |
static const int K_ADPCM_LOOPING_RECOVERY_INDEX = 99999; |
| 44 | 44 |
static const int COSINE_INTERPOLATION_RESOLUTION = 8192; |
| ... | ... |
@@ -172,7 +172,7 @@ int SPU_Init(int coreid, int Buffersize) |
| 172 | 172 |
for (i = 0; i < COSINE_INTERPOLATION_RESOLUTION; ++i) |
| 173 | 173 |
cos_lut[i] = (1.0 - std::cos((static_cast<double>(i) / COSINE_INTERPOLATION_RESOLUTION) * M_PI)) * 0.5; |
| 174 | 174 |
|
| 175 |
- SPU_core.reset(new SPU_struct(static_cast<int>(std::ceil(samples_per_hline)))); |
|
| 175 |
+ SPU_core.reset(new SPU_struct(std::ceil(samples_per_hline))); |
|
| 176 | 176 |
SPU_Reset(); |
| 177 | 177 |
|
| 178 | 178 |
int j; |
| ... | ... |
@@ -350,7 +350,7 @@ void SPU_struct::KeyOn(int channel) |
| 350 | 350 |
thischan.x = 0x7FFF; |
| 351 | 351 |
} |
| 352 | 352 |
|
| 353 |
- thischan.double_totlength_shifted = static_cast<double>(thischan.totlength << format_shift[thischan.format]); |
|
| 353 |
+ thischan.double_totlength_shifted = thischan.totlength << format_shift[thischan.format]; |
|
| 354 | 354 |
|
| 355 | 355 |
if (thischan.format != 3 && fEqual(thischan.double_totlength_shifted, 0.0)) |
| 356 | 356 |
{
|
| ... | ... |
@@ -484,7 +484,7 @@ static GpVar bb_profiler_entry; |
| 484 | 484 |
if (!imm) \ |
| 485 | 485 |
imm = 31; \ |
| 486 | 486 |
c.sar(rhs, imm); \ |
| 487 |
- uint32_t rhs_first = static_cast<int32_t>(cpu->R[REG_POS(i, 0)]) >> imm; |
|
| 487 |
+ uint32_t rhs_first = cpu->R[REG_POS(i, 0)] >> imm; |
|
| 488 | 488 |
|
| 489 | 489 |
#define S_ASR_IMM \ |
| 490 | 490 |
JIT_COMMENT("S_ASR_IMM"); \
|
| ... | ... |
@@ -512,7 +512,7 @@ static GpVar bb_profiler_entry; |
| 512 | 512 |
} \ |
| 513 | 513 |
else \ |
| 514 | 514 |
c.ror(rhs, imm); \ |
| 515 |
- 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); |
|
| 515 |
+ 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); |
|
| 516 | 516 |
|
| 517 | 517 |
#define S_ROR_IMM \ |
| 518 | 518 |
JIT_COMMENT("S_ROR_IMM"); \
|
| ... | ... |
@@ -2136,7 +2136,7 @@ template<int PROCNUM, bool store, int dir, bool null_compiled> static FORCEINLIN |
| 2136 | 2136 |
#ifdef ENABLE_ADVANCED_TIMING |
| 2137 | 2137 |
cycles = 0; |
| 2138 | 2138 |
#endif |
| 2139 |
- uintptr_t *func = reinterpret_cast<uintptr_t *>(&JIT_COMPILED_FUNC(adr, PROCNUM)); |
|
| 2139 |
+ uintptr_t *func = &JIT_COMPILED_FUNC(adr, PROCNUM); |
|
| 2140 | 2140 |
|
| 2141 | 2141 |
#define OP(j) \ |
| 2142 | 2142 |
{ \
|
| ... | ... |
@@ -2247,7 +2247,7 @@ static void call_ldm_stm(GpVar adr, uint32_t bitmask, bool store, int dir) |
| 2247 | 2247 |
// same prototype, but we have to handle splitting of a u64 arg manually |
| 2248 | 2248 |
GpVar regs_lo = c.newGpVar(kX86VarTypeGpd); |
| 2249 | 2249 |
GpVar regs_hi = c.newGpVar(kX86VarTypeGpd); |
| 2250 |
- c.mov(regs_lo, static_cast<uint32_t>(get_reg_list(bitmask, dir))); |
|
| 2250 |
+ c.mov(regs_lo, get_reg_list(bitmask, dir) & 0xFFFFFFFF); |
|
| 2251 | 2251 |
c.mov(regs_hi, get_reg_list(bitmask, dir) >> 32); |
| 2252 | 2252 |
X86CompilerFuncCall *ctx = c.call(reinterpret_cast<void *>(op_ldm_stm_tab[PROCNUM][store][dir > 0])); |
| 2253 | 2253 |
ctx->setPrototype(ASMJIT_CALL_CONV, FuncBuilder4<uint32_t, uint32_t, uint32_t, uint32_t, int>()); |
| ... | ... |
@@ -3685,7 +3685,7 @@ static int OP_B_COND(uint32_t i) |
| 3685 | 3685 |
{
|
| 3686 | 3686 |
Label skip = c.newLabel(); |
| 3687 | 3687 |
|
| 3688 |
- uint32_t dst = bb_r15 + (static_cast<uint32_t>(static_cast<int8_t>(i & 0xFF)) << 1); |
|
| 3688 |
+ uint32_t dst = bb_r15 + ((i & 0xFF) << 1); |
|
| 3689 | 3689 |
|
| 3690 | 3690 |
c.mov(cpu_ptr(instruct_adr), bb_next_instruction); |
| 3691 | 3691 |
|
| ... | ... |
@@ -4149,7 +4149,7 @@ template<int PROCNUM> static uint32_t compile_basicblock() |
| 4149 | 4149 |
#endif |
| 4150 | 4150 |
c.endFunc(); |
| 4151 | 4151 |
|
| 4152 |
- ArmOpCompiled f = reinterpret_cast<ArmOpCompiled>(c.make()); |
|
| 4152 |
+ ArmOpCompiled f = static_cast<ArmOpCompiled>(c.make()); |
|
| 4153 | 4153 |
if(c.getError()) |
| 4154 | 4154 |
{
|
| 4155 | 4155 |
fprintf(stderr, "JIT error: %s\n", getErrorString(c.getError())); |
| ... | ... |
@@ -4247,13 +4247,13 @@ void arm_jit_reset(bool enable) |
| 4247 | 4247 |
#if PROFILER_JIT_LEVEL > 0 |
| 4248 | 4248 |
static int pcmp(PROFILER_COUNTER_INFO *info1, PROFILER_COUNTER_INFO *info2) |
| 4249 | 4249 |
{
|
| 4250 |
- return static_cast<int>(info2->count - info1->count); |
|
| 4250 |
+ return info2->count - info1->count; |
|
| 4251 | 4251 |
} |
| 4252 | 4252 |
|
| 4253 | 4253 |
#if PROFILER_JIT_LEVEL > 1 |
| 4254 | 4254 |
static int pcmp_entry(PROFILER_ENTRY *info1, PROFILER_ENTRY *info2) |
| 4255 | 4255 |
{
|
| 4256 |
- return static_cast<int>(info1->cycles - info2->cycles); |
|
| 4256 |
+ return info1->cycles - info2->cycles; |
|
| 4257 | 4257 |
} |
| 4258 | 4258 |
#endif |
| 4259 | 4259 |
#endif |
| ... | ... |
@@ -281,16 +281,16 @@ TEMPLATE static uint32_t sleep() |
| 281 | 281 |
|
| 282 | 282 |
TEMPLATE static uint32_t divide() |
| 283 | 283 |
{
|
| 284 |
- int32_t num = static_cast<int32_t>(cpu->R[0]); |
|
| 285 |
- int32_t dnum = static_cast<int32_t>(cpu->R[1]); |
|
| 284 |
+ int32_t num = cpu->R[0]; |
|
| 285 |
+ int32_t dnum = cpu->R[1]; |
|
| 286 | 286 |
|
| 287 | 287 |
if (!dnum) |
| 288 | 288 |
return 0; |
| 289 | 289 |
|
| 290 | 290 |
int32_t res = num / dnum; |
| 291 |
- cpu->R[0] = static_cast<uint32_t>(res); |
|
| 292 |
- cpu->R[1] = static_cast<uint32_t>(num % dnum); |
|
| 293 |
- cpu->R[3] = static_cast<uint32_t>(std::abs(res)); |
|
| 291 |
+ cpu->R[0] = res; |
|
| 292 |
+ cpu->R[1] = num % dnum; |
|
| 293 |
+ cpu->R[3] = std::abs(res); |
|
| 294 | 294 |
|
| 295 | 295 |
return 6; |
| 296 | 296 |
} |
| ... | ... |
@@ -324,7 +324,7 @@ TEMPLATE static uint32_t copy() |
| 324 | 324 |
cnt &= 0x1FFFFF; |
| 325 | 325 |
while (cnt) |
| 326 | 326 |
{
|
| 327 |
- _MMU_write16<PROCNUM>(dst, static_cast<uint16_t>(val)); |
|
| 327 |
+ _MMU_write16<PROCNUM>(dst, val); |
|
| 328 | 328 |
--cnt; |
| 329 | 329 |
dst += 2; |
| 330 | 330 |
} |
| ... | ... |
@@ -439,7 +439,7 @@ TEMPLATE static uint32_t LZ77UnCompVram() |
| 439 | 439 |
|
| 440 | 440 |
if (byteCount == 2) |
| 441 | 441 |
{
|
| 442 |
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue)); |
|
| 442 |
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF); |
|
| 443 | 443 |
dest += 2; |
| 444 | 444 |
byteCount = 0; |
| 445 | 445 |
byteShift = 0; |
| ... | ... |
@@ -457,7 +457,7 @@ TEMPLATE static uint32_t LZ77UnCompVram() |
| 457 | 457 |
++byteCount; |
| 458 | 458 |
if (byteCount == 2) |
| 459 | 459 |
{
|
| 460 |
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue)); |
|
| 460 |
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF); |
|
| 461 | 461 |
dest += 2; |
| 462 | 462 |
byteCount = 0; |
| 463 | 463 |
byteShift = 0; |
| ... | ... |
@@ -479,7 +479,7 @@ TEMPLATE static uint32_t LZ77UnCompVram() |
| 479 | 479 |
++byteCount; |
| 480 | 480 |
if (byteCount == 2) |
| 481 | 481 |
{
|
| 482 |
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue)); |
|
| 482 |
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF); |
|
| 483 | 483 |
dest += 2; |
| 484 | 484 |
byteShift = 0; |
| 485 | 485 |
byteCount = 0; |
| ... | ... |
@@ -587,7 +587,7 @@ TEMPLATE static uint32_t RLUnCompVram() |
| 587 | 587 |
|
| 588 | 588 |
if (byteCount == 2) |
| 589 | 589 |
{
|
| 590 |
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue)); |
|
| 590 |
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF); |
|
| 591 | 591 |
dest += 2; |
| 592 | 592 |
byteCount = 0; |
| 593 | 593 |
byteShift = 0; |
| ... | ... |
@@ -609,7 +609,7 @@ TEMPLATE static uint32_t RLUnCompVram() |
| 609 | 609 |
|
| 610 | 610 |
if (byteCount == 2) |
| 611 | 611 |
{
|
| 612 |
- _MMU_write16<PROCNUM>(dest, static_cast<uint16_t>(writeValue)); |
|
| 612 |
+ _MMU_write16<PROCNUM>(dest, writeValue & 0xFFFF); |
|
| 613 | 613 |
dest += 2; |
| 614 | 614 |
byteCount = 0; |
| 615 | 615 |
byteShift = 0; |
| ... | ... |
@@ -738,7 +738,7 @@ TEMPLATE static uint32_t UnCompHuffman() |
| 738 | 738 |
{
|
| 739 | 739 |
byteCount = 0; |
| 740 | 740 |
byteShift = 0; |
| 741 |
- _MMU_write08<PROCNUM>(dest, static_cast<uint8_t>(writeValue)); |
|
| 741 |
+ _MMU_write08<PROCNUM>(dest, writeValue & 0xFF); |
|
| 742 | 742 |
writeValue = 0; |
| 743 | 743 |
dest += 4; |
| 744 | 744 |
len -= 4; |
| ... | ... |
@@ -801,7 +801,7 @@ TEMPLATE static uint32_t UnCompHuffman() |
| 801 | 801 |
{
|
| 802 | 802 |
byteCount = 0; |
| 803 | 803 |
byteShift = 0; |
| 804 |
- _MMU_write08<PROCNUM>(dest, static_cast<uint8_t>(writeValue)); |
|
| 804 |
+ _MMU_write08<PROCNUM>(dest, writeValue & 0xFF); |
|
| 805 | 805 |
dest += 4; |
| 806 | 806 |
writeValue = 0; |
| 807 | 807 |
len -= 4; |
| ... | ... |
@@ -959,7 +959,7 @@ TEMPLATE static uint32_t bios_sqrt() |
| 959 | 959 |
|
| 960 | 960 |
TEMPLATE static uint32_t setHaltCR() |
| 961 | 961 |
{
|
| 962 |
- _MMU_write08<PROCNUM>(0x4000300+cpu->proc_ID, static_cast<uint8_t>(cpu->R[0])); |
|
| 962 |
+ _MMU_write08<PROCNUM>(0x4000300+cpu->proc_ID, cpu->R[0] & 0xFF); |
|
| 963 | 963 |
return 1; |
| 964 | 964 |
} |
| 965 | 965 |
|
| ... | ... |
@@ -1010,7 +1010,7 @@ TEMPLATE static uint32_t getCRC16() |
| 1010 | 1010 |
// if this implementation is wrong, then it won't match what the real bios returns, |
| 1011 | 1011 |
// and savefiles created with a bios will be invalid when loaded with non-bios (and vice-versa) |
| 1012 | 1012 |
|
| 1013 |
- uint16_t crc = static_cast<uint16_t>(cpu->R[0]); |
|
| 1013 |
+ uint16_t crc = cpu->R[0] & 0xFFFF; |
|
| 1014 | 1014 |
uint32_t datap = cpu->R[1]; |
| 1015 | 1015 |
uint32_t size = cpu->R[2] >> 1; |
| 1016 | 1016 |
uint16_t currVal = 0; |
| ... | ... |
@@ -384,7 +384,7 @@ bool armcp15_t::moveARM2CP(uint32_t val, uint8_t CRn, uint8_t CRm, uint8_t opcod |
| 384 | 384 |
{
|
| 385 | 385 |
// On the NDS bit0,2,7,12..19 are R/W, Bit3..6 are always set, all other bits are always zero. |
| 386 | 386 |
this->ctrl = (val & 0x000FF085) | 0x00000078; |
| 387 |
- MMU.ARM9_RW_MODE = static_cast<uint8_t>(BIT7(val)); |
|
| 387 |
+ MMU.ARM9_RW_MODE = BIT7(val); |
|
| 388 | 388 |
// zero 31-jan-2010: change from 0x0FFF0000 to 0xFFFF0000 per gbatek |
| 389 | 389 |
this->cpu->intVector = 0xFFFF0000 * BIT13(val); |
| 390 | 390 |
this->cpu->LDTBit = !BIT15(val); // TBit |
| ... | ... |
@@ -90,7 +90,7 @@ protected: |
| 90 | 90 |
this->vec->resize(amt); |
| 91 | 91 |
} |
| 92 | 92 |
public: |
| 93 |
- EMUFILE_MEMORY(std::vector<uint8_t> *underlying) : vec(underlying), ownvec(false), pos(0), len(static_cast<int32_t>(underlying->size())) { }
|
|
| 93 |
+ EMUFILE_MEMORY(std::vector<uint8_t> *underlying) : vec(underlying), ownvec(false), pos(0), len(underlying->size()) { }
|
|
| 94 | 94 |
EMUFILE_MEMORY(uint32_t preallocate) : vec(new std::vector<uint8_t>()), ownvec(true), pos(0), len(0) |
| 95 | 95 |
{
|
| 96 | 96 |
this->vec->resize(preallocate); |
| ... | ... |
@@ -196,7 +196,7 @@ public: |
| 196 | 196 |
|
| 197 | 197 |
virtual size_t ftell() |
| 198 | 198 |
{
|
| 199 |
- return static_cast<size_t>(::ftell(this->fp)); |
|
| 199 |
+ return ::ftell(this->fp); |
|
| 200 | 200 |
} |
| 201 | 201 |
|
| 202 | 202 |
virtual size_t size() |
| ... | ... |
@@ -18,7 +18,7 @@ |
| 18 | 18 |
#ifndef _INSTRUCIONS_H_ |
| 19 | 19 |
#define _INSTRUCIONS_H_ |
| 20 | 20 |
|
| 21 |
-typedef uint32_t (FASTCALL *OpFunc)(const uint32_t i); |
|
| 21 |
+typedef uint32_t (FASTCALL *OpFunc)(uint32_t i); |
|
| 22 | 22 |
extern const OpFunc arm_instructions_set[2][4096]; |
| 23 | 23 |
extern const char* arm_instruction_names[4096]; |
| 24 | 24 |
extern const OpFunc thumb_instructions_set[2][1024]; |
| ... | ... |
@@ -284,7 +284,7 @@ void BackupDevice::reset() |
| 284 | 284 |
this->state = RUNNING; |
| 285 | 285 |
int savetype = save_types[CommonSettings.manualBackupType].media_type; |
| 286 | 286 |
int savesize = save_types[CommonSettings.manualBackupType].size; |
| 287 |
- this->ensure(static_cast<uint32_t>(savesize)); // expand properly if necessary |
|
| 287 |
+ this->ensure(savesize); // expand properly if necessary |
|
| 288 | 288 |
this->resize(savesize); // truncate if necessary |
| 289 | 289 |
this->addr_size = this->addr_size_for_old_save_type(savetype); |
| 290 | 290 |
} |
| ... | ... |
@@ -356,12 +356,12 @@ void BackupDevice::load_old_state(uint32_t addrSize, uint8_t *Data, uint32_t dat |
| 356 | 356 |
// ======================================================================= |
| 357 | 357 |
// ======================================================================= |
| 358 | 358 |
|
| 359 |
-static int no_gba_unpackSAV(void *in_buf, uint32_t fsize, void *out_buf, uint32_t &size) |
|
| 359 |
+static int no_gba_unpackSAV(const uint8_t *in_buf, uint32_t fsize, uint8_t *out_buf, uint32_t &size) |
|
| 360 | 360 |
{
|
| 361 | 361 |
const char no_GBA_HEADER_ID[] = "NocashGbaBackupMediaSavDataFile"; |
| 362 | 362 |
const char no_GBA_HEADER_SRAM_ID[] = "SRAM"; |
| 363 |
- uint8_t *src = static_cast<uint8_t *>(in_buf); |
|
| 364 |
- uint8_t *dst = static_cast<uint8_t *>(out_buf); |
|
| 363 |
+ const uint8_t *src = in_buf; |
|
| 364 |
+ uint8_t *dst = out_buf; |
|
| 365 | 365 |
uint32_t src_pos = 0; |
| 366 | 366 |
uint32_t dst_pos = 0; |
| 367 | 367 |
uint32_t size_unpacked = 0; |
| ... | ... |
@@ -379,11 +379,11 @@ static int no_gba_unpackSAV(void *in_buf, uint32_t fsize, void *out_buf, uint32_ |
| 379 | 379 |
if (src[i + 0x40] != no_GBA_HEADER_SRAM_ID[i]) |
| 380 | 380 |
return 2; |
| 381 | 381 |
|
| 382 |
- compressMethod = *(reinterpret_cast<uint32_t *>(src + 0x44)); |
|
| 382 |
+ compressMethod = *(reinterpret_cast<const uint32_t *>(src + 0x44)); |
|
| 383 | 383 |
|
| 384 | 384 |
if (!compressMethod) // unpacked |
| 385 | 385 |
{
|
| 386 |
- size_unpacked = *(reinterpret_cast<uint32_t *>(src + 0x48)); |
|
| 386 |
+ size_unpacked = *(reinterpret_cast<const uint32_t *>(src + 0x48)); |
|
| 387 | 387 |
src_pos = 0x4C; |
| 388 | 388 |
for (uint32_t i = 0; i < size_unpacked; ++i) |
| 389 | 389 |
dst[dst_pos++] = src[src_pos++]; |
| ... | ... |
@@ -393,7 +393,7 @@ static int no_gba_unpackSAV(void *in_buf, uint32_t fsize, void *out_buf, uint32_ |
| 393 | 393 |
|
| 394 | 394 |
if (compressMethod == 1) // packed (method 1) |
| 395 | 395 |
{
|
| 396 |
- size_unpacked = *(reinterpret_cast<uint32_t *>(src + 0x4C)); |
|
| 396 |
+ size_unpacked = *(reinterpret_cast<const uint32_t *>(src + 0x4C)); |
|
| 397 | 397 |
|
| 398 | 398 |
src_pos = 0x50; |
| 399 | 399 |
while (true) |
| ... | ... |
@@ -408,7 +408,7 @@ static int no_gba_unpackSAV(void *in_buf, uint32_t fsize, void *out_buf, uint32_ |
| 408 | 408 |
|
| 409 | 409 |
if (cc == 0x80) |
| 410 | 410 |
{
|
| 411 |
- uint16_t tsize = *(reinterpret_cast<uint16_t *>(src + src_pos + 1)); |
|
| 411 |
+ uint16_t tsize = *(reinterpret_cast<const uint16_t *>(src + src_pos + 1)); |
|
| 412 | 412 |
for (int t = 0; t < tsize; ++t) |
| 413 | 413 |
dst[dst_pos++] = src[src_pos]; |
| 414 | 414 |
src_pos += 3; |
| ... | ... |
@@ -433,11 +433,11 @@ static int no_gba_unpackSAV(void *in_buf, uint32_t fsize, void *out_buf, uint32_ |
| 433 | 433 |
return 200; |
| 434 | 434 |
} |
| 435 | 435 |
|
| 436 |
-static uint32_t no_gba_savTrim(void *buf, uint32_t size) |
|
| 436 |
+static uint32_t no_gba_savTrim(uint8_t *buf, uint32_t size) |
|
| 437 | 437 |
{
|
| 438 | 438 |
uint32_t rows = size / 16; |
| 439 | 439 |
uint32_t pos = (size - 16); |
| 440 |
- uint8_t *src = static_cast<uint8_t *>(buf); |
|
| 440 |
+ uint8_t *src = buf; |
|
| 441 | 441 |
|
| 442 | 442 |
for (unsigned i = 0; i < rows; ++i, pos -= 16) |
| 443 | 443 |
{
|
| ... | ... |
@@ -539,7 +539,7 @@ void BackupDevice::loadfile() |
| 539 | 539 |
else |
| 540 | 540 |
{
|
| 541 | 541 |
// scan for desmume save footer |
| 542 |
- int32_t cookieLen = static_cast<int32_t>(strlen(kDesmumeSaveCookie)); |
|
| 542 |
+ int32_t cookieLen = strlen(kDesmumeSaveCookie); |
|
| 543 | 543 |
auto sigbuf = std::unique_ptr<char[]>(new char[cookieLen]); |
| 544 | 544 |
inf->fseek(-cookieLen, SEEK_END); |
| 545 | 545 |
inf->fread(&sigbuf[0], cookieLen); |
| ... | ... |
@@ -610,7 +610,7 @@ bool BackupDevice::load_raw(const char *fn, uint32_t force_size) |
| 610 | 610 |
return false; |
| 611 | 611 |
|
| 612 | 612 |
fseek(inf, 0, SEEK_END); |
| 613 |
- uint32_t size = static_cast<uint32_t>(ftell(inf)); |
|
| 613 |
+ uint32_t size = ftell(inf); |
|
| 614 | 614 |
uint32_t left = 0; |
| 615 | 615 |
|
| 616 | 616 |
if (force_size > 0) |
| ... | ... |
@@ -43,7 +43,7 @@ inline uint16_t T1ReadWord_guaranteedAligned(const uint8_t *const mem, uint32_t |
| 43 | 43 |
{
|
| 44 | 44 |
assert(!(addr & 1)); |
| 45 | 45 |
#ifdef WORDS_BIGENDIAN |
| 46 |
- return (static_cast<uint8_t *>(mem)[addr + 1] << 8) | static_cast<uint8_t *>(mem)[addr]; |
|
| 46 |
+ return (mem[addr + 1] << 8) | mem[addr]; |
|
| 47 | 47 |
#else |
| 48 | 48 |
return *reinterpret_cast<const uint16_t *>(mem + addr); |
| 49 | 49 |
#endif |
| ... | ... |
@@ -52,7 +52,7 @@ inline uint16_t T1ReadWord_guaranteedAligned(const uint8_t *const mem, uint32_t |
| 52 | 52 |
inline uint16_t T1ReadWord(const uint8_t *const mem, uint32_t addr) |
| 53 | 53 |
{
|
| 54 | 54 |
#ifdef WORDS_BIGENDIAN |
| 55 |
- return (static_cast<uint8_t *>(mem)[addr + 1] << 8) | static_cast<uint8_t *>(mem)[addr]; |
|
| 55 |
+ return (mem[addr + 1] << 8) | mem[addr]; |
|
| 56 | 56 |
#else |
| 57 | 57 |
return *reinterpret_cast<const uint16_t *>(mem + addr); |
| 58 | 58 |
#endif |
| ... | ... |
@@ -62,7 +62,7 @@ inline uint32_t T1ReadLong_guaranteedAligned(const uint8_t *const mem, uint32_t |
| 62 | 62 |
{
|
| 63 | 63 |
assert(!(addr & 3)); |
| 64 | 64 |
#ifdef WORDS_BIGENDIAN |
| 65 |
- return mem[addr + 3] << 24 | mem[addr + 2] << 16 | mem[addr + 1] << 8 | mem[addr]; |
|
| 65 |
+ return (mem[addr + 3] << 24) | (mem[addr + 2] << 16) | (mem[addr + 1] << 8) | mem[addr]; |
|
| 66 | 66 |
#else |
| 67 | 67 |
return *reinterpret_cast<const uint32_t *>(mem + addr); |
| 68 | 68 |
#endif |
| ... | ... |
@@ -72,7 +72,7 @@ inline uint32_t T1ReadLong(const uint8_t *const mem, uint32_t addr) |
| 72 | 72 |
{
|
| 73 | 73 |
addr &= ~3; |
| 74 | 74 |
#ifdef WORDS_BIGENDIAN |
| 75 |
- return mem[addr + 3] << 24 | mem[addr + 2] << 16 | mem[addr + 1] << 8 | mem[addr]; |
|
| 75 |
+ return (mem[addr + 3] << 24) | (mem[addr + 2] << 16) | (mem[addr + 1] << 8) | mem[addr]; |
|
| 76 | 76 |
#else |
| 77 | 77 |
return *reinterpret_cast<const uint32_t *>(mem + addr); |
| 78 | 78 |
#endif |
| ... | ... |
@@ -81,8 +81,7 @@ inline uint32_t T1ReadLong(const uint8_t *const mem, uint32_t addr) |
| 81 | 81 |
inline uint64_t T1ReadQuad(const uint8_t *const mem, uint32_t addr) |
| 82 | 82 |
{
|
| 83 | 83 |
#ifdef WORDS_BIGENDIAN |
| 84 |
- 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 | |
|
| 85 |
- uint64_t(mem[addr + 3]) << 24 | uint64_t(mem[addr + 2]) << 16 | uint64_t(mem[addr + 1]) << 8 | uint64_t(mem[addr]); |
|
| 84 |
+ 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]; |
|
| 86 | 85 |
#else |
| 87 | 86 |
return *reinterpret_cast<const uint64_t *>(mem + addr); |
| 88 | 87 |
#endif |
| ... | ... |
@@ -118,7 +117,7 @@ inline void T1WriteLong(uint8_t *const mem, uint32_t addr, uint32_t val) |
| 118 | 117 |
inline void T1WriteQuad(uint8_t *const mem, uint32_t addr, uint64_t val) |
| 119 | 118 |
{
|
| 120 | 119 |
#ifdef WORDS_BIGENDIAN |
| 121 |
- mem[addr + 7] = (val >> 56); |
|
| 120 |
+ mem[addr + 7] = val >> 56; |
|
| 122 | 121 |
mem[addr + 6] = (val >> 48) & 0xFF; |
| 123 | 122 |
mem[addr + 5] = (val >> 40) & 0xFF; |
| 124 | 123 |
mem[addr + 4] = (val >> 32) & 0xFF; |
| ... | ... |
@@ -36,7 +36,7 @@ StereoOut32::StereoOut32(const StereoOutFloat &src) : Left(static_cast<int32_t>( |
| 36 | 36 |
|
| 37 | 37 |
StereoOut16 StereoOut32::DownSample() const |
| 38 | 38 |
{
|
| 39 |
- return StereoOut16(static_cast<int16_t>(Left >> SndOutVolumeShift), static_cast<int16_t>(Right >> SndOutVolumeShift)); |
|
| 39 |
+ return StereoOut16((Left >> SndOutVolumeShift) & 0xFFFF, (Right >> SndOutVolumeShift) & 0xFFFF); |
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
std::unique_ptr<StereoOut32[]> SndBuffer::m_buffer; |
| ... | ... |
@@ -83,7 +83,7 @@ struct StereoOut16 |
| 83 | 83 |
{
|
| 84 | 84 |
} |
| 85 | 85 |
|
| 86 |
- StereoOut16(const StereoOut32 &src) : Left(static_cast<int16_t>(src.Left)), Right(static_cast<int16_t>(src.Right)) |
|
| 86 |
+ StereoOut16(const StereoOut32 &src) : Left(src.Left & 0xFFFF), Right(src.Right & 0xFFFF) |
|
| 87 | 87 |
{
|
| 88 | 88 |
} |
| 89 | 89 |
|
| ... | ... |
@@ -58,7 +58,7 @@ FIFOSampleBuffer::FIFOSampleBuffer(int32_t numChannels) |
| 58 | 58 |
this->bufferUnaligned.reset(); |
| 59 | 59 |
this->samplesInBuffer = 0; |
| 60 | 60 |
this->bufferPos = 0; |
| 61 |
- this->channels = static_cast<uint32_t>(numChannels); |
|
| 61 |
+ this->channels = numChannels; |
|
| 62 | 62 |
this->ensureCapacity(32); // allocate initial capacity |
| 63 | 63 |
} |
| 64 | 64 |
|
| ... | ... |
@@ -72,7 +72,7 @@ void FIFOSampleBuffer::setChannels(int32_t numChannels) |
| 72 | 72 |
{
|
| 73 | 73 |
assert(numChannels > 0); |
| 74 | 74 |
uint32_t usedBytes = this->channels * this->samplesInBuffer; |
| 75 |
- this->channels = static_cast<uint32_t>(numChannels); |
|
| 75 |
+ this->channels = numChannels; |
|
| 76 | 76 |
this->samplesInBuffer = usedBytes / this->channels; |
| 77 | 77 |
} |
| 78 | 78 |
|
| ... | ... |
@@ -159,7 +159,7 @@ void FIRFilter::setCoefficients(const SAMPLETYPE *coeffs, uint32_t newLength, ui |
| 159 | 159 |
assert(this->length == newLength); |
| 160 | 160 |
|
| 161 | 161 |
this->resultDivFactor = uResultDivFactor; |
| 162 |
- this->resultDivider = static_cast<SAMPLETYPE>(std::pow(2.0, static_cast<double>(resultDivFactor))); |
|
| 162 |
+ this->resultDivider = static_cast<SAMPLETYPE>(std::pow(2.0, static_cast<double>(this->resultDivFactor))); |
|
| 163 | 163 |
|
| 164 | 164 |
this->filterCoeffs.reset(new SAMPLETYPE[this->length]); |
| 165 | 165 |
memcpy(this->filterCoeffs.get(), coeffs, this->length * sizeof(SAMPLETYPE)); |
| ... | ... |
@@ -325,7 +325,7 @@ uint32_t RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE |
| 325 | 325 |
LONG_SAMPLETYPE temp, vol1; |
| 326 | 326 |
while (this->iSlopeCount <= SCALE) |
| 327 | 327 |
{
|
| 328 |
- vol1 = static_cast<LONG_SAMPLETYPE>(SCALE - this->iSlopeCount); |
|
| 328 |
+ vol1 = SCALE - this->iSlopeCount; |
|
| 329 | 329 |
temp = vol1 * this->sPrevSampleL + this->iSlopeCount * src[0]; |
| 330 | 330 |
dest[i] = static_cast<SAMPLETYPE>(temp / SCALE); |
| 331 | 331 |
++i; |
| ... | ... |
@@ -343,7 +343,7 @@ uint32_t RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE |
| 343 | 343 |
if (used >= nSamples - 1) |
| 344 | 344 |
goto end; |
| 345 | 345 |
} |
| 346 |
- vol1 = static_cast<LONG_SAMPLETYPE>(SCALE - this->iSlopeCount); |
|
| 346 |
+ vol1 = SCALE - this->iSlopeCount; |
|
| 347 | 347 |
temp = src[used] * vol1 + this->iSlopeCount * src[used + 1]; |
| 348 | 348 |
dest[i] = static_cast<SAMPLETYPE>(temp / SCALE); |
| 349 | 349 |
++i; |
| ... | ... |
@@ -370,7 +370,7 @@ uint32_t RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETY |
| 370 | 370 |
LONG_SAMPLETYPE temp, vol1; |
| 371 | 371 |
while (this->iSlopeCount <= SCALE) |
| 372 | 372 |
{
|
| 373 |
- vol1 = static_cast<LONG_SAMPLETYPE>(SCALE - this->iSlopeCount); |
|
| 373 |
+ vol1 = SCALE - this->iSlopeCount; |
|
| 374 | 374 |
temp = vol1 * this->sPrevSampleL + this->iSlopeCount * src[0]; |
| 375 | 375 |
dest[2 * i] = static_cast<SAMPLETYPE>(temp / SCALE); |
| 376 | 376 |
temp = vol1 * this->sPrevSampleR + this->iSlopeCount * src[1]; |
| ... | ... |
@@ -391,7 +391,7 @@ uint32_t RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETY |
| 391 | 391 |
goto end; |
| 392 | 392 |
} |
| 393 | 393 |
unsigned srcPos = 2 * used; |
| 394 |
- vol1 = static_cast<LONG_SAMPLETYPE>(SCALE - this->iSlopeCount); |
|
| 394 |
+ vol1 = SCALE - this->iSlopeCount; |
|
| 395 | 395 |
temp = src[srcPos] * vol1 + this->iSlopeCount * src[srcPos + 2]; |
| 396 | 396 |
dest[2 * i] = static_cast<SAMPLETYPE>(temp / SCALE); |
| 397 | 397 |
temp = src[srcPos + 1] * vol1 + this->iSlopeCount * src[srcPos + 3]; |
| ... | ... |
@@ -112,8 +112,8 @@ void SoundTouch::setChannels(uint32_t numChannels) |
| 112 | 112 |
if (numChannels != 1 && numChannels != 2) |
| 113 | 113 |
throw std::runtime_error("Illegal number of channels");
|
| 114 | 114 |
this->channels = numChannels; |
| 115 |
- this->pRateTransposer->setChannels(static_cast<int32_t>(numChannels)); |
|
| 116 |
- this->pTDStretch->setChannels(static_cast<int32_t>(numChannels)); |
|
| 115 |
+ this->pRateTransposer->setChannels(numChannels); |
|
| 116 |
+ this->pTDStretch->setChannels(numChannels); |
|
| 117 | 117 |
} |
| 118 | 118 |
|
| 119 | 119 |
// Sets new rate control value. Normal rate = 1.0, smaller values |
| ... | ... |
@@ -230,7 +230,7 @@ void SoundTouch::setSampleRate(uint32_t srate) |
| 230 | 230 |
{
|
| 231 | 231 |
this->bSrateSet = true; |
| 232 | 232 |
// set sample rate, leave other tempo changer parameters as they are. |
| 233 |
- this->pTDStretch->setParameters(static_cast<int32_t>(srate)); |
|
| 233 |
+ this->pTDStretch->setParameters(srate); |
|
| 234 | 234 |
} |
| 235 | 235 |
|
| 236 | 236 |
// Adds 'numSamples' pcs of samples from the 'samples' memory position into |
| ... | ... |
@@ -300,7 +300,7 @@ void SoundTouch::flush() |
| 300 | 300 |
for (int i = 0; i < 128; ++i) |
| 301 | 301 |
{
|
| 302 | 302 |
this->putSamples(buff, 64); |
| 303 |
- if (static_cast<int32_t>(numSamples()) >= nOut) |
|
| 303 |
+ if (static_cast<int32_t>(this->numSamples()) >= nOut) |
|
| 304 | 304 |
{
|
| 305 | 305 |
// Enough new samples have appeared into the output! |
| 306 | 306 |
// As samples come from processing with bigger chunks, now truncate it |
| ... | ... |
@@ -167,7 +167,7 @@ void TDStretch::getParameters(int32_t *pSampleRate, int32_t *pSequenceMs, int32_ |
| 167 | 167 |
// Overlaps samples in 'midBuffer' with the samples in 'pInput' |
| 168 | 168 |
void TDStretch::overlapMono(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput) const |
| 169 | 169 |
{
|
| 170 |
- SAMPLETYPE m1 = static_cast<SAMPLETYPE>(0); |
|
| 170 |
+ SAMPLETYPE m1 = 0; |
|
| 171 | 171 |
SAMPLETYPE m2 = static_cast<SAMPLETYPE>(this->overlapLength); |
| 172 | 172 |
|
| 173 | 173 |
for (int32_t i = 0; i < this->overlapLength; ++i) |
| ... | ... |
@@ -249,7 +249,7 @@ int32_t TDStretch::seekBestOverlapPositionFull(const SAMPLETYPE *refPos) |
| 249 | 249 |
// to 'i' |
| 250 | 250 |
double corr = this->calcCrossCorr(refPos + this->channels * i, this->pMidBuffer); |
| 251 | 251 |
// heuristic rule to slightly favour values close to mid of the range |
| 252 |
- double tmp = static_cast<double>(2 * i - this->seekLength) / this->seekLength; |
|
| 252 |
+ double tmp = (2.0 * i - this->seekLength) / this->seekLength; |
|
| 253 | 253 |
corr = (corr + 0.1) * (1.0 - 0.25 * tmp * tmp); |
| 254 | 254 |
|
| 255 | 255 |
// Checks for the highest correlation value |
| ... | ... |
@@ -293,9 +293,9 @@ int32_t TDStretch::seekBestOverlapPositionQuick(const SAMPLETYPE *refPos) |
| 293 | 293 |
|
| 294 | 294 |
// Calculates correlation value for the mixing position corresponding |
| 295 | 295 |
// to 'tempOffset' |
| 296 |
- double corr = static_cast<double>(this->calcCrossCorr(refPos + this->channels * tempOffset, this->pMidBuffer)); |
|
| 296 |
+ double corr = this->calcCrossCorr(refPos + this->channels * tempOffset, this->pMidBuffer); |
|
| 297 | 297 |
// heuristic rule to slightly favour values close to mid of the range |
| 298 |
- double tmp = static_cast<double>(2 * tempOffset - this->seekLength) / seekLength; |
|
| 298 |
+ double tmp = (2.0 * tempOffset - this->seekLength) / seekLength; |
|
| 299 | 299 |
corr = (corr + 0.1) * (1.0 - 0.25 * tmp * tmp); |
| 300 | 300 |
|
| 301 | 301 |
// Checks for the highest correlation value |
| ... | ... |
@@ -419,8 +419,8 @@ void TDStretch::processSamples() |
| 419 | 419 |
// samples in 'midBuffer' using sliding overlapping |
| 420 | 420 |
// ... first partially overlap with the end of the previous sequence |
| 421 | 421 |
// (that's in 'midBuffer') |
| 422 |
- this->overlap(this->outputBuffer.ptrEnd(static_cast<uint32_t>(this->overlapLength)), this->inputBuffer.ptrBegin(), static_cast<uint32_t>(offset)); |
|
| 423 |
- this->outputBuffer.putSamples(static_cast<uint32_t>(this->overlapLength)); |
|
| 422 |
+ this->overlap(this->outputBuffer.ptrEnd(this->overlapLength), this->inputBuffer.ptrBegin(), offset); |
|
| 423 |
+ this->outputBuffer.putSamples(this->overlapLength); |
|
| 424 | 424 |
|
| 425 | 425 |
// ... then copy sequence samples from 'inputBuffer' to output: |
| 426 | 426 |
|
| ... | ... |
@@ -431,12 +431,12 @@ void TDStretch::processSamples() |
| 431 | 431 |
if (static_cast<int32_t>(inputBuffer.numSamples()) < offset + temp + this->overlapLength * 2) |
| 432 | 432 |
continue; // just in case, shouldn't really happen |
| 433 | 433 |
|
| 434 |
- this->outputBuffer.putSamples(this->inputBuffer.ptrBegin() + this->channels * (offset + this->overlapLength), static_cast<uint32_t>(temp)); |
|
| 434 |
+ this->outputBuffer.putSamples(this->inputBuffer.ptrBegin() + this->channels * (offset + this->overlapLength), temp); |
|
| 435 | 435 |
|
| 436 | 436 |
// Copies the end of the current sequence from 'inputBuffer' to |
| 437 | 437 |
// 'midBuffer' for being mixed with the beginning of the next |
| 438 | 438 |
// processing sequence and so on |
| 439 |
- assert(offset + temp + this->overlapLength * 2 <= static_cast<int>(this->inputBuffer.numSamples())); |
|
| 439 |
+ assert(offset + temp + this->overlapLength * 2 <= static_cast<int32_t>(this->inputBuffer.numSamples())); |
|
| 440 | 440 |
memcpy(this->pMidBuffer, this->inputBuffer.ptrBegin() + this->channels * (offset + this->seekWindowLength - this->overlapLength), this->channels * sizeof(SAMPLETYPE) * this->overlapLength); |
| 441 | 441 |
|
| 442 | 442 |
// Remove the processed samples from the input buffer. Update |
| ... | ... |
@@ -445,7 +445,7 @@ void TDStretch::processSamples() |
| 445 | 445 |
this->skipFract += this->nominalSkip; // real skip size |
| 446 | 446 |
int ovlSkip = static_cast<int>(skipFract); // rounded to integer skip |
| 447 | 447 |
this->skipFract -= ovlSkip; // maintain the fraction part, i.e. real vs. integer skip |
| 448 |
- this->inputBuffer.receiveSamples(static_cast<uint32_t>(ovlSkip)); |
|
| 448 |
+ this->inputBuffer.receiveSamples(ovlSkip); |
|
| 449 | 449 |
} |
| 450 | 450 |
} |
| 451 | 451 |
|
| ... | ... |
@@ -522,7 +522,7 @@ void TDStretch::overlapStereo(short *poutput, const short *pinput) const |
| 522 | 522 |
{
|
| 523 | 523 |
for (int32_t i = 0; i < this->overlapLength; ++i) |
| 524 | 524 |
{
|
| 525 |
- short temp = static_cast<short>(this->overlapLength - i); |
|
| 525 |
+ short temp = this->overlapLength - i; |
|
| 526 | 526 |
int32_t cnt2 = 2 * i; |
| 527 | 527 |
poutput[cnt2] = (pinput[cnt2] * i + this->pMidBuffer[cnt2] * temp) / this->overlapLength; |
| 528 | 528 |
poutput[cnt2 + 1] = (pinput[cnt2 + 1] * i + this->pMidBuffer[cnt2 + 1] * temp) / this->overlapLength; |
| ... | ... |
@@ -550,7 +550,7 @@ void TDStretch::calculateOverlapLength(int32_t aoverlapMs) |
| 550 | 550 |
this->overlapDividerBits = 9; |
| 551 | 551 |
if (this->overlapDividerBits < 3) |
| 552 | 552 |
this->overlapDividerBits = 3; |
| 553 |
- int32_t newOvl = static_cast<int>std::pow(2, static_cast<int>(this->overlapDividerBits) + 1); // +1 => account for -1 above |
|
| 553 |
+ int32_t newOvl = static_cast<int32_t>(std::pow(2, this->overlapDividerBits + 1)); // +1 => account for -1 above |
|
| 554 | 554 |
|
| 555 | 555 |
this->acceptNewOverlapLength(newOvl); |
| 556 | 556 |
|
| ... | ... |
@@ -140,7 +140,7 @@ double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2) const |
| 140 | 140 |
norm = 1.0; // to avoid div by zero |
| 141 | 141 |
|
| 142 | 142 |
float *pvSum = reinterpret_cast<float *>(&vSum); |
| 143 |
- return static_cast<double>(pvSum[0] + pvSum[1] + pvSum[2] + pvSum[3]) / norm; |
|
| 143 |
+ return (pvSum[0] + pvSum[1] + pvSum[2] + pvSum[3]) / norm; |
|
| 144 | 144 |
|
| 145 | 145 |
/* This is approximately corresponding routine in C-language: |
| 146 | 146 |
double corr, norm; |
| ... | ... |
@@ -277,7 +277,7 @@ uint32_t FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, ui |
| 277 | 277 |
// 2. If it could be guaranteed that 'dest' were always aligned to 16-byte |
| 278 | 278 |
// boundary, a faster '_mm_store_ps' instruction could be used. |
| 279 | 279 |
|
| 280 |
- return static_cast<uint32_t>(count); |
|
| 280 |
+ return count; |
|
| 281 | 281 |
|
| 282 | 282 |
/* original routine in C-language. please notice the C-version has differently |
| 283 | 283 |
organized coefficients though. |
| ... | ... |
@@ -259,7 +259,7 @@ void SndBuffer::timeStretchWrite() |
| 259 | 259 |
// suddenly we'll get several chunks back at once. Thus we use |
| 260 | 260 |
// data prediction to make the timestretcher more responsive. |
| 261 | 261 |
|
| 262 |
- PredictDataWrite(static_cast<int>(SndOutPacketSize / eTempo)); |
|
| 262 |
+ PredictDataWrite(SndOutPacketSize / eTempo); |
|
| 263 | 263 |
CvtPacketToFloat(sndTempBuffer.get()); |
| 264 | 264 |
|
| 265 | 265 |
pSoundTouch->putSamples(reinterpret_cast<float *>(sndTempBuffer.get()), SndOutPacketSize); |
| ... | ... |
@@ -124,7 +124,7 @@ private: |
| 124 | 124 |
this->rollingTotalSize -= this->statsHistory.front(); |
| 125 | 125 |
this->statsHistory.pop(); |
| 126 | 126 |
|
| 127 |
- float averageSize = static_cast<float>(rollingTotalSize / kAverageSize); |
|
| 127 |
+ float averageSize = rollingTotalSize / kAverageSize; |
|
| 128 | 128 |
//static int ctr=0; ctr++; if((ctr&127)==0) printf("avg size: %f curr size: %d rate: %f\n",averageSize,size,rate);
|
| 129 | 129 |
{
|
| 130 | 130 |
float targetRate; |
| ... | ... |
@@ -208,8 +208,8 @@ private: |
| 208 | 208 |
int outNum = end - cur; |
| 209 | 209 |
int denom = end - start; |
| 210 | 210 |
|
| 211 |
- int lrv = (static_cast<int>(lhs.l) * outNum + static_cast<int>(rhs.l) * inNum) / denom; |
|
| 212 |
- int rrv = (static_cast<int>(lhs.r) * outNum + static_cast<int>(rhs.r) * inNum) / denom; |
|
| 211 |
+ int lrv = (lhs.l * outNum + rhs.l * inNum) / denom; |
|
| 212 |
+ int rrv = (lhs.r * outNum + rhs.r * inNum) / denom; |
|
| 213 | 213 |
|
| 214 | 214 |
return ssamp(lrv, rrv); |
| 215 | 215 |
} |
| ... | ... |
@@ -130,15 +130,15 @@ const char dldiFileExtension[] = ".dldi"; |
| 130 | 130 |
|
| 131 | 131 |
addr_t readAddr(data_t *mem, addr_t offset) |
| 132 | 132 |
{
|
| 133 |
- return static_cast<addr_t>(mem[offset + 0] | (mem[offset + 1] << 8) | (mem[offset + 2] << 16) | (mem[offset + 3] << 24)); |
|
| 133 |
+ return mem[offset + 0] | (mem[offset + 1] << 8) | (mem[offset + 2] << 16) | (mem[offset + 3] << 24); |
|
| 134 | 134 |
} |
| 135 | 135 |
|
| 136 | 136 |
void writeAddr(data_t *mem, addr_t offset, addr_t value) |
| 137 | 137 |
{
|
| 138 |
- mem[offset + 0] = static_cast<data_t>(value); |
|
| 139 |
- mem[offset + 1] = static_cast<data_t>(value >> 8); |
|
| 140 |
- mem[offset + 2] = static_cast<data_t>(value >> 16); |
|
| 141 |
- mem[offset + 3] = static_cast<data_t>(value >> 24); |
|
| 138 |
+ mem[offset + 0] = value & 0xFF; |
|
| 139 |
+ mem[offset + 1] = (value >> 8) & 0xFF; |
|
| 140 |
+ mem[offset + 2] = (value >> 16) & 0xFF; |
|
| 141 |
+ mem[offset + 3] = (value >> 24) & 0xFF; |
|
| 142 | 142 |
} |
| 143 | 143 |
|
| 144 | 144 |
int stringCaseInsensitiveCompare(const char *str1, const char *str2) |