Tuesday, December 3, 2019

Additional, Smaller Displays Don't Improve Content Visibility

In real life, I do audio/video design and support for a university. When visibility is poor in a room, the intuitive solution--and what people typically request--is to simply add more, smaller displays throughout the room. Unfortunately, due to the way perspective works, this solution tends to have little benefit despite significant increased cost. However, I've never seen any breakdown of exactly why this solution is so ineffective, and I didn't really have anywhere else to publish my thoughts on it, so here we go...

To quantify the effects of this intervention, we'll construct a hypothetical room using standard equipment and 15 representative seats/students (most of our classrooms have closer to 40 students, but these results can be extrapolated). Most of our projection screens are approximately 110-120 inches diagonal, while most of our repeater displays are between 55 and 70 inches, depending on age and various constraints (space, cost, etc). For simplicity's sake, we can say that repeater displays are usually about half the size of the main display, give or take, and we would usually place it roughly halfway between the largest display and our furthest viewers:
We install these repeater displays with the hope of improving the visibility for students in the back row, but as we see in the following diagram, the students in the back row have no visibility benefit when looking at the repeater display (that is, it appears no larger or more readable for them than the main display):

Moreover, for the students at the sides of the back row, the viewing angle is slightly worse when compared with the projection screen, making it no better and arguably worse for them to look at the repeater display instead of the main display.

So, who actually benefits from this repeater display? Well, the student in the middle of the second row has a bit better view of it as compared with the projection screen, but really not that much better; maybe 25-30% improvement, tops:
The students one seat to either side may have a slightly better view, too, though the viewing angle is becoming quite shallow for them and could have detrimental effects, depending on the display, while the students farther out have no chance of a better view, since the viewing angle is unusably tight:
So, that leaves us with definitely one, possibly up to three students out of our 15 who actually reap a benefit from the repeater display, and the magnitude of that improvement is not particularly large.

Furthermore, these numbers get even worse if you mount the repeater display at an angle on (or even worse, flat against) the wall, as is typical (i.e., as opposed to the hypothetical example above, where it is floating in the optimal spot for visibility; in reality, we have ADA clearances and vertical viewing angles to contend with), with only one student--maybe two if we're lucky--gaining any benefit:

So, unless your repeater displays are very large or you have the money and the inclination to install many of them throughout the room (which brings its own issues of visual confusion/distraction), it's probably not going to bring you much value.

At this point, you may be asking "so, what's the solution, then?" Unfortunately, I don't have a good answer to that.

There are some software+BYOD solutions, like TopHat (only really useful for slide-based presentations) or Huddle Hub One (bandwidth-hungry; only supports 75 participants, making it ineffective for auditoriums) or even simply Zoom (this can quickly turn into a feedback mess with many devices in the same room), but instructors are often distrustful of anything that has students pulling their own devices out in class, let alone staring at them the whole time.

Separating students into groups/pods with a dedicated large-ish display for each group seems to work pretty well, and this configuration lends itself well to active learning applications, but it's also expensive, requires complex AV and reduces the maximum student density of a room as compared with traditional rowed seating by about 25%.

Monday, October 14, 2019

Adding Genesis/MD to MC-Cthulhu

So, about a year ago I had been working on a plan for a universal arcade stick with support for a bunch of retro consoles plus PC and PS3 (via an MC-Cthulhu board), Sega Genesis / Mega Drive via a padhacked 6-button pad from eBay and Xbox 360 via a leftover control board from one of my Mad Catz sticks.

360 and Cthulhu were supposed to share the same USB-over-RJ45 with a toggle switch to go between them and Genesis/MD was going to have a little pigtail that could hook up to an extension cable when needed. When I got the 360 board wired into the Cthulhu, though, everything went haywire with phantom button presses and all sorts of nonsense. This got me pretty bummed out about the whole project and I put it on ice.

However, there's been a lot of interest over on my MC-Cthulhu pinout page from people trying to integrate Genesis/MD input with the Cthulhu board since then, so I figured I'd better at least finish up that part and report my experience, which I finally did last night.

I won't go into a ton of detail in this post, as the "how" bits have already been covered in my other posts (linked above), so instead I'll focus on what worked and what didn't.

First off, I had originally tried swapping between the Cthulhu and the 360 board (before I abandoned it) using a momentary DPDT switch like you find on a guitar foot pedal. I wanted something tough that was hard to press, so it wouldn't trigger accidentally mid-game. This ended up being the wrong tool for the job, though, as it only switched to the other board while the switch was actually held down. So, I switched over to an ON/ON DPDT 2-position switch. I'm pretty confident this would have worked as intended had my 360 board wanted to cooperate.

The way the switch is supposed to work is: from your USB, you have 4 lines--GND, 5v, Data+ and Data-. The 5v and GND are wired onto the extra solder points on the Cthulhu (that is, the 3 sets of thru-holes where you solder on the RJ45 lines) and the Data+/- lines are wired onto the switch, with 2 coming from the Cthulhu and 2 coming the 360 board's USB header. The output lines from the switch (typically the 2 center leads) connect to the RJ45 lines. In normal use, both boards will be powered (whenever you do a multi-board solution, all boards need their voltage and ground lines connected together at all times) but the one that actually sends/receives data will be controlled by the toggle switch.

Once I got the boards wired together and noticed the strange behavior, I did a lot of troubleshooting and determined that just having the 5v and GND lines linked up was enough to break everything, so that was that. I may revisit it another time with a different 360 board, but for now I decided to just drop 360 support altogether. With the 360 board out of the picture, I didn't need the switch anymore, but I just left it on there anyway rather than having a gaping hole in the side of my stick for dust and liquids to sneak in. Plus, now I have a little fidget thingie I can fiddle with between matches.

sorry for blurry pic :(

Moving on to the Genesis/MD pad, there wasn't really anything unexpected. I soldered the padhack's button lines to the secondary soldering points on the Cthulhu (the 2 rows of thru-holes labeled A-H and 1-9) as outlined at the end of my pinout post and it all works great. The crummy pad I used has a very short cable, which made it super-easy to cram into my already-crowded Mad Catz SE chassis.
Yes, the wiring is a mess. Good thing nobody ever sees it but me (and now you)
You'll notice I did a little loop around a screw post before sending the connector out the back side. That's to prevent the wire from tugging on the pad PCB and ripping out my solder joints. I also covered the entire PCB and solder points with electrical tape to prevent any stray grounding/bridging.
The pigtail. It's pretty unobtrusive without the extension cable attached
You might also notice that I removed the 360 home/LED/turbo panel with a 3D-printed blank, which just barely fits a 24 mm button to serve as the Cthulhu's HOME button.

While I was at it, I took a tip from u/gongfuren on reddit's r/fightsticks board and swapped out some plungers on my short-stem IL competition buttons for a cool "bullseye" look and also removed the springs from the buttons, which gives them a much lighter touch. They're still a lot stiffer than Sanwa buttons (which is good, IMO, as I like to rest my hands on the buttons) but they feel significantly more responsive than with the spring, and they still keep their satisfying cherry click.

Here's the final result:
And here's my other IL stick that I swapped plungers with:

Thursday, January 31, 2019

RetroArch Wii U Slang Shaders

RetroArch on Wii U has supported slang shaders for a long time, but it's really hard to find them online. I found a pack of them, though, and decided to rehost it here. Hopefully, more people will get to enjoy them now.

EDIT (11/1/2019): To use these, copy them to your SD card and then go to settings > directory in RetroArch and set your 'video shaders' directory to that location.

Unfortunately, the GPU on the Wii U isn't particularly powerful, so relatively few run full speed, and there seem to be some weird scaling issues going on, leading to slightly uneven scanlines at times and broken xBR/Hqx effects. LUTs are also wonky, apparently, as many of the LUT-based mask effects are just scaled up to fit the screen instead of tiled across it.

EDIT: I thought the scaling issues might have been caused by it rendering at 720p and then upscaling to 1080p, so I changed the Wii U's output res to 720p but it still has a bunch of ugly issues. Mask effects are completely terrible. Currently, I'm just using misc/interlacing at a 2x scale to get even scanlines.

Saturday, December 22, 2018

Retro Console RJ45 Pinouts - PS360+, MC-Cthulhu, Brook Retro Board

I build a lot of arcade sticks and I like to use them on old video game consoles, and the best way to do this is usually to get a control board that is compatible with multiple consoles. There have been a few boards that do this over the years, including Toodles' MC-Cthulhu (mostly discontinued but still available sporadically), Akishop Customs' PS360+ (discontinued) and now (at the time of this writing) Brook's Retro Board.

The preferred way to connect these boards to the consoles is via RJ45 connectors soldered to the board and then a console-specific connector soldered onto the other end of the cable. A few arcade parts stores sell premade cables for some of the more popular consoles at the time of this writing, but that will probably stop at some point, so it's good to know how to put these cables together.

There used to be a huge thread with really great tutorials on making these cables on the Shoryuken forums by user "rtdzign" but when SRK migrated to a different forum software a few years ago, it completely fucked up their post index so you can't get to things from google search results and I think the whole forum is shutting down completely soon, so all of this will be lost (most of it already is, really; I had to go sifting through the Wayback Machine's archives to collect most of this stuff).

Anyway, here goes (note: the pics in this post come from rtdzign's original tutorial on SRK and from Akishop Custom's PS360+ manual, with copyrights for those respective images belonging to them):

If you buy a MC-Cthulhu from somewhere, you may want to make sure you have the latest firmware. Toodles' "Godlike Controls" site has been down for a while, but the Wayback Machine cached the firmware file here.
Mirror

The ethernet connection pinout looks like this:

USB

The first cable you'll probably want to make is a regular USB cable (for PC and PS3). It's pretty simple - ground (pin 4 of the USB cable) goes to pin 1 of the ethernet cable, data+ (USB pin 2) goes to pin 5 of the ethernet cable, data- (USB pin 3) goes to ethernet pin 6 and VCC (USB pin 1) goes to ethernet pin 8.

Color - Purpose - RJ45 Pin - Cthulhu - ETH Color
Black - GND     - 1        - G       - Orange Stripe
---   - ---     - 2        - A       - Orange Solid
---   - ---     - 3        - B       - Green Stripe
---   - ---     - 4        - C       - Blue Solid
White - DATA-   - 5        - D       - Blue Stripe
Green - DATA+   - 6        - E       - Green Solid
---   - ---     - 7        - F       - Brown Stripe
Red   - VCC     - 8        - V       - Brown Solid

Original Xbox

Once you've done USB, OG Xbox is a logical next choice, as it's just USB with a proprietary plug:


OG Xbox also has a yellow wire that is unused and can be ignored, but otherwise it's the same as the regular USB cable.
NOTE: in general, don't trust wire colors blindly. *Always* test continuity with a multimeter to confirm wire-to-pin assignment. Cheap, knockoff extension cables are notorious for using essentially random wire colors (including nonsense like red GNDs, black VCCs, etc.)
If your construction skills aren't great and you would rather buy something, I believe you could also just use a USB-female-to-Xbox-male adapter like this one (or build one) and get the same effect pairing it with your newly constructed RJ45-to-USB cable.

Once you've got the hang of it, the rest of the consoles are just a matter of matching up the gamepad pins with the ethernet wires.

Gamecube

Gamecube (not compatible with PS360+) only uses the first 3 pins of the controller, which makes it pretty easy: controller pin 1 is VCC, which goes to ethernet pin 8, controller pin 3 is GND, which goes to ethernet pin 1 and controller pin 2 is DATA, which goes to ethernet pin 7. Easy-peasy.

Here's the diagram:

GC Pin - Purpose - RJ45 Pin - Cthulhu - ETH Color
1      - +5v     - 8        - V       - Brown Solid
2      - DATA    - 7        - F       - Brown Stripe
3      - Ground  - 1        - G       - Orange Stripe
And the same info in order of RJ45/Cthulhu pins:
GC Pin - Purpose - RJ45 Pin - Cthulhu - ETH Color
3      - Ground  - 1        - G       - Orange Stripe
---    - ---     - 2        - A       - Orange Solid
---    - ---     - 3        - B       - Green Stripe
---    - ---     - 4        - C       - Blue Solid
---    - ---     - 5        - D       - Blue Stripe
---    - ---     - 6        - E       - Green Solid
2      - DATA    - 7        - F       - Brown Stripe
1      - +5v     - 8        - V       - Brown Solid

PS1 and PS2

PSX is another good one, since it covers both PS1 and PS2 and was considered the "standard" connector for sticks prior to the adoption of USB, so you can find PSX-to-whatever adapters fairly easily from companies like Raphnet. In fact, Akishop Customs recommends using a PSX cable with a PSX-to-Gamecube adapter to cover Gamecube and Wii inputs with PS360+ boards.

Note: the 'RUMBLE' pin carries 7.2v-9v for use by the rumble motors. We don't need to mess with it.


PSX Pin - Purpose - RJ45 Pin - Cthulhu - ETH Color
1         DATA    - 4        - C       - Blue Solid
2         CMD     - 3        - B       - Green Stripe
3         RUMBLE  - ---      - ---    
4         GND     - 1        - G       - Orange Stripe
5         +3.3v   - 8        - V       - Brown Solid
6         ATTN    - 5        - D       - Blue Stripe
7         CLK     - 2        - A       - Orange Solid
8         UNUSED  - ---      - ---
9         ACK     - 7        - F       - Brown Stripe
and here's that same data shuffled around to use the order of the RJ45/Cthulhu pins, in case that is easier to understand:
PSX Pin - Purpose - RJ45 Pin - Cthulhu - ETH Color
4       - GND     - 1        - G       - Orange Stripe
7       - CLK     - 2        - A       - Orange Solid
2       - CMD     - 3        - B       - Green Stripe
1       - DATA    - 4        - C       - Blue Solid
6       - ATTN    - 5        - D       - Blue Stripe
---     - ---     - 6        - E       - Green Solid
9       - ACK     - 7        - F       - Brown Stripe
5       - +3.3v   - 8        - V       - Brown Solid

NES and SNES

SNES / NES is another interesting case insofar as they use the same protocol, just with a different connector. Rather than making/storing/transporting 2 separate ethernet cables, I made one ethernet-to-SNES cable and use a self-made SNES-to-NES adapter for NES (also useful for using the more ergonomic SNES pad on an NES). I also have a cheap SNES-to-Wiimote-expansion adapter (this one from Hyperkin https://www.amazon.com/Hyperkin-Controller-Adapter-Classic-super-nintendo/dp/B075RMYMNH) but neither my PS360+ nor my MC-Cthulhu work with my SNES Classic/Mini through it, so YMMV (worth noting: MC-Cthulhu and PS360+ don't work with my Analogue Super Nt using the normal SNES cable, either, though they both work with an actual SNES console, so clearly something fucky is going on that probably won't ever be resolved for either of the essentially dead products). I haven't tried either of them running through a Wiimote's Bluetooth connection (to, for example, use an arcade stick wirelessly with emulators on a softmodded Wii), so if you try that, please let me know your results in the comments.

To be verbose, here are both the NES and SNES pinouts and pics, respectively (the "unused" pins are reserved for special controllers and serve no purpose for us):

NES




NES pin - Purpose - RJ45 pin - Cthulhu - ETH Color
1       - GND     - 1        - G       - Orange Stripe
2       - CLK     - 2        - A       - Orange Solid
3       - LATCH   - 7        - F       - Brown Stripe
4       - DATA    - 4        - C       - Blue Solid
5       - UNUSED  - ---      - ---     - ---
6       - UNUSED  - ---      - ---     - ---
7       - VCC     - 8        - V       - Brown Solid
And here it is sorted by RJ45 pin:
NES pin - Purpose - RJ45 pin - Cthulhu - ETH Color
1       - GND     - 1        - G       - Orange Stripe
2       - CLK     - 2        - A       - Orange Solid
5       - UNUSED  - 3        - B       - Green Stripe
4       - DATA    - 4        - C       - Blue Solid
6       - UNUSED  - 5        - D       - Blue Stripe
---     - ---     - 6        - E       - Green Solid
3       - LATCH   - 7        - F       - Brown Stripe
7       - VCC     - 8        - V       - Brown Solid

SNES



SNES pin - Purpose - RJ45 pin - Cthulhu - ETH Color
1        - GND     - 1        - G       - Orange Stripe
2        - UNUSED  - ---      - ---     - ---
3        - UNUSED  - ---      - ---     - ---
4        - DATA    - 4        - C       - Blue Solid
5        - LATCH   - 7        - F       - Brown Stripe
6        - CLK     - 2        - A       - Orange Solid
7        - +5v     - 8        - V       - Brown Solid
And sorted by RJ45 pin:
SNES pin - Purpose - RJ45 pin - Cthulhu - ETH Color
1        - GND     - 1        - G       - Orange Stripe
6        - CLK     - 2        - A       - Orange Solid
2        - UNUSED  - 3        - B       - Green Stripe
4        - DATA    - 4        - C       - Blue Solid
3        - UNUSED  - 5        - D       - Blue Stripe
---      - ---     - 6        - E       - Green Solid
5        - LATCH   - 7        - F       - Brown Stripe
7        - +5v     - 8        - V       - Brown Solid

TurboGrafx-16 / PC-Engine

TG16/PCE is kinda weird insofar as it has 2 functions on each pin (e.g. D-pad up and the I button) and then it uses the DATA SELECT pin to select which set of functions to poll.

I don't have a TG16/PCE, but from rtdzign:
The American TurboGrafx-16 uses has a female Din 8 port on the system while the Turbo Duo and all the Japanese systems use a Mini Din 8. I recommend that you buy a number of 6 ft monoprice Mini Din 8 cables. For an TG-16 you can buy a male Din 8 connector and solder that to an ethernet cable.

And here's the diagram sorted by DIN pin:
DIN Pin  - RJ45 pin - Cthulhu - ETH Color
1 +5v    - 8        - V       - Brown Solid
2 UP/I   - 2        - A       - Orange Solid
3 RT/II  - 3        - B       - Green Stripe
4 DN/Sel - 4        - C       - Blue Solid
5 LF/Run - 7        - F       - Brown Stripe
6 SELECT - 6        - E       - Green Solid
7 OE     - 5        - D       - Blue Stripe
8 GND    - 1        - G       - Orange Stripe
And sorted by RJ45 pin:
DIN Pin  - RJ45 pin - Cthulhu - ETH Color
8 GND    - 1        - G       - Orange Stripe
2 UP/I   - 2        - A       - Orange Solid
3 RT/II  - 3        - B       - Green Stripe
4 DN/Sel - 4        - C       - Blue Solid
7 OE     - 5        - D       - Blue Stripe
6 SELECT - 6        - E       - Green Solid
5 LF/Run - 7        - F       - Brown Stripe
1 +5v    - 8        - V       - Brown Solid

Saturn

Saturn pads have voltage lines running in and out of the gamepad. When you see diagrams online, they are typically named according to the console's perspective, rather than the controller's, so keep in mind that these names are basically backward.

Sorted by Saturn pin:

Sat Pin   - RJ45 pin - Cthulhu - ETH Color
1 +5v-OUT - 8        - V       - Brown Solid
2 DATA1   - 3        - B       - Green Stripe
3 DATA0   - 2        - A       - Orange Solid
4 SELECT0 - 5        - D       - Blue Stripe
5 SELECT1 - 6        - E       - Green Solid
6 +5v-IN  - ---      - ---     - ---
7 DATA3   - 7        - F       - Brown Stripe
8 DATA2   - 4        - C       - Blue Solid
9 GND     - 1        - G       - Orange Stripe
Sorted by RJ45 pin:
Sat Pin   - RJ45 pin - Cthulhu - ETH Color
9 GND     - 1        - G       - Orange Stripe
3 DATA0   - 2        - A       - Orange Solid
2 DATA1   - 3        - B       - Green Stripe
8 DATA2   - 4        - C       - Blue Solid
4 SELECT0 - 5        - D       - Blue Stripe
5 SELECT1 - 6        - E       - Green Solid
7 DATA3   - 7        - F       - Brown Stripe
1 +5v-OUT - 8        - V       - Brown Solid

3DO

3DO pads have headphone jacks on them, so 2 of the pins are dedicated to carrying audio signals, and there's a second VCC line. I would assume you can use either of them but haven't tested it, since I don't have a 3DO. Neither did rtdzign, it seems, as here's what he had to say about it:
(I don't have a 3DO and am assuming the D-sub follows normal pinout convention Picture is from a 3rd party genesis extension cable.)

3do will currently only work as the only controller, plugged directly into the system; trying to daisy chain off of it or use it through a daisy chain isn't going to work.

Here's the diagram sorted by Dsub pin:
Dsub Pin - Purpose - RJ45 pin - Cthulhu - ETH Color
1        - GND     - 1        - G       - Orange Stripe
2        - VCC+5v  - 8        - V       - Brown Solid
3        - AUDIO1  - ---      - ---
4        - AUDIO2  - ---      - ---
5        - VCC+5v  - ---      - ---
6        - P/S     - 7        - F       - Brown Stripe
7        - CLOCK   - 2        - A       - Orange Solid
8        - GND     - ---      - ---
9        - DATA    - 4        - C       - Blue Solid
And sorted by RJ45:
Dsub Pin - Purpose - RJ45 pin - Cthulhu - ETH Color
1        - GND     - 1        - G       - Orange Stripe
7        - CLOCK   - 2        - A       - Orange Solid
---      - ---     - 3        - B       - Green Stripe
9        - DATA    - 4        - C       - Blue Solid
---      - ---     - 5        - D       - Blue Stripe
---      - ---     - 6        - E       - Green Solid
6        - P/S     - 7        - F       - Brown Stripe
2        - VCC+5v  - 8        - V       - Brown Solid

Dreamcast

No VMU support and only works with games that can be played solely with an arcade stick.

Here's the diagram sorted by DC pin:
DC Pin   - RJ45 Pin - Cthulhu - ETH Color
1 DATA1  - 7        - F       - Brown Stripe
2 VCC+5v - 8        - V       - Brown Solid
3 GND    - 1        - G       - Orange Stripe
4 SENSE  - 3        - B       - Green Stripe
5 DATA5  - 4        - C       - Blue Solid
And sorted by RJ45 pin:
DC Pin   - RJ45 Pin - Cthulhu - ETH Color
3 GND    - 1        - G       - Orange Stripe
---      - 2        - A       - Orange Solid
4 SENSE  - 3        - B       - Green Stripe
5 DATA5  - 4        - C       - Blue Solid
---      - 5        - D       - Blue Stripe
---      - 6        - E       - Green Solid
1 DATA1  - 7        - F       - Brown Stripe
2 VCC+5v - 8        - V       - Brown Solid

Sega Genesis / Mega Drive

None of these boards work with Genesis / MD because it does its own crazy thing that's very difficult to reproduce without spending a ton of money on dedicated parts. The best thing to do for these is to padhack a crappy 6-button pad, which can be purchased online for peanuts. See my post here for a look at that process.

MC-Cthulhu Secondary Solder Point Pinout

The Cthulhu boards include a double-row of unlabeled solder points on the side of the board opposite the RJ45 solder points. These are intended for attaching a 360 padhack for adding 360 support, but they're just additional hard-lines tied to the screw-terminals, so they can technically be used to add any additional PCB, so long as you tie the VCC and Grounds together.

Since they're unlabeled, it can be a hassle to use them, but you can easily identify by testing continuity between the solder points and the screw-terms. Nevertheless, I'll include the pinout here to make it easier (the labeling scheme assumes right-alignment; that is, H and 9 are on the far right, lined up, while A and 1 are staggered on the left side):

    [A] [B] [C] [D] [E] [F] [G] [H]
[1] [2] [3] [4] [5] [6] [7] [8] [9]

A = VCC
B = Down
C = Ground
D = Select
E = Right
F = 3K ('Roundhouse' in Street Fighter nomenclature)
G = 3P (Fierce)
H = 1P (Jab)

1 = Up
2 = 4P (PPP)
3 = Left
4 = 4K (KKK)
5 = Start
6 = 2K (Forward)
7 = 1K (Short)
8 = 2P (Strong)
9 = Home/Guide

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.

Thursday, June 7, 2018

Trading Moire for Noise in Shaders

Note: the ugly artifacts we're trying to deal with in this post also happen whenever you up/downscale images, so be sure to click the thumbnails to view at full resolution.

A lot of folks like to apply a pincushion/curvature effect to their emulator image to try and capture a bit of the old CRT TV curved tube effect. This can be a problem, though, when paired with a scanline effect, since the curvature introduces an aliasing artifact on the scanlines known as a "moire pattern":
This is a worst-case scenario, used for illustrative purposes.
Notice the ugly pattern fanning out from the middle of the outside edges of the screen
This problem comes up a lot in virtual reality applications, where content often runs through a pincushion effect to compensate for the lens distortion of head-mounted displays, which then leads these same ugly patterns to crop up on any design with parallel/converging lines.

Graphics programmer Timothy Lottes (author of the popular FXAA algorithm and a lovely public domain CRT shader, among others) was working on ways of dealing with the aliasing/moire problem for VR and published this shadertoy showing how to hide it by introducing jitter/noise in where the texture is sampled. Turns out that same strategy can be used to mitigate our scanline moire.

When applied to an actual game image, this:
becomes this (caution, big animated gif; the noise effect doesn't really work in still images):
You can see that the noise is concentrated along the same areas where the moire pattern was visible before, but it's much less obtrusive and sort of melts away when viewed at a distance.

When curvature is added to an existing, normally flat CRT shader (Themaister's crtglow-gaussian shader, one of my favorites), we go from this:
to this, with the noise/jitter-based mitigation:
In this example, the noise also adds a touch of analog warmth/sparkle to the CRT effect, which I like.

Here's the code snippet that does it (all copyrights belong to Mr. Lottes):
This code can be added to many CRT shaders by wrapping the shader's fragment texcoord declaration with the moire_resolve() function to add the jitter/noise and then wrapping that with the Warp() function to add the curvature. You can see an example of where I've done exactly that in the crtglow-gaussian shader here to create the screenshots above.

Update 12/1/2018: A more traditional--and highly effective--method of moire removal is through elliptical weighted average (EWA) filtering, as described here. Fellow shader enthusiast torridgristle whipped up a GLSL version with curvature, which can be added after CRT/scanline shaders to look like this:
It's quite fast, too, making it a very good, flexible choice for curvature plus moire-mitigation.

Wednesday, May 30, 2018

RetroArch Mirror Mode

Sega recently updated their Mega Drive & Genesis Classics emulator collecdtion on Steam to include a fun little feature known as "mirror mode," which flips the game image and controls to be a mirror image of what we're used to. This adds a really surprising challenge, since it breaks all of our muscle memory (including the deeply ingrained "run to the right!" imperative).

This has been possible in RetroArch for a very long time, but it requires twiddling a few esoteric options that may not be familiar to a majority of users, so I figured I'd run through the process briefly.

Step 1: Flip the screen

As with most of the fun video tweaks in RetroArch, we accomplish this through a shader. So, with some content loaded, bring up the 'quick menu' and scroll down to 'shader settings'. On that screen, increment the number of shader passes from 0 to 1 and where it says 'shader #0 N/A,' navigate to the image-adjustment shader located in the 'misc' subdirectory of your shader flavor of choice. I'm using slang shaders here, which are compatible with the Vulkan and D3D11/12 video backends. You can add additional shader passes after the image-adjustment shader, if you like.
Once the shader is selected, go up to the top of the shader menu and hit 'apply changes', then skip down to the 'shader parameters' submenu and you should see a ton of options for tweaking the image. Down at the very bottom, you should see 'flip horiz axis' as the second-to-last option. Set it '1.0' and you should see the screen mirror.

Step 2: Flip the controls

From the shader menu, hit backspace or 'cancel' to return to the 'quick menu' and look for the 'controls' submenu. Here, you can change which of your physical or retropad buttons trigger which core functions. So, scroll down until you see entries for the D-pad. In my case, we have 'Left D-pad (key: left)', to which is assigned D-pad Left, and 'Right D-pad (key: right)', to which is assigned D-pad Right. Simply swap those (as pictured) and you're all set.
Now, we could save a remap file to be automatically loaded whenever this core or game is loaded, but I don't want my controls to be mirrored indefinitely, so I'm not going to do that, and this setting will simply get wiped out when I 'close content' or 'quit RetroArch'.

Bonus Step 3: Flip the audio channels

This is not vital, but if you want to get the full mirror effect, we'll need to swap the audio channels so that the sound effects follow our mirrored video and controls. This is achieved using RetroArch's fun, powerful and oft-overlooked audio DSP system. The pre-installed 'panning' DSP has the ability to swap the channels, we just need to create a preset file that tells it how to do it. So, open up a text editor and paste in these contents:
filters = 1
filter0 = panning

# Swap left and right channels:
 panning_left_mix = "0.0 1.0"
 panning_right_mix = "1.0 0.0"
Save this file as something descriptive and change the file extension to 'dsp' (mine is named Mirror.dsp) and then move it into your RetroArch installation directory, under [RA dir]/filters/audio. Then, back out of the 'quick menu' and go to 'settings' -> 'audio' and scroll down to the 'Audio DSP Plugin' option, where you can select your newly made DSP preset:
 

Getting back to normal

Ok, that was fun, but I don't want to play like that forever, so it's time to put things back to normal. For the shader, go back to the shader options menu and navigate to the number of shader passes. Decrement it down to 0 (or hit the spacebar on your keyboard or 'start' on your gamepad) and then go up and 'apply changes' and you should be un-mirrored. Now, for the audio, go back into 'settings' -> 'audio' and navigate to the 'Audio DSP Plugin' option and press spacebar on your keyboard or 'start' on your gamepad to remove the plugin. As long as you didn't save the input remapping in the 'controls' menu, they should return to normal as soon as you 'close content' or 'quit RetroArch'.

Analytics Tracking Footer