2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
2011-07-24 13:51:01 +00:00
|
|
|
|
2018-10-04 10:11:23 +00:00
|
|
|
#include <nall/file-map.hpp>
|
2011-07-24 13:51:01 +00:00
|
|
|
#include <nall/string.hpp>
|
|
|
|
#include <nall/vector.hpp>
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 10:10:46 +00:00
|
|
|
#include <nall/decode/inflate.hpp>
|
2011-07-24 13:51:01 +00:00
|
|
|
|
2019-01-16 00:46:42 +00:00
|
|
|
namespace nall::Decode {
|
2011-07-24 13:51:01 +00:00
|
|
|
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 10:10:46 +00:00
|
|
|
struct ZIP {
|
2011-07-24 13:51:01 +00:00
|
|
|
struct File {
|
|
|
|
string name;
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
const uint8_t* data;
|
2015-12-14 09:41:06 +00:00
|
|
|
uint size;
|
|
|
|
uint csize;
|
|
|
|
uint cmode; //0 = uncompressed, 8 = deflate
|
|
|
|
uint crc32;
|
Update to 20180729 release.
byuu wrote:
Sigh ...
asio.hpp needs #include <nall/windows/registry.hpp>
[Since the last WIP, byuu also posted the following message. -Ed.]
ruby drivers have all been updated (but not tested outside of BSD), and
I redesigned the settings window. The driver functionality all exists on
a new "Drivers" panel, the emulator/hack settings go to a
"Configuration" panel, and the video/audio panels lose driver settings.
As does the settings menu and its synchronize options.
I want to start pushing toward a v107 release. Critically, I will need
DirectSound and ALSA to support dynamic rate control. I'd also like to
eliminate the other system manifest.bml files. I need to update the
cheat code database format, and bundle at least a few quark shaders --
although I still need to default to Direct3D on Windows.
Turbo keys would be nice, if it's not too much effort. Aside from
netplay, it's the last significant feature I'm missing.
I think for v107, higan is going to be a bit rough around the edges
compared to bsnes. And I don't think it's practical to finish the bsnes
localization support.
I'm thinking we probably want another WIP to iron out any critical
issues, but this time there should be a feature freeze with the next
WIP.
2018-07-29 13:24:38 +00:00
|
|
|
time_t timestamp;
|
2011-07-24 13:51:01 +00:00
|
|
|
};
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
~ZIP() {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto open(const string& filename) -> bool {
|
2011-07-24 13:51:01 +00:00
|
|
|
close();
|
2018-10-04 10:11:23 +00:00
|
|
|
if(fm.open(filename, file::mode::read) == false) return false;
|
2011-07-24 13:51:01 +00:00
|
|
|
if(open(fm.data(), fm.size()) == false) {
|
|
|
|
fm.close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
auto open(const uint8_t* data, uint size) -> bool {
|
2011-07-24 13:51:01 +00:00
|
|
|
if(size < 22) return false;
|
|
|
|
|
|
|
|
filedata = data;
|
|
|
|
filesize = size;
|
|
|
|
|
|
|
|
file.reset();
|
|
|
|
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
const uint8_t* footer = data + size - 22;
|
2012-04-20 12:48:09 +00:00
|
|
|
while(true) {
|
|
|
|
if(footer <= data + 22) return false;
|
|
|
|
if(read(footer, 4) == 0x06054b50) {
|
2015-12-14 09:41:06 +00:00
|
|
|
uint commentlength = read(footer + 20, 2);
|
2012-04-20 12:48:09 +00:00
|
|
|
if(footer + 22 + commentlength == data + size) break;
|
|
|
|
}
|
|
|
|
footer--;
|
|
|
|
}
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
const uint8_t* directory = data + read(footer + 16, 4);
|
2011-07-24 13:51:01 +00:00
|
|
|
|
|
|
|
while(true) {
|
2015-12-14 09:41:06 +00:00
|
|
|
uint signature = read(directory + 0, 4);
|
2011-07-24 13:51:01 +00:00
|
|
|
if(signature != 0x02014b50) break;
|
|
|
|
|
|
|
|
File file;
|
|
|
|
file.cmode = read(directory + 10, 2);
|
|
|
|
file.crc32 = read(directory + 16, 4);
|
|
|
|
file.csize = read(directory + 20, 4);
|
|
|
|
file.size = read(directory + 24, 4);
|
|
|
|
|
Update to 20180729 release.
byuu wrote:
Sigh ...
asio.hpp needs #include <nall/windows/registry.hpp>
[Since the last WIP, byuu also posted the following message. -Ed.]
ruby drivers have all been updated (but not tested outside of BSD), and
I redesigned the settings window. The driver functionality all exists on
a new "Drivers" panel, the emulator/hack settings go to a
"Configuration" panel, and the video/audio panels lose driver settings.
As does the settings menu and its synchronize options.
I want to start pushing toward a v107 release. Critically, I will need
DirectSound and ALSA to support dynamic rate control. I'd also like to
eliminate the other system manifest.bml files. I need to update the
cheat code database format, and bundle at least a few quark shaders --
although I still need to default to Direct3D on Windows.
Turbo keys would be nice, if it's not too much effort. Aside from
netplay, it's the last significant feature I'm missing.
I think for v107, higan is going to be a bit rough around the edges
compared to bsnes. And I don't think it's practical to finish the bsnes
localization support.
I'm thinking we probably want another WIP to iron out any critical
issues, but this time there should be a feature freeze with the next
WIP.
2018-07-29 13:24:38 +00:00
|
|
|
uint16_t dosTime = read(directory + 12, 2);
|
|
|
|
uint16_t dosDate = read(directory + 14, 2);
|
|
|
|
tm info = {};
|
|
|
|
info.tm_sec = (dosTime >> 0 & 31) << 1;
|
|
|
|
info.tm_min = (dosTime >> 5 & 63);
|
|
|
|
info.tm_hour = (dosTime >> 11 & 31);
|
|
|
|
info.tm_mday = (dosDate >> 0 & 31);
|
|
|
|
info.tm_mon = (dosDate >> 5 & 15) - 1;
|
|
|
|
info.tm_year = (dosDate >> 9 & 127) + 80;
|
|
|
|
info.tm_isdst = -1;
|
|
|
|
file.timestamp = mktime(&info);
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
uint namelength = read(directory + 28, 2);
|
|
|
|
uint extralength = read(directory + 30, 2);
|
|
|
|
uint commentlength = read(directory + 32, 2);
|
2011-07-24 13:51:01 +00:00
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
char* filename = new char[namelength + 1];
|
2011-07-24 13:51:01 +00:00
|
|
|
memcpy(filename, directory + 46, namelength);
|
|
|
|
filename[namelength] = 0;
|
|
|
|
file.name = filename;
|
|
|
|
delete[] filename;
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
uint offset = read(directory + 42, 4);
|
|
|
|
uint offsetNL = read(data + offset + 26, 2);
|
|
|
|
uint offsetEL = read(data + offset + 28, 2);
|
2011-07-24 13:51:01 +00:00
|
|
|
file.data = data + offset + 30 + offsetNL + offsetEL;
|
|
|
|
|
|
|
|
directory += 46 + namelength + extralength + commentlength;
|
|
|
|
|
|
|
|
this->file.append(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
auto extract(File& file) -> vector<uint8_t> {
|
|
|
|
vector<uint8_t> buffer;
|
2011-07-24 13:51:01 +00:00
|
|
|
|
|
|
|
if(file.cmode == 0) {
|
2012-06-18 10:13:51 +00:00
|
|
|
buffer.resize(file.size);
|
|
|
|
memcpy(buffer.data(), file.data, file.size);
|
2011-07-24 13:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(file.cmode == 8) {
|
2012-06-18 10:13:51 +00:00
|
|
|
buffer.resize(file.size);
|
|
|
|
if(inflate(buffer.data(), buffer.size(), file.data, file.csize) == false) {
|
|
|
|
buffer.reset();
|
2011-07-24 13:51:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-18 10:13:51 +00:00
|
|
|
return buffer;
|
2011-07-24 13:51:01 +00:00
|
|
|
}
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
auto close() -> void {
|
2018-10-04 10:11:23 +00:00
|
|
|
if(fm) fm.close();
|
2011-07-24 13:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-10-04 10:11:23 +00:00
|
|
|
file_map fm;
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
const uint8_t* filedata;
|
2015-12-14 09:41:06 +00:00
|
|
|
uint filesize;
|
2011-07-24 13:51:01 +00:00
|
|
|
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
auto read(const uint8_t* data, uint size) -> uint {
|
2015-12-14 09:41:06 +00:00
|
|
|
uint result = 0, shift = 0;
|
2011-07-24 13:51:01 +00:00
|
|
|
while(size--) { result |= *data++ << shift; shift += 8; }
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-01-26 06:50:09 +00:00
|
|
|
vector<File> file;
|
2011-07-24 13:51:01 +00:00
|
|
|
};
|
|
|
|
|
2019-01-16 00:46:42 +00:00
|
|
|
}
|