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.
This commit is contained in:
parent
4bfd29c702
commit
182f81fb46
|
@ -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<NUM_TITLES;i++)
|
||||
wcscpy(titles[i],L"None");
|
||||
memset(end0xFF,0,sizeof(end0xFF));
|
||||
}
|
||||
|
||||
|
|
|
@ -284,14 +284,14 @@ struct RomBanner
|
|||
enum { NUM_TITLES = 6 };
|
||||
union {
|
||||
struct {
|
||||
wchar_t title_jp[0x80]; //Title 0 Japanese (128 characters, 16bit Unicode)
|
||||
wchar_t title_en[0x80]; //Title 1 English ("")
|
||||
wchar_t title_fr[0x80]; //Title 2 French ("")
|
||||
wchar_t title_de[0x80]; //Title 3 German ("")
|
||||
wchar_t title_it[0x80]; //Title 4 Italian ("")
|
||||
wchar_t title_es[0x80]; //Title 5 Spanish ("")
|
||||
u16 title_jp[0x80]; //Title 0 Japanese (128 characters, 16bit Unicode)
|
||||
u16 title_en[0x80]; //Title 1 English ("")
|
||||
u16 title_fr[0x80]; //Title 2 French ("")
|
||||
u16 title_de[0x80]; //Title 3 German ("")
|
||||
u16 title_it[0x80]; //Title 4 Italian ("")
|
||||
u16 title_es[0x80]; //Title 5 Spanish ("")
|
||||
};
|
||||
wchar_t titles[NUM_TITLES][0x80];
|
||||
u16 titles[NUM_TITLES][0x80];
|
||||
};
|
||||
u8 end0xFF[0x1C0];
|
||||
//840h ? (Maybe newer/chinese firmware do also support chinese title?)
|
||||
|
|
|
@ -565,12 +565,7 @@ BOOL CHEATS::save()
|
|||
if (flist)
|
||||
{
|
||||
fprintf(flist, "; DeSmuME cheats file. VERSION %i.%03i\n", CHEAT_VERSION_MAJOR, CHEAT_VERSION_MINOR);
|
||||
std::wstring wtemp = (std::wstring)gameInfo.getRomBanner().titles[1];
|
||||
std::string temp = wcstombs(wtemp);
|
||||
strcpy(buf, temp.c_str());
|
||||
trim(buf);
|
||||
removeSpecialChars(buf);
|
||||
fprintf(flist, "Name=%s\n", buf);
|
||||
fprintf(flist, "Name=%s\n", gameInfo.ROMname);
|
||||
fprintf(flist, "Serial=%s\n", gameInfo.ROMserial);
|
||||
fputs("\n; cheats list\n", flist);
|
||||
for (size_t i = 0; i < list.size(); i++)
|
||||
|
|
Loading…
Reference in New Issue