-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartscreen.asm
251 lines (236 loc) · 6.09 KB
/
startscreen.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# Bitmap Display Configuration:
# - Unit width in pixels: 8
# - Unit height in pixels: 8
# - Display width in pixels: 256
# - Display height in pixels: 256
# - Base Address for Display: 0x10008000 ($gp)
#
# WARNING: THERE WILL BE CONFLICT AS THE DRAW ENEMY IS DIFF THAN FOR THE MOVE ENEMY'S VERSION OF DRAW ENEMY
#
.eqv lightBrown 0xa0522d
.eqv darkBrown 0x654321
.eqv red 0xff0000
.eqv green 0x00ff00
.eqv baseAddress 0x10008000
.eqv yellow 0xffff00
.eqv grey 0x808080
.eqv white 0xffffff
.eqv black 0x000000
.data
ggsMessage: .word 0,0
obstacle: .word 0, 0 #x, y coordinates of the obstacle
start: .word 25, 9 # x,y coordinates of the top right of the word "start"
s_game: .word 23, 15 # x,y coordinates of the top right of the word "game"
ship: .word 6, 11 #x, y coordinates of the top right corner of the ship and then the y coordinates of the left and right wing.
.text
startGamePhase:
jal drawStartGame
jal animateShip
addi $0, $0, 0
animateShip:
la $t0, ship
lw $t1, 0($t0)
beq $t1, 31, end
la $t0, grey # load the grey colour
addi, $sp, $sp, -4 # move stack up
sw $t0, 0($sp) # store white into the stack
la $t0, white # load the white colour
addi, $sp, $sp, -4 # move stack up
sw $t0, 0($sp) # store white into the stack
jal drawShip
li $v0,32
li $a0,50
syscall
jal clearShip
la $t0, ship
lw $t1, 0($t0)
addi $t1, $t1, 1
sw $t1, 0($t0)
j animateShip
#bye:
# j end
# addi $0, $0, 0
# draw reset
drawShip:
lw $s0, 0($sp) # load the white color into $s0
addi $sp, $sp, 4 # move stack down
lw $s1, 0($sp) # load the white color into $s1
addi $sp, $sp, 4 # move stack down
la $s2, ship # $s2 load the top right corner of the ship
lw $s3, 0($s2) # $s3 has the x coordinate
lw $s4, 4($s2) # $s4 holds the y coordinate
sll $s4, $s4, 5 # $s4 holds y * 32
add $s4, $s4, $s3 # $s4 holds y * 32 + x
sll $s4, $s4, 2 # $s4 holds 4 * (y * 32 + x)
add $s5, $s4, $zero
la $s5, baseAddress
add $s5, $s5, $s4
sw $s0, -8($s5)
addi $s5, $s5, 128 # move to next row
sw $s0, -8($s5)
sw $s0, -12($s5)
addi $s5, $s5, 128 # move to next row
sw $s0, -4($s5)
sw $s0, -8($s5)
sw $s0, -12($s5)
sw $s0, -16($s5)
sw $s0, -24($s5)
addi $s5, $s5, 128 # move to next row
sw $s0, 0($s5)
sw $s0, -4($s5)
sw $s1, -8($s5)
sw $s1, -12($s5)
sw $s0, -16($s5)
sw $s0, -20($s5)
sw $s0, -24($s5)
addi $s5, $s5, 128 # move to next row
sw $s0, -4($s5)
sw $s0, -8($s5)
sw $s0, -12($s5)
sw $s0, -16($s5)
sw $s0, -24($s5)
addi $s5, $s5, 128 # move to next row
sw $s0, -8($s5)
sw $s0, -12($s5)
addi $s5, $s5, 128 # move to next row
sw $s0, -8($s5)
jr $ra
addi $0, $0, 0
clearShip:
addi $sp, $sp, -4 # move stack up
sw $ra, 0($sp)
la $s0, black # load the black colour
addi, $sp, $sp, -4 # move stack up
sw $s0, 0($sp) # store white into the stack
addi, $sp, $sp, -4 # move stack up
sw $s0, 0($sp) # store white into the stack
jal drawShip
addi $0, $0, 0
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
addi $0, $0, 0
drawStartGame:
la $s0, green # load the red colour into $s0
la $s1, baseAddress # $s1 has the base address
la $s2, start # $s2 holds the top right corner of the word "game"
lw $s3, 0($s2) # $s3 holds the x coordinate
lw $s4, 4($s2) # $s4 holds the y coordinate
sll $s4, $s4, 5 # $s4 holds y coordinate * 32
add $s4, $s4, $s3 # $s4 holds 32*y + x
sll $s4, $s4, 2 # $s4 holds 4*(32*y + x)
la $s5, baseAddress # $s5 has the base address
add $s5, $s5, $s4 # $s5 holds displayAddress + 4*(32*y + x)
sw $s0, 0($s5)#first row of the word game
sw $s0, -4($s5)
sw $s0, -8($s5)
sw $s0, -16($s5)
sw $s0, -20($s5)
sw $s0, -24($s5)
sw $s0, -36($s5)
sw $s0, -48($s5)
sw $s0, -52($s5)
sw $s0, -56($s5)
sw $s0, -64($s5)
sw $s0, -68($s5)
sw $s0, -72($s5)
addi $s5, $s5, 128 #set to next row, rightmost pixel
sw $s0, -4($s5)
sw $s0, -16($s5)
sw $s0, -24($s5)
sw $s0, -32($s5)
sw $s0, -40($s5)
sw $s0, -52($s5)
sw $s0, -72($s5)
addi $s5, $s5, 128 #set to next row, rightmost pixel
sw $s0, -4($s5)
sw $s0, -16($s5)
sw $s0, -20($s5)
sw $s0, -24($s5)
sw $s0, -32($s5)
sw $s0, -36($s5)
sw $s0, -40($s5)
sw $s0, -52($s5)
sw $s0, -64($s5)
sw $s0, -68($s5)
sw $s0, -72($s5)
addi $s5, $s5, 128 #set to next row, rightmost pixel
sw $s0, -4($s5) #fourth row
sw $s0, -20($s5)
sw $s0, -24($s5)
sw $s0, -32($s5)
sw $s0, -40($s5)
sw $s0, -52($s5)
sw $s0, -64($s5)
addi $s5, $s5, 128 #set to next row, rightmost pixel
sw $s0, -4($s5)
sw $s0, -16($s5)
sw $s0, -24($s5)
sw $s0, -32($s5)
sw $s0, -40($s5)
sw $s0, -52($s5)
sw $s0, -64($s5)
sw $s0, -68($s5)
sw $s0, -72($s5)
la $s0, green # load the red colour into $s0
la $s1, baseAddress # $s1 has the base address
la $s2, s_game # $s2 holds the top right corner of the word "game"
lw $s3, 0($s2) # $s3 holds the x coordinate
lw $s4, 4($s2) # $s4 holds the y coordinate
sll $s4, $s4, 5 # $s4 holds y coordinate * 32
add $s4, $s4, $s3 # $s4 holds 32*y + x
sll $s4, $s4, 2 # $s4 holds 4*(32*y + x)
la $s5, baseAddress # $s5 has the base address
add $s5, $s5, $s4 # $s5 holds displayAddress + 4*(32*y + x)
sw $s0, 0($s5)#first row of the word game
sw $s0, -4($s5)
sw $s0, -16($s5)
sw $s0, -20($s5)
sw $s0, -24($s5)
sw $s0, -40($s5)
sw $s0, -52($s5)
sw $s0, -56($s5)
sw $s0, -60($s5)
addi $s5, $s5, 128 #set to next row, rightmost pixel
sw $s0, -4($s5) #second row
sw $s0, -12($s5)
sw $s0, -20($s5)
sw $s0, -28($s5)
sw $s0, -36($s5)
sw $s0, -44($s5)
sw $s0, -60($s5)
addi $s5, $s5, 128 #set to next row, rightmost pixel
sw $s0, -0($s5) #third row
sw $s0, -4($s5)
sw $s0, -12($s5)
sw $s0, -20($s5)
sw $s0, -28($s5)
sw $s0, -36($s5)
sw $s0, -40($s5)
sw $s0, -44($s5)
sw $s0, -52($s5)
sw $s0, -60($s5)
addi $s5, $s5, 128 #set to next row, rightmost pixel
sw $s0, -4($s5) #fourth row
sw $s0, -12($s5)
sw $s0, -20($s5)
sw $s0, -28($s5)
sw $s0, -36($s5)
sw $s0, -44($s5)
sw $s0, -52($s5)
sw $s0, -60($s5)
addi $s5, $s5, 128 #set to next row, rightmost pixel
sw $s0, -0($s5) #fifth row
sw $s0, -4($s5)
sw $s0, -12($s5)
sw $s0, -20($s5)
sw $s0, -28($s5)
sw $s0, -36($s5)
sw $s0, -44($s5)
sw $s0, -52($s5)
sw $s0, -56($s5)
sw $s0, -60($s5)
jr $ra
end:
li $v0, 10
syscall