mirror of
https://github.com/jiangzhengwenjz/katam.git
synced 2024-11-23 13:10:11 +00:00
document task
This commit is contained in:
parent
896f080ddd
commit
e6e77ae480
@ -73,7 +73,7 @@ sub_08020298: @ 0x08020298
|
||||
mov r8, r0
|
||||
ldr r1, _0802032C @ =0x0000FFFF
|
||||
movs r0, #0
|
||||
bl sub_08152FB0
|
||||
bl TasksDestroyInPriorityRange
|
||||
ldr r1, _08020330 @ =gUnk_03003A04
|
||||
ldr r0, _08020334 @ =gUnk_03003790
|
||||
ldrb r0, [r0]
|
||||
|
@ -6799,7 +6799,7 @@ sub_08029618: @ 0x08029618
|
||||
strh r0, [r1]
|
||||
ldr r1, _080296D0 @ =0x0000FFFF
|
||||
movs r0, #0
|
||||
bl sub_08152FB0
|
||||
bl TasksDestroyInPriorityRange
|
||||
ldr r1, _080296D4 @ =gUnk_03003A04
|
||||
ldr r0, _080296D8 @ =gUnk_03003790
|
||||
ldrb r0, [r0]
|
||||
|
@ -11,7 +11,7 @@ sub_08032E98: @ 0x08032E98
|
||||
sub sp, #8
|
||||
ldr r1, _08032EFC @ =0x0000FFFF
|
||||
movs r0, #0
|
||||
bl sub_08152FB0
|
||||
bl TasksDestroyInPriorityRange
|
||||
ldr r1, _08032F00 @ =gUnk_03003A04
|
||||
ldr r0, _08032F04 @ =gUnk_03003790
|
||||
ldrb r0, [r0]
|
||||
@ -438,7 +438,7 @@ sub_08033234: @ 0x08033234
|
||||
push {lr}
|
||||
ldr r1, _08033278 @ =0x0000FFFF
|
||||
movs r0, #0
|
||||
bl sub_08152FB0
|
||||
bl TasksDestroyInPriorityRange
|
||||
ldr r1, _0803327C @ =gUnk_03003A04
|
||||
ldr r0, _08033280 @ =gUnk_03003790
|
||||
ldrb r0, [r0]
|
||||
|
@ -64,14 +64,15 @@ SoftReset: @ 0x0815931C
|
||||
ldr r3, _0815932C @ =0x04000208
|
||||
movs r2, #0
|
||||
strb r2, [r3]
|
||||
ldr r1, _08159330 @ =gUnk_03007F00
|
||||
@ default sp_usr
|
||||
ldr r1, _08159330 @ =0x03007F00
|
||||
mov sp, r1
|
||||
svc #1
|
||||
svc #0
|
||||
movs r0, r0
|
||||
.align 2, 0
|
||||
_0815932C: .4byte 0x04000208
|
||||
_08159330: .4byte gUnk_03007F00
|
||||
_08159330: .4byte 0x03007F00
|
||||
|
||||
thumb_func_start SoundBiasReset
|
||||
SoundBiasReset: @ 0x08159334
|
||||
|
@ -4125,7 +4125,7 @@ sub_0802CB60: @ 0x0802CB60
|
||||
strh r0, [r1]
|
||||
ldr r1, _0802CC1C @ =0x0000FFFF
|
||||
movs r0, #0
|
||||
bl sub_08152FB0
|
||||
bl TasksDestroyInPriorityRange
|
||||
ldr r1, _0802CC20 @ =gUnk_03003A04
|
||||
ldr r0, _0802CC24 @ =gUnk_03003790
|
||||
ldrb r0, [r0]
|
||||
|
@ -63,4 +63,6 @@ typedef void (*FuncType_030068C0)(void);
|
||||
typedef u32 (*FuncType_08D5FDD4)(void);
|
||||
typedef void (*IntrFunc)(void);
|
||||
|
||||
extern void *iwram_end;
|
||||
|
||||
#endif // GUARD_GLOBAL_H
|
||||
|
@ -8,51 +8,53 @@ struct Task;
|
||||
typedef void (*TaskMain)(void);
|
||||
typedef void (*TaskDestructor)(struct Task*);
|
||||
|
||||
#define MAX_TASK_NUM 0x80
|
||||
|
||||
#define TASK_INACTIVE 0x0001
|
||||
#define TASK_DESTROY_DISABLED 0x0002
|
||||
#define TASK_x0004 0x0004
|
||||
#define TASK_USE_EWRAM 0x0010 // when it fails, use the other work ram instead.
|
||||
|
||||
struct Task {
|
||||
/* 0x00 */ u16 unk0;
|
||||
/* 0x02 */ u16 unk2; // prev?
|
||||
/* 0x00 */ u16 parent; // the current task on creation
|
||||
/* 0x02 */ u16 prev;
|
||||
/* 0x04 */ u16 next;
|
||||
/* 0x06 */ u16 structOffset;
|
||||
/* 0x08 */ TaskMain main;
|
||||
/* 0x0C */ TaskDestructor dtor;
|
||||
/* 0x10 */ u16 unk10; // priority?
|
||||
/* 0x12 */ u16 flags; // 0x1 = active
|
||||
// 0x2 = ???
|
||||
// 0x10 = use ewram for struct
|
||||
/* 0x10 */ u16 priority; // lower value => higher priority
|
||||
/* 0x12 */ u16 flags;
|
||||
};
|
||||
|
||||
struct Unk_03003A20 {
|
||||
u16 unk0;
|
||||
s16 unk2;
|
||||
struct IwramNode {
|
||||
u16 next;
|
||||
s16 state;
|
||||
u8 space[0];
|
||||
};
|
||||
|
||||
#define TaskGetStructPtr(taskp, dst) ({ \
|
||||
if ((taskp)->flags & 0x10) \
|
||||
if ((taskp)->flags & TASK_USE_EWRAM) \
|
||||
(dst) = (typeof(dst))(EWRAM_START + ((taskp)->structOffset << 2)); \
|
||||
else \
|
||||
(dst) = (typeof(dst))(IWRAM_START + (taskp)->structOffset); \
|
||||
(dst); \
|
||||
})
|
||||
|
||||
extern struct Task gUnk_030019F0[];
|
||||
extern u32 gUnk_03002440;
|
||||
extern struct Task gTasks[];
|
||||
extern struct Task gEmptyTask;
|
||||
extern u8 gUnk_03002558;
|
||||
extern struct Task* gTaskList[];
|
||||
extern s32 gLastTaskNum;
|
||||
extern struct Task* gUnk_03002E98;
|
||||
extern struct Task* gTaskPtrs[];
|
||||
extern s32 gNumTasks;
|
||||
extern struct Task* gNextTaskToCheckForDestruction;
|
||||
extern struct Task* gNextTask;
|
||||
extern struct Task* gCurTask;
|
||||
extern struct Unk_03003A20 gUnk_03003A20[];
|
||||
extern struct IwramNode gIwramHeap;
|
||||
extern u8 gExecSoundMain;
|
||||
extern OamData *gUnk_03006CC4;
|
||||
|
||||
u32 TaskInit(void);
|
||||
void TaskExecute(void);
|
||||
u32 TasksInit(void);
|
||||
void TasksExec(void);
|
||||
struct Task* TaskCreate(TaskMain, u16, u16, u16, TaskDestructor);
|
||||
void TaskDestroy(struct Task*);
|
||||
struct Unk_03003A20* IwramMalloc(u16);
|
||||
void sub_08152FB0(u16, u16);
|
||||
struct IwramNode* IwramMalloc(u16);
|
||||
void TasksDestroyInPriorityRange(u16, u16);
|
||||
|
||||
#endif
|
||||
|
13
linker.ld
13
linker.ld
@ -136,7 +136,7 @@ SECTIONS {
|
||||
. = 0x00000560; src/m4a.o(common_data);
|
||||
. = ALIGN(16); gIntrTable = .;
|
||||
. = 0x000017F0; gIntrMainBuf = .;
|
||||
. = 0x000019F0; gUnk_030019F0 = .;
|
||||
. = 0x000019F0; gTasks = .;
|
||||
. = 0x000023F0; gUnk_030023F0 = .;
|
||||
. = 0x000023F4; gUnk_030023F4 = .;
|
||||
. = 0x00002400; gUnk_03002400 = .;
|
||||
@ -162,7 +162,7 @@ SECTIONS {
|
||||
. = 0x00002550; gUnk_03002550 = .;
|
||||
. = 0x00002554; gMultiSioStatusFlags = .;
|
||||
. = 0x00002558; gUnk_03002558 = .;
|
||||
. = 0x00002560; gTaskList = .;
|
||||
. = 0x00002560; gTaskPtrs = .;
|
||||
. = 0x00002760; gUnk_03002760 = .;
|
||||
. = 0x00002C60; gObjPalette = .;
|
||||
. = 0x00002E20; gUnk_03002E20 = .;
|
||||
@ -170,13 +170,13 @@ SECTIONS {
|
||||
. = 0x00002E60; gUnk_03002E60 = .;
|
||||
. = 0x00002E64; gFrameCount = .;
|
||||
. = 0x00002E70; gWinRegs = .;
|
||||
. = 0x00002E7C; gLastTaskNum = .;
|
||||
. = 0x00002E7C; gNumTasks = .;
|
||||
. = 0x00002E80; gUnk_03002E80 = .;
|
||||
. = 0x00002E82; gUnk_03002E82 = .;
|
||||
. = 0x00002E83; gUnk_03002E83 = .;
|
||||
. = 0x00002E90; gInput = .;
|
||||
. = 0x00002E94; gUnk_03002E94 = .;
|
||||
. = 0x00002E98; gUnk_03002E98 = .;
|
||||
. = 0x00002E98; gNextTaskToCheckForDestruction = .;
|
||||
. = 0x00002EA0; gRepeatedKeysTestCounter = .;
|
||||
. = 0x00002EAC; gUnk_03002EAC = .;
|
||||
. = 0x00002EB0; gBgCntRegs = .;
|
||||
@ -221,7 +221,7 @@ SECTIONS {
|
||||
. = 0x00003A00; gUnk_03003A00 = .;
|
||||
. = 0x00003A04; gUnk_03003A04 = .;
|
||||
. = 0x00003A10; gHBlankIntrs = .;
|
||||
. = 0x00003A20; gUnk_03003A20 = .;
|
||||
. = 0x00003A20; gIwramHeap = .;
|
||||
. = 0x00006030; gUnk_03006030 = .;
|
||||
. = 0x00006070; gUnk_03006070 = .;
|
||||
. = 0x00006074; gUnk_03006074 = .;
|
||||
@ -243,8 +243,7 @@ SECTIONS {
|
||||
. = ALIGN(16); src/input_recorder.o(common_data);
|
||||
. = ALIGN(4); src/input_recorder.o(.bss);
|
||||
. = ALIGN(4); gUnk_03006CC0 = .;
|
||||
. = 0x00006CC4; gUnk_03006CC4 = .;
|
||||
. = 0x00007F00; gUnk_03007F00 = .;
|
||||
. = 0x00006CC4; iwram_end = .;
|
||||
. = 0x00008000;
|
||||
} >iwram
|
||||
|
||||
|
@ -83,7 +83,7 @@ static const u8 gUnk_0835390F[] = {
|
||||
static const u8 gUnk_08353922[] = { 0x00, 0x08, 0x0f, 0x10, 0x00, 0x00, };
|
||||
|
||||
void *CreateAbilityStar(struct Object *arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, sub_080AAA14);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, sub_080AAA14);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x4000;
|
||||
@ -249,7 +249,7 @@ static void sub_080A98F4(struct Object2* arg0) {
|
||||
}
|
||||
|
||||
void *CreateUnknown83(struct Object *arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x40;
|
||||
@ -281,7 +281,7 @@ static void sub_080A9BB4(struct Object2* arg0) {
|
||||
}
|
||||
|
||||
void *CreateDustCloud(struct Object *arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x40;
|
||||
@ -409,7 +409,7 @@ static void sub_080A9CEC(struct Object2* arg0) {
|
||||
static void sub_080A9FBC(struct Object2* arg0, s16 arg1, s16 arg2) {
|
||||
s16 r2;
|
||||
struct Object4 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(sub_080AA108, sizeof(struct Object4), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *task = TaskCreate(sub_080AA108, sizeof(struct Object4), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
sub_0803E3B0(obj);
|
||||
obj->unk0 = 3;
|
||||
@ -528,7 +528,7 @@ static void sub_080AA108(void) {
|
||||
}
|
||||
|
||||
void *CreateAbilityStatue(struct Object *arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.unk68 &= ~7;
|
||||
@ -680,7 +680,7 @@ static void sub_080AA960(struct Object2* arg0) {
|
||||
}
|
||||
|
||||
void *CreateAbilityStatueRandom(struct Object *arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x400;
|
||||
|
@ -19,7 +19,7 @@ static void sub_080C71C4(struct Object2*);
|
||||
|
||||
void* CreateBangBang(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
|
@ -60,7 +60,7 @@ static void sub_080BD524(struct Object2*);
|
||||
|
||||
void* CreateBatty(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
|
@ -17,7 +17,7 @@ static void sub_080A5054(struct Object2*);
|
||||
void* CreateBigWaddleDee(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Kirby *kirby;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x200000;
|
||||
|
@ -8,7 +8,7 @@ static void sub_080A4A08(struct Object2*);
|
||||
void* CreateBlockin(struct Object* arg0, u8 arg1) {
|
||||
struct Task *task;
|
||||
struct Object2 *obj;
|
||||
task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
TaskGetStructPtr(task, obj);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x8000;
|
||||
|
@ -13,7 +13,7 @@ static void sub_080C4968(struct Object2*);
|
||||
|
||||
void* CreateBomber(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.unkC |= 0x100;
|
||||
|
@ -36,7 +36,7 @@ static void sub_080D15F8(struct Object2*);
|
||||
static void sub_080D163C(struct Object2*);
|
||||
|
||||
void *CreateBonkers(struct Object *arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.unkC |= 1;
|
||||
@ -657,7 +657,7 @@ static void sub_080D109C(struct Object2 *arg0) {
|
||||
}
|
||||
|
||||
void *CreateBonkersNut(struct Object *arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x10000;
|
||||
|
@ -18,7 +18,7 @@ static void sub_081238FC(struct Object2*);
|
||||
static void sub_0812385C(struct Object2*);
|
||||
|
||||
void* CreateBonus(struct Object* arg0, u8 arg1) {
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x2f9c, 0x10, ObjectDestroy);
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x2f9c, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj, *obj2;
|
||||
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
void* CreateBrontoBurt(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
|
@ -138,7 +138,7 @@ static void sub_080A3B5C(struct Object2* arg0);
|
||||
static void sub_080A3B94(struct Object2* arg0);
|
||||
|
||||
void* CreateCupie(struct Object* arg0, u8 arg1) {
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
sub_0803E2B0(&obj->base, -5, -3, 5, 8);
|
||||
@ -637,7 +637,7 @@ static void sub_080A35C8(struct Object2* arg0) {
|
||||
|
||||
void* CreateCupieArrow(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.unk63 = 1;
|
||||
|
@ -352,7 +352,7 @@ static inline s32 RandLessThan10(void)
|
||||
void *CreateDarkMindForm1(struct Object *r6, u8 r4_)
|
||||
{
|
||||
u16 r4;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct DarkMindForm1), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct DarkMindForm1), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct DarkMindForm1 *r0, *r5 = TaskGetStructPtr(task, r0);
|
||||
|
||||
InitObject(&r5->unk0, r6, r4_);
|
||||
@ -3089,7 +3089,7 @@ void sub_08104E04(struct DarkMindForm1 *r4)
|
||||
|
||||
void sub_081050E8(struct Object2 *r5, u8 r7)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_08105278, sizeof(struct Object4), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_08105278, sizeof(struct Object4), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *r0, *r4 = TaskGetStructPtr(t, r0);
|
||||
|
||||
sub_0803E3B0(r4);
|
||||
@ -3228,7 +3228,7 @@ void sub_08105278(void)
|
||||
|
||||
struct Object4 *sub_081055B8(struct Object2 *r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_08105698, sizeof(struct Object4), 0x1000, 0x10, sub_0810A130);
|
||||
struct Task *t = TaskCreate(sub_08105698, sizeof(struct Object4), 0x1000, TASK_USE_EWRAM, sub_0810A130);
|
||||
struct Object4 *r0, *r4 = TaskGetStructPtr(t, r0);
|
||||
|
||||
sub_0803E3B0(r4);
|
||||
@ -3362,7 +3362,7 @@ void sub_081059A8(struct DarkMindForm1 *r5)
|
||||
|
||||
void *CreateShadowKirbyBomb(struct Object *r6, u8 r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
InitObject(r4, r6, r5);
|
||||
@ -3600,7 +3600,7 @@ void sub_081062B4(struct DarkMindForm1 *r2)
|
||||
|
||||
void *CreateDarkMindStar(struct Object *r5, u8 r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj = TaskGetStructPtr(t, obj);
|
||||
|
||||
InitObject(obj, r5, r4);
|
||||
@ -3747,7 +3747,7 @@ void sub_081069BC(struct DarkMindForm1 *r7)
|
||||
|
||||
if (!(r7->unk0.base.flags & 0x1000))
|
||||
{
|
||||
t = TaskCreate(sub_08106BE0, sizeof(struct Object4), 0xFFF, 0x10, sub_0803DCCC);
|
||||
t = TaskCreate(sub_08106BE0, sizeof(struct Object4), 0xFFF, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
r4 = TaskGetStructPtr(t, r5);
|
||||
sub_0803E3B0(r4);
|
||||
r4->unk0 = 3;
|
||||
@ -3773,7 +3773,7 @@ void sub_08106AD0(struct Object2 *r5)
|
||||
r6 = r5;
|
||||
if (!(r5->base.flags & 0x1000))
|
||||
{
|
||||
t = TaskCreate(sub_08106BE0, sizeof(struct Object4), 0xFFF, 0x10, sub_0803DCCC);
|
||||
t = TaskCreate(sub_08106BE0, sizeof(struct Object4), 0xFFF, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
r4 = TaskGetStructPtr(t, r0);
|
||||
sub_0803E3B0(r4);
|
||||
r4->unk0 = 3;
|
||||
@ -3988,7 +3988,7 @@ struct DarkMindBomb *sub_08107254(struct Object2 *r3)
|
||||
|
||||
void *CreateDarkMindBomb(struct Object *r5, u8 r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct DarkMindBomb), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct DarkMindBomb), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct DarkMindBomb *obj8 = TaskGetStructPtr(t, obj8);
|
||||
|
||||
InitObject(&obj8->unk0, r5, r4);
|
||||
@ -4109,7 +4109,7 @@ void sub_081075DC(struct DarkMindForm1 *r5) // not referenced
|
||||
|
||||
struct Object2 *sub_08107780(struct Object *r6, u8 r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
InitObject(r4, r6, r5);
|
||||
@ -4133,7 +4133,7 @@ struct Object2 *sub_08107780(struct Object *r6, u8 r5)
|
||||
|
||||
void sub_08107844(struct Object2 *r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_0810792C, sizeof(struct ObjectBase), 0x3500, 0x10, NULL);
|
||||
struct Task *t = TaskCreate(sub_0810792C, sizeof(struct ObjectBase), 0x3500, TASK_USE_EWRAM, NULL);
|
||||
struct ObjectBase *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
sub_0803E380(r4);
|
||||
@ -4182,7 +4182,7 @@ void sub_0810792C(void)
|
||||
|
||||
struct ObjectBase *sub_08107A48(struct Object2 *r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_08107BA8, sizeof(struct ObjectBase), 0x3500, 0x10, sub_0810A104);
|
||||
struct Task *t = TaskCreate(sub_08107BA8, sizeof(struct ObjectBase), 0x3500, TASK_USE_EWRAM, sub_0810A104);
|
||||
struct ObjectBase *r0, *r5 = TaskGetStructPtr(t, r0);
|
||||
|
||||
sub_0803E380(r0);
|
||||
@ -4270,7 +4270,7 @@ void sub_08107BA8(void)
|
||||
|
||||
void sub_08107ED4(struct Object2 *r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_08107FC4, sizeof(struct Object4), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_08107FC4, sizeof(struct Object4), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *r5 = TaskGetStructPtr(t, r5);
|
||||
|
||||
sub_0803E3B0(r5);
|
||||
@ -4328,7 +4328,7 @@ void sub_08107FC4(void)
|
||||
|
||||
void sub_08108280(struct Object2 *r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_08108368, sizeof(struct Object4), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_08108368, sizeof(struct Object4), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
sub_0803E3B0(r4);
|
||||
@ -4432,7 +4432,7 @@ void sub_08108368(void)
|
||||
|
||||
void sub_08108960(struct Object2 *r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_08108A50, sizeof(struct Object4), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_08108A50, sizeof(struct Object4), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *r5 = TaskGetStructPtr(t, r5);
|
||||
|
||||
sub_0803E3B0(r5);
|
||||
@ -4544,7 +4544,7 @@ void sub_08108A50(void)
|
||||
struct Object4 *sub_08109304(struct Object2 *sp10, u8 sp08)
|
||||
{
|
||||
u8 sp0C = 16;
|
||||
struct Task *t = TaskCreate(sub_081094C4, sizeof(struct Object9), 0x3501, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_081094C4, sizeof(struct Object9), 0x3501, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object9 *r0, *r5;
|
||||
struct Object4 *r4;
|
||||
u8 i;
|
||||
@ -5868,7 +5868,7 @@ void sub_0810B904(struct Task *task)
|
||||
|
||||
void *CreateDarkMindForm2(struct Object *r5, u8 r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_0810B1F4, sizeof(struct DarkMindForm2), 0xFFF, 0x10, sub_0810B904);
|
||||
struct Task *t = TaskCreate(sub_0810B1F4, sizeof(struct DarkMindForm2), 0xFFF, TASK_USE_EWRAM, sub_0810B904);
|
||||
struct DarkMindForm2 *r0 = TaskGetStructPtr(t, r0);
|
||||
struct DarkMindForm2 *r7 = r0;
|
||||
u16 v1;
|
||||
@ -7995,7 +7995,7 @@ void sub_0810F13C(struct DarkMindForm2 *r5)
|
||||
|
||||
void *sub_0810F320(struct Object *r6, u8 r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object12), 0xFFF, 0x10, sub_081147F0);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object12), 0xFFF, TASK_USE_EWRAM, sub_081147F0);
|
||||
struct Object12 *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
InitObject(&r4->unk0, r6, r5);
|
||||
@ -8929,7 +8929,7 @@ void sub_08111314(struct DarkMindForm2 *r5)
|
||||
|
||||
void *sub_081113EC(struct Object *r6, u8 r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r0, *r4 = TaskGetStructPtr(t, r0);
|
||||
|
||||
InitObject(r4, r6, r5);
|
||||
@ -9059,7 +9059,7 @@ void DarkMindForm2CreateLaserShower(struct DarkMindForm2 *r5)
|
||||
|
||||
void *sub_08111984(struct Object *r6, u8 r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r0, *r4 = TaskGetStructPtr(t, r0);
|
||||
|
||||
InitObject(r4, r6, r5);
|
||||
@ -9122,7 +9122,7 @@ void sub_08111AEC(struct Object2 *r4)
|
||||
|
||||
void sub_08111B88(struct Object2 *r5)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_08111C5C, sizeof(struct Object4), 0x1001, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_08111C5C, sizeof(struct Object4), 0x1001, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
sub_0803E3B0(r4);
|
||||
@ -9188,7 +9188,7 @@ void sub_08111C5C(void)
|
||||
struct Object4 *sub_08111EF4(struct DarkMindForm2 *r6)
|
||||
{
|
||||
struct DarkMindForm2 *r5 = r6;
|
||||
struct Task *t = TaskCreate(sub_08112024, sizeof(struct Object4), 0x3501, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_08112024, sizeof(struct Object4), 0x3501, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *r0, *r4 = TaskGetStructPtr(t, r0);
|
||||
|
||||
sub_0803E3B0(r4);
|
||||
@ -9259,7 +9259,7 @@ void sub_08112024(void)
|
||||
|
||||
struct Object4 *sub_081122A0(struct Object2 *r6, u8 sb)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_081123CC, sizeof(struct Object4), 0x3501, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_081123CC, sizeof(struct Object4), 0x3501, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *r0, *r4 = TaskGetStructPtr(t, r0);
|
||||
|
||||
sub_0803E3B0(r4);
|
||||
@ -9339,7 +9339,7 @@ void sub_081123CC(void)
|
||||
struct Object4 *sub_081126C0(struct DarkMindForm2 *sb, u8 sp08)
|
||||
{
|
||||
u8 sp0C = 40, i;
|
||||
struct Task *t = TaskCreate(sub_08112880, sizeof(struct Object13), 0x3501, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_08112880, sizeof(struct Object13), 0x3501, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object13 *r0 = TaskGetStructPtr(t, r0);
|
||||
struct Object4 *r6 = &r0->unk0;
|
||||
struct Object13 *r8 = r0;
|
||||
@ -9523,7 +9523,7 @@ void sub_08112D58(struct Object12 *r6)
|
||||
|
||||
void *CreateDarkMindMirrorCutter(struct Object *r6, u8 r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r5 = TaskGetStructPtr(t, r5);
|
||||
|
||||
InitObject(r5, r6, r4);
|
||||
@ -10450,7 +10450,7 @@ void sub_081147F0(struct Task *t)
|
||||
|
||||
void *CreateDarkMindTrigger(struct Object *r5, u8 r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct DarkMindTrigger), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct DarkMindTrigger), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct DarkMindTrigger *r6 = TaskGetStructPtr(t, r6);
|
||||
|
||||
InitObject(&r6->unk0, r5, r4);
|
||||
@ -11682,7 +11682,7 @@ void sub_08117A9C(struct DarkMindTrigger *r6, s16 a2, s16 a3, s8 a4, s8 a5)
|
||||
|
||||
void *sub_08117BBC(struct Object *r5, u8 r4)
|
||||
{
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r6 = TaskGetStructPtr(t, r6);
|
||||
|
||||
InitObject(r6, r5, r4);
|
||||
|
@ -31,7 +31,7 @@ static void sub_08025E00(UNUSED struct DemoStruct* arg0) {
|
||||
}
|
||||
|
||||
void CreateDemo(u16 arg0) {
|
||||
struct Task* task = TaskCreate(sub_08025F50, sizeof(struct DemoStruct), 1, 4, NULL);
|
||||
struct Task* task = TaskCreate(sub_08025F50, sizeof(struct DemoStruct), 1, TASK_x0004, NULL);
|
||||
struct DemoStruct* demo;
|
||||
TaskGetStructPtr(task, demo);
|
||||
CpuFill16(0, demo, sizeof(*demo));
|
||||
|
@ -21,7 +21,7 @@ extern const struct Unk_08354EEC gUnk_08354E98[];
|
||||
extern const struct Unk_08354EEC gUnk_08354EEC[];
|
||||
|
||||
void *CreateFoley(struct Object * r6, u8 r5) {
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
InitObject(r4, r6, r5);
|
||||
@ -134,7 +134,7 @@ static void sub_080C09E0(struct Object2 *r4) {
|
||||
}
|
||||
|
||||
void *CreateFoleyLeaves(struct Object *r6, u8 r5) {
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
InitObject(r4, r6, r5);
|
||||
|
@ -19,7 +19,7 @@ static void sub_080C059C(struct Object2 *);
|
||||
|
||||
void *CreateGiantRocky(struct Object *r5, u8 r4)
|
||||
{
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r0, *r6 = TaskGetStructPtr(task, r0);
|
||||
|
||||
InitObject(r6, r5, r4);
|
||||
@ -126,7 +126,7 @@ static void sub_080C00E0(struct Object2 *r5)
|
||||
|
||||
static void sub_080C0218(struct Object2 *r5)
|
||||
{
|
||||
struct Task *task = TaskCreate(sub_080C0320, sizeof(struct ObjectBase), 0x3500, 16, NULL);
|
||||
struct Task *task = TaskCreate(sub_080C0320, sizeof(struct ObjectBase), 0x3500, TASK_USE_EWRAM, NULL);
|
||||
struct ObjectBase *r0, *r4 = TaskGetStructPtr(task, r0);
|
||||
|
||||
sub_0803E380(r4);
|
||||
|
@ -10,7 +10,7 @@ static void GordoInitType3(struct Object2*);
|
||||
|
||||
void* CreateGordo(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x4000;
|
||||
|
@ -86,7 +86,7 @@ static void sub_080BFD0C(struct Object2*);
|
||||
static void sub_080BFD58(struct Object2*);
|
||||
|
||||
void* CreateHeavyKnight(struct Object* arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x800000;
|
||||
@ -481,7 +481,7 @@ static void sub_080BF414(struct Object2* arg0) {
|
||||
}
|
||||
|
||||
static void sub_080BF654(struct Object2* arg0) {
|
||||
struct Task *task = TaskCreate(sub_080BF7D0, sizeof(struct ObjectBase), 0x3500, 0x10, NULL);
|
||||
struct Task *task = TaskCreate(sub_080BF7D0, sizeof(struct ObjectBase), 0x3500, TASK_USE_EWRAM, NULL);
|
||||
struct ObjectBase *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
sub_0803E380(obj);
|
||||
obj->unk0 = 2;
|
||||
@ -549,7 +549,7 @@ static void sub_080BF7D0(void) {
|
||||
static void sub_080BF914(struct Object2* arg0) {
|
||||
register struct ObjectBase *obj2, *obj;
|
||||
u32 flags;
|
||||
struct Task *task = TaskCreate(sub_080BF9EC, sizeof(struct ObjectBase), 0x3500, 0x10, NULL);
|
||||
struct Task *task = TaskCreate(sub_080BF9EC, sizeof(struct ObjectBase), 0x3500, TASK_USE_EWRAM, NULL);
|
||||
TaskGetStructPtr(task, obj2);
|
||||
if (task) obj = obj2;
|
||||
obj = obj2;
|
||||
|
@ -13,7 +13,7 @@ static void sub_080B2CAC(struct Object2*);
|
||||
|
||||
void* CreateLaserBall(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x140;
|
||||
@ -263,7 +263,7 @@ static void sub_080B2710(struct Object2* arg0) {
|
||||
}
|
||||
|
||||
static void sub_080B2780(struct Object2* arg0) {
|
||||
struct Task *task = TaskCreate(sub_08070580, sizeof(struct Laser), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *task = TaskCreate(sub_08070580, sizeof(struct Laser), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Laser *laser2, *laser = TaskGetStructPtr(task, laser2);
|
||||
sub_0803E380(&laser->base);
|
||||
laser->base.unk0 = 2;
|
||||
|
@ -178,7 +178,7 @@ void GameInit(void) {
|
||||
m4aSoundMode(SOUND_MODE_DA_BIT_8 | SOUND_MODE_FREQ_15768 | (15 << SOUND_MODE_MASVOL_SHIFT) | (10 << SOUND_MODE_MAXCHN_SHIFT));
|
||||
m4aSoundMain();
|
||||
gExecSoundMain = TRUE;
|
||||
TaskInit();
|
||||
TasksInit();
|
||||
EwramInitHeap();
|
||||
gUnk_03002488 = 0x400;
|
||||
gUnk_03002540 = 0x06010000;
|
||||
@ -232,7 +232,7 @@ void GameLoop(void) {
|
||||
}
|
||||
|
||||
if (!(gUnk_020382D0.unk4 & 4)) {
|
||||
TaskExecute();
|
||||
TasksExec();
|
||||
}
|
||||
else {
|
||||
gUnk_030035D4 = 0;
|
||||
|
@ -66,7 +66,7 @@ static u32 sub_080BE2C4(struct MetalGuardianLaser*);
|
||||
|
||||
void* CreateMetalGuardian(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
@ -212,7 +212,7 @@ static void sub_080BDA00(struct Object2* arg0) {
|
||||
|
||||
static void sub_080BDA70(struct Object2* arg0, u8 arg1) {
|
||||
struct MetalGuardianLaser *laser, *laser2;
|
||||
struct Task *task = TaskCreate(sub_08070580, sizeof(struct MetalGuardianLaser), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *task = TaskCreate(sub_08070580, sizeof(struct MetalGuardianLaser), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
laser = TaskGetStructPtr(task, laser2);
|
||||
sub_0803E380(&laser->base);
|
||||
laser->base.unk0 = 2;
|
||||
@ -299,7 +299,7 @@ static void sub_080BDE7C(struct Object2* arg0) {
|
||||
struct Sprite *sprite;
|
||||
u8 arg2;
|
||||
struct MetalGuardianLaser *laser, *laser2;
|
||||
struct Task *task = TaskCreate(sub_08070580, sizeof(struct MetalGuardianLaser), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *task = TaskCreate(sub_08070580, sizeof(struct MetalGuardianLaser), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
laser = TaskGetStructPtr(task, laser2);
|
||||
sub_0803E380(&laser->base);
|
||||
laser->base.unk0 = 2;
|
||||
|
@ -7,7 +7,7 @@ static void MinnySubtype1Start(struct Object2*);
|
||||
static void MinnyTurnAround(struct Object2*);
|
||||
|
||||
void* CreateMinny(struct Object* arg0, u8 arg1) {
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
|
@ -10,7 +10,7 @@ static void sub_080B1254(struct Object2*);
|
||||
|
||||
void* CreateMirra(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x3064, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x3064, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.flags |= 0x2000000;
|
||||
|
@ -313,7 +313,7 @@ static void *const gUnk_082DE308[][9] =
|
||||
|
||||
struct Multi_08019F28 *sub_08019F28(s32 r7)
|
||||
{
|
||||
struct Task *r5 = TaskCreate(sub_0801A798, sizeof(struct Multi_08019F28), -2, 4, sub_0801A7CC);
|
||||
struct Task *r5 = TaskCreate(sub_0801A798, sizeof(struct Multi_08019F28), -2, TASK_x0004, sub_0801A7CC);
|
||||
struct Multi_08019F28 *r6;
|
||||
|
||||
TaskGetStructPtr(r5, r6);
|
||||
|
@ -1306,7 +1306,7 @@ static void sub_08032A80(void)
|
||||
|
||||
struct Multi_08032B0C *sub_08032B0C(void)
|
||||
{
|
||||
struct Task *t = TaskCreate(sub_08031D24, sizeof(struct Multi_08032B0C), 0xFFFE, 4, NULL);
|
||||
struct Task *t = TaskCreate(sub_08031D24, sizeof(struct Multi_08032B0C), 0xFFFE, TASK_x0004, NULL);
|
||||
struct Multi_08032B0C *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
CpuFill16(0, r4, sizeof(*r4));
|
||||
|
@ -15,7 +15,7 @@ static void sub_080C2994(struct Object2 *);
|
||||
static void sub_080C29A4(struct Object2 *);
|
||||
|
||||
void *CreateNoddy(struct Object *r6, u8 r4) {
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r0, *r5 = TaskGetStructPtr(t, r0);
|
||||
|
||||
InitObject(r5, r6, r4);
|
||||
@ -82,7 +82,7 @@ static void sub_080C23B0(struct Object2 *r4) {
|
||||
}
|
||||
|
||||
static void sub_080C2438(struct Object2 *r6) {
|
||||
struct Task *t = TaskCreate(sub_080C25CC, sizeof(struct Object4), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *t = TaskCreate(sub_080C25CC, sizeof(struct Object4), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *r0, *r4 = TaskGetStructPtr(t, r0);
|
||||
|
||||
sub_0803E3B0(r4);
|
||||
|
@ -25,7 +25,7 @@ void sub_080C29C0(struct Object2 *r5, u8 r8) {
|
||||
}
|
||||
|
||||
void *CreateParasol(struct Object *r6, u8 r5) {
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1001, 0x10, ObjectDestroy);
|
||||
struct Task *t = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1001, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *r4 = TaskGetStructPtr(t, r4);
|
||||
|
||||
InitObject(r4, r6, r5);
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "pause_fade.h"
|
||||
|
||||
void CreatePauseFade(s8 arg0, u32 arg1) {
|
||||
struct Task* task = TaskCreate(PauseFadeMain, sizeof(struct PauseFadeStruct), 0x100, 4, NULL);
|
||||
struct Task* task = TaskCreate(PauseFadeMain, sizeof(struct PauseFadeStruct), 0x100, TASK_x0004, NULL);
|
||||
struct PauseFadeStruct *fade, *fade2;
|
||||
|
||||
fade2 = TaskGetStructPtr(task, fade);
|
||||
@ -30,7 +30,7 @@ void CreatePauseFade(s8 arg0, u32 arg1) {
|
||||
}
|
||||
|
||||
void CreatePauseFadeSetBldCnt(s8 arg0, u32 arg1) {
|
||||
struct Task* task = TaskCreate(PauseFadeMain, sizeof(struct PauseFadeStruct), 0x100, 4, NULL);
|
||||
struct Task* task = TaskCreate(PauseFadeMain, sizeof(struct PauseFadeStruct), 0x100, TASK_x0004, NULL);
|
||||
struct PauseFadeStruct *fade, *fade2;
|
||||
|
||||
fade2 = TaskGetStructPtr(task, fade);
|
||||
|
@ -104,7 +104,7 @@ static void sub_080BBCD8(struct Object2*);
|
||||
static void sub_080BBD14(struct Object2*);
|
||||
|
||||
void* CreatePengy(struct Object* arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
@ -279,7 +279,7 @@ static void sub_080BAFBC(struct Object2* arg0) {
|
||||
}
|
||||
|
||||
void sub_080BB080(struct Object2* arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(sub_080BB290, sizeof(struct ObjectBase), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *task = TaskCreate(sub_080BB290, sizeof(struct ObjectBase), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct ObjectBase *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
sub_0803E380(obj);
|
||||
obj->unk0 = 2;
|
||||
@ -351,7 +351,7 @@ static void sub_080BB290(void) {
|
||||
}
|
||||
|
||||
void sub_080BB470(struct Object2* arg0) {
|
||||
struct Task *task = TaskCreate(sub_080BB568, sizeof(struct Object4), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *task = TaskCreate(sub_080BB568, sizeof(struct Object4), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
sub_0803E3B0(obj);
|
||||
obj->unk0 = 3;
|
||||
@ -430,7 +430,7 @@ static void sub_080BB568(void) {
|
||||
}
|
||||
|
||||
void sub_080BB804(struct Object2* arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(sub_080BB8FC, sizeof(struct Object4), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *task = TaskCreate(sub_080BB8FC, sizeof(struct Object4), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct Object4 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
sub_0803E3B0(obj);
|
||||
obj->unk0 = 3;
|
||||
|
@ -32,7 +32,7 @@ static void sub_080BE9D8(struct Object2*);
|
||||
static void sub_080BE9FC(struct Object2*);
|
||||
|
||||
void *CreateRocky(struct Object* arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
|
||||
InitObject(obj, arg0, arg1);
|
||||
|
@ -11,7 +11,7 @@ static void sub_080A81C4(struct Object2*);
|
||||
|
||||
void* CreateScarfy(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
|
@ -12,7 +12,7 @@ static void sub_080C4300(struct Object2*);
|
||||
|
||||
void* CreateSparky(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
obj->base.y -= 0x100;
|
||||
|
@ -71,7 +71,7 @@ void sub_0815604C(struct Sprite *sb) {
|
||||
sb->unk1D = gUnk_030024F0;
|
||||
for (sp0C = 0; sp0C < r8.sub->unk2; ++sp0C) {
|
||||
r4 = sub_08156D84((sb->unk14 & 0x7C0) >> 6);
|
||||
if (gUnk_03006CC4 == r4) return;
|
||||
if (iwram_end == r4) return;
|
||||
DmaCopy16(3, &sp10[3 * ((r8.sub->unk0 & 0x3FFF) + sp0C)], r4, 6);
|
||||
r7 = r4->all.attr1 & 0x1FF;
|
||||
r5 = r4->all.attr0 & 0xFF;
|
||||
@ -276,7 +276,7 @@ void sub_081564D8(struct Sprite *sl) {
|
||||
p->all.attr2 += p->all.attr2 & 0x3FF;
|
||||
p->all.attr2 += (sl->unk0 - 0x6010000u) >> 5;
|
||||
r1_ = sub_08156D84((sl->unk14 & 0x7C0) >> 6);
|
||||
if (gUnk_03006CC4 == r1_) return;
|
||||
if (iwram_end == r1_) return;
|
||||
DmaCopy16(3, sp00, r1_, 6);
|
||||
}
|
||||
}
|
||||
@ -386,7 +386,7 @@ void sub_081569A0(struct Sprite *sb, u16 *sp08, u8 sp0C) {
|
||||
const u16 *r4 = gUnk_03003674->unk8[sb->unkC];
|
||||
OamData *r6 = sub_08156D84((sb->unk14 & 0x7C0) >> 6);
|
||||
|
||||
if (gUnk_03006CC4 == r6) return;
|
||||
if (iwram_end == r6) return;
|
||||
DmaCopy16(3, &r4[3 * ((sl.sub->unk0 & 0x3FFF) + sp18)], r6, 6); // excluding affine params
|
||||
sp1C = r6->all.attr1 & 0x1FF;
|
||||
sp20 = r6->all.attr0 & 0xFF;
|
||||
@ -430,7 +430,7 @@ void sub_081569A0(struct Sprite *sb, u16 *sp08, u8 sp0C) {
|
||||
for (i = 0; i < sp0C; ++i) {
|
||||
OamData *r5 = sub_08156D84((sb->unk14 & 0x7C0) >> 6);
|
||||
|
||||
if (gUnk_03006CC4 == r6) return;
|
||||
if (iwram_end == r6) return;
|
||||
DmaCopy16(3, r6, r5, 6);
|
||||
r5->all.attr1 &= 0xFE00;
|
||||
r5->all.attr0 &= 0xFF00;
|
||||
@ -445,7 +445,7 @@ void sub_081569A0(struct Sprite *sb, u16 *sp08, u8 sp0C) {
|
||||
OamData *sub_08156D84(u8 r5) {
|
||||
if (r5 > 0x1f) r5 = 0x1f;
|
||||
if ((s8)gUnk_030024F0 < 0) {
|
||||
return gUnk_03006CC4;
|
||||
return iwram_end;
|
||||
}
|
||||
else {
|
||||
if (gUnk_03002450[r5] == 0xff) {
|
||||
|
446
src/task.c
446
src/task.c
@ -5,174 +5,175 @@
|
||||
#include "malloc_ewram.h"
|
||||
#include "gba/m4a.h"
|
||||
|
||||
static void nullsub_143(void);
|
||||
static void nullsub_144(void);
|
||||
static void nullsub_145(void);
|
||||
static void IwramFree(struct Unk_03003A20* arg0);
|
||||
static void TaskMainDummy(void);
|
||||
static void TaskMainDummy2(void);
|
||||
static void TaskMainDummy3(void);
|
||||
static void IwramFree(void *);
|
||||
static struct Task* TaskGetNextSlot(void);
|
||||
|
||||
u32 TaskInit(void) {
|
||||
struct Task *r2, *r4;
|
||||
u32 TasksInit(void) {
|
||||
struct Task* cur;
|
||||
s32 i;
|
||||
gCurTask = NULL;
|
||||
gNextTask = NULL;
|
||||
gLastTaskNum = 0;
|
||||
gUnk_03002E98 = NULL;
|
||||
DmaFill32(3, 0, gUnk_030019F0, 0x200);
|
||||
gNumTasks = 0;
|
||||
gNextTaskToCheckForDestruction = NULL;
|
||||
DmaFill32(3, 0, gTasks, 0x200); // really no idea why it's 0x200...
|
||||
// 3001BF0 (gTasks+0x200) is referenced only in multi-boot programs
|
||||
|
||||
for (i = 0; i < 0x80; ++i)
|
||||
gTaskList[i] = &gUnk_030019F0[i];
|
||||
for (i = 0; i < MAX_TASK_NUM; ++i)
|
||||
gTaskPtrs[i] = &gTasks[i];
|
||||
|
||||
r4 = TaskGetNextSlot();
|
||||
if (!r4) {
|
||||
cur = TaskGetNextSlot();
|
||||
if (!cur) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r4->main = nullsub_143;
|
||||
r4->unk10 = 0;
|
||||
r4->flags = 0;
|
||||
r4->unk0 = 0;
|
||||
r4->unk2 = 0;
|
||||
r4->next = (uintptr_t)TaskGetNextSlot();
|
||||
cur->main = TaskMainDummy;
|
||||
cur->priority = 0;
|
||||
cur->flags = 0;
|
||||
cur->parent = 0;
|
||||
cur->prev = 0;
|
||||
cur->next = (uintptr_t)TaskGetNextSlot();
|
||||
|
||||
if ((r4->next + IWRAM_START) == IWRAM_START) {
|
||||
if ((cur->next + IWRAM_START) == IWRAM_START) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
((struct Task*)(r4->next + IWRAM_START))->unk2 = (u32)r4;
|
||||
r4 = (struct Task*)(r4->next + IWRAM_START);
|
||||
r4->main = nullsub_144;
|
||||
r4->unk10 = 0xffff;
|
||||
r4->flags = 0;
|
||||
r4->unk0 = 0;
|
||||
r4->next = 0;
|
||||
gEmptyTask.unk0 = 0;
|
||||
gEmptyTask.unk2 = 0;
|
||||
((struct Task*)(cur->next + IWRAM_START))->prev = (u32)cur;
|
||||
cur = (struct Task*)(cur->next + IWRAM_START);
|
||||
cur->main = TaskMainDummy2;
|
||||
cur->priority = 0xffff;
|
||||
cur->flags = 0;
|
||||
cur->parent = 0;
|
||||
cur->next = 0;
|
||||
gEmptyTask.parent = 0;
|
||||
gEmptyTask.prev = 0;
|
||||
gEmptyTask.next = 0;
|
||||
gEmptyTask.structOffset = (uintptr_t)gUnk_03006CC4;
|
||||
gUnk_03003A20[0].unk0 = 0;
|
||||
gUnk_03003A20[0].unk2 = 0x2604;
|
||||
gEmptyTask.structOffset = (uintptr_t)iwram_end;
|
||||
// initialize IWRAM heap -- a huge node
|
||||
gIwramHeap.next = 0;
|
||||
gIwramHeap.state = 0x2604;
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct Task* TaskCreate(TaskMain taskMain, u16 structSize, u16 arg2, u16 flags, TaskDestructor taskDestructor) {
|
||||
struct Task* TaskCreate(TaskMain taskMain, u16 structSize, u16 priority, u16 flags, TaskDestructor taskDestructor) {
|
||||
struct Task* slow;
|
||||
struct Task* r4;
|
||||
struct Task* task;
|
||||
u16 fast;
|
||||
struct EwramNode* r1;
|
||||
struct EwramNode* temp;
|
||||
|
||||
do ; while (0);
|
||||
r4 = NULL;
|
||||
task = NULL;
|
||||
slow = NULL;
|
||||
|
||||
if (gLastTaskNum <= 0x7f) {
|
||||
struct Task* nextSlot = gTaskList[gLastTaskNum++];
|
||||
r4 = nextSlot;
|
||||
if (gNumTasks < MAX_TASK_NUM) {
|
||||
struct Task* nextSlot = gTaskPtrs[gNumTasks++];
|
||||
task = nextSlot;
|
||||
}
|
||||
|
||||
if (r4 == NULL) {
|
||||
if (task == NULL) {
|
||||
return &gEmptyTask;
|
||||
}
|
||||
|
||||
r4->main = taskMain;
|
||||
r4->dtor = taskDestructor;
|
||||
r4->unk10 = arg2;
|
||||
r4->flags = flags;
|
||||
task->main = taskMain;
|
||||
task->dtor = taskDestructor;
|
||||
task->priority = priority;
|
||||
task->flags = flags;
|
||||
|
||||
if (flags & 0x10) {
|
||||
if (flags & TASK_USE_EWRAM) {
|
||||
if (structSize == 0) {
|
||||
r4->structOffset = 0;
|
||||
task->structOffset = 0;
|
||||
}
|
||||
else {
|
||||
r4->structOffset = ((uintptr_t)EwramMalloc(structSize) - EWRAM_START) >> 2;
|
||||
task->structOffset = ((uintptr_t)EwramMalloc(structSize) - EWRAM_START) >> 2;
|
||||
}
|
||||
|
||||
if (gUnk_0203ADE4 == TaskGetStructPtr(r4, r1)) {
|
||||
r4->flags &= ~0x10;
|
||||
r4->structOffset = (uintptr_t)IwramMalloc(structSize);
|
||||
if (gUnk_0203ADE4 == TaskGetStructPtr(task, temp)) {
|
||||
task->flags &= ~TASK_USE_EWRAM;
|
||||
task->structOffset = (uintptr_t)IwramMalloc(structSize);
|
||||
}
|
||||
}
|
||||
else {
|
||||
r4->structOffset = (uintptr_t)IwramMalloc(structSize);
|
||||
if ((structSize != 0) && (r4->structOffset == 0)) {
|
||||
r4->flags |= 0x10;
|
||||
r4->structOffset = ((uintptr_t)EwramMalloc(structSize) - EWRAM_START) >> 2;
|
||||
task->structOffset = (uintptr_t)IwramMalloc(structSize);
|
||||
if ((structSize != 0) && (task->structOffset == 0)) {
|
||||
task->flags |= TASK_USE_EWRAM;
|
||||
task->structOffset = ((uintptr_t)EwramMalloc(structSize) - EWRAM_START) >> 2;
|
||||
}
|
||||
}
|
||||
|
||||
r4->unk0 = (uintptr_t)gCurTask;
|
||||
slow = gTaskList[0];
|
||||
fast = slow->next;
|
||||
task->parent = (uintptr_t)gCurTask;
|
||||
|
||||
// insert the task
|
||||
slow = gTaskPtrs[0];
|
||||
fast = slow->next;
|
||||
while ((fast + IWRAM_START) != IWRAM_START) {
|
||||
if (((struct Task*)(fast + IWRAM_START))->unk10 > arg2) {
|
||||
((struct Task*)(fast + IWRAM_START))->unk2 = (uintptr_t)r4;
|
||||
r4->next = slow->next;
|
||||
r4->unk2 = (uintptr_t)slow;
|
||||
slow->next = (uintptr_t)r4;
|
||||
if (slow->next == gNextTask->unk2) {
|
||||
gNextTask = r4;
|
||||
if (((struct Task*)(fast + IWRAM_START))->priority > priority) {
|
||||
((struct Task*)(fast + IWRAM_START))->prev = (uintptr_t)task;
|
||||
task->next = slow->next;
|
||||
task->prev = (uintptr_t)slow;
|
||||
slow->next = (uintptr_t)task;
|
||||
if (slow->next == gNextTask->prev) {
|
||||
gNextTask = task;
|
||||
}
|
||||
break;
|
||||
}
|
||||
slow = (struct Task*)(fast + IWRAM_START);
|
||||
fast = ((struct Task*)(fast + IWRAM_START))->next;
|
||||
}
|
||||
return r4;
|
||||
return task;
|
||||
}
|
||||
|
||||
void TaskDestroy(struct Task* task) {
|
||||
u32 r0, r1;
|
||||
if (!(task->flags & 2)) {
|
||||
r1 = task->unk2 + IWRAM_START;
|
||||
r0 = task->next + IWRAM_START;
|
||||
if (r1 != IWRAM_START) {
|
||||
if (r0 != IWRAM_START) {
|
||||
if (task->dtor != NULL) {
|
||||
task->dtor(task);
|
||||
}
|
||||
|
||||
if (task == gNextTask) {
|
||||
gNextTask = (struct Task*)(task->next + IWRAM_START);
|
||||
}
|
||||
|
||||
if (task == gUnk_03002E98) {
|
||||
gUnk_03002E98 = (struct Task*)(task->next + IWRAM_START);
|
||||
}
|
||||
|
||||
r1 = task->unk2 + IWRAM_START;
|
||||
r0 = task->next + IWRAM_START;
|
||||
((struct Task*)r1)->next = r0;
|
||||
((struct Task*)r0)->unk2 = r1;
|
||||
|
||||
if (task->structOffset != 0) {
|
||||
if (task->flags & 0x10) {
|
||||
EwramFree(task->structOffset + (u32*)EWRAM_START);
|
||||
}
|
||||
else {
|
||||
IwramFree(task->structOffset + (void*)IWRAM_START);
|
||||
}
|
||||
}
|
||||
|
||||
gTaskList[--gLastTaskNum] = task;
|
||||
task->unk0 = 0;
|
||||
task->unk2 = 0;
|
||||
task->main = nullsub_145;
|
||||
task->unk10 = 0;
|
||||
task->flags = 0;
|
||||
task->structOffset = 0;
|
||||
u32 next, prev;
|
||||
if (!(task->flags & TASK_DESTROY_DISABLED)) {
|
||||
prev = task->prev + IWRAM_START;
|
||||
next = task->next + IWRAM_START;
|
||||
if (prev != IWRAM_START && next != IWRAM_START) {
|
||||
if (task->dtor != NULL) {
|
||||
task->dtor(task);
|
||||
}
|
||||
|
||||
if (task == gNextTask) {
|
||||
gNextTask = (struct Task*)(task->next + IWRAM_START);
|
||||
}
|
||||
|
||||
// can only happen in (implicitly) recursive TaskDestroy calls (from task->dtor) in TasksDestroyInPriorityRange
|
||||
if (task == gNextTaskToCheckForDestruction) {
|
||||
gNextTaskToCheckForDestruction = (struct Task*)(task->next + IWRAM_START);
|
||||
}
|
||||
|
||||
prev = task->prev + IWRAM_START;
|
||||
next = task->next + IWRAM_START;
|
||||
((struct Task*)prev)->next = next;
|
||||
((struct Task*)next)->prev = prev;
|
||||
|
||||
if (task->structOffset != 0) {
|
||||
if (task->flags & TASK_USE_EWRAM) {
|
||||
EwramFree(task->structOffset + (u32*)EWRAM_START);
|
||||
}
|
||||
else {
|
||||
IwramFree(task->structOffset + (void*)IWRAM_START);
|
||||
}
|
||||
}
|
||||
gTaskPtrs[--gNumTasks] = task;
|
||||
task->parent = 0;
|
||||
task->prev = 0;
|
||||
task->main = TaskMainDummy3;
|
||||
task->priority = 0;
|
||||
task->flags = 0;
|
||||
task->structOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskExecute(void) {
|
||||
gCurTask = gTaskList[0];
|
||||
if (!(gUnk_03002440 & 0x800) && (gTaskList[0] != (struct Task*)IWRAM_START)) {
|
||||
void TasksExec(void) {
|
||||
gCurTask = gTaskPtrs[0];
|
||||
if (!(gUnk_03002440 & 0x800) && (gTaskPtrs[0] != (struct Task*)IWRAM_START)) {
|
||||
while (gCurTask != (struct Task*)IWRAM_START) {
|
||||
gNextTask = (struct Task*)(IWRAM_START + gCurTask->next);
|
||||
|
||||
if (!(gCurTask->flags & 1)) {
|
||||
if (!(gCurTask->flags & TASK_INACTIVE)) {
|
||||
gCurTask->main();
|
||||
}
|
||||
|
||||
@ -185,11 +186,11 @@ void TaskExecute(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gTaskList[0] != (struct Task*)IWRAM_START) {
|
||||
else if (gTaskPtrs[0] != (struct Task*)IWRAM_START) {
|
||||
while (gCurTask != (struct Task*)IWRAM_START) {
|
||||
gNextTask = (struct Task*)(IWRAM_START + gCurTask->next);
|
||||
|
||||
if ((gCurTask->flags & 4) && !(gCurTask->flags & 1)) {
|
||||
if ((gCurTask->flags & TASK_x0004) && !(gCurTask->flags & TASK_INACTIVE)) {
|
||||
gCurTask->main();
|
||||
}
|
||||
|
||||
@ -204,193 +205,190 @@ void TaskExecute(void) {
|
||||
gNextTask = NULL;
|
||||
}
|
||||
|
||||
struct Unk_03003A20* IwramMalloc(u16 size) {
|
||||
struct Unk_03003A20 *r3, *r1;
|
||||
s16 r0;
|
||||
u16 r2 = size;
|
||||
r2 = (r2 + 3) >> 2;
|
||||
if (r2 == 0) {
|
||||
struct IwramNode* IwramMalloc(u16 req) {
|
||||
struct IwramNode *cur, *next;
|
||||
u16 size = req;
|
||||
size = (size + 3) >> 2;
|
||||
if (size == 0) {
|
||||
return NULL;
|
||||
}
|
||||
r2 = (r2 << 2) + 4;
|
||||
r3 = gUnk_03003A20;
|
||||
do {
|
||||
r0 = r2;
|
||||
if (r0 <= r3->unk2) {
|
||||
if (r0 != r3->unk2) {
|
||||
r0 = r2 + 4;
|
||||
if (r0 > r3->unk2) {
|
||||
if ((r3->unk0 + IWRAM_START) == IWRAM_START) {
|
||||
size = (size << 2) + 4;
|
||||
cur = &gIwramHeap;
|
||||
while (1) {
|
||||
s16 sizeSigned = size;
|
||||
if (sizeSigned <= cur->state) {
|
||||
if (sizeSigned != cur->state) {
|
||||
s16 offset = size + 4; // space field in the anticipated next node
|
||||
if (offset > cur->state) {
|
||||
if ((cur->next + IWRAM_START) == IWRAM_START) {
|
||||
return NULL;
|
||||
}
|
||||
r3 = (struct Unk_03003A20*)(r3->unk0 + IWRAM_START);
|
||||
cur = (struct IwramNode*)(cur->next + IWRAM_START);
|
||||
continue;
|
||||
}
|
||||
r1 = (struct Unk_03003A20*)((u8*)r3 + r2);
|
||||
r1->unk0 = r3->unk0;
|
||||
r1->unk2 = r3->unk2 - r2;
|
||||
r3->unk0 = (u32)r1;
|
||||
// shrink the original node
|
||||
next = (struct IwramNode*)((u8*)cur + size);
|
||||
next->next = cur->next;
|
||||
next->state = cur->state - size;
|
||||
cur->next = (uintptr_t)next;
|
||||
}
|
||||
r3->unk2 = -r2;
|
||||
return r3->space;
|
||||
cur->state = -size;
|
||||
return cur->space;
|
||||
}
|
||||
if ((r3->unk0 + IWRAM_START) == IWRAM_START) {
|
||||
if ((cur->next + IWRAM_START) == IWRAM_START) {
|
||||
return NULL;
|
||||
}
|
||||
r3 = (struct Unk_03003A20*)(r3->unk0 + IWRAM_START);
|
||||
} while (1);
|
||||
cur = (struct IwramNode*)(cur->next + IWRAM_START);
|
||||
}
|
||||
}
|
||||
|
||||
static void IwramFree(struct Unk_03003A20* p) {
|
||||
struct Unk_03003A20* r2 = p, *r3;
|
||||
static void IwramFree(void* p) {
|
||||
struct IwramNode* node = p, *fast;
|
||||
#ifndef NONMATCHING
|
||||
register struct Unk_03003A20* r1 asm("r1");
|
||||
register struct IwramNode* slow asm("r1");
|
||||
#else
|
||||
struct Unk_03003A20* r1;
|
||||
struct IwramNode* slow;
|
||||
#endif
|
||||
r2 -= 1;
|
||||
r1 = gUnk_03003A20;
|
||||
r3 = r1;
|
||||
|
||||
if (r2 != r1) {
|
||||
--node; // get node address from p
|
||||
fast = slow = &gIwramHeap;
|
||||
if (node != slow) {
|
||||
do {
|
||||
r1 = r3;
|
||||
r3 = (struct Unk_03003A20*)(IWRAM_START + r1->unk0);
|
||||
} while (r2 != r3);
|
||||
slow = fast;
|
||||
fast = (struct IwramNode*)(IWRAM_START + slow->next);
|
||||
} while (node != fast);
|
||||
}
|
||||
if (r2->unk2 < 0) {
|
||||
r2->unk2 = -r2->unk2;
|
||||
if (node->state < 0) {
|
||||
node->state = -node->state;
|
||||
}
|
||||
if ((struct Unk_03003A20*)(r1->unk2 + (u8*)r1) == r2) {
|
||||
u16 r4 = r1->unk2; // not actual code. only for handling side effect of inline asm
|
||||
if (r1->unk2 > 0) {
|
||||
r1->unk0 = r3->unk0;
|
||||
r1->unk2 = r4 + r2->unk2;
|
||||
r2 = r1;
|
||||
if ((struct IwramNode*)(slow->state + (u8*)slow) == node) {
|
||||
u16 state = slow->state; // not actual code. only for handling side effect of inline asm
|
||||
if (slow->state > 0) {
|
||||
slow->next = fast->next;
|
||||
slow->state = state + node->state;
|
||||
node = slow;
|
||||
}
|
||||
}
|
||||
r3 = (struct Unk_03003A20*)((u8*)r2 + r2->unk2);
|
||||
if (r3 == (struct Unk_03003A20*)(IWRAM_START + r2->unk0)) {
|
||||
if (r3->unk2 > 0) {
|
||||
r2->unk2 += r3->unk2;
|
||||
r2->unk0 = r3->unk0;
|
||||
fast = (struct IwramNode*)((u8*)node + node->state);
|
||||
if (fast == (struct IwramNode*)(IWRAM_START + node->next)) {
|
||||
if (fast->state > 0) {
|
||||
node->state += fast->state;
|
||||
node->next = fast->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The function is probably for cleaning up the IWRAM nodes, but it's not working. */
|
||||
static void sub_08152EBC(void) {
|
||||
struct Unk_03003A20* r2 = &gUnk_03003A20[0];
|
||||
s32 r7;
|
||||
s32 r3;
|
||||
u16 r1;
|
||||
u32* r5;
|
||||
u32* r6;
|
||||
struct IwramNode* cur = &gIwramHeap;
|
||||
s32 curStateBackup;
|
||||
s32 i;
|
||||
u16 nextNodeOffset;
|
||||
u8* nextNodeSpace;
|
||||
u8* space;
|
||||
|
||||
while ((r2->unk0 + IWRAM_START) != IWRAM_START) {
|
||||
if (r2->unk2 >= 0) {
|
||||
r2->unk0 += 0; // load again pls
|
||||
r1 = r2->unk0;
|
||||
if (((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk2 >= 0) {
|
||||
r2->unk2 += ((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk2;
|
||||
r2->unk0 = ((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk0;
|
||||
while ((cur->next + IWRAM_START) != IWRAM_START) {
|
||||
if (cur->state >= 0) {
|
||||
cur->next += 0; // load again pls
|
||||
nextNodeOffset = cur->next;
|
||||
if (((struct IwramNode*)(cur->next + IWRAM_START))->state >= 0) {
|
||||
cur->state += ((struct IwramNode*)(cur->next + IWRAM_START))->state;
|
||||
cur->next = ((struct IwramNode*)(cur->next + IWRAM_START))->next;
|
||||
}
|
||||
else {
|
||||
r5 = r2->unk0 + (void*)(IWRAM_START + 4);
|
||||
r6 = (void*)r2 + 4;
|
||||
r7 = r2->unk2;
|
||||
r2->unk2 = ((struct Unk_03003A20*)(r2->unk0 + IWRAM_START))->unk2;
|
||||
++r1; --r1; // why do you insist on loading here?
|
||||
r2->unk0 = ((struct Unk_03003A20*)(r1 + IWRAM_START))->unk0;
|
||||
for (r3 = 0; r3 <= 0x7f; r3++) {
|
||||
if (gUnk_030019F0[r3].structOffset == (u16)r5) {
|
||||
gUnk_030019F0[r3].structOffset = (u32)r6;
|
||||
nextNodeSpace = (void*)(cur->next + (IWRAM_START + 4));
|
||||
space = (void*)cur + 4;
|
||||
curStateBackup = cur->state;
|
||||
cur->state = ((struct IwramNode*)(cur->next + IWRAM_START))->state;
|
||||
++nextNodeOffset; --nextNodeOffset; // why do you insist on loading here?
|
||||
cur->next = ((struct IwramNode*)(nextNodeOffset + IWRAM_START))->next;
|
||||
for (i = 0; i < MAX_TASK_NUM; i++) {
|
||||
if (gTasks[i].structOffset == (u16)nextNodeSpace) {
|
||||
gTasks[i].structOffset = (u32)space;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DmaCopy32(3, r5, r6, r2->unk2 + 4u);
|
||||
DmaCopy32(3, nextNodeSpace, space, cur->state + 4u);
|
||||
{
|
||||
struct Unk_03003A20* r1 = (void*)r2 + r2->unk2;
|
||||
r1->unk0 = r2->unk0;
|
||||
r1->unk2 = r7;
|
||||
r2 = r1;
|
||||
r2->unk0 = (u32)r2;
|
||||
struct IwramNode* newLoc = (void*)cur + cur->state;
|
||||
newLoc->next = cur->next;
|
||||
newLoc->state = curStateBackup;
|
||||
cur = newLoc;
|
||||
cur->next = (u32)cur; // will cause inf loop
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
r2 = (struct Unk_03003A20*)(r2->unk0 + IWRAM_START);
|
||||
cur = (struct IwramNode*)(cur->next + IWRAM_START);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct Task* TaskGetNextSlot(void) {
|
||||
if (gLastTaskNum > 0x7f) {
|
||||
if (gNumTasks >= MAX_TASK_NUM) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
return gTaskList[gLastTaskNum++];
|
||||
return gTaskPtrs[gNumTasks++];
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08152FB0(u16 arg0, u16 arg1) {
|
||||
struct Task* r2;
|
||||
u32 r0;
|
||||
r2 = gTaskList[0];
|
||||
r0 = (u16)r2;
|
||||
void TasksDestroyInPriorityRange(u16 lbound, u16 rbound) {
|
||||
struct Task* cur = gTaskPtrs[0];
|
||||
u32 curOffset = (u16)cur;
|
||||
#ifndef NONMATCHING
|
||||
asm("":::"r5");
|
||||
#endif
|
||||
while (r0 != 0) {
|
||||
if (r2->unk10 >= arg0) {
|
||||
arg0 = 0;
|
||||
while (r2->unk10 < arg1) {
|
||||
gUnk_03002E98 = (struct Task*)(r2->next + (IWRAM_START));
|
||||
if (r2 != gTaskList[0] && r2 != gTaskList[1]) {
|
||||
TaskDestroy(r2);
|
||||
while (curOffset != 0) {
|
||||
if (cur->priority >= lbound) {
|
||||
lbound = 0;
|
||||
while (cur->priority < rbound) {
|
||||
gNextTaskToCheckForDestruction = (struct Task*)(cur->next + (IWRAM_START));
|
||||
if (cur != gTaskPtrs[0] && cur != gTaskPtrs[1]) {
|
||||
TaskDestroy(cur);
|
||||
}
|
||||
r2 = gUnk_03002E98;
|
||||
cur = gNextTaskToCheckForDestruction;
|
||||
|
||||
if (r2 == (struct Task*)IWRAM_START) {
|
||||
if (cur == (struct Task*)IWRAM_START) {
|
||||
break;
|
||||
}
|
||||
++r2; --r2;
|
||||
gUnk_03002E98 += 0;
|
||||
++cur; --cur;
|
||||
gNextTaskToCheckForDestruction += 0;
|
||||
}
|
||||
gUnk_03002E98 = (void*)arg0; // ridiculous
|
||||
gNextTaskToCheckForDestruction = (void*)lbound; // NULL
|
||||
return;
|
||||
}
|
||||
r0 = r2->next;
|
||||
r2 = (struct Task*)(r0 + IWRAM_START);
|
||||
curOffset = cur->next;
|
||||
cur = (struct Task*)(curOffset + IWRAM_START);
|
||||
}
|
||||
gUnk_03002E98 = NULL;
|
||||
gNextTaskToCheckForDestruction = NULL;
|
||||
}
|
||||
|
||||
static s32 sub_08153028(void) {
|
||||
s32 i = 0;
|
||||
struct Unk_03003A20* r1 = gUnk_03003A20;
|
||||
struct Unk_03003A20* r0;
|
||||
static s32 IwramActiveNodeTotalSize(void) {
|
||||
s32 activeSize = 0;
|
||||
struct IwramNode* cur = &gIwramHeap;
|
||||
struct IwramNode* next;
|
||||
while (1) {
|
||||
if (r1->unk2 < 0) {
|
||||
i -= r1->unk2;
|
||||
if (cur->state < 0) {
|
||||
activeSize -= cur->state;
|
||||
}
|
||||
r0 = (void*)(r1->unk0 + IWRAM_START);
|
||||
if (r0 == (void*)IWRAM_START) {
|
||||
next = (void*)(cur->next + IWRAM_START);
|
||||
if (next == (void*)IWRAM_START) {
|
||||
break;
|
||||
}
|
||||
r1 = r0;
|
||||
cur = next;
|
||||
}
|
||||
return i;
|
||||
return activeSize;
|
||||
}
|
||||
|
||||
static void nullsub_143(void) {
|
||||
static void TaskMainDummy(void) {
|
||||
|
||||
}
|
||||
|
||||
static void nullsub_144(void) {
|
||||
static void TaskMainDummy2(void) {
|
||||
|
||||
}
|
||||
|
||||
static void nullsub_145(void) {
|
||||
static void TaskMainDummy3(void) {
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ static void sub_080BC4A8(struct Object2*);
|
||||
|
||||
void* CreateTwister(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
|
@ -24,7 +24,7 @@ static void sub_080A4568(struct Object2*);
|
||||
void* CreateWaddleDee(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Kirby* kirby;
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task* task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
sub_0803E2B0(&obj->base, -5, -4, 5, 7);
|
||||
|
@ -53,7 +53,7 @@ static void sub_080B7460(struct Object2*);
|
||||
static void sub_080B74B4(struct Object2*);
|
||||
|
||||
void* CreateWaddleDoo(struct Object* arg0, u8 arg1) {
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
struct Object2 *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
sub_0803E2B0(&obj->base, -5, -3, 5, 8);
|
||||
@ -254,7 +254,7 @@ static void sub_080B6D58(struct Object2* arg0) {
|
||||
|
||||
static void sub_080B6DDC(struct Object2* arg0, u8 arg1) {
|
||||
u32 arg;
|
||||
struct Task *task = TaskCreate(sub_080B7068, sizeof(struct ObjectBase), 0x3500, 0x10, sub_0803DCCC);
|
||||
struct Task *task = TaskCreate(sub_080B7068, sizeof(struct ObjectBase), 0x3500, TASK_USE_EWRAM, sub_0803DCCC);
|
||||
struct ObjectBase *obj2, *obj = TaskGetStructPtr(task, obj2);
|
||||
sub_0803E380(obj);
|
||||
obj->unk0 = 2;
|
||||
|
@ -20,7 +20,7 @@ static void sub_080BCBB8(struct Object2*);
|
||||
|
||||
void* CreateWheelie(struct Object* arg0, u8 arg1) {
|
||||
struct Object2 *obj, *obj2;
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, 0x10, ObjectDestroy);
|
||||
struct Task *task = TaskCreate(ObjectMain, sizeof(struct Object2), 0x1000, TASK_USE_EWRAM, ObjectDestroy);
|
||||
obj = TaskGetStructPtr(task, obj2);
|
||||
InitObject(obj, arg0, arg1);
|
||||
if (obj->base.x > obj->kirby3->base.base.base.x) {
|
||||
|
Loading…
Reference in New Issue
Block a user