OpenCores
URL https://opencores.org/ocsvn/diogenes/diogenes/trunk

Subversion Repositories diogenes

[/] [diogenes/] [trunk/] [video/] [snake3.asm] - Blame information for rev 236

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 200 fellnhofer
@ l7: stack
2
@ l6: push_function
3
@ l0: return address of leavfuction (push pop im speziell)
4
 
5
  stio l0, [l0]
6
 
7
  LDL l0, :start
8
  LDL l6, :push
9
 
10
  ldi l7, 0x03
11
  jump 
12
  lsi l7, 0xff
13
 
14
 
15
push:
16
  st  h0, [l7]
17
  adi l7, -1
18
  st  h1, [l7]
19
  adi l7, -1
20
  st  h2, [l7]
21
  adi l7, -1
22
  st  h3, [l7]
23
  adi l7, -1
24
  st  h4, [l7]
25
  adi l7, -1
26
  st  h5, [l7]
27
  adi l7, -1
28
  st  h6, [l7]
29
  adi l7, -1
30
  st  h7, [l7]
31
  jump 
32
  adi l7, -1
33
 
34
pop:
35
  adi l7, 1
36
  ld  h7, [l7]
37
  adi l7, 1
38
  ld  h6, [l7]
39
  adi l7, 1
40
  ld  h5, [l7]
41
  adi l7, 1
42
  ld  h4, [l7]
43
  adi l7, 1
44
  ld  h3, [l7]
45
  adi l7, 1
46
  ld  h2, [l7]
47
  adi l7, 1
48
  ld  h1, [l7]
49
  adi l7, 1
50
  ld  h0, [l7]
51
  nop
52
  nop
53
  jump 
54
  nop
55
 
56
 
57
start:
58
 
59
@ initialize snake
60
  ldi   h1, 8
61
l0:
62
  st    h1, [h1]
63
  brnz  h1, :l0
64
  adi   h1, -1
65
 
66
  ldi   h1, 4
67
  ldi   h2, 0
68
 
69
 
70
@ initialize vmem
71
  LDL   h4, :set_tile
72
  ldi   l3, 59     @ max y
73
hloop:
74
  ldi   l2, 79     @ max x
75
pixloop:
76
  call  h0, 

77
  ldi   l1, 0x6b     @ white=0x7f  (black = 6b)
78
 
79
  brnz  l2, :pixloop
80
  adi   l2, -1
81
  brnz  l3, :hloop
82
  adi   l3, -1
83
 
84
  LDL   h3, :delay
85
  LDL   h5, :update
86
loop:
87
  call  h0, 

@ call delay

88
  ldi   l1, 20         @ 2^20 steps
89
 
90
  ldi   l1, 0x01
91
  and   l2, l0, l1     @ select bit for right
92
  sub   h2, h2, l2     @ add bit to direction
93
  shi   l0, -1         @ shift input
94
  and   l2, l0, l1
95
  add   h2, h2, l2     @ add bit to direction
96
  stio  h2, [l0]
97
 
98
  shi   l0, -6         @ shift input
99
  and   h4, l0, l1
100
 
101
  call h0, 
@ call update
102
  mov  l1, h2
103
 
104
  add   h1, h1, h4
105
 
106
  brnz  h5, :loop
107
  nop
108
 
109
 
110
update:
111
  call l0, 
112
  nop
113
 
114
  brz   h4, :no_grow    @ if snake does not grow
115
  mov   l0, h1
116
  adi   l0, 2
117
  adi   h1, 1
118
  ld    l1, [h1]        @ if snake grows
119
  brnz  h4, :cloope
120
  mov   l2, h1
121
 
122
no_grow:
123
  ldi   l0, 0
124
  ld    l1, [l0]
125
 
126
  @ extract tile,y,x  (l1=tile, l2=x, l3=y)
127
  ldi   l4, 0xff
128
  and   l2, l1, l4
129
  shi   l1, -8
130
  and   l3, l1, l4
131
  ldi   l1, 0x6b
132
 
133
  LDL   l0, :set_tile
134
  call  h0, 
135
  nop
136
 
137
  ldi   l0, 0
138
  ldi   l2, 1
139
 
140
cloop:
141
  ld    l1, [l2]      @ src
142
  adi   l2, 1         @ src + 1
143
  st    l1, [l0]      @ dst
144
  cmpl  l3, l0, h1    @ until dst=highest address)
145
  brnz  l3, :cloop
146
  adi   l0, 1         @ dst + 1
147
cloope:
148
 
149
  ldi   l5, 3
150
  and   h2, h2, l5    @ trunc direction
151
 
152
  @ extract tile,y,x  (l1=tile, l2=x, l3=y)
153
  ldi   l4, 0xff
154
  and   l2, l1, l4
155
  shi   l1, -8
156
  and   l3, l1, l4
157
 
158
  shi   l1, -8        @ old direction
159
  shi   l1, 4         @ old direction << 2
160
  or    l1, l1, h2    @  00OO 00NN (old new combination)
161
  adi   l1, 4
162
 
163
  mov   h5, l0
164
  mov   h6, l2
165
  mov   h7, l3
166
 
167
  LDL   l4, :set_tile
168
  call  h0, 
169
  nop
170
  mov   l0, h5
171
  mov   l2, h6
172
  mov   l3, h7
173
 
174
down:
175
  xor   l4, h2, l5
176
  brnz  l4, :up
177
  nop
178
  adi   l3, 1
179
  ldi   l1, 8
180
up:
181
  ldi   l5, 1
182
  xor   l4, h2, l5
183
  brnz  l4, :right
184
  nop
185
  adi   l3, -1
186
  ldi   l1, 9
187
right:
188
  brnz  h2, :left
189
  ldi   l5, 2
190
  adi   l2, 1
191
  ldi   l1, 10
192
left:
193
  xor   l4, h2, l5
194
  brnz  l4, :end_key
195
  nop
196
  adi   l2, -1
197
  ldi   l1, 11
198
end_key:
199
 
200
  mov   l4, h2
201
  shi   l4, 8
202
  or    l4, l4, l3
203
  shi   l4, 8
204
  or    l4, l4, l2
205
  st    l4, [l0]       @ write new head
206
 
207
  LDL   l0, :set_tile
208
  call  h0, 
209
  nop
210
 
211
  ldi   l0, 0
212
  ld    l1, [l0]
213
  @ extract tail tile,y,x  (l1=tile, l2=x, l3=y)
214
  ldi   l4, 0xff
215
  and   l2, l1, l4
216
  shi   l1, -8
217
  and   l3, l1, l4
218
  ldi   l0, 1
219
  ld    l1, [l0]
220
  nop
221
  shi   l1, -16        @ old direction
222
  adi   l1, 0x0c
223
 
224
  LDL   l0, :set_tile
225
  call  h0, 
226
  nop
227
 
228
  adi  h6, l6, 17
229
  jump 
230
  nop
231
 
232
 
233
set_stile:
234
  call l0, 
235
  nop
236
 
237
  ldi  l0, 0xff
238
  and  l2, l1, l0
239
  shi  l1, -8
240
  and  l3, l1, l0
241
 
242
  LDL  h4, :set_tile
243
  call h0, 

244
  shi  l1, -8
245
 
246
  adi  h6, l6, 17
247
  jump 
248
  nop
249
 
250
 
251
set_tile:
252
  call l0, 
253
  nop
254
 
255
  ldi   l4, 0xc0   @ vmem starts at 0xc000
256
  shi   l4, 8
257
 
258
  shi   h3, l3, 7
259
  add   l0, l2, h3
260
  add   l0, l0, l4
261
  stio  l1, [l0]
262
 
263
  adi  h6, l6, 17
264
  jump 
265
  nop
266
 
267
delay:
268
  call l0, 
269
  nop
270
  ldi   l2, 1
271
  sh    l2, l2, l1
272
  ldi   l4, 0xff
273
  shi   l4, 10
274
  ldi   l1, 0
275
  ldi   l0, 0
276
delay_loop:
277
  ldio  l3, [l1]
278
  ldi   l5, 0x0B              @ filter left, right, switch
279
  and   l3, l3, l5
280
  brz   l3, :goon
281
  nop
282
  brnz  l4, :goon
283
  adi   l4, -1
284
  mov   l0, l3
285
goon:
286
  brnz  l2, :delay_loop
287
  adi   l2, -1
288
 
289
  adi  h6, l6, 17
290
  jump 
291
  nop
292
 
293
 
294
stop
295
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.