Update to v106r58 release.

byuu says:

The main thing I worked on today was emulating the MBC7 EEPROM.

And... I have many things to say about that, but not here, and not now...

The missing EEPROM support is why the accelerometer was broken. Although
it's not evidently clear that I'm emulating the actual values
incorrectly. I'll think about it and get it fixed, though.

bsnes went from ~308fps to ~328fps, and I don't even know why. Probably
something somewhere in the 140KB of changes to other things made in this
WIP.
This commit is contained in:
Tim Allen
2018-08-21 13:17:12 +10:00
parent 9a6ae6dacb
commit f9adb4d2c6
98 changed files with 3422 additions and 1539 deletions

View File

@@ -1,5 +1,4 @@
#include "xaudio2.hpp"
#include <windows.h>
#undef interface
struct AudioXAudio2 : AudioDriver, public IXAudio2VoiceCallback {

View File

@@ -21,7 +21,7 @@ using namespace ruby;
#include <Carbon/Carbon.h>
#include <nall/macos/guard.hpp>
#elif defined(DISPLAY_WINDOWS)
#include <windows.h>
#include <mmsystem.h>
#endif
#include <ruby/video/video.cpp>

View File

@@ -26,7 +26,6 @@ struct VideoCGL : VideoDriver, OpenGL {
auto hasContext() -> bool override { return true; }
auto hasBlocking() -> bool override { return true; }
auto hasFlush() -> bool override { return true; }
auto hasSmooth() -> bool override { return true; }
auto hasShader() -> bool override { return true; }
auto setContext(uintptr context) -> bool override {
@@ -47,14 +46,8 @@ struct VideoCGL : VideoDriver, OpenGL {
return true;
}
auto setSmooth(bool) -> bool override {
if(!self.shader) OpenGL::filter = self.smooth ? GL_LINEAR : GL_NEAREST;
return true;
}
auto setShader(string) -> bool override {
OpenGL::setShader(self.shader);
if(!self.shader) OpenGL::filter = self.smooth ? GL_LINEAR : GL_NEAREST;
auto setShader(string shader) -> bool override {
OpenGL::setShader(shader);
return true;
}

View File

@@ -22,12 +22,12 @@ struct VideoDirect3D : VideoDriver {
auto hasExclusive() -> bool override { return true; }
auto hasContext() -> bool override { return true; }
auto hasBlocking() -> bool override { return true; }
auto hasSmooth() -> bool override { return true; }
auto hasShader() -> bool override { return true; }
auto setExclusive(bool exclusive) -> bool override { return initialize(); }
auto setContext(uintptr context) -> bool override { return initialize(); }
auto setBlocking(bool blocking) -> bool override { return true; }
auto setSmooth(bool smooth) -> bool override { return updateFilter(); }
auto setShader(string shader) -> bool override { return updateFilter(); }
auto clear() -> void override {
if(!ready()) return;
@@ -169,7 +169,7 @@ private:
if(!_device) return false;
if(_lost && !recover()) return false;
auto filter = !self.smooth ? D3DTEXF_POINT : D3DTEXF_LINEAR;
auto filter = self.shader == "Blur" ? D3DTEXF_LINEAR : D3DTEXF_POINT;
_device->SetSamplerState(0, D3DSAMP_MINFILTER, filter);
_device->SetSamplerState(0, D3DSAMP_MAGFILTER, filter);
return true;

View File

@@ -7,6 +7,7 @@ struct VideoDirectDraw : VideoDriver {
~VideoDirectDraw() { terminate(); }
auto create() -> bool override {
super.setShader("Blur");
return initialize();
}

View File

@@ -4,6 +4,7 @@ struct VideoGDI : VideoDriver {
~VideoGDI() { terminate(); }
auto create() -> bool override {
super.setShader("None");
return initialize();
}

View File

@@ -23,7 +23,6 @@ struct VideoGLX : VideoDriver, OpenGL {
auto hasContext() -> bool override { return true; }
auto hasBlocking() -> bool override { return true; }
auto hasFlush() -> bool override { return true; }
auto hasSmooth() -> bool override { return true; }
auto hasShader() -> bool override { return true; }
auto hasFormats() -> vector<string> override {
@@ -57,14 +56,8 @@ struct VideoGLX : VideoDriver, OpenGL {
return false;
}
auto setSmooth(bool) -> bool override {
if(!self.shader) OpenGL::filter = self.smooth ? GL_LINEAR : GL_NEAREST;
return true;
}
auto setShader(string) -> bool override {
OpenGL::setShader(self.shader);
if(!self.shader) OpenGL::filter = self.smooth ? GL_LINEAR : GL_NEAREST;
auto setShader(string shader) -> bool override {
OpenGL::setShader(shader);
return true;
}
@@ -214,7 +207,7 @@ private:
_doubleBuffer = value;
_isDirect = glXIsDirect(_display, _glXContext);
return _ready = OpenGL::initialize();
return _ready = OpenGL::initialize(self.shader);
}
auto terminate() -> void {

View File

@@ -38,7 +38,7 @@ struct VideoGLX2 : VideoDriver {
auto hasBlocking() -> bool override { return true; }
auto hasFlush() -> bool override { return true; }
auto hasFormats() -> vector<string> override { return {"RGB24"}; }
auto hasSmooth() -> bool override { return true; }
auto hasShader() -> bool override { return true; }
auto setContext(uintptr context) -> bool override {
return initialize();
@@ -63,6 +63,15 @@ struct VideoGLX2 : VideoDriver {
return false;
}
auto setShader(string shader) -> bool override {
return true;
}
auto configure(uint width, uint height, double inputFrequency, double outputFrequency) -> bool override {
XResizeWindow(_display, _window, width, height);
return true;
}
auto clear() -> void override {
memory::fill<uint32_t>(_glBuffer, _glWidth * _glHeight);
glClearColor(0.0, 0.0, 0.0, 1.0);
@@ -81,22 +90,15 @@ struct VideoGLX2 : VideoDriver {
}
auto output() -> void override {
XWindowAttributes parent, child;
XGetWindowAttributes(_display, (Window)self.context, &parent);
XGetWindowAttributes(_display, _window, &child);
if(child.width != parent.width || child.height != parent.height) {
XResizeWindow(_display, _window, parent.width, parent.height);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, self.smooth ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, self.smooth ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, self.shader == "Blur" ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, self.shader == "Blur" ? GL_LINEAR : GL_NEAREST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, parent.width, 0, parent.height, -1.0, 1.0);
glViewport(0, 0, parent.width, parent.height);
glOrtho(0, self.width, 0, self.height, -1.0, 1.0);
glViewport(0, 0, self.width, self.height);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -105,8 +107,8 @@ struct VideoGLX2 : VideoDriver {
double w = (double)_width / (double)_glWidth;
double h = (double)_height / (double)_glHeight;
int u = parent.width;
int v = parent.height;
int u = self.width;
int v = self.height;
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0, 0); glVertex3i(0, v, 0);
@@ -261,6 +263,7 @@ private:
}
bool _ready = false;
bool blur = false;
Display* _display = nullptr;
int _screen = 0;

View File

@@ -11,7 +11,11 @@ auto OpenGL::setShader(const string& pathname) -> void {
relativeWidth = 0, relativeHeight = 0;
uint historySize = 0;
if(pathname) {
if(pathname == "None") {
filter = GL_NEAREST;
} else if(pathname == "Blur") {
filter = GL_LINEAR;
} else if(directory::exists(pathname)) {
auto document = BML::unserialize(file::read({pathname, "manifest.bml"}));
for(auto node : document["settings"]) {
@@ -180,7 +184,7 @@ auto OpenGL::output() -> void {
}
}
auto OpenGL::initialize() -> bool {
auto OpenGL::initialize(const string& shader) -> bool {
if(!OpenGLBind()) return false;
glDisable(GL_BLEND);
@@ -196,7 +200,7 @@ auto OpenGL::initialize() -> bool {
OpenGLSurface::allocate();
glrLinkProgram(program);
setShader("");
setShader(shader);
return initialized = true;
}

View File

@@ -70,7 +70,7 @@ struct OpenGL : OpenGLProgram {
auto clear() -> void;
auto lock(uint32_t*& data, uint& pitch) -> bool;
auto output() -> void;
auto initialize() -> bool;
auto initialize(const string& shader) -> bool;
auto terminate() -> void;
vector<OpenGLProgram> programs;

View File

@@ -71,13 +71,6 @@ auto Video::setFormat(string format) -> bool {
return true;
}
auto Video::setSmooth(bool smooth) -> bool {
if(instance->smooth == smooth) return true;
if(!instance->hasSmooth()) return false;
if(!instance->setSmooth(instance->smooth = smooth)) return false;
return true;
}
auto Video::setShader(string shader) -> bool {
if(instance->shader == shader) return true;
if(!instance->hasShader()) return false;
@@ -87,6 +80,14 @@ auto Video::setShader(string shader) -> bool {
//
auto Video::configure(uint width, uint height, double inputFrequency, double outputFrequency) -> bool {
instance->width = width;
instance->height = height;
instance->inputFrequency = inputFrequency;
instance->outputFrequency = outputFrequency;
return instance->configure(width, height, inputFrequency, outputFrequency);
}
auto Video::clear() -> void {
return instance->clear();
}

View File

@@ -13,7 +13,6 @@ struct VideoDriver {
virtual auto hasBlocking() -> bool { return false; }
virtual auto hasFlush() -> bool { return false; }
virtual auto hasFormats() -> vector<string> { return {"RGB24"}; }
virtual auto hasSmooth() -> bool { return false; }
virtual auto hasShader() -> bool { return false; }
auto hasFormat(string format) -> bool { return (bool)hasFormats().find(format); }
@@ -23,9 +22,9 @@ struct VideoDriver {
virtual auto setBlocking(bool blocking) -> bool { return true; }
virtual auto setFlush(bool flush) -> bool { return true; }
virtual auto setFormat(string format) -> bool { return true; }
virtual auto setSmooth(bool smooth) -> bool { return true; }
virtual auto setShader(string shader) -> bool { return true; }
virtual auto configure(uint width, uint height, double inputFrequency, double outputFrequency) -> bool { return true; }
virtual auto clear() -> void {}
virtual auto acquire(uint32_t*& data, uint& pitch, uint width, uint height) -> bool { return false; }
virtual auto release() -> void {}
@@ -41,8 +40,12 @@ protected:
bool blocking = false;
bool flush = false;
string format = "RGB24";
bool smooth = false;
string shader = "";
string shader = "Blur";
uint width = 0;
uint height = 0;
double inputFrequency = 0.0;
double outputFrequency = 0.0;
};
struct Video {
@@ -63,7 +66,6 @@ struct Video {
auto hasBlocking() -> bool { return instance->hasBlocking(); }
auto hasFlush() -> bool { return instance->hasFlush(); }
auto hasFormats() -> vector<string> { return instance->hasFormats(); }
auto hasSmooth() -> bool { return instance->hasSmooth(); }
auto hasShader() -> bool { return instance->hasShader(); }
auto hasFormat(string format) -> bool { return instance->hasFormat(format); }
@@ -73,7 +75,6 @@ struct Video {
auto blocking() -> bool { return instance->blocking; }
auto flush() -> bool { return instance->flush; }
auto format() -> string { return instance->format; }
auto smooth() -> bool { return instance->smooth; }
auto shader() -> string { return instance->shader; }
auto setExclusive(bool exclusive) -> bool;
@@ -81,9 +82,9 @@ struct Video {
auto setBlocking(bool blocking) -> bool;
auto setFlush(bool flush) -> bool;
auto setFormat(string format) -> bool;
auto setSmooth(bool smooth) -> bool;
auto setShader(string shader) -> bool;
auto configure(uint width, uint height, double inputFrequency, double outputFrequency) -> bool;
auto clear() -> void;
auto acquire(uint32_t*& data, uint& pitch, uint width, uint height) -> bool;
auto release() -> void;

View File

@@ -18,7 +18,6 @@ struct VideoWGL : VideoDriver, OpenGL {
auto hasContext() -> bool override { return true; }
auto hasBlocking() -> bool override { return true; }
auto hasFlush() -> bool override { return true; }
auto hasSmooth() -> bool override { return true; }
auto hasShader() -> bool override { return true; }
auto setContext(uintptr context) -> bool override {
@@ -34,14 +33,8 @@ struct VideoWGL : VideoDriver, OpenGL {
return true;
}
auto setSmooth(bool) -> bool override {
if(!self.shader) OpenGL::filter = self.smooth ? GL_LINEAR : GL_NEAREST;
return true;
}
auto setShader(string) -> bool override {
auto setShader(string shader) -> bool override {
OpenGL::setShader(self.shader);
if(!self.shader) OpenGL::filter = self.smooth ? GL_LINEAR : GL_NEAREST;
return true;
}
@@ -104,7 +97,7 @@ private:
}
if(wglSwapInterval) wglSwapInterval(self.blocking);
return _ready = OpenGL::initialize();
return _ready = OpenGL::initialize(self.shader);
}
auto terminate() -> void {

View File

@@ -21,12 +21,29 @@ struct VideoXShm : VideoDriver {
auto ready() -> bool override { return _ready; }
auto hasContext() -> bool override { return true; }
auto hasSmooth() -> bool override { return true; }
auto hasShader() -> bool override { return true; }
auto hasFormats() -> vector<string> override { return {"RGB24"}; }
auto setContext(uintptr context) -> bool override { return initialize(); }
auto setSmooth(bool smooth) -> bool override { return true; }
auto setShader(string shader) -> bool override { return true; }
auto configure(uint width, uint height, double inputFrequency, double outputFrequency) -> bool override {
_outputWidth = width;
_outputHeight = height;
XResizeWindow(_display, _window, _outputWidth, _outputHeight);
free();
_shmInfo.shmid = shmget(IPC_PRIVATE, _outputWidth * _outputHeight * sizeof(uint32_t), IPC_CREAT | 0777);
if(_shmInfo.shmid < 0) return false;
_shmInfo.shmaddr = (char*)shmat(_shmInfo.shmid, 0, 0);
_shmInfo.readOnly = False;
XShmAttach(_display, &_shmInfo);
_outputBuffer = (uint32_t*)_shmInfo.shmaddr;
_image = XShmCreateImage(_display, _visual, _depth, ZPixmap, _shmInfo.shmaddr, &_shmInfo, _outputWidth, _outputHeight);
return true;
}
auto clear() -> void override {
auto dp = _inputBuffer;
@@ -65,7 +82,7 @@ struct VideoXShm : VideoDriver {
uint32_t* sp = _inputBuffer + (uint)ystep * _inputWidth;
uint32_t* dp = _outputBuffer + y * _outputWidth;
if(!self.smooth) {
if(self.shader != "Blur") {
for(uint x = 0; x < _outputWidth; x++) {
*dp++ = 255u << 24 | sp[(uint)xstep];
xstep += xratio;
@@ -145,23 +162,6 @@ private:
}
auto size() -> bool {
XWindowAttributes windowAttributes;
XGetWindowAttributes(_display, (Window)self.context, &windowAttributes);
if(_outputBuffer && _outputWidth == windowAttributes.width && _outputHeight == windowAttributes.height) return true;
_outputWidth = windowAttributes.width;
_outputHeight = windowAttributes.height;
XResizeWindow(_display, _window, _outputWidth, _outputHeight);
free();
_shmInfo.shmid = shmget(IPC_PRIVATE, _outputWidth * _outputHeight * sizeof(uint32_t), IPC_CREAT | 0777);
if(_shmInfo.shmid < 0) return false;
_shmInfo.shmaddr = (char*)shmat(_shmInfo.shmid, 0, 0);
_shmInfo.readOnly = False;
XShmAttach(_display, &_shmInfo);
_outputBuffer = (uint32_t*)_shmInfo.shmaddr;
_image = XShmCreateImage(_display, _visual, _depth, ZPixmap, _shmInfo.shmaddr, &_shmInfo, _outputWidth, _outputHeight);
return true;
}

View File

@@ -12,6 +12,7 @@ struct VideoXVideo : VideoDriver {
~VideoXVideo() { terminate(); }
auto create() -> bool override {
super.setShader("Blur");
return initialize();
}