diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2009-04-16 06:22:51 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2009-04-16 06:22:51 +0000 |
| commit | 8139fbf8204882663446bcb06f68789353597820 (patch) | |
| tree | 6ea1f39932b33faee84d603e956470e37f135804 /plugins/dfOpenGL | |
| download | pcsxr-8139fbf8204882663446bcb06f68789353597820.tar.gz | |
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@23061 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfOpenGL')
| -rw-r--r-- | plugins/dfOpenGL/AUTHORS | 5 | ||||
| -rw-r--r-- | plugins/dfOpenGL/GPU.c | 1014 | ||||
| -rw-r--r-- | plugins/dfOpenGL/GPU.h | 1 | ||||
| -rw-r--r-- | plugins/dfOpenGL/Makefile.am | 22 | ||||
| -rw-r--r-- | plugins/dfOpenGL/Makefile.in | 602 | ||||
| -rw-r--r-- | plugins/dfOpenGL/PSEmu_PlugIn_Defs.h | 121 | ||||
| -rw-r--r-- | plugins/dfOpenGL/TODO | 31 | ||||
| -rw-r--r-- | plugins/dfOpenGL/cfg.c | 106 | ||||
| -rw-r--r-- | plugins/dfOpenGL/cfg.h | 10 | ||||
| -rw-r--r-- | plugins/dfOpenGL/fps.c | 41 | ||||
| -rw-r--r-- | plugins/dfOpenGL/gllog.c | 43 | ||||
| -rw-r--r-- | plugins/dfOpenGL/gpu_i.h | 208 | ||||
| -rw-r--r-- | plugins/dfOpenGL/gpucfg-0.1df/dfopengl.glade2 | 272 | ||||
| -rw-r--r-- | plugins/dfOpenGL/gpucfg-0.1df/main.c | 261 | ||||
| -rw-r--r-- | plugins/dfOpenGL/oldMakefile | 32 | ||||
| -rw-r--r-- | plugins/dfOpenGL/primitive_drawing.c | 1710 | ||||
| -rw-r--r-- | plugins/dfOpenGL/primitive_drawing.h | 3 |
17 files changed, 4482 insertions, 0 deletions
diff --git a/plugins/dfOpenGL/AUTHORS b/plugins/dfOpenGL/AUTHORS new file mode 100644 index 00000000..84b50402 --- /dev/null +++ b/plugins/dfOpenGL/AUTHORS @@ -0,0 +1,5 @@ +This plugin is based on (built around) gpuZenOpenGL by CitiZen X (1998). +GPL'd by permission September 23, 2007. +Many hints taken from Pete Bernert's GPL soft gpu plugin. + +Stephen Chao <stephen@digitalnexus.org> diff --git a/plugins/dfOpenGL/GPU.c b/plugins/dfOpenGL/GPU.c new file mode 100644 index 00000000..4776f47b --- /dev/null +++ b/plugins/dfOpenGL/GPU.c @@ -0,0 +1,1014 @@ +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> +#include <string.h> +#include <stdint.h> +#include <assert.h> + +#define GPU_INTERNALS_DEF +#include "gpu_i.h" +#include "primitive_drawing.h" +#include "cfg.h" +#include "PSEmu_PlugIn_Defs.h" + +#include <X11/extensions/xf86vmode.h> + +#define CALLBACK + +// PPDK developer must change libraryName field and can change revision and build + +const unsigned char version = PLUGIN_VERSION; // do not touch - library for PSEmu 1.x + +// it is up to developer but values must be in range 0-255 + +const unsigned char revision = 1; +const unsigned char build = 0; + +// to obtain library name for your plugin, mail: plugin@psemu.com +// this must be unique, and only we can provide this +static char *libraryName = "PCSX-df OpenGL Plugin"; + +float scalarDispWidth,scalarDispHeight; +float scalarDrawWidth,scalarDrawHeight; + + +// driver dependant variables +GpuConfS gpuConfig; + +static int initGPU = 0; +static int ScreenOpened = 0; + +#define RED(x) (x & 0xff) +#define BLUE(x) ((x>>16) & 0xff) +#define GREEN(x) ((x>>8) & 0xff) + +#define COLOR(x) (x & 0xffffff) + +// macros for easy access to packet information +#define GPUCOMMAND(x) ((x>>24) & 0xff) + +// memory image of the PSX vram +unsigned char psxVub[1024*520*2]; +signed char *psxVsb; +unsigned short *psxVuw; +signed short *psxVsw; +uint32_t *psxVul; +int32_t *psxVsl; + +int flip; + +// internal GPU + +static int32_t GPUdataRet; +int32_t GPUstatusRet; +int32_t GPUInfoVals[16]; + +static uint32_t gpuData[100]; +static unsigned char gpuCommand = 0; +static int32_t gpuDataC = 0; +static int32_t gpuDataP = 0; + +int drawingLines; + +VRAMLoad_t vramWrite; +struct PSXDisplay_t psxDisp, oldpsxDisp; +struct PSXDraw_t psxDraw; + +short dispWidths[8] = {256,320,512,640,368,384,512,640}; + +int dispLace = 0; +int dispLaceNew; +int imageTransfer; +int drawLace; + +#define FRAMES 16 +GLuint drawrec; +int drawreccount; + +short imTYc,imTXc,imTY,imTX; +int imSize; +short imageX0,imageX1; +short imageY0,imageY1; + +unsigned short textBuf[512*512]; +int newTextX0,newTextX1,newTextX2,newTextX3; +int newTextY0,newTextY1,newTextY2,newTextY3; + +GLuint xferTexture16 = 0; +GLuint xferTexture24 = 0; + +uint32_t gpuDataX; + + +typedef struct +{ + Display *dpy; + int screen; + Window win; + GLXContext ctx; + XSetWindowAttributes attr; + BOOL fs; + XF86VidModeModeInfo deskMode; + int x,y; + unsigned int width, height; + unsigned int bpp; +}GLWindow; + +static GLWindow GLWin; /* Set our OpenGL Window to static, we only want one */ + + + +char * CALLBACK PSEgetLibName(void) +{ + return libraryName; +} + +unsigned long CALLBACK PSEgetLibType(void) +{ + return PSE_LT_GPU; +} + +unsigned long CALLBACK PSEgetLibVersion(void) +{ + return version<<16|revision<<8|build; +} + + + + +long CALLBACK GPUinit() +{ + //if(capcom fighting game) dispWidths[4]=384; + //else dispWidths[4]=368; + + /* Set default configuration values */ + gpuConfig.bFullscreen=FALSE; + gpuConfig.bBilinear=FALSE; + gpuConfig.nMaxTextures=64; + gpuConfig.bWireFrame=FALSE; + gpuConfig.bAntialias=FALSE; + gpuConfig.bClearScreen=FALSE; + gpuConfig.FrameLimit=1; + + /* Read in values from the config file */ + readconfig(); + + // mapping the VRAM + psxVsb=(signed char *)psxVub; + psxVsw=(signed short *)psxVub; + psxVsl=(int32_t *)psxVub; + psxVuw=(unsigned short *)psxVub; + psxVul=(uint32_t *)psxVub; + + GPUstatusRet = 0x74000000; + memset(GPUInfoVals,0x00,16*sizeof(uint32_t)); + + return PSE_ERR_SUCCESS; +} + + +long CALLBACK GPUshutdown() +{ + if(initGPU==1) + { + initGPU=0; + } + return 0; +} + + +void DoGLInit(){ + int i; + + glViewport(0,0,gpuConfig.windowX,gpuConfig.windowY); + /* + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glScalef(1.0f,-1.0f,1.0f); + glOrtho(0.0,1024,0.0,512,1.0,-1.0); + */ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glScalef(1.0f/256.0f,1.0f/256.0f,1.0f); + //glTranslatef(0.5f, 0.5f, 0); + + glEnable(GL_CLIP_PLANE0); + glEnable(GL_CLIP_PLANE1); + glEnable(GL_CLIP_PLANE2); + glEnable(GL_CLIP_PLANE3); + glEnable(GL_BLEND); + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); + if(gpuConfig.bAntialias){ + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POLYGON_SMOOTH); + } + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + + glEnable(GL_TEXTURE_2D); + for(i=0;i<gpuConfig.nMaxTextures;i++){ + texture[i].textAddrX=0; + texture[i].textAddrY=0; + texture[i].textTP=0; + texture[i].clutP=nullclutP; + texture[i].Update=FALSE; + glGenTextures(1,&texture[i].id); + glBindTexture(GL_TEXTURE_2D,texture[i].id); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); + if(gpuConfig.bBilinear){ + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + }else{ + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + } + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); + glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,image); + } + + glGenTextures(1,&xferTexture24); + glBindTexture(GL_TEXTURE_2D,xferTexture24); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexImage2D(GL_TEXTURE_2D,0,3,1024,512,0,GL_RGB,GL_UNSIGNED_BYTE,0); + + glGenTextures(1,&xferTexture16); + glBindTexture(GL_TEXTURE_2D,xferTexture16); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexImage2D(GL_TEXTURE_2D,0,4,1024,512,0,GL_RGBA,GL_UNSIGNED_BYTE,0); + + glGenTextures(1,&nullid); + glBindTexture(GL_TEXTURE_2D,nullid); + glTexImage2D(GL_TEXTURE_2D,0,4,0,0,0,GL_RGBA,GL_UNSIGNED_BYTE,0); + + glClearColor(0.0f,0.0f,0.0f,0.0f); + glClear(GL_COLOR_BUFFER_BIT); + + if(gpuConfig.bWireFrame) + glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); + + drawrec = glGenLists(FRAMES); + glNewList(drawrec, GL_COMPILE); + drawreccount=0; + + + //black is reversed: transparent when STP not set, opaque when set + torgba[0]=0x00000000; + for(i=1;i<65536;i++){ + torgba[i] =(i&0x001f)<<3; + torgba[i]|=(i&0x03e0)<<6; + torgba[i]|=(i&0x7c00)<<9; + torgba[i]|=0xfe000000; + if (!(i&0x8000)) + torgba[i]|=0xff000000; + //torgba[i]|=0xff000000; + } + torgba[0x8000] = 0xff000000; + + for(i=0; i<128; i++) + texshade[i]=i<<1; + for(i=128; i<256; i++) + texshade[i]=255; + + gllog(0,(char*)glGetString(GL_VENDOR)); + gllog(0,(char*)glGetString(GL_RENDERER)); + gllog(0,(char*)glGetString(GL_VERSION)); + gllog(0,(char*)glGetString(GL_EXTENSIONS)); +} + +long CALLBACK GPUopen(unsigned long * disp,char * CapText,char * CfgFile) +{ + int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER, + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + None}; + + XVisualInfo *vi; + Colormap cmap; + int dpyWidth, dpyHeight; + int i; + int vidModeMajorVersion, vidModeMinorVersion; + XF86VidModeModeInfo **modes; + int modeNum; + int bestMode; + Atom wmDelete; + Window winDummy; + unsigned int borderDummy; + + GLWin.fs = gpuConfig.bFullscreen; + bestMode = 0; + + GLWin.dpy = XOpenDisplay(0); + GLWin.screen = DefaultScreen(GLWin.dpy); + XF86VidModeQueryVersion(GLWin.dpy, &vidModeMajorVersion, + &vidModeMinorVersion); + + XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes); + + GLWin.deskMode = *modes[0]; + + for (i = 0; i < modeNum; i++) + { + if ((modes[i]->hdisplay == gpuConfig.windowX) && (modes[i]->vdisplay == gpuConfig.windowY)) + { + bestMode = i; + } + } + + vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDbl); + if (vi == NULL) + { + printf("Visual not found\n"); + exit(0); + } + + GLWin.ctx = glXCreateContext(GLWin.dpy, vi, 0, GL_TRUE); + + cmap = XCreateColormap(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),vi->visual, AllocNone); + GLWin.attr.colormap = cmap; + GLWin.attr.border_pixel = 0; + + GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | + ButtonPressMask | ButtonReleaseMask | StructureNotifyMask; + + + if(GLWin.fs) + { + XF86VidModeSwitchToMode(GLWin.dpy, GLWin.screen, modes[bestMode]); + XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0); + dpyWidth = modes[bestMode]->hdisplay; + dpyHeight = modes[bestMode]->vdisplay; + XFree(modes); + GLWin.attr.override_redirect = True; + GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), + 0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, + &GLWin.attr); + XWarpPointer(GLWin.dpy, None, GLWin.win, 0, 0, 0, 0, 0, 0); + XMapRaised(GLWin.dpy, GLWin.win); + XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync,GrabModeAsync, CurrentTime); + XGrabPointer(GLWin.dpy, GLWin.win, True, ButtonPressMask, + GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime); + } + else + { + GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), + 0, 0, gpuConfig.windowX, gpuConfig.windowY, 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask, &GLWin.attr); + wmDelete = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True); + XSetWMProtocols(GLWin.dpy, GLWin.win, &wmDelete, 1); + XSetStandardProperties(GLWin.dpy, GLWin.win, CapText, + CapText, None, NULL, 0, NULL); + XMapRaised(GLWin.dpy, GLWin.win); + } + + glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); + XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y, + &GLWin.width, &GLWin.height, &borderDummy, &GLWin.bpp); + + printf("Direct Rendering: %s\n",glXIsDirect(GLWin.dpy, GLWin.ctx) ? "true" : "false"); + printf("Running in %s mode\n",GLWin.fs ? "fullscreen" : "window"); + + if(disp) + *disp=(long)GLWin.dpy; // wanna x pointer? ok + + ScreenOpened=1; + + DoGLInit(); + + return 0; +} + +long CALLBACK GPUclose() +{ + if(GLWin.ctx) + { + if(!glXMakeCurrent(GLWin.dpy, None, NULL)) + { + printf("Error releasing drawing context : killGLWindow\n"); + } + glXDestroyContext(GLWin.dpy, GLWin.ctx); + GLWin.ctx = NULL; + } + + if(GLWin.fs) + { + XF86VidModeSwitchToMode(GLWin.dpy, GLWin.screen, &GLWin.deskMode); + XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0); + } + XCloseDisplay(GLWin.dpy); + + return 0; +} + +bool db=FALSE; + + +void waitforrealtime(); + +/* +Here's how playstation double buffering works: +1) Vsync +2) Set buffer selection (via status 0x05) (psxDisp.startX & Y) +3) (Possibly) swap draw area, and draw. +1) Vsync +... + +The problem arises in step 3 when drawing is done in the back buffer while step 2 and the subsequent vsync shows the front. +Current solution is to record the draw commands (3), wait till (2), then playback the draw into the now-known buffer. +During vsync we output the most recent frame (3) to catch any offscreen drawing. This means we draw everything twice...but at least most of it will be clipped. + +*/ + +void updateScreenMode() +{ + int i=0; + + glEndList(); + + if(psxDisp.modeX>0 && psxDisp.modeY>0) + { + int height = (psxDisp.rangeY2-psxDisp.rangeY1) * ((int)psxDisp.interlaced+1); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glScalef(1.0f,-1.0f,1.0f); + glOrtho(psxDisp.startX, psxDisp.startX + psxDisp.modeX, + psxDisp.startY, psxDisp.startY + height, 1.0,-1.0); + //glOrtho(0,(double)1024,0,(double)768,1.0,-1.0); + //glOrtho(0,psxDisp.modeX,0,psxDisp.modeY,1.0,-1.0); + + //glMatrixMode(GL_MODELVIEW); + //glLoadIdentity(); + //glPushMatrix(); + //glTranslatef(-oldpsxDisp.startX, -oldpsxDisp.startY, 0); + for(i=0;i<=drawreccount;i++) + { + glCallList(drawrec+i); + //glXSwapBuffers(GLWin.dpy, GLWin.win); + } + drawreccount=0; + //glPopMatrix(); + } + + glNewList(drawrec,GL_COMPILE); +} + +void updateDisplay(void) +{ + glEndList(); + + glCallList(drawrec+drawreccount); + glFlush(); + if (gpuConfig.FrameLimit) + waitforrealtime(); + + glXSwapBuffers(GLWin.dpy, GLWin.win); + + drawreccount++; + drawreccount%=FRAMES; + + glNewList(drawrec+drawreccount,GL_COMPILE); +} + +// update lace is called every VSync +void CALLBACK GPUupdateLace(void) +{ + //if(dispLace) + //{ + drawingLines^=1; + //if(psxDisp.modeX>0 && psxDisp.modeY>0) + //{ + //gllog(0,"UPDATING LACE"); + updateDisplay(); + //} + //} +} + + +// process read request from GPU status register +unsigned long CALLBACK GPUreadStatus(void) +{ + // return the status of the GPU + /* + - gp1 - GPU Status + Mask + 04000000 - 1:Idle 0:Busy + 10000000 - 1:Ready 0:Not ready , to receive commands. + 80000000 - GPU is drawing 1:Odd 0:Even lines, in interlaced mode. + */ + //just'0x74000000' for now ! (idle, ready, even lines) + if (drawingLines==1) + return GPUstatusRet; + else + return GPUstatusRet|0x80000000; + //return 0x74000000; +} + + +// processes data send to GPU status register +// these are always single packet commands. +void CALLBACK GPUwriteStatus(uint32_t gdata) +{ + switch((gdata>>24)&0xff) + { + case 0x00: + memset(GPUInfoVals,0x00,16*sizeof(uint32_t)); + GPUstatusRet=0x14802000; + psxDisp.disabled = 1; + psxDraw.offsetX = psxDraw.offsetY = psxDraw.clipX1 = psxDraw.clipX2 = psxDraw.clipY1 = psxDraw.clipY2 = 0; + texinfo.mirror=0; + texinfo.x = texinfo.y = 0; + texinfo.colormode = texinfo.abr = 0; + psxDisp.colordepth24 = FALSE; + psxDisp.interlaced = FALSE; + psxDisp.changed = 1; + return; + case 0x03: + psxDisp.disabled = (gdata & 1); + if(psxDisp.disabled) + GPUstatusRet|=GPUSTATUS_DISPLAYDISABLED; + else GPUstatusRet&=~GPUSTATUS_DISPLAYDISABLED; + return; + case 0x04: + //gllog(77," GPU_S: TR_MODE: %x\n",gdata&0xffffff); + if((gdata&0xffffff)==0) imageTransfer=0; + if((gdata&0xffffff)==2) imageTransfer=3; + GPUstatusRet&=~GPUSTATUS_DMABITS; // Clear the current settings of the DMA bits + GPUstatusRet|=(gdata << 29); // Set the DMA bits according to the received data + return; + + case 0x05: + + oldpsxDisp.startY = psxDisp.startY; + oldpsxDisp.startX = psxDisp.startX; + + psxDisp.startY = (gdata>>10)&0x3ff; + psxDisp.startX = gdata & 0x3ff; + //gllog(77," GPU_S: DISPLAY SET: X=%d Y=%d\n",dispPosX,dispPosY); + + if (oldpsxDisp.startY != psxDisp.startY || oldpsxDisp.startX != psxDisp.startX) + psxDisp.changed = 1; + + updateScreenMode(); + + //if (dispLace==0) updateDisplay(); + return; + case 0x06: + psxDisp.rangeX1 = ( short ) ( gdata & 0x7ff ); + psxDisp.rangeX2 = ( short ) ( ( gdata>>12 ) & 0xfff ); + return; + case 0x07: + psxDisp.rangeY1 = ( short ) ( gdata & 0x3ff ); + psxDisp.rangeY2 = ( short ) ( ( gdata>>10 ) & 0x3ff ); + return; + case 0x08: + psxDisp.modeX = dispWidths[ (gdata&0x3)|((gdata&0x40)>>4) ]; + + if (gdata&0x04) psxDisp.modeY = 480; + else psxDisp.modeY = 240; + + psxDisp.colordepth24 = (gdata>>4)&0x1; // if 1 - TrueColor + if (psxDisp.colordepth24) + GPUstatusRet|=GPUSTATUS_RGB24; + else GPUstatusRet&=~GPUSTATUS_RGB24; + + psxDisp.pal = (gdata & 0x08)?TRUE:FALSE; // if 1 - PAL mode, else NTSC + if (psxDisp.pal) + GPUstatusRet|=GPUSTATUS_PAL; + else GPUstatusRet&=~GPUSTATUS_PAL; + + psxDisp.interlaced = (gdata>>5)&0x01; // if 1 - Interlace + //gllog(77,"!GPU! DISPLAY SET: W=%d Wo=%d H=%d TRUE=%d LACE=%d\n",dispHorNew,dispWidths[gdata&0x3],dispVerNew,dispColorNew,dispLaceNew); + if(psxDisp.modeY==480 && psxDisp.interlaced==1) drawLace = 1; + else drawLace = 0; + + psxDisp.changed = 1; + + return; + case 0x10: // ask about GPU version + gdata&=0xff; + + switch(gdata) + { + case 0x02: + GPUdataRet=GPUInfoVals[INFO_TW]; // tw infos + return; + case 0x03: + GPUdataRet=GPUInfoVals[INFO_DRAWSTART]; // draw start + return; + case 0x04: + GPUdataRet=GPUInfoVals[INFO_DRAWEND]; // draw end + return; + case 0x05: + case 0x06: + GPUdataRet=GPUInfoVals[INFO_DRAWOFF]; // draw offset + return; + case 0x07: + if(0) + GPUdataRet=0x01; + else GPUdataRet=0x02; // gpu type + return; + case 0x08: + case 0x0F: // some bios addr? + GPUdataRet=0xBFC03720; + return; + default: + gllog(77,"STATUS=%08x\n",gdata); + return; + } + return; + } + return; +} + +unsigned long CALLBACK GPUreadData(void) +{ + if(imageTransfer==2) + { + // **** + //imageTransfer = 0; + + // image transfer from VRAM + if ((imTY>=0) && (imTY<512) && (imTX>=0) && (imTX<1024)) + { + GPUdataRet=psxVul[imTY*512+imTX/2]; + //gllog(11,"RD: %08x",GPUdataRet); + } + imTX+=2; + imTXc-=2; + if(imTXc<=0) + { + imTX=imageX0; + imTXc=imageX1; + imTYc--; + imTY++; + } + imSize--; + if(imSize <= 0) + { + GPUstatusRet&=0xf7ffffff; + imageTransfer=0; + } + } + return GPUdataRet; +} + +void psx24torgba(char* s, int len) +{ + int i; + char *out = s; + char r1,g1,b1,r2,g2,b2; + + for (i=0; i<len; i+=2) + { + g1 = *s++; + r1 = *s++; + r2 = *s++; + b1 = *s++; + b2 = *s++; + g2 = *s++; + + *out++ = r1; + *out++ = g1; + *out++ = b1; + *out++ = r2; + *out++ = g2; + *out++ = b2; + } +} + +int PullFromPsxRam(uint32_t *pMem, int size) +{ + int count = 0; + unsigned short *input = (unsigned short*)pMem; + uint32_t *t = vramWrite.extratarget; + uint16_t *st = (uint16_t*)t; + + short x2 = vramWrite.x + vramWrite.w; + short y2 = vramWrite.y + vramWrite.h; + + unsigned short posx, posy; + + if (vramWrite.enabled == 0) { + imageTransfer = 0; + return 0; + } + + size <<=1; //multiply by 2 for int to short; + + while(vramWrite.cury < y2) + { + posy = (unsigned short) vramWrite.cury; + if (posy >= 512) + posy = 0; + while(vramWrite.curx < x2) + { + posx = (unsigned short) vramWrite.curx; + if (posx >= 1024) + posx = 0; + + if (!psxDisp.colordepth24) + *t++ = torgba[*input]; + else + *st++ = *input; + + psxVuw[(posy<<10)+posx] = *input; + + vramWrite.curx++; + count++; + input++; + + if (count == size) + { + if (vramWrite.curx == x2) + { + vramWrite.cury++; + vramWrite.curx=vramWrite.x; + } + goto NOMOREIMAGEDATA; + } + } + vramWrite.cury++; + vramWrite.curx=vramWrite.x; + } + +NOMOREIMAGEDATA: + if (vramWrite.cury >= y2) + { + float x,w; + + vramWrite.enabled = 0; + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + glScalef(1.0f/1024.0f,1.0f/512.0f,1.0f); + + if (psxDisp.colordepth24) + { + x=vramWrite.x*2/3; + w=vramWrite.w*2/3; + //psx24torgba((char*)vramWrite.extratarget, vramWrite.w*vramWrite.h*2/3); + glBindTexture(GL_TEXTURE_2D,xferTexture24); + glTexSubImage2D(GL_TEXTURE_2D,0,0,0,w,vramWrite.h,GL_RGB,GL_UNSIGNED_BYTE,vramWrite.extratarget); + } + else + { + x=vramWrite.x; + w=vramWrite.w; + glBindTexture(GL_TEXTURE_2D,xferTexture16); + glTexSubImage2D(GL_TEXTURE_2D,0,0,0,w,vramWrite.h,GL_RGBA,GL_UNSIGNED_BYTE,vramWrite.extratarget); + } + + glDisable(GL_BLEND); + glDisable(GL_CLIP_PLANE0); + glDisable(GL_CLIP_PLANE1); + glDisable(GL_CLIP_PLANE2); + glDisable(GL_CLIP_PLANE3); + + glColor3ub(255,255,255); + + glBegin(GL_POLYGON); + glTexCoord2s(0, 0); + glVertex2s(x,vramWrite.y); + + glTexCoord2s(w, 0); + glVertex2s(x+w,vramWrite.y); + + glTexCoord2s(w, vramWrite.h); + glVertex2s(x+w,vramWrite.y+vramWrite.h); + + glTexCoord2s(0, vramWrite.h); + glVertex2s(x,vramWrite.y+vramWrite.h); + glEnd(); + glEnable(GL_BLEND); + + glPopMatrix(); + + glEnable(GL_CLIP_PLANE0); + glEnable(GL_CLIP_PLANE1); + glEnable(GL_CLIP_PLANE2); + glEnable(GL_CLIP_PLANE3); + + + free(vramWrite.extratarget); + imageTransfer = 0; + if (count%2 == 1) + count++; + } + + return count>>1; //back from short to int +} + +void CALLBACK GPUwriteDataMem(uint32_t * pMem, int iSize) +{ + unsigned char command; + int i = 0; + uint32_t gdata; + + GPUIsBusy; + GPUIsNotReadyForCommands; + + for(;i<iSize;) + { + if((imageTransfer & 1) == 1) + { + i += PullFromPsxRam(pMem, iSize-i); + if (i >= iSize) + continue; + pMem += i; + } + + gdata=*pMem; + GPUdataRet=gdata; + pMem++; + i++; + + if(gpuDataC == 0) + { + command = (unsigned char) (gdata>>24) & 0xff; + if (primTableC[command]) + { + gpuDataC = primTableC[command]; + gpuCommand = command; + gpuData[0] = gdata; + gpuDataP = 1; + } + else + continue; + } + else + { + gpuData[gpuDataP] = gdata; + if ( gpuDataC>128 ) + { + if ( ( gpuDataC==254 && gpuDataP>=3 ) || + ( gpuDataC==255 && gpuDataP>=4 && ! ( gpuDataP&1 ) ) ) + { + if ( ( gpuData[gpuDataP] & 0xF000F000 ) == 0x50005000 ) + gpuDataP=gpuDataC-1; + } + } + gpuDataP++; + } + if(gpuDataP == gpuDataC) + { + gpuDataC=gpuDataP=0; + primTableJ[gpuCommand]((unsigned char *)gpuData); + } + } + + GPUdataRet=gdata; + + GPUIsReadyForCommands; + GPUIsIdle; +} + +void CALLBACK GPUwriteData(uint32_t gdata) +{ + GPUwriteDataMem(&gdata,1); +} + + +// this function will be removed soon +void CALLBACK GPUsetMode(uint32_t gdata) +{ + imageTransfer = gdata; + return; +} + +// this function will be removed soon +long CALLBACK GPUgetMode(void) +{ + return imageTransfer; +} + + +long CALLBACK GPUconfigure(void) +{ + ExecCfg ("CFG"); + return 0; +} + +uint32_t lUsedAddr[3]; + +__inline bool CheckForEndlessLoop(uint32_t laddr) +{ + if(laddr==lUsedAddr[1]) return TRUE; + if(laddr==lUsedAddr[2]) return TRUE; + + if(laddr<lUsedAddr[0]) lUsedAddr[1]=laddr; + else lUsedAddr[2]=laddr; + lUsedAddr[0]=laddr; + return FALSE; +} + +long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) +{ + uint32_t dmaMem; + unsigned char * baseAddrB; + short count;unsigned int DMACommandCounter = 0; + + lUsedAddr[0]=lUsedAddr[1]=lUsedAddr[2]=0xffffff; + + baseAddrB = (unsigned char*) baseAddrL; + + do + { + addr&=0x1FFFFC; + if(DMACommandCounter++ > 2000000) break; + if(CheckForEndlessLoop(addr)) break; + + count = baseAddrB[addr+3]; + + dmaMem=addr+4; + + if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count); + + addr = baseAddrL[addr>>2] & 0xffffff; + } + while (addr != 0xffffff); + + return 0; +} + +void CALLBACK GPUkeypressed(int keycode) +{ + switch ( keycode ) + { + case 0xFFC9: //X11 key: F12 + case ( ( 1<<29 ) | 0xFF0D ) : //special keycode from pcsx-df: alt-enter + //bChangeWinMode=TRUE; + break; + case 0xffc2: //F5 + //GPUmakeSnapshot(); + break; + case 0x60: //backtick ` + gpuConfig.FrameLimit = !gpuConfig.FrameLimit; + break; + } +} + + +void CALLBACK GPUabout(void) +{ + ExecCfg ("ABOUT"); +} + +long CALLBACK GPUtest(void) +{ + // if test fails this function should return negative value for error (unable to continue) + // and positive value for warning (can continue but output might be crappy) + return 0; +} + + +struct TGA_HEADER +{ + u8 identsize; // size of ID field that follows 18 u8 header (0 usually) + u8 colourmaptype; // type of colour map 0=none, 1=has palette + u8 imagetype; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed + + s16 colourmapstart; // first colour map entry in palette + s16 colourmaplength; // number of colours in palette + u8 colourmapbits; // number of bits per palette entry 15,16,24,32 + + s16 xstart; // image x origin + s16 ystart; // image y origin + s16 width; // image width in pixels + s16 height; // image height in pixels + u8 bits; // image bits per pixel 8,16,24,32 + u8 descriptor; // image descriptor bits (vh flip bits) + + // pixel data follows header + +} __attribute__((packed)); + + +bool SaveTGA(const char* filename, int width, int height, void* pdata) +{ + struct TGA_HEADER hdr; + FILE* f = fopen(filename, "wb"); + if( f == NULL ) + return 0; + + assert( sizeof(struct TGA_HEADER) == 18 && sizeof(hdr) == 18 ); + + memset(&hdr, 0, sizeof(hdr)); + hdr.imagetype = 2; + hdr.bits = 32; + hdr.width = width; + hdr.height = height; + hdr.descriptor |= 8|(1<<5); // 8bit alpha, flip vertical + + fwrite(&hdr, sizeof(hdr), 1, f); + fwrite(pdata, width*height*4, 1, f); + fclose(f); + return 1; +} diff --git a/plugins/dfOpenGL/GPU.h b/plugins/dfOpenGL/GPU.h new file mode 100644 index 00000000..ba3a05fa --- /dev/null +++ b/plugins/dfOpenGL/GPU.h @@ -0,0 +1 @@ +bool SaveTGA(const char* filename, int width, int height, void* pdata);
\ No newline at end of file diff --git a/plugins/dfOpenGL/Makefile.am b/plugins/dfOpenGL/Makefile.am new file mode 100644 index 00000000..7bf6b441 --- /dev/null +++ b/plugins/dfOpenGL/Makefile.am @@ -0,0 +1,22 @@ +INCLUDES = -DPIXMAPDIR=\"${datadir}/pixmaps/\" \ + -DLOCALE_DIR=\"${datadir}/locale/\" \ + -DDATADIR=\"${datadir}/psemu/\" \ + $(GTK2_CFLAGS) $(GLADE2_CFLAGS) -I/usr/X11R6/include \ + -g -O0 -Wall -fPIC + +bindir = @libdir@/games/psemu/ +libdir = @libdir@/games/psemu/ + +lib_LTLIBRARIES = libdfOpenGL.la + +libdfOpenGL_la_SOURCES = GPU.c primitive_drawing.c fps.c gllog.c cfg.c +libdfOpenGL_la_LDFLAGS = -module -avoid-version -L/usr/lib \ + -L/usr/X11R6/lib64 -L/usr/X11R6/lib -lX11 -lXxf86vm -lGL -lm + +bin_PROGRAMS = cfgDFOpenGL +cfgDFOpenGL_SOURCES = gpucfg-0.1df/main.c +cfgDFOpenGL_LDADD = $(GTK2_LIBS) $(GLADE2_LIBS) + +glade_DATA = gpucfg-0.1df/dfopengl.glade2 +gladedir = $(datadir)/psemu/ +EXTRA_DIST = $(glade_DATA) diff --git a/plugins/dfOpenGL/Makefile.in b/plugins/dfOpenGL/Makefile.in new file mode 100644 index 00000000..a3c04976 --- /dev/null +++ b/plugins/dfOpenGL/Makefile.in @@ -0,0 +1,602 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +bin_PROGRAMS = cfgDFOpenGL$(EXEEXT) +subdir = plugins/dfOpenGL +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in AUTHORS TODO +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ + "$(DESTDIR)$(gladedir)" +libLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(lib_LTLIBRARIES) +libdfOpenGL_la_LIBADD = +am_libdfOpenGL_la_OBJECTS = GPU.lo primitive_drawing.lo fps.lo \ + gllog.lo cfg.lo +libdfOpenGL_la_OBJECTS = $(am_libdfOpenGL_la_OBJECTS) +libdfOpenGL_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdfOpenGL_la_LDFLAGS) $(LDFLAGS) -o $@ +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_cfgDFOpenGL_OBJECTS = main.$(OBJEXT) +cfgDFOpenGL_OBJECTS = $(am_cfgDFOpenGL_OBJECTS) +am__DEPENDENCIES_1 = +cfgDFOpenGL_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libdfOpenGL_la_SOURCES) $(cfgDFOpenGL_SOURCES) +DIST_SOURCES = $(libdfOpenGL_la_SOURCES) $(cfgDFOpenGL_SOURCES) +gladeDATA_INSTALL = $(INSTALL_DATA) +DATA = $(glade_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALSA_LIBS = @ALSA_LIBS@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DFOPENGL = @DFOPENGL@ +DSYMUTIL = @DSYMUTIL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLADE2_CFLAGS = @GLADE2_CFLAGS@ +GLADE2_LIBS = @GLADE2_LIBS@ +GLIB2_CFLAGS = @GLIB2_CFLAGS@ +GLIB2_LIBS = @GLIB2_LIBS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +GTK2_CFLAGS = @GTK2_CFLAGS@ +GTK2_LIBS = @GTK2_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @libdir@/games/psemu/ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@/games/psemu/ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = -DPIXMAPDIR=\"${datadir}/pixmaps/\" \ + -DLOCALE_DIR=\"${datadir}/locale/\" \ + -DDATADIR=\"${datadir}/psemu/\" \ + $(GTK2_CFLAGS) $(GLADE2_CFLAGS) -I/usr/X11R6/include \ + -g -O0 -Wall -fPIC + +lib_LTLIBRARIES = libdfOpenGL.la +libdfOpenGL_la_SOURCES = GPU.c primitive_drawing.c fps.c gllog.c cfg.c +libdfOpenGL_la_LDFLAGS = -module -avoid-version -L/usr/lib \ + -L/usr/X11R6/lib64 -L/usr/X11R6/lib -lX11 -lXxf86vm -lGL -lm + +cfgDFOpenGL_SOURCES = gpucfg-0.1df/main.c +cfgDFOpenGL_LDADD = $(GTK2_LIBS) $(GLADE2_LIBS) +glade_DATA = gpucfg-0.1df/dfopengl.glade2 +gladedir = $(datadir)/psemu/ +EXTRA_DIST = $(glade_DATA) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins/dfOpenGL/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu plugins/dfOpenGL/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libdfOpenGL.la: $(libdfOpenGL_la_OBJECTS) $(libdfOpenGL_la_DEPENDENCIES) + $(libdfOpenGL_la_LINK) -rpath $(libdir) $(libdfOpenGL_la_OBJECTS) $(libdfOpenGL_la_LIBADD) $(LIBS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +cfgDFOpenGL$(EXEEXT): $(cfgDFOpenGL_OBJECTS) $(cfgDFOpenGL_DEPENDENCIES) + @rm -f cfgDFOpenGL$(EXEEXT) + $(LINK) $(cfgDFOpenGL_OBJECTS) $(cfgDFOpenGL_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPU.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfg.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fps.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gllog.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/primitive_drawing.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +main.o: gpucfg-0.1df/main.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT main.o -MD -MP -MF $(DEPDIR)/main.Tpo -c -o main.o `test -f 'gpucfg-0.1df/main.c' || echo '$(srcdir)/'`gpucfg-0.1df/main.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/main.Tpo $(DEPDIR)/main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gpucfg-0.1df/main.c' object='main.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o main.o `test -f 'gpucfg-0.1df/main.c' || echo '$(srcdir)/'`gpucfg-0.1df/main.c + +main.obj: gpucfg-0.1df/main.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT main.obj -MD -MP -MF $(DEPDIR)/main.Tpo -c -o main.obj `if test -f 'gpucfg-0.1df/main.c'; then $(CYGPATH_W) 'gpucfg-0.1df/main.c'; else $(CYGPATH_W) '$(srcdir)/gpucfg-0.1df/main.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/main.Tpo $(DEPDIR)/main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gpucfg-0.1df/main.c' object='main.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o main.obj `if test -f 'gpucfg-0.1df/main.c'; then $(CYGPATH_W) 'gpucfg-0.1df/main.c'; else $(CYGPATH_W) '$(srcdir)/gpucfg-0.1df/main.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-gladeDATA: $(glade_DATA) + @$(NORMAL_INSTALL) + test -z "$(gladedir)" || $(MKDIR_P) "$(DESTDIR)$(gladedir)" + @list='$(glade_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(gladeDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(gladedir)/$$f'"; \ + $(gladeDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(gladedir)/$$f"; \ + done + +uninstall-gladeDATA: + @$(NORMAL_UNINSTALL) + @list='$(glade_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(gladedir)/$$f'"; \ + rm -f "$(DESTDIR)$(gladedir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) +install-binPROGRAMS: install-libLTLIBRARIES + +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(gladedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-gladeDATA + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS install-libLTLIBRARIES + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-gladeDATA \ + uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libLTLIBRARIES clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-gladeDATA install-html \ + install-html-am install-info install-info-am \ + install-libLTLIBRARIES install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-gladeDATA uninstall-libLTLIBRARIES + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/plugins/dfOpenGL/PSEmu_PlugIn_Defs.h b/plugins/dfOpenGL/PSEmu_PlugIn_Defs.h new file mode 100644 index 00000000..18b269cf --- /dev/null +++ b/plugins/dfOpenGL/PSEmu_PlugIn_Defs.h @@ -0,0 +1,121 @@ +/* + PSEmu Plugin Developer Kit Header definition + + (C)1998 Vision Thing + + This file can be used only to develop PSEmu Plugins + Other usage is highly prohibited. +*/ + + +// IMPORTANT!!! +// This file will be used by PSEmu version >= 1.0.3 +// so, please, develop Plugins w/o using this header file now +// if you want to add return codes (any) just drop mail to +// duddie@psemu.com + +#ifndef _PSEMU_PLUGIN_DEFS_H +#define _PSEMU_PLUGIN_DEFS_H + + +// header version +#define _PPDK_HEADER_VERSION 1 + +#define PLUGIN_VERSION 1 + +// plugin type returned by PSEgetLibType (types can be merged if plugin is multi type!) +#define PSE_LT_CDR 1 +#define PSE_LT_GPU 2 +#define PSE_LT_SPU 4 +#define PSE_LT_PAD 8 + + +// every function in DLL if completed sucessfully should return this value +#define PSE_ERR_SUCCESS 0 +// undefined error but fatal one, that kills all functionality +#define PSE_ERR_FATAL -1 + + +// XXX_Init return values +// Those return values apply to all libraries + +// initialization went OK +#define PSE_INIT_ERR_SUCCESS 0 + +// this driver is not configured +#define PSE_INIT_ERR_NOTCONFIGURED -2 + +// this driver can not operate properly on this hardware or hardware is not detected +#define PSE_INIT_ERR_NOHARDWARE -3 + + +/* GPU PlugIn */ + + +// GPU_Test return values + +// sucess, everything configured, and went OK. +#define PSE_GPU_ERR_SUCCESS 0 + +// this driver is not configured +#define PSE_GPU_ERR_NOTCONFIGURED 1 + + + +// GPU_Query - will be implemented in v2 +/* +typedef struct +{ + unsigned long flags; + unsigned long status; + HWND window; + unsigned char reserved[100]; +} gpuQueryS; +*/ +// gpuQueryS.flags +// this driver requests windowed mode, +#define PSE_GPU_FLAGS_WINDOWED 1 + +// gpuQueryS.status +// this driver cannot operate in this windowed mode +#define PSE_GPU_STATUS_WINDOWWRONG 1 + +// GPU_Query End - will be implemented in v2 + + +/* CDR PlugIn */ + +// CDR_Test return values + +// sucess, everything configured, and went OK. +#define PSE_CDR_ERR_SUCCESS 0 + +// ERRORS +#define PSE_CDR_ERR -40 +// this driver is not configured +#define PSE_CDR_ERR_NOTCONFIGURED PSE_CDR_ERR - 0 +// if this driver is unable to read data from medium +#define PSE_CDR_ERR_NOREAD PSE_CDR_ERR - 1 + +// WARNINGS +#define PSE_CDR_WARN 40 +// if this driver emulates lame mode ie. can read only 2048 tracks and sector header is emulated +// this might happen to CDROMS that do not support RAW mode reading - surelly it will kill many games +#define PSE_CDR_WARN_LAMECD PSE_CDR_WARN + 0 + + + + +/* SPU PlugIn */ + +// retricted info (now!) + + + + +/* PAD PlugIn */ + +// not yet finished + + +#endif // _PSEMU_PLUGIN_DEFS_H diff --git a/plugins/dfOpenGL/TODO b/plugins/dfOpenGL/TODO new file mode 100644 index 00000000..918620ab --- /dev/null +++ b/plugins/dfOpenGL/TODO @@ -0,0 +1,31 @@ +emulation: +-opaque texture pixels + -something better than my 0xfe alpha hack + -finish implementing, not just sprite +-masked drawing (silent hill) +-subtractive blending? +-VRAM read +-texture mirroring +-use software polygon clip test, not opengl clipping +-Texture window: repeating instead of scaling - difficult! +-lines, dots as 1 unit width rectangle +-check for clut changes + +optimization/features: +-change 11bit gpu integers to union bitfields - probably won't help much, but hey, it'll be elegant :) +-fix psx texture pixel co-ords so we can turn on bilinear filtering and antialiasing. +-rewrite texturing + -check vram uploads for updates to subtexture +-rewrite (and fix) blending +-render to texture for psx front/back buffer +-implement black & STP pixels as stencil + -needed for masked drawing anyway... + -(would this also fix FF7 outlines when bilinear filtered textures are enabled?) +-upscale textures +-pixel shaders + +Pcsx: +-save states +-fullscreen toggle +-gui config +-fps display
\ No newline at end of file diff --git a/plugins/dfOpenGL/cfg.c b/plugins/dfOpenGL/cfg.c new file mode 100644 index 00000000..c048da68 --- /dev/null +++ b/plugins/dfOpenGL/cfg.c @@ -0,0 +1,106 @@ +#include "cfg.h" +#include <unistd.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <sys/stat.h> + + +extern GpuConfS gpuConfig; +char * pConfigFile=NULL; + +#define GetValue(name, var) \ + p = strstr(pB, name); \ + if (p != NULL) { \ + p+=strlen(name); \ + while ((*p == ' ') || (*p == '=')) p++; \ + if (*p != '\n') var = atoi(p); \ + } + +void readconfig() +{ + struct stat buf; + FILE *in;char t[256];int len, size; + char * pB, * p; + + if(pConfigFile) + strcpy(t,pConfigFile); + else + { + strcpy(t,"dfopengl.cfg"); + in = fopen(t,"rb"); + if (!in) + { + strcpy(t,"cfg/dfopengl.cfg"); + in = fopen(t,"rb"); + if(!in) sprintf(t,"%s/.pcsx/plugins/dfopengl.cfg",getenv("HOME")); + else fclose(in); + } + else fclose(in); + } + + if (stat(t, &buf) == -1) return; + size = buf.st_size; + + in = fopen(t,"rb"); + if (!in) return; + + pB=(char *)malloc(size); + memset(pB,0,size); + + len = fread(pB, 1, size, in); + fclose(in); + + gpuConfig.bFullscreen=FALSE; + gpuConfig.bBilinear=FALSE; + gpuConfig.nMaxTextures=64; + gpuConfig.bWireFrame=FALSE; + gpuConfig.bAntialias=FALSE; + gpuConfig.bClearScreen=FALSE; + gpuConfig.FrameLimit=TRUE; + gpuConfig.windowX=1024; + gpuConfig.windowY=768; + + GetValue("Fullscreen", gpuConfig.bFullscreen); + GetValue("Bilinear", gpuConfig.bBilinear); + GetValue("MaxTextures", gpuConfig.nMaxTextures); + GetValue("Wireframe", gpuConfig.bWireFrame); + GetValue("Antialias", gpuConfig.bAntialias); + GetValue("Clearscreen", gpuConfig.bClearScreen); + GetValue("FrameLimit", gpuConfig.FrameLimit); + GetValue("windowX", gpuConfig.windowX); + GetValue("windowY", gpuConfig.windowY); + + + free(pB); + +} + +void writeconfig() +{ +} + +void ExecCfg(char *arg) { + char cfg[256]; + struct stat buf; + + strcpy(cfg, "./cfgDFOpenGL"); + if (stat(cfg, &buf) != -1) { + sprintf(cfg, "%s %s", cfg, arg); + system(cfg); return; + } + + strcpy(cfg, "./cfg/cfgDFOpenGL"); + if (stat(cfg, &buf) != -1) { + sprintf(cfg, "%s %s", cfg, arg); + system(cfg); return; + } + + sprintf(cfg, "%s/.pcsx/plugins/cfg/cfgDFOpenGL", getenv("HOME")); + if (stat(cfg, &buf) != -1) { + sprintf(cfg, "%s %s", cfg, arg); + system(cfg); return; + } + + printf("ERROR: cfgDFOpenGL file not found!\n"); +} diff --git a/plugins/dfOpenGL/cfg.h b/plugins/dfOpenGL/cfg.h new file mode 100644 index 00000000..9f3c0830 --- /dev/null +++ b/plugins/dfOpenGL/cfg.h @@ -0,0 +1,10 @@ +#ifndef _GPU_CFG_H_ +#define _GPU_CFG_H_ + +#include "gpu_i.h" + +void readconfig(void); +void writeconfig(void); + + +#endif // _GPU_CFG_H_ diff --git a/plugins/dfOpenGL/fps.c b/plugins/dfOpenGL/fps.c new file mode 100644 index 00000000..21f95c7f --- /dev/null +++ b/plugins/dfOpenGL/fps.c @@ -0,0 +1,41 @@ +#include <sys/time.h> +#include <unistd.h> +#include "gpu_i.h" + +static const double NTSC = 100000000/5994; +static const double PAL = 100000000/5000; + +static double lastvsync = 0; +#define FRAMESAMPLES 10 + +double GetTime() //in microseconds +{ + struct timeval tv; + gettimeofday(&tv, 0); // well, maybe there are better ways + return (double)tv.tv_sec * 1000000 + tv.tv_usec; // to do that, but at least it works +} + +void waitforrealtime() +{ + double currenttime,tickstogo; + double target; + + currenttime = GetTime(); + + if (currenttime < lastvsync + 1000000) + target = lastvsync + (psxDisp.pal ? PAL : NTSC); + else + target = currenttime; + + lastvsync = target; + + while (currenttime < target) + { + tickstogo = target - currenttime; + if (tickstogo >= 500.0f) + { + usleep((useconds_t)tickstogo-200); //usleep in microseconds + } + currenttime = GetTime(); + } +} diff --git a/plugins/dfOpenGL/gllog.c b/plugins/dfOpenGL/gllog.c new file mode 100644 index 00000000..447b05a5 --- /dev/null +++ b/plugins/dfOpenGL/gllog.c @@ -0,0 +1,43 @@ +// comment next line and all gllog(xx,....) will go to gpulog.txt (enable logging) +#define _COMMENTLOG + +void gllog(int level, char *fmt,...) +{ +#ifndef _COMMENTLOG + static FILE *out=NULL; + static char tmpbuf[200], tmpbufold[200]; + + static int repeatcount=0; + + if(out==NULL) + { + // open output file ! + if((out=fopen("gpulog.txt","wb"))==NULL)exit(1); + } + // file already opened + + va_list marker; + va_start(marker,fmt); + vsprintf(tmpbuf, fmt, marker ); + va_end(marker); + + // we dont log the same line multiple times + if(strcmp(tmpbufold,tmpbuf)==0) + { + repeatcount++; + return; + } + else + { + // copy the new line to the old buffer + strcpy(tmpbufold,tmpbuf); + if(repeatcount>0) + { + fprintf(out,"Last message repeated %d times\n",repeatcount); + repeatcount=0; + } + fprintf(out,"Level: %d msg: %s\n",level,tmpbuf); + fflush(out); + } +#endif +} diff --git a/plugins/dfOpenGL/gpu_i.h b/plugins/dfOpenGL/gpu_i.h new file mode 100644 index 00000000..a45c0e94 --- /dev/null +++ b/plugins/dfOpenGL/gpu_i.h @@ -0,0 +1,208 @@ +#ifndef _GPU_INTERNALS_H +#define _GPU_INTERNALS_H + +#define GL_GLEXT_PROTOTYPES +#include <GL/glx.h> +#include <GL/gl.h> +#include <GL/glext.h> +#include <stdint.h> + +#ifdef GPU_INTERNALS_DEF +#define GPUVAR_DEF +#else +#define GPUVAR_DEF extern +#endif + +typedef int bool; +#define FALSE 0 +#define TRUE 1 + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; + +void gllog(int level, char *fmt,...); + +extern unsigned short lutBGR2RGB[65536]; + +extern unsigned short textBuf[]; + +extern int32_t GPUstatusRet; +extern int32_t GPUInfoVals[16]; + +#define INFO_TW 0 +#define INFO_DRAWSTART 1 +#define INFO_DRAWEND 2 +#define INFO_DRAWOFF 3 + +#define GPUSTATUS_ODDLINES 0x80000000 +#define GPUSTATUS_DMABITS 0x60000000 // Two bits +#define GPUSTATUS_READYFORCOMMANDS 0x10000000 +#define GPUSTATUS_READYFORVRAM 0x08000000 +#define GPUSTATUS_IDLE 0x04000000 +#define GPUSTATUS_DISPLAYDISABLED 0x00800000 +#define GPUSTATUS_INTERLACED 0x00400000 +#define GPUSTATUS_RGB24 0x00200000 +#define GPUSTATUS_PAL 0x00100000 +#define GPUSTATUS_DOUBLEHEIGHT 0x00080000 +#define GPUSTATUS_WIDTHBITS 0x00070000 // Three bits +#define GPUSTATUS_MASKENABLED 0x00001000 +#define GPUSTATUS_MASKDRAWN 0x00000800 +#define GPUSTATUS_DRAWINGALLOWED 0x00000400 +#define GPUSTATUS_DITHER 0x00000200 + +#define GPUIsBusy (GPUstatusRet &= ~GPUSTATUS_IDLE) +#define GPUIsIdle (GPUstatusRet |= GPUSTATUS_IDLE) + +#define GPUIsNotReadyForCommands (GPUstatusRet &= ~GPUSTATUS_READYFORCOMMANDS) +#define GPUIsReadyForCommands (GPUstatusRet |= GPUSTATUS_READYFORCOMMANDS) + +extern unsigned char psxVub[]; +extern signed char *psxVsb; +extern unsigned short *psxVuw; +extern signed short *psxVsw; +extern uint32_t *psxVul; +extern int32_t *psxVsl; + + +typedef struct { + uint32_t x, y; + uint32_t colormode; + uint32_t abr; //alpha blending + uint32_t mirror; +} TextureState_t; + +extern TextureState_t texinfo; + +typedef struct VRAMLOADTTAG +{ + short x; + short y; + short w; + short h; + short curx; + short cury; + uint32_t* extratarget; + bool enabled; +} VRAMLoad_t; + +extern VRAMLoad_t vramWrite; + +struct PSXDisplay_t { + short modeX; + short modeY; + short startX; + short startY; + bool disabled; + bool colordepth24; + bool interlaced; + bool pal; + + //Has to do with television hsync & vsync? + //1 Y line = 1 vtrace? (typical 16 to 256 (32 to 512)) + //X (typical 608 to 3168) + short rangeX1; + short rangeY1; + short rangeX2; + short rangeY2; + + bool changed; +}; +extern struct PSXDisplay_t psxDisp, oldpsxDisp; + +struct PSXDraw_t { + short offsetX; + short offsetY; + short clipX1; + short clipX2; + short clipY1; + short clipY2; + short texwinX1; + short texwinY1; + short texwinX2; + short texwinY2; + bool texwinenabled; + bool enabled; + bool setmask; + bool testmask; +}; +extern struct PSXDraw_t psxDraw; + +extern short dispWidths[8]; + +extern int32_t dispLace; +extern int32_t dispLaceNew; +extern int32_t imageTransfer; +extern int32_t drawLace; +extern int32_t drawingLines; + +extern short imTYc,imTXc,imTY,imTX; +extern int32_t imSize; +extern short imageX0,imageX1; +extern short imageY0,imageY1; + + +extern int32_t newTextX0,newTextX1,newTextX2,newTextX3; +extern int32_t newTextY0,newTextY1,newTextY2,newTextY3; +extern unsigned short textBuf[]; + +union uPointers{ + void *v; + unsigned char *b; + unsigned short *w; + uint32_t *d; + char *c; + short *s; + int32_t *l; +}; +extern unsigned char psxVub[]; +extern signed char *psxVsb; +extern unsigned short *psxVuw; +extern signed short *psxVsw; +extern uint32_t *psxVul; +extern int32_t *psxVsl; + +typedef struct +{ + bool bFullscreen; + bool bBilinear; + int nMaxTextures; + bool bWireFrame; + bool bAntialias; + bool bClearScreen; + bool FrameLimit; + short windowX; + short windowY; +} GpuConfS; +extern GpuConfS gpuConfig; + +extern short windowX, windowY; + +extern unsigned char texshade[256]; +extern uint32_t image[65536]; +extern uint32_t torgba[65536]; + + +struct texturecache{ + int32_t textAddrX; + int32_t textAddrY; + int32_t textTP; + int32_t clutP; + GLuint id; + bool Update; +}; +//#define maxtextures 32 +extern struct texturecache texture[64]; +extern GLuint xferTexture16; +extern GLuint xferTexture24; +extern GLuint nullid; +#define nullclutP (1024*512+1) + + +#endif // _GPU_INTERNALS_H diff --git a/plugins/dfOpenGL/gpucfg-0.1df/dfopengl.glade2 b/plugins/dfOpenGL/gpucfg-0.1df/dfopengl.glade2 new file mode 100644 index 00000000..a7d24cdc --- /dev/null +++ b/plugins/dfOpenGL/gpucfg-0.1df/dfopengl.glade2 @@ -0,0 +1,272 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> +<!--Generated with glade3 3.1.5 on Sun Mar 16 17:26:02 2008 by hoshy@mobilbox--> +<glade-interface> + <widget class="GtkWindow" id="CfgWnd"> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="spacing">6</property> + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>OpenGL Configuration Options</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="left_padding">12</property> + <child> + <widget class="GtkVBox" id="vbox4"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkCheckButton" id="chk_fullscreen"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Display Fullscreen</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="chk_bilinear"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Bilinear</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Maximum Textures</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="te_maxtextures"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="chk_wireframe"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Wireframe</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="chk_antialias"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Antialias</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">4</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="chk_clearscreen"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Clearscreen</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">5</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="chk_framelimit"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Framelimit</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">6</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">WindowX</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="te_windowX"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">7</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">WindowY</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="te_windowY"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">8</property> + </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + </child> + <child> + <widget class="GtkHButtonBox" id="hbuttonbox1"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <child> + <widget class="GtkButton" id="btn_close"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">gtk-close</property> + <property name="use_stock">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="padding">6</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="padding">6</property> + <property name="position">1</property> + </packing> + </child> + </widget> + </child> + </widget> +</glade-interface> diff --git a/plugins/dfOpenGL/gpucfg-0.1df/main.c b/plugins/dfOpenGL/gpucfg-0.1df/main.c new file mode 100644 index 00000000..ba9c2220 --- /dev/null +++ b/plugins/dfOpenGL/gpucfg-0.1df/main.c @@ -0,0 +1,261 @@ +#include <gtk/gtk.h> +#include <glade/glade.h> + +#include <unistd.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <sys/stat.h> + +#define CONFIG_FILENAME "dfopengl.cfg" +#define READBINARY "rb" +#define WRITEBINARY "wb" + +void on_config_clicked (GtkWidget *widget, gpointer user_data) +{ + gtk_widget_destroy (widget); + exit (0); +} + +void on_about_clicked (GtkWidget *widget, gpointer user_data) +{ + gtk_widget_destroy (widget); + exit (0); +} + +void SetCfgVal(char * pB,char * pE,int val) +{ + char * p, *ps, *pC;char t[32]; + + sprintf(t,"%d",val); + + p=strstr(pB,pE); + if(p) + { + p=strstr(p,"="); + if(!p) return; + p++; + while(*p && *p!='\n' && (*p<'0' || *p>'9')) p++; + if(*p==0 || *p=='\n') return; + ps=p; + while(*p>='0' && *p<='9') p++; + pC=(char *)malloc(32767); + strcpy(pC,p); + strcpy(ps,t); + strcat(pB,pC); + free(pC); + } + else + { + strcat(pB,pE); + strcat(pB," = "); + strcat(pB,t); + strcat(pB,"\n"); + } +} + +void save_config (GtkWidget *widget, gpointer user_data) +{ + GladeXML *xml; + char cfg[255]; + FILE *in; + int len, val; + char *pB; + + pB=(char *)malloc(32767); + memset(pB,0,32767); + + strcpy(cfg, CONFIG_FILENAME); + + /* ADB TODO Why do we read this in just to replace it again? */ + in = fopen(cfg,READBINARY); + if(in) + { + len = fread(pB, 1, 32767, in); + fclose(in); + } + + xml = (GladeXML*) user_data; + + val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "chk_fullscreen"))); + SetCfgVal(pB,"\nFullscreen",val); + val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "chk_bilinear"))); + SetCfgVal(pB,"\nBilinear",val); + val = atoi (gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (xml, "te_maxtextures")))); + SetCfgVal(pB,"\nMaxTextures",val); + val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "chk_wireframe"))); + SetCfgVal(pB,"\nWireframe",val); + val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "chk_antialias"))); + SetCfgVal(pB,"\nAntialias",val); + val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "chk_clearscreen"))); + SetCfgVal(pB,"\nClearscreen",val); + val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "chk_framelimit"))); + SetCfgVal(pB,"\nFrameLimit",val); + val = atoi (gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (xml, "te_windowX")))); + SetCfgVal(pB,"\nwindowX",val); + val = atoi (gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (xml, "te_windowY")))); + SetCfgVal(pB,"\nwindowY",val); + + /* Write to the config file */ + if((in=fopen(cfg, WRITEBINARY))!=NULL) { + fwrite(pB,strlen(pB),1,in); + fclose(in); + } + free(pB); + + gtk_widget_destroy (glade_xml_get_widget (xml, "CfgWnd")); + + /* Close the window and exit control from the plugin */ + exit (0); +} + +/* This function checks for the value being outside the accepted range, + and returns the appropriate boundary value */ +int set_limit (char *p, int len, int lower, int upper) +{ + int val = 0; + + if (p) + val = atoi(p + len); + /* printf("Checking for val %d greater than %d and lower than %d, ", val, lower, upper);*/ + if (val < lower) + val = lower; + if (val > upper) + val = upper; + /* printf ("val is now %d\n", val);*/ + return val; +} + +int +main (int argc, char *argv[]) +{ + GtkWidget *widget; + GladeXML *xml; + FILE *in; + char t[256]; + int len; + char * pB, * p; + char cfg[255]; + char tempstr[128]; + + if (argc!=2) { + printf("Usage: cfgOpenGL {ABOUT | CFG}\n"); + return 0; + } + if(strcmp(argv[1],"CFG")!=0 && strcmp(argv[1],"ABOUT")!=0) { + printf("Usage: cfgOpenGL {ABOUT | CFG}\n"); + return 0; + } + + gtk_set_locale (); + gtk_init (&argc, &argv); + + if (strcmp(argv[1], "ABOUT") == 0) { + widget = gtk_about_dialog_new (); + gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (widget), "PCSX OpenGL Video Plugin"); + gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (widget), "1.0"); + + g_signal_connect_data(GTK_OBJECT(widget), "response", + GTK_SIGNAL_FUNC(on_about_clicked), NULL, NULL, G_CONNECT_AFTER); + + gtk_widget_show (widget); + gtk_main(); + + return 0; + } + + xml = glade_xml_new(DATADIR "dfopengl.glade2", "CfgWnd", NULL); + if (!xml) { + g_warning("We could not load the interface!"); + return -1; + } + + strcpy(cfg, CONFIG_FILENAME); + + in = fopen(cfg, READBINARY); + if(in) { + pB = (char *)malloc(32767); + memset(pB, 0, 32767); + len = fread(pB, 1, 32767, in); + fclose(in); + } else { + pB = 0; + printf("Couldn't find config file %s - creating new file\n", cfg); + } + + /* Set default values */ + int bFullscreen = FALSE; + int bBilinear = FALSE; + int nMaxTextures = 64; + int bWireFrame = FALSE; + int bAntialias = FALSE; + int bClearScreen = FALSE; + int bFrameLimit = TRUE; + short nwindowX = 1024; + short nwindowY = 768; + + if (pB) { + strcpy(t,"\nFullscreen");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + bFullscreen = set_limit (p, len, 0, 1); + + strcpy(t,"\nBilinear");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + bBilinear = set_limit (p, len, 0, 1); + + strcpy(t,"\nMaxTextures");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + nMaxTextures = set_limit (p, len, 0, 128); /* TODO - What should the limit be? */ +printf("Max Textures is %d\n", nMaxTextures); + + strcpy(t,"\nWireframe");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + bWireFrame = set_limit (p, len, 0, 1); + + strcpy(t,"\nAntialias");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + bAntialias = set_limit (p, len, 0, 1); + + strcpy(t,"\nClearscreen");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + bClearScreen = set_limit (p, len, 0, 1); + + strcpy(t,"\nFrameLimit");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + bFrameLimit = set_limit (p, len, 0, 1); + + strcpy(t,"\nwindowX");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + nwindowX = set_limit (p, len, 0, 1600); /* TODO - limit ? */ + + strcpy(t,"\nwindowY");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} + nwindowY = set_limit (p, len, 0, 1200); /* TODO - limit ? */ + + free(pB); + } + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "chk_fullscreen")), bFullscreen); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "chk_bilinear")), bBilinear); + + snprintf (tempstr, 10, "%d", nMaxTextures); + gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget(xml, "te_maxtextures")), tempstr); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "chk_wireframe")), bWireFrame); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "chk_antialias")), bAntialias); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "chk_clearscreen")), bClearScreen); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "chk_framelimit")), bFrameLimit); + + snprintf (tempstr, 10, "%d", nwindowX); + gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget(xml, "te_windowX")), tempstr); + + snprintf (tempstr, 10, "%d", nwindowY); + gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget(xml, "te_windowY")), tempstr); + + widget = glade_xml_get_widget(xml, "CfgWnd"); + g_signal_connect_data(GTK_OBJECT(widget), "delete_event", + GTK_SIGNAL_FUNC(on_config_clicked), NULL, NULL, G_CONNECT_AFTER); + gtk_widget_show_all (widget); + + widget = glade_xml_get_widget(xml, "btn_close"); + g_signal_connect_data(GTK_OBJECT(widget), "clicked", + GTK_SIGNAL_FUNC(save_config), xml, NULL, G_CONNECT_AFTER); + + gtk_main (); + return 0; +} diff --git a/plugins/dfOpenGL/oldMakefile b/plugins/dfOpenGL/oldMakefile new file mode 100644 index 00000000..6fb3557b --- /dev/null +++ b/plugins/dfOpenGL/oldMakefile @@ -0,0 +1,32 @@ +CC = gcc +LD = gcc + +PLUGIN = libdfOpenGL.so +OBJECTS = GPU.o primitive_drawing.o fps.o gllog.o +#CFLAGS += `gtk-config --cflags` +CFLAGS = -g -O0 -Wall -fPIC +#CFGLIBS += `gtk-config --libs` +LIBS += -L/usr/lib -lXxf86vm -lGL -lm + +%.o : %.c + $(CC) $(CFLAGS) -c $< + +all: $(OBJECTS) + $(LD) -fPIC $(OBJECTS) -g -shared -o $(PLUGIN) $(LIBS) + +#cfg: ${CFGOBJS} +# $(LD) $(CFGOBJS) -g -o $(CFG) $(CFGLIBS) + +release: all + strip $(PLUGIN) +# strip $(CFG) +# cp $(PLUGIN).$(NUMBER) ../$(PLUGIN).$(NUMBER) +# cp $(CFG) ../$(CFG) + +clean: + rm -f *.o *.a *.so $(CFG) + + +# Dependencies + + diff --git a/plugins/dfOpenGL/primitive_drawing.c b/plugins/dfOpenGL/primitive_drawing.c new file mode 100644 index 00000000..8d2104bd --- /dev/null +++ b/plugins/dfOpenGL/primitive_drawing.c @@ -0,0 +1,1710 @@ +#include <stdlib.h> +#include <string.h> +#include "gpu_i.h" + +typedef unsigned char byte; + +byte texshade[256]; +uint32_t torgba[65536]; +uint32_t image[65536]; +char curText=0; +TextureState_t texinfo; +struct texturecache texture[64]; +GLuint nullid; + +struct TransparencySettings{ + int mode; + int src; + int dst; + byte alpha; + bool change; +}; + +struct TransparencySettings TransRate[4]={ + {GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,128,TRUE}, + {GL_FUNC_ADD, GL_ONE, GL_ONE_MINUS_SRC_ALPHA,0,TRUE}, + {GL_FUNC_ADD, GL_ZERO, GL_ONE_MINUS_SRC_COLOR, 0,TRUE}, + {GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE,64,TRUE} +}; +bool transparent=FALSE; +byte gAlpha; + +void cmdSTP(unsigned char * baseAddr) +{ + uint32_t gdata = ((uint32_t*)baseAddr)[0]; + + GPUstatusRet&=~0x1800; // Clear the necessary bits + GPUstatusRet|=((gdata & 0x03) << 11); // Set the necessary bits + + psxDraw.setmask = gdata & 1; + psxDraw.testmask = (gdata & 2) >> 1; + + gllog(77," CMD: STP: %x",gdata&0xffffff); +} + + +inline void UpdateTextureInfo ( uint32_t gdata ) +{ + texinfo.x = ( gdata << 6 ) & 0x3c0; // texture addr + texinfo.y = ( gdata << 4 ) & 0x100; + + //if ( gdata&200 ) iDither=iUseDither; else iDither=0; + + texinfo.colormode = ( gdata >> 7 ) & 0x3; // tex mode (4bit,8bit,15direct) + if ( texinfo.colormode==3 ) + texinfo.colormode=2; // seen in Wild9 :( + + texinfo.abr = ( gdata >> 5 ) & 0x3; // blend mode + + texinfo.mirror = gdata&0x3000 >> 12; //??? + + GPUstatusRet&=~0x07ff; // Clear the necessary bits + GPUstatusRet|= ( gdata & 0x07ff ); // set the necessary bits +} + +void cmdTexturePage(unsigned char * baseAddr) +{ + uint32_t gdata = ((uint32_t*)baseAddr)[0]; + + int32_t tempABR = (gdata >> 5) & 0x3; + if(texinfo.abr != tempABR){ + texinfo.abr = tempABR; + //glBlendEquation(TransRate[texinfo.abr].mode); + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + gAlpha=TransRate[texinfo.abr].alpha; + transparent=TRUE; + } + UpdateTextureInfo(gdata); + + + /*switch(texinfo.abr){ + case 0: + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=128; + break; + case 1: + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=0; + break; + case 2: + glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR); + gAlpha=0; + break; + case 3: + glBlendFunc(GL_SRC_ALPHA,GL_ONE); + gAlpha=64; + break; + }*/ + //textREST = (gdata&0x00ffffff)>>9; + //gllog(77," CMD: TPage: %d,%d TP=%d ABR=%d REST=%x\n",textAddrX,textAddrY,textTP,texinfo.abr,(gdata&0x00ffffff)>>9); + return; +} + +void cmdTextureWindow(unsigned char *baseAddr) +{ + //hopefully true psx texture window emulation, oddities & all + //taken from peops soft gpu + + uint32_t gdata = ((uint32_t*)baseAddr)[0]; + //gllog(77,"CDM: TWin: %x *NI*", gdata&0xffffff); + + GPUInfoVals[INFO_TW]=gdata&0xFFFFF; + + uint32_t YAlign,XAlign; + + if(gdata & 0x020) + psxDraw.texwinY2 = 8; // xxxx1 + else if (gdata & 0x040) + psxDraw.texwinY2 = 16; // xxx10 + else if (gdata & 0x080) + psxDraw.texwinY2 = 32; // xx100 + else if (gdata & 0x100) + psxDraw.texwinY2 = 64; // x1000 + else if (gdata & 0x200) + psxDraw.texwinY2 = 128; // 10000 + else + psxDraw.texwinY2 = 256; // 00000 + + // Texture window size is determined by the least bit set of the relevant 5 bits + + if (gdata & 0x001) + psxDraw.texwinX2 = 8; // xxxx1 + else if (gdata & 0x002) + psxDraw.texwinX2 = 16; // xxx10 + else if (gdata & 0x004) + psxDraw.texwinX2 = 32; // xx100 + else if (gdata & 0x008) + psxDraw.texwinX2 = 64; // x1000 + else if (gdata & 0x010) + psxDraw.texwinX2 = 128; // 10000 + else + psxDraw.texwinX2 = 256; // 00000 + + // Re-calculate the bit field, because we can't trust what is passed in the data + + + YAlign = (uint32_t)(32 - (psxDraw.texwinY2 >> 3)); + XAlign = (uint32_t)(32 - (psxDraw.texwinX2 >> 3)); + + // Absolute position of the start of the texture window + + psxDraw.texwinY1 = (short)(((gdata >> 15) & YAlign) << 3); + psxDraw.texwinX1 = (short)(((gdata >> 10) & XAlign) << 3); + + if((psxDraw.texwinX1 == 0 && // tw turned off + psxDraw.texwinY1 == 0 && + psxDraw.texwinX2 == 0 && + psxDraw.texwinY2 == 0) || + (psxDraw.texwinX2 == 256 && + psxDraw.texwinY2 == 256)) + { + psxDraw.texwinenabled = 0; // -> just do it + } + else // otherwise + { + psxDraw.texwinenabled = 1; // -> tw turned on + } +} + +void cmdDrawAreaStart(unsigned char * baseAddr) +{ + uint32_t gdata = ((uint32_t*)baseAddr)[0]; + GPUInfoVals[INFO_DRAWSTART]=gdata&0x3FFFFF; + + psxDraw.clipX1 = gdata & 0x3ff; + psxDraw.clipY1 = (gdata>>10)&0x1ff; + + GLdouble equation[4]={0.0,0.0,0.0,0.0}; + equation[0]=1.0; + equation[3]=(GLdouble)-(psxDraw.clipX1); + glClipPlane(GL_CLIP_PLANE0,equation); + + equation[0]=0.0; + equation[1]=1.0; + equation[3]=(GLdouble)-(psxDraw.clipY1); + glClipPlane(GL_CLIP_PLANE1,equation); + + //gllog(77," CMD: DrawArea Start %d,%d %x",drawX,drawY,gdata); +} + +void cmdDrawAreaEnd(unsigned char * baseAddr) +{ + uint32_t gdata = ((uint32_t*)baseAddr)[0]; + GPUInfoVals[INFO_DRAWEND]=gdata&0x3FFFFF; + + psxDraw.clipX2 = gdata & 0x3ff; + psxDraw.clipY2 = (gdata>>10)&0x1ff; + + GLdouble equation[4]={0.0,0.0,0.0,0.0}; + equation[0]=-1.0; + equation[3]=(GLdouble)(psxDraw.clipX2); + glClipPlane(GL_CLIP_PLANE2,equation); + + equation[0]=0.0; + equation[1]=-1.0; + equation[3]=(GLdouble)(psxDraw.clipY2); + glClipPlane(GL_CLIP_PLANE3,equation); + + + //gllog(77," CMD: DrawArea End %d,%d",drawW,drawH); +} + +void cmdDrawOffset(unsigned char * baseAddr) +{ + uint32_t gdata = ((uint32_t*)baseAddr)[0]; + GPUInfoVals[INFO_DRAWOFF]=gdata&0x7FFFFF; + + psxDraw.offsetX = (short)(gdata & 0x7ff); + psxDraw.offsetY = (short)((gdata>>11)&0x7ff); + + psxDraw.offsetX=(short)(((int)psxDraw.offsetX<<21)>>21); + psxDraw.offsetY=(short)(((int)psxDraw.offsetY<<21)>>21); + + //gllog(77," CMD: Draw Offset %d,%d",ofsX,ofsY,gdata); +} + +void primLoadImage(unsigned char * baseAddr) +{ + short *sgpuData = ((short *) baseAddr); + //uint32_t *gpuData = ((uint32_t *) baseAddr); + + short x = (sgpuData[2]<<21)>>21; + short y = (sgpuData[3]<<21)>>21; + short w = (sgpuData[4]<<21)>>21; + short h = (sgpuData[5]<<21)>>21; + + if (w == -1024) w = 1024; + if (h == -512) h = 512; + + if (x < 0 || y < 0 || w<0 || h<0 || x+w > 1024 || y+h > 512) + { + return; + } + + vramWrite.curx = vramWrite.x = x; + vramWrite.cury = vramWrite.y = y; + vramWrite.w = w; + vramWrite.h = h; + vramWrite.extratarget = (uint32_t*)malloc(vramWrite.w*vramWrite.h*4); + vramWrite.enabled = 1; + + imageTransfer = 1; + + int i; + + for(i=0;i<gpuConfig.nMaxTextures;i++){ + if(((texture[i].textAddrX+255)>=x) + &&((texture[i].textAddrY+255)>=y) + &&(texture[i].textAddrX<=(x+w)) + &&(texture[i].textAddrY<=(y+h))){ + texture[i].Update=TRUE; + } + } + + //gllog(1," CMD: MEM->VRAM %d,%d %d,%d\n",imageX0,imageY0,imageX1,imageY1); +} + +void primStoreImage(unsigned char * baseAddr) +{ + uint32_t *gpuData = ((uint32_t *) baseAddr); + + imageX0 = (short)(gpuData[1] & 0x3ff); + imageY0 = (short)(gpuData[1]>>16) & 0x1ff; + imageX1 = (short)(gpuData[2] & 0xffff); + imageY1 = (short)((gpuData[2]>>16) & 0xffff); + + //gllog(1," CMD: VRAM->MEM %d,%d %d,%d\n",imageX0,imageY0,imageX1,imageY1); + imTX=imageX0; imTY=imageY0; + imTXc=imageX1; imTYc=imageY1; + imSize=imageY1*imageX1/2; + + imageTransfer = 2; + GPUstatusRet|=0x08000000; +} + +void primMoveImage(unsigned char * baseAddr) +{ + // 0x80 image move (VRAM->VRAM) + uint32_t *gpuData = ((uint32_t *) baseAddr); + + unsigned short imageX0,imageY0,imageX1,imageY1,imageSX,imageSY,i,j; + + imageX0 = (short)(gpuData[1] & 0x3ff); + imageY0 = (short)(gpuData[1]>>16) & 0x1ff; + + imageX1 = (short)(gpuData[2] & 0x3ff); + imageY1 = (short)((gpuData[2]>>16) & 0x1ff); + + imageSY = (short)((gpuData[3]>>16) & 0xffff); + imageSX = (short)(gpuData[3] & 0xffff); + + for(i=0;i<gpuConfig.nMaxTextures;i++){ + if(((texture[i].textAddrX+255)>=imageX1) + &&((texture[i].textAddrY+255)>=imageY1) + &&(texture[i].textAddrX<=(imageX1+imageSX)) + &&(texture[i].textAddrY<=(imageY1+imageSY))){ + texture[i].Update=TRUE; + } + } + + //gllog(1," CMD: VRAM->VRAM %d,%d -> %d,%d (%d,%d)\n",imageX0,imageY0,imageX1,imageY1,imageSX,imageSY); + + if((imageY0+imageSY)>512) imageSY=512-imageY0; + if((imageY1+imageSY)>512) imageSY=512-imageY1; + if((imageX0+imageSX)>1024) imageSX=1024-imageX0; + if((imageX1+imageSX)>1024) imageSX=1024-imageX1; + for(j=0;j<imageSY;j++) + for(i=0;i<imageSX;i++) + psxVuw[((imageY1+j)<<10)+imageX1+i]=psxVuw[((imageY0+j)<<10)+imageX0+i]; +} + + + + +void primTileS(unsigned char * baseAddr) +{ + //gllog(2,"Tile S *NI*");// : %04x,%04x - %04x,%04x",baseAddrW[addr+2],baseAddrW[addr+3],baseAddrW[addr+4],baseAddrW[addr+5]); + //gllog(2,"Tile S *NI* : %04x,%04x - %04x,%04x",baseAddrW[addr+2],baseAddrW[addr+3],baseAddrW[addr+4],baseAddrW[addr+5]); + + //uint32_t *gpuData = (uint32_t *)baseAddr; + unsigned short *gpuPoint = (unsigned short*) baseAddr; + + short x = (gpuPoint[2]<<21)>>21; + short y = (gpuPoint[3]<<21)>>21; + short w = (gpuPoint[4]<<21)>>21; + short h = (gpuPoint[5]<<21)>>21; + + x += psxDraw.offsetX; + y += psxDraw.offsetY; + + if(baseAddr[3]&2){ //if blending on + //if(TransRate[texinfo.abr].change && !transparent){ + //glBlendEquation(TransRate[texinfo.abr].mode); + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + gAlpha=TransRate[texinfo.abr].alpha; + transparent=TRUE; + //} + //if(baseAddr[3]&1){ + // glColor4ub(255,255,255,gAlpha); + //}else{ + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],gAlpha); + //} + }else{ + //if(TransRate[texinfo.abr].change && transparent){ + //glBlendEquation(TransRate[0].mode); + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + //} + //if(baseAddr[3]&1){ + // glColor3ub(255,255,255); + //}else{ + glColor3ub(baseAddr[0],baseAddr[1],baseAddr[2]); + //} + } + + glBegin(GL_POLYGON); + glVertex2s(x,y); + glVertex2s(x+w,y); + glVertex2s(x+w,y+h); + glVertex2s(x,y+h); + glEnd(); + + + return; +} + +void primBlkFill(unsigned char * baseAddr) +{ + short * gpuPoint = (short*) baseAddr; + //uint32_t *gpuData = ((uint32_t *) baseAddr); + + //gllog(2,"BlkFill : %04x,%04x - %04x,%04x",gpuPoint[2],gpuPoint[3],gpuPoint[4],gpuPoint[5]); + + short x = (gpuPoint[2]<<21)>>21; + short y = (gpuPoint[3]<<21)>>21; + short w = (gpuPoint[4]<<21)>>21; + short h = (gpuPoint[5]<<21)>>21; + +/* + this function is something like clear_with_given_color + and according to baseAddr + struct packet + { + unsigned char R,G,B,code; + unsigned short X,Y,W,H; + } + this function is not clipped bby drawing area, accesses whole VRAM +*/ + + glDisable(GL_CLIP_PLANE0); + glDisable(GL_CLIP_PLANE1); + glDisable(GL_CLIP_PLANE2); + glDisable(GL_CLIP_PLANE3); + + glColor3ub(baseAddr[0],baseAddr[1],baseAddr[2]); + glBegin(GL_POLYGON); + glVertex2s(x,y); + glVertex2s(x+w,y); + glVertex2s(x+w,y+h); + glVertex2s(x,y+h); + glEnd(); + + glEnable(GL_CLIP_PLANE0); + glEnable(GL_CLIP_PLANE1); + glEnable(GL_CLIP_PLANE2); + glEnable(GL_CLIP_PLANE3); +} + + + +void setupTexture(int32_t clutP){ + int i; + int32_t sprCY,sprCX,tbw; + short color,tC; + int ctext; + union uPointers psxVOffset,psxVOffset2; + + if( (texinfo.colormode&2) == 2 ) + clutP=nullclutP; + + ctext=curText; + for(i=0;i<gpuConfig.nMaxTextures;i++){ + if(texture[i].textAddrX==texinfo.x && texture[i].textAddrY==texinfo.y && clutP==texture[i].clutP) + { + if(texture[i].Update==TRUE || texinfo.colormode!=texture[i].textTP) + { + ctext=i; + break; + } + glBindTexture(GL_TEXTURE_2D,texture[i].id); + return; + } + } + + texture[ctext].textAddrX=texinfo.x; + texture[ctext].textAddrY=texinfo.y; + texture[ctext].textTP=texinfo.colormode; + texture[ctext].clutP=clutP; + texture[ctext].Update=FALSE; + glBindTexture(GL_TEXTURE_2D,texture[ctext].id); + if(ctext==curText){ + curText++; + if(curText>=gpuConfig.nMaxTextures)curText=0; + } + + + tbw=256; + psxVOffset.w=psxVuw+(texinfo.y<<10)+texinfo.x; + + uint32_t *pimage = image; + + switch(texinfo.colormode) + { + //4bit clut + case 0: + for (sprCY=0;sprCY<256;sprCY++){ + psxVOffset2.b=psxVOffset.b; + for (sprCX=0;sprCX<256;sprCX+=2){ + tC = (*psxVOffset2.b)&0x0f; + *pimage = torgba[psxVuw[clutP+tC]]; + pimage++; + + tC = (*psxVOffset2.b>>4)&0x0f; + *pimage = torgba[psxVuw[clutP+tC]]; + pimage++; + + psxVOffset2.b++; + } + psxVOffset.w+=1024; + } + break; + + //8bit clut + case 1: + if(texinfo.x==960)tbw=128; + for (sprCY=0;sprCY<256;sprCY++){ + psxVOffset2.b=psxVOffset.b; + for (sprCX=0;sprCX<tbw;sprCX++){ + tC = *psxVOffset2.b; + image[(sprCY<<8)+sprCX] = torgba[psxVuw[clutP+tC]]; + psxVOffset2.b++; + } + psxVOffset.w+=1024; + } + break; + + //15bit direct + case 2: + if(texinfo.x==960)tbw=64; + else if(texinfo.x==896)tbw=128; + else if(texinfo.x==832)tbw=192; + + for (sprCY=0;sprCY<256;sprCY++){ + psxVOffset2.w=psxVOffset.w; + for (sprCX=0;sprCX<tbw;sprCX++){ + color = *psxVOffset2.w; + image[(sprCY<<8)+sprCX] = torgba[color]; + psxVOffset2.w++; + } + psxVOffset.w+=1024; + } + break; + } + glTexSubImage2D(GL_TEXTURE_2D,0,0,0,256,256,GL_RGBA,GL_UNSIGNED_BYTE,image); +} + + +void setSpriteBlendMode(int32_t command){ + unsigned char *baseAddr = (unsigned char *)&command; + + //color info is 0-127, or bit 0x80 to indicate full color + //note: above applies to texture (and sprite) color shading info only? + unsigned char r,g,b; + r = texshade[baseAddr[0]]; + g = texshade[baseAddr[1]]; + b = texshade[baseAddr[2]]; + + if(baseAddr[3]&2){ //if blending on + //if(TransRate[texinfo.abr].change && !transparent){ + //glBlendEquation(TransRate[texinfo.abr].mode); + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + //} + if(baseAddr[3]&1){ //should always be 0 for sprite? Apparantly not... + glColor4ub(255,255,255,gAlpha); + }else{ + glColor4ub(r,g,b,gAlpha); + } + }else{ + //if(TransRate[texinfo.abr].change && transparent){ + //glBlendEquation(TransRate[0].mode); + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + //} + if(baseAddr[3]&1){ + glColor3ub(255,255,255); + }else{ + glColor3ub(r,g,b); + } + } +} + +void primSprt8(unsigned char * baseAddr) +{ +/* + fixed size (8x8) sprite +*/ + uint32_t *gpuData = (uint32_t *)baseAddr; + short *gpuPoint = (short*) baseAddr; + int32_t clutP; + short tx,ty; + short x,y; + + //gllog(2,"Sprt8x8 : %d,%d %02x",gpuPoint[2],gpuPoint[3],baseAddr[3]); + clutP = (gpuData[2]>>12) & 0x7fff0;//0xffff0; + tx = (short)(gpuData[2] & 0x000000ff); + ty = (short)((gpuData[2]>>8) & 0x000000ff); + + x = (gpuPoint[2]<<21)>>21; + y = (gpuPoint[3]<<21)>>21; + + x += psxDraw.offsetX; + y += psxDraw.offsetY; + + setupTexture(clutP); + setSpriteBlendMode(*gpuData); + + /*switch(baseAddr[3]&3){ + case 0: + glColor3ub(baseAddr[0],baseAddr[1],baseAddr[2]); + break; + case 1: + glColor3ub(255,255,255); + break; + case 2: + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],gAlpha); + break; + case 3: + glColor4ub(255,255,255,gAlpha); + break; + }*/ + + glBegin(GL_POLYGON); + glTexCoord2s(tx,ty); + glVertex2s(x,y); + glTexCoord2s(tx+7,ty); + glVertex2s(x+8,y); + glTexCoord2s(tx+7,ty+7); + glVertex2s(x+8,y+8); + glTexCoord2s(tx,ty+7); + glVertex2s(x,y+8); + glEnd(); + + //draw opaque areas of texture + if(baseAddr[3]&2){ + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_EQUAL, 1); + glColor3ub(255,255,255); + glDisable(GL_BLEND); + glBegin(GL_POLYGON); + glTexCoord2s(tx,ty); + glVertex2s(x,y); + glTexCoord2s(tx+7,ty); + glVertex2s(x+8,y); + glTexCoord2s(tx+7,ty+7); + glVertex2s(x+8,y+8); + glTexCoord2s(tx,ty+7); + glVertex2s(x,y+8); + glEnd(); + glEnable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + } + + glBindTexture(GL_TEXTURE_2D,nullid); +} + +void primSprt16(unsigned char * baseAddr) +{ +/* + fixed size (16x16) sprite +*/ + uint32_t *gpuData = (uint32_t *)baseAddr; + short *gpuPoint = (short*) baseAddr; + int32_t clutP; + short tx,ty; + short x,y; + + //gllog(2,"Sprt16x16 : %d,%d %02x",gpuPoint[2],gpuPoint[3],baseAddr[3]); + clutP = (gpuData[2]>>12) & 0x7fff0;//0xffff0; + tx = (short)(gpuData[2] & 0x000000ff); + ty = (short)((gpuData[2]>>8) & 0x000000ff); + + x = (gpuPoint[2]<<21)>>21; + y = (gpuPoint[3]<<21)>>21; + + x += psxDraw.offsetX; + y += psxDraw.offsetY; + + setupTexture(clutP); + setSpriteBlendMode(*gpuData); + + glBegin(GL_POLYGON); + glTexCoord2s(tx,ty); + glVertex2s(x,y); + glTexCoord2s(tx+15,ty); + glVertex2s(x+16,y); + glTexCoord2s(tx+15,ty+15); + glVertex2s(x+16,y+16); + glTexCoord2s(tx,ty+15); + glVertex2s(x,y+16); + glEnd(); + + //draw opaque areas of texture + if(baseAddr[3]&2){ + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_EQUAL, 1); + glColor3ub(255,255,255); + glDisable(GL_BLEND); + glBegin(GL_POLYGON); + glTexCoord2s(tx,ty); + glVertex2s(x,y); + glTexCoord2s(tx+15,ty); + glVertex2s(x+16,y); + glTexCoord2s(tx+15,ty+15); + glVertex2s(x+16,y+16); + glTexCoord2s(tx,ty+15); + glVertex2s(x,y+16); + glEnd(); + glEnable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + } + + + glBindTexture(GL_TEXTURE_2D,nullid); +} + +void primSprtS(unsigned char * baseAddr) +{ +/* + free size (up to 256x256) sprite +*/ + uint32_t *gpuData = (uint32_t *)baseAddr; + short *gpuPoint = (short*) baseAddr; + int32_t clutP; + short tx,ty,sprtW,sprtH; + short tx1,tx2,ty1,ty2; + short x,y; + + clutP = (gpuData[2]>>12) & 0x7fff0;//0xffff0; + + tx = (short)(gpuData[2] & 0x000000ff); + ty = (short)((gpuData[2]>>8) & 0x000000ff); + sprtW = (short)(gpuData[3] & 0x3ff); + sprtH = (short)((gpuData[3]>>16) & 0x1ff); + + x = (gpuPoint[2]<<21)>>21; + y = (gpuPoint[3]<<21)>>21; + + x += psxDraw.offsetX; + y += psxDraw.offsetY; + + //gllog(2,"Sprt : %04x,%04x - %04x,%04x code=%02x pal=%05x",gpuPoint[2],gpuPoint[3],gpuPoint[6],gpuPoint[7],baseAddr[3],clutP); + /*if(textAddrX==320&&textAddrY==0){ + gllog(2,"Sprt : %d,%d - %d,%d pal=%05x",gpuPoint[2],gpuPoint[3],gpuPoint[6],gpuPoint[7],gpuData[2]>>12); + }*/ + + //scaled instead of repeated for now... + #define min(a,b) ((a) < (b) ? (a) : (b)) + + short minw = min(psxDraw.texwinX2, sprtW); + short minh = min(psxDraw.texwinY2, sprtH); + + tx1 = tx + psxDraw.texwinX1; + tx2 = tx1 + minw - 1; + ty1 = ty + psxDraw.texwinY1; + ty2 = ty1 + minh - 1; +/* + short tswap; + + #define swap(a,b) tswap = (a); (a)=(b); (b) = tswap + + switch (texinfo.mirror) + { + case 1: + swap(tx1, tx2); + break; + case 2: + swap(ty1, ty2); + break; + case 3: + swap(tx1,tx2); + swap(ty1,ty2); + break; + } +*/ + + setupTexture(clutP); + setSpriteBlendMode(*gpuData); + + glBegin(GL_POLYGON); + glTexCoord2s(tx1, ty1); + glVertex2s(x,y); + glTexCoord2s(tx2, ty1); + glVertex2s(x+sprtW,y); + glTexCoord2s(tx2, ty2); + glVertex2s(x+sprtW,y+sprtH); + glTexCoord2s(tx1, ty2); + glVertex2s(x,y+sprtH); + glEnd(); + + //draw opaque areas of texture + if(baseAddr[3]&2){ + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_EQUAL, 1); + glDisable(GL_BLEND); + glColor3ub(255,255,255); + glBegin(GL_POLYGON); + glTexCoord2s(tx1, ty1); + glVertex2s(x,y); + glTexCoord2s(tx2, ty1); + glVertex2s(x+sprtW,y); + glTexCoord2s(tx2, ty2); + glVertex2s(x+sprtW,y+sprtH); + glTexCoord2s(tx1, ty2); + glVertex2s(x,y+sprtH); + glEnd(); + glEnable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + } + + glBindTexture(GL_TEXTURE_2D,nullid); +} + + +void primLineF2(unsigned char *baseAddr) +{ +/* + Flat Line 2 vertices +*/ + short *gpuPoint=((short *) baseAddr); + short x1,y1,x2,y2; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[4]<<21)>>21; + y2 = (gpuPoint[5]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + + + if(baseAddr[3]&2){ + if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + } + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],gAlpha); + }else{ + if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + } + glColor3ub(baseAddr[0],baseAddr[1],baseAddr[2]); + } + /*if(baseAddr[3]&2){ + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],gAlpha); + }else{ + glColor3ub(baseAddr[0],baseAddr[1],baseAddr[2]); + }*/ + glBegin(GL_LINES); + glVertex2s(x1,y1); + glVertex2s(x2,y2); + glEnd(); +} + +void primLineG2(unsigned char *baseAddr) +{ +/* + Goraud Line 2 vertices +*/ + short *gpuPoint=((short *) baseAddr); + short x1,y1,x2,y2; + unsigned char alpha; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[6]<<21)>>21; + y2 = (gpuPoint[7]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + + + if(baseAddr[3]&2){ + if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + } + alpha=gAlpha; + }else{ + if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + } + alpha=255; + } + /*if(baseAddr[3]&2){ + alpha=gAlpha; + }else{ + alpha=255; + }*/ + glBegin(GL_LINES); + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],alpha); + glVertex2s(x1,y1); + glColor4ub(baseAddr[8],baseAddr[9],baseAddr[10],alpha); + glVertex2s(x2,y2); + glEnd(); +} + +void primPolyF3(unsigned char *baseAddr) +{ +/* + Flat Shaded Polygon 3 vertices +*/ + short *gpuPoint=((short *) baseAddr); + short x1,x2,x3,y1,y2,y3; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[4]<<21)>>21; + y2 = (gpuPoint[5]<<21)>>21; + x3 = (gpuPoint[6]<<21)>>21; + y3 = (gpuPoint[7]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + x3 += psxDraw.offsetX; + y3 += psxDraw.offsetY; + + //gllog(77,"!GPU! P3 F %d,%d %d,%d %d,%d\n",lx0,ly0,lx1,ly1,lx2,ly2); + + if(baseAddr[3]&2){ + if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + } + gAlpha = TransRate[texinfo.abr].alpha; + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],gAlpha); + }else{ + if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + } + glColor3ub(baseAddr[0],baseAddr[1],baseAddr[2]); + } + glBegin(GL_POLYGON); + glVertex2s(x1,y1); + glVertex2s(x2,y2); + glVertex2s(x3,y3); + glEnd(); +} + +void primPolyF4(unsigned char *baseAddr) +{ +/* + Flat Shaded Polygon 4 vertices +*/ + short *gpuPoint=((short *) baseAddr); + short x1,x2,x3,x4,y1,y2,y3,y4; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[4]<<21)>>21; + y2 = (gpuPoint[5]<<21)>>21; + x3 = (gpuPoint[6]<<21)>>21; + y3 = (gpuPoint[7]<<21)>>21; + x4 = (gpuPoint[8]<<21)>>21; + y4 = (gpuPoint[9]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + x3 += psxDraw.offsetX; + y3 += psxDraw.offsetY; + x4 += psxDraw.offsetX; + y4 += psxDraw.offsetY; + + //gllog(77,"!GPU! P4 F %d,%d %d,%d %d,%d %d,%d %6x\n",lx0,ly0,lx1,ly1,lx2,ly2,lx3,ly3,gpuData[0]); + + if(baseAddr[3]&2){ + if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + } + gAlpha = TransRate[texinfo.abr].alpha; + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],gAlpha); + }else{ + if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + } + glColor3ub(baseAddr[0],baseAddr[1],baseAddr[2]); + } + glBegin(GL_POLYGON); + glVertex2s(x1,y1); + glVertex2s(x2,y2); + glVertex2s(x4,y4); + glVertex2s(x3,y3); + glEnd(); +} + +void primPolyG3(unsigned char *baseAddr) +{ +/* + Goraud Shaded Polygon 3 vertices +*/ + short *gpuPoint=((short *) baseAddr); + unsigned char alpha; + short x1,x2,x3,y1,y2,y3; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[6]<<21)>>21; + y2 = (gpuPoint[7]<<21)>>21; + x3 = (gpuPoint[10]<<21)>>21; + y3 = (gpuPoint[11]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + x3 += psxDraw.offsetX; + y3 += psxDraw.offsetY; + + //gllog(77,"!GPU! P3 G %d,%d %d,%d %d,%d\n",lx0,ly0,lx1,ly1,lx2,ly2); + + if(baseAddr[3]&2){ + if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + } + alpha = TransRate[texinfo.abr].alpha; + }else{ + if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + } + alpha=255; + } + glBegin(GL_POLYGON); + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],alpha); + glVertex2s(x1,y1); + glColor4ub(baseAddr[8],baseAddr[9],baseAddr[10],alpha); + glVertex2s(x2,y2); + glColor4ub(baseAddr[16],baseAddr[17],baseAddr[18],alpha); + glVertex2s(x3,y3); + glEnd(); +} + +void primPolyG4(unsigned char * baseAddr) +{ +/* + Goraud Shaded Polygon 4 vertices +*/ + short *gpuPoint=((short *) baseAddr); + short x1,x2,x3,x4,y1,y2,y3,y4; + unsigned char alpha; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[6]<<21)>>21; + y2 = (gpuPoint[7]<<21)>>21; + x3 = (gpuPoint[10]<<21)>>21; + y3 = (gpuPoint[11]<<21)>>21; + x4 = (gpuPoint[14]<<21)>>21; + y4 = (gpuPoint[15]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + x3 += psxDraw.offsetX; + y3 += psxDraw.offsetY; + x4 += psxDraw.offsetX; + y4 += psxDraw.offsetY; + + if(baseAddr[3]&2){ + if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + } + alpha = TransRate[texinfo.abr].alpha; + }else{ + if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + } + alpha=255; + } + glBegin(GL_POLYGON); + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],alpha); + glVertex2s(x1,y1); + glColor4ub(baseAddr[8],baseAddr[9],baseAddr[10],alpha); + glVertex2s(x2,y2); + glColor4ub(baseAddr[24],baseAddr[25],baseAddr[26],alpha); + glVertex2s(x4,y4); + glColor4ub(baseAddr[16],baseAddr[17],baseAddr[18],alpha); + glVertex2s(x3,y3); + glEnd(); +} + +void primPolyFT3(unsigned char * baseAddr) +{ +/* + Flat Shaded Textured Polygon 3 vertices +*/ + uint32_t *gpuData = (uint32_t *)baseAddr; + short *gpuPoint=((short *) baseAddr); + int32_t clutP; + short x1,x2,x3,y1,y2,y3; + short tx0,ty0,tx1,ty1,tx2,ty2; + unsigned short gpuDataX; + + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[6]<<21)>>21; + y2 = (gpuPoint[7]<<21)>>21; + x3 = (gpuPoint[10]<<21)>>21; + y3 = (gpuPoint[11]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + x3 += psxDraw.offsetX; + y3 += psxDraw.offsetY; + + tx0 = (short)(gpuData[2] & 0xff); + ty0 = (short)((gpuData[2]>>8) & 0xff); + tx1 = (short)(gpuData[4] & 0xff); + ty1 = (short)((gpuData[4]>>8) & 0xff); + tx2 = (short)(gpuData[6] & 0xff); + ty2 = (short)((gpuData[6]>>8) & 0xff); + //gllog(77,"!GPU! P3 F %d,%d %d,%d %d,%d\n",lx0,ly0,lx1,ly1,lx2,ly2); + gpuDataX=(unsigned short)(gpuData[4]>>16); + + int32_t tempABR = (gpuDataX >>5) & 0x3; + if(texinfo.abr!=tempABR){ + texinfo.abr = tempABR; + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + gAlpha=TransRate[texinfo.abr].alpha; + transparent=TRUE; + } + UpdateTextureInfo(gpuDataX); + + /*switch(texinfo.abr){ + case 0: + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=128; + break; + case 1: + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=0; + break; + case 2: + glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR); + gAlpha=0; + break; + case 3: + glBlendFunc(GL_SRC_ALPHA,GL_ONE); + gAlpha=64; + break; + }*/ + //gllog(77," CMD: P3TF: %d,%d TP=%d",textAddrX,textAddrY,textTP); + //gllog(77," CMD: P3TF: %d,%d %02x",lx0,ly0,baseAddr[3]); + + clutP = (gpuData[2]>>12) & 0x7fff0;//0xffff0; + setupTexture(clutP); + //setPolyTexBlendMode(*gpuData); + + baseAddr[0] = texshade[baseAddr[0]]; + baseAddr[1] = texshade[baseAddr[1]]; + baseAddr[2] = texshade[baseAddr[2]]; + + if(baseAddr[3]&2){ + if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + } + if(baseAddr[3]&1){ + glColor4ub(255,255,255,gAlpha); + //glColor4ub(255,255,255,255); + }else{ + glColor4ub(baseAddr[0],baseAddr[1],baseAddr[2],gAlpha); + } + }else{ + //if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + //} + if(baseAddr[3]&1){ + glColor3ub(255,255,255); + }else{ + glColor3ub(baseAddr[0],baseAddr[1],baseAddr[2]); + } + } + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + + short xtest = (x1-x2)*(tx0-tx1); + if (xtest == 0) + xtest = (x1-x3)*(tx0-tx2); + if (xtest < 0) + glTranslatef(1.0f, 0, 0); + + short ytest = (y1-y2)*(ty0-ty1); + if (ytest == 0) + ytest = (y1-y3)*(ty0-ty2); + if (ytest < 0) + glTranslatef(0, 1.0f, 0); + + glBegin(GL_POLYGON); + glTexCoord2s(tx0,ty0); + glVertex2s(x1,y1); + glTexCoord2s(tx1,ty1); + glVertex2s(x2,y2); + glTexCoord2s(tx2,ty2); + glVertex2s(x3,y3); + glEnd(); + + glPopMatrix(); + + glBindTexture(GL_TEXTURE_2D,nullid); +} + + +void primPolyFT4(unsigned char * baseAddr) +{ +/* + Flat Shaded Textured Polygon 4 vertices +*/ + + uint32_t *gpuData = (uint32_t *)baseAddr; + short *gpuPoint=((short *) baseAddr); + int32_t clutP; + short x1,x2,x3,x4,y1,y2,y3,y4; + short tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3; + unsigned short gpuDataX; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[6]<<21)>>21; + y2 = (gpuPoint[7]<<21)>>21; + x3 = (gpuPoint[10]<<21)>>21; + y3 = (gpuPoint[11]<<21)>>21; + x4 = (gpuPoint[14]<<21)>>21; + y4 = (gpuPoint[15]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + x3 += psxDraw.offsetX; + y3 += psxDraw.offsetY; + x4 += psxDraw.offsetX; + y4 += psxDraw.offsetY; + + tx0 = (short)(gpuData[2] & 0xff); + ty0 = (short)((gpuData[2]>>8) & 0xff); + tx1 = (short)(gpuData[4] & 0xff); + ty1 = (short)((gpuData[4]>>8) & 0xff); + tx2 = (short)(gpuData[6] & 0xff); + ty2 = (short)((gpuData[6]>>8) & 0xff); + tx3 = (short)(gpuData[8] & 0xff); + ty3 = (short)((gpuData[8]>>8) & 0xff); + //gllog(77,"!GPU! P4 F %d,%d %d,%d %d,%d %d,%d %6x\n",tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3,gpuData[0]); + + gpuDataX=(unsigned short)(gpuData[4]>>16); + + int32_t tempABR = (gpuDataX >> 5) & 0x3; + if(texinfo.abr!=tempABR){ + texinfo.abr = tempABR; + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + gAlpha=TransRate[texinfo.abr].alpha; + transparent=TRUE; + } + UpdateTextureInfo(gpuDataX); + + /*switch(texinfo.abr){ + case 0: + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=128; + break; + case 1: + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=0; + break; + case 2: + glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR); + gAlpha=0; + break; + case 3: + glBlendFunc(GL_SRC_ALPHA,GL_ONE); + gAlpha=64; + break; + }*/ + //gllog(77," CMD: P4TF: %d,%d TP=%d",textAddrX,textAddrY,textTP); + //gllog(77," CMD: P4TG: %d,%d,%d,%d",baseAddr[3],baseAddr[15],baseAddr[39],baseAddr[27]); + //gllog(77," CMD: P4TF: %d,%d %02x",lx0,ly0,baseAddr[3]); + + clutP = (gpuData[2]>>12) & 0x7fff0;//0xffff0; + setupTexture(clutP); + + if(baseAddr[3]&2){ + if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + } + if(baseAddr[3]&1){ + glColor4ub(255,255,255,gAlpha); + //glColor4ub(255,255,255,255); + }else{ + glColor4ub(texshade[baseAddr[0]],texshade[baseAddr[1]],texshade[baseAddr[2]],gAlpha); + } + }else{ + //if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + //} + if(baseAddr[3]&1){ + glColor3ub(255,255,255); + }else{ + glColor3ub(texshade[baseAddr[0]],texshade[baseAddr[1]],texshade[baseAddr[2]]); + } + } + + //verify order, otherwise it will pick wrong texture pixel if backwards + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + + short xtest = (x1-x2)^(tx0-tx1); + if (xtest == 0) + xtest = (x1-x3)^(tx0-tx2); + if (xtest < 0) + glTranslatef(1.0f, 0, 0); + + short ytest = (y1-y2)^(ty0-ty1); + if (ytest == 0) + ytest = (y1-y3)^(ty0-ty2); + if (ytest < 0) + glTranslatef(0, 1.0f, 0); + + glBegin(GL_POLYGON); + glTexCoord2s(tx0,ty0); + glVertex2s(x1,y1); + glTexCoord2s(tx1,ty1); + glVertex2s(x2,y2); + glTexCoord2s(tx3,ty3); + glVertex2s(x4,y4); + glTexCoord2s(tx2,ty2); + glVertex2s(x3,y3); + glEnd(); + + glPopMatrix(); + + glBindTexture(GL_TEXTURE_2D,nullid); +} + +void primPolyGT3(unsigned char *baseAddr) +{ +/* + Goraud Shaded Textured Polygon 3 vertices +*/ + uint32_t *gpuData = (uint32_t *)baseAddr; + short *gpuPoint=((short *) baseAddr); + int32_t clutP; + short x1,x2,x3,y1,y2,y3; + short tx0,ty0,tx1,ty1,tx2,ty2; + unsigned short gpuDataX; + unsigned char alpha; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[8]<<21)>>21; + y2 = (gpuPoint[9]<<21)>>21; + x3 = (gpuPoint[14]<<21)>>21; + y3 = (gpuPoint[15]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + x3 += psxDraw.offsetX; + y3 += psxDraw.offsetY; + + + tx0 = (short)(gpuData[2] & 0xff); + ty0 = (short)((gpuData[2]>>8) & 0xff); + tx1 = (short)(gpuData[5] & 0xff); + ty1 = (short)((gpuData[5]>>8) & 0xff); + tx2 = (short)(gpuData[8] & 0xff); + ty2 = (short)((gpuData[8]>>8) & 0xff); + //gllog(77,"!GPU! P3TG %d,%d %d,%d %d,%d\n",lx0,ly0,lx1,ly1,lx2,ly2); + + gpuDataX=(unsigned short)(gpuData[5]>>16); + int32_t tempABR = (gpuDataX >> 5) & 0x3; + if(texinfo.abr!=tempABR){ + texinfo.abr = tempABR; + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + gAlpha=TransRate[texinfo.abr].alpha; + transparent=TRUE; + } + UpdateTextureInfo(gpuDataX); + + /*switch(texinfo.abr){ + case 0: + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=128; + break; + case 1: + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=0; + break; + case 2: + glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR); + gAlpha=0; + break; + case 3: + glBlendFunc(GL_SRC_ALPHA,GL_ONE); + gAlpha=64; + break; + }*/ + + //gllog(77," CMD: P3TG: %d,%d TP=%d",textAddrX,textAddrY,textTP); + //gllog(77," CMD: P3TG: %d,%d %02x",lx0,ly0,baseAddr[3]); + + clutP = (gpuData[2]>>12) & 0x7fff0;//0xffff0; + setupTexture(clutP); + if(baseAddr[3]&2){ + //if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + //} + alpha=gAlpha; + }else{ + //if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + //} + alpha=255; + } + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + + short xtest = (x1-x2)*(tx0-tx1); + if (xtest == 0) + xtest = (x1-x3)*(tx0-tx2); + if (xtest < 0) + glTranslatef(1.0f, 0, 0); + + short ytest = (y1-y2)*(ty0-ty1); + if (ytest == 0) + ytest = (y1-y3)*(ty0-ty2); + if (ytest < 0) + glTranslatef(0, 1.0f, 0); + + glBegin(GL_POLYGON); + glColor4ub(texshade[baseAddr[0]],texshade[baseAddr[1]],texshade[baseAddr[2]],alpha); + glTexCoord2s(tx0,ty0); + glVertex2s(x1,y1); + glColor4ub(texshade[baseAddr[12]],texshade[baseAddr[13]],texshade[baseAddr[14]],alpha); + glTexCoord2s(tx1,ty1); + glVertex2s(x2,y2); + glColor4ub(texshade[baseAddr[24]],texshade[baseAddr[25]],texshade[baseAddr[26]],alpha); + glTexCoord2s(tx2,ty2); + glVertex2s(x3,y3); + glEnd(); + + glPopMatrix(); + + glBindTexture(GL_TEXTURE_2D,nullid); +} + +void primPolyGT4(unsigned char *baseAddr) +{ +/* + Goraud Shaded Textured Polygon 4 vertices +*/ + uint32_t *gpuData = (uint32_t *)baseAddr; + short *gpuPoint=((short *) baseAddr); + int32_t clutP; + short x1,y1,x2,y2,x3,y3,x4,y4; + short tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3; + unsigned short gpuDataX; + unsigned char alpha; + + x1 = (gpuPoint[2]<<21)>>21; + y1 = (gpuPoint[3]<<21)>>21; + x2 = (gpuPoint[8]<<21)>>21; + y2 = (gpuPoint[9]<<21)>>21; + x3 = (gpuPoint[14]<<21)>>21; + y3 = (gpuPoint[15]<<21)>>21; + x4 = (gpuPoint[20]<<21)>>21; + y4 = (gpuPoint[21]<<21)>>21; + + x1 += psxDraw.offsetX; + y1 += psxDraw.offsetY; + x2 += psxDraw.offsetX; + y2 += psxDraw.offsetY; + x3 += psxDraw.offsetX; + y3 += psxDraw.offsetY; + x4 += psxDraw.offsetX; + y4 += psxDraw.offsetY; + + tx0 = (short)(gpuData[2] & 0xff); + ty0 = (short)((gpuData[2]>>8) & 0xff); + tx1 = (short)(gpuData[5] & 0xff); + ty1 = (short)((gpuData[5]>>8) & 0xff); + tx2 = (short)(gpuData[8] & 0xff); + ty2 = (short)((gpuData[8]>>8) & 0xff); + tx3 = (short)(gpuData[11] & 0xff); + ty3 = (short)((gpuData[11]>>8) & 0xff); + + gpuDataX=(unsigned short)(gpuData[5]>>16); + int32_t tempABR = (gpuDataX >> 5) & 0x3; + if(texinfo.abr!=tempABR){ + texinfo.abr = tempABR; + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + gAlpha=TransRate[texinfo.abr].alpha; + transparent=TRUE; + } + UpdateTextureInfo(gpuDataX); + + /*switch(texinfo.abr){ + case 0: + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=128; + break; + case 1: + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); + gAlpha=0; + break; + case 2: + glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR); + gAlpha=0; + break; + case 3: + glBlendFunc(GL_SRC_ALPHA,GL_ONE); + gAlpha=64; + break; + }*/ + + //gllog(77," CMD: P4TG: %d,%d TP=%d",textAddrX,textAddrY,textTP); + //gllog(77," CMD: P4TG: %d,%d %02x",lx0,ly0,baseAddr[3]); + + clutP = (gpuData[2]>>12) & 0x7fff0;//0xffff0; + setupTexture(clutP); + if(baseAddr[3]&2){ + //if(TransRate[texinfo.abr].change&&!transparent){ + glBlendFunc(TransRate[texinfo.abr].src,TransRate[texinfo.abr].dst); + transparent=TRUE; + //} + alpha=gAlpha; + }else{ + //if(TransRate[texinfo.abr].change&&transparent){ + glBlendFunc(TransRate[0].src,TransRate[0].dst); + transparent=FALSE; + //} + alpha=255; + } + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + + short xtest = (x1-x2)*(tx0-tx1); + if (xtest == 0) + xtest = (x1-x3)*(tx0-tx2); + if (xtest < 0) + glTranslatef(1.0f, 0, 0); + + short ytest = (y1-y2)*(ty0-ty1); + if (ytest == 0) + ytest = (y1-y3)*(ty0-ty2); + if (ytest < 0) + glTranslatef(0, 1.0f, 0); + + glBegin(GL_POLYGON); + glColor4ub(texshade[baseAddr[0]],texshade[baseAddr[1]],texshade[baseAddr[2]],alpha); + glTexCoord2s(tx0,ty0); + glVertex2s(x1,y1); + glColor4ub(texshade[baseAddr[12]],texshade[baseAddr[13]],texshade[baseAddr[14]],alpha); + glTexCoord2s(tx1,ty1); + glVertex2s(x2,y2); + glColor4ub(texshade[baseAddr[36]],texshade[baseAddr[37]],texshade[baseAddr[38]],alpha); + glTexCoord2s(tx3,ty3); + glVertex2s(x4,y4); + glColor4ub(texshade[baseAddr[24]],texshade[baseAddr[25]],texshade[baseAddr[26]],alpha); + glTexCoord2s(tx2,ty2); + glVertex2s(x3,y3); + glEnd(); + + glPopMatrix(); + + glBindTexture(GL_TEXTURE_2D,nullid); +} + + +void primNI(unsigned char *bA) +{ + // primitive not implemented + if (bA[3]) gllog(255,"PRIM: *NI* %02x",bA[3]); +} + + +unsigned char primTableC[256] = +{ + // 00 + 0,0,3,0,0,0,0,0, + // 08 + 0,0,0,0,0,0,0,0, + // 10 + 0,0,0,0,0,0,0,0, + // 18 + 0,0,0,0,0,0,0,0, + // 20 + 4,4,4,4,7,7,7,7, + // 28 + 5,5,5,5,9,9,9,9, + // 30 + 6,6,6,6,9,9,9,9, + // 38 + 8,8,8,8,12,12,12,12, + // 40 + 3,3,3,3,0,0,0,0, // LineF2 + // 48 + 5,5,5,5,6,6,6,6, // LineF3 LineF4 + // 50 + 4,4,4,4,0,0,0,0, // LineG2 + // 58 + 7,7,7,7,9,9,9,9, // LineG3 LineG4 + // 60 + 3,3,3,3,4,4,4,4, // Tile Sprt + // 68 + 2,2,2,2,0,0,0,0, // Tile1 + // 70 + 2,2,2,2,3,3,3,3, // Tile8 Sprt8 + // 78 + 2,2,2,2,3,3,3,3, // Tile16 Sprt16 + // 80 + 4,0,0,0,0,0,0,0, + // 88 + 0,0,0,0,0,0,0,0, + // 90 + 0,0,0,0,0,0,0,0, + // 98 + 0,0,0,0,0,0,0,0, + // a0 + 3,0,0,0,0,0,0,0, + // a8 + 0,0,0,0,0,0,0,0, + // b0 + 0,0,0,0,0,0,0,0, + // b8 + 0,0,0,0,0,0,0,0, + // c0 + 3,0,0,0,0,0,0,0, + // c8 + 0,0,0,0,0,0,0,0, + // d0 + 0,0,0,0,0,0,0,0, + // d8 + 0,0,0,0,0,0,0,0, + // e0 + 0,1,1,1,1,1,1,0, + // e8 + 0,0,0,0,0,0,0,0, + // f0 + 0,0,0,0,0,0,0,0, + // f8 + 0,0,0,0,0,0,0,0 + +}; + +void (*primTableJ[256])(unsigned char *) = +{ + // 00 + primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI, + // 08 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 10 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 18 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 20 + primPolyF3,primPolyF3,primPolyF3,primPolyF3,primPolyFT3,primPolyFT3,primPolyFT3,primPolyFT3, + // 28 + primPolyF4,primPolyF4,primPolyF4,primPolyF4,primPolyFT4,primPolyFT4,primPolyFT4,primPolyFT4, + // 30 + primPolyG3,primPolyG3,primPolyG3,primPolyG3,primPolyGT3,primPolyGT3,primPolyGT3,primPolyGT3, + // 38 + primPolyG4,primPolyG4,primPolyG4,primPolyG4,primPolyGT4,primPolyGT4,primPolyGT4,primPolyGT4, + // 40 + primLineF2,primLineF2,primLineF2,primLineF2,primNI,primNI,primNI,primNI, + // 48 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 50 + primLineG2,primLineG2,primLineG2,primLineG2,primNI,primNI,primNI,primNI, + // 58 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 60 + primTileS,primTileS,primTileS,primTileS,primSprtS,primSprtS,primSprtS,primSprtS, + // 68 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 70 + primNI,primNI,primNI,primNI,primSprt8,primSprt8,primSprt8,primSprt8, + // 78 + primNI,primNI,primNI,primNI,primSprt16,primSprt16,primSprt16,primSprt16, + // 80 + primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 88 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 90 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // 98 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // a0 + primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // a8 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // b0 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // b8 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // c0 + primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // c8 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // d0 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // d8 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // e0 + primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI, + // e8 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // f0 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI, + // f8 + primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI +}; + diff --git a/plugins/dfOpenGL/primitive_drawing.h b/plugins/dfOpenGL/primitive_drawing.h new file mode 100644 index 00000000..5e97c7b6 --- /dev/null +++ b/plugins/dfOpenGL/primitive_drawing.h @@ -0,0 +1,3 @@ + +extern unsigned char primTableC[256]; +extern void (*primTableJ[256])(unsigned char *); |
