diff --git a/Makefile_cygwin.caanoo b/Makefile_cygwin.caanoo index 1dcea6f..15ca2c9 100644 --- a/Makefile_cygwin.caanoo +++ b/Makefile_cygwin.caanoo @@ -5,7 +5,7 @@ UNZIP=1 #GLIDE=1 #OPENGL=1 -THREAD_SOUND=1 +#THREAD_SOUND=1 CHEATS=1 #ASMKREED=1 #ZSNESC4=1 @@ -119,8 +119,10 @@ STRIP := ${BINPATH}/$(ARCH)-strip AS := ${BINPATH}/$(ARCH)-as GASM := ${BINPATH}/$(ARCH)-g++ -OPTIMISE = -mcpu=arm926ej-s -mtune=arm926ej-s -g -I. -I$(TOOLCHAINDIR)/$(ARCH)/include -O3 -D_ZAURUS -DCAANOO -DUSE_SA1 -OPTIMISE += -ffast-math -fexpensive-optimizations -finline -finline-functions -falign-functions=32 -falign-loops -falign-labels -falign-jumps -fomit-frame-pointer +OPTIMISE = -mcpu=arm926ej-s -mtune=arm926ej-s -I. -I$(TOOLCHAINDIR)/$(ARCH)/include -O3 -D_ZAURUS -DCAANOO -DUSE_SA1 +OPTIMISE += -ffast-math -fexpensive-optimizations -finline -finline-functions -falign-functions=32 -falign-loops -falign-labels -falign-jumps -fomit-frame-pointer -fprofile-use +#-fprofile-generate +#-fprofile-use CCFLAGS = $(OPTIMISE) \ -I. \ diff --git a/Makefile_cygwin.dingoo b/Makefile_cygwin.dingoo index d468279..723ed80 100644 --- a/Makefile_cygwin.dingoo +++ b/Makefile_cygwin.dingoo @@ -117,8 +117,10 @@ STRIP := $(BINPATH)/mipsel-linux-uclibc-strip AS := $(BINPATH)/mipsel-linux-uclibc-as GASM := $(BINPATH)/mipsel-linux-uclibc-g++ -OPTIMISE= -D_ZAURUS -O3 -ffast-math -fstrict-aliasing -fomit-frame-pointer -ftree-vectorize -funroll-all-loops -fpeel-loops -ftracer -funswitch-loops -finline-functions -G 0 -march=mips32 -mtune=r4600 -mno-mips16 -msoft-float -# -fprofile-use -ftest-coverage -fprofile-arcs +OPTIMISE= -D_ZAURUS -O3 -ffast-math -fstrict-aliasing -fomit-frame-pointer -ftree-vectorize -funroll-all-loops -fpeel-loops -ftracer -funswitch-loops -finline-functions -G 0 -march=mips32 -mno-mips16 -msoft-float +#-fprofile-generate +#-fprofile-use +#-mtune=r4600 -ftest-coverage CCFLAGS = $(OPTIMISE) \ -I. \ diff --git a/soundux.h b/soundux.h index 26552c4..02d9ada 100644 --- a/soundux.h +++ b/soundux.h @@ -214,8 +214,7 @@ void S9xSetEchoDelay (int byte); void S9xSetEchoWriteEnable (uint8 byte); void S9xSetFilterCoefficient (int tap, int value); void S9xSetFrequencyModulationEnable (uint8 byte); -void S9xSetEnvelopeRate (int channel, unsigned long rate, int direction, - int target); +void S9xSetEnvelopeRate (int channel, unsigned long rate, int direction, int target); bool8_32 S9xSetSoundMode (int channel, int mode); int S9xGetEnvelopeHeight (int channel); void S9xResetSound (bool8_32 full); diff --git a/unix/menu.cpp b/unix/menu.cpp index 757ad95..80e5488 100644 --- a/unix/menu.cpp +++ b/unix/menu.cpp @@ -21,7 +21,7 @@ extern Uint16 sfc_key[256]; extern bool8_32 Scale; extern char SaveSlotNum; -extern int vol; +extern short vol; extern void S9xDisplayString (const char *string, uint8 *, uint32, int ypos); void save_screenshot(char *fname); @@ -41,6 +41,11 @@ bool8_32 highres_current = false; char snapscreen[17120]={}; extern clock_t start; +void sys_sleep(int us) +{ + if(us>0) SDL_Delay(us/1000); +} + void menu_dispupdate(void){ char temp[256]; char disptxt[20][256]; @@ -197,14 +202,14 @@ void menu_loop(void) S9xInitDisplay(0, 0); menu_dispupdate(); - usleep(100000); + sys_sleep(100000); //usleep(100000); SDL_Event event; do { menu_dispupdate(); - usleep(100); + sys_sleep(100); //usleep(100); #ifdef CAANOO keyssnes = SDL_JoystickOpen(0); @@ -220,17 +225,107 @@ void menu_loop(void) // CAANOO ------------------------------------------------------------- case SDL_JOYBUTTONDOWN: keyssnes = SDL_JoystickOpen(0); + + if ( (SDL_JoystickGetAxis(keyssnes, 1) < -20000) || SDL_JoystickGetButton(keyssnes, sfc_key[START_1]) ) + cursor--; + else if( (SDL_JoystickGetAxis(keyssnes, 1) > 20000) || SDL_JoystickGetButton(keyssnes, sfc_key[SELECT_1]) ) + cursor++; + else if( SDL_JoystickGetButton(keyssnes, sfc_key[A_1]) || (SDL_JoystickGetAxis(keyssnes, 0) < -20000) ) + { + switch(cursor) + { + case 2: + if ( SDL_JoystickGetButton(keyssnes, sfc_key[A_1]) ) + { + S9xReset(); + exit_loop = TRUE; + } + break; + case 3: + if ( SDL_JoystickGetButton(keyssnes, sfc_key[A_1]) ) + { + memcpy(snapscreen,snapscreen_tmp,16050); + show_screenshot(); + strcpy(fname," Saving..."); + S9xDisplayString (fname, GFX.Screen +280, 640,204); + S9xDeinitUpdate (320, 240); + sprintf(ext, ".s0%d", SaveSlotNum); + strcpy(fname, S9xGetFilename (ext)); + save_screenshot(fname); + sprintf(ext, ".00%d", SaveSlotNum); + strcpy(fname, S9xGetFilename (ext)); + S9xFreezeGame (fname); + sync(); + exit_loop = TRUE; + } + break; + case 4: + if ( SDL_JoystickGetButton(keyssnes, sfc_key[A_1]) ) + { + sprintf(ext, ".00%d", SaveSlotNum); + strcpy(fname, S9xGetFilename (ext)); + S9xLoadSnapshot (fname); + exit_loop = TRUE; + } + break; + case 5: + if ( SDL_JoystickGetAxis(keyssnes, 0) < -20000 ) + SaveSlotNum--; + else SaveSlotNum++; + if(SaveSlotNum>3) + SaveSlotNum =0; + else if(SaveSlotNum<0) + SaveSlotNum=3; + break; + case 6: + Settings.DisplayFrameRate = !Settings.DisplayFrameRate; + break; + case 7: + Scale_org = !Scale_org; + break; + case 8: + if (Settings.SkipFrames == AUTO_FRAMERATE) + Settings.SkipFrames = 10; + + if ( SDL_JoystickGetAxis(keyssnes, 0) < -20000 ) + Settings.SkipFrames--; + else + Settings.SkipFrames++; + + if(Settings.SkipFrames>=10) + Settings.SkipFrames = AUTO_FRAMERATE; + else if (Settings.SkipFrames <=1) + Settings.SkipFrames = 1; + break; + case 9: + if ( SDL_JoystickGetAxis(keyssnes, 0) < -20000 ) + vol -= 10; + else vol += 10; + if(vol>=100) + vol = 100; + else if (vol <=0) + vol = 0; + break; + case 10: + if ( SDL_JoystickGetButton(keyssnes, sfc_key[A_1]) ) + ShowCredit(); + break; + case 11: + if ( SDL_JoystickGetButton(keyssnes, sfc_key[A_1]) ) + S9xExit(); + break; + } + } #else //PANDORA & DINGOO ------------------------------------------------------ case SDL_KEYDOWN: keyssnes = SDL_GetKeyState(NULL); + if(keyssnes[sfc_key[UP_1]] == SDL_PRESSED) cursor--; else if(keyssnes[sfc_key[DOWN_1]] == SDL_PRESSED) cursor++; - else if((keyssnes[sfc_key[A_1]] == SDL_PRESSED)|| - (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED)|| - (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED)) + else if( (keyssnes[sfc_key[A_1]] == SDL_PRESSED)|| (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED) ) { switch(cursor) { @@ -413,7 +508,8 @@ void capt_screenshot() //107px*80px } } -void show_screenshot(){ +void show_screenshot() +{ int s=0; for(int y=126;y<126+80;y++){ for(int x=248; x<248+107*2; x+=2){ @@ -424,7 +520,8 @@ void show_screenshot(){ } } -int batt_level(void){ +int batt_level(void) +{ FILE *FP; int mvolts; char buf[6]={}; @@ -436,7 +533,8 @@ int batt_level(void){ return (mvolts); } -int chk_hold(void){ +int chk_hold(void) +{ FILE *FP; uint32 hold=0; char buf[12]={}; @@ -451,7 +549,8 @@ int chk_hold(void){ return (0); } -int get_lcd_backlight(void){ +int get_lcd_backlight(void) +{ FILE *FP; int backlight=0; char buf[12]; @@ -463,7 +562,8 @@ int get_lcd_backlight(void){ return (backlight); } -void set_lcd_backlight(int bk){ +void set_lcd_backlight(int bk) +{ char buf[128]; sprintf(buf,"echo %d >/proc/jz/lcd_backlight",bk); @@ -471,17 +571,22 @@ void set_lcd_backlight(int bk){ //sync(); } -void ShowCredit(){ - uint8 *keyssnes; +void ShowCredit() +{ +#ifdef CAANOO + SDL_Joystick* keyssnes = 0; +#else + uint8 *keyssnes = 0; +#endif int line=0,ypix=0; char disptxt[100][256]={ "", "", "", "", - " Snes9x4D for Dingux", + " Snes9x4X", " ", - " Thank you using Snes9x4D! ", + " Thank you using this Emulator! ", " ", " Key Configurations, ", " State Save: START + R ", @@ -496,11 +601,17 @@ void ShowCredit(){ " regards to joyrider & g17" }; - do{ + do + { SDL_Event event; SDL_PollEvent(&event); + +#ifdef CAANOO + keyssnes = SDL_JoystickOpen(0); +#else keyssnes = SDL_GetKeyState(NULL); - +#endif + for(int y=12; y<=212; y++){ for(int x=10; x<246*2; x+=2){ memset(GFX.Screen + 320*y*2+x,0x11,2); @@ -520,8 +631,14 @@ void ShowCredit(){ } if(line == 20) line = 0; S9xDeinitUpdate (320, 240); - usleep(30000); - }while(keyssnes[sfc_key[B_1]] != SDL_PRESSED); + sys_sleep(30000); //usleep(30000); + } +#ifdef CAANOO + while( SDL_JoystickGetButton(keyssnes, sfc_key[A_1])!=TRUE ); +#else + while(keyssnes[sfc_key[B_1]] != SDL_PRESSED); +#endif + return; } diff --git a/unix/unix.cpp b/unix/unix.cpp index 285fb89..0bf00fd 100644 --- a/unix/unix.cpp +++ b/unix/unix.cpp @@ -134,14 +134,14 @@ char SaveSlotNum = 0; bool8_32 Scale = FALSE; char msg[256]; -int vol=50; +short vol=50; static int mixerdev = 0; clock_t start; int OldSkipFrame; void InitTimer (); void *S9xProcessSound (void *); -void gp2x_sound_volume(int l, int r); +//void gp2x_sound_volume(int l, int r); extern void S9xDisplayFrameRate (uint8 *, uint32); extern void S9xDisplayString (const char *string, uint8 *, uint32, int); @@ -1158,14 +1158,16 @@ void S9xProcessEvents (bool8_32 block) //QUIT Emulator if ( SDL_JoystickGetButton(keyssnes, sfc_key[QUIT]) && SDL_JoystickGetButton(keyssnes, sfc_key[B_1] ) ) { + S9xSetSoundMute(true); S9xExit(); } // MAINMENU else if ( SDL_JoystickGetButton(keyssnes, sfc_key[QUIT]) ) { - gp2x_sound_volume(0, 0); + S9xSetSoundMute(true); menu_loop(); - gp2x_sound_volume(vol, vol); + S9xSetSoundMute(false); + //S9xSetMasterVolume(vol,vol); } break; @@ -1182,12 +1184,15 @@ void S9xProcessEvents (bool8_32 block) // shortcut #ifdef PANDORA - if ( event.key.keysym.sym == SDLK_q ) { - exit ( 0 ); // just die + if ( event.key.keysym.sym == SDLK_q ) + { + S9xSetSoundMute(true); + exit ( 0 ); // just die } #endif //PANDORA //QUIT Emulator if ( (keyssnes[sfc_key[SELECT_1]] == SDL_PRESSED) &&(keyssnes[sfc_key[START_1]] == SDL_PRESSED) && (keyssnes[sfc_key[X_1]] == SDL_PRESSED) ) + S9xSetSoundMute(true); S9xExit(); //RESET ROM Playback else if ((keyssnes[sfc_key[SELECT_1]] == SDL_PRESSED) && (keyssnes[sfc_key[START_1]] == SDL_PRESSED) && (keyssnes[sfc_key[B_1]] == SDL_PRESSED)) @@ -1197,7 +1202,7 @@ void S9xProcessEvents (bool8_32 block) { //extern char snapscreen; char fname[256], ext[20]; - gp2x_sound_volume(0, 0); + S9xSetSoundMute(true); sprintf(ext, ".00%d", SaveSlotNum); strcpy(fname, S9xGetFilename (ext)); S9xFreezeGame (fname); @@ -1205,32 +1210,34 @@ void S9xProcessEvents (bool8_32 block) sprintf(ext, ".s0%d", SaveSlotNum); strcpy(fname, S9xGetFilename (ext)); save_screenshot(fname); - gp2x_sound_volume(vol, vol); + S9xSetSoundMute(false); } //LOAD State else if ( (keyssnes[sfc_key[START_1]] == SDL_PRESSED) && (keyssnes[sfc_key[L_1]] == SDL_PRESSED) ) { char fname[256], ext[8]; - gp2x_sound_volume(0, 0); + S9xSetSoundMute(true); sprintf(ext, ".00%d", SaveSlotNum); strcpy(fname, S9xGetFilename (ext)); S9xLoadSnapshot (fname); - gp2x_sound_volume(vol, vol); + S9xSetSoundMute(false); } // MAINMENU else if ((keyssnes[sfc_key[SELECT_1]] == SDL_PRESSED)&&(keyssnes[sfc_key[B_1]] == SDL_PRESSED) ) { - gp2x_sound_volume(0, 0); + S9xSetSoundMute(true); menu_loop(); - gp2x_sound_volume(vol, vol); + S9xSetSoundMute(false); + //S9xSetMasterVolume (vol, vol); #ifdef PANDORA - } - // another shortcut I'm afraid - else if (event.key.keysym.sym == SDLK_SPACE) - { - gp2x_sound_volume(0, 0); + } + // another shortcut I'm afraid + else if (event.key.keysym.sym == SDLK_SPACE) + { + S9xSetSoundMute(true); menu_loop(); - gp2x_sound_volume(vol, vol); + S9xSetSoundMute(false); + //S9xSetMasterVolume (vol, vol); #endif //PANDORA } break; @@ -1343,7 +1350,7 @@ bool8_32 S9xOpenSoundDevice (int mode, bool8_32 stereo, int buffer_size) so.playback_rate, so.buffer_size, so.sixteen_bit ? "yes" : "no", so.stereo ? "yes" : "no", so.encoded ? "yes" : "no"); - gp2x_sound_volume(vol,vol); +// gp2x_sound_volume(vol,vol); return (TRUE); } @@ -1549,12 +1556,14 @@ void *S9xProcessSound (void *) return (NULL); } +/* void gp2x_sound_volume(int l, int r) { l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r; l<<=8; l|=r; ioctl(mixerdev, SOUND_MIXER_WRITE_VOLUME, &l); } +*/ uint32 S9xReadJoypad (int which1) {