Merge pull request #12 from camthesaxman/proc

finish decompiling proc.c
This commit is contained in:
Cameron Hall 2018-02-24 00:34:27 -06:00 committed by GitHub
commit 8359cae7d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 5670 additions and 5787 deletions

View File

@ -14,13 +14,14 @@ ASFLAGS := -mcpu=arm7tdmi -mthumb-interwork -I include
#### Files ####
ROM := fireemblem8.gba
ELF := $(ROM:.gba=.elf)
MAP := $(ROM:.gba=.map)
LDSCRIPT := ldscript.txt
CFILES := $(wildcard src/*.c)
SFILES := $(wildcard asm/*.s) $(wildcard asm/libc/*.s) $(wildcard data/*.s)
OFILES := $(SFILES:.s=.o) $(CFILES:.c=.o)
ROM := fireemblem8.gba
ELF := $(ROM:.gba=.elf)
MAP := $(ROM:.gba=.map)
LDSCRIPT := ldscript.txt
SYM_FILES := sym_iwram.txt sym_ewram.txt
CFILES := $(wildcard src/*.c)
SFILES := $(wildcard asm/*.s) $(wildcard asm/libc/*.s) $(wildcard data/*.s)
OFILES := $(SFILES:.s=.o) $(CFILES:.c=.o)
#### Main Targets ####
@ -34,7 +35,7 @@ clean:
#### Recipes ####
$(ELF): $(OFILES) $(LDSCRIPT)
$(ELF): $(OFILES) $(LDSCRIPT) $(SYM_FILES)
$(LD) -T $(LDSCRIPT) -Map $(MAP) $(OFILES) tools/agbcc/lib/libgcc.a tools/agbcc/lib/libc.a -o $@
%.gba: %.elf

View File

@ -308,7 +308,7 @@ NewKeyStatusSetter: @ 0x08001470
adds r4, r0, #0
ldr r0, _08001488 @ gUnknown_08587920
movs r1, #1
bl New6C
bl Proc_Create
adds r0, #0x64
strh r4, [r0]
pop {r4}

6718
asm/code.s

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ _08000A64:
bl UpdateKeyStatus
bl StoreRoutinesToIRAM
bl sub_80A2C3C
bl Initialize6CEngine
bl Proc_Initialize
bl TCS_ClearAll
bl ResetMoveunitStructs
ldr r0, _08000B08 @ 0x42D690E9

View File

@ -1,175 +0,0 @@
.INCLUDE "macro.inc"
.SYNTAX UNIFIED
THUMB_FUNC_START Find6C_
Find6C_: @ 0x0800346C
push {lr}
adds r3, r0, #0
cmp r1, #0
bne _08003480
ldr r1, _08003478 @ gUnknown_02024E68
b _08003482
.align 2, 0
_08003478: .4byte gUnknown_02024E68
_0800347C:
adds r0, r1, #0
b _08003498
_08003480:
adds r1, #0x6c
_08003482:
ldr r0, _0800349C @ gUnknown_02026968
cmp r1, r0
bhs _08003496
adds r2, r0, #0
_0800348A:
ldr r0, [r1]
cmp r0, r3
beq _0800347C
adds r1, #0x6c
cmp r1, r2
blo _0800348A
_08003496:
movs r0, #0
_08003498:
pop {r1}
bx r1
.align 2, 0
_0800349C: .4byte gUnknown_02026968
THUMB_FUNC_START sub_80034A0
sub_80034A0: @ 0x080034A0
push {lr}
adds r2, r0, #0
cmp r2, #0
bne _080034B4
ldr r2, _080034AC @ gUnknown_02024E68
b _080034B6
.align 2, 0
_080034AC: .4byte gUnknown_02024E68
_080034B0:
adds r0, r2, #0
b _080034CC
_080034B4:
adds r2, #0x6c
_080034B6:
ldr r0, _080034D0 @ gUnknown_02026968
cmp r2, r0
bhs _080034CA
adds r3, r0, #0
_080034BE:
ldr r0, [r2, #0x14]
cmp r0, r1
beq _080034B0
adds r2, #0x6c
cmp r2, r3
blo _080034BE
_080034CA:
movs r0, #0
_080034CC:
pop {r1}
bx r1
.align 2, 0
_080034D0: .4byte gUnknown_02026968
THUMB_FUNC_START sub_80034D4
sub_80034D4: @ 0x080034D4
push {lr}
movs r2, #0x40
ldr r1, _080034F4 @ gUnknown_02024E68
ldr r0, _080034F8 @ 0x00001A94
adds r3, r1, r0
_080034DE:
ldr r0, [r1]
cmp r0, #0
beq _080034E6
subs r2, #1
_080034E6:
adds r1, #0x6c
cmp r1, r3
ble _080034DE
adds r0, r2, #0
pop {r1}
bx r1
.align 2, 0
_080034F4: .4byte gUnknown_02024E68
_080034F8: .4byte 0x00001A94
THUMB_FUNC_START sub_80034FC
sub_80034FC: @ 0x080034FC
push {r4, lr}
adds r3, r0, #0
ldr r2, _08003514 @ gUnknown_02024E68
movs r1, #0
movs r4, #0x3f
_08003506:
cmp r3, #0
bne _08003518
ldr r0, [r2]
cmp r0, #0
beq _08003520
b _0800351E
.align 2, 0
_08003514: .4byte gUnknown_02024E68
_08003518:
ldr r0, [r2]
cmp r0, r3
bne _08003520
_0800351E:
adds r1, #1
_08003520:
subs r4, #1
adds r2, #0x6c
cmp r4, #0
bge _08003506
adds r0, r1, #0
pop {r4}
pop {r1}
bx r1
THUMB_FUNC_START sub_8003530
sub_8003530: @ 0x08003530
ldr r2, _0800353C @ gUnknown_02024E68
str r2, [r0]
str r1, [r0, #4]
movs r1, #0
str r1, [r0, #8]
bx lr
.align 2, 0
_0800353C: .4byte gUnknown_02024E68
THUMB_FUNC_START sub_8003540
sub_8003540: @ 0x08003540
push {r4, r5, lr}
adds r3, r0, #0
movs r4, #0
ldr r0, [r3, #8]
cmp r0, #0x3f
bgt _08003570
ldr r5, [r3, #4]
_0800354E:
ldr r1, [r3]
ldr r0, [r1]
cmp r0, r5
bne _08003558
adds r4, r1, #0
_08003558:
ldr r0, [r3, #8]
adds r2, r0, #1
str r2, [r3, #8]
adds r0, r1, #0
adds r0, #0x6c
str r0, [r3]
cmp r4, #0
beq _0800356C
adds r0, r4, #0
b _08003572
_0800356C:
cmp r2, #0x3f
ble _0800354E
_08003570:
movs r0, #0
_08003572:
pop {r4, r5}
pop {r1}
bx r1

View File

@ -1992,7 +1992,7 @@ _08002326:
ldr r0, [r5]
cmp r0, #0
beq _08002336
bl Break6CLoop
bl Proc_ClearNativeCallback
movs r0, #0
str r0, [r5]
_08002336:
@ -2000,7 +2000,7 @@ _08002336:
ldr r0, [r5]
cmp r0, #0
beq _08002346
bl Break6CLoop
bl Proc_ClearNativeCallback
movs r0, #0
str r0, [r5]
_08002346:
@ -2037,7 +2037,7 @@ _08002386:
ldr r0, [r5]
cmp r0, #0
beq _08002396
bl Break6CLoop
bl Proc_ClearNativeCallback
movs r0, #0
str r0, [r5]
_08002396:
@ -2045,7 +2045,7 @@ _08002396:
ldr r0, [r5]
cmp r0, #0
beq _080023A6
bl Break6CLoop
bl Proc_ClearNativeCallback
movs r0, #0
str r0, [r5]
_080023A6:
@ -2243,7 +2243,7 @@ sub_80024F0: @ 0x080024F0
cmp r0, r1
blt _08002556
adds r0, r7, #0
bl Break6CLoop
bl Proc_ClearNativeCallback
ldr r1, _08002570 @ gUnknown_03000040
movs r0, #0
str r0, [r1]
@ -2284,7 +2284,7 @@ sub_8002574: @ 0x08002574
strh r6, [r0, #4]
ldr r0, _0800260C @ gUnknown_08587958
movs r1, #3
bl New6C
bl Proc_Create
mov r8, r0
ldr r4, _08002610 @ gUnknown_03006440
adds r0, r4, #0
@ -2481,14 +2481,14 @@ ISuspectThisToBeMusicRelated_8002730: @ 0x08002730
cmp r1, #0
beq _0800274C
ldr r0, _08002748 @ gUnknown_08587970
bl NewBlocking6C
bl Proc_CreateBlockingChild
b _08002754
.align 2, 0
_08002748: .4byte gUnknown_08587970
_0800274C:
ldr r0, _08002780 @ gUnknown_08587970
movs r1, #3
bl New6C
bl Proc_Create
_08002754:
adds r4, r0, #0
adds r0, r4, #0
@ -2574,7 +2574,7 @@ _080027F4:
strb r0, [r1, #6]
_080027FA:
adds r0, r5, #0
bl Break6CLoop
bl Proc_ClearNativeCallback
ldr r1, _08002818 @ gUnknown_03000044
movs r0, #0
str r0, [r1]
@ -2613,7 +2613,7 @@ Some6CMusicRelatedWaitCallback: @ 0x0800281C
ldr r1, [r4, #0x54]
bl sub_8002890
adds r0, r4, #0
bl Delete6C
bl Proc_Delete
_0800284E:
pop {r4}
pop {r0}
@ -2635,7 +2635,7 @@ Exec6CSomeWaitIfMusicOn: @ 0x08002858
bne _08002880
ldr r0, _0800288C @ gUnknown_08587988
movs r1, #3
bl New6C
bl Proc_Create
adds r1, r0, #0
adds r0, #0x4c
strh r4, [r0]
@ -2757,7 +2757,7 @@ _0800294C: .4byte gUnknown_02024E5C
sub_8002950: @ 0x08002950
push {lr}
ldr r0, _08002960 @ gUnknown_08587970
bl Find6C
bl Proc_Find
cmp r0, #0
bne _08002964
movs r0, #0
@ -2829,7 +2829,7 @@ sub_80029BC: @ 0x080029BC
_080029DA:
adds r0, r4, #0
movs r1, #0
bl Goto6CLabel
bl Proc_GotoLabel
_080029E2:
pop {r4}
pop {r0}
@ -2860,7 +2860,7 @@ _08002A0E:
beq _08002A24
ldr r0, _08002A20 @ gUnknown_08587998
adds r1, r4, #0
bl NewBlocking6C
bl Proc_CreateBlockingChild
b _08002A2C
.align 2, 0
_08002A1C: .4byte gUnknown_02024E5C
@ -2868,7 +2868,7 @@ _08002A20: .4byte gUnknown_08587998
_08002A24:
ldr r0, _08002A4C @ gUnknown_08587998
movs r1, #3
bl New6C
bl Proc_Create
_08002A2C:
adds r4, r0, #0
str r6, [r4, #0x58]
@ -2907,7 +2907,7 @@ _08002A62:
sub_8002A6C: @ 0x08002A6C
push {lr}
ldr r0, _08002A7C @ gUnknown_08587998
bl Find6C
bl Proc_Find
cmp r0, #0
bne _08002A80
movs r0, #0
@ -2949,7 +2949,7 @@ _08002AB4: .4byte gUnknown_02024E5C
DeleteAll6CWaitMusicRelated: @ 0x08002AB8
push {lr}
ldr r0, _08002AC4 @ gUnknown_08587988
bl DeleteEach6C
bl Proc_DeleteAllWithScript
pop {r0}
bx r0
.align 2, 0

File diff suppressed because it is too large Load Diff

1793
data/data_D74C8.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@
struct Proc;
typedef void (*ProcFunc)(struct Proc *);
typedef void (*OtherProcFunc)(struct Proc *);
struct ProcCmd
{
@ -13,92 +12,89 @@ struct ProcCmd
void *dataPtr;
};
#define PROC_END { 0x00, 0x0000, 0 }
#define PROC_SET_NAME(aName) { 0x01, 0x0000, aName }
#define PROC_CALL_ROUTINE(apRoutine) { 0x02, 0x0000, (void*)(apRoutine) }
#define PROC_LOOP_ROUTINE(apRoutine) { 0x03, 0x0000, (void*)(apRoutine) }
#define PROC_SET_DESTRUCTOR(apRoutine) { 0x04, 0x0000, (void*)(apRoutine) }
#define PROC_NEW_CHILD(ap6CChild) { 0x05, 0x0000, (void*)(ap6CChild) }
#define PROC_NEW_CHILD_BLOCKING(ap6CChild) { 0x06, 0x0000, (void*)(ap6CChild) }
#define PROC_NEW_MAIN_BUGGED(ap6CMain) { 0x07, 0x0000, ap6CMain }
#define PROC_WHILE_EXISTS(ap6CToCheck) { 0x08, 0x0000, (void*)(ap6CToCheck) }
#define PROC_END_ALL(ap6CToCheck) { 0x09, 0x0000, (void*)(ap6CToCheck) }
#define PROC_BREAK_ALL_LOOP(ap6CToCheck) { 0x0A, 0x0000, (void*)(ap6CToCheck) }
#define PROC_LABEL(aLabelId) { 0x0B, aLabelId, 0 }
#define PROC_GOTO(aLabelId) { 0x0C, aLabelId, 0 }
#define PROC_JUMP(ap6CCode) { 0x0D, 0x0000, (void*)(ap6CCode) }
#define PROC_SLEEP(aTime) { 0x0E, aTime, 0 }
#define PROC_SET_MARK(aMark) { 0x0F, aMark, 0 }
#define PROC_BLOCK { 0x10, 0x0000, 0 }
#define PROC_END_IF_DUPLICATE { 0x11, 0x0000, 0 }
#define PROC_SET_BIT4 { 0x12, 0x0000, 0 }
#define PROC_13 { 0x13, 0x0000, 0 }
#define PROC_WHILE_ROUTINE(aprRoutine) { 0x14, 0x0000, (void*)(aprRoutine) }
#define PROC_15 { 0x15, 0x0000, 0 }
#define PROC_CALL_ROUTINE_2(aprRoutine) { 0x16, 0x0000, (void*)(aprRoutine) }
#define PROC_END_DUPLICATES { 0x17, 0x0000, 0 }
#define PROC_CALL_ROUTINE_ARG(aprRoutine, aArgument) { 0x18, aArgument, (void*)(aprRoutine) }
#define PROC_19 { 0x19, 0x0000, 0 }
#define PROC_YIELD PROC_SLEEP(0)
struct Proc
{
/*0x00*/ struct ProcCmd *codeStart;
/*0x04*/ struct ProcCmd *codeNext;
/*0x08*/ ProcFunc onDestroy;
/*0x0C*/ ProcFunc onCycle;
/*0x00*/ struct ProcCmd *script; // pointer to process script
/*0x04*/ struct ProcCmd *currCmd; // pointer to currently executing script command
/*0x08*/ ProcFunc onDelete; // callback to run upon delegint the process
/*0x0C*/ ProcFunc nativeFunc; // callback to run once each frame.
// disables script execution when not null
/*0x10*/ char *name;
/*0x14*/ struct Proc *unk14;
/*0x18*/ struct Proc *child;
/*0x1C*/ struct Proc *prev;
/*0x20*/ struct Proc *next;
/*0x14*/ struct Proc *parent; // pointer to parent proc. If this proc is a root proc,
// this member is an integer which is the root index.
/*0x18*/ struct Proc *child; // pointer to most recently added child
/*0x1C*/ struct Proc *next; // next sibling
/*0x20*/ struct Proc *prev; // previous sibling
/*0x24*/ s16 sleepTime;
/*0x26*/ u8 mark;
/*0x27*/ u8 flags;
/*0x28*/ u8 blockCount;
/*0x28*/ u8 blockSemaphore; // wait semaphore. Process execution is blocked when this is nonzero.
/*0x29*/ u8 filler29[0x6C-0x29];
};
void Initialize6CEngine(void);
// ??? New6C(???);
// ??? NewBlocking6C(???);
// ??? Delete6CInternal(???);
// ??? Delete6C(???);
// ??? Allocate6C(???);
// ??? Free6C(???);
// ??? InsertMain6C(???);
// ??? InsertChild6C(???);
// ??? Isolate6C(???);
// ??? Exec6C_(???);
// ??? Exec6C(???);
// ??? Break6CLoop(???);
// ??? Find6C(???);
// ??? sub_8002EC4(???);
// ??? sub_8002EF4(???);
// ??? Goto6CLabel(???);
// ??? Goto6CPointer(???);
// ??? Set6CMark(???);
// ??? Set6CDestructor(???);
// ??? ForAll6C(???);
// ??? ForEach6C(???);
// ??? sub_8002FC0(???);
// ??? BlockEach6CMarked(???);
// ??? UnblockEach6CMarked(???);
// ??? DeleteEach6CMarked(???);
// ??? Delete6C_(???);
// ??? DeleteEach6C(???);
// ??? Clear6CLoopWrapper(???);
// ??? ClearCallbackAll6CMatch(???);
// ??? ForAllFollowing6C(???);
struct UnknownProcStruct
{
struct Proc *unk0;
struct ProcCmd *unk4;
int unk8;
};
void Proc_Initialize(void);
// ??? Proc_Create(???);
// ??? Proc_CreateBlockingChild(???);
// ??? Proc_Delete(???);;
// ??? Proc_Run(???);
// ??? Proc_ClearNativeCallback(???);
// ??? Proc_Find(???);
// ??? Proc_FindNonBlocked(???);
// ??? Proc_FindWithMark(???);
// ??? Proc_GotoLabel(???);
// ??? Proc_JumpToPointer(???);
// ??? Proc_SetMark(???);
// ??? Proc_SetDestructor(???);
// ??? Proc_ForEach(???);
// ??? Proc_ForEachWithScript(???);
// ??? Proc_ForEachWithMark(???);
// ??? Proc_BlockEachWithMark(???);
// ??? Proc_UnblockEachWithMark(???);
// ??? Proc_DeleteEachWithMark(???);
// ??? Proc_DeleteAllWithScript(???);
// ??? Proc_ClearNativeCallbackEachWithScript(???);
// ??? sub_80030CC(???);
// ??? Call6C_00Delete(???);
// ??? Call6C_01Name(???);
// ??? Call6C_02CallAndContinue(???);
// ??? Call6C_16Call(???);
// ??? Call6C_18CallWithArg(???);
// ??? Call6C_14While(???);
// ??? Call6C_03SetLoop(???);
// ??? Call6C_04SetDestructor(???);
// ??? Call6C_05AddChild(???);
// ??? Call6C_06AddBlockingChild(???);
// ??? Call6C_07AddGlobal_BuggedMaybe(???);
// ??? Call6C_08WhileExists(???);
// ??? Call6C_09DeleteEach6C(???);
// ??? Call6C_0AClearLoopForEach6C(???);
// ??? Call6C_0BOr19Label(???);
// ??? Call6C_0DJump(???);
// ??? Call6C_0CGotoLabel(???);
// ??? _6CSleepLoop(???);
// ??? Call6C_0ESleep(???);
// ??? Call6C_0FMark(???);
// ??? Call6C_13Blank(???);
// ??? Call6C_10Block(???);
// ??? Call6C_11DeleteIfDuplicate(???);
// ??? Call6C_17DeleteOtherDuplicates(???);
// ??? Call6C_15Blank(???);
// ??? Call6C_12SetBit4(???);
// ??? Call6CCode(???);
// ??? nullsub_2(???);
// ??? ForEach6CDoNothing(???);
// ??? sub_8003418(???);
// ??? sub_800344C(???);
// ??? Set6CLoop(???);
// ??? sub_8003454(???);
// ??? sub_8003460(???);
// ??? Find6C_(???);
// ??? sub_80034A0(???);
// ??? Proc_SetNativeFunc(???);
// ??? Proc_BlockSemaphore(???);
// ??? Proc_WakeSemaphore(???);
// ??? Proc_FindAfter(???);
// ??? Proc_FindAfterWithParent(???);
// ??? sub_80034D4(???);
// ??? sub_80034FC(???);
// ??? sub_8003530(???);

View File

@ -495,10 +495,10 @@
// extern ??? gUnknown_02024CD4
// extern ??? gUnknown_02024CDC
// extern ??? gUnknown_02024E5C
// extern ??? gUnknown_02024E68
// extern ??? gProcesses
// extern ??? gUnknown_02026968
// extern ??? gUnknown_02026A6C
// extern ??? gUnknown_02026A70
// extern ??? gRootProcesses
// extern ??? gUnknown_02026A90
// extern ??? gUnknown_02026E10
// extern ??? gUnknown_02026E30
@ -1346,7 +1346,7 @@
// extern ??? gUnknown_08587970
// extern ??? gUnknown_08587988
// extern ??? gUnknown_08587998
// extern ??? gUnknown_085879D8
// extern ??? gProcCmdFuncs
// extern ??? gUnknown_08587A40
// extern ??? gUnknown_08588240
// extern ??? gUnknown_08588274

View File

@ -4,14 +4,14 @@ SECTIONS
/* TODO: figure out what is COMMON and .bss */
. = 0x02000000;
EWRAM :
EWRAM (NOLOAD) :
ALIGN(4)
{
INCLUDE "sym_ewram.txt"
}
. = 0x03000000;
IWRAM :
IWRAM (NOLOAD):
ALIGN(4)
{
INCLUDE "sym_iwram.txt"
@ -30,7 +30,6 @@ SECTIONS
asm/IO.o(.text);
asm/rom_800148C.o(.text);
src/proc.o(.text);
asm/proc.o(.text);
asm/code.o(.text);
asm/m4a.o(.text);
asm/libagbsyscall.o(.text);
@ -85,7 +84,9 @@ SECTIONS
tools/agbcc/lib/libgcc.a:_negdi2.o(.text);
asm/arm_call.o(.text);
data/data.o(.rodata);
data/data_D74C8.o(.rodata);
src/proc.o(.rodata);
data/data_587A40.o(.rodata);
} = 0
. = 0x8B1FA20;

File diff suppressed because it is too large Load Diff

View File

@ -495,10 +495,7 @@
. = 0x024CD4; gUnknown_02024CD4 = .;
. = 0x024CDC; gUnknown_02024CDC = .;
. = 0x024E5C; gUnknown_02024E5C = .;
. = 0x024E68; gUnknown_02024E68 = .;
. = 0x026968; gUnknown_02026968 = .;
. = 0x026A6C; gUnknown_02026A6C = .;
. = 0x026A70; gUnknown_02026A70 = .;
. = 0x024E68; src/proc.o(ewram_data);
. = 0x026A90; gUnknown_02026A90 = .;
. = 0x026E10; gUnknown_02026E10 = .;
. = 0x026E30; gUnknown_02026E30 = .;