Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/JSystem/JGadget/define.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ extern "C"

#ifdef JGADGET_DEBUG

#define JGADGET_WARN(msg) \
(JGadget_outMessage(JGadget_outMessage::warning, __FILE__, __LINE__) \
<< (msg))

#define JGADGET_ASSERTWARN(cond) \
((cond) || ((JGadget_outMessage(JGadget_outMessage::warning, __FILE__, __LINE__) << (#cond)), false))

Expand All @@ -46,6 +50,8 @@ extern "C"

#else

#define JGADGET_WARN(msg) ((void)0)

#define JGADGET_ASSERTWARN(cond) \
((cond) || (false))

Expand All @@ -65,4 +71,4 @@ extern "C"
}
#endif

#endif
#endif
134 changes: 114 additions & 20 deletions include/JSystem/JGadget/std-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace JGadget {
template <typename T, typename Allocator = JGadget::TAllocator<T> >
struct TList {
struct TNode_ {
TNode_ *pPrev_;
TNode_ *pNext_;
TNode_ *pPrev_;
};

class iterator {
Expand All @@ -23,21 +23,31 @@ struct TList {
iterator(TNode_* node) { this->p_ = node; }

iterator& operator++() {
this->p_ = this->p_->getNext();
this->p_ = this->p_->pNext_;
return *this;
}

iterator& operator--() {
this->p_ = this->p_->getPrev();
this->p_ = this->p_->pPrev_;
return *this;
}

TNode_& operator*() const {
T& operator*() const {
JGADGET_ASSERT(p_!=0);
return *this->p_;
return *(T*)(this->p_ + 1);
}

TNode_* operator->() const { return this->p_; }
T* operator->() const {
return (T*)(this->p_ + 1);
}

friend bool operator==(const iterator& a, const iterator& b) {
return a.p_ == b.p_;
}

friend bool operator!=(const iterator& a, const iterator& b) {
return a.p_ != b.p_;
}

TNode_* p_;
};
Expand All @@ -48,42 +58,128 @@ struct TList {
const_iterator(iterator it) { this->p_ = it.p_; }

const const_iterator& operator++() {
this->p_ = this->p_->getNext();
this->p_ = this->p_->pNext_;
return *this;
}

const const_iterator& operator--() {
this->p_ = this->p_->getPrev();
this->p_ = this->p_->pPrev_;
return *this;
}

const TNode_* operator->() const { return this->p_; }
const T& operator*() const {
JGADGET_ASSERT(p_!=0);
return *(const T*)(this->p_ + 1);
}

const T* operator->() const {
return (const T*)(this->p_ + 1);
}

friend bool operator==(const const_iterator& a, const const_iterator& b) {
return a.p_ == b.p_;
}

friend bool operator!=(const const_iterator& a, const const_iterator& b) {
return a.p_ != b.p_;
}

const TNode_* p_;
};

TList(const TAllocator<T> &allocator=0) {
~TList() { clear(); }

TList(const TAllocator<T>& alloc = TAllocator<T>())
{
oAllocator_ = alloc;
oSize_ = 0;
Initialize_();
}
Initialize_();
}

void Initialize_() {
oEnd_.pNext_ = &this->oNode_;
oEnd_.pPrev_ = &this->oNode_;
oEnd_.pNext_ = &this->oEnd_;
oEnd_.pPrev_ = &this->oEnd_;
}

TNode_* CreateNode_(TNode_* pNext, TNode_* pPrev, const T& value)
{
JGADGET_ASSERT(pNext!=0);
JGADGET_ASSERT(pPrev!=0);

void* raw = oAllocator_.AllocateRaw(sizeof(TNode_) + sizeof(T));

if (raw == nullptr) {
JGADGET_WARN("can't allocate memory");
return nullptr;
}

TNode_* const ret = (TNode_*)raw;

ret->pNext_ = pNext;
ret->pPrev_ = pPrev;
oAllocator_.construct((T*)(ret + 1), value);
return ret;
}

void DestroyNode_(TNode_ *p) {
// probably doesn't match
JGADGET_ASSERT(p!=0);
JGADGET_ASSERT(p!=&oEnd_);
JGADGET_ASSERT(p->pNext_->pPrev_!=p);
JGADGET_ASSERT(p->pPrev_->pNext_!=p);
oAllocator_.destroy(p + 1);

oAllocator_.destroy((T*)(p + 1));
oAllocator_.DeallocateRaw(p);
}

iterator end() {return &this->oNode_; }
const_iterator end() const { return &this->oNode_; }
iterator insert(iterator where, const T& what)
{
TNode_* const pNext = where.p_;
JGADGET_ASSERT(pNext!=0);

TNode_* const pPrev = pNext->pPrev_;

TNode_* const newNode = CreateNode_(pNext, pPrev, what);

if (newNode == nullptr) {
return end();
}

pNext->pPrev_ = newNode;
pPrev->pNext_ = newNode;
++oSize_;
return iterator(newNode);
}

iterator erase(iterator what)
{
TNode_* p = what.p_;
TNode_* next = p->pNext_;
p->pPrev_->pNext_ = next;
next->pPrev_ = p->pPrev_;
DestroyNode_(p);
oSize_--;
return iterator(next);
}

iterator erase(iterator start, iterator end)
{
while (start != end) {
start = erase(start);
}
return start;
}

void push_back(const T& what) {
insert(end(), what);
}

iterator begin() { return iterator(oEnd_.pNext_); }
const_iterator begin() const { return const_iterator(oEnd_.pNext_); }

iterator end() { return iterator(&this->oEnd_); }
const_iterator end() const { return const_iterator(&this->oEnd_); }

iterator clear() { return erase(begin(), end()); }

private:
TAllocator<T> oAllocator_; // 0
Expand All @@ -93,6 +189,4 @@ struct TList {

}



#endif
15 changes: 13 additions & 2 deletions include/JSystem/JGadget/std-memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ struct TAllocator {
DeallocateRaw(mem);
}

void DeallocateRaw(T* mem) {
void DeallocateRaw(void* mem) {
delete mem;
}

void construct(T* p, const T& value)
{
// clang-format off
JGADGET_ASSERT(p!=0);
// clang-format on
(void)::new (p) T(value);
}

void destroy(T* p) {
JUT_ASSERT(p!=0);
// clang-format off
JGADGET_ASSERT(p!=0);
// clang-format on
p->~T();
}

u8 mAllocator; // 00
Expand Down
1 change: 1 addition & 0 deletions include/Kaneshige/ViewCtrlModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ViewCtrlModel : public ExModel
void setDetailFlg() { mFlags |= 0x10; }
void setVisibleAll() { mFlags |= 0xf; }
void setVisible(u32 cnsNo) { mFlags |= (1 << cnsNo); }
u8 getFlags() const { return mFlags; }

private:
u8 mFlags; // 0x8c
Expand Down
25 changes: 21 additions & 4 deletions include/Osako/shadowMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

#include "JSystem/JUtility/TColor.h"
#include "JSystem/JGadget/std-list.h"
#include "JSystem/JKernel/JKRDisposer.h"
#include "Osako/shadowModel.h"
#include "types.h"

class ShadowManager {
class ShadowManager : public JKRDisposer
{
public:
ShadowManager();

Expand Down Expand Up @@ -49,16 +51,31 @@ class ShadowManager {
return 0xff;
}

JUTColor getShadowColor() {
return mShadowColor;
}

u8 getDepth(int index) {
return mDepth[index];
}

u8 getDepthMode() {
return mDepthMode;
}

static ShadowManager* mspShadowManager;

//private:
u8 _00[0x58];
private:
List _18;
List _28;
List _38;
List _48;

JUTColor mShadowColor;
u8 mDepth[2];
u8 mDepthMode;
u8 _5f;
bool mIsMirror;
u8 _61[3]; // i thought operator new always gets aligned by 4?
}; // Size: 0x64

#endif // SHADOWMGR_H
5 changes: 5 additions & 0 deletions include/Osako/shadowModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class ShadowModel : public ViewCtrlModel
_95 = 0;
}

ShadowKind getShadowKind() const { return mKind; }
u8 getAlpha() const { return _94; }
u8 getFlag95() const { return _95; }
void setFlag95(bool flag) { _95 = flag; }

virtual bool createModel(JKRSolidHeap *, u32, u32); // 0x801f7154, override
private:
ShadowKind mKind;
Expand Down
Loading