-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgw-cpm.3740
executable file
·69 lines (54 loc) · 1.39 KB
/
gw-cpm.3740
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
#!/usr/bin/env bash
# Format: IBM 3740 8in CP/M
# gw diskdef: ibm.3740
# 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 IBM 3740 compatible CP/M 2.2 disk"
gw convert --diskdefs $diskdefs --format ibm.3740 "$raw" "$img" 2>&1 | tee -a $log_decode
}
# Overloaded function from gw-raw
function extract # 1-Nothing
{
echo "Extract files from [$img] here as a verification step"
#file "$img" 2>&1 | tee -a $log_extract
format="ibm-3740"
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 ..