diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 581996a21..a33d9f79e 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -1,7 +1,7 @@ /* Copyright (C) 2006 yopyop Copyright (C) 2007 shash - Copyright (C) 2007-2023 DeSmuME team + Copyright (C) 2007-2025 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 @@ -1457,11 +1457,11 @@ void DESMUME_FASTCALL MMU_writeToSPIData(u16 val) enum PM_Bits //from libnds { - PM_SOUND_AMP = BIT(0) , /*!< \brief Power the sound hardware (needed to hear stuff in GBA mode too) */ - PM_SOUND_MUTE = BIT(1), /*!< \brief Mute the main speakers, headphone output will still work. */ - PM_BACKLIGHT_BOTTOM = BIT(2), /*!< \brief Enable the top backlight if set */ - PM_BACKLIGHT_TOP = BIT(3) , /*!< \brief Enable the bottom backlight if set */ - PM_SYSTEM_PWR = BIT(6) , /*!< \brief Turn the power *off* if set */ + PM_SOUND_AMP = BIT(0), /*!< \brief Power the sound hardware (needed to hear stuff in GBA mode too) */ + PM_SOUND_MUTE = BIT(1), /*!< \brief Mute the main speakers, headphone output will still work. */ + PM_BACKLIGHT_BOTTOM = BIT(2), /*!< \brief Enable the top backlight if set */ + PM_BACKLIGHT_TOP = BIT(3), /*!< \brief Enable the bottom backlight if set */ + PM_SYSTEM_PWR = BIT(6) /*!< \brief Turn the power *off* if set */ }; if (val !=0) diff --git a/desmume/src/MMU.h b/desmume/src/MMU.h index eebcad627..261247be8 100644 --- a/desmume/src/MMU.h +++ b/desmume/src/MMU.h @@ -1,7 +1,7 @@ /* Copyright (C) 2006 yopyop Copyright (C) 2007 shash - Copyright (C) 2007-2023 DeSmuME team + Copyright (C) 2007-2025 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,6 +88,8 @@ enum EDMADestinationUpdate class TRegister_32 { public: + virtual ~TRegister_32() {} + virtual u32 read32() = 0; virtual void write32(const u32 val) = 0; void write(const int size, const u32 adr, const u32 val) { @@ -124,6 +126,9 @@ struct TGXSTAT : public TRegister_32 fifo_empty = true; fifo_low = false; } + + virtual ~TGXSTAT() {} + u8 tb; //test busy u8 tr; //test result u8 se; //stack error @@ -246,7 +251,10 @@ public: AddressRegister(u32* _ptr) : ptr(_ptr) {} - virtual u32 read32() { + + virtual ~AddressRegister() {} + + virtual u32 read32() { return *ptr; } virtual void write32(const u32 val) { @@ -259,7 +267,9 @@ public: //we pass in a pointer to the controller here so we can alert it if anything changes DmaController* controller; ControlRegister() {} - virtual u32 read32() { + virtual ~ControlRegister() {} + + virtual u32 read32() { return controller->read32(); } virtual void write32(const u32 val) { diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 24b087fe2..73ab19321 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -748,9 +748,9 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi int read = gameInfo.reader->Read(gameInfo.fROM,fROMBuffer,4096); if(read == 0) break; if(first && read >= 512) - gameInfo.crcForCheatsDb = ~crc32(0, fROMBuffer, 512); + gameInfo.crcForCheatsDb = (u32)~crc32(0, fROMBuffer, 512); first = false; - gameInfo.crc = crc32(gameInfo.crc, fROMBuffer, read); + gameInfo.crc = (u32)crc32(gameInfo.crc, fROMBuffer, read); } gameInfo.chipID = 0xC2; // The Manufacturer ID is defined by JEDEC (C2h = Macronix) @@ -2642,12 +2642,12 @@ bool NDS_FakeBoot() //perhaps we could automatically boot homebrew to an R4-like device. _MMU_write32(0x02FFFE70, 0x5f617267); _MMU_write32(0x02FFFE74, kCommandline); //(commandline starts here) - _MMU_write32(0x02FFFE78, rompath.size()+1); + _MMU_write32(0x02FFFE78, (u32)(rompath.size()+1)); //0x027FFF7C (argc) //0x027FFF80 (argv) - for(size_t i=0;i(kCommandline+i, rompath[i]); - _MMU_write08(kCommandline+rompath.size(), 0); + for (size_t i = 0; i < rompath.size(); i++) + _MMU_write08((u32)(kCommandline+i), rompath[i]); + _MMU_write08((u32)(kCommandline+rompath.size()), 0); //-------------------------------- //Call the card post_fakeboot hook to perform additional initialization diff --git a/desmume/src/SPU.cpp b/desmume/src/SPU.cpp index 96c449bbf..695e3add1 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-2021 DeSmuME team + Copyright (C) 2008-2025 DeSmuME team Ideas borrowed from Stephane Dallongeville's SCSP core @@ -176,7 +176,7 @@ int SPU_ChangeSoundCore(int coreid, int newBufferSizeBytes) return -1; // Since it failed, instead of it being fatal, disable the user spu - if (_currentSNDCore->Init(_currentBufferSize * 2) == -1) + if (_currentSNDCore->Init((int)(_currentBufferSize * 2)) == -1) { _currentSNDCore = 0; return -1; @@ -196,7 +196,7 @@ SoundInterface_struct *SPU_SoundCore() void SPU_ReInit(bool fakeBoot) { - SPU_Init(_currentSNDCoreId, _currentBufferSize); + SPU_Init(_currentSNDCoreId, (int)_currentBufferSize); // Firmware set BIAS to 0x200 if (fakeBoot) @@ -285,7 +285,7 @@ void SPU_SetSynchMode(int mode, int method) if (_currentSynchMode == ESynchMode_DualSynchAsynch) { - SPU_user = new SPU_struct(_currentBufferSize); + SPU_user = new SPU_struct((int)_currentBufferSize); SPU_CloneUser(); } } @@ -1702,15 +1702,15 @@ void SPU_Emulate_user(bool mix) processedSampleCount = SPU_DefaultPostProcessSamples(postProcessBuffer, freeSampleCount, _currentSynchMode, _currentSynchronizer); } - soundProcessor->UpdateAudio(postProcessBuffer, processedSampleCount); - WAV_WavSoundUpdate(postProcessBuffer, processedSampleCount, WAVMODE_USER); + soundProcessor->UpdateAudio(postProcessBuffer, (u32)processedSampleCount); + WAV_WavSoundUpdate(postProcessBuffer, (int)processedSampleCount, WAVMODE_USER); } void SPU_DefaultFetchSamples(s16 *sampleBuffer, size_t sampleCount, ESynchMode synchMode, ISynchronizingAudioBuffer *theSynchronizer) { if (synchMode == ESynchMode_Synchronous) { - theSynchronizer->enqueue_samples(sampleBuffer, sampleCount); + theSynchronizer->enqueue_samples(sampleBuffer, (int)sampleCount); } } @@ -1723,14 +1723,14 @@ size_t SPU_DefaultPostProcessSamples(s16 *postProcessBuffer, size_t requestedSam case ESynchMode_DualSynchAsynch: if(SPU_user != NULL) { - SPU_MixAudio(true, SPU_user, requestedSampleCount); + SPU_MixAudio(true, SPU_user, (int)requestedSampleCount); memcpy(postProcessBuffer, SPU_user->outbuf, requestedSampleCount * 2 * sizeof(s16)); processedSampleCount = requestedSampleCount; } break; case ESynchMode_Synchronous: - processedSampleCount = theSynchronizer->output_samples(postProcessBuffer, requestedSampleCount); + processedSampleCount = theSynchronizer->output_samples(postProcessBuffer, (int)requestedSampleCount); break; default: @@ -1864,7 +1864,7 @@ void WavWriter::update(void* soundData, int numSamples) { if(!spufp) return; //TODO - big endian for the s16 samples?? - size_t elems_written = fwrite(soundData, numSamples*2, 2, spufp); + fwrite(soundData, (size_t)(numSamples*2), 2, spufp); } bool WavWriter::isRecording() const @@ -1872,7 +1872,6 @@ bool WavWriter::isRecording() const return spufp != NULL; } - static WavWriter wavWriter; void WAV_End() diff --git a/desmume/src/addons/slot1_retail_mcrom_debug.cpp b/desmume/src/addons/slot1_retail_mcrom_debug.cpp index be050ad60..bd089ff4a 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-2021 DeSmuME team + Copyright (C) 2013-2025 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 @@ -193,7 +193,7 @@ private: if (fpROM) { u32 data = 0; - u32 readed = fread(&data, 1, 4, fpROM); + u32 readed = (u32)fread(&data, 1, 4, fpROM); if (readed) { rom.incAddress(); diff --git a/desmume/src/addons/slot1comp_protocol.h b/desmume/src/addons/slot1comp_protocol.h index 86796af5c..de97a7a83 100644 --- a/desmume/src/addons/slot1comp_protocol.h +++ b/desmume/src/addons/slot1comp_protocol.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2021 DeSmuME team + Copyright (C) 2013-2025 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,6 +59,8 @@ enum eSlot1Operation class ISlot1Comp_Protocol_Client { public: + virtual ~ISlot1Comp_Protocol_Client() {} + virtual void slot1client_startOperation(eSlot1Operation theOperation) {} virtual u32 slot1client_read_GCDATAIN(eSlot1Operation theOperation) = 0; virtual void slot1client_write_GCDATAIN(eSlot1Operation theOperation, u32 val) {} diff --git a/desmume/src/addons/slot2_gbagame.cpp b/desmume/src/addons/slot2_gbagame.cpp index 67acb7141..d47a55618 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-2021 DeSmuME team + Copyright (C) 2009-2025 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 @@ -65,7 +65,7 @@ private: fROM->fseek(pos, SEEK_SET); u32 data = 0xFFFFFFFF; - u32 readed = fROM->fread(&data, size); + u32 readed = (u32)fROM->fread(&data, size); return data; } @@ -77,7 +77,7 @@ private: fSRAM->fseek(pos, SEEK_SET); u32 data = 0xFFFFFFFF; - u32 readed = fSRAM->fread(&data, size); + u32 readed = (u32)fSRAM->fread(&data, size); return data; } @@ -107,7 +107,7 @@ private: for(;;) { u32 romType = 0; - u32 readed = fROM->fread(&romType, 4); + u32 readed = (u32)fROM->fread(&romType, 4); int pos = fROM->ftell(); int currPct = pos*100/(size-1); diff --git a/desmume/src/cp15.cpp b/desmume/src/cp15.cpp index bde283142..e689a0e89 100644 --- a/desmume/src/cp15.cpp +++ b/desmume/src/cp15.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2006 yopyop - Copyright (C) 2006-2021 DeSmuME team + Copyright (C) 2006-2025 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 @@ -175,7 +175,7 @@ void armcp15_setSingleRegionAccess(armcp15_t *armcp15, u8 num, u32 mask, u32 set armcp15->regionExecuteSet_SYS[num] = set ; break ; } -} ; +} /* precalculate region masks/sets from cp15 register */ void armcp15_maskPrecalc(armcp15_t *armcp15) diff --git a/desmume/src/debug.cpp b/desmume/src/debug.cpp index 81e2b0b12..bdbee09be 100644 --- a/desmume/src/debug.cpp +++ b/desmume/src/debug.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2006 Guillaume Duhamel - Copyright (C) 2006-2021 DeSmuME team + Copyright (C) 2006-2025 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 @@ -416,28 +416,28 @@ void NocashMessage(armcpu_t* cpu, int offset) //this is very inefficiently coded! char tmp[100]; - todo = mass_replace(todo,"%sp%","%r13%"); - todo = mass_replace(todo,"%lr%","%r14%"); - todo = mass_replace(todo,"%pc%","%r15%"); - sprintf(tmp,"%08X",cpu->R[0]); todo = mass_replace(todo,"%r0%",tmp); - sprintf(tmp,"%08X",cpu->R[1]); todo = mass_replace(todo,"%r1%",tmp); - sprintf(tmp,"%08X",cpu->R[2]); todo = mass_replace(todo,"%r2%",tmp); - sprintf(tmp,"%08X",cpu->R[3]); todo = mass_replace(todo,"%r3%",tmp); - sprintf(tmp,"%08X",cpu->R[4]); todo = mass_replace(todo,"%r4%",tmp); - sprintf(tmp,"%08X",cpu->R[5]); todo = mass_replace(todo,"%r5%",tmp); - sprintf(tmp,"%08X",cpu->R[6]); todo = mass_replace(todo,"%r6%",tmp); - sprintf(tmp,"%08X",cpu->R[7]); todo = mass_replace(todo,"%r7%",tmp); - sprintf(tmp,"%08X",cpu->R[8]); todo = mass_replace(todo,"%r8%",tmp); - sprintf(tmp,"%08X",cpu->R[9]); todo = mass_replace(todo,"%r9%",tmp); - sprintf(tmp,"%08X",cpu->R[10]); todo = mass_replace(todo,"%r10%",tmp); - sprintf(tmp,"%08X",cpu->R[11]); todo = mass_replace(todo,"%r11%",tmp); - sprintf(tmp,"%08X",cpu->R[12]); todo = mass_replace(todo,"%r12%",tmp); - sprintf(tmp,"%08X",cpu->R[13]); todo = mass_replace(todo,"%r13%",tmp); - sprintf(tmp,"%08X",cpu->R[14]); todo = mass_replace(todo,"%r14%",tmp); - sprintf(tmp,"%08X",cpu->R[15]); todo = mass_replace(todo,"%r15%",tmp); - sprintf(tmp,"%d",nds.VCount); todo = mass_replace(todo,"%scanline%",tmp); - sprintf(tmp,"%d",currFrameCounter); todo = mass_replace(todo,"%frame%",tmp); - sprintf(tmp,"%lld",nds_timer); todo = mass_replace(todo,"%totalclks%",tmp); + todo = mass_replace(todo, "%sp%", "%r13%"); + todo = mass_replace(todo, "%lr%", "%r14%"); + todo = mass_replace(todo, "%pc%", "%r15%"); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 0]); todo = mass_replace(todo, "%r0%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 1]); todo = mass_replace(todo, "%r1%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 2]); todo = mass_replace(todo, "%r2%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 3]); todo = mass_replace(todo, "%r3%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 4]); todo = mass_replace(todo, "%r4%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 5]); todo = mass_replace(todo, "%r5%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 6]); todo = mass_replace(todo, "%r6%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 7]); todo = mass_replace(todo, "%r7%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 8]); todo = mass_replace(todo, "%r8%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[ 9]); todo = mass_replace(todo, "%r9%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[10]); todo = mass_replace(todo, "%r10%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[11]); todo = mass_replace(todo, "%r11%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[12]); todo = mass_replace(todo, "%r12%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[13]); todo = mass_replace(todo, "%r13%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[14]); todo = mass_replace(todo, "%r14%", tmp); + snprintf(tmp, sizeof(tmp), "%08X", cpu->R[15]); todo = mass_replace(todo, "%r15%", tmp); + snprintf(tmp, sizeof(tmp), "%d", nds.VCount); todo = mass_replace(todo, "%scanline%", tmp); + snprintf(tmp, sizeof(tmp), "%d", currFrameCounter); todo = mass_replace(todo, "%frame%", tmp); + snprintf(tmp, sizeof(tmp), "%lld", nds_timer); todo = mass_replace(todo, "%totalclks%", tmp); printf("%s",todo.c_str()); fflush(stdout); diff --git a/desmume/src/debug.h b/desmume/src/debug.h index a41ab4201..5dfda56a2 100644 --- a/desmume/src/debug.h +++ b/desmume/src/debug.h @@ -1,6 +1,6 @@ /* Copyright (C) 2006 Guillaume Duhamel - Copyright (C) 2006-2015 DeSmuME team + Copyright (C) 2006-2025 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 @@ -149,7 +149,7 @@ enum EDEBUG_EVENT DEBUG_EVENT_WRITE=2, //write on arm9 or arm7 bus DEBUG_EVENT_EXECUTE=3, //prefetch on arm9 or arm7, triggered after the read event DEBUG_EVENT_ACL_EXCEPTION=4, //acl exception on arm9 - DEBUG_EVENT_CACHE_MISS=5, //cache miss on arm9 + DEBUG_EVENT_CACHE_MISS=5 //cache miss on arm9 }; enum EDEBUG_NOTIFY diff --git a/desmume/src/driver.h b/desmume/src/driver.h index a0b3a7031..a791900b2 100644 --- a/desmume/src/driver.h +++ b/desmume/src/driver.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2018 DeSmuME team + Copyright (C) 2009-2025 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,6 +26,8 @@ class VIEW3D_Driver { public: + virtual ~VIEW3D_Driver() {} + virtual void Launch() {} virtual void NewFrame() {} virtual bool IsRunning() { return false; } @@ -35,7 +37,7 @@ public: class BaseDriver { public: BaseDriver(); - ~BaseDriver(); + virtual ~BaseDriver(); virtual void AVI_SoundUpdate(void* soundData, int soundLen) {} virtual bool AVI_IsRecording() { return FALSE; } diff --git a/desmume/src/filter/filter.h b/desmume/src/filter/filter.h index f21e08ec2..950d9fa76 100644 --- a/desmume/src/filter/filter.h +++ b/desmume/src/filter/filter.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2016 DeSmuME team + Copyright (C) 2009-2025 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 @@ -20,15 +20,18 @@ #define FILTER_MAX_WORKING_SURFACE_COUNT 8 -typedef struct { +struct SSurface +{ unsigned char *Surface; - unsigned int Pitch; - unsigned int Width, Height; + int Pitch; + int Width; + int Height; unsigned char *workingSurface[FILTER_MAX_WORKING_SURFACE_COUNT]; void *userData; -} SSurface; +}; +typedef struct SSurface SSurface; void RenderDeposterize(SSurface Src, SSurface Dst); diff --git a/desmume/src/filter/videofilter.cpp b/desmume/src/filter/videofilter.cpp index d14550bd7..4defcd072 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-2022 DeSmuME team + Copyright (C) 2013-2025 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 @@ -144,10 +144,10 @@ VideoFilter::~VideoFilter() void VideoFilter::__InstanceInit(size_t srcWidth, size_t srcHeight, VideoFilterTypeID typeID, size_t threadCount) { SSurface newSurface; - newSurface.Surface = NULL; - newSurface.Pitch = srcWidth*2; - newSurface.Width = srcWidth; - newSurface.Height = srcHeight; + newSurface.Surface = NULL; + newSurface.Pitch = (int)(srcWidth * 2); + newSurface.Width = (int)srcWidth; + newSurface.Height = (int)srcHeight; newSurface.userData = NULL; for (size_t i = 0; i < FILTER_MAX_WORKING_SURFACE_COUNT; i++) @@ -228,9 +228,9 @@ bool VideoFilter::__AllocateDstBuffer(const size_t dstWidth, const size_t dstHei } // Set up SSurface structure. - this->__vfDstSurface.Width = dstWidth; - this->__vfDstSurface.Height = dstHeight; - this->__vfDstSurface.Pitch = dstWidth * 2; + this->__vfDstSurface.Width = (int)dstWidth; + this->__vfDstSurface.Height = (int)dstHeight; + this->__vfDstSurface.Pitch = (int)(dstWidth * 2); if (_useInternalDstBuffer) { @@ -241,8 +241,8 @@ bool VideoFilter::__AllocateDstBuffer(const size_t dstWidth, const size_t dstHei // Update the surfaces on threads. const size_t threadCount = this->__vfThread.size(); - const unsigned int linesPerThread = (threadCount > 1) ? dstHeight/threadCount : dstHeight; - unsigned int remainingLines = dstHeight; + const int linesPerThread = (threadCount > 1) ? (int)(dstHeight/threadCount) : (int)dstHeight; + int remainingLines = (int)dstHeight; for (size_t i = 0; i < threadCount; i++) { @@ -311,9 +311,9 @@ bool VideoFilter::SetSourceSize(const size_t width, const size_t height) sizeChanged = true; } - this->__vfSrcSurface.Width = width; - this->__vfSrcSurface.Height = height; - this->__vfSrcSurface.Pitch = width * 2; + this->__vfSrcSurface.Width = (int)width; + this->__vfSrcSurface.Height = (int)height; + this->__vfSrcSurface.Pitch = (int)(width * 2); // Set the working source buffer pointer so that the working memory block is padded // with 4 pixel rows worth of memory on both sides. this->__vfSrcSurface.Surface = (unsigned char *)(newPixBuffer + (width * 4)); @@ -323,8 +323,8 @@ bool VideoFilter::SetSourceSize(const size_t width, const size_t height) // Update the surfaces on threads. size_t threadCount = this->__vfThread.size(); - const unsigned int linesPerThread = (threadCount > 1) ? this->__vfSrcSurface.Height/threadCount : this->__vfSrcSurface.Height; - unsigned int remainingLines = this->__vfSrcSurface.Height; + const int linesPerThread = (threadCount > 1) ? this->__vfSrcSurface.Height/(int)threadCount : this->__vfSrcSurface.Height; + int remainingLines = this->__vfSrcSurface.Height; for (size_t i = 0; i < threadCount; i++) { @@ -351,7 +351,7 @@ bool VideoFilter::SetSourceSize(const size_t width, const size_t height) if (sizeChanged) { const VideoFilterAttributes vfAttr = this->GetAttributes(); - const size_t dstWidth = width * vfAttr.scaleMultiply / vfAttr.scaleDivide; + const size_t dstWidth = width * vfAttr.scaleMultiply / vfAttr.scaleDivide; const size_t dstHeight = height * vfAttr.scaleMultiply / vfAttr.scaleDivide; this->_pixelScale = (float)vfAttr.scaleMultiply / (float)vfAttr.scaleDivide; @@ -625,16 +625,16 @@ void VideoFilter::RunFilterCustomByAttributes(const uint32_t *__restrict srcBuff SSurface srcSurface; memset(&srcSurface, 0, sizeof(srcSurface)); srcSurface.Surface = (unsigned char *)srcBuffer; - srcSurface.Pitch = srcWidth*2; - srcSurface.Width = srcWidth; - srcSurface.Height = srcHeight; + srcSurface.Pitch = (int)(srcWidth * 2); + srcSurface.Width = (int)srcWidth; + srcSurface.Height = (int)srcHeight; SSurface dstSurface; memset(&dstSurface, 0, sizeof(dstSurface)); dstSurface.Surface = (unsigned char *)dstBuffer; - dstSurface.Pitch = dstWidth*2; - dstSurface.Width = dstWidth; - dstSurface.Height = dstHeight; + dstSurface.Pitch = (int)(dstWidth * 2); + dstSurface.Width = (int)dstWidth; + dstSurface.Height = (int)dstHeight; if (filterFunction == NULL) { diff --git a/desmume/src/libretro-common/features/features_cpu.c b/desmume/src/libretro-common/features/features_cpu.c index 2c41d5732..e632a0a88 100644 --- a/desmume/src/libretro-common/features/features_cpu.c +++ b/desmume/src/libretro-common/features/features_cpu.c @@ -501,8 +501,8 @@ unsigned cpu_features_get_core_amount(void) /* Linux, most UNIX-likes. */ long ret = sysconf(_SC_NPROCESSORS_ONLN); if (ret <= 0) - return (unsigned)1; - return ret; + ret = 1; + return (unsigned)ret; #elif defined(BSD) || defined(__APPLE__) /* BSD */ /* Copypasta from stackoverflow, dunno if it works. */ diff --git a/desmume/src/mc.cpp b/desmume/src/mc.cpp index 8fdc4ef70..b4ad9f9fd 100644 --- a/desmume/src/mc.cpp +++ b/desmume/src/mc.cpp @@ -192,12 +192,12 @@ bool BackupDevice::load_state(EMUFILE &is) is.read_u8(this->_write_protect); } - this->_fsize = data.size(); + this->_fsize = (u32)data.size(); #ifndef _DONT_SAVE_BACKUP this->_fpMC->fseek(0, SEEK_SET); if (data.size() != 0) this->_fpMC->fwrite((char *)&data[0], this->_fsize); - ensure(data.size(), this->_fpMC); + ensure((u32)data.size(), this->_fpMC); #endif if (version >= 5) @@ -657,9 +657,9 @@ void BackupDevice::detect() if ( (this->_state == DETECTING) && (this->_data_autodetect.size() > 0) ) { //we can now safely detect the save address size - u32 autodetect_size = this->_data_autodetect.size(); + u32 autodetect_size = (u32)this->_data_autodetect.size(); - printf("Autodetecting with autodetect_size=%d\n",autodetect_size); + printf("Autodetecting with autodetect_size=%u\n", autodetect_size); //detect based on rules switch(autodetect_size) @@ -1132,7 +1132,7 @@ u32 BackupDevice::get_save_nogba_size(const char* fname) if (fsrc) { char src[0x50] = {0}; - u32 fsize = 0; + size_t fsize = 0; fseek(fsrc, 0, SEEK_END); fsize = ftell(fsrc); fseek(fsrc, 0, SEEK_SET); @@ -1174,7 +1174,7 @@ u32 BackupDevice::get_save_nogba_size(u8 *data) return 0xFFFFFFFF; } -static int no_gba_unpackSAV(void *in_buf, u32 fsize, void *out_buf, u32 &size) +static int no_gba_unpackSAV(void *in_buf, size_t fsize, void *out_buf, u32 &size) { u8 *src = (u8 *)in_buf; u8 *dst = (u8 *)out_buf; @@ -1295,7 +1295,7 @@ bool BackupDevice::import_no_gba(const char *fname, u32 force_size) if (fsrc) { - u32 fsize = 0; + size_t fsize = 0; fseek(fsrc, 0, SEEK_END); fsize = ftell(fsrc); fseek(fsrc, 0, SEEK_SET); @@ -1366,19 +1366,19 @@ bool BackupDevice::export_no_gba(const char* fname) this->_fpMC->fread((char *)&data[0], this->_fsize); this->_fpMC->fseek(pos, SEEK_SET); - FILE* outf = fopen(fname,"wb"); - if(!outf) return false; - u32 size = data.size(); - u32 padSize = pad_up_size(size); - if(data.size()>0) - fwrite(&data[0],1,size,outf); - for(u32 i=size;i 0) + fwrite(&data[0], 1, size, outf); + for (size_t i = size; i < padSize; i++) + fputc(0xFF, outf); - if (padSize < 512 * 1024) + if (padSize < (512 * 1024)) { - for(u32 i=padSize; i<512 * 1024; i++) - fputc(0xFF,outf); + for (size_t i = padSize; i < (512 * 1024); i++) + fputc(0xFF, outf); } fclose(outf); @@ -1395,14 +1395,14 @@ bool BackupDevice::export_raw(const char* filename) this->_fpMC->fread((char *)&data[0], this->_fsize); this->_fpMC->fseek(pos, SEEK_SET); - FILE* outf = fopen(filename,"wb"); - if(!outf) return false; - u32 size = data.size(); - u32 padSize = pad_up_size(size); - if(data.size()>0) - fwrite(&data[0],1,size,outf); - for(u32 i=size;i 0) + fwrite(&data[0], 1, size, outf); + for (size_t i = size; i < padSize; i++) + fputc(uninitializedValue, outf); fclose(outf); return true; @@ -1649,8 +1649,8 @@ bool BackupDevice::import_dsv(const char *filename) // Truncate the file if necessary. // * Also see TODO note above, since that applies to this step as well. - const size_t newFileSize = this->_info.padSize + BackupDevice::GetDSVFooterSize(); - this->_fpMC->truncate(newFileSize); + const size_t newFileSize = (size_t)this->_info.padSize + BackupDevice::GetDSVFooterSize(); + this->_fpMC->truncate((s32)newFileSize); result = true; diff --git a/desmume/src/movie.cpp b/desmume/src/movie.cpp index a189972dc..55eafc410 100644 --- a/desmume/src/movie.cpp +++ b/desmume/src/movie.cpp @@ -1,5 +1,5 @@ /* - Copyright 2008-2021 DeSmuME team + Copyright 2008-2025 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 @@ void MovieData::insertEmpty(int at, int frames) { if(at == -1) { - int currcount = records.size(); + int currcount = (int)records.size(); records.resize(records.size()+frames); clearRecordRange(currcount,frames); } @@ -258,7 +258,7 @@ MovieData::MovieData(bool fromCurrentSettings) for(int i=0;i<256;i++) { char tmp[256]; - sprintf(tmp,"micsample%d",i); + snprintf(tmp, sizeof(tmp), "micsample%d", i); installValueMap[tmp] = &MovieData::installMicSample; } @@ -403,7 +403,7 @@ int MovieData::dump(EMUFILE &fp, bool binary) fp.fprintf("savestate %d\n", savestate?1:0); if (sram.size() != 0) - fp.fprintf("sram %s\n", BytesToString(&sram[0],sram.size()).c_str()); + fp.fprintf( "sram %s\n", BytesToString(&sram[0], (int)sram.size()).c_str() ); for (size_t i = 0; i < 256; i++) { @@ -411,8 +411,8 @@ int MovieData::dump(EMUFILE &fp, bool binary) if(micSamples.size() > i) { char tmp[32]; - sprintf(tmp,"micsample%d", (int)i); - fp.fprintf("%s %s\n",tmp, BytesToString(&micSamples[i][0],micSamples[i].size()).c_str()); + snprintf(tmp, sizeof(tmp), "micsample%d", (int)i); + fp.fprintf( "%s %s\n", tmp, BytesToString(&micSamples[i][0], (int)micSamples[i].size()).c_str() ); } } @@ -527,7 +527,7 @@ bool LoadFM2(MovieData &movieData, EMUFILE &fp, int size, bool stopAfterHeader) } else { - int currcount = movieData.records.size(); + size_t currcount = movieData.records.size(); movieData.records.resize(currcount + 1); movieData.records[currcount].parse(fp); } @@ -1310,16 +1310,17 @@ void FCEUI_MakeBackupMovie(bool dispMessage) string backupFn; //Target backup filename string tempFn; //temp used in back filename creation stringstream stream; - int x; //Temp variable for string manip + size_t x; //Temp variable for string manip bool exist = false; //Used to test if filename exists bool overflow = false; //Used for special situation when backup numbering exceeds limit currentFn = curMovieFilename; //Get current moviefilename backupFn = curMovieFilename; //Make backup filename the same as current moviefilename - x = backupFn.find_last_of("."); //Find file extension + x = backupFn.find_last_of("."); //Find file extension backupFn = backupFn.substr(0,x); //Remove extension tempFn = backupFn; //Store the filename at this point - for (unsigned int backNum=0;backNum<999;backNum++) //999 = arbituary limit to backup files + + for (size_t backNum = 0; backNum < 999; backNum++) //999 = arbituary limit to backup files { stream.str(""); //Clear stream if (backNum > 99) diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 61cb28bb7..5a294a381 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -2,7 +2,7 @@ Copyright (C) 2006 Normmatt Copyright (C) 2006 Theo Berkau Copyright (C) 2007 Pascal Giard - Copyright (C) 2008-2021 DeSmuME team + Copyright (C) 2008-2025 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 @@ -68,7 +68,7 @@ int lastSaveState = 0; //Keeps track of last savestate used for quick save/load u32 _DESMUME_version = EMU_DESMUME_VERSION_NUMERIC(); u32 svn_rev = 0; //EMU_DESMUME_VERSION_NUMERIC(); //sorry, not using this now -s64 save_time = 0; +s64 save_time_data = 0; NDS_SLOT1_TYPE slot1Type = NDS_SLOT1_RETAIL_AUTO; NDS_SLOT2_TYPE slot2Type = NDS_SLOT2_AUTO; @@ -87,7 +87,7 @@ SFORMAT SF_NDS_INFO[]={ { "DVMI", 1, 1, (void*)&DESMUME_VERSION_MINOR}, { "DSBD", 1, 1, (void*)&DESMUME_VERSION_BUILD}, { "GREV", 1, 4, &svn_rev}, - { "GTIM", 1, 8, &save_time}, + { "GTIM", 1, 8, &save_time_data}, { 0 } }; @@ -670,7 +670,7 @@ void scan_savestates() path.getpathnoext(path.STATE_SLOTS, filename); if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ > MAX_PATH) return; - sprintf(filename + strlen(filename), ".ds%d", i); + snprintf(filename + strlen(filename), sizeof(filename), ".ds%d", i); #ifdef _MSC_VER wchar_t wgarbage[1024] = {0}; @@ -697,7 +697,7 @@ void savestate_slot(int num) path.getpathnoext(path.STATE_SLOTS, filename); if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ > MAX_PATH) return; - sprintf(filename + strlen(filename), ".ds%d", num); + snprintf(filename + strlen(filename), sizeof(filename), ".ds%d", num); if (savestate_save(filename)) { @@ -775,7 +775,7 @@ void loadstate_slot(int num) std::string fname = dirname + PSS; char mini[100]; - sprintf(mini, "%u", cur_index); + snprintf(mini, sizeof(mini), "%u", cur_index); fname += mini + (std::string)".dst"; savestate_save(fname.c_str()); @@ -789,7 +789,7 @@ void loadstate_slot(int num) } if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ > MAX_PATH) return; - sprintf(filename + strlen(filename), ".ds%d", num); + snprintf(filename + strlen(filename), sizeof(filename), ".ds%d", num); if (savestate_load(filename)) { @@ -1125,7 +1125,7 @@ static void writechunks(EMUFILE &os) DateTime tm = DateTime::get_Now(); svn_rev = 0; - save_time = tm.get_Ticks(); + save_time_data = tm.get_Ticks(); gfx3d_PrepareSaveStateBufferWrite(); @@ -1253,7 +1253,7 @@ static bool ReadStateChunks(EMUFILE &is, s32 totalsize) { char buf[32] = {0}; if (svn_rev != 0xFFFFFFFF) - sprintf(buf, " svn %u", svn_rev); + snprintf(buf, sizeof(buf), " svn %u", svn_rev); printf("\tDeSmuME version: %u.%u.%u%s\n", version_major, version_minor, version_build, buf); } diff --git a/desmume/src/slot1.h b/desmume/src/slot1.h index 8955a3e9f..dc3172d15 100644 --- a/desmume/src/slot1.h +++ b/desmume/src/slot1.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2010-2015 DeSmuME team + Copyright (C) 2010-2025 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 @@ -28,6 +28,8 @@ class EMUFILE; class Slot1Info { public: + virtual ~Slot1Info() {} + virtual const char* name() const = 0; virtual const char* descr()const = 0; virtual const u8 id() const = 0; @@ -42,6 +44,9 @@ public: , mID(_id) { } + + virtual ~Slot1InfoSimple() {} + virtual const char* name() const { return mName; } virtual const char* descr() const { return mDescr; } virtual const u8 id() const { return mID; } diff --git a/desmume/src/slot2.h b/desmume/src/slot2.h index 66f84f708..d34849575 100644 --- a/desmume/src/slot2.h +++ b/desmume/src/slot2.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2023 DeSmuME team + Copyright (C) 2009-2025 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 @@ -29,6 +29,8 @@ class EMUFILE; class Slot2Info { public: + virtual ~Slot2Info() {} + virtual const char* name() const = 0; virtual const char* descr() const = 0; virtual u8 id() const = 0; @@ -43,6 +45,9 @@ public: , mID(_id) { } + + virtual ~Slot2InfoSimple() {} + virtual const char* name() const { return mName; } virtual const char* descr() const { return mDescr; } virtual u8 id() const { return mID; } diff --git a/desmume/src/utils/emufat.cpp b/desmume/src/utils/emufat.cpp index 386ff1803..41fa05bf3 100644 --- a/desmume/src/utils/emufat.cpp +++ b/desmume/src/utils/emufat.cpp @@ -1,5 +1,5 @@ /* - Copyright 2009-2021 DeSmuME team + Copyright 2009-2025 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 @@ -234,8 +234,8 @@ do { /* The factor 2 below avoids cut-off errors for nr_fats == 1. * The "nr_fats*3" is for the reserved first two FAT entries */ - clust12 = 2*((u64) fatdata *sector_size + bs.fatCount*3) / - (2*(int) bs.sectorsPerCluster * sector_size + bs.fatCount*3); + clust12 = (u32)( ( (2ULL * (u64)fatdata * (u64)sector_size) + ((u64)bs.fatCount * 3ULL) ) / + ( (2ULL * (u64)bs.sectorsPerCluster * (u64)sector_size) + ((u64)bs.fatCount * 3ULL) ) ); fatlength12 = cdiv (((clust12+2) * 3 + 1) >> 1, sector_size); /* Need to recalculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, @@ -251,8 +251,8 @@ do { printf( "FAT12: too much clusters\n" ); } - clust16 = ((u64) fatdata *sector_size + bs.fatCount*4) / - ((int) bs.sectorsPerCluster * sector_size + bs.fatCount*2); + clust16 = (u32)( ( ((u64)fatdata * (u64)sector_size) + ((u64)bs.fatCount * 4ULL) ) / + ( ((u64)bs.sectorsPerCluster * (u64)sector_size) + ((u64)bs.fatCount * 2ULL) ) ); fatlength16 = cdiv ((clust16+2) * 2, sector_size); /* Need to recalculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, @@ -276,8 +276,8 @@ do { clust16 = 0; } - clust32 = ((u64) fatdata *sector_size + bs.fatCount*8) / - ((int) bs.sectorsPerCluster * sector_size + bs.fatCount*4); + clust32 = (u32)( ( ((u64)fatdata * (u64)sector_size) + ((u64)bs.fatCount * 8ULL) ) / + ( ((u64)bs.sectorsPerCluster * (u64)sector_size) + ((u64)bs.fatCount * 4ULL) ) ); fatlength32 = cdiv ((clust32+2) * 4, sector_size); /* Need to recalculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, @@ -397,7 +397,6 @@ case 32: //but we onnly targeted fat32 our first time through bool EmuFatVolume::formatNew(u32 sectors) { - u32 volumeStartBlock = 0; TFat32BootSector bsrec; memset(&bsrec,0,sizeof(TFat32BootSector)); TFat32BootSector *bs = &bsrec; diff --git a/desmume/src/utils/fsnitro.cpp b/desmume/src/utils/fsnitro.cpp index 391e03822..988b2824a 100644 --- a/desmume/src/utils/fsnitro.cpp +++ b/desmume/src/utils/fsnitro.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2017 DeSmuME team + Copyright (C) 2013-2025 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 @@ -165,9 +165,8 @@ bool FS_NITRO::loadFileTables() for (u32 i = 0 ; i < numOverlay9; i++) { char buf[129] = {0}; - memset(&buf[0], 0, sizeof(buf)); fat[ovr9[i].fileID].isOverlay = true; - sprintf(buf, "overlay_%04u.bin", ovr9[i].id); + snprintf(buf, sizeof(buf), "overlay_%04u.bin", ovr9[i].id); fat[ovr9[i].fileID].filename = buf; } } @@ -181,9 +180,8 @@ bool FS_NITRO::loadFileTables() for (u32 i = 0 ; i < numOverlay7; i++) { char buf[129] = {0}; - memset(&buf[0], 0, sizeof(buf)); fat[ovr7[i].fileID].isOverlay = true; - sprintf(buf, "overlay_%04u.bin", ovr7[i].id); + snprintf(buf, sizeof(buf), "overlay_%04u.bin", ovr7[i].id); fat[ovr7[i].fileID].filename = buf; } } @@ -300,15 +298,15 @@ bool FS_NITRO::rebuildFAT(u32 addr, u32 size, std::string pathData) FILE *fp = fopen(path.c_str(), "rb"); if (!fp) continue; fseek(fp, 0, SEEK_END); - u32 size = ftell(fp); + u32 fileSize = (u32)ftell(fp); fclose(fp); fat[i].file = true; - if (fat[i].size != size) + if (fat[i].size != fileSize) { - //printf("Different size: %s (ROM: %d, file %d)\n", path.c_str(), fat[i].size, size); - fat[i].sizeFile = size; + //printf("Different size: %s (ROM: %d, file %d)\n", path.c_str(), fat[i].size, fileSize); + fat[i].sizeFile = fileSize; } else fat[i].sizeFile = fat[i].size; diff --git a/desmume/src/utils/fsnitro.h b/desmume/src/utils/fsnitro.h index 724d3f916..d1ecb1088 100644 --- a/desmume/src/utils/fsnitro.h +++ b/desmume/src/utils/fsnitro.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2017 DeSmuME team + Copyright (C) 2013-2025 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,7 +26,7 @@ enum FNT_TYPES FS_FILE_ENTRY = 0, FS_SUBDIR_ENTRY = 1, FS_END_SUBTABLE = 2, - FS_RESERVED = 3, + FS_RESERVED = 3 }; #include "../PACKED.h" diff --git a/desmume/src/utils/guid.cpp b/desmume/src/utils/guid.cpp index 5fce4f89b..b73c205f2 100644 --- a/desmume/src/utils/guid.cpp +++ b/desmume/src/utils/guid.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2008-2009 DeSmuME team + Copyright (C) 2008-2025 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 @@ -56,7 +56,7 @@ void Desmume_Guid::newGuid() std::string Desmume_Guid::toString() { char buf[37]; - sprintf(buf,"%08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X", + snprintf(buf, sizeof(buf), "%08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X", de32lsb(data),de16lsb(data+4),de16lsb(data+6),de16lsb(data+8),data[10],data[11],data[12],data[13],data[14],data[15]); return std::string(buf); } @@ -84,7 +84,7 @@ u8 Desmume_Guid::hexToByte(char** ptrptr) void Desmume_Guid::scan(std::string& str) { char* endptr = (char*)str.c_str(); - en32lsb(data,strtoul(endptr,&endptr,16)); + en32lsb(data+0,(u32)strtoul(endptr+0,&endptr,16)); en16lsb(data+4,(u16)strtoul(endptr+1,&endptr,16)); en16lsb(data+6,(u16)strtoul(endptr+1,&endptr,16)); en16lsb(data+8,(u16)strtoul(endptr+1,&endptr,16)); diff --git a/desmume/src/utils/vfat.cpp b/desmume/src/utils/vfat.cpp index 2ff7074e1..717ed6a6f 100644 --- a/desmume/src/utils/vfat.cpp +++ b/desmume/src/utils/vfat.cpp @@ -1,7 +1,7 @@ /* Copyright (C) 2006 yopyop Copyright (C) 2006 Mic - Copyright (C) 2010-2016 DeSmuME team + Copyright (C) 2010-2025 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 @@ -65,13 +65,13 @@ static void list_files(const char *filepath, ListCallback list_callback) if(!retro_readdir(rdir)) break; - const char* fname = retro_dirent_get_name(rdir); + const char* fname2 = retro_dirent_get_name(rdir); list_callback(rdir,EListCallbackArg_Item); - printf("cflash added %s\n",fname); + printf("cflash added %s\n", fname2); - if (retro_dirent_is_dir(rdir, fname) && (strcmp(fname, ".")) && strcmp(fname, "..")) + if (retro_dirent_is_dir(rdir, fname2) && (strcmp(fname2, ".")) && strcmp(fname2, "..")) { - std::string subdir = (std::string)filepath + path_default_slash() + fname; + std::string subdir = (std::string)filepath + path_default_slash() + fname2; list_files(subdir.c_str(), list_callback); list_callback(rdir, EListCallbackArg_Pop); } @@ -145,16 +145,16 @@ static void DirectoryListCallback(RDIR* rdir, EListCallbackArg arg) if(inf) { fseek(inf,0,SEEK_END); - long len = ftell(inf); + size_t len = ftell(inf); fseek(inf,0,SEEK_SET); u8 *buf = new u8[len]; fread(buf,1,len,inf); fclose(inf); - std::string path = currVirtPath + "/" + fname; - printf("FAT + (%10.2f KB) %s \n",len/1024.f,path.c_str()); - bool ok = LIBFAT::WriteFile(path.c_str(),buf,len); - if(!ok) + std::string path2 = currVirtPath + "/" + fname; + printf( "FAT + (%10.2f KB) %s \n", (float)len/1024.f, path2.c_str() ); + bool ok = LIBFAT::WriteFile(path2. c_str(), buf, (int)len); + if (!ok) printf("ERROR adding file to fat\n"); delete[] buf; } else printf("ERROR opening file for fat\n"); @@ -206,7 +206,7 @@ bool VFAT::build(const char* path, int extra_MB) delete file; try { - file = new EMUFILE_MEMORY(dataSectors*512); + file = new EMUFILE_MEMORY((u32)dataSectors*512); } catch(std::bad_alloc) { @@ -223,7 +223,7 @@ bool VFAT::build(const char* path, int extra_MB) EmuFat fat(file); EmuFatVolume vol; u8 ok = vol.init(&fat); - vol.formatNew(dataSectors); + vol.formatNew((u32)dataSectors); //ensure we are working in memory, just in case we were testing with a disk file. //libfat will need to go straight to memory (for now; we could easily change it to work with the disk) diff --git a/desmume/src/utils/xstring.cpp b/desmume/src/utils/xstring.cpp index 1b4a21ce4..55ca5f652 100644 --- a/desmume/src/utils/xstring.cpp +++ b/desmume/src/utils/xstring.cpp @@ -2,7 +2,7 @@ //subsequently modified for desmume /* - Copyright (C) 2008-2009 DeSmuME team + Copyright (C) 2008-2025 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 @@ -24,7 +24,7 @@ //a vc-style substring operation (very kind and lenient) std::string strsub(const std::string& str, int pos, int len) { - int strlen = str.size(); + int strlen = (int)str.size(); if(strlen==0) return str; //empty strings always return empty strings if(pos>=strlen) return str; //if you start past the end of the string, return the entire string. this is unusual, but there you have it @@ -44,7 +44,7 @@ std::string strsub(const std::string& str, int pos, int len) { std::string strmid(const std::string& str, int pos, int len) { return strsub(str,pos,len); } std::string strleft(const std::string& str, int len) { return strsub(str,0,len); } -std::string strright(const std::string& str, int len) { return len ? strsub(str,str.size()-len,len) : ""; } +std::string strright(const std::string& str, int len) { return len ? strsub(str,(int)str.size()-len,len) : ""; } std::string toupper(const std::string& str) { std::string ret = str; @@ -80,7 +80,7 @@ private: std::string u32ToHexString(u32 val) { char temp[16]; - sprintf(temp,"%08X",val); + snprintf(temp, sizeof(temp), "%08X", val); return temp; } @@ -89,14 +89,14 @@ std::string BytesToString(const void* data, int len) { char temp[16]; if(len==1) { - sprintf(temp,"%d",*(const unsigned char*)data); + snprintf(temp, sizeof(temp), "%d",*(const unsigned char*)data); return temp; } else if(len==2) { - sprintf(temp,"%d",*(const unsigned short*)data); + snprintf(temp, sizeof(temp), "%d",*(const unsigned short*)data); return temp; } else if(len==4) { - sprintf(temp,"%d",*(const unsigned int*)data); - return temp; + snprintf(temp, sizeof(temp), "%d",*(const unsigned int*)data); + return temp; } std::string ret; @@ -143,7 +143,7 @@ std::string BytesToString(const void* data, int len) int HexStringToBytesLength(const std::string& str) { if(str.size()>2 && str[0] == '0' && toupper(str[1]) == 'X') - return str.size()/2-1; + return (int)(str.size() / 2) - 1; else return -1; } @@ -154,7 +154,7 @@ int Base64StringToBytesLength(const std::string& str) size_t c = ((str.size() - 7) / 4) * 3; if(str[str.size()-1] == '=') { --c; if(str[str.size()-2] == '=') --c; } - return c; + return (int)c; } ///parses a string in the same format as BytesToString @@ -194,7 +194,7 @@ bool StringToBytes(const std::string& str, void* data, int len) { // hex int amt = len; - int bytesAvailable = str.size()/2; + int bytesAvailable = (int)(str.size() / 2); if(bytesAvailable < amt) amt = bytesAvailable; const char* cstr = str.c_str()+2; @@ -266,7 +266,7 @@ std::vector tokenize_str(const std::string & str, std::string stditoa(int n) { char tempbuf[16]; - sprintf(tempbuf, "%d", n); + snprintf(tempbuf, sizeof(tempbuf), "%d", n); return tempbuf; } diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index f6fc7ac0d..f079f9a7a 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2007 Tim Seidel - Copyright (C) 2008-2022 DeSmuME team + Copyright (C) 2008-2025 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 @@ -3475,7 +3475,7 @@ int AdhocCommInterface::_RXPacketGetFromSocket(RXRawPacketData& rawPacket) u8* targetPacket = &rawPacket.buffer[rawPacket.writeLocation]; - rxPacketSizeInt = recvfrom(thisSocket, (char*)targetPacket, WIFI_WORKING_PACKET_BUFFER_SIZE, 0, &fromAddr, &fromLen); + rxPacketSizeInt = (int)recvfrom(thisSocket, (char*)targetPacket, WIFI_WORKING_PACKET_BUFFER_SIZE, 0, &fromAddr, &fromLen); if(rxPacketSizeInt <= 0) { return rxPacketSizeInt; // No packet data was received. @@ -3720,7 +3720,7 @@ size_t SoftAPCommInterface::TXPacketSend(u8* txTargetBuffer, size_t txLength) return txPacketSize; } - int result = this->_pcap->sendpacket(this->_bridgeDevice, txTargetBuffer, txLength); + int result = this->_pcap->sendpacket(this->_bridgeDevice, txTargetBuffer, (int)txLength); if(result == 0) { txPacketSize = txLength; @@ -4025,9 +4025,10 @@ void WifiHandler::_PacketCaptureFileOpen() tm* t = localtime(&ti); char* gamecd = gameInfo.header.gameCode; - char file_name[50]; - sprintf( + char file_name[64]; + snprintf( file_name, + sizeof(file_name), "%c%c%c%c [%02d-%02d-%02d-%02d].pcap", gamecd[0], gamecd[1], gamecd[2], gamecd[3], t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec @@ -4081,8 +4082,8 @@ void WifiHandler::_PacketCaptureFileWrite(const u8* packet, u32 len, bool isRece return; } - const u32 seconds = timeStamp / 1000000; - const u32 millis = timeStamp % 1000000; + const u32 seconds = (u32)(timeStamp / 1000000ULL); + const u32 millis = (u32)(timeStamp % 1000000ULL); // Add the packet // more info: http://www.kroosec.com/2012/10/a-look-at-pcap-file-format.html @@ -4503,7 +4504,7 @@ int WifiHandler::GetBridgeDeviceList(std::vector* deviceStringList) } } - return deviceStringList->size(); + return (int)deviceStringList->size(); } int WifiHandler::GetSelectedBridgeDeviceIndex() diff --git a/desmume/src/wifi.h b/desmume/src/wifi.h index 94c1a568b..5786fdf74 100644 --- a/desmume/src/wifi.h +++ b/desmume/src/wifi.h @@ -1,7 +1,7 @@ /* Copyright (C) 2007 Tim Seidel Copyright (C) 2014 pleonex - Copyright (C) 2008-2022 DeSmuME team + Copyright (C) 2008-2025 DeSmuME team This file is part of DeSmuME @@ -3230,6 +3230,8 @@ typedef struct _FW_WFCProfile class ClientPCapInterface { public: + virtual ~ClientPCapInterface() {} + virtual int findalldevs(void **alldevs, char *errbuf) = 0; virtual void freealldevs(void *alldevs) = 0; virtual void* open(const char *source, int snaplen, int flags, int readtimeout, char *errbuf) = 0; @@ -3246,6 +3248,8 @@ private: void __CopyErrorString(char *errbuf); public: + virtual ~DummyPCapInterface() {} + virtual int findalldevs(void **alldevs, char *errbuf); virtual void freealldevs(void *alldevs); virtual void* open(const char *source, int snaplen, int flags, int readtimeout, char *errbuf); @@ -3261,6 +3265,8 @@ public: class POSIXPCapInterface : public ClientPCapInterface { public: + virtual ~POSIXPCapInterface() {} + virtual int findalldevs(void **alldevs, char *errbuf); virtual void freealldevs(void *alldevs); virtual void* open(const char *source, int snaplen, int flags, int readtimeout, char *errbuf); @@ -3286,7 +3292,7 @@ protected: public: WifiCommInterface(); - ~WifiCommInterface(); + virtual ~WifiCommInterface(); virtual bool Start(WifiHandler *currentWifiHandler) = 0; virtual void Stop() = 0; @@ -3302,7 +3308,7 @@ protected: public: AdhocCommInterface(); - ~AdhocCommInterface(); + virtual ~AdhocCommInterface(); int _RXPacketGetFromSocket(RXRawPacketData &rawPacket);