mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-10-05 08:51:41 +02:00
**Known issues:** - button menus do not show up with Windows Vista/7 theme - snesreader's multi-file archive dialog box doesn't redraw itself on Windows when you choose different games Windows Qt is buggy as always. Nothing we can do but keep waiting. I'm also going to hold off on including pixel shaders until Direct3D PS support is in. It's just going to annoy the 98% of users who can't use them if I include them now. Yes, Windows OpenGL support is that bad. Anyway, from v058 wip10, the following changes were made: - cheat code editor grays out the slot#s when they are empty. I can't put "Empty" in the text boxes for various reasons. - added "Clear Selected" button and multi-selection support to cheat editor. This is meant to quickly erase all slots. - settings and tools windows start at 600x360 when bsnes.cfg is not found / empty - fixed the emulationSpeed section to start with input. instead of config. - open-folder concept requires the folders to end in .sfc to work now, once again doesn't care what the ROM inside is named (this is meant to mimic OS X .app folders) - 21fx API extended to map to $2200, $2201 for now; mostly as a test for A-bus access (21fx->VRAM DMA, etc) (old $21fx registers remain for now) I intend to release this on Saturday as-is even if a few small bugs are reported. But if there's something major we can make another RC build.
141 lines
3.4 KiB
C++
141 lines
3.4 KiB
C++
#include <sys/ipc.h>
|
|
#include <sys/shm.h>
|
|
#include <X11/extensions/Xv.h>
|
|
#include <X11/extensions/Xvlib.h>
|
|
#include <X11/extensions/XShm.h>
|
|
#include <SDL/SDL.h>
|
|
|
|
namespace ruby {
|
|
|
|
class pVideoSDL {
|
|
public:
|
|
Display *display;
|
|
SDL_Surface *screen, *buffer;
|
|
unsigned iwidth, iheight;
|
|
|
|
struct {
|
|
uintptr_t handle;
|
|
|
|
unsigned width;
|
|
unsigned height;
|
|
} settings;
|
|
|
|
bool cap(const string& name) {
|
|
if(name == Video::Handle) return true;
|
|
return false;
|
|
}
|
|
|
|
any get(const string& name) {
|
|
if(name == Video::Handle) return settings.handle;
|
|
return false;
|
|
}
|
|
|
|
bool set(const string& name, const any& value) {
|
|
if(name == Video::Handle) {
|
|
settings.handle = any_cast<uintptr_t>(value);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void resize(unsigned width, unsigned height) {
|
|
if(iwidth >= width && iheight >= height) return;
|
|
|
|
iwidth = max(width, iwidth);
|
|
iheight = max(height, iheight);
|
|
|
|
if(buffer) SDL_FreeSurface(buffer);
|
|
buffer = SDL_CreateRGBSurface(
|
|
SDL_SWSURFACE, iwidth, iheight, 32,
|
|
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000
|
|
);
|
|
}
|
|
|
|
bool lock(uint32_t *&data, unsigned &pitch, unsigned width, unsigned height) {
|
|
if(width != settings.width || height != settings.height) {
|
|
resize(settings.width = width, settings.height = height);
|
|
}
|
|
|
|
if(SDL_MUSTLOCK(buffer)) SDL_LockSurface(buffer);
|
|
pitch = buffer->pitch;
|
|
return data = (uint32_t*)buffer->pixels;
|
|
}
|
|
|
|
void unlock() {
|
|
if(SDL_MUSTLOCK(buffer)) SDL_UnlockSurface(buffer);
|
|
}
|
|
|
|
void clear() {
|
|
if(SDL_MUSTLOCK(buffer)) SDL_LockSurface(buffer);
|
|
for(unsigned y = 0; y < iheight; y++) {
|
|
uint32_t *data = (uint32_t*)buffer->pixels + y * (buffer->pitch >> 2);
|
|
for(unsigned x = 0; x < iwidth; x++) *data++ = 0xff000000;
|
|
}
|
|
if(SDL_MUSTLOCK(buffer)) SDL_UnlockSurface(buffer);
|
|
refresh();
|
|
}
|
|
|
|
void refresh() {
|
|
//ruby input is X8R8G8B8, top 8-bits are ignored.
|
|
//as SDL forces us to use a 32-bit buffer, we must set alpha to 255 (full opacity)
|
|
//to prevent blending against the window beneath when X window visual is 32-bits.
|
|
if(SDL_MUSTLOCK(buffer)) SDL_LockSurface(buffer);
|
|
for(unsigned y = 0; y < settings.height; y++) {
|
|
uint32_t *data = (uint32_t*)buffer->pixels + y * (buffer->pitch >> 2);
|
|
for(unsigned x = 0; x < settings.width; x++) *data++ |= 0xff000000;
|
|
}
|
|
if(SDL_MUSTLOCK(buffer)) SDL_UnlockSurface(buffer);
|
|
|
|
XWindowAttributes attributes;
|
|
XGetWindowAttributes(display, settings.handle, &attributes);
|
|
|
|
SDL_Rect src, dest;
|
|
|
|
src.x = 0;
|
|
src.y = 0;
|
|
src.w = settings.width;
|
|
src.h = settings.height;
|
|
|
|
dest.x = 0;
|
|
dest.y = 0;
|
|
dest.w = attributes.width;
|
|
dest.h = attributes.height;
|
|
|
|
SDL_SoftStretch(buffer, &src, screen, &dest);
|
|
SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
|
|
}
|
|
|
|
bool init() {
|
|
display = XOpenDisplay(0);
|
|
|
|
char env[512];
|
|
sprintf(env, "SDL_WINDOWID=%ld", (long int)settings.handle);
|
|
putenv(env);
|
|
|
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
screen = SDL_SetVideoMode(2560, 1600, 32, SDL_HWSURFACE);
|
|
|
|
buffer = 0;
|
|
iwidth = 0;
|
|
iheight = 0;
|
|
resize(settings.width = 256, settings.height = 256);
|
|
|
|
return true;
|
|
}
|
|
|
|
void term() {
|
|
XCloseDisplay(display);
|
|
SDL_FreeSurface(buffer);
|
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
}
|
|
|
|
pVideoSDL() {
|
|
settings.handle = 0;
|
|
}
|
|
};
|
|
|
|
DeclareVideo(SDL)
|
|
|
|
};
|