move g2 to src and finally import misc.h

This commit is contained in:
Seth Barberee 2026-06-19 11:55:35 -07:00
parent 24465589d7
commit 2f71cc84d9
15 changed files with 1182 additions and 95 deletions

View File

@ -77,7 +77,7 @@ PRECOMPILE_OBJ_DIR := $(dir $(PRECOMPILE_OBJ))
PRECOMPILE_DEPFILE := $(BUILD_DIR)/precompile/global.d
# Directories
NITROSDK_SRC_SUBDIRS := os mi snd fs
NITROSDK_SRC_SUBDIRS := os mi snd fs gx
LIB_SUBDIRS := DSE NitroSDK MSL_C
SRC_SUBDIR := src

View File

@ -1,53 +0,0 @@
.include "asm/macros.inc"
.include "include/g2.inc"
.text
arm_func_start G2x_SetBlendAlpha_
G2x_SetBlendAlpha_: ; 0x020776E8
ldr ip, [sp]
orr r1, r1, #0x40
orr r2, r1, r2, lsl #8
orr r1, r3, ip, lsl #8
orr r1, r2, r1, lsl #16
str r1, [r0]
bx lr
arm_func_end G2x_SetBlendAlpha_
arm_func_start G2x_SetBlendBrightness_
G2x_SetBlendBrightness_: ; 0x02077704
cmp r2, #0
orrge r1, r1, #0x80
strgeh r1, [r0]
strgeh r2, [r0, #4]
bxge lr
orr r1, r1, #0xc0
strh r1, [r0]
rsb r1, r2, #0
strh r1, [r0, #4]
bx lr
arm_func_end G2x_SetBlendBrightness_
arm_func_start G2x_ChangeBlendBrightness_
G2x_ChangeBlendBrightness_: ; 0x0207772C
ldrh r3, [r0]
cmp r1, #0
and r2, r3, #0xc0
bge _02077758
cmp r2, #0x80
biceq r2, r3, #0xc0
orreq r2, r2, #0xc0
streqh r2, [r0]
rsb r1, r1, #0
strh r1, [r0, #4]
bx lr
_02077758:
cmp r2, #0xc0
biceq r2, r3, #0xc0
orreq r2, r2, #0x80
streqh r2, [r0]
strh r1, [r0, #4]
bx lr
arm_func_end G2x_ChangeBlendBrightness_

54
lib/NitroSDK/src/gx/g2.c Normal file
View File

@ -0,0 +1,54 @@
#include <nitro.h>
typedef enum {
G2_BLENDTYPE_NONE = 0x0000,
G2_BLENDTYPE_ALPHA = 0x0040,
G2_BLENDTYPE_FADEIN = 0x0080,
G2_BLENDTYPE_FADEOUT = 0x00c0
} G2_BLENDTYPE;
void G2x_SetBlendAlpha_ (u32 addr, int plane1, int plane2, int ev1, int ev2)
{
SDK_MINMAX_ASSERT(plane1, 0, 0x20 - 1);
SDK_MINMAX_ASSERT(plane2, 0, 0x40 - 1);
SDK_MINMAX_ASSERT(ev1, 0, 31);
SDK_MINMAX_ASSERT(ev2, 0, 31);
*((vu32 *)addr + 0) = (u32)((G2_BLENDTYPE_ALPHA | plane1 | plane2 << 8) | ((ev1 | ev2 << 8) << 16));
}
void G2x_SetBlendBrightness_ (u32 addr, int plane, int brightness)
{
SDK_MINMAX_ASSERT(brightness, -31, 31);
SDK_MINMAX_ASSERT(plane, 0, 0x40 - 1);
if (brightness < 0) {
*((vu16 *)addr + 0) = (u16)(G2_BLENDTYPE_FADEOUT | plane);
*((vu16 *)addr + 2) = (u16) - brightness;
} else {
*((vu16 *)addr + 0) = (u16)(G2_BLENDTYPE_FADEIN | plane);
*((vu16 *)addr + 2) = (u16)brightness;
}
}
void G2x_ChangeBlendBrightness_ (u32 addr, int brightness)
{
u16 tmp;
SDK_MINMAX_ASSERT(brightness, -31, 31);
tmp = *((vu16 *)addr + 0);
if (brightness < 0) {
if (G2_BLENDTYPE_FADEIN == (tmp & REG_G2_BLDCNT_EFFECT_MASK)) {
*((vu16 *)addr + 0) = (u16)((tmp & ~REG_G2_BLDCNT_EFFECT_MASK) | G2_BLENDTYPE_FADEOUT);
}
*((vu16 *)addr + 2) = (u16) - brightness;
} else {
if (G2_BLENDTYPE_FADEOUT == (tmp & REG_G2_BLDCNT_EFFECT_MASK)) {
*((vu16 *)addr + 0) = (u16)((tmp & ~REG_G2_BLDCNT_EFFECT_MASK) | G2_BLENDTYPE_FADEIN);
}
*((vu16 *)addr + 2) = (u16)brightness;
}
}

248
lib/include/nitro/fx/fx.h Normal file
View File

@ -0,0 +1,248 @@
#ifndef NITRO_FX_H_
#define NITRO_FX_H_
#if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
#include <nitro/misc.h>
#endif
#include <nitro/types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef s32 fx32;
#define FX32_SHIFT 12
#define FX32_INT_SIZE 19
#define FX32_DEC_SIZE 12
#define FX32_INT_MASK 0x7ffff000
#define FX32_DEC_MASK 0x00000fff
#define FX32_SIGN_MASK 0x80000000
#define FX32_MAX ((fx32)0x7fffffff)
#define FX32_MIN ((fx32)0x80000000)
#define FX_MUL(v1, v2) FX32_CAST(((fx64)(v1) * (v2) + 0x800LL) >> FX32_SHIFT)
#define FX_MUL32x64C(v1, v2) FX32_CAST(((v2) * (v1) + 0x80000000LL) >> 32)
#define FX_FX32_TO_F32(x) ((f32)((x) / (f32)(1 << FX32_SHIFT)))
#define FX_F32_TO_FX32(x) ((fx32)(((x) > 0) ? \
((x) * (1 << FX32_SHIFT) + 0.5f) : \
((x) * (1 << FX32_SHIFT) - 0.5f)))
#define FX32_CONST(x) FX_F32_TO_FX32(x)
typedef s64 fx64;
#define FX64_SHIFT 12
#define FX64_INT_SIZE 51
#define FX64_DEC_SIZE 12
#define FX64_INT_MASK ((fx64)0x7ffffffffffff000)
#define FX64_DEC_MASK ((fx64)0x0000000000000fff)
#define FX64_SIGN_MASK ((fx64)0x8000000000000000)
#define FX64_MAX ((fx64)0x7fffffffffffffff)
#define FX64_MIN ((fx64)0x8000000000000000)
#define FX_FX64_TO_F32(x) ((f32)((x) / (f32)(1 << FX64_SHIFT)))
#define FX_F32_TO_FX64(x) ((fx64)(((x) > 0) ? \
((x) * (1 << FX32_SHIFT) + 0.5f) : \
((x) * (1 << FX32_SHIFT) - 0.5f)))
#define FX64_CONST(x) FX_F32_TO_FX64(x)
typedef s64 fx64c;
#define FX64C_SHIFT 32
#define FX64C_INT_SIZE 31
#define FX64C_DEC_SIZE 32
#define FX64C_INT_MASK ((fx64c)0x7fffffff00000000)
#define FX64C_DEC_MASK ((fx64c)0x00000000ffffffff)
#define FX64C_SIGN_MASK ((fx64c)0x8000000000000000)
#define FX64C_MAX ((fx64c)0x7fffffffffffffff)
#define FX64C_MIN ((fx64c)0x8000000000000000)
#define FX_FX64C_TO_F32(x) ((f32)((x) / (f32)((fx64c)1 << FX64C_SHIFT)))
#define FX_F32_TO_FX64C(x) ((fx64c)(((x) > 0) ? \
((x) * ((fx64c)1 << FX64C_SHIFT) + 0.5f) : \
((x) * ((fx64c)1 << FX64C_SHIFT) - 0.5f)))
#define FX64C_CONST(x) FX_F32_TO_FX64C(x)
typedef s16 fx16;
#define FX16_SHIFT 12
#define FX16_INT_SIZE 3
#define FX16_DEC_SIZE 12
#define FX16_INT_MASK 0x7000
#define FX16_DEC_MASK 0x0fff
#define FX16_SIGN_MASK 0x8000
#define FX16_MAX ((fx16)0x7fff)
#define FX16_MIN ((fx16)0x8000)
#define FX_FX16_TO_F32(x) ((f32)((x) / (f32)(1 << FX16_SHIFT)))
#define FX_F32_TO_FX16(x) ((fx16)(((x) > 0) ? \
(fx16)((x) * (1 << FX16_SHIFT) + 0.5f) : \
(fx16)((x) * (1 << FX16_SHIFT) - 0.5f)))
#define FX16_CONST(x) FX_F32_TO_FX16(x)
typedef struct {
fx32 x;
fx32 y;
fx32 z;
} VecFx32;
typedef struct {
fx16 x;
fx16 y;
fx16 z;
} VecFx16;
#ifdef SDK_ADS
typedef struct {
fx32 _00, _01, _02, _03;
fx32 _10, _11, _12, _13;
fx32 _20, _21, _22, _23;
fx32 _30, _31, _32, _33;
}
MtxFx44;
#else
typedef union {
struct {
fx32 _00, _01, _02, _03;
fx32 _10, _11, _12, _13;
fx32 _20, _21, _22, _23;
fx32 _30, _31, _32, _33;
};
fx32 m[4][4];
fx32 a[16];
} MtxFx44;
#endif
#ifdef SDK_ADS
typedef struct {
fx32 _00, _01, _02;
fx32 _10, _11, _12;
fx32 _20, _21, _22;
fx32 _30, _31, _32;
} MtxFx43;
#else
typedef union {
struct {
fx32 _00, _01, _02;
fx32 _10, _11, _12;
fx32 _20, _21, _22;
fx32 _30, _31, _32;
};
fx32 m[4][3];
fx32 a[12];
} MtxFx43;
#endif
#ifdef SDK_ADS
typedef struct {
fx32 _00, _01, _02;
fx32 _10, _11, _12;
fx32 _20, _21, _22;
} MtxFx33;
#else
typedef union {
struct {
fx32 _00, _01, _02;
fx32 _10, _11, _12;
fx32 _20, _21, _22;
};
fx32 m[3][3];
fx32 a[9];
} MtxFx33;
#endif
#ifdef SDK_ADS
typedef struct {
fx32 _00, _01;
fx32 _10, _11;
} MtxFx22;
#else
typedef union {
struct {
fx32 _00, _01;
fx32 _10, _11;
};
fx32 m[2][2];
fx32 a[4];
} MtxFx22;
#endif
// #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
// void FX_Init(void);
//
// SDK_DECL_INLINE s32 FX_Whole(fx32 v);
// SDK_DECL_INLINE fx32 FX_Floor(fx32 v);
//
// fx32 FX_Modf(fx32 x, fx32 * iPtr);
//
// SDK_INLINE s32 FX_Whole (fx32 v)
// {
// return (s32)(v >> FX32_SHIFT);
// }
//
// SDK_INLINE fx32 FX_Floor (fx32 v)
// {
// return (fx32)(v & (FX32_INT_MASK | FX32_SIGN_MASK));
// }
//
// SDK_INLINE fx32 FX32_CAST (s64 res)
// {
// SDK_WARNING(res >= FX32_MIN && res <= FX32_MAX, "FX_Mul: Overflow/Underflow");
// return (fx32)res;
// }
//
// fx32 FX_MulFunc(fx32 v1, fx32 v2);
// SDK_DECL_INLINE fx32 FX_MulInline(fx32 v1, fx32 v2);
//
// SDK_INLINE fx32 FX_MulInline (fx32 v1, fx32 v2)
// {
// return FX32_CAST(((s64)(v1) * v2 + 0x800LL) >> FX32_SHIFT);
// }
//
// #ifndef FX_Mul
// #ifdef SDK_CODE_ARM
// #define FX_Mul(v1, v2) FX_MulInline(v1, v2)
// #else
// #define FX_Mul(v1, v2) FX_MulFunc(v1, v2)
// #endif
// #endif
//
// #ifndef FX_Mul32x64c
// #ifdef SDK_CODE_ARM
// #define FX_Mul32x64c(v32, v64c) FX_Mul32x64cInline(v32, v64c)
// #else
// #define FX_Mul32x64c(v32, v64c) FX_Mul32x64cFunc(v32, v64c)
// #endif
// #endif
//
// fx32 FX_Mul32x64cFunc(fx32 v32, fx64c v64c);
// SDK_DECL_INLINE fx32 FX_Mul32x64cInline(fx32 v32, fx64c v64c);
//
// SDK_INLINE fx32 FX_Mul32x64cInline (fx32 v32, fx64c v64c)
// {
// fx64c tmp = v64c * v32 + 0x80000000LL;
// return FX32_CAST(tmp >> FX64C_SHIFT);
// }
// #endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,5 +2,6 @@
#define NITRO_GX_H_
#include <nitro/gx/gxasm.h>
#include <nitro/gx/g2.h>
#endif //NITRO_GX_H_

542
lib/include/nitro/gx/g2.h Normal file
View File

@ -0,0 +1,542 @@
#ifndef NITRO_G2_H_
#define NITRO_G2_H_
#include <nitro/gx/gxcommon.h>
#include <nitro/hw/common/io_reg.h>
//#include <nitro/hw/ARM9/ioreg_G2S.h>
//#include <nitro/hw/ARM9/ioreg_GX.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
u8 planeMask :5;
u8 effect :1;
u8 _reserve :2;
} GXWndPlane;
typedef enum {
GX_WND_PLANEMASK_NONE = 0x0000,
GX_WND_PLANEMASK_BG0 = 0x0001,
GX_WND_PLANEMASK_BG1 = 0x0002,
GX_WND_PLANEMASK_BG2 = 0x0004,
GX_WND_PLANEMASK_BG3 = 0x0008,
GX_WND_PLANEMASK_OBJ = 0x0010
} GXWndPlaneMask;
#define GX_WND_PLANEMASK_ASSERT(x) \
SDK_MINMAX_ASSERT(x, \
GX_WND_PLANEMASK_NONE, \
(GX_WND_PLANEMASK_BG0 | GX_WND_PLANEMASK_BG1 | \
GX_WND_PLANEMASK_BG2 | GX_WND_PLANEMASK_BG3 | \
GX_WND_PLANEMASK_OBJ))
typedef enum {
GX_BLEND_PLANEMASK_NONE = 0x0000,
GX_BLEND_PLANEMASK_BG0 = 0x0001,
GX_BLEND_PLANEMASK_BG1 = 0x0002,
GX_BLEND_PLANEMASK_BG2 = 0x0004,
GX_BLEND_PLANEMASK_BG3 = 0x0008,
GX_BLEND_PLANEMASK_OBJ = 0x0010,
GX_BLEND_PLANEMASK_BD = 0x0020
} GXBlendPlaneMask;
#define GX_BLEND_PLANEMASK_ASSERT(x) \
SDK_MINMAX_ASSERT(x, GX_BLEND_PLANEMASK_NONE, 0x3f)
#define GX_MOSAICSIZE_ASSERT(x) SDK_MINMAX_ASSERT(x, 0, 15)
#if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
static void G2_SetBG0Offset(int hOffset, int vOffset);
static void G2_SetBG1Offset(int hOffset, int vOffset);
static void G2_SetBG2Offset(int hOffset, int vOffset);
static void G2_SetBG3Offset(int hOffset, int vOffset);
static void G2_SetBG2Affine(const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1);
static void G2_SetBG3Affine(const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1);
static void G2_SetWnd0InsidePlane(int wnd, BOOL effect);
static void G2_SetWnd1InsidePlane(int wnd, BOOL effect);
static void G2_SetWndOutsidePlane(int wnd, BOOL effect);
static void G2_SetWndOBJInsidePlane(int wnd, BOOL effect);
static void G2_SetWnd0Position(int x1, int y1, int x2, int y2);
static void G2_SetWnd1Position(int x1, int y1, int x2, int y2);
static void G2_SetBGMosaicSize(int hSize, int vSize);
static void G2_SetOBJMosaicSize(int hSize, int vSize);
static void G2_BlendNone(void);
static void G2_SetBlendAlpha(int plane1, int plane2, int ev1, int ev2);
static void G2_SetBlendBrightness(int plane, int brightness);
static void G2_SetBlendBrightnessExt(int plane1, int plane2, int ev1, int ev2, int brightness);
static void G2_ChangeBlendAlpha(int ev1, int ev2);
static void G2_ChangeBlendBrightness(int brightness);
static void G2S_SetBG0Offset(int hOffset, int vOffset);
static void G2S_SetBG1Offset(int hOffset, int vOffset);
static void G2S_SetBG2Offset(int hOffset, int vOffset);
static void G2S_SetBG3Offset(int hOffset, int vOffset);
static void G2S_SetBG2Affine(const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1);
static void G2S_SetBG3Affine(const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1);
static void G2S_SetWnd0InsidePlane(int wnd, BOOL effect);
static void G2S_SetWnd1InsidePlane(int wnd, BOOL effect);
static void G2S_SetWndOutsidePlane(int wnd, BOOL effect);
static void G2S_SetWndOBJInsidePlane(int wnd, BOOL effect);
static void G2S_SetWnd0Position(int x1, int y1, int x2, int y2);
static void G2S_SetWnd1Position(int x1, int y1, int x2, int y2);
static void G2S_SetBGMosaicSize(int hSize, int vSize);
static void G2S_SetOBJMosaicSize(int hSize, int vSize);
static void G2S_BlendNone(void);
static void G2S_SetBlendAlpha(int plane1, int plane2, int ev1, int ev2);
static void G2S_SetBlendBrightness(int plane, int brightness);
static void G2S_SetBlendBrightnessExt(int plane1, int plane2, int ev1, int ev2, int brightness);
static void G2S_ChangeBlendAlpha(int ev1, int ev2);
static void G2S_ChangeBlendBrightness(int brightness);
void G2x_SetBGyAffine_(u32 addr, const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1);
void G2x_SetBlendAlpha_(u32 addr, int plane1, int plane2, int ev1, int ev2);
void G2x_SetBlendBrightness_(u32 addr, int plane, int brightness);
void G2x_SetBlendBrightnessExt_(u32 addr, int plane1, int plane2, int ev1, int ev2, int brightness);
void G2x_ChangeBlendBrightness_(u32 addr, int brightness);
// static inline void G2_SetBG0Offset (int hOffset, int vOffset)
// {
// // SDK_WARNING(0 == (reg_GX_DISPCNT & REG_GX_DISPCNT_BG02D3D_MASK),
// // "BG0 is in 3D mode now. call \'G3X_SetHOffset\'\n");
//
// reg_G2_BG0OFS = (u32)(((hOffset << REG_G2_BG0OFS_HOFFSET_SHIFT) & REG_G2_BG0OFS_HOFFSET_MASK) |
// ((vOffset << REG_G2_BG0OFS_VOFFSET_SHIFT) & REG_G2_BG0OFS_VOFFSET_MASK));
// }
// static inline void G2_SetBG1Offset (int hOffset, int vOffset)
// {
// reg_G2_BG1OFS = (u32)(((hOffset << REG_G2_BG1OFS_HOFFSET_SHIFT) & REG_G2_BG1OFS_HOFFSET_MASK) |
// ((vOffset << REG_G2_BG1OFS_VOFFSET_SHIFT) & REG_G2_BG1OFS_VOFFSET_MASK));
// }
// static inline void G2_SetBG2Offset (int hOffset, int vOffset)
// {
// #ifdef SDK_DEBUG
// {
// u32 tmp = (reg_GX_DISPCNT & REG_GX_DISPCNT_BGMODE_MASK) >> REG_GX_DISPCNT_BGMODE_SHIFT;
// SDK_WARNING((0 == tmp) || (1 == tmp) || (3 == tmp),
// "G2_SetBG2Offset requires BG #2 to be text mode. Use G2_SetBG2Affine instead.");
// }
// #endif
// reg_G2_BG2OFS = (u32)(((hOffset << REG_G2_BG2OFS_HOFFSET_SHIFT) & REG_G2_BG2OFS_HOFFSET_MASK) |
// ((vOffset << REG_G2_BG2OFS_VOFFSET_SHIFT) & REG_G2_BG2OFS_VOFFSET_MASK));
// }
// static inline void G2_SetBG3Offset (int hOffset, int vOffset)
// {
// #ifdef SDK_DEBUG
// {
// u32 tmp = (reg_GX_DISPCNT & REG_GX_DISPCNT_BGMODE_MASK) >> REG_GX_DISPCNT_BGMODE_SHIFT;
// SDK_WARNING(0 == tmp,
// "G2_SetBG3Offset requires BG #3 to be text mode. Use G2_SetBG3Affine instead.");
// }
// #endif
// reg_G2_BG3OFS = (u32)(((hOffset << REG_G2_BG3OFS_HOFFSET_SHIFT) & REG_G2_BG3OFS_HOFFSET_MASK) |
// ((vOffset << REG_G2_BG3OFS_VOFFSET_SHIFT) & REG_G2_BG3OFS_VOFFSET_MASK));
// }
// static inline void G2_SetWnd0InsidePlane (int wnd, BOOL effect)
// {
// u32 tmp;
// GX_WND_PLANEMASK_ASSERT(wnd);
//
// tmp = ((reg_G2_WININ & ~REG_G2_WININ_WIN0IN_MASK) | ((u32)wnd << REG_G2_WININ_WIN0IN_SHIFT));
//
// if (effect) {
// tmp |= (0x20 << REG_G2_WININ_WIN0IN_SHIFT);
// }
//
// reg_G2_WININ = (u16)tmp;
// }
// static inline GXWndPlane G2_GetWnd0InsidePlane (void)
// {
// return *(volatile GXWndPlane *)(REG_WININ_ADDR);
// }
//
// static inline void G2_SetWnd1InsidePlane (int wnd, BOOL effect)
// {
// u32 tmp;
// GX_WND_PLANEMASK_ASSERT(wnd);
//
// tmp = ((reg_G2_WININ & ~REG_G2_WININ_WIN1IN_MASK) | ((u32)wnd << REG_G2_WININ_WIN1IN_SHIFT));
//
// if (effect) {
// tmp |= (0x20 << REG_G2_WININ_WIN1IN_SHIFT);
// }
//
// reg_G2_WININ = (u16)tmp;
// }
//
// static inline GXWndPlane G2_GetWnd1InsidePlane (void)
// {
// return *(volatile GXWndPlane *)(REG_WININ_ADDR + 1);
// }
//
// static inline void G2_SetWndOutsidePlane (int wnd, BOOL effect)
// {
// u32 tmp;
// GX_WND_PLANEMASK_ASSERT(wnd);
//
// tmp = ((reg_G2_WINOUT & ~REG_G2_WINOUT_WINOUT_MASK) | ((u32)wnd << REG_G2_WINOUT_WINOUT_SHIFT));
//
// if (effect) {
// tmp |= (0x20 << REG_G2_WINOUT_WINOUT_SHIFT);
// }
//
// reg_G2_WINOUT = (u16)tmp;
// }
// static inline GXWndPlane G2_GetWndOutsidePlane (void)
// {
// return *(volatile GXWndPlane *)(REG_WINOUT_ADDR);
// }
//
// static inline void G2_SetWndOBJInsidePlane (int wnd, BOOL effect)
// {
// u32 tmp;
// GX_WND_PLANEMASK_ASSERT(wnd);
//
// tmp = ((reg_G2_WINOUT & ~REG_G2_WINOUT_OBJWININ_MASK) |
// ((u32)wnd << REG_G2_WINOUT_OBJWININ_SHIFT));
//
// if (effect) {
// tmp |= (0x20 << REG_G2_WINOUT_OBJWININ_SHIFT);
// }
//
// reg_G2_WINOUT = (u16)tmp;
// }
//
// static inline GXWndPlane G2_GetWndOBJInsidePlane (void)
// {
// return *(volatile GXWndPlane *)(REG_WINOUT_ADDR + 1);
// }
//
// static inline void G2_SetWnd0Position (int x1, int y1, int x2, int y2)
// {
// SDK_MINMAX_ASSERT(y1, 0, 192);
// SDK_MINMAX_ASSERT(y2, 0, 192);
//
// reg_G2_WIN0H = (u16)(((x1 << REG_G2_WIN0H_LEFTX_SHIFT) & REG_G2_WIN0H_LEFTX_MASK) |
// ((x2 << REG_G2_WIN0H_RIGHTX_SHIFT) & REG_G2_WIN0H_RIGHTX_MASK));
//
// reg_G2_WIN0V = (u16)(((y1 << REG_G2_WIN0V_UPY_SHIFT) & REG_G2_WIN0V_UPY_MASK) |
// ((y2 << REG_G2_WIN0V_DOWNY_SHIFT) & REG_G2_WIN0V_DOWNY_MASK));
// }
// static inline void G2_SetWnd1Position (int x1, int y1, int x2, int y2)
// {
// SDK_MINMAX_ASSERT(y1, 0, 192);
// SDK_MINMAX_ASSERT(y2, 0, 192);
//
// reg_G2_WIN1H = (u16)(((x1 << REG_G2_WIN1H_LEFTX_SHIFT) & REG_G2_WIN1H_LEFTX_MASK) |
// ((x2 << REG_G2_WIN1H_RIGHTX_SHIFT) & REG_G2_WIN1H_RIGHTX_MASK));
//
// reg_G2_WIN1V = (u16)(((y1 << REG_G2_WIN1V_UPY_SHIFT) & REG_G2_WIN1V_UPY_MASK) |
// ((y2 << REG_G2_WIN1V_DOWNY_SHIFT) & REG_G2_WIN1V_DOWNY_MASK));
// }
//
// static inline void G2_SetBGMosaicSize (int hSize, int vSize)
// {
// GX_MOSAICSIZE_ASSERT(hSize);
// GX_MOSAICSIZE_ASSERT(vSize);
//
// *((vu8 *)REG_MOSAIC_ADDR) = (u8)((hSize << REG_G2_MOSAIC_BGHSIZE_SHIFT) |
// (vSize << REG_G2_MOSAIC_BGVSIZE_SHIFT));
// }
// static inline void G2_SetOBJMosaicSize (int hSize, int vSize)
// {
// GX_MOSAICSIZE_ASSERT(hSize);
// GX_MOSAICSIZE_ASSERT(vSize);
//
// *((vu8 *)(REG_MOSAIC_ADDR + 1)) = (u8)((hSize << (REG_G2_MOSAIC_OBJHSIZE_SHIFT - 8)) |
// (vSize << (REG_G2_MOSAIC_OBJVSIZE_SHIFT - 8)));
// }
//
// static inline void G2_BlendNone (void)
// {
// reg_G2_BLDCNT = 0;
// }
//
// static inline void G2_ChangeBlendAlpha (int ev1, int ev2)
// {
// GX_ALPHA_ASSERT(ev1);
// GX_ALPHA_ASSERT(ev2);
//
// reg_G2_BLDALPHA = (u16)((ev1 << REG_G2_BLDALPHA_EVA_SHIFT) |
// (ev2 << REG_G2_BLDALPHA_EVB_SHIFT));
// }
//
// static inline void G2_SetBG2Affine (const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1)
// {
// G2x_SetBGyAffine_((u32) & reg_G2_BG2PA, mtx, centerX, centerY, x1, y1);
// }
//
// static inline void G2_SetBG3Affine (const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1)
// {
// G2x_SetBGyAffine_((u32) & reg_G2_BG3PA, mtx, centerX, centerY, x1, y1);
// }
//
// static inline void G2_SetBlendAlpha (int plane1, int plane2, int ev1, int ev2)
// {
// G2x_SetBlendAlpha_((u32) & reg_G2_BLDCNT, plane1, plane2, ev1, ev2);
// }
//
// static inline void G2_SetBlendBrightness (int plane, int brightness)
// {
// G2x_SetBlendBrightness_((u32) & reg_G2_BLDCNT, plane, brightness);
// }
//
// static inline void G2_SetBlendBrightnessExt (int plane1, int plane2, int ev1, int ev2, int brightness)
// {
// G2x_SetBlendBrightnessExt_((u32) & reg_G2_BLDCNT, plane1, plane2, ev1, ev2, brightness);
// }
//
// static inline void G2_ChangeBlendBrightness (int brightness)
// {
// G2x_ChangeBlendBrightness_((u32) & reg_G2_BLDCNT, brightness);
// }
//
// static inline void G2S_SetBG0Offset (int hOffset, int vOffset)
// {
// reg_G2S_DB_BG0OFS =
// (u32)(((hOffset << REG_G2S_DB_BG0OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG0OFS_HOFFSET_MASK) |
// ((vOffset << REG_G2S_DB_BG0OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG0OFS_VOFFSET_MASK));
// }
//
// static inline void G2S_SetBG1Offset (int hOffset, int vOffset)
// {
// reg_G2S_DB_BG1OFS =
// (u32)(((hOffset << REG_G2S_DB_BG1OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG1OFS_HOFFSET_MASK) |
// ((vOffset << REG_G2S_DB_BG1OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG1OFS_VOFFSET_MASK));
// }
// static inline void G2S_SetBG2Offset (int hOffset, int vOffset)
// {
// #ifdef SDK_DEBUG
// {
// u32 tmp =
// (reg_GXS_DB_DISPCNT & REG_GXS_DB_DISPCNT_BGMODE_MASK) >>
// REG_GXS_DB_DISPCNT_BGMODE_SHIFT;
// SDK_WARNING((0 == tmp) || (1 == tmp)
// || (3 == tmp),
// "G2S_SetBG2Offset requires BG #2 to be text mode. Use G2S_SetBG2Affine instead.");
// }
// #endif
//
// reg_G2S_DB_BG2OFS =
// (u32)(((hOffset << REG_G2S_DB_BG2OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG2OFS_HOFFSET_MASK) |
// ((vOffset << REG_G2S_DB_BG2OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG2OFS_VOFFSET_MASK));
// }
//
// static inline void G2S_SetBG3Offset (int hOffset, int vOffset)
// {
// #ifdef SDK_DEBUG
// {
// u32 tmp =
// (reg_GXS_DB_DISPCNT & REG_GXS_DB_DISPCNT_BGMODE_MASK) >>
// REG_GXS_DB_DISPCNT_BGMODE_SHIFT;
// SDK_WARNING(0 == tmp,
// "G2S_SetBG3Offset requires BG #3 to be text mode. Use G2S_SetBG3Affine instead.");
// }
// #endif
//
// reg_G2S_DB_BG3OFS =
// (u32)(((hOffset << REG_G2S_DB_BG3OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG3OFS_HOFFSET_MASK) |
// ((vOffset << REG_G2S_DB_BG3OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG3OFS_VOFFSET_MASK));
// }
//
// static inline void G2S_SetWnd0InsidePlane (int wnd, BOOL effect)
// {
// u32 tmp;
// GX_WND_PLANEMASK_ASSERT(wnd);
//
// tmp = ((reg_G2S_DB_WININ & ~REG_G2S_DB_WININ_WIN0IN_MASK) |
// ((u32)wnd << REG_G2S_DB_WININ_WIN0IN_SHIFT));
//
// if (effect) {
// tmp |= (0x20 << REG_G2S_DB_WININ_WIN0IN_SHIFT);
// }
//
// reg_G2S_DB_WININ = (u16)tmp;
// }
//
// static inline GXWndPlane G2S_GetWnd0InsidePlane (void)
// {
// return *(volatile GXWndPlane *)(REG_DB_WININ_ADDR);
// }
//
// static inline void G2S_SetWnd1InsidePlane (int wnd, BOOL effect)
// {
// u32 tmp;
// GX_WND_PLANEMASK_ASSERT(wnd);
//
// tmp = ((reg_G2S_DB_WININ & ~REG_G2S_DB_WININ_WIN1IN_MASK) |
// ((u32)wnd << REG_G2S_DB_WININ_WIN1IN_SHIFT));
//
// if (effect) {
// tmp |= (0x20 << REG_G2S_DB_WININ_WIN1IN_SHIFT);
// }
//
// reg_G2S_DB_WININ = (u16)tmp;
// }
//
// static inline GXWndPlane G2S_GetWnd1InsidePlane (void)
// {
// return *(volatile GXWndPlane *)(REG_DB_WININ_ADDR + 1);
// }
//
// static inline void G2S_SetWndOutsidePlane (int wnd, BOOL effect)
// {
// u32 tmp;
// GX_WND_PLANEMASK_ASSERT(wnd);
//
// tmp = ((reg_G2S_DB_WINOUT & ~REG_G2S_DB_WINOUT_WINOUT_MASK) |
// ((u32)wnd << REG_G2S_DB_WINOUT_WINOUT_SHIFT));
//
// if (effect) {
// tmp |= (0x20 << REG_G2S_DB_WINOUT_WINOUT_SHIFT);
// }
//
// reg_G2S_DB_WINOUT = (u16)tmp;
// }
//
// static inline GXWndPlane G2S_GetWndOutsidePlane (void)
// {
// return *(volatile GXWndPlane *)(REG_DB_WINOUT_ADDR);
// }
//
// static inline void G2S_SetWndOBJInsidePlane (int wnd, BOOL effect)
// {
// u32 tmp;
// GX_WND_PLANEMASK_ASSERT(wnd);
//
// tmp = ((reg_G2S_DB_WINOUT & ~REG_G2S_DB_WINOUT_OBJWININ_MASK) |
// ((u32)wnd << REG_G2S_DB_WINOUT_OBJWININ_SHIFT));
//
// if (effect) {
// tmp |= (0x20 << REG_G2S_DB_WINOUT_OBJWININ_SHIFT);
// }
//
// reg_G2S_DB_WINOUT = (u16)tmp;
// }
//
// static inline GXWndPlane G2S_GetWndOBJInsidePlane (void)
// {
// return *(volatile GXWndPlane *)(REG_DB_WINOUT_ADDR + 1);
// }
//
// static inline void G2S_SetWnd0Position (int x1, int y1, int x2, int y2)
// {
// SDK_MINMAX_ASSERT(y1, 0, 192);
// SDK_MINMAX_ASSERT(y2, 0, 192);
//
// reg_G2S_DB_WIN0H = (u16)(((x1 << REG_G2S_DB_WIN0H_LEFTX_SHIFT) & REG_G2S_DB_WIN0H_LEFTX_MASK) |
// ((x2 << REG_G2S_DB_WIN0H_RIGHTX_SHIFT) &
// REG_G2S_DB_WIN0H_RIGHTX_MASK));
//
// reg_G2S_DB_WIN0V = (u16)(((y1 << REG_G2S_DB_WIN0V_UPY_SHIFT) & REG_G2S_DB_WIN0V_UPY_MASK) |
// ((y2 << REG_G2S_DB_WIN0V_DOWNY_SHIFT) & REG_G2S_DB_WIN0V_DOWNY_MASK));
// }
//
// static inline void G2S_SetWnd1Position (int x1, int y1, int x2, int y2)
// {
// SDK_MINMAX_ASSERT(y1, 0, 192);
// SDK_MINMAX_ASSERT(y2, 0, 192);
//
// reg_G2S_DB_WIN1H = (u16)(((x1 << REG_G2S_DB_WIN1H_LEFTX_SHIFT) & REG_G2S_DB_WIN1H_LEFTX_MASK) |
// ((x2 << REG_G2S_DB_WIN1H_RIGHTX_SHIFT) &
// REG_G2S_DB_WIN1H_RIGHTX_MASK));
//
// reg_G2S_DB_WIN1V = (u16)(((y1 << REG_G2S_DB_WIN1V_UPY_SHIFT) & REG_G2S_DB_WIN1V_UPY_MASK) |
// ((y2 << REG_G2S_DB_WIN1V_DOWNY_SHIFT) & REG_G2S_DB_WIN1V_DOWNY_MASK));
// }
//
// static inline void G2S_SetBGMosaicSize (int hSize, int vSize)
// {
// GX_MOSAICSIZE_ASSERT(hSize);
// GX_MOSAICSIZE_ASSERT(vSize);
//
// *((vu8 *)REG_DB_MOSAIC_ADDR) = (u8)((hSize << REG_G2S_DB_MOSAIC_BGHSIZE_SHIFT) |
// (vSize << REG_G2S_DB_MOSAIC_BGVSIZE_SHIFT));
//
// }
//
// static inline void G2S_SetOBJMosaicSize (int hSize, int vSize)
// {
// GX_MOSAICSIZE_ASSERT(hSize);
// GX_MOSAICSIZE_ASSERT(vSize);
//
// *((vu8 *)(REG_DB_MOSAIC_ADDR + 1)) = (u8)((hSize << (REG_G2S_DB_MOSAIC_OBJHSIZE_SHIFT - 8)) |
// (vSize << (REG_G2S_DB_MOSAIC_OBJVSIZE_SHIFT - 8)));
//
// }
//
// static inline void G2S_BlendNone (void)
// {
// reg_G2S_DB_BLDCNT = 0;
// }
//
// static inline void G2S_ChangeBlendAlpha (int ev1, int ev2)
// {
// GX_ALPHA_ASSERT(ev1);
// GX_ALPHA_ASSERT(ev2);
//
// reg_G2S_DB_BLDALPHA = (u16)((ev1 << REG_G2S_DB_BLDALPHA_EVA_SHIFT) |
// (ev2 << REG_G2S_DB_BLDALPHA_EVB_SHIFT));
// }
//
// static inline void G2S_SetBG2Affine (const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1)
// {
// G2x_SetBGyAffine_((u32) & reg_G2S_DB_BG2PA, mtx, centerX, centerY, x1, y1);
// }
//
// static inline void G2S_SetBG3Affine (const MtxFx22 * mtx, int centerX, int centerY, int x1, int y1)
// {
// G2x_SetBGyAffine_((u32) & reg_G2S_DB_BG3PA, mtx, centerX, centerY, x1, y1);
// }
//
// static inline void G2S_SetBlendAlpha (int plane1, int plane2, int ev1, int ev2)
// {
// G2x_SetBlendAlpha_((u32) & reg_G2S_DB_BLDCNT, plane1, plane2, ev1, ev2);
// }
//
// static inline void G2S_SetBlendBrightness (int plane, int brightness)
// {
// G2x_SetBlendBrightness_((u32) & reg_G2S_DB_BLDCNT, plane, brightness);
// }
//
// static inline void G2S_SetBlendBrightnessExt (int plane1,
// int plane2, int ev1, int ev2, int brightness)
// {
// G2x_SetBlendBrightnessExt_((u32) & reg_G2S_DB_BLDCNT, plane1, plane2, ev1, ev2, brightness);
// }
//
// static inline void G2S_ChangeBlendBrightness (int brightness)
// {
// G2x_ChangeBlendBrightness_((u32) & reg_G2S_DB_BLDCNT, brightness);
// }
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,87 @@
#ifndef NITRO_GXCOMMON_H_
#define NITRO_GXCOMMON_H_
#if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
#include <nitro/misc.h>
//#include <nitro/memorymap.h>
#endif
#include <nitro/types.h>
#include <nitro/fx/fx.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GX_DEFAULT_DMAID (3)
#define GX_DMA_NOT_USE ((u32) ~0)
#define GX_DMAID (GXi_DmaId)
extern u32 GXi_DmaId;
typedef u16 GXRgb;
#define GXRGB_ASSERT(gxrgb) SDK_ASSERT(((gxrgb) & 0x8000) == 0)
#define GX_RGB_R_SHIFT (0)
#define GX_RGB_R_MASK (0x001f)
#define GX_RGB_G_SHIFT (5)
#define GX_RGB_G_MASK (0x03e0)
#define GX_RGB_B_SHIFT (10)
#define GX_RGB_B_MASK (0x7c00)
#define GX_RGB(r, g, b) ((GXRgb)(((r) << GX_RGB_R_SHIFT) | \
((g) << GX_RGB_G_SHIFT) | \
((b) << GX_RGB_B_SHIFT)))
typedef u16 GXRgba;
#define GX_RGBA_R_SHIFT (0)
#define GX_RGBA_R_MASK (0x001f)
#define GX_RGBA_G_SHIFT (5)
#define GX_RGBA_G_MASK (0x03e0)
#define GX_RGBA_B_SHIFT (10)
#define GX_RGBA_B_MASK (0x7c00)
#define GX_RGBA_A_SHIFT (15)
#define GX_RGBA_A_MASK (0x8000)
#define GX_RGBA(r, g, b, a) ((GXRgba)(((r) << GX_RGBA_R_SHIFT) | \
((g) << GX_RGBA_G_SHIFT) | \
((b) << GX_RGBA_B_SHIFT) | \
((a) << GX_RGBA_A_SHIFT)))
#define GX_POLYGONID_ASSERT(x) SDK_ASSERT((x) >= 0 && (x) <= 63)
#define GX_ALPHA_ASSERT(x) SDK_ASSERT((x) >= 0 && (x) <= 31)
#define GX_DEPTH_ASSERT(x) SDK_ASSERT((x) >= 0 && (x) <= 0x7fff)
#define GX_VECFX10(x, y, z) \
((VecFx10)(((((x) >> (FX32_DEC_SIZE - GX_FX10_DEC_SIZE)) & GX_FX10_MASK) << GX_VEC_FX10_X_SHIFT) | \
((((y) >> (FX32_DEC_SIZE - GX_FX10_DEC_SIZE)) & GX_FX10_MASK) << GX_VEC_FX10_Y_SHIFT) | \
((((z) >> (FX32_DEC_SIZE - GX_FX10_DEC_SIZE)) & GX_FX10_MASK) << GX_VEC_FX10_Z_SHIFT)))
typedef u32 VecFx10;
#define GX_FX10_SHIFT 9
#define GX_FX10_INT_SIZE 0
#define GX_FX10_DEC_SIZE 9
#define GX_FX10_INT_MASK 0x0000
#define GX_FX10_DEC_MASK 0x01ff
#define GX_FX10_SIGN_MASK 0x0200
#define GX_FX10_MASK (GX_FX10_INT_MASK | GX_FX10_DEC_MASK | GX_FX10_SIGN_MASK)
#define GX_FX16_FX10_MAX (fx16)(0x0fff)
#define GX_FX16_FX10_MIN (fx16)(0xf000)
#define GX_FX32_FX10_MAX (fx32)(0x00000fff);
#define GX_FX32_FX10_MIN (fx32)(0xfffff000);
#define GX_VEC_FX10_X_SHIFT 0
#define GX_VEC_FX10_Y_SHIFT 10
#define GX_VEC_FX10_Z_SHIFT 20
#ifdef __cplusplus
}
#endif
#endif

View File

@ -5,7 +5,7 @@
extern "C" {
#endif
//#include <nitro/misc.h>
#include <nitro/misc.h>
#include <nitro/types.h>
//#include <nitro/memorymap.h>

View File

@ -5,7 +5,7 @@
extern "C" {
#endif
//#include <nitro/misc.h>
#include <nitro/misc.h>
#include <nitro/types.h>
void MTi_CpuClear16(u16 data, void * destp, u32 size);
@ -21,17 +21,17 @@ void MTi_CpuCopy32Fast(const void * srcp, void * destp, u32 size);
static inline void MI_CpuFill32 (void * dest, u32 data, u32 size)
{
// SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
// SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
MTi_CpuClear32(data, dest, size);
}
static inline void MI_CpuCopy32 (const void * src, void * dest, u32 size)
{
// SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
// SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
// SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
MTi_CpuCopy32(src, dest, size);
}
@ -43,26 +43,26 @@ static inline void MI_CpuClear32 (void * dest, u32 size)
static inline void MI_CpuSend32 (const void * src, volatile void * dest, u32 size)
{
// SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
// SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
// SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
MTi_CpuSend32(src, dest, size);
}
static inline void MI_CpuFill16 (void * dest, u16 data, u32 size)
{
// SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
// SDK_ASSERTMSG(((u32)dest & 1) == 0, "source address must be in 2-byte alignment");
SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
SDK_ASSERTMSG(((u32)dest & 1) == 0, "source address must be in 2-byte alignment");
MTi_CpuClear16(data, dest, size);
}
static inline void MI_CpuCopy16 (const void * src, void * dest, u32 size)
{
// SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
// SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
// SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
MTi_CpuCopy16(src, dest, size);
}
@ -74,26 +74,26 @@ static inline void MI_CpuClear16 (void * dest, u32 size)
static inline void MI_CpuSend16 (const void * src, volatile void * dest, u32 size)
{
// SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
// SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
// SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
MTi_CpuSend16(src, dest, size);
}
static inline void MI_CpuFillFast (void * dest, u32 data, u32 size)
{
// SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
// SDK_ASSERTMSG(((u32)dest & 3) == 0, "source address must be in 4-byte alignment");
SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
SDK_ASSERTMSG(((u32)dest & 3) == 0, "source address must be in 4-byte alignment");
MTi_CpuClearFast(data, dest, size);
}
static inline void MI_CpuCopyFast (const void * src, void * dest, u32 size)
{
// SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
// SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
// SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
MTi_CpuCopy32Fast(src, dest, size);
}

View File

@ -5,7 +5,7 @@
extern "C" {
#endif
//#include <nitro/misc.h>
#include <nitro/misc.h>
#include <nitro/types.h>
typedef enum {

207
lib/include/nitro/misc.h Normal file
View File

@ -0,0 +1,207 @@
#ifndef NITRO_MISC_H_
#define NITRO_MISC_H_
#ifdef __cplusplus
extern "C" {
#endif
// #include <nitro/os/common/printf.h>
#ifdef __cplusplus
#define SDK_IFDEFCPP extern "C" {
#define SDK_ENDIFCPP }
#else
#define SDK_IFDEFCPP
#define SDK_ENDIFCPP
#endif
#ifdef SDK_DEBUG
#ifndef SDK_ASSERT
#define SDK_ASSERT(exp) \
(void) ((exp) || (OSi_Panic(__FILE__, __LINE__, "Failed assertion " #exp), 0))
#endif
#else
#ifndef SDK_ASSERT
#define SDK_ASSERT(exp) ((void) 0)
#endif
#endif
#define SDK_COMPILER_ASSERT(expr) \
extern void sdk_compiler_assert ## __LINE__ (char is[(expr) ? +1 : -1])
#ifdef SDK_DEBUG
#ifndef SDK_ASSERTMSG
#define SDK_ASSERTMSG(exp, ...) \
(void) ((exp) || (OSi_Panic(__FILE__, __LINE__, __VA_ARGS__), 0))
#endif
#ifndef SDK_TASSERTMSG
#define SDK_TASSERTMSG(exp, ...) \
(void) ((exp) || (OSi_TPanic(__FILE__, __LINE__, __VA_ARGS__), 0))
#endif
#else
#ifndef SDK_ASSERTMSG
#define SDK_ASSERTMSG(exp, ...) ((void) 0)
#endif
#ifndef SDK_TASSERTMSG
#define SDK_TASSERTMSG(exp, ...) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_WARNING
#define SDK_WARNING(exp, ...) \
(void) ((exp) || (OSi_Warning(__FILE__, __LINE__, __VA_ARGS__), 0))
#endif
#ifndef SDK_TWARNING
#define SDK_TWARNING(exp, ...) \
(void) ((exp) || (OSi_TWarning(__FILE__, __LINE__, __VA_ARGS__), 0))
#endif
#else
#ifndef SDK_WARNING
#define SDK_WARNING(exp, ...) ((void) 0)
#endif
#ifndef SDK_TWARNING
#define SDK_TWARNING(exp, ...) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_NULL_ASSERT
#define SDK_NULL_ASSERT(exp) \
(void) (((exp) != NULL) || (OSi_Panic(__FILE__, __LINE__, "Pointer must not be NULL ("#exp ")"), 0))
#endif
#else
#ifndef SDK_NULL_ASSERT
#define SDK_NULL_ASSERT(exp) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_MIN_ASSERT
#define SDK_MIN_ASSERT(exp, min) \
(void) (((exp) >= (min)) || \
(OSi_Panic(__FILE__, __LINE__, #exp " is out of bounds(%d)\n%d <= "#exp " not satisfied.", exp, min), 0))
#endif
#else
#ifndef SDK_MIN_ASSERT
#define SDK_MIN_ASSERT(exp, min) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_MAX_ASSERT
#define SDK_MAX_ASSERT(exp, max) \
(void) (((exp) <= (max)) || \
(OSi_Panic(__FILE__, __LINE__, #exp " is out of bounds(%d)\n"#exp " <= %d not satisfied.", exp, max), 0))
#endif
#else
#ifndef SDK_MAX_ASSERT
#define SDK_MAX_ASSERT(exp, max) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_MINMAX_ASSERT
#define SDK_MINMAX_ASSERT(exp, min, max) \
(void) (((exp) >= (min) && (exp) <= (max)) || \
(OSi_Panic(__FILE__, __LINE__, #exp " is out of bounds(%d)\n%d <= "#exp " <= %d not satisfied.", exp, min, max), 0))
#endif
#else
#ifndef SDK_MINMAX_ASSERT
#define SDK_MINMAX_ASSERT(exp, min, max) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_FATAL_ERROR
#define SDK_FATAL_ERROR(...) \
(void) (OSi_Panic(__FILE__, __LINE__, "Fatal Error\n"__VA_ARGS__), 0)
#endif
#ifndef SDK_TFATAL_ERROR
#define SDK_TFATAL_ERROR(...) \
(void) (OSi_TPanic(__FILE__, __LINE__, "Fatal Error\n"__VA_ARGS__), 0)
#endif
#else
#ifndef SDK_FATAL_ERROR
#define SDK_FATAL_ERROR(...) ((void) 0)
#endif
#ifndef SDK_TFATAL_ERROR
#define SDK_TFATAL_ERROR(...) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_INTERNAL_ERROR
#define SDK_INTERNAL_ERROR(...) \
(void) (OSi_Panic(__FILE__, __LINE__, "SDK Internal error\nPlease e-mail to nintendo\n" __VA_ARGS__), 0)
#endif
#ifndef SDK_TINTERNAL_ERROR
#define SDK_TINTERNAL_ERROR(...) \
(void) (OSi_TPanic(__FILE__, __LINE__, "SDK Internal error\nPlease e-mail to nintendo\n" __VA_ARGS__), 0)
#endif
#else
#ifndef SDK_INTERNAL_ERROR
#define SDK_INTERNAL_ERROR(...) ((void) 0)
#endif
#ifndef SDK_TINTERNAL_ERROR
#define SDK_TINTERNAL_ERROR(...) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_ALIGN4_ASSERT
#define SDK_ALIGN4_ASSERT(exp) \
(void) ((((u32)(exp) & 3) == 0) || (OSi_Panic(__FILE__, __LINE__, "Alignment Error(0x%x)\n"#exp " must be aligned to 4 bytes boundary.", exp), 0))
#endif
#else
#ifndef SDK_ALIGN4_ASSERT
#define SDK_ALIGN4_ASSERT(exp) ((void) 0)
#endif
#endif
#ifdef SDK_DEBUG
#ifndef SDK_ALIGN2_ASSERT
#define SDK_ALIGN2_ASSERT(exp) \
(void) ((((u32)(exp) & 1) == 0) || (OSi_Panic(__FILE__, __LINE__, "Alignment Error(0x%x)\n"#exp " must be aligned to 2 bytes boundary.", exp), 0))
#endif
#else
#ifndef SDK_ALIGN2_ASSERT
#define SDK_ALIGN2_ASSERT(exp) ((void) 0)
#endif
#endif
void OSi_ReferSymbol(void * symbol);
#define SDK_REFER_SYMBOL(symbol) OSi_ReferSymbol((void *)(symbol))
#define SDK_MIDDLEWARE_STRING(vender, module) "[SDK+" vender ":" module "]"
#define SDK_DEFINE_MIDDLEWARE(id, vender, module) static char id [] = SDK_MIDDLEWARE_STRING(vender, module)
#define SDK_USING_MIDDLEWARE(id) SDK_REFER_SYMBOL(id)
// SDK_INLINE void * OSi_AbortByUnsupportedRegister (const char * regname, const char * file, int line)
// {
// (void)regname;
// (void)file;
// (void)line;
// OSi_TPanic(file, line, " I/O register \"%s\" is unsupported on this platform!", regname);
// return 0;
// }
#define OS_UNSUPPORTED_REGADDR(reg) OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#define OS_UNSUPPORTED_REG8(reg) *(REGType8 *)OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#define OS_UNSUPPORTED_REG16(reg) *(REGType16 *)OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#define OS_UNSUPPORTED_REG32(reg) *(REGType32 *)OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#define OS_UNSUPPORTED_REG64(reg) *(REGType64 *)OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#ifdef __cplusplus
}
#endif
#endif

View File

@ -3,16 +3,16 @@
#include <nitro/types.h>
// #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
// #include <nitro/misc.h>
// #include <nitro/hw/common/armArch.h>
//
// #ifdef SDK_ARM7
// #include <nitro/hw/ARM7/ioreg_SND.h>
// #endif
// #else
// #define HW_CPU_CLOCK_ARM7 33513982
// #endif
#if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
#include <nitro/misc.h>
//#include <nitro/hw/common/armArch.h>
#ifdef SDK_ARM7
#include <nitro/hw/ARM7/ioreg_SND.h>
#endif
#else
#define HW_CPU_CLOCK_ARM7 33513982
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -3,11 +3,11 @@
#include <nitro/types.h>
// #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
// #include <nitro/misc.h>
// #else
// #define SDK_MINMAX_ASSERT(exp, min, max) ((void) 0)
// #endif
#if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
#include <nitro/misc.h>
#else
#define SDK_MINMAX_ASSERT(exp, min, max) ((void) 0)
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -231,7 +231,7 @@ Static main
Object lib/NitroSDK/asm/gxstate.o
Object lib/NitroSDK/asm/gx_vramcnt.o
Object lib/NitroSDK/asm/gx_bgcnt.o
Object lib/NitroSDK/asm/g2.o
Object lib/NitroSDK/src/gx/g2.o
Object lib/NitroSDK/asm/g3imm.o
Object lib/NitroSDK/asm/g3x.o
Object lib/NitroSDK/asm/g3_util.o

View File

@ -1,3 +1,4 @@
#include <nitro.h>
#include "main_02009F9C.h"
extern s32 _02092A04[];
@ -16,7 +17,7 @@ extern u8 _022A37F0[];
extern u8 _022A37F1[];
extern u8 _022A37F2[];
extern void G2x_SetBlendAlpha_(s32, s32, s32, s32, s32);
//extern void G2x_SetBlendAlpha_(s32, s32, s32, s32, s32);
extern void sub_02009B98(s32, u8);
extern void sub_02009BC0(s32, u8);
extern void sub_02009BE8(s32, u8);