summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoen Hirschberg <marcoen@gmail.com>2006-08-30 23:47:09 +0000
committerMarcoen Hirschberg <marcoen@gmail.com>2006-08-30 23:47:09 +0000
commitae8d47574d01e1aae45b905d17c912e235230f9b (patch)
treea674afd45830563aa84f897a684d1dfed3c77640
parent530f31dbe9fe404d41fd21867c8ed9cec1addd96 (diff)
downloadrockbox-ae8d47574d01e1aae45b905d17c912e235230f9b.zip
rockbox-ae8d47574d01e1aae45b905d17c912e235230f9b.tar.gz
rockbox-ae8d47574d01e1aae45b905d17c912e235230f9b.tar.bz2
rockbox-ae8d47574d01e1aae45b905d17c912e235230f9b.tar.xz
add Gigabeat support to the scramble tools
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10817 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--tools/Makefile11
-rwxr-xr-xtools/configure5
-rw-r--r--tools/descramble.c8
-rw-r--r--tools/gigabeat.c76
-rw-r--r--tools/gigabeat.h20
-rw-r--r--tools/scramble.c9
6 files changed, 122 insertions, 7 deletions
diff --git a/tools/Makefile b/tools/Makefile
index 53b1200..26cdcab 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -10,17 +10,18 @@ CFLAGS := -O -ansi -g
LDFLAGS := -g
CLEANALL := scramble descramble iriver sh2d bmp2rb rdf2binary convbdf \
- generate_rocklatin mkboot ipod_fw codepages uclpack mi4
+ generate_rocklatin mkboot ipod_fw codepages uclpack mi4 gigabeat
all:
@echo "Run make in your build directory!"
-scramble: scramble.o iriver.o mi4.o
-descramble: descramble.o iriver.o
+scramble: scramble.o iriver.o mi4.o gigabeat.o
+descramble: descramble.o iriver.o gigabeat.o
-scramble.o: scramble.c iriver.h
-descramble.o: descramble.c iriver.h
+scramble.o: scramble.c iriver.h mi4.h gigabeat.h
+descramble.o: descramble.c iriver.h gigabeat.h
iriver.o: iriver.c iriver.h
+gigabeat.o: gigabeat.c gigabeat.h
mi4.o: mi4.c mi4.h
sh2d: sh2d.c
diff --git a/tools/configure b/tools/configure
index 2f766d8..2c7443b 100755
--- a/tools/configure
+++ b/tools/configure
@@ -454,7 +454,8 @@ EOF
iriverbitmaptools="$toolset scramble descramble mkboot bmp2rb codepages"
iaudiobitmaptools="$toolset scramble descramble mkboot bmp2rb codepages"
ipodbitmaptools="$toolset scramble ipod_fw bmp2rb codepages"
- # generic is used by Gigabeat, IFP, H10, Sansa-e200
+ gigabeatbitmaptools="$toolset scramble descramble bmp2rb codepages"
+ # generic is used by IFP, H10, Sansa-e200
genericbitmaptools="$toolset bmp2rb codepages"
@@ -892,7 +893,7 @@ EOF
flash=""
plugins="yes"
codecs="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
- toolset=$genericbitmaptools
+ toolset=$gigabeatbitmaptools
# architecture, manufacturer and model for the target-tree build
t_cpu="arm"
t_manufacturer="gigabeat"
diff --git a/tools/descramble.c b/tools/descramble.c
index 9b76eaa..bfcf706 100644
--- a/tools/descramble.c
+++ b/tools/descramble.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "iriver.h"
+#include "gigabeat.h"
int iaudio_decode(char *iname, char *oname);
@@ -33,6 +34,7 @@ void usage(void)
"\t-v2 Archos V2 recorder format\n"
"\t-mm=X Archos Multimedia format (X values: A=JBMM, B=AV1xx, C=AV3xx)\n"
"\t-iriver iRiver format\n"
+ "\t-gigabeat Toshiba Gigabeat format\n"
"\t-iaudio iAudio format\n"
"\nNo option assumes Archos standard player/recorder format.\n");
exit(1);
@@ -73,6 +75,12 @@ int main (int argc, char** argv)
iriver_decode(iname, oname, FALSE, STRIP_NONE);
return 0;
}
+ if(!strcmp(argv[1], "-gigabeat")) {
+ iname = argv[2];
+ oname = argv[3];
+ gigabeat_code(iname, oname);
+ return 0;
+ }
if(!strcmp(argv[1], "-iaudio")) {
iname = argv[2];
diff --git a/tools/gigabeat.c b/tools/gigabeat.c
new file mode 100644
index 0000000..863d074
--- /dev/null
+++ b/tools/gigabeat.c
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Christian Hack
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static FILE * openinfile( const char * filename )
+{
+ FILE * F = fopen( filename, "rb" );
+ if( F == NULL )
+ {
+ fprintf( stderr, "Couldn't open input file %s\n", filename );
+ perror( "Error was " );
+ exit( -1 );
+ };
+ return F;
+};
+
+static FILE * openoutfile( const char * filename )
+{
+ FILE * F = fopen( filename, "wb" );
+ if( F == NULL )
+ {
+ fprintf( stderr, "Couldn't open output file %s\n", filename );
+ perror( "Error was " );
+ exit( -1 );
+ };
+ return F;
+};
+
+int gigabeat_code(char *infile, char *outfile)
+{
+ FILE *in, *out;
+ unsigned long size = 0;
+ unsigned long bytes_read;
+ unsigned long data;
+ unsigned long key = 0x19751217;
+
+ in = openinfile(infile);
+ out = openoutfile(outfile);
+
+ while (!feof(in)) {
+ bytes_read = fread(&data, 1, 4, in);
+
+ data = data ^ key;
+
+ key = key + (key << 1);
+ key = key + 0x19751217;
+
+ size += bytes_read;
+
+ fwrite(&data, 1, bytes_read, out);
+ }
+
+ fprintf(stderr, "File processed successfully\n" );
+
+ fclose(in);
+ fclose(out);
+ return(0);
+}
diff --git a/tools/gigabeat.h b/tools/gigabeat.h
new file mode 100644
index 0000000..c292014
--- /dev/null
+++ b/tools/gigabeat.h
@@ -0,0 +1,20 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Marcoen Hirschberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+int gigabeat_code(char *infile, char *outfile);
diff --git a/tools/scramble.c b/tools/scramble.c
index d1e3d1d..7d7465a 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -22,6 +22,7 @@
#include <stdbool.h>
#include <string.h>
#include "iriver.h"
+#include "gigabeat.h"
#include "mi4.h"
int iaudio_encode(char *iname, char *oname, char *idstring);
@@ -83,6 +84,7 @@ void usage(void)
"\t-ipod3g ipod firmware partition format (3rd Gen)\n"
"\t-ipod4g ipod firmware partition format (4th Gen, Mini, Nano, Photo/Color)\n"
"\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n"
+ "\t-gigabeat Toshiba Gigabeat format\n"
"\t-mi4v2 PortalPlayer .mi4 format (revision 010201)\n"
"\t-mi4v3 PortalPlayer .mi4 format (revision 010301)\n"
"\t-add=X Rockbox generic \"add-up\" checksum format\n"
@@ -219,6 +221,13 @@ int main (int argc, char** argv)
iriver_encode(iname, oname, FALSE);
return 0;
}
+ else if(!strcmp(argv[1], "-gigabeat")) {
+ /* iRiver code dealt with in the iriver.c code */
+ iname = argv[2];
+ oname = argv[3];
+ gigabeat_code(iname, oname);
+ return 0;
+ }
else if(!strcmp(argv[1], "-iaudiox5")) {
iname = argv[2];
oname = argv[3];