-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawscoreiconasm
273 lines (223 loc) · 6.15 KB
/
drawscoreiconasm
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# 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
.data
ggsMessage: .word 0,0
obstacle: .word 0, 0 #x, y coordinates of the obstacle
game: .word 18, 4 # x,y coordinates of the top right of the word "game"
over: .word 28, 10 # x,y coordinates of the top right of the word "end"
score: .word 23, 16 # x,y coordinates of the top right of the word "score"
symbol_1: .word 6, 23 # x, y coordinates for the score
symbol_2: .word 12, 23
symbol_3: .word 18, 23
symbol_4: .word 24, 23
symbol_5: .word 30, 23
.text
gameOverPhase:
addi $t0, $zero, 76
addi $t1, $zero, 15
ble $t0, $t1, bye
jal drawSymbol_1
addi $t1, $zero, 30
ble $t0, $t1, bye
jal drawSymbol_2
addi $t1, $zero, 45
ble $t0, $t1, bye
jal drawSymbol_3
addi $t1, $zero, 60
ble $t0, $t1, bye
jal drawSymbol_4
addi $t1, $zero, 75
ble $t0, $t1, bye
jal drawSymbol_5
j bye
bye:
j end
addi $0, $0, 0
# draw reset
drawSymbol_1:
la $s0, red # $s0 has the green colour
la $s6, yellow
la $s1, baseAddress # $t1 has the base address
la $s2, symbol_1 # $t2 holds the top right corner of the word "score"
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, -8($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, 0($s5)
sw $s6, -4($s5)
sw $s0, -8($s5)
sw $s6, -12($s5)
sw $s0, -16($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -8($s5)
jr $ra
drawSymbol_2:
la $s0, red # $s0 has the green colour
la $s6, yellow
la $s1, baseAddress # $t1 has the base address
la $s2, symbol_2 # $t2 holds the top right corner of the word "score"
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, -8($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, 0($s5)
sw $s6, -4($s5)
sw $s0, -8($s5)
sw $s6, -12($s5)
sw $s0, -16($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -8($s5)
jr $ra
drawSymbol_3:
la $s0, red # $s0 has the green colour
la $s6, yellow
la $s1, baseAddress # $t1 has the base address
la $s2, symbol_3 # $t2 holds the top right corner of the word "score"
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, -8($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, 0($s5)
sw $s6, -4($s5)
sw $s0, -8($s5)
sw $s6, -12($s5)
sw $s0, -16($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -8($s5)
jr $ra
drawSymbol_4:
la $s0, red # $s0 has the green colour
la $s6, yellow
la $s1, baseAddress # $t1 has the base address
la $s2, symbol_4 # $t2 holds the top right corner of the word "score"
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, -8($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, 0($s5)
sw $s6, -4($s5)
sw $s0, -8($s5)
sw $s6, -12($s5)
sw $s0, -16($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -8($s5)
jr $ra
drawSymbol_5:
la $s0, red # $s0 has the green colour
la $s6, yellow
la $s1, baseAddress # $t1 has the base address
la $s2, symbol_5 # $t2 holds the top right corner of the word "score"
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, -8($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, 0($s5)
sw $s6, -4($s5)
sw $s0, -8($s5)
sw $s6, -12($s5)
sw $s0, -16($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -4($s5)
sw $s6, -8($s5)
sw $s0, -12($s5)
#set to next row, rightmost pixel
addi $s5, $s5, 128
sw $s0, -8($s5)
jr $ra
end:
# gracefully terminate the program
li $v0, 10
syscall