From 182f81fb46ec6c9575256f7f6836731bd6e6d72e Mon Sep 17 00:00:00 2001 From: riccardom Date: Sat, 23 Jul 2011 16:01:48 +0000 Subject: [PATCH] Fix memory block alignment in RomBanner for 4-byte wchar_t, #3354040 From rogerman: The RomBanner struct requires UTF-16 strings for the six different ROM titles. Currently, we use wchar_t buffers to define the memory blocks where the title strings are supposed to go. Using wchar_t is fine for compilers that assume a 2-byte wchar_t. But compilers that use a 4-byte wchar_t will misalign the memory blocks. I've submitted a new patch that changes all the wchar_t in RomBanner titles to u16 for all ports. It took me a while to research the dependencies on titles, and to make sure I didn't accidentally break something in the Windows port. As for the wcscpy() deal in the RomBanner constructor, it's an arbitrary default init value that we don't actually use in practice, so I removed it. If a particular port wants to know what to display for the titles when a ROM isn't loaded, there are plenty of ways to figure this out. Or they can just check the titles for an empty string, which the constructor inits the titles to before the wcscpy() call. For CHEATS::save(), I removed the dependency on using titles. The ROM name we write to file is also an arbitrary value which we don't actually reference in practice. I changed it to use gameInfo.ROMname, since we're already using gameInfo.ROMserial. --- desmume/src/NDSSystem.cpp | 2 -- desmume/src/NDSSystem.h | 14 +++++++------- desmume/src/cheatSystem.cpp | 7 +------ 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 9e1a30c9e..6a6ca4b75 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -306,8 +306,6 @@ RomBanner::RomBanner(bool defaultInit) memset(bitmap,0,sizeof(bitmap)); memset(palette,0,sizeof(palette)); memset(titles,0,sizeof(titles)); - for(int i=0;i