1
0
mirror of https://github.com/Halofreak1990/XFXFramework synced 2024-12-26 13:49:34 +01:00

Fixed TextureCollection issues caused by circular dependencies.

Added RenderTarget and RenderTarget2D classes to the XFX::Graphics namespace
Added Internal StorageDeviceAsyncResult class to the XFX::Storage namespace to aid in the implementation of the Guide.
Added Guide::BeginShowMessageBox and Guide::EndShowMessageBox methods
Began fixing comments to properly show up in IntelliSense
This commit is contained in:
Halofreak1990 2011-06-09 12:57:16 +00:00
parent 22893b5c47
commit ec0c1820dd
34 changed files with 758 additions and 263 deletions

View File

@ -11,9 +11,6 @@ namespace XFX
{
namespace Audio
{
/// <summary>
/// Controls how Cue objects should stop when Cue.Stop is called.
/// </summary>
struct AudioStopOptions
{
enum type
@ -23,8 +20,8 @@ namespace XFX
};
};
typedef AudioStopOptions::type AudioStopOptions_t;
typedef AudioStopOptions::type AudioStopOptions_t; // Controls how Cue objects should stop when Cue::Stop is called.
}
}
#endif //XFRAMEWORK_AUDIOSTOPOPTIONS_H
#endif //_XFX_AUDIO_ENUMS_

View File

@ -5,9 +5,6 @@ namespace XFX
{
namespace GamerServices
{
/// <summary>
/// Indicates how sensitive this gamer prefers controller input to be.
/// </summary>
struct ControllerSensitivity
{
enum type
@ -18,9 +15,6 @@ namespace XFX
};
};
/// <summary>
/// Indicates how difficult this gamer likes things to be.
/// </summary>
struct GameDifficulty
{
enum type
@ -31,9 +25,6 @@ namespace XFX
};
};
/// <summary>
/// This style of social gaming preferred by this Xbox Live member.
/// </summary>
struct GamerZone
{
enum type
@ -46,9 +37,6 @@ namespace XFX
};
};
/// <summary>
/// Defines the different icons for a message box.
/// </summary>
struct MessageBoxIcon
{
enum type
@ -60,9 +48,6 @@ namespace XFX
};
};
/// <summary>
/// Determines where notifications appear on the screen.
/// </summary>
struct NotificationPosition
{
enum type
@ -79,9 +64,6 @@ namespace XFX
};
};
/// <summary>
/// Indicates which camera angle this gamer prefers to use in racing games.
/// </summary>
struct RacingCameraAngle
{
enum type
@ -92,12 +74,12 @@ namespace XFX
};
};
typedef ControllerSensitivity::type ControllerSensitivity_t;
typedef GameDifficulty::type GameDifficulty_t;
typedef GamerZone::type GamerZone_t;
typedef MessageBoxIcon::type MessageBoxIcon_t;
typedef NotificationPosition::type NotificationPosition_t;
typedef RacingCameraAngle::type RacingCameraAngle_t;
typedef ControllerSensitivity::type ControllerSensitivity_t; // Indicates how sensitive this gamer prefers controller input to be.
typedef GameDifficulty::type GameDifficulty_t; // Indicates how difficult this gamer likes things to be.
typedef GamerZone::type GamerZone_t; // This style of social gaming preferred by this Xbox Live member.
typedef MessageBoxIcon::type MessageBoxIcon_t; // Defines the different icons for a message box.
typedef NotificationPosition::type NotificationPosition_t; // Determines where notifications appear on the screen.
typedef RacingCameraAngle::type RacingCameraAngle_t; // Indicates which camera angle this gamer prefers to use in racing games.
}
}

View File

@ -7,13 +7,16 @@
#ifndef _XFX_GAMERSERVICES_GUIDE_
#define _XFX_GAMERSERVICES_GUIDE_
#include <System/Collections/Generic/Interfaces.h>
#include <System/Delegates.h>
#include <System/Interfaces.h>
#include <System/TimeSpan.h>
#include <System/Types.h>
#include <Storage/StorageDevice.h>
#include "Enums.h"
using namespace System;
using namespace System::Collections::Generic;
using namespace XFX::Storage;
namespace XFX
@ -32,16 +35,19 @@ namespace XFX
Guide();
public:
static bool IsScreenSaverEnabled();
static bool IsScreenSaverEnabled;
static bool IsVisible();
static NotificationPosition_t notificationPosition;
static NotificationPosition_t NotificationPosition;
static IAsyncResult* BeginShowKeyboardInput(PlayerIndex_t player, char* title, char* description, char* defaultText, AsyncCallback callback, Object* state);
static IAsyncResult* BeginShowMessageBox(PlayerIndex_t player, char* title, char* text, IEnumerable<char*>* buttons, int focusButton, MessageBoxIcon_t icon, AsyncCallback callback, Object* state);
static IAsyncResult* BeginShowStorageDeviceSelector(int sizeInBytes, int directoryCount, AsyncCallback callback, Object* state);
static IAsyncResult* BeginShowStorageDeviceSelector(AsyncCallback callback, Object* state);
static IAsyncResult* BeginShowStorageDeviceSelector(PlayerIndex_t player, int sizeInBytes, int directoryCount, AsyncCallback callback, Object* state);
static IAsyncResult* BeginShowStorageDeviceSelector(PlayerIndex_t player, AsyncCallback callback, Object* state);
static void DelayNotifications(TimeSpan timespan);
static char* EndShowKeyboardInput(IAsyncResult* result);
static int EndShowMessageBox(IAsyncResult* result);
static StorageDevice EndShowStorageDeviceSelector(IAsyncResult* result);
};
}

View File

@ -0,0 +1,33 @@
#include <System/Interfaces.h>
#include <System/Threading/WaitHandle.h>
using namespace System;
using namespace System::Threading;
namespace XFX
{
namespace GamerServices
{
class Guide;
class StorageDeviceAsyncResult : public IAsyncResult
{
friend class Guide;
private:
Object* syncObject;
int playerIndex;
StorageDeviceAsyncResult(Object* stateObject, int player);
StorageDeviceAsyncResult(const StorageDeviceAsyncResult &obj);
StorageDeviceAsyncResult(IAsyncResult* &obj);
public:
Object* AsyncState();
bool CompletedSynchronously();
bool IsCompleted();
WaitHandle* AsyncWaitHandle();
};
}
}

View File

@ -15,6 +15,7 @@
#include "GraphicsDeviceCapabilities.h"
#include "GraphicsDeviceCreationParameters.h"
#include "PresentationParameters.h"
#include "RenderTarget2D.h"
#include "TextureCollection.h"
#include "Viewport.h"
@ -34,10 +35,10 @@ namespace XFX
/// Performs primitive-based rendering, creates resources, handles system-level
/// variables, adjusts gamma ramp levels, and creates shaders.
/// </summary>
class GraphicsDevice : public IDisposable
class GraphicsDevice : public IDisposable, virtual Object
{
private:
GraphicsAdapter _adapter;
GraphicsAdapter* _adapter;
DepthStencilBuffer _depthStencilBuffer;
DeviceType_t _deviceType;
GraphicsDeviceCapabilities graphicsDeviceCapabilities;
@ -45,19 +46,31 @@ namespace XFX
TextureCollection textures;
Color clearColor;
Viewport viewport;
void setPresentationParameters(PresentationParameters* presentationParameters);
protected:
virtual void Dispose(bool disposing);
virtual void raise_DeviceLost(Object* sender, EventArgs e);
virtual void raise_DeviceReset(Object* sender, EventArgs e);
virtual void raise_DeviceResetting(Object* sender, EventArgs e);
virtual void raise_Disposing(Object* sender, EventArgs e);
public:
EventHandler DeviceLost;
EventHandler DeviceReset;
EventHandler DeviceResetting;
EventHandler Disposing;
GraphicsDeviceCreationParameters CreationParameters();
DepthStencilBuffer GetDepthStencilBuffer();
void SetDepthStencilBuffer(DepthStencilBuffer buffer);
DepthStencilBuffer getDepthStencilBuffer();
void setDepthStencilBuffer(DepthStencilBuffer buffer);
PresentationParameters* getPresentationParameters();
TextureCollection Textures();
Viewport Viewport_();
void Viewport_(Viewport newValue);
Viewport getViewport();
void setViewport(Viewport value);
GraphicsDevice(GraphicsAdapter adapter, DeviceType_t deviceType, PresentationParameters presentationParameters);
GraphicsDevice(GraphicsAdapter* adapter, DeviceType_t deviceType, PresentationParameters* presentationParameters);
GraphicsDevice();
virtual ~GraphicsDevice();
@ -76,7 +89,7 @@ namespace XFX
template <class T>
void DrawUserPrimitives(PrimitiveType_t primitiveType, T vertexData[], int vertexOffset, int primitiveCount);
void EvictManagedResources();
GammaRamp GetGammaRamp();
GammaRamp* GetGammaRamp();
int* GetPixelShaderBooleanConstant(int startRegister, int constantCount);
int* GetPixelShaderInt32Constant(int startRegister, int constantCount);
Matrix* GetPixelShaderMatrixArrayConstant(int startRegister, int constantCount);
@ -86,6 +99,11 @@ namespace XFX
float* GetPixelShaderSingleConstant(int startRegister, int constantCount);
Vector2* GetPixelShaderVector2ArrayConstant(int startRegister, int constantCount);
Vector2 GetPixelShaderVector2Constant(int startRegister);
void Present();
void Reset();
void Reset(PresentationParameters* presentationParameters);
void SetGammaRamp(bool calibrate, GammaRamp* ramp);
void SetRenderTarget(int renderTargetIndex, RenderTarget2D* renderTarget);
void SetVertexShaderConstant(int startRegister, Matrix constantData);
void SetVertexShaderConstant(int startRegister, Vector4 constantData);
};

View File

@ -0,0 +1,62 @@
/********************************************************
* RenderTarget.h *
* *
* XFX RenderTarget definition file *
* Copyright © XFX Team. All Rights Reserved *
********************************************************/
#ifndef _XFX_GRAPHICS_RENDERTARGET_
#define _XFX_GRAPHICS_RENDERTARGET_
#include <System/Interfaces.h>
#include <System/Types.h>
#include "Enums.h"
using namespace System;
namespace XFX
{
namespace Graphics
{
class RenderTarget : public IDisposable, virtual Object
{
private:
bool isContentLost;
bool isDisposed;
protected:
GraphicsDevice* graphicsDevice;
SurfaceFormat_t format;
int width;
int height;
int multiSampleQuality;
MultiSampleType_t multiSampleType;
RenderTargetUsage_t renderTargetUsage;
int numLevels;
virtual void Dispose(bool disposing);
virtual void raise_ContentLost(Object* sender, EventArgs e);
void raise_Disposing(Object* sender, EventArgs e);
public:
SurfaceFormat_t getFormat();
GraphicsDevice* getGraphicsDevice();
int Height();
bool IsContentLost();
bool IsDisposed();
int MultiSampleQuality();
MultiSampleType_t getMultiSampleType();
char* Name;
Object* Tag;
int Width();
EventHandler ContentLost;
EventHandler Disposing;
virtual ~RenderTarget();
void Dispose();
};
}
}
#endif //_XFX_GRAPHICS_RENDERTARGET_

View File

@ -0,0 +1,43 @@
/********************************************************
* RenderTarget2D.h *
* *
* XFX RenderTarget2D definition file *
* Copyright © XFX Team. All Rights Reserved *
********************************************************/
#ifndef _XFX_GRAPHICS_RENDERTARGET2D_
#define _XFX_GRAPHICS_RENDERTARGET2D_
#include <System/Types.h>
#include "RenderTarget.h"
//#include "Texture2D.h"
using namespace System;
namespace XFX
{
namespace Graphics
{
class GraphicsDevice;
class Texture2D;
class RenderTarget2D : public RenderTarget, virtual Object
{
private:
Texture2D* texture;
int renderBufferIdentifier;
protected:
void Dispose(bool disposing);
public:
RenderTarget2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, SurfaceFormat_t format);
RenderTarget2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, SurfaceFormat_t format, MultiSampleType_t multiSampleType, int multiSampleQuality);
RenderTarget2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, SurfaceFormat_t format, RenderTargetUsage_t usage);
RenderTarget2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, SurfaceFormat_t format, MultiSampleType_t multiSampleType, int multiSampleQuality, RenderTargetUsage_t usage);
Texture2D* GetTexture();
};
}
}
#endif //_XFX_GRAPHICS_RENDERTARGET2D_

View File

@ -9,6 +9,7 @@
#include "Texture.h"
#include <System/IO/Stream.h>
#include <System/Types.h>
using namespace System;
using namespace System::IO;
@ -47,7 +48,7 @@ namespace XFX
Texture2D();
Texture2D(GraphicsDevice* graphicsDevice, int width, int height);
Texture2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, TextureUsage_t usage, SurfaceFormat_t format);
Texture2D(const Texture2D &obj);
Texture2D(const Texture2D &obj); // Copy constructor
static Texture2D* FromFile(GraphicsDevice* graphicsDevice, Stream* textureStream);
static Texture2D* FromFile(GraphicsDevice* graphicsDevice, Stream* textureStream, TextureCreationParameters creationParameters);

View File

@ -8,16 +8,15 @@
#define _XFX_GRAPHICS_TEXTURECOLLECTION_
#include <System/Collections/Generic/List.h>
#include "Texture.h"
using namespace System::Collections::Generic;
namespace XFX
{
class Texture;
namespace Graphics
{
class Texture;
/// <summary>
/// Represents a collection of Texture objects.
/// </summary>
@ -26,13 +25,14 @@ namespace XFX
private:
bool disposed;
List<Texture*> textures;
void Dispose();
void Dispose(bool disposing);
public:
TextureCollection();
~TextureCollection();
void Dispose();
Texture* operator[](int index);
};
}

View File

@ -31,8 +31,13 @@ namespace XFX
int X;
int Y;
bool Equals(Viewport obj);
int GetHashCode();
Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world);
Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world);
bool operator !=(Viewport right);
bool operator ==(Viewport right);
};
}
}

View File

@ -11,9 +11,6 @@ namespace XFX
{
namespace Net
{
/// <summary>
/// Defines the reason a session ended.
/// </summary>
struct NetworkSessionEndReason
{
enum type
@ -24,9 +21,7 @@ namespace XFX
Disconnected
};
};
/// <summary>
/// Contains additional data about a NetworkSessionJoinException.
/// </summary>
struct NetworkSessionJoinError
{
enum type
@ -36,9 +31,7 @@ namespace XFX
SessionFull
};
};
/// <summary>
/// Defines the different states of a multiplayer session.
/// </summary>
struct NetworkSessionState
{
enum type
@ -48,9 +41,7 @@ namespace XFX
Ended
};
};
/// <summary>
/// Defines the different types of a multiplayer session.
/// </summary>
struct NetworkSessionType
{
enum type
@ -62,9 +53,6 @@ namespace XFX
};
};
/// <summary>
/// Defines options for network packet transmission.
/// </summary>
struct SendDataOptions
{
enum type
@ -76,11 +64,11 @@ namespace XFX
};
};
typedef NetworkSessionEndReason::type NetworkSessionEndReason_t;
typedef NetworkSessionJoinError::type NetworkSessionJoinError_t;
typedef NetworkSessionState::type NetworkSessionState_t;
typedef NetworkSessionType::type NetworkSessionType_t;
typedef SendDataOptions::type SendDataOptions_t;
typedef NetworkSessionEndReason::type NetworkSessionEndReason_t; // Defines the reason a session ended.
typedef NetworkSessionJoinError::type NetworkSessionJoinError_t; // Contains additional data about a NetworkSessionJoinException.
typedef NetworkSessionState::type NetworkSessionState_t; // Defines the different states of a multiplayer session.
typedef NetworkSessionType::type NetworkSessionType_t; // Defines the different types of a multiplayer session.
typedef SendDataOptions::type SendDataOptions_t; // Defines options for network packet transmission.
}
}

View File

@ -15,10 +15,8 @@ namespace XFX
namespace Net
{
/// <summary>
/// Provides common functionality for efficiently reading incoming network packets.
/// </summary>
class PacketReader : public BinaryReader
// Provides common functionality for efficiently reading incoming network packets.
class PacketReader : public BinaryReader, virtual Object
{
public:
int Length();

View File

@ -26,11 +26,12 @@ namespace XFX
/// </summary>
class StorageContainer : public IDisposable, virtual Object
{
friend class StorageDevice;
private:
bool isDisposed;
DirectoryInfo containerFolder;
StorageDevice* device;
EventHandler Disposing;
PlayerIndex_t playerIndex;
char* titleName;
@ -38,9 +39,11 @@ namespace XFX
~StorageContainer();
public:
EventHandler Disposing;
bool IsDisposed();
char* Path();
StorageDevice StorageDevice_();
StorageDevice* StorageDevice_();
static char* TitleLocation();
char* TitleName();

View File

@ -8,10 +8,18 @@
#define _XFX_STORAGE_STORAGEDEVICE_
#include <System/Types.h>
#include <System/Object.h>
#include "../Enums.h"
using namespace System;
namespace XFX
{
namespace GamerServices
{
class Guide;
}
namespace Storage
{
class StorageContainer;
@ -19,13 +27,15 @@ namespace XFX
/// <summary>
/// Represents a storage device for user data, such as a memory unit or hard drive.
/// </summary>
class StorageDevice
class StorageDevice : virtual Object
{
friend class XFX::GamerServices::Guide;
private:
PlayerIndex_t _playerIndex;
bool _playerSpecified;
uint _deviceIndex;
StorageDevice(PlayerIndex_t playerIndex, bool playerSpecified);
StorageDevice(uint deviceIndex, PlayerIndex_t playerIndex);
public:
long long FreeSpace();

View File

@ -9,9 +9,7 @@
#include <System/Array.h>
#include <System/Exception.h>
#include <System/Collections/Generic/Dictionary.h>
#include <System/Collections/Generic/EqualityComparer.h>
#include "HashHelpers.h"
#include "EqualityComparer.h"
#include "Interfaces.h"
#include "KeyValuePair.h"
@ -70,66 +68,16 @@ namespace System
Dictionary<TKey, TValue>* _dictionary;
public:
int Count()
{
return _dictionary.Count();
}
int Count();
KeyCollection(Dictionary<TKey, TValue> dictionary)
{
_dictionary = &dictionary;
}
KeyCollection(Dictionary<TKey, TValue> dictionary);
KeyCollection(const KeyCollection<UKey, UValue> &obj);
KeyCollection(const KeyCollection<UKey, UValue> &obj)
{
_dictionary = &obj._dictionary;
}
void Add(UKey item)
{
throw NotSupportedException("Adding keys directly to the Dictionary::Keycollection is not supported.");
}
void Clear()
{
throw NotSupportedException("Directly clearing the Dictionary::KeyCollection is not supported.");
}
bool Contains(UKey item)
{
return _dictionary.ContainsKey(item);
}
void CopyTo(UKey array[], int index)
{
if(array == null)
{
throw ArgumentNullException("array");
}
if((index < 0) ||(index > Array::Length(array)))
{
throw ArgumentOutOfRangeException("index", "Non-negative array index required.");
}
if((Array::Length(array) - index) < _dictionary.Count())
{
throw ArgumentException("Array plus offset too small.");
}
int count = _dictionary.Count();
Entry<UKey, UValue> entries[] = _dictionary.entries;
for(int i = 0; i < count; i++)
{
if(entries[i].hashCode >= 0)
{
array[index++] = entries[i].key;
}
}
}
bool Remove(UKey item)
{
throw NotSupportedException("Removing keys directly from the Dictionary::KeyCollection is not supported.");
return false;
}
void Add(UKey item);
void Clear();
bool Contains(UKey item);
void CopyTo(UKey array[], int index);
bool Remove(UKey item);
};
/// <summary>
@ -174,82 +122,171 @@ namespace System
}*/
}
Dictionary(int capacity);
~Dictionary()
{
delete[] buckets;
delete[] entries;
}
~Dictionary();
void Add(TKey key, TValue value)
{
Insert(key, value, true);
}
void Clear()
{
if(count > 0)
{
for(int i = 0; i < Array::Length(buckets); i++)
{
buckets[i] = -1;
}
Array::Clear(entries, 0, count);
freeList = -1;
count = 0;
freeCount = 0;
version++;
}
}
void Clear();
bool ContainsKey(TKey key);
bool ContainsValue(TValue value);
bool Remove(TKey key)
{
if(buckets)
{
int num = comparer->GetHashCode(key) & 0x7fffffff;
int index = num % Array::Length(buckets);
int num3 = -1;
for(int i = buckets[index]; i >= 0; i = entries[i].next)
{
if((entries[i].hashCode == num) && comparer->Equals(entries[i].key, key))
{
if(num3 < 0)
{
buckets[index] = entries[i].next;
}
else
{
entries[num3].next = entries[i].next;
}
entries[i].hashCode = -1;
entries[i].next = freeList;
entries[i].key = TKey();
entries[i].value = TValue();
freeList = i;
freeCount++;
version++;
return true;
}
num3 = i;
}
}
return false;
}
bool Remove(TKey key);
bool TryGetValue(TKey key, out TValue value);
};
bool TryGetValue(TKey key, out TValue value)
//////////////////////////////////////////////////////////////////////
template <class TKey, class TValue>
template <class UKey, class UValue>
int Dictionary<TKey, TValue>::KeyCollection<UKey, UValue>::Count()
{
return _dictionary->Count();
}
template <class TKey, class TValue>
template <class UKey, class UValue>
Dictionary<TKey, TValue>::KeyCollection<UKey, UValue>::KeyCollection(Dictionary<TKey, TValue> dictionary)
{
_dictionary = &dictionary;
}
template <class TKey, class TValue>
template <class UKey, class UValue>
Dictionary<TKey, TValue>::KeyCollection<UKey, UValue>::KeyCollection(const KeyCollection<UKey, UValue> &obj)
{
_dictionary = obj._dictionary;
}
template <class TKey, class TValue>
template <class UKey, class UValue>
void Dictionary<TKey, TValue>::KeyCollection<UKey, UValue>::Add(UKey item)
{
throw NotSupportedException("Adding keys directly to the Dictionary::Keycollection is not supported.");
}
template <class TKey, class TValue>
template <class UKey, class UValue>
void Dictionary<TKey, TValue>::KeyCollection<UKey, UValue>::Clear()
{
throw NotSupportedException("Directly clearing the Dictionary::KeyCollection is not supported.");
}
template <class TKey, class TValue>
template <class UKey, class UValue>
bool Dictionary<TKey, TValue>::KeyCollection<UKey, UValue>::Contains(UKey item)
{
return _dictionary.ContainsKey(item);
}
template <class TKey, class TValue>
template <class UKey, class UValue>
void Dictionary<TKey, TValue>::KeyCollection<UKey, UValue>::CopyTo(UKey array[], int index)
{
if(array == null)
{
int index = FindEntry(key);
if(index >= 0)
{
value = entries[index].value;
return true;
}
value = TValue();
return false;
throw ArgumentNullException("array");
}
};
if((index < 0) ||(index > Array::Length(array)))
{
throw ArgumentOutOfRangeException("index", "Non-negative array index required.");
}
if((Array::Length(array) - index) < _dictionary.Count())
{
throw ArgumentException("Array plus offset too small.");
}
int count = _dictionary.Count();
Entry<UKey, UValue> entries[] = _dictionary.entries;
for(int i = 0; i < count; i++)
{
if(entries[i].hashCode >= 0)
{
array[index++] = entries[i].key;
}
}
}
template <class TKey, class TValue>
template <class UKey, class UValue>
bool Dictionary<TKey, TValue>::KeyCollection<UKey, UValue>::Remove(UKey item)
{
throw NotSupportedException("Removing keys directly from the Dictionary::KeyCollection is not supported.");
return false;
}
template <class TKey, class TValue>
Dictionary<TKey, TValue>::~Dictionary()
{
delete[] buckets;
delete[] entries;
}
template <class TKey, class TValue>
void Dictionary<TKey, TValue>::Clear()
{
if(count > 0)
{
for(int i = 0; i < Array::Length(buckets); i++)
{
buckets[i] = -1;
}
Array::Clear(entries, 0, count);
freeList = -1;
count = 0;
freeCount = 0;
version++;
}
}
template <class TKey, class TValue>
bool Dictionary<TKey, TValue>::Remove(TKey key)
{
if(buckets)
{
int num = comparer->GetHashCode(key) & 0x7fffffff;
int index = num % Array::Length(buckets);
int num3 = -1;
for(int i = buckets[index]; i >= 0; i = entries[i].next)
{
if((entries[i].hashCode == num) && comparer->Equals(entries[i].key, key))
{
if(num3 < 0)
{
buckets[index] = entries[i].next;
}
else
{
entries[num3].next = entries[i].next;
}
entries[i].hashCode = -1;
entries[i].next = freeList;
entries[i].key = TKey();
entries[i].value = TValue();
freeList = i;
freeCount++;
version++;
return true;
}
num3 = i;
}
}
return false;
}
template <class TKey, class TValue>
bool Dictionary<TKey, TValue>::TryGetValue(TKey key, out TValue value)
{
int index = FindEntry(key);
if(index >= 0)
{
value = entries[index].value;
return true;
}
value = TValue();
return false;
}
}
}
}

View File

@ -54,8 +54,8 @@ namespace System
virtual bool Remove(TKey key)=0;
virtual bool TryGetValue(TKey key, out TValue value)=0;
virtual ICollection<TKey> Keys()=0;
virtual ICollection<TValue> Values()=0;
virtual ICollection<TKey>& Keys()=0;
virtual ICollection<TValue>& Values()=0;
};
/// <summary>
@ -75,7 +75,7 @@ namespace System
interface IEnumerable
{
public:
virtual IEnumerator<T> GetEnumerator()=0;
virtual IEnumerator<T>& GetEnumerator()=0;
};
/// <summary>

View File

@ -334,7 +334,7 @@ namespace System
if (other._size == 0) // is other array is empty -- clear this array
Clear();
Capacity(other._size); // set size
setCapacity(other._size); // set size
memcpy(_items, other._items, sizeof(T) * other._size);

View File

@ -9,6 +9,7 @@
#include "../Exception.h"
#include "../Interfaces.h"
#include "../Object.h"
#include "../Types.h"
#include "../Threading/WaitHandle.h"
@ -19,7 +20,7 @@ namespace System
/// <summary>
///
/// </summary>
class StreamAsyncResult : public IAsyncResult
class StreamAsyncResult : public IAsyncResult, virtual Object
{
Object* _state;
bool completed;
@ -29,7 +30,7 @@ namespace System
public:
Object* ASyncState();
Threading::WaitHandle AsyncWaitHandle();
Threading::WaitHandle* AsyncWaitHandle();
virtual bool CompletedSynchronously();
bool IsCompleted();
Exception* Exception_();

View File

@ -19,8 +19,8 @@ namespace System
interface IAsyncResult
{
public:
virtual Object* ASyncState()=0;
virtual Threading::WaitHandle AsyncWaitHandle()=0;
virtual Object* AsyncState()=0;
virtual Threading::WaitHandle* AsyncWaitHandle()=0;
virtual bool CompletedSynchronously()=0;
virtual bool IsCompleted()=0;
};

View File

@ -129,6 +129,10 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\makefile"
>
</File>
</Files>
<Globals>
</Globals>

49
src/libSystem/makefile Normal file
View File

@ -0,0 +1,49 @@
#
# update this variable to wherever you installed the OpenXDK libraries
#
#########################################################################
PREFIX = /usr/local/openxdk
CC = gcc
CCAS = gcc
CPP = g++
AR = ar rcu
RANLIB = ranlib
CXBE = $(PREFIX)/bin/cxbe
SDLFLAGS = -DENABLE_XBOX -DDEBUG
CC_FLAGS = -c -g -std=gnu99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -mno-cygwin -march=i386 -mmmx -msse -mfpmath=sse $(SDLFLAGS)
CCAS_FLAGS = --32 -march=pentiumiii, mmx, sse -mtune=pentiumiii -msse-check=error
CPP_FLAGS = -c -O2 -Wall -nostdlib -fno-builtin -mno-cygwin -march=i386 -mmmx -msse -mfpmath=sse $(SDLFLAGS)
INCLUDE = -I$(PREFIX)/i386-pc-xbox/include -I$(PREFIX)/include -I$(PREFIX)/include/SDL -I../../include
CLINK = -nostdlib
ALIGN = -Wl,--file-alignment,0x20 -Wl,--section-alignment,0x20
SHARED = -shared
ENTRYPOINT = -Wl,--entry,_WinMainCRTStartup
STRIP = -Wl,--strip-all
LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP)
LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib
LD_LIBS = $(LD_DIRS) -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lstdc++ -lgcc
OBJS =
all: libSystem.a
rebuild: clean libSystem.a
libSystem.a: $(OBJS)
$(AR) $@ $(OBJS)
$(RANLIB) $@
.c.o:
$(CC) -c $< $(CC_FLAGS) $(INCLUDE)
.cpp.o:
$(CPP) -c $< $(CPP_FLAGS) $(INCLUDE)
.s.o:
$(CCAS) -c $< $(CCAS_FLAGS)
clean:
rm -f *.o *.exe *.dll *.xbe *.cxbe *.lib *.a

View File

@ -44,13 +44,54 @@ namespace XFX
{
namespace Graphics
{
GraphicsDeviceCreationParameters GraphicsDevice::CreationParameters()
{
}
DepthStencilBuffer GraphicsDevice::getDepthStencilBuffer()
{
return _depthStencilBuffer;
}
void GraphicsDevice::setDepthStencilBuffer(DepthStencilBuffer buffer)
{
_depthStencilBuffer = buffer;
}
void GraphicsDevice::setPresentationParameters(PresentationParameters* presentationParameters)
{
viewport.X = 0;
viewport.Y = 0;
viewport.Width = presentationParameters->BackBufferWidth;
viewport.Height = presentationParameters->BackBufferHeight;
}
Viewport GraphicsDevice::getViewport()
{
return viewport;
}
void GraphicsDevice::setViewport(Viewport value)
{
if (viewport != value)
{
}
}
TextureCollection GraphicsDevice::Textures()
{
return textures;
}
GraphicsDevice::GraphicsDevice(GraphicsAdapter adapter, DeviceType_t deviceType, PresentationParameters presentationParameters)
GraphicsDevice::GraphicsDevice(GraphicsAdapter* adapter, DeviceType_t deviceType, PresentationParameters* presentationParameters)
{
if (adapter == null || presentationParameters == null)
throw new ArgumentNullException("adapter or presentationParameters is null.");
_adapter = adapter;
if(deviceType != DeviceType::Hardware)
throw DeviceNotSupportedException("Only DeviceType::Hardware is supported.");
@ -110,29 +151,6 @@ namespace XFX
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();*/
}
void GraphicsDevice::Clear(ClearOptions_t options, Color color, float depth, int stencil)
{
if(isDisposed)
throw ObjectDisposedException("GraphicsDevice");
switch(options)
{
case ClearOptions::Depth:
{
}
case ClearOptions::Stencil:
{
}
case ClearOptions::Target:
{
}
}
}
void GraphicsDevice::Dispose()
{
@ -141,15 +159,51 @@ namespace XFX
void GraphicsDevice::Dispose(bool disposing)
{
if(disposing)
if (!isDisposed)
{
if(disposing)
{
textures.Dispose();
isDisposed = true;
}
}
}
void GraphicsDevice::SetVertexShaderConstant(int startRegister, Vector4 constantData)
void GraphicsDevice::raise_DeviceLost(Object* sender, EventArgs e)
{
if (DeviceLost != null)
DeviceLost(sender, e);
}
void GraphicsDevice::raise_DeviceReset(Object* sender, EventArgs e)
{
if (DeviceReset != null)
DeviceReset(sender, e);
}
void GraphicsDevice::raise_DeviceResetting(Object* sender, EventArgs e)
{
if (DeviceResetting != null)
DeviceResetting(sender, e);
}
void GraphicsDevice::raise_Disposing(Object* sender, EventArgs e)
{
if (Disposing != null)
Disposing(sender, e);
}
void GraphicsDevice::Reset()
{
Reset(getPresentationParameters());
}
void GraphicsDevice::Reset(PresentationParameters* presentationParameters)
{
raise_DeviceResetting(this, EventArgs::Empty);
setPresentationParameters(presentationParameters);
raise_DeviceReset(this, EventArgs::Empty);
}
}
}

View File

@ -26,6 +26,8 @@
// POSSIBILITY OF SUCH DAMAGE.
#include <GamerServices/Guide.h>
#include <GamerServices/StorageDeviceAsyncResult.h>
#include <System/Exception.h>
#include <System/TimeSpan.h>
namespace XFX
@ -52,6 +54,12 @@ namespace XFX
return null;
}
IAsyncResult* Guide::BeginShowMessageBox(PlayerIndex_t player, char* title, char* text, IEnumerable<char*>* buttons, int focusButton, MessageBoxIcon_t icon, AsyncCallback callback, Object* state)
{
// just return null to stop warning until this thing's coded
return null;
}
IAsyncResult* Guide::BeginShowStorageDeviceSelector(int sizeInBytes, int directoryCount, AsyncCallback callback, Object* state)
{
// just return null to stop warning until this thing's coded
@ -82,8 +90,20 @@ namespace XFX
return "";
}
StorageDevice Guide::EndShowStorageDeviceSelector(IAsyncResult* result)
int Guide::EndShowMessageBox(IAsyncResult* result)
{
// Since C++ doesn't have a nullable type, we return -1, since it represents an invalid value anyways.
return -1;
}
StorageDevice Guide::EndShowStorageDeviceSelector(IAsyncResult* asyncResult)
{
StorageDeviceAsyncResult* result = (StorageDeviceAsyncResult*)asyncResult;
if (!result)
{
throw ArgumentNullException("result");
}
return StorageDevice(0, (PlayerIndex_t)result->playerIndex);
}
}
}

View File

@ -903,34 +903,35 @@ namespace XFX
int Matrix::Decompose(Vector3 scale, Quaternion rotation, Vector3 translation)
{
//Get the translation.
translation.X = M41;
translation.Y = M42;
translation.Z = M43;
//Scaling is the length of the rows.
scale.X = (float)Math::Sqrt((M11 * M11) + (M12 * M12) + (M13 * M13));
scale.Y = (float)Math::Sqrt((M21 * M21) + (M22 * M22) + (M23 * M23));
scale.Z = (float)Math::Sqrt((M31 * M31) + (M32 * M32) + (M33 * M33));
//If any of the scaling factors are zero, than the rotation matrix can not exist.
if (Math::Abs(scale.X) < 1e-6f ||
Math::Abs(scale.Y) < 1e-6f ||
Math::Abs(scale.Z) < 1e-6f)
float xs, ys, zs;
if (Math::Sign(M11 * M12 * M13 * M14) < 0)
xs = -1.0f;
else
xs = 1.0f;
if (Math::Sign(M21 * M22 * M23 * M24) < 0)
ys = -1.0f;
else
ys = 1.0f;
if (Math::Sign(M31 * M32 * M33 * M34) < 0)
zs = -1.0f;
else
zs = 1.0f;
scale.X = xs * (float)Math::Sqrt(M11 * M11 + M12 * M12 + M13 * M13);
scale.Y = ys * (float)Math::Sqrt(M21 * M21 + M22 * M22 + M23 * M23);
scale.Z = zs * (float)Math::Sqrt(M31 * M31 + M32 * M32 + M33 * M33);
if (scale.X == 0.0 || scale.Y == 0.0 || scale.Z == 0.0)
{
rotation = Quaternion::Identity;
return false;
} //The rotation is the left over matrix after dividing out the scaling.
Matrix rotationmatrix = Matrix();
rotationmatrix.M11 = M11 / scale.X;
rotationmatrix.M12 = M12 / scale.X;
rotationmatrix.M13 = M13 / scale.X;
rotationmatrix.M21 = M21 / scale.Y;
rotationmatrix.M22 = M22 / scale.Y;
rotationmatrix.M23 = M23 / scale.Y;
rotationmatrix.M31 = M31 / scale.Z;
rotationmatrix.M32 = M32 / scale.Z;
rotationmatrix.M33 = M33 / scale.Z;
rotationmatrix.M44 = 1.0f;
Quaternion::CreateFromRotationMatrix(rotationmatrix, rotation);
}
Matrix m1 = Matrix(M11/scale.X, M12/scale.X, M13/scale.X, 0,
M21/scale.Y, M22/scale.Y, M23/scale.Y, 0,
M31/scale.Z, M32/scale.Z, M33/scale.Z, 0,
0, 0, 0, 1);
rotation = Quaternion::CreateFromRotationMatrix(m1);
return true;
}

View File

@ -38,17 +38,17 @@ namespace XFX
{
int PacketReader::Length()
{
return (int)BaseStream().Length();
return (int)BaseStream()->Length();
}
int PacketReader::Position()
{
return (int)BaseStream().Position;
return (int)BaseStream()->Position;
}
int PacketReader::Position(int newValue)
{
BaseStream().Position = newValue;
BaseStream()->Position = newValue;
}
PacketReader::PacketReader()

View File

@ -0,0 +1,56 @@
// Copyright (C) 2010-2012, 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 <Graphics/RenderTarget.h>
namespace XFX
{
namespace Graphics
{
RenderTarget::~RenderTarget()
{
Dispose(false);
}
void RenderTarget::Dispose()
{
Dispose(true);
}
void RenderTarget::Dispose(bool disposing)
{
if (!isDisposed)
{
if (disposing)
{
}
isDisposed = true;
}
}
}
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2010-2012, 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 <Graphics/RenderTarget2D.h>
namespace XFX
{
namespace Graphics
{
}
}

View File

@ -47,12 +47,18 @@ namespace XFX
{
}
StorageDevice::StorageDevice(uint deviceIndex, PlayerIndex_t playerIndex)
{
_playerIndex = playerIndex;
_deviceIndex = deviceIndex;
}
StorageContainer StorageDevice::OpenContainer(char* titleName)
{
if(titleName == null || titleName == "")
if(!titleName || titleName == "")
throw ArgumentNullException("Non-null title name required.");
//return StorageContainer(*this, titleName, _playerSpecified, _playerIndex);
return StorageContainer(*this, titleName, _deviceIndex, _playerIndex);
}
}
}

View File

@ -0,0 +1,35 @@
#include <GamerServices/StorageDeviceAsyncResult.h>
namespace XFX
{
namespace GamerServices
{
Object* StorageDeviceAsyncResult::AsyncState()
{
return syncObject;
}
bool StorageDeviceAsyncResult::CompletedSynchronously()
{
return true;
}
StorageDeviceAsyncResult::StorageDeviceAsyncResult(Object* stateObject, int player)
{
syncObject = stateObject;
playerIndex = player;
}
StorageDeviceAsyncResult::StorageDeviceAsyncResult(const StorageDeviceAsyncResult &obj)
{
syncObject = obj.syncObject;
playerIndex = obj.playerIndex;
}
StorageDeviceAsyncResult::StorageDeviceAsyncResult(IAsyncResult* &obj)
{
}
}
}

View File

@ -48,6 +48,18 @@ namespace XFX
return ((-1.401298E-45f <= num) && (num <= 1.401298E-45f));
}
bool Viewport::Equals(Viewport obj)
{
return ((AspectRatio() == obj.AspectRatio()) && (Height == obj.Height) &&
(MaxDepth == obj.MaxDepth) && (MinDepth == obj.MinDepth) &&
(Width == obj.Width) && (X == obj.X) && (Y == obj.Y));
}
int Viewport::GetHashCode()
{
return ((int)AspectRatio() + Height + MaxDepth + MinDepth + Width + X + Y);
}
Vector3 Viewport::Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
{
Matrix matrix = Matrix::Multiply(Matrix::Multiply(world, view), projection);
@ -78,5 +90,15 @@ namespace XFX
}
return position;
}
bool Viewport::operator !=(Viewport right)
{
return !Equals(right);
}
bool Viewport::operator ==(Viewport right)
{
return Equals(right);
}
}
}

View File

@ -223,6 +223,14 @@
RelativePath=".\PresentationParameters.cpp"
>
</File>
<File
RelativePath=".\RenderTarget.cpp"
>
</File>
<File
RelativePath=".\RenderTarget2D.cpp"
>
</File>
<File
RelativePath=".\Sprite.cpp"
>
@ -327,6 +335,10 @@
RelativePath=".\Guide.cpp"
>
</File>
<File
RelativePath=".\StorageDeviceAsyncResult.cpp"
>
</File>
</Filter>
<Filter
Name="Net"
@ -493,6 +505,14 @@
RelativePath="..\..\include\Graphics\PresentationParameters.h"
>
</File>
<File
RelativePath="..\..\include\Graphics\RenderTarget.h"
>
</File>
<File
RelativePath="..\..\include\Graphics\RenderTarget2D.h"
>
</File>
<File
RelativePath="..\..\include\Graphics\Sprite.h"
>
@ -645,6 +665,10 @@
RelativePath="..\..\include\GamerServices\Guide.h"
>
</File>
<File
RelativePath="..\..\include\GamerServices\StorageDeviceAsyncResult.h"
>
</File>
</Filter>
<Filter
Name="Net"

View File

@ -34,7 +34,7 @@ LD_LIBS = $(LD_DIRS) -lmscorlib -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -l
OBJS = BoundingBox.o BoundingFrustrum.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 =
CONTENT_OBJS = ContentManager.o ContentReader.o
GAMERSERVICES_OBJS = Guide.o
GAMERSERVICES_OBJS = Guide.o StorageDeviceAsyncResult.o
GRAPHICS_OBJS = Color.o DepthStencilBuffer.o DisplayMode.o DisplayModeCollection.o GraphicsAdapter.o GraphicsDevice.o pbKit.o Sprite.o SpriteBatch.o SpriteFont.o Texture.o Texture2D.o TextureCollection.o TextureCreationParameters.o VertexElement.o VertexPositionColor.o VertexPositionNormalTexture.o VertexPositionTexture.o Viewport.o
INPUT_OBJS = GamePad.o Keyboard.o Mouse.o
MEDIA_OBJS = VideoPlayer.o

View File

@ -73,6 +73,11 @@ namespace System
return _nbytes;
}
Threading::WaitHandle* StreamAsyncResult::AsyncWaitHandle()
{
}
void StreamAsyncResult::SetComplete(Exception* e)
{
exc = e;

View File

@ -24,7 +24,7 @@ ENTRYPOINT = -Wl,--entry,_WinMainCRTStartup
STRIP = -Wl,--strip-all
LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP)
LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib
LD_LIBS = $(LD_DIRS) -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lstdc++ -lgcc
LD_LIBS = $(LD_DIRS) -lmscorlib -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lstdc++ -lgcc
OBJS = Array.o BinaryReader.o BinaryWriter.o BitConverter.o Boolean.o Buffer.o Byte.o Calendar.o Comparer.o DateTime.o Decoder.o Directory.o Encoder.o Environment.o Exception.o File.o FileStream.o HashHelpers.o KeyNotFoundException.o KeyValuePair.o Math.o MemoryStream.o Path.o Stack.o Stream.o StreamAsyncResult.o StreamReader.o StreamWriter.o Thread.o TimeSpan.o Version.o