mirror of https://github.com/bsnes-emu/bsnes.git
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:
parent
6882bd98cf
commit
685cec6583
|
@ -11,7 +11,7 @@ flags += $(if $(call streq,$(profile),accurate),-DPROFILE_ACCURATE,-DPROFILE_FAS
|
||||||
|
|
||||||
ifeq ($(platform),windows)
|
ifeq ($(platform),windows)
|
||||||
ifeq ($(binary),application)
|
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-auto-import
|
||||||
link += -Wl,-enable-runtime-pseudo-reloc
|
link += -Wl,-enable-runtime-pseudo-reloc
|
||||||
else ifeq ($(binary),library)
|
else ifeq ($(binary),library)
|
||||||
|
|
|
@ -12,7 +12,7 @@ using namespace nall;
|
||||||
|
|
||||||
namespace Emulator {
|
namespace Emulator {
|
||||||
static const string Name = "higan";
|
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 Author = "byuu";
|
||||||
static const string License = "GPLv3";
|
static const string License = "GPLv3";
|
||||||
static const string Website = "https://byuu.org/";
|
static const string Website = "https://byuu.org/";
|
||||||
|
|
|
@ -38,7 +38,7 @@ auto CPU::power(bool reset) -> void {
|
||||||
r.pc.byte(0) = bus.read(0xfffc);
|
r.pc.byte(0) = bus.read(0xfffc);
|
||||||
r.pc.byte(1) = bus.read(0xfffd);
|
r.pc.byte(1) = bus.read(0xfffd);
|
||||||
|
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
io.rdyLine = 1;
|
io.rdyLine = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,17 +40,17 @@ struct CPU : Processor::MOS6502, Thread {
|
||||||
uint8 ram[0x800];
|
uint8 ram[0x800];
|
||||||
|
|
||||||
struct IO {
|
struct IO {
|
||||||
bool interruptPending;
|
bool interruptPending = 0;
|
||||||
bool nmiPending;
|
bool nmiPending = 0;
|
||||||
bool nmiLine;
|
bool nmiLine = 0;
|
||||||
bool irqLine;
|
bool irqLine = 0;
|
||||||
bool apuLine;
|
bool apuLine = 0;
|
||||||
|
|
||||||
bool rdyLine;
|
bool rdyLine = 0;
|
||||||
bool rdyAddrValid;
|
bool rdyAddrValid = 0;
|
||||||
uint16 rdyAddrValue;
|
uint16 rdyAddrValue;
|
||||||
|
|
||||||
bool oamdmaPending;
|
bool oamdmaPending = 0;
|
||||||
uint8 oamdmaPage;
|
uint8 oamdmaPage;
|
||||||
} io;
|
} io;
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,8 +57,8 @@ auto PPU::refresh() -> void {
|
||||||
auto PPU::power(bool reset) -> void {
|
auto PPU::power(bool reset) -> void {
|
||||||
create(PPU::Enter, system.frequency());
|
create(PPU::Enter, system.frequency());
|
||||||
|
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
memory::fill(&latch, sizeof(Latches));
|
latch = {};
|
||||||
io.vramIncrement = 1;
|
io.vramIncrement = 1;
|
||||||
|
|
||||||
if(!reset) {
|
if(!reset) {
|
||||||
|
|
|
@ -39,13 +39,14 @@ struct PPU : Thread {
|
||||||
uint8 mdr;
|
uint8 mdr;
|
||||||
|
|
||||||
uint1 field;
|
uint1 field;
|
||||||
uint lx;
|
uint lx = 0;
|
||||||
uint ly;
|
uint ly = 0;
|
||||||
|
|
||||||
uint8 busData;
|
uint8 busData;
|
||||||
|
|
||||||
union {
|
union Union {
|
||||||
uint value;
|
auto& operator=(const Union& u) { value = u.value; return *this; }
|
||||||
|
uint value = 0;
|
||||||
NaturalBitField<uint, 0, 4> tileX;
|
NaturalBitField<uint, 0, 4> tileX;
|
||||||
NaturalBitField<uint, 5, 9> tileY;
|
NaturalBitField<uint, 5, 9> tileY;
|
||||||
NaturalBitField<uint,10,11> nametable;
|
NaturalBitField<uint,10,11> nametable;
|
||||||
|
@ -59,28 +60,28 @@ struct PPU : Thread {
|
||||||
NaturalBitField<uint,16,18> fineX;
|
NaturalBitField<uint,16,18> fineX;
|
||||||
} v, t;
|
} v, t;
|
||||||
|
|
||||||
bool nmiHold;
|
bool nmiHold = 0;
|
||||||
bool nmiFlag;
|
bool nmiFlag = 0;
|
||||||
|
|
||||||
//$2000
|
//$2000
|
||||||
uint vramIncrement;
|
uint vramIncrement = 0;
|
||||||
uint spriteAddress;
|
uint spriteAddress = 0;
|
||||||
uint bgAddress;
|
uint bgAddress = 0;
|
||||||
uint spriteHeight;
|
uint spriteHeight = 0;
|
||||||
bool masterSelect;
|
bool masterSelect = 0;
|
||||||
bool nmiEnable;
|
bool nmiEnable = 0;
|
||||||
|
|
||||||
//$2001
|
//$2001
|
||||||
bool grayscale;
|
bool grayscale = 0;
|
||||||
bool bgEdgeEnable;
|
bool bgEdgeEnable = 0;
|
||||||
bool spriteEdgeEnable;
|
bool spriteEdgeEnable = 0;
|
||||||
bool bgEnable;
|
bool bgEnable = 0;
|
||||||
bool spriteEnable;
|
bool spriteEnable = 0;
|
||||||
uint3 emphasis;
|
uint3 emphasis;
|
||||||
|
|
||||||
//$2002
|
//$2002
|
||||||
bool spriteOverflow;
|
bool spriteOverflow = 0;
|
||||||
bool spriteZeroHit;
|
bool spriteZeroHit = 0;
|
||||||
|
|
||||||
//$2003
|
//$2003
|
||||||
uint8 oamAddress;
|
uint8 oamAddress;
|
||||||
|
@ -106,8 +107,8 @@ struct PPU : Thread {
|
||||||
uint16 tiledataLo;
|
uint16 tiledataLo;
|
||||||
uint16 tiledataHi;
|
uint16 tiledataHi;
|
||||||
|
|
||||||
uint oamIterator;
|
uint oamIterator = 0;
|
||||||
uint oamCounter;
|
uint oamCounter = 0;
|
||||||
|
|
||||||
OAM oam[8]; //primary
|
OAM oam[8]; //primary
|
||||||
OAM soam[8]; //secondary
|
OAM soam[8]; //secondary
|
||||||
|
|
|
@ -70,7 +70,7 @@ auto Cartridge::load() -> bool {
|
||||||
|
|
||||||
if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=ROM,content=Program)"]}) {
|
if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=ROM,content=Program)"]}) {
|
||||||
rom.size = max(0x4000, (uint)memory.size);
|
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)) {
|
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Required)) {
|
||||||
fp->read(rom.data, min(rom.size, fp->size()));
|
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)"]}) {
|
if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=RAM,content=Save)"]}) {
|
||||||
ram.size = memory.size;
|
ram.size = memory.size;
|
||||||
ram.data = (uint8*)memory::allocate(ram.size, 0xff);
|
ram.data = memory::allocate<uint8>(ram.size, 0xff);
|
||||||
if(memory.nonVolatile) {
|
if(memory.nonVolatile) {
|
||||||
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Optional)) {
|
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Optional)) {
|
||||||
fp->read(ram.data, min(ram.size, fp->size()));
|
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)"]}) {
|
if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=RTC,content=Time)"]}) {
|
||||||
rtc.size = memory.size;
|
rtc.size = memory.size;
|
||||||
rtc.data = (uint8*)memory::allocate(rtc.size, 0xff);
|
rtc.data = memory::allocate<uint8>(rtc.size, 0xff);
|
||||||
if(memory.nonVolatile) {
|
if(memory.nonVolatile) {
|
||||||
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Optional)) {
|
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Optional)) {
|
||||||
fp->read(rtc.data, min(rtc.size, fp->size()));
|
fp->read(rtc.data, min(rtc.size, fp->size()));
|
||||||
|
|
|
@ -123,7 +123,7 @@ auto CPU::power() -> void {
|
||||||
for(auto& n : wram) n = 0x00;
|
for(auto& n : wram) n = 0x00;
|
||||||
for(auto& n : hram) n = 0x00;
|
for(auto& n : hram) n = 0x00;
|
||||||
|
|
||||||
memory::fill(&status, sizeof(Status));
|
status = {};
|
||||||
status.dmaCompleted = true;
|
status.dmaCompleted = true;
|
||||||
status.wramBank = 1;
|
status.wramBank = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,18 +38,18 @@ struct CPU : Processor::LR35902, Thread, MMIO {
|
||||||
uint22 clock;
|
uint22 clock;
|
||||||
|
|
||||||
//$ff00 JOYP
|
//$ff00 JOYP
|
||||||
bool p15;
|
bool p15 = 0;
|
||||||
bool p14;
|
bool p14 = 0;
|
||||||
uint8 joyp;
|
uint8 joyp;
|
||||||
uint8 mltReq;
|
uint8 mltReq;
|
||||||
|
|
||||||
//$ff01 SB
|
//$ff01 SB
|
||||||
uint8 serialData;
|
uint8 serialData;
|
||||||
uint serialBits;
|
uint serialBits = 0;
|
||||||
|
|
||||||
//$ff02 SC
|
//$ff02 SC
|
||||||
bool serialTransfer;
|
bool serialTransfer = 0;
|
||||||
bool serialClock;
|
bool serialClock = 0;
|
||||||
|
|
||||||
//$ff04 DIV
|
//$ff04 DIV
|
||||||
uint16 div;
|
uint16 div;
|
||||||
|
@ -61,19 +61,19 @@ struct CPU : Processor::LR35902, Thread, MMIO {
|
||||||
uint8 tma;
|
uint8 tma;
|
||||||
|
|
||||||
//$ff07 TAC
|
//$ff07 TAC
|
||||||
bool timerEnable;
|
bool timerEnable = 0;
|
||||||
uint timerClock;
|
uint timerClock = 0;
|
||||||
|
|
||||||
//$ff0f IF
|
//$ff0f IF
|
||||||
bool interruptRequestJoypad;
|
bool interruptRequestJoypad = 0;
|
||||||
bool interruptRequestSerial;
|
bool interruptRequestSerial = 0;
|
||||||
bool interruptRequestTimer;
|
bool interruptRequestTimer = 0;
|
||||||
bool interruptRequestStat;
|
bool interruptRequestStat = 0;
|
||||||
bool interruptRequestVblank;
|
bool interruptRequestVblank = 0;
|
||||||
|
|
||||||
//$ff4d KEY1
|
//$ff4d KEY1
|
||||||
bool speedDouble;
|
bool speedDouble = 0;
|
||||||
bool speedSwitch;
|
bool speedSwitch = 0;
|
||||||
|
|
||||||
//$ff51,$ff52 HDMA1,HDMA2
|
//$ff51,$ff52 HDMA1,HDMA2
|
||||||
uint16 dmaSource;
|
uint16 dmaSource;
|
||||||
|
@ -82,9 +82,9 @@ struct CPU : Processor::LR35902, Thread, MMIO {
|
||||||
uint16 dmaTarget;
|
uint16 dmaTarget;
|
||||||
|
|
||||||
//$ff55 HDMA5
|
//$ff55 HDMA5
|
||||||
bool dmaMode;
|
bool dmaMode = 0;
|
||||||
uint16 dmaLength;
|
uint16 dmaLength;
|
||||||
bool dmaCompleted;
|
bool dmaCompleted = 0;
|
||||||
|
|
||||||
//$ff6c ???
|
//$ff6c ???
|
||||||
uint8 ff6c;
|
uint8 ff6c;
|
||||||
|
@ -99,11 +99,11 @@ struct CPU : Processor::LR35902, Thread, MMIO {
|
||||||
uint8 ff75;
|
uint8 ff75;
|
||||||
|
|
||||||
//$ffff IE
|
//$ffff IE
|
||||||
bool interruptEnableJoypad;
|
bool interruptEnableJoypad = 0;
|
||||||
bool interruptEnableSerial;
|
bool interruptEnableSerial = 0;
|
||||||
bool interruptEnableTimer;
|
bool interruptEnableTimer = 0;
|
||||||
bool interruptEnableStat;
|
bool interruptEnableStat = 0;
|
||||||
bool interruptEnableVblank;
|
bool interruptEnableVblank = 0;
|
||||||
} status;
|
} status;
|
||||||
|
|
||||||
uint8 wram[32768]; //GB=8192, GBC=32768
|
uint8 wram[32768]; //GB=8192, GBC=32768
|
||||||
|
|
|
@ -151,7 +151,7 @@ auto PPU::power() -> void {
|
||||||
for(auto& n : bgpd) n = 0x0000;
|
for(auto& n : bgpd) n = 0x0000;
|
||||||
for(auto& n : obpd) n = 0x0000;
|
for(auto& n : obpd) n = 0x0000;
|
||||||
|
|
||||||
memory::fill(&status, sizeof(Status));
|
status = {};
|
||||||
|
|
||||||
for(auto& n : screen) n = 0;
|
for(auto& n : screen) n = 0;
|
||||||
|
|
||||||
|
|
|
@ -44,24 +44,24 @@ struct PPU : Thread, MMIO {
|
||||||
function<auto () -> void> run;
|
function<auto () -> void> run;
|
||||||
|
|
||||||
struct Status {
|
struct Status {
|
||||||
bool irq; //STAT IRQ line
|
bool irq = 0; //STAT IRQ line
|
||||||
uint lx;
|
uint lx = 0;
|
||||||
|
|
||||||
//$ff40 LCDC
|
//$ff40 LCDC
|
||||||
bool displayEnable;
|
bool displayEnable = 0;
|
||||||
bool windowTilemapSelect;
|
bool windowTilemapSelect = 0;
|
||||||
bool windowDisplayEnable;
|
bool windowDisplayEnable = 0;
|
||||||
bool bgTiledataSelect;
|
bool bgTiledataSelect = 0;
|
||||||
bool bgTilemapSelect;
|
bool bgTilemapSelect = 0;
|
||||||
bool obSize;
|
bool obSize = 0;
|
||||||
bool obEnable;
|
bool obEnable = 0;
|
||||||
bool bgEnable;
|
bool bgEnable = 0;
|
||||||
|
|
||||||
//$ff41 STAT
|
//$ff41 STAT
|
||||||
bool interruptLYC;
|
bool interruptLYC = 0;
|
||||||
bool interruptOAM;
|
bool interruptOAM = 0;
|
||||||
bool interruptVblank;
|
bool interruptVblank = 0;
|
||||||
bool interruptHblank;
|
bool interruptHblank = 0;
|
||||||
uint2 mode;
|
uint2 mode;
|
||||||
|
|
||||||
//$ff42 SCY
|
//$ff42 SCY
|
||||||
|
@ -77,8 +77,8 @@ struct PPU : Thread, MMIO {
|
||||||
uint8 lyc;
|
uint8 lyc;
|
||||||
|
|
||||||
//$ff46 DMA
|
//$ff46 DMA
|
||||||
bool dmaActive;
|
bool dmaActive = 0;
|
||||||
uint dmaClock;
|
uint dmaClock = 0;
|
||||||
uint8 dmaBank;
|
uint8 dmaBank;
|
||||||
|
|
||||||
//$ff4a WY
|
//$ff4a WY
|
||||||
|
@ -88,14 +88,14 @@ struct PPU : Thread, MMIO {
|
||||||
uint8 wx;
|
uint8 wx;
|
||||||
|
|
||||||
//$ff4f VBK
|
//$ff4f VBK
|
||||||
bool vramBank;
|
bool vramBank = 0;
|
||||||
|
|
||||||
//$ff68 BGPI
|
//$ff68 BGPI
|
||||||
bool bgpiIncrement;
|
bool bgpiIncrement = 0;
|
||||||
uint6 bgpi;
|
uint6 bgpi;
|
||||||
|
|
||||||
//$ff6a OBPI
|
//$ff6a OBPI
|
||||||
bool obpiIncrement;
|
bool obpiIncrement = 0;
|
||||||
uint8 obpi;
|
uint8 obpi;
|
||||||
} status;
|
} status;
|
||||||
|
|
||||||
|
@ -104,26 +104,26 @@ struct PPU : Thread, MMIO {
|
||||||
struct Pixel {
|
struct Pixel {
|
||||||
uint16 color;
|
uint16 color;
|
||||||
uint8 palette;
|
uint8 palette;
|
||||||
bool priority;
|
bool priority = 0;
|
||||||
};
|
};
|
||||||
Pixel bg;
|
Pixel bg;
|
||||||
Pixel ob;
|
Pixel ob;
|
||||||
|
|
||||||
struct Sprite {
|
struct Sprite {
|
||||||
uint x;
|
uint x = 0;
|
||||||
uint y;
|
uint y = 0;
|
||||||
uint tile;
|
uint tile = 0;
|
||||||
uint attr;
|
uint attr = 0;
|
||||||
uint data;
|
uint data = 0;
|
||||||
};
|
};
|
||||||
Sprite sprite[10];
|
Sprite sprite[10];
|
||||||
uint sprites;
|
uint sprites = 0;
|
||||||
|
|
||||||
uint px;
|
uint px = 0;
|
||||||
|
|
||||||
struct Background {
|
struct Background {
|
||||||
uint attr;
|
uint attr = 0;
|
||||||
uint data;
|
uint data = 0;
|
||||||
};
|
};
|
||||||
Background background;
|
Background background;
|
||||||
Background window;
|
Background window;
|
||||||
|
|
|
@ -87,7 +87,7 @@ auto PPU::Objects::run(uint x, uint y) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PPU::Objects::power() -> void {
|
auto PPU::Objects::power() -> void {
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
for(auto& pixel : buffer) pixel = {};
|
for(auto& pixel : buffer) pixel = {};
|
||||||
output = {};
|
output = {};
|
||||||
mosaic = {};
|
mosaic = {};
|
||||||
|
|
|
@ -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) writePRAM(n, Half, 0x0000);
|
||||||
for(uint n = 0; n < 1024; n += 2) writeOAM(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& object : this->object) object = {};
|
||||||
for(auto& param : this->objectParam) param = {};
|
for(auto& param : this->objectParam) param = {};
|
||||||
|
|
||||||
|
|
|
@ -65,5 +65,5 @@ auto PPU::Screen::blend(uint15 above, uint eva, uint15 below, uint evb) -> uint1
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PPU::Screen::power() -> void {
|
auto PPU::Screen::power() -> void {
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,6 @@ auto PPU::Window::run(uint x, uint y) -> void {
|
||||||
auto PPU::Window::power(uint id) -> void {
|
auto PPU::Window::power(uint id) -> void {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
|
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
output = 0;
|
output = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ auto APU::power(bool reset) -> void {
|
||||||
bus->grant(false);
|
bus->grant(false);
|
||||||
create(APU::Enter, system.frequency() / 15.0);
|
create(APU::Enter, system.frequency() / 15.0);
|
||||||
|
|
||||||
if(!reset) memory::fill(ram, sizeof ram);
|
if(!reset) memory::fill(ram, sizeof(ram));
|
||||||
state = {};
|
state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ auto CPU::power(bool reset) -> void {
|
||||||
M68K::power();
|
M68K::power();
|
||||||
create(CPU::Enter, system.frequency() / 7.0);
|
create(CPU::Enter, system.frequency() / 7.0);
|
||||||
|
|
||||||
if(!reset) memory::fill(ram, sizeof ram);
|
if(!reset) memory::fill(ram, sizeof(ram));
|
||||||
|
|
||||||
io = {};
|
io = {};
|
||||||
io.version = tmssEnable;
|
io.version = tmssEnable;
|
||||||
|
|
|
@ -47,5 +47,5 @@ auto VDP::DMA::copy() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto VDP::DMA::power() -> void {
|
auto VDP::DMA::power() -> void {
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ auto Cartridge::unload() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Cartridge::power() -> void {
|
auto Cartridge::power() -> void {
|
||||||
memory::fill(&mapper, sizeof(Mapper));
|
mapper = {};
|
||||||
mapper.romPage0 = 0;
|
mapper.romPage0 = 0;
|
||||||
mapper.romPage1 = 1;
|
mapper.romPage1 = 1;
|
||||||
mapper.romPage2 = 2;
|
mapper.romPage2 = 2;
|
||||||
|
|
|
@ -60,7 +60,7 @@ auto CPU::power() -> void {
|
||||||
|
|
||||||
r.pc = 0x0000; //reset vector address
|
r.pc = 0x0000; //reset vector address
|
||||||
|
|
||||||
memory::fill(&state, sizeof(State));
|
state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ private:
|
||||||
uint8 ram[8 * 1024];
|
uint8 ram[8 * 1024];
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
bool nmiLine;
|
bool nmiLine = 0;
|
||||||
bool intLine;
|
bool intLine = 0;
|
||||||
} state;
|
} state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,6 @@ auto VDP::Background::run() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto VDP::Background::power() -> void {
|
auto VDP::Background::power() -> void {
|
||||||
memory::fill(&state, sizeof(State));
|
state = {};
|
||||||
memory::fill(&output, sizeof(Output));
|
output = {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,6 @@ auto VDP::Sprite::run() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto VDP::Sprite::power() -> void {
|
auto VDP::Sprite::power() -> void {
|
||||||
memory::fill(&state, sizeof(State));
|
state = {};
|
||||||
memory::fill(&output, sizeof(Output));
|
output = {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,8 @@ auto VDP::vblank() -> bool {
|
||||||
auto VDP::power() -> void {
|
auto VDP::power() -> void {
|
||||||
create(VDP::Enter, system.colorburst() * 15.0 / 5.0);
|
create(VDP::Enter, system.colorburst() * 15.0 / 5.0);
|
||||||
|
|
||||||
memory::fill(&buffer, sizeof(buffer));
|
memory::fill<uint32>(buffer, 256 * 264);
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
|
|
||||||
background.power();
|
background.power();
|
||||||
sprite.power();
|
sprite.power();
|
||||||
|
|
|
@ -32,8 +32,8 @@ struct VDP : Thread {
|
||||||
auto serialize(serializer&) -> void;
|
auto serialize(serializer&) -> void;
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
uint x;
|
uint x = 0;
|
||||||
uint y;
|
uint y = 0;
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
struct Output {
|
struct Output {
|
||||||
|
@ -60,8 +60,8 @@ struct VDP : Thread {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
uint x;
|
uint x = 0;
|
||||||
uint y;
|
uint y = 0;
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
struct Output {
|
struct Output {
|
||||||
|
@ -82,21 +82,21 @@ private:
|
||||||
uint8 cram[0x40]; //MS = 0x20, GG = 0x40
|
uint8 cram[0x40]; //MS = 0x20, GG = 0x40
|
||||||
|
|
||||||
struct IO {
|
struct IO {
|
||||||
uint vcounter; //vertical counter
|
uint vcounter = 0; //vertical counter
|
||||||
uint hcounter; //horizontal counter
|
uint hcounter = 0; //horizontal counter
|
||||||
uint lcounter; //line counter
|
uint lcounter = 0; //line counter
|
||||||
|
|
||||||
//interrupt flags
|
//interrupt flags
|
||||||
bool intLine;
|
bool intLine = 0;
|
||||||
bool intFrame;
|
bool intFrame = 0;
|
||||||
|
|
||||||
//status flags
|
//status flags
|
||||||
bool spriteOverflow;
|
bool spriteOverflow = 0;
|
||||||
bool spriteCollision;
|
bool spriteCollision = 0;
|
||||||
uint5 fifthSprite;
|
uint5 fifthSprite;
|
||||||
|
|
||||||
//latches
|
//latches
|
||||||
bool controlLatch;
|
bool controlLatch = 0;
|
||||||
uint16 controlData;
|
uint16 controlData;
|
||||||
uint2 code;
|
uint2 code;
|
||||||
uint14 address;
|
uint14 address;
|
||||||
|
@ -104,22 +104,22 @@ private:
|
||||||
uint8 vramLatch;
|
uint8 vramLatch;
|
||||||
|
|
||||||
//$00 mode control 1
|
//$00 mode control 1
|
||||||
bool externalSync;
|
bool externalSync = 0;
|
||||||
bool extendedHeight;
|
bool extendedHeight = 0;
|
||||||
bool mode4;
|
bool mode4 = 0;
|
||||||
bool spriteShift;
|
bool spriteShift = 0;
|
||||||
bool lineInterrupts;
|
bool lineInterrupts = 0;
|
||||||
bool leftClip;
|
bool leftClip = 0;
|
||||||
bool horizontalScrollLock;
|
bool horizontalScrollLock = 0;
|
||||||
bool verticalScrollLock;
|
bool verticalScrollLock = 0;
|
||||||
|
|
||||||
//$01 mode control 2
|
//$01 mode control 2
|
||||||
bool spriteDouble;
|
bool spriteDouble = 0;
|
||||||
bool spriteTile;
|
bool spriteTile = 0;
|
||||||
bool lines240;
|
bool lines240 = 0;
|
||||||
bool lines224;
|
bool lines224 = 0;
|
||||||
bool frameInterrupts;
|
bool frameInterrupts = 0;
|
||||||
bool displayEnable;
|
bool displayEnable = 0;
|
||||||
|
|
||||||
//$02 name table base address
|
//$02 name table base address
|
||||||
uint1 nameTableMask;
|
uint1 nameTableMask;
|
||||||
|
|
|
@ -36,9 +36,9 @@ auto CPU::power() -> void {
|
||||||
r.pc.byte(1) = read(0x00, 0x1fff);
|
r.pc.byte(1) = read(0x00, 0x1fff);
|
||||||
|
|
||||||
for(auto& byte : ram) byte = 0x00;
|
for(auto& byte : ram) byte = 0x00;
|
||||||
memory::fill(&irq, sizeof(IRQ));
|
irq = {};
|
||||||
memory::fill(&timer, sizeof(Timer));
|
timer = {};
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto CPU::lastCycle() -> void {
|
auto CPU::lastCycle() -> void {
|
||||||
|
|
|
@ -36,11 +36,11 @@ private:
|
||||||
auto poll() -> void;
|
auto poll() -> void;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool disableExternal;
|
bool disableExternal = 0;
|
||||||
bool disableVDC;
|
bool disableVDC = 0;
|
||||||
bool disableTimer;
|
bool disableTimer = 0;
|
||||||
|
|
||||||
bool pendingIRQ;
|
bool pendingIRQ = 0;
|
||||||
uint16 pendingVector;
|
uint16 pendingVector;
|
||||||
|
|
||||||
friend class CPU;
|
friend class CPU;
|
||||||
|
@ -54,12 +54,12 @@ private:
|
||||||
auto step(uint clocks) -> void;
|
auto step(uint clocks) -> void;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool enable;
|
bool enable = 0;
|
||||||
uint7 latch;
|
uint7 latch;
|
||||||
uint7 value;
|
uint7 value;
|
||||||
uint clock;
|
uint clock = 0;
|
||||||
|
|
||||||
bool line;
|
bool line = 0;
|
||||||
|
|
||||||
friend class CPU;
|
friend class CPU;
|
||||||
} timer;
|
} timer;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
auto PSG::Channel::power(uint id) -> void {
|
auto PSG::Channel::power(uint id) -> void {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PSG::Channel::run() -> void {
|
auto PSG::Channel::run() -> void {
|
||||||
|
|
|
@ -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::First, Emulator::Filter::Type::HighPass, 20.0);
|
||||||
stream->addFilter(Emulator::Filter::Order::Second, Emulator::Filter::Type::LowPass, 20000.0, 3);
|
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);
|
for(auto C : range(6)) channel[C].power(C);
|
||||||
|
|
||||||
double level = 32767.0 / 6.0 / 32.0; //max volume / channels / steps
|
double level = 32767.0 / 6.0 / 32.0; //max volume / channels / steps
|
||||||
|
|
|
@ -61,10 +61,9 @@ auto VCE::power() -> void {
|
||||||
create(VCE::Enter, system.colorburst() * 6.0);
|
create(VCE::Enter, system.colorburst() * 6.0);
|
||||||
|
|
||||||
for(auto& pixel : buffer) pixel = 0;
|
for(auto& pixel : buffer) pixel = 0;
|
||||||
memory::fill(&cram, sizeof(CRAM));
|
cram = {};
|
||||||
memory::fill(&timing, sizeof(Timing));
|
timing = {};
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
io.clock = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,14 @@ private:
|
||||||
} cram;
|
} cram;
|
||||||
|
|
||||||
struct Timing {
|
struct Timing {
|
||||||
uint hclock;
|
uint hclock = 0;
|
||||||
uint vclock;
|
uint vclock = 0;
|
||||||
} timing;
|
} timing;
|
||||||
|
|
||||||
struct IO {
|
struct IO {
|
||||||
uint clock;
|
uint clock = 4;
|
||||||
bool extraLine;
|
bool extraLine = 0;
|
||||||
bool grayscale;
|
bool grayscale = 0;
|
||||||
} io;
|
} io;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -99,13 +99,13 @@ auto VDC::power() -> void {
|
||||||
create(VDC::Enter, system.colorburst() * 6.0);
|
create(VDC::Enter, system.colorburst() * 6.0);
|
||||||
|
|
||||||
memory::fill(&vram, sizeof(VRAM));
|
memory::fill(&vram, sizeof(VRAM));
|
||||||
memory::fill(&satb, sizeof(SATB));
|
satb = {};
|
||||||
memory::fill(&timing, sizeof(Timing));
|
timing = {};
|
||||||
memory::fill(&irq, sizeof(IRQ));
|
irq = {};
|
||||||
memory::fill(&dma, sizeof(DMA));
|
dma = {};
|
||||||
memory::fill(&io, sizeof(IO));
|
io = {};
|
||||||
memory::fill(&background, sizeof(Background));
|
background = {};
|
||||||
memory::fill(&sprite, sizeof(Sprite));
|
sprite = {};
|
||||||
|
|
||||||
dma.vdc = this;
|
dma.vdc = this;
|
||||||
background.vdc = this;
|
background.vdc = this;
|
||||||
|
|
|
@ -56,20 +56,20 @@ private:
|
||||||
uint9 verticalDisplayLength;
|
uint9 verticalDisplayLength;
|
||||||
uint8 verticalDisplayEnd;
|
uint8 verticalDisplayEnd;
|
||||||
|
|
||||||
bool vpulse;
|
bool vpulse = 0;
|
||||||
bool hpulse;
|
bool hpulse = 0;
|
||||||
|
|
||||||
uint hclock;
|
uint hclock = 0;
|
||||||
uint vclock;
|
uint vclock = 0;
|
||||||
|
|
||||||
uint hoffset;
|
uint hoffset = 0;
|
||||||
uint voffset;
|
uint voffset = 0;
|
||||||
|
|
||||||
uint hstart;
|
uint hstart = 0;
|
||||||
uint vstart;
|
uint vstart = 0;
|
||||||
|
|
||||||
uint hlength;
|
uint hlength = 0;
|
||||||
uint vlength;
|
uint vlength = 0;
|
||||||
} timing;
|
} timing;
|
||||||
|
|
||||||
struct IRQ {
|
struct IRQ {
|
||||||
|
@ -87,21 +87,21 @@ private:
|
||||||
auto raise(Line) -> void;
|
auto raise(Line) -> void;
|
||||||
auto lower() -> void;
|
auto lower() -> void;
|
||||||
|
|
||||||
bool enableCollision;
|
bool enableCollision = 0;
|
||||||
bool enableOverflow;
|
bool enableOverflow = 0;
|
||||||
bool enableLineCoincidence;
|
bool enableLineCoincidence = 0;
|
||||||
bool enableVblank;
|
bool enableVblank = 0;
|
||||||
bool enableTransferVRAM;
|
bool enableTransferVRAM = 0;
|
||||||
bool enableTransferSATB;
|
bool enableTransferSATB = 0;
|
||||||
|
|
||||||
bool pendingCollision;
|
bool pendingCollision = 0;
|
||||||
bool pendingOverflow;
|
bool pendingOverflow = 0;
|
||||||
bool pendingLineCoincidence;
|
bool pendingLineCoincidence = 0;
|
||||||
bool pendingVblank;
|
bool pendingVblank = 0;
|
||||||
bool pendingTransferVRAM;
|
bool pendingTransferVRAM = 0;
|
||||||
bool pendingTransferSATB;
|
bool pendingTransferSATB = 0;
|
||||||
|
|
||||||
bool line;
|
bool line = 0;
|
||||||
} irq;
|
} irq;
|
||||||
|
|
||||||
struct DMA {
|
struct DMA {
|
||||||
|
@ -113,17 +113,17 @@ private:
|
||||||
auto satbStart() -> void;
|
auto satbStart() -> void;
|
||||||
auto satbQueue() -> void;
|
auto satbQueue() -> void;
|
||||||
|
|
||||||
bool sourceIncrementMode;
|
bool sourceIncrementMode = 0;
|
||||||
bool targetIncrementMode;
|
bool targetIncrementMode = 0;
|
||||||
bool satbRepeat;
|
bool satbRepeat = 0;
|
||||||
uint16 source;
|
uint16 source;
|
||||||
uint16 target;
|
uint16 target;
|
||||||
uint16 length;
|
uint16 length;
|
||||||
uint16 satbSource;
|
uint16 satbSource;
|
||||||
|
|
||||||
bool vramActive;
|
bool vramActive = 0;
|
||||||
bool satbActive;
|
bool satbActive = 0;
|
||||||
bool satbPending;
|
bool satbPending = 0;
|
||||||
uint16 satbOffset;
|
uint16 satbOffset;
|
||||||
} dma;
|
} dma;
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ private:
|
||||||
auto scanline(uint y) -> void;
|
auto scanline(uint y) -> void;
|
||||||
auto run(uint x, uint y) -> void;
|
auto run(uint x, uint y) -> void;
|
||||||
|
|
||||||
bool enable;
|
bool enable = 0;
|
||||||
uint10 hscroll;
|
uint10 hscroll;
|
||||||
uint9 vscroll;
|
uint9 vscroll;
|
||||||
uint9 vcounter;
|
uint9 vcounter;
|
||||||
|
@ -155,26 +155,26 @@ private:
|
||||||
auto scanline(uint y) -> void;
|
auto scanline(uint y) -> void;
|
||||||
auto run(uint x, uint y) -> void;
|
auto run(uint x, uint y) -> void;
|
||||||
|
|
||||||
bool enable;
|
bool enable = 0;
|
||||||
|
|
||||||
struct Object {
|
struct Object {
|
||||||
uint10 y;
|
uint10 y;
|
||||||
uint10 x;
|
uint10 x;
|
||||||
bool mode;
|
bool mode = 0;
|
||||||
uint10 pattern;
|
uint10 pattern;
|
||||||
uint4 palette;
|
uint4 palette;
|
||||||
bool priority;
|
bool priority = 0;
|
||||||
uint width;
|
uint width = 0;
|
||||||
bool hflip;
|
bool hflip = 0;
|
||||||
uint height;
|
uint height = 0;
|
||||||
bool vflip;
|
bool vflip = 0;
|
||||||
bool first;
|
bool first = 0;
|
||||||
};
|
};
|
||||||
array<Object, 64> objects;
|
array<Object, 64> objects;
|
||||||
|
|
||||||
uint4 color;
|
uint4 color;
|
||||||
uint4 palette;
|
uint4 palette;
|
||||||
bool priority;
|
bool priority = 0;
|
||||||
} sprite;
|
} sprite;
|
||||||
|
|
||||||
struct IO {
|
struct IO {
|
||||||
|
@ -183,7 +183,7 @@ private:
|
||||||
//$0005 CR (W)
|
//$0005 CR (W)
|
||||||
uint2 externalSync;
|
uint2 externalSync;
|
||||||
uint2 displayOutput;
|
uint2 displayOutput;
|
||||||
bool dramRefresh;
|
bool dramRefresh = 0;
|
||||||
|
|
||||||
//$0006 RCR
|
//$0006 RCR
|
||||||
uint10 lineCoincidence;
|
uint10 lineCoincidence;
|
||||||
|
@ -191,7 +191,7 @@ private:
|
||||||
//$0009 MWR
|
//$0009 MWR
|
||||||
uint2 vramAccess;
|
uint2 vramAccess;
|
||||||
uint2 spriteAccess;
|
uint2 spriteAccess;
|
||||||
bool cgMode;
|
bool cgMode = 0;
|
||||||
} io;
|
} io;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -234,16 +234,9 @@ auto DSP::power(bool reset) -> void {
|
||||||
|
|
||||||
if(!reset) random.array(apuram, sizeof(apuram));
|
if(!reset) random.array(apuram, sizeof(apuram));
|
||||||
|
|
||||||
memory::fill(&state, sizeof(State));
|
state = {};
|
||||||
state.noise = 0x4000;
|
|
||||||
state.echoHistoryOffset = 0;
|
|
||||||
state.everyOtherSample = 1;
|
|
||||||
state.echoOffset = 0;
|
|
||||||
state.counter = 0;
|
|
||||||
|
|
||||||
for(auto n : range(8)) {
|
for(auto n : range(8)) {
|
||||||
memory::fill(&voice[n], sizeof(Voice));
|
voice[n] = {};
|
||||||
voice[n].brrOffset = 1;
|
|
||||||
voice[n].vbit = 1 << n;
|
voice[n].vbit = 1 << n;
|
||||||
voice[n].vidx = n * 0x10;
|
voice[n].vidx = n * 0x10;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,66 +54,66 @@ private:
|
||||||
struct State {
|
struct State {
|
||||||
uint8 regs[128];
|
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;
|
uint3 echoHistoryOffset;
|
||||||
|
|
||||||
bool everyOtherSample; //toggles every sample
|
bool everyOtherSample = 1; //toggles every sample
|
||||||
int kon; //KON value when last checked
|
int kon = 0; //KON value when last checked
|
||||||
int noise;
|
int noise = 0x4000;
|
||||||
int counter;
|
int counter = 0;
|
||||||
int echoOffset; //offset from ESA in echo buffer
|
int echoOffset = 0; //offset from ESA in echo buffer
|
||||||
int echoLength; //number of bytes that echo_offset will stop at
|
int echoLength = 0; //number of bytes that echo_offset will stop at
|
||||||
|
|
||||||
//hidden registers also written to when main register is written to
|
//hidden registers also written to when main register is written to
|
||||||
int konBuffer;
|
int konBuffer = 0;
|
||||||
int endxBuffer;
|
int endxBuffer = 0;
|
||||||
int envxBuffer;
|
int envxBuffer = 0;
|
||||||
int outxBuffer;
|
int outxBuffer = 0;
|
||||||
|
|
||||||
//temporary state between clocks (prefixed with _)
|
//temporary state between clocks (prefixed with _)
|
||||||
|
|
||||||
//read once per sample
|
//read once per sample
|
||||||
int _pmon;
|
int _pmon = 0;
|
||||||
int _non;
|
int _non = 0;
|
||||||
int _eon;
|
int _eon = 0;
|
||||||
int _dir;
|
int _dir = 0;
|
||||||
int _koff;
|
int _koff = 0;
|
||||||
|
|
||||||
//read a few clocks ahead before used
|
//read a few clocks ahead before used
|
||||||
int _brrNextAddress;
|
int _brrNextAddress = 0;
|
||||||
int _adsr0;
|
int _adsr0 = 0;
|
||||||
int _brrHeader;
|
int _brrHeader = 0;
|
||||||
int _brrByte;
|
int _brrByte = 0;
|
||||||
int _srcn;
|
int _srcn = 0;
|
||||||
int _esa;
|
int _esa = 0;
|
||||||
int _echoDisabled;
|
int _echoDisabled = 0;
|
||||||
|
|
||||||
//internal state that is recalculated every sample
|
//internal state that is recalculated every sample
|
||||||
int _dirAddress;
|
int _dirAddress = 0;
|
||||||
int _pitch;
|
int _pitch = 0;
|
||||||
int _output;
|
int _output = 0;
|
||||||
int _looped;
|
int _looped = 0;
|
||||||
int _echoPointer;
|
int _echoPointer = 0;
|
||||||
|
|
||||||
//left/right sums
|
//left/right sums
|
||||||
int _mainOut[2];
|
int _mainOut[2] = {};
|
||||||
int _echoOut[2];
|
int _echoOut[2] = {};
|
||||||
int _echoIn [2];
|
int _echoIn [2] = {};
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
struct Voice {
|
struct Voice {
|
||||||
int buffer[12 * 3]; //12 decoded samples (mirrored for wrapping)
|
int buffer[12 * 3] = {}; //12 decoded samples (mirrored for wrapping)
|
||||||
int bufferOffset; //place in buffer where next samples will be decoded
|
int bufferOffset = 0; //place in buffer where next samples will be decoded
|
||||||
int gaussianOffset; //relative fractional position in sample (0x1000 = 1.0)
|
int gaussianOffset = 0; //relative fractional position in sample (0x1000 = 1.0)
|
||||||
int brrAddress; //address of current BRR block
|
int brrAddress = 0; //address of current BRR block
|
||||||
int brrOffset; //current decoding offset in BRR block
|
int brrOffset = 1; //current decoding offset in BRR block
|
||||||
int vbit; //bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc
|
int vbit = 0; //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 vidx = 0; //voice channel register index: 0x00 for voice 0, 0x10 for voice 1, etc
|
||||||
int konDelay; //KON delay/current setup phase
|
int konDelay = 0; //KON delay/current setup phase
|
||||||
int envelopeMode;
|
int envelopeMode = 0;
|
||||||
int envelope; //current envelope level
|
int envelope = 0; //current envelope level
|
||||||
int hiddenEnvelope; //used by GAIN mode 7, very obscure quirk
|
int hiddenEnvelope = 0; //used by GAIN mode 7, very obscure quirk
|
||||||
int _envxOut;
|
int _envxOut = 0;
|
||||||
} voice[8];
|
} voice[8];
|
||||||
|
|
||||||
//gaussian.cpp
|
//gaussian.cpp
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace SuperFamicom {
|
||||||
|
|
||||||
Satellaview::Satellaview() {
|
Satellaview::Satellaview() {
|
||||||
bus.map({&Satellaview::read, this}, {&Satellaview::write, this}, "00-3f,80-bf:2188-219f");
|
bus.map({&Satellaview::read, this}, {&Satellaview::write, this}, "00-3f,80-bf:2188-219f");
|
||||||
memory::fill(®s, sizeof regs);
|
regs = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Satellaview::~Satellaview() {
|
Satellaview::~Satellaview() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ auto MappedRAM::reset() -> void {
|
||||||
auto MappedRAM::allocate(uint size) -> void {
|
auto MappedRAM::allocate(uint size) -> void {
|
||||||
reset();
|
reset();
|
||||||
_data = new uint8[_size = size];
|
_data = new uint8[_size = size];
|
||||||
memory::fill(_data, _size, 0xff);
|
memory::fill<uint8>(_data, _size, 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MappedRAM::writeProtect(bool writeProtect) -> void { _writeProtect = writeProtect; }
|
auto MappedRAM::writeProtect(bool writeProtect) -> void { _writeProtect = writeProtect; }
|
||||||
|
|
|
@ -87,7 +87,7 @@ auto PPU::load(Markup::Node node) -> bool {
|
||||||
auto PPU::power(bool reset) -> void {
|
auto PPU::power(bool reset) -> void {
|
||||||
create(Enter, system.cpuFrequency());
|
create(Enter, system.cpuFrequency());
|
||||||
PPUcounter::reset();
|
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) -> uint8> reader{&PPU::readIO, this};
|
||||||
function<auto (uint24, uint8) -> void> writer{&PPU::writeIO, this};
|
function<auto (uint24, uint8) -> void> writer{&PPU::writeIO, this};
|
||||||
|
|
|
@ -90,7 +90,7 @@ auto PPU::load(Markup::Node node) -> bool {
|
||||||
auto PPU::power(bool reset) -> void {
|
auto PPU::power(bool reset) -> void {
|
||||||
create(Enter, system.cpuFrequency());
|
create(Enter, system.cpuFrequency());
|
||||||
PPUcounter::reset();
|
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) -> uint8> reader{&PPU::readIO, this};
|
||||||
function<auto (uint24, uint8) -> void> writer{&PPU::writeIO, this};
|
function<auto (uint24, uint8) -> void> writer{&PPU::writeIO, this};
|
||||||
|
|
|
@ -176,7 +176,7 @@ auto Presentation::drawIcon(uint32_t* output, uint length, uint width, uint heig
|
||||||
for(uint y : range(128)) {
|
for(uint y : range(128)) {
|
||||||
auto target = output + (y + oy) * (length >> 2) + ox;
|
auto target = output + (y + oy) * (length >> 2) + ox;
|
||||||
auto source = (uint32_t*)icon.data() + y * 128;
|
auto source = (uint32_t*)icon.data() + y * 128;
|
||||||
memory::copy(target, source, 128 * sizeof(uint32_t));
|
memory::copy<uint32_t>(target, source, 128);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ auto Program::videoRefresh(const uint32* data, uint pitch, uint width, uint heig
|
||||||
length >>= 2;
|
length >>= 2;
|
||||||
|
|
||||||
for(auto y : range(height)) {
|
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();
|
video->unlock();
|
||||||
|
|
|
@ -214,7 +214,7 @@ auto Presentation::drawIcon(uint32_t* output, uint length, uint width, uint heig
|
||||||
for(uint y : range(112)) {
|
for(uint y : range(112)) {
|
||||||
auto target = output + (y + oy) * (length >> 2) + ox;
|
auto target = output + (y + oy) * (length >> 2) + ox;
|
||||||
auto source = (uint32_t*)icon.data() + y * 112;
|
auto source = (uint32_t*)icon.data() + y * 112;
|
||||||
memory::copy(target, source, 112 * sizeof(uint32_t));
|
memory::copy<uint32_t>(target, source, 112);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ auto Program::videoRefresh(const uint32* data, uint pitch, uint width, uint heig
|
||||||
length >>= 2;
|
length >>= 2;
|
||||||
|
|
||||||
for(auto y : range(height)) {
|
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();
|
video->unlock();
|
||||||
|
|
|
@ -33,12 +33,7 @@ auto Cartridge::power() -> void {
|
||||||
if(rtc.data) bus.map(this, 0x00ca, 0x00cb);
|
if(rtc.data) bus.map(this, 0x00ca, 0x00cb);
|
||||||
bus.map(this, 0x00cc, 0x00cd);
|
bus.map(this, 0x00cc, 0x00cd);
|
||||||
|
|
||||||
memory::fill(&r, sizeof(Registers));
|
r = {};
|
||||||
|
|
||||||
r.romBank0 = 0xff;
|
|
||||||
r.romBank1 = 0xff;
|
|
||||||
r.romBank2 = 0xff;
|
|
||||||
r.sramBank = 0xff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Cartridge::load() -> bool {
|
auto Cartridge::load() -> bool {
|
||||||
|
@ -72,7 +67,7 @@ auto Cartridge::load() -> bool {
|
||||||
rom.size = memory.size;
|
rom.size = memory.size;
|
||||||
rom.mask = bit::round(rom.size) - 1;
|
rom.mask = bit::round(rom.size) - 1;
|
||||||
rom.data = new uint8[rom.mask + 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)) {
|
if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Required)) {
|
||||||
fp->read(rom.data, rom.size);
|
fp->read(rom.data, rom.size);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +77,7 @@ auto Cartridge::load() -> bool {
|
||||||
ram.size = memory.size;
|
ram.size = memory.size;
|
||||||
ram.mask = bit::round(ram.size) - 1;
|
ram.mask = bit::round(ram.size) - 1;
|
||||||
ram.data = new uint8[ram.mask + 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(memory.nonVolatile) {
|
||||||
if(auto fp = platform->open(pathID(), memory.name(), File::Read)) {
|
if(auto fp = platform->open(pathID(), memory.name(), File::Read)) {
|
||||||
fp->read(ram.data, ram.size);
|
fp->read(ram.data, ram.size);
|
||||||
|
@ -102,7 +97,7 @@ auto Cartridge::load() -> bool {
|
||||||
rtc.size = memory.size;
|
rtc.size = memory.size;
|
||||||
rtc.mask = bit::round(rtc.size) - 1;
|
rtc.mask = bit::round(rtc.size) - 1;
|
||||||
rtc.data = new uint8[rtc.mask + 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(memory.nonVolatile) {
|
||||||
if(auto fp = platform->open(pathID(), memory.name(), File::Read)) {
|
if(auto fp = platform->open(pathID(), memory.name(), File::Read)) {
|
||||||
fp->read(rtc.data, rtc.size);
|
fp->read(rtc.data, rtc.size);
|
||||||
|
|
|
@ -44,16 +44,16 @@ struct Cartridge : Thread, IO {
|
||||||
|
|
||||||
struct Registers {
|
struct Registers {
|
||||||
//$00c0 BANK_ROM2
|
//$00c0 BANK_ROM2
|
||||||
uint8 romBank2;
|
uint8 romBank2 = 0xff;
|
||||||
|
|
||||||
//$00c1 BANK_SRAM
|
//$00c1 BANK_SRAM
|
||||||
uint8 sramBank;
|
uint8 sramBank = 0xff;
|
||||||
|
|
||||||
//$00c2 BANK_ROM0
|
//$00c2 BANK_ROM0
|
||||||
uint8 romBank0;
|
uint8 romBank0 = 0xff;
|
||||||
|
|
||||||
//$00c3 BANK_ROM1
|
//$00c3 BANK_ROM1
|
||||||
uint8 romBank1;
|
uint8 romBank1 = 0xff;
|
||||||
|
|
||||||
//$00cc GPO_EN
|
//$00cc GPO_EN
|
||||||
uint8 gpoEnable;
|
uint8 gpoEnable;
|
||||||
|
|
|
@ -56,7 +56,7 @@ auto CPU::power() -> void {
|
||||||
bus.map(this, 0x0062);
|
bus.map(this, 0x0062);
|
||||||
}
|
}
|
||||||
|
|
||||||
memory::fill(&r, sizeof(Registers));
|
r = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,13 +95,9 @@ auto PPU::power() -> void {
|
||||||
bus.map(this, 0x00a4, 0x00ab);
|
bus.map(this, 0x00a4, 0x00ab);
|
||||||
|
|
||||||
for(auto& n : output) n = 0;
|
for(auto& n : output) n = 0;
|
||||||
memory::fill(&s, sizeof(State));
|
s = {};
|
||||||
memory::fill(&l, sizeof(Latches));
|
l = {};
|
||||||
memory::fill(&r, sizeof(Registers));
|
r = {};
|
||||||
|
|
||||||
r.lcdEnable = 1;
|
|
||||||
r.vtotal = 158;
|
|
||||||
r.vblank = 155;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@ struct PPU : Thread, IO {
|
||||||
uint32 output[224 * 144];
|
uint32 output[224 * 144];
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
bool field;
|
bool field = 0;
|
||||||
uint vclk;
|
uint vclk = 0;
|
||||||
uint hclk;
|
uint hclk = 0;
|
||||||
Pixel pixel;
|
Pixel pixel;
|
||||||
} s;
|
} s;
|
||||||
|
|
||||||
|
@ -73,11 +73,11 @@ struct PPU : Thread, IO {
|
||||||
|
|
||||||
//latchSprites()
|
//latchSprites()
|
||||||
uint32 sprite[32];
|
uint32 sprite[32];
|
||||||
uint spriteCount;
|
uint spriteCount = 0;
|
||||||
|
|
||||||
//latchOAM()
|
//latchOAM()
|
||||||
uint32 oam[2][128];
|
uint32 oam[2][128];
|
||||||
uint oamCount;
|
uint oamCount = 0;
|
||||||
} l;
|
} l;
|
||||||
|
|
||||||
struct Registers {
|
struct Registers {
|
||||||
|
@ -145,7 +145,7 @@ struct PPU : Thread, IO {
|
||||||
uint8 scrollTwoY;
|
uint8 scrollTwoY;
|
||||||
|
|
||||||
//$0014 LCD_CTRL
|
//$0014 LCD_CTRL
|
||||||
uint1 lcdEnable;
|
uint1 lcdEnable = 1;
|
||||||
uint1 lcdContrast; //WSC only
|
uint1 lcdContrast; //WSC only
|
||||||
uint6 lcdUnknown;
|
uint6 lcdUnknown;
|
||||||
|
|
||||||
|
@ -158,10 +158,10 @@ struct PPU : Thread, IO {
|
||||||
uint1 iconAux3;
|
uint1 iconAux3;
|
||||||
|
|
||||||
//$0016 LCD_VTOTAL
|
//$0016 LCD_VTOTAL
|
||||||
uint8 vtotal;
|
uint8 vtotal = 158;
|
||||||
|
|
||||||
//$0017 LCD_VBLANK
|
//$0017 LCD_VBLANK
|
||||||
uint8 vblank;
|
uint8 vblank = 155;
|
||||||
|
|
||||||
//$001c-001f PALMONO_POOL
|
//$001c-001f PALMONO_POOL
|
||||||
uint4 pool[8];
|
uint4 pool[8];
|
||||||
|
|
|
@ -5,14 +5,14 @@ auto Video::refresh() -> void {
|
||||||
auto& palette = settings.colorEmulation ? paletteEmulation : paletteStandard;
|
auto& palette = settings.colorEmulation ? paletteEmulation : paletteStandard;
|
||||||
|
|
||||||
if(system.orientation() == 0) {
|
if(system.orientation() == 0) {
|
||||||
for(uint y = 0; y < 224; y++) {
|
for(uint y : range(224)) {
|
||||||
auto target = output() + y * 224;
|
auto target = output() + y * 224;
|
||||||
if(y < 40 || y >= 184) {
|
if(y < 40 || y >= 184) {
|
||||||
memory::fill(target, 224 * sizeof(uint32));
|
memory::fill<uint32>(target, 224);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto source = ppu.output + (y - 40) * 224;
|
auto source = ppu.output + (y - 40) * 224;
|
||||||
for(uint x = 0; x < 224; x++) {
|
for(uint x : range(224)) {
|
||||||
auto color = palette[*source++];
|
auto color = palette[*source++];
|
||||||
if(settings.blurEmulation) {
|
if(settings.blurEmulation) {
|
||||||
auto a = color, b = *target;
|
auto a = color, b = *target;
|
||||||
|
@ -25,12 +25,12 @@ auto Video::refresh() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(system.orientation() == 1) {
|
if(system.orientation() == 1) {
|
||||||
for(uint y = 0; y < 224; y++) {
|
for(uint y : range(224)) {
|
||||||
auto target = output() + y * 224;
|
auto target = output() + y * 224;
|
||||||
memory::fill(target, 40 * sizeof(uint32));
|
memory::fill<uint32>(target, 40);
|
||||||
memory::fill(target + 184, 40 * sizeof(uint32));
|
memory::fill<uint32>(target + 184, 40);
|
||||||
target += 40;
|
target += 40;
|
||||||
for(uint x = 0; x < 144; x++) {
|
for(uint x : range(144)) {
|
||||||
auto source = ppu.output + x * 224 + (223 - y);
|
auto source = ppu.output + x * 224 + (223 - y);
|
||||||
auto color = palette[*source];
|
auto color = palette[*source];
|
||||||
if(settings.blurEmulation) {
|
if(settings.blurEmulation) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ auto NSMakeImage(image icon, uint scaleWidth = 0, uint scaleHeight = 0) -> NSIma
|
||||||
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
|
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
|
||||||
bytesPerRow:(4 * icon.width()) bitsPerPixel:32
|
bytesPerRow:(4 * icon.width()) bitsPerPixel:32
|
||||||
] autorelease];
|
] 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];
|
[cocoaImage addRepresentation:bitmap];
|
||||||
return cocoaImage;
|
return cocoaImage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ auto pCanvas::_rasterize() -> void {
|
||||||
auto buffer = (uint32_t*)gdk_pixbuf_get_pixels(surface);
|
auto buffer = (uint32_t*)gdk_pixbuf_get_pixels(surface);
|
||||||
|
|
||||||
if(auto& icon = state().icon) {
|
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) {
|
} else if(auto& gradient = state().gradient) {
|
||||||
auto& colors = gradient.state.colors;
|
auto& colors = gradient.state.colors;
|
||||||
image fill;
|
image fill;
|
||||||
|
|
|
@ -69,7 +69,7 @@ auto pCanvas::_rasterize() -> void {
|
||||||
auto buffer = (uint32_t*)qtImage->bits();
|
auto buffer = (uint32_t*)qtImage->bits();
|
||||||
|
|
||||||
if(auto& icon = state().icon) {
|
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) {
|
} else if(auto& gradient = state().gradient) {
|
||||||
auto& colors = gradient.state.colors;
|
auto& colors = gradient.state.colors;
|
||||||
image fill;
|
image fill;
|
||||||
|
|
|
@ -155,7 +155,7 @@ auto pCanvas::_rasterize() -> void {
|
||||||
pixels.resize(width * height);
|
pixels.resize(width * height);
|
||||||
|
|
||||||
if(auto& icon = state().icon) {
|
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) {
|
} else if(auto& gradient = state().gradient) {
|
||||||
auto& colors = gradient.state.colors;
|
auto& colors = gradient.state.colors;
|
||||||
image fill;
|
image fill;
|
||||||
|
|
|
@ -88,9 +88,9 @@ endif
|
||||||
|
|
||||||
# windows settings
|
# windows settings
|
||||||
ifeq ($(platform),windows)
|
ifeq ($(platform),windows)
|
||||||
link += -lws2_32 -lole32
|
link += -mthreads -lpthread -lws2_32 -lole32
|
||||||
link += $(if $(findstring $(compiler),g++),-static-libgcc -static-libstdc++)
|
link += $(if $(findstring g++,$(compiler)),-static -static-libgcc -static-libstdc++)
|
||||||
link += $(if $(findstring $(console),true),-mconsole,-mwindows)
|
link += $(if $(findstring true,$(console)),-mconsole,-mwindows)
|
||||||
windres := windres
|
windres := windres
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -65,15 +65,15 @@ struct bpsmulti {
|
||||||
bpslinear patch;
|
bpslinear patch;
|
||||||
patch.source({sourcePath, targetName});
|
patch.source({sourcePath, targetName});
|
||||||
patch.target({targetPath, targetName});
|
patch.target({targetPath, targetName});
|
||||||
patch.create({Path::temp(), "temp.bps"});
|
patch.create({Path::temporary(), "temp.bps"});
|
||||||
} else {
|
} else {
|
||||||
bpsdelta patch;
|
bpsdelta patch;
|
||||||
patch.source({sourcePath, targetName});
|
patch.source({sourcePath, targetName});
|
||||||
patch.target({targetPath, 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());
|
writeNumber(buffer.size());
|
||||||
for(auto &byte : buffer) write(byte);
|
for(auto &byte : buffer) write(byte);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct bitvector {
|
||||||
|
|
||||||
auto operator=(const bitvector& source) -> bitvector& {
|
auto operator=(const bitvector& source) -> bitvector& {
|
||||||
bits = source.bits;
|
bits = source.bits;
|
||||||
pool = (uint8_t*)memory::resize(pool, bytes());
|
pool = memory::resize<uint8_t>(pool, bytes());
|
||||||
memory::copy(pool, source.pool, bytes());
|
memory::copy(pool, source.pool, bytes());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ struct bitvector {
|
||||||
uint from = bits;
|
uint from = bits;
|
||||||
bits = size;
|
bits = size;
|
||||||
for(uint n = size; n < from; n++) clear(n); //on reduce
|
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
|
for(uint n = from; n < size; n++) clear(n); //on expand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,11 +55,11 @@ struct bitvector {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto clear() -> void {
|
auto clear() -> void {
|
||||||
memory::fill(pool, bytes(), 0x00);
|
memory::fill<uint8_t>(pool, bytes(), 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto set() -> void {
|
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);
|
for(uint n = bits; n < bytes() * 8; n++) clear(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct Poly1305 {
|
||||||
r[0] = 0, r[1] = 0, r[2] = 0;
|
r[0] = 0, r[1] = 0, r[2] = 0;
|
||||||
h[0] = 0, h[1] = 0, h[2] = 0;
|
h[0] = 0, h[1] = 0, h[2] = 0;
|
||||||
pad[0] = 0, pad[1] = 0;
|
pad[0] = 0, pad[1] = 0;
|
||||||
memory::fill(buffer, 16);
|
memory::fill(buffer, sizeof(buffer));
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
return uint128_t(h1) << 64 | h0;
|
return uint128_t(h1) << 64 | h0;
|
||||||
|
|
|
@ -4,26 +4,26 @@
|
||||||
#include <nall/stdint.hpp>
|
#include <nall/stdint.hpp>
|
||||||
|
|
||||||
namespace nall { namespace memory {
|
namespace nall { namespace memory {
|
||||||
inline auto allocate(uint size) -> void*;
|
template<typename T = uint8_t> inline auto allocate(uint size) -> T*;
|
||||||
inline auto allocate(uint size, uint8_t data) -> void*;
|
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 free(void* target) -> void;
|
||||||
|
|
||||||
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, 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, const void* source, uint size) -> int;
|
||||||
|
|
||||||
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, 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, const void* source, uint size) -> int;
|
||||||
|
|
||||||
inline auto copy(void* target, uint capacity, const void* source, uint size) -> void*;
|
template<typename T = uint8_t> inline auto copy(void* target, uint capacity, const void* source, uint size) -> T*;
|
||||||
inline auto copy(void* target, const void* source, uint size) -> void*;
|
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*;
|
template<typename T = uint8_t> inline auto move(void* target, uint capacity, const void* source, uint size) -> T*;
|
||||||
inline auto move(void* target, const void* source, uint size) -> void*;
|
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> inline auto assign(T* target) -> void {}
|
||||||
template<typename T, typename U, typename... P> inline auto assign(T* target, const U& value, P&&... p) -> 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;
|
template<uint size, typename T = uint64_t> inline auto writem(void* target, T data) -> void;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
namespace nall {
|
namespace nall { namespace memory {
|
||||||
|
|
||||||
//implementation notes:
|
//implementation notes:
|
||||||
//memcmp, memcpy, memmove have terrible performance on small block sizes (FreeBSD 10.0-amd64)
|
//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,
|
//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
|
//this library hand-codes these functions instead. surprisingly, it's a substantial speedup
|
||||||
|
|
||||||
auto memory::allocate(uint size) -> void* {
|
template<typename T> auto allocate(uint size) -> T* {
|
||||||
return malloc(size);
|
return (T*)malloc(size * sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memory::allocate(uint size, uint8_t data) -> void* {
|
template<typename T> auto allocate(uint size, const T& value) -> T* {
|
||||||
auto result = malloc(size);
|
auto result = allocate<T>(size);
|
||||||
if(result) fill(result, size, data);
|
if(result) fill<T>(result, size, value);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memory::resize(void* target, uint size) -> void* {
|
template<typename T> auto resize(void* target, uint size) -> T* {
|
||||||
return realloc(target, size);
|
return (T*)realloc(target, size * sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memory::free(void* target) -> void {
|
auto free(void* target) -> void {
|
||||||
::free(target);
|
::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 t = (int8_t*)target;
|
||||||
auto s = (int8_t*)source;
|
auto s = (int8_t*)source;
|
||||||
auto l = min(capacity, size);
|
auto l = min(capacity, size) * sizeof(T);
|
||||||
while(l--) {
|
while(l--) {
|
||||||
auto x = *t++;
|
auto x = *t++;
|
||||||
auto y = *s++;
|
auto y = *s++;
|
||||||
|
@ -72,14 +72,14 @@ auto memory::compare(const void* target, uint capacity, const void* source, uint
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memory::compare(const void* target, const void* source, uint size) -> int {
|
template<typename T> auto compare(const void* target, const void* source, uint size) -> int {
|
||||||
return compare(target, size, source, size);
|
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 t = (int8_t*)target;
|
||||||
auto s = (int8_t*)source;
|
auto s = (int8_t*)source;
|
||||||
auto l = min(capacity, size);
|
auto l = min(capacity, size) * sizeof(T);
|
||||||
while(l--) {
|
while(l--) {
|
||||||
auto x = *t++;
|
auto x = *t++;
|
||||||
auto y = *s++;
|
auto y = *s++;
|
||||||
|
@ -90,26 +90,26 @@ auto memory::icompare(const void* target, uint capacity, const void* source, uin
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memory::icompare(const void* target, const void* source, uint size) -> int {
|
template<typename T> auto icompare(const void* target, const void* source, uint size) -> int {
|
||||||
return icompare(target, size, source, size);
|
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 t = (uint8_t*)target;
|
||||||
auto s = (uint8_t*)source;
|
auto s = (uint8_t*)source;
|
||||||
auto l = min(capacity, size);
|
auto l = min(capacity, size) * sizeof(T);
|
||||||
while(l--) *t++ = *s++;
|
while(l--) *t++ = *s++;
|
||||||
return target;
|
return (T*)target;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memory::copy(void* target, const void* source, uint size) -> void* {
|
template<typename T> auto copy(void* target, const void* source, uint size) -> T* {
|
||||||
return copy(target, size, source, size);
|
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 t = (uint8_t*)target;
|
||||||
auto s = (uint8_t*)source;
|
auto s = (uint8_t*)source;
|
||||||
auto l = min(capacity, size);
|
auto l = min(capacity, size) * sizeof(T);
|
||||||
if(t < s) {
|
if(t < s) {
|
||||||
while(l--) *t++ = *s++;
|
while(l--) *t++ = *s++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -117,47 +117,46 @@ auto memory::move(void* target, uint capacity, const void* source, uint size) ->
|
||||||
s += l;
|
s += l;
|
||||||
while(l--) *--t = *--s;
|
while(l--) *--t = *--s;
|
||||||
}
|
}
|
||||||
return target;
|
return (T*)target;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memory::move(void* target, const void* source, uint size) -> void* {
|
template<typename T> auto move(void* target, const void* source, uint size) -> T* {
|
||||||
return move(target, size, source, size);
|
return move<T>(target, size, source, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memory::fill(void* target, uint capacity, uint8_t data) -> void* {
|
template<typename T> auto fill(void* target, uint capacity, const T& value) -> T* {
|
||||||
auto t = (uint8_t*)target;
|
auto t = (T*)target;
|
||||||
while(capacity--) *t++ = data;
|
while(capacity--) *t++ = value;
|
||||||
return target;
|
return (T*)target;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename U, typename... P>
|
template<typename T, typename U, typename... P> auto assign(T* target, const U& value, P&&... p) -> void {
|
||||||
auto memory::assign(T* target, const U& value, P&&... p) -> void {
|
|
||||||
*target++ = value;
|
*target++ = value;
|
||||||
assign(target, forward<P>(p)...);
|
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;
|
auto p = (const uint8_t*)source;
|
||||||
T data = 0;
|
T data = 0;
|
||||||
for(uint n = 0; n < size; n++) data |= T(*p++) << n * 8;
|
for(uint n = 0; n < size; n++) data |= T(*p++) << n * 8;
|
||||||
return data;
|
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;
|
auto p = (const uint8_t*)source;
|
||||||
T data = 0;
|
T data = 0;
|
||||||
for(int n = size - 1; n >= 0; n--) data |= T(*p++) << n * 8;
|
for(int n = size - 1; n >= 0; n--) data |= T(*p++) << n * 8;
|
||||||
return data;
|
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;
|
auto p = (uint8_t*)target;
|
||||||
for(uint n = 0; n < size; n++) *p++ = data >> n * 8;
|
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;
|
auto p = (uint8_t*)target;
|
||||||
for(int n = size - 1; n >= 0; n--) *p++ = data >> n * 8;
|
for(int n = size - 1; n >= 0; n--) *p++ = data >> n * 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}}
|
||||||
|
|
|
@ -41,7 +41,7 @@ auto service::command(const string& name, const string& command) -> bool {
|
||||||
}
|
}
|
||||||
if(auto data = shared.acquire()) {
|
if(auto data = shared.acquire()) {
|
||||||
if(command == "stop") print("[{0}] stopped\n", string_format{name});
|
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();
|
shared.release();
|
||||||
}
|
}
|
||||||
if(command == "remove") {
|
if(command == "remove") {
|
||||||
|
|
|
@ -96,7 +96,7 @@ auto string::operator=(string&& source) -> type& {
|
||||||
auto string::_allocate() -> void {
|
auto string::_allocate() -> void {
|
||||||
char _temp[SSO];
|
char _temp[SSO];
|
||||||
memory::copy(_temp, _text, 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);
|
memory::copy(_data, _temp, SSO);
|
||||||
_refs = (uint*)(_data + _capacity + 1); //always aligned by 32 via reserve()
|
_refs = (uint*)(_data + _capacity + 1); //always aligned by 32 via reserve()
|
||||||
*_refs = 1;
|
*_refs = 1;
|
||||||
|
@ -104,7 +104,7 @@ auto string::_allocate() -> void {
|
||||||
|
|
||||||
//COW -> Unique
|
//COW -> Unique
|
||||||
auto string::_copy() -> void {
|
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));
|
memory::copy(_temp, _data, _size = min(_capacity, _size));
|
||||||
_temp[_size] = 0;
|
_temp[_size] = 0;
|
||||||
--*_refs;
|
--*_refs;
|
||||||
|
@ -115,7 +115,7 @@ auto string::_copy() -> void {
|
||||||
|
|
||||||
//COW -> Resize
|
//COW -> Resize
|
||||||
auto string::_resize() -> void {
|
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 = (uint*)(_data + _capacity + 1);
|
||||||
*_refs = 1;
|
*_refs = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ auto string::operator=(string&& source) -> string& {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto string::_allocate() -> char* {
|
auto string::_allocate() -> char* {
|
||||||
auto _temp = (char*)memory::allocate(_capacity + 1 + sizeof(uint));
|
auto _temp = memory::allocate<char>(_capacity + 1 + sizeof(uint));
|
||||||
*_temp = 0;
|
*_temp = 0;
|
||||||
_refs = (uint*)(_temp + _capacity + 1); //this will always be aligned by 32 via reserve()
|
_refs = (uint*)(_temp + _capacity + 1); //this will always be aligned by 32 via reserve()
|
||||||
*_refs = 1;
|
*_refs = 1;
|
||||||
|
@ -78,7 +78,7 @@ auto string::_allocate() -> char* {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto string::_copy() -> 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));
|
memory::copy(_temp, _data, _size = min(_capacity, _size));
|
||||||
_temp[_size] = 0;
|
_temp[_size] = 0;
|
||||||
--*_refs;
|
--*_refs;
|
||||||
|
|
|
@ -50,10 +50,10 @@ auto string::reserve(uint capacity) -> type& {
|
||||||
if(_capacity < SSO) {
|
if(_capacity < SSO) {
|
||||||
char _temp[SSO];
|
char _temp[SSO];
|
||||||
memory::copy(_temp, _text, 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);
|
memory::copy(_data, _temp, SSO);
|
||||||
} else {
|
} else {
|
||||||
_data = (char*)memory::resize(_data, _capacity = capacity + 1);
|
_data = memory::resize<char>(_data, _capacity = capacity + 1);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ auto string::operator=(const string& source) -> type& {
|
||||||
if(&source == this) return *this;
|
if(&source == this) return *this;
|
||||||
reset();
|
reset();
|
||||||
if(source._capacity >= SSO) {
|
if(source._capacity >= SSO) {
|
||||||
_data = (char*)memory::allocate(source._capacity + 1);
|
_data = memory::allocate<char>(source._capacity + 1);
|
||||||
_capacity = source._capacity;
|
_capacity = source._capacity;
|
||||||
_size = source._size;
|
_size = source._size;
|
||||||
memory::copy(_data, source._data, source._size + 1);
|
memory::copy(_data, source._data, source._size + 1);
|
||||||
|
|
|
@ -39,7 +39,7 @@ auto string::reset() -> type& {
|
||||||
auto string::reserve(uint capacity) -> type& {
|
auto string::reserve(uint capacity) -> type& {
|
||||||
if(capacity > _capacity) {
|
if(capacity > _capacity) {
|
||||||
_capacity = bit::round(capacity + 1) - 1;
|
_capacity = bit::round(capacity + 1) - 1;
|
||||||
_data = (char*)memory::resize(_data, _capacity + 1);
|
_data = memory::resize<char>(_data, _capacity + 1);
|
||||||
_data[_capacity] = 0;
|
_data[_capacity] = 0;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -54,7 +54,7 @@ auto string::resize(uint size) -> type& {
|
||||||
auto string::operator=(const string& source) -> type& {
|
auto string::operator=(const string& source) -> type& {
|
||||||
if(&source == this) return *this;
|
if(&source == this) return *this;
|
||||||
reset();
|
reset();
|
||||||
_data = (char*)memory::allocate(source._size + 1);
|
_data = memory::allocate<char>(source._size + 1);
|
||||||
_capacity = source._size;
|
_capacity = source._size;
|
||||||
_size = source._size;
|
_size = source._size;
|
||||||
memory::copy(_data, source.data(), source.size() + 1);
|
memory::copy(_data, source.data(), source.size() + 1);
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace nall {
|
||||||
|
|
||||||
auto string::format(const nall::string_format& params) -> type& {
|
auto string::format(const nall::string_format& params) -> type& {
|
||||||
auto size = (int)this->size();
|
auto size = (int)this->size();
|
||||||
auto data = (char*)memory::allocate(size);
|
auto data = memory::allocate<char>(size);
|
||||||
memory::copy(data, this->data(), size);
|
memory::copy(data, this->data(), size);
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace nall {
|
||||||
|
|
||||||
template<typename T> auto vector<T>::operator=(const vector<T>& source) -> vector<T>& {
|
template<typename T> auto vector<T>::operator=(const vector<T>& source) -> vector<T>& {
|
||||||
if(this == &source) return *this;
|
if(this == &source) return *this;
|
||||||
_pool = (T*)memory::allocate(sizeof(T) * source._size);
|
_pool = memory::allocate<T>(source._size);
|
||||||
_size = source._size;
|
_size = source._size;
|
||||||
_left = 0;
|
_left = 0;
|
||||||
_right = 0;
|
_right = 0;
|
||||||
|
|
|
@ -27,7 +27,7 @@ template<typename T> auto vector<T>::reserveLeft(uint capacity) -> bool {
|
||||||
if(_size + _left >= capacity) return false;
|
if(_size + _left >= capacity) return false;
|
||||||
|
|
||||||
uint left = bit::round(capacity);
|
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]));
|
for(uint n : range(_size)) new(pool + n) T(move(_pool[n]));
|
||||||
memory::free(_pool - _left);
|
memory::free(_pool - _left);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ template<typename T> auto vector<T>::reserveRight(uint capacity) -> bool {
|
||||||
if(_size + _right >= capacity) return false;
|
if(_size + _right >= capacity) return false;
|
||||||
|
|
||||||
uint right = bit::round(capacity);
|
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]));
|
for(uint n : range(_size)) new(pool + n) T(move(_pool[n]));
|
||||||
memory::free(_pool - _left);
|
memory::free(_pool - _left);
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct AudioALSA : Audio {
|
||||||
_offset--;
|
_offset--;
|
||||||
output++;
|
output++;
|
||||||
}
|
}
|
||||||
memory::move(_buffer, output, _offset * sizeof(uint32_t));
|
memory::move<uint32_t>(_buffer, output, _offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,10 +71,10 @@ struct AudioASIO : Audio {
|
||||||
auto clear() -> void {
|
auto clear() -> void {
|
||||||
if(!ready()) return;
|
if(!ready()) return;
|
||||||
for(uint n : range(_channels)) {
|
for(uint n : range(_channels)) {
|
||||||
memory::fill(_channel[n].buffers[0], _latency * _sampleSize);
|
memory::fill<uint8_t>(_channel[n].buffers[0], _latency * _sampleSize);
|
||||||
memory::fill(_channel[n].buffers[1], _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.read = 0;
|
||||||
_queue.write = 0;
|
_queue.write = 0;
|
||||||
_queue.count = 0;
|
_queue.count = 0;
|
||||||
|
|
|
@ -51,7 +51,7 @@ struct AudioDirectSound : Audio {
|
||||||
_ringWrite = _rings - 1;
|
_ringWrite = _rings - 1;
|
||||||
_ringDistance = _rings - 1;
|
_ringDistance = _rings - 1;
|
||||||
|
|
||||||
if(_buffer) memory::fill(_buffer, _period * _rings * 4);
|
if(_buffer) memory::fill<uint32_t>(_buffer, _period * _rings);
|
||||||
_offset = 0;
|
_offset = 0;
|
||||||
|
|
||||||
if(!_secondary) return;
|
if(!_secondary) return;
|
||||||
|
@ -61,7 +61,7 @@ struct AudioDirectSound : Audio {
|
||||||
void* output;
|
void* output;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
_secondary->Lock(0, _period * _rings * 4, &output, &size, 0, 0, 0);
|
_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->Unlock(output, size, 0, 0);
|
||||||
|
|
||||||
_secondary->Play(0, 0, DSBPLAY_LOOPING);
|
_secondary->Play(0, 0, DSBPLAY_LOOPING);
|
||||||
|
@ -102,7 +102,7 @@ struct AudioDirectSound : Audio {
|
||||||
void* output;
|
void* output;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
if(_secondary->Lock(_ringWrite * _period * 4, _period * 4, &output, &size, 0, 0, 0) == DS_OK) {
|
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);
|
_secondary->Unlock(output, size, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ struct AudioXAudio2 : Audio, public IXAudio2VoiceCallback {
|
||||||
_bufferIndex = 0;
|
_bufferIndex = 0;
|
||||||
|
|
||||||
_bufferOffset = 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);
|
_sourceVoice->Start(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ private:
|
||||||
|
|
||||||
LPDIRECT3DVERTEXBUFFER9* vertexPointer = nullptr;
|
LPDIRECT3DVERTEXBUFFER9* vertexPointer = nullptr;
|
||||||
_vertexBuffer->Lock(0, sizeof(Vertex) * 4, (void**)&vertexPointer, 0);
|
_vertexBuffer->Lock(0, sizeof(Vertex) * 4, (void**)&vertexPointer, 0);
|
||||||
memory::copy(vertexPointer, vertex, sizeof(Vertex) * 4);
|
memory::copy<Vertex>(vertexPointer, vertex, 4);
|
||||||
_vertexBuffer->Unlock();
|
_vertexBuffer->Unlock();
|
||||||
|
|
||||||
_device->SetStreamSource(0, _vertexBuffer, 0, sizeof(Vertex));
|
_device->SetStreamSource(0, _vertexBuffer, 0, sizeof(Vertex));
|
||||||
|
|
|
@ -52,7 +52,7 @@ struct VideoGLX2 : Video {
|
||||||
|
|
||||||
auto clear() -> void {
|
auto clear() -> void {
|
||||||
if(!ready()) return;
|
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);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct VideoXVideo : Video {
|
||||||
|
|
||||||
auto clear() -> void {
|
auto clear() -> void {
|
||||||
if(!ready()) return;
|
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 ...
|
//clear twice in case video is double buffered ...
|
||||||
output();
|
output();
|
||||||
output();
|
output();
|
||||||
|
@ -335,7 +335,7 @@ private:
|
||||||
uint32_t* output = (uint32_t*)_image->data;
|
uint32_t* output = (uint32_t*)_image->data;
|
||||||
|
|
||||||
for(uint y : range(height)) {
|
for(uint y : range(height)) {
|
||||||
memory::copy(output, input, width * 4);
|
memory::copy<uint32_t>(output, input, width);
|
||||||
input += _bufferWidth;
|
input += _bufferWidth;
|
||||||
output += _bufferWidth;
|
output += _bufferWidth;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue