A GameCube/Wii emulator and debugger written in Rust.
more di. fixes pokepark boot
Laylefb2900ec853c
diff --git a/crates/gecko/src/flipper/gx.rs b/crates/gecko/src/flipper/gx.rsindex b13cf53..59cede8 100644--- a/crates/gecko/src/flipper/gx.rs+++ b/crates/gecko/src/flipper/gx.rs@@ -230,7 +230,7 @@ pub fn present_xfb<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {if delta_bytes >= xfb_bytes {continue;}-+let delta_pixels = (delta_bytes / 2) as u32;let offset_x = delta_pixels % stride_in_pixels;let offset_y = delta_pixels / stride_in_pixels;@@ -263,7 +263,11 @@ pub fn present_xfb<const SYSTEM: SystemId>(sys: &mut System<SYSTEM>) {let parts = if frame_base != 0 {let mut p = build_parts(frame_base);if p.is_empty() {- p.push(XfbPart { id: frame_base, offset_x: 0, offset_y: 0 });+ p.push(XfbPart {+ id: frame_base,+ offset_x: 0,+ offset_y: 0,+ });}p} else {diff --git a/crates/gecko/src/hollywood/ipc/di.rs b/crates/gecko/src/hollywood/ipc/di.rsindex a6ec5d7..e11f8e4 100644--- a/crates/gecko/src/hollywood/ipc/di.rs+++ b/crates/gecko/src/hollywood/ipc/di.rs@@ -4,14 +4,18 @@ use zerocopy::byteorder::big_endian::U32;use zerocopy::{FromBytes, Immutable, KnownLayout};pub const IOCTL_DVD_LOW_READ: u32 = 0x71;+pub const IOCTL_DVD_LOW_GET_COVER_REGISTER: u32 = 0x7A;pub const IOCTL_DVD_LOW_CLEAR_COVER_INTERRUPT: u32 = 0x86;pub const IOCTL_DVD_LOW_UNENCRYPTED_READ: u32 = 0x8D;+pub const IOCTL_DVD_LOW_GET_STATUS_REGISTER: u32 = 0x95;+pub const IOCTL_DVD_LOW_GET_CONTROL_REGISTER: u32 = 0x96;pub const IOCTL_DVD_LOW_REPORT_KEY: u32 = 0xA4;pub const IOCTL_DVD_LOW_REQUEST_ERROR: u32 = 0xE0;+pub const IOCTL_DVD_LOW_STOP_MOTOR: u32 = 0xE3;const DI_RET_OK: i32 = 1;const DI_RET_ERROR: i32 = 2;-const DI_RET_INVALID_RANGE: i32 = 0x20;+const DI_RET_SECURITY_ERROR: i32 = 0x20;const DI_RET_BAD_ALIGNMENT: i32 = 0x80;const DI_ERROR_OK: u32 = 0x00000000;@@ -46,6 +50,10 @@ impl IosDevice for DiskInterface {IOCTL_DVD_LOW_REPORT_KEY => self.dvd_low_report_key(ctx, in_ptr, out_ptr, out_len),IOCTL_DVD_LOW_CLEAR_COVER_INTERRUPT => self.dvd_low_clear_cover_interrupt(ctx, in_ptr, out_ptr, out_len),IOCTL_DVD_LOW_READ => self.dvd_low_read(ctx, in_ptr, out_ptr, out_len),+ IOCTL_DVD_LOW_GET_STATUS_REGISTER => self.dvd_low_get_status_register(ctx, out_ptr, out_len),+ IOCTL_DVD_LOW_GET_COVER_REGISTER => self.dvd_low_get_cover_register(ctx, out_ptr, out_len),+ IOCTL_DVD_LOW_GET_CONTROL_REGISTER => self.dvd_low_get_control_register(ctx, out_ptr, out_len),+ IOCTL_DVD_LOW_STOP_MOTOR => self.dvd_low_stop_motor(ctx, in_ptr, out_ptr, out_len),_ => {tracing::warn!(cmd = format!("{cmd:08X}"),@@ -87,7 +95,7 @@ impl DiskInterface {.iter().position(|r| pos_bytes >= r.start && end_bytes <= r.end);let Some(range_idx) = range_idx else {- return DI_RET_INVALID_RANGE;+ return DI_RET_SECURITY_ERROR;};if range_idx == 0 {@@ -175,7 +183,7 @@ impl DiskInterface {let pos_bytes = input.position_bytes();if out_len < size {- return DI_RET_INVALID_RANGE;+ return DI_RET_SECURITY_ERROR;}let Some(dvd) = ctx.di.dvd.as_ref() else {@@ -198,6 +206,45 @@ impl DiskInterface {DI_RET_OK}++ #[inline(always)]+ fn dvd_low_get_status_register(&mut self, ctx: &mut DeviceContext<'_>, out_ptr: u32, out_len: u32) -> i32 {+ let value = ctx.di.status.raw();+ self::write_if_fits(ctx, out_ptr, out_len, value)+ }++ #[inline(always)]+ fn dvd_low_get_cover_register(&mut self, ctx: &mut DeviceContext<'_>, out_ptr: u32, out_len: u32) -> i32 {+ let value = ctx.di.cover.raw();+ self::write_if_fits(ctx, out_ptr, out_len, value)+ }++ #[inline(always)]+ fn dvd_low_get_control_register(&mut self, ctx: &mut DeviceContext<'_>, out_ptr: u32, out_len: u32) -> i32 {+ let value = ctx.di.control.raw();+ self::write_if_fits(ctx, out_ptr, out_len, value)+ }++ #[inline(always)]+ fn dvd_low_stop_motor(&mut self, ctx: &mut DeviceContext<'_>, in_ptr: u32, out_ptr: u32, out_len: u32) -> i32 {+ let input = ctx.mmio.phys_read_struct::<DvdLowStopMotor>(in_ptr);+ tracing::debug!(eject = input.eject, kill = input.kill, "DVDLowStopMotor");++ if out_len >= 4 {+ ctx.mmio.phys_write_u32(out_ptr, ctx.di.immbuf);+ }++ DI_RET_OK+ }+}++#[inline(always)]+fn write_if_fits(ctx: &mut DeviceContext<'_>, out_ptr: u32, out_len: u32, value: u32) -> i32 {+ if out_len < 4 {+ return DI_RET_SECURITY_ERROR;+ }+ ctx.mmio.phys_write_u32(out_ptr, value);+ DI_RET_OK}#[repr(C, packed)]@@ -224,6 +271,16 @@ struct DvdLowReportKey {pub param2: U32,}+#[repr(C, packed)]+#[derive(FromBytes, KnownLayout, Immutable)]+struct DvdLowStopMotor {+ pub cmd: u8,+ _pad0: [u8; 6],+ pub eject: u8,+ _pad1: [u8; 3],+ pub kill: u8,+}+#[repr(C, packed)]#[derive(FromBytes, KnownLayout, Immutable)]struct DvdLowRead {