File: mkrom.sh

package info (click to toggle)
xa 2.4.1-0.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,356 kB
  • sloc: ansic: 8,585; asm: 845; makefile: 755; perl: 116; sh: 53
file content (92 lines) | stat: -rwxr-xr-x 1,978 bytes parent folder | download | duplicates (7)
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
#!/bin/bash
#
#    xa65 - 6502 cross assembler and utility suite
#    mkrom.sh - assemble several 'romable' files into one binary
#    Copyright (C) 1997 Andr Fachat (a.fachat@physik.tu-chemnitz.de)
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

XA="../xa"
FILE=../file65

start=32768
ende=65536
romfile=rom65

next=$[ start + 2 ];
pars="-A $next"

umask 077

tmp1=/tmp/mkrom65.sh.$$.a
tmp2=/tmp/mkrom65.sh.$$.b
tmp3=/tmp/mkrom65.sh.$$.c

echo -e "#include <stdio.h>\nvoid main(int argc, char *argv[]) { printf(\"%c%c\",atoi(argv[1])&255,(atoi(argv[1])/256)&255);}"  \
	> $tmp3;
cc $tmp3 -o $tmp2

while [ $# -ne 0 ]; do 
  case $1 in
  -A)	# get start address
	start=$[ $2 ];
	shift
	;;
  -E)	# get end address
	ende=$[ $2 ];
	shift
	;;
  -R)   # get ROM filename
	romfile=$2;
	shift
	;;
  -O)	# xa options
	XA="$XA $2";
	shift
	;;
  -S)   # segment addresses - in xa option format
	pars="$pars $2";
	shift
	;;
  *)
	break;
	;;
  esac;
  shift
done

#get file list 
list="$*"


echo -n > $romfile

for i in $list; do 
  #echo "next=$next, start=$start, pars=$pars"
  #echo "cmd= ${XA} -R $pars -o $tmp1 $i"
  $XA -R $pars -o $tmp1 $i
  pars=`$FILE -a 2 -P $tmp1`;
  next=`$FILE -A 0 $tmp1`;

  $tmp2 $next >> $romfile
  cat $tmp1 >> $romfile;

done;

$tmp2 65535 >> $romfile

rm -f $tmp1 $tmp2 $tmp3