Skip to content

Commit

Permalink
Analog stick cursor movement, boxing added back
Browse files Browse the repository at this point in the history
  • Loading branch information
Northfear committed Apr 15, 2021
1 parent 42e5a43 commit 808437c
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 38 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ endif()

if(VITA)
add_definitions(-DVITA)
set(VITA_FLAGS "-O2 -mcpu=cortex-a9 -mfpu=neon -ffast-math -ftree-vectorize -fno-lto -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
set(VITA_FLAGS "-O2 -mcpu=cortex-a9 -mfpu=neon -fno-lto -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VITA_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VITA_FLAGS}")
list(APPEND VANILLA_LIBS "-lSceMotion_stub -lSceTouch_stub -lSceAudio_stub -lSceAudioIn_stub -lSceCtrl_stub -lSceGxm_stub \
Expand Down
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ https://github.com/Cpasjuste/psp2shell

### Controls

Game is optimized for touch controls.

- Left/Right analog stick - Map scrolling
- Left analog stick - Cursor movement / Map scrolling (switch between both modes with a 3-fingress press on the rear touchpad)
- Right analog stick - Map scrolling
- CROSS - Left mouse button
- CIRCLE - Right mouse button (Cancel building, deselect unit..)
- CROSS - G (Guard Area)
- SQUARE - F (Formation. RA only I guess)
- TRIANGLE - X (Scatter Units)
- SQUARE - G (Guard Area)
- TRIANGLE - F (Formation. RA only)
- D-Pad Up/Right/Down/Left - 1/2/3/4 button
- R1 - Alt (force move)
- L1 - Ctrl (force attack)
Expand All @@ -52,10 +51,19 @@ Game is optimized for touch controls.

Use R1 + D-Pad to create teams (1-4) and D-Pad to select them (same as Ctrl + 1-4 on keyboard). You can use DPad numbers while entering savegame names.

Left analog stick can be used for both cursor movement (good for builing or preciece movement) or map scrolling (useful during combat when you're giving command with a touchpad). Cursor movement mode is default. To switch between both modes use 3-finger touch on the rear touchpad.

You can change cursor movement speed by editing ```ControllerPointerSpeed``` option under ```[Vita]``` section inside ```conquer.ini```/```redalert.ini``` files.

### Other

Game supports nearest and linear filtering. Nearest is used by default and it produces sharp, but pixelated image (that's especially noticeable on text). Linear is smooth, but somewhat blurred. To select linear filtering edit
```ux0:data/VanillaTD/vanillatd/conquer.ini``` or ```ux0:data/VanillaRA/vanillara/redalert.ini``` and change ```Scaler``` option to ```linear```
Config files for VanillaTD and VanillaRA are located at ```ux0:data/VanillaTD/vanillatd/conquer.ini``` and ```ux0:data/VanillaRA/vanillara/redalert.ini```.

To preserve original aspect ratio set ```Boxing=yes``` option.

If you want to display the game at native resolution without any scaling set ```ScaleGameSurface=no``` (```[Vita]``` section).

Game supports nearest and linear filtering. Nearest is used by default and it produces sharp, but pixelated image (that's especially noticeable on text). Linear is smooth, but somewhat blurred. To select linear filtering set ```Scaler``` option to ```linear```

```
[Video]
Expand Down
20 changes: 15 additions & 5 deletions common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ SettingsClass::SettingsClass()
Video.Scaler = "nearest";
Video.Driver = "default";
Video.PixelFormat = "default";

#ifdef VITA
Vita.ScaleGameSurface = true;
Vita.ControllerPointerSpeed = 10;
#endif
}

void SettingsClass::Load(INIClass& ini)
Expand All @@ -52,11 +57,6 @@ void SettingsClass::Load(INIClass& ini)
Video.Driver = ini.Get_String("Video", "Driver", Video.Driver);
Video.PixelFormat = ini.Get_String("Video", "PixelFormat", Video.PixelFormat);

#ifdef VITA
//touch to mouse translates badly with boxing on
Video.Boxing = false;
#endif

/*
** VQA and WSA interpolation mode 0 = scanlines, 1 = vertical doubling, 2 = linear
*/
Expand All @@ -68,6 +68,11 @@ void SettingsClass::Load(INIClass& ini)
if (Video.Boxing || Mouse.RawInput) {
Video.HardwareCursor = false;
}

#ifdef VITA
Vita.ScaleGameSurface = ini.Get_Bool("Vita", "ScaleGameSurface", Vita.ScaleGameSurface);
Vita.ControllerPointerSpeed = ini.Get_Int("Vita", "ControllerPointerSpeed", Vita.ControllerPointerSpeed);
#endif
}

void SettingsClass::Save(INIClass& ini)
Expand Down Expand Up @@ -97,4 +102,9 @@ void SettingsClass::Save(INIClass& ini)
** VQA and WSA interpolation mode 0 = scanlines, 1 = vertical doubling, 2 = linear
*/
ini.Put_Int("Video", "InterpolationMode", Video.InterpolationMode);

#ifdef VITA
ini.Put_Bool("Vita", "ScaleGameSurface", Vita.ScaleGameSurface);
ini.Put_Int("Vita", "ControllerPointerSpeed", Vita.ControllerPointerSpeed);
#endif
}
8 changes: 8 additions & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class SettingsClass
std::string Driver;
std::string PixelFormat;
} Video;

#ifdef VITA
struct
{
bool ScaleGameSurface;
int ControllerPointerSpeed;
} Vita;
#endif
};

extern SettingsClass Settings;
Expand Down
11 changes: 11 additions & 0 deletions common/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ void Reset_Video_Mode();
unsigned Get_Free_Video_Memory();
void Wait_Blit();

#ifdef VITA
#include <SDL.h>

const int32_t VITA_FULLSCREEN_WIDTH = 960;
const int32_t VITA_FULLSCREEN_HEIGHT = 544;

SDL_Rect Get_Render_Rect();
void Get_Game_Resolution(int& w, int& h);
void Set_Video_Mouse(int x, int y);
#endif

/*
** Set desired cursor image in game palette.
*/
Expand Down
57 changes: 57 additions & 0 deletions common/video_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,38 @@ static void Update_HWCursor_Settings()
/*
** Update screen boxing settings.
*/
#ifdef VITA
if (hwcursor.GameW != VITA_FULLSCREEN_WIDTH || hwcursor.GameH != VITA_FULLSCREEN_HEIGHT) {
render_dst.x = 0;
render_dst.y = 0;
render_dst.w = hwcursor.GameW;
render_dst.h = hwcursor.GameH;

if (Settings.Vita.ScaleGameSurface) {
//resize to fullscreen
if (Settings.Video.Boxing) {
if ((static_cast<float>(VITA_FULLSCREEN_WIDTH) / VITA_FULLSCREEN_HEIGHT) >= (static_cast<float>(hwcursor.GameW) / hwcursor.GameH)) {
float scale = static_cast<float>(VITA_FULLSCREEN_HEIGHT) / hwcursor.GameH;
render_dst.w = hwcursor.GameW * scale;
render_dst.h = VITA_FULLSCREEN_HEIGHT;
render_dst.x = (VITA_FULLSCREEN_WIDTH - render_dst.w) / 2;
} else {
float scale = static_cast<float>(VITA_FULLSCREEN_WIDTH) / hwcursor.GameW;
render_dst.w = VITA_FULLSCREEN_WIDTH;
render_dst.h = hwcursor.GameH * scale;
render_dst.y = (VITA_FULLSCREEN_HEIGHT - render_dst.h) / 2;
}
} else {
render_dst.w = VITA_FULLSCREEN_WIDTH;
render_dst.h = VITA_FULLSCREEN_HEIGHT;
}
} else {
//center game area
render_dst.x = (VITA_FULLSCREEN_WIDTH - hwcursor.GameW) / 2;
render_dst.y = (VITA_FULLSCREEN_HEIGHT - hwcursor.GameH) / 2;
}
}
#else
float ar = (float)hwcursor.GameW / hwcursor.GameH;
if (Settings.Video.Boxing) {
render_dst.w = win_w;
Expand All @@ -147,6 +179,7 @@ static void Update_HWCursor_Settings()
render_dst.x = 0;
render_dst.y = 0;
}
#endif

/*
** Ensure cursor clip is in the desired state.
Expand Down Expand Up @@ -428,6 +461,10 @@ void Move_Video_Mouse(int xrel, int yrel)

void Get_Video_Mouse(int& x, int& y)
{
#ifdef VITA
x = hwcursor.X;
y = hwcursor.Y;
#else
if (Settings.Mouse.RawInput && (hwcursor.Clip || !Settings.Video.Windowed)) {
x = hwcursor.X;
y = hwcursor.Y;
Expand All @@ -438,8 +475,28 @@ void Get_Video_Mouse(int& x, int& y)
x /= scale_x;
y /= scale_y;
}
#endif
}

#ifdef VITA
SDL_Rect Get_Render_Rect()
{
return render_dst;
}

void Get_Game_Resolution(int& w, int& h)
{
w = hwcursor.GameW;
h = hwcursor.GameH;
}

void Set_Video_Mouse(int x, int y)
{
hwcursor.X = x;
hwcursor.Y = y;
}
#endif

/***********************************************************************************************
* Reset_Video_Mode -- Resets video mode and deletes Direct Draw Object *
* *
Expand Down
Loading

0 comments on commit 808437c

Please sign in to comment.