summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/eventlooper.cpp60
1 files changed, 36 insertions, 24 deletions
diff --git a/src/eventlooper.cpp b/src/eventlooper.cpp
index 3c1fe7d..755742d 100644
--- a/src/eventlooper.cpp
+++ b/src/eventlooper.cpp
@@ -13,6 +13,7 @@ struct EventLooper {
u8 _B8[0x318]; // 0xB8
// Any variables you add to the class go here; starting at offset 0x3D0
u64 eventFlag; // 0x3D0
+ u64 eventActive; // 0x3D0
u8 delay; // 0x3D4
u8 delayCount; // 0x3D7
};
@@ -29,27 +30,39 @@ void EventLooper_Update(EventLooper *self);
bool EventLooper_Create(EventLooper *self) {
- OSReport("Sprite Created");
char eventStart = (self->settings >> 24) & 0xFF;
char eventEnd = (self->settings >> 16) & 0xFF;
- OSReport("Mark 1");
-
// Putting all the events into the flag
int i;
- int q;
- for(i=eventStart;i<eventEnd;i++)
- q = q & ((u64)1 << (i - 1));
-
- OSReport("Mark 2");
+ u64 q = (u64)0;
+ for(i=eventStart;i<(eventEnd+1);i++)
+ {
+ q = q | ((u64)1 << (i - 1));
+ }
self->eventFlag = q;
- self->delay = ((self->settings) & FF) * 10;
+ self->delay = (((self->settings) & 0xFF) + 1) * 10;
self->delayCount = 0;
-
- OSReport("About to first update");
+ char tmpEvent= (self->settings >> 8) & 0xFF;
+ if (tmpEvent == 0)
+ {
+ self->eventActive = (u64)0xFFFFFFFFFFFFFFFF;
+ }
+ else
+ {
+ self->eventActive = (u64)1 << (tmpEvent - 1);
+
+ }
+
+
+ if (EventTable->events & self->eventActive)
+ {
+ u64 evState = (u64)1 << (eventStart - 1);
+ EventTable->events = EventTable->events | evState;
+ }
EventLooper_Update(self);
@@ -57,7 +70,6 @@ bool EventLooper_Create(EventLooper *self) {
}
bool EventLooper_Execute(EventLooper *self) {
- OSReport("Sprite Update");
EventLooper_Update(self);
return true;
}
@@ -65,29 +77,31 @@ bool EventLooper_Execute(EventLooper *self) {
void EventLooper_Update(EventLooper *self) {
+ if ((EventTable->events & self->eventActive) == 0)
+ return;
// Waiting for the right moment
if (self->delayCount < self->delay)
{
- OSReport("Delaying: %d\n", self->delayCount);
+// OSReport("Delaying: %d / %d\n", self->delayCount, self->delay);
self->delayCount = self->delayCount + 1;
return;
}
-
- OSReport("Event flag Start: %08x %08x\n", self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF);
- OSReport("Event TableStart: %08x %08x\n", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF);
- // Find which event(s) is/are on
+ // Reset the delay
+ self->delayCount = 0;
+
+ // Find which event(s) is/are on
u64 evState = EventTable->events & self->eventFlag;
// Turn off the old events
- EventTable->events & (~self->eventFlag);
+ EventTable->events = EventTable->events & (~self->eventFlag);
// Shift them right if they can, if not, reset!
- if (evState < eventFlag)
+ evState = evState << 1;
+ if (evState < self->eventFlag)
{
- evState << 1;
EventTable->events = EventTable->events | evState;
}
@@ -97,8 +111,6 @@ void EventLooper_Update(EventLooper *self) {
evState = (u64)1 << (eventStart - 1);
EventTable->events = EventTable->events | evState;
}
-
- OSReport("Event flag End: %08x %08x\n", self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF);
- OSReport("Event Table End: %08x %08x\n", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF);
-
+
+
}