Skip to content

Commit 073ec01

Browse files
committed
Merge branch 'Mechazawa-applesingle'
2 parents 777703f + 27528f7 commit 073ec01

20 files changed

Lines changed: 533 additions & 50 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
target
22
Cargo.lock
33
**/special/*.woz
4-
**/special/scratch.json
4+
**/special/scratch.json
5+
.DS_Store
6+
.idea

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixes
1111

1212
* fix an issue where minifier level 3 could break valid code
13-
* fix some issues with handling of unusual WOZ tracks
13+
* fix some issues with handling of unusual WOZ layouts
1414
* correct various docstrings and log strings
1515
* register LSP commands (will be required by Neovim 0.13)
1616

1717
### New Features
1818

1919
* create, read, and write with proprietary formats
2020
- from CLI use `--pro` argument with any disk image subcommand
21+
* support AppleSingle format (PR #2)
2122
* minify and renumber can be guarded by external references
2223
* CLI `mkdsk` supports creating blank or empty disks (issue #3)
2324
* support for quarter tracks
@@ -33,11 +34,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3334

3435
* modules `disk35` and `disk525` are eliminated
3536
* various public entities are eliminated from `img::woz`
36-
* changes to `DiskImage`
37+
* changes to `DiskImage` trait
3738
- eliminated `track-2ch`, `ch_2_track`
3839
* enumeration `img::NibbleCode` is eliminated
3940
* removed functions `lang::merlin::eval_if`, `img::imd::cpm_blocking`
40-
* trait function args changed: `Renumber::build_edits`
41+
* trait function args or return values changed: `Renumber::build_edits`, `Packing::get_load_address`
4142

4243
## [3.7.0] - 2025-03-22
4344

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "a2kit"
3-
version = "4.0.0-beta1"
3+
version = "4.0.0-beta2"
44
edition = "2021"
55
readme = "README.md"
66
license = "MIT"
@@ -43,4 +43,5 @@ num-traits = "0.2.14"
4343
num-derive = "0.4"
4444
a2kit_macro = "1.0.0"
4545
a2kit_macro_derive = "1.0.0"
46-
retrocompressor = "1.0.0"
46+
retrocompressor = "1.0.0"
47+
binrw="0.14.0"

src/bin/server-merlin/request.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ pub fn handle_request(
304304
resp = match item {
305305
disk_server::SelectionResult::Directory(dir) => Response::new_ok(req.id,serde_json::to_value(dir).expect("json")),
306306
disk_server::SelectionResult::FileData(mut sfimg) => {
307-
// encode the load address in first two bytes
308-
let mut ans = u16::to_le_bytes(sfimg.load_addr).to_vec();
307+
// encode the load address in first two bytes, if there is a bank byte it is ignored
308+
let addr16 = (sfimg.load_addr & 0xffff) as u16;
309+
let mut ans = u16::to_le_bytes(addr16).to_vec();
309310
ans.append(&mut sfimg.data);
310311
Response::new_ok(req.id, serde_json::to_value(ans).expect("json"))
311312
}

src/bios/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
//! This module is a place for any middleware we may require
44
//! between the `fs` and `img` modules. It is named in analogy
55
//! with the CP/M concept of a BIOS as being (in part) a layer between
6-
//! the BDOS and the physical disk.
6+
//! the BDOS and the physical disk. Tasks that live here include:
77
//!
8-
//! All the sector skewing tables are kept in this module.
9-
//! CP/M and FAT disk parameter blocks are here as well.
8+
//! * converting a block request into a sector request
9+
//! * maintaining sector skewing tables
10+
//! * maintaining parameter tables (such as CP/M DPB and FAT BPB)
1011
1112
pub mod skew;
1213
pub mod dpb;

src/cli.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Detokenize from image: `a2kit get -f prog -t atok -d myimg.dsk | a2kit detokeniz
9999
let get_put_types = [
100100
"any",
101101
"auto",
102+
"as",
102103
"bin",
103104
"txt",
104105
"raw",
@@ -115,6 +116,7 @@ Detokenize from image: `a2kit get -f prog -t atok -d myimg.dsk | a2kit detokeniz
115116

116117
let pack_unpack_types = [
117118
"auto",
119+
"as",
118120
"bin",
119121
"txt",
120122
"raw",

src/commands/get.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fn unpack_primitive(fimg: &FileImage,typ: ItemType,rec_len: Option<usize>,trunc:
2828
match typ {
2929
ItemType::Automatic => fimg.unpack(),
3030
ItemType::FileImage => Ok(UnpackedData::Text(fimg.to_json(indent))),
31+
ItemType::AppleSingle => Ok(UnpackedData::Binary(fimg.unpack_apple_single()?)),
3132
ItemType::Records => Ok(UnpackedData::Text(fimg.unpack_rec_str(rec_len,indent)?)),
3233
ItemType::ApplesoftTokens => Ok(UnpackedData::Binary(fimg.unpack_tok()?)),
3334
ItemType::IntegerTokens => Ok(UnpackedData::Binary(fimg.unpack_tok()?)),

src/commands/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,21 @@ pub enum CommandError {
5252
#[error("File not found")]
5353
FileNotFound,
5454
#[error("Key not found")]
55-
KeyNotFound
55+
KeyNotFound,
5656
}
5757

5858
/// Types of files that may be distinguished by the file system or a2kit.
5959
/// This will have to be mapped to a similar enumeration at lower levels
6060
/// in order to obtain the binary type code.
6161
#[derive(PartialEq,Clone,Copy)]
6262
pub enum ItemType {
63+
FileImage,
64+
Automatic,
65+
AppleSingle,
6366
Raw,
6467
Binary,
6568
Text,
6669
Records,
67-
FileImage,
6870
ApplesoftText,
6971
IntegerText,
7072
MerlinText,
@@ -79,18 +81,19 @@ pub enum ItemType {
7981
RawTrack,
8082
System,
8183
Metadata,
82-
Automatic
8384
}
8485

8586
impl FromStr for ItemType {
8687
type Err = CommandError;
8788
fn from_str(s: &str) -> Result<Self,Self::Err> {
8889
match s {
90+
"any" => Ok(Self::FileImage),
91+
"auto" => Ok(Self::Automatic),
92+
"as" => Ok(Self::AppleSingle),
8993
"raw" => Ok(Self::Raw),
9094
"bin" => Ok(Self::Binary),
9195
"txt" => Ok(Self::Text),
9296
"rec" => Ok(Self::Records),
93-
"any" => Ok(Self::FileImage),
9497
"atxt" => Ok(Self::ApplesoftText),
9598
"itxt" => Ok(Self::IntegerText),
9699
"mtxt" => Ok(Self::MerlinText),
@@ -105,7 +108,6 @@ impl FromStr for ItemType {
105108
"sec" => Ok(Self::Sector),
106109
"sys" => Ok(Self::System),
107110
"meta" => Ok(Self::Metadata),
108-
"auto" => Ok(Self::Automatic),
109111
_ => Err(CommandError::UnknownItemType)
110112
}
111113
}

src/commands/put.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clap;
22
use std::io::Read;
33
use std::str::FromStr;
4-
use super::{ItemType,CommandError};
4+
use super::{ItemType, CommandError};
55
use crate::fs::FileImage;
66
use crate::STDRESULT;
77

@@ -10,20 +10,22 @@ const RANGED_ACCESS: &str =
1010

1111
fn pack_primitive(fimg: &mut FileImage, dat: &[u8], load_addr: Option<usize>, typ: ItemType) -> STDRESULT {
1212
match typ {
13-
ItemType::Raw => fimg.pack_raw(&dat),
14-
ItemType::Binary => fimg.pack_bin(&dat,load_addr,None),
15-
ItemType::ApplesoftTokens => fimg.pack_tok(&dat,ItemType::ApplesoftTokens,None),
16-
ItemType::IntegerTokens => fimg.pack_tok(&dat,ItemType::IntegerTokens,None),
17-
ItemType::MerlinTokens => fimg.pack_raw(&dat),
13+
ItemType::Automatic => fimg.pack(dat,load_addr),
14+
ItemType::AppleSingle => fimg.pack_apple_single(dat, load_addr),
15+
ItemType::Raw => fimg.pack_raw(dat),
16+
ItemType::Binary => fimg.pack_bin(dat,load_addr,None),
17+
ItemType::ApplesoftTokens => fimg.pack_tok(dat,ItemType::ApplesoftTokens,None),
18+
ItemType::IntegerTokens => fimg.pack_tok(dat,ItemType::IntegerTokens,None),
19+
ItemType::MerlinTokens => fimg.pack_raw(dat),
1820
ItemType::Text => {
19-
let txt = std::str::from_utf8(&dat)?;
21+
let txt = std::str::from_utf8(dat)?;
2022
fimg.pack_txt(txt)
2123
},
2224
ItemType::Records => {
23-
let json_str = std::str::from_utf8(&dat)?;
25+
let json_str = std::str::from_utf8(dat)?;
2426
fimg.pack_rec_str(json_str)
2527
},
26-
_ => return Err(Box::new(CommandError::UnsupportedItemType))
28+
_ => Err(Box::new(CommandError::UnsupportedItemType))
2729
}
2830
}
2931

src/fs/cpm/pack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl Packing for Packer {
225225
}
226226
}
227227

228-
fn get_load_address(&self,_fimg: &FileImage) -> u16 {
228+
fn get_load_address(&self,_fimg: &FileImage) -> usize {
229229
0
230230
}
231231

0 commit comments

Comments
 (0)