summaryrefslogtreecommitdiff
path: root/src/spriteswapper.cpp
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-03-17 16:27:52 -0500
committerColin Noga <Tempus@chronometry.ca>2012-03-17 16:27:52 -0500
commite6a945496b2252477f1d5015343ce7e6cdda0cc4 (patch)
tree67aeb5a84b5423082c264d1c1326c9d443960839 /src/spriteswapper.cpp
parente88fd1dcef52d4375fef655918886fc14bb1f40c (diff)
downloadkamek-e6a945496b2252477f1d5015343ce7e6cdda0cc4.tar.gz
kamek-e6a945496b2252477f1d5015343ce7e6cdda0cc4.zip
Added Captina Bowser and his crew of merry sprites, plus some fixes for other junk.
Diffstat (limited to '')
-rwxr-xr-xsrc/spriteswapper.cpp86
1 files changed, 30 insertions, 56 deletions
diff --git a/src/spriteswapper.cpp b/src/spriteswapper.cpp
index 2bc03d5..89ead56 100755
--- a/src/spriteswapper.cpp
+++ b/src/spriteswapper.cpp
@@ -1,17 +1,14 @@
#include <common.h>
#include <game.h>
-struct SpriteSpawnerTimed {
- u32 id; // 0x00
- u32 settings; // 0x04
- u16 name; // 0x08
- u8 _0A[6]; // 0x0A
- u8 _10[0x9C]; // 0x10
- float x; // 0xAC
- float y; // 0xB0
- float z; // 0xB4
- u8 _B8[0x318]; // 0xB8
- // Any variables you add to the class go here; starting at offset 0x3D0
+
+class SpriteSpawnerTimed : public dStageActor_c {
+public:
+ int onCreate();
+ int onExecute();
+
+ static SpriteSpawnerTimed *build();
+
u64 eventFlag; // 0x3D0
u16 type; // 0x3D4
u32 inheritSet; // 0x3D6
@@ -24,68 +21,45 @@ struct EventTable_t {
};
-struct VEC {
- float x;
- float y;
- float z;
-};
-
+SpriteSpawnerTimed *SpriteSpawnerTimed::build() {
+ void *buffer = AllocFromGameHeap1(sizeof(SpriteSpawnerTimed));
+ return new(buffer) SpriteSpawnerTimed;
+}
extern EventTable_t *EventTable;
-extern "C" dStageActor_c *CreateActor(u16 classID, int settings, VEC pos, char rot, char layer);
-extern "C" dStageActor_c *Actor_SearchByID(u32 actorID);
-
-void SpriteSpawnerTimed_Update(SpriteSpawnerTimed *self);
-
-#define ACTIVATE 1
-#define DEACTIVATE 0
-
+extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer);
-bool SpriteSpawnerTimed_Create(SpriteSpawnerTimed *self) {
+int SpriteSpawnerTimed::onCreate() {
- char eventNum = (self->settings >> 28) & 0xF;
+ char eventNum = (this->settings >> 28) & 0xF;
- self->eventFlag = (u64)1 << (eventNum - 1);
- self->type = (self->settings >> 16) & 0xFFF;
+ this->eventFlag = (u64)1 << (eventNum - 1);
+ this->type = (this->settings >> 16) & 0xFFF;
- short tempSet = self->settings & 0xFFFF;
- self->inheritSet = (tempSet & 3) | ((tempSet & 0xC) << 2) | ((tempSet & 0x30) << 4) | ((tempSet & 0xC0) << 6) | ((tempSet & 0x300) << 8) | ((tempSet & 0xC00) << 10) | ((tempSet & 0x3000) << 12) | ((tempSet & 0xC000) << 14);
+ short tempSet = this->settings & 0xFFFF;
+ this->inheritSet = (tempSet & 3) | ((tempSet & 0xC) << 2) | ((tempSet & 0x30) << 4) | ((tempSet & 0xC0) << 6) | ((tempSet & 0x300) << 8) | ((tempSet & 0xC00) << 10) | ((tempSet & 0x3000) << 12) | ((tempSet & 0xC000) << 14);
- self->timer = 0;
- SpriteSpawnerTimed_Update(self);
+ this->timer = 0;
return true;
}
-bool SpriteSpawnerTimed_Execute(SpriteSpawnerTimed *self) {
- SpriteSpawnerTimed_Update(self);
- return true;
-}
+int SpriteSpawnerTimed::onExecute() {
-
-void SpriteSpawnerTimed_Update(SpriteSpawnerTimed *self) {
-
- if (EventTable->events & self->eventFlag)
- {
-
- if (self->timer == 0)
- {
- VEC pos;
- pos.x = self->x;
- pos.y = self->y;
- pos.z = self->z;
-
-
- dStageActor_c *spawned = CreateActor(self->type, self->inheritSet, pos, 0, 0);
- self->timer = 120;
+ if (EventTable->events & this->eventFlag) { // If the event is on
+ if (this->timer < 1) { // If the timer is empty
+ CreateActor(this->type, this->inheritSet, this->pos, 0, 0);
+ this->timer = 120;
}
+ this->timer--;
}
+
else {
- self->timer = 0;
+ this->timer = 0;
}
- self->timer--;
-}
+ return true;
+} \ No newline at end of file