diff --git a/desmume/src/Database.cpp b/desmume/src/Database.cpp index 6029e5c21..1a0d3ca43 100644 --- a/desmume/src/Database.cpp +++ b/desmume/src/Database.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2008-2016 DeSmuME team + Copyright (C) 2008-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,24 +13,24 @@ You should have received a copy of the GNU General Public License along with the this software. If not, see . -*/ - -#include - -#include "types.h" -#include "Database.h" -#include "retro_miscellaneous.h" - -//------------------------------------------------------------ -//large databases are first. scroll down to ENDLARGE to find the code - -struct MAKER -{ - u16 code; - const char* name; -}; - - +*/ + +#include + +#include "types.h" +#include "Database.h" +#include "retro_miscellaneous.h" + +//------------------------------------------------------------ +//large databases are first. scroll down to ENDLARGE to find the code + +struct MAKER +{ + u16 code; + const char* name; +}; + + static const char regions_index[] = "JPFSEODIRKHXVWUC"; static const char *regions[] = { "JPN", // J @@ -49,8 +49,8 @@ static const char *regions[] = { "EUU", // W "AUS", // U "CHN", // C -}; - +}; + static MAKER makerCodes[] = { { 0x3130, "Nintendo" }, { 0x3230, "Rocket Games, Ajinomoto" }, @@ -367,26 +367,26 @@ static MAKER makerCodes[] = { //ENDLARGE //------------------------------------------------------------ -namespace Database -{ - const char* RegionXXXForCode(char code, bool unknownAsString) - { +namespace Database +{ + const char* RegionXXXForCode(char code, bool unknownAsString) + { size_t regions_num = ARRAY_SIZE(regions); const char* found = strchr(regions_index,code); if(found) return regions[found-regions_index]; else return unknownAsString ? "???" : NULL; - } - - const char *MakerNameForMakerCode(u16 id, bool unknownAsString) - { - //too bad these aren't sorted - for (int i = 0; i < ARRAY_SIZE(makerCodes); i++) + } + + const char *MakerNameForMakerCode(u16 id, bool unknownAsString) + { + //too bad these aren't sorted + for (size_t i = 0; i < ARRAY_SIZE(makerCodes); i++) { if (makerCodes[i].code == id) return makerCodes[i].name; } - return unknownAsString ? "Unknown" : NULL; - } + return unknownAsString ? "Unknown" : NULL; + } } diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 6097e24d5..3f1208cfe 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -1128,7 +1128,7 @@ static void execdiv() { DSI_TSC::DSI_TSC() { - for(int i=0;i memReadBreakPoints; -std::vector memWriteBreakPoints; +std::vector memReadBreakPoints; +std::vector memWriteBreakPoints; using std::min; using std::max; @@ -707,15 +707,17 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi //run crc over the whole buffer (chunk at a time, to avoid coding a streaming crc gameInfo.reader->Seek(gameInfo.fROM, 0, SEEK_SET); gameInfo.crc = 0; + + u8 fROMBuffer[4096]; bool first = true; + for(;;) { - u8 buf[4096]; - int read = gameInfo.reader->Read(gameInfo.fROM,buf,4096); + int read = gameInfo.reader->Read(gameInfo.fROM,fROMBuffer,4096); if(read == 0) break; if(first && read >= 512) - gameInfo.crcForCheatsDb = ~crc32(0, buf, 512); + gameInfo.crcForCheatsDb = ~crc32(0, fROMBuffer, 512); first = false; - gameInfo.crc = crc32(gameInfo.crc, buf, read); + gameInfo.crc = crc32(gameInfo.crc, fROMBuffer, read); } gameInfo.chipID = 0xC2; // The Manufacturer ID is defined by JEDEC (C2h = Macronix) @@ -1921,7 +1923,7 @@ static /*donotinline*/ std::pair armInnerLoop( { // breakpoint handling #if defined(HOST_WINDOWS) && !defined(TARGET_INTERFACE) - const std::vector *breakpointList9 = NDS_ARM9.breakPoints; + const std::vector *breakpointList9 = NDS_ARM9.breakPoints; for (int i = 0; i < breakpointList9->size(); ++i) { if (NDS_ARM9.instruct_adr == (*breakpointList9)[i] && !NDS_ARM9.debugStep) { emu_paused = true; @@ -1933,7 +1935,7 @@ static /*donotinline*/ std::pair armInnerLoop( return std::make_pair(arm9, arm7); } } - const std::vector *breakpointList7 = NDS_ARM7.breakPoints; + const std::vector *breakpointList7 = NDS_ARM7.breakPoints; for (int i = 0; i < breakpointList7->size(); ++i) { if (NDS_ARM7.instruct_adr == (*breakpointList7)[i] && !NDS_ARM7.debugStep) { emu_paused = true; diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 8afa017a7..9c2cc6cae 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -1,6 +1,6 @@ /* Copyright (C) 2006 yopyop - Copyright (C) 2008-2019 DeSmuME team + Copyright (C) 2008-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -404,8 +404,8 @@ typedef struct TSCalInfo extern GameInfo gameInfo; -extern std::vector memReadBreakPoints; -extern std::vector memWriteBreakPoints; +extern std::vector memReadBreakPoints; +extern std::vector memWriteBreakPoints; struct UserButtons : buttonstruct diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index da8ebc115..96133273b 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -1814,7 +1814,7 @@ FragmentColor* OpenGLRenderer::GetFramebuffer() GLsizei OpenGLRenderer::GetLimitedMultisampleSize() const { - GLsizei deviceMultisamples = this->_deviceInfo.maxSamples; + u32 deviceMultisamples = this->_deviceInfo.maxSamples; u32 workingMultisamples = (u32)this->_selectedMultisampleSize; if (workingMultisamples == 1) @@ -1847,7 +1847,7 @@ GLsizei OpenGLRenderer::GetLimitedMultisampleSize() const deviceMultisamples = workingMultisamples; } - return deviceMultisamples; + return (GLsizei)deviceMultisamples; } OpenGLTexture* OpenGLRenderer::GetLoadedTextureFromPolygon(const POLY &thePoly, bool enableTexturing) diff --git a/desmume/src/SPU.cpp b/desmume/src/SPU.cpp index e2d3d2bf9..6601a1e0a 100644 --- a/desmume/src/SPU.cpp +++ b/desmume/src/SPU.cpp @@ -1,7 +1,7 @@ /* Copyright (C) 2006 yopyop Copyright (C) 2006 Theo Berkau - Copyright (C) 2008-2017 DeSmuME team + Copyright (C) 2008-2021 DeSmuME team Ideas borrowed from Stephane Dallongeville's SCSP core @@ -1269,6 +1269,7 @@ template FORCEINLINE static void SPU_Mix(SPU_struct* SPU, channel_ case 0: MixL(SPU, chan, data); break; case 1: MixLR(SPU, chan, data); break; case 2: MixR(SPU, chan, data); break; + default: break; } SPU->lastdata = data; } @@ -1288,6 +1289,7 @@ template case 1: Fetch16BitData(chan, &data); break; case 2: FetchADPCMData(chan, &data); break; case 3: FetchPSGData(chan, &data); break; + default: break; } SPU_Mix(SPU, chan, data); } @@ -1296,6 +1298,7 @@ template case 0: case 1: TestForLoop(SPU, chan); break; case 2: TestForLoop2(SPU, chan); break; case 3: chan->sampcnt += chan->sampinc; break; + default: break; } } } @@ -1441,6 +1444,7 @@ static void SPU_MixAudio_Advanced(bool actuallyMix, SPU_struct *SPU, int length) case SPU_struct::REGS::LOM_CH1: sndout[0] = submix[1*2+0]; break; case SPU_struct::REGS::LOM_CH3: sndout[0] = submix[3*2+0]; break; case SPU_struct::REGS::LOM_CH1_PLUS_CH3: sndout[0] = submix[1*2+0] + submix[3*2+0]; break; + default: break; } switch (SPU->regs.ctl_right) { @@ -1448,6 +1452,7 @@ static void SPU_MixAudio_Advanced(bool actuallyMix, SPU_struct *SPU, int length) case SPU_struct::REGS::ROM_CH1: sndout[1] = submix[1*2+1]; break; case SPU_struct::REGS::ROM_CH3: sndout[1] = submix[3*2+1]; break; case SPU_struct::REGS::ROM_CH1_PLUS_CH3: sndout[1] = submix[1*2+1] + submix[3*2+1]; break; + default: break; } diff --git a/desmume/src/addons/slot1_r4.cpp b/desmume/src/addons/slot1_r4.cpp index c4d3c53a1..a0cb33f05 100644 --- a/desmume/src/addons/slot1_r4.cpp +++ b/desmume/src/addons/slot1_r4.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2010-2017 DeSmuME team + Copyright (C) 2010-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -82,9 +82,9 @@ public: return protocol.read_GCDATAIN(PROCNUM); } - virtual void slot1client_startOperation(eSlot1Operation operation) + virtual void slot1client_startOperation(eSlot1Operation theOperation) { - if(operation != eSlot1Operation_Unknown) + if (theOperation != eSlot1Operation_Unknown) return; u32 address; @@ -109,9 +109,9 @@ public: } } - virtual u32 slot1client_read_GCDATAIN(eSlot1Operation operation) + virtual u32 slot1client_read_GCDATAIN(eSlot1Operation theOperation) { - if (operation != eSlot1Operation_Unknown) + if (theOperation != eSlot1Operation_Unknown) return 0; u32 val = 0; @@ -141,9 +141,9 @@ public: return val; } - void slot1client_write_GCDATAIN(eSlot1Operation operation, u32 val) + void slot1client_write_GCDATAIN(eSlot1Operation theOperation, u32 val) { - if (operation != eSlot1Operation_Unknown) + if (theOperation != eSlot1Operation_Unknown) return; int cmd = protocol.command.bytes[0]; diff --git a/desmume/src/addons/slot1_retail_mcrom.cpp b/desmume/src/addons/slot1_retail_mcrom.cpp index 3d9a3d292..07057ec99 100644 --- a/desmume/src/addons/slot1_retail_mcrom.cpp +++ b/desmume/src/addons/slot1_retail_mcrom.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2010-2015 DeSmuME team + Copyright (C) 2010-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,9 +73,9 @@ public: return protocol.read_GCDATAIN(PROCNUM); } - virtual void slot1client_startOperation(eSlot1Operation operation) + virtual void slot1client_startOperation(eSlot1Operation theOperation) { - rom.start(operation,protocol.address); + rom.start(theOperation,protocol.address); } virtual void post_fakeboot(int PROCNUM) diff --git a/desmume/src/addons/slot1_retail_mcrom_debug.cpp b/desmume/src/addons/slot1_retail_mcrom_debug.cpp index 388df8c85..be050ad60 100644 --- a/desmume/src/addons/slot1_retail_mcrom_debug.cpp +++ b/desmume/src/addons/slot1_retail_mcrom_debug.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2017 DeSmuME team + Copyright (C) 2013-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -108,7 +108,7 @@ public: rom.loadstate(is); } - virtual void slot1client_startOperation(eSlot1Operation operation) + virtual void slot1client_startOperation(eSlot1Operation theOperation) { if (protocol.operation == eSlot1Operation_B7_Read) { @@ -168,7 +168,7 @@ public: curr_file_id = file_id; } - rom.start(operation, protocol.address); + rom.start(theOperation, protocol.address); } private: diff --git a/desmume/src/addons/slot1_retail_nand.cpp b/desmume/src/addons/slot1_retail_nand.cpp index f63afa8ea..2820dda20 100644 --- a/desmume/src/addons/slot1_retail_nand.cpp +++ b/desmume/src/addons/slot1_retail_nand.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2010-2017 DeSmuME team + Copyright (C) 2010-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -88,7 +88,7 @@ public: return protocol.read_GCDATAIN(PROCNUM); } - virtual void slot1client_startOperation(eSlot1Operation operation) + virtual void slot1client_startOperation(eSlot1Operation theOperation) { //INFO("Start command: %02X%02X%02X%02X%02X%02X%02X%02X\t", // protocol.command.bytes[0], protocol.command.bytes[1], protocol.command.bytes[2], protocol.command.bytes[3], @@ -98,14 +98,14 @@ public: u32 addressFromProtocol = (protocol.command.bytes[1] << 24) | (protocol.command.bytes[2] << 16) | (protocol.command.bytes[3] << 8) | protocol.command.bytes[4]; //pass the normal rom operations along to the rom component - switch(operation) + switch (theOperation) { case eSlot1Operation_00_ReadHeader_Unencrypted: - rom.start(operation,addressFromProtocol); + rom.start(theOperation, addressFromProtocol); return; case eSlot1Operation_2x_SecureAreaLoad: - rom.start(operation,protocol.address); + rom.start(theOperation, protocol.address); return; default: @@ -159,7 +159,7 @@ public: } else { - rom.start(operation, addressFromProtocol); + rom.start(theOperation, addressFromProtocol); } break; @@ -183,6 +183,9 @@ public: case eSlot1Operation_2x_SecureAreaLoad: //case eSlot1Operation_B7_Read: return rom.read(); + + default: + break; } //handle special commands ourselves @@ -253,6 +256,9 @@ public: case eSlot1Operation_B7_Read: case eSlot1Operation_2x_SecureAreaLoad: return; + + default: + break; } //handle special commands ourselves diff --git a/desmume/src/addons/slot1comp_protocol.cpp b/desmume/src/addons/slot1comp_protocol.cpp index 213a18478..abeadedf0 100644 --- a/desmume/src/addons/slot1comp_protocol.cpp +++ b/desmume/src/addons/slot1comp_protocol.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 DeSmuME team + Copyright (C) 2012-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,9 +26,9 @@ static _KEY1 key1((const u8*)arm7_key); -void Slot1Comp_Protocol::reset(ISlot1Comp_Protocol_Client* client) +void Slot1Comp_Protocol::reset(ISlot1Comp_Protocol_Client* theClient) { - this->client = client; + this->client = theClient; //we have to initialize this to something.. lets use dummy. //(need to clean this up...) @@ -40,9 +40,9 @@ void Slot1Comp_Protocol::reset(ISlot1Comp_Protocol_Client* client) mode = eCardMode_RAW; } -void Slot1Comp_Protocol::write_command_RAW(GC_Command command) +void Slot1Comp_Protocol::write_command_RAW(GC_Command theCommand) { - int cmd = command.bytes[0]; + int cmd = theCommand.bytes[0]; if(cmd == 0x9F) { operation = eSlot1Operation_9F_Dummy; @@ -74,17 +74,17 @@ void Slot1Comp_Protocol::write_command_RAW(GC_Command command) } } -void Slot1Comp_Protocol::write_command_KEY1(GC_Command command) +void Slot1Comp_Protocol::write_command_KEY1(GC_Command theCommand) { //decrypt the KEY1-format command u32 temp[2]; - command.toCryptoBuffer(temp); + theCommand.toCryptoBuffer(temp); key1.decrypt(temp); - command.fromCryptoBuffer(temp); - GCLOG("[GC] (key1-decrypted):"); command.print(); + theCommand.fromCryptoBuffer(temp); + GCLOG("[GC] (key1-decrypted):"); theCommand.print(); //and process it: - int cmd = command.bytes[0]; + int cmd = theCommand.bytes[0]; switch(cmd&0xF0) { case 0x10: @@ -100,9 +100,9 @@ void Slot1Comp_Protocol::write_command_KEY1(GC_Command command) //TODO - more endian-safe way of doing this (theres examples in R4) { #ifdef MSB_FIRST - u64 cmd64 = *(u64*)command.bytes; + u64 cmd64 = *(u64*)theCommand.bytes; #else - u64 cmd64 = bswap64(*(u64*)command.bytes); + u64 cmd64 = bswap64(*(u64*)theCommand.bytes); #endif //todo - parse into blocknumber u32 blocknumber = (cmd64>>44)&0xFFFF; @@ -133,7 +133,7 @@ void Slot1Comp_Protocol::write_command_KEY1(GC_Command command) } } -void Slot1Comp_Protocol::write_command_NORMAL(GC_Command command) +void Slot1Comp_Protocol::write_command_NORMAL(GC_Command theCommand) { switch(command.bytes[0]) { @@ -143,9 +143,9 @@ void Slot1Comp_Protocol::write_command_NORMAL(GC_Command command) //TODO - more endian-safe way of doing this (theres examples in R4) #ifdef MSB_FIRST - u64 cmd64 = *(u64*)command.bytes; + u64 cmd64 = *(u64*)theCommand.bytes; #else - u64 cmd64 = bswap64(*(u64*)command.bytes); + u64 cmd64 = bswap64(*(u64*)theCommand.bytes); #endif address = (u32)((cmd64 >> 24)); length = 0x200; @@ -167,9 +167,9 @@ void Slot1Comp_Protocol::write_command_NORMAL(GC_Command command) } } -void Slot1Comp_Protocol::write_command(GC_Command command) +void Slot1Comp_Protocol::write_command(GC_Command theCommand) { - this->command = command; + this->command = theCommand; //unrecognized commands will do something depending on the current state of the card delay = 0; @@ -178,17 +178,20 @@ void Slot1Comp_Protocol::write_command(GC_Command command) switch(mode) { - case eCardMode_RAW: - write_command_RAW(command); - break; + case eCardMode_RAW: + write_command_RAW(theCommand); + break; - case eCardMode_KEY1: - write_command_KEY1(command); - break; + case eCardMode_KEY1: + write_command_KEY1(theCommand); + break; - case eCardMode_NORMAL: - write_command_NORMAL(command); - break; + case eCardMode_NORMAL: + write_command_NORMAL(theCommand); + break; + + default: + break; } } @@ -199,6 +202,9 @@ void Slot1Comp_Protocol::write_GCDATAIN(u8 PROCNUM, u32 val) case eSlot1Operation_Unknown: client->slot1client_write_GCDATAIN(operation,val); break; + + default: + break; } } diff --git a/desmume/src/addons/slot1comp_protocol.h b/desmume/src/addons/slot1comp_protocol.h index 415676c9d..86796af5c 100644 --- a/desmume/src/addons/slot1comp_protocol.h +++ b/desmume/src/addons/slot1comp_protocol.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 DeSmuME team + Copyright (C) 2013-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -59,9 +59,9 @@ enum eSlot1Operation class ISlot1Comp_Protocol_Client { public: - virtual void slot1client_startOperation(eSlot1Operation operation) {} - virtual u32 slot1client_read_GCDATAIN(eSlot1Operation operation) = 0; - virtual void slot1client_write_GCDATAIN(eSlot1Operation operation, u32 val) {} + virtual void slot1client_startOperation(eSlot1Operation theOperation) {} + virtual u32 slot1client_read_GCDATAIN(eSlot1Operation theOperation) = 0; + virtual void slot1client_write_GCDATAIN(eSlot1Operation theOperation, u32 val) {} }; @@ -73,17 +73,17 @@ public: void loadstate(EMUFILE &is); //set some kind of protocol/hardware reset state - void reset(ISlot1Comp_Protocol_Client* client); + void reset(ISlot1Comp_Protocol_Client* theClient); //signals from the GC bus - void write_command(GC_Command command); + void write_command(GC_Command theCommand); void write_GCDATAIN(u8 PROCNUM, u32 val); u32 read_GCDATAIN(u8 PROCNUM); //helpers for write_command() - void write_command_RAW(GC_Command command); - void write_command_KEY1(GC_Command command); - void write_command_NORMAL(GC_Command command); + void write_command_RAW(GC_Command theCommand); + void write_command_KEY1(GC_Command theCommand); + void write_command_NORMAL(GC_Command theCommand); //operations not related to obscurities of the protocol or otherwise unknown are passed through to the client here ISlot1Comp_Protocol_Client* client; diff --git a/desmume/src/addons/slot1comp_rom.cpp b/desmume/src/addons/slot1comp_rom.cpp index e034fa2e1..7a03d97c2 100644 --- a/desmume/src/addons/slot1comp_rom.cpp +++ b/desmume/src/addons/slot1comp_rom.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2010-2015 DeSmuME team + Copyright (C) 2010-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,18 +23,18 @@ void Slot1Comp_Rom::start(eSlot1Operation operation, u32 addr) { - this->operation = operation; - this->address = addr; + this->_operation = operation; + this->_address = addr; } u32 Slot1Comp_Rom::read() { - switch(operation) + switch(this->_operation) { case eSlot1Operation_00_ReadHeader_Unencrypted: { - u32 ret = gameInfo.readROM(address); - address = (address + 4) & 0xFFF; + u32 ret = gameInfo.readROM(this->_address); + this->_address = (this->_address + 4) & 0xFFF; return ret; } break; @@ -45,10 +45,10 @@ u32 Slot1Comp_Rom::read() //zero 15-sep-2014 - this is meaningless. newer mask is actually reasonable //address &= gameInfo.mask; //sanity check - u32 secureAreaAddress = (address - 0x4000); + u32 secureAreaAddress = (this->_address - 0x4000); secureAreaAddress &= 0x3FFF; //memory safe sanity test u32 ret = LE_TO_LOCAL_32(*(u32*)(gameInfo.secureArea + secureAreaAddress)); - address = (address&~0xFFF) + ((address+4)&0xFFF); + this->_address = (this->_address&~0xFFF) + ((this->_address+4)&0xFFF); return ret; } @@ -59,13 +59,13 @@ u32 Slot1Comp_Rom::read() //it seems that etrian odyssey 3 doesnt work unless we mask this to cart size. //but, a thought: does the internal rom address counter register wrap around? we may be making a mistake by keeping the extra precision //but there is no test case yet - address &= gameInfo.mask; + this->_address &= gameInfo.mask; //feature of retail carts: //B7 "Can be used only for addresses 8000h and up, smaller addresses will be silently redirected to address `8000h+(addr AND 1FFh)`" if(CommonSettings.RetailCardProtection8000) - if(address < 0x8000) - address = (0x8000 + (address & 0x1FF)); + if(this->_address < 0x8000) + this->_address = (0x8000 + (this->_address & 0x1FF)); //1. as a sanity measure for funny-sized roms (homebrew and perhaps truncated retail roms) we need to protect ourselves by returning 0xFF for things still out of range. //2. this isnt right, unless someone documents otherwise: @@ -73,16 +73,16 @@ u32 Slot1Comp_Rom::read() // ... the cart hardware doesnt know anything about the rom header. if it has a totally bogus endROMoffset, the cart will probably work just fine. and, the +4 is missing anyway: //3. this is better: it just allows us to read 0xFF anywhere we dont have rom data. forget what the header says //note: we allow the reading to proceed anyway, because the readROM method is built to allow jaggedy reads off the end of the rom to support trimmed roms - if(address+4 > gameInfo.romsize) + if(this->_address+4 > gameInfo.romsize) { - DEBUG_Notify.ReadBeyondEndOfCart(address,gameInfo.romsize); + DEBUG_Notify.ReadBeyondEndOfCart(this->_address,gameInfo.romsize); } //actually read from the ROM provider - u32 ret = gameInfo.readROM(address); + u32 ret = gameInfo.readROM(this->_address); //"However, the datastream wraps to the begin of the current 4K block when address+length crosses a 4K boundary (1000h bytes)" - address = (address&~0xFFF) + ((address+4)&0xFFF); + this->_address = (this->_address&~0xFFF) + ((this->_address+4)&0xFFF); return ret; } @@ -96,14 +96,14 @@ u32 Slot1Comp_Rom::read() u32 Slot1Comp_Rom::getAddress() { - return address & gameInfo.mask; + return this->_address & gameInfo.mask; } //Slot1Comp_Rom::getAddress() u32 Slot1Comp_Rom::incAddress() { - address &= gameInfo.mask; - address = (address&~0xFFF) + ((address+4)&0xFFF); - return address; + this->_address &= gameInfo.mask; + this->_address = (this->_address&~0xFFF) + ((this->_address+4)&0xFFF); + return this->_address; } @@ -111,13 +111,13 @@ void Slot1Comp_Rom::savestate(EMUFILE &os) { s32 version = 0; os.write_32LE(version); - os.write_32LE((s32)operation); - os.write_32LE(address); + os.write_32LE((s32)this->_operation); + os.write_32LE(this->_address); } void Slot1Comp_Rom::loadstate(EMUFILE &is) { s32 version = is.read_s32LE(); - operation = (eSlot1Operation)is.read_s32LE(); - address = is.read_u32LE(); + this->_operation = (eSlot1Operation)is.read_s32LE(); + this->_address = is.read_u32LE(); } diff --git a/desmume/src/addons/slot1comp_rom.h b/desmume/src/addons/slot1comp_rom.h index 229f8eccb..4e563995c 100644 --- a/desmume/src/addons/slot1comp_rom.h +++ b/desmume/src/addons/slot1comp_rom.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2010-2015 DeSmuME team + Copyright (C) 2010-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,8 +38,8 @@ public: void loadstate(EMUFILE &is); private: - u32 address; - eSlot1Operation operation; + u32 _address; + eSlot1Operation _operation; }; #endif diff --git a/desmume/src/addons/slot2_gbagame.cpp b/desmume/src/addons/slot2_gbagame.cpp index b701b94a8..67acb7141 100644 --- a/desmume/src/addons/slot2_gbagame.cpp +++ b/desmume/src/addons/slot2_gbagame.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2009 CrazyMax - Copyright (C) 2009-2016 DeSmuME team + Copyright (C) 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -106,8 +106,8 @@ private: int len = fROM->size(); for(;;) { - u32 tmp; - u32 readed = fROM->fread(&tmp, 4); + u32 romType = 0; + u32 readed = fROM->fread(&romType, 4); int pos = fROM->ftell(); int currPct = pos*100/(size-1); @@ -126,7 +126,7 @@ private: break; - switch (tmp) + switch (romType) { case EEPROM: return 1; @@ -139,6 +139,9 @@ private: } case SIIRTC_V: return 4; + + default: + break; } } diff --git a/desmume/src/armcpu.cpp b/desmume/src/armcpu.cpp index 66bf9c7c3..68bf57cad 100644 --- a/desmume/src/armcpu.cpp +++ b/desmume/src/armcpu.cpp @@ -146,7 +146,7 @@ int armcpu_new( armcpu_t *armcpu, u32 id) armcpu->post_ex_fn = NULL; armcpu->post_ex_fn_data = NULL; - armcpu->breakPoints = new std::vector; + armcpu->breakPoints = new std::vector; armcpu_init(armcpu, 0); diff --git a/desmume/src/armcpu.h b/desmume/src/armcpu.h index 4369fa09e..ea9354582 100644 --- a/desmume/src/armcpu.h +++ b/desmume/src/armcpu.h @@ -310,10 +310,10 @@ struct armcpu_t armcpu_ctrl_iface ctrl_iface; // debugging stuff - int runToRetTmp; + u32 runToRetTmp; bool runToRet; - int stepOverBreak; - std::vector *breakPoints; + u32 stepOverBreak; + std::vector *breakPoints; bool debugStep; }; diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index a5860f545..00d50e5e5 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2019 DeSmuME team + Copyright (C) 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -121,7 +121,7 @@ static void CheatWrite(int size, int proc, u32 addr, u32 val) } -void CHEATS::ARparser(CHEATS_LIST& list) +void CHEATS::ARparser(CHEATS_LIST& theList) { //primary organizational source (seems to be referenced by cheaters the most) - http://doc.kodewerx.org/hacking_nds.html //secondary clarification and details (for programmers) - http://problemkaputt.de/gbatek.htm#dscartcheatactionreplayds @@ -167,18 +167,18 @@ void CHEATS::ARparser(CHEATS_LIST& list) CHEATLOG("-----------------------------------\n"); - for (u32 i=0; i < list.num; i++) + for (u32 i = 0; i < theList.num; i++) { - const u32 hi = list.code[i][0]; - const u32 lo = list.code[i][1]; + const u32 hi = theList.code[i][0]; + const u32 lo = theList.code[i][1]; CHEATLOG("executing [%02d] %08X %08X (ofs=%08X)\n",i, hi,lo, st.offset); //parse codes into types by kodewerx standards - u32 type = list.code[i][0] >> 28; + u32 type = theList.code[i][0] >> 28; //these two are broken down into subtypes if(type == 0x0C || type == 0x0D) - type = list.code[i][0] >> 24; + type = theList.code[i][0] >> 24; //process current execution status: u32 statusSkip = st.status & 1; @@ -568,9 +568,9 @@ void CHEATS::ARparser(CHEATS_LIST& list) if(y>0) i++; //skip over the current code while(y>=4) { - if(i==list.num) break; //if we erroneously went off the end, bail - u32 tmp = list.code[i][t]; - if(t==1) i++; + if (i == theList.num) break; //if we erroneously went off the end, bail + u32 tmp = theList.code[i][t]; + if (t == 1) i++; t ^= 1; CheatWrite(32,st.proc,addr,tmp); addr += 4; @@ -578,8 +578,8 @@ void CHEATS::ARparser(CHEATS_LIST& list) } while(y>0) { - if(i==list.num) break; //if we erroneously went off the end, bail - u32 tmp = list.code[i][t]>>b; + if (i == theList.num) break; //if we erroneously went off the end, bail + u32 tmp = theList.code[i][t]>>b; CheatWrite(8,st.proc,addr,tmp); addr += 1; y -= 1; @@ -604,7 +604,7 @@ void CHEATS::ARparser(CHEATS_LIST& list) operand = x; //mis-use of this variable to store dst while(y>=4) { - if(i==list.num) break; //if we erroneously went off the end, bail + if (i == theList.num) break; //if we erroneously went off the end, bail u32 tmp = _MMU_read32(st.proc,MMU_AT_DEBUG,addr); CheatWrite(32, st.proc,operand,tmp); addr += 4; @@ -613,7 +613,7 @@ void CHEATS::ARparser(CHEATS_LIST& list) } while(y>0) { - if(i==list.num) break; //if we erroneously went off the end, bail + if (i == theList.num) break; //if we erroneously went off the end, bail u8 tmp = _MMU_read08(st.proc,MMU_AT_DEBUG,addr); CheatWrite(8,st.proc,operand,tmp); addr += 1; @@ -821,7 +821,7 @@ BOOL CHEATS::save() sprintf(buf1, "%s %c ", types[list[i].type], list[i].enabled?'1':'0'); cheatLineStr = buf1; - for (int t = 0; t < list[i].num; t++) + for (u32 t = 0; t < list[i].num; t++) { char buf2[10] = { 0 }; @@ -946,7 +946,7 @@ BOOL CHEATS::load() INFO("Cheats: Too many values for internal cheat\n", line); continue; } - for (int i = 0; i < tmp_cht.num; i++) + for (u32 i = 0; i < tmp_cht.num; i++) { char tmp_buf[9] = {0}; @@ -1044,13 +1044,13 @@ void CHEATS::process(int targetType) #endif } -void CHEATS::getXXcodeString(CHEATS_LIST list, char *res_buf) +void CHEATS::getXXcodeString(CHEATS_LIST theList, char *res_buf) { - char buf[50] = { 0 }; + char buf[50] = { 0 }; - for (int i=0; i < list.num; i++) + for (u32 i = 0; i < theList.num; i++) { - sprintf(buf, "%08X %08X\n", list.code[i][0], list.code[i][1]); + sprintf(buf, "%08X %08X\n", theList.code[i][0], theList.code[i][1]); strcat(res_buf, buf); } } @@ -1564,9 +1564,9 @@ bool CHEATSEXPORT::search() } if (!dataSize) return false; CRC = fat.CRC; - char buf[5] = {0}; - memcpy(&buf, &fat.serial[0], 4); - printf("Cheats: found %s CRC %08X at 0x%08llX, size %i byte(s)\n", buf, fat.CRC, fat.addr, dataSize - encOffset); + char serialBuf[5] = {0}; + memcpy(&serialBuf, &fat.serial[0], 4); + printf("Cheats: found %s CRC %08X at 0x%08llX, size %i byte(s)\n", serialBuf, fat.CRC, fat.addr, dataSize - encOffset); return true; } @@ -1600,13 +1600,13 @@ bool CHEATSEXPORT::getCodes() if (encrypted) R4decrypt(data, dataSize, fat.addr >> 9); - intptr_t ptrMask = (~0 << 2); + uintptr_t ptrMask = ~(uintptr_t)0 << 2; u8 *gameTitlePtr = (u8 *)data + encOffset; memset(gametitle, 0, CHEAT_DB_GAME_TITLE_SIZE); memcpy(gametitle, gameTitlePtr, strlen((const char *)gameTitlePtr)); - u32 *cmd = (u32 *)(((intptr_t)gameTitlePtr + strlen((const char *)gameTitlePtr) + 4) & ptrMask); + u32 *cmd = (u32 *)(((uintptr_t)gameTitlePtr + strlen((const char *)gameTitlePtr) + 4) & ptrMask); numCheats = cmd[0] & 0x0FFFFFFF; cmd += 9; cheats = new CHEATS_LIST[numCheats]; @@ -1620,17 +1620,17 @@ bool CHEATSEXPORT::getCodes() if ((*cmd & 0xF0000000) == 0x10000000) // Folder { folderNum = (*cmd & 0x00FFFFFF); - folderName = (u8*)((intptr_t)cmd + 4); - folderNote = (u8*)((intptr_t)folderName + strlen((char*)folderName) + 1); + folderName = (u8*)((uintptr_t)cmd + 4); + folderNote = (u8*)((uintptr_t)folderName + strlen((char*)folderName) + 1); pos++; - cmd = (u32 *)(((intptr_t)folderName + strlen((char*)folderName) + 1 + strlen((char*)folderNote) + 1 + 3) & ptrMask); + cmd = (u32 *)(((uintptr_t)folderName + strlen((char*)folderName) + 1 + strlen((char*)folderNote) + 1 + 3) & ptrMask); } for (u32 i = 0; i < folderNum; i++) // in folder { - u8 *cheatName = (u8 *)((intptr_t)cmd + 4); - u8 *cheatNote = (u8 *)((intptr_t)cheatName + strlen((char*)cheatName) + 1); - u32 *cheatData = (u32 *)(((intptr_t)cheatNote + strlen((char*)cheatNote) + 1 + 3) & ptrMask); + u8 *cheatName = (u8 *)((uintptr_t)cmd + 4); + u8 *cheatNote = (u8 *)((uintptr_t)cheatName + strlen((char*)cheatName) + 1); + u32 *cheatData = (u32 *)(((uintptr_t)cheatNote + strlen((char*)cheatNote) + 1 + 3) & ptrMask); u32 cheatDataLen = *cheatData++; u32 numberCodes = cheatDataLen / 2; @@ -1670,7 +1670,7 @@ bool CHEATSEXPORT::getCodes() } pos++; - cmd = (u32 *)((intptr_t)cmd + ((*cmd + 1)*4)); + cmd = (u32 *)((uintptr_t)cmd + ((*cmd + 1)*4)); } }; diff --git a/desmume/src/cheatSystem.h b/desmume/src/cheatSystem.h index 502be154e..855d0a9b7 100644 --- a/desmume/src/cheatSystem.h +++ b/desmume/src/cheatSystem.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2015 DeSmuME team + Copyright (C) 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ struct CHEATS_LIST // 2 - can increase u32 code[MAX_XX_CODE][2]; char description[1024]; - int num; + u32 num; u8 size; }; @@ -93,7 +93,7 @@ public: BOOL save(); BOOL load(); void process(int targetType); - void getXXcodeString(CHEATS_LIST cheat, char *res_buf); + void getXXcodeString(CHEATS_LIST theList, char *res_buf); static BOOL XXCodeFromString(CHEATS_LIST *cheatItem, const std::string codeString); static BOOL XXCodeFromString(CHEATS_LIST *cheatItem, const char *codeString); diff --git a/desmume/src/emufile.cpp b/desmume/src/emufile.cpp index 9aae7099f..e24b9ffe2 100644 --- a/desmume/src/emufile.cpp +++ b/desmume/src/emufile.cpp @@ -1,7 +1,7 @@ /* The MIT License -Copyright (C) 2009-2019 DeSmuME team +Copyright (C) 2009-2021 DeSmuME team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -90,7 +90,7 @@ size_t EMUFILE_MEMORY::_fread(const void *ptr, size_t bytes){ u32 todo = std::min(remain,(u32)bytes); if(len==0) { - failbit = true; + this->_failbit = true; return 0; } if(todo<=4) @@ -106,43 +106,43 @@ size_t EMUFILE_MEMORY::_fread(const void *ptr, size_t bytes){ } pos += todo; if(todo_failbit = true; return todo; } void EMUFILE_FILE::truncate(s32 length) { - ::fflush(fp); + ::fflush(this->_fp); #ifdef HOST_WINDOWS - _chsize(_fileno(fp),length); + _chsize(_fileno(this->_fp),length); #else - ftruncate(fileno(fp),length); + ftruncate(fileno(this->_fp),length); #endif - fclose(fp); - fp = NULL; - open(fname.c_str(),mode); + fclose(this->_fp); + this->_fp = NULL; + this->__open(this->_fname.c_str(), this->_mode); } int EMUFILE_FILE::fseek(int offset, int origin) { //if the position cache is enabled, and the seek offset matches the known current position, then early exit. - if(mPositionCacheEnabled) + if (this->_mPositionCacheEnabled) { - if(origin == SEEK_SET) + if (origin == SEEK_SET) { - if(mFilePosition == offset) + if (this->_mFilePosition == offset) { return 0; } } } - mCondition = eCondition_Clean; + this->_mCondition = eCondition_Clean; - int ret = ::fseek(fp, offset, origin); + int ret = ::fseek(this->_fp, offset, origin); - if(mPositionCacheEnabled) - mFilePosition = ::ftell(fp); + if (this->_mPositionCacheEnabled) + this->_mFilePosition = ::ftell(this->_fp); return ret; } @@ -150,53 +150,54 @@ int EMUFILE_FILE::fseek(int offset, int origin) int EMUFILE_FILE::ftell() { - if(mPositionCacheEnabled) - return (int)mFilePosition; - return (u32)::ftell(fp); + if (this->_mPositionCacheEnabled) + return (int)this->_mFilePosition; + return (u32)::ftell(this->_fp); } void EMUFILE_FILE::DemandCondition(eCondition cond) { //allows switching between reading and writing; an fseek is required, under the circumstances - if(mCondition == eCondition_Clean) + if( this->_mCondition == eCondition_Clean) goto CONCLUDE; - if(mCondition == eCondition_Unknown) + if (this->_mCondition == eCondition_Unknown) goto RESET; - if(mCondition != cond) + if (this->_mCondition != cond) goto RESET; return; RESET: - ::fseek(fp,::ftell(fp),SEEK_SET); + ::fseek(this->_fp,::ftell(this->_fp),SEEK_SET); CONCLUDE: - mCondition = cond; + this->_mCondition = cond; } size_t EMUFILE_FILE::_fread(const void *ptr, size_t bytes) { DemandCondition(eCondition_Read); - size_t ret = ::fread((void*)ptr, 1, bytes, fp); - mFilePosition += ret; - if(ret < bytes) - failbit = true; + size_t ret = ::fread((void*)ptr, 1, bytes, this->_fp); + this->_mFilePosition += ret; + if (ret < bytes) + this->_failbit = true; + return ret; } void EMUFILE_FILE::EnablePositionCache() { - mPositionCacheEnabled = true; - mFilePosition = ::ftell(fp); + this->_mPositionCacheEnabled = true; + this->_mFilePosition = ::ftell(this->_fp); } size_t EMUFILE_FILE::fwrite(const void *ptr, size_t bytes) { DemandCondition(eCondition_Write); - size_t ret = ::fwrite((void*)ptr, 1, bytes, fp); - mFilePosition += ret; - if(ret < bytes) - failbit = true; + size_t ret = ::fwrite((void*)ptr, 1, bytes, this->_fp); + this->_mFilePosition += ret; + if (ret < bytes) + this->_failbit = true; return ret; } @@ -511,19 +512,22 @@ size_t EMUFILE::read_MemoryStream(EMUFILE_MEMORY &ms) return 1; } -void EMUFILE_FILE::open(const char* fname, const char* mode) +void EMUFILE_FILE::__open(const char* fname, const char* mode) { - mPositionCacheEnabled = false; - mCondition = eCondition_Clean; - mFilePosition = 0; + this->_mPositionCacheEnabled = false; + this->_mCondition = eCondition_Clean; + this->_mFilePosition = 0; + #ifdef HOST_WINDOWS auto tmp = mbstowcs((std::string)fname); - fp = _wfopen(tmp.c_str(),mbstowcs(mode).c_str()); + this->_fp = _wfopen(tmp.c_str(),mbstowcs(mode).c_str()); #else - fp = fopen(fname,mode); + this->_fp = fopen(fname, mode); #endif - if(!fp) - failbit = true; - this->fname = fname; - strcpy(this->mode,mode); + + if (this->_fp == NULL) + this->_failbit = true; + + this->_fname = fname; + strcpy(this->_mode, mode); } diff --git a/desmume/src/emufile.h b/desmume/src/emufile.h index bce46d9cf..29d58b23d 100644 --- a/desmume/src/emufile.h +++ b/desmume/src/emufile.h @@ -1,7 +1,7 @@ /* The MIT License -Copyright (C) 2009-2017 DeSmuME team +Copyright (C) 2009-2021 DeSmuME team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -47,11 +47,11 @@ class EMUFILE_MEMORY; class EMUFILE { protected: - bool failbit; + bool _failbit; public: EMUFILE() - : failbit(false) + : _failbit(false) {} @@ -62,8 +62,8 @@ public: static bool readAllBytes(std::vector* buf, const std::string& fname); - bool fail(bool unset=false) { bool ret = failbit; if(unset) unfail(); return ret; } - void unfail() { failbit=false; } + bool fail(bool unset=false) { bool ret = this->_failbit; if(unset) unfail(); return ret; } + void unfail() { this->_failbit = false; } bool eof() { return size()==ftell(); } @@ -220,7 +220,7 @@ public: //else return temp; u32 remain = len-pos; if(remain<1) { - failbit = true; + this->_failbit = true; return -1; } temp = buf()[pos]; @@ -286,11 +286,11 @@ public: class EMUFILE_FILE : public EMUFILE { protected: - FILE* fp; - std::string fname; - char mode[16]; - long mFilePosition; - bool mPositionCacheEnabled; + FILE* _fp; + std::string _fname; + char _mode[16]; + long _mFilePosition; + bool _mPositionCacheEnabled; enum eCondition { @@ -298,30 +298,30 @@ protected: eCondition_Unknown, eCondition_Read, eCondition_Write - } mCondition; + } _mCondition; private: - void open(const char* fname, const char* mode); + void __open(const char* fname, const char* mode); public: - EMUFILE_FILE(const std::string& fname, const char* mode) { open(fname.c_str(),mode); } - EMUFILE_FILE(const char* fname, const char* mode) { open(fname,mode); } + EMUFILE_FILE(const std::string& fname, const char* mode) { __open(fname.c_str(),mode); } + EMUFILE_FILE(const char* fname, const char* mode) { __open(fname,mode); } void EnablePositionCache(); virtual ~EMUFILE_FILE() { - if(NULL != fp) - fclose(fp); + if (NULL != this->_fp) + fclose(this->_fp); } virtual FILE *get_fp() { - return fp; + return this->_fp; } virtual EMUFILE* memwrap(); - bool is_open() { return fp != NULL; } + bool is_open() { return this->_fp != NULL; } void DemandCondition(eCondition cond); @@ -330,20 +330,20 @@ public: virtual int fprintf(const char *format, ...) { va_list argptr; va_start(argptr, format); - int ret = ::vfprintf(fp, format, argptr); + int ret = ::vfprintf(this->_fp, format, argptr); va_end(argptr); return ret; }; virtual int fgetc() { - return ::fgetc(fp); + return ::fgetc(this->_fp); } virtual int fputc(int c) { - return ::fputc(c, fp); + return ::fputc(c, this->_fp); } virtual char* fgets(char* str, int num) { - return ::fgets(str, num, fp); + return ::fgets(str, num, this->_fp); } virtual size_t _fread(const void *ptr, size_t bytes); @@ -362,7 +362,7 @@ public: } virtual void fflush() { - ::fflush(fp); + ::fflush(this->_fp); } }; diff --git a/desmume/src/filter/videofilter.cpp b/desmume/src/filter/videofilter.cpp index 5381bc2ee..f44249486 100644 --- a/desmume/src/filter/videofilter.cpp +++ b/desmume/src/filter/videofilter.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2011-2012 Roger Manuel - Copyright (C) 2013-2019 DeSmuME team + Copyright (C) 2013-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -189,7 +189,7 @@ void VideoFilter::__InstanceInit(size_t srcWidth, size_t srcHeight, VideoFilterT __vfThread[i].task = new Task; char name[16]; - snprintf(name, 16, "video filter %d", i); + snprintf(name, 16, "video filter %d", (int)i); __vfThread[i].task->start(false, 0, name); } diff --git a/desmume/src/frontend/cocoa/cocoa_GPU.mm b/desmume/src/frontend/cocoa/cocoa_GPU.mm index e8f32d433..af213168d 100644 --- a/desmume/src/frontend/cocoa/cocoa_GPU.mm +++ b/desmume/src/frontend/cocoa/cocoa_GPU.mm @@ -355,7 +355,7 @@ public: const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo(); - if (colorFormat != dispInfo.colorFormat) + if (dispInfo.colorFormat != (NDSColorFormat)colorFormat) { #ifdef ENABLE_SHARED_FETCH_OBJECT const size_t maxPages = GPU->GetDisplayInfo().framebufferPageCount; @@ -521,7 +521,7 @@ public: CommonSettings.num_cores = numberCores; - if (renderingEngineID == CORE3DLIST_SWRASTERIZE) + if (renderingEngineID == RENDERID_SOFTRASTERIZER) { GPU->Set3DRendererByID(renderingEngineID); } @@ -558,7 +558,7 @@ public: { gpuEvent->ApplyRender3DSettingsLock(); - const int currentMSAASize = CommonSettings.GFX3D_Renderer_MultisampleSize; + const NSUInteger currentMSAASize = (NSUInteger)CommonSettings.GFX3D_Renderer_MultisampleSize; if (currentMSAASize != msaaSize) { @@ -644,8 +644,8 @@ public: msaaSize = openglDeviceMaxMultisamples; } - msaaSize = GetNearestPositivePOT(msaaSize); - CommonSettings.GFX3D_Renderer_MultisampleSize = msaaSize; + msaaSize = GetNearestPositivePOT((uint32_t)msaaSize); + CommonSettings.GFX3D_Renderer_MultisampleSize = (int)msaaSize; } gpuEvent->ApplyRender3DSettingsUnlock(); diff --git a/desmume/src/frontend/cocoa/userinterface/DisplayWindowController.mm b/desmume/src/frontend/cocoa/userinterface/DisplayWindowController.mm index 97b7b7d89..5c183ae39 100644 --- a/desmume/src/frontend/cocoa/userinterface/DisplayWindowController.mm +++ b/desmume/src/frontend/cocoa/userinterface/DisplayWindowController.mm @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 DeSmuME team + Copyright (C) 2013-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2078,9 +2078,10 @@ static std::unordered_map _screenMap; // CocoaDSCore *cdsCore = (CocoaDSCore *)[[[windowController emuControl] cdsCoreController] content]; CocoaDSGPU *cdsGPU = [cdsCore cdsGPU]; MacClientSharedObject *macSharedData = [cdsGPU sharedData]; - BOOL isMetalLayer = NO; #ifdef ENABLE_APPLE_METAL + BOOL isMetalLayer = NO; + if ((macSharedData != nil) && [macSharedData isKindOfClass:[MetalDisplayViewSharedData class]]) { if ([(MetalDisplayViewSharedData *)macSharedData device] != nil) diff --git a/desmume/src/frontend/cocoa/userinterface/preferencesWindowDelegate.mm b/desmume/src/frontend/cocoa/userinterface/preferencesWindowDelegate.mm index 4b19a91ed..ad8a46581 100644 --- a/desmume/src/frontend/cocoa/userinterface/preferencesWindowDelegate.mm +++ b/desmume/src/frontend/cocoa/userinterface/preferencesWindowDelegate.mm @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Roger Manuel - Copyright (C) 2012-2018 DeSmuME Team + Copyright (C) 2012-2021 DeSmuME Team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -999,7 +999,7 @@ - (void) markUnsupportedOpenGLMSAAMenuItems { CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; - NSUInteger maxSamples = [[cdsCore cdsGPU] openglDeviceMaxMultisamples]; + NSInteger maxSamples = (NSInteger)[[cdsCore cdsGPU] openglDeviceMaxMultisamples]; size_t itemCount = [openglMSAAPopUpButton numberOfItems]; BOOL needAddUnsupportedSeparator = YES; diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 7f9f0e5dd..2df3f3dfc 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2006 yopyop - Copyright (C) 2008-2019 DeSmuME team + Copyright (C) 2008-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -538,7 +538,7 @@ void gfx3d_init() // in this case. if (polylists == NULL) { - polylists = (POLYLIST *)malloc(sizeof(POLYLIST)*2); + polylists = (POLYLIST *)malloc_alignedPage(sizeof(POLYLIST) * 2); polylist = &polylists[0]; } @@ -565,7 +565,7 @@ void gfx3d_deinit() { Render3D_DeInit(); - free(polylists); + free_aligned(polylists); polylists = NULL; polylist = NULL; @@ -982,7 +982,7 @@ static void gfx3d_glLightDirection_cache(const size_t index) MatrixMultVec3x3(mtxCurrent[MATRIXMODE_POSITION_VECTOR], cacheLightDirection[index]); //Calculate the half angle vector - s32 lineOfSight[4] = {0, 0, (-1)<<12, 0}; + s32 lineOfSight[4] = {0, 0, 0xFFFFF000, 0}; for (size_t i = 0; i < 4; i++) { cacheHalfVector[index][i] = ((cacheLightDirection[index][i] + lineOfSight[i])); @@ -2416,7 +2416,7 @@ void gfx3d_GenerateRenderLists(const ClipperMode clippingMode) verty = 1.0f-(verty+vertw)/(2*vertw); poly.miny = poly.maxy = verty; - for (size_t j = 1; j < poly.type; j++) + for (size_t j = 1; j < (size_t)poly.type; j++) { verty = gfx3d.vertList[poly.vertIndexes[j]].y; vertw = (gfx3d.vertList[poly.vertIndexes[j]].w != 0.0f) ? gfx3d.vertList[poly.vertIndexes[j]].w : 0.00000001f; @@ -3355,7 +3355,7 @@ bool GFX3D_Clipper::ClipPoly(const u16 polyIndex, const POLY &poly, const VERT * CLIPLOG("==Begin poly==\n"); PolygonType outType; - const PolygonType type = poly.type; + const PolygonType polyType = poly.type; numScratchClipVerts = 0; switch (CLIPPERMODE) @@ -3363,7 +3363,7 @@ bool GFX3D_Clipper::ClipPoly(const u16 polyIndex, const POLY &poly, const VERT * case ClipperMode_Full: { clipper1.init(this->_clippedPolyList[this->_clippedPolyCounter].clipVerts); - for (size_t i = 0; i < type; i++) + for (size_t i = 0; i < (size_t)polyType; i++) clipper1.clipVert(verts[i]); outType = (PolygonType)clipper1.finish(); @@ -3373,7 +3373,7 @@ bool GFX3D_Clipper::ClipPoly(const u16 polyIndex, const POLY &poly, const VERT * case ClipperMode_FullColorInterpolate: { clipper1i.init(this->_clippedPolyList[this->_clippedPolyCounter].clipVerts); - for (size_t i = 0; i < type; i++) + for (size_t i = 0; i < (size_t)polyType; i++) clipper1i.clipVert(verts[i]); outType = (PolygonType)clipper1i.finish(); @@ -3383,7 +3383,7 @@ bool GFX3D_Clipper::ClipPoly(const u16 polyIndex, const POLY &poly, const VERT * case ClipperMode_DetermineClipOnly: { clipper1d.init(this->_clippedPolyList[this->_clippedPolyCounter].clipVerts); - for (size_t i = 0; i < type; i++) + for (size_t i = 0; i < (size_t)polyType; i++) clipper1d.clipVert(verts[i]); outType = (PolygonType)clipper1d.finish(); diff --git a/desmume/src/lua-engine.cpp b/desmume/src/lua-engine.cpp index ce5934241..13e381129 100644 --- a/desmume/src/lua-engine.cpp +++ b/desmume/src/lua-engine.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2019 DeSmuME team + Copyright (C) 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2261,7 +2261,7 @@ public: virtual size_t fwrite(const void *ptr, size_t bytes) { - if(!failbit) + if(!this->_failbit) { u8* dst = buf()+pos; const u8* src = (const u8*)ptr; @@ -2271,7 +2271,7 @@ public: if(*src != *dst) { if(differences.size() == 100) - failbit = true; + this->_failbit = true; else { const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo(); diff --git a/desmume/src/mc.cpp b/desmume/src/mc.cpp index 2823efdad..2680927ae 100644 --- a/desmume/src/mc.cpp +++ b/desmume/src/mc.cpp @@ -1,7 +1,7 @@ /* Copyright (C) 2006 thoduv Copyright (C) 2006-2007 Theo Berkau - Copyright (C) 2008-2018 DeSmuME team + Copyright (C) 2008-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1554,8 +1554,8 @@ bool BackupDevice::import_duc(const char* filename, u32 force_size) fseek(file, 0xA4, SEEK_SET); //validate size - int specifiedSize = (id3[0]<<8)+(id3[1]<<16); - if(specifiedSize != size) + const u32 specifiedSize = ((u32)id3[0] << 8) + ((u32)id3[1] << 16); + if (specifiedSize != size) goto INVALID_DUC; } diff --git a/desmume/src/metaspu/Timestretcher.cpp b/desmume/src/metaspu/Timestretcher.cpp index b1b854db4..ceac059f2 100644 --- a/desmume/src/metaspu/Timestretcher.cpp +++ b/desmume/src/metaspu/Timestretcher.cpp @@ -249,7 +249,7 @@ static void CvtPacketToFloat( StereoOut32* srcdest ) { StereoOutFloat* dest = (StereoOutFloat*)srcdest; const StereoOut32* src = (StereoOut32*)srcdest; - for( uint i=0; i i) { char tmp[32]; - sprintf(tmp,"micsample%d",i); + sprintf(tmp,"micsample%d", (int)i); fp.fprintf("%s %s\n",tmp, BytesToString(&micSamples[i][0],micSamples[i].size()).c_str()); } } diff --git a/desmume/src/path.cpp b/desmume/src/path.cpp index baeb1b691..5e5e05310 100644 --- a/desmume/src/path.cpp +++ b/desmume/src/path.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2016 DeSmuME team + Copyright (C) 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -100,7 +100,7 @@ std::string Path::ScrubInvalid(std::string str) for (std::string::iterator it(str.begin()); it != str.end(); ++it) { bool ok = true; - for(int i=0;i::Render() const CPoly &clippedPoly = this->_softRender->GetClippedPolyByIndex(i); const POLY &thePoly = *clippedPoly.poly; - const int vertCount = clippedPoly.type; + const size_t vertCount = (size_t)clippedPoly.type; const bool useLineHack = USELINEHACK && (thePoly.vtxFormat & 4); polyAttr = thePoly.attribute; @@ -1666,8 +1666,8 @@ void SoftRasterizerTexture::SetScalingFactor(size_t scalingFactor) scalingFactor = 1; } - u32 newWidth = this->_sizeS * scalingFactor; - u32 newHeight = this->_sizeT * scalingFactor; + s32 newWidth = (s32)(this->_sizeS * scalingFactor); + s32 newHeight = (s32)(this->_sizeT * scalingFactor); if (this->_renderWidth != newWidth || this->_renderHeight != newHeight) { @@ -1875,7 +1875,7 @@ void SoftRasterizerRenderer::_TransformVertices() for (size_t i = 0; i < this->_clippedPolyCount; i++) { CPoly &poly = this->_clippedPolyList[i]; - for (size_t j = 0; j < poly.type; j++) + for (size_t j = 0; j < (size_t)poly.type; j++) { VERT &vert = poly.clipVerts[j]; diff --git a/desmume/src/slot1.cpp b/desmume/src/slot1.cpp index 30d2be2c2..bf7285bc4 100644 --- a/desmume/src/slot1.cpp +++ b/desmume/src/slot1.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2010-2013 DeSmuME team + Copyright (C) 2010-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -112,7 +112,7 @@ void slot1_Init() void slot1_Shutdown() { - for(int i=0;ishutdown(); diff --git a/desmume/src/utils/emufat.cpp b/desmume/src/utils/emufat.cpp index 1a6c5575a..386ff1803 100644 --- a/desmume/src/utils/emufat.cpp +++ b/desmume/src/utils/emufat.cpp @@ -1,5 +1,5 @@ /* - Copyright 2009-2015 DeSmuME team + Copyright 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,11 +18,11 @@ //based on Arduino SdFat Library ( http://code.google.com/p/sdfatlib/ ) //Copyright (C) 2009 by William Greiman -//based on mkdosfs - utility to create FAT/MS-DOS filesystems -//Copyright (C) 1991 Linus Torvalds -//Copyright (C) 1992-1993 Remy Card -//Copyright (C) 1993-1994 David Hudson -//Copyright (C) 1998 H. Peter Anvin +//based on mkdosfs - utility to create FAT/MS-DOS filesystems +//Copyright (C) 1991 Linus Torvalds +//Copyright (C) 1992-1993 Remy Card +//Copyright (C) 1993-1994 David Hudson +//Copyright (C) 1998 H. Peter Anvin //Copyright (C) 1998-2005 Roman Hodek #include "emufat.h" @@ -557,15 +557,15 @@ bool EmuFatVolume::formatNew(u32 sectors) dev_->writeBlock(bs->fat32.fat32BackBootBlock,(const u8*)bs); } /* seek to start of FATS and write them all */ - int ctr=bs->reservedSectorCount; - for (int i=0;ifatCount;i++) - for(int j=0;jwriteBlock(ctr,fat+j*sector_size); + u32 ctr = bs->reservedSectorCount; + for (u8 i = 0; i < bs->fatCount; i++) + for (u32 j = 0; j < fat_length; j++, ctr++) + dev_->writeBlock(ctr, fat+j*sector_size); /* Write the root directory directly after the last FAT. This is the root * dir area on FAT12/16, and the first cluster on FAT32. */ - for(int i=0;iwriteBlock(ctr,blank_sector); + for (u32 i = 0; i < size_root_dir_in_sectors; i++) + dev_->writeBlock(ctr, blank_sector); delete[] blank_sector; delete[] info_sector; @@ -1260,7 +1260,7 @@ u8 EmuFatFile::open(EmuFatFile* dirFile, const char* fileName, u8 oflag) { * See open() by fileName for definition of flags and return values. * */ -u8 EmuFatFile::open(EmuFatFile* dirFile, u16 index, u8 oflag) { +u8 EmuFatFile::open(EmuFatFile* dirFile, u32 index, u8 oflag) { // error if already open if (isOpen())return false; @@ -1282,7 +1282,7 @@ u8 EmuFatFile::open(EmuFatFile* dirFile, u16 index, u8 oflag) { return false; } // open cached entry - return openCachedEntry(index & 0XF, oflag); + return openCachedEntry((u8)(index & 0x0F), oflag); } //------------------------------------------------------------------------------ @@ -1601,7 +1601,7 @@ u8 EmuFatFile::rmRfStar(void) { EmuFatFile f; // remember position - u16 index = curPosition_/32; + u32 index = curPosition_/32; TDirectoryEntry* p = readDirCache(); if (!p) return false; diff --git a/desmume/src/utils/emufat.h b/desmume/src/utils/emufat.h index bcfd82806..750befc70 100644 --- a/desmume/src/utils/emufat.h +++ b/desmume/src/utils/emufat.h @@ -1,5 +1,5 @@ /* - Copyright 2009-2015 DeSmuME team + Copyright 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -514,7 +514,7 @@ class EmuFatFile u8 timestamp(u8 flag, u16 year, u8 month, u8 day, u8 hour, u8 minute, u8 second); u8 sync(void); u8 makeDir(EmuFatFile* dir, const char* dirName); - u8 open(EmuFatFile* dirFile, u16 index, u8 oflag); + u8 open(EmuFatFile* dirFile, u32 index, u8 oflag); u8 open(EmuFatFile* dirFile, const char* fileName, u8 oflag); u8 remove(EmuFatFile* dirFile, const char* fileName); u8 remove(void);