Minor speedups for SuperFX and Cx4 emulation.

This commit is contained in:
byuu 2019-08-05 11:08:25 +09:00
parent e030428054
commit 06ceb7d29e
12 changed files with 37 additions and 31 deletions

View File

@ -1,4 +1,4 @@
processors += wdc65816 spc700 arm7tdmi gsu hg51b upd96050 processors += wdc65816 spc700 arm7tdmi
objects += sfc-interface sfc-system sfc-controller objects += sfc-interface sfc-system sfc-controller
objects += sfc-cartridge sfc-memory objects += sfc-cartridge sfc-memory

View File

@ -141,7 +141,7 @@ auto Cartridge::loadMap(Markup::Node map, T& memory) -> uint {
auto Cartridge::loadMap( auto Cartridge::loadMap(
Markup::Node map, Markup::Node map,
const function<uint8 (uint, uint8)>& reader, const function<uint8 (uint, uint8)>& reader,
const function<void (uint, uint8)>& writer const function<void (uint, uint8)>& writer
) -> uint { ) -> uint {
auto addr = map["address"].text(); auto addr = map["address"].text();
auto size = map["size"].natural(); auto size = map["size"].natural();

View File

@ -1,4 +1,5 @@
#include <sfc/sfc.hpp> #include <sfc/sfc.hpp>
#include <processor/hg51b/hg51b.cpp>
namespace SuperFamicom { namespace SuperFamicom {

View File

@ -1,4 +1,5 @@
#include <sfc/sfc.hpp> #include <sfc/sfc.hpp>
#include <processor/upd96050/upd96050.cpp>
namespace SuperFamicom { namespace SuperFamicom {

View File

@ -1,4 +1,5 @@
#include <sfc/sfc.hpp> #include <sfc/sfc.hpp>
#include <processor/gsu/gsu.cpp>
namespace SuperFamicom { namespace SuperFamicom {

View File

@ -29,7 +29,7 @@ auto CPU::step() -> void {
static_assert(Clocks == 2 || Clocks == 4 || Clocks == 6 || Clocks == 8 || Clocks == 10 || Clocks == 12); static_assert(Clocks == 2 || Clocks == 4 || Clocks == 6 || Clocks == 8 || Clocks == 10 || Clocks == 12);
for(auto coprocessor : coprocessors) { for(auto coprocessor : coprocessors) {
coprocessor->clock -= Clocks * (uint64_t)coprocessor->frequency; coprocessor->clock -= Clocks * (uint64)coprocessor->frequency;
} }
if(overclocking.target) { if(overclocking.target) {
@ -37,9 +37,8 @@ auto CPU::step() -> void {
if(overclocking.counter < overclocking.target) { if(overclocking.counter < overclocking.target) {
if constexpr(Synchronize) { if constexpr(Synchronize) {
if(configuration.hacks.coprocessor.delayedSync) return; if(configuration.hacks.coprocessor.delayedSync) return;
synchronizeCoprocessors(); return synchronizeCoprocessors();
} }
return;
} }
} }
@ -50,7 +49,7 @@ auto CPU::step() -> void {
if constexpr(Clocks >= 10) stepOnce(); if constexpr(Clocks >= 10) stepOnce();
if constexpr(Clocks >= 12) stepOnce(); if constexpr(Clocks >= 12) stepOnce();
smp.clock -= Clocks * (uint64_t)smp.frequency; smp.clock -= Clocks * (uint64)smp.frequency;
ppu.clock -= Clocks; ppu.clock -= Clocks;
if(!status.dramRefresh && hcounter() >= status.dramRefreshPosition) { if(!status.dramRefresh && hcounter() >= status.dramRefreshPosition) {

View File

@ -231,6 +231,9 @@ private:
void echo_30(); void echo_30();
void soft_reset_common(); void soft_reset_common();
public:
bool mute() { return m.regs[r_flg] & 0x40; }
}; };
#include <assert.h> #include <assert.h>

View File

@ -7,7 +7,7 @@ DSP dsp;
#include "serialization.cpp" #include "serialization.cpp"
#include "SPC_DSP.cpp" #include "SPC_DSP.cpp"
void DSP::main() { auto DSP::main() -> void {
if(!configuration.hacks.dsp.fast) { if(!configuration.hacks.dsp.fast) {
spc_dsp.run(1); spc_dsp.run(1);
clock += 2; clock += 2;
@ -25,19 +25,19 @@ void DSP::main() {
} }
} }
uint8 DSP::read(uint8 addr) { auto DSP::read(uint8 address) -> uint8 {
return spc_dsp.read(addr); return spc_dsp.read(address);
} }
void DSP::write(uint8 addr, uint8 data) { auto DSP::write(uint8 address, uint8 data) -> void {
spc_dsp.write(addr, data); spc_dsp.write(address, data);
} }
bool DSP::load() { auto DSP::load() -> bool {
return true; return true;
} }
void DSP::power(bool reset) { auto DSP::power(bool reset) -> void {
clock = 0; clock = 0;
stream = Emulator::audio.createStream(2, system.apuFrequency() / 768.0); stream = Emulator::audio.createStream(2, system.apuFrequency() / 768.0);
@ -51,8 +51,8 @@ void DSP::power(bool reset) {
} }
} }
bool DSP::mute() { auto DSP::mute() -> bool {
return false; return spc_dsp.mute();
} }
} }

View File

@ -2,23 +2,24 @@
struct DSP { struct DSP {
shared_pointer<Emulator::Stream> stream; shared_pointer<Emulator::Stream> stream;
uint8_t apuram[64 * 1024] = {}; uint8 apuram[64 * 1024] = {};
void main(); auto main() -> void;
uint8 read(uint8 addr); auto read(uint8 address) -> uint8;
void write(uint8 addr, uint8 data); auto write(uint8 address, uint8 data) -> void;
bool load(); auto load() -> bool;
void power(bool reset); auto power(bool reset) -> void;
bool mute(); auto mute() -> bool;
void serialize(serializer&); auto serialize(serializer&) -> void;
int64 clock = 0; int64 clock = 0;
private: private:
bool fastDSP = false;
SPC_DSP spc_dsp; SPC_DSP spc_dsp;
int16_t samplebuffer[8192]; int16 samplebuffer[8192];
}; };
extern DSP dsp; extern DSP dsp;

View File

@ -1,20 +1,20 @@
static void dsp_state_save(unsigned char **out, void *in, size_t size) { static auto dsp_state_save(unsigned char** out, void* in, size_t size) -> void {
memcpy(*out, in, size); memcpy(*out, in, size);
*out += size; *out += size;
} }
static void dsp_state_load(unsigned char **in, void *out, size_t size) { static auto dsp_state_load(unsigned char** in, void* out, size_t size) -> void {
memcpy(out, *in, size); memcpy(out, *in, size);
*in += size; *in += size;
} }
void DSP::serialize(serializer &s) { auto DSP::serialize(serializer& s) -> void {
s.array(apuram); s.array(apuram);
s.array(samplebuffer); s.array(samplebuffer);
s.integer(clock); s.integer(clock);
unsigned char state[SPC_DSP::state_size]; unsigned char state[SPC_DSP::state_size];
unsigned char *p = state; unsigned char* p = state;
memset(&state, 0, SPC_DSP::state_size); memset(&state, 0, SPC_DSP::state_size);
if(s.mode() == serializer::Save) { if(s.mode() == serializer::Save) {
spc_dsp.copy_state(&p, dsp_state_save); spc_dsp.copy_state(&p, dsp_state_save);

View File

@ -11,7 +11,7 @@ Bus::~Bus() {
} }
auto Bus::reset() -> void { auto Bus::reset() -> void {
for(auto id : range(256)) { for(uint id : range(256)) {
reader[id].reset(); reader[id].reset();
writer[id].reset(); writer[id].reset();
counter[id] = 0; counter[id] = 0;
@ -29,7 +29,7 @@ auto Bus::reset() -> void {
auto Bus::map( auto Bus::map(
const function<uint8 (uint, uint8)>& read, const function<uint8 (uint, uint8)>& read,
const function<void (uint, uint8)>& write, const function<void (uint, uint8)>& write,
const string& addr, uint size, uint base, uint mask const string& addr, uint size, uint base, uint mask
) -> uint { ) -> uint {
uint id = 1; uint id = 1;

View File

@ -42,7 +42,7 @@ private:
uint32* target = nullptr; uint32* target = nullptr;
function<uint8 (uint, uint8)> reader[256]; function<uint8 (uint, uint8)> reader[256];
function<void (uint, uint8)> writer[256]; function<void (uint, uint8)> writer[256];
uint counter[256]; uint counter[256];
}; };