From 9e776c48cae95f0c639fa22f5ad49049785719d1 Mon Sep 17 00:00:00 2001 From: zeromus Date: Fri, 26 Mar 2010 18:22:46 +0000 Subject: [PATCH] check in all the xbox compile fixes after tweaking some things. looks benign. need to test compilation in nix still --- desmume/src/NDSSystem.cpp | 2 +- desmume/src/NDSSystem.h | 2 +- desmume/src/SPU.h | 7 ++-- desmume/src/addons/compactFlash.cpp | 2 +- desmume/src/gfx3d.cpp | 8 ++-- desmume/src/metaspu/SoundTouch/FIRFilter.cpp | 3 +- desmume/src/metaspu/SoundTouch/STTypes.h | 3 +- desmume/src/metaspu/SoundTouch/TDStretch.cpp | 4 +- desmume/src/metaspu/win32/Dialogs.h | 5 ++- desmume/src/movie.cpp | 1 + desmume/src/path.h | 14 ++++--- desmume/src/rasterize.h | 10 +++-- desmume/src/saves.cpp | 4 +- desmume/src/sndsdl.cpp | 36 ++++++++++++++++++ desmume/src/types.h | 40 ++++++++++++++++++-- desmume/src/utils/task.cpp | 12 ++++-- desmume/src/version.cpp | 2 +- desmume/src/wifi.cpp | 8 ++-- 18 files changed, 122 insertions(+), 41 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 60f10c871..305adc629 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -333,7 +333,7 @@ void GameInfo::populate() } } -#ifdef WIN32 +#ifdef _WINDOWS static std::vector buffer; static std::vector v; diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index ff657064e..0c632ef09 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -33,7 +33,7 @@ #include -#if defined(WIN32) && !defined(WXPORT) +#if defined(_WINDOWS) && !defined(WXPORT) #include "pathsettings.h" #endif diff --git a/desmume/src/SPU.h b/desmume/src/SPU.h index de16fd9da..052b25f84 100644 --- a/desmume/src/SPU.h +++ b/desmume/src/SPU.h @@ -36,9 +36,10 @@ #define CHANSTAT_STOPPED 0 #define CHANSTAT_PLAY 1 -static FORCEINLINE u32 sputrunc(float f) { return u32floor(f); } -static FORCEINLINE u32 sputrunc(double d) { return u32floor(d); } -static FORCEINLINE s32 spumuldiv7(s32 val, u8 multiplier) { +//who made these static? theyre used in multiple places. +FORCEINLINE u32 sputrunc(float f) { return u32floor(f); } +FORCEINLINE u32 sputrunc(double d) { return u32floor(d); } +FORCEINLINE s32 spumuldiv7(s32 val, u8 multiplier) { assert(multiplier <= 127); return (multiplier == 127) ? val : ((val * multiplier) >> 7); } diff --git a/desmume/src/addons/compactFlash.cpp b/desmume/src/addons/compactFlash.cpp index 0f28a8643..1edb40132 100644 --- a/desmume/src/addons/compactFlash.cpp +++ b/desmume/src/addons/compactFlash.cpp @@ -30,7 +30,7 @@ #include #include -#ifdef _XBOX && WIN32 +#ifdef _MSC_VER #include #define OPEN_MODE _O_RDWR | _O_BINARY diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 678b8e39e..e7aaeca67 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -495,11 +495,9 @@ void gfx3d_init() void gfx3d_reset() { -#ifndef _XBOX - gfx3d = GFX3D(); -#else - GFX3D(); -#endif + //if this doesn't work on the xbox, we need to find out why. + reconstruct(&gfx3d); + gxf_hardware.reset(); control = 0; diff --git a/desmume/src/metaspu/SoundTouch/FIRFilter.cpp b/desmume/src/metaspu/SoundTouch/FIRFilter.cpp index ac57335a1..89d090a1c 100644 --- a/desmume/src/metaspu/SoundTouch/FIRFilter.cpp +++ b/desmume/src/metaspu/SoundTouch/FIRFilter.cpp @@ -232,10 +232,11 @@ FIRFilter * FIRFilter::newInstance() { uint uExtensions = 0; +#ifndef _XBOX #if !defined(_MSC_VER) || !defined(__x86_64__) uExtensions = detectCPUextensions(); #endif - +#endif // Check if MMX/SSE/3DNow! instruction set extensions supported by CPU #ifdef ALLOW_MMX diff --git a/desmume/src/metaspu/SoundTouch/STTypes.h b/desmume/src/metaspu/SoundTouch/STTypes.h index f3a6a5d5c..7081b398c 100644 --- a/desmume/src/metaspu/SoundTouch/STTypes.h +++ b/desmume/src/metaspu/SoundTouch/STTypes.h @@ -190,10 +190,11 @@ namespace soundtouch #if _WIN32 // #define ALLOW_3DNOW 1 #endif - +#ifndef _XBOX #if (_WIN32 || __i386__ || __x86_64__) #define ALLOW_SSE 1 #endif +#endif #endif #endif // INTEGER_SAMPLES diff --git a/desmume/src/metaspu/SoundTouch/TDStretch.cpp b/desmume/src/metaspu/SoundTouch/TDStretch.cpp index d80962368..cac9998de 100644 --- a/desmume/src/metaspu/SoundTouch/TDStretch.cpp +++ b/desmume/src/metaspu/SoundTouch/TDStretch.cpp @@ -670,11 +670,11 @@ void * TDStretch::operator new(size_t s) TDStretch * TDStretch::newInstance() { uint uExtensions = 0; - +#ifndef _XBOX #if !defined(_MSC_VER) || !defined(__x86_64__) uExtensions = detectCPUextensions(); #endif - +#endif // Check if MMX/SSE/3DNow! instruction set extensions supported by CPU #ifdef ALLOW_MMX diff --git a/desmume/src/metaspu/win32/Dialogs.h b/desmume/src/metaspu/win32/Dialogs.h index b0080c293..7ef389ae0 100644 --- a/desmume/src/metaspu/win32/Dialogs.h +++ b/desmume/src/metaspu/win32/Dialogs.h @@ -16,8 +16,9 @@ */ #pragma once - -#ifdef _WIN32 +#ifdef _XBOX +#include +#elif _WIN32 #include #endif diff --git a/desmume/src/movie.cpp b/desmume/src/movie.cpp index ed95e56a5..74b74231d 100644 --- a/desmume/src/movie.cpp +++ b/desmume/src/movie.cpp @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define WIN32_LEAN_AND_MEAN #include #include #include "utils/guid.h" diff --git a/desmume/src/path.h b/desmume/src/path.h index f87c45782..ffd57cf57 100644 --- a/desmume/src/path.h +++ b/desmume/src/path.h @@ -1,6 +1,6 @@ #include -#if defined(WIN32) && !defined(WXPORT) +#if defined(_WINDOWS) && !defined(WXPORT) #include "resource.h" #else #include @@ -76,9 +76,12 @@ public: void LoadModulePath() { -#ifdef WIN32 +#ifndef _XBOX +#if defined(_WINDOWS) + char *p; ZeroMemory(pathToModule, sizeof(pathToModule)); + GetModuleFileName(NULL, pathToModule, sizeof(pathToModule)); p = pathToModule + lstrlen(pathToModule); while (p >= pathToModule && *p != '\\') p--; @@ -88,6 +91,7 @@ public: g_mkdir_with_parents(cwd, 0755); strncpy(pathToModule, cwd, MAX_PATH); g_free(cwd); +#endif #endif } @@ -104,7 +108,7 @@ public: void ReadKey(char *pathToRead, const char *key) { -#ifdef WIN32 +#ifdef _WINDOWS GetPrivateProfileString(SECTION, key, key, pathToRead, MAX_PATH, IniName); if(strcmp(pathToRead, key) == 0) { //since the variables are all intialized in this file they all use MAX_PATH @@ -130,7 +134,7 @@ public: ReadKey(pathToSounds, SOUNDKEY); ReadKey(pathToFirmware, FIRMWAREKEY); ReadKey(pathToLua, LUAKEY); -#ifdef WIN32 +#ifdef _WINDOWS GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName); savelastromvisit = GetPrivateProfileBool(SECTION, LASTVISITKEY, true, IniName); currentimageformat = (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName); @@ -312,7 +316,7 @@ public: enum ImageFormat { -#if defined(WIN32) && !defined(WXPORT) +#if defined(_WINDOWS) && !defined(WXPORT) PNG = IDC_PNG, BMP = IDC_BMP #else diff --git a/desmume/src/rasterize.h b/desmume/src/rasterize.h index 8d47241d5..8204078fe 100644 --- a/desmume/src/rasterize.h +++ b/desmume/src/rasterize.h @@ -25,12 +25,14 @@ extern GPU3DInterface gpu3DRasterize; -union FragmentColor -{ +union FragmentColor { u32 color; - struct - { + struct { +#ifdef WORDS_BIGENDIAN + u8 a,b,g,r; +#else u8 r,g,b,a; +#endif }; }; diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 5815f7400..dd2c820b8 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -46,7 +46,7 @@ #include "path.h" -#ifdef _MSC_VER +#ifdef _WINDOWS #include "windows/main.h" #endif @@ -1177,7 +1177,7 @@ bool savestate_load(EMUFILE* is) if(!x && !SAV_silent_fail_flag) { printf("Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked"); -#ifdef _MSC_VER +#ifdef _WINDOWS //HACK! we really need a better way to handle this kind of feedback MessageBox(0,"Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked",0,0); #endif diff --git a/desmume/src/sndsdl.cpp b/desmume/src/sndsdl.cpp index 2befb2bff..8e738ff9f 100644 --- a/desmume/src/sndsdl.cpp +++ b/desmume/src/sndsdl.cpp @@ -26,6 +26,12 @@ #include "sndsdl.h" #include "debug.h" +#ifdef _XBOX +#include +#include +#include +#endif + int SNDSDLInit(int buffersize); void SNDSDLDeInit(); void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples); @@ -54,6 +60,24 @@ static u32 soundbufsize; static SDL_AudioSpec audiofmt; ////////////////////////////////////////////////////////////////////////////// +#ifdef _XBOX +static volatile bool doterminate; +static volatile bool terminated; + +DWORD WINAPI SNDXBOXThread( LPVOID ) +{ + for(;;) { + if(doterminate) break; + { + SPU_Emulate_user(); + } + Sleep(10); + } + terminated = true; + return 0; +} +#endif + static void MixAudio(void *userdata, Uint8 *stream, int len) { int i; @@ -108,6 +132,12 @@ int SNDSDLInit(int buffersize) SDL_PauseAudio(0); +#ifdef _XBOX + doterminate = false; + terminated = false; + CreateThread(0,0,SNDXBOXThread,0,0,0); +#endif + return 0; } @@ -115,6 +145,12 @@ int SNDSDLInit(int buffersize) void SNDSDLDeInit() { +#ifdef _XBOX + doterminate = true; + while(!terminated) { + Sleep(1); + } +#endif SDL_CloseAudio(); if (stereodata16) diff --git a/desmume/src/types.h b/desmume/src/types.h index 85aa2d0ac..0fd95f641 100644 --- a/desmume/src/types.h +++ b/desmume/src/types.h @@ -21,18 +21,38 @@ #ifndef TYPES_HPP #define TYPES_HPP -//todo - everyone will want to support this eventually, i suppose +//analyze microsoft compilers #ifdef _MSC_VER + #ifdef _XBOX + //#define _XBOX //already defined + #else + #define _WINDOWS + #ifdef _M_X64 + #define _WIN64 + #else + //#define _WIN32 //already defined + #endif + #endif +#endif + +//todo - everyone will want to support this eventually, i suppose +#ifdef _WINDOWS #include "config.h" #endif +//xbox needs to include this to resemble windows +#ifdef _XBOX + #include + #include +#endif + #ifdef DEVELOPER #define IF_DEVELOPER(X) X #else #define IF_DEVELOPER(X) #endif -#ifdef _MSC_VER +#ifdef _WINDOWS #define HAVE_WX #define HAVE_LIBAGG #define ENABLE_SSE @@ -59,7 +79,7 @@ #undef ENABLE_SSE2 #endif -#ifdef _WIN32 +#ifdef _MSC_VER #define strcasecmp(x,y) _stricmp(x,y) #define snprintf _snprintf #else @@ -75,6 +95,13 @@ #endif #endif + +#ifdef _XBOX +#define MAX_PATH 1024 +#define PATH_MAX 1024 +#endif + + #if defined(_MSC_VER) || defined(__INTEL_COMPILER) #define ALIGN(X) __declspec(align(X)) #elif __GNUC__ @@ -418,4 +445,11 @@ char (*BLAHBLAHBLAH( UNALIGNED T (&)[N] ))[N]; static const char hexValid[23] = {"0123456789ABCDEFabcdef"}; + +template inline void reconstruct(T* t) { + t->~T(); + new(t) T(); +} + + #endif diff --git a/desmume/src/utils/task.cpp b/desmume/src/utils/task.cpp index d06d14ba5..a53e144db 100644 --- a/desmume/src/utils/task.cpp +++ b/desmume/src/utils/task.cpp @@ -17,13 +17,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "types.h" #include "task.h" - -#ifdef _WIN32 - -#include #include +#ifdef _MSC_VER + +#ifdef _WINDOWS +#include +#endif + + class Task::Impl { public: Impl(); diff --git a/desmume/src/version.cpp b/desmume/src/version.cpp index 83280c3a9..9ae128bed 100644 --- a/desmume/src/version.cpp +++ b/desmume/src/version.cpp @@ -21,7 +21,7 @@ #include "version.h" //todo - everyone will want to support this eventually, i suppose -#if defined(_MSC_VER) && !defined(WXPORT) +#if defined(_WINDOWS) && !defined(WXPORT) #include "svnrev.h" #else #ifdef SVN_REV diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index e53f70e23..b1288c4f0 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -26,8 +26,7 @@ #include "bits.h" - -#ifdef WIN32 +#ifdef _WINDOWS #include #include #define socket_t SOCKET @@ -52,12 +51,11 @@ #define BASEPORT 7000 -socket_t wifi_socket = INVALID_SOCKET; -sockaddr_t sendAddr; - const u8 BroadcastMAC[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; #ifdef EXPERIMENTAL_WIFI_COMM +socket_t wifi_socket = INVALID_SOCKET; +sockaddr_t sendAddr; #ifndef WIN32 #include "pcap/pcap.h" #endif