[GTK3] Implement the new SGB border options
This commit is contained in:
parent
5b79094293
commit
b142227577
24
gtk3/main.c
24
gtk3/main.c
@ -58,6 +58,7 @@ static bool vram_viewer_updating = false;
|
||||
static gchar *vram_viewer_active_tab = "";
|
||||
static gboolean vram_viewer_is_cgb = false;
|
||||
static uint8_t vram_viewer_palette_data[16][0x40];
|
||||
static bool border_mode_changed = false;
|
||||
|
||||
static volatile bool running = false;
|
||||
static volatile bool stopping = false;
|
||||
@ -1561,6 +1562,13 @@ G_MODULE_EXPORT void on_frame_blending_changed(GtkWidget *w, gpointer user_data_
|
||||
config.frame_blending_mode = (gchar *)gtk_combo_box_get_active_id(box);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void on_display_border_changed(GtkWidget *w, gpointer user_data_gptr) {
|
||||
GtkComboBox *box = GTK_COMBO_BOX(w);
|
||||
config.display_border_mode = (gchar *)gtk_combo_box_get_active_id(box);
|
||||
|
||||
border_mode_changed = true;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void on_color_menubar_override_changed(GtkWidget *w, gpointer user_data_gptr) {
|
||||
config.menubar_override = (gchar *)gtk_combo_box_get_active_id(GTK_COMBO_BOX(w));
|
||||
}
|
||||
@ -1982,6 +1990,14 @@ static void on_vblank(gpointer data) {
|
||||
|
||||
static void vblank(GB_gameboy_t *gb) {
|
||||
flip();
|
||||
|
||||
if (border_mode_changed) {
|
||||
GB_set_border_mode(gb, get_display_border_mode());
|
||||
update_window_geometry();
|
||||
|
||||
border_mode_changed = false;
|
||||
}
|
||||
|
||||
GB_set_pixels_output(gb, get_pixels());
|
||||
|
||||
if (underclock_down && clock_mutliplier > 0.5) {
|
||||
@ -2083,7 +2099,6 @@ static void init(GuiData *gui_data) {
|
||||
if (GB_is_inited(&gb)) return;
|
||||
|
||||
GB_init(&gb, get_model());
|
||||
update_window_geometry();
|
||||
|
||||
GB_set_vblank_callback(&gb, vblank);
|
||||
GB_set_pixels_output(&gb, get_current_buffer());
|
||||
@ -2098,6 +2113,12 @@ static void init(GuiData *gui_data) {
|
||||
GB_set_async_input_callback(&gb, async_console_input);
|
||||
GB_set_log_callback(&gb, console_log);
|
||||
GB_set_boot_rom_load_callback(&gb, load_boot_rom);
|
||||
|
||||
if (get_display_border_mode() <= GB_BORDER_ALWAYS) {
|
||||
GB_set_border_mode(&gb, get_display_border_mode());
|
||||
}
|
||||
|
||||
update_window_geometry();
|
||||
}
|
||||
|
||||
static void load_boot_rom(GB_gameboy_t *gb, GB_boot_rom_t type) {
|
||||
@ -2201,7 +2222,6 @@ static void reset(GuiData *gui_data) {
|
||||
update_window_geometry();
|
||||
}
|
||||
|
||||
|
||||
char *path = g_file_get_path(gui_data->file);
|
||||
|
||||
if (GB_load_rom(&gb, path) != 0) {
|
||||
|
@ -141,6 +141,7 @@ G_MODULE_EXPORT void on_boot_rom_location_changed(GtkWidget *w, gpointer user_da
|
||||
G_MODULE_EXPORT void on_cgb_model_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_color_correction_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_frame_blending_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_display_border_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_color_menubar_override_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_dmg_model_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
G_MODULE_EXPORT void on_graphic_filter_changed(GtkWidget *w, gpointer user_data_gptr);
|
||||
|
@ -660,6 +660,39 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Display Border:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="display_border_selector">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
<items>
|
||||
<item id="never" translatable="yes">Never</item>
|
||||
<item id="sgb_only" translatable="yes">Super Game Boy Only</item>
|
||||
<item id="always" translatable="yes">Always</item>
|
||||
</items>
|
||||
<signal name="changed" handler="on_display_border_changed" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="integer_scaling_toggle">
|
||||
<property name="label" translatable="yes">Use Integer Scaling</property>
|
||||
@ -674,7 +707,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
<property name="position">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@ -691,7 +724,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
<property name="position">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@ -702,7 +735,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
<property name="position">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@ -719,7 +752,7 @@ Maximilian Mader https://github.com/max-m</property>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">9</property>
|
||||
<property name="position">11</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -109,6 +109,7 @@ void on_preferences_realize(GtkWidget *w, gpointer builder_ptr) {
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "shader_selector"), config.shader);
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "color_correction_selector"), config.color_correction_id);
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "frame_blending_selector"), config.frame_blending_mode);
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "display_border_selector"), config.display_border_mode);
|
||||
gtk_toggle_button_set_active(builder_get(GTK_TOGGLE_BUTTON, "integer_scaling_toggle"), config.use_integer_scaling);
|
||||
gtk_toggle_button_set_active(builder_get(GTK_TOGGLE_BUTTON, "aspect_ratio_toggle"), config.keep_aspect_ratio);
|
||||
gtk_combo_box_set_active_id(builder_get(GTK_COMBO_BOX, "highpass_filter_selector"), config.high_pass_filter_id);
|
||||
@ -311,6 +312,38 @@ void set_frame_blending_mode(GB_frame_blending_mode_t mode) {
|
||||
}
|
||||
}
|
||||
|
||||
GB_border_mode_t get_display_border_mode(void) {
|
||||
if (config.display_border_mode == NULL) goto default_value;
|
||||
|
||||
if (g_strcmp0(config.display_border_mode, "never") == 0) {
|
||||
return GB_BORDER_NEVER;
|
||||
}
|
||||
else if (g_strcmp0(config.display_border_mode, "sgb_only") == 0) {
|
||||
return GB_BORDER_SGB;
|
||||
}
|
||||
else if (g_strcmp0(config.display_border_mode, "always") == 0) {
|
||||
return GB_BORDER_ALWAYS;
|
||||
}
|
||||
|
||||
// This should not happen
|
||||
g_warning("Unknown frame blending mode: %s\nFalling back to “Never”", config.display_border_mode);
|
||||
default_value: return GB_BORDER_NEVER;
|
||||
}
|
||||
|
||||
void set_display_border_mode(GB_border_mode_t mode) {
|
||||
switch (mode) {
|
||||
case GB_BORDER_NEVER:
|
||||
config.display_border_mode = "never";
|
||||
break;
|
||||
case GB_BORDER_SGB:
|
||||
config.display_border_mode = "sgb_only";
|
||||
break;
|
||||
case GB_BORDER_ALWAYS:
|
||||
config.display_border_mode = "always";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GB_highpass_mode_t get_highpass_mode(void) {
|
||||
if (config.high_pass_filter_id == NULL) goto default_value;
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
EXPAND_GROUP_MEMBER(shader, string, "NearestNeighbor") \
|
||||
EXPAND_GROUP_MEMBER(color_correction_id, string, "emulate_hardware") \
|
||||
EXPAND_GROUP_MEMBER(frame_blending_mode, string, "disabled") \
|
||||
EXPAND_GROUP_MEMBER(display_border_mode, string, "never") \
|
||||
EXPAND_GROUP_MEMBER(keep_aspect_ratio, boolean, true) \
|
||||
EXPAND_GROUP_MEMBER(use_integer_scaling, boolean, true) \
|
||||
EXPAND_GROUP_MEMBER(menubar_override, string, "auto") \
|
||||
@ -93,6 +94,9 @@ void set_color_correction_mode(GB_color_correction_mode_t);
|
||||
GB_frame_blending_mode_t get_frame_blending_mode(void);
|
||||
void set_frame_blending_mode(GB_frame_blending_mode_t);
|
||||
|
||||
GB_border_mode_t get_display_border_mode(void);
|
||||
void set_display_border_mode(GB_border_mode_t);
|
||||
|
||||
GB_highpass_mode_t get_highpass_mode(void);
|
||||
void set_highpass_mode(GB_highpass_mode_t);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user