| 1 |
#! /usr/bin/perl -w |
| 2 |
# --------------------------------------------------------------------------- |
| 3 |
# This file is part of reSID, a MOS6581 SID emulator engine. |
| 4 |
# Copyright (C) 2004 Dag Lem <[email protected]> |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation; either version 2 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
# |
| 11 |
# This program is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program; if not, write to the Free Software |
| 18 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
# --------------------------------------------------------------------------- |
| 20 |
|
| 21 |
use strict; |
| 22 |
|
| 23 |
die("Usage: samp2src name data-in src-out\n") unless @ARGV == 3; |
| 24 |
my ($name, $in, $out) = @ARGV; |
| 25 |
|
| 26 |
open(F, "<$in") or die($!); |
| 27 |
local $/ = undef; |
| 28 |
my $data = <F>; |
| 29 |
close(F) or die($!); |
| 30 |
|
| 31 |
open(F, ">$out") or die($!); |
| 32 |
|
| 33 |
print F <<\EOF; |
| 34 |
// --------------------------------------------------------------------------- |
| 35 |
// This file is part of reSID, a MOS6581 SID emulator engine. |
| 36 |
// Copyright (C) 2004 Dag Lem <[email protected]> |
| 37 |
// |
| 38 |
// This program is free software; you can redistribute it and/or modify |
| 39 |
// it under the terms of the GNU General Public License as published by |
| 40 |
// the Free Software Foundation; either version 2 of the License, or |
| 41 |
// (at your option) any later version. |
| 42 |
// |
| 43 |
// This program is distributed in the hope that it will be useful, |
| 44 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 45 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 46 |
// GNU General Public License for more details. |
| 47 |
// |
| 48 |
// You should have received a copy of the GNU General Public License |
| 49 |
// along with this program; if not, write to the Free Software |
| 50 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 51 |
// --------------------------------------------------------------------------- |
| 52 |
|
| 53 |
EOF |
| 54 |
|
| 55 |
print F "#include \"wave.h\"\n\nreg8 WaveformGenerator::$name\[\] =\n{\n"; |
| 56 |
|
| 57 |
for (my $i = 0; $i < length($data); $i += 8) { |
| 58 |
print F sprintf("/* 0x%03x: */ ", $i), map(sprintf(" 0x%02x,", $_), unpack("C*", substr($data, $i, 8))), "\n"; |
| 59 |
} |
| 60 |
|
| 61 |
print F "};\n"; |
| 62 |
|
| 63 |
close(F) or die($!); |
| 64 |
|
| 65 |
exit(0); |