-
Notifications
You must be signed in to change notification settings - Fork 1
/
fsb2-abersoft.sh
executable file
·109 lines (79 loc) · 2.69 KB
/
fsb2-abersoft.sh
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
# fsb2-abersoft.sh
# This file is part of fsb2
# http://programandala.net/en.program.fsb2.html
# ##############################################################
# Author and license
# Copyright (C) 2015,2020 Marcos Cruz (programandala.net)
# You may do whatever you want with this work, so long as you
# retain the copyright notice(s) and this license in all
# redistributed copies and derived works. There is no warranty.
# ##############################################################
# Description
# This program converts a Forth source file from the FSB format
# to a ZX Spectrum TAP file suitable for Abersoft Forth.
#
# Abersoft Forth has a bug: the last byte of its RAM-disk (11
# blocks of 1 KiB) is not saved to tape (11263 bytes are saved
# instead of 11264). Trying to load a complete 11264-byte
# RAM-disk file causes "Tape loading error". The solution is to
# remove the last byte from the file.
#
# For Abersoft Forth systems with the Afera library
# (http://programandala.net/en.program.afera.html) use
# <fsb2abersoft11k.sh> or <fsb2abersoft16k.sh> instead.
# ##############################################################
# Requirements
# fsb2:
# <http://programandala.net/en.program.fsb2.html>
# bin2code:
# <http://metalbrain.speccy.org/link-eng.htm>.
# ##############################################################
# Usage (after installation)
# fsb2-abersoft filename.fsb
# ##############################################################
# History
# 2015-10-12: Adapted from fsb
# (http://programandala.net/en.program.fsb.html).
# ##############################################################
# Error checking
if [ "$#" -ne 1 ] ; then
echo "Convert a Forth source file from .fsb to .tap format for Abersoft Forth"
echo 'Usage:'
echo " ${0##*/} sourcefile.fsb"
exit 1
fi
if [ ! -e "$1" ] ; then
echo "Error: <$1> does not exist"
exit 1
fi
if [ ! -f "$1" ] ; then
echo "Error: <$1> is not a regular file"
exit 1
fi
if [ ! -r "$1" ] ; then
echo "Error: <$1> can not be read"
exit 1
fi
if [ ! -s "$1" ] ; then
echo "Error: <$1> is empty"
exit 1
fi
# ##############################################################
# Main
fsb2 $1
# Get the filenames:
basefilename=${1%.*}
blocksfile=$basefilename.fb
tapefile=$basefilename.tap
# Create the target file:
head --bytes=11263 $blocksfile > DISC
# The bin2code converter uses the host system filename in the
# TAP file header (there's no option to change it) and Abersoft
# Forth needs the file in the tape to be called "DISC". That's
# why an intermediate file called "DISC" is used.
bin2code DISC $tapefile
echo "\"$tapefile\" created"
# Remove the intermediate files:
rm -f DISC $blocksfile
# vim:tw=64:ts=2:sts=2:et: