Skip to content

Commit

Permalink
Merge pull request RPCS3#1 from DHrpcs3/wip
Browse files Browse the repository at this point in the history
Wip
  • Loading branch information
DHrpcs3 committed Aug 26, 2013
2 parents 991f281 + f83aa9d commit 555ad94
Show file tree
Hide file tree
Showing 115 changed files with 10,869 additions and 2,525 deletions.
2,014 changes: 1,837 additions & 177 deletions GL/glext.h

Large diffs are not rendered by default.

181 changes: 170 additions & 11 deletions Utilities/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

template<typename T> class Array
{
protected:
u32 m_count;
T* m_array;

Expand Down Expand Up @@ -87,11 +88,14 @@ template<typename T> class Array
return m_count - 1;
}

inline bool AddCpy(const u32 pos, const T* data, u64 count = 1)
inline bool AddCpy(const u32 pos, const T* data, u32 count = 1)
{
if(!InsertRoom(pos, count)) return false;

memcpy(m_array + pos, data, sizeof(T) * count);
for(u32 i=0; i<count; ++i)
{
new (m_array + pos + i) T(data[i]);
}

return true;
}
Expand All @@ -101,11 +105,14 @@ template<typename T> class Array
return AddCpy(pos, &data);
}

inline u32 AddCpy(const T* data, u64 count = 1)
inline u32 AddCpy(const T* data, u32 count = 1)
{
_InsertRoomEnd(count);

memcpy(m_array + m_count - count, data, sizeof(T)*count);
for(u32 i=0; i<count; ++i)
{
new (m_array + m_count - count + i) T(data[i]);
}

return m_count - count;
}
Expand All @@ -120,7 +127,13 @@ template<typename T> class Array
u32 count = m_count;
m_count = 0;
for(u32 i=0; i<count; ++i) m_array[i].~T();
safe_delete(m_array);
safe_free(m_array);
}

inline void ClearF()
{
m_count = 0;
safe_free(m_array);
}

inline T& Get(u32 num)
Expand All @@ -129,15 +142,15 @@ template<typename T> class Array
return m_array[num];
}

u32 GetCount() const { return m_count; }
virtual u32 GetCount() const { return m_count; }

void SetCount(const u32 count, bool memzero = true)
virtual void SetCount(const u32 count, bool memzero = true)
{
if(GetCount() >= count) return;
_InsertRoomEnd(count - GetCount());
if(m_count >= count) return;

_InsertRoomEnd(count - m_count);

if(memzero) memset(m_array + GetCount(), 0, count - GetCount());
if(memzero) memset(m_array + m_count - count, 0, sizeof(T) * (m_count - count));
}

void Reserve(const u32 count)
Expand All @@ -162,6 +175,7 @@ template<typename T> class Array
}

inline T* GetPtr() { return m_array; }
inline const T* GetPtr() const { return m_array; }

T& operator[](u32 num) const { return m_array[num]; }

Expand All @@ -185,6 +199,96 @@ template<typename T> class Array
}
};

class ArrayString : public Array<char>
{
public:
ArrayString() : Array()
{
}

ArrayString(const wxString& value) : Array()
{
*this = value;
}

ArrayString(const char* value) : Array()
{
*this = value;
}

virtual u32 GetCount() const
{
return m_array ? strlen(m_array) : 0;
}

virtual void SetCount(const u32 count, bool memzero = true)
{
if(m_count && count < m_count - 1)
{
m_array[count] = '\0';
}
else
{
Array::SetCount(count + 1, memzero);
}
}

ArrayString& operator = (const char* right)
{
Clear();

if(right)
{
size_t len = strlen(right);

if(len)
{
SetCount(len);
memcpy(m_array, right, len * sizeof(char));
m_array[len] = '\0';
}
}

return *this;
}

ArrayString& operator = (const ArrayString& right)
{
Clear();

if(size_t len = right.GetCount())
{
SetCount(len);
memcpy(m_array, right.GetPtr(), len * sizeof(char));
m_array[len] = '\0';
}

return *this;
}

ArrayString& operator = (const wxString& right)
{
Clear();

if(size_t len = right.Len())
{
SetCount(len);
memcpy(m_array, right.c_str(), len * sizeof(char));
m_array[len] = '\0';
}

return *this;
}

ArrayString* Clone() const
{
ArrayString* new_array = new ArrayString();
(*new_array) = m_array;

return new_array;
}
};

template<typename T> struct Stack : public Array<T>
{
Stack() : Array<T>()
Expand All @@ -209,6 +313,61 @@ template<typename T> struct Stack : public Array<T>
}
};

template<typename T, size_t size> class SizedStack
{
T m_ptr[size];
uint m_count;

public:
SizedStack()
{
Clear();
}

~SizedStack()
{
Clear();
}

void Clear()
{
m_count = 0;
}

bool Pop(T& dst)
{
if(!m_count)
return false;

dst = m_ptr[--m_count];
return true;
}

bool Push(const T& src)
{
if(m_count + 1 > size)
return false;

m_ptr[m_count++] = src;
return true;
}

size_t GetFreeCount() const
{
return size - m_count;
}

size_t GetCount() const
{
return m_count;
}

size_t GetMaxCount() const
{
return size;
}
};

template<typename T> class ArrayF
{
u32 m_count;
Expand Down
6 changes: 5 additions & 1 deletion Utilities/Thread.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once
#include "Array.h"
#include <functional>
#include <thread>
#include <mutex>
#include <condition_variable>

class ThreadExec;

Expand Down Expand Up @@ -59,7 +63,7 @@ class ThreadExec : public wxThread

m_parent = nullptr;

//if(wait)
if(wait)
{
Delete();
//wxCriticalSectionLocker lock(m_wait_for_exit);
Expand Down
Binary file added bin/dev_hdd0/game/TEST12345/USRDIR/cube.elf
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions rpcs3/Emu/Cell/MFC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "stdafx.h"
#include "MFC.h"
Loading

0 comments on commit 555ad94

Please sign in to comment.