Add JUTConsole and JUTConsoleManager classes

This commit is contained in:
Cuyler36
2023-12-05 12:28:00 -05:00
parent 4e704ac06b
commit 10f4e7c13e
18 changed files with 1379 additions and 61 deletions
+48
View File
@@ -0,0 +1,48 @@
#ifndef J2DGXCOLORS10_H
#define J2DGXCOLORS10_H
#include "types.h"
#include "dolphin/gx.h"
#include "JSystem/JUtility/TColor.h"
/**
* Everything is fabricated here except for the default ctor.
* Copied from J3DGXColorS10.
*/
struct J2DGXColorS10 : public GXColorS10
{
J2DGXColorS10() {}
J2DGXColorS10(u16 _r, u16 _g, u16 _b, u16 _a)
{
r = _r;
g = _g;
b = _b;
a = _a;
}
J2DGXColorS10(const J2DGXColorS10 &other)
{
r = other.r;
g = other.g;
b = other.b;
a = other.a;
}
J2DGXColorS10(const u64 &other)
{
GXColorS10 *otherBytes = (GXColorS10 *)&other;
r = otherBytes->r;
g = otherBytes->g;
b = otherBytes->b;
a = otherBytes->a;
}
inline operator u64() const { return toUInt64(); }
inline u32 toUInt64() const { return *(u64 *)&r; }
inline operator JUtility::TColor() const { return toTColor(); }
inline JUtility::TColor toTColor() const { return JUtility::TColor(r, g, b, a); }
};
#endif
+126
View File
@@ -0,0 +1,126 @@
#ifndef J2DINDBLOCK_H
#define J2DINDBLOCK_H
#include "types.h"
#include "JSystem/J3D/J3DTypes.h"
#include "dolphin/gx.h"
typedef float Mtx23[2][3];
struct J2DIndTexCoordScaleInfo
{
GXIndTexScale getScaleS() const { return (GXIndTexScale)mScaleS; }
GXIndTexScale getScaleT() const { return (GXIndTexScale)mScaleT; }
u8 mScaleS; // _00
u8 mScaleT; // _01
};
/**
* @size{0x2}
*/
struct J2DIndTexCoordScale
{
J2DIndTexCoordScale();
~J2DIndTexCoordScale() {}
void load(u8);
J2DIndTexCoordScaleInfo mScaleInfo; // _00
};
struct J2DIndTexMtxInfo
{
Mtx23 mMtx; // _00
s8 mScale; // _18
};
/**
* @size{0x1C}
*/
struct J2DIndTexMtx
{
J2DIndTexMtx();
~J2DIndTexMtx() {}
void load(u8);
J2DIndTexMtxInfo mMtxInfo; // _00
};
extern J2DIndTexMtxInfo j2dDefaultIndTexMtxInfo;
/**
* @size{0x2}
*/
struct J2DIndTexOrder
{
J2DIndTexOrder();
void load(u8);
u8 mCoord; // _00
u8 mMap; // _01
};
struct J2DIndBlock
{
virtual void initialize() {} // _08 (weak)
virtual void setGX() {} // _0C (weak)
virtual u32 getType() = 0; // _10
virtual void setIndTexStageNum(u8 texStageNum) {} // _14 (weak)
virtual u8 getIndTexStageNum() const { return 0; } // _18 (weak)
virtual void setIndTexOrder(unsigned long index, J2DIndTexOrder order) {} // _1C (weak)
virtual J2DIndTexOrder *getIndTexOrder(unsigned long index) { return nullptr; } // _20 (weak)
virtual void setIndTexMtx(unsigned long index, J2DIndTexMtx texMtx) {} // _24 (weak)
virtual J2DIndTexMtx *getIndTexMtx(unsigned long index) { return nullptr; } // _28 (weak)
virtual void setIndTexCoordScale(unsigned long index, J2DIndTexCoordScale scale) {} // _2C (weak)
virtual J2DIndTexCoordScale *getIndTexCoordScale(unsigned long index) { return nullptr; } // _30 (weak)
virtual ~J2DIndBlock() {} // _34 (weak)
// _00 VTBL
};
struct J2DIndBlockNull : public J2DIndBlock
{
inline J2DIndBlockNull()
: J2DIndBlock()
{
}
virtual void setGX(); // _0C (weak)
virtual u32 getType(); // _10 (weak)
virtual ~J2DIndBlockNull(); // _34 (weak)
};
struct J2DIndBlockFull : public J2DIndBlock
{
inline J2DIndBlockFull()
: J2DIndBlock(), mTexOrders(), mTexMtxes(), mTexCoordScales()
{
initialize();
}
virtual void initialize(); // _08
virtual void setGX(); // _0C
virtual u32 getType() { return JBT_IndFull; } // _10 (weak)
virtual void setIndTexStageNum(u8 texStageNum) { mTexStageNum = texStageNum; } // _14 (weak)
virtual u8 getIndTexStageNum() const { return mTexStageNum; } // _18 (weak)
virtual void setIndTexOrder(unsigned long index, J2DIndTexOrder order) { mTexOrders[index] = order; } // _1C (weak)
virtual J2DIndTexOrder *getIndTexOrder(unsigned long index) { return mTexOrders + index; } // _20 (weak)
virtual void setIndTexMtx(unsigned long, J2DIndTexMtx); // _24 (weak)
virtual J2DIndTexMtx *getIndTexMtx(unsigned long index) { return mTexMtxes + index; } // _28 (weak)
virtual void setIndTexCoordScale(unsigned long index, J2DIndTexCoordScale scale) { mTexCoordScales[index] = scale; } // _2C (weak)
virtual J2DIndTexCoordScale *getIndTexCoordScale(unsigned long index) { return mTexCoordScales + index; } // _30 (weak)
virtual ~J2DIndBlockFull() {} // _34 (weak)
u8 mTexStageNum; // _04
J2DIndTexOrder mTexOrders[4]; // _05
u32 : 0;
J2DIndTexMtx mTexMtxes[3]; // _10
J2DIndTexCoordScale mTexCoordScales[4]; // _64
};
#endif
+389
View File
@@ -0,0 +1,389 @@
#ifndef J2DTYPES_H
#define J2DTYPES_H
/**
* Header for J2D POD and nearly POD types, as well as defines, typedefs, and enums that aren't specific to a particular non-POD type.
*/
#include <dolphin/mtx.h>
#include "JSystem/J2D/J2DGXColorS10.h"
#include "JSystem/J2D/J2DIndBlock.h"
#include "JSystem/JUtility/TColor.h"
#include "types.h"
struct JUTTexture;
enum J2DBinding
{
J2DBIND_Unk15 = 15,
};
enum J2DMirror
{
J2DMIRROR_Unk0 = 0,
};
extern u16 j2dDefaultAlphaCmp;
struct J2DAlphaCompInfo
{
// TODO: work out what goes in this
};
struct J2DAlphaComp
{
/** @fabricated */
J2DAlphaComp()
: mAlphaComp(j2dDefaultAlphaCmp), mRef0(0), mRef1(0)
{
}
u16 mAlphaComp; // _00
u8 mRef0; // _02
u8 mRef1; // _03
};
struct J2DBlendInfo
{
J2DBlendInfo() {}
J2DBlendInfo(u8 type, u8 srcFactor, u8 destFactor)
{
mType = type;
mSrcFactor = srcFactor;
mDestFactor = destFactor;
}
void operator=(J2DBlendInfo const &other)
{
mType = other.mType;
mSrcFactor = other.mSrcFactor;
mDestFactor = other.mDestFactor;
}
u8 mType; // _00
u8 mSrcFactor; // _01
u8 mDestFactor; // _02
};
extern J2DBlendInfo j2dDefaultBlendInfo;
struct J2DBlend
{
J2DBlend() { mBlendInfo = j2dDefaultBlendInfo; }
J2DBlend(u8 type, u8 srcFactor, u8 destFactor, u8 op)
: mBlendInfo(type, srcFactor, destFactor), mOp(op)
{
}
void operator=(J2DBlend const &other)
{
mBlendInfo = other.mBlendInfo;
mOp = other.mOp;
}
inline void set(J2DBlend blend)
{
mBlendInfo = blend.mBlendInfo;
mOp = blend.mOp;
}
J2DBlendInfo mBlendInfo; // _00
u8 mOp; // _03
};
struct J2DColorChanInfo
{
u8 _00; // _00, should these be one u16?
u8 _01; // _01
};
extern J2DColorChanInfo j2dDefaultColorChanInfo;
/**
* @size{0x2}
*/
struct J2DColorChan
{
J2DColorChan() { mData = j2dDefaultColorChanInfo._01; }
u16 getMatSrc() const { return mData & 1; }
u16 mData; // _00, should this be J2DColorChanInfo?
};
struct J2DTevOrderInfo
{
u8 mTexCoord; // _00
u8 mTexMap; // _01
u8 mColor; // _02
};
extern J2DTevOrderInfo j2dDefaultTevOrderInfoNull;
struct J2DTevOrder
{
J2DTevOrder() { mTevOrderInfo = j2dDefaultTevOrderInfoNull; }
/** @fabricated */
inline J2DTevOrder(u8 texCoord, u8 texMap, u8 color)
{
mTevOrderInfo.mTexCoord = texCoord;
mTevOrderInfo.mTexMap = texMap;
mTevOrderInfo.mColor = color;
}
/** @fabricated */
inline J2DTevOrder &operator=(const J2DTevOrderInfo &other)
{
mTevOrderInfo = other;
return *this;
}
/** @fabricated */
inline J2DTevOrder &operator=(const J2DTevOrder &other)
{
mTevOrderInfo = other.mTevOrderInfo;
return *this;
}
inline GXChannelID getColor() const { return (GXChannelID)mTevOrderInfo.mColor; }
inline GXTexMapID getTexMap() const { return (GXTexMapID)mTevOrderInfo.mTexMap; }
inline GXTexCoordID getTexCoord() const { return (GXTexCoordID)mTevOrderInfo.mTexCoord; }
J2DTevOrderInfo mTevOrderInfo; // _00
u8 _03; // _03
};
struct J2DTevStageInfo
{
u8 _00; // _00
bool _01; // _01
u8 _02; // _02
bool _03; // _03
u8 _04; // _04
u8 _05; // _05
u8 _06; // _06
u8 _07; // _07
bool _08; // _08
u8 _09; // _09
u8 _0A; // _0A
u8 _0B; // _0B
u8 _0C; // _0C
u8 _0D; // _0D
u8 _0E; // _0E
u8 _0F; // _0F
u8 _10; // _10
bool _11; // _11
u8 _12; // _12
u8 _13; // _13
};
#pragma reverse_bitfields on
struct J2DTevStage_0x1
{
// LSB
u8 _0 : 2;
u8 _2 : 1;
u8 _3 : 1;
u8 _4 : 2;
u8 _6 : 2;
// MSB
};
struct J2DTevStage_0x4
{
// LSB
u8 _0 : 1;
u8 _1 : 3;
u8 _4 : 3;
u8 _7 : 3;
u8 _A : 3;
u8 _D : 3;
u8 _10 : 2;
u8 _12 : 1;
u8 _13 : 1;
u8 _14 : 2;
u8 _16 : 2;
// u8 _2 : 2;
// u8 _0 : 2;
// MSB
};
struct J2DTevStage
{
J2DTevStage();
void setTevStageInfo(const J2DTevStageInfo &info);
/** @fabricated */
inline J2DTevStage &operator=(const J2DTevStage &other)
{
_01 = other._01;
_02 = other._02;
_03 = other._03;
_04.asBytes[1] = other._04.asBytes[1];
_04.asBytes[2] = other._04.asBytes[2];
_04.asBytes[3] = other._04.asBytes[3];
return *this;
}
u8 _00; // _00
J2DTevStage_0x1 _01; // _01
u8 _02; // _02
u8 _03; // _03
// u8 _04; // _04
union
{
J2DTevStage_0x4 asStruct;
u8 asBytes[4];
} _04; // _04
// J2DTevStage_0x1 _05; // _05
// J2DTevStage_0x6 _06; // _06
// struct J2DTevStage_0x1 {
// // MSB
// u8 _6 : 2;
// u8 _4 : 2;
// bool _3 : 1;
// bool _2 : 1;
// u8 _0 : 2;
// // LSB
// } _01; // _01
// u8 _02; // _02
// u8 _03; // _03
// u8 _04; // _04
// J2DTevStage_0x1 _05; // _05
// struct J2DTevStage_0x6 {
// // MSB
// u8 _D : 3;
// u8 _A : 3;
// u8 _7 : 3;
// u8 _4 : 3;
// u8 _1 : 3;
// u8 _0 : 1;
// // u8 _2 : 2;
// // u8 _0 : 2;
// // LSB
// } _06; // _06
};
struct J2DTevSwapModeInfo
{
u8 _00;
u8 _01;
};
struct J2DTevSwapModeTableInfo
{
// TODO: work out what goes in this
};
// struct TwoBit {
// u8 _00 : 2;
// };
struct J2DTevSwapModeTable
{
J2DTevSwapModeTable();
/** @fabricated */
inline J2DTevSwapModeTable(u8 p1, u8 p2, u8 p3, u8 p4)
{
_0 = p1;
_2 = p2;
_4 = p3;
_6 = p4;
}
// // LSB
u8 _0 : 2;
u8 _2 : 2;
u8 _4 : 2;
u8 _6 : 2;
// // MSB
// LSB
// TwoBit _0[4];
// MSB
};
#pragma reverse_bitfields reset
struct J2DIndTevStage
{
J2DIndTevStage();
void load(u8);
GXIndTexStageID getIndStage() const { return (GXIndTexStageID)(mFlags & 0x03); }
GXIndTexFormat getIndFormat() const { return (GXIndTexFormat)((mFlags >> 2) & 0x03); }
GXIndTexBiasSel getBiasSel() const { return (GXIndTexBiasSel)((mFlags >> 4) & 0x07); }
GXIndTexWrap getWrapS() const { return (GXIndTexWrap)((mFlags >> 8) & 0x07); }
GXIndTexWrap getWrapT() const { return (GXIndTexWrap)((mFlags >> 11) & 0x07); }
GXIndTexMtxID getMtxSel() const { return (GXIndTexMtxID)((mFlags >> 16) & 0x0F); }
GXBool getPrev() const { return (GXBool)((mFlags >> 20) & 0x01); }
GXBool getLod() const { return (GXBool)((mFlags >> 21) & 0x01); }
GXIndTexAlphaSel getAlphaSel() const { return (GXIndTexAlphaSel)((mFlags >> 22) & 0x03); }
u32 mFlags; // _00
};
struct J2DTexCoordInfo
{
u8 mTexGenType; // _00
u8 mTexGenSrc; // _01
u8 mTexGenMtx; // _02
u8 _03; // _03 - padding?
};
struct J2DTexCoord
{
J2DTexCoord();
// J2DTexCoordInfo _00;
J2DTexCoordInfo mTexCoordInfo; // _00
};
struct J2DTextureSRTInfo
{
f32 _00; // _00
f32 _04; // _04
f32 _08; // _08
f32 _0C; // _0C
f32 _10; // _10
};
extern J2DTexCoordInfo j2dDefaultTexCoordInfo[8];
extern J2DTevStageInfo j2dDefaultTevStageInfo;
extern u32 j2dDefaultColInfo;
// j2dDefaultTevOrderInfoNull declared earlier in file.
extern J2DIndTexOrder j2dDefaultIndTexOrderNull;
extern J2DGXColorS10 j2dDefaultTevColor;
extern J2DIndTexCoordScale j2dDefaultIndTexCoordScaleInfo;
extern JUtility::TColor j2dDefaultTevKColor;
extern J2DTevSwapModeInfo j2dDefaultTevSwapMode;
extern u8 j2dDefaultTevSwapModeTable[4];
// j2dDefaultBlendInfo declared earlier in file.
extern const u8 j2dDefaultDither;
// j2dDefaultColorChanInfo declared earlier in file.
extern u8 j2dDefaultTevSwapTable;
// j2dDefaultAlphaCmp declared earlier in file.
enum J2DTextBoxHBinding
{
J2DHBIND_Center = 0,
J2DHBIND_Right = 1,
J2DHBIND_Left = 2,
};
enum J2DTextBoxVBinding
{
J2DVBIND_Center = 0,
J2DVBIND_Bottom = 1,
J2DVBIND_Top = 2,
};
// extern const J2DTexCoordInfo j2dDefaultTexCoordInfo[8];
#endif
+32
View File
@@ -0,0 +1,32 @@
#ifndef J3DTYPES_H
#define J3DTYPES_H
#include "types.h"
enum JBlockType {
JBT_ColorAmbientOn = 'CLAB',
JBT_ColorNull = 'CLNL',
JBT_ColorLightOff = 'CLOF',
JBT_ColorLightOn = 'CLON',
JBT_IndFull = 'IBLF',
JBT_IndNull = 'IBLN',
JBT_PETexEdge = 'PEED',
JBT_PEFogOff = 'PEFG',
JBT_PEFull = 'PEFL',
JBT_PENull = 'PENL',
JBT_PEOpa = 'PEOP',
JBT_PEXlu = 'PEXL',
JBT_TexGen4 = 'TGB4',
JBT_TexGenBasic = 'TGBC',
JBT_TexGenNull = 'TGNL',
JBT_TexGenPatched = 'TGPT',
JBT_Tev16 = 'TV16',
JBT_Tev1 = 'TVB1',
JBT_Tev2 = 'TVB2',
JBT_Tev4 = 'TVB4',
JBT_Tev8 = 'TVB8',
JBT_TevNull = 'TVNL',
JBT_TevPatched = 'TVPT'
};
#endif
+16 -16
View File
@@ -245,50 +245,50 @@ public:
TNodeLinkList::const_iterator mIt;
};
iterator begin() { return TNodeLinkList::begin(); }
const_iterator begin() const { return const_cast<TLinkList*>(this)->begin(); }
inline iterator begin() { return TNodeLinkList::begin(); }
inline const_iterator begin() const { return const_cast<TLinkList*>(this)->begin(); }
iterator end() { return TNodeLinkList::end(); }
const_iterator end() const { return const_cast<TLinkList*>(this)->end(); }
inline iterator end() { return TNodeLinkList::end(); }
inline const_iterator end() const { return const_cast<TLinkList*>(this)->end(); }
iterator Find(const T* p) { return TNodeLinkList::Find(TLinkList::Element_toNode(p)); }
iterator Erase(T* p) { return TNodeLinkList::Erase(Element_toNode(p)); }
iterator Insert(iterator it, T *p) { return TNodeLinkList::Insert(it.mIt, TLinkList::Element_toNode(p)); }
void Remove(T* p) { TNodeLinkList::Remove(TLinkList::Element_toNode(p)); }
void Push_front(T* p) { Insert(begin(), p); }
void Push_back(T* p) { Insert(end(), p); }
inline iterator Find(const T* p) { return TNodeLinkList::Find(TLinkList::Element_toNode(p)); }
inline iterator Erase(T* p) { return TNodeLinkList::Erase(Element_toNode(p)); }
inline iterator Insert(iterator it, T *p) { return TNodeLinkList::Insert(it.mIt, TLinkList::Element_toNode(p)); }
inline void Remove(T* p) { TNodeLinkList::Remove(TLinkList::Element_toNode(p)); }
inline void Push_front(T* p) { Insert(begin(), p); }
inline void Push_back(T* p) { Insert(end(), p); }
T& front() {
inline T& front() {
#line 642
JUT_ASSERT(!empty());
return *begin();
}
T& back() {
inline T& back() {
#line 652
JUT_ASSERT(!empty());
return *--end();
}
static TLinkListNode* Element_toNode(T* p) {
static inline TLinkListNode* Element_toNode(T* p) {
#line 753
JUT_ASSERT(p!=0);
return (TLinkListNode*)((char*)p - O);
}
static const TLinkListNode* Element_toNode(const T* p) {
static inline const TLinkListNode* Element_toNode(const T* p) {
#line 758
JUT_ASSERT(p!=0);
return (const TLinkListNode*)((const char*)p - O);
}
static T* Element_toValue(TLinkListNode* p) {
static inline T* Element_toValue(TLinkListNode* p) {
#line 763
JUT_ASSERT(p!=0);
return (T*)((char*)p + O);
}
static const T* Element_toValue(const TLinkListNode* p) {
static inline const T* Element_toValue(const TLinkListNode* p) {
#line 768
JUT_ASSERT(p!=0);
return (const T*)((const char*)p + O);
+9
View File
@@ -0,0 +1,9 @@
#ifndef JGEOMETRY_H
#define JGEOMETRY_H
#include "JSystem/JGeometry/Vec.h"
#include "JSystem/JGeometry/Box.h"
#include "JSystem/JGeometry/Util.h"
#endif
#endif
+1 -1
View File
@@ -6,11 +6,11 @@
#include "dolphin/os/OSThread.h"
#include "dolphin/os/OSTime.h"
#include "JSystem/JSupport/JSUList.h"
#include "JSystem/JUtility/JUTConsole.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JKernel/JKRDisposer.h"
struct JKRThread;
class JUTConsole;
struct JKRThreadName_
{
+29
View File
@@ -0,0 +1,29 @@
#ifndef JMACRO_H
#define JMACRO_H
#include "dolphin/os.h"
#include "libforest/osreport.h"
#define JLOG(msg) (OSReport(msg))
#define JLOGF(msg, ...) (OSReport(msg, __VA_ARGS__))
/* Macros which will remove debug OSReport calls when not compiled for debug */
#ifdef JSYSTEM_DEBUG
#define JREPORT(msg) OSReport(msg)
#define JREPORTF(msg, ...) OSReport(msg, __VA_ARGS__)
#else
#define JREPORT(msg)
#define JREPORTF(msg, ...)
#endif
#ifdef JSYSTEM_DEBUG
#define JPANICLINE(line) ()
#define JPANIC(line, msg) () /* TODO: JUTException */
#define JPANICF(line, msg, ...) () /* TODO: JUTException */
#else
#define JPANICLINE(line) (OSErrorLine(line, "Abort."))
#define JPANIC(line, msg) (OSErrorLine(line, msg))
#define JPANICF(line, msg, ...) (OSErrorLine(line, msg, __VA_ARGS__))
#endif
#endif
+1 -24
View File
@@ -1,31 +1,8 @@
#ifndef JSYSTEM_H
#define JSYSTEM_H
#include "dolphin/os.h"
#include "libforest/osreport.h"
#include "JSystem/JKernel/JKRAram.h"
#include "JSystem/JMacro.h"
//#include "JSystem/JUtility/JUTException.h"
#define JLOG(msg) (OSReport(msg))
#define JLOGF(msg, ...) (OSReport(msg, __VA_ARGS__))
/* Macros which will remove debug OSReport calls when not compiled for debug */
#ifdef JSYSTEM_DEBUG
#define JREPORT(msg) OSReport(msg)
#define JREPORTF(msg, ...) OSReport(msg, __VA_ARGS__)
#else
#define JREPORT(msg)
#define JREPORTF(msg, ...)
#endif
#ifdef JSYSTEM_DEBUG
#define JPANICLINE(line) ()
#define JPANIC(line, msg) () /* TODO: JUTException */
#define JPANICF(line, msg, ...) () /* TODO: JUTException */
#else
#define JPANICLINE(line) (OSErrorLine(line, "Abort."))
#define JPANIC(line, msg) (OSErrorLine(line, msg))
#define JPANICF(line, msg, ...) (OSErrorLine(line, msg, __VA_ARGS__))
#endif
#endif
+149 -14
View File
@@ -2,27 +2,162 @@
#define _JSYSTEM_JUT_JUTCONSOLE_H
#include "va_args.h"
#include "JSystem/JGadget/linklist.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JUtility/JUTFont.h"
#include "JSystem/JUtility/JUTConsoleExtern.h"
class JUTConsole; // TODO
#ifdef __cplusplus
extern "C"
inline s32 colorCheck(s32 diff, s32 t)
{
#endif
void JUTConsole_print_f_va_(JUTConsole*, const char*, va_list);
s32 ret = diff - t;
return ret + 1;
}
class JUTConsole : public JKRDisposer
{
public:
enum EConsoleType
{
CONSOLE_TYPE_0 = 0,
CONSOLE_TYPE_1 = 1,
CONSOLE_TYPE_2 = 2,
};
enum OutputFlag
{
/* 0x0 */ OUTPUT_NONE,
/* 0x1 */ OUTPUT_OSREPORT,
/* 0x2 */ OUTPUT_CONSOLE,
/* 0x3 */ OUTPUT_OSR_AND_CONSOLE,
};
virtual ~JUTConsole(); // _08
// _00 VTBL
static JUTConsole *create(uint, uint, JKRHeap *);
static JUTConsole *create(uint, void *, u32);
static void destroy(JUTConsole *); // UNUSED
JUTConsole(uint, uint, bool);
static size_t getObjectSizeFromBufferSize(uint, uint);
static size_t getLineFromObjectSize(u32, uint);
void clear();
void doDraw(JUTConsole::EConsoleType) const;
void print_f(char const *, ...);
void print(char const *);
void dumpToTerminal(uint);
void scroll(int);
int getUsedLine() const;
int getLineOffset() const;
void setOutput(uint output) { mOutput = output; }
void setPosition(int x, int y)
{
mPositionX = x;
mPositionY = y;
}
void setFontSize(f32 x, f32 y)
{
mFontSizeX = x;
mFontSizeY = y;
}
void setHeight(u32 height)
{
mHeight = height;
if (mHeight > mMaxLines)
{
mHeight = mMaxLines;
}
}
void setFont(JUTFont *p_font)
{
mFont = p_font;
setFontSize(p_font->getWidth(), p_font->getHeight());
}
int nextIndex(int index) const
{
return ++index >= (int)mMaxLines ? 0 : index;
}
u32 getOutput() const { return mOutput; }
int getPositionY() const { return mPositionY; }
int getPositionX() const { return mPositionX; }
u32 getHeight() const { return mHeight; }
bool isVisible() const { return mIsVisible; }
void setVisible(bool visible) { mIsVisible = visible; }
void setLineAttr(int param_0, u8 param_1) { mBuf[(_20 + 2) * param_0] = param_1; }
u8 *getLinePtr(int param_0) const { return &mBuf[(_20 + 2) * param_0] + 1; }
int diffIndex(int param_0, int param_1) const
{
int diff = param_1 - param_0;
if (diff >= 0)
{
return diff;
}
return diff += mMaxLines;
}
void scrollToLastLine() { scroll(mMaxLines); }
void scrollToFirstLine() { scroll(-mMaxLines); }
// _00 = VTBL
// _00-_18 = JKRDisposer
JGadget::TLinkListNode mNode; // _18
u32 _20; // _20
u32 mMaxLines; // _24, might be int
u8 *mBuf; // _28
bool _2C; // _2C
int _30; // _30
int _34; // _34
int _38; // _38
int _3C; // _3C
int mPositionX; // _40
int mPositionY; // _44
u32 mHeight; // _48
JUTFont *mFont; // _4C
f32 mFontSizeX; // _50
f32 mFontSizeY; // _54
u32 mOutput; // _58
JUtility::TColor _5C; // _5C
JUtility::TColor _60; // _60
int _64; // _64
bool mIsVisible; // _68
bool _69; // _69
bool _6A; // _6A
bool _6B; // _6B
}; // Size: 0x6C
class JUTConsoleManager
{
public:
JUTConsoleManager();
static JUTConsoleManager *createManager(JKRHeap *);
void appendConsole(JUTConsole *console);
void removeConsole(JUTConsole *console);
void draw() const;
void drawDirect(bool) const;
void setDirectConsole(JUTConsole *);
static JUTConsoleManager *getManager() { return sManager; }
static JUTConsoleManager *sManager;
private:
JGadget::TLinkList<JUTConsole, -24> soLink_; // _00
JUTConsole *mActiveConsole; // _0C
JUTConsole *mDirectConsole; // _10
}; // Size: 0x14
extern "C" {
void JUTConsole_print_f_va_(JUTConsole*, const char*, va_list);
JUTConsole* JUTGetReportConsole();
void JUTSetReportConsole(JUTConsole*);
JUTConsole* JUTGetWarningConsole();
void JUTSetWarningConsole(JUTConsole*);
void JUTReportConsole(const char*);
void JUTReportConsole_f(const char*, ...);
void JUTReportConsole_f_va(const char*, va_list);
void JUTWarningConsole(const char*);
void JUTWarningConsole_f(const char*, ...);
void JUTWarningConsole_f_va(const char*, va_list);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
@@ -0,0 +1,21 @@
#ifndef JUTCONSOLEEXTERN_H
#define JUTCONSOLEEXTERN_H
#include "types.h"
#include "va_args.h"
#ifdef __cplusplus
extern "C"
{
#endif
void JUTReportConsole(const char*);
void JUTReportConsole_f(const char*, ...);
void JUTReportConsole_f_va(const char*, va_list);
void JUTWarningConsole(const char*);
void JUTWarningConsole_f(const char*, ...);
void JUTWarningConsole_f_va(const char*, va_list);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
+62
View File
@@ -0,0 +1,62 @@
#ifndef JUTDIRECTPRINT_H
#define JUTDIRECTPRINT_H
#include "types.h"
#include "va_args.h"
#include "JSystem/JUtility/TColor.h"
class JUTDirectPrint
{
private:
JUTDirectPrint();
public:
static JUTDirectPrint *start();
void erase(int x, int y, int w, int h);
void setCharColor(JUtility::TColor color);
void setCharColor(u8 r, u8 g, u8 b);
void drawChar(int, int, int);
void drawString(u16 x, u16 y, char *text);
void drawString_f(u16 x, u16 y, const char * text, ...);
void changeFrameBuffer(void *framebuffer, u16 w, u16 h );
// Inline/Unused
void printSub(u16, u16, const char *, __va_list_struct *, bool);
void print(u16, u16, const char *, ...);
bool isActive() const { return mFramebuffer != nullptr; }
void *getFrameBuffer() { return mFramebuffer; }
JUtility::TColor getCharColor() const { return mCharColor; }
static JUTDirectPrint *getManager() { return sDirectPrint; }
private:
static u8 sAsciiTable[128];
static u32 sFontData[64];
static u32 sFontData2[77];
static JUTDirectPrint *sDirectPrint;
void *mFramebuffer; // _00
u16 mFbWidth; // _04
u16 mFbHeight; // _06
u16 mStride; // _08, aligned width?
size_t mFbSize; // _0C
u8 _10[0x4]; // _10 - unknown
u16 *mFrameMemory; // _14
JUtility::TColor mCharColor; // _18, Color in RGBA format
u16 mCharColorY; // _1C, 1C-2C = color in YCbCr
u16 mCharColorCb; // _1E
u16 mCharColorCb2; // _20
u16 mCharColorCb4; // _22
u16 mCharColorCr; // _24
u16 mCharColorCr2; // _26
u16 mCharColorCr4; // _28
u16 _2A; // _2A
};
inline void JUTChangeFrameBuffer(void *buffer, u16 height, u16 width)
{
JUTDirectPrint::getManager()->changeFrameBuffer(buffer, width, height);
}
#endif
+369
View File
@@ -0,0 +1,369 @@
#ifndef JUTFONT_H
#define JUTFONT_H
#include "types.h"
#include "dolphin/string.h"
#include "dolphin/gx.h"
#include "dolphin/os.h"
#include "JSystem/JUtility/TColor.h"
struct JKRAramBlock;
struct JKRHeap;
struct ResFONT;
struct JUTFont
{
typedef bool (*IsLeadByte)(int);
struct TWidth
{
u8 w0;
u8 w1;
const TWidth &operator=(const TWidth &other)
{
w0 = other.w0;
w1 = other.w1;
return *this;
}
};
JUTFont();
virtual ~JUTFont() {} // _08
virtual void setGX() = 0; // _0C
virtual void setGX(JUtility::TColor, JUtility::TColor) { setGX(); }; // _10
virtual f32 drawChar_scale(f32, f32, f32, f32, int, bool) = 0; // _14
virtual int getLeading() const = 0; // _18
virtual int getAscent() const = 0; // _1C
virtual int getDescent() const = 0; // _20
virtual int getHeight() const = 0; // _24
virtual int getWidth() const = 0; // _28
virtual void getWidthEntry(int, JUTFont::TWidth *) const = 0; // _2C
virtual int getCellWidth() const { return getWidth(); }; // _30
virtual int getCellHeight() const { return getHeight(); }; // _34
virtual int getFontType() const = 0; // _38
virtual const ResFONT *getResFont() const = 0; // _3C
virtual bool isLeadByte(int) const = 0; // _40
void initialize_state();
void setCharColor(JUtility::TColor);
void setGradColor(JUtility::TColor, JUtility::TColor);
f32 drawString_size_scale(f32, f32, f32, f32, const char *, u32, bool);
void drawString(int posX, int posY, const char *str, bool visible) { drawString_size(posX, posY, str, strlen(str), visible); }
void drawString_size(int posX, int posY, const char *str, u32 len, bool visible)
{
drawString_size_scale(posX, posY, getWidth(), getHeight(), str, len, visible);
}
void drawString_scale(f32 posX, f32 posY, f32 width, f32 height, const char *str, bool visible)
{
drawString_size_scale(posX, posY, width, height, str, strlen(str), visible);
}
int getWidth(int i_no) const
{
TWidth width;
getWidthEntry(i_no, &width);
return width.w0;
}
void setFixedWidth(bool fixed, int width) {
mFixed = fixed;
mFixedWidth = width;
}
bool isValid() const { return mValid; }
static bool isLeadByte_1Byte(int c) { return false; }
static bool isLeadByte_2Byte(int c) { return true; }
static bool isLeadByte_ShiftJIS(int c)
{
return ((c >= 0x81) && (c <= 0x9F)) || ((c >= 0xE0) && (c <= 0xFC));
}
// _00 = VTBL
bool mValid; // _04
bool mFixed; // _05
int mFixedWidth; // _08
JUtility::TColor mColor1; // _0C, bottom left
JUtility::TColor mColor2; // _10, bottom right
JUtility::TColor mColor3; // _14, top left
JUtility::TColor mColor4; // _18, top right
};
struct JUTRomFont : public JUTFont
{
// @fabricatedName
struct AboutEncoding
{
u32 mFontType; // _00
u32 mDataSize; // _04
IsLeadByte mIsLeadByteFunction; // _08
};
JUTRomFont();
JUTRomFont(JKRHeap *);
virtual ~JUTRomFont(); // _08
virtual void setGX(); // _0C
virtual f32 drawChar_scale(f32, f32, f32, f32, int, bool); // _14
virtual int getWidth() const { return spFontHeader_->width; }; // _28
virtual int getLeading() const { return spFontHeader_->leading; }; // _18
virtual int getAscent() const { return spFontHeader_->ascent; }; // _1C
virtual int getDescent() const { return spFontHeader_->descent; }; // _20
virtual int getHeight() const { return getAscent() + getDescent(); }; // _24
virtual void getWidthEntry(int, JUTFont::TWidth *) const; // _2C
virtual int getCellWidth() const { return spFontHeader_->cellWidth; }; // _30
virtual int getCellHeight() const { return spFontHeader_->cellHeight; }; // _34
virtual ResFONT *getResFont() const { return nullptr; }; // _3C
virtual int getFontType() const { return spAboutEncoding_->mFontType; }; // _38
virtual bool isLeadByte(int) const; // _40
void initiate(JKRHeap *);
void loadImage(JKRHeap *);
static AboutEncoding *spAboutEncoding_;
static OSFontHeader *spFontHeader_;
static u32 suFontHeaderRefered_; // they misspelled referred
static AboutEncoding saoAboutEncoding_[2];
// _00 = VTBL
// _00-_1C = JUTFont
};
struct BlockHeader
{
const BlockHeader *getNext() const { return reinterpret_cast<const BlockHeader *>(reinterpret_cast<const u8 *>(this) + this->mSize); }
inline static void advance(const BlockHeader **iterator)
{
*iterator = reinterpret_cast<const BlockHeader *>(reinterpret_cast<const u8 *>(*iterator) + (*iterator)->mSize);
}
u32 mMagic; // _00
u32 mSize; // _04
};
struct ResFONT
{
// INF1, size: 0x14
struct InfoBlock : public BlockHeader
{
// _00 = BlockHeader
u16 mFontType; // _08
u16 mAscent; // _0A
u16 mDescent; // _0C
u16 mWidth; // _0E
u16 mLeading; // _10
u16 mDefaultCode; // _12
};
// WID1, size: 0x10
struct WidthBlock : public BlockHeader
{
// _00 = BlockHeader
u16 mStartCode; // _08
u16 mEndCode; // _0A
JUTFont::TWidth mChunkNum[2]; // _0C
};
// MAP1, size: 0x14
struct MapBlock : public BlockHeader
{
// _00 = BlockHeader
u16 mMappingMethod; // _08
u16 mStartCode; // _0A
u16 mEndCode; // _0C
u16 mNumEntries; // _0E
u16 mLeading; // _10
};
// GLY1, size: 0x20
struct GlyphBlock : public BlockHeader
{
// _00 = BlockHeader
u16 mStartCode; // _08
u16 mEndCode; // _0A
u16 mCellWidth; // _0C
u16 mCellHeight; // _0E
u32 mTextureSize; // _10
u16 mTextureFormat; // _14
u16 mNumRows; // _16
u16 mNumColumns; // _18
u16 mTextureWidth; // _1A
u16 mTextureHeight; // _1C
u16 mPadding; // _1E
u8 mData[]; // _20
};
u64 mMagic; // _00
u32 mFileSize; // _08
u32 mNumBlocks; // _0C
u8 mPadding[0x10]; // _10
u8 mData[]; // _20
};
/**
* @size{0x70}
*/
struct JUTResFont : public JUTFont
{
JUTResFont();
JUTResFont(const ResFONT *, JKRHeap *);
virtual ~JUTResFont(); // _08
virtual void setGX(); // _0C
virtual void setGX(JUtility::TColor, JUtility::TColor); // _10
virtual f32 drawChar_scale(f32, f32, f32, f32, int, bool); // _14
virtual int getDescent() const { return mInfoBlock->mDescent; }; // _20
virtual int getHeight() const { return getAscent() + getDescent(); }; // _24
virtual int getAscent() const { return mInfoBlock->mAscent; }; // _1C
virtual int getWidth() const { return mInfoBlock->mWidth; }; // _28
virtual void getWidthEntry(int, JUTFont::TWidth *) const; // _2C
virtual int getCellWidth() const; // _30
virtual int getCellHeight() const; // _34
virtual int getFontType() const { return mInfoBlock->mFontType; }; // _38
virtual const ResFONT *getResFont() const { return mResource; }; // _3C
virtual int getLeading() const { return mInfoBlock->mLeading; }; // _18
virtual bool isLeadByte(int) const; // _40
virtual void loadImage(int, GXTexMapID); // _44
virtual void setBlock(); // _48
int convertSjis(int, u16 *) const;
void countBlock();
void deleteMemBlocks_ResFont();
int getFontCode(int) const;
void initialize_state();
bool initiate(const ResFONT *, JKRHeap *);
void loadFont(int, GXTexMapID, TWidth *);
bool protected_initiate(const ResFONT *, JKRHeap *);
inline void delete_and_initialize()
{
deleteMemBlocks_ResFont();
initialize_state();
}
static IsLeadByte const saoAboutEncoding_[3];
// _00 = VTBL
// _00-_1C = JUTFont
int mWidth; // _1C
int mHeight; // _20
GXTexObj _24; // _24
int _44; // _44
const ResFONT *mResource; // _48
ResFONT::InfoBlock *mInfoBlock; // _4C, INF1
void **mMemBlocks; // _50
ResFONT::WidthBlock **mWidthBlocks; // _54, WID1
ResFONT::GlyphBlock **mGlyphBlocks; // _58, GLY1
ResFONT::MapBlock **mMapBlocks; // _5C, MAP1
u16 mWidthBlockCount; // _60
u16 mGlyphBlockCount; // _62
u16 mMapBlockCount; // _64
u16 _66; // _66
u16 mMaxCode; // _68
IsLeadByte *mIsLeadByte; // _6C
};
struct JUTCacheFont : public JUTResFont
{
enum EPagingType
{
CFPAGETYPE_Unk0 = 0,
CFPAGETYPE_Unk1 = 1,
};
struct TGlyphCacheInfo
{
// TODO: the rest of the data members
TGlyphCacheInfo *mPrev; // _00
TGlyphCacheInfo *mNext; // _04
u8 _08[4]; // _08
u16 _0C; // _0C
u16 _0E; // _0E
u8 _10[4]; // _10
u16 _14; // _14
u16 _16; // _16
u8 _18[8]; // _18
GXTexObj mGxTexObj; // _20
};
struct TCachePage
{
u8 _00[0x8]; // _00, unknown
s16 _08; // _08
u16 _0A; // _0A
u8 _0C[0x4]; // _0C, unknown
u8 *_10; // _10
u16 _14; // _14
u16 _18; // _18
u16 _1C; // _1C
u16 _20; // _20
u16 _24; // _24
u16 _28; // _28
};
JUTCacheFont();
JUTCacheFont(const ResFONT *, void *, u32, JKRHeap *);
JUTCacheFont(const ResFONT *, u32, JKRHeap *);
virtual ~JUTCacheFont(); // _08
virtual void loadImage(int, _GXTexMapID); // _44
virtual void setBlock(); // _48
bool allocArea(void *, u32, JKRHeap *);
bool allocArray(JKRHeap *);
void deleteMemBlocks_CacheFont();
bool getMemorySize(const ResFONT *, u16 *, u32 *, u16 *, u32 *, u16 *, u32 *, u32 *);
void initialize_state();
bool initiate(const ResFONT *, void *, u32, JKRHeap *);
bool internal_initiate(const ResFONT *, void *, u32, JKRHeap *);
void invalidiateAllCache();
TGlyphCacheInfo *loadCache_char_subroutine(int *, bool);
void loadCache_string(const char *, bool);
void prepend(TGlyphCacheInfo *);
void unlink(TGlyphCacheInfo *);
// Unused/inlined:
void determineBlankPage();
void getGlyphFromAram(TGlyphCacheInfo *, TCachePage *, int *, int *);
void loadCache_char(int, bool);
void loadCache_string_size(const char *, u32, bool);
void unlockCache_all();
void unlockCache_char(int);
void unlockCache_string(const char *);
void unlockCache_string_size(const char *, u32);
void setPagingType(EPagingType type) { mPagingType = type; }
static u32 calcCacheSize(u32 param_0, int param_1) { return (ALIGN_NEXT(param_0, 0x20) + 0x40) * param_1; }
// _00 = VTBL
// _00-_70 = JUTResFont
u32 mWidthBlocksSize; // _70
u32 mGlyphBlocksSize; // _74
u32 mMapBlocksSize; // _78
void *_7C; // _7C
void *_80; // _80
void *_84; // _84
u32 mMaxSheetSize; // _88
EPagingType mPagingType; // _8C
void *mCacheBuffer; // _90
u32 _94; // _94
u32 mCachePage; // _98
TGlyphCacheInfo *_9C; // _9C
TGlyphCacheInfo *_A0; // _A0
void *_A4; // _A4
u32 _A8; // _A8
JKRAramBlock *mAramBlock; // _AC
u8 _B0; // _B0
int _B4; // _B4
};
extern const ResFONT JUTResFONT_Ascfont_fix12;
#endif
+84
View File
@@ -0,0 +1,84 @@
#ifndef JUTVIDEO_H
#define JUTVIDEO_H
#include "types.h"
#include "dolphin/os/OSTime.h"
#include "dolphin/os.h"
#include "dolphin/gx.h"
#include "dolphin/vi.h"
/**
* @size{0x58}
*/
typedef u8 (*Pattern)[2];
struct JUTVideo
{
JUTVideo(const _GXRenderModeObj *);
virtual ~JUTVideo(); // _08
static JUTVideo *createManager(const _GXRenderModeObj *);
static void destroyManager();
static void preRetraceProc(unsigned long);
static void postRetraceProc(unsigned long);
static void drawDoneCallback();
u16 getEfbHeight() const { return mRenderModeObj->efbHeight; }
u16 getFbWidth() const { return mRenderModeObj->fbWidth; }
void getBounds(u16& width, u16& height) const {
width = getFbWidth();
height = getEfbHeight();
}
_GXRenderModeObj *getRenderMode() const { return mRenderModeObj; }
u16 getXfbHeight() const { return mRenderModeObj->xfbHeight; }
u32 isAntiAliasing() const { return mRenderModeObj->aa; }
Pattern getSamplePattern() const { return mRenderModeObj->sample_pattern; }
u8 *getVFilter() const { return mRenderModeObj->vfilter; }
OSMessageQueue *getMessageQueue() { return &mMessageQueue; };
static void drawDoneStart();
static void dummyNoDrawWait();
void setRenderMode(const _GXRenderModeObj *);
void waitRetraceIfNeed(); // blr, global
VIRetraceCallback setPostRetraceCallback(VIRetraceCallback);
// Unused/inlined:
void getDrawWait();
VIRetraceCallback setPreRetraceCallback(VIRetraceCallback);
void getPixelAspect(const _GXRenderModeObj *);
void getPixelAspect() const;
// Static inline gets
static JUTVideo *getManager() { return sManager; }
static OSTick getVideoInterval() { return sVideoInterval; }
static OSTick getVideoLastTick() { return sVideoLastTick; }
// _00 VTBL
GXRenderModeObj *mRenderModeObj; // _04
u32 _08; // _08
u32 mRetraceCount; // _0C
int _10; // _10
u8 _14[4]; // _14
u32 _18; // _18
VIRetraceCallback mPreviousPreRetraceCallback; // _1C
VIRetraceCallback mPreviousPostRetraceCallback; // _20
VIRetraceCallback mPreRetraceCallback; // _24
VIRetraceCallback mPostRetraceCallback; // _28
bool mIsSetBlack; // _2C
s32 mSetBlackFrameCount; // _30
OSMessage mMessage; // _34
OSMessageQueue mMessageQueue; // _38
static JUTVideo *sManager;
static OSTick sVideoLastTick;
static OSTick sVideoInterval;
};
inline JUTVideo *JUTGetVideoManager() {
return JUTVideo::getManager();
}
extern bool sDrawWaiting;
#endif
+1
View File
@@ -7,6 +7,7 @@
#include "dolphin/os/OSMessage.h"
#include "libforest/osreport.h" /* OSReport funcs */
#include "dolphin/os/OSReset.h"
#include "dolphin/os/OSFont.h"
#include "va_args.h"
#ifdef __cplusplus
+39 -3
View File
@@ -7,10 +7,46 @@
extern "C" {
#endif
#define OS_FONT_ANSI 0u
#define OS_FONT_SJIS 1u
typedef struct OSFontHeader {
u16 fontType; // _00
u16 firstChar; // _02, first char code defined in font.
u16 lastChar; // _04, last char code defined in font.
u16 invalChar; // _06, code to sub for invalid chars.
u16 ascent; // _08
u16 descent; // _0A
u16 width; // _0C, max width.
u16 leading; // _0E
u16 cellWidth; // _10
u16 cellHeight; // _12
u32 sheetSize; // _14
u16 sheetFormat; // _18, see GX_TF_* part of GXTexFmt enum
u16 sheetColumn; // _1A
u16 sheetRow; // _1C
u16 sheetWidth; // _1E
u16 sheetHeight; // _20
u16 widthTable; // _22
u32 sheetImage; // _24
u32 sheetFullSize; // _28
u8 c0; // _2C, font color components?
u8 c1; // _2D
u8 c2; // _2E
u8 c3; // _2F
} OSFontHeader;
u16 OSGetFontEncode();
#define OS_FONT_ENCODE_NULL -1
#define OS_FONT_ENCODE_ANSI 0u
#define OS_FONT_ENCODE_SJIS 1u
#define OS_FONT_ENCODE_UTF8 3u // UTF-8 [RFC 3629]
#define OS_FONT_ENCODE_UTF16 4u // UTF-16BE [RFC 2781]
#define OS_FONT_ENCODE_UTF32 5u // UTF-32
#define OS_FONT_ENCODE_MAX 5u
#define OS_FONT_ENCODE_VOID 0xffffu
#define OS_FONT_PROPORTIONAL FALSE
#define OS_FONT_FIXED TRUE
u16 OSGetFontEncode(void);
u16 OSSetFontEncode(u16 encode);
#ifdef __cplusplus
}