Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 4:3 aspect ratio and add 8:7. #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,13 @@ static bool HandleIniConfig(int section, const char *key, char *value) {
g_config.extended_aspect_ratio = (h * 16 / 10 - 256) / 2;
else if (strcmp(s, "18:9") == 0)
g_config.extended_aspect_ratio = (h * 18 / 9 - 256) / 2;
else if (strcmp(s, "4:3") == 0)
else if (strcmp(s, "8:7") == 0)
g_config.extended_aspect_ratio = 0;
else if (strcmp(s, "unchanged_sprites") == 0)
else if (strcmp(s, "4:3") == 0) {
g_config.extended_aspect_ratio = 0;
g_config.tv_aspect_ratio = true;
}
else if (strcmp(s, "unchanged_sprites") == 0)
nospr = true;
else if (strcmp(s, "no_visual_fixes") == 0)
novis = true;
Expand Down
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef struct Config {
bool enhanced_mode7;
bool new_renderer;
bool ignore_aspect_ratio;
bool tv_aspect_ratio;
uint8 fullscreen;
uint8 window_scale;
bool enable_audio;
Expand Down
8 changes: 6 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,12 @@ static bool SdlRenderer_Init(SDL_Window *window) {
printf("\n");
}
g_renderer = renderer;
if (!g_config.ignore_aspect_ratio)
SDL_RenderSetLogicalSize(renderer, g_snes_width, g_snes_height);
if (!g_config.ignore_aspect_ratio) {
if(!g_config.tv_aspect_ratio)
SDL_RenderSetLogicalSize(renderer, g_snes_width, g_snes_height);
else
SDL_RenderSetLogicalSize(renderer, 4, 3);
}
if (g_config.linear_filtering)
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best");

Expand Down
10 changes: 8 additions & 2 deletions opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,15 @@ static void OpenGLRenderer_EndDraw() {

if (!g_config.ignore_aspect_ratio) {
if (viewport_width * g_draw_height < viewport_height * g_draw_width)
viewport_height = viewport_width * g_draw_height / g_draw_width; // limit height
if (!g_config.tv_aspect_ratio)
viewport_height = viewport_width * g_draw_height / g_draw_width; // limit height
else
viewport_height = viewport_width * 3 / 4; // limit height
else
viewport_width = viewport_height * g_draw_width / g_draw_height; // limit width
if (!g_config.tv_aspect_ratio)
viewport_width = viewport_height * g_draw_width / g_draw_height; // limit width
else
viewport_width = viewport_height * 4 / 3; // limit width
}

int viewport_x = (drawable_width - viewport_width) >> 1;
Expand Down
4 changes: 3 additions & 1 deletion zelda3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Autosave = 0
DisplayPerfInTitle = 0

# Extended aspect ratio, either 16:9, 16:10, or 18:9. 4:3 means normal aspect ratio.
# Extended aspect ratio, either 16:9, 16:10, or 18:9. 4:3 means the aspect ratio that
# the game would display on a real CRT TV, and 8:7 is the aspect ratio the game was
# internally rendered at, before being ouput to TV, since SNES is 256x224 internally.
# Add ", unchanged_sprites" to avoid changing sprite spawn/die behavior. Without this
# replays will be incompatible.
# Add ", no_visual_fixes" to avoid fixing some graphics glitches (for example with Cape).
Expand Down