-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitmap2.asm
More file actions
162 lines (102 loc) · 2.58 KB
/
bitmap2.asm
File metadata and controls
162 lines (102 loc) · 2.58 KB
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
#bitmap settings: 2by2 unit size, 512 by 512 display size
.data
newLine: .asciiz "\n"
invalidMessage: .asciiz "INVALID MOVE"
heightMap: .word 0x05050505, 0x00050505
board: .space 48
yellowColor: .word 0xfed700
redColor: .word 0x00ffffff
white: .word 0x00ffffff
black: .word 0x00000000
displayAddress:.word 0x10008000 # base address of the display
.include "macros.asm"
.text
main:
lw $t0, displayAddress # $t0 stores the base address for display
li $t1, 0xfed700 # $t1 stores the yellow chip color
li $t2, 0xff00000 # $t2 stores the red chip color
li $t3, 0x0020fb # $t3 stores the primary color of the board
li $s0, 0x00000000
li $t4, 0 #units in the row counter
li $t5, 224 #max units in the row
li $t6, 0 #row counter
li $t7, 192 #number of rows
addi $t0, $t0, 32832 #(32 rows * 256 units * 4) + (16 units of left padding * 4)
makeRow:
sw $t3, ($t0)
addi $t0, $t0, 4
addi $t4, $t4, 1
bne $t4, $t5, makeRow
addi $t6, $t6, 1
addi $t0, $t0, 128 #(32 units of right and left padding * 4)
li $t4, 0
bne $t6, $t7, makeRow
li $t4, 0 # circles in a row incrementer
li $t5, 7 # maximum circles in the row
li $t6, -1 # number of rows of circles
li $t7, 6 # maximum rows of circles
markPoints:
move $a0, $t4
move $a1, $t6
move $a3, $s0
jal makeCircle
addi $t4, $t4, 1
bne $t4, $t5, markPoints
addi $t6, $t6, 1
li $t4, 0
bne $t6, $t7, markPoints
li $s3, 7
li $s0, 0xffff0000
gameLoop:
lw $s1, ($s0)
beq $s1, $zero, checkAgain
li $s6, -1
li $s7, 6
lw $s2, 4($s0)
subi $s2, $s2, 49
blt $s2, $zero, invalidMove #invalid character Checking
bgt $s2, $s7, invalidMove #invalid character Checking
lb $s5, heightMap($s2) #holds the current height of the column
beq $s5, $s6, invalidMove #if theres too many chips, then it just goes back to game loop
save()
move $a0, $s2
li $a1, 1
jal set_board
restor()
li $v0, 0
jal win
bne $v0, $zero, userWin
save()
jal printBoard
restor()
jal opps
li $v0, 0
jal win
bne $v0, $zero, userLose
save
jal checkDraw
restor
li $a0, 2
li $v0, 32
li $a0, 60
li $a1, 300
li $a2, 104
li $a3, 127
li $v0, 33
syscall
li $a0, 67
li $a1, 300
li $a2, 104
li $a3, 127
li $v0, 33
syscall
# end of user move
checkAgain:
j gameLoop
Exit:
li $v0, 10 # terminate the program gracefully
syscall
.include "graphics.asm"
.include "sounds.asm"
.include "logic2.asm"
.include "render.asm"