2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
2011-07-24 13:51:01 +00:00
|
|
|
|
|
|
|
#include <nall/filemap.hpp>
|
|
|
|
#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
|
|
|
|
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
|
|
|
namespace nall { namespace 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;
|
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();
|
|
|
|
if(fm.open(filename, filemap::mode::read) == false) return false;
|
|
|
|
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);
|
|
|
|
|
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 {
|
2011-07-24 13:51:01 +00:00
|
|
|
if(fm.open()) fm.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
filemap 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
|
|
|
};
|
|
|
|
|
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
|
|
|
}}
|