2012-04-29 06:16:44 +00:00
|
|
|
#include <sfc/sfc.hpp>
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
#define DSP_CPP
|
2012-04-26 10:51:13 +00:00
|
|
|
namespace SuperFamicom {
|
2010-08-09 13:28:56 +00:00
|
|
|
|
Update to v085r03 release.
byuu says:
Changelog:
- fixed cursor being visible under Metacity window manager (hopefully
doesn't cause regression with other WMs)
- show normal cursor when using SDL video driver
- added menu accelerators (meh, why not?)
- removed debugvirtual, ChipDebugger and chip/debugger functionality
entirely
- alt/smp disassembler moved up
- fixed alt/smp incw/decw instructions (unsigned->uint16 for internal
variables)
My plan going forward for a debugger is not to hardcode functionality
that causes the 10-15% slowdown right into the emulator itself.
Instead, I'm going to make a callback class, which will be a specialized
version of nall::function:
- can call function even if not assigned (results in no-op, return type
must have a trivial default constructor)
- if compiled without #define DEBUGGER, the entire thing turns into
a huge no-op; and will be eliminated entirely when compiled
- strategically place the functions: cb_step, cb_read, cb_write, etc.
From here, the ui-debugger GUI will bind the callbacks, implement
breakpoint checking, usage table generation, etc itself.
I'll probably have to add some breakout commands to exit the emulation
core prior to a frame event in some cases as well.
I didn't initially want any debugger-related stuff in the base cores,
but the #if debugger sCPUDebugger #else sCPU #endif stuff was already
more of a burden than this will be.
2012-02-04 09:23:53 +00:00
|
|
|
DSP dsp;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
#define REG(n) state.regs[r_##n]
|
|
|
|
#define VREG(n) state.regs[v.vidx + v_##n]
|
|
|
|
|
Update to v085r03 release.
byuu says:
Changelog:
- fixed cursor being visible under Metacity window manager (hopefully
doesn't cause regression with other WMs)
- show normal cursor when using SDL video driver
- added menu accelerators (meh, why not?)
- removed debugvirtual, ChipDebugger and chip/debugger functionality
entirely
- alt/smp disassembler moved up
- fixed alt/smp incw/decw instructions (unsigned->uint16 for internal
variables)
My plan going forward for a debugger is not to hardcode functionality
that causes the 10-15% slowdown right into the emulator itself.
Instead, I'm going to make a callback class, which will be a specialized
version of nall::function:
- can call function even if not assigned (results in no-op, return type
must have a trivial default constructor)
- if compiled without #define DEBUGGER, the entire thing turns into
a huge no-op; and will be eliminated entirely when compiled
- strategically place the functions: cb_step, cb_read, cb_write, etc.
From here, the ui-debugger GUI will bind the callbacks, implement
breakpoint checking, usage table generation, etc itself.
I'll probably have to add some breakout commands to exit the emulation
core prior to a frame event in some cases as well.
I didn't initially want any debugger-related stuff in the base cores,
but the #if debugger sCPUDebugger #else sCPU #endif stuff was already
more of a burden than this will be.
2012-02-04 09:23:53 +00:00
|
|
|
#include "serialization.cpp"
|
2010-08-09 13:28:56 +00:00
|
|
|
#include "gaussian.cpp"
|
|
|
|
#include "counter.cpp"
|
|
|
|
#include "envelope.cpp"
|
|
|
|
#include "brr.cpp"
|
|
|
|
#include "misc.cpp"
|
|
|
|
#include "voice.cpp"
|
|
|
|
#include "echo.cpp"
|
|
|
|
|
|
|
|
/* timing */
|
|
|
|
|
|
|
|
void DSP::step(unsigned clocks) {
|
|
|
|
clock += clocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSP::synchronize_smp() {
|
Updated to v067r21 release.
byuu says:
This moves toward a profile-selection mode. Right now, it is incomplete.
There are three binaries, one for each profile. The GUI selection
doesn't actually do anything yet. There will be a launcher in a future
release that loads each profile's respective binary.
I reverted away from blargg's SMP library for the time being, in favor
of my own. This will fix most of the csnes/bsnes-performance bugs. This
causes a 10% speed hit on 64-bit platforms, and a 15% speed hit on
32-bit platforms. I hope to be able to regain that speed in the future,
I may also experiment with creating my own fast-SMP core which drops bus
hold delays and TEST register support (never used by anything, ever.)
Save states now work in all three cores, but they are not
cross-compatible. The profile name is stored in the description field of
the save states, and it won't load a state if the profile name doesn't
match.
The debugger only works on the research target for now. Give it time and
it will return for the other targets.
Other than that, let's please resume testing on all three once again.
See how far we get this time :)
I can confirm the following games have issues on the performance
profile:
- Armored Police Metal Jacket (minor logo flickering, not a big deal)
- Chou Aniki (won't start, so obviously unplayable)
- Robocop vs The Terminator (major in-game flickering, unplayable)
Anyone still have that gigantic bsnes thread archive from the ZSNES
forum? Maybe I posted about how to fix those two broken games in there,
heh.
I really want to release this as v1.0, but my better judgment says we
need to give it another week. Damn.
2010-10-20 11:22:44 +00:00
|
|
|
if(SMP::Threaded == true) {
|
|
|
|
if(clock >= 0 && scheduler.sync != Scheduler::SynchronizeMode::All) co_switch(smp.thread);
|
|
|
|
} else {
|
|
|
|
while(clock >= 0) smp.enter();
|
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DSP::Enter() { dsp.enter(); }
|
|
|
|
|
|
|
|
void DSP::enter() {
|
|
|
|
while(true) {
|
|
|
|
if(scheduler.sync == Scheduler::SynchronizeMode::All) {
|
|
|
|
scheduler.exit(Scheduler::ExitReason::SynchronizeEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
voice_5(voice[0]);
|
|
|
|
voice_2(voice[1]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_6(voice[0]);
|
|
|
|
voice_3(voice[1]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_7(voice[0]);
|
|
|
|
voice_4(voice[1]);
|
|
|
|
voice_1(voice[3]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_8(voice[0]);
|
|
|
|
voice_5(voice[1]);
|
|
|
|
voice_2(voice[2]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_9(voice[0]);
|
|
|
|
voice_6(voice[1]);
|
|
|
|
voice_3(voice[2]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_7(voice[1]);
|
|
|
|
voice_4(voice[2]);
|
|
|
|
voice_1(voice[4]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_8(voice[1]);
|
|
|
|
voice_5(voice[2]);
|
|
|
|
voice_2(voice[3]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_9(voice[1]);
|
|
|
|
voice_6(voice[2]);
|
|
|
|
voice_3(voice[3]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_7(voice[2]);
|
|
|
|
voice_4(voice[3]);
|
|
|
|
voice_1(voice[5]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_8(voice[2]);
|
|
|
|
voice_5(voice[3]);
|
|
|
|
voice_2(voice[4]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_9(voice[2]);
|
|
|
|
voice_6(voice[3]);
|
|
|
|
voice_3(voice[4]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_7(voice[3]);
|
|
|
|
voice_4(voice[4]);
|
|
|
|
voice_1(voice[6]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_8(voice[3]);
|
|
|
|
voice_5(voice[4]);
|
|
|
|
voice_2(voice[5]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_9(voice[3]);
|
|
|
|
voice_6(voice[4]);
|
|
|
|
voice_3(voice[5]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_7(voice[4]);
|
|
|
|
voice_4(voice[5]);
|
|
|
|
voice_1(voice[7]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_8(voice[4]);
|
|
|
|
voice_5(voice[5]);
|
|
|
|
voice_2(voice[6]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_9(voice[4]);
|
|
|
|
voice_6(voice[5]);
|
|
|
|
voice_3(voice[6]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_1(voice[0]);
|
|
|
|
voice_7(voice[5]);
|
|
|
|
voice_4(voice[6]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_8(voice[5]);
|
|
|
|
voice_5(voice[6]);
|
|
|
|
voice_2(voice[7]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_9(voice[5]);
|
|
|
|
voice_6(voice[6]);
|
|
|
|
voice_3(voice[7]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_1(voice[1]);
|
|
|
|
voice_7(voice[6]);
|
|
|
|
voice_4(voice[7]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_8(voice[6]);
|
|
|
|
voice_5(voice[7]);
|
|
|
|
voice_2(voice[0]);
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_3a(voice[0]);
|
|
|
|
voice_9(voice[6]);
|
|
|
|
voice_6(voice[7]);
|
|
|
|
echo_22();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_7(voice[7]);
|
|
|
|
echo_23();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_8(voice[7]);
|
|
|
|
echo_24();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_3b(voice[0]);
|
|
|
|
voice_9(voice[7]);
|
|
|
|
echo_25();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
echo_26();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
misc_27();
|
|
|
|
echo_27();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
misc_28();
|
|
|
|
echo_28();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
misc_29();
|
|
|
|
echo_29();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
misc_30();
|
|
|
|
voice_3c(voice[0]);
|
|
|
|
echo_30();
|
|
|
|
tick();
|
|
|
|
|
|
|
|
voice_4(voice[0]);
|
|
|
|
voice_1(voice[2]);
|
|
|
|
tick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSP::tick() {
|
|
|
|
step(3 * 8);
|
|
|
|
synchronize_smp();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* register interface for S-SMP $00f2,$00f3 */
|
|
|
|
|
2012-05-29 12:20:46 +00:00
|
|
|
bool DSP::mute() {
|
|
|
|
return state.regs[r_flg] & 0x40;
|
|
|
|
}
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
uint8 DSP::read(uint8 addr) {
|
|
|
|
return state.regs[addr];
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSP::write(uint8 addr, uint8 data) {
|
|
|
|
state.regs[addr] = data;
|
|
|
|
|
|
|
|
if((addr & 0x0f) == v_envx) {
|
|
|
|
state.envx_buf = data;
|
|
|
|
} else if((addr & 0x0f) == v_outx) {
|
|
|
|
state.outx_buf = data;
|
|
|
|
} else if(addr == r_kon) {
|
|
|
|
state.new_kon = data;
|
|
|
|
} else if(addr == r_endx) {
|
|
|
|
//always cleared, regardless of data written
|
|
|
|
state.endx_buf = 0;
|
|
|
|
state.regs[r_endx] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialization */
|
|
|
|
|
|
|
|
void DSP::power() {
|
|
|
|
memset(&state.regs, 0, sizeof state.regs);
|
|
|
|
state.echo_hist_pos = 0;
|
|
|
|
state.every_other_sample = false;
|
|
|
|
state.kon = 0;
|
|
|
|
state.noise = 0;
|
|
|
|
state.counter = 0;
|
|
|
|
state.echo_offset = 0;
|
|
|
|
state.echo_length = 0;
|
|
|
|
state.new_kon = 0;
|
|
|
|
state.endx_buf = 0;
|
|
|
|
state.envx_buf = 0;
|
|
|
|
state.outx_buf = 0;
|
|
|
|
state.t_pmon = 0;
|
|
|
|
state.t_non = 0;
|
|
|
|
state.t_eon = 0;
|
|
|
|
state.t_dir = 0;
|
|
|
|
state.t_koff = 0;
|
|
|
|
state.t_brr_next_addr = 0;
|
|
|
|
state.t_adsr0 = 0;
|
|
|
|
state.t_brr_header = 0;
|
|
|
|
state.t_brr_byte = 0;
|
|
|
|
state.t_srcn = 0;
|
|
|
|
state.t_esa = 0;
|
|
|
|
state.t_echo_disabled = 0;
|
|
|
|
state.t_dir_addr = 0;
|
|
|
|
state.t_pitch = 0;
|
|
|
|
state.t_output = 0;
|
|
|
|
state.t_looped = 0;
|
|
|
|
state.t_echo_ptr = 0;
|
|
|
|
state.t_main_out[0] = state.t_main_out[1] = 0;
|
|
|
|
state.t_echo_out[0] = state.t_echo_out[1] = 0;
|
|
|
|
state.t_echo_in[0] = state.t_echo_in[1] = 0;
|
|
|
|
|
|
|
|
for(unsigned i = 0; i < 8; i++) {
|
|
|
|
voice[i].buf_pos = 0;
|
|
|
|
voice[i].interp_pos = 0;
|
|
|
|
voice[i].brr_addr = 0;
|
|
|
|
voice[i].brr_offset = 1;
|
|
|
|
voice[i].vbit = 1 << i;
|
|
|
|
voice[i].vidx = i * 0x10;
|
|
|
|
voice[i].kon_delay = 0;
|
|
|
|
voice[i].env_mode = env_release;
|
|
|
|
voice[i].env = 0;
|
|
|
|
voice[i].t_envx_out = 0;
|
|
|
|
voice[i].hidden_env = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSP::reset() {
|
|
|
|
create(Enter, system.apu_frequency());
|
|
|
|
|
|
|
|
REG(flg) = 0xe0;
|
|
|
|
|
|
|
|
state.noise = 0x4000;
|
|
|
|
state.echo_hist_pos = 0;
|
|
|
|
state.every_other_sample = 1;
|
|
|
|
state.echo_offset = 0;
|
|
|
|
state.counter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DSP::DSP() {
|
|
|
|
static_assert(sizeof(int) >= 32 / 8, "int >= 32-bits");
|
|
|
|
static_assert((int8)0x80 == -0x80, "8-bit sign extension");
|
|
|
|
static_assert((int16)0x8000 == -0x8000, "16-bit sign extension");
|
|
|
|
static_assert((uint16)0xffff0000 == 0, "16-bit unsigned clip");
|
|
|
|
static_assert((-1 >> 1) == -1, "arithmetic shift right");
|
|
|
|
|
|
|
|
//-0x8000 <= n <= +0x7fff
|
|
|
|
assert(sclamp<16>(+0x8000) == +0x7fff);
|
|
|
|
assert(sclamp<16>(-0x8001) == -0x8000);
|
|
|
|
}
|
|
|
|
|
|
|
|
DSP::~DSP() {
|
|
|
|
}
|
|
|
|
|
Update to v085r03 release.
byuu says:
Changelog:
- fixed cursor being visible under Metacity window manager (hopefully
doesn't cause regression with other WMs)
- show normal cursor when using SDL video driver
- added menu accelerators (meh, why not?)
- removed debugvirtual, ChipDebugger and chip/debugger functionality
entirely
- alt/smp disassembler moved up
- fixed alt/smp incw/decw instructions (unsigned->uint16 for internal
variables)
My plan going forward for a debugger is not to hardcode functionality
that causes the 10-15% slowdown right into the emulator itself.
Instead, I'm going to make a callback class, which will be a specialized
version of nall::function:
- can call function even if not assigned (results in no-op, return type
must have a trivial default constructor)
- if compiled without #define DEBUGGER, the entire thing turns into
a huge no-op; and will be eliminated entirely when compiled
- strategically place the functions: cb_step, cb_read, cb_write, etc.
From here, the ui-debugger GUI will bind the callbacks, implement
breakpoint checking, usage table generation, etc itself.
I'll probably have to add some breakout commands to exit the emulation
core prior to a frame event in some cases as well.
I didn't initially want any debugger-related stuff in the base cores,
but the #if debugger sCPUDebugger #else sCPU #endif stuff was already
more of a burden than this will be.
2012-02-04 09:23:53 +00:00
|
|
|
#undef REG
|
|
|
|
#undef VREG
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|