From 791cc2670e8dc4ac04056f7bfa9aaf55cf442195 Mon Sep 17 00:00:00 2001 From: Ivan Dardi Date: Sat, 15 Oct 2016 20:04:34 -0300 Subject: [PATCH] Ensure there isn't a stream of tiles repeatedly --- main.asm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.asm b/main.asm index bc01ab7..5e495a1 100644 --- a/main.asm +++ b/main.asm @@ -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)