Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I ' m having trouble with this code in mips assembly checking if the C key is pressed. drawmode _ nothing: push ra # Check
Im having trouble with this code in mips assembly checking if the C key is pressed.
drawmodenothing:
push ra
# Check if left mouse button is pressed
lw t displaymousepressed
and t t MOUSELBUTTON # Check if bit left mouse button is set
beq tendifnotclicked # If left mouse button is not pressed, skip drawing
# Set drawmode to MODEBRUSH
li t MODEBRUSH
sw t drawmode
# Draw a pixellong line at current mouse coordinates in current color
lw a displaymousex # Load current mouse x coordinate
lw a displaymousey # Load current mouse y coordinate
lw a displaymousex # Load current mouse x coordinate
lw a displaymousey
lw v color
jal displaydrawline
lw a displaymousex # Load current mouse x coordinate
lw a displaymousey # Load current mouse y coordinate
# Set lastx and lasty to current mouse coordinates
sw a lastx
sw a lasty
li t KEYC
sw t displaykeypressed
lw t displaykeypressed
beq tendifnotclicked
j cclicked
j endifnotclicked
cclicked:
li t MODECOLOR
sw t drawmode
la t displaysprtable
addi t t
#inside your
#initialize outer loop counter
li s
#nested for loop
outerloop:
#initialize inner loop counter
li s
innerloop:
#t calculate x cord
mul t s
add t t PALETTEX #spritex PALETTEX x
sb tt
#calculate y cord
li t PALETTEY
mul t s
add t t PALETTEY #spritey PALETTEY y
sb tt
#calc which tile to use
li t PALETTETILE
add t t s # Calculate the tile index by adding s to PALETTETILE
#add t t s
sb tt
#settilespriteindex, PALETTETILE spriteindex
#flags are just
li t
sb tt
#finally, add to t to move to the next sprite
add t t
#inner loop increment and branch here
add s s
blt sinnerloop
#outer loop increment and branch here
add s s
blt souterloop
endifnotclicked:
pop ra
jr ra
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started