From b2ec63d69e19b274fa5f8d56fb0a35cc0c9bd524 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sun, 5 Mar 2017 07:35:03 +0000 Subject: [PATCH] resolve implicit declarations and enforce warnings as errors --- Makefile | 2 +- asm/battle_anim.s | 22 ++-- asm/battle_anim_8170478.s | 26 ++--- asm/credits.s | 58 +++++----- asm/evolution_graphics.s | 22 ++-- asm/field_effect.s | 36 +++---- asm/field_region_map.s | 10 +- asm/hall_of_fame.s | 40 +++---- asm/intro.s | 6 +- asm/intro_credits_graphics.s | 48 ++++----- data/data2.s | 103 +++++++++++++++++- include/battle.h | 7 +- include/dma3.h | 23 ++++ include/m4a.h | 18 ++++ include/rtc.h | 48 +++++++++ src/battle_ai.c | 204 +++++++++++++++++------------------ src/dma3_manager.c | 16 +-- src/main.c | 24 ++++- src/palette.c | 1 - 19 files changed, 457 insertions(+), 257 deletions(-) create mode 100644 include/dma3.h create mode 100644 include/m4a.h create mode 100644 include/rtc.h diff --git a/Makefile b/Makefile index 221c54e243..b962140e8e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ AS := $(DEVKITARM)/bin/arm-none-eabi-as ASFLAGS := -mcpu=arm7tdmi CC1 := tools/agbcc/bin/agbcc -override CFLAGS += -mthumb-interwork -Wimplicit -O2 -fhex-asm +override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm CPP := $(DEVKITARM)/bin/arm-none-eabi-cpp CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef diff --git a/asm/battle_anim.s b/asm/battle_anim.s index 18e09542a4..f7dfc1ed04 100644 --- a/asm/battle_anim.s +++ b/asm/battle_anim.s @@ -1330,14 +1330,14 @@ _080A44B0: movs r0, 0x16 bl SetGpuReg lsls r4, r6, 5 - ldr r0, =gUnknown_02037914 + ldr r0, =gPlttBufferUnfaded + 0x200 adds r4, r0 add r0, sp, 0x10 ldrb r1, [r0, 0x8] lsls r1, 4 adds r0, r4, 0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette add r0, sp, 0x10 ldrb r1, [r0, 0x8] lsls r1, 5 @@ -1471,12 +1471,12 @@ _080A460E: movs r0, 0x1A bl SetGpuReg lsls r4, r6, 5 - ldr r0, =gUnknown_02037914 + ldr r0, =gPlttBufferUnfaded + 0x200 adds r4, r0 adds r0, r4, 0 movs r1, 0x90 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette ldr r1, =0x05000120 ldr r2, =0x04000008 adds r0, r4, 0 @@ -1727,7 +1727,7 @@ task_pA_ma0A_obj_to_bg_pal: @ 80A47D8 adds r0, r5 strh r0, [r1] lsls r0, r6, 5 - ldr r2, =gUnknown_02037D14 + ldr r2, =gPlttBufferFaded + 0x200 adds r0, r2 mov r1, sp ldrb r1, [r1, 0x8] @@ -1753,7 +1753,7 @@ _080A4870: adds r0, r5 strh r0, [r1] lsls r0, r6, 5 - ldr r1, =gUnknown_02037D14 + ldr r1, =gPlttBufferFaded + 0x200 adds r0, r1 subs r1, 0xE0 ldr r2, =0x04000008 @@ -2582,14 +2582,14 @@ task_p5_load_battle_screen_elements: @ 80A4EF4 movs r1, 0 movs r2, 0 movs r3, 0x10 - bl sub_80A27B0 + bl BeginHardwarePaletteFade ldrh r0, [r4, 0x1C] adds r0, 0x1 strh r0, [r4, 0x1C] b _080A4FBC .pool _080A4F2C: - ldr r2, =gUnknown_02037FD4 + ldr r2, =gPaletteFade ldrb r1, [r2, 0x7] movs r0, 0x80 ands r0, r1 @@ -2626,7 +2626,7 @@ _080A4F6E: movs r1, 0 movs r2, 0x10 movs r3, 0 - bl sub_80A27B0 + bl BeginHardwarePaletteFade ldr r1, =gTasks lsls r0, r5, 2 adds r0, r5 @@ -2713,7 +2713,7 @@ sub_80A4FC8: @ 80A4FC8 lsrs r1, 20 adds r0, r4, 0 movs r2, 0x20 - bl decompress_palette + bl LoadCompressedPalette b _080A507E .pool _080A5050: @@ -2736,7 +2736,7 @@ _080A5050: ldr r0, [r4] movs r1, 0x20 movs r2, 0x20 - bl decompress_palette + bl LoadCompressedPalette _080A507E: pop {r4-r7} pop {r0} diff --git a/asm/battle_anim_8170478.s b/asm/battle_anim_8170478.s index 4b170be29e..608e5d2007 100644 --- a/asm/battle_anim_8170478.s +++ b/asm/battle_anim_8170478.s @@ -167,7 +167,7 @@ sub_8170478: @ 8170478 ldrb r1, [r1, 0x8] lsls r1, 4 movs r2, 0x20 - bl decompress_palette + bl LoadCompressedPalette ldr r1, =gUnknown_02022E18 ldrh r0, [r7, 0x20] negs r0, r0 @@ -471,7 +471,7 @@ sub_8170834: @ 8170834 lsls r4, 4 orrs r4, r3 lsls r0, 1 - ldr r1, =gUnknown_02037714 + ldr r1, =gPlttBufferUnfaded mov r8, r1 add r0, r8 mov r2, r9 @@ -480,7 +480,7 @@ sub_8170834: @ 8170834 adds r1, r3, r1 movs r2, 0x20 str r3, [sp] - bl gpu_pal_apply + bl LoadPalette lsls r4, 1 add r4, r8 ldrb r0, [r7] @@ -490,7 +490,7 @@ sub_8170834: @ 8170834 adds r0, r4, 0 adds r1, r3, 0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette mov r0, r9 ldrb r1, [r0] lsls r1, 4 @@ -2352,7 +2352,7 @@ sub_81717F8: @ 81717F8 lsls r0, r1 movs r1, 0x6 movs r2, 0 - bl sub_80A2A20 + bl BlendPalettes adds r0, r6, 0 bl sub_81719EC b _081718BC @@ -2370,7 +2370,7 @@ _0817183C: movs r1, 0x2 movs r2, 0x6 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade b _081718BC _0817185A: cmp r1, 0x5F @@ -2473,7 +2473,7 @@ _081718F6: movs r1, 0 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade b _08171982 .pool _08171944: @@ -2514,7 +2514,7 @@ _08171982: strh r0, [r4, 0x2E] b _081719B0 _0817198A: - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -4553,7 +4553,7 @@ _08172A7E: movs r1, 0 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade mov r0, r8 add sp, 0x4 pop {r3,r4} @@ -4608,7 +4608,7 @@ sub_8172AB0: @ 8172AB0 b _08172B30 .pool _08172B08: - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -4623,7 +4623,7 @@ _08172B08: movs r1, 0 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade adds r0, r5, 0 bl DestroyTask _08172B30: @@ -4640,7 +4640,7 @@ sub_8172B40: @ 8172B40 sub sp, 0x4 lsls r0, 24 lsrs r2, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -4660,7 +4660,7 @@ sub_8172B40: @ 8172B40 movs r1, 0 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_8172B90 str r0, [r4] _08172B78: diff --git a/asm/credits.s b/asm/credits.s index 0365a34d75..c9a6072ff8 100644 --- a/asm/credits.s +++ b/asm/credits.s @@ -10,7 +10,7 @@ sub_81754C8: @ 81754C8 push {lr} bl LoadOamFromSprites bl ProcessObjectCopyRequests - bl copy_pal_bg_faded_to_pal_ram + bl TransferPlttBuffer pop {r0} bx r0 thumb_func_end sub_81754C8 @@ -49,7 +49,7 @@ sub_81754DC: @ 81754DC strb r0, [r1] _08175522: bl PrepareSpritesForOamLoad - bl fade_and_return_progress_probably + bl UpdatePaletteFade pop {r0} bx r0 .pool @@ -73,7 +73,7 @@ sub_8175548: @ 8175548 ldr r0, =gUnknown_085E56F0 movs r1, 0x80 movs r2, 0x40 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085E6F6C bl InitWindows bl DeactivateAllTextPrinters @@ -169,7 +169,7 @@ sub_8175620: @ 8175620 movs r1, 0xE0 lsls r1, 9 bl InitHeap - bl sub_80A1A74 + bl ResetPaletteFade bl ResetTasks bl sub_8175548 ldr r0, =sub_8175744 @@ -231,7 +231,7 @@ _0817566A: movs r1, 0 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade movs r0, 0x1 bl EnableInterrupts ldr r0, =sub_81754C8 @@ -273,7 +273,7 @@ sub_8175744: @ 8175744 push {lr} lsls r0, 24 lsrs r2, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -337,7 +337,7 @@ _081757B0: movs r1, 0 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_8175808 b _081757FA .pool @@ -352,7 +352,7 @@ _081757E0: movs r1, 0 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_81758A4 _081757FA: str r0, [r4] @@ -369,7 +369,7 @@ sub_8175808: @ 8175808 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -420,7 +420,7 @@ c2_080C9BFC: @ 8175848 str r1, [sp] movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade movs r0, 0x1 bl EnableInterrupts ldr r0, =sub_81754C8 @@ -440,7 +440,7 @@ sub_81758A4: @ 81758A4 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -501,7 +501,7 @@ _08175906: ldr r0, =gUnknown_085B0A02 movs r1, 0x1 movs r2, 0x3E - bl gpu_pal_apply + bl LoadPalette movs r1, 0 ldr r4, =0x0201c000 movs r3, 0x11 @@ -608,7 +608,7 @@ _081759F0: movs r1, 0 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade movs r0, 0x1C movs r1, 0 bl SetGpuReg @@ -667,7 +667,7 @@ _08175AC4: movs r1, 0xC movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_8175AE4 str r0, [r4] _08175AD8: @@ -683,7 +683,7 @@ sub_8175AE4: @ 8175AE4 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -713,7 +713,7 @@ sub_8175B1C: @ 8175B1C lsls r4, 24 lsrs r4, 24 bl sub_8175CE4 - bl sub_80A1A74 + bl ResetPaletteFade movs r1, 0xE0 lsls r1, 6 movs r0, 0 @@ -728,7 +728,7 @@ sub_8175B1C: @ 8175B1C movs r1, 0x8 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade movs r1, 0xE0 lsls r1, 3 movs r0, 0x8 @@ -782,7 +782,7 @@ _08175BB8: movs r1, 0x6 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_8175BD8 str r0, [r4] _08175BCC: @@ -799,7 +799,7 @@ sub_8175BD8: @ 8175BD8 sub sp, 0x4 lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -817,7 +817,7 @@ sub_8175BD8: @ 8175BD8 movs r1, 0 movs r2, 0 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r1, =gTasks lsls r0, r5, 2 adds r0, r5 @@ -842,7 +842,7 @@ sub_8175C34: @ 8175C34 sub sp, 0x4 lsls r0, 24 lsrs r2, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -871,7 +871,7 @@ _08175C62: movs r1, 0x8 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_8175CC8 str r0, [r4] b _08175CB8 @@ -906,7 +906,7 @@ _08175CB8: thumb_func_start sub_8175CC8 sub_8175CC8: @ 8175CC8 push {lr} - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -1035,7 +1035,7 @@ _08175DD4: .4byte _08175E00 .4byte _08175FFC _08175E00: - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -1173,7 +1173,7 @@ _08175F1A: movs r1, 0 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade b _0817602A .pool _08175F2C: @@ -1185,7 +1185,7 @@ _08175F32: strh r0, [r5, 0x24] b _0817602A _08175F38: - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -1254,11 +1254,11 @@ _08175FB6: movs r1, 0 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade b _0817602A .pool _08175FC8: - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -2866,7 +2866,7 @@ sub_8176D1C: @ 8176D1C ldr r0, =gIntroCopyright_Pal adds r1, r5, 0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette lsrs r4, 20 lsls r4, 28 lsrs r4, 16 diff --git a/asm/evolution_graphics.s b/asm/evolution_graphics.s index 6003632661..1664079835 100644 --- a/asm/evolution_graphics.s +++ b/asm/evolution_graphics.s @@ -620,7 +620,7 @@ sub_817BEC4: @ 817BEC4 movs r1, 0xA movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_817BF14 str r0, [r5] movs r0, 0x8C @@ -966,8 +966,8 @@ sub_817C174: @ 817C174 adds r5, r0 movs r0, 0 strh r0, [r5, 0x26] - ldr r0, =gUnknown_02037B54 - ldr r1, =gUnknown_02037754 + ldr r0, =gPlttBufferFaded + 0x40 + ldr r1, =gPlttBufferUnfaded + 0x40 movs r2, 0x30 bl CpuSet ldr r0, =0xfff9041c @@ -976,7 +976,7 @@ sub_817C174: @ 817C174 movs r1, 0 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_817C1D4 str r0, [r5] movs r0, 0xCA @@ -1034,7 +1034,7 @@ _0817C224: movs r1, 0x10 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade _0817C234: ldr r0, =gTasks adds r1, r5, r6 @@ -1061,7 +1061,7 @@ sub_817C260: @ 817C260 push {lr} lsls r0, 24 lsrs r2, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -1113,8 +1113,8 @@ sub_817C2B0: @ 817C2B0 adds r5, r0 movs r0, 0 strh r0, [r5, 0x26] - ldr r0, =gUnknown_02037B54 - ldr r1, =gUnknown_02037754 + ldr r0, =gPlttBufferFaded + 0x40 + ldr r1, =gPlttBufferUnfaded + 0x40 movs r2, 0x30 bl CpuSet ldr r0, =0xfff90400 @@ -1123,7 +1123,7 @@ sub_817C2B0: @ 817C2B0 movs r1, 0 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =sub_817C310 str r0, [r5] movs r0, 0xCA @@ -1181,7 +1181,7 @@ _0817C360: movs r1, 0x10 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade _0817C370: ldr r0, =gTasks adds r1, r5, r6 @@ -1312,7 +1312,7 @@ _0817C3BA: ldrb r1, [r2, 0x5] lsrs r1, 4 lsls r1, 5 - ldr r0, =gUnknown_02037D14 + ldr r0, =gPlttBufferFaded + 0x200 mov r10, r0 add r1, r10 add r0, sp, 0x4 diff --git a/asm/field_effect.s b/asm/field_effect.s index 3d704b2f2a..370fdf283b 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -587,7 +587,7 @@ sub_80B5F0C: @ 80B5F0C ldr r0, [r4] adds r1, r5, 0 movs r2, 0x20 - bl decompress_palette + bl LoadCompressedPalette pop {r4,r5} pop {r0} bx r0 @@ -777,7 +777,7 @@ sub_80B609C: @ 80B609C lsrs r2, 24 lsls r3, 24 lsrs r3, 24 - ldr r4, =gUnknown_02037714 + ldr r4, =gPlttBufferUnfaded lsrs r0, 15 adds r4, r0, r4 ldrh r4, [r4] @@ -822,7 +822,7 @@ sub_80B609C: @ 80B609C lsls r4, 26 orrs r4, r6 lsrs r4, 16 - ldr r1, =gUnknown_02037B14 + ldr r1, =gPlttBufferFaded adds r0, r1 strh r4, [r0] pop {r3,r4} @@ -846,7 +846,7 @@ sub_80B6128: @ 80B6128 lsrs r2, 24 lsls r3, 24 lsrs r3, 24 - ldr r4, =gUnknown_02037714 + ldr r4, =gPlttBufferUnfaded lsrs r0, 15 adds r4, r0, r4 ldrh r4, [r4] @@ -883,7 +883,7 @@ sub_80B6128: @ 80B6128 lsls r4, 26 orrs r4, r5 lsrs r4, 16 - ldr r1, =gUnknown_02037B14 + ldr r1, =gPlttBufferFaded adds r0, r1 strh r4, [r0] pop {r3} @@ -2082,7 +2082,7 @@ c3_080843F8: @ 80B6B0C ldrsh r0, [r4, r1] cmp r0, 0 bne _080B6B3E - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -2748,7 +2748,7 @@ sub_80B7050: @ 80B7050 thumb_func_start sub_80B7060 sub_80B7060: @ 80B7060 push {lr} - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -3715,7 +3715,7 @@ sub_80B77F8: @ 80B77F8 thumb_func_start sub_80B7814 sub_80B7814: @ 80B7814 push {lr} - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -4190,7 +4190,7 @@ _080B7BEA: thumb_func_start sub_80B7BF4 sub_80B7BF4: @ 80B7BF4 push {lr} - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -4381,7 +4381,7 @@ _080B7D86: ldrsh r0, [r4, r1] cmp r0, 0 bne _080B7DF8 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -4862,7 +4862,7 @@ _080B817E: sub_80B8198: @ 80B8198 push {r4,lr} adds r4, r0, 0 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -5389,7 +5389,7 @@ sub_80B85F8: @ 80B85F8 ldr r0, =gUnknown_0855B050 movs r1, 0xF0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette adds r0, r4, 0 bl sub_80B8874 ldrh r0, [r6, 0x8] @@ -5783,7 +5783,7 @@ sub_80B8920: @ 80B8920 ldr r0, =gUnknown_0855B370 movs r1, 0xF0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette ldrh r0, [r6, 0x8] adds r0, 0x1 strh r0, [r6, 0x8] @@ -6596,7 +6596,7 @@ sub_80B8F98: @ 80B8F98 ldr r0, =gUnknown_0855B610 movs r1, 0xC0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette movs r0, 0x12 movs r1, 0x78 bl SetGpuReg @@ -7142,7 +7142,7 @@ _080B948E: thumb_func_start sub_80B9494 sub_80B9494: @ 80B9494 push {lr} - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -8141,13 +8141,13 @@ sub_80B9C54: @ 80B9C54 adds r0, r6, 0 movs r1, 0x10 adds r2, r5, 0 - bl sub_80A2A20 + bl BlendPalettes str r5, [sp] adds r0, r6, 0 movs r1, 0 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade adds r0, r4, 0 bl sub_80B9D24 movs r0, 0x57 @@ -8173,7 +8173,7 @@ sub_80B9CDC: @ 80B9CDC adds r4, r0, 0 lsls r1, 24 lsrs r5, r1, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 diff --git a/asm/field_region_map.s b/asm/field_region_map.s index 67fc08a2b0..12411dbf55 100644 --- a/asm/field_region_map.s +++ b/asm/field_region_map.s @@ -89,7 +89,7 @@ sub_8170260: @ 8170260 push {lr} bl LoadOamFromSprites bl ProcessObjectCopyRequests - bl copy_pal_bg_faded_to_pal_ram + bl TransferPlttBuffer pop {r0} bx r0 thumb_func_end sub_8170260 @@ -100,7 +100,7 @@ sub_8170274: @ 8170274 bl sub_8170290 bl CallObjectCallbacks bl PrepareSpritesForOamLoad - bl fade_and_return_progress_probably + bl UpdatePaletteFade bl do_scheduled_bg_tilemap_copies_to_vram pop {r0} bx r0 @@ -205,7 +205,7 @@ _08170358: b _081703D8 .pool _08170380: - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -241,7 +241,7 @@ _081703C0: movs r2, 0 movs r3, 0x10 _081703CC: - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r0, =gUnknown_0203BCD0 ldr r1, [r0] _081703D4: @@ -254,7 +254,7 @@ _081703D8: b _08170416 .pool _081703E8: - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 diff --git a/asm/hall_of_fame.s b/asm/hall_of_fame.s index 8c73e42e51..43a1a86c89 100644 --- a/asm/hall_of_fame.s +++ b/asm/hall_of_fame.s @@ -10,7 +10,7 @@ sub_817354C: @ 817354C push {lr} bl LoadOamFromSprites bl ProcessObjectCopyRequests - bl copy_pal_bg_faded_to_pal_ram + bl TransferPlttBuffer pop {r0} bx r0 thumb_func_end sub_817354C @@ -22,7 +22,7 @@ sub_8173560: @ 8173560 bl RunTextPrinters bl CallObjectCallbacks bl PrepareSpritesForOamLoad - bl fade_and_return_progress_probably + bl UpdatePaletteFade pop {r0} bx r0 thumb_func_end sub_8173560 @@ -104,7 +104,7 @@ _08173620: movs r1, 0 movs r2, 0x10 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade _08173642: ldr r1, =gMain movs r0, 0x87 @@ -116,8 +116,8 @@ _08173642: b _08173688 .pool _0817365C: - bl fade_and_return_progress_probably - ldr r0, =gUnknown_02037FD4 + bl UpdatePaletteFade + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -873,7 +873,7 @@ _08173C78: movs r1, 0 movs r2, 0xC movs r3, 0xC - bl pal_fade_maybe + bl BeginNormalPaletteFade movs r0, 0 ldrsh r1, [r6, r0] lsls r0, r1, 4 @@ -922,7 +922,7 @@ sub_8173D24: @ 8173D24 str r1, [sp] movs r2, 0 movs r3, 0 - bl pal_fade_maybe + bl BeginNormalPaletteFade movs r3, 0 lsls r1, r4, 2 adds r0, r1, r4 @@ -1059,7 +1059,7 @@ _08173E40: movs r1, 0 movs r2, 0xC movs r3, 0xC - bl pal_fade_maybe + bl BeginNormalPaletteFade movs r0, 0 movs r1, 0 bl FillWindowPixelBuffer @@ -1171,7 +1171,7 @@ sub_8173EE4: @ 8173EE4 bl stdpal_get movs r1, 0xE0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette movs r0, 0x78 strh r0, [r4, 0xE] ldr r0, =sub_8173F84 @@ -1294,8 +1294,8 @@ sub_8174060: @ 8174060 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - ldr r0, =gUnknown_02037B14 - ldr r1, =gUnknown_02037714 + ldr r0, =gPlttBufferFaded + ldr r1, =gPlttBufferUnfaded movs r2, 0x80 lsls r2, 2 bl CpuSet @@ -1306,7 +1306,7 @@ sub_8174060: @ 8174060 movs r1, 0x8 movs r2, 0 movs r3, 0x10 - bl pal_fade_maybe + bl BeginNormalPaletteFade ldr r1, =gTasks lsls r0, r4, 2 adds r0, r4 @@ -1329,7 +1329,7 @@ sub_81740B0: @ 81740B0 push {r6,r7} lsls r0, 24 lsrs r7, r0, 24 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -1515,7 +1515,7 @@ _08174280: bl RunTasks bl CallObjectCallbacks bl PrepareSpritesForOamLoad - bl fade_and_return_progress_probably + bl UpdatePaletteFade bl sub_80F9C1C lsls r0, 24 cmp r0, 0 @@ -1845,7 +1845,7 @@ _0817454E: ldr r0, =0xffff0000 ldr r2, =0x000063b0 movs r1, 0xC - bl sub_80A2A20 + bl BlendPalettes ldr r0, =gStringVar1 ldr r1, =gTasks ldr r4, [sp, 0x14] @@ -2001,7 +2001,7 @@ _0817466C: str r0, [r2] ldr r2, =0x000063b0 movs r1, 0xC - bl sub_80A2A5C + bl BlendPalettesUnfaded movs r0, 0xC ldrsh r1, [r6, r0] lsls r0, r1, 2 @@ -2209,8 +2209,8 @@ sub_8174898: @ 8174898 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - ldr r0, =gUnknown_02037B14 - ldr r1, =gUnknown_02037714 + ldr r0, =gPlttBufferFaded + ldr r1, =gPlttBufferUnfaded movs r2, 0x80 lsls r2, 2 bl CpuSet @@ -2958,11 +2958,11 @@ _08174EEA: orrs r3, r0 str r3, [r2, 0x8] ldr r0, [r2, 0x8] - bl sub_80A1A74 + bl ResetPaletteFade ldr r0, =gUnknown_085E54E8 movs r1, 0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette add sp, 0x8 pop {r3} mov r8, r3 diff --git a/asm/intro.s b/asm/intro.s index aff010d546..c7bbbc41f2 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -5619,7 +5619,7 @@ _0816FBB4: lsls r0, 1 ldr r4, =gUnknown_08D85C50 adds r0, r4 - ldr r5, =gUnknown_02037D52 + ldr r5, =gPlttBufferFaded + 0x23E adds r1, r5, 0 movs r2, 0x1 bl CpuSet @@ -5653,7 +5653,7 @@ _0816FC14: lsls r0, 1 ldr r4, =gUnknown_08D85C50 adds r0, r4 - ldr r5, =gUnknown_02037D52 + ldr r5, =gPlttBufferFaded + 0x23E adds r1, r5, 0 movs r2, 0x1 bl CpuSet @@ -5698,7 +5698,7 @@ _0816FC6C: lsls r0, 1 ldr r4, =gUnknown_08D85C50 adds r0, r4 - ldr r5, =gUnknown_02037D52 + ldr r5, =gPlttBufferFaded + 0x23E adds r1, r5, 0 movs r2, 0x1 bl CpuSet diff --git a/asm/intro_credits_graphics.s b/asm/intro_credits_graphics.s index 9a933c66b9..9748ca4b57 100644 --- a/asm/intro_credits_graphics.s +++ b/asm/intro_credits_graphics.s @@ -19,7 +19,7 @@ load_intro_part2_graphics: @ 817B064 ldr r0, =gUnknown_085F06E0 movs r1, 0xF0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette cmp r4, 0 beq _0817B08C cmp r4, 0x1 @@ -35,14 +35,14 @@ _0817B08C: ldr r0, =gUnknown_085F0CFC movs r1, 0 movs r2, 0x60 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F5064 bl LoadCompressedObjectPic ldr r0, =gUnknown_085F1668 movs r1, 0x80 lsls r1, 1 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette bl sub_817B76C b _0817B11E .pool @@ -57,14 +57,14 @@ _0817B0EC: ldr r0, =gUnknown_085F17E4 movs r1, 0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F50EC bl LoadCompressedObjectPic ldr r0, =gUnknown_085F21B0 movs r1, 0x80 lsls r1, 1 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette bl sub_817B788 _0817B11E: ldr r1, =gUnknown_0203BD28 @@ -156,7 +156,7 @@ _0817B214: ldr r0, =gUnknown_085F06E0 movs r1, 0xF0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F0DBC movs r1, 0xC0 lsls r1, 19 @@ -167,7 +167,7 @@ _0817B214: ldr r0, =gUnknown_085F0CFC movs r1, 0 movs r2, 0x60 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F5064 bl LoadCompressedObjectPic ldr r0, =gUnknown_085F16A8 @@ -180,7 +180,7 @@ _0817B270: ldr r0, =gUnknown_085F0700 movs r1, 0xF0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F0DBC movs r1, 0xC0 lsls r1, 19 @@ -191,7 +191,7 @@ _0817B270: ldr r0, =gUnknown_085F0D5C movs r1, 0 movs r2, 0x60 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F5064 bl LoadCompressedObjectPic ldr r0, =gUnknown_085F16A8 @@ -202,7 +202,7 @@ _0817B2A6: movs r1, 0x80 lsls r1, 1 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette bl sub_817B76C b _0817B370 .pool @@ -210,7 +210,7 @@ _0817B2DC: ldr r0, =gUnknown_085F0700 movs r1, 0xF0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F1824 movs r1, 0xC0 lsls r1, 19 @@ -222,14 +222,14 @@ _0817B2DC: adds r0, r4, 0 movs r1, 0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F50EC bl LoadCompressedObjectPic movs r1, 0x80 lsls r1, 1 adds r0, r4, 0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette bl sub_817B788 b _0817B370 .pool @@ -237,7 +237,7 @@ _0817B334: ldr r0, =gUnknown_085F0720 movs r1, 0xF0 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F235C movs r1, 0xC0 lsls r1, 19 @@ -248,14 +248,14 @@ _0817B334: ldr r0, =gUnknown_085F231C movs r1, 0 movs r2, 0x40 - bl gpu_pal_apply + bl LoadPalette ldr r0, =gUnknown_085F5180 bl LoadCompressedObjectPic ldr r0, =gUnknown_085F2548 movs r1, 0x80 lsls r1, 1 movs r2, 0x20 - bl gpu_pal_apply + bl LoadPalette bl sub_817B7A4 _0817B370: ldr r1, =gUnknown_0300301C @@ -479,7 +479,7 @@ _0817B554: ands r0, r2 cmp r0, 0 bne _0817B620 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -489,7 +489,7 @@ _0817B554: ands r2, r0 cmp r2, 0 beq _0817B58C - ldr r2, =gUnknown_02037714 + ldr r2, =gPlttBufferUnfaded ldrh r1, [r2, 0x12] mov r0, sp strh r1, [r0] @@ -497,7 +497,7 @@ _0817B554: b _0817B596 .pool _0817B58C: - ldr r2, =gUnknown_02037714 + ldr r2, =gPlttBufferUnfaded ldrh r1, [r2, 0x14] mov r0, sp strh r1, [r0] @@ -509,11 +509,11 @@ _0817B596: mov r0, sp movs r1, 0x9 movs r2, 0x2 - bl gpu_pal_apply + bl LoadPalette adds r0, r4, 0 movs r1, 0xA movs r2, 0x2 - bl gpu_pal_apply + bl LoadPalette b _0817B620 .pool _0817B5B8: @@ -523,7 +523,7 @@ _0817B5B8: ands r0, r2 cmp r0, 0 bne _0817B620 - ldr r0, =gUnknown_02037FD4 + ldr r0, =gPaletteFade ldrb r1, [r0, 0x7] movs r0, 0x80 ands r0, r1 @@ -556,11 +556,11 @@ _0817B606: mov r0, sp movs r1, 0xC movs r2, 0x2 - bl gpu_pal_apply + bl LoadPalette adds r0, r4, 0 movs r1, 0xD movs r2, 0x2 - bl gpu_pal_apply + bl LoadPalette _0817B620: add sp, 0x4 pop {r4} diff --git a/data/data2.s b/data/data2.s index 24fe6536e1..ba871b516e 100644 --- a/data/data2.s +++ b/data/data2.s @@ -5582,8 +5582,107 @@ gUnknown_085B0830:: @ 85B0830 gUnknown_085B0838:: @ 85B0838 .incbin "baserom.gba", 0x5b0838, 0x4 -gUnknown_085B083C:: @ 85B083C - .incbin "baserom.gba", 0x5b083c, 0x18c + @ todo, label functions from battle_ai.c +sBattleAICmdTable:: @ 85B083C + .4byte 0x08131179 + .4byte 0x081311b9 + .4byte 0x081311f9 + .4byte 0x08131239 + .4byte 0x08131279 + .4byte 0x081312bd + .4byte 0x08131325 + .4byte 0x0813138d + .4byte 0x081313f5 + .4byte 0x0813145d + .4byte 0x081314d1 + .4byte 0x08131545 + .4byte 0x081315b9 + .4byte 0x0813162d + .4byte 0x0813169d + .4byte 0x0813170d + .4byte 0x08131789 + .4byte 0x08131805 + .4byte 0x08131841 + .4byte 0x0813187d + .4byte 0x081318b9 + .4byte 0x081318f5 + .4byte 0x08131949 + .4byte 0x0813199d + .4byte 0x081319f1 + .4byte 0x08131a45 + .4byte 0x08131a89 + .4byte 0x08131acd + .4byte 0x08131b35 + .4byte 0x08131ba1 + .4byte 0x08131c0d + .4byte 0x08131c7d + .4byte 0x08131ced + .4byte 0x08131d5d + .4byte 0x08131d81 + .4byte 0x08131f1d + .4byte 0x08131f49 + .4byte 0x0813214d + .4byte 0x081321a5 + .4byte 0x081321e1 + .4byte 0x0813221d + .4byte 0x08132269 + .4byte 0x081322b5 + .4byte 0x081322b9 + .4byte 0x081322bd + .4byte 0x081323b9 + .4byte 0x081323d5 + .4byte 0x08132401 + .4byte 0x08132615 + .4byte 0x08132701 + .4byte 0x081327d1 + .4byte 0x081327d5 + .4byte 0x081327d9 + .4byte 0x081328b9 + .4byte 0x08132995 + .4byte 0x08132a01 + .4byte 0x08132a4d + .4byte 0x08132a99 + .4byte 0x08132b01 + .4byte 0x08132b69 + .4byte 0x08132bd1 + .4byte 0x08132c39 + .4byte 0x08132d35 + .4byte 0x08132e19 + .4byte 0x08132f49 + .4byte 0x08133021 + .4byte 0x08133119 + .4byte 0x081331fd + .4byte 0x08133285 + .4byte 0x08133315 + .4byte 0x08133329 + .4byte 0x08133389 + .4byte 0x0813339d + .4byte 0x08133495 + .4byte 0x081334ed + .4byte 0x08133539 + .4byte 0x08133585 + .4byte 0x081335ad + .4byte 0x081335f9 + .4byte 0x08133625 + .4byte 0x08133651 + .4byte 0x0813367d + .4byte 0x081336c9 + .4byte 0x081336cd + .4byte 0x081336d1 + .4byte 0x081336d5 + .4byte 0x081336d9 + .4byte 0x081336dd + .4byte 0x081336e1 + .4byte 0x08133711 + .4byte 0x08133731 + .4byte 0x08133755 + .4byte 0x0813382d + .4byte 0x0813387d + .4byte 0x081338cd + .4byte 0x08131eb5 + .4byte 0x0813251d + .4byte 0x0813391d + .4byte 0x08133415 gUnknown_085B09C8:: @ 85B09C8 .incbin "baserom.gba", 0x5b09c8, 0x1c diff --git a/include/battle.h b/include/battle.h index fa42a7b535..741e821e9f 100644 --- a/include/battle.h +++ b/include/battle.h @@ -1,3 +1,6 @@ +#ifndef GUARD_BATTLE_H +#define GUARD_BATTLE_H + #define BATTLE_TYPE_DOUBLE 0x0001 #define BATTLE_TYPE_LINK 0x0002 #define BATTLE_TYPE_WILD 0x0004 @@ -21,4 +24,6 @@ #define AI_ACTION_UNK5 0x0010 #define AI_ACTION_UNK6 0x0020 #define AI_ACTION_UNK7 0x0040 -#define AI_ACTION_UNK8 0x0080 \ No newline at end of file +#define AI_ACTION_UNK8 0x0080 + +#endif diff --git a/include/dma3.h b/include/dma3.h new file mode 100644 index 0000000000..beb00745df --- /dev/null +++ b/include/dma3.h @@ -0,0 +1,23 @@ +#ifndef GUARD_DMA3_H +#define GUARD_DMA3_H + +extern u8 gDma3ManagerLocked; +extern u8 gDma3RequestCursor; + +struct DmaRequestsStruct +{ + /* 0x00 */ u8 *src; + /* 0x04 */ u8 *dest; + /* 0x08 */ u16 size; + /* 0x0A */ u16 mode; + /* 0x0C */ u32 value; +}; + +extern struct DmaRequestsStruct gDma3Requests[128]; + +void ClearDma3Requests(void); +void ProcessDma3Requests(void); +int RequestDma3Copy(void *src, void *dest, u16 size, u8 mode); +int RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode); + +#endif diff --git a/include/m4a.h b/include/m4a.h new file mode 100644 index 0000000000..949403885d --- /dev/null +++ b/include/m4a.h @@ -0,0 +1,18 @@ +#ifndef GUARD_M4A_H +#define GUARD_M4A_H + +#include "gba/m4a_internal.h" + +void m4aSoundVSync(void); + +void m4aSoundInit(void); +void m4aSoundMain(void); +void m4aSongNumStart(u16); +void m4aSongNumStop(u16 n); +void m4aMPlayContinue(struct MusicPlayerInfo *mplayInfo); +void m4aMPlayFadeOut(struct MusicPlayerInfo *mplayInfo, u16 speed); +void m4aMPlayFadeOutTemporarily(struct MusicPlayerInfo *mplayInfo, u16 speed); +void m4aMPlayFadeIn(struct MusicPlayerInfo *mplayInfo, u16 speed); +void m4aMPlayImmInit(struct MusicPlayerInfo *mplayInfo); + +#endif //GUARD_M4A_H diff --git a/include/rtc.h b/include/rtc.h new file mode 100644 index 0000000000..fdc5ad7092 --- /dev/null +++ b/include/rtc.h @@ -0,0 +1,48 @@ +#ifndef GUARD_RTC_UTIL_H +#define GUARD_RTC_UTIL_H + +#include "siirtc.h" + +#define RTC_INIT_ERROR 0x0001 +#define RTC_INIT_WARNING 0x0002 + +#define RTC_ERR_12HOUR_CLOCK 0x0010 +#define RTC_ERR_POWER_FAILURE 0x0020 +#define RTC_ERR_INVALID_YEAR 0x0040 +#define RTC_ERR_INVALID_MONTH 0x0080 +#define RTC_ERR_INVALID_DAY 0x0100 +#define RTC_ERR_INVALID_HOUR 0x0200 +#define RTC_ERR_INVALID_MINUTE 0x0400 +#define RTC_ERR_INVALID_SECOND 0x0800 + +#define RTC_ERR_FLAG_MASK 0x0FF0 + +extern struct Time gLocalTime; + +void RtcDisableInterrupts(void); +void RtcRestoreInterrupts(void); +u32 ConvertBcdToBinary(u8 bcd); +bool8 IsLeapYear(u8 year); +u16 ConvertDateToDayCount(u8 year, u8 month, u8 day); +u16 RtcGetDayCount(struct SiiRtcInfo *rtc); +void RtcInit(void); +u16 RtcGetErrorStatus(void); +void RtcGetInfo(struct SiiRtcInfo *rtc); +void RtcGetDateTime(struct SiiRtcInfo *rtc); +void RtcGetStatus(struct SiiRtcInfo *rtc); +void RtcGetRawInfo(struct SiiRtcInfo *rtc); +u16 RtcCheckInfo(struct SiiRtcInfo *rtc); +void RtcReset(void); +void FormatDecimalTime(u8 *dest, s32 hour, s32 minute, s32 second); +void FormatHexTime(u8 *dest, s32 hour, s32 minute, s32 second); +void FormatHexRtcTime(u8 *dest); +void FormatDecimalDate(u8 *dest, s32 year, s32 month, s32 day); +void FormatHexDate(u8 *dest, s32 year, s32 month, s32 day); +void RtcCalcTimeDifference(struct SiiRtcInfo *rtc, struct Time *result, struct Time *t); +void RtcCalcLocalTime(void); +void RtcInitLocalTimeOffset(s32 hour, s32 minute); +void RtcCalcLocalTimeOffset(s32 days, s32 hours, s32 minutes, s32 seconds); +void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2); +u32 RtcGetMinuteCount(void); + +#endif // GUARD_RTC_UTIL_H diff --git a/src/battle_ai.c b/src/battle_ai.c index 8f3b7cf1e9..37960f401f 100644 --- a/src/battle_ai.c +++ b/src/battle_ai.c @@ -208,7 +208,7 @@ extern void sub_8046E7C(u8, u8); typedef void (*BattleAICmdFunc)(void); -extern const BattleAICmdFunc gUnknown_085B083C[]; +extern const BattleAICmdFunc sBattleAICmdTable[]; extern u8 sub_803FECC(); extern u16 Random(); @@ -810,7 +810,7 @@ void BattleAI_DoAIProcessing(void) break; case AIState_Processing: if (AI_THINKING_STRUCT->moveConsidered != 0) - gUnknown_085B083C[*gAIScriptPtr](); // run AI command. + sBattleAICmdTable[*gAIScriptPtr](); // run AI command. else { AI_THINKING_STRUCT->score[AI_THINKING_STRUCT->movesetIndex] = 0; @@ -877,7 +877,7 @@ void sub_8131160(u8 a) gUnknown_020244A8->unk18->unk44[a] = 0; } -static void BattleAICmd_if_random_less_than(void) +void BattleAICmd_if_random_less_than(void) { u16 random = Random(); @@ -887,7 +887,7 @@ static void BattleAICmd_if_random_less_than(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_random_greater_than(void) +void BattleAICmd_if_random_greater_than(void) { u16 random = Random(); @@ -897,7 +897,7 @@ static void BattleAICmd_if_random_greater_than(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_random_equal(void) +void BattleAICmd_if_random_equal(void) { u16 random = Random(); @@ -907,7 +907,7 @@ static void BattleAICmd_if_random_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_random_not_equal(void) +void BattleAICmd_if_random_not_equal(void) { u16 random = Random(); @@ -917,7 +917,7 @@ static void BattleAICmd_if_random_not_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_score(void) +void BattleAICmd_score(void) { AI_THINKING_STRUCT->score[AI_THINKING_STRUCT->movesetIndex] += gAIScriptPtr[1]; // add the result to the array of the move consider's score. @@ -927,7 +927,7 @@ static void BattleAICmd_score(void) gAIScriptPtr += 2; // AI return. } -static void BattleAICmd_if_hp_less_than(void) +void BattleAICmd_if_hp_less_than(void) { u16 index; @@ -942,7 +942,7 @@ static void BattleAICmd_if_hp_less_than(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_hp_more_than(void) +void BattleAICmd_if_hp_more_than(void) { u16 index; @@ -957,7 +957,7 @@ static void BattleAICmd_if_hp_more_than(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_hp_equal(void) +void BattleAICmd_if_hp_equal(void) { u16 index; @@ -972,7 +972,7 @@ static void BattleAICmd_if_hp_equal(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_hp_not_equal(void) +void BattleAICmd_if_hp_not_equal(void) { u16 index; @@ -987,7 +987,7 @@ static void BattleAICmd_if_hp_not_equal(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_status(void) +void BattleAICmd_if_status(void) { u16 index; u32 arg; @@ -1005,7 +1005,7 @@ static void BattleAICmd_if_status(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_not_status(void) +void BattleAICmd_if_not_status(void) { u16 index; u32 arg; @@ -1023,7 +1023,7 @@ static void BattleAICmd_if_not_status(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_status2(void) +void BattleAICmd_if_status2(void) { u16 index; u32 arg; @@ -1041,7 +1041,7 @@ static void BattleAICmd_if_status2(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_not_status2(void) +void BattleAICmd_if_not_status2(void) { u16 index; u32 arg; @@ -1059,7 +1059,7 @@ static void BattleAICmd_if_not_status2(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_status3(void) +void BattleAICmd_if_status3(void) { u16 index; u32 arg; @@ -1077,7 +1077,7 @@ static void BattleAICmd_if_status3(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_not_status3(void) +void BattleAICmd_if_not_status3(void) { u16 index; u32 arg; @@ -1095,7 +1095,7 @@ static void BattleAICmd_if_not_status3(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_status4(void) +void BattleAICmd_if_status4(void) { u16 index; u32 arg1, arg2; @@ -1114,7 +1114,7 @@ static void BattleAICmd_if_status4(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_not_status4(void) +void BattleAICmd_if_not_status4(void) { u16 index; u32 arg1, arg2; @@ -1133,7 +1133,7 @@ static void BattleAICmd_if_not_status4(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_less_than(void) +void BattleAICmd_if_less_than(void) { if (AI_THINKING_STRUCT->funcResult < gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1141,7 +1141,7 @@ static void BattleAICmd_if_less_than(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_more_than(void) +void BattleAICmd_if_more_than(void) { if (AI_THINKING_STRUCT->funcResult > gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1149,7 +1149,7 @@ static void BattleAICmd_if_more_than(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_equal(void) +void BattleAICmd_if_equal(void) { if (AI_THINKING_STRUCT->funcResult == gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1157,7 +1157,7 @@ static void BattleAICmd_if_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_not_equal(void) +void BattleAICmd_if_not_equal(void) { if (AI_THINKING_STRUCT->funcResult != gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1165,7 +1165,7 @@ static void BattleAICmd_if_not_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_less_than_32(void) +void BattleAICmd_if_less_than_32(void) { u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); @@ -1175,7 +1175,7 @@ static void BattleAICmd_if_less_than_32(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_more_than_32(void) +void BattleAICmd_if_more_than_32(void) { u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); @@ -1185,7 +1185,7 @@ static void BattleAICmd_if_more_than_32(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_equal_32(void) +void BattleAICmd_if_equal_32(void) { u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); @@ -1195,7 +1195,7 @@ static void BattleAICmd_if_equal_32(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_not_equal_32(void) +void BattleAICmd_if_not_equal_32(void) { u8 *temp = AIScriptReadPtr(gAIScriptPtr + 1); @@ -1205,7 +1205,7 @@ static void BattleAICmd_if_not_equal_32(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_move(void) +void BattleAICmd_if_move(void) { u16 move = AIScriptRead16(gAIScriptPtr + 1); @@ -1215,7 +1215,7 @@ static void BattleAICmd_if_move(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_not_move(void) +void BattleAICmd_if_not_move(void) { u16 move = AIScriptRead16(gAIScriptPtr + 1); @@ -1225,7 +1225,7 @@ static void BattleAICmd_if_not_move(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_in_bytes(void) +void BattleAICmd_if_in_bytes(void) { u8 *ptr = AIScriptReadPtr(gAIScriptPtr + 1); @@ -1241,7 +1241,7 @@ static void BattleAICmd_if_in_bytes(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_not_in_bytes(void) +void BattleAICmd_if_not_in_bytes(void) { u8 *ptr = AIScriptReadPtr(gAIScriptPtr + 1); @@ -1257,7 +1257,7 @@ static void BattleAICmd_if_not_in_bytes(void) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); } -static void BattleAICmd_if_in_words(void) +void BattleAICmd_if_in_words(void) { u16 *ptr = (u16 *)AIScriptReadPtr(gAIScriptPtr + 1); @@ -1273,7 +1273,7 @@ static void BattleAICmd_if_in_words(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_not_in_words(void) +void BattleAICmd_if_not_in_words(void) { u16 *ptr = (u16 *)AIScriptReadPtr(gAIScriptPtr + 1); @@ -1289,7 +1289,7 @@ static void BattleAICmd_if_not_in_words(void) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5); } -static void BattleAICmd_if_user_can_damage(void) +void BattleAICmd_if_user_can_damage(void) { s32 i; @@ -1305,7 +1305,7 @@ static void BattleAICmd_if_user_can_damage(void) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); } -static void BattleAICmd_if_user_cant_damage(void) +void BattleAICmd_if_user_cant_damage(void) { s32 i; @@ -1321,13 +1321,13 @@ static void BattleAICmd_if_user_cant_damage(void) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); } -static void BattleAICmd_get_turn_count(void) +void BattleAICmd_get_turn_count(void) { AI_THINKING_STRUCT->funcResult = gUnknown_03005D10[19]; gAIScriptPtr += 1; } -static void BattleAICmd_get_type(void) +void BattleAICmd_get_type(void) { u8 typeVar = gAIScriptPtr[1]; @@ -1369,7 +1369,7 @@ u8 sub_8131E70(u8 index) } } -static void BattleAICmd_unk_5F(void) +void BattleAICmd_unk_5F(void) { u8 index = sub_8131E70(gAIScriptPtr[1]); @@ -1385,14 +1385,14 @@ static void BattleAICmd_unk_5F(void) gAIScriptPtr += 3; } -static void BattleAICmd_get_move_power(void) +void BattleAICmd_get_move_power(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power; gAIScriptPtr += 1; } __attribute__((naked)) // not even going to try. if it doesnt match in ruby, it wont match in emerald (yet). -static void BattleAICmd_is_most_powerful_move(void) +void BattleAICmd_is_most_powerful_move(void) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -1635,7 +1635,7 @@ _08132130:\n\ .syntax divided"); } -static void BattleAICmd_get_move(void) +void BattleAICmd_get_move(void) { if (gAIScriptPtr[1] == USER) AI_THINKING_STRUCT->funcResult = gUnknown_02024248[gPlayerMonIndex]; @@ -1645,7 +1645,7 @@ static void BattleAICmd_get_move(void) gAIScriptPtr += 2; } -static void BattleAICmd_if_arg_equal(void) +void BattleAICmd_if_arg_equal(void) { if (gAIScriptPtr[1] == AI_THINKING_STRUCT->funcResult) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1653,7 +1653,7 @@ static void BattleAICmd_if_arg_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_arg_not_equal(void) +void BattleAICmd_if_arg_not_equal(void) { if (gAIScriptPtr[1] != AI_THINKING_STRUCT->funcResult) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1661,7 +1661,7 @@ static void BattleAICmd_if_arg_not_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_would_go_first(void) +void BattleAICmd_if_would_go_first(void) { if (b_first_side(gPlayerMonIndex, gEnemyMonIndex, 1) == gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1669,7 +1669,7 @@ static void BattleAICmd_if_would_go_first(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_would_not_go_first(void) +void BattleAICmd_if_would_not_go_first(void) { if (b_first_side(gPlayerMonIndex, gEnemyMonIndex, 1) != gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -1677,15 +1677,15 @@ static void BattleAICmd_if_would_not_go_first(void) gAIScriptPtr += 6; } -static void BattleAICmd_nullsub_2A(void) +void BattleAICmd_nullsub_2A(void) { } -static void BattleAICmd_nullsub_2B(void) +void BattleAICmd_nullsub_2B(void) { } -static void BattleAICmd_count_alive_pokemon(void) +void BattleAICmd_count_alive_pokemon(void) { u8 index; u8 var, var2; @@ -1731,19 +1731,19 @@ static void BattleAICmd_count_alive_pokemon(void) gAIScriptPtr += 2; } -static void BattleAICmd_get_considered_move(void) +void BattleAICmd_get_considered_move(void) { AI_THINKING_STRUCT->funcResult = AI_THINKING_STRUCT->moveConsidered; gAIScriptPtr += 1; } -static void BattleAICmd_get_considered_move_effect(void) +void BattleAICmd_get_considered_move_effect(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect; gAIScriptPtr += 1; } -static void BattleAICmd_get_ability(void) +void BattleAICmd_get_ability(void) { u8 index; @@ -1804,7 +1804,7 @@ static void BattleAICmd_get_ability(void) } #ifdef NONMATCHING -static void tai60_unk(void) +void tai60_unk(void) { u8 index = sub_8131E70(gAIScriptPtr[1]); u8 arg2 = gAIScriptPtr[2]; @@ -1880,7 +1880,7 @@ static void tai60_unk(void) } #else __attribute__((naked)) -static void tai60_unk(void) +void tai60_unk(void) { asm(".syntax unified\n\ push {r4-r6,lr}\n\ @@ -2010,7 +2010,7 @@ _08132608:\n\ } #endif -static void BattleAICmd_get_highest_possible_damage(void) +void BattleAICmd_get_highest_possible_damage(void) { s32 i; @@ -2050,7 +2050,7 @@ static void BattleAICmd_get_highest_possible_damage(void) gAIScriptPtr += 1; } -static void BattleAICmd_if_damage_bonus(void) +void BattleAICmd_if_damage_bonus(void) { u8 damageVar; @@ -2086,15 +2086,15 @@ static void BattleAICmd_if_damage_bonus(void) gAIScriptPtr += 6; } -static void BattleAICmd_nullsub_32(void) +void BattleAICmd_nullsub_32(void) { } -static void BattleAICmd_nullsub_33(void) +void BattleAICmd_nullsub_33(void) { } -static void BattleAICmd_if_status_in_party(void) +void BattleAICmd_if_status_in_party(void) { struct Pokemon *party; int i; @@ -2131,7 +2131,7 @@ static void BattleAICmd_if_status_in_party(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_status_not_in_party(void) +void BattleAICmd_if_status_not_in_party(void) { struct Pokemon *party; int i; @@ -2167,7 +2167,7 @@ static void BattleAICmd_if_status_not_in_party(void) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); } -static void BattleAICmd_get_weather(void) +void BattleAICmd_get_weather(void) { if (gBattleWeather & 7) AI_THINKING_STRUCT->funcResult = 1; @@ -2181,7 +2181,7 @@ static void BattleAICmd_get_weather(void) gAIScriptPtr += 1; } -static void BattleAICmd_if_effect(void) +void BattleAICmd_if_effect(void) { if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -2189,7 +2189,7 @@ static void BattleAICmd_if_effect(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_not_effect(void) +void BattleAICmd_if_not_effect(void) { if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect != gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); @@ -2197,7 +2197,7 @@ static void BattleAICmd_if_not_effect(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_stat_level_less_than(void) +void BattleAICmd_if_stat_level_less_than(void) { u32 party; @@ -2212,7 +2212,7 @@ static void BattleAICmd_if_stat_level_less_than(void) gAIScriptPtr += 8; } -static void BattleAICmd_if_stat_level_more_than(void) +void BattleAICmd_if_stat_level_more_than(void) { u32 party; @@ -2227,7 +2227,7 @@ static void BattleAICmd_if_stat_level_more_than(void) gAIScriptPtr += 8; } -static void BattleAICmd_if_stat_level_equal(void) +void BattleAICmd_if_stat_level_equal(void) { u32 party; @@ -2242,7 +2242,7 @@ static void BattleAICmd_if_stat_level_equal(void) gAIScriptPtr += 8; } -static void BattleAICmd_if_stat_level_not_equal(void) +void BattleAICmd_if_stat_level_not_equal(void) { u32 party; @@ -2257,7 +2257,7 @@ static void BattleAICmd_if_stat_level_not_equal(void) gAIScriptPtr += 8; } -static void BattleAICmd_if_can_faint(void) +void BattleAICmd_if_can_faint(void) { if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power < 2) { @@ -2286,7 +2286,7 @@ static void BattleAICmd_if_can_faint(void) gAIScriptPtr += 5; } -static void BattleAICmd_if_cant_faint(void) +void BattleAICmd_if_cant_faint(void) { if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power < 2) { @@ -2313,7 +2313,7 @@ static void BattleAICmd_if_cant_faint(void) gAIScriptPtr += 5; } -static void BattleAICmd_if_has_move(void) +void BattleAICmd_if_has_move(void) { int i; u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2); @@ -2381,7 +2381,7 @@ static void BattleAICmd_if_has_move(void) } } -static void BattleAICmd_if_dont_have_move(void) +void BattleAICmd_if_dont_have_move(void) { int i; u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2); @@ -2425,7 +2425,7 @@ static void BattleAICmd_if_dont_have_move(void) } } -static void BattleAICmd_if_move_effect(void) +void BattleAICmd_if_move_effect(void) { int i; @@ -2458,7 +2458,7 @@ static void BattleAICmd_if_move_effect(void) } } -static void BattleAICmd_if_not_move_effect(void) +void BattleAICmd_if_not_move_effect(void) { int i; @@ -2491,7 +2491,7 @@ static void BattleAICmd_if_not_move_effect(void) } } -static void BattleAICmd_if_last_move_did_damage(void) +void BattleAICmd_if_last_move_did_damage(void) { u8 index; @@ -2523,7 +2523,7 @@ static void BattleAICmd_if_last_move_did_damage(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_encored(void) +void BattleAICmd_if_encored(void) { switch (gAIScriptPtr[1]) { @@ -2549,12 +2549,12 @@ static void BattleAICmd_if_encored(void) } } -static void BattleAICmd_flee(void) +void BattleAICmd_flee(void) { AI_THINKING_STRUCT->aiAction |= (AI_ACTION_UNK1 | AI_ACTION_UNK2 | AI_ACTION_UNK4); // what matters is UNK2 being enabled. } -static void BattleAICmd_if_random_100(void) +void BattleAICmd_if_random_100(void) { u8 safariFleeRate = gUnknown_0202449C[0x7B] * 5; // safari flee rate, from 0-20 @@ -2564,12 +2564,12 @@ static void BattleAICmd_if_random_100(void) gAIScriptPtr += 5; } -static void BattleAICmd_watch(void) +void BattleAICmd_watch(void) { AI_THINKING_STRUCT->aiAction |= (AI_ACTION_UNK1 | AI_ACTION_UNK3 | AI_ACTION_UNK4); // what matters is UNK3 being enabled. } -static void BattleAICmd_get_hold_effect(void) +void BattleAICmd_get_hold_effect(void) { u8 index; u16 status; @@ -2589,7 +2589,7 @@ static void BattleAICmd_get_hold_effect(void) gAIScriptPtr += 2; } -static void tai62_unk(void) +void tai62_unk(void) { u8 index = sub_8131E70(gAIScriptPtr[1]); u16 item; @@ -2610,7 +2610,7 @@ static void tai62_unk(void) gAIScriptPtr += 8; } -static void BattleAICmd_get_gender(void) +void BattleAICmd_get_gender(void) { u8 index; @@ -2624,7 +2624,7 @@ static void BattleAICmd_get_gender(void) gAIScriptPtr += 2; } -static void BattleAICmd_is_first_turn(void) +void BattleAICmd_is_first_turn(void) { u8 index; @@ -2638,7 +2638,7 @@ static void BattleAICmd_is_first_turn(void) gAIScriptPtr += 2; } -static void BattleAICmd_get_stockpile_count(void) +void BattleAICmd_get_stockpile_count(void) { u8 index; @@ -2652,14 +2652,14 @@ static void BattleAICmd_get_stockpile_count(void) gAIScriptPtr += 2; } -static void BattleAICmd_is_double_battle(void) +void BattleAICmd_is_double_battle(void) { AI_THINKING_STRUCT->funcResult = gBattleTypeFlags & BATTLE_TYPE_DOUBLE; gAIScriptPtr += 1; } -static void BattleAICmd_get_item(void) +void BattleAICmd_get_item(void) { u8 index; @@ -2674,28 +2674,28 @@ static void BattleAICmd_get_item(void) gAIScriptPtr += 2; } -static void BattleAICmd_get_move_type_from_result(void) +void BattleAICmd_get_move_type_from_result(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].type; gAIScriptPtr += 1; } -static void BattleAICmd_get_move_power_from_result(void) +void BattleAICmd_get_move_power_from_result(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].power; gAIScriptPtr += 1; } -static void BattleAICmd_get_move_effect_from_result(void) +void BattleAICmd_get_move_effect_from_result(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].effect; gAIScriptPtr += 1; } -static void BattleAICmd_get_protect_count(void) +void BattleAICmd_get_protect_count(void) { u8 index; @@ -2709,48 +2709,48 @@ static void BattleAICmd_get_protect_count(void) gAIScriptPtr += 2; } -static void BattleAICmd_nullsub_52(void) +void BattleAICmd_nullsub_52(void) { } -static void BattleAICmd_nullsub_53(void) +void BattleAICmd_nullsub_53(void) { } -static void BattleAICmd_nullsub_54(void) +void BattleAICmd_nullsub_54(void) { } -static void BattleAICmd_nullsub_55(void) +void BattleAICmd_nullsub_55(void) { } -static void BattleAICmd_nullsub_56(void) +void BattleAICmd_nullsub_56(void) { } -static void BattleAICmd_nullsub_57(void) +void BattleAICmd_nullsub_57(void) { } -static void BattleAICmd_call(void) +void BattleAICmd_call(void) { b_mc_stack_push(gAIScriptPtr + 5); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); } -static void BattleAICmd_jump(void) +void BattleAICmd_jump(void) { gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); } -static void BattleAICmd_end(void) +void BattleAICmd_end(void) { if (b_mc_stack_pop_cursor() == 0) AI_THINKING_STRUCT->aiAction |= AI_ACTION_UNK1; } -static void BattleAICmd_if_level_cond(void) +void BattleAICmd_if_level_cond(void) { switch (gAIScriptPtr[1]) { @@ -2781,7 +2781,7 @@ static void BattleAICmd_if_level_cond(void) } } -static void BattleAICmd_if_taunted(void) +void BattleAICmd_if_taunted(void) { if (gUnknown_020242BC[gEnemyMonIndex].taunt != 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); @@ -2789,7 +2789,7 @@ static void BattleAICmd_if_taunted(void) gAIScriptPtr += 5; } -static void BattleAICmd_if_not_taunted(void) +void BattleAICmd_if_not_taunted(void) { if (gUnknown_020242BC[gEnemyMonIndex].taunt == 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); @@ -2797,7 +2797,7 @@ static void BattleAICmd_if_not_taunted(void) gAIScriptPtr += 5; } -static void tai5E_unk(void) +void tai5E_unk(void) { if((gPlayerMonIndex & 1) == (gEnemyMonIndex & 1)) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); @@ -2805,7 +2805,7 @@ static void tai5E_unk(void) gAIScriptPtr += 5; } -static void tai61_unk(void) +void tai61_unk(void) { u8 index = sub_8131E70(gAIScriptPtr[1]); diff --git a/src/dma3_manager.c b/src/dma3_manager.c index cd080a1720..6d12dec05a 100644 --- a/src/dma3_manager.c +++ b/src/dma3_manager.c @@ -1,19 +1,5 @@ #include "global.h" - -extern u8 gDma3ManagerLocked; -extern u8 gDma3RequestCursor; - -// size is 0x10 -struct DmaRequestsStruct -{ - /* 0x00 */ u8 *src; - /* 0x04 */ u8 *dest; - /* 0x08 */ u16 size; - /* 0x0A */ u16 mode; - /* 0x0C */ u32 value; -}; - -extern struct DmaRequestsStruct gDma3Requests[128]; +#include "dma3.h" void ClearDma3Requests(void) { diff --git a/src/main.c b/src/main.c index a88c378eb6..61280f5a70 100644 --- a/src/main.c +++ b/src/main.c @@ -1,13 +1,34 @@ #include "global.h" #include "main.h" +#include "m4a.h" +#include "rtc.h" +#include "rng.h" +#include "dma3.h" #include "gba/flash_internal.h" -#include "gba/m4a_internal.h" extern u16 GetGpuReg(u8); extern void SetGpuReg(u8, u16); extern void LinkVSync(void); extern void sub_800E174(void); extern void sub_800B9B8(void); +extern void InitGpuRegManager(void); +extern void sub_800E6D0(void); +extern void CheckForFlashMemory(void); +extern void InitMapMusic(void); +extern void ResetBgs(void); +extern void SetDefaultFontsPointer(void); +extern void InitHeap(void *heapStart, u32 heapSize); // malloc.h +extern void rfu_REQ_stopMode(void); +extern void rfu_waitREQComplete(void); +extern bool32 sub_8087634(void); +extern bool32 sub_80875C8(void); +extern void ClearObjectCopyRequests(void); +extern void PlayTimeCounter_Update(void); +extern void MapMusicMain(void); +extern void EnableInterrupts(u16); +extern void sub_8033648(void); +extern u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void)); +extern void remove_some_task(void); extern struct SoundInfo gSoundInfo; extern u32 gFlashMemoryPresent; @@ -79,6 +100,7 @@ static void SeedRngWithRtc(void); static void ReadKeys(void); void InitIntrHandlers(void); static void WaitForVBlank(void); +void EnableVCountIntrAtLine150(void); #define B_START_SELECT (B_BUTTON | START_BUTTON | SELECT_BUTTON) diff --git a/src/palette.c b/src/palette.c index 6f5dfff245..538429a696 100644 --- a/src/palette.c +++ b/src/palette.c @@ -1221,7 +1221,6 @@ void sub_80A2D54(u8 a1) { s16 *v2; u32 v3; - u16 v4; u16 v5; s32 v6; u16 v7;