diff --git a/higan/emulator/emulator.hpp b/higan/emulator/emulator.hpp index a68ba7a2..36f408db 100644 --- a/higan/emulator/emulator.hpp +++ b/higan/emulator/emulator.hpp @@ -4,9 +4,27 @@ #include 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; + 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 struct hook R> { #else #define privileged private #endif - -using varuint = varuint_t; diff --git a/higan/processor/arm/arm.cpp b/higan/processor/arm/arm.cpp index 82aae781..6c3090da 100644 --- a/higan/processor/arm/arm.cpp +++ b/higan/processor/arm/arm.cpp @@ -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) { diff --git a/higan/processor/arm/registers.hpp b/higan/processor/arm/registers.hpp index ab332ced..7ea22d2a 100644 --- a/higan/processor/arm/registers.hpp +++ b/higan/processor/arm/registers.hpp @@ -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 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; } diff --git a/higan/processor/r65816/r65816.hpp b/higan/processor/r65816/r65816.hpp index f63e9c55..18f61252 100644 --- a/higan/processor/r65816/r65816.hpp +++ b/higan/processor/r65816/r65816.hpp @@ -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; diff --git a/higan/processor/v30mz/algorithms.cpp b/higan/processor/v30mz/algorithms.cpp index 37b1aacc..a75eae95 100644 --- a/higan/processor/v30mz/algorithms.cpp +++ b/higan/processor/v30mz/algorithms.cpp @@ -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; diff --git a/higan/processor/v30mz/instructions-alu.cpp b/higan/processor/v30mz/instructions-alu.cpp index 9726797b..c15f4ba0 100644 --- a/higan/processor/v30mz/instructions-alu.cpp +++ b/higan/processor/v30mz/instructions-alu.cpp @@ -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 diff --git a/higan/processor/v30mz/instructions-exec.cpp b/higan/processor/v30mz/instructions-exec.cpp index 54d59cfa..fb11ab06 100644 --- a/higan/processor/v30mz/instructions-exec.cpp +++ b/higan/processor/v30mz/instructions-exec.cpp @@ -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() { diff --git a/higan/processor/v30mz/instructions-group.cpp b/higan/processor/v30mz/instructions-group.cpp index 09bf6c2a..bc8544a7 100644 --- a/higan/processor/v30mz/instructions-group.cpp +++ b/higan/processor/v30mz/instructions-group.cpp @@ -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; diff --git a/higan/sfc/controller/gamepad/gamepad.cpp b/higan/sfc/controller/gamepad/gamepad.cpp index 5fad8a2b..e2c38f6e 100644 --- a/higan/sfc/controller/gamepad/gamepad.cpp +++ b/higan/sfc/controller/gamepad/gamepad.cpp @@ -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); diff --git a/higan/sfc/controller/gamepad/gamepad.hpp b/higan/sfc/controller/gamepad/gamepad.hpp index a2c9e69c..9170d8e1 100644 --- a/higan/sfc/controller/gamepad/gamepad.hpp +++ b/higan/sfc/controller/gamepad/gamepad.hpp @@ -10,7 +10,7 @@ struct Gamepad : Controller { private: bool latched; - unsigned counter; + uint counter; bool b, y, select, start; bool up, down, left, right; diff --git a/higan/sfc/coprocessor/sa1/memory/memory.cpp b/higan/sfc/coprocessor/sa1/memory/memory.cpp index 005bf133..acb09acb 100644 --- a/higan/sfc/coprocessor/sa1/memory/memory.cpp +++ b/higan/sfc/coprocessor/sa1/memory/memory.cpp @@ -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); diff --git a/higan/sfc/coprocessor/sa1/memory/memory.hpp b/higan/sfc/coprocessor/sa1/memory/memory.hpp index c36b07c7..1fa165ca 100644 --- a/higan/sfc/coprocessor/sa1/memory/memory.hpp +++ b/higan/sfc/coprocessor/sa1/memory/memory.hpp @@ -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; diff --git a/higan/sfc/dsp/dsp.cpp b/higan/sfc/dsp/dsp.cpp index bb0e4dff..b1296db8 100644 --- a/higan/sfc/dsp/dsp.cpp +++ b/higan/sfc/dsp/dsp.cpp @@ -18,11 +18,11 @@ 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((-1 >> 1) == -1, "arithmetic shift right"); + 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 assert(sclamp<16>(+0x8000) == +0x7fff); diff --git a/higan/sfc/ppu/video.cpp b/higan/sfc/ppu/video.cpp index 04bf71a6..01f080e1 100644 --- a/higan/sfc/ppu/video.cpp +++ b/higan/sfc/ppu/video.cpp @@ -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; diff --git a/higan/target-tomoko/input/input.cpp b/higan/target-tomoko/input/input.cpp index 8cccdc1d..d8db41c0 100644 --- a/higan/target-tomoko/input/input.cpp +++ b/higan/target-tomoko/input/input.cpp @@ -210,7 +210,7 @@ auto InputManager::poll() -> void { if(presentation && presentation->focused()) pollHotkeys(); } -auto InputManager::onChange(shared_pointer device, uint group, uint input, int16 oldValue, int16 newValue) -> void { +auto InputManager::onChange(shared_pointer 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); diff --git a/higan/target-tomoko/input/input.hpp b/higan/target-tomoko/input/input.hpp index 87b84a33..f3551d95 100644 --- a/higan/target-tomoko/input/input.hpp +++ b/higan/target-tomoko/input/input.hpp @@ -48,7 +48,7 @@ struct InputManager { InputManager(); auto bind() -> void; auto poll() -> void; - auto onChange(shared_pointer device, uint group, uint input, int16 oldValue, int16 newValue) -> void; + auto onChange(shared_pointer device, uint group, uint input, int16_t oldValue, int16_t newValue) -> void; auto quit() -> void; auto findMouse() -> shared_pointer; diff --git a/higan/target-tomoko/presentation/presentation.cpp b/higan/target-tomoko/presentation/presentation.cpp index c722cf7b..d0831673 100644 --- a/higan/target-tomoko/presentation/presentation.cpp +++ b/higan/target-tomoko/presentation/presentation.cpp @@ -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(); diff --git a/higan/target-tomoko/program/interface.cpp b/higan/target-tomoko/program/interface.cpp index 1af604ac..e4279b74 100644 --- a/higan/target-tomoko/program/interface.cpp +++ b/higan/target-tomoko/program/interface.cpp @@ -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)) { diff --git a/higan/ws/cpu/io.cpp b/higan/ws/cpu/io.cpp index 7a3bea99..5b47041c 100644 --- a/higan/ws/cpu/io.cpp +++ b/higan/ws/cpu/io.cpp @@ -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; } diff --git a/hiro/core/widget/canvas.cpp b/hiro/core/widget/canvas.cpp index 55df58aa..64d8e57b 100644 --- a/hiro/core/widget/canvas.cpp +++ b/hiro/core/widget/canvas.cpp @@ -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 { diff --git a/hiro/extension/message-dialog.hpp b/hiro/extension/message-dialog.hpp index cd53ae69..64f845a1 100644 --- a/hiro/extension/message-dialog.hpp +++ b/hiro/extension/message-dialog.hpp @@ -15,7 +15,7 @@ struct MessageDialog { private: struct State { lstring buttons; - vector icon; + vector icon; sWindow parent; string response; string text; diff --git a/hiro/gtk/widget/canvas.cpp b/hiro/gtk/widget/canvas.cpp index 9b14efa0..ca9fc7ae 100644 --- a/hiro/gtk/widget/canvas.cpp +++ b/hiro/gtk/widget/canvas.cpp @@ -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; } diff --git a/icarus/core/bs-memory.cpp b/icarus/core/bs-memory.cpp index bc32d71f..ad41df54 100644 --- a/icarus/core/bs-memory.cpp +++ b/icarus/core/bs-memory.cpp @@ -1,10 +1,10 @@ auto Icarus::bsMemoryManifest(string location) -> string { - vector buffer; + vector buffer; concatenate(buffer, {location, "program.rom"}); return bsMemoryManifest(buffer, location); } -auto Icarus::bsMemoryManifest(vector& buffer, string location) -> string { +auto Icarus::bsMemoryManifest(vector& buffer, string location) -> string { string markup; string digest = Hash::SHA256(buffer.data(), buffer.size()).digest(); @@ -31,7 +31,7 @@ auto Icarus::bsMemoryManifest(vector& buffer, string location) -> string return markup; } -auto Icarus::bsMemoryImport(vector& buffer, string location) -> string { +auto Icarus::bsMemoryImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "BS Memory/", name, ".bs/"}; diff --git a/icarus/core/core.cpp b/icarus/core/core.cpp index d60601cb..aa2ac1f1 100644 --- a/icarus/core/core.cpp +++ b/icarus/core/core.cpp @@ -77,7 +77,7 @@ auto Icarus::import(string location) -> string { return failure("unrecognized file extension"); } -auto Icarus::concatenate(vector& output, string location) -> void { +auto Icarus::concatenate(vector& output, string location) -> void { if(auto input = file::read(location)) { auto size = output.size(); output.resize(size + input.size()); diff --git a/icarus/core/core.hpp b/icarus/core/core.hpp index 341ef607..deb308cc 100644 --- a/icarus/core/core.hpp +++ b/icarus/core/core.hpp @@ -9,53 +9,53 @@ struct Icarus { auto manifest(string location) -> string; auto import(string location) -> string; - auto concatenate(vector& output, string location) -> void; + auto concatenate(vector& output, string location) -> void; //famicom.cpp auto famicomManifest(string location) -> string; - auto famicomManifest(vector& buffer, string location, uint* prgrom = nullptr, uint* chrrom = nullptr) -> string; - auto famicomImport(vector& buffer, string location) -> string; + auto famicomManifest(vector& buffer, string location, uint* prgrom = nullptr, uint* chrrom = nullptr) -> string; + auto famicomImport(vector& buffer, string location) -> string; //super-famicom.cpp auto superFamicomManifest(string location) -> string; - auto superFamicomManifest(vector& buffer, string location, bool* firmwareAppended = nullptr) -> string; + auto superFamicomManifest(vector& buffer, string location, bool* firmwareAppended = nullptr) -> string; auto superFamicomManifestScan(vector& roms, Markup::Node node) -> void; - auto superFamicomImport(vector& buffer, string location) -> string; + auto superFamicomImport(vector& buffer, string location) -> string; //game-boy.cpp auto gameBoyManifest(string location) -> string; - auto gameBoyManifest(vector& buffer, string location) -> string; - auto gameBoyImport(vector& buffer, string location) -> string; + auto gameBoyManifest(vector& buffer, string location) -> string; + auto gameBoyImport(vector& buffer, string location) -> string; //game-boy-color.cpp auto gameBoyColorManifest(string location) -> string; - auto gameBoyColorManifest(vector& buffer, string location) -> string; - auto gameBoyColorImport(vector& buffer, string location) -> string; + auto gameBoyColorManifest(vector& buffer, string location) -> string; + auto gameBoyColorImport(vector& buffer, string location) -> string; //game-boy-advance.cpp auto gameBoyAdvanceManifest(string location) -> string; - auto gameBoyAdvanceManifest(vector& buffer, string location) -> string; - auto gameBoyAdvanceImport(vector& buffer, string location) -> string; + auto gameBoyAdvanceManifest(vector& buffer, string location) -> string; + auto gameBoyAdvanceImport(vector& buffer, string location) -> string; //bs-memory.cpp auto bsMemoryManifest(string location) -> string; - auto bsMemoryManifest(vector& buffer, string location) -> string; - auto bsMemoryImport(vector& buffer, string location) -> string; + auto bsMemoryManifest(vector& buffer, string location) -> string; + auto bsMemoryImport(vector& buffer, string location) -> string; //sufami-turbo.cpp auto sufamiTurboManifest(string location) -> string; - auto sufamiTurboManifest(vector& buffer, string location) -> string; - auto sufamiTurboImport(vector& buffer, string location) -> string; + auto sufamiTurboManifest(vector& buffer, string location) -> string; + auto sufamiTurboImport(vector& buffer, string location) -> string; //wonderswan.cpp auto wonderSwanManifest(string location) -> string; - auto wonderSwanManifest(vector& buffer, string location) -> string; - auto wonderSwanImport(vector& buffer, string location) -> string; + auto wonderSwanManifest(vector& buffer, string location) -> string; + auto wonderSwanImport(vector& buffer, string location) -> string; //wonderswan-color.cpp auto wonderSwanColorManifest(string location) -> string; - auto wonderSwanColorManifest(vector& buffer, string location) -> string; - auto wonderSwanColorImport(vector& buffer, string location) -> string; + auto wonderSwanColorManifest(vector& buffer, string location) -> string; + auto wonderSwanColorImport(vector& buffer, string location) -> string; private: string errorMessage; diff --git a/icarus/core/famicom.cpp b/icarus/core/famicom.cpp index d5292d31..97b03a08 100644 --- a/icarus/core/famicom.cpp +++ b/icarus/core/famicom.cpp @@ -1,12 +1,12 @@ auto Icarus::famicomManifest(string location) -> string { - vector buffer; + vector buffer; concatenate(buffer, {location, "ines.rom"}); concatenate(buffer, {location, "program.rom"}); concatenate(buffer, {location, "character.rom"}); return famicomManifest(buffer, location); } -auto Icarus::famicomManifest(vector& buffer, string location, uint* prgrom, uint* chrrom) -> string { +auto Icarus::famicomManifest(vector& 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& buffer, string location, uint* prgro return markup; } -auto Icarus::famicomImport(vector& buffer, string location) -> string { +auto Icarus::famicomImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "Famicom/", name, ".fc/"}; diff --git a/icarus/core/game-boy-advance.cpp b/icarus/core/game-boy-advance.cpp index e8e840fd..0549f1b6 100644 --- a/icarus/core/game-boy-advance.cpp +++ b/icarus/core/game-boy-advance.cpp @@ -1,10 +1,10 @@ auto Icarus::gameBoyAdvanceManifest(string location) -> string { - vector buffer; + vector buffer; concatenate(buffer, {location, "program.rom"}); return gameBoyAdvanceManifest(buffer, location); } -auto Icarus::gameBoyAdvanceManifest(vector& buffer, string location) -> string { +auto Icarus::gameBoyAdvanceManifest(vector& buffer, string location) -> string { string markup; string digest = Hash::SHA256(buffer.data(), buffer.size()).digest(); @@ -31,7 +31,7 @@ auto Icarus::gameBoyAdvanceManifest(vector& buffer, string location) -> s return markup; } -auto Icarus::gameBoyAdvanceImport(vector& buffer, string location) -> string { +auto Icarus::gameBoyAdvanceImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "Game Boy Advance/", name, ".gba/"}; diff --git a/icarus/core/game-boy-color.cpp b/icarus/core/game-boy-color.cpp index 4fa78587..f92a80b2 100644 --- a/icarus/core/game-boy-color.cpp +++ b/icarus/core/game-boy-color.cpp @@ -1,10 +1,10 @@ auto Icarus::gameBoyColorManifest(string location) -> string { - vector buffer; + vector buffer; concatenate(buffer, {location, "program.rom"}); return gameBoyColorManifest(buffer, location); } -auto Icarus::gameBoyColorManifest(vector& buffer, string location) -> string { +auto Icarus::gameBoyColorManifest(vector& buffer, string location) -> string { string markup; string digest = Hash::SHA256(buffer.data(), buffer.size()).digest(); @@ -31,7 +31,7 @@ auto Icarus::gameBoyColorManifest(vector& buffer, string location) -> str return markup; } -auto Icarus::gameBoyColorImport(vector& buffer, string location) -> string { +auto Icarus::gameBoyColorImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "Game Boy Color/", name, ".gbc/"}; diff --git a/icarus/core/game-boy.cpp b/icarus/core/game-boy.cpp index 7ed040af..af9a4ff8 100644 --- a/icarus/core/game-boy.cpp +++ b/icarus/core/game-boy.cpp @@ -1,10 +1,10 @@ auto Icarus::gameBoyManifest(string location) -> string { - vector buffer; + vector buffer; concatenate(buffer, {location, "program.rom"}); return gameBoyManifest(buffer, location); } -auto Icarus::gameBoyManifest(vector& buffer, string location) -> string { +auto Icarus::gameBoyManifest(vector& buffer, string location) -> string { string markup; string digest = Hash::SHA256(buffer.data(), buffer.size()).digest(); @@ -31,7 +31,7 @@ auto Icarus::gameBoyManifest(vector& buffer, string location) -> string { return markup; } -auto Icarus::gameBoyImport(vector& buffer, string location) -> string { +auto Icarus::gameBoyImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "Game Boy/", name, ".gb/"}; diff --git a/icarus/core/sufami-turbo.cpp b/icarus/core/sufami-turbo.cpp index b77accc1..f03a4c51 100644 --- a/icarus/core/sufami-turbo.cpp +++ b/icarus/core/sufami-turbo.cpp @@ -1,10 +1,10 @@ auto Icarus::sufamiTurboManifest(string location) -> string { - vector buffer; + vector buffer; concatenate(buffer, {location, "program.rom"}); return sufamiTurboManifest(buffer, location); } -auto Icarus::sufamiTurboManifest(vector& buffer, string location) -> string { +auto Icarus::sufamiTurboManifest(vector& buffer, string location) -> string { string markup; string digest = Hash::SHA256(buffer.data(), buffer.size()).digest(); @@ -31,7 +31,7 @@ auto Icarus::sufamiTurboManifest(vector& buffer, string location) -> stri return markup; } -auto Icarus::sufamiTurboImport(vector& buffer, string location) -> string { +auto Icarus::sufamiTurboImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "Sufami Turbo/", name, ".st/"}; diff --git a/icarus/core/super-famicom.cpp b/icarus/core/super-famicom.cpp index abda6d09..f305e80b 100644 --- a/icarus/core/super-famicom.cpp +++ b/icarus/core/super-famicom.cpp @@ -1,5 +1,5 @@ auto Icarus::superFamicomManifest(string location) -> string { - vector buffer; + vector 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& buffer, string location, bool* firmwareAppended) -> string { +auto Icarus::superFamicomManifest(vector& 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& roms, Markup::Node n for(auto leaf : node) superFamicomManifestScan(roms, leaf); } -auto Icarus::superFamicomImport(vector& buffer, string location) -> string { +auto Icarus::superFamicomImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "Super Famicom/", name, ".sfc/"}; diff --git a/icarus/core/wonderswan-color.cpp b/icarus/core/wonderswan-color.cpp index 944dafde..c0fcd18d 100644 --- a/icarus/core/wonderswan-color.cpp +++ b/icarus/core/wonderswan-color.cpp @@ -1,10 +1,10 @@ auto Icarus::wonderSwanColorManifest(string location) -> string { - vector buffer; + vector buffer; concatenate(buffer, {location, "program.rom"}); return wonderSwanColorManifest(buffer, location); } -auto Icarus::wonderSwanColorManifest(vector& buffer, string location) -> string { +auto Icarus::wonderSwanColorManifest(vector& buffer, string location) -> string { string manifest; string digest = Hash::SHA256(buffer.data(), buffer.size()).digest(); @@ -31,7 +31,7 @@ auto Icarus::wonderSwanColorManifest(vector& buffer, string location) -> return manifest; } -auto Icarus::wonderSwanColorImport(vector& buffer, string location) -> string { +auto Icarus::wonderSwanColorImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "WonderSwan Color/", name, ".wsc/"}; diff --git a/icarus/core/wonderswan.cpp b/icarus/core/wonderswan.cpp index 48611631..0e228876 100644 --- a/icarus/core/wonderswan.cpp +++ b/icarus/core/wonderswan.cpp @@ -1,10 +1,10 @@ auto Icarus::wonderSwanManifest(string location) -> string { - vector buffer; + vector buffer; concatenate(buffer, {location, "program.rom"}); return wonderSwanManifest(buffer, location); } -auto Icarus::wonderSwanManifest(vector& buffer, string location) -> string { +auto Icarus::wonderSwanManifest(vector& buffer, string location) -> string { string manifest; string digest = Hash::SHA256(buffer.data(), buffer.size()).digest(); @@ -31,7 +31,7 @@ auto Icarus::wonderSwanManifest(vector& buffer, string location) -> strin return manifest; } -auto Icarus::wonderSwanImport(vector& buffer, string location) -> string { +auto Icarus::wonderSwanImport(vector& buffer, string location) -> string { auto name = prefixname(location); auto source = pathname(location); string target{settings["Library/Location"].text(), "WonderSwan/", name, ".ws/"}; diff --git a/icarus/heuristics/bs-memory.cpp b/icarus/heuristics/bs-memory.cpp index c7294790..4f9f7975 100644 --- a/icarus/heuristics/bs-memory.cpp +++ b/icarus/heuristics/bs-memory.cpp @@ -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"); } diff --git a/icarus/heuristics/famicom.cpp b/icarus/heuristics/famicom.cpp index a2398ec9..e7517f69 100644 --- a/icarus/heuristics/famicom.cpp +++ b/icarus/heuristics/famicom.cpp @@ -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; diff --git a/icarus/heuristics/game-boy-advance.cpp b/icarus/heuristics/game-boy-advance.cpp index af3937ff..2363a2bc 100644 --- a/icarus/heuristics/game-boy-advance.cpp +++ b/icarus/heuristics/game-boy-advance.cpp @@ -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; diff --git a/icarus/heuristics/game-boy.cpp b/icarus/heuristics/game-boy.cpp index 1ff9115d..002a6bf2 100644 --- a/icarus/heuristics/game-boy.cpp +++ b/icarus/heuristics/game-boy.cpp @@ -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"; diff --git a/icarus/heuristics/super-famicom.cpp b/icarus/heuristics/super-famicom.cpp index ec605082..a9d5ed44 100644 --- a/icarus/heuristics/super-famicom.cpp +++ b/icarus/heuristics/super-famicom.cpp @@ -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. diff --git a/icarus/heuristics/wonderswan-color.cpp b/icarus/heuristics/wonderswan-color.cpp index 37d39081..4d5927b1 100644 --- a/icarus/heuristics/wonderswan-color.cpp +++ b/icarus/heuristics/wonderswan-color.cpp @@ -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"); diff --git a/icarus/heuristics/wonderswan.cpp b/icarus/heuristics/wonderswan.cpp index 65a39a9b..b68c2969 100644 --- a/icarus/heuristics/wonderswan.cpp +++ b/icarus/heuristics/wonderswan.cpp @@ -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"); diff --git a/nall/beat/delta.hpp b/nall/beat/delta.hpp index 12482682..17c98340 100644 --- a/nall/beat/delta.hpp +++ b/nall/beat/delta.hpp @@ -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(); diff --git a/nall/beat/linear.hpp b/nall/beat/linear.hpp index 0f677671..94e19530 100644 --- a/nall/beat/linear.hpp +++ b/nall/beat/linear.hpp @@ -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(); diff --git a/nall/beat/metadata.hpp b/nall/beat/metadata.hpp index d924a349..4336cde0 100644 --- a/nall/beat/metadata.hpp +++ b/nall/beat/metadata.hpp @@ -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(); diff --git a/nall/beat/multi.hpp b/nall/beat/multi.hpp index f6f9be6a..7fb9add6 100644 --- a/nall/beat/multi.hpp +++ b/nall/beat/multi.hpp @@ -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 buffer; + vector 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; diff --git a/nall/beat/patch.hpp b/nall/beat/patch.hpp index f8f01058..ab502ea0 100644 --- a/nall/beat/patch.hpp +++ b/nall/beat/patch.hpp @@ -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; diff --git a/nall/bitvector.hpp b/nall/bitvector.hpp index 77b5955b..f968cc36 100644 --- a/nall/bitvector.hpp +++ b/nall/bitvector.hpp @@ -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; }; diff --git a/nall/decode/gzip.hpp b/nall/decode/gzip.hpp index 75985e9a..15ad463d 100644 --- a/nall/decode/gzip.hpp +++ b/nall/decode/gzip.hpp @@ -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; diff --git a/nall/decode/inflate.hpp b/nall/decode/inflate.hpp index 884358f2..e07fd527 100644 --- a/nall/decode/inflate.hpp +++ b/nall/decode/inflate.hpp @@ -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); diff --git a/nall/decode/png.hpp b/nall/decode/png.hpp index e68736e9..3e884d06 100644 --- a/nall/decode/png.hpp +++ b/nall/decode/png.hpp @@ -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: diff --git a/nall/decode/zip.hpp b/nall/decode/zip.hpp index 637ec395..e6314aa7 100644 --- a/nall/decode/zip.hpp +++ b/nall/decode/zip.hpp @@ -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 { - vector buffer; + auto extract(File& file) -> vector { + vector 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; diff --git a/nall/dsp/buffer.hpp b/nall/dsp/buffer.hpp index f488c647..22934d07 100644 --- a/nall/dsp/buffer.hpp +++ b/nall/dsp/buffer.hpp @@ -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; }; diff --git a/nall/file.hpp b/nall/file.hpp index 6049b247..b570d050 100644 --- a/nall/file.hpp +++ b/nall/file.hpp @@ -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 { - vector memory; + static auto read(const string& filename) -> vector { + vector 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& buffer) -> bool { + static auto write(const string& filename, const vector& 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++); } diff --git a/nall/mosaic/bitstream.hpp b/nall/mosaic/bitstream.hpp index 98fa0598..d46e971c 100644 --- a/nall/mosaic/bitstream.hpp +++ b/nall/mosaic/bitstream.hpp @@ -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; diff --git a/nall/mosaic/parser.hpp b/nall/mosaic/parser.hpp index 47765c7e..5d68cd83 100644 --- a/nall/mosaic/parser.hpp +++ b/nall/mosaic/parser.hpp @@ -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); diff --git a/nall/primitives.hpp b/nall/primitives.hpp index cf37f67a..2004dd1f 100644 --- a/nall/primitives.hpp +++ b/nall/primitives.hpp @@ -7,10 +7,10 @@ namespace nall { struct Boolean { inline Boolean() : data(false) {} - inline Boolean(bool value) : data(value) {} + template inline Boolean(const T& value) : data(value) {} inline operator bool() const { return data; } - inline auto& operator=(const bool value) { data = value; return *this; } + template inline auto& operator=(const T& value) { data = value; return *this; } inline auto serialize(serializer& s) { s(data); } @@ -28,12 +28,10 @@ template struct Natural { enum : type { Mask = ~0ull >> (64 - Bits) }; inline Natural() : data(0) {} - inline Natural(const type value) : data(clip(value)) {} - template inline Natural(const Natural value) : data(clip(value)) {} + template 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 inline auto& operator=(const Natural value) { data = clip(value); return *this; } + template 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 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 struct Range { enum : type { RangeBits = Hi - Lo + 1, RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask }; @@ -109,12 +133,10 @@ template 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 inline Integer(const Integer value) : data(clip(value)) {} + template 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 inline auto& operator=(const Integer value) { data = clip(value); return *this; } + template 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 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 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 struct Real { void>>>; inline Real() : data(0.0) {} - inline Real(const type value) : data(value) {} - template inline Real(const Real value) : data((type)value) {} + template 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 inline auto& operator=(const Real value) { data = (type)value; return *this; } + template 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; } diff --git a/nall/serializer.hpp b/nall/serializer.hpp index 68be2c87..bb7d8621 100644 --- a/nall/serializer.hpp +++ b/nall/serializer.hpp @@ -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; }; diff --git a/nall/stdint.hpp b/nall/stdint.hpp index 39e5ec1b..98243521 100644 --- a/nall/stdint.hpp +++ b/nall/stdint.hpp @@ -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 diff --git a/nall/stream/auto.hpp b/nall/stream/auto.hpp index 25a2dc5a..0c5fc65b 100644 --- a/nall/stream/auto.hpp +++ b/nall/stream/auto.hpp @@ -10,11 +10,11 @@ inline auto makestream(const string& path) -> std::unique_ptr { return std::unique_ptr(new mmapstream(path)); } -inline auto makestream(uint8* data, uint size) -> std::unique_ptr { +inline auto makestream(uint8_t* data, uint size) -> std::unique_ptr { return std::unique_ptr(new memorystream(data, size)); } -inline auto makestream(const uint8* data, uint size) -> std::unique_ptr { +inline auto makestream(const uint8_t* data, uint size) -> std::unique_ptr { return std::unique_ptr(new memorystream(data, size)); } diff --git a/nall/stream/file.hpp b/nall/stream/file.hpp index 043992ee..1ce9984c 100644 --- a/nall/stream/file.hpp +++ b/nall/stream/file.hpp @@ -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: diff --git a/nall/stream/gzip.hpp b/nall/stream/gzip.hpp index abc0a5a8..f4a4e0a2 100644 --- a/nall/stream/gzip.hpp +++ b/nall/stream/gzip.hpp @@ -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; diff --git a/nall/stream/memory.hpp b/nall/stream/memory.hpp index 92f4ab1f..3f873d45 100644 --- a/nall/stream/memory.hpp +++ b/nall/stream/memory.hpp @@ -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; diff --git a/nall/stream/mmap.hpp b/nall/stream/mmap.hpp index a1afc351..8c116f1b 100644 --- a/nall/stream/mmap.hpp +++ b/nall/stream/mmap.hpp @@ -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; }; diff --git a/nall/stream/stream.hpp b/nall/stream/stream.hpp index 6a6cc4b8..a9e1a64a 100644 --- a/nall/stream/stream.hpp +++ b/nall/stream/stream.hpp @@ -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: diff --git a/nall/stream/vector.hpp b/nall/stream/vector.hpp index 540501cf..5f6ddac6 100644 --- a/nall/stream/vector.hpp +++ b/nall/stream/vector.hpp @@ -9,27 +9,27 @@ struct vectorstream : stream { using stream::read; using stream::write; - vectorstream(vector& memory) : memory(memory), pwritable(true) {} - vectorstream(const vector& memory) : memory((vector&)memory), pwritable(false) {} + vectorstream(vector& memory) : memory(memory), pwritable(true) {} + vectorstream(const vector& memory) : memory((vector&)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& memory; + vector& memory; mutable uint poffset = 0; mutable bool pwritable = false; }; diff --git a/nall/stream/zip.hpp b/nall/stream/zip.hpp index b2ee11f8..7f928dca 100644 --- a/nall/stream/zip.hpp +++ b/nall/stream/zip.hpp @@ -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; diff --git a/nall/string/eval/evaluator.hpp b/nall/string/eval/evaluator.hpp index 2261d046..60fc2d1b 100644 --- a/nall/string/eval/evaluator.hpp +++ b/nall/string/eval/evaluator.hpp @@ -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 { +inline auto integer(const string& expression) -> maybe { try { auto tree = new Node; const char* p = expression; diff --git a/ruby/input/xlib.cpp b/ruby/input/xlib.cpp index b9043462..b84c24e3 100644 --- a/ruby/input/xlib.cpp +++ b/ruby/input/xlib.cpp @@ -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; }