Added gfx3d module which emulates the whole GE as part of the core emu. This is step 1 of making every platform share the same 3d code. Step 2 will be to bring down the windows/cocoa OGLRenderer and make it act as the ogl_collector did.

This commit is contained in:
zeromus 2008-09-13 19:34:08 +00:00
parent fa73952d6c
commit b00df5e746
18 changed files with 1834 additions and 4977 deletions

View File

@ -53,6 +53,9 @@
- Added a bunch of crazy templates to the cpu and mmu which speed up a the emu little by optimizing variable accesses [zeromus]
- Add an arm8 cpu load average calculator [zeromus]
? Fix a bug in texture transformation mode 1 [zeromus]
- Added gfx3d module which emulates the whole GE as part of the core emu.
This is step 1 of making every platform share the same 3d code.
Step 2 will be to bring down the windows/cocoa OGLRenderer and make it act as the ogl_collector did. [zeromus]
0.7.3 -> 0.8

View File

@ -2,7 +2,7 @@ Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007 Free Software Foundation, Inc.
2006 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
@ -67,9 +67,6 @@ The simplest way to compile this package is:
all sorts of other programs in order to regenerate files that came
with the distribution.
6. Often, you can also type `make uninstall' to remove the installed
files again.
Compilers and Options
=====================

View File

@ -36,6 +36,7 @@
#include "wifi.h"
#include "registers.h"
#include "render3D.h"
#include "gfx3d.h"
#define ROM_MASK 3
@ -652,9 +653,9 @@ u16 FASTCALL _MMU_read16(u32 adr)
switch(adr)
{
case 0x04000604:
return (gpu3D->NDS_3D_GetNumPolys()&2047);
return (gfx3d_GetNumPolys()&2047);
case 0x04000606:
return (gpu3D->NDS_3D_GetNumVertex()&8191);
return (gfx3d_GetNumVertex()&8191);
case REG_IPCFIFORECV : /* TODO (clear): ??? */
//printlog("Stopped IPCFIFORECV\n");
@ -751,7 +752,7 @@ u32 FASTCALL _MMU_read32(u32 adr)
case 0x0400067C:
{
//LOG("4000640h..67Fh - CLIPMTX_RESULT - Read Current Clip Coordinates Matrix (R)");
return gpu3D->NDS_3D_GetClipMatrix ((adr-0x04000640)/4);
return gfx3d_GetClipMatrix ((adr-0x04000640)/4);
}
case 0x04000680:
case 0x04000684:
@ -764,12 +765,12 @@ u32 FASTCALL _MMU_read32(u32 adr)
case 0x040006A0:
{
//LOG("4000680h..6A3h - VECMTX_RESULT - Read Current Directional Vector Matrix (R)");
return gpu3D->NDS_3D_GetDirectionalMatrix ((adr-0x04000680)/4);
return gfx3d_GetDirectionalMatrix ((adr-0x04000680)/4);
}
case 0x4000604:
{
return (gpu3D->NDS_3D_GetNumPolys()&2047) & ((gpu3D->NDS_3D_GetNumVertex()&8191) << 16);
return (gfx3d_GetNumPolys()&2047) & ((gfx3d_GetNumVertex()&8191) << 16);
//LOG ("read32 - RAM_COUNT -> 0x%X", ((u32 *)(MMU.MMU_MEM[proc][(adr>>20)&0xFF]))[(adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF])>>2]);
}
@ -1300,7 +1301,7 @@ void FASTCALL _MMU_write16(u32 adr, u16 val)
{
//toon table
((u16 *)(MMU.MMU_MEM[proc][0x40]))[(adr-0x04000000)>>1] = val;
gpu3D->NDS_3D_UpdateToonTable(&((MMU.MMU_MEM[proc][0x40]))[(0x380)]);
gfx3d_UpdateToonTable(&((MMU.MMU_MEM[proc][0x40]))[(0x380)]);
}
/* Adress is an IO register */
else switch(adr)
@ -1310,7 +1311,7 @@ void FASTCALL _MMU_write16(u32 adr, u16 val)
((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x35C>>1] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_FogOffset (val);
gfx3d_glFogOffset (val);
}
return;
}
@ -1319,7 +1320,7 @@ void FASTCALL _MMU_write16(u32 adr, u16 val)
((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x340>>1] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_AlphaFunc(val);
gfx3d_glAlphaFunc(val);
}
return;
}
@ -1328,7 +1329,7 @@ void FASTCALL _MMU_write16(u32 adr, u16 val)
((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x060>>1] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Control(val);
gfx3d_Control(val);
}
return;
}
@ -1337,7 +1338,7 @@ void FASTCALL _MMU_write16(u32 adr, u16 val)
((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x354>>1] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_ClearDepth(val);
gfx3d_glClearDepth(val);
}
return;
}
@ -1957,14 +1958,14 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x400>>2] = val;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_CallList(val);
gfx3d_glCallList(val);
}
}
else if(adr >= 0x04000380 && adr <= 0x040003BC)
{
//toon table
((u32 *)(MMU.MMU_MEM[proc][0x40]))[(adr-0x04000000)>>2] = val;
gpu3D->NDS_3D_UpdateToonTable(&((MMU.MMU_MEM[proc][0x40]))[(0x380)]);
gfx3d_UpdateToonTable(&((MMU.MMU_MEM[proc][0x40]))[(0x380)]);
}
else switch(adr)
{
@ -1974,7 +1975,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x340>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_AlphaFunc(val);
gfx3d_glAlphaFunc(val);
}
return;
}
@ -1984,7 +1985,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x350>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_ClearColor(val);
gfx3d_glClearColor(val);
}
return;
}
@ -1994,7 +1995,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x354>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_ClearDepth(val);
gfx3d_glClearDepth(val);
}
return;
}
@ -2004,7 +2005,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x358>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_FogColor(val);
gfx3d_glFogColor(val);
}
return;
}
@ -2013,7 +2014,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x35C>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_FogOffset(val);
gfx3d_glFogOffset(val);
}
return;
}
@ -2024,7 +2025,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_MatrixMode(val);
gfx3d_glMatrixMode(val);
}
return;
}
@ -2034,7 +2035,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x444>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_PushMatrix();
gfx3d_glPushMatrix();
}
return;
}
@ -2044,7 +2045,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x448>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_PopMatrix(val);
gfx3d_glPopMatrix(val);
}
return;
}
@ -2054,7 +2055,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x44C>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_StoreMatrix(val);
gfx3d_glStoreMatrix(val);
}
return;
}
@ -2064,7 +2065,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x450>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_RestoreMatrix(val);
gfx3d_glRestoreMatrix(val);
}
return;
}
@ -2074,7 +2075,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x454>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_LoadIdentity();
gfx3d_glLoadIdentity();
}
return;
}
@ -2084,7 +2085,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x458>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_LoadMatrix4x4(val);
gfx3d_glLoadMatrix4x4(val);
}
return;
}
@ -2094,7 +2095,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x45C>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_LoadMatrix4x3(val);
gfx3d_glLoadMatrix4x3(val);
}
return;
}
@ -2104,7 +2105,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x460>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_MultMatrix4x4(val);
gfx3d_glLoadMatrix4x4(val);
}
return;
}
@ -2114,7 +2115,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x464>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_MultMatrix4x3(val);
gfx3d_glMultMatrix4x3(val);
}
return;
}
@ -2124,7 +2125,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x468>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_MultMatrix3x3(val);
gfx3d_glMultMatrix3x3(val);
}
return;
}
@ -2134,7 +2135,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x46C>>2] = val;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_Scale(val);
gfx3d_glScale(val);
}
return;
}
@ -2144,7 +2145,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x470>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Translate(val);
gfx3d_glTranslate(val);
}
return;
}
@ -2154,7 +2155,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x480>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Color3b(val);
gfx3d_glColor3b(val);
}
return;
}
@ -2164,7 +2165,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x484>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Normal(val);
gfx3d_glNormal(val);
}
return;
}
@ -2174,7 +2175,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x488>>2] = val;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_TexCoord(val);
gfx3d_glTexCoord(val);
}
return;
}
@ -2184,7 +2185,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x48C>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Vertex16b(val);
gfx3d_glVertex16b(val);
}
return;
}
@ -2194,7 +2195,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x490>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Vertex10b(val);
gfx3d_glVertex10b(val);
}
return;
}
@ -2204,7 +2205,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x494>>2] = val;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_Vertex3_cord(0,1,val);
gfx3d_glVertex3_cord(0,1,val);
}
return;
}
@ -2214,7 +2215,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x498>>2] = val;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_Vertex3_cord(0,2,val);
gfx3d_glVertex3_cord(0,2,val);
}
return;
}
@ -2224,7 +2225,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x49C>>2] = val;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_Vertex3_cord(1,2,val);
gfx3d_glVertex3_cord(1,2,val);
}
return;
}
@ -2234,7 +2235,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4A0>>2] = val;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_Vertex_rel (val);
gfx3d_glVertex_rel (val);
}
return;
}
@ -2244,7 +2245,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4A4>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_PolygonAttrib(val);
gfx3d_glPolygonAttrib(val);
}
return;
}
@ -2254,7 +2255,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4A8>>2] = val;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_TexImage(val);
gfx3d_glTexImage(val);
}
return;
}
@ -2264,7 +2265,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4AC>>2] = val&0x1FFF;
if(proc==ARMCPU_ARM9)
{
gpu3D->NDS_3D_TexPalette(val&0x1FFFF);
gfx3d_glTexPalette(val&0x1FFFF);
}
return;
}
@ -2274,7 +2275,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4C0>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Material0 (val);
gfx3d_glMaterial0 (val);
}
return;
}
@ -2284,7 +2285,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4C4>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Material1 (val);
gfx3d_glMaterial1 (val);
}
return;
}
@ -2294,7 +2295,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4C8>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_LightDirection (val);
gfx3d_glLightColor (val);
}
return;
}
@ -2304,7 +2305,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4CC>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_LightColor(val);
gfx3d_glLightColor(val);
}
return;
}
@ -2314,7 +2315,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4D0>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Shininess(val);
gfx3d_glShininess(val);
}
return;
}
@ -2324,7 +2325,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x500>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Begin(val);
gfx3d_glBegin(val);
}
return;
}
@ -2334,7 +2335,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x504>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_End();
gfx3d_glEnd();
}
return;
}
@ -2344,7 +2345,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x540>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_Flush(val);
gfx3d_glFlush(val);
}
return;
}
@ -2354,7 +2355,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x580>>2] = val;
if(proc == ARMCPU_ARM9)
{
gpu3D->NDS_3D_ViewPort(val);
gfx3d_glViewPort(val);
}
return;
}

View File

@ -23,6 +23,6 @@ libdesmume_a_SOURCES = \
SPU.cpp SPU.h \
gdbstub.h \
matrix.cpp matrix.h \
opengl_collector_3Demu.cpp opengl_collector_3Demu.h \
gfx3d.cpp gfx3d.h \
thumb_instructions.cpp thumb_instructions.h types.h
libdesmume_a_LIBADD = fs-$(desmume_arch).$(OBJEXT)

View File

@ -30,7 +30,7 @@
#include "MMU.h"
#include "cflash.h"
#include "ROMReader.h"
#include "render3D.h"
#include "gfx3d.h"
/* the count of bytes copied from the firmware into memory */
#define NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT 0x70
@ -159,6 +159,8 @@ int NDS_Init( void) {
if (Screen_Init(GFXCORE_DUMMY) != 0)
return -1;
gfx3d_init();
#ifdef GDB_STUB
armcpu_new(&NDS_ARM7,1, arm7_mem_if, arm7_ctrl_iface);
armcpu_new(&NDS_ARM9,0, arm9_mem_if, arm9_ctrl_iface);
@ -1027,7 +1029,7 @@ NDS_exec(s32 nb, BOOL force)
nds.lignerendu = FALSE;
if(nds.VCount==192)
{
gpu3D->NDS_3D_VBlankSignal();
gfx3d_VBlankSignal();
T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 1);
T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 1);

1472
desmume/src/gfx3d.cpp Normal file

File diff suppressed because it is too large Load Diff

160
desmume/src/gfx3d.h Normal file
View File

@ -0,0 +1,160 @@
/*
Copyright (C) 2008 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _GFX3D_H_
#define _GFX3D_H_
#include "types.h"
void gfx3d_init();
struct POLY {
int type; //tri or quad
int vertIndexes[4]; //up to four verts can be referenced by this poly
u32 polyAttr, texParam, texPalette; //the hardware rendering params
float projMatrix[16];
};
#define POLYLIST_SIZE 6000
//#define POLYLIST_SIZE 2048
struct POLYLIST {
int count;
POLY list[POLYLIST_SIZE];
};
struct VERT {
float coord[4];
float texcoord[2];
int color[4];
u32 depth;
};
#define VERTLIST_SIZE 30000
//#define VERTLIST_SIZE 10000
struct VERTLIST {
int count;
VERT list[VERTLIST_SIZE];
};
//used to communicate state to the renderer
struct GFX3D
{
GFX3D()
: enableTexturing(true)
, shading(TOON)
, enableAlphaTest(true)
, enableAlphaBlending(true)
, enableAntialiasing(false)
, enableEdgeMarking(false)
, polylist(0)
, vertlist(0)
, alphaTestRef(0)
{}
bool enableTexturing, enableAlphaTest, enableAlphaBlending, enableAntialiasing, enableEdgeMarking;
enum {
TOON, HIGHLIGHT
} shading;
POLYLIST* polylist;
VERTLIST* vertlist;
bool wbuffer, sortmode;
float alphaTestRef;
};
extern GFX3D gfx3d;
//---------------------
//produce a 32bpp color from a DS RGB16
#define RGB16TO32(col,alpha) (((alpha)<<24) | ((((col) & 0x7C00)>>7)<<16) | ((((col) & 0x3E0)>>2)<<8) | (((col) & 0x1F)<<3))
//produce a 32bpp color from a ds RGB15 plus an 8bit alpha, using a table
#define RGB15TO32(col,alpha8) ( ((alpha8)<<24) | color_15bit_to_24bit[col] )
//produce a 32bpp color from a ds RGB15 plus an 8bit alpha, not using a table (but using other tables)
#define RGB15TO32_DIRECT(col,alpha8) ( ((alpha8)<<24) | (material_5bit_to_8bit[((col)>>10)&0x1F]<<16) | (material_5bit_to_8bit[((col)>>5)&0x1F]<<8) | material_5bit_to_8bit[(col)&0x1F] )
extern u32 color_15bit_to_24bit[32768];
extern const int material_5bit_to_31bit[32];
extern const u8 material_5bit_to_8bit[32];
extern const u8 material_3bit_to_8bit[8];
//GE commands:
void gfx3d_glViewPort(unsigned long v);
void gfx3d_glClearColor(unsigned long v);
void gfx3d_glFogColor(unsigned long v);
void gfx3d_glFogOffset (unsigned long v);
void gfx3d_glClearDepth(unsigned long v);
void gfx3d_glMatrixMode(unsigned long v);
void gfx3d_glLoadIdentity();
void gfx3d_glLoadMatrix4x4(signed long v);
void gfx3d_glLoadMatrix4x3(signed long v);
void gfx3d_glStoreMatrix(unsigned long v);
void gfx3d_glRestoreMatrix(unsigned long v);
void gfx3d_glPushMatrix(void);
void gfx3d_glPopMatrix(signed long i);
void gfx3d_glTranslate(signed long v);
void gfx3d_glScale(signed long v);
void gfx3d_glMultMatrix3x3(signed long v);
void gfx3d_glMultMatrix4x3(signed long v);
void gfx3d_glMultMatrix4x4(signed long v);
void gfx3d_glBegin(unsigned long v);
void gfx3d_glEnd(void);
void gfx3d_glColor3b(unsigned long v);
void gfx3d_glVertex16b(unsigned int v);
void gfx3d_glVertex10b(unsigned long v);
void gfx3d_glVertex3_cord(unsigned int one, unsigned int two, unsigned int v);
void gfx3d_glVertex_rel(unsigned long v);
void gfx3d_glSwapScreen(unsigned int screen);
int gfx3d_GetNumPolys();
int gfx3d_GetNumVertex();
void gfx3d_glPolygonAttrib (unsigned long val);
void gfx3d_glMaterial0(unsigned long val);
void gfx3d_glMaterial1(unsigned long val);
void gfx3d_glShininess (unsigned long val);
void gfx3d_UpdateToonTable(void* toonTable);
void gfx3d_glTexImage(unsigned long val);
void gfx3d_glTexPalette(unsigned long val);
void gfx3d_glTexCoord(unsigned long val);
void gfx3d_glNormal(unsigned long v);
signed long gfx3d_GetClipMatrix (unsigned int index);
signed long gfx3d_GetDirectionalMatrix (unsigned int index);
void gfx3d_glLightDirection (unsigned long v);
void gfx3d_glLightColor (unsigned long v);
void gfx3d_glAlphaFunc(unsigned long v);
void gfx3d_glBoxTest(unsigned long v);
void gfx3d_glPosTest(unsigned long v);
void gfx3d_glVecTest(unsigned long v);
void gfx3d_glGetPosRes(unsigned int index);
void gfx3d_glGetVecRes(unsigned int index);
void gfx3d_glCallList(unsigned long v);
void gfx3d_glFlush(unsigned long v);
void gfx3d_VBlankSignal();
void gfx3d_Control(unsigned long v);
//other misc stuff
void gfx3d_glGetMatrix(unsigned int mode, unsigned int index, float* dest);
void gfx3d_glGetLightDirection(unsigned int index, unsigned int* dest);
void gfx3d_glGetLightColor(unsigned int index, unsigned int* dest);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +0,0 @@
/* $Id: opengl_collector_3Demu.h,v 1.2 2007-04-20 12:42:58 masscat Exp $
*/
#ifndef _OPENGL_COLLECTOR_3DEMU_H_
#define _OPENGL_COLLECTOR_3DEMU_H_ 1
/*
Copyright (C) 2006-2007 Ben Jaques
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
extern GPU3DInterface gpu3D_opengl_collector;
/**
* This is called before a set of OpenGL functions are called.
* It is up to the platform code to switch to the correct context and similar.
*
* If the platform code is unsucessful then return 0 and the OpenGL functions
* will not be called. Return 1 otherwise.
*
* If this is not overridden then the call will always fail.
*/
extern int (*begin_opengl_ogl_collector_platform)( void);
/**
* This is called after a set of OpenGL functions have been called, marking
* the end the OpenGL calls.
*
* If not overridden this function will do nothing.
*/
extern void (*end_opengl_ogl_collector_platform)( void);
/**
* This is called during the OpenGL Collector's initialisation.
*
* If the platform code is unsucessful then return 0 and the initialisation
* will fail. Return 1 otherwise.
*
* If this is not overridden then the call will always fail.
*/
extern int (*initialise_ogl_collector_platform)( void);
/**
* This is called when all the OpenGL functions comprising a single set
* have been called.
*
* If this is not overridden then a call to glFlush() is made.
*/
extern void (*complete_render_ogl_collector_platform)( void);
#endif /* End of _OPENGL_COLLECTOR_3DEMU_H_ */

View File

@ -20,85 +20,17 @@
#include "render3D.h"
char NDS_nullFunc1 (void){ return 1; }
void NDS_nullFunc2 (void){}
void NDS_nullFunc3 (unsigned long v){}
void NDS_nullFunc4 (signed long v) {}
void NDS_nullFunc5 (unsigned int v){}
void NDS_nullFunc6 (unsigned int one, unsigned int two, unsigned int v){}
int NDS_nullFunc7 (void) {return 0;}
long NDS_nullFunc8 (unsigned int index){ return 0; }
void NDS_nullFunc9 (int line, unsigned short * DST) { };
void NDS_nullFunc10 (unsigned int mode, unsigned int index, float* dest) {}; // NDS_3D_GetMatrix
void NDS_nullFunc11 (unsigned int index, unsigned int* dest) {}; // NDS_glGetLightDirection
void NDS_nullFunc12 (void* v) {}
void NDS_nullFunc1 (void){}
char NDS_nullFunc2 (void){ return 1; }
void NDS_nullFunc3 (int,unsigned short*) {}
GPU3DInterface gpu3DNull = {
NDS_nullFunc1, // NDS_3D_Init
NDS_nullFunc2, // NDS_3D_Reset
NDS_nullFunc2, // NDS_3D_Close
NDS_nullFunc3, // NDS_3D_ViewPort
NDS_nullFunc3, // NDS_3D_ClearColor
NDS_nullFunc3, // NDS_3D_FogColor
NDS_nullFunc3, // NDS_3D_FogOffset
NDS_nullFunc3, // NDS_3D_ClearDepth
NDS_nullFunc3, // NDS_3D_MatrixMode
NDS_nullFunc2, // NDS_3D_LoadIdentity
NDS_nullFunc4, // NDS_3D_LoadMatrix4x4
NDS_nullFunc4, // NDS_3D_LoadMatrix4x3
NDS_nullFunc3, // NDS_3D_StoreMatrix
NDS_nullFunc3, // NDS_3D_RestoreMatrix
NDS_nullFunc2, // NDS_3D_PushMatrix
NDS_nullFunc4, // NDS_3D_PopMatrix
NDS_nullFunc4, // NDS_3D_Translate
NDS_nullFunc4, // NDS_3D_Scale
NDS_nullFunc4, // NDS_3D_MultMatrix3x3
NDS_nullFunc4, // NDS_3D_MultMatrix4x3
NDS_nullFunc4, // NDS_3D_MultMatrix4x4
NDS_nullFunc3, // NDS_3D_Begin
NDS_nullFunc2, // NDS_3D_End
NDS_nullFunc3, // NDS_3D_Color3b
NDS_nullFunc5, // NDS_3D_Vertex16b
NDS_nullFunc3, // NDS_3D_Vertex10b
NDS_nullFunc6, // NDS_3D_Vertex3_cord
NDS_nullFunc3, // NDS_3D_Vertex_rel
NDS_nullFunc5, // NDS_3D_SwapScreen
NDS_nullFunc7, // NDS_3D_GetNumPolys
NDS_nullFunc7, // NDS_3D_GetNumVertex
NDS_nullFunc3, // NDS_3D_Flush
NDS_nullFunc3, // NDS_3D_PolygonAttrib
NDS_nullFunc3, // NDS_3D_Material0
NDS_nullFunc3, // NDS_3D_Material1
NDS_nullFunc3, // NDS_3D_Shininess
NDS_nullFunc3, // NDS_3D_TexImage
NDS_nullFunc3, // NDS_3D_TexPalette
NDS_nullFunc3, // NDS_3D_TexCoord
NDS_nullFunc3, // NDS_3D_LightDirection
NDS_nullFunc3, // NDS_3D_LightColor
NDS_nullFunc3, // NDS_3D_AlphaFunc
NDS_nullFunc3, // NDS_3D_Control
NDS_nullFunc3, // NDS_3D_Normal
NDS_nullFunc3, // NDS_3D_CallList
NDS_nullFunc8, // NDS_3D_GetClipMatrix
NDS_nullFunc8, // NDS_3D_GetDirectionalMatrix
NDS_nullFunc9, // NDS_3D_GetLine
NDS_nullFunc10, // NDS_3D_GetMatrix
NDS_nullFunc11, // NDS_glGetLightDirection
NDS_nullFunc11, // NDS_glGetLightColor
NDS_nullFunc3, // NDS_3D_BoxTest
NDS_nullFunc3, // NDS_3D_PosTest
NDS_nullFunc3, // NDS_3D_VecTest
NDS_nullFunc8, // NDS_3D_GetPosRes
NDS_nullFunc8, // NDS_3D_GetVecRes
NDS_nullFunc12, // NDS_3D_UpdateToonTable
NDS_nullFunc2, // NDS_3D_VBlankSignal
NDS_nullFunc2 // NDS_3D_VramReconfigureSignal
NDS_nullFunc2, //NDS_3D_Init
NDS_nullFunc1, //NDS_3D_Reset
NDS_nullFunc1, //NDS_3D_Close
NDS_nullFunc1, //NDS_3D_Render
NDS_nullFunc1, //NDS_3D_VramReconfigureSignal
NDS_nullFunc3, //NDS_3D_GetLine
};
GPU3DInterface *gpu3D = &gpu3DNull;

View File

@ -18,114 +18,32 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GPU_3D
#define GPU_3D
#ifndef RENDER3D_H
#define RENDER3D_H
//not using this right now
#define CALL_CONVENTION
/*
enum DRIVER_3D
{
DRIVER_NULL = 0,
DRIVER_OPENGL
};
*/
typedef struct GPU3DInterface
typedef struct Render3DInterface
{
//called once when the plugin starts up
char (CALL_CONVENTION* NDS_3D_Init) (void);
//called when the emulator resets (is this necessary?)
void (CALL_CONVENTION* NDS_3D_Reset) (void);
//called when the plugin shuts down
void (CALL_CONVENTION* NDS_3D_Close) (void);
void (CALL_CONVENTION* NDS_3D_ViewPort) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_ClearColor) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_FogColor) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_FogOffset) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_ClearDepth) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_MatrixMode) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_LoadIdentity) (void);
void (CALL_CONVENTION* NDS_3D_LoadMatrix4x4) (signed long v);
void (CALL_CONVENTION* NDS_3D_LoadMatrix4x3) (signed long v);
void (CALL_CONVENTION* NDS_3D_StoreMatrix) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_RestoreMatrix) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_PushMatrix) (void);
void (CALL_CONVENTION* NDS_3D_PopMatrix) (signed long i);
void (CALL_CONVENTION* NDS_3D_Translate) (signed long v);
void (CALL_CONVENTION* NDS_3D_Scale) (signed long v);
void (CALL_CONVENTION* NDS_3D_MultMatrix3x3) (signed long v);
void (CALL_CONVENTION* NDS_3D_MultMatrix4x3) (signed long v);
void (CALL_CONVENTION* NDS_3D_MultMatrix4x4) (signed long v);
void (CALL_CONVENTION* NDS_3D_Begin) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_End) (void);
void (CALL_CONVENTION* NDS_3D_Color3b) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_Vertex16b) (unsigned int v);
void (CALL_CONVENTION* NDS_3D_Vertex10b) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_Vertex3_cord) (unsigned int one, unsigned int two, unsigned int v);
void (CALL_CONVENTION* NDS_3D_Vertex_rel) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_SwapScreen) (unsigned int screen);
int (CALL_CONVENTION* NDS_3D_GetNumPolys) (void); // THIS IS A HACK :D
int (CALL_CONVENTION* NDS_3D_GetNumVertex) (void);
void (CALL_CONVENTION* NDS_3D_Flush) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_PolygonAttrib) (unsigned long val);
void (CALL_CONVENTION* NDS_3D_Material0) (unsigned long val);
void (CALL_CONVENTION* NDS_3D_Material1) (unsigned long val);
void (CALL_CONVENTION* NDS_3D_Shininess) (unsigned long val);
void (CALL_CONVENTION* NDS_3D_TexImage) (unsigned long val);
void (CALL_CONVENTION* NDS_3D_TexPalette) (unsigned long val);
void (CALL_CONVENTION* NDS_3D_TexCoord) (unsigned long val);
void (CALL_CONVENTION* NDS_3D_LightDirection) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_LightColor) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_AlphaFunc) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_Control) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_Normal) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_CallList) (unsigned long v);
long (CALL_CONVENTION* NDS_3D_GetClipMatrix) (unsigned int index);
long (CALL_CONVENTION* NDS_3D_GetDirectionalMatrix) (unsigned int index);
void (CALL_CONVENTION* NDS_3D_GetLine) (int line, unsigned short * DST);
//called when the renderer should do its job and render the current display lists
void (CALL_CONVENTION* NDS_3D_Render) (void);
//////////////////////////////////////////////////////////////////////////////
// NDS_3D_GetMatrix
//
// mode: 0 = projection
// 1 = coordinate
// 2 = direction
// 3 = texture
//
// index: the matrix stack index or -1 for current
//
// dest: pointer to the destination float[16] buffer
//////////////////////////////////////////////////////////////////////////////
void (CALL_CONVENTION* NDS_3D_GetMatrix) (unsigned int mode, unsigned int index, float* dest);
//////////////////////////////////////////////////////////////////////////////
// NDS_glGetLightDirection
//
// index: light index
//
// dest: pointer to the destination variable
//////////////////////////////////////////////////////////////////////////////
void (CALL_CONVENTION* NDS_glGetLightDirection) (unsigned int index, unsigned int* dest);
//////////////////////////////////////////////////////////////////////////////
// NDS_glGetLightColor
//
// index: light index
//
// dest: pointer to the destination variable
//////////////////////////////////////////////////////////////////////////////
void (CALL_CONVENTION* NDS_glGetLightColor) (unsigned int index, unsigned int* dest);
void (CALL_CONVENTION* NDS_3D_BoxTest) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_PosTest) (unsigned long v);
void (CALL_CONVENTION* NDS_3D_VecTest) (unsigned long v);
long (CALL_CONVENTION* NDS_3D_GetPosRes) (unsigned int index);
long (CALL_CONVENTION* NDS_3D_GetVecRes) (unsigned int index);
void (CALL_CONVENTION* NDS_3D_UpdateToonTable) (void* toonTable);
void (CALL_CONVENTION* NDS_3D_VBlankSignal) ();
//called when the emulator reconfigures its vram. you may need to invalidate your texture cache.
void (CALL_CONVENTION* NDS_3D_VramReconfigureSignal) ();
//Retrieves a line of color buffer data
void (CALL_CONVENTION* NDS_3D_GetLine) (int line, unsigned short* dst);
} GPU3DInterface;

View File

@ -20,6 +20,14 @@
#ifndef TYPES_HPP
#define TYPES_HPP
#ifdef _MSC_VER
#define ALIGN(X) __declspec(align(X))
#elif __GNUC__
#define ALIGN(X) __attribute__ ((aligned (X)))
#else
#define ALIGN(X)
#endif
#ifndef FASTCALL
#ifdef __MINGW32__
#define FASTCALL __attribute__((fastcall))

View File

@ -617,6 +617,10 @@
RelativePath="..\gdbstub\gdbstub.cpp"
>
</File>
<File
RelativePath="..\gfx3d.cpp"
>
</File>
<File
RelativePath=".\ginfo.cpp"
>
@ -962,6 +966,10 @@
RelativePath="..\gdbstub\gdbstub_internal.h"
>
</File>
<File
RelativePath="..\gfx3d.h"
>
</File>
<File
RelativePath=".\ginfo.h"
>

View File

@ -614,6 +614,10 @@
RelativePath="..\gdbstub\gdbstub.cpp"
>
</File>
<File
RelativePath="..\gfx3d.cpp"
>
</File>
<File
RelativePath=".\ginfo.cpp"
>
@ -931,6 +935,10 @@
RelativePath="..\gdbstub\gdbstub_internal.h"
>
</File>
<File
RelativePath="..\gfx3d.h"
>
</File>
<File
RelativePath=".\ginfo.h"
>

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
#include "lightView.h"
#include "resource.h"
#include "matrix.h"
#include "render3d.h"
#include "gfx3d.h"
#include "armcpu.h"
#include "colorctrl.h"
#include "colorconv.h"
@ -74,9 +74,9 @@ void LightView_OnPaintLight(lightview_struct* win, int index)
ColorCtrl* colorCtrl;
char buffer[128];
// Get necessary information from render module
gpu3D->NDS_glGetLightColor(index, &color);
gpu3D->NDS_glGetLightDirection(index, &direction);
// Get necessary information from gfx3d module
gfx3d_glGetLightColor(index, &color);
gfx3d_glGetLightDirection(index, &direction);
// Print Light Direction
sprintf(buffer, "%.8x", direction);

View File

@ -50,6 +50,7 @@
#include "FirmConfig.h"
#include "AboutBox.h"
#include "OGLRender.h"
#include "../gfx3d.h"
#include "../render3D.h"
#include "../gdbstub.h"
#include "colorctrl.h"
@ -418,7 +419,7 @@ DWORD WINAPI run( LPVOID lpParameter)
return -1;
}
NDS_3D_SetDriver (GPU3D_OPENGL);
//NDS_3D_SetDriver (GPU3D_OPENGL);
if (!gpu3D->NDS_3D_Init ())
{

View File

@ -22,8 +22,8 @@
#include "matrixView.h"
#include "resource.h"
#include "matrix.h"
#include "render3d.h"
#include "armcpu.h"
#include "gfx3d.h"
//////////////////////////////////////////////////////////////////////////////
@ -99,7 +99,7 @@ void MatrixView_OnPaintPositionMatrix(matrixview_struct* win)
stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1;
gpu3D->NDS_3D_GetMatrix(1, stackIndex, matrix);
gfx3d_glGetMatrix(1, stackIndex, matrix);
MatrixView_SetMatrix(win, idcGroup, matrix);
}
@ -122,7 +122,7 @@ void MatrixView_OnPaintDirectionMatrix(matrixview_struct* win)
stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1;
gpu3D->NDS_3D_GetMatrix(2, stackIndex, matrix);
gfx3d_glGetMatrix(2, stackIndex, matrix);
MatrixView_SetMatrix(win, idcGroup, matrix);
}
@ -141,7 +141,7 @@ void MatrixView_OnPaintProjectionMatrix(matrixview_struct* win)
float mat[16];
gpu3D->NDS_3D_GetMatrix(0, -1, mat);
gfx3d_glGetMatrix(0, -1, mat);
MatrixView_SetMatrix(win, idcGroup, mat);
}
@ -160,7 +160,7 @@ void MatrixView_OnPaintTextureMatrix(matrixview_struct* win)
float mat[16];
gpu3D->NDS_3D_GetMatrix(3, -1, mat);
gfx3d_glGetMatrix(3, -1, mat);
MatrixView_SetMatrix(win, idcGroup, mat);
}