mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-08-22 05:49:04 -04:00
Migrate to dtk-template
Co-authored-by: NWPlayer123 <NWPlayer123@users.noreply.github.com>
This commit is contained in:
+48
-43
@@ -14,54 +14,57 @@ extern "C" {
|
||||
typedef void (*GBATransferCallback)(s32 chan);
|
||||
|
||||
typedef struct GBASecParam {
|
||||
u8 readbuf[4];
|
||||
s32 paletteColor;
|
||||
s32 paletteSpeed;
|
||||
s32 length;
|
||||
u32* out;
|
||||
u8 _padding0[12];
|
||||
u32 keyA;
|
||||
s32 keyB;
|
||||
u8 _padding1[24];
|
||||
// total size: 0x40
|
||||
u8 readbuf[4]; // offset 0x0, size 0x4
|
||||
s32 paletteColor; // offset 0x4, size 0x4
|
||||
s32 paletteSpeed; // offset 0x8, size 0x4
|
||||
s32 length; // offset 0xC, size 0x4
|
||||
u32* out; // offset 0x10, size 0x4
|
||||
u8 _padding0[12]; // offset 0x14, size 0xC
|
||||
u32 keyA; // offset 0x20, size 0x4
|
||||
s32 keyB; // offset 0x24, size 0x4
|
||||
u8 _padding1[24]; // offset 0x28, size 0x18
|
||||
} GBASecParam;
|
||||
|
||||
typedef struct GBABootInfo {
|
||||
s32 paletteColor;
|
||||
s32 paletteSpeed;
|
||||
u8* programp;
|
||||
s32 length;
|
||||
u8* status;
|
||||
GBACallback callback;
|
||||
u8 readbuf[4];
|
||||
u8 writebuf[4];
|
||||
int i;
|
||||
OSTick start;
|
||||
OSTime begin;
|
||||
int firstXfer;
|
||||
int curOffset;
|
||||
u32 crc;
|
||||
u32 dummyWord[7];
|
||||
u32 keyA;
|
||||
s32 keyB;
|
||||
u32 initialCode;
|
||||
int realLength;
|
||||
// total size: 0x68
|
||||
s32 paletteColor; // offset 0x0, size 0x4
|
||||
s32 paletteSpeed; // offset 0x4, size 0x4
|
||||
u8* programp; // offset 0x8, size 0x4
|
||||
s32 length; // offset 0xC, size 0x4
|
||||
u8* status; // offset 0x10, size 0x4
|
||||
GBACallback callback; // offset 0x14, size 0x4
|
||||
u8 readbuf[4]; // offset 0x18, size 0x4
|
||||
u8 writebuf[4]; // offset 0x1C, size 0x4
|
||||
int i; // offset 0x20, size 0x4
|
||||
OSTick start; // offset 0x24, size 0x4
|
||||
OSTime begin; // offset 0x28, size 0x8
|
||||
BOOL firstXfer; // offset 0x30, size 0x4
|
||||
int curOffset; // offset 0x34, size 0x4
|
||||
u32 crc; // offset 0x38, size 0x4
|
||||
u32 dummyWord[7]; // offset 0x3C, size 0x1C
|
||||
u32 keyA; // offset 0x58, size 0x4
|
||||
s32 keyB; // offset 0x5C, size 0x4
|
||||
u32 initialCode; // offset 0x60, size 0x4
|
||||
int realLength; // offset 0x64, size 0x4
|
||||
} GBABootInfo;
|
||||
|
||||
typedef struct GBAControl {
|
||||
u8 output[5];
|
||||
u8 input[5];
|
||||
s32 outputBytes;
|
||||
s32 inputBytes;
|
||||
u8* status;
|
||||
u8* ptr;
|
||||
GBACallback callback;
|
||||
s32 ret;
|
||||
OSThreadQueue threadQueue;
|
||||
OSTime delay;
|
||||
GBATransferCallback proc;
|
||||
GBABootInfo bootInfo;
|
||||
DSPTaskInfo task;
|
||||
GBASecParam* param;
|
||||
// total size: 0x100
|
||||
u8 output[5]; // offset 0x0, size 0x5
|
||||
u8 input[5]; // offset 0x5, size 0x5
|
||||
u32 outputBytes; // offset 0xC, size 0x4
|
||||
u32 inputBytes; // offset 0x10, size 0x4
|
||||
u8* status; // offset 0x14, size 0x4
|
||||
void* ptr; // offset 0x18, size 0x4
|
||||
GBACallback callback; // offset 0x1C, size 0x4
|
||||
s32 ret; // offset 0x20, size 0x4
|
||||
OSThreadQueue threadQueue; // offset 0x24, size 0x8
|
||||
OSTime delay; // offset 0x30, size 0x8
|
||||
GBATransferCallback proc; // offset 0x38, size 0x4
|
||||
GBABootInfo bootInfo; // offset 0x40, size 0x68
|
||||
DSPTaskInfo task; // offset 0xA8, size 0x50
|
||||
GBASecParam * param; // offset 0xF8, size 0x4
|
||||
} GBAControl;
|
||||
|
||||
extern GBAControl __GBA[4];
|
||||
@@ -71,7 +74,9 @@ void __GBAHandler(s32 chan, u32 error, OSContext* context);
|
||||
void __GBASyncCallback(s32 chan, s32 ret);
|
||||
s32 __GBASync(s32 chan);
|
||||
OSTime __GBASetDelay(s32 chan, OSTime delay);
|
||||
s32 __GBATransfer(s32 chan, s32 w1, s32 w2, GBATransferCallback callback);
|
||||
s32 __GBATransfer(s32 chan, u32 outputBytes, u32 inputBytes, GBATransferCallback proc);
|
||||
void __GBAX01(s32 chan, s32 ret);
|
||||
void __GBAX02(s32 chan, u8* readbuf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+6
-3
@@ -13,7 +13,7 @@ extern "C" {
|
||||
#define GBA_CHAN3 3
|
||||
#define GBA_MAX_CHAN 4
|
||||
|
||||
#define GBA_ALL_KEY_MASK 0x03ff
|
||||
#define GBA_ALL_KEY_MASK 0x03FF
|
||||
#define GBA_A_BUTTON 0x0001
|
||||
#define GBA_B_BUTTON 0x0002
|
||||
#define GBA_SELECT_BUTTON 0x0004
|
||||
@@ -25,7 +25,7 @@ extern "C" {
|
||||
#define GBA_R_BUTTON 0x0100
|
||||
#define GBA_L_BUTTON 0x0200
|
||||
|
||||
#define GBA_JSTAT_MASK 0x3a
|
||||
#define GBA_JSTAT_MASK 0x3A
|
||||
#define GBA_JSTAT_FLAGS_SHIFT 4
|
||||
#define GBA_JSTAT_FLAGS_MASK 0x30
|
||||
#define GBA_JSTAT_PSF1 0x20
|
||||
@@ -41,9 +41,11 @@ extern "C" {
|
||||
|
||||
#define GBA_JOYBOOT_PROGRAM_SIZE_MAX 0x40000
|
||||
|
||||
#define GBA_JOYBOOT_BOOTPARAM_OFFSET 0xc8
|
||||
#define GBA_JOYBOOT_BOOTPARAM_OFFSET 0xC8
|
||||
#define GBA_JOYBOOT_BOOTPARAM_SIZE 0x18
|
||||
|
||||
typedef void (*GBACallback)(s32 chan, s32 ret);
|
||||
|
||||
void GBAInit(void);
|
||||
s32 GBAGetStatus(s32 chan, u8* status);
|
||||
s32 GBAGetStatusAsync(s32 chan, u8* status, GBACallback callback);
|
||||
@@ -58,6 +60,7 @@ s32 GBAJoyBoot(s32 chan, s32 palette_color, s32 palette_speed, u8* programp, s32
|
||||
u8* status);
|
||||
s32 GBAJoyBootAsync(s32 chan, s32 palette_color, s32 palette_speed, u8* programp, s32 length,
|
||||
u8* status, GBACallback callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -25,24 +25,12 @@ private:
|
||||
int mLine;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#define JGADGET_ASSERTWARN(cond) \
|
||||
((cond) || ((JGadget_outMessage(JGadget_outMessage::warning, __FILE__, __LINE__) << (#cond)), false))
|
||||
|
||||
#define JGADGET_EXITWARN(cond) \
|
||||
if (!(cond)) { JGadget_outMessage(JGadget_outMessage::warning, __FILE__, __LINE__) << (#cond), false; return false; }
|
||||
|
||||
#else
|
||||
|
||||
#define JGADGET_ASSERTWARN(cond) \
|
||||
((cond) || (false))
|
||||
|
||||
#define JGADGET_EXITWARN(cond) \
|
||||
if (!(cond)) { false; return false; }
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ public:
|
||||
}
|
||||
|
||||
TLinkListNode& operator*() const {
|
||||
JUT_ASSERT(p_!=0);
|
||||
return *this->p_;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
class JSUPtrLink;
|
||||
|
||||
class JSUPtrList
|
||||
@@ -174,11 +171,11 @@ public:
|
||||
bool insertChild(JSUTree<T> *before, JSUTree<T> *child) { return this->insert(before, child); }
|
||||
|
||||
JSUTree<T> *getEndChild() const { return nullptr; }
|
||||
JSUTree<T> *getFirstChild() const { return (JSUTree<T> *)getFirstLink(); }
|
||||
JSUTree<T> *getFirstChild() const { return (JSUTree<T> *)this->getFirstLink(); }
|
||||
JSUTree<T> *getLastChild() const { return (JSUTree<T> *)this->getLast(); }
|
||||
JSUTree<T> *getNextChild() const { return (JSUTree<T> *)mNext; }
|
||||
JSUTree<T> *getNextChild() const { return (JSUTree<T> *)this->mNext; }
|
||||
JSUTree<T> *getPrevChild() const { return (JSUTree<T> *)this->getPrev(); }
|
||||
u32 getNumChildren() const { return mLinkCount; }
|
||||
u32 getNumChildren() const { return this->mLinkCount; }
|
||||
T *getObject() const { return (T *)this->mData; }
|
||||
JSUTree<T> *getParent() const { return (JSUTree<T> *)this->mPtrList; }
|
||||
};
|
||||
@@ -223,7 +220,4 @@ private:
|
||||
JSUTree<T> *mTree;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* JSULIST_H */
|
||||
#endif /* JSULIST_H */
|
||||
|
||||
@@ -44,22 +44,8 @@ namespace JUTAssertion
|
||||
#define JUT_MINMAX_ASSERT(...)
|
||||
#define JUT_MAX_ASSERT(...)
|
||||
#define JUT_LOG_F(...)
|
||||
|
||||
#if defined(DEBUG) || 1
|
||||
#define JUT_ASSERT(...)
|
||||
#define JUT_ASSERT_F(...)
|
||||
#else
|
||||
|
||||
#define JUT_ASSERT(COND) \
|
||||
((COND)) ? (void)0 : (JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, __LINE__, #COND), OSHalt("Halt"));
|
||||
|
||||
#define JUT_ASSERT_F(COND, ...) \
|
||||
if ((COND) == false) \
|
||||
{ \
|
||||
JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), __FILE__, __LINE__, __VA_ARGS__); \
|
||||
OSHalt("Halt"); \
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
#ifndef _JSYSTEM_JUT_JUTDBPRINT_H
|
||||
#define _JSYSTEM_JUT_JUTDBPRINT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void* JC_JUTDbPrint_getManager(void);
|
||||
void JC_JUTDbPrint_setVisible(void*, int); // I know these are C++ but these were used to match a c function so I'll fix these when I need them or fix zurumode update.
|
||||
|
||||
void JUTReport(int x, int y, int show_count, const char* fmt, ...);
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef RAND_H
|
||||
#define RAND_H
|
||||
#include "types.h"
|
||||
|
||||
void srand(u32 seed);
|
||||
int rand(void);
|
||||
|
||||
#endif
|
||||
#ifndef RAND_H
|
||||
#define RAND_H
|
||||
#include "types.h"
|
||||
|
||||
void srand(u32 seed);
|
||||
int rand(void);
|
||||
|
||||
#endif
|
||||
|
||||
+21
-21
@@ -1,22 +1,22 @@
|
||||
#ifndef _MEM_H
|
||||
#define _MEM_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma section code_type ".init"
|
||||
|
||||
void * memcpy(void * dst, const void * src, size_t n);
|
||||
void * memset(void * dst, int val, size_t n);
|
||||
int memcmp(const void* src1, const void* src2, size_t n);
|
||||
void __fill_mem(void * dst, int val, unsigned long n);
|
||||
|
||||
#pragma section code_type
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#ifndef _MEM_H
|
||||
#define _MEM_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma section code_type ".init"
|
||||
|
||||
void * memcpy(void * dst, const void * src, size_t n);
|
||||
void * memset(void * dst, int val, size_t n);
|
||||
int memcmp(const void* src1, const void* src2, size_t n);
|
||||
void __fill_mem(void * dst, int val, unsigned long n);
|
||||
|
||||
#pragma section code_type
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#define BOOTDATA_H
|
||||
|
||||
#include "types.h"
|
||||
#include "PR/mbi.h"
|
||||
#include "PR/gbi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#ifndef PPCARCH_H
|
||||
#define PPCARCH_H
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
u32 PPCMfmsr(void);
|
||||
void PPCMtmsr(u32);
|
||||
|
||||
u32 PPCMfhid0(void);
|
||||
void PPCMthid0(u32);
|
||||
|
||||
u32 PPCMfl2cr(void);
|
||||
void PPCMtl2cr(u32);
|
||||
|
||||
void PPCMtdec(u32);
|
||||
|
||||
void PPCSync(void);
|
||||
void PPCHalt(void);
|
||||
|
||||
u32 PPCMfhid2(void);
|
||||
void PPCMthid2(u32);
|
||||
|
||||
|
||||
void PPCMtwpar(u32);
|
||||
|
||||
void PPCDisableSpeculation(void);
|
||||
void PPCSetFpNonIEEEMode(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,100 @@
|
||||
#ifndef PPCARCH_H
|
||||
#define PPCARCH_H
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
u32 PPCMfmsr(void);
|
||||
void PPCMtmsr(u32);
|
||||
|
||||
u32 PPCMfhid0(void);
|
||||
void PPCMthid0(u32);
|
||||
|
||||
u32 PPCMfl2cr(void);
|
||||
void PPCMtl2cr(u32);
|
||||
|
||||
void PPCMtdec(u32);
|
||||
|
||||
void PPCSync(void);
|
||||
void PPCHalt(void);
|
||||
|
||||
u32 PPCMfhid2(void);
|
||||
void PPCMthid2(u32);
|
||||
|
||||
|
||||
void PPCMtwpar(u32);
|
||||
|
||||
void PPCDisableSpeculation(void);
|
||||
void PPCSetFpNonIEEEMode(void);
|
||||
|
||||
#define HID0_EMCP 0x80000000u // Enable MCP
|
||||
#define HID0_DBP 0x40000000u // Enable 60x bus address and data parity chk
|
||||
#define HID0_EBA 0x20000000u // Enable 60x address parity checking
|
||||
#define HID0_EBD 0x10000000u // Enable 60x data parity checking
|
||||
#define HID0_BCLK 0x08000000u // CLK_OUT output enable and clk selection
|
||||
#define HID0_ECLK 0x02000000u // CLK_OUT output enable and clk selection
|
||||
#define HID0_PAR 0x01000000u // Disable !ARTRY precharge
|
||||
#define HID0_DOZE 0x00800000u // Doze mode enable
|
||||
#define HID0_NAP 0x00400000u // Nap mode enable
|
||||
#define HID0_SLEEP 0x00200000u // Sleep mode enable
|
||||
#define HID0_DPM 0x00100000u // Dynamic power management enable
|
||||
#define HID0_NHR 0x00010000u // Not hard reset (0 hard reset if s/w set it)
|
||||
#define HID0_ICE 0x00008000u // Instruction cache enable
|
||||
#define HID0_DCE 0x00004000u // Data cache enable
|
||||
#define HID0_ILOCK 0x00002000u // ICache lock
|
||||
#define HID0_DLOCK 0x00001000u // DCache lock
|
||||
#define HID0_ICFI 0x00000800u // ICache flash invalidate
|
||||
#define HID0_DCFI 0x00000400u // DCache flash invalidate
|
||||
#define HID0_SPD 0x00000200u // Speculative cache access enable (0 enable)
|
||||
#define HID0_IFEM 0x00000100u // Enable M bit on bus for Ifetch
|
||||
#define HID0_SGE 0x00000080u // Store gathering enable
|
||||
#define HID0_DCFA 0x00000040u // DCache flush assist - set before a flush
|
||||
#define HID0_BTIC 0x00000020u // Branch target icache enable
|
||||
#define HID0_ABE 0x00000008u // Address bcast enable
|
||||
#define HID0_BHT 0x00000004u // Branch history table enable
|
||||
#define HID0_NOOPTI 0x00000001u // No-op Dcache touch instructions
|
||||
|
||||
#define HID2_DCHERR 0x00800000 // ERROR: dcbz_l cache hit
|
||||
#define HID2_DNCERR 0x00400000 // ERROR: DMA access to normal cache
|
||||
#define HID2_DCMERR 0x00200000 // ERROR: DMA cache miss error
|
||||
#define HID2_DQOERR 0x00100000 // ERROR: DMA queue overflow
|
||||
#define HID2_DCHEE 0x00080000 // dcbz_l cache hit error enable
|
||||
#define HID2_DNCEE 0x00040000 // DMA access to normal cache error enable
|
||||
#define HID2_DCMEE 0x00020000 // DMA cache miss error error enable
|
||||
#define HID2_DQOEE 0x00010000 // DMA queue overflow error enable
|
||||
|
||||
#define SRR1_DMA_BIT 0x00200000
|
||||
#define SRR1_L2DP_BIT 0x00100000
|
||||
|
||||
#define L2CR_L2E 0x80000000 // L2 Enable
|
||||
#define L2CR_L2PE 0x40000000 // L2 data parity generation and checking enable
|
||||
|
||||
#define L2CR_L2DO 0x00400000 // Data only
|
||||
#define L2CR_L2I 0x00200000 // Global invalidate
|
||||
#define L2CR_L2CTL 0x00100000 // ZZ enable
|
||||
#define L2CR_L2WT 0x00080000 // L2 write through
|
||||
#define L2CR_L2TS 0x00040000 // L2 test support
|
||||
|
||||
#define MSR_POW 0x00040000 // Power Management
|
||||
#define MSR_ILE 0x00010000 // Interrupt Little Endian
|
||||
#define MSR_EE 0x00008000 // external interrupt
|
||||
#define MSR_PR 0x00004000 // privilege level(should be 0)
|
||||
#define MSR_FP 0x00002000 // floating point available
|
||||
#define MSR_ME 0x00001000 // machine check enable
|
||||
#define MSR_FE0 0x00000800 // floating point exception enable
|
||||
#define MSR_SE 0x00000400 // single step trace enable
|
||||
#define MSR_BE 0x00000200 // branch trace enable
|
||||
#define MSR_FE1 0x00000100 // floating point exception enable
|
||||
#define MSR_IP 0x00000040 // Exception prefix
|
||||
#define MSR_IR 0x00000020 // instruction relocate
|
||||
#define MSR_DR 0x00000010 // data relocate
|
||||
#define MSR_PM 0x00000004 // Performance monitor marked mode
|
||||
#define MSR_RI 0x00000002 // Recoverable interrupt
|
||||
#define MSR_LE 0x00000001 // Little Endian
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef OS_AUDIO_SYSTEM_H
|
||||
#define OS_AUDIO_SYSTEM_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#endif
|
||||
+161
-33
@@ -1,45 +1,173 @@
|
||||
#ifndef OS_CONTEXT_H
|
||||
#define OS_CONTEXT_H
|
||||
#ifndef _DOLPHIN_OSCONTEXT_H_
|
||||
#define _DOLPHIN_OSCONTEXT_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OSContext{
|
||||
u32 gprs[32];
|
||||
u32 cr;
|
||||
u32 lr;
|
||||
u32 ctr;
|
||||
u32 xer;
|
||||
f64 fprs[32];
|
||||
u32 fpscr_tmp;
|
||||
u32 fpscr;
|
||||
u32 srr0;
|
||||
u32 srr1;
|
||||
u16 mode;
|
||||
u16 state;
|
||||
u32 gqrs[8];
|
||||
char UNK_0x1C4;
|
||||
f64 psfs[32];
|
||||
#define __OS_CONTEXT_FRAME 768
|
||||
|
||||
#define OS_CONTEXT_R0 0
|
||||
#define OS_CONTEXT_R1 4
|
||||
#define OS_CONTEXT_R2 8
|
||||
#define OS_CONTEXT_R3 12
|
||||
#define OS_CONTEXT_R4 16
|
||||
#define OS_CONTEXT_R5 20
|
||||
#define OS_CONTEXT_R6 24
|
||||
#define OS_CONTEXT_R7 28
|
||||
#define OS_CONTEXT_R8 32
|
||||
#define OS_CONTEXT_R9 36
|
||||
#define OS_CONTEXT_R10 40
|
||||
#define OS_CONTEXT_R11 44
|
||||
#define OS_CONTEXT_R12 48
|
||||
#define OS_CONTEXT_R13 52
|
||||
#define OS_CONTEXT_R14 56
|
||||
#define OS_CONTEXT_R15 60
|
||||
#define OS_CONTEXT_R16 64
|
||||
#define OS_CONTEXT_R17 68
|
||||
#define OS_CONTEXT_R18 72
|
||||
#define OS_CONTEXT_R19 76
|
||||
#define OS_CONTEXT_R20 80
|
||||
#define OS_CONTEXT_R21 84
|
||||
#define OS_CONTEXT_R22 88
|
||||
#define OS_CONTEXT_R23 92
|
||||
#define OS_CONTEXT_R24 96
|
||||
#define OS_CONTEXT_R25 100
|
||||
#define OS_CONTEXT_R26 104
|
||||
#define OS_CONTEXT_R27 108
|
||||
#define OS_CONTEXT_R28 112
|
||||
#define OS_CONTEXT_R29 116
|
||||
#define OS_CONTEXT_R30 120
|
||||
#define OS_CONTEXT_R31 124
|
||||
|
||||
#define OS_CONTEXT_CR 128
|
||||
#define OS_CONTEXT_LR 132
|
||||
#define OS_CONTEXT_CTR 136
|
||||
#define OS_CONTEXT_XER 140
|
||||
|
||||
#define OS_CONTEXT_FPR0 144
|
||||
#define OS_CONTEXT_FPR1 152
|
||||
#define OS_CONTEXT_FPR2 160
|
||||
#define OS_CONTEXT_FPR3 168
|
||||
#define OS_CONTEXT_FPR4 176
|
||||
#define OS_CONTEXT_FPR5 184
|
||||
#define OS_CONTEXT_FPR6 192
|
||||
#define OS_CONTEXT_FPR7 200
|
||||
#define OS_CONTEXT_FPR8 208
|
||||
#define OS_CONTEXT_FPR9 216
|
||||
#define OS_CONTEXT_FPR10 224
|
||||
#define OS_CONTEXT_FPR11 232
|
||||
#define OS_CONTEXT_FPR12 240
|
||||
#define OS_CONTEXT_FPR13 248
|
||||
#define OS_CONTEXT_FPR14 256
|
||||
#define OS_CONTEXT_FPR15 264
|
||||
#define OS_CONTEXT_FPR16 272
|
||||
#define OS_CONTEXT_FPR17 280
|
||||
#define OS_CONTEXT_FPR18 288
|
||||
#define OS_CONTEXT_FPR19 296
|
||||
#define OS_CONTEXT_FPR20 304
|
||||
#define OS_CONTEXT_FPR21 312
|
||||
#define OS_CONTEXT_FPR22 320
|
||||
#define OS_CONTEXT_FPR23 328
|
||||
#define OS_CONTEXT_FPR24 336
|
||||
#define OS_CONTEXT_FPR25 344
|
||||
#define OS_CONTEXT_FPR26 352
|
||||
#define OS_CONTEXT_FPR27 360
|
||||
#define OS_CONTEXT_FPR28 368
|
||||
#define OS_CONTEXT_FPR29 376
|
||||
#define OS_CONTEXT_FPR30 384
|
||||
#define OS_CONTEXT_FPR31 392
|
||||
|
||||
#define OS_CONTEXT_FPSCR 400
|
||||
|
||||
#define OS_CONTEXT_SRR0 408
|
||||
#define OS_CONTEXT_SRR1 412
|
||||
|
||||
#define OS_CONTEXT_MODE 416
|
||||
#define OS_CONTEXT_STATE 418
|
||||
|
||||
#define OS_CONTEXT_GQR0 420
|
||||
#define OS_CONTEXT_GQR1 424
|
||||
#define OS_CONTEXT_GQR2 428
|
||||
#define OS_CONTEXT_GQR3 432
|
||||
#define OS_CONTEXT_GQR4 436
|
||||
#define OS_CONTEXT_GQR5 440
|
||||
#define OS_CONTEXT_GQR6 444
|
||||
#define OS_CONTEXT_GQR7 448
|
||||
#define __OSCONTEXT_PADDING 452
|
||||
|
||||
#define OS_CONTEXT_PSF0 456
|
||||
#define OS_CONTEXT_PSF1 464
|
||||
#define OS_CONTEXT_PSF2 472
|
||||
#define OS_CONTEXT_PSF3 480
|
||||
#define OS_CONTEXT_PSF4 488
|
||||
#define OS_CONTEXT_PSF5 496
|
||||
#define OS_CONTEXT_PSF6 504
|
||||
#define OS_CONTEXT_PSF7 512
|
||||
#define OS_CONTEXT_PSF8 520
|
||||
#define OS_CONTEXT_PSF9 528
|
||||
#define OS_CONTEXT_PSF10 536
|
||||
#define OS_CONTEXT_PSF11 544
|
||||
#define OS_CONTEXT_PSF12 552
|
||||
#define OS_CONTEXT_PSF13 560
|
||||
#define OS_CONTEXT_PSF14 568
|
||||
#define OS_CONTEXT_PSF15 576
|
||||
#define OS_CONTEXT_PSF16 584
|
||||
#define OS_CONTEXT_PSF17 592
|
||||
#define OS_CONTEXT_PSF18 600
|
||||
#define OS_CONTEXT_PSF19 608
|
||||
#define OS_CONTEXT_PSF20 616
|
||||
#define OS_CONTEXT_PSF21 624
|
||||
#define OS_CONTEXT_PSF22 632
|
||||
#define OS_CONTEXT_PSF23 640
|
||||
#define OS_CONTEXT_PSF24 648
|
||||
#define OS_CONTEXT_PSF25 656
|
||||
#define OS_CONTEXT_PSF26 664
|
||||
#define OS_CONTEXT_PSF27 672
|
||||
#define OS_CONTEXT_PSF28 680
|
||||
#define OS_CONTEXT_PSF29 688
|
||||
#define OS_CONTEXT_PSF30 696
|
||||
#define OS_CONTEXT_PSF31 704
|
||||
#define OS_CONTEXT_STATE_EXC 0x02u
|
||||
|
||||
#define OS_CONTEXT_STATE_FPSAVED 0x01u
|
||||
|
||||
typedef struct OSContext
|
||||
{
|
||||
/*0x000*/ u32 gpr[32];
|
||||
/*0x080*/ u32 cr;
|
||||
/*0x084*/ u32 lr;
|
||||
/*0x088*/ u32 ctr;
|
||||
/*0x08C*/ u32 xer;
|
||||
/*0x090*/ f64 fpr[32];
|
||||
/*0x190*/ u32 fpscr_pad;
|
||||
/*0x194*/ u32 fpscr;
|
||||
/*0x198*/ u32 srr0;
|
||||
/*0x19C*/ u32 srr1;
|
||||
/*0x1A0*/ u16 mode;
|
||||
/*0x1A2*/ u16 state;
|
||||
/*0x1A4*/ u32 gqr[8];
|
||||
/*0x1C4*/ f64 psf[32];
|
||||
} OSContext;
|
||||
|
||||
OSContext* OS_CURRENT_CONTEXT_PHYS AT_ADDRESS(0x800000C0);
|
||||
OSContext* OS_CURRENT_CONTEXT AT_ADDRESS(0x800000D4);
|
||||
OSContext* OS_CURRENT_FPU_CONTEXT AT_ADDRESS(0x800000D8);
|
||||
u32 OSGetStackPointer(void);
|
||||
void OSDumpContext(OSContext *context);
|
||||
void OSLoadContext(OSContext *context);
|
||||
u32 OSSaveContext(OSContext *context);
|
||||
void OSClearContext(OSContext *context);
|
||||
OSContext *OSGetCurrentContext(void);
|
||||
void OSSetCurrentContext(OSContext *context);
|
||||
void OSLoadFPUContext(OSContext *fpuContext);
|
||||
void OSSaveFPUContext(OSContext *fpuContext);
|
||||
u32 OSSwitchStack(u32 newsp);
|
||||
int OSSwitchFiber(u32 pc, u32 newsp);
|
||||
void OSInitContext(OSContext *context, u32 pc, u32 newsp);
|
||||
void OSFillFPUContext(OSContext *context);
|
||||
|
||||
void OSSaveFPUContext(OSContext*);
|
||||
void OSSetCurrentContext(OSContext*);
|
||||
OSContext* OSGetCurrentContext(void);
|
||||
BOOL OSSaveContext(OSContext*);
|
||||
void OSLoadContext(OSContext*);
|
||||
void* OSGetStackPointer(void);
|
||||
void OSClearContext(OSContext*);
|
||||
void OSInitContext(register OSContext*, register u32 srr, register u32 sp);
|
||||
void OSDumpContext(const OSContext*);
|
||||
|
||||
void __OSContextInit(void);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,32 +1,37 @@
|
||||
#ifndef OS_ERROR_H
|
||||
#define OS_ERROR_H
|
||||
#include "types.h"
|
||||
#ifndef _DOLPHIN_OSERROR_H_
|
||||
#define _DOLPHIN_OSERROR_H_
|
||||
|
||||
#include <dolphin/os/OSContext.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
OS_ERR_SYSTEM_RESET,
|
||||
OS_ERR_MACHINE_CHECK,
|
||||
OS_ERR_DSI,
|
||||
OS_ERR_ISI,
|
||||
OS_ERR_EXT_INTERRUPT,
|
||||
OS_ERR_ALIGMENT,
|
||||
OS_ERR_PROGRAM,
|
||||
OS_ERR_FP_UNAVAIL,
|
||||
OS_ERR_DECREMENTER,
|
||||
OS_ERR_SYSTEM_CALL,
|
||||
OS_ERR_TRACE,
|
||||
OS_ERR_PERF_MONITOR,
|
||||
OS_ERR_IABR,
|
||||
OS_ERR_SMI,
|
||||
OS_ERR_THERMAL_INT,
|
||||
OS_ERR_PROTECTION,
|
||||
OS_ERR_FP_EXCEPTION,
|
||||
OS_ERR_MAX,
|
||||
};
|
||||
typedef u16 OSError;
|
||||
typedef void (*OSErrorHandler)(OSError error, OSContext *context, ...);
|
||||
|
||||
#define OS_ERROR_SYSTEM_RESET 0
|
||||
#define OS_ERROR_MACHINE_CHECK 1
|
||||
#define OS_ERROR_DSI 2
|
||||
#define OS_ERROR_ISI 3
|
||||
#define OS_ERROR_EXTERNAL_INTERRUPT 4
|
||||
#define OS_ERROR_ALIGNMENT 5
|
||||
#define OS_ERROR_PROGRAM 6
|
||||
#define OS_ERROR_FLOATING_POINT 7
|
||||
#define OS_ERROR_DECREMENTER 8
|
||||
#define OS_ERROR_SYSTEM_CALL 9
|
||||
#define OS_ERROR_TRACE 10
|
||||
#define OS_ERROR_PERFORMACE_MONITOR 11
|
||||
#define OS_ERROR_BREAKPOINT 12
|
||||
#define OS_ERROR_SYSTEM_INTERRUPT 13
|
||||
#define OS_ERROR_THERMAL_INTERRUPT 14
|
||||
#define OS_ERROR_PROTECTION 15
|
||||
#define OS_ERROR_MAX (OS_ERROR_THERMAL_INTERRUPT + 1)
|
||||
|
||||
OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,37 @@
|
||||
#ifndef DOLPHIN_OSEXCEPTION_H
|
||||
#define DOLPHIN_OSEXCEPTION_H
|
||||
#ifndef _DOLPHIN_OSEXCEPTION_H_
|
||||
#define _DOLPHIN_OSEXCEPTION_H_
|
||||
|
||||
typedef enum OSException {
|
||||
OS_EXCEPTION_FLOATING_POINT = 7,
|
||||
OS_EXCEPTION_COUNT = 15,
|
||||
} OSException;
|
||||
#include <dolphin/os/OSContext.h>
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#define __OS_EXCEPTION_SYSTEM_RESET 0
|
||||
#define __OS_EXCEPTION_MACHINE_CHECK 1
|
||||
#define __OS_EXCEPTION_DSI 2
|
||||
#define __OS_EXCEPTION_ISI 3
|
||||
#define __OS_EXCEPTION_EXTERNAL_INTERRUPT 4
|
||||
#define __OS_EXCEPTION_ALIGNMENT 5
|
||||
#define __OS_EXCEPTION_PROGRAM 6
|
||||
#define __OS_EXCEPTION_FLOATING_POINT 7
|
||||
#define __OS_EXCEPTION_DECREMENTER 8
|
||||
#define __OS_EXCEPTION_SYSTEM_CALL 9
|
||||
#define __OS_EXCEPTION_TRACE 10
|
||||
#define __OS_EXCEPTION_PERFORMACE_MONITOR 11
|
||||
#define __OS_EXCEPTION_BREAKPOINT 12
|
||||
#define __OS_EXCEPTION_SYSTEM_INTERRUPT 13
|
||||
#define __OS_EXCEPTION_THERMAL_INTERRUPT 14
|
||||
#define __OS_EXCEPTION_MAX (__OS_EXCEPTION_THERMAL_INTERRUPT + 1)
|
||||
|
||||
typedef u8 __OSException;
|
||||
typedef void (*__OSExceptionHandler)(__OSException exception, OSContext* context);
|
||||
|
||||
__OSExceptionHandler __OSSetExceptionHandler(__OSException exception, __OSExceptionHandler handler);
|
||||
__OSExceptionHandler __OSGetExceptionHandler(__OSException exception);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _DOLPHIN_OSEXCEPTION_H_
|
||||
|
||||
@@ -126,7 +126,7 @@ u32 __OSMaskInterrupts(u32);
|
||||
u32 __OSUnmaskInterrupts(u32);
|
||||
|
||||
u32 SetInterruptMask(OSInterruptMask mask, OSInterruptMask current);
|
||||
void __OSDispatchInterrupt(OSException exception, OSContext* context);
|
||||
void __OSDispatchInterrupt(__OSException exception, OSContext* context);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -30,6 +30,7 @@ u32 OSGetResetCode();
|
||||
void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu);
|
||||
BOOL OSGetResetSwitchState();
|
||||
void OSGetSaveRegion(void** start, void** end);
|
||||
void OSRegisterResetFunction(OSResetFunctionInfo* info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ u32 __busclock AT_ADDRESS(0x800000F8);
|
||||
#define OSNanosecondsToTicks(nsec) (((nsec) * (OS_TIMER_CLOCK / 125000)) / 8000)
|
||||
|
||||
OSTime OSGetTime(void);
|
||||
OSTime __OSGetSystemTime(void);
|
||||
OSTick OSGetTick(void);
|
||||
|
||||
typedef struct OSCalendarTime_s {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef PPC_EABI_INIT_H
|
||||
#define PPC_EABI_INIT_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
@@ -61,7 +63,6 @@ DECL_BSS_SECTION(_sbss2);
|
||||
void __init_hardware(void);
|
||||
void __flush_cache(void*, size_t);
|
||||
void __init_user(void);
|
||||
void __fini_cpp(void);
|
||||
void _ExitProcess(void);
|
||||
|
||||
typedef struct RomSection {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef OS_ADDRESS_H
|
||||
#define OS_ADDRESS_H
|
||||
|
||||
// maybe put this in OSUtil instead
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
// Defines for cached and uncached memory.
|
||||
#define OS_BASE_CACHED (0x80000000)
|
||||
#define OS_BASE_UNCACHED (0xC0000000)
|
||||
|
||||
// Address conversions.
|
||||
#define OSPhysicalToCached(paddr) ((void *)((u32)(paddr) + OS_BASE_CACHED))
|
||||
#define OSPhysicalToUncached(paddr) ((void *)((u32)(paddr) + OS_BASE_UNCACHED))
|
||||
#define OSCachedToPhysical(caddr) ((u32)((u8 *)(caddr)-OS_BASE_CACHED))
|
||||
#define OSUncachedToPhysical(ucaddr) ((u32)((u8 *)(ucaddr)-OS_BASE_UNCACHED))
|
||||
#define OSCachedToUncached(caddr) ((void *)((u8 *)(caddr) + (OS_BASE_UNCACHED - OS_BASE_CACHED)))
|
||||
#define OSUncachedToCached(ucaddr) ((void *)((u8 *)(ucaddr) - (OS_BASE_UNCACHED - OS_BASE_CACHED)))
|
||||
|
||||
#define OS_CACHED_REGION_PREFIX 0x8000
|
||||
#define OS_UNCACHED_REGION_PREFIX 0xC000
|
||||
#define OS_PHYSICAL_MASK 0x3FFF
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef DOLPHIN_OS_ALARM_H
|
||||
#define DOLPHIN_OS_ALARM_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSTime.h"
|
||||
#include "dolphin/os/OSContext.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OSAlarm OSAlarm;
|
||||
typedef void (*OSAlarmHandler)(OSAlarm* alarm, OSContext* context);
|
||||
|
||||
struct OSAlarm
|
||||
{
|
||||
OSAlarmHandler handler;
|
||||
OSTime fire;
|
||||
OSAlarm *prev;
|
||||
OSAlarm *next;
|
||||
|
||||
// Periodic alarm
|
||||
OSTime period;
|
||||
OSTime start;
|
||||
};
|
||||
|
||||
void OSInitAlarm(void);
|
||||
void OSSetAlarm(OSAlarm *alarm, OSTime tick, OSAlarmHandler handler);
|
||||
void OSSetAbsAlarm(OSAlarm *alarm, OSTime time, OSAlarmHandler handler);
|
||||
void OSSetPeriodicAlarm(OSAlarm *alarm, OSTime start, OSTime period,
|
||||
OSAlarmHandler handler);
|
||||
void OSCreateAlarm(OSAlarm *alarm);
|
||||
void OSCancelAlarm(OSAlarm *alarm);
|
||||
|
||||
BOOL OSCheckAlarmQueue(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DOLPHIN_OS_ALARM_H
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef OS_ALLOC_H
|
||||
#define OS_ALLOC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int OSHeapHandle;
|
||||
|
||||
extern volatile OSHeapHandle __OSCurrHeap;
|
||||
|
||||
void* OSAllocFromHeap(int heap, unsigned long size);
|
||||
void* OSAllocFixed(void* rstart, void* rend);
|
||||
void OSFreeToHeap(int heap, void* ptr);
|
||||
int OSSetCurrentHeap(int heap);
|
||||
void* OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps);
|
||||
int OSCreateHeap(void* start, void* end);
|
||||
void OSDestroyHeap(int heap);
|
||||
void OSAddToHeap(int heap, void* start, void* end);
|
||||
long OSCheckHeap(int heap);
|
||||
unsigned long OSReferentSize(void* ptr);
|
||||
void OSDumpHeap(int heap);
|
||||
void OSVisitAllocated(void (*visitor)(void*, unsigned long));
|
||||
|
||||
#define OSAlloc(size) OSAllocFromHeap(__OSCurrHeap, (size))
|
||||
#define OSFree(ptr) OSFreeToHeap(__OSCurrHeap, (ptr))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef OS_ARENA_H
|
||||
#define OS_ARENA_H
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void* OSGetArenaHi(void);
|
||||
void* OSGetArenaLo(void);
|
||||
|
||||
void OSSetArenaHi(void*);
|
||||
void OSSetArenaLo(void*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef OS_CACHE_H
|
||||
#define OS_CACHE_H
|
||||
#include "types.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void DCEnable(void);
|
||||
void DCInvalidateRange(void*, u32);
|
||||
void DCFlushRange(void*, u32);
|
||||
void DCStoreRange(void*, u32);
|
||||
void DCFlushRangeNoSync(void*, u32);
|
||||
void DCStoreRangeNoSync(void*, u32);
|
||||
void DCZeroRange(void*, u32);
|
||||
void DCTouchRange(void*, u32 len);
|
||||
void ICInvalidateRange(void*, u32);
|
||||
void ICFlashInvalidate(void);
|
||||
void ICEnable(void);
|
||||
void LCDisable(void);
|
||||
|
||||
//void L2GlobalInvalidate(void);
|
||||
|
||||
//void DMAErrorHandler(u8, struct OSContext*, u32, u32, ...);
|
||||
|
||||
//void __OSCacheInit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef OS_CONTEXT_H
|
||||
#define OS_CONTEXT_H
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OSContext{
|
||||
u32 gprs[32];
|
||||
u32 cr;
|
||||
u32 lr;
|
||||
u32 ctr;
|
||||
u32 xer;
|
||||
f64 fprs[32];
|
||||
u32 fpscr_tmp;
|
||||
u32 fpscr;
|
||||
u32 srr0;
|
||||
u32 srr1;
|
||||
u16 mode;
|
||||
u16 state;
|
||||
u32 gqrs[8];
|
||||
char UNK_0x1C4;
|
||||
f64 psfs[32];
|
||||
} OSContext;
|
||||
|
||||
OSContext* OS_CURRENT_CONTEXT_PHYS AT_ADDRESS(0x800000C0);
|
||||
OSContext* OS_CURRENT_CONTEXT AT_ADDRESS(0x800000D4);
|
||||
OSContext* OS_CURRENT_FPU_CONTEXT AT_ADDRESS(0x800000D8);
|
||||
|
||||
void OSSaveFPUContext(OSContext*);
|
||||
void OSSetCurrentContext(OSContext*);
|
||||
OSContext* OSGetCurrentContext(void);
|
||||
BOOL OSSaveContext(OSContext*);
|
||||
void OSLoadContext(OSContext*);
|
||||
void* OSGetStackPointer(void);
|
||||
void OSClearContext(OSContext*);
|
||||
void OSInitContext(register OSContext*, register u32 srr, register u32 sp);
|
||||
void OSDumpContext(const OSContext*);
|
||||
|
||||
void __OSContextInit(void);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef OS_ERROR_H
|
||||
#define OS_ERROR_H
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
OS_ERR_SYSTEM_RESET,
|
||||
OS_ERR_MACHINE_CHECK,
|
||||
OS_ERR_DSI,
|
||||
OS_ERR_ISI,
|
||||
OS_ERR_EXT_INTERRUPT,
|
||||
OS_ERR_ALIGMENT,
|
||||
OS_ERR_PROGRAM,
|
||||
OS_ERR_FP_UNAVAIL,
|
||||
OS_ERR_DECREMENTER,
|
||||
OS_ERR_SYSTEM_CALL,
|
||||
OS_ERR_TRACE,
|
||||
OS_ERR_PERF_MONITOR,
|
||||
OS_ERR_IABR,
|
||||
OS_ERR_SMI,
|
||||
OS_ERR_THERMAL_INT,
|
||||
OS_ERR_PROTECTION,
|
||||
OS_ERR_FP_EXCEPTION,
|
||||
OS_ERR_MAX,
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef DOLPHIN_OSEXCEPTION_H
|
||||
#define DOLPHIN_OSEXCEPTION_H
|
||||
|
||||
typedef enum OSException {
|
||||
OS_EXCEPTION_FLOATING_POINT = 7,
|
||||
OS_EXCEPTION_COUNT = 15,
|
||||
} OSException;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef DOLPHIN_OSEXI_H
|
||||
#define DOLPHIN_OSEXI_H
|
||||
|
||||
#include "dolphin/os/OSContext.h"
|
||||
#include "dolphin/os/OSInterrupt.h"
|
||||
#include "types.h"
|
||||
|
||||
typedef enum {
|
||||
EXI_STATE_DMA_ACCESS = (1 << 0),
|
||||
EXI_STATE_IMM_ACCESS = (1 << 1),
|
||||
EXI_STATE_SELECTED = (1 << 2),
|
||||
EXI_STATE_ATTACHED = (1 << 3),
|
||||
EXI_STATE_LOCKED = (1 << 4),
|
||||
EXI_STATE_BUSY = EXI_STATE_DMA_ACCESS | EXI_STATE_IMM_ACCESS
|
||||
} EXIState;
|
||||
|
||||
typedef enum {
|
||||
EXI_CHAN_0,
|
||||
EXI_CHAN_1,
|
||||
EXI_CHAN_2,
|
||||
EXI_MAX_CHAN
|
||||
} EXIChannel;
|
||||
|
||||
typedef enum {
|
||||
EXI_READ,
|
||||
EXI_WRITE,
|
||||
EXI_TYPE_2,
|
||||
EXI_MAX_TYPE
|
||||
} EXIType;
|
||||
|
||||
typedef void (*EXICallback)(EXIChannel, OSContext*);
|
||||
|
||||
typedef struct EXIControl {
|
||||
EXICallback exiCallback;
|
||||
EXICallback tcCallback;
|
||||
EXICallback extCallback;
|
||||
vu32 state;
|
||||
int immLen;
|
||||
u8* immBuf;
|
||||
u32 dev;
|
||||
u32 id;
|
||||
s32 idTime;
|
||||
int items;
|
||||
struct {
|
||||
u32 dev;
|
||||
EXICallback callback;
|
||||
} queue[3];
|
||||
} EXIControl;
|
||||
|
||||
#define EXI_REG_MAX 5
|
||||
extern vu32 __EXIRegs[EXI_MAX_CHAN][EXI_REG_MAX] AT_ADDRESS(0xCC006800);
|
||||
|
||||
void SetExiInterruptMask(EXIChannel, volatile EXIControl*);
|
||||
BOOL EXIImm(EXIChannel, void* buf, s32 len, u32 type, EXICallback);
|
||||
BOOL EXIImmEx(EXIChannel, void* buf, s32 len, u32 mode);
|
||||
BOOL EXIDma(EXIChannel, void* buf, s32 len, u32 type, EXICallback);
|
||||
BOOL EXISync(EXIChannel);
|
||||
u32 EXIClearInterrupts(EXIChannel, BOOL exi, BOOL tc, BOOL ext);
|
||||
EXICallback EXISetExiCallback(EXIChannel, EXICallback exiCallback);
|
||||
BOOL EXIProbe(EXIChannel);
|
||||
s32 EXIProbeEx(EXIChannel);
|
||||
BOOL EXIAttach(EXIChannel, EXICallback);
|
||||
BOOL EXIDetach(EXIChannel);
|
||||
BOOL EXISelect(EXIChannel, u32 dev, u32 freq);
|
||||
BOOL EXIDeselect(EXIChannel);
|
||||
void EXIInit(void);
|
||||
BOOL EXILock(EXIChannel, u32 dev, EXICallback unlockedCallback);
|
||||
BOOL EXIUnlock(EXIChannel);
|
||||
u32 EXIGetState(EXIChannel);
|
||||
s32 EXIGetID(EXIChannel, u32 dev, u32* id);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,124 @@
|
||||
#ifndef _DOLPHIN_OS_OSFASTCAST_H
|
||||
#define _DOLPHIN_OS_OSFASTCAST_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
/////// FAST CAST DEFINES ////////
|
||||
// GQR formats.
|
||||
#define OS_GQR_U8 (0x0004) // GQR 1
|
||||
#define OS_GQR_U16 (0x0005) // GQR 2
|
||||
#define OS_GQR_S8 (0x0006) // GQR 3
|
||||
#define OS_GQR_S16 (0x0007) // GQR 4
|
||||
|
||||
// GQRs for fast casting.
|
||||
#define OS_FASTCAST_U8 (2)
|
||||
#define OS_FASTCAST_U16 (3)
|
||||
#define OS_FASTCAST_S8 (4)
|
||||
#define OS_FASTCAST_S16 (5)
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
/////// FAST CAST INLINES ////////
|
||||
// Initialise fast casting.
|
||||
static inline void OSInitFastCast() {
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
asm {
|
||||
li r3, OS_GQR_U8
|
||||
oris r3, r3, OS_GQR_U8
|
||||
mtspr 0x392, r3
|
||||
li r3, OS_GQR_U16
|
||||
oris r3, r3, OS_GQR_U16
|
||||
mtspr 0x393, r3
|
||||
li r3, OS_GQR_S8
|
||||
oris r3, r3, OS_GQR_S8
|
||||
mtspr 0x394, r3
|
||||
li r3, OS_GQR_S16
|
||||
oris r3, r3, OS_GQR_S16
|
||||
mtspr 0x395, r3
|
||||
}
|
||||
#endif // clang-format on
|
||||
}
|
||||
|
||||
// Float to int.
|
||||
static inline s16 __OSf32tos16(register f32 inF) {
|
||||
register s16 out;
|
||||
u32 tmp;
|
||||
register u32* tmpPtr = &tmp;
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
asm {
|
||||
psq_st inF, 0(tmpPtr), 0x1, OS_FASTCAST_S16
|
||||
lha out, 0(tmpPtr)
|
||||
}
|
||||
#endif // clang-format on
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline void OSf32tos16(f32* f, s16* out) {
|
||||
*out = __OSf32tos16(*f);
|
||||
}
|
||||
|
||||
static inline u8 __OSf32tou8(register f32 inF) {
|
||||
register u8 out;
|
||||
u32 tmp;
|
||||
register u32* tmpPtr = &tmp;
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
asm {
|
||||
psq_st inF, 0(tmpPtr), 0x1, OS_FASTCAST_U8
|
||||
lbz out, 0(tmpPtr)
|
||||
}
|
||||
#endif // clang-format on
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline void OSf32tou8(f32* f, u8* out) {
|
||||
*out = __OSf32tou8(*f);
|
||||
}
|
||||
|
||||
static inline s8 __OSf32tos8(register f32 inF) {
|
||||
register s8 out;
|
||||
u32 tmp;
|
||||
register u32* tmpPtr = &tmp;
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
asm {
|
||||
psq_st inF, 0(tmpPtr), 0x1, OS_FASTCAST_S8
|
||||
lbz out, 0(tmpPtr)
|
||||
extsb out, out
|
||||
}
|
||||
#endif // clang-format on
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline void OSf32tos8(f32* f, s8* out) {
|
||||
*out = __OSf32tos8(*f);
|
||||
}
|
||||
|
||||
static inline float __OSs16tof32(register s16* s) {
|
||||
register float f;
|
||||
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
asm {
|
||||
psq_l f, 0(s), 1, 5
|
||||
}
|
||||
#endif // clang-format on
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
static inline void OSs16tof32(register s16* s, volatile register f32* f) {
|
||||
*f = __OSs16tof32(s);
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef OSFONT_H
|
||||
#define OSFONT_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
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;
|
||||
|
||||
#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
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,136 @@
|
||||
#ifndef DOLPHIN_OSINTERRUPT_H
|
||||
#define DOLPHIN_OSINTERRUPT_H
|
||||
|
||||
#include "dolphin/os/OSContext.h"
|
||||
#include "dolphin/os/OSException.h"
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef s16 __OSInterrupt;
|
||||
typedef u32 OSInterruptMask;
|
||||
|
||||
typedef enum OSInterruptType {
|
||||
OS_INTR_MEM_0,
|
||||
OS_INTR_MEM_1,
|
||||
OS_INTR_MEM_2,
|
||||
OS_INTR_MEM_3,
|
||||
OS_INTR_MEM_ADDRESS,
|
||||
OS_INTR_DSP_AI,
|
||||
OS_INTR_DSP_ARAM,
|
||||
OS_INTR_DSP_DSP,
|
||||
OS_INTR_AI_AI,
|
||||
OS_INTR_EXI_0_EXI,
|
||||
OS_INTR_EXI_0_TC,
|
||||
OS_INTR_EXI_0_EXT,
|
||||
OS_INTR_EXI_1_EXI,
|
||||
OS_INTR_EXI_1_TC,
|
||||
OS_INTR_EXI_1_EXT,
|
||||
OS_INTR_EXI_2_EXI,
|
||||
OS_INTR_EXI_2_TC,
|
||||
OS_INTR_PI_CP,
|
||||
OS_INTR_PI_PE_TOKEN,
|
||||
OS_INTR_PI_PE_FINISH,
|
||||
OS_INTR_PI_SI,
|
||||
OS_INTR_PI_DI,
|
||||
OS_INTR_PI_RSW,
|
||||
OS_INTR_PI_ERROR,
|
||||
OS_INTR_PI_VI,
|
||||
OS_INTR_PI_DEBUG,
|
||||
OS_INTR_PI_HSP,
|
||||
OS_INTR_PI_ACR,
|
||||
OS_INTR_28,
|
||||
OS_INTR_29,
|
||||
OS_INTR_30,
|
||||
OS_INTR_31,
|
||||
|
||||
OS_INTR_MAX
|
||||
} OSInterruptType;
|
||||
|
||||
#define OS_INTRMASK_MEM_0 (0x80000000U >> OS_INTR_MEM_0)
|
||||
#define OS_INTRMASK_MEM_1 (0x80000000U >> OS_INTR_MEM_1)
|
||||
#define OS_INTRMASK_MEM_2 (0x80000000U >> OS_INTR_MEM_2)
|
||||
#define OS_INTRMASK_MEM_3 (0x80000000U >> OS_INTR_MEM_3)
|
||||
#define OS_INTRMASK_MEM_ADDRESS (0x80000000U >> OS_INTR_MEM_ADDRESS)
|
||||
#define OS_INTRMASK_DSP_AI (0x80000000U >> OS_INTR_DSP_AI)
|
||||
#define OS_INTRMASK_DSP_ARAM (0x80000000U >> OS_INTR_DSP_ARAM)
|
||||
#define OS_INTRMASK_DSP_DSP (0x80000000U >> OS_INTR_DSP_DSP)
|
||||
#define OS_INTRMASK_AI_AI (0x80000000U >> OS_INTR_AI_AI)
|
||||
#define OS_INTRMASK_EXI_0_EXI (0x80000000U >> OS_INTR_EXI_0_EXI)
|
||||
#define OS_INTRMASK_EXI_0_TC (0x80000000U >> OS_INTR_EXI_0_TC)
|
||||
#define OS_INTRMASK_EXI_0_EXT (0x80000000U >> OS_INTR_EXI_0_EXT)
|
||||
#define OS_INTRMASK_EXI_1_EXI (0x80000000U >> OS_INTR_EXI_1_EXI)
|
||||
#define OS_INTRMASK_EXI_1_TC (0x80000000U >> OS_INTR_EXI_1_TC)
|
||||
#define OS_INTRMASK_EXI_1_EXT (0x80000000U >> OS_INTR_EXI_1_EXT)
|
||||
#define OS_INTRMASK_EXI_2_EXI (0x80000000U >> OS_INTR_EXI_2_EXI)
|
||||
#define OS_INTRMASK_EXI_2_TC (0x80000000U >> OS_INTR_EXI_2_TC)
|
||||
#define OS_INTRMASK_PI_CP (0x80000000U >> OS_INTR_PI_CP)
|
||||
#define OS_INTRMASK_PI_PE_TOKEN (0x80000000U >> OS_INTR_PI_PE_TOKEN)
|
||||
#define OS_INTRMASK_PI_PE_FINISH (0x80000000U >> OS_INTR_PI_PE_FINISH)
|
||||
#define OS_INTRMASK_PI_SI (0x80000000U >> OS_INTR_PI_SI)
|
||||
#define OS_INTRMASK_PI_DI (0x80000000U >> OS_INTR_PI_DI)
|
||||
#define OS_INTRMASK_PI_RSW (0x80000000U >> OS_INTR_PI_RSW)
|
||||
#define OS_INTRMASK_PI_ERROR (0x80000000U >> OS_INTR_PI_ERROR)
|
||||
#define OS_INTRMASK_PI_VI (0x80000000U >> OS_INTR_PI_VI)
|
||||
#define OS_INTRMASK_PI_DEBUG (0x80000000U >> OS_INTR_PI_DEBUG)
|
||||
#define OS_INTRMASK_PI_HSP (0x80000000U >> OS_INTR_PI_HSP)
|
||||
|
||||
#define OS_INTRMASK_MEM \
|
||||
(OS_INTRMASK_MEM_0 | OS_INTRMASK_MEM_1 | OS_INTRMASK_MEM_2 | \
|
||||
OS_INTRMASK_MEM_3 | OS_INTRMASK_MEM_ADDRESS)
|
||||
|
||||
#define OS_INTRMASK_AI (OS_INTRMASK_AI_AI)
|
||||
|
||||
#define OS_INTRMASK_DSP \
|
||||
(OS_INTRMASK_DSP_AI | OS_INTRMASK_DSP_ARAM | OS_INTRMASK_DSP_DSP)
|
||||
|
||||
#define OS_INTRMASK_EXI_0 \
|
||||
(OS_INTRMASK_EXI_0_EXI | OS_INTRMASK_EXI_0_TC | OS_INTRMASK_EXI_0_EXT)
|
||||
#define OS_INTRMASK_EXI_1 \
|
||||
(OS_INTRMASK_EXI_1_EXI | OS_INTRMASK_EXI_1_TC | OS_INTRMASK_EXI_1_EXT)
|
||||
#define OS_INTRMASK_EXI_2 (OS_INTRMASK_EXI_2_EXI | OS_INTRMASK_EXI_2_TC)
|
||||
#define OS_INTRMASK_EXI \
|
||||
(OS_INTRMASK_EXI_0_EXI | OS_INTRMASK_EXI_0_TC | OS_INTRMASK_EXI_0_EXT | \
|
||||
OS_INTRMASK_EXI_1_EXI | OS_INTRMASK_EXI_1_TC | OS_INTRMASK_EXI_1_EXT | \
|
||||
OS_INTRMASK_EXI_2_EXI | OS_INTRMASK_EXI_2_TC)
|
||||
|
||||
#define OS_INTRMASK_PI \
|
||||
(OS_INTRMASK_PI_CP | OS_INTRMASK_PI_SI | OS_INTRMASK_PI_DI | \
|
||||
OS_INTRMASK_PI_RSW | OS_INTRMASK_PI_ERROR | OS_INTRMASK_PI_VI | \
|
||||
OS_INTRMASK_PI_PE_TOKEN | OS_INTRMASK_PI_PE_FINISH | \
|
||||
OS_INTRMASK_PI_DEBUG | OS_INTRMASK_PI_HSP)
|
||||
|
||||
#define OS_INTRMASK_PI_PE (OS_INTRMASK_PI_PE_TOKEN | OS_INTRMASK_PI_PE_FINISH)
|
||||
|
||||
typedef void (*OSInterruptHandler)(__OSInterrupt, OSContext*);
|
||||
|
||||
extern volatile u32 __OSLastInterruptSrr0;
|
||||
extern volatile s16 __OSLastInterrupt;
|
||||
extern volatile s64 __OSLastInterruptTime;
|
||||
|
||||
void __RAS_OSDisableInterrupts_begin(void);
|
||||
void __RAS_OSDisableInterrupts_end(void);
|
||||
|
||||
BOOL OSDisableInterrupts(void);
|
||||
BOOL OSEnableInterrupts(void);
|
||||
BOOL OSRestoreInterrupts(BOOL);
|
||||
|
||||
OSInterruptHandler __OSSetInterruptHandler(__OSInterrupt, OSInterruptHandler);
|
||||
OSInterruptHandler __OSGetInterruptHandler(__OSInterrupt);
|
||||
|
||||
void __OSInterruptInit(void);
|
||||
|
||||
u32 __OSMaskInterrupts(u32);
|
||||
u32 __OSUnmaskInterrupts(u32);
|
||||
|
||||
u32 SetInterruptMask(OSInterruptMask mask, OSInterruptMask current);
|
||||
void __OSDispatchInterrupt(OSException exception, OSContext* context);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef OS_MEMORY_H
|
||||
#define OS_MEMORY_H
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SIM_MEM *(u32 *)0x800000f0
|
||||
static void Config24MB();
|
||||
static void Config48MB();
|
||||
u32 OSGetConsoleSimulatedMemSize(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef _DOLPHIN_OS_OSMESSAGE_H
|
||||
#define _DOLPHIN_OS_OSMESSAGE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSUtil.h"
|
||||
#include "dolphin/os/OSThread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
///////// MESSAGE TYPES //////////
|
||||
typedef struct OSMessageQueue OSMessageQueue;
|
||||
|
||||
// Useful typedef for messages.
|
||||
typedef void* OSMessage;
|
||||
|
||||
// Struct for managing the message queue.
|
||||
struct OSMessageQueue {
|
||||
OSThreadQueue queueSend; // _00
|
||||
OSThreadQueue queueReceive; // _08
|
||||
OSMessage* msgArray; // _10, array of messages.
|
||||
int msgCount; // _14, array limit size.
|
||||
int firstIndex; // _18, first message index in array.
|
||||
int usedCount; // _1C, actual number of used messages.
|
||||
};
|
||||
|
||||
// Defines for message flags for sending/receiving.
|
||||
#define OS_MESSAGE_NOBLOCK (0)
|
||||
#define OS_MESSAGE_BLOCK (1)
|
||||
|
||||
typedef enum {
|
||||
OS_MSG_PERSISTENT = (1 << 0),
|
||||
} OSMessageFlags;
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
/////// MESSAGE FUNCTIONS ////////
|
||||
// Functions for handling messages.
|
||||
void OSInitMessageQueue(OSMessageQueue* queue, OSMessage* msgArray, int msgCount);
|
||||
BOOL OSSendMessage(OSMessageQueue* queue, OSMessage msg, int flags);
|
||||
BOOL OSJamMessage(OSMessageQueue* queue, OSMessage msg, int flags);
|
||||
BOOL OSReceiveMessage(OSMessageQueue* queue, OSMessage* msgPtr, int flags);
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef DOLPHIN_OSMODULE_H
|
||||
#define DOLPHIN_OSMODULE_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OSModuleInfo_s OSModuleInfo;
|
||||
|
||||
typedef struct OSModuleQueue_s {
|
||||
OSModuleInfo* head;
|
||||
OSModuleInfo* tail;
|
||||
} OSModuleQueue;
|
||||
|
||||
typedef struct OSModuleLink_s {
|
||||
OSModuleInfo* next;
|
||||
OSModuleInfo* prev;
|
||||
} OSModuleLink;
|
||||
|
||||
typedef struct OSModuleInfo_s {
|
||||
u32 id;
|
||||
OSModuleLink link;
|
||||
u32 numSections;
|
||||
u32 sectionInfoOfs;
|
||||
u32 nameOfs;
|
||||
u32 nameSize;
|
||||
u32 version;
|
||||
} OSModuleInfo;
|
||||
|
||||
typedef struct OSModuleHeader_s {
|
||||
OSModuleInfo info;
|
||||
u32 bssSize;
|
||||
u32 relOfs;
|
||||
u32 impOfs;
|
||||
u32 impSize;
|
||||
|
||||
u8 prologSection;
|
||||
u8 epilogSection;
|
||||
u8 unresolvedSection;
|
||||
u8 bssSection;
|
||||
|
||||
u32 prolog;
|
||||
u32 epilog;
|
||||
u32 unresolved;
|
||||
/* OS_MODULE_VERSION >= 2 */
|
||||
|
||||
u32 align;
|
||||
u32 bssAlign;
|
||||
} OSModuleHeader;
|
||||
|
||||
typedef struct OSSectionInfo_s {
|
||||
u32 offset;
|
||||
u32 size;
|
||||
} OSSectionInfo;
|
||||
|
||||
#define OSGetSectionInfo(module) \
|
||||
((OSSectionInfo*) (((OSModuleInfo*) (module))->sectionInfoOfs))
|
||||
|
||||
#define OS_SECTIONINFO_EXEC 1
|
||||
#define OS_SECTIONINFO_OFFSET(offset) ((offset) & ~OS_SECTIONINFO_EXEC)
|
||||
|
||||
void OSSetStringTable (const void* strTable);
|
||||
BOOL OSLink(OSModuleInfo* module, void* bss);
|
||||
BOOL OSUnlink(OSModuleInfo* module);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef OS_MUTEX_H
|
||||
#define OS_MUTEX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "dolphin/os/OSThread.h"
|
||||
|
||||
struct OSMutex
|
||||
{
|
||||
OSThreadQueue queue;
|
||||
OSThread *thread; // the current owner
|
||||
s32 count; // lock count
|
||||
OSMutexLink link; // for OSThread.queueMutex
|
||||
};
|
||||
|
||||
struct OSCond
|
||||
{
|
||||
OSThreadQueue queue;
|
||||
};
|
||||
|
||||
void OSInitMutex(OSMutex *mutex);
|
||||
void OSLockMutex(OSMutex *mutex);
|
||||
void OSUnlockMutex(OSMutex *mutex);
|
||||
BOOL OSTryLockMutex(OSMutex *mutex);
|
||||
void OSInitCond(OSCond *cond);
|
||||
void OSWaitCond(OSCond *cond, OSMutex *mutex);
|
||||
void OSSignalCond(OSCond *cond);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DOLPHIN_OSMUTEX_H
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef OSRESET_H
|
||||
#define OSRESET_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OS_RESETCODE_RESTART 0x80000000
|
||||
|
||||
#define OS_RESET_RESTART 0
|
||||
#define OS_RESET_HOTRESET 1 /* Soft reset */
|
||||
#define OS_RESET_SHUTDOWN 2
|
||||
|
||||
typedef BOOL (*OSResetFunction)(BOOL final);
|
||||
typedef struct OSResetFunctionInfo OSResetFunctionInfo;
|
||||
|
||||
struct OSResetFunctionInfo {
|
||||
// public
|
||||
OSResetFunction func;
|
||||
u32 priority;
|
||||
|
||||
// private
|
||||
OSResetFunctionInfo* next;
|
||||
OSResetFunctionInfo* prev;
|
||||
};
|
||||
|
||||
u32 OSGetResetCode();
|
||||
void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu);
|
||||
BOOL OSGetResetSwitchState();
|
||||
void OSGetSaveRegion(void** start, void** end);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef OSRESETSW_H
|
||||
#define OSRESETSW_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL OSGetResetSwitchState();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,111 @@
|
||||
#ifndef DOLPHIN_OSRTC_H
|
||||
#define DOLPHIN_OSTRC_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSExi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OS_SOUND_MODE_MONO 0
|
||||
#define OS_SOUND_MODE_STEREO 1
|
||||
|
||||
#define OS_PROGRESSIVE_MODE_OFF 0
|
||||
#define OS_PROGRESSIVE_MODE_ON 1
|
||||
|
||||
#define OS_BOOT_MODE_DEBUG (0 << 7)
|
||||
#define OS_BOOT_MODE_RETAIL (1 << 7)
|
||||
|
||||
#define RTC_CMD_READ 0x20000000
|
||||
#define RTC_CMD_WRITE 0xA0000000
|
||||
|
||||
#define RTC_SRAM_ADDR 0x00000100
|
||||
#define RTC_SRAM_SIZE 64
|
||||
|
||||
#define RTC_CHAN EXI_CHAN_0
|
||||
#define RTC_DEVICE 1
|
||||
#define RTC_FREQUENCY 3
|
||||
|
||||
typedef struct OSSram_s {
|
||||
u16 checkSum;
|
||||
u16 checkSumInv;
|
||||
u32 ead0;
|
||||
u32 ead1;
|
||||
u32 counterBias;
|
||||
s8 displayOffsetH;
|
||||
u8 ntd;
|
||||
u8 language;
|
||||
u8 flags;
|
||||
} OSSram;
|
||||
|
||||
typedef struct OSSramEx_s {
|
||||
u8 flashID[2][12];
|
||||
u32 wirelessKeyboardID;
|
||||
u16 wirelessPadID[4];
|
||||
u8 dvdErrorCode;
|
||||
u8 pad0;
|
||||
u8 flashIDCheckSum[2];
|
||||
u16 gbs;
|
||||
u8 pad1[2];
|
||||
} OSSramEx;
|
||||
|
||||
typedef struct SramControlBlock_s {
|
||||
u8 sram[RTC_SRAM_SIZE];
|
||||
u32 offset;
|
||||
BOOL enabled;
|
||||
BOOL locked;
|
||||
BOOL sync;
|
||||
void (*callback)(void);
|
||||
} SramControlBlock;
|
||||
|
||||
// static void GetRTC();
|
||||
// extern void __OSGetRTC();
|
||||
// extern void __OSSetRTC();
|
||||
static inline BOOL ReadSram(void* buffer);
|
||||
static void WriteSramCallback(EXIChannel chan, OSContext* ctx);
|
||||
static BOOL WriteSram(void* buffer, u32 offset, u32 size);
|
||||
extern void __OSInitSram();
|
||||
static inline void* LockSram(u32 offset);
|
||||
extern OSSram* __OSLockSram();
|
||||
extern OSSramEx* __OSLockSramEx();
|
||||
static BOOL UnlockSram(BOOL commit, u32 offset);
|
||||
extern void __OSUnlockSram(BOOL commit);
|
||||
extern void __OSUnlockSramEx(BOOL commit);
|
||||
extern BOOL __OSSyncSram();
|
||||
// extern void __OSCheckSram();
|
||||
// extern void __OSReadROM();
|
||||
// extern void __OSReadROMCallback();
|
||||
// extern void __OSReadROMAsync();
|
||||
extern u32 OSGetSoundMode();
|
||||
extern void OSSetSoundMode(u32 mode);
|
||||
extern u32 OSGetProgressiveMode();
|
||||
extern void OSSetProgressiveMode(u32 on);
|
||||
// extern void OSGetVideoMode();
|
||||
// extern void OSSetVideoMode();
|
||||
// extern void OSGetLanguage();
|
||||
// extern void OSSetLanguage();
|
||||
// extern void __OSGetBootMode();
|
||||
extern void __OSSetBootMode(u8 mode);
|
||||
// extern void OSGetEuRgb60Mode();
|
||||
// extern void OSSetEuRgb60Mode();
|
||||
extern u16 OSGetWirelessID(u32 chan);
|
||||
extern void OSSetWirelessID(u32 chan, u16 id);
|
||||
|
||||
#define GET_SOUNDMODE(flags) ((flags) & (1 << 2))
|
||||
#define CLR_SOUNDMODE(flags) ((flags) & (~(1 << 2)))
|
||||
#define SET_SOUNDMODE(mode) (((mode) & 1) << 2)
|
||||
|
||||
#define GET_PROGMODE(flags) ((flags) & (1 << 7))
|
||||
#define CLR_PROGMODE(flags) ((flags) & (~(1 << 7)))
|
||||
#define SET_PROGMODE(mode) (((mode) & 1) << 7)
|
||||
|
||||
#define GET_BOOTMODE(flags) ((flags) & (1 << 7))
|
||||
#define CLR_BOOTMODE(flags) ((flags) & (~(1 << 7)))
|
||||
#define SET_BOOTMODE(mode) (mode)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
#ifndef DOLPHIN_OSSERIAL
|
||||
#define DOLPHIN_OSSERIAL
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SI_MAX_CHAN 4
|
||||
#define SI_MAX_COMCSR_INLNGTH 128
|
||||
#define SI_MAX_COMCSR_OUTLNGTH 128
|
||||
#define SI_ERROR_UNDER_RUN 0x0001
|
||||
#define SI_ERROR_OVER_RUN 0x0002
|
||||
#define SI_ERROR_COLLISION 0x0004
|
||||
#define SI_ERROR_NO_RESPONSE 0x0008
|
||||
#define SI_ERROR_WRST 0x0010
|
||||
#define SI_ERROR_RDST 0x0020
|
||||
#define SI_ERROR_UNKNOWN 0x0040
|
||||
#define SI_ERROR_BUSY 0x0080
|
||||
#define SI_CHAN0 0
|
||||
#define SI_CHAN1 1
|
||||
#define SI_CHAN2 2
|
||||
#define SI_CHAN3 3
|
||||
#define SI_CHAN0_BIT 0x80000000
|
||||
#define SI_CHAN1_BIT 0x40000000
|
||||
#define SI_CHAN2_BIT 0x20000000
|
||||
#define SI_CHAN3_BIT 0x10000000
|
||||
#define SI_CHAN_BIT(chan) (SI_CHAN0_BIT >> (chan))
|
||||
#define SI_TYPE_MASK 0x18000000u
|
||||
#define SI_TYPE_N64 0x00000000u
|
||||
#define SI_TYPE_DOLPHIN 0x08000000u
|
||||
#define SI_TYPE_GC SI_TYPE_DOLPHIN
|
||||
#define SI_GC_WIRELESS 0x80000000
|
||||
#define SI_GC_NOMOTOR 0x20000000
|
||||
#define SI_GC_STANDARD 0x01000000
|
||||
#define SI_WIRELESS_RECEIVED 0x40000000
|
||||
#define SI_WIRELESS_IR 0x04000000
|
||||
#define SI_WIRELESS_STATE 0x02000000
|
||||
#define SI_WIRELESS_ORIGIN 0x00200000
|
||||
#define SI_WIRELESS_FIX_ID 0x00100000
|
||||
#define SI_WIRELESS_TYPE 0x000f0000
|
||||
#define SI_WIRELESS_LITE_MASK 0x000c0000
|
||||
#define SI_WIRELESS_LITE 0x00040000
|
||||
#define SI_WIRELESS_CONT_MASK 0x00080000
|
||||
#define SI_WIRELESS_CONT 0x00000000
|
||||
#define SI_WIRELESS_ID 0x00c0ff00
|
||||
#define SI_WIRELESS_TYPE_ID (SI_WIRELESS_TYPE | SI_WIRELESS_ID)
|
||||
#define SI_N64_CONTROLLER (SI_TYPE_N64 | 0x05000000)
|
||||
#define SI_N64_MIC (SI_TYPE_N64 | 0x00010000)
|
||||
#define SI_N64_KEYBOARD (SI_TYPE_N64 | 0x00020000)
|
||||
#define SI_N64_MOUSE (SI_TYPE_N64 | 0x02000000)
|
||||
#define SI_GBA (SI_TYPE_N64 | 0x00040000)
|
||||
#define SI_GC_CONTROLLER (SI_TYPE_GC | SI_GC_STANDARD)
|
||||
#define SI_GC_RECEIVER (SI_TYPE_GC | SI_GC_WIRELESS)
|
||||
#define SI_GC_WAVEBIRD \
|
||||
(SI_TYPE_GC | SI_GC_WIRELESS | SI_GC_STANDARD | SI_WIRELESS_STATE | SI_WIRELESS_FIX_ID)
|
||||
#define SI_GC_KEYBOARD (SI_TYPE_GC | 0x00200000)
|
||||
#define SI_GC_STEERING (SI_TYPE_GC | 0x00000000)
|
||||
|
||||
u32 SIProbe(s32 chan);
|
||||
char* SIGetTypeString(u32 type);
|
||||
void SIRefreshSamplingRate(void);
|
||||
void SISetSamplingRate(u32 msec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,129 @@
|
||||
#ifndef OS_THREAD_H
|
||||
#define OS_THREAD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "dolphin/os/OSContext.h"
|
||||
|
||||
typedef struct OSThread OSThread;
|
||||
typedef struct OSThreadQueue OSThreadQueue;
|
||||
typedef struct OSThreadLink OSThreadLink;
|
||||
typedef s32 OSPriority; // 0 highest, 31 lowest
|
||||
|
||||
typedef struct OSMutex OSMutex;
|
||||
typedef struct OSMutexQueue OSMutexQueue;
|
||||
typedef struct OSMutexLink OSMutexLink;
|
||||
typedef struct OSCond OSCond;
|
||||
|
||||
typedef void (*OSIdleFunction)(void *param);
|
||||
|
||||
struct OSThreadQueue
|
||||
{
|
||||
OSThread *head;
|
||||
OSThread *tail;
|
||||
};
|
||||
|
||||
struct OSThreadLink
|
||||
{
|
||||
OSThread *next;
|
||||
OSThread *prev;
|
||||
};
|
||||
|
||||
struct OSMutexQueue
|
||||
{
|
||||
OSMutex *head;
|
||||
OSMutex *tail;
|
||||
};
|
||||
|
||||
struct OSMutexLink
|
||||
{
|
||||
OSMutex *next;
|
||||
OSMutex *prev;
|
||||
};
|
||||
|
||||
struct OSThread
|
||||
{
|
||||
OSContext context; // register context
|
||||
|
||||
u16 state; // OS_THREAD_STATE_*
|
||||
u16 attr; // OS_THREAD_ATTR_*
|
||||
s32 suspend; // suspended if the count is greater than zero
|
||||
OSPriority priority; // effective scheduling priority
|
||||
OSPriority base; // base scheduling priority
|
||||
void *val; // exit value
|
||||
|
||||
OSThreadQueue *queue; // queue thread is on
|
||||
OSThreadLink link; // queue link
|
||||
|
||||
OSThreadQueue queueJoin; // list of threads waiting for termination (join)
|
||||
|
||||
OSMutex *mutex; // mutex trying to lock
|
||||
OSMutexQueue queueMutex; // list of mutexes owned
|
||||
|
||||
OSThreadLink linkActive; // link of all threads for debugging
|
||||
|
||||
u8 *stackBase; // the thread's designated stack (high address)
|
||||
u32 *stackEnd; // last word of stack (low address)
|
||||
};
|
||||
|
||||
// Thread states
|
||||
enum OS_THREAD_STATE
|
||||
{
|
||||
OS_THREAD_STATE_READY = 1,
|
||||
OS_THREAD_STATE_RUNNING = 2,
|
||||
OS_THREAD_STATE_WAITING = 4,
|
||||
OS_THREAD_STATE_MORIBUND = 8
|
||||
};
|
||||
|
||||
// Thread priorities
|
||||
#define OS_PRIORITY_MIN 0 // highest
|
||||
#define OS_PRIORITY_MAX 31 // lowest
|
||||
#define OS_PRIORITY_IDLE OS_PRIORITY_MAX
|
||||
|
||||
// Thread attributes
|
||||
#define OS_THREAD_ATTR_DETACH 0x0001u // detached
|
||||
|
||||
// Stack magic value
|
||||
#define OS_THREAD_STACK_MAGIC 0xDEADBABE
|
||||
|
||||
void OSInitThreadQueue(OSThreadQueue *queue);
|
||||
OSThread *OSGetCurrentThread(void);
|
||||
BOOL OSIsThreadSuspended(OSThread *thread);
|
||||
BOOL OSIsThreadTerminated(OSThread *thread);
|
||||
s32 OSDisableScheduler(void);
|
||||
s32 OSEnableScheduler(void);
|
||||
void OSYieldThread(void);
|
||||
BOOL OSCreateThread(OSThread *thread,
|
||||
void *(*func)(void *),
|
||||
void *param,
|
||||
void *stack,
|
||||
u32 stackSize,
|
||||
OSPriority priority,
|
||||
u16 attr);
|
||||
void OSExitThread(void *val);
|
||||
void OSCancelThread(OSThread *thread);
|
||||
BOOL OSJoinThread(OSThread *thread, void **val);
|
||||
void OSDetachThread(OSThread *thread);
|
||||
s32 OSResumeThread(OSThread *thread);
|
||||
s32 OSSuspendThread(OSThread *thread);
|
||||
BOOL OSSetThreadPriority(OSThread *thread, OSPriority priority);
|
||||
OSPriority OSGetThreadPriority(OSThread *thread);
|
||||
void OSSleepThread(OSThreadQueue *queue);
|
||||
void OSWakeupThread(OSThreadQueue *queue);
|
||||
|
||||
OSThread *OSSetIdleFunction(OSIdleFunction idleFunction,
|
||||
void *param,
|
||||
void *stack,
|
||||
u32 stackSize);
|
||||
OSThread *OSGetIdleFunction(void);
|
||||
|
||||
long OSCheckActiveThreads(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DOLPHIN_OSTHREAD_H
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef OS_TIME_H
|
||||
#define OS_TIME_H
|
||||
#include "types.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OSDiffTick(tick1, tick0) ((s32)(tick1) - (s32)(tick0))
|
||||
|
||||
typedef s64 OSTime;
|
||||
typedef u32 OSTick;
|
||||
|
||||
u32 __busclock AT_ADDRESS(0x800000F8);
|
||||
|
||||
#define OS_BUS_CLOCK __busclock
|
||||
|
||||
#define OS_TIMER_CLOCK (OS_BUS_CLOCK / 4)
|
||||
|
||||
#define OSTicksToSeconds(ticks) ((ticks) / OS_TIMER_CLOCK)
|
||||
#define OSTicksToMilliseconds(ticks) ((ticks) / (OS_TIMER_CLOCK / 1000))
|
||||
#define OSTicksToMicroseconds(ticks) (((ticks)*8) / (OS_TIMER_CLOCK / 125000))
|
||||
#define OSTicksToNanoseconds(ticks) (((ticks)*8000) / (OS_TIMER_CLOCK / 125000))
|
||||
#define OSSecondsToTicks(sec) ((sec)*OS_TIMER_CLOCK)
|
||||
#define OSMillisecondsToTicks(msec) ((msec) * (OS_TIMER_CLOCK / 1000))
|
||||
#define OSMicrosecondsToTicks(usec) (((usec) * (OS_TIMER_CLOCK / 125000)) / 8)
|
||||
#define OSNanosecondsToTicks(nsec) (((nsec) * (OS_TIMER_CLOCK / 125000)) / 8000)
|
||||
|
||||
OSTime OSGetTime(void);
|
||||
OSTick OSGetTick(void);
|
||||
|
||||
typedef struct OSCalendarTime_s {
|
||||
int sec;
|
||||
int min;
|
||||
int hour;
|
||||
int mday;
|
||||
int mon;
|
||||
int year;
|
||||
int wday;
|
||||
int yday;
|
||||
|
||||
int msec;
|
||||
int usec;
|
||||
} OSCalendarTime;
|
||||
|
||||
OSTime OSCalendarTimeToTicks(OSCalendarTime* td);
|
||||
void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* td);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/* TODO: not sure if this should live here or in libultra/OSTimer.h */
|
||||
|
||||
#ifndef DOLPHIN_OS_TIMER_H
|
||||
#define DOLPHIN_OS_TIMER_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSAlarm.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OSTimer_s {
|
||||
OSAlarm alarm;
|
||||
struct OSTimer_s* next;
|
||||
struct OSTimer_s* prev;
|
||||
OSTime interval;
|
||||
OSTime value;
|
||||
OSMessageQueue* mq;
|
||||
OSMessage msg;
|
||||
} OSTimer;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef OS_UTIL_H
|
||||
#define OS_UTIL_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define OSRoundUp32B(x) (((u32)(x) + 0x1F) & ~(0x1F))
|
||||
#define OSRoundDown32B(x) (((u32)(x)) & ~(0x1F))
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
#ifndef PPC_EABI_INIT_H
|
||||
#define PPC_EABI_INIT_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef void (*voidfunctionptr)(void); // pointer to function returning void
|
||||
__declspec(section ".ctors") extern voidfunctionptr _ctors[];
|
||||
__declspec(section ".dtors") extern voidfunctionptr _dtors[];
|
||||
|
||||
/**
|
||||
* Linker Generated Symbols
|
||||
*/
|
||||
|
||||
// Declare linker symbols for a section in the ROM
|
||||
#define DECL_ROM_SECTION(x) \
|
||||
extern u8 _f##x[]; \
|
||||
extern u8 _f##x##_rom[]; \
|
||||
extern u8 _e##x[];
|
||||
|
||||
// Declare linker symbols for a BSS section
|
||||
#define DECL_BSS_SECTION(x) \
|
||||
extern u8 _f##x[]; \
|
||||
extern u8 _e##x[];
|
||||
|
||||
// Debugger stack
|
||||
extern u8 _db_stack_addr[];
|
||||
extern u8 _db_stack_end[];
|
||||
|
||||
// Program arena
|
||||
extern u8 __ArenaLo[];
|
||||
extern u8 __ArenaHi[];
|
||||
|
||||
// Program stack
|
||||
extern u8 _stack_addr[];
|
||||
extern u8 _stack_end[];
|
||||
|
||||
// Small data bases
|
||||
extern u8 _SDA_BASE_[];
|
||||
extern u8 _SDA2_BASE_[];
|
||||
|
||||
// ROM sections
|
||||
DECL_ROM_SECTION(_init);
|
||||
DECL_ROM_SECTION(extab);
|
||||
DECL_ROM_SECTION(extabindex);
|
||||
DECL_ROM_SECTION(_text);
|
||||
DECL_ROM_SECTION(_ctors);
|
||||
DECL_ROM_SECTION(_dtors);
|
||||
DECL_ROM_SECTION(_rodata);
|
||||
DECL_ROM_SECTION(_data);
|
||||
DECL_ROM_SECTION(_sdata);
|
||||
DECL_ROM_SECTION(_sdata2);
|
||||
DECL_ROM_SECTION(_stack);
|
||||
|
||||
// BSS sections
|
||||
DECL_BSS_SECTION(_bss);
|
||||
DECL_BSS_SECTION(_sbss);
|
||||
DECL_BSS_SECTION(_sbss2);
|
||||
|
||||
void __init_hardware(void);
|
||||
extern void __flush_cache(void *address, unsigned int size);
|
||||
void __init_user(void);
|
||||
void __fini_cpp(void);
|
||||
void _ExitProcess(void);
|
||||
|
||||
typedef struct RomSection {
|
||||
void* romOfs; // at 0x4
|
||||
void* virtualOfs; // at 0x0
|
||||
size_t size; // at 0x8
|
||||
} RomSection;
|
||||
|
||||
typedef struct BssSection {
|
||||
void* virtualOfs; // at 0x0
|
||||
size_t size; // at 0x8
|
||||
} BssSection;
|
||||
|
||||
typedef struct ExtabIndexInfo {
|
||||
void* etiStart; // at 0x0
|
||||
void* etiEnd; // at 0x4
|
||||
void* codeStart; // at 0x8
|
||||
u32 codeSize; // at 0x10
|
||||
} ExtabIndexInfo;
|
||||
|
||||
__declspec(section ".init") extern RomSection _rom_copy_info[];
|
||||
__declspec(section ".init") extern BssSection _bss_init_info[];
|
||||
__declspec(section ".init") extern ExtabIndexInfo _eti_init_info[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -10,9 +10,6 @@
|
||||
#define AUDIO_THREAD_FLAG_NEOS (1 << 2)
|
||||
|
||||
extern volatile int intcount;
|
||||
OSThread jac_audioThread[3];
|
||||
OSThread jac_neosThread;
|
||||
OSThread jac_dvdThread;
|
||||
|
||||
extern void NeosSync(void);
|
||||
|
||||
|
||||
+21
-21
@@ -1,21 +1,21 @@
|
||||
#ifndef LIB_C_MATH_H
|
||||
#define LIB_C_MATH_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define SQRT_OF_2_F 1.41421356237309504880f
|
||||
#define SQRT_OF_3_F 1.73205080756887729353f
|
||||
|
||||
#define SQRT_3_OVER_3_F (SQRT_OF_3_F / 3.0f)
|
||||
|
||||
#define M_PI 3.14159265358979323846f
|
||||
|
||||
s16 sins(u16);
|
||||
s16 coss(u16);
|
||||
|
||||
f32 fatan2(f32, f32);
|
||||
|
||||
f64 fsqrt(f32);
|
||||
|
||||
f32 facos(f32);
|
||||
#endif
|
||||
#ifndef LIB_C_MATH_H
|
||||
#define LIB_C_MATH_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define SQRT_OF_2_F 1.41421356237309504880f
|
||||
#define SQRT_OF_3_F 1.73205080756887729353f
|
||||
|
||||
#define SQRT_3_OVER_3_F (SQRT_OF_3_F / 3.0f)
|
||||
|
||||
#define M_PI 3.14159265358979323846f
|
||||
|
||||
s16 sins(u16);
|
||||
s16 coss(u16);
|
||||
|
||||
f32 fatan2(f32, f32);
|
||||
|
||||
f64 fsqrt(f32);
|
||||
|
||||
f32 facos(f32);
|
||||
#endif
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSTime.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void csleep(OSTime c);
|
||||
void msleep(int);
|
||||
void msleep(u32);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#ifndef BATCONFIG_H
|
||||
#define BATCONFIG_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSMemory.h"
|
||||
#include "dolphin/os/OSInterrupt.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void Config24MB();
|
||||
void Config48MB();
|
||||
void ReconfigBATs();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BATCONFIG_H
|
||||
#define BATCONFIG_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSMemory.h"
|
||||
#include "dolphin/os/OSInterrupt.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void Config24MB();
|
||||
void Config48MB();
|
||||
void ReconfigBATs();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -23,7 +23,7 @@
|
||||
#define EMU64_TEX_BLOCK_SIZE_Y 4
|
||||
|
||||
#define NUM_COMMANDS 64
|
||||
#define NUM_SEGMENTS 16
|
||||
#define EMU64_NUM_SEGMENTS 16
|
||||
#define DL_MAX_STACK_LEVEL 18
|
||||
#define DL_HISTORY_COUNT 16
|
||||
#define NUM_TILES 8
|
||||
@@ -494,70 +494,6 @@ class emu64_print {
|
||||
|
||||
#define EMU64_ASSERT(cond) EMU64_PANICLINE(cond, __LINE__)
|
||||
|
||||
class emu64_print {
|
||||
public:
|
||||
void Printf(const char* fmt, ...) {
|
||||
va_list list;
|
||||
|
||||
if ((this->print_flags & EMU64_PRINTF_FLAG)) {
|
||||
va_start(list, fmt);
|
||||
this->Vprintf(fmt, list);
|
||||
va_end(list);
|
||||
}
|
||||
}
|
||||
|
||||
void Printf0(const char* fmt, ...) {
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
this->Vprintf(fmt, list);
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
void Printf1(const char* fmt, ...) {
|
||||
va_list list;
|
||||
|
||||
if ((this->print_flags & EMU64_PRINTF1_FLAG)) {
|
||||
va_start(list, fmt);
|
||||
this->Vprintf(fmt, list);
|
||||
va_end(list);
|
||||
}
|
||||
}
|
||||
|
||||
void Printf2(const char* fmt, ...) {
|
||||
va_list list;
|
||||
|
||||
if ((this->print_flags & EMU64_PRINTF2_FLAG)) {
|
||||
va_start(list, fmt);
|
||||
this->Vprintf(fmt, list);
|
||||
va_end(list);
|
||||
}
|
||||
}
|
||||
|
||||
void Printf3(const char* fmt, ...) {
|
||||
va_list list;
|
||||
|
||||
if ((this->print_flags & EMU64_PRINTF3_FLAG)) {
|
||||
va_start(list, fmt);
|
||||
this->Vprintf(fmt, list);
|
||||
va_end(list);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
u8 print_flags;
|
||||
|
||||
private:
|
||||
void Vprintf(const char* fmt, std::__tag_va_List* va_list) {
|
||||
vprintf(fmt, va_list);
|
||||
}
|
||||
};
|
||||
|
||||
#define EMU64_ASSERTLINE(cond, line) \
|
||||
if (!(cond)) { \
|
||||
this->panic(#cond, __FILE__, line); \
|
||||
}
|
||||
|
||||
#define EMU64_PRINTF(msg, ...) this->Printf0(msg, __VA_ARGS__);
|
||||
|
||||
#ifdef EMU64_DEBUG
|
||||
@@ -604,8 +540,6 @@ class emu64_print {
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define EMU64_ASSERT(cond) EMU64_ASSERTLINE(cond, __LINE__)
|
||||
|
||||
#define EMU64_PRINT_MEMBER(member) \
|
||||
do { \
|
||||
this->Printf0(#member " = %u\n", this->##member); \
|
||||
@@ -786,7 +720,7 @@ class emu64 : public emu64_print {
|
||||
/* 0x0060 */ ucode_info* ucode_info_p;
|
||||
/* 0x0064 */ int ucode_type; // maybe?
|
||||
/* 0x0068 */ int _0068; /* ??? */
|
||||
/* 0x006C */ u32 segments[NUM_SEGMENTS];
|
||||
/* 0x006C */ u32 segments[EMU64_NUM_SEGMENTS];
|
||||
/* 0x00AC */ u32 DL_stack[DL_MAX_STACK_LEVEL];
|
||||
/* 0x00F4 */ s8 DL_stack_level;
|
||||
/* 0x00F8 */ u32 othermode_high;
|
||||
|
||||
+59
-59
@@ -1,59 +1,59 @@
|
||||
#ifndef FAULT_H
|
||||
#define FAULT_H
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSInterrupt.h"
|
||||
#include "libultra/libultra.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define FAULT_MIN_PRIORITY 0
|
||||
|
||||
#define FAULT_STAGE_POST 0
|
||||
#define FAULT_STAGE_PRE 1
|
||||
|
||||
#define FAULT_FLAG_POSTEXCEPTION (1 << FAULT_STAGE_POST)
|
||||
#define FAULT_FLAG_PREEXCEPTION (1 << FAULT_STAGE_PRE)
|
||||
|
||||
#define FAULT_FLAG_SKIP_DRAW_SEPARATOR (1 << 2)
|
||||
#define FAULT_FLAG_SKIP_DRAW_CALLBACK_INFO (1 << 3)
|
||||
|
||||
#define FAULT_PAD_READ_SUCCESS 0
|
||||
#define FAULT_PAD_READ_FAILED -1
|
||||
|
||||
typedef void (*FaultCallback)(const char* msg, u32 param);
|
||||
typedef struct fault_client_s fault_client;
|
||||
|
||||
struct fault_client_s {
|
||||
fault_client* next;
|
||||
FaultCallback callback;
|
||||
const char* msg;
|
||||
u32 param;
|
||||
u8 priority;
|
||||
u8 flags;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u8 _0, _1, _2, _3;
|
||||
u8 num_clients;
|
||||
fault_client* first_client;
|
||||
} fault;
|
||||
|
||||
|
||||
extern void fault_AddClientEx(fault_client* client, FaultCallback callback, const char* msg, u32 param, u8 priority, u8 flags);
|
||||
extern void fault_AddClient(fault_client* client, FaultCallback callback, const char* msg, u32 param);
|
||||
extern void fault_Printf(const char* msg, ...);
|
||||
static void fault_DrawUpdate();
|
||||
extern void fault_WaitTime(u32 waitTime);
|
||||
extern int fault_ReadPad(u32* outTriggers, u32* outButtons);
|
||||
static void fault_CallBackFunc(int stage);
|
||||
|
||||
extern void fault_Init();
|
||||
static void my_PreExceptionCallback();
|
||||
static void my_PostExceptionCallback();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifndef FAULT_H
|
||||
#define FAULT_H
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSInterrupt.h"
|
||||
#include "libultra/libultra.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define FAULT_MIN_PRIORITY 0
|
||||
|
||||
#define FAULT_STAGE_POST 0
|
||||
#define FAULT_STAGE_PRE 1
|
||||
|
||||
#define FAULT_FLAG_POSTEXCEPTION (1 << FAULT_STAGE_POST)
|
||||
#define FAULT_FLAG_PREEXCEPTION (1 << FAULT_STAGE_PRE)
|
||||
|
||||
#define FAULT_FLAG_SKIP_DRAW_SEPARATOR (1 << 2)
|
||||
#define FAULT_FLAG_SKIP_DRAW_CALLBACK_INFO (1 << 3)
|
||||
|
||||
#define FAULT_PAD_READ_SUCCESS 0
|
||||
#define FAULT_PAD_READ_FAILED -1
|
||||
|
||||
typedef void (*FaultCallback)(const char* msg, u32 param);
|
||||
typedef struct fault_client_s fault_client;
|
||||
|
||||
struct fault_client_s {
|
||||
fault_client* next;
|
||||
FaultCallback callback;
|
||||
const char* msg;
|
||||
u32 param;
|
||||
u8 priority;
|
||||
u8 flags;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u8 _0, _1, _2, _3;
|
||||
u8 num_clients;
|
||||
fault_client* first_client;
|
||||
} fault;
|
||||
|
||||
|
||||
extern void fault_AddClientEx(fault_client* client, FaultCallback callback, const char* msg, u32 param, u8 priority, u8 flags);
|
||||
extern void fault_AddClient(fault_client* client, FaultCallback callback, const char* msg, u32 param);
|
||||
extern void fault_Printf(const char* msg, ...);
|
||||
static void fault_DrawUpdate();
|
||||
extern void fault_WaitTime(u32 waitTime);
|
||||
extern int fault_ReadPad(u32* outTriggers, u32* outButtons);
|
||||
static void fault_CallBackFunc(int stage);
|
||||
|
||||
extern void fault_Init();
|
||||
static void my_PreExceptionCallback();
|
||||
static void my_PostExceptionCallback();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+129
-129
@@ -1,129 +1,129 @@
|
||||
#ifndef GFXPRINT_H
|
||||
#define GFXPRINT_H
|
||||
|
||||
#include "types.h"
|
||||
#include "libu64/u64types.h"
|
||||
#include "PR/mbi.h"
|
||||
#include "va_args.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define GFXPRINT_NUM_SUBPIXELS 4
|
||||
#define GFXPRINT_PIXELS_PER_BLOCK 8
|
||||
#define GFXPRINT_PAD GFXPRINT_PIXELS_PER_BLOCK * GFXPRINT_NUM_SUBPIXELS
|
||||
|
||||
#define GFXPRINT_FLAG_KANA_MODE (1 << 0) /* Japanese characters displayed as hiragana or katakana */
|
||||
#define GFXPRINT_FLAG_GRADIENT (1 << 1) /* Gradient state */
|
||||
#define GFXPRINT_FLAG_SHADOW (1 << 2) /* Shadow state */
|
||||
#define GFXPRINT_FLAG_CHANGED (1 << 3) /* Text changed */
|
||||
/* Unused...? */
|
||||
#define GFXPRINT_FLAG_HIGHRES (1 << 6) /* Highres text */
|
||||
#define GFXPRINT_FLAG_OPENED (1 << 7) /* Open state */
|
||||
|
||||
#define GFXPRINT_KANA_MODE_KATAKANA 0
|
||||
#define GFXPRINT_KANA_MODE_HIRAGANA 1
|
||||
|
||||
#define GFXPRINT_CLEAR_GRADIENT_CHAR "\x8A"
|
||||
#define GFXPRINT_ENABLE_GRADIENT_CHAR "\x8B"
|
||||
|
||||
#define GFXPRINT_KATAKANA_MODE_CHAR "\x8C"
|
||||
#define GFXPRINT_HIRAGANA_MODE_CHAR "\x8D"
|
||||
|
||||
#define GFXPRINT_UNUSED_CHAR "\x8E"
|
||||
|
||||
/* NOTE: this should be a void return type but we're going to use a void* for readibility */
|
||||
typedef void* (*PrintCallback)(void*, const char*, int);
|
||||
typedef struct gfxprint_obj {
|
||||
PrintCallback prout_func; /* Current print out func */
|
||||
Gfx* glistp; /* Current display list to write text to */
|
||||
u16 position_x; /* Display coords (sub-pixel units) */
|
||||
u16 position_y; /* Display coords (sub-pixel units) */
|
||||
u16 offset_x; /* Display offset */
|
||||
u8 offset_y; /* Display offset */
|
||||
u8 flags; /* 1: Kana mode -> 0: Katakana/1: Hiragana
|
||||
2: Gradient displayed
|
||||
4: Shadow displayed
|
||||
8: Attribute changed
|
||||
64: Low-res -> high-res conversion
|
||||
128: Opened state */
|
||||
rgba8888 color; /* Current font color */
|
||||
u8 dummy[28]; /* For size compatibility */
|
||||
} gfxprint_t;
|
||||
|
||||
/* Default gfxprint flag values set in game_ct func, default value is 0x40 (GFXPRINT_FLAG_HIGHRES on) */
|
||||
extern u8 __gfxprint_default_flags;
|
||||
|
||||
extern u16 gfxprint_moji_tlut[];
|
||||
extern u8 gfxprint_font[];
|
||||
|
||||
/* Macros for quickly checking state of gfxprint struct */
|
||||
#define gfxprint_isFlagOn(this, flag) ((this->flags & flag) != 0)
|
||||
#define gfxprint_setFlag(this, flag) (this->flags |= flag)
|
||||
#define gfxprint_clrFlag(this, flag) (this->flags &= ~flag)
|
||||
|
||||
#define gfxprint_isOpened(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_OPENED))
|
||||
#define gfxprint_setOpened(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_OPENED))
|
||||
#define gfxprint_clrOpened(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_OPENED))
|
||||
|
||||
#define gfxprint_isHighres(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_HIGHRES))
|
||||
#define gfxprint_setHighres(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_HIGHRES))
|
||||
#define gfxprint_clrHighres(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_HIGHRES))
|
||||
|
||||
#define gfxprint_isHiragana(this) ((this->flags & GFXPRINT_FLAG_KANA_MODE) != GFXPRINT_KANA_MODE_KATAKANA)
|
||||
#define gfxprint_isKatakana(this) ((this->flags & GFXPRINT_FLAG_KANA_MODE) == GFXPRINT_KANA_MODE_KATAKANA)
|
||||
#define gfxprint_setHiragana(this) (this->flags |= GFXPRINT_FLAG_KANA_MODE)
|
||||
#define gfxprint_setKatakana(this) (this->flags &= ~GFXPRINT_FLAG_KANA_MODE)
|
||||
|
||||
#define gfxprint_isGradient(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_GRADIENT))
|
||||
#define gfxprint_setGradient(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_GRADIENT))
|
||||
#define gfxprint_clrGradient(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_GRADIENT))
|
||||
|
||||
#define gfxprint_isShadow(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_SHADOW))
|
||||
#define gfxprint_setShadow(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_SHADOW))
|
||||
#define gfxprint_clrShadow(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_SHADOW))
|
||||
|
||||
#define gfxprint_isChanged(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_CHANGED))
|
||||
#define gfxprint_setChanged(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_CHANGED))
|
||||
#define gfxprint_clrChanged(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_CHANGED))
|
||||
|
||||
static void gfxprint_setup(gfxprint_t* this);
|
||||
static void gfxprint_putc1(gfxprint_t* this, char c);
|
||||
static void* gfxprint_prout(void* this, const char* buffer, int n);
|
||||
|
||||
extern void gfxprint_color(gfxprint_t* this, u32 r, u32 g, u32 b, u32 a);
|
||||
|
||||
extern void gfxprint_locate(gfxprint_t* this, int x, int y);
|
||||
extern void gfxprint_locate8x8(gfxprint_t* this, int x, int y);
|
||||
extern void gfxprint_setoffset(gfxprint_t* this, int x, int y);
|
||||
|
||||
extern void gfxprint_putc(gfxprint_t* this, char c);
|
||||
extern void gfxprint_write(gfxprint_t* this, const void* buffer, size_t size, size_t n);
|
||||
extern void gfxprint_puts(gfxprint_t* this, char* string);
|
||||
|
||||
extern void gfxprint_init(gfxprint_t* this);
|
||||
extern void gfxprint_cleanup(gfxprint_t* this);
|
||||
|
||||
extern void gfxprint_open(gfxprint_t* this, Gfx* glistp);
|
||||
extern Gfx* gfxprint_close(gfxprint_t* this);
|
||||
|
||||
extern int gfxprint_vprintf(gfxprint_t* this, const char* fmt, va_list ap);
|
||||
extern int gfxprint_printf(gfxprint_t* this, const char* fmt, ...);
|
||||
|
||||
/* Custom macro to match gDPLoadTLUT_pal16 but with N palette entries */
|
||||
#define gDPLoadTLUT_palX(pkt, pal, dram, count) \
|
||||
do { \
|
||||
gDPSetTextureImage(pkt, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram); \
|
||||
gDPTileSync(pkt); \
|
||||
gDPSetTile(pkt, 0, 0, 0, (256+(((pal)&0xf)*16)), \
|
||||
G_TX_LOADTILE, 0 , 0, 0, 0, 0, 0, 0); \
|
||||
gDPLoadSync(pkt); \
|
||||
gDPLoadTLUTCmd(pkt, G_TX_LOADTILE, (count)-1); \
|
||||
gDPPipeSync(pkt); \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifndef GFXPRINT_H
|
||||
#define GFXPRINT_H
|
||||
|
||||
#include "types.h"
|
||||
#include "libu64/u64types.h"
|
||||
#include "PR/mbi.h"
|
||||
#include "va_args.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define GFXPRINT_NUM_SUBPIXELS 4
|
||||
#define GFXPRINT_PIXELS_PER_BLOCK 8
|
||||
#define GFXPRINT_PAD GFXPRINT_PIXELS_PER_BLOCK * GFXPRINT_NUM_SUBPIXELS
|
||||
|
||||
#define GFXPRINT_FLAG_KANA_MODE (1 << 0) /* Japanese characters displayed as hiragana or katakana */
|
||||
#define GFXPRINT_FLAG_GRADIENT (1 << 1) /* Gradient state */
|
||||
#define GFXPRINT_FLAG_SHADOW (1 << 2) /* Shadow state */
|
||||
#define GFXPRINT_FLAG_CHANGED (1 << 3) /* Text changed */
|
||||
/* Unused...? */
|
||||
#define GFXPRINT_FLAG_HIGHRES (1 << 6) /* Highres text */
|
||||
#define GFXPRINT_FLAG_OPENED (1 << 7) /* Open state */
|
||||
|
||||
#define GFXPRINT_KANA_MODE_KATAKANA 0
|
||||
#define GFXPRINT_KANA_MODE_HIRAGANA 1
|
||||
|
||||
#define GFXPRINT_CLEAR_GRADIENT_CHAR "\x8A"
|
||||
#define GFXPRINT_ENABLE_GRADIENT_CHAR "\x8B"
|
||||
|
||||
#define GFXPRINT_KATAKANA_MODE_CHAR "\x8C"
|
||||
#define GFXPRINT_HIRAGANA_MODE_CHAR "\x8D"
|
||||
|
||||
#define GFXPRINT_UNUSED_CHAR "\x8E"
|
||||
|
||||
/* NOTE: this should be a void return type but we're going to use a void* for readibility */
|
||||
typedef void* (*PrintCallback)(void*, const char*, int);
|
||||
typedef struct gfxprint_obj {
|
||||
PrintCallback prout_func; /* Current print out func */
|
||||
Gfx* glistp; /* Current display list to write text to */
|
||||
u16 position_x; /* Display coords (sub-pixel units) */
|
||||
u16 position_y; /* Display coords (sub-pixel units) */
|
||||
u16 offset_x; /* Display offset */
|
||||
u8 offset_y; /* Display offset */
|
||||
u8 flags; /* 1: Kana mode -> 0: Katakana/1: Hiragana
|
||||
2: Gradient displayed
|
||||
4: Shadow displayed
|
||||
8: Attribute changed
|
||||
64: Low-res -> high-res conversion
|
||||
128: Opened state */
|
||||
rgba8888 color; /* Current font color */
|
||||
u8 dummy[28]; /* For size compatibility */
|
||||
} gfxprint_t;
|
||||
|
||||
/* Default gfxprint flag values set in game_ct func, default value is 0x40 (GFXPRINT_FLAG_HIGHRES on) */
|
||||
extern u8 __gfxprint_default_flags;
|
||||
|
||||
extern u16 gfxprint_moji_tlut[];
|
||||
extern u8 gfxprint_font[];
|
||||
|
||||
/* Macros for quickly checking state of gfxprint struct */
|
||||
#define gfxprint_isFlagOn(this, flag) ((this->flags & flag) != 0)
|
||||
#define gfxprint_setFlag(this, flag) (this->flags |= flag)
|
||||
#define gfxprint_clrFlag(this, flag) (this->flags &= ~flag)
|
||||
|
||||
#define gfxprint_isOpened(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_OPENED))
|
||||
#define gfxprint_setOpened(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_OPENED))
|
||||
#define gfxprint_clrOpened(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_OPENED))
|
||||
|
||||
#define gfxprint_isHighres(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_HIGHRES))
|
||||
#define gfxprint_setHighres(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_HIGHRES))
|
||||
#define gfxprint_clrHighres(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_HIGHRES))
|
||||
|
||||
#define gfxprint_isHiragana(this) ((this->flags & GFXPRINT_FLAG_KANA_MODE) != GFXPRINT_KANA_MODE_KATAKANA)
|
||||
#define gfxprint_isKatakana(this) ((this->flags & GFXPRINT_FLAG_KANA_MODE) == GFXPRINT_KANA_MODE_KATAKANA)
|
||||
#define gfxprint_setHiragana(this) (this->flags |= GFXPRINT_FLAG_KANA_MODE)
|
||||
#define gfxprint_setKatakana(this) (this->flags &= ~GFXPRINT_FLAG_KANA_MODE)
|
||||
|
||||
#define gfxprint_isGradient(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_GRADIENT))
|
||||
#define gfxprint_setGradient(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_GRADIENT))
|
||||
#define gfxprint_clrGradient(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_GRADIENT))
|
||||
|
||||
#define gfxprint_isShadow(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_SHADOW))
|
||||
#define gfxprint_setShadow(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_SHADOW))
|
||||
#define gfxprint_clrShadow(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_SHADOW))
|
||||
|
||||
#define gfxprint_isChanged(this) (gfxprint_isFlagOn(this, GFXPRINT_FLAG_CHANGED))
|
||||
#define gfxprint_setChanged(this) (gfxprint_setFlag(this, GFXPRINT_FLAG_CHANGED))
|
||||
#define gfxprint_clrChanged(this) (gfxprint_clrFlag(this, GFXPRINT_FLAG_CHANGED))
|
||||
|
||||
static void gfxprint_setup(gfxprint_t* this);
|
||||
static void gfxprint_putc1(gfxprint_t* this, char c);
|
||||
static void* gfxprint_prout(void* this, const char* buffer, int n);
|
||||
|
||||
extern void gfxprint_color(gfxprint_t* this, u32 r, u32 g, u32 b, u32 a);
|
||||
|
||||
extern void gfxprint_locate(gfxprint_t* this, int x, int y);
|
||||
extern void gfxprint_locate8x8(gfxprint_t* this, int x, int y);
|
||||
extern void gfxprint_setoffset(gfxprint_t* this, int x, int y);
|
||||
|
||||
extern void gfxprint_putc(gfxprint_t* this, char c);
|
||||
extern void gfxprint_write(gfxprint_t* this, const void* buffer, size_t size, size_t n);
|
||||
extern void gfxprint_puts(gfxprint_t* this, char* string);
|
||||
|
||||
extern void gfxprint_init(gfxprint_t* this);
|
||||
extern void gfxprint_cleanup(gfxprint_t* this);
|
||||
|
||||
extern void gfxprint_open(gfxprint_t* this, Gfx* glistp);
|
||||
extern Gfx* gfxprint_close(gfxprint_t* this);
|
||||
|
||||
extern int gfxprint_vprintf(gfxprint_t* this, const char* fmt, va_list ap);
|
||||
extern int gfxprint_printf(gfxprint_t* this, const char* fmt, ...);
|
||||
|
||||
/* Custom macro to match gDPLoadTLUT_pal16 but with N palette entries */
|
||||
#define gDPLoadTLUT_palX(pkt, pal, dram, count) \
|
||||
do { \
|
||||
gDPSetTextureImage(pkt, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram); \
|
||||
gDPTileSync(pkt); \
|
||||
gDPSetTile(pkt, 0, 0, 0, (256+(((pal)&0xf)*16)), \
|
||||
G_TX_LOADTILE, 0 , 0, 0, 0, 0, 0, 0); \
|
||||
gDPLoadSync(pkt); \
|
||||
gDPLoadTLUTCmd(pkt, G_TX_LOADTILE, (count)-1); \
|
||||
gDPPipeSync(pkt); \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+41
-41
@@ -1,41 +1,41 @@
|
||||
#ifndef LIBULTRA_H
|
||||
#define LIBULTRA_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSTime.h"
|
||||
#include "dolphin/os/OSCache.h"
|
||||
#include "libultra/gu.h"
|
||||
#include "libultra/osMesg.h"
|
||||
#include "libultra/shutdown.h"
|
||||
#include "libultra/os_timer.h"
|
||||
#include "libultra/os_thread.h"
|
||||
#include "libultra/os_pi.h"
|
||||
#include "libultra/initialize.h"
|
||||
#include "libc/math.h" /* TODO: sins and coss belong in libultra */
|
||||
|
||||
#define N64_SCREEN_HEIGHT 240
|
||||
#define N64_SCREEN_WIDTH 320
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef u64 Z_OSTime;
|
||||
|
||||
int bcmp(void* v1, void* v2, u32 size);
|
||||
void bcopy(void* src, void* dst, size_t n);
|
||||
void bzero(void* ptr, size_t size);
|
||||
void osSyncPrintf(const char* fmt, ...);
|
||||
void osWritebackDCache(void* vaddr, u32 nbytes);
|
||||
u32 osGetCount(void);
|
||||
OSTime osGetTime(void);
|
||||
|
||||
extern s32 osAppNMIBuffer[];
|
||||
extern int osShutdown;
|
||||
extern u8 __osResetSwitchPressed;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifndef LIBULTRA_H
|
||||
#define LIBULTRA_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/os/OSTime.h"
|
||||
#include "dolphin/os/OSCache.h"
|
||||
#include "libultra/gu.h"
|
||||
#include "libultra/osMesg.h"
|
||||
#include "libultra/shutdown.h"
|
||||
#include "libultra/os_timer.h"
|
||||
#include "libultra/os_thread.h"
|
||||
#include "libultra/os_pi.h"
|
||||
#include "libultra/initialize.h"
|
||||
#include "libc/math.h" /* TODO: sins and coss belong in libultra */
|
||||
|
||||
#define N64_SCREEN_HEIGHT 240
|
||||
#define N64_SCREEN_WIDTH 320
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef u64 Z_OSTime;
|
||||
|
||||
int bcmp(void* v1, void* v2, u32 size);
|
||||
void bcopy(void* src, void* dst, size_t n);
|
||||
void bzero(void* ptr, size_t size);
|
||||
void osSyncPrintf(const char* fmt, ...);
|
||||
void osWritebackDCache(void* vaddr, u32 nbytes);
|
||||
u32 osGetCount(void);
|
||||
OSTime osGetTime(void);
|
||||
|
||||
extern s32 osAppNMIBuffer[];
|
||||
extern int osShutdown;
|
||||
extern u8 __osResetSwitchPressed;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+10
-10
@@ -28,22 +28,22 @@ extern "C" {
|
||||
#define CHAR_ACUTE_I 14
|
||||
#define CHAR_CIRCUMFLEX_I 15
|
||||
#define CHAR_DIARESIS_I 16
|
||||
#define CHAR_ETH 17 /* Đ */
|
||||
#define CHAR_ETH 17
|
||||
#define CHAR_TILDE_N 18
|
||||
#define CHAR_GRAVE_O 19
|
||||
#define CHAR_ACUTE_O 20
|
||||
#define CHAR_CIRCUMFLEX_O 21
|
||||
#define CHAR_TILDE_O 22
|
||||
#define CHAR_DIARESIS_O 23
|
||||
#define CHAR_OE 24 /* Ø */
|
||||
#define CHAR_OE 24
|
||||
#define CHAR_GRAVE_U 25
|
||||
#define CHAR_ACUTE_U 26
|
||||
#define CHAR_CIRCUMFLEX_U 27
|
||||
#define CHAR_DIARESIS_U 28
|
||||
#define CHAR_LOWER_BETA 29 /* β */
|
||||
#define CHAR_THORN 30 /* Þ */
|
||||
#define CHAR_LOWER_BETA 29
|
||||
#define CHAR_THORN 30
|
||||
#define CHAR_GRAVE_a 31
|
||||
#define CHAR_SPACE 32 /* ' ' */
|
||||
#define CHAR_SPACE 32
|
||||
#define CHAR_EXCLAMATION 33
|
||||
#define CHAR_QUOTATION 34
|
||||
#define CHAR_ACUTE_a 35
|
||||
@@ -144,8 +144,8 @@ extern "C" {
|
||||
#define CHAR_ACUTE_i 130
|
||||
#define CHAR_CIRCUMFLEX_i 131
|
||||
#define CHAR_DIARESIS_i 132
|
||||
#define CHAR_INTERPUNCT 133 /* · */
|
||||
#define CHAR_LOWER_ETH 134 /* đ */
|
||||
#define CHAR_INTERPUNCT 133
|
||||
#define CHAR_LOWER_ETH 134
|
||||
#define CHAR_TILDE_n 135
|
||||
#define CHAR_GRAVE_o 136
|
||||
#define CHAR_ACUTE_o 137
|
||||
@@ -162,10 +162,10 @@ extern "C" {
|
||||
#define CHAR_DIARESIS_y 148
|
||||
#define CHAR_LOWER_THORN 149
|
||||
#define CHAR_ACUTE_Y 150
|
||||
#define CHAR_BROKEN_BAR 151 /* ¦ */
|
||||
#define CHAR_SILCROW 152 /* § */
|
||||
#define CHAR_BROKEN_BAR 151
|
||||
#define CHAR_SILCROW 152
|
||||
#define CHAR_FEMININE_ORDINAL 153
|
||||
#define CHAR_MASCULINE_ORDINAL 154 /* ° */
|
||||
#define CHAR_MASCULINE_ORDINAL 154
|
||||
#define CHAR_DOUBLE_VERTICAL_BAR 155
|
||||
#define CHAR_LATIN_MU 156
|
||||
#define CHAR_SUPERSCRIPT_THREE 157
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "types.h"
|
||||
#include "m_music_ovl_h.h"
|
||||
#include "m_submenu_ovl.h"
|
||||
#include "m_item_name.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
+183
-183
@@ -1,184 +1,184 @@
|
||||
#ifndef ROOM_TYPE_H
|
||||
#define ROOM_TYPE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "libu64/gfxprint.h"
|
||||
#include "m_actor_type.h"
|
||||
#include "m_play_h.h"
|
||||
|
||||
#define mRmTp_FTR_UNIT_MAX 4
|
||||
|
||||
enum {
|
||||
mRmTp_FTRSIZE_1x1, /* x */
|
||||
mRmTp_FTRSIZE_1x2, /* yy OR y */
|
||||
/* y */
|
||||
mRmTp_FTRSIZE_2x2, /* zz */
|
||||
/* zz */
|
||||
mRmTp_FTRSIZE_NUM
|
||||
};
|
||||
|
||||
enum birth_type {
|
||||
mRmTp_BIRTH_TYPE_GRP_A = 0,
|
||||
mRmTp_BIRTH_TYPE_GRP_B = 1,
|
||||
mRmTp_BIRTH_TYPE_GRP_C = 2,
|
||||
mRmTp_BIRTH_TYPE_EVENT = 3,
|
||||
mRmTp_BIRTH_TYPE_BIRTHDAY = 4,
|
||||
mRmTp_BIRTH_TYPE_HALLOWEEN = 5,
|
||||
mRmTp_BIRTH_TYPE_HANIWA = 6,
|
||||
mRmTp_BIRTH_TYPE_LOTTERY = 7,
|
||||
mRmTp_BIRTH_TYPE_FTR_CLOTH = 8,
|
||||
mRmTp_BIRTH_TYPE_FTR_UMBRELLA = 9,
|
||||
mRmTp_BIRTH_TYPE_FTR_INSECT = 10,
|
||||
mRmTp_BIRTH_TYPE_FTR_FISH = 11,
|
||||
mRmTp_BIRTH_TYPE_SINGLE_FOSSIL = 12,
|
||||
mRmTp_BIRTH_TYPE_MULTI_FOSSIL = 13,
|
||||
mRmTp_BIRTH_TYPE_XMAS = 14,
|
||||
mRmTp_BIRTH_TYPE_SANTA = 15,
|
||||
mRmTp_BIRTH_TYPE_UNOBTAINABLE = 16,
|
||||
mRmTp_BIRTH_TYPE_SNOWMAN = 17,
|
||||
mRmTp_BIRTH_TYPE_HALLOWEEN_TRICK = 18,
|
||||
mRmTp_BIRTH_TYPE_POST_OFFICE = 19,
|
||||
mRmTp_BIRTH_TYPE_MARK_ROOM = 20,
|
||||
mRmTp_BIRTH_TYPE_SONCHO = 21,
|
||||
mRmTp_BIRTH_TYPE_JONASON = 22,
|
||||
mRmTp_BIRTH_TYPE_UNUSED_23 = 23,
|
||||
mRmTp_BIRTH_TYPE_FAMICOM_EREADER = 24,
|
||||
mRmTp_BIRTH_TYPE_ISLAND = 25,
|
||||
mRmTp_BIRTH_TYPE_FAMICOM_ISLAND = 26,
|
||||
mRmTp_BIRTH_TYPE_MY_ORIGINAL = 27,
|
||||
mRmTp_BIRTH_TYPE_FAMICOM_CODE = 28,
|
||||
mRmTp_BIRTH_TYPE_MUSEUM = 29,
|
||||
mRmTp_BIRTH_TYPE_SONCHO_LIGHTHOUSE_QUEST = 30,
|
||||
mRmTp_BIRTH_TYPE_FTR_DIARY = 31,
|
||||
mRmTp_BIRTH_TYPE_GROUNDHOG = 32,
|
||||
mRmTp_BIRTH_TYPE_KAMAKURA = 33,
|
||||
mRmTp_BIRTH_TYPE_NINTENDO_CODE = 34,
|
||||
mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL = 35,
|
||||
mRmTp_BIRTH_TYPE_UNUSED_36 = 36,
|
||||
mRmTp_BIRTH_TYPE_SUMMER_CAMPER = 37,
|
||||
|
||||
mRmTp_BIRTH_TYPE_NUM
|
||||
};
|
||||
|
||||
enum {
|
||||
mRmTp_DIRECT_SOUTH,
|
||||
mRmTp_DIRECT_EAST,
|
||||
mRmTp_DIRECT_NORTH,
|
||||
mRmTp_DIRECT_WEST,
|
||||
|
||||
mRmTp_DIRECT_NUM
|
||||
};
|
||||
|
||||
enum {
|
||||
mRmTp_FTR_SE_NONE,
|
||||
mRmTp_FTR_SE_SOFT_CHAIR,
|
||||
mRmTp_FTR_SE_HARD_CHAIR,
|
||||
mRmTp_FTR_SE_BUBU_CHAIR,
|
||||
mRmTp_FTR_SE_TOILET_CHAIR,
|
||||
|
||||
mRmTp_FTR_SE_NUM
|
||||
};
|
||||
|
||||
enum {
|
||||
mRmTp_CHAIR_ACTION_SIT,
|
||||
mRmTp_CHAIR_ACTION_STAND,
|
||||
|
||||
mRmTp_CHAIR_ACTION_NUM
|
||||
};
|
||||
|
||||
typedef struct room_type_place_info_one_s {
|
||||
int exists;
|
||||
int ut_x;
|
||||
int ut_z;
|
||||
} mRmTp_FtrPlaceInfoOne_t;
|
||||
|
||||
#define FTR_NUM 1266
|
||||
|
||||
#define FTR_GET_ROTATION(f) ((f)&3)
|
||||
#define FTR_IDX_2_NO(f) ((f) >> 2)
|
||||
#define FTR_NO_2_IDX(f) ((f) << 2)
|
||||
#define FTR_NO_ROT_2_IDX(f, rot) (FTR_NO_2_IDX(f) | ((rot)&3))
|
||||
|
||||
// TEMPORARY. Should be generated with .decl files
|
||||
#define ITEM0_NO_START 0x0000
|
||||
#define ITEM0_1_NO_START ITEM0_NO_START + 0x800
|
||||
|
||||
#define FTR0_NO_START 0x1000
|
||||
|
||||
#define ITEM1_NO_START 0x2000
|
||||
#define ITEM1_0_NO_START ITEM0_1_NO_START // paper
|
||||
#define ITEM1_1_NO_START ITEM1_NO_START + 0x100 // money
|
||||
#define ITEM1_2_NO_START ITEM1_NO_START + 0x200 // tools
|
||||
#define ITEM1_3_NO_START ITEM1_NO_START + 0x300 // fish
|
||||
#define ITEM1_4_NO_START ITEM1_NO_START + 0x400 // clothing
|
||||
#define ITEM1_5_NO_START ITEM1_NO_START + 0x500 // etc
|
||||
#define ITEM1_6_NO_START ITEM1_NO_START + 0x600 // carpets
|
||||
#define ITEM1_7_NO_START ITEM1_NO_START + 0x700 // wallpaper
|
||||
#define ITEM1_8_NO_START ITEM1_NO_START + 0x800 // food
|
||||
#define ITEM1_9_NO_START ITEM1_NO_START + 0x900 // seeds
|
||||
#define ITEM1_A_NO_START ITEM1_NO_START + 0xA00 // mini disks
|
||||
#define ITEM1_B_NO_START ITEM1_NO_START + 0xB00 // diaries
|
||||
#define ITEM1_C_NO_START ITEM1_NO_START + 0xC00 // tickets
|
||||
#define ITEM1_D_NO_START ITEM1_NO_START + 0xD00 // insects
|
||||
#define ITEM1_E_NO_START ITEM1_NO_START + 0xE00 // hukubukuro
|
||||
#define ITEM1_F_NO_START ITEM1_NO_START + 0xF00 // kabu
|
||||
|
||||
#define FTR1_NO_START 0x3000
|
||||
|
||||
enum {
|
||||
mRmTp_LIGHT_SWITCH_HOUSE0_MAIN_UPPER,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE0_BASEMENT,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE1_MAIN_UPPER,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE1_BASEMENT,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE2_MAIN_UPPER,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE2_BASEMENT,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE3_MAIN_UPPER,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE3_BASEMENT,
|
||||
mRmTp_LIGHT_SWITCH_COTTAGE_MY,
|
||||
mRmTp_LIGHT_SWITCH_9,
|
||||
mRmTp_LIGHT_SWITCH_NPC,
|
||||
mRmTp_LIGHT_SWITCH_LIGHTHOUSE,
|
||||
mRmTp_LIGHT_SWITCH_TENT,
|
||||
|
||||
mRmTp_LIGHT_SWITCH_NUM
|
||||
};
|
||||
|
||||
extern int mRmTp_ItemNo2FtrSize(mActor_name_t item_no);
|
||||
extern int mRmTp_GetFurnitureData(mActor_name_t ftr, int ut_x, int ut_z, mRmTp_FtrPlaceInfoOne_t* place_info);
|
||||
extern void mRmTp_MakeFtrNoTable(mActor_name_t* dst, mActor_name_t* src);
|
||||
extern int mRmTp_GetFtrActionSE(int ftr_idx, int mode);
|
||||
extern u8* mRmTp_CheckFtrBirthInfoTop();
|
||||
extern int mRmTp_GetFloorIdx();
|
||||
extern int mRmTp_GetWallIdx();
|
||||
extern mActor_name_t mRmTp_Item1ItemNo2FtrItemNo_AtPlayerRoom(mActor_name_t item1_no, int no_convert_tools);
|
||||
extern mActor_name_t mRmTp_FtrItemNo2Item1ItemNo(mActor_name_t ftr_no, int no_convert_tools);
|
||||
extern void mRmTp_MakeMelodyData();
|
||||
extern u8* mRmTp_GetMelodyData();
|
||||
extern void mRmTp_DrawFamicomInfo(gfxprint_t* gfxprint);
|
||||
extern void mRmTp_MakeFamicom_Fdebug();
|
||||
extern mActor_name_t mRmTp_GetPlayerRoomCollisionIdx(mActor_name_t field_id, mActor_name_t bg_idx);
|
||||
extern int mRmTp_FurnitureIdx2FurnitureKind(int ftr_idx);
|
||||
extern void mRmTp_CopyWallData(u8* dst, int wall_no);
|
||||
extern void mRmTp_CopyFloorData(u8* dst, int floor_no);
|
||||
extern int mRmTp_CheckTalkAble(s16* rot, xyz_t* pos, int required_dir, f32 max_dist, GAME_PLAY* play);
|
||||
extern int mRmTp_CheckWallIsMyOriginalInThisScene();
|
||||
extern int mRmTp_CheckFloorIsMyOriginalInThisScene();
|
||||
extern int mRmTp_GetEntranceBasePosition(xyz_t* pos);
|
||||
extern int mRmTp_GetNowSceneLightSwitchIndex();
|
||||
extern int mRmTp_PleaseDrawLightSwitch();
|
||||
extern int mRmTp_NowSceneLightSwitchON();
|
||||
extern int mRmTp_IndexLightSwitchON(int switch_index);
|
||||
extern int mRmTp_NowSceneLightSwitchOFF();
|
||||
extern int mRmTp_IndexLightSwitchOFF(int switch_index);
|
||||
extern int mRmTp_Index2LightSwitchStatus(int switch_index);
|
||||
extern int mRmTp_SetDefaultLightSwitchData(int state);
|
||||
extern void mRmTp_DecideCottageDefaultLightSwitch();
|
||||
extern int mRmTp_GetNowSceneOriginalWallStatus();
|
||||
extern int mRmTp_GetNowSceneOriginalFloorStatus();
|
||||
extern void mRmTp_SetNowSceneOriginalWallStatus(int enabled);
|
||||
extern void mRmTp_SetNowSceneOriginalFloorStatus(int enabled);
|
||||
extern int mRmTp_FtrItemNo2FtrIdx(mActor_name_t ftr_item_no);
|
||||
extern mActor_name_t mRmTp_FtrIdx2FtrItemNo(int ftr_idx, int direct);
|
||||
extern int mRmTp_SoundStepWalkSE(xyz_t* wpos);
|
||||
|
||||
#ifndef ROOM_TYPE_H
|
||||
#define ROOM_TYPE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "libu64/gfxprint.h"
|
||||
#include "m_actor_type.h"
|
||||
#include "m_play_h.h"
|
||||
|
||||
#define mRmTp_FTR_UNIT_MAX 4
|
||||
|
||||
enum {
|
||||
mRmTp_FTRSIZE_1x1, /* x */
|
||||
mRmTp_FTRSIZE_1x2, /* yy OR y */
|
||||
/* y */
|
||||
mRmTp_FTRSIZE_2x2, /* zz */
|
||||
/* zz */
|
||||
mRmTp_FTRSIZE_NUM
|
||||
};
|
||||
|
||||
enum birth_type {
|
||||
mRmTp_BIRTH_TYPE_GRP_A = 0,
|
||||
mRmTp_BIRTH_TYPE_GRP_B = 1,
|
||||
mRmTp_BIRTH_TYPE_GRP_C = 2,
|
||||
mRmTp_BIRTH_TYPE_EVENT = 3,
|
||||
mRmTp_BIRTH_TYPE_BIRTHDAY = 4,
|
||||
mRmTp_BIRTH_TYPE_HALLOWEEN = 5,
|
||||
mRmTp_BIRTH_TYPE_HANIWA = 6,
|
||||
mRmTp_BIRTH_TYPE_LOTTERY = 7,
|
||||
mRmTp_BIRTH_TYPE_FTR_CLOTH = 8,
|
||||
mRmTp_BIRTH_TYPE_FTR_UMBRELLA = 9,
|
||||
mRmTp_BIRTH_TYPE_FTR_INSECT = 10,
|
||||
mRmTp_BIRTH_TYPE_FTR_FISH = 11,
|
||||
mRmTp_BIRTH_TYPE_SINGLE_FOSSIL = 12,
|
||||
mRmTp_BIRTH_TYPE_MULTI_FOSSIL = 13,
|
||||
mRmTp_BIRTH_TYPE_XMAS = 14,
|
||||
mRmTp_BIRTH_TYPE_SANTA = 15,
|
||||
mRmTp_BIRTH_TYPE_UNOBTAINABLE = 16,
|
||||
mRmTp_BIRTH_TYPE_SNOWMAN = 17,
|
||||
mRmTp_BIRTH_TYPE_HALLOWEEN_TRICK = 18,
|
||||
mRmTp_BIRTH_TYPE_POST_OFFICE = 19,
|
||||
mRmTp_BIRTH_TYPE_MARK_ROOM = 20,
|
||||
mRmTp_BIRTH_TYPE_SONCHO = 21,
|
||||
mRmTp_BIRTH_TYPE_JONASON = 22,
|
||||
mRmTp_BIRTH_TYPE_UNUSED_23 = 23,
|
||||
mRmTp_BIRTH_TYPE_FAMICOM_EREADER = 24,
|
||||
mRmTp_BIRTH_TYPE_ISLAND = 25,
|
||||
mRmTp_BIRTH_TYPE_FAMICOM_ISLAND = 26,
|
||||
mRmTp_BIRTH_TYPE_MY_ORIGINAL = 27,
|
||||
mRmTp_BIRTH_TYPE_FAMICOM_CODE = 28,
|
||||
mRmTp_BIRTH_TYPE_MUSEUM = 29,
|
||||
mRmTp_BIRTH_TYPE_SONCHO_LIGHTHOUSE_QUEST = 30,
|
||||
mRmTp_BIRTH_TYPE_FTR_DIARY = 31,
|
||||
mRmTp_BIRTH_TYPE_GROUNDHOG = 32,
|
||||
mRmTp_BIRTH_TYPE_KAMAKURA = 33,
|
||||
mRmTp_BIRTH_TYPE_NINTENDO_CODE = 34,
|
||||
mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL = 35,
|
||||
mRmTp_BIRTH_TYPE_UNUSED_36 = 36,
|
||||
mRmTp_BIRTH_TYPE_SUMMER_CAMPER = 37,
|
||||
|
||||
mRmTp_BIRTH_TYPE_NUM
|
||||
};
|
||||
|
||||
enum {
|
||||
mRmTp_DIRECT_SOUTH,
|
||||
mRmTp_DIRECT_EAST,
|
||||
mRmTp_DIRECT_NORTH,
|
||||
mRmTp_DIRECT_WEST,
|
||||
|
||||
mRmTp_DIRECT_NUM
|
||||
};
|
||||
|
||||
enum {
|
||||
mRmTp_FTR_SE_NONE,
|
||||
mRmTp_FTR_SE_SOFT_CHAIR,
|
||||
mRmTp_FTR_SE_HARD_CHAIR,
|
||||
mRmTp_FTR_SE_BUBU_CHAIR,
|
||||
mRmTp_FTR_SE_TOILET_CHAIR,
|
||||
|
||||
mRmTp_FTR_SE_NUM
|
||||
};
|
||||
|
||||
enum {
|
||||
mRmTp_CHAIR_ACTION_SIT,
|
||||
mRmTp_CHAIR_ACTION_STAND,
|
||||
|
||||
mRmTp_CHAIR_ACTION_NUM
|
||||
};
|
||||
|
||||
typedef struct room_type_place_info_one_s {
|
||||
int exists;
|
||||
int ut_x;
|
||||
int ut_z;
|
||||
} mRmTp_FtrPlaceInfoOne_t;
|
||||
|
||||
#define FTR_NUM 1266
|
||||
|
||||
#define FTR_GET_ROTATION(f) ((f)&3)
|
||||
#define FTR_IDX_2_NO(f) ((f) >> 2)
|
||||
#define FTR_NO_2_IDX(f) ((f) << 2)
|
||||
#define FTR_NO_ROT_2_IDX(f, rot) (FTR_NO_2_IDX(f) | ((rot)&3))
|
||||
|
||||
// TEMPORARY. Should be generated with .decl files
|
||||
#define ITEM0_NO_START 0x0000
|
||||
#define ITEM0_1_NO_START ITEM0_NO_START + 0x800
|
||||
|
||||
#define FTR0_NO_START 0x1000
|
||||
|
||||
#define ITEM1_NO_START 0x2000
|
||||
#define ITEM1_0_NO_START ITEM0_1_NO_START // paper
|
||||
#define ITEM1_1_NO_START ITEM1_NO_START + 0x100 // money
|
||||
#define ITEM1_2_NO_START ITEM1_NO_START + 0x200 // tools
|
||||
#define ITEM1_3_NO_START ITEM1_NO_START + 0x300 // fish
|
||||
#define ITEM1_4_NO_START ITEM1_NO_START + 0x400 // clothing
|
||||
#define ITEM1_5_NO_START ITEM1_NO_START + 0x500 // etc
|
||||
#define ITEM1_6_NO_START ITEM1_NO_START + 0x600 // carpets
|
||||
#define ITEM1_7_NO_START ITEM1_NO_START + 0x700 // wallpaper
|
||||
#define ITEM1_8_NO_START ITEM1_NO_START + 0x800 // food
|
||||
#define ITEM1_9_NO_START ITEM1_NO_START + 0x900 // seeds
|
||||
#define ITEM1_A_NO_START ITEM1_NO_START + 0xA00 // mini disks
|
||||
#define ITEM1_B_NO_START ITEM1_NO_START + 0xB00 // diaries
|
||||
#define ITEM1_C_NO_START ITEM1_NO_START + 0xC00 // tickets
|
||||
#define ITEM1_D_NO_START ITEM1_NO_START + 0xD00 // insects
|
||||
#define ITEM1_E_NO_START ITEM1_NO_START + 0xE00 // hukubukuro
|
||||
#define ITEM1_F_NO_START ITEM1_NO_START + 0xF00 // kabu
|
||||
|
||||
#define FTR1_NO_START 0x3000
|
||||
|
||||
enum {
|
||||
mRmTp_LIGHT_SWITCH_HOUSE0_MAIN_UPPER,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE0_BASEMENT,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE1_MAIN_UPPER,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE1_BASEMENT,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE2_MAIN_UPPER,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE2_BASEMENT,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE3_MAIN_UPPER,
|
||||
mRmTp_LIGHT_SWITCH_HOUSE3_BASEMENT,
|
||||
mRmTp_LIGHT_SWITCH_COTTAGE_MY,
|
||||
mRmTp_LIGHT_SWITCH_9,
|
||||
mRmTp_LIGHT_SWITCH_NPC,
|
||||
mRmTp_LIGHT_SWITCH_LIGHTHOUSE,
|
||||
mRmTp_LIGHT_SWITCH_TENT,
|
||||
|
||||
mRmTp_LIGHT_SWITCH_NUM
|
||||
};
|
||||
|
||||
extern int mRmTp_ItemNo2FtrSize(mActor_name_t item_no);
|
||||
extern int mRmTp_GetFurnitureData(mActor_name_t ftr, int ut_x, int ut_z, mRmTp_FtrPlaceInfoOne_t* place_info);
|
||||
extern void mRmTp_MakeFtrNoTable(mActor_name_t* dst, mActor_name_t* src);
|
||||
extern int mRmTp_GetFtrActionSE(int ftr_idx, int mode);
|
||||
extern u8* mRmTp_CheckFtrBirthInfoTop();
|
||||
extern int mRmTp_GetFloorIdx();
|
||||
extern int mRmTp_GetWallIdx();
|
||||
extern mActor_name_t mRmTp_Item1ItemNo2FtrItemNo_AtPlayerRoom(mActor_name_t item1_no, int no_convert_tools);
|
||||
extern mActor_name_t mRmTp_FtrItemNo2Item1ItemNo(mActor_name_t ftr_no, int no_convert_tools);
|
||||
extern void mRmTp_MakeMelodyData();
|
||||
extern u8* mRmTp_GetMelodyData();
|
||||
extern void mRmTp_DrawFamicomInfo(gfxprint_t* gfxprint);
|
||||
extern void mRmTp_MakeFamicom_Fdebug();
|
||||
extern mActor_name_t mRmTp_GetPlayerRoomCollisionIdx(mActor_name_t field_id, mActor_name_t bg_idx);
|
||||
extern int mRmTp_FurnitureIdx2FurnitureKind(int ftr_idx);
|
||||
extern void mRmTp_CopyWallData(u8* dst, int wall_no);
|
||||
extern void mRmTp_CopyFloorData(u8* dst, int floor_no);
|
||||
extern int mRmTp_CheckTalkAble(s16* rot, xyz_t* pos, int required_dir, f32 max_dist, GAME_PLAY* play);
|
||||
extern int mRmTp_CheckWallIsMyOriginalInThisScene();
|
||||
extern int mRmTp_CheckFloorIsMyOriginalInThisScene();
|
||||
extern int mRmTp_GetEntranceBasePosition(xyz_t* pos);
|
||||
extern int mRmTp_GetNowSceneLightSwitchIndex();
|
||||
extern int mRmTp_PleaseDrawLightSwitch();
|
||||
extern int mRmTp_NowSceneLightSwitchON();
|
||||
extern int mRmTp_IndexLightSwitchON(int switch_index);
|
||||
extern int mRmTp_NowSceneLightSwitchOFF();
|
||||
extern int mRmTp_IndexLightSwitchOFF(int switch_index);
|
||||
extern int mRmTp_Index2LightSwitchStatus(int switch_index);
|
||||
extern int mRmTp_SetDefaultLightSwitchData(int state);
|
||||
extern void mRmTp_DecideCottageDefaultLightSwitch();
|
||||
extern int mRmTp_GetNowSceneOriginalWallStatus();
|
||||
extern int mRmTp_GetNowSceneOriginalFloorStatus();
|
||||
extern void mRmTp_SetNowSceneOriginalWallStatus(int enabled);
|
||||
extern void mRmTp_SetNowSceneOriginalFloorStatus(int enabled);
|
||||
extern int mRmTp_FtrItemNo2FtrIdx(mActor_name_t ftr_item_no);
|
||||
extern mActor_name_t mRmTp_FtrIdx2FtrItemNo(int ftr_idx, int direct);
|
||||
extern int mRmTp_SoundStepWalkSE(xyz_t* wpos);
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -20,7 +20,7 @@ extern int ScreenHeight;
|
||||
extern OSThread graphThread;
|
||||
extern u8 SegmentBaseAddress[0x40];
|
||||
|
||||
void foresta_main();
|
||||
void main();
|
||||
extern void mainproc(void* val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+10
-10
@@ -1,11 +1,11 @@
|
||||
#ifndef RANDOM_FIELD_H
|
||||
#define RANDOM_FIELD_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define mRF_PERFECT_BIT 9
|
||||
|
||||
int mRF_GetRandom(int val);
|
||||
|
||||
|
||||
#ifndef RANDOM_FIELD_H
|
||||
#define RANDOM_FIELD_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define mRF_PERFECT_BIT 9
|
||||
|
||||
int mRF_GetRandom(int val);
|
||||
|
||||
|
||||
#endif
|
||||
+173
-139
@@ -1,139 +1,173 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include "../tools/ppcdis/include/ppcdis.h"
|
||||
|
||||
#ifdef IS_REL
|
||||
// #pragma section const_type sconst_type ".rodata" ".rodata" data_mode=far_abs code_mode=pc_rel
|
||||
#endif
|
||||
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
typedef signed long s32;
|
||||
typedef signed long long s64;
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long size_t;
|
||||
typedef unsigned long long u64;
|
||||
typedef unsigned int uint;
|
||||
|
||||
typedef volatile u8 vu8;
|
||||
typedef volatile u16 vu16;
|
||||
typedef volatile u32 vu32;
|
||||
typedef volatile u64 vu64;
|
||||
typedef volatile s8 vs8;
|
||||
typedef volatile s16 vs16;
|
||||
typedef volatile s32 vs32;
|
||||
typedef volatile s64 vs64;
|
||||
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
typedef volatile f32 vf32;
|
||||
typedef volatile f64 vf64;
|
||||
|
||||
typedef int BOOL;
|
||||
typedef unsigned int uintptr_t; // Manually added
|
||||
|
||||
// Pointer to unknown, to be determined at a later date.
|
||||
typedef void* unkptr;
|
||||
typedef u32 unknown;
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define NULL ((void*)0)
|
||||
#define nullptr 0
|
||||
|
||||
#define AT_ADDRESS(x) : (x)
|
||||
|
||||
#define ALIGN_PREV(u, align) (u & (~(align - 1)))
|
||||
#define ALIGN_NEXT(u, align) ((u + (align - 1)) & (~(align - 1)))
|
||||
#define IS_ALIGNED(X, N) (((X) & ((N) - 1)) == 0)
|
||||
#define IS_NOT_ALIGNED(X, N) (((X) & ((N) - 1)) != 0)
|
||||
|
||||
#define FLAG_ON(V, F) (((V) & (F)) == 0)
|
||||
#define FLAG_OFF(V, F) (((V) & (F)) != 0)
|
||||
|
||||
#ifndef ATTRIBUTE_ALIGN
|
||||
#if defined(__MWERKS__) || defined(__GNUC__)
|
||||
#define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num)))
|
||||
#elif defined(_MSC_VER)
|
||||
#define ATTRIBUTE_ALIGN(num)
|
||||
#else
|
||||
#error unknown compiler
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BUTTON_NONE 0x0000
|
||||
#define BUTTON_CRIGHT 0x0001
|
||||
#define BUTTON_CLEFT 0x0002
|
||||
#define BUTTON_CDOWN 0x0004
|
||||
#define BUTTON_CUP 0x0008
|
||||
#define BUTTON_R 0x0010
|
||||
#define BUTTON_L 0x0020
|
||||
#define BUTTON_X 0x0040
|
||||
#define BUTTON_Y 0x0080
|
||||
#define BUTTON_DRIGHT 0x0100
|
||||
#define BUTTON_DLEFT 0x0200
|
||||
#define BUTTON_DDOWN 0x0400
|
||||
#define BUTTON_DUP 0x0800
|
||||
#define BUTTON_START 0x1000
|
||||
#define BUTTON_Z 0x2000
|
||||
#define BUTTON_B 0x4000
|
||||
#define BUTTON_A 0x8000
|
||||
|
||||
#define FRAMES_PER_SECOND 60
|
||||
|
||||
#define ARRAY_SIZE(arr, type) (sizeof(arr) / sizeof(type))
|
||||
#define ARRAY_COUNT(arr) (int)(sizeof(arr) / sizeof(arr[0]))
|
||||
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#define FLOOR(n, f) (((n) / (f)) * (f))
|
||||
|
||||
#define F32_IS_ZERO(v) (fabsf(v) < 0.008f)
|
||||
|
||||
/* ARGB8 color format (32 bits) to RGB5A3 color format (16 bits) */
|
||||
#define ARGB8_to_RGB5A3(argb8) \
|
||||
((u16)(((argb8) & 0xFF000000) >= 0xE0000000 \
|
||||
? /* Fully opaque, 5 bits per color channel */ (0x8000 | ((((argb8) >> 16) & 0xF8) << 7) | \
|
||||
((((argb8) >> 8) & 0xF8) << 2) | \
|
||||
(((argb8) & 0xFF) >> 3)) \
|
||||
: /* 3 bits of transparency, 4 bits per color channel */ ( \
|
||||
((((argb8) >> 24) & 0xE0) << 7) | ((((argb8) >> 16) & 0xF0) << 4) | (((argb8) >> 8) & 0xF0) | \
|
||||
(((argb8) & 0xF0) >> 4))))
|
||||
|
||||
#define GPACK_RGB5A3(r, g, b, a) \
|
||||
ARGB8_to_RGB5A3((((a) & 0xFF) << 24) | (((r) & 0xFF) << 16) | (((g) & 0xFF) << 8) | ((b) & 0xFF))
|
||||
|
||||
#pragma section RX "forcestrip"
|
||||
#ifndef __INTELLISENSE__
|
||||
#define FORCESTRIP __declspec(section "forcestrip")
|
||||
#else
|
||||
#define FORCESTRIP
|
||||
#endif
|
||||
|
||||
#ifdef MUST_MATCH
|
||||
#define MATCH_FORCESTRIP FORCESTRIP
|
||||
#else
|
||||
#define MATCH_FORCESTRIP
|
||||
#endif
|
||||
|
||||
#if !defined(__INTELLISENSE__) && defined(MUST_MATCH)
|
||||
#define BSS_ORDER_GROUP_START FORCESTRIP ORDER_BSS_DATA {
|
||||
#define BSS_ORDER_GROUP_END }
|
||||
#define BSS_ORDER_ITEM(v) ORDER_BSS(v)
|
||||
#else
|
||||
#define BSS_ORDER_GROUP_START
|
||||
#define BSS_ORDER_GROUP_END
|
||||
#define BSS_ORDER_ITEM(v)
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
// Some definitions rely on wchar_t being defined
|
||||
typedef short wchar_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
typedef signed long s32;
|
||||
typedef signed long long s64;
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned long u32;
|
||||
#ifndef _SIZE_T_DEF
|
||||
#define _SIZE_T_DEF
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
typedef unsigned long long u64;
|
||||
typedef unsigned int uint;
|
||||
|
||||
typedef volatile u8 vu8;
|
||||
typedef volatile u16 vu16;
|
||||
typedef volatile u32 vu32;
|
||||
typedef volatile u64 vu64;
|
||||
typedef volatile s8 vs8;
|
||||
typedef volatile s16 vs16;
|
||||
typedef volatile s32 vs32;
|
||||
typedef volatile s64 vs64;
|
||||
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
typedef volatile f32 vf32;
|
||||
typedef volatile f64 vf64;
|
||||
|
||||
typedef int BOOL;
|
||||
typedef unsigned int uintptr_t; // Manually added
|
||||
|
||||
// Pointer to unknown, to be determined at a later date.
|
||||
typedef void* unkptr;
|
||||
typedef u32 unknown;
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
#define nullptr 0
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#define AT_ADDRESS(x) : (x)
|
||||
#else
|
||||
#define AT_ADDRESS(x) __attribute__((section(".data." #x)))
|
||||
#endif
|
||||
|
||||
#define ALIGN_PREV(u, align) (u & (~(align - 1)))
|
||||
#define ALIGN_NEXT(u, align) ((u + (align - 1)) & (~(align - 1)))
|
||||
#define IS_ALIGNED(X, N) (((X) & ((N) - 1)) == 0)
|
||||
#define IS_NOT_ALIGNED(X, N) (((X) & ((N) - 1)) != 0)
|
||||
|
||||
#define FLAG_ON(V, F) (((V) & (F)) == 0)
|
||||
#define FLAG_OFF(V, F) (((V) & (F)) != 0)
|
||||
|
||||
#ifndef ATTRIBUTE_ALIGN
|
||||
#if defined(__MWERKS__) || defined(__GNUC__)
|
||||
#define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num)))
|
||||
#elif defined(_MSC_VER)
|
||||
#define ATTRIBUTE_ALIGN(num)
|
||||
#else
|
||||
#error unknown compiler
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BUTTON_NONE 0x0000
|
||||
#define BUTTON_CRIGHT 0x0001
|
||||
#define BUTTON_CLEFT 0x0002
|
||||
#define BUTTON_CDOWN 0x0004
|
||||
#define BUTTON_CUP 0x0008
|
||||
#define BUTTON_R 0x0010
|
||||
#define BUTTON_L 0x0020
|
||||
#define BUTTON_X 0x0040
|
||||
#define BUTTON_Y 0x0080
|
||||
#define BUTTON_DRIGHT 0x0100
|
||||
#define BUTTON_DLEFT 0x0200
|
||||
#define BUTTON_DDOWN 0x0400
|
||||
#define BUTTON_DUP 0x0800
|
||||
#define BUTTON_START 0x1000
|
||||
#define BUTTON_Z 0x2000
|
||||
#define BUTTON_B 0x4000
|
||||
#define BUTTON_A 0x8000
|
||||
|
||||
#define FRAMES_PER_SECOND 60
|
||||
|
||||
#define ARRAY_SIZE(arr, type) (sizeof(arr) / sizeof(type))
|
||||
#define ARRAY_COUNT(arr) (int)(sizeof(arr) / sizeof(arr[0]))
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define FLOOR(n, f) (((n) / (f)) * (f))
|
||||
|
||||
#define F32_IS_ZERO(v) (fabsf(v) < 0.008f)
|
||||
|
||||
/* ARGB8 color format (32 bits) to RGB5A3 color format (16 bits) */
|
||||
#define ARGB8_to_RGB5A3(argb8) \
|
||||
((u16)(((argb8) & 0xFF000000) >= 0xE0000000 \
|
||||
? /* Fully opaque, 5 bits per color channel */ (0x8000 | ((((argb8) >> 16) & 0xF8) << 7) | \
|
||||
((((argb8) >> 8) & 0xF8) << 2) | \
|
||||
(((argb8) & 0xFF) >> 3)) \
|
||||
: /* 3 bits of transparency, 4 bits per color channel */ ( \
|
||||
((((argb8) >> 24) & 0xE0) << 7) | ((((argb8) >> 16) & 0xF0) << 4) | (((argb8) >> 8) & 0xF0) | \
|
||||
(((argb8) & 0xF0) >> 4))))
|
||||
|
||||
#define GPACK_RGB5A3(r, g, b, a) \
|
||||
ARGB8_to_RGB5A3((((a) & 0xFF) << 24) | (((r) & 0xFF) << 16) | (((g) & 0xFF) << 8) | ((b) & 0xFF))
|
||||
|
||||
#pragma section RX "forcestrip"
|
||||
#ifndef __INTELLISENSE__
|
||||
#define FORCESTRIP __declspec(section "forcestrip")
|
||||
#else
|
||||
#define FORCESTRIP
|
||||
#endif
|
||||
|
||||
#if defined(MUST_MATCH) && defined(__MWERKS__)
|
||||
#define MATCH_FORCESTRIP FORCESTRIP
|
||||
#else
|
||||
#define MATCH_FORCESTRIP
|
||||
#endif
|
||||
|
||||
#if !defined(__INTELLISENSE__) && defined(MUST_MATCH)
|
||||
#define ORDER_BSS_DATA static asm void order_bss()
|
||||
#define ORDER_BSS(s) lis r3, s @ha
|
||||
#define BSS_ORDER_GROUP_START FORCESTRIP ORDER_BSS_DATA {
|
||||
#define BSS_ORDER_GROUP_END }
|
||||
#define BSS_ORDER_ITEM(v) ORDER_BSS(v)
|
||||
#else
|
||||
#define BSS_ORDER_GROUP_START
|
||||
#define BSS_ORDER_GROUP_END
|
||||
#define BSS_ORDER_ITEM(v)
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
// Some definitions rely on wchar_t being defined
|
||||
typedef short wchar_t;
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
#define ASSERTLINE(line, cond) \
|
||||
((cond) || (OSPanic(__FILE__, line, "Failed assertion " #cond), 0))
|
||||
|
||||
#define ASSERTMSGLINE(line, cond, msg) \
|
||||
((cond) || (OSPanic(__FILE__, line, msg), 0))
|
||||
|
||||
// This is dumb but we dont have a Metrowerks way to do variadic macros in the macro to make this done in a not scrubby way.
|
||||
#define ASSERTMSG1LINE(line, cond, msg, arg1) \
|
||||
((cond) || (OSPanic(__FILE__, line, msg, arg1), 0))
|
||||
|
||||
#define ASSERTMSG2LINE(line, cond, msg, arg1, arg2) \
|
||||
((cond) || (OSPanic(__FILE__, line, msg, arg1, arg2), 0))
|
||||
|
||||
#define ASSERTMSGLINEV(line, cond, ...) \
|
||||
((cond) || (OSPanic(__FILE__, line, __VA_ARGS__), 0))
|
||||
|
||||
#else
|
||||
#define ASSERTLINE(line, cond) (void)0
|
||||
#define ASSERTMSGLINE(line, cond, msg) (void)0
|
||||
#define ASSERTMSG1LINE(line, cond, msg, arg1) (void)0
|
||||
#define ASSERTMSG2LINE(line, cond, msg, arg1, arg2) (void)0
|
||||
#define ASSERTMSGLINEV(line, cond, ...) (void)0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+55
-55
@@ -1,55 +1,55 @@
|
||||
#ifndef ZURUMODE_H
|
||||
#define ZURUMODE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "m_controller.h"
|
||||
#include "dolphin/os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct zuru_keycheck {
|
||||
u8 state;
|
||||
u8 progressing;
|
||||
u16 last_controller;
|
||||
u8 zurumode_enabled;
|
||||
} zuru_keycheck;
|
||||
|
||||
extern s32 zurumode_flag;
|
||||
|
||||
extern void zurumode_cleanup(void);
|
||||
extern void zurumode_init(void);
|
||||
|
||||
#define ZURUMODE_RESET 0
|
||||
#define ZURUMODE_PROGRESSING 1
|
||||
|
||||
enum zurumode_stage {
|
||||
ZURUMODE_STAGE_BEGIN_e = 0,
|
||||
|
||||
ZURUMODE_STAGE_0_e = ZURUMODE_STAGE_BEGIN_e,
|
||||
ZURUMODE_STAGE_1_e,
|
||||
ZURUMODE_STAGE_2_e,
|
||||
ZURUMODE_STAGE_3_e,
|
||||
ZURUMODE_STAGE_4_e,
|
||||
ZURUMODE_STAGE_5_e,
|
||||
ZURUMODE_STAGE_6_e,
|
||||
ZURUMODE_STAGE_7_e,
|
||||
ZURUMODE_STAGE_8_e,
|
||||
ZURUMODE_STAGE_9_e,
|
||||
ZURUMODE_STAGE_91_e = 91,
|
||||
ZURUMODE_STAGE_92_e = 92,
|
||||
ZURUMODE_STAGE_10_e = 10,
|
||||
ZURUMODE_STAGE_11_e,
|
||||
|
||||
ZURUMODE_STAGE_FINAL_e = ZURUMODE_STAGE_11_e
|
||||
};
|
||||
|
||||
#define ZURUMODE_ENABLED() (zurumode_flag >= 1)
|
||||
#define ZURUMODE2_ENABLED() (zurumode_flag >= 2)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifndef ZURUMODE_H
|
||||
#define ZURUMODE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "m_controller.h"
|
||||
#include "dolphin/os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct zuru_keycheck {
|
||||
u8 state;
|
||||
u8 progressing;
|
||||
u16 last_controller;
|
||||
u8 zurumode_enabled;
|
||||
} zuru_keycheck;
|
||||
|
||||
extern s32 zurumode_flag;
|
||||
|
||||
extern void zurumode_cleanup(void);
|
||||
extern void zurumode_init(void);
|
||||
|
||||
#define ZURUMODE_RESET 0
|
||||
#define ZURUMODE_PROGRESSING 1
|
||||
|
||||
enum zurumode_stage {
|
||||
ZURUMODE_STAGE_BEGIN_e = 0,
|
||||
|
||||
ZURUMODE_STAGE_0_e = ZURUMODE_STAGE_BEGIN_e,
|
||||
ZURUMODE_STAGE_1_e,
|
||||
ZURUMODE_STAGE_2_e,
|
||||
ZURUMODE_STAGE_3_e,
|
||||
ZURUMODE_STAGE_4_e,
|
||||
ZURUMODE_STAGE_5_e,
|
||||
ZURUMODE_STAGE_6_e,
|
||||
ZURUMODE_STAGE_7_e,
|
||||
ZURUMODE_STAGE_8_e,
|
||||
ZURUMODE_STAGE_9_e,
|
||||
ZURUMODE_STAGE_91_e = 91,
|
||||
ZURUMODE_STAGE_92_e = 92,
|
||||
ZURUMODE_STAGE_10_e = 10,
|
||||
ZURUMODE_STAGE_11_e,
|
||||
|
||||
ZURUMODE_STAGE_FINAL_e = ZURUMODE_STAGE_11_e
|
||||
};
|
||||
|
||||
#define ZURUMODE_ENABLED() (zurumode_flag >= 1)
|
||||
#define ZURUMODE2_ENABLED() (zurumode_flag >= 2)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user