Mercurial > audlegacy
changeset 1196:ec7998847818 trunk
[svn] - some JMA stuff
author | nenolod |
---|---|
date | Tue, 13 Jun 2006 22:16:47 -0700 |
parents | b8e919aa6350 |
children | 09c4a19098fa |
files | ChangeLog Plugins/Input/console/Audacious_Driver.cpp Plugins/Input/console/Jma_File.cpp Plugins/Input/console/Jma_File.h |
diffstat | 4 files changed, 35 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Jun 13 21:23:52 2006 -0700 +++ b/ChangeLog Tue Jun 13 22:16:47 2006 -0700 @@ -1,3 +1,12 @@ +2006-06-14 04:23:52 +0000 William Pitcock <nenolod@nenolod.net> + revision [1300] + - Jma_File_Reader class + + + Changes: Modified: + +1 -0 trunk/Plugins/Input/console/Makefile.in + + 2006-06-14 03:37:25 +0000 William Pitcock <nenolod@nenolod.net> revision [1298] - add libjma (a hopefully portable snapshot of the ZSNES JMA implementation)
--- a/Plugins/Input/console/Audacious_Driver.cpp Tue Jun 13 21:23:52 2006 -0700 +++ b/Plugins/Input/console/Audacious_Driver.cpp Tue Jun 13 22:16:47 2006 -0700 @@ -32,6 +32,7 @@ #include "Track_Emu.h" #include "Vfs_File.h" #include "Gzip_File.h" +#include "Jma_File.h" #include "blargg_endian.h" //typedef Vfs_File_Reader Audacious_Reader; // will use VFS once it handles gzip transparently @@ -73,6 +74,7 @@ int length; // in msec, -1 = unknown int loop; // in msec, -1 = unknown, 0 = not looped int intro; // in msec, -1 = unknown + gchar *jma_spec; TitleInput* ti; }; @@ -394,7 +396,7 @@ // File identification -enum { type_none = 0, type_spc, type_nsf, type_nsfe, type_vgm, type_gbs, type_gym }; +enum { type_none = 0, type_spc, type_nsf, type_nsfe, type_vgm, type_gbs, type_gym, type_jma }; int const tag_size = 4; typedef char tag_t [tag_size]; @@ -413,6 +415,7 @@ if ( !memcmp( tag, "GYMX", 4 ) ) result = type_gym; if ( !memcmp( tag, "GBS" , 3 ) ) result = type_gbs; if ( !memcmp( tag, "Vgm ", 4 ) ) result = type_vgm; + if ( !memcmp( tag, "JMA" , 3 ) ) result = type_jma; return result; } @@ -583,22 +586,34 @@ // open and identify file unload_file(); Audacious_Reader in; + Jma_File_Reader in_jma; // to do: integrate somehow into Audacious_Reader (?) tag_t tag; // extract the subsong id from the virtual path gchar *path2 = g_strdup(path); gchar *_path = strchr(path2, '?'); + gchar *jmaspec = NULL; if (_path != NULL && *_path == '?') { *_path = '\0'; _path++; track = atoi(_path); + jmaspec = _path; } - if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) - return; int type = identify_file( path2, tag ); + + if ( type != type_jma ) + { + if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) + return; + } + else + { + if ( in_jma.open( path2, jmaspec ) || in.read( tag, sizeof tag ) ) + return; + } // setup info long sample_rate = 44100; @@ -620,6 +635,7 @@ case type_gym: load_file( tag, in, sample_rate, &info, (Gym_Emu*) 0 ); break; case type_vgm: load_file( tag, in, sample_rate, &info, (Vgm_Emu*) 0 ); break; case type_spc: load_file( tag, in, sample_rate, &info, (Spc_Emu*) 0 ); break; + case type_jma: load_file( tag, in_jma, sample_rate, &info, (Spc_Emu*) 0 ); break; } in.close(); if ( !emu )
--- a/Plugins/Input/console/Jma_File.cpp Tue Jun 13 21:23:52 2006 -0700 +++ b/Plugins/Input/console/Jma_File.cpp Tue Jun 13 22:16:47 2006 -0700 @@ -73,12 +73,14 @@ return size_; } -long Jma_File_Reader::read_avail( unsigned char* p, long s ) +long Jma_File_Reader::read_avail( void* p, long s ) { - p = new unsigned char[s]; + unsigned char *n = new unsigned char[s]; for (long i = 0; i < s; i++) - p[i] = *bufptr_++; + n[i] = *bufptr_++; + + p = (void *) n; return s; }
--- a/Plugins/Input/console/Jma_File.h Tue Jun 13 21:23:52 2006 -0700 +++ b/Plugins/Input/console/Jma_File.h Tue Jun 13 22:16:47 2006 -0700 @@ -26,6 +26,7 @@ #ifndef JMA_FILE_H #define JMA_FILE_H +#include "libjma/jma.h" #include "abstract_file.h" class Jma_File_Reader : public File_Reader { @@ -42,7 +43,7 @@ error_t open( const char *, const char* ); long size() const; - long read_avail( unsigned char*, long ); + long read_avail( void*, long ); long tell() const; error_t seek( long );