mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-10 00:36:35 +02:00
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:
@@ -642,9 +642,11 @@ void Cartridge::xml_parse_serial(xml_element &root) {
|
|||||||
|
|
||||||
void Cartridge::xml_parse_link(xml_element &root) {
|
void Cartridge::xml_parse_link(xml_element &root) {
|
||||||
has_link = true;
|
has_link = true;
|
||||||
|
link.frequency = 1;
|
||||||
link.program = "";
|
link.program = "";
|
||||||
|
|
||||||
foreach(attr, root.attribute) {
|
foreach(attr, root.attribute) {
|
||||||
|
if(attr.name == "frequency") link.frequency = decimal(attr.content);
|
||||||
if(attr.name == "program") link.program = attr.content;
|
if(attr.name == "program") link.program = attr.content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,18 @@ namespace SNES {
|
|||||||
|
|
||||||
Link link;
|
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() {
|
void Link::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,6 +28,7 @@ void Link::load() {
|
|||||||
if(open(name, path)) {
|
if(open(name, path)) {
|
||||||
link_power = sym("link_power");
|
link_power = sym("link_power");
|
||||||
link_reset = sym("link_reset");
|
link_reset = sym("link_reset");
|
||||||
|
link_run = sym("link_run" );
|
||||||
link_read = sym("link_read" );
|
link_read = sym("link_read" );
|
||||||
link_write = sym("link_write");
|
link_write = sym("link_write");
|
||||||
}
|
}
|
||||||
@@ -27,10 +40,12 @@ void Link::unload() {
|
|||||||
|
|
||||||
void Link::power() {
|
void Link::power() {
|
||||||
if(link_power) link_power();
|
if(link_power) link_power();
|
||||||
|
create(Link::Enter, frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Link::reset() {
|
void Link::reset() {
|
||||||
if(link_reset) link_reset();
|
if(link_reset) link_reset();
|
||||||
|
create(Link::Enter, frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 Link::read(unsigned addr) {
|
uint8 Link::read(unsigned addr) {
|
||||||
|
@@ -2,6 +2,8 @@ class Link : public Coprocessor, public library {
|
|||||||
public:
|
public:
|
||||||
string program;
|
string program;
|
||||||
|
|
||||||
|
static void Enter();
|
||||||
|
void enter();
|
||||||
void init();
|
void init();
|
||||||
void load();
|
void load();
|
||||||
void unload();
|
void unload();
|
||||||
@@ -14,6 +16,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
function<void ()> link_power;
|
function<void ()> link_power;
|
||||||
function<void ()> link_reset;
|
function<void ()> link_reset;
|
||||||
|
function<unsigned ()> link_run;
|
||||||
function<uint8 (unsigned)> link_read;
|
function<uint8 (unsigned)> link_read;
|
||||||
function<void (unsigned, uint8)> link_write;
|
function<void (unsigned, uint8)> link_write;
|
||||||
};
|
};
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
namespace SNES {
|
namespace SNES {
|
||||||
namespace Info {
|
namespace Info {
|
||||||
static const char Name[] = "bsnes";
|
static const char Name[] = "bsnes";
|
||||||
static const char Version[] = "079.01";
|
static const char Version[] = "079.02";
|
||||||
static const unsigned SerializerVersion = 20;
|
static const unsigned SerializerVersion = 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -195,6 +195,7 @@ void System::power() {
|
|||||||
if(cartridge.has_necdsp()) cpu.coprocessors.append(&necdsp);
|
if(cartridge.has_necdsp()) cpu.coprocessors.append(&necdsp);
|
||||||
if(cartridge.has_msu1()) cpu.coprocessors.append(&msu1);
|
if(cartridge.has_msu1()) cpu.coprocessors.append(&msu1);
|
||||||
if(cartridge.has_serial()) cpu.coprocessors.append(&serial);
|
if(cartridge.has_serial()) cpu.coprocessors.append(&serial);
|
||||||
|
if(cartridge.has_link()) cpu.coprocessors.append(&link);
|
||||||
|
|
||||||
scheduler.init();
|
scheduler.init();
|
||||||
input.update();
|
input.update();
|
||||||
@@ -232,6 +233,7 @@ void System::reset() {
|
|||||||
if(cartridge.has_necdsp()) cpu.coprocessors.append(&necdsp);
|
if(cartridge.has_necdsp()) cpu.coprocessors.append(&necdsp);
|
||||||
if(cartridge.has_msu1()) cpu.coprocessors.append(&msu1);
|
if(cartridge.has_msu1()) cpu.coprocessors.append(&msu1);
|
||||||
if(cartridge.has_serial()) cpu.coprocessors.append(&serial);
|
if(cartridge.has_serial()) cpu.coprocessors.append(&serial);
|
||||||
|
if(cartridge.has_link()) cpu.coprocessors.append(&link);
|
||||||
|
|
||||||
scheduler.init();
|
scheduler.init();
|
||||||
input.port_set_device(0, config.controller_port1);
|
input.port_set_device(0, config.controller_port1);
|
||||||
|
Reference in New Issue
Block a user