From 16117e0e4c6faede12aeca7d1c7ebfe782df26a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Mar 2015 22:52:51 -0500 Subject: [PATCH 1/3] Load non-printable or non-ASCII characters as '?'. --- Source/Glide64/Main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 45a388391..65f67f596 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -1732,8 +1732,18 @@ void CALL RomOpen (void) // get the name of the ROM for (int i=0; i<20; i++) - name[i] = gfx.HEADER[(32+i)^3]; - name[20] = 0; + { + char ch; + const char invalid_ch = '?'; /* Some Japanese games use wide chars. */ + + ch = (char)gfx.HEADER[(32 + i) ^ 3]; + if (ch < ' ') + ch = invalid_ch; + if (ch > '~') + ch = invalid_ch; + name[i] = ch; + } + name[20] = '\0'; // remove all trailing spaces while (name[strlen(name)-1] == ' ') From 0ab6c15f05cd6e4fc42fec750fc515a24dafa842 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Mar 2015 22:55:27 -0500 Subject: [PATCH 2/3] Load null bytes as whitespace. A few lines down in this file, there is a while() loop that removes all trailing spaces to replace them with null bytes, so "SUPER MARIO 64 " becomes "SUPER MARIO 64", whether or not we converted null bytes to spaces. Also, the null byte is not documented to be a valid character for game developers to use in their ROM headers, even though for a few ROMs this is being done anyway. --- Source/Glide64/Main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 65f67f596..0f150145b 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -1737,6 +1737,8 @@ void CALL RomOpen (void) const char invalid_ch = '?'; /* Some Japanese games use wide chars. */ ch = (char)gfx.HEADER[(32 + i) ^ 3]; + if (ch == '\0') + ch = ' '; if (ch < ' ') ch = invalid_ch; if (ch > '~') From e97389560bda4e2d96f48de6a9e2afae59964266 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Mar 2015 22:57:14 -0500 Subject: [PATCH 3/3] now able to parse ROM header's game title as ASCII data again --- Source/Glide64/Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 0f150145b..2b3dfc2ed 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -1751,7 +1751,7 @@ void CALL RomOpen (void) while (name[strlen(name)-1] == ' ') name[strlen(name)-1] = 0; - wxString strRomName = wxString::FromUTF8(name); + wxString strRomName = wxString::FromAscii(name); if (settings.ghq_use && strRomName != rdp.RomName) { ext_ghq_shutdown();