mirror of https://github.com/bsnes-emu/bsnes.git
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.
This commit is contained in:
parent
6c83329cae
commit
0d0af39b44
|
@ -4,9 +4,27 @@
|
|||
#include <nall/dsp.hpp>
|
||||
using namespace nall;
|
||||
|
||||
//todo: update code to support Natural<8,16,32>
|
||||
//using int8 = Integer<8>;
|
||||
//using int16 = Integer<16>;
|
||||
//using int32 = Integer<32>;
|
||||
//using int64 = Integer<64>;
|
||||
//using uint32 = Natural<32>;
|
||||
//using uint64 = Natural<64>;
|
||||
|
||||
using int8 = int8_t;
|
||||
using int16 = int16_t;
|
||||
using int32 = int32_t;
|
||||
using int64 = int64_t;
|
||||
using uint8 = uint8_t;
|
||||
using uint16 = uint16_t;
|
||||
using uint32 = uint32_t;
|
||||
using uint64 = uint64_t;
|
||||
using varuint = varuint_t<uint>;
|
||||
|
||||
namespace Emulator {
|
||||
static const string Name = "higan";
|
||||
static const string Version = "097.13";
|
||||
static const string Version = "097.14";
|
||||
static const string Author = "byuu";
|
||||
static const string License = "GPLv3";
|
||||
static const string Website = "http://byuu.org/";
|
||||
|
@ -52,5 +70,3 @@ template<typename R, typename... P> struct hook<auto (P...) -> R> {
|
|||
#else
|
||||
#define privileged private
|
||||
#endif
|
||||
|
||||
using varuint = varuint_t<uint>;
|
||||
|
|
|
@ -44,12 +44,12 @@ auto ARM::load(unsigned mode, uint32 addr) -> uint32 {
|
|||
|
||||
if(mode & Half) {
|
||||
addr &= 1;
|
||||
word = mode & Signed ? (int16)word : (uint16)word;
|
||||
word = mode & Signed ? (int16_t)word : (uint16_t)word;
|
||||
}
|
||||
|
||||
if(mode & Byte) {
|
||||
addr &= 0;
|
||||
word = mode & Signed ? (int8)word : (uint8)word;
|
||||
word = mode & Signed ? (int8_t)word : (uint8_t)word;
|
||||
}
|
||||
|
||||
if(mode & Signed) {
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
struct GPR {
|
||||
inline operator uint32() const { return data; }
|
||||
inline auto operator=(uint32 n) { data = n; if(modify) modify(); return *this; }
|
||||
inline operator uint32_t() const { return data; }
|
||||
inline auto operator=(uint32_t n) { data = n; if(modify) modify(); return *this; }
|
||||
inline auto operator=(const GPR& source) { return operator=(source.data); }
|
||||
|
||||
inline auto operator &=(uint32 n) { return operator=(data & n); }
|
||||
inline auto operator |=(uint32 n) { return operator=(data | n); }
|
||||
inline auto operator ^=(uint32 n) { return operator=(data ^ n); }
|
||||
inline auto operator +=(uint32 n) { return operator=(data + n); }
|
||||
inline auto operator -=(uint32 n) { return operator=(data - n); }
|
||||
inline auto operator *=(uint32 n) { return operator=(data * n); }
|
||||
inline auto operator /=(uint32 n) { return operator=(data / n); }
|
||||
inline auto operator %=(uint32 n) { return operator=(data % n); }
|
||||
inline auto operator<<=(uint32 n) { return operator=(data << n); }
|
||||
inline auto operator>>=(uint32 n) { return operator=(data >> n); }
|
||||
inline auto operator &=(uint32_t n) { return operator=(data & n); }
|
||||
inline auto operator |=(uint32_t n) { return operator=(data | n); }
|
||||
inline auto operator ^=(uint32_t n) { return operator=(data ^ n); }
|
||||
inline auto operator +=(uint32_t n) { return operator=(data + n); }
|
||||
inline auto operator -=(uint32_t n) { return operator=(data - n); }
|
||||
inline auto operator *=(uint32_t n) { return operator=(data * n); }
|
||||
inline auto operator /=(uint32_t n) { return operator=(data / n); }
|
||||
inline auto operator %=(uint32_t n) { return operator=(data % n); }
|
||||
inline auto operator<<=(uint32_t n) { return operator=(data << n); }
|
||||
inline auto operator>>=(uint32_t n) { return operator=(data >> n); }
|
||||
|
||||
uint32 data = 0;
|
||||
uint32_t data = 0;
|
||||
function<auto () -> void> modify;
|
||||
};
|
||||
|
||||
struct PSR {
|
||||
inline operator uint32() const {
|
||||
inline operator uint32_t() const {
|
||||
return (n << 31) + (z << 30) + (c << 29) + (v << 28)
|
||||
+ (i << 7) + (f << 6) + (t << 5) + (m << 0);
|
||||
}
|
||||
|
||||
inline auto operator=(uint32 d) {
|
||||
inline auto operator=(uint32_t d) {
|
||||
n = d & (1 << 31);
|
||||
z = d & (1 << 30);
|
||||
c = d & (1 << 29);
|
||||
|
@ -45,7 +45,7 @@ struct PSR {
|
|||
bool i = false; //irq
|
||||
bool f = false; //fiq
|
||||
bool t = false; //thumb
|
||||
unsigned m = 0; //mode
|
||||
uint m = 0; //mode
|
||||
};
|
||||
|
||||
struct Pipeline {
|
||||
|
@ -120,7 +120,7 @@ Processor processor;
|
|||
Pipeline pipeline;
|
||||
bool crash = false;
|
||||
|
||||
alwaysinline auto r(unsigned n) -> GPR& { return *processor.r[n]; }
|
||||
alwaysinline auto r(uint n) -> GPR& { return *processor.r[n]; }
|
||||
alwaysinline auto cpsr() -> PSR& { return processor.cpsr; }
|
||||
alwaysinline auto spsr() -> PSR& { return *processor.spsr; }
|
||||
alwaysinline auto carryout() -> bool& { return processor.carryout; }
|
||||
|
|
|
@ -14,8 +14,8 @@ struct R65816 {
|
|||
using fp = auto (R65816::*)() -> void;
|
||||
|
||||
virtual auto op_io() -> void = 0;
|
||||
virtual auto op_read(uint32_t addr) -> uint8_t = 0;
|
||||
virtual auto op_write(uint32_t addr, uint8_t data) -> void = 0;
|
||||
virtual auto op_read(uint32 addr) -> uint8 = 0;
|
||||
virtual auto op_write(uint32 addr, uint8 data) -> void = 0;
|
||||
virtual auto last_cycle() -> void = 0;
|
||||
virtual auto interrupt_pending() -> bool = 0;
|
||||
virtual auto op_irq() -> void;
|
||||
|
|
|
@ -55,8 +55,8 @@ auto V30MZ::alDiv(Size size, uint32 x, uint32 y) -> uint32 {
|
|||
|
||||
auto V30MZ::alDivi(Size size, int32 x, int32 y) -> uint32 {
|
||||
if(y == 0) return interrupt(0), 0;
|
||||
x = size == Byte ? (int8)x : (int16)x;
|
||||
y = size == Byte ? (int8)y : (int16)y;
|
||||
x = size == Byte ? (int8_t)x : (int16_t)x;
|
||||
y = size == Byte ? (int8_t)y : (int16_t)y;
|
||||
uint32 quotient = x / y;
|
||||
uint32 remainder = x % y;
|
||||
return (remainder & mask) << bits | (quotient & mask);
|
||||
|
@ -80,8 +80,8 @@ auto V30MZ::alMul(Size size, uint16 x, uint16 y) -> uint32 {
|
|||
}
|
||||
|
||||
auto V30MZ::alMuli(Size size, int16 x, int16 y) -> uint32 {
|
||||
x = size == Byte ? (int8)x : (int16)x;
|
||||
y = size == Byte ? (int8)y : (int16)y;
|
||||
x = size == Byte ? (int8_t)x : (int16_t)x;
|
||||
y = size == Byte ? (int8_t)y : (int16_t)y;
|
||||
uint32 result = x * y;
|
||||
r.f.c = result >> bits;
|
||||
r.f.v = result >> bits;
|
||||
|
|
|
@ -134,7 +134,7 @@ auto V30MZ::opTestMemReg(Size size) {
|
|||
auto V30MZ::opMultiplySignedRegMemImm(Size size) {
|
||||
wait(2);
|
||||
modRM();
|
||||
setReg(size, alMuli(size, getMem(size), size == Word ? (int16)fetch(Word) : (int8)fetch(Byte)));
|
||||
setReg(size, alMuli(size, getMem(size), size == Word ? (int16_t)fetch(Word) : (int8_t)fetch(Byte)));
|
||||
}
|
||||
|
||||
//40 inc ax
|
||||
|
|
|
@ -185,7 +185,7 @@ auto V30MZ::opPopAll() {
|
|||
//68 push imm16
|
||||
//6a push imm8s
|
||||
auto V30MZ::opPushImm(Size size) {
|
||||
push(size == Word ? fetch(Word) : (int8)fetch(Byte));
|
||||
push(size == Word ? fetch(Word) : (int8_t)fetch(Byte));
|
||||
}
|
||||
|
||||
auto V30MZ::opPopMem() {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
auto V30MZ::opGroup1MemImm(Size size, bool sign) {
|
||||
modRM();
|
||||
auto mem = getMem(size);
|
||||
auto imm = sign ? (int8)fetch() : size == Byte ? fetch() : fetch(Word);
|
||||
auto imm = sign ? (int8_t)fetch() : size == Byte ? fetch() : fetch(Word);
|
||||
switch(modrm.reg) {
|
||||
case 0: setMem(size, alAdd(size, mem, imm)); break;
|
||||
case 1: setMem(size, alOr (size, mem, imm)); break;
|
||||
|
|
|
@ -9,7 +9,7 @@ Gamepad::Gamepad(bool port) : Controller(port) {
|
|||
|
||||
auto Gamepad::data() -> uint2 {
|
||||
if(counter >= 16) return 1;
|
||||
if(latched == 1) return interface->inputPoll(port, (unsigned)Device::ID::Gamepad, B);
|
||||
if(latched == 1) return interface->inputPoll(port, (uint)Device::ID::Gamepad, B);
|
||||
|
||||
//note: D-pad physically prevents up+down and left+right from being pressed at the same time
|
||||
switch(counter++) {
|
||||
|
@ -36,7 +36,7 @@ auto Gamepad::latch(bool data) -> void {
|
|||
counter = 0;
|
||||
|
||||
if(latched == 0) {
|
||||
auto id = (unsigned)Device::ID::Gamepad;
|
||||
auto id = (uint)Device::ID::Gamepad;
|
||||
b = interface->inputPoll(port, id, B);
|
||||
y = interface->inputPoll(port, id, Y);
|
||||
select = interface->inputPoll(port, id, Select);
|
||||
|
|
|
@ -10,7 +10,7 @@ struct Gamepad : Controller {
|
|||
|
||||
private:
|
||||
bool latched;
|
||||
unsigned counter;
|
||||
uint counter;
|
||||
|
||||
bool b, y, select, start;
|
||||
bool up, down, left, right;
|
||||
|
|
|
@ -112,13 +112,13 @@ auto SA1::op_io() -> void {
|
|||
tick();
|
||||
}
|
||||
|
||||
auto SA1::op_read(uint addr) -> uint8 {
|
||||
auto SA1::op_read(uint32 addr) -> uint8 {
|
||||
tick();
|
||||
if(((addr & 0x40e000) == 0x006000) || ((addr & 0xd00000) == 0x400000)) tick();
|
||||
return bus_read(addr, regs.mdr);
|
||||
}
|
||||
|
||||
auto SA1::op_write(uint addr, uint8 data) -> void {
|
||||
auto SA1::op_write(uint32 addr, uint8 data) -> void {
|
||||
tick();
|
||||
if(((addr & 0x40e000) == 0x006000) || ((addr & 0xd00000) == 0x400000)) tick();
|
||||
bus_write(addr, regs.mdr = data);
|
||||
|
|
|
@ -3,8 +3,8 @@ auto bus_write(uint addr, uint8 data) -> void;
|
|||
auto vbr_read(uint addr, uint8 data = 0) -> uint8;
|
||||
|
||||
alwaysinline auto op_io() -> void;
|
||||
alwaysinline auto op_read(uint addr) -> uint8;
|
||||
alwaysinline auto op_write(uint addr, uint8 data) -> void;
|
||||
alwaysinline auto op_read(uint32 addr) -> uint8;
|
||||
alwaysinline auto op_write(uint32 addr, uint8 data) -> void;
|
||||
|
||||
auto mmcrom_read(uint addr, uint8 data) -> uint8;
|
||||
auto mmcrom_write(uint addr, uint8 data) -> void;
|
||||
|
|
|
@ -18,10 +18,10 @@ DSP dsp;
|
|||
#include "serialization.cpp"
|
||||
|
||||
DSP::DSP() {
|
||||
static_assert(sizeof(signed) >= 32 / 8, "signed >= 32-bits");
|
||||
static_assert((int8)0x80 == -0x80, "8-bit sign extension");
|
||||
static_assert((int16)0x8000 == -0x8000, "16-bit sign extension");
|
||||
static_assert((uint16)0xffff0000 == 0, "16-bit unsigned clip");
|
||||
static_assert(sizeof(int) >= 32 / 8, "int >= 32-bits");
|
||||
static_assert((int8_t)0x80 == -0x80, "8-bit sign extension");
|
||||
static_assert((int16_t)0x8000 == -0x8000, "16-bit sign extension");
|
||||
static_assert((uint16_t)0xffff0000 == 0, "16-bit unsigned clip");
|
||||
static_assert((-1 >> 1) == -1, "arithmetic shift right");
|
||||
|
||||
//-0x8000 <= n <= +0x7fff
|
||||
|
|
|
@ -133,7 +133,7 @@ auto Video::drawCursor(uint32 color, int x, int y) -> void {
|
|||
if(vx < 0 || vx >= 256) continue; //do not draw offscreen
|
||||
uint8 pixel = cursor[cy * 15 + cx];
|
||||
if(pixel == 0) continue;
|
||||
uint32 pixelcolor = pixel == 1 ? 0xff000000 : color;
|
||||
uint32 pixelcolor = pixel == 1 ? (uint32)(255 << 24) : color;
|
||||
|
||||
*(output + vy * 1024 + vx * 2 + 0) = pixelcolor;
|
||||
*(output + vy * 1024 + vx * 2 + 1) = pixelcolor;
|
||||
|
|
|
@ -210,7 +210,7 @@ auto InputManager::poll() -> void {
|
|||
if(presentation && presentation->focused()) pollHotkeys();
|
||||
}
|
||||
|
||||
auto InputManager::onChange(shared_pointer<HID::Device> device, uint group, uint input, int16 oldValue, int16 newValue) -> void {
|
||||
auto InputManager::onChange(shared_pointer<HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue) -> void {
|
||||
if(settingsManager->focused()) {
|
||||
settingsManager->input.inputEvent(device, group, input, oldValue, newValue);
|
||||
settingsManager->hotkeys.inputEvent(device, group, input, oldValue, newValue);
|
||||
|
|
|
@ -48,7 +48,7 @@ struct InputManager {
|
|||
InputManager();
|
||||
auto bind() -> void;
|
||||
auto poll() -> void;
|
||||
auto onChange(shared_pointer<HID::Device> device, uint group, uint input, int16 oldValue, int16 newValue) -> void;
|
||||
auto onChange(shared_pointer<HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue) -> void;
|
||||
auto quit() -> void;
|
||||
|
||||
auto findMouse() -> shared_pointer<HID::Device>;
|
||||
|
|
|
@ -260,11 +260,11 @@ auto Presentation::toggleFullScreen() -> void {
|
|||
|
||||
auto Presentation::drawSplashScreen() -> void {
|
||||
if(!video) return;
|
||||
uint32* output;
|
||||
uint32_t* output;
|
||||
uint length;
|
||||
if(video->lock(output, length, 256, 240)) {
|
||||
for(auto y : range(240)) {
|
||||
uint32* dp = output + y * (length >> 2);
|
||||
auto dp = output + y * (length >> 2);
|
||||
for(auto x : range(256)) *dp++ = 0xff000000;
|
||||
}
|
||||
video->unlock();
|
||||
|
|
|
@ -46,7 +46,7 @@ auto Program::saveRequest(uint id, string filename) -> void {
|
|||
}
|
||||
|
||||
auto Program::videoRefresh(const uint32* data, uint pitch, uint width, uint height) -> void {
|
||||
uint32* output;
|
||||
uint32_t* output;
|
||||
uint length;
|
||||
|
||||
if(video->lock(output, length, width, height)) {
|
||||
|
|
|
@ -81,7 +81,7 @@ auto CPU::portWrite(uint16 addr, uint8 data) -> void {
|
|||
|
||||
//INT_BASE
|
||||
if(addr == 0x00b0) {
|
||||
r.interruptBase = WS() ? (data & ~7) : (data & ~1);
|
||||
r.interruptBase = WS() ? data & ~7 : data & ~1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ auto mCanvas::color() const -> Color {
|
|||
return state.color;
|
||||
}
|
||||
|
||||
auto mCanvas::data() -> uint32* {
|
||||
return (uint32*)state.icon.data();
|
||||
auto mCanvas::data() -> uint32_t* {
|
||||
return (uint32_t*)state.icon.data();
|
||||
}
|
||||
|
||||
auto mCanvas::droppable() const -> bool {
|
||||
|
|
|
@ -15,7 +15,7 @@ struct MessageDialog {
|
|||
private:
|
||||
struct State {
|
||||
lstring buttons;
|
||||
vector<uint8> icon;
|
||||
vector<uint8_t> icon;
|
||||
sWindow parent;
|
||||
string response;
|
||||
string text;
|
||||
|
|
|
@ -156,7 +156,7 @@ auto pCanvas::_rasterize() -> void {
|
|||
auto buffer = (uint32_t*)gdk_pixbuf_get_pixels(surface);
|
||||
|
||||
if(auto& icon = state().icon) {
|
||||
memory::copy(buffer, state().icon.data(), width * height * sizeof(uint32));
|
||||
memory::copy(buffer, state().icon.data(), width * height * sizeof(uint32_t));
|
||||
} else if(auto& gradient = state().gradient) {
|
||||
auto& colors = gradient.state.colors;
|
||||
image fill;
|
||||
|
@ -164,13 +164,13 @@ auto pCanvas::_rasterize() -> void {
|
|||
fill.gradient(colors[0].value(), colors[1].value(), colors[2].value(), colors[3].value());
|
||||
memory::copy(buffer, fill.data(), fill.size());
|
||||
} else {
|
||||
uint32 color = state().color.value();
|
||||
uint32_t color = state().color.value();
|
||||
for(auto n : range(width * height)) buffer[n] = color;
|
||||
}
|
||||
|
||||
//ARGB -> ABGR conversion
|
||||
for(auto n : range(width * height)) {
|
||||
uint32 color = *buffer;
|
||||
uint32_t color = *buffer;
|
||||
color = (color & 0xff00ff00) | ((color & 0xff0000) >> 16) | ((color & 0x0000ff) << 16);
|
||||
*buffer++ = color;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
auto Icarus::bsMemoryManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
return bsMemoryManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::bsMemoryManifest(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::bsMemoryManifest(vector<uint8_t>& buffer, string location) -> string {
|
||||
string markup;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -31,7 +31,7 @@ auto Icarus::bsMemoryManifest(vector<uint8>& buffer, string location) -> string
|
|||
return markup;
|
||||
}
|
||||
|
||||
auto Icarus::bsMemoryImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::bsMemoryImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "BS Memory/", name, ".bs/"};
|
||||
|
|
|
@ -77,7 +77,7 @@ auto Icarus::import(string location) -> string {
|
|||
return failure("unrecognized file extension");
|
||||
}
|
||||
|
||||
auto Icarus::concatenate(vector<uint8>& output, string location) -> void {
|
||||
auto Icarus::concatenate(vector<uint8_t>& output, string location) -> void {
|
||||
if(auto input = file::read(location)) {
|
||||
auto size = output.size();
|
||||
output.resize(size + input.size());
|
||||
|
|
|
@ -9,53 +9,53 @@ struct Icarus {
|
|||
auto manifest(string location) -> string;
|
||||
auto import(string location) -> string;
|
||||
|
||||
auto concatenate(vector<uint8>& output, string location) -> void;
|
||||
auto concatenate(vector<uint8_t>& output, string location) -> void;
|
||||
|
||||
//famicom.cpp
|
||||
auto famicomManifest(string location) -> string;
|
||||
auto famicomManifest(vector<uint8>& buffer, string location, uint* prgrom = nullptr, uint* chrrom = nullptr) -> string;
|
||||
auto famicomImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto famicomManifest(vector<uint8_t>& buffer, string location, uint* prgrom = nullptr, uint* chrrom = nullptr) -> string;
|
||||
auto famicomImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
//super-famicom.cpp
|
||||
auto superFamicomManifest(string location) -> string;
|
||||
auto superFamicomManifest(vector<uint8>& buffer, string location, bool* firmwareAppended = nullptr) -> string;
|
||||
auto superFamicomManifest(vector<uint8_t>& buffer, string location, bool* firmwareAppended = nullptr) -> string;
|
||||
auto superFamicomManifestScan(vector<Markup::Node>& roms, Markup::Node node) -> void;
|
||||
auto superFamicomImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto superFamicomImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
//game-boy.cpp
|
||||
auto gameBoyManifest(string location) -> string;
|
||||
auto gameBoyManifest(vector<uint8>& buffer, string location) -> string;
|
||||
auto gameBoyImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto gameBoyManifest(vector<uint8_t>& buffer, string location) -> string;
|
||||
auto gameBoyImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
//game-boy-color.cpp
|
||||
auto gameBoyColorManifest(string location) -> string;
|
||||
auto gameBoyColorManifest(vector<uint8>& buffer, string location) -> string;
|
||||
auto gameBoyColorImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto gameBoyColorManifest(vector<uint8_t>& buffer, string location) -> string;
|
||||
auto gameBoyColorImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
//game-boy-advance.cpp
|
||||
auto gameBoyAdvanceManifest(string location) -> string;
|
||||
auto gameBoyAdvanceManifest(vector<uint8>& buffer, string location) -> string;
|
||||
auto gameBoyAdvanceImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto gameBoyAdvanceManifest(vector<uint8_t>& buffer, string location) -> string;
|
||||
auto gameBoyAdvanceImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
//bs-memory.cpp
|
||||
auto bsMemoryManifest(string location) -> string;
|
||||
auto bsMemoryManifest(vector<uint8>& buffer, string location) -> string;
|
||||
auto bsMemoryImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto bsMemoryManifest(vector<uint8_t>& buffer, string location) -> string;
|
||||
auto bsMemoryImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
//sufami-turbo.cpp
|
||||
auto sufamiTurboManifest(string location) -> string;
|
||||
auto sufamiTurboManifest(vector<uint8>& buffer, string location) -> string;
|
||||
auto sufamiTurboImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto sufamiTurboManifest(vector<uint8_t>& buffer, string location) -> string;
|
||||
auto sufamiTurboImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
//wonderswan.cpp
|
||||
auto wonderSwanManifest(string location) -> string;
|
||||
auto wonderSwanManifest(vector<uint8>& buffer, string location) -> string;
|
||||
auto wonderSwanImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto wonderSwanManifest(vector<uint8_t>& buffer, string location) -> string;
|
||||
auto wonderSwanImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
//wonderswan-color.cpp
|
||||
auto wonderSwanColorManifest(string location) -> string;
|
||||
auto wonderSwanColorManifest(vector<uint8>& buffer, string location) -> string;
|
||||
auto wonderSwanColorImport(vector<uint8>& buffer, string location) -> string;
|
||||
auto wonderSwanColorManifest(vector<uint8_t>& buffer, string location) -> string;
|
||||
auto wonderSwanColorImport(vector<uint8_t>& buffer, string location) -> string;
|
||||
|
||||
private:
|
||||
string errorMessage;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
auto Icarus::famicomManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
concatenate(buffer, {location, "ines.rom"});
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
concatenate(buffer, {location, "character.rom"});
|
||||
return famicomManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::famicomManifest(vector<uint8>& buffer, string location, uint* prgrom, uint* chrrom) -> string {
|
||||
auto Icarus::famicomManifest(vector<uint8_t>& buffer, string location, uint* prgrom, uint* chrrom) -> string {
|
||||
string markup;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -37,7 +37,7 @@ auto Icarus::famicomManifest(vector<uint8>& buffer, string location, uint* prgro
|
|||
return markup;
|
||||
}
|
||||
|
||||
auto Icarus::famicomImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::famicomImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "Famicom/", name, ".fc/"};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
auto Icarus::gameBoyAdvanceManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
return gameBoyAdvanceManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::gameBoyAdvanceManifest(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::gameBoyAdvanceManifest(vector<uint8_t>& buffer, string location) -> string {
|
||||
string markup;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -31,7 +31,7 @@ auto Icarus::gameBoyAdvanceManifest(vector<uint8>& buffer, string location) -> s
|
|||
return markup;
|
||||
}
|
||||
|
||||
auto Icarus::gameBoyAdvanceImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::gameBoyAdvanceImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "Game Boy Advance/", name, ".gba/"};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
auto Icarus::gameBoyColorManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
return gameBoyColorManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::gameBoyColorManifest(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::gameBoyColorManifest(vector<uint8_t>& buffer, string location) -> string {
|
||||
string markup;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -31,7 +31,7 @@ auto Icarus::gameBoyColorManifest(vector<uint8>& buffer, string location) -> str
|
|||
return markup;
|
||||
}
|
||||
|
||||
auto Icarus::gameBoyColorImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::gameBoyColorImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "Game Boy Color/", name, ".gbc/"};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
auto Icarus::gameBoyManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
return gameBoyManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::gameBoyManifest(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::gameBoyManifest(vector<uint8_t>& buffer, string location) -> string {
|
||||
string markup;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -31,7 +31,7 @@ auto Icarus::gameBoyManifest(vector<uint8>& buffer, string location) -> string {
|
|||
return markup;
|
||||
}
|
||||
|
||||
auto Icarus::gameBoyImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::gameBoyImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "Game Boy/", name, ".gb/"};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
auto Icarus::sufamiTurboManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
return sufamiTurboManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::sufamiTurboManifest(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::sufamiTurboManifest(vector<uint8_t>& buffer, string location) -> string {
|
||||
string markup;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -31,7 +31,7 @@ auto Icarus::sufamiTurboManifest(vector<uint8>& buffer, string location) -> stri
|
|||
return markup;
|
||||
}
|
||||
|
||||
auto Icarus::sufamiTurboImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::sufamiTurboImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "Sufami Turbo/", name, ".st/"};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
auto Icarus::superFamicomManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
auto files = directory::files(location, "*.rom");
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
concatenate(buffer, {location, "data.rom" });
|
||||
|
@ -10,7 +10,7 @@ auto Icarus::superFamicomManifest(string location) -> string {
|
|||
return superFamicomManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::superFamicomManifest(vector<uint8>& buffer, string location, bool* firmwareAppended) -> string {
|
||||
auto Icarus::superFamicomManifest(vector<uint8_t>& buffer, string location, bool* firmwareAppended) -> string {
|
||||
string markup;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -45,7 +45,7 @@ auto Icarus::superFamicomManifestScan(vector<Markup::Node>& roms, Markup::Node n
|
|||
for(auto leaf : node) superFamicomManifestScan(roms, leaf);
|
||||
}
|
||||
|
||||
auto Icarus::superFamicomImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::superFamicomImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "Super Famicom/", name, ".sfc/"};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
auto Icarus::wonderSwanColorManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
return wonderSwanColorManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::wonderSwanColorManifest(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::wonderSwanColorManifest(vector<uint8_t>& buffer, string location) -> string {
|
||||
string manifest;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -31,7 +31,7 @@ auto Icarus::wonderSwanColorManifest(vector<uint8>& buffer, string location) ->
|
|||
return manifest;
|
||||
}
|
||||
|
||||
auto Icarus::wonderSwanColorImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::wonderSwanColorImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "WonderSwan Color/", name, ".wsc/"};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
auto Icarus::wonderSwanManifest(string location) -> string {
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
concatenate(buffer, {location, "program.rom"});
|
||||
return wonderSwanManifest(buffer, location);
|
||||
}
|
||||
|
||||
auto Icarus::wonderSwanManifest(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::wonderSwanManifest(vector<uint8_t>& buffer, string location) -> string {
|
||||
string manifest;
|
||||
string digest = Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
|
||||
|
@ -31,7 +31,7 @@ auto Icarus::wonderSwanManifest(vector<uint8>& buffer, string location) -> strin
|
|||
return manifest;
|
||||
}
|
||||
|
||||
auto Icarus::wonderSwanImport(vector<uint8>& buffer, string location) -> string {
|
||||
auto Icarus::wonderSwanImport(vector<uint8_t>& buffer, string location) -> string {
|
||||
auto name = prefixname(location);
|
||||
auto source = pathname(location);
|
||||
string target{settings["Library/Location"].text(), "WonderSwan/", name, ".ws/"};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
struct BSMemoryCartridge {
|
||||
BSMemoryCartridge(const uint8* data, uint size);
|
||||
BSMemoryCartridge(const uint8_t* data, uint size);
|
||||
|
||||
string markup;
|
||||
};
|
||||
|
||||
BSMemoryCartridge::BSMemoryCartridge(const uint8* data, uint size) {
|
||||
BSMemoryCartridge::BSMemoryCartridge(const uint8_t* data, uint size) {
|
||||
markup.append("board\n");
|
||||
markup.append(" rom type=flash name=program.rom size=0x", hex(size), "\n");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
struct FamicomCartridge {
|
||||
FamicomCartridge(const uint8* data, uint size);
|
||||
FamicomCartridge(const uint8_t* data, uint size);
|
||||
|
||||
string markup;
|
||||
|
||||
|
@ -12,7 +12,7 @@ struct FamicomCartridge {
|
|||
uint chrram;
|
||||
};
|
||||
|
||||
FamicomCartridge::FamicomCartridge(const uint8* data, uint size) {
|
||||
FamicomCartridge::FamicomCartridge(const uint8_t* data, uint size) {
|
||||
if(size < 16) return;
|
||||
if(data[0] != 'N') return;
|
||||
if(data[1] != 'E') return;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
struct GameBoyAdvanceCartridge {
|
||||
GameBoyAdvanceCartridge(const uint8_t *data, unsigned size);
|
||||
GameBoyAdvanceCartridge(const uint8_t* data, unsigned size);
|
||||
|
||||
string markup;
|
||||
string identifiers;
|
||||
};
|
||||
|
||||
GameBoyAdvanceCartridge::GameBoyAdvanceCartridge(const uint8_t *data, unsigned size) {
|
||||
GameBoyAdvanceCartridge::GameBoyAdvanceCartridge(const uint8_t* data, unsigned size) {
|
||||
struct Identifier {
|
||||
string name;
|
||||
unsigned size;
|
||||
|
|
|
@ -19,7 +19,7 @@ struct GameBoyCartridge {
|
|||
} info;
|
||||
};
|
||||
|
||||
GameBoyCartridge::GameBoyCartridge(uint8_t *romdata, unsigned romsize) {
|
||||
GameBoyCartridge::GameBoyCartridge(uint8_t* romdata, unsigned romsize) {
|
||||
if(romsize < 0x4000) return;
|
||||
|
||||
info.mapper = "unknown";
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
struct SuperFamicomCartridge {
|
||||
SuperFamicomCartridge(const uint8* data, uint size, bool has_msu1 = false);
|
||||
SuperFamicomCartridge(const uint8_t* data, uint size, bool has_msu1 = false);
|
||||
|
||||
string markup;
|
||||
|
||||
//private:
|
||||
auto readHeader(const uint8* data, uint size) -> void;
|
||||
auto findHeader(const uint8* data, uint size) -> uint;
|
||||
auto scoreHeader(const uint8* data, uint size, uint addr) -> uint;
|
||||
auto readHeader(const uint8_t* data, uint size) -> void;
|
||||
auto findHeader(const uint8_t* data, uint size) -> uint;
|
||||
auto scoreHeader(const uint8_t* data, uint size, uint addr) -> uint;
|
||||
|
||||
enum HeaderField : uint {
|
||||
CartName = 0x00,
|
||||
|
@ -86,7 +86,7 @@ struct SuperFamicomCartridge {
|
|||
bool has_st018 = false;
|
||||
};
|
||||
|
||||
SuperFamicomCartridge::SuperFamicomCartridge(const uint8* data, uint size, bool has_msu1) {
|
||||
SuperFamicomCartridge::SuperFamicomCartridge(const uint8_t* data, uint size, bool has_msu1) {
|
||||
//skip copier header
|
||||
if((size & 0x7fff) == 512) data += 512, size -= 512;
|
||||
|
||||
|
@ -534,7 +534,7 @@ SuperFamicomCartridge::SuperFamicomCartridge(const uint8* data, uint size, bool
|
|||
}
|
||||
}
|
||||
|
||||
auto SuperFamicomCartridge::readHeader(const uint8* data, uint size) -> void {
|
||||
auto SuperFamicomCartridge::readHeader(const uint8_t* data, uint size) -> void {
|
||||
//detect Game Boy carts
|
||||
if(size >= 0x0140) {
|
||||
if(data[0x0104] == 0xce && data[0x0105] == 0xed && data[0x0106] == 0x66 && data[0x0107] == 0x66
|
||||
|
@ -545,14 +545,14 @@ auto SuperFamicomCartridge::readHeader(const uint8* data, uint size) -> void {
|
|||
}
|
||||
|
||||
const uint index = findHeader(data, size);
|
||||
const uint8 mapperid = data[index + Mapper];
|
||||
const uint8 rom_type = data[index + RomType];
|
||||
const uint8 rom_size = data[index + RomSize];
|
||||
const uint8 company = data[index + Company];
|
||||
const uint8 regionid = data[index + CartRegion] & 0x7f;
|
||||
const uint8_t mapperid = data[index + Mapper];
|
||||
const uint8_t rom_type = data[index + RomType];
|
||||
const uint8_t rom_size = data[index + RomSize];
|
||||
const uint8_t company = data[index + Company];
|
||||
const uint8_t regionid = data[index + CartRegion] & 0x7f;
|
||||
|
||||
const uint16 complement = data[index + Complement] | data[index + Complement + 1] << 8;
|
||||
const uint16 checksum = data[index + Checksum] | data[index + Checksum + 1] << 8;
|
||||
const uint16_t complement = data[index + Complement] | data[index + Complement + 1] << 8;
|
||||
const uint16_t checksum = data[index + Checksum] | data[index + Checksum + 1] << 8;
|
||||
|
||||
this->rom_size = size;
|
||||
ram_size = 1024 << (data[index + RamSize] & 7);
|
||||
|
@ -565,7 +565,7 @@ auto SuperFamicomCartridge::readHeader(const uint8* data, uint size) -> void {
|
|||
//detect BS-X flash carts
|
||||
if(data[index + 0x13] == 0x00 || data[index + 0x13] == 0xff) {
|
||||
if(data[index + 0x14] == 0x00) {
|
||||
const uint8 n15 = data[index + 0x15];
|
||||
const uint8_t n15 = data[index + 0x15];
|
||||
if(n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc) {
|
||||
if(data[index + 0x1a] == 0x33 || data[index + 0x1a] == 0xff) {
|
||||
type = Type::Satellaview;
|
||||
|
@ -620,7 +620,7 @@ auto SuperFamicomCartridge::readHeader(const uint8* data, uint size) -> void {
|
|||
//detect presence of BS-X flash cartridge connector (reads extended header information)
|
||||
if(data[index - 14] == 'Z') {
|
||||
if(data[index - 11] == 'J') {
|
||||
uint8 n13 = data[index - 13];
|
||||
uint8_t n13 = data[index - 13];
|
||||
if((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9')) {
|
||||
if(company == 0x33 || (data[index - 10] == 0x00 && data[index - 4] == 0x00)) {
|
||||
has_bsx_slot = true;
|
||||
|
@ -737,7 +737,7 @@ auto SuperFamicomCartridge::readHeader(const uint8* data, uint size) -> void {
|
|||
}
|
||||
}
|
||||
|
||||
auto SuperFamicomCartridge::findHeader(const uint8* data, uint size) -> uint {
|
||||
auto SuperFamicomCartridge::findHeader(const uint8_t* data, uint size) -> uint {
|
||||
uint score_lo = scoreHeader(data, size, 0x007fc0);
|
||||
uint score_hi = scoreHeader(data, size, 0x00ffc0);
|
||||
uint score_ex = scoreHeader(data, size, 0x40ffc0);
|
||||
|
@ -752,16 +752,16 @@ auto SuperFamicomCartridge::findHeader(const uint8* data, uint size) -> uint {
|
|||
}
|
||||
}
|
||||
|
||||
auto SuperFamicomCartridge::scoreHeader(const uint8* data, uint size, uint addr) -> uint {
|
||||
auto SuperFamicomCartridge::scoreHeader(const uint8_t* data, uint size, uint addr) -> uint {
|
||||
if(size < addr + 64) return 0; //image too small to contain header at this location?
|
||||
int score = 0;
|
||||
|
||||
uint16 resetvector = data[addr + ResetVector] | (data[addr + ResetVector + 1] << 8);
|
||||
uint16 checksum = data[addr + Checksum ] | (data[addr + Checksum + 1] << 8);
|
||||
uint16 complement = data[addr + Complement ] | (data[addr + Complement + 1] << 8);
|
||||
uint16_t resetvector = data[addr + ResetVector] | (data[addr + ResetVector + 1] << 8);
|
||||
uint16_t checksum = data[addr + Checksum ] | (data[addr + Checksum + 1] << 8);
|
||||
uint16_t complement = data[addr + Complement ] | (data[addr + Complement + 1] << 8);
|
||||
|
||||
uint8 resetop = data[(addr & ~0x7fff) | (resetvector & 0x7fff)]; //first opcode executed upon reset
|
||||
uint8 mapper = data[addr + Mapper] & ~0x10; //mask off irrelevent FastROM-capable bit
|
||||
uint8_t resetop = data[(addr & ~0x7fff) | (resetvector & 0x7fff)]; //first opcode executed upon reset
|
||||
uint8_t mapper = data[addr + Mapper] & ~0x10; //mask off irrelevent FastROM-capable bit
|
||||
|
||||
//$00:[000-7fff] contains uninitialized RAM and MMIO.
|
||||
//reset vector must point to ROM at $00:[8000-ffff] to be considered valid.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
struct WonderSwanColorCartridge {
|
||||
WonderSwanColorCartridge(uint8* data, uint size);
|
||||
WonderSwanColorCartridge(uint8_t* data, uint size);
|
||||
|
||||
string manifest;
|
||||
|
||||
|
@ -8,7 +8,7 @@ struct WonderSwanColorCartridge {
|
|||
} information;
|
||||
};
|
||||
|
||||
WonderSwanColorCartridge::WonderSwanColorCartridge(uint8* data, uint size) {
|
||||
WonderSwanColorCartridge::WonderSwanColorCartridge(uint8_t* data, uint size) {
|
||||
if(size < 0x10000) return;
|
||||
|
||||
manifest.append("board\n");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
struct WonderSwanCartridge {
|
||||
WonderSwanCartridge(uint8* data, uint size);
|
||||
WonderSwanCartridge(uint8_t* data, uint size);
|
||||
|
||||
string manifest;
|
||||
|
||||
|
@ -8,7 +8,7 @@ struct WonderSwanCartridge {
|
|||
} information;
|
||||
};
|
||||
|
||||
WonderSwanCartridge::WonderSwanCartridge(uint8* data, uint size) {
|
||||
WonderSwanCartridge::WonderSwanCartridge(uint8_t* data, uint size) {
|
||||
if(size < 0x10000) return;
|
||||
|
||||
manifest.append("board\n");
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
namespace nall {
|
||||
|
||||
struct bpsdelta {
|
||||
inline auto source(const uint8* data, uint size) -> void;
|
||||
inline auto target(const uint8* data, uint size) -> void;
|
||||
inline auto source(const uint8_t* data, uint size) -> void;
|
||||
inline auto target(const uint8_t* data, uint size) -> void;
|
||||
|
||||
inline auto source(const string& filename) -> bool;
|
||||
inline auto target(const string& filename) -> bool;
|
||||
|
@ -27,20 +27,20 @@ protected:
|
|||
};
|
||||
|
||||
filemap sourceFile;
|
||||
const uint8* sourceData;
|
||||
const uint8_t* sourceData;
|
||||
uint sourceSize;
|
||||
|
||||
filemap targetFile;
|
||||
const uint8* targetData;
|
||||
const uint8_t* targetData;
|
||||
uint targetSize;
|
||||
};
|
||||
|
||||
auto bpsdelta::source(const uint8* data, uint size) -> void {
|
||||
auto bpsdelta::source(const uint8_t* data, uint size) -> void {
|
||||
sourceData = data;
|
||||
sourceSize = size;
|
||||
}
|
||||
|
||||
auto bpsdelta::target(const uint8* data, uint size) -> void {
|
||||
auto bpsdelta::target(const uint8_t* data, uint size) -> void {
|
||||
targetData = data;
|
||||
targetSize = size;
|
||||
}
|
||||
|
@ -64,14 +64,14 @@ auto bpsdelta::create(const string& filename, const string& metadata) -> bool {
|
|||
Hash::CRC32 sourceChecksum, modifyChecksum;
|
||||
uint sourceRelativeOffset = 0, targetRelativeOffset = 0, outputOffset = 0;
|
||||
|
||||
auto write = [&](uint8 data) {
|
||||
auto write = [&](uint8_t data) {
|
||||
modifyFile.write(data);
|
||||
modifyChecksum.data(data);
|
||||
};
|
||||
|
||||
auto encode = [&](uint64 data) {
|
||||
auto encode = [&](uint64_t data) {
|
||||
while(true) {
|
||||
uint64 x = data & 0x7f;
|
||||
uint64_t x = data & 0x7f;
|
||||
data >>= 7;
|
||||
if(data == 0) {
|
||||
write(0x80 | x);
|
||||
|
@ -100,7 +100,7 @@ auto bpsdelta::create(const string& filename, const string& metadata) -> bool {
|
|||
|
||||
//source tree creation
|
||||
for(uint offset = 0; offset < sourceSize; offset++) {
|
||||
uint16 symbol = sourceData[offset + 0];
|
||||
uint16_t symbol = sourceData[offset + 0];
|
||||
sourceChecksum.data(symbol);
|
||||
if(offset < sourceSize - 1) symbol |= sourceData[offset + 1] << 8;
|
||||
Node *node = new Node;
|
||||
|
@ -122,7 +122,7 @@ auto bpsdelta::create(const string& filename, const string& metadata) -> bool {
|
|||
while(outputOffset < targetSize) {
|
||||
uint maxLength = 0, maxOffset = 0, mode = TargetRead;
|
||||
|
||||
uint16 symbol = targetData[outputOffset + 0];
|
||||
uint16_t symbol = targetData[outputOffset + 0];
|
||||
if(outputOffset < targetSize - 1) symbol |= targetData[outputOffset + 1] << 8;
|
||||
|
||||
{ //source read
|
||||
|
@ -198,9 +198,9 @@ auto bpsdelta::create(const string& filename, const string& metadata) -> bool {
|
|||
targetReadFlush();
|
||||
|
||||
for(uint n = 0; n < 32; n += 8) write(sourceChecksum.value() >> n);
|
||||
uint32 targetChecksum = Hash::CRC32(targetData, targetSize).value();
|
||||
uint32_t targetChecksum = Hash::CRC32(targetData, targetSize).value();
|
||||
for(uint n = 0; n < 32; n += 8) write(targetChecksum >> n);
|
||||
uint32 outputChecksum = modifyChecksum.value();
|
||||
uint32_t outputChecksum = modifyChecksum.value();
|
||||
for(uint n = 0; n < 32; n += 8) write(outputChecksum >> n);
|
||||
|
||||
modifyFile.close();
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
namespace nall {
|
||||
|
||||
struct bpslinear {
|
||||
inline auto source(const uint8* data, uint size) -> void;
|
||||
inline auto target(const uint8* data, uint size) -> void;
|
||||
inline auto source(const uint8_t* data, uint size) -> void;
|
||||
inline auto target(const uint8_t* data, uint size) -> void;
|
||||
|
||||
inline auto source(const string& filename) -> bool;
|
||||
inline auto target(const string& filename) -> bool;
|
||||
|
@ -20,20 +20,20 @@ protected:
|
|||
enum : uint { Granularity = 1 };
|
||||
|
||||
filemap sourceFile;
|
||||
const uint8* sourceData;
|
||||
const uint8_t* sourceData;
|
||||
uint sourceSize;
|
||||
|
||||
filemap targetFile;
|
||||
const uint8* targetData;
|
||||
const uint8_t* targetData;
|
||||
uint targetSize;
|
||||
};
|
||||
|
||||
auto bpslinear::source(const uint8* data, uint size) -> void {
|
||||
auto bpslinear::source(const uint8_t* data, uint size) -> void {
|
||||
sourceData = data;
|
||||
sourceSize = size;
|
||||
}
|
||||
|
||||
auto bpslinear::target(const uint8* data, uint size) -> void {
|
||||
auto bpslinear::target(const uint8_t* data, uint size) -> void {
|
||||
targetData = data;
|
||||
targetSize = size;
|
||||
}
|
||||
|
@ -57,14 +57,14 @@ auto bpslinear::create(const string& filename, const string& metadata) -> bool {
|
|||
Hash::CRC32 modifyChecksum;
|
||||
uint targetRelativeOffset = 0, outputOffset = 0;
|
||||
|
||||
auto write = [&](uint8 data) {
|
||||
auto write = [&](uint8_t data) {
|
||||
modifyFile.write(data);
|
||||
modifyChecksum.data(data);
|
||||
};
|
||||
|
||||
auto encode = [&](uint64 data) {
|
||||
auto encode = [&](uint64_t data) {
|
||||
while(true) {
|
||||
uint64 x = data & 0x7f;
|
||||
uint64_t x = data & 0x7f;
|
||||
data >>= 7;
|
||||
if(data == 0) {
|
||||
write(0x80 | x);
|
||||
|
@ -134,11 +134,11 @@ auto bpslinear::create(const string& filename, const string& metadata) -> bool {
|
|||
|
||||
targetReadFlush();
|
||||
|
||||
uint32 sourceChecksum = Hash::CRC32(sourceData, sourceSize).value();
|
||||
uint32_t sourceChecksum = Hash::CRC32(sourceData, sourceSize).value();
|
||||
for(uint n = 0; n < 32; n += 8) write(sourceChecksum >> n);
|
||||
uint32 targetChecksum = Hash::CRC32(targetData, targetSize).value();
|
||||
uint32_t targetChecksum = Hash::CRC32(targetData, targetSize).value();
|
||||
for(uint n = 0; n < 32; n += 8) write(targetChecksum >> n);
|
||||
uint32 outputChecksum = modifyChecksum.value();
|
||||
uint32_t outputChecksum = modifyChecksum.value();
|
||||
for(uint n = 0; n < 32; n += 8) write(outputChecksum >> n);
|
||||
|
||||
modifyFile.close();
|
||||
|
|
|
@ -24,10 +24,10 @@ auto bpsmetadata::load(const string& filename) -> bool {
|
|||
return sourceFile.read();
|
||||
};
|
||||
|
||||
auto decode = [&]() -> uint64 {
|
||||
uint64 data = 0, shift = 1;
|
||||
auto decode = [&]() -> uint64_t {
|
||||
uint64_t data = 0, shift = 1;
|
||||
while(true) {
|
||||
uint8 x = read();
|
||||
uint8_t x = read();
|
||||
data += (x & 0x7f) * shift;
|
||||
if(x & 0x80) break;
|
||||
shift <<= 7;
|
||||
|
@ -57,14 +57,14 @@ auto bpsmetadata::save(const string& filename, const string& metadata) -> bool {
|
|||
if(sourceFile.open() == false) return false;
|
||||
sourceFile.seek(0);
|
||||
|
||||
auto read = [&]() -> uint8 {
|
||||
auto read = [&]() -> uint8_t {
|
||||
return sourceFile.read();
|
||||
};
|
||||
|
||||
auto decode = [&]() -> uint64 {
|
||||
uint64 data = 0, shift = 1;
|
||||
auto decode = [&]() -> uint64_t {
|
||||
uint64_t data = 0, shift = 1;
|
||||
while(true) {
|
||||
uint8 x = read();
|
||||
uint8_t x = read();
|
||||
data += (x & 0x7f) * shift;
|
||||
if(x & 0x80) break;
|
||||
shift <<= 7;
|
||||
|
@ -75,14 +75,14 @@ auto bpsmetadata::save(const string& filename, const string& metadata) -> bool {
|
|||
|
||||
Hash::CRC32 checksum;
|
||||
|
||||
auto write = [&](uint8 data) {
|
||||
auto write = [&](uint8_t data) {
|
||||
targetFile.write(data);
|
||||
checksum.data(data);
|
||||
};
|
||||
|
||||
auto encode = [&](uint64 data) {
|
||||
auto encode = [&](uint64_t data) {
|
||||
while(true) {
|
||||
uint64 x = data & 0x7f;
|
||||
uint64_t x = data & 0x7f;
|
||||
data >>= 7;
|
||||
if(data == 0) {
|
||||
write(0x80 | x);
|
||||
|
@ -103,7 +103,7 @@ auto bpsmetadata::save(const string& filename, const string& metadata) -> bool {
|
|||
for(uint n = 0; n < targetLength; n++) write(metadata[n]);
|
||||
uint length = sourceFile.size() - sourceFile.offset() - 4;
|
||||
for(uint n = 0; n < length; n++) write(read());
|
||||
uint32 outputChecksum = checksum.value();
|
||||
uint32_t outputChecksum = checksum.value();
|
||||
for(uint n = 0; n < 32; n += 8) write(outputChecksum >> n);
|
||||
|
||||
targetFile.close();
|
||||
|
|
|
@ -46,7 +46,7 @@ struct bpsmulti {
|
|||
Hash::CRC32 cksum;
|
||||
|
||||
for(uint n = 0; n < sp.size(); n++) {
|
||||
uint8 byte = sp.read();
|
||||
uint8_t byte = sp.read();
|
||||
if(identical && byte != dp.read()) identical = false;
|
||||
cksum.data(byte);
|
||||
}
|
||||
|
@ -118,13 +118,13 @@ struct bpsmulti {
|
|||
fp.open({targetPath, targetName}, file::mode::write);
|
||||
auto fileSize = readNumber();
|
||||
while(fileSize--) fp.write(read());
|
||||
uint32 cksum = readChecksum();
|
||||
uint32_t cksum = readChecksum();
|
||||
} else if(action == ModifyFile) {
|
||||
auto encoding = readNumber();
|
||||
string originPath = encoding & 1 ? targetPath : sourcePath;
|
||||
string sourceName = (encoding >> 1) == 0 ? targetName : readString(encoding >> 1);
|
||||
auto patchSize = readNumber();
|
||||
vector<uint8> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
buffer.resize(patchSize);
|
||||
for(uint n = 0; n < patchSize; n++) buffer[n] = read();
|
||||
bpspatch patch;
|
||||
|
@ -137,15 +137,15 @@ struct bpsmulti {
|
|||
string originPath = encoding & 1 ? targetPath : sourcePath;
|
||||
string sourceName = (encoding >> 1) == 0 ? targetName : readString(encoding >> 1);
|
||||
file::copy({originPath, sourceName}, {targetPath, targetName});
|
||||
uint32 cksum = readChecksum();
|
||||
uint32_t cksum = readChecksum();
|
||||
}
|
||||
}
|
||||
|
||||
uint32 cksum = checksum.value();
|
||||
if(read() != (uint8)(cksum >> 0)) return false;
|
||||
if(read() != (uint8)(cksum >> 8)) return false;
|
||||
if(read() != (uint8)(cksum >> 16)) return false;
|
||||
if(read() != (uint8)(cksum >> 24)) return false;
|
||||
uint32_t cksum = checksum.value();
|
||||
if(read() != (uint8_t)(cksum >> 0)) return false;
|
||||
if(read() != (uint8_t)(cksum >> 8)) return false;
|
||||
if(read() != (uint8_t)(cksum >> 16)) return false;
|
||||
if(read() != (uint8_t)(cksum >> 24)) return false;
|
||||
|
||||
fp.close();
|
||||
return true;
|
||||
|
@ -169,14 +169,14 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
auto write(uint8 data) -> void {
|
||||
auto write(uint8_t data) -> void {
|
||||
fp.write(data);
|
||||
checksum.data(data);
|
||||
}
|
||||
|
||||
auto writeNumber(uint64 data) -> void {
|
||||
auto writeNumber(uint64_t data) -> void {
|
||||
while(true) {
|
||||
uint64 x = data & 0x7f;
|
||||
uint64_t x = data & 0x7f;
|
||||
data >>= 7;
|
||||
if(data == 0) {
|
||||
write(0x80 | x);
|
||||
|
@ -192,7 +192,7 @@ protected:
|
|||
for(uint n = 0; n < length; n++) write(text[n]);
|
||||
}
|
||||
|
||||
auto writeChecksum(uint32 cksum) -> void {
|
||||
auto writeChecksum(uint32_t cksum) -> void {
|
||||
write(cksum >> 0);
|
||||
write(cksum >> 8);
|
||||
write(cksum >> 16);
|
||||
|
@ -200,16 +200,16 @@ protected:
|
|||
}
|
||||
|
||||
//apply() functions
|
||||
auto read() -> uint8 {
|
||||
uint8 data = fp.read();
|
||||
auto read() -> uint8_t {
|
||||
uint8_t data = fp.read();
|
||||
checksum.data(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
auto readNumber() -> uint64 {
|
||||
uint64 data = 0, shift = 1;
|
||||
auto readNumber() -> uint64_t {
|
||||
uint64_t data = 0, shift = 1;
|
||||
while(true) {
|
||||
uint8 x = read();
|
||||
uint8_t x = read();
|
||||
data += (x & 0x7f) * shift;
|
||||
if(x & 0x80) break;
|
||||
shift <<= 7;
|
||||
|
@ -226,8 +226,8 @@ protected:
|
|||
return text;
|
||||
}
|
||||
|
||||
auto readChecksum() -> uint32 {
|
||||
uint32 checksum = 0;
|
||||
auto readChecksum() -> uint32_t {
|
||||
uint32_t checksum = 0;
|
||||
checksum |= read() << 0;
|
||||
checksum |= read() << 8;
|
||||
checksum |= read() << 16;
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
namespace nall {
|
||||
|
||||
struct bpspatch {
|
||||
inline auto modify(const uint8* data, uint size) -> bool;
|
||||
inline auto source(const uint8* data, uint size) -> void;
|
||||
inline auto target(uint8* data, uint size) -> void;
|
||||
inline auto modify(const uint8_t* data, uint size) -> bool;
|
||||
inline auto source(const uint8_t* data, uint size) -> void;
|
||||
inline auto target(uint8_t* data, uint size) -> void;
|
||||
|
||||
inline auto modify(const string& filename) -> bool;
|
||||
inline auto source(const string& filename) -> bool;
|
||||
|
@ -37,15 +37,15 @@ protected:
|
|||
enum : uint { SourceRead, TargetRead, SourceCopy, TargetCopy };
|
||||
|
||||
filemap modifyFile;
|
||||
const uint8* modifyData;
|
||||
const uint8_t* modifyData;
|
||||
uint modifySize;
|
||||
|
||||
filemap sourceFile;
|
||||
const uint8* sourceData;
|
||||
const uint8_t* sourceData;
|
||||
uint sourceSize;
|
||||
|
||||
filemap targetFile;
|
||||
uint8* targetData;
|
||||
uint8_t* targetData;
|
||||
uint targetSize;
|
||||
|
||||
uint modifySourceSize;
|
||||
|
@ -54,16 +54,16 @@ protected:
|
|||
string metadataString;
|
||||
};
|
||||
|
||||
auto bpspatch::modify(const uint8* data, uint size) -> bool {
|
||||
auto bpspatch::modify(const uint8_t* data, uint size) -> bool {
|
||||
if(size < 19) return false;
|
||||
modifyData = data;
|
||||
modifySize = size;
|
||||
|
||||
uint offset = 4;
|
||||
auto decode = [&]() -> uint64 {
|
||||
uint64 data = 0, shift = 1;
|
||||
auto decode = [&]() -> uint64_t {
|
||||
uint64_t data = 0, shift = 1;
|
||||
while(true) {
|
||||
uint8 x = modifyData[offset++];
|
||||
uint8_t x = modifyData[offset++];
|
||||
data += (x & 0x7f) * shift;
|
||||
if(x & 0x80) break;
|
||||
shift <<= 7;
|
||||
|
@ -84,12 +84,12 @@ auto bpspatch::modify(const uint8* data, uint size) -> bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
auto bpspatch::source(const uint8* data, uint size) -> void {
|
||||
auto bpspatch::source(const uint8_t* data, uint size) -> void {
|
||||
sourceData = data;
|
||||
sourceSize = size;
|
||||
}
|
||||
|
||||
auto bpspatch::target(uint8* data, uint size) -> void {
|
||||
auto bpspatch::target(uint8_t* data, uint size) -> void {
|
||||
targetData = data;
|
||||
targetSize = size;
|
||||
}
|
||||
|
@ -130,16 +130,16 @@ auto bpspatch::apply() -> result {
|
|||
Hash::CRC32 modifyChecksum, targetChecksum;
|
||||
uint modifyOffset = 0, sourceRelativeOffset = 0, targetRelativeOffset = 0, outputOffset = 0;
|
||||
|
||||
auto read = [&]() -> uint8 {
|
||||
uint8 data = modifyData[modifyOffset++];
|
||||
auto read = [&]() -> uint8_t {
|
||||
uint8_t data = modifyData[modifyOffset++];
|
||||
modifyChecksum.data(data);
|
||||
return data;
|
||||
};
|
||||
|
||||
auto decode = [&]() -> uint64 {
|
||||
uint64 data = 0, shift = 1;
|
||||
auto decode = [&]() -> uint64_t {
|
||||
uint64_t data = 0, shift = 1;
|
||||
while(true) {
|
||||
uint8 x = read();
|
||||
uint8_t x = read();
|
||||
data += (x & 0x7f) * shift;
|
||||
if(x & 0x80) break;
|
||||
shift <<= 7;
|
||||
|
@ -148,7 +148,7 @@ auto bpspatch::apply() -> result {
|
|||
return data;
|
||||
};
|
||||
|
||||
auto write = [&](uint8 data) {
|
||||
auto write = [&](uint8_t data) {
|
||||
targetData[outputOffset++] = data;
|
||||
targetChecksum.data(data);
|
||||
};
|
||||
|
@ -196,13 +196,13 @@ auto bpspatch::apply() -> result {
|
|||
}
|
||||
}
|
||||
|
||||
uint32 modifySourceChecksum = 0, modifyTargetChecksum = 0, modifyModifyChecksum = 0;
|
||||
uint32_t modifySourceChecksum = 0, modifyTargetChecksum = 0, modifyModifyChecksum = 0;
|
||||
for(uint n = 0; n < 32; n += 8) modifySourceChecksum |= read() << n;
|
||||
for(uint n = 0; n < 32; n += 8) modifyTargetChecksum |= read() << n;
|
||||
uint32 checksum = modifyChecksum.value();
|
||||
uint32_t checksum = modifyChecksum.value();
|
||||
for(uint n = 0; n < 32; n += 8) modifyModifyChecksum |= read() << n;
|
||||
|
||||
uint32 sourceChecksum = Hash::CRC32(sourceData, modifySourceSize).value();
|
||||
uint32_t sourceChecksum = Hash::CRC32(sourceData, modifySourceSize).value();
|
||||
|
||||
if(sourceChecksum != modifySourceChecksum) return result::source_checksum_invalid;
|
||||
if(targetChecksum.value() != modifyTargetChecksum) return result::target_checksum_invalid;
|
||||
|
|
|
@ -13,7 +13,7 @@ struct bitvector {
|
|||
|
||||
auto operator=(const bitvector& source) -> bitvector& {
|
||||
bits = source.bits;
|
||||
pool = (uint8*)memory::resize(pool, bytes());
|
||||
pool = (uint8_t*)memory::resize(pool, bytes());
|
||||
memory::copy(pool, source.pool, bytes());
|
||||
return *this;
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ struct bitvector {
|
|||
auto empty() const -> bool { return bits == 0; }
|
||||
auto size() const -> uint { return bits; }
|
||||
auto bytes() const -> uint { return (bits + 7) / 8; }
|
||||
auto data() -> uint8* { return pool; }
|
||||
auto data() const -> const uint8* { return pool; }
|
||||
auto data() -> uint8_t* { return pool; }
|
||||
auto data() const -> const uint8_t* { return pool; }
|
||||
|
||||
auto reset() -> void {
|
||||
if(pool) free(pool);
|
||||
|
@ -43,7 +43,7 @@ struct bitvector {
|
|||
uint from = bits;
|
||||
bits = size;
|
||||
for(uint n = size; n < from; n++) clear(n); //on reduce
|
||||
pool = (uint8*)memory::resize(pool, bytes());
|
||||
pool = (uint8_t*)memory::resize(pool, bytes());
|
||||
for(uint n = from; n < size; n++) clear(n); //on expand
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ struct bitvector {
|
|||
auto end() -> iterator { return iterator(*this, bits); }
|
||||
|
||||
protected:
|
||||
uint8* pool = nullptr;
|
||||
uint8_t* pool = nullptr;
|
||||
uint bits = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ struct GZIP {
|
|||
inline ~GZIP();
|
||||
|
||||
inline auto decompress(const string& filename) -> bool;
|
||||
inline auto decompress(const uint8* data, uint size) -> bool;
|
||||
inline auto decompress(const uint8_t* data, uint size) -> bool;
|
||||
|
||||
string filename;
|
||||
uint8* data = nullptr;
|
||||
uint8_t* data = nullptr;
|
||||
uint size = 0;
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ auto GZIP::decompress(const string& filename) -> bool {
|
|||
return false;
|
||||
}
|
||||
|
||||
auto GZIP::decompress(const uint8* data, uint size) -> bool {
|
||||
auto GZIP::decompress(const uint8_t* data, uint size) -> bool {
|
||||
if(size < 18) return false;
|
||||
if(data[0] != 0x1f) return false;
|
||||
if(data[1] != 0x8b) return false;
|
||||
|
|
|
@ -12,8 +12,8 @@ namespace puff {
|
|||
}
|
||||
|
||||
inline auto inflate(
|
||||
uint8* target, uint targetLength,
|
||||
const uint8* source, uint sourceLength
|
||||
uint8_t* target, uint targetLength,
|
||||
const uint8_t* source, uint sourceLength
|
||||
) -> bool {
|
||||
unsigned long tl = targetLength, sl = sourceLength;
|
||||
int result = puff::puff((unsigned char*)target, &tl, (unsigned char*)source, &sl);
|
||||
|
|
|
@ -10,8 +10,8 @@ struct PNG {
|
|||
inline ~PNG();
|
||||
|
||||
inline auto load(const string& filename) -> bool;
|
||||
inline auto load(const uint8* sourceData, uint sourceSize) -> bool;
|
||||
inline auto readbits(const uint8*& data) -> uint;
|
||||
inline auto load(const uint8_t* sourceData, uint sourceSize) -> bool;
|
||||
inline auto readbits(const uint8_t*& data) -> uint;
|
||||
|
||||
struct Info {
|
||||
uint width;
|
||||
|
@ -31,10 +31,10 @@ struct PNG {
|
|||
uint bytesPerPixel;
|
||||
uint pitch;
|
||||
|
||||
uint8 palette[256][3];
|
||||
uint8_t palette[256][3];
|
||||
} info;
|
||||
|
||||
uint8* data = nullptr;
|
||||
uint8_t* data = nullptr;
|
||||
uint size = 0;
|
||||
|
||||
uint bitpos = 0;
|
||||
|
@ -49,9 +49,9 @@ protected:
|
|||
|
||||
inline auto interlace(uint pass, uint index) -> uint;
|
||||
inline auto inflateSize() -> uint;
|
||||
inline auto deinterlace(const uint8*& inputData, uint pass) -> bool;
|
||||
inline auto filter(uint8* outputData, const uint8* inputData, uint width, uint height) -> bool;
|
||||
inline auto read(const uint8* data, uint length) -> uint;
|
||||
inline auto deinterlace(const uint8_t*& inputData, uint pass) -> bool;
|
||||
inline auto filter(uint8_t* outputData, const uint8_t* inputData, uint width, uint height) -> bool;
|
||||
inline auto read(const uint8_t* data, uint length) -> uint;
|
||||
};
|
||||
|
||||
PNG::PNG() {
|
||||
|
@ -68,12 +68,12 @@ auto PNG::load(const string& filename) -> bool {
|
|||
return false;
|
||||
}
|
||||
|
||||
auto PNG::load(const uint8* sourceData, uint sourceSize) -> bool {
|
||||
auto PNG::load(const uint8_t* sourceData, uint sourceSize) -> bool {
|
||||
if(sourceSize < 8) return false;
|
||||
if(read(sourceData + 0, 4) != 0x89504e47) return false;
|
||||
if(read(sourceData + 4, 4) != 0x0d0a1a0a) return false;
|
||||
|
||||
uint8* compressedData = nullptr;
|
||||
uint8_t* compressedData = nullptr;
|
||||
uint compressedSize = 0;
|
||||
|
||||
uint offset = 8;
|
||||
|
@ -125,7 +125,7 @@ auto PNG::load(const uint8* sourceData, uint sourceSize) -> bool {
|
|||
}
|
||||
|
||||
if(fourCC == (uint)FourCC::IDAT) {
|
||||
compressedData = (uint8*)realloc(compressedData, compressedSize + length);
|
||||
compressedData = (uint8_t*)realloc(compressedData, compressedSize + length);
|
||||
memcpy(compressedData + compressedSize, sourceData + offset + 8, length);
|
||||
compressedSize += length;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ auto PNG::load(const uint8* sourceData, uint sourceSize) -> bool {
|
|||
}
|
||||
|
||||
uint interlacedSize = inflateSize();
|
||||
uint8 *interlacedData = new uint8[interlacedSize];
|
||||
auto interlacedData = new uint8_t[interlacedSize];
|
||||
|
||||
bool result = inflate(interlacedData, interlacedSize, compressedData + 2, compressedSize - 6);
|
||||
free(compressedData);
|
||||
|
@ -149,7 +149,7 @@ auto PNG::load(const uint8* sourceData, uint sourceSize) -> bool {
|
|||
}
|
||||
|
||||
size = info.width * info.height * info.bytesPerPixel;
|
||||
data = new uint8[size];
|
||||
data = new uint8_t[size];
|
||||
|
||||
if(info.interlaceMethod == 0) {
|
||||
if(filter(data, interlacedData, info.width, info.height) == false) {
|
||||
|
@ -159,7 +159,7 @@ auto PNG::load(const uint8* sourceData, uint sourceSize) -> bool {
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
const uint8* passData = interlacedData;
|
||||
const uint8_t* passData = interlacedData;
|
||||
for(uint pass = 0; pass < 7; pass++) {
|
||||
if(deinterlace(passData, pass) == false) {
|
||||
delete[] interlacedData;
|
||||
|
@ -205,7 +205,7 @@ auto PNG::inflateSize() -> uint {
|
|||
return size;
|
||||
}
|
||||
|
||||
auto PNG::deinterlace(const uint8*& inputData, uint pass) -> bool {
|
||||
auto PNG::deinterlace(const uint8_t*& inputData, uint pass) -> bool {
|
||||
uint xd = interlace(pass, 0), yd = interlace(pass, 1);
|
||||
uint xo = interlace(pass, 2), yo = interlace(pass, 3);
|
||||
uint width = (info.width + (xd - xo - 1)) / xd;
|
||||
|
@ -213,12 +213,12 @@ auto PNG::deinterlace(const uint8*& inputData, uint pass) -> bool {
|
|||
if(width == 0 || height == 0) return true;
|
||||
|
||||
uint outputSize = width * height * info.bytesPerPixel;
|
||||
uint8* outputData = new uint8[outputSize];
|
||||
auto outputData = new uint8_t[outputSize];
|
||||
bool result = filter(outputData, inputData, width, height);
|
||||
|
||||
const uint8* rd = outputData;
|
||||
const uint8_t* rd = outputData;
|
||||
for(uint y = yo; y < info.height; y += yd) {
|
||||
uint8* wr = data + y * info.pitch;
|
||||
uint8_t* wr = data + y * info.pitch;
|
||||
for(uint x = xo; x < info.width; x += xd) {
|
||||
for(uint b = 0; b < info.bytesPerPixel; b++) {
|
||||
wr[x * info.bytesPerPixel + b] = *rd++;
|
||||
|
@ -231,12 +231,12 @@ auto PNG::deinterlace(const uint8*& inputData, uint pass) -> bool {
|
|||
return result;
|
||||
}
|
||||
|
||||
auto PNG::filter(uint8* outputData, const uint8* inputData, uint width, uint height) -> bool {
|
||||
uint8* wr = outputData;
|
||||
const uint8* rd = inputData;
|
||||
auto PNG::filter(uint8_t* outputData, const uint8_t* inputData, uint width, uint height) -> bool {
|
||||
uint8_t* wr = outputData;
|
||||
const uint8_t* rd = inputData;
|
||||
int bpp = info.bytesPerPixel, pitch = width * bpp;
|
||||
for(int y = 0; y < height; y++) {
|
||||
uint8 filter = *rd++;
|
||||
uint8_t filter = *rd++;
|
||||
|
||||
switch(filter) {
|
||||
case 0x00: //None
|
||||
|
@ -262,7 +262,7 @@ auto PNG::filter(uint8* outputData, const uint8* inputData, uint width, uint hei
|
|||
short a = x - bpp < 0 ? 0 : wr[x - bpp];
|
||||
short b = y - 1 < 0 ? 0 : wr[x - pitch];
|
||||
|
||||
wr[x] = rd[x] + (uint8)((a + b) / 2);
|
||||
wr[x] = rd[x] + (uint8_t)((a + b) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -277,7 +277,7 @@ auto PNG::filter(uint8* outputData, const uint8* inputData, uint width, uint hei
|
|||
short pb = p > b ? p - b : b - p;
|
||||
short pc = p > c ? p - c : c - p;
|
||||
|
||||
uint8 paeth = (uint8)((pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c);
|
||||
auto paeth = (uint8_t)((pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c);
|
||||
|
||||
wr[x] = rd[x] + paeth;
|
||||
}
|
||||
|
@ -294,13 +294,13 @@ auto PNG::filter(uint8* outputData, const uint8* inputData, uint width, uint hei
|
|||
return true;
|
||||
}
|
||||
|
||||
auto PNG::read(const uint8* data, uint length) -> uint {
|
||||
auto PNG::read(const uint8_t* data, uint length) -> uint {
|
||||
uint result = 0;
|
||||
while(length--) result = (result << 8) | (*data++);
|
||||
return result;
|
||||
}
|
||||
|
||||
auto PNG::readbits(const uint8*& data) -> uint {
|
||||
auto PNG::readbits(const uint8_t*& data) -> uint {
|
||||
uint result = 0;
|
||||
switch(info.bitDepth) {
|
||||
case 1:
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace nall { namespace Decode {
|
|||
struct ZIP {
|
||||
struct File {
|
||||
string name;
|
||||
const uint8* data;
|
||||
const uint8_t* data;
|
||||
uint size;
|
||||
uint csize;
|
||||
uint cmode; //0 = uncompressed, 8 = deflate
|
||||
|
@ -31,7 +31,7 @@ struct ZIP {
|
|||
return true;
|
||||
}
|
||||
|
||||
auto open(const uint8* data, uint size) -> bool {
|
||||
auto open(const uint8_t* data, uint size) -> bool {
|
||||
if(size < 22) return false;
|
||||
|
||||
filedata = data;
|
||||
|
@ -39,7 +39,7 @@ struct ZIP {
|
|||
|
||||
file.reset();
|
||||
|
||||
const uint8* footer = data + size - 22;
|
||||
const uint8_t* footer = data + size - 22;
|
||||
while(true) {
|
||||
if(footer <= data + 22) return false;
|
||||
if(read(footer, 4) == 0x06054b50) {
|
||||
|
@ -48,7 +48,7 @@ struct ZIP {
|
|||
}
|
||||
footer--;
|
||||
}
|
||||
const uint8* directory = data + read(footer + 16, 4);
|
||||
const uint8_t* directory = data + read(footer + 16, 4);
|
||||
|
||||
while(true) {
|
||||
uint signature = read(directory + 0, 4);
|
||||
|
@ -83,8 +83,8 @@ struct ZIP {
|
|||
return true;
|
||||
}
|
||||
|
||||
auto extract(File& file) -> vector<uint8> {
|
||||
vector<uint8> buffer;
|
||||
auto extract(File& file) -> vector<uint8_t> {
|
||||
vector<uint8_t> buffer;
|
||||
|
||||
if(file.cmode == 0) {
|
||||
buffer.resize(file.size);
|
||||
|
@ -107,10 +107,10 @@ struct ZIP {
|
|||
|
||||
protected:
|
||||
filemap fm;
|
||||
const uint8* filedata;
|
||||
const uint8_t* filedata;
|
||||
uint filesize;
|
||||
|
||||
auto read(const uint8* data, uint size) -> uint {
|
||||
auto read(const uint8_t* data, uint size) -> uint {
|
||||
uint result = 0, shift = 0;
|
||||
while(size--) { result |= *data++ << shift; shift += 8; }
|
||||
return result;
|
||||
|
|
|
@ -26,11 +26,11 @@ struct Buffer {
|
|||
}
|
||||
|
||||
inline auto read(uint channel, int offset = 0) -> double& {
|
||||
return sample[channel][(uint16)(rdoffset + offset)];
|
||||
return sample[channel][(uint16_t)(rdoffset + offset)];
|
||||
}
|
||||
|
||||
inline auto write(uint channel, int offset = 0) -> double& {
|
||||
return sample[channel][(uint16)(wroffset + offset)];
|
||||
return sample[channel][(uint16_t)(wroffset + offset)];
|
||||
}
|
||||
|
||||
inline auto clear() -> void {
|
||||
|
@ -44,7 +44,7 @@ struct Buffer {
|
|||
}
|
||||
|
||||
double** sample = nullptr;
|
||||
uint16 rdoffset = 0;
|
||||
uint16 wroffset = 0;
|
||||
uint16_t rdoffset = 0;
|
||||
uint16_t wroffset = 0;
|
||||
uint channels = 0;
|
||||
};
|
||||
|
|
|
@ -73,8 +73,8 @@ struct file : file_system_object, varint {
|
|||
return S_ISREG(data.st_mode) ? data.st_size : 0u;
|
||||
}
|
||||
|
||||
static auto read(const string& filename) -> vector<uint8> {
|
||||
vector<uint8> memory;
|
||||
static auto read(const string& filename) -> vector<uint8_t> {
|
||||
vector<uint8_t> memory;
|
||||
file fp;
|
||||
if(fp.open(filename, mode::read)) {
|
||||
memory.resize(fp.size());
|
||||
|
@ -83,7 +83,7 @@ struct file : file_system_object, varint {
|
|||
return memory;
|
||||
}
|
||||
|
||||
static auto read(const string& filename, uint8* data, uint size) -> bool {
|
||||
static auto read(const string& filename, uint8_t* data, uint size) -> bool {
|
||||
file fp;
|
||||
if(fp.open(filename, mode::read) == false) return false;
|
||||
fp.read(data, size);
|
||||
|
@ -92,14 +92,14 @@ struct file : file_system_object, varint {
|
|||
}
|
||||
|
||||
static auto write(const string& filename, const string& text) -> bool {
|
||||
return write(filename, (const uint8*)text.data(), text.size());
|
||||
return write(filename, (const uint8_t*)text.data(), text.size());
|
||||
}
|
||||
|
||||
static auto write(const string& filename, const vector<uint8>& buffer) -> bool {
|
||||
static auto write(const string& filename, const vector<uint8_t>& buffer) -> bool {
|
||||
return write(filename, buffer.data(), buffer.size());
|
||||
}
|
||||
|
||||
static auto write(const string& filename, const uint8* data, uint size) -> bool {
|
||||
static auto write(const string& filename, const uint8_t* data, uint size) -> bool {
|
||||
file fp;
|
||||
if(fp.open(filename, mode::write) == false) return false;
|
||||
fp.write(data, size);
|
||||
|
@ -120,7 +120,7 @@ struct file : file_system_object, varint {
|
|||
return Hash::SHA256(buffer.data(), buffer.size()).digest();
|
||||
}
|
||||
|
||||
auto read() -> uint8 {
|
||||
auto read() -> uint8_t {
|
||||
if(!fp) return 0xff; //file not open
|
||||
if(file_mode == mode::write) return 0xff; //reads not permitted
|
||||
if(file_offset >= file_size) return 0xff; //cannot read past end of file
|
||||
|
@ -152,11 +152,11 @@ struct file : file_system_object, varint {
|
|||
return result;
|
||||
}
|
||||
|
||||
auto read(uint8* buffer, uint length) -> void {
|
||||
auto read(uint8_t* buffer, uint length) -> void {
|
||||
while(length--) *buffer++ = read();
|
||||
}
|
||||
|
||||
auto write(uint8 data) -> void {
|
||||
auto write(uint8_t data) -> void {
|
||||
if(!fp) return; //file not open
|
||||
if(file_mode == mode::read) return; //writes not permitted
|
||||
buffer_sync();
|
||||
|
@ -182,7 +182,7 @@ struct file : file_system_object, varint {
|
|||
for(auto byte : s) write(byte);
|
||||
}
|
||||
|
||||
auto write(const uint8* buffer, uint length) -> void {
|
||||
auto write(const uint8_t* buffer, uint length) -> void {
|
||||
while(length--) write(*buffer++);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@ struct bitstream {
|
|||
close();
|
||||
}
|
||||
|
||||
auto read(uint64 addr) const -> bool {
|
||||
auto read(uint64_t addr) const -> bool {
|
||||
if(data == nullptr || (addr >> 3) >= size) return 0;
|
||||
uint mask = endian == 0 ? (0x01 << (addr & 7)) : (0x80 >> (addr & 7));
|
||||
return data[addr >> 3] & mask;
|
||||
}
|
||||
|
||||
auto write(uint64 addr, bool value) -> void {
|
||||
auto write(uint64_t addr, bool value) -> void {
|
||||
if(data == nullptr || readonly == true || (addr >> 3) >= size) return;
|
||||
uint mask = endian == 0 ? (0x01 << (addr & 7)) : (0x80 >> (addr & 7));
|
||||
if(value == 0) data[addr >> 3] &= ~mask;
|
||||
|
@ -39,7 +39,7 @@ struct bitstream {
|
|||
}
|
||||
|
||||
filemap fp;
|
||||
uint8* data = nullptr;
|
||||
uint8_t* data = nullptr;
|
||||
uint size = 0;
|
||||
bool readonly = false;
|
||||
bool endian = 1;
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace nall { namespace mosaic {
|
|||
|
||||
struct parser {
|
||||
//export from bitstream to canvas
|
||||
auto load(bitstream& stream, uint64 offset, context& ctx, uint width, uint height) -> void {
|
||||
auto load(bitstream& stream, uint64_t offset, context& ctx, uint width, uint height) -> void {
|
||||
canvas.allocate(width, height);
|
||||
canvas.fill(ctx.paddingColor);
|
||||
parse(1, stream, offset, ctx, width, height);
|
||||
|
@ -18,21 +18,21 @@ struct parser {
|
|||
}
|
||||
|
||||
private:
|
||||
auto read(uint x, uint y) const -> uint32 {
|
||||
auto read(uint x, uint y) const -> uint32_t {
|
||||
uint addr = y * canvas.width() + x;
|
||||
if(addr >= canvas.width() * canvas.height()) return 0u;
|
||||
auto buffer = (uint32*)canvas.data();
|
||||
auto buffer = (uint32_t*)canvas.data();
|
||||
return buffer[addr];
|
||||
}
|
||||
|
||||
auto write(uint x, uint y, uint32_t data) -> void {
|
||||
uint addr = y * canvas.width() + x;
|
||||
if(addr >= canvas.width() * canvas.height()) return;
|
||||
auto buffer = (uint32*)canvas.data();
|
||||
auto buffer = (uint32_t*)canvas.data();
|
||||
buffer[addr] = data;
|
||||
}
|
||||
|
||||
auto parse(bool load, bitstream& stream, uint64 offset, context& ctx, uint width, uint height) -> void {
|
||||
auto parse(bool load, bitstream& stream, uint64_t offset, context& ctx, uint width, uint height) -> void {
|
||||
stream.endian = ctx.endian;
|
||||
uint canvasWidth = width / (ctx.mosaicWidth * ctx.tileWidth * ctx.blockWidth + ctx.paddingWidth);
|
||||
uint canvasHeight = height / (ctx.mosaicHeight * ctx.tileHeight * ctx.blockHeight + ctx.paddingHeight);
|
||||
|
|
|
@ -7,10 +7,10 @@ namespace nall {
|
|||
|
||||
struct Boolean {
|
||||
inline Boolean() : data(false) {}
|
||||
inline Boolean(bool value) : data(value) {}
|
||||
template<typename T> inline Boolean(const T& value) : data(value) {}
|
||||
|
||||
inline operator bool() const { return data; }
|
||||
inline auto& operator=(const bool value) { data = value; return *this; }
|
||||
template<typename T> inline auto& operator=(const T& value) { data = value; return *this; }
|
||||
|
||||
inline auto serialize(serializer& s) { s(data); }
|
||||
|
||||
|
@ -28,12 +28,10 @@ template<uint Bits> struct Natural {
|
|||
enum : type { Mask = ~0ull >> (64 - Bits) };
|
||||
|
||||
inline Natural() : data(0) {}
|
||||
inline Natural(const type value) : data(clip(value)) {}
|
||||
template<uint B> inline Natural(const Natural<B> value) : data(clip(value)) {}
|
||||
template<typename T> inline Natural(const T& value) : data(clip(value)) {}
|
||||
|
||||
inline operator type() const { return data; }
|
||||
inline auto& operator=(const type value) { data = clip(value); return *this; }
|
||||
template<uint B> inline auto& operator=(const Natural<B> value) { data = clip(value); return *this; }
|
||||
template<typename T> inline auto& operator=(const T& value) { data = clip(value); return *this; }
|
||||
|
||||
inline auto operator++(int) { type value = data; data = clip(data + 1); return value; }
|
||||
inline auto operator--(int) { type value = data; data = clip(data - 1); return value; }
|
||||
|
@ -54,6 +52,32 @@ template<uint Bits> struct Natural {
|
|||
|
||||
inline auto serialize(serializer& s) { s(data); }
|
||||
|
||||
struct Reference {
|
||||
inline Reference(Natural& source, uint Lo, uint Hi) : source(source), Lo(Lo), Hi(Hi) {}
|
||||
|
||||
inline operator type() const {
|
||||
const type RangeBits = Hi - Lo + 1;
|
||||
const type RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask;
|
||||
return (source & RangeMask) >> Lo;
|
||||
}
|
||||
|
||||
inline auto& operator=(const type value) {
|
||||
const type RangeBits = Hi - Lo + 1;
|
||||
const type RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask;
|
||||
source = (source & ~RangeMask) | ((value << Lo) & RangeMask);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Natural& source;
|
||||
const uint Lo;
|
||||
const uint Hi;
|
||||
};
|
||||
|
||||
inline auto bits(uint lo, uint hi) -> Reference { return {*this, lo, hi}; }
|
||||
inline auto bit(uint index) -> Reference { return {*this, index, index}; }
|
||||
inline auto byte(uint index) -> Reference { return {*this, index * 8 + 0, index * 8 + 7}; }
|
||||
|
||||
template<uint Lo, uint Hi> struct Range {
|
||||
enum : type { RangeBits = Hi - Lo + 1, RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask };
|
||||
|
||||
|
@ -109,12 +133,10 @@ template<uint Bits> struct Integer {
|
|||
enum : utype { Mask = ~0ull >> (64 - Bits), Sign = 1ull << (Bits - 1) };
|
||||
|
||||
inline Integer() : data(0) {}
|
||||
inline Integer(const type value) : data(clip(value)) {}
|
||||
template<uint B> inline Integer(const Integer<B> value) : data(clip(value)) {}
|
||||
template<typename T> inline Integer(const T& value) : data(clip(value)) {}
|
||||
|
||||
inline operator type() const { return data; }
|
||||
inline auto& operator=(const type value) { data = clip(value); return *this; }
|
||||
template<uint B> inline auto& operator=(const Integer<B> value) { data = clip(value); return *this; }
|
||||
template<typename T> inline auto& operator=(const T& value) { data = clip(value); return *this; }
|
||||
|
||||
inline auto operator++(int) { type value = data; data = clip(data + 1); return value; }
|
||||
inline auto operator--(int) { type value = data; data = clip(data - 1); return value; }
|
||||
|
@ -135,15 +157,41 @@ template<uint Bits> struct Integer {
|
|||
|
||||
inline auto serialize(serializer& s) { s(data); }
|
||||
|
||||
struct Reference {
|
||||
inline Reference(Integer& source, uint Lo, uint Hi) : source(source), Lo(Lo), Hi(Hi) {}
|
||||
|
||||
inline operator utype() const {
|
||||
const type RangeBits = Hi - Lo + 1;
|
||||
const type RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask;
|
||||
return ((utype)source & RangeMask) >> Lo;
|
||||
}
|
||||
|
||||
inline auto& operator=(const utype value) {
|
||||
const type RangeBits = Hi - Lo + 1;
|
||||
const type RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask;
|
||||
source = ((utype)source & ~RangeMask) | ((value << Lo) & RangeMask);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Integer& source;
|
||||
uint Lo;
|
||||
uint Hi;
|
||||
};
|
||||
|
||||
inline auto bits(uint lo, uint hi) -> Reference { return {*this, lo, hi}; }
|
||||
inline auto bit(uint index) -> Reference { return {*this, index, index}; }
|
||||
inline auto byte(uint index) -> Reference { return {*this, index * 8 + 0, index * 8 + 7}; }
|
||||
|
||||
template<uint Lo, uint Hi> struct Range {
|
||||
enum : utype { RangeBits = Hi - Lo + 1, RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask };
|
||||
|
||||
inline operator utype() const {
|
||||
return (self() & RangeMask) >> Lo;
|
||||
return ((utype)self() & RangeMask) >> Lo;
|
||||
}
|
||||
|
||||
inline auto& operator=(const utype value) {
|
||||
self() = (((self() & ~RangeMask) | ((value << Lo) & RangeMask)) ^ Sign) - Sign;
|
||||
self() = ((((utype)self() & ~RangeMask) | ((value << Lo) & RangeMask)) ^ Sign) - Sign;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -186,12 +234,10 @@ template<uint Bits> struct Real {
|
|||
void>>>;
|
||||
|
||||
inline Real() : data(0.0) {}
|
||||
inline Real(const type value) : data(value) {}
|
||||
template<uint B> inline Real(const Real<B> value) : data((type)value) {}
|
||||
template<typename T> inline Real(const T& value) : data((type)value) {}
|
||||
|
||||
inline operator type() const { return data; }
|
||||
inline auto& operator=(const type value) { data = value; return *this; }
|
||||
template<uint B> inline auto& operator=(const Real<B> value) { data = (type)value; return *this; }
|
||||
template<typename T> inline auto& operator=(const T& value) { data = (type)value; return *this; }
|
||||
|
||||
inline auto operator++(int) { type value = data; ++data; return value; }
|
||||
inline auto operator--(int) { type value = data; --data; return value; }
|
||||
|
|
|
@ -33,7 +33,7 @@ struct serializer {
|
|||
return _mode;
|
||||
}
|
||||
|
||||
auto data() const -> const uint8* {
|
||||
auto data() const -> const uint8_t* {
|
||||
return _data;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ struct serializer {
|
|||
enum { size = sizeof(T) };
|
||||
//this is rather dangerous, and not cross-platform safe;
|
||||
//but there is no standardized way to export FP-values
|
||||
auto p = (uint8*)&value;
|
||||
auto p = (uint8_t*)&value;
|
||||
if(_mode == Save) {
|
||||
for(uint n = 0; n < size; n++) _data[_size++] = p[n];
|
||||
} else if(_mode == Load) {
|
||||
|
@ -93,7 +93,7 @@ struct serializer {
|
|||
if(_data) delete[] _data;
|
||||
|
||||
_mode = s._mode;
|
||||
_data = new uint8[s._capacity];
|
||||
_data = new uint8_t[s._capacity];
|
||||
_size = s._size;
|
||||
_capacity = s._capacity;
|
||||
|
||||
|
@ -119,14 +119,14 @@ struct serializer {
|
|||
|
||||
serializer(uint capacity) {
|
||||
_mode = Save;
|
||||
_data = new uint8[capacity]();
|
||||
_data = new uint8_t[capacity]();
|
||||
_size = 0;
|
||||
_capacity = capacity;
|
||||
}
|
||||
|
||||
serializer(const uint8* data, uint capacity) {
|
||||
serializer(const uint8_t* data, uint capacity) {
|
||||
_mode = Load;
|
||||
_data = new uint8[capacity];
|
||||
_data = new uint8_t[capacity];
|
||||
_size = 0;
|
||||
_capacity = capacity;
|
||||
memcpy(_data, data, capacity);
|
||||
|
@ -138,7 +138,7 @@ struct serializer {
|
|||
|
||||
private:
|
||||
Mode _mode = Size;
|
||||
uint8* _data = nullptr;
|
||||
uint8_t* _data = nullptr;
|
||||
uint _size = 0;
|
||||
uint _capacity = 0;
|
||||
};
|
||||
|
|
|
@ -49,22 +49,22 @@ static_assert(sizeof(float) >= 4, "float32_t is not of the correct size")
|
|||
static_assert(sizeof(double) >= 8, "float64_t is not of the correct size");
|
||||
static_assert(sizeof(long double) >= 10, "float80_t is not of the correct size");
|
||||
|
||||
using int8 = int8_t;
|
||||
using int16 = int16_t;
|
||||
using int32 = int32_t;
|
||||
using int64 = int64_t;
|
||||
//using int8 = int8_t;
|
||||
//using int16 = int16_t;
|
||||
//using int32 = int32_t;
|
||||
//using int64 = int64_t;
|
||||
using intmax = intmax_t;
|
||||
using intptr = intptr_t;
|
||||
|
||||
using uint = unsigned int;
|
||||
using uint8 = uint8_t;
|
||||
using uint16 = uint16_t;
|
||||
using uint32 = uint32_t;
|
||||
using uint64 = uint64_t;
|
||||
//using uint8 = uint8_t;
|
||||
//using uint16 = uint16_t;
|
||||
//using uint32 = uint32_t;
|
||||
//using uint64 = uint64_t;
|
||||
using uintmax = uintmax_t;
|
||||
using uintptr = uintptr_t;
|
||||
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
using int128 = int128_t;
|
||||
using uint128 = uint128_t;
|
||||
//using int128 = int128_t;
|
||||
//using uint128 = uint128_t;
|
||||
#endif
|
||||
|
|
|
@ -10,11 +10,11 @@ inline auto makestream(const string& path) -> std::unique_ptr<stream> {
|
|||
return std::unique_ptr<stream>(new mmapstream(path));
|
||||
}
|
||||
|
||||
inline auto makestream(uint8* data, uint size) -> std::unique_ptr<stream> {
|
||||
inline auto makestream(uint8_t* data, uint size) -> std::unique_ptr<stream> {
|
||||
return std::unique_ptr<stream>(new memorystream(data, size));
|
||||
}
|
||||
|
||||
inline auto makestream(const uint8* data, uint size) -> std::unique_ptr<stream> {
|
||||
inline auto makestream(const uint8_t* data, uint size) -> std::unique_ptr<stream> {
|
||||
return std::unique_ptr<stream>(new memorystream(data, size));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ struct filestream : stream {
|
|||
|
||||
auto size() const -> uint { return pfile.size(); }
|
||||
auto offset() const -> uint { return pfile.offset(); }
|
||||
auto seek(unsigned offset) const -> void { pfile.seek(offset); }
|
||||
auto seek(uint offset) const -> void { pfile.seek(offset); }
|
||||
|
||||
auto read() const -> uint8 { return pfile.read(); }
|
||||
auto read() const -> uint8_t { return pfile.read(); }
|
||||
auto write(uint8_t data) const -> void { pfile.write(data); }
|
||||
|
||||
private:
|
||||
|
|
|
@ -10,7 +10,7 @@ struct gzipstream : memorystream {
|
|||
|
||||
gzipstream(const stream& stream) {
|
||||
uint size = stream.size();
|
||||
auto data = new uint8[size];
|
||||
auto data = new uint8_t[size];
|
||||
stream.read(data, size);
|
||||
|
||||
Decode::GZIP archive;
|
||||
|
|
|
@ -10,14 +10,14 @@ struct memorystream : stream {
|
|||
|
||||
memorystream() = default;
|
||||
|
||||
memorystream(uint8* data, uint size) {
|
||||
memorystream(uint8_t* data, uint size) {
|
||||
pdata = data;
|
||||
psize = size;
|
||||
pwritable = true;
|
||||
}
|
||||
|
||||
memorystream(const uint8* data, uint size) {
|
||||
pdata = (uint8*)data;
|
||||
memorystream(const uint8_t* data, uint size) {
|
||||
pdata = (uint8_t*)data;
|
||||
psize = size;
|
||||
pwritable = false;
|
||||
}
|
||||
|
@ -27,19 +27,19 @@ struct memorystream : stream {
|
|||
auto writable() const -> bool { return pwritable; }
|
||||
auto randomaccess() const -> bool { return true; }
|
||||
|
||||
auto data() const -> uint8* { return pdata; }
|
||||
auto data() const -> uint8_t* { return pdata; }
|
||||
auto size() const -> uint { return psize; }
|
||||
auto offset() const -> uint { return poffset; }
|
||||
auto seek(uint offset) const -> void { poffset = offset; }
|
||||
|
||||
auto read() const -> uint8 { return pdata[poffset++]; }
|
||||
auto write(uint8 data) const -> void { pdata[poffset++] = data; }
|
||||
auto read() const -> uint8_t { return pdata[poffset++]; }
|
||||
auto write(uint8_t data) const -> void { pdata[poffset++] = data; }
|
||||
|
||||
auto read(uint offset) const -> uint8 { return pdata[offset]; }
|
||||
auto write(uint offset, uint8 data) const -> void { pdata[offset] = data; }
|
||||
auto read(uint offset) const -> uint8_t { return pdata[offset]; }
|
||||
auto write(uint offset, uint8_t data) const -> void { pdata[offset] = data; }
|
||||
|
||||
protected:
|
||||
mutable uint8* pdata = nullptr;
|
||||
mutable uint8_t* pdata = nullptr;
|
||||
mutable uint psize = 0;
|
||||
mutable uint poffset = 0;
|
||||
mutable bool pwritable = false;
|
||||
|
|
|
@ -23,17 +23,17 @@ struct mmapstream : stream {
|
|||
|
||||
auto size() const -> uint { return pmmap.size(); }
|
||||
auto offset() const -> uint { return poffset; }
|
||||
auto seek(unsigned offset) const -> void { poffset = offset; }
|
||||
auto seek(uint offset) const -> void { poffset = offset; }
|
||||
|
||||
auto read() const -> uint8 { return pdata[poffset++]; }
|
||||
auto write(uint8 data) const -> void { pdata[poffset++] = data; }
|
||||
auto read() const -> uint8_t { return pdata[poffset++]; }
|
||||
auto write(uint8_t data) const -> void { pdata[poffset++] = data; }
|
||||
|
||||
auto read(uint offset) const -> uint8 { return pdata[offset]; }
|
||||
auto write(uint offset, uint8 data) const -> void { pdata[offset] = data; }
|
||||
auto read(uint offset) const -> uint8_t { return pdata[offset]; }
|
||||
auto write(uint offset, uint8_t data) const -> void { pdata[offset] = data; }
|
||||
|
||||
private:
|
||||
mutable filemap pmmap;
|
||||
mutable uint8* pdata = nullptr;
|
||||
mutable uint8_t* pdata = nullptr;
|
||||
mutable uint poffset = 0;
|
||||
mutable bool pwritable = false;
|
||||
};
|
||||
|
|
|
@ -14,16 +14,16 @@ struct stream {
|
|||
virtual auto writable() const -> bool = 0;
|
||||
virtual auto randomaccess() const -> bool = 0;
|
||||
|
||||
virtual auto data() const -> uint8* { return nullptr; }
|
||||
virtual auto data() const -> uint8_t* { return nullptr; }
|
||||
virtual auto size() const -> uint = 0;
|
||||
virtual auto offset() const -> uint = 0;
|
||||
virtual auto seek(unsigned offset) const -> void = 0;
|
||||
virtual auto seek(uint offset) const -> void = 0;
|
||||
|
||||
virtual auto read() const -> uint8 = 0;
|
||||
virtual auto read() const -> uint8_t = 0;
|
||||
virtual auto write(uint8_t data) const -> void = 0;
|
||||
|
||||
virtual auto read(uint) const -> uint8 { return 0; }
|
||||
virtual auto write(uint, uint8) const -> void {}
|
||||
virtual auto read(uint) const -> uint8_t { return 0; }
|
||||
virtual auto write(uint, uint8_t) const -> void {}
|
||||
|
||||
explicit operator bool() const {
|
||||
return size();
|
||||
|
@ -49,7 +49,7 @@ struct stream {
|
|||
return data;
|
||||
}
|
||||
|
||||
auto read(uint8* data, uint length) const -> void {
|
||||
auto read(uint8_t* data, uint length) const -> void {
|
||||
while(length--) *data++ = read();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ struct stream {
|
|||
string buffer;
|
||||
buffer.resize(size());
|
||||
seek(0);
|
||||
read((uint8*)buffer.get(), size());
|
||||
read((uint8_t*)buffer.get(), size());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -76,13 +76,13 @@ struct stream {
|
|||
}
|
||||
}
|
||||
|
||||
auto write(const uint8* data, uint length) const -> void {
|
||||
auto write(const uint8_t* data, uint length) const -> void {
|
||||
while(length--) write(*data++);
|
||||
}
|
||||
|
||||
struct byte {
|
||||
byte(const stream& s, uint offset) : s(s), offset(offset) {}
|
||||
operator uint8() const { return s.read(offset); }
|
||||
operator uint8_t() const { return s.read(offset); }
|
||||
auto operator=(uint8_t data) -> byte& { s.write(offset, data); return *this; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -9,27 +9,27 @@ struct vectorstream : stream {
|
|||
using stream::read;
|
||||
using stream::write;
|
||||
|
||||
vectorstream(vector<uint8>& memory) : memory(memory), pwritable(true) {}
|
||||
vectorstream(const vector<uint8>& memory) : memory((vector<uint8>&)memory), pwritable(false) {}
|
||||
vectorstream(vector<uint8_t>& memory) : memory(memory), pwritable(true) {}
|
||||
vectorstream(const vector<uint8_t>& memory) : memory((vector<uint8_t>&)memory), pwritable(false) {}
|
||||
|
||||
auto seekable() const -> bool { return true; }
|
||||
auto readable() const -> bool { return true; }
|
||||
auto writable() const -> bool { return pwritable; }
|
||||
auto randomaccess() const -> bool { return true; }
|
||||
|
||||
auto data() const -> uint8* { return memory.data(); }
|
||||
auto data() const -> uint8_t* { return memory.data(); }
|
||||
auto size() const -> uint { return memory.size(); }
|
||||
auto offset() const -> uint { return poffset; }
|
||||
auto seek(unsigned offset) const -> void { poffset = offset; }
|
||||
auto seek(uint offset) const -> void { poffset = offset; }
|
||||
|
||||
auto read() const -> uint8 { return memory[poffset++]; }
|
||||
auto write(uint8 data) const -> void { memory[poffset++] = data; }
|
||||
auto read() const -> uint8_t { return memory[poffset++]; }
|
||||
auto write(uint8_t data) const -> void { memory[poffset++] = data; }
|
||||
|
||||
auto read(uint offset) const -> uint8 { return memory[offset]; }
|
||||
auto write(uint offset, uint8 data) const -> void { memory[offset] = data; }
|
||||
auto read(uint offset) const -> uint8_t { return memory[offset]; }
|
||||
auto write(uint offset, uint8_t data) const -> void { memory[offset] = data; }
|
||||
|
||||
protected:
|
||||
vector<uint8>& memory;
|
||||
vector<uint8_t>& memory;
|
||||
mutable uint poffset = 0;
|
||||
mutable bool pwritable = false;
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ struct zipstream : memorystream {
|
|||
|
||||
zipstream(const stream& stream, const string& filter = "*") {
|
||||
uint size = stream.size();
|
||||
auto data = new uint8[size];
|
||||
auto data = new uint8_t[size];
|
||||
stream.read(data, size);
|
||||
|
||||
Decode::ZIP archive;
|
||||
|
|
|
@ -36,7 +36,7 @@ inline auto evaluateExpression(Node* node) -> string {
|
|||
throw "invalid operator";
|
||||
}
|
||||
|
||||
inline auto evaluateInteger(Node* node) -> int64 {
|
||||
inline auto evaluateInteger(Node* node) -> int64_t {
|
||||
if(node->type == Node::Type::Literal) return nall::integer(node->literal);
|
||||
|
||||
#define p(n) evaluateInteger(node->link[n])
|
||||
|
@ -85,7 +85,7 @@ inline auto evaluateInteger(Node* node) -> int64 {
|
|||
throw "invalid operator";
|
||||
}
|
||||
|
||||
inline auto integer(const string& expression) -> maybe<int64> {
|
||||
inline auto integer(const string& expression) -> maybe<int64_t> {
|
||||
try {
|
||||
auto tree = new Node;
|
||||
const char* p = expression;
|
||||
|
|
|
@ -56,7 +56,7 @@ struct InputXlib : Input {
|
|||
return devices;
|
||||
}
|
||||
|
||||
auto rumble(uint64 id, bool enable) -> bool {
|
||||
auto rumble(uint64_t id, bool enable) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue