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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
'The MIT License (MIT)
'Copyright (c) 2019 Chipnetics Computing (www.chipnetics.com)
'Permission is hereby granted, free of charge, to any person obtaining a copy of
'this software and associated documentation files (the "Software"), to deal in
'the Software without restriction, including without limitation the rights to
'use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
'the Software, and to permit persons to whom the Software is furnished to do so,
'subject to the following conditions:
'The above copyright notice and this permission notice shall be included in all
'copies or substantial portions of the Software.
'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
'IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
'FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
'COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
'IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
'CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
$regfile = "attiny2313.DAT"
$hwstack = 40
$swstack = 20
$framesize = 24
$crystal = 20000000
Config Timer0 = Timer , Prescale = 8
On Timer0 Frame2
Enable Interrupts
Dim Linecount As Word
Dim Drawing As Word
Dim Count As Byte
Dim X As Bit
Const Red = 12
Const Green = 10
Const Blue = 9
Const Yellow = 14
Const Magenta = 13
Const Lblue = 11
Const White = 15
Const Black = 8
'DDRx - Port X Data Direction Register
'Writing 1 in the pin location makes output pin. 0 makes input pin
'Data Direction Register. 0 = Input, 1 = Output
Ddrb = &B00000100 ' B2 is the LED
Ddrd = &B11111111
'PINx - Port X Input Pins Register (READING)
'To READ the values on the pins of PortX you read the values that are on the pin
'register.
'PORTx - Port X Data Register. (OUTPUTTING)
'Stores logic values currently being OUTPUTTED on the physical pinds of PORTx
Portb = &B00000101
Selector Alias Pinb.0
Led Alias Portb.2
Video Alias Portd
Drawing = 0
Linecount = 0
Count = 0
Enable Timer0
'--------------------------------------------------------------------------------
Bardraw_screen:
While Pinb.0 = 0
Wend
Do
rcall bardraw
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
Red_screen:
While Pinb.0 = 0
Wend
Do
Video = Red
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
Green_screen:
While Pinb.0 = 0
Wend
Do
Video = Green
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
Blue_screen:
While Pinb.0 = 0
Wend
Do
Video = Blue
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
Yellow_screen:
While Pinb.0 = 0
Wend
Do
Video = Yellow
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
Magenta_screen:
While Pinb.0 = 0
Wend
Do
Video = Magenta
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
Lblue_screen:
While Pinb.0 = 0
Wend
Do
Video = Lblue
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
White_screen:
While Pinb.0 = 0
Wend
Do
Video = White
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
Black_screen:
While Pinb.0 = 0
Wend
Do
Video = Black
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
220blue_screen:
While Pinb.0 = 0
Wend
Do
If Linecount < 241 Then
Video = Blue
Else
Video = Red
End If
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
Crosshatch:
While Pinb.0 = 0
Wend
Do
If Linecount = 40 Or Linecount = 100 Or Linecount = 160 Or Linecount = 220 Or Linecount = 280 Then
Video = White
Else
rcall line_draw
End If
If Pinb.0 = 0 Then Exit Do
Idle
Loop
'--------------------------------------------------------------------------------
' No more screens to jump through.... start at beginning
'--------------------------------------------------------------------------------
Goto Bardraw_screen
'--------------------------------------------------------------------------------
' Helper Drawing Functions
'--------------------------------------------------------------------------------
Line_draw:
ldi R17, $06
Del3:
dec R17
brne del3
rcall crosshatch0
Video = White
Nop
Video = Black
rcall crosshatch0
Video = White
Nop
Video = Black
rcall crosshatch0
Video = White
Nop
Video = Black
rcall crosshatch0
Video = White
Nop
Video = Black
rcall crosshatch0
Video = White
Nop
Video = Black
Return
'--------------------------------------------------------------------------------
Bardraw:
Video = White
RCALL Delay_time
Video = Yellow
RCALL Delay_time
Video = Lblue
RCALL Delay_time
Video = Green
RCALL Delay_time
Video = Magenta
RCALL Delay_time
Video = Red
RCALL Delay_time
Video = Black
RCALL Delay_time
Video = Blue
Return
'--------------------------------------------------------------------------------
Delay16:
ldi R17, $4d
Wgloop0:
dec R17
brne wgloop0
nop
nop
ret
'--------------------------------------------------------------------------------
Delay_time:
ldi R17, $25
Bars1:
dec R17
brne bars1
ret
'--------------------------------------------------------------------------------
Crosshatch0:
ldi R17, $35
Crosshatch1:
dec R17
brne crosshatch1
nop
ret
'--------------------------------------------------------------------------------
' ISR for Timer0. When trigger Csync and RGB go Low.
'--------------------------------------------------------------------------------
Frame2:
Video = 0
'Low Duration Loop
Incr Linecount
ldi R17, $15 '
Frame_delay:
dec R17
brne frame_delay
If Linecount >= 262 Then ' Blanking period
Timer0 = &H00
ldi R17, $FF
Low_blank_delay_1:
dec R17
brne low_blank_delay_1
Timer0 = &H00
ldi R17, $68
Low_blank_delay_12:
dec R17
brne low_blank_delay_12
'PULSE HIGH'
Timer0 = &H00
Video = Black
ldi R17, $1F
High_blank_delay:
dec R17
brne high_blank_delay
NOP
'PULSE LOW'
Video = 0
Timer0 = &H00
ldi R17, $FF
Low_blank_delay_2:
dec R17
brne low_blank_delay_2
Timer0 = &H00
ldi R17, $86
Low_blank_delay_21:
dec R17
brne low_blank_delay_21
NOP
'PULSE HIGH'
Timer0 = &H00
Video = Black
ldi R17, $1F
High_blank_delay_2:
dec R17
brne high_blank_delay_2
NOP
'PULSE LOW'
Video = 0
Timer0 = &H00
ldi R17, $FF
Low_blank_delay_3:
dec R17
brne low_blank_delay_3
Timer0 = &H00
ldi R17, $86
Low_blank_delay_31:
dec R17
brne low_blank_delay_31
NOP
'PULSE HIGH'
Timer0 = &H00
Video = Black
ldi R17, $1F
High_blank_delay_3:
dec R17
brne high_blank_delay_3
NOP
'PULSE LOW'
Video = 0
Timer0 = &H00
ldi R17, $16
Low_blank_delay:
dec R17
brne low_blank_delay
NOP
Linecount = 0
Goto Exit_isr
End If
Exit_isr:
' Timer affects high durations, as 'Black' will make Csync 1.
' Timer is set such that ISR will trigger just on time to make Csync 0
' When it re-enters the ISR.
Timer0 = &H75
Video = Black
Return
|