View difference between Paste ID: WA2t0dmE and seutCrU4
SHOW: | | - or go back to the newest paste.
1-
Lbl Left
1+
Lbl Right
2
.r₁=row scan offset
3
.r₂=column scan index
4
.r₃=column dest index
5
.r₄=last value slid
6-
 0
6+
 3
7
.For each row
8
 For(4)
9
  →r₁
10-
  0→r₃→r₄
10+
  0→r₄
11-
  .For each column, starting from the left
11+
  12→r₃
12
  .For each column, starting from the right
13
  For(4)
14
   →r₂
15
   .If occupied by a tile
16
   If {+r₁+L₁}
17
    .Remove original tile
18
    Select(→r₅,0→{r₁+r₂+L₁})
19
    .If equal to the last slid tile
20
    !If -r₄
21-
     {r₁+r₃-1+L₁}++
21+
22
     {r₁+r₃+4+L₁}++
23
    .If not equal to the last slid tile
24-
     .Store tile to destination and increment destination index
24+
25-
     Select(r₅,→{r₃+++r₁-1+L₁})
25+
     .Store tile to destination and decrement destination index
26
     Select(r₅,→{r₃-4→r₃+r₁+4+L₁})
27
    End
28
    .Store value last slid (or garbage if a merge occured)
29
    →r₄
30-
   r₂+1
30+
31
   r₂-4
32-
  r₁+4
32+
33
  r₁-1
34
 End
35
Return