Hi this is my first post here. I am making a maze game in mips that uses bitmap display and the Keyboard and Display MMIO Simulator for movement. I created my function that accepts the characters WASD and when I press any movement key the character moves infinitely in the direction I input. For example, pressing W once causes my character to keep moving right until my MARS crashes. I only want it to move once and then wait for a new input. Attached below is the code I am trying to debug. If possible I want to implement the jr $ra register into my code. Thanks
.eqv characterPos $t5
gameUpdateLoop:
lw $t3, 0xffff0004 # get input from user, then call appropriate movement function
beq $t3, 100, moveRight # input d = move right
beq $t3, 97, moveLeft # input a = move left
beq $t3, 119, moveUp # input w = move up
beq $t3, 115, moveDown # input s = move down
beq $t3, 120, exitGame # input x = exit game
jal gameUpdateLoop
moveRight:
### MOVE RIGHT ###
addi characterPos, characterPos, 4
sw $t6, 0($t5)
j gameUpdateLoop
moveLeft:
### MOVE LEFT ###
addi characterPos, characterPos, -4
sw $t6, 0($t5)
j gameUpdateLoop
moveUp:
### MOVE UP ###
addi characterPos, characterPos, -256
sw $t6, 0($t5)
j gameUpdateLoop
moveDown:
### MOVE DOWN ###
addi characterPos, characterPos, 256
sw $t6, 0($t5)
j gameUpdateLoop
exitGame:
li $v0 10
syscall
I tried using jal instead of j to call back gameUpdateLoop. I am not sure what else can be the problem
John Legaspi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.