diff --git a/parallel-rdp/interface.cpp b/parallel-rdp/interface.cpp index ed23ebb1..5dda2513 100644 --- a/parallel-rdp/interface.cpp +++ b/parallel-rdp/interface.cpp @@ -132,7 +132,7 @@ static const unsigned cmd_len_lut[64] = { 1, }; -void rdp_init(void *_window, GFX_INFO _gfx_info, bool _fullscreen) +void rdp_init(void *_window, GFX_INFO _gfx_info, bool _fullscreen, bool _upscale) { window = (SDL_Window *)_window; SDL_SetEventFilter(sdl_event_filter, nullptr); @@ -156,6 +156,11 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, bool _fullscreen) rdp_close(); } RDP::CommandProcessorFlags flags = 0; + if (_upscale) + { + flags |= RDP::COMMAND_PROCESSOR_FLAG_UPSCALING_2X_BIT; + flags |= RDP::COMMAND_PROCESSOR_FLAG_SUPER_SAMPLED_DITHER_BIT; + } processor = new RDP::CommandProcessor(wsi->get_device(), gfx_info.RDRAM, 0, gfx_info.RDRAM_SIZE, gfx_info.RDRAM_SIZE / 2, flags); if (!processor->device_is_supported()) diff --git a/parallel-rdp/interface.hpp b/parallel-rdp/interface.hpp index c000293c..a14a8dcc 100644 --- a/parallel-rdp/interface.hpp +++ b/parallel-rdp/interface.hpp @@ -23,7 +23,7 @@ extern "C" uint32_t *VI_WIDTH_REG; } GFX_INFO; - void rdp_init(void *_window, GFX_INFO _gfx_info, bool fullscreen); + void rdp_init(void *_window, GFX_INFO _gfx_info, bool fullscreen, bool _upscale); void rdp_close(); void rdp_set_vi_register(uint32_t reg, uint32_t value); bool rdp_update_screen(); diff --git a/src/ui/config.rs b/src/ui/config.rs index 0ace8244..82839dac 100644 --- a/src/ui/config.rs +++ b/src/ui/config.rs @@ -18,8 +18,13 @@ pub struct Input { pub controller_enabled: [bool; 4], } #[derive(serde::Serialize, serde::Deserialize)] +pub struct Video { + pub upscale: bool, +} +#[derive(serde::Serialize, serde::Deserialize)] pub struct Config { pub input: Input, + pub video: Video, } impl Config { @@ -38,6 +43,7 @@ impl Config { input_profiles, controller_enabled: [true, false, false, false], }, + video: Video { upscale: false }, } } } diff --git a/src/ui/gui.rs b/src/ui/gui.rs index 24946ea2..faa2c8a3 100644 --- a/src/ui/gui.rs +++ b/src/ui/gui.rs @@ -10,6 +10,7 @@ pub struct GopherEguiApp { selected_profile: [String; 4], input_profiles: Vec, controller_enabled: [bool; 4], + upscale: bool, } fn get_input_profiles(game_ui: &ui::Ui) -> Vec { @@ -65,6 +66,7 @@ impl GopherEguiApp { controllers: get_controllers(&game_ui), input_profiles: get_input_profiles(&game_ui), controller_enabled: game_ui.config.input.controller_enabled, + upscale: game_ui.config.video.upscale, } } } @@ -74,6 +76,7 @@ fn save_config( selected_controller: [i32; 4], selected_profile: [String; 4], controller_enabled: [bool; 4], + upscale: bool, ) { let joystick_subsystem = game_ui.joystick_subsystem.as_ref().unwrap(); for (pos, item) in selected_controller.iter().enumerate() { @@ -91,6 +94,8 @@ fn save_config( game_ui.config.input.input_profile_binding = selected_profile; game_ui.config.input.controller_enabled = controller_enabled; + + game_ui.config.video.upscale = upscale; } impl Drop for GopherEguiApp { @@ -101,6 +106,7 @@ impl Drop for GopherEguiApp { self.selected_controller, self.selected_profile.clone(), self.controller_enabled, + self.upscale, ); } } @@ -148,6 +154,7 @@ impl eframe::App for GopherEguiApp { let selected_controller = self.selected_controller; let selected_profile = self.selected_profile.clone(); let controller_enabled = self.controller_enabled; + let upscale = self.upscale; execute(async move { let file = task.await; @@ -166,6 +173,7 @@ impl eframe::App for GopherEguiApp { selected_controller, selected_profile, controller_enabled, + upscale, ); device::run_game(std::path::Path::new(file.path()), &mut device, false); let _ = std::fs::remove_file(running_file.clone()); @@ -233,6 +241,8 @@ impl eframe::App for GopherEguiApp { } }); ui.add_space(32.0); + ui.checkbox(&mut self.upscale, "High-Res Graphics"); + ui.add_space(32.0); ui.label(format!("Version: {}", env!("CARGO_PKG_VERSION"))); }); } diff --git a/src/ui/video.rs b/src/ui/video.rs index f65a7fa5..dbf02761 100644 --- a/src/ui/video.rs +++ b/src/ui/video.rs @@ -17,7 +17,7 @@ pub struct GfxInfo { } unsafe extern "C" { - pub fn rdp_init(window: usize, gfx_info: GfxInfo, fullscreen: bool); + pub fn rdp_init(window: usize, gfx_info: GfxInfo, fullscreen: bool, upscale: bool); pub fn rdp_close(); pub fn rdp_update_screen() -> bool; pub fn rdp_set_vi_register(reg: u32, value: u32); @@ -62,6 +62,7 @@ pub fn init(device: &mut device::Device, fullscreen: bool) { device.ui.window.as_mut().unwrap().raw() as usize, gfx_info, fullscreen, + device.ui.config.video.upscale, ) } }