C#: Value does not fall within the expected range

Categories Programming

To save anybody from a fruitless internet search, the default message for ArgumentException is the phrase “Value does not fall within the expected range”. This error may be returned from various sources, but in my case it was an explicit throw:

if (someInvalidValue)
throw new ArgumentException();

So if this error is bubbling up, it’s an ArgumentException.

Fantasy Consoles

Categories Programming

I’d been meaning to write for my blog, since I’m now posting more regularly on Twitter, and am fairly active in a few Discord chats. Most of what I’ve been doing lately has been centered around fantasy consoles.

Fantasy Consoles?

While there are differing opinions on exactly what constitutes a fantasy console, the basic idea is that it’s a game development platform for hardware that doesn’t exist. In some cases, there are entire systems dedicated to maintaining the illusion that somewhere in an alternative universe, these video game consoles could have existed.

Why Fantasy Consoles?

The most appealing aspect of developing on these platforms is the artificially-imposed constraint that working within a proscribed set of parameters affords. That’s a mouthful, but it’d probably be simpler to explain the idea with some practical examples.

Pico-8 demo cart

Let’s take the first and probably most well-known fantasy console out there, Pico-8. If the Pico-8 system were a real console, it would have lower color specs and resolution than a Game Boy Color with two less buttons. Its specs are as follows:

Display resolution: 128×128 pixels, 16 pre-set colors (through an additional palette 16 additional colors have been discovered)
Audio: 4-channel “bloops” (basic FM synthesis) simultanous
Input: Up to 4 six-button gamepads
Memory: Up to 32k for each cartridge
Language: Customized version of Lua

Cartridges for this platform are stored in the lower bits of the color channels in a standard PNG image, so the “cartridge” file actually contains all the relevant game data. The system itself comes with a feature to browse finished games, so Pico-8 can be used as a standalone console.

While you’d think that being limited to 128×128 pixels with only 16 colors at a time is fairly limiting, the community itself has made the platform an overwhelming success, and they continue to push out amazing games using a highly constrained format.

Some example Pico-8 games (click each to visit)

More Fantasy Consoles

Since Pico-8, there have been a slew of other fantasy consoles released, some with similar design goals, and some that are completely esoteric. I am currently maintaining a (mostly up-to-date) list of all the fantasy consoles I can find (let me know if I’m missing yours!). I’ve also helped a couple other people with their systems, and learned some different programming languages on the way.


If you need help getting started, check out the fantasy console list. If you’re looking for a well-established product with tons of community support, I really can’t recommend Pico-8 enough. It’s not free (at $14.99), but it’s one of the more polished systems out there.

My personal fantasy console recommendations are as follows:

  • Pico-8 ($14.99) – The original. Has a huge community following, and is the origin of #tweetcart.
  • TIC-80 (free) – This project came out almost directly on the heels of Pico-8. It has similar, but far less constraints, with a low barrier to entry.
  • PixelVision 8 ($14.99) – A system that lets you design your own constrained system, then make a game for it.

To discuss with other like-minded individuals, check out these Discord servers:

    Pico-8 – Useful for things other than Pico-8, but mostly centered around Pico-8.
    Fantasy Consoles – Includes most other smaller fantasy console channels.

There’s also a Fantasy Consoles wiki with more information on different FCs.

Making Games

And finally, what blog post would be complete without a little self-promotion? While working on the Leikr fantasy console, I turned a small demo into a “full” Flappy Bird style clone! The gameplay isn’t much to be impressed about, but all assets in the game were made by me: graphics, code, sounds, and music.

Update: Took down the game link because I broke it.

ROM Checksums and Headers

Categories Programming

NES ROM header

Lately I’ve been futzing around with classic game ROMs a bit more. Since nearly day one of Nesticle hitting the Internet, I’ve been obsessed with emulation of classic computer systems. I love playing old video games, and I love learning more about the internals of the systems I cut my teeth on back in the day.

But this post isn’t about nostalgia; it’s about organizing games, specifically ROM files. While I’m fairly certain I’ve got several discs (and old HDDs) filled with variously-complete ROM sets for various platforms, these were mostly collected from newsgroups waaay back in the day and as a result have a wide variety of headers, possible trainers, and intros. Nowadays, even the Internet Archive maintains full sets of “no-intro” ROMs donated by people who stayed in the scene far longer than I did.

If you intend to organize such a non-trivial amount of games, you’re gonna need some ROM utilities. The most well-known of these are clrmamepro, RomCenter, and RomVault. I’m sure there are others, but these are the big players. I’m not really going to speak about their various strengths/weaknesses, as that’s a little outside the scope of this post.

What I actually want to discuss is how checksums are calculated using the “datfiles” provided by the No-Intro site’s users. I had a hard time finding this information initially, so I’m putting it here for anyone else. Also, if I’m wrong, I’d love to be called out and told what I’m doing wrong.

I’m using the following:

I only found the clrmamepro iNES header config far later than the rest of this info. This specific file is fairly sparse, and only has the following:

<name>No-Intro NES Dat iNES Header Skipper</name>
<rule start_offset="10">
<data offset="0" value="4E4553"/>

Basically, take this to mean we’re starting at offset 0x10 and reading to EOF (NES files aren’t larger than 0x4e4553 bytes). Once I did this, my CRC32 checks started working. I’d normally stop there, but it looks like my MD5 and SHA-1 hashes are wrong. Adding the entire file back in fixes this, so…I’m not really sure why we’re bothering to trim the header for only one check.

To sum up:

CRC32 – 0x10 through EOF
MD5 – entire file
SHA-1 – entire file

Let’s Get Cuddly! (or not, I’m not judging)

Categories Programming

As a personal preference, I’m a fan of cuddly braces. It’s the way I learned, but I feel like it leads to more concise and readable code in most cases. I could go on, but as a topic it’s been beaten to death, and there are arguments with merit on both sides.

That being said, at work we use newline braces, and I don’t like it. A good programmer follows the in-place coding style, so that’s what I’ve been doing. It doesn’t mean I have to like it, though. While I use a separate installation of Visual Studio on an entirely different computer for coding my personal projects, there are times where I’d like to not have to completely switch machines to bang out some lines of code.

After reading that you can export and import Visual Studio settings, I created two settings files trimmed down to only include indentation and newline settings, so now I can simply import a settings file and all the rules I want changed are changed.

Feel free to edit the below files to your needs:

VS_Personal.vssettings (3.6k) – Cuddly style
VS_Work.vssettings (3.6k) – Non-cuddly style (braces on newlines)

These are only for Visual Studio, though. I’ve got nothing to offer for other editors, but feel free to contribute settings files for any other IDE.

PSA: Vertex and Vertices

Categories Uncategorized

Hey everybody, just a quick reminder that the singular form of vertices is vertex. There is no such thing as a “vertice”.

the singular form of "vertices" is "vertex"I’ve heard it pronounced this way in video tutorials (especially from one specific “guru” who knows a lot about Blender ;), but recently I’ve noticed this malapropism being used in written tutorials as well.

The Importance of Order

The order of things is important; even moreso when those things are command line arguments.

After spending way too long (~30 minutes) trying to figure out why my background Blender renders were producing default cubes when that is clearly not what is in the scene, I finally looked at the console output and understood.

blender --background --python script.py myfile.blend

What this command does is tells Blender, “Load into memory as a background process and run script.py (which changes some settings and starts a render). Then load myfile.blend.” Once the file is loaded, background Blender exits.

In the proper order:

blender myfile.blend --background --python script.py