Oatmeal

A digital pillow fort

Looking up at a tree covered in shelf mushrooms

Up and up and up

I realized this morning why I’m put off by super hero movies. They are fun, and I’ve always loved comic books, but the super hero movies of the last decade specifically, (I mean, beside being military propaganda) totally omit the potential future of any sort of utopia. They cannot envision their own undoing.

The stories are predicated on the super heros always needing something to be super against, despite having fantastical abilities to help usher in some sort of utopia…they end in punching. The zeitgeist is saturated by super heros that reinforce the systems the work to protect folks from and endless stories of dystopian collapse.

I guess I am looking for utopian stories these days — stories that can see and spell the way towards a better future.

What is Solar Punk?

Data Types and Variables in C

I’ve been writing a heap of Lua lately — this has lead to my becoming interested, again, in C. Here are some ancient notes I dug up on the most basics of data types and variables in C.

All of a computer’s memory is comprised of bits. A sequence of 8 bits forms a byte. A group of bytes (typically 4 or 8) form a word. Each word is associated with a memory address. The address increases by 1 with each byte of memory.

In C, a byte is an object that is as big as the smallest addressable unit.

Bytes are the minimum addressable, 8 bit wide unit.

A variable is a container for data. A variable is a symbolic representation of a memory location, or address.

A variable is comprised of a few parts:

First, define the data type, then an identifier, and then, optionally, initialize the variable with some data.

int number_of_bananas = 124;

Here, int is the data type, number_of_bananas is the identifier and 124 is the data.

C is strongly typed, this means that the data type cannot be changed after it is declared. You can make the value immutable by turning it into a constant using the const keyword.

const int number_of_bananas = 124;

A data type is a collection of compile-time properties, including:

  • memory size and alignment
  • set of valid values
  • set of permitted operations

Some data types available in C include,

  • Numbers (int, float, hex, etc.)
  • Characters
  • Strings
  • Array
  • Complex data types, like structs and pointers

Numbers and characters are called fundamental data types” in C — all other data types are called derived data types” because they are derived from the fundamental types.

Integers, int, are any non-fractional numbers either negative or positive including 0. You would use an int to describe the number of pets you have — you cannot have a fractional number of pets…unless you’ve done something awful and/or are cosplaying as King Solomon.

ints come in both signed and unsigned flavors. An int can be negative or positive, while an unsigned int can be 0 or positive, never negative. unsigned ints are useful for when you need to express a very large positive value. So, if you were going to create a variable to represent the temperature in Fahrenheit, you would want to use an int since the temperature in Fahrenheit can be negative, positive or exactly 0. While, if you were going to create a variable to represent the temperature in Kelvin you would probably want to use an unsigned int since Kelvin starts at 0 and only goes up from 0.

You can define the unsigned int data type using the keyword unsigned int or just unsigned.

Beside coming in signed and unsigned variants, int also comes in different sizes –

  • short int
  • int
  • long int
  • long long int

These describe different byte sizes allotted to the value. These exist in unsigned variants, too. See stdint.h for waaaaay more on this.


Totally random aside! When displaying a variable you need to use the correct format specifier, so, if a plain ol’ int %d whereas if a long int %ld. Now, if you wanna format the number a bit more, you can also include a width to help pad the number, e.g. %7d will add 6 leading spaces before the number if it is 1 digit long, or 5 if the number is 2 digits long.

int the_number = 42;
printf("The Answer to life, the universe and everything is %7d\n", the_number);

// The Answer to life, the universe and everything is      42

floats and doubles can also include a number in their format string that defines their precision.

So, with 2 points of precision:

float pi = 3.14;
printf("%12.2f | PI\n", pi);
double pi2 = 314E-2;
printf("%12.2e | PI\n", pi2);

//      3.14 | PI
//  3.14e+00 | PI

Or with 4!

float pi = 3.14;
printf("%12.4f | PI\n", pi);
double pi2 = 314E-2;
printf("%12.4e | PI\n", pi2);

//  3.140000 | PI
//3.1400e+00 | PI

While ints represent discrete values floating point numbers (floats) are used to represent any number, negative or positive, including 0 and decimals, e.g. 3.14 is a float. This can also be written as 314E-2 as a double.

float pi = 3.14;
double pi2 = 314E-2;

char variables are represented numerically by an 8 bit signed integer (1 byte). This means that the available numeric range for char is from -128 to 127. This is the range of the ASCII table. BOOM, or from Wikipedia.

While char ranges from -128 to 127 unsigned char ranges from 0 to 255.

A boolean is a variable that can only take 1 of 2 values. Either true or false. C originally didn’t have any booleans, instead false was assumed to be 0 and anything other than 0 was considered to be true. While modern C supports boolean data types, treating 0 as false remains a common idiom. The boolean data type was introduced in the C99 standard.

An enumeration, or enum is a list of constants. It is useful for when you want to select exactly 1 option from a list of predefined values. Behind the scenes, enums are nothing more than numbers…this makes sense for a data type called an enumeration. enums return an index, not an identifier, e.g. 

enum Menu {
    COFFEE,  // 0
    JUICE,   // 1
    WAFFLES, // 2
};

enum menu order = JUICE;

printf("The order: %d\n", order);

// The order: 1

If you want to explicitly set an index on an enum option you can. Note that the numbers of the options picks up from whatever you defined.

enum months
{
    JAN = 1,
    FEB,
    MAR,
    APR,
    MAY,
    JUN,
    JUL,
    AUG,
    SEP,
    OCT,
    NOV,
    DEC,    
};

The above ensure that the months are numbered in a sane way…not starting from 0.

In reply to: MEMEX - The Small Website Discoverability Crisis [2021-09-08]

A proposal, dear reader: Create a list of bookmarks linking to websites you find interesting, and publish it for the world to see. You decide what constitutes interesting”.

In reply to: Sable: Kotaku Review, My Top Game of 2021

Sable’s world is not a broken machine, it’s doing fine. You’re not on some grand quest to save it, or return the planet to its former glory. You’re just a girl growing up in this place, and growing up means choosing a new mask.

Closing,

Sable imagines identity and growth as playful, joyous, and nearly impossible to fail. It promises you that changing your mind is okay. You wanted to be an Innkeeper, and now you don’t. It encourages you to become something else then, without rejecting or hating the person you’re leaving behind.

Later on,

Sable imagines something different, and gentler. It imagines masks as objects which communicate to other people who you are, and how you can help them. You can find the machinist in any city, or the cartographer in any bar. These identities are not the only part of the person, of course, but they do express how they relate to other people. And I think that, at its best, that’s what identity is all about.

How to install Uxn on macOS

Uxn is an esoteric stack-machine with 32 bit instructions. It exists someplace at the intersection of a GameBoy, 6502 ASM, an Apple II, Forth, RetroForth, the z80, a Sinclair ZX Spectrum, and what if Nausicaä from Studio Ghibli’s Nausicaä of the Valley of the Wind used a computer?” It is tiny, unlike most anything else around these days, and, once you wrap your head around it, pretty fun.

I won’t go into how to develop for it here (mostly because I’m not heaps good at that, not yet) but will walk you though how to get it running under a relatively recent release of macOS.

For more info on how to use it and develop programs for it see:

Assumptions

I’m assuming that you, at a minimum know how to find and launch the terminal application on macOS. Opening Launchpad or Spotlight and typing Terminal” should do the trick. Beyond being able to start the terminal application this assumes no prior knowledge of the command line nor Unix.

To run a Uxn rom you’ll need a Uxn emulator. There are a few of these out and about, but I’ll focus on the reference implementation here, Uxnemu.

This implementation has only one dependency, SDL2. SDL2 provides the audio/video bindings, as well as a few other niceties, to the host OS.

If you’ll be building Uxnemu from source you’ll need SDL2 to be installed on your machine. I’ll provide more information about that further on.

Quick and easy

If you don’t want to bother with installing anything other than Uxnemu you can download a build of it that includes SDL2 here.

When this downloads it’ll look sort of like a text file, not a normal application like you are probably used to. Before you run it you’ll need to change permissions on it to make the file executable (able to be run as a program). To do this you’ll have to launch the macOS’ terminal.

Once you’ve launched the terminal, either drag your downloads directory on to the terminal and press return on your keyboard, or type the following (assuming you’ve not changed the location of your system-standard downloads folder),

cd ~/Downloads

Then press retrun on your keyboard.

You’ve navigated to your downloads directory! Next up, we’ll make the freshly downloaded Uxnemu executable. To do this, type the following:

First, ensure that the file is present in the downloads folder:

ls

Then hit return.

You should see a list of all the contents of your downloads directory, including uxnemu. If you don’t see uxnemu you are either in the wrong directory or didn’t download it.

If you need to troubleshoot: check what directory you are in — type pwd and then hit return. This will display the current directory, it should return a string of text that ends in Downloads.” If you are in the downloads directory and still don’t see uxnemu download it again and check to where it is being saved.

Once in your downloads folder with your fresh copy of uxnemu run the following commands to make it executable:

chmod a+x uxnemu

Hit return!

This command will make uxnemu executable. To test that it worked, run the following,

./uxnemu

Then hit return — you should see output like, usage: uxnemu file.rom. If you do, that means that it worked! You’ve now got yourself a working uxnemu emulator.

Snag a rom and go nuts!

Give it a go, download the piano.rom from here.

Now run,

./uxnemu piano.rom

A new window will open. You should see something along the lines of this!

Uxn’s piano rom

Slightly more involved

Now, if you wanna get a little deeper into the weeds, you can assemble uxnemu from source. To do that, you’ll need to have some more pieces in place.

Preparing the way

Before we get started ensure that you’ve got all the necessary tools to build unxnemu’s C source. The easiest way to do this is to use macOS’ deeply middling package manager, brew. Before you install it, you’ll need to install the Xcode Command Line Tools (if you haven’t already, or if you haven’t installed the full, GUI, version of Xcode).

Here are directions for how to do that. Or, tl;dr wanna live dangerously xcode-select --install!

If you don’t explicitly needs Xcode, I recommend the command line tools over the full Xcode GUI because Xcode is ginormous, and will devour a computer’s disk-space.

Once you’ve got the Xcode Command Line Tools and brew installed you are almost ready. As mentioned above, Uxn depends on SDL2. We’ll use brew to install that.

Check that brew is working by looking for SDL2,

brew info sdl2

It’ll output something sort of like this if everything is working to plan,

Brew info sdl2’s output

With that command we ensured that sdl2 is available through brew, but haven’t yet installed anything. Eyes on the prize, you are ready to install sdl2. Do that by running,

brew install sdl2

That will output something along the lines of,

Brew install sdl2’s output

Note that brew can sometimes be bananas slow. Patience is key to this step.

Once brew is done doing its thing, and sdl2 is installed you are ready to start cooking with fire!

Doing the thing

The first step is to obtain the uxn source code. We’ll use git to do that. At the terminal,

git clone https://git.sr.ht/~rabbits/uxn

Then return.

This will download the uxn project. It’ll look something a bit like this,

Cloneing uxn’s output

Once that has completed, enter the directory you just cloned using git by typing,

cd uxn

Then return — from within that directory, now type,

ls

And then hit return on your keyboard. You’ll see a listing of the directory’s contents, like this

The contents of uxn’s repo

Now we’re reading to do the thing! Uxn comes with a handy script called build.sh. The script is a little program that can build uxnemu and a few other programs for you. To run it,

./build.sh

And return!

Uxnemu build and run

That will run the build script. The build script will build, and then run a default rom, like this!

Uxn’s piano rom

At this point you should be good to go!

Building from source means that you have the uxnemu as well as the uxnasm.

The uxnemu is an emulator, capable of running assembled Uxn roms.

The uxnasm is an assembler, capable of assembling Uxntal files into roms for the uxnemu to run!

As I learn more about about Uxn I hope to write more about it, in the meantime, check out the great tutorial!

In reply to: Kids who grew up with search engines could change STEM education forever - The Verge

This, for me, points to the arbitrariness of the desktop” as a prime metaphor in computer user interfaces.

It made sense at the birth of contemporary computing — business suits and what not — but maybe there’s a new paradigm worth exploring? Something not so exceedingly boring. Something that embraces scale, or relationships that can’t be easily modeled in 3d space?

« Future Page 1 of 203 Past »