Skip to content

Commit

Permalink
switch: fix/improve scaling and ascept ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
Cpasjuste committed Mar 27, 2018
1 parent 3534f00 commit c9ff4bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 46 deletions.
4 changes: 4 additions & 0 deletions scaler.cpp
Expand Up @@ -125,7 +125,11 @@ static void scaleNx(int factor, uint32_t *dst, int dstPitch, const uint32_t *src
const Scaler _internalScaler = {
SCALER_TAG,
"scaleNx",
#ifdef __SWITCH__
1, 3,
#else
2, 4,
#endif
scaleNx,
};

Expand Down
45 changes: 3 additions & 42 deletions switch/main_switch.cpp
Expand Up @@ -128,44 +128,6 @@ static void initOptions() {
}
}

static void parseScaler(char *name, ScalerParameters *scalerParameters) {
struct {
const char *name;
int type;
} scalers[] = {
{ "point", kScalerTypePoint },
{ "linear", kScalerTypeLinear },
{ "scale", kScalerTypeInternal },
{ 0, -1 }
};
bool found = false;
char *sep = strchr(name, '@');
if (sep) {
*sep = 0;
}
for (int i = 0; scalers[i].name; ++i) {
if (strcmp(scalers[i].name, name) == 0) {
scalerParameters->type = (ScalerType)scalers[i].type;
found = true;
break;
}
}
if (!found) {
char libname[32];
snprintf(libname, sizeof(libname), "scaler_%s", name);
const Scaler *scaler = findScaler(libname);
if (scaler) {
scalerParameters->type = kScalerTypeExternal;
scalerParameters->scaler = scaler;
} else {
warning("Scaler '%s' not found, using default", libname);
}
}
if (sep) {
scalerParameters->factor = atoi(sep + 1);
}
}

int main(int argc, char *argv[]) {

consoleDebugInit(debugDevice_SVC);
Expand All @@ -177,9 +139,8 @@ int main(int argc, char *argv[]) {

bool fullscreen = true;
ScalerParameters scalerParameters = ScalerParameters::defaults();
scalerParameters.factor = 1;
scalerParameters.type = kScalerTypeExternal;
scalerParameters.scaler = NULL;
scalerParameters.factor = 2;
scalerParameters.type = kScalerTypePoint;

int forcedLanguage = -1;
int demoNum = -1;
Expand Down Expand Up @@ -220,7 +181,7 @@ int main(int argc, char *argv[]) {
fullscreen = true;
break;
case 5:
parseScaler(optarg, &scalerParameters);
//parseScaler(optarg, &scalerParameters);
break;
case 6: {
static const struct {
Expand Down
22 changes: 18 additions & 4 deletions systemstub_sdl.cpp
Expand Up @@ -15,11 +15,12 @@
#define JOY_KEY_DOWN 15
#define JOY_KEY_LEFT 12
#define JOY_KEY_RIGHT 14
#define JOY_KEY_SPACE 0 // A
#define JOY_KEY_SHIFT 1 // B
#define JOY_KEY_ENTER 2 // X
#define JOY_KEY_ENTER 0 // A
#define JOY_KEY_SPACE 1 // B
#define JOY_KEY_SHIFT 2 // X
#define JOY_KEY_BACK 3 // Y
#define JOY_KEY_ESC 10 // PLUS
#define JOY_KEY_SCALE 11 // MINUS

static const int kAudioHz = 48000;
#else
Expand Down Expand Up @@ -396,6 +397,15 @@ void SystemStub_SDL::processEvent(const SDL_Event &ev, bool &paused) {
case JOY_KEY_ESC:
_pi.escape = pressed;
break;
/*
case JOY_KEY_SCALE:
_scaleFactor++;
if(_scaleFactor > _scaler->factorMax) {
_scaleFactor = _scaler->factorMin;
}
changeGraphics(_fullscreen, _scaleFactor);
break;
*/
}
}
break;
Expand Down Expand Up @@ -685,7 +695,11 @@ void SystemStub_SDL::prepareGraphics() {
const int windowH = _screenH * _scaleFactor;
int flags = 0;
if (_fullscreen) {
#ifdef __SWITCH__
flags |= SDL_WINDOW_FULLSCREEN;
#else
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
#endif
}
_window = SDL_CreateWindow(_caption, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowW, windowH, flags);
SDL_Surface *icon = SDL_LoadBMP(kIconBmp);
Expand All @@ -697,8 +711,8 @@ void SystemStub_SDL::prepareGraphics() {
_renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_SOFTWARE);
#else
_renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_ACCELERATED);
#endif
SDL_RenderSetLogicalSize(_renderer, windowW, windowH);
#endif
_texture = SDL_CreateTexture(_renderer, kPixelFormat, SDL_TEXTUREACCESS_STREAMING, _texW, _texH);
_fmt = SDL_AllocFormat(kPixelFormat);
forceGraphicsRedraw();
Expand Down

0 comments on commit c9ff4bd

Please sign in to comment.