Skip to content

Commit

Permalink
Ensure there isn't a stream of tiles repeatedly
Browse files Browse the repository at this point in the history
  • Loading branch information
melothemarten committed Oct 15, 2016
1 parent 35255f4 commit 791cc26
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,17 @@ FUNCTION_BEGIN CreateRandomTiles
CreateRandomTiles.forloop:
beq $s0, $s1, CreateRandomTiles.endforloop

CreateRandomTiles.retryunique:
# Get random number in interval [0, 3]
xor $a0, $a0, $a0
syscall

# Add 1 to get [1, 4]
addi $a0, $a0, 1

# Ensure that the new tile isn't the same as the previous one
lw $t0, -4($s0)
beq $t0, $a0, CreateRandomTiles.retryunique

# Write to the vector
sw $a0, 0($s0)
Expand Down

0 comments on commit 791cc26

Please sign in to comment.