diff options
| author | iCatButler <i.am.catbutler@gmail.com> | 2016-03-30 15:07:35 +0100 |
|---|---|---|
| committer | iCatButler <i.am.catbutler@gmail.com> | 2016-03-30 15:07:35 +0100 |
| commit | 8b4350fee747708ffd376744ef5dc1e239a87ba6 (patch) | |
| tree | a9ab6e2f25e06edc7c668353f8000856704f7fa3 /plugins/dfxvideo | |
| parent | e3df273095a5800e3dcdcb63bd66e269c0c2d3a8 (diff) | |
| download | pcsxr-8b4350fee747708ffd376744ef5dc1e239a87ba6.tar.gz | |
Bring up to date with PCSX-R master (97809)
Diffstat (limited to 'plugins/dfxvideo')
| -rwxr-xr-x | plugins/dfxvideo/draw.c | 63 | ||||
| -rwxr-xr-x | plugins/dfxvideo/fps.c | 22 | ||||
| -rwxr-xr-x | plugins/dfxvideo/gpu.c | 70 |
3 files changed, 92 insertions, 63 deletions
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 |
