Skip to content

Commit

Permalink
[video]: Video overhaul
Browse files Browse the repository at this point in the history
video_driver -> video_interpolation
All video driver options now correspond to interpolation settings (scaling)
  • Loading branch information
mrpapersonic committed Jun 21, 2022
1 parent b5e16e7 commit 7be04b0
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 179 deletions.
2 changes: 1 addition & 1 deletion include/it.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ extern int show_default_volumes; /* pattern-view.c */
/* --------------------------------------------------------------------- */
/* settings (config.c) */

extern char cfg_video_driver[];
extern char cfg_video_interpolation[];
/* TODO: consolidate these into cfg_video_flags */
extern int cfg_video_fullscreen;
extern int cfg_video_mousecursor;
Expand Down
5 changes: 3 additions & 2 deletions include/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ void vgamem_scan8(unsigned int y,unsigned char *out,unsigned int tc[16], unsigne
/* video output routines */
const char *video_driver_name(void);

void video_setup(const char *driver);
void video_redraw_texture(void);
void video_setup(const char *quality);
void video_startup(void);
void video_shutdown(void);
void video_report(void);
void video_refresh(void);
void video_colors(unsigned char palette[16][3]);
void video_resize(unsigned int width, unsigned int height);
void video_fullscreen(int tri);
void video_fullscreen(int new_fs_flag);
void video_translate(unsigned int vx, unsigned int vy,
unsigned int *x, unsigned int *y);
void video_blit(void);
Expand Down
6 changes: 3 additions & 3 deletions schism/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

char cfg_dir_modules[PATH_MAX + 1], cfg_dir_samples[PATH_MAX + 1], cfg_dir_instruments[PATH_MAX + 1],
cfg_dir_dotschism[PATH_MAX + 1], cfg_font[NAME_MAX + 1];
char cfg_video_driver[65];
char cfg_video_interpolation[8];
int cfg_video_fullscreen = 0;
int cfg_video_mousecursor = MOUSE_EMULATED;
int cfg_video_gl_bilinear = 1;
Expand Down Expand Up @@ -133,7 +133,7 @@ void cfg_load(void)

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

cfg_get_string(&cfg, "Video", "driver", cfg_video_driver, 64, "");
cfg_get_string(&cfg, "Video", "interpolation", cfg_video_interpolation, 64, "");
cfg_video_width = cfg_get_number(&cfg, "Video", "width", 640);
cfg_video_height = cfg_get_number(&cfg, "Video", "height", 400);
cfg_video_fullscreen = !!cfg_get_number(&cfg, "Video", "fullscreen", 0);
Expand Down Expand Up @@ -302,7 +302,7 @@ void cfg_atexit_save(void)
/* TODO: move these config options to video.c, this is lame :)
Or put everything here, which is what the note in audio_loadsave.cc
says. Very well, I contradict myself. */
cfg_set_string(&cfg, "Video", "driver", video_driver_name());
cfg_set_string(&cfg, "Video", "interpolation", SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY));
cfg_set_number(&cfg, "Video", "fullscreen", !!(video_is_fullscreen()));
cfg_set_number(&cfg, "Video", "mouse_cursor", video_mousecursor_visible());
cfg_set_number(&cfg, "Video", "gl_bilinear", 1);
Expand Down
7 changes: 0 additions & 7 deletions schism/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ static void handle_window_event(SDL_WindowEvent *w)
SDL_WINDOWEVENT_NONE, /**< Never used */
SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
*/
SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as
a result of an API call or through the
system or user changing the window size. */
SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
Expand Down Expand Up @@ -1132,10 +1129,6 @@ int main(int argc, char **argv)
if (startup_flags & SF_CLASSIC) status.flags |= CLASSIC_MODE;
}

if (!video_driver) {
video_driver = cfg_video_driver;
if (!video_driver || !*video_driver) video_driver = NULL;
}
if (!did_fullscreen) {
video_fullscreen(cfg_video_fullscreen);
}
Expand Down
123 changes: 18 additions & 105 deletions schism/page_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,92 +104,21 @@ static void change_ui_settings(void)
static int countdown = 10;
static time_t started = 0;

static const char *video_revert_driver = NULL;
static int video_revert_fs = 0;

static void video_mode_keep(UNUSED void*ign)
{
status_text_flash(SAVED_AT_EXIT);
config_set_page();
status.flags |= NEED_UPDATE;
}
static void video_mode_cancel(UNUSED void*ign)
{
if (video_revert_driver) {
video_startup();
}
video_fullscreen(video_revert_fs);
palette_apply();
font_init();
config_set_page();
status.flags |= NEED_UPDATE;
}

static void video_dialog_draw_const(void)
{
char buf[80];
time_t now;

time(&now);
if (now != started) {
countdown--;
time(&started); /* err... */
status.flags |= NEED_UPDATE;
if (countdown == 0) {
dialog_destroy();
video_mode_cancel(NULL);
return;
}
}

draw_text("Your video settings have been changed.", 21,19,0,2);
sprintf(buf, "In %2d seconds, your changes will be", countdown);
draw_text(buf, 23, 21, 0, 2);
draw_text("reverted to the last known-good", 21, 22, 0, 2);
draw_text("settings.", 21, 23, 0, 2);
draw_text("To use the new video mode, and make", 21, 24, 0, 2);
draw_text("it default, select OK.", 21, 25, 0, 2);
}

static struct widget video_dialog_widgets[2];
static void video_change_dialog(void)
{
struct dialog *d;

video_revert_driver = video_driver_name();
video_revert_fs = video_is_fullscreen();

countdown = 10;
time(&started);

create_button(video_dialog_widgets+0, 28,28,8, 0, 0, 0, 1, 1,
dialog_yes_NULL, "OK", 4);
create_button(video_dialog_widgets+1, 42,28,8, 1, 1, 0, 1, 0,
dialog_cancel_NULL, "Cancel", 2);
d = dialog_create_custom(20, 17, 40, 14,
video_dialog_widgets,
2, 1,
video_dialog_draw_const, NULL);
d->action_yes = video_mode_keep;
d->action_no = video_mode_cancel;
d->action_cancel = video_mode_cancel;
}

static void change_video_settings(void)
{
const char *new_video_driver;
int new_fs_flag;

if (widgets_config[11].d.togglebutton.state) {
new_video_driver = "sdl";
new_video_driver = "nearest";
} else if (widgets_config[12].d.togglebutton.state) {
new_video_driver = "yuv";
new_video_driver = "linear";
} else if (widgets_config[13].d.togglebutton.state) {
new_video_driver = "gl";
} else if (widgets_config[14].d.togglebutton.state) {
new_video_driver = "directdraw";
new_video_driver = "best";
} else {
new_video_driver = "sdl";
new_video_driver = "linear";
}

if (widgets_config[9].d.togglebutton.state) {
Expand All @@ -198,17 +127,17 @@ static void change_video_settings(void)
new_fs_flag = 0;
}

if (!strcasecmp(new_video_driver, video_driver_name())
if (!SDL_strcasecmp(new_video_driver, SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY))
&& new_fs_flag == video_is_fullscreen()) {
return;
}

video_change_dialog();
if (strcasecmp(new_video_driver, video_driver_name())) {
video_startup();
if (SDL_strcasecmp(new_video_driver, SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY))) {
video_setup(new_video_driver);
}
video_redraw_texture();
if (new_fs_flag != video_is_fullscreen())
video_fullscreen(new_fs_flag);
toggle_display_fullscreen();
palette_apply();
font_init();
}
Expand All @@ -231,7 +160,7 @@ static void config_draw_const(void)

draw_text("MIDI mode", 8,25, 0, 2);

draw_text("Video Driver:", 2, 28, 0, 2);
draw_text("Video Scaling:", 2, 28, 0, 2);
draw_text("Full Screen:", 38, 28, 0, 2);

draw_fill_chars(18, 15, 34, 25, 0);
Expand Down Expand Up @@ -262,11 +191,10 @@ static void config_set_page(void)
widgets_config[9].d.togglebutton.state = video_is_fullscreen();
widgets_config[10].d.togglebutton.state = !video_is_fullscreen();

nn = video_driver_name();
widgets_config[11].d.togglebutton.state = (strcasecmp(nn,"sdl") == 0);
widgets_config[12].d.togglebutton.state = (strcasecmp(nn,"yuv") == 0);
widgets_config[13].d.togglebutton.state = (strcasecmp(nn,"opengl") == 0);
widgets_config[14].d.togglebutton.state = (strcasecmp(nn,"directdraw") == 0);
const char* hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
widgets_config[11].d.togglebutton.state = (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0);
widgets_config[12].d.togglebutton.state = (!hint || *hint == '1' || SDL_strcasecmp(hint, "linear") == 0);
widgets_config[13].d.togglebutton.state = (!hint || *hint == '2' || SDL_strcasecmp(hint, "best") == 0);
}

/* --------------------------------------------------------------------- */
Expand All @@ -275,7 +203,7 @@ void config_load_page(struct page *page)
page->title = "System Configuration (Ctrl-F1)";
page->draw_const = config_draw_const;
page->set_page = config_set_page;
page->total_widgets = 15;
page->total_widgets = 14;
page->widgets = widgets_config;
page->help_index = HELP_GLOBAL;

Expand Down Expand Up @@ -343,36 +271,21 @@ void config_load_page(struct page *page)
6, 30, 26,
8,12,11,9,12,
change_video_settings,
"SDL Video Surface",
"Nearest",
2, video_group);

create_togglebutton(widgets_config+12,
6, 33, 26,
11,13,12,9,13,
change_video_settings,
"YUV Video Overlay",
"Linear",
2, video_group);

create_togglebutton(widgets_config+13,
6, 36, 26,
12,14,13,9,14,
change_video_settings,
"OpenGL Graphic Context",
2, video_group);

create_togglebutton(widgets_config+14,
6, 39, 26,
13,14,14,9,9,
change_video_settings,
"DirectDraw Surface",
"Best",
2, video_group);
#ifndef WIN32
/* patch ddraw out */
video_group[3] = -1;
widgets_config[14].d.togglebutton.state = 0;
widgets_config[13].next.down = 13;
widgets_config[13].next.tab = 9;
page->total_widgets--;
#endif

}
37 changes: 22 additions & 15 deletions schism/page_loadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,21 +812,28 @@ static int dir_list_handle_key(struct key_event * k)

if (k->mouse != MOUSE_NONE) {
if (k->x >= 50 && k->x <= 67 && k->y >= 13 && k->y <= 33) {
if (k->mouse == MOUSE_CLICK) {
new_dir = (k->y - 13) + top_dir;
} else if (k->mouse == MOUSE_DBLCLICK) {
top_file = current_file = 0;
change_dir(dlist.dirs[current_dir]->path);

if (flist.num_files > 0)
*selected_widget = 0;
status.flags |= NEED_UPDATE;
return 1;
/* FIXME wheel should be adjusting top_dir instead (and then adjust it later) */
} else if (k->mouse == MOUSE_SCROLL_UP) {
new_dir -= MOUSE_SCROLL_LINES;
} else if (k->mouse == MOUSE_SCROLL_DOWN) {
new_dir += MOUSE_SCROLL_LINES;
switch (k->mouse) {
case MOUSE_CLICK:
new_dir = (k->y - 13) + top_dir;
break;
case MOUSE_DBLCLICK:
top_file = current_file = 0;
change_dir(dlist.dirs[current_dir]->path);

if (flist.num_files > 0)
*selected_widget = 0;
status.flags |= NEED_UPDATE;
return 1;
break;
case MOUSE_SCROLL_UP:
case MOUSE_SCROLL_DOWN:
top_dir += (k->mouse == MOUSE_SCROLL_UP) ? -MOUSE_SCROLL_LINES : MOUSE_SCROLL_LINES;
if (top_dir > dlist.num_dirs - 21)
top_dir = dlist.num_dirs - 21;
if (top_dir < 0)
top_dir = 0;
status.flags |= NEED_UPDATE;
break;
}
} else {
return 0;
Expand Down
Loading

0 comments on commit 7be04b0

Please sign in to comment.