diff --git a/src/device/sram.rs b/src/device/sram.rs index 9e54611..155ae4c 100644 --- a/src/device/sram.rs +++ b/src/device/sram.rs @@ -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;