Skip to content

Commit

Permalink
Merge pull request #4 from rsn8887/master
Browse files Browse the repository at this point in the history
VITA: Analog mouse support, menu updates
  • Loading branch information
Cpasjuste committed Dec 21, 2016
2 parents 48c831e + d9873fe commit a2dac27
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 60 deletions.
31 changes: 26 additions & 5 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,29 @@ F11 - change input method
Please put kickstarts files in android/data/pandora.uae4all.sdl/kickstarts directory.
Files must be named as kick13.rom kick20.rom kick31.rom

VITA controls:

L+R+dpad up down - Change Screen vertical position
Start - toggle between gp2x style mouse mode, joystick mode and stylus mode (stylus mode not working yet). Press multiple times to change behaviour between the three modes.
Select - toggle menu
Vita Controls:

A=square
B=circle
X=cross
Y=triangle

Vita controls:

Select = toggle menu
Start+dpad = move screen
right analog stick = analog mouse (can switch this to left in menu)
left analog stick = acts as amiga joystick

Only when custom controls are off:
L/R=mousebuttons
R+Square = CTRL
R+Circle = LALT
R+Cross = HELP
L+Square = left mouse
L+Circle = right mouse
R+dpad = arrow keys

When custom mouse controls are on:
Dpad = digital mouse
Triangle = slow mouse down
30 changes: 15 additions & 15 deletions src/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ static _INLINE_ void mousehack_setdontcare (void)

write_log ("Don't care mouse mode set\n");
mousestate = dont_care_mouse;
lastspr0x = lastmx; lastspr0y = lastmy;
lastspr0x = lastmx/16; lastspr0y = lastmy/16;
mstepx = defstepx; mstepy = defstepy;
}

Expand All @@ -2114,16 +2114,16 @@ static _INLINE_ uae_u32 mousehack_helper (void)
{
/* @@@ This isn't completely right, it doesn't deal with virtual
screen sizes larger than physical very well. */
if (lastmy >= PREFS_GFX_HEIGHT)
lastmy = PREFS_GFX_HEIGHT - 1;
if (lastmy/16 >= PREFS_GFX_HEIGHT)
lastmy = 16 * (PREFS_GFX_HEIGHT - 1);
if (lastmy < 0)
lastmy = 0;
if (lastmx < 0)
lastmx = 0;
if (lastmx >= PREFS_GFX_WIDTH)
lastmx = PREFS_GFX_WIDTH - 1;
mouseypos = coord_native_to_amiga_y (lastmy) << 1;
mousexpos = coord_native_to_amiga_x (lastmx);
if (lastmx/16 >= PREFS_GFX_WIDTH)
lastmx = 16 * (PREFS_GFX_WIDTH - 1);
mouseypos = coord_native_to_amiga_y (lastmy/16) << 1;
mousexpos = coord_native_to_amiga_x (lastmx/16);
}

switch (_68k_dreg (0)) {
Expand Down Expand Up @@ -2171,8 +2171,8 @@ static _INLINE_ void do_mouse_hack (void)
switch (mousestate)
{
case normal_mouse:
diffx = lastmx - lastsampledmx;
diffy = lastmy - lastsampledmy;
diffx = lastmx/16 - lastsampledmx;
diffy = lastmy/16 - lastsampledmy;
if (!newmousecounters)
{
if (diffx > 127)
Expand All @@ -2190,10 +2190,10 @@ static _INLINE_ void do_mouse_hack (void)
break;

case dont_care_mouse:
diffx = adjust (((lastmx - lastspr0x) * mstepx) >> 16);
diffy = adjust (((lastmy - lastspr0y) * mstepy) >> 16);
lastspr0x = lastmx;
lastspr0y = lastmy;
diffx = adjust (((lastmx/16 - lastspr0x) * mstepx) >> 16);
diffy = adjust (((lastmy/16 - lastspr0y) * mstepy) >> 16);
lastspr0x = lastmx/16;
lastspr0y = lastmy/16;
mouse_x += diffx;
mouse_y += diffy;
break;
Expand All @@ -2205,8 +2205,8 @@ static _INLINE_ void do_mouse_hack (void)
if (sprvbfl && (sprvbfl-- > 1))
{
int stylusxpos, stylusypos;
stylusxpos = coord_native_to_amiga_x (lastmx);
stylusypos = coord_native_to_amiga_y (lastmy) << 1;
stylusxpos = coord_native_to_amiga_x (lastmx/16);
stylusypos = coord_native_to_amiga_y (lastmy/16) << 1;
if(stylusxpos != spr0x || stylusypos != spr0y)
{
diffx = (stylusxpos - spr0x);
Expand Down
2 changes: 1 addition & 1 deletion src/gp2x/gp2x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int flashLED;

int gp2xMouseEmuOn=0;
int gp2xButtonRemappingOn=0;
#ifndef PANDORA
#if !defined(PANDORA) && !defined(__PSP2__)
int hasGp2xButtonRemapping=1;
#endif
int GFXVIDINFO_HEIGHT=240;
Expand Down
6 changes: 6 additions & 0 deletions src/gp2x/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ void init_text(int splash)

SDL_SetVideoModeScaling(x, y, sw, sh);
printf("init_text: SDL_SetVideoModeScaling(%i, %i, %i, %i)\n", x, y, (int)sw, (int)sh);

//This requires a recent SDL-Vita branch SDL12 for example
//https://github.com/rsn8887/SDL-Vita/tree/SDL12
//to compile
SDL_SetVideoModeBilinear(0);

#elif PANDORA
setenv("SDL_OMAP_LAYER_SIZE","640x480",1);
setenv("SDL_OMAP_BORDER_CUT","0,0,0,30",1);
Expand Down
20 changes: 15 additions & 5 deletions src/gp2x/menu/menu_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ int visibleAreaWidth = 320;

int saveMenu_n_savestate = 0;

#ifdef __PSP2__
int mainMenu_leftStickMouse = 0;
#endif

// The following params in use, but can't be changed with gui
int mainMenu_autosave = DEFAULT_AUTOSAVE;
Expand All @@ -100,16 +103,16 @@ int mainMenu_button2 = GP2X_BUTTON_A;
int mainMenu_autofireButton1 = GP2X_BUTTON_B;
int mainMenu_jump = -1;

#ifdef __PSP2__
int mainMenu_shader = 5;
#endif

// The following params not in use, but stored to write them back to the config file
int gp2xClockSpeed = -1;
int mainMenu_scanlines = 0;
int mainMenu_enableScreenshots = DEFAULT_ENABLESCREENSHOTS;
int mainMenu_enableScripts = DEFAULT_ENABLESCRIPTS;

#ifdef __PSP2__
int mainMenu_shader = 0;
#endif

#ifdef ANDROIDSDL
int mainMenu_onScreen = 1;
int mainMenu_onScreen_textinput = 1;
Expand Down Expand Up @@ -187,7 +190,6 @@ void SetDefaultMenuSettings(int general)
mainMenu_CPU_speed = 0;

mainMenu_cpuSpeed = 600;

mainMenu_joyConf = 0;
mainMenu_joyPort = 0;
mainMenu_autofireRate = 8;
Expand Down Expand Up @@ -217,6 +219,11 @@ void SetDefaultMenuSettings(int general)
mainMenu_frameskip = 0;
mainMenu_autofire = DEFAULT_AUTOFIRE;

#ifdef __PSP2__
mainMenu_shader = 5;
mainMenu_leftStickMouse = 0;
#endif

// The following params can't be changed in gui
skipintro = DEFAULT_SKIPINTRO;
mainMenu_autosave = DEFAULT_AUTOSAVE;
Expand Down Expand Up @@ -801,6 +808,8 @@ int saveconfig(int general)
#ifdef __PSP2__
snprintf((char*)buffer, 255, "shader=%d\n",mainMenu_shader);
fputs(buffer,f);
snprintf((char*)buffer, 255, "leftstickmouse=%d\n",mainMenu_leftStickMouse);
fputs(buffer,f);
#endif
snprintf((char*)buffer, 255, "showstatus=%d\n",mainMenu_showStatus);
fputs(buffer,f);
Expand Down Expand Up @@ -1101,6 +1110,7 @@ void loadconfig(int general)
#endif
#ifdef __PSP2__
fscanf(f,"shader=%d\n",&mainMenu_shader);
fscanf(f,"leftstickmouse=%d\n",&mainMenu_leftStickMouse);
#endif
fscanf(f,"showstatus=%d\n",&mainMenu_showStatus);
fscanf(f,"mousemultiplier=%d\n",&mainMenu_mouseMultiplier );
Expand Down
5 changes: 5 additions & 0 deletions src/gp2x/menu/menu_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ extern int mainMenu_vsync;
#endif
extern char custom_kickrom[256];
#endif

#ifdef __PSP2__
extern int mainMenu_leftStickMouse;
extern int mainMenu_shader;
#endif
3 changes: 2 additions & 1 deletion src/gp2x/menu/menu_controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,11 @@ static int key_controlsMenu(int *c)
static int delay=0;
int left=0, right=0, up=0, down=0, hit0=0, hit1=0;
SDL_Event event;
#ifndef __PSP2__ // this can be snappy on Vita no need to worry about touch
delay ++;
if (delay<5) return end;
delay=0;

#endif
while (SDL_PollEvent(&event) > 0)
{
if (event.type == SDL_KEYDOWN)
Expand Down
73 changes: 71 additions & 2 deletions src/gp2x/menu/menu_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,27 @@ enum {
MENUDISPLAY_CUTRIGHT,
MENUDISPLAY_FRAMESKIP,
MENUDISPLAY_REFRESHRATE,
#ifdef __PSP2__
MENUDISPLAY_SHADER,
#endif
MENUDISPLAY_SOUND,
MENUDISPLAY_SNDRATE,
MENUDISPLAY_STEREO,
MENUDISPLAY_END
};


#ifdef __PSP2__
enum {
SHADER_NONE = 0,
SHADER_LCD3X,
SHADER_AAA,
SHADER_SCALE2X,
SHADER_SHARP_BILINEAR,
SHADER_SHARP_BILINEAR_SIMPLE,
SHADER_FXAA,
NUM_SHADERS, //NUM_SHADERS - 1 is the max allowed number in mainMenu_shader
};
#endif

static void draw_displayMenu(int c)
{
Expand All @@ -83,7 +97,7 @@ static void draw_displayMenu(int c)
int bb=(b%6)/3;
SDL_Rect r;
extern SDL_Surface *text_screen;
char value[20]="";
char value[25]="";
r.x=80-64; r.y=0; r.w=110+64+64; r.h=240;

text_draw_background();
Expand Down Expand Up @@ -228,6 +242,43 @@ static void draw_displayMenu(int c)
write_text_inv(tabstop3+1,menuLine,"60Hz");
else
write_text(tabstop3+1,menuLine,"60Hz");
#ifdef __PSP2__
//Shader settings on Vita
//MENUDISPLAY_SHADER
menuLine+=2;
write_text(leftMargin,menuLine,"Shader");

switch (mainMenu_shader)
{
case SHADER_NONE:
snprintf((char*)value, 25, "NONE (perfect 2x)");
break;
case SHADER_LCD3X:
snprintf((char*)value, 25, "LCD3X");
break;
case SHADER_SCALE2X:
snprintf((char*)value, 25, "SCALE2X");
break;
case SHADER_AAA:
snprintf((char*)value, 25, "AAA");
break;
case SHADER_SHARP_BILINEAR:
snprintf((char*)value, 25, "SHARP_BILINEAR");
break;
case SHADER_SHARP_BILINEAR_SIMPLE:
snprintf((char*)value, 25, "SHARP_BILINEAR_SIMPL");
break;
case SHADER_FXAA:
snprintf((char*)value, 25, "FXAA");
break;
default:
break;
}
if ((menuDisplay!=MENUDISPLAY_SHADER)||(bb))
write_text_inv(tabstop3-2,menuLine,value);
else
write_text(tabstop3-2,menuLine,value);
#endif

menuLine++;
write_text(leftMargin,menuLine,text_str_display_separator);
Expand Down Expand Up @@ -479,6 +530,24 @@ static int key_displayMenu(int *c)
if ((left)||(right))
mainMenu_ntsc = !mainMenu_ntsc;
break;
#ifdef __PSP2__ //shader choice on VITA
case MENUDISPLAY_SHADER:
if (left)
{
if (mainMenu_shader <= 0)
mainMenu_shader = 0;
else
mainMenu_shader -= 1;
}
else if (right)
{
if (mainMenu_shader >= NUM_SHADERS-1)
mainMenu_shader = NUM_SHADERS-1;
else
mainMenu_shader +=1;
}
break;
#endif

case MENUDISPLAY_SOUND:
if (left)
Expand Down
12 changes: 7 additions & 5 deletions src/gp2x/menu/menu_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,28 @@ void update_display() {
int x;
int y;

//is the sharp_bilinear_simple shader active?
if (mainMenu_shader == 5)
//is a shader active?
if (mainMenu_shader != 0)
{
sh = 544;
sw = ((float)visibleAreaWidth*((float)544/(float)mainMenu_displayedLines));
x = (960 - sw) / 2;
y = (544 - sh) / 2;

//This requires SDL-Vita branch SDL12 for example
//This requires a recent SDL-Vita branch SDL12 for example
//https://github.com/rsn8887/SDL-Vita/tree/SDL12
//to compile
SDL_SetVideoModeScalingBilinear(x, y, sw, sh);
SDL_SetVideoModeScaling(x, y, sw, sh);
SDL_SetVideoModeBilinear(1);
}
else //otherwise do regular integer 2* scaling to ensure good picture quality
else //otherwise do regular integer 2* scaling without filtering to ensure good picture quality
{
sh = (float) (2 * mainMenu_displayedLines);
sw = (float) (2 * visibleAreaWidth);
x = (960 - sw) / 2;
y = (544 - sh) / 2;
SDL_SetVideoModeScaling(x, y, sw, sh);
SDL_SetVideoModeBilinear(0);
}
printf("update_display: SDL_SetVideoModeScaling(%i, %i, %i, %i)\n", x, y, (int)sw, (int)sh);

Expand Down

0 comments on commit a2dac27

Please sign in to comment.