Skip to content

Commit 24b464f

Browse files
authored
Add option for high-res graphics (#111)
1 parent 89673df commit 24b464f

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

parallel-rdp/interface.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static const unsigned cmd_len_lut[64] = {
132132
1,
133133
};
134134

135-
void rdp_init(void *_window, GFX_INFO _gfx_info, bool _fullscreen)
135+
void rdp_init(void *_window, GFX_INFO _gfx_info, bool _fullscreen, bool _upscale)
136136
{
137137
window = (SDL_Window *)_window;
138138
SDL_SetEventFilter(sdl_event_filter, nullptr);
@@ -156,6 +156,11 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, bool _fullscreen)
156156
rdp_close();
157157
}
158158
RDP::CommandProcessorFlags flags = 0;
159+
if (_upscale)
160+
{
161+
flags |= RDP::COMMAND_PROCESSOR_FLAG_UPSCALING_2X_BIT;
162+
flags |= RDP::COMMAND_PROCESSOR_FLAG_SUPER_SAMPLED_DITHER_BIT;
163+
}
159164
processor = new RDP::CommandProcessor(wsi->get_device(), gfx_info.RDRAM, 0, gfx_info.RDRAM_SIZE, gfx_info.RDRAM_SIZE / 2, flags);
160165

161166
if (!processor->device_is_supported())

parallel-rdp/interface.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern "C"
2323
uint32_t *VI_WIDTH_REG;
2424
} GFX_INFO;
2525

26-
void rdp_init(void *_window, GFX_INFO _gfx_info, bool fullscreen);
26+
void rdp_init(void *_window, GFX_INFO _gfx_info, bool fullscreen, bool _upscale);
2727
void rdp_close();
2828
void rdp_set_vi_register(uint32_t reg, uint32_t value);
2929
bool rdp_update_screen();

src/ui/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ pub struct Input {
1818
pub controller_enabled: [bool; 4],
1919
}
2020
#[derive(serde::Serialize, serde::Deserialize)]
21+
pub struct Video {
22+
pub upscale: bool,
23+
}
24+
#[derive(serde::Serialize, serde::Deserialize)]
2125
pub struct Config {
2226
pub input: Input,
27+
pub video: Video,
2328
}
2429

2530
impl Config {
@@ -38,6 +43,7 @@ impl Config {
3843
input_profiles,
3944
controller_enabled: [true, false, false, false],
4045
},
46+
video: Video { upscale: false },
4147
}
4248
}
4349
}

src/ui/gui.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct GopherEguiApp {
1010
selected_profile: [String; 4],
1111
input_profiles: Vec<String>,
1212
controller_enabled: [bool; 4],
13+
upscale: bool,
1314
}
1415

1516
fn get_input_profiles(game_ui: &ui::Ui) -> Vec<String> {
@@ -65,6 +66,7 @@ impl GopherEguiApp {
6566
controllers: get_controllers(&game_ui),
6667
input_profiles: get_input_profiles(&game_ui),
6768
controller_enabled: game_ui.config.input.controller_enabled,
69+
upscale: game_ui.config.video.upscale,
6870
}
6971
}
7072
}
@@ -74,6 +76,7 @@ fn save_config(
7476
selected_controller: [i32; 4],
7577
selected_profile: [String; 4],
7678
controller_enabled: [bool; 4],
79+
upscale: bool,
7780
) {
7881
let joystick_subsystem = game_ui.joystick_subsystem.as_ref().unwrap();
7982
for (pos, item) in selected_controller.iter().enumerate() {
@@ -91,6 +94,8 @@ fn save_config(
9194

9295
game_ui.config.input.input_profile_binding = selected_profile;
9396
game_ui.config.input.controller_enabled = controller_enabled;
97+
98+
game_ui.config.video.upscale = upscale;
9499
}
95100

96101
impl Drop for GopherEguiApp {
@@ -101,6 +106,7 @@ impl Drop for GopherEguiApp {
101106
self.selected_controller,
102107
self.selected_profile.clone(),
103108
self.controller_enabled,
109+
self.upscale,
104110
);
105111
}
106112
}
@@ -148,6 +154,7 @@ impl eframe::App for GopherEguiApp {
148154
let selected_controller = self.selected_controller;
149155
let selected_profile = self.selected_profile.clone();
150156
let controller_enabled = self.controller_enabled;
157+
let upscale = self.upscale;
151158
execute(async move {
152159
let file = task.await;
153160

@@ -166,6 +173,7 @@ impl eframe::App for GopherEguiApp {
166173
selected_controller,
167174
selected_profile,
168175
controller_enabled,
176+
upscale,
169177
);
170178
device::run_game(std::path::Path::new(file.path()), &mut device, false);
171179
let _ = std::fs::remove_file(running_file.clone());
@@ -233,6 +241,8 @@ impl eframe::App for GopherEguiApp {
233241
}
234242
});
235243
ui.add_space(32.0);
244+
ui.checkbox(&mut self.upscale, "High-Res Graphics");
245+
ui.add_space(32.0);
236246
ui.label(format!("Version: {}", env!("CARGO_PKG_VERSION")));
237247
});
238248
}

src/ui/video.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct GfxInfo {
1717
}
1818

1919
unsafe extern "C" {
20-
pub fn rdp_init(window: usize, gfx_info: GfxInfo, fullscreen: bool);
20+
pub fn rdp_init(window: usize, gfx_info: GfxInfo, fullscreen: bool, upscale: bool);
2121
pub fn rdp_close();
2222
pub fn rdp_update_screen() -> bool;
2323
pub fn rdp_set_vi_register(reg: u32, value: u32);
@@ -62,6 +62,7 @@ pub fn init(device: &mut device::Device, fullscreen: bool) {
6262
device.ui.window.as_mut().unwrap().raw() as usize,
6363
gfx_info,
6464
fullscreen,
65+
device.ui.config.video.upscale,
6566
)
6667
}
6768
}

0 commit comments

Comments
 (0)