mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-28 17:29:56 +02:00
Update to v098r08 release.
byuu says: Changelog: - nall/vector rewritten from scratch - higan/audio uses nall/vector instead of raw pointers - higan/sfc/coprocessor/sdd1 updated with new research information - ruby/video/glx and ruby/video/glx2: fuck salt glXSwapIntervalEXT! The big change here is definitely nall/vector. The Windows, OS X and Qt ports won't compile until you change some first/last strings to left/right, but GTK will compile. I'd be really grateful if anyone could stress-test nall/vector. Pretty much everything I do relies on this class. If we introduce a bug, the worst case scenario is my entire SFC game dump database gets corrupted, or the byuu.org server gets compromised. So it's really critical that we test the hell out of this right now. The S-DD1 changes mean you need to update your installation of icarus again. Also, even though the Lunar FMV never really worked on the accuracy core anyway (it didn't initialize the PPU properly), it really won't work now that we emulate the hard-limit of 16MiB for S-DD1 games.
This commit is contained in:
134
nall/emulation/21fx.hpp
Normal file
134
nall/emulation/21fx.hpp
Normal file
@@ -0,0 +1,134 @@
|
||||
#pragma once
|
||||
|
||||
#include <nall/nall.hpp>
|
||||
#include <nall/serial.hpp>
|
||||
using namespace nall;
|
||||
|
||||
struct FX {
|
||||
auto open(lstring& args) -> bool;
|
||||
auto close() -> void;
|
||||
auto readable() -> bool;
|
||||
auto read() -> uint8_t;
|
||||
auto writable() -> bool;
|
||||
auto write(uint8_t data) -> void;
|
||||
|
||||
auto read(uint offset, uint length) -> vector<uint8_t>;
|
||||
auto write(uint offset, const vector<uint8_t>& buffer) -> void;
|
||||
auto execute(uint offset) -> void;
|
||||
|
||||
auto read(uint offset) -> uint8_t;
|
||||
auto write(uint offset, uint8_t data) -> void;
|
||||
|
||||
serial device;
|
||||
};
|
||||
|
||||
auto FX::open(lstring& args) -> bool {
|
||||
//device name override support
|
||||
string name;
|
||||
for(uint n : range(args)) {
|
||||
if(args[n].beginsWith("--device=")) {
|
||||
name = args.take(n).ltrim("--device=", 1L);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!device.open(name)) {
|
||||
print("[21fx] error: unable to open hardware device\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
//flush the device (to clear floating inputs)
|
||||
while(true) {
|
||||
while(readable()) read();
|
||||
auto iplrom = read(0x2184, 122);
|
||||
auto sha256 = Hash::SHA256(iplrom.data(), iplrom.size()).digest();
|
||||
if(sha256 == "41b79712a4a2d16d39894ae1b38cde5c41dad22eadc560df631d39f13df1e4b9") break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto FX::close() -> void {
|
||||
device.close();
|
||||
}
|
||||
|
||||
auto FX::readable() -> bool {
|
||||
return device.readable();
|
||||
}
|
||||
|
||||
//1000ns delay avoids burning CPU core at 100%; does not slow down max transfer rate at all
|
||||
auto FX::read() -> uint8_t {
|
||||
while(!readable()) usleep(1000);
|
||||
uint8_t buffer[1] = {0};
|
||||
device.read(buffer, 1);
|
||||
return buffer[0];
|
||||
}
|
||||
|
||||
auto FX::writable() -> bool {
|
||||
return device.writable();
|
||||
}
|
||||
|
||||
auto FX::write(uint8_t data) -> void {
|
||||
while(!writable()) usleep(1000);
|
||||
uint8_t buffer[1] = {data};
|
||||
device.write(buffer, 1);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
auto FX::read(uint offset, uint length) -> vector<uint8_t> {
|
||||
write(0x21);
|
||||
write(0x66);
|
||||
write(0x78);
|
||||
write(offset >> 16);
|
||||
write(offset >> 8);
|
||||
write(offset >> 0);
|
||||
write(0x01);
|
||||
write(length >> 8);
|
||||
write(length >> 0);
|
||||
write(0x00);
|
||||
|
||||
vector<uint8_t> buffer;
|
||||
while(length--) buffer.append(read());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
auto FX::write(uint offset, const vector<uint8_t>& buffer) -> void {
|
||||
auto length = buffer.size();
|
||||
|
||||
write(0x21);
|
||||
write(0x66);
|
||||
write(0x78);
|
||||
write(offset >> 16);
|
||||
write(offset >> 8);
|
||||
write(offset >> 0);
|
||||
write(0x01);
|
||||
write(buffer.size() >> 8);
|
||||
write(buffer.size() >> 0);
|
||||
write(0x01);
|
||||
|
||||
for(auto data : buffer) write(data);
|
||||
write(0x00);
|
||||
}
|
||||
|
||||
auto FX::execute(uint offset) -> void {
|
||||
write(0x21);
|
||||
write(0x66);
|
||||
write(0x78);
|
||||
write(offset >> 16);
|
||||
write(offset >> 8);
|
||||
write(offset >> 0);
|
||||
write(0x00);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
auto FX::read(uint offset) -> uint8_t {
|
||||
auto buffer = read(offset, 1);
|
||||
return buffer[0];
|
||||
}
|
||||
|
||||
auto FX::write(uint offset, uint8_t data) -> void {
|
||||
vector<uint8_t> buffer = {data};
|
||||
write(offset, buffer);
|
||||
}
|
Reference in New Issue
Block a user