mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 09:35:21 +02:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0eadc38917 | |||
| a40e795036 | |||
| b70c943a43 | |||
| c962589478 | |||
| 6dec154351 | |||
| ca33797973 | |||
| 8d331e1aed | |||
| 5e7f562d0d | |||
| 14e3fe2a55 | |||
| b1c6dd2910 | |||
| e87c4736ee | |||
| e9e1e000c2 | |||
| bc83dd26ee | |||
| ae97990308 | |||
| e02ac09703 | |||
| 4cbdae2fce | |||
| 877eff0fd4 | |||
| b560944234 | |||
| c6bfea5018 | |||
| 74db103659 | |||
| fb756d5d94 | |||
| bdd15e340b | |||
| f9dbaeeb23 | |||
| d644617d62 | |||
| bbb0bd1447 | |||
| 711edef9cc | |||
| 64dae8970d |
+1
-7
@@ -1,8 +1,2 @@
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
[target.'cfg(target_arch = "x86_64")']
|
||||
rustflags = ["-C", "target-cpu=x86-64-v3"]
|
||||
|
||||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-cpu=x86-64-v3"]
|
||||
|
||||
[target.x86_64-apple-darwin]
|
||||
rustflags = ["-C", "target-cpu=x86-64-v2"]
|
||||
|
||||
+21
-20
@@ -48,23 +48,24 @@ jobs:
|
||||
with:
|
||||
name: gopher64-windows
|
||||
path: target/release/gopher64.exe
|
||||
# build-macos:
|
||||
# runs-on: macos-13
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# with:
|
||||
# submodules: recursive
|
||||
# - name: Install sdl2 headers
|
||||
# run: |
|
||||
# brew install sdl2
|
||||
# - name: Update rust
|
||||
# run: |
|
||||
# rustup update
|
||||
# - name: Build
|
||||
# run: |
|
||||
# cargo build --release -v
|
||||
# - name: Upload file
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: gopher64-mac
|
||||
# path: target/release/gopher64
|
||||
|
||||
build-macos:
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install sdl2 headers
|
||||
run: |
|
||||
brew install sdl2
|
||||
- name: Update rust
|
||||
run: |
|
||||
rustup update
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --release -v
|
||||
- name: Upload file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: gopher64-mac
|
||||
path: target/release/gopher64
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "gopher64"
|
||||
version = "0.1.6"
|
||||
version = "0.1.11"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
@@ -8,21 +8,21 @@ edition = "2021"
|
||||
[dependencies]
|
||||
dirs = "5.0"
|
||||
zip = "2.1"
|
||||
governor = "0.6"
|
||||
governor = "0.8"
|
||||
sevenz-rust = "0.6"
|
||||
chrono = "0.4"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
eframe = "0.27"
|
||||
rfd = "0.14"
|
||||
eframe = "0.30"
|
||||
rfd = "0.15"
|
||||
sha2 = "0.10"
|
||||
rusttype = "0.9"
|
||||
futures = "0.3"
|
||||
sdl2-sys = "0.36"
|
||||
sdl2-sys = "0.37"
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
|
||||
[dependencies.sdl2]
|
||||
version = "0.36"
|
||||
version = "0.37"
|
||||
default-features = false
|
||||
features = ["static-link","bundled"]
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ fn main() {
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
{
|
||||
build.flag("/arch:AVX2");
|
||||
}
|
||||
build.flag("-DVK_USE_PLATFORM_WIN32_KHR");
|
||||
|
||||
winres::WindowsResource::new()
|
||||
@@ -60,6 +64,10 @@ fn main() {
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
{
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
{
|
||||
build.flag("-march=x86-64-v3");
|
||||
}
|
||||
build
|
||||
.flag("-Wno-missing-field-initializers")
|
||||
.flag("-Wno-unused-parameter");
|
||||
|
||||
Submodule parallel-rdp/parallel-rdp-standalone updated: ff3b858dd3...388d70f583
+12
-7
@@ -80,14 +80,16 @@ pub fn dma_read(
|
||||
cart_addr &= CART_MASK as u32;
|
||||
|
||||
for i in 0..length {
|
||||
device.cart.rom[(cart_addr + i) as usize] =
|
||||
device.rdram.mem[(dram_addr + i) as usize ^ device.byte_swap];
|
||||
if cart_addr + i < device.cart.rom.len() as u32 {
|
||||
device.cart.rom[(cart_addr + i) as usize] =
|
||||
device.rdram.mem[(dram_addr + i) as usize ^ device.byte_swap];
|
||||
|
||||
device.ui.saves.romsave.0.insert(
|
||||
(cart_addr + i).to_string(),
|
||||
serde_json::to_value(device.rdram.mem[(dram_addr + i) as usize ^ device.byte_swap])
|
||||
.unwrap(),
|
||||
);
|
||||
device.ui.saves.romsave.0.insert(
|
||||
(cart_addr + i).to_string(),
|
||||
serde_json::to_value(device.rdram.mem[(dram_addr + i) as usize ^ device.byte_swap])
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
device.ui.saves.romsave.1 = true;
|
||||
@@ -127,6 +129,9 @@ pub fn init(device: &mut device::Device, rom_file: Vec<u8>) {
|
||||
device.ui.game_hash = calculate_hash(&device.cart.rom);
|
||||
|
||||
device.ui.game_id = String::from_utf8(device.cart.rom[0x3B..0x3E].to_vec()).unwrap();
|
||||
if device.ui.game_id.contains('\0') {
|
||||
device.ui.game_id = String::from("UNK");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_rom_save(device: &mut device::Device) {
|
||||
|
||||
@@ -165,11 +165,14 @@ pub fn do_dma(device: &mut device::Device, dma: RspDma) {
|
||||
while j < count {
|
||||
let mut i = 0;
|
||||
while i < length {
|
||||
let data = u32::from_ne_bytes(
|
||||
device.rdram.mem[dram_addr as usize..dram_addr as usize + 4]
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
);
|
||||
let mut data = 0;
|
||||
if dram_addr < device::rdram::RDRAM_SIZE as u32 {
|
||||
data = u32::from_ne_bytes(
|
||||
device.rdram.mem[dram_addr as usize..dram_addr as usize + 4]
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
if offset != 0 {
|
||||
// imem being updated
|
||||
device.rsp.cpu.instructions[((mem_addr & 0xFFF) / 4) as usize].func =
|
||||
|
||||
+351
-131
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -141,7 +141,7 @@ pub fn dma_read_sram(
|
||||
|
||||
format_sram(device);
|
||||
|
||||
while i < dram_addr + length {
|
||||
while i < dram_addr + length && i < device::rdram::RDRAM_SIZE as u32 {
|
||||
device.ui.saves.sram.0[j as usize] = device.rdram.mem[i as usize ^ device.byte_swap];
|
||||
i += 1;
|
||||
j += 1;
|
||||
@@ -191,7 +191,7 @@ pub fn dma_write_sram(
|
||||
|
||||
format_sram(device);
|
||||
|
||||
while i < dram_addr + length {
|
||||
while i < dram_addr + length && i < device::rdram::RDRAM_SIZE as u32 {
|
||||
device.rdram.mem[i as usize ^ device.byte_swap] = device.ui.saves.sram.0[j as usize];
|
||||
i += 1;
|
||||
j += 1;
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ fn main() {
|
||||
eframe::run_native(
|
||||
"gopher64",
|
||||
options,
|
||||
Box::new(|_cc| Box::new(ui::gui::GopherEguiApp::new())),
|
||||
Box::new(|_cc| Ok(Box::new(ui::gui::GopherEguiApp::new()))),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ pub struct Ui {
|
||||
pub video_subsystem: Option<sdl2::VideoSubsystem>,
|
||||
pub audio_subsystem: Option<sdl2::AudioSubsystem>,
|
||||
pub joystick_subsystem: Option<sdl2::JoystickSubsystem>,
|
||||
#[allow(dead_code)]
|
||||
pub controller_subsystem: Option<sdl2::GameControllerSubsystem>,
|
||||
pub window: Option<sdl2::video::Window>,
|
||||
pub audio_device: Option<sdl2::audio::AudioQueue<i16>>,
|
||||
|
||||
+5
-3
@@ -129,7 +129,9 @@ impl eframe::App for GopherEguiApp {
|
||||
}
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.set_enabled(!self.configure_profile);
|
||||
if self.configure_profile {
|
||||
ui.disable()
|
||||
}
|
||||
|
||||
if ui.button("Open ROM").clicked() {
|
||||
// Spawn dialog on main thread
|
||||
@@ -177,7 +179,7 @@ impl eframe::App for GopherEguiApp {
|
||||
for i in 0..4 {
|
||||
ui.label(format!("{}", i + 1));
|
||||
|
||||
egui::ComboBox::from_id_source(format!("profile-combo-{}", i))
|
||||
egui::ComboBox::from_id_salt(format!("profile-combo-{}", i))
|
||||
.selected_text(self.selected_profile[i].clone())
|
||||
.show_ui(ui, |ui| {
|
||||
for j in 0..self.input_profiles.len() {
|
||||
@@ -194,7 +196,7 @@ impl eframe::App for GopherEguiApp {
|
||||
} else {
|
||||
self.controllers[self.selected_controller[i] as usize].clone()
|
||||
};
|
||||
egui::ComboBox::from_id_source(format!("controller-combo-{}", i))
|
||||
egui::ComboBox::from_id_salt(format!("controller-combo-{}", i))
|
||||
.selected_text(controller_text)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(
|
||||
|
||||
+51
-17
@@ -87,28 +87,36 @@ pub fn set_axis_from_controller(
|
||||
let mut y = 0.0;
|
||||
if profile.controller_axis[AXIS_LEFT].0 {
|
||||
let axis_position =
|
||||
controller.axis(std::mem::transmute(profile.controller_axis[AXIS_LEFT].1));
|
||||
controller.axis(std::mem::transmute::<i32, sdl2::controller::Axis>(
|
||||
profile.controller_axis[AXIS_LEFT].1,
|
||||
));
|
||||
if axis_position as isize * profile.controller_axis[AXIS_LEFT].2 as isize > 0 {
|
||||
x = axis_position as f64 * MAX_AXIS_VALUE / i16::MAX as f64;
|
||||
}
|
||||
}
|
||||
if profile.controller_axis[AXIS_RIGHT].0 {
|
||||
let axis_position =
|
||||
controller.axis(std::mem::transmute(profile.controller_axis[AXIS_RIGHT].1));
|
||||
controller.axis(std::mem::transmute::<i32, sdl2::controller::Axis>(
|
||||
profile.controller_axis[AXIS_RIGHT].1,
|
||||
));
|
||||
if axis_position as isize * profile.controller_axis[AXIS_RIGHT].2 as isize > 0 {
|
||||
x = axis_position as f64 * MAX_AXIS_VALUE / i16::MAX as f64;
|
||||
}
|
||||
}
|
||||
if profile.controller_axis[AXIS_DOWN].0 {
|
||||
let axis_position =
|
||||
controller.axis(std::mem::transmute(profile.controller_axis[AXIS_DOWN].1));
|
||||
controller.axis(std::mem::transmute::<i32, sdl2::controller::Axis>(
|
||||
profile.controller_axis[AXIS_DOWN].1,
|
||||
));
|
||||
if axis_position as isize * profile.controller_axis[AXIS_DOWN].2 as isize > 0 {
|
||||
y = (axis_position as f64 * MAX_AXIS_VALUE / i16::MAX as f64).neg();
|
||||
}
|
||||
}
|
||||
if profile.controller_axis[AXIS_UP].0 {
|
||||
let axis_position =
|
||||
controller.axis(std::mem::transmute(profile.controller_axis[AXIS_UP].1));
|
||||
controller.axis(std::mem::transmute::<i32, sdl2::controller::Axis>(
|
||||
profile.controller_axis[AXIS_UP].1,
|
||||
));
|
||||
if axis_position as isize * profile.controller_axis[AXIS_UP].2 as isize > 0 {
|
||||
y = (axis_position as f64 * MAX_AXIS_VALUE / i16::MAX as f64).neg();
|
||||
}
|
||||
@@ -125,22 +133,34 @@ pub fn set_axis_from_keys(
|
||||
let mut x = 0.0;
|
||||
let mut y = 0.0;
|
||||
if profile.keys[AXIS_LEFT].0
|
||||
&& keyboard_state.is_scancode_pressed(std::mem::transmute(profile.keys[AXIS_LEFT].1))
|
||||
&& keyboard_state
|
||||
.is_scancode_pressed(std::mem::transmute::<i32, sdl2::keyboard::Scancode>(
|
||||
profile.keys[AXIS_LEFT].1,
|
||||
))
|
||||
{
|
||||
x = -MAX_AXIS_VALUE
|
||||
}
|
||||
if profile.keys[AXIS_RIGHT].0
|
||||
&& keyboard_state.is_scancode_pressed(std::mem::transmute(profile.keys[AXIS_RIGHT].1))
|
||||
&& keyboard_state
|
||||
.is_scancode_pressed(std::mem::transmute::<i32, sdl2::keyboard::Scancode>(
|
||||
profile.keys[AXIS_RIGHT].1,
|
||||
))
|
||||
{
|
||||
x = MAX_AXIS_VALUE
|
||||
}
|
||||
if profile.keys[AXIS_DOWN].0
|
||||
&& keyboard_state.is_scancode_pressed(std::mem::transmute(profile.keys[AXIS_DOWN].1))
|
||||
&& keyboard_state
|
||||
.is_scancode_pressed(std::mem::transmute::<i32, sdl2::keyboard::Scancode>(
|
||||
profile.keys[AXIS_DOWN].1,
|
||||
))
|
||||
{
|
||||
y = -MAX_AXIS_VALUE
|
||||
}
|
||||
if profile.keys[AXIS_UP].0
|
||||
&& keyboard_state.is_scancode_pressed(std::mem::transmute(profile.keys[AXIS_UP].1))
|
||||
&& keyboard_state
|
||||
.is_scancode_pressed(std::mem::transmute::<i32, sdl2::keyboard::Scancode>(
|
||||
profile.keys[AXIS_UP].1,
|
||||
))
|
||||
{
|
||||
y = MAX_AXIS_VALUE
|
||||
}
|
||||
@@ -162,7 +182,9 @@ pub fn set_buttons_from_joystick(
|
||||
let profile_joystick_hat = profile.joystick_hat[i];
|
||||
if profile_joystick_hat.0
|
||||
&& joystick.hat(profile_joystick_hat.1).unwrap()
|
||||
== unsafe { std::mem::transmute(profile_joystick_hat.2) }
|
||||
== unsafe {
|
||||
std::mem::transmute::<i8, sdl2::joystick::HatState>(profile_joystick_hat.2)
|
||||
}
|
||||
{
|
||||
*keys |= 1 << i;
|
||||
}
|
||||
@@ -187,15 +209,20 @@ pub fn set_buttons_from_controller(
|
||||
let profile_controller_button = profile.controller_buttons[i];
|
||||
if profile_controller_button.0 {
|
||||
unsafe {
|
||||
*keys |=
|
||||
(controller.button(std::mem::transmute(profile_controller_button.1)) as u32) << i;
|
||||
*keys |= (controller.button(std::mem::transmute::<i32, sdl2::controller::Button>(
|
||||
profile_controller_button.1,
|
||||
)) as u32)
|
||||
<< i;
|
||||
}
|
||||
}
|
||||
|
||||
let profile_controller_axis = profile.controller_axis[i];
|
||||
if profile_controller_axis.0 {
|
||||
let axis_position =
|
||||
unsafe { controller.axis(std::mem::transmute(profile_controller_axis.1)) };
|
||||
let axis_position = unsafe {
|
||||
controller.axis(std::mem::transmute::<i32, sdl2::controller::Axis>(
|
||||
profile_controller_axis.1,
|
||||
))
|
||||
};
|
||||
if axis_position as isize * profile_controller_axis.2 as isize > 0
|
||||
&& axis_position.saturating_abs() > i16::MAX / 2
|
||||
{
|
||||
@@ -219,8 +246,10 @@ pub fn get(ui: &mut ui::Ui, channel: usize) -> u32 {
|
||||
let profile_key = profile.keys[i];
|
||||
if profile_key.0 {
|
||||
unsafe {
|
||||
keys |= (keyboard_state.is_scancode_pressed(std::mem::transmute(profile_key.1))
|
||||
as u32)
|
||||
keys |= (keyboard_state
|
||||
.is_scancode_pressed(std::mem::transmute::<i32, sdl2::keyboard::Scancode>(
|
||||
profile_key.1,
|
||||
)) as u32)
|
||||
<< i;
|
||||
}
|
||||
}
|
||||
@@ -377,8 +406,13 @@ pub fn configure_input_profile(ui: &mut ui::Ui, profile: String) {
|
||||
key_set = true
|
||||
}
|
||||
sdl2::event::Event::JoyHatMotion { hat_idx, state, .. } => {
|
||||
new_joystick_hat[*value] =
|
||||
unsafe { (true, hat_idx as u32, std::mem::transmute(state)) };
|
||||
new_joystick_hat[*value] = unsafe {
|
||||
(
|
||||
true,
|
||||
hat_idx as u32,
|
||||
std::mem::transmute::<sdl2::joystick::HatState, i8>(state),
|
||||
)
|
||||
};
|
||||
key_set = true
|
||||
}
|
||||
sdl2::event::Event::JoyAxisMotion {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
use crate::ui;
|
||||
|
||||
extern "C" {
|
||||
unsafe extern "C" {
|
||||
pub fn vk_init(rdram_ptr: usize, rdram_size: u32, fullscreen: u8);
|
||||
pub fn set_sdl_window(window: usize);
|
||||
pub fn rdp_update_screen() -> u8;
|
||||
|
||||
Reference in New Issue
Block a user