diff options
author | Treeki <treeki@gmail.com> | 2011-09-17 00:55:14 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-09-17 00:55:14 +0200 |
commit | 7a01ebfe271008804af099444b61498246594351 (patch) | |
tree | 86b04fe121e7ccb7a95d3eaa5f2a1adf42fb6e61 | |
parent | 3f51fed7227c3a409efd3fb8a38a63b709d9cca3 (diff) | |
download | kamek-7a01ebfe271008804af099444b61498246594351.tar.gz kamek-7a01ebfe271008804af099444b61498246594351.zip |
Mr Sun converted to C++. untested but compiles
Diffstat (limited to '')
-rw-r--r-- | NewerProject.yaml | 2 | ||||
-rw-r--r-- | include/g3dhax.h | 268 | ||||
-rwxr-xr-x | include/game.h | 23 | ||||
-rw-r--r-- | kamek_ntsc.x | 6 | ||||
-rw-r--r-- | kamek_ntsc2.x | 6 | ||||
-rw-r--r-- | kamek_pal.x | 6 | ||||
-rw-r--r-- | kamek_pal2.x | 6 | ||||
-rw-r--r-- | mrsun.yaml | 21 | ||||
-rwxr-xr-x | src/mrsun.cpp | 27 |
9 files changed, 231 insertions, 134 deletions
diff --git a/NewerProject.yaml b/NewerProject.yaml index 8a27c54..af9ab90 100644 --- a/NewerProject.yaml +++ b/NewerProject.yaml @@ -6,6 +6,7 @@ modules: - processed/worldmap.yaml - processed/levelnames.yaml - processed/animtiles.yaml + - processed/levelspecial.yaml - processed/mrsun.yaml - processed/spritetex.yaml # - processed/gakenoko.yaml @@ -20,7 +21,6 @@ modules: # - processed/msgbox.yaml # - processed/replay.yaml - processed/growup.yaml - #- processed/levelspecial.yaml - processed/eventlooper.yaml - processed/spritespawner.yaml - processed/spriteswapper.yaml diff --git a/include/g3dhax.h b/include/g3dhax.h index c3aeaef..ac5ba80 100644 --- a/include/g3dhax.h +++ b/include/g3dhax.h @@ -1,159 +1,209 @@ +#ifndef __KAMEK_G3DHAX_H +#define __KAMEK_G3DHAX_H + // nw4r::g3d wrapper namespace nw4r { -namespace g3d { + namespace g3d { -class ResName { -public: - const char *name; + class ResName { + public: + const char *name; + + ResName(const char *p = NULL) { + name = p; + } + }; - ResName(const char *p = NULL) { - name = p; - } -}; + class ResMdl { + public: + void * /*ResMdlData*/ data; -class ResFile { -public: - void * /*ResFileData*/ data; + ResMdl(void *p = NULL) { + data = p; + } - ResFile(void *p = NULL) { - data = p; - } + void * /*ResMat*/ GetResMat(const char *str) const; + }; - void Init(); - bool CheckRevision() const; - - void * /*ResMdl*/ GetResMdl(const char *str) const; - void * /*ResPltt*/ GetResPltt(const ResName n) const; - void * /*ResTex*/ GetResTex(const char *str) const; - void * /*ResTex*/ GetResTex(const ResName n) const; - void * /*ResTex*/ GetResTex(u32 idx) const; - void * /*ResAnmChr*/ GetResAnmChr(const char *str) const; - void * /*ResAnmVis*/ GetResAnmVis(const char *str) const; - void * /*ResAnmClr*/ GetResAnmClr(const char *str) const; - void * /*ResAnmTexPat*/ GetResAnmTexPat(const char *str) const; - void * /*ResAnmTexSrt*/ GetResAnmTexSrt(const char *str) const; - void * /*ResAnmScn*/ GetResAnmScn(const char *str) const; - - bool Bind(ResFile rhs); -}; + class ResFile { + public: + void * /*ResFileData*/ data; -void *__ScnMdlSimple__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResMdl*/ mdl, - int nView = 1); + ResFile(void *p = NULL) { + data = p; + } + void Init(); + bool CheckRevision() const; -void *__ScnMdl__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResMdl*/ mdl, - u32 bufferOption, - int nView = 1); + ResMdl GetResMdl(const char *str) const; + void * /*ResPltt*/ GetResPltt(const ResName n) const; + void * /*ResTex*/ GetResTex(const char *str) const; + void * /*ResTex*/ GetResTex(const ResName n) const; + void * /*ResTex*/ GetResTex(u32 idx) const; + void * /*ResAnmChr*/ GetResAnmChr(const char *str) const; + void * /*ResAnmVis*/ GetResAnmVis(const char *str) const; + void * /*ResAnmClr*/ GetResAnmClr(const char *str) const; + void * /*ResAnmTexPat*/ GetResAnmTexPat(const char *str) const; + void * /*ResAnmTexSrt*/ GetResAnmTexSrt(const char *str) const; + void * /*ResAnmScn*/ GetResAnmScn(const char *str) const; + bool Bind(ResFile rhs); + }; -void *__AnmObjChrRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmChr*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__ScnMdlSimple__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResMdl*/ mdl, + int nView = 1); -void *__AnmObjVisRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmVis*/ resAnm, - void * /*ResMdl*/ resMdl); + void *__ScnMdl__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResMdl*/ mdl, + u32 bufferOption, + int nView = 1); -void *__AnmObjTexPatRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmTexPat*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__AnmObjChrRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmChr*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); -void *__AnmObjTexSrtRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmTexSrt*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__AnmObjVisRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmVis*/ resAnm, + void * /*ResMdl*/ resMdl); -void *__AnmObjMatClrRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmMatClr*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__AnmObjTexPatRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmTexPat*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); -void *__AnmObjShpRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmShp*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__AnmObjTexSrtRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmTexSrt*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); + void *__AnmObjMatClrRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmMatClr*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); -bool InsertIntoScene(void *scnObj); // 80164F90 -extern void *g3dMemAllocator; // 8042A6A8 + void *__AnmObjShpRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmShp*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); -inline void *ConstructScnMdlSimple(void *mdl, int nView = 1) { - return __ScnMdlSimple__Construct(g3dMemAllocator, 0, mdl, nView); -} -inline void *ConstructScnMdl(void *mdl, u32 bufferOption, int nView = 1) { - return __ScnMdl__Construct(g3dMemAllocator, 0, mdl, bufferOption, nView); -} + bool InsertIntoScene(void *scnObj); // 80164F90 + extern void *g3dMemAllocator; // 8042A6A8 -} + inline void *ConstructScnMdlSimple(void *mdl, int nView = 1) { + return __ScnMdlSimple__Construct(g3dMemAllocator, 0, mdl, nView); + } + + inline void *ConstructScnMdl(void *mdl, u32 bufferOption, int nView = 1) { + return __ScnMdl__Construct(g3dMemAllocator, 0, mdl, bufferOption, nView); + } + + + + } } class mHeapAllocator_c { // Actually that weird subclass. INCOMPLETE!! -public: - char data1[0x10]; + public: + char data1[0x10]; - mHeapAllocator_c(); - virtual ~mHeapAllocator_c(); - virtual void *alloc(u32 size); - virtual void free(void *block); + mHeapAllocator_c(); + virtual ~mHeapAllocator_c(); + virtual void *alloc(u32 size); + virtual void free(void *block); - bool link(s32 size, void *heap, const char *name, int align); - u32 unlink(); + bool link(s32 size, void *heap, const char *name, int align); + u32 unlink(); - char data2[8]; + char data2[8]; }; namespace m3d { + // random, just dumped it here because I dunno where else + void DisableIndirectTexturing(); + void InitTexObjWithResTex(GXTexObj *obj, /* ResTex */ void *resTex, GXTexWrapMode wrapS, GXTexWrapMode wrapT, GXTexFilter minFilt, GXTexFilter magFilt); + + // I need to do scnLeaf_c some time... + + class proc_c { + public: + proc_c(); + virtual ~proc_c(); + + void setup(void *allocator = 0, u32 *size = 0); + virtual int returnUnknown(); + virtual void free(); + virtual bool scheduleForDrawing(); + virtual void drawOpa(); + virtual void drawXlu(); + + void setScnObjOption(ulong, ulong); + bool getScnObjOption(ulong, ulong*); + + void setScale(float x, float y, float z); + void setScale(Vec vec); + + void setDrawMatrix(Mtx *mtx); + void getLocalMatrix(Mtx *mtx); + void getViewMatrix(Mtx *mtx); + + void calcWorld(bool); + void calcView(bool); + + void setDrawPriorities(int opa, int xlu); + + void *scnObj; + }; + class mdl_c { - public: - mdl_c(); - virtual ~mdl_c(); + public: + mdl_c(); + virtual ~mdl_c(); - virtual void _vf0C(); - virtual void _vf10(); - virtual bool scheduleForDrawing(); - virtual void bindAnim(void *anim, float boo); - virtual void _vf1C(); + virtual void _vf0C(); + virtual void _vf10(); + virtual bool scheduleForDrawing(); + virtual void bindAnim(void *anim, float boo); + virtual void _vf1C(); - bool setup(void *model, void *allocator, u32 bufferOption, int nView, u32 *size); - void oneSetupType(); - void sub_80064BF0(); + bool setup(nw4r::g3d::ResMdl model, void *allocator, u32 bufferOption, int nView, u32 *size); + void oneSetupType(); + void sub_80064BF0(); - void setDrawMatrix(const Mtx matrix); + void setDrawMatrix(const Mtx matrix); - char data[0x3C]; + char data[0x3C]; }; }; @@ -166,3 +216,5 @@ void SetupTextures_Enemy(m3d::mdl_c *model, int sceneID); // 800B4170 void SetupTextures_MapObj(m3d::mdl_c *model, int sceneID); // 800B42B0 void SetupTextures_Item(m3d::mdl_c *model, int sceneID); // 800B43D0 +#endif + diff --git a/include/game.h b/include/game.h index 38e8dd6..3476eaa 100755 --- a/include/game.h +++ b/include/game.h @@ -1366,6 +1366,29 @@ public: };
+class dAc_Py_c : public dStageActor_c {
+public:
+ u8 data[0x1164 - 0x394];
+ ActivePhysics bPhysics;
+ ActivePhysics cPhysics;
+ ActivePhysics dPhysics;
+ ActivePhysics ePhysics;
+
+ dAc_Py_c();
+
+ int beforeCreate();
+ int afterCreate(int);
+ int beforeDelete();
+ int afterDelete(int);
+ int beforeExecute();
+ int afterExecute(int);
+ int beforeDraw();
+ int afterDraw(int);
+
+ ~dAc_Py_c();
+};
+
+
/* TODO
class dActorState_c : public dStageActor_c {
public:
diff --git a/kamek_ntsc.x b/kamek_ntsc.x index dab4502..4a7a35d 100644 --- a/kamek_ntsc.x +++ b/kamek_ntsc.x @@ -176,6 +176,7 @@ SECTIONS { StateID_DownMove_DiffEnd__15daEnBlockMain_c = 0x80352B74; __ct__5dEn_cFv = 0x80094E80; + __dt__5dEn_cFv = 0x80095130; afterCreate__5dEn_cFi = 0x800951D0; afterExecute__5dEn_cFi = 0x80095480; kill__5dEn_cFv = 0x80097F70; @@ -185,6 +186,7 @@ SECTIONS { _vfCC__5dEn_cFP7Point2d = 0x800973F0; _vfD0__5dEn_cFP7Point2d = 0x800974F0; doStateChange__5dEn_cFP9StateBase = 0x800A7DF0; + collisionCallback__5dEn_cFPQ213ActivePhysics4InfoPQ213ActivePhysics4Info = 0x80095950; preSpriteCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095CE0; prePlayerCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095D30; preYoshiCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095F50; @@ -386,6 +388,10 @@ SECTIONS { instance__10dFlagMgr_c = 0x8042A078; + addToList__13ActivePhysicsFv = 0x8008C330; + initWithStruct__13ActivePhysicsFP8dActor_cPQ213ActivePhysics4Info = 0x8008C3E0; + + __ct__7PhysicsFv = 0x8007F7A0; setup__7PhysicsFP8dActor_cPQ27Physics4InfoUcUcP7Point2d = 0x8007FB10; addToList__7PhysicsFv = 0x8007F900; diff --git a/kamek_ntsc2.x b/kamek_ntsc2.x index 8307ebc..d59089a 100644 --- a/kamek_ntsc2.x +++ b/kamek_ntsc2.x @@ -176,6 +176,7 @@ SECTIONS { StateID_DownMove_DiffEnd__15daEnBlockMain_c = 0x80352B74; __ct__5dEn_cFv = 0x80094E80; + __dt__5dEn_cFv = 0x80095130; afterCreate__5dEn_cFi = 0x800951D0; afterExecute__5dEn_cFi = 0x80095480; kill__5dEn_cFv = 0x80097F70; @@ -185,6 +186,7 @@ SECTIONS { _vfCC__5dEn_cFP7Point2d = 0x800973F0; _vfD0__5dEn_cFP7Point2d = 0x800974F0; doStateChange__5dEn_cFP9StateBase = 0x800A7DF0; + collisionCallback__5dEn_cFPQ213ActivePhysics4InfoPQ213ActivePhysics4Info = 0x80095950; preSpriteCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095CE0; prePlayerCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095D30; preYoshiCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095F50; @@ -386,6 +388,10 @@ SECTIONS { instance__10dFlagMgr_c = 0x8042A078; + addToList__13ActivePhysicsFv = 0x8008C330; + initWithStruct__13ActivePhysicsFP8dActor_cPQ213ActivePhysics4Info = 0x8008C3E0; + + __ct__7PhysicsFv = 0x8007F7A0; setup__7PhysicsFP8dActor_cPQ27Physics4InfoUcUcP7Point2d = 0x8007FB10; addToList__7PhysicsFv = 0x8007F900; diff --git a/kamek_pal.x b/kamek_pal.x index 75b50b9..b910118 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -176,6 +176,7 @@ SECTIONS { StateID_DownMove_DiffEnd__15daEnBlockMain_c = 0x80352E74; __ct__5dEn_cFv = 0x80094E80; + __dt__5dEn_cFv = 0x80095130; afterCreate__5dEn_cFi = 0x800951D0; afterExecute__5dEn_cFi = 0x80095480; kill__5dEn_cFv = 0x80097F70; @@ -185,6 +186,7 @@ SECTIONS { _vfCC__5dEn_cFP7Point2d = 0x800973F0; _vfD0__5dEn_cFP7Point2d = 0x800974F0; doStateChange__5dEn_cFP9StateBase = 0x800A7DF0; + collisionCallback__5dEn_cFPQ213ActivePhysics4InfoPQ213ActivePhysics4Info = 0x80095950; preSpriteCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095CE0; prePlayerCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095D30; preYoshiCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095F50; @@ -386,6 +388,10 @@ SECTIONS { instance__10dFlagMgr_c = 0x8042A358; + addToList__13ActivePhysicsFv = 0x8008C330; + initWithStruct__13ActivePhysicsFP8dActor_cPQ213ActivePhysics4Info = 0x8008C3E0; + + __ct__7PhysicsFv = 0x8007F7A0; setup__7PhysicsFP8dActor_cPQ27Physics4InfoUcUcP7Point2d = 0x8007FB10; addToList__7PhysicsFv = 0x8007F900; diff --git a/kamek_pal2.x b/kamek_pal2.x index 8621496..87ce78f 100644 --- a/kamek_pal2.x +++ b/kamek_pal2.x @@ -176,6 +176,7 @@ SECTIONS { StateID_DownMove_DiffEnd__15daEnBlockMain_c = 0xDEADBEEF; __ct__5dEn_cFv = 0xDEADBEEF; + __dt__5dEn_cFv = 0xDEADBEEF; afterCreate__5dEn_cFi = 0xDEADBEEF; afterExecute__5dEn_cFi = 0xDEADBEEF; kill__5dEn_cFv = 0xDEADBEEF; @@ -185,6 +186,7 @@ SECTIONS { _vfCC__5dEn_cFP7Point2d = 0xDEADBEEF; _vfD0__5dEn_cFP7Point2d = 0xDEADBEEF; doStateChange__5dEn_cFP9StateBase = 0xDEADBEEF; + collisionCallback__5dEn_cFPQ213ActivePhysics4InfoPQ213ActivePhysics4Info = 0xDEADBEEF; preSpriteCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0xDEADBEEF; prePlayerCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0xDEADBEEF; preYoshiCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0xDEADBEEF; @@ -386,6 +388,10 @@ SECTIONS { instance__10dFlagMgr_c = 0xDEADBEEF; + addToList__13ActivePhysicsFv = 0xDEADBEEF; + initWithStruct__13ActivePhysicsFP8dActor_cPQ213ActivePhysics4Info = 0xDEADBEEF; + + __ct__7PhysicsFv = 0xDEADBEEF; setup__7PhysicsFP8dActor_cPQ27Physics4InfoUcUcP7Point2d = 0xDEADBEEF; addToList__7PhysicsFv = 0xDEADBEEF; @@ -3,23 +3,8 @@ source_files: [../src/mrsun.cpp] hooks: - - name: MrSun_Create + - name: BuildEventBlock type: add_func_pointer - src_addr_pal: 0x80B0DFB8 - target_func: 'MrSun_Create(MrSun *)' - - - name: MrSun_Execute - type: add_func_pointer - src_addr_pal: 0x80B0DFD0 - target_func: 'MrSun_Execute(MrSun *)' - - - name: MrSun_Draw - type: patch - addr_pal: 0x80B0DFDC - data: '809D0810' - - - name: MrSun_HeapDeallocated - type: patch - addr_pal: 0x80B0DFF8 - data: '809D1F70' + src_addr_pal: 0x80B0DFA0 + target_func: 'daMrSun_c::build(void)' diff --git a/src/mrsun.cpp b/src/mrsun.cpp index b246131..668a789 100755 --- a/src/mrsun.cpp +++ b/src/mrsun.cpp @@ -1,24 +1,36 @@ #include <common.h> -#include <g3dhax.h> #include <game.h> +#include <g3dhax.h> -class dMrSun_c : public dEn_c { +class daMrSun_c : public dEn_c { int onCreate(); int onDelete(); int onExecute(); int onDraw(); mHeapAllocator_c allocator; + m3d::mdl_c model; - static dMrSun_c *build(); + static daMrSun_c *build(); }; +daMrSun_c *daMrSun_c::build() { + void *buffer = AllocFromGameHeap1(sizeof(daMrSun_c)); + return new(buffer) daMrSun_c; +} + #define ACTIVATE 1 #define DEACTIVATE 0 -int dMrSun_c::onCreate() { +int daMrSun_c::onCreate() { OSReport("Creating the Mr.Sun Model"); + allocator.link(-1, GameHeaps[0], 0, 0x20); + + nw4r::g3d::ResFile rf(getResource("g3d/bubble.brres", "bubble")); + model.setup(rf.GetResMdl("bubble"), &allocator, 0x224, 1, 0); + SetupTextures_Enemy(&model, 0); + allocator.unlink(); OSReport("Setting Mr.Sun's Size to 4.0"); this->scale = (Vec){4.0, 4.0, 4.0}; @@ -47,16 +59,17 @@ int dMrSun_c::onCreate() { return true; } -int dMrSun_c::onDelete() { +int daMrSun_c::onDelete() { return true; } -int dMrSun_c::onExecute() { +int daMrSun_c::onExecute() { OSReport("Oh Mr.Sun, Sun, Mr.Golden Sun"); return true; } -int dMrSun_c::onDraw() { +int daMrSun_c::onDraw() { + model.scheduleForDrawing(); return true; } |