From e7bb9a818aa2d7df5a7b0c5ce34ab9f5a4aaa0ce Mon Sep 17 00:00:00 2001 From: superp00t Date: Mon, 8 Jul 2024 15:26:09 -0400 Subject: [PATCH] feat(include): add some gx device headers --- 3.3.5a/include/gx/buffer.h | 136 ++++++++++ 3.3.5a/include/gx/caps.h | 31 +++ 3.3.5a/include/gx/device.h | 88 +++++++ 3.3.5a/include/gx/format.h | 35 +++ 3.3.5a/include/gx/matrix_stack.h | 22 ++ 3.3.5a/include/gx/shader.h | 29 +++ 3.3.5a/include/gx/state_bom.h | 21 ++ 3.3.5a/include/gx/types.h | 355 ++++++++++++++++++++++++++ 3.3.5a/include/main.h | 19 +- 3.3.5a/include/storm/array/uint32_t.h | 2 +- 3.3.5a/include/storm/array/uint8_t.h | 10 + 3.3.5a/include/storm/hash.h | 47 ++++ 3.3.5a/include/storm/list.h | 17 +- README.md | 6 +- 14 files changed, 805 insertions(+), 13 deletions(-) create mode 100644 3.3.5a/include/gx/buffer.h create mode 100644 3.3.5a/include/gx/caps.h create mode 100644 3.3.5a/include/gx/device.h create mode 100644 3.3.5a/include/gx/format.h create mode 100644 3.3.5a/include/gx/matrix_stack.h create mode 100644 3.3.5a/include/gx/shader.h create mode 100644 3.3.5a/include/gx/state_bom.h create mode 100644 3.3.5a/include/gx/types.h create mode 100644 3.3.5a/include/storm/array/uint8_t.h create mode 100644 3.3.5a/include/storm/hash.h diff --git a/3.3.5a/include/gx/buffer.h b/3.3.5a/include/gx/buffer.h new file mode 100644 index 0000000..1eed0c4 --- /dev/null +++ b/3.3.5a/include/gx/buffer.h @@ -0,0 +1,136 @@ +#ifndef GX_BUFFER_H +#define GX_BUFFER_H + +#include + +#include "storm/list.h" +#include "tempest/vector.h" + +typedef enum EGxPoolHintBits EGxPoolHintBits; +typedef enum EGxPoolTarget EGxPoolTarget; +typedef enum EGxPoolUsage EGxPoolUsage; +typedef enum EGxVertexAttrib EGxVertexAttrib; +typedef enum EGxVertexBufferFormat EGxVertexBufferFormat; +typedef struct ubyte4 ubyte4; +typedef struct CGxVertexAttrib CGxVertexAttrib; +typedef struct CGxVertexPBNT2 CGxVertexPBNT2; +typedef struct CGxVertexPCT CGxVertexPCT; +typedef struct CGxPool CGxPool; +typedef struct CGxBuf CGxBuf; + +enum EGxPoolHintBits { + GxPoolHintBit_Unk0 = 0, + GxPoolHintBit_Unk1 = 1, + GxPoolHintBit_Unk2 = 2, + GxPoolHintBit_Unk3 = 3 +}; + +enum EGxPoolTarget { + GxPoolTarget_Vertex = 0, + GxPoolTarget_Index = 1, + GxPoolTargets_Last = 2 +}; + +enum EGxPoolUsage { + GxPoolUsage_Static = 0, + GxPoolUsage_Dynamic = 1, + GxPoolUsage_Stream = 2, + GxPoolUsages_Last = 3 +}; + +enum EGxVertexAttrib { + GxVA_Position = 0, + GxVA_BlendWeight = 1, + GxVA_BlendIndices = 2, + GxVA_Normal = 3, + GxVA_Color0 = 4, + GxVA_Color1 = 5, + GxVA_TexCoord0 = 6, + GxVA_TexCoord1 = 7, + GxVA_TexCoord2 = 8, + GxVA_TexCoord3 = 9, + GxVA_TexCoord4 = 10, + GxVA_TexCoord5 = 11, + GxVA_TexCoord6 = 12, + GxVA_TexCoord7 = 13, + GxVAs_Last = 14 +}; + +enum EGxVertexBufferFormat { + GxVBF_P = 0, + GxVBF_PN = 1, + GxVBF_PNC = 2, + GxVBF_PNT = 3, + GxVBF_PNCT = 4, + GxVBF_PNT2 = 5, + GxVBF_PNCT2 = 6, + GxVBF_PC = 7, + GxVBF_PCT = 8, + GxVBF_PCT2 = 9, + GxVBF_PT = 10, + GxVBF_PT2 = 11, + GxVBF_PBNT2 = 12, + GxVBF_PNC2T2 = 13, + GxVertexBufferFormats_Last = 14 +}; + +struct ubyte4 { + union { + uint8_t b[4]; + uint32_t u; + }; +}; + +struct CGxVertexAttrib { + EGxVertexAttrib attrib; + uint32_t type; + uint32_t offset; + uint32_t bufSize; +}; + +struct CGxVertexPBNT2 { + C3Vector p; + ubyte4 bw; + ubyte4 bi; + C3Vector n; + C2Vector tc[2]; +}; + +struct CGxVertexPCT { + C3Vector p; + CImVector c; + C2Vector tc[1]; +}; + +STORM_TS_LIST(CGxBuf); +STORM_TS_LIST(CGxPool); + +// class CGxPool : public TSLinkedNode +struct CGxPool { + TSLinkedNode_CGxPool b_base; + EGxPoolTarget m_target; + EGxPoolUsage m_usage; + int32_t m_size; + void* m_apiSpecific; + void* m_mem; + int32_t unk1C; // TODO + TSList_CGxBuf m_bufList; + EGxPoolHintBits m_hint; + const char* m_name; +}; + +// class CGxBuf : public TSLinkedNode +struct CGxBuf { + TSLinkedNode_CGxBuf b_base; + CGxPool* m_pool; + uint32_t m_itemSize; + uint32_t m_itemCount; + uint32_t m_size; + uint32_t m_index; + uint8_t unk1C; // TODO + uint8_t unk1D; // TODO + uint8_t unk1E; // TODO + uint8_t unk1F; // TODO +}; + +#endif \ No newline at end of file diff --git a/3.3.5a/include/gx/caps.h b/3.3.5a/include/gx/caps.h new file mode 100644 index 0000000..ee1dd4e --- /dev/null +++ b/3.3.5a/include/gx/caps.h @@ -0,0 +1,31 @@ +#ifndef GX_CAPS_H +#define GX_CAPS_H + +#include "gx/types.h" +#include + +typedef struct CGxCaps CGxCaps; + +struct CGxCaps { + int32_t m_numTmus; + int32_t m_pixelCenterOnEdge; + int32_t m_texelCenterOnEdge; + int32_t m_numStreams; + int32_t int10; + EGxColorFormat m_colorFormat; + uint32_t m_maxIndex; + int32_t m_generateMipMaps; + int32_t m_texFmt[GxTexFormats_Last]; + int32_t m_texTarget[GxTexTargets_Last]; + uint32_t m_texMaxSize[GxTexTargets_Last]; + int32_t m_shaderTargets[GxShTargets_Last]; + int32_t m_texFilterTrilinear; + int32_t m_texFilterAnisotropic; + uint32_t m_maxTexAnisotropy; + int32_t m_depthBias; + int32_t int130; + int32_t int134; + int32_t int138; +}; + +#endif diff --git a/3.3.5a/include/gx/device.h b/3.3.5a/include/gx/device.h new file mode 100644 index 0000000..c325ce9 --- /dev/null +++ b/3.3.5a/include/gx/device.h @@ -0,0 +1,88 @@ +#ifndef GX_DEVICE_H +#define GX_DEVICE_H + +#include + +#include "storm/array.h" +#include "storm/array/uint32_t.h" + +#include "tempest/box.h" +#include "tempest/matrix.h" +#include "tempest/rect.h" +#include "tempest/vector.h" + +#include "gx/types.h" +#include "gx/caps.h" +#include "gx/format.h" +#include "gx/state_bom.h" +#include "gx/shader.h" +#include "gx/matrix_stack.h" +#include "gx/buffer.h" + +typedef struct CGxDevice CGxDevice; + +struct CGxAppRenderState { + CGxStateBom m_value; + uint32_t m_stackDepth; + int32_t m_dirty; +}; +STORM_TS_FIXED_ARRAY(CGxAppRenderState); + +struct CGxPushedRenderState { + EGxRenderState m_which; + CGxStateBom m_value; + uint32_t m_stackDepth; +}; +STORM_TS_GROWABLE_ARRAY(CGxPushedRenderState); + +struct ShaderConstants { + C4Vector constants[256]; + uint32_t unk1; + uint32_t unk2; +}; + +// minimum size in binary: 3944 bytes +struct CGxDevice { + // TODO: pointer to struct CGxDevice__vtable + void* v_vtable; + TSGrowableArray_CGxPushedRenderState m_pushedStates; + TSGrowableArray_uint32_t m_stackOffsets; + TSGrowableArray_EGxRenderState m_dirtyStates; + CRect m_defWindowRect; + CRect m_curWindowRect; + EGxApi m_api; + CGxFormat m_format; + CGxCaps m_caps; + TSHashTable_CGxShader_HASHKEY_STRI m_shaderList[GxShTargets_Last]; + int32_t (*m_windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam); + int32_t m_context; + int32_t intF5C; + int32_t m_windowVisible; + int32_t intF64; + int32_t intF6C; + CBoundingBox m_viewport; + C44Matrix m_projection; + C44Matrix m_projNative; + CGxMatrixStack m_xforms[GxXforms_Last]; + uint32_t m_appMasterEnables; + uint32_t m_hwMasterEnables; + TSList_CGxPool m_poolList; + CGxBuf* m_bufLocked[GxPoolTargets_Last]; + CGxPool* m_vertexPool; + CGxPool* m_indexPool; + CGxBuf* m_streamBufs[GxPoolTargets_Last]; + CGxVertexAttrib m_primVertexFormatAttrib[GxVertexBufferFormats_Last]; + CGxBuf* m_primVertexFormatBuf[GxVertexBufferFormats_Last]; + uint32_t m_primVertexMask; + uint32_t m_primVertexDirty; + EGxVertexBufferFormat m_primVertexFormat; + CGxBuf* m_primVertexBuf; + uint32_t m_primVertexSize; + CGxBuf* m_primIndexBuf; + int32_t m_primIndexDirty; + TSFixedArray_CGxAppRenderState m_appRenderStates; + TSFixedArray_CGxStateBom m_hwRenderStates; + uint32_t m_baseMipLevel; // TODO placeholder +}; + +#endif \ No newline at end of file diff --git a/3.3.5a/include/gx/format.h b/3.3.5a/include/gx/format.h new file mode 100644 index 0000000..4acf671 --- /dev/null +++ b/3.3.5a/include/gx/format.h @@ -0,0 +1,35 @@ +#ifndef GX_FORMAT_H +#define GX_FORMAT_H + +#include +#include "tempest/vector.h" + +typedef enum CGxFormat__Format CGxFormat__Format; +typedef struct CGxFormat CGxFormat; + +enum CGxFormat__Format { + Fmt_Rgb565 = 0, + Fmt_ArgbX888 = 1, + Fmt_Argb8888 = 2, + Fmt_Argb2101010 = 3, + Fmt_Ds160 = 4, + Fmt_Ds24X = 5, + Fmt_Ds248 = 6, + Fmt_Ds320 = 7, + Formats_Last = 8 +}; + +struct CGxFormat { + bool hwTnL; + int8_t window; + int32_t maximize; + CGxFormat__Format depthFormat; + C2iVector size; + uint32_t sampleCount; + CGxFormat__Format colorFormat; + uint32_t refreshRate; + uint32_t vsync; + C2iVector pos; +}; + +#endif diff --git a/3.3.5a/include/gx/matrix_stack.h b/3.3.5a/include/gx/matrix_stack.h new file mode 100644 index 0000000..8769c10 --- /dev/null +++ b/3.3.5a/include/gx/matrix_stack.h @@ -0,0 +1,22 @@ +#ifndef GX_MATRIX_STACK_H +#define GX_MATRIX_STACK_H + +#include + +#include "tempest/matrix.h" + +typedef enum CGxMatrixStack__EMatrixFlags CGxMatrixStack__EMatrixFlags; +typedef struct CGxMatrixStack CGxMatrixStack; + +enum CGxMatrixStack__EMatrixFlags { + F_Identity = 0x1 +}; + +struct CGxMatrixStack { + uint32_t m_level; + int8_t m_dirty; + C44Matrix m_mtx[4]; + uint32_t m_flags[4]; +}; + +#endif \ No newline at end of file diff --git a/3.3.5a/include/gx/shader.h b/3.3.5a/include/gx/shader.h new file mode 100644 index 0000000..bc0c009 --- /dev/null +++ b/3.3.5a/include/gx/shader.h @@ -0,0 +1,29 @@ +#ifndef GX_SHADER_H +#define GX_SHADER_H + +#include "storm/hash.h" +#include "storm/array/uint8_t.h" + +typedef struct CGxShader CGxShader; + +STORM_TS_HASH(CGxShader, HASHKEY_STRI); + +// class CGxShader : public TSHashObject +struct CGxShader { + TSHashObject_CGxShader_HASHKEY_STRI b_base; + uint32_t refCount; + void* apiSpecific; + int32_t target; + int32_t int28; + int32_t valid; + int32_t loaded; + int32_t int34; + int32_t patched; + int32_t int3C; + int32_t int40; + int16_t int44; + int16_t int46; + TSGrowableArray_uint8_t code; +}; + +#endif \ No newline at end of file diff --git a/3.3.5a/include/gx/state_bom.h b/3.3.5a/include/gx/state_bom.h new file mode 100644 index 0000000..e31270e --- /dev/null +++ b/3.3.5a/include/gx/state_bom.h @@ -0,0 +1,21 @@ +#ifndef GX_STATE_BOM_H +#define GX_STATE_BOM_H + +#include +#include "storm/array.h" + +typedef struct CGxStateBom CGxStateBom; + +struct CGxStateBom { + union { + int32_t i[3]; + uint32_t u[3]; + float f[3]; + void* p; + } m_data; + + int32_t filler; +}; +STORM_TS_FIXED_ARRAY(CGxStateBom); + +#endif \ No newline at end of file diff --git a/3.3.5a/include/gx/types.h b/3.3.5a/include/gx/types.h new file mode 100644 index 0000000..afb7b6e --- /dev/null +++ b/3.3.5a/include/gx/types.h @@ -0,0 +1,355 @@ +#ifndef GX_TYPES_H +#define GX_TYPES_H + +#include + +#include "storm/array.h" + +enum BlitAlpha { + BlitAlpha_0 = 0, + BlitAlpha_1 = 1, + BlitAlpha_8 = 2, + BlitAlpha_Filler = 3, + BlitAlphas_Last = 4 +}; + +enum BlitFormat { + BlitFormat_Unknown = 0, + BlitFormat_Abgr8888 = 1, + BlitFormat_Argb8888 = 2, + BlitFormat_Argb4444 = 3, + BlitFormat_Argb1555 = 4, + BlitFormat_Rgb565 = 5, + BlitFormat_Dxt1 = 6, + BlitFormat_Dxt3 = 7, + BlitFormat_Dxt5 = 8, + BlitFormat_Uv88 = 9, + BlitFormat_Gr1616F = 10, + BlitFormat_R32F = 11, + BlitFormat_D24X8 = 12, + BlitFormats_Last = 13 +}; + +enum EGxApi { + GxApi_OpenGl = 0, + GxApi_D3d9 = 1, + GxApi_D3d9Ex = 2, + GxApi_D3d10 = 3, + GxApi_D3d11 = 4, + GxApi_GLL = 5, + GxApi_GLSDL = 6, + GxApis_Last = 7 +}; + +enum EGxBlend { + GxBlend_Opaque = 0, + GxBlend_AlphaKey = 1, + GxBlend_Alpha = 2, + GxBlend_Add = 3, + GxBlend_Mod = 4, + GxBlend_Mod2x = 5, + GxBlend_ModAdd = 6, + GxBlend_InvSrcAlphaAdd = 7, + GxBlend_InvSrcAlphaOpaque = 8, + GxBlend_SrcAlphaOpaque = 9, + GxBlend_NoAlphaAdd = 10, + GxBlend_ConstantAlpha = 11, + GxBlends_Last = 12 +}; + +enum EGxColorFormat { + GxCF_argb = 0, + GxCF_rgba = 1, + GxColorFormats_Last = 2, +}; + +enum EGxFontHJusts { + GxHJ_Left = 0, + GxHJ_Center = 1, + GxHJ_Right = 2, + GxHJ_Last = 3 +}; + +enum EGxFontVJusts { + GxVJ_Top = 0, + GxVJ_Middle = 1, + GxVJ_Bottom = 2, + GxVJ_Last = 3 +}; + +enum EGxMasterEnables { + GxMasterEnable_Lighting = 0, + GxMasterEnable_Fog = 1, + GxMasterEnable_DepthTest = 2, + GxMasterEnable_DepthWrite = 3, + GxMasterEnable_ColorWrite = 4, + GxMasterEnable_Culling = 5, + GxMasterEnable_DoubleBuffering = 6, + GxMasterEnable_NormalProjection = 7, + GxMasterEnable_PolygonFill = 8, + GxMasterEnables_Last = 9 +}; + +enum EGxPrim { + GxPrim_Points = 0, + GxPrim_Lines = 1, + GxPrim_LineStrip = 2, + GxPrim_Triangles = 3, + GxPrim_TriangleStrip = 4, + GxPrim_TriangleFan = 5, + GxPrims_Last = 6 +}; + +enum EGxPrimMask { + GxPrim_Position = 0x1, + GxPrim_BlendWeight = 0x2, + GxPrim_BlendIndices = 0x4, + GxPrim_Normal = 0x8, + GxPrim_Color0 = 0x10, + GxPrim_Color1 = 0x20, + GxPrim_TexCoord0 = 0x40, + GxPrim_TexCoord1 = 0x80 +}; + +enum EGxRenderState { + GxRs_PolygonOffset = 0, + GxRs_MatDiffuse = 1, + GxRs_MatEmissive = 2, + GxRs_MatSpecular = 3, + GxRs_MatSpecularExp = 4, + GxRs_NormalizeNormals = 5, + GxRs_BlendingMode = 6, + GxRs_AlphaRef = 7, + GxRs_FogStart = 8, + GxRs_FogEnd = 9, + GxRs_FogColor = 10, + GxRs_Lighting = 11, + GxRs_Fog = 12, + GxRs_DepthTest = 13, + GxRs_DepthFunc = 14, + GxRs_DepthWrite = 15, + GxRs_ColorWrite = 16, + GxRs_Culling = 17, + GxRs_ClipPlaneMask = 18, + GxRs_Multisample = 19, + GxRs_ScissorTest = 20, + GxRs_Texture0 = 21, + GxRs_Texture1 = 22, + GxRs_Texture2 = 23, + GxRs_Texture3 = 24, + GxRs_Texture4 = 25, + GxRs_Texture5 = 26, + GxRs_Texture6 = 27, + GxRs_Texture7 = 28, + GxRs_Texture8 = 29, + GxRs_Texture9 = 30, + GxRs_Texture10 = 31, + GxRs_Texture11 = 32, + GxRs_Texture12 = 33, + GxRs_Texture13 = 34, + GxRs_Texture14 = 35, + GxRs_Texture15 = 36, + GxRs_ColorOp0 = 37, + GxRs_ColorOp1 = 38, + GxRs_ColorOp2 = 39, + GxRs_ColorOp3 = 40, + GxRs_ColorOp4 = 41, + GxRs_ColorOp5 = 42, + GxRs_ColorOp6 = 43, + GxRs_ColorOp7 = 44, + GxRs_AlphaOp0 = 45, + GxRs_AlphaOp1 = 46, + GxRs_AlphaOp2 = 47, + GxRs_AlphaOp3 = 48, + GxRs_AlphaOp4 = 49, + GxRs_AlphaOp5 = 50, + GxRs_AlphaOp6 = 51, + GxRs_AlphaOp7 = 52, + GxRs_TexGen0 = 53, + GxRs_TexGen1 = 54, + GxRs_TexGen2 = 55, + GxRs_TexGen3 = 56, + GxRs_TexGen4 = 57, + GxRs_TexGen5 = 58, + GxRs_TexGen6 = 59, + GxRs_TexGen7 = 60, + GxRs_Unk61 = 61, + GxRs_Unk62 = 62, + GxRs_Unk63 = 63, + GxRs_Unk64 = 64, + GxRs_Unk65 = 65, + GxRs_Unk66 = 66, + GxRs_Unk67 = 67, + GxRs_Unk68 = 68, + GxRs_Unk69 = 69, + GxRs_Unk70 = 70, + GxRs_Unk71 = 71, + GxRs_Unk72 = 72, + GxRs_Unk73 = 73, + GxRs_Unk74 = 74, + GxRs_Unk75 = 75, + GxRs_Unk76 = 76, + GxRs_VertexShader = 77, + GxRs_PixelShader = 78, + GxRs_PointScale = 79, + GxRs_PointScaleAttenuation = 80, + GxRs_PointScaleMin = 81, + GxRs_PointScaleMax = 82, + GxRs_PointSprite = 83, + GxRs_Unk84 = 84, + GxRs_ColorMaterial = 85, + GxRenderStates_Last = 86 +}; +STORM_TS_GROWABLE_ARRAY(EGxRenderState); + +enum EGxShPS { + GxShPS_none = 0, + GxShPS_ps_1_1 = 1, + GxShPS_ps_1_4 = 2, + GxShPS_ps_2_0 = 3, + GxShPS_ps_3_0 = 4, + GxShPS_ps_4_0 = 5, + GxShPS_ps_5_0 = 6, + GxShPS_nvrc = 7, + GxShPS_nvts = 8, + GxShPS_nvts2 = 9, + GxShPS_nvts3 = 10, + GxShPS_nvfp2 = 11, + GxShPS_arbfp1 = 12, + GxShPS_glsl = 13, +}; + +enum EGxShTarget { + GxSh_Vertex = 0, + GxSh_Hull = 1, + GxSh_Domain = 2, + GxSh_Geometry = 3, + GxSh_Pixel = 4, + GxSh_Compute = 5, + GxShTargets_Last = 6 +}; + +enum EGxShVS { + GxShVS_none = 0, + GxShVS_vs_1_1 = 1, + GxShVS_vs_2_0 = 2, + GxShVS_vs_3_0 = 3, + GxShVS_vs_4_0 = 4, + GxShVS_vs_5_0 = 5, + GxShVS_arbvp1 = 6, + GxShVS_arbvp1_cg12 = 7, + GxShVS_nvvp = 8, + GxShVS_nvvp2 = 9, + GxShVS_nvvp3 = 10, + GxShVS_glsl = 11 +}; + +enum EGxTexCommand { + GxTex_Lock = 0, + GxTex_Latch = 1, + GxTex_Unlock = 2, + GxTexCommands_Last = 3 +}; + +enum EGxTexFilter { + GxTex_Nearest = 0x0, + GxTex_Linear = 0x1, + GxTex_NearestMipNearest = 0x2, + GxTex_LinearMipNearest = 0x3, + GxTex_LinearMipLinear = 0x4, + GxTex_Anisotropic = 0x5, + GxTexFilters_Last = 0x6, +}; + +enum EGxTexFormat { + GxTex_Unknown = 0x0, + GxTex_Abgr8888 = 0x1, + GxTex_Argb8888 = 0x2, + GxTex_Argb4444 = 0x3, + GxTex_Argb1555 = 0x4, + GxTex_Rgb565 = 0x5, + GxTex_Dxt1 = 0x6, + GxTex_Dxt3 = 0x7, + GxTex_Dxt5 = 0x8, + GxTex_Uv88 = 0x9, + GxTex_Gr1616F = 0xA, + GxTex_R32F = 0xB, + GxTex_D24X8 = 0xC, + GxTexFormats_Last = 0xD, +}; + +enum EGxTexTarget { + GxTex_2d = 0x0, + GxTex_CubeMap = 0x1, + GxTex_Rectangle = 0x2, + GxTex_NonPow2 = 0x3, + GxTexTargets_Last = 0x4 +}; + +enum EGxTexWrapMode { + GxTex_Clamp = 0, + GxTex_Wrap = 1 +}; + +enum EGxXform { + GxXform_Tex0 = 0, + GxXform_Tex1 = 1, + GxXform_Tex2 = 2, + GxXform_Tex3 = 3, + GxXform_Tex4 = 4, + GxXform_Tex5 = 5, + GxXform_Tex6 = 6, + GxXform_Tex7 = 7, + GxXform_World = 8, + GxXform_Projection = 9, + GxXform_View = 10, + GxXforms_Last = 11 +}; + +enum EGxuDrawListCategory { + GxuCat_0 = 0, + GxuCat_1 = 1, + GxuCat_2 = 2 +}; + +enum EGxWM { + GxWM_Size = 0, + GxWM_DisplayChange = 1, + GxWM_Destroy = 2, + GxWM_SetFocus = 3, + GxWM_KillFocus = 4, +}; + +enum COLOR_FILE_FORMAT { + COLOR_JPEG = 0, + COLOR_PAL = 1, + COLOR_DXT = 2, + COLOR_3 = 3 +}; + +enum PIXEL_FORMAT { + PIXEL_DXT1 = 0x0, + PIXEL_DXT3 = 0x1, + PIXEL_ARGB8888 = 0x2, + PIXEL_ARGB1555 = 0x3, + PIXEL_ARGB4444 = 0x4, + PIXEL_RGB565 = 0x5, + PIXEL_A8 = 0x6, + PIXEL_DXT5 = 0x7, + PIXEL_UNSPECIFIED = 0x8, + PIXEL_ARGB2565 = 0x9, + NUM_PIXEL_FORMATS = 0xA +}; + +struct C4Pixel { + char b; + char g; + char r; + char a; +}; + +struct MipBits { + C4Pixel* mip[1]; +}; + +#endif diff --git a/3.3.5a/include/main.h b/3.3.5a/include/main.h index 1306079..50043aa 100644 --- a/3.3.5a/include/main.h +++ b/3.3.5a/include/main.h @@ -1,6 +1,7 @@ // Types #include "storm/array.h" #include "storm/list.h" +#include "storm/hash.h" #include "tempest/box.h" #include "tempest/matrix.h" @@ -11,5 +12,19 @@ #include "tempest/sphere.h" #include "tempest/vector.h" -// include files that define the use of template classes -#include "storm/array/uint32_t.h" \ No newline at end of file +#include "gx/buffer.h" +#include "gx/caps.h" +#include "gx/device.h" +#include "gx/format.h" +#include "gx/matrix_stack.h" +#include "gx/shader.h" +#include "gx/state_bom.h" +#include "gx/types.h" + +// include files that define the use of template classes for standard library types + +#include "storm/array/uint32_t.h" + +// template types that are defined in our headers, should be declared immediately after the base type +// and not used anywhere else + diff --git a/3.3.5a/include/storm/array/uint32_t.h b/3.3.5a/include/storm/array/uint32_t.h index f54dd73..ec11de9 100644 --- a/3.3.5a/include/storm/array/uint32_t.h +++ b/3.3.5a/include/storm/array/uint32_t.h @@ -5,6 +5,6 @@ #include "storm/array.h" -STORM_TS_GROWABLE_ARRAY(uint32_t) +STORM_TS_GROWABLE_ARRAY(uint32_t); #endif \ No newline at end of file diff --git a/3.3.5a/include/storm/array/uint8_t.h b/3.3.5a/include/storm/array/uint8_t.h new file mode 100644 index 0000000..5d8f12d --- /dev/null +++ b/3.3.5a/include/storm/array/uint8_t.h @@ -0,0 +1,10 @@ +#ifndef STORM_ARRAY_UINT8_T_H +#define STORM_ARRAY_UINT8_T_H + +#include + +#include "storm/array.h" + +STORM_TS_GROWABLE_ARRAY(uint8_t); + +#endif \ No newline at end of file diff --git a/3.3.5a/include/storm/hash.h b/3.3.5a/include/storm/hash.h new file mode 100644 index 0000000..652bd3f --- /dev/null +++ b/3.3.5a/include/storm/hash.h @@ -0,0 +1,47 @@ +#ifndef STORM_HASH_H +#define STORM_HASH_H + +#include + +#include "storm/array.h" +#include "storm/list.h" + +#define STORM_TS_HASH(T, K) \ +STORM_TS_LIST(T) \ +STORM_TS_GROWABLE_ARRAY(TSList_##T) \ +typedef struct TSHashTable_##T##_##K TSHashTable_##T##_##K; \ +typedef struct TSHashObject_##T##_##K TSHashObject_##T##_##K; \ +struct TSHashTable_##T##_##K { \ + TSList_##T m_fulllist; \ + uint32_t m_fulllist; \ + TSGrowableArray_TSList_##T m_slotlistarray; \ + uint32_t m_slotmask; \ +}; \ +struct TSHashObject_##T##_##K { \ + uint32_t m_hashval; \ + TSLink_##T m_linktoslot; \ + TSLink_##T m_linktofull; \ + K m_key; \ +}; + +typedef struct HASHKEY_PTR HASHKEY_PTR; +typedef struct HASHKEY_STR HASHKEY_STR; +typedef struct HASHKEY_STRI HASHKEY_STRI; +typedef struct HASHKEY_NONE HASHKEY_NONE; + +struct HASHKEY_PTR { + void* m_key; +}; + +struct HASHKEY_STR { + char* m_str; +}; + +struct HASHKEY_STRI { + char* m_str; +}; + +struct HASHKEY_NONE { +}; + +#endif \ No newline at end of file diff --git a/3.3.5a/include/storm/list.h b/3.3.5a/include/storm/list.h index 6afa644..924840b 100644 --- a/3.3.5a/include/storm/list.h +++ b/3.3.5a/include/storm/list.h @@ -14,17 +14,18 @@ struct TSLink_##T { \ T* m_next; \ }; +// TSList // TSLinkedNode -#define STORM_TS_LINKED_NODE(T) typedef struct TSLinkedNode_##T TSLinkedNode_##T; \ +#define STORM_TS_LIST(T) \ +STORM_TS_LINK(T) \ +typedef struct TSList_##T TSList_##T##; \ +typedef struct TSLinkedNode_##T TSLinkedNode_##T; \ +struct TSList_##T { \ + ptrdiff_t m_linkoffset; \ + TSLink_##T m_terminator; \ +}; \ struct TSLinkedNode_##T { \ TSLink_##T m_link; \ }; -// TSList -#define STORM_TS_LIST(T) typedef struct TSList_##T TSList_##T##; \ -struct TSList_##T { \ - ptrdiff_t m_linkoffset; \ - TSLink_##T m_terminator; \ -}; - #endif \ No newline at end of file diff --git a/README.md b/README.md index a6fd09f..806db5b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ To use these headers in Ghidra, 1. go to `File` > `Parse C Source...`. 2. Select `clib.prf` as your parse configuration, and clear all source files and input paths. 3. Add the header `/include/main.h` to the `Source files to parse` combo box. - 4. press `Parse to Program`. + 4. Add the path to `/include` to the `Include paths` combo box. + 5. press `Parse to Program`. TODO: equivalent guide for IDA Pro. @@ -51,4 +52,5 @@ To import this file to your Ghidra project, To refresh the `main.sym` file after changing one of the constituent symbol files: ```bash -script/compile-symbols \ No newline at end of file +script/compile-symbols +``` \ No newline at end of file