Showing posts with label gameboy advance. Show all posts
Showing posts with label gameboy advance. Show all posts

Monday, April 6, 2026

Some Shaders I've Been Working On

“Whatever you now find weird, ugly, uncomfortable and nasty about a new medium will surely become its signature. CD distortion, the jitteriness of digital video, the crap sound of 8-bit - all of these will be cherished and emulated as soon as they can be avoided. It’s the sound of failure: so much modern art is the sound of things going out of control, of a medium pushing to its limits and breaking apart. ... The excitement of grainy film, of bleached-out black and white, is the excitement of witnessing events too momentous for the medium assigned to record them.” -Brian Eno 

I've been working on some shaders lately. 

The first one I want to talk about was inspired by some posts on the RetroArch/libretro subreddit, where a guy was using overlays (I think? might have just been photoshops) to make some really dark images of Game Boy Color games that mimicked the experience of using their technically awful front-lit LCD screens.

I never owned a GBC, and only played on a GBA very briefly in its day, but the enthusiastic response to those shots was really something, and it highlighted a significant unmet need that I had never really considered before. So, I borrowed a friend's GBA 001 and set to work on it, and here's what I came up with (as always, click to embiggen):

screenshot - presets/authentic-gbc-frontlit.slang
Rather than reinvent several wheels, I'm leaning on fishku's "authentic-gbc" LCD shader, which includes the characteristic little dog-ear on each subpixel, as well as Matt Akins lovely "pixel transparency" shader, which makes the white pixels appear transparent and adds a little drop shadow to them.

My addition darkens the image (adjustable how dark you want the ambient light), desaturates it, and then adds a point light source, the focus of which you can adjust (diffuse, like an overhead light, or more focused like a lamp or even a "worm" light attachment) and move around (by default, it's in the upper-right corner, like an overhead light). Direct light washes out whatever is under it, but indirect light fades off quickly, and some of the colors get inverted in the semi-lit area.

I also added in a "shmutz" effect using a dirty glass texture, which only really shows up when it's directly lit, along with a slight green tint that those old LCDs had under direct illumination.

There's also a "Nighttime Car Mode," which makes a bright light sweep across the screen every few seconds to simulate a car passing under streetlights in the night, which is a situation people seem to have a perverse nostalgia for.

While I was working on my shader, Matt Akins was exploring another idea that had been teased by that same redditor, of showing a rainbow pattern at certain angles due to a quirk of the GBC LCD's internal structure. He added this functionality to his pixel transparency shader, and he also submitted a patch to RetroArch to enable gyro and accelerometer control hooks to the shader backend. I was planning to work on this, too, but I'm thankful that Mr. Akins got to it first because he did a much better job than I would have.

With that in place, I added an option to control the light source using gyro control, which makes for a very uncanny gaming experience, tilting a controller to shine a virtual light source on a virtual crappy screen, but then seeing hints of rainbowing as you tilt it. Fun stuff.

I also made a modification of the 'gbc' console-border preset, which looks pretty nice, but the light source only affects the screen and would have required a lot of invasive changes to work on the border, too, so I didn't think it was worth the trouble. Ultimately, it's not my favorite, but it still works well for people who really want a border.

The other shader I've been working on is a CRT shader. Yes, another one, because there aren't enough already. This one focuses on monochrome displays, which are usually just an afterthought in CRT shaders, and monochrome modes don't usually exhibit any special characteristics vs the color-full settings. This is unfortunate, I think, because monochrome CRTs are cool devices that ruled the land for decades, even after color TVs were commonplace.

First off, monochrome CRTs don't have subpixels or masks. The entire screen surface is coated with a layer of powdered phosphor material that glows when the electron gun scans over it. Having this direct view of the beam makes the dynamic width very visible, and the beam itself has a bit of ... life to it.

I tried to capture that, and, as a result, static screenshots aren't going to look very good or capture the "magic," so I recommend trying the presets live / in person, if you have the inclination. Nevertheless, here's what it looks like:

That's the 'black and white tv' preset, which is intentionally pretty blurry, horizontally. Monochrome computer monitors could be quite sharp, though, and there's an "apple-monitor-ii" preset that handles that better:


In addition to the beam perturbations, this preset also has the scanline brightness cranked up really high, which brings in some general glow visible around the numbers, and it also makes some nice trails anywhere there's movement (courtesy of the 'glow-trails' shaders I made several years ago): 

Both of these presets include my analog service menu shader, which lets you adjust lots of physical CRT parameters, like h- and v-size, pincushioning, etc., as well as a version of crt-royale's geometry control that I isolated just for this. It allows you to tilt the monitor up/down/left/right and control the radius of its curvature, among other tweaks. I picked a really exaggerated, low-radius curvature, since these displays were often very small (sub-15 inches), but I used the pincushion control to flatten the middle out some, just as you would on such a small display.

These presets also leverage blurbusters' and Timothy Lottes' crt-beam-simulator shader whenever shader subframes are enabled, and, in addition to the motion clarity improvements, I think the flicker it introduces provides another level of verisimilitude that I wasn't able to capture properly in still shots.

The monoCRT shader also includes several different monochrome phosphor colors:

Just be sure to use integer scaling with this shader, since the scanlines look like crap otherwise. As usual, it looks better when it has more pixels to work with, and I think 5x scale is a minimum, making integer overscale on the Y axis a great way to experience these on 1080p displays. 

So that's what I've got. The 'frontlit-reflective' shader is available in handhelds/shaders, and monoCRT is available in crt/shaders, if you want to use them in your own presets. Most of the presets I've shown here (authentic-gbc-frontlit, black-and-white-tv, and apple-monitor-ii) are available in the 'presets' directory. Aside from the beam sim effect and the gyro controls, which aren't widely supported outside of RetroArch, these shaders should work fine anywhere you can load slang shaders (e.g., ares, snes9x, OpenEmu, etc.).

Thursday, July 26, 2018

240p GBA via Gamecube Game Boy Player on Unmodified Console

I recently bought a Game Boy Player without the start-up disc and went through this process with frustratingly little guidance available online, so I figured I'd lay it all out to save anyone else the pain and hassle:

The Game Boy Player add-on for Nintendo's Gamecube console requires a special launcher disc (Game Boy Player Start-up Disc) to function, normally, and it costs a fair bit (somewhere around $75 at the time of this writing) to get a complete package including the hardware and software disc. However, you can buy the hardware without the disc for substantially less (more like $25 at the time of this writing), since it's thought to be useless on its own. There is homebrew--known as Game Boy Interface (GBI)--that can replace the functionality of the launcher disc, but most of the ways to launch the homebrew are fairly costly ($30-50), require hardware modifications to the console itself and/or require a launcher disc of their own that can get scratched/damaged/lost and then you're SOL again.

However, there are a number of exploits available for common games, including Wind Waker, Twilight Princess and Smash Bros, among others, which allow you to launch homebrew on an unmodified console, and these are easy to utilize if you have a softmodded Wii. Just fire up GCMM (GameCube Memory Manager) on the Wii's Homebrew Channel and flash one of the exploits to your memory card. Then, perform the exploit on the Gamecube to launch an unsigned application named 'boot.dol' from the memory card. I have a copy of Smash Bros Melee, so I used the appropriate Home Bros exploit for my disc revision. Once it's loaded on the Gamecube memory card, I just start the game, go to 'VS Mode' and then choose 'Name Entry' and it loads the homebrew application.

OK, great so far. If I flash the default GBI application to my memory card, it fires right up and I can see the Game Boy Advance BIOS animation. There are some nice video options I can change, like zoom, etc. but it's stuck in nasty, flickery, line-doubled 480i. If you want the nicest, cleanest, most stable image, everybody knows you want "240p"/non-interlaced mode.

Now, this is where most of the other guides online stop being helpful. They typically expect you to have an SD card interface or modchip and they recommend using Swiss to change/set your video mode to 240p. This causes a couple of problems, though: 1.) only one homebrew application named boot.dol can live on your memory card at any time (i.e., so you can't have Swiss and GBI on the same card, typically), and 2.) even if you somehow get another homebrew application onto your memory card (more on this in a bit), Swiss can't launch another homebrew application from the memory card and then adjust the video mode on-the-fly the way it can with programs launched from disc, SD card, etc.

The simplest solution is to just use the speedrunning variant of GBI (known as GBI-SR; gbi-sr.gci in the GBI package), which forces 240p (yay!) but doesn't expose the other handy video options available with the standard GBI (booo!). This lets us drop Swiss entirely from the equation for this task, but you might/should still want to have it available in your homebrew toolkit for other purposes, and we can accomplish this with a little hex editing.

Just open the gbi-sr.gci in your hex editor and right at the top you'll see 2 instances of the word 'boot.dol' (you might have to scroll down a bit to see the second instance, depending on how many lines your hex editor shows). You can change that name to anything else--I changed mine to 'boob.dol' because it's a simple change that keeps the same length. Save and exit, and you should now be able to flash both Swiss and GBI-SR to your memory card without conflicts. Now, when you fire the exploit, it will boot into Swiss and you can choose your 'boob.dol' or whatever from Swiss' list of launchable content on the memory card to play GBA games in glorious, stable 240p or you can use any of Swiss' other awesome/handy features on your native Gamecube disc-based games.

Monday, September 26, 2011

Pixel Shaders in Genesis, GBA, GBC Emulation

If you've looked at any of the amazing pixel shaders available for bsnes, such as the collaborative CRT shader from cgwg and DOLLS or Themaister's dot-n-bloom, you may have wanted to use them with other systems, such as Sega Genesis or Gameboy Advance. Well, now you can! Update (10/03/2011): now it works with Final Burn Alpha, as well. Update (10/5/2011): I'm adding download links for Windows binaries of the various libraries, when possible.

Themaister wrote some "hacky" wrappers around Genesis Plus GX, Visualboy Advance and Gambatte that route their APIs to match up with that of libsnes. That means any frontend for libsnes, such as Themaister's own SSNES, can now serve as a frontend for these excellent emulators. Thus, any features of the frontend, such as SSNES' real-time rewind and FFMPEG-powered video dumping capabilities, get baked in automatically. This also extends SSNES' badass GGPO-style netplay to all of these systems (where applicable, of course).

If you're using Ubuntu or another Debian-based distro, you can get precompiled binaries from my PPA repo. Other *nixes can compile them from source. The only dependencies are git (not even totally necessary if you manually download the source via http), a compiler that supports C++98 or higher (gcc-3.4 and up, IIRC) and zlib (in Debian-based distros, it's the zlib1g-dev package).

So, open a terminal and type:

For Genesis Plus GX:
git clone https://github.com/twinaphex/genesis-next
cd megadrive-next/src/libsnes
make

Download Windows libsnes-genesisplusgx binaries
(you may need to rename zlib.dll to libz-1.dll for it to work)

For Visualboy Advance (vba):
git clone git://github.com/Themaister/gba-next.git
cd trunk/platform/libsnes
make

For Gambatte:
git clone git://github.com/Themaister/gambatte-libsnes.git --branch libsnes
cd gambatte-libsnes/libgambatte/libsnes
make

For Final Burn Alpha (fba):
git clone git://github.com/twinaphex/fba-next-slim.git
cd fba-next-slim/src/burner/libsnes
make

Download Windows libsnes-fba binaries

The resulting libraries will all be called libsnes.so. In my packages, the libraries are named according to the emulator (libsnes-*.so) so you can have them all peacefully coexist.

One thing to be aware of: SSNES-Phoenix's file browser will filter out non-SNES extensions, so you'll have to manually type the filenames unless/until Themaister does anything about it.

Screenshots (dot-n-bloom shader is used for the GBC and GBA screenshots, CRT is used for Genesis and FBA):


Analytics Tracking Footer