;############################################################################### ; # ; avrmusicbox V0.38 zweistimmige Klangerzeugung (Spieluhr) mit ATMEGA8/88 # ; (c)2006 Jörg Wolfram joerg@jcwolfram.de # ; # ; Dieses Programm ist freie Software. Sie können es unter den Bedingungen # ; der GNU General Public License, wie von der Free Software Foundation # ; veröffentlicht, weitergeben und/oder modifizieren, entweder gemäss # ; Version 2 der Lizenz oder (nach Ihrer Option) jeder späteren Version. # ; # ; Die Veröffentlichung dieses Programms erfolgt in der Hoffnung, daß es # ; Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, auch ohne die # ; implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN # ; BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License. # ; # ; Sie sollten ein Exemplar der GNU General Public License zusammen mit # ; diesem Programm erhalten haben. Falls nicht, schreiben Sie an die Free # ; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, # ; USA. # ; # ; Jede Nutzung der Software/Informationen nonkonform zur GPL oder ausserhalb # ; des Geltungsbereiches der GPL ist untersagt! # ; # ;############################################################################### ;############################################################################### ; the player (sequencer) ;############################################################################### ;------------------------------------------------------------------------------- ; set power down and wait... ;------------------------------------------------------------------------------- pdown: ldi ZH,0 pdown1: ldi ZL,0 pdown2: sbis PIND,3 rjmp pdown dec ZL brne pdown2 dec ZH brne pdown1 .if ctype == 88 ldi temp,0x02 ;enable external interrupt out EIMSK,temp sei ;Interrupts freigeben sts EIFR,byte127 ;clear INTflags sleep ;and sleep now .endif .if ctype == 08 ldi temp,0xc0 ;enable external interrupt out GICR,temp sei ;Interrupts freigeben sts GIFR,byte254 ;clear INTflags sleep ;and sleep now .endif loop: sei nop nop nop nop nop nop nop rcall w1s ;wait aprox 1s ;------------------------------------------------------------------------------- ;check, which mode is selected ;------------------------------------------------------------------------------- sbic PIND,3 ;skip, if key is pressed rjmp playsong ;playmode sts sysram+36,byte127 ;preview-mode ;------------------------------------------------------------------------------- ;previev-mode ;------------------------------------------------------------------------------- select: ldi ZH,HIGH(md1*2) ;pointer to music data ldi ZL,LOW(md1*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s ldi temp,0 ;song no. 1 sts sysram+35,temp ;store as selected sbic PIND,3 ;skip, if key is pressed rjmp playsong ;this song is selected ldi ZH,HIGH(md2*2) ;pointer to music data ldi ZL,LOW(md2*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s ldi temp,1 ;song no. 2 sts sysram+35,temp ;store as selected sbic PIND,3 ;skip, if key is pressed rjmp playsong ;this song is selected ldi ZH,HIGH(md3*2) ;pointer to music data ldi ZL,LOW(md3*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s ldi temp,2 ;song no. 3 sts sysram+35,temp ;store as selected sbic PIND,3 ;skip, if key is pressed rjmp playsong ;this song is selected ldi ZH,HIGH(md4*2) ;pointer to music data ldi ZL,LOW(md4*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s ldi temp,3 ;song no. 4 sts sysram+35,temp ;store as selected sbic PIND,3 ;skip, if key is pressed rjmp playsong ;this song is selected ldi ZH,HIGH(md5*2) ;pointer to music data ldi ZL,LOW(md5*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s ldi temp,4 ;song no. 5 sts sysram+35,temp ;store as selected sbic PIND,3 ;skip, if key is pressed rjmp playsong ;this song is selected rjmp select ;start again with song no. 1 ;------------------------------------------------------------------------------- ;play-mode ;------------------------------------------------------------------------------- playsong: sts sysram+36,byte0 ;set playmode lds temp,sysram+35 ;selected song playsong_01: cpi temp,0 ;song no. 1? brne playsong_02 ;next ldi ZH,HIGH(md1*2) ;pointer to music data ldi ZL,LOW(md1*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s rjmp pdown ;now goto sleep-mode playsong_02: cpi temp,1 ;song no. 2? brne playsong_03 ;next ldi ZH,HIGH(md2*2) ;pointer to music data ldi ZL,LOW(md2*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s rjmp pdown ;now goto sleep-mode playsong_03: cpi temp,2 ;song no. 3? brne playsong_04 ;next ldi ZH,HIGH(md3*2) ;pointer to music data ldi ZL,LOW(md3*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s rjmp pdown ;now goto sleep-mode playsong_04: cpi temp,3 ;song no. 4? brne playsong_05 ;next ldi ZH,HIGH(md4*2) ;pointer to music data ldi ZL,LOW(md4*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s rjmp pdown ;now goto sleep-mode playsong_05: cpi temp,4 ;song no. 5? brne playsong_06 ;next ldi ZH,HIGH(md5*2) ;pointer to music data ldi ZL,LOW(md5*2) ;pointer to music data rcall play ;play song rcall w1s ;wait 1s rjmp pdown ;now goto sleep-mode playsong_06: sts sysram+35,byte0 ;set song to 1 rjmp pdown ;goto sleep-mode ;############################################################################### ;subroutine, waits approx. 1s at 8MHz ;############################################################################### w1s: cli ;disable interrupts ldi temp,100 w1sa: ldi temp1,100 w1sb: ldi temp2,0 w1sc: dec temp2 brne w1sc dec temp1 brne w1sb dec temp brne w1sa sei ;enable interrupts ret ;thats all