add widescreen stretch option (#291)

This commit is contained in:
Logan McNaughton
2025-02-27 22:05:19 +01:00
committed by GitHub
parent ee77e75855
commit 7b51ca82eb
5 changed files with 28 additions and 4 deletions
+1 -1
View File
@@ -294,7 +294,7 @@ void rdp_close()
static void calculate_viewport(float *x, float *y, float *width, float *height)
{
const int32_t display_width = gfx_info.PAL ? 384 : 320;
const int32_t display_width = gfx_info.widescreen ? (gfx_info.PAL ? 512 : 426) : (gfx_info.PAL ? 384 : 320);
const int32_t display_height = gfx_info.PAL ? 288 : 240;
int w, h;
+1
View File
@@ -17,6 +17,7 @@ extern "C"
uint32_t *DPC_END_REG;
uint32_t *DPC_STATUS_REG;
bool PAL;
bool widescreen;
} GFX_INFO;
typedef struct
+2
View File
@@ -45,6 +45,7 @@ pub struct Video {
pub upscale: u32,
pub integer_scaling: bool,
pub fullscreen: bool,
pub widescreen: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Config {
@@ -96,6 +97,7 @@ impl Config {
upscale: 1,
integer_scaling: false,
fullscreen: false,
widescreen: false,
},
}
}
+8
View File
@@ -17,6 +17,7 @@ pub struct GopherEguiApp {
upscale: u32,
integer_scaling: bool,
fullscreen: bool,
widescreen: bool,
emulate_vru: bool,
dinput: bool,
show_vru_dialog: bool,
@@ -41,6 +42,7 @@ struct SaveConfig {
upscale: u32,
integer_scaling: bool,
fullscreen: bool,
widescreen: bool,
emulate_vru: bool,
}
@@ -116,6 +118,7 @@ impl GopherEguiApp {
upscale: config.video.upscale,
integer_scaling: config.video.integer_scaling,
fullscreen: config.video.fullscreen,
widescreen: config.video.widescreen,
emulate_vru: config.input.emulate_vru,
show_vru_dialog: false,
dinput: false,
@@ -152,6 +155,7 @@ fn save_config(
config.video.upscale = save_config_items.upscale;
config.video.integer_scaling = save_config_items.integer_scaling;
config.video.fullscreen = save_config_items.fullscreen;
config.video.widescreen = save_config_items.widescreen;
config.input.emulate_vru = save_config_items.emulate_vru;
}
@@ -165,6 +169,7 @@ impl Drop for GopherEguiApp {
upscale: self.upscale,
integer_scaling: self.integer_scaling,
fullscreen: self.fullscreen,
widescreen: self.widescreen,
emulate_vru: self.emulate_vru,
};
let mut config = ui::config::Config::new();
@@ -300,6 +305,7 @@ pub fn open_rom(app: &mut GopherEguiApp, ctx: &egui::Context) {
let upscale = app.upscale;
let integer_scaling = app.integer_scaling;
let fullscreen = app.fullscreen;
let widescreen = app.widescreen;
let emulate_vru = app.emulate_vru;
let peer_addr;
let session;
@@ -394,6 +400,7 @@ pub fn open_rom(app: &mut GopherEguiApp, ctx: &egui::Context) {
upscale,
integer_scaling,
fullscreen,
widescreen,
emulate_vru,
};
@@ -606,6 +613,7 @@ impl eframe::App for GopherEguiApp {
};
ui.checkbox(&mut self.integer_scaling, "Integer Scaling");
ui.checkbox(&mut self.fullscreen, "Fullscreen (Esc closes game)");
ui.checkbox(&mut self.widescreen, "Widescreen (stretch)");
ui.add_space(16.0);
ui.hyperlink_to("Wiki", "https://github.com/gopher64/gopher64/wiki");
+16 -3
View File
@@ -16,11 +16,22 @@ pub fn init(device: &mut device::Device) {
}
flags |= sdl3_sys::video::SDL_WINDOW_INPUT_FOCUS;
let mut window_width = 640;
let mut window_height = 480;
let window_width;
let window_height;
if device.cart.pal {
window_width = 768;
window_width = if device.ui.config.video.widescreen {
1024
} else {
768
};
window_height = 576;
} else {
window_width = if device.ui.config.video.widescreen {
852
} else {
640
};
window_height = 480;
}
device.ui.window = unsafe {
sdl3_sys::video::SDL_CreateWindow(title.as_ptr(), window_width, window_height, flags)
@@ -42,6 +53,7 @@ pub fn init(device: &mut device::Device) {
DPC_END_REG: &mut device.rdp.regs_dpc[device::rdp::DPC_END_REG as usize],
DPC_STATUS_REG: &mut device.rdp.regs_dpc[device::rdp::DPC_STATUS_REG as usize],
PAL: device.cart.pal,
widescreen: device.ui.config.video.widescreen,
};
unsafe {
@@ -85,6 +97,7 @@ pub fn load_state(device: &mut device::Device) {
DPC_END_REG: &mut device.rdp.regs_dpc[device::rdp::DPC_END_REG as usize],
DPC_STATUS_REG: &mut device.rdp.regs_dpc[device::rdp::DPC_STATUS_REG as usize],
PAL: device.cart.pal,
widescreen: device.ui.config.video.widescreen,
};
unsafe {
rdp_new_processor(gfx_info, device.ui.config.video.upscale);