diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index 098e36f..01c18ba 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -619,13 +619,16 @@ ConfigureButtons (u16 ctrlr_type) int ctlrmenucount = 9; char ctlrmenu[][50] = { + // toggle: "MultiTap", "SuperScope", - "Mouse", + "Snes Mice", + "Justifiers", + // config: "Nunchuk", "Classic Controller", - "Gamecube Pad", "Wiimote", + "Gamecube Pad", "Save Preferences", "Go Back" }; @@ -640,24 +643,23 @@ ConfigureControllers () // disable unavailable controller options if in GC mode #ifndef HW_RVL - ctlrmenu[1][0] = '\0'; - ctlrmenu[2][0] = '\0'; ctlrmenu[4][0] = '\0'; + ctlrmenu[5][0] = '\0'; + ctlrmenu[6][0] = '\0'; #endif while (quit == 0) { sprintf (ctlrmenu[0], "MultiTap %s", Settings.MultiPlayer5Master == true ? " ON" : "OFF"); - if (GCSettings.Superscope > 0) - sprintf (ctlrmenu[1], "Superscope: Pad %d", GCSettings.Superscope); - else - sprintf (ctlrmenu[1], "Superscope OFF"); + if (GCSettings.Superscope > 0) sprintf (ctlrmenu[1], "Superscope: Pad %d", GCSettings.Superscope); + else sprintf (ctlrmenu[1], "Superscope OFF"); - if (GCSettings.Mouse > 0) - sprintf (ctlrmenu[2], "Mouse: Pad %d", GCSettings.Mouse); - else - sprintf (ctlrmenu[2], "Mouse OFF"); + if (GCSettings.Mouse > 0) sprintf (ctlrmenu[2], "Mice: %d", GCSettings.Mouse); + else sprintf (ctlrmenu[2], "Mice: OFF"); + + if (GCSettings.Justifier > 0) sprintf (ctlrmenu[3], "Justifiers: %d", GCSettings.Justifier); + else sprintf (ctlrmenu[3], "Justifiers: OFF"); /*** Controller Config Menu ***/ ret = RunMenu (ctlrmenu, ctlrmenucount, (char*)"Configure Controllers"); @@ -665,11 +667,7 @@ ConfigureControllers () switch (ret) { case 0: - Settings.MultiPlayer5Master = (Settings.MultiPlayer5Master == false ? true : false); - if (Settings.MultiPlayer5Master) - S9xSetController (1, CTL_MP5, 1, 2, 3, -1); - else - S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0); + Settings.MultiPlayer5Master ^= 1; break; case 1: GCSettings.Superscope ++; @@ -678,36 +676,42 @@ ConfigureControllers () break; case 2: GCSettings.Mouse ++; - if (GCSettings.Mouse > 4) + if (GCSettings.Mouse > 2) GCSettings.Mouse = 0; break; case 3: + GCSettings.Justifier ++; + if (GCSettings.Justifier > 2) + GCSettings.Justifier = 0; + break; + + case 4: /*** Configure Nunchuk ***/ ConfigureButtons (CTRLR_NUNCHUK); break; - case 4: + case 5: /*** Configure Classic ***/ ConfigureButtons (CTRLR_CLASSIC); break; - - case 5: - /*** Configure GC Pad ***/ - ConfigureButtons (CTRLR_GCPAD); - break; - + case 6: /*** Configure Wiimote ***/ ConfigureButtons (CTRLR_WIIMOTE); break; case 7: + /*** Configure GC Pad ***/ + ConfigureButtons (CTRLR_GCPAD); + break; + + case 8: /*** Save Preferences Now ***/ quickSavePrefs(NOTSILENT); break; case -1: /*** Button B ***/ - case 8: + case 9: /*** Return ***/ quit = 1; break; @@ -724,7 +728,7 @@ int menucount = 7; char menuitems[][50] = { "Choose Game", "Controller Configuration", "Preferences", "Game Menu", - "Credits", "Reset System", "Exit" + "Credits", "Reset System", "Return to Loader" }; void @@ -817,8 +821,8 @@ mainmenu (int selectedMenu) ReInitGCVideo(); // update video after reading settings - Settings.SuperScopeMaster = (GCSettings.Superscope > 0 ? true : false); // update superscope settings - Settings.MouseMaster = (GCSettings.Mouse > 0 ? true : false); // update mouse settings - // update mouse/justifier info? + Settings.SuperScopeMaster = (GCSettings.Superscope > 0 ? true : false); + Settings.MouseMaster = (GCSettings.Mouse > 0 ? true : false); + Settings.JustifierMaster = (GCSettings.Justifier > 0 ? true : false); SetControllers(); } diff --git a/source/ngc/menudraw.cpp b/source/ngc/menudraw.cpp index 0ae837a..6d80cd9 100644 --- a/source/ngc/menudraw.cpp +++ b/source/ngc/menudraw.cpp @@ -523,6 +523,7 @@ DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsiz int i, w = 0; int ypos = 0; int n = 1; + int line_height; ypos = 65; @@ -547,23 +548,27 @@ DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsiz // Draw menu items setfontsize (fontsize); // set font size + + line_height = (fontsize + 8); for (i = 0; i < maxitems; i++) { if(strlen(items[i]) > 0) { - if (i == selected) + if ( items[i] == NULL ) + ypos -= line_height; + else if (i == selected) { - for( w = 0; w < (fontsize + 8); w++ ) - DrawLineFast( 30, 610, n * (fontsize + 8) + (ypos-(fontsize + 2)) + w, 0x80, 0x80, 0x80 ); + for( w = 0; w < line_height; w++ ) + DrawLineFast( 30, 610, n * line_height + (ypos-line_height+6) + w, 0x80, 0x80, 0x80 ); setfontcolour (0xff, 0xff, 0xff); - DrawText (x, n * (fontsize + 8) + ypos, items[i]); + DrawText (x, n * line_height + ypos, items[i]); setfontcolour (0x00, 0x00, 0x00); } else { - DrawText (x, n * (fontsize + 8) + ypos, items[i]); + DrawText (x, n * line_height + ypos, items[i]); } n++; } diff --git a/source/ngc/preferences.cpp b/source/ngc/preferences.cpp index 78a6ac5..4a27e79 100644 --- a/source/ngc/preferences.cpp +++ b/source/ngc/preferences.cpp @@ -33,7 +33,7 @@ extern unsigned int ccpadmap[]; extern unsigned int ncpadmap[]; #define PREFS_FILE_NAME "snes9xGx.prf" -#define PREFSVERSTRING "Snes9x GX 005 Prefs" +#define PREFSVERSTRING "Snes9x GX 005a Prefs" char prefscomment[2][32] = { {PREFSVERSTRING}, {"Preferences"} }; diff --git a/source/ngc/s9xconfig.cpp b/source/ngc/s9xconfig.cpp index 6c3b59b..21f770e 100644 --- a/source/ngc/s9xconfig.cpp +++ b/source/ngc/s9xconfig.cpp @@ -185,6 +185,7 @@ DefaultSettings () GCSettings.render = 0; GCSettings.Superscope = 0; GCSettings.Mouse = 0; + GCSettings.Justifier = 0; /****************** SNES9x Settings ***********************/ @@ -197,7 +198,7 @@ DefaultSettings () Settings.MouseMaster = false; Settings.SuperScopeMaster = false; Settings.MultiPlayer5Master = false; - Settings.JustifierMaster = true; + Settings.JustifierMaster = false; Settings.ShutdownMaster = false; Settings.CyclesPercentage = 100; // snes9x 1.50 and earlier Settings.ApplyCheats = true; diff --git a/source/ngc/snes9xGX.cpp b/source/ngc/snes9xGX.cpp index 4daefde..d6e3bb4 100644 --- a/source/ngc/snes9xGX.cpp +++ b/source/ngc/snes9xGX.cpp @@ -199,7 +199,9 @@ extern int FrameTimer; extern long long prev; extern unsigned int timediffallowed; -int scope_x = 0; int scope_y = 0; // superscope cursor position +// hold superscope/mouse/justifier cursor positions +int cursor_x[5] = {0,0,0,0,0}; +int cursor_y[5] = {0,0,0,0,0}; extern void fat_enable_readahead_all(); @@ -250,41 +252,47 @@ unsigned int ncpadmap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B, }; /*** Superscope : GC controller button mapping ***/ unsigned int gcscopemap[] = { PAD_TRIGGER_Z, PAD_BUTTON_B, - PAD_BUTTON_A, PAD_BUTTON_Y, - PAD_BUTTON_START + PAD_BUTTON_A, PAD_BUTTON_Y, PAD_BUTTON_START }; /*** Superscope : wiimote button mapping ***/ unsigned int wmscopemap[] = { WPAD_BUTTON_MINUS, WPAD_BUTTON_B, - WPAD_BUTTON_A, WPAD_BUTTON_DOWN, - WPAD_BUTTON_PLUS + WPAD_BUTTON_A, WPAD_BUTTON_DOWN, WPAD_BUTTON_PLUS }; +/*** Mouse : GC controller button mapping ***/ +unsigned int gcmousemap[] = { PAD_BUTTON_A, PAD_BUTTON_B }; +/*** Mouse : wiimote button mapping ***/ +unsigned int wmmousemap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B }; +/*** Justifier : GC controller button mapping ***/ +unsigned int gcjustmap[] = { PAD_BUTTON_A, PAD_BUTTON_B, PAD_BUTTON_START }; +/*** Justifier : wiimote button mapping ***/ +unsigned int wmjustmap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B, WPAD_BUTTON_PLUS }; void UpdateCursorPosition (int pad, int &pos_x, int &pos_y) { // gc left joystick signed char pad_x = PAD_StickX (pad); signed char pad_y = PAD_StickY (pad); - int SCOPEPADCAL = 30; + int SCOPEPADCAL = 20; #ifdef HW_RVL // wiimote ir struct ir_t ir; #endif if (pad_x > SCOPEPADCAL){ - pos_x +=4; + pos_x += (pad_x*1.0)/SCOPEPADCAL; if (pos_x > 256) pos_x = 256; } if (pad_x < -SCOPEPADCAL){ - pos_x -=4; + pos_x -= (pad_x*-1.0)/SCOPEPADCAL; if (pos_x < 0) pos_x = 0; } if (pad_y < -SCOPEPADCAL){ - pos_y +=4; + pos_y += (pad_y*-1.0)/SCOPEPADCAL; if (pos_y > 224) pos_y = 224; } if (pad_y > SCOPEPADCAL){ - pos_y -=4; + pos_y -= (pad_y*1.0)/SCOPEPADCAL; if (pos_y < 0) pos_y = 0; } @@ -293,8 +301,8 @@ void UpdateCursorPosition (int pad, int &pos_x, int &pos_y) WPAD_IR(pad, &ir); if (ir.valid) { - scope_x = (ir.x * 256) / 640; - scope_y = (ir.y * 224) / 480; + pos_x = (ir.x * 256) / 640; + pos_y = (ir.y * 224) / 480; } #endif @@ -431,9 +439,51 @@ decodepad (int pad) S9xReportButton (offset + i, false); } // pointer - offset = 0x60; - UpdateCursorPosition (pad, scope_x, scope_y); - S9xReportPointer(offset, (u16)scope_x, (u16)scope_y); + offset = 0x80; + UpdateCursorPosition (pad, cursor_x[0], cursor_y[0]); + S9xReportPointer(offset, (u16)cursor_x[0], (u16)cursor_y[0]); + } + /*** Mouse ***/ + else if (Settings.MouseMaster && pad < GCSettings.Mouse) + { + // buttons + offset = 0x60+(2*pad); + for (i = 0; i < 2; i++) + { + if ( jp & gcmousemap[i] +#ifdef HW_RVL + || wp & wmmousemap[i] +#endif + ) + S9xReportButton (offset + i, true); + else + S9xReportButton (offset + i, false); + } + // pointer + offset = 0x81; + UpdateCursorPosition (pad, cursor_x[1+pad], cursor_y[1+pad]); + S9xReportPointer(offset+pad, (u16)cursor_x[1+pad], (u16)cursor_y[1+pad]); + } + /*** Justifier ***/ + else if (Settings.JustifierMaster && pad < GCSettings.Justifier) + { + // buttons + offset = 0x70+(3*pad); + for (i = 0; i < 3; i++) + { + if ( jp & gcjustmap[i] +#ifdef HW_RVL + || wp & wmjustmap[i] +#endif + ) + S9xReportButton (offset + i, true); + else + S9xReportButton (offset + i, false); + } + // pointer + offset = 0x83; + UpdateCursorPosition (pad, cursor_x[3+pad], cursor_y[3+pad]); + S9xReportPointer(offset+pad, (u16)cursor_x[3+pad], (u16)cursor_y[3+pad]); } } /**************************************************************************** @@ -607,8 +657,13 @@ void SetControllers () } else if (Settings.MouseMaster == true) { - S9xSetController (0, CTL_MOUSE, 0, 0, 0, 0); - S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0); + S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0); + S9xSetController (1, CTL_MOUSE, (GCSettings.Mouse == 2), 0, 0, 0); + } + else if (Settings.JustifierMaster == true) + { + S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0); + S9xSetController(1, CTL_JUSTIFIER, (GCSettings.Justifier == 2), 0, 0, 0); } else { @@ -694,10 +749,29 @@ SetDefaultButtonMap () ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Cursor"); ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo"); ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Pause"); - + maxcode = 0x60; + /*** Mouse ***/ + ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 L"); + ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 R"); + ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 L"); + ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 R"); + + maxcode = 0x70; + /*** Justifier ***/ + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 AimOffscreen"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Trigger"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 AimOffscreen"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Trigger"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Start"); + + maxcode = 0x80; S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Superscope"), false); - // add mouses here + S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse1"), false); + S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse2"), false); + S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier1"), false); + S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier2"), false); SetControllers (); diff --git a/source/ngc/snes9xGX.h b/source/ngc/snes9xGX.h index 5d83768..2b4db00 100644 --- a/source/ngc/snes9xGX.h +++ b/source/ngc/snes9xGX.h @@ -196,7 +196,8 @@ struct SGCSettings{ uint8 VerifySaves; u16 render; // 0 - original, 1 - no AA u16 Superscope; - u16 Mouse; + u16 Mouse; + u16 Justifier; }; START_EXTERN_C