Merge branch 'play'

This commit is contained in:
Themaister 2010-11-19 21:27:31 +01:00
commit fc1c8cb15c
6 changed files with 116 additions and 22 deletions

View File

@ -4,7 +4,9 @@ TARGET = ssnes
DEFINES =
OBJ = ssnes.o
LIBS = -lsamplerate -lsnes
libsnes = -lsnes
LIBS = -lsamplerate $(libsnes)
ifeq ($(BUILD_RSOUND), 1)
OBJ += rsound.o
@ -49,12 +51,10 @@ CFLAGS = -Wall -O3 -march=native -std=gnu99 -Wno-unused-variable -I. $(DEFINES)
all: $(TARGET)
ssnes: $(OBJ)
@$(CXX) -o $@ $(OBJ) $(LIBS) $(CFLAGS)
@echo "LD $@"
$(CXX) -o $@ $(OBJ) $(LIBS) $(CFLAGS)
%.o: %.c config.h config.mk
@$(CC) $(CFLAGS) -c -o $@ $<
@echo "CC $<"
$(CC) $(CFLAGS) -c -o $@ $<
install: $(TARGET)
install -m755 $(TARGET) $(PREFIX)/bin

View File

@ -49,8 +49,8 @@
////////////////
// Windowed
static const float xscale = 4.0; // Real x res = 296 * xscale
static const float yscale = 4.0; // Real y res = 224 * yscale
static const float xscale = 3.0; // Real x res = 296 * xscale
static const float yscale = 3.0; // Real y res = 224 * yscale
// Fullscreen
static bool fullscreen = false; // To start in Fullscreen or not
@ -66,7 +66,7 @@ static const bool video_smooth = true;
// Path to custom Cg shader. If using custom shaders, it is recommended to disable video_smooth.
#ifdef HAVE_CG
extern char cg_shader_path[];
#define DEFAULT_CG_SHADER "hqflt/cg/hq2x.cg"
#define DEFAULT_CG_SHADER "hqflt/cg/2xSaI.cg"
#endif
// On resize and fullscreen, rendering area will stay 4:3
@ -129,12 +129,12 @@ static const struct snes_keybind snes_keybinds_1[] = {
{ SNES_DEVICE_ID_JOYPAD_Y, 'A', 2 },
{ SNES_DEVICE_ID_JOYPAD_L, 'Q', 4 },
{ SNES_DEVICE_ID_JOYPAD_R, 'W', 5 },
{ SNES_DEVICE_ID_JOYPAD_LEFT, GLFW_KEY_LEFT, 12 },
{ SNES_DEVICE_ID_JOYPAD_RIGHT, GLFW_KEY_RIGHT, 13 },
{ SNES_DEVICE_ID_JOYPAD_UP, GLFW_KEY_UP, 10 },
{ SNES_DEVICE_ID_JOYPAD_DOWN, GLFW_KEY_DOWN, 11 },
{ SNES_DEVICE_ID_JOYPAD_LEFT, GLFW_KEY_LEFT, 11 },
{ SNES_DEVICE_ID_JOYPAD_RIGHT, GLFW_KEY_RIGHT, 12 },
{ SNES_DEVICE_ID_JOYPAD_UP, GLFW_KEY_UP, 13 },
{ SNES_DEVICE_ID_JOYPAD_DOWN, GLFW_KEY_DOWN, 14 },
{ SNES_DEVICE_ID_JOYPAD_START, GLFW_KEY_ENTER, 6 },
{ SNES_DEVICE_ID_JOYPAD_SELECT, GLFW_KEY_RSHIFT, 14 },
{ SNES_DEVICE_ID_JOYPAD_SELECT, GLFW_KEY_RSHIFT, 7 },
{ SNES_FAST_FORWARD_KEY, GLFW_KEY_SPACE, 9 },
{ -1 }
};
@ -148,12 +148,12 @@ static const struct snes_keybind snes_keybinds_2[] = {
{ SNES_DEVICE_ID_JOYPAD_Y, 'F', 2 },
{ SNES_DEVICE_ID_JOYPAD_L, 'R', 4 },
{ SNES_DEVICE_ID_JOYPAD_R, 'T', 5 },
{ SNES_DEVICE_ID_JOYPAD_LEFT, 'J', 12 },
{ SNES_DEVICE_ID_JOYPAD_RIGHT, 'L', 13 },
{ SNES_DEVICE_ID_JOYPAD_UP, 'I', 10 },
{ SNES_DEVICE_ID_JOYPAD_DOWN, 'K', 11 },
{ SNES_DEVICE_ID_JOYPAD_LEFT, 'J', 11 },
{ SNES_DEVICE_ID_JOYPAD_RIGHT, 'L', 12 },
{ SNES_DEVICE_ID_JOYPAD_UP, 'I', 13 },
{ SNES_DEVICE_ID_JOYPAD_DOWN, 'K', 14 },
{ SNES_DEVICE_ID_JOYPAD_START, 'P', 6 },
{ SNES_DEVICE_ID_JOYPAD_SELECT, 'O', 14 },
{ SNES_DEVICE_ID_JOYPAD_SELECT, 'O', 7 },
{ -1 }
};

View File

@ -1,6 +1,6 @@
BUILD_OPENGL = 1
BUILD_CG = 0
BUILD_CG = 1
BUILD_FILTER = 0
BUILD_RSOUND = 0
@ -10,5 +10,4 @@ BUILD_ROAR = 0
BUILD_AL = 0
PREFIX = /usr/local
PREFIX = /usr

8
gl.c
View File

@ -61,6 +61,7 @@ typedef struct gl
CGprofile cgFProf;
CGprofile cgVProf;
CGparameter cg_video_size, cg_texture_size, cg_output_size;
CGparameter cg_Vvideo_size, cg_Vtexture_size, cg_Voutput_size; // Vertexes
#endif
GLuint texture;
GLuint tex_filter;
@ -248,6 +249,10 @@ static bool gl_frame(void *data, const uint16_t* frame, int width, int height, i
cgGLSetParameter2f(gl->cg_video_size, width, height);
cgGLSetParameter2f(gl->cg_texture_size, width, height);
cgGLSetParameter2f(gl->cg_output_size, gl_width, gl_height);
cgGLSetParameter2f(gl->cg_Vvideo_size, width, height);
cgGLSetParameter2f(gl->cg_Vtexture_size, width, height);
cgGLSetParameter2f(gl->cg_Voutput_size, gl_width, gl_height);
#endif
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch >> 1);
@ -376,6 +381,9 @@ static void* gl_init(video_info_t *video, const input_driver_t **input)
gl->cg_video_size = cgGetNamedParameter(gl->cgFPrg, "IN.video_size");
gl->cg_texture_size = cgGetNamedParameter(gl->cgFPrg, "IN.texture_size");
gl->cg_output_size = cgGetNamedParameter(gl->cgFPrg, "IN.output_size");
gl->cg_Vvideo_size = cgGetNamedParameter(gl->cgVPrg, "IN.video_size");
gl->cg_Vtexture_size = cgGetNamedParameter(gl->cgVPrg, "IN.texture_size");
gl->cg_Voutput_size = cgGetNamedParameter(gl->cgVPrg, "IN.output_size");
cg_mvp_matrix = cgGetNamedParameter(gl->cgVPrg, "modelViewProj");
cgGLSetStateMatrixParameter(cg_mvp_matrix, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
#endif

View File

@ -17,7 +17,7 @@ void main_vertex
otexCoord = texCoord;
}
float Luminance = 0.08f;
float Luminance = 0.09f;
static const float fMiddleGray = 0.18f;
static const float fWhiteCutoff = 0.8f;

87
hqflt/cg/quad.cg Normal file
View File

@ -0,0 +1,87 @@
/*
Author: Themaister
License: Public domain
*/
/* Default Vertex shader */
void main_vertex
(
float4 position : POSITION,
float4 color : COLOR,
float2 texCoord : TEXCOORD0,
uniform float4x4 modelViewProj,
out float4 oPosition : POSITION,
out float4 oColor : COLOR,
out float2 otexCoord : TEXCOORD
)
{
oPosition = mul(modelViewProj, position);
oColor = color;
otexCoord = texCoord;
}
struct output
{
float4 color : COLOR;
};
struct input
{
float2 video_size;
float2 texture_size;
float2 output_size;
};
struct deltas
{
float2 UL, UR, DL, DR;
};
float3 quad_inter(float3 x0, float3 x1, float3 x2, float x)
{
float3 poly[3];
poly[2] = 0.5*x0 - x1 + 0.5*x2;
poly[1] = -1.5*x0 + 2.0*x1 - 0.5*x2;
poly[0] = x0;
return poly[2] * x * x + poly[1] * x + poly[0];
}
output main_fragment (float2 tex : TEXCOORD0, uniform input IN, uniform sampler2D s0 : TEXUNIT0)
{
float2 texsize = IN.texture_size;
float sharpness = 2.0;
float dx = float(pow(sharpness * texsize.x, -1.0));
float dy = float(pow(sharpness * texsize.y, -1.0));
float3 c00 = tex2D(s0, tex + float2(-dx, -dy)).xyz;
float3 c01 = tex2D(s0, tex + float2(-dx, 0)).xyz;
float3 c02 = tex2D(s0, tex + float2(-dx, dy)).xyz;
float3 c10 = tex2D(s0, tex + float2(0, -dy)).xyz;
float3 c11 = tex2D(s0, tex + float2(0, 0)).xyz;
float3 c12 = tex2D(s0, tex + float2(0, dy)).xyz;
float3 c20 = tex2D(s0, tex + float2(dx, -dy)).xyz;
float3 c21 = tex2D(s0, tex + float2(dx, 0)).xyz;
float3 c22 = tex2D(s0, tex + float2(dx, dy)).xyz;
float frac_amt_x = frac(tex.x * texsize.x);
float frac_amt_y = frac(tex.y * texsize.y);
float3 loval = quad_inter(c00, c10, c20, frac_amt_x + 0.5);
float3 midval = quad_inter(c01, c11, c21, frac_amt_x + 0.5);
float3 hival = quad_inter(c02, c12, c22, frac_amt_x + 0.5);
float3 res = quad_inter(loval, midval, hival, frac_amt_y + 0.5);
output OUT;
// Bilinear!
// float3 first = lerp(c00, c20, frac(tex.x * texsize.x + 0.5));
// float3 second = lerp(c02, c22, frac(tex.x * texsize.x + 0.5));
// float3 res = lerp(first, second, frac(tex.y * texsize.y + 0.5));
// OUT.color = float4(res, 1.0);
OUT.color = float4(res, 1.0);
return OUT;
}