standardize file size

This commit is contained in:
Logan McNaughton
2023-10-11 13:16:00 -06:00
parent 0f0565b8b7
commit fe2c7752ea
2 changed files with 15 additions and 28 deletions
+5 -12
View File
@@ -10,6 +10,7 @@ pub const JCMD_RESET: u8 = 0xff;
pub const JDT_EEPROM_4K: u16 = 0x8000; /* 4k EEPROM */
pub const JDT_EEPROM_16K: u16 = 0xc000; /* 16k EEPROM */
pub const EEPROM_BLOCK_SIZE: usize = 8;
pub const EEPROM_MAX_SIZE: usize = 0x800;
pub fn process(device: &mut device::Device, channel: usize) {
let cmd = device.pif.ram[device.pif.channels[channel].tx_buf.unwrap()];
@@ -62,12 +63,8 @@ pub fn process(device: &mut device::Device, channel: usize) {
pub fn eeprom_read_block(device: &mut device::Device, block: usize, offset: usize) {
let address = device.pif.ram[block as usize] as usize * EEPROM_BLOCK_SIZE;
if address + EEPROM_BLOCK_SIZE > device.ui.saves.eeprom.len() {
device
.ui
.saves
.eeprom
.resize(address + EEPROM_BLOCK_SIZE, 0xFF)
if device.ui.saves.eeprom.len() < EEPROM_MAX_SIZE {
device.ui.saves.eeprom.resize(EEPROM_MAX_SIZE, 0xFF)
}
device.pif.ram[offset..offset + EEPROM_BLOCK_SIZE]
@@ -77,12 +74,8 @@ pub fn eeprom_read_block(device: &mut device::Device, block: usize, offset: usiz
pub fn eeprom_write_block(device: &mut device::Device, block: usize, offset: usize, status: usize) {
let address = device.pif.ram[block as usize] as usize * EEPROM_BLOCK_SIZE;
if address + EEPROM_BLOCK_SIZE > device.ui.saves.eeprom.len() {
device
.ui
.saves
.eeprom
.resize(address + EEPROM_BLOCK_SIZE, 0xFF)
if device.ui.saves.eeprom.len() < EEPROM_MAX_SIZE {
device.ui.saves.eeprom.resize(EEPROM_MAX_SIZE, 0xFF)
}
device.ui.saves.eeprom[address..address + EEPROM_BLOCK_SIZE]
+10 -16
View File
@@ -2,6 +2,8 @@ use crate::device;
use crate::ui;
pub const SRAM_MASK: usize = 0xFFFF;
pub const SRAM_SIZE: usize = 0x8000;
//pub const FLASHRAM_SIZE: usize = 0x20000;
pub fn read_mem(
device: &mut device::Device,
@@ -14,8 +16,8 @@ pub fn read_mem(
if device.ui.save_type.contains(&ui::storage::SaveTypes::Sram) {
let masked_address = address as usize & SRAM_MASK;
if masked_address + 4 > device.ui.saves.sram.len() {
device.ui.saves.sram.resize(masked_address + 4, 0xFF)
if device.ui.saves.sram.len() < SRAM_SIZE {
device.ui.saves.sram.resize(SRAM_SIZE, 0xFF)
}
return u32::from_be_bytes(
@@ -32,8 +34,8 @@ pub fn write_mem(device: &mut device::Device, address: u64, value: u32, mask: u3
if device.ui.save_type.contains(&ui::storage::SaveTypes::Sram) {
let masked_address = address as usize & SRAM_MASK;
if masked_address + 4 > device.ui.saves.sram.len() {
device.ui.saves.sram.resize(masked_address + 4, 0xFF)
if device.ui.saves.sram.len() < SRAM_SIZE {
device.ui.saves.sram.resize(SRAM_SIZE, 0xFF)
}
let mut data = u32::from_be_bytes(
@@ -74,12 +76,8 @@ pub fn dma_read(
let mut i = dram_addr;
let mut j = cart_addr;
if (cart_addr + length) as usize > device.ui.saves.sram.len() {
device
.ui
.saves
.sram
.resize((cart_addr + length) as usize, 0xFF)
if device.ui.saves.sram.len() < SRAM_SIZE {
device.ui.saves.sram.resize(SRAM_SIZE, 0xFF)
}
while i < dram_addr + length {
@@ -108,12 +106,8 @@ pub fn dma_write(
let mut i = dram_addr;
let mut j = cart_addr;
if (cart_addr + length) as usize > device.ui.saves.sram.len() {
device
.ui
.saves
.sram
.resize((cart_addr + length) as usize, 0xFF)
if device.ui.saves.sram.len() < SRAM_SIZE {
device.ui.saves.sram.resize(SRAM_SIZE, 0xFF)
}
while i < dram_addr + length {