-
Notifications
You must be signed in to change notification settings - Fork 0
/
Music.asm
219 lines (195 loc) · 3.75 KB
/
Music.asm
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
LIST P=16f628a , R=DEC
INCLUDE "P16F628a.INC"
ERRORLEVEL -302
__CONFIG _CP_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_ON & _MCLRE_ON & _LVP_OFF
#DEFINE BANK0 BCF STATUS,RP0 ; Define Bank 0
#DEFINE BANK1 BSF STATUS,RPG0 ; Define Bank 1
#DEFINE HEADPHONE PORTA,2 ; Define headphone output on pin '1'
CBLOCK 20H TEMP, TEMP1, TEMP2, TEMPO, TMRH_AUX, TMRL_AUX
ENDC
CBLOCK 70X W_TEMPO, STATUS_TEMP
ENDC
H_DO EQU HIGH (10000H - (.500000/.262))
L_DO EQU LOW (10000H - (.500000/.262))
H_DO_ EQU HIGH (10000H - (.500000/.277))
L_DO_ EQU LOW (10000H - (.500000/.277))
H_RE EQU HIGH (10000H - (.500000/.294))
L_RE EQU LOW (10000H - (.500000/.294))
H_RE_ EQU HIGH (10000H - (.500000/.311))
L_RE_ EQU LOW (10000H - (.500000/.311))
H_MI EQU HIGH (10000H - (.500000/.330))
L_MI EQU LOW (10000H - (.500000/.330))
H_FA EQU HIGH (10000H - (.500000/.349))
L_FA EQU LOW (10000H - (.500000/.349))
H_FA_ EQU HIGH (10000H - (.500000/.370))
L_FA_ EQU LOW (10000H - (.500000/.370))
H_SOL EQU HIGH (10000H - (.500000/.392))
L_SOL EQU LOW (10000H - (.500000/.392))
H_SOL_ EQU HIGH (10000H - (.500000/.415))
L_SOL_ EQU LOW (10000H - (.500000/.415))
H_LA EQU HIGH (10000H - (.500000/.440))
L_LA EQU LOW (10000H - (.500000/.440))
H_LA_ EQU HIGH (10000H - (.500000/.466))
L_LA_ EQU LOW (10000H - (.500000/.466))
H_SI EQU HIGH (10000H - (.500000/.494))
L_SI EQU LOW (10000H - (.500000/.494))
ORG 00H
BANK1
MOVLW b'11111011' ; Define input as '1' and output as '0'
MOVWF TRISA
MOVLW b'11111111'
MOVWF TRISB
MOVLW b'10000100' ; TMR0(16)
MOVWF OPTION_REG
BSF PIE1,0 ; Set interruption on TMR1
BANK0
MOVLW .7
MOVWF CMCON
MOVLW 01H ; PRESCALLER(1) on TMR1
MOVWF T1CON ; Turn on TMR1
MOVLW b'01100000' ; Set interruption on TMR0
MOVWF INTCON ; Turn off all interruptions
CLRF PORTA
CLRF PORTB
MUSIC
CALL JINGLEBELLS
MOVLW .4
CALL DELAY
CALL YESTERDAY
MOVLW .4
CALL DELAY
GOTO MUSIC
JINGLEBELLS
; TODO: music
RETURN
YESTERDAY
; TODO: music
RETURN
N_DO
MOVWF TEMPO
MOVLW H_DO
MOVWF TMRH_AUX
MOVLW L_DO
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_DO_
MOVWF TEMPO
MOVLW H_DO_
MOVWF TMRH_AUX
MOVLW L_DO_
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_RE
MOVWF TEMPO
MOVLW H_RE
MOVWF TMRH_AUX
MOVLW L_RE
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_RE_
MOVWF TEMPO
MOVLW H_RE_
MOVWF TMRH_AUX
MOVLW L_RE_
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_MI
MOVWF TEMPO
MOVLW H_MI
MOVWF TMRH_AUX
MOVLW L_MI
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_FA
MOVWF TEMPO
MOVLW H_FA
MOVWF TMRH_AUX
MOVLW L_FA
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_FA_
MOVWF TEMPO
MOVLW H_FA_
MOVWF TMRH_AUX
MOVLW L_FA_
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_SOL
MOVWF TEMPO
MOVLW H_SOL
MOVWF TMRH_AUX
MOVLW L_SOL
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_SOL_
MOVWF TEMPO
MOVLW H_SOL_
MOVWF TMRH_AUX
MOVLW L_SOL_
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_LA
MOVWF TEMPO
MOVLW H_LA
MOVWF TMRH_AUX
MOVLW L_LA
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_LA_
MOVWF TEMPO
MOVLW H_LA_
MOVWF TMRH_AUX
MOVLW L_LA_
MOVWF TMRH_AUX
GOTO PLAY_CHORD
N_SI
MOVWF TEMPO
MOVLW H_SI
MOVWF TMRH_AUX
MOVLW L_SI
MOVWF TMRH_AUX
GOTO PLAY_CHORD
PLAY_CHORD
BSF INTCON,GIE
MOVW TEMPO,F
BTFSS STATUS,Z
GOTO $-2
BCF HEADPHONE
BCF INTCON,GIE
MOVLW .0
LIL_DELAY
ADDLW .1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
BTFSS STATUS,Z
GOTO LIL_DELAY
RETURN
DELAY
MOVFW TEMP
_A0
MOVLW .10
CALL DELAY_2
DECFSZ TEMP,F
GOTO _A0
RETURN
DELAY_2
MOVWF TEMP2
_B0
MOVLW .250
MOVWF TEMP1
DECFSZ TEMP1,F
GOTO $-1
DECFSZ TEMP2,F
GOTO _B0
RETURN
END