summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoriCatButler <i.am.catbutler@gmail.com>2016-03-30 15:07:35 +0100
committeriCatButler <i.am.catbutler@gmail.com>2016-03-30 15:07:35 +0100
commit8b4350fee747708ffd376744ef5dc1e239a87ba6 (patch)
treea9ab6e2f25e06edc7c668353f8000856704f7fa3 /plugins
parente3df273095a5800e3dcdcb63bd66e269c0c2d3a8 (diff)
downloadpcsxr-8b4350fee747708ffd376744ef5dc1e239a87ba6.tar.gz
Bring up to date with PCSX-R master (97809)
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/dfinput/cfg-gtk.c4
-rwxr-xr-xplugins/dfinput/cfg.c20
-rwxr-xr-xplugins/dfinput/pad.h2
-rwxr-xr-xplugins/dfxvideo/draw.c63
-rwxr-xr-xplugins/dfxvideo/fps.c22
-rwxr-xr-xplugins/dfxvideo/gpu.c70
-rwxr-xr-xplugins/peopsxgl/fps.c49
7 files changed, 156 insertions, 74 deletions
diff --git a/plugins/dfinput/cfg-gtk.c b/plugins/dfinput/cfg-gtk.c
index eba56d8a..5f26040f 100755
--- a/plugins/dfinput/cfg-gtk.c
+++ b/plugins/dfinput/cfg-gtk.c
@@ -61,7 +61,9 @@ const char *EmuKeyText[EMU_TOTAL] = {
N_("Save state"),
N_("Screenshot"),
N_("Escape"),
- N_("Rewind")
+ N_("Rewind"),
+ N_("Alt Speed 1"),
+ N_("Alt Speed 2")
};
const char *DPadText[DKEY_TOTAL] = {
diff --git a/plugins/dfinput/cfg.c b/plugins/dfinput/cfg.c
index 2757bd74..f1d16673 100755
--- a/plugins/dfinput/cfg.c
+++ b/plugins/dfinput/cfg.c
@@ -126,6 +126,8 @@ static void SetDefaultConfig() {
g.cfg.E.EmuDef[EMU_SCREENSHOT].EmuKeyEvent = XK_F8;
g.cfg.E.EmuDef[EMU_ESCAPE].EmuKeyEvent = XK_Escape;
g.cfg.E.EmuDef[EMU_REWIND].EmuKeyEvent = XK_BackSpace;
+ g.cfg.E.EmuDef[EMU_ALTSPEED1].EmuKeyEvent = XK_bracketleft;
+ g.cfg.E.EmuDef[EMU_ALTSPEED2].EmuKeyEvent = XK_bracketright;
}
void LoadPADConfig() {
@@ -199,6 +201,16 @@ void LoadPADConfig() {
g.cfg.E.EmuDef[EMU_REWIND].Mapping.Key = a;
g.cfg.E.EmuDef[EMU_REWIND].Mapping.JoyEvType = b;
g.cfg.E.EmuDef[EMU_REWIND].Mapping.J.d = c;
+ } else if (strncmp(buf, "EMU_ALTSPEED1=", 14) == 0) {
+ sscanf(buf, "EMU_ALTSPEED1=%d,%d,%d", &a, &b, &c);
+ g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.Key = a;
+ g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.JoyEvType = b;
+ g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.J.d = c;
+ } else if (strncmp(buf, "EMU_ALTSPEED2=", 14) == 0) {
+ sscanf(buf, "EMU_ALTSPEED2=%d,%d,%d", &a, &b, &c);
+ g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.Key = a;
+ g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.JoyEvType = b;
+ g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.J.d = c;
} else if (strncmp(buf, "Select=", 7) == 0) {
sscanf(buf, "Select=%d,%d,%d", &a, &b, &c);
g.cfg.PadDef[current].KeyDef[DKEY_SELECT].Key = a;
@@ -437,5 +449,13 @@ void SavePADConfig() {
fprintf(fp, "EMU_REWIND=%d,%d,%d\n", g.cfg.E.EmuDef[EMU_REWIND].Mapping.Key,
g.cfg.E.EmuDef[EMU_REWIND].Mapping.JoyEvType,
g.cfg.E.EmuDef[EMU_REWIND].Mapping.J.d);
+ fprintf(fp, "EMU_ALTSPEED1=%d,%d,%d\n",
+ g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.Key,
+ g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.JoyEvType,
+ g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.J.d);
+ fprintf(fp, "EMU_ALTSPEED2=%d,%d,%d\n",
+ g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.Key,
+ g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.JoyEvType,
+ g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.J.d);
fclose(fp);
}
diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h
index fb5ca718..7cd8eefe 100755
--- a/plugins/dfinput/pad.h
+++ b/plugins/dfinput/pad.h
@@ -121,6 +121,8 @@ enum {
EMU_SCREENSHOT,
EMU_ESCAPE,
EMU_REWIND,
+ EMU_ALTSPEED1,
+ EMU_ALTSPEED2,
EMU_TOTAL
};
diff --git a/plugins/dfxvideo/draw.c b/plugins/dfxvideo/draw.c
index 73d0fef8..3cc5e1c2 100755
--- a/plugins/dfxvideo/draw.c
+++ b/plugins/dfxvideo/draw.c
@@ -902,11 +902,10 @@ static XVisualInfo *myvisual;
Display *display;
static Colormap colormap;
Window window;
+Window overlay;
static GC hGC;
static XImage * Ximage;
-static XvImage * XCimage;
static XImage * XPimage=0;
-char * Xpixels;
char * pCaptionText;
static int fx=0;
@@ -949,16 +948,16 @@ void DestroyDisplay(void)
XFreeGC(display,hGC);
hGC = 0;
}
+ if (overlay)
+ {
+ XDestroyWindow(display, overlay);
+ overlay = 0;
+ }
if(Ximage)
{
XDestroyImage(Ximage);
Ximage=0;
}
- if(XCimage)
- {
- XFree(XCimage);
- XCimage=0;
- }
XShmDetach(display,&shminfo);
shmdt(shminfo.shmaddr);
@@ -1254,6 +1253,22 @@ void CreateDisplay(void)
return;
}
+ overlay=XCreateWindow(display,window,
+ iResX - 128,0,128,96,
+ 0,myvisual->depth,
+ InputOutput,myvisual->visual,
+ CWBorderPixel | CWBackPixel |
+ CWEventMask | CWDontPropagate |
+ CWColormap | CWCursor | CWEventMask,
+ &winattr);
+
+ if(!overlay)
+ {
+ fprintf(stderr,"Failed in XCreateWindow()!!!\n");
+ DestroyDisplay();
+ return;
+ }
+
delwindow = XInternAtom(display,"WM_DELETE_WINDOW",0);
XSetWMProtocols(display, window, &delwindow, 1);
@@ -1352,14 +1367,6 @@ void CreateDisplay(void)
else
color = 0;
- Xpixels = (char *)malloc(8*8*4);
- for(i = 0; i < 8*8; ++i)
- ((uint32_t *)Xpixels)[i] = color;
-
- XCimage = XvCreateImage(display,xv_port,xv_id,
- (char *)Xpixels, 8, 8);
-
-
/*
Allocate max that could be needed:
Big(est?) PSX res: 640x512
@@ -1676,6 +1683,7 @@ void DoBufferSwap(void)
_w, _h, //dst w,h
1
);
+ DisplayPic();
if(ulKeybits&KEY_SHOWFPS) //DisplayText(); c // paint menu text
{
@@ -1695,7 +1703,6 @@ void DoBufferSwap(void)
XDrawImageString(display,window,hGC,2,13,szDispBuf,strlen(szDispBuf));
}
- //if(XPimage) DisplayPic();
XFree(xvi);
}
@@ -1707,15 +1714,11 @@ void DoClearScreenBuffer(void) // CLEAR DX BUFFER
XGetGeometry(display, window, &_dw, (int *)&_d, (int *)&_d, &_w, &_h, &_d, &_d);
- XvPutImage(display, xv_port, window, hGC, XCimage,
- 0, 0, 8, 8, 0, 0, _w, _h);
//XSync(display,False);
}
void DoClearFrontBuffer(void) // CLEAR DX BUFFER
{/*
- XPutImage(display,window,hGC, XCimage,
- 0, 0, 0, 0, iResX, iResY);
XSync(display,False);*/
}
@@ -1877,9 +1880,7 @@ void CreatePic(unsigned char * pMem)
void DestroyPic(void)
{
if(XPimage)
- { /*
- XPutImage(display,window,hGC, XCimage,
- 0, 0, 0, 0, iResX, iResY);*/
+ {
XDestroyImage(XPimage);
XPimage=0;
}
@@ -1887,8 +1888,20 @@ void DestroyPic(void)
void DisplayPic(void)
{
- XPutImage(display,window,hGC, XPimage,
- 0, 0, iResX-128, 0,128,96);
+ static int mapped = 0;
+ if (XPimage) {
+ if (!mapped) {
+ XMapWindow(display, overlay);
+ mapped = 1;
+ }
+ XPutImage(display,overlay,hGC, XPimage,
+ 0,0, 0,0, 128,96);
+ } else {
+ if (mapped) {
+ XUnmapWindow(display, overlay);
+ mapped = 0;
+ }
+ }
}
void ShowGpuPic(void)
diff --git a/plugins/dfxvideo/fps.c b/plugins/dfxvideo/fps.c
index 2edcd30b..621c4963 100755
--- a/plugins/dfxvideo/fps.c
+++ b/plugins/dfxvideo/fps.c
@@ -36,8 +36,16 @@ BOOL bInitCap = TRUE;
float fps_skip = 0;
float fps_cur = 0;
+float speed = 1;
+
#define MAXLACE 16
+void CALLBACK GPUsetSpeed(float newSpeed) {
+ if (newSpeed > 0 && newSpeed <= 1000) {
+ speed = newSpeed;
+ }
+}
+
void CheckFrameRate(void)
{
if(UseFrameSkip) // skipping mode?
@@ -74,6 +82,7 @@ void FrameCap (void)
{
static unsigned long curticks, lastticks, _ticks_since_last_update;
static unsigned int TicksToWait = 0;
+ unsigned int frTicks = dwFrameRateTicks / speed;
int overslept=0, tickstogo=0;
BOOL Waiting = TRUE;
@@ -86,10 +95,10 @@ void FrameCap (void)
{
lastticks = curticks;
overslept = _ticks_since_last_update - TicksToWait;
- if((_ticks_since_last_update-TicksToWait) > dwFrameRateTicks)
+ if((_ticks_since_last_update-TicksToWait) > frTicks)
TicksToWait=0;
else
- TicksToWait=dwFrameRateTicks - overslept;
+ TicksToWait=frTicks - overslept;
}
else
{
@@ -104,7 +113,7 @@ void FrameCap (void)
Waiting = FALSE;
lastticks = curticks;
overslept = _ticks_since_last_update - TicksToWait;
- TicksToWait = dwFrameRateTicks - overslept;
+ TicksToWait = frTicks - overslept;
return;
}
if (tickstogo >= 200 && !(dwActFixes&16))
@@ -123,6 +132,7 @@ void FrameSkip(void)
static DWORD curticks, lastticks, _ticks_since_last_update;
int tickstogo=0;
static int overslept=0;
+ unsigned int frTicks = dwFrameRateTicks / speed;
if(!dwLaceCnt) return; // important: if no updatelace happened, we ignore it completely
@@ -146,12 +156,12 @@ void FrameSkip(void)
curticks = timeGetTime(); // -> now we calc the time of the last drawn frame + the time we spent skipping
_ticks_since_last_update= dwT+curticks - lastticks;
- dwWaitTime=dwLastLace*dwFrameRateTicks; // -> and now we calc the time the real psx would have needed
+ dwWaitTime=dwLastLace*frTicks; // -> and now we calc the time the real psx would have needed
if(_ticks_since_last_update<dwWaitTime) // -> we were too fast?
{
if((dwWaitTime-_ticks_since_last_update)> // -> some more security, to prevent
- (60*dwFrameRateTicks)) // wrong waiting times
+ (60*frTicks)) // wrong waiting times
_ticks_since_last_update=dwWaitTime;
while(_ticks_since_last_update<dwWaitTime) // -> loop until we have reached the real psx time
@@ -188,7 +198,7 @@ void FrameSkip(void)
_ticks_since_last_update = curticks - lastticks;
dwLastLace=dwLaceCnt; // store curr count (frame limitation helper)
- dwWaitTime=dwLaceCnt*dwFrameRateTicks; // calc the 'real psx lace time'
+ dwWaitTime=dwLaceCnt*frTicks; // calc the 'real psx lace time'
if (dwWaitTime >= overslept)
dwWaitTime-=overslept;
diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c
index 8e23be85..2ee92e78 100755
--- a/plugins/dfxvideo/gpu.c
+++ b/plugins/dfxvideo/gpu.c
@@ -2219,46 +2219,53 @@ void CALLBACK GPUgetScreenPic(unsigned char * pMem)
// LINUX version:
-extern char * Xpixels;
-
void GPUgetScreenPic(unsigned char * pMem)
{
-/*
- unsigned short c;unsigned char * pf;int x,y;
-
- float XS=(float)iResX/128;
- float YS=(float)iResY/96;
-
- pf=pMem;
- memset(pMem, 0, 128*96*3);
-
- if(Xpixels)
- {
- unsigned char * ps=(unsigned char *)Xpixels;
- {
- long lPitch=iResX<<2;
- uint32_t sx;
-
- for(y=0;y<96;y++)
- {
- for(x=0;x<128;x++)
- {
- sx=*((uint32_t *)((ps)+
- (((int)((float)y*YS))*lPitch)+
- ((int)((float)x*XS))*4));
- *(pf+0)=(sx&0xff);
- *(pf+1)=(sx&0xff00)>>8;
- *(pf+2)=(sx&0xff0000)>>16;
- pf+=3;
- }
+ unsigned char *pf=pMem;
+ unsigned char *buf, *line, *pD;
+
+ int w = PreviousPSXDisplay.Range.x1, h = PreviousPSXDisplay.DisplayMode.y;
+ int x, y;
+ float XS = w / 128.0, YS = h / 96.0;
+ line = pf;
+ for (y = 0; y < 96; ++y) {
+ for (x = 0; x < 128; ++x) {
+ float r = 0, g = 0, b = 0, sr, sg, sb;
+ uint32_t cnt = 0, i, j;
+ for (j = 0; j < (int)((y+1)*YS) - (int)(y*YS); ++j) {
+ for (i = 0; i < (int)((x+1)*XS) - (int)(x*XS); ++i) {
+ pD = (unsigned char *)&psxVuw[(int)(y*YS +
+ PSXDisplay.DisplayPosition.y - 1 + j) * 1024 +
+ PSXDisplay.DisplayPosition.x] +
+ (PSXDisplay.RGB24 ? 3 : 2) * (int)(x*XS + i);
+ if (PSXDisplay.RGB24) {
+ uint32_t lu = *(uint32_t *)pD;
+ sr = RED(lu);
+ sg = GREEN(lu);
+ sb = BLUE(lu);
+ } else {
+ int32_t color = GETLE16(pD);
+ sr = (color << 3) & 0xf1;
+ sg = (color >> 2) & 0xf1;
+ sb = (color >> 7) & 0xf1;
+ }
+ r += sr * sr;
+ g += sg * sg;
+ b += sb * sb;
+ cnt += 1;
+ }
+ line[x * 3 + 2] = sqrt(r / cnt);
+ line[x * 3 + 1] = sqrt(g / cnt);
+ line[x * 3 + 0] = sqrt(b / cnt);
}
}
+ line += 128 * 3;
}
-
/////////////////////////////////////////////////////////////////////
// generic number/border painter
+ unsigned short c;
pf=pMem+(103*3); // offset to number rect
for(y=0;y<20;y++) // loop the number rect pixel
@@ -2289,7 +2296,6 @@ void GPUgetScreenPic(unsigned char * pMem)
*(pf+(127*3))=0xff;*pf++=0xff;
pf+=127*3; // offset to next line
}
-*/
}
#endif
diff --git a/plugins/peopsxgl/fps.c b/plugins/peopsxgl/fps.c
index 32eeb4c6..5b9f7449 100755
--- a/plugins/peopsxgl/fps.c
+++ b/plugins/peopsxgl/fps.c
@@ -36,6 +36,7 @@
BOOL bIsPerformanceCounter=FALSE;
float fFrameRateHz=0;
+float speed=1;
DWORD dwFrameRateTicks=16;
float fFrameRate;
int iFrameLimit;
@@ -64,7 +65,9 @@ void FrameCap(void)
{
static unsigned long curticks, lastticks, _ticks_since_last_update;
static unsigned long TicksToWait = 0;
+ double remTime;
bool Waiting = TRUE;
+ DWORD frTicks=(DWORD)(dwFrameRateTicks / speed);
{
curticks = timeGetTime();
@@ -75,9 +78,9 @@ void FrameCap(void)
{
lastticks = curticks;
- if((_ticks_since_last_update-TicksToWait) > dwFrameRateTicks)
+ if((_ticks_since_last_update-TicksToWait) > frTicks)
TicksToWait=0;
- else TicksToWait=dwFrameRateTicks-(_ticks_since_last_update-TicksToWait);
+ else TicksToWait=frTicks-(_ticks_since_last_update-TicksToWait);
}
else
{
@@ -85,13 +88,18 @@ void FrameCap(void)
{
curticks = timeGetTime();
_ticks_since_last_update = curticks - lastticks;
+ remTime = (TicksToWait - _ticks_since_last_update) * 1e6 / TIMEBASE;
if ((_ticks_since_last_update > TicksToWait) ||
(curticks < lastticks))
{
Waiting = FALSE;
lastticks = curticks;
- TicksToWait = dwFrameRateTicks;
+ TicksToWait = frTicks;
}
+ else if (remTime > 2)
+ {
+ usleep(remTime - 2);
+ }
}
}
}
@@ -105,9 +113,15 @@ void FrameSkip(void)
static int iNumSkips=0,iAdditionalSkip=0; // number of additional frames to skip
static DWORD dwLastLace=0; // helper var for frame limitation
static DWORD curticks, lastticks, _ticks_since_last_update;
+ DWORD frTicks=(DWORD)(dwFrameRateTicks / speed);
+ double remTime;
+ DWORD maxSkipTicks = 0;
if(!dwLaceCnt) return; // important: if no updatelace happened, we ignore it completely
+ if (speed > 1) {
+ maxSkipTicks = 1/30. * TIMEBASE;
+ }
if(iNumSkips) // we are in skipping mode?
{
dwLastLace+=dwLaceCnt; // -> calc frame limit helper (number of laces)
@@ -128,23 +142,28 @@ void FrameSkip(void)
curticks = timeGetTime();
_ticks_since_last_update= dwT+curticks - lastticks;
- dwWaitTime=dwLastLace*dwFrameRateTicks; // -> and now we calc the time the real psx would have needed
+ dwWaitTime=dwLastLace*frTicks; // -> and now we calc the time the real psx would have needed
if(_ticks_since_last_update<dwWaitTime) // -> we were too fast?
{
if((dwWaitTime-_ticks_since_last_update)> // -> some more security, to prevent
- (60*dwFrameRateTicks)) // wrong waiting times
+ (60*frTicks)) // wrong waiting times
_ticks_since_last_update=dwWaitTime;
while(_ticks_since_last_update<dwWaitTime) // -> loop until we have reached the real psx time
{ // (that's the additional limitation, yup)
+ remTime = (dwWaitTime - _ticks_since_last_update) * 1e6 / TIMEBASE;
+ if (remTime > 2) {
+ usleep(remTime - 2);
+ }
curticks = timeGetTime();
_ticks_since_last_update = dwT+curticks - lastticks;
}
}
else // we were still too slow ?!!?
{
- if(iAdditionalSkip<MAXSKIP) // -> well, somewhen we really have to stop skipping on very slow systems
+ if(iAdditionalSkip<MAXSKIP &&
+ _ticks_since_last_update<maxSkipTicks) // -> well, somewhen we really have to stop skipping on very slow systems
{
iAdditionalSkip++; // -> inc our watchdog var
dwLaceCnt=0; // -> reset lace count
@@ -170,7 +189,7 @@ void FrameSkip(void)
_ticks_since_last_update = curticks - lastticks;
dwLastLace=dwLaceCnt; // store curr count (frame limitation helper)
- dwWaitTime=dwLaceCnt*dwFrameRateTicks; // calc the 'real psx lace time'
+ dwWaitTime=dwLaceCnt*frTicks; // calc the 'real psx lace time'
if(_ticks_since_last_update>dwWaitTime) // hey, we needed way too long for that frame...
{
@@ -194,6 +213,10 @@ void FrameSkip(void)
while(_ticks_since_last_update<dwWaitTime) // just do a waiting loop...
{
+ remTime = (dwWaitTime - _ticks_since_last_update) * 1e6 / TIMEBASE;
+ if (remTime > 2) {
+ usleep(remTime - 2);
+ }
curticks = timeGetTime();
_ticks_since_last_update = curticks - lastticks;
}
@@ -247,8 +270,8 @@ void calcfps(void)
fps_cnt = 0;
fps_tck = 1;
- if(bUseFrameLimit && fps_cur>fFrameRateHz) // optical adjust ;) avoids flickering fps display
- fps_cur=fFrameRateHz;
+ if(bUseFrameLimit && fps_cur>fFrameRateHz * speed) // optical adjust ;) avoids flickering fps display
+ fps_cur=fFrameRateHz * speed;
}
}
@@ -267,7 +290,7 @@ void PCFrameCap (void)
{
Waiting = FALSE;
lastticks = curticks;
- TicksToWait = (TIMEBASE / (unsigned long)fFrameRateHz);
+ TicksToWait = (TIMEBASE / (unsigned long)(fFrameRateHz * speed));
}
}
}
@@ -380,6 +403,12 @@ void CheckFrameRate(void) // called in updatelace (
}
}
+void CALLBACK GPUsetSpeed(float newSpeed) {
+ if (newSpeed > 0 && newSpeed <= 1000) {
+ speed = newSpeed;
+ }
+}
+
void CALLBACK GPUsetframelimit(unsigned long option) // new EPSXE interface func: main emu can enable/disable fps limitation this way
{
bInitCap = TRUE;