Skip to content

Commit a163539

Browse files
committed
patch 400K, id matrix
1 parent ab04a2b commit a163539

13 files changed

Lines changed: 116 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [4.0.1] - 2025-10-04
9+
10+
### Fixes
11+
12+
* fix handling of 400K Apple disks
13+
* remove interleave restriction on 3.5 inch Apple disks
14+
* eliminate unnecessary elements from disk identification matrix
15+
816
## [4.0.0] - 2025-09-20
917

1018
### Fixes
@@ -63,7 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6371
- arguments to many functions use abstract `Track` and `Sector` in place of CHS indices
6472
* changes to `DiskFS` trait
6573
- permissions are controlled by `set_attrib`, while `lock`, `unlock`, `protect`, and `unprotect` are eliminated
66-
* changed interfaces: `escaped_ascii_to_bytes`, `Packing::get_load_address`, `Woz1::create`, `Woz2::create`
74+
* changed interfaces: `create_fs_*`, `escaped_ascii_to_bytes`, `Packing::get_load_address`, `Woz1::create`, `Woz2::create`
6775
* changed structures: `merlin::settings::Flag`, `img::TrackSolution`
6876
* changed enumerations: various error enumerations
6977
* public became private: `lang::linenum`

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "a2kit"
3-
version = "4.0.0"
3+
version = "4.0.1"
44
edition = "2024"
55
readme = "README.md"
66
license = "MIT"

src/fs/cpm/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ use crate::{STDRESULT,DYNERR};
4242
const RCH: &str = "unreachable was reached";
4343

4444
pub const FS_NAME: &str = "cpm";
45+
const IMAGE_TYPES: [img::DiskImageType;7] = [
46+
img::DiskImageType::DO,
47+
img::DiskImageType::NIB,
48+
img::DiskImageType::WOZ1,
49+
img::DiskImageType::WOZ2,
50+
img::DiskImageType::DOT2MG,
51+
img::DiskImageType::IMD,
52+
img::DiskImageType::TD0,
53+
];
4554

4655
/// Given a CP/M extended filename string, get the access and fs_type fields
4756
/// to be used in a file image. These are tied together because of the way
@@ -162,6 +171,10 @@ impl Disk
162171
/// Usually called before user parameters are applied.
163172
/// Will not accept images with directory structures corresponding to CP/M versions higher than `cpm_vers`.
164173
pub fn test_img(img: &mut Box<dyn img::DiskImage>,dpb: &DiskParameterBlock,cpm_vers: [u8;3]) -> bool {
174+
if !IMAGE_TYPES.contains(&img.what_am_i()) {
175+
return false;
176+
}
177+
log::info!("trying CP/M");
165178
img.change_method(img::tracks::Method::Auto);
166179
// test the volume directory header
167180
if let Some(directory) = get_directory(img,dpb) {

src/fs/dos3x/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ use crate::DiskFormat;
2727
use crate::{STDRESULT,DYNERR};
2828

2929
pub const FS_NAME: &str = "a2 dos";
30+
const IMAGE_TYPES: [img::DiskImageType;6] = [
31+
img::DiskImageType::D13,
32+
img::DiskImageType::DO,
33+
img::DiskImageType::NIB,
34+
img::DiskImageType::WOZ1,
35+
img::DiskImageType::WOZ2,
36+
img::DiskImageType::DOT2MG
37+
];
3038

3139
pub fn new_fimg(chunk_len: usize,name: &str) -> Result<super::FileImage,DYNERR> {
3240
if !pack::is_name_valid(name) {
@@ -130,6 +138,10 @@ impl Disk
130138
/// Test an image for DOS 3.x. Changes method to Auto.
131139
/// Usually called before user parameters are applied.
132140
pub fn test_img(img: &mut Box<dyn img::DiskImage>, maybe_fmt: Option<&DiskFormat>) -> bool {
141+
if !IMAGE_TYPES.contains(&img.what_am_i()) {
142+
return false;
143+
}
144+
log::info!("trying DOS 3.x");
133145
img.change_method(img::tracks::Method::Auto);
134146
let tlen = img.end_track();
135147
if (tlen < 35 || tlen > 40) && maybe_fmt.is_none() {

src/fs/fat/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ use crate::bios::{bpb,fat};
2626
use crate::{DYNERR,STDRESULT};
2727

2828
pub const FS_NAME: &str = "fat";
29+
const IMAGE_TYPES: [img::DiskImageType;4] = [
30+
img::DiskImageType::IMG,
31+
img::DiskImageType::IMD,
32+
img::DiskImageType::TD0,
33+
img::DiskImageType::DOT86F
34+
];
2935

3036
pub fn new_fimg(chunk_len: usize,set_time: bool,path: &str) -> Result<super::FileImage,DYNERR> {
3137
if !pack::is_path_valid(path) {
@@ -121,6 +127,10 @@ impl Disk {
121127
}
122128
/// Test an image for the FAT file system.
123129
pub fn test_img(img: &mut Box<dyn img::DiskImage>) -> bool {
130+
if !IMAGE_TYPES.contains(&img.what_am_i()) {
131+
return false;
132+
}
133+
log::info!("trying FAT");
124134
// test the boot sector to see if this is FAT
125135
if let Ok(boot) = img.read_sector(Track::Num(0),Sector::Num(1)) {
126136
return bpb::BootSector::verify(&boot);
@@ -130,6 +140,10 @@ impl Disk {
130140
}
131141
/// Test an image for DOS 1.x (no signature, no BPB)
132142
pub fn test_img_dos1x(img: &mut Box<dyn img::DiskImage>) -> bool {
143+
if !IMAGE_TYPES.contains(&img.what_am_i()) {
144+
return false;
145+
}
146+
log::info!("trying DOS 1.x");
133147
// We are going to look in the first FAT.
134148
// We look in the boot sector only for logging purposes.
135149
// By this time layout or size has already been used to create the `DiskImage`.

src/fs/fimg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//!
77
//! The native file image used by `a2kit` is the `FileImage` trait object.
88
//! It handles sparse and sequential files on an equal footing.
9-
//! All data must be packed as a `FileImage` before being written to a disk image.
10-
//! All data read from a disk image will be initially in the form of a `FileImage`.
9+
//! All file data must be packed as a `FileImage` before being written to a disk image.
10+
//! All file data read from a disk image will be initially in the form of a `FileImage`.
1111
//! `FileImage` data can be unpacked into a form suitable for ordinary consumers.
1212
//! If the data is not unpacked, the user will receive the `FileImage` as a JSON string.
1313
//!

src/fs/pascal/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ use crate::img;
2121
use crate::{STDRESULT,DYNERR};
2222

2323
pub const FS_NAME: &str = "a2 pascal";
24+
const IMAGE_TYPES: [img::DiskImageType;5] = [
25+
img::DiskImageType::DO,
26+
img::DiskImageType::NIB,
27+
img::DiskImageType::WOZ1,
28+
img::DiskImageType::WOZ2,
29+
img::DiskImageType::DOT2MG
30+
];
2431

2532
/// Load directory structure from a borrowed disk image.
2633
/// This is used to test images, as well as being called during FS operations.
@@ -99,6 +106,10 @@ impl Disk
99106
/// Test an image for the Pascal file system. Changes method to Auto.
100107
/// Usually called before user parameters are applied.
101108
pub fn test_img(img: &mut Box<dyn img::DiskImage>) -> bool {
109+
if !IMAGE_TYPES.contains(&img.what_am_i()) {
110+
return false;
111+
}
112+
log::info!("trying Pascal");
102113
img.change_method(img::tracks::Method::Auto);
103114
// test the volume directory header
104115
match get_directory(img) {

src/fs/prodos/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ use crate::img;
2323
use crate::{DYNERR,STDRESULT};
2424

2525
pub const FS_NAME: &str = "prodos";
26+
const IMAGE_TYPES: [img::DiskImageType;6] = [
27+
img::DiskImageType::DO,
28+
img::DiskImageType::PO,
29+
img::DiskImageType::NIB,
30+
img::DiskImageType::WOZ1,
31+
img::DiskImageType::WOZ2,
32+
img::DiskImageType::DOT2MG
33+
];
2634

2735
/// The primary interface for disk operations.
2836
pub struct Disk {
@@ -91,6 +99,10 @@ impl Disk {
9199
/// Test an image for the ProDOS file system. May try multiple track methods.
92100
/// Usually called before user parameters are applied.
93101
pub fn test_img(img: &mut Box<dyn img::DiskImage>) -> bool {
102+
if !IMAGE_TYPES.contains(&img.what_am_i()) {
103+
return false;
104+
}
105+
log::info!("trying ProDOS");
94106
let mut maybe_buf: Result<Vec<u8>,DYNERR> = Err(Box::new(Error::IOError));
95107
for test_method in [img::tracks::Method::Auto,img::tracks::Method::Emulate] {
96108
img.change_method(test_method);

src/img/tracks/formats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl ZoneFormat {
9696
_ => panic!("sides should be 1 or 2")
9797
},
9898
addr_fmt_expr: expr_vec(&["cyl%64","sec","head*32+cyl//64",&format,&chk]),
99-
addr_seek_expr: expr_vec(&["cyl%64","sec","head*32+cyl//64",&format,"(a0^a1^a2^a3)&63"]),
99+
addr_seek_expr: expr_vec(&["cyl%64","sec","head*32+cyl//64","a3","(a0^a1^a2^a3)&63"]),
100100
data_expr: expr_vec(&["sec","dat"]),
101101
markers: [
102102
SectorMarker {key: vec![0xd5,0xaa,0x96], mask: vec![0xff,0xff,0xff]},

src/img/tracks/gcr.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
//! ## module for GCR tracks
22
//!
3-
//! This handles bit-level processing of a GCR encoded disk track.
3+
//! This handles bit-level or flux-level processing of a GCR encoded disk track.
44
//! Image types handled include WOZ, G64, and NIB.
55
//! Special handling can be triggered by elements of the `ZoneFormat` struct.
66
//!
7-
//! There is an assumed tick normalization for each kind of disk:
7+
//! The `FluxCells` that are passed in for Apple disks must use tick normalizations as follows:
88
//! * Apple 5.25 inch - 125000 ps
99
//! * Apple 3.5 inch - 62500 ps
10+
//! This differs from WOZ image normalization which is always 125000 ps.
11+
//! Callers external to the library should not have to worry about this.
1012
1113
use crate::img::{Error,FieldCode,SectorHood,Sector};
1214
use super::{ZoneFormat,Method,FluxCells};

0 commit comments

Comments
 (0)