summaryrefslogtreecommitdiff
path: root/src/spritespawner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/spritespawner.cpp')
-rwxr-xr-x[-rw-r--r--]src/spritespawner.cpp47
1 files changed, 16 insertions, 31 deletions
diff --git a/src/spritespawner.cpp b/src/spritespawner.cpp
index d9ee51a..7468bbb 100644..100755
--- a/src/spritespawner.cpp
+++ b/src/spritespawner.cpp
@@ -14,7 +14,8 @@ struct SpriteSpawner {
// Any variables you add to the class go here; starting at offset 0x3D0
u64 eventFlag; // 0x3D0
u16 type; // 0x3D4
- u8 lastEvState; // 0x3D6
+ u32 inheritSet; // 0x3D6
+ u8 lastEvState; // 0x3DA
};
struct EventTable_t {
@@ -43,42 +44,34 @@ void SpriteSpawner_Update(SpriteSpawner *self);
bool SpriteSpawner_Create(SpriteSpawner *self) {
OSReport("I exist, dammit!");
- char eventNum = (self->settings >> 24) & 0xFF;
+ char eventNum = (self->settings >> 28) & 0xF;
+ OSReport("Event to activate: %d", eventNum);
+
self->eventFlag = (u64)1 << (eventNum - 1);
+ self->type = (self->settings >> 16) & 0xFFF;
- self->type = (self->settings) & 0xFFFF;
-
- self->lastEvState = 0xFF;
-
+ 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);
+
SpriteSpawner_Update(self);
return true;
}
bool SpriteSpawner_Execute(SpriteSpawner *self) {
+ OSReport("Events: %08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF);
SpriteSpawner_Update(self);
return true;
}
void SpriteSpawner_Update(SpriteSpawner *self) {
-
- u8 newEvState = 0;
- if (EventTable->events & self->eventFlag)
- newEvState = 1;
-
- if (newEvState == self->lastEvState)
- return;
-
- u8 offState;
- if (newEvState == ACTIVATE)
- {
- offState = (newEvState == 1) ? 1 : 0;
-
+
+ if (EventTable->events & self->eventFlag)
+ {
// Put an action for when the event turns on here
- int spriteset = 0;
VEC pos;
pos.x = self->x;
pos.y = self->y;
@@ -86,16 +79,8 @@ void SpriteSpawner_Update(SpriteSpawner *self) {
OSReport("Spawning Sprite: %d at %f,%f,%f\n", self->type, pos.x, pos.y, pos.z);
- CreateActor(self->type, spriteset, pos, 0, 0);
- }
-
- else
- {
- offState = (newEvState == 1) ? 0 : 1;
-
- // Put an action for when the event turns off here
-
+ CreateActor(self->type, self->inheritSet, pos, 0, 0);
+
+ EventTable->events = EventTable->events & ~self->eventFlag;
}
-
- self->lastEvState = newEvState;
}