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