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-cartridge sfc-memory

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
#include <sfc/sfc.hpp>
#include <processor/gsu/gsu.cpp>
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);
for(auto coprocessor : coprocessors) {
coprocessor->clock -= Clocks * (uint64_t)coprocessor->frequency;
coprocessor->clock -= Clocks * (uint64)coprocessor->frequency;
}
if(overclocking.target) {
@ -37,9 +37,8 @@ auto CPU::step() -> void {
if(overclocking.counter < overclocking.target) {
if constexpr(Synchronize) {
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 >= 12) stepOnce();
smp.clock -= Clocks * (uint64_t)smp.frequency;
smp.clock -= Clocks * (uint64)smp.frequency;
ppu.clock -= Clocks;
if(!status.dramRefresh && hcounter() >= status.dramRefreshPosition) {

View File

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

View File

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

View File

@ -2,23 +2,24 @@
struct DSP {
shared_pointer<Emulator::Stream> stream;
uint8_t apuram[64 * 1024] = {};
uint8 apuram[64 * 1024] = {};
void main();
uint8 read(uint8 addr);
void write(uint8 addr, uint8 data);
auto main() -> void;
auto read(uint8 address) -> uint8;
auto write(uint8 address, uint8 data) -> void;
bool load();
void power(bool reset);
bool mute();
auto load() -> bool;
auto power(bool reset) -> void;
auto mute() -> bool;
void serialize(serializer&);
auto serialize(serializer&) -> void;
int64 clock = 0;
private:
bool fastDSP = false;
SPC_DSP spc_dsp;
int16_t samplebuffer[8192];
int16 samplebuffer[8192];
};
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);
*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);
*in += size;
}
void DSP::serialize(serializer &s) {
auto DSP::serialize(serializer& s) -> void {
s.array(apuram);
s.array(samplebuffer);
s.integer(clock);
unsigned char state[SPC_DSP::state_size];
unsigned char *p = state;
unsigned char* p = state;
memset(&state, 0, SPC_DSP::state_size);
if(s.mode() == serializer::Save) {
spc_dsp.copy_state(&p, dsp_state_save);

View File

@ -11,7 +11,7 @@ Bus::~Bus() {
}
auto Bus::reset() -> void {
for(auto id : range(256)) {
for(uint id : range(256)) {
reader[id].reset();
writer[id].reset();
counter[id] = 0;
@ -29,7 +29,7 @@ auto Bus::reset() -> void {
auto Bus::map(
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
) -> uint {
uint id = 1;

View File

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