mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-19 14:30:29 -04:00
185 lines
4.5 KiB
C
185 lines
4.5 KiB
C
#ifndef _DOLPHIN_GX_GXVERT_H_
|
|
#define _DOLPHIN_GX_GXVERT_H_
|
|
|
|
#ifdef __REVOLUTION_SDK__
|
|
#include <revolution/gx/GXVert.h>
|
|
#elif defined(TARGET_PC)
|
|
// On PC, include Aurora's GXVert for GXPosition/GXNormal/GXColor/GXTexCoord/GXEnd
|
|
// (extern functions implemented in Aurora's GXVert.cpp, stream-based vertex buffers)
|
|
#include "../../../extern/aurora/include/dolphin/gx/GXVert.h"
|
|
|
|
// Aurora's GXVert.h does not provide GXCmd, GXParam, GXMatrixIndex, or a valid
|
|
// GXWGFifo target. J3D code uses these for low-level display list writes.
|
|
// We declare them as extern (implemented in stubs.cpp) and provide a dummy
|
|
// GXWGFifo that writes into a throw-away buffer so direct FIFO writes don't crash.
|
|
|
|
// Replace Aurora's GXWGFifo macro (pointing to 0xCC008000) with an extern variable
|
|
#undef GXWGFifo
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// PPCWGPipe is already typedef'd by Aurora's GXVert.h above.
|
|
// Dummy FIFO sink: direct GXWGFifo writes in J3DFifo.h land here harmlessly.
|
|
extern volatile PPCWGPipe GXWGFifo;
|
|
|
|
void GXCmd1u8(const u8 x);
|
|
void GXCmd1u16(const u16 x);
|
|
void GXCmd1u32(const u32 x);
|
|
|
|
void GXParam1u8(const u8 x);
|
|
void GXParam1u16(const u16 x);
|
|
void GXParam1u32(const u32 x);
|
|
void GXParam1s8(const s8 x);
|
|
void GXParam1s16(const s16 x);
|
|
void GXParam1s32(const s32 x);
|
|
void GXParam1f32(const f32 x);
|
|
void GXParam3f32(const f32 x, const f32 y, const f32 z);
|
|
void GXParam4f32(const f32 x, const f32 y, const f32 z, const f32 w);
|
|
|
|
void GXMatrixIndex1u8(const u8 x);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#else
|
|
#include <dolphin/types.h>
|
|
#include <dolphin/os.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define GXFIFO_ADDR 0xCC008000
|
|
|
|
typedef union {
|
|
u8 u8;
|
|
u16 u16;
|
|
u32 u32;
|
|
u64 u64;
|
|
s8 s8;
|
|
s16 s16;
|
|
s32 s32;
|
|
s64 s64;
|
|
f32 f32;
|
|
f64 f64;
|
|
} PPCWGPipe;
|
|
|
|
#ifdef __MWERKS__
|
|
volatile PPCWGPipe GXWGFifo AT_ADDRESS(GXFIFO_ADDR);
|
|
#else
|
|
#define GXWGFifo (*(volatile PPCWGPipe *)GXFIFO_ADDR)
|
|
#endif
|
|
|
|
#if DEBUG
|
|
|
|
// external functions
|
|
|
|
#define FUNC_1PARAM(name, T) void name##1##T(const T x);
|
|
#define FUNC_2PARAM(name, T) void name##2##T(const T x, const T y);
|
|
#define FUNC_3PARAM(name, T) void name##3##T(const T x, const T y, const T z);
|
|
#define FUNC_4PARAM(name, T) void name##4##T(const T x, const T y, const T z, const T w);
|
|
#define FUNC_INDEX8(name) void name##1x8(const u8 x);
|
|
#define FUNC_INDEX16(name) void name##1x16(const u16 x);
|
|
|
|
#else
|
|
|
|
// inline functions
|
|
|
|
#define FUNC_1PARAM(name, T) \
|
|
static inline void name##1##T(const T x) { GXWGFifo.T = x; }
|
|
|
|
#define FUNC_2PARAM(name, T) \
|
|
static inline void name##2##T(const T x, const T y) { GXWGFifo.T = x; GXWGFifo.T = y; }
|
|
|
|
#define FUNC_3PARAM(name, T) \
|
|
static inline void name##3##T(const T x, const T y, const T z) { GXWGFifo.T = x; GXWGFifo.T = y; GXWGFifo.T = z; }
|
|
|
|
#define FUNC_4PARAM(name, T) \
|
|
static inline void name##4##T(const T x, const T y, const T z, const T w) { GXWGFifo.T = x; GXWGFifo.T = y; GXWGFifo.T = z; GXWGFifo.T = w; }
|
|
|
|
#define FUNC_INDEX8(name) \
|
|
static inline void name##1x8(const u8 x) { GXWGFifo.u8 = x; }
|
|
|
|
#define FUNC_INDEX16(name) \
|
|
static inline void name##1x16(const u16 x) { GXWGFifo.u16 = x; }
|
|
|
|
#endif
|
|
|
|
// GXCmd
|
|
FUNC_1PARAM(GXCmd, u8)
|
|
FUNC_1PARAM(GXCmd, u16)
|
|
FUNC_1PARAM(GXCmd, u32)
|
|
|
|
// GXParam
|
|
FUNC_1PARAM(GXParam, u8)
|
|
FUNC_1PARAM(GXParam, u16)
|
|
FUNC_1PARAM(GXParam, u32)
|
|
FUNC_1PARAM(GXParam, s8)
|
|
FUNC_1PARAM(GXParam, s16)
|
|
FUNC_1PARAM(GXParam, s32)
|
|
FUNC_1PARAM(GXParam, f32)
|
|
FUNC_3PARAM(GXParam, f32)
|
|
FUNC_4PARAM(GXParam, f32)
|
|
|
|
// GXPosition
|
|
FUNC_3PARAM(GXPosition, f32)
|
|
FUNC_3PARAM(GXPosition, u8)
|
|
FUNC_3PARAM(GXPosition, s8)
|
|
FUNC_3PARAM(GXPosition, u16)
|
|
FUNC_3PARAM(GXPosition, s16)
|
|
FUNC_2PARAM(GXPosition, f32)
|
|
FUNC_2PARAM(GXPosition, u8)
|
|
FUNC_2PARAM(GXPosition, s8)
|
|
FUNC_2PARAM(GXPosition, u16)
|
|
FUNC_2PARAM(GXPosition, s16)
|
|
FUNC_INDEX16(GXPosition)
|
|
FUNC_INDEX8(GXPosition)
|
|
|
|
// GXNormal
|
|
FUNC_3PARAM(GXNormal, f32)
|
|
FUNC_3PARAM(GXNormal, s16)
|
|
FUNC_3PARAM(GXNormal, s8)
|
|
FUNC_INDEX16(GXNormal)
|
|
FUNC_INDEX8(GXNormal)
|
|
|
|
// GXColor
|
|
FUNC_4PARAM(GXColor, u8)
|
|
FUNC_1PARAM(GXColor, u32)
|
|
FUNC_3PARAM(GXColor, u8)
|
|
FUNC_1PARAM(GXColor, u16)
|
|
FUNC_INDEX16(GXColor)
|
|
FUNC_INDEX8(GXColor)
|
|
|
|
// GXTexCoord
|
|
FUNC_2PARAM(GXTexCoord, f32)
|
|
FUNC_2PARAM(GXTexCoord, s16)
|
|
FUNC_2PARAM(GXTexCoord, u16)
|
|
FUNC_2PARAM(GXTexCoord, s8)
|
|
FUNC_2PARAM(GXTexCoord, u8)
|
|
FUNC_1PARAM(GXTexCoord, f32)
|
|
FUNC_1PARAM(GXTexCoord, s16)
|
|
FUNC_1PARAM(GXTexCoord, u16)
|
|
FUNC_1PARAM(GXTexCoord, s8)
|
|
FUNC_1PARAM(GXTexCoord, u8)
|
|
FUNC_INDEX16(GXTexCoord)
|
|
FUNC_INDEX8(GXTexCoord)
|
|
|
|
// GXMatrixIndex
|
|
FUNC_1PARAM(GXMatrixIndex, u8)
|
|
|
|
#undef FUNC_1PARAM
|
|
#undef FUNC_2PARAM
|
|
#undef FUNC_3PARAM
|
|
#undef FUNC_4PARAM
|
|
#undef FUNC_INDEX8
|
|
#undef FUNC_INDEX16
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
#endif
|