Rev Author Line No. Line
193 miho 1 CCS PCW C Compiler, Version 3.110, 15448
2  
3 Filename: mb01a.LST
4  
5 ROM used: 1536 (75%)
6 Largest free fragment is 512
7 RAM used: 29 (17%) at main() level
8 88 (50%) worst case
9 Stack: 6 worst case (5 in main + 1 for interrupts)
10  
11 *
12 0000: MOVLW 00
13 0001: MOVWF 0A
14 0002: GOTO 595
15 0003: NOP
16 0004: MOVWF 7F
17 0005: SWAPF 03,W
18 0006: CLRF 03
19 0007: MOVWF 21
20 0008: MOVF 7F,W
21 0009: MOVWF 20
22 000A: MOVF 0A,W
23 000B: MOVWF 28
24 000C: CLRF 0A
25 000D: SWAPF 20,F
26 000E: MOVF 04,W
27 000F: MOVWF 22
28 0010: MOVF 77,W
29 0011: MOVWF 23
30 0012: MOVF 78,W
31 0013: MOVWF 24
32 0014: MOVF 79,W
33 0015: MOVWF 25
34 0016: MOVF 7A,W
35 0017: MOVWF 26
36 0018: MOVF 7B,W
37 0019: MOVWF 27
38 001A: BCF 03.7
39 001B: BCF 03.5
40 001C: MOVLW 8C
41 001D: MOVWF 04
42 001E: BTFSS 00.2
43 001F: GOTO 022
44 0020: BTFSC 0C.2
45 0021: GOTO 0CB
46 0022: MOVF 22,W
47 0023: MOVWF 04
48 0024: MOVF 23,W
49 0025: MOVWF 77
50 0026: MOVF 24,W
51 0027: MOVWF 78
52 0028: MOVF 25,W
53 0029: MOVWF 79
54 002A: MOVF 26,W
55 002B: MOVWF 7A
56 002C: MOVF 27,W
57 002D: MOVWF 7B
58 002E: MOVF 28,W
59 002F: MOVWF 0A
60 0030: SWAPF 21,W
61 0031: MOVWF 03
62 0032: SWAPF 7F,F
63 0033: SWAPF 7F,W
64 0034: RETFIE
65 .................... // Melodicky zvonek MB01A_1_00
66 .................... //
67 .................... // Prohram pro melodicky zvonek s pouzitim knihovny Sound_t1.C
68 .................... //
69 .................... // (c)miho 2004, pefi 2004
70 .................... //
71 .................... // Historie:
72 .................... // 1.00 Uvodni verze
73 .................... // 1.01 Zaveden WDT
74 ....................
75 .................... #include <16F819.h> // Definice procesoru
76 .................... //////// Standard Header file for the PIC16F628 device ////////////////
77 .................... #device PIC16F819
78 .................... #list
79 ....................
80 .................... #fuses HS,NOPROTECT,WDT,PUT,NOLVP,NOBROWNOUT,WRT // Definice konfiguracniho slova
81 ....................
82 .................... #define POWER_386 PIN_A4 // L zapne napajeni pro zesilovac LM386
83 .................... #define POWER_PIC PIN_A3 // L pripoji GND pro procesor PIC
84 ....................
85 .................... #define SOUND_HI PIN_B3 // Akusticky vystup
86 .................... #define SOUND_LO PIN_B2 // Akusticky vystup
87 .................... #define SOUND_CLOCK 20000000 // Frekvence hodin
88 .................... #define SOUND_LowOctave 1 // O oktavu vys protoze mame moc rychly krystal
89 .................... #define SOUND_WDT 1 // Budeme pouzivat WDT
90 .................... #include "Sound_T1.c" // Hudebni knihovna
91 .................... // Knihovna pro generovani hudebnich zvuku dane frekvence a delky nebo
92 .................... // dane noty temperovaneho ladeni a delky.
93 .................... //
94 .................... // Pro gnerovani pouziva casovac T0, T1 a jednotku CCP1.
95 .................... //
96 .................... // POZOR -- POZOR -- POZOR
97 .................... // Pri nizsi frekvenci XTALu (nez asi 5MHz) je rezie preruseni tak velka, ze spotrebuje
98 .................... // veskery strojovy cas a uz nedojde k ukonceni rozehraneho tonu vyssi frekvence (z oktavy 7
99 .................... // nebo nad cca 8KHz). Resenim je pouzit vlastni INT proceduru s minimalni rezii.
100 .................... //
101 .................... // (c)miho 2004, pefi 2004,
102 .................... //
103 .................... // Historie
104 .................... // 1.00 Uvodni verze
105 .................... // 1.01 Pridana podpora zapnuteho WDT
106 ....................
107 .................... // Konfiguracni parametry
108 .................... //#define SOUND_HI PIN_xx // Pozitivni vystup
109 .................... //#define SOUND_LO PIN_xx // Komplementarni vystup
110 .................... //#define SOUND_WDT 1 // Pokud je pouzit WDT
111 .................... #ifndef SOUND_CLOCK
112 .................... #define SOUND_CLOCK 4000000 // Frelvence krystalu v Hz
113 .................... #endif
114 ....................
115 ....................
116 .................... // Definice hudebnich tonu (not) pro proceduru SoundNote()
117 .................... #define SOUND_C 0
118 .................... #define SOUND_Cis 1
119 .................... #define SOUND_D 2
120 .................... #define SOUND_Dis 3
121 .................... #define SOUND_E 4
122 .................... #define SOUND_F 5
123 .................... #define SOUND_Fis 6
124 .................... #define SOUND_G 7
125 .................... #define SOUND_Gis 8
126 .................... #define SOUND_A 9
127 .................... #define SOUND_Ais 10
128 .................... #define SOUND_H 11
129 .................... #define SOUND_Space 12 // Pomlka
130 ....................
131 ....................
132 .................... // Prototypy verejnych procedur
133 ....................
134 .................... void SoundBeep(unsigned int16 Frequency, unsigned int16 Duration);
135 .................... // Predava se frekvence v Hz a doba trvani v ms (0 znamena ticho)
136 ....................
137 .................... void SoundNote(unsigned int8 Note, Octave, unsigned int16 Duration);
138 .................... // Predava se cislo noty (0 je C), posunuti v oktavach (0 nejnizsi ton,
139 .................... // SOUND_Space je ticho), doba trvani v ms
140 ....................
141 .................... // Alternativni makra pro generovani konstatnich tonu
142 .................... // SoundBeepMacro(Frequency, Duration) - frekvence nesmi byt 0
143 .................... // SoundNoteMacro(Note, Octave, Duration) - nepodporuje SOUND_Space
144 .................... // SoundSpaceMacro(Duration) - hraje ticho
145 ....................
146 .................... // Privatni cast
147 ....................
148 ....................
149 .................... #int_ccp1
150 .................... void IntCCP1()
151 .................... // Preruseni od jednotky CCP1 generuje vystup
152 .................... {
153 .................... volatile int1 Data; // Posledni stav vystupu
154 .................... output_bit(SOUND_HI,Data); // Nastav vystup
155 *
156 00CB: BTFSC 72.0
157 00CC: GOTO 0CF
158 00CD: BCF 06.3
159 00CE: GOTO 0D0
160 00CF: BSF 06.3
161 00D0: BSF 03.5
162 00D1: BCF 06.3
163 .................... output_bit(SOUND_LO,~Data);
164 00D2: BTFSS 72.0
165 00D3: GOTO 0D8
166 00D4: BCF 03.5
167 00D5: BCF 06.2
168 00D6: GOTO 0DA
169 00D7: BSF 03.5
170 00D8: BCF 03.5
171 00D9: BSF 06.2
172 00DA: BSF 03.5
173 00DB: BCF 06.2
174 .................... Data=~Data; // Otoc stav vystupu
175 00DC: MOVLW 01
176 00DD: XORWF 72,F
177 .................... }
178 ....................
179 ....................
180 .................... #if SOUND_CLOCK < (65535*32*4*2) // < 16.7 MHz
181 .................... #define SOUND_PRESCALE 1
182 .................... #elif SOUND_CLOCK < (65535*32*4*2*2) // < 33.6 MHz
183 .................... #define SOUND_PRESCALE 2
184 .................... #elif SOUND_CLOCK < (65535*32*4*2*4) // < 67.1 MHz
185 .................... #define SOUND_PRESCALE 4
186 .................... #elif SOUND_CLOCK < (65535*32*4*2*8) // < 134 MHz
187 .................... #define SOUND_PRESCALE 8
188 .................... #else
189 .................... #error SOUND_CLOCK Frequency too high
190 .................... #endif
191 00DE: BCF 03.5
192 00DF: BCF 0C.2
193 00E0: BCF 0A.3
194 00E1: GOTO 022
195 .................... #bit T0IF=0x0B.2
196 .................... void SoundBeep(unsigned int16 Frequency, unsigned int16 Duration)
197 .................... // Predava se frekvence v Hz a doba trvani v ms (0 znamena ticho)
198 .................... // Rozumne frekvence jsou od 32Hz
199 .................... {
200 .................... unsigned int16 Time; // Pocitadlo zlomkoveho casu
201 ....................
202 .................... // Inicializace casovace
203 .................... if (Frequency!=0) // Frekvence 0 znamena ticho
204 .................... {
205 .................... setup_ccp1(CCP_COMPARE_RESET_TIMER);
206 .................... set_timer1(0);
207 .................... (int16)CCP_1=SOUND_CLOCK/SOUND_PRESCALE/4/2/Frequency;
208 .................... #if SOUND_PRESCALE==1
209 .................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
210 .................... #elif SOUND_PRESCALE==2
211 .................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_2);
212 .................... #elif SOUND_PRESCALE==4
213 .................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
214 .................... #elif SOUND_PRESCALE==8
215 .................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
216 .................... #endif
217 .................... enable_interrupts(int_ccp1);
218 .................... enable_interrupts(global);
219 .................... }
220 ....................
221 .................... // Delka tonu merena casovacem T0 (bez preruseni)
222 .................... Time=0;
223 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
224 .................... while (Duration)
225 .................... {
226 .................... #ifdef SOUND_WDT
227 .................... restart_wdt(); // Nuluj watchdog abychom se nezresetovali
228 .................... #endif
229 .................... if (T0IF) // Preteceni T0 - kazdych (1/CLK)*4*256
230 .................... {
231 .................... T0IF = 0;
232 .................... Time += (256*4*1000*2048+SOUND_CLOCK/2)/SOUND_CLOCK;
233 .................... }
234 .................... if (Time>>11)
235 .................... {
236 .................... Time -= 2048;
237 .................... Duration--;
238 .................... }
239 .................... }
240 ....................
241 .................... // Konec casovace
242 .................... disable_interrupts(int_ccp1);
243 .................... disable_interrupts(global);
244 .................... }
245 ....................
246 ....................
247 .................... // Definice casu pulperody pro nejnizsi oktavu, v kvantech casovace T1
248 .................... // Pulperiody tonu v dalsich oktavach se ziskavaji rotaci vpravo
249 .................... #define SOUND_Peri_C ((30578*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 30578us
250 .................... #define SOUND_Peri_Cis ((28862*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 28862us
251 .................... #define SOUND_Peri_D ((27242*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 27242us
252 .................... #define SOUND_Peri_Dis ((25713*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 25713us
253 .................... #define SOUND_Peri_E ((24270*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 24270us
254 .................... #define SOUND_Peri_F ((22908*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 22908us
255 .................... #define SOUND_Peri_Fis ((21622*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 21622us
256 .................... #define SOUND_Peri_G ((20408*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 20408us
257 .................... #define SOUND_Peri_Gis ((19263*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 19263us
258 .................... #define SOUND_Peri_A ((18182*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 18182us
259 .................... #define SOUND_Peri_Ais ((17161*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 17161us
260 .................... #define SOUND_Peri_H ((16198*(SOUND_CLOCK/1000)/1000/4/2)/SOUND_PRESCALE) // Perioda 16198us
261 ....................
262 .................... // Kontrola na delku konstanty (musi byt mensi nez delka citace)
263 .................... #if SOUND_Peri_C > 65535
264 .................... #error "SOUND_Peri_C too long (Note C requires delay > 65535 cycles)"
265 .................... #endif
266 ....................
267 .................... // Casove konstanty pro noty nejnizsi oktavy
268 .................... const unsigned int16 Table[12] =
269 .................... SOUND_Peri_C, SOUND_Peri_Cis, SOUND_Peri_D, SOUND_Peri_Dis,
270 .................... SOUND_Peri_E, SOUND_Peri_F, SOUND_Peri_Fis, SOUND_Peri_G,
271 .................... SOUND_Peri_Gis, SOUND_Peri_A, SOUND_Peri_Ais, SOUND_Peri_H;
272 *
273 0035: BCF 0A.0
274 0036: BCF 0A.1
275 0037: BCF 0A.2
276 0038: ADDWF 02,F
277 0039: RETLW 4E
278 003A: RETLW 95
279 003B: RETLW ED
280 003C: RETLW 8C
281 003D: RETLW 04
282 003E: RETLW 85
283 003F: RETLW 8D
284 0040: RETLW 7D
285 0041: RETLW 81
286 0042: RETLW 76
287 0043: RETLW DB
288 0044: RETLW 6F
289 0045: RETLW 93
290 0046: RETLW 69
291 0047: RETLW A6
292 0048: RETLW 63
293 0049: RETLW 0E
294 004A: RETLW 5E
295 004B: RETLW C7
296 004C: RETLW 58
297 004D: RETLW CB
298 004E: RETLW 53
299 004F: RETLW 17
300 0050: RETLW 4F
301 ....................
302 ....................
303 .................... void SoundNote(unsigned int8 Note, Octave, unsigned int16 Duration)
304 .................... // Predava se cislo noty (0 je C), posunuti v oktavach (0 nejnizsi ton)
305 .................... // doba trvani v ms (0 znamena ticho)
306 .................... // Zahraje zadanou notu v zadane oktave dane delky
307 .................... {
308 .................... unsigned int16 Time; // Pocitadlo zlomkoveho casu
309 ....................
310 .................... // Inicializace casovace
311 .................... if (Note!=SOUND_Space) // Pokud se ma hrat spust hrani
312 *
313 00E2: MOVF 69,W
314 00E3: SUBLW 0C
315 00E4: BTFSC 03.2
316 00E5: GOTO 109
317 .................... {
318 .................... setup_ccp1(CCP_COMPARE_RESET_TIMER);
319 00E6: MOVLW 0B
320 00E7: MOVWF 17
321 .................... set_timer1(0);
322 00E8: CLRF 0F
323 00E9: CLRF 0E
324 .................... (int16)CCP_1=Table[Note]>>Octave;
325 00EA: BCF 03.0
326 00EB: RLF 69,W
327 00EC: MOVWF 77
328 00ED: MOVWF 6F
329 00EE: INCF 6F,W
330 00EF: CALL 035
331 00F0: MOVWF 7A
332 00F1: MOVF 6F,W
333 00F2: CALL 035
334 00F3: MOVWF 70
335 00F4: MOVF 7A,W
336 00F5: MOVWF 71
337 00F6: MOVWF 16
338 00F7: MOVF 70,W
339 00F8: MOVWF 15
340 00F9: MOVF 6A,W
341 00FA: MOVWF 77
342 00FB: BTFSC 03.2
343 00FC: GOTO 102
344 00FD: BCF 03.0
345 00FE: RRF 16,F
346 00FF: RRF 15,F
347 0100: DECFSZ 77,F
348 0101: GOTO 0FD
349 .................... #if SOUND_PRESCALE==1
350 .................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
351 .................... #elif SOUND_PRESCALE==2
352 .................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_2);
353 0102: MOVLW 95
354 0103: MOVWF 10
355 .................... #elif SOUND_PRESCALE==4
356 .................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
357 .................... #elif SOUND_PRESCALE==8
358 .................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
359 .................... #endif
360 .................... enable_interrupts(int_ccp1);
361 0104: BSF 03.5
362 0105: BSF 0C.2
363 .................... enable_interrupts(global);
364 0106: MOVLW C0
365 0107: BCF 03.5
366 0108: IORWF 0B,F
367 .................... }
368 ....................
369 .................... // Delka tonu merena casovacem T0 (bez preruseni)
370 .................... Time=0;
371 0109: CLRF 6E
372 010A: CLRF 6D
373 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
374 010B: BSF 03.5
375 010C: MOVF 01,W
376 010D: ANDLW C0
377 010E: IORLW 08
378 010F: MOVWF 01
379 .................... while (Duration)
380 0110: BCF 03.5
381 0111: MOVF 6B,W
382 0112: IORWF 6C,W
383 0113: BTFSC 03.2
384 0114: GOTO 133
385 .................... {
386 .................... if (T0IF) // Preteceni T0 - kazdych (1/CLK)*4*256
387 0115: BTFSS 0B.2
388 0116: GOTO 11C
389 .................... {
390 .................... T0IF = 0;
391 0117: BCF 0B.2
392 .................... Time += (256*4*1000*2048+SOUND_CLOCK/2)/SOUND_CLOCK;
393 0118: MOVLW 69
394 0119: ADDWF 6D,F
395 011A: BTFSC 03.0
396 011B: INCF 6E,F
397 .................... }
398 .................... if (Time>>11)
399 011C: CLRF 7A
400 011D: RRF 6E,W
401 011E: MOVWF 79
402 011F: RRF 79,F
403 0120: RRF 79,F
404 0121: MOVLW 1F
405 0122: ANDWF 79,F
406 0123: MOVF 79,W
407 0124: IORWF 7A,W
408 0125: BTFSC 03.2
409 0126: GOTO 131
410 .................... {
411 .................... Time -= 2048;
412 0127: MOVLW 00
413 0128: SUBWF 6D,F
414 0129: MOVLW 08
415 012A: BTFSS 03.0
416 012B: MOVLW 09
417 012C: SUBWF 6E,F
418 .................... Duration--;
419 012D: MOVF 6B,W
420 012E: BTFSC 03.2
421 012F: DECF 6C,F
422 0130: DECF 6B,F
423 .................... }
424 .................... #ifdef SOUND_WDT
425 .................... restart_wdt(); // Nuluj watchdog abychom se nezresetovali
426 0131: CLRWDT
427 .................... #endif
428 .................... }
429 0132: GOTO 111
430 ....................
431 .................... // Konec casovace
432 .................... disable_interrupts(int_ccp1);
433 0133: BSF 03.5
434 0134: BCF 0C.2
435 .................... disable_interrupts(global);
436 0135: BCF 03.5
437 0136: BCF 0B.6
438 0137: BCF 0B.7
439 0138: BTFSC 0B.7
440 0139: GOTO 137
441 013A: RETLW 00
442 .................... }
443 ....................
444 ....................
445 .................... #include "Data.c" // Datovy blok pro predpripravene skladby
446 .................... // Tento soubor definuje vse potrebne pro ulozeni skladeb do pameti programu.
447 .................... // Dale definuje pislusna makra pro snadne definice. Tyto definice jsou voleny
448 .................... // zamerne tak, aby mohl byt pouzit stejny soubor s definici skladby jak
449 .................... // pro vlozeni primo do firmwaru v dobe prekladu tak i k dodatecnemu nahrani
450 .................... // skladby pres seriovou linku.
451 ....................
452 .................... // Definice hranic pameti pro ulozeni pisnicek
453 .................... #define STARTMEM 0x600 // Zde zacina pametoa oblast pro pisnicky
454 .................... #define ENDMEM 0x7ff // Zde konci pametova oblast pro pisnicky
455 ....................
456 .................... // Definice konstant pro kodovani dat
457 .................... #define ENDOFDATA 0x3FFF // Priznak konce pisnicek (prazdna pamet)
458 .................... #define DATABEGIN 0x2000 // Kod zacatku skladby
459 .................... #define MASKBEGIN 0x3800
460 .................... #define DATATEMPO 0x2800 // Kod pro nastaveni tempa
461 .................... #define MASKTEMPO 0x3800
462 .................... #define DATAPAUSE 0x3000 // Kod pro nastaveni mezery mezi notami
463 .................... #define MASKPAUSE 0x3800
464 .................... #define MASKNOTE 0x2000 // Nejvissi bit 0 urcuje, ze jde o notu
465 ....................
466 .................... // Pseudomakra pro jednoduchy zapis skladeb do zdrojaku jazyka C
467 .................... #define BEGIN DATABEGIN+ // Zacatek pisnicky + posunuti oktav
468 .................... #define TEMPO DATATEMPO+ // Delka nejskratsi noty v ms
469 .................... #define PAUSE DATAPAUSE+ // Delka mezery mezi notami
470 .................... #define END // Konec skladby, zde nic neznamena
471 ....................
472 .................... // Pseudomakra pro zapis not, zapisuje se cislo oktavy, nota, delka noty
473 .................... #define C *16 + SOUND_C + 128 *
474 .................... #define Cis *16 + SOUND_Cis + 128 *
475 .................... #define D *16 + SOUND_D + 128 *
476 .................... #define Dis *16 + SOUND_Dis + 128 *
477 .................... #define E *16 + SOUND_E + 128 *
478 .................... #define F *16 + SOUND_F + 128 *
479 .................... #define Fis *16 + SOUND_Fis + 128 *
480 .................... #define G *16 + SOUND_G + 128 *
481 .................... #define Gis *16 + SOUND_Gis + 128 *
482 .................... #define A *16 + SOUND_A + 128 *
483 .................... #define Ais *16 + SOUND_Ais + 128 *
484 .................... #define H *16 + SOUND_H + 128 *
485 .................... #define Space SOUND_Space + 128 *
486 ....................
487 .................... // Pametova oblast
488 .................... #ORG 0x600,0x7FF {} // Vyhrazeni oblasti pameti pro ulozeni pisnicek
489 .................... #ROM 0x600 = { // Naplneni oblasti pameti daty
490 ....................
491 .................... // Pisnicky jako soucast firwaru se vkladaji sem
492 .................... // Museji mit stejny format jako uvedene priklady aby zafungovaly makra
493 .................... #include "Skladby\TheFinalSoundDown.txt"
494 .................... // Pisnicka "The Final Sound Down"
495 .................... //
496 .................... // Tato pisnicka je napsana ve formatu, ktery se da pouzit jak pro primy
497 .................... // preklad do firmwaru melodickeho zvonku tak i pro dodatecne nahrani
498 ....................
499 .................... BEGIN 3, // Zacatek skladby
500 .................... TEMPO 100, // Delka nejkratsi noty v ms
501 .................... PAUSE 100, // Delka mezery mezi notami
502 ....................
503 .................... 1 A 1,
504 .................... 1 G 1,
505 .................... 1 A 4,
506 .................... 1 D 4,
507 .................... Space 2,
508 ....................
509 .................... 1 Ais 1,
510 .................... 1 A 1,
511 .................... 1 Ais 2,
512 .................... 1 A 2,
513 .................... 1 G 4,
514 .................... Space 2,
515 ....................
516 .................... 1 Ais 1,
517 .................... 1 A 1,
518 .................... 1 Ais 4,
519 .................... 1 D 4,
520 .................... Space 2,
521 ....................
522 .................... 1 G 1,
523 .................... 1 F 1,
524 .................... 1 G 2,
525 .................... 1 F 2,
526 .................... 1 E 2,
527 .................... 1 G 2,
528 .................... 1 F 4,
529 .................... Space 2,
530 ....................
531 .................... 1 E 1,
532 .................... 1 F 1,
533 .................... 1 G 4,
534 .................... Space 2,
535 ....................
536 .................... 1 F 1,
537 .................... 1 G 1,
538 .................... 1 A 2,
539 .................... 1 G 2,
540 .................... 1 F 2,
541 .................... 1 E 2,
542 .................... 1 D 4,
543 .................... 1 Ais 4,
544 .................... 1 A 4,
545 .................... Space 2,
546 ....................
547 .................... 1 A 1,
548 .................... 1 Ais 1,
549 .................... 1 A 1,
550 .................... 1 G 1,
551 .................... 1 A 4,
552 .................... Space 2,
553 ....................
554 .................... END
555 ....................
556 .................... #include "Skladby\BednaOdWhisky.txt"
557 .................... // Pisnicka "Bedna od Whisky"
558 .................... //
559 .................... // Tato pisnicka je napsana ve formatu, ktery se da pouzit jak pro primy
560 .................... // preklad do firmwaru melodickeho zvonku tak i pro dodatecne nahrani
561 ....................
562 .................... BEGIN 2, // Zacatek skladby
563 .................... TEMPO 100, // Delka nejkratsi noty v ms
564 .................... PAUSE 100, // Delka mezery mezi notami
565 ....................
566 .................... 1 A 2,
567 .................... 2 C 2,
568 .................... 2 E 2,
569 .................... 2 A 2,
570 .................... 2 G 4,
571 .................... 2 E 2,
572 .................... 2 E 2,
573 .................... 2 A 2,
574 .................... 2 G 2,
575 .................... 2 E 2,
576 .................... 2 D 2,
577 .................... 2 E 4,
578 .................... Space 4,
579 .................... 1 A 2,
580 .................... 2 C 2,
581 .................... 2 E 2,
582 .................... 2 A 2,
583 .................... 2 G 2,
584 .................... 2 G 2,
585 .................... 2 E 2,
586 .................... 2 E 2,
587 .................... 1 A 2,
588 .................... 2 E 2,
589 .................... 1 H 2,
590 .................... 2 E 2,
591 .................... 1 A 4,
592 .................... Space 4,
593 .................... 1 A 2,
594 .................... 2 C 2,
595 .................... 2 E 2,
596 .................... 2 A 2,
597 .................... 2 G 2,
598 .................... 2 G 2,
599 .................... 2 E 4,
600 .................... 2 A 2,
601 .................... 2 G 2,
602 .................... 2 E 2,
603 .................... 2 D 2,
604 .................... 2 E 4,
605 .................... Space 2,
606 .................... 2 E 2,
607 .................... 1 A 2,
608 .................... 2 C 2,
609 .................... 2 E 2,
610 .................... 2 A 2,
611 .................... 2 G 2,
612 .................... 2 E 4,
613 .................... 2 E 2,
614 .................... 2 A 2,
615 .................... 2 A 2,
616 .................... 2 GIS 2,
617 .................... 2 H 2,
618 .................... 2 A 4,
619 .................... Space 8,
620 .................... 2 E 2,
621 .................... 2 A 2,
622 .................... 2 A 2,
623 .................... 2 A 2,
624 .................... 2 GIS 2,
625 .................... 2 FIS 2,
626 .................... 2 A 4,
627 .................... 2 A 2,
628 .................... 2 H 2,
629 .................... 2 H 2,
630 .................... 2 A 2,
631 .................... 2 H 2,
632 .................... 3 CIS 2,
633 .................... 2 A 4,
634 .................... 2 E 2,
635 .................... 2 A 2,
636 .................... 2 A 2,
637 .................... 2 A 2,
638 .................... 2 GIS 2,
639 .................... 2 FIS 2,
640 .................... 2 A 2,
641 .................... 2 A 2,
642 .................... 2 A 2,
643 .................... 2 H 2,
644 .................... 2 H 2,
645 .................... 2 A 2,
646 .................... 2 GIS 2,
647 .................... 2 A 4,
648 .................... Space 2,
649 .................... 2 E 2,
650 .................... 2 A 2,
651 .................... 2 A 2,
652 .................... 2 A 2,
653 .................... 2 GIS 2,
654 .................... 2 FIS 2,
655 .................... 2 A 4,
656 .................... 2 A 2,
657 .................... 2 H 2,
658 .................... 2 H 2,
659 .................... 2 A 2,
660 .................... 2 H 2,
661 .................... 3 CIS 2,
662 .................... 2 A 4,
663 .................... 2 E 2,
664 .................... 2 A 2,
665 .................... 2 A 2,
666 .................... 2 A 2,
667 .................... 2 GIS 2,
668 .................... 2 FIS 2,
669 .................... 2 A 2,
670 .................... Space 2,
671 .................... 2 A 2,
672 .................... 2 H 2,
673 .................... 2 H 2,
674 .................... 2 A 2,
675 .................... 2 GIS 2,
676 .................... 2 A 8,
677 .................... 2 G 2,
678 .................... 2 A 8,
679 .................... 2 G 2,
680 .................... 2 A 8,
681 ....................
682 .................... END
683 ....................
684 .................... #include "Skladby\KdyzMeBaliZaVojacka.txt"
685 .................... // Pisnicka "Kdyz me brali za vojacka"
686 .................... //
687 .................... // Tato pisnicka je napsana ve formatu, ktery se da pouzit jak pro primy
688 .................... // preklad do firmwaru melodickeho zvonku tak i pro dodatecne nahrani
689 ....................
690 .................... BEGIN 2, // Zacatek skladby
691 .................... TEMPO 150, // Delka nejkratsi noty v ms
692 .................... PAUSE 100, // Delka mezery mezi notami
693 ....................
694 .................... 1 A 1,
695 .................... 2 C 1,
696 .................... 2 E 1,
697 .................... 2 D 1,
698 .................... 2 C 1,
699 .................... 1 H 1,
700 .................... 2 C 2,
701 .................... 2 D 1,
702 .................... 2 E 2,
703 .................... 2 D 1,
704 .................... 2 G 1,
705 .................... 2 G 1,
706 .................... 2 G 1,
707 .................... 2 G 1,
708 .................... 2 A 1,
709 .................... 2 E 2,
710 .................... Space 4,
711 .................... 2 D 1,
712 .................... 2 F 1,
713 .................... 2 A 1,
714 .................... 2 G 1,
715 .................... 2 F 1,
716 .................... 2 E 1,
717 .................... 2 E 1,
718 .................... 2 F 1,
719 .................... 2 E 1,
720 .................... 2 C 1,
721 .................... 1 A 2,
722 .................... 1 GIS 1,
723 .................... 1 H 1,
724 .................... 2 E 1,
725 .................... 2 D 1,
726 .................... 1 H 1,
727 .................... 2 C 1,
728 .................... 1 A 2,
729 .................... Space 2,
730 .................... 1 H 2,
731 .................... 2 C 2,
732 .................... Space 2,
733 .................... 2 D 2,
734 .................... 2 E 1,
735 .................... 2 E 1,
736 .................... 2 E 1,
737 .................... 2 D 1,
738 .................... 1 H 1,
739 .................... 2 C 1,
740 .................... 1 A 2,
741 ....................
742 .................... END
743 ....................
744 .................... #include "Skladby\Medvedi.txt"
745 .................... // Pisnicka "Medvedi"
746 .................... //
747 .................... // Tato pisnicka je napsana ve formatu, ktery se da pouzit jak pro primy
748 .................... // preklad do firmwaru melodickeho zvonku tak i pro dodatecne nahrani
749 ....................
750 .................... BEGIN 1, // Zacatek skladby
751 .................... TEMPO 150, // Delka nejkratsi noty v ms
752 .................... PAUSE 100, // Delka mezery mezi notami
753 ....................
754 .................... 1 C 1, // 1
755 .................... 1 C 1,
756 .................... 1 C 1,
757 .................... 1 E 1,
758 .................... 1 D 1,
759 .................... 0 G 1,
760 ....................
761 .................... 1 C 3, // 2
762 .................... Space 4,
763 ....................
764 .................... 1 E 1, // 3
765 .................... 1 E 1,
766 .................... 1 E 1,
767 .................... 1 E 1,
768 .................... 1 D 1,
769 .................... 1 G 1,
770 ....................
771 .................... 1 E 2, // 4
772 .................... Space 4,
773 ....................
774 .................... 1 G 1, // 5
775 .................... 1 G 1,
776 .................... 1 A 1,
777 .................... 1 G 1,
778 .................... 1 F 1,
779 .................... 1 E 1,
780 ....................
781 .................... 1 F 1, // 6
782 .................... 1 A 1,
783 .................... 1 G 1,
784 .................... 1 F 1,
785 .................... 1 E 1,
786 .................... 1 D 1,
787 ....................
788 .................... 1 C 1, // 7
789 .................... 0 H 1,
790 .................... 1 C 1,
791 .................... 1 E 1,
792 .................... 1 D 1,
793 .................... 0 G 1,
794 ....................
795 .................... 1 C 3, // 8
796 .................... Space 4,
797 .................... 1 A 1, // 9
798 .................... 1 A 1,
799 .................... 1 A 1,
800 .................... 1 A 1,
801 .................... 1 H 1,
802 .................... 2 D 1,
803 ....................
804 .................... 2 C 4, // 10
805 .................... Space 2,
806 ....................
807 .................... 2 E 1, // 11
808 .................... 2 E 1,
809 .................... 2 E 1,
810 .................... 2 E 1,
811 .................... 2 D 1,
812 .................... 2 G 1,
813 ....................
814 .................... 2 E 4, // 12
815 .................... Space 2,
816 ....................
817 .................... 2 G 1, // 13
818 .................... 2 G 1,
819 .................... 2 A 1,
820 .................... 2 G 1,
821 .................... 2 F 1,
822 .................... 2 E 1,
823 ....................
824 .................... 2 F 1, // 14
825 .................... 2 A 1,
826 .................... 2 G 1,
827 .................... 2 F 1,
828 .................... 2 E 1,
829 .................... 2 D 1,
830 ....................
831 .................... 2 C 1, // 15
832 .................... 1 H 1,
833 .................... 2 C 1,
834 .................... 2 E 1,
835 .................... 2 D 1,
836 .................... 1 G 1,
837 ....................
838 .................... 2 C 4, // 16
839 .................... Space 2,
840 ....................
841 .................... 1 C 6, // 1
842 .................... 0 G 2,
843 ....................
844 .................... 1 D 3, // 2
845 .................... Space 3,
846 ....................
847 .................... 1 G 1, // 3
848 .................... 1 G 1,
849 .................... 1 Fis 1,
850 .................... 1 G 1,
851 .................... 1 A 1,
852 .................... 1 Fis 1,
853 ....................
854 .................... 1 G 2, // 4
855 .................... Space 4,
856 ....................
857 .................... 1 G 1, // 5
858 .................... 1 G 1,
859 .................... 1 A 1,
860 .................... 1 G 1,
861 .................... 1 F 1,
862 .................... 1 E 1,
863 ....................
864 .................... 1 F 1, // 6
865 .................... 1 A 1,
866 .................... 1 G 1,
867 .................... 1 F 1,
868 .................... 1 E 1,
869 .................... 1 D 1,
870 ....................
871 .................... 1 C 6, // 7
872 .................... 1 E 2,
873 ....................
874 .................... 1 D 3, // 8
875 .................... Space 3,
876 ....................
877 .................... 1 C 6, // 9
878 .................... 0 G 2,
879 ....................
880 .................... 1 D 3, // 10
881 .................... Space 3,
882 ....................
883 .................... 1 G 1, // 11
884 .................... 1 G 1,
885 .................... 1 Fis 1,
886 .................... 1 G 1,
887 .................... 1 A 1,
888 .................... 1 Fis 1,
889 ....................
890 .................... 1 G 2, // 12
891 .................... Space 4,
892 ....................
893 .................... 1 G 1, // 13
894 .................... 1 G 1,
895 .................... 1 A 1,
896 .................... 1 G 1,
897 .................... 1 F 1,
898 .................... 1 E 1,
899 ....................
900 .................... 1 F 1, // 14
901 .................... 1 A 1,
902 .................... 1 G 1,
903 .................... 1 F 1,
904 .................... 1 E 1,
905 .................... 1 D 1,
906 ....................
907 .................... 1 C 1, // 15
908 .................... 0 H 1,
909 .................... 1 C 1,
910 .................... 1 E 1,
911 .................... 1 D 1,
912 .................... 0 G 1,
913 ....................
914 .................... 1 C 2, // 16
915 .................... Space 4,
916 ....................
917 .................... END
918 ....................
919 ....................
920 .................... // Koncova znacka a konec oblasti pro skladby
921 .................... ENDOFDATA
922 .................... }
923 ....................
924 .................... // Zruseni definic maker pro definici skladeb
925 .................... // V dalsim programu uz nebudou potreba
926 .................... #undef BEGIN
927 .................... #undef TEMPO
928 .................... #undef PAUSE
929 .................... #undef END
930 .................... #undef C
931 .................... #undef Cis
932 .................... #undef D
933 .................... #undef Dis
934 .................... #undef E
935 .................... #undef F
936 .................... #undef Fis
937 .................... #undef G
938 .................... #undef Gis
939 .................... #undef A
940 .................... #undef Ais
941 .................... #undef H
942 .................... #undef Space
943 ....................
944 ....................
945 .................... #define RXD PIN_B1 // Port pro RS232
946 .................... #use delay(CLOCK=20000000,RESTART_WDT) // Konfigurace pro casovani RS232
947 .................... #use rs232(BAUD=9600,RCV=RXD,RESTART_WDT,INVERT,PARITY=N,BITS=8) // Prenosove parametry RS232
948 *
949 0153: MOVLW 08
950 0154: MOVWF 77
951 0155: BSF 03.5
952 0156: BSF 06.1
953 0157: CLRWDT
954 0158: BCF 03.5
955 0159: BTFSC 06.1
956 015A: GOTO 15D
957 015B: BSF 03.5
958 015C: GOTO 157
959 015D: CLRF 61
960 015E: BSF 77.7
961 015F: GOTO 16E
962 0160: BCF 77.7
963 0161: GOTO 16E
964 0162: BCF 03.0
965 0163: BTFSS 06.1
966 0164: BSF 03.0
967 0165: RRF 61,F
968 0166: BSF 77.6
969 0167: GOTO 16E
970 0168: BCF 77.6
971 0169: DECFSZ 77,F
972 016A: GOTO 162
973 016B: MOVF 61,W
974 016C: MOVWF 78
975 016D: GOTO 17A
976 016E: MOVLW A7
977 016F: BTFSC 77.7
978 0170: MOVLW 2D
979 0171: MOVWF 78
980 0172: DECFSZ 78,F
981 0173: GOTO 172
982 0174: NOP
983 0175: BTFSC 77.7
984 0176: GOTO 160
985 0177: BTFSC 77.6
986 0178: GOTO 168
987 0179: GOTO 162
988 017A: RETLW 00
989 ....................
990 ....................
991 .................... // Sada globalnich promennych
992 .................... // --------------------------
993 .................... // Vyuzivame globalni promenne protoze je to vyhodne z hlediska spotreby zdroju. Usetri
994 .................... // se vyznmane mnoho pameti programu pri predavani parametru
995 ....................
996 ....................
997 .................... unsigned int16 Adr; // Adresovy ukazatel do pameti skladeb
998 .................... unsigned int16 Data; // Prectena data nebo data pro zapis
999 .................... unsigned int1 Mode; // 0=rezim testovani, 1=rezim zapisu do FLASH
1000 ....................
1001 .................... unsigned int16 Tempo; // Tempo (delka nejkratsi skladby v ms)
1002 .................... unsigned int16 Pause; // Delka mezery mezi notami v ms
1003 .................... unsigned int8 Octava; // Posunuti skladby v oktavach
1004 ....................
1005 .................... unsigned int8 Beep; // Druh pipnuti pro proceduru SoundSpec
1006 .................... unsigned int1 Error; // Priznak chyby
1007 ....................
1008 .................... unsigned int8 CisloSkladby; // Cislo skladby pro proceduru Find a Play
1009 ....................
1010 ....................
1011 .................... // Zvuky, posloupnost zadaneho poctu tonu
1012 .................... #define SoundEndOfLine 0x01 // Kratke pipnuti na konci radky
1013 .................... #define SoundPGM 0x03 // Trilek pri vstupu do rezimu programovani
1014 .................... #define SoundPostPlay 0x03 // Po ukonceni prehravani
1015 .................... #define SoundERASE 0x02 // Zvuk pri smazani bloku FLASH pameti
1016 .................... #define SoundERR 0x05 // Chyba syntaxe
1017 ....................
1018 .................... void SpecBeep()
1019 .................... // Data - pocet pipnuti, 0 znamena ticho
1020 .................... {
1021 .................... int Oct;
1022 ....................
1023 .................... if (Error) Beep=SoundERR;
1024 *
1025 013B: BTFSS 2D.1
1026 013C: GOTO 13F
1027 013D: MOVLW 05
1028 013E: MOVWF 33
1029 ....................
1030 .................... for(Oct=2;Beep!=0;Beep--)
1031 013F: MOVLW 02
1032 0140: MOVWF 61
1033 0141: MOVF 33,F
1034 0142: BTFSC 03.2
1035 0143: GOTO 151
1036 .................... {
1037 .................... SoundNote(SOUND_A,Oct++,50);
1038 0144: MOVF 61,W
1039 0145: INCF 61,F
1040 0146: MOVWF 62
1041 0147: MOVLW 09
1042 0148: MOVWF 69
1043 0149: MOVF 62,W
1044 014A: MOVWF 6A
1045 014B: CLRF 6C
1046 014C: MOVLW 32
1047 014D: MOVWF 6B
1048 014E: CALL 0E2
1049 .................... }
1050 014F: DECF 33,F
1051 0150: GOTO 141
1052 ....................
1053 .................... Error=0;
1054 0151: BCF 2D.1
1055 0152: RETLW 00
1056 .................... }
1057 ....................
1058 ....................
1059 .................... // Precti slovo z pameti programu
1060 .................... int16 ReadData()
1061 .................... // Adr - adresa ze ktere se cte
1062 .................... // Data - prectena data
1063 .................... {
1064 .................... int8 a,b; // Pomocne promenne
1065 ....................
1066 .................... (int8)*EEADR = Adr; // Adresa, spodni cast
1067 *
1068 01EF: MOVF 29,W
1069 01F0: BSF 03.6
1070 01F1: MOVWF 0D
1071 .................... (int8)*EEADRH = Adr >> 8; // Adresa, horni cast
1072 01F2: BCF 03.6
1073 01F3: MOVF 2A,W
1074 01F4: BSF 03.6
1075 01F5: MOVWF 0F
1076 .................... bit_set(*EECON1,EECON1_EEPGD); // Pamet programu
1077 01F6: BSF 03.5
1078 01F7: BSF 0C.7
1079 .................... bit_set(*EECON1,EECON1_RD); // Operace cteni
1080 01F8: BSF 0C.0
1081 .................... #ASM
1082 .................... nop; // Povinne nop
1083 01F9: NOP
1084 .................... nop;
1085 .................... #ENDASM
1086 01FA: NOP
1087 .................... a = (int8)*EEDATA; // Prevezmi data
1088 01FB: BCF 03.5
1089 01FC: MOVF 0C,W
1090 01FD: BCF 03.6
1091 01FE: MOVWF 61
1092 .................... b = (int8)*EEDATAH;
1093 01FF: BSF 03.6
1094 0200: MOVF 0E,W
1095 0201: BCF 03.6
1096 0202: MOVWF 62
1097 .................... Data=make16(b,a); // Sestav vysledek ze 2 bajtu
1098 0203: MOVF 62,W
1099 0204: MOVWF 2C
1100 0205: MOVF 61,W
1101 0206: MOVWF 2B
1102 0207: RETLW 00
1103 .................... }
1104 ....................
1105 ....................
1106 .................... // Smazani cele pameti vyhrazene pro skladby
1107 .................... void Erase()
1108 .................... {
1109 .................... for(Adr=STARTMEM; Adr<=ENDMEM; Adr++) // Cela oblast
1110 *
1111 0482: MOVLW 06
1112 0483: MOVWF 2A
1113 0484: CLRF 29
1114 0485: MOVF 2A,W
1115 0486: SUBLW 07
1116 0487: BTFSS 03.0
1117 0488: GOTO 4B8
1118 .................... {
1119 .................... ReadData();
1120 0489: CALL 1EF
1121 .................... if (Data!=0x3FFF) // Mazu jen bloky, ktere to potrebuji
1122 048A: INCFSZ 2B,W
1123 048B: GOTO 490
1124 048C: MOVF 2C,W
1125 048D: SUBLW 3F
1126 048E: BTFSC 03.2
1127 048F: GOTO 4B4
1128 .................... {
1129 .................... if (input(POWER_PIC)!=0) return; // Nezapisuj pokud neni jumper povoleni programovani
1130 0490: BSF 03.5
1131 0491: BSF 05.3
1132 0492: MOVLW 00
1133 0493: BCF 03.5
1134 0494: BTFSC 05.3
1135 0495: MOVLW 01
1136 0496: XORLW 00
1137 0497: BTFSC 03.2
1138 0498: GOTO 49A
1139 0499: GOTO 4B8
1140 .................... (int8)*EEADR = Adr; // Adresa bloku, spodni cast
1141 049A: MOVF 29,W
1142 049B: BSF 03.6
1143 049C: MOVWF 0D
1144 .................... (int8)*EEADRH = Adr >> 8; // Adresa bloku, horni cast
1145 049D: BCF 03.6
1146 049E: MOVF 2A,W
1147 049F: BSF 03.6
1148 04A0: MOVWF 0F
1149 .................... bit_set(*EECON1,EECON1_EEPGD); // Pamet programu
1150 04A1: BSF 03.5
1151 04A2: BSF 0C.7
1152 .................... bit_set(*EECON1,EECON1_WREN); // Povolit zapis
1153 04A3: BSF 0C.2
1154 .................... bit_set(*EECON1,EECON1_FREE); // Operace mazani
1155 04A4: BSF 0C.4
1156 .................... (int8)*EECON2 = 0x55; // Povinna sekvence pro zapis
1157 04A5: MOVLW 55
1158 04A6: MOVWF 0D
1159 .................... (int8)*EECON2 = 0xAA;
1160 04A7: MOVLW AA
1161 04A8: MOVWF 0D
1162 .................... bit_set(*EECON1,EECON1_WR); // Zahajeni mazani
1163 04A9: BSF 0C.1
1164 .................... #ASM
1165 .................... nop; // Povinne prazdne instrukce
1166 04AA: NOP
1167 .................... nop;
1168 .................... #ENDASM
1169 04AB: NOP
1170 .................... bit_clear(*EECON1,EECON1_WREN); // Uz ne zapis
1171 04AC: BCF 0C.2
1172 .................... bit_clear(*EECON1,EECON1_FREE); // Uz ne mazani
1173 04AD: BCF 0C.4
1174 .................... bit_clear(*EECON1,EECON1_EEPGD); // Uz ne pamet programu
1175 04AE: BCF 0C.7
1176 .................... Beep=SoundERASE;
1177 04AF: MOVLW 02
1178 04B0: BCF 03.5
1179 04B1: BCF 03.6
1180 04B2: MOVWF 33
1181 .................... SpecBeep();
1182 04B3: CALL 13B
1183 .................... }
1184 .................... }
1185 04B4: INCF 29,F
1186 04B5: BTFSC 03.2
1187 04B6: INCF 2A,F
1188 04B7: GOTO 485
1189 .................... }
1190 ....................
1191 ....................
1192 .................... // Zapis do pameti programu po jednotlivych slovech.
1193 .................... // Soucastka vyzaduje zapis vzdy celych osmi slov najednou. Vyuziva se toho, ze pamet FLASH
1194 .................... // umi zapisovat jen smerem do nuly a tak staci na pozice, ktere zrovna nechceme programovat
1195 .................... // zapsat same jednicky cimz se stav jejich stav nezmeni.
1196 .................... void WriteData()
1197 .................... // Adr - adresa, kam se bude zapisovat
1198 .................... // Data - data, ktera se budou zapisovat
1199 .................... {
1200 .................... int i;
1201 ....................
1202 .................... bit_set(*EECON1,EECON1_EEPGD); // Pamet programu
1203 *
1204 0304: BSF 03.5
1205 0305: BSF 03.6
1206 0306: BSF 0C.7
1207 .................... bit_set(*EECON1,EECON1_WREN); // Zapis
1208 0307: BSF 0C.2
1209 .................... (int8)*EEADR = Adr & ~3; // Adresa, spodni cast, zaokrouhleno dolu na nasobek 8
1210 0308: BCF 03.5
1211 0309: BCF 03.6
1212 030A: MOVF 29,W
1213 030B: ANDLW FC
1214 030C: BSF 03.6
1215 030D: MOVWF 0D
1216 .................... (int8)*EEADRH = Adr >> 8; // Adresa, horni cast
1217 030E: BCF 03.6
1218 030F: MOVF 2A,W
1219 0310: BSF 03.6
1220 0311: MOVWF 0F
1221 .................... for (i=0; i<4; i++)
1222 0312: BCF 03.6
1223 0313: CLRF 61
1224 0314: MOVF 61,W
1225 0315: SUBLW 03
1226 0316: BTFSS 03.0
1227 0317: GOTO 33F
1228 .................... {
1229 .................... if ((Adr & 3) == i) // Pokud je adresa slova v bloku totozna s pozadovanou
1230 0318: MOVF 29,W
1231 0319: ANDLW 03
1232 031A: MOVWF 62
1233 031B: MOVF 2A,W
1234 031C: ANDLW 00
1235 031D: MOVWF 63
1236 031E: MOVF 61,W
1237 031F: SUBWF 62,W
1238 0320: BTFSS 03.2
1239 0321: GOTO 32E
1240 0322: MOVF 63,F
1241 0323: BTFSS 03.2
1242 0324: GOTO 32E
1243 .................... {
1244 .................... (int8)*EEDATA =Data; // Platne slovo, spodni cast
1245 0325: MOVF 2B,W
1246 0326: BSF 03.6
1247 0327: MOVWF 0C
1248 .................... (int8)*EEDATAH=Data >> 8; // Platne slovo, horni cast
1249 0328: BCF 03.6
1250 0329: MOVF 2C,W
1251 032A: BSF 03.6
1252 032B: MOVWF 0E
1253 .................... }
1254 .................... else // Ostatni bunky nemenime
1255 032C: GOTO 332
1256 032D: BCF 03.6
1257 .................... {
1258 .................... (int8)*EEDATA =0xFF; // Zbytek same jednicky
1259 032E: MOVLW FF
1260 032F: BSF 03.6
1261 0330: MOVWF 0C
1262 .................... (int8)*EEDATAH=0xFF;
1263 0331: MOVWF 0E
1264 .................... }
1265 .................... (int8)*EECON2 = 0x55; // Povinna sekvence pro zapis
1266 0332: MOVLW 55
1267 0333: BSF 03.5
1268 0334: MOVWF 0D
1269 .................... (int8)*EECON2 = 0xAA;
1270 0335: MOVLW AA
1271 0336: MOVWF 0D
1272 .................... bit_set(*EECON1,EECON1_WR); // Zahajeni zapisu
1273 0337: BSF 0C.1
1274 .................... #ASM
1275 .................... nop; // Povinne dve prazdne instrukce
1276 0338: NOP
1277 .................... nop;
1278 .................... #ENDASM
1279 0339: NOP
1280 .................... ((int8)*EEADR) ++; // Dalsi slovo
1281 033A: BCF 03.5
1282 033B: INCF 0D,F
1283 .................... }
1284 033C: BCF 03.6
1285 033D: INCF 61,F
1286 033E: GOTO 314
1287 .................... bit_clear(*EECON1,EECON1_WREN); // Konec zapisu
1288 033F: BSF 03.5
1289 0340: BSF 03.6
1290 0341: BCF 0C.2
1291 .................... bit_clear(*EECON1,EECON1_EEPGD); // Uz ne pamet programu (bezpecnost)
1292 0342: BCF 0C.7
1293 .................... }
1294 ....................
1295 ....................
1296 .................... // Zapise data Data na adresu Adr a provede posun na dalsi adresu, zapisuje se jen do
1297 .................... // dovolene oblasti pameti a jen v pripade, ze je Mode=1
1298 .................... void WriteDataInc()
1299 .................... // Data - co se zapisuje
1300 .................... // Adr - kam se zapisuje, po zapisu se adresa posouva
1301 .................... {
1302 .................... if (~Mode) return; // Neni rezim zapisu
1303 *
1304 02E0: BTFSC 2D.0
1305 02E1: GOTO 2E3
1306 02E2: GOTO 34A
1307 .................... if ( (Adr>=STARTMEM) & (Adr<=ENDMEM) & (input(POWER_PIC)==0) )
1308 02E3: MOVF 2A,W
1309 02E4: SUBLW 05
1310 02E5: BTFSS 03.0
1311 02E6: GOTO 2E9
1312 02E7: MOVLW 00
1313 02E8: GOTO 2EA
1314 02E9: MOVLW 01
1315 02EA: MOVWF 61
1316 02EB: MOVF 2A,W
1317 02EC: SUBLW 07
1318 02ED: BTFSC 03.0
1319 02EE: GOTO 2F1
1320 02EF: MOVLW 00
1321 02F0: GOTO 2F2
1322 02F1: MOVLW 01
1323 02F2: ANDWF 61,W
1324 02F3: MOVWF 62
1325 02F4: BSF 03.5
1326 02F5: BSF 05.3
1327 02F6: MOVLW 00
1328 02F7: BCF 03.5
1329 02F8: BTFSC 05.3
1330 02F9: MOVLW 01
1331 02FA: XORLW 00
1332 02FB: BTFSC 03.2
1333 02FC: GOTO 2FF
1334 02FD: MOVLW 00
1335 02FE: GOTO 300
1336 02FF: MOVLW 01
1337 0300: ANDWF 62,W
1338 0301: XORLW 00
1339 0302: BTFSC 03.2
1340 0303: GOTO 349
1341 .................... {
1342 .................... WriteData();
1343 .................... Adr++;
1344 *
1345 0343: BCF 03.5
1346 0344: BCF 03.6
1347 0345: INCF 29,F
1348 0346: BTFSC 03.2
1349 0347: INCF 2A,F
1350 .................... }
1351 .................... else
1352 0348: GOTO 34A
1353 .................... {
1354 .................... Error=1;
1355 0349: BSF 2D.1
1356 .................... }
1357 034A: RETLW 00
1358 .................... }
1359 ....................
1360 ....................
1361 .................... // Najdi zacatek zadaneho cisla skladby. Promenna Adr ukazuje na zacatek skladby.
1362 .................... // Neni-li skladba nalezena ukazuje Adr na koncovou znacku (0x3FFF) posledni skladby
1363 .................... // nebo na konec pameti.
1364 .................... int1 Find()
1365 .................... // CisloSkladby - poradove cislo skladby
1366 .................... // Adr - adresa zacatku skladby
1367 .................... {
1368 .................... Adr=STARTMEM-1; // Od zacatku oblasti pro skladby
1369 *
1370 0208: MOVLW 05
1371 0209: MOVWF 2A
1372 020A: MOVLW FF
1373 020B: MOVWF 29
1374 .................... for(;1;)
1375 .................... {
1376 .................... Adr++;
1377 020C: INCF 29,F
1378 020D: BTFSC 03.2
1379 020E: INCF 2A,F
1380 .................... ReadData(); // Precti data
1381 020F: CALL 1EF
1382 .................... if (Data==ENDOFDATA) return 1; // Priznak konce dat
1383 0210: INCFSZ 2B,W
1384 0211: GOTO 219
1385 0212: MOVF 2C,W
1386 0213: SUBLW 3F
1387 0214: BTFSS 03.2
1388 0215: GOTO 219
1389 0216: MOVLW 01
1390 0217: MOVWF 78
1391 0218: GOTO 236
1392 .................... if (Adr==ENDMEM+1) return 1; // Uz jsme prosli celou pamet
1393 0219: MOVF 29,F
1394 021A: BTFSS 03.2
1395 021B: GOTO 223
1396 021C: MOVF 2A,W
1397 021D: SUBLW 08
1398 021E: BTFSS 03.2
1399 021F: GOTO 223
1400 0220: MOVLW 01
1401 0221: MOVWF 78
1402 0222: GOTO 236
1403 .................... if ((Data&MASKBEGIN)==DATABEGIN) // Priznak zacatku skladby
1404 0223: MOVF 2B,W
1405 0224: ANDLW 00
1406 0225: MOVWF 61
1407 0226: MOVF 2C,W
1408 0227: ANDLW 38
1409 0228: MOVWF 62
1410 0229: MOVF 61,F
1411 022A: BTFSS 03.2
1412 022B: GOTO 235
1413 022C: MOVF 62,W
1414 022D: SUBLW 20
1415 022E: BTFSS 03.2
1416 022F: GOTO 235
1417 .................... {
1418 .................... CisloSkladby--; // Otestuj pocitadlo skladeb
1419 0230: DECFSZ 34,F
1420 .................... if (CisloSkladby==0) return 0; // Je to tato skladba
1421 0231: GOTO 235
1422 0232: MOVLW 00
1423 0233: MOVWF 78
1424 0234: GOTO 236
1425 .................... }
1426 .................... }
1427 0235: GOTO 20C
1428 0236: RETLW 00
1429 .................... }
1430 ....................
1431 ....................
1432 .................... // Zahraj jednu notu
1433 .................... void PlayData()
1434 .................... // Data = zakodovana nota
1435 .................... // Tempo, Octava, Pause = parametry hrane noty
1436 .................... {
1437 .................... SoundNote((int8)Data&0xF,Octava+(((int8)Data>>4)&0x7),Tempo*((Data>>7)&0x3F)); // Nota
1438 0237: MOVF 2B,W
1439 0238: ANDLW 0F
1440 0239: MOVWF 61
1441 023A: SWAPF 2B,W
1442 023B: MOVWF 77
1443 023C: MOVLW 0F
1444 023D: ANDWF 77,F
1445 023E: MOVF 77,W
1446 023F: ANDLW 07
1447 0240: ADDWF 32,W
1448 0241: MOVWF 63
1449 0242: RRF 2C,W
1450 0243: MOVWF 65
1451 0244: RRF 2B,W
1452 0245: MOVWF 64
1453 0246: RRF 65,F
1454 0247: RRF 64,F
1455 0248: RRF 65,F
1456 0249: RRF 64,F
1457 024A: RRF 65,F
1458 024B: RRF 64,F
1459 024C: RRF 65,F
1460 024D: RRF 64,F
1461 024E: RRF 65,F
1462 024F: RRF 64,F
1463 0250: RRF 65,F
1464 0251: RRF 64,F
1465 0252: MOVLW 01
1466 0253: ANDWF 65,F
1467 0254: MOVF 64,W
1468 0255: ANDLW 3F
1469 0256: MOVWF 77
1470 0257: MOVF 65,W
1471 0258: ANDLW 00
1472 0259: MOVWF 7A
1473 025A: MOVF 77,W
1474 025B: MOVWF 66
1475 025C: MOVF 7A,W
1476 025D: MOVWF 67
1477 025E: MOVF 2F,W
1478 025F: MOVWF 69
1479 0260: MOVF 2E,W
1480 0261: MOVWF 68
1481 0262: MOVF 7A,W
1482 0263: MOVWF 6B
1483 0264: MOVF 77,W
1484 0265: MOVWF 6A
1485 0266: CALL 17B
1486 0267: MOVF 79,W
1487 0268: MOVWF 68
1488 0269: MOVF 78,W
1489 026A: MOVWF 67
1490 026B: MOVF 61,W
1491 026C: MOVWF 69
1492 026D: MOVF 63,W
1493 026E: MOVWF 6A
1494 026F: MOVF 79,W
1495 0270: MOVWF 6C
1496 0271: MOVF 78,W
1497 0272: MOVWF 6B
1498 0273: CALL 0E2
1499 .................... SoundNote(SOUND_Space,0,Pause); // Mezera
1500 0274: MOVLW 0C
1501 0275: MOVWF 69
1502 0276: CLRF 6A
1503 0277: MOVF 31,W
1504 0278: MOVWF 6C
1505 0279: MOVF 30,W
1506 027A: MOVWF 6B
1507 027B: CALL 0E2
1508 027C: RETLW 00
1509 .................... }
1510 ....................
1511 ....................
1512 .................... // Zahraj skladbu od zadane adresy v promenne Adr.
1513 .................... void Play()
1514 .................... // CisloSkladby - cislo skladby k hrani
1515 .................... {
1516 .................... if (Find()) // Najdi zacatek skladby v pameti skladeb
1517 027D: CALL 208
1518 027E: MOVF 78,F
1519 027F: BTFSC 03.2
1520 0280: GOTO 282
1521 .................... {
1522 .................... return; // Skladba nenalezena
1523 0281: GOTO 2DF
1524 .................... }
1525 ....................
1526 .................... Tempo=100; // Default delka noty
1527 0282: CLRF 2F
1528 0283: MOVLW 64
1529 0284: MOVWF 2E
1530 .................... Pause=100; // Default mezera mezi notami
1531 0285: CLRF 31
1532 0286: MOVWF 30
1533 ....................
1534 .................... Octava=Data&~MASKBEGIN; // Posunuti oktav (povinna soucast zacatku skladby)
1535 0287: MOVF 2B,W
1536 0288: MOVWF 32
1537 .................... Adr++;
1538 0289: INCF 29,F
1539 028A: BTFSC 03.2
1540 028B: INCF 2A,F
1541 ....................
1542 .................... for (;1;)
1543 .................... {
1544 .................... if (Adr==ENDMEM+1) return; // Konec pametove oblasti
1545 028C: MOVF 29,F
1546 028D: BTFSS 03.2
1547 028E: GOTO 294
1548 028F: MOVF 2A,W
1549 0290: SUBLW 08
1550 0291: BTFSS 03.2
1551 0292: GOTO 294
1552 0293: GOTO 2DF
1553 .................... ReadData(); // Vezmi data
1554 0294: CALL 1EF
1555 .................... Adr++; // Posun adresu
1556 0295: INCF 29,F
1557 0296: BTFSC 03.2
1558 0297: INCF 2A,F
1559 .................... if (Data==ENDOFDATA) return; // Konec dat
1560 0298: INCFSZ 2B,W
1561 0299: GOTO 29F
1562 029A: MOVF 2C,W
1563 029B: SUBLW 3F
1564 029C: BTFSS 03.2
1565 029D: GOTO 29F
1566 029E: GOTO 2DF
1567 .................... if ((Data&MASKBEGIN)==DATABEGIN) return; // Zacatek dalsi skladby
1568 029F: MOVF 2B,W
1569 02A0: ANDLW 00
1570 02A1: MOVWF 61
1571 02A2: MOVF 2C,W
1572 02A3: ANDLW 38
1573 02A4: MOVWF 62
1574 02A5: MOVF 61,F
1575 02A6: BTFSS 03.2
1576 02A7: GOTO 2AD
1577 02A8: MOVF 62,W
1578 02A9: SUBLW 20
1579 02AA: BTFSS 03.2
1580 02AB: GOTO 2AD
1581 02AC: GOTO 2DF
1582 .................... if ((Data&MASKTEMPO)==DATATEMPO) Tempo=Data&~DATATEMPO; // Paramter TEMPO
1583 02AD: MOVF 2B,W
1584 02AE: ANDLW 00
1585 02AF: MOVWF 61
1586 02B0: MOVF 2C,W
1587 02B1: ANDLW 38
1588 02B2: MOVWF 62
1589 02B3: MOVF 61,F
1590 02B4: BTFSS 03.2
1591 02B5: GOTO 2BF
1592 02B6: MOVF 62,W
1593 02B7: SUBLW 28
1594 02B8: BTFSS 03.2
1595 02B9: GOTO 2BF
1596 02BA: MOVF 2B,W
1597 02BB: MOVWF 2E
1598 02BC: MOVF 2C,W
1599 02BD: ANDLW D7
1600 02BE: MOVWF 2F
1601 .................... if ((Data&MASKPAUSE)==DATAPAUSE) Pause=Data&~DATAPAUSE; // Parametr PAUSE
1602 02BF: MOVF 2B,W
1603 02C0: ANDLW 00
1604 02C1: MOVWF 61
1605 02C2: MOVF 2C,W
1606 02C3: ANDLW 38
1607 02C4: MOVWF 62
1608 02C5: MOVF 61,F
1609 02C6: BTFSS 03.2
1610 02C7: GOTO 2D1
1611 02C8: MOVF 62,W
1612 02C9: SUBLW 30
1613 02CA: BTFSS 03.2
1614 02CB: GOTO 2D1
1615 02CC: MOVF 2B,W
1616 02CD: MOVWF 30
1617 02CE: MOVF 2C,W
1618 02CF: ANDLW CF
1619 02D0: MOVWF 31
1620 .................... if ((Data&MASKNOTE)==0) // Nota
1621 02D1: MOVF 2B,W
1622 02D2: ANDLW 00
1623 02D3: MOVWF 61
1624 02D4: MOVF 2C,W
1625 02D5: ANDLW 20
1626 02D6: MOVWF 62
1627 02D7: MOVF 61,F
1628 02D8: BTFSS 03.2
1629 02D9: GOTO 2DE
1630 02DA: MOVF 62,F
1631 02DB: BTFSS 03.2
1632 02DC: GOTO 2DE
1633 .................... {
1634 .................... PlayData(); // Zahraj notu
1635 02DD: CALL 237
1636 .................... }
1637 .................... }
1638 02DE: GOTO 28C
1639 02DF: RETLW 00
1640 .................... }
1641 ....................
1642 ....................
1643 .................... // Vycisli cislo z bufferu, posune ukazovatko na prvni nezpracovany znak, preskakuje mezery
1644 .................... int16 Number(char line[], int *a, len)
1645 .................... {
1646 .................... int16 Data;
1647 .................... char c;
1648 ....................
1649 .................... while((line[*a]==' ')&(*a<len)) // Vynech mezery na zacatku
1650 *
1651 0190: MOVF 62,W
1652 0191: MOVWF 04
1653 0192: MOVF 61,W
1654 0193: ADDWF 00,W
1655 0194: MOVWF 04
1656 0195: MOVF 00,W
1657 0196: SUBLW 20
1658 0197: BTFSC 03.2
1659 0198: GOTO 19B
1660 0199: MOVLW 00
1661 019A: GOTO 19C
1662 019B: MOVLW 01
1663 019C: MOVWF 69
1664 019D: MOVF 62,W
1665 019E: MOVWF 04
1666 019F: MOVF 63,W
1667 01A0: SUBWF 00,W
1668 01A1: BTFSS 03.0
1669 01A2: GOTO 1A5
1670 01A3: MOVLW 00
1671 01A4: GOTO 1A6
1672 01A5: MOVLW 01
1673 01A6: ANDWF 69,W
1674 01A7: XORLW 00
1675 01A8: BTFSC 03.2
1676 01A9: GOTO 1AE
1677 .................... (*a)++; // Posouvej ukazovatko
1678 01AA: MOVF 62,W
1679 01AB: MOVWF 04
1680 01AC: INCF 00,F
1681 01AD: GOTO 190
1682 ....................
1683 .................... Data=0;
1684 01AE: CLRF 65
1685 01AF: CLRF 64
1686 .................... while (1)
1687 .................... {
1688 .................... if (*a>=len) return Data; // Konec retezce
1689 01B0: MOVF 62,W
1690 01B1: MOVWF 04
1691 01B2: MOVF 63,W
1692 01B3: SUBWF 00,W
1693 01B4: BTFSS 03.0
1694 01B5: GOTO 1BB
1695 01B6: MOVF 64,W
1696 01B7: MOVWF 78
1697 01B8: MOVF 65,W
1698 01B9: MOVWF 79
1699 01BA: GOTO 1EE
1700 .................... c=line[*a]; // Vezmi znak z pole
1701 01BB: MOVF 62,W
1702 01BC: MOVWF 04
1703 01BD: MOVF 61,W
1704 01BE: ADDWF 00,W
1705 01BF: MOVWF 04
1706 01C0: MOVF 00,W
1707 01C1: MOVWF 66
1708 .................... if ((c<'0')|(c>'9')) return Data; // Koncime pokud znak neni cislice
1709 01C2: MOVF 66,W
1710 01C3: SUBLW 2F
1711 01C4: BTFSC 03.0
1712 01C5: GOTO 1C8
1713 01C6: MOVLW 00
1714 01C7: GOTO 1C9
1715 01C8: MOVLW 01
1716 01C9: MOVWF 67
1717 01CA: MOVF 66,W
1718 01CB: SUBLW 39
1719 01CC: BTFSS 03.0
1720 01CD: GOTO 1D0
1721 01CE: MOVLW 00
1722 01CF: GOTO 1D1
1723 01D0: MOVLW 01
1724 01D1: IORWF 67,W
1725 01D2: XORLW 00
1726 01D3: BTFSC 03.2
1727 01D4: GOTO 1DA
1728 01D5: MOVF 64,W
1729 01D6: MOVWF 78
1730 01D7: MOVF 65,W
1731 01D8: MOVWF 79
1732 01D9: GOTO 1EE
1733 .................... Data = Data * 10 + (c-'0'); // Pouzij cislici
1734 01DA: MOVF 65,W
1735 01DB: MOVWF 69
1736 01DC: MOVF 64,W
1737 01DD: MOVWF 68
1738 01DE: CLRF 6B
1739 01DF: MOVLW 0A
1740 01E0: MOVWF 6A
1741 01E1: CALL 17B
1742 01E2: MOVLW 30
1743 01E3: SUBWF 66,W
1744 01E4: ADDWF 78,W
1745 01E5: MOVWF 64
1746 01E6: MOVF 79,W
1747 01E7: MOVWF 65
1748 01E8: BTFSC 03.0
1749 01E9: INCF 65,F
1750 .................... (*a)++; // Dalsi znak
1751 01EA: MOVF 62,W
1752 01EB: MOVWF 04
1753 01EC: INCF 00,F
1754 .................... }
1755 01ED: GOTO 1B0
1756 01EE: RETLW 00
1757 .................... }
1758 ....................
1759 ....................
1760 .................... // Vyhledej klicove slovo a vrat jeho zkraceny kod
1761 .................... // Pokud slovo neexistuje vraci -1
1762 .................... // Format definice - retezec ukonceny nulou + zastupny znak, na konci prazdny retezec (nula)
1763 .................... const char KeyWords[] =
1764 .................... {
1765 .................... 'P','L','A','Y',0, 'P',
1766 .................... 'E','R','A','S','E',0, 'E',
1767 .................... 'T','E','M','P','O',0, 't',
1768 .................... 'P','A','U','S','E',0, 'p',
1769 .................... 'B','E','G','I','N',0, 'B',
1770 .................... 'T','E','S','T',0, 'b',
1771 .................... 'E','N','D',0, 'Z',
1772 .................... 'C',0. SOUND_C,
1773 .................... 'C','I','S',0, SOUND_Cis,
1774 .................... 'D',0, SOUND_D,
1775 .................... 'D','I','S',0, SOUND_Dis,
1776 .................... 'E',0, SOUND_E,
1777 .................... 'F',0, SOUND_F,
1778 .................... 'F','I','S',0, SOUND_Fis,
1779 .................... 'G',0, SOUND_G,
1780 .................... 'G','I','S',0, SOUND_Gis,
1781 .................... 'A',0, SOUND_A,
1782 .................... 'A','I','S',0, SOUND_Ais,
1783 .................... 'H',0, SOUND_H,
1784 .................... 'S','P','A','C','E',0, SOUND_Space
1785 .................... };
1786 *
1787 0051: BCF 0A.0
1788 0052: BCF 0A.1
1789 0053: BCF 0A.2
1790 0054: ADDWF 02,F
1791 0055: RETLW 50
1792 0056: RETLW 4C
1793 0057: RETLW 41
1794 0058: RETLW 59
1795 0059: RETLW 00
1796 005A: RETLW 50
1797 005B: RETLW 45
1798 005C: RETLW 52
1799 005D: RETLW 41
1800 005E: RETLW 53
1801 005F: RETLW 45
1802 0060: RETLW 00
1803 0061: RETLW 45
1804 0062: RETLW 54
1805 0063: RETLW 45
1806 0064: RETLW 4D
1807 0065: RETLW 50
1808 0066: RETLW 4F
1809 0067: RETLW 00
1810 0068: RETLW 74
1811 0069: RETLW 50
1812 006A: RETLW 41
1813 006B: RETLW 55
1814 006C: RETLW 53
1815 006D: RETLW 45
1816 006E: RETLW 00
1817 006F: RETLW 70
1818 0070: RETLW 42
1819 0071: RETLW 45
1820 0072: RETLW 47
1821 0073: RETLW 49
1822 0074: RETLW 4E
1823 0075: RETLW 00
1824 0076: RETLW 42
1825 0077: RETLW 54
1826 0078: RETLW 45
1827 0079: RETLW 53
1828 007A: RETLW 54
1829 007B: RETLW 00
1830 007C: RETLW 62
1831 007D: RETLW 45
1832 007E: RETLW 4E
1833 007F: RETLW 44
1834 0080: RETLW 00
1835 0081: RETLW 5A
1836 0082: RETLW 43
1837 0083: RETLW 00
1838 0084: RETLW 00
1839 0085: RETLW 43
1840 0086: RETLW 49
1841 0087: RETLW 53
1842 0088: RETLW 00
1843 0089: RETLW 01
1844 008A: RETLW 44
1845 008B: RETLW 00
1846 008C: RETLW 02
1847 008D: RETLW 44
1848 008E: RETLW 49
1849 008F: RETLW 53
1850 0090: RETLW 00
1851 0091: RETLW 03
1852 0092: RETLW 45
1853 0093: RETLW 00
1854 0094: RETLW 04
1855 0095: RETLW 46
1856 0096: RETLW 00
1857 0097: RETLW 05
1858 0098: RETLW 46
1859 0099: RETLW 49
1860 009A: RETLW 53
1861 009B: RETLW 00
1862 009C: RETLW 06
1863 009D: RETLW 47
1864 009E: RETLW 00
1865 009F: RETLW 07
1866 00A0: RETLW 47
1867 00A1: RETLW 49
1868 00A2: RETLW 53
1869 00A3: RETLW 00
1870 00A4: RETLW 08
1871 00A5: RETLW 41
1872 00A6: RETLW 00
1873 00A7: RETLW 09
1874 00A8: RETLW 41
1875 00A9: RETLW 49
1876 00AA: RETLW 53
1877 00AB: RETLW 00
1878 00AC: RETLW 0A
1879 00AD: RETLW 48
1880 00AE: RETLW 00
1881 00AF: RETLW 0B
1882 00B0: RETLW 53
1883 00B1: RETLW 50
1884 00B2: RETLW 41
1885 00B3: RETLW 43
1886 00B4: RETLW 45
1887 00B5: RETLW 00
1888 00B6: RETLW 0C
1889 .................... signed int Word(char line[], unsigned int8 *a, len)
1890 .................... {
1891 .................... unsigned int8 i; // Index do pole klicovych slov
1892 .................... unsigned int8 j; // index do zpracovavane radky
1893 ....................
1894 .................... while((line[*a]==' ')&(*a<len)) // Vynech mezery na zacatku
1895 *
1896 03A6: MOVF 62,W
1897 03A7: MOVWF 04
1898 03A8: MOVF 61,W
1899 03A9: ADDWF 00,W
1900 03AA: MOVWF 04
1901 03AB: MOVF 00,W
1902 03AC: SUBLW 20
1903 03AD: BTFSC 03.2
1904 03AE: GOTO 3B1
1905 03AF: MOVLW 00
1906 03B0: GOTO 3B2
1907 03B1: MOVLW 01
1908 03B2: MOVWF 68
1909 03B3: MOVF 62,W
1910 03B4: MOVWF 04
1911 03B5: MOVF 63,W
1912 03B6: SUBWF 00,W
1913 03B7: BTFSS 03.0
1914 03B8: GOTO 3BB
1915 03B9: MOVLW 00
1916 03BA: GOTO 3BC
1917 03BB: MOVLW 01
1918 03BC: ANDWF 68,W
1919 03BD: XORLW 00
1920 03BE: BTFSC 03.2
1921 03BF: GOTO 3C4
1922 .................... (*a)++; // Posouvej ukazovatko
1923 03C0: MOVF 62,W
1924 03C1: MOVWF 04
1925 03C2: INCF 00,F
1926 03C3: GOTO 3A6
1927 ....................
1928 .................... for (i=0;i<sizeof(KeyWords);) // Slova ze slovniku
1929 03C4: CLRF 64
1930 03C5: MOVF 64,W
1931 03C6: SUBLW 61
1932 03C7: BTFSS 03.0
1933 03C8: GOTO 430
1934 .................... {
1935 .................... for (j=*a;(j<len)&(KeyWords[i]!=0)&(KeyWords[i]==line[j]);i++,j++) // Znaky ze slova
1936 03C9: MOVF 62,W
1937 03CA: MOVWF 04
1938 03CB: MOVF 00,W
1939 03CC: MOVWF 65
1940 03CD: MOVF 63,W
1941 03CE: SUBWF 65,W
1942 03CF: BTFSS 03.0
1943 03D0: GOTO 3D3
1944 03D1: MOVLW 00
1945 03D2: GOTO 3D4
1946 03D3: MOVLW 01
1947 03D4: MOVWF 66
1948 03D5: MOVF 64,W
1949 03D6: CALL 051
1950 03D7: XORLW 00
1951 03D8: BTFSS 03.2
1952 03D9: GOTO 3DC
1953 03DA: MOVLW 00
1954 03DB: GOTO 3DD
1955 03DC: MOVLW 01
1956 03DD: ANDWF 66,W
1957 03DE: MOVWF 68
1958 03DF: MOVF 64,W
1959 03E0: CALL 051
1960 03E1: MOVWF 69
1961 03E2: MOVF 61,W
1962 03E3: ADDWF 65,W
1963 03E4: MOVWF 04
1964 03E5: MOVF 00,W
1965 03E6: SUBWF 69,W
1966 03E7: BTFSC 03.2
1967 03E8: GOTO 3EB
1968 03E9: MOVLW 00
1969 03EA: GOTO 3EC
1970 03EB: MOVLW 01
1971 03EC: ANDWF 68,W
1972 03ED: XORLW 00
1973 03EE: BTFSC 03.2
1974 03EF: GOTO 3F4
1975 .................... {
1976 .................... }
1977 03F0: MOVF 64,W
1978 03F1: INCF 64,F
1979 03F2: INCF 65,F
1980 03F3: GOTO 3CD
1981 .................... if ((KeyWords[i]==0)&((line[j]==' ')|(j==len)))
1982 03F4: MOVF 64,W
1983 03F5: CALL 051
1984 03F6: XORLW 00
1985 03F7: BTFSC 03.2
1986 03F8: GOTO 3FB
1987 03F9: MOVLW 00
1988 03FA: GOTO 3FC
1989 03FB: MOVLW 01
1990 03FC: MOVWF 67
1991 03FD: MOVF 61,W
1992 03FE: ADDWF 65,W
1993 03FF: MOVWF 04
1994 0400: MOVF 00,W
1995 0401: SUBLW 20
1996 0402: BTFSC 03.2
1997 0403: GOTO 406
1998 0404: MOVLW 00
1999 0405: GOTO 407
2000 0406: MOVLW 01
2001 0407: MOVWF 69
2002 0408: MOVF 63,W
2003 0409: SUBWF 65,W
2004 040A: BTFSC 03.2
2005 040B: GOTO 40E
2006 040C: MOVLW 00
2007 040D: GOTO 40F
2008 040E: MOVLW 01
2009 040F: IORWF 69,W
2010 0410: ANDWF 67,W
2011 0411: XORLW 00
2012 0412: BTFSC 03.2
2013 0413: GOTO 426
2014 .................... {
2015 .................... if (j>=len) j=len-1; // Korekce abychom se nedostali za konec retezce
2016 0414: MOVF 63,W
2017 0415: SUBWF 65,W
2018 0416: BTFSS 03.0
2019 0417: GOTO 41B
2020 0418: MOVLW 01
2021 0419: SUBWF 63,W
2022 041A: MOVWF 65
2023 .................... *a=j+1; // Posun ukazovatko za zpracovane slovo
2024 041B: MOVF 62,W
2025 041C: MOVWF 04
2026 041D: MOVLW 01
2027 041E: ADDWF 65,W
2028 041F: MOVWF 00
2029 ....................
2030 .................... return KeyWords[i+1]; // Vrat zastupnou hodnotu z tabulky klicovych slov
2031 0420: MOVLW 01
2032 0421: ADDWF 64,W
2033 0422: CALL 051
2034 0423: MOVWF 78
2035 0424: MOVWF 78
2036 0425: GOTO 432
2037 .................... }
2038 .................... while(KeyWords[i]!=0) i++; // Preskoc zbytek slova v tabulce
2039 0426: MOVF 64,W
2040 0427: CALL 051
2041 0428: XORLW 00
2042 0429: BTFSC 03.2
2043 042A: GOTO 42D
2044 042B: INCF 64,F
2045 042C: GOTO 426
2046 .................... i++; // Preskoc oddelovac
2047 042D: INCF 64,F
2048 .................... i++; // Preskoc polozku se zastupnou hodnotou
2049 042E: INCF 64,F
2050 .................... }
2051 042F: GOTO 3C5
2052 .................... return -1; // Prosli jsme cely slovnik a nedoslo ke shode
2053 0430: MOVLW FF
2054 0431: MOVWF 78
2055 .................... }
2056 ....................
2057 ....................
2058 .................... // Programovani pres RS232
2059 .................... #define LINELEN 40 // Delka radky pro RS232
2060 .................... #define CR 0x0D // Odradkovani
2061 .................... #define BS 0x08 // Back Space
2062 ....................
2063 .................... #separate
2064 .................... void Download()
2065 .................... {
2066 .................... char line[LINELEN]; // Buffer na radku
2067 .................... unsigned char c; // Znak
2068 .................... unsigned int8 a; // Ukazovatko do bufferu
2069 .................... unsigned int8 len; // Delka retezce v radce
2070 .................... unsigned int8 Oct; // Cislo oktavy u noty
2071 ....................
2072 .................... output_low(POWER_386); // Zapni napajeni zesilovace
2073 *
2074 034B: BSF 03.5
2075 034C: BCF 05.4
2076 034D: BCF 03.5
2077 034E: BCF 05.4
2078 .................... SoundNote(SOUND_Space,3,10); // Mezera
2079 034F: MOVLW 0C
2080 0350: MOVWF 69
2081 0351: MOVLW 03
2082 0352: MOVWF 6A
2083 0353: CLRF 6C
2084 0354: MOVLW 0A
2085 0355: MOVWF 6B
2086 0356: CALL 0E2
2087 .................... Beep=SoundPGM;
2088 0357: MOVLW 03
2089 0358: MOVWF 33
2090 .................... Error=0;
2091 0359: BCF 2D.1
2092 .................... SpecBeep(); // Pipni na znameni vstupu do programovani
2093 035A: CALL 13B
2094 ....................
2095 .................... Tempo=100; // Default hodnoty
2096 035B: CLRF 2F
2097 035C: MOVLW 64
2098 035D: MOVWF 2E
2099 .................... Pause=100;
2100 035E: CLRF 31
2101 035F: MOVWF 30
2102 .................... Octava=0;
2103 0360: CLRF 32
2104 .................... Mode=0; // Mod hrani
2105 0361: BCF 2D.0
2106 .................... Oct=0;
2107 0362: CLRF 60
2108 .................... a=0; // Na zacatku je radka prazdna
2109 0363: CLRF 5E
2110 ....................
2111 .................... for(;input(POWER_PIC)==0;) // Opakuj vse dokud je PGM rezim
2112 0364: BSF 03.5
2113 0365: BSF 05.3
2114 0366: MOVLW 00
2115 0367: BCF 03.5
2116 0368: BTFSC 05.3
2117 0369: MOVLW 01
2118 036A: XORLW 00
2119 036B: BTFSS 03.2
2120 036C: GOTO 594
2121 .................... {
2122 .................... Loop:
2123 .................... c=Getc(); // Vezmi znak ze seriovky
2124 036D: CALL 153
2125 036E: MOVF 78,W
2126 036F: MOVWF 5D
2127 .................... if (c>=0x80) goto Loop; // Ignoruj znaky nad ASCII
2128 0370: MOVF 5D,W
2129 0371: SUBLW 7F
2130 0372: BTFSC 03.0
2131 0373: GOTO 375
2132 0374: GOTO 36D
2133 .................... if (c>=0x60) c=c-0x20; // Preved velka pismena na velka pismena
2134 0375: MOVF 5D,W
2135 0376: SUBLW 5F
2136 0377: BTFSC 03.0
2137 0378: GOTO 37B
2138 0379: MOVLW 20
2139 037A: SUBWF 5D,F
2140 .................... if ((c==CR)|(c=='/')) // Konec radky nebo komentar
2141 037B: MOVF 5D,W
2142 037C: SUBLW 0D
2143 037D: BTFSC 03.2
2144 037E: GOTO 381
2145 037F: MOVLW 00
2146 0380: GOTO 382
2147 0381: MOVLW 01
2148 0382: MOVWF 61
2149 0383: MOVF 5D,W
2150 0384: SUBLW 2F
2151 0385: BTFSC 03.2
2152 0386: GOTO 389
2153 0387: MOVLW 00
2154 0388: GOTO 38A
2155 0389: MOVLW 01
2156 038A: IORWF 61,W
2157 038B: XORLW 00
2158 038C: BTFSC 03.2
2159 038D: GOTO 560
2160 .................... {
2161 .................... while (c!=CR) c=Getc(); // Zpracuj znaky komentare
2162 038E: MOVF 5D,W
2163 038F: SUBLW 0D
2164 0390: BTFSC 03.2
2165 0391: GOTO 396
2166 0392: CALL 153
2167 0393: MOVF 78,W
2168 0394: MOVWF 5D
2169 0395: GOTO 38E
2170 .................... len=a; // Zapamatuj si delku radky
2171 0396: MOVF 5E,W
2172 0397: MOVWF 5F
2173 .................... a=0; // Postav se na zacatek radky
2174 0398: CLRF 5E
2175 .................... Beep=SoundEndOfLine; // Default zuk na konci radky
2176 0399: MOVLW 01
2177 039A: MOVWF 33
2178 .................... // Zpracovani radky
2179 .................... while(a<len)
2180 039B: MOVF 5F,W
2181 039C: SUBWF 5E,W
2182 039D: BTFSC 03.0
2183 039E: GOTO 55D
2184 .................... {
2185 .................... restart_wdt(); // Nuluj watchdog abychom se nezresetovali
2186 039F: CLRWDT
2187 .................... c=Word(line,&a,len);
2188 03A0: MOVLW 35
2189 03A1: MOVWF 61
2190 03A2: MOVLW 5E
2191 03A3: MOVWF 62
2192 03A4: MOVF 5F,W
2193 03A5: MOVWF 63
2194 *
2195 0432: MOVF 78,W
2196 0433: MOVWF 5D
2197 .................... if (c==-1) // Nezname klicove slovo
2198 0434: MOVF 5D,W
2199 0435: SUBLW FF
2200 0436: BTFSS 03.2
2201 0437: GOTO 46B
2202 .................... {
2203 .................... if (a<len) // Nejsme uz na konci radky ??
2204 0438: MOVF 5F,W
2205 0439: SUBWF 5E,W
2206 043A: BTFSC 03.0
2207 043B: GOTO 46A
2208 .................... {
2209 .................... if ((line[a]>='0')&(line[a]<='9')) // Stojime na cislici -> je to cislo
2210 043C: MOVLW 35
2211 043D: ADDWF 5E,W
2212 043E: MOVWF 04
2213 043F: MOVF 00,W
2214 0440: SUBLW 2F
2215 0441: BTFSS 03.0
2216 0442: GOTO 445
2217 0443: MOVLW 00
2218 0444: GOTO 446
2219 0445: MOVLW 01
2220 0446: MOVWF 62
2221 0447: MOVLW 35
2222 0448: ADDWF 5E,W
2223 0449: MOVWF 04
2224 044A: MOVF 00,W
2225 044B: SUBLW 39
2226 044C: BTFSC 03.0
2227 044D: GOTO 450
2228 044E: MOVLW 00
2229 044F: GOTO 451
2230 0450: MOVLW 01
2231 0451: ANDWF 62,W
2232 0452: XORLW 00
2233 0453: BTFSC 03.2
2234 0454: GOTO 461
2235 .................... {
2236 .................... // Oct=Number(line,&a,len)&0x7; // tohle nefunguje protoze je chyba v prekladaci
2237 .................... Oct=Number(line,&a,len); // prekladac prepoklada, z W obsahuje spodni bajt vysledku
2238 0455: MOVLW 35
2239 0456: MOVWF 61
2240 0457: MOVLW 5E
2241 0458: MOVWF 62
2242 0459: MOVF 5F,W
2243 045A: MOVWF 63
2244 045B: CALL 190
2245 045C: MOVF 78,W
2246 045D: MOVWF 60
2247 .................... Oct&=0x7; // ale k navratu pouziva RETLW 0 coz smaze W !
2248 045E: MOVLW 07
2249 045F: ANDWF 60,F
2250 .................... }
2251 .................... else // Stojime na pismenu nebo oddelovaci
2252 0460: GOTO 46A
2253 .................... {
2254 .................... if (line[a]!=' ') Error=1; // Neni to oddelovac - chyba
2255 0461: MOVLW 35
2256 0462: ADDWF 5E,W
2257 0463: MOVWF 04
2258 0464: MOVF 00,W
2259 0465: SUBLW 20
2260 0466: BTFSC 03.2
2261 0467: GOTO 469
2262 0468: BSF 2D.1
2263 .................... a++; // Preskocim 1 znak (a kdyz to nepomuze dostanu se zase sem)
2264 0469: INCF 5E,F
2265 .................... }
2266 .................... }
2267 .................... }
2268 .................... else if (c=='P') // Play
2269 046A: GOTO 55C
2270 046B: MOVF 5D,W
2271 046C: SUBLW 50
2272 046D: BTFSS 03.2
2273 046E: GOTO 47D
2274 .................... {
2275 .................... CisloSkladby=Number(line,&a,len);
2276 046F: MOVLW 35
2277 0470: MOVWF 61
2278 0471: MOVLW 5E
2279 0472: MOVWF 62
2280 0473: MOVF 5F,W
2281 0474: MOVWF 63
2282 0475: CALL 190
2283 0476: MOVF 78,W
2284 0477: MOVWF 34
2285 .................... Mode=0;
2286 0478: BCF 2D.0
2287 .................... Play();
2288 0479: CALL 27D
2289 .................... Beep=SoundPGM;
2290 047A: MOVLW 03
2291 047B: MOVWF 33
2292 .................... }
2293 .................... else if (c=='E') // Erase
2294 047C: GOTO 55C
2295 047D: MOVF 5D,W
2296 047E: SUBLW 45
2297 047F: BTFSS 03.2
2298 0480: GOTO 4BB
2299 .................... {
2300 .................... Mode=0;
2301 0481: BCF 2D.0
2302 .................... Erase();
2303 .................... Beep=SoundPGM;
2304 *
2305 04B8: MOVLW 03
2306 04B9: MOVWF 33
2307 .................... }
2308 .................... else if (c=='t') // Tempo
2309 04BA: GOTO 55C
2310 04BB: MOVF 5D,W
2311 04BC: SUBLW 74
2312 04BD: BTFSS 03.2
2313 04BE: GOTO 4DB
2314 .................... {
2315 .................... Tempo=Number(line,&a,len)&~MASKTEMPO;
2316 04BF: MOVLW 35
2317 04C0: MOVWF 61
2318 04C1: MOVLW 5E
2319 04C2: MOVWF 62
2320 04C3: MOVF 5F,W
2321 04C4: MOVWF 63
2322 04C5: CALL 190
2323 04C6: MOVF 78,W
2324 04C7: MOVWF 2E
2325 04C8: MOVF 79,W
2326 04C9: ANDLW C7
2327 04CA: MOVWF 2F
2328 .................... if (Tempo==0) Tempo=100;
2329 04CB: MOVF 2E,F
2330 04CC: BTFSS 03.2
2331 04CD: GOTO 4D4
2332 04CE: MOVF 2F,F
2333 04CF: BTFSS 03.2
2334 04D0: GOTO 4D4
2335 04D1: CLRF 2F
2336 04D2: MOVLW 64
2337 04D3: MOVWF 2E
2338 .................... Data=Tempo|DATATEMPO;
2339 04D4: MOVF 2E,W
2340 04D5: MOVWF 2B
2341 04D6: MOVF 2F,W
2342 04D7: IORLW 28
2343 04D8: MOVWF 2C
2344 .................... WriteDataInc(); // Podmineny zapis do FLASH a posun na dalsi adresu
2345 04D9: CALL 2E0
2346 .................... }
2347 .................... else if (c=='p') // Pause
2348 04DA: GOTO 55C
2349 04DB: MOVF 5D,W
2350 04DC: SUBLW 70
2351 04DD: BTFSS 03.2
2352 04DE: GOTO 4FB
2353 .................... {
2354 .................... Pause=Number(line,&a,len)&~MASKPAUSE;
2355 04DF: MOVLW 35
2356 04E0: MOVWF 61
2357 04E1: MOVLW 5E
2358 04E2: MOVWF 62
2359 04E3: MOVF 5F,W
2360 04E4: MOVWF 63
2361 04E5: CALL 190
2362 04E6: MOVF 78,W
2363 04E7: MOVWF 30
2364 04E8: MOVF 79,W
2365 04E9: ANDLW C7
2366 04EA: MOVWF 31
2367 .................... if (Pause==0) Pause=100;
2368 04EB: MOVF 30,F
2369 04EC: BTFSS 03.2
2370 04ED: GOTO 4F4
2371 04EE: MOVF 31,F
2372 04EF: BTFSS 03.2
2373 04F0: GOTO 4F4
2374 04F1: CLRF 31
2375 04F2: MOVLW 64
2376 04F3: MOVWF 30
2377 .................... Data=Pause|DATAPAUSE;
2378 04F4: MOVF 30,W
2379 04F5: MOVWF 2B
2380 04F6: MOVF 31,W
2381 04F7: IORLW 30
2382 04F8: MOVWF 2C
2383 .................... WriteDataInc(); // Podmineny zapis do FLASH a posun na dalsi adresu
2384 04F9: CALL 2E0
2385 .................... }
2386 .................... else if (c=='B') // Begin
2387 04FA: GOTO 55C
2388 04FB: MOVF 5D,W
2389 04FC: SUBLW 42
2390 04FD: BTFSS 03.2
2391 04FE: GOTO 512
2392 .................... {
2393 .................... CisloSkladby=~0; // Neplatne cislo skladby
2394 04FF: MOVLW FF
2395 0500: MOVWF 34
2396 .................... Find(); // najde konec posledni skladby
2397 0501: CALL 208
2398 .................... Octava=Number(line,&a,len)&~MASKBEGIN;
2399 0502: MOVLW 35
2400 0503: MOVWF 61
2401 0504: MOVLW 5E
2402 0505: MOVWF 62
2403 0506: MOVF 5F,W
2404 0507: MOVWF 63
2405 0508: CALL 190
2406 0509: MOVF 78,W
2407 050A: MOVWF 32
2408 .................... Data=DATABEGIN|Octava; // Zacatecni znacka
2409 050B: MOVF 32,W
2410 050C: MOVWF 2B
2411 050D: MOVLW 20
2412 050E: MOVWF 2C
2413 .................... Mode=1; // Mod zapisu do FLASH pameti
2414 050F: BSF 2D.0
2415 .................... WriteDataInc(); // Podmineny zapis do FLASH a posun na dalsi adresu
2416 0510: CALL 2E0
2417 .................... }
2418 .................... else if (c=='b') // Test
2419 0511: GOTO 55C
2420 0512: MOVF 5D,W
2421 0513: SUBLW 62
2422 0514: BTFSS 03.2
2423 0515: GOTO 521
2424 .................... {
2425 .................... Octava=Number(line,&a,len)&~MASKBEGIN;
2426 0516: MOVLW 35
2427 0517: MOVWF 61
2428 0518: MOVLW 5E
2429 0519: MOVWF 62
2430 051A: MOVF 5F,W
2431 051B: MOVWF 63
2432 051C: CALL 190
2433 051D: MOVF 78,W
2434 051E: MOVWF 32
2435 .................... Mode=0;
2436 051F: BCF 2D.0
2437 .................... }
2438 .................... else if (c=='Z') // End
2439 0520: GOTO 55C
2440 0521: MOVF 5D,W
2441 0522: SUBLW 5A
2442 0523: BTFSS 03.2
2443 0524: GOTO 527
2444 .................... {
2445 .................... Mode=0;
2446 0525: BCF 2D.0
2447 .................... }
2448 .................... else // Nota
2449 0526: GOTO 55C
2450 .................... {
2451 .................... Data=Number(line,&a,len); // Delka noty (nepovinna)
2452 0527: MOVLW 35
2453 0528: MOVWF 61
2454 0529: MOVLW 5E
2455 052A: MOVWF 62
2456 052B: MOVF 5F,W
2457 052C: MOVWF 63
2458 052D: CALL 190
2459 052E: MOVF 79,W
2460 052F: MOVWF 2C
2461 0530: MOVF 78,W
2462 0531: MOVWF 2B
2463 .................... Data&=0x3F; // Jen platny rozsah
2464 0532: MOVLW 3F
2465 0533: ANDWF 2B,F
2466 0534: MOVLW 00
2467 0535: ANDWF 2C,F
2468 .................... if (Data==0) Data++; // Je-li nulova delka - dej jednotkovou
2469 0536: MOVF 2B,F
2470 0537: BTFSS 03.2
2471 0538: GOTO 53F
2472 0539: MOVF 2C,F
2473 053A: BTFSS 03.2
2474 053B: GOTO 53F
2475 053C: INCF 2B,F
2476 053D: BTFSC 03.2
2477 053E: INCF 2C,F
2478 .................... Data<<=7; // Delka
2479 053F: RLF 2B,F
2480 0540: RLF 2C,F
2481 0541: RLF 2B,F
2482 0542: RLF 2C,F
2483 0543: RLF 2B,F
2484 0544: RLF 2C,F
2485 0545: RLF 2B,F
2486 0546: RLF 2C,F
2487 0547: RLF 2B,F
2488 0548: RLF 2C,F
2489 0549: RLF 2B,F
2490 054A: RLF 2C,F
2491 054B: RLF 2B,F
2492 054C: RLF 2C,F
2493 054D: MOVLW 80
2494 054E: ANDWF 2B,F
2495 .................... Data|=c; // Nota
2496 054F: MOVF 5D,W
2497 0550: IORWF 2B,F
2498 .................... Data|=(Oct<<4); // Oktava
2499 0551: SWAPF 60,W
2500 0552: MOVWF 77
2501 0553: MOVLW F0
2502 0554: ANDWF 77,F
2503 0555: MOVF 77,W
2504 0556: IORWF 2B,F
2505 .................... WriteDataInc(); // Podmineny zapis do FLASH a posun na dalsi adresu
2506 0557: CALL 2E0
2507 .................... if (~Mode)
2508 0558: BTFSC 2D.0
2509 0559: GOTO 55C
2510 .................... {
2511 .................... PlayData(); // Zahraj notu
2512 055A: CALL 237
2513 .................... Beep=0; // Po zahrani noty uz nepipej na konci radky
2514 055B: CLRF 33
2515 .................... }
2516 .................... }
2517 .................... }
2518 055C: GOTO 39B
2519 .................... a=0; // Radka zpracovana, nuluj jeji delku
2520 055D: CLRF 5E
2521 .................... SpecBeep(); // Pipni
2522 055E: CALL 13B
2523 .................... goto Loop;
2524 055F: GOTO 36D
2525 .................... }
2526 .................... if ((c==BS)&(a>0)) {a--;goto Loop;} // Smaz znak
2527 0560: MOVF 5D,W
2528 0561: SUBLW 08
2529 0562: BTFSC 03.2
2530 0563: GOTO 566
2531 0564: MOVLW 00
2532 0565: GOTO 567
2533 0566: MOVLW 01
2534 0567: MOVWF 61
2535 0568: MOVF 5E,F
2536 0569: BTFSS 03.2
2537 056A: GOTO 56D
2538 056B: MOVLW 00
2539 056C: GOTO 56E
2540 056D: MOVLW 01
2541 056E: ANDWF 61,W
2542 056F: XORLW 00
2543 0570: BTFSC 03.2
2544 0571: GOTO 574
2545 0572: DECF 5E,F
2546 0573: GOTO 36D
2547 .................... if ((c==',')|(c<=' ')) c=' '; // Vsechny ostatni ridici znaky i carka jsou oddelovac
2548 0574: MOVF 5D,W
2549 0575: SUBLW 2C
2550 0576: BTFSC 03.2
2551 0577: GOTO 57A
2552 0578: MOVLW 00
2553 0579: GOTO 57B
2554 057A: MOVLW 01
2555 057B: MOVWF 61
2556 057C: MOVF 5D,W
2557 057D: SUBLW 20
2558 057E: BTFSC 03.0
2559 057F: GOTO 582
2560 0580: MOVLW 00
2561 0581: GOTO 583
2562 0582: MOVLW 01
2563 0583: IORWF 61,W
2564 0584: XORLW 00
2565 0585: BTFSC 03.2
2566 0586: GOTO 589
2567 0587: MOVLW 20
2568 0588: MOVWF 5D
2569 .................... if (a<LINELEN) line[a++]=c; // Zapis znak do bufferu a posun ukazovatko
2570 0589: MOVF 5E,W
2571 058A: SUBLW 27
2572 058B: BTFSS 03.0
2573 058C: GOTO 593
2574 058D: MOVF 5E,W
2575 058E: INCF 5E,F
2576 058F: ADDLW 35
2577 0590: MOVWF 04
2578 0591: MOVF 5D,W
2579 0592: MOVWF 00
2580 .................... }
2581 0593: GOTO 364
2582 0594: GOTO 5CB (RETURN)
2583 .................... }
2584 ....................
2585 ....................
2586 .................... // Tabulka pro prekodovani tlacitek
2587 .................... const int8 KeyTranslate[16] = {0, 1, 2, 5, 3, 6, 8, 11, 4, 7, 9, 12, 10, 13, 14, 15};
2588 *
2589 00B7: BCF 0A.0
2590 00B8: BCF 0A.1
2591 00B9: BCF 0A.2
2592 00BA: ADDWF 02,F
2593 00BB: RETLW 00
2594 00BC: RETLW 01
2595 00BD: RETLW 02
2596 00BE: RETLW 05
2597 00BF: RETLW 03
2598 00C0: RETLW 06
2599 00C1: RETLW 08
2600 00C2: RETLW 0B
2601 00C3: RETLW 04
2602 00C4: RETLW 07
2603 00C5: RETLW 09
2604 00C6: RETLW 0C
2605 00C7: RETLW 0A
2606 00C8: RETLW 0D
2607 00C9: RETLW 0E
2608 00CA: RETLW 0F
2609 ....................
2610 .................... void main()
2611 .................... {
2612 *
2613 0595: CLRF 04
2614 0596: MOVLW 1F
2615 0597: ANDWF 03,F
2616 0598: MOVLW 07
2617 0599: BSF 03.5
2618 059A: MOVWF 1F
2619 059B: BCF 05.0
2620 059C: BCF 03.5
2621 059D: BCF 05.0
2622 .................... Start:
2623 ....................
2624 .................... if (restart_cause()==WDT_FROM_SLEEP) // Osetreni probuzeni od WDT
2625 059E: MOVF 03,W
2626 059F: ANDLW 18
2627 05A0: XORLW 00
2628 05A1: BTFSS 03.2
2629 05A2: GOTO 5A4
2630 .................... {
2631 .................... sleep();
2632 05A3: SLEEP
2633 .................... }
2634 .................... // Inicializace WDT
2635 .................... // setup_wdt(WDT_16MS); // nelze pouzit, zabira 15 instukci
2636 .................... #asm
2637 .................... bsf 0x03,5 // banka 1 nebo 3 aby se mohlo k OPTION registu
2638 05A4: BSF 03.5
2639 .................... bcf 0x81,3 // WDT primo tedy 16ms
2640 .................... #endasm
2641 05A5: BSF 03.5
2642 05A6: BCF 01.3
2643 ....................
2644 .................... // Inicializace
2645 .................... port_b_pullups(TRUE); // Zapni pull-up odpory na portu B
2646 05A7: BCF 01.7
2647 .................... set_tris_a(0b00001000); // Nastav nepouzite vyvody jako vystupy
2648 05A8: MOVLW 08
2649 05A9: MOVWF 05
2650 .................... set_tris_b(0b11110000); // 1 znamena vstup
2651 05AA: MOVLW F0
2652 05AB: MOVWF 06
2653 .................... *0x9F = 6; // Vsechny vstupy jsou digitalni
2654 05AC: MOVLW 06
2655 05AD: MOVWF 1F
2656 ....................
2657 .................... // Test na rezim programovani
2658 .................... if ((input(POWER_PIC)==0)&(input(RXD)==0)) // Podminka programovani
2659 05AE: BSF 05.3
2660 05AF: MOVLW 00
2661 05B0: BCF 03.5
2662 05B1: BTFSC 05.3
2663 05B2: MOVLW 01
2664 05B3: XORLW 00
2665 05B4: BTFSC 03.2
2666 05B5: GOTO 5B8
2667 05B6: MOVLW 00
2668 05B7: GOTO 5B9
2669 05B8: MOVLW 01
2670 05B9: MOVWF 36
2671 05BA: BSF 03.5
2672 05BB: BSF 06.1
2673 05BC: MOVLW 00
2674 05BD: BCF 03.5
2675 05BE: BTFSC 06.1
2676 05BF: MOVLW 01
2677 05C0: XORLW 00
2678 05C1: BTFSC 03.2
2679 05C2: GOTO 5C5
2680 05C3: MOVLW 00
2681 05C4: GOTO 5C6
2682 05C5: MOVLW 01
2683 05C6: ANDWF 36,W
2684 05C7: XORLW 00
2685 05C8: BTFSC 03.2
2686 05C9: GOTO 5CB
2687 .................... Download(); // Pripojen RS232 a propojka na PGM
2688 05CA: GOTO 34B
2689 ....................
2690 .................... // Zapnuti napajeni
2691 .................... output_low(POWER_PIC); // Pripoj GND pro procesor
2692 05CB: BSF 03.5
2693 05CC: BCF 05.3
2694 05CD: BCF 03.5
2695 05CE: BCF 05.3
2696 .................... SoundNote(SOUND_Space,3,10); // Mezera
2697 05CF: MOVLW 0C
2698 05D0: MOVWF 69
2699 05D1: MOVLW 03
2700 05D2: MOVWF 6A
2701 05D3: CLRF 6C
2702 05D4: MOVLW 0A
2703 05D5: MOVWF 6B
2704 05D6: CALL 0E2
2705 .................... output_low(POWER_386); // Zapni napajeni zesilovace
2706 05D7: BSF 03.5
2707 05D8: BCF 05.4
2708 05D9: BCF 03.5
2709 05DA: BCF 05.4
2710 .................... SoundNote(SOUND_Space,3,100); // Mezera (jinak se chybne detekuje tlacitko)
2711 05DB: MOVLW 0C
2712 05DC: MOVWF 69
2713 05DD: MOVLW 03
2714 05DE: MOVWF 6A
2715 05DF: CLRF 6C
2716 05E0: MOVLW 64
2717 05E1: MOVWF 6B
2718 05E2: CALL 0E2
2719 ....................
2720 .................... // Cteni tlacitek
2721 .................... #use FAST_IO(B)
2722 .................... CisloSkladby=(input_b() >> 4) ^ 0xFF & 0xF; // Precti stav tlacitek
2723 05E3: SWAPF 06,W
2724 05E4: MOVWF 77
2725 05E5: MOVLW 0F
2726 05E6: ANDWF 77,F
2727 05E7: MOVF 77,W
2728 05E8: XORLW 0F
2729 05E9: MOVWF 34
2730 .................... #use STANDARD_IO(B)
2731 .................... CisloSkladby=KeyTranslate[CisloSkladby]; // Prekoduj je do binarniho kodu
2732 05EA: MOVF 34,W
2733 05EB: CALL 0B7
2734 05EC: MOVWF 78
2735 05ED: MOVWF 34
2736 ....................
2737 .................... // Prehrani skladby
2738 .................... Play(); // Zahraj skladbu
2739 05EE: CALL 27D
2740 ....................
2741 .................... // Po odehrani usni a cekej na zmacknuti tlacitka
2742 .................... #use FAST_IO(B)
2743 .................... if (input_B()); // Precti stav portu B (vuci tomuto stavu se bude hlidat zmena)
2744 05EF: MOVF 06,W
2745 05F0: XORLW 00
2746 05F1: BTFSC 03.2
2747 05F2: GOTO 5F3
2748 .................... #use STANDARD_IO(B)
2749 .................... bit_clear(*0xB,0); // Nuluj priznak preruseni od zmeny stavu portu B
2750 05F3: BCF 0B.0
2751 .................... enable_interrupts(INT_RB); // Povol preruseni od zmeny stavu portu B
2752 05F4: BSF 0B.3
2753 ....................
2754 .................... output_high(POWER_386); // Vypni napajeni zesilovace
2755 05F5: BSF 03.5
2756 05F6: BCF 05.4
2757 05F7: BCF 03.5
2758 05F8: BSF 05.4
2759 .................... output_float(POWER_PIC); // Odpoj GND
2760 05F9: BSF 03.5
2761 05FA: BSF 05.3
2762 ....................
2763 .................... Sleep(); // Usni aby byla minimalni klidova spotreba
2764 05FB: SLEEP
2765 ....................
2766 .................... disable_interrupts(INT_RB); // Zakaz preruseni od portu
2767 05FC: BCF 03.5
2768 05FD: BCF 0B.3
2769 .................... goto Start; // Po probuzeni skoc na zacatek
2770 05FE: GOTO 59E
2771 .................... }
2772 ....................
2773 05FF: SLEEP