2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
Update to v091r11 release.
byuu says:
This release refines HSU1 support as a bidirectional protocol, nests SFC
manifests as "release/cartridge" and "release/information" (but release/
is not guaranteed to be finalized just yet), removes the database
integration, and adds support for ananke.
ananke represents inevitability. It's a library that, when installed,
higan can use to load files from the command-line, and also from a new
File -> Load Game menu option.
I need to change the build rules a bit for it to work on Windows (need
to make phoenix a DLL, basically), but it works now on Linux.
Right now, it only takes *.sfc file names, looks them up in the included
database, converts them to game folders, and returns the game folder
path for higan to load.
The idea is to continue expanding it to support everything we can that
I don't want in the higan core:
- load *.sfc, *.smc, *.swc, *.fig files
- remove SNES copier headers
- split apart merged firmware files
- pull in external firmware files (eg dsp1b.rom - these are staying
merged, just as SPC7110 prg+dat are merged)
- load *.zip and *.7z archives
- prompt for selection on multi-file archives
- generate manifest files based on heuristics
- apply BPS patches
The "Load" menu option has been renamed to "Library", to represent games
in your library. I'm going to add some sort of suffix to indicate
unverified games, and use a different folder icon for those (eg
manifests built on heuristics rather than from the database.)
So basically, to future end users:
File -> Load Game will be how they play games.
Library -> (specific system) can be thought of as an infinitely-sized
recent games list.
purify will likely become a simple stub that invokes ananke's functions.
No reason to duplicate all that code.
2012-11-05 08:22:50 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
#include <nall/beat/file.hpp>
|
|
|
|
|
|
|
|
namespace nall { namespace Beat {
|
|
|
|
|
|
|
|
struct Archive {
|
|
|
|
static auto create(const string& beatname, const string& pathname, const string& metadata = "") -> bool;
|
|
|
|
static auto unpack(const string& beatname, const string& pathname) -> bool;
|
|
|
|
static auto extract(const string& beatname, const string& pathname) -> vector<uint8_t>;
|
|
|
|
|
|
|
|
private:
|
2016-07-01 11:58:12 +00:00
|
|
|
static auto scan(string_vector& result, const string& basename, const string& pathname) -> void;
|
2015-07-14 09:32:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto Archive::create(const string& beatname, const string& pathname, const string& metadata) -> bool {
|
|
|
|
if(!beatname.endsWith(".bpa") || !pathname.endsWith("/")) return false; //protect against reversed arguments
|
|
|
|
|
|
|
|
File beat{beatname, file::mode::write};
|
|
|
|
if(!beat) return false; //file not writable?
|
|
|
|
|
|
|
|
beat.writes("BPA1");
|
|
|
|
beat.writevu(metadata.size());
|
|
|
|
beat.writes(metadata);
|
|
|
|
|
2016-07-01 11:58:12 +00:00
|
|
|
string_vector contents;
|
2015-07-14 09:32:43 +00:00
|
|
|
scan(contents, pathname, pathname);
|
|
|
|
|
|
|
|
for(auto& name : contents) {
|
2015-08-02 06:23:13 +00:00
|
|
|
string location{pathname, name};
|
|
|
|
bool directory = name.endsWith("/");
|
Update to v097r17 release.
byuu says:
Changelog:
- ruby: if DirectSoundCreate fails (no sound device present), return
false from init instead of crashing
- nall: improved edge case return values for
(basename,pathname,dirname,...)
- nall: renamed file_system_object class to inode
- nall: varuint_t replaced with VariadicNatural; which contains
.bit,.bits,.byte ala Natural/Integer
- nall: fixed boolean compilation error on Windows
- WS: popa should not restore SP
- GBA: rewrote the CPU/APU cores to use the .bit,.bits functions;
removed registers.cpp from each
Note that the GBA changes are extremely major. This is about five hours
worth of extremely delicate work. Any slight errors could break
emulation in extremely bad ways. Let's hold off on extensive testing
until the next WIP, after I do the same to the PPU.
So far ... endrift's SOUNDCNT_X I/O test is failing, although that code
didn't change, so clearly I messed up SOUNDCNT_H somehow ...
To compile on Windows:
1. change nall/string/platform.hpp line 47 to
return slice(result, 0, 3);
2. change ruby/video.wgl.cpp line 72 to
auto lock(uint32_t*& data, uint& pitch, uint width, uint height) -> bool {
3. add this line to the very top of hiro/windows/header.cpp:
#define boolean FuckYouMicrosoft
2016-02-23 11:08:44 +00:00
|
|
|
bool writable = inode::writable(location);
|
|
|
|
bool executable = inode::executable(location);
|
2016-05-16 09:51:12 +00:00
|
|
|
uint info = directory << 0 | writable << 1 | executable << 2 | (name.trimRight("/").size() - 1) << 3;
|
2015-08-02 06:23:13 +00:00
|
|
|
|
|
|
|
beat.writevu(info);
|
|
|
|
beat.writes(name);
|
|
|
|
if(directory) continue;
|
|
|
|
|
|
|
|
File input{location, file::mode::read};
|
|
|
|
if(input) {
|
2015-07-14 09:32:43 +00:00
|
|
|
auto size = input.size();
|
|
|
|
beat.writevu(size);
|
|
|
|
while(size--) beat.write(input.read());
|
2016-10-27 21:16:58 +00:00
|
|
|
beat.writel(input.checksum.digest().hex(), 4);
|
2015-08-02 06:23:13 +00:00
|
|
|
} else {
|
|
|
|
beat.writevu(0);
|
|
|
|
beat.writel(0x00000000, 4);
|
Update to v091r11 release.
byuu says:
This release refines HSU1 support as a bidirectional protocol, nests SFC
manifests as "release/cartridge" and "release/information" (but release/
is not guaranteed to be finalized just yet), removes the database
integration, and adds support for ananke.
ananke represents inevitability. It's a library that, when installed,
higan can use to load files from the command-line, and also from a new
File -> Load Game menu option.
I need to change the build rules a bit for it to work on Windows (need
to make phoenix a DLL, basically), but it works now on Linux.
Right now, it only takes *.sfc file names, looks them up in the included
database, converts them to game folders, and returns the game folder
path for higan to load.
The idea is to continue expanding it to support everything we can that
I don't want in the higan core:
- load *.sfc, *.smc, *.swc, *.fig files
- remove SNES copier headers
- split apart merged firmware files
- pull in external firmware files (eg dsp1b.rom - these are staying
merged, just as SPC7110 prg+dat are merged)
- load *.zip and *.7z archives
- prompt for selection on multi-file archives
- generate manifest files based on heuristics
- apply BPS patches
The "Load" menu option has been renamed to "Library", to represent games
in your library. I'm going to add some sort of suffix to indicate
unverified games, and use a different folder icon for those (eg
manifests built on heuristics rather than from the database.)
So basically, to future end users:
File -> Load Game will be how they play games.
Library -> (specific system) can be thought of as an infinitely-sized
recent games list.
purify will likely become a simple stub that invokes ananke's functions.
No reason to duplicate all that code.
2012-11-05 08:22:50 +00:00
|
|
|
}
|
2015-07-14 09:32:43 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 21:16:58 +00:00
|
|
|
beat.writel(beat.checksum.digest().hex(), 4);
|
2015-07-14 09:32:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Archive::unpack(const string& beatname, const string& pathname) -> bool {
|
|
|
|
if(!beatname.endsWith(".bpa") || !pathname.endsWith("/")) return false; //protect against reversed arguments
|
Update to v091r11 release.
byuu says:
This release refines HSU1 support as a bidirectional protocol, nests SFC
manifests as "release/cartridge" and "release/information" (but release/
is not guaranteed to be finalized just yet), removes the database
integration, and adds support for ananke.
ananke represents inevitability. It's a library that, when installed,
higan can use to load files from the command-line, and also from a new
File -> Load Game menu option.
I need to change the build rules a bit for it to work on Windows (need
to make phoenix a DLL, basically), but it works now on Linux.
Right now, it only takes *.sfc file names, looks them up in the included
database, converts them to game folders, and returns the game folder
path for higan to load.
The idea is to continue expanding it to support everything we can that
I don't want in the higan core:
- load *.sfc, *.smc, *.swc, *.fig files
- remove SNES copier headers
- split apart merged firmware files
- pull in external firmware files (eg dsp1b.rom - these are staying
merged, just as SPC7110 prg+dat are merged)
- load *.zip and *.7z archives
- prompt for selection on multi-file archives
- generate manifest files based on heuristics
- apply BPS patches
The "Load" menu option has been renamed to "Library", to represent games
in your library. I'm going to add some sort of suffix to indicate
unverified games, and use a different folder icon for those (eg
manifests built on heuristics rather than from the database.)
So basically, to future end users:
File -> Load Game will be how they play games.
Library -> (specific system) can be thought of as an infinitely-sized
recent games list.
purify will likely become a simple stub that invokes ananke's functions.
No reason to duplicate all that code.
2012-11-05 08:22:50 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
File beat{beatname, file::mode::read};
|
|
|
|
if(!beat) return false; //file not readable?
|
|
|
|
|
|
|
|
if(beat.reads(4) != "BPA1") return false;
|
|
|
|
auto size = beat.readvu();
|
|
|
|
while(size--) beat.read();
|
|
|
|
|
|
|
|
directory::create(pathname);
|
|
|
|
while(beat.offset() < beat.size() - 4) {
|
2015-08-02 06:23:13 +00:00
|
|
|
auto info = beat.readvu();
|
2015-11-08 08:54:42 +00:00
|
|
|
auto name = beat.reads((info >> 3) + 1);
|
2015-07-14 09:32:43 +00:00
|
|
|
if(name.find("\\") || name.find("../")) return false; //block path exploits
|
|
|
|
|
2015-08-02 06:23:13 +00:00
|
|
|
string location{pathname, name};
|
|
|
|
bool directory = info & 1;
|
2015-11-08 08:54:42 +00:00
|
|
|
bool writable = info & 2;
|
|
|
|
bool executable = info & 4;
|
2015-08-02 06:23:13 +00:00
|
|
|
|
|
|
|
if(directory) {
|
|
|
|
if(!nall::directory::create(location)) return false;
|
2015-07-14 09:32:43 +00:00
|
|
|
} else {
|
2015-08-02 06:23:13 +00:00
|
|
|
File output{location, file::mode::write};
|
2015-07-14 09:32:43 +00:00
|
|
|
if(!output) return false;
|
|
|
|
|
|
|
|
auto size = beat.readvu();
|
|
|
|
while(size--) output.write(beat.read());
|
2016-10-27 21:16:58 +00:00
|
|
|
if(beat.readl(4) != output.checksum.digest().hex()) return false;
|
2015-07-14 09:32:43 +00:00
|
|
|
}
|
Update to v091r11 release.
byuu says:
This release refines HSU1 support as a bidirectional protocol, nests SFC
manifests as "release/cartridge" and "release/information" (but release/
is not guaranteed to be finalized just yet), removes the database
integration, and adds support for ananke.
ananke represents inevitability. It's a library that, when installed,
higan can use to load files from the command-line, and also from a new
File -> Load Game menu option.
I need to change the build rules a bit for it to work on Windows (need
to make phoenix a DLL, basically), but it works now on Linux.
Right now, it only takes *.sfc file names, looks them up in the included
database, converts them to game folders, and returns the game folder
path for higan to load.
The idea is to continue expanding it to support everything we can that
I don't want in the higan core:
- load *.sfc, *.smc, *.swc, *.fig files
- remove SNES copier headers
- split apart merged firmware files
- pull in external firmware files (eg dsp1b.rom - these are staying
merged, just as SPC7110 prg+dat are merged)
- load *.zip and *.7z archives
- prompt for selection on multi-file archives
- generate manifest files based on heuristics
- apply BPS patches
The "Load" menu option has been renamed to "Library", to represent games
in your library. I'm going to add some sort of suffix to indicate
unverified games, and use a different folder icon for those (eg
manifests built on heuristics rather than from the database.)
So basically, to future end users:
File -> Load Game will be how they play games.
Library -> (specific system) can be thought of as an infinitely-sized
recent games list.
purify will likely become a simple stub that invokes ananke's functions.
No reason to duplicate all that code.
2012-11-05 08:22:50 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 21:16:58 +00:00
|
|
|
uint32_t checksum = beat.checksum.digest().hex();
|
2015-07-14 09:32:43 +00:00
|
|
|
return beat.readl(4) == checksum;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Archive::extract(const string& beatname, const string& filename) -> vector<uint8_t> {
|
|
|
|
File beat{beatname, file::mode::read};
|
|
|
|
if(!beat) return {}; //file not readable?
|
|
|
|
|
|
|
|
if(beat.reads(4) != "BPA1") return {};
|
|
|
|
auto size = beat.readvu();
|
|
|
|
beat.seek(beat.offset() + size);
|
|
|
|
|
|
|
|
while(beat.offset() < beat.size() - 4) {
|
2015-08-02 06:23:13 +00:00
|
|
|
auto info = beat.readvu();
|
2015-11-08 08:54:42 +00:00
|
|
|
auto name = beat.reads((info >> 3) + 1);
|
2015-08-02 06:23:13 +00:00
|
|
|
if(info & 1) continue; //ignore directories
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto size = beat.readvu();
|
|
|
|
if(name != filename) {
|
|
|
|
beat.seek(beat.offset() + size + 4);
|
|
|
|
continue;
|
Update to v091r11 release.
byuu says:
This release refines HSU1 support as a bidirectional protocol, nests SFC
manifests as "release/cartridge" and "release/information" (but release/
is not guaranteed to be finalized just yet), removes the database
integration, and adds support for ananke.
ananke represents inevitability. It's a library that, when installed,
higan can use to load files from the command-line, and also from a new
File -> Load Game menu option.
I need to change the build rules a bit for it to work on Windows (need
to make phoenix a DLL, basically), but it works now on Linux.
Right now, it only takes *.sfc file names, looks them up in the included
database, converts them to game folders, and returns the game folder
path for higan to load.
The idea is to continue expanding it to support everything we can that
I don't want in the higan core:
- load *.sfc, *.smc, *.swc, *.fig files
- remove SNES copier headers
- split apart merged firmware files
- pull in external firmware files (eg dsp1b.rom - these are staying
merged, just as SPC7110 prg+dat are merged)
- load *.zip and *.7z archives
- prompt for selection on multi-file archives
- generate manifest files based on heuristics
- apply BPS patches
The "Load" menu option has been renamed to "Library", to represent games
in your library. I'm going to add some sort of suffix to indicate
unverified games, and use a different folder icon for those (eg
manifests built on heuristics rather than from the database.)
So basically, to future end users:
File -> Load Game will be how they play games.
Library -> (specific system) can be thought of as an infinitely-sized
recent games list.
purify will likely become a simple stub that invokes ananke's functions.
No reason to duplicate all that code.
2012-11-05 08:22:50 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
vector<uint8_t> result;
|
|
|
|
result.resize(size);
|
|
|
|
beat.checksum.reset();
|
|
|
|
for(auto n : range(size)) result[n] = beat.read();
|
2016-10-27 21:16:58 +00:00
|
|
|
uint32_t checksum = beat.checksum.digest().hex();
|
2015-07-14 09:32:43 +00:00
|
|
|
if(beat.readl(4) != checksum) return {};
|
|
|
|
return result;
|
Update to v091r11 release.
byuu says:
This release refines HSU1 support as a bidirectional protocol, nests SFC
manifests as "release/cartridge" and "release/information" (but release/
is not guaranteed to be finalized just yet), removes the database
integration, and adds support for ananke.
ananke represents inevitability. It's a library that, when installed,
higan can use to load files from the command-line, and also from a new
File -> Load Game menu option.
I need to change the build rules a bit for it to work on Windows (need
to make phoenix a DLL, basically), but it works now on Linux.
Right now, it only takes *.sfc file names, looks them up in the included
database, converts them to game folders, and returns the game folder
path for higan to load.
The idea is to continue expanding it to support everything we can that
I don't want in the higan core:
- load *.sfc, *.smc, *.swc, *.fig files
- remove SNES copier headers
- split apart merged firmware files
- pull in external firmware files (eg dsp1b.rom - these are staying
merged, just as SPC7110 prg+dat are merged)
- load *.zip and *.7z archives
- prompt for selection on multi-file archives
- generate manifest files based on heuristics
- apply BPS patches
The "Load" menu option has been renamed to "Library", to represent games
in your library. I'm going to add some sort of suffix to indicate
unverified games, and use a different folder icon for those (eg
manifests built on heuristics rather than from the database.)
So basically, to future end users:
File -> Load Game will be how they play games.
Library -> (specific system) can be thought of as an infinitely-sized
recent games list.
purify will likely become a simple stub that invokes ananke's functions.
No reason to duplicate all that code.
2012-11-05 08:22:50 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
return {};
|
Update to v091r11 release.
byuu says:
This release refines HSU1 support as a bidirectional protocol, nests SFC
manifests as "release/cartridge" and "release/information" (but release/
is not guaranteed to be finalized just yet), removes the database
integration, and adds support for ananke.
ananke represents inevitability. It's a library that, when installed,
higan can use to load files from the command-line, and also from a new
File -> Load Game menu option.
I need to change the build rules a bit for it to work on Windows (need
to make phoenix a DLL, basically), but it works now on Linux.
Right now, it only takes *.sfc file names, looks them up in the included
database, converts them to game folders, and returns the game folder
path for higan to load.
The idea is to continue expanding it to support everything we can that
I don't want in the higan core:
- load *.sfc, *.smc, *.swc, *.fig files
- remove SNES copier headers
- split apart merged firmware files
- pull in external firmware files (eg dsp1b.rom - these are staying
merged, just as SPC7110 prg+dat are merged)
- load *.zip and *.7z archives
- prompt for selection on multi-file archives
- generate manifest files based on heuristics
- apply BPS patches
The "Load" menu option has been renamed to "Library", to represent games
in your library. I'm going to add some sort of suffix to indicate
unverified games, and use a different folder icon for those (eg
manifests built on heuristics rather than from the database.)
So basically, to future end users:
File -> Load Game will be how they play games.
Library -> (specific system) can be thought of as an infinitely-sized
recent games list.
purify will likely become a simple stub that invokes ananke's functions.
No reason to duplicate all that code.
2012-11-05 08:22:50 +00:00
|
|
|
}
|
|
|
|
|
2016-07-01 11:58:12 +00:00
|
|
|
auto Archive::scan(string_vector& result, const string& basename, const string& pathname) -> void {
|
2015-07-14 09:32:43 +00:00
|
|
|
for(auto& name : directory::contents(pathname)) {
|
2016-05-16 09:51:12 +00:00
|
|
|
result.append(string{pathname, name}.trimLeft(basename, 1L));
|
2015-07-14 09:32:43 +00:00
|
|
|
if(name.endsWith("/")) scan(result, basename, {pathname, name});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|