diff --git a/asm/code_08000108.s b/asm/code_08000108.s index 7fb9b84d..db7cb020 100644 --- a/asm/code_08000108.s +++ b/asm/code_08000108.s @@ -33,7 +33,7 @@ _08000136: pop {r4, pc} _08000138: _08000138: .4byte gUnk_030056F1 -_0800013C: .4byte sub_0807D280 +_0800013C: .4byte sub_0807D280 @ layer 1, 2, 3? _08000140: .4byte sub_0807D46C _08000144: .4byte sub_0807D6D8 @@ -55,8 +55,8 @@ sub_08000152: @ 0x08000152 lsrs r2, r2, #2 non_word_aligned_thumb_func_start SetTile -SetTile: @ 0x0800015E - push {r4, r5, r6, r7, lr} +SetTile: @ r0 = tile type, r1, = tile position, r2 = layer + push {r4-r7, lr} lsls r3, r2, #3 ldr r4, _08000208 @ =gUnk_08000228 ldr r5, [r4, r3] @@ -75,7 +75,7 @@ SetTile: @ 0x0800015E ldrb r0, [r3, r4] lsrs r2, r2, #2 bl sub_08000148 - pop {r0, r1} + pop {r0, r1} # tilepos, layer push {r0, r1} bl DeleteLoadedTileEntity adds r0, r7, #0 @@ -170,8 +170,8 @@ gUnk_08000278:: @ call 0x80B19CC @ ======== @ Unused? Doesn't seem to be called by anything in Ghidra. - thumb_func_start sub_08000288 -sub_08000288: @ 0x08000288 + thumb_func_start GetTileAtEntityPos +GetTileAtEntityPos: @ 0x08000288 ldr r3, _080002F4 @ =gUnk_03005740 bx r3 diff --git a/asm/code_08016B30.s b/asm/code_08016B30.s index 4b1079c9..059e1c4c 100644 --- a/asm/code_08016B30.s +++ b/asm/code_08016B30.s @@ -13,7 +13,7 @@ sub_08016B30: @ 0x08016B30 thumb_func_start sub_08016B34 sub_08016B34: @ 0x08016B34 ldr r1, _08016B54 @ =0x03007FFC - ldr r0, _08016B58 @ =gUnk_03005D90 + ldr r0, _08016B58 @ =IntrMain str r0, [r1] ldr r1, _08016B5C @ =0x04000004 ldr r2, _08016B60 @ =0x00005028 @@ -29,7 +29,7 @@ sub_08016B34: @ 0x08016B34 bx lr .align 2, 0 _08016B54: .4byte 0x03007FFC -_08016B58: .4byte gUnk_03005D90 +_08016B58: .4byte IntrMain _08016B5C: .4byte 0x04000004 _08016B60: .4byte 0x00005028 _08016B64: .4byte 0x04000200 diff --git a/asm/crt0.s b/asm/crt0.s index aa94b6fd..73578ef5 100644 --- a/asm/crt0.s +++ b/asm/crt0.s @@ -1,32 +1,31 @@ .include "asm/macros.inc" .include "constants/constants.inc" - .syntax unified - .text arm_func_start __start -__start: @ 0x08000000 - b _080000C0 -_08000004: +__start: + b start_vector + +header: .include "asm/rom_header.inc" -_080000C0: + +start_vector: mov r0, #0x12 msr cpsr_fc, r0 - ldr sp, _080000F4 @ =gUnk_03007FA0 + ldr sp, sp_irq mov r0, #0x1f msr cpsr_fc, r0 - ldr sp, _080000F8 @ =gUnk_03007F00 - ldr r1, _080000FC @ =0x03007FFC - ldr r0, _08000100 @ =gUnk_03005D90 + ldr sp, sp_usr + ldr r1, INTR_VECTOR_BUF + ldr r0, intr_main str r0, [r1] - ldr r1, _08000104 @ =MainLoop + ldr r1, =AgbMain mov lr, pc bx r1 _080000F0: - b _080000C0 -_080000F4: .4byte gUnk_03007FA0 -_080000F8: .4byte gUnk_03007F00 -_080000FC: .4byte 0x03007FFC -_08000100: .4byte gUnk_03005D90 -_08000104: .4byte MainLoop + b start_vector +sp_irq: .4byte gUnk_03007FA0 +sp_usr: .4byte gUnk_03007F00 +INTR_VECTOR_BUF: .4byte 0x03007FFC +intr_main: .4byte IntrMain diff --git a/asm/intr.s b/asm/intr.s index 388274a3..3332c380 100644 --- a/asm/intr.s +++ b/asm/intr.s @@ -49,16 +49,17 @@ _080B19C0: .4byte gRoomControls _080B19C4: .4byte 0x80000020 _080B19C8: .4byte 0x040000D4 - arm_func_start sub_080B19CC -sub_080B19CC: @ 0x080B19CC - ldrb r2, [r0, #0x38] - ldrh r1, [r0, #0x32] - ldrh r0, [r0, #0x2e] +@ r0 = entity* + arm_func_start _GetTileAtEntityPos +_GetTileAtEntityPos: @ 0x080B19CC + ldrb r2, [r0, #0x38] @ obj layer + ldrh r1, [r0, #0x32] @ obj y + ldrh r0, [r0, #0x2e] @ obj x ldr ip, _080B1C10 @ =gRoomControls ldrh r3, [ip, #6] - sub r0, r0, r3 + sub r0, r0, r3 @ obj x - room x ldrh r3, [ip, #8] - sub r1, r1, r3 + sub r1, r1, r3 @ obj y - room y lsl r0, r0, #0x16 lsr r0, r0, #0x1a lsl r1, r1, #0x16 @@ -102,7 +103,7 @@ _080B1A64: ldr r1, [r2] lsl r0, r0, #1 ldrh r0, [r1, r0] - cmp r0, #0x4000 + cmp r0, #0x4000 @ return tile index is OOB bxhs lr ldr r1, [r2, #4] lsl r0, r0, #1 diff --git a/linker.ld b/linker.ld index 01c96243..d8d2d2ee 100644 --- a/linker.ld +++ b/linker.ld @@ -258,7 +258,7 @@ SECTIONS { . = 0x00005D24; gUnk_03005D24 = .; . = 0x00005D58; gUnk_03005D58 = .; . = 0x00005D5C; gUnk_03005D5C = .; - . = 0x00005D90; gUnk_03005D90 = .; + . = 0x00005D90; IntrMain = .; . = 0x00005E60; gUnk_03005E60 = .; . = 0x00005E98; gUnk_03005E98 = .; . = 0x00005F24; _EntUpdate = .; diff --git a/src/main.c b/src/main.c index c05d9945..c00ce322 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ static void (*const sScreenHandlers[])(void) = { [SCREEN_CREDITS] = HandleCreditsScreen, [SCREEN_DEBUG_TEXT] = HandleDebugTextScreen, }; -void MainLoop(void) { +void AgbMain(void) { int var0; sub_08055F70();