Skip to content

Commit 02d1be9

Browse files
committed
refactor a bunch of stuff, add Platform, amiga & adf features
1 parent 3c16ab1 commit 02d1be9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1724
-931
lines changed

.clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# All my preferences are no longer supported :(
1+
# Moved to cargo.toml

CHANGELOG.md

+44-24
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22

33
### Features:
44

5-
- Added a convenience wrapper, StandardFormatParam, for use with parsing user input into StandardFormat
6-
- Added silly visualization functions to map a Pixmap to a DiskImage. See the png2disk crate for usage.
7-
- Added DiskCh, DiskChs and DiskChsn iterators for walking geometries of a StandardFormat
8-
- Added a StandardSectorView interface that provides Read + Write + Seek traits for a DiskImage
5+
- Added a `Platform` enumeration that defines the computing platform a disk image is intended for.
6+
- Added a `TrackSchema` enumeration that defines the specific format of a disk track
7+
- Added `ParserReadOptions` and `ParserWriteOptions` parameters to `ImageFileParser` to eventually better control
8+
disk image reading and writing.
9+
- Added a convenience wrapper, `StandardFormatParam`, for use with parsing user input into `StandardFormat`s
10+
- Added silly visualization functions to map a Pixmap to a `DiskImage`. See the png2disk crate for usage.
11+
- Added `DiskCh`, `DiskChs` and `DiskChsn` iterators for walking through sector layouts conforming to a `StandardFormat`
12+
- Added a `StandardSectorView` interface wrapper that provides `Read` + `Write` + `Seek` traits for a `DiskImage`
913
- Added basic FAT support and example
1014
- Added progress reporting for MFI loader.
15+
- Added support for high density MFI images.
1116
- Added support for WEAK chunk in PRI images.
1217
- Added support for PFI (PCE Flux Image) images
1318
- Added support for visualization of bitstream errors
1419
- Added offset fields to track interface functions to support tracks with duplicate sector IDs
15-
- Implemented DiskChsnQuery struct to enable optional matching of Sector ID fields when scanning, reading, or writing
20+
- Implemented `DiskChsnQuery` struct to enable optional matching of Sector ID fields when scanning, reading, or writing
1621
a sector.
17-
- Type aliased to SectorIdQuery
22+
- Type aliased to `SectorIdQuery`
23+
- Added several feature flags to fine-tune desired fluxfox functionality and dependencies
1824

1925
### Bugfixes:
2026

@@ -28,25 +34,39 @@
2834

2935
### Breaking changes:
3036

31-
- read_sector operations no longer require a mutable reference.
32-
- Several changes to DiskCh* structs and trait implementations.
33-
- Moved common type imports to fluxfox::prelude
34-
- Removed get_* prefixes from API per Rust style guidelines.
35-
- Removed Invalid variant of StandardFormat. Removed From<> and implemented TryFrom<usize>
36-
- All add_track_* API functions now return a mutable reference to the new track on success
37+
- Removed `default_sector_size` from `DiskDescriptor`.
38+
- `add_track_bitstream` now takes a `BitStreamTrackParams` reference.
39+
- `add_track_fluxstream` now takes a `FluxStreamTrackParams` reference.
40+
- `add_track_metasector` now takes a `MetaSectorTrackParams` reference.
41+
- `load_image` and `save_image` methods of `ImageFileParser` now take a `ParserReadOptions` and `ParserWriteOptions`
42+
reference, respectively.
43+
- `ImageWriter` now takes a reference to `DiskImage` in `new` instead of `write`.
44+
- `track_stream` and `track_stream_mut` methods of `Track` were renamed to `stream` and `stream_mut`.
45+
- `read_track` and `read_track_raw` methods of `Track` were renamed to `read` and `read_raw`.
46+
- Renamed `DiskConsistency` to `DiskAnalysis`, and `TrackConsistency` to `TrackAnalysis`.
47+
- "Consistency" was a somewhat imprecise and confusing term.
48+
- `track_consistency` was renamed to `analysis`
49+
- Renamed many 'Disk*' enums to 'Track*' to be more clear that these parameters may vary per track.
50+
- `DiskDensity` -> `TrackDensity`
51+
- `DiskDataEncoding` -> `TrackDataEncoding`
52+
- `DiskDataRate` -> `TrackDataRate`
53+
- `BiosParameterBlock2` and `BiosParameterBlock2` now implement `try_from<StandardFormat>` instead of
54+
`from<StandardFormat>` to support non-pc `StandardFormat`s
55+
- `read_sector()` method of `DiskImage` and `Track` no longer requires a mutable reference.
56+
- Several changes to `DiskCh*` structs and trait implementations.
57+
- Moved common type imports to `fluxfox::prelude`
58+
- Removed `get_*` prefixes from API per Rust style guidelines.
59+
- Removed the `Invalid` variant of `StandardFormat`. Replaced `From<usize>` with`TryFrom<usize>`
60+
- All `add_track_*` API functions now return a mutable reference to the new `Track` on success
3761
- Track API changes
38-
- Implemented DiskChsnQuery struct for optional matching of Sector ID fields
39-
- Added bit offset field to track sector read and write functions to support tracks with duplicate sector IDs
40-
- Factored common sector attributes into SectorAttributes struct. Affects SectorDescriptor and SectorMapEntry.
41-
- Renamed RwSectorScope::DataBlock to RwSectorScope::DataElement
42-
- Changed DiskCh::seek_next_track() to take a mutable reference to self.
43-
- Renamed render_track_weak_bits() to render_track_map() which can render track maps
44-
defined by RenderMapType
45-
46-
### Dependency updates:
47-
48-
- thiserror = "2.0"
49-
- regex = "1.11"
62+
- Implemented `DiskChsnQuery` struct for optional matching of Sector ID fields
63+
- Added an optional bit offset field to track `read_sector`, `scan_sector` and `write_sector` methods to support
64+
tracks with duplicate sector IDs
65+
- Factored common sector attributes into `SectorAttributes` struct. Affects `SectorDescriptor` and `SectorMapEntry`.
66+
- Renamed `RwSectorScope::DataBlock` to `RwSectorScope::DataElement` for internal naming consistency
67+
- Changed `DiskCh::seek_next_track()` to take a mutable reference to self.
68+
- Replaced `render_track_weak_bits()` with `render_track_map()` which can render different kinds of track masks
69+
defined by `RenderMapType`
5070

5171
## 0.1.0 (2024-11-07)
5272

Cargo.lock

+8-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+83-29
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,78 @@ keywords.workspace = true
1717
repository.workspace = true
1818
license.workspace = true
1919

20+
# Workspace definition
21+
# ----------------------------------------------------------------------------------------------------------------------
22+
[workspace]
23+
members = [
24+
"examples/async",
25+
"examples/serde_demo",
26+
"examples/imginfo",
27+
"examples/imgdump",
28+
"examples/imgviz",
29+
"crates/png2disk",
30+
"crates/ffedit",
31+
"crates/fftool",
32+
"crates/ff_egui_app",
33+
"crates/ff_egui_lib",
34+
"examples/fat"
35+
]
36+
37+
# Required dependencies
38+
# ----------------------------------------------------------------------------------------------------------------------
2039
[dependencies]
2140
bit-vec = "0.8"
22-
bitflags = "2.6.0"
41+
bitflags = "2.6"
2342
binrw = "0.14"
2443
thiserror = "2.0"
2544
logger = "0.4"
2645
env_logger = "0.11"
27-
regex = "1.10"
28-
log = "0.4.22"
29-
rand = "0.8.5"
30-
sha1_smol = "1.0.1"
46+
regex = "1.11"
47+
log = "0.4"
48+
rand = "0.8"
49+
sha1_smol = "1.0"
50+
dyn-clone = "1.0"
51+
strum = { version = "0.26", features = ["derive"] }
52+
53+
# Optional dependencies
54+
# ----------------------------------------------------------------------------------------------------------------------
3155

32-
# Dependencies for optional features
3356
# Num-traits and num-derive are used by retrocompressor ('td0' feature)
34-
num-traits = { version = "0.2.14", optional = true }
57+
num-traits = { version = "0.2", optional = true }
3558
num-derive = { version = "0.4", optional = true }
3659

3760
# tiny-skia is used by visualization functions ('viz' feature)
3861
tiny-skia = { version = "0.11", optional = true }
3962

4063
# flate2 is required for MFI decompression ('mfi' feature)
4164
flate2 = { version = "1.0", optional = true }
42-
histogram = "0.11"
43-
plotly = { version = "0.10", optional = true }
65+
66+
# histogram is required for flux timing detection / PLL initialization
67+
histogram = { version = "0.11", optional = true }
68+
69+
# plotly is used for plotting flux timings
70+
plotly = { version = "0.11", optional = true }
71+
72+
# serde is used for serialization / deserialization of app state and disk images ('serde' feature)
4473
serde = { version = "1.0", optional = true }
74+
75+
# typetag is used for serialization / deserialization of dyn trait objects ('serde' feature)
4576
typetag = { version = "0.2", optional = true }
77+
4678
wasm-bindgen-futures = { version = "0.4", optional = true }
4779

80+
# fluxfox_fat is used for reading FAT12/16/32 filesystems if 'fat' feature is enabled
4881
fluxfox_fat = { git = "https://github.com/dbalsom/fluxfox_fat.git", package = "fatfs", branch = "bpb_fix", default-features = false, features = ["std", "alloc", "log_level_debug"], optional = true }
4982

83+
# Native dependencies
84+
# ----------------------------------------------------------------------------------------------------------------------
5085
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
5186
zip = { version = "2.1", default-features = false, features = ["bzip2", "deflate", "deflate64", "lzma", "time", "zstd"], optional = true }
5287
tar = { version = "0.4", optional = true }
5388
tokio = { version = "1", optional = true, features = ["full"] }
5489

90+
# Wasm32 dependencies
91+
# ----------------------------------------------------------------------------------------------------------------------
5592
[target.'cfg(target_arch = "wasm32")'.dependencies]
5693
getrandom = { version = "0.2", features = ["js"] }
5794
zip = { version = "2.1", default-features = false, features = ["deflate", "deflate64", "lzma"], optional = true }
@@ -61,49 +98,66 @@ tar = { version = "0.4", optional = true }
6198
wasm-bindgen = { version = "0.2", optional = true }
6299
wasm-bindgen-futures = { version = "0.4", optional = true }
63100

101+
# Dev dependencies
102+
# ----------------------------------------------------------------------------------------------------------------------
64103
[dev-dependencies]
65-
sha1 = "0.10.6"
104+
sha1 = "0.10"
66105
hex = "0.4" # or the latest version
67106

68-
[workspace]
69-
members = [
70-
"examples/async",
71-
"examples/serde_demo",
72-
"examples/imginfo",
73-
"examples/imgdump",
74-
"examples/imgviz",
75-
"crates/png2disk",
76-
"crates/ffedit",
77-
"crates/fftool",
78-
"crates/ff_egui_app",
79-
"crates/ff_egui_lib"
80-
, "examples/fat"]
81-
82107
[features]
83-
default = ["viz", "zip", "tar", "mfi", "td0", "fat"]
108+
default = ["viz", "zip", "tar", "mfi", "fat", "flux", "ibmpc", "amiga"]
84109
wasm = ["async", "wasm-bindgen", "wasm-bindgen-futures"]
85110
serde = ["dep:serde", "dep:typetag", "bit-vec/serde_std", "bitflags/serde"]
86111
tokio-async = ["async", "tokio"]
87112
async = []
113+
# ibmpc feature enables IBM PC-specific disk image support (not fully factored out at the moment)
114+
ibmpc = ["td0"]
115+
# amiga feature enables Amiga-specific disk image support
116+
amiga = ["adf"]
117+
# viz feature enables visualization functions - will pull in tiny-skia dependency for drawing
88118
viz = ["dep:tiny-skia"]
119+
# zip feature enables reading zipped images, as well as reading/writing zip files from FileSystem interfaces
89120
zip = ["dep:zip"]
121+
# tar feature enables reading tar files from FileSystem interfaces
90122
tar = ["dep:tar"]
91-
mfi = ["dep:flate2"]
92-
td0 = ["dep:num-traits", "dep:num-derive"]
123+
# fat feature enables reading FAT12/16/32 filesystems. This will pull in fluxfox_fat dependency
93124
fat = ["dep:fluxfox_fat"]
125+
# flux feature enables reading flux images. This will pull in histogram dependency
126+
flux = ["dep:histogram"]
127+
# plotly feature enables export of flux timings to plotly (perhaps this should not be internal to fluxfox?)
94128
plot = ["dep:plotly"]
95129

130+
# Disk Image File Format Features
131+
# ----------------------------------------------------------------------------------------------------------------------
132+
# mfi feature enables reading MFI images. This will pull in flate2 dependency for compression/decompression
133+
mfi = ["dep:flate2", "flux"]
134+
# td0 feature enables reading TD0 images. This will pull in num-traits and num-derive dependencies and LZW/LZHUF
135+
# routines for compression/decompression
136+
td0 = ["dep:num-traits", "dep:num-derive"]
137+
# adf feature enables reading Amiga ADF images. This does not require an additional format parser, instead it is used to
138+
# enable reading/writing StandardFormat::Amiga880k images in the `raw` parser and StandardSectorView, as well as
139+
# advertising the ADF extension.
140+
adf = []
141+
142+
# Clippy lint control
143+
# ----------------------------------------------------------------------------------------------------------------------
96144
[lints.clippy]
145+
# We will eventually take this advice, but not now
97146
too-many-arguments = "allow"
147+
# Sometimes adding + 0 helps line things up. There's no harm in it
98148
identity_op = "allow"
99149

150+
# Build profiles
151+
# ----------------------------------------------------------------------------------------------------------------------
100152
[profile.release]
153+
# Most aggressive LTO profile
101154
lto = "thin"
102155

103156
[profile.release.package.ff_egui_app]
104-
opt-level = 2 # fast and small wasm
157+
# Fast and small wasm
158+
opt-level = 2
105159

106-
# Optimize all dependencies even in debug builds:
160+
# Optimize all dependencies even in debug builds
107161
[profile.dev.package."*"]
108162
opt-level = 2
109163

crates/ff_egui_app/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ eframe = { version = "0.29", default-features = false, features = [
2121
egui_extras = { version = "0.29", default-features = false, features = ["http", "image"] }
2222
image = { version = "0.25", default-features = false, features = ["png"] }
2323
log = "0.4"
24-
fluxfox = { path = "../..", default-features = false, features = ["serde", "zip", "tar", "mfi", "wasm", "viz", "fat"] }
24+
fluxfox = { path = "../..", default-features = false, features = ["serde", "zip", "tar", "mfi", "wasm", "viz", "fat", "ibmpc", "amiga"] }
2525
fluxfox_egui = { path = "../ff_egui_lib" }
2626

2727
# We don't need tiny_skia's png support since egui is pulling in image anyway.

crates/ff_egui_app/src/windows/sector_viewer.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
--------------------------------------------------------------------------
2626
*/
2727
use fluxfox::prelude::*;
28-
use fluxfox_egui::{
29-
widgets::data_table::{DataRange, DataTableWidget},
30-
SectorSelection,
31-
};
28+
use fluxfox_egui::{widgets::data_table::DataTableWidget, SectorSelection};
3229
use std::sync::{Arc, RwLock};
3330

3431
#[derive(Default)]

crates/ff_egui_app/src/windows/track_viewer.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use fluxfox::prelude::*;
2828
use fluxfox_egui::{
2929
widgets::data_table::{DataRange, DataTableWidget},
30-
SectorSelection,
3130
TrackSelection,
3231
};
3332
use std::sync::{Arc, RwLock};
@@ -68,7 +67,7 @@ impl TrackViewer {
6867
}
6968
};
7069

71-
let rtr = match track_ref.read_track(None) {
70+
let rtr = match track_ref.read(None) {
7271
Ok(rtr) => rtr,
7372
Err(e) => {
7473
log::error!("Error reading sector: {:?}", e);

crates/ff_egui_lib/src/widgets/disk_info.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ pub struct DiskInfoWidget {
3636
pub filename: Option<String>,
3737
pub resolution: DiskDataResolution,
3838
pub geometry: DiskCh,
39-
pub rate: DiskDataRate,
40-
pub encoding: DiskDataEncoding,
41-
pub density: DiskDensity,
39+
pub rate: TrackDataRate,
40+
pub encoding: TrackDataEncoding,
41+
pub density: TrackDensity,
4242
}
4343

4444
impl DiskInfoWidget {

crates/fftool/src/convert/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub(crate) fn run(global: &GlobalOptions, params: &args::ConvertParams) -> Resul
102102

103103
// Create an output buffer
104104
let mut out_buffer = Cursor::new(Vec::new());
105-
match output_format.save_image(&mut in_disk, &mut out_buffer) {
105+
match output_format.save_image(&mut in_disk, &ParserWriteOptions::default(), &mut out_buffer) {
106106
Ok(_) => {
107107
let out_inner: Vec<u8> = out_buffer.into_inner();
108108
match std::fs::write(params.out_file.clone(), out_inner) {

0 commit comments

Comments
 (0)