Saturday, May 28, 2011

Programs Won't Launch in Win7 64-bit

UPDATE (10/7/11): I never did find an actual solution for this problem. Every time I thought I had something, it would always come back. In the end, I had to reinstall the system. :/

So, I've been running into an issue on my Lenovo Thinkpad X120e when booted into Windows 7 where programs won't launch from the taskbar when I click on them. The little transparent box shows up around it, it sits for a second, then fades away.

I found, however, that I could run things from the command line, though that was not a good fix. After futzing around with the startup applications in msconfig, I found that it would start programs just fine if I turned off all of my startup items. This was also suboptimal, so I set to tracking down the culprit from the startup items by enabling them one-by-one and restarting each time.

UPDATE (6/5/11): Turns out my below "fix" may have just been coincidental, because my issue returned. It hung around through several reboots until I ran Windows Update and updated my video card driver, after which it went away again. Whether this fixes things permanently, we'll have to see.

I'll update this post if anything changes.

Original, ineffectual post:
Eventually, I found the problem to be related to the Sidebar application, which powers the CPU frequency and weather widgets I like to have sitting on my desktop. :(

I haven't had any problems since I turned it off.

Monday, May 16, 2011

Profiled, optimized libsnes builds for win32

I've been playing around with mingw, doing cross-compiles of libsnes with profile-guided optimizations (PGO) for use with SSNES in Windows and I think I've gotten it down pretty well.

I used the following C-flags at compile time:
-msse2 -fmerge-all-constants -fmodulo-sched -fgcse-sm -fgcse-las -funsafe-loop-optimizations -fsched-spec-load -fsched-spec-load-dangerous -fsched-stalled-insns=0 -fsched-stalled-insns-dep -fsched2-use-superblocks -fipa-pta -ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon -fivopts -fvariable-expansion-in-unroller -ffast-math -fbranch-target-load-optimize -maccumulate-outgoing-args -combine
This means it's only going to work on CPUs that support the SSE2 SIMD instructions, but that includes pretty much every processor manufactured in the past 8 years, so I figured that was good enough.

If you want to give them a try, you can get them from my mediafire.

Sunday, May 15, 2011

More Emulator Pixel Shaders (CRT updated and more)

I'm just going to dive right in with the pictures in this post. If you want/need some backstory, read my previous CRT shader post. These shaders are all available in Screwtape's bsnes git repo, except for Beam4, which can be downloaded here, and NTSC, which can be downloaded here (both mirrored in my mediafire in case the pastebins expire before Screwtape adds them to his repo).

Update (01/11/12): bsnes support is back! Plus, the Win32 and GTK+ ports of snes9x support these shaders, as well. :D

UPDATE (9/20/11): Themaister has written an awesome little WebGL applet that enables shader testing and combining (up to 2 separate shaders) quickly and easily. Check it out! (requires browser with support for WebGL, such as newer versions of Google Chrome and Mozilla Firefox; only supports single-pass shaders at the time of this writing)

Here's a good picture to test with (320x240 resolution with point filtering, mimics raw SNES output):


UPDATE (5/30/11): Added shots of caligari's phosphor21x shader (a.k.a. caligari's scanlines in Screwtape's repo). UPDATE (6/3/11): Added Themaister's Dot 'n' Bloom, available from Screwtape's repo. UPDATE (6/18/11): Added caligari's scanlines - rgb triad. UPDATE (9/29/11): Added Themaister's phosphorish. UPDATE (11/22/11): Added edge detection and ALovelyBloom.

All images are taken at 3x scale, followed by that same image blown up 400% with no further interpolation. As always, click the thumbnails to embiggen.

4xBR

This one uses an algorithm similar to HQ4x and it shows.

ALovelyBloom

Unfortunately, this one's just a big flare-out on Super Mario World, but it looks pretty good on darker games, if you're into bloom. You can stack it with some other shaders to soften up phosphor effects and so on.

Beam4
This is a multipass scanline shader from cgwg that also simulates an electron beam that takes longer to rise than to fall. It is perfect for producing the pseudo-hires transparency used in Kirby's Dreamland 3 and Jurassic Park. Sadly, it only works in emulators that support shader spec 1.1 (at the time of this writing, Themaister's SSNES and PS3 homebrew emus written by Dante Ali).

Bicubic

This one's pretty straightforward, using an algorithm similar to that of bilinear filtering (aka, 'smooth video'). It's a little sharper and preserves edges a little better.

CRT.OpenGL

This is the latest and greatest version of the collaborative CRT shader. The screen curvature is user-definable, based on changing a single value in the helpfully commented shader code. As you can see, it looks totally amazing. It also runs a lot faster than it used to, so give it a shot even if your machine couldn't handle it before.

CRT-simple.OpenGL

This one is very closely related to the aforementioned CRT shader, only this one is optimized for weaker cards while only sacrificing a tiny bit of accuracy. If your machine can't run the full-fledged CRT shader, this one is your last good chance.

Dot 'n' Bloom

Another cool one from Themaister, Dot 'n' Bloom treats each pixel like a single, distinct dot and then adjusts its size based on brightness, such that brighter dots appear larger than darker ones, similar to a CRT electron beam (though this shader is not attempting to reproduce a CRT, it resembles one). He then added a bit of bloom to blend things together some. The results look really nice in motion (especially on Super Metroid :D) and the shader runs extremely fast.

Edge Detection

This one is more stylized than most of the others I've covered. As you might have guessed by the title, it finds the edges of colors and presents them as an outline. On SMW's cartoony, hard outlines, it makes a crazy quadruple outline.

Lanczos 4-tap

Another fairly straightforward interpolation filter, this one runs quite fast even on weaker hardware. You can learn more about the Lanczos algorithm and its use in resampling at the Wikipedia.

Lanczos 6-tap

As you might have guessed, this one is very similar to the 4-tap Lanczos, but it is further sharpened, which leads to the ringing/halo effect around sprites.

NTSC

This multipass shader is the result of cgwg and Themaister porting blargg's awesome NTSC filter to GLSL. It looks quite nice and doesn't bog down the CPU like the regular filter version. Unfortunately, it only works on shader spec 1.1-compatible emus.

Phosphor21x
This is caligari's implementation of an algorithm originally written by xythen in Matlab, which served as the inspiration for the work that later became CRT.OpenGL. This shader builds on xythen's work to be essentially scale factor-independent, except it looks a little weird at 2x in my experience; everything larger looks great. An interesting note: the scanlines that appear with this shader are not simply added in. Instead, they are naturally occurring as a result of the phosphor simulation. Pretty cool stuff :D

By uncommenting some lines in caligari's code, you can enable one of three phosphor/shadow mask arrangements, of which the RGB triad option is the nicest (I recommend clicking these thumbnails to see in full size):

As you can see, this option causes some serious dimming of the picture brightness, which was also a technological obstacle for actual CRT engineers when shadow masks were first being designed and implemented. In bsnes, you should be able to just increase the gamma in the picture settings to compensate. You can download this shader variation from my mediafire account.

Phosphorish












A simple, single-pass shader that makes a nice phosphor effect. This shader runs fast and works with both bsnes and SSNES. It is available here or in my mediafire.

Quilez

This fast, crisp interpolation filter is totally new to the emulation scene. It's based on some fancy math demonstrated by Inigo Quilez and represents a good compromise between the pixelate2x and bicubic shaders.

Simple TV Blur

This one's rather subtle, but is intended to do the minimum amount of work required to reproduce the pseudo-hires transparency.

Beam4+NTSC
Just for fun, I used SSNES' shader stacking support to combine the new NTSC shader with the Beam4 shader. It's almost indistinguishable from Beam4 alone (except for some really slight changes to the color palette), so I wouldn't bother trying it yourself.

CRT+NTSC

As above, I tried stacking the NTSC shader with the new CRT shader and this was the result. It's kinda cool in a way, like newsprint. :P According to cgwg, this is happening because it's only picking up the first pass of the NTSC shader, which has no color values.

CRT-Flat+Caligari's Scanlines - RGB Triad
When the regular CRT shader (edited to have 0.0 for the distortion value) is paired with caligari's scanlines - RGB triad variant, you end up with a pretty neat result:

The colors are off by a good bit (I think because of the double gamma correction) and it's very dark, but the phosphor triads from caligari's are still clearly discernible over the CRT shader's already-awesome result. Still not perfect, obviously, but getting close in a lot of ways.