Skip to content

Commit

Permalink
Some adjustments from SA1 integration
Browse files Browse the repository at this point in the history
  • Loading branch information
JaceCear committed Dec 24, 2024
1 parent bdd8018 commit 99b044c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
6 changes: 3 additions & 3 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef void *IwramData;
#define TASK_x0004 0x0004
#define TASK_USE_EWRAM 0x0010

#define USE_OLD_TASK_SYSTEM FALSE
#define USE_SA2_TASK_SYSTEM FALSE

struct Task {
/* 0x00 */ TaskPtr parent;
Expand All @@ -53,7 +53,7 @@ struct Task {
/* 0x12 */ u16 flags; // 0x1 = active
// 0x2 = ???
// 0x10 = use ewram for struct
#if USE_OLD_TASK_SYSTEM
#if USE_SA2_TASK_SYSTEM
/* 0x14 */ u8 unk14;
/* 0x15 */ u8 unk15;
/* 0x16 */ u16 unk16;
Expand Down Expand Up @@ -88,7 +88,7 @@ extern struct Task gTasks[MAX_TASK_NUM];
extern struct Task gEmptyTask;
extern struct Task *gTaskPtrs[MAX_TASK_NUM];
extern s32 gNumTasks;
#if !USE_OLD_TASK_SYSTEM
#if !USE_SA2_TASK_SYSTEM
extern struct Task *gNextTaskToCheckForDestruction;
#endif
extern struct Task *gNextTask;
Expand Down
3 changes: 2 additions & 1 deletion src/background.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@ static AnimCmdResult animCmd_SetOamOrder_BG(void *cursor, Sprite *s)
return 1;
}

// Not in SA2
#if (GAME >= GAME_SA3)
NONMATCH("asm/non_matching/engine/background__unused__sub_80BF1CC.inc", void sub_80BF1CC(void *param0)) { }
END_NONMATCH
#endif
5 changes: 2 additions & 3 deletions src/bg_triangles.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,7 @@ void sa2__sub_8007A08(u8 bg, u8 param1, u8 param2, u8 param3, u8 param4)
}
}

// TODO: Not in SA3 ?
#if 0
#if ((GAME == GAME_SA1) || (GAME == GAME_SA2))
void sa2__sub_8007AC0(u8 affineBg, int_vcount minY, int_vcount maxY)
{
u16 *cursor;
Expand Down Expand Up @@ -837,4 +836,4 @@ void sa2__sub_8007AC0(u8 affineBg, int_vcount minY, int_vcount maxY)
minY++;
}
}
#endif
#endif
1 change: 0 additions & 1 deletion src/sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ extern const AnimationCommandFunc animCmdTable[];

#define ReadInstruction(script, cursor) ((void *)(script) + (cursor * sizeof(s32)))

// TODO: extern -> static
static AnimCmdResult animCmd_GetTiles(void *cursor, Sprite *s);
static AnimCmdResult animCmd_GetPalette(void *cursor, Sprite *s);
static AnimCmdResult animCmd_JumpBack(void *cursor, Sprite *s);
Expand Down
20 changes: 13 additions & 7 deletions src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ u32 TasksInit(void)
gNextTask = NULL;
gNumTasks = 0;

#if !USE_OLD_TASK_SYSTEM
#if !USE_SA2_TASK_SYSTEM
gNextTaskToCheckForDestruction = NULL;
#endif

Expand Down Expand Up @@ -99,7 +99,7 @@ struct Task *TaskCreate(TaskMain taskMain, u16 structSize, u16 priority, u16 fla
task->dtor = taskDestructor;
task->priority = priority;
task->flags = flags;
#if USE_OLD_TASK_SYSTEM
#if USE_SA2_TASK_SYSTEM
task->unk15 = 0;
task->unk16 = 0;
task->unk18 = 0;
Expand Down Expand Up @@ -128,6 +128,9 @@ void TaskDestroy(struct Task *task)
{
TaskPtr32 next, prev;
if (!(task->flags & TASK_DESTROY_DISABLED)) {
#if ENABLE_TASK_LOGGING
printf("Destroying '%s'\n", task->name);
#endif
prev = TASK_PTR(task->prev);
next = TASK_PTR(task->next);

Expand All @@ -141,11 +144,13 @@ void TaskDestroy(struct Task *task)
gNextTask = TASK_NEXT(task);
}

#if (GAME == GAME_SA3)
// can only happen in (implicitly) recursive TaskDestroy calls (from
// task->dtor) in TasksDestroyInPriorityRange
if (task == gNextTaskToCheckForDestruction) {
gNextTaskToCheckForDestruction = (struct Task *)(task->next + IWRAM_START);
}
#endif

prev = TASK_PTR(task->prev);
next = TASK_PTR(task->next);
Expand All @@ -164,7 +169,7 @@ void TaskDestroy(struct Task *task)
task->flags = 0;
task->data = (IwramData)NULL;

#if USE_OLD_TASK_SYSTEM
#if USE_SA2_TASK_SYSTEM
task->unk15 = 0;
task->unk16 = 0;
task->unk18 = 0;
Expand Down Expand Up @@ -294,9 +299,8 @@ void IwramFree(void *p)
}
}

/* The function is probably for cleaning up the IWRAM nodes, but it's not working.
SA2: sub_80028DC */
static void sub_80BD1E0(void)
/* The function is probably for cleaning up the IWRAM nodes, but it's not working. */
static void sa2__sub_80028DC(void)
{
struct IwramNode *cur = (struct IwramNode *)&gIwramHeap[0];
s32 curStateBackup;
Expand Down Expand Up @@ -354,7 +358,7 @@ static struct Task *TaskGetNextSlot(void)
}
}

#if USE_OLD_TASK_SYSTEM
#if ((GAME == GAME_SA1) || (GAME == GAME_SA2))
void TasksDestroyInPriorityRange(u16 lbound, u16 rbound)
{
struct Task *cur = gTaskPtrs[0];
Expand Down Expand Up @@ -421,6 +425,7 @@ void TasksDestroyInPriorityRange(u16 lbound, u16 rbound)
}
#endif

#if (GAME == GAME_SA3)
static s32 IwramActiveNodeTotalSize(void)
{
s32 activeSize = 0;
Expand All @@ -438,6 +443,7 @@ static s32 IwramActiveNodeTotalSize(void)
}
return activeSize;
}
#endif

static void TaskMainDummy1(void) { }

Expand Down

0 comments on commit 99b044c

Please sign in to comment.