diff --git a/desmume/src/FIFO.cpp b/desmume/src/FIFO.cpp index 65e1ebed9..ae812cefc 100755 --- a/desmume/src/FIFO.cpp +++ b/desmume/src/FIFO.cpp @@ -1,7 +1,7 @@ /* Copyright 2006 yopyop Copyright 2007 shash - Copyright 2007-2022 DeSmuME team + Copyright 2007-2023 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 @@ -353,24 +353,24 @@ void DISP_FIFOsend(const T val) case 1: { #ifndef MSB_FIRST - HostWriteByte((u8 *)disp_fifo.buf, finalWriteAddress, val); + HostWriteByte((u8 *)disp_fifo.buf, (u32)finalWriteAddress, val); #else switch (ADDROFFSET) { case 0: - HostWriteByte((u8 *)disp_fifo.buf, baseWriteAddress + 2, val); + HostWriteByte((u8 *)disp_fifo.buf, (u32)baseWriteAddress + 2, val); break; case 1: - HostWriteByte((u8 *)disp_fifo.buf, baseWriteAddress + 3, val); + HostWriteByte((u8 *)disp_fifo.buf, (u32)baseWriteAddress + 3, val); break; case 2: - HostWriteByte((u8 *)disp_fifo.buf, baseWriteAddress + 0, val); + HostWriteByte((u8 *)disp_fifo.buf, (u32)baseWriteAddress + 0, val); break; case 3: - HostWriteByte((u8 *)disp_fifo.buf, baseWriteAddress + 1, val); + HostWriteByte((u8 *)disp_fifo.buf, (u32)baseWriteAddress + 1, val); break; default: @@ -392,16 +392,16 @@ void DISP_FIFOsend(const T val) case 2: { #ifndef MSB_FIRST - HostWriteWord((u8 *)disp_fifo.buf, finalWriteAddress, val); + HostWriteWord((u8 *)disp_fifo.buf, (u32)finalWriteAddress, val); #else switch (ADDROFFSET) { case 0: - HostWriteWord((u8 *)disp_fifo.buf, baseWriteAddress + 2, val); + HostWriteWord((u8 *)disp_fifo.buf, (u32)baseWriteAddress + 2, val); break; case 2: - HostWriteWord((u8 *)disp_fifo.buf, baseWriteAddress + 0, val); + HostWriteWord((u8 *)disp_fifo.buf, (u32)baseWriteAddress + 0, val); break; default: @@ -421,7 +421,7 @@ void DISP_FIFOsend(const T val) } case 4: - HostWriteTwoWords((u8 *)disp_fifo.buf, finalWriteAddress, val); + HostWriteTwoWords((u8 *)disp_fifo.buf, (u32)finalWriteAddress, val); disp_fifo.tail++; break; diff --git a/desmume/src/movie.h b/desmume/src/movie.h index 00314c9ac..fab5b0f9f 100644 --- a/desmume/src/movie.h +++ b/desmume/src/movie.h @@ -1,5 +1,5 @@ /* - Copyright 2008-2018 DeSmuME team + Copyright 2008-2023 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 @@ -179,7 +179,7 @@ public: int advancedTiming; int jitBlockSize; - int getNumRecords() { return records.size(); } + int getNumRecords() { return (int)records.size(); } class TDictionary : public std::map { diff --git a/desmume/src/texcache.cpp b/desmume/src/texcache.cpp index 6d2b50757..faafd5574 100644 --- a/desmume/src/texcache.cpp +++ b/desmume/src/texcache.cpp @@ -1,7 +1,7 @@ /* Copyright (C) 2006 yopyop Copyright (C) 2006-2007 shash - Copyright (C) 2008-2022 DeSmuME team + Copyright (C) 2008-2023 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 @@ -1757,7 +1757,7 @@ void NDSTextureUnpackA5I3(const size_t srcSize, const u8 *__restrict srcData, co template void NDSTextureUnpack4x4(const size_t srcSize, const u32 *__restrict srcData, const u16 *__restrict srcIndex, const u32 palAddress, const u32 sizeX, const u32 sizeY, u32 *__restrict dstBuffer) { - const u32 limit = srcSize * sizeof(u32); + const size_t limit = srcSize * sizeof(u32); const u32 xTmpSize = sizeX >> 2; const u32 yTmpSize = sizeY >> 2; diff --git a/desmume/src/utils/datetime.h b/desmume/src/utils/datetime.h index b050153e1..7ecf6fd37 100644 --- a/desmume/src/utils/datetime.h +++ b/desmume/src/utils/datetime.h @@ -1,20 +1,20 @@ -/* - Copyright (C) 2010 DeSmuME team - - This file is based on System.DateTime.cs and System.TimeSpan.cs from mono-2.6.7 - - 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 - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This file is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the this software. If not, see . +/* + Copyright (C) 2010-2023 DeSmuME team + + This file is based on System.DateTime.cs and System.TimeSpan.cs from mono-2.6.7 + + 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 + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the this software. If not, see . */ // @@ -78,19 +78,19 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - -#ifndef _DATETIME_H_ -#define _DATETIME_H_ - -#include -#include -#include -#include - -#include - -#include "../types.h" - + +#ifndef _DATETIME_H_ +#define _DATETIME_H_ + +#include +#include +#include +#include + +#include + +#include "../types.h" + enum DayOfWeek { DayOfWeek_Sunday=0, DayOfWeek_Monday=1, @@ -99,41 +99,41 @@ enum DayOfWeek { DayOfWeek_Thursday=4, DayOfWeek_Friday=5, DayOfWeek_Saturday=6 -}; - -class TimeSpan -{ - friend class DateTime; - -public: - static const TimeSpan& get_MaxValue() - { - static TimeSpan val(0x7FFFFFFFFFFFFFFFLL); - return val; - } - - static const TimeSpan& get_MinValue() - { - static TimeSpan val(0x8000000000000000LL); - return val; - } - - static const TimeSpan& get_Zero() - { - static TimeSpan val(0); - return val; - } +}; + +class TimeSpan +{ + friend class DateTime; + +public: + static const TimeSpan& get_MaxValue() + { + static TimeSpan val(0x7FFFFFFFFFFFFFFFLL); + return val; + } + + static const TimeSpan& get_MinValue() + { + static TimeSpan val(0x8000000000000000LL); + return val; + } + + static const TimeSpan& get_Zero() + { + static TimeSpan val(0); + return val; + } static const s64 TicksPerDay = 864000000000LL; static const s64 TicksPerHour = 36000000000LL; static const s64 TicksPerMillisecond = 10000LL; static const s64 TicksPerMinute = 600000000LL; - static const s64 TicksPerSecond = 10000000LL; - - TimeSpan () - { - } - + static const s64 TicksPerSecond = 10000000LL; + + TimeSpan () + { + } + TimeSpan (s64 ticks) : _ticks(ticks) { @@ -294,8 +294,8 @@ public: private: - s64 _ticks; - + s64 _ticks; + static s64 CalculateTicks (int days, int hours, int minutes, int seconds, int milliseconds) { // there's no overflow checks for hours, minutes, ... @@ -369,18 +369,18 @@ private: //} }; - -class DateTime -{ -private: - TimeSpan ticks; - static inline double round(const double x) { return floor(x + 0.5); } +class DateTime +{ +private: + TimeSpan ticks; + + static inline double round(const double x) { return floor(x + 0.5); } static const int dp400 = 146097; static const int dp100 = 36524; static const int dp4 = 1461; - + // w32 file time starts counting from 1/1/1601 00:00 GMT // which is the constant ticks from the .NET epoch static const s64 w32file_epoch = 504911232000000000LL; @@ -394,7 +394,7 @@ private: // in Ticks // static const s64 UnixEpoch = 621355968000000000LL; - + static const int daysmonth[13]; static const int daysmonthleap[13]; @@ -415,7 +415,7 @@ private: ticks = TimeSpan (AbsoluteDays(year,month,day), hour, minute, second, millisecond); } - + static int AbsoluteDays (int year, int month, int day) @@ -589,8 +589,8 @@ public: static DateTime get_Now () { - time_t timer; - time(&timer); + time_t timer; + time(&timer); struct tm *tm = localtime(&timer); return DateTime(tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec); } @@ -657,7 +657,6 @@ public: DateTime AddMonths (int months) const { int day, month, year, maxday ; - DateTime temp; day = get_Day(); month = get_Month() + (months % 12); @@ -677,7 +676,7 @@ public: if (day > maxday) day = maxday; - temp = (year, month, day); + DateTime temp(year, month, day); return temp.Add (get_TimeOfDay()); } @@ -784,7 +783,7 @@ public: std::string ToString() const { char tmp[32]; - sprintf(tmp,"%04d-%s-%02d %02d:%02d:%02d:%03d",get_Year(),monthnames[get_Month()],get_Day(),get_Hour(),get_Minute(),get_Second(),get_Millisecond()); + snprintf(tmp, sizeof(tmp), "%04d-%s-%02d %02d:%02d:%02d:%03d",get_Year(),monthnames[get_Month()],get_Day(),get_Hour(),get_Minute(),get_Second(),get_Millisecond()); return tmp; } @@ -812,7 +811,7 @@ public: return ret; } -}; - - -#endif //_DATETIME_H_ +}; + + +#endif //_DATETIME_H_