WIWH

From Esolang
Jump to navigation Jump to search

WIWH (which stands for Wishing I Were Home, a song by the musician Todd Edwards, famous for having large amounts of tiny samples in his songs) is an esoteric programming language created in 2023 by User:BoundedBeans in which code is disguised as a sample find video.

Syntax

A WIWH program is an uncompressed or losslessly compressed video (the exact format can vary by implementation, though implementations are free to handle multiple).

Out of the 16,777,216 24-bit colors, 510 are reserved. These are any color where the red and green channels are either both 0 or both 255, and the blue channel is not 0. (Most reserved colors will be visually identical to the human eye with a difference of 1 on the red or green channel, so you can be free to use whatever graphic design you want, although it should ideally have a black background.)

For every frame, if the bottom left corner and the bottom right corner are the same color, the bottom fourth of the frame (rounded down) is copied, all non-white (#FFFFFF) pixels in the copy are changed to black (#000000), then the result is run through an optical character recognizer to form the command. Then some special pixels are checked.

A few pixels in the top left have special meaning (the indexes here are 1-based).

Pixel coordinates (x, y) (one-based) ! Purpose
1, 1 Indicate a special meaning using the 2-17, 1-4 range as a 16x4 rectangle of arguments.
2-17, 1-4 Arguments.

Special meanings of pixel 1, 1

Color Meaning Argument meaning
#000001 Error correction on the text. Each of the 4 rows represents an single byte correction. If a pixel is color #000001, it represents bit 1, and if it is not reserved, it represents bit 0. The first 8 bits of a row represent the one-based index of the byte in the string, and the last 8 bits represent the byte to change to. If there are more than 4 mistakes, you will have to change the text being recognized. (You could also use this to add purposeful spelling errors as a joke, but no more than 4.)
#000002 Calling another file Interpret each of the rows as 4 bytes, with a non-reserved color being a 00, color #000001 being 01, color #000002 being 10, and #000003 being 11. If one of the colors in a byte is #0000FF, discard that byte. This forms 16 or less characters which form an ASCII filename for another video file to call. The command will be ignored.

Commands

These commands are case-insensitive. They run on a tape that is infinite to the right and left containing wrapping cells from 0-255.

The left side of the tape relative to the starting point contains command line arguments, in this format from right to left: A byte is represented by 1 followed by the byte. The end of an argument is represented by two zeroes. The last argument is followed by an additional 0 followed by a one.

So if the arguments were:

-t Hello "a b"

The tape would contain (the arrow represents the pointer):

1 0 0 0 98 1 32 1 97 1 0 0 111 1 108 1 108 1 101 1 72 1 0 0 116 1 45 1 ->0 0 0 0 0 0...
Syntax ! Semantics
+(number) semitone(optional s) Adds the number to the current cell.
-(number) semitone(optional s) Subtracts the number from the current cell.
+(number) cent(optional s) Adds the number to the cell pointer.
-(number) cent(optional s) Subtracts the number from the cell pointer.
this sampled (text 1 without -) - (text 2) Declares that if the instruction pointer hits a label referred to by text 1, it will jump to the command after the label referred to by text 2. This command must actually be executed before the label, otherwise the label will not actually jump (this may be desirable for some types of control flow). This command can also change the targets of an existing label. Note that the hyphen must be surrounded by spaces.
("artist", "song", or "album"): (text) Places the label referred to by the text. Labels must be unique. Skipping over a label causes it to not do the jump attached to it by the this sampled... command.
fast-forward Skips the next command if the current cell is zero.
reversed Skips the next command if the current cell is not zero.
listen closely Print the cell as a byte.
let's play it again Input a byte to the cell.

WIWH-IH

WIWH-IH (the IH stands for I'm Hopeful, another song by Todd Edwards) is a variant of WIWH that works in an ASCII format. This should only be used when an uncompressed video file would be completely out of the question, otherwise a video should be used.

WIWH-IH consists of a list of Instructions, each following this format:

//Represents a single instruction
Instruction ::= Pixel* "/" Newline Characters "::" Newline
//Represents a reserved pixel
Pixel       ::= Coordinates " -> " Color Newline
//Represents the one-based coordinates of a pixel
//Multiple coordinates means multiple pixels with the same color
Coordinates ::= "(" Digit+ "," Digit+ ")"
              | "{:" Coordinates+ ":}"
//Represents a pixel's color
Color       ::= "%\[" HexDigit{6} "]"
HexDigit    ::= [0123456789ABCDEF]
//Represents the text of an instruction
Characters  ::= AnyCharacterOtherThanNewline* Newline
//Represents the ending of a line
Newline     ::= "\n"
              | "\r"
              | "\r\n"

Pixels are color #000000 by default, which is non-reserved.

An example of an instruction in WIWH-IHL:

(1,1) -> %\[000001]
(9,1) -> %\[000001]
(12,1) -> %\[000001]
(14,1) -> %\[000001]
(16,1) -> %\[000001]
(17,1) -> %\[000001]
/
$6 Semitones
::

Or alternatively:

{:(1,1)(9,1)(12,1)(14,1)(16,1)(17,1):} -> %\[000001]
/
$6 Semitones
::

This translates into +6 Semitones.

Note that the whole pixel syntax isn't super necessary unless you want to call other files, since error correction isn't super necessary in text form. The error correction mechanism is provided in case the optical character recognizer doesn't work.

Examples

Truth-machine in WIWH-IH

/
Let's play it again
::
/
-48 Semitones
:: 
/
This sampled Bee Gees - Stayin Alive
::
/
Fast-forward
::
/
Artist: Bee Gees
::
/
+48 Semitones
::
/
Listen closely
::
/
This sampled Daft Punk - Too Long
::
/
Artist: Daft Punk
::
/
Song: Stayin Alive
::
/
+1 Cent
::
/
+49 Semitones
::
/
This sampled Phoenix - If I Ever Feel Better
::
/
Song: If I Ever Feel Better
::
/
Listen closely
::
/
Artist: Phoenix
::
/
Song: Too Long
::

Computational class

WIWH (and WIWH-IH, since it has the exact same capabilities) is Turing-complete, since it can simulate Brainfuck.

Brainfuck WIWH-IH
+
/
+1 semitone
::
-
/
-1 semitone
::
>
/
+1 cent
::
<
/
-1 cent
::
.
/
listen closely
::
,
/
let's play it again
::
[(brainfuck code)]
/
this sampled {unique name 1} - {unique name 2}
::
/
reversed
::
/
artist: {unique name 1}
::
/
song: {unique name 4}
::
{brainfuck code transformed into WIWH-IH by this table}
/
this sampled {unique name 3} - {unique name 4}
::
/
fast-forward
::
/
artist: {unique name 3}
::