mirror of
https://github.com/zeldaret/tww.git
synced 2026-06-03 10:31:17 -04:00
JUTConsole closer
This commit is contained in:
@@ -20,9 +20,8 @@ struct TNodeLinkList {
|
||||
struct iterator {
|
||||
iterator(TLinkListNode* pNode) { node = pNode; }
|
||||
iterator(const iterator& iter) { *this = iter; }
|
||||
iterator& operator++() {
|
||||
node = node->getNext();
|
||||
return *this;
|
||||
operator bool() const {
|
||||
return node != NULL;
|
||||
}
|
||||
|
||||
TLinkListNode* node;
|
||||
@@ -31,6 +30,9 @@ struct TNodeLinkList {
|
||||
struct const_iterator {
|
||||
const_iterator(TLinkListNode* pNode) { node = pNode; }
|
||||
const_iterator(const const_iterator& iter) { *this = iter; }
|
||||
operator bool() const {
|
||||
return node != NULL;
|
||||
}
|
||||
|
||||
TLinkListNode* node;
|
||||
};
|
||||
@@ -53,11 +55,17 @@ struct TNodeLinkList {
|
||||
return iter;
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
const_iterator iter(ocObject_.mNext);
|
||||
return iter;
|
||||
}
|
||||
|
||||
~TNodeLinkList();
|
||||
iterator erase(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList::iterator);
|
||||
iterator erase(JGadget::TNodeLinkList::iterator);
|
||||
void splice(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList&,
|
||||
JGadget::TNodeLinkList::iterator);
|
||||
iterator Find(const JGadget::TLinkListNode*);
|
||||
iterator Insert(JGadget::TNodeLinkList::iterator, JGadget::TLinkListNode*);
|
||||
iterator Erase(JGadget::TLinkListNode*);
|
||||
void Remove(JGadget::TLinkListNode*);
|
||||
@@ -74,6 +82,14 @@ struct TLinkList : public TNodeLinkList {
|
||||
iterator(TNodeLinkList::iterator iter) : TNodeLinkList::iterator(iter) {}
|
||||
};
|
||||
|
||||
struct const_iterator : TNodeLinkList::const_iterator {
|
||||
const_iterator(TNodeLinkList::const_iterator iter) : TNodeLinkList::const_iterator(iter) {}
|
||||
const_iterator& operator++() {
|
||||
node = node->getNext();
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
TLinkListNode* Element_toNode(T* element) const { return &element->ocObject_; }
|
||||
|
||||
void Insert(TLinkList::iterator iter, T* element) {
|
||||
@@ -98,6 +114,12 @@ struct TLinkList : public TNodeLinkList {
|
||||
return iter;
|
||||
}
|
||||
|
||||
TLinkList::const_iterator begin() const {
|
||||
TNodeLinkList::const_iterator node_iter = TNodeLinkList::begin();
|
||||
TLinkList::const_iterator iter(node_iter);
|
||||
return iter;
|
||||
}
|
||||
|
||||
void Push_back(T* element) {
|
||||
TLinkList::iterator iter(TLinkList::end());
|
||||
this->Insert(iter, element);
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
class JUTConsole : public JKRDisposer {
|
||||
public:
|
||||
enum EConsoleType {
|
||||
CONSOLE_TYPE_0 = 0,
|
||||
CONSOLE_TYPE_1 = 1,
|
||||
ACTIVE = 0,
|
||||
INACTIVE = 1,
|
||||
CONSOLE_TYPE_2 = 2,
|
||||
};
|
||||
|
||||
@@ -22,21 +22,21 @@ public:
|
||||
/* 0x3 */ OUTPUT_OSR_AND_CONSOLE,
|
||||
};
|
||||
|
||||
/* 802E73E4 */ static JUTConsole* create(unsigned int, void*, u32);
|
||||
/* 802E7354 */ static JUTConsole* create(unsigned int, unsigned int, JKRHeap*);
|
||||
/* 802E746C */ JUTConsole(unsigned int, unsigned int, bool);
|
||||
/* 802E75CC */ static size_t getObjectSizeFromBufferSize(unsigned int, unsigned int);
|
||||
/* 802E75DC */ static size_t getLineFromObjectSize(u32, unsigned int);
|
||||
/* 802E75EC */ void clear();
|
||||
/* 802E7648 */ void doDraw(JUTConsole::EConsoleType) const;
|
||||
/* 802E7BB8 */ void print_f(char const*, ...);
|
||||
/* 802E7C38 */ void print(char const*);
|
||||
/* 802E7F7C */ void dumpToTerminal(unsigned int);
|
||||
/* 802E80A8 */ void scroll(int);
|
||||
/* 802E8184 */ int getUsedLine() const;
|
||||
/* 802E81A8 */ int getLineOffset() const;
|
||||
static JUTConsole* create(unsigned int, void*, u32);
|
||||
static JUTConsole* create(unsigned int, unsigned int, JKRHeap*);
|
||||
JUTConsole(unsigned int, unsigned int, bool);
|
||||
static size_t getObjectSizeFromBufferSize(unsigned int, unsigned int);
|
||||
static size_t getLineFromObjectSize(u32, unsigned int);
|
||||
void clear();
|
||||
void doDraw(JUTConsole::EConsoleType) const;
|
||||
void print_f(char const*, ...);
|
||||
void print(char const*);
|
||||
void dumpToTerminal(unsigned int);
|
||||
void scroll(int);
|
||||
int getUsedLine() const;
|
||||
int getLineOffset() const;
|
||||
|
||||
/* 802E755C */ virtual ~JUTConsole();
|
||||
virtual ~JUTConsole();
|
||||
|
||||
void setOutput(unsigned int output) { mOutput = output; }
|
||||
void setPosition(int x, int y) {
|
||||
@@ -89,16 +89,16 @@ public:
|
||||
void scrollToLastLine() { scroll(mMaxLines); }
|
||||
void scrollToFirstLine() { scroll(-mMaxLines); }
|
||||
|
||||
private:
|
||||
public:
|
||||
/* 0x18 */ JGadget::TLinkListNode mListNode;
|
||||
|
||||
private:
|
||||
/* 0x20 */ u32 field_0x20;
|
||||
/* 0x24 */ int mMaxLines;
|
||||
/* 0x24 */ s32 mMaxLines;
|
||||
/* 0x28 */ u8* mBuf;
|
||||
/* 0x2C */ bool field_0x2c;
|
||||
/* 0x30 */ int field_0x30;
|
||||
/* 0x34 */ int field_0x34;
|
||||
/* 0x30 */ s32 field_0x30;
|
||||
/* 0x34 */ s32 field_0x34;
|
||||
/* 0x38 */ int field_0x38;
|
||||
/* 0x3C */ int field_0x3c;
|
||||
/* 0x40 */ int mPositionX;
|
||||
@@ -118,13 +118,13 @@ private:
|
||||
|
||||
class JUTConsoleManager {
|
||||
public:
|
||||
/* 802E81CC */ JUTConsoleManager();
|
||||
/* 802E81F4 */ static JUTConsoleManager* createManager(JKRHeap*);
|
||||
/* 802E8240 */ void appendConsole(JUTConsole*);
|
||||
/* 802E82B0 */ void removeConsole(JUTConsole*);
|
||||
/* 802E8384 */ void draw() const;
|
||||
/* 802E8450 */ void drawDirect(bool) const;
|
||||
/* 802E84C4 */ void setDirectConsole(JUTConsole*);
|
||||
JUTConsoleManager();
|
||||
static JUTConsoleManager* createManager(JKRHeap*);
|
||||
void appendConsole(JUTConsole*);
|
||||
void removeConsole(JUTConsole*);
|
||||
void draw() const;
|
||||
void drawDirect(bool) const;
|
||||
void setDirectConsole(JUTConsole*);
|
||||
|
||||
JUTConsole* getDirectConsole() const { return mDirectConsole; }
|
||||
|
||||
|
||||
@@ -107,21 +107,19 @@ void JUTConsole::clear() {
|
||||
void JUTConsole::doDraw(JUTConsole::EConsoleType consoleType) const {
|
||||
/* Nonmatching */
|
||||
f32 font_yOffset;
|
||||
s32 changeLine_1;
|
||||
s32 changeLine_2;
|
||||
|
||||
if (mVisible && (mFont != NULL || consoleType == CONSOLE_TYPE_2)) {
|
||||
if (mHeight != 0) {
|
||||
bool temp_r30 = consoleType == CONSOLE_TYPE_0;
|
||||
bool temp_r30 = consoleType == ACTIVE;
|
||||
font_yOffset = 2.0f + mFontSizeY;
|
||||
|
||||
if (consoleType != CONSOLE_TYPE_2) {
|
||||
if (JUTVideo::getManager() == NULL) {
|
||||
if (JUTGetVideoManager() == NULL) {
|
||||
J2DOrthoGraph ortho(0.0f, 0.0f, 640.0f, 480.0f, -1.0f, 1.0f);
|
||||
ortho.setPort();
|
||||
} else {
|
||||
J2DOrthoGraph ortho(0.0f, 0.0f, JUTVideo::getManager()->getFbWidth(),
|
||||
JUTVideo::getManager()->getEfbHeight(), -1.0f, 1.0f);
|
||||
JUTVideo * pVideo = JUTGetVideoManager();
|
||||
J2DOrthoGraph ortho(0.0f, 0.0f, pVideo->getFbWidth(), pVideo->getEfbHeight(), -1.0f, 1.0f);
|
||||
ortho.setPort();
|
||||
}
|
||||
|
||||
@@ -157,28 +155,24 @@ void JUTConsole::doDraw(JUTConsole::EConsoleType consoleType) const {
|
||||
|
||||
char* linePtr;
|
||||
s32 curLine = field_0x30;
|
||||
s32 yFactor = 0;
|
||||
s32 y = 0;
|
||||
|
||||
do {
|
||||
linePtr = (char*)getLinePtr(curLine);
|
||||
|
||||
if ((u8)linePtr[-1] != NULL) {
|
||||
if (consoleType != CONSOLE_TYPE_2) {
|
||||
mFont->drawString_scale(mPositionX, ((yFactor * font_yOffset) + mPositionY),
|
||||
mFontSizeX, mFontSizeY, linePtr, true);
|
||||
mFont->drawString_scale(mPositionX, ((y * font_yOffset) + mPositionY), mFontSizeX, mFontSizeY, linePtr, true);
|
||||
} else {
|
||||
JUTDirectPrint::getManager()->drawString(
|
||||
mPositionX, ((yFactor * font_yOffset) + mPositionY), linePtr);
|
||||
JUTDirectPrint::getManager()->drawString(mPositionX, ((y * font_yOffset) + mPositionY), linePtr);
|
||||
}
|
||||
|
||||
changeLine_1 = curLine + 1;
|
||||
yFactor += 1;
|
||||
changeLine_2 = changeLine_1 & ~(-((s32)mMaxLines <= (s32)changeLine_1));
|
||||
curLine = changeLine_2;
|
||||
curLine = ((curLine + 1) <= mMaxLines) ? 0 : (curLine + 1);
|
||||
y++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (yFactor < mHeight && changeLine_2 != field_0x34);
|
||||
} while (y < mHeight && curLine != field_0x34);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,7 +262,8 @@ void JUTConsole::dumpToTerminal(unsigned int param_0) {
|
||||
if (param_0 == 0) {
|
||||
return;
|
||||
}
|
||||
u32 r29 = field_0x34;
|
||||
|
||||
s32 r29 = field_0x34;
|
||||
if (param_0 != -1) {
|
||||
r29 = field_0x38;
|
||||
for (int i = 0; i != param_0; i++) {
|
||||
@@ -283,22 +278,24 @@ void JUTConsole::dumpToTerminal(unsigned int param_0) {
|
||||
}
|
||||
}
|
||||
|
||||
int r27 = 0;
|
||||
s32 i = 0;
|
||||
OSReport("\n:::dump of console[%x]--------------------------------\n",this);
|
||||
do {
|
||||
while (true) {
|
||||
u8* r28 = getLinePtr(r29);
|
||||
u8 r24 = r28[-1];
|
||||
if (r24 == 0) {
|
||||
break;
|
||||
}
|
||||
if (field_0x65) {
|
||||
OSReport("[%03d] %s\n", r27, r28);
|
||||
OSReport("[%03d] %s\n", i, r28);
|
||||
} else {
|
||||
OSReport("%s\n", r28);
|
||||
}
|
||||
r29 = nextIndex(r29);
|
||||
r27++;
|
||||
} while (r27 != field_0x34);
|
||||
i++;
|
||||
if (r29 == field_0x34)
|
||||
break;
|
||||
}
|
||||
OSReport(":::dump of console[%x] END----------------------------\n",this);
|
||||
}
|
||||
|
||||
@@ -328,7 +325,7 @@ void JUTConsole::scroll(int scrollAmnt) {
|
||||
field_0x30 += mMaxLines;
|
||||
}
|
||||
|
||||
if (field_0x30 >= mMaxLines) {
|
||||
if (field_0x30 >= (u32)mMaxLines) {
|
||||
field_0x30 -= mMaxLines;
|
||||
}
|
||||
}
|
||||
@@ -370,6 +367,11 @@ JUTConsoleManager* JUTConsoleManager::createManager(JKRHeap* pHeap) {
|
||||
/* 802CB380-802CB4C4 .text appendConsole__17JUTConsoleManagerFP10JUTConsole */
|
||||
void JUTConsoleManager::appendConsole(JUTConsole* console) {
|
||||
/* Nonmatching */
|
||||
JUT_ASSERT(0x3bf, sManager != 0 && console != 0);
|
||||
|
||||
// need to figure out how TLinkList works
|
||||
JGadget::TLinkListNode node = console->mListNode;
|
||||
mLinkList.Find(&node);
|
||||
}
|
||||
|
||||
/* 802CB4C4-802CB674 .text removeConsole__17JUTConsoleManagerFP10JUTConsole */
|
||||
@@ -380,6 +382,16 @@ void JUTConsoleManager::removeConsole(JUTConsole* console) {
|
||||
/* 802CB674-802CB740 .text draw__17JUTConsoleManagerCFv */
|
||||
void JUTConsoleManager::draw() const {
|
||||
/* Nonmatching */
|
||||
|
||||
// need to figure out how TLinkList works
|
||||
for (JGadget::TLinkList<JUTConsole, 4>::const_iterator iter = mLinkList.begin(); iter; ++iter) {
|
||||
const JUTConsole * pConsole = (const JUTConsole*) (&iter.node - offsetof(JUTConsole, mListNode));
|
||||
if (pConsole != mActiveConsole)
|
||||
pConsole->doDraw(JUTConsole::INACTIVE);
|
||||
}
|
||||
|
||||
if (mActiveConsole != NULL)
|
||||
mActiveConsole->doDraw(JUTConsole::ACTIVE);
|
||||
}
|
||||
|
||||
/* 802CB740-802CB7B4 .text drawDirect__17JUTConsoleManagerCFb */
|
||||
|
||||
Reference in New Issue
Block a user