diff --git a/include/Graphics/IGraphicsDeviceService.h b/include/Graphics/IGraphicsDeviceService.h index 6a9f841..60863ea 100644 --- a/include/Graphics/IGraphicsDeviceService.h +++ b/include/Graphics/IGraphicsDeviceService.h @@ -7,8 +7,11 @@ #ifndef _XFX_GRAPHICS_IGRAPHICSDEVICESERVICE_ #define _XFX_GRAPHICS_IGRAPHICSDEVICESERVICE_ +#include #include +using namespace System; + namespace XFX { namespace Graphics @@ -28,8 +31,7 @@ namespace XFX virtual GraphicsDevice* getGraphicsDevice() const =0; - //! TODO: return typecode - int GetType() const { } + static const Type& GetType(); }; } } diff --git a/include/Graphics/SpriteBatch.h b/include/Graphics/SpriteBatch.h index f632234..ee02f03 100644 --- a/include/Graphics/SpriteBatch.h +++ b/include/Graphics/SpriteBatch.h @@ -8,6 +8,7 @@ #define _XFX_GRAPHICS_SPRITEBATCH_ #include "BlendState.h" +#include "DepthStencilState.h" #include "Effect.h" #include "Enums.h" #include diff --git a/include/Input/GamePadButtons.h b/include/Input/GamePadButtons.h index 1f0c95a..f680c67 100644 --- a/include/Input/GamePadButtons.h +++ b/include/Input/GamePadButtons.h @@ -9,6 +9,7 @@ #include "Enums.h" #include +#include using namespace System; @@ -32,7 +33,7 @@ namespace XFX const ButtonState_t X; const ButtonState_t Y; - GamePadButtons(const uint /* Buttons */ buttons); + GamePadButtons(const uint /* Buttons_t */ buttons); GamePadButtons(); GamePadButtons(const GamePadButtons &obj); diff --git a/include/Interfaces.h b/include/Interfaces.h index c64cd74..84f4ecb 100644 --- a/include/Interfaces.h +++ b/include/Interfaces.h @@ -46,6 +46,8 @@ namespace XFX virtual void CreateDevice()=0; virtual void EndDraw()=0; + static const Type& GetType(); + virtual ~IGraphicsDeviceManager() {} }; diff --git a/include/System/Collections/Generic/List.h b/include/System/Collections/Generic/List.h index 44368cd..f723643 100644 --- a/include/System/Collections/Generic/List.h +++ b/include/System/Collections/Generic/List.h @@ -63,15 +63,15 @@ namespace System class Enumerator : public IEnumerator { private: - int index = -1; + int index; + List * const parent; const int version; - List const * const parent; public: - T Current() const { return (*parent)[index]; } + T& Current() const { return (*parent)[index]; } - Enumerator(List const * const parent) - : parent(parent), version(parent->_version) + Enumerator(List * const parent) + : index(-1), parent(parent), version(parent->_version) { } @@ -184,7 +184,7 @@ namespace System while (enumerator->MoveNext()) { - Add(enumerator->Current(); + Add(enumerator->Current()); } } diff --git a/include/xmem.h b/include/xmem.h index 46eabf9..59ca0d2 100644 --- a/include/xmem.h +++ b/include/xmem.h @@ -7,6 +7,8 @@ #ifndef _XMEM_ #define _XMEM_ +#include + /** * * @@ -55,10 +57,10 @@ private: { private: CountedPtr(U* pT) : Count(0), my_pT(pT) { ASSERT(pT != 0); } - ~CountedPtr() { ASSERT(Count == 0); delete my_pT; } + ~CountedPtr() { sassert(Count == 0, "ERROR: called ~CountedPtr() while still holding at least one reference."); delete my_pT; } unsigned GetRef() { return ++Count; } - unsigned FreeRef() { ASSERT(Count != 0); return --Count; } + unsigned FreeRef() { sassert(Count != 0, "ERROR: called FreeRef() while not holding any reference."); return --Count; } U* const my_pT; unsigned Count; @@ -87,12 +89,13 @@ public: void Null() { UnBind(); } - UnBind() + void UnBind() { if (!IsNull() && ptr->FreeRef() == 0) { delete ptr; } + ptr = 0; } diff --git a/src/libXFX.Game/Game.cpp b/src/libXFX.Game/Game.cpp index 681914a..96b3f99 100644 --- a/src/libXFX.Game/Game.cpp +++ b/src/libXFX.Game/Game.cpp @@ -211,16 +211,22 @@ namespace XFX graphicsManager = (IGraphicsDeviceManager*)((GraphicsDeviceManager*)services.GetService(IGraphicsDeviceManager::GetType())); if (graphicsManager != null) + { graphicsManager->CreateDevice(); + } #if DEBUG else + { debugPrint("graphicsManager is NULL.\n"); + } #endif Initialize(); while(1) + { Tick(); + } EndRun(); inRun = false; diff --git a/src/libXFX.Game/GameServiceContainer.cpp b/src/libXFX.Game/GameServiceContainer.cpp index ab3e520..536a773 100644 --- a/src/libXFX.Game/GameServiceContainer.cpp +++ b/src/libXFX.Game/GameServiceContainer.cpp @@ -33,21 +33,24 @@ namespace XFX { } - void GameServiceContainer::AddService(const String& serviceType, Object* provider) + void GameServiceContainer::AddService(const Type& serviceType, Object* provider) { _services.Add(serviceType, provider); } - Object* GameServiceContainer::GetService(const String& serviceType) + Object* GameServiceContainer::GetService(const Type& serviceType) { Object* service = null; + if (_services.TryGetValue(serviceType, service)) + { return service; + } return null; } - void GameServiceContainer::RemoveService(const String& type) + void GameServiceContainer::RemoveService(const Type& type) { _services.Remove(type); } diff --git a/src/libXFX.Game/Interfaces.cpp b/src/libXFX.Game/Interfaces.cpp new file mode 100644 index 0000000..db506a0 --- /dev/null +++ b/src/libXFX.Game/Interfaces.cpp @@ -0,0 +1,42 @@ +// Copyright (C) XFX Team +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the copyright holder nor the names of any +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include + +#include + +using namespace System; + +namespace XFX +{ + const Type IGraphicsDeviceManagerTypeInfo("IGraphicsDeviceManager", "XFX::IGraphicsDeviceManager", TypeCode::Object); + + const Type& IGraphicsDeviceManager::GetType() + { + return IGraphicsDeviceManagerTypeInfo; + } +} diff --git a/src/libXFX.Game/libXFX.Game.vcxproj b/src/libXFX.Game/libXFX.Game.vcxproj index 0af24d9..f2ba66b 100644 --- a/src/libXFX.Game/libXFX.Game.vcxproj +++ b/src/libXFX.Game/libXFX.Game.vcxproj @@ -83,6 +83,7 @@ + diff --git a/src/libXFX.Game/libXFX.Game.vcxproj.filters b/src/libXFX.Game/libXFX.Game.vcxproj.filters index a779778..6a8fd0f 100644 --- a/src/libXFX.Game/libXFX.Game.vcxproj.filters +++ b/src/libXFX.Game/libXFX.Game.vcxproj.filters @@ -41,6 +41,9 @@ Source Files\GamerServices + + Source Files + diff --git a/src/libXFX.Game/makefile b/src/libXFX.Game/makefile index 83dfe52..dce7285 100644 --- a/src/libXFX.Game/makefile +++ b/src/libXFX.Game/makefile @@ -2,7 +2,7 @@ # update this variable to wherever you installed the OpenXDK libraries # ######################################################################### -PREFIX = /openxdk +PREFIX = /usr/local/openxdk CC = gcc CCAS = gcc diff --git a/src/libXFX/Color.cpp b/src/libXFX/Color.cpp index a1c738f..a2b071e 100644 --- a/src/libXFX/Color.cpp +++ b/src/libXFX/Color.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,8 @@ namespace XFX { namespace Graphics { + const Type ColorTypeInfo("Color", "XFX::Graphics::Color", TypeCode::Object); + uint Color::RGBAtoARGB(uint value) { uint x = ((value >> 0) ^ (value >> 25)) & ((1U << 8) - 1); // XOR temporary @@ -258,9 +261,9 @@ namespace XFX return (int)_packedValue; } - int Color::GetType() + const Type& Color::GetType() { - // TODO: implement + return ColorTypeInfo; } uint Color::PackedValue() const @@ -269,21 +272,21 @@ namespace XFX } uint Color::InitializeFromVector4(const Vector4 value) - { - byte r = (byte)(Math::Round(value.X * 255)); - byte g = (byte)(Math::Round(value.Y * 255)); - byte b = (byte)(Math::Round(value.Z * 255)); - byte a = (byte)(Math::Round(value.W * 255)); - return ((uint)a << 24) + ((uint)r << 16) + ((uint)g << 8) + b; - } - - uint Color::InitializeFromVector3(const Vector3 value) - { - byte r = (byte)(Math::Round(value.X * 255)); - byte g = (byte)(Math::Round(value.Y * 255)); - byte b = (byte)(Math::Round(value.Z * 255)); - return ((uint)255 << 24) + ((uint)r << 16) + ((uint)g << 8) + b; - } + { + byte r = (byte)(Math::Round(value.X * 255)); + byte g = (byte)(Math::Round(value.Y * 255)); + byte b = (byte)(Math::Round(value.Z * 255)); + byte a = (byte)(Math::Round(value.W * 255)); + return ((uint)a << 24) + ((uint)r << 16) + ((uint)g << 8) + b; + } + + uint Color::InitializeFromVector3(const Vector3 value) + { + byte r = (byte)(Math::Round(value.X * 255)); + byte g = (byte)(Math::Round(value.Y * 255)); + byte b = (byte)(Math::Round(value.Z * 255)); + return ((uint)255 << 24) + ((uint)r << 16) + ((uint)g << 8) + b; + } const String Color::ToString() const { @@ -291,14 +294,14 @@ namespace XFX } Vector4 Color::ToVector4() const - { - return Vector4((float)R() / 255, (float)G() / 255, (float)B() / 255, (float)A() / 255); - } - - Vector3 Color::ToVector3() const - { - return Vector3((float)R() / 255, (float)G() / 255, (float)B() / 255); - } + { + return Vector4((float)R() / 255, (float)G() / 255, (float)B() / 255, (float)A() / 255); + } + + Vector3 Color::ToVector3() const + { + return Vector3((float)R() / 255, (float)G() / 255, (float)B() / 255); + } bool Color::operator!=(const Color& other) const { @@ -306,9 +309,9 @@ namespace XFX } bool Color::operator==(const Color& other) const - { - return (_packedValue == other._packedValue); - } + { + return (_packedValue == other._packedValue); + } Color Color::operator*(const float scale) const { diff --git a/src/libXFX/ContentManager.cpp b/src/libXFX/ContentManager.cpp index 668eb24..62625bf 100644 --- a/src/libXFX/ContentManager.cpp +++ b/src/libXFX/ContentManager.cpp @@ -99,7 +99,7 @@ namespace XFX } template - T ContentManager::Load(const String& assetName) + T* ContentManager::Load(const String& assetName) { T dummyVal; Object* obj2; @@ -134,7 +134,6 @@ namespace XFX return local; */ - Object* obj2; sassert(!String::IsNullOrEmpty(assetName), String::Format("assetName; %s", FrameworkResources::ArgumentNull_Generic)); /*if (this->loadedAssets.TryGetValue(assetName, obj2)) { @@ -182,7 +181,7 @@ namespace XFX } template - T ContentManager::ReadAsset(const String& assetName) + T* ContentManager::ReadAsset(const String& assetName) { sassert(!disposed, ""); diff --git a/src/libXFX/DisplayModeCollection.cpp b/src/libXFX/DisplayModeCollection.cpp index 61d55c7..582439e 100644 --- a/src/libXFX/DisplayModeCollection.cpp +++ b/src/libXFX/DisplayModeCollection.cpp @@ -26,41 +26,29 @@ // POSSIBILITY OF SUCH DAMAGE. #include +#include namespace XFX { namespace Graphics { + const Type DisplayModeCollectionTypeInfo("DisplayModeCollection", "XFX::Graphics::DisplayModeCollection", TypeCode::Object); + DisplayModeCollection::DisplayModeCollection() { } - bool DisplayModeCollection::operator!=(const DisplayModeCollection& other) const + IEnumerator* DisplayModeCollection::GetEnumerator() { - int num; - if ((adapterOrdinal == other.adapterOrdinal) && (currentFormat == other.currentFormat)) - { - num = 1; - } - else - { - num = 0; - } - return (bool)((byte)(((byte) num) == 0)); } - bool DisplayModeCollection::operator==(const DisplayModeCollection& other) const + const Type& DisplayModeCollection::GetType() + { + return DisplayModeCollectionTypeInfo; + } + + DisplayMode& DisplayModeCollection::operator[](const SurfaceFormat_t format) const { - int num; - if ((adapterOrdinal == other.adapterOrdinal) && (currentFormat == other.currentFormat)) - { - num = 1; - } - else - { - num = 0; - } - return (bool)((byte) num); } } } diff --git a/src/libXFX/IGraphicsDeviceService.cpp b/src/libXFX/IGraphicsDeviceService.cpp new file mode 100644 index 0000000..11ef929 --- /dev/null +++ b/src/libXFX/IGraphicsDeviceService.cpp @@ -0,0 +1,45 @@ +// Copyright (C) XFX Team +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the copyright holder nor the names of any +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include + +#include + +using namespace System; + +namespace XFX +{ + namespace Graphics + { + const Type IGraphicsDeviceServiceTypeInfo("IGraphicsDeviceService", "XFX::Graphics::IGraphicsDeviceService", TypeCode::Object); + + const Type& IGraphicsDeviceService::GetType() + { + return IGraphicsDeviceServiceTypeInfo; + } + } +} diff --git a/src/libXFX/Sprite.cpp b/src/libXFX/Sprite.cpp index 951f49a..14b83f3 100644 --- a/src/libXFX/Sprite.cpp +++ b/src/libXFX/Sprite.cpp @@ -26,11 +26,14 @@ // POSSIBILITY OF SUCH DAMAGE. #include +#include namespace XFX { namespace Graphics { + const Type SpriteTypeInfo("Sprite", "XFX::Graphics::Sprite", TypeCode::Object); + Sprite::Sprite() { } @@ -99,8 +102,9 @@ namespace XFX return layerDepth; } - int Sprite::GetType() + const Type& Sprite::GetType() { + return SpriteTypeInfo; } bool Sprite::operator !=(const Sprite& right) const diff --git a/src/libXFX/SpriteBatch.cpp b/src/libXFX/SpriteBatch.cpp index 3ed8707..4cca96d 100644 --- a/src/libXFX/SpriteBatch.cpp +++ b/src/libXFX/SpriteBatch.cpp @@ -44,10 +44,14 @@ extern "C" #include +#include + namespace XFX { namespace Graphics { + const Type SpriteBatchTypeInfo("SpriteBatch", "XFX::Graphics::SpriteBatch", TypeCode::Object); + SpriteBatch::SpriteBatch(GraphicsDevice * const graphicsDevice) : device(graphicsDevice) { @@ -228,18 +232,18 @@ namespace XFX inBeginEndPair = false; } - int SpriteBatch::GetType() + const Type& SpriteBatch::GetType() { - // TODO: implement + return SpriteBatchTypeInfo; } - + void SpriteBatch::restoreRenderState() { - + } - - void SpriteBatch::applyGraphicsDeviceSettings() - { + + void SpriteBatch::applyGraphicsDeviceSettings() + { DWORD* p; p = pb_begin(); diff --git a/src/libXFX/StateBlock.cpp b/src/libXFX/StateBlock.cpp index 4b76429..f5f6af2 100644 --- a/src/libXFX/StateBlock.cpp +++ b/src/libXFX/StateBlock.cpp @@ -26,11 +26,14 @@ // POSSIBILITY OF SUCH DAMAGE. #include +#include namespace XFX { namespace Graphics { + const Type StateBlockTypeInfo("StateBlock", "XFX::Graphics::StateBlock", TypeCode::Object); + StateBlock::StateBlock(GraphicsDevice* graphicsDevice) : device(graphicsDevice) { @@ -68,8 +71,9 @@ namespace XFX { } - int StateBlock::GetType() + const Type& StateBlock::GetType() { + return StateBlockTypeInfo; } const String StateBlock::ToString() const diff --git a/src/libXFX/StorageContainer.cpp b/src/libXFX/StorageContainer.cpp index 774a536..cba8d05 100644 --- a/src/libXFX/StorageContainer.cpp +++ b/src/libXFX/StorageContainer.cpp @@ -34,6 +34,8 @@ extern "C" #include #include #include + +#undef __STRICT_ANSI__ #include #include @@ -46,7 +48,7 @@ namespace XFX typedef struct { char cDriveLetter; - char* szDevice; + char const * const szDevice; int iPartition; } stDriveMapping; @@ -77,11 +79,13 @@ namespace XFX } part_num = atoi(szPartition + 19); + if (part_num >= EXTEND_PARTITION_BEGIN) { *cDriveLetter = extendPartitionMapping[part_num - EXTEND_PARTITION_BEGIN]; return; } + for (unsigned int i = 0; i < NUM_OF_DRIVES; i++) { if (strnicmp(driveMapping[i].szDevice, szPartition, strlen(driveMapping[i].szDevice)) == 0) @@ -90,6 +94,7 @@ namespace XFX return; } } + *cDriveLetter = 0; } @@ -144,7 +149,7 @@ namespace XFX // copy the XeImageFileName to tmp, and strip the \default.xbe //char *tmp = strncpy(tmp, XeImageFileName->Buffer, XeImageFileName->Length - 12); - auto_ptr szTemp(new char[256]); + char* szTemp = new char[256]; char cDriveLetter = 0; char* szDest; @@ -157,13 +162,15 @@ namespace XFX sprintf(szDest, "%c:\\%s", cDriveLetter, szTemp); + delete szTemp; + return szDest; } const String StorageContainer::TitleName() const { FILE* file = fopen(XeImageFileName->Buffer, "rb"); - auto_ptr titleName(new char[0x50]); + char* titleName = new char[0x50]; uint32_t CertAddr = 0; fseek(file, 0x118, SEEK_SET); fread(&CertAddr, 4, 1, file); @@ -171,6 +178,8 @@ namespace XFX fseek(file, CertAddr - 0x10000, SEEK_SET); fread(titleName, 0x50, 1, file); + // TODO: free C-string somehow + fclose(file); return titleName; diff --git a/src/libXFX/TextureCollection.cpp b/src/libXFX/TextureCollection.cpp index c762f07..176afcc 100644 --- a/src/libXFX/TextureCollection.cpp +++ b/src/libXFX/TextureCollection.cpp @@ -28,10 +28,14 @@ #include #include +#include + namespace XFX { namespace Graphics { + const Type TextureCollectionTypeInfo("TextureCollection", "XFX::Graphics::TextureCollection", TypeCode::Object); + void TextureCollection::Dispose() { Dispose(true); @@ -52,8 +56,9 @@ namespace XFX Dispose(false); } - int TextureCollection::GetType() + const Type& TextureCollection::GetType() { + return TextureCollectionTypeInfo; } // // Operators diff --git a/src/libXFX/VertexPositionNormalTexture.cpp b/src/libXFX/VertexPositionNormalTexture.cpp index af0143c..2db599c 100644 --- a/src/libXFX/VertexPositionNormalTexture.cpp +++ b/src/libXFX/VertexPositionNormalTexture.cpp @@ -29,11 +29,14 @@ #include #include #include +#include namespace XFX { namespace Graphics { + const Type VertexPositionNormalTextureTypeInfo("VertexPositionNormalTexture", "XFX::Graphics::VertexPositionNormalTexture", TypeCode::Object); + const VertexElement VertexPositionNormalTexture::vertexArray[] = { VertexElement(0, VertexElementFormat::Vector3, VertexElementUsage::Position, 0), @@ -65,9 +68,9 @@ namespace XFX return Normal.GetHashCode() ^ Position.GetHashCode() ^ TextureCoordinate.GetHashCode(); } - int VertexPositionNormalTexture::GetType() + const Type& VertexPositionNormalTexture::GetType() { - // TODO: implement + return VertexPositionNormalTextureTypeInfo; } const String VertexPositionNormalTexture::ToString() const diff --git a/src/libXFX/libXFX.vcxproj b/src/libXFX/libXFX.vcxproj index 7fbe82c..3e4d89c 100644 --- a/src/libXFX/libXFX.vcxproj +++ b/src/libXFX/libXFX.vcxproj @@ -54,7 +54,7 @@ - $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);$(SolutionDir)include + C:\cygwin\usr\include;C:\cygwin\usr\local\openxdk\i386-pc-xbox\include;C:\cygwin\usr\local\openxdk\include;C:\cygwin\usr\local\openxdk\include\SDL;$(SolutionDir)include @@ -85,6 +85,7 @@ + diff --git a/src/libXFX/libXFX.vcxproj.filters b/src/libXFX/libXFX.vcxproj.filters index 9d4d576..71db1d0 100644 --- a/src/libXFX/libXFX.vcxproj.filters +++ b/src/libXFX/libXFX.vcxproj.filters @@ -257,6 +257,9 @@ Source Files + + Source Files\Graphics + diff --git a/src/libXFX/makefile b/src/libXFX/makefile index decfe8e..c12a70b 100644 --- a/src/libXFX/makefile +++ b/src/libXFX/makefile @@ -2,13 +2,13 @@ # update this variable to wherever you installed the OpenXDK libraries # ######################################################################### -PREFIX = /openxdk +PREFIX = /usr/local/openxdk -CC = xbox-gcc -CCAS = xbox-gcc -CPP = xbox-g++ -AR = xbox-ar rcu -RANLIB = xbox-ranlib +CC = gcc +CCAS = gcc +CPP = g++ +AR = ar rcu +RANLIB = ranlib CXBE = $(PREFIX)/bin/cxbe SDLFLAGS = -DENABLE_XBOX -DDEBUG @@ -28,9 +28,9 @@ LD_LIBS = $(LD_DIRS) -lmscorlib -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -l OBJS = BoundingBox.o BoundingFrustum.o BoundingSphere.o MathHelper.o Matrix.o Plane.o Point.o Quaternion.o Ray.o Rectangle.o Vector2.o Vector3.o Vector4.o AUDIO_OBJS = SoundEffect.o SoundEffectInstance.o -CONTENT_OBJS = ContentManager.o ContentReader.o +#CONTENT_OBJS = ContentManager.o ContentReader.o GAMERSERVICES_OBJS = Guide.o StorageDeviceAsyncResult.o -GRAPHICS_OBJS = BasicEffect.o BlendState.o Color.o DisplayMode.o DisplayModeCollection.o Effect.o GraphicsAdapter.o GraphicsDevice.o GraphicsResource.o pbKit.o PresentationParameters.o Sprite.o SpriteBatch.o SpriteFont.o StateBlock.o Texture.o Texture2D.o TextureCollection.o VertexElement.o VertexPositionColor.o VertexPositionNormalTexture.o VertexPositionTexture.o Viewport.o +GRAPHICS_OBJS = BasicEffect.o BlendState.o Color.o DisplayMode.o DisplayModeCollection.o Effect.o GraphicsAdapter.o GraphicsDevice.o GraphicsResource.o IGraphicsDeviceService.o pbKit.o PresentationParameters.o Sprite.o SpriteBatch.o SpriteFont.o StateBlock.o Texture.o Texture2D.o TextureCollection.o VertexElement.o VertexPositionColor.o VertexPositionNormalTexture.o VertexPositionTexture.o Viewport.o INPUT_OBJS = GamePad.o Keyboard.o Mouse.o MEDIA_OBJS = VideoPlayer.o NET_OBJS = PacketReader.o PacketWriter.o diff --git a/src/libmscorlib/Int64.cpp b/src/libmscorlib/Int64.cpp index 7fb707e..8310dea 100644 --- a/src/libmscorlib/Int64.cpp +++ b/src/libmscorlib/Int64.cpp @@ -29,6 +29,7 @@ #include #include +#undef __STRICT_ANSI__ #include namespace System diff --git a/src/libmscorlib/Math.cpp b/src/libmscorlib/Math.cpp index a703e2b..3bbc453 100644 --- a/src/libmscorlib/Math.cpp +++ b/src/libmscorlib/Math.cpp @@ -27,10 +27,8 @@ #include -extern "C" -{ +#undef __STRICT_ANSI__ #include -} namespace System { diff --git a/src/libmscorlib/Object.cpp b/src/libmscorlib/Object.cpp index ce6fb9d..4335a76 100644 --- a/src/libmscorlib/Object.cpp +++ b/src/libmscorlib/Object.cpp @@ -32,7 +32,7 @@ namespace System { - const Type ObjectTypeInfo("Object", "System::Object"); + const Type ObjectTypeInfo("Object", "System::Object", TypeCode::Object); bool Object::Equals(Object const * const obj) const { @@ -49,7 +49,7 @@ namespace System return (int)this; } - Type Object::GetType() + const Type& Object::GetType() { return ObjectTypeInfo; } @@ -59,7 +59,7 @@ namespace System return (&objA == &objB); } - const String& Object::ToString() const + const String Object::ToString() const { return "Object"; } diff --git a/src/libmscorlib/OperatingSystem.cpp b/src/libmscorlib/OperatingSystem.cpp index f6239f5..cddbafb 100644 --- a/src/libmscorlib/OperatingSystem.cpp +++ b/src/libmscorlib/OperatingSystem.cpp @@ -27,9 +27,12 @@ #include #include +#include namespace System { + const Type OperatingSystemTypeInfo("OperatingSystem", "System::OperatingSystem", TypeCode::Object); + OperatingSystem::OperatingSystem(const PlatformID_t platform, const System::Version version) : Platform(platform), Version(version) { @@ -55,13 +58,14 @@ namespace System return (int)Platform + Version.GetHashCode(); } - int OperatingSystem::GetType() + const Type& OperatingSystem::GetType() { + return OperatingSystemTypeInfo; } - const String& OperatingSystem::ToString() const + const String OperatingSystem::ToString() const { - return ""; + // TODO: implement } bool OperatingSystem::operator !=(const OperatingSystem& right) const diff --git a/src/libmscorlib/Path.cpp b/src/libmscorlib/Path.cpp index ff1f096..078f6f7 100644 --- a/src/libmscorlib/Path.cpp +++ b/src/libmscorlib/Path.cpp @@ -30,6 +30,7 @@ #include #include +#undef __STRICT_ANSI__ #include #include #include @@ -98,17 +99,26 @@ namespace System String Path::Combine(const String& path1, const String& path2) { if (path1.Length == 0) + { return path2; + } if (path2.Length == 0) + { return path1; + } if (IsPathRooted(path2)) + { return path2; + } char p1end = path1[path1.Length - 1]; + if (p1end != DirectorySeparatorChar && p1end != AltDirectorySeparatorChar && p1end != VolumeSeparatorChar) + { return path1 + &DirectorySeparatorChar + path2; + } return (path1 + path2); } @@ -125,17 +135,22 @@ namespace System } part_num = atoi(szPartition + 19); + if (part_num >= 6) { *cDriveLetter = extendPartitionMapping[part_num-6]; return; } + for (unsigned int i=0; i < NUM_OF_DRIVES; i++) + { if (strnicmp(driveMapping[i].szDevice, szPartition, strlen(driveMapping[i].szDevice)) == 0) { *cDriveLetter = driveMapping[i].cDriveLetter; return; } + } + *cDriveLetter = 0; } diff --git a/src/libmscorlib/Single.cpp b/src/libmscorlib/Single.cpp index d34df0f..f5827ce 100644 --- a/src/libmscorlib/Single.cpp +++ b/src/libmscorlib/Single.cpp @@ -30,7 +30,9 @@ #include #include #include +#include #include +#undef __STRICT_ANSI__ #include namespace System @@ -46,6 +48,8 @@ namespace System const float Single::PositiveInfinity = *(float*)&rawPosInfF; const float Single::NegativeInfinity = *(float*)&rawNegInfF; + const Type SingleTypeInfo("Single", "System::Single", TypeCode::Single); + Single::Single() : value(0.0f) { @@ -64,9 +68,15 @@ namespace System int Single::CompareTo(const Single other) const { if (value > other.value) + { return 1; + } + if (value < other.value) + { return -1; + } + return 0; } @@ -85,9 +95,9 @@ namespace System return (int)value; } - int Single::GetType() + const Type& Single::GetType() { - return 13; + return SingleTypeInfo; } bool Single::TryParse(const String& str, out float* result) @@ -119,12 +129,12 @@ namespace System return true; } - const String& Single::ToString() const + const String Single::ToString() const { return String::Format("%f", value); } - const String& Single::ToString(const float value) + const String Single::ToString(const float value) { return String::Format("%f", value); } diff --git a/src/libmscorlib/Stream.cpp b/src/libmscorlib/Stream.cpp index 51ae167..7652bd1 100644 --- a/src/libmscorlib/Stream.cpp +++ b/src/libmscorlib/Stream.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -39,6 +40,7 @@ namespace System namespace IO { const Stream* Stream::Null = new Stream(); + const Type StreamTypeInfo("Stream", "System::IO::Stream", TypeCode::Object); Stream::Stream() { @@ -76,9 +78,9 @@ namespace System // TODO: implement } - int Stream::GetType() + const Type& Stream::GetType() { - // TODO: implement + return StreamTypeInfo; } int Stream::ReadByte() diff --git a/src/libmscorlib/String.cpp b/src/libmscorlib/String.cpp index d6d3ff2..176d0f7 100644 --- a/src/libmscorlib/String.cpp +++ b/src/libmscorlib/String.cpp @@ -30,6 +30,7 @@ #include #include #include +#undef __STRICT_ANSI__ #include #include #include @@ -489,7 +490,9 @@ namespace System return *this; } - return String(right); + String result(right.internalString); + + return result; } String String::operator +(const char *right) const diff --git a/src/libmscorlib/UInt64.cpp b/src/libmscorlib/UInt64.cpp index f08b671..6dcec7c 100644 --- a/src/libmscorlib/UInt64.cpp +++ b/src/libmscorlib/UInt64.cpp @@ -29,6 +29,7 @@ #include #include +#undef __STRICT_ANSI__ #include namespace System diff --git a/src/libmscorlib/libmscorlib.vcxproj b/src/libmscorlib/libmscorlib.vcxproj index c9bb256..8997c6c 100644 --- a/src/libmscorlib/libmscorlib.vcxproj +++ b/src/libmscorlib/libmscorlib.vcxproj @@ -54,6 +54,9 @@ + + C:\cygwin\usr\include;C:\cygwin\usr\local\openxdk\i386-pc-xbox\include;C:\cygwin\usr\local\openxdk\include;C:\cygwin\usr\local\openxdk\include\SDL;$(SolutionDir)include + BuildLog.htm diff --git a/src/libmscorlib/makefile b/src/libmscorlib/makefile index c00ad5b..f6c6579 100644 --- a/src/libmscorlib/makefile +++ b/src/libmscorlib/makefile @@ -2,7 +2,7 @@ # update this variable to wherever you installed the OpenXDK libraries # ######################################################################### -PREFIX = /openxdk +PREFIX = /usr/local/openxdk CC = gcc CCAS = gcc @@ -12,7 +12,7 @@ RANLIB = ranlib CXBE = $(PREFIX)/bin/cxbe SDLFLAGS = -DENABLE_XBOX -DDEBUG -CC_FLAGS = -c -g -O2 -std=C99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS) +CC_FLAGS = -c -g -O2 -std=gnu99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS) CCAS_FLAGS = --32 -march=pentiumiii, mmx, sse -mtune=pentiumiii -msse-check=error CPP_FLAGS = -c -O2 -std=c++03 -Wall -nostdlib -fno-builtin -fno-exceptions -fno-rtti -march=i686 -mmmx -msse -mfpmath=sse $(SDLFLAGS) INCLUDE = -I$(PREFIX)/i386-pc-xbox/include -I$(PREFIX)/include -I$(PREFIX)/include/SDL -I../../include diff --git a/src/libmscorlib/misc.cpp b/src/libmscorlib/misc.cpp index 5e8671e..9fb1fa3 100644 --- a/src/libmscorlib/misc.cpp +++ b/src/libmscorlib/misc.cpp @@ -152,3 +152,18 @@ int strcasecmp(const char * s1, const char * s2) return (tolower(*us1) - tolower(*--us2)); } + +int strncasecmp(const char * s1, const char * s2, size_t n) +{ + while (n --> 0) // n goes to zero ;) + { + const unsigned char us1 = (const unsigned char)toupper(*s1); + const unsigned char us2 = (const unsigned char)toupper(*s2); + + if (us1 < us2) return -1; + if (us1 > us2) return 1; + ++s1; ++s2; + } + + return 0; +}