From 0fa3659fb42e0c002320f81b256edc4b1149bcb6 Mon Sep 17 00:00:00 2001 From: Tom Lint Date: Thu, 30 May 2013 13:55:10 +0200 Subject: [PATCH] added README Updated XFX::Input namespace classes Updated XFX::Net namespace classes Updated System::IO namespace classes Updated .gitignore to ignore buildlog.htm variants --- .gitignore | 2 +- README.md | 11 +++++ XFX.sln | 3 ++ include/Input/Mouse.h | 4 +- include/Net/PacketReader.h | 8 ++-- include/System/IO/MemoryStream.h | 3 +- include/System/IO/TextWriter.h | 2 +- src/libXFX/GamePad.cpp | 35 +++++++++------- src/libXFX/Guide.cpp | 7 +++- src/libXFX/Keyboard.cpp | 18 ++++---- src/libXFX/Mouse.cpp | 12 +++--- src/libXFX/PacketReader.cpp | 51 +++++++++++------------ src/libXFX/PacketWriter.cpp | 68 +++++++++++++++---------------- src/libXFX/VideoPlayer.cpp | 2 +- src/libmscorlib/DirectoryInfo.cpp | 2 +- src/libmscorlib/TextWriter.cpp | 7 ++-- 16 files changed, 130 insertions(+), 105 deletions(-) create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 090149c..ae83298 100644 --- a/.gitignore +++ b/.gitignore @@ -46,7 +46,7 @@ local.properties [Rr]elease/ *_i.c *_p.c -[Bb]uildlog.htm +[Bb]uild[Ll]og.htm *.ilk *.meta *.o diff --git a/README.md b/README.md new file mode 100644 index 0000000..f698c3c --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# XFXFramework +## C++ implementation of XNA For XBOX + +XFX, or [XNA](http://en.wikipedia.org/wiki/Microsoft_XNA) for [XBOX](http://en.wikipedia.org/wiki/Xbox_(console)) is an implementation of [XNA](http://en.wikipedia.org/wiki/Microsoft_XNA), written in C++ for Microsofts [XBOX](http://en.wikipedia.org/wiki/Xbox_(console)) console. +It's written on top of [OpenXDK](http://sourceforge.net/projects/openxdk/), the open source, free, legal XBOX Development Kit. + +XFX is an attempt to bring development for the original [XBOX](http://en.wikipedia.org/wiki/Xbox_(console)) console to the masses by wrapping all low-level code in the familiar XNA classes. +Being written in C++ allows XFX to be lightweight and as close to the hardware as possible. + +Compiling XFX requires at least OpenXDK version 0.7 + diff --git a/XFX.sln b/XFX.sln index 1153a3a..24d2002 100644 --- a/XFX.sln +++ b/XFX.sln @@ -2,6 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{888801DD-E68C-4BDE-8B21-890076EF7A59}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libXFX", "src\libXFX\libXFX.vcxproj", "{379FFCFD-88FA-46D6-A686-CAE8F58652FC}" EndProject diff --git a/include/Input/Mouse.h b/include/Input/Mouse.h index 2e4a387..4fdf462 100644 --- a/include/Input/Mouse.h +++ b/include/Input/Mouse.h @@ -27,8 +27,8 @@ namespace XFX ButtonState_t XButton2; int Y; - bool operator!=(const MouseState other); - bool operator==(const MouseState other); + bool operator!=(const MouseState& other) const; + bool operator==(const MouseState& other) const; }; // Allows retrieval of position and button clicks from a mouse input device. diff --git a/include/Net/PacketReader.h b/include/Net/PacketReader.h index 0954581..63a2a0d 100644 --- a/include/Net/PacketReader.h +++ b/include/Net/PacketReader.h @@ -16,12 +16,12 @@ namespace XFX namespace Net { // Provides common functionality for efficiently reading incoming network packets. - class PacketReader : public BinaryReader, public virtual Object + class PacketReader : public BinaryReader, public Object { public: int Length(); - int Position(); - void Position(int newValue); + int getPosition(); + void setPosition(int newValue); PacketReader(); PacketReader(int capacity); @@ -30,7 +30,7 @@ namespace XFX Quaternion ReadQuaternion(); Vector2 ReadVector2(); Vector3 ReadVector3(); - Vector4 ReadVEctor4(); + Vector4 ReadVector4(); }; } } diff --git a/include/System/IO/MemoryStream.h b/include/System/IO/MemoryStream.h index 3fc6b45..5151d53 100644 --- a/include/System/IO/MemoryStream.h +++ b/include/System/IO/MemoryStream.h @@ -9,7 +9,7 @@ namespace System namespace IO { // Creates a stream whose backing store is memory. - class MemoryStream : public Stream, public virtual Object + class MemoryStream : public Stream { private: byte* _buffer; @@ -48,6 +48,7 @@ namespace System void Flush(); virtual byte* GetBuffer(); + int GetType() const; int Read(byte buffer[], int offset, int count); int ReadByte(); long long Seek(long long offset, SeekOrigin_t loc); diff --git a/include/System/IO/TextWriter.h b/include/System/IO/TextWriter.h index b80d26a..844ccf5 100644 --- a/include/System/IO/TextWriter.h +++ b/include/System/IO/TextWriter.h @@ -24,7 +24,7 @@ namespace System char CoreNewLine[]; TextWriter(); - TextWriter(const IFormatProvider* provider); + TextWriter(IFormatProvider * const provider); TextWriter(const TextWriter &obj); virtual void Dispose(bool disposing); diff --git a/src/libXFX/GamePad.cpp b/src/libXFX/GamePad.cpp index 1ce35f2..7021f4e 100644 --- a/src/libXFX/GamePad.cpp +++ b/src/libXFX/GamePad.cpp @@ -121,9 +121,9 @@ namespace XFX { } - bool GamePadState::Equals(const Object* obj) const + bool GamePadState::Equals(Object const * const obj) const { - return is(obj, this) ? this->Equals(*(GamePadState*)obj) : false; + return is(obj, this) ? *this == *(GamePadState *)obj : false; } bool GamePadState::Equals(const GamePadState obj) const @@ -138,6 +138,7 @@ namespace XFX int GamePadState::GetType() const { + // TODO: implement } bool GamePadState::IsButtonDown(const Buttons_t button) const @@ -203,7 +204,7 @@ namespace XFX const char* GamePadState::ToString() const { - return String::Format("{{IsConnected:%b}}", IsConnected); + return String::Format("{IsConnected:%b}", IsConnected); } bool GamePadState::operator ==(const GamePadState& right) const @@ -248,9 +249,9 @@ namespace XFX { } - bool GamePadButtons::Equals(const Object* obj) const + bool GamePadButtons::Equals(Object const * const obj) const { - return is(obj, this) ? this->Equals(*(GamePadButtons*)obj) : false; + return is(obj, this) ? *this == *(GamePadButtons *)obj : false; } bool GamePadButtons::Equals(const GamePadButtons other) const @@ -266,6 +267,7 @@ namespace XFX int GamePadButtons::GetType() const { + // TODO: implement } const char* GamePadButtons::ToString() const @@ -316,7 +318,7 @@ namespace XFX str = "None"; } - return String::Format("{{Buttons:%s}}", str.ToString()); + return String::Format("{Buttons:%s}", str.ToString()); } bool GamePadButtons::operator!=(const GamePadButtons& other) const @@ -350,9 +352,9 @@ namespace XFX { } - bool GamePadDPad::Equals(const Object* obj) const + bool GamePadDPad::Equals(Object const * const obj) const { - return is(obj, this) ? this->Equals(*(GamePadDPad*)obj) : false; + return is(obj, this) ? *this == *(GamePadDPad *)obj : false; } bool GamePadDPad::Equals(const GamePadDPad obj) const @@ -367,6 +369,7 @@ namespace XFX int GamePadDPad::GetType() const { + // TODO: implement } const char* GamePadDPad::ToString() const @@ -393,7 +396,7 @@ namespace XFX str = "None"; } - return String::Format("{{DPad:%s}}", str.ToString()); + return String::Format("{DPad:%s}", str.ToString()); } bool GamePadDPad::operator !=(const GamePadDPad& right) const @@ -423,9 +426,9 @@ namespace XFX { } - bool GamePadThumbSticks::Equals(const Object* obj) const + bool GamePadThumbSticks::Equals(Object const * const obj) const { - return is(obj, this) ? this->Equals(*(GamePadThumbSticks*)obj) : false; + return is(obj, this) ? *this == *(GamePadThumbSticks *)obj : false; } bool GamePadThumbSticks::Equals(const GamePadThumbSticks obj) const @@ -440,11 +443,12 @@ namespace XFX int GamePadThumbSticks::GetType() const { + // TODO: implement } const char* GamePadThumbSticks::ToString() const { - return String::Format("{{Left:%s Right%s}}", Left.ToString(), Right.ToString()); + return String::Format("{Left:%s Right%s}", Left.ToString(), Right.ToString()); } bool GamePadThumbSticks::operator!=(const GamePadThumbSticks& other) const @@ -472,9 +476,9 @@ namespace XFX { } - bool GamePadTriggers::Equals(const Object* obj) const + bool GamePadTriggers::Equals(Object const * const obj) const { - return is(obj, this) ? this->Equals(*(GamePadTriggers*)obj) : false; + return is(obj, this) ? *this == *(GamePadTriggers *)obj : false; } bool GamePadTriggers::Equals(const GamePadTriggers obj) const @@ -489,11 +493,12 @@ namespace XFX int GamePadTriggers::GetType() const { + // TODO: implement } const char* GamePadTriggers::ToString() const { - return String::Format("{{Left:%f Right:%f}}", Left, Right); + return String::Format("{Left:%f Right:%f}", Left, Right); } bool GamePadTriggers::operator!=(const GamePadTriggers& other) const diff --git a/src/libXFX/Guide.cpp b/src/libXFX/Guide.cpp index e913376..1bd46eb 100644 --- a/src/libXFX/Guide.cpp +++ b/src/libXFX/Guide.cpp @@ -59,6 +59,11 @@ namespace XFX IAsyncResult* Guide::BeginShowMessageBox(const PlayerIndex_t player, String& title, String& text, IEnumerable* buttons, const int focusButton, const MessageBoxIcon_t icon, AsyncCallback callback, Object* state) { + if (String::IsNullOrEmpty(title)) + title = String::Empty; + + sassert(buttons != NULL, String::Format("buttons: %s", FrameworkResources::ArgumentNull_Generic)); + // just return null to stop warning until this thing's coded return null; } @@ -103,7 +108,7 @@ namespace XFX { StorageDeviceAsyncResult* result = (StorageDeviceAsyncResult*)asyncResult; - sassert(result, String::Format("result; %s", FrameworkResources::ArgumentNull_Generic)); + sassert(result, String::Format("asyncResult; %s", FrameworkResources::ArgumentNull_Generic)); return StorageDevice(0, (PlayerIndex_t)result->playerIndex); } diff --git a/src/libXFX/Keyboard.cpp b/src/libXFX/Keyboard.cpp index b9b76dd..e6bca04 100644 --- a/src/libXFX/Keyboard.cpp +++ b/src/libXFX/Keyboard.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2012, Halofreak_1990 +// Copyright (C) 2010-2012, XFX Team // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -41,17 +41,17 @@ namespace XFX { XKEYBOARD_STROKE Stroke; - //It's a waste of memory to create a new KeyboardState each time the input states are updated. - //Therefore, we create a static one and update it each time an update is requested. + // It's a waste of memory to create a new KeyboardState each time the input states are updated. + // Therefore, we create a static one and update it each time an update is requested. static KeyboardState result; - //Initializes the KeyboardState class + // Initializes the KeyboardState class KeyboardState::KeyboardState() { KeyboardState(null); } - //Initializes the KeyboardState class with the specified keys pressed + // Initializes the KeyboardState class with the specified keys pressed KeyboardState::KeyboardState(Keys_t keys[]) { if (keys == null) @@ -70,7 +70,7 @@ namespace XFX return (Keys_t*)pressedKeys; } - //Returns whether the specified key is currently pressed + // Returns whether the specified key is currently pressed bool KeyboardState::IsKeyDown(Keys_t key) { if(XInputGetKeystroke(&Stroke) == 0) @@ -85,7 +85,7 @@ namespace XFX return -1; } - //Returns whether the specified key is NOT pressed + // Returns whether the specified key is NOT pressed bool KeyboardState::IsKeyUp(Keys_t key) { if(XInputGetKeystroke(&Stroke) == 0) @@ -96,11 +96,11 @@ namespace XFX } return false; } - //The keyboard was not connected...bail out. + // The keyboard was not connected...bail out. return -1; } - //Gets the state of the keyboard + // Gets the state of the keyboard KeyboardState Keyboard::GetState() { return result; diff --git a/src/libXFX/Mouse.cpp b/src/libXFX/Mouse.cpp index f09564f..9ffcf5b 100644 --- a/src/libXFX/Mouse.cpp +++ b/src/libXFX/Mouse.cpp @@ -44,14 +44,14 @@ namespace XFX static MouseState result; /* MouseState Operators */ - bool MouseState::operator!=(const MouseState other) + bool MouseState::operator!=(const MouseState& other) const { return !((LeftButton == other.LeftButton) && (MiddleButton == other.MiddleButton) && (RightButton == other.RightButton) && (X == other.X) && (XButton1 == other.XButton1) && (XButton2 == other.XButton2) && (Y == other.Y)); } - bool MouseState::operator==(const MouseState other) + bool MouseState::operator==(const MouseState& other) const { return ((LeftButton == other.LeftButton) && (MiddleButton == other.MiddleButton) && (RightButton == other.RightButton) && (X == other.X) && (XButton1 == other.XButton1) && @@ -61,10 +61,10 @@ namespace XFX MouseState Mouse::GetState() { - result.X +=XMOUSE_current.x; - result.Y +=XMOUSE_current.y; - XMOUSE_current.x=0; - XMOUSE_current.y=0; + result.X += XMOUSE_current.x; + result.Y += XMOUSE_current.y; + XMOUSE_current.x = 0; + XMOUSE_current.y = 0; if((XMOUSE_current.buttons & XMOUSE_BUTTON_1)) result.LeftButton = ButtonState::Pressed; diff --git a/src/libXFX/PacketReader.cpp b/src/libXFX/PacketReader.cpp index 6320d96..b089ac0 100644 --- a/src/libXFX/PacketReader.cpp +++ b/src/libXFX/PacketReader.cpp @@ -25,6 +25,7 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. +#include #include #include #include @@ -41,23 +42,23 @@ namespace XFX return (int)BaseStream()->Length(); } - int PacketReader::Position() + int PacketReader::getPosition() { return (int)BaseStream()->Position; } - int PacketReader::Position(int newValue) + void PacketReader::setPosition(int newValue) { BaseStream()->Position = newValue; } PacketReader::PacketReader() - : BinaryReader(MemoryStream(0)) + : BinaryReader(new MemoryStream(0)) { } PacketReader::PacketReader(int capacity) - : BinaryReader(MemoryStream(capacity)) + : BinaryReader(new MemoryStream(capacity)) { } @@ -85,39 +86,39 @@ namespace XFX Quaternion PacketReader::ReadQuaternion() { - Quaternion quaternion; - quaternion.X = ReadSingle(); - quaternion.Y = ReadSingle(); - quaternion.Z = ReadSingle(); - quaternion.W = ReadSingle(); - return quaternion; + return Quaternion( + ReadSingle(), + ReadSingle(), + ReadSingle(), + ReadSingle() + ); } Vector2 PacketReader::ReadVector2() { - Vector2 vector2; - vector2.X = ReadSingle(); - vector2.Y = ReadSingle(); - return vector2; + return Vector2( + ReadSingle(), + ReadSingle() + ); } Vector3 PacketReader::ReadVector3() { - Vector3 vector3; - vector3.X = ReadSingle(); - vector3.Y = ReadSingle(); - vector3.Z = ReadSingle(); - return vector3; + return Vector3( + ReadSingle(), + ReadSingle(), + ReadSingle() + ); } Vector4 PacketReader::ReadVector4() { - Vector4 vector4; - vector4.X = ReadSingle(); - vector4.Y = ReadSingle(); - vector4.Z = ReadSingle(); - vector4.W = ReadSingle(); - return vector4; + return Vector4( + ReadSingle(), + ReadSingle(), + ReadSingle(), + ReadSingle() + ); } } } diff --git a/src/libXFX/PacketWriter.cpp b/src/libXFX/PacketWriter.cpp index b66dd18..aa02328 100644 --- a/src/libXFX/PacketWriter.cpp +++ b/src/libXFX/PacketWriter.cpp @@ -40,76 +40,76 @@ namespace XFX { int PacketWriter::Length() { - return (int)BaseStream.Length; + return (int)BaseStream()->Length(); } int PacketWriter::Position() { - return (int)BaseStream.Position; + return (int)BaseStream()->Position; } void PacketWriter::Position(int newValue) { - BaseStream.Position = newValue); + BaseStream()->Position = newValue; } PacketWriter::PacketWriter() - : BinaryWriter(MemoryStream(0)) + : BinaryWriter(new MemoryStream(0)) { } PacketWriter::PacketWriter(int capacity) - : BinaryWriter(MemoryStream(capacity)) + : BinaryWriter(new MemoryStream(capacity)) { } void PacketWriter::Write(Matrix value) { - Write(value.M11); - Write(value.M12); - Write(value.M13); - Write(value.M14); - Write(value.M21); - Write(value.M22); - Write(value.M23); - Write(value.M24); - Write(value.M31); - Write(value.M32); - Write(value.M33); - Write(value.M34); - Write(value.M41); - Write(value.M42); - Write(value.M43); - Write(value.M44); + BinaryWriter::Write(value.M11); + BinaryWriter::Write(value.M12); + BinaryWriter::Write(value.M13); + BinaryWriter::Write(value.M14); + BinaryWriter::Write(value.M21); + BinaryWriter::Write(value.M22); + BinaryWriter::Write(value.M23); + BinaryWriter::Write(value.M24); + BinaryWriter::Write(value.M31); + BinaryWriter::Write(value.M32); + BinaryWriter::Write(value.M33); + BinaryWriter::Write(value.M34); + BinaryWriter::Write(value.M41); + BinaryWriter::Write(value.M42); + BinaryWriter::Write(value.M43); + BinaryWriter::Write(value.M44); } void PacketWriter::Write(Quaternion value) { - Write(value.X); - Write(value.Y); - Write(value.Z); - Write(value.W); + BinaryWriter::Write(value.X); + BinaryWriter::Write(value.Y); + BinaryWriter::Write(value.Z); + BinaryWriter::Write(value.W); } void PacketWriter::Write(Vector2 value) { - Write(value.X); - Write(value.Y); + BinaryWriter::Write(value.X); + BinaryWriter::Write(value.Y); } void PacketWriter::Write(Vector3 value) { - Write(value.X); - Write(value.Y); - Write(value.Z); + BinaryWriter::Write(value.X); + BinaryWriter::Write(value.Y); + BinaryWriter::Write(value.Z); } void PacketWriter::Write(Vector4 value) { - Write(value.X); - Write(value.Y); - Write(value.Z); - Write(value.W); + BinaryWriter::Write(value.X); + BinaryWriter::Write(value.Y); + BinaryWriter::Write(value.Z); + BinaryWriter::Write(value.W); } } } diff --git a/src/libXFX/VideoPlayer.cpp b/src/libXFX/VideoPlayer.cpp index db973d7..88d99df 100644 --- a/src/libXFX/VideoPlayer.cpp +++ b/src/libXFX/VideoPlayer.cpp @@ -70,7 +70,7 @@ namespace XFX { } - void VideoPlayer::Play(Video* video) + void VideoPlayer::Play(Video * const video) { } diff --git a/src/libmscorlib/DirectoryInfo.cpp b/src/libmscorlib/DirectoryInfo.cpp index cf5b2b3..27fd109 100644 --- a/src/libmscorlib/DirectoryInfo.cpp +++ b/src/libmscorlib/DirectoryInfo.cpp @@ -81,7 +81,7 @@ namespace System DirectoryInfo* DirectoryInfo::GetDirectories(const String& searchPattern) { - sassert(searchPattern != null, String::Format("searchPattern; %s", FrameworkResources::ArgumentNull_Generic)); + sassert(!String::IsNullOrEmpty(searchPattern), String::Format("searchPattern; %s", FrameworkResources::ArgumentNull_Generic)); List infos = List(); diff --git a/src/libmscorlib/TextWriter.cpp b/src/libmscorlib/TextWriter.cpp index afe8fff..e18faa1 100644 --- a/src/libmscorlib/TextWriter.cpp +++ b/src/libmscorlib/TextWriter.cpp @@ -34,13 +34,13 @@ namespace System const char* TextWriter::InitialNewLine = "\r\n"; TextWriter::TextWriter() { - CoreNewLine = new char[] { '\r', '\n' }; + CoreNewLine = { '\r', '\n' }; InternalFormatProvider = null; } - TextWriter::TextWriter(IFormatProvider* provider) + TextWriter::TextWriter(IFormatProvider * const provider) { - CoreNewLine = new char[] { '\r', '\n' }; + CoreNewLine = { '\r', '\n' }; InternalFormatProvider = provider; } @@ -61,7 +61,6 @@ namespace System { Write(buffer, 0, Array::Length(buffer)); } - } } }