-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTitleScreen.asm
54 lines (43 loc) · 1.34 KB
/
TitleScreen.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This file contains the functionality
# of the title screen of the Reversi
# game application
.text
.globl getMainMenu
getMainMenu:
#method: Save the return address
move $a0, $ra
jal saveReturnAdd
#output: Print the main title screen
la $a0, str_MainTitle
li $v0, 4
syscall
#output: Print the user prompt
la $a0, str_mainPrompt
la $a1, str_mainSubtitle
jal renderPrompt
get_menu_choice:
#input: Get the users choise
li $v0, 5
syscall
sw $v0, int_buffer
#method: validate the input
move $a0, $v0
li $a1, 1
li $a2, 2
jal checkIntRange
#condition: If the input is invalid, ask again
bnez $v0, valid_menu_choice
la $a0, str_mainSubtitle
jal renderError
j get_menu_choice
valid_menu_choice:
#method: Return the user input
lw $v0, int_buffer
#method: Reload the return address
jal loadReturnAdd
jr $ra
.data
str_MainTitle: .asciiz "------------------------\n|**********************|\n|****** *****|\n|****** Reversi *****|\n|****** *****|\n|**********************|\n| |\n| A Game Of Strategy |\n| By The Forsaken Four |\n| |\n------------------------\n"
str_mainPrompt: .asciiz "MAIN MENU"
str_mainSubtitle: .asciiz "Welcome! Please choose from the following options.\n1. Play 'Reversi'\n2. Exit the application\n\n[INPUT]: "
int_buffer: .word 0