Compare commits
9
Commits
5c0f4c2df4
...
v0.7.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c52c33ce67 | ||
|
|
7ecb248407 | ||
|
|
fdd71f582b | ||
|
|
83b567cfd4 | ||
|
|
6687b1f12f | ||
|
|
af2df78809 | ||
|
|
89dfeeeb2d | ||
|
|
d4844a303a | ||
|
|
74ce44db8b |
Generated
+171
-170
File diff suppressed because it is too large
Load Diff
+2
-4
@@ -4,7 +4,7 @@ description = "An emulator for the Virtual Boy."
|
|||||||
repository = "https://git.virtual-boy.com/PVB/lemur"
|
repository = "https://git.virtual-boy.com/PVB/lemur"
|
||||||
publish = false
|
publish = false
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
version = "0.7.1"
|
version = "0.7.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -30,6 +30,7 @@ num-derive = "0.4"
|
|||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
oneshot = "0.1"
|
oneshot = "0.1"
|
||||||
pollster = "0.4"
|
pollster = "0.4"
|
||||||
|
rand = "0.9"
|
||||||
rfd = { version = "0.15", default-features = false, features = ["xdg-portal", "async-std"]}
|
rfd = { version = "0.15", default-features = false, features = ["xdg-portal", "async-std"]}
|
||||||
rtrb = "0.3"
|
rtrb = "0.3"
|
||||||
rubato = "0.16"
|
rubato = "0.16"
|
||||||
@@ -57,6 +58,3 @@ name = "Lemur"
|
|||||||
identifier = "com.virtual-boy.Lemur"
|
identifier = "com.virtual-boy.Lemur"
|
||||||
icon = ["assets/lemur-256x256.png"]
|
icon = ["assets/lemur-256x256.png"]
|
||||||
category = "games"
|
category = "games"
|
||||||
|
|
||||||
#[patch.crates-io]
|
|
||||||
#egui = "0.32"
|
|
||||||
+1
-1
Submodule shrooms-vb-core updated: ecbd103917...fe9c5c4781
+6
-44
@@ -1,8 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
fs::{self, File},
|
|
||||||
io::{Read, Seek, SeekFrom, Write},
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::{
|
sync::{
|
||||||
Arc, Weak,
|
Arc, Weak,
|
||||||
@@ -20,6 +18,7 @@ use tracing::{error, warn};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
audio::Audio,
|
audio::Audio,
|
||||||
|
emulator::cart::Cart,
|
||||||
graphics::TextureSink,
|
graphics::TextureSink,
|
||||||
memory::{MemoryRange, MemoryRegion},
|
memory::{MemoryRange, MemoryRegion},
|
||||||
};
|
};
|
||||||
@@ -27,6 +26,7 @@ use shrooms_vb_core::{EXPECTED_FRAME_SIZE, Sim, StopReason};
|
|||||||
pub use shrooms_vb_core::{VBKey, VBRegister, VBWatchpointType};
|
pub use shrooms_vb_core::{VBKey, VBRegister, VBWatchpointType};
|
||||||
|
|
||||||
mod address_set;
|
mod address_set;
|
||||||
|
mod cart;
|
||||||
mod shrooms_vb_core;
|
mod shrooms_vb_core;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||||
@@ -61,43 +61,6 @@ impl Display for SimId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Cart {
|
|
||||||
rom_path: PathBuf,
|
|
||||||
rom: Vec<u8>,
|
|
||||||
sram_file: File,
|
|
||||||
sram: Vec<u8>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Cart {
|
|
||||||
fn load(rom_path: &Path, sim_id: SimId) -> Result<Self> {
|
|
||||||
let rom = fs::read(rom_path)?;
|
|
||||||
|
|
||||||
let mut sram_file = File::options()
|
|
||||||
.read(true)
|
|
||||||
.write(true)
|
|
||||||
.create(true)
|
|
||||||
.truncate(false)
|
|
||||||
.open(sram_path(rom_path, sim_id))?;
|
|
||||||
sram_file.set_len(8 * 1024)?;
|
|
||||||
|
|
||||||
let mut sram = vec![];
|
|
||||||
sram_file.read_to_end(&mut sram)?;
|
|
||||||
Ok(Cart {
|
|
||||||
rom_path: rom_path.to_path_buf(),
|
|
||||||
rom,
|
|
||||||
sram_file,
|
|
||||||
sram,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sram_path(rom_path: &Path, sim_id: SimId) -> PathBuf {
|
|
||||||
match sim_id {
|
|
||||||
SimId::Player1 => rom_path.with_extension("p1.sram"),
|
|
||||||
SimId::Player2 => rom_path.with_extension("p2.sram"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct EmulatorBuilder {
|
pub struct EmulatorBuilder {
|
||||||
rom: Option<PathBuf>,
|
rom: Option<PathBuf>,
|
||||||
commands: mpsc::Receiver<EmulatorCommand>,
|
commands: mpsc::Receiver<EmulatorCommand>,
|
||||||
@@ -219,12 +182,12 @@ impl Emulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_second_sim(&mut self, rom: Option<PathBuf>) -> Result<()> {
|
pub fn start_second_sim(&mut self, rom: Option<PathBuf>) -> Result<()> {
|
||||||
let rom_path = if let Some(path) = rom {
|
let file_path = if let Some(path) = rom {
|
||||||
Some(path)
|
Some(path)
|
||||||
} else {
|
} else {
|
||||||
self.carts[0].as_ref().map(|c| c.rom_path.clone())
|
self.carts[0].as_ref().map(|c| c.file_path.clone())
|
||||||
};
|
};
|
||||||
let cart = match rom_path {
|
let cart = match file_path {
|
||||||
Some(rom_path) => Some(Cart::load(&rom_path, SimId::Player2)?),
|
Some(rom_path) => Some(Cart::load(&rom_path, SimId::Player2)?),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
@@ -337,8 +300,7 @@ impl Emulator {
|
|||||||
let cart = self.carts[sim_id.to_index()].as_mut();
|
let cart = self.carts[sim_id.to_index()].as_mut();
|
||||||
if let (Some(sim), Some(cart)) = (sim, cart) {
|
if let (Some(sim), Some(cart)) = (sim, cart) {
|
||||||
sim.read_sram(&mut cart.sram);
|
sim.read_sram(&mut cart.sram);
|
||||||
cart.sram_file.seek(SeekFrom::Start(0))?;
|
cart.save_sram()?;
|
||||||
cart.sram_file.write_all(&cart.sram)?;
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
use anyhow::Result;
|
||||||
|
use rand::Rng;
|
||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
io::{Read, Seek as _, SeekFrom, Write as _},
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::emulator::SimId;
|
||||||
|
|
||||||
|
pub struct Cart {
|
||||||
|
pub file_path: PathBuf,
|
||||||
|
pub rom: Vec<u8>,
|
||||||
|
sram_file: File,
|
||||||
|
pub sram: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cart {
|
||||||
|
pub fn load(file_path: &Path, sim_id: SimId) -> Result<Self> {
|
||||||
|
let rom = fs::read(file_path)?;
|
||||||
|
|
||||||
|
let mut sram_file = File::options()
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(false)
|
||||||
|
.open(sram_path(file_path, sim_id))?;
|
||||||
|
|
||||||
|
let sram = if sram_file.metadata()?.len() == 0 {
|
||||||
|
// new SRAM file, randomize the contents
|
||||||
|
let mut sram = vec![0; 16 * 1024];
|
||||||
|
let mut rng = rand::rng();
|
||||||
|
for dst in sram.iter_mut().step_by(2) {
|
||||||
|
*dst = rng.random();
|
||||||
|
}
|
||||||
|
sram
|
||||||
|
} else {
|
||||||
|
let mut sram = Vec::with_capacity(16 * 1024);
|
||||||
|
sram_file.read_to_end(&mut sram)?;
|
||||||
|
sram
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Cart {
|
||||||
|
file_path: file_path.to_path_buf(),
|
||||||
|
rom,
|
||||||
|
sram_file,
|
||||||
|
sram,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save_sram(&mut self) -> Result<()> {
|
||||||
|
self.sram_file.seek(SeekFrom::Start(0))?;
|
||||||
|
self.sram_file.write_all(&self.sram)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sram_path(file_path: &Path, sim_id: SimId) -> PathBuf {
|
||||||
|
match sim_id {
|
||||||
|
SimId::Player1 => file_path.with_extension("p1.sram"),
|
||||||
|
SimId::Player2 => file_path.with_extension("p2.sram"),
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-4
@@ -301,11 +301,11 @@ impl<T: Number> Widget for NumberEdit<'_, T> {
|
|||||||
|
|
||||||
let mut delta = None;
|
let mut delta = None;
|
||||||
if self.arrows {
|
if self.arrows {
|
||||||
let arrow_left = res.rect.max.x + 4.0;
|
let arrow_left = res.rect.max.x - 16.0;
|
||||||
let arrow_right = res.rect.max.x + 20.0;
|
let arrow_right = res.rect.max.x;
|
||||||
let arrow_top = res.rect.min.y - 2.0;
|
let arrow_top = res.rect.min.y;
|
||||||
let arrow_middle = (res.rect.min.y + res.rect.max.y) / 2.0;
|
let arrow_middle = (res.rect.min.y + res.rect.max.y) / 2.0;
|
||||||
let arrow_bottom = res.rect.max.y + 2.0;
|
let arrow_bottom = res.rect.max.y;
|
||||||
|
|
||||||
let top_arrow_rect = Rect {
|
let top_arrow_rect = Rect {
|
||||||
min: (arrow_left, arrow_top).into(),
|
min: (arrow_left, arrow_top).into(),
|
||||||
|
|||||||
Reference in New Issue
Block a user