-
Notifications
You must be signed in to change notification settings - Fork 3
/
gw-cpm.86
executable file
·84 lines (67 loc) · 1.58 KB
/
gw-cpm.86
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# Format: CP/M-86 Boot Disk
# gw diskdef: cpm.86
# External tools: cpmtools (https://github.com/lipro-cpm4l/cpmtools)
# Get project name
name="$1"
# Include parent script
if [[ -f "./gw-raw" ]]
then
parent="./gw-raw"
else
parent="$(which gw-raw)"
fi
source "$parent" "$name" "source"
# Output file names
img="$name.img"
# Overloaded function from gw-raw
function decode # 1-Nothing
{
echo "Decoding CP/M 86 disk"
gw convert --diskdefs $diskdefs --format cpm.86 "$raw" "$img" 2>&1 | tee -a $log_decode
}
# Overloaded function from gw-rawo
# Need custom cpmtools disk diskdef
# CompuPro CPM/86?
cpm_diskdef="diskdef comp86
seclen 1024
tracks 70
sectrk 8
blocksize 1024
maxdir 64
skew 3
offset 11520
boottrk 0
os 2.2
end"
function extract # 1-Nothing
{
echo "Extract files from [$img] here as a verification step"
#file "$img" 2>&1 | tee -a $log_extract
format="$cpm_diskdef"
dest="$name-files"
# System dir creation
mkdir -p "$dest"
# Get files in copy
cpmls -f "$format" "$img" 2>&1 | tee -a $log_extract
cpmfiles=( $(cpmls -f "$format" "$img") )
if [[ "$(cpmls -f "$format" "$img" 2>&1 | grep "/")" != "" ]]
then
echo "CP/M files with '/' detected, replacing with '_'" 2>&1 | tee -a $log_extract
fi
# Extract each file from image
for line in "${cpmfiles[@]}"
do
if [[ "$line" == "0:" ]]
then
continue
fi
echo "Extracting: [$line]"
cpmcp -f "$format" "$img" "0:$line" "$dest/$(echo "$line" | sed 's|/|_|')"
done
}
# Create dir based on name and rip within it
mkdir -p "$name"
cd "$name"
rip A "h=0"
cd ..