From c8286ae96360246df279f860c9e3dbd640f4acdb Mon Sep 17 00:00:00 2001 From: "fabio.olimpieri" Date: Sat, 10 Dec 2011 16:55:26 +0000 Subject: [PATCH] Added rumble support and aspect ratio --- CHANGES.wii | 14 ++++++---- Makefile.wii | 2 +- src/cfgfile.c | 12 +++++++- src/drawing.c | 6 +++- src/gfx-sdl/sdlgfx.c | 9 +++++- src/gui-sdl/gui-sdl.c | 65 ++++++++++++++++++++++++++++++++----------- src/include/options.h | 2 ++ src/jd-sdl/joystick.c | 59 +++++++++++++++++++++++++++++++++++++++ uaerc.wii | 6 ++++ 9 files changed, 148 insertions(+), 27 deletions(-) diff --git a/CHANGES.wii b/CHANGES.wii index c9efa38..16021a1 100644 --- a/CHANGES.wii +++ b/CHANGES.wii @@ -1,10 +1,12 @@ version 7: - *Fixed Hardfile and virtual filesystem support - *Added virtual keyboard - *Added several menu options (immediate blits, collision level, real CPU speed, scanlines, ntsc and sound) - *Menu reorganization - *Other small improvements + * Fixed Hardfile and virtual filesystem support + * Added virtual keyboard + * Added several menu options (immediate blits, collision level, real CPU speed, scanlines, ntsc and sound) + * Menu reorganization + * Other small improvements + -- Fabio Olimpieri , Nov 27 CEST 2011 + version 6: *(build) Update to devkitpro r24 and libogc 1.8.8 * Added SMB support @@ -21,7 +23,7 @@ version 6: * Fixed second Joystick configuration issue * Other small fixes - -- Fabio Olimpieri , sept 23 CEST 2011 + -- Fabio Olimpieri , Oct 23 CEST 2011 version 5.1: diff --git a/Makefile.wii b/Makefile.wii index 5074470..841433b 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -178,7 +178,7 @@ dist:uae.dol cd $@ && tar -czf ../uae-wii-bin.tar.gz * distsource: - cd .. && cp uae-wii uae-wii-v + cd .. && cp -r uae-wii uae-wii-v cd ../uae-wii-v && find . -name ".svn" | xargs rm -rf cd .. && tar -czf uae-wii-v.tar.gz uae-wii-v diff --git a/src/cfgfile.c b/src/cfgfile.c index 935733a..a416aaf 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -559,6 +559,8 @@ void save_options (FILE *f, const struct uae_prefs *p, int type) #if defined GEKKO //cfgfile_write (f, "wii_use_mario_kart_wheel=%s\n", p->use_wheel_input ? "yes" : "no"); cfgfile_write (f, "wii_port=%d\n", p->Port); + cfgfile_write (f, "rumble=%s\n", p->rumble? "true" : "false"); + cfgfile_write (f, "gfx_correct_ratio=%d\n", p->gfx_correct_ratio); #endif #ifdef FILESYS @@ -856,11 +858,17 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) //return 1; if (cfgfile_intval (option, value, "wii_port", &p->Port, 1)) return 1; if (cfgfile_yesno (option, value, "smb_enable", &p->smb_enable)) return 1; + if (cfgfile_yesno (option, value, "rumble", &p->rumble)) return 1; if (cfgfile_string (option, value, "user", p->SmbUser, 32) || cfgfile_string (option, value, "password", p->SmbPwd,32) || cfgfile_string (option, value, "share_name", p->SmbShare, 32) || cfgfile_string (option, value, "smb_ip", p->SmbIp, 32)) return 1; - + if (cfgfile_intval (option, value, "gfx_correct_ratio", &p->gfx_correct_ratio, 1)) + { + if (p->gfx_correct_ratio < 80) p->gfx_correct_ratio = 80; + if (p->gfx_correct_ratio > 100) p->gfx_correct_ratio = 100; + return 1; + } #endif if (cfgfile_yesno (option, value, "logfile", &p->logfile)) return 1; @@ -2488,6 +2496,8 @@ void default_prefs (struct uae_prefs *p, int type) strcpy (p->SmbShare, "Share"); strcpy (p->SmbIp, "192.168.0.1"); p->Port= PORT_SD; + p->rumble= 0; + p->gfx_correct_ratio = 100; #endif p->logfile= 0; diff --git a/src/drawing.c b/src/drawing.c index da701d2..34f1bc1 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -1046,7 +1046,11 @@ static void init_aspect_maps (void) native_lines_per_amiga_line = ((double)gfxvidinfo.height * (currprefs.gfx_lores ? 320 : 640) / (currprefs.gfx_linedbl ? 512 : 256) - / gfxvidinfo.width); + / gfxvidinfo.width +#ifdef GEKKO + *currprefs.gfx_correct_ratio/100 +#endif + ); else native_lines_per_amiga_line = 1; diff --git a/src/gfx-sdl/sdlgfx.c b/src/gfx-sdl/sdlgfx.c index 89ac951..52a8c10 100644 --- a/src/gfx-sdl/sdlgfx.c +++ b/src/gfx-sdl/sdlgfx.c @@ -1369,7 +1369,11 @@ int check_prefs_changed_gfx (void) && changed_prefs.gfx_xcenter == currprefs.gfx_xcenter && changed_prefs.gfx_ycenter == currprefs.gfx_ycenter && changed_prefs.gfx_afullscreen == currprefs.gfx_afullscreen - && changed_prefs.gfx_pfullscreen == currprefs.gfx_pfullscreen) { + && changed_prefs.gfx_pfullscreen == currprefs.gfx_pfullscreen + #ifdef GEKKO + && changed_prefs.gfx_correct_ratio == currprefs.gfx_correct_ratio + #endif + ) { return 0; } @@ -1391,6 +1395,9 @@ int check_prefs_changed_gfx (void) currprefs.gfx_ycenter = changed_prefs.gfx_ycenter; currprefs.gfx_afullscreen = changed_prefs.gfx_afullscreen; currprefs.gfx_pfullscreen = changed_prefs.gfx_pfullscreen; + #ifdef GEKKO + currprefs.gfx_correct_ratio = changed_prefs.gfx_correct_ratio; + #endif #ifdef PICASSO96 if (!screen_is_picasso) diff --git a/src/gui-sdl/gui-sdl.c b/src/gui-sdl/gui-sdl.c index c11fbe1..ed7de7b 100644 --- a/src/gui-sdl/gui-sdl.c +++ b/src/gui-sdl/gui-sdl.c @@ -36,6 +36,8 @@ extern int usbismount, smbismount; extern const char *strdup_path_expand (const char *src); +int gui_is_active; + static void default_config(void); static const char *main_menu_messages[] = { @@ -112,7 +114,7 @@ static const int z3fastmem_size_table[] = { 0, 1024 * 1024, 2048 * 1024, 4096 * static const char *cpu_chipset_messages[] = { /*00*/ "CPU type", - /*01*/ "^|68000|68010|68020|68030|68040|68060", + /*01*/ "^|68000|68010|68020|68020/68881|68040|68060", /*02*/ " ", /*03*/ "Chipset type", /*04*/ "^|OCS|ECS AGNUS|ECS|AGA", @@ -145,20 +147,24 @@ static const char *emulation_messages[] = { static const char *graphic_messages[] = { - /*06*/ "Correct aspect", + /*00*/ "Correct aspect", + /*01*/ "^|off|100%|95%|93%|90%|custom", + /*02*/ " ", + /*03*/ "Scanlines", + /*04*/ "^|on|off", + /*05*/ " ", + /*06*/ "Leds", /*07*/ "^|on|off", - /*05*/ " ", - /*06*/ "Scanlines", - /*07*/ "^|on|off", - /*05*/ " ", - /*08*/ "Leds", - /*09*/ "^|on|off", - /*05*/ " ", - /*10*/ "Port", - /*11*/ "^|SD|USB|SMB", + /*08*/ " ", + /*09*/ "Port", + /*10*/ "^|SD|USB|SMB", + /*11*/ " ", + /*12*/ "Rumble", + /*13*/ "^|on|off", NULL }; +static const int correct_aspect_table[] = {0,100,95,93,90}; static const int cpu_to_chipset_table[] = {0,-1,512*2,512*4, 512*8, 512*12, 512*16, 512*20}; static const int floppy_table[] = {100, 0, 400, 800}; static const int framerate_table[] = {1, 2, 3, 4, 8}; @@ -398,7 +404,7 @@ static void set_floppy_speed(int which) static void set_gfx_framerate(int which) { /* Custom setting - don't touch! */ - if (which > SDL_arraysize(framerate_table)) + if (which > SDL_arraysize(framerate_table)-1) return; changed_prefs.gfx_framerate = framerate_table[which]; } @@ -410,6 +416,24 @@ static int get_gfx_framerate(void) } +static void set_gfx_aspect_ratio(int which) +{ + if (!which) {changed_prefs.gfx_correct_aspect = 0; return;} + /* Custom setting or correct aspect off - don't touch! */ + if (which > SDL_arraysize(correct_aspect_table)-1) + return; + changed_prefs.gfx_correct_aspect = 1; + changed_prefs.gfx_correct_ratio = correct_aspect_table[which]; +} + +static int get_gfx_aspect_ratio(void) +{ + if (!changed_prefs.gfx_correct_aspect) return 0; + else + return find_index_by_val(changed_prefs.gfx_correct_ratio, correct_aspect_table, + SDL_arraysize(correct_aspect_table), 5); +} + /* Helpers to determine the accuracy */ static int get_emulation_accuracy(void) { @@ -547,26 +571,30 @@ static void emulation_options(void) static void graphic_options(void) { - int submenus[4]; + int submenus[5]; int opt; memset(submenus, 0, sizeof(submenus)); - submenus[0] = !changed_prefs.gfx_correct_aspect; + + submenus[0] = get_gfx_aspect_ratio(); submenus[1] = !(changed_prefs.gfx_linedbl == 2) ; submenus[2] = !changed_prefs.leds_on_screen; submenus[3] = changed_prefs.Port; + submenus[4] = !changed_prefs.rumble; opt = menu_select_title("Other options menu", graphic_messages, submenus); if (opt < 0) return; - changed_prefs.gfx_correct_aspect = !submenus[0]; + set_gfx_aspect_ratio(submenus[0]); changed_prefs.gfx_linedbl = submenus[1] ? 1 : 2; changed_prefs.leds_on_screen = !submenus[2]; - currprefs.leds_on_screen = changed_prefs.leds_on_screen; set_Port(submenus[3]); + changed_prefs.rumble = !submenus[4]; + currprefs.leds_on_screen = changed_prefs.leds_on_screen; + currprefs.rumble = changed_prefs.rumble; } /* There are a few unfortunate header problems, so I'll do like this for now */ @@ -886,6 +914,7 @@ void gui_display(int shortcut) { int submenus[3]; int opt; + gui_is_active=1; pause_sound(); memset(submenus, 0, sizeof(submenus)); @@ -932,7 +961,8 @@ void gui_display(int shortcut) help(); break; case 14: - if (msgYesNo("Are you sure to quit?", 0, FULL_DISPLAY_X /2-138, FULL_DISPLAY_Y /2-48)) uae_quit(); + if (msgYesNo("Are you sure to quit?", 0, FULL_DISPLAY_X /2-138, FULL_DISPLAY_Y /2-48)) + {currprefs.rumble=0; uae_quit();} break; default: break; @@ -940,6 +970,7 @@ void gui_display(int shortcut) } while (opt == 0 || opt == 5 || opt == 8 || opt == 9 || opt == 10 || opt == 13); resume_sound(); + gui_is_active=0; } void gui_message (const char *format,...) diff --git a/src/include/options.h b/src/include/options.h index 3e422bc..3d2c22b 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -253,6 +253,8 @@ struct uae_prefs { char SmbShare[32]; char SmbIp[32]; int Port; //SD, USB or SMB + int rumble; + int gfx_correct_ratio; #endif /* input */ diff --git a/src/jd-sdl/joystick.c b/src/jd-sdl/joystick.c index cb20d1d..2bb32a8 100644 --- a/src/jd-sdl/joystick.c +++ b/src/jd-sdl/joystick.c @@ -15,6 +15,13 @@ #include "inputdevice.h" #include +#if defined(GEKKO) +# include +# include +#endif + +extern int gui_is_active; + static unsigned int nr_joysticks; static int initialized; @@ -26,6 +33,55 @@ struct joyinfo { static struct joyinfo joys[MAX_INPUT_DEVICES]; +//Wiimote Rumble +#ifdef GEKKO +void Rumble(unsigned int nr, unsigned int i, int bs) +{ + static Uint32 last_ticks[MAX_INPUT_DEVICES]; + Uint32 cur_ticks; + static bool rumble_on[MAX_INPUT_DEVICES]; + static bool fire_pressed[MAX_INPUT_DEVICES]; + static int joystickbutton_fire[MAX_INPUT_DEVICES]={-1,-1,-1,-1,-1,-1}; + int kc; + + cur_ticks = SDL_GetTicks(); + + kc = currprefs.joystick_settings[1][nr].eventid[i][0]; + + if (bs && (kc == INPUTEVENT_JOY2_FIRE_BUTTON || kc == INPUTEVENT_JOY1_FIRE_BUTTON) && !rumble_on[nr] && !fire_pressed[nr]) + { + WPAD_Rumble(nr, true); + last_ticks[nr]= cur_ticks; + rumble_on[nr]=true; + fire_pressed[nr]=true; + joystickbutton_fire[nr]=i; + } + + if (joystickbutton_fire[nr] == i) + { + if (!bs && (kc == INPUTEVENT_JOY2_FIRE_BUTTON || kc == INPUTEVENT_JOY1_FIRE_BUTTON) && rumble_on[nr] && fire_pressed[nr]) + { + rumble_on[nr]=true; + fire_pressed[nr]=false; + } + + if (((cur_ticks - last_ticks[nr] > 120) && rumble_on[nr] && !fire_pressed[nr]) \ + ||(!bs && (kc == INPUTEVENT_JOY2_FIRE_BUTTON || kc == INPUTEVENT_JOY1_FIRE_BUTTON) && !rumble_on[nr] && fire_pressed[nr])) + { + WPAD_Rumble(nr, false); + rumble_on[nr]=false; + fire_pressed[nr]=false; + joystickbutton_fire[nr]=-1; + } + if ((cur_ticks - last_ticks[nr] > 120) && rumble_on[nr] && fire_pressed[nr]) + { + WPAD_Rumble(nr, false); + rumble_on[nr]=false; + fire_pressed[nr]=true; + } + } +} +#endif static void read_joy (unsigned int nr) { @@ -66,6 +122,9 @@ static void read_joy (unsigned int nr) for (i = 0; i < num; i++) { int bs = SDL_JoystickGetButton (joy, i) ? 1 : 0; setjoybuttonstate (nr, i, bs); + #ifdef GEKKO + if (!gui_is_active && currprefs.rumble) Rumble (nr,i, bs); + #endif } } diff --git a/uaerc.wii b/uaerc.wii index 55d65ca..ec1056b 100644 --- a/uaerc.wii +++ b/uaerc.wii @@ -30,6 +30,8 @@ cpu_type=68000 immediate_blits=true collision_level=playfields + +#Use the 32 bit Motorola CPU 68020 version cpu_24bit_addressing=false # Emulation precision @@ -154,6 +156,10 @@ gfx_vsync=false # Set true to adapt the Amiga screen to Wii screen gfx_correct_aspect=false +# Set the screen correct % ratio when gfx_correct_aspect is true - possible values 80-100 +gfx_correct_ratio=93 + + # Set the framerate gfx_framerate=2