Remove some utilities that should not be there anymore
This commit is contained in:
parent
0e844d4720
commit
16da5396aa
3 changed files with 0 additions and 338 deletions
|
@ -1,36 +0,0 @@
|
|||
#include "library/ogg.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if(argc != 2) {
|
||||
std::cerr << "Filename needed." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::ifstream s(argv[1], std::ios_base::binary);
|
||||
if(!s) {
|
||||
std::cerr << "Can't open '" << argv[1] << "'" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
ogg::stream_reader_iostreams r(s);
|
||||
ogg::page p;
|
||||
while(r.get_page(p)) {
|
||||
std::cout << "Ogg page: Stream " << p.get_stream() << " sequence " << p.get_sequence()
|
||||
<< " Flags: " << (p.get_continue() ? "CONTINUE " : "")
|
||||
<< (p.get_bos() ? "BOS " : "") << (p.get_eos() ? "EOS " : "")
|
||||
<< "granulepos=" << p.get_granulepos() << std::endl;
|
||||
size_t pc = p.get_packet_count();
|
||||
for(size_t i = 0; i < pc; i++) {
|
||||
auto pp = p.get_packet(i);
|
||||
std::cout << "Packet #" << i << ": " << pp.second << " bytes";
|
||||
if(i == 0 && p.get_continue())
|
||||
std::cout << " <continued>";
|
||||
if(i + 1 == pc && p.get_last_packet_incomplete())
|
||||
std::cout << " <incomplete>";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << "End of Ogg stream." << std::endl;
|
||||
return 0;
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
#include "lsnes.hpp"
|
||||
|
||||
#include "core/advdumper.hpp"
|
||||
#include "core/controller.hpp"
|
||||
#include "core/command.hpp"
|
||||
#include "core/dispatch.hpp"
|
||||
#include "core/mainloop.hpp"
|
||||
#include "core/framerate.hpp"
|
||||
#include "core/keymapper.hpp"
|
||||
#include "interface/romtype.hpp"
|
||||
#include "core/loadlib.hpp"
|
||||
#include "lua/lua.hpp"
|
||||
#include "core/mainloop.hpp"
|
||||
#include "core/messages.hpp"
|
||||
#include "core/misc.hpp"
|
||||
#include "core/instance.hpp"
|
||||
#include "core/moviedata.hpp"
|
||||
#include "core/random.hpp"
|
||||
#include "core/rom.hpp"
|
||||
#include "core/settings.hpp"
|
||||
#include "core/window.hpp"
|
||||
#include "library/string.hpp"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool hashing_in_progress = false;
|
||||
uint64_t hashing_left = 0;
|
||||
int64_t last_update = 0;
|
||||
|
||||
void hash_callback(uint64_t left, uint64_t total)
|
||||
{
|
||||
if(left == 0xFFFFFFFFFFFFFFFFULL) {
|
||||
hashing_in_progress = false;
|
||||
std::cout << "Done." << std::endl;
|
||||
last_update = framerate_regulator::get_utime() - 2000000;
|
||||
return;
|
||||
}
|
||||
if(!hashing_in_progress) {
|
||||
std::cout << "Hashing disc images..." << std::flush;
|
||||
}
|
||||
hashing_in_progress = true;
|
||||
hashing_left = left;
|
||||
int64_t this_update = framerate_regulator::get_utime();
|
||||
if(this_update < last_update - 1000000 || this_update > last_update + 1000000) {
|
||||
std::cout << ((hashing_left + 524288) >> 20) << "..." << std::flush;
|
||||
last_update = this_update;
|
||||
}
|
||||
}
|
||||
|
||||
void dump_what_was_loaded(loaded_rom& r, moviefile& f)
|
||||
{
|
||||
std::cout << "Core:\t" << r.get_core_identifier() << std::endl;
|
||||
std::cout << "System:\t" << r.get_hname() << std::endl;
|
||||
std::cout << "Region:\t" << r.region_get_hname() << std::endl;
|
||||
for(auto i = 0; i < ROM_SLOT_COUNT; i++) {
|
||||
std::string risha = r.romimg[i].sha_256.read();
|
||||
std::string rxsha = r.romxml[i].sha_256.read();
|
||||
std::string fisha = f.romimg_sha256[i];
|
||||
std::string fxsha = f.romxml_sha256[i];
|
||||
std::string finam = r.romimg[i].filename;
|
||||
std::string fxnam = r.romxml[i].filename;
|
||||
std::string nhint = f.namehint[i];
|
||||
if(risha != "" || rxsha != "" || fisha != "" || fxsha != "" || nhint != "") {
|
||||
std::cout << "ROM slot #" << i << ":" << std::endl;
|
||||
if(nhint != "")
|
||||
std::cout << "\tHint:\t" << nhint << std::endl;
|
||||
if(finam != "")
|
||||
std::cout << "\tFile:\t" << finam << std::endl;
|
||||
if(fxnam != "")
|
||||
std::cout << "\tXFile:\t" << fxnam << std::endl;
|
||||
if(risha != "" && fisha == risha)
|
||||
std::cout << "\tHash:\t" << risha << " (matches)" << std::endl;
|
||||
if(risha != "" && fisha != risha)
|
||||
std::cout << "\tHash:\t" << risha << " (ROM)" << std::endl;
|
||||
if(fisha != "" && fisha != risha)
|
||||
std::cout << "\tHash:\t" << risha << " (Movie)" << std::endl;
|
||||
if(rxsha != "" && fxsha == rxsha)
|
||||
std::cout << "\tXHash:\t" << rxsha << " (matches)" << std::endl;
|
||||
if(rxsha != "" && fxsha != rxsha)
|
||||
std::cout << "\tXHash:\t" << rxsha << " (ROM)" << std::endl;
|
||||
if(fxsha != "" && fxsha != rxsha)
|
||||
std::cout << "\tXHash:\t" << rxsha << " (Movie)" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
reached_main();
|
||||
std::vector<std::string> cmdline;
|
||||
for(int i = 1; i < argc; i++)
|
||||
cmdline.push_back(argv[i]);
|
||||
|
||||
set_random_seed();
|
||||
platform::init();
|
||||
|
||||
messages << "lsnes version: lsnes rr" << lsnes_version << std::endl;
|
||||
messages << "Command line is: ";
|
||||
for(auto k = cmdline.begin(); k != cmdline.end(); k++)
|
||||
messages << "\"" << *k << "\" ";
|
||||
messages << std::endl;
|
||||
|
||||
std::string cfgpath = get_config_path();
|
||||
autoload_libraries();
|
||||
|
||||
for(auto i : cmdline) {
|
||||
regex_results r;
|
||||
if(r = regex("--firmware-path=(.*)", i))
|
||||
try {
|
||||
lsnes_instance.setcache->set("firmwarepath", r[1]);
|
||||
std::cerr << "Set firmware path to '" << r[1] << "'" << std::endl;
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << "Can't set firmware path to '" << r[1] << "': " << e.what() << std::endl;
|
||||
}
|
||||
if(r = regex("--rom-path=(.*)", i))
|
||||
try {
|
||||
lsnes_instance.setcache->set("rompath", r[1]);
|
||||
std::cerr << "Set rompath path to '" << r[1] << "'" << std::endl;
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << "Can't set firmware path to '" << r[1] << "': " << e.what() << std::endl;
|
||||
}
|
||||
if(r = regex("--setting-(.*)=(.*)", i))
|
||||
try {
|
||||
lsnes_instance.setcache->set(r[1], r[2]);
|
||||
std::cerr << "Set " << r[1] << " to '" << r[2] << "'" << std::endl;
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << "Can't set " << r[1] << " to '" << r[2] << "': " << e.what()
|
||||
<< std::endl;
|
||||
}
|
||||
if(r = regex("--load-library=(.*)", i))
|
||||
try {
|
||||
with_loaded_library(*new loadlib::module(loadlib::library(r[1])));
|
||||
handle_post_loadlibrary();
|
||||
} catch(std::runtime_error& e) {
|
||||
std::cerr << "Can't load '" << r[1] << "': " << e.what() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
set_hasher_callback(hash_callback);
|
||||
|
||||
std::string movfn;
|
||||
for(auto i : cmdline) {
|
||||
if(i.length() > 0 && i[0] != '-') {
|
||||
movfn = i;
|
||||
}
|
||||
}
|
||||
|
||||
struct loaded_rom r;
|
||||
try {
|
||||
std::map<std::string, std::string> tmp;
|
||||
r = construct_rom(movfn, cmdline);
|
||||
r.load(tmp, 1000000000, 0);
|
||||
} catch(std::bad_alloc& e) {
|
||||
OOM_panic();
|
||||
} catch(std::exception& e) {
|
||||
messages << "FATAL: Can't load ROM: " << e.what() << std::endl;
|
||||
fatal_error();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
moviefile* movie = NULL;
|
||||
try {
|
||||
if(movfn != "")
|
||||
movie = new moviefile(movfn, r.get_internal_rom_type());
|
||||
} catch(std::bad_alloc& e) {
|
||||
OOM_panic();
|
||||
} catch(std::exception& e) {
|
||||
messages << "FATAL: Can't load movie: " << e.what() << std::endl;
|
||||
fatal_error();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dump_what_was_loaded(r, *movie);
|
||||
|
||||
lsnes_instance.mlogic->release_memory();
|
||||
lsnes_instance.buttons->cleanup();
|
||||
return 0;
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
#include "library/filesystem.hpp"
|
||||
#include "library/serialization.hpp"
|
||||
#include "library/string.hpp"
|
||||
#include <iostream>
|
||||
|
||||
struct stream_statistics
|
||||
{
|
||||
stream_statistics()
|
||||
{
|
||||
size = length = packets = clusters = 0;
|
||||
}
|
||||
stream_statistics operator+(const stream_statistics& s) const
|
||||
{
|
||||
stream_statistics r;
|
||||
r.size = size + s.size;
|
||||
r.length = length + s.length;
|
||||
r.packets = packets + s.packets;
|
||||
r.clusters = clusters + s.clusters;
|
||||
return r;
|
||||
}
|
||||
stream_statistics& operator+=(const stream_statistics& s)
|
||||
{
|
||||
*this = *this + s;
|
||||
return *this;
|
||||
}
|
||||
uint64_t size;
|
||||
uint64_t length;
|
||||
uint64_t packets;
|
||||
uint64_t clusters;
|
||||
};
|
||||
|
||||
stream_statistics dump_stream(filesystem& fs, uint32_t ccluster, uint32_t dcluster)
|
||||
{
|
||||
stream_statistics ss;
|
||||
uint32_t ctrl_c = ccluster;
|
||||
uint32_t ctrl_o = 0;
|
||||
uint32_t data_c = dcluster;
|
||||
uint32_t data_o = 0;
|
||||
ss.clusters = 2;
|
||||
while(true) {
|
||||
uint32_t ctrl_uc = ctrl_c;
|
||||
uint32_t ctrl_uo = ctrl_o;
|
||||
uint32_t data_uc = data_c;
|
||||
uint32_t data_uo = data_o;
|
||||
char buffer[4];
|
||||
size_t r = fs.read_data(ctrl_c, ctrl_o, buffer, 4);
|
||||
if(r < 4)
|
||||
break;
|
||||
uint16_t psize = serialization::u16b(buffer + 0);
|
||||
uint16_t plength = 120 * serialization::u8b(buffer + 2);
|
||||
if(!serialization::u8b(buffer + 3))
|
||||
break;
|
||||
r = fs.skip_data(data_c, data_o, psize);
|
||||
if(r < psize)
|
||||
(stringfmt() << "Unexpected end of data, read " << r << " bytes, expected "
|
||||
<< psize).throwex();
|
||||
ss.size += psize;
|
||||
ss.length += plength;
|
||||
ss.packets++;
|
||||
if(ctrl_uc != ctrl_c)
|
||||
ss.clusters++;
|
||||
if(data_uc != data_c)
|
||||
ss.clusters++;
|
||||
std::cout << "\tPacket: " << psize << " bytes@" << data_uc << ":" << data_uo << "(" << ctrl_uc
|
||||
<< ":" << ctrl_uo << "), " << plength << " samples." << std::endl;
|
||||
}
|
||||
std::cout << "\tTotal of " << ss.size << " bytes in " << ss.packets << " packets, " << ss.length
|
||||
<< " samples" << " (" << ss.clusters << " clusters used)" << std::endl;
|
||||
return ss;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
stream_statistics ss;
|
||||
if(argc != 2) {
|
||||
std::cerr << "Syntax: lsvsdump <filename>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
filesystem* fs;
|
||||
uint64_t stream_count = 0;
|
||||
try {
|
||||
fs = new filesystem(argv[1]);
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << "Can't load .lsvs file '" << argv[1] << "': " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
try {
|
||||
uint32_t maindir_c = 2;
|
||||
uint32_t maindir_o = 0;
|
||||
uint32_t maindir_uc;
|
||||
uint32_t maindir_uo;
|
||||
ss.clusters++;
|
||||
while(true) {
|
||||
maindir_uc = maindir_c;
|
||||
maindir_uo = maindir_o;
|
||||
char buffer[16];
|
||||
size_t r = fs->read_data(maindir_c, maindir_o, buffer, 16);
|
||||
if(r < 16)
|
||||
break;
|
||||
uint64_t stream_ts = serialization::u64b(buffer);
|
||||
uint32_t stream_c = serialization::u32b(buffer + 8);
|
||||
uint32_t stream_d = serialization::u32b(buffer + 12);
|
||||
if(!stream_c)
|
||||
continue;
|
||||
std::cout << "Found stream (from " << maindir_uc << ":" << maindir_uo << "): ts=" << stream_ts
|
||||
<< ", cluster=" << stream_c << "/" << stream_d << std::endl;
|
||||
auto ss2 = dump_stream(*fs, stream_c, stream_d);
|
||||
stream_count++;
|
||||
ss += ss2;
|
||||
if(maindir_c != maindir_uc)
|
||||
ss.clusters++;
|
||||
}
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << "Error reading .lsvs file '" << argv[1] << "': " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Totals: " << ss.size << " bytes in " << ss.packets << " packets in " << stream_count <<
|
||||
" streams, totalling " << ss.length << " samples. " << ss.clusters << " clusters used." << std::endl;
|
||||
delete fs;
|
||||
}
|
Loading…
Add table
Reference in a new issue