aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ARCodeFile.cpp4
-rw-r--r--src/ARMJIT.cpp14
-rw-r--r--src/ARMJIT_Memory.cpp2
-rw-r--r--src/Config.cpp4
-rw-r--r--src/DSi_I2C.cpp2
-rw-r--r--src/DSi_NWifi.cpp8
-rw-r--r--src/GBACart.cpp10
-rw-r--r--src/GPU.cpp6
-rw-r--r--src/GPU.h2
-rw-r--r--src/GPU3D.cpp6
-rw-r--r--src/GPU3D_OpenGL.cpp12
-rw-r--r--src/NDS.cpp24
-rw-r--r--src/NDSCart.h2
-rw-r--r--src/NonStupidBitfield.h6
-rw-r--r--src/SPU.h13
-rw-r--r--src/Savestate.cpp4
-rw-r--r--src/Wifi.cpp2
17 files changed, 69 insertions, 52 deletions
diff --git a/src/ARCodeFile.cpp b/src/ARCodeFile.cpp
index d92c078..2510b6e 100644
--- a/src/ARCodeFile.cpp
+++ b/src/ARCodeFile.cpp
@@ -60,7 +60,9 @@ bool ARCodeFile::Load()
char linebuf[1024];
while (!feof(f))
{
- fgets(linebuf, 1024, f);
+ if (fgets(linebuf, 1024, f) == NULL)
+ printf("Error reading string from file!");
+
linebuf[1023] = '\0';
char* start = linebuf;
diff --git a/src/ARMJIT.cpp b/src/ARMJIT.cpp
index b3dae1e..38e9ddc 100644
--- a/src/ARMJIT.cpp
+++ b/src/ARMJIT.cpp
@@ -262,7 +262,7 @@ template <bool Write, int ConsoleType>
void SlowBlockTransfer9(u32 addr, u64* data, u32 num, ARMv5* cpu)
{
addr &= ~0x3;
- for (int i = 0; i < num; i++)
+ for (u32 i = 0; i < num; i++)
{
if (Write)
SlowWrite9<u32, ConsoleType>(addr, cpu, data[i]);
@@ -276,7 +276,7 @@ template <bool Write, int ConsoleType>
void SlowBlockTransfer7(u32 addr, u64* data, u32 num)
{
addr &= ~0x3;
- for (int i = 0; i < num; i++)
+ for (u32 i = 0; i < num; i++)
{
if (Write)
SlowWrite7<u32, ConsoleType>(addr, data[i]);
@@ -667,7 +667,7 @@ void CompileBlock(ARM* cpu)
if (i == 0 || translatedAddrRounded != addressRanges[numAddressRanges - 1])
{
bool returning = false;
- for (int j = 0; j < numAddressRanges; j++)
+ for (u32 j = 0; j < numAddressRanges; j++)
{
if (addressRanges[j] == translatedAddrRounded)
{
@@ -874,7 +874,7 @@ void CompileBlock(ARM* cpu)
if (mayRestore && prevBlock->NumAddresses == numAddressRanges)
{
- for (int j = 0; j < numAddressRanges; j++)
+ for (u32 j = 0; j < numAddressRanges; j++)
{
if (prevBlock->AddressRanges()[j] != addressRanges[j]
|| prevBlock->AddressMasks()[j] != addressMasks[j])
@@ -901,9 +901,9 @@ void CompileBlock(ARM* cpu)
block = new JitBlock(cpu->Num, i, numAddressRanges, numLiterals);
block->LiteralHash = literalHash;
block->InstrHash = instrHash;
- for (int j = 0; j < numAddressRanges; j++)
+ for (u32 j = 0; j < numAddressRanges; j++)
block->AddressRanges()[j] = addressRanges[j];
- for (int j = 0; j < numAddressRanges; j++)
+ for (u32 j = 0; j < numAddressRanges; j++)
block->AddressMasks()[j] = addressMasks[j];
for (int j = 0; j < numLiterals; j++)
block->Literals()[j] = literalLoadAddrs[j];
@@ -929,7 +929,7 @@ void CompileBlock(ARM* cpu)
}
assert((localAddr & 1) == 0);
- for (int j = 0; j < numAddressRanges; j++)
+ for (u32 j = 0; j < numAddressRanges; j++)
{
assert(addressRanges[j] == block->AddressRanges()[j]);
assert(addressMasks[j] == block->AddressMasks()[j]);
diff --git a/src/ARMJIT_Memory.cpp b/src/ARMJIT_Memory.cpp
index 05399f3..3b78505 100644
--- a/src/ARMJIT_Memory.cpp
+++ b/src/ARMJIT_Memory.cpp
@@ -839,7 +839,7 @@ void Reset()
Mappings[region].Clear();
}
- for (int i = 0; i < sizeof(MappingStatus9); i++)
+ for (size_t i = 0; i < sizeof(MappingStatus9); i++)
{
assert(MappingStatus9[i] == memstate_Unmapped);
assert(MappingStatus7[i] == memstate_Unmapped);
diff --git a/src/Config.cpp b/src/Config.cpp
index 33ca9dc..3fb2b26 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -119,7 +119,9 @@ void Load()
char entryval[1024];
while (!feof(f))
{
- fgets(linebuf, 1024, f);
+ if (fgets(linebuf, 1024, f) == NULL)
+ printf("Error reading string from file!");
+
int ret = sscanf(linebuf, "%31[A-Za-z_0-9]=%[^\t\r\n]", entryname, entryval);
entryname[31] = '\0';
if (ret < 2) continue;
diff --git a/src/DSi_I2C.cpp b/src/DSi_I2C.cpp
index ad01a42..4bb7df9 100644
--- a/src/DSi_I2C.cpp
+++ b/src/DSi_I2C.cpp
@@ -98,7 +98,7 @@ void Write(u8 val, bool last)
return;
}
- if (CurPos == -1)
+ if (CurPos == 0xFFFFFFFF)
{
CurPos = val;
//printf("BPTWL: reg=%02X\n", val);
diff --git a/src/DSi_NWifi.cpp b/src/DSi_NWifi.cpp
index 1d1b925..57bd93c 100644
--- a/src/DSi_NWifi.cpp
+++ b/src/DSi_NWifi.cpp
@@ -747,7 +747,7 @@ void DSi_NWifi::BMI_Command()
u32 len = MB_Read32(0);
printf("BMI mem write %08X %08X\n", addr, len);
- for (int i = 0; i < len; i++)
+ for (u32 i = 0; i < len; i++)
{
u8 val = Mailbox[0].Read();
@@ -801,7 +801,7 @@ void DSi_NWifi::BMI_Command()
printf("BMI LZ write %08X\n", len);
//FILE* f = fopen("debug/wififirm.bin", "ab");
- for (int i = 0; i < len; i++)
+ for (u32 i = 0; i < len; i++)
{
u8 val = Mailbox[0].Read();
@@ -1306,7 +1306,7 @@ void DSi_NWifi::SendWMIEvent(u8 ep, u16 id, u8* data, u32 len)
Mailbox[8].Write(0); //
MB_Write16(8, id); // event ID
- for (int i = 0; i < len; i++)
+ for (u32 i = 0; i < len; i++)
{
Mailbox[8].Write(data[i]);
}
@@ -1383,7 +1383,7 @@ void DSi_NWifi::SendWMIBSSInfo(u8 type, u8* data, u32 len)
MB_Write16(8, *(u16*)&WifiAP::APMac[4]);
MB_Write32(8, 0); // ieMask
- for (int i = 0; i < len; i++)
+ for (u32 i = 0; i < len; i++)
{
Mailbox[8].Write(data[i]);
}
diff --git a/src/GBACart.cpp b/src/GBACart.cpp
index 246f986..808fc0b 100644
--- a/src/GBACart.cpp
+++ b/src/GBACart.cpp
@@ -198,11 +198,11 @@ void CartGame::LoadSave(const char* path, u32 type)
case 128*1024:
SRAMType = S_FLASH1M;
break;
- default:
- printf("!! BAD GBA SAVE LENGTH %d\n", SRAMLength);
case 0:
SRAMType = S_NULL;
break;
+ default:
+ printf("!! BAD GBA SAVE LENGTH %d\n", SRAMLength);
}
if (SRAMType == S_FLASH512K)
@@ -309,6 +309,8 @@ u8 CartGame::SRAMRead(u32 addr)
case S_SRAM256K:
return SRAMRead_SRAM(addr);
+ default:
+ break;
}
return 0xFF;
@@ -330,6 +332,8 @@ void CartGame::SRAMWrite(u32 addr, u8 val)
case S_SRAM256K:
return SRAMWrite_SRAM(addr, val);
+ default:
+ break;
}
}
@@ -704,7 +708,7 @@ void LoadROMCommon(const char *sram)
printf("GBA game code: %s\n", gamecode);
bool solarsensor = false;
- for (int i = 0; i < sizeof(SOLAR_SENSOR_GAMECODES)/sizeof(SOLAR_SENSOR_GAMECODES[0]); i++)
+ for (size_t i = 0; i < sizeof(SOLAR_SENSOR_GAMECODES)/sizeof(SOLAR_SENSOR_GAMECODES[0]); i++)
{
if (strcmp(gamecode, SOLAR_SENSOR_GAMECODES[i]) == 0)
solarsensor = true;
diff --git a/src/GPU.cpp b/src/GPU.cpp
index cd026e1..cbd1343 100644
--- a/src/GPU.cpp
+++ b/src/GPU.cpp
@@ -251,12 +251,12 @@ void Reset()
else
fbsize = 256 * 192;
- for (int i = 0; i < fbsize; i++)
+ for (size_t i = 0; i < fbsize; i++)
{
Framebuffer[0][0][i] = 0xFFFFFFFF;
Framebuffer[1][0][i] = 0xFFFFFFFF;
}
- for (int i = 0; i < fbsize; i++)
+ for (size_t i = 0; i < fbsize; i++)
{
Framebuffer[0][1][i] = 0xFFFFFFFF;
Framebuffer[1][1][i] = 0xFFFFFFFF;
@@ -1067,7 +1067,7 @@ void StartScanline(u32 line)
{
if (line == 0)
VCount = 0;
- else if (NextVCount != -1)
+ else if (NextVCount != 0xFFFFFFFF)
VCount = NextVCount;
else
VCount++;
diff --git a/src/GPU.h b/src/GPU.h
index 7299b90..1432bdf 100644
--- a/src/GPU.h
+++ b/src/GPU.h
@@ -93,7 +93,7 @@ struct VRAMTrackingSet
void Reset()
{
- for (int i = 0; i < Size / MappingGranularity; i++)
+ for (u32 i = 0; i < Size / MappingGranularity; i++)
{
// this is not a real VRAM bank
// so it will always be a mismatch => the bank will be completely invalidated
diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp
index 132410d..fa1f576 100644
--- a/src/GPU3D.cpp
+++ b/src/GPU3D.cpp
@@ -486,7 +486,7 @@ void DoSavestate(Savestate* file)
{
u32 id;
file->Var32(&id);
- if (id == -1) LastStripPolygon = NULL;
+ if (id == 0xFFFFFFFF) LastStripPolygon = NULL;
else LastStripPolygon = &PolygonRAM[id];
}
@@ -535,7 +535,7 @@ void DoSavestate(Savestate* file)
{
u32 id = -1;
file->Var32(&id);
- if (id == -1) poly->Vertices[j] = NULL;
+ if (id == 0xFFFFFFFF) poly->Vertices[j] = NULL;
else poly->Vertices[j] = &VertexRAM[id];
}
}
@@ -574,7 +574,7 @@ void DoSavestate(Savestate* file)
{
poly->Degenerate = false;
- for (int j = 0; j < poly->NumVertices; j++)
+ for (u32 j = 0; j < poly->NumVertices; j++)
{
if (poly->Vertices[j]->Position[3] == 0)
poly->Degenerate = true;
diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp
index c67cc00..ccac08a 100644
--- a/src/GPU3D_OpenGL.cpp
+++ b/src/GPU3D_OpenGL.cpp
@@ -508,7 +508,7 @@ void GLRenderer::BuildPolygons(GLRenderer::RendererPolygon* polygons, int npolys
u32 lastx, lasty;
int nout = 0;
- for (int j = 0; j < poly->NumVertices; j++)
+ for (u32 j = 0; j < poly->NumVertices; j++)
{
Vertex* vtx = poly->Vertices[j];
@@ -557,7 +557,7 @@ void GLRenderer::BuildPolygons(GLRenderer::RendererPolygon* polygons, int npolys
{
// regular triangle-splitting
- for (int j = 0; j < poly->NumVertices; j++)
+ for (u32 j = 0; j < poly->NumVertices; j++)
{
Vertex* vtx = poly->Vertices[j];
@@ -588,7 +588,7 @@ void GLRenderer::BuildPolygons(GLRenderer::RendererPolygon* polygons, int npolys
float cR = 0, cG = 0, cB = 0;
float cS = 0, cT = 0;
- for (int j = 0; j < poly->NumVertices; j++)
+ for (u32 j = 0; j < poly->NumVertices; j++)
{
Vertex* vtx = poly->Vertices[j];
@@ -651,7 +651,7 @@ void GLRenderer::BuildPolygons(GLRenderer::RendererPolygon* polygons, int npolys
vidx++;
// build the final polygon
- for (int j = 0; j < poly->NumVertices; j++)
+ for (u32 j = 0; j < poly->NumVertices; j++)
{
Vertex* vtx = poly->Vertices[j];
@@ -680,7 +680,7 @@ void GLRenderer::BuildPolygons(GLRenderer::RendererPolygon* polygons, int npolys
rp->NumEdgeIndices = 0;
u32 vidx_cur = vidx_first;
- for (int j = 1; j < poly->NumVertices; j++)
+ for (u32 j = 1; j < poly->NumVertices; j++)
{
IndexBuffer[eidx++] = vidx_cur;
IndexBuffer[eidx++] = vidx_cur + 1;
@@ -1259,7 +1259,7 @@ void GLRenderer::RenderFrame()
int npolys = 0;
int firsttrans = -1;
- for (int i = 0; i < RenderNumPolygons; i++)
+ for (u32 i = 0; i < RenderNumPolygons; i++)
{
if (RenderPolygonRAM[i]->Degenerate) continue;
diff --git a/src/NDS.cpp b/src/NDS.cpp
index fa37c39..eade479 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -655,7 +655,7 @@ bool DoSavestate_Scheduler(Savestate* file)
break;
}
}
- if (funcid == -1)
+ if (funcid == 0xFFFFFFFF)
{
printf("savestate: VERY BAD!!!!! FUNCTION POINTER FOR EVENT %d NOT IN HACKY LIST. CANNOT SAVE. SMACK ARISOTURA.\n", i);
return false;
@@ -676,7 +676,7 @@ bool DoSavestate_Scheduler(Savestate* file)
u32 funcid;
file->Var32(&funcid);
- if (funcid != -1)
+ if (funcid != 0xFFFFFFFF)
{
for (int j = 0; ; j++)
{
@@ -1470,11 +1470,11 @@ void NocashPrint(u32 ncpu, u32 addr)
else if (!strcmp(cmd, "pc")) sprintf(subs, "%08X", cpu->R[15]);
else if (!strcmp(cmd, "frame")) sprintf(subs, "%u", NumFrames);
else if (!strcmp(cmd, "scanline")) sprintf(subs, "%u", GPU::VCount);
- else if (!strcmp(cmd, "totalclks")) sprintf(subs, "%lu", GetSysClockCycles(0));
- else if (!strcmp(cmd, "lastclks")) sprintf(subs, "%lu", GetSysClockCycles(1));
+ else if (!strcmp(cmd, "totalclks")) sprintf(subs, "%" PRIu64, GetSysClockCycles(0));
+ else if (!strcmp(cmd, "lastclks")) sprintf(subs, "%" PRIu64, GetSysClockCycles(1));
else if (!strcmp(cmd, "zeroclks"))
{
- sprintf(subs, "");
+ sprintf(subs, "%s", "");
GetSysClockCycles(1);
}
}
@@ -3575,31 +3575,31 @@ u8 ARM7IORead8(u32 addr)
case 0x040001A8:
if (ExMemCnt[0] & (1<<11))
return NDSCart::ROMCommand[0];
- return 0;
+ return 0;
case 0x040001A9:
if (ExMemCnt[0] & (1<<11))
return NDSCart::ROMCommand[1];
- return 0;
+ return 0;
case 0x040001AA:
if (ExMemCnt[0] & (1<<11))
return NDSCart::ROMCommand[2];
- return 0;
+ return 0;
case 0x040001AB:
if (ExMemCnt[0] & (1<<11))
return NDSCart::ROMCommand[3];
- return 0;
+ return 0;
case 0x040001AC:
if (ExMemCnt[0] & (1<<11))
return NDSCart::ROMCommand[4];
- return 0;
+ return 0;
case 0x040001AD:
if (ExMemCnt[0] & (1<<11))
return NDSCart::ROMCommand[5];
- return 0;
+ return 0;
case 0x040001AE:
if (ExMemCnt[0] & (1<<11))
return NDSCart::ROMCommand[6];
- return 0;
+ return 0;
case 0x040001AF:
if (ExMemCnt[0] & (1<<11))
return NDSCart::ROMCommand[7];
diff --git a/src/NDSCart.h b/src/NDSCart.h
index d54dc76..0345297 100644
--- a/src/NDSCart.h
+++ b/src/NDSCart.h
@@ -108,7 +108,7 @@ public:
void Reset() override;
- void DoSavestate(Savestate* file);
+ void DoSavestate(Savestate* file) override;
void LoadSave(const char* path, u32 type) override;
int ImportSRAM(const u8* data, u32 length) override;
diff --git a/src/NonStupidBitfield.h b/src/NonStupidBitfield.h
index 4ffbcdc..45b160e 100644
--- a/src/NonStupidBitfield.h
+++ b/src/NonStupidBitfield.h
@@ -166,7 +166,7 @@ struct NonStupidBitField
void SetRange(u32 startBit, u32 bitsCount)
{
u32 startEntry = startBit >> 6;
- u64 entriesCount = ((startBit + bitsCount + 0x3F & ~0x3F) >> 6) - startEntry;
+ u64 entriesCount = (((startBit + bitsCount + 0x3F) & ~0x3F) >> 6) - startEntry;
if (entriesCount > 1)
{
@@ -175,7 +175,7 @@ struct NonStupidBitField
Data[startEntry + entriesCount - 1] |= ~(0xFFFFFFFFFFFFFFFF << ((startBit + bitsCount) & 0x3F));
else
Data[startEntry + entriesCount - 1] = 0xFFFFFFFFFFFFFFFF;
- for (int i = startEntry + 1; i < startEntry + entriesCount - 1; i++)
+ for (u64 i = startEntry + 1; i < startEntry + entriesCount - 1; i++)
Data[i] = 0xFFFFFFFFFFFFFFFF;
}
else
@@ -203,4 +203,4 @@ struct NonStupidBitField
};
-#endif \ No newline at end of file
+#endif
diff --git a/src/SPU.h b/src/SPU.h
index 35c924c..bbc48e5 100644
--- a/src/SPU.h
+++ b/src/SPU.h
@@ -134,8 +134,17 @@ public:
case 1: return Run<1>(); break;
case 2: return Run<2>(); break;
case 3:
- if (Num >= 14) return Run<4>();
- else if (Num >= 8) return Run<3>();
+ if (Num >= 14)
+ {
+ return Run<4>();
+ break;
+ }
+ else if (Num >= 8)
+ {
+ return Run<3>();
+ break;
+ }
+ [[fallthrough]];
default:
return 0;
}
diff --git a/src/Savestate.cpp b/src/Savestate.cpp
index 1af2694..1bfe937 100644
--- a/src/Savestate.cpp
+++ b/src/Savestate.cpp
@@ -134,7 +134,7 @@ Savestate::~Savestate()
if (Saving)
{
- if (CurSection != -1)
+ if (CurSection != 0xFFFFFFFF)
{
u32 pos = (u32)ftell(file);
fseek(file, CurSection+4, SEEK_SET);
@@ -160,7 +160,7 @@ void Savestate::Section(const char* magic)
if (Saving)
{
- if (CurSection != -1)
+ if (CurSection != 0xFFFFFFFF)
{
u32 pos = (u32)ftell(file);
fseek(file, CurSection+4, SEEK_SET);
diff --git a/src/Wifi.cpp b/src/Wifi.cpp
index 4da7cc3..e6fdeed 100644
--- a/src/Wifi.cpp
+++ b/src/Wifi.cpp
@@ -1085,7 +1085,7 @@ void USTimer(u32 param)
printf("wifi: RX buffer full\n");
RXTime = 0;
SetStatus(1);
- if (TXCurSlot == -1)
+ if (TXCurSlot == 0xFFFFFFFF)
{
ComStatus &= ~0x1;
RXCounter = 0;