Update to v079r02 release.

byuu says:

Added "unsigned link_run();" which acts as its own thread synchronized
against the S-CPU. Specify the frequency in the configuration file.
I intend to prototype the Cx4 LLE openly using the link module, and that
required timing support, so there we go.

It's very basic, and it synchronizes the CPU to the coprocessors and
vice versa after every call to link_run(). Meaning performance won't be
super exceptional at full 21MHz or higher, but then this is for
prototyping only. I didn't want to expose cothreading, yielding, calls
back into bsnes' core, calls to sync up the S-CPU, etc.
This commit is contained in:
Tim Allen 2011-06-13 22:03:19 +10:00
parent 42dbf73d18
commit e30fcade43
5 changed files with 23 additions and 1 deletions
bsnes/snes

@ -642,9 +642,11 @@ void Cartridge::xml_parse_serial(xml_element &root) {
void Cartridge::xml_parse_link(xml_element &root) {
has_link = true;
link.frequency = 1;
link.program = "";
foreach(attr, root.attribute) {
if(attr.name == "frequency") link.frequency = decimal(attr.content);
if(attr.name == "program") link.program = attr.content;
}

@ -5,6 +5,18 @@ namespace SNES {
Link link;
void Link::Enter() { link.enter(); }
void Link::enter() {
while(true) {
cpu.synchronize_coprocessor();
unsigned clocks = 1;
if(link_run) clocks = link_run();
step(clocks);
synchronize_cpu();
}
}
void Link::init() {
}
@ -16,6 +28,7 @@ void Link::load() {
if(open(name, path)) {
link_power = sym("link_power");
link_reset = sym("link_reset");
link_run = sym("link_run" );
link_read = sym("link_read" );
link_write = sym("link_write");
}
@ -27,10 +40,12 @@ void Link::unload() {
void Link::power() {
if(link_power) link_power();
create(Link::Enter, frequency);
}
void Link::reset() {
if(link_reset) link_reset();
create(Link::Enter, frequency);
}
uint8 Link::read(unsigned addr) {

@ -2,6 +2,8 @@ class Link : public Coprocessor, public library {
public:
string program;
static void Enter();
void enter();
void init();
void load();
void unload();
@ -14,6 +16,7 @@ public:
private:
function<void ()> link_power;
function<void ()> link_reset;
function<unsigned ()> link_run;
function<uint8 (unsigned)> link_read;
function<void (unsigned, uint8)> link_write;
};

@ -1,7 +1,7 @@
namespace SNES {
namespace Info {
static const char Name[] = "bsnes";
static const char Version[] = "079.01";
static const char Version[] = "079.02";
static const unsigned SerializerVersion = 20;
}
}

@ -195,6 +195,7 @@ void System::power() {
if(cartridge.has_necdsp()) cpu.coprocessors.append(&necdsp);
if(cartridge.has_msu1()) cpu.coprocessors.append(&msu1);
if(cartridge.has_serial()) cpu.coprocessors.append(&serial);
if(cartridge.has_link()) cpu.coprocessors.append(&link);
scheduler.init();
input.update();
@ -232,6 +233,7 @@ void System::reset() {
if(cartridge.has_necdsp()) cpu.coprocessors.append(&necdsp);
if(cartridge.has_msu1()) cpu.coprocessors.append(&msu1);
if(cartridge.has_serial()) cpu.coprocessors.append(&serial);
if(cartridge.has_link()) cpu.coprocessors.append(&link);
scheduler.init();
input.port_set_device(0, config.controller_port1);