update formatting

This commit is contained in:
Alex Janka 2023-12-10 11:17:00 +11:00
parent 6f23ed0377
commit 55af282e7e
10 changed files with 89 additions and 90 deletions

View file

@ -55,7 +55,6 @@ impl Default for StandaloneConfig {
}
}
#[allow(dead_code)]
struct Configs {
standalone_config: StandaloneConfig,
emu_config: gb_emu_lib::config::Config,
@ -132,13 +131,12 @@ pub fn prepare(
let will_be_cgb = rom.rom_type == CgbRomType::CgbOnly || config.prefer_cgb;
let shader_path =
if will_be_cgb {
config.vulkan_config.cgb_shader_path.as_ref()
} else {
config.vulkan_config.dmg_shader_path.as_ref()
}
.map(|v| CONFIG_MANAGER.dir().join(v));
let shader_path = if will_be_cgb {
config.vulkan_config.cgb_shader_path.as_ref()
} else {
config.vulkan_config.dmg_shader_path.as_ref()
}
.map(|v| CONFIG_MANAGER.dir().join(v));
let resizable = shader_path.is_some()
&& if will_be_cgb {

View file

@ -117,15 +117,14 @@ impl WinitWindowManagerData {
is_main: bool,
record: bool,
) -> RendererChannel {
let (r, sender) =
WindowRenderer::new(
factor,
event_loop,
self.window_data_manager.clone(),
shader_path,
resizable,
record,
);
let (r, sender) = WindowRenderer::new(
factor,
event_loop,
self.window_data_manager.clone(),
shader_path,
resizable,
record,
);
let id = r.window.id();
self.windows.insert(id, r);
if is_main {
@ -143,13 +142,12 @@ impl WinitWindowManagerData {
.as_ref()
.and_then(|id| self.windows.get(id))
{
let image =
ImageBuffer::<image::Rgba<u8>, _>::from_raw(
window.width as u32,
window.height as u32,
bytemuck::cast_slice(&window.queued_buf.buf),
)
.unwrap();
let image = ImageBuffer::<image::Rgba<u8>, _>::from_raw(
window.width as u32,
window.height as u32,
bytemuck::cast_slice(&window.queued_buf.buf),
)
.unwrap();
let configs = access_config();
let screenshot_dir = if configs.standalone_config.group_screenshots_by_rom {
configs
@ -162,13 +160,12 @@ impl WinitWindowManagerData {
std::fs::create_dir_all(&screenshot_dir)
.expect("could not create screenshot directory!");
let screenshot_path =
screenshot_dir.join(format!(
"{} - {}.png",
chrono::DateTime::<chrono::Local>::from(std::time::SystemTime::now())
.to_rfc3339(),
configs.rom_title,
));
let screenshot_path = screenshot_dir.join(format!(
"{} - {}.png",
chrono::DateTime::<chrono::Local>::from(std::time::SystemTime::now())
.to_rfc3339(),
configs.rom_title,
));
image
.save(screenshot_path)
.expect("Could not save screenshot!");

View file

@ -104,33 +104,32 @@ impl Plugin for GameboyEmu {
const VERSION: &'static str = "0.1";
const AUDIO_IO_LAYOUTS: &'static [AudioIOLayout] =
&[
AudioIOLayout {
main_input_channels: None,
main_output_channels: NonZeroU32::new(2),
const AUDIO_IO_LAYOUTS: &'static [AudioIOLayout] = &[
AudioIOLayout {
main_input_channels: None,
main_output_channels: NonZeroU32::new(2),
aux_input_ports: &[],
aux_output_ports: &[],
aux_input_ports: &[],
aux_output_ports: &[],
// Individual ports and the layout as a whole can be named here. By default these names
// are generated as needed. This layout will be called 'Stereo', while the other one is
// given the name 'Mono' based no the number of input and output channels.
names: PortNames::const_default(),
},
AudioIOLayout {
main_input_channels: None,
main_output_channels: NonZeroU32::new(1),
// Individual ports and the layout as a whole can be named here. By default these names
// are generated as needed. This layout will be called 'Stereo', while the other one is
// given the name 'Mono' based no the number of input and output channels.
names: PortNames::const_default(),
},
AudioIOLayout {
main_input_channels: None,
main_output_channels: NonZeroU32::new(1),
aux_input_ports: &[],
aux_output_ports: &[],
aux_input_ports: &[],
aux_output_ports: &[],
// Individual ports and the layout as a whole can be named here. By default these names
// are generated as needed. This layout will be called 'Stereo', while the other one is
// given the name 'Mono' based no the number of input and output channels.
names: PortNames::const_default(),
},
];
// Individual ports and the layout as a whole can be named here. By default these names
// are generated as needed. This layout will be called 'Stereo', while the other one is
// given the name 'Mono' based no the number of input and output channels.
names: PortNames::const_default(),
},
];
const MIDI_INPUT: MidiConfig = MidiConfig::MidiCCs;
const SAMPLE_ACCURATE_AUTOMATION: bool = true;

View file

@ -59,13 +59,13 @@ where
let is_cgb_mode = rom.rom_type == CgbRomType::CgbOnly || options.cgb_mode;
let bootrom = if is_cgb_mode {
options.cgb_bootrom.unwrap_or(
RomFile::Raw(include_bytes!("../../sameboy-bootroms/cgb_boot.bin").to_vec())
)
options.cgb_bootrom.unwrap_or(RomFile::Raw(
include_bytes!("../../sameboy-bootroms/cgb_boot.bin").to_vec(),
))
} else {
options.dmg_bootrom.unwrap_or(
RomFile::Raw(include_bytes!("../../sameboy-bootroms/dmg_boot.bin").to_vec())
)
options.dmg_bootrom.unwrap_or(RomFile::Raw(
include_bytes!("../../sameboy-bootroms/dmg_boot.bin").to_vec(),
))
}
.load_data()
.expect("Error loading bootrom!");

View file

@ -290,13 +290,11 @@ where
fn get_io(&self, address: IoAddress) -> u8 {
match address {
IoAddress::Joypad => self.joypad.as_register(),
IoAddress::Serial(address) => {
match address.inner() {
0xFF01 => self.serial.get_queued(),
0xFF02 => self.serial.get_control(),
_ => unreachable!(),
}
}
IoAddress::Serial(address) => match address.inner() {
0xFF01 => self.serial.get_queued(),
0xFF02 => self.serial.get_control(),
_ => unreachable!(),
},
IoAddress::Timer(address) => match address.inner() {
0xFF04 => self.timers.get_div(),
0xFF05 => self.timers.get_tima(),

View file

@ -363,12 +363,11 @@ where
.get_addr(object.tile_index + if object_row >= 8 { 1 } else { 0 })
+ (tile_row as u16 * 2))
.unwrap();
let bank =
if self.is_cgb_mode() {
object.flags.cgb_vram_bank
} else {
VramBank::Bank0
};
let bank = if self.is_cgb_mode() {
object.flags.cgb_vram_bank
} else {
VramBank::Bank0
};
let lsbs = self.vram.get_with_bank(tile_addr, bank).unwrap();
let msbs = self
.vram
@ -480,12 +479,11 @@ where
.get_with_bank((tile_addr + 1).unwrap(), attributes.tile_bank)
.unwrap();
let tile_px_x =
if attributes.flip_h {
7 - (tile_line_x % 8)
} else {
tile_line_x % 8
};
let tile_px_x = if attributes.flip_h {
7 - (tile_line_x % 8)
} else {
tile_line_x % 8
};
let lsb = get_bit(lsbs, 7 - tile_px_x);
let msb = get_bit(msbs, 7 - tile_px_x);
let (colour, is_zero) = if self.is_cgb_mode() {

View file

@ -56,12 +56,11 @@ where
) -> Option<Self> {
if self.currently_cgb != is_cgb_mode {
self.currently_cgb = is_cgb_mode;
let current_width =
if is_cgb_mode {
TILE_WINDOW_WIDTH * 2
} else {
TILE_WINDOW_WIDTH
};
let current_width = if is_cgb_mode {
TILE_WINDOW_WIDTH * 2
} else {
TILE_WINDOW_WIDTH
};
self.sender
.send(RendererMessage::Resize {
width: current_width,

View file

@ -80,7 +80,9 @@ impl Mbc for Mbc1 {
}
fn get_ram(&self, address: CartRamAddress) -> u8 {
if self.ram_enabled && let Some(ram) = &self.ram {
if self.ram_enabled
&& let Some(ram) = &self.ram
{
let addr = self.get_ram_addr(address) % ram.len();
return ram.get(addr);
}
@ -89,7 +91,9 @@ impl Mbc for Mbc1 {
fn set_ram(&mut self, address: CartRamAddress, data: u8) {
let mut addr = self.get_ram_addr(address);
if self.ram_enabled && let Some(ram) = &mut self.ram {
if self.ram_enabled
&& let Some(ram) = &mut self.ram
{
addr %= ram.len();
ram.set(addr, data);
}

View file

@ -63,7 +63,9 @@ impl Mbc for Mbc5 {
}
fn get_ram(&self, address: CartRamAddress) -> u8 {
if self.ram_enabled && let Some(ram) = &self.ram {
if self.ram_enabled
&& let Some(ram) = &self.ram
{
ram.get(self.get_ram_addr(address))
} else {
0xFF
@ -92,7 +94,9 @@ impl Mbc for Mbc5 {
fn set_ram(&mut self, address: CartRamAddress, data: u8) {
let real_addr = self.get_ram_addr(address);
if self.ram_enabled && let Some(ram) = &mut self.ram {
if self.ram_enabled
&& let Some(ram) = &mut self.ram
{
ram.set(real_addr, data);
}
}

View file

@ -158,7 +158,9 @@ where
match self.ram_bank {
RamBank::Ram(bank) => {
let real_addr = self.get_ram_addr(address, bank);
if self.ram_enabled && let Some(ram) = &mut self.ram {
if self.ram_enabled
&& let Some(ram) = &mut self.ram
{
ram.set(real_addr, data);
}
}