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

added integer display option, very useful for gpi/pi-zero. #8

Open
wants to merge 2 commits 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
1 change: 1 addition & 0 deletions snes9x.cfg.template
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ DisplaySmoothStretch=1
DisplayEffect=0
MaintainAspectRatio=1
DisplayBorder=0
DisplayInteger=0
AutoFrameskip=1
Frameskip=200
Transparency=1
Expand Down
1 change: 1 addition & 0 deletions snes9x.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ struct SSettings{
bool8_32 MaintainAspectRatio;
uint32 DisplayBorder;
uint32 DisplayEffect;
uint32 DisplayInteger;

// Fixes for individual games
uint32 StrikeGunnerOffsetHack;
Expand Down
37 changes: 26 additions & 11 deletions unix/gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,34 @@ void gles2_create(int display_width, int display_height, int bitmap_width, int b
dis_width = display_width;
dis_height = display_height;

// Screen aspect ratio adjustment
if(Settings.MaintainAspectRatio)
if(Settings.DisplayInteger)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original indentation is somewhat wonky but can you align this as the original and we can reformat later if needed. Thanks.

Copy link
Author

@DSkywalk DSkywalk Sep 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my english is terrible, you preffer printf in just one line?
I usually try to adapt my code to 80cols, but no problem.

I fixed some missing tabs in my code, thanks @joolswills

float a = (float)display_width/(float)display_height;
float a0 = (float)bitmap_width/(float)bitmap_height;
if(a > a0)
sx = a0/a;
else
sy = a/a0;
// screen integer - x1
sx = (float)bitmap_width/(float)display_width;
sy = (float)bitmap_height/(float)display_height;

SetOrtho(proj, -0.5f, +0.5f, +0.5f, -0.5f, -1.0f, 1.0f, sx, sy);

printf("integer enabled - %ux%u : %ux%u (x:%f y:%f)\n",
display_width, display_height, bitmap_width, bitmap_height, sx, sy);
}
else
{
// Screen aspect ratio adjustment
if(Settings.MaintainAspectRatio)
{
float a = (float)display_width/(float)display_height;
float a0 = (float)bitmap_width/(float)bitmap_height;
if(a > a0)
sx = a0/a;
else
sy = a/a0;
}

//Set the dimensions for displaying the texture(bitmap) on the screen
SetOrtho(proj, -0.5f, +0.5f, +0.5f, -0.5f, -1.0f, 1.0f, sx*op_zoom, sy*op_zoom);
}

//Set the dimensions for displaying the texture(bitmap) on the screen
SetOrtho(proj, -0.5f, +0.5f, +0.5f, -0.5f, -1.0f, 1.0f, sx*op_zoom, sy*op_zoom);
}

void gles2_destroy()
Expand Down Expand Up @@ -369,7 +384,7 @@ static void gles2_DrawQuad(const ShaderInfo *sh, GLuint textures[2])

inline unsigned short BGR565(unsigned char r, unsigned char g, unsigned char b) { return ((r&~7) << 8)|((g&~3) << 3)|(b >> 3); }

void gles2_draw(short *screen, int width, int height)
void gles2_draw(unsigned short *screen, int width, int height)
{
if(!shader.program) return;

Expand Down
1 change: 0 additions & 1 deletion unix/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ extern uint32 xs, ys, cl, cs;

void gles2_create(int display_width, int display_height, int bitmap_width, int bitmap_height);
void gles2_destroy();
void gles2_draw(short *screen);
void gles2_palette_changed();

EGLDisplay display = NULL;
Expand Down
3 changes: 2 additions & 1 deletion unix/unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static uint32 ffc = 0;
bool8_32 nso = FALSE, vga = FALSE;
uint32 xs = 256, ys = 240, cl = 0, cs = 0, mfs = 10;

void gles2_draw(short *screen, int width, int height);
void gles2_draw(unsigned short *screen, int width, int height);

extern EGLDisplay display;
extern EGLSurface surface;
Expand Down Expand Up @@ -1211,6 +1211,7 @@ void S9xParseConfigFile (void)
Settings.DisplayBorder = get_integer_conf("Graphics", "DisplayBorder", 0);

Settings.DisplayEffect = get_integer_conf("Graphics", "DisplayEffect", 0);
Settings.DisplayInteger = get_integer_conf("Graphics", "DisplayInteger", 0);

Settings.SkipFrames = get_integer_conf("Graphics", "AutoFrameskip", 1);
if (Settings.SkipFrames)
Expand Down