diff --git a/.vscode/settings.json b/.vscode/settings.json index 6387bd67..4cc6a08a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -27,6 +27,7 @@ "xtr1common": "cpp", "limits": "cpp", "utility": "cpp", - "initializer_list": "cpp" + "initializer_list": "cpp", + "new": "cpp" } } diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index b1f0165e..cbff745b 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -316,6 +316,12 @@ nw4r/db/db_directPrint.cpp: .sbss start:0x805765E8 end:0x805765EC .bss start:0x80636B80 end:0x80636BA4 +nw4r/lyt/lyt_common.cpp: + .text start:0x80492780 end:0x804932E0 + .sbss start:0x80576720 end:0x80576728 + .sdata2 start:0x8057F2E0 end:0x8057F2E8 + .bss start:0x80673AA8 end:0x80673AC8 + egg/core/eggArchive.cpp: .text start:0x80493510 end:0x80494254 .data start:0x8056E820 end:0x8056E830 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 48b7e544..33de0e69 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -22589,7 +22589,7 @@ fn_803CDAD0 = .text:0x803CDAD0; // type:function size:0xD0 fn_803CDBA0 = .text:0x803CDBA0; // type:function size:0x10 fn_803CDBB0 = .text:0x803CDBB0; // type:function size:0x8 MEMAllocFromAllocator = .text:0x803CDBC0; // type:function size:0x10 -fn_803CDBD0 = .text:0x803CDBD0; // type:function size:0x10 +MEMFreeToAllocator = .text:0x803CDBD0; // type:function size:0x10 fn_803CDBE0 = .text:0x803CDBE0; // type:function size:0x1C fn_803CDC00 = .text:0x803CDC00; // type:function size:0x18 fn_803CDC20 = .text:0x803CDC20; // type:function size:0x70 @@ -40878,12 +40878,12 @@ lbl_805766D8 = .sbss:0x805766D8; // type:object size:0x8 data:byte lbl_805766E0 = .sbss:0x805766E0; // type:object size:0x8 data:byte lbl_805766E8 = .sbss:0x805766E8; // type:object size:0x8 data:4byte lbl_805766F0 = .sbss:0x805766F0; // type:object size:0x8 data:4byte -lbl_805766F8 = .sbss:0x805766F8; // type:object size:0x8 data:4byte +mspAllocator__Q34nw4r3lyt6Layout = .sbss:0x805766F8; // type:object size:0x8 data:4byte lbl_80576700 = .sbss:0x80576700; // type:object size:0x8 data:4byte lbl_80576708 = .sbss:0x80576708; // type:object size:0x8 data:4byte lbl_80576710 = .sbss:0x80576710; // type:object size:0x8 data:4byte lbl_80576718 = .sbss:0x80576718; // type:object size:0x8 data:4byte -lbl_80576720 = .sbss:0x80576720; // type:object size:0x8 data:byte +@GUARD@SetSize__Q44nw4r3lyt6detail11TexCoordAryFUc@texCoords = .sbss:0x80576720; // type:object size:0x1 data:byte lbl_80576728 = .sbss:0x80576728; // type:object size:0x8 data:byte lbl_80576730 = .sbss:0x80576730; // type:object size:0x8 data:byte lbl_80576738 = .sbss:0x80576738; // type:object size:0x8 data:4byte @@ -49350,7 +49350,7 @@ lbl_80673A38 = .bss:0x80673A38; // type:object size:0xC lbl_80673A44 = .bss:0x80673A44; // type:object size:0x3C lbl_80673A80 = .bss:0x80673A80; // type:object size:0xC lbl_80673A8C = .bss:0x80673A8C; // type:object size:0x1C data:byte -lbl_80673AA8 = .bss:0x80673AA8; // type:object size:0x20 data:float +@LOCAL@SetSize__Q44nw4r3lyt6detail11TexCoordAryFUc@texCoords = .bss:0x80673AA8; // type:object size:0x20 scope:local data:float lbl_80673AC8 = .bss:0x80673AC8; // type:object size:0x10 lbl_80673AD8 = .bss:0x80673AD8; // type:object size:0x10 sHeapList__Q23EGG4Heap = .bss:0x80673AE8; // type:object size:0xC diff --git a/configure.py b/configure.py index 8b572602..21bb27b7 100644 --- a/configure.py +++ b/configure.py @@ -155,6 +155,7 @@ cflags_base = [ "-str reuse", "-enc SJIS", "-i include", + "-i include/MSL_C", f"-i build/{config.version}/include", f"-DVERSION={version_num}", ] @@ -347,6 +348,12 @@ config.libs = [ Object(Matching, "nw4r/ut/ut_TextWriterBase.cpp"), ], ), + nw4rLib( + "lyt", + [ + Object(Matching, "nw4r/lyt/lyt_common.cpp"), + ], + ), # EGG EGGLib( "core", diff --git a/include/nw4r/ef/ef_animcurve.h b/include/nw4r/ef/ef_animcurve.h index 3471172c..b5b4efca 100644 --- a/include/nw4r/ef/ef_animcurve.h +++ b/include/nw4r/ef/ef_animcurve.h @@ -1,13 +1,11 @@ #ifndef NW4R_EF_ANIMCURVE_H #define NW4R_EF_ANIMCURVE_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - UNKTYPE AnimCurveExecuteF32(u8 *, float *, u32, u16, u32); - } +namespace nw4r { +namespace ef { +UNKTYPE AnimCurveExecuteF32(u8 *, float *, u32, u16, u32); } +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/ef/ef_creationqueue.h b/include/nw4r/ef/ef_creationqueue.h index 9cccffc7..0a544783 100644 --- a/include/nw4r/ef/ef_creationqueue.h +++ b/include/nw4r/ef/ef_creationqueue.h @@ -1,46 +1,38 @@ #ifndef NW4R_EF_CREATIONQUEUE #define NW4R_EF_CREATIONQUEUE +#include "common.h" #include "ef_emitter.h" -#include "types_nw4r.h" -namespace nw4r -{ - namespace ef - { - enum CreationType - { - CreationType_Particle, - CreationType_Emitter - }; - - //sizeof(UNK_CREATIONQUEUE) = 0x14 - struct Creation - { - u8 mType; // at 0x0 - u16 SHORT_0x2; - EmitterInheritSetting mInheritSetting; // at 0x4 - Particle * mParticle; // at 0x8 - EmitterResource * mResource; // at 0xc - }; - - struct CreationQueue - { - CreationQueue(); - void AddParticleCreation(const EmitterInheritSetting *, Particle *, EmitterResource *, u16); - void AddEmitterCreation(const EmitterInheritSetting *, Particle *, EmitterResource *, u16); - - int mSize; - - Creation mCreations[0x400]; - - inline bool IsEmpty() - { - return mSize == 0; - } - - void Execute(); - }; - } -} -#endif \ No newline at end of file +namespace nw4r { +namespace ef { +enum CreationType { CreationType_Particle, CreationType_Emitter }; + +// sizeof(UNK_CREATIONQUEUE) = 0x14 +struct Creation { + u8 mType; // at 0x0 + u16 SHORT_0x2; + EmitterInheritSetting mInheritSetting; // at 0x4 + Particle *mParticle; // at 0x8 + EmitterResource *mResource; // at 0xc +}; + +struct CreationQueue { + CreationQueue(); + void AddParticleCreation(const EmitterInheritSetting *, Particle *, EmitterResource *, u16); + void AddEmitterCreation(const EmitterInheritSetting *, Particle *, EmitterResource *, u16); + + int mSize; + + Creation mCreations[0x400]; + + inline bool IsEmpty() { + return mSize == 0; + } + + void Execute(); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_drawbillboardstrategy.h b/include/nw4r/ef/ef_drawbillboardstrategy.h index 2bdf88cf..291f53e4 100644 --- a/include/nw4r/ef/ef_drawbillboardstrategy.h +++ b/include/nw4r/ef/ef_drawbillboardstrategy.h @@ -1,22 +1,19 @@ #ifndef NW4R_EF_DRAW_BILLBOARD_STRATEGY_H #define NW4R_EF_DRAW_BILLBOARD_STRATEGY_H -#include "types_nw4r.h" +#include "common.h" #include "ef_drawstrategyimpl.h" -namespace nw4r -{ - namespace ef - { - class DrawBillboardStrategy : public DrawStrategyImpl - { - public: - DrawBillboardStrategy(); - virtual ~DrawBillboardStrategy() {} // at 0x8 - virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 - - void Draw(const DrawInfo &, ParticleManager *); - }; - } -} +namespace nw4r { +namespace ef { +class DrawBillboardStrategy : public DrawStrategyImpl { +public: + DrawBillboardStrategy(); + virtual ~DrawBillboardStrategy() {} // at 0x8 + virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 -#endif \ No newline at end of file + void Draw(const DrawInfo &, ParticleManager *); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_drawdirectionalstrategy.h b/include/nw4r/ef/ef_drawdirectionalstrategy.h index 47abae96..a88630e9 100644 --- a/include/nw4r/ef/ef_drawdirectionalstrategy.h +++ b/include/nw4r/ef/ef_drawdirectionalstrategy.h @@ -1,22 +1,19 @@ #ifndef NW4R_EF_DRAW_DIRECTIONAL_STRATEGY_H #define NW4R_EF_DRAW_DIRECTIONAL_STRATEGY_H -#include "types_nw4r.h" +#include "common.h" #include "ef_drawstrategyimpl.h" -namespace nw4r -{ - namespace ef - { - class DrawDirectionalStrategy : public DrawStrategyImpl - { - public: - DrawDirectionalStrategy(); - virtual ~DrawDirectionalStrategy() {} // at 0x8 - virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 - - void Draw(const DrawInfo &, ParticleManager *); - }; - } -} +namespace nw4r { +namespace ef { +class DrawDirectionalStrategy : public DrawStrategyImpl { +public: + DrawDirectionalStrategy(); + virtual ~DrawDirectionalStrategy() {} // at 0x8 + virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 -#endif \ No newline at end of file + void Draw(const DrawInfo &, ParticleManager *); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_drawfreestrategy.h b/include/nw4r/ef/ef_drawfreestrategy.h index 42b156b0..6de764a9 100644 --- a/include/nw4r/ef/ef_drawfreestrategy.h +++ b/include/nw4r/ef/ef_drawfreestrategy.h @@ -1,21 +1,18 @@ #ifndef NW4R_EF_DRAW_FREE_STRATEGY_H #define NW4R_EF_DRAW_FREE_STRATEGY_H -#include "types_nw4r.h" +#include "common.h" #include "ef_drawstrategyimpl.h" -namespace nw4r -{ - namespace ef - { - class DrawFreeStrategy : public DrawStrategyImpl - { - public: - DrawFreeStrategy(); - virtual ~DrawFreeStrategy() {} // at 0x8 - - UNKTYPE Draw(const DrawInfo &, ParticleManager *); - }; - } -} +namespace nw4r { +namespace ef { +class DrawFreeStrategy : public DrawStrategyImpl { +public: + DrawFreeStrategy(); + virtual ~DrawFreeStrategy() {} // at 0x8 -#endif \ No newline at end of file + UNKTYPE Draw(const DrawInfo &, ParticleManager *); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_drawinfo.h b/include/nw4r/ef/ef_drawinfo.h index a156d1ab..4bbb83b3 100644 --- a/include/nw4r/ef/ef_drawinfo.h +++ b/include/nw4r/ef/ef_drawinfo.h @@ -1,16 +1,11 @@ #ifndef NW4R_EF_DRAWINFO #define NW4R_EF_DRAWINFO -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - struct DrawInfo - { - - }; - } -} +namespace nw4r { +namespace ef { +struct DrawInfo {}; +} // namespace ef +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/ef/ef_drawlinestrategy.h b/include/nw4r/ef/ef_drawlinestrategy.h index cdc87596..46a40d6b 100644 --- a/include/nw4r/ef/ef_drawlinestrategy.h +++ b/include/nw4r/ef/ef_drawlinestrategy.h @@ -1,21 +1,18 @@ #ifndef NW4R_EF_DRAW_LINE_STRATEGY_H #define NW4R_EF_DRAW_LINE_STRATEGY_H -#include "types_nw4r.h" +#include "common.h" #include "ef_drawstrategyimpl.h" -namespace nw4r -{ - namespace ef - { - class DrawLineStrategy : public DrawStrategyImpl - { - public: - DrawLineStrategy(); - virtual ~DrawLineStrategy() {} // at 0x8 - - UNKTYPE Draw(const DrawInfo &, ParticleManager *); - }; - } -} +namespace nw4r { +namespace ef { +class DrawLineStrategy : public DrawStrategyImpl { +public: + DrawLineStrategy(); + virtual ~DrawLineStrategy() {} // at 0x8 -#endif \ No newline at end of file + UNKTYPE Draw(const DrawInfo &, ParticleManager *); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_draworder.h b/include/nw4r/ef/ef_draworder.h index 53a568bd..b72c51bb 100644 --- a/include/nw4r/ef/ef_draworder.h +++ b/include/nw4r/ef/ef_draworder.h @@ -1,20 +1,17 @@ #ifndef NW4R_EF_DRAWORDER #define NW4R_EF_DRAWORDER -#include "types_nw4r.h" -#include "ef_particlemanager.h" +#include "common.h" #include "ef_draworderbase.h" +#include "ef_particlemanager.h" -namespace nw4r -{ - namespace ef - { - struct DrawOrder : DrawOrderBase - { - void Draw(Effect *, const DrawInfo &); - void Add(Effect *, ParticleManager *); - void Remove(Effect *, ParticleManager *); - }; - } -} +namespace nw4r { +namespace ef { +struct DrawOrder : DrawOrderBase { + void Draw(Effect *, const DrawInfo &); + void Add(Effect *, ParticleManager *); + void Remove(Effect *, ParticleManager *); +}; +} // namespace ef +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/ef/ef_drawpointstrategy.h b/include/nw4r/ef/ef_drawpointstrategy.h index ef4ca9d1..8b037377 100644 --- a/include/nw4r/ef/ef_drawpointstrategy.h +++ b/include/nw4r/ef/ef_drawpointstrategy.h @@ -1,22 +1,19 @@ #ifndef NW4R_EF_DRAW_POINT_STRATEGY_H #define NW4R_EF_DRAW_POINT_STRATEGY_H -#include "types_nw4r.h" +#include "common.h" #include "ef_drawstrategyimpl.h" -namespace nw4r -{ - namespace ef - { - class DrawPointStrategy : public DrawStrategyImpl - { - public: - DrawPointStrategy(); - virtual ~DrawPointStrategy() {} // at 0x8 - - void Draw(const DrawInfo&, ParticleManager *); - void InitGraphics(const DrawInfo&, ParticleManager *); - }; - } -} +namespace nw4r { +namespace ef { +class DrawPointStrategy : public DrawStrategyImpl { +public: + DrawPointStrategy(); + virtual ~DrawPointStrategy() {} // at 0x8 -#endif \ No newline at end of file + void Draw(const DrawInfo &, ParticleManager *); + void InitGraphics(const DrawInfo &, ParticleManager *); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_drawsmoothstripestrategy.h b/include/nw4r/ef/ef_drawsmoothstripestrategy.h index 3a172b5f..d76971c4 100644 --- a/include/nw4r/ef/ef_drawsmoothstripestrategy.h +++ b/include/nw4r/ef/ef_drawsmoothstripestrategy.h @@ -1,22 +1,19 @@ #ifndef NW4R_EF_DRAW_SMOOTH_STRIPE_STRATEGY_H #define NW4R_EF_DRAW_SMOOTH_STRIPE_STRATEGY_H -#include "types_nw4r.h" +#include "common.h" #include "ef_drawstrategyimpl.h" -namespace nw4r -{ - namespace ef - { - class DrawSmoothStripeStrategy : public DrawStrategyImpl - { - public: - DrawSmoothStripeStrategy(); - virtual ~DrawSmoothStripeStrategy() {} // at 0x8 - virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 - - UNKTYPE Draw(const DrawInfo &, ParticleManager *); - }; - } -} +namespace nw4r { +namespace ef { +class DrawSmoothStripeStrategy : public DrawStrategyImpl { +public: + DrawSmoothStripeStrategy(); + virtual ~DrawSmoothStripeStrategy() {} // at 0x8 + virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 -#endif \ No newline at end of file + UNKTYPE Draw(const DrawInfo &, ParticleManager *); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_drawstrategy.h b/include/nw4r/ef/ef_drawstrategy.h index e3ed01d7..34d3c38c 100644 --- a/include/nw4r/ef/ef_drawstrategy.h +++ b/include/nw4r/ef/ef_drawstrategy.h @@ -1,17 +1,14 @@ #ifndef NW4R_EF_DRAWSTRATEGY_H #define NW4R_EF_DRAWSTRATEGY_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - struct DrawStrategy - { - inline virtual ~DrawStrategy() {} - virtual UNKTYPE Draw(const DrawInfo &, ParticleManager *) = 0; - }; - } -} +namespace nw4r { +namespace ef { +struct DrawStrategy { + inline virtual ~DrawStrategy() {} + virtual UNKTYPE Draw(const DrawInfo &, ParticleManager *) = 0; +}; +} // namespace ef +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/ef/ef_drawstrategybuilder.h b/include/nw4r/ef/ef_drawstrategybuilder.h index d39e638d..f2de9d2e 100644 --- a/include/nw4r/ef/ef_drawstrategybuilder.h +++ b/include/nw4r/ef/ef_drawstrategybuilder.h @@ -1,27 +1,23 @@ #ifndef NW4R_EF_DRAWSTRATEGYBUILDER_H #define NW4R_EF_DRAWSTRATEGYBUILDER_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - enum DrawStrategyType - { - DrawStratType_Point, - DrawStratType_Line, - DrawStratType_Free, - DrawStratType_Billboard, - DrawStratType_Directional, - DrawStratType_Stripe, - DrawStratType_SmoothStripe - }; - - struct DrawStrategyBuilder - { - virtual DrawStrategy * Create(u32); - }; - } -} +namespace nw4r { +namespace ef { +enum DrawStrategyType { + DrawStratType_Point, + DrawStratType_Line, + DrawStratType_Free, + DrawStratType_Billboard, + DrawStratType_Directional, + DrawStratType_Stripe, + DrawStratType_SmoothStripe +}; -#endif \ No newline at end of file +struct DrawStrategyBuilder { + virtual DrawStrategy *Create(u32); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_drawstrategyimpl.h b/include/nw4r/ef/ef_drawstrategyimpl.h index c236a044..2a88e87b 100644 --- a/include/nw4r/ef/ef_drawstrategyimpl.h +++ b/include/nw4r/ef/ef_drawstrategyimpl.h @@ -1,44 +1,40 @@ #ifndef NW4R_EF_DRAW_STRATEGY_IMPL_H #define NW4R_EF_DRAW_STRATEGY_IMPL_H -#include "types_nw4r.h" +#include "common.h" #include "ef_drawstrategy.h" #include "math_types.h" -namespace nw4r -{ - namespace ef - { - class DrawStrategyImpl : public DrawStrategy - { - public: - struct PrevTexture - { - UNKWORD WORD_0x0; - f32 FLOAT_0x4; - f32 FLOAT_0x8; - f32 FLOAT_0xC; - f32 FLOAT_0x10; - UNKWORD WORD_0x14; - UNKWORD WORD_0x18; - math::VEC2 VEC2_0x1C; - f32 FLOAT_0x24; - math::VEC2 VEC2_0x28; - }; +namespace nw4r { +namespace ef { +class DrawStrategyImpl : public DrawStrategy { +public: + struct PrevTexture { + UNKWORD WORD_0x0; + f32 FLOAT_0x4; + f32 FLOAT_0x8; + f32 FLOAT_0xC; + f32 FLOAT_0x10; + UNKWORD WORD_0x14; + UNKWORD WORD_0x18; + math::VEC2 VEC2_0x1C; + f32 FLOAT_0x24; + math::VEC2 VEC2_0x28; + }; - public: - DrawStrategyImpl(); - virtual UNKTYPE GetGetFirstDrawParticleFunc(int); - virtual UNKTYPE GetGetNextDrawParticleFunc(int); +public: + DrawStrategyImpl(); + virtual UNKTYPE GetGetFirstDrawParticleFunc(int); + virtual UNKTYPE GetGetNextDrawParticleFunc(int); - void InitTexture(const EmitterDrawSetting &); - void InitTev(const EmitterDrawSetting &, const DrawInfo &); - void InitColor(ParticleManager *, const EmitterDrawSetting &, const DrawInfo &); + void InitTexture(const EmitterDrawSetting &); + void InitTev(const EmitterDrawSetting &, const DrawInfo &); + void InitColor(ParticleManager *, const EmitterDrawSetting &, const DrawInfo &); - private: - PrevTexture mPrevTextures[3]; // at 0x4 - char UNK_0x94[0xBC - 0x94]; - }; - } -} +private: + PrevTexture mPrevTextures[3]; // at 0x4 + char UNK_0x94[0xBC - 0x94]; +}; +} // namespace ef +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/ef/ef_drawstripestrategy.h b/include/nw4r/ef/ef_drawstripestrategy.h index ccdbc04f..2edf9238 100644 --- a/include/nw4r/ef/ef_drawstripestrategy.h +++ b/include/nw4r/ef/ef_drawstripestrategy.h @@ -1,22 +1,19 @@ #ifndef NW4R_EF_DRAW_STRIPE_STRATEGY_H #define NW4R_EF_DRAW_STRIPE_STRATEGY_H -#include "types_nw4r.h" +#include "common.h" #include "ef_drawstrategyimpl.h" -namespace nw4r -{ - namespace ef - { - class DrawStripeStrategy : public DrawStrategyImpl - { - public: - DrawStripeStrategy(); - virtual ~DrawStripeStrategy() {} // at 0x8 - virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 - - UNKTYPE Draw(const DrawInfo &, ParticleManager *); - }; - } -} +namespace nw4r { +namespace ef { +class DrawStripeStrategy : public DrawStrategyImpl { +public: + DrawStripeStrategy(); + virtual ~DrawStripeStrategy() {} // at 0x8 + virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 -#endif \ No newline at end of file + UNKTYPE Draw(const DrawInfo &, ParticleManager *); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_effect.h b/include/nw4r/ef/ef_effect.h index 24050fc8..bed4ac26 100644 --- a/include/nw4r/ef/ef_effect.h +++ b/include/nw4r/ef/ef_effect.h @@ -1,59 +1,56 @@ #ifndef NW4R_EF_EFFECT #define NW4R_EF_EFFECT -#include "types_nw4r.h" -#include "math_types.h" -#include "ef_ref.h" -#include "ut_list.h" +#include "common.h" #include "ef_list.h" +#include "ef_ref.h" #include "ef_util.h" +#include "math_types.h" +#include "ut_list.h" -namespace nw4r -{ - namespace ef - { - struct Effect : ReferencedObject - { - EffectSystem * mSystem; // at 0x20 - ActivityList mEmitters; // at 0x24 - u32 INDEX_0x40; - - void (* mEmissionPrologue)(Emitter *, ParticleManager *, int *, u32 *, float *, u16 *, float *, math::MTX34 *); // at 0x44 - - UNKWORD WORD_0x48; - UNKWORD WORD_0x4C; - u32 mFlags; // at 0x50 - math::MTX34 mRootMtx; // at 0x54 - math::VEC3 VEC_0x84; - ut::List UTLIST_0x90; - DrawOrder * mDrawOrder; // at 0x9c - - Effect(); - ~Effect(); - - virtual bool Initialize(EffectSystem *, EmitterResource *, u16); - virtual Emitter * CreateEmitter(ResEmitter, u8, u16); - virtual void Calc(bool); - virtual void Draw(const DrawInfo &); - - bool SendClosing(); - UNKTYPE DestroyFunc(); - bool Closing(Emitter *); - Emitter * CreateEmitter(EmitterResource *, u8, u16); - bool RetireEmitter(Emitter *); - u16 RetireEmitterAll(); - u16 RetireParticleAll(); - u16 GetNumEmitter() const; - Emitter * GetEmitter(u16); - u16 ForeachParticleManager(Action, u32, bool); - u16 ForeachEmitterFrom(Action, u32, bool, Emitter *); - UNKTYPE SetRootMtx(const math::MTX34 &); - - inline bool GetFlagDisableDraw() - { - return mFlags & 2; - } - }; - } -} +namespace nw4r { +namespace ef { +struct Effect : ReferencedObject { + EffectSystem *mSystem; // at 0x20 + ActivityList mEmitters; // at 0x24 + u32 INDEX_0x40; -#endif \ No newline at end of file + void (*mEmissionPrologue)(Emitter *, ParticleManager *, int *, u32 *, float *, u16 *, float *, + math::MTX34 *); // at 0x44 + + UNKWORD WORD_0x48; + UNKWORD WORD_0x4C; + u32 mFlags; // at 0x50 + math::MTX34 mRootMtx; // at 0x54 + math::VEC3 VEC_0x84; + ut::List UTLIST_0x90; + DrawOrder *mDrawOrder; // at 0x9c + + Effect(); + ~Effect(); + + virtual bool Initialize(EffectSystem *, EmitterResource *, u16); + virtual Emitter *CreateEmitter(ResEmitter, u8, u16); + virtual void Calc(bool); + virtual void Draw(const DrawInfo &); + + bool SendClosing(); + UNKTYPE DestroyFunc(); + bool Closing(Emitter *); + Emitter *CreateEmitter(EmitterResource *, u8, u16); + bool RetireEmitter(Emitter *); + u16 RetireEmitterAll(); + u16 RetireParticleAll(); + u16 GetNumEmitter() const; + Emitter *GetEmitter(u16); + u16 ForeachParticleManager(Action, u32, bool); + u16 ForeachEmitterFrom(Action, u32, bool, Emitter *); + UNKTYPE SetRootMtx(const math::MTX34 &); + + inline bool GetFlagDisableDraw() { + return mFlags & 2; + } +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_effectsystem.h b/include/nw4r/ef/ef_effectsystem.h index 93ccccf7..68177a21 100644 --- a/include/nw4r/ef/ef_effectsystem.h +++ b/include/nw4r/ef/ef_effectsystem.h @@ -1,57 +1,53 @@ #ifndef NW4R_EF_EFFECTSYSTEM #define NW4R_EF_EFFECTSYSTEM -#include "types_nw4r.h" +#include "common.h" #include "ef_creationqueue.h" -#include "ef_ref.h" -#include "ef_rand.h" #include "ef_list.h" +#include "ef_rand.h" +#include "ef_ref.h" -namespace nw4r -{ - namespace ef - { - struct EffectSystem - { - static bool mDisplayVersion; - - static EffectSystem instance; - - MemoryManager * mMemoryManager; // at 0x0 - DrawOrder * mDrawOrder; // at 0x4 - DrawStrategyBuilder * mDrawStrategyBuilder; // at 0x8 - EmitFormBuilder * mEmitFormBuilder; // at 0xc - CreationQueue mCreationQueue; // at 0x10 - u32 mNumGroup; - ActivityList * ARR_0x5018; - Random mRandom; // at 0x501C - math::VEC3 VEC_0x5020; - math::MTX34 MTX_0x502C; - float FLOAT_0x505C; - float FLOAT_0x5060; - char BYTE_0x5064; - - inline MemoryManager * GetMemoryManager() const - { - return mMemoryManager; - } - - EffectSystem(); - ~EffectSystem(); - - static EffectSystem * GetInstance(); - - bool Initialize(u32); - bool Closing(Effect *); - Effect * CreateEffect(const char *, u32, u16); - bool RetireEffect(Effect *); - u16 RetireEffectAll(u32); - u16 RetireEmitterAll(u32); - u16 RetireParticleAll(u32); - - void Calc(u32, bool); - void Draw(const DrawInfo &, u32); - }; - } -} +namespace nw4r { +namespace ef { +struct EffectSystem { + static bool mDisplayVersion; -#endif \ No newline at end of file + static EffectSystem instance; + + MemoryManager *mMemoryManager; // at 0x0 + DrawOrder *mDrawOrder; // at 0x4 + DrawStrategyBuilder *mDrawStrategyBuilder; // at 0x8 + EmitFormBuilder *mEmitFormBuilder; // at 0xc + CreationQueue mCreationQueue; // at 0x10 + u32 mNumGroup; + ActivityList *ARR_0x5018; + Random mRandom; // at 0x501C + math::VEC3 VEC_0x5020; + math::MTX34 MTX_0x502C; + float FLOAT_0x505C; + float FLOAT_0x5060; + char BYTE_0x5064; + + inline MemoryManager *GetMemoryManager() const { + return mMemoryManager; + } + + EffectSystem(); + ~EffectSystem(); + + static EffectSystem *GetInstance(); + + bool Initialize(u32); + bool Closing(Effect *); + Effect *CreateEffect(const char *, u32, u16); + bool RetireEffect(Effect *); + u16 RetireEffectAll(u32); + u16 RetireEmitterAll(u32); + u16 RetireParticleAll(u32); + + void Calc(u32, bool); + void Draw(const DrawInfo &, u32); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_emform.h b/include/nw4r/ef/ef_emform.h index 97f8adf2..c0d00924 100644 --- a/include/nw4r/ef/ef_emform.h +++ b/include/nw4r/ef/ef_emform.h @@ -1,27 +1,23 @@ #ifndef NW4R_EF_EMFORM_H #define NW4R_EF_EMFORM_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - enum EmitFormType - { - EmitForm_Disc, - EmitForm_Line, - EmitForm_Cube = 5, - EmitForm_Cylinder = 7, - EmitForm_Sphere, - EmitForm_Point, - EmitForm_Torus - }; - - struct EmitFormBuilder - { - virtual EmitterForm * Create(EmitFormType); - }; - } -} +namespace nw4r { +namespace ef { +enum EmitFormType { + EmitForm_Disc, + EmitForm_Line, + EmitForm_Cube = 5, + EmitForm_Cylinder = 7, + EmitForm_Sphere, + EmitForm_Point, + EmitForm_Torus +}; -#endif \ No newline at end of file +struct EmitFormBuilder { + virtual EmitterForm *Create(EmitFormType); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_emitter.h b/include/nw4r/ef/ef_emitter.h index b19ae39a..386eba51 100644 --- a/include/nw4r/ef/ef_emitter.h +++ b/include/nw4r/ef/ef_emitter.h @@ -1,259 +1,247 @@ #ifndef NW4R_EF_EMITTER #define NW4R_EF_EMITTER -#include -#include "types_nw4r.h" -#include "ef_ref.h" -#include "ut_list.h" +#include "ef_animcurve.h" #include "ef_list.h" #include "ef_rand.h" +#include "ef_ref.h" #include "ef_util.h" -#include "ef_animcurve.h" +#include "ut_list.h" +#include #include "common.h" -namespace nw4r -{ - namespace ef - { - struct ResEmitter - { - EmitterResource * mPtr; - - inline EmitterResource * ptr() { return mPtr; } - }; - - struct EmitterInheritSetting - { - s16 SHORT_0x0; - u8 BYTE_0x2; - u8 BYTE_0x3; - u8 BYTE_0x4; - u8 BYTE_0x5; - u8 BYTE_0x6; - u8 BYTE_0x7; - }; - struct EmitterDesc - { - UNKWORD FLAGS_0x0; // at 0x0/0x8 - UNKWORD EMFORMTYPE_0x4; // at 0x4/0xc - u16 SHORT_0x8; // at 0x8/0x10 - u16 SHORT_0xA; // at 0xa/0x12 - s8 SBYTE_0xC; // at 0xc/0x14 - s8 SBYTE_0xD; // at 0xd/0x15 - s8 SBYTE_0xE; // at 0xe/0x16 - s8 SBYTE_0xF; // at 0xf/0x17 - float FLOAT_0x10; // at 0x10/0x18 - u16 SHORT_0x14; // at 0x14/0x1c - u16 SHORT_0x16; // at 0x16/0x1e - u16 SHORT_0x18; // at 0x18/0x20 - s8 BYTE_0x1A; // at 0x1a/0x22 - s8 BYTE_0x1B; // at 0x1b/0x23 - float FLOAT_0x1C; - float FLOAT_0x20; - float FLOAT_0x24; - float FLOAT_0x28; - float FLOAT_0x2C; - float FLOAT_0x30; - u16 SHORT_0x34; - u8 BYTE_0x36; - u8 BYTE_0x37; - float FLOAT_0x38; - float FLOAT_0x3C; - float FLOAT_0x40; - float FLOAT_0x44; - float FLOAT_0x48; - float FLOAT_0x4C; - float FLOAT_0x50; - float FLOAT_0x54; - float FLOAT_0x58; - float FLOAT_0x5C; - - float FLOAT_0x60; - float FLOAT_0x64; - float FLOAT_0x68; - float FLOAT_0x6C; - float FLOAT_0x70; - float FLOAT_0x74; - - float FLOAT_0x78; - float FLOAT_0x7C; - float FLOAT_0x80; - - u8 BYTE_0x84; // at 0x84/0x8c - u8 BYTE_0x85; // at 0x85/0x8d - u8 BYTE_0x86; // at 0x86/0x8e - UNKWORD WORD_0x88; - }; - - struct EmitTrack - { - u8 BYTE_0x0; - u8 BYTE_0x1; - u16 SHORT_0x2; - - u8 BYTE_0x4; - }; - - struct EmitterResource - { - char UNK_0x0[0x4]; - u32 OFFSET_0x4; - - EmitterDesc STRUCT_0x8; - - inline UNKTYPE * SkipEmitterDesc() - { - return (char *)&STRUCT_0x8 + OFFSET_0x4; - } - - inline UNKTYPE * SkipParticleParameterDesc() - { - char * particleDesc = (char *)SkipEmitterDesc(); - - return particleDesc + *(int *)particleDesc; - } - - inline u16 NumEmitInitTrack() - { - u16 * ptr = (u16 *)SkipParticleParameterDesc(); - - return ptr[(4**(ptr += 2))+3]; - } - - inline u16 NumEmitTrack() - { - u16 * ptr = (u16 *)SkipParticleParameterDesc(); - - return ptr[(4**(ptr += 2))+2]; - } - - inline EmitTrack * GetEmitTrack(u16 i) - { - u16 * ptr = (u16 *)SkipParticleParameterDesc(); - - return reinterpret_cast(ptr)[(2**(ptr += 1))+1+i]; - } - }; - - struct Emitter : ReferencedObject - { - virtual bool Initialize(Effect *, EmitterResource *, u8); // at 0x10 - virtual Emitter * CreateEmitter(EmitterResource *, EmitterInheritSetting *, Particle *, u16); // at 0x14 - virtual void CalcEmitter(); // at 0x18 - virtual void CalcParticle(); // at 0x1c - virtual void CalcEmission(); // at 0x20 - virtual void CalcBillboard(); // at 0x24 - - u32 mFlags; - UNKWORD WORD_0x24; - - //char UNK_0x28[0x8C]; - float FLOAT_0x28; - float FLOAT_0x2C; - short SHORT_0x30; - short SHORT_0x32; - float FLOAT_0x34; - float FLOAT_0x38; - short SHORT_0x3C; - float FLOAT_0x40; - float FLOAT_0x44; - float FLOAT_0x48; - float FLOAT_0x4C; - float FLOAT_0x50; - float FLOAT_0x54; - float FLOAT_0x58; - float FLOAT_0x5C; - float FLOAT_0x60; - - u8 BYTE_0x64; - s8 BYTE_0x65; - u8 BYTE_0x66; - s8 BYTE_0x67; - - float FLOAT_0x68; - float FLOAT_0x6C; - float FLOAT_0x70; - float FLOAT_0x74; - float FLOAT_0x78; - float FLOAT_0x7C; - float FLOAT_0x80; - float FLOAT_0x84; - float FLOAT_0x88; - float FLOAT_0x8C; - /* - float FLOAT_0x90; - float FLOAT_0x94; - float FLOAT_0x98; - */ - math::VEC3 VEC_0x90; - /* - float FLOAT_0x9C; - float FLOAT_0xA0; - float FLOAT_0xA4; - */ - math::VEC3 VEC_0x9C; - /* - float FLOAT_0xA8; - float FLOAT_0xAC; - float FLOAT_0xB0; - */ - math::VEC3 VEC_0xA8; - - UNKWORD WORD_0xB4; - EmitterResource * mResource; // at 0xb8 - Effect * mEffect; // at 0xbc - ActivityList mManagers; // at 0xc0 - char UNK_0xDA[0x2]; - u8 BYTE_0xDC; - u16 SHORT_0xDE; - u16 SHORT_0xE0; - UNKWORD WORD_0xE4; - u16 SHORT_0xE8; - u16 SHORT_0xEA; - Random mRandom; // at 0xec - EmitterForm * mForm; // at 0xf0 - Emitter * mParent; // at 0xf4 - Particle * REF_0xF8; // at 0xf8 - - EmitterInheritSetting mInheritSettings; // at 0xfc - - bool mMtxDirtyFlag; // at 0x104 - - math::MTX34 mGlobalMtx; // at 0x108 - - Emitter(); - ~Emitter(); - - u16 RetireParticleAll(); - bool SendClosing(); - void DestroyFunc(); - bool Closing(ParticleManager *); - bool RetireParticleManager(ParticleManager *); - u16 RetireParticleManagerAll(); - bool InitializeDatas(EmitterResource *, Effect *); - - ParticleManager * FindParticleManager(EmitterResource *, bool, bool, s8, u8); - UNKTYPE CreateEmitterTmp(EmitterResource *, EmitterInheritSetting *, Particle *, u16); - - float GetLODratio(math::VEC3 &, math::VEC3 &, float, float, float, float); - - u16 ForeachParticleManager(Action, u32, bool, bool); - - UNKTYPE Emission(ParticleManager *, const math::MTX34 *); - - math::MTX34 * CalcGlobalMtx(math::MTX34 *); - UNKTYPE SetMtxDirty(); - - static math::MTX34 * RestructMatrix(math::MTX34 *, math::MTX34 *, bool, bool, s8); - - u16 GetNumParticleManager() const; - ParticleManager * GetParticleManager(u16); - - inline bool GetFlagDisableCalc() const - { - return mFlags & 0x200; - } - }; - } -} +namespace nw4r { +namespace ef { +struct ResEmitter { + EmitterResource *mPtr; -#endif \ No newline at end of file + inline EmitterResource *ptr() { + return mPtr; + } +}; + +struct EmitterInheritSetting { + s16 SHORT_0x0; + u8 BYTE_0x2; + u8 BYTE_0x3; + u8 BYTE_0x4; + u8 BYTE_0x5; + u8 BYTE_0x6; + u8 BYTE_0x7; +}; + +struct EmitterDesc { + UNKWORD FLAGS_0x0; // at 0x0/0x8 + UNKWORD EMFORMTYPE_0x4; // at 0x4/0xc + u16 SHORT_0x8; // at 0x8/0x10 + u16 SHORT_0xA; // at 0xa/0x12 + s8 SBYTE_0xC; // at 0xc/0x14 + s8 SBYTE_0xD; // at 0xd/0x15 + s8 SBYTE_0xE; // at 0xe/0x16 + s8 SBYTE_0xF; // at 0xf/0x17 + float FLOAT_0x10; // at 0x10/0x18 + u16 SHORT_0x14; // at 0x14/0x1c + u16 SHORT_0x16; // at 0x16/0x1e + u16 SHORT_0x18; // at 0x18/0x20 + s8 BYTE_0x1A; // at 0x1a/0x22 + s8 BYTE_0x1B; // at 0x1b/0x23 + float FLOAT_0x1C; + float FLOAT_0x20; + float FLOAT_0x24; + float FLOAT_0x28; + float FLOAT_0x2C; + float FLOAT_0x30; + u16 SHORT_0x34; + u8 BYTE_0x36; + u8 BYTE_0x37; + float FLOAT_0x38; + float FLOAT_0x3C; + float FLOAT_0x40; + float FLOAT_0x44; + float FLOAT_0x48; + float FLOAT_0x4C; + float FLOAT_0x50; + float FLOAT_0x54; + float FLOAT_0x58; + float FLOAT_0x5C; + + float FLOAT_0x60; + float FLOAT_0x64; + float FLOAT_0x68; + float FLOAT_0x6C; + float FLOAT_0x70; + float FLOAT_0x74; + + float FLOAT_0x78; + float FLOAT_0x7C; + float FLOAT_0x80; + + u8 BYTE_0x84; // at 0x84/0x8c + u8 BYTE_0x85; // at 0x85/0x8d + u8 BYTE_0x86; // at 0x86/0x8e + UNKWORD WORD_0x88; +}; + +struct EmitTrack { + u8 BYTE_0x0; + u8 BYTE_0x1; + u16 SHORT_0x2; + + u8 BYTE_0x4; +}; + +struct EmitterResource { + char UNK_0x0[0x4]; + u32 OFFSET_0x4; + + EmitterDesc STRUCT_0x8; + + inline UNKTYPE *SkipEmitterDesc() { + return (char *)&STRUCT_0x8 + OFFSET_0x4; + } + + inline UNKTYPE *SkipParticleParameterDesc() { + char *particleDesc = (char *)SkipEmitterDesc(); + + return particleDesc + *(int *)particleDesc; + } + + inline u16 NumEmitInitTrack() { + u16 *ptr = (u16 *)SkipParticleParameterDesc(); + + return ptr[(4 * *(ptr += 2)) + 3]; + } + + inline u16 NumEmitTrack() { + u16 *ptr = (u16 *)SkipParticleParameterDesc(); + + return ptr[(4 * *(ptr += 2)) + 2]; + } + + inline EmitTrack *GetEmitTrack(u16 i) { + u16 *ptr = (u16 *)SkipParticleParameterDesc(); + + return reinterpret_cast(ptr)[(2 * *(ptr += 1)) + 1 + i]; + } +}; + +struct Emitter : ReferencedObject { + virtual bool Initialize(Effect *, EmitterResource *, u8); // at 0x10 + virtual Emitter *CreateEmitter(EmitterResource *, EmitterInheritSetting *, Particle *, u16); // at 0x14 + virtual void CalcEmitter(); // at 0x18 + virtual void CalcParticle(); // at 0x1c + virtual void CalcEmission(); // at 0x20 + virtual void CalcBillboard(); // at 0x24 + + u32 mFlags; + UNKWORD WORD_0x24; + + // char UNK_0x28[0x8C]; + float FLOAT_0x28; + float FLOAT_0x2C; + short SHORT_0x30; + short SHORT_0x32; + float FLOAT_0x34; + float FLOAT_0x38; + short SHORT_0x3C; + float FLOAT_0x40; + float FLOAT_0x44; + float FLOAT_0x48; + float FLOAT_0x4C; + float FLOAT_0x50; + float FLOAT_0x54; + float FLOAT_0x58; + float FLOAT_0x5C; + float FLOAT_0x60; + + u8 BYTE_0x64; + s8 BYTE_0x65; + u8 BYTE_0x66; + s8 BYTE_0x67; + + float FLOAT_0x68; + float FLOAT_0x6C; + float FLOAT_0x70; + float FLOAT_0x74; + float FLOAT_0x78; + float FLOAT_0x7C; + float FLOAT_0x80; + float FLOAT_0x84; + float FLOAT_0x88; + float FLOAT_0x8C; + /* + float FLOAT_0x90; + float FLOAT_0x94; + float FLOAT_0x98; + */ + math::VEC3 VEC_0x90; + /* + float FLOAT_0x9C; + float FLOAT_0xA0; + float FLOAT_0xA4; + */ + math::VEC3 VEC_0x9C; + /* + float FLOAT_0xA8; + float FLOAT_0xAC; + float FLOAT_0xB0; + */ + math::VEC3 VEC_0xA8; + + UNKWORD WORD_0xB4; + EmitterResource *mResource; // at 0xb8 + Effect *mEffect; // at 0xbc + ActivityList mManagers; // at 0xc0 + char UNK_0xDA[0x2]; + u8 BYTE_0xDC; + u16 SHORT_0xDE; + u16 SHORT_0xE0; + UNKWORD WORD_0xE4; + u16 SHORT_0xE8; + u16 SHORT_0xEA; + Random mRandom; // at 0xec + EmitterForm *mForm; // at 0xf0 + Emitter *mParent; // at 0xf4 + Particle *REF_0xF8; // at 0xf8 + + EmitterInheritSetting mInheritSettings; // at 0xfc + + bool mMtxDirtyFlag; // at 0x104 + + math::MTX34 mGlobalMtx; // at 0x108 + + Emitter(); + ~Emitter(); + + u16 RetireParticleAll(); + bool SendClosing(); + void DestroyFunc(); + bool Closing(ParticleManager *); + bool RetireParticleManager(ParticleManager *); + u16 RetireParticleManagerAll(); + bool InitializeDatas(EmitterResource *, Effect *); + + ParticleManager *FindParticleManager(EmitterResource *, bool, bool, s8, u8); + UNKTYPE CreateEmitterTmp(EmitterResource *, EmitterInheritSetting *, Particle *, u16); + + float GetLODratio(math::VEC3 &, math::VEC3 &, float, float, float, float); + + u16 ForeachParticleManager(Action, u32, bool, bool); + + UNKTYPE Emission(ParticleManager *, const math::MTX34 *); + + math::MTX34 *CalcGlobalMtx(math::MTX34 *); + UNKTYPE SetMtxDirty(); + + static math::MTX34 *RestructMatrix(math::MTX34 *, math::MTX34 *, bool, bool, s8); + + u16 GetNumParticleManager() const; + ParticleManager *GetParticleManager(u16); + + inline bool GetFlagDisableCalc() const { + return mFlags & 0x200; + } +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_emitterform.h b/include/nw4r/ef/ef_emitterform.h index 28de21fb..67ba51e0 100644 --- a/include/nw4r/ef/ef_emitterform.h +++ b/include/nw4r/ef/ef_emitterform.h @@ -1,19 +1,17 @@ #ifndef NW4R_EF_EMITTERFORM_H #define NW4R_EF_EMITTERFORM_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - struct EmitterForm - { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *) = 0; - - UNKTYPE CalcVelocity(math::VEC3 *, Emitter *, const math::VEC3 &, const math::VEC3 &, const math::VEC3 &, const math::VEC3 &) const; - u16 CalcLife(u16, float, Emitter *); - }; - } -} +namespace nw4r { +namespace ef { +struct EmitterForm { + virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *) = 0; -#endif \ No newline at end of file + UNKTYPE CalcVelocity(math::VEC3 *, Emitter *, const math::VEC3 &, const math::VEC3 &, const math::VEC3 &, + const math::VEC3 &) const; + u16 CalcLife(u16, float, Emitter *); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_handle.h b/include/nw4r/ef/ef_handle.h index 4e0c4f6e..34b4e1d2 100644 --- a/include/nw4r/ef/ef_handle.h +++ b/include/nw4r/ef/ef_handle.h @@ -1,29 +1,25 @@ #ifndef NW4R_EF_HANDLE_H #define NW4R_EF_HANDLE_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - struct LinkedObject - { - char UNK_0x0[8]; - LinkedObject * PTR_0x8; - }; - - struct HandleBase - { - LinkedObject * PTR_0x0; - LinkedObject * mPtr; - - HandleBase(); - HandleBase & operator=(const HandleBase &); - HandleBase & operator=(LinkedObject *); - bool IsValid() const; - LinkedObject * GetPtr() const; - }; - } -} +namespace nw4r { +namespace ef { +struct LinkedObject { + char UNK_0x0[8]; + LinkedObject *PTR_0x8; +}; -#endif \ No newline at end of file +struct HandleBase { + LinkedObject *PTR_0x0; + LinkedObject *mPtr; + + HandleBase(); + HandleBase &operator=(const HandleBase &); + HandleBase &operator=(LinkedObject *); + bool IsValid() const; + LinkedObject *GetPtr() const; +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_list.h b/include/nw4r/ef/ef_list.h index d4ea3468..09efa06e 100644 --- a/include/nw4r/ef/ef_list.h +++ b/include/nw4r/ef/ef_list.h @@ -1,67 +1,57 @@ #ifndef NW4R_EF_LIST #define NW4R_EF_LIST -#include "types_nw4r.h" +#include "common.h" #include "ut_list.h" -namespace nw4r -{ - namespace ef - { - //sizeof(ActivityList) = 0x1C - struct ActivityList - { - ut::List mActive; - ut::List mClosing; - u16 mNumActive; - - inline void SetOffset(u16 offset) - { - ut::List_Init(&mActive, offset); - ut::List_Init(&mClosing, offset); - mNumActive = 0; - } - - inline ActivityList(u16 offset) - { - SetOffset(offset); - } - - inline ActivityList() - { - SetOffset(0); - } - - inline void Initialize() - { - mActive.first = NULL; - mActive.size = 0; - mActive.last = NULL; - - mClosing.first = NULL; - mClosing.size = 0; - mClosing.last = NULL; - - mNumActive = 0; - } - - inline void ToActive(void * pNode) - { - ut::List_Append(&mActive, pNode); - mNumActive++; - } - - inline void ToClosing(void * pNode) - { - ut::List_Remove(&mActive, pNode); - ut::List_Append(&mClosing, pNode); - } - - inline void ToWait(void * pNode) - { - mNumActive--; - } - }; - } -} +namespace nw4r { +namespace ef { +// sizeof(ActivityList) = 0x1C +struct ActivityList { + ut::List mActive; + ut::List mClosing; + u16 mNumActive; + + inline void SetOffset(u16 offset) { + ut::List_Init(&mActive, offset); + ut::List_Init(&mClosing, offset); + mNumActive = 0; + } + + inline ActivityList(u16 offset) { + SetOffset(offset); + } + + inline ActivityList() { + SetOffset(0); + } + + inline void Initialize() { + mActive.first = NULL; + mActive.size = 0; + mActive.last = NULL; + + mClosing.first = NULL; + mClosing.size = 0; + mClosing.last = NULL; + + mNumActive = 0; + } + + inline void ToActive(void *pNode) { + ut::List_Append(&mActive, pNode); + mNumActive++; + } + + inline void ToClosing(void *pNode) { + ut::List_Remove(&mActive, pNode); + ut::List_Append(&mClosing, pNode); + } + + inline void ToWait(void *pNode) { + mNumActive--; + } +}; +} // namespace ef +} // namespace nw4r #endif diff --git a/include/nw4r/ef/ef_memorymanagerbase.h b/include/nw4r/ef/ef_memorymanagerbase.h index bf722d83..61c67bbe 100644 --- a/include/nw4r/ef/ef_memorymanagerbase.h +++ b/include/nw4r/ef/ef_memorymanagerbase.h @@ -1,43 +1,40 @@ #ifndef NW4R_EF_MEMORYMANAGERBASE #define NW4R_EF_MEMORYMANAGERBASE -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - struct MemoryManagerBase - { - virtual ~MemoryManagerBase(); // at 0x8 - virtual UNKTYPE GarbageCollection() = 0; // at 0xc - - virtual Effect * AllocEffect() = 0; // at 0x10 - virtual UNKTYPE FreeEffect(void *) = 0; // at 0x14 - virtual UNKWORD GetNumAllocEffect() const = 0; // at 0x18 - virtual UNKWORD GetNumActiveEffect() const = 0; // at 0x1c - virtual UNKWORD GetNumFreeEffect() const = 0; // at 0x20 - - virtual Emitter * AllocEmitter() = 0; // at 0x24 - virtual UNKTYPE FreeEmitter(void *) = 0; // at 0x28 - virtual UNKWORD GetNumAllocEmitter() const = 0; // at 0x2c - virtual UNKWORD GetNumActiveEmitter() const = 0; // at 0x30 - virtual UNKWORD GetNumFreeEmitter() const = 0; // at 0x34 - - virtual ParticleManager * AllocParticleManager() = 0; // at 0x38 - virtual UNKTYPE FreeParticleManager(void *) = 0; // at 0x3c - virtual UNKWORD GetNumAllocParticleManager() const = 0; // at 0x40 - virtual UNKWORD GetNumActiveParticleManager() const = 0; // at 0x44 - virtual UNKWORD GetNumFreeParticleManager() const = 0; // at 0x48 - - virtual Particle * AllocParticle() = 0; // at 0x4c - virtual UNKTYPE FreeParticle(void *) = 0; // at 0x50 - virtual UNKWORD GetNumAllocParticle() const = 0; // at 0x54 - virtual UNKWORD GetNumActiveParticle() const = 0; // at 0x58 - virtual UNKWORD GetNumFreeParticle() const = 0; // at 0x5c - - virtual void * AllocHeap(u32) = 0; // at 0x60 - }; - } -} +namespace nw4r { +namespace ef { +struct MemoryManagerBase { + virtual ~MemoryManagerBase(); // at 0x8 + virtual UNKTYPE GarbageCollection() = 0; // at 0xc -#endif \ No newline at end of file + virtual Effect *AllocEffect() = 0; // at 0x10 + virtual UNKTYPE FreeEffect(void *) = 0; // at 0x14 + virtual UNKWORD GetNumAllocEffect() const = 0; // at 0x18 + virtual UNKWORD GetNumActiveEffect() const = 0; // at 0x1c + virtual UNKWORD GetNumFreeEffect() const = 0; // at 0x20 + + virtual Emitter *AllocEmitter() = 0; // at 0x24 + virtual UNKTYPE FreeEmitter(void *) = 0; // at 0x28 + virtual UNKWORD GetNumAllocEmitter() const = 0; // at 0x2c + virtual UNKWORD GetNumActiveEmitter() const = 0; // at 0x30 + virtual UNKWORD GetNumFreeEmitter() const = 0; // at 0x34 + + virtual ParticleManager *AllocParticleManager() = 0; // at 0x38 + virtual UNKTYPE FreeParticleManager(void *) = 0; // at 0x3c + virtual UNKWORD GetNumAllocParticleManager() const = 0; // at 0x40 + virtual UNKWORD GetNumActiveParticleManager() const = 0; // at 0x44 + virtual UNKWORD GetNumFreeParticleManager() const = 0; // at 0x48 + + virtual Particle *AllocParticle() = 0; // at 0x4c + virtual UNKTYPE FreeParticle(void *) = 0; // at 0x50 + virtual UNKWORD GetNumAllocParticle() const = 0; // at 0x54 + virtual UNKWORD GetNumActiveParticle() const = 0; // at 0x58 + virtual UNKWORD GetNumFreeParticle() const = 0; // at 0x5c + + virtual void *AllocHeap(u32) = 0; // at 0x60 +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_particle.h b/include/nw4r/ef/ef_particle.h index faae8309..f0c36aaf 100644 --- a/include/nw4r/ef/ef_particle.h +++ b/include/nw4r/ef/ef_particle.h @@ -1,24 +1,21 @@ #ifndef NW4R_EF_PARTICLE_H #define NW4R_EF_PARTICLE_H -#include "types_nw4r.h" +#include "common.h" #include "ef_ref.h" -namespace nw4r -{ - namespace ef - { - struct Particle : ReferencedObject - { - char UNK_0x20[0x8C]; - - math::VEC3 VEC_0xAC; - math::VEC3 VEC_0xB8; - - char UNK_0xC4[0x4]; - - ParticleManager * mManager; // at 0xc8 - }; - } -} +namespace nw4r { +namespace ef { +struct Particle : ReferencedObject { + char UNK_0x20[0x8C]; -#endif \ No newline at end of file + math::VEC3 VEC_0xAC; + math::VEC3 VEC_0xB8; + + char UNK_0xC4[0x4]; + + ParticleManager *mManager; // at 0xc8 +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_particlemanager.h b/include/nw4r/ef/ef_particlemanager.h index f850f3e9..f4fd3b20 100644 --- a/include/nw4r/ef/ef_particlemanager.h +++ b/include/nw4r/ef/ef_particlemanager.h @@ -1,91 +1,83 @@ #ifndef NW4R_EF_PARTICLEMANAGER #define NW4R_EF_PARTICLEMANAGER -#include "types_nw4r.h" -#include "math_types.h" +#include "common.h" #include "ef_list.h" #include "ef_ref.h" +#include "math_types.h" #include "ut_Color.h" -namespace nw4r -{ - namespace ef - { - struct ParticleManager : ReferencedObject - { - struct ParticleModifier - { - math::VEC2 mScale; // at 0x0 - math::VEC3 mRotate; // at 0x8 +namespace nw4r { +namespace ef { +struct ParticleManager : ReferencedObject { + struct ParticleModifier { + math::VEC2 mScale; // at 0x0 + math::VEC3 mRotate; // at 0x8 - struct SimpleLight - { - u8 mType; // at 0x0 - ut::Color mAmbColor; // at 0x1 - } mLight; - }; + struct SimpleLight { + u8 mType; // at 0x0 + ut::Color mAmbColor; // at 0x1 + } mLight; + }; - UNKTYPE BeginDraw(); - UNKTYPE EndDraw(); - UNKTYPE BeginCalc(bool); - UNKTYPE EndCalc(); - - bool SendClosing(); - UNKTYPE DestroyFunc(); - virtual bool Initialize(Emitter *, EmitterResource *); - virtual UNKTYPE CreateParticle(u16, math::VEC3, math::VEC3, const math::MTX34 *, float, const EmitterInheritSetting *, Particle *, u16); - virtual UNKTYPE Calc(); - virtual UNKTYPE Draw(const DrawInfo &); - - Emitter * mEmitter; // at 0x20 - EmitterResource * mResource; // at 0x24 - UNKWORD FLAGS_0x28; - char UNK_0x2C[0xC]; - ActivityList EFLIST_0x38; - char UNK_0x54[0x4]; + UNKTYPE BeginDraw(); + UNKTYPE EndDraw(); + UNKTYPE BeginCalc(bool); + UNKTYPE EndCalc(); - ParticleModifier mMod; // at 0x58 + bool SendClosing(); + UNKTYPE DestroyFunc(); + virtual bool Initialize(Emitter *, EmitterResource *); + virtual UNKTYPE CreateParticle(u16, math::VEC3, math::VEC3, const math::MTX34 *, float, + const EmitterInheritSetting *, Particle *, u16); + virtual UNKTYPE Calc(); + virtual UNKTYPE Draw(const DrawInfo &); - char UNK_0x74[0x14]; + Emitter *mEmitter; // at 0x20 + EmitterResource *mResource; // at 0x24 + UNKWORD FLAGS_0x28; + char UNK_0x2C[0xC]; + ActivityList EFLIST_0x38; + char UNK_0x54[0x4]; - s8 BYTE_0x88; - u8 BYTE_0x89; - bool BOOL_0x8A; + ParticleModifier mMod; // at 0x58 - UNKWORD FLAGS_0xB4; - - u16 RetireParticleAll(); - - UNKTYPE CalcGlobalMtx(math::MTX34 *); + char UNK_0x74[0x14]; - static void ModifierTravFunc_SetSimpleLightType(void *p, u32 payload) - { - ParticleManager *mgr = (ParticleManager *)p; - u8 type = (u8)payload; - mgr->mMod.mLight.mType = type; - } + s8 BYTE_0x88; + u8 BYTE_0x89; + bool BOOL_0x8A; - static void ModifierTravFunc_SetSimpleLightAmbient(void *p, u32 payload) - { - ParticleManager *mgr = (ParticleManager *)p; - ut::Color *color = (ut::Color *)payload; - mgr->mMod.mLight.mAmbColor = *color; - } + UNKWORD FLAGS_0xB4; - static void ModifierTravFunc_SetScale(void *p, u32 payload) - { - ParticleManager *mgr = (ParticleManager *)p; - math::VEC2 *scale = (math::VEC2 *)payload; - mgr->mMod.mScale = *scale; - } + u16 RetireParticleAll(); - static void ModifierTravFunc_SetRotate(void *p, u32 payload) - { - ParticleManager *mgr = (ParticleManager *)p; - math::VEC3 *rot = (math::VEC3 *)payload; - mgr->mMod.mRotate = *rot; - } - }; + UNKTYPE CalcGlobalMtx(math::MTX34 *); + + static void ModifierTravFunc_SetSimpleLightType(void *p, u32 payload) { + ParticleManager *mgr = (ParticleManager *)p; + u8 type = (u8)payload; + mgr->mMod.mLight.mType = type; } -} -#endif \ No newline at end of file + static void ModifierTravFunc_SetSimpleLightAmbient(void *p, u32 payload) { + ParticleManager *mgr = (ParticleManager *)p; + ut::Color *color = (ut::Color *)payload; + mgr->mMod.mLight.mAmbColor = *color; + } + + static void ModifierTravFunc_SetScale(void *p, u32 payload) { + ParticleManager *mgr = (ParticleManager *)p; + math::VEC2 *scale = (math::VEC2 *)payload; + mgr->mMod.mScale = *scale; + } + + static void ModifierTravFunc_SetRotate(void *p, u32 payload) { + ParticleManager *mgr = (ParticleManager *)p; + math::VEC3 *rot = (math::VEC3 *)payload; + mgr->mMod.mRotate = *rot; + } +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_rand.h b/include/nw4r/ef/ef_rand.h index a007d096..18741a1a 100644 --- a/include/nw4r/ef/ef_rand.h +++ b/include/nw4r/ef/ef_rand.h @@ -1,38 +1,31 @@ #ifndef NW4R_EF_RAND_H #define NW4R_EF_RAND_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - struct Random - { - u32 mSeed; // at 0x0 - - inline u32 MixRandomSeed() - { - return mSeed = mSeed * 0x343fd + 0x269ec3; - } - - inline void Srand(u32 seed) - { - mSeed = seed; - } - - inline u32 Rand() - { - //WARNING: THIS INLINE FUNCTION MAY NOT BE ACCURATE - return MixRandomSeed() >> 0x10; - } - - inline float RandFloat() - { - //WARNING: THIS INLINE FUNCTION MAY NOT BE ACCURATE - return (float)Rand() / 0xFFFF; - } - }; - } -} +namespace nw4r { +namespace ef { +struct Random { + u32 mSeed; // at 0x0 -#endif \ No newline at end of file + inline u32 MixRandomSeed() { + return mSeed = mSeed * 0x343fd + 0x269ec3; + } + + inline void Srand(u32 seed) { + mSeed = seed; + } + + inline u32 Rand() { + // WARNING: THIS INLINE FUNCTION MAY NOT BE ACCURATE + return MixRandomSeed() >> 0x10; + } + + inline float RandFloat() { + // WARNING: THIS INLINE FUNCTION MAY NOT BE ACCURATE + return (float)Rand() / 0xFFFF; + } +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_ref.h b/include/nw4r/ef/ef_ref.h index 2ee05712..4f71969f 100644 --- a/include/nw4r/ef/ef_ref.h +++ b/include/nw4r/ef/ef_ref.h @@ -1,48 +1,45 @@ #ifndef NW4R_EF_REF #define NW4R_EF_REF -#include "types_nw4r.h" +#include "common.h" #include "math_types.h" -namespace nw4r -{ - namespace ef - { - struct ReferencedObject - { - char UNK_0x0[0xC]; - UNKWORD WORD_0xC; - u32 mRefCount; // at 0x10 - char UNK_0x14[0x8]; - - virtual bool SendClosing(); - virtual UNKTYPE DestroyFunc(); - - inline void Initialize() - { - mRefCount = 0; - WORD_0xC = 1; - } - - inline void Ref() - { - mRefCount++; - } - - inline void UnRef() - { - if (--mRefCount == 0 && WORD_0xC == 2) SendClosing(); - } - - inline void Destroy() - { - DestroyFunc(); - WORD_0xC = 2; - if (mRefCount == 0) SendClosing(); - } - }; - - typedef ReferencedObject UNKREF; - } -} +namespace nw4r { +namespace ef { +struct ReferencedObject { + char UNK_0x0[0xC]; + UNKWORD WORD_0xC; + u32 mRefCount; // at 0x10 + char UNK_0x14[0x8]; -#endif \ No newline at end of file + virtual bool SendClosing(); + virtual UNKTYPE DestroyFunc(); + + inline void Initialize() { + mRefCount = 0; + WORD_0xC = 1; + } + + inline void Ref() { + mRefCount++; + } + + inline void UnRef() { + if (--mRefCount == 0 && WORD_0xC == 2) { + SendClosing(); + } + } + + inline void Destroy() { + DestroyFunc(); + WORD_0xC = 2; + if (mRefCount == 0) { + SendClosing(); + } + } +}; + +typedef ReferencedObject UNKREF; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_resource.h b/include/nw4r/ef/ef_resource.h index f3cdd672..ac461516 100644 --- a/include/nw4r/ef/ef_resource.h +++ b/include/nw4r/ef/ef_resource.h @@ -1,18 +1,15 @@ #ifndef NW4R_EF_RESOURCE #define NW4R_EF_RESOURCE -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace ef - { - struct Resource - { - EmitterResource * _FindEmitter(const char *, EffectProject *) const; - - static Resource * GetInstance(); - }; - } -} +namespace nw4r { +namespace ef { +struct Resource { + EmitterResource *_FindEmitter(const char *, EffectProject *) const; -#endif \ No newline at end of file + static Resource *GetInstance(); +}; +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/ef/ef_util.h b/include/nw4r/ef/ef_util.h index 5f7dd6b0..81ca35ef 100644 --- a/include/nw4r/ef/ef_util.h +++ b/include/nw4r/ef/ef_util.h @@ -1,22 +1,20 @@ #ifndef NW4R_EF_UTIL #define NW4R_EF_UTIL -#include "types_nw4r.h" +#include "common.h" #include "ut_list.h" -namespace nw4r -{ - namespace ef - { - typedef void (* Action)(void *, u32); - - u16 UtlistToArray(const ut::List *, void **, int); - - UNKTYPE GetDirMtxY(math::MTX34 *, const math::VEC3 &); - UNKTYPE MtxGetRotation(const math::MTX34 &, math::VEC3 *); - UNKTYPE MtxGetTranslate(const math::MTX34 &, math::VEC3 *); - UNKTYPE MtxGetRotationMtx(const math::MTX34 &, math::MTX34 *); - UNKTYPE MtxGetScale(const math::MTX34 &, math::VEC3 *); - } -} +namespace nw4r { +namespace ef { +typedef void (*Action)(void *, u32); -#endif \ No newline at end of file +u16 UtlistToArray(const ut::List *, void **, int); + +UNKTYPE GetDirMtxY(math::MTX34 *, const math::VEC3 &); +UNKTYPE MtxGetRotation(const math::MTX34 &, math::VEC3 *); +UNKTYPE MtxGetTranslate(const math::MTX34 &, math::VEC3 *); +UNKTYPE MtxGetRotationMtx(const math::MTX34 &, math::MTX34 *); +UNKTYPE MtxGetScale(const math::MTX34 &, math::VEC3 *); +} // namespace ef +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_3dsmax.h b/include/nw4r/g3d/g3d_3dsmax.h index 01be899b..56c56453 100644 --- a/include/nw4r/g3d/g3d_3dsmax.h +++ b/include/nw4r/g3d/g3d_3dsmax.h @@ -1,20 +1,16 @@ #ifndef NW4R_G3D_3DSMAX_H #define NW4R_G3D_3DSMAX_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_anmtexsrt.h" -namespace nw4r -{ - namespace g3d - { - namespace detail - { - namespace dcc - { - bool CalcTexMtx_3dsmax(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag); - } - } - } +namespace nw4r { +namespace g3d { +namespace detail { +namespace dcc { +bool CalcTexMtx_3dsmax(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag); } +} // namespace detail +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_anmcamera.h b/include/nw4r/g3d/g3d_anmcamera.h index 1ea8fd1c..972ed03e 100644 --- a/include/nw4r/g3d/g3d_anmcamera.h +++ b/include/nw4r/g3d/g3d_anmcamera.h @@ -1,7 +1,7 @@ #ifndef NW4R_G3D_ANMCAMERA_H #define NW4R_G3D_ANMCAMERA_H +#include "common.h" #include "math_types.h" -#include "types_nw4r.h" #include diff --git a/include/nw4r/g3d/g3d_anmchr.h b/include/nw4r/g3d/g3d_anmchr.h index 34c6ab51..577bd8ff 100644 --- a/include/nw4r/g3d/g3d_anmchr.h +++ b/include/nw4r/g3d/g3d_anmchr.h @@ -1,40 +1,25 @@ #ifndef NW4R_G3D_ANMCHR_H #define NW4R_G3D_ANMCHR_H -#include "types_nw4r.h" +#include "common.h" #include "math_types.h" -namespace nw4r -{ - namespace g3d - { - struct ChrAnmResult - { - u32 mFlags; // at 0x0 - math::VEC3 VEC3_0x4; - math::VEC3 VEC3_0x10; - math::MTX34 mMtx; // at 0x1C - }; +namespace nw4r { +namespace g3d { +struct ChrAnmResult { + u32 mFlags; // at 0x0 + math::VEC3 VEC3_0x4; + math::VEC3 VEC3_0x10; + math::MTX34 mMtx; // at 0x1C +}; - struct AnmObjChr - { +struct AnmObjChr {}; - }; - - struct AnmObjChrNode - { +struct AnmObjChrNode {}; - }; +struct AnmObjChrBlend {}; - struct AnmObjChrBlend - { +struct AnmObjChrRes {}; +} // namespace g3d +} // namespace nw4r - }; - - struct AnmObjChrRes - { - - }; - } -} - -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_anmclr.h b/include/nw4r/g3d/g3d_anmclr.h index dab07f60..6a009f19 100644 --- a/include/nw4r/g3d/g3d_anmclr.h +++ b/include/nw4r/g3d/g3d_anmclr.h @@ -1,23 +1,17 @@ #ifndef NW4R_G3D_ANMCLR_H #define NW4R_G3D_ANMCLR_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace g3d - { - struct ClrAnmResult - { - enum - { - ANM_COUNT = 11 - }; - - u32 mFlags; // at 0x0 - u32 COLORS_0x4[ANM_COUNT]; - UNKWORD WORDS_0x30[ANM_COUNT]; - }; - } -} +namespace nw4r { +namespace g3d { +struct ClrAnmResult { + enum { ANM_COUNT = 11 }; -#endif \ No newline at end of file + u32 mFlags; // at 0x0 + u32 COLORS_0x4[ANM_COUNT]; + UNKWORD WORDS_0x30[ANM_COUNT]; +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_anmfog.h b/include/nw4r/g3d/g3d_anmfog.h index 10f6e72f..565f1bd3 100644 --- a/include/nw4r/g3d/g3d_anmfog.h +++ b/include/nw4r/g3d/g3d_anmfog.h @@ -1,6 +1,6 @@ #ifndef NW4R_G3D_ANMFOG_H #define NW4R_G3D_ANMFOG_H -#include "types_nw4r.h" +#include "common.h" #include "ut_Color.h" #include diff --git a/include/nw4r/g3d/g3d_anmobj.h b/include/nw4r/g3d/g3d_anmobj.h index da233a0e..421223a0 100644 --- a/include/nw4r/g3d/g3d_anmobj.h +++ b/include/nw4r/g3d/g3d_anmobj.h @@ -1,129 +1,103 @@ #ifndef NW4R_G3D_ANMOBJ_H #define NW4R_G3D_ANMOBJ_H -#include "types_nw4r.h" +#include "common.h" +#include "g3d_obj.h" #include "g3d_rescommon.h" #include "g3d_resmdl.h" -#include "g3d_obj.h" -namespace nw4r -{ - namespace g3d - { - enum AnmPolicy - { - ANM_POLICY_ONETIME, - ANM_POLICY_LOOP, - ANM_POLICY_MAX - }; +namespace nw4r { +namespace g3d { +enum AnmPolicy { ANM_POLICY_ONETIME, ANM_POLICY_LOOP, ANM_POLICY_MAX }; - typedef f32 (* PlayPolicyFunc)(f32, f32, f32); - f32 PlayPolicy_Onetime(f32, f32, f32); - f32 PlayPolicy_Loop(f32, f32, f32); +typedef f32 (*PlayPolicyFunc)(f32, f32, f32); +f32 PlayPolicy_Onetime(f32, f32, f32); +f32 PlayPolicy_Loop(f32, f32, f32); - inline PlayPolicyFunc GetAnmPlayPolicy(AnmPolicy policy) - { - static PlayPolicyFunc policyTable[ANM_POLICY_MAX] = { - PlayPolicy_Onetime, - PlayPolicy_Loop - }; - return policyTable[policy]; - } - - struct FrameCtrl - { - FrameCtrl(f32 f1, f32 f2, PlayPolicyFunc policy) - : mFrame(0.0f), mRate(1.0f), FLOAT_0x8(f1), mEndFrame(f2), mPolicy(policy) {} - - f32 GetFrm() const - { - return mFrame; - } - - f32 GetRate() const - { - return mRate; - } - - void SetFrm(f32 frm) - { - f32 newFrm = mPolicy(FLOAT_0x8, mEndFrame, frm); - mFrame = newFrm; - } - - void SetRate(f32 rate) - { - mRate = rate; - } - - void SetPolicy(PlayPolicyFunc func) - { - mPolicy = func; - } - - void UpdateFrm() - { - SetFrm(mFrame + mRate * smBaseUpdateRate); - } - - f32 mFrame; // at 0x0 - f32 mRate; // at 0x4 - f32 FLOAT_0x8; - f32 mEndFrame; - PlayPolicyFunc mPolicy; // at 0x10 - - static f32 smBaseUpdateRate; - }; - - class AnmObj : public G3dObj - { - public: - enum AnmFlag - { - ANMFLAG_2 = 0x2, - ANMFLAG_ISBOUND = 0x4 - }; - - public: - AnmObj(MEMAllocator *pAllocator, G3dObj *pParent) - : G3dObj(pAllocator, pParent), mFlags(0) {} - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : G3dObj::IsDerivedFrom(other); - } - virtual void G3dProc(u32, u32, void *) = 0; // at 0xC - virtual ~AnmObj() {} // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - virtual void SetFrame(f32) = 0; // at 0x1C - virtual f32 GetFrame() const = 0; // at 0x20 - virtual void UpdateFrame() = 0; // at 0x24 - virtual void SetUpdateRate(f32) = 0; // at 0x28 - virtual f32 GetUpdateRate() const = 0; // at 0x2C - virtual bool Bind(ResMdl) = 0; // at 0x30 - virtual void Release(); // at 0x34 - - static const TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - void SetAnmFlag(AnmFlag, bool); - bool TestAnmFlag(AnmFlag) const; - - private: - u32 mFlags; // at 0x4 - - NW4R_G3D_TYPE_OBJ_DECL(AnmObj); - }; - } +inline PlayPolicyFunc GetAnmPlayPolicy(AnmPolicy policy) { + static PlayPolicyFunc policyTable[ANM_POLICY_MAX] = {PlayPolicy_Onetime, PlayPolicy_Loop}; + return policyTable[policy]; } -#endif \ No newline at end of file +struct FrameCtrl { + FrameCtrl(f32 f1, f32 f2, PlayPolicyFunc policy) + : mFrame(0.0f), mRate(1.0f), FLOAT_0x8(f1), mEndFrame(f2), mPolicy(policy) {} + + f32 GetFrm() const { + return mFrame; + } + + f32 GetRate() const { + return mRate; + } + + void SetFrm(f32 frm) { + f32 newFrm = mPolicy(FLOAT_0x8, mEndFrame, frm); + mFrame = newFrm; + } + + void SetRate(f32 rate) { + mRate = rate; + } + + void SetPolicy(PlayPolicyFunc func) { + mPolicy = func; + } + + void UpdateFrm() { + SetFrm(mFrame + mRate * smBaseUpdateRate); + } + + f32 mFrame; // at 0x0 + f32 mRate; // at 0x4 + f32 FLOAT_0x8; + f32 mEndFrame; + PlayPolicyFunc mPolicy; // at 0x10 + + static f32 smBaseUpdateRate; +}; + +class AnmObj : public G3dObj { +public: + enum AnmFlag { ANMFLAG_2 = 0x2, ANMFLAG_ISBOUND = 0x4 }; + +public: + AnmObj(MEMAllocator *pAllocator, G3dObj *pParent) : G3dObj(pAllocator, pParent), mFlags(0) {} + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 + { + return (other == GetTypeObjStatic()) ? true : G3dObj::IsDerivedFrom(other); + } + virtual void G3dProc(u32, u32, void *) = 0; // at 0xC + virtual ~AnmObj() {} // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + virtual void SetFrame(f32) = 0; // at 0x1C + virtual f32 GetFrame() const = 0; // at 0x20 + virtual void UpdateFrame() = 0; // at 0x24 + virtual void SetUpdateRate(f32) = 0; // at 0x28 + virtual f32 GetUpdateRate() const = 0; // at 0x2C + virtual bool Bind(ResMdl) = 0; // at 0x30 + virtual void Release(); // at 0x34 + + static const TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + void SetAnmFlag(AnmFlag, bool); + bool TestAnmFlag(AnmFlag) const; + +private: + u32 mFlags; // at 0x4 + + NW4R_G3D_TYPE_OBJ_DECL(AnmObj); +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_anmscn.h b/include/nw4r/g3d/g3d_anmscn.h index 42643e0d..f32f99f4 100644 --- a/include/nw4r/g3d/g3d_anmscn.h +++ b/include/nw4r/g3d/g3d_anmscn.h @@ -1,60 +1,56 @@ #ifndef NW4R_G3D_ANMSCN_H #define NW4R_G3D_ANMSCN_H -#include "types_nw4r.h" -#include "g3d_obj.h" -#include "g3d_light.h" -#include "g3d_fog.h" +#include "common.h" #include "g3d_camera.h" +#include "g3d_fog.h" +#include "g3d_light.h" +#include "g3d_obj.h" -namespace nw4r -{ - namespace g3d - { - class AnmScnRes // : public AnmScn - { - }; +namespace nw4r { +namespace g3d { +class AnmScnRes // : public AnmScn +{}; - class AnmScn : G3dObj - { - public: - AnmScn(MEMAllocator *); - virtual bool IsDerivedFrom(TypeObj other) const; // at 0x8 - virtual ~AnmScn(); // at 0x10 - virtual const TypeObj GetTypeObj() const; // at 0x14 - virtual const char * GetTypeName() const; // at 0x18 - virtual void SetFrame(f32) = 0; // at 0x1C - virtual f32 GetFrame() const = 0; // at 0x20 - virtual void SetUpdateRate(f32) = 0; // at 0x24 - virtual f32 GetUpdateRate() const = 0; // at 0x28 - virtual void UpdateFrame() = 0; // at 0x2C - virtual void Attach(int, AnmScnRes); // at 0x30 - virtual void Detach(); // at 0x34 - virtual int GetNumLightSet() const = 0; // at 0x38 - virtual int GetNumAmbLight() const = 0; // at 0x3C - virtual int GetNumDiffuseLight() const = 0; // at 0x40 - virtual int GetNumSpecularLight() const = 0; // at 0x44 - virtual int GetNumFog() const = 0; // at 0x48 - virtual int GetNumCamera() const = 0; // at 0x4C - virtual int GetLightSetMaxRefNumber() const = 0; // at 0x50 - virtual int GetAmbLightMaxRefNumber() const = 0; // at 0x54 - virtual int GetDiffuseLightMaxRefNumber() const = 0; // at 0x58 - virtual int GetFogMaxRefNumber() const = 0; // at 0x5C - virtual int GetCameraMaxRefNumber() const = 0; // at 0x60 - virtual void GetLightSet(LightSet, u32) = 0; // at 0x64 - virtual ut::Color GetAmbLightColor(u32) = 0; // at 0x68 - virtual void GetLight(LightObj *, LightObj *, u32) = 0; // at 0x6C - virtual void GetFog(Fog, u32) = 0; // at 0x70 - virtual void GetCamera(Camera, u32) = 0; // at 0x74 - virtual int GetSpecularLightID(u32) const = 0; // at 0x78 - virtual bool HasSpecularLight(u32) const = 0; // at 0x7C - virtual void GetAmbLightResult(AmbLightAnmResult *, u32) = 0; // at 0x80 - virtual void GetLightResult(LightAnmResult *, u32) = 0; // at 0x84 - virtual void GetFogResult(FogAnmResult *, u32) = 0; // at 0x88 - virtual void GetFogResult(CameraAnmResult *, u32) = 0; // at 0x8C +class AnmScn : G3dObj { +public: + AnmScn(MEMAllocator *); + virtual bool IsDerivedFrom(TypeObj other) const; // at 0x8 + virtual ~AnmScn(); // at 0x10 + virtual const TypeObj GetTypeObj() const; // at 0x14 + virtual const char *GetTypeName() const; // at 0x18 + virtual void SetFrame(f32) = 0; // at 0x1C + virtual f32 GetFrame() const = 0; // at 0x20 + virtual void SetUpdateRate(f32) = 0; // at 0x24 + virtual f32 GetUpdateRate() const = 0; // at 0x28 + virtual void UpdateFrame() = 0; // at 0x2C + virtual void Attach(int, AnmScnRes); // at 0x30 + virtual void Detach(); // at 0x34 + virtual int GetNumLightSet() const = 0; // at 0x38 + virtual int GetNumAmbLight() const = 0; // at 0x3C + virtual int GetNumDiffuseLight() const = 0; // at 0x40 + virtual int GetNumSpecularLight() const = 0; // at 0x44 + virtual int GetNumFog() const = 0; // at 0x48 + virtual int GetNumCamera() const = 0; // at 0x4C + virtual int GetLightSetMaxRefNumber() const = 0; // at 0x50 + virtual int GetAmbLightMaxRefNumber() const = 0; // at 0x54 + virtual int GetDiffuseLightMaxRefNumber() const = 0; // at 0x58 + virtual int GetFogMaxRefNumber() const = 0; // at 0x5C + virtual int GetCameraMaxRefNumber() const = 0; // at 0x60 + virtual void GetLightSet(LightSet, u32) = 0; // at 0x64 + virtual ut::Color GetAmbLightColor(u32) = 0; // at 0x68 + virtual void GetLight(LightObj *, LightObj *, u32) = 0; // at 0x6C + virtual void GetFog(Fog, u32) = 0; // at 0x70 + virtual void GetCamera(Camera, u32) = 0; // at 0x74 + virtual int GetSpecularLightID(u32) const = 0; // at 0x78 + virtual bool HasSpecularLight(u32) const = 0; // at 0x7C + virtual void GetAmbLightResult(AmbLightAnmResult *, u32) = 0; // at 0x80 + virtual void GetLightResult(LightAnmResult *, u32) = 0; // at 0x84 + virtual void GetFogResult(FogAnmResult *, u32) = 0; // at 0x88 + virtual void GetFogResult(CameraAnmResult *, u32) = 0; // at 0x8C - void GetLightSetting(LightSetting *); - }; - } -} + void GetLightSetting(LightSetting *); +}; +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_anmvis.h b/include/nw4r/g3d/g3d_anmvis.h index d7549f8a..26bffd4d 100644 --- a/include/nw4r/g3d/g3d_anmvis.h +++ b/include/nw4r/g3d/g3d_anmvis.h @@ -1,188 +1,170 @@ #ifndef NW4R_G3D_ANMVIS_H #define NW4R_G3D_ANMVIS_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_anmobj.h" #include "g3d_resanmvis.h" -namespace nw4r -{ - namespace g3d +namespace nw4r { +namespace g3d { +void ApplyVisAnmResult(ResMdl, AnmObjVis *); +void ApplyVisAnmResult(u8 *, ResMdl, AnmObjVis *); + +class AnmObjVis : public AnmObj { +public: + AnmObjVis(MEMAllocator *, u16 *, int); + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 { - void ApplyVisAnmResult(ResMdl, AnmObjVis *); - void ApplyVisAnmResult(u8 *, ResMdl, AnmObjVis *); - - class AnmObjVis : public AnmObj - { - public: - AnmObjVis(MEMAllocator *, u16 *, int); - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : AnmObj::IsDerivedFrom(other); - } - virtual void G3dProc(u32, u32, void *); // at 0xC - virtual ~AnmObjVis() {} // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - virtual void SetFrame(f32) = 0; // at 0x1C - virtual f32 GetFrame() const = 0; // at 0x20 - virtual void UpdateFrame() = 0; // at 0x24 - virtual void SetUpdateRate(f32) = 0; // at 0x28 - virtual f32 GetUpdateRate() const = 0; // at 0x2C - virtual bool Bind(ResMdl) = 0; // at 0x30 - virtual void Release(); // at 0x34 - virtual bool GetResult(u32) = 0; // at 0x38 - virtual AnmObjVisRes * Attach(int, AnmObjVisRes *); // at 0x3C - virtual AnmObjVisRes * Detach(int); // at 0x40 - - static const TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - bool TestDefined(u32 idx) const; - bool TestExistence(u32 idx) const; - void DetachAll(); - - protected: - static const int MAX_RESOURCES = 4; - - int mNumBinds; // at 0x10 - u16 *mBinds; // at 0x14 - - NW4R_G3D_TYPE_OBJ_DECL(AnmObjVis); - }; - - class AnmObjVisNode : public AnmObjVis - { - public: - AnmObjVisNode(MEMAllocator *allocator, u16 *bindBuffer, int numBinds) - : AnmObjVis(allocator, bindBuffer, numBinds) - { - mResources[0] = NULL; - mResources[1] = NULL; - mResources[2] = NULL; - mResources[3] = NULL; - } - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : AnmObjVis::IsDerivedFrom(other); - } - virtual void G3dProc(u32, u32, void *); // at 0xC - virtual ~AnmObjVisNode(); // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - virtual void SetFrame(f32); // at 0x1C - virtual f32 GetFrame() const; // at 0x20 - virtual void UpdateFrame(); // at 0x24 - virtual void SetUpdateRate(f32); // at 0x28 - virtual f32 GetUpdateRate() const; // at 0x2C - virtual bool Bind(ResMdl); // at 0x30 - virtual void Release(); // at 0x34 - virtual bool GetResult(u32) = 0; // at 0x38 - virtual AnmObjVisRes * Attach(int, AnmObjVisRes *); // at 0x3C - virtual AnmObjVisRes * Detach(int); // at 0x40 - - static const TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - protected: - AnmObjVisRes *mResources[MAX_RESOURCES]; // at 0x18 - - NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisNode); - }; - - class AnmObjVisOR : public AnmObjVisNode - { - public: - AnmObjVisOR(MEMAllocator *allocator, u16 *bindBuffer, int numBinds) - : AnmObjVisNode(allocator, bindBuffer, numBinds) - { - } - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : AnmObjVisNode::IsDerivedFrom(other); - } - virtual ~AnmObjVisOR() {} // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - virtual bool GetResult(u32); // at 0x38 - - static const TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - static AnmObjVisOR * Construct(MEMAllocator *, u32 *, ResMdl); - - private: - NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisOR); - }; - - class AnmObjVisRes : public AnmObjVis, public FrameCtrl - { - public: - AnmObjVisRes(MEMAllocator *, ResAnmVis, u16 *, int); - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : AnmObjVis::IsDerivedFrom(other); - } - virtual ~AnmObjVisRes() {} // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - virtual void SetFrame(f32); // at 0x1C - virtual f32 GetFrame() const; // at 0x20 - virtual void UpdateFrame(); // at 0x24 - virtual void SetUpdateRate(f32); // at 0x28 - virtual f32 GetUpdateRate() const; // at 0x2C - virtual bool Bind(ResMdl); // at 0x30 - virtual bool GetResult(u32); // at 0x38 - - static const TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - static AnmObjVisRes * Construct(MEMAllocator *, u32 *, ResAnmVis, ResMdl); - - private: - ResAnmVis mResAnmVis; // at 0x2C - - NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisRes); - }; + return (other == GetTypeObjStatic()) ? true : AnmObj::IsDerivedFrom(other); } -} + virtual void G3dProc(u32, u32, void *); // at 0xC + virtual ~AnmObjVis() {} // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + virtual void SetFrame(f32) = 0; // at 0x1C + virtual f32 GetFrame() const = 0; // at 0x20 + virtual void UpdateFrame() = 0; // at 0x24 + virtual void SetUpdateRate(f32) = 0; // at 0x28 + virtual f32 GetUpdateRate() const = 0; // at 0x2C + virtual bool Bind(ResMdl) = 0; // at 0x30 + virtual void Release(); // at 0x34 + virtual bool GetResult(u32) = 0; // at 0x38 + virtual AnmObjVisRes *Attach(int, AnmObjVisRes *); // at 0x3C + virtual AnmObjVisRes *Detach(int); // at 0x40 -#endif \ No newline at end of file + static const TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + bool TestDefined(u32 idx) const; + bool TestExistence(u32 idx) const; + void DetachAll(); + +protected: + static const int MAX_RESOURCES = 4; + + int mNumBinds; // at 0x10 + u16 *mBinds; // at 0x14 + + NW4R_G3D_TYPE_OBJ_DECL(AnmObjVis); +}; + +class AnmObjVisNode : public AnmObjVis { +public: + AnmObjVisNode(MEMAllocator *allocator, u16 *bindBuffer, int numBinds) : AnmObjVis(allocator, bindBuffer, numBinds) { + mResources[0] = NULL; + mResources[1] = NULL; + mResources[2] = NULL; + mResources[3] = NULL; + } + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 + { + return (other == GetTypeObjStatic()) ? true : AnmObjVis::IsDerivedFrom(other); + } + virtual void G3dProc(u32, u32, void *); // at 0xC + virtual ~AnmObjVisNode(); // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + virtual void SetFrame(f32); // at 0x1C + virtual f32 GetFrame() const; // at 0x20 + virtual void UpdateFrame(); // at 0x24 + virtual void SetUpdateRate(f32); // at 0x28 + virtual f32 GetUpdateRate() const; // at 0x2C + virtual bool Bind(ResMdl); // at 0x30 + virtual void Release(); // at 0x34 + virtual bool GetResult(u32) = 0; // at 0x38 + virtual AnmObjVisRes *Attach(int, AnmObjVisRes *); // at 0x3C + virtual AnmObjVisRes *Detach(int); // at 0x40 + + static const TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + +protected: + AnmObjVisRes *mResources[MAX_RESOURCES]; // at 0x18 + + NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisNode); +}; + +class AnmObjVisOR : public AnmObjVisNode { +public: + AnmObjVisOR(MEMAllocator *allocator, u16 *bindBuffer, int numBinds) + : AnmObjVisNode(allocator, bindBuffer, numBinds) {} + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 + { + return (other == GetTypeObjStatic()) ? true : AnmObjVisNode::IsDerivedFrom(other); + } + virtual ~AnmObjVisOR() {} // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + virtual bool GetResult(u32); // at 0x38 + + static const TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + static AnmObjVisOR *Construct(MEMAllocator *, u32 *, ResMdl); + +private: + NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisOR); +}; + +class AnmObjVisRes : public AnmObjVis, public FrameCtrl { +public: + AnmObjVisRes(MEMAllocator *, ResAnmVis, u16 *, int); + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 + { + return (other == GetTypeObjStatic()) ? true : AnmObjVis::IsDerivedFrom(other); + } + virtual ~AnmObjVisRes() {} // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + virtual void SetFrame(f32); // at 0x1C + virtual f32 GetFrame() const; // at 0x20 + virtual void UpdateFrame(); // at 0x24 + virtual void SetUpdateRate(f32); // at 0x28 + virtual f32 GetUpdateRate() const; // at 0x2C + virtual bool Bind(ResMdl); // at 0x30 + virtual bool GetResult(u32); // at 0x38 + + static const TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + static AnmObjVisRes *Construct(MEMAllocator *, u32 *, ResAnmVis, ResMdl); + +private: + ResAnmVis mResAnmVis; // at 0x2C + + NW4R_G3D_TYPE_OBJ_DECL(AnmObjVisRes); +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_calcview.h b/include/nw4r/g3d/g3d_calcview.h index 9a705da4..8cb3a7c5 100644 --- a/include/nw4r/g3d/g3d_calcview.h +++ b/include/nw4r/g3d/g3d_calcview.h @@ -1,14 +1,12 @@ #ifndef NW4R_G3D_CALC_VIEW_H #define NW4R_G3D_CALC_VIEW_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace g3d - { - void CalcView(math::MTX34 *, math::MTX33 *, const math::MTX34 *, const u32 *, - u32, const math::MTX34 *, ResMdl, math::MTX34 *); - } +namespace nw4r { +namespace g3d { +void CalcView(math::MTX34 *, math::MTX33 *, const math::MTX34 *, const u32 *, u32, const math::MTX34 *, ResMdl, + math::MTX34 *); } +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_calcworld.h b/include/nw4r/g3d/g3d_calcworld.h index 70d052cb..f4968c2f 100644 --- a/include/nw4r/g3d/g3d_calcworld.h +++ b/include/nw4r/g3d/g3d_calcworld.h @@ -1,19 +1,15 @@ #ifndef NW4R_G3D_CALC_WORLD_H #define NW4R_G3D_CALC_WORLD_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace g3d - { - void CalcWorld(math::MTX34 *, u32 *, const u8 *, const math::MTX34 *, - ResMdl, AnmObjChr *, FuncObjCalcWorld *, u32); +namespace nw4r { +namespace g3d { +void CalcWorld(math::MTX34 *, u32 *, const u8 *, const math::MTX34 *, ResMdl, AnmObjChr *, FuncObjCalcWorld *, u32); - void CalcWorld(math::MTX34 *, u32 *, const u8 *, const math::MTX34 *, - ResMdl, AnmObjChr *, FuncObjCalcWorld *); +void CalcWorld(math::MTX34 *, u32 *, const u8 *, const math::MTX34 *, ResMdl, AnmObjChr *, FuncObjCalcWorld *); - void CalcSkinning(math::MTX34 *, u32 *, ResMdl, const u8 *); - } -} +void CalcSkinning(math::MTX34 *, u32 *, ResMdl, const u8 *); +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_camera.h b/include/nw4r/g3d/g3d_camera.h index 5c270db1..e5c58271 100644 --- a/include/nw4r/g3d/g3d_camera.h +++ b/include/nw4r/g3d/g3d_camera.h @@ -1,8 +1,8 @@ #ifndef NW4R_G3D_CAMERA_H #define NW4R_G3D_CAMERA_H +#include "common.h" #include "g3d_rescommon.h" #include "math_types.h" -#include "types_nw4r.h" #include diff --git a/include/nw4r/g3d/g3d_cpu.h b/include/nw4r/g3d/g3d_cpu.h index 8b159c85..07599a08 100644 --- a/include/nw4r/g3d/g3d_cpu.h +++ b/include/nw4r/g3d/g3d_cpu.h @@ -1,17 +1,14 @@ #ifndef NW4R_G3D_CPU_H #define NW4R_G3D_CPU_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace g3d - { - namespace detail - { - void Copy32ByteBlocks(void *, const void *, u32); - void ZeroMemory32ByteBlocks(void *, u32); - } - } -} +namespace nw4r { +namespace g3d { +namespace detail { +void Copy32ByteBlocks(void *, const void *, u32); +void ZeroMemory32ByteBlocks(void *, u32); +} // namespace detail +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_dcc.h b/include/nw4r/g3d/g3d_dcc.h index 570cdc81..56a009d8 100644 --- a/include/nw4r/g3d/g3d_dcc.h +++ b/include/nw4r/g3d/g3d_dcc.h @@ -1,15 +1,12 @@ #ifndef NW4R_G3D_DCC_H #define NW4R_G3D_DCC_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_anmtexsrt.h" -namespace nw4r -{ - namespace g3d - { - void CalcTexMtx(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag, - TexSrtTypedef::TexMatrixMode); - } +namespace nw4r { +namespace g3d { +void CalcTexMtx(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag, TexSrtTypedef::TexMatrixMode); } +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_draw.h b/include/nw4r/g3d/g3d_draw.h index d163bd8d..0d0956d7 100644 --- a/include/nw4r/g3d/g3d_draw.h +++ b/include/nw4r/g3d/g3d_draw.h @@ -1,19 +1,15 @@ #ifndef NW4R_G3D_DRAW_H #define NW4R_G3D_DRAW_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_resmdl.h" -namespace nw4r -{ - namespace g3d - { - struct DrawResMdlReplacement - { - }; +namespace nw4r { +namespace g3d { +struct DrawResMdlReplacement {}; - void DrawResMdlDirectly(ResMdl, const math::MTX34 *, const math::MTX33 *, - const math::MTX34 *, const u8 *, const u8 *, DrawResMdlReplacement *, u32); - } -} +void DrawResMdlDirectly(ResMdl, const math::MTX34 *, const math::MTX33 *, const math::MTX34 *, const u8 *, const u8 *, + DrawResMdlReplacement *, u32); +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_draw1mat1shp.h b/include/nw4r/g3d/g3d_draw1mat1shp.h index cad3e4a9..b442c9d1 100644 --- a/include/nw4r/g3d/g3d_draw1mat1shp.h +++ b/include/nw4r/g3d/g3d_draw1mat1shp.h @@ -1,20 +1,16 @@ #ifndef NW4R_G3D_DRAW1_MAT1_SHP_H #define NW4R_G3D_DRAW1_MAT1_SHP_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_resmat.h" #include "g3d_resshp.h" -namespace nw4r -{ - namespace g3d - { - struct Draw1Mat1ShpSwap - { - }; +namespace nw4r { +namespace g3d { +struct Draw1Mat1ShpSwap {}; - void Draw1Mat1ShpDirectly(ResMat, ResShp, const math::MTX34 *, - const math::MTX34 *, u32, Draw1Mat1ShpSwap *, G3DState::IndMtxOp *); - } -} +void Draw1Mat1ShpDirectly(ResMat, ResShp, const math::MTX34 *, const math::MTX34 *, u32, Draw1Mat1ShpSwap *, + G3DState::IndMtxOp *); +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_fog.h b/include/nw4r/g3d/g3d_fog.h index 240ffc9c..0c1932a7 100644 --- a/include/nw4r/g3d/g3d_fog.h +++ b/include/nw4r/g3d/g3d_fog.h @@ -1,8 +1,8 @@ #ifndef NW4R_G3D_FOG_H #define NW4R_G3D_FOG_H +#include "common.h" #include "g3d_rescommon.h" #include "math_types.h" -#include "types_nw4r.h" #include "ut_Color.h" #include diff --git a/include/nw4r/g3d/g3d_gpu.h b/include/nw4r/g3d/g3d_gpu.h index 760609fe..693af719 100644 --- a/include/nw4r/g3d/g3d_gpu.h +++ b/include/nw4r/g3d/g3d_gpu.h @@ -1,8 +1,8 @@ #ifndef NW4R_G3D_GPU_H #define NW4R_G3D_GPU_H +#include "common.h" #include "g3d_rescommon.h" #include "math_types.h" -#include "types_nw4r.h" #include diff --git a/include/nw4r/g3d/g3d_init.h b/include/nw4r/g3d/g3d_init.h index d8d39907..d6e9718a 100644 --- a/include/nw4r/g3d/g3d_init.h +++ b/include/nw4r/g3d/g3d_init.h @@ -1,6 +1,6 @@ #ifndef NW4R_G3D_INIT_H #define NW4R_G3D_INIT_H -#include "types_nw4r.h" +#include "common.h" #include namespace nw4r { diff --git a/include/nw4r/g3d/g3d_light.h b/include/nw4r/g3d/g3d_light.h index b1235377..a989dcf6 100644 --- a/include/nw4r/g3d/g3d_light.h +++ b/include/nw4r/g3d/g3d_light.h @@ -1,7 +1,7 @@ #ifndef NW4R_G3D_LIGHT_H #define NW4R_G3D_LIGHT_H +#include "common.h" #include "g3d_rescommon.h" -#include "types_nw4r.h" #include diff --git a/include/nw4r/g3d/g3d_maya.h b/include/nw4r/g3d/g3d_maya.h index b28becdb..ab10b53f 100644 --- a/include/nw4r/g3d/g3d_maya.h +++ b/include/nw4r/g3d/g3d_maya.h @@ -1,20 +1,16 @@ #ifndef NW4R_G3D_MAYA_H #define NW4R_G3D_MAYA_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_anmtexsrt.h" -namespace nw4r -{ - namespace g3d - { - namespace detail - { - namespace dcc - { - bool CalcTexMtx_Maya(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag); - } - } - } +namespace nw4r { +namespace g3d { +namespace detail { +namespace dcc { +bool CalcTexMtx_Maya(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag); } +} // namespace detail +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_obj.h b/include/nw4r/g3d/g3d_obj.h index e755ea47..6f596a11 100644 --- a/include/nw4r/g3d/g3d_obj.h +++ b/include/nw4r/g3d/g3d_obj.h @@ -1,6 +1,6 @@ #ifndef NW4R_G3D_G3DOBJ_H #define NW4R_G3D_G3DOBJ_H -#include "types_nw4r.h" +#include "common.h" #include #define NW4R_G3D_TYPE_OBJ_DECL(VAL) static const nw4r::g3d::G3dObj::ResNameDataT TYPE_NAME diff --git a/include/nw4r/g3d/g3d_resanm.h b/include/nw4r/g3d/g3d_resanm.h index 8e1205a6..f4c0335e 100644 --- a/include/nw4r/g3d/g3d_resanm.h +++ b/include/nw4r/g3d/g3d_resanm.h @@ -1,88 +1,83 @@ #ifndef NW4R_G3D_RESANM_H #define NW4R_G3D_RESANM_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace g3d - { - struct ResKeyFrameAnmFramesData - { - float mTime; // at 0x0 - float mValue; // at 0x4 - float mDerivative; // at 0x8 - }; - - struct ResKeyFrameAnmData - { - u16 mCount; // at 0x0 - float FLOAT_0x4; - ResKeyFrameAnmFramesData mFrames[]; // at 0x8 - }; - - struct ResColorAnmFramesData - { - u32 mColor; // at 0x0 - }; - - union ResColorAnmData - { - u32 mColor; - s32 mOffset; - }; - - struct ResBoolAnmFramesData - { - u32 mFlags; // at 0x0 - }; - - union ResAnmData - { - float mValue; - s32 mOffset; - }; - - namespace detail - { - float GetResKeyFrameAnmResult(const ResKeyFrameAnmData *, float); - - u32 GetResColorAnmResult(const ResColorAnmFramesData *, float); - - inline u32 GetResColorAnmResult(const ResColorAnmData * pData, float time, bool b) - { - if (b) return pData->mColor; - - return GetResColorAnmResult((const ResColorAnmFramesData *)((u8 *)pData + pData->mOffset), time); - } - - inline bool GetResBoolAnmFramesResult(const ResBoolAnmFramesData * pData, int i) - { - u32 index = i; - - u32 mask = 0x80000000 >> (index % 32); - u32 flags = pData[index / 32].mFlags; - - return flags & mask; - } - - template - inline float ClipFrame(T & info, float time) - { - if (time <= 0.0f) return 0.0f; - - if (info.mNumFrames <= time) return info.mNumFrames; - - return time; - } - - inline float GetResAnmResult(const ResAnmData * pData, float time, bool b) - { - if (b) return pData->mValue; - - return GetResKeyFrameAnmResult((const ResKeyFrameAnmData *)((u8 *)pData + pData->mOffset), time); - } - } - } +namespace nw4r { +namespace g3d { +struct ResKeyFrameAnmFramesData { + float mTime; // at 0x0 + float mValue; // at 0x4 + float mDerivative; // at 0x8 +}; + +struct ResKeyFrameAnmData { + u16 mCount; // at 0x0 + float FLOAT_0x4; + ResKeyFrameAnmFramesData mFrames[]; // at 0x8 +}; + +struct ResColorAnmFramesData { + u32 mColor; // at 0x0 +}; + +union ResColorAnmData { + u32 mColor; + s32 mOffset; +}; + +struct ResBoolAnmFramesData { + u32 mFlags; // at 0x0 +}; + +union ResAnmData { + float mValue; + s32 mOffset; +}; + +namespace detail { +float GetResKeyFrameAnmResult(const ResKeyFrameAnmData *, float); + +u32 GetResColorAnmResult(const ResColorAnmFramesData *, float); + +inline u32 GetResColorAnmResult(const ResColorAnmData *pData, float time, bool b) { + if (b) { + return pData->mColor; + } + + return GetResColorAnmResult((const ResColorAnmFramesData *)((u8 *)pData + pData->mOffset), time); } -#endif \ No newline at end of file +inline bool GetResBoolAnmFramesResult(const ResBoolAnmFramesData *pData, int i) { + u32 index = i; + + u32 mask = 0x80000000 >> (index % 32); + u32 flags = pData[index / 32].mFlags; + + return flags & mask; +} + +template +inline float ClipFrame(T &info, float time) { + if (time <= 0.0f) { + return 0.0f; + } + + if (info.mNumFrames <= time) { + return info.mNumFrames; + } + + return time; +} + +inline float GetResAnmResult(const ResAnmData *pData, float time, bool b) { + if (b) { + return pData->mValue; + } + + return GetResKeyFrameAnmResult((const ResKeyFrameAnmData *)((u8 *)pData + pData->mOffset), time); +} +} // namespace detail +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resanmcamera.h b/include/nw4r/g3d/g3d_resanmcamera.h index d3b00b17..0b1eb409 100644 --- a/include/nw4r/g3d/g3d_resanmcamera.h +++ b/include/nw4r/g3d/g3d_resanmcamera.h @@ -1,30 +1,28 @@ #ifndef NW4R_G3D_RESANMCAMERA_H #define NW4R_G3D_RESANMCAMERA_H -#include "types_nw4r.h" -#include "g3d_rescommon.h" +#include "common.h" #include "g3d_anmcamera.h" +#include "g3d_rescommon.h" -namespace nw4r -{ - namespace g3d - { - struct ResAnmCameraData - { - char UNK_0x0[0xC]; - u32 mID; // at 0xC - }; +namespace nw4r { +namespace g3d { +struct ResAnmCameraData { + char UNK_0x0[0xC]; + u32 mID; // at 0xC +}; - struct ResAnmCamera - { - ResCommon mAnmCamera; - - inline ResAnmCamera(void * vptr) : mAnmCamera(vptr) {} +struct ResAnmCamera { + ResCommon mAnmCamera; - bool IsValid() const { return mAnmCamera.IsValid(); } + inline ResAnmCamera(void *vptr) : mAnmCamera(vptr) {} - void GetAnmResult(CameraAnmResult *, f32) const; - }; + bool IsValid() const { + return mAnmCamera.IsValid(); } -} -#endif \ No newline at end of file + void GetAnmResult(CameraAnmResult *, f32) const; +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resanmchr.h b/include/nw4r/g3d/g3d_resanmchr.h index f37edd22..fd6696f9 100644 --- a/include/nw4r/g3d/g3d_resanmchr.h +++ b/include/nw4r/g3d/g3d_resanmchr.h @@ -1,35 +1,27 @@ #ifndef NW4R_G3D_RESANMCHR_H #define NW4R_G3D_RESANMCHR_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_rescommon.h" -namespace nw4r -{ - namespace g3d - { - struct ResAnmChrData - { - char UNK_0x0[0x8]; - u32 mRevision; // at 0x8 - }; +namespace nw4r { +namespace g3d { +struct ResAnmChrData { + char UNK_0x0[0x8]; + u32 mRevision; // at 0x8 +}; - struct ResAnmChr - { - enum - { - REVISION = 4 - }; - - ResCommon mAnmChr; - - inline ResAnmChr(void * vptr) : mAnmChr(vptr) {} - - inline bool CheckRevision() const - { - return mAnmChr.ref().mRevision == REVISION; - } - }; - } -} +struct ResAnmChr { + enum { REVISION = 4 }; -#endif \ No newline at end of file + ResCommon mAnmChr; + + inline ResAnmChr(void *vptr) : mAnmChr(vptr) {} + + inline bool CheckRevision() const { + return mAnmChr.ref().mRevision == REVISION; + } +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resanmfog.h b/include/nw4r/g3d/g3d_resanmfog.h index 2aab7454..4cc933cc 100644 --- a/include/nw4r/g3d/g3d_resanmfog.h +++ b/include/nw4r/g3d/g3d_resanmfog.h @@ -1,30 +1,28 @@ #ifndef NW4R_G3D_RESANMFOG_H #define NW4R_G3D_RESANMFOG_H -#include "types_nw4r.h" -#include "g3d_rescommon.h" +#include "common.h" #include "g3d_anmfog.h" +#include "g3d_rescommon.h" -namespace nw4r -{ - namespace g3d - { - struct ResAnmFogData - { - char UNK_0x0[0xC]; - u32 mID; // at 0xC - }; +namespace nw4r { +namespace g3d { +struct ResAnmFogData { + char UNK_0x0[0xC]; + u32 mID; // at 0xC +}; - struct ResAnmFog - { - ResCommon mAnmFog; - - inline ResAnmFog(void * vptr) : mAnmFog(vptr) {} +struct ResAnmFog { + ResCommon mAnmFog; - void GetAnmResult(FogAnmResult *, f32) const; + inline ResAnmFog(void *vptr) : mAnmFog(vptr) {} - bool IsValid() const { return mAnmFog.IsValid(); } - }; + void GetAnmResult(FogAnmResult *, f32) const; + + bool IsValid() const { + return mAnmFog.IsValid(); } -} +}; +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_resanmscn.h b/include/nw4r/g3d/g3d_resanmscn.h index 86c5ffd8..5983b256 100644 --- a/include/nw4r/g3d/g3d_resanmscn.h +++ b/include/nw4r/g3d/g3d_resanmscn.h @@ -1,45 +1,41 @@ #ifndef NW4R_G3D_RESANMSCN_H #define NW4R_G3D_RESANMSCN_H -#include "types_nw4r.h" -#include "g3d_rescommon.h" -#include "g3d_resanmfog.h" +#include "common.h" #include "g3d_resanmcamera.h" +#include "g3d_resanmfog.h" +#include "g3d_rescommon.h" -namespace nw4r -{ - namespace g3d - { - struct ResAnmScnData - { - char UNK_0x0[0x8]; - u32 mRevision; // at 0x8 - char UNK_0xC[0x3E - 0xC]; - u16 mFogMaxRefNum; // at 0x3E - }; +namespace nw4r { +namespace g3d { +struct ResAnmScnData { + char UNK_0x0[0x8]; + u32 mRevision; // at 0x8 + char UNK_0xC[0x3E - 0xC]; + u16 mFogMaxRefNum; // at 0x3E +}; - struct ResAnmScn - { - enum - { - REVISION = 4 - }; - - ResCommon mAnmScn; - - ResAnmFog GetResAnmFogByRefNumber(u32) const; - ResAnmCamera GetResAnmCameraByRefNumber(u32) const; +struct ResAnmScn { + enum { REVISION = 4 }; - inline ResAnmScn(void * vptr) : mAnmScn(vptr) {} + ResCommon mAnmScn; - inline bool IsValid() const { return mAnmScn.IsValid(); } - inline bool CheckRevision() const - { - return mAnmScn.ref().mRevision == REVISION; - } + ResAnmFog GetResAnmFogByRefNumber(u32) const; + ResAnmCamera GetResAnmCameraByRefNumber(u32) const; - u16 GetResAnmFogMaxRefNumber() const { return mAnmScn.ref().mFogMaxRefNum; } - }; - } -} + inline ResAnmScn(void *vptr) : mAnmScn(vptr) {} -#endif \ No newline at end of file + inline bool IsValid() const { + return mAnmScn.IsValid(); + } + inline bool CheckRevision() const { + return mAnmScn.ref().mRevision == REVISION; + } + + u16 GetResAnmFogMaxRefNumber() const { + return mAnmScn.ref().mFogMaxRefNum; + } +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resanmshp.h b/include/nw4r/g3d/g3d_resanmshp.h index 96bce327..58c3452b 100644 --- a/include/nw4r/g3d/g3d_resanmshp.h +++ b/include/nw4r/g3d/g3d_resanmshp.h @@ -1,35 +1,27 @@ #ifndef NW4R_G3D_RESANMSHP_H #define NW4R_G3D_RESANMSHP_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_rescommon.h" -namespace nw4r -{ - namespace g3d - { - struct ResAnmShpData - { - char UNK_0x0[0x8]; - u32 mRevision; // at 0x8 - }; +namespace nw4r { +namespace g3d { +struct ResAnmShpData { + char UNK_0x0[0x8]; + u32 mRevision; // at 0x8 +}; - struct ResAnmShp - { - enum - { - REVISION = 3 - }; - - ResCommon mAnmShp; - - inline ResAnmShp(void * vptr) : mAnmShp(vptr) {} - - inline bool CheckRevision() const - { - return mAnmShp.ref().mRevision == REVISION; - } - }; - } -} +struct ResAnmShp { + enum { REVISION = 3 }; -#endif \ No newline at end of file + ResCommon mAnmShp; + + inline ResAnmShp(void *vptr) : mAnmShp(vptr) {} + + inline bool CheckRevision() const { + return mAnmShp.ref().mRevision == REVISION; + } +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_rescommon.h b/include/nw4r/g3d/g3d_rescommon.h index 6bbd814f..5ff29ff7 100644 --- a/include/nw4r/g3d/g3d_rescommon.h +++ b/include/nw4r/g3d/g3d_rescommon.h @@ -1,141 +1,134 @@ #ifndef NW4R_G3D_RESCOMMON_H #define NW4R_G3D_RESCOMMON_H -#include "types_nw4r.h" +#include "common.h" -#define NW4R_G3D_CREATE_RES_NAME_DATA(VAR,VAL) ResNameData ResNameData_##VAR = { sizeof(VAL) - 1, VAL } +#define NW4R_G3D_CREATE_RES_NAME_DATA(VAR, VAL) ResNameData ResNameData_##VAR = {sizeof(VAL) - 1, VAL} #define FIFO_ACCESS_BP 0x61 #define FIFO_ACCESS_CP 0x8 #define FIFO_ACCESS_XF 0x10 -namespace nw4r -{ - namespace g3d - { - template - class ResCommon - { - T * mPtr; - - public: - inline ResCommon(void * vptr) : mPtr(static_cast(vptr)) {} - inline ResCommon(const void * vptr) : mPtr(static_cast(vptr)) {} - - inline T & ref() const { return *mPtr; } - inline T * ptr() const { return mPtr; } - inline bool IsValid() const { return mPtr != NULL; } +namespace nw4r { +namespace g3d { +template +class ResCommon { + T *mPtr; - template - inline const TPtr * ofs_to_ptr_raw(s32 ofs) const - { - return (const TPtr *)((u8 *)mPtr + ofs); - } - - template - inline TPtr * ofs_to_ptr(s32 ofs) - { - if (ofs) return (TPtr *)((u8 *)mPtr + ofs); - - return NULL; - } - - template - inline const TPtr * ofs_to_ptr(s32 ofs) const - { - if (ofs) return (const TPtr *)((u8 *)mPtr + ofs); - - return NULL; - } - - template - inline TObj ofs_to_obj(s32 ofs) const - { - if (ofs) return (u8 *)mPtr + ofs; - - return NULL; - } - }; - - struct ResNameData - { - u32 mLength; - char mName[0x1C]; - }; +public: + inline ResCommon(void *vptr) : mPtr(static_cast(vptr)) {} + inline ResCommon(const void *vptr) : mPtr(static_cast(vptr)) {} - struct ResName - { - ResCommon mRes; - - inline ResName(const void *vptr) : mRes(vptr) {} + inline T &ref() const { + return *mPtr; + } + inline T *ptr() const { + return mPtr; + } + inline bool IsValid() const { + return mPtr != NULL; + } - inline u32 GetLength() const - { - return mRes.ref().mLength; - } - - inline const char * GetName() const - { - return mRes.ref().mName; - } - - bool operator==(ResName) const; - }; + template + inline const TPtr *ofs_to_ptr_raw(s32 ofs) const { + return (const TPtr *)((u8 *)mPtr + ofs); + } - namespace detail - { - typedef u8 CPCmd[6]; - typedef u8 BPCmd[5]; - - inline void ResWrite_u8(u8 *res, u8 arg) - { - *res = arg; - } + template + inline TPtr *ofs_to_ptr(s32 ofs) { + if (ofs) { + return (TPtr *)((u8 *)mPtr + ofs); + } - inline void ResWrite_u16(u8 *res, u16 arg) - { - ResWrite_u8(res + 0, arg >> 8); - ResWrite_u8(res + 1, arg >> 0); - } + return NULL; + } - inline void ResWrite_u32(u8 *res, u32 arg) - { - ResWrite_u8(res + 0, arg >> 24); - ResWrite_u8(res + 1, arg >> 16); - ResWrite_u8(res + 2, arg >> 8); - ResWrite_u8(res + 3, arg >> 0); - } + template + inline const TPtr *ofs_to_ptr(s32 ofs) const { + if (ofs) { + return (const TPtr *)((u8 *)mPtr + ofs); + } - inline u8 ResRead_u8(const u8 *res) - { - return *res; - } + return NULL; + } - inline u32 ResRead_u32(const u8 *res) - { - int ret = ResRead_u8(res) << 24; - ret |= ResRead_u8(res + 1) << 16; - ret |= ResRead_u8(res + 2) << 8; - ret |= ResRead_u8(res + 3); - return ret; - } - - inline void ResReadBPCmd(const u8 *res, u32 *out) - { - *out = ResRead_u32(res + 1); - } - - inline void ResReadCPCmd(const u8 *res, u32 *out) - { - *out = ResRead_u32(res + 2); - } - - void ResWriteBPCmd(u8 *, u32); - void ResWriteBPCmd(u8 *, u32, u32); - void ResWriteCPCmd(u8 *, u8, u32); - void ResWriteXFCmd(u8 *, u16, u32); - void ResWriteSSMask(u8 *, u32); - } - } + template + inline TObj ofs_to_obj(s32 ofs) const { + if (ofs) { + return (u8 *)mPtr + ofs; + } + + return NULL; + } +}; + +struct ResNameData { + u32 mLength; + char mName[0x1C]; +}; + +struct ResName { + ResCommon mRes; + + inline ResName(const void *vptr) : mRes(vptr) {} + + inline u32 GetLength() const { + return mRes.ref().mLength; + } + + inline const char *GetName() const { + return mRes.ref().mName; + } + + bool operator==(ResName) const; +}; + +namespace detail { +typedef u8 CPCmd[6]; +typedef u8 BPCmd[5]; + +inline void ResWrite_u8(u8 *res, u8 arg) { + *res = arg; } -#endif \ No newline at end of file +inline void ResWrite_u16(u8 *res, u16 arg) { + ResWrite_u8(res + 0, arg >> 8); + ResWrite_u8(res + 1, arg >> 0); +} + +inline void ResWrite_u32(u8 *res, u32 arg) { + ResWrite_u8(res + 0, arg >> 24); + ResWrite_u8(res + 1, arg >> 16); + ResWrite_u8(res + 2, arg >> 8); + ResWrite_u8(res + 3, arg >> 0); +} + +inline u8 ResRead_u8(const u8 *res) { + return *res; +} + +inline u32 ResRead_u32(const u8 *res) { + int ret = ResRead_u8(res) << 24; + ret |= ResRead_u8(res + 1) << 16; + ret |= ResRead_u8(res + 2) << 8; + ret |= ResRead_u8(res + 3); + return ret; +} + +inline void ResReadBPCmd(const u8 *res, u32 *out) { + *out = ResRead_u32(res + 1); +} + +inline void ResReadCPCmd(const u8 *res, u32 *out) { + *out = ResRead_u32(res + 2); +} + +void ResWriteBPCmd(u8 *, u32); +void ResWriteBPCmd(u8 *, u32, u32); +void ResWriteCPCmd(u8 *, u8, u32); +void ResWriteXFCmd(u8 *, u16, u32); +void ResWriteSSMask(u8 *, u32); +} // namespace detail +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resdict.h b/include/nw4r/g3d/g3d_resdict.h index c3fde06a..07ecc2e7 100644 --- a/include/nw4r/g3d/g3d_resdict.h +++ b/include/nw4r/g3d/g3d_resdict.h @@ -1,57 +1,54 @@ #ifndef NW4R_G3D_RESDICT_H #define NW4R_G3D_RESDICT_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_rescommon.h" #include -namespace nw4r -{ - namespace g3d - { - struct ResDicEntry - { - u16 INT_0x0; // at 0x0 - u16 INT_0x2; // at 0x2 - u16 unk_index; // at 0x4 - u16 unk_index2; // at 0x6 - u32 INT_0x8; // at 0x8 - u32 INT_0xC; // at 0xC - }; +namespace nw4r { +namespace g3d { +struct ResDicEntry { + u16 INT_0x0; // at 0x0 + u16 INT_0x2; // at 0x2 + u16 unk_index; // at 0x4 + u16 unk_index2; // at 0x6 + u32 INT_0x8; // at 0x8 + u32 INT_0xC; // at 0xC +}; - struct ResDicData - { - u32 mSize; // at 0x0 - u32 mNumData; // at 0x4 - ResDicEntry mEntries[]; // 0x8 - }; +struct ResDicData { + u32 mSize; // at 0x0 + u32 mNumData; // at 0x4 + ResDicEntry mEntries[]; // 0x8 +}; - struct ResDic - { - ResCommon mDict; +struct ResDic { + ResCommon mDict; - ResDicEntry * Get(ResName) const; - ResDicEntry * Get(const char *, u32) const; - void * operator[](const char *) const; - void * operator[](ResName) const; - s32 GetIndex(ResName) const; - - inline ResDic(void * vptr) : mDict(vptr) {} - - inline void * operator[](int i) const - { - if (mDict.IsValid()) return (void *)mDict.ofs_to_ptr(mDict.ref().mEntries[i + 1].INT_0xC); - - return NULL; - } - - inline u32 GetNumData() const - { - if (mDict.IsValid()) return mDict.ref().mNumData; - - return 0; - } - }; - } -} + ResDicEntry *Get(ResName) const; + ResDicEntry *Get(const char *, u32) const; + void *operator[](const char *) const; + void *operator[](ResName) const; + s32 GetIndex(ResName) const; -#endif \ No newline at end of file + inline ResDic(void *vptr) : mDict(vptr) {} + + inline void *operator[](int i) const { + if (mDict.IsValid()) { + return (void *)mDict.ofs_to_ptr(mDict.ref().mEntries[i + 1].INT_0xC); + } + + return NULL; + } + + inline u32 GetNumData() const { + if (mDict.IsValid()) { + return mDict.ref().mNumData; + } + + return 0; + } +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resfile.h b/include/nw4r/g3d/g3d_resfile.h index fceaf42c..597fec6c 100644 --- a/include/nw4r/g3d/g3d_resfile.h +++ b/include/nw4r/g3d/g3d_resfile.h @@ -1,92 +1,87 @@ #ifndef NW4R_G3D_RESFILE_H #define NW4R_G3D_RESFILE_H -#include "ut_binaryFileFormat.h" +#include "common.h" #include "g3d_rescommon.h" #include "g3d_resdict.h" -#include "types_nw4r.h" +#include "ut_binaryFileFormat.h" -namespace nw4r -{ - namespace g3d - { - - struct ResFileData - { - ut::BinaryFileHeader mHeader; // at 0x0 - - ut::BinaryBlockHeader mRootHeader; // at 0x10 - ResDicData mRootData; // at 0x18 - }; - - struct ResFile - { - ResCommon mFile; // at 0x0 - - inline ResFileData & ref() const - { - return mFile.ref(); - } - - ResMdl GetResMdl(const char *) const; - ResMdl GetResMdl(int) const; - ResMdl GetResMdl(u32) const; //inlined - - ResPltt GetResPltt(const char *) const; - ResPltt GetResPltt(ResName) const; - ResPltt GetResPltt(int) const; - ResPltt GetResPltt(u32) const; //inlined - - ResTex GetResTex(const char *) const; - ResTex GetResTex(ResName) const; - ResTex GetResTex(int) const; - ResTex GetResTex(u32) const; //inlined - - ResAnmChr GetResAnmChr(const char *) const; - ResAnmChr GetResAnmChr(int) const; - ResAnmChr GetResAnmChr(u32) const; //inlined - - ResAnmVis GetResAnmVis(const char *) const; - ResAnmVis GetResAnmVis(int) const; - ResAnmVis GetResAnmVis(u32) const; //inlined - - ResAnmClr GetResAnmClr(const char *) const; - ResAnmClr GetResAnmClr(int) const; - ResAnmClr GetResAnmClr(u32) const; //inlined - - ResAnmTexPat GetResAnmTexPat(const char *) const; - ResAnmTexPat GetResAnmTexPat(int) const; - ResAnmTexPat GetResAnmTexPat(u32) const; //inlined - - ResAnmTexSrt GetResAnmTexSrt(const char *) const; - ResAnmTexSrt GetResAnmTexSrt(int) const; - ResAnmTexSrt GetResAnmTexSrt(u32) const; //inlined - - ResAnmShp GetResAnmShp(const char *) const; - ResAnmShp GetResAnmShp(int) const; - ResAnmShp GetResAnmShp(u32) const; //inlined - - ResAnmScn GetResAnmScn(const char *) const; - ResAnmScn GetResAnmScn(int) const; - ResAnmScn GetResAnmScn(u32) const; //inlined - - u32 GetResMdlNumEntries() const; //inlined - u32 GetResPlttNumEntries() const; //inlined - u32 GetResTexNumEntries() const; //inlined - u32 GetResAnmChrNumEntries() const; //inlined - u32 GetResAnmVisNumEntries() const; //inlined - u32 GetResAnmClrNumEntries() const; //inlined - u32 GetResAnmTexPatNumEntries() const; //inlined - u32 GetResAnmTexSrtNumEntries() const; //inlined - u32 GetResAnmShpNumEntries() const; //inlined - u32 GetResAnmScnNumEntries() const; - - bool Bind(ResFile); - void Release(); - void Init(); - void Terminate(); - bool CheckRevision() const; - }; - } -} +namespace nw4r { +namespace g3d { -#endif \ No newline at end of file +struct ResFileData { + ut::BinaryFileHeader mHeader; // at 0x0 + + ut::BinaryBlockHeader mRootHeader; // at 0x10 + ResDicData mRootData; // at 0x18 +}; + +struct ResFile { + ResCommon mFile; // at 0x0 + + inline ResFileData &ref() const { + return mFile.ref(); + } + + ResMdl GetResMdl(const char *) const; + ResMdl GetResMdl(int) const; + ResMdl GetResMdl(u32) const; // inlined + + ResPltt GetResPltt(const char *) const; + ResPltt GetResPltt(ResName) const; + ResPltt GetResPltt(int) const; + ResPltt GetResPltt(u32) const; // inlined + + ResTex GetResTex(const char *) const; + ResTex GetResTex(ResName) const; + ResTex GetResTex(int) const; + ResTex GetResTex(u32) const; // inlined + + ResAnmChr GetResAnmChr(const char *) const; + ResAnmChr GetResAnmChr(int) const; + ResAnmChr GetResAnmChr(u32) const; // inlined + + ResAnmVis GetResAnmVis(const char *) const; + ResAnmVis GetResAnmVis(int) const; + ResAnmVis GetResAnmVis(u32) const; // inlined + + ResAnmClr GetResAnmClr(const char *) const; + ResAnmClr GetResAnmClr(int) const; + ResAnmClr GetResAnmClr(u32) const; // inlined + + ResAnmTexPat GetResAnmTexPat(const char *) const; + ResAnmTexPat GetResAnmTexPat(int) const; + ResAnmTexPat GetResAnmTexPat(u32) const; // inlined + + ResAnmTexSrt GetResAnmTexSrt(const char *) const; + ResAnmTexSrt GetResAnmTexSrt(int) const; + ResAnmTexSrt GetResAnmTexSrt(u32) const; // inlined + + ResAnmShp GetResAnmShp(const char *) const; + ResAnmShp GetResAnmShp(int) const; + ResAnmShp GetResAnmShp(u32) const; // inlined + + ResAnmScn GetResAnmScn(const char *) const; + ResAnmScn GetResAnmScn(int) const; + ResAnmScn GetResAnmScn(u32) const; // inlined + + u32 GetResMdlNumEntries() const; // inlined + u32 GetResPlttNumEntries() const; // inlined + u32 GetResTexNumEntries() const; // inlined + u32 GetResAnmChrNumEntries() const; // inlined + u32 GetResAnmVisNumEntries() const; // inlined + u32 GetResAnmClrNumEntries() const; // inlined + u32 GetResAnmTexPatNumEntries() const; // inlined + u32 GetResAnmTexSrtNumEntries() const; // inlined + u32 GetResAnmShpNumEntries() const; // inlined + u32 GetResAnmScnNumEntries() const; + + bool Bind(ResFile); + void Release(); + void Init(); + void Terminate(); + bool CheckRevision() const; +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resmat.h b/include/nw4r/g3d/g3d_resmat.h index f9638af4..1c5a6358 100644 --- a/include/nw4r/g3d/g3d_resmat.h +++ b/include/nw4r/g3d/g3d_resmat.h @@ -1,8 +1,8 @@ #ifndef NW4R_G3D_RESMAT_H #define NW4R_G3D_RESMAT_H +#include "common.h" #include "g3d_rescommon.h" #include "math_types.h" -#include "types_nw4r.h" #include diff --git a/include/nw4r/g3d/g3d_resmdl.h b/include/nw4r/g3d/g3d_resmdl.h index 84975c47..bf865abf 100644 --- a/include/nw4r/g3d/g3d_resmdl.h +++ b/include/nw4r/g3d/g3d_resmdl.h @@ -1,100 +1,93 @@ #ifndef NW4R_G3D_RESMDL_H #define NW4R_G3D_RESMDL_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_rescommon.h" -#include "g3d_resnode.h" #include "g3d_resdict.h" +#include "g3d_resnode.h" -namespace nw4r -{ - namespace g3d - { - struct ResMdlData - { - char mMagic[4]; // "MDL0" - u32 INT_0x4; - u32 mRevision; // at 0x8 - s32 INT_0xC; - u32 mByteCodeDictOfs; // at 0x10 - u32 mNodeDictOfs; // at 0x14 - u32 mVtxPosDictOfs; // at 0x18 - u32 mVtxNrmDictOfs; // at 0x1C - u32 mVtxClrDictOfs; // at 0x20 - u32 mVtxTexCoordDictOfs; // at 0x24 - u32 mMatDictOfs; // at 0x28 - u32 mTevDictOfs; // at 0x2C - u32 mShpDictOfs; // at 0x30 - u32 mPlttTexInfoOfs; // at 0x34 - }; +namespace nw4r { +namespace g3d { +struct ResMdlData { + char mMagic[4]; // "MDL0" + u32 INT_0x4; + u32 mRevision; // at 0x8 + s32 INT_0xC; + u32 mByteCodeDictOfs; // at 0x10 + u32 mNodeDictOfs; // at 0x14 + u32 mVtxPosDictOfs; // at 0x18 + u32 mVtxNrmDictOfs; // at 0x1C + u32 mVtxClrDictOfs; // at 0x20 + u32 mVtxTexCoordDictOfs; // at 0x24 + u32 mMatDictOfs; // at 0x28 + u32 mTevDictOfs; // at 0x2C + u32 mShpDictOfs; // at 0x30 + u32 mPlttTexInfoOfs; // at 0x34 +}; - struct ResMdl - { - enum - { - REVISION = 9 - }; - - ResCommon mMdl; - - inline ResMdl(void * vptr) : mMdl(vptr) {} - bool IsValid() const { return mMdl.IsValid(); } - - u8 * GetResByteCode(const char *) const; +struct ResMdl { + enum { REVISION = 9 }; - ResNode GetResNode(const char *) const; - ResNode GetResNode(ResName) const; - ResNode GetResNode(int) const; - ResNode GetResNode(u32) const; - u32 GetResNodeNumEntries() const; + ResCommon mMdl; - ResVtxPos GetResVtxPos(ResName) const; - ResVtxPos GetResVtxPos(int) const; - ResVtxPos GetResVtxPos(u32) const; - u32 GetResVtxPosNumEntries() const; + inline ResMdl(void *vptr) : mMdl(vptr) {} + bool IsValid() const { + return mMdl.IsValid(); + } - ResVtxNrm GetResVtxNrm(ResName) const; - ResVtxNrm GetResVtxNrm(int) const; - ResVtxNrm GetResVtxNrm(u32) const; - u32 GetResVtxNrmNumEntries() const; + u8 *GetResByteCode(const char *) const; - ResVtxClr GetResVtxClr(ResName) const; - ResVtxClr GetResVtxClr(int) const; - ResVtxClr GetResVtxClr(u32) const; - u32 GetResVtxClrNumEntries() const; + ResNode GetResNode(const char *) const; + ResNode GetResNode(ResName) const; + ResNode GetResNode(int) const; + ResNode GetResNode(u32) const; + u32 GetResNodeNumEntries() const; - ResVtxTexCoord GetResVtxTexCoord(int) const; + ResVtxPos GetResVtxPos(ResName) const; + ResVtxPos GetResVtxPos(int) const; + ResVtxPos GetResVtxPos(u32) const; + u32 GetResVtxPosNumEntries() const; - ResMat GetResMat(const char *) const; - ResMat GetResMat(ResName) const; - ResMat GetResMat(int) const; - ResMat GetResMat(u32) const; - u32 GetResMatNumEntries() const; + ResVtxNrm GetResVtxNrm(ResName) const; + ResVtxNrm GetResVtxNrm(int) const; + ResVtxNrm GetResVtxNrm(u32) const; + u32 GetResVtxNrmNumEntries() const; - ResShp GetResShp(const char *) const; - ResShp GetResShp(int) const; - ResShp GetResShp(u32) const; - u32 GetResShpNumEntries() const; + ResVtxClr GetResVtxClr(ResName) const; + ResVtxClr GetResVtxClr(int) const; + ResVtxClr GetResVtxClr(u32) const; + u32 GetResVtxClrNumEntries() const; - ResTexPlttInfo GetResTexPlttInfoOffsetFromTexName(int) const; - u32 GetResTexPlttInfoOffsetFromTexNameNumEntries() const; + ResVtxTexCoord GetResVtxTexCoord(int) const; - bool Bind(ResFile); - void Release(); - void Init(); - void Terminate(); - - inline bool CheckRevision() const - { - return mMdl.ref().mRevision == REVISION; - } + ResMat GetResMat(const char *) const; + ResMat GetResMat(ResName) const; + ResMat GetResMat(int) const; + ResMat GetResMat(u32) const; + u32 GetResMatNumEntries() const; - inline u32 GetResVtxTexCoordNumEntries() const - { - ResMdlData& ref = mMdl.ref(); - return mMdl.ofs_to_obj(ref.mVtxTexCoordDictOfs).GetNumData(); - } - }; - } -} + ResShp GetResShp(const char *) const; + ResShp GetResShp(int) const; + ResShp GetResShp(u32) const; + u32 GetResShpNumEntries() const; -#endif \ No newline at end of file + ResTexPlttInfo GetResTexPlttInfoOffsetFromTexName(int) const; + u32 GetResTexPlttInfoOffsetFromTexNameNumEntries() const; + + bool Bind(ResFile); + void Release(); + void Init(); + void Terminate(); + + inline bool CheckRevision() const { + return mMdl.ref().mRevision == REVISION; + } + + inline u32 GetResVtxTexCoordNumEntries() const { + ResMdlData &ref = mMdl.ref(); + return mMdl.ofs_to_obj(ref.mVtxTexCoordDictOfs).GetNumData(); + } +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resnode.h b/include/nw4r/g3d/g3d_resnode.h index 54e1a0c5..4e080c9d 100644 --- a/include/nw4r/g3d/g3d_resnode.h +++ b/include/nw4r/g3d/g3d_resnode.h @@ -1,68 +1,62 @@ #ifndef NW4R_G3D_RESNODE_H #define NW4R_G3D_RESNODE_H -#include "types_nw4r.h" -#include "g3d_rescommon.h" +#include "common.h" #include "g3d_anmchr.h" +#include "g3d_rescommon.h" #include "math_types.h" -namespace nw4r -{ - namespace g3d - { - struct ResNodeData - { - u32 INT_0x0; - s32 INT_0x4; - u16 SHORT_0x8; - u16 SHORT_0xA; - UNKWORD WORD_0xC; - UNKWORD WORD_0x10; - u32 mFlags; // at 0x14 - UNKWORD WORD_0x18; - UNKWORD WORD_0x1C; - math::VEC3 VEC3_0x20; - math::VEC3 VEC3_0x2C; - f32 FLOAT_0x38; - f32 FLOAT_0x3C; - f32 FLOAT_0x40; - // . . . - }; +namespace nw4r { +namespace g3d { +struct ResNodeData { + u32 INT_0x0; + s32 INT_0x4; + u16 SHORT_0x8; + u16 SHORT_0xA; + UNKWORD WORD_0xC; + UNKWORD WORD_0x10; + u32 mFlags; // at 0x14 + UNKWORD WORD_0x18; + UNKWORD WORD_0x1C; + math::VEC3 VEC3_0x20; + math::VEC3 VEC3_0x2C; + f32 FLOAT_0x38; + f32 FLOAT_0x3C; + f32 FLOAT_0x40; + // . . . +}; - struct ResNode - { - enum ResNodeFlags - { - NODE_IS_VISIBLE = 0x100 - }; +struct ResNode { + enum ResNodeFlags { NODE_IS_VISIBLE = 0x100 }; - ResCommon mNode; + ResCommon mNode; - inline ResNode(void * vptr) : mNode(vptr) {} - - bool IsValid() const { return mNode.IsValid(); } + inline ResNode(void *vptr) : mNode(vptr) {} - UNKWORD GetID() const - { - if (IsValid()) - return mNode.ptr()->WORD_0xC; - return 0; - } - - void SetVisibility(bool visible) - { - if (IsValid()) - { - if (visible) - mNode.ptr()->mFlags |= NODE_IS_VISIBLE; - else - mNode.ptr()->mFlags &= ~NODE_IS_VISIBLE; - } - } - - void PatchChrAnmResult(ChrAnmResult *) const; - void CalcChrAnmResult(ChrAnmResult *) const; - }; + bool IsValid() const { + return mNode.IsValid(); } -} -#endif \ No newline at end of file + UNKWORD GetID() const { + if (IsValid()) { + return mNode.ptr()->WORD_0xC; + } + return 0; + } + + void SetVisibility(bool visible) { + if (IsValid()) { + if (visible) { + mNode.ptr()->mFlags |= NODE_IS_VISIBLE; + } else { + mNode.ptr()->mFlags &= ~NODE_IS_VISIBLE; + } + } + } + + void PatchChrAnmResult(ChrAnmResult *) const; + void CalcChrAnmResult(ChrAnmResult *) const; +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_resshp.h b/include/nw4r/g3d/g3d_resshp.h index bf61cebb..55cd6f29 100644 --- a/include/nw4r/g3d/g3d_resshp.h +++ b/include/nw4r/g3d/g3d_resshp.h @@ -1,122 +1,110 @@ #ifndef NW4R_G3D_RESSHP_H #define NW4R_G3D_RESSHP_H -#include -#include "types_nw4r.h" #include "g3d_rescommon.h" #include "g3d_resmdl.h" #include "g3d_resvtx.h" +#include #include "common.h" -namespace nw4r -{ - namespace g3d - { - struct ResTagDLData - { - u32 mBufSize; // at 0x0 - u32 mCmdSize; // at 0x4 - u32 mOffset; // at 0x8 - }; - - struct ResPrePrimDL - { - char UNK_0x0[0xA]; - detail::CPCmd CP_CMD_0xA; - detail::CPCmd CP_CMD_0x10; - char UNK_0x16[0xA]; - detail::CPCmd CP_CMD_0x20; - detail::CPCmd CP_CMD_0x26; - detail::CPCmd CP_CMD_0x2C; - detail::CPCmd CP_CMD_PAIRS_0x32[GX_POS_MTX_ARRAY - GX_VA_POS][2]; - char UNK_0xC2[0x1E]; - }; - - struct ResShpData - { - char UNK_0x0[0x4]; - u32 mParentOffset; // at 0x4 - char UNK_0x8[0x10]; - ResTagDLData mPrePrimDLTag; // at 0x18 - ResTagDLData mPrimDLTag; // at 0x24 - char UNK_0x30[0x18]; - - s16 mVtxPosIndex; // at 0x48 - s16 mVtxNrmIndex; // at 0x4a - s16 mVtxClrIndices[GX_VA_TEX0 - GX_VA_CLR0]; // at 0x4c - s16 mVtxTexCoordIndices[GX_POS_MTX_ARRAY - GX_VA_TEX0]; // at 0x50 - }; - - struct ResTagDL - { - ResCommon mData; - - inline ResTagDL(void * vptr) : mData(vptr) {} - - inline u8 * GetDL() const - { - return const_cast(mData.ofs_to_ptr(mData.ref().mOffset)); - } - - inline u32 GetBufSize() const - { - return mData.ref().mBufSize; - } - - inline u32 GetCmdSize() const - { - return mData.ref().mCmdSize; - } - }; - - struct ResShpPrePrim - { - ResCommon mDL; - - inline ResShpPrePrim(void * vptr) : mDL(vptr) {} - - inline ResPrePrimDL & ref() const - { - return mDL.ref(); - } - }; - - struct ResShp - { - ResCommon mShp; - - inline ResShp(void * vptr) : mShp(vptr) {} - bool IsValid() const { return mShp.IsValid(); } - inline ResShpData & ref() const - { - return mShp.ref(); - } - - inline ResShpPrePrim GetResShpPrePrim() const - { - return ResTagDL(&ref().mPrePrimDLTag).GetDL(); - } - - bool GXGetVtxDescv(GXVtxDescList*) const; - bool GXGetVtxAttrFmtv(GXVtxAttrFmtList*) const; - - ResMdl GetParent() const; //inlined - - ResVtxPos GetResVtxPos() const; - ResVtxNrm GetResVtxNrm() const; - ResVtxClr GetResVtxClr(u32) const; - ResVtxTexCoord GetResVtxTexCoord(u32) const; //inlined - - void GXSetArray(GXAttr, const void *, u8); //inlined - - void Init(); - - void DisableSetArray(GXAttr); //inlined - void Terminate(); - - void CallPrePrimitiveDisplayList(bool, bool) const; - void CallPrimitiveDisplayList(bool) const; - }; - } -} +namespace nw4r { +namespace g3d { +struct ResTagDLData { + u32 mBufSize; // at 0x0 + u32 mCmdSize; // at 0x4 + u32 mOffset; // at 0x8 +}; -#endif \ No newline at end of file +struct ResPrePrimDL { + char UNK_0x0[0xA]; + detail::CPCmd CP_CMD_0xA; + detail::CPCmd CP_CMD_0x10; + char UNK_0x16[0xA]; + detail::CPCmd CP_CMD_0x20; + detail::CPCmd CP_CMD_0x26; + detail::CPCmd CP_CMD_0x2C; + detail::CPCmd CP_CMD_PAIRS_0x32[GX_POS_MTX_ARRAY - GX_VA_POS][2]; + char UNK_0xC2[0x1E]; +}; + +struct ResShpData { + char UNK_0x0[0x4]; + u32 mParentOffset; // at 0x4 + char UNK_0x8[0x10]; + ResTagDLData mPrePrimDLTag; // at 0x18 + ResTagDLData mPrimDLTag; // at 0x24 + char UNK_0x30[0x18]; + + s16 mVtxPosIndex; // at 0x48 + s16 mVtxNrmIndex; // at 0x4a + s16 mVtxClrIndices[GX_VA_TEX0 - GX_VA_CLR0]; // at 0x4c + s16 mVtxTexCoordIndices[GX_POS_MTX_ARRAY - GX_VA_TEX0]; // at 0x50 +}; + +struct ResTagDL { + ResCommon mData; + + inline ResTagDL(void *vptr) : mData(vptr) {} + + inline u8 *GetDL() const { + return const_cast(mData.ofs_to_ptr(mData.ref().mOffset)); + } + + inline u32 GetBufSize() const { + return mData.ref().mBufSize; + } + + inline u32 GetCmdSize() const { + return mData.ref().mCmdSize; + } +}; + +struct ResShpPrePrim { + ResCommon mDL; + + inline ResShpPrePrim(void *vptr) : mDL(vptr) {} + + inline ResPrePrimDL &ref() const { + return mDL.ref(); + } +}; + +struct ResShp { + ResCommon mShp; + + inline ResShp(void *vptr) : mShp(vptr) {} + bool IsValid() const { + return mShp.IsValid(); + } + + inline ResShpData &ref() const { + return mShp.ref(); + } + + inline ResShpPrePrim GetResShpPrePrim() const { + return ResTagDL(&ref().mPrePrimDLTag).GetDL(); + } + + bool GXGetVtxDescv(GXVtxDescList *) const; + bool GXGetVtxAttrFmtv(GXVtxAttrFmtList *) const; + + ResMdl GetParent() const; // inlined + + ResVtxPos GetResVtxPos() const; + ResVtxNrm GetResVtxNrm() const; + ResVtxClr GetResVtxClr(u32) const; + ResVtxTexCoord GetResVtxTexCoord(u32) const; // inlined + + void GXSetArray(GXAttr, const void *, u8); // inlined + + void Init(); + + void DisableSetArray(GXAttr); // inlined + void Terminate(); + + void CallPrePrimitiveDisplayList(bool, bool) const; + void CallPrimitiveDisplayList(bool) const; +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_restex.h b/include/nw4r/g3d/g3d_restex.h index 15283910..9d85d355 100644 --- a/include/nw4r/g3d/g3d_restex.h +++ b/include/nw4r/g3d/g3d_restex.h @@ -1,7 +1,7 @@ #ifndef NW4R_G3D_RESTEX_H #define NW4R_G3D_RESTEX_H +#include "common.h" #include "g3d_rescommon.h" -#include "types_nw4r.h" #include diff --git a/include/nw4r/g3d/g3d_scnmdl.h b/include/nw4r/g3d/g3d_scnmdl.h index f1875981..5f1cb9e9 100644 --- a/include/nw4r/g3d/g3d_scnmdl.h +++ b/include/nw4r/g3d/g3d_scnmdl.h @@ -1,42 +1,39 @@ #ifndef NW4R_G3D_SCN_MDL_H #define NW4R_G3D_SCN_MDL_H -#include "types_nw4r.h" -#include "g3d_scnmdlsmpl.h" -#include "g3d_resmat.h" +#include "common.h" #include "g3d_draw.h" +#include "g3d_resmat.h" +#include "g3d_scnmdlsmpl.h" -namespace nw4r -{ - namespace g3d - { - class ScnMdl : public ScnMdlSimple - { - public: - class CopiedMatAccess - { - public: - CopiedMatAccess(ScnMdl *, u32); - ResTexSrt GetResTexSrtEx(); +namespace nw4r { +namespace g3d { +class ScnMdl : public ScnMdlSimple { +public: + class CopiedMatAccess { + public: + CopiedMatAccess(ScnMdl *, u32); + ResTexSrt GetResTexSrtEx(); - private: - char UNK_0x0[0x2C]; - }; + private: + char UNK_0x0[0x2C]; + }; - public: - static const G3dObj::TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - DrawResMdlReplacement * GetDrawResMdlReplacement() { return &mDrawMdlReplace; } - - private: - char UNK_0x118[0x144 - 0x118]; - DrawResMdlReplacement mDrawMdlReplace; // at 0x144 - - NW4R_G3D_TYPE_OBJ_DECL(ScnMdl); - }; +public: + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); } -} -#endif \ No newline at end of file + DrawResMdlReplacement *GetDrawResMdlReplacement() { + return &mDrawMdlReplace; + } + +private: + char UNK_0x118[0x144 - 0x118]; + DrawResMdlReplacement mDrawMdlReplace; // at 0x144 + + NW4R_G3D_TYPE_OBJ_DECL(ScnMdl); +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_scnmdl1mat1shp.h b/include/nw4r/g3d/g3d_scnmdl1mat1shp.h index 1b55ece6..5e3d3dc9 100644 --- a/include/nw4r/g3d/g3d_scnmdl1mat1shp.h +++ b/include/nw4r/g3d/g3d_scnmdl1mat1shp.h @@ -1,32 +1,32 @@ #ifndef NW4R_G3D_SCN_MDL1_MAT1_SHP_H #define NW4R_G3D_SCN_MDL1_MAT1_SHP_H -#include "types_nw4r.h" -#include "g3d_scnobj.h" +#include "common.h" #include "g3d_resmat.h" #include "g3d_resshp.h" +#include "g3d_scnobj.h" -namespace nw4r -{ - namespace g3d - { - class ScnMdl1Mat1Shp : public ScnLeaf - { - public: - static const G3dObj::TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - ResMat GetResMat() { return mResMat; } - ResShp GetResShp() { return mResShp; } - - private: - ResMat mResMat; // at 0xE8 - ResShp mResShp; // at 0xEC - - NW4R_G3D_TYPE_OBJ_DECL(ScnMdl1Mat1Shp); - }; +namespace nw4r { +namespace g3d { +class ScnMdl1Mat1Shp : public ScnLeaf { +public: + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); } -} -#endif \ No newline at end of file + ResMat GetResMat() { + return mResMat; + } + ResShp GetResShp() { + return mResShp; + } + +private: + ResMat mResMat; // at 0xE8 + ResShp mResShp; // at 0xEC + + NW4R_G3D_TYPE_OBJ_DECL(ScnMdl1Mat1Shp); +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_scnmdlsmpl.h b/include/nw4r/g3d/g3d_scnmdlsmpl.h index 56ae32c0..00ab12a0 100644 --- a/include/nw4r/g3d/g3d_scnmdlsmpl.h +++ b/include/nw4r/g3d/g3d_scnmdlsmpl.h @@ -1,73 +1,77 @@ #ifndef NW4R_G3D_SCN_MDL_SIMPLE_H #define NW4R_G3D_SCN_MDL_SIMPLE_H -#include "types_nw4r.h" -#include "g3d_scnobj.h" +#include "common.h" #include "g3d_resmdl.h" +#include "g3d_scnobj.h" -namespace nw4r -{ - namespace g3d +namespace nw4r { +namespace g3d { +class ScnMdlSimple : public ScnLeaf { +public: + enum ByteCodeType { + BYTE_CODE_CALC, + BYTE_CODE_MIX, + BYTE_CODE_DRAW_OPA, + BYTE_CODE_DRAW_XLU, + }; + +public: + ScnMdlSimple(MEMAllocator *, ResMdl, math::MTX34 *, u32 *, math::MTX34 *, math::MTX33 *, math::MTX34 *, int, int); + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 { - class ScnMdlSimple : public ScnLeaf - { - public: - enum ByteCodeType - { - BYTE_CODE_CALC, - BYTE_CODE_MIX, - BYTE_CODE_DRAW_OPA, - BYTE_CODE_DRAW_XLU, - }; - - public: - ScnMdlSimple(MEMAllocator *, ResMdl, math::MTX34 *, u32 *, - math::MTX34 *, math::MTX33 *, math::MTX34 *, int, int); - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : ScnLeaf::IsDerivedFrom(other); - } - virtual void G3dProc(u32, u32, void *); // at 0xC - virtual ~ScnMdlSimple(); // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - - const u8 * GetByteCode(ByteCodeType) const; - - const ResMdl GetResMdl() const { return mResMdl; } - ResMdl GetResMdl() { return mResMdl; } - - math::MTX34 * GetWldMtxArray() { return mWldMatrixArray; } - u32 * GetWldMtxAttribArray() { return mWldMtxAttribArray; } - - u16 GetNumViewMtx() const { return mNumViewMtx; } - - private: - ResMdl mResMdl; // at 0xE8 - math::MTX34 *mWldMatrixArray; // at 0xEC - u32 *mWldMtxAttribArray; // at 0xF0 - math::MTX34 *PTR_0xF4; - math::MTX33 *PTR_0xF8; - math::MTX34 *PTR_0xFC; - u8 BYTE_0x100; - u8 BYTE_0x101; - u16 mNumViewMtx; // at 0x102 - UNKWORD WORD_0x104; - void *mByteCodeCalc; // at 0x108 - void *mByteCodeMix; // at 0x10C - void *mByteCodeDrawOpa; // at 0x110 - void *mByteCodeDrawXlu; // at 0x114 - - NW4R_G3D_TYPE_OBJ_DECL(ScnMdlSimple); - }; + return (other == GetTypeObjStatic()) ? true : ScnLeaf::IsDerivedFrom(other); + } + virtual void G3dProc(u32, u32, void *); // at 0xC + virtual ~ScnMdlSimple(); // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); } -} -#endif \ No newline at end of file + const u8 *GetByteCode(ByteCodeType) const; + + const ResMdl GetResMdl() const { + return mResMdl; + } + ResMdl GetResMdl() { + return mResMdl; + } + + math::MTX34 *GetWldMtxArray() { + return mWldMatrixArray; + } + u32 *GetWldMtxAttribArray() { + return mWldMtxAttribArray; + } + + u16 GetNumViewMtx() const { + return mNumViewMtx; + } + +private: + ResMdl mResMdl; // at 0xE8 + math::MTX34 *mWldMatrixArray; // at 0xEC + u32 *mWldMtxAttribArray; // at 0xF0 + math::MTX34 *PTR_0xF4; + math::MTX33 *PTR_0xF8; + math::MTX34 *PTR_0xFC; + u8 BYTE_0x100; + u8 BYTE_0x101; + u16 mNumViewMtx; // at 0x102 + UNKWORD WORD_0x104; + void *mByteCodeCalc; // at 0x108 + void *mByteCodeMix; // at 0x10C + void *mByteCodeDrawOpa; // at 0x110 + void *mByteCodeDrawXlu; // at 0x114 + + NW4R_G3D_TYPE_OBJ_DECL(ScnMdlSimple); +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_scnobj.h b/include/nw4r/g3d/g3d_scnobj.h index babda1f0..f10a037e 100644 --- a/include/nw4r/g3d/g3d_scnobj.h +++ b/include/nw4r/g3d/g3d_scnobj.h @@ -1,340 +1,278 @@ #ifndef NW4R_G3D_SCNOBJ_H #define NW4R_G3D_SCNOBJ_H -#include "types_nw4r.h" -#include "math_types.h" -#include "math_geometry.h" +#include "common.h" #include "g3d_obj.h" +#include "math_geometry.h" +#include "math_types.h" -namespace nw4r -{ - namespace g3d +namespace nw4r { +namespace g3d { +namespace { +static inline u32 align4(u32 x) { + return x + 3 & ~3; +} +} // namespace + +struct IScnObjGather { + virtual ~IScnObjGather(); + virtual UNKWORD Add(ScnObj *, bool, bool) = 0; +}; + +class ScnObj : public G3dObj { +public: + enum ForEachResult { FOREACH_RESULT_0, FOREACH_RESULT_1 }; + + enum ScnObjFlag { + FLAG_1 = 0x1, + FLAG_2 = 0x2, + FLAG_4 = 0x4, + FLAG_8 = 0x8, + FLAG_10 = 0x10, + FLAG_20 = 0x20, + FLAG_40 = 0x40, + FLAG_80 = 0x80, + FLAG_10000000 = 0x10000000, + FLAG_20000000 = 0x20000000, + FLAG_40000000 = 0x40000000, + FLAG_80000000 = 0x80000000, + + FLAG_60 = FLAG_40 | FLAG_20 + }; + + enum ScnObjMtxType { MTX_TYPE_0, MTX_TYPE_WORLD, MTX_TYPE_VIEW, MTX_TYPE_MAX }; + + enum Timing { TIMING_1 = 0x1, TIMING_2 = 0x2, TIMING_4 = 0x4 }; + + enum ExecOp { EXEC_OP_1 = 0x1, EXEC_OP_2 = 0x2, EXEC_OP_4 = 0x4 }; + + enum ScnObjBoundingVolumeType { BOUNDING_0, BOUNDING_1, BOUNDING_MAX }; + + enum ScnObjOption { OPTION_VISIBLE = (1 << 0) }; + + typedef ForEachResult (*ForEachAction)(ScnObj *, void *); + +public: + ScnObj(MEMAllocator *); + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 { - namespace - { - static inline u32 align4(u32 x) { return x + 3 & ~3; } + return (other == GetTypeObjStatic()) ? true : G3dObj::IsDerivedFrom(other); + } + virtual void G3dProc(u32, u32, void *) = 0; // at 0xC + virtual ~ScnObj(); // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + virtual ForEachResult ForEach(ForEachAction, void *, bool) = 0; // at 0x1C + virtual bool SetScnObjOption(u32, u32); // at 0x20 + virtual bool GetScnObjOption(u32, u32 *) const; // at 0x24 + virtual f32 GetValueForSortOpa() const; // at 0x28 + virtual f32 GetValueForSortXlu() const; // at 0x2C + virtual void CalcWorldMtx(const math::MTX34 *, u32 *); // at 0x30 + + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + void CalcViewMtx(const math::MTX34 *); + bool SetMtx(ScnObjMtxType, const math::MTX34 *); + bool GetMtx(ScnObjMtxType, math::MTX34 *) const; + void SetPriorityDrawOpa(int); + void SetPriorityDrawXlu(int); + void EnableScnObjCallbackTiming(Timing); + void EnableScnObjCallbackExecOp(ExecOp); + bool SetBoundingVolume(ScnObjBoundingVolumeType, const math::AABB *); + bool GetBoundingVolume(ScnObjBoundingVolumeType, math::AABB *) const; + + const math::MTX34 *GetMtxPtr(ScnObjMtxType type) const { + return &mMatrices[type]; + } + + void SetScnObjFlag(ScnObjFlag f, u32 set) { + if (set) { + mFlags |= f; + } else { + mFlags &= ~f; } + } + bool TestScnObjFlag(ScnObjFlag f) const { + return mFlags & f; + } - struct IScnObjGather - { - virtual ~IScnObjGather(); - virtual UNKWORD Add(ScnObj *, bool, bool) = 0; - }; + inline void CheckCallback_CALC_VIEW(Timing timing, u32 r5, void *r6); + inline void CheckCallback_CALC_MAT(Timing timing, u32 r5, void *r6); + inline void CheckCallback_CALC_WORLD(Timing timing, u32 r5, void *r6); - class ScnObj : public G3dObj - { - public: - enum ForEachResult - { - FOREACH_RESULT_0, - FOREACH_RESULT_1 - }; - - enum ScnObjFlag - { - FLAG_1 = 0x1, - FLAG_2 = 0x2, - FLAG_4 = 0x4, - FLAG_8 = 0x8, - FLAG_10 = 0x10, - FLAG_20 = 0x20, - FLAG_40 = 0x40, - FLAG_80 = 0x80, - FLAG_10000000 = 0x10000000, - FLAG_20000000 = 0x20000000, - FLAG_40000000 = 0x40000000, - FLAG_80000000 = 0x80000000, - - FLAG_60 = FLAG_40 | FLAG_20 - }; - - enum ScnObjMtxType - { - MTX_TYPE_0, - MTX_TYPE_WORLD, - MTX_TYPE_VIEW, - MTX_TYPE_MAX - }; - - enum Timing - { - TIMING_1 = 0x1, - TIMING_2 = 0x2, - TIMING_4 = 0x4 - }; - - enum ExecOp - { - EXEC_OP_1 = 0x1, - EXEC_OP_2 = 0x2, - EXEC_OP_4 = 0x4 - }; - - enum ScnObjBoundingVolumeType - { - BOUNDING_0, - BOUNDING_1, - BOUNDING_MAX - }; - - enum ScnObjOption - { - OPTION_VISIBLE = (1 << 0) - }; - - typedef ForEachResult (* ForEachAction)(ScnObj *, void *); - - public: - ScnObj(MEMAllocator *); - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : G3dObj::IsDerivedFrom(other); - } - virtual void G3dProc(u32, u32, void *) = 0; // at 0xC - virtual ~ScnObj(); // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - virtual ForEachResult ForEach(ForEachAction, void *, bool) = 0; // at 0x1C - virtual bool SetScnObjOption(u32, u32); // at 0x20 - virtual bool GetScnObjOption(u32, u32 *) const; // at 0x24 - virtual f32 GetValueForSortOpa() const; // at 0x28 - virtual f32 GetValueForSortXlu() const; // at 0x2C - virtual void CalcWorldMtx(const math::MTX34 *, u32 *); // at 0x30 - - static const G3dObj::TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - void CalcViewMtx(const math::MTX34 *); - bool SetMtx(ScnObjMtxType, const math::MTX34 *); - bool GetMtx(ScnObjMtxType, math::MTX34 *) const; - void SetPriorityDrawOpa(int); - void SetPriorityDrawXlu(int); - void EnableScnObjCallbackTiming(Timing); - void EnableScnObjCallbackExecOp(ExecOp); - bool SetBoundingVolume(ScnObjBoundingVolumeType, const math::AABB *); - bool GetBoundingVolume(ScnObjBoundingVolumeType, math::AABB *) const; - - const math::MTX34 * GetMtxPtr(ScnObjMtxType type) const - { - return &mMatrices[type]; - } - - void SetScnObjFlag(ScnObjFlag f, u32 set) - { - if (set) - { - mFlags |= f; - } - else - { - mFlags &= ~f; - } - } - bool TestScnObjFlag(ScnObjFlag f) const - { - return mFlags & f; - } - - inline void CheckCallback_CALC_VIEW(Timing timing, u32 r5, void *r6); - inline void CheckCallback_CALC_MAT(Timing timing, u32 r5, void *r6); - inline void CheckCallback_CALC_WORLD(Timing timing, u32 r5, void *r6); - - bool IsG3dProcDisabled(u32 task) const - { - if ((task < 9) && (1 << (task - 1) & mFlags)) return true; - return false; - } - - protected: - math::MTX34 mMatrices[MTX_TYPE_MAX]; // at 0xC - math::AABB mBounds[BOUNDING_MAX]; // at 0x9C - - u32 mFlags; // at 0xCC - u8 mPriorityDrawOpa; // at 0xD0 - u8 mPriorityDrawXlu; // at 0xD1 - u8 BYTE_0xD2; - u8 BYTE_0xD3; - IScnObjCallback *mCallback; // at 0xD4 - u8 mTiming; // at 0xD8 - u8 BYTE_0xD9; - u16 mExecOp; // at 0xDA - - NW4R_G3D_TYPE_OBJ_DECL(ScnObj); - }; - - struct IScnObjCallback - { - virtual ~IScnObjCallback() {} // at 0x8 - virtual void ExecCallback_CALC_WORLD(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0xC - virtual void ExecCallback_CALC_MAT(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0x10 - virtual void ExecCallback_CALC_VIEW(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0x14 - }; - - // Is there a better way of resolving this dependency? - void ScnObj::CheckCallback_CALC_VIEW(Timing timing, u32 r5, void *r6) - { - if (mCallback != NULL) - { - if ((mExecOp & EXEC_OP_4) && (mTiming & timing)) - { - mCallback->ExecCallback_CALC_VIEW(timing, this, r5, r6); - } - } + bool IsG3dProcDisabled(u32 task) const { + if ((task < 9) && (1 << (task - 1) & mFlags)) { + return true; } + return false; + } - void ScnObj::CheckCallback_CALC_MAT(Timing timing, u32 r5, void *r6) - { - if (mCallback != NULL) - { - if ((mExecOp & EXEC_OP_2) && (mTiming & timing)) - { - mCallback->ExecCallback_CALC_MAT(timing, this, r5, r6); - } - } +protected: + math::MTX34 mMatrices[MTX_TYPE_MAX]; // at 0xC + math::AABB mBounds[BOUNDING_MAX]; // at 0x9C + + u32 mFlags; // at 0xCC + u8 mPriorityDrawOpa; // at 0xD0 + u8 mPriorityDrawXlu; // at 0xD1 + u8 BYTE_0xD2; + u8 BYTE_0xD3; + IScnObjCallback *mCallback; // at 0xD4 + u8 mTiming; // at 0xD8 + u8 BYTE_0xD9; + u16 mExecOp; // at 0xDA + + NW4R_G3D_TYPE_OBJ_DECL(ScnObj); +}; + +struct IScnObjCallback { + virtual ~IScnObjCallback() {} // at 0x8 + virtual void ExecCallback_CALC_WORLD(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0xC + virtual void ExecCallback_CALC_MAT(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0x10 + virtual void ExecCallback_CALC_VIEW(ScnObj::Timing, ScnObj *, u32, void *) {} // at 0x14 +}; + +// Is there a better way of resolving this dependency? +void ScnObj::CheckCallback_CALC_VIEW(Timing timing, u32 r5, void *r6) { + if (mCallback != NULL) { + if ((mExecOp & EXEC_OP_4) && (mTiming & timing)) { + mCallback->ExecCallback_CALC_VIEW(timing, this, r5, r6); } - - void ScnObj::CheckCallback_CALC_WORLD(Timing timing, u32 r5, void *r6) - { - if (mCallback != NULL) - { - if ((mExecOp & EXEC_OP_1) && (mTiming & timing)) - { - mCallback->ExecCallback_CALC_WORLD(timing, this, r5, r6); - } - } - } - - class ScnLeaf : public ScnObj - { - public: - // Unofficial name, however GetScaleProperty needs to return an enum to match - enum ScaleProperty - { - SCALE_PROPERTY_0, - SCALE_PROPERTY_1, - SCALE_PROPERTY_2, - }; - - public: - ScnLeaf(MEMAllocator *allocator) : ScnObj(allocator), mScale(1.0f, 1.0f, 1.0f) {} - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : ScnObj::IsDerivedFrom(other); - } - virtual void G3dProc(u32, u32, void *) = 0; // at 0xC - virtual ~ScnLeaf() {} // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - virtual ForEachResult ForEach(ForEachAction, void *, bool); // at 0x1C - virtual bool SetScnObjOption(u32, u32); // at 0x20 - virtual bool GetScnObjOption(u32, u32 *) const; // at 0x24 - virtual void CalcWorldMtx(const math::MTX34 *, u32 *); // at 0x30 - - static const G3dObj::TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - ScaleProperty GetScaleProperty() const; - void DefG3dProcScnLeaf(u32, u32, void *); - - private: - math::VEC3 mScale; - - NW4R_G3D_TYPE_OBJ_DECL(ScnLeaf); - }; - - class ScnGroup : public ScnObj - { - public: - ScnGroup(MEMAllocator *, ScnObj **, u32); - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()) ? true - : ScnObj::IsDerivedFrom(other); - } - virtual void G3dProc(u32, u32, void *); // at 0xC - virtual ~ScnGroup(); // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - virtual ForEachResult ForEach(ForEachAction, void *, bool); // at 0x1C - virtual bool Insert(u32, ScnObj *); // at 0x34 - virtual ScnObj * Remove(u32); // at 0x38 - virtual bool Remove(ScnObj *); // at 0x3C - - static const G3dObj::TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - bool Empty() const - { - return mSize == 0; - } - - u32 Size() const - { - return mSize; - } - - ScnObj * PopBack() - { - if (!Empty()) - { - return Remove(Size() - 1); - } - - return NULL; - } - - void Clear() - { - while (!Empty()) - { - PopBack(); - } - } - - void ScnGroup_G3DPROC_GATHER_SCNOBJ(u32, IScnObjGather *); - void ScnGroup_G3DPROC_CALC_WORLD(u32, const math::MTX34 *); - void ScnGroup_G3DPROC_CALC_MAT(u32, void *); - void ScnGroup_G3DPROC_CALC_VIEW(u32, const math::MTX34 *); - void DefG3dProcScnGroup(u32, u32, void *); - - bool PushBack(ScnObj *); - - ScnObj **mObjects; // at 0xDC - u32 mCapacity; // at 0xE0 - u32 mSize; // at 0xE4 - - private: - NW4R_G3D_TYPE_OBJ_DECL(ScnGroup); - }; } } -#endif \ No newline at end of file +void ScnObj::CheckCallback_CALC_MAT(Timing timing, u32 r5, void *r6) { + if (mCallback != NULL) { + if ((mExecOp & EXEC_OP_2) && (mTiming & timing)) { + mCallback->ExecCallback_CALC_MAT(timing, this, r5, r6); + } + } +} + +void ScnObj::CheckCallback_CALC_WORLD(Timing timing, u32 r5, void *r6) { + if (mCallback != NULL) { + if ((mExecOp & EXEC_OP_1) && (mTiming & timing)) { + mCallback->ExecCallback_CALC_WORLD(timing, this, r5, r6); + } + } +} + +class ScnLeaf : public ScnObj { +public: + // Unofficial name, however GetScaleProperty needs to return an enum to match + enum ScaleProperty { + SCALE_PROPERTY_0, + SCALE_PROPERTY_1, + SCALE_PROPERTY_2, + }; + +public: + ScnLeaf(MEMAllocator *allocator) : ScnObj(allocator), mScale(1.0f, 1.0f, 1.0f) {} + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 + { + return (other == GetTypeObjStatic()) ? true : ScnObj::IsDerivedFrom(other); + } + virtual void G3dProc(u32, u32, void *) = 0; // at 0xC + virtual ~ScnLeaf() {} // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + virtual ForEachResult ForEach(ForEachAction, void *, bool); // at 0x1C + virtual bool SetScnObjOption(u32, u32); // at 0x20 + virtual bool GetScnObjOption(u32, u32 *) const; // at 0x24 + virtual void CalcWorldMtx(const math::MTX34 *, u32 *); // at 0x30 + + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + ScaleProperty GetScaleProperty() const; + void DefG3dProcScnLeaf(u32, u32, void *); + +private: + math::VEC3 mScale; + + NW4R_G3D_TYPE_OBJ_DECL(ScnLeaf); +}; + +class ScnGroup : public ScnObj { +public: + ScnGroup(MEMAllocator *, ScnObj **, u32); + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 + { + return (other == GetTypeObjStatic()) ? true : ScnObj::IsDerivedFrom(other); + } + virtual void G3dProc(u32, u32, void *); // at 0xC + virtual ~ScnGroup(); // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + virtual ForEachResult ForEach(ForEachAction, void *, bool); // at 0x1C + virtual bool Insert(u32, ScnObj *); // at 0x34 + virtual ScnObj *Remove(u32); // at 0x38 + virtual bool Remove(ScnObj *); // at 0x3C + + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + bool Empty() const { + return mSize == 0; + } + + u32 Size() const { + return mSize; + } + + ScnObj *PopBack() { + if (!Empty()) { + return Remove(Size() - 1); + } + + return NULL; + } + + void Clear() { + while (!Empty()) { + PopBack(); + } + } + + void ScnGroup_G3DPROC_GATHER_SCNOBJ(u32, IScnObjGather *); + void ScnGroup_G3DPROC_CALC_WORLD(u32, const math::MTX34 *); + void ScnGroup_G3DPROC_CALC_MAT(u32, void *); + void ScnGroup_G3DPROC_CALC_VIEW(u32, const math::MTX34 *); + void DefG3dProcScnGroup(u32, u32, void *); + + bool PushBack(ScnObj *); + + ScnObj **mObjects; // at 0xDC + u32 mCapacity; // at 0xE0 + u32 mSize; // at 0xE4 + +private: + NW4R_G3D_TYPE_OBJ_DECL(ScnGroup); +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_scnproc.h b/include/nw4r/g3d/g3d_scnproc.h index 0f01d175..45aa86b6 100644 --- a/include/nw4r/g3d/g3d_scnproc.h +++ b/include/nw4r/g3d/g3d_scnproc.h @@ -1,78 +1,76 @@ #ifndef NW4R_G3D_SCNPROC_H #define NW4R_G3D_SCNPROC_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_scnobj.h" -namespace nw4r -{ - namespace g3d - { - class ScnProc : public ScnLeaf - { - public: - typedef void (* DrawProc)(ScnProc *, bool opa); +namespace nw4r { +namespace g3d { +class ScnProc : public ScnLeaf { +public: + typedef void (*DrawProc)(ScnProc *, bool opa); - ScnProc(MEMAllocator *allocator, DrawProc proc, void *userdata, bool set1, bool set2) - : ScnLeaf(allocator), mFlags(0), mDrawProc(proc), mUserData(userdata) - { - if (set1) mFlags |= 0x1; - if (set2) mFlags |= 0x2; - } - - static ScnProc * Construct(MEMAllocator *, u32 *, DrawProc, bool, bool, u32); - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return other == GetTypeObjStatic() ? true - : ScnLeaf::IsDerivedFrom(other); - }; - virtual void G3dProc(u32, u32, void *); // at 0xC - virtual ~ScnProc() {} // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - - static const G3dObj::TypeObj GetTypeObjStatic() { return TypeObj(TYPE_NAME); } - - void * GetUserData() { return mUserData; } - void SetUserData(void *data) { mUserData = data; } - - void SetDrawProc(DrawProc proc, bool r5, bool r6) - { - mDrawProc = proc; - - if (r5) - { - mFlags |= 0x1; - } - else - { - mFlags &= ~0x1; - } - - if (r6) - { - mFlags |= 0x2; - } - else - { - mFlags &= ~0x2; - } - } - - private: - u32 mFlags; // at 0xE8 - DrawProc mDrawProc; // at 0xEC - void *mUserData; // at 0xF0 - - NW4R_G3D_TYPE_OBJ_DECL(ScnProc); - }; + ScnProc(MEMAllocator *allocator, DrawProc proc, void *userdata, bool set1, bool set2) + : ScnLeaf(allocator), mFlags(0), mDrawProc(proc), mUserData(userdata) { + if (set1) { + mFlags |= 0x1; + } + if (set2) { + mFlags |= 0x2; + } } -} -#endif \ No newline at end of file + static ScnProc *Construct(MEMAllocator *, u32 *, DrawProc, bool, bool, u32); + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 + { + return other == GetTypeObjStatic() ? true : ScnLeaf::IsDerivedFrom(other); + }; + virtual void G3dProc(u32, u32, void *); // at 0xC + virtual ~ScnProc() {} // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); + } + + static const G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + + void *GetUserData() { + return mUserData; + } + void SetUserData(void *data) { + mUserData = data; + } + + void SetDrawProc(DrawProc proc, bool r5, bool r6) { + mDrawProc = proc; + + if (r5) { + mFlags |= 0x1; + } else { + mFlags &= ~0x1; + } + + if (r6) { + mFlags |= 0x2; + } else { + mFlags &= ~0x2; + } + } + +private: + u32 mFlags; // at 0xE8 + DrawProc mDrawProc; // at 0xEC + void *mUserData; // at 0xF0 + + NW4R_G3D_TYPE_OBJ_DECL(ScnProc); +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_scnrfl.h b/include/nw4r/g3d/g3d_scnrfl.h index 2ccba439..cca91279 100644 --- a/include/nw4r/g3d/g3d_scnrfl.h +++ b/include/nw4r/g3d/g3d_scnrfl.h @@ -1,56 +1,51 @@ #ifndef NW4R_G3D_SCNRFL_H #define NW4R_G3D_SCNRFL_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_scnleaf.h" -#include #include +#include -namespace nw4r -{ - namespace g3d +namespace nw4r { +namespace g3d { +class ScnRfl : public ScnLeaf { +public: + struct RflData { + bool SetupCharModel(RFLDataSource, u16, RFLMiddleDB *); + }; + +public: + static ScnRfl *Construct(MEMAllocator *, u32 *, RFLResolution, u32, u32); + ScnRfl(MEMAllocator *, ScnRfl *, RflData *, void *, u32); + + virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 { - class ScnRfl : public ScnLeaf - { - public: - struct RflData - { - bool SetupCharModel(RFLDataSource, u16, RFLMiddleDB *); - }; - - public: - static ScnRfl * Construct(MEMAllocator *, u32 *, RFLResolution, u32, u32); - ScnRfl(MEMAllocator *, ScnRfl *, RflData *, void *, u32); - - virtual bool IsDerivedFrom(TypeObj other) const // at 0x8 - { - return (other == GetTypeObjStatic()); - } - virtual void G3dProc(u32, u32, void *); // at 0xC - virtual ~ScnRfl(); // at 0x10 - virtual const TypeObj GetTypeObj() const // at 0x14 - { - return TypeObj(TYPE_NAME); - } - virtual const char * GetTypeName() const // at 0x18 - { - return GetTypeObj().GetTypeName(); - } - - bool GetExpression(RFLExpression *); - bool SetExpression(RFLExpression); - - void SetFogIdx(int); - void SetLightSetIdx(int); - - static const nw4r::g3d::G3dObj::TypeObj GetTypeObjStatic() - { - return TypeObj(TYPE_NAME); - } - - private: - NW4R_G3D_TYPE_OBJ_DECL(ScnRfl); - }; + return (other == GetTypeObjStatic()); + } + virtual void G3dProc(u32, u32, void *); // at 0xC + virtual ~ScnRfl(); // at 0x10 + virtual const TypeObj GetTypeObj() const // at 0x14 + { + return TypeObj(TYPE_NAME); + } + virtual const char *GetTypeName() const // at 0x18 + { + return GetTypeObj().GetTypeName(); } -} -#endif \ No newline at end of file + bool GetExpression(RFLExpression *); + bool SetExpression(RFLExpression); + + void SetFogIdx(int); + void SetLightSetIdx(int); + + static const nw4r::g3d::G3dObj::TypeObj GetTypeObjStatic() { + return TypeObj(TYPE_NAME); + } + +private: + NW4R_G3D_TYPE_OBJ_DECL(ScnRfl); +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_scnroot.h b/include/nw4r/g3d/g3d_scnroot.h index 8c3fb797..bfd9a9b3 100644 --- a/include/nw4r/g3d/g3d_scnroot.h +++ b/include/nw4r/g3d/g3d_scnroot.h @@ -1,41 +1,40 @@ #ifndef NW4R_G3D_SCNROOT_H #define NW4R_G3D_SCNROOT_H -#include "types_nw4r.h" -#include "g3d_scnobj.h" +#include "common.h" #include "g3d_camera.h" #include "g3d_fog.h" +#include "g3d_scnobj.h" -namespace nw4r -{ - namespace g3d - { - class ScnRoot : public ScnGroup - { - public: - Camera GetCamera(int); - Camera GetCurrentCamera(); - void SetCurrentCamera(int); - Fog GetFog(int); +namespace nw4r { +namespace g3d { +class ScnRoot : public ScnGroup { +public: + Camera GetCamera(int); + Camera GetCurrentCamera(); + void SetCurrentCamera(int); + Fog GetFog(int); - void UpdateFrame(); - void CalcWorld(); - void CalcMaterial(); - void CalcVtx(); - void CalcView(); - void GatherDrawScnObj(); - void ZSort(); - void DrawOpa(); - void DrawXlu(); + void UpdateFrame(); + void CalcWorld(); + void CalcMaterial(); + void CalcVtx(); + void CalcView(); + void GatherDrawScnObj(); + void ZSort(); + void DrawOpa(); + void DrawXlu(); - u8 GetCurrentCameraID() const { return mCameraId; } - - private: - UNKWORD WORD_0xE8; - UNKWORD WORD_0xEC; - UNKWORD WORD_0xF0; - u8 mCameraId; - }; + u8 GetCurrentCameraID() const { + return mCameraId; } -} -#endif \ No newline at end of file +private: + UNKWORD WORD_0xE8; + UNKWORD WORD_0xEC; + UNKWORD WORD_0xF0; + u8 mCameraId; +}; +} // namespace g3d +} // namespace nw4r + +#endif diff --git a/include/nw4r/g3d/g3d_state.h b/include/nw4r/g3d/g3d_state.h index 5b7b87e8..0f16769f 100644 --- a/include/nw4r/g3d/g3d_state.h +++ b/include/nw4r/g3d/g3d_state.h @@ -1,6 +1,6 @@ #ifndef NW4R_G3D_STATE_H #define NW4R_G3D_STATE_H -#include "types_nw4r.h" +#include "common.h" #include namespace nw4r { diff --git a/include/nw4r/g3d/g3d_tmem.h b/include/nw4r/g3d/g3d_tmem.h index 749156de..6ab71c9b 100644 --- a/include/nw4r/g3d/g3d_tmem.h +++ b/include/nw4r/g3d/g3d_tmem.h @@ -1,22 +1,15 @@ #ifndef NW4R_G3D_TMEM_H #define NW4R_G3D_TMEM_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace g3d - { - namespace tmem - { - enum TMemLayout - { - TMEM_LAYOUT_0, - TMEM_LAYOUT_1 - }; +namespace nw4r { +namespace g3d { +namespace tmem { +enum TMemLayout { TMEM_LAYOUT_0, TMEM_LAYOUT_1 }; - void SetTMemLayout(TMemLayout); - } - } -} +void SetTMemLayout(TMemLayout); +} // namespace tmem +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_workmem.h b/include/nw4r/g3d/g3d_workmem.h index 3f0ca444..0a03d1f2 100644 --- a/include/nw4r/g3d/g3d_workmem.h +++ b/include/nw4r/g3d/g3d_workmem.h @@ -1,26 +1,22 @@ #ifndef NW4R_G3D_WORKMEM_H #define NW4R_G3D_WORKMEM_H -#include "types_nw4r.h" +#include "common.h" #define G3D_WORKMEM_SIZE 0x18000 -namespace nw4r -{ - namespace g3d - { - namespace detail - { - namespace workmem - { - void * GetScaleTemporary(); - void * GetMtxIDTemporary(); - void * GetMdlZTemporary(); - void * GetSkinningMtxTemporary(); - void * GetBillboardMtxTemporary(); - void * GetShpAnmResultBufTemporary(); - } - } - } -} +namespace nw4r { +namespace g3d { +namespace detail { +namespace workmem { +void *GetScaleTemporary(); +void *GetMtxIDTemporary(); +void *GetMdlZTemporary(); +void *GetSkinningMtxTemporary(); +void *GetBillboardMtxTemporary(); +void *GetShpAnmResultBufTemporary(); +} // namespace workmem +} // namespace detail +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/g3d/g3d_xsi.h b/include/nw4r/g3d/g3d_xsi.h index 939e6a19..fb812e49 100644 --- a/include/nw4r/g3d/g3d_xsi.h +++ b/include/nw4r/g3d/g3d_xsi.h @@ -1,20 +1,16 @@ #ifndef NW4R_G3D_XSI_H #define NW4R_G3D_XSI_H -#include "types_nw4r.h" +#include "common.h" #include "g3d_anmtexsrt.h" -namespace nw4r -{ - namespace g3d - { - namespace detail - { - namespace dcc - { - bool CalcTexMtx_Xsi(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag); - } - } - } +namespace nw4r { +namespace g3d { +namespace detail { +namespace dcc { +bool CalcTexMtx_Xsi(math::MTX34 *, bool, const TexSrt &, TexSrt::Flag); } +} // namespace detail +} // namespace g3d +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/lyt/lyt_animation.h b/include/nw4r/lyt/lyt_animation.h index a9303e03..fd26da01 100644 --- a/include/nw4r/lyt/lyt_animation.h +++ b/include/nw4r/lyt/lyt_animation.h @@ -1,82 +1,69 @@ #ifndef NW4R_LYT_ANIMATION_H #define NW4R_LYT_ANIMATION_H -#include "types_nw4r.h" -#include "ut_LinkList.h" -#include "lyt_resourceAccessor.h" -#include "lyt_common.h" +#include "common.h" +#include "nw4r/lyt/lyt_common.h" +#include "nw4r/lyt/lyt_resourceAccessor.h" +#include "nw4r/ut/ut_LinkList.h" -namespace nw4r -{ - namespace lyt - { - namespace res - { - struct AnimationBlock - { - - }; - } +namespace nw4r { +namespace lyt { +namespace res { +struct AnimationBlock {}; +} // namespace res - struct AnimationBlock - { - res::DataBlockHeader header; // at 0x0 - u16 frameSize; // at 0x8 - bool loop; // at 0xA - // . . . - }; +struct AnimationBlock { + res::DataBlockHeader header; // at 0x0 + u16 frameSize; // at 0x8 + bool loop; // at 0xA + // . . . +}; - struct AnimTransform - { - inline AnimTransform() : mNode(), mResource(NULL), mFrame(0.0f) {} +struct AnimTransform { + inline AnimTransform() : mNode(), mResource(NULL), mFrame(0.0f) {} - u16 GetFrameSize() const; - bool IsLoopData() const; + u16 GetFrameSize() const; + bool IsLoopData() const; - ut::LinkListNode mNode; // at 0x0 - AnimationBlock *mResource; // at 0xC - f32 mFrame; // at 0x10 - }; + ut::LinkListNode mNode; // at 0x0 + AnimationBlock *mResource; // at 0xC + f32 mFrame; // at 0x10 +}; - struct AnimTransformBasic : AnimTransform - { - AnimTransformBasic(); - virtual ~AnimTransformBasic(); - virtual UNKTYPE SetResource(const res::AnimationBlock *, ResourceAccessor *); - virtual UNKTYPE Bind(Pane *, bool); - virtual UNKTYPE Bind(Material *); - virtual UNKTYPE Animate(u32, Pane *); - virtual UNKTYPE Animate(u32, Material *); +struct AnimTransformBasic : AnimTransform { + AnimTransformBasic(); + virtual ~AnimTransformBasic(); + virtual UNKTYPE SetResource(const res::AnimationBlock *, ResourceAccessor *); + virtual UNKTYPE Bind(Pane *, bool); + virtual UNKTYPE Bind(Material *); + virtual UNKTYPE Animate(u32, Pane *); + virtual UNKTYPE Animate(u32, Material *); - u32 INT_0x14; - u32 INT_0x18; - u16 INT_0x1C; - }; + u32 INT_0x14; + u32 INT_0x18; + u16 INT_0x1C; +}; - struct AnimationLink - { - inline AnimationLink() : mNode() - { - Reset(); - } - - inline void Reset() - { - Set(NULL, 0, false); - } - - inline void Set(AnimTransform *pTransform, u16 us, bool b) - { - mTransform = pTransform; - SHORT_0xC = us; - BOOL_0xE = b; - } - - ut::LinkListNode mNode; // at 0x0 - AnimTransform *mTransform; // at 0x8 - u16 SHORT_0xC; - bool BOOL_0xE; - }; +struct AnimationLink { + inline AnimationLink() : mNode() { + Reset(); } -} -#endif \ No newline at end of file + inline void Reset() { + Set(NULL, 0, false); + } + + inline void Set(AnimTransform *pTransform, u16 us, bool b) { + mTransform = pTransform; + SHORT_0xC = us; + BOOL_0xE = b; + } + + ut::LinkListNode mNode; // at 0x0 + AnimTransform *mTransform; // at 0x8 + u16 SHORT_0xC; + bool BOOL_0xE; +}; +} // namespace lyt +} // namespace nw4r + +#endif diff --git a/include/nw4r/lyt/lyt_arcResourceAccessor.h b/include/nw4r/lyt/lyt_arcResourceAccessor.h index 7c5e86ae..505639b2 100644 --- a/include/nw4r/lyt/lyt_arcResourceAccessor.h +++ b/include/nw4r/lyt/lyt_arcResourceAccessor.h @@ -1,13 +1,12 @@ #ifndef NW4R_LYT_ARC_RESOURCE_ACCESSOR_H #define NW4R_LYT_ARC_RESOURCE_ACCESSOR_H +#include "common.h" #include "lyt_resourceAccessor.h" -#include "types_nw4r.h" -#include "ut_Font.h" -#include "ut_LinkList.h" +#include "nw4r/ut/ut_Font.h" +#include "nw4r/ut/ut_LinkList.h" #include #include - #define FONTNAMEBUF_MAX 127 namespace nw4r { diff --git a/include/nw4r/lyt/lyt_bounding.h b/include/nw4r/lyt/lyt_bounding.h index 7dcc2013..56740463 100644 --- a/include/nw4r/lyt/lyt_bounding.h +++ b/include/nw4r/lyt/lyt_bounding.h @@ -1,36 +1,26 @@ #ifndef NW4R_LYT_BOUNDING_H #define NW4R_LYT_BOUNDING_H -#include "types_nw4r.h" -#include "lyt_pane.h" -#include "lyt_drawInfo.h" +#include "common.h" +#include "nw4r/lyt/lyt_drawInfo.h" +#include "nw4r/lyt/lyt_pane.h" -namespace nw4r -{ - namespace lyt - { - namespace res - { - struct Bounding : Pane - { +namespace nw4r { +namespace lyt { +namespace res { +struct Bounding : Pane {}; +} // namespace res - }; - } +struct ResBlockSet {}; - struct ResBlockSet - { +struct Bounding : Pane { + Bounding(const res::Bounding *, const ResBlockSet &); + virtual ~Bounding(); + virtual const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const; + virtual void DrawSelf(const DrawInfo &); - }; + static ut::detail::RuntimeTypeInfo typeInfo; +}; +} // namespace lyt +} // namespace nw4r - struct Bounding : Pane - { - Bounding(const res::Bounding *, const ResBlockSet&); - virtual ~Bounding(); - virtual const ut::detail::RuntimeTypeInfo * GetRuntimeTypeInfo() const; - virtual void DrawSelf(const DrawInfo&); - - static ut::detail::RuntimeTypeInfo typeInfo; - }; - } -} - -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/lyt/lyt_common.h b/include/nw4r/lyt/lyt_common.h index af80950b..7b488f63 100644 --- a/include/nw4r/lyt/lyt_common.h +++ b/include/nw4r/lyt/lyt_common.h @@ -1,60 +1,53 @@ #ifndef NW4R_LYT_COMMON_H #define NW4R_LYT_COMMON_H -#include "types_nw4r.h" -#include "math_types.h" -#include "ut_binaryFileFormat.h" +#include "common.h" +#include "nw4r/math/math_types.h" +#include "nw4r/ut/ut_binaryFileFormat.h" #define NW4R_RES_NAME_SIZE 16 #define NW4R_MAT_NAME_SIZE 20 #define TEXCOORD_VTX_COUNT 4 -namespace nw4r -{ - namespace lyt - { - namespace res - { - struct BinaryFileHeader : ut::BinaryFileHeader - { +namespace nw4r { +namespace lyt { +namespace res { +struct BinaryFileHeader : ut::BinaryFileHeader {}; - }; +struct DataBlockHeader { + u32 kind; // at 0x0 + u32 size; // at 0x4 +}; +} // namespace res - struct DataBlockHeader { - u32 kind; // at 0x0 - u32 size; // at 0x4 - }; - } +namespace detail { +typedef math::VEC2 TexCoordData[TEXCOORD_VTX_COUNT]; - namespace detail - { - typedef math::VEC2 TexCoordData[TEXCOORD_VTX_COUNT]; - - struct TexCoordAry - { - TexCoordAry(); - void Free(); - void Reserve(u8); - void SetSize(u8); - void Copy(const void *, u8); +struct TexCoordAry { + TexCoordAry(); + void Free(); + void Reserve(u8); + void SetSize(u8); + void Copy(const void *, u8); - u8 mCap; // at 0x0 - u8 mSize; // at 0x1 - TexCoordData *mTexCoords; // at 0x4 - }; + u8 mCap; // at 0x0 + u8 mNum; // at 0x1 + TexCoordData *mpData; // at 0x4 +}; - bool EqualsResName(const char *, const char *); - bool EqualsMaterialName(const char *, const char *); - bool TestFileHeader(const res::BinaryFileHeader&); - bool TestFileHeader(const res::BinaryFileHeader&, u32); - bool IsModulateVertexColor(ut::Color *, u8); - void MultipleAlpha(ut::Color *, const ut::Color *, u8); // Inlined - ut::Color MultipleAlpha(ut::Color, u8); - void SetVertexFormat(bool, u8); - void DrawQuad(const math::VEC2&, const Size&, u8, const TexCoordData *, const ut::Color *); - void DrawQuad(const math::VEC2&, const Size&, u8, const TexCoordData *, const ut::Color *, u8); - } - } -} +bool EqualsResName(const char *, const char *); +bool EqualsMaterialName(const char *, const char *); +bool TestFileHeader(const res::BinaryFileHeader &); +bool TestFileHeader(const res::BinaryFileHeader &, u32); +bool IsModulateVertexColor(ut::Color *, u8); +void MultipleAlpha(ut::Color *, const ut::Color *, u8); // Inlined +ut::Color MultipleAlpha(ut::Color, u8); +void SetVertexFormat(bool, u8); +void DrawQuad(const math::VEC2 &, const Size &, u8, const TexCoordData *, const ut::Color *); +void DrawQuad(const math::VEC2 &, const Size &, u8, const TexCoordData *, const ut::Color *, u8); +void DrawLine(const math::VEC2 &pos, const Size &size, ut::Color color); +} // namespace detail +} // namespace lyt +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/lyt/lyt_drawInfo.h b/include/nw4r/lyt/lyt_drawInfo.h index 8aab5fcc..636a1b4e 100644 --- a/include/nw4r/lyt/lyt_drawInfo.h +++ b/include/nw4r/lyt/lyt_drawInfo.h @@ -1,25 +1,22 @@ #ifndef NW4R_LYT_DRAWINFO_H #define NW4R_LYT_DRAWINFO_H -#include "types_nw4r.h" -#include "math_types.h" -#include "ut_Rect.h" +#include "common.h" +#include "nw4r/math/math_types.h" +#include "nw4r/ut/ut_Rect.h" -namespace nw4r -{ - namespace lyt - { - struct DrawInfo - { - virtual ~DrawInfo(); - DrawInfo(); +namespace nw4r { +namespace lyt { +struct DrawInfo { + virtual ~DrawInfo(); + DrawInfo(); - math::MTX34 mViewMtx; // at 0x0 - ut::Rect mViewRect; // at 0x34 - math::VEC2 mScale; // at 0x44 - f32 mGlobalAlpha; // at 0x48 - u8 mFlags; // at 0x50 - }; - } -} + math::MTX34 mViewMtx; // at 0x0 + ut::Rect mViewRect; // at 0x34 + math::VEC2 mScale; // at 0x44 + f32 mGlobalAlpha; // at 0x48 + u8 mFlags; // at 0x50 +}; +} // namespace lyt +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/lyt/lyt_group.h b/include/nw4r/lyt/lyt_group.h index efe17ac0..b12a8665 100644 --- a/include/nw4r/lyt/lyt_group.h +++ b/include/nw4r/lyt/lyt_group.h @@ -1,55 +1,47 @@ #ifndef NW4R_LYT_GROUP_H #define NW4R_LYT_GROUP_H -#include "types_nw4r.h" -#include "lyt_pane.h" -#include "lyt_common.h" -#include "ut_LinkList.h" +#include "common.h" +#include "nw4r/lyt/lyt_common.h" +#include "nw4r/lyt/lyt_pane.h" +#include "nw4r/ut/ut_LinkList.h" -namespace nw4r -{ - namespace lyt - { - namespace res - { - struct Group - { - char UNK_0x0[0x8]; - char mName[NW4R_RES_NAME_SIZE]; // at 0x8 - u16 SHORT_0x18; - }; - } +namespace nw4r { +namespace lyt { +namespace res { +struct Group { + char UNK_0x0[0x8]; + char mName[NW4R_RES_NAME_SIZE]; // at 0x8 + u16 SHORT_0x18; +}; +} // namespace res - namespace detail - { - struct PaneLink - { - ut::LinkListNode mNode; // at 0x0 - Pane *PANE_0x8; - }; - } +namespace detail { +struct PaneLink { + ut::LinkListNode mNode; // at 0x0 + Pane *PANE_0x8; +}; +} // namespace detail - struct Group - { - Group(const res::Group *, Pane *); - virtual ~Group(); - void AppendPane(Pane *); - void Init(); +struct Group { + Group(const res::Group *, Pane *); + virtual ~Group(); + void AppendPane(Pane *); + void Init(); - ut::LinkListNode mNode; // at 0x4 - ut::LinkList mPaneList; // at 0xC - char mName[NW4R_RES_NAME_SIZE]; // at 0x18 - bool mIsUserAllocated; // at 0x29 - }; + ut::LinkListNode mNode; // at 0x4 + ut::LinkList mPaneList; // at 0xC + char mName[NW4R_RES_NAME_SIZE]; // at 0x18 + bool mIsUserAllocated; // at 0x29 +}; - struct GroupContainer - { - ~GroupContainer(); - void AppendGroup(Group *); - Group * FindGroupByName(const char *); +struct GroupContainer { + ~GroupContainer(); + void AppendGroup(Group *); + Group *FindGroupByName(const char *); - ut::LinkList mGroups; // at 0x4 - }; - } -} + ut::LinkList mGroups; // at 0x4 +}; +} // namespace lyt +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/lyt/lyt_layout.h b/include/nw4r/lyt/lyt_layout.h index 6f052a0b..156e13f3 100644 --- a/include/nw4r/lyt/lyt_layout.h +++ b/include/nw4r/lyt/lyt_layout.h @@ -1,7 +1,7 @@ #ifndef NW4R_LYT_LAYOUT_H #define NW4R_LYT_LAYOUT_H -#include "types_nw4r.h" -#include +#include "common.h" +#include #include namespace nw4r { @@ -19,11 +19,13 @@ struct Layout { template static void DeleteArray(T *p, size_t n) { - for (size_t i = 0; i < n; i++) { - p[i].~T(); - } + if (p) { + for (size_t i = 0; i < n; i++) { + p[i].~T(); + } - FreeMemory(p); + FreeMemory(p); + } } template diff --git a/include/nw4r/lyt/lyt_material.h b/include/nw4r/lyt/lyt_material.h index 4b2e76ac..fec6d500 100644 --- a/include/nw4r/lyt/lyt_material.h +++ b/include/nw4r/lyt/lyt_material.h @@ -1,10 +1,9 @@ #ifndef NW4R_LYT_MATERIAL_H #define NW4R_LYT_MATERIAL_H -#include "lyt_animation.h" -#include "ut_LinkList.h" +#include "nw4r/lyt/lyt_animation.h" +#include "nw4r/ut/ut_LinkList.h" #include - namespace nw4r { namespace lyt { // TO-DO diff --git a/include/nw4r/lyt/lyt_pane.h b/include/nw4r/lyt/lyt_pane.h index 28acbb6d..b31f2ccb 100644 --- a/include/nw4r/lyt/lyt_pane.h +++ b/include/nw4r/lyt/lyt_pane.h @@ -1,157 +1,139 @@ #ifndef NW4R_LYT_PANE_H #define NW4R_LYT_PANE_H -#include "types_nw4r.h" -#include "math_types.h" -#include "ut_LinkList.h" -#include "ut_RuntimeTypeInfo.h" -#include "ut_Color.h" -#include "ut_algorithm.h" -#include "lyt_animation.h" -#include +#include "common.h" +#include "nw4r/lyt/lyt_animation.h" +#include "nw4r/math/math_types.h" +#include "nw4r/ut/ut_Color.h" +#include "nw4r/ut/ut_LinkList.h" +#include "nw4r/ut/ut_RuntimeTypeInfo.h" +#include "nw4r/ut/ut_algorithm.h" +#include #define PANE_NAME_SIZE 17 #define PANE_USERDATA_SIZE 9 #define ANIMTARGET_PANE_MAX 10 -namespace nw4r -{ - namespace lyt - { - void LytInit(); +namespace nw4r { +namespace lyt { +void LytInit(); - struct Size - { - inline Size() : x(), y() {} +struct Size { + inline Size() : x(), y() {} - inline Size& operator=(const Size& rhs) - { - x = rhs.x; - y = rhs.y; - return *this; - } - - f32 x, y; - }; - - namespace detail - { - struct PaneBase - { - inline PaneBase() : mNode() {} - - virtual ~PaneBase(); - ut::LinkListNode mNode; // at 0x4 - }; - } - - namespace res - { - struct Pane - { - u32 mMagic; // "pan1", at 0x0 - u32 mLength; // at 0x4 - u8 BYTE_0x8; - u8 BYTE_0x9; - u8 BYTE_0xA; - u8 BYTE_0xB; // NO REFERENCES - char mName[PANE_NAME_SIZE]; // at 0xC - char mUserData[PANE_USERDATA_SIZE]; // at 0x1C - math::VEC3 VEC3_0x24; - math::VEC3 VEC3_0x30; - math::VEC2 VEC2_0x3C; - Size mSize; // at 0x44 - }; - } - - struct Pane : detail::PaneBase - { - // For use with TestBit - enum PaneBits - { - VISIBLE, - INFLUENCED_ALPHA, - LOCATION_ADJUST - }; - - inline void Init() - { - mParent = NULL; - mMaterial = NULL; - BYTE_0xD6 = 0; - INT_0xB4 = 0; - } - - inline void SetName(const char *pName) - { - strncpy(mName, pName, PANE_NAME_SIZE); - mName[PANE_NAME_SIZE - 1] = '\0'; - } - - inline void SetUserData(const char *pData) - { - strncpy(mUserData, pData, PANE_USERDATA_SIZE); - mUserData[PANE_USERDATA_SIZE - 1] = '\0'; - } - - inline void InsertChild(ut::LinkList::Iterator iter, lyt::Pane *pChild) - { - mChildren.Insert(iter, pChild); - pChild->mParent = this; - } - - Pane(const res::Pane *); - virtual ~Pane(); // at 0x8 - virtual const ut::detail::RuntimeTypeInfo * GetRuntimeTypeInfo() const; // at 0xC - virtual UNKTYPE CalculateMtx(const DrawInfo&); // at 0x10 - virtual UNKTYPE Draw(const DrawInfo&); // at 0x14 - virtual void DrawSelf(const DrawInfo&); // at 0x18 - virtual UNKTYPE Animate(u32); // at 0x1C - virtual UNKTYPE AnimateSelf(u32); // at 0x20 - virtual ut::Color GetVtxColor(u32) const; // at 0x24 - virtual void SetVtxColor(u32, ut::Color); // at 0x28 - virtual UNKTYPE GetColorElement(u32) const; // at 0x2C - virtual UNKTYPE SetColorElement(u32, u8); // at 0x30 - virtual u8 GetVtxColorElement(u32) const; // at 0x34 - virtual void SetVtxColorElement(u32, u8); // at 0x38 - virtual Pane * FindPaneByName(const char *, bool); // at 0x3C - virtual UNKTYPE FindMaterialByName(const char *, bool); // at 0x40 - virtual UNKTYPE BindAnimation(AnimTransform *, bool); // at 0x44 - virtual UNKTYPE UnbindAnimation(AnimTransform *, bool); // at 0x48 - virtual UNKTYPE UnbindAllAnimation(bool); // at 0x4C - virtual UNKTYPE UnbindAnimationSelf(AnimTransform *); // at 0x50 - virtual UNKTYPE FindAnimationLink(AnimTransform *); // at 0x54 - virtual UNKTYPE SetAnimationEnable(AnimTransform *, bool, bool); // at 0x58 - virtual UNKTYPE GetMaterial() const; // at 0x5C - virtual UNKTYPE LoadMtx(const DrawInfo&); // at 0x60 - void AppendChild(Pane *); - void RemoveChild(Pane *); - UNKTYPE GetPaneRect(const DrawInfo&) const; - UNKTYPE AddAnimationLink(AnimationLink *); - UNKTYPE GetVtxPos() const; - - ut::LinkListNode mNode; // at 0x4 - Pane *mParent; // at 0x8 - ut::LinkList mChildren; // at 0x14 - ut::LinkList mAnims; // at 0x20; - Material *mMaterial; // at 0x2C - math::VEC3 mTranslate; // at 0x30 - math::VEC3 VEC3_0x3C; - math::VEC2 mScale; // at 0x48 - Size mSize; // at 0x50 - math::MTX34 MTX34_0x58; - math::MTX34 mGlobalMtx; // at 0x84 - int INT_0xB4; - u8 mAlpha; // at 0xB8 - u8 BYTE_0xB9; - u8 BYTE_0xBA; - u8 mFlags; // at 0xBB - char mName[PANE_NAME_SIZE]; // at 0xBC - char mUserData[PANE_USERDATA_SIZE]; // at 0xCD - u8 BYTE_0xD6; - - static ut::detail::RuntimeTypeInfo typeInfo; - }; + inline Size &operator=(const Size &rhs) { + x = rhs.x; + y = rhs.y; + return *this; } -} -#endif \ No newline at end of file + f32 x, y; +}; + +namespace detail { +struct PaneBase { + inline PaneBase() : mNode() {} + + virtual ~PaneBase(); + ut::LinkListNode mNode; // at 0x4 +}; +} // namespace detail + +namespace res { +struct Pane { + u32 mMagic; // "pan1", at 0x0 + u32 mLength; // at 0x4 + u8 BYTE_0x8; + u8 BYTE_0x9; + u8 BYTE_0xA; + u8 BYTE_0xB; // NO REFERENCES + char mName[PANE_NAME_SIZE]; // at 0xC + char mUserData[PANE_USERDATA_SIZE]; // at 0x1C + math::VEC3 VEC3_0x24; + math::VEC3 VEC3_0x30; + math::VEC2 VEC2_0x3C; + Size mSize; // at 0x44 +}; +} // namespace res + +struct Pane : detail::PaneBase { + // For use with TestBit + enum PaneBits { VISIBLE, INFLUENCED_ALPHA, LOCATION_ADJUST }; + + inline void Init() { + mParent = NULL; + mMaterial = NULL; + BYTE_0xD6 = 0; + INT_0xB4 = 0; + } + + inline void SetName(const char *pName) { + strncpy(mName, pName, PANE_NAME_SIZE); + mName[PANE_NAME_SIZE - 1] = '\0'; + } + + inline void SetUserData(const char *pData) { + strncpy(mUserData, pData, PANE_USERDATA_SIZE); + mUserData[PANE_USERDATA_SIZE - 1] = '\0'; + } + + inline void InsertChild(ut::LinkList::Iterator iter, lyt::Pane *pChild) { + mChildren.Insert(iter, pChild); + pChild->mParent = this; + } + + Pane(const res::Pane *); + virtual ~Pane(); // at 0x8 + virtual const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const; // at 0xC + virtual UNKTYPE CalculateMtx(const DrawInfo &); // at 0x10 + virtual UNKTYPE Draw(const DrawInfo &); // at 0x14 + virtual void DrawSelf(const DrawInfo &); // at 0x18 + virtual UNKTYPE Animate(u32); // at 0x1C + virtual UNKTYPE AnimateSelf(u32); // at 0x20 + virtual ut::Color GetVtxColor(u32) const; // at 0x24 + virtual void SetVtxColor(u32, ut::Color); // at 0x28 + virtual UNKTYPE GetColorElement(u32) const; // at 0x2C + virtual UNKTYPE SetColorElement(u32, u8); // at 0x30 + virtual u8 GetVtxColorElement(u32) const; // at 0x34 + virtual void SetVtxColorElement(u32, u8); // at 0x38 + virtual Pane *FindPaneByName(const char *, bool); // at 0x3C + virtual UNKTYPE FindMaterialByName(const char *, bool); // at 0x40 + virtual UNKTYPE BindAnimation(AnimTransform *, bool); // at 0x44 + virtual UNKTYPE UnbindAnimation(AnimTransform *, bool); // at 0x48 + virtual UNKTYPE UnbindAllAnimation(bool); // at 0x4C + virtual UNKTYPE UnbindAnimationSelf(AnimTransform *); // at 0x50 + virtual UNKTYPE FindAnimationLink(AnimTransform *); // at 0x54 + virtual UNKTYPE SetAnimationEnable(AnimTransform *, bool, bool); // at 0x58 + virtual UNKTYPE GetMaterial() const; // at 0x5C + virtual UNKTYPE LoadMtx(const DrawInfo &); // at 0x60 + void AppendChild(Pane *); + void RemoveChild(Pane *); + UNKTYPE GetPaneRect(const DrawInfo &) const; + UNKTYPE AddAnimationLink(AnimationLink *); + UNKTYPE GetVtxPos() const; + + ut::LinkListNode mNode; // at 0x4 + Pane *mParent; // at 0x8 + ut::LinkList mChildren; // at 0x14 + ut::LinkList mAnims; // at 0x20; + Material *mMaterial; // at 0x2C + math::VEC3 mTranslate; // at 0x30 + math::VEC3 VEC3_0x3C; + math::VEC2 mScale; // at 0x48 + Size mSize; // at 0x50 + math::MTX34 MTX34_0x58; + math::MTX34 mGlobalMtx; // at 0x84 + int INT_0xB4; + u8 mAlpha; // at 0xB8 + u8 BYTE_0xB9; + u8 BYTE_0xBA; + u8 mFlags; // at 0xBB + char mName[PANE_NAME_SIZE]; // at 0xBC + char mUserData[PANE_USERDATA_SIZE]; // at 0xCD + u8 BYTE_0xD6; + + static ut::detail::RuntimeTypeInfo typeInfo; +}; +} // namespace lyt +} // namespace nw4r + +#endif diff --git a/include/nw4r/lyt/lyt_resourceAccessor.h b/include/nw4r/lyt/lyt_resourceAccessor.h index d8a10c8a..99e48765 100644 --- a/include/nw4r/lyt/lyt_resourceAccessor.h +++ b/include/nw4r/lyt/lyt_resourceAccessor.h @@ -1,21 +1,18 @@ #ifndef NW4R_LYT_RESOURCE_ACCESSOR_H #define NW4R_LYT_RESOURCE_ACCESSOR_H -#include "types_nw4r.h" -#include "ut_Font.h" +#include "common.h" +#include "nw4r/ut/ut_Font.h" -namespace nw4r -{ - namespace lyt - { - class ResourceAccessor - { - public: - ResourceAccessor(); - virtual ~ResourceAccessor(); // at 0x8 - virtual UNKTYPE * GetResource(u32, const char *, u32 *) = 0; // at 0xC - virtual ut::Font * GetFont(const char *); // at 0x10 - }; - } -} +namespace nw4r { +namespace lyt { +class ResourceAccessor { +public: + ResourceAccessor(); + virtual ~ResourceAccessor(); // at 0x8 + virtual UNKTYPE *GetResource(u32, const char *, u32 *) = 0; // at 0xC + virtual ut::Font *GetFont(const char *); // at 0x10 +}; +} // namespace lyt +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/lyt/lyt_texMap.h b/include/nw4r/lyt/lyt_texMap.h index e685602b..a277fa92 100644 --- a/include/nw4r/lyt/lyt_texMap.h +++ b/include/nw4r/lyt/lyt_texMap.h @@ -1,6 +1,6 @@ #ifndef NW4R_LYT_TEXMAP_H #define NW4R_LYT_TEXMAP_H -#include "types_nw4r.h" +#include "common.h" #include #include diff --git a/include/nw4r/snd/snd_BankFile.h b/include/nw4r/snd/snd_BankFile.h index 9286704f..b7bfacc1 100644 --- a/include/nw4r/snd/snd_BankFile.h +++ b/include/nw4r/snd/snd_BankFile.h @@ -1,102 +1,90 @@ #ifndef NW4R_SND_BANK_FILE_H #define NW4R_SND_BANK_FILE_H -#include "types_nw4r.h" -#include "ut_binaryFileFormat.h" -#include "ut_algorithm.h" +#include "common.h" #include "snd_Util.h" #include "snd_WaveFile.h" +#include "ut_algorithm.h" +#include "ut_binaryFileFormat.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct InstInfo - { - int WORD_0x0; - u8 mAttack; // at 0x4 - u8 mDecay; // at 0x5 - u8 mSustain; // at 0x6 - u8 mRelease; // at 0x7 - - u8 BYTE_0x8; - u8 BYTE_0x9; - u8 BYTE_0xA; - float FLOAT_0xC; - }; - - struct BankFile - { - struct InstParam - { - int WORD_0x0; - u8 mAttack; // at 0x4 - u8 mDecay; // at 0x5 - u8 mSustain; // at 0x6 - u8 mRelease; // at 0x7 - - char UNK_0x8[0x4]; - - char BYTE_0xC; - u8 BYTE_0xD; - char BYTE_0xE; - float FLOAT_0x10; - }; - - struct RangeTable - { - u8 BYTE_0x0; - u8 BYTES_0x1[]; - }; - - struct IndexTable - { - u8 BYTE_0x0; - u8 BYTE_0x1; - }; - - ut::BinaryFileHeader mHeader; // at 0x0 - u32 OFFSET_0x10; - char UNK_0x14[0x4]; - u32 OFFSET_0x18; - - typedef Util::DataRef Region; - }; - - struct BankFileReader - { - struct UNKBLOCK_DATA - { - ut::BinaryBlockHeader mHeader; // at 0x0 - int INT_0x8; - BankFile::Region ARR_0xC[]; - }; - - struct UNKBLOCK_WAVE - { - ut::BinaryBlockHeader mHeader; // at 0x0 - u32 INT_0x8; - WaveFile::Region ARR_0xC[]; - }; - - bool IsValidFileHeader(const void *); - BankFileReader(const void *); - bool ReadInstInfo(InstInfo *, int, int, int) const; - const BankFile::Region * GetReferenceToSubRegion(const BankFile::Region *, int) const; - bool ReadWaveParam(WaveData *, int, const void *) const; - - const BankFile * mFile; // at 0x0 - const UNKBLOCK_DATA * PTR_0x4; - const UNKBLOCK_WAVE * PTR_0x8; - }; - - inline u8 ReadByte(const void * ptr) - { - return *static_cast(ptr); - } - } - } +namespace nw4r { +namespace snd { +namespace detail { +struct InstInfo { + int WORD_0x0; + u8 mAttack; // at 0x4 + u8 mDecay; // at 0x5 + u8 mSustain; // at 0x6 + u8 mRelease; // at 0x7 + + u8 BYTE_0x8; + u8 BYTE_0x9; + u8 BYTE_0xA; + float FLOAT_0xC; +}; + +struct BankFile { + struct InstParam { + int WORD_0x0; + u8 mAttack; // at 0x4 + u8 mDecay; // at 0x5 + u8 mSustain; // at 0x6 + u8 mRelease; // at 0x7 + + char UNK_0x8[0x4]; + + char BYTE_0xC; + u8 BYTE_0xD; + char BYTE_0xE; + float FLOAT_0x10; + }; + + struct RangeTable { + u8 BYTE_0x0; + u8 BYTES_0x1[]; + }; + + struct IndexTable { + u8 BYTE_0x0; + u8 BYTE_0x1; + }; + + ut::BinaryFileHeader mHeader; // at 0x0 + u32 OFFSET_0x10; + char UNK_0x14[0x4]; + u32 OFFSET_0x18; + + typedef Util::DataRef Region; +}; + +struct BankFileReader { + struct UNKBLOCK_DATA { + ut::BinaryBlockHeader mHeader; // at 0x0 + int INT_0x8; + BankFile::Region ARR_0xC[]; + }; + + struct UNKBLOCK_WAVE { + ut::BinaryBlockHeader mHeader; // at 0x0 + u32 INT_0x8; + WaveFile::Region ARR_0xC[]; + }; + + bool IsValidFileHeader(const void *); + BankFileReader(const void *); + bool ReadInstInfo(InstInfo *, int, int, int) const; + const BankFile::Region *GetReferenceToSubRegion(const BankFile::Region *, int) const; + bool ReadWaveParam(WaveData *, int, const void *) const; + + const BankFile *mFile; // at 0x0 + const UNKBLOCK_DATA *PTR_0x4; + const UNKBLOCK_WAVE *PTR_0x8; +}; + +inline u8 ReadByte(const void *ptr) { + return *static_cast(ptr); } +} // namespace detail +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_Channel.h b/include/nw4r/snd/snd_Channel.h index 47fc74b2..ce5c8e35 100644 --- a/include/nw4r/snd/snd_Channel.h +++ b/include/nw4r/snd/snd_Channel.h @@ -1,161 +1,145 @@ #ifndef NW4R_SND_CHANNEL_H #define NW4R_SND_CHANNEL_H -#include "types_nw4r.h" -#include "ut_LinkList.h" -#include "snd_Voice.h" -#include "snd_Lfo.h" -#include "snd_InstancePool.h" -#include "snd_WaveFile.h" +#include "common.h" #include "snd_EnvGenerator.h" +#include "snd_InstancePool.h" +#include "snd_Lfo.h" #include "snd_MoveValue.h" +#include "snd_Voice.h" +#include "snd_WaveFile.h" +#include "ut_LinkList.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct Channel - { - enum ChannelCallbackStatus - { - CALLBACK_STATUS_0, - CALLBACK_STATUS_1, - CALLBACK_STATUS_2, - CALLBACK_STATUS_3 - }; - - typedef void (* ChannelCallback)(Channel *, ChannelCallbackStatus, u32); - - static void VoiceCallbackFunc(Voice *, Voice::VoiceCallbackStatus, void *); - - static Channel * AllocChannel(int, int, int, ChannelCallback, u32); - static void FreeChannel(Channel *); - Channel(); - - UNKTYPE InitParam(ChannelCallback, u32); - void Update(bool); - UNKTYPE Start(const WaveData &, int, u32); - UNKTYPE Release(); - UNKTYPE Stop(); - - float GetSweepValue() const; - void UpdateSweep(int); - void SetSweepParam(float, int, bool); - - EnvGenerator mEnvGenerator; // at 0x0 - Lfo mLfo; // at 0x18 - u8 BYTE_0x30; - bool mPauseFlag; // at 0x31 - bool mActiveFlag; // at 0x32 - bool BOOL_0x33; - bool mAutoUpdateSweepFlag; // at 0x34 - bool mReleasePriorityFixFlag; // at 0x35 - - float FLOAT_0x38; - float FLOAT_0x3C; - float FLOAT_0x40; - float FLOAT_0x44; - float FLOAT_0x48; - - int mRemoteFilter; // at 0x4c - int mOutputLine; // at 0x50 - - float FLOAT_0x54; - float FLOAT_0x58; - - float ARR_0x5C[3]; - - float mRemoteOutVolumes[4]; // at 0x68 - float ARR_0x78[4]; - float ARR_0x88[4]; - - float FLOAT_0x98; - float FLOAT_0x9C; - - int INT_0xA0; - int INT_0xA4; - - float FLOAT_0xA8; - float FLOAT_0xAC; - float FLOAT_0xB0; - float FLOAT_0xB4; - MoveValue MV_0xB8; - UNKWORD INT_0xC0; - UNKWORD INT_0xC4; - int mLength; // at 0xc8 - - PanMode mPanMode; // at 0xcc - PanCurve mPanCurve; // at 0xd0 - - ChannelCallback mCallback; // at 0xd4 - u32 INT_0xD8; - Voice * mVoice; // at 0xdc - Channel * mNext; // at 0xe0 - ut::LinkListNode mNode; // at 0xe4 - - inline bool IsActive() const - { - return mActiveFlag; - } - - inline void SetRelease(int release) - { - if (release >= 0) mEnvGenerator.SetRelease(release); - - Release(); - } - - inline bool IsAutoUpdateSweep() const - { - return mAutoUpdateSweepFlag; - } - - inline bool IsPause() const - { - return mPauseFlag; - } - - inline void Pause(bool flag) - { - mPauseFlag = flag; - - mVoice->Pause(flag); - } - - inline void SetLfoParam(const LfoParam & lfoParam) - { - mLfo.SetParam(lfoParam); - } - - inline void SetSilence(bool silentFlag, int time) - { - MV_0xB8.SetTarget(silentFlag ? 0 : 0xFF, time); - } - }; - - struct ChannelManager - { - ChannelManager(); - - u32 GetRequiredMemSize(); - void Setup(void *, u32); - void Shutdown(); - UNKTYPE UpdateAllChannel(); - static void Free(Channel *); //inlined - Channel * Alloc(); // inlined - static ChannelManager * GetInstance(); - - InstancePool mPool; // at 0x0 - ut::LinkList mList; // at 0x4 - - bool BOOL_0x10; - u32 INT_0x14; - UNKTYPE * PTR_0x18; - u32 INT_0x1C; - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct Channel { + enum ChannelCallbackStatus { CALLBACK_STATUS_0, CALLBACK_STATUS_1, CALLBACK_STATUS_2, CALLBACK_STATUS_3 }; -#endif \ No newline at end of file + typedef void (*ChannelCallback)(Channel *, ChannelCallbackStatus, u32); + + static void VoiceCallbackFunc(Voice *, Voice::VoiceCallbackStatus, void *); + + static Channel *AllocChannel(int, int, int, ChannelCallback, u32); + static void FreeChannel(Channel *); + Channel(); + + UNKTYPE InitParam(ChannelCallback, u32); + void Update(bool); + UNKTYPE Start(const WaveData &, int, u32); + UNKTYPE Release(); + UNKTYPE Stop(); + + float GetSweepValue() const; + void UpdateSweep(int); + void SetSweepParam(float, int, bool); + + EnvGenerator mEnvGenerator; // at 0x0 + Lfo mLfo; // at 0x18 + u8 BYTE_0x30; + bool mPauseFlag; // at 0x31 + bool mActiveFlag; // at 0x32 + bool BOOL_0x33; + bool mAutoUpdateSweepFlag; // at 0x34 + bool mReleasePriorityFixFlag; // at 0x35 + + float FLOAT_0x38; + float FLOAT_0x3C; + float FLOAT_0x40; + float FLOAT_0x44; + float FLOAT_0x48; + + int mRemoteFilter; // at 0x4c + int mOutputLine; // at 0x50 + + float FLOAT_0x54; + float FLOAT_0x58; + + float ARR_0x5C[3]; + + float mRemoteOutVolumes[4]; // at 0x68 + float ARR_0x78[4]; + float ARR_0x88[4]; + + float FLOAT_0x98; + float FLOAT_0x9C; + + int INT_0xA0; + int INT_0xA4; + + float FLOAT_0xA8; + float FLOAT_0xAC; + float FLOAT_0xB0; + float FLOAT_0xB4; + MoveValue MV_0xB8; + UNKWORD INT_0xC0; + UNKWORD INT_0xC4; + int mLength; // at 0xc8 + + PanMode mPanMode; // at 0xcc + PanCurve mPanCurve; // at 0xd0 + + ChannelCallback mCallback; // at 0xd4 + u32 INT_0xD8; + Voice *mVoice; // at 0xdc + Channel *mNext; // at 0xe0 + ut::LinkListNode mNode; // at 0xe4 + + inline bool IsActive() const { + return mActiveFlag; + } + + inline void SetRelease(int release) { + if (release >= 0) { + mEnvGenerator.SetRelease(release); + } + + Release(); + } + + inline bool IsAutoUpdateSweep() const { + return mAutoUpdateSweepFlag; + } + + inline bool IsPause() const { + return mPauseFlag; + } + + inline void Pause(bool flag) { + mPauseFlag = flag; + + mVoice->Pause(flag); + } + + inline void SetLfoParam(const LfoParam &lfoParam) { + mLfo.SetParam(lfoParam); + } + + inline void SetSilence(bool silentFlag, int time) { + MV_0xB8.SetTarget(silentFlag ? 0 : 0xFF, time); + } +}; + +struct ChannelManager { + ChannelManager(); + + u32 GetRequiredMemSize(); + void Setup(void *, u32); + void Shutdown(); + UNKTYPE UpdateAllChannel(); + static void Free(Channel *); // inlined + Channel *Alloc(); // inlined + static ChannelManager *GetInstance(); + + InstancePool mPool; // at 0x0 + ut::LinkList mList; // at 0x4 + + bool BOOL_0x10; + u32 INT_0x14; + UNKTYPE *PTR_0x18; + u32 INT_0x1C; +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_ChannelManager.h b/include/nw4r/snd/snd_ChannelManager.h index 2b9fca7e..7bb2f56d 100644 --- a/include/nw4r/snd/snd_ChannelManager.h +++ b/include/nw4r/snd/snd_ChannelManager.h @@ -1,21 +1,17 @@ #ifndef NW4R_SND_CHANNEL_MANAGER_H #define NW4R_SND_CHANNEL_MANAGER_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct ChannelManager - { - static ChannelManager * GetInstance(); +namespace nw4r { +namespace snd { +namespace detail { +struct ChannelManager { + static ChannelManager *GetInstance(); - void UpdateAllChannel(); - }; - } - } -} + void UpdateAllChannel(); +}; +} // namespace detail +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_DisposeCallback.h b/include/nw4r/snd/snd_DisposeCallback.h index b76bfeed..69234cc5 100644 --- a/include/nw4r/snd/snd_DisposeCallback.h +++ b/include/nw4r/snd/snd_DisposeCallback.h @@ -1,24 +1,20 @@ #ifndef NW4R_SND_DISPOSE_CALLBACK_H #define NW4R_SND_DISPOSE_CALLBACK_H -#include "types_nw4r.h" +#include "common.h" #include "ut_LinkList.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct DisposeCallback - { - ut::LinkListNode mNode; // at 0x0 - - inline virtual ~DisposeCallback() {} // at 0x8 - virtual void InvalidateData(const void *, const void *) = 0; // at 0xc - virtual void InvalidateWaveData(const void *, const void *) = 0; // at 0x10 - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct DisposeCallback { + ut::LinkListNode mNode; // at 0x0 -#endif \ No newline at end of file + inline virtual ~DisposeCallback() {} // at 0x8 + virtual void InvalidateData(const void *, const void *) = 0; // at 0xc + virtual void InvalidateWaveData(const void *, const void *) = 0; // at 0x10 +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_DisposeCallbackManager.h b/include/nw4r/snd/snd_DisposeCallbackManager.h index 16c0a67e..26547a6a 100644 --- a/include/nw4r/snd/snd_DisposeCallbackManager.h +++ b/include/nw4r/snd/snd_DisposeCallbackManager.h @@ -1,29 +1,25 @@ #ifndef NW4R_SND_DISPOSE_CALLBACK_MANAGER_H #define NW4R_SND_DISPOSE_CALLBACK_MANAGER_H -#include "types_nw4r.h" +#include "common.h" #include "snd_DisposeCallback.h" #include "ut_LinkList.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct DisposeCallbackManager - { - static DisposeCallbackManager * GetInstance(); - - ut::LinkList mList; // at 0x0 - - UNKTYPE RegisterDisposeCallback(DisposeCallback *); - UNKTYPE UnregisterDisposeCallback(DisposeCallback *); - - UNKTYPE Dispose(void *, u32, void *); - UNKTYPE DisposeWave(void *, u32, void *); - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct DisposeCallbackManager { + static DisposeCallbackManager *GetInstance(); -#endif \ No newline at end of file + ut::LinkList mList; // at 0x0 + + UNKTYPE RegisterDisposeCallback(DisposeCallback *); + UNKTYPE UnregisterDisposeCallback(DisposeCallback *); + + UNKTYPE Dispose(void *, u32, void *); + UNKTYPE DisposeWave(void *, u32, void *); +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_FrameHeap.h b/include/nw4r/snd/snd_FrameHeap.h index dec66053..fcab561b 100644 --- a/include/nw4r/snd/snd_FrameHeap.h +++ b/include/nw4r/snd/snd_FrameHeap.h @@ -1,90 +1,75 @@ #ifndef NW4R_SND_FRAME_HEAP_H #define NW4R_SND_FRAME_HEAP_H -#include "types_nw4r.h" +#include "common.h" #include "ut_LinkList.h" #include "ut_algorithm.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct FrameHeap - { - typedef void (* AllocCallback)(void *, u32, void *); - - struct Block - { - ut::LinkListNode mNode; // at 0x0 - u32 mSize; // at 0x8 - AllocCallback mCallback; // at 0xc - void * PTR_0x10; - - inline Block(u32 size, AllocCallback callback, void * ptr) - : - mSize(size), - mCallback(callback), - PTR_0x10(ptr) - {} - - inline void * GetBufferAddr() - { - return reinterpret_cast(this) + ut::RoundUp(sizeof(Block), 0x20); - } - - inline ~Block() - { - if (mCallback) mCallback(PTR_0x10, mSize, GetBufferAddr()); - } - }; - - struct Section - { - ut::LinkListNode mNode; // at 0x0 - ut::LinkList mList; // at 0x8 - - inline void AppendBlock(Block * pBlock) - { - mList.PushBack(pBlock); - } - - inline ~Section() - { - ut::LinkList::Iterator iter = mList.GetEndIter(); - - while (iter != mList.GetBeginIter()) - { - (--iter)->~Block(); - } - } - }; - - bool NewSection(); //inlined - UNKTYPE ClearSection(); //inlined - - FrameHeap(); - ~FrameHeap(); - - bool Create(void *, u32); - UNKTYPE Destroy(); - void Clear(); - void * Alloc(u32, AllocCallback, void *); - int SaveState(); - void LoadState(int); - int GetCurrentLevel() const; - u32 GetFreeSize() const; - - UNKTYPE * PTR_0x0; - ut::LinkList mList; // at 0x4 - - inline bool IsValid() const - { - return mList.GetSize(); - } - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct FrameHeap { + typedef void (*AllocCallback)(void *, u32, void *); -#endif \ No newline at end of file + struct Block { + ut::LinkListNode mNode; // at 0x0 + u32 mSize; // at 0x8 + AllocCallback mCallback; // at 0xc + void *PTR_0x10; + + inline Block(u32 size, AllocCallback callback, void *ptr) : mSize(size), mCallback(callback), PTR_0x10(ptr) {} + + inline void *GetBufferAddr() { + return reinterpret_cast(this) + ut::RoundUp(sizeof(Block), 0x20); + } + + inline ~Block() { + if (mCallback) { + mCallback(PTR_0x10, mSize, GetBufferAddr()); + } + } + }; + + struct Section { + ut::LinkListNode mNode; // at 0x0 + ut::LinkList mList; // at 0x8 + + inline void AppendBlock(Block *pBlock) { + mList.PushBack(pBlock); + } + + inline ~Section() { + ut::LinkList::Iterator iter = mList.GetEndIter(); + + while (iter != mList.GetBeginIter()) { + (--iter)->~Block(); + } + } + }; + + bool NewSection(); // inlined + UNKTYPE ClearSection(); // inlined + + FrameHeap(); + ~FrameHeap(); + + bool Create(void *, u32); + UNKTYPE Destroy(); + void Clear(); + void *Alloc(u32, AllocCallback, void *); + int SaveState(); + void LoadState(int); + int GetCurrentLevel() const; + u32 GetFreeSize() const; + + UNKTYPE *PTR_0x0; + ut::LinkList mList; // at 0x4 + + inline bool IsValid() const { + return mList.GetSize(); + } +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_FxBase.h b/include/nw4r/snd/snd_FxBase.h index d8a0725b..12d71cef 100644 --- a/include/nw4r/snd/snd_FxBase.h +++ b/include/nw4r/snd/snd_FxBase.h @@ -1,33 +1,24 @@ #ifndef NW4R_SND_FX_BASE_H #define NW4R_SND_FX_BASE_H -#include "types_nw4r.h" +#include "common.h" #include "snd_Common.h" #include "ut_LinkList.h" -namespace nw4r -{ - namespace snd - { - enum SampleFormat - { - SAMPLE_FORMAT_PCM_S32, - SAMPLE_FORMAT_PCM_S16, - SAMPLE_FORMAT_PCM_S8, - SAMPLE_FORMAT_DSP_ADPCM - }; - - struct FxBase - { - inline virtual ~FxBase() {} // at 0x8 - inline virtual bool StartUp() {} // at 0xc - inline virtual UNKTYPE Shutdown() {} // at 0x10 - inline virtual UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode) {} // at 0x14 - - NW4R_UT_LIST_NODE_DECL(); // at 0x4 - }; +namespace nw4r { +namespace snd { +enum SampleFormat { SAMPLE_FORMAT_PCM_S32, SAMPLE_FORMAT_PCM_S16, SAMPLE_FORMAT_PCM_S8, SAMPLE_FORMAT_DSP_ADPCM }; - NW4R_UT_LIST_TYPEDEF_DECL(FxBase); - } -} +struct FxBase { + inline virtual ~FxBase() {} // at 0x8 + inline virtual bool StartUp() {} // at 0xc + inline virtual UNKTYPE Shutdown() {} // at 0x10 + inline virtual UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode) {} // at 0x14 -#endif \ No newline at end of file + NW4R_UT_LIST_NODE_DECL(); // at 0x4 +}; + +NW4R_UT_LIST_TYPEDEF_DECL(FxBase); +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_FxChorus.h b/include/nw4r/snd/snd_FxChorus.h index 77af4857..d39be6be 100644 --- a/include/nw4r/snd/snd_FxChorus.h +++ b/include/nw4r/snd/snd_FxChorus.h @@ -1,47 +1,42 @@ #ifndef NW4R_SND_FX_CHORUS_H #define NW4R_SND_FX_CHORUS_H -#include -#include "types_nw4r.h" -#include "snd_FxBase.h" #include "snd_AxfxImpl.h" +#include "snd_FxBase.h" +#include #include "common.h" -namespace nw4r -{ - namespace snd - { - struct FxChorus : FxBase - { - //sizeof(ChorusParam) = 0xc - struct ChorusParam - { - float FLOAT_0x0; - float FLOAT_0x4; - float FLOAT_0x8; - }; - - FxChorus(); - - inline ~FxChorus() - { - Shutdown(); - ReleaseWorkBuffer(); - } - - u32 GetRequiredMemSize(); - virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18 - virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c - - bool StartUp(); // at 0xc - UNKTYPE Shutdown(); // at 0x10 - bool SetParam(const ChorusParam &); - UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14 - - detail::AxfxImpl mAxfxImpl; - - ChorusParam mParam; // at 0x18 - AXFX_CHORUS mAXFXChorus; // 0x24 - }; - } -} -#endif \ No newline at end of file +namespace nw4r { +namespace snd { +struct FxChorus : FxBase { + // sizeof(ChorusParam) = 0xc + struct ChorusParam { + float FLOAT_0x0; + float FLOAT_0x4; + float FLOAT_0x8; + }; + + FxChorus(); + + inline ~FxChorus() { + Shutdown(); + ReleaseWorkBuffer(); + } + + u32 GetRequiredMemSize(); + virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18 + virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c + + bool StartUp(); // at 0xc + UNKTYPE Shutdown(); // at 0x10 + bool SetParam(const ChorusParam &); + UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14 + + detail::AxfxImpl mAxfxImpl; + + ChorusParam mParam; // at 0x18 + AXFX_CHORUS mAXFXChorus; // 0x24 +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_FxDelay.h b/include/nw4r/snd/snd_FxDelay.h index a054c39b..1ad7f26b 100644 --- a/include/nw4r/snd/snd_FxDelay.h +++ b/include/nw4r/snd/snd_FxDelay.h @@ -1,47 +1,42 @@ #ifndef NW4R_SND_FX_DELAY_H #define NW4R_SND_FX_DELAY_H -#include -#include "snd_FxBase.h" +#include "common.h" #include "snd_AxfxImpl.h" -#include "types_nw4r.h" +#include "snd_FxBase.h" +#include -namespace nw4r -{ - namespace snd - { - struct FxDelay : FxBase - { - //sizeof(FxDelayParam) = 0xc - struct DelayParam - { - float FLOAT_0x0; - float FLOAT_0x4; - float FLOAT_0x8; - }; - - FxDelay(); - - inline ~FxDelay() - { - Shutdown(); - ReleaseWorkBuffer(); - } - - u32 GetRequiredMemSize(); - virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18 - virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c - - bool StartUp(); // at 0xc - UNKTYPE Shutdown(); // at 0x10 - bool SetParam(const DelayParam &); - UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14 - - detail::AxfxImpl mAxfxImpl; // at 0xc - DelayParam mParam; // at 0x18 - - AXFX_DELAY mAXFXDelay; // at 0x24 - }; - } -} +namespace nw4r { +namespace snd { +struct FxDelay : FxBase { + // sizeof(FxDelayParam) = 0xc + struct DelayParam { + float FLOAT_0x0; + float FLOAT_0x4; + float FLOAT_0x8; + }; -#endif \ No newline at end of file + FxDelay(); + + inline ~FxDelay() { + Shutdown(); + ReleaseWorkBuffer(); + } + + u32 GetRequiredMemSize(); + virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18 + virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c + + bool StartUp(); // at 0xc + UNKTYPE Shutdown(); // at 0x10 + bool SetParam(const DelayParam &); + UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14 + + detail::AxfxImpl mAxfxImpl; // at 0xc + DelayParam mParam; // at 0x18 + + AXFX_DELAY mAXFXDelay; // at 0x24 +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_FxReverbHi.h b/include/nw4r/snd/snd_FxReverbHi.h index 2b472d05..fcbb0cf5 100644 --- a/include/nw4r/snd/snd_FxReverbHi.h +++ b/include/nw4r/snd/snd_FxReverbHi.h @@ -1,50 +1,45 @@ #ifndef NW4R_SND_FX_REVERB_HI_H #define NW4R_SND_FX_REVERB_HI_H -#include -#include "snd_FxBase.h" +#include "common.h" #include "snd_AxfxImpl.h" -#include "types_nw4r.h" +#include "snd_FxBase.h" +#include -namespace nw4r -{ - namespace snd - { - struct FxReverbHi : FxBase - { - //sizeof(ReverbHiParam) = 0x18 - struct ReverbHiParam - { - float FLOAT_0x0; - float FLOAT_0x4; - float FLOAT_0x8; - float FLOAT_0xC; - float FLOAT_0x10; - float FLOAT_0x14; - }; - - FxReverbHi(); - - inline ~FxReverbHi() - { - Shutdown(); - ReleaseWorkBuffer(); - } - - u32 GetRequiredMemSize(); - virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18 - virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c - - bool StartUp(); // at 0xc - UNKTYPE Shutdown(); // at 0x10 - bool SetParam(const ReverbHiParam &); - UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14 - - detail::AxfxImpl mAxfxImpl; // at 0xc - ReverbHiParam mParam; // at 0x18 - - AXFX_REVERBHI mAXFXReverbHi; // at 0x30 - }; - } -} +namespace nw4r { +namespace snd { +struct FxReverbHi : FxBase { + // sizeof(ReverbHiParam) = 0x18 + struct ReverbHiParam { + float FLOAT_0x0; + float FLOAT_0x4; + float FLOAT_0x8; + float FLOAT_0xC; + float FLOAT_0x10; + float FLOAT_0x14; + }; -#endif \ No newline at end of file + FxReverbHi(); + + inline ~FxReverbHi() { + Shutdown(); + ReleaseWorkBuffer(); + } + + u32 GetRequiredMemSize(); + virtual UNKTYPE AssignWorkBuffer(void *, u32); // at 0x18 + virtual UNKTYPE ReleaseWorkBuffer(); // at 0x1c + + bool StartUp(); // at 0xc + UNKTYPE Shutdown(); // at 0x10 + bool SetParam(const ReverbHiParam &); + UNKTYPE UpdateBuffer(int, void **, u32, SampleFormat, float, OutputMode); // at 0x14 + + detail::AxfxImpl mAxfxImpl; // at 0xc + ReverbHiParam mParam; // at 0x18 + + AXFX_REVERBHI mAXFXReverbHi; // at 0x30 +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_InstancePool.h b/include/nw4r/snd/snd_InstancePool.h index ad630a98..a074fe5e 100644 --- a/include/nw4r/snd/snd_InstancePool.h +++ b/include/nw4r/snd/snd_InstancePool.h @@ -1,9 +1,8 @@ #ifndef NW4R_SND_INSTANCE_POOL_H #define NW4R_SND_INSTANCE_POOL_H -#include "types_nw4r.h" +#include "common.h" #include - namespace nw4r { namespace snd { namespace detail { diff --git a/include/nw4r/snd/snd_MmlParser.h b/include/nw4r/snd/snd_MmlParser.h index 54398397..9abd7f0b 100644 --- a/include/nw4r/snd/snd_MmlParser.h +++ b/include/nw4r/snd/snd_MmlParser.h @@ -1,46 +1,40 @@ #ifndef NW4R_SND_MML_PARSER_H #define NW4R_SND_MML_PARSER_H -#include "types_nw4r.h" +#include "common.h" #include "snd_MmlSeqTrack.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct MmlParser - { - u16 Read16(const u8 **) const; //inlined - u32 Read24(const u8 **) const; //inlined - u32 ReadVar(const u8 **) const; //inlined - - volatile s16 * GetVariablePtr(SeqPlayer *, SeqTrack *, int) const; - - UNKWORD Parse(MmlSeqTrack *, bool) const; - virtual void CommandProc(MmlSeqTrack *, u32, s32, s32) const; // at 0x8 - virtual Channel * NoteOnCommandProc(MmlSeqTrack *, int, int, s32, bool) const; // at 0xc - - enum SeqArgType - { - SEQ_ARG_TYPE_IMMEDIATE_BYTE, - SEQ_ARG_TYPE_IMMEDIATE_16, - SEQ_ARG_TYPE_IMMEDIATE_VAR, - SEQ_ARG_TYPE_RANDOM, - SEQ_ARG_TYPE_VARIABLE - }; - - s32 ReadArg(const u8 **, SeqPlayer *, SeqTrack *, SeqArgType) const; - - inline u8 ReadByte(const u8 ** pPointer) const - { - return *(*pPointer)++; - } - - static bool mPrintVarEnabledFlag; - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct MmlParser { + u16 Read16(const u8 **) const; // inlined + u32 Read24(const u8 **) const; // inlined + u32 ReadVar(const u8 **) const; // inlined -#endif \ No newline at end of file + volatile s16 *GetVariablePtr(SeqPlayer *, SeqTrack *, int) const; + + UNKWORD Parse(MmlSeqTrack *, bool) const; + virtual void CommandProc(MmlSeqTrack *, u32, s32, s32) const; // at 0x8 + virtual Channel *NoteOnCommandProc(MmlSeqTrack *, int, int, s32, bool) const; // at 0xc + + enum SeqArgType { + SEQ_ARG_TYPE_IMMEDIATE_BYTE, + SEQ_ARG_TYPE_IMMEDIATE_16, + SEQ_ARG_TYPE_IMMEDIATE_VAR, + SEQ_ARG_TYPE_RANDOM, + SEQ_ARG_TYPE_VARIABLE + }; + + s32 ReadArg(const u8 **, SeqPlayer *, SeqTrack *, SeqArgType) const; + + inline u8 ReadByte(const u8 **pPointer) const { + return *(*pPointer)++; + } + + static bool mPrintVarEnabledFlag; +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_MmlSeqTrack.h b/include/nw4r/snd/snd_MmlSeqTrack.h index a35646c7..0975a3a6 100644 --- a/include/nw4r/snd/snd_MmlSeqTrack.h +++ b/include/nw4r/snd/snd_MmlSeqTrack.h @@ -1,40 +1,33 @@ #ifndef NW4R_SND_MML_SEQ_TRACK_H #define NW4R_SND_MML_SEQ_TRACK_H +#include "common.h" #include "snd_SeqTrack.h" -#include "types_nw4r.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct MmlSeqTrack : SeqTrack - { - enum - { - STACK_FRAME_COUNT = 3 - }; - - struct MmlParserParam - { - bool mPredicate; // at 0x0 - bool BOOL_0x1; - bool BOOL_0x2; - u8 mLoopCounters[STACK_FRAME_COUNT]; // at 0x3 - u8 mStackIndex; // at 0x6 - const u8 * mReturnAddresses[STACK_FRAME_COUNT]; // at 0x8 - }; - - MmlParser * mParser; // at 0xc0 - MmlParserParam mMmlParserParam; // at 0xc4 - - MmlSeqTrack(); - - UNKWORD Parse(bool); // at 0xc - }; - } - } -} -#endif \ No newline at end of file +namespace nw4r { +namespace snd { +namespace detail { +struct MmlSeqTrack : SeqTrack { + enum { STACK_FRAME_COUNT = 3 }; + + struct MmlParserParam { + bool mPredicate; // at 0x0 + bool BOOL_0x1; + bool BOOL_0x2; + u8 mLoopCounters[STACK_FRAME_COUNT]; // at 0x3 + u8 mStackIndex; // at 0x6 + const u8 *mReturnAddresses[STACK_FRAME_COUNT]; // at 0x8 + }; + + MmlParser *mParser; // at 0xc0 + MmlParserParam mMmlParserParam; // at 0xc4 + + MmlSeqTrack(); + + UNKWORD Parse(bool); // at 0xc +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_MmlSeqTrackAllocator.h b/include/nw4r/snd/snd_MmlSeqTrackAllocator.h index b8d5750b..f92b4043 100644 --- a/include/nw4r/snd/snd_MmlSeqTrackAllocator.h +++ b/include/nw4r/snd/snd_MmlSeqTrackAllocator.h @@ -1,31 +1,27 @@ #ifndef NW4R_SND_MML_SEQ_TRACK_ALLOCATOR_H #define NW4R_SND_MML_SEQ_TRACK_ALLOCATOR_H -#include "snd_MmlSeqTrack.h" -#include "snd_MmlParser.h" +#include "common.h" #include "snd_InstancePool.h" -#include "types_nw4r.h" +#include "snd_MmlParser.h" +#include "snd_MmlSeqTrack.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct MmlSeqTrackAllocator : SeqTrackAllocator - { - MmlParser * mParser; - InstancePool mPool; // at 0x8 - - SeqTrack * AllocTrack(SeqPlayer *); // at 0xc - void FreeTrack(SeqTrack *); // at 0x10 - - u32 Create(void *, u32); - void Destroy(void *, u32); - - int GetAllocatableTrackCount() const; // at 0x14 - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct MmlSeqTrackAllocator : SeqTrackAllocator { + MmlParser *mParser; + InstancePool mPool; // at 0x8 -#endif \ No newline at end of file + SeqTrack *AllocTrack(SeqPlayer *); // at 0xc + void FreeTrack(SeqTrack *); // at 0x10 + + u32 Create(void *, u32); + void Destroy(void *, u32); + + int GetAllocatableTrackCount() const; // at 0x14 +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_NoteOn.h b/include/nw4r/snd/snd_NoteOn.h index 474ed151..9e04ce8b 100644 --- a/include/nw4r/snd/snd_NoteOn.h +++ b/include/nw4r/snd/snd_NoteOn.h @@ -1,34 +1,29 @@ #ifndef NW4R_SND_NOTE_ON_H #define NW4R_SND_NOTE_ON_H -#include "types_nw4r.h" +#include "common.h" #include "snd_Channel.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct NoteOnInfo - { - int INT_0x0; - int INT_0x4; - int INT_0x8; - int INT_0xC; - int INT_0x10; - int INT_0x14; - int INT_0x18; - Channel::ChannelCallback mChannelCallback; // at 0x1c - u32 INT_0x20; - }; - - struct NoteOnCallback - { - virtual ~NoteOnCallback(); // at 0x8 - virtual bool NoteOn(SeqPlayer *, int, const NoteOnInfo &) = 0; // at 0xc - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct NoteOnInfo { + int INT_0x0; + int INT_0x4; + int INT_0x8; + int INT_0xC; + int INT_0x10; + int INT_0x14; + int INT_0x18; + Channel::ChannelCallback mChannelCallback; // at 0x1c + u32 INT_0x20; +}; -#endif \ No newline at end of file +struct NoteOnCallback { + virtual ~NoteOnCallback(); // at 0x8 + virtual bool NoteOn(SeqPlayer *, int, const NoteOnInfo &) = 0; // at 0xc +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_PlayerHeap.h b/include/nw4r/snd/snd_PlayerHeap.h index f29b1dd5..ef3874ea 100644 --- a/include/nw4r/snd/snd_PlayerHeap.h +++ b/include/nw4r/snd/snd_PlayerHeap.h @@ -1,21 +1,17 @@ #ifndef NW4R_SND_PLAYER_HEAP_H #define NW4R_SND_PLAYER_HEAP_H -#include "types_nw4r.h" +#include "common.h" #include "snd_SoundHeap.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct PlayerHeap : SoundHeap - { - ~PlayerHeap(); - UNKTYPE * Alloc(u32); - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct PlayerHeap : SoundHeap { + ~PlayerHeap(); + UNKTYPE *Alloc(u32); +}; +} // namespace detail +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_RemoteSpeaker.h b/include/nw4r/snd/snd_RemoteSpeaker.h index 2252a5e8..b63f3dc9 100644 --- a/include/nw4r/snd/snd_RemoteSpeaker.h +++ b/include/nw4r/snd/snd_RemoteSpeaker.h @@ -1,75 +1,69 @@ #ifndef NW4R_SND_REMOTE_SPEAKER_H #define NW4R_SND_REMOTE_SPEAKER_H #include -#include -#include "types_nw4r.h" +#include #include "common.h" -namespace nw4r -{ - namespace snd - { - struct RemoteSpeaker - { - typedef void (*RemoteSpeakerCallback)(s32, s32); - - enum SpeakerCommand - { - SpeakerCommand_None, - SpeakerCommand_On, - SpeakerCommand_Play, - SpeakerCommand_Off, - }; - - bool mPoweredFlag; // at 0x0 - bool BOOL_0x1; - bool mEnabledOutputFlag; // at 0x2 - bool BOOL_0x3; - bool BOOL_0x4; - bool BOOL_0x5; - bool BOOL_0x6; - bool BOOL_0x7; - volatile bool BOOL_0x8; - - UNKWORD WORD_0xC; - SpeakerCommand CMD_0x10; - SpeakerCommand CMD_0x14; - char UNK_0x18[0x20]; - s32 mChannelIndex; // at 0x38 - RemoteSpeakerCallback mCallback; // at 0x3c - OSAlarm ALARM_0x40; - OSAlarm ALARM_0x70; - s64 mTime; // at 0xa0 - - RemoteSpeaker(); - void ClearParam(); //inlined - void InitParam(); //inlined - - bool Setup(RemoteSpeakerCallback); - void Shutdown(RemoteSpeakerCallback); - - bool EnableOutput(bool); - bool IsEnabledOutput() const; - - void Update(); - void ExecCommand(SpeakerCommand); - - bool IsAllSampleZero(const s16 *); //inlined - void UpdateStreamData(const s16 *); - - void NotifyCallback(s32, s32); //inlined - static void SpeakerOnCallback(s32, s32); - static void SpeakerPlayCallback(s32, s32); - static void SpeakerOffCallback(s32, s32); - - static void ContinueAlarmHandler(OSAlarm *, OSContext *); - static void IntervalAlarmHandler(OSAlarm *, OSContext *); - - inline void SetChannelIndex(int channelIndex) - { - mChannelIndex = channelIndex; - } - }; - } -} +namespace nw4r { +namespace snd { +struct RemoteSpeaker { + typedef void (*RemoteSpeakerCallback)(s32, s32); -#endif \ No newline at end of file + enum SpeakerCommand { + SpeakerCommand_None, + SpeakerCommand_On, + SpeakerCommand_Play, + SpeakerCommand_Off, + }; + + bool mPoweredFlag; // at 0x0 + bool BOOL_0x1; + bool mEnabledOutputFlag; // at 0x2 + bool BOOL_0x3; + bool BOOL_0x4; + bool BOOL_0x5; + bool BOOL_0x6; + bool BOOL_0x7; + volatile bool BOOL_0x8; + + UNKWORD WORD_0xC; + SpeakerCommand CMD_0x10; + SpeakerCommand CMD_0x14; + char UNK_0x18[0x20]; + s32 mChannelIndex; // at 0x38 + RemoteSpeakerCallback mCallback; // at 0x3c + OSAlarm ALARM_0x40; + OSAlarm ALARM_0x70; + s64 mTime; // at 0xa0 + + RemoteSpeaker(); + void ClearParam(); // inlined + void InitParam(); // inlined + + bool Setup(RemoteSpeakerCallback); + void Shutdown(RemoteSpeakerCallback); + + bool EnableOutput(bool); + bool IsEnabledOutput() const; + + void Update(); + void ExecCommand(SpeakerCommand); + + bool IsAllSampleZero(const s16 *); // inlined + void UpdateStreamData(const s16 *); + + void NotifyCallback(s32, s32); // inlined + static void SpeakerOnCallback(s32, s32); + static void SpeakerPlayCallback(s32, s32); + static void SpeakerOffCallback(s32, s32); + + static void ContinueAlarmHandler(OSAlarm *, OSContext *); + static void IntervalAlarmHandler(OSAlarm *, OSContext *); + + inline void SetChannelIndex(int channelIndex) { + mChannelIndex = channelIndex; + } +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SeqFile.h b/include/nw4r/snd/snd_SeqFile.h index 0d72e344..f03e48c9 100644 --- a/include/nw4r/snd/snd_SeqFile.h +++ b/include/nw4r/snd/snd_SeqFile.h @@ -1,37 +1,31 @@ #ifndef NW4R_SND_SEQ_FILE_H #define NW4R_SND_SEQ_FILE_H -#include "types_nw4r.h" +#include "common.h" #include "ut_binaryFileFormat.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct SeqFile - { - ut::BinaryFileHeader mHeader; // at 0x0 - u32 OFFSET_0x10; // at 0x10 - }; - - struct SeqFileReader - { - struct UNKBLOCK - { - ut::BinaryBlockHeader mHeader; // at 0x0 - u32 OFFSET_0x8; - }; - - const SeqFile * mFile; // at 0x0 - const UNKBLOCK * PTR_0x4; - - bool IsValidFileHeader(const void *); - SeqFileReader(const void *); - const void * GetBaseAddress() const; - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct SeqFile { + ut::BinaryFileHeader mHeader; // at 0x0 + u32 OFFSET_0x10; // at 0x10 +}; -#endif \ No newline at end of file +struct SeqFileReader { + struct UNKBLOCK { + ut::BinaryBlockHeader mHeader; // at 0x0 + u32 OFFSET_0x8; + }; + + const SeqFile *mFile; // at 0x0 + const UNKBLOCK *PTR_0x4; + + bool IsValidFileHeader(const void *); + SeqFileReader(const void *); + const void *GetBaseAddress() const; +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SeqPlayer.h b/include/nw4r/snd/snd_SeqPlayer.h index 12236216..7fda47b1 100644 --- a/include/nw4r/snd/snd_SeqPlayer.h +++ b/include/nw4r/snd/snd_SeqPlayer.h @@ -1,138 +1,121 @@ #ifndef NW4R_SND_SEQ_PLAYER_H #define NW4R_SND_SEQ_PLAYER_H -#include "types_nw4r.h" -#include "ut_lock.h" +#include "common.h" #include "snd_BasicPlayer.h" -#include "snd_InstancePool.h" #include "snd_DisposeCallback.h" -#include "snd_SoundThread.h" +#include "snd_InstancePool.h" #include "snd_NoteOn.h" +#include "snd_SoundThread.h" +#include "ut_lock.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - // Used an anonymous enum instead of a macro - // because I wanted the magic number to have - // namespace scope - enum - { - SEQ_TRACKS_PER_PLAYER = 0x10, - SEQ_VARIABLE_COUNT = 0x10 - }; - - //sizeof(SeqPlayer) = 0x11C - struct SeqPlayer : BasicPlayer, DisposeCallback, SoundThread::PlayerCallback - { - enum OffsetType - { - OFFSET_TYPE_0, - OFFSET_TYPE_1 - }; - - - bool Start(); // at 0xc - void Stop(); // at 0x10 - void Pause(bool); // at 0x14 - bool IsActive() const; // at 0x18 - bool IsStarted() const; // at 0x1c - bool IsPause() const; // at 0x20 - - void InvalidateData(const void *, const void *); - inline void InvalidateWaveData(const void *, const void *) {} - inline virtual void ChannelCallback(Channel *) {} - - bool mActiveFlag; // at 0x8c - bool mStartedFlag; // at 0x8d - bool mPauseFlag; // at 0x8e - - bool mReleasePriorityFixFlag; // at 0x8f - float FLOAT_0x90; - float mTempoRatio; // at 0x94 - float FLOAT_0x98; - int OFFSET_0x9C; - float OFFSET_0xA0; - int INT_0xA4; - char BYTE_0xA8; - u8 mChannelPriority; // at 0xa9 - u8 BYTE_0xAA; - u16 SHORT_0xAC; - - NoteOnCallback * mNoteOnCallback; // at 0xb0 - SeqTrackAllocator * mTrackAllocator; // at 0xb4 - SeqTrack * mPlayerTracks[SEQ_TRACKS_PER_PLAYER]; // at 0xb8 - volatile s16 mLocalVariables[SEQ_VARIABLE_COUNT]; // at 0xf8 - - int INT_0x118; - - SeqPlayer(); - ~SeqPlayer(); - - UNKTYPE InitParam(int, NoteOnCallback *); - void CloseTrack(int); - void FinishPlayer(); //inlined - - bool Setup(SeqTrackAllocator *, u32, int, NoteOnCallback *); - void SetSeqData(const void *, s32); - void Skip(OffsetType, int); - - void SetTempoRatio(float); - void SetChannelPriority(int); - void SetReleasePriorityFix(bool); - void SetLocalVariable(int, short); - static void InitGlobalVariable(); //inline - static void SetGlobalVariable(int, short); - - template - inline void SetTrackParam(u32 flags, void (SeqTrack::* pSetter)(T), T param) - { - ut::AutoInterruptLock lock; - - for (int i = 0; i < SEQ_TRACKS_PER_PLAYER && flags; flags >>= 1, i++) - { - if (flags & 1) - { - SeqTrack * pPlayerTrack = GetPlayerTrack(i); - - if (pPlayerTrack) (pPlayerTrack->*pSetter)(param); - } - } - } - - void SetTrackVolume(u32, float); - void SetTrackPitch(u32, float); - - void SetPlayerTrack(int, SeqTrack *); //inlined - SeqTrack * GetPlayerTrack(int); - bool ParseNextTick(bool); - volatile s16 * GetVariablePtr(int); - void UpdateChannelParam(); //inlined - void Update(); - void UpdateTick(); - void UpdateTick(int); - bool NoteOn(int, const NoteOnInfo &); - inline void OnUpdateFrameSoundThread() - { - Update(); - } - - inline void OnShutdownSoundThread() - { - Stop(); - } - - inline float GetBaseTempo() const - { - return mTempoRatio * (BYTE_0xAA * SHORT_0xAC) / 60000.0f; - } - - static volatile s16 mGlobalVariable[SEQ_VARIABLE_COUNT]; - static bool mGobalVariableInitialized; // typo - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +// Used an anonymous enum instead of a macro +// because I wanted the magic number to have +// namespace scope +enum { SEQ_TRACKS_PER_PLAYER = 0x10, SEQ_VARIABLE_COUNT = 0x10 }; -#endif \ No newline at end of file +// sizeof(SeqPlayer) = 0x11C +struct SeqPlayer : BasicPlayer, DisposeCallback, SoundThread::PlayerCallback { + enum OffsetType { OFFSET_TYPE_0, OFFSET_TYPE_1 }; + + bool Start(); // at 0xc + void Stop(); // at 0x10 + void Pause(bool); // at 0x14 + bool IsActive() const; // at 0x18 + bool IsStarted() const; // at 0x1c + bool IsPause() const; // at 0x20 + + void InvalidateData(const void *, const void *); + inline void InvalidateWaveData(const void *, const void *) {} + inline virtual void ChannelCallback(Channel *) {} + + bool mActiveFlag; // at 0x8c + bool mStartedFlag; // at 0x8d + bool mPauseFlag; // at 0x8e + + bool mReleasePriorityFixFlag; // at 0x8f + float FLOAT_0x90; + float mTempoRatio; // at 0x94 + float FLOAT_0x98; + int OFFSET_0x9C; + float OFFSET_0xA0; + int INT_0xA4; + char BYTE_0xA8; + u8 mChannelPriority; // at 0xa9 + u8 BYTE_0xAA; + u16 SHORT_0xAC; + + NoteOnCallback *mNoteOnCallback; // at 0xb0 + SeqTrackAllocator *mTrackAllocator; // at 0xb4 + SeqTrack *mPlayerTracks[SEQ_TRACKS_PER_PLAYER]; // at 0xb8 + volatile s16 mLocalVariables[SEQ_VARIABLE_COUNT]; // at 0xf8 + + int INT_0x118; + + SeqPlayer(); + ~SeqPlayer(); + + UNKTYPE InitParam(int, NoteOnCallback *); + void CloseTrack(int); + void FinishPlayer(); // inlined + + bool Setup(SeqTrackAllocator *, u32, int, NoteOnCallback *); + void SetSeqData(const void *, s32); + void Skip(OffsetType, int); + + void SetTempoRatio(float); + void SetChannelPriority(int); + void SetReleasePriorityFix(bool); + void SetLocalVariable(int, short); + static void InitGlobalVariable(); // inline + static void SetGlobalVariable(int, short); + + template + inline void SetTrackParam(u32 flags, void (SeqTrack::*pSetter)(T), T param) { + ut::AutoInterruptLock lock; + + for (int i = 0; i < SEQ_TRACKS_PER_PLAYER && flags; flags >>= 1, i++) { + if (flags & 1) { + SeqTrack *pPlayerTrack = GetPlayerTrack(i); + + if (pPlayerTrack) { + (pPlayerTrack->*pSetter)(param); + } + } + } + } + + void SetTrackVolume(u32, float); + void SetTrackPitch(u32, float); + + void SetPlayerTrack(int, SeqTrack *); // inlined + SeqTrack *GetPlayerTrack(int); + bool ParseNextTick(bool); + volatile s16 *GetVariablePtr(int); + void UpdateChannelParam(); // inlined + void Update(); + void UpdateTick(); + void UpdateTick(int); + bool NoteOn(int, const NoteOnInfo &); + inline void OnUpdateFrameSoundThread() { + Update(); + } + + inline void OnShutdownSoundThread() { + Stop(); + } + + inline float GetBaseTempo() const { + return mTempoRatio * (BYTE_0xAA * SHORT_0xAC) / 60000.0f; + } + + static volatile s16 mGlobalVariable[SEQ_VARIABLE_COUNT]; + static bool mGobalVariableInitialized; // typo +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SeqSound.h b/include/nw4r/snd/snd_SeqSound.h index 26a825a3..b1f8f72f 100644 --- a/include/nw4r/snd/snd_SeqSound.h +++ b/include/nw4r/snd/snd_SeqSound.h @@ -1,104 +1,95 @@ #ifndef NW4R_SND_SEQ_SOUND_H #define NW4R_SND_SEQ_SOUND_H -#include -#include "types_nw4r.h" #include "snd_BasicSound.h" +#include "snd_NoteOn.h" #include "snd_SeqPlayer.h" #include "snd_SoundInstanceManager.h" #include "snd_Task.h" -#include "snd_NoteOn.h" #include "ut_FileStream.h" +#include #include "common.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct SeqSound : BasicSound - { - typedef void (*SeqLoadCallback)(bool, const void *, void *); - - //sizeof(SeqLoadTask) = 0x24 - struct SeqLoadTask : Task - { - ut::FileStream * mFileStream; // at 0x10 - void * mData; // at 0x14 - int mSize; // at 0x18 - SeqLoadCallback mCallback; // at 0x1c - SeqSound * mSound; // at 0x20 - - inline SeqLoadTask() : mFileStream(NULL), mData(NULL), mCallback(NULL), mSound(NULL) {} - - void Execute(); - void Cancel(); - void OnCancel(); - }; - - static ut::detail::RuntimeTypeInfo typeInfo; - - SeqPlayer mPlayer; // at 0xd8 - SeqSoundHandle * mTempSpecialHandle; // at 0x1f4 - SoundInstanceManager * mManager; // at 0x1f8 - s32 INT_0x1FC; - SeqPlayer::OffsetType mOffsetType; // at 0x200 - int mOffset; // at 0x204 - bool mLoadingFlag; // at 0x208 - volatile bool mPreparedFlag; // at 0x209 - ut::FileStream * mFileStream; // at 0x20c - char UNK_0x210[0x200]; - SeqLoadTask mLoadTask; // at 0x410 - OSMutex MUTEX_0x434; // at 0x434 - - SeqSound(SoundInstanceManager *); - UNKTYPE InitParam(); - UNKTYPE Setup(SeqTrackAllocator *, u32, int, NoteOnCallback *); - - UNKTYPE Skip(SeqPlayer::OffsetType, int); //inlined - bool LoadData(SeqLoadCallback, void *); //inlined - void Prepare(const void *, s32, SeqPlayer::OffsetType, int); - void Prepare(ut::FileStream *, s32, SeqPlayer::OffsetType, int); - static void NotifyLoadAsyncEndSeqData(bool, const void *, void *); - - void Shutdown(); - - UNKTYPE SetTempoRatio(float); - UNKTYPE SetChannelPriority(int); - UNKTYPE SetReleasePriorityFix(bool); - - UNKTYPE SetPlayerPriority(int); - - UNKTYPE SetTrackVolume(u32, float); - UNKTYPE SetTrackPitch(u32, float); - - bool WriteVariable(int, short); - static bool WriteGlobalVariable(int, short); - - bool IsAttachedTempSpecialHandle(); - UNKTYPE DetachTempSpecialHandle(); - - inline const BasicPlayer * GetBasicPlayer() const - { - return &mPlayer; - } - - inline BasicPlayer * GetBasicPlayer() - { - return &mPlayer; - } - - inline bool IsPrepared() const - { - return mPreparedFlag; - } - - inline const ut::detail::RuntimeTypeInfo * GetRuntimeTypeInfo() const - { - return &typeInfo; - } - }; - } - } -} -#endif \ No newline at end of file +namespace nw4r { +namespace snd { +namespace detail { +struct SeqSound : BasicSound { + typedef void (*SeqLoadCallback)(bool, const void *, void *); + + // sizeof(SeqLoadTask) = 0x24 + struct SeqLoadTask : Task { + ut::FileStream *mFileStream; // at 0x10 + void *mData; // at 0x14 + int mSize; // at 0x18 + SeqLoadCallback mCallback; // at 0x1c + SeqSound *mSound; // at 0x20 + + inline SeqLoadTask() : mFileStream(NULL), mData(NULL), mCallback(NULL), mSound(NULL) {} + + void Execute(); + void Cancel(); + void OnCancel(); + }; + + static ut::detail::RuntimeTypeInfo typeInfo; + + SeqPlayer mPlayer; // at 0xd8 + SeqSoundHandle *mTempSpecialHandle; // at 0x1f4 + SoundInstanceManager *mManager; // at 0x1f8 + s32 INT_0x1FC; + SeqPlayer::OffsetType mOffsetType; // at 0x200 + int mOffset; // at 0x204 + bool mLoadingFlag; // at 0x208 + volatile bool mPreparedFlag; // at 0x209 + ut::FileStream *mFileStream; // at 0x20c + char UNK_0x210[0x200]; + SeqLoadTask mLoadTask; // at 0x410 + OSMutex MUTEX_0x434; // at 0x434 + + SeqSound(SoundInstanceManager *); + UNKTYPE InitParam(); + UNKTYPE Setup(SeqTrackAllocator *, u32, int, NoteOnCallback *); + + UNKTYPE Skip(SeqPlayer::OffsetType, int); // inlined + bool LoadData(SeqLoadCallback, void *); // inlined + void Prepare(const void *, s32, SeqPlayer::OffsetType, int); + void Prepare(ut::FileStream *, s32, SeqPlayer::OffsetType, int); + static void NotifyLoadAsyncEndSeqData(bool, const void *, void *); + + void Shutdown(); + + UNKTYPE SetTempoRatio(float); + UNKTYPE SetChannelPriority(int); + UNKTYPE SetReleasePriorityFix(bool); + + UNKTYPE SetPlayerPriority(int); + + UNKTYPE SetTrackVolume(u32, float); + UNKTYPE SetTrackPitch(u32, float); + + bool WriteVariable(int, short); + static bool WriteGlobalVariable(int, short); + + bool IsAttachedTempSpecialHandle(); + UNKTYPE DetachTempSpecialHandle(); + + inline const BasicPlayer *GetBasicPlayer() const { + return &mPlayer; + } + + inline BasicPlayer *GetBasicPlayer() { + return &mPlayer; + } + + inline bool IsPrepared() const { + return mPreparedFlag; + } + + inline const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const { + return &typeInfo; + } +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SeqSoundHandle.h b/include/nw4r/snd/snd_SeqSoundHandle.h index 4f4c1b05..9580e45e 100644 --- a/include/nw4r/snd/snd_SeqSoundHandle.h +++ b/include/nw4r/snd/snd_SeqSoundHandle.h @@ -1,22 +1,19 @@ #ifndef NW4R_SND_SEQ_SOUND_HANDLE_H #define NW4R_SND_SEQ_SOUND_HANDLE_H -#include "types_nw4r.h" +#include "common.h" #include "snd_SoundHandle.h" -namespace nw4r -{ - namespace snd - { - using namespace detail; - - struct SeqSoundHandle - { - detail::SeqSound * mSound; // at 0x0 - - SeqSoundHandle(SoundHandle *); - void DetachSound(); - }; - } -} +namespace nw4r { +namespace snd { +using namespace detail; -#endif \ No newline at end of file +struct SeqSoundHandle { + detail::SeqSound *mSound; // at 0x0 + + SeqSoundHandle(SoundHandle *); + void DetachSound(); +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SeqTrack.h b/include/nw4r/snd/snd_SeqTrack.h index 3040d00f..2e50ea01 100644 --- a/include/nw4r/snd/snd_SeqTrack.h +++ b/include/nw4r/snd/snd_SeqTrack.h @@ -1,129 +1,117 @@ #ifndef NW4R_SND_SEQ_TRACK_H #define NW4R_SND_SEQ_TRACK_H -#include "types_nw4r.h" -#include "snd_Lfo.h" +#include "common.h" #include "snd_Channel.h" +#include "snd_Lfo.h" -namespace nw4r -{ - namespace snd - { - enum SeqMute - { - SEQ_MUTE_0, - SEQ_MUTE_1, - SEQ_MUTE_2, - SEQ_MUTE_3 - }; - - namespace detail - { - struct SeqTrack - { - virtual ~SeqTrack(); - virtual UNKWORD Parse(bool) = 0; - - u8 mPlayerTrackNo; // at 0x4 - bool mOpenFlag; // at 0x5 - - float mVolume; // at 0x8 - float mPitch; // at 0xc - float FLOAT_0x10; - float FLOAT_0x14; - float FLOAT_0x18; - float FLOAT_0x1C; - float FLOAT_0x20; - float FLOATS_0x24[3]; - float FLOATS_0x30[4]; - float FLOATS_0x40[4]; - - const u8 * PTR_0x50; - const u8 * PTR_0x54; - - int TIMER_0x58; - - bool BOOL_0x5C; - char BYTE_0x5D; - bool BOOL_0x5E; - bool BOOL_0x5F; - bool BOOL_0x60; - - int INT_0x64; - UNKWORD WORD_0x68; - - LfoParam mLfoParam; // at 0x6c - - u8 BYTE_0x7C; - float FLOAT_0x80; - u8 BYTE_0x84; - u8 BYTE_0x85; - s8 BYTE_0x86; - u8 BYTE_0x87; - s8 BYTE_0x88; - s8 BYTE_0x89; - s8 BYTE_0x8A; - char BYTE_0x8B; - u8 BYTE_0x8C; - char BYTE_0x8D; - u8 BYTE_0x8E; - - u8 mAttack; // at 0x8f - u8 mDecay; // at 0x90 - u8 mSustain; // at 0x91 - u8 mRelease; // at 0x92 - - u8 BYTE_0x93; - u8 BYTES_0x94[3]; - char BYTE_0x97; - - s16 mVariables[0x10]; // at 0x98 - - SeqPlayer * mPlayer; // at 0xb8 - Channel * mChannel; // at 0xbc - - void SetPlayerTrackNo(int); - - SeqTrack(); - - UNKTYPE InitParam(); - - void SetSeqData(const void *, s32); - - void Open(); - void Close(); - - void UpdateChannelRelease(Channel *); //inlined - void UpdateChannelLength(); - UNKWORD ParseNextTick(bool); - void ReleaseAllChannel(int); - UNKTYPE PauseAllChannel(bool); - void UpdateChannelParam(); - UNKTYPE FreeAllChannel(); - - static void ChannelCallbackFunc(Channel *, Channel::ChannelCallbackStatus, u32); - - void StopAllChannel(); //inlined - void SetMute(SeqMute); - void SetVolume(float); - void SetPitch(float); - s16 * GetVariablePtr(int); - void AddChannel(Channel *); //inlined - Channel * NoteOn(int, int, s32, bool); - - inline bool IsOpened() const - { - return mOpenFlag; - } - }; - - struct SeqTrackAllocator - { - inline virtual ~SeqTrackAllocator() {} - virtual SeqTrack * AllocTrack(SeqPlayer *) = 0; - virtual void FreeTrack(SeqTrack *) = 0; - virtual int GetAllocatableTrackCount() const = 0; - }; - } - } -} -#endif \ No newline at end of file +namespace nw4r { +namespace snd { +enum SeqMute { SEQ_MUTE_0, SEQ_MUTE_1, SEQ_MUTE_2, SEQ_MUTE_3 }; + +namespace detail { +struct SeqTrack { + virtual ~SeqTrack(); + virtual UNKWORD Parse(bool) = 0; + + u8 mPlayerTrackNo; // at 0x4 + bool mOpenFlag; // at 0x5 + + float mVolume; // at 0x8 + float mPitch; // at 0xc + float FLOAT_0x10; + float FLOAT_0x14; + float FLOAT_0x18; + float FLOAT_0x1C; + float FLOAT_0x20; + float FLOATS_0x24[3]; + float FLOATS_0x30[4]; + float FLOATS_0x40[4]; + + const u8 *PTR_0x50; + const u8 *PTR_0x54; + + int TIMER_0x58; + + bool BOOL_0x5C; + char BYTE_0x5D; + bool BOOL_0x5E; + bool BOOL_0x5F; + bool BOOL_0x60; + + int INT_0x64; + UNKWORD WORD_0x68; + + LfoParam mLfoParam; // at 0x6c + + u8 BYTE_0x7C; + float FLOAT_0x80; + u8 BYTE_0x84; + u8 BYTE_0x85; + s8 BYTE_0x86; + u8 BYTE_0x87; + s8 BYTE_0x88; + s8 BYTE_0x89; + s8 BYTE_0x8A; + char BYTE_0x8B; + u8 BYTE_0x8C; + char BYTE_0x8D; + u8 BYTE_0x8E; + + u8 mAttack; // at 0x8f + u8 mDecay; // at 0x90 + u8 mSustain; // at 0x91 + u8 mRelease; // at 0x92 + + u8 BYTE_0x93; + u8 BYTES_0x94[3]; + char BYTE_0x97; + + s16 mVariables[0x10]; // at 0x98 + + SeqPlayer *mPlayer; // at 0xb8 + Channel *mChannel; // at 0xbc + + void SetPlayerTrackNo(int); + + SeqTrack(); + + UNKTYPE InitParam(); + + void SetSeqData(const void *, s32); + + void Open(); + void Close(); + + void UpdateChannelRelease(Channel *); // inlined + void UpdateChannelLength(); + UNKWORD ParseNextTick(bool); + void ReleaseAllChannel(int); + UNKTYPE PauseAllChannel(bool); + void UpdateChannelParam(); + UNKTYPE FreeAllChannel(); + + static void ChannelCallbackFunc(Channel *, Channel::ChannelCallbackStatus, u32); + + void StopAllChannel(); // inlined + void SetMute(SeqMute); + void SetVolume(float); + void SetPitch(float); + s16 *GetVariablePtr(int); + void AddChannel(Channel *); // inlined + Channel *NoteOn(int, int, s32, bool); + + inline bool IsOpened() const { + return mOpenFlag; + } +}; + +struct SeqTrackAllocator { + inline virtual ~SeqTrackAllocator() {} + virtual SeqTrack *AllocTrack(SeqPlayer *) = 0; + virtual void FreeTrack(SeqTrack *) = 0; + virtual int GetAllocatableTrackCount() const = 0; +}; +} // namespace detail +} // namespace snd +} // namespace nw4r +#endif diff --git a/include/nw4r/snd/snd_Sound3DListener.h b/include/nw4r/snd/snd_Sound3DListener.h index 2a61b8cd..4e12f717 100644 --- a/include/nw4r/snd/snd_Sound3DListener.h +++ b/include/nw4r/snd/snd_Sound3DListener.h @@ -1,23 +1,20 @@ #ifndef NW4R_SND_SOUND_3D_LISTENER_H #define NW4R_SND_SOUND_3D_LISTENER_H -#include "types_nw4r.h" +#include "common.h" #include "math_types.h" -namespace nw4r -{ - namespace snd - { - struct Sound3DListener - { - math::MTX34 mMatrix; // at 0x0 - - float mInteriorSize; // at 0x30 - float mMaxVolumeDistance; // at 0x34 - float mUnitDistance; // at 0x38 - - Sound3DListener(); - }; - } -} +namespace nw4r { +namespace snd { +struct Sound3DListener { + math::MTX34 mMatrix; // at 0x0 -#endif \ No newline at end of file + float mInteriorSize; // at 0x30 + float mMaxVolumeDistance; // at 0x34 + float mUnitDistance; // at 0x38 + + Sound3DListener(); +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SoundArchive.h b/include/nw4r/snd/snd_SoundArchive.h index 3a3bd351..4745ab93 100644 --- a/include/nw4r/snd/snd_SoundArchive.h +++ b/include/nw4r/snd/snd_SoundArchive.h @@ -1,163 +1,147 @@ #ifndef NW4R_SND_SOUND_ARCHIVE_H #define NW4R_SND_SOUND_ARCHIVE_H +#include "common.h" #include "ut_FileStream.h" -#include "types_nw4r.h" -namespace nw4r -{ - namespace snd - { - struct SoundArchive - { - struct Sound3DParam - { - UNKWORD WORD_0x0; - u8 BYTE_0x4; - u8 BYTE_0x5; - }; - - struct SoundArchivePlayerInfo - { - u32 SIZE_0x0; - UNKWORD WORD_0x4; - u32 SIZE_0x8; - UNKWORD WORD_0xC; - UNKWORD WORD_0x10; - u32 SIZE_0x14; - UNKWORD WORD_0x18; - }; - - struct SoundInfo - { - UNKWORD WORD_0x0; - UNKWORD WORD_0x4; - UNKWORD WORD_0x8; - UNKWORD WORD_0xC; - UNKWORD WORD_0x10; - UNKWORD WORD_0x14; - UNKWORD WORD_0x18; - }; - - struct SeqSoundInfo - { - UNKWORD WORD_0x0; - UNKWORD WORD_0x4; - UNKWORD WORD_0x8; - UNKWORD WORD_0xC; - bool BOOL_0x10; - }; - - struct StrmSoundInfo - { - - }; - - struct WaveSoundInfo - { - UNKWORD WORD_0x0; - UNKWORD WORD_0x4; - bool BOOL_0x8; - }; - - struct BankInfo - { - UNKWORD WORD_0x0; - }; - - struct PlayerInfo - { - UNKWORD WORD_0x0; - UNKWORD WORD_0x4; - }; - - struct GroupInfo - { - u32 mCount; // at 0x0 - const char * mExternalFileName; // at 0x4 - u32 INT_0x8; - u32 INT_0xC; - u32 INT_0x10; - u32 INT_0x14; - }; - - struct GroupItemInfo - { - UNKWORD WORD_0x0; - u32 INT_0x4; - u32 INT_0x8; - u32 INT_0xC; - UNKWORD WORD_0x10; - }; - - struct FileInfo - { - UNKWORD WORD_0x0; - UNKWORD WORD_0x4; - const char * mExternalFileName; // at 0x8 - u32 SIZE_0xC; - }; - - struct FilePos - { - u32 mGroupIndex; // at 0x0 - u32 mGroupItemIndex; // at 0x4 - }; - - virtual ~SoundArchive(); // at 0x8 - virtual const void * detail_GetFileAddress(u32) const = 0; // at 0xc - virtual const void * detail_GetWaveDataFileAddress(u32) const = 0; // at 0x10 - virtual int detail_GetRequiredStreamBufferSize() const = 0; // at 0x14 - virtual ut::FileStream * OpenStream(void *, int, u32, u32) const = 0; // at 0x18 - virtual ut::FileStream * OpenExtStream(void *, int, const char *, u32, u32) const = 0; // at 0x1c - - detail::SoundArchiveFileReader * mFileReader; // at 0x4 - char mExternalFileRoot[0x100]; // at 0x8 - - SoundArchive(); - - bool IsAvailable() const; - - void Setup(detail::SoundArchiveFileReader *); - void Shutdown(); - - u32 GetPlayerCount() const; - u32 GetGroupCount() const; - - const char * GetSoundLabelString(u32) const; - - u32 ConvertLabelStringToSoundId(const char *) const; - u32 ConvertLabelStringToPlayerId(const char *) const; - u32 ConvertLabelStringToGroupId(const char *) const; - - UNKWORD GetSoundUserParam(u32) const; - UNKWORD GetSoundType(u32) const; - - bool ReadSoundInfo(u32, SoundInfo *) const; - - bool detail_ReadSeqSoundInfo(u32, SeqSoundInfo *) const; - bool detail_ReadStrmSoundInfo(u32, StrmSoundInfo *) const; - bool detail_ReadWaveSoundInfo(u32, WaveSoundInfo *) const; - - bool ReadPlayerInfo(u32, PlayerInfo *) const; - - bool ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo *) const; - - bool detail_ReadSound3DParam(u32, Sound3DParam *) const; - - bool detail_ReadBankInfo(u32, BankInfo *) const; - bool detail_ReadGroupInfo(u32, GroupInfo *) const; - bool detail_ReadGroupItemInfo(u32, u32, GroupItemInfo *) const; - bool detail_ReadFileInfo(u32, FileInfo *) const; - bool detail_ReadFilePos(u32, u32, FilePos *) const; - - ut::FileStream * OpenExtStreamImpl(void *, int, const char *, u32, u32) const; //inlined - ut::FileStream * detail_OpenFileStream(u32, void *, int) const; - ut::FileStream * detail_OpenGroupStream(u32, void *, int) const; - ut::FileStream * detail_OpenGroupWaveDataStream(u32, void *, int) const; - - UNKTYPE SetExternalFileRoot(const char *); - }; - } -} -#endif \ No newline at end of file +namespace nw4r { +namespace snd { +struct SoundArchive { + struct Sound3DParam { + UNKWORD WORD_0x0; + u8 BYTE_0x4; + u8 BYTE_0x5; + }; + + struct SoundArchivePlayerInfo { + u32 SIZE_0x0; + UNKWORD WORD_0x4; + u32 SIZE_0x8; + UNKWORD WORD_0xC; + UNKWORD WORD_0x10; + u32 SIZE_0x14; + UNKWORD WORD_0x18; + }; + + struct SoundInfo { + UNKWORD WORD_0x0; + UNKWORD WORD_0x4; + UNKWORD WORD_0x8; + UNKWORD WORD_0xC; + UNKWORD WORD_0x10; + UNKWORD WORD_0x14; + UNKWORD WORD_0x18; + }; + + struct SeqSoundInfo { + UNKWORD WORD_0x0; + UNKWORD WORD_0x4; + UNKWORD WORD_0x8; + UNKWORD WORD_0xC; + bool BOOL_0x10; + }; + + struct StrmSoundInfo {}; + + struct WaveSoundInfo { + UNKWORD WORD_0x0; + UNKWORD WORD_0x4; + bool BOOL_0x8; + }; + + struct BankInfo { + UNKWORD WORD_0x0; + }; + + struct PlayerInfo { + UNKWORD WORD_0x0; + UNKWORD WORD_0x4; + }; + + struct GroupInfo { + u32 mCount; // at 0x0 + const char *mExternalFileName; // at 0x4 + u32 INT_0x8; + u32 INT_0xC; + u32 INT_0x10; + u32 INT_0x14; + }; + + struct GroupItemInfo { + UNKWORD WORD_0x0; + u32 INT_0x4; + u32 INT_0x8; + u32 INT_0xC; + UNKWORD WORD_0x10; + }; + + struct FileInfo { + UNKWORD WORD_0x0; + UNKWORD WORD_0x4; + const char *mExternalFileName; // at 0x8 + u32 SIZE_0xC; + }; + + struct FilePos { + u32 mGroupIndex; // at 0x0 + u32 mGroupItemIndex; // at 0x4 + }; + + virtual ~SoundArchive(); // at 0x8 + virtual const void *detail_GetFileAddress(u32) const = 0; // at 0xc + virtual const void *detail_GetWaveDataFileAddress(u32) const = 0; // at 0x10 + virtual int detail_GetRequiredStreamBufferSize() const = 0; // at 0x14 + virtual ut::FileStream *OpenStream(void *, int, u32, u32) const = 0; // at 0x18 + virtual ut::FileStream *OpenExtStream(void *, int, const char *, u32, u32) const = 0; // at 0x1c + + detail::SoundArchiveFileReader *mFileReader; // at 0x4 + char mExternalFileRoot[0x100]; // at 0x8 + + SoundArchive(); + + bool IsAvailable() const; + + void Setup(detail::SoundArchiveFileReader *); + void Shutdown(); + + u32 GetPlayerCount() const; + u32 GetGroupCount() const; + + const char *GetSoundLabelString(u32) const; + + u32 ConvertLabelStringToSoundId(const char *) const; + u32 ConvertLabelStringToPlayerId(const char *) const; + u32 ConvertLabelStringToGroupId(const char *) const; + + UNKWORD GetSoundUserParam(u32) const; + UNKWORD GetSoundType(u32) const; + + bool ReadSoundInfo(u32, SoundInfo *) const; + + bool detail_ReadSeqSoundInfo(u32, SeqSoundInfo *) const; + bool detail_ReadStrmSoundInfo(u32, StrmSoundInfo *) const; + bool detail_ReadWaveSoundInfo(u32, WaveSoundInfo *) const; + + bool ReadPlayerInfo(u32, PlayerInfo *) const; + + bool ReadSoundArchivePlayerInfo(SoundArchivePlayerInfo *) const; + + bool detail_ReadSound3DParam(u32, Sound3DParam *) const; + + bool detail_ReadBankInfo(u32, BankInfo *) const; + bool detail_ReadGroupInfo(u32, GroupInfo *) const; + bool detail_ReadGroupItemInfo(u32, u32, GroupItemInfo *) const; + bool detail_ReadFileInfo(u32, FileInfo *) const; + bool detail_ReadFilePos(u32, u32, FilePos *) const; + + ut::FileStream *OpenExtStreamImpl(void *, int, const char *, u32, u32) const; // inlined + ut::FileStream *detail_OpenFileStream(u32, void *, int) const; + ut::FileStream *detail_OpenGroupStream(u32, void *, int) const; + ut::FileStream *detail_OpenGroupWaveDataStream(u32, void *, int) const; + + UNKTYPE SetExternalFileRoot(const char *); +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SoundArchiveFile.h b/include/nw4r/snd/snd_SoundArchiveFile.h index eff6e904..d3af2f18 100644 --- a/include/nw4r/snd/snd_SoundArchiveFile.h +++ b/include/nw4r/snd/snd_SoundArchiveFile.h @@ -1,278 +1,245 @@ #ifndef NW4R_SND_SOUND_ARCHIVE_FILE_H #define NW4R_SND_SOUND_ARCHIVE_FILE_H -#include "types_nw4r.h" -#include "ut_binaryFileFormat.h" -#include "snd_Util.h" +#include "common.h" #include "snd_SoundArchive.h" +#include "snd_Util.h" +#include "ut_binaryFileFormat.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - namespace SoundArchiveFile - { - struct Header - { - ut::BinaryFileHeader mHeader; // at 0x0 - u32 mLabelStringChunkOffset; // at 0x10 - u32 mLabelStringChunkSize; // at 0x14 - u32 mInfoChunkOffset; // at 0x18 - u32 mInfoChunkSize; // at 0x1c - UNKWORD UNK_0x20[0x8 / sizeof(UNKWORD)]; // at 0x20 - }; - - struct Sound3DParam - { - UNKWORD WORD_0x0; - u8 BYTE_0x4; - u8 BYTE_0x5; - }; - - struct SeqSoundInfo - { - UNKWORD WORD_0x0; - UNKWORD WORD_0x4; - UNKWORD WORD_0x8; - u8 BYTE_0xC; - u8 BYTE_0xD; - }; - - struct StrmSoundInfo - { - - }; - - struct WaveSoundInfo - { - UNKWORD WORD_0x0; - char UNK_0x4[0x4]; - u8 BYTE_0x8; - u8 BYTE_0x9; - }; - - typedef Util::DataRef SoundInfoOffset; - - struct SoundCommonInfo - { - u32 mSoundStringId; // at 0x0 - UNKWORD WORD_0x4; - UNKWORD WORD_0x8; - Util::DataRef mSound3DParam; // at 0xc - u8 BYTE_0x14; - u8 BYTE_0x15; - u8 mType; // at 0x16 - u8 BYTE_0x17; - SoundInfoOffset mSoundInfoOffset; // at 0x18 - UNKWORD mSoundUserParam; // at 0x20 - char UNK_0x24[0x4]; - u8 BYTE_0x28; - u8 BYTE_0x29; - }; - - typedef Util::Table > SoundCommonTable; - - struct BankInfo - { - char UNK_0x0[0x4]; - UNKWORD WORD_0x4; - }; - - typedef Util::Table > BankTable; - - struct PlayerInfo - { - char UNK_0x0[0x4]; - u8 BYTE_0x4; - UNKWORD WORD_0x8; - }; - - typedef Util::Table > PlayerTable; - - struct GroupItemInfo - { - UNKWORD WORD_0x0; - u32 INT_0x4; - u32 INT_0x8; - u32 INT_0xC; - UNKWORD WORD_0x10; - }; - - typedef Util::Table > GroupItemTable; - - struct GroupInfo - { - char UNK_0x0[0x8]; - Util::DataRef mExternalFileName; // at 0x8 - u32 INT_0x10; - u32 INT_0x14; - u32 INT_0x18; - u32 INT_0x1C; - Util::DataRef mGroupItemTable; // at 0x20 - }; - - typedef Util::Table > GroupTable; - - struct SoundArchivePlayerInfo - { - u16 SIZE_0x0; - u16 SHORT_0x2; - u16 SIZE_0x4; - u16 SHORT_0x6; - u16 SHORT_0x8; - u16 SIZE_0xA; - u16 SHORT_0xC; - }; - - typedef Util::Table > FilePosTable; - - struct FileInfo - { - UNKWORD WORD_0x0; - UNKWORD WORD_0x4; - char UNK_0x8[0x4]; - Util::DataRef mExternalFileName; // at 0xc - Util::DataRef TABLE_0x14; - }; - - typedef Util::Table > FileTable; - - struct StringNode - { - enum - { - FLAG_LEAF = 0x0001 - }; - - u16 mFlags; // at 0x0 - u16 SHORT_0x2; - u32 mLeftIndex; // at 0x4 - u32 mRightIndex; // at 0x8 - u32 mStringId; // at 0xc - u32 mId; // at 0x10 - }; - - struct StringTree - { - u32 mRootIndex; // at 0x0 - u32 INT_0x4; - StringNode mNodes[]; // at 0x8 - }; - - struct StringChunk - { - u32 mTableOffset; // at 0x0 - u32 mSoundTreeOffset; // at 0x4 - u32 mPlayerTreeOffset; // at 0x8 - u32 mGroupTreeOffset; // at 0xc - u32 OFFSET_0x10; - }; - - struct InfoChunk - { - Util::DataRef mSoundCommonTable; // at 0x0 - Util::DataRef mBankTable; // at 0x8 - Util::DataRef mPlayerTable; // at 0x10 - Util::DataRef mFileTable; // at 0x18 - Util::DataRef mGroupTable; // at 0x20 - Util::DataRef mSoundArchivePlayerInfo; // at 0x28 - }; - }; - - struct SoundArchiveFileReader - { - struct StringBlock - { - ut::BinaryBlockHeader mHeader; // at 0x0 - SoundArchiveFile::StringChunk mChunk; // at 0x8 - }; - - struct InfoBlock - { - ut::BinaryBlockHeader mHeader; // at 0x0 - SoundArchiveFile::InfoChunk mChunk; // at 0x8 - }; - - SoundArchiveFile::Header mHeader; // at 0x0 - - const SoundArchiveFile::InfoChunk * mInfoChunk; // at 0x28 - const SoundArchiveFile::StringChunk * mStringChunk; // at 0x2c - const Util::Table * mStringTable; // at 0x30 - const SoundArchiveFile::StringTree * mSoundStringTree; // at 0x34 - const SoundArchiveFile::StringTree * mPlayerStringTree; // at 0x38 - const SoundArchiveFile::StringTree * mGroupStringTree; // at 0x3c - const UNKTYPE * PTR_0x40; - - SoundArchiveFileReader(); - - bool IsValidFileHeader(const void *); //inlined - void Init(const void *); - - const void * GetPtrConst(const void *, u32) const; //inlined - - void SetStringChunk(const void *, u32); - void SetInfoChunk(const void *, u32); - - UNKWORD GetSoundType(u32) const; - - const SoundArchiveFile::SoundCommonInfo * impl_GetSoundInfo(u32) const; //inlined - bool ReadSoundInfo(u32, SoundArchive::SoundInfo *) const; - bool ReadSound3DParam(u32, SoundArchive::Sound3DParam *) const; - bool ReadSeqSoundInfo(u32, SoundArchive::SeqSoundInfo *) const; - bool ReadStrmSoundInfo(u32, SoundArchive::StrmSoundInfo *) const; - bool ReadWaveSoundInfo(u32, SoundArchive::WaveSoundInfo *) const; - const SoundArchiveFile::BankInfo * impl_GetBankInfo(u32) const; //inlined - bool ReadBankInfo(u32, SoundArchive::BankInfo *) const; - const SoundArchiveFile::PlayerInfo * impl_GetPlayerInfo(u32) const; //inlined - bool ReadPlayerInfo(u32, SoundArchive::PlayerInfo *) const; - const SoundArchiveFile::GroupInfo * impl_GetGroupInfo(u32) const; //inlined - bool ReadGroupInfo(u32, SoundArchive::GroupInfo *) const; - bool ReadGroupItemInfo(u32, u32, SoundArchive::GroupItemInfo *) const; - bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo *) const; - - u32 GetPlayerCount() const; - u32 GetGroupCount() const; - - u32 GetSoundStringId(u32) const; //inlined - const char * GetString(u32) const; //inlined - const char * GetSoundLabelString(u32) const; - UNKWORD GetSoundUserParam(u32) const; - - bool ReadFileInfo(u32, SoundArchive::FileInfo *) const; - bool ReadFilePos(u32, u32, SoundArchive::FilePos *) const; - - u32 ConvertLabelStringToId(const SoundArchiveFile::StringTree *, const char *) const; - - SoundArchiveFile::SoundInfoOffset impl_GetSoundInfoOffset(u32) const; - - inline u16 GetVersion() const - { - return mHeader.mHeader.version; - } - - inline u32 GetLabelStringChunkOffset() const - { - return mHeader.mLabelStringChunkOffset; - } - - inline u32 GetLabelStringChunkSize() const - { - return mHeader.mLabelStringChunkSize; - } - - inline u32 GetInfoChunkOffset() const - { - return mHeader.mInfoChunkOffset; - } - - inline u32 GetInfoChunkSize() const - { - return mHeader.mInfoChunkSize; - } - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +namespace SoundArchiveFile { +struct Header { + ut::BinaryFileHeader mHeader; // at 0x0 + u32 mLabelStringChunkOffset; // at 0x10 + u32 mLabelStringChunkSize; // at 0x14 + u32 mInfoChunkOffset; // at 0x18 + u32 mInfoChunkSize; // at 0x1c + UNKWORD UNK_0x20[0x8 / sizeof(UNKWORD)]; // at 0x20 +}; -#endif \ No newline at end of file +struct Sound3DParam { + UNKWORD WORD_0x0; + u8 BYTE_0x4; + u8 BYTE_0x5; +}; + +struct SeqSoundInfo { + UNKWORD WORD_0x0; + UNKWORD WORD_0x4; + UNKWORD WORD_0x8; + u8 BYTE_0xC; + u8 BYTE_0xD; +}; + +struct StrmSoundInfo {}; + +struct WaveSoundInfo { + UNKWORD WORD_0x0; + char UNK_0x4[0x4]; + u8 BYTE_0x8; + u8 BYTE_0x9; +}; + +typedef Util::DataRef SoundInfoOffset; + +struct SoundCommonInfo { + u32 mSoundStringId; // at 0x0 + UNKWORD WORD_0x4; + UNKWORD WORD_0x8; + Util::DataRef mSound3DParam; // at 0xc + u8 BYTE_0x14; + u8 BYTE_0x15; + u8 mType; // at 0x16 + u8 BYTE_0x17; + SoundInfoOffset mSoundInfoOffset; // at 0x18 + UNKWORD mSoundUserParam; // at 0x20 + char UNK_0x24[0x4]; + u8 BYTE_0x28; + u8 BYTE_0x29; +}; + +typedef Util::Table> SoundCommonTable; + +struct BankInfo { + char UNK_0x0[0x4]; + UNKWORD WORD_0x4; +}; + +typedef Util::Table> BankTable; + +struct PlayerInfo { + char UNK_0x0[0x4]; + u8 BYTE_0x4; + UNKWORD WORD_0x8; +}; + +typedef Util::Table> PlayerTable; + +struct GroupItemInfo { + UNKWORD WORD_0x0; + u32 INT_0x4; + u32 INT_0x8; + u32 INT_0xC; + UNKWORD WORD_0x10; +}; + +typedef Util::Table> GroupItemTable; + +struct GroupInfo { + char UNK_0x0[0x8]; + Util::DataRef mExternalFileName; // at 0x8 + u32 INT_0x10; + u32 INT_0x14; + u32 INT_0x18; + u32 INT_0x1C; + Util::DataRef mGroupItemTable; // at 0x20 +}; + +typedef Util::Table> GroupTable; + +struct SoundArchivePlayerInfo { + u16 SIZE_0x0; + u16 SHORT_0x2; + u16 SIZE_0x4; + u16 SHORT_0x6; + u16 SHORT_0x8; + u16 SIZE_0xA; + u16 SHORT_0xC; +}; + +typedef Util::Table> FilePosTable; + +struct FileInfo { + UNKWORD WORD_0x0; + UNKWORD WORD_0x4; + char UNK_0x8[0x4]; + Util::DataRef mExternalFileName; // at 0xc + Util::DataRef TABLE_0x14; +}; + +typedef Util::Table> FileTable; + +struct StringNode { + enum { FLAG_LEAF = 0x0001 }; + + u16 mFlags; // at 0x0 + u16 SHORT_0x2; + u32 mLeftIndex; // at 0x4 + u32 mRightIndex; // at 0x8 + u32 mStringId; // at 0xc + u32 mId; // at 0x10 +}; + +struct StringTree { + u32 mRootIndex; // at 0x0 + u32 INT_0x4; + StringNode mNodes[]; // at 0x8 +}; + +struct StringChunk { + u32 mTableOffset; // at 0x0 + u32 mSoundTreeOffset; // at 0x4 + u32 mPlayerTreeOffset; // at 0x8 + u32 mGroupTreeOffset; // at 0xc + u32 OFFSET_0x10; +}; + +struct InfoChunk { + Util::DataRef mSoundCommonTable; // at 0x0 + Util::DataRef mBankTable; // at 0x8 + Util::DataRef mPlayerTable; // at 0x10 + Util::DataRef mFileTable; // at 0x18 + Util::DataRef mGroupTable; // at 0x20 + Util::DataRef mSoundArchivePlayerInfo; // at 0x28 +}; +}; // namespace SoundArchiveFile + +struct SoundArchiveFileReader { + struct StringBlock { + ut::BinaryBlockHeader mHeader; // at 0x0 + SoundArchiveFile::StringChunk mChunk; // at 0x8 + }; + + struct InfoBlock { + ut::BinaryBlockHeader mHeader; // at 0x0 + SoundArchiveFile::InfoChunk mChunk; // at 0x8 + }; + + SoundArchiveFile::Header mHeader; // at 0x0 + + const SoundArchiveFile::InfoChunk *mInfoChunk; // at 0x28 + const SoundArchiveFile::StringChunk *mStringChunk; // at 0x2c + const Util::Table *mStringTable; // at 0x30 + const SoundArchiveFile::StringTree *mSoundStringTree; // at 0x34 + const SoundArchiveFile::StringTree *mPlayerStringTree; // at 0x38 + const SoundArchiveFile::StringTree *mGroupStringTree; // at 0x3c + const UNKTYPE *PTR_0x40; + + SoundArchiveFileReader(); + + bool IsValidFileHeader(const void *); // inlined + void Init(const void *); + + const void *GetPtrConst(const void *, u32) const; // inlined + + void SetStringChunk(const void *, u32); + void SetInfoChunk(const void *, u32); + + UNKWORD GetSoundType(u32) const; + + const SoundArchiveFile::SoundCommonInfo *impl_GetSoundInfo(u32) const; // inlined + bool ReadSoundInfo(u32, SoundArchive::SoundInfo *) const; + bool ReadSound3DParam(u32, SoundArchive::Sound3DParam *) const; + bool ReadSeqSoundInfo(u32, SoundArchive::SeqSoundInfo *) const; + bool ReadStrmSoundInfo(u32, SoundArchive::StrmSoundInfo *) const; + bool ReadWaveSoundInfo(u32, SoundArchive::WaveSoundInfo *) const; + const SoundArchiveFile::BankInfo *impl_GetBankInfo(u32) const; // inlined + bool ReadBankInfo(u32, SoundArchive::BankInfo *) const; + const SoundArchiveFile::PlayerInfo *impl_GetPlayerInfo(u32) const; // inlined + bool ReadPlayerInfo(u32, SoundArchive::PlayerInfo *) const; + const SoundArchiveFile::GroupInfo *impl_GetGroupInfo(u32) const; // inlined + bool ReadGroupInfo(u32, SoundArchive::GroupInfo *) const; + bool ReadGroupItemInfo(u32, u32, SoundArchive::GroupItemInfo *) const; + bool ReadSoundArchivePlayerInfo(SoundArchive::SoundArchivePlayerInfo *) const; + + u32 GetPlayerCount() const; + u32 GetGroupCount() const; + + u32 GetSoundStringId(u32) const; // inlined + const char *GetString(u32) const; // inlined + const char *GetSoundLabelString(u32) const; + UNKWORD GetSoundUserParam(u32) const; + + bool ReadFileInfo(u32, SoundArchive::FileInfo *) const; + bool ReadFilePos(u32, u32, SoundArchive::FilePos *) const; + + u32 ConvertLabelStringToId(const SoundArchiveFile::StringTree *, const char *) const; + + SoundArchiveFile::SoundInfoOffset impl_GetSoundInfoOffset(u32) const; + + inline u16 GetVersion() const { + return mHeader.mHeader.version; + } + + inline u32 GetLabelStringChunkOffset() const { + return mHeader.mLabelStringChunkOffset; + } + + inline u32 GetLabelStringChunkSize() const { + return mHeader.mLabelStringChunkSize; + } + + inline u32 GetInfoChunkOffset() const { + return mHeader.mInfoChunkOffset; + } + + inline u32 GetInfoChunkSize() const { + return mHeader.mInfoChunkSize; + } +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SoundArchiveLoader.h b/include/nw4r/snd/snd_SoundArchiveLoader.h index 87f57846..ab33776e 100644 --- a/include/nw4r/snd/snd_SoundArchiveLoader.h +++ b/include/nw4r/snd/snd_SoundArchiveLoader.h @@ -1,52 +1,47 @@ #ifndef NW4R_SND_SOUND_ARCHIVE_LOADER_H #define NW4R_SND_SOUND_ARCHIVE_LOADER_H +#include "common.h" #include "snd_SoundMemoryAllocatable.h" #include "ut_FileStream.h" -#include "types_nw4r.h" #include -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct FileStreamHandle - { - ut::FileStream * mFileStream; - - inline FileStreamHandle(ut::FileStream * pFileStream) : mFileStream(pFileStream) {} - - inline ~FileStreamHandle() - { - if (mFileStream) mFileStream->Close(); - } - - inline operator bool() const - { - return mFileStream; - } - - inline ut::FileStream * operator->() - { - return mFileStream; - } - }; - - struct SoundArchiveLoader - { - OSMutex mMutex; // at 0x0 - const SoundArchive & mArchive; // at 0x18 - u8 mBuffer[0x200]; // at 0x1c - ut::FileStream * mFileStream; // at 0x21c - - SoundArchiveLoader(const SoundArchive &); - ~SoundArchiveLoader(); - - void * LoadGroup(u32, SoundMemoryAllocatable *, void **, u32); - }; - } - } -} -#endif \ No newline at end of file +namespace nw4r { +namespace snd { +namespace detail { +struct FileStreamHandle { + ut::FileStream *mFileStream; + + inline FileStreamHandle(ut::FileStream *pFileStream) : mFileStream(pFileStream) {} + + inline ~FileStreamHandle() { + if (mFileStream) { + mFileStream->Close(); + } + } + + inline operator bool() const { + return mFileStream; + } + + inline ut::FileStream *operator->() { + return mFileStream; + } +}; + +struct SoundArchiveLoader { + OSMutex mMutex; // at 0x0 + const SoundArchive &mArchive; // at 0x18 + u8 mBuffer[0x200]; // at 0x1c + ut::FileStream *mFileStream; // at 0x21c + + SoundArchiveLoader(const SoundArchive &); + ~SoundArchiveLoader(); + + void *LoadGroup(u32, SoundMemoryAllocatable *, void **, u32); +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SoundArchivePlayer.h b/include/nw4r/snd/snd_SoundArchivePlayer.h index 0070b4d4..50378b9c 100644 --- a/include/nw4r/snd/snd_SoundArchivePlayer.h +++ b/include/nw4r/snd/snd_SoundArchivePlayer.h @@ -1,53 +1,46 @@ #ifndef NW4R_SND_SOUND_ARCHIVE_PLAYER_H #define NW4R_SND_SOUND_ARCHIVE_PLAYER_H -#include "snd_SoundStartable.h" -#include "snd_SoundHandle.h" +#include "common.h" #include "snd_DisposeCallback.h" +#include "snd_SoundHandle.h" #include "snd_SoundMemoryAllocatable.h" -#include "types_nw4r.h" +#include "snd_SoundStartable.h" -namespace nw4r -{ - namespace snd - { - struct SoundArchivePlayer : detail::DisposeCallback, SoundStartable - { - SoundArchivePlayer(); - ~SoundArchivePlayer(); +namespace nw4r { +namespace snd { +struct SoundArchivePlayer : detail::DisposeCallback, SoundStartable { + SoundArchivePlayer(); + ~SoundArchivePlayer(); - bool IsAvailable() const; - bool Setup(const SoundArchive *, void *, u32, void *, u32); + bool IsAvailable() const; + bool Setup(const SoundArchive *, void *, u32, void *, u32); - void Shutdown(); - u32 GetRequiredMemSize(const SoundArchive *); - u32 GetRequiredStrmBufferSize(const SoundArchive *); + void Shutdown(); + u32 GetRequiredMemSize(const SoundArchive *); + u32 GetRequiredStrmBufferSize(const SoundArchive *); - void Update(); + void Update(); - SoundArchive * GetSoundArchive() const; - SoundPlayer * GetSoundPlayer(u32); + SoundArchive *GetSoundArchive() const; + SoundPlayer *GetSoundPlayer(u32); - UNKWORD detail_SetupSound(SoundHandle *, - u32, - detail::BasicSound::AmbientArgInfo *, - detail::ExternalSoundPlayer *, - bool, - const StartInfo *); + UNKWORD detail_SetupSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, detail::ExternalSoundPlayer *, + bool, const StartInfo *); - UNKWORD LoadGroup(u32, SoundMemoryAllocatable *, u32); - UNKWORD LoadGroup(const char *, SoundMemoryAllocatable *, u32); + UNKWORD LoadGroup(u32, SoundMemoryAllocatable *, u32); + UNKWORD LoadGroup(const char *, SoundMemoryAllocatable *, u32); - virtual void InvalidateData(const void *, const void *); - virtual void InvalidateWaveData(const void *, const void *); - virtual UNKWORD detail_ConvertLabelStringToSoundId(const char *); + virtual void InvalidateData(const void *, const void *); + virtual void InvalidateWaveData(const void *, const void *); + virtual UNKWORD detail_ConvertLabelStringToSoundId(const char *); - char UNK_0x4[0x8]; - SoundHandle mHandle; // at 0xC - char UNK_0x1C[0x14]; - u32 WORD_0x30; - char UNK_0x34[0xAC]; - }; - } -} + char UNK_0x4[0x8]; + SoundHandle mHandle; // at 0xC + char UNK_0x1C[0x14]; + u32 WORD_0x30; + char UNK_0x34[0xAC]; +}; +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h index b1071033..7ded3e2f 100644 --- a/include/nw4r/snd/snd_SoundHandle.h +++ b/include/nw4r/snd/snd_SoundHandle.h @@ -1,39 +1,42 @@ #ifndef NW4R_SND_SOUND_HANDLE_H #define NW4R_SND_SOUND_HANDLE_H -#include "types_nw4r.h" +#include "common.h" #include "snd_BasicSound.h" -namespace nw4r -{ - namespace snd - { - struct SoundHandle - { - detail::BasicSound * mSound; // at 0x0 - - void detail_AttachSound(detail::BasicSound *); - void detail_AttachSoundAsTempHandle(detail::BasicSound *); - void DetachSound(); - - inline SoundHandle() : mSound(NULL) {} - - inline ~SoundHandle() - { - DetachSound(); - } +namespace nw4r { +namespace snd { +struct SoundHandle { + detail::BasicSound *mSound; // at 0x0 - inline detail::BasicSound * detail_GetAttachedSound() { return mSound; } + void detail_AttachSound(detail::BasicSound *); + void detail_AttachSoundAsTempHandle(detail::BasicSound *); + void DetachSound(); - inline bool IsAttachedSound() const { return mSound != NULL; } + inline SoundHandle() : mSound(NULL) {} - inline void StartPrepared() - { - if (IsAttachedSound()) mSound->StartPrepared(); - } + inline ~SoundHandle() { + DetachSound(); + } - inline u32 GetId() const { return IsAttachedSound() ? mSound->GetId() : -1; } - }; - } -} + inline detail::BasicSound *detail_GetAttachedSound() { + return mSound; + } -#endif \ No newline at end of file + inline bool IsAttachedSound() const { + return mSound != NULL; + } + + inline void StartPrepared() { + if (IsAttachedSound()) { + mSound->StartPrepared(); + } + } + + inline u32 GetId() const { + return IsAttachedSound() ? mSound->GetId() : -1; + } +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SoundHeap.h b/include/nw4r/snd/snd_SoundHeap.h index 62987130..7c809994 100644 --- a/include/nw4r/snd/snd_SoundHeap.h +++ b/include/nw4r/snd/snd_SoundHeap.h @@ -1,33 +1,32 @@ #ifndef NW4R_SND_SOUND_HEAP_H #define NW4R_SND_SOUND_HEAP_H -#include "types_nw4r.h" +#include "common.h" #include "snd_FrameHeap.h" #include "snd_SoundMemoryAllocatable.h" #include -namespace nw4r -{ - namespace snd - { - struct SoundHeap : SoundMemoryAllocatable - { - SoundHeap(); - virtual ~SoundHeap(); // VMT 0x8 - bool Create(void *, u32); - void Destroy(); - virtual void * Alloc(u32); // VMT 0xC - void* Alloc(u32, detail::FrameHeap::AllocCallback, void *); - void Clear(); - int SaveState(); - void LoadState(int); - static void DisposeCallbackFunc(void *, u32, void *); +namespace nw4r { +namespace snd { +struct SoundHeap : SoundMemoryAllocatable { + SoundHeap(); + virtual ~SoundHeap(); // VMT 0x8 + bool Create(void *, u32); + void Destroy(); + virtual void *Alloc(u32); // VMT 0xC + void *Alloc(u32, detail::FrameHeap::AllocCallback, void *); + void Clear(); + int SaveState(); + void LoadState(int); + static void DisposeCallbackFunc(void *, u32, void *); - bool IsValid() { return mFrameHeap.PTR_0x0 != NULL; } + bool IsValid() { + return mFrameHeap.PTR_0x0 != NULL; + } - OSMutex mMutex; // 0x00 - detail::FrameHeap mFrameHeap; // 0x1C - }; - } -} + OSMutex mMutex; // 0x00 + detail::FrameHeap mFrameHeap; // 0x1C +}; +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_SoundInstanceManager.h b/include/nw4r/snd/snd_SoundInstanceManager.h index 3bb4a445..0786dbd2 100644 --- a/include/nw4r/snd/snd_SoundInstanceManager.h +++ b/include/nw4r/snd/snd_SoundInstanceManager.h @@ -1,61 +1,57 @@ #ifndef NW4R_SND_SOUND_INSTANCE_MANAGER_H #define NW4R_SND_SOUND_INSTANCE_MANAGER_H -#include -#include "types_nw4r.h" -#include "ut_lock.h" -#include "ut_LinkList.h" #include "snd_InstancePool.h" +#include "ut_LinkList.h" +#include "ut_lock.h" +#include #include "common.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - template - struct SoundInstanceManager - { - MemoryPool mPool; // at 0x0 - ut::LinkList mPriorityList; // at 0x4 - OSMutex mMutex; // at 0x10 - - inline void Free(T * pInstance) - { - ut::detail::AutoLock lock(mMutex); - - if (mPriorityList.IsEmpty()) return; - - mPriorityList.Erase(pInstance); - mPool.Free(pInstance); - } - - inline void InsertPriorityList(T * pInstance, int priority) - { - ut::LinkList::Iterator iter = mPriorityList.GetBeginIter(); - int curPriority; - - while (iter != mPriorityList.GetEndIter()) - { - curPriority = iter->CalcCurrentPlayerPriority(); - - if (priority < curPriority) break; - - iter++; - } - - mPriorityList.Insert(iter, pInstance); - } - - inline void UpdatePriority(T * pInstance, int priority) - { - ut::detail::AutoLock lock(mMutex); - - mPriorityList.Erase(pInstance); - InsertPriorityList(pInstance, priority); - } - }; - } - } -} -#endif \ No newline at end of file +namespace nw4r { +namespace snd { +namespace detail { +template +struct SoundInstanceManager { + MemoryPool mPool; // at 0x0 + ut::LinkList mPriorityList; // at 0x4 + OSMutex mMutex; // at 0x10 + + inline void Free(T *pInstance) { + ut::detail::AutoLock lock(mMutex); + + if (mPriorityList.IsEmpty()) { + return; + } + + mPriorityList.Erase(pInstance); + mPool.Free(pInstance); + } + + inline void InsertPriorityList(T *pInstance, int priority) { + ut::LinkList::Iterator iter = mPriorityList.GetBeginIter(); + int curPriority; + + while (iter != mPriorityList.GetEndIter()) { + curPriority = iter->CalcCurrentPlayerPriority(); + + if (priority < curPriority) { + break; + } + + iter++; + } + + mPriorityList.Insert(iter, pInstance); + } + + inline void UpdatePriority(T *pInstance, int priority) { + ut::detail::AutoLock lock(mMutex); + + mPriorityList.Erase(pInstance); + InsertPriorityList(pInstance, priority); + } +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SoundMemoryAllocatable.h b/include/nw4r/snd/snd_SoundMemoryAllocatable.h index 218df211..b9701464 100644 --- a/include/nw4r/snd/snd_SoundMemoryAllocatable.h +++ b/include/nw4r/snd/snd_SoundMemoryAllocatable.h @@ -1,17 +1,14 @@ #ifndef NW4R_SOUND_MEMORY_ALLOCATABLE_H #define NW4R_SOUND_MEMORY_ALLOCATABLE_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace snd - { - struct SoundMemoryAllocatable - { - virtual ~SoundMemoryAllocatable() {} // at 0x8 - virtual void * Alloc(u32) = 0; // at 0xc - }; - } -} +namespace nw4r { +namespace snd { +struct SoundMemoryAllocatable { + virtual ~SoundMemoryAllocatable() {} // at 0x8 + virtual void *Alloc(u32) = 0; // at 0xc +}; +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_SoundPlayer.h b/include/nw4r/snd/snd_SoundPlayer.h index 24ceee98..ec55a461 100644 --- a/include/nw4r/snd/snd_SoundPlayer.h +++ b/include/nw4r/snd/snd_SoundPlayer.h @@ -1,36 +1,36 @@ #ifndef NW4R_SND_SOUND_PLAYER_H #define NW4R_SND_SOUND_PLAYER_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace snd - { - class SoundPlayer - { - public: +namespace nw4r { +namespace snd { +class SoundPlayer { +public: + f32 GetVolume() const { + return mVolume; + } + f32 detail_GetMainOutVolume() const { + return mMainOutVolume; + } - f32 GetVolume() const { return mVolume; } - f32 detail_GetMainOutVolume() const { return mMainOutVolume; } + void StopAllSound(int); - void StopAllSound(int); + bool detail_IsEnabledOutputLine() const; + int detail_GetOutputLine() const; + f32 detail_GetRemoteOutVolume(int) const; + UNKTYPE detail_FreePlayerHeap(detail::BasicSound *); + UNKTYPE detail_InsertPriorityList(detail::BasicSound *); + UNKTYPE detail_RemoveSoundList(detail::BasicSound *); + UNKTYPE detail_RemovePriorityList(detail::BasicSound *); - bool detail_IsEnabledOutputLine() const; - int detail_GetOutputLine() const; - f32 detail_GetRemoteOutVolume(int) const; - UNKTYPE detail_FreePlayerHeap(detail::BasicSound *); - UNKTYPE detail_InsertPriorityList(detail::BasicSound *); - UNKTYPE detail_RemoveSoundList(detail::BasicSound *); - UNKTYPE detail_RemovePriorityList(detail::BasicSound *); +private: + char UNK_0x0[0x28]; + f32 mVolume; // at 0x28 + bool mEnableOutputLine; // at 0x2C + int mOutputLine; // at 0x30 + f32 mMainOutVolume; // at 0x34 +}; +} // namespace snd +} // namespace nw4r - private: - char UNK_0x0[0x28]; - f32 mVolume; // at 0x28 - bool mEnableOutputLine; // at 0x2C - int mOutputLine; // at 0x30 - f32 mMainOutVolume; // at 0x34 - }; - } -} - -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_SoundStartable.h b/include/nw4r/snd/snd_SoundStartable.h index 2868fd83..99c9f700 100644 --- a/include/nw4r/snd/snd_SoundStartable.h +++ b/include/nw4r/snd/snd_SoundStartable.h @@ -1,48 +1,31 @@ #ifndef NW4R_SND_SOUND_STARTABLE_H #define NW4R_SND_SOUND_STARTABLE_H +#include "common.h" #include "snd_BasicSound.h" -#include "types_nw4r.h" -namespace nw4r -{ - namespace snd - { - struct SoundStartable - { - struct StartInfo - { - - }; - - inline SoundStartable() {} - inline virtual ~SoundStartable() {} // at 0x8 - virtual UNKWORD detail_SetupSound(SoundHandle *, - u32, - detail::BasicSound::AmbientArgInfo *, - detail::ExternalSoundPlayer *, - bool, - const StartInfo *) = 0; // at 0xc - virtual UNKWORD detail_ConvertLabelStringToSoundId(const char *) = 0; // at 0x10 - UNKWORD detail_StartSound(SoundHandle *, - u32, - detail::BasicSound::AmbientArgInfo *, - detail::ExternalSoundPlayer *, - const StartInfo *); +namespace nw4r { +namespace snd { +struct SoundStartable { + struct StartInfo {}; - UNKWORD detail_HoldSound(SoundHandle *, - u32, - detail::BasicSound::AmbientArgInfo *, - detail::ExternalSoundPlayer *, - const StartInfo *); + inline SoundStartable() {} + inline virtual ~SoundStartable() {} // at 0x8 + virtual UNKWORD detail_SetupSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, + detail::ExternalSoundPlayer *, bool, + const StartInfo *) = 0; // at 0xc + virtual UNKWORD detail_ConvertLabelStringToSoundId(const char *) = 0; // at 0x10 - UNKWORD detail_PrepareSound(SoundHandle *, - u32, - detail::BasicSound::AmbientArgInfo *, - detail::ExternalSoundPlayer *, - const StartInfo *); - }; - } -} + UNKWORD detail_StartSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, detail::ExternalSoundPlayer *, + const StartInfo *); -#endif \ No newline at end of file + UNKWORD detail_HoldSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, detail::ExternalSoundPlayer *, + const StartInfo *); + + UNKWORD detail_PrepareSound(SoundHandle *, u32, detail::BasicSound::AmbientArgInfo *, detail::ExternalSoundPlayer *, + const StartInfo *); +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_SoundSystem.h b/include/nw4r/snd/snd_SoundSystem.h index c60affc9..4aa4da4c 100644 --- a/include/nw4r/snd/snd_SoundSystem.h +++ b/include/nw4r/snd/snd_SoundSystem.h @@ -1,36 +1,28 @@ #ifndef NW4R_SND_SOUND_SYSTEM_H #define NW4R_SND_SOUND_SYSTEM_H -#include "types_nw4r.h" +#include "common.h" #include "snd_AxManager.h" -namespace nw4r -{ - namespace snd - { - struct SoundSystem - { - struct SoundSystemParam - { +namespace nw4r { +namespace snd { +struct SoundSystem { + struct SoundSystemParam {}; - }; + static inline f32 GetMasterVolume() { + return detail::AxManager::GetInstance().GetMasterVolume(); + } - static inline f32 GetMasterVolume() - { - return detail::AxManager::GetInstance().GetMasterVolume(); - } + static inline void PrepareReset() { + detail::AxManager::GetInstance().PrepareReset(); + } - static inline void PrepareReset() - { - detail::AxManager::GetInstance().PrepareReset(); - } + void InitSoundSystem(s32, s32); + void InitSoundSystem(const SoundSystemParam &, void *, u32); + static void ShutdownSoundSystem(); + static void WaitForResetReady(); + UNKWORD GetRequiredMemSize(const SoundSystemParam &); +}; +} // namespace snd +} // namespace nw4r - void InitSoundSystem(s32, s32); - void InitSoundSystem(const SoundSystemParam&, void *, u32); - static void ShutdownSoundSystem(); - static void WaitForResetReady(); - UNKWORD GetRequiredMemSize(const SoundSystemParam &); - }; - } -} - -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_SoundThread.h b/include/nw4r/snd/snd_SoundThread.h index ca27746d..5e5699a9 100644 --- a/include/nw4r/snd/snd_SoundThread.h +++ b/include/nw4r/snd/snd_SoundThread.h @@ -1,7 +1,7 @@ #ifndef NW4R_SND_SOUND_THREAD_H #define NW4R_SND_SOUND_THREAD_H +#include "common.h" #include "snd_AxManager.h" -#include "types_nw4r.h" #include "ut_LinkList.h" #include #include diff --git a/include/nw4r/snd/snd_StrmChannel.h b/include/nw4r/snd/snd_StrmChannel.h index 20abdcc7..ab6e3fb0 100644 --- a/include/nw4r/snd/snd_StrmChannel.h +++ b/include/nw4r/snd/snd_StrmChannel.h @@ -1,31 +1,27 @@ #ifndef NW4R_SND_STRMCHANNEL_H #define NW4R_SND_STRMCHANNEL_H -#include "types_nw4r.h" +#include "common.h" #define BLOCK_MAX 0x20 -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct StrmBufferPool - { - void Setup(void *, u32, int); - void Shutdown(); - void * Alloc(); - void Free(void *); +namespace nw4r { +namespace snd { +namespace detail { +struct StrmBufferPool { + void Setup(void *, u32, int); + void Shutdown(); + void *Alloc(); + void Free(void *); - void *mBuffer; // at 0x0 - u32 mStrmBufferSize; // at 0x4 - u32 mBlockSize; // at 0x8 - s32 mBlockCount; // at 0xC (< BLOCK_MAX) - s32 mAllocCount; // at 0x10 - u8 mAllocFlags[4]; // at 0x14 (1 bit per block) - }; - } - } -} + void *mBuffer; // at 0x0 + u32 mStrmBufferSize; // at 0x4 + u32 mBlockSize; // at 0x8 + s32 mBlockCount; // at 0xC (< BLOCK_MAX) + s32 mAllocCount; // at 0x10 + u8 mAllocFlags[4]; // at 0x14 (1 bit per block) +}; +} // namespace detail +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_StrmPlayer.h b/include/nw4r/snd/snd_StrmPlayer.h index 1cd14dba..0bb90337 100644 --- a/include/nw4r/snd/snd_StrmPlayer.h +++ b/include/nw4r/snd/snd_StrmPlayer.h @@ -1,63 +1,58 @@ #ifndef NW4R_SND_STRMPLAYER_H #define NW4R_SND_STRMPLAYER_H -#include "types_nw4r.h" +#include "common.h" #include "snd_BasicPlayer.h" #include "snd_SoundThread.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct StrmPlayer : BasicPlayer, SoundThread::PlayerCallback - { - enum StartOffsetType - { +namespace nw4r { +namespace snd { +namespace detail { +struct StrmPlayer : BasicPlayer, SoundThread::PlayerCallback { + enum StartOffsetType { - }; + }; - virtual ~StrmPlayer(); // at 0x8 - virtual bool Start(); // at 0xc - virtual void Stop(); // at 0x10 - virtual void Pause(bool); // at 0x14 - virtual bool IsActive() const; // at 0x18 - virtual bool IsStarted() const; // at 0x1c - virtual bool IsPause() const; // at 0x20 + virtual ~StrmPlayer(); // at 0x8 + virtual bool Start(); // at 0xc + virtual void Stop(); // at 0x10 + virtual void Pause(bool); // at 0x14 + virtual bool IsActive() const; // at 0x18 + virtual bool IsStarted() const; // at 0x1c + virtual bool IsPause() const; // at 0x20 - virtual void OnUpdateFrameSoundThread(); // at 0xc - virtual void OnUpdateVoiceSoundThread(); // at 0x10 - virtual void OnShutdownSoundThread(); // at 0x14 + virtual void OnUpdateFrameSoundThread(); // at 0xc + virtual void OnUpdateVoiceSoundThread(); // at 0x10 + virtual void OnShutdownSoundThread(); // at 0x14 - struct StrmDataLoadTask - { - virtual ~StrmDataLoadTask(); - virtual UNKTYPE Execute(); - virtual UNKTYPE Cancel(); - virtual UNKTYPE OnCancel(); - }; + struct StrmDataLoadTask { + virtual ~StrmDataLoadTask(); + virtual UNKTYPE Execute(); + virtual UNKTYPE Cancel(); + virtual UNKTYPE OnCancel(); + }; - struct StrmHeaderLoadTask - { - virtual ~StrmHeaderLoadTask(); - virtual UNKTYPE Execute(); - virtual UNKTYPE Cancel(); - virtual UNKTYPE OnCancel(); - }; + struct StrmHeaderLoadTask { + virtual ~StrmHeaderLoadTask(); + virtual UNKTYPE Execute(); + virtual UNKTYPE Cancel(); + virtual UNKTYPE OnCancel(); + }; - bool IsPrepared() const { return mIsPrepared; } - - StrmPlayer(); - bool Setup(StrmBufferPool *); - bool Prepare(ut::FileStream *, int, StartOffsetType, int); - void Shutdown(); - - char UNK_D8[0x113 - 0xD8]; - bool mIsPrepared; // at 0x113 - char UNK_120[0x78C]; - }; - } + bool IsPrepared() const { + return mIsPrepared; } -} -#endif \ No newline at end of file + StrmPlayer(); + bool Setup(StrmBufferPool *); + bool Prepare(ut::FileStream *, int, StartOffsetType, int); + void Shutdown(); + + char UNK_D8[0x113 - 0xD8]; + bool mIsPrepared; // at 0x113 + char UNK_120[0x78C]; +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_StrmSound.h b/include/nw4r/snd/snd_StrmSound.h index d77ca533..cb84045e 100644 --- a/include/nw4r/snd/snd_StrmSound.h +++ b/include/nw4r/snd/snd_StrmSound.h @@ -1,39 +1,35 @@ #ifndef NW4R_SND_STRMSOUND_H #define NW4R_SND_STRMSOUND_H -#include "types_nw4r.h" +#include "common.h" #include "snd_BasicSound.h" #include "snd_StrmPlayer.h" #include "ut_RuntimeTypeInfo.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct StrmSound : BasicSound - { - StrmPlayer mPlayer; // at 0xD8 - StrmSoundHandle *mTempSpecialHandle; // at 0x920 - SoundInstanceManager *mManager; // at 0x924 +namespace nw4r { +namespace snd { +namespace detail { +struct StrmSound : BasicSound { + StrmPlayer mPlayer; // at 0xD8 + StrmSoundHandle *mTempSpecialHandle; // at 0x920 + SoundInstanceManager *mManager; // at 0x924 - StrmSound(SoundInstanceManager *); - bool Prepare(StrmBufferPool *, StrmPlayer::StartOffsetType, s32, int, ut::FileStream *); + StrmSound(SoundInstanceManager *); + bool Prepare(StrmBufferPool *, StrmPlayer::StartOffsetType, s32, int, ut::FileStream *); - static ut::detail::RuntimeTypeInfo typeInfo; - - virtual const ut::detail::RuntimeTypeInfo * GetRuntimeTypeInfo() const; // at 0x8 - virtual ~StrmSound(); // at 0xc - virtual UNKTYPE Shutdown(); // at 0x28 - virtual bool IsPrepared() const; // at 0x2c - virtual void SetPlayerPriority(int); // at 0x4c - virtual bool IsAttachedTempSpecialHandle(); // at 0x5c - virtual UNKTYPE DetachTempSpecialHandle(); // at 0x60 - virtual BasicPlayer * GetBasicPlayer(); // at 0x68 - virtual const BasicPlayer * GetBasicPlayer() const; // at 0x6c - }; - } - } -} + static ut::detail::RuntimeTypeInfo typeInfo; -#endif \ No newline at end of file + virtual const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const; // at 0x8 + virtual ~StrmSound(); // at 0xc + virtual UNKTYPE Shutdown(); // at 0x28 + virtual bool IsPrepared() const; // at 0x2c + virtual void SetPlayerPriority(int); // at 0x4c + virtual bool IsAttachedTempSpecialHandle(); // at 0x5c + virtual UNKTYPE DetachTempSpecialHandle(); // at 0x60 + virtual BasicPlayer *GetBasicPlayer(); // at 0x68 + virtual const BasicPlayer *GetBasicPlayer() const; // at 0x6c +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_StrmSoundHandle.h b/include/nw4r/snd/snd_StrmSoundHandle.h index c64e61ee..dfafb738 100644 --- a/include/nw4r/snd/snd_StrmSoundHandle.h +++ b/include/nw4r/snd/snd_StrmSoundHandle.h @@ -1,24 +1,20 @@ #ifndef NW4R_SND_STRMSOUNDHANDLE_H #define NW4R_SND_STRMSOUNDHANDLE_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace snd - { - struct StrmSoundHandle - { - detail::StrmSound *mStrmSound; // at 0x0 +namespace nw4r { +namespace snd { +struct StrmSoundHandle { + detail::StrmSound *mStrmSound; // at 0x0 - inline StrmSoundHandle() : mStrmSound(NULL) {} - inline bool IsAttachedSound() - { - return mStrmSound != NULL; - } - - void DetachSound(); - }; + inline StrmSoundHandle() : mStrmSound(NULL) {} + inline bool IsAttachedSound() { + return mStrmSound != NULL; } -} -#endif \ No newline at end of file + void DetachSound(); +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_Task.h b/include/nw4r/snd/snd_Task.h index 688a2c99..6752b996 100644 --- a/include/nw4r/snd/snd_Task.h +++ b/include/nw4r/snd/snd_Task.h @@ -1,28 +1,24 @@ #ifndef NW4R_SND_TASK_H #define NW4R_SND_TASK_H -#include "types_nw4r.h" +#include "common.h" #include "ut_LinkList.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct Task - { - virtual ~Task(); // at 0x8 - virtual void Execute() = 0; // at 0xc - virtual void Cancel() = 0; // at 0x10 - virtual void OnCancel() = 0; // at 0x14 - - ut::LinkListNode mNode; // at 0x4 - char BYTE_0xC; - - inline Task() : BYTE_0xC() {} - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct Task { + virtual ~Task(); // at 0x8 + virtual void Execute() = 0; // at 0xc + virtual void Cancel() = 0; // at 0x10 + virtual void OnCancel() = 0; // at 0x14 -#endif \ No newline at end of file + ut::LinkListNode mNode; // at 0x4 + char BYTE_0xC; + + inline Task() : BYTE_0xC() {} +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_TaskManager.h b/include/nw4r/snd/snd_TaskManager.h index 978fe886..1ef6f72d 100644 --- a/include/nw4r/snd/snd_TaskManager.h +++ b/include/nw4r/snd/snd_TaskManager.h @@ -1,7 +1,7 @@ #ifndef NW4R_SND_TASK_MANAGER_H #define NW4R_SND_TASK_MANAGER_H +#include "common.h" #include "snd_Task.h" -#include "types_nw4r.h" #include "ut_LinkList.h" #include "ut_lock.h" #include diff --git a/include/nw4r/snd/snd_TaskThread.h b/include/nw4r/snd/snd_TaskThread.h index 6cb6e4df..b966af2a 100644 --- a/include/nw4r/snd/snd_TaskThread.h +++ b/include/nw4r/snd/snd_TaskThread.h @@ -1,6 +1,6 @@ #ifndef NW4R_SND_TASKTHREAD_H #define NW4R_SND_TASKTHREAD_H -#include "types_nw4r.h" +#include "common.h" #include namespace nw4r { diff --git a/include/nw4r/snd/snd_Util.h b/include/nw4r/snd/snd_Util.h index dd48ddf5..a3c086d7 100644 --- a/include/nw4r/snd/snd_Util.h +++ b/include/nw4r/snd/snd_Util.h @@ -1,78 +1,66 @@ #ifndef NW4R_SND_UTIL_H #define NW4R_SND_UTIL_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - namespace Util - { - enum RefType - { - REFTYPE_ADDRESS, - REFTYPE_OFFSET, - }; - - template - struct DataRef - { - u8 mType; // at 0x0 - u8 BYTE_0x1; - u32 INT_0x4; - }; - - template - struct Table - { - u32 mCount; // at 0x0 - T mEntries[]; // at 0x4 - }; - - struct PanInfo - { - u32 mPanTableID; // 0x0, (PanTableTable) - bool BOOL_0x4; - bool BOOL_0x5; - }; +namespace nw4r { +namespace snd { +namespace detail { +namespace Util { +enum RefType { + REFTYPE_ADDRESS, + REFTYPE_OFFSET, +}; - template - inline const T0 * GetDataRefAddress0(const DataRef & dataRef, const void * ptr) - { - return (const T0 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr); - } - - template - inline const T1 * GetDataRefAddress1(const DataRef & dataRef, const void * ptr) - { - return (const T1 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr); - } - - template - inline const T2 * GetDataRefAddress2(const DataRef & dataRef, const void * ptr) - { - return (const T2 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr); - } - - template - inline const T3 * GetDataRefAddress3(const DataRef & dataRef, const void * ptr) - { - return (const T3 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr); - } +template +struct DataRef { + u8 mType; // at 0x0 + u8 BYTE_0x1; + u32 INT_0x4; +}; - f32 CalcPitchRatio(int); - f32 CalcVolumeRatio(f32); - f32 CalcPanRatio(f32, const PanInfo&); - f32 CalcSurroundPanRatio(f32, const PanInfo&); - int CalcLpfFreq(f32); - void GetRemoteFilterCoefs(int, u16 *, u16 *, u16 *, u16 *, u16 *); - u16 CalcRandom(); - const void * GetDataRefAddressImpl(RefType, u32, const void *); - } - } - } +template +struct Table { + u32 mCount; // at 0x0 + T mEntries[]; // at 0x4 +}; + +struct PanInfo { + u32 mPanTableID; // 0x0, (PanTableTable) + bool BOOL_0x4; + bool BOOL_0x5; +}; + +template +inline const T0 *GetDataRefAddress0(const DataRef &dataRef, const void *ptr) { + return (const T0 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr); } -#endif \ No newline at end of file +template +inline const T1 *GetDataRefAddress1(const DataRef &dataRef, const void *ptr) { + return (const T1 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr); +} + +template +inline const T2 *GetDataRefAddress2(const DataRef &dataRef, const void *ptr) { + return (const T2 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr); +} + +template +inline const T3 *GetDataRefAddress3(const DataRef &dataRef, const void *ptr) { + return (const T3 *)GetDataRefAddressImpl((RefType)dataRef.mType, dataRef.INT_0x4, ptr); +} + +f32 CalcPitchRatio(int); +f32 CalcVolumeRatio(f32); +f32 CalcPanRatio(f32, const PanInfo &); +f32 CalcSurroundPanRatio(f32, const PanInfo &); +int CalcLpfFreq(f32); +void GetRemoteFilterCoefs(int, u16 *, u16 *, u16 *, u16 *, u16 *); +u16 CalcRandom(); +const void *GetDataRefAddressImpl(RefType, u32, const void *); +} // namespace Util +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_Voice.h b/include/nw4r/snd/snd_Voice.h index f96b19d1..7052e7cf 100644 --- a/include/nw4r/snd/snd_Voice.h +++ b/include/nw4r/snd/snd_Voice.h @@ -1,67 +1,57 @@ #ifndef NW4R_SND_VOICE_H #define NW4R_SND_VOICE_H -#include "types_nw4r.h" +#include "common.h" #include "snd_AxManager.h" -#include "snd_WaveFile.h" #include "snd_Common.h" +#include "snd_WaveFile.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct Voice - { - enum VoiceCallbackStatus - { - STATUS_0, - STATUS_1, - STATUS_2, - STATUS_3 - }; +namespace nw4r { +namespace snd { +namespace detail { +struct Voice { + enum VoiceCallbackStatus { STATUS_0, STATUS_1, STATUS_2, STATUS_3 }; - enum VoiceSyncFlag { - SYNC_AX_SRC_INITIAL = (1 << 0), - SYNC_AX_VOICE = (1 << 1), - SYNC_AX_SRC = (1 << 2), - SYNC_AX_VE = (1 << 3), - SYNC_AX_MIX = (1 << 4), - SYNC_AX_LPF = (1 << 5), - SYNC_AX_REMOTE = (1 << 7), - SYNC_AX_BIQUAD = (1 << 8), - }; - - typedef void (* VoiceCallback)(Voice *, VoiceCallbackStatus, void *); - - UNKTYPE Start(); - UNKTYPE Setup(const WaveData &, u32); - UNKTYPE SetPriority(int); - UNKTYPE Stop(); - UNKTYPE Free(); - UNKTYPE SetPanMode(PanMode); - UNKTYPE SetPanCurve(PanCurve); - UNKTYPE SetVolume(float); - UNKTYPE SetVeVolume(float, float); - UNKTYPE SetPitch(float); - UNKTYPE SetPan(float); - UNKTYPE SetSurroundPan(float); - UNKTYPE SetLpfFreq(float); - UNKTYPE SetRemoteFilter(int); - UNKTYPE SetOutputLine(int); - UNKTYPE SetMainOutVolume(float); - UNKTYPE SetMainSend(float); - - UNKTYPE SetFxSend(AuxBus, float); - - UNKTYPE SetRemoteOutVolume(int, float); - UNKTYPE SetRemoteSend(int, float); - UNKTYPE SetRemoteFxSend(int, float); - - UNKTYPE Pause(bool); - }; - } - } -} + enum VoiceSyncFlag { + SYNC_AX_SRC_INITIAL = (1 << 0), + SYNC_AX_VOICE = (1 << 1), + SYNC_AX_SRC = (1 << 2), + SYNC_AX_VE = (1 << 3), + SYNC_AX_MIX = (1 << 4), + SYNC_AX_LPF = (1 << 5), + SYNC_AX_REMOTE = (1 << 7), + SYNC_AX_BIQUAD = (1 << 8), + }; -#endif \ No newline at end of file + typedef void (*VoiceCallback)(Voice *, VoiceCallbackStatus, void *); + + UNKTYPE Start(); + UNKTYPE Setup(const WaveData &, u32); + UNKTYPE SetPriority(int); + UNKTYPE Stop(); + UNKTYPE Free(); + UNKTYPE SetPanMode(PanMode); + UNKTYPE SetPanCurve(PanCurve); + UNKTYPE SetVolume(float); + UNKTYPE SetVeVolume(float, float); + UNKTYPE SetPitch(float); + UNKTYPE SetPan(float); + UNKTYPE SetSurroundPan(float); + UNKTYPE SetLpfFreq(float); + UNKTYPE SetRemoteFilter(int); + UNKTYPE SetOutputLine(int); + UNKTYPE SetMainOutVolume(float); + UNKTYPE SetMainSend(float); + + UNKTYPE SetFxSend(AuxBus, float); + + UNKTYPE SetRemoteOutVolume(int, float); + UNKTYPE SetRemoteSend(int, float); + UNKTYPE SetRemoteFxSend(int, float); + + UNKTYPE Pause(bool); +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_VoiceManager.h b/include/nw4r/snd/snd_VoiceManager.h index 1706d975..36affe50 100644 --- a/include/nw4r/snd/snd_VoiceManager.h +++ b/include/nw4r/snd/snd_VoiceManager.h @@ -1,25 +1,21 @@ #ifndef NW4R_SND_VOICE_MANAGER_H #define NW4R_SND_VOICE_MANAGER_H -#include "types_nw4r.h" +#include "common.h" #include "snd_Voice.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct VoiceManager - { - static VoiceManager& GetInstance(); +namespace nw4r { +namespace snd { +namespace detail { +struct VoiceManager { + static VoiceManager &GetInstance(); - Voice * AllocVoice(int, int, int, Voice::VoiceCallback, void *); - void UpdateAllVoices(); - void NotifyVoiceUpdate(); - UNKTYPE UpdateAllVoicesSync(u32); - }; - } - } -} + Voice *AllocVoice(int, int, int, Voice::VoiceCallback, void *); + void UpdateAllVoices(); + void NotifyVoiceUpdate(); + UNKTYPE UpdateAllVoicesSync(u32); +}; +} // namespace detail +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/nw4r/snd/snd_WaveFile.h b/include/nw4r/snd/snd_WaveFile.h index 0bd32763..0ec8ceda 100644 --- a/include/nw4r/snd/snd_WaveFile.h +++ b/include/nw4r/snd/snd_WaveFile.h @@ -1,39 +1,30 @@ #ifndef NW4R_SND_WAVE_FILE_H #define NW4R_SND_WAVE_FILE_H -#include "types_nw4r.h" -#include "ut_binaryFileFormat.h" +#include "common.h" #include "snd_Util.h" +#include "ut_binaryFileFormat.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct WaveData - { - char UNK_0x0[0x2]; - u8 BYTE_0x2; - char UNK_0x4[0x90]; - }; - - struct WaveFile - { - struct WaveInfo - { - - }; - - typedef Util::DataRef Region; - }; - - struct WaveFileReader - { - WaveFileReader(const WaveFile::WaveInfo *); - bool ReadWaveParam(WaveData *, const void *) const; - }; - } - } -} +namespace nw4r { +namespace snd { +namespace detail { +struct WaveData { + char UNK_0x0[0x2]; + u8 BYTE_0x2; + char UNK_0x4[0x90]; +}; -#endif \ No newline at end of file +struct WaveFile { + struct WaveInfo {}; + + typedef Util::DataRef Region; +}; + +struct WaveFileReader { + WaveFileReader(const WaveFile::WaveInfo *); + bool ReadWaveParam(WaveData *, const void *) const; +}; +} // namespace detail +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_WaveSound.h b/include/nw4r/snd/snd_WaveSound.h index aa538ef8..2d588bea 100644 --- a/include/nw4r/snd/snd_WaveSound.h +++ b/include/nw4r/snd/snd_WaveSound.h @@ -1,8 +1,8 @@ #ifndef NW4R_SND_WAVESOUND_H #define NW4R_SND_WAVESOUND_H +#include "common.h" #include "snd_BasicSound.h" #include "snd_WsdPlayer.h" -#include "types_nw4r.h" #include "ut_RuntimeTypeInfo.h" diff --git a/include/nw4r/snd/snd_WaveSoundHandle.h b/include/nw4r/snd/snd_WaveSoundHandle.h index e9a150db..d6d178c8 100644 --- a/include/nw4r/snd/snd_WaveSoundHandle.h +++ b/include/nw4r/snd/snd_WaveSoundHandle.h @@ -1,24 +1,20 @@ #ifndef NW4R_SND_WAVESOUNDHANDLE_H #define NW4R_SND_WAVESOUNDHANDLE_H -#include "types_nw4r.h" +#include "common.h" -namespace nw4r -{ - namespace snd - { - struct WaveSoundHandle - { - detail::WaveSound *mWaveSound; // at 0x0 +namespace nw4r { +namespace snd { +struct WaveSoundHandle { + detail::WaveSound *mWaveSound; // at 0x0 - inline WaveSoundHandle() : mWaveSound(NULL) {} - inline bool IsAttachedSound() - { - return mWaveSound != NULL; - } - - void DetachSound(); - }; + inline WaveSoundHandle() : mWaveSound(NULL) {} + inline bool IsAttachedSound() { + return mWaveSound != NULL; } -} -#endif \ No newline at end of file + void DetachSound(); +}; +} // namespace snd +} // namespace nw4r + +#endif diff --git a/include/nw4r/snd/snd_WsdPlayer.h b/include/nw4r/snd/snd_WsdPlayer.h index 80a2a0b5..67d94663 100644 --- a/include/nw4r/snd/snd_WsdPlayer.h +++ b/include/nw4r/snd/snd_WsdPlayer.h @@ -1,53 +1,47 @@ #ifndef NW4R_SND_WSDPLAYER_H #define NW4R_SND_WSDPLAYER_H -#include "types_nw4r.h" +#include "common.h" #include "snd_BasicPlayer.h" #include "snd_DisposeCallback.h" -#include "snd_SoundThread.h" #include "snd_Lfo.h" +#include "snd_SoundThread.h" -namespace nw4r -{ - namespace snd - { - namespace detail - { - struct WsdPlayer : BasicPlayer, DisposeCallback, SoundThread::PlayerCallback - { - enum StartOffsetType - { +namespace nw4r { +namespace snd { +namespace detail { +struct WsdPlayer : BasicPlayer, DisposeCallback, SoundThread::PlayerCallback { + enum StartOffsetType { - }; + }; - virtual ~WsdPlayer() {} // at 0x8 - virtual bool Start(); // at 0xc - virtual void Stop(); // at 0x10 - virtual void Pause(bool); // at 0x14 - virtual bool IsActive() const; // at 0x18 - virtual bool IsStarted() const; // at 0x1c - virtual bool IsPause() const; // at 0x20 + virtual ~WsdPlayer() {} // at 0x8 + virtual bool Start(); // at 0xc + virtual void Stop(); // at 0x10 + virtual void Pause(bool); // at 0x14 + virtual bool IsActive() const; // at 0x18 + virtual bool IsStarted() const; // at 0x1c + virtual bool IsPause() const; // at 0x20 - virtual void OnUpdateFrameSoundThread(); // at 0xc - virtual void OnUpdateVoiceSoundThread(); // at 0x10 - virtual void OnShutdownSoundThread(); // at 0x14 + virtual void OnUpdateFrameSoundThread(); // at 0xc + virtual void OnUpdateVoiceSoundThread(); // at 0x10 + virtual void OnShutdownSoundThread(); // at 0x14 - virtual void InvalidateData(const void *, const void *); // at 0xc - virtual void InvalidateWaveData(const void *, const void *); // at 0x10 + virtual void InvalidateData(const void *, const void *); // at 0xc + virtual void InvalidateWaveData(const void *, const void *); // at 0x10 - struct WsdCallback - { - virtual ~WsdCallback(); - }; + struct WsdCallback { + virtual ~WsdCallback(); + }; - WsdPlayer(); - bool Prepare(const void *, int, WsdPlayer::StartOffsetType, int, int, const WsdPlayer::WsdCallback *, u32); - void SetChannelPriority(int); - void SetReleasePriorityFix(bool); + WsdPlayer(); + bool Prepare(const void *, int, WsdPlayer::StartOffsetType, int, int, const WsdPlayer::WsdCallback *, u32); + void SetChannelPriority(int); + void SetReleasePriorityFix(bool); - char UNK_0xE4[0x4C]; - }; - } - } -} + char UNK_0xE4[0x4C]; +}; +} // namespace detail +} // namespace snd +} // namespace nw4r -#endif \ No newline at end of file +#endif diff --git a/include/rvl/ARC/arc.h b/include/rvl/ARC/arc.h index 33096322..3e012138 100644 --- a/include/rvl/ARC/arc.h +++ b/include/rvl/ARC/arc.h @@ -59,6 +59,13 @@ typedef struct ARCHandle { s32 entrynum; // at 0x18 } ARCHandle; +typedef struct ARCDir { + ARCHeader *handle; // at 0x0 + u32 entryNum; // at 0x4 + u32 location; // at 0x8 + u32 next; // at 0xC +} ARCDir; + typedef struct ARCFileInfo { ARCHandle *handle; // at 0x0 u32 offset; // at 0x4 diff --git a/include/rvl/GX/GXInternal.h b/include/rvl/GX/GXInternal.h index 40b05fb2..89507bfd 100644 --- a/include/rvl/GX/GXInternal.h +++ b/include/rvl/GX/GXInternal.h @@ -56,9 +56,13 @@ typedef struct _GXLightObjImpl { } GXLightObjImpl; typedef struct _GXTexObjImpl { - u8 todo; + u8 todo[0x20]; } GXTexObjImpl; +typedef struct _GXTlutObjImpl { + u8 todo[0xC]; +} GXTlutObjImpl; + #ifdef __cplusplus } #endif diff --git a/include/rvl/GX/GXTexture.h b/include/rvl/GX/GXTexture.h index 06e33a3b..8f826a2c 100644 --- a/include/rvl/GX/GXTexture.h +++ b/include/rvl/GX/GXTexture.h @@ -7,6 +7,7 @@ extern "C" { #endif GX_DECL_PUBLIC_STRUCT(GXTexObj, 32); +GX_DECL_PUBLIC_STRUCT(GXTlutObj, 12); void __GXSetSUTexRegs(void); diff --git a/src/nw4r/lyt/lyt_animation.cpp b/src/nw4r/lyt/lyt_animation.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_arcResourceAccessor.cpp b/src/nw4r/lyt/lyt_arcResourceAccessor.cpp new file mode 100644 index 00000000..5aab3607 --- /dev/null +++ b/src/nw4r/lyt/lyt_arcResourceAccessor.cpp @@ -0,0 +1,197 @@ +#include "nw4r/lyt/lyt_arcResourceAccessor.h" +#include "nw4r/ut/ut_Font.h" + +namespace { + +// FindNameResource__37@unnamed@lyt_arcResourceAccessor_cpp@FP9ARCHandlePCc +s32 FindResourcename(ARCHandle *pArcHandle, const char *resName) { + return 1; +} + +// GetResourceSub__37@unnamed@lyt_arcResourceAccessor_cpp@FP9ARCHandlePCcUlPCcPUl +void *GetResourceSub(ARCHandle *pArcHandle, const char *resRootDir, u32 resType, const char *name, u32 *pSize) {} + +} // namespace + +namespace nw4r { +namespace lyt { +// __ct__Q34nw4r3lyt11FontRefLinkFv +FontRefLink::FontRefLink() {} + +// Set__Q34nw4r3lyt11FontRefLinkFPCcPQ34nw4r2ut4Font +void FontRefLink::Set(const char *name, ut::Font *pFont) {} + +// __ct__Q34nw4r3lyt19ArcResourceAccessorFv +ArcResourceAccessor::ArcResourceAccessor() {} + +// Attach__Q34nw4r3lyt19ArcResourceAccessorFPvPCc +bool ArcResourceAccessor::Attach(void *archiveStart, const char *resourceRootDirectory) { + return false; +} + +// Detach__Q34nw4r3lyt19ArcResourceAccessorFv + +// GetResource__Q34nw4r3lyt19ArcResourceAccessorFUlPCcPUl + +// RegistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink + +// UnregistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink + +// GetFont__Q34nw4r3lyt19ArcResourceAccessorFPCc + +// __dt__Q34nw4r3lyt24MultiArcResourceAccessorFv + +} // namespace lyt +} // namespace nw4r + +// 29c03b: <88> TAG_global_subroutine +// AT_sibling(0x29c0dc) +// AT_name("Detach") +// AT_lo_user("Detach__Q34nw4r3lyt19ArcResourceAccessorFv") +// AT_member(0x16271) +// AT_fund_type(FT_pointer) +// AT_low_pc(0x802d50c8) +// AT_high_pc(0x802d5158) + +// 29c093: <38> TAG_formal_parameter +// AT_sibling(0x29c0b9) +// AT_name("this") +// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) +// AT_location(<5>OP_REG(0x1f) ) + +// 29c0dc: <105> TAG_global_subroutine +// AT_sibling(0x29c1ec) +// AT_name("GetResource") +// AT_lo_user("GetResource__Q34nw4r3lyt19ArcResourceAccessorFUlPCcPUl") +// AT_member(0x16271) +// AT_fund_type(FT_pointer) +// AT_low_pc(0x802d5158) +// AT_high_pc(0x802d51a4) + +// 29c145: <38> TAG_formal_parameter +// AT_sibling(0x29c16b) +// AT_name("this") +// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) +// AT_location(<5>OP_REG(0x1f) ) + +// 29c16b: <41> TAG_formal_parameter +// AT_sibling(0x29c194) +// AT_name("resType") +// AT_fund_type(FT_unsigned_long) +// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x8) OP_ADD ) + +// 29c194: <42> TAG_formal_parameter +// AT_sibling(0x29c1be) +// AT_name("name") +// AT_mod_fund_type(<4>MOD_pointer_to MOD_const FT_char) +// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0xc) OP_ADD ) + +// 29c1be: <42> TAG_formal_parameter +// AT_sibling(0x29c1e8) +// AT_name("pSize") +// AT_mod_fund_type(<3>MOD_pointer_to FT_unsigned_long) +// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x10) OP_ADD ) +// 29c1e8: <4> + +// 29c1ec: <116> TAG_global_subroutine +// AT_sibling(0x29c2b6) +// AT_name("RegistFont") +// AT_lo_user("RegistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink") +// AT_member(0x16271) +// AT_low_pc(0x802d51a4) +// AT_high_pc(0x802d5228) + +// 29c260: <44> TAG_formal_parameter +// AT_sibling(0x29c28c) +// AT_name("this") +// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) +// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x8) OP_ADD ) + +// 29c28c: <38> TAG_formal_parameter +// AT_sibling(0x29c2b2) +// AT_name("pLink") +// AT_mod_u_d_type(<5>MOD_pointer_to 0x1613f) +// AT_location(<5>OP_REG(0x1d) ) +// 29c2b2: <4> + +// 29c2b6: <120> TAG_global_subroutine +// AT_sibling(0x29c384) +// AT_name("UnregistFont") +// AT_lo_user("UnregistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink") +// AT_member(0x16271) +// AT_low_pc(0x802d5228) +// AT_high_pc(0x802d52ac) + +// 29c32e: <44> TAG_formal_parameter +// AT_sibling(0x29c35a) +// AT_name("this") +// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) +// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x8) OP_ADD ) + +// 29c35a: <38> TAG_formal_parameter +// AT_sibling(0x29c380) +// AT_name("pLink") +// AT_mod_u_d_type(<5>MOD_pointer_to 0x1613f) +// AT_location(<5>OP_REG(0x1d) ) +// 29c380: <4> + +// 29c384: <97> TAG_global_subroutine +// AT_sibling(0x29c43f) +// AT_name("GetFont") +// AT_lo_user("GetFont__Q34nw4r3lyt19ArcResourceAccessorFPCc") +// AT_member(0x16271) +// AT_mod_u_d_type(<5>MOD_pointer_to 0x15c72) +// AT_low_pc(0x802d52ac) +// AT_high_pc(0x802d52e0) + +// 29c3e5: <44> TAG_formal_parameter +// AT_sibling(0x29c411) +// AT_name("this") +// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) +// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x8) OP_ADD ) + +// 29c411: <42> TAG_formal_parameter +// AT_sibling(0x29c43b) +// AT_name("name") +// AT_mod_fund_type(<4>MOD_pointer_to MOD_const FT_char) +// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0xc) OP_ADD ) +// 29c43b: <4> + +// 29c43f: <95> TAG_global_subroutine +// AT_sibling(0x29c4c8) +// AT_name("__dt") +// AT_lo_user("__dt__Q34nw4r3lyt24MultiArcResourceAccessorFv") +// AT_member(0x63219) +// AT_fund_type(FT_pointer) +// AT_low_pc(0x802d533c) +// AT_high_pc(0x802d53cc) +// (0x29c83e) + +// 29c49e: <38> TAG_formal_parameter +// AT_sibling(0x29c4c4) +// AT_name("this") +// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x63219) +// AT_location(<5>OP_REG(0x1f) ) +// 29c4c4: <4> + +// AT_name("DetachAll") +// AT_lo_user("DetachAll__Q34nw4r3lyt24MultiArcResourceAccessorFv") + +// AT_name("GetResource") +// AT_lo_user("GetResource__Q34nw4r3lyt24MultiArcResourceAccessorFUlPCcPUl") +// AT_fund_type(FT_pointer) +// AT_name("this") +// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x63219) +// AT_name("resType") +// AT_fund_type(FT_unsigned_long) +// AT_name("name") +// AT_mod_fund_type(<4>MOD_pointer_to MOD_const FT_char) +// AT_name("pSize") +// AT_mod_fund_type(<3>MOD_pointer_to FT_unsigned_long) + +// AT_lo_user("GetFont__Q34nw4r3lyt24MultiArcResourceAccessorFPCc") +// AT_name("name") +// AT_mod_fund_type(<4>MOD_pointer_to MOD_const FT_char) + +// "__vt__Q34nw4r3lyt24MultiArcResourceAccessor" +// "__vt__Q34nw4r3lyt19ArcResourceAccessor" diff --git a/src/nw4r/lyt/lyt_bounding.cpp b/src/nw4r/lyt/lyt_bounding.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_common.cpp b/src/nw4r/lyt/lyt_common.cpp new file mode 100644 index 00000000..c5cda80e --- /dev/null +++ b/src/nw4r/lyt/lyt_common.cpp @@ -0,0 +1,189 @@ +#include "nw4r/lyt/lyt_common.h" +#include "nw4r/lyt/lyt_layout.h" +#include "nw4r/lyt/lyt_pane.h" +#include "nw4r/ut/ut_Color.h" +#include "nw4r/ut/ut_algorithm.h" + +namespace nw4r { +namespace lyt { +using namespace math; +using namespace ut; + +// EqualsResName__Q34nw4r3lyt6detailFPCcPCc +bool detail::EqualsResName(const char *name1, const char *name2) { + return strncmp(name1, name2, NW4R_RES_NAME_SIZE) == 0; + ; +} + +// EqualsMaterialName__Q34nw4r3lyt6detailFPCcPCc +bool detail::EqualsMaterialName(const char *name1, const char *name2) { + return strncmp(name1, name2, NW4R_MAT_NAME_SIZE) == 0; +} + +// TestFileHeader__Q34nw4r3lyt6detailFRCQ44nw4r3lyt3res16BinaryFileHeaderUl +bool detail::TestFileHeader(const res::BinaryFileHeader &fileHeader, u32 testSig) { + return ((testSig == fileHeader.magic) && (fileHeader.byteOrder == NW4R_BYTEORDER_BIG)); +} + +namespace detail { +// __ct__Q44nw4r3lyt6detail11TexCoordAryFv +TexCoordAry::TexCoordAry() : mpData(nullptr), mCap(0), mNum(0) {} + +// Free__Q44nw4r3lyt6detail11TexCoordAryFv +void TexCoordAry::Free() { + if (this->mpData) { + Layout::DeleteArray(*this->mpData, this->mNum * TEXCOORD_VTX_COUNT); + this->mpData = nullptr; + this->mCap = 0; + this->mNum = 0; + } +} + +// Reserve__Q44nw4r3lyt6detail11TexCoordAryFUc +void TexCoordAry::Reserve(u8 num) { + if (mCap < num) { + Free(); + const TexCoordData *pData = (TexCoordData *)Layout::NewArray(num * TEXCOORD_VTX_COUNT); + this->mpData = pData ? const_cast(pData) : nullptr; + if (mpData != NULL) { + mCap = num; + } + } +} + +// SetSize__Q44nw4r3lyt6detail11TexCoordAryFUc +void TexCoordAry::SetSize(u8 num) { + if (this->mpData != nullptr && num <= this->mCap) { + static TexCoordData texCoords = {VEC2(0.0f, 0.0f), VEC2(1.0f, 0.0f), VEC2(0.0f, 1.0f), VEC2(1.0f, 1.0f)}; + + for (int i = mNum; i < num; i++) { + for (int j = 0; j < TEXCOORD_VTX_COUNT; j++) { + this->mpData[i][j] = texCoords[j]; + } + } + this->mNum = num; + } +} + +// Copy__Q44nw4r3lyt6detail11TexCoordAryFPCvUc +void TexCoordAry::Copy(const void *pResTexCoord, u8 texCoordNum) { + mNum = Max(mNum, texCoordNum); + + const TexCoordData *src = static_cast(pResTexCoord); + for (int i = 0; i < texCoordNum; i++) { + for (int j = 0; j < TEXCOORD_VTX_COUNT; j++) { + mpData[i][j] = src[i][j]; + } + } +} + +} // namespace detail + +// IsModulateVertexColor__Q34nw4r3lyt6detailFPQ34nw4r2ut5ColorUc +bool detail::IsModulateVertexColor(ut::Color *vtxColors, u8 glbAlpha) { + if (glbAlpha != 0xFF) { + return true; + } + + if ((vtxColors != NULL) && + ((vtxColors[0] != 0xFFFFFFFF) || (vtxColors[1] != 0xFFFFFFFF) || (vtxColors[2] != 0xFFFFFFFF) || + (vtxColors[3] != 0xFFFFFFFF))) { + return true; + } else { + return false; + } +} + +// MultipleAlpha__Q34nw4r3lyt6detailFQ34nw4r2ut5ColorUc +ut::Color detail::MultipleAlpha(ut::Color col, u8 alpha) { + ut::Color ret = col; + if (alpha != 0xFF) { + ret.a = (col.a * alpha) / 0xFF; + } + return ret; +} + +// MultipleAlpha__Q34nw4r3lyt6detailFPQ34nw4r2ut5ColorPCQ34nw4r2ut5ColorUc +void detail::MultipleAlpha(ut::Color *dst, const ut::Color *src, u8 alpha) { + for (int i = 0; i < TEXCOORD_VTX_COUNT; i++) { + dst[i] = MultipleAlpha(src[i], alpha); + } +} + +// SetVertexFormat__Q34nw4r3lyt6detailFbUc +void detail::SetVertexFormat(bool bModulate, u8 textCoordNum) { + GXClearVtxDesc(); + + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + if (bModulate) { + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + } + + for (int i = 0; i < textCoordNum; i++) { + GXSetVtxDesc((GXAttr)(GX_VA_TEX0 + i), GX_DIRECT); + } + + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0); + if (bModulate) { + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + } + + for (int i = 0; i < textCoordNum; i++) { + GXSetVtxAttrFmt(GX_VTXFMT0, (GXAttr)(GX_VA_TEX0 + i), GX_TEX_ST, GX_F32, 0); + } +} + +// DrawQuad__Q34nw4r3lyt6detailFRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeUcPA4_CQ34nw4r4math4VEC2PCQ34nw4r2ut5Color +void detail::DrawQuad(const math::VEC2 &basePt, const Size &size, u8 texCoordNum, const TexCoordData *texCoords, + const ut::Color *vtxColors) { + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + + GXPosition2f32(basePt.x, basePt.y); + if (vtxColors != NULL) { + GXColor1u32(vtxColors[0]); + } + for (int i = 0; i < texCoordNum; i++) { + GXTexCoord2f32(texCoords[i][0].x, texCoords[i][0].y); + } + + GXPosition2f32(basePt.x + size.x, basePt.y); + if (vtxColors != NULL) { + GXColor1u32(vtxColors[1]); + } + for (int i = 0; i < texCoordNum; i++) { + GXTexCoord2f32(texCoords[i][1].x, texCoords[i][1].y); + } + + GXPosition2f32(basePt.x + size.x, basePt.y - size.y); + if (vtxColors != NULL) { + GXColor1u32(vtxColors[3]); + } + for (int i = 0; i < texCoordNum; i++) { + GXTexCoord2f32(texCoords[i][3].x, texCoords[i][3].y); + } + + GXPosition2f32(basePt.x, basePt.y - size.y); + if (vtxColors != NULL) { + GXColor1u32(vtxColors[2]); + } + for (int i = 0; i < texCoordNum; i++) { + GXTexCoord2f32(texCoords[i][2].x, texCoords[i][2].y); + } +} + +// DrawQuad__Q34nw4r3lyt6detailFRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeUcPA4_CQ34nw4r4math4VEC2PCQ34nw4r2ut5ColorUc +void detail::DrawQuad(const math::VEC2 &basePt, const Size &size, u8 texCoordNum, const TexCoordData *texCoords, + const ut::Color *vtxColors, u8 alpha) { + ut::Color wkVtxColors[4]; + if (vtxColors) { + MultipleAlpha(wkVtxColors, vtxColors, alpha); + } + DrawQuad(basePt, size, texCoordNum, texCoords, vtxColors ? wkVtxColors : nullptr); +} + +// DrawLine__Q34nw4r3lyt6detailFRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeQ34nw4r2ut5Color +void detail::DrawLine(const math::VEC2 &pos, const Size &size, ut::Color color) { + // Not Impl in SS +} +} // namespace lyt +} // namespace nw4r diff --git a/src/nw4r/lyt/lyt_drawInfo.cpp b/src/nw4r/lyt/lyt_drawInfo.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_group.cpp b/src/nw4r/lyt/lyt_group.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_init.cpp b/src/nw4r/lyt/lyt_init.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_layout.cpp b/src/nw4r/lyt/lyt_layout.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_material.cpp b/src/nw4r/lyt/lyt_material.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_pane.cpp b/src/nw4r/lyt/lyt_pane.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_picture.cpp b/src/nw4r/lyt/lyt_picture.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_resourceAccessor.cpp b/src/nw4r/lyt/lyt_resourceAccessor.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_texMap.cpp b/src/nw4r/lyt/lyt_texMap.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_textBox.cpp b/src/nw4r/lyt/lyt_textBox.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/nw4r/lyt/lyt_util.cpp b/src/nw4r/lyt/lyt_util.cpp new file mode 100644 index 00000000..972ab47e --- /dev/null +++ b/src/nw4r/lyt/lyt_util.cpp @@ -0,0 +1,33 @@ + +#include +#include +#include +#include + +namespace nw4r { +namespace lyt { + +namespace { +// Contains__Q34nw4r3lyt22@unnamed@lyt_util_cpp@FRCQ34nw4r2ut4RectRCQ34nw4r4math4VEC2 +bool Contains(const ut::Rect &rect, const math::VEC2 &point) {} +} // namespace + +// BindAnimation__Q24nw4r3lytFPQ34nw4r3lyt5GroupPQ34nw4r3lyt13AnimTransformbb +void BindAnimation(Group *pGroup, AnimTransform *pAnimTrans, bool bRecursive, bool bDisable) {} + +// SetAnimationEnable__Q24nw4r3lytFPQ34nw4r3lyt5GroupPQ34nw4r3lyt13AnimTransformbb +void SetAnimationEnable(Group *pGroup, nw4r::lyt::AnimTransform *pAnimTrans, bool bEnable, bool bRecursive) {} + +// IsContain__Q24nw4r3lytFPQ34nw4r3lyt4PaneRCQ34nw4r4math4VEC2 +bool IsContain(Pane *pPane, const math::VEC2 &pos) { + return false; +} + +// FindHitPane__Q24nw4r3lytFPQ34nw4r3lyt4PaneRCQ34nw4r4math4VEC2 +Pane *FindHitPane(Pane *pPane, const math::VEC2 &pos) { + return nullptr; +} + +} // namespace lyt + +} // namespace nw4r diff --git a/src/nw4r/lyt/lyt_window.cpp b/src/nw4r/lyt/lyt_window.cpp new file mode 100644 index 00000000..e69de29b