chirp: Break frontends into separate projects
This commit is contained in:
parent
bcd5499833
commit
f886aadc63
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
# Rust files
|
# Rust files
|
||||||
|
**/target
|
||||||
|
**/Cargo.lock
|
||||||
/target
|
/target
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
flamegraph.svg
|
flamegraph.svg
|
||||||
|
38
Cargo.toml
38
Cargo.toml
@ -1,12 +1,22 @@
|
|||||||
[package]
|
[workspace]
|
||||||
name = "chirp"
|
members = ["chirp-imgui", "chirp-minifb"]
|
||||||
|
# default-members = ["chirp-imgui"]
|
||||||
|
|
||||||
|
[workspace.package]
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
default-run = "chirp-imgui"
|
|
||||||
authors = ["John Breaux"]
|
authors = ["John Breaux"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "chirp"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
publish.workspace = true
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "chirp"
|
name = "chirp"
|
||||||
path = "src/bin/chirp-minifb/main.rs"
|
path = "src/bin/chirp-minifb/main.rs"
|
||||||
@ -16,26 +26,14 @@ required-features = ["minifb"]
|
|||||||
name = "chirp-disasm"
|
name = "chirp-disasm"
|
||||||
required-features = ["default"]
|
required-features = ["default"]
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "chirp-imgui"
|
|
||||||
required-features = ["imgui"]
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "chirp-shot-viewer"
|
name = "chirp-shot-viewer"
|
||||||
required-features = ["default", "drawille"]
|
required-features = ["default", "drawille"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["drawille", "imgui", "serde"]
|
default = ["drawille", "serde"]
|
||||||
nightly = []
|
nightly = []
|
||||||
drawille = ["dep:drawille"]
|
drawille = ["dep:drawille"]
|
||||||
imgui = [
|
|
||||||
"dep:imgui",
|
|
||||||
"dep:imgui-wgpu",
|
|
||||||
"dep:imgui-winit-support",
|
|
||||||
"dep:winit",
|
|
||||||
"dep:winit_input_helper",
|
|
||||||
"dep:pixels",
|
|
||||||
]
|
|
||||||
minifb = ["dep:minifb"]
|
minifb = ["dep:minifb"]
|
||||||
rhexdump = ["dep:rhexdump"]
|
rhexdump = ["dep:rhexdump"]
|
||||||
|
|
||||||
@ -54,14 +52,6 @@ overflow-checks = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
imgui = { version = "^0.10", optional = true }
|
|
||||||
imgui-winit-support = { version = "^0.10", optional = true }
|
|
||||||
imgui-wgpu = { version = "^0", optional = true }
|
|
||||||
pixels = { version = "^0", optional = true }
|
|
||||||
# TODO: When imgui-winit-support updates to 0.28 (Soon:tm:), update winit and winit_input_helper
|
|
||||||
winit = { version = "0.27.5", features = ["default", "x11"], optional = true }
|
|
||||||
winit_input_helper = { version = "^0.13.0", optional = true }
|
|
||||||
|
|
||||||
drawille = { version = "0.3.0", optional = true }
|
drawille = { version = "0.3.0", optional = true }
|
||||||
rhexdump = { version = "0.1.1", optional = true }
|
rhexdump = { version = "0.1.1", optional = true }
|
||||||
serde = { version = "1.0.0", features = ["derive"], optional = true }
|
serde = { version = "1.0.0", features = ["derive"], optional = true }
|
||||||
|
23
chirp-imgui/Cargo.toml
Normal file
23
chirp-imgui/Cargo.toml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[package]
|
||||||
|
name = "chirp-imgui"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
publish.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
|
||||||
|
chirp = { path = ".." }
|
||||||
|
|
||||||
|
gumdrop = "0.8.1"
|
||||||
|
owo-colors = "3"
|
||||||
|
thiserror = "1.0.39"
|
||||||
|
|
||||||
|
imgui = { version = "^0.11" }
|
||||||
|
imgui-winit-support = { version = "^0.11" }
|
||||||
|
imgui-wgpu = { version = "^0.23" }
|
||||||
|
pixels = { version = "^0" }
|
||||||
|
# TODO: When imgui-winit-support updates to 0.28 (Soon:tm:), update winit and winit_input_helper
|
||||||
|
winit = { version = "0.27.5", features = ["default", "x11"] }
|
||||||
|
winit_input_helper = { version = "^0.13.0" }
|
15
chirp-minifb/Cargo.toml
Normal file
15
chirp-minifb/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
name = "chirp-minifb"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
|
||||||
|
chirp = { path = ".." }
|
||||||
|
minifb = { version = "0.24.0" }
|
||||||
|
|
||||||
|
gumdrop = "0.8.1"
|
||||||
|
owo-colors = "3"
|
||||||
|
thiserror = "1.0.39"
|
18
chirp-minifb/src/error.rs
Normal file
18
chirp-minifb/src/error.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//! Error type for chirp-minifb
|
||||||
|
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum Error {
|
||||||
|
/// Error originated in [`chirp`]
|
||||||
|
#[error(transparent)]
|
||||||
|
Chirp(#[from] chirp::error::Error),
|
||||||
|
/// Error originated in [`std::io`]
|
||||||
|
#[error(transparent)]
|
||||||
|
Io(#[from] std::io::Error),
|
||||||
|
/// Error originated in [`minifb`]
|
||||||
|
#[error(transparent)]
|
||||||
|
Minifb(#[from] minifb::Error),
|
||||||
|
}
|
@ -6,10 +6,13 @@
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
mod error;
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
use chirp::error::Error::BreakpointHit;
|
use chirp::error::Error::BreakpointHit;
|
||||||
use chirp::{error::Result, *};
|
use chirp::*;
|
||||||
|
use error::Result;
|
||||||
use gumdrop::*;
|
use gumdrop::*;
|
||||||
use owo_colors::OwoColorize;
|
use owo_colors::OwoColorize;
|
||||||
use std::{
|
use std::{
|
||||||
@ -162,7 +165,7 @@ impl State {
|
|||||||
self.ui.keys(&mut self.ch8)
|
self.ui.keys(&mut self.ch8)
|
||||||
}
|
}
|
||||||
fn frame(&mut self) -> Result<bool> {
|
fn frame(&mut self) -> Result<bool> {
|
||||||
self.ui.frame(&mut self.ch8)
|
self.ui.frame(&self.ch8)
|
||||||
}
|
}
|
||||||
fn tick_cpu(&mut self) -> Result<()> {
|
fn tick_cpu(&mut self) -> Result<()> {
|
||||||
if !self.ch8.cpu.flags.pause {
|
if !self.ch8.cpu.flags.pause {
|
||||||
@ -209,7 +212,7 @@ impl Iterator for State {
|
|||||||
}
|
}
|
||||||
// Allow breakpoint hit messages
|
// Allow breakpoint hit messages
|
||||||
match self.tick_cpu() {
|
match self.tick_cpu() {
|
||||||
Err(BreakpointHit { addr, next }) => {
|
Err(error::Error::Chirp(BreakpointHit { addr, next })) => {
|
||||||
eprintln!("Breakpoint hit: {:3x} ({:4x})", addr, next);
|
eprintln!("Breakpoint hit: {:3x} ({:4x})", addr, next);
|
||||||
}
|
}
|
||||||
Err(e) => return Some(Err(e)),
|
Err(e) => return Some(Err(e)),
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
use super::ui::*;
|
use super::ui::*;
|
||||||
use super::Chip8;
|
use super::Chip8;
|
||||||
|
use crate::error::Result;
|
||||||
use chirp::*;
|
use chirp::*;
|
||||||
use std::{collections::hash_map::DefaultHasher, hash::Hash};
|
use std::{collections::hash_map::DefaultHasher, hash::Hash};
|
||||||
|
|
||||||
@ -37,8 +38,8 @@ mod ui {
|
|||||||
#[test]
|
#[test]
|
||||||
fn frame() -> Result<()> {
|
fn frame() -> Result<()> {
|
||||||
let mut ui = UIBuilder::new(32, 64, "dummy.ch8").build()?;
|
let mut ui = UIBuilder::new(32, 64, "dummy.ch8").build()?;
|
||||||
let mut ch8 = new_chip8();
|
let ch8 = new_chip8();
|
||||||
ui.frame(&mut ch8).unwrap();
|
ui.frame(&ch8).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
@ -5,7 +5,8 @@
|
|||||||
//! TODO: Destroy this all.
|
//! TODO: Destroy this all.
|
||||||
|
|
||||||
use super::Chip8;
|
use super::Chip8;
|
||||||
use chirp::{error::Result, screen::Screen};
|
use crate::error::Result;
|
||||||
|
use chirp::screen::Screen;
|
||||||
use minifb::*;
|
use minifb::*;
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
@ -144,7 +145,7 @@ pub struct UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl UI {
|
impl UI {
|
||||||
pub fn frame(&mut self, ch8: &mut Chip8) -> Result<bool> {
|
pub fn frame(&mut self, ch8: &Chip8) -> Result<bool> {
|
||||||
if ch8.cpu.flags.pause {
|
if ch8.cpu.flags.pause {
|
||||||
self.window.set_title("Chirp ⏸")
|
self.window.set_title("Chirp ⏸")
|
||||||
} else {
|
} else {
|
Loading…
Reference in New Issue
Block a user