diff --git a/desmume/src/ARM9.h b/desmume/src/ARM9.h index 4dae037d8..bc1cd8cf8 100644 --- a/desmume/src/ARM9.h +++ b/desmume/src/ARM9.h @@ -3,6 +3,10 @@ #include "types.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { //ARM9 mem u8 ARM9_ITCM[0x8000]; @@ -30,4 +34,8 @@ typedef struct { extern ARM9_struct ARM9Mem; +#ifdef __cplusplus +} +#endif + #endif diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 9206d865e..931330f5d 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -240,7 +240,8 @@ NDS_exec(s32 nb, BOOL force); MainScreen.offset = SubScreen.offset; SubScreen.offset = tmp; } - + + int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename); #ifdef __cplusplus } diff --git a/desmume/src/SPU.h b/desmume/src/SPU.h index eff5845f5..47d610c8c 100644 --- a/desmume/src/SPU.h +++ b/desmume/src/SPU.h @@ -22,6 +22,10 @@ #include "types.h" +#ifdef __cplusplus +extern "C" { +#endif + #define SNDCORE_DEFAULT -1 #define SNDCORE_DUMMY 0 #define SNDCORE_FILEWRITE 1 @@ -91,4 +95,8 @@ void SPU_WriteLong(u32 addr, u32 val); u32 SPU_ReadLong(u32 addr); void SPU_Emulate(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/desmume/src/matrix.h b/desmume/src/matrix.h index 91232017a..8e8481e4d 100644 --- a/desmume/src/matrix.h +++ b/desmume/src/matrix.h @@ -23,6 +23,10 @@ #include "types.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifdef SSE2 #include #include @@ -87,4 +91,8 @@ void Vector3Normalize(float *dst); void Vector4Copy(float *dst, float *src); +#ifdef __cplusplus +} +#endif + #endif diff --git a/desmume/src/render3D.h b/desmume/src/render3D.h index fac293c22..f869e27ab 100644 --- a/desmume/src/render3D.h +++ b/desmume/src/render3D.h @@ -27,6 +27,10 @@ #define CALL_CONVENTION #endif +#ifdef __cplusplus +extern "C" { +#endif + /* enum DRIVER_3D { @@ -142,4 +146,8 @@ extern GPU3DInterface *gpu3D; void NDS_3D_SetDriver (int core3DIndex); +#ifdef __cplusplus +} +#endif + #endif diff --git a/desmume/src/windows/CWindow.cpp b/desmume/src/windows/CWindow.cpp index dfa1964d3..b0cbcc5ea 100644 --- a/desmume/src/windows/CWindow.cpp +++ b/desmume/src/windows/CWindow.cpp @@ -177,7 +177,7 @@ void CWindow_AddToRefreshList(void *win) updatewindowlist = (cwindow_struct *)win; LeaveCriticalSection(§ion); - CWindow_UpdateAutoUpdateItem(win, TRUE); + CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, TRUE); } ////////////////////////////////////////////////////////////////////////////// @@ -202,7 +202,7 @@ void CWindow_RemoveFromRefreshList(void *win) win2->prev = NULL; LeaveCriticalSection(§ion); - CWindow_UpdateAutoUpdateItem(win, FALSE); + CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, FALSE); } ////////////////////////////////////////////////////////////////////////////// @@ -223,7 +223,7 @@ int CWindow_ToggleAutoUpdate(void *win) CWindow_AddToRefreshList(win); // checks or unchecks the auto update item in the system menu - CWindow_UpdateAutoUpdateItem(win, win2->autoup); + CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, win2->autoup); return win2->autoup; } diff --git a/desmume/src/windows/ConfigKeys.cpp b/desmume/src/windows/ConfigKeys.cpp index ef21af7ab..d3cfd8791 100644 --- a/desmume/src/windows/ConfigKeys.cpp +++ b/desmume/src/windows/ConfigKeys.cpp @@ -33,15 +33,13 @@ #include "../debug.h" #include "resource.h" -char IniName[MAX_PATH]; +static char IniName[MAX_PATH]; char vPath[MAX_PATH],*szPath,currDir[MAX_PATH]; -u32 keytab[12]; -const char tabkeytext[52][14] = {"0","1","2","3","4","5","6","7","8","9","A","B","C", +const char *tabkeytext[52] = {"0","1","2","3","4","5","6","7","8","9","A","B","C", "D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X", "Y","Z","SPACE","UP","DOWN","LEFT","RIGHT","TAB","SHIFT","DEL","INSERT","HOME","END","ENTER", "Joystick UP","Joystick DOWN","Joystick LEFT","Joystick RIGHT"}; -const char DI_tabkeytext[50][20]; DWORD dds_up=37; DWORD dds_down=38; @@ -349,11 +347,11 @@ HRESULT Input_Init(HWND hwnd) ReadConfig(); g_pKeyboard=NULL; g_pJoystick=NULL; - if(!FAILED(DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,&IID_IDirectInput8,(void**)&g_pDI,NULL))) + if(!FAILED(DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&g_pDI,NULL))) { //******************* Keyboard res=0; - if (FAILED(IDirectInput8_CreateDevice(g_pDI,&GUID_SysKeyboard,&g_pKeyboard,NULL))) res=-1; + if (FAILED(IDirectInput8_CreateDevice(g_pDI,GUID_SysKeyboard,&g_pKeyboard,NULL))) res=-1; else if (FAILED(IDirectInputDevice8_SetDataFormat(g_pKeyboard,&c_dfDIKeyboard))) res=-1; else @@ -366,7 +364,7 @@ HRESULT Input_Init(HWND hwnd) //******************** Joystick res=0; - if(FAILED(IDirectInput8_CreateDevice(g_pDI,&GUID_Joystick,&g_pJoystick,NULL))) res=-1; + if(FAILED(IDirectInput8_CreateDevice(g_pDI,GUID_Joystick,&g_pJoystick,NULL))) res=-1; else if(FAILED(IDirectInputDevice8_SetDataFormat(g_pJoystick,&c_dfDIJoystick2))) res=-1; else diff --git a/desmume/src/windows/ConfigKeys.h b/desmume/src/windows/ConfigKeys.h index 43b9ae306..6b73af7a5 100644 --- a/desmume/src/windows/ConfigKeys.h +++ b/desmume/src/windows/ConfigKeys.h @@ -24,7 +24,6 @@ #define DIRECTINPUT_VERSION 0x0800 #include -extern unsigned long keytab[12]; extern const DWORD tabkey[48]; extern DWORD ds_up; extern DWORD ds_down; @@ -52,5 +51,6 @@ HRESULT Input_DeInit (void); void Input_Process (void); BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); +void WritePrivateProfileInt(char* appname, char* keyname, int val, char* file); #endif diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index 43ecffa4d..15a749025 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -60,7 +60,7 @@ EnableEnhancedInstructionSet="0" DebugInformationFormat="4" CallingConvention="0" - CompileAs="1" + CompileAs="0" /> #include #include + #include "console.h" #else #define __forceinline #include #include #endif +#include "../types.h" #include "../debug.h" #include "../MMU.h" #include "../bits.h" #include "../matrix.h" +#include "../NDSSystem.h" #include "OGLRender.h" @@ -284,7 +287,9 @@ static void NDS_3D_UpdateToonTable(void* toonTable) { #define INITOGLEXT(x,y) y = (x)wglGetProcAddress(#y); OGLEXT(PFNGLCREATESHADERPROC,glCreateShader) -OGLEXT(PFNGLGETSHADERSOURCEPROC,glShaderSource) +//zero: i dont understand this at all. my glext.h has the wrong thing declared here... so I have to do it myself +typedef void (APIENTRYP X_PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLchar **source, GLsizei *length); +OGLEXT(X_PFNGLGETSHADERSOURCEPROC,glShaderSource) OGLEXT(PFNGLCOMPILESHADERPROC,glCompileShader) OGLEXT(PFNGLCREATEPROGRAMPROC,glCreateProgram) OGLEXT(PFNGLATTACHSHADERPROC,glAttachShader) @@ -390,7 +395,7 @@ char NDS_glInit(void) MatrixInit (mtxTemporal); INITOGLEXT(PFNGLCREATESHADERPROC,glCreateShader) - INITOGLEXT(PFNGLGETSHADERSOURCEPROC,glShaderSource) + INITOGLEXT(X_PFNGLGETSHADERSOURCEPROC,glShaderSource) INITOGLEXT(PFNGLCOMPILESHADERPROC,glCompileShader) INITOGLEXT(PFNGLCREATEPROGRAMPROC,glCreateProgram) INITOGLEXT(PFNGLATTACHSHADERPROC,glAttachShader) @@ -401,7 +406,7 @@ char NDS_glInit(void) if(glCreateShader && glShaderSource && glCompileShader && glCreateProgram && glAttachShader && glLinkProgram && glUseProgram && glGetShaderInfoLog) { { - glGenTextures (MAX_TEXTURE, &oglToonTableTextureID); + glGenTextures (1, &oglToonTableTextureID); glBindTexture(GL_TEXTURE_1D,oglToonTableTextureID); glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -410,8 +415,8 @@ char NDS_glInit(void) } { char buf[10000]; - const char* toonShaderSource[] = { - "uniform sampler2D tex2; \ + const char* toonShaderSource[] = {"\ + uniform sampler2D tex2; \ uniform sampler1D tex1; \ void main() {\ gl_FragColor = gl_Color; \ @@ -424,8 +429,7 @@ char NDS_glInit(void) toonShader = glCreateShader(GL_FRAGMENT_SHADER); toonProgram = glCreateProgram(); - - glShaderSource(toonShader, 1, toonShaderSource, 0); + glShaderSource(toonShader, 1, (GLchar**)toonShaderSource, 0); glCompileShader(toonShader); glGetShaderInfoLog(toonShader,10000,0,buf); @@ -695,17 +699,15 @@ __forceinline void NDS_glMultMatrix4x4(signed long v) // txt_slot_size=txt_slot_current_size=0x020000;\ // } +//zero 9/7/08 - changed *adr= to adr= while changing from c++. was that a bug? #define CHECKSLOT txt_slot_current_size--;\ if (txt_slot_current_size<=0)\ {\ txt_slot_current++;\ - *adr=(unsigned char *)ARM9Mem.textureSlotAddr[txt_slot_current];\ + adr=(unsigned char *)ARM9Mem.textureSlotAddr[txt_slot_current];\ txt_slot_size=txt_slot_current_size=0x020000;\ } - - - //todo - make all color conversions go through a properly spread table!! __forceinline void* memcpy_fast(void* dest, const void* src, size_t count) @@ -762,7 +764,6 @@ __forceinline void* memcpy_fast(void* dest, const void* src, size_t count) static void DebugDumpTexture(int which) { - int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename); static int ctr = 0; char fname[100]; FILE* outf; @@ -777,8 +778,6 @@ static void DebugDumpTexture(int which) texMAP); NDS_WriteBMP_32bppBuffer(texcache[which].sizeX,texcache[which].sizeY,texMAP,fname); - - } //================================================================================ @@ -971,9 +970,9 @@ __forceinline void setTexture(unsigned int format, unsigned int texpal) unsigned int * dst = (unsigned int *)texMAP; if ( (texcache[i].frm & 0xc000) == 0x8000) // texel are in slot 2 - slot1=(const unsigned short*)&ARM9Mem.textureSlotAddr[1][((texcache[i].frm&0x3FFF)<<2)+0x010000]; + slot1=(unsigned short*)&ARM9Mem.textureSlotAddr[1][((texcache[i].frm&0x3FFF)<<2)+0x010000]; else - slot1=(const unsigned short*)&ARM9Mem.textureSlotAddr[1][(texcache[i].frm&0x3FFF)<<2]; + slot1=(unsigned short*)&ARM9Mem.textureSlotAddr[1][(texcache[i].frm&0x3FFF)<<2]; for (y = 0; y < (texcache[i].sizeY>>2); y ++) { @@ -1048,7 +1047,8 @@ __forceinline void setTexture(unsigned int format, unsigned int texpal) if (txt_slot_current_size<=0) { txt_slot_current++; - *map=(unsigned char *)ARM9Mem.textureSlotAddr[txt_slot_current]; + //zero 9/7/08 - changed *adr= to adr= while changing from c++. was that a bug? + map=(unsigned int*)ARM9Mem.textureSlotAddr[txt_slot_current]; //map-=txt_slot_size>>2; //zero 8/25/08 - I dont understand this. it broke my game. txt_slot_size=txt_slot_current_size=0x020000; } @@ -1092,7 +1092,8 @@ __forceinline void setTexture(unsigned int format, unsigned int texpal) if (txt_slot_current_size<=0) { txt_slot_current++; - *map=(unsigned char *)ARM9Mem.textureSlotAddr[txt_slot_current]; + //zero 9/7/08 - changed *adr= to adr= while changing from c++. was that a bug? + map=(unsigned short *)ARM9Mem.textureSlotAddr[txt_slot_current]; map-=txt_slot_size>>1; txt_slot_size=txt_slot_current_size=0x020000; } diff --git a/desmume/src/windows/colorctrl.cpp b/desmume/src/windows/colorctrl.cpp index 98be37f3a..226826cb5 100644 --- a/desmume/src/windows/colorctrl.cpp +++ b/desmume/src/windows/colorctrl.cpp @@ -80,7 +80,7 @@ LRESULT CALLBACK ColorCtrl_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP LRESULT ColorCtrl_OnNCCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) { // Allocate a new CustCtrl structure for this window. - ColorCtrl* pCtrl = malloc(sizeof(ColorCtrl)); + ColorCtrl* pCtrl = (ColorCtrl*)malloc(sizeof(ColorCtrl)); // Failed to allocate, stop window creation. if(pCtrl == NULL) diff --git a/desmume/src/windows/console.cpp b/desmume/src/windows/console.cpp index f8c96ae65..d51ea4a50 100644 --- a/desmume/src/windows/console.cpp +++ b/desmume/src/windows/console.cpp @@ -28,7 +28,7 @@ #ifdef BETA_VERSION #define BUFFER_SIZE 100 HANDLE hConsole; -void printlog(char *fmt, ...); +void printlog(const char *fmt, ...); void OpenConsole() { @@ -64,7 +64,7 @@ void CloseConsole() { hConsole = NULL; } -void printlog(char *fmt, ...) +void printlog(const char *fmt, ...) { va_list list; char msg[512]; diff --git a/desmume/src/windows/console.h b/desmume/src/windows/console.h index c69da720b..0716679f0 100644 --- a/desmume/src/windows/console.h +++ b/desmume/src/windows/console.h @@ -28,7 +28,7 @@ #ifdef BETA_VERSION void OpenConsole(); void CloseConsole(); -void printlog(LPCTSTR *fmt, ...); +void printlog(const char *fmt, ...); #else #define OpenConsole() #define CloseConsole() diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index ddbce5caa..07afa9c87 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -116,6 +116,7 @@ int sndcoretype=SNDCORE_DIRECTX; int sndbuffersize=735*4; int sndvolume=100; +extern "C" { SoundInterface_struct *SNDCoreList[] = { &SNDDummy, &SNDFile, @@ -127,6 +128,7 @@ GPU3DInterface *core3DList[] = { &gpu3DNull, &gpu3Dgl, }; +} int autoframeskipenab=1; int frameskiprate=0; @@ -390,7 +392,7 @@ DWORD WINAPI run( LPVOID lpParameter) DDCAPS hw_caps, sw_caps; - if (DirectDrawCreateEx(NULL, &lpDDraw, &IID_IDirectDraw7, NULL) != DD_OK) + if (DirectDrawCreateEx(NULL, (LPVOID*)&lpDDraw, IID_IDirectDraw7, NULL) != DD_OK) { MessageBox(hwnd,"Unable to initialize DirectDraw","Error",MB_OK); return -1; @@ -510,7 +512,7 @@ DWORD WINAPI run( LPVOID lpParameter) } else printlog("16bit depth color not supported"); - IDirectDrawSurface7_Unlock(lpBackSurface,ddsd.lpSurface); + IDirectDrawSurface7_Unlock(lpBackSurface,(LPRECT)ddsd.lpSurface); if (IDirectDrawSurface7_Blt(lpPrimarySurface,&MainWindowRect,lpBackSurface,0, DDBLT_WAIT,0)==DDERR_SURFACELOST) { @@ -1411,7 +1413,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM { cwindow_struct *IoregView; - if ((IoregView = malloc(sizeof(cwindow_struct))) == NULL) + if ((IoregView = (cwindow_struct*)malloc(sizeof(cwindow_struct))) == NULL) return 0; if (CWindow_Init2(IoregView, hAppInst, HWND_DESKTOP, "IO REG VIEW", IDD_IO_REG, IoregView_Proc) == 0) @@ -1818,7 +1820,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static timerid=0; + static int timerid=0; switch (uMsg) { case WM_INITDIALOG: diff --git a/desmume/src/windows/snddx.cpp b/desmume/src/windows/snddx.cpp index 62a1cd8b7..7af3663df 100755 --- a/desmume/src/windows/snddx.cpp +++ b/desmume/src/windows/snddx.cpp @@ -17,6 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #ifdef __MINGW32__ // I have to do this because for some reason because the dxerr8.h header is fubared