BOUNCING BALL GAME

I HAVE BOUNCING BALL GAME PROJECT IN MIPS ASSEMBLY LANGUAGE. THE GAME IS SETUP BUT THE BALL AND PADDLE IS NOT MOVING USING MARS PROGRAM. HOW TO FIX IT AND MAKE THE GAME WORK. PLASE MAKE SURE ITS USED IN MARS PROGRAM.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

PLEASE MAKE SURE IT WORKS ON MARS POGRAM

PLEASE MAKE SURE ITS DISPLAY MAP ON MARS

MAKE SURE YOU USE THE CODE I SEND

PLEASE MAKE SURE YOU USE GRAPHICS

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

PLEASEEEE MAKE SURE IT WORKS BEFORE YOU SEND IT

.data

# Constants

SCREEN_WIDTH:.word 32

SCREEN_HEIGHT:.word 20

BALL_VELOCITY:.word 1

PADDLE_WIDTH:.word 10

PADDLE_Y:.word 18

LEFT_HOLE_X:.word 2

RIGHT_HOLE_X:.word 30

HOLES_Y:.word 1

SPEED_INCREASE_INTERVAL: .word 5

# Variables

ball_x:.word 16

ball_y:.word 1

ball_velocity_x:.word 1

ball_velocity_y:.word 1

paddle_x:.word 11

start_time:.word 0

current_time:.word 0

speed_increase_count: .word 50

speed_increase_amount: .word 50

.text

.globl __start

__start:

# Set the exception handler address

la $k0, handle_unexpected_

syscall

mtc0 $k0, $14

# Jump to the main function

j main

# Procedure: draw_components

# Draws the ceiling, ball, and paddle on the screen.

draw_components:

# Save registers

addi $sp, $sp, -12

sw $ra, 8($sp)

sw $s0, 4($sp)

sw $s1, 0($sp)

# Load constants

lw $s0, SCREEN_WIDTH

lw $s1, SCREEN_HEIGHT

# Draw the ceiling

li $t1, 0

draw_ceiling_loop:

li $v0, 11

li $a0, ‘M’

syscall

addi $t1, $t1, 1

blt $t1, $s0, draw_ceiling_loop

# New line

li $v0, 11

li $a0, ‘\n’

syscall

# Draw the ball

lw $t1, ball_y

draw_ball_vertical_loop:

li $v0, 11li $a0, ‘\n’syscall

addi $t1, $t1, -1

bgtz $t1, draw_ball_vertical_loop

lw $t1, ball_x

draw_ball_horizontal_loop:

li $v0, 11

li $a0, ‘ ‘

syscalladdi $t1, $t1, -1

bgtz $t1, draw_ball_horizontal_loop

li $v0, 11

li $a0, ‘o’

syscall# New lineli $v0, 11li $a0, ‘\n’syscall

# Draw the paddle

lw $t1, PADDLE_Y

draw_paddle_vertical_loop:

li $v0, 11li $a0, ‘\n’syscalladdi $t1, $t1, -1

bgtz $t1, draw_paddle_vertical_loop

lw $t1, paddle_x

draw_paddle_horizontal_loop:

li $v0, 11li $a0, ‘ ‘syscalladdi $t1, $t1, -1

bgtz $t1, draw_paddle_horizontal_loop

lw $t1, PADDLE_WIDTH

draw_paddle_width_loop:

li $v0, 11

li $a0, ‘W’

syscalladdi $t1, $t1, -1

bgtz $t1, draw_paddle_width_loop

# New lineli $v0, 11li $a0, ‘\n’syscall

# Restore registers

and return

lw $ra, 8($sp)

lw $s0, 4($sp)

lw $s1, 0($sp)

addi $sp, $sp, 12

jr $ra

.text

# Procedure: update_ball_position

# Updates the ball’s position and velocity.

update_ball_position:

# Save registers

addi $sp, $sp, -8

sw $ra, 4($sp)

sw $s0, 0($sp)

# Update ball_x

lw $t0, ball_x

lw $t1, ball_velocity_x

add $t0, $t0, $t1

sw $t0, ball_x

# Update ball_y

lw $t0, ball_y

lw $t1, ball_velocity_y

add $t0, $t0, $t1

sw $t0, ball_y

# Restore registers and return

lw $ra, 4($sp)

lw $s0, 0($sp)

addi $sp, $sp, 8

jr $ra.text

# Procedure: check_collisions

# Checks for collisions between the ball and the walls, paddle, and holes.

check_collisions:

# Save registersaddi $sp, $sp, -12sw $ra, 8($sp)sw $s0, 4($sp)sw $s1, 0($sp)

# Load constants and variables

lw $s0, SCREEN_WIDTHlw $s1, SCREEN_HEIGHTlw $t0, ball_xlw $t1, ball_y

lw $t2, ball_velocity_x

lw $t3, ball_velocity_y

lw $t4, paddle_x

lw $t5, PADDLE_Y

lw $t6, LEFT_HOLE_X

lw $t7, RIGHT_HOLE_X

lw $t8, HOLES_Y

# Check for wall collisions (left and right)

beq $t0, 0, reverse_velocity_x

sub $t9, $s0, 1

beq $t0, $t9, reverse_velocity_x

# Check for ceiling collision

beq $t1, 0, reverse_velocity_y

# Check for paddle collision

beq $t1, $t5, check_paddle_collision

j continue_checks

check_paddle_collision:

blt $t0, $t4, continue_checks

lw $t9, PADDLE_WIDTH

# Load the PADDLE_WIDTH value into the register $t9

add $t9, $t4, $t9

blt $t0, $t9, reverse_velocity_y

continue_checks:

# Check for hole collisions

beq $t0, $t6, check_hole_collision

beq $t0, $t7, check_hole_collision

j end_check_collisions

check_hole_collision:

beq $t1, $t8, reverse_velocity_x

reverse_velocity_x:

neg $t2, $t2

sw $t2, ball_velocity_x

j end_check_collisions

reverse_velocity_y:

neg $t3, $t3

sw $t3, ball_velocity_y

end_check_collisions:

# Restore registers and returnlw $ra, 8($sp)lw $s0, 4($sp)lw $s1, 0($sp)addi $sp, $sp, 12jr $ra.text

handle_input:

# Save registersaddi $sp, $sp, -8sw $ra, 4($sp)sw $s0, 0($sp)

# Read user input

jal read_char

move $t0, $v0

# Check if input is ‘q’ for quitting

li $t1, ‘q’

beq $t0, $t1, exit_game

# Check if input is the left arrow key (assuming 75 as left arrow key code)

li $t1, ‘a’

bne $t0, $t1, check_right_arrow

lw $t2, paddle_x

bgtz $t2, move_paddle_left

j end_handle_input

.text

# Procedure: read_char

# Reads a single character from the input.

read_char:

# Read character using syscall

li $v0, 12

syscall

# Save the read character to $v0

move $v0, $a0

# Return

jr $ra

# Handles user input for moving the paddle left or right.

exit_game:

# Restore registerslw $ra, 4($sp)lw $s0, 0($sp)addi $sp, $sp, 8

# Exit the game using syscall

li $v0, 10

syscall

check_right_arrow:

# Check if input is the right arrow key (assuming 77 as right arrow key code)

li $t1, ‘d’

bne $t0, $t1, end_handle_input

lw $t2, paddle_x

lw $t3, SCREEN_WIDTH

lw $t9, PADDLE_WIDTH

sub $t3, $t3, $t9

blt $t2, $t3, move_paddle_right

j end_handle_input

move_paddle_left:

li $t3, 10

sub $t2, $t2, $t3

sw $t2, paddle_x

j end_handle_input

move_paddle_right:

li $t3, 10

add $t2, $t2, $t3

sw $t2, paddle_x

end_handle_input:

# Restore registers and returnlw $ra, 4($sp)lw $s0, 0($sp)addi $sp, $sp, 8jr $ra

clear_screen:

# Save return address

addi $sp, $sp, -4

sw $ra, 0($sp)

# Print a sufficient number of newline characters

li $t0, 25# Adjust this value based on the desired number of lines

clear_screen_loop:

li $v0, 11li $a0, ‘\n’syscall

addi $t0, $t0, -1

bgtz $t0, clear_screen_loop

# Restore return address and return

lw $ra, 0($sp)

addi $sp, $sp, 4

jr $ra

main:

# Clear the screen

jal clear_screen

# Draw the game components

jal draw_components

# Check for user input

jal handle_input

# Update ball position

jal update_ball_position

# Check for collisions

jal check_collisions

# Add a delay between frames

li $t0, 500000

delay_loop:

addi $t0, $t0, -1

bgtz $t0, delay_loop

# Loop

j main

handle_unexpected_syscall:

# Print an error message

li $v0, 4

la $a0, unexpected_syscall_msg

syscall# Exit the game using syscallli $v0, 10syscall.data

unexpected_syscall_msg: .asciiz “Error: An unexpected syscall occurred.\n”

exit:

# Exit the game using syscallli $v0, 10syscall

.globl getch

getch:

li $v0, 5

syscall

jr $ra

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER