From 40d0217883c661b3dd766eb0e6cbb38239db14fd Mon Sep 17 00:00:00 2001 From: flo Date: Fri, 24 Feb 2017 21:57:01 +0100 Subject: [PATCH] modifs --- Makefile | 2 +- Makefile.config | 5 +- README.md | 4 +- src/Sound4Calc.c | 145 +++++++++++++++++++++++------------------------ 4 files changed, 75 insertions(+), 81 deletions(-) diff --git a/Makefile b/Makefile index 1d24c0f..fb8429c 100755 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ $(NAME).bin: $(NAME).elf ## Make the G1A file $(NAME).g1a: $(NAME).bin - $(WRAPR) $< -o $(NAME).g1a -i $(IMG) + $(WRAPR) $< -o $(NAME).g1a -i $(ICON) @stat -c "Build finished -- output size is %s bytes." $(NAME).g1a ## Clean up your mess diff --git a/Makefile.config b/Makefile.config index 7c3b7c7..7675330 100755 --- a/Makefile.config +++ b/Makefile.config @@ -1,7 +1,7 @@ #!/usr/bin/make -f # PROJECT INFORMATION NAME = sound -ICON = ./icon.bmp +ICON = misc/icon.bmp LIB = gcc ## DIRECTORIES @@ -39,7 +39,4 @@ SRC = $(notdir $(wildcard $(SRCDIR)/*.[cs])) # INCLUDES INC = $(notdir $(wildcard $(INCDIR)/*.h)) -#IMAGE - IMG = $(wildcard **/*.bmp) - # END OF FILE diff --git a/README.md b/README.md index 71ff992..0a2184d 100755 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Building the library is achieved by the Makefile : - `make fclean`: clean the object files and the final library ; - `make re`: cleans the object files and the final library, then makes the project. -These sources can be compiled with __GCC__ and use __Gint__ (Lephe's library) +These sources can be compiled with __GCC__ and use __Gint__ (Lephenixnoir's library) ## Final project -A sound library to make sound in games. Need GCC and Gint +A sound library to make sound in games. diff --git a/src/Sound4Calc.c b/src/Sound4Calc.c index 67a4e3a..fb3a267 100755 --- a/src/Sound4Calc.c +++ b/src/Sound4Calc.c @@ -9,14 +9,12 @@ //#define PI 3.141592653584 -char bincod[25] = {0}; -char place = 0; - -unsigned char range = 0; +unsigned char bincod[25] = {0}; +unsigned char place = 0; void lect() { - // range = (range < 20 ? range +1 : 0); + static unsigned char range = 0; if(bincod[range%place] != bincod[(range+1)%place]) { @@ -36,94 +34,93 @@ void lect() int main(void) { - unsigned int key=0; +unsigned int key = 0; - int freq = 440; +static int freq = 440; - //unsigned int i=0; +//unsigned int i=0; - setup(); +setup(); - while(1) +while(1) + { + dclear(); + + dprint(1, 1, "%d", freq); + dprint(1, 10, "%s", bincod); + dprint(1, 20, "%d", place); + dtext(1, 50, "F1 _ F2 -"); + + dupdate(); + + key = getkey(); + + switch(key) { - dclear(); + case KEY_RIGHT : freq+=1; break; + case KEY_LEFT : freq-=1; break; + case KEY_UP : freq+=10; break; + case KEY_DOWN : freq-=10; break; - dprint(1, 1, "%d", freq); - dprint(1, 10, "%s", bincod); - dprint(1, 20, "%d", place); - dtext(1, 50, "F1 _ F2 -"); + case KEY_F1 : *(bincod+place++) = '_'; break; + case KEY_F2 : *(bincod+place++) = '-'; break; + case KEY_DEL : place=(place>0 ? place - 1 : 0); *(bincod+place) = 0; break; - dupdate(); - - key=getkey(); - - switch(key) - { - case KEY_RIGHT : freq+=1; break; - case KEY_LEFT : freq-=1; break; - case KEY_UP : freq+=10; break; - case KEY_DOWN : freq-=10; break; - - case KEY_F1 : *(bincod+place++) = '_'; range = 0; break; - case KEY_F2 : *(bincod+place++) = '-'; range = 0;break; - case KEY_DEL : place=(place>0 ? place - 1 : 0); *(bincod+place) = 0; range = 0; break; - - case KEY_EXE : - timer_start(TIMER_USER, freq*place, Clock_Hz, lect, 2*freq*place); - - break; - case KEY_EXIT : - timer_stop(TIMER_USER); - return 1; - } + case KEY_EXE : + timer_start(TIMER_USER, freq*place, Clock_Hz, lect, 2*freq*place); + break; + case KEY_EXIT : + timer_stop(TIMER_USER); + return 1; } + } return 1; // this point is never reached } void setup() { - if(isSH3()) - { - // initialisation of pin - *(volatile unsigned char*)SH7337_SCPDR |= 0x01; +if(isSH3()) + { +// initialisation of pin + *(volatile unsigned char*)SH7337_SCPDR |= 0x01; - // SCIF2 clock on (STBCR3.MSTP31) - *(volatile unsigned char*)SH7337_STBCR3 &= ~0x02; - // switch off SCSMR_2.TE and SCSMR_2.RE - *(volatile unsigned short*)SH7337_SCSCR2 &= ~0x0030; - // SCIF2 clock off (STBCR3.MSTP31) - *(volatile unsigned char*)SH7337_STBCR3 |= 0x02; - // set bit 6 of port G to output mode - *(volatile unsigned short*)SH7337_PGCR = ( *(volatile unsigned short*)SH7337_PGCR & ~0x3000 ) | 0x1000; - // set bit 5 and 6 of port G - *(volatile unsigned char*)SH7337_PGDR |= 0x60; - // set port SC bit 0 to output - *(volatile unsigned short*)SH7337_SCPCR = ( *(volatile unsigned short*)SH7337_SCPCR & ~0x0003 ) | 0x0001; - } - else - { - // initialisation of pin - *(volatile unsigned char*)SH7305_PJDR |= 0x04; +// SCIF2 clock on (STBCR3.MSTP31) + *(volatile unsigned char*)SH7337_STBCR3 &= ~0x02; +// switch off SCSMR_2.TE and SCSMR_2.RE + *(volatile unsigned short*)SH7337_SCSCR2 &= ~0x0030; +// SCIF2 clock off (STBCR3.MSTP31) + *(volatile unsigned char*)SH7337_STBCR3 |= 0x02; +// set bit 6 of port G to output mode + *(volatile unsigned short*)SH7337_PGCR = ( *(volatile unsigned short*)SH7337_PGCR & ~0x3000 ) | 0x1000; +// set bit 5 and 6 of port G + *(volatile unsigned char*)SH7337_PGDR |= 0x60; +// set port SC bit 0 to output + *(volatile unsigned short*)SH7337_SCPCR = ( *(volatile unsigned short*)SH7337_SCPCR & ~0x0003 ) | 0x0001; + } +else + { +// initialisation of pin + *(volatile unsigned char*)SH7305_PJDR |= 0x04; - // SCIF2 clock on (MSTPCR0.MSTP007) - *(volatile unsigned int*)SH7305_MSTPCR0 &= ~0x00000080; - // switch off SCSMR_2.TE and SCSMR_2.RE - *(volatile unsigned short*)SH7305_SCSCR &= ~0x0030; - // SCIF2 clock off (MSTPCR0.MSTP007) - *(volatile unsigned int*)SH7305_MSTPCR0 |= 0x00000080; +// SCIF2 clock on (MSTPCR0.MSTP007) + *(volatile unsigned int*)SH7305_MSTPCR0 &= ~0x00000080; +// switch off SCSMR_2.TE and SCSMR_2.RE + *(volatile unsigned short*)SH7305_SCSCR &= ~0x0030; + // SCIF2 clock off (MSTPCR0.MSTP007) + *(volatile unsigned int*)SH7305_MSTPCR0 |= 0x00000080; - // set bit 3 of port U to output mode - *(volatile unsigned short*)SH7305_PUCR = ( *(volatile unsigned short*)SH7305_PUCR & ~0x00C0 ) | 0x0040; - // set bit 4 and 5 of port U - *(volatile unsigned char*)SH7305_PUDR |= 0x0C; +// set bit 3 of port U to output mode + *(volatile unsigned short*)SH7305_PUCR = ( *(volatile unsigned short*)SH7305_PUCR & ~0x00C0 ) | 0x0040; +// set bit 4 and 5 of port U + *(volatile unsigned char*)SH7305_PUDR |= 0x0C; - // set port J bit 2 to output mode - *(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x0030 ) | 0x0010; - // set port J bit 3 to output mode - *(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x00C0 ) | 0x0040; - } +// set port J bit 2 to output mode + *(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x0030 ) | 0x0010; +// set port J bit 3 to output mode + *(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x00C0 ) | 0x0040; + } /* // set port J bit 2 to output *(unsigned short*)0xA4050110 = ( *(unsigned short*)0xA4050110 & ~0x0030 ) | 0x0010;