Mercurial > audlegacy
comparison Plugins/Input/console/Audacious_Driver.cpp @ 1198:311c4a27c3dd trunk
[svn] - yeah, JMA sucks -- i don't have the time for this
| author | nenolod |
|---|---|
| date | Tue, 13 Jun 2006 23:19:04 -0700 |
| parents | ec7998847818 |
| children | f1e57db353a3 |
comparison
equal
deleted
inserted
replaced
| 1197:09c4a19098fa | 1198:311c4a27c3dd |
|---|---|
| 30 #include "Spc_Emu.h" | 30 #include "Spc_Emu.h" |
| 31 | 31 |
| 32 #include "Track_Emu.h" | 32 #include "Track_Emu.h" |
| 33 #include "Vfs_File.h" | 33 #include "Vfs_File.h" |
| 34 #include "Gzip_File.h" | 34 #include "Gzip_File.h" |
| 35 #include "Jma_File.h" | |
| 36 #include "blargg_endian.h" | 35 #include "blargg_endian.h" |
| 37 | 36 |
| 38 //typedef Vfs_File_Reader Audacious_Reader; // will use VFS once it handles gzip transparently | 37 //typedef Vfs_File_Reader Audacious_Reader; // will use VFS once it handles gzip transparently |
| 39 typedef Gzip_File_Reader Audacious_Reader; | 38 typedef Gzip_File_Reader Audacious_Reader; |
| 40 | 39 |
| 72 { | 71 { |
| 73 int track; // track to get info for | 72 int track; // track to get info for |
| 74 int length; // in msec, -1 = unknown | 73 int length; // in msec, -1 = unknown |
| 75 int loop; // in msec, -1 = unknown, 0 = not looped | 74 int loop; // in msec, -1 = unknown, 0 = not looped |
| 76 int intro; // in msec, -1 = unknown | 75 int intro; // in msec, -1 = unknown |
| 77 gchar *jma_spec; | |
| 78 | 76 |
| 79 TitleInput* ti; | 77 TitleInput* ti; |
| 80 }; | 78 }; |
| 81 | 79 |
| 82 // NSFE | 80 // NSFE |
| 394 get_vgm_gd3( gd3.begin(), gd3.size(), out ); | 392 get_vgm_gd3( gd3.begin(), gd3.size(), out ); |
| 395 } | 393 } |
| 396 | 394 |
| 397 // File identification | 395 // File identification |
| 398 | 396 |
| 399 enum { type_none = 0, type_spc, type_nsf, type_nsfe, type_vgm, type_gbs, type_gym, type_jma }; | 397 enum { type_none = 0, type_spc, type_nsf, type_nsfe, type_vgm, type_gbs, type_gym }; |
| 400 | 398 |
| 401 int const tag_size = 4; | 399 int const tag_size = 4; |
| 402 typedef char tag_t [tag_size]; | 400 typedef char tag_t [tag_size]; |
| 403 | 401 |
| 404 static int identify_file( gchar* path, tag_t tag ) | 402 static int identify_file( gchar* path, tag_t tag ) |
| 413 if ( !memcmp( tag, "NESM", 4 ) ) result = type_nsf; | 411 if ( !memcmp( tag, "NESM", 4 ) ) result = type_nsf; |
| 414 if ( !memcmp( tag, "NSFE", 4 ) ) result = type_nsfe; | 412 if ( !memcmp( tag, "NSFE", 4 ) ) result = type_nsfe; |
| 415 if ( !memcmp( tag, "GYMX", 4 ) ) result = type_gym; | 413 if ( !memcmp( tag, "GYMX", 4 ) ) result = type_gym; |
| 416 if ( !memcmp( tag, "GBS" , 3 ) ) result = type_gbs; | 414 if ( !memcmp( tag, "GBS" , 3 ) ) result = type_gbs; |
| 417 if ( !memcmp( tag, "Vgm ", 4 ) ) result = type_vgm; | 415 if ( !memcmp( tag, "Vgm ", 4 ) ) result = type_vgm; |
| 418 if ( !memcmp( tag, "JMA" , 3 ) ) result = type_jma; | |
| 419 return result; | 416 return result; |
| 420 } | 417 } |
| 421 | 418 |
| 422 // Get info | 419 // Get info |
| 423 | 420 |
| 584 int track = 0; // to do: some way to select other tracks | 581 int track = 0; // to do: some way to select other tracks |
| 585 | 582 |
| 586 // open and identify file | 583 // open and identify file |
| 587 unload_file(); | 584 unload_file(); |
| 588 Audacious_Reader in; | 585 Audacious_Reader in; |
| 589 Jma_File_Reader in_jma; // to do: integrate somehow into Audacious_Reader (?) | |
| 590 tag_t tag; | 586 tag_t tag; |
| 591 | 587 |
| 592 // extract the subsong id from the virtual path | 588 // extract the subsong id from the virtual path |
| 593 gchar *path2 = g_strdup(path); | 589 gchar *path2 = g_strdup(path); |
| 594 gchar *_path = strchr(path2, '?'); | 590 gchar *_path = strchr(path2, '?'); |
| 595 gchar *jmaspec = NULL; | |
| 596 | 591 |
| 597 if (_path != NULL && *_path == '?') | 592 if (_path != NULL && *_path == '?') |
| 598 { | 593 { |
| 599 *_path = '\0'; | 594 *_path = '\0'; |
| 600 _path++; | 595 _path++; |
| 601 track = atoi(_path); | 596 track = atoi(_path); |
| 602 jmaspec = _path; | 597 } |
| 603 } | 598 |
| 604 | 599 if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) |
| 600 return; | |
| 605 int type = identify_file( path2, tag ); | 601 int type = identify_file( path2, tag ); |
| 606 | |
| 607 if ( type != type_jma ) | |
| 608 { | |
| 609 if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) | |
| 610 return; | |
| 611 } | |
| 612 else | |
| 613 { | |
| 614 if ( in_jma.open( path2, jmaspec ) || in.read( tag, sizeof tag ) ) | |
| 615 return; | |
| 616 } | |
| 617 | 602 |
| 618 // setup info | 603 // setup info |
| 619 long sample_rate = 44100; | 604 long sample_rate = 44100; |
| 620 if ( type == type_spc ) | 605 if ( type == type_spc ) |
| 621 sample_rate = Spc_Emu::native_sample_rate; | 606 sample_rate = Spc_Emu::native_sample_rate; |
| 633 case type_nsfe:load_file( tag, in, sample_rate, &info, (Nsfe_Emu*)0 ); break; | 618 case type_nsfe:load_file( tag, in, sample_rate, &info, (Nsfe_Emu*)0 ); break; |
| 634 case type_gbs: load_file( tag, in, sample_rate, &info, (Gbs_Emu*) 0 ); break; | 619 case type_gbs: load_file( tag, in, sample_rate, &info, (Gbs_Emu*) 0 ); break; |
| 635 case type_gym: load_file( tag, in, sample_rate, &info, (Gym_Emu*) 0 ); break; | 620 case type_gym: load_file( tag, in, sample_rate, &info, (Gym_Emu*) 0 ); break; |
| 636 case type_vgm: load_file( tag, in, sample_rate, &info, (Vgm_Emu*) 0 ); break; | 621 case type_vgm: load_file( tag, in, sample_rate, &info, (Vgm_Emu*) 0 ); break; |
| 637 case type_spc: load_file( tag, in, sample_rate, &info, (Spc_Emu*) 0 ); break; | 622 case type_spc: load_file( tag, in, sample_rate, &info, (Spc_Emu*) 0 ); break; |
| 638 case type_jma: load_file( tag, in_jma, sample_rate, &info, (Spc_Emu*) 0 ); break; | |
| 639 } | 623 } |
| 640 in.close(); | 624 in.close(); |
| 641 if ( !emu ) | 625 if ( !emu ) |
| 642 return; | 626 return; |
| 643 | 627 |
