From 87bc0e711b4fb2f990f3c37ca681be1fc027d554 Mon Sep 17 00:00:00 2001 From: lepelog Date: Thu, 1 Apr 2021 00:15:05 +0200 Subject: [PATCH] c_API --- include/SSystem/SComponent/c_API.h | 4 ++ include/SSystem/SComponent/c_API_graphic.h | 4 ++ include/SSystem/SComponent/c_m3d_g_cyl.h | 26 ++++++++++++ libs/SSystem/SComponent/c_API.cpp | 19 ++------- libs/SSystem/SComponent/c_API_graphic.cpp | 46 ++++------------------ libs/SSystem/SComponent/c_m3d_g_cyl.cpp | 2 +- 6 files changed, 45 insertions(+), 56 deletions(-) diff --git a/include/SSystem/SComponent/c_API.h b/include/SSystem/SComponent/c_API.h index 8cae06f3cb7..0813ef82cf5 100644 --- a/include/SSystem/SComponent/c_API.h +++ b/include/SSystem/SComponent/c_API.h @@ -3,4 +3,8 @@ #include "dolphin/types.h" +typedef void (*cAPIGph_Mthd)(void); + +extern cAPIGph_Mthd g_cAPI_Interface[6]; + #endif /* C_API_H */ diff --git a/include/SSystem/SComponent/c_API_graphic.h b/include/SSystem/SComponent/c_API_graphic.h index 2d9d8c2b7a8..2419b4bfd4f 100644 --- a/include/SSystem/SComponent/c_API_graphic.h +++ b/include/SSystem/SComponent/c_API_graphic.h @@ -3,4 +3,8 @@ #include "dolphin/types.h" +void cAPIGph_Painter(void); +void cAPIGph_BeforeOfDraw(void); +void cAPIGph_AfterOfDraw(void); + #endif /* C_API_GRAPHIC_H */ diff --git a/include/SSystem/SComponent/c_m3d_g_cyl.h b/include/SSystem/SComponent/c_m3d_g_cyl.h index e5d0da31e7a..292ce0080ed 100644 --- a/include/SSystem/SComponent/c_m3d_g_cyl.h +++ b/include/SSystem/SComponent/c_m3d_g_cyl.h @@ -2,5 +2,31 @@ #define C_M3D_G_CYL_H #include "dolphin/types.h" +#include "SSystem/SComponent/c_xyz.h" + +// Cylinder +struct cM3dGCylS { + cXyz mCenter; + f32 mRadius; + f32 mHeight; +}; +class cM3dGSph; + +class cM3dGCyl : public cM3dGCylS { +public: + cM3dGCyl(const cXyz*, f32, f32); + ~cM3dGCyl(); + void Set(const cM3dGCylS&); + void Set(const cXyz&, f32, f32); + void SetC(const cXyz&); + void SetH(f32); + void SetR(f32); + bool cross(const cM3dGSph*, cXyz*) const; + bool cross(const cM3dGCyl*, cXyz*) const; + void calcMinMax(cXyz*, cXyz*); + const cXyz& GetCP(void) const { return mCenter; } + f32 GetR(void) const { return mRadius; } + f32 GetH(void) const { return mHeight; } +}; #endif /* C_M3D_G_CYL_H */ diff --git a/libs/SSystem/SComponent/c_API.cpp b/libs/SSystem/SComponent/c_API.cpp index 2c24060505c..2e545af3321 100644 --- a/libs/SSystem/SComponent/c_API.cpp +++ b/libs/SSystem/SComponent/c_API.cpp @@ -7,12 +7,6 @@ #include "dol2asm.h" #include "dolphin/types.h" -// -// Forward References: -// - -extern "C" extern void* g_cAPI_Interface[6]; - // // External References: // @@ -24,20 +18,13 @@ void mDoGph_AfterOfDraw(); void mDoGph_Painter(); void mDoGph_Create(); -extern "C" void mDoGph_BlankingON__Fv(); -extern "C" void mDoGph_BlankingOFF__Fv(); -extern "C" void mDoGph_BeforeOfDraw__Fv(); -extern "C" void mDoGph_AfterOfDraw__Fv(); -extern "C" void mDoGph_Painter__Fv(); -extern "C" void mDoGph_Create__Fv(); - // // Declarations: // /* ############################################################################################## */ /* 803C3528-803C3540 0018+00 s=0 e=3 z=0 None .data g_cAPI_Interface */ -SECTION_DATA void* g_cAPI_Interface[6] = { - (void*)mDoGph_Create__Fv, (void*)mDoGph_BeforeOfDraw__Fv, (void*)mDoGph_AfterOfDraw__Fv, - (void*)mDoGph_Painter__Fv, (void*)mDoGph_BlankingON__Fv, (void*)mDoGph_BlankingOFF__Fv, +cAPIGph_Mthd g_cAPI_Interface[6] = { + mDoGph_Create, mDoGph_BeforeOfDraw, mDoGph_AfterOfDraw, + mDoGph_Painter, mDoGph_BlankingON, mDoGph_BlankingOFF, }; diff --git a/libs/SSystem/SComponent/c_API_graphic.cpp b/libs/SSystem/SComponent/c_API_graphic.cpp index 98997e1e36c..744ffcaf43f 100644 --- a/libs/SSystem/SComponent/c_API_graphic.cpp +++ b/libs/SSystem/SComponent/c_API_graphic.cpp @@ -4,57 +4,25 @@ // #include "SSystem/SComponent/c_API_graphic.h" +#include "SSystem/SComponent/c_API.h" #include "dol2asm.h" #include "dolphin/types.h" -// -// Forward References: -// - -void cAPIGph_Painter(); -void cAPIGph_BeforeOfDraw(); -void cAPIGph_AfterOfDraw(); - -extern "C" void cAPIGph_Painter__Fv(); -extern "C" void cAPIGph_BeforeOfDraw__Fv(); -extern "C" void cAPIGph_AfterOfDraw__Fv(); - -// -// External References: -// - -extern "C" extern void* g_cAPI_Interface[6]; - // // Declarations: // /* 802632C8-802632F8 0030+00 s=0 e=1 z=0 None .text cAPIGph_Painter__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cAPIGph_Painter() { - nofralloc -#include "asm/SSystem/SComponent/c_API_graphic/cAPIGph_Painter__Fv.s" +void cAPIGph_Painter(void) { + g_cAPI_Interface[3](); } -#pragma pop /* 802632F8-80263328 0030+00 s=0 e=1 z=0 None .text cAPIGph_BeforeOfDraw__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cAPIGph_BeforeOfDraw() { - nofralloc -#include "asm/SSystem/SComponent/c_API_graphic/cAPIGph_BeforeOfDraw__Fv.s" +void cAPIGph_BeforeOfDraw(void) { + g_cAPI_Interface[1](); } -#pragma pop /* 80263328-80263358 0030+00 s=0 e=1 z=0 None .text cAPIGph_AfterOfDraw__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cAPIGph_AfterOfDraw() { - nofralloc -#include "asm/SSystem/SComponent/c_API_graphic/cAPIGph_AfterOfDraw__Fv.s" +void cAPIGph_AfterOfDraw(void) { + g_cAPI_Interface[2](); } -#pragma pop diff --git a/libs/SSystem/SComponent/c_m3d_g_cyl.cpp b/libs/SSystem/SComponent/c_m3d_g_cyl.cpp index 2ef35fd553e..1899b4c90b5 100644 --- a/libs/SSystem/SComponent/c_m3d_g_cyl.cpp +++ b/libs/SSystem/SComponent/c_m3d_g_cyl.cpp @@ -3,7 +3,7 @@ // Translation Unit: c_m3d_g_cyl // -#include "SSystem/SComponent/c_m3d_g_cyl.h" +// #include "SSystem/SComponent/c_m3d_g_cyl.h" #include "dol2asm.h" #include "dolphin/types.h"