Mode Spam

Mode Spam is an esoteric programming language where there are different modes. They all affect commands, input, and output in some way.
== Language overview ==
Mode Spam uses a 2-dimensional grid as its memory. It is infinitely long in every direction. Along with that, Mode Spam has an accumulator which you can store values to. Mode Spam uses .modespam file extensions.
== Modes ==
Mode 	Brief description
1. Basic Math and Memory	Move around the memory grid and use commands to manipulate it. Store and retrieve numbers from the accumulator and memory. Do basic math operations, like adding and subtracting.
2. Pixel Grid 	Move around the memory grid and a 256x256 pixel grid (which is a form of output) and change pixel colors.
3. Input 	Move around the memory grid and take input from the user. Includes number and character input.
4. Output 	Move around the memory grid and output values.
5. Data Retrieval 	Move around the memory grid and retrieve all sorts of data, like the current Unix timestamp.
By default the program will start in the first mode.
=== Pixel grid colors ===
Here are all the colors. Each color is associated with a number that will be used when changing or reading a pixel's color.
Black (#000000) 	  0
Red (#FF2626) 	  1
Orange (#FF8026)	  2
Yellow (#FFFF26)	  3
Green (#26FF26) 	  4
Blue (#2626FF) 	  5
Purple (#8026FF)	  6
Pink (#FF26FF) 	  7
White (#FFFFFF) 	  8
== Instructions ==
=== Universal instructions ===
These are instructions that work in any mode.
Opcode 	Description
> < ^ v	Move the memory pointer one cell. This is available in all modes.
, . 	Increment/decrement the active cell by one.
[ ] 	brainfuck-style loops. They function the same way.
z 	Switch between modes. Switches to the mode number of the active cell's value mod 6.
=== 1. Basic math and memory mode ===
The accumulator can only be accessed in this mode.
Opcode	Description
} 	Memory to accumulator. Loads the active cell's value into the accumulator.
{ 	Accumulator to memory. Replaces the active memory cell's value with the value of the accumulator.
+ 	Accumulator = accumulator + active memory cell
- 	Accumulator = accumulator - active memory cell
* 	Accumulator = accumulator * active memory cell
/ 	Accumulator = accumulator / active memory cell. Does float division.
% 	Accumulator = accumulator mod active memory cell. Does division but returns only the remainder.
\ 	Accumulator = accumulator ^ active memory cell.
r 	Rounds the accumulator to the closest integer.
R 	Rounds the accumulator up.
? 	Sets the accumulator to a random integer between the accumulator and the active memory cell, inclusive.
s 	Swaps the accumulator and active memory cell's value.
=== 2. Pixel grid mode ===
The pixel grid is a 256x256 grid where each pixel can have 9 different colors. The pixel pointer (the one that chooses which pixel is active) starts in the upper-left corner. If the pixel pointer moves out of bounds, then it will wrap around to the other side.
Opcode 	Description
w a s d	Move the pixel pointer up, left, down, or right one pixel in the pixel grid.
} 	Memory to pixel. Changes the color of the current pixel to the value of the active memory cell's value mod 9.
{ 	Pixel to memory. Sets the value of the active memory cell to the color value of the current pixel.
? 	Sets the current pixel to a random color.
f 	Flips the current pixel. Black will become white and vice versa. This only works if the pixel is either black or white.
=== 3. Input mode ===
If an input operation receives nothing, then it will default to 0.
Opcode	Description
i 	Take one number as input and store it in the active cell.
I 	Take one character as input and store its Unicode value in the active cell.
=== 4. Output mode ===
Opcode	Description
o 	Outputs the active cell's value as a number
O 	Outputs the active cell's value as a Unicode character.
=== 5. Data Retrieval mode ===
This mode is optional for interpreters. So far, this is all that I've added, and more may be added. This is kind of the little joke section, where there are many random things to retrieve that don't really have a real purpose.
Opcode	Description
t 	Sets the active cell's value to the current Unix timestamp.
l 	Sets the active cell's value to the length of the program (excluding whitespace)
L 	Sets the active cell's value to the current program counter.
== Examples ==
=== Hello, world! ===
==== brainfuck-style ====
It's possible to copy over a program and modify it to output values correctly.
Brainfuck program: (this is pretty unoptimized but I made it this way so that it's easier to output)
 >++++++++++
 [>+++++++>++++++++++>+++++++++++>+++++++++++>+++++++++++>++++>+++>
 +++++++++>+++++++++++>+++++++++++>+++++++++++>++++++++++>+++<[<]>-]
 >++>+>-->-->+>++++>++>--->+>++++>-->>+++
 [<]>[.>]
==== Mode Spam version ====
For the Mode Spam version, all you have to do is change the . to O, change the + and - to , and ., and change to output mode.
 >,,,,,,,,,,
 [>,,,,,,,>,,,,,,,,,,>,,,,,,,,,,,>,,,,,,,,,,,>,,,,,,,,,,,>,,,,>,,,>
 ,,,,,,,,,>,,,,,,,,,,,>,,,,,,,,,,,>,,,,,,,,,,,>,,,,,,,,,,>,,,<[<]>.]
 >,,>,>..>..>,>,,,,>,,>...>,>,,,,>..>>,,, // gets all the values for outputting
 [<]
 ,,,,z // switch to output mode
 >[O>]
=== A + B Problem ===
 ,,, z // to input mode
 i>i // take the 2 inputs
 >,z // to basic mode
 <} // store second value to accumulator
 <+ // add
 { // store back to cell
 <,,,,z // to output mode
 > o // output
=== Cat program (one time) ===
 ,,, z // input mode
 I // input (char)
 >,,,, z // output mode
 < O // output (char)
=== Cat program (indefinite) ===
 ,,,^,,,, // input mode top, output mode bottom
 vz // input mode
 >, // 1
 [
 <z>>I<<^zv>>O< // I think this will work
 ] // loop indefinetly
Category:Languages Category:Cell-based Category:Works-in-Progress Category:Unimplemented