Dedicated to the one always dissatisfied with my typesetting skills. Your comments have been a test to my patience and self-control.

To everyone's great surprise, this game contains bugs. It's mostly input processing.

Normally, this would be considered cheating, but hey, I know some puzzles are not easy and that I flunked the tutorial part.

Layer 0:

MOVE 4 0
MOVE 5 1

Move 4 up, then 5 right.

Layer 1:

MOVE 21 1
MOVE 4 0
MOVE -1 1
MOVE 2 0
MOVE 1 1
MOVE 8 0
MOVE -12 1
MOVE -4 0
MOVE -1 1
MOVE -2 0
MOVE 3 1
MOVE -4 0
MOVE 2 1
MOVE 1 0

Simply navigate through the maze.

Layer 2:

MOVE 1 0
MOVE 11 1
MOVE -1 0
READ [5]
MOVE 3 0
UNLOCK [5]
MOVE 3 0

Move to tile containing the code, read it (to register 5), then move down to the door and open it.

Layer 3:

MOVE 2 0
MOVE 1 1
READ [0]
MOVE -2 1
READ [1]
MOVE 1 1
ADD [2] [0] [1]
SUB [3] [1] [0]
MUL [4] [0] [1]
UNLOCK [2]
MOVE 4 0
UNLOCK [3]
MOVE 4 0
UNLOCK [4]
MOVE 4 0

Load both operands to registers 0 and 1. Do addition, substraction and multiplication into registers 2, 3, 4, respectivelly, then open doors.

Layer 4:

MOVE -3 1
MOVE 2 0
MOVE 3 1
MOVE 2 0
JMP 1

First four lines indicate a segment, that repeats multiple times. JMP to reuse.

Layer 5:

MOVE -4 1
READ [0]
MUL [0] [0] -2
MOVE [0] 0
MOVE 99 1

Load index to the first register, then multiply by two to get the desired amount of steps. We also need to change the direction (upwards), hence -1. Then go right by 99 steps.

Layer 6:

MOVE 6 0
READ [0]
SUB [0] [0] 47
JMPZ 7 [0]
MOVE 7 1
MOVE 99 0
MOVE -7 1
MOVE 99 0

Load value, then substract 47. Now we have to decide based on whether it's 0 or 1. If 0, then jump to the rest of the program (go left). This skips the 'go right' part.

Layer 7:

MOVE -6 1
READ [0]
MOVE 12 1
READ [2]
MOVE -6 1
MOVE -6 0
READ [1]
MOVE 8 0
SUB [2] [0] [2]
MUL [2] [2] [2]
MUL [2] [2] [1]
MUL [0] [0] 2
ADD [0] [0] [2]
MUL [0] [0] 2
ADD [0] [0] 3
UNLOCK [0]
MOVE 4 0

Load values a, b, c and do bunch of arithmetic operations.

Layer 8:

MOVE 5 0
MOVE -2 1
READ [0]
MOVE 4 1
READ [1]
MOVE -2 1
CMP [2] [0] [1]
ADD [3] [3] 1
SUB [0] [0] [1]
JMPZ 14 [2]
JMP 8
UNLOCK [3]
MOVE 5 0

Load values and then substract from a as much as possible without it getting to zero.

Layer 9:

MOVE 2 0
ADD [6] 0 4
JMP 15
MOVE 3 0
MOVE 2 1
ADD [6] 0 8
JMP 15
MOVE 2 0
ADD [6] 0 11
JMP 15
MOVE 2 0
READ [0]
MUL [1] [0] [0]
MUL [1] [1] 2
MUL [2] [0] -3
ADD [1] [2] [1]
ADD [1] [1] 7
UNLOCK [1]
JMP [6]

First we write a function, that reads a current tile, then computes an expression, unlocks the door and returns to line stored in the 6th register. Then we call this function by storing in the 6th register and jumping to the 15th line.

Layer 10:

MOVE 2 1
MOVE 1 0
READ [0]
MOVE 1 1
READ [1]
MOVE 1 1
READ [2]
MOVE 1 1
READ [3]
MOVE -1 0
MOVE 4 1
MOVE 1 0
READ [4]
MOVE 2 1
READ [5]
MOVE -1 0
MOVE 1 1
READ [6]
UNLOCK [[6]]
MOVE 4 1

Load all values and then use double dereferencing to get the correct one.

Layer 11:

MOVE 99 1
MUL [0] [7] -1
ADD [1] [7] 0
MOVE [0] 1
UNLOCK [1]
MOVE -2 0

Move right as far as possible, calculate the amount of steps in the opposite direction, save previous result, walk, then unlock door.

Layer 12:

MOVE 1 0
READ [1]
READ [2]
SUB [1] [1] 1
SUB [2] [1] 1
JMPZ 11 [2]
JMP 14
MOVE 1 1
MOVE -1 1
READ [4]
JMPZ 12 [4]
JMPN 5 [4]
SUB [4] [4] [1]
JMP 15

The most straightforward way is to check divisibility by all numbers (y) in the interval 2..x-1. y is iterated in the first segment. If it reaches 1, then we know that the examined number is prime (hence jump to 11). Otherwise jump to 14, that is check if repeated substraction leads to 0 or a negative number. If zero, then x is a composite number, if negative number, continue in previous cycle. Multiple read commands may seem confusing, but bear in mind, that you are standing on x tile.