2DP

From Esolang
Jump to navigation Jump to search

2DP is a language made by User:iconmaster. This language, interestingly enough, was made before the author knew about esoteric programming.

2DP is an acronym for 2 Dimensional Processor.

Description

A 2DP program consists of Heads and Tiles. all the tiles form a grid, and can hold any 8-bit value. Heads move across the tiles, executing instructions on the tile under them. Heads can go in any one of 8 directions. Additonally, heads can also store a 8-bit hex value. Heads will continue on their path, and execute the instruction contained on the tile under them. The program ends when all the heads have been deleted. The only form of output is through 8-bit color codes. The playfield is 256*256 tiles.

Commands

Descriptions are unfinished.

(Note that if a command has a #2 or #3, it has arguments. Arguments are always directly next to the instruction, and going in the direction of the head. Heads will skip over arguments the next tick. Also note that VAL is a reference to the head’s stored value.)

00 NOP
 Does nothing. The default config for all tiles.
01 LT
 Turns left once. IE: N to NW.
02 RT
 Turns right once.
03 LT 2
 Turns left twice. IE: N to W.
04 RT 2
 Turns right twice.
05 LT 3
 Turns left 3 times. IE: N to SW.
06 RT 3
 Turns right 3 times.
07 REV
 Reverses the heads position. IE: N to S.
08 TRL #1
 Sets the trail to #2. From now on, it will replace any tiles it goes over with this value.
09 TOFF
 Disables the trail.
0A JROW #2
 Sets the heads row to #2.
0B JCOL #2
 Sets the heads colunm to #2.
0C JP #2,#3
 Jumps to row #2, col #3.
0D MOVE #2
 moves forward #2 spaces
0E ADD #2,#3
 Adds #2 and #3, and stores the value at #2's position.
0F SUB #2,#3
 Subtracts #2 and #3, and stores the value at #2's position.
10 SET #2,#3
 Sets the space #2 paces away from it to #3.
11 HALT
 Stops the movement of the head until a START command is under it.
12 AND #2,#3
 Logical ANDs #2 and #3, and stores the value at #2's position.
13 OR #2,#3
 Logical ORs #2 and #3, and stores the value at #2's position.
14 XOR #2,#3
 Logical XORs #2 and #3, and stores the value at #2's position.
15 NOT #2
 Logical NOTs #2.
16 COPY #2,#3
 Copy the value #2 paces away form it, and store it #3 paces away from it.
17 NEWHD #2
 Generates a new head #2 paces away form it.
18 SAVE #2
 Stores the value #2 paces away from it into VAL.
19 LOAD #2
 puts VAL #2 spaces away from it.
1A EXEC
 Executes the command in VAL.
1B SVAL #2
 stores #2 into VAL.
1C LDADD #2
 adds VAL and #2, and stores it in VAL.
1D LDSUB #2
 Subtracts VAL and #2, and stores it in VAL.
1E LDJR
 Jumps to the row pointed to by VAL.
1F LDJC
 Jumps to the colunm pointed to by VAL.
20 LDAND #2
 Logicl ANDs VAL and #2, and stores it in VAL.
21 LDOR #2
 Logicl ORs VAL and #2, and stores it in VAL.
22 LDXOR #2
 Logicl XORs VAL and #2, and stores it in VAL.
23 LDNOT
 Logical NOT's VAL.
24 CP #2
25 SROW
 Saves the row into VAL.
26 SCOL
 Saves the colunm into VAL
27 IF #2,#3
 If #2 is equal to VAL, jump #3 paces forward.
28 SHD ON
 Turns SHD on. When it is on, it gives VAL to newly created heads.
29 SHD OFF
 Turns SHD off.
2A DELHD
 Deletes the head.
2B DIR N
 the DIR commands make the head move in the argument's direction.
2C DIR NE
2D DIR E
2E DIR SE
2F DIR S
30 DIR SW
31 DIR W
32 DIR NW
33 INC #2
 Increments the tile #2 paces away.
34 DEC #2
 Decrements the tile #2 paces away.
35 LDINC
 Increments VAL.
36 LDDEC
 Decrements VAL.
37 LDMOV
 Moves forward VAL paces.
38 BACK #2
 Moves backwards #2 paces.
39 LDBACK
 Moves backwards VAL paces.
3A RAND #2
 Puts a random value #2 paces away.
3B LDROW #2
3C LDCOL #2
3D SPOS #2#3
 Sets the position to #2 and #3.
3E HDAT #2#3
 Sets VAL to 1 if there is a head at the position #2#3, 0 otherwise.
3F SHFT #2
40 LDSHFT
41 LDTRL
 Sets the trail to VAL.
42 START
 Starts a halted head.
43 SAT #2#3
44 LDAT #2#3
45 LTIF #2
 turns 2 left if #2 is not 0.
46 RTIF #2
 turns 2 right if #2 is not 0.
47 LTIFLD
 turns 2 left if VAL is not 0.
48 RTIFLD
 turns 2 right if VAL is not 0.
49 COLR #2
 Sets the color trail to #2.
4A COLR OFF
 Disables the color trail.
4B SETCOLR #2
 Sets the color #2 paces away from it to VAL.
4C LDCOLR
 Sets the color trail to VAL.
4D GETCOLR #2
 Loads the color #2 paces away from it.

Interpreter Syntax

A theroetical 2DP program would be split into 2 sections, the Heads section and the Tiles section. The HEADS section would define all the heads in the program when it starts. Each entry has this syntax:

X nn Y nn DIR dd VAL nn [HALTED]

Where nn is a hex number, and dd is a direction (N,NW,W,etc.).

The fields are:

  • X: The X position of the head. Default is 01.
  • Y: The Y position of the head. Default is 01.
  • DIR: The direction of the head. Default is E.
  • VAL: The stored value of the head. Default is 00.
  • HALTED: Include this word if the head starts out halted.

The TILES setion would contain a grid of tiles. Each tile is 2 characters long, and 1 tall. The hex value of each word is put into the corresponding tile. Spaces equate to 0s.

The complete program style is like this:

HEADS
 (head definitions here)
TILES
 (Tile words here)

Computational Class

2DP is at best a Bounded-storage machine, because of its fixed playfield and data size. However, a version somehow including bignum words or a infinite playfield would be Turing-complete.