summaryrefslogtreecommitdiff
path: root/src/spriteswapper.cpp
diff options
context:
space:
mode:
authorColin Noga <Tempus@Spectrum-Song.local>2011-07-23 11:47:43 -0500
committerColin Noga <Tempus@Spectrum-Song.local>2011-07-23 11:47:43 -0500
commit09d075c5469f64f500de70123bbb1042315d7ac0 (patch)
treeee92906230c7fa01e89afb84beeb65b8855393ad /src/spriteswapper.cpp
parentffa9dabc6b535da90b3cd8a7849079c546cacfbd (diff)
downloadkamek-09d075c5469f64f500de70123bbb1042315d7ac0.tar.gz
kamek-09d075c5469f64f500de70123bbb1042315d7ac0.zip
Added Crowd clapper. Changed everything to LF only. If anyone on Windows tries to read the code now, they will be faced with a single impenetrable line!
Diffstat (limited to '')
-rwxr-xr-xsrc/spriteswapper.cpp144
1 files changed, 144 insertions, 0 deletions
diff --git a/src/spriteswapper.cpp b/src/spriteswapper.cpp
new file mode 100755
index 0000000..cbff99f
--- /dev/null
+++ b/src/spriteswapper.cpp
@@ -0,0 +1,144 @@
+#include <common.h>
+#include <game.h>
+
+struct SpriteSwapper {
+ 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
+ u64 eventFlag; // 0x3D0
+ u16 firstType; // 0x3D4
+ u16 secondType; // 0x3D4
+ u8 lastEvState; // 0x3DA
+ u32 firstActor;
+ u32 secondActor;
+};
+
+struct EventTable_t {
+ u64 events;
+};
+
+
+struct VEC {
+ float x;
+ float y;
+ float z;
+};
+
+
+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 SpriteSwapper_Update(SpriteSwapper *self);
+
+#define ACTIVATE 1
+#define DEACTIVATE 0
+
+
+
+
+bool SpriteSwapper_Create(SpriteSwapper *self) {
+ OSReport("I exist, dammit!");
+
+ char eventNum = (self->settings >> 28) & 0xF;
+ OSReport("Event to activate: %d", eventNum);
+
+ self->eventFlag = (u64)1 << (eventNum - 1);
+ self->firstActor = 0;
+ self->secondActor = 0;
+ self->firstType = (self->settings >> 16) & 0xFFF;
+ self->secondType = self->settings & 0xFFF;
+
+ VEC pos;
+ pos.x = self->x;
+ pos.y = self->y;
+ pos.z = self->z;
+
+ OSReport("Spawning first sprite.");
+
+ dStageActor_c *spawned = CreateActor(self->firstType, 0, pos, 0, 0);
+ self->firstActor = spawned->id;
+
+ OSReport("Spawned %d.", self->firstActor);
+
+ SpriteSwapper_Update(self);
+
+ return true;
+}
+
+bool SpriteSwapper_Execute(SpriteSwapper *self) {
+ SpriteSwapper_Update(self);
+ return true;
+}
+
+
+void SpriteSwapper_Update(SpriteSwapper *self) {
+
+ if (EventTable->events & self->eventFlag)
+ {
+ // Put an action for when the event turns on here
+ OSReport("Event turned on.");
+
+ if (self->firstActor != 0)
+ {
+ OSReport("Found the first sprite.");
+
+ dStageActor_c *spawned = Actor_SearchByID(self->firstActor);
+ if (spawned != 0) {
+ OSReport("It's still alive.");
+ self->x = spawned->pos.x;
+ self->y = spawned->pos.y;
+ self->z = spawned->pos.z;
+ spawned->Delete();
+ }
+ self->firstActor = 0;
+ OSReport("Now it's deleted.");
+
+ VEC pos;
+ pos.x = self->x;
+ pos.y = self->y;
+ pos.z = self->z;
+
+ OSReport("Making second sprite.");
+ dStageActor_c *spawner = CreateActor(self->secondType, 0, pos, 0, 0);
+ self->secondActor = spawner->id;
+ OSReport("Spawned %d.", self->secondActor);
+ }
+// EventTable->events = EventTable->events & ~self->eventFlag;
+ }
+ else
+ {
+ OSReport("Event turned off.");
+ if (self->secondActor != 0)
+ {
+ OSReport("Found the second sprite.");
+ dStageActor_c *spawned = Actor_SearchByID(self->secondActor);
+ if (spawned != 0) {
+ OSReport("It's still alive.");
+ self->x = spawned->pos.x;
+ self->y = spawned->pos.y;
+ self->z = spawned->pos.z;
+ spawned->Delete();
+ }
+ self->secondActor = 0;
+ OSReport("Now it's deleted.");
+
+ VEC pos;
+ pos.x = self->x;
+ pos.y = self->y;
+ pos.z = self->z;
+
+ OSReport("Making first sprite again.");
+ dStageActor_c *spawner = CreateActor(self->firstType, 0, pos, 0, 0);
+ self->firstActor = spawner->id;
+ OSReport("Spawned %d.", self->firstActor);
+ }
+ }
+}