SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
object.h
Go to the documentation of this file.
1
23
24#ifndef _OBJECT_H_
25#define _OBJECT_H_
26
27#include "pool.h"
28
29
33#define OBJ_ALLOCATED 0x8000
34
35
36
37// forward
38typedef struct Object_ Object;
39
47typedef void ObjectCallback(Object* obj);
48
64typedef struct Object_
65{
66 u16 internalState;
67 u16 type;
68 ObjectCallback* init;
69 ObjectCallback* update;
70 ObjectCallback* end;
71} Object;
72
73
87Pool* OBJ_createObjectPool(u16 size, u16 objectSize);
88
101Object* OBJ_create(Pool* pool);
117void OBJ_release(Pool* pool, Object* object, bool maintainCoherency);
118
128void OBJ_updateAll(Pool* pool);
129
142void OBJ_setInitMethod(Object* object, ObjectCallback* initMethod);
155void OBJ_setUpdateMethod(Object* object, ObjectCallback* updateMethod);
168void OBJ_setEndMethod(Object* object, ObjectCallback* endMethod);
169
170
171#endif // _OBJECT_H_
void ObjectCallback(Object *obj)
Object function callback.
Definition object.h:47
struct Object_ Object
Base object structure.
Definition object.h:38
Pool * OBJ_createObjectPool(u16 size, u16 objectSize)
Create and allocate the new object pool (this method is an alias of POOL_create(.....
Definition object.c:37
void OBJ_release(Pool *pool, Object *object, bool maintainCoherency)
Release an objet from the given object pool (object must extend basic Object structure)
Definition object.c:61
void OBJ_setEndMethod(Object *object, ObjectCallback *endMethod)
Set the ending method for the given object.
Definition object.c:87
void OBJ_setInitMethod(Object *object, ObjectCallback *initMethod)
Set the initialization method for the given object.
Definition object.c:71
void OBJ_setUpdateMethod(Object *object, ObjectCallback *updateMethod)
Set the update method for the given object.
Definition object.c:79
Object * OBJ_create(Pool *pool)
Create a new objet from the given object pool (object must extend basic Object structure)
Definition object.c:43
void OBJ_updateAll(Pool *pool)
Iterate over all active objects from the given object pool and call update method for each of them.
Definition object.c:95
Pool object management unit.
Base object structure.
Definition object.h:65
Object pool allocator structure.
Definition pool.h:57
unsigned short u16
Definition types.h:100