It is currently Sat May 18, 2013 5:11 am

All times are UTC




Post new topic Reply to topic  [ 20 posts ] 
Author Message
PostPosted: Sat Jul 21, 2012 4:37 am 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
win32: improve DBCS processing in S9xBasename. This one should process S9xBasename("C:\roms\ソウルブレイダー.smc") correctly.
Code:
612369f106bdc4d79c4f8727e68484bf046f5c11
 win32/win32.cpp |   26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/win32/win32.cpp b/win32/win32.cpp
index 7d4a52f..3492280 100644
--- a/win32/win32.cpp
+++ b/win32/win32.cpp
@@ -611,16 +611,28 @@ void S9xSyncSpeed( void)
 
 const char *S9xBasename (const char *f)
 {
-    const char *p;
-    if ((p = strrchr (f, '/')) != NULL || (p = strrchr (f, '\\')) != NULL)
-   return (p + 1);
+   const char *p = f;
+   const char *last = p;
+   const char *slash;
 
-#ifdef __DJGPP
-    if (p = _tcsrchr (f, SLASH_CHAR))
-   return (p + 1);
+   // search rightmost separator
+   while ((slash = strchr (p, '/')) != NULL || (slash = strchr (p, '\\')) != NULL)
+   {
+      p = slash + 1;
+
+#ifdef UNICODE
+      // update always; UTF-8 doesn't have a problem between ASCII character and multi-byte character.
+      last = p;
+#else
+      // update if it's not a trailer byte of a double-byte character.
+      if (CharPrev(f, p) == slash)
+      {
+         last = p;
+      }
 #endif
+   }
 
-    return (f);
+   return last;
 }
 
 bool8 S9xReadMousePosition (int which, int &x, int &y, uint32 &buttons)


win32: fix Cheat Search not to add the same cheat twice.
Code:
a1a3cfc986062cacc72ac158f13e1d01bf64a6e5
 win32/wsnes9x.cpp |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp
index 694338f..66c794b 100644
--- a/win32/wsnes9x.cpp
+++ b/win32/wsnes9x.cpp
@@ -9613,16 +9613,7 @@ INT_PTR CALLBACK DlgCheatSearch(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
                }
                cht.format=val_type;
                //invoke dialog
-               if(!DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHEAT_FROM_SEARCH), hDlg, DlgCheatSearchAdd, (LPARAM)&cht))
-               {
-                  int p;
-                  for(p=0; p<cht.size; p++)
-                  {
-                     S9xAddCheat(TRUE, cht.saved, cht.address +p, ((cht.new_val>>(8*p))&0xFF));
-                     //add cheat
-                     strcpy(Cheat.c[Cheat.num_cheats-1].name, cht.name);
-                  }
-               }
+               DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHEAT_FROM_SEARCH), hDlg, DlgCheatSearchAdd, (LPARAM)&cht);
             }
             break;
          case IDC_C_RESET:
@@ -10132,8 +10123,11 @@ INT_PTR CALLBACK DlgCheatSearchAdd(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
                   strncpy(new_cheat->name,_tToChar(tempBuf),22);
 
                   new_cheat->enabled=TRUE;
-                  S9xAddCheat(new_cheat->enabled,new_cheat->saved_val,new_cheat->address,new_cheat->new_val);
-                  strcpy(Cheat.c[Cheat.num_cheats-1].name,new_cheat->name);
+                  for(int byteIndex = 0; byteIndex < new_cheat->size; byteIndex++)
+                  {
+                     S9xAddCheat(new_cheat->enabled,new_cheat->saved_val,new_cheat->address+byteIndex,(new_cheat->new_val>>(8*byteIndex))&0xFF);
+                     strcpy(Cheat.c[Cheat.num_cheats-1].name,new_cheat->name);
+                  }
                   ret=0;
                }
             }

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Sat Jul 21, 2012 5:48 pm 
Offline
Hero of Hyrule | Official Port Recruiter

Joined: Mon May 24, 2004 5:06 pm
Posts: 2490
Location: 255.255.255.255
just curious, does the first patch allow all Japanese character named ROMs to process correctly or just that specific one?

_________________
Image

Unofficial Test Monkey For:
* Snes9X GX (Wii)
* Snes9X EX (Android)
* Snes9X 64-bits

ZSNES|Ben Heck|NSRT|Bob Smiley


Top
 Profile  
 
PostPosted: Sat Jul 21, 2012 11:09 pm 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
adventure_of_link wrote:
just curious, does the first patch allow all Japanese character named ROMs to process correctly or just that specific one?

All characters. ソ is a character whose trailer byte is 0x5c (\). I just wanted to show an example of problematic input. It should process all characters as well.

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 12:14 am 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
The DBCS patch above probably can be wrong when it processes a string which has both slash and backslash. I've made a fix.
Code:
const char *S9xBasename (const char *f)
{
   const char *p = f;
   const char *last = p;
   const char *slash;
   const char *backslash;

   // search rightmost separator
   while (true)
   {
      slash = strchr (p, '/');
      backslash = strchr (p, '\\');
      if (backslash != NULL)
      {
         if (slash == NULL || slash > backslash)
         {
            slash = backslash;
         }
      }
      if (slash == NULL)
      {
         break;
      }

      p = slash + 1;

#ifdef UNICODE
      // update always; UTF-8 doesn't have a problem between ASCII character and multi-byte character.
      last = p;
#else
      // update if it's not a trailer byte of a double-byte character.
      if (CharPrev(f, p) == slash)
      {
         last = p;
      }
#endif
   }

   return last;
}

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 4:01 am 
Offline
Snes9x Purple belt
User avatar

Joined: Thu Nov 08, 2007 7:59 pm
Posts: 909
Location: /dev/null
gocha wrote:
adventure_of_link wrote:
just curious, does the first patch allow all Japanese character named ROMs to process correctly or just that specific one?

All characters. ソ is a character whose trailer byte is 0x5c (\). I just wanted to show an example of problematic input. It should process all characters as well.



Isn't this because certain characters, regardless of region settings, are not allowed by Windows?

_________________
Snes9x FAQs | Forum Rules
What operating system are you using? 32 or 64bit? Version of Snes9x? Is the text at the bottom of the window white when you load the game?
These suggestions are usually the solution to your issue!


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 4:44 am 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
Camo_Yoshi wrote:
gocha wrote:
adventure_of_link wrote:
just curious, does the first patch allow all Japanese character named ROMs to process correctly or just that specific one?

All characters. ソ is a character whose trailer byte is 0x5c (\). I just wanted to show an example of problematic input. It should process all characters as well.



Isn't this because certain characters, regardless of region settings, are not allowed by Windows?

What do you mean by "not allowed by Windows?" Windows allows using all katakana for filename.
The problem is simply caused by a poor filename processing. Uh, is there any English website which describes about the SJIS (MS932) trailer byte problem? I think they'll explain the things better...

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 4:56 am 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
win32: Unicode - fix Custom ROM dialog to show half-width katakana
Code:
83594657052359eb030726dff32ade38588f7cda
 win32/_tfwopen.cpp |    6 ++++++
 win32/_tfwopen.h   |    9 +++++++++
 win32/wsnes9x.cpp  |    8 ++++----
 win32/wsnes9x.h    |    2 ++
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/win32/_tfwopen.cpp b/win32/_tfwopen.cpp
index 537b3c7..8f0d82e 100644
--- a/win32/_tfwopen.cpp
+++ b/win32/_tfwopen.cpp
@@ -192,6 +192,12 @@ WideToUtf8::WideToUtf8(const wchar_t *wideChars) {
    WideCharToMultiByte(CP_UTF8,0,wideChars,-1,utf8Chars,requiredChars,NULL,NULL);
 }
 
+MS932ToWide::MS932ToWide(const char *ms932Chars) {
+   int requiredChars = MultiByteToWideChar(932,0,ms932Chars,-1,wideChars,0);
+   wideChars = new wchar_t[requiredChars];
+   MultiByteToWideChar(932,0,ms932Chars,-1,wideChars,requiredChars);
+}
+
 extern "C" FILE *_tfwopen(const char *filename, const char *mode ) {
    wchar_t mode_w[30];
    lstrcpyn(mode_w,Utf8ToWide(mode),29);
diff --git a/win32/_tfwopen.h b/win32/_tfwopen.h
index 5cb88e1..8429b99 100644
--- a/win32/_tfwopen.h
+++ b/win32/_tfwopen.h
@@ -227,6 +227,15 @@ public:
    operator char *() { return utf8Chars; }
 };
 
+class MS932ToWide {
+private:
+   wchar_t *wideChars;
+public:
+   MS932ToWide(const char *ms932Chars);
+   ~MS932ToWide() { delete [] wideChars; }
+   operator wchar_t *() { return wideChars; }
+};
+
 namespace std {
 class u8nifstream: public std::ifstream
 {
diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp
index a2319b3..8dfc254 100644
--- a/win32/wsnes9x.cpp
+++ b/win32/wsnes9x.cpp
@@ -5322,7 +5322,7 @@ void rominfo(const TCHAR *filename, TCHAR *namebuffer, TCHAR *sizebuffer)
             if (InfoScore((char *)HeaderBuffer) > 1)
             {
                EHi = true;
-               _tcsncpy(namebuffer, _tFromChar((char *)HeaderBuffer), 21);
+               _tcsncpy(namebuffer, _tFromMS932((char *)HeaderBuffer), 21);
             }
          }
 
@@ -5340,7 +5340,7 @@ void rominfo(const TCHAR *filename, TCHAR *namebuffer, TCHAR *sizebuffer)
                ROMFile.read(HiHead, INFO_LEN);
                int HiScore = InfoScore(HiHead);
 
-               _tcsncpy(namebuffer, _tFromChar(LoScore > HiScore ? LoHead : HiHead), 21);
+               _tcsncpy(namebuffer, _tFromMS932(LoScore > HiScore ? LoHead : HiHead), 21);
 
                if (filestats.st_size - HeaderSize >= 0x20000)
                {
@@ -5350,7 +5350,7 @@ void rominfo(const TCHAR *filename, TCHAR *namebuffer, TCHAR *sizebuffer)
 
                   if (IntLScore > LoScore && IntLScore > HiScore)
                   {
-                     _tcsncpy(namebuffer, _tFromChar(LoHead), 21);
+                     _tcsncpy(namebuffer, _tFromMS932(LoHead), 21);
                   }
                }
             }
@@ -5359,7 +5359,7 @@ void rominfo(const TCHAR *filename, TCHAR *namebuffer, TCHAR *sizebuffer)
                char buf[21];
                ROMFile.seekg(0x7FC0 + HeaderSize, ios::beg);
                ROMFile.read(buf, 21);
-               _tcsncpy(namebuffer,_tFromChar(buf),21);
+               _tcsncpy(namebuffer,_tFromMS932(buf),21);
             }
          }
          ROMFile.close();
diff --git a/win32/wsnes9x.h b/win32/wsnes9x.h
index 0e0e6e5..415c9c3 100644
--- a/win32/wsnes9x.h
+++ b/win32/wsnes9x.h
@@ -217,9 +217,11 @@
 #ifdef UNICODE
 #define _tToChar WideToUtf8
 #define _tFromChar Utf8ToWide
+#define _tFromMS932 MS932ToWide
 #else
 #define _tToChar
 #define _tFromChar
+#define _tFromMS932
 #endif
 
 /****************************************************************************/

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 1:12 pm 
Offline
Official Win32 Porter/Dev
User avatar

Joined: Thu Aug 30, 2007 10:15 pm
Posts: 450
Thanks, I've commited them.

I've also added the half-width katakana display to the regular rom info dialog.


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 3:18 pm 
Offline
Snes9x Purple belt
User avatar

Joined: Thu Nov 08, 2007 7:59 pm
Posts: 909
Location: /dev/null
gocha wrote:

What do you mean by "not allowed by Windows?" Windows allows using all katakana for filename.
The problem is simply caused by a poor filename processing. Uh, is there any English website which describes about the SJIS (MS932) trailer byte problem? I think they'll explain the things better...



Actually, I was referring to the fact that the following characters in filenames are not allowed: \ / : * ? " < > |

Now that I realize the issue at hand, I mistook it for reserved characters in the filesystem. Don't mind me! :P

_________________
Snes9x FAQs | Forum Rules
What operating system are you using? 32 or 64bit? Version of Snes9x? Is the text at the bottom of the window white when you load the game?
These suggestions are usually the solution to your issue!


Top
 Profile  
 
PostPosted: Tue Jul 24, 2012 10:56 am 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
gfx.cpp : adjust input display position since it covers frame counter display - http://git.io/gs_zYw

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Tue Jul 24, 2012 1:56 pm 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
Also, I suggest to put "static" to all "__forceinline" functions in _twfopen.h. Without it, the source code cannot be compiled when the compiler doesn't inline the function for some reasons.

MSDN wrote:
Even with __forceinline, the compiler cannot inline code in all circumstances. The compiler cannot inline a function if:
http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Tue Jul 31, 2012 11:17 am 
Offline
Official Win32 Porter/Dev
User avatar

Joined: Thu Aug 30, 2007 10:15 pm
Posts: 450
I've changed the offset and made the __forceinline functions static. Didn't have the time to look into the movie reset desync yet, but will definitely get to it.


Top
 Profile  
 
PostPosted: Thu Aug 02, 2012 11:12 pm 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
OV2 wrote:
Didn't have the time to look into the movie reset desync yet, but will definitely get to it.
Thank you very much.

win32: remove "Toggled fast forward mode" checkbox, and give "fast forward toggle" hotkey
https://github.com/snes9x-rr/snes9x/com ... 3dc0743421
I want to use both keys. I hope the change doesn't affect to the existing users.
I think most users didn't change the checkbox frequently. (because it needs to open the settings dialog)

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Thu Aug 02, 2012 11:40 pm 
Offline
Snes9x Yellow Belt

Joined: Tue May 03, 2011 2:35 pm
Posts: 190
awesome, this satisfies half of my previous feature request!


Top
 Profile  
 
PostPosted: Sat Aug 04, 2012 9:45 pm 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
small fix for the previous post
https://github.com/snes9x-rr/snes9x/com ... 6fe667f7cb

win32: drag and drop support for snes9x movie (*.smv)
https://github.com/snes9x-rr/snes9x/com ... acc9aa47a1

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Sat Aug 04, 2012 9:52 pm 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
Also, I removed MovieNotifyIgnored from my branch for some reasons.
https://github.com/snes9x-rr/snes9x/com ... a8adcbabaa
If you want, you can merge those (movie-free frame count display, lag frame count display, etc.) changes as well, although I think you don't want them.

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Wed Aug 15, 2012 1:58 am 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
Fix small mistake of previous contribution.
https://github.com/snes9x-rr/snes9x/com ... ae111b3d27

win32: update mouse coordinates calculation, it fixes the case of non-stretched 3x filters, hi-res games (I know no hi-res games that uses mouse or superscope, though)
https://github.com/snes9x-rr/snes9x/com ... 9aaa9ee9a6

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Tue Aug 21, 2012 1:40 pm 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
Remove the most of compiler warnings. (VS2008)
http://git.io/dQEQ6Q

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Fri Aug 24, 2012 12:39 pm 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
Add movie "finished" state. For details, see http://tasvideos.org/LawsOfTAS/OnSavestates.html - http://git.io/Gkg0dg

_________________
gocha - TASvideos forum


Top
 Profile  
 
PostPosted: Thu Mar 14, 2013 1:00 pm 
Offline
Snes9x Yellow Belt
User avatar

Joined: Sun Dec 30, 2007 12:14 am
Posts: 64
Location: Japan, Nagoya
win32: fix multibyte filename display in ROM Information dialog. · 8f1d176 · snes9x-rr/snes9x · GitHub https://github.com/snes9x-rr/snes9x/com ... 6b3aef6548

_________________
gocha - TASvideos forum


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group