Advertisement
Runer112

Slide left

Apr 18th, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Lbl Left
  2. .r₁=row scan offset
  3. .r₂=column scan index
  4. .r₃=column dest index
  5. .r₄=last value slid
  6. 0
  7. .For each row
  8. For(4)
  9. →r₁
  10. 0→r₃→r₄
  11. .For each column, starting from the left
  12. For(4)
  13. →r₂
  14. .If occupied by a tile
  15. If {+r₁+L₁}
  16. .Remove original tile
  17. Select(→r₅,0→{r₁+r₂+L₁})
  18. .If equal to the last slid tile
  19. !If -r₄
  20. .Increment merged tile value
  21. {r₁+r₃-1+L₁}++
  22. .If not equal to the last slid tile
  23. Else
  24. .Store tile to destination and increment destination index
  25. Select(r₅,→{r₃+++r₁-1+L₁})
  26. End
  27. .Store value last slid (or garbage if a merge occured)
  28. →r₄
  29. End
  30. r₂+1
  31. End
  32. r₁+4
  33. End
  34. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement