Change "Zoom" to "Scale" #81

This commit is contained in:
Snesrev
2022-09-12 19:30:37 +02:00
parent 49cc686ed4
commit 5efb2cacb8
4 changed files with 32 additions and 32 deletions

View File

@@ -33,7 +33,7 @@ static const uint16 kDefaultKbdControls[kKeys_Total] = {
_(SDLK_1), _(SDLK_2), _(SDLK_3), _(SDLK_4), _(SDLK_5), _(SDLK_6), _(SDLK_7), _(SDLK_8), _(SDLK_9), _(SDLK_0), _(SDLK_MINUS), _(SDLK_EQUALS), _(SDLK_BACKSPACE), N, N, N, N, N, N, N,
// Replay Ref State
C(SDLK_1), C(SDLK_2), C(SDLK_3), C(SDLK_4), C(SDLK_5), C(SDLK_6), C(SDLK_7), C(SDLK_8), C(SDLK_9), C(SDLK_0), C(SDLK_MINUS), C(SDLK_EQUALS), C(SDLK_BACKSPACE), N, N, N, N, N, N, N,
// CheatLife, CheatKeys, CheatEquipment, ClearKeyLog, StopReplay, Fullscreen, Reset, Pause, PauseDimmed, Turbo, ZoomIn, ZoomOut, DisplayPerf, ToggleRenderer
// CheatLife, CheatKeys, CheatEquipment, ClearKeyLog, StopReplay, Fullscreen, Reset, Pause, PauseDimmed, Turbo, WindowBigger, WindowSmaller, DisplayPerf, ToggleRenderer
_(SDLK_w), _(SDLK_o), S(SDLK_w), _(SDLK_k), _(SDLK_l), A(SDLK_RETURN), _(SDLK_e), S(SDLK_p), _(SDLK_p), _(SDLK_t), N, N, _(SDLK_f), _(SDLK_r),
};
#undef _
@@ -52,7 +52,7 @@ typedef struct KeyNameId {
static const KeyNameId kKeyNameId[] = {
M(Controls), M(Load), M(Save), M(Replay), M(LoadRef), M(ReplayRef),
S(CheatLife), S(CheatKeys), S(CheatEquipment), S(ClearKeyLog), S(StopReplay), S(Fullscreen), S(Reset),
S(Pause), S(PauseDimmed), S(Turbo), S(ZoomIn), S(ZoomOut), S(DisplayPerf), S(ToggleRenderer),
S(Pause), S(PauseDimmed), S(Turbo), S(WindowBigger), S(WindowSmaller), S(DisplayPerf), S(ToggleRenderer),
};
#undef S
#undef M
@@ -219,8 +219,8 @@ static bool HandleIniConfig(int section, const char *key, char *value) {
} else if (StringEqualsNoCase(key, "Fullscreen")) {
g_config.fullscreen = (uint8)strtol(value, (char**)NULL, 10);
return true;
} else if (StringEqualsNoCase(key, "Zoom")) {
g_config.zoom = (uint8)strtol(value, (char**)NULL, 10);
} else if (StringEqualsNoCase(key, "WindowScale")) {
g_config.window_scale = (uint8)strtol(value, (char**)NULL, 10);
return true;
}
} else if (section == 2) {

View File

@@ -25,8 +25,8 @@ enum {
kKeys_Pause,
kKeys_PauseDimmed,
kKeys_Turbo,
kKeys_ZoomIn,
kKeys_ZoomOut,
kKeys_WindowBigger,
kKeys_WindowSmaller,
kKeys_DisplayPerf,
kKeys_ToggleRenderer,
kKeys_Total,
@@ -37,7 +37,7 @@ typedef struct Config {
bool new_renderer;
bool ignore_aspect_ratio;
uint8 fullscreen;
uint8 zoom;
uint8 window_scale;
uint16 audio_freq;
uint8 audio_channels;
uint16 audio_samples;

42
main.c
View File

@@ -46,8 +46,8 @@ enum {
kRenderWidth = 256 * 2,
kRenderHeight = 224 * 2,
kDefaultFullscreen = 0,
kDefaultZoom = 2,
kMaxZoom = 10,
kDefaultWindowScale = 2,
kMaxWindowScale = 10,
kDefaultFreq = 44100,
kDefaultChannels = 2,
kDefaultSamples = 2048,
@@ -59,7 +59,7 @@ static uint32 g_win_flags = SDL_WINDOW_RESIZABLE;
static SDL_Window *g_window;
static SDL_Renderer *g_renderer;
static uint8 g_paused, g_turbo = true, g_cursor = true;
static uint8 g_current_zoom;
static uint8 g_current_window_scale;
static int g_samples_per_block;
static uint8 g_gamepad_buttons;
static int g_input1_state;
@@ -84,10 +84,10 @@ void SetButtonState(int button, bool pressed) {
}
void DoZoom(int zoom_step) {
void ChangeWindowScale(int scale_step) {
int screen = SDL_GetWindowDisplayIndex(g_window);
if (screen < 0) screen = 0;
int max_zoom = kMaxZoom;
int max_scale = kMaxWindowScale;
SDL_Rect bounds;
int bt = -1, bl, bb, br;
// note this takes into effect Windows display scaling, i.e., resolution is divided by scale factor
@@ -98,15 +98,15 @@ void DoZoom(int zoom_step) {
bl = br = bb = 1;
bt = 31;
}
// Allow a zoom level slightly above the max that fits on screen
int mw = (bounds.w - bl - br + (kRenderWidth / kDefaultZoom) / 4) / (kRenderWidth / kDefaultZoom);
int mh = (bounds.h - bt - bb + (kRenderHeight / kDefaultZoom) / 4) / (kRenderHeight / kDefaultZoom);
max_zoom = IntMin(mw, mh);
// Allow a scale level slightly above the max that fits on screen
int mw = (bounds.w - bl - br + (kRenderWidth / kDefaultWindowScale) / 4) / (kRenderWidth / kDefaultWindowScale);
int mh = (bounds.h - bt - bb + (kRenderHeight / kDefaultWindowScale) / 4) / (kRenderHeight / kDefaultWindowScale);
max_scale = IntMin(mw, mh);
}
int new_zoom = IntMax(IntMin(g_current_zoom + zoom_step, max_zoom), 1);
g_current_zoom = new_zoom;
int w = new_zoom * (kRenderWidth / kDefaultZoom);
int h = new_zoom * (kRenderHeight / kDefaultZoom);
int new_scale = IntMax(IntMin(g_current_window_scale + scale_step, max_scale), 1);
g_current_window_scale = new_scale;
int w = new_scale * (kRenderWidth / kDefaultWindowScale);
int h = new_scale * (kRenderHeight / kDefaultWindowScale);
//SDL_RenderSetLogicalSize(g_renderer, w, h);
SDL_SetWindowSize(g_window, w, h);
@@ -186,14 +186,14 @@ int main(int argc, char** argv) {
else if (g_config.fullscreen == 2)
g_win_flags ^= SDL_WINDOW_FULLSCREEN;
// Window zoom (0=50%, 1=100%, 2=200%, 3=300%, etc.)
g_current_zoom = g_config.zoom == 0 ? 1 : IntMin(g_config.zoom * 2, kMaxZoom);
// Window scale (0=50%, 1=100%, 2=200%, 3=300%, etc.)
g_current_window_scale = g_config.window_scale == 0 ? 1 : IntMin(g_config.window_scale * 2, kMaxWindowScale);
// audio_freq: Use common sampling rates (see user config file. values higher than 48000 are not supported.)
if (g_config.audio_freq < 11025 || g_config.audio_freq > 48000)
g_config.audio_freq = kDefaultFreq;
// Currently, the SPC/DSP implementation only supports up to stereo.
// Currently, the SPC/DSP implementation <EFBFBD>only supports up to stereo.
if (g_config.audio_channels < 1 || g_config.audio_channels > 2)
g_config.audio_channels = kDefaultChannels;
@@ -207,8 +207,8 @@ int main(int argc, char** argv) {
return 1;
}
int window_width = g_current_zoom * (kRenderWidth / kDefaultZoom);
int window_height = g_current_zoom * (kRenderHeight / kDefaultZoom);
int window_width = g_current_window_scale * (kRenderWidth / kDefaultWindowScale);
int window_height = g_current_window_scale * (kRenderHeight / kDefaultWindowScale);
SDL_Window* window = SDL_CreateWindow(kWindowTitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width, window_height, g_win_flags);
if(window == NULL) {
printf("Failed to create window: %s\n", SDL_GetError());
@@ -306,7 +306,7 @@ int main(int argc, char** argv) {
break;
case SDL_MOUSEWHEEL:
if (((g_win_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0 || (g_win_flags & SDL_WINDOW_FULLSCREEN) == 0) && event.wheel.y != 0 && SDL_GetModState() & KMOD_CTRL)
DoZoom(event.wheel.y > 0 ? 1 : -1);
ChangeWindowScale(event.wheel.y > 0 ? 1 : -1);
break;
case SDL_MOUSEBUTTONDOWN:
if (event.button.button == SDL_BUTTON_LEFT && event.button.state == SDL_PRESSED && event.button.clicks == 2) {
@@ -549,8 +549,8 @@ static void HandleCommand(uint32 j, bool pressed) {
}
break;
case kKeys_Turbo: g_turbo = !g_turbo; break;
case kKeys_ZoomIn: DoZoom(1); break;
case kKeys_ZoomOut: DoZoom(-1); break;
case kKeys_WindowBigger: ChangeWindowScale(1); break;
case kKeys_WindowSmaller: ChangeWindowScale(-1); break;
case kKeys_DisplayPerf: g_display_perf ^= 1; break;
case kKeys_ToggleRenderer: g_ppu_render_flags ^= kPpuRenderFlags_NewRenderer; break;
default: assert(0);

View File

@@ -7,8 +7,8 @@ DisplayPerfInTitle = 0
[Graphics]
# Fullscreen mode (0=windowed, 1=desktop fullscreen, 2=fullscreen w/mode change)
Fullscreen = 0
# Window zoom (0=50%, 1=100%, 2=200%, 3=300%, etc.)
Zoom = 2
# Window scale (0=50%, 1=100%, 2=200%, 3=300%, etc.)
WindowScale = 2
NewRenderer = 1
EnhancedMode7 = 1
IgnoreAspectRatio = 0
@@ -45,8 +45,8 @@ Reset = Ctrl+e
Pause = Shift+p
PauseDimmed = p
Turbo = t
ZoomIn = Ctrl+Up
ZoomOut = Ctrl+Down
WindowBigger = Ctrl+Up
WindowSmaller = Ctrl+Down
Load = F1, F2, F3, F4, F5, F6, F7, F8, F9, F10
Save = Shift+F1,Shift+F2,Shift+F3,Shift+F4,Shift+F5,Shift+F6,Shift+F7,Shift+F8,Shift+F9,Shift+F10