-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.bash
More file actions
executable file
·55 lines (47 loc) · 1.58 KB
/
Copy pathsimple.bash
File metadata and controls
executable file
·55 lines (47 loc) · 1.58 KB
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
#!/bin/bash
# Check if an input file was provided
if [ -z "$1" ]; then
echo "Usage: ./simple.bash <input_file.clb>"
echo "Example: ./simple.bash programs/simple.clb"
exit 1
fi
INPUT_FILE=$1
# Get the filename without path and extension for the output names
BASE_NAME=$(basename "$INPUT_FILE" .clb)
OUTPUT_BAS="build/${BASE_NAME}.bas"
OUTPUT_PRG="build/${BASE_NAME}.prg"
# Ensure build directory exists
mkdir -p build
# 1. Run your Prolog Transpiler (CLB -> BASIC Text)
echo "Compiling $INPUT_FILE to BASIC..."
swipl -s src/compiler.pl -g "compile_file('$INPUT_FILE', '$OUTPUT_BAS'), halt"
# Check if compilation succeeded
if [ $? -ne 0 ]; then
echo "ERROR: Prolog compilation failed."
exit 1
fi
# 2. Convert BASIC Text to C64 Binary (using petcat)
# Check if petcat is installed
if ! command -v petcat &> /dev/null; then
echo "----------------------------------------"
echo "WARNING: 'petcat' (part of VICE) not found."
echo "PRG creation skipped. Only BASIC source created."
echo ""
echo "To install petcat:"
echo " macOS: brew install vice"
echo " Ubuntu: sudo apt-get install vice"
echo "----------------------------------------"
echo "BASIC source is available at: $OUTPUT_BAS"
exit 0
fi
echo "Converting to C64 PRG..."
petcat -w2 -o "$OUTPUT_PRG" -- "$OUTPUT_BAS"
if [ $? -eq 0 ]; then
echo "----------------------------------------"
echo "SUCCESS: $OUTPUT_PRG created!"
echo "Now copy it to your Commodore 64."
echo "----------------------------------------"
else
echo "ERROR: petcat conversion failed."
exit 1
fi