Update to v106r30 release.

byuu says:

Changelog:

  - nall/GNUmakefile: fixed findstring parameter arguments [Screwtape]
  - nall/Windows: always include -mthreads -lpthread for all
    applications
  - nall/memory: code restructuring

I really wanted to work on the new PPU today, but I thought I'd spend a
few minutes making some minor improvements to nall::memory, that was
five and a half hours ago. Now I have a 67KiB diff of changes. Sigh.
This commit is contained in:
Tim Allen 2018-05-28 11:16:27 +10:00
parent 6882bd98cf
commit 685cec6583
73 changed files with 372 additions and 389 deletions

View File

@ -11,7 +11,7 @@ flags += $(if $(call streq,$(profile),accurate),-DPROFILE_ACCURATE,-DPROFILE_FAS
ifeq ($(platform),windows)
ifeq ($(binary),application)
link += -mthreads -lpthread -luuid -lkernel32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lshell32
link += -luuid -lkernel32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lshell32
link += -Wl,-enable-auto-import
link += -Wl,-enable-runtime-pseudo-reloc
else ifeq ($(binary),library)

View File

@ -12,7 +12,7 @@ using namespace nall;
namespace Emulator {
static const string Name = "higan";
static const string Version = "106.29";
static const string Version = "106.30";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "https://byuu.org/";

View File

@ -38,7 +38,7 @@ auto CPU::power(bool reset) -> void {
r.pc.byte(0) = bus.read(0xfffc);
r.pc.byte(1) = bus.read(0xfffd);
memory::fill(&io, sizeof(IO));
io = {};
io.rdyLine = 1;
}

View File

@ -40,17 +40,17 @@ struct CPU : Processor::MOS6502, Thread {
uint8 ram[0x800];
struct IO {
bool interruptPending;
bool nmiPending;
bool nmiLine;
bool irqLine;
bool apuLine;
bool interruptPending = 0;
bool nmiPending = 0;
bool nmiLine = 0;
bool irqLine = 0;
bool apuLine = 0;
bool rdyLine;
bool rdyAddrValid;
bool rdyLine = 0;
bool rdyAddrValid = 0;
uint16 rdyAddrValue;
bool oamdmaPending;
bool oamdmaPending = 0;
uint8 oamdmaPage;
} io;
};

View File

@ -57,8 +57,8 @@ auto PPU::refresh() -> void {
auto PPU::power(bool reset) -> void {
create(PPU::Enter, system.frequency());
memory::fill(&io, sizeof(IO));
memory::fill(&latch, sizeof(Latches));
io = {};
latch = {};
io.vramIncrement = 1;
if(!reset) {

View File

@ -39,13 +39,14 @@ struct PPU : Thread {
uint8 mdr;
uint1 field;
uint lx;
uint ly;
uint lx = 0;
uint ly = 0;
uint8 busData;
union {
uint value;
union Union {
auto& operator=(const Union& u) { value = u.value; return *this; }
uint value = 0;
NaturalBitField<uint, 0, 4> tileX;
NaturalBitField<uint, 5, 9> tileY;
NaturalBitField<uint,10,11> nametable;
@ -59,28 +60,28 @@ struct PPU : Thread {
NaturalBitField<uint,16,18> fineX;
} v, t;
bool nmiHold;
bool nmiFlag;
bool nmiHold = 0;
bool nmiFlag = 0;
//$2000
uint vramIncrement;
uint spriteAddress;
uint bgAddress;
uint spriteHeight;
bool masterSelect;
bool nmiEnable;
uint vramIncrement = 0;
uint spriteAddress = 0;
uint bgAddress = 0;
uint spriteHeight = 0;
bool masterSelect = 0;
bool nmiEnable = 0;
//$2001
bool grayscale;
bool bgEdgeEnable;
bool spriteEdgeEnable;
bool bgEnable;
bool spriteEnable;
bool grayscale = 0;
bool bgEdgeEnable = 0;
bool spriteEdgeEnable = 0;
bool bgEnable = 0;
bool spriteEnable = 0;
uint3 emphasis;
//$2002
bool spriteOverflow;
bool spriteZeroHit;
bool spriteOverflow = 0;
bool spriteZeroHit = 0;
//$2003
uint8 oamAddress;
@ -106,8 +107,8 @@ struct PPU : Thread {
uint16 tiledataLo;
uint16 tiledataHi;
uint oamIterator;
uint oamCounter;
uint oamIterator = 0;
uint oamCounter = 0;
OAM oam[8]; //primary
OAM soam[8]; //secondary

View File

@ -70,7 +70,7 @@ auto Cartridge::load() -> bool {
if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=ROM,content=Program)"]}) {
rom.size = max(0x4000, (uint)memory.size);
rom.data = (uint8*)memory::allocate(rom.size, 0xff);
rom.data = memory::allocate<uint8>(rom.size, 0xff);
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Required)) {
fp->read(rom.data, min(rom.size, fp->size()));
}
@ -78,7 +78,7 @@ auto Cartridge::load() -> bool {
if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=RAM,content=Save)"]}) {
ram.size = memory.size;
ram.data = (uint8*)memory::allocate(ram.size, 0xff);
ram.data = memory::allocate<uint8>(ram.size, 0xff);
if(memory.nonVolatile) {
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Optional)) {
fp->read(ram.data, min(ram.size, fp->size()));
@ -88,7 +88,7 @@ auto Cartridge::load() -> bool {
if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=RTC,content=Time)"]}) {
rtc.size = memory.size;
rtc.data = (uint8*)memory::allocate(rtc.size, 0xff);
rtc.data = memory::allocate<uint8>(rtc.size, 0xff);
if(memory.nonVolatile) {
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Optional)) {
fp->read(rtc.data, min(rtc.size, fp->size()));

View File

@ -123,7 +123,7 @@ auto CPU::power() -> void {
for(auto& n : wram) n = 0x00;
for(auto& n : hram) n = 0x00;
memory::fill(&status, sizeof(Status));
status = {};
status.dmaCompleted = true;
status.wramBank = 1;
}

View File

@ -38,18 +38,18 @@ struct CPU : Processor::LR35902, Thread, MMIO {
uint22 clock;
//$ff00 JOYP
bool p15;
bool p14;
bool p15 = 0;
bool p14 = 0;
uint8 joyp;
uint8 mltReq;
//$ff01 SB
uint8 serialData;
uint serialBits;
uint serialBits = 0;
//$ff02 SC
bool serialTransfer;
bool serialClock;
bool serialTransfer = 0;
bool serialClock = 0;
//$ff04 DIV
uint16 div;
@ -61,19 +61,19 @@ struct CPU : Processor::LR35902, Thread, MMIO {
uint8 tma;
//$ff07 TAC
bool timerEnable;
uint timerClock;
bool timerEnable = 0;
uint timerClock = 0;
//$ff0f IF
bool interruptRequestJoypad;
bool interruptRequestSerial;
bool interruptRequestTimer;
bool interruptRequestStat;
bool interruptRequestVblank;
bool interruptRequestJoypad = 0;
bool interruptRequestSerial = 0;
bool interruptRequestTimer = 0;
bool interruptRequestStat = 0;
bool interruptRequestVblank = 0;
//$ff4d KEY1
bool speedDouble;
bool speedSwitch;
bool speedDouble = 0;
bool speedSwitch = 0;
//$ff51,$ff52 HDMA1,HDMA2
uint16 dmaSource;
@ -82,9 +82,9 @@ struct CPU : Processor::LR35902, Thread, MMIO {
uint16 dmaTarget;
//$ff55 HDMA5
bool dmaMode;
bool dmaMode = 0;
uint16 dmaLength;
bool dmaCompleted;
bool dmaCompleted = 0;
//$ff6c ???
uint8 ff6c;
@ -99,11 +99,11 @@ struct CPU : Processor::LR35902, Thread, MMIO {
uint8 ff75;
//$ffff IE
bool interruptEnableJoypad;
bool interruptEnableSerial;
bool interruptEnableTimer;
bool interruptEnableStat;
bool interruptEnableVblank;
bool interruptEnableJoypad = 0;
bool interruptEnableSerial = 0;
bool interruptEnableTimer = 0;
bool interruptEnableStat = 0;
bool interruptEnableVblank = 0;
} status;
uint8 wram[32768]; //GB=8192, GBC=32768

View File

@ -151,7 +151,7 @@ auto PPU::power() -> void {
for(auto& n : bgpd) n = 0x0000;
for(auto& n : obpd) n = 0x0000;
memory::fill(&status, sizeof(Status));
status = {};
for(auto& n : screen) n = 0;

View File

@ -44,24 +44,24 @@ struct PPU : Thread, MMIO {
function<auto () -> void> run;
struct Status {
bool irq; //STAT IRQ line
uint lx;
bool irq = 0; //STAT IRQ line
uint lx = 0;
//$ff40 LCDC
bool displayEnable;
bool windowTilemapSelect;
bool windowDisplayEnable;
bool bgTiledataSelect;
bool bgTilemapSelect;
bool obSize;
bool obEnable;
bool bgEnable;
bool displayEnable = 0;
bool windowTilemapSelect = 0;
bool windowDisplayEnable = 0;
bool bgTiledataSelect = 0;
bool bgTilemapSelect = 0;
bool obSize = 0;
bool obEnable = 0;
bool bgEnable = 0;
//$ff41 STAT
bool interruptLYC;
bool interruptOAM;
bool interruptVblank;
bool interruptHblank;
bool interruptLYC = 0;
bool interruptOAM = 0;
bool interruptVblank = 0;
bool interruptHblank = 0;
uint2 mode;
//$ff42 SCY
@ -77,8 +77,8 @@ struct PPU : Thread, MMIO {
uint8 lyc;
//$ff46 DMA
bool dmaActive;
uint dmaClock;
bool dmaActive = 0;
uint dmaClock = 0;
uint8 dmaBank;
//$ff4a WY
@ -88,14 +88,14 @@ struct PPU : Thread, MMIO {
uint8 wx;
//$ff4f VBK
bool vramBank;
bool vramBank = 0;
//$ff68 BGPI
bool bgpiIncrement;
bool bgpiIncrement = 0;
uint6 bgpi;
//$ff6a OBPI
bool obpiIncrement;
bool obpiIncrement = 0;
uint8 obpi;
} status;
@ -104,26 +104,26 @@ struct PPU : Thread, MMIO {
struct Pixel {
uint16 color;
uint8 palette;
bool priority;
bool priority = 0;
};
Pixel bg;
Pixel ob;
struct Sprite {
uint x;
uint y;
uint tile;
uint attr;
uint data;
uint x = 0;
uint y = 0;
uint tile = 0;
uint attr = 0;
uint data = 0;
};
Sprite sprite[10];
uint sprites;
uint sprites = 0;
uint px;
uint px = 0;
struct Background {
uint attr;
uint data;
uint attr = 0;
uint data = 0;
};
Background background;
Background window;

View File

@ -87,7 +87,7 @@ auto PPU::Objects::run(uint x, uint y) -> void {
}
auto PPU::Objects::power() -> void {
memory::fill(&io, sizeof(IO));
io = {};
for(auto& pixel : buffer) pixel = {};
output = {};
mosaic = {};

View File

@ -124,7 +124,7 @@ auto PPU::power() -> void {
for(uint n = 0; n < 1024; n += 2) writePRAM(n, Half, 0x0000);
for(uint n = 0; n < 1024; n += 2) writeOAM(n, Half, 0x0000);
memory::fill(&io, sizeof(IO));
io = {};
for(auto& object : this->object) object = {};
for(auto& param : this->objectParam) param = {};

View File

@ -65,5 +65,5 @@ auto PPU::Screen::blend(uint15 above, uint eva, uint15 below, uint evb) -> uint1
}
auto PPU::Screen::power() -> void {
memory::fill(&io, sizeof(IO));
io = {};
}

View File

@ -11,6 +11,6 @@ auto PPU::Window::run(uint x, uint y) -> void {
auto PPU::Window::power(uint id) -> void {
this->id = id;
memory::fill(&io, sizeof(IO));
io = {};
output = 0;
}

View File

@ -58,7 +58,7 @@ auto APU::power(bool reset) -> void {
bus->grant(false);
create(APU::Enter, system.frequency() / 15.0);
if(!reset) memory::fill(ram, sizeof ram);
if(!reset) memory::fill(ram, sizeof(ram));
state = {};
}

View File

@ -85,7 +85,7 @@ auto CPU::power(bool reset) -> void {
M68K::power();
create(CPU::Enter, system.frequency() / 7.0);
if(!reset) memory::fill(ram, sizeof ram);
if(!reset) memory::fill(ram, sizeof(ram));
io = {};
io.version = tmssEnable;

View File

@ -47,5 +47,5 @@ auto VDP::DMA::copy() -> void {
}
auto VDP::DMA::power() -> void {
memory::fill(&io, sizeof(IO));
io = {};
}

View File

@ -72,7 +72,7 @@ auto Cartridge::unload() -> void {
}
auto Cartridge::power() -> void {
memory::fill(&mapper, sizeof(Mapper));
mapper = {};
mapper.romPage0 = 0;
mapper.romPage1 = 1;
mapper.romPage2 = 2;

View File

@ -60,7 +60,7 @@ auto CPU::power() -> void {
r.pc = 0x0000; //reset vector address
memory::fill(&state, sizeof(State));
state = {};
}
}

View File

@ -29,8 +29,8 @@ private:
uint8 ram[8 * 1024];
struct State {
bool nmiLine;
bool intLine;
bool nmiLine = 0;
bool intLine = 0;
} state;
};

View File

@ -53,6 +53,6 @@ auto VDP::Background::run() -> void {
}
auto VDP::Background::power() -> void {
memory::fill(&state, sizeof(State));
memory::fill(&output, sizeof(Output));
state = {};
output = {};
}

View File

@ -63,6 +63,6 @@ auto VDP::Sprite::run() -> void {
}
auto VDP::Sprite::power() -> void {
memory::fill(&state, sizeof(State));
memory::fill(&output, sizeof(Output));
state = {};
output = {};
}

View File

@ -101,8 +101,8 @@ auto VDP::vblank() -> bool {
auto VDP::power() -> void {
create(VDP::Enter, system.colorburst() * 15.0 / 5.0);
memory::fill(&buffer, sizeof(buffer));
memory::fill(&io, sizeof(IO));
memory::fill<uint32>(buffer, 256 * 264);
io = {};
background.power();
sprite.power();

View File

@ -32,8 +32,8 @@ struct VDP : Thread {
auto serialize(serializer&) -> void;
struct State {
uint x;
uint y;
uint x = 0;
uint y = 0;
} state;
struct Output {
@ -60,8 +60,8 @@ struct VDP : Thread {
};
struct State {
uint x;
uint y;
uint x = 0;
uint y = 0;
} state;
struct Output {
@ -82,21 +82,21 @@ private:
uint8 cram[0x40]; //MS = 0x20, GG = 0x40
struct IO {
uint vcounter; //vertical counter
uint hcounter; //horizontal counter
uint lcounter; //line counter
uint vcounter = 0; //vertical counter
uint hcounter = 0; //horizontal counter
uint lcounter = 0; //line counter
//interrupt flags
bool intLine;
bool intFrame;
bool intLine = 0;
bool intFrame = 0;
//status flags
bool spriteOverflow;
bool spriteCollision;
bool spriteOverflow = 0;
bool spriteCollision = 0;
uint5 fifthSprite;
//latches
bool controlLatch;
bool controlLatch = 0;
uint16 controlData;
uint2 code;
uint14 address;
@ -104,22 +104,22 @@ private:
uint8 vramLatch;
//$00 mode control 1
bool externalSync;
bool extendedHeight;
bool mode4;
bool spriteShift;
bool lineInterrupts;
bool leftClip;
bool horizontalScrollLock;
bool verticalScrollLock;
bool externalSync = 0;
bool extendedHeight = 0;
bool mode4 = 0;
bool spriteShift = 0;
bool lineInterrupts = 0;
bool leftClip = 0;
bool horizontalScrollLock = 0;
bool verticalScrollLock = 0;
//$01 mode control 2
bool spriteDouble;
bool spriteTile;
bool lines240;
bool lines224;
bool frameInterrupts;
bool displayEnable;
bool spriteDouble = 0;
bool spriteTile = 0;
bool lines240 = 0;
bool lines224 = 0;
bool frameInterrupts = 0;
bool displayEnable = 0;
//$02 name table base address
uint1 nameTableMask;

View File

@ -36,9 +36,9 @@ auto CPU::power() -> void {
r.pc.byte(1) = read(0x00, 0x1fff);
for(auto& byte : ram) byte = 0x00;
memory::fill(&irq, sizeof(IRQ));
memory::fill(&timer, sizeof(Timer));
memory::fill(&io, sizeof(IO));
irq = {};
timer = {};
io = {};
}
auto CPU::lastCycle() -> void {

View File

@ -36,11 +36,11 @@ private:
auto poll() -> void;
private:
bool disableExternal;
bool disableVDC;
bool disableTimer;
bool disableExternal = 0;
bool disableVDC = 0;
bool disableTimer = 0;
bool pendingIRQ;
bool pendingIRQ = 0;
uint16 pendingVector;
friend class CPU;
@ -54,12 +54,12 @@ private:
auto step(uint clocks) -> void;
private:
bool enable;
bool enable = 0;
uint7 latch;
uint7 value;
uint clock;
uint clock = 0;
bool line;
bool line = 0;
friend class CPU;
} timer;

View File

@ -1,6 +1,6 @@
auto PSG::Channel::power(uint id) -> void {
this->id = id;
memory::fill(&io, sizeof(IO));
io = {};
}
auto PSG::Channel::run() -> void {

View File

@ -55,7 +55,7 @@ auto PSG::power() -> void {
stream->addFilter(Emulator::Filter::Order::First, Emulator::Filter::Type::HighPass, 20.0);
stream->addFilter(Emulator::Filter::Order::Second, Emulator::Filter::Type::LowPass, 20000.0, 3);
memory::fill(&io, sizeof(IO));
io = {};
for(auto C : range(6)) channel[C].power(C);
double level = 32767.0 / 6.0 / 32.0; //max volume / channels / steps

View File

@ -61,10 +61,9 @@ auto VCE::power() -> void {
create(VCE::Enter, system.colorburst() * 6.0);
for(auto& pixel : buffer) pixel = 0;
memory::fill(&cram, sizeof(CRAM));
memory::fill(&timing, sizeof(Timing));
memory::fill(&io, sizeof(IO));
io.clock = 4;
cram = {};
timing = {};
io = {};
}
}

View File

@ -29,14 +29,14 @@ private:
} cram;
struct Timing {
uint hclock;
uint vclock;
uint hclock = 0;
uint vclock = 0;
} timing;
struct IO {
uint clock;
bool extraLine;
bool grayscale;
uint clock = 4;
bool extraLine = 0;
bool grayscale = 0;
} io;
};

View File

@ -99,13 +99,13 @@ auto VDC::power() -> void {
create(VDC::Enter, system.colorburst() * 6.0);
memory::fill(&vram, sizeof(VRAM));
memory::fill(&satb, sizeof(SATB));
memory::fill(&timing, sizeof(Timing));
memory::fill(&irq, sizeof(IRQ));
memory::fill(&dma, sizeof(DMA));
memory::fill(&io, sizeof(IO));
memory::fill(&background, sizeof(Background));
memory::fill(&sprite, sizeof(Sprite));
satb = {};
timing = {};
irq = {};
dma = {};
io = {};
background = {};
sprite = {};
dma.vdc = this;
background.vdc = this;

View File

@ -56,20 +56,20 @@ private:
uint9 verticalDisplayLength;
uint8 verticalDisplayEnd;
bool vpulse;
bool hpulse;
bool vpulse = 0;
bool hpulse = 0;
uint hclock;
uint vclock;
uint hclock = 0;
uint vclock = 0;
uint hoffset;
uint voffset;
uint hoffset = 0;
uint voffset = 0;
uint hstart;
uint vstart;
uint hstart = 0;
uint vstart = 0;
uint hlength;
uint vlength;
uint hlength = 0;
uint vlength = 0;
} timing;
struct IRQ {
@ -87,21 +87,21 @@ private:
auto raise(Line) -> void;
auto lower() -> void;
bool enableCollision;
bool enableOverflow;
bool enableLineCoincidence;
bool enableVblank;
bool enableTransferVRAM;
bool enableTransferSATB;
bool enableCollision = 0;
bool enableOverflow = 0;
bool enableLineCoincidence = 0;
bool enableVblank = 0;
bool enableTransferVRAM = 0;
bool enableTransferSATB = 0;
bool pendingCollision;
bool pendingOverflow;
bool pendingLineCoincidence;
bool pendingVblank;
bool pendingTransferVRAM;
bool pendingTransferSATB;
bool pendingCollision = 0;
bool pendingOverflow = 0;
bool pendingLineCoincidence = 0;
bool pendingVblank = 0;
bool pendingTransferVRAM = 0;
bool pendingTransferSATB = 0;
bool line;
bool line = 0;
} irq;
struct DMA {
@ -113,17 +113,17 @@ private:
auto satbStart() -> void;
auto satbQueue() -> void;
bool sourceIncrementMode;
bool targetIncrementMode;
bool satbRepeat;
bool sourceIncrementMode = 0;
bool targetIncrementMode = 0;
bool satbRepeat = 0;
uint16 source;
uint16 target;
uint16 length;
uint16 satbSource;
bool vramActive;
bool satbActive;
bool satbPending;
bool vramActive = 0;
bool satbActive = 0;
bool satbPending = 0;
uint16 satbOffset;
} dma;
@ -134,7 +134,7 @@ private:
auto scanline(uint y) -> void;
auto run(uint x, uint y) -> void;
bool enable;
bool enable = 0;
uint10 hscroll;
uint9 vscroll;
uint9 vcounter;
@ -155,26 +155,26 @@ private:
auto scanline(uint y) -> void;
auto run(uint x, uint y) -> void;
bool enable;
bool enable = 0;
struct Object {
uint10 y;
uint10 x;
bool mode;
bool mode = 0;
uint10 pattern;
uint4 palette;
bool priority;
uint width;
bool hflip;
uint height;
bool vflip;
bool first;
bool priority = 0;
uint width = 0;
bool hflip = 0;
uint height = 0;
bool vflip = 0;
bool first = 0;
};
array<Object, 64> objects;
uint4 color;
uint4 palette;
bool priority;
bool priority = 0;
} sprite;
struct IO {
@ -183,7 +183,7 @@ private:
//$0005 CR (W)
uint2 externalSync;
uint2 displayOutput;
bool dramRefresh;
bool dramRefresh = 0;
//$0006 RCR
uint10 lineCoincidence;
@ -191,7 +191,7 @@ private:
//$0009 MWR
uint2 vramAccess;
uint2 spriteAccess;
bool cgMode;
bool cgMode = 0;
} io;
};

View File

@ -234,16 +234,9 @@ auto DSP::power(bool reset) -> void {
if(!reset) random.array(apuram, sizeof(apuram));
memory::fill(&state, sizeof(State));
state.noise = 0x4000;
state.echoHistoryOffset = 0;
state.everyOtherSample = 1;
state.echoOffset = 0;
state.counter = 0;
state = {};
for(auto n : range(8)) {
memory::fill(&voice[n], sizeof(Voice));
voice[n].brrOffset = 1;
voice[n] = {};
voice[n].vbit = 1 << n;
voice[n].vidx = n * 0x10;
}

View File

@ -54,66 +54,66 @@ private:
struct State {
uint8 regs[128];
int echoHistory[2][8]; //echo history keeps most recent 8 stereo samples
int echoHistory[2][8] = {}; //echo history keeps most recent 8 stereo samples
uint3 echoHistoryOffset;
bool everyOtherSample; //toggles every sample
int kon; //KON value when last checked
int noise;
int counter;
int echoOffset; //offset from ESA in echo buffer
int echoLength; //number of bytes that echo_offset will stop at
bool everyOtherSample = 1; //toggles every sample
int kon = 0; //KON value when last checked
int noise = 0x4000;
int counter = 0;
int echoOffset = 0; //offset from ESA in echo buffer
int echoLength = 0; //number of bytes that echo_offset will stop at
//hidden registers also written to when main register is written to
int konBuffer;
int endxBuffer;
int envxBuffer;
int outxBuffer;
int konBuffer = 0;
int endxBuffer = 0;
int envxBuffer = 0;
int outxBuffer = 0;
//temporary state between clocks (prefixed with _)
//read once per sample
int _pmon;
int _non;
int _eon;
int _dir;
int _koff;
int _pmon = 0;
int _non = 0;
int _eon = 0;
int _dir = 0;
int _koff = 0;
//read a few clocks ahead before used
int _brrNextAddress;
int _adsr0;
int _brrHeader;
int _brrByte;
int _srcn;
int _esa;
int _echoDisabled;
int _brrNextAddress = 0;
int _adsr0 = 0;
int _brrHeader = 0;
int _brrByte = 0;
int _srcn = 0;
int _esa = 0;
int _echoDisabled = 0;
//internal state that is recalculated every sample
int _dirAddress;
int _pitch;
int _output;
int _looped;
int _echoPointer;
int _dirAddress = 0;
int _pitch = 0;
int _output = 0;
int _looped = 0;
int _echoPointer = 0;
//left/right sums
int _mainOut[2];
int _echoOut[2];
int _echoIn [2];
int _mainOut[2] = {};
int _echoOut[2] = {};
int _echoIn [2] = {};
} state;
struct Voice {
int buffer[12 * 3]; //12 decoded samples (mirrored for wrapping)
int bufferOffset; //place in buffer where next samples will be decoded
int gaussianOffset; //relative fractional position in sample (0x1000 = 1.0)
int brrAddress; //address of current BRR block
int brrOffset; //current decoding offset in BRR block
int vbit; //bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc
int vidx; //voice channel register index: 0x00 for voice 0, 0x10 for voice 1, etc
int konDelay; //KON delay/current setup phase
int envelopeMode;
int envelope; //current envelope level
int hiddenEnvelope; //used by GAIN mode 7, very obscure quirk
int _envxOut;
int buffer[12 * 3] = {}; //12 decoded samples (mirrored for wrapping)
int bufferOffset = 0; //place in buffer where next samples will be decoded
int gaussianOffset = 0; //relative fractional position in sample (0x1000 = 1.0)
int brrAddress = 0; //address of current BRR block
int brrOffset = 1; //current decoding offset in BRR block
int vbit = 0; //bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc
int vidx = 0; //voice channel register index: 0x00 for voice 0, 0x10 for voice 1, etc
int konDelay = 0; //KON delay/current setup phase
int envelopeMode = 0;
int envelope = 0; //current envelope level
int hiddenEnvelope = 0; //used by GAIN mode 7, very obscure quirk
int _envxOut = 0;
} voice[8];
//gaussian.cpp

View File

@ -4,7 +4,7 @@ namespace SuperFamicom {
Satellaview::Satellaview() {
bus.map({&Satellaview::read, this}, {&Satellaview::write, this}, "00-3f,80-bf:2188-219f");
memory::fill(&regs, sizeof regs);
regs = {};
}
Satellaview::~Satellaview() {

View File

@ -27,7 +27,7 @@ auto MappedRAM::reset() -> void {
auto MappedRAM::allocate(uint size) -> void {
reset();
_data = new uint8[_size = size];
memory::fill(_data, _size, 0xff);
memory::fill<uint8>(_data, _size, 0xff);
}
auto MappedRAM::writeProtect(bool writeProtect) -> void { _writeProtect = writeProtect; }

View File

@ -87,7 +87,7 @@ auto PPU::load(Markup::Node node) -> bool {
auto PPU::power(bool reset) -> void {
create(Enter, system.cpuFrequency());
PPUcounter::reset();
memory::fill(output, 512 * 480 * sizeof(uint32));
memory::fill<uint32>(output, 512 * 480);
function<auto (uint24, uint8) -> uint8> reader{&PPU::readIO, this};
function<auto (uint24, uint8) -> void> writer{&PPU::writeIO, this};

View File

@ -90,7 +90,7 @@ auto PPU::load(Markup::Node node) -> bool {
auto PPU::power(bool reset) -> void {
create(Enter, system.cpuFrequency());
PPUcounter::reset();
memory::fill(output, 512 * 480 * sizeof(uint32));
memory::fill<uint32>(output, 512 * 480);
function<auto (uint24, uint8) -> uint8> reader{&PPU::readIO, this};
function<auto (uint24, uint8) -> void> writer{&PPU::writeIO, this};

View File

@ -176,7 +176,7 @@ auto Presentation::drawIcon(uint32_t* output, uint length, uint width, uint heig
for(uint y : range(128)) {
auto target = output + (y + oy) * (length >> 2) + ox;
auto source = (uint32_t*)icon.data() + y * 128;
memory::copy(target, source, 128 * sizeof(uint32_t));
memory::copy<uint32_t>(target, source, 128);
}
}
}

View File

@ -219,7 +219,7 @@ auto Program::videoRefresh(const uint32* data, uint pitch, uint width, uint heig
length >>= 2;
for(auto y : range(height)) {
memory::copy(output + y * length, data + y * pitch, width * sizeof(uint32));
memory::copy<uint32>(output + y * length, data + y * pitch, width);
}
video->unlock();

View File

@ -214,7 +214,7 @@ auto Presentation::drawIcon(uint32_t* output, uint length, uint width, uint heig
for(uint y : range(112)) {
auto target = output + (y + oy) * (length >> 2) + ox;
auto source = (uint32_t*)icon.data() + y * 112;
memory::copy(target, source, 112 * sizeof(uint32_t));
memory::copy<uint32_t>(target, source, 112);
}
}
}

View File

@ -71,7 +71,7 @@ auto Program::videoRefresh(const uint32* data, uint pitch, uint width, uint heig
length >>= 2;
for(auto y : range(height)) {
memory::copy(output + y * length, data + y * pitch, width * sizeof(uint32));
memory::copy<uint32>(output + y * length, data + y * pitch, width);
}
video->unlock();

View File

@ -33,12 +33,7 @@ auto Cartridge::power() -> void {
if(rtc.data) bus.map(this, 0x00ca, 0x00cb);
bus.map(this, 0x00cc, 0x00cd);
memory::fill(&r, sizeof(Registers));
r.romBank0 = 0xff;
r.romBank1 = 0xff;
r.romBank2 = 0xff;
r.sramBank = 0xff;
r = {};
}
auto Cartridge::load() -> bool {
@ -72,7 +67,7 @@ auto Cartridge::load() -> bool {
rom.size = memory.size;
rom.mask = bit::round(rom.size) - 1;
rom.data = new uint8[rom.mask + 1];
memory::fill(rom.data, rom.mask + 1, 0xff);
memory::fill<uint8>(rom.data, rom.mask + 1, 0xff);
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Required)) {
fp->read(rom.data, rom.size);
}
@ -82,7 +77,7 @@ auto Cartridge::load() -> bool {
ram.size = memory.size;
ram.mask = bit::round(ram.size) - 1;
ram.data = new uint8[ram.mask + 1];
memory::fill(ram.data, ram.mask + 1, 0xff);
memory::fill<uint8>(ram.data, ram.mask + 1, 0xff);
if(memory.nonVolatile) {
if(auto fp = platform->open(pathID(), memory.name(), File::Read)) {
fp->read(ram.data, ram.size);
@ -102,7 +97,7 @@ auto Cartridge::load() -> bool {
rtc.size = memory.size;
rtc.mask = bit::round(rtc.size) - 1;
rtc.data = new uint8[rtc.mask + 1];
memory::fill(rtc.data, rtc.mask + 1, 0x00);
memory::fill<uint8>(rtc.data, rtc.mask + 1, 0x00);
if(memory.nonVolatile) {
if(auto fp = platform->open(pathID(), memory.name(), File::Read)) {
fp->read(rtc.data, rtc.size);

View File

@ -44,16 +44,16 @@ struct Cartridge : Thread, IO {
struct Registers {
//$00c0 BANK_ROM2
uint8 romBank2;
uint8 romBank2 = 0xff;
//$00c1 BANK_SRAM
uint8 sramBank;
uint8 sramBank = 0xff;
//$00c2 BANK_ROM0
uint8 romBank0;
uint8 romBank0 = 0xff;
//$00c3 BANK_ROM1
uint8 romBank1;
uint8 romBank1 = 0xff;
//$00cc GPO_EN
uint8 gpoEnable;

View File

@ -56,7 +56,7 @@ auto CPU::power() -> void {
bus.map(this, 0x0062);
}
memory::fill(&r, sizeof(Registers));
r = {};
}
}

View File

@ -95,13 +95,9 @@ auto PPU::power() -> void {
bus.map(this, 0x00a4, 0x00ab);
for(auto& n : output) n = 0;
memory::fill(&s, sizeof(State));
memory::fill(&l, sizeof(Latches));
memory::fill(&r, sizeof(Registers));
r.lcdEnable = 1;
r.vtotal = 158;
r.vblank = 155;
s = {};
l = {};
r = {};
}
}

View File

@ -38,9 +38,9 @@ struct PPU : Thread, IO {
uint32 output[224 * 144];
struct State {
bool field;
uint vclk;
uint hclk;
bool field = 0;
uint vclk = 0;
uint hclk = 0;
Pixel pixel;
} s;
@ -73,11 +73,11 @@ struct PPU : Thread, IO {
//latchSprites()
uint32 sprite[32];
uint spriteCount;
uint spriteCount = 0;
//latchOAM()
uint32 oam[2][128];
uint oamCount;
uint oamCount = 0;
} l;
struct Registers {
@ -145,7 +145,7 @@ struct PPU : Thread, IO {
uint8 scrollTwoY;
//$0014 LCD_CTRL
uint1 lcdEnable;
uint1 lcdEnable = 1;
uint1 lcdContrast; //WSC only
uint6 lcdUnknown;
@ -158,10 +158,10 @@ struct PPU : Thread, IO {
uint1 iconAux3;
//$0016 LCD_VTOTAL
uint8 vtotal;
uint8 vtotal = 158;
//$0017 LCD_VBLANK
uint8 vblank;
uint8 vblank = 155;
//$001c-001f PALMONO_POOL
uint4 pool[8];

View File

@ -5,14 +5,14 @@ auto Video::refresh() -> void {
auto& palette = settings.colorEmulation ? paletteEmulation : paletteStandard;
if(system.orientation() == 0) {
for(uint y = 0; y < 224; y++) {
for(uint y : range(224)) {
auto target = output() + y * 224;
if(y < 40 || y >= 184) {
memory::fill(target, 224 * sizeof(uint32));
memory::fill<uint32>(target, 224);
continue;
}
auto source = ppu.output + (y - 40) * 224;
for(uint x = 0; x < 224; x++) {
for(uint x : range(224)) {
auto color = palette[*source++];
if(settings.blurEmulation) {
auto a = color, b = *target;
@ -25,12 +25,12 @@ auto Video::refresh() -> void {
}
if(system.orientation() == 1) {
for(uint y = 0; y < 224; y++) {
for(uint y : range(224)) {
auto target = output() + y * 224;
memory::fill(target, 40 * sizeof(uint32));
memory::fill(target + 184, 40 * sizeof(uint32));
memory::fill<uint32>(target, 40);
memory::fill<uint32>(target + 184, 40);
target += 40;
for(uint x = 0; x < 144; x++) {
for(uint x : range(144)) {
auto source = ppu.output + x * 224 + (223 - y);
auto color = palette[*source];
if(settings.blurEmulation) {

View File

@ -18,7 +18,7 @@ auto NSMakeImage(image icon, uint scaleWidth = 0, uint scaleHeight = 0) -> NSIma
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
bytesPerRow:(4 * icon.width()) bitsPerPixel:32
] autorelease];
memory::copy([bitmap bitmapData], icon.data(), 4 * icon.width() * icon.height());
memory::copy<uint32_t>([bitmap bitmapData], icon.data(), icon.width() * icon.height());
[cocoaImage addRepresentation:bitmap];
return cocoaImage;
}

View File

@ -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_t));
memory::copy<uint32_t>(buffer, state().icon.data(), width * height);
} else if(auto& gradient = state().gradient) {
auto& colors = gradient.state.colors;
image fill;

View File

@ -69,7 +69,7 @@ auto pCanvas::_rasterize() -> void {
auto buffer = (uint32_t*)qtImage->bits();
if(auto& icon = state().icon) {
memory::copy(buffer, state().icon.data(), width * height * sizeof(uint32_t));
memory::copy<uint32_t>(buffer, state().icon.data(), width * height);
} else if(auto& gradient = state().gradient) {
auto& colors = gradient.state.colors;
image fill;

View File

@ -155,7 +155,7 @@ auto pCanvas::_rasterize() -> void {
pixels.resize(width * height);
if(auto& icon = state().icon) {
memory::copy(pixels.data(), icon.data(), width * height * sizeof(uint32_t));
memory::copy<uint32_t>(pixels.data(), icon.data(), width * height);
} else if(auto& gradient = state().gradient) {
auto& colors = gradient.state.colors;
image fill;

View File

@ -88,9 +88,9 @@ endif
# windows settings
ifeq ($(platform),windows)
link += -lws2_32 -lole32
link += $(if $(findstring $(compiler),g++),-static-libgcc -static-libstdc++)
link += $(if $(findstring $(console),true),-mconsole,-mwindows)
link += -mthreads -lpthread -lws2_32 -lole32
link += $(if $(findstring g++,$(compiler)),-static -static-libgcc -static-libstdc++)
link += $(if $(findstring true,$(console)),-mconsole,-mwindows)
windres := windres
endif

View File

@ -65,15 +65,15 @@ struct bpsmulti {
bpslinear patch;
patch.source({sourcePath, targetName});
patch.target({targetPath, targetName});
patch.create({Path::temp(), "temp.bps"});
patch.create({Path::temporary(), "temp.bps"});
} else {
bpsdelta patch;
patch.source({sourcePath, targetName});
patch.target({targetPath, targetName});
patch.create({Path::temp(), "temp.bps"});
patch.create({Path::temporary(), "temp.bps"});
}
auto buffer = file::read({Path::temp(), "temp.bps"});
auto buffer = file::read({Path::temporary(), "temp.bps"});
writeNumber(buffer.size());
for(auto &byte : buffer) write(byte);
}

View File

@ -13,7 +13,7 @@ struct bitvector {
auto operator=(const bitvector& source) -> bitvector& {
bits = source.bits;
pool = (uint8_t*)memory::resize(pool, bytes());
pool = memory::resize<uint8_t>(pool, bytes());
memory::copy(pool, source.pool, bytes());
return *this;
}
@ -42,7 +42,7 @@ struct bitvector {
uint from = bits;
bits = size;
for(uint n = size; n < from; n++) clear(n); //on reduce
pool = (uint8_t*)memory::resize(pool, bytes());
pool = memory::resize<uint8_t>(pool, bytes());
for(uint n = from; n < size; n++) clear(n); //on expand
}
@ -55,11 +55,11 @@ struct bitvector {
}
auto clear() -> void {
memory::fill(pool, bytes(), 0x00);
memory::fill<uint8_t>(pool, bytes(), 0x00);
}
auto set() -> void {
memory::fill(pool, bytes(), 0xff);
memory::fill<uint8_t>(pool, bytes(), 0xff);
for(uint n = bits; n < bytes() * 8; n++) clear(n);
}

View File

@ -69,7 +69,7 @@ struct Poly1305 {
r[0] = 0, r[1] = 0, r[2] = 0;
h[0] = 0, h[1] = 0, h[2] = 0;
pad[0] = 0, pad[1] = 0;
memory::fill(buffer, 16);
memory::fill(buffer, sizeof(buffer));
offset = 0;
return uint128_t(h1) << 64 | h0;

View File

@ -4,26 +4,26 @@
#include <nall/stdint.hpp>
namespace nall { namespace memory {
inline auto allocate(uint size) -> void*;
inline auto allocate(uint size, uint8_t data) -> void*;
template<typename T = uint8_t> inline auto allocate(uint size) -> T*;
template<typename T = uint8_t> inline auto allocate(uint size, const T& value) -> T*;
inline auto resize(void* target, uint size) -> void*;
template<typename T = uint8_t> inline auto resize(void* target, uint size) -> T*;
inline auto free(void* target) -> void;
inline auto compare(const void* target, uint capacity, const void* source, uint size) -> int;
inline auto compare(const void* target, const void* source, uint size) -> int;
template<typename T = uint8_t> inline auto compare(const void* target, uint capacity, const void* source, uint size) -> int;
template<typename T = uint8_t> inline auto compare(const void* target, const void* source, uint size) -> int;
inline auto icompare(const void* target, uint capacity, const void* source, uint size) -> int;
inline auto icompare(const void* target, const void* source, uint size) -> int;
template<typename T = uint8_t> inline auto icompare(const void* target, uint capacity, const void* source, uint size) -> int;
template<typename T = uint8_t> inline auto icompare(const void* target, const void* source, uint size) -> int;
inline auto copy(void* target, uint capacity, const void* source, uint size) -> void*;
inline auto copy(void* target, const void* source, uint size) -> void*;
template<typename T = uint8_t> inline auto copy(void* target, uint capacity, const void* source, uint size) -> T*;
template<typename T = uint8_t> inline auto copy(void* target, const void* source, uint size) -> T*;
inline auto move(void* target, uint capacity, const void* source, uint size) -> void*;
inline auto move(void* target, const void* source, uint size) -> void*;
template<typename T = uint8_t> inline auto move(void* target, uint capacity, const void* source, uint size) -> T*;
template<typename T = uint8_t> inline auto move(void* target, const void* source, uint size) -> T*;
inline auto fill(void* target, uint capacity, uint8_t data = 0x00) -> void*;
template<typename T = uint8_t> inline auto fill(void* target, uint capacity, const T& value = {}) -> T*;
template<typename T> inline auto assign(T* target) -> void {}
template<typename T, typename U, typename... P> inline auto assign(T* target, const U& value, P&&... p) -> void;
@ -35,35 +35,35 @@ namespace nall { namespace memory {
template<uint size, typename T = uint64_t> inline auto writem(void* target, T data) -> void;
}}
namespace nall {
namespace nall { namespace memory {
//implementation notes:
//memcmp, memcpy, memmove have terrible performance on small block sizes (FreeBSD 10.0-amd64)
//as this library is used extensively by nall/string, and most strings tend to be small,
//this library hand-codes these functions instead. surprisingly, it's a substantial speedup
auto memory::allocate(uint size) -> void* {
return malloc(size);
template<typename T> auto allocate(uint size) -> T* {
return (T*)malloc(size * sizeof(T));
}
auto memory::allocate(uint size, uint8_t data) -> void* {
auto result = malloc(size);
if(result) fill(result, size, data);
template<typename T> auto allocate(uint size, const T& value) -> T* {
auto result = allocate<T>(size);
if(result) fill<T>(result, size, value);
return result;
}
auto memory::resize(void* target, uint size) -> void* {
return realloc(target, size);
template<typename T> auto resize(void* target, uint size) -> T* {
return (T*)realloc(target, size * sizeof(T));
}
auto memory::free(void* target) -> void {
auto free(void* target) -> void {
::free(target);
}
auto memory::compare(const void* target, uint capacity, const void* source, uint size) -> int {
template<typename T> auto compare(const void* target, uint capacity, const void* source, uint size) -> int {
auto t = (int8_t*)target;
auto s = (int8_t*)source;
auto l = min(capacity, size);
auto l = min(capacity, size) * sizeof(T);
while(l--) {
auto x = *t++;
auto y = *s++;
@ -72,14 +72,14 @@ auto memory::compare(const void* target, uint capacity, const void* source, uint
return 0;
}
auto memory::compare(const void* target, const void* source, uint size) -> int {
return compare(target, size, source, size);
template<typename T> auto compare(const void* target, const void* source, uint size) -> int {
return compare<T>(target, size, source, size);
}
auto memory::icompare(const void* target, uint capacity, const void* source, uint size) -> int {
template<typename T> auto icompare(const void* target, uint capacity, const void* source, uint size) -> int {
auto t = (int8_t*)target;
auto s = (int8_t*)source;
auto l = min(capacity, size);
auto l = min(capacity, size) * sizeof(T);
while(l--) {
auto x = *t++;
auto y = *s++;
@ -90,26 +90,26 @@ auto memory::icompare(const void* target, uint capacity, const void* source, uin
return 0;
}
auto memory::icompare(const void* target, const void* source, uint size) -> int {
return icompare(target, size, source, size);
template<typename T> auto icompare(const void* target, const void* source, uint size) -> int {
return icompare<T>(target, size, source, size);
}
auto memory::copy(void* target, uint capacity, const void* source, uint size) -> void* {
template<typename T> auto copy(void* target, uint capacity, const void* source, uint size) -> T* {
auto t = (uint8_t*)target;
auto s = (uint8_t*)source;
auto l = min(capacity, size);
auto l = min(capacity, size) * sizeof(T);
while(l--) *t++ = *s++;
return target;
return (T*)target;
}
auto memory::copy(void* target, const void* source, uint size) -> void* {
return copy(target, size, source, size);
template<typename T> auto copy(void* target, const void* source, uint size) -> T* {
return copy<T>(target, size, source, size);
}
auto memory::move(void* target, uint capacity, const void* source, uint size) -> void* {
template<typename T> auto move(void* target, uint capacity, const void* source, uint size) -> T* {
auto t = (uint8_t*)target;
auto s = (uint8_t*)source;
auto l = min(capacity, size);
auto l = min(capacity, size) * sizeof(T);
if(t < s) {
while(l--) *t++ = *s++;
} else {
@ -117,47 +117,46 @@ auto memory::move(void* target, uint capacity, const void* source, uint size) ->
s += l;
while(l--) *--t = *--s;
}
return target;
return (T*)target;
}
auto memory::move(void* target, const void* source, uint size) -> void* {
return move(target, size, source, size);
template<typename T> auto move(void* target, const void* source, uint size) -> T* {
return move<T>(target, size, source, size);
}
auto memory::fill(void* target, uint capacity, uint8_t data) -> void* {
auto t = (uint8_t*)target;
while(capacity--) *t++ = data;
return target;
template<typename T> auto fill(void* target, uint capacity, const T& value) -> T* {
auto t = (T*)target;
while(capacity--) *t++ = value;
return (T*)target;
}
template<typename T, typename U, typename... P>
auto memory::assign(T* target, const U& value, P&&... p) -> void {
template<typename T, typename U, typename... P> auto assign(T* target, const U& value, P&&... p) -> void {
*target++ = value;
assign(target, forward<P>(p)...);
}
template<uint size, typename T> auto memory::readl(const void* source) -> T {
template<uint size, typename T> auto readl(const void* source) -> T {
auto p = (const uint8_t*)source;
T data = 0;
for(uint n = 0; n < size; n++) data |= T(*p++) << n * 8;
return data;
}
template<uint size, typename T> auto memory::readm(const void* source) -> T {
template<uint size, typename T> auto readm(const void* source) -> T {
auto p = (const uint8_t*)source;
T data = 0;
for(int n = size - 1; n >= 0; n--) data |= T(*p++) << n * 8;
return data;
}
template<uint size, typename T> auto memory::writel(void* target, T data) -> void {
template<uint size, typename T> auto writel(void* target, T data) -> void {
auto p = (uint8_t*)target;
for(uint n = 0; n < size; n++) *p++ = data >> n * 8;
}
template<uint size, typename T> auto memory::writem(void* target, T data) -> void {
template<uint size, typename T> auto writem(void* target, T data) -> void {
auto p = (uint8_t*)target;
for(int n = size - 1; n >= 0; n--) *p++ = data >> n * 8;
}
}
}}

View File

@ -41,7 +41,7 @@ auto service::command(const string& name, const string& command) -> bool {
}
if(auto data = shared.acquire()) {
if(command == "stop") print("[{0}] stopped\n", string_format{name});
memory::copy(data, command.data(), min(command.size(), 4096));
memory::copy(data, 4096, command.data(), command.size());
shared.release();
}
if(command == "remove") {

View File

@ -96,7 +96,7 @@ auto string::operator=(string&& source) -> type& {
auto string::_allocate() -> void {
char _temp[SSO];
memory::copy(_temp, _text, SSO);
_data = (char*)memory::allocate(_capacity + 1 + sizeof(uint));
_data = memory::allocate<char>(_capacity + 1 + sizeof(uint));
memory::copy(_data, _temp, SSO);
_refs = (uint*)(_data + _capacity + 1); //always aligned by 32 via reserve()
*_refs = 1;
@ -104,7 +104,7 @@ auto string::_allocate() -> void {
//COW -> Unique
auto string::_copy() -> void {
auto _temp = (char*)memory::allocate(_capacity + 1 + sizeof(uint));
auto _temp = memory::allocate<char>(_capacity + 1 + sizeof(uint));
memory::copy(_temp, _data, _size = min(_capacity, _size));
_temp[_size] = 0;
--*_refs;
@ -115,7 +115,7 @@ auto string::_copy() -> void {
//COW -> Resize
auto string::_resize() -> void {
_data = (char*)memory::resize(_data, _capacity + 1 + sizeof(uint));
_data = memory::resize<char>(_data, _capacity + 1 + sizeof(uint));
_refs = (uint*)(_data + _capacity + 1);
*_refs = 1;
}

View File

@ -70,7 +70,7 @@ auto string::operator=(string&& source) -> string& {
}
auto string::_allocate() -> char* {
auto _temp = (char*)memory::allocate(_capacity + 1 + sizeof(uint));
auto _temp = memory::allocate<char>(_capacity + 1 + sizeof(uint));
*_temp = 0;
_refs = (uint*)(_temp + _capacity + 1); //this will always be aligned by 32 via reserve()
*_refs = 1;
@ -78,7 +78,7 @@ auto string::_allocate() -> char* {
}
auto string::_copy() -> char* {
auto _temp = (char*)memory::allocate(_capacity + 1 + sizeof(uint));
auto _temp = memory::allocate<char>(_capacity + 1 + sizeof(uint));
memory::copy(_temp, _data, _size = min(_capacity, _size));
_temp[_size] = 0;
--*_refs;

View File

@ -50,10 +50,10 @@ auto string::reserve(uint capacity) -> type& {
if(_capacity < SSO) {
char _temp[SSO];
memory::copy(_temp, _text, SSO);
_data = (char*)memory::allocate(_capacity = capacity + 1);
_data = memory::allocate<char>(_capacity = capacity + 1);
memory::copy(_data, _temp, SSO);
} else {
_data = (char*)memory::resize(_data, _capacity = capacity + 1);
_data = memory::resize<char>(_data, _capacity = capacity + 1);
}
return *this;
}
@ -68,7 +68,7 @@ auto string::operator=(const string& source) -> type& {
if(&source == this) return *this;
reset();
if(source._capacity >= SSO) {
_data = (char*)memory::allocate(source._capacity + 1);
_data = memory::allocate<char>(source._capacity + 1);
_capacity = source._capacity;
_size = source._size;
memory::copy(_data, source._data, source._size + 1);

View File

@ -39,7 +39,7 @@ auto string::reset() -> type& {
auto string::reserve(uint capacity) -> type& {
if(capacity > _capacity) {
_capacity = bit::round(capacity + 1) - 1;
_data = (char*)memory::resize(_data, _capacity + 1);
_data = memory::resize<char>(_data, _capacity + 1);
_data[_capacity] = 0;
}
return *this;
@ -54,7 +54,7 @@ auto string::resize(uint size) -> type& {
auto string::operator=(const string& source) -> type& {
if(&source == this) return *this;
reset();
_data = (char*)memory::allocate(source._size + 1);
_data = memory::allocate<char>(source._size + 1);
_capacity = source._size;
_size = source._size;
memory::copy(_data, source.data(), source.size() + 1);

View File

@ -7,7 +7,7 @@ namespace nall {
auto string::format(const nall::string_format& params) -> type& {
auto size = (int)this->size();
auto data = (char*)memory::allocate(size);
auto data = memory::allocate<char>(size);
memory::copy(data, this->data(), size);
int x = 0;

View File

@ -4,7 +4,7 @@ namespace nall {
template<typename T> auto vector<T>::operator=(const vector<T>& source) -> vector<T>& {
if(this == &source) return *this;
_pool = (T*)memory::allocate(sizeof(T) * source._size);
_pool = memory::allocate<T>(source._size);
_size = source._size;
_left = 0;
_right = 0;

View File

@ -27,7 +27,7 @@ template<typename T> auto vector<T>::reserveLeft(uint capacity) -> bool {
if(_size + _left >= capacity) return false;
uint left = bit::round(capacity);
auto pool = (T*)memory::allocate(sizeof(T) * (left + _right)) + (left - _size);
auto pool = memory::allocate<T>(left + _right) + (left - _size);
for(uint n : range(_size)) new(pool + n) T(move(_pool[n]));
memory::free(_pool - _left);
@ -41,7 +41,7 @@ template<typename T> auto vector<T>::reserveRight(uint capacity) -> bool {
if(_size + _right >= capacity) return false;
uint right = bit::round(capacity);
auto pool = (T*)memory::allocate(sizeof(T) * (_left + right)) + _left;
auto pool = memory::allocate<T>(_left + right) + _left;
for(uint n : range(_size)) new(pool + n) T(move(_pool[n]));
memory::free(_pool - _left);

View File

@ -91,7 +91,7 @@ struct AudioALSA : Audio {
_offset--;
output++;
}
memory::move(_buffer, output, _offset * sizeof(uint32_t));
memory::move<uint32_t>(_buffer, output, _offset);
}
}

View File

@ -71,10 +71,10 @@ struct AudioASIO : Audio {
auto clear() -> void {
if(!ready()) return;
for(uint n : range(_channels)) {
memory::fill(_channel[n].buffers[0], _latency * _sampleSize);
memory::fill(_channel[n].buffers[1], _latency * _sampleSize);
memory::fill<uint8_t>(_channel[n].buffers[0], _latency * _sampleSize);
memory::fill<uint8_t>(_channel[n].buffers[1], _latency * _sampleSize);
}
memory::fill(_queue.samples, sizeof(_queue.samples));
memory::fill<uint8_t>(_queue.samples, sizeof(_queue.samples));
_queue.read = 0;
_queue.write = 0;
_queue.count = 0;

View File

@ -51,7 +51,7 @@ struct AudioDirectSound : Audio {
_ringWrite = _rings - 1;
_ringDistance = _rings - 1;
if(_buffer) memory::fill(_buffer, _period * _rings * 4);
if(_buffer) memory::fill<uint32_t>(_buffer, _period * _rings);
_offset = 0;
if(!_secondary) return;
@ -61,7 +61,7 @@ struct AudioDirectSound : Audio {
void* output;
DWORD size;
_secondary->Lock(0, _period * _rings * 4, &output, &size, 0, 0, 0);
memory::fill(output, size);
memory::fill<uint8_t>(output, size);
_secondary->Unlock(output, size, 0, 0);
_secondary->Play(0, 0, DSBPLAY_LOOPING);
@ -102,7 +102,7 @@ struct AudioDirectSound : Audio {
void* output;
DWORD size;
if(_secondary->Lock(_ringWrite * _period * 4, _period * 4, &output, &size, 0, 0, 0) == DS_OK) {
memory::copy(output, _buffer, _period * 4);
memory::copy<uint32_t>(output, _buffer, _period);
_secondary->Unlock(output, size, 0, 0);
}
}

View File

@ -53,7 +53,7 @@ struct AudioXAudio2 : Audio, public IXAudio2VoiceCallback {
_bufferIndex = 0;
_bufferOffset = 0;
if(_buffer) memory::fill(_buffer, _period * _bufferCount * sizeof(uint32_t));
if(_buffer) memory::fill<uint32_t>(_buffer, _period * _bufferCount);
_sourceVoice->Start(0);
}

View File

@ -215,7 +215,7 @@ private:
LPDIRECT3DVERTEXBUFFER9* vertexPointer = nullptr;
_vertexBuffer->Lock(0, sizeof(Vertex) * 4, (void**)&vertexPointer, 0);
memory::copy(vertexPointer, vertex, sizeof(Vertex) * 4);
memory::copy<Vertex>(vertexPointer, vertex, 4);
_vertexBuffer->Unlock();
_device->SetStreamSource(0, _vertexBuffer, 0, sizeof(Vertex));

View File

@ -52,7 +52,7 @@ struct VideoGLX2 : Video {
auto clear() -> void {
if(!ready()) return;
memory::fill(_glBuffer, _glWidth * _glHeight * sizeof(uint32_t));
memory::fill<uint32_t>(_glBuffer, _glWidth * _glHeight);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();

View File

@ -38,7 +38,7 @@ struct VideoXVideo : Video {
auto clear() -> void {
if(!ready()) return;
memory::fill(_buffer, _bufferWidth * _bufferHeight * sizeof(uint32_t));
memory::fill<uint32_t>(_buffer, _bufferWidth * _bufferHeight);
//clear twice in case video is double buffered ...
output();
output();
@ -335,7 +335,7 @@ private:
uint32_t* output = (uint32_t*)_image->data;
for(uint y : range(height)) {
memory::copy(output, input, width * 4);
memory::copy<uint32_t>(output, input, width);
input += _bufferWidth;
output += _bufferWidth;
}