This repository has been archived by the owner on Jul 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaScreenAnimations.s
240 lines (214 loc) · 5.08 KB
/
aScreenAnimations.s
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
.equ SCREEN_WIDTH, 640
.equ SCREEN_HEIGH, 480
.data
WHITE: .word 0xFFFFFF
.globl animationTest
// NOTE Animation Test
animationTest:
sub sp, sp, #8
stur x30, [sp, #0] // Guardamos el return pointer en memoria
mov x18, xzr // Empieza en negro
antestloop:
bl paintScreen // Pinta la pantalla
bl delay
add x18, x18, #1
mov x8, WHITE
cmp x18, x8
b.ne antestloop
ldur x30, [sp, #0] // Guardamos el return pointer en memoria ret
add sp, sp, #8
ret
.globl circleAnimation1
// NOTE circle Animation 1
circleAnimation1:
sub sp, sp, #8
stur x30, [sp, #0] // Guardamos el return pointer en memoria
mov x21, 320
mov x22, 240
mov x23, 10 // x23 = Radio
mov x24, 30 // x24 = Color
// circloop1...
circloop1:
mov x13, x24 // R
mov x14, 10 // G
mov x15, x24 // B
bl setColour // R+G+B = Naranja
bl doCircle
add x23, x23, #1 // r++
bl doCircle
bl delay
add x23, x23, #2 // r++
mov x8, #255
cmp x24, x8
b.eq circlend
add x24, x24, #1 // colour++
b circloop1
circlend:
ldur x30, [sp, #0] // Guardamos el return pointer en memoria ret
add sp, sp, #8
ret
.globl circleAnimation2
// NOTE circle Animation 2
circleAnimation2:
sub sp, sp, #8
stur x30, [sp, #0] // Guardamos el return pointer en memoria
mov x21, 320
mov x22, 240
mov x23, 10 // x23 = Radio
mov x24, 30 // x24 = Color
// circloop2...
circ2loop1:
mov x13, x24 // R
mov x14, 10 // G
mov x15, 10 // B
bl setColour // R+G+B = Naranja
bl doCircle
add x23, x23, #1 // r++
bl doCircle
add x23, x23, #1 // r++
bl doCircle
bl delay
add x23, x23, #1 // r++
mov x8, #255
cmp x24, x8
b.eq circ2lend
add x24, x24, #1 // colour++
b circ2loop1
circ2lend:
ldur x30, [sp, #0] // Guardamos el return pointer en memoria ret
add sp, sp, #8
ret
// BL sobreescribe el registro x30 y RET lee el registro x30 //
// BL (Break and link -> funciones) es para salto incondicional, cambia el program counter y cambia el registro x30 //
// B (Break dentro de funciones) es para saltos condicionales cambia el program counter //
.globl cleanScreen
// NOTE cleanScreen
cleanScreen: // Pinta toda la pantalla de negro
sub sp, sp, #16
stur lr, [sp] // Guardo el link register para no pisarlo
stur x30, [sp, #8] // Guardamos el return pointer en memoria
mov x13, xzr // R
mov x14, xzr // G
mov x15, xzr // B
bl setColour // Negro
bl paintScreen
ldur x30, [sp, #8] // Guardamos el return pointer en memoria ret
ldur lr, [sp] // Devuelvo el link register
add sp, sp, #16
ret
.globl cleanScreenBuffer
// NOTE cleanScreenBuffer
cleanScreenBuffer: // Pinta toda la pantalla de negro
sub sp, sp, #16
stur lr, [sp] // Guardo el link register para no pisarlo
stur x30, [sp, #8] // Guardamos el return pointer en memoria
mov x13, xzr // R
mov x14, xzr // G
mov x15, xzr // B
bl setColour // Negro
bl paintScreenBuffer
ldur x30, [sp, #8] // Guardamos el return pointer en memoria ret
ldur lr, [sp] // Devuelvo el link register
add sp, sp, #16
ret
.globl paintScreenBuffer
// NOTE paintScreenBuffer
paintScreenBuffer: // 320w 240h -> 76800 + 240
// Return -> nada
// Args: x18 Colour
mov x0, x20 // Origen del frameBuffer
mov x8, SCREEN_WIDTH
mov x9, SCREEN_HEIGH
mul x8, x8, x9 // x8 contador de pixeles a pintar
// paintScreenBufferLoop...
paintScreenBufferLoop:
stur w18, [x0] // Set color of pixel N
add x0, x0, 4 // Next pixel
sub x8, x8, 1 // decrement pixel counter
cbnz x8, paintScreenBufferLoop // If not end row jump
ret
.globl paintScreen
// NOTE paintScreen
paintScreen: // 320w 240h -> 76800 + 240
// Return -> nada
// Args: x18 Colour
adr x28, PreFrameBuffer // Origen del frameBuffer
mov x8, SCREEN_WIDTH
mov x9, SCREEN_HEIGH
mul x8, x8, x9 // x8 contador de pixeles a pintar
// paintScreenLoop...
paintScreenLoop:
stur w18, [x28] // Set color of pixel N
add x28, x28, 4 // Next pixel
sub x8, x8, 1 // decrement pixel counter
cbnz x8, paintScreenLoop // If not end row jump
ret
// TODO revisar
/*
drawBorder:
// Args
// x18 colour
sub sp, sp, #8 // Guardo el link register para no sobreescribirlo
stur lr, [sp]
mov x16, 0 // Guardo la posicion en x a la que quiero llegar
mov x12, SCREEN_HEIGH // Guardo la posicion y donde quiero llegar
bl setPixel
ldur x9, [x0]
mov x16, SCREEN_WIDTH
mov x12, SCREEN_HEIGH
bl setPixel
stur x18, [x0]
drawLeft:
bl setPixel
stur x18, [x0]
sub x16, x16, #1
cmp x9, x0
b.eq preDrawUp
b drawLeft
preDrawUp:
mov x9, #0
drawUp:
bl setPixel
stur x18, [x0]
sub x12, x12, #1
cmp x9, x0
b.eq preDrawRight
b drawUp
preDrawRight:
mov x12, #0
mov x16, SCREEN_WIDTH
bl setPixel
ldur x9, [x0]
drawRight:
bl setPixel
stur x18, [x0]
sub x16, x16, #1
cmp x9, x0
b.eq preDrawDown
b drawRight
preDrawDown:
mov x12, SCREEN_HEIGH
mov x16, SCREEN_WIDTH
bl setPixel
ldur x9, [x0]
drawDown:
bl setPixel
stur x18, [x0]
add x12, x12, #1
cmp x9, x0
b.eq endBorder
b drawDown
endBorder:
ldur lr, [sp]
add sp, sp, #8
ret
*/
/*
endDraw:
// TODO
borderLoop:
// TODO Hacer
b borderLoop
borderEnd:
// TODO
*/