Copy JKernel (#126)

* start JSystem

* JKRAram and JUTGamePad

* started heap and thread

* more JKernel

* mostly finished JKernel

* delete unused asm

* JKRFileFinder

* delete unused asm and match findNextFile

* format

* fix mtx_vec
This commit is contained in:
lepelog
2021-05-03 02:03:24 +02:00
committed by GitHub
parent 913bb08f51
commit 0b8db42226
360 changed files with 6646 additions and 12699 deletions
+10
View File
@@ -3,4 +3,14 @@
#include "dolphin/types.h"
// TODO: make it a namespace
struct JUTAssertion {
/* 802E495C */ static void create();
/* 802E4960 */ static void flush_subroutine();
/* 802E499C */ static void flushMessage();
/* 802E4A54 */ static void flushMessage_dbPrint();
/* 802E4C34 */ static void setVisible(bool);
/* 802E4C3C */ static void setMessageCount(int);
};
#endif /* JUTASSERT_H */
+61
View File
@@ -1,6 +1,67 @@
#ifndef JUTEXCEPTION_H
#define JUTEXCEPTION_H
#include "dolphin/gx/GX.h"
#include "dolphin/os/OS.h"
#include "dolphin/types.h"
struct _GXRenderModeObj;
struct _GXGamma {};
struct JUTExternalFB {
/* 802E40CC */ JUTExternalFB(_GXRenderModeObj*, _GXGamma, void*, u32);
};
struct JUTDirectPrint {
/* 802E456C */ void changeFrameBuffer(void*, u16, u16);
};
struct JUTException {
struct EInfoPage {};
// TODO: return types are probably wrong
/* 802E1D5C */ JUTException(JUTDirectPrint*);
/* 802E1E40 */ void create(JUTDirectPrint*);
/* 802E1EA8 */ void run();
/* 802E1FCC */ void errorHandler(u16, OSContext*, u32, u32);
/* 802E20C0 */ void panic_f_va(char const*, int, char const*, __va_list_struct*);
/* 802E21FC */ static void panic_f(char const*, int, char const*, ...);
/* 802E227C */ void setFPException(u32);
/* 802E22C4 */ void showFloatSub(int, f32);
/* 802E2454 */ void showFloat(OSContext*);
/* 802E2578 */ void searchPartialModule(u32, u32*, u32*, u32*, u32*);
/* 802E26B0 */ void showStack(OSContext*);
/* 802E27B0 */ void showMainInfo(u16, OSContext*, u32, u32);
/* 802E2A84 */ void showGPR(OSContext*);
/* 802E2B44 */ void showMapInfo_subroutine(u32, bool);
/* 802E2CA0 */ void showGPRMap(OSContext*);
/* 802E2DAC */ void showSRR0Map(OSContext*);
/* 802E2E70 */ void printDebugInfo(JUTException::EInfoPage, u16, OSContext*, u32, u32);
/* 802E2F18 */ void isEnablePad() const;
/* 802E2F54 */ void readPad(u32*, u32*);
/* 802E34C0 */ void printContext(u16, OSContext*, u32, u32);
/* 802E3980 */ void waitTime(s32);
/* 802E3A08 */ void createFB();
/* 802E3AEC */ void setPreUserCallback(void (*)(u16, OSContext*, u32, u32));
/* 802E3AFC */ void setPostUserCallback(void (*)(u16, OSContext*, u32, u32));
/* 802E3B0C */ void appendMapFile(char const*);
/* 802E3BA0 */ void queryMapAddress(char*, u32, s32, u32*, u32*, char*, u32, bool, bool);
/* 802E3C90 */ void queryMapAddress_single(char*, u32, s32, u32*, u32*, char*, u32, bool, bool);
/* 802E3FEC */ void createConsole(void*, u32);
/* 802E40EC */ ~JUTException();
static u8 sMessageQueue[32];
static void* sCpuExpName[17];
static u8 sMapFileList[12 + 4 /* padding */];
static u8 sMessageBuffer[4 + 4 /* padding */];
static u8 sErrorManager[4];
static u8 sPreUserCallback[4];
static u8 sPostUserCallback[4];
static u8 sConsoleBuffer[4];
static u8 sConsoleBufferSize[4];
static u8 sConsole[4];
static u8 msr[4];
static u8 fpscr[4];
};
#endif /* JUTEXCEPTION_H */
+42 -1
View File
@@ -1,7 +1,7 @@
#ifndef JUTFONT_H
#define JUTFONT_H
#include "dolphin/gx/GXTexture.h"
#include "dolphin/gx/GX.h"
#include "dolphin/types.h"
namespace JUtility {
@@ -21,4 +21,45 @@ struct TColor : _GXColor {
} // namespace JUtility
class JUTFont {
public:
JUTFont();
virtual ~JUTFont() {}
struct TWidth {};
/* 0x0c */ virtual void setGX() = 0;
/* 0x10 */ virtual void setGX(JUtility::TColor col1, JUtility::TColor col2);
/* 0x14 */ virtual f32 drawChar_scale(f32 a1, f32 a2, f32 a3, f32 a4, int a5, bool a6) = 0;
/* 0x18 */ virtual u16 getLeading() const = 0;
/* 0x1c */ virtual u16 getAscent() const = 0;
/* 0x20 */ virtual u16 getDescent() const = 0;
/* 0x24 */ virtual u32 getHeight() const = 0;
/* 0x28 */ virtual u32 getWidth() const = 0;
/* 0x2c */ virtual void getWidthEntry(int i_no, TWidth* width) const;
/* 0x30 */ virtual u32 getCellWidth() const;
/* 0x34 */ virtual u32 getCellHeight() const;
/* 0x38 */ virtual u32 getFontType() const = 0;
/* 0x3c */ virtual void getResFont() const = 0;
/* 0x40 */ virtual bool isLeadByte(int a1) const = 0;
static bool isLeadByte_1Byte(int b);
static bool isLeadByte_2Byte(int b);
static bool isLeadByte_ShiftJIS(int b);
void initialize_state();
void setCharColor(JUtility::TColor col1);
void setGradColor(JUtility::TColor col1, JUtility::TColor col2);
f32 drawString_size_scale(f32 a1, f32 a2, f32 a3, f32 a4, const char* a5, u32 usz, bool a7);
u8 unk4;
bool unk5;
int unk8;
JUtility::TColor mColor1;
JUtility::TColor mColor2;
JUtility::TColor mColor3;
JUtility::TColor mColor4;
int unk1C;
};
#endif /* JUTFONT_H */
+180
View File
@@ -1,6 +1,186 @@
#ifndef JUTGAMEPAD_H
#define JUTGAMEPAD_H
#include "JSystem/JKernel/JKRDisposer.h"
#include "JSystem/JSupport/JSUList.h"
#include "dolphin/os/OS.h"
#include "dolphin/pad/Pad.h"
#include "dolphin/types.h"
typedef void (*callbackFn)(int, void*);
namespace CButton {
enum {
DPAD_LEFT = 0x0001,
DPAD_RIGHT = 0x0002,
DPAD_DOWN = 0x0004,
DPAD_UP = 0x0008,
Z = 0x0010,
R = 0x0020,
L = 0x0040,
A = 0x0100,
B = 0x0200,
X = 0x0400,
Y = 0x0800,
START = 0x1000,
};
}
struct JUTGamePad : public JKRDisposer {
public:
// TODO: fix types
// static JSUList<JUTGamePad> mPadList;
static u8 mPadList[12];
static PADStatus mPadStatus[4];
static u8 mPadButton[192];
static u8 mPadMStick[64];
static u8 mPadSStick[64];
static u32 sStickMode;
static u32 sClampMode;
static u8 mPadAssign[4];
static u8 sSuppressPadReset[4];
static s32 sAnalogMode;
static u8 sRumbleSupported[4];
enum EStickMode {};
enum EWhichStick {};
// typedef u32 EPadPort;
enum EPadPort { Port_1 = 0, Port_2 = 0, Port_3 = 0, Port_4 = 0 };
JUTGamePad(JUTGamePad::EPadPort port);
virtual ~JUTGamePad();
void initList();
static s32 init();
void clear();
void read();
void assign();
void checkResetCallback(OSTime unk); // todo: weird arg
void update();
void stopPatternedRumble() { this->rumble.stopPatternedRumble(this->pad_port); }
static void checkResetSwitch();
static void clearForReset();
static JUTGamePad* getGamePad(int pad_index);
static bool recalibrate(/*PADMask*/ u32 pad_mask);
struct CButton {
CButton();
void clear();
u32 update(PADStatus const*, u32 unk);
void setRepeat(u32 unk0, u32 unk1, u32 unk2);
u32 mButtonFlags;
u32 mPressedButtonFlags;
u32 mReleasedButtonFlags;
u8 mAnalogARaw;
u8 mAnalogBRaw;
u8 mTriggerLeftRaw;
u8 mTriggerRightRaw;
f32 mTriggerLeft;
f32 mTriggerRight;
u32 field_0x18; // padding?
u32 field_0x1c;
u32 field_0x20;
u32 field_0x24;
u32 field_0x28;
u32 field_0x2c;
};
struct C3ButtonReset {
// TODO: fix types
static u32 sResetPattern;
static u32 sResetMaskPattern;
static callbackFn sCallback;
static void* sCallbackArg;
static OSTime sThreshold;
static s32 sResetOccurredPort;
};
struct CStick {
static f32 sPressPoint;
static f32 sReleasePoint;
CStick();
void clear();
void clear(JUTGamePad* pad);
u32 update(s8 unk0, s8 unk1, JUTGamePad::EStickMode mode, JUTGamePad::EWhichStick stick,
u32 unk2);
u32 getButton(u32 unk);
float mPosX;
float mPosY;
float mValue;
s16 mAngle;
s8 field_0xe;
s8 field_0xf;
};
struct CRumble {
static PADMask sChannelMask[4];
static bool mStatus[4];
static PADMask mEnabled;
enum ERumble {
VAL_0 = 0,
VAL_1 = 1,
VAL_2 = 2,
};
void clear();
void clear(JUTGamePad* pad);
static void startMotor(int channel);
static void stopMotor(int channel, bool stop);
void update(s16 unk0);
void triggerPatternedRumble(u32 unk0);
void startPatternedRumble(void* unk0, ERumble rumble, u32 unk1);
void stopPatternedRumble(s16 pad_port);
void stopPatternedRumbleAtThePeriod();
static void setEnabled(/*PADMask*/ u32 pad_mask);
u32 field_0x0;
u32 field_0x4;
u8* field_0x8;
u32 field_0xc;
u8* field_0x10;
};
CButton buttons;
CStick control_stick;
CStick c_stick;
CRumble rumble;
s16 pad_port;
s8 error_value;
u8 pad0;
JSUPtrLink ptr_link;
u8 unk0[8];
u8 field_0x98;
u8 unk1[3];
u8 reset_flag;
u8 pad1[3];
OSTime reset_time;
u8 field_0xa8;
friend class CRumble;
};
struct JUTGamePadLongPress {
// TODO: fix type
// static JSUList<JUTGamePadLongPress> sPatternList;
static u8 sPatternList[12];
void checkCallback(int unk0, u32 unk2);
u8 unk0[17];
bool field_0x11; // bool?
u8 unk1[10];
u32 field_0x1c;
u8 unk2[28];
u8 field_0x3c;
u8 unk3[11];
bool field_0x48[4]; // bool[4]?
void (*callback)(s32, JUTGamePadLongPress*, s32);
s32 field_0x50;
};
#endif /* JUTGAMEPAD_H */
+7
View File
@@ -0,0 +1,7 @@
#ifndef JSYSTEM_JUTILITY_JUTREPORT_H
#define JSYSTEM_JUTILITY_JUTREPORT_H
void JUTReport(int, int, const char*, ...);
void JUTReport(int, int, int, const char*, ...);
#endif
+46
View File
@@ -1,6 +1,52 @@
#ifndef JUTVIDEO_H
#define JUTVIDEO_H
#include "dolphin/gx/GX.h"
#include "dolphin/os/OS.h"
#include "dolphin/types.h"
#include "dolphin/vi/vi.h"
// TODO: placeholder
struct _GXRenderModeObj {};
struct JUTVideo {
static JUTVideo* sManager;
// TODO: figure out type
static u8 sVideoLastTick[4];
static u8 sVideoInterval[4];
JUTVideo(_GXRenderModeObj const*);
virtual ~JUTVideo();
typedef void (*CallbackFn)(void);
// struct JUTVideo_vtable * vtable;
GXRenderModeObj* render_object;
u32 field_0x8;
u32 retrace_count;
u32 field_0x10;
u32 field_0x14;
u32 field_0x18;
VIRetraceCallback pre_retrace_callback;
VIRetraceCallback post_retrace_callback;
CallbackFn unknown_callback_1;
CallbackFn unknown_callback_2;
bool set_black;
u8 padding[3];
s32 set_black_frame_counter;
OSMessage message;
OSMessageQueue message_queue;
// TODO: return types not confirmed
/* 802E4C54 */ void createManager(_GXRenderModeObj const*);
/* 802E4CAC */ void destroyManager();
/* 802E4E50 */ void preRetraceProc(u32);
/* 802E5088 */ void drawDoneStart();
/* 802E50B0 */ void dummyNoDrawWait();
/* 802E50BC */ void drawDoneCallback();
/* 802E5144 */ void postRetraceProc(u32);
/* 802E5198 */ void setRenderMode(_GXRenderModeObj const*);
/* 802E5210 */ void waitRetraceIfNeed();
};
#endif /* JUTVIDEO_H */