ZSNES 1.51 on Win32 patch to make Vista/7 friendly

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

gblues
Rookie
Posts: 22
Joined: Tue Jan 18, 2005 3:50 am

Post by gblues »

Hmm, well I discovered a couple issues with my work:

1) My build dynamically links with msvcrt9.dll which means it will fail spectacularly on systems that don't already have it.

2) Even with the appropriate runtime library, it doesn't work at all in XP, despite my attempts to preserve XP compatibility.

I resolved #1 by updating the project settings (also had to rebuild zlib1.lib and libpng.lib) for statically linking libcmt.lib.

#2 I am working on now; my XP laptop is not a convenient testbed, but I have access to XP Pro through school so I am going to try Virtual PC + XP Pro. Here's hoping the DirectX calls don't fail miserably inside VPC. :\
gblues
Rookie
Posts: 22
Joined: Tue Jan 18, 2005 3:50 am

Post by gblues »

Well, DirectX didn't fail, although it doesn't capture the mouse properly inside VPC.

I found the source of the problem--turns out the dynamic linking wants to resolve all symbols referenced, even if they're never actually called. Yeah, this is my first foray into this kind of thing, shut up. :P Anyway, I resolved it by extracting the function pointer inside useKnownFolders() and referencing the function pointer at runtime.

It now works like a champ in XP. I've re-re-uploaded the archive:

http://www.strong-consultants.com/zsnes2008.zip
kode54
Zealot
Posts: 1140
Joined: Wed Jul 28, 2004 3:31 am
Contact:

Post by kode54 »

What is the difference between SHGetKnownFolderPath and SHGetFolderPath, other than the former requiring Vista?
gblues
Rookie
Posts: 22
Joined: Tue Jan 18, 2005 3:50 am

Post by gblues »

kode54 wrote:What is the difference between SHGetKnownFolderPath and SHGetFolderPath, other than the former requiring Vista?
Under-the-hood API stuff most likely. In fact, in Vista/7 SHGetFolderPath is just a wrapper for SHGetKnownFolderPath(). I haven't researched the reason for halting the old API. It's probably in MSDN somewhere. :)
gblues
Rookie
Posts: 22
Joined: Tue Jan 18, 2005 3:50 am

Post by gblues »

So now that I have my code working, I am now attempting to merge it back in to the main codebase in a way that does not break the Linux and MS-DOS builds. To that end, I've put together a Virtual PC environment running Ubuntu 9.10. I also had to bring in code changes from this thread to get it to build and run correctly.

I think the simplest way to do it is going to be to use MSVC's TEXT() macro which will dynamically change a literal string from multibyte to wide char depending on if the macro UNICODE is defined. MSVC sets the UNICODE setting based on the character set specified in the project file; other OSs that want/need to use wchar_t can simply add -DUNICODE to the compile flags. In the same manner, I'll probably change char * to LPSTR or something similar, so that LPSTR can be defined as wchar_t transparently. This avoids cluttering every function with a bunch of #ifdefs.

I will then wrap the various path handling code in #ifdef UNICODE blocks and ensure there are char * versions and wchar_t * versions defined accordingly.

I'm also doing a little code cleanup, like making sure certain definitions are only done once, and using full macro wrappers for the POSIX functions (to quell MSVC's compiler warnings) instead of using the potentially hazardous method of "#define strncmp _strncmp".

I'm exploring this approach, as opposed to making everything wchar_t internally and using mbstowcs()/wcstombs() because I'm pretty sure trying to use wchar_t paths in DOS is a waste of time.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Sorry for the late reply to this thread, I haven't been around much as of late. We've had a patch which is better than this one in our developer tree for well over a year. If it is indeed an issue, I can see about backporting some of our patches and putting out a new release.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
gblues
Rookie
Posts: 22
Joined: Tue Jan 18, 2005 3:50 am

Post by gblues »

Yeah, the patch in the OP isn't the best, although it is functional. I'm working on something more portable--putting path-related string literals into MSVC's TEXT() macro (and porting the TEXT() macro for DOS/Linux) and then using an "#ifdef UNICODE" test to choose between char * and wchar_t* versions of the path code.

I've finally got ZSNES compiling successfully in DOS and Linux via VirtualPC! I hope to have v. 2.0 of the patch done within the next couple weeks.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

gblues wrote:Yeah, the patch in the OP isn't the best, although it is functional. I'm working on something more portable--putting path-related string literals into MSVC's TEXT() macro (and porting the TEXT() macro for DOS/Linux) and then using an "#ifdef UNICODE" test to choose between char * and wchar_t* versions of the path code.

I've finally got ZSNES compiling successfully in DOS and Linux via VirtualPC! I hope to have v. 2.0 of the patch done within the next couple weeks.
You don't have to make another patch. Trust me on this.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
gblues
Rookie
Posts: 22
Joined: Tue Jan 18, 2005 3:50 am

Post by gblues »

Nach wrote:You don't have to make another patch. Trust me on this.
You think my code is that bad, eh? :lol:

No, but seriously it would obviously be pointless to integrate my code if the work has already been done in the private SVN. I'm mainly doing this for my own personal benefit, but I figured someone else might be interested in the result.
byuu

Post by byuu »

Yeah, even if it's in SVN, it'll be helpful until the next official release is out for some.
Post Reply