1#!/bin/sh
2
3#
4# od2c.sh - convert 'od -Ax -t x1 -w8 <file>' output
5#
6# Written by
7#  Marco van den Heuvel <blackystardust68@yahoo.com>
8#
9# This file is part of VICE, the Versatile Commodore Emulator.
10# See README for copyright notice.
11#
12#  This program is free software; you can redistribute it and/or modify
13#  it under the terms of the GNU General Public License as published by
14#  the Free Software Foundation; either version 2 of the License, or
15#  (at your option) any later version.
16#
17#  This program is distributed in the hope that it will be useful,
18#  but WITHOUT ANY WARRANTY; without even the implied warranty of
19#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20#  GNU General Public License for more details.
21#
22#  You should have received a copy of the GNU General Public License
23#  along with this program; if not, write to the Free Software
24#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25#  02111-1307  USA.
26#
27
28start="yes"
29
30while read data
31do
32  charlength=${#data}
33  datalength=`expr $charlength - 6`
34  tl=`expr $datalength / 3`
35  if test x"$start" != "xyes"; then
36    if [ $tl -ne 0 ]; then
37        tdata="$tdata,"
38        echo "    $tdata"
39    fi
40  else
41    start=no
42  fi
43  if [ $tl -ne 0 ]; then
44    if [ $tl -ge 1 ]; then
45      tdata="0x${data:7:2}"
46    fi
47    if [ $tl -ge 2 ]; then
48      tdata="$tdata, 0x${data:10:2}"
49    fi
50    if [ $tl -ge 3 ]; then
51      tdata="$tdata, 0x${data:13:2}"
52    fi
53    if [ $tl -ge 4 ]; then
54      tdata="$tdata, 0x${data:16:2}"
55    fi
56    if [ $tl -ge 5 ]; then
57      tdata="$tdata, 0x${data:19:2}"
58    fi
59    if [ $tl -ge 6 ]; then
60      tdata="$tdata, 0x${data:22:2}"
61    fi
62    if [ $tl -ge 7 ]; then
63      tdata="$tdata, 0x${data:25:2}"
64    fi
65    if [ $tl -ge 8 ]; then
66      tdata="$tdata, 0x${data:28:2}"
67    fi
68  fi
69done
70echo "    $tdata"
71