diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a322eb..d2abe8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0) set(CMAKE_VERBOSE_MAKEFILE OFF) set(VERSION_MAJOR 1) -set(VERSION_MINOR 73) +set(VERSION_MINOR 74) if(BUILD_PSP2) if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) diff --git a/README.MD b/README.MD index 053f21c..5fcd8d9 100644 --- a/README.MD +++ b/README.MD @@ -1,3 +1,13 @@ +Changes in this Version +====== +1.74 (Switch only) + +- Allow remapping of ZR/ZL on Switch +- Map ZR/ZL to "slow-down mouse" on Switch if custom controls are off +- Add option to misc menu to choose either A or B as OK button on Switch +- Add sharp-bilinear-simple scaling routine, and make it the new default +- Add point filtering scaling routine + Description ===== Use4All2 Mod is an Amiga emulator for Vita and Switch. This is my mod of this great Amiga emulator that was originally ported to the Vita by Cpasjuste. Depending on when you read this, this mod might be ahead or behind his version. @@ -10,7 +20,7 @@ Thanks to ScHlAuChi for extensive testing, ideas, and for contributing the new l Thanks to the original authors Chui, john4p, TomB, notaz, Bernd Schneider, Toni Wilen, Pickle, smoku, AnotherGuest, Anonymous engineer, finkel, Lubomyr, pelya and many more. -Thanks to my supporters on Patreon: Andyways, CountDuckula, Matthew Machnee, and Sean Ritzo. +Thanks to my supporters on Patreon: Andyways, CountDuckula, Matthew Machnee, and RadicalR. Installation ====== @@ -33,6 +43,7 @@ Vita/Switch-exclusive Features - Multiple hard-file support: up to 4 hdf files (size <2GB each) can be mounted simultaneously - Multiple controller support on Vita TV: up to four paired controllers can be fully mapped - Analog mouse control: control the mouse using the analog stick with adjustable sensitivity +- Shader support: default "sharp_bilinear_simple" uses integer pre-scale for sharp, undistorted pixels with minimum blur, even if game is zoomed to fill the full screen - Custom autofire: any mapped Vita button can have autofire with adjustable rate - Savestate with hard-file support: state can be saved even when hard-files are used - Additional emulator settings: sprite-sprite collisions can be enabled, blitter settings can be changed @@ -45,23 +56,17 @@ Vita/Switch-exclusive Features Vita-exclusive Features ====== -- Shader support: default "sharp_bilinear_simple" uses integer pre-scale for sharp, undistorted pixels with minimum blur, even if game is zoomed to fill the full Vita screen. - Bluetooth keyboard and mouse support - Supports loading files from ux0: or uma0: partition - Rear touch panel can be enabled for mouse pointer control -Switch-exclusive Features -====== -- On the Switch, there's no shader support yet. But the Switch resolution is high enough for perfect integer scaling with factor 3x if displayed lines is not larger than 240 and width is not larger than 426. Filtering can be set to "Bilinear" or "None". When "Bilinear" is selected, the screen is scaled to fill the Vita display, keeping aspect ratio. No black bars on top and bottom appear. The image can be quickly zoomed using "R+Start+left/right" and vertically adjusted using "R+Start+up/down" to center it. When "None" is selected, only a perfect integer scaling is applied. Depending on the chosen Amiga screenmode, the integer scaling will be a 1x, 2x, 3x, or in principle even 4x, depending on whether the scaled Amiga screen fits. In most cases, this results in black bars on top and bottom as well as left and right. - Notes ====== - *Bios:* Please put kickstart files in `ux0:/data/uae4all/kickstarts` on Vita and in `/switch/uae4all2/kickstarts` directory on Switch. Files must be named as kick13.rom, kick20.rom, kick31.rom - *Speed:* Most games run full speed. Some slow Amiga 1200 and WHDLoad games actually run faster if the CPU speed is reduced from 14 MHz to 7 MHz, because they rely more on custom chips than CPU. Some graphics glitches in Lionheart WHDLoad inside the caves are fixed by this. - *Config File:* If you have problems with settings not saving etc, please delete or rename your config file in the folder `ux0:/data/uae4all` (Vita) or `/switch/uae4all2/conf/` and restart the emu. I heard this can fix many problems when you are replacing an older version of this emulator with a newer version. Lots of things are changing in the config file between releases. -- *Display on Vita:* On the Vita, the sharp_bilinear_simple shader, on by default, creates a sharp pixel image with minimal blurring. It applies a maximum integer pre-scale first. Then it scales only the small remainder using the builtin bilinear filter, keeping the aspect ratio intact. -- *Display on Switch:* On Switch, there is no shader support yet. But the 720p resolution on Switch allows 3* integer scaling as long as the displayed lines are <=240 and width is <426. This can be selected in the display menu under `shader`. There are two settings: `None (perfect integer scaling)` with black bars on top and bottom, or `bilinear (a little blurry)`, without black bars on top and bottom. -- *Screen settings:* Many Amiga games fit the screen very nicely. For example, take Chaos Engine with a screen setting of 320*200 and sharp_bilinear_simple shader enabled (or bilinear on Switch). The picture can be zoomed using R+Start+Dpad left/right, and moved vertically using R+Start+Dpad up/down to center it on the screen. Once this is done, the picture fills almost the whole screen and looks amazing with no artifacts and, on Vita, almost no blurriness. The game runs smooth with zero frameskip. +- *Display:* The sharp_bilinear_simple shader, on by default, creates a sharp pixel image with minimal blurring. It applies a maximum integer pre-scale first. Then it scales only the small remainder using the builtin bilinear filter, keeping the aspect ratio intact. + Many Amiga games fit the Vita screen very nicely. For example, take Chaos Engine with a screen setting of 320*200 and sharp_bilinear_simple shader enabled. The picture can be zoomed using R+Start+Dpad left/right, and moved vertically using R+Start+Dpad up/down to center it on the Vita screen. Once this is done, the picture fills almost the whole screen and looks amazing with no artifacts or blurriness. The game runs smooth with zero frameskip. Selecting a 'Preset Width' of 320, 352 or 384 (max overscan) results in lo-res screen emulation, good for most games, while 640, 704, or 768 results in hi-res screen emulation, good for use with Workbench or some text-based games. - *Blitter:* The blitter settings can help with graphics glitches in some games. Since it seems to work best, "immediate" is the default. But some games require setting blitter to "normal" and re-booting to remove graphics glitches, for example PP Hammer, Spindizzy Worlds, and Shufflepuck Cafe. - *WHDLoad:* If you have problems with a WHDLoad .hdf game, maybe try an .adf version of the same game. Rock'n Roll is one of a few games that work on UAE4All2 only using .adf files. It has graphics glitches and runs too fast in WHDLoad with .hdf. To make it work correctly, I loaded the "Rock'n Roll.adf" from Gamebase Amiga, chose the preset A500 config, and changed the Blitter setting to Normal. @@ -127,7 +132,12 @@ Controls Switch: ----- -Switch uses exactly the same controls as the Vita, with the following meaning: +The default OK button in menu and on-screen keyboard is B. This can be changed to A in "more options." + +ZR button = slow-mouse (if custom controls are off) +ZL button = slow-mouse (if custom controls are off) + +Otherwise Switch uses exactly the same controls as the Vita (see below), with the following meaning: Square = Y Triangle = X Cross = B @@ -172,10 +182,10 @@ Virtual keyboard controls Start = Toggle virtual keyboard Right analog stick up/down = Move virtual keyboard up and down Right analog stick left/right = Change virtual keyboard transparency -Cross = Press selected key +Cross = Press selected key (on Switch, this can be changed from B to A) Square = Backspace Triangle = Toggle shift -Circle = Turn off all sticky keys (ctrl, alt, amiga, and shift) +Circle = Turn off all sticky keys (ctrl, alt, amiga, and shift) (on Switch, this can be changed from A to B) Touch controls ----- @@ -193,6 +203,14 @@ Mouse + keyboard tested working with the "Jelly Comb Mini Bluetooth Keyboard Wit CHANGELOG ===== +1.74 (Switch only) + +- Allow remapping of ZR/ZL on Switch +- Map ZR/ZL to "slow-down mouse" on Switch if custom controls are off +- Add option to misc menu to choose either A or B as OK button on Switch +- Add sharp-bilinear-simple scaling routine, and make it the new default +- Add point filtering scaling routine + 1.73 (Switch only) - Fix savestates on Switch diff --git a/src/gp2x/menu/menu.h b/src/gp2x/menu/menu.h index 3a4fa12..583bffe 100755 --- a/src/gp2x/menu/menu.h +++ b/src/gp2x/menu/menu.h @@ -103,3 +103,7 @@ enum { MEMDISK_MENU_CASE_MAIN, MEMDISK_MENU_CASE_MISC }; #define MENU_LOAD_HDF 3 #define MENU_LOAD_CONFIG 4 #define MENU_LOAD_KICKROM 5 + +#ifdef __SWITCH__ +#define DEFAULT_SWAPAB 0 +#endif diff --git a/src/gp2x/menu/menu_config.cpp b/src/gp2x/menu/menu_config.cpp index c992386..6f75f3b 100755 --- a/src/gp2x/menu/menu_config.cpp +++ b/src/gp2x/menu/menu_config.cpp @@ -89,6 +89,12 @@ int mainMenu_custom_X[4] = {0,0,0,0}; int mainMenu_custom_Y[4] = {0,0,0,0}; int mainMenu_custom_L[4] = {0,0,0,0}; int mainMenu_custom_R[4] = {0,0,0,0}; +#ifdef __SWITCH__ +int mainMenu_custom_L2[4] = {0,0,0,0}; +int mainMenu_custom_R2[4] = {0,0,0,0}; +int mainMenu_custom_L3[4] = {0,0,0,0}; +int mainMenu_custom_R3[4] = {0,0,0,0}; +#endif #if defined(__PSP2__) || defined(__SWITCH__) int mainMenu_custom_controlSet = 0; //This controls which custom config is used int mainMenu_custom1_up[4] = {0,0,0,0}; @@ -101,6 +107,12 @@ int mainMenu_custom1_X[4] = {0,0,0,0}; int mainMenu_custom1_Y[4] = {0,0,0,0}; int mainMenu_custom1_L[4] = {0,0,0,0}; int mainMenu_custom1_R[4] = {0,0,0,0}; +#ifdef __SWITCH__ +int mainMenu_custom1_L2[4] = {0,0,0,0}; +int mainMenu_custom1_R2[4] = {0,0,0,0}; +int mainMenu_custom1_L3[4] = {0,0,0,0}; +int mainMenu_custom1_R3[4] = {0,0,0,0}; +#endif int mainMenu_custom2_up[4] = {0,0,0,0}; int mainMenu_custom2_down[4] = {0,0,0,0}; int mainMenu_custom2_left[4] = {0,0,0,0}; @@ -111,6 +123,12 @@ int mainMenu_custom2_X[4] = {0,0,0,0}; int mainMenu_custom2_Y[4] = {0,0,0,0}; int mainMenu_custom2_L[4] = {0,0,0,0}; int mainMenu_custom2_R[4] = {0,0,0,0}; +#ifdef __SWITCH__ +int mainMenu_custom2_L2[4] = {0,0,0,0}; +int mainMenu_custom2_R2[4] = {0,0,0,0}; +int mainMenu_custom2_L3[4] = {0,0,0,0}; +int mainMenu_custom2_R3[4] = {0,0,0,0}; +#endif int mainMenu_custom3_up[4] = {0,0,0,0}; int mainMenu_custom3_down[4] = {0,0,0,0}; int mainMenu_custom3_left[4] = {0,0,0,0}; @@ -121,6 +139,12 @@ int mainMenu_custom3_X[4] = {0,0,0,0}; int mainMenu_custom3_Y[4] = {0,0,0,0}; int mainMenu_custom3_L[4] = {0,0,0,0}; int mainMenu_custom3_R[4] = {0,0,0,0}; +#ifdef __SWITCH__ +int mainMenu_custom3_L2[4] = {0,0,0,0}; +int mainMenu_custom3_R2[4] = {0,0,0,0}; +int mainMenu_custom3_L3[4] = {0,0,0,0}; +int mainMenu_custom3_R3[4] = {0,0,0,0}; +#endif #endif int mainMenu_autofire = DEFAULT_AUTOFIRE; @@ -148,6 +172,9 @@ int mainMenu_leftStickMouse = 0; int mainMenu_touchControls = 1; int mainMenu_deadZone = 1000; #endif +#ifdef __SWITCH__ +int mainMenu_swapAB = DEFAULT_SWAPAB; +#endif // The following params in use, but can't be changed with gui int mainMenu_autosave = DEFAULT_AUTOSAVE; @@ -265,6 +292,12 @@ void SetDefaultMenuSettings(int general) mainMenu_custom_Y[i] = 0; mainMenu_custom_L[i] = 0; mainMenu_custom_R[i] = 0; +#ifdef __SWITCH__ + mainMenu_custom_L2[i] = 0; + mainMenu_custom_R2[i] = 0; + mainMenu_custom_L3[i] = 0; + mainMenu_custom_R3[i] = 0; +#endif } #if defined(__PSP2__) || defined(__SWITCH__) mainMenu_custom_controlSet = 0; @@ -280,6 +313,12 @@ void SetDefaultMenuSettings(int general) mainMenu_custom1_Y[i] = 0; mainMenu_custom1_L[i] = 0; mainMenu_custom1_R[i] = 0; +#ifdef __SWITCH__ + mainMenu_custom1_L2[i] = 0; + mainMenu_custom1_R2[i] = 0; + mainMenu_custom1_L3[i] = 0; + mainMenu_custom1_R3[i] = 0; +#endif mainMenu_custom2_up[i] = 0; mainMenu_custom2_down[i] = 0; mainMenu_custom2_left[i] = 0; @@ -290,6 +329,12 @@ void SetDefaultMenuSettings(int general) mainMenu_custom2_Y[i] = 0; mainMenu_custom2_L[i] = 0; mainMenu_custom2_R[i] = 0; +#ifdef __SWITCH__ + mainMenu_custom2_L2[i] = 0; + mainMenu_custom2_R2[i] = 0; + mainMenu_custom2_L3[i] = 0; + mainMenu_custom2_R3[i] = 0; +#endif mainMenu_custom3_up[i] = 0; mainMenu_custom3_down[i] = 0; mainMenu_custom3_left[i] = 0; @@ -300,6 +345,13 @@ void SetDefaultMenuSettings(int general) mainMenu_custom3_Y[i] = 0; mainMenu_custom3_L[i] = 0; mainMenu_custom3_R[i] = 0; +#ifdef __SWITCH__ + mainMenu_custom3_L2[i] = 0; + mainMenu_custom3_R2[i] = 0; + mainMenu_custom3_L3[i] = 0; + mainMenu_custom3_R3[i] = 0; +#endif + } #endif //__PSP2__ SetPresetMode(2); @@ -322,7 +374,9 @@ void SetDefaultMenuSettings(int general) mainMenu_touchControls = 1; mainMenu_deadZone = 1000; #endif - +#ifdef __SWITCH__ + mainMenu_swapAB = DEFAULT_SWAPAB; +#endif // The following params can't be changed in gui skipintro = DEFAULT_SKIPINTRO; mainMenu_autosave = DEFAULT_AUTOSAVE; @@ -1088,6 +1142,16 @@ int saveconfig(int general) fputs(buffer,f); snprintf((char*)buffer, 255, "custom1_R_Ply%d=%d\n",i,mainMenu_custom1_R[i]); fputs(buffer,f); +#ifdef __SWITCH__ + snprintf((char*)buffer, 255, "custom1_L2_Ply%d=%d\n",i,mainMenu_custom1_L2[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom1_R2_Ply%d=%d\n",i,mainMenu_custom1_R2[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom1_L3_Ply%d=%d\n",i,mainMenu_custom1_L3[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom1_R3_Ply%d=%d\n",i,mainMenu_custom1_R3[i]); + fputs(buffer,f); +#endif snprintf((char*)buffer, 255, "custom2_up_Ply%d=%d\n",i,mainMenu_custom2_up[i]); fputs(buffer,f); snprintf((char*)buffer, 255, "custom2_down_Ply%d=%d\n",i,mainMenu_custom2_down[i]); @@ -1108,6 +1172,16 @@ int saveconfig(int general) fputs(buffer,f); snprintf((char*)buffer, 255, "custom2_R_Ply%d=%d\n",i,mainMenu_custom2_R[i]); fputs(buffer,f); +#ifdef __SWITCH__ + snprintf((char*)buffer, 255, "custom2_L2_Ply%d=%d\n",i,mainMenu_custom2_L2[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom2_R2_Ply%d=%d\n",i,mainMenu_custom2_R2[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom2_L3_Ply%d=%d\n",i,mainMenu_custom2_L3[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom2_R3_Ply%d=%d\n",i,mainMenu_custom2_R3[i]); + fputs(buffer,f); +#endif snprintf((char*)buffer, 255, "custom3_up_Ply%d=%d\n",i,mainMenu_custom3_up[i]); fputs(buffer,f); snprintf((char*)buffer, 255, "custom3_down_Ply%d=%d\n",i,mainMenu_custom3_down[i]); @@ -1128,6 +1202,16 @@ int saveconfig(int general) fputs(buffer,f); snprintf((char*)buffer, 255, "custom3_R_Ply%d=%d\n",i,mainMenu_custom3_R[i]); fputs(buffer,f); +#ifdef __SWITCH__ + snprintf((char*)buffer, 255, "custom3_L2_Ply%d=%d\n",i,mainMenu_custom3_L2[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom3_R2_Ply%d=%d\n",i,mainMenu_custom3_R2[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom3_L3_Ply%d=%d\n",i,mainMenu_custom3_L3[i]); + fputs(buffer,f); + snprintf((char*)buffer, 255, "custom3_R3_Ply%d=%d\n",i,mainMenu_custom3_R3[i]); + fputs(buffer,f); +#endif } #endif snprintf((char*)buffer, 255, "cpu=%d\n",mainMenu_CPU_model); @@ -1279,7 +1363,10 @@ int saveconfig(int general) fputs(buffer,f); snprintf((char*)buffer, 255, "useSavesFolder=%d\n",mainMenu_useSavesFolder); fputs(buffer,f); - +#ifdef __SWITCH__ + snprintf((char*)buffer, 255, "swapAB=%d\n",mainMenu_swapAB); + fputs(buffer,f); +#endif fclose(f); return 1; } @@ -1361,7 +1448,7 @@ void loadconfig(int general) #if defined(__PSP2__) || defined(__SWITCH__) fscanf(f,"shader=%d\n",&mainMenu_shader); #if defined(__SWITCH__) - if (mainMenu_shader > 1) mainMenu_shader = 1; + if (mainMenu_shader > 3) mainMenu_shader = 1; #endif fscanf(f,"leftstickmouse=%d\n",&mainMenu_leftStickMouse); fscanf(f,"touchcontrols=%d\n",&mainMenu_touchControls); @@ -1447,6 +1534,7 @@ void loadconfig(int general) fscanf(f,"custom_R=%d\n",&mainMenu_custom_R[0]); #else fscanf(f,"custom_controlSet=%d\n",&mainMenu_custom_controlSet); + int config_1_73 = -1; for (int i=0; i<4; i++) { int j; @@ -1460,7 +1548,30 @@ void loadconfig(int general) fscanf(f,"custom1_Y_Ply%d=%d\n",&j,&mainMenu_custom1_Y[i]); fscanf(f,"custom1_L_Ply%d=%d\n",&j,&mainMenu_custom1_L[i]); fscanf(f,"custom1_R_Ply%d=%d\n",&j,&mainMenu_custom1_R[i]); +#ifdef __SWITCH__ + if (config_1_73 > 0) { + fscanf(f,"custom1_L2_Ply%d=%d\n",&j,&mainMenu_custom1_L2[i]); + fscanf(f,"custom1_R2_Ply%d=%d\n",&j,&mainMenu_custom1_R2[i]); + fscanf(f,"custom1_L3_Ply%d=%d\n",&j,&mainMenu_custom1_L3[i]); + fscanf(f,"custom1_R3_Ply%d=%d\n",&j,&mainMenu_custom1_R3[i]); + fscanf(f,"custom2_up_Ply%d=%d\n",&j,&mainMenu_custom2_up[i]); + } else if (config_1_73 == 0) { + fscanf(f,"custom2_up_Ply%d=%d\n",&j,&mainMenu_custom2_up[i]); + } else if (config_1_73 < 0) { + if (fscanf(f,"custom1_L2_Ply%d=%d\n",&j,&mainMenu_custom1_L2[i])) { + fscanf(f,"custom1_R2_Ply%d=%d\n",&j,&mainMenu_custom1_R2[i]); + fscanf(f,"custom1_L3_Ply%d=%d\n",&j,&mainMenu_custom1_L3[i]); + fscanf(f,"custom1_R3_Ply%d=%d\n",&j,&mainMenu_custom1_R3[i]); + fscanf(f,"custom2_up_Ply%d=%d\n",&j,&mainMenu_custom2_up[i]); + config_1_73 = 1; + } else { + fscanf(f,"2_up_Ply%d=%d\n",&j,&mainMenu_custom2_up[i]); + config_1_73 = 0; + } + } +#else fscanf(f,"custom2_up_Ply%d=%d\n",&j,&mainMenu_custom2_up[i]); +#endif fscanf(f,"custom2_down_Ply%d=%d\n",&j,&mainMenu_custom2_down[i]); fscanf(f,"custom2_left_Ply%d=%d\n",&j,&mainMenu_custom2_left[i]); fscanf(f,"custom2_right_Ply%d=%d\n",&j,&mainMenu_custom2_right[i]); @@ -1470,6 +1581,14 @@ void loadconfig(int general) fscanf(f,"custom2_Y_Ply%d=%d\n",&j,&mainMenu_custom2_Y[i]); fscanf(f,"custom2_L_Ply%d=%d\n",&j,&mainMenu_custom2_L[i]); fscanf(f,"custom2_R_Ply%d=%d\n",&j,&mainMenu_custom2_R[i]); +#ifdef __SWITCH__ + if (config_1_73 != 0) { + fscanf(f,"custom2_L2_Ply%d=%d\n",&j,&mainMenu_custom2_L2[i]); + fscanf(f,"custom2_R2_Ply%d=%d\n",&j,&mainMenu_custom2_R2[i]); + fscanf(f,"custom2_L3_Ply%d=%d\n",&j,&mainMenu_custom2_L3[i]); + fscanf(f,"custom2_R3_Ply%d=%d\n",&j,&mainMenu_custom2_R3[i]); + } +#endif fscanf(f,"custom3_up_Ply%d=%d\n",&j,&mainMenu_custom3_up[i]); fscanf(f,"custom3_down_Ply%d=%d\n",&j,&mainMenu_custom3_down[i]); fscanf(f,"custom3_left_Ply%d=%d\n",&j,&mainMenu_custom3_left[i]); @@ -1480,6 +1599,14 @@ void loadconfig(int general) fscanf(f,"custom3_Y_Ply%d=%d\n",&j,&mainMenu_custom3_Y[i]); fscanf(f,"custom3_L_Ply%d=%d\n",&j,&mainMenu_custom3_L[i]); fscanf(f,"custom3_R_Ply%d=%d\n",&j,&mainMenu_custom3_R[i]); +#ifdef __SWITCH__ + if (config_1_73 != 0) { + fscanf(f,"custom3_L2_Ply%d=%d\n",&j,&mainMenu_custom3_L2[i]); + fscanf(f,"custom3_R2_Ply%d=%d\n",&j,&mainMenu_custom3_R2[i]); + fscanf(f,"custom3_L3_Ply%d=%d\n",&j,&mainMenu_custom3_L3[i]); + fscanf(f,"custom3_R3_Ply%d=%d\n",&j,&mainMenu_custom3_R3[i]); + } +#endif } remap_custom_controls(); // update the custom variables with the appropriate set. #endif //__PSP2__ @@ -1599,11 +1726,8 @@ void loadconfig(int general) } if (uae4all_hard_file3[0] == '*') uae4all_hard_file3[0] = '\0'; - fscanf(f,"chipmemory=%d\n",&mainMenu_chipMemory); - } - else { - fscanf(f,"hipmemory=%d\n",&mainMenu_chipMemory); } + fscanf(f,"chipmemory=%d\n",&mainMenu_chipMemory); fscanf(f,"slowmemory=%d\n",&mainMenu_slowMemory); fscanf(f,"fastmemory=%d\n",&mainMenu_fastMemory); #ifdef ANDROIDSDL @@ -1647,6 +1771,9 @@ void loadconfig(int general) strcpy(custom_kickrom, filebuffer); } fscanf(f,"useSavesFolder=%d\n",&mainMenu_useSavesFolder); +#ifdef __SWITCH__ + fscanf(f,"swapAB=%d\n",&mainMenu_swapAB); +#endif fclose(f); } // make sure the just-loaded mainMenu_displayedLines is not changed by setPresetMode diff --git a/src/gp2x/menu/menu_config.h b/src/gp2x/menu/menu_config.h index 8e60627..58ed2f4 100755 --- a/src/gp2x/menu/menu_config.h +++ b/src/gp2x/menu/menu_config.h @@ -51,6 +51,12 @@ extern int mainMenu_custom_X[4]; extern int mainMenu_custom_Y[4]; extern int mainMenu_custom_L[4]; extern int mainMenu_custom_R[4]; +#ifdef __SWITCH__ +extern int mainMenu_custom_L2[4]; +extern int mainMenu_custom_R2[4]; +extern int mainMenu_custom_L3[4]; +extern int mainMenu_custom_R3[4]; +#endif extern int mainMenu_displayedLines; extern int mainMenu_displayHires; extern char presetMode[20]; @@ -129,6 +135,12 @@ extern int mainMenu_custom1_X[4]; extern int mainMenu_custom1_Y[4]; extern int mainMenu_custom1_L[4]; extern int mainMenu_custom1_R[4]; +#ifdef __SWITCH__ +extern int mainMenu_custom1_L2[4]; +extern int mainMenu_custom1_R2[4]; +extern int mainMenu_custom1_L3[4]; +extern int mainMenu_custom1_R3[4]; +#endif extern int mainMenu_custom2_up[4]; extern int mainMenu_custom2_down[4]; extern int mainMenu_custom2_left[4]; @@ -139,6 +151,12 @@ extern int mainMenu_custom2_X[4]; extern int mainMenu_custom2_Y[4]; extern int mainMenu_custom2_L[4]; extern int mainMenu_custom2_R[4]; +#ifdef __SWITCH__ +extern int mainMenu_custom2_L2[4]; +extern int mainMenu_custom2_R2[4]; +extern int mainMenu_custom2_L3[4]; +extern int mainMenu_custom2_R3[4]; +#endif extern int mainMenu_custom3_up[4]; extern int mainMenu_custom3_down[4]; extern int mainMenu_custom3_left[4]; @@ -149,6 +167,15 @@ extern int mainMenu_custom3_X[4]; extern int mainMenu_custom3_Y[4]; extern int mainMenu_custom3_L[4]; extern int mainMenu_custom3_R[4]; +#ifdef __SWITCH__ +extern int mainMenu_custom3_L2[4]; +extern int mainMenu_custom3_R2[4]; +extern int mainMenu_custom3_L3[4]; +extern int mainMenu_custom3_R3[4]; +#endif +#ifdef __SWITCH__ +extern int mainMenu_swapAB; +#endif #endif #endif \ No newline at end of file diff --git a/src/gp2x/menu/menu_controls.cpp b/src/gp2x/menu/menu_controls.cpp index bba6588..11c0f78 100755 --- a/src/gp2x/menu/menu_controls.cpp +++ b/src/gp2x/menu/menu_controls.cpp @@ -63,6 +63,10 @@ enum { MENUCONTROLS_B, MENUCONTROLS_L, MENUCONTROLS_R, +#ifdef __SWITCH__ + MENUCONTROLS_L2, + MENUCONTROLS_R2, +#endif MENUCONTROLS_END }; @@ -326,6 +330,12 @@ void mapback_custom_controls() // assign currently used custom set to custom con mainMenu_custom1_Y[i] = mainMenu_custom_Y[i]; mainMenu_custom1_L[i] = mainMenu_custom_L[i]; mainMenu_custom1_R[i] = mainMenu_custom_R[i]; +#ifdef __SWITCH__ + mainMenu_custom1_L2[i] = mainMenu_custom_L2[i]; + mainMenu_custom1_R2[i] = mainMenu_custom_R2[i]; + mainMenu_custom1_L3[i] = mainMenu_custom_L3[i]; + mainMenu_custom1_R3[i] = mainMenu_custom_R3[i]; +#endif break; case 1: mainMenu_custom2_up[i] = mainMenu_custom_up[i]; @@ -338,6 +348,12 @@ void mapback_custom_controls() // assign currently used custom set to custom con mainMenu_custom2_Y[i] = mainMenu_custom_Y[i]; mainMenu_custom2_L[i] = mainMenu_custom_L[i]; mainMenu_custom2_R[i] = mainMenu_custom_R[i]; +#ifdef __SWITCH__ + mainMenu_custom2_L2[i] = mainMenu_custom_L2[i]; + mainMenu_custom2_R2[i] = mainMenu_custom_R2[i]; + mainMenu_custom2_L3[i] = mainMenu_custom_L3[i]; + mainMenu_custom2_R3[i] = mainMenu_custom_R3[i]; +#endif break; case 2: mainMenu_custom3_up[i] = mainMenu_custom_up[i]; @@ -350,6 +366,12 @@ void mapback_custom_controls() // assign currently used custom set to custom con mainMenu_custom3_Y[i] = mainMenu_custom_Y[i]; mainMenu_custom3_L[i] = mainMenu_custom_L[i]; mainMenu_custom3_R[i] = mainMenu_custom_R[i]; +#ifdef __SWITCH__ + mainMenu_custom3_L2[i] = mainMenu_custom_L2[i]; + mainMenu_custom3_R2[i] = mainMenu_custom_R2[i]; + mainMenu_custom3_L3[i] = mainMenu_custom_L3[i]; + mainMenu_custom3_R3[i] = mainMenu_custom_R3[i]; +#endif break; default: break; @@ -521,7 +543,11 @@ static void draw_controlsMenu(int c) } // MENUCONTROLS_Y +#ifdef __SWITCH__ + menuLine+=2; +#else menuLine+=3; +#endif #if defined(__PSP2__) write_text(leftMargin,menuLine,"Triangle"); #elif defined(__SWITCH__) @@ -582,7 +608,11 @@ static void draw_controlsMenu(int c) // MENUCONTROLS_L +#ifdef __SWITCH__ + menuLine+=2; +#else menuLine+=3; +#endif write_text(leftMargin,menuLine," L"); getMapping(mainMenu_custom_L[ctrlNr]); if ((menuControls!=MENUCONTROLS_L)||(bb)) @@ -597,8 +627,27 @@ static void draw_controlsMenu(int c) write_text_inv(tabstop1-4,menuLine,mapping); else write_text(tabstop1-4,menuLine,mapping); - -#if defined(__PSP2__) || defined(__SWITCH__) + +#ifdef __SWITCH__ + // MENUCONTROLS_L2 + menuLine+=2; + write_text(leftMargin,menuLine," ZL"); + getMapping(mainMenu_custom_L2[ctrlNr]); + if ((menuControls!=MENUCONTROLS_L2)||(bb)) + write_text_inv(tabstop1-4,menuLine,mapping); + else + write_text(tabstop1-4,menuLine,mapping); + // MENUCONTROLS_R2 + menuLine+=2; + write_text(leftMargin,menuLine," ZR"); + getMapping(mainMenu_custom_R2[ctrlNr]); + if ((menuControls!=MENUCONTROLS_R2)||(bb)) + write_text_inv(tabstop1-4,menuLine,mapping); + else + write_text(tabstop1-4,menuLine,mapping); +#endif + +#if defined(__PSP2__) menuLine++; write_text(leftMargin,menuLine,text_str_controls_separator); menuLine++; @@ -683,8 +732,11 @@ static int key_controlsMenu(int *c) if (menuControls==MENUCONTROLS_A && mainMenu_custom_dpad>0) menuControls=MENUCONTROLS_DPAD; else #endif +#ifdef __SWITCH__ + if (menuControls==MENUCONTROLS_RETURNMAIN) menuControls=MENUCONTROLS_R2; +#else if (menuControls==MENUCONTROLS_RETURNMAIN) menuControls=MENUCONTROLS_R; - +#endif else menuControls--; } else if (down) @@ -693,7 +745,11 @@ static int key_controlsMenu(int *c) if (menuControls==MENUCONTROLS_DPAD && mainMenu_custom_dpad>0) menuControls=MENUCONTROLS_A; else #endif +#ifdef __SWITCH__ + if (menuControls==MENUCONTROLS_R2) menuControls=MENUCONTROLS_RETURNMAIN; +#else if (menuControls==MENUCONTROLS_R) menuControls=MENUCONTROLS_RETURNMAIN; +#endif else menuControls++; } switch (menuControls) @@ -1059,6 +1115,54 @@ static int key_controlsMenu(int *c) #endif } break; +#ifdef __SWITCH__ + case MENUCONTROLS_L2: + if (left) + { + if (mainMenu_custom_L2[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_L2[ctrlNr]--; + else + mainMenu_custom_L2[ctrlNr]=MAX_CUSTOM_ID; + mapback_custom_controls(); //record this change in custom control set + } + else if (right) + { + if (mainMenu_custom_L2[ctrlNr]MIN_CUSTOM_ID) + mainMenu_custom_R2[ctrlNr]--; + else + mainMenu_custom_R2[ctrlNr]=MAX_CUSTOM_ID; + mapback_custom_controls(); //record this change in custom control set + } + else if (right) + { + if (mainMenu_custom_R2[ctrlNr] 0) + { + getMapping(mainMenu_custom_L2[i]); + uae4all_keystate[customKey] = 1; + record_key(customKey << 1); + } + justPressedL2[i]=1; + } + } + else if(justPressedL2[i]) + { + if(mainMenu_custom_L2[i] == -1) buttonstate[0]=0; + else if(mainMenu_custom_L2[i] == -2) buttonstate[2]=0; + else if(mainMenu_custom_L2[i] > 0) + { + getMapping(mainMenu_custom_L2[i]); + uae4all_keystate[customKey] = 0; + record_key((customKey << 1) | 1); + } + justPressedL2[i]=0; + } + + //(R2) + if(triggerR2[i]) + { + if(!justPressedR2[i]) + { + if(mainMenu_custom_R2[i] == -1) buttonstate[0]=1; + else if(mainMenu_custom_R2[i] == -2) buttonstate[2]=1; + else if(mainMenu_custom_R2[i] > 0) + { + getMapping(mainMenu_custom_R2[i]); + uae4all_keystate[customKey] = 1; + record_key(customKey << 1); + } + justPressedR2[i]=1; + } + } + else if(justPressedR2[i]) + { + if(mainMenu_custom_R2[i] == -1) buttonstate[0]=0; + else if(mainMenu_custom_R2[i] == -2) buttonstate[2]=0; + else if(mainMenu_custom_R2[i] > 0) + { + getMapping(mainMenu_custom_R2[i]); + uae4all_keystate[customKey] = 0; + record_key((customKey << 1) | 1); + } + justPressedR2[i]=0; + } + + //(L3) + if(triggerL3[i]) + { + if(!justPressedL3[i]) + { + if(mainMenu_custom_L3[i] == -1) buttonstate[0]=1; + else if(mainMenu_custom_L3[i] == -2) buttonstate[2]=1; + else if(mainMenu_custom_L3[i] > 0) + { + getMapping(mainMenu_custom_L3[i]); + uae4all_keystate[customKey] = 1; + record_key(customKey << 1); + } + justPressedL3[i]=1; + } + } + else if(justPressedL3[i]) + { + if(mainMenu_custom_L3[i] == -1) buttonstate[0]=0; + else if(mainMenu_custom_L3[i] == -2) buttonstate[2]=0; + else if(mainMenu_custom_L3[i] > 0) + { + getMapping(mainMenu_custom_L3[i]); + uae4all_keystate[customKey] = 0; + record_key((customKey << 1) | 1); + } + justPressedL3[i]=0; + } + + //(R3) + if(triggerR3[i]) + { + if(!justPressedR3[i]) + { + if(mainMenu_custom_R3[i] == -1) buttonstate[0]=1; + else if(mainMenu_custom_R3[i] == -2) buttonstate[2]=1; + else if(mainMenu_custom_R3[i] > 0) + { + getMapping(mainMenu_custom_R3[i]); + uae4all_keystate[customKey] = 1; + record_key(customKey << 1); + } + justPressedR3[i]=1; + } + } + else if(justPressedR3[i]) + { + if(mainMenu_custom_R3[i] == -1) buttonstate[0]=0; + else if(mainMenu_custom_R3[i] == -2) buttonstate[2]=0; + else if(mainMenu_custom_R3[i] > 0) + { + getMapping(mainMenu_custom_R3[i]); + uae4all_keystate[customKey] = 0; + record_key((customKey << 1) | 1); + } + justPressedR3[i]=0; + } +#endif } }//end of nr_joysticks loop else if(!gp2xMouseEmuOn) diff --git a/src/od-joy.cpp b/src/od-joy.cpp index 0845d0d..20cd2a4 100755 --- a/src/od-joy.cpp +++ b/src/od-joy.cpp @@ -47,6 +47,12 @@ extern int buttonX[4]; extern int buttonY[4]; extern int triggerL[4]; extern int triggerR[4]; +#ifdef __SWITCH__ +extern int triggerL2[4]; +extern int triggerR2[4]; +extern int triggerL3[4]; +extern int triggerR3[4]; +#endif extern int buttonSelect[4]; extern int buttonStart[4]; #endif @@ -151,6 +157,14 @@ void read_joystick(int nr, unsigned int *dir, int *button) (mainMenu_custom_L[i]==-25 && triggerL[i]) || (mainMenu_custom_R[i]==-25 && triggerR[i]) ) || +#ifdef __SWITCH__ + ( + (mainMenu_custom_L2[i]==-25 && triggerL2[i]) || + (mainMenu_custom_R2[i]==-25 && triggerR2[i]) || + (mainMenu_custom_L3[i]==-25 && triggerL3[i]) || + (mainMenu_custom_R3[i]==-25 && triggerR3[i]) + ) || +#endif ( (mainMenu_custom_dpad == 0) && ( @@ -166,6 +180,19 @@ void read_joystick(int nr, unsigned int *dir, int *button) } } } +#ifdef __SWITCH__ + // or if custom controls are OFF but ZR is held on Switch, then also use slow-mouse + else { + for (int i=0; i