Frame blending
This commit is contained in:
parent
d262dde71a
commit
3c1a805770
18
SDL/gui.c
18
SDL/gui.c
@ -47,7 +47,7 @@ void render_texture(void *pixels, void *previous)
|
|||||||
|
|
||||||
configuration_t configuration =
|
configuration_t configuration =
|
||||||
{
|
{
|
||||||
{ SDL_SCANCODE_RIGHT,
|
.keys = { SDL_SCANCODE_RIGHT,
|
||||||
SDL_SCANCODE_LEFT,
|
SDL_SCANCODE_LEFT,
|
||||||
SDL_SCANCODE_UP,
|
SDL_SCANCODE_UP,
|
||||||
SDL_SCANCODE_DOWN,
|
SDL_SCANCODE_DOWN,
|
||||||
@ -57,8 +57,9 @@ configuration_t configuration =
|
|||||||
SDL_SCANCODE_RETURN,
|
SDL_SCANCODE_RETURN,
|
||||||
SDL_SCANCODE_SPACE
|
SDL_SCANCODE_SPACE
|
||||||
},
|
},
|
||||||
GB_COLOR_CORRECTION_EMULATE_HARDWARE,
|
.color_correction_mode = GB_COLOR_CORRECTION_EMULATE_HARDWARE,
|
||||||
GB_SDL_SCALING_INTEGER_FACTOR,
|
.scaling_mode = GB_SDL_SCALING_INTEGER_FACTOR,
|
||||||
|
.blend_frames = true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -383,10 +384,21 @@ static void return_to_root_menu(unsigned index)
|
|||||||
current_selection = 0;
|
current_selection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void toggle_blend_frames(unsigned index)
|
||||||
|
{
|
||||||
|
configuration.blend_frames ^= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *blend_frames_string(unsigned index)
|
||||||
|
{
|
||||||
|
return configuration.blend_frames? "Enabled" : "Disabled";
|
||||||
|
}
|
||||||
|
|
||||||
static const struct menu_item graphics_menu[] = {
|
static const struct menu_item graphics_menu[] = {
|
||||||
{"Scaling Mode:", cycle_scaling, current_scaling_mode, cycle_scaling_backwards},
|
{"Scaling Mode:", cycle_scaling, current_scaling_mode, cycle_scaling_backwards},
|
||||||
{"Scaling Filter:", cycle_filter, current_filter_name, cycle_filter_backwards},
|
{"Scaling Filter:", cycle_filter, current_filter_name, cycle_filter_backwards},
|
||||||
{"Color Correction:", cycle_color_correction, current_color_correction_mode, cycle_color_correction_backwards},
|
{"Color Correction:", cycle_color_correction, current_color_correction_mode, cycle_color_correction_backwards},
|
||||||
|
{"Blend Frames:", toggle_blend_frames, blend_frames_string, toggle_blend_frames},
|
||||||
{"Back", return_to_root_menu},
|
{"Back", return_to_root_menu},
|
||||||
{NULL,}
|
{NULL,}
|
||||||
};
|
};
|
||||||
|
@ -35,6 +35,7 @@ typedef struct {
|
|||||||
SDL_Scancode keys[9];
|
SDL_Scancode keys[9];
|
||||||
GB_color_correction_mode_t color_correction_mode;
|
GB_color_correction_mode_t color_correction_mode;
|
||||||
enum scaling_mode scaling_mode;
|
enum scaling_mode scaling_mode;
|
||||||
|
bool blend_frames;
|
||||||
|
|
||||||
bool div_joystick;
|
bool div_joystick;
|
||||||
bool flip_joystick_bit_1;
|
bool flip_joystick_bit_1;
|
||||||
|
17
SDL/main.c
17
SDL/main.c
@ -16,7 +16,9 @@
|
|||||||
GB_gameboy_t gb;
|
GB_gameboy_t gb;
|
||||||
static bool dmg = false;
|
static bool dmg = false;
|
||||||
static bool paused = false;
|
static bool paused = false;
|
||||||
static uint32_t pixels[160*144];
|
static uint32_t pixel_buffer_1[160*144], pixel_buffer_2[160*144];
|
||||||
|
static uint32_t *active_pixel_buffer = pixel_buffer_1, *previous_pixel_buffer = pixel_buffer_2;
|
||||||
|
|
||||||
|
|
||||||
static char *filename = NULL;
|
static char *filename = NULL;
|
||||||
static bool should_free_filename = false;
|
static bool should_free_filename = false;
|
||||||
@ -213,7 +215,16 @@ static void handle_events(GB_gameboy_t *gb)
|
|||||||
|
|
||||||
static void vblank(GB_gameboy_t *gb)
|
static void vblank(GB_gameboy_t *gb)
|
||||||
{
|
{
|
||||||
render_texture(pixels, NULL);
|
if (configuration.blend_frames) {
|
||||||
|
render_texture(active_pixel_buffer, previous_pixel_buffer);
|
||||||
|
uint32_t *temp = active_pixel_buffer;
|
||||||
|
active_pixel_buffer = previous_pixel_buffer;
|
||||||
|
previous_pixel_buffer = temp;
|
||||||
|
GB_set_pixels_output(gb, active_pixel_buffer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
render_texture(active_pixel_buffer, NULL);
|
||||||
|
}
|
||||||
handle_events(gb);
|
handle_events(gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +314,7 @@ restart:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GB_set_vblank_callback(&gb, (GB_vblank_callback_t) vblank);
|
GB_set_vblank_callback(&gb, (GB_vblank_callback_t) vblank);
|
||||||
GB_set_pixels_output(&gb, pixels);
|
GB_set_pixels_output(&gb, active_pixel_buffer);
|
||||||
GB_set_rgb_encode_callback(&gb, rgb_encode);
|
GB_set_rgb_encode_callback(&gb, rgb_encode);
|
||||||
GB_set_sample_rate(&gb, have_aspec.freq);
|
GB_set_sample_rate(&gb, have_aspec.freq);
|
||||||
GB_set_color_correction_mode(&gb, configuration.color_correction_mode);
|
GB_set_color_correction_mode(&gb, configuration.color_correction_mode);
|
||||||
|
Loading…
Reference in New Issue
Block a user