From 3da05af30ab82639b5898f6ef46326bdd2f1dc7e Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 3 Jan 2013 10:35:07 -0600 Subject: Fix truncated names and descriptions in the game list on linux. --- Source/Core/Common/Src/ChunkFile.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h index be8b49a3a3..e26536735d 100644 --- a/Source/Core/Common/Src/ChunkFile.h +++ b/Source/Core/Common/Src/ChunkFile.h @@ -155,7 +155,14 @@ public: Do(stringLen); switch (mode) { - case MODE_READ: x = (wchar_t*)*ptr; break; + case MODE_READ: + { + wchar_t* tmp = new wchar_t[stringLen / sizeof(wchar_t)]; + memcpy(tmp, *ptr, stringLen); + x = tmp; + delete[] tmp; + } + break; case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; case MODE_MEASURE: break; case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break; -- cgit v1.2.3 From 12a606501c108de1c513f4aacf4e345fe077bd8d Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 3 Jan 2013 19:21:20 -0600 Subject: Fix the name and description truncation issue in a cleaner way. --- Source/Core/Common/Src/ChunkFile.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h index e26536735d..5a6f26e7c3 100644 --- a/Source/Core/Common/Src/ChunkFile.h +++ b/Source/Core/Common/Src/ChunkFile.h @@ -155,14 +155,7 @@ public: Do(stringLen); switch (mode) { - case MODE_READ: - { - wchar_t* tmp = new wchar_t[stringLen / sizeof(wchar_t)]; - memcpy(tmp, *ptr, stringLen); - x = tmp; - delete[] tmp; - } - break; + case MODE_READ: x.assign((wchar_t*)*ptr, stringLen / sizeof(wchar_t)); break; case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; case MODE_MEASURE: break; case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break; -- cgit v1.2.3 From 9b51c99c6ba5f1b5f256032f6750540d7d8b2b0e Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 3 Jan 2013 19:49:19 -0600 Subject: Make sure the null character is not included in the string. --- Source/Core/Common/Src/ChunkFile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h index 5a6f26e7c3..38e1b2176c 100644 --- a/Source/Core/Common/Src/ChunkFile.h +++ b/Source/Core/Common/Src/ChunkFile.h @@ -155,7 +155,7 @@ public: Do(stringLen); switch (mode) { - case MODE_READ: x.assign((wchar_t*)*ptr, stringLen / sizeof(wchar_t)); break; + case MODE_READ: x.assign((wchar_t*)*ptr, (stringLen / sizeof(wchar_t)) - 1); break; case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; case MODE_MEASURE: break; case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break; -- cgit v1.2.3 From 6df1dacca8ffdf7109e0d914751eed6e8185b172 Mon Sep 17 00:00:00 2001 From: skidau Date: Mon, 7 Jan 2013 12:16:04 +1100 Subject: OpenAL for Windows initial commit --- Source/Core/Common/Src/Common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index 884a1e6c16..c3cab37dd8 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -81,8 +81,9 @@ private: #define GC_ALIGNED16_DECL(x) __declspec(align(16)) x #define GC_ALIGNED64_DECL(x) __declspec(align(64)) x -// Since it is always around on windows +// Since they are always around on windows #define HAVE_WX 1 + #define HAVE_OPENAL 1 #define HAVE_PORTAUDIO 1 -- cgit v1.2.3 From d0301ca89d318d8d6e3e7fde9c4b60e470e184e4 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 7 Jan 2013 13:47:34 -0600 Subject: Revert 30dd9c2 e9d00bf db5f4c8 and bff0fae --- Source/Core/Common/Src/MathUtil.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/MathUtil.h b/Source/Core/Common/Src/MathUtil.h index c5f613ada1..a6290ff602 100644 --- a/Source/Core/Common/Src/MathUtil.h +++ b/Source/Core/Common/Src/MathUtil.h @@ -117,8 +117,6 @@ struct Rectangle Rectangle(T theLeft, T theTop, T theRight, T theBottom) : left(theLeft), top(theTop), right(theRight), bottom(theBottom) { } - - bool operator==(const Rectangle& r) { return left==r.left && top==r.top && right==r.right && bottom==r.bottom; } T GetWidth() const { return abs(right - left); } T GetHeight() const { return abs(bottom - top); } -- cgit v1.2.3 From 876eee5e601915dd361a16899754d35b43cae80c Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 8 Jan 2013 16:01:15 +0100 Subject: PixelShaderGen: Don't disable depth texture emulation if z writing is disabled (this is what VideoSoftware is doing). --- Source/Core/Common/Src/LinearDiskCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h index 4c746e9b75..0f4e3f7832 100644 --- a/Source/Core/Common/Src/LinearDiskCache.h +++ b/Source/Core/Common/Src/LinearDiskCache.h @@ -24,7 +24,7 @@ // Increment this every time you change shader generation code. enum { - LINEAR_DISKCACHE_VER = 6975 + LINEAR_DISKCACHE_VER = 6977 }; // On disk format: -- cgit v1.2.3 From b06f30f8452af075f5929e37f168e54bfd37083a Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 8 Jan 2013 16:40:15 +0100 Subject: Remove the per pixel depth option. Depth calculations are always done in the pixel shader now. Due to the unpredictability of our zcomploc hacks this commit probably changes the behavior of some games which use zcomploc. --- Source/Core/Common/Src/LinearDiskCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h index 0f4e3f7832..f75e80cd4b 100644 --- a/Source/Core/Common/Src/LinearDiskCache.h +++ b/Source/Core/Common/Src/LinearDiskCache.h @@ -24,7 +24,7 @@ // Increment this every time you change shader generation code. enum { - LINEAR_DISKCACHE_VER = 6977 + LINEAR_DISKCACHE_VER = 6978 }; // On disk format: -- cgit v1.2.3 From 4925a28f94d8a9925a85824ec89513c6774bdc30 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 8 Jan 2013 17:29:16 +0100 Subject: PixelShaderGen: Shader uid maintainance --- Source/Core/Common/Src/LinearDiskCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h index f75e80cd4b..9755c996bd 100644 --- a/Source/Core/Common/Src/LinearDiskCache.h +++ b/Source/Core/Common/Src/LinearDiskCache.h @@ -24,7 +24,7 @@ // Increment this every time you change shader generation code. enum { - LINEAR_DISKCACHE_VER = 6978 + LINEAR_DISKCACHE_VER = 6979 }; // On disk format: -- cgit v1.2.3 From baa29f571c0fa914cc80d505e7db1f9c7a654488 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 8 Jan 2013 15:02:50 -0600 Subject: Fix incorrect iterator usage in BreakPoints::Clear --- Source/Core/Common/Src/BreakPoints.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/BreakPoints.cpp b/Source/Core/Common/Src/BreakPoints.cpp index 1700276d85..62fadefd4f 100644 --- a/Source/Core/Common/Src/BreakPoints.cpp +++ b/Source/Core/Common/Src/BreakPoints.cpp @@ -19,7 +19,9 @@ #include "DebugInterface.h" #include "BreakPoints.h" #include "../../Core/Src/PowerPC/JitCommon/JitBase.h" + #include +#include bool BreakPoints::IsAddressBreakPoint(u32 _iAddress) { @@ -110,12 +112,17 @@ void BreakPoints::Remove(u32 em_address) void BreakPoints::Clear() { - for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i) + if (jit) { - if (jit) - jit->GetBlockCache()->InvalidateICache(i->iAddress, 4); - m_BreakPoints.erase(i); + std::for_each(m_BreakPoints.begin(), m_BreakPoints.end(), + [](const TBreakPoint& bp) + { + jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4); + } + ); } + + m_BreakPoints.clear(); } MemChecks::TMemChecksStr MemChecks::GetStrings() const -- cgit v1.2.3 From 4f4aa4860df98f401384f6e598cb649b13882e79 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 8 Jan 2013 16:50:09 -0600 Subject: Fix a currently unused unique_lock function. Thanks to Lioncash. --- Source/Core/Common/Src/StdMutex.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/StdMutex.h b/Source/Core/Common/Src/StdMutex.h index 150d18f53e..8949e905ac 100644 --- a/Source/Core/Common/Src/StdMutex.h +++ b/Source/Core/Common/Src/StdMutex.h @@ -318,9 +318,12 @@ public: mutex_type* release() { - return mutex(); + auto const ret = mutex(); + pm = NULL; owns = false; + + return ret; } bool owns_lock() const -- cgit v1.2.3 From cf942450e0aec50ce815e086a9dc277b59b18bae Mon Sep 17 00:00:00 2001 From: lioncash Date: Thu, 10 Jan 2013 17:38:38 -0500 Subject: Very tiny cleanup of ChunkFile.h. Also changed the size parameter from DoVoid to size_t. As far as I know, that should never be negative. Also changed the the count parameter of DoArray to size_t, this also should never be negative. Got rid of some typecasts. --- Source/Core/Common/Src/ChunkFile.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h index 38e1b2176c..cc893cc8e7 100644 --- a/Source/Core/Common/Src/ChunkFile.h +++ b/Source/Core/Common/Src/ChunkFile.h @@ -63,13 +63,13 @@ public: Mode GetMode() const {return mode;} u8 **GetPPtr() {return ptr;} - void DoVoid(void *data, int size) + void DoVoid(void *data, size_t size) { switch (mode) { case MODE_READ: memcpy(data, *ptr, size); break; case MODE_WRITE: memcpy(*ptr, data, size); break; case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything - case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; + case MODE_VERIFY: for(size_t i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; default: break; // throw an error? } (*ptr) += size; @@ -78,7 +78,7 @@ public: template void Do(std::map &x) { - unsigned int number = (unsigned int)x.size(); + size_t number = x.size(); Do(number); switch (mode) { case MODE_READ: @@ -126,18 +126,17 @@ public: template void Do(std::deque &x) { - u32 deq_size = (u32)x.size(); + size_t deq_size = x.size(); Do(deq_size); x.resize(deq_size); - u32 i; - for(i = 0; i < deq_size; i++) + for(size_t i = 0; i < deq_size; i++) DoVoid(&x[i],sizeof(T)); } // Store strings. void Do(std::string &x) { - int stringLen = (int)x.length() + 1; + size_t stringLen = (x.length() + 1); Do(stringLen); switch (mode) { @@ -151,7 +150,7 @@ public: void Do(std::wstring &x) { - int stringLen = sizeof(wchar_t)*((int)x.length() + 1); + size_t stringLen = sizeof(wchar_t)*(x.length() + 1); Do(stringLen); switch (mode) { @@ -164,7 +163,7 @@ public: } template - void DoArray(T *x, int count) { + void DoArray(T *x, size_t count) { DoVoid((void *)x, sizeof(T) * count); } -- cgit v1.2.3 From 51a1d4cde73b1d497792504f0b96afff1fc9cc09 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Thu, 10 Jan 2013 17:39:07 -0600 Subject: Revert "Very tiny cleanup of ChunkFile.h." int/size_t change without updating the rev# caused crash on Dolphin start This reverts commit cf942450e0aec50ce815e086a9dc277b59b18bae. --- Source/Core/Common/Src/ChunkFile.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h index cc893cc8e7..38e1b2176c 100644 --- a/Source/Core/Common/Src/ChunkFile.h +++ b/Source/Core/Common/Src/ChunkFile.h @@ -63,13 +63,13 @@ public: Mode GetMode() const {return mode;} u8 **GetPPtr() {return ptr;} - void DoVoid(void *data, size_t size) + void DoVoid(void *data, int size) { switch (mode) { case MODE_READ: memcpy(data, *ptr, size); break; case MODE_WRITE: memcpy(*ptr, data, size); break; case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything - case MODE_VERIFY: for(size_t i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; + case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; default: break; // throw an error? } (*ptr) += size; @@ -78,7 +78,7 @@ public: template void Do(std::map &x) { - size_t number = x.size(); + unsigned int number = (unsigned int)x.size(); Do(number); switch (mode) { case MODE_READ: @@ -126,17 +126,18 @@ public: template void Do(std::deque &x) { - size_t deq_size = x.size(); + u32 deq_size = (u32)x.size(); Do(deq_size); x.resize(deq_size); - for(size_t i = 0; i < deq_size; i++) + u32 i; + for(i = 0; i < deq_size; i++) DoVoid(&x[i],sizeof(T)); } // Store strings. void Do(std::string &x) { - size_t stringLen = (x.length() + 1); + int stringLen = (int)x.length() + 1; Do(stringLen); switch (mode) { @@ -150,7 +151,7 @@ public: void Do(std::wstring &x) { - size_t stringLen = sizeof(wchar_t)*(x.length() + 1); + int stringLen = sizeof(wchar_t)*((int)x.length() + 1); Do(stringLen); switch (mode) { @@ -163,7 +164,7 @@ public: } template - void DoArray(T *x, size_t count) { + void DoArray(T *x, int count) { DoVoid((void *)x, sizeof(T) * count); } -- cgit v1.2.3 From dfc0c4b08d339502989fdfaf21e89f8ed77366a3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 11 Jan 2013 19:38:04 -0500 Subject: Fix two signed/unsigned mismatch warnings. Also tidied up SDCardUtil - made the variables make more sense (typewise) --- Source/Core/Common/Src/SDCardUtil.cpp | 98 +++++++++++++++++------------------ 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/SDCardUtil.cpp b/Source/Core/Common/Src/SDCardUtil.cpp index 4002a51b99..0f2ad08607 100644 --- a/Source/Core/Common/Src/SDCardUtil.cpp +++ b/Source/Core/Common/Src/SDCardUtil.cpp @@ -40,7 +40,7 @@ #include // for unlink() #endif -/* believe me, you *don't* want to change these constants !! */ +/* Believe me, you *don't* want to change these constants !! */ #define BYTES_PER_SECTOR 512 #define RESERVED_SECTORS 32 #define BACKUP_BOOT_SECTOR 6 @@ -52,15 +52,15 @@ #define POKES(p,v) ( BYTE_(p,0) = (u8)(v), BYTE_(p,1) = (u8)((v) >> 8) ) #define POKEW(p,v) ( BYTE_(p,0) = (u8)(v), BYTE_(p,1) = (u8)((v) >> 8), BYTE_(p,2) = (u8)((v) >> 16), BYTE_(p,3) = (u8)((v) >> 24) ) -static u8 s_boot_sector [ BYTES_PER_SECTOR ]; /* boot sector */ +static u8 s_boot_sector [ BYTES_PER_SECTOR ]; /* Boot sector */ static u8 s_fsinfo_sector [ BYTES_PER_SECTOR ]; /* FS Info sector */ -static u8 s_fat_head [ BYTES_PER_SECTOR ]; /* first FAT sector */ +static u8 s_fat_head [ BYTES_PER_SECTOR ]; /* First FAT sector */ -/* this is the date and time when creating the disk */ -static int get_serial_id() +/* This is the date and time when creating the disk */ +static unsigned int get_serial_id() { u16 lo, hi; - time_t now = time(NULL); + time_t now = time(nullptr); struct tm tm = gmtime( &now )[0]; lo = (u16)(tm.tm_mday + ((tm.tm_mon+1) << 8) + (tm.tm_sec << 8)); @@ -69,7 +69,7 @@ static int get_serial_id() return lo + (hi << 16); } -static int get_sectors_per_cluster(u64 disk_size) +static unsigned int get_sectors_per_cluster(u64 disk_size) { u64 disk_MB = disk_size/(1024*1024); @@ -88,60 +88,60 @@ static int get_sectors_per_cluster(u64 disk_size) return 32; } -static int get_sectors_per_fat(u64 disk_size, int sectors_per_cluster) +static unsigned int get_sectors_per_fat(u64 disk_size, u32 sectors_per_cluster) { u64 divider; - /* weird computation from MS - see fatgen103.doc for details */ - disk_size -= RESERVED_SECTORS * BYTES_PER_SECTOR; /* don't count 32 reserved sectors */ - disk_size /= BYTES_PER_SECTOR; /* disk size in sectors */ + /* Weird computation from MS - see fatgen103.doc for details */ + disk_size -= RESERVED_SECTORS * BYTES_PER_SECTOR; /* Don't count 32 reserved sectors */ + disk_size /= BYTES_PER_SECTOR; /* Disk size in sectors */ divider = ((256 * sectors_per_cluster) + NUM_FATS) / 2; - return (int)( (disk_size + (divider-1)) / divider ); + return (u32)( (disk_size + (divider-1)) / divider ); } static void boot_sector_init(u8* boot, u8* info, u64 disk_size, const char* label) { - int sectors_per_cluster = get_sectors_per_cluster(disk_size); - int sectors_per_fat = get_sectors_per_fat(disk_size, sectors_per_cluster); - int sectors_per_disk = (int)(disk_size / BYTES_PER_SECTOR); - int serial_id = get_serial_id(); - int free_count; + u32 sectors_per_cluster = get_sectors_per_cluster(disk_size); + u32 sectors_per_fat = get_sectors_per_fat(disk_size, sectors_per_cluster); + u32 sectors_per_disk = (u32)(disk_size / BYTES_PER_SECTOR); + u32 serial_id = get_serial_id(); + u32 free_count; - if (label == NULL) + if (label == nullptr) label = "DOLPHINSD"; POKEB(boot, 0xeb); POKEB(boot+1, 0x5a); POKEB(boot+2, 0x90); strcpy( (char*)boot + 3, "MSWIN4.1" ); - POKES( boot + 0x0b, BYTES_PER_SECTOR ); /* sector size */ - POKEB( boot + 0xd, sectors_per_cluster ); /* sectors per cluster */ - POKES( boot + 0xe, RESERVED_SECTORS ); /* reserved sectors before first FAT */ - POKEB( boot + 0x10, NUM_FATS ); /* number of FATs */ - POKES( boot + 0x11, 0 ); /* max root directory entries for FAT12/FAT16, 0 for FAT32 */ - POKES( boot + 0x13, 0 ); /* total sectors, 0 to use 32-bit value at offset 0x20 */ - POKEB( boot + 0x15, 0xF8 ); /* media descriptor, 0xF8 == hard disk */ + POKES( boot + 0x0b, BYTES_PER_SECTOR ); /* Sector size */ + POKEB( boot + 0xd, sectors_per_cluster ); /* Sectors per cluster */ + POKES( boot + 0xe, RESERVED_SECTORS ); /* Reserved sectors before first FAT */ + POKEB( boot + 0x10, NUM_FATS ); /* Number of FATs */ + POKES( boot + 0x11, 0 ); /* Max root directory entries for FAT12/FAT16, 0 for FAT32 */ + POKES( boot + 0x13, 0 ); /* Total sectors, 0 to use 32-bit value at offset 0x20 */ + POKEB( boot + 0x15, 0xF8 ); /* Media descriptor, 0xF8 == hard disk */ POKES( boot + 0x16, 0 ); /* Sectors per FAT for FAT12/16, 0 for FAT32 */ POKES( boot + 0x18, 9 ); /* Sectors per track (whatever) */ POKES( boot + 0x1a, 2 ); /* Number of heads (whatever) */ POKEW( boot + 0x1c, 0 ); /* Hidden sectors */ POKEW( boot + 0x20, sectors_per_disk ); /* Total sectors */ - /* extension */ + /* Extension */ POKEW( boot + 0x24, sectors_per_fat ); /* Sectors per FAT */ POKES( boot + 0x28, 0 ); /* FAT flags */ - POKES( boot + 0x2a, 0 ); /* version */ - POKEW( boot + 0x2c, 2 ); /* cluster number of root directory start */ - POKES( boot + 0x30, 1 ); /* sector number of FS information sector */ - POKES( boot + 0x32, BACKUP_BOOT_SECTOR ); /* sector number of a copy of this boot sector */ - POKEB( boot + 0x40, 0x80 ); /* physical drive number */ - POKEB( boot + 0x42, 0x29 ); /* extended boot signature ?? */ - POKEW( boot + 0x43, serial_id ); /* serial ID */ + POKES( boot + 0x2a, 0 ); /* Version */ + POKEW( boot + 0x2c, 2 ); /* Cluster number of root directory start */ + POKES( boot + 0x30, 1 ); /* Sector number of FS information sector */ + POKES( boot + 0x32, BACKUP_BOOT_SECTOR ); /* Sector number of a copy of this boot sector */ + POKEB( boot + 0x40, 0x80 ); /* Physical drive number */ + POKEB( boot + 0x42, 0x29 ); /* Extended boot signature ?? */ + POKEW( boot + 0x43, serial_id ); /* Serial ID */ strncpy( (char*)boot + 0x47, label, 11 ); /* Volume Label */ memcpy( boot + 0x52, "FAT32 ", 8 ); /* FAT system type, padded with 0x20 */ - POKEB( boot + BYTES_PER_SECTOR-2, 0x55 ); /* boot sector signature */ + POKEB( boot + BYTES_PER_SECTOR-2, 0x55 ); /* Boot sector signature */ POKEB( boot + BYTES_PER_SECTOR-1, 0xAA ); /* FSInfo sector */ @@ -149,25 +149,25 @@ static void boot_sector_init(u8* boot, u8* info, u64 disk_size, const char* labe POKEW( info + 0, 0x41615252 ); POKEW( info + 484, 0x61417272 ); - POKEW( info + 488, free_count ); /* number of free clusters */ - POKEW( info + 492, 3 ); /* next free clusters, 0-1 reserved, 2 is used for the root dir */ + POKEW( info + 488, free_count ); /* Number of free clusters */ + POKEW( info + 492, 3 ); /* Next free clusters, 0-1 reserved, 2 is used for the root dir */ POKEW( info + 508, 0xAA550000 ); } static void fat_init(u8* fat) { - POKEW( fat, 0x0ffffff8 ); /* reserve cluster 1, media id in low byte */ - POKEW( fat + 4, 0x0fffffff ); /* reserve cluster 2 */ - POKEW( fat + 8, 0x0fffffff ); /* end of clust chain for root dir */ + POKEW( fat, 0x0ffffff8 ); /* Reserve cluster 1, media id in low byte */ + POKEW( fat + 4, 0x0fffffff ); /* Reserve cluster 2 */ + POKEW( fat + 8, 0x0fffffff ); /* End of cluster chain for root dir */ } -static int write_sector(FILE* file, u8* sector) +static unsigned int write_sector(FILE* file, u8* sector) { return fwrite(sector, 1, 512, file) != 512; } -static int write_empty(FILE* file, u64 count) +static unsigned int write_empty(FILE* file, u64 count) { static u8 empty[64*1024]; @@ -188,8 +188,8 @@ static int write_empty(FILE* file, u64 count) bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename) { - int sectors_per_fat; - int sectors_per_disk; + u32 sectors_per_fat; + u32 sectors_per_disk; FILE* f; // Convert MB to bytes @@ -200,21 +200,21 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename) return false; } - // pretty unlikely to overflow. - sectors_per_disk = (int)(disk_size / 512); + // Pretty unlikely to overflow. + sectors_per_disk = (u32)(disk_size / 512); sectors_per_fat = get_sectors_per_fat(disk_size, get_sectors_per_cluster(disk_size)); - boot_sector_init(s_boot_sector, s_fsinfo_sector, disk_size, NULL ); + boot_sector_init(s_boot_sector, s_fsinfo_sector, disk_size, nullptr); fat_init(s_fat_head); f = fopen(filename, "wb"); if (!f) { - ERROR_LOG(COMMON, "could not create file '%s', aborting...\n", filename); + ERROR_LOG(COMMON, "Could not create file '%s', aborting...\n", filename); return false; } - /* here's the layout: + /* Here's the layout: * * boot_sector * fsinfo_sector @@ -251,7 +251,7 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename) return true; FailWrite: - ERROR_LOG(COMMON, "could not write to '%s', aborting...\n", filename); + ERROR_LOG(COMMON, "Could not write to '%s', aborting...\n", filename); if (unlink(filename) < 0) ERROR_LOG(COMMON, "unlink(%s) failed\n%s", filename, GetLastErrorMsg()); fclose(f); -- cgit v1.2.3 From 6f7b11b9bebf4a80a6d09d344c312241a9abe16e Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 13 Jan 2013 14:06:15 -0600 Subject: themes directory stuffs --- Source/Core/Common/Src/CommonPaths.h | 1 + Source/Core/Common/Src/FileUtil.cpp | 1 + Source/Core/Common/Src/FileUtil.h | 1 + 3 files changed, 3 insertions(+) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index 430a0c0cd8..c39056a946 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -89,6 +89,7 @@ #define MAIL_LOGS_DIR LOGS_DIR DIR_SEP "Mail" #define SHADERS_DIR "Shaders" #define WII_SYSCONF_DIR "shared2" DIR_SEP "sys" +#define THEMES_DIR "Themes" // Filenames // Files in the directory returned by GetUserPath(D_CONFIG_IDX) diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 77290528a6..acd4588126 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -678,6 +678,7 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath) paths[D_DUMPDSP_IDX] = paths[D_USER_IDX] + DUMP_DSP_DIR DIR_SEP; paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; paths[D_MAILLOGS_IDX] = paths[D_USER_IDX] + MAIL_LOGS_DIR DIR_SEP; + paths[D_THEMES_IDX] = paths[D_USER_IDX] + THEMES_DIR DIR_SEP; paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR DIR_SEP; paths[F_DOLPHINCONFIG_IDX] = paths[D_CONFIG_IDX] + DOLPHIN_CONFIG; paths[F_DSPCONFIG_IDX] = paths[D_CONFIG_IDX] + DSP_CONFIG; diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 9134bcf44e..0947db4f5c 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -50,6 +50,7 @@ enum { D_LOGS_IDX, D_MAILLOGS_IDX, D_WIISYSCONF_IDX, + D_THEMES_IDX, F_DOLPHINCONFIG_IDX, F_DSPCONFIG_IDX, F_DEBUGGERCONFIG_IDX, -- cgit v1.2.3 From a9ff3709e485a4f38189c694c540652468cc1d19 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 13 Jan 2013 15:32:26 -0600 Subject: Attempt to make file searching stuff less crappy on Linux. Supports a * search now. --- Source/Core/Common/Src/FileSearch.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/FileSearch.cpp b/Source/Core/Common/Src/FileSearch.cpp index c60ce9beda..595dfe7000 100644 --- a/Source/Core/Common/Src/FileSearch.cpp +++ b/Source/Core/Common/Src/FileSearch.cpp @@ -25,6 +25,7 @@ #endif #include +#include #include "FileSearch.h" @@ -72,36 +73,36 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& #else - size_t dot_pos = _searchString.rfind("."); + // TODO: super lame/broken - if (dot_pos == std::string::npos) - return; + auto end_match(_searchString); + + // assuming we have a "*.blah"-like pattern + if (!end_match.empty() && end_match[0] == '*') + end_match.erase(0, 1); + + // ugly + if (end_match == ".*") + end_match.clear(); - std::string ext = _searchString.substr(dot_pos); DIR* dir = opendir(_strPath.c_str()); if (!dir) return; - dirent* dp; - - while (true) + while (auto const dp = readdir(dir)) { - dp = readdir(dir); - - if (!dp) - break; - - std::string s(dp->d_name); + std::string found(dp->d_name); - if ( (!ext.compare(".*") && s.compare(".") && s.compare("..")) || - ((s.size() > ext.size()) && (!strcasecmp(s.substr(s.size() - ext.size()).c_str(), ext.c_str())) )) + if ((found != ".") && (found != "..") + && (found.size() >= end_match.size()) + && std::equal(end_match.rbegin(), end_match.rend(), found.rbegin())) { std::string full_name; if (_strPath.c_str()[_strPath.size()-1] == DIR_SEP_CHR) - full_name = _strPath + s; + full_name = _strPath + found; else - full_name = _strPath + DIR_SEP + s; + full_name = _strPath + DIR_SEP + found; m_FileNames.push_back(full_name); } -- cgit v1.2.3 From 196c2867adc1f80d1037b0b87e9d99e775cad375 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Wed, 16 Jan 2013 20:16:56 -0500 Subject: Move DSP settings to dolphin.ini --- Source/Core/Common/Src/CommonPaths.h | 1 - Source/Core/Common/Src/FileUtil.cpp | 1 - Source/Core/Common/Src/FileUtil.h | 1 - 3 files changed, 3 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index c39056a946..9e14d7cf7e 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -94,7 +94,6 @@ // Filenames // Files in the directory returned by GetUserPath(D_CONFIG_IDX) #define DOLPHIN_CONFIG "Dolphin.ini" -#define DSP_CONFIG "DSP.ini" #define DEBUGGER_CONFIG "Debugger.ini" #define LOGGER_CONFIG "Logger.ini" diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index acd4588126..d7b248a722 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -681,7 +681,6 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath) paths[D_THEMES_IDX] = paths[D_USER_IDX] + THEMES_DIR DIR_SEP; paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR DIR_SEP; paths[F_DOLPHINCONFIG_IDX] = paths[D_CONFIG_IDX] + DOLPHIN_CONFIG; - paths[F_DSPCONFIG_IDX] = paths[D_CONFIG_IDX] + DSP_CONFIG; paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 0947db4f5c..451b1b6929 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -52,7 +52,6 @@ enum { D_WIISYSCONF_IDX, D_THEMES_IDX, F_DOLPHINCONFIG_IDX, - F_DSPCONFIG_IDX, F_DEBUGGERCONFIG_IDX, F_LOGGERCONFIG_IDX, F_MAINLOG_IDX, -- cgit v1.2.3 From 2db0c4270eda2e652bb39e394aa8a576785a2354 Mon Sep 17 00:00:00 2001 From: lioncash Date: Thu, 24 Jan 2013 08:21:08 -0500 Subject: Fix a potential memory leak on non-windows systems. Also added a FIXME to BPStructs.cpp and BPMemLoader.cpp --- Source/Core/Common/Src/FileUtil.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index d7b248a722..d74c99b7a2 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -512,12 +512,24 @@ bool DeleteDirRecursively(const std::string &directory) if (IsDirectory(newPath)) { if (!DeleteDirRecursively(newPath)) + { + #ifndef _WIN32 + closedir(dirp); + #endif + return false; + } } else { if (!File::Delete(newPath)) + { + #ifndef _WIN32 + closedir(dirp); + #endif + return false; + } } #ifdef _WIN32 -- cgit v1.2.3 From d60cc373d1b389215eb63c4e20fe24e902680c7a Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 24 Jan 2013 16:11:07 +0100 Subject: Revert "Revert 30dd9c2 e9d00bf db5f4c8 and bff0fae" This reverts commit d0301ca89d318d8d6e3e7fde9c4b60e470e184e4. Conflicts: .gitignore --- Source/Core/Common/Src/MathUtil.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Src/MathUtil.h b/Source/Core/Common/Src/MathUtil.h index a6290ff602..c5f613ada1 100644 --- a/Source/Core/Common/Src/MathUtil.h +++ b/Source/Core/Common/Src/MathUtil.h @@ -117,6 +117,8 @@ struct Rectangle Rectangle(T theLeft, T theTop, T theRight, T theBottom) : left(theLeft), top(theTop), right(theRight), bottom(theBottom) { } + + bool operator==(const Rectangle& r) { return left==r.left && top==r.top && right==r.right && bottom==r.bottom; } T GetWidth() const { return abs(right - left); } T GetHeight() const { return abs(bottom - top); } -- cgit v1.2.3