summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--context.h130
-rw-r--r--include/pso/TMainTask.h2
2 files changed, 75 insertions, 57 deletions
diff --git a/context.h b/context.h
index 0af5667..24a211d 100644
--- a/context.h
+++ b/context.h
@@ -56,31 +56,31 @@ typedef long ptrdiff_t;
o(tl_fade, TL_FADE) \
o(tl_fadeafter, TL_FADEAFTER)
-#define FOREACH_NODE(type, first, varname) for (type *varname = (type *)(first); varname != NULL; varname = (type *)(varname->next))
-#define FOREACH_NODE_NODECL(type, first, varname) for (varname = (type *)(first); varname != NULL; varname = (type *)(varname->next))
-
-#define FOREACH_NODE_MULTI_ITER(type, first, varname, ...) for (type *varname = (type *)(first); varname != NULL; varname = (type *)(varname->next), __VA_ARGS__)
-#define FOREACH_NODE_NODECL_MULTI_ITER(type, first, varname, ...) for (varname = (type *)(first); varname != NULL; varname = (type *)(varname->next), __VA_ARGS__)
-
-#define X_OR_Y_CHILD(flags, old_flags, one_prefix, zero_prefix, suffix) \
- if (flags != old_flags) { \
- TMainTask *child; \
- u32 bit = 1; \
- FOREACH_NODE_NODECL_MULTI_ITER(TMainTask, main_task.down, child, bit <<= 1) { \
- if (flags & bit) { \
- child->one_prefix##_##suffix(); \
- } else { \
- child->zero_prefix##_##suffix(); \
- } \
- } \
- old_flags = flags; \
+#define FOREACH_NODE(type, first, varname) for (type *varname = (type *)(first); varname != NULL; varname = (type *)(varname->next()))
+#define FOREACH_NODE_NODECL(type, first, varname) for (varname = (type *)(first); varname != NULL; varname = (type *)(varname->next()))
+
+#define FOREACH_NODE_MULTI_ITER(type, first, varname, ...) for (type *varname = (type *)(first); varname != NULL; varname = (type *)(varname->next()), __VA_ARGS__)
+#define FOREACH_NODE_NODECL_MULTI_ITER(type, first, varname, ...) for (varname = (type *)(first); varname != NULL; varname = (type *)(varname->next()), __VA_ARGS__)
+
+#define X_OR_Y_CHILD(flags, old_flags, one_prefix, zero_prefix, suffix) \
+ if (flags != old_flags) { \
+ TMainTask *child; \
+ u32 bit = 1; \
+ FOREACH_NODE_NODECL_MULTI_ITER(TMainTask, main_task.down(), child, bit <<= 1) { \
+ if (flags & bit) { \
+ child->one_prefix##_##suffix(); \
+ } else { \
+ child->zero_prefix##_##suffix(); \
+ } \
+ } \
+ old_flags = flags; \
}
#define SET_OR_CLEAR_CHILD_FLAGS(flags, old_flags, flag_bit) \
X_OR_Y_CHILD(flags, old_flags, set_flag, clear_flag, flag_bit)
#define DISALLOW_OR_ALLOW_CHILD(flags, old_flags, flag_name) \
- X_OR_Y_CHILD(flags, old_flags, disallow, allow, flag_name)
+ X_OR_Y_CHILD(flags, old_flags, allow, disallow, flag_name)
// Class forward.
@@ -192,17 +192,17 @@ public:
};
class TObject {
-public:
- const char *name;
+private:
+ const char *m_name;
union {
- object_flags flags;
- u16 flags_u16;
+ object_flags m_flags;
+ u16 m_flags_u16;
};
- u16 id;
- TObject *prev;
- TObject *next;
- TObject *up;
- TObject *down;
+ u16 m_id;
+ TObject *m_prev;
+ TObject *m_next;
+ TObject *m_up;
+ TObject *m_down;
public:
void disallow_rendering_shadows();
void allow_rendering_shadows();
@@ -221,6 +221,24 @@ public:
void *operator new (size_t size) { return alloc(size); };
void operator delete(void *ptr) { free(ptr); };
+ const char *name() { return m_name; };
+ object_flags flags() { return m_flags; };
+ u16 flags_u16() { return m_flags_u16; };
+ u16 id() { return m_id; };
+ TObject *prev() { return m_prev; };
+ TObject *next() { return m_next; };
+ TObject *up() { return m_up; };
+ TObject *down() { return m_down; };
+
+ void set_name(const char *name) { m_name = name; };
+ void set_obj_flags(object_flags flags) { m_flags = flags; };
+ void set_flags_u16(u16 flags) { m_flags_u16 = flags; };
+ void set_id(u16 id) { m_id = id; };
+ void set_prev(TObject *node) { m_prev = node; };
+ void set_next(TObject *node) { m_next = node; };
+ void set_up(TObject *node) { m_up = node; };
+ void set_down(TObject *node) { m_down = node; };
+
void delete_children();
void queue_destruction_for_each_node();
void run_tasks();
@@ -244,63 +262,63 @@ public:
private:
void _delete_children() {
- while (this->down != NULL) {
- delete this->down;
+ while (m_down != NULL) {
+ delete m_down;
}
};
void add_parent(TObject *parent, bool set_parent) {
if (set_parent) {
- up = parent;
+ m_up = parent;
}
TObject *child;
if (parent == NULL) {
- this->prev = this;
- this->next = NULL;
+ m_prev = this;
+ m_next = NULL;
return;
}
- child = parent->down;
+ child = parent->m_down;
if (child != NULL) {
- this->prev = child->next;
- this->next = NULL;
- child->prev->next = this;
- child->prev = this;
+ m_prev = child->m_next;
+ m_next = NULL;
+ child->m_prev->m_next = this;
+ child->m_prev = this;
} else {
- this->prev = this;
- parent->down = this;
- this->next = NULL;
+ m_prev = this;
+ parent->m_down = this;
+ m_next = NULL;
}
};
void remove_parent() {
- if (this->up != NULL) {
- if (this->prev == this) {
- this->up->down = NULL;
- } else if (this->up->down == this) {
- this->up->down = this->prev;
- this->prev->next = NULL;
- if (this->next != NULL) {
- this->next->prev = this->next;
+ if (m_up != NULL) {
+ if (m_prev == this) {
+ m_up->m_down = NULL;
+ } else if (m_up->m_down == this) {
+ m_up->m_down = m_next;
+ m_prev->m_next = NULL;
+ if (m_next != NULL) {
+ m_next->m_prev = m_prev;
}
} else {
- this->prev->next = this->next;
- if (this->next != NULL) {
- this->next->prev = this->prev;
+ m_prev->m_next = m_next;
+ if (m_next != NULL) {
+ m_next->m_prev = m_prev;
} else {
- this->up->down->prev = this->prev;
+ m_up->m_down->m_prev = m_prev;
}
}
}
};
void set_flags(object_flags flags) {
- this->flags |= flags;
+ m_flags |= flags;
}
void clear_flags(object_flags flags) {
- flags_u16 &= ~static_cast<u16>(flags);
+ m_flags_u16 &= ~static_cast<u16>(flags);
}
u32 get_flags(object_flags flags) {
- return this->flags & flags;
+ return m_flags & flags;
};
};
diff --git a/include/pso/TMainTask.h b/include/pso/TMainTask.h
index d8b5b6e..03319a6 100644
--- a/include/pso/TMainTask.h
+++ b/include/pso/TMainTask.h
@@ -10,7 +10,7 @@
if (flags != old_flags) { \
TMainTask *child; \
u32 bit = 1; \
- FOREACH_NODE_NODECL_MULTI_ITER(TMainTask, main_task.down(), child, bit <<= 1) { \
+ FOREACH_NODE_NODECL_MULTI_ITER(TMainTask, main_task.down(), child, bit <<= 1) { \
if (flags & bit) { \
child->one_prefix##_##suffix(); \
} else { \