Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b62046045d |
Generated
+517
-173
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -4,7 +4,7 @@ description = "An emulator for the Virtual Boy."
|
||||
repository = "https://git.virtual-boy.com/PVB/lemur"
|
||||
publish = false
|
||||
license = "MIT"
|
||||
version = "0.7.3"
|
||||
version = "0.7.1"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
@@ -36,12 +36,14 @@ rtrb = "0.3"
|
||||
rubato = "0.16"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
sha2 = "0.10"
|
||||
thread-priority = "2"
|
||||
tokio = { version = "1", features = ["io-util", "macros", "net", "rt", "sync", "time"] }
|
||||
tracing = { version = "0.1", features = ["release_max_level_info"] }
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
wgpu = "25"
|
||||
winit = { version = "0.30", features = ["serde"] }
|
||||
zip = "4"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows = { version = "0.61", features = ["Win32_System_Threading"] }
|
||||
|
||||
+10
-26
@@ -1,39 +1,24 @@
|
||||
# This Dockerfile produces a base image for builds.
|
||||
# It includes all dependencies necessary to cross-compile for Windows/MacOS/Linux.
|
||||
|
||||
FROM debian:bookworm AS osxcross
|
||||
ADD --chmod=644 "https://apt.llvm.org/llvm-snapshot.gpg.key" /etc/apt/trusted.gpg.d/apt.llvm.org.asc
|
||||
WORKDIR /build/osxcross
|
||||
ADD "https://github.com/tpoechtrager/osxcross.git#47936a512273bb3b414b5a2e83043c92eabc7ae7" .
|
||||
ADD "https://github.com/joseluisq/macosx-sdks/releases/download/14.5/MacOSX14.5.sdk.tar.xz" ./tarballs/MacOSX14.5.sdk.tar.xz
|
||||
RUN apt-get update && \
|
||||
apt-get install -y ca-certificates
|
||||
COPY llvm.sources /etc/apt/sources.list.d/llvm.sources
|
||||
RUN apt-get update && \
|
||||
apt-get install -y bash bzip2 clang-20 git lld-20 llvm-20 make patch xz-utils && \
|
||||
ln -s $(which clang-20) /usr/bin/clang && \
|
||||
ln -s $(which clang++-20) /usr/bin/clang++ && \
|
||||
ln -s $(which ld64.lld-20) /usr/bin/ld64.lld && \
|
||||
SDK_VERSION=14.5 UNATTENDED=1 ENABLE_COMPILER_RT_INSTALL=1 TARGET_DIR=/osxcross ./build.sh
|
||||
FROM crazymax/osxcross:latest-ubuntu AS osxcross
|
||||
|
||||
FROM rust:1.89-bookworm
|
||||
ADD --chmod=644 "https://apt.llvm.org/llvm-snapshot.gpg.key" /etc/apt/trusted.gpg.d/apt.llvm.org.asc
|
||||
COPY llvm.sources /etc/apt/sources.list.d/llvm.sources
|
||||
FROM rust:latest
|
||||
RUN rustup target add x86_64-pc-windows-msvc && \
|
||||
rustup target add x86_64-apple-darwin && \
|
||||
rustup target add aarch64-apple-darwin && \
|
||||
apt-get update && \
|
||||
apt-get install -y clang-20 lld-20 libc6-dev libasound2-dev libudev-dev genisoimage mingw-w64 && \
|
||||
apt-get install -y clang-19 lld-19 libc6-dev libasound2-dev libudev-dev genisoimage mingw-w64 && \
|
||||
cargo install cargo-bundle xwin && \
|
||||
xwin --accept-license splat --output xwin && \
|
||||
rm -rf .xwin-cache && \
|
||||
ln -s $(which clang-20) /usr/bin/clang && \
|
||||
ln -s $(which clang++-20) /usr/bin/clang++
|
||||
ln -s $(which clang-19) /usr/bin/clang && \
|
||||
ln -s $(which clang++-19) /usr/bin/clang++
|
||||
COPY --from=osxcross /osxcross /osxcross
|
||||
|
||||
ENV PATH="/osxcross/bin:$PATH" \
|
||||
LD_LIBRARY_PATH="/osxcross/lib" \
|
||||
CC="clang-20" CXX="clang++-20" AR="llvm-ar-20" \
|
||||
CC="clang-19" CXX="clang++-19" AR="llvm-ar-19" \
|
||||
CC_x86_64-apple-darwin="o64-clang" \
|
||||
CXX_x86_64-apple-darwin="o64-clang++" \
|
||||
CC_aarch64-apple-darwin="oa64-clang" \
|
||||
@@ -42,11 +27,10 @@ ENV PATH="/osxcross/bin:$PATH" \
|
||||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld" \
|
||||
SHROOMS_CFLAGS_x86_64-pc-windows-msvc="-flto" \
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS="-Lnative=/xwin/crt/lib/x86_64 -Lnative=/xwin/sdk/lib/um/x86_64 -Lnative=/xwin/sdk/lib/ucrt/x86_64 -Clinker-plugin-lto -Clink-arg=-fuse-ld=lld" \
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER="lld-link-20" \
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER="lld-link-19" \
|
||||
CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER="o64-clang" \
|
||||
CARGO_TARGET_X86_64_APPLE_DARWIN_AR="llvm-ar-20" \
|
||||
CARGO_TARGET_X86_64_APPLE_DARWIN_AR="llvm-ar-19" \
|
||||
CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER="oa64-clang" \
|
||||
CARGO_TARGET_AARCH64_APPLE_DARWIN_AR="llvm-ar-20" \
|
||||
RC_PATH="llvm-rc-20" \
|
||||
CARGO_TARGET_AARCH64_APPLE_DARWIN_AR="llvm-ar-19" \
|
||||
RC_PATH="llvm-rc-19" \
|
||||
MACOSX_DEPLOYMENT_TARGET="14.5"
|
||||
ENTRYPOINT ["bash"]
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
Types: deb deb-src
|
||||
URIs: http://apt.llvm.org/bookworm/
|
||||
Suites: llvm-toolchain-bookworm-20
|
||||
Components: main
|
||||
@@ -1,4 +0,0 @@
|
||||
set -e
|
||||
|
||||
docker build --pull -f build.Dockerfile -t lemur-build .
|
||||
MSYS_NO_PATHCONV=1 docker run -it --rm -v .:/app -w /app lemur-build /app/scripts/do-bundle.sh
|
||||
+2
-1
@@ -24,7 +24,8 @@ if ! command -v docker 2>&1 >/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./scripts/bundle.sh
|
||||
docker build -f build.Dockerfile -t lemur-build .
|
||||
MSYS_NO_PATHCONV=1 docker run -it --rm -v .:/app -w /app --entrypoint bash lemur-build /app/scripts/do-bundle.sh
|
||||
|
||||
body=$(cat <<EOF
|
||||
## How to install
|
||||
|
||||
+1
-1
Submodule shrooms-vb-core updated: 8598eab087...ecbd103917
+5
-4
@@ -209,10 +209,11 @@ impl ApplicationHandler<UserEvent> for Application {
|
||||
.focused
|
||||
.as_ref()
|
||||
.and_then(|id| self.viewports.get_mut(id))
|
||||
&& viewport.app.handle_gamepad_event(&event)
|
||||
{
|
||||
if viewport.app.handle_gamepad_event(&event) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.controllers.handle_gamepad_event(&event);
|
||||
}
|
||||
UserEvent::OpenAbout => {
|
||||
@@ -288,13 +289,13 @@ impl ApplicationHandler<UserEvent> for Application {
|
||||
|
||||
fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
|
||||
let (sender, receiver) = oneshot::channel();
|
||||
if self.client.send_command(EmulatorCommand::Exit(sender))
|
||||
&& let Err(error) = receiver.recv_timeout(Duration::from_secs(5))
|
||||
{
|
||||
if self.client.send_command(EmulatorCommand::Exit(sender)) {
|
||||
if let Err(error) = receiver.recv_timeout(Duration::from_secs(5)) {
|
||||
error!(%error, "could not gracefully exit.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct WgpuState {
|
||||
instance: wgpu::Instance,
|
||||
|
||||
+3
-3
@@ -455,12 +455,12 @@ impl Emulator {
|
||||
let Some(sim) = self.sims.get_mut(sim_id.to_index()) else {
|
||||
return true;
|
||||
};
|
||||
if let Some(text) = sim.take_stdout()
|
||||
&& stdout.send(text).is_err()
|
||||
{
|
||||
if let Some(text) = sim.take_stdout() {
|
||||
if stdout.send(text).is_err() {
|
||||
sim.watch_stdout(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
|
||||
+101
-9
@@ -1,7 +1,10 @@
|
||||
use anyhow::Result;
|
||||
use anyhow::{Context, Result, bail};
|
||||
use rand::Rng;
|
||||
use serde::Deserialize;
|
||||
use sha2::Digest;
|
||||
use std::{
|
||||
fs::{self, File},
|
||||
ffi::OsStr,
|
||||
fs,
|
||||
io::{Read, Seek as _, SeekFrom, Write as _},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
@@ -11,38 +14,52 @@ use crate::emulator::SimId;
|
||||
pub struct Cart {
|
||||
pub file_path: PathBuf,
|
||||
pub rom: Vec<u8>,
|
||||
sram_file: File,
|
||||
sram_file: fs::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 vbx_extension = OsStr::new("vbx");
|
||||
let contents = if file_path.extension() == Some(vbx_extension) {
|
||||
read_bundle(file_path)
|
||||
} else {
|
||||
read_rom(file_path)
|
||||
}?;
|
||||
|
||||
let mut sram_file = File::options()
|
||||
let mut sram_file = fs::File::options()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(false)
|
||||
.open(sram_path(file_path, sim_id))?;
|
||||
|
||||
let sram_file_size = if contents.sram_small_bus {
|
||||
contents.sram_size * 2
|
||||
} else {
|
||||
contents.sram_size
|
||||
};
|
||||
let sram = if sram_file.metadata()?.len() == 0 {
|
||||
// new SRAM file, randomize the contents
|
||||
let mut sram = vec![0; 16 * 1024];
|
||||
let mut sram = vec![0; sram_file_size];
|
||||
let mut rng = rand::rng();
|
||||
for dst in sram.iter_mut().step_by(2) {
|
||||
for dst in sram
|
||||
.iter_mut()
|
||||
.step_by(if contents.sram_small_bus { 2 } else { 1 })
|
||||
{
|
||||
*dst = rng.random();
|
||||
}
|
||||
sram
|
||||
} else {
|
||||
let mut sram = Vec::with_capacity(16 * 1024);
|
||||
let mut sram = Vec::with_capacity(sram_file_size);
|
||||
sram_file.read_to_end(&mut sram)?;
|
||||
sram.resize(sram_file_size, 0);
|
||||
sram
|
||||
};
|
||||
|
||||
Ok(Cart {
|
||||
file_path: file_path.to_path_buf(),
|
||||
rom,
|
||||
rom: contents.rom,
|
||||
sram_file,
|
||||
sram,
|
||||
})
|
||||
@@ -55,6 +72,81 @@ impl Cart {
|
||||
}
|
||||
}
|
||||
|
||||
struct CartContents {
|
||||
rom: Vec<u8>,
|
||||
sram_size: usize,
|
||||
sram_small_bus: bool,
|
||||
}
|
||||
|
||||
fn read_bundle(file_path: &Path) -> Result<CartContents> {
|
||||
let file = fs::File::open(file_path)?;
|
||||
let mut archive = zip::ZipArchive::new(file).context("invalid VBX")?;
|
||||
let manifest_reader = archive
|
||||
.by_name("manifest.json")
|
||||
.context("manifest.json not found")?;
|
||||
let manifest: Manifest =
|
||||
serde_json::from_reader(manifest_reader).context("malformed manifest")?;
|
||||
let rom = {
|
||||
let mut rom_file = archive
|
||||
.by_name(&manifest.rom.file)
|
||||
.context("ROM file not found")?;
|
||||
let mut buffer = Vec::with_capacity(rom_file.size() as usize);
|
||||
rom_file
|
||||
.read_to_end(&mut buffer)
|
||||
.context("could not read ROM")?;
|
||||
buffer
|
||||
};
|
||||
if let Some(hash) = manifest.rom.sha256 {
|
||||
let expected_hash = hex::decode(hash)?;
|
||||
let actual_hash = sha2::Sha256::digest(&rom);
|
||||
if expected_hash[..] != actual_hash[..] {
|
||||
bail!("Incorrect ROM hash");
|
||||
}
|
||||
}
|
||||
|
||||
let sram_size = manifest.sram.as_ref().map(|s| s.size).unwrap_or(8192);
|
||||
if !sram_size.is_power_of_two() {
|
||||
bail!("Invalid SRAM size, must be power of two")
|
||||
}
|
||||
let sram_small_bus = manifest.sram.and_then(|s| s.bus_width).unwrap_or_default() < 16;
|
||||
|
||||
Ok(CartContents {
|
||||
rom,
|
||||
sram_size,
|
||||
sram_small_bus,
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct Manifest {
|
||||
rom: ManifestRom,
|
||||
sram: Option<ManifestSram>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ManifestRom {
|
||||
file: String,
|
||||
sha256: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ManifestSram {
|
||||
size: usize,
|
||||
bus_width: Option<usize>,
|
||||
}
|
||||
|
||||
fn read_rom(rom_path: &Path) -> Result<CartContents> {
|
||||
let rom = fs::read(rom_path)?;
|
||||
Ok(CartContents {
|
||||
rom,
|
||||
sram_size: 8192,
|
||||
sram_small_bus: true,
|
||||
})
|
||||
}
|
||||
|
||||
fn sram_path(file_path: &Path, sim_id: SimId) -> PathBuf {
|
||||
match sim_id {
|
||||
SimId::Player1 => file_path.with_extension("p1.sram"),
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ impl MemoryRef<'_> {
|
||||
T::from_bytes(&self.inner[from..to])
|
||||
}
|
||||
|
||||
pub fn range<T: MemoryValue>(&self, start: usize, count: usize) -> MemoryIter<'_, T> {
|
||||
pub fn range<T: MemoryValue>(&self, start: usize, count: usize) -> MemoryIter<T> {
|
||||
let from = start * size_of::<T>();
|
||||
let to = from + (count * size_of::<T>());
|
||||
MemoryIter::new(&self.inner[from..to])
|
||||
|
||||
+1
-1
@@ -457,7 +457,7 @@ impl GameWindow {
|
||||
self.config = new_config;
|
||||
}
|
||||
|
||||
fn button_for(&self, ctx: &Context, text: &str, command: Command) -> Button<'_> {
|
||||
fn button_for(&self, ctx: &Context, text: &str, command: Command) -> Button {
|
||||
let button = Button::new(text);
|
||||
match self.shortcuts.shortcut_for(command) {
|
||||
Some(shortcut) => button.shortcut_text(ctx.format_shortcut(&shortcut)),
|
||||
|
||||
@@ -62,8 +62,8 @@ impl HotkeysWindow {
|
||||
}
|
||||
});
|
||||
});
|
||||
if let Some(command) = self.now_binding
|
||||
&& let Some(shortcut) = ui.input_mut(|i| {
|
||||
if let Some(command) = self.now_binding {
|
||||
if let Some(shortcut) = ui.input_mut(|i| {
|
||||
i.events.iter().find_map(|event| match event {
|
||||
Event::Key {
|
||||
key,
|
||||
@@ -73,12 +73,12 @@ impl HotkeysWindow {
|
||||
} => Some(KeyboardShortcut::new(*modifiers, *key)),
|
||||
_ => None,
|
||||
})
|
||||
})
|
||||
{
|
||||
}) {
|
||||
self.shortcuts.set(command, shortcut);
|
||||
self.now_binding = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn show_ff_settings(&mut self, ui: &mut Ui) {
|
||||
let row_height = ui.spacing().interact_size.y;
|
||||
|
||||
+7
-7
@@ -86,11 +86,11 @@ impl UiExt for Ui {
|
||||
let (rect, _) = ui.allocate_at_least(Vec2::new(100.0, 100.0), Sense::hover());
|
||||
ui.painter().rect_filled(rect, 0.0, *color);
|
||||
let resp = ui.text_edit_singleline(hex);
|
||||
if resp.changed()
|
||||
&& let Ok(new_color) = HexColor::from_str_without_hash(hex)
|
||||
{
|
||||
if resp.changed() {
|
||||
if let Ok(new_color) = HexColor::from_str_without_hash(hex) {
|
||||
*color = new_color.color();
|
||||
}
|
||||
}
|
||||
resp
|
||||
},
|
||||
)
|
||||
@@ -301,11 +301,11 @@ impl<T: Number> Widget for NumberEdit<'_, T> {
|
||||
|
||||
let mut delta = None;
|
||||
if self.arrows {
|
||||
let arrow_left = res.rect.max.x - 16.0;
|
||||
let arrow_right = res.rect.max.x;
|
||||
let arrow_top = res.rect.min.y;
|
||||
let arrow_left = res.rect.max.x + 4.0;
|
||||
let arrow_right = res.rect.max.x + 20.0;
|
||||
let arrow_top = res.rect.min.y - 2.0;
|
||||
let arrow_middle = (res.rect.min.y + res.rect.max.y) / 2.0;
|
||||
let arrow_bottom = res.rect.max.y;
|
||||
let arrow_bottom = res.rect.max.y + 2.0;
|
||||
|
||||
let top_arrow_rect = Rect {
|
||||
min: (arrow_left, arrow_top).into(),
|
||||
|
||||
Reference in New Issue
Block a user