diff --git a/Makefile b/Makefile index 22f9cb452..65a4aa7bd 100644 --- a/Makefile +++ b/Makefile @@ -165,6 +165,10 @@ ifeq ($(MODERN),0) @$(MAKE) tidy MODERN=1 endif +ifneq ($(MODERN),0) +$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member +endif + include graphics_file_rules.mk include map_data_rules.mk include spritesheet_rules.mk diff --git a/asm/berry_crush.s b/asm/berry_crush.s index 2c2b55250..8d44c7269 100755 --- a/asm/berry_crush.s +++ b/asm/berry_crush.s @@ -5,9 +5,6 @@ .text - - - thumb_func_start sub_8021A28 sub_8021A28: @ 8021A28 push {r4-r7,lr} diff --git a/asm/pokenav_unk_2.s b/asm/pokenav_unk_2.s deleted file mode 100644 index da83ccf55..000000000 --- a/asm/pokenav_unk_2.s +++ /dev/null @@ -1,2239 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - -@ File centered around AllocSubstruct(2) - - - thumb_func_start sub_81C9924 -sub_81C9924: @ 81C9924 - push {lr} - bl sub_81C9958 - adds r1, r0, 0 - cmp r1, 0 - beq _081C9938 - movs r0, 0 - strb r0, [r1, 0xD] - movs r0, 0x1 - b _081C993A -_081C9938: - movs r0, 0 -_081C993A: - pop {r1} - bx r1 - thumb_func_end sub_81C9924 - - thumb_func_start sub_81C9940 -sub_81C9940: @ 81C9940 - push {lr} - bl sub_81C9958 - adds r1, r0, 0 - cmp r1, 0 - beq _081C9952 - movs r0, 0x1 - strb r0, [r1, 0xD] - b _081C9954 -_081C9952: - movs r0, 0 -_081C9954: - pop {r1} - bx r1 - thumb_func_end sub_81C9940 - - thumb_func_start sub_81C9958 -sub_81C9958: @ 81C9958 - push {r4,lr} - ldr r1, =0x0000088c - movs r0, 0x2 - bl AllocSubstruct - adds r4, r0, 0 - cmp r4, 0 - beq _081C997A - movs r0, 0 - strb r0, [r4, 0xC] - ldr r0, =sub_81C9A10 - movs r1, 0x1 - bl CreateLoopedTask - str r0, [r4, 0x4] - ldr r0, =sub_81C99FC - str r0, [r4] -_081C997A: - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81C9958 - - thumb_func_start sub_81C9990 -sub_81C9990: @ 81C9990 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x2 - bl GetSubstructPtr - adds r5, r0, 0 - ldr r0, =gUnknown_086201A0 - lsls r4, 2 - adds r4, r0 - ldr r0, [r4] - movs r1, 0x1 - bl CreateLoopedTask - str r0, [r5, 0x4] - ldr r0, =sub_81C99FC - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C9990 - - thumb_func_start sub_81C99C0 -sub_81C99C0: @ 81C99C0 - push {lr} - movs r0, 0x2 - bl GetSubstructPtr - ldr r0, [r0] - bl _call_via_r0 - pop {r1} - bx r1 - thumb_func_end sub_81C99C0 - - thumb_func_start sub_81C99D4 -sub_81C99D4: @ 81C99D4 - push {r4,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r4, r0, 0 - bl sub_81CA7F4 - ldrb r0, [r4, 0x8] - bl RemoveWindow - bl sub_81C9FEC - bl sub_81CA994 - movs r0, 0x2 - bl FreePokenavSubstruct - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81C99D4 - - thumb_func_start sub_81C99FC -sub_81C99FC: @ 81C99FC - push {lr} - movs r0, 0x2 - bl GetSubstructPtr - ldr r0, [r0, 0x4] - bl IsLoopedTaskActive - pop {r1} - bx r1 - thumb_func_end sub_81C99FC - - thumb_func_start sub_81C9A10 -sub_81C9A10: @ 81C9A10 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - movs r0, 0x2 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x9 - bls _081C9A24 - b _081C9C60 -_081C9A24: - lsls r0, r4, 2 - ldr r1, =_081C9A34 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081C9A34: - .4byte _081C9A5C - .4byte _081C9AEC - .4byte _081C9B30 - .4byte _081C9B88 - .4byte _081C9B9E - .4byte _081C9BA4 - .4byte _081C9BB6 - .4byte _081C9BC0 - .4byte _081C9C0E - .4byte _081C9C4C -_081C9A5C: - ldr r0, =gUnknown_08620194 - movs r1, 0x3 - bl InitBgTemplates - ldr r1, =gPokenavMessageBox_Gfx - movs r0, 0 - str r0, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - adds r1, r5, 0 - adds r1, 0x8C - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, =gPokenavMessageBox_Tilemap - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - ldr r0, =gPokenavMessageBox_Pal - movs r1, 0x10 - movs r2, 0x20 - bl CopyPaletteIntoBufferUnfaded - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgY -_081C9AD6: - movs r0, 0 - b _081C9C62 - .pool -_081C9AEC: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _081C9AFA - b _081C9C5C -_081C9AFA: - ldr r1, =gUnknown_0861FD6C - str r0, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gUnknown_0861FFF4 - movs r0, 0x1 - str r0, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r0, =gUnknown_0861FD4C - movs r1, 0x20 - movs r2, 0x20 - bl CopyPaletteIntoBufferUnfaded - b _081C9AD6 - .pool -_081C9B30: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _081C9B3E - b _081C9C5C -_081C9B3E: - ldr r1, =gUnknown_0861FC98 - str r0, [sp] - movs r0, 0x3 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r1, =gUnknown_0861FCAC - movs r0, 0x1 - str r0, [sp] - movs r0, 0x3 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r0, =gUnknown_0861FC78 - movs r1, 0x30 - movs r2, 0x20 - bl CopyPaletteIntoBufferUnfaded - bl sub_81C9894 - cmp r0, 0x3 - beq _081C9B76 - bl sub_81C9894 - cmp r0, 0x4 - bne _081C9AD6 -_081C9B76: - bl sub_81CA850 - b _081C9AD6 - .pool -_081C9B88: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081C9C5C - bl sub_81CA6E0 - bl sub_81CA7D4 -_081C9B9A: - movs r0, 0x1 - b _081C9C62 -_081C9B9E: - bl sub_81C9FC4 - b _081C9B9A -_081C9BA4: - bl sub_81CA714 - bl sub_81CA02C - bl sub_81CA640 - bl sub_81CA0C8 - b _081C9AD6 -_081C9BB6: - bl sub_81CA7C4 - cmp r0, 0 - bne _081C9C5C - b _081C9B9A -_081C9BC0: - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - ldrb r0, [r5, 0xD] - cmp r0, 0 - beq _081C9BE0 - movs r0, 0x1 - bl sub_81C7AC0 - b _081C9BEC -_081C9BE0: - movs r0, 0x6E - bl PlaySE - movs r0, 0x3 - bl sub_81C7AC0 -_081C9BEC: - bl sub_81C9894 - cmp r0, 0x3 - beq _081C9BFE - cmp r0, 0x4 - bne _081C9C06 - movs r0, 0x7 - bl LoadLeftHeaderGfxForIndex -_081C9BFE: - movs r0, 0x1 - bl LoadLeftHeaderGfxForIndex - b _081C9AD6 -_081C9C06: - movs r0, 0 - bl LoadLeftHeaderGfxForIndex - b _081C9AD6 -_081C9C0E: - bl IsPaletteFadeActive - cmp r0, 0 - bne _081C9C5C - bl sub_81C9894 - cmp r0, 0x3 - beq _081C9C2C - cmp r0, 0x4 - bne _081C9C38 - movs r0, 0x7 - movs r1, 0 - movs r2, 0 - bl sub_81C7FA0 -_081C9C2C: - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl sub_81C7FA0 - b _081C9C42 -_081C9C38: - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl sub_81C7FA0 -_081C9C42: - bl sub_81CA20C - bl titlescreen_0 - b _081C9B9A -_081C9C4C: - bl sub_81CA324 - cmp r0, 0 - bne _081C9C5C - bl sub_81C8010 - cmp r0, 0 - beq _081C9C60 -_081C9C5C: - movs r0, 0x2 - b _081C9C62 -_081C9C60: - movs r0, 0x4 -_081C9C62: - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81C9A10 - - thumb_func_start sub_81C9C6C -sub_81C9C6C: @ 81C9C6C - push {lr} - cmp r0, 0 - beq _081C9C78 - cmp r0, 0x1 - beq _081C9C8E - b _081C9CA2 -_081C9C78: - bl sub_81CAA3C - bl sub_81CA278 - bl sub_81CA714 - movs r0, 0x5 - bl PlaySE - movs r0, 0 - b _081C9CA4 -_081C9C8E: - bl sub_81CA324 - cmp r0, 0 - bne _081C9C9E - bl sub_81CA7C4 - cmp r0, 0 - beq _081C9CA2 -_081C9C9E: - movs r0, 0x2 - b _081C9CA4 -_081C9CA2: - movs r0, 0x4 -_081C9CA4: - pop {r1} - bx r1 - thumb_func_end sub_81C9C6C - - thumb_func_start sub_81C9CA8 -sub_81C9CA8: @ 81C9CA8 - push {lr} - cmp r0, 0x1 - beq _081C9CDC - cmp r0, 0x1 - bgt _081C9CB8 - cmp r0, 0 - beq _081C9CC2 - b _081C9D3C -_081C9CB8: - cmp r0, 0x2 - beq _081C9CFA - cmp r0, 0x3 - beq _081C9D14 - b _081C9D3C -_081C9CC2: - bl sub_81CA9C8 - bl sub_81CA2DC - movs r0, 0 - movs r1, 0 - bl sub_81C7FC4 - movs r0, 0x5 - bl PlaySE - movs r0, 0 - b _081C9D3E -_081C9CDC: - bl sub_81CA324 - cmp r0, 0 - bne _081C9D34 - bl sub_81C8010 - cmp r0, 0 - bne _081C9D34 - bl sub_81CA0C8 - movs r0, 0x1 - bl LoadLeftHeaderGfxForIndex - movs r0, 0 - b _081C9D3E -_081C9CFA: - bl sub_81CA20C - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl sub_81C7FA0 - bl sub_81CA818 - bl sub_81CA714 - movs r0, 0 - b _081C9D3E -_081C9D14: - bl sub_81CA324 - cmp r0, 0 - bne _081C9D34 - bl sub_81C8010 - cmp r0, 0 - bne _081C9D34 - bl sub_81CA89C - cmp r0, 0 - bne _081C9D34 - bl sub_81CA7C4 - cmp r0, 0 - beq _081C9D38 -_081C9D34: - movs r0, 0x2 - b _081C9D3E -_081C9D38: - bl sub_81CA9D8 -_081C9D3C: - movs r0, 0x4 -_081C9D3E: - pop {r1} - bx r1 - thumb_func_end sub_81C9CA8 - - thumb_func_start sub_81C9D44 -sub_81C9D44: @ 81C9D44 - push {lr} - cmp r0, 0x1 - beq _081C9D72 - cmp r0, 0x1 - bgt _081C9D54 - cmp r0, 0 - beq _081C9D5E - b _081C9DD2 -_081C9D54: - cmp r0, 0x2 - beq _081C9D90 - cmp r0, 0x3 - beq _081C9DAA - b _081C9DD2 -_081C9D5E: - bl sub_81CA9C8 - bl sub_81CA2DC - movs r0, 0x1 - movs r1, 0 - bl sub_81C7FC4 - movs r0, 0 - b _081C9DD4 -_081C9D72: - bl sub_81CA324 - cmp r0, 0 - bne _081C9DCA - bl sub_81C8010 - cmp r0, 0 - bne _081C9DCA - bl sub_81CA0C8 - movs r0, 0 - bl LoadLeftHeaderGfxForIndex - movs r0, 0 - b _081C9DD4 -_081C9D90: - bl sub_81CA20C - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl sub_81C7FA0 - bl sub_81CA864 - bl sub_81CA714 - movs r0, 0 - b _081C9DD4 -_081C9DAA: - bl sub_81CA324 - cmp r0, 0 - bne _081C9DCA - bl sub_81C8010 - cmp r0, 0 - bne _081C9DCA - bl sub_81CA89C - cmp r0, 0 - bne _081C9DCA - bl sub_81CA7C4 - cmp r0, 0 - beq _081C9DCE -_081C9DCA: - movs r0, 0x2 - b _081C9DD4 -_081C9DCE: - bl sub_81CA9D8 -_081C9DD2: - movs r0, 0x4 -_081C9DD4: - pop {r1} - bx r1 - thumb_func_end sub_81C9D44 - - thumb_func_start sub_81C9DD8 -sub_81C9DD8: @ 81C9DD8 - push {lr} - cmp r0, 0x1 - beq _081C9E04 - cmp r0, 0x1 - bgt _081C9DE8 - cmp r0, 0 - beq _081C9DF2 - b _081C9E50 -_081C9DE8: - cmp r0, 0x2 - beq _081C9E1A - cmp r0, 0x3 - beq _081C9E30 - b _081C9E50 -_081C9DF2: - bl sub_81CA9C8 - bl sub_81CA2DC - movs r0, 0x5 - bl PlaySE - movs r0, 0 - b _081C9E52 -_081C9E04: - bl sub_81CA324 - cmp r0, 0 - bne _081C9E48 - movs r0, 0x7 - bl LoadLeftHeaderGfxForIndex - bl sub_81CA0C8 - movs r0, 0 - b _081C9E52 -_081C9E1A: - bl sub_81CA20C - movs r0, 0x7 - movs r1, 0 - movs r2, 0 - bl sub_81C7FA0 - bl sub_81CA714 - movs r0, 0 - b _081C9E52 -_081C9E30: - bl sub_81CA324 - cmp r0, 0 - bne _081C9E48 - bl sub_81C8010 - cmp r0, 0 - bne _081C9E48 - bl sub_81CA89C - cmp r0, 0 - beq _081C9E4C -_081C9E48: - movs r0, 0x2 - b _081C9E52 -_081C9E4C: - bl sub_81CA9D8 -_081C9E50: - movs r0, 0x4 -_081C9E52: - pop {r1} - bx r1 - thumb_func_end sub_81C9DD8 - - thumb_func_start sub_81C9E58 -sub_81C9E58: @ 81C9E58 - push {lr} - cmp r0, 0x1 - beq _081C9E86 - cmp r0, 0x1 - bgt _081C9E68 - cmp r0, 0 - beq _081C9E72 - b _081C9EC2 -_081C9E68: - cmp r0, 0x2 - beq _081C9E9E - cmp r0, 0x3 - beq _081C9EAA - b _081C9EC2 -_081C9E72: - bl sub_81CA9C8 - bl sub_81CA2DC - movs r0, 0x7 - movs r1, 0 - bl sub_81C7FC4 - movs r0, 0 - b _081C9EC4 -_081C9E86: - bl sub_81CA324 - cmp r0, 0 - bne _081C9EBA - bl sub_81C8010 - cmp r0, 0 - bne _081C9EBA - bl sub_81CA0C8 - movs r0, 0 - b _081C9EC4 -_081C9E9E: - bl sub_81CA20C - bl sub_81CA714 - movs r0, 0 - b _081C9EC4 -_081C9EAA: - bl sub_81CA324 - cmp r0, 0 - bne _081C9EBA - bl sub_81CA89C - cmp r0, 0 - beq _081C9EBE -_081C9EBA: - movs r0, 0x2 - b _081C9EC4 -_081C9EBE: - bl sub_81CA9D8 -_081C9EC2: - movs r0, 0x4 -_081C9EC4: - pop {r1} - bx r1 - thumb_func_end sub_81C9E58 - - thumb_func_start sub_81C9EC8 -sub_81C9EC8: @ 81C9EC8 - push {lr} - cmp r0, 0 - beq _081C9ED4 - cmp r0, 0x1 - beq _081C9EE2 - b _081C9EF0 -_081C9ED4: - movs r0, 0x20 - bl PlaySE - bl sub_81CA770 - movs r0, 0 - b _081C9EF2 -_081C9EE2: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081C9EF0 - movs r0, 0x2 - b _081C9EF2 -_081C9EF0: - movs r0, 0x4 -_081C9EF2: - pop {r1} - bx r1 - thumb_func_end sub_81C9EC8 - - thumb_func_start sub_81C9EF8 -sub_81C9EF8: @ 81C9EF8 - push {lr} - cmp r0, 0 - beq _081C9F04 - cmp r0, 0x1 - beq _081C9F12 - b _081C9F20 -_081C9F04: - movs r0, 0x5 - bl PlaySE - bl sub_81CA714 - movs r0, 0 - b _081C9F22 -_081C9F12: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081C9F20 - movs r0, 0x2 - b _081C9F22 -_081C9F20: - movs r0, 0x4 -_081C9F22: - pop {r1} - bx r1 - thumb_func_end sub_81C9EF8 - - thumb_func_start sub_81C9F28 -sub_81C9F28: @ 81C9F28 - push {lr} - cmp r0, 0x1 - beq _081C9F52 - cmp r0, 0x1 - bgt _081C9F38 - cmp r0, 0 - beq _081C9F42 - b _081C9FBC -_081C9F38: - cmp r0, 0x2 - beq _081C9F96 - cmp r0, 0x3 - beq _081C9FB0 - b _081C9FBC -_081C9F42: - bl sub_81C98C4 - lsls r0, 16 - lsrs r0, 16 - bl sub_81C7BA4 - movs r0, 0 - b _081C9FBE -_081C9F52: - bl IsDma3ManagerBusyWithBgCopy_ - cmp r0, 0 - bne _081C9FB8 - bl sub_81C7880 - bl sub_81CA9C8 - bl sub_81CA2DC - bl sub_81C9894 - cmp r0, 0x3 - beq _081C9F7A - cmp r0, 0x4 - bne _081C9F84 - movs r0, 0x7 - movs r1, 0 - bl sub_81C7FC4 -_081C9F7A: - movs r0, 0x1 - movs r1, 0 - bl sub_81C7FC4 - b _081C9F8C -_081C9F84: - movs r0, 0 - movs r1, 0 - bl sub_81C7FC4 -_081C9F8C: - movs r0, 0x5 - bl PlaySE - movs r0, 0 - b _081C9FBE -_081C9F96: - bl sub_81CA324 - cmp r0, 0 - bne _081C9FB8 - bl sub_81C8010 - cmp r0, 0 - bne _081C9FB8 - movs r0, 0 - bl sub_81C7AC0 - movs r0, 0 - b _081C9FBE -_081C9FB0: - bl IsPaletteFadeActive - cmp r0, 0 - beq _081C9FBC -_081C9FB8: - movs r0, 0x2 - b _081C9FBE -_081C9FBC: - movs r0, 0x4 -_081C9FBE: - pop {r1} - bx r1 - thumb_func_end sub_81C9F28 - - thumb_func_start sub_81C9FC4 -sub_81C9FC4: @ 81C9FC4 - push {r4,r5,lr} - movs r5, 0 - ldr r4, =gUnknown_086201C4 -_081C9FCA: - adds r0, r4, 0 - bl LoadCompressedSpriteSheet - adds r4, 0x8 - adds r5, 0x1 - cmp r5, 0x1 - bls _081C9FCA - ldr r0, =gUnknown_086201D4 - bl Pokenav_AllocAndLoadPalettes - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C9FC4 - - thumb_func_start sub_81C9FEC -sub_81C9FEC: @ 81C9FEC - push {lr} - movs r0, 0x3 - bl FreeSpriteTilesByTag - movs r0, 0x1 - bl FreeSpriteTilesByTag - movs r0, 0x4 - bl FreeSpritePaletteByTag - movs r0, 0x5 - bl FreeSpritePaletteByTag - movs r0, 0x6 - bl FreeSpritePaletteByTag - movs r0, 0x7 - bl FreeSpritePaletteByTag - movs r0, 0x8 - bl FreeSpritePaletteByTag - movs r0, 0x3 - bl FreeSpritePaletteByTag - bl sub_81CA094 - bl sub_81CA698 - pop {r0} - bx r0 - thumb_func_end sub_81C9FEC - - thumb_func_start sub_81CA02C -sub_81CA02C: @ 81CA02C - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r0, 0x2 - bl GetSubstructPtr - movs r2, 0 - adds r0, 0x2C - mov r8, r0 -_081CA03E: - movs r4, 0 - lsls r0, r2, 2 - lsls r1, r2, 4 - adds r7, r2, 0x1 - adds r0, r2 - lsls r0, 18 - movs r2, 0xA0 - lsls r2, 14 - adds r5, r0, r2 - mov r0, r8 - adds r6, r1, r0 -_081CA054: - ldr r0, =gUnknown_0862034C - movs r1, 0x8C - asrs r2, r5, 16 - movs r3, 0x3 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - stm r6!, {r1} - lsls r0, r4, 5 - strh r0, [r1, 0x24] - adds r4, 0x1 - cmp r4, 0x3 - ble _081CA054 - adds r2, r7, 0 - cmp r2, 0x5 - ble _081CA03E - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA02C - - thumb_func_start sub_81CA094 -sub_81CA094: @ 81CA094 - push {r4-r7,lr} - movs r0, 0x2 - bl GetSubstructPtr - movs r1, 0 - adds r7, r0, 0 - adds r7, 0x2C -_081CA0A2: - lsls r0, r1, 4 - adds r6, r1, 0x1 - adds r4, r0, r7 - movs r5, 0x3 -_081CA0AA: - ldr r0, [r4] - bl FreeSpriteOamMatrix - ldm r4!, {r0} - bl DestroySprite - subs r5, 0x1 - cmp r5, 0 - bge _081CA0AA - adds r1, r6, 0 - cmp r1, 0x5 - ble _081CA0A2 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81CA094 - - thumb_func_start sub_81CA0C8 -sub_81CA0C8: @ 81CA0C8 - push {lr} - bl sub_81C9894 - lsls r2, r0, 3 - subs r2, r0 - lsls r2, 2 - ldr r1, =gUnknown_08620240+4 - adds r0, r2, r1 - subs r1, 0x4 - adds r2, r1 - ldrh r1, [r2] - ldrh r2, [r2, 0x2] - bl sub_81CA0EC - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA0C8 - - thumb_func_start sub_81CA0EC -sub_81CA0EC: @ 81CA0EC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - adds r6, r0, 0 - str r1, [sp, 0x14] - str r2, [sp] - movs r0, 0x2 - bl GetSubstructPtr - mov r10, r0 - movs r0, 0x3 - bl GetSpriteTileStartByTag - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0x4] - movs r1, 0 -_081CA114: - ldr r0, [r6] - cmp r0, 0 - beq _081CA1B0 - movs r5, 0 - lsls r2, r1, 4 - mov r0, r10 - adds r0, 0x2C - lsls r3, r1, 2 - mov r9, r3 - movs r4, 0x10 - add r4, r10 - mov r8, r4 - adds r7, r6, 0x4 - str r7, [sp, 0xC] - ldr r3, [sp, 0x14] - ldr r4, [sp] - adds r3, r4 - str r3, [sp, 0x8] - adds r1, 0x1 - str r1, [sp, 0x10] - adds r4, r2, r0 -_081CA13E: - ldr r3, [r4] - ldr r0, [r6] - ldrh r2, [r0] - ldr r7, [sp, 0x4] - adds r2, r7 - lsls r0, r5, 3 - adds r2, r0 - ldr r1, =0x000003ff - adds r0, r1, 0 - ands r2, r0 - ldrh r0, [r3, 0x4] - ldr r7, =0xfffffc00 - adds r1, r7, 0 - ands r0, r1 - orrs r0, r2 - strh r0, [r3, 0x4] - ldr r0, [r6] - ldrh r0, [r0, 0x2] - adds r0, 0x4 - lsls r0, 16 - lsrs r0, 16 - bl IndexOfSpritePaletteTag - ldr r3, [r4] - lsls r0, 4 - ldrb r2, [r3, 0x5] - movs r1, 0xF - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0x5] - ldr r2, [r4] - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r0, [r4] - mov r1, sp - ldrh r1, [r1, 0x14] - strh r1, [r0, 0x22] - ldr r1, [r4] - movs r0, 0x8C - strh r0, [r1, 0x20] - ldm r4!, {r1} - lsls r0, r5, 5 - strh r0, [r1, 0x24] - adds r5, 0x1 - cmp r5, 0x3 - ble _081CA13E - mov r1, r8 - add r1, r9 - movs r0, 0x1 - b _081CA1EC - .pool -_081CA1B0: - lsls r2, r1, 4 - mov r0, r10 - adds r0, 0x2C - lsls r3, r1, 2 - mov r9, r3 - movs r4, 0x10 - add r4, r10 - mov r8, r4 - adds r6, 0x4 - str r6, [sp, 0xC] - ldr r7, [sp, 0x14] - ldr r3, [sp] - adds r7, r3 - str r7, [sp, 0x8] - adds r1, 0x1 - str r1, [sp, 0x10] - movs r3, 0x4 - adds r2, r0 - movs r5, 0x3 -_081CA1D6: - ldm r2!, {r1} - adds r1, 0x3E - ldrb r0, [r1] - orrs r0, r3 - strb r0, [r1] - subs r5, 0x1 - cmp r5, 0 - bge _081CA1D6 - mov r1, r8 - add r1, r9 - movs r0, 0 -_081CA1EC: - str r0, [r1] - ldr r6, [sp, 0xC] - ldr r4, [sp, 0x8] - str r4, [sp, 0x14] - ldr r1, [sp, 0x10] - cmp r1, 0x5 - ble _081CA114 - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81CA0EC - - thumb_func_start sub_81CA20C -sub_81CA20C: @ 81CA20C - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r0, 0x2 - bl GetSubstructPtr - adds r6, r0, 0 - bl sub_81C98A4 - mov r8, r0 - movs r7, 0 - movs r5, 0 - adds r4, r6, 0 - adds r4, 0x2C -_081CA228: - lsls r0, r5, 2 - adds r1, r6, 0 - adds r1, 0x10 - adds r1, r0 - ldr r0, [r1] - cmp r0, 0 - beq _081CA25C - adds r0, r7, 0 - adds r7, 0x1 - cmp r0, r8 - bne _081CA244 - movs r2, 0x82 - strb r5, [r6, 0xB] - b _081CA246 -_081CA244: - movs r2, 0x8C -_081CA246: - adds r0, r4, 0 - movs r1, 0x80 - lsls r1, 1 - movs r3, 0xC - bl sub_81CA35C - adds r0, r4, 0 - movs r1, 0 - bl sub_81CA448 - b _081CA264 -_081CA25C: - adds r0, r4, 0 - movs r1, 0x1 - bl sub_81CA448 -_081CA264: - adds r4, 0x10 - adds r5, 0x1 - cmp r5, 0x5 - ble _081CA228 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81CA20C - - thumb_func_start sub_81CA278 -sub_81CA278: @ 81CA278 - push {r4,r5,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r4, r0, 0 - bl sub_81C98A4 - adds r3, r0, 0 - movs r2, 0 - movs r5, 0 - ldr r0, [r4, 0x10] - cmp r0, 0 - beq _081CA298 - cmp r5, r3 - beq _081CA2B2 -_081CA296: - adds r5, 0x1 -_081CA298: - adds r2, 0x1 - cmp r2, 0x5 - bgt _081CA2B2 - lsls r0, r2, 2 - adds r1, r4, 0 - adds r1, 0x10 - adds r1, r0 - ldr r0, [r1] - cmp r0, 0 - beq _081CA298 - cmp r5, r3 - bne _081CA296 - adds r5, r2, 0 -_081CA2B2: - ldrb r0, [r4, 0xB] - lsls r0, 4 - adds r0, 0x2C - adds r0, r4, r0 - movs r1, 0x82 - movs r2, 0x8C - movs r3, 0x4 - bl sub_81CA35C - lsls r0, r5, 4 - adds r0, 0x2C - adds r0, r4, r0 - movs r1, 0x8C - movs r2, 0x82 - movs r3, 0x4 - bl sub_81CA35C - strb r5, [r4, 0xB] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81CA278 - - thumb_func_start sub_81CA2DC -sub_81CA2DC: @ 81CA2DC - push {r4-r6,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r6, r0, 0 - movs r5, 0 - adds r4, r6, 0 - adds r4, 0x2C -_081CA2EC: - lsls r0, r5, 2 - adds r1, r6, 0 - adds r1, 0x10 - adds r1, r0 - ldr r0, [r1] - cmp r0, 0 - beq _081CA316 - ldrb r0, [r6, 0xB] - cmp r0, r5 - beq _081CA310 - adds r0, r4, 0 - movs r1, 0x8C - movs r2, 0x80 - lsls r2, 1 - movs r3, 0x8 - bl sub_81CA35C - b _081CA316 -_081CA310: - adds r0, r4, 0 - bl sub_81CA3B4 -_081CA316: - adds r4, 0x10 - adds r5, 0x1 - cmp r5, 0x5 - ble _081CA2EC - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81CA2DC - - thumb_func_start sub_81CA324 -sub_81CA324: @ 81CA324 - push {r4,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r3, r0, 0 - movs r2, 0 - ldr r4, =SpriteCallbackDummy - adds r1, r3, 0 - adds r1, 0x2C -_081CA336: - ldr r0, [r1] - ldr r0, [r0, 0x1C] - cmp r0, r4 - bne _081CA354 - adds r1, 0x10 - adds r2, 0x1 - cmp r2, 0x5 - ble _081CA336 - ldrb r0, [r3, 0xC] - cmp r0, 0 - bne _081CA354 - movs r0, 0 - b _081CA356 - .pool -_081CA354: - movs r0, 0x1 -_081CA356: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CA324 - - thumb_func_start sub_81CA35C -sub_81CA35C: @ 81CA35C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r4, r0, 0 - adds r5, r1, 0 - mov r9, r2 - adds r6, r3, 0 - ldr r0, =sub_81CA474 - mov r8, r0 - subs r0, r2, r5 - lsls r0, 4 - adds r1, r6, 0 - bl __divsi3 - adds r3, r0, 0 - movs r1, 0x3 - lsls r2, r5, 4 -_081CA380: - ldr r0, [r4] - strh r5, [r0, 0x20] - ldr r0, [r4] - strh r6, [r0, 0x2E] - ldr r0, [r4] - strh r3, [r0, 0x30] - ldr r0, [r4] - strh r2, [r0, 0x32] - ldr r0, [r4] - mov r7, r9 - strh r7, [r0, 0x3C] - ldm r4!, {r0} - mov r7, r8 - str r7, [r0, 0x1C] - subs r1, 0x1 - cmp r1, 0 - bge _081CA380 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA35C - - thumb_func_start sub_81CA3B4 -sub_81CA3B4: @ 81CA3B4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r4, r0, 0 - movs r0, 0x2 - bl GetSubstructPtr - adds r7, r0, 0 - movs r5, 0 - mov r8, r5 -_081CA3C8: - ldr r2, [r4] - ldrb r1, [r2, 0x1] - movs r3, 0xD - negs r3, r3 - adds r0, r3, 0 - ands r1, r0 - movs r0, 0x4 - orrs r1, r0 - strb r1, [r2, 0x1] - ldr r2, [r4] - ldrb r0, [r2, 0x1] - movs r1, 0x3 - orrs r0, r1 - strb r0, [r2, 0x1] - ldr r1, [r4] - ldr r0, =sub_81CA4AC - str r0, [r1, 0x1C] - movs r6, 0x8 - strh r6, [r1, 0x2E] - ldr r0, [r4] - mov r1, r8 - strh r1, [r0, 0x30] - ldr r0, [r4] - strh r5, [r0, 0x3C] - ldr r0, [r4] - bl InitSpriteAffineAnim - ldm r4!, {r0} - movs r1, 0 - bl StartSpriteAffineAnim - adds r5, 0x1 - cmp r5, 0x3 - ble _081CA3C8 - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - ldr r0, =sub_81CA580 - movs r1, 0x3 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r6, [r1, 0x8] - ldrb r0, [r7, 0xC] - adds r0, 0x1 - strb r0, [r7, 0xC] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA3B4 - - thumb_func_start sub_81CA448 -sub_81CA448: @ 81CA448 - push {r4-r6,lr} - adds r5, r0, 0 - movs r0, 0x1 - ands r1, r0 - lsls r4, r1, 2 - movs r6, 0x5 - negs r6, r6 - movs r3, 0x3 -_081CA458: - ldm r5!, {r0} - adds r0, 0x3E - ldrb r2, [r0] - adds r1, r6, 0 - ands r1, r2 - orrs r1, r4 - strb r1, [r0] - subs r3, 0x1 - cmp r3, 0 - bge _081CA458 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81CA448 - - thumb_func_start sub_81CA474 -sub_81CA474: @ 81CA474 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x2E] - subs r0, 0x1 - strh r0, [r2, 0x2E] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - beq _081CA49A - ldrh r0, [r2, 0x30] - ldrh r1, [r2, 0x32] - adds r0, r1 - strh r0, [r2, 0x32] - lsls r0, 16 - asrs r0, 20 - strh r0, [r2, 0x20] - b _081CA4A2 -_081CA49A: - ldrh r0, [r2, 0x3C] - strh r0, [r2, 0x20] - ldr r0, =SpriteCallbackDummy - str r0, [r2, 0x1C] -_081CA4A2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA474 - - thumb_func_start sub_81CA4AC -sub_81CA4AC: @ 81CA4AC - push {r4,r5,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x2E] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _081CA574 - movs r0, 0x30 - ldrsh r5, [r4, r0] - cmp r5, 0 - bne _081CA4E2 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - movs r0, 0x80 - lsls r0, 1 - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x24] - ldrh r1, [r4, 0x20] - adds r0, r1 - strh r0, [r4, 0x20] - strh r5, [r4, 0x24] - b _081CA578 -_081CA4E2: - ldrh r0, [r4, 0x32] - adds r0, 0x10 - strh r0, [r4, 0x32] - movs r2, 0x32 - ldrsh r0, [r4, r2] - asrs r1, r0, 3 - adds r0, r1, 0 - subs r0, 0x20 - lsrs r1, r0, 31 - adds r0, r1 - asrs r1, r0, 1 - movs r2, 0x3C - ldrsh r0, [r4, r2] - cmp r0, 0x1 - beq _081CA518 - cmp r0, 0x1 - bgt _081CA50A - cmp r0, 0 - beq _081CA514 - b _081CA526 -_081CA50A: - cmp r0, 0x2 - beq _081CA51C - cmp r0, 0x3 - beq _081CA520 - b _081CA526 -_081CA514: - negs r1, r1 - b _081CA520 -_081CA518: - negs r0, r1 - b _081CA524 -_081CA51C: - strh r1, [r4, 0x24] - b _081CA526 -_081CA520: - lsls r0, r1, 1 - adds r0, r1 -_081CA524: - strh r0, [r4, 0x24] -_081CA526: - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _081CA578 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldrb r1, [r4, 0x1] - lsrs r1, 6 - ldrb r2, [r4, 0x3] - lsrs r2, 6 - adds r0, r4, 0 - movs r3, 0 - bl CalcCenterToCornerVec - ldrb r1, [r4, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - movs r1, 0xD - negs r1, r1 - ands r0, r1 - strb r0, [r4, 0x1] - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] - b _081CA578 - .pool -_081CA574: - subs r0, r1, 0x1 - strh r0, [r4, 0x2E] -_081CA578: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81CA4AC - - thumb_func_start sub_81CA580 -sub_81CA580: @ 81CA580 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldrh r0, [r4] - movs r1, 0 - ldrsh r2, [r4, r1] - cmp r2, 0 - bne _081CA634 - movs r0, 0x2 - ldrsh r1, [r4, r0] - cmp r1, 0 - beq _081CA5AC - cmp r1, 0x1 - beq _081CA5CC - b _081CA638 - .pool -_081CA5AC: - movs r0, 0x10 - strh r0, [r4, 0x4] - strh r2, [r4, 0x6] - movs r1, 0xFC - lsls r1, 6 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - ldrh r0, [r4, 0x2] - adds r0, 0x1 - strh r0, [r4, 0x2] - b _081CA638 -_081CA5CC: - ldrh r0, [r4, 0x8] - ands r1, r0 - cmp r1, 0 - beq _081CA5E4 - ldrh r0, [r4, 0x4] - subs r0, 0x3 - strh r0, [r4, 0x4] - lsls r0, 16 - cmp r0, 0 - bge _081CA5F6 - strh r2, [r4, 0x4] - b _081CA5F6 -_081CA5E4: - ldrh r0, [r4, 0x6] - adds r0, 0x3 - strh r0, [r4, 0x6] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x10 - ble _081CA5F6 - movs r0, 0x10 - strh r0, [r4, 0x6] -_081CA5F6: - ldrh r1, [r4, 0x6] - lsls r1, 8 - ldrh r0, [r4, 0x4] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xC - bne _081CA638 - movs r0, 0x2 - bl GetSubstructPtr - ldrb r1, [r0, 0xC] - subs r1, 0x1 - strb r1, [r0, 0xC] - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - adds r0, r5, 0 - bl DestroyTask - b _081CA638 -_081CA634: - subs r0, 0x1 - strh r0, [r4] -_081CA638: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81CA580 - - thumb_func_start sub_81CA640 -sub_81CA640: @ 81CA640 - push {r4,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r4, r0, 0 - ldr r0, =gUnknown_0862036C - movs r1, 0x10 - movs r2, 0x60 - movs r3, 0x4 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - str r1, [r4, 0x28] - bl sub_81C98D4 - cmp r0, 0 - beq _081CA684 - ldr r1, [r4, 0x28] - ldr r0, =sub_81CA6AC - str r0, [r1, 0x1C] - b _081CA690 - .pool -_081CA684: - ldr r0, [r4, 0x28] - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_081CA690: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CA640 - - thumb_func_start sub_81CA698 -sub_81CA698: @ 81CA698 - push {lr} - movs r0, 0x2 - bl GetSubstructPtr - ldr r0, [r0, 0x28] - bl DestroySprite - pop {r0} - bx r0 - thumb_func_end sub_81CA698 - - thumb_func_start sub_81CA6AC -sub_81CA6AC: @ 81CA6AC - push {lr} - adds r3, r0, 0 - ldrh r0, [r3, 0x2E] - adds r0, 0x1 - strh r0, [r3, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x8 - ble _081CA6DA - movs r0, 0 - strh r0, [r3, 0x2E] - adds r3, 0x3E - ldrb r2, [r3] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] -_081CA6DA: - pop {r0} - bx r0 - thumb_func_end sub_81CA6AC - - thumb_func_start sub_81CA6E0 -sub_81CA6E0: @ 81CA6E0 - push {r4,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r4, r0, 0 - ldr r0, =gUnknown_086202CC - bl AddWindow - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r0, 24 - bl PutWindowTilemap - ldrb r0, [r4, 0x8] - movs r1, 0x66 - bl FillWindowPixelBuffer - ldrb r0, [r4, 0x8] - movs r1, 0x3 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA6E0 - - thumb_func_start sub_81CA714 -sub_81CA714: @ 81CA714 - push {r4-r6,lr} - sub sp, 0xC - movs r0, 0x2 - bl GetSubstructPtr - adds r5, r0, 0 - bl sub_81C98B4 - ldr r1, =gUnknown_086202D4 - lsls r0, 2 - adds r0, r1 - ldr r6, [r0] - movs r2, 0x1 - negs r2, r2 - movs r0, 0x1 - adds r1, r6, 0 - bl GetStringWidth - adds r4, r0, 0 - ldrb r0, [r5, 0x8] - movs r1, 0x66 - bl FillWindowPixelBuffer - ldrb r0, [r5, 0x8] - movs r2, 0xC0 - subs r2, r4 - lsrs r2, 1 - lsls r2, 24 - lsrs r2, 24 - ldr r1, =gUnknown_0862030C - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r6, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x1 - bl AddTextPrinterParameterized3 - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA714 - - thumb_func_start sub_81CA770 -sub_81CA770: @ 81CA770 - push {r4-r6,lr} - sub sp, 0xC - movs r0, 0x2 - bl GetSubstructPtr - adds r5, r0, 0 - ldr r6, =gText_NoRibbonWinners - movs r2, 0x1 - negs r2, r2 - movs r0, 0x1 - adds r1, r6, 0 - bl GetStringWidth - adds r4, r0, 0 - ldrb r0, [r5, 0x8] - movs r1, 0x66 - bl FillWindowPixelBuffer - ldrb r0, [r5, 0x8] - movs r2, 0xC0 - subs r2, r4 - lsrs r2, 1 - lsls r2, 24 - lsrs r2, 24 - ldr r1, =gUnknown_0862030F - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r6, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x1 - bl AddTextPrinterParameterized3 - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA770 - - thumb_func_start sub_81CA7C4 -sub_81CA7C4: @ 81CA7C4 - push {lr} - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_81CA7C4 - - thumb_func_start sub_81CA7D4 -sub_81CA7D4: @ 81CA7D4 - push {r4,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r4, r0, 0 - ldr r0, =sub_81CA808 - movs r1, 0x2 - bl CreateTask - strb r0, [r4, 0xA] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA7D4 - - thumb_func_start sub_81CA7F4 -sub_81CA7F4: @ 81CA7F4 - push {lr} - movs r0, 0x2 - bl GetSubstructPtr - ldrb r0, [r0, 0xA] - bl DestroyTask - pop {r0} - bx r0 - thumb_func_end sub_81CA7F4 - - thumb_func_start sub_81CA808 -sub_81CA808: @ 81CA808 - push {lr} - movs r0, 0x3 - movs r1, 0x80 - movs r2, 0x1 - bl ChangeBgX - pop {r0} - bx r0 - thumb_func_end sub_81CA808 - - thumb_func_start sub_81CA818 -sub_81CA818: @ 81CA818 - push {r4,r5,lr} - ldr r0, =sub_81CA8B0 - movs r1, 0x3 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =gUnknown_0861FC78 + 2 - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r5, 0 - bl SetWordTaskArg - adds r5, 0xC - adds r0, r4, 0 - movs r1, 0x3 - adds r2, r5, 0 - bl SetWordTaskArg - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA818 - - thumb_func_start sub_81CA850 -sub_81CA850: @ 81CA850 - push {lr} - ldr r0, =gUnknown_0861FC78 + 0xE - movs r1, 0x31 - movs r2, 0x4 - bl CopyPaletteIntoBufferUnfaded - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA850 - - thumb_func_start sub_81CA864 -sub_81CA864: @ 81CA864 - push {r4,r5,lr} - ldr r0, =sub_81CA8B0 - movs r1, 0x3 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =gUnknown_0861FC78 + 0xE - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r5, 0 - bl SetWordTaskArg - subs r5, 0xC - adds r0, r4, 0 - movs r1, 0x3 - adds r2, r5, 0 - bl SetWordTaskArg - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA864 - - thumb_func_start sub_81CA89C -sub_81CA89C: @ 81CA89C - push {lr} - ldr r0, =sub_81CA8B0 - bl FuncIsActiveTask - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CA89C - - thumb_func_start sub_81CA8B0 -sub_81CA8B0: @ 81CA8B0 - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r6, r0, 24 - lsls r4, r6, 2 - adds r4, r6 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - adds r0, r6, 0 - movs r1, 0x1 - bl GetWordTaskArg - adds r5, r0, 0 - adds r0, r6, 0 - movs r1, 0x3 - bl GetWordTaskArg - adds r1, r0, 0 - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - lsls r0, 16 - asrs r0, 16 - str r0, [sp] - add r0, sp, 0x8 - str r0, [sp, 0x4] - adds r0, r5, 0 - movs r2, 0x2 - movs r3, 0xC - bl sub_81C79BC - add r0, sp, 0x8 - movs r1, 0x31 - movs r2, 0x4 - bl LoadPalette - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0xC - bne _081CA908 - adds r0, r6, 0 - bl DestroyTask -_081CA908: - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA8B0 - - thumb_func_start sub_81CA914 -sub_81CA914: @ 81CA914 - push {lr} - bl TransferPlttBuffer - bl LoadOam - bl ProcessSpriteCopyRequests - bl ScanlineEffect_InitHBlankDmaTransfer - pop {r0} - bx r0 - thumb_func_end sub_81CA914 - - thumb_func_start titlescreen_0 -titlescreen_0: @ 81CA92C - push {lr} - movs r0, 0x50 - movs r1, 0x90 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl SetGpuRegBits - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuRegBits - movs r0, 0x4A - movs r1, 0x1F - bl SetGpuRegBits - movs r0, 0x44 - movs r1, 0xA0 - bl SetGpuRegBits - bl ScanlineEffect_Stop - bl sub_81CAA3C - ldr r2, =gUnknown_08620384 - ldr r0, [r2] - ldr r1, [r2, 0x4] - ldr r2, [r2, 0x8] - bl ScanlineEffect_SetParams - ldr r0, =sub_81CA914 - bl SetVBlankCallback_ - ldr r0, =sub_81CA9EC - movs r1, 0x3 - bl CreateTask - pop {r0} - bx r0 - .pool - thumb_func_end titlescreen_0 - - thumb_func_start sub_81CA994 -sub_81CA994: @ 81CA994 - push {lr} - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl ClearGpuRegBits - bl ScanlineEffect_Stop - ldr r0, =sub_81CA9EC - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask - bl SetPokenavVBlankCallback - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA994 - - thumb_func_start sub_81CA9C8 -sub_81CA9C8: @ 81CA9C8 - push {lr} - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r0} - bx r0 - thumb_func_end sub_81CA9C8 - - thumb_func_start sub_81CA9D8 -sub_81CA9D8: @ 81CA9D8 - push {lr} - bl sub_81CAA3C - movs r0, 0x50 - movs r1, 0x90 - bl SetGpuReg - pop {r0} - bx r0 - thumb_func_end sub_81CA9D8 - - thumb_func_start sub_81CA9EC -sub_81CA9EC: @ 81CA9EC - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r2, r1, r0 - ldrh r0, [r2] - adds r0, 0x1 - strh r0, [r2] - lsls r0, 16 - cmp r0, 0 - ble _081CAA30 - movs r0, 0 - strh r0, [r2] - ldrh r0, [r2, 0x2] - adds r0, 0x3 - movs r1, 0x7F - ands r0, r1 - strh r0, [r2, 0x2] - ldr r1, =gSineTable - movs r3, 0x2 - ldrsh r0, [r2, r3] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 16 - asrs r1, 21 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x54 - bl SetGpuReg -_081CAA30: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA9EC - - thumb_func_start sub_81CAA3C -sub_81CAA3C: @ 81CAA3C - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x8 - bl sub_81C9894 - adds r4, r0, 0 - bl sub_81C98A4 - ldr r2, =gUnknown_08620240 - lsls r1, r4, 3 - subs r1, r4 - lsls r1, 2 - adds r1, r2 - ldrh r2, [r1, 0x2] - adds r4, r2, 0 - muls r4, r0 - ldrh r1, [r1] - adds r4, r1 - subs r4, 0x8 - mov r0, sp - movs r6, 0 - strh r6, [r0] - ldr r5, =gScanlineEffectRegBuffers - ldr r0, =0x010000a0 - mov r8, r0 - mov r0, sp - adds r1, r5, 0 - mov r2, r8 - bl CpuSet - mov r0, sp - adds r0, 0x2 - strh r6, [r0] - movs r1, 0xF0 - lsls r1, 3 - adds r1, r5 - mov r9, r1 - mov r2, r8 - bl CpuSet - add r0, sp, 0x4 - ldr r1, =0x000072f0 - adds r6, r1, 0 - strh r6, [r0] - lsls r4, 1 - adds r5, r4, r5 - ldr r1, =0x01000010 - mov r8, r1 - adds r1, r5, 0 - mov r2, r8 - bl CpuSet - mov r0, sp - adds r0, 0x6 - strh r6, [r0] - add r4, r9 - adds r1, r4, 0 - mov r2, r8 - bl CpuSet - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CAA3C - - thumb_func_start sub_81CAADC -sub_81CAADC: @ 81CAADC - push {lr} - bl sub_81CA9C8 - pop {r0} - bx r0 - thumb_func_end sub_81CAADC - - .align 2, 0 @ Don't pad with nop. diff --git a/include/global.h b/include/global.h index eb18682e9..14377d8bb 100644 --- a/include/global.h +++ b/include/global.h @@ -19,16 +19,23 @@ #if defined (__APPLE__) || defined (__CYGWIN__) || defined (_MSC_VER) #define _(x) x #define __(x) x -#define INCBIN_U8 {0} -#define INCBIN_U16 {0} -#define INCBIN_U32 {0} -#define INCBIN_S8 {0} -#define INCBIN_S16 {0} -#define INCBIN_S32 {0} + +// Fool CLion IDE +#define INCBIN(x) {0} +#define INCBIN_U8 INCBIN +#define INCBIN_U16 INCBIN +#define INCBIN_U32 INCBIN +#define INCBIN_S8 INCBIN +#define INCBIN_S16 INCBIN +#define INCBIN_S32 INCBIN #endif // IDE support #define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0])) +// GameFreak used a macro called "NELEMS", as evidenced by +// AgbAssert calls. +#define NELEMS(arr) (sizeof(arr)/sizeof(*(arr))) + #define SWAP(a, b, temp) \ { \ temp = a; \ diff --git a/include/graphics.h b/include/graphics.h index c39ad60b0..d1d99cc8f 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4950,4 +4950,11 @@ extern const u16 gUsePokeblockCondition_Pal[]; extern const u32 gUnknown_08DE34B8[]; extern const u16 gUnknown_08DE3398[]; +// Pokenav +extern const u32 gPokenavMessageBox_Gfx[]; +extern const u32 gPokenavMessageBox_Tilemap[]; +extern const u16 gPokenavMessageBox_Pal[]; +extern const u32 gPokenavOptions_Gfx[]; +extern const u16 gPokenavOptions_Pal[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/pokenav.h b/include/pokenav.h index 380e61dda..31cb5cb17 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -138,6 +138,8 @@ void sub_81C7B40(void); struct Sprite *PauseSpinningPokenavSprite(void); void ResumeSpinningPokenavSprite(void); void sub_81C7E14(u32 arg0); +void sub_81C7FC4(u32 arg0, bool32 arg1); +void sub_81C7880(void); void sub_81C7990(u32 a0, u16 a1); // pokenav_unk_1.c @@ -150,8 +152,15 @@ u32 sub_81C941C(void); void sub_81C9430(void); int sub_81C9894(void); const u8 *sub_81CAF78(int index, u8 *arg1); +int sub_81C98A4(void); +int sub_81C98B4(void); +u16 sub_81C98C4(void); // pokenav_unk_2.c +bool32 sub_81C9924(void); +bool32 sub_81C9940(void); +void sub_81C9990(s32 ltIdx); +bool32 sub_81C99C0(void); void sub_81C99D4(void); void sub_81CAADC(void); diff --git a/include/strings.h b/include/strings.h index 97285b051..f2d3f23ad 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2766,6 +2766,7 @@ extern const u8 gUnknown_085EBE06[]; extern const u8 gUnknown_085EBE19[]; extern const u8 gUnknown_085EBE2D[]; extern const u8 gUnknown_085EBE41[]; +extern const u8 gText_NoRibbonWinners[]; // pokenav_unk_4 extern const u8 gUnknown_085EC017[]; diff --git a/include/trainer_hill.h b/include/trainer_hill.h index ad2713316..e605ac654 100644 --- a/include/trainer_hill.h +++ b/include/trainer_hill.h @@ -24,7 +24,7 @@ const struct WarpEvent* sub_81D6134(u8 warpEventId); u16 LocalIdToHillTrainerId(u8 localId); bool8 GetHillTrainerFlag(u8 eventObjectId); void SetHillTrainerFlag(void); -const u8 *sub_81D62AC(void); +const u8 *GetTrainerHillTrainerScript(void); void FillHillTrainerParty(void); void FillHillTrainersParties(void); u32 sub_81D63C4(void); diff --git a/ld_script.txt b/ld_script.txt index 17d0d0574..1fbd464f7 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -47,292 +47,291 @@ SECTIONS { .text : ALIGN(4) { - asm/crt0.o(.text*); - src/main.o(.text*); - src/alloc.o(.text*); - src/dma3_manager.o(.text*); - src/gpu_regs.o(.text*); - src/bg.o(.text*); - src/blit.o(.text*); - src/window.o(.text*); - src/text.o(.text*); - src/sprite.o(.text*); - src/string_util.o(.text*); - src/link.o(.text*); - src/link_rfu.o(.text*); - src/union_room.o(.text*); - src/mystery_gift.o(.text*); - src/union_room_player_avatar.o(.text*); - src/union_room_battle.o(.text*); - src/mevent2.o(.text*); - src/mevent_801BAAC.o(.text*); - src/mevent_server.o(.text*); - src/mevent_client.o(.text*); - src/mevent_server_helpers.o(.text*); - src/mevent_news.o(.text*); - src/union_room_chat.o(.text*); - src/berry_crush.o(.text*); - asm/berry_crush.o(.text*); - src/berry_powder.o(.text*); - src/dodrio_berry_picking.o(.text*); - src/pokemon_jump.o(.text*); - src/rtc.o(.text*); - src/main_menu.o(.text*); - src/battle_controllers.o(.text*); - src/decompress.o(.text*); - src/rom_8034C54.o(.text*); - src/battle_bg.o(.text*); - src/battle_main.o(.text*); - src/battle_util.o(.text*); - src/battle_script_commands.o(.text*); - src/battle_util2.o(.text*); - src/battle_controller_player.o(.text*); - src/battle_gfx_sfx_util.o(.text*); - src/battle_controller_opponent.o(.text*); - src/battle_ai_switch_items.o(.text*); - src/battle_controller_link_opponent.o(.text*); - src/pokemon.o(.text*); - src/trig.o(.text*); - src/random.o(.text*); - src/util.o(.text*); - src/daycare.o(.text*); - src/egg_hatch.o(.text*); - src/battle_interface.o(.text*); - src/smokescreen.o(.text*); - src/pokeball.o(.text*); - src/load_save.o(.text*); - src/trade.o(.text*); - src/berry_blender.o(.text*); - src/play_time.o(.text*); - src/new_game.o(.text*); - src/overworld.o(.text*); - src/fieldmap.o(.text*); - src/metatile_behavior.o(.text*); - src/field_camera.o(.text*); - src/field_door.o(.text*); - src/field_player_avatar.o(.text*); - src/event_object_movement.o(.text*); - src/field_message_box.o(.text*); - src/event_obj_lock.o(.text*); - src/text_window.o(.text*); - src/script.o(.text*); - src/scrcmd.o(.text*); - src/field_control_avatar.o(.text*); - src/event_data.o(.text*); - src/coord_event_weather.o(.text*); - src/field_tasks.o(.text*); - src/clock.o(.text*); - src/reset_rtc_screen.o(.text*); - src/start_menu.o(.text*); - src/tileset_anims.o(.text*); - src/palette.o(.text*); - src/sound.o(.text*); - src/battle_anim.o(.text*); - src/battle_anim_mons.o(.text*); - src/task.o(.text*); - src/reshow_battle_screen.o(.text*); - src/battle_anim_status_effects.o(.text*); - src/title_screen.o(.text*); - src/field_weather.o(.text*); - src/field_weather_effect.o(.text*); - src/field_screen_effect.o(.text*); - src/battle_setup.o(.text*); - src/cable_club.o(.text*); - src/trainer_see.o(.text*); - src/wild_encounter.o(.text*); - src/field_effect.o(.text*); - src/scanline_effect.o(.text*); - src/option_menu.o(.text*); - src/pokedex.o(.text*); - src/trainer_card.o(.text*); - src/frontier_pass.o(.text*); - src/pokemon_storage_system.o(.text*); - src/pokemon_icon.o(.text*); - src/script_movement.o(.text*); - src/fldeff_cut.o(.text*); - src/mail_data.o(.text*); - src/map_name_popup.o(.text*); - src/item_menu_icons.o(.text*); - src/battle_anim_mon_movement.o(.text*); - src/item.o(.text*); - src/contest.o(.text*); - src/shop.o(.text*); - src/fldeff_escalator.o(.text*); - src/berry.o(.text*); - src/script_menu.o(.text*); - src/naming_screen.o(.text*); - src/money.o(.text*); - src/contest_effect.o(.text*); - src/record_mixing.o(.text*); - src/secret_base.o(.text*); - src/tv.o(.text*); - src/contest_link_80F57C4.o(.text*); - src/script_pokemon_util_80F87D8.o(.text*); - src/field_poison.o(.text*); - src/pokemon_size_record.o(.text*); - src/fldeff_misc.o(.text*); - src/field_special_scene.o(.text*); - src/rotating_gate.o(.text*); - src/safari_zone.o(.text*); - src/contest_link_80FC4F4.o(.text*); - src/item_use.o(.text*); - src/battle_anim_effects_1.o(.text*); - src/battle_anim_effects_2.o(.text*); - src/water.o(.text*); - src/fire.o(.text*); - src/electric.o(.text*); - src/ice.o(.text*); - src/fight.o(.text*); - src/poison.o(.text*); - src/flying.o(.text*); - src/psychic.o(.text*); - src/bug.o(.text*); - src/rock.o(.text*); - src/ghost.o(.text*); - src/dragon.o(.text*); - src/dark.o(.text*); - src/ground.o(.text*); - src/normal.o(.text*); - src/battle_anim_utility_funcs.o(.text*); - src/battle_intro.o(.text*); - src/bike.o(.text*); - src/easy_chat.o(.text*); - src/mon_markings.o(.text*); - src/mauville_old_man.o(.text*); - src/mail.o(.text*); - src/menu_helpers.o(.text*); - src/dewford_trend.o(.text*); - src/heal_location.o(.text*); - src/region_map.o(.text*); - src/contest_painting_effects.o(.text*); - src/decoration.o(.text*); - src/slot_machine.o(.text*); - src/contest_painting.o(.text*); - src/battle_ai_script_commands.o(.text*); - src/trader.o(.text*); - src/starter_choose.o(.text*); - src/wallclock.o(.text*); - src/fldeff_rocksmash.o(.text*); - src/fldeff_dig.o(.text*); - src/pokeblock.o(.text*); - src/fldeff_flash.o(.text*); - src/post_battle_event_funcs.o(.text*); - src/time_events.o(.text*); - src/birch_pc.o(.text*); - src/hof_pc.o(.text*); - src/field_specials.o(.text*); - src/battle_records.o(.text*); - src/pokedex_area_screen.o(.text*); - src/evolution_scene.o(.text*); - src/roulette.o(.text*); - src/pokedex_cry_screen.o(.text*); - src/coins.o(.text*); - src/landmark.o(.text*); - src/fldeff_strength.o(.text*); - src/battle_transition.o(.text*); - src/battle_controller_link_partner.o(.text*); - src/battle_message.o(.text*); - src/cable_car.o(.text*); - src/math_util.o(.text*); - src/roulette_util.o(.text*); - src/rom_81520A8.o(.text*); - src/save.o(.text*); - src/mystery_event_script.o(.text*); - src/field_effect_helpers.o(.text*); - src/contest_ai.o(.text*); - src/battle_anim_sound_tasks.o(.text*); - src/battle_controller_safari.o(.text*); - src/fldeff_sweetscent.o(.text*); - src/battle_anim_effects_3.o(.text*); - src/move_relearner.o(.text*); - src/fldeff_softboiled.o(.text*); - src/decoration_inventory.o(.text*); - src/roamer.o(.text*); - src/battle_tower.o(.text*); - src/use_pokeblock.o(.text*); - src/battle_controller_wally.o(.text*); - src/player_pc.o(.text*); - src/intro.o(.text*); - src/reset_save_heap.o(.text*); - src/field_region_map.o(.text*); - src/battle_anim_special.o(.text*); - src/hall_of_fame.o(.text*); - src/credits.o(.text*); - src/lottery_corner.o(.text*); - src/diploma.o(.text*); - src/berry_tag_screen.o(.text*); - src/mystery_event_menu.o(.text*); - src/save_failed_screen.o(.text*); - src/braille_puzzles.o(.text*); - src/pokeblock_feed.o(.text*); - src/clear_save_data_screen.o(.text*); - src/intro_credits_graphics.o(.text*); - src/evolution_graphics.o(.text*); - src/bard_music.o(.text*); - src/fldeff_teleport.o(.text*); - src/battle_tv.o(.text*); - src/pokemon_animation.o(.text*); - src/recorded_battle.o(.text*); - src/battle_controller_recorded_opponent.o(.text*); - src/battle_controller_recorded_player.o(.text*); - src/trainer_pokemon_sprites.o(.text*); - src/lilycove_lady.o(.text*); - src/battle_dome.o(.text*); - src/battle_palace.o(.text*); - src/match_call.o(.text*); - src/menu.o(.text*); - src/battle_factory_screen.o(.text*); - src/apprentice.o(.text*); - src/frontier_util.o(.text*); - src/battle_arena.o(.text*); - src/battle_factory.o(.text*); - src/battle_pike.o(.text*); - src/mossdeep_gym.o(.text*); - src/battle_pyramid.o(.text*); - src/item_menu.o(.text*); - src/list_menu.o(.text*); - src/dynamic_placeholder_text_util.o(.text*); - src/save_location.o(.text*); - src/item_icon.o(.text*); - src/party_menu.o(.text*); - src/battle_tent.o(.text*); - src/unk_text_util_2.o(.text*); - src/multiboot.o(.text*); - src/unk_81BAD84.o(.text*); - src/battle_controller_player_partner.o(.text*); - src/mirage_tower.o(.text*); - src/berry_fix_program.o(.text*); - src/pokemon_summary_screen.o(.text*); - src/unk_pokedex_area_screen_helper.o(.text*); - src/battle_pyramid_bag.o(.text*); - src/pokenav.o(.text*); - src/pokenav_main_menu.o(.text*); - src/pokenav_match_call_ui.o(.text*); - src/pokenav_unk_1.o(.text*); - src/pokenav_unk_2.o(.text*); - asm/pokenav_unk_2.o(.text*); - src/pokenav_unk_3.o(.text*); - src/pokenav_unk_4.o(.text*); - src/pokenav_unk_5.o(.text*); - src/pokenav_unk_6.o(.text*); - src/pokenav_unk_7.o(.text*); - src/pokenav_unk_8.o(.text*); - asm/pokenav_unk_8.o(.text*); - src/pokenav_unk_9.o(.text*); - asm/pokenav_unk_9.o(.text*); - src/pokenav_unk_10.o(.text*); - src/pokenav_match_call_data.o(.text*); - src/menu_specialized.o(.text*); - src/ereader_helpers.o(.text*); - src/faraway_island.o(.text*); - src/ereader_screen.o(.text*); - src/trainer_hill.o(.text*); - src/rayquaza_scene.o(.text*); - src/walda_phrase.o(.text*); - src/contest_link_81D9DE4.o(.text*); - src/gym_leader_rematch.o(.text*); - src/unk_transition.o(.text*); - src/international_string_util.o(.text*); + asm/crt0.o(.text); + src/main.o(.text); + src/alloc.o(.text); + src/dma3_manager.o(.text); + src/gpu_regs.o(.text); + src/bg.o(.text); + src/blit.o(.text); + src/window.o(.text); + src/text.o(.text); + src/sprite.o(.text); + src/string_util.o(.text); + src/link.o(.text); + src/link_rfu.o(.text); + src/union_room.o(.text); + src/mystery_gift.o(.text); + src/union_room_player_avatar.o(.text); + src/union_room_battle.o(.text); + src/mevent2.o(.text); + src/mevent_801BAAC.o(.text); + src/mevent_server.o(.text); + src/mevent_client.o(.text); + src/mevent_server_helpers.o(.text); + src/mevent_news.o(.text); + src/union_room_chat.o(.text); + src/berry_crush.o(.text); + asm/berry_crush.o(.text); + src/berry_powder.o(.text); + src/dodrio_berry_picking.o(.text); + src/pokemon_jump.o(.text); + src/rtc.o(.text); + src/main_menu.o(.text); + src/battle_controllers.o(.text); + src/decompress.o(.text); + src/rom_8034C54.o(.text); + src/battle_bg.o(.text); + src/battle_main.o(.text); + src/battle_util.o(.text); + src/battle_script_commands.o(.text); + src/battle_util2.o(.text); + src/battle_controller_player.o(.text); + src/battle_gfx_sfx_util.o(.text); + src/battle_controller_opponent.o(.text); + src/battle_ai_switch_items.o(.text); + src/battle_controller_link_opponent.o(.text); + src/pokemon.o(.text); + src/trig.o(.text); + src/random.o(.text); + src/util.o(.text); + src/daycare.o(.text); + src/egg_hatch.o(.text); + src/battle_interface.o(.text); + src/smokescreen.o(.text); + src/pokeball.o(.text); + src/load_save.o(.text); + src/trade.o(.text); + src/berry_blender.o(.text); + src/play_time.o(.text); + src/new_game.o(.text); + src/overworld.o(.text); + src/fieldmap.o(.text); + src/metatile_behavior.o(.text); + src/field_camera.o(.text); + src/field_door.o(.text); + src/field_player_avatar.o(.text); + src/event_object_movement.o(.text); + src/field_message_box.o(.text); + src/event_obj_lock.o(.text); + src/text_window.o(.text); + src/script.o(.text); + src/scrcmd.o(.text); + src/field_control_avatar.o(.text); + src/event_data.o(.text); + src/coord_event_weather.o(.text); + src/field_tasks.o(.text); + src/clock.o(.text); + src/reset_rtc_screen.o(.text); + src/start_menu.o(.text); + src/tileset_anims.o(.text); + src/palette.o(.text); + src/sound.o(.text); + src/battle_anim.o(.text); + src/battle_anim_mons.o(.text); + src/task.o(.text); + src/reshow_battle_screen.o(.text); + src/battle_anim_status_effects.o(.text); + src/title_screen.o(.text); + src/field_weather.o(.text); + src/field_weather_effect.o(.text); + src/field_screen_effect.o(.text); + src/battle_setup.o(.text); + src/cable_club.o(.text); + src/trainer_see.o(.text); + src/wild_encounter.o(.text); + src/field_effect.o(.text); + src/scanline_effect.o(.text); + src/option_menu.o(.text); + src/pokedex.o(.text); + src/trainer_card.o(.text); + src/frontier_pass.o(.text); + src/pokemon_storage_system.o(.text); + src/pokemon_icon.o(.text); + src/script_movement.o(.text); + src/fldeff_cut.o(.text); + src/mail_data.o(.text); + src/map_name_popup.o(.text); + src/item_menu_icons.o(.text); + src/battle_anim_mon_movement.o(.text); + src/item.o(.text); + src/contest.o(.text); + src/shop.o(.text); + src/fldeff_escalator.o(.text); + src/berry.o(.text); + src/script_menu.o(.text); + src/naming_screen.o(.text); + src/money.o(.text); + src/contest_effect.o(.text); + src/record_mixing.o(.text); + src/secret_base.o(.text); + src/tv.o(.text); + src/contest_link_80F57C4.o(.text); + src/script_pokemon_util_80F87D8.o(.text); + src/field_poison.o(.text); + src/pokemon_size_record.o(.text); + src/fldeff_misc.o(.text); + src/field_special_scene.o(.text); + src/rotating_gate.o(.text); + src/safari_zone.o(.text); + src/contest_link_80FC4F4.o(.text); + src/item_use.o(.text); + src/battle_anim_effects_1.o(.text); + src/battle_anim_effects_2.o(.text); + src/water.o(.text); + src/fire.o(.text); + src/electric.o(.text); + src/ice.o(.text); + src/fight.o(.text); + src/poison.o(.text); + src/flying.o(.text); + src/psychic.o(.text); + src/bug.o(.text); + src/rock.o(.text); + src/ghost.o(.text); + src/dragon.o(.text); + src/dark.o(.text); + src/ground.o(.text); + src/normal.o(.text); + src/battle_anim_utility_funcs.o(.text); + src/battle_intro.o(.text); + src/bike.o(.text); + src/easy_chat.o(.text); + src/mon_markings.o(.text); + src/mauville_old_man.o(.text); + src/mail.o(.text); + src/menu_helpers.o(.text); + src/dewford_trend.o(.text); + src/heal_location.o(.text); + src/region_map.o(.text); + src/contest_painting_effects.o(.text); + src/decoration.o(.text); + src/slot_machine.o(.text); + src/contest_painting.o(.text); + src/battle_ai_script_commands.o(.text); + src/trader.o(.text); + src/starter_choose.o(.text); + src/wallclock.o(.text); + src/fldeff_rocksmash.o(.text); + src/fldeff_dig.o(.text); + src/pokeblock.o(.text); + src/fldeff_flash.o(.text); + src/post_battle_event_funcs.o(.text); + src/time_events.o(.text); + src/birch_pc.o(.text); + src/hof_pc.o(.text); + src/field_specials.o(.text); + src/battle_records.o(.text); + src/pokedex_area_screen.o(.text); + src/evolution_scene.o(.text); + src/roulette.o(.text); + src/pokedex_cry_screen.o(.text); + src/coins.o(.text); + src/landmark.o(.text); + src/fldeff_strength.o(.text); + src/battle_transition.o(.text); + src/battle_controller_link_partner.o(.text); + src/battle_message.o(.text); + src/cable_car.o(.text); + src/math_util.o(.text); + src/roulette_util.o(.text); + src/rom_81520A8.o(.text); + src/save.o(.text); + src/mystery_event_script.o(.text); + src/field_effect_helpers.o(.text); + src/contest_ai.o(.text); + src/battle_anim_sound_tasks.o(.text); + src/battle_controller_safari.o(.text); + src/fldeff_sweetscent.o(.text); + src/battle_anim_effects_3.o(.text); + src/move_relearner.o(.text); + src/fldeff_softboiled.o(.text); + src/decoration_inventory.o(.text); + src/roamer.o(.text); + src/battle_tower.o(.text); + src/use_pokeblock.o(.text); + src/battle_controller_wally.o(.text); + src/player_pc.o(.text); + src/intro.o(.text); + src/reset_save_heap.o(.text); + src/field_region_map.o(.text); + src/battle_anim_special.o(.text); + src/hall_of_fame.o(.text); + src/credits.o(.text); + src/lottery_corner.o(.text); + src/diploma.o(.text); + src/berry_tag_screen.o(.text); + src/mystery_event_menu.o(.text); + src/save_failed_screen.o(.text); + src/braille_puzzles.o(.text); + src/pokeblock_feed.o(.text); + src/clear_save_data_screen.o(.text); + src/intro_credits_graphics.o(.text); + src/evolution_graphics.o(.text); + src/bard_music.o(.text); + src/fldeff_teleport.o(.text); + src/battle_tv.o(.text); + src/pokemon_animation.o(.text); + src/recorded_battle.o(.text); + src/battle_controller_recorded_opponent.o(.text); + src/battle_controller_recorded_player.o(.text); + src/trainer_pokemon_sprites.o(.text); + src/lilycove_lady.o(.text); + src/battle_dome.o(.text); + src/battle_palace.o(.text); + src/match_call.o(.text); + src/menu.o(.text); + src/battle_factory_screen.o(.text); + src/apprentice.o(.text); + src/frontier_util.o(.text); + src/battle_arena.o(.text); + src/battle_factory.o(.text); + src/battle_pike.o(.text); + src/mossdeep_gym.o(.text); + src/battle_pyramid.o(.text); + src/item_menu.o(.text); + src/list_menu.o(.text); + src/dynamic_placeholder_text_util.o(.text); + src/save_location.o(.text); + src/item_icon.o(.text); + src/party_menu.o(.text); + src/battle_tent.o(.text); + src/unk_text_util_2.o(.text); + src/multiboot.o(.text); + src/unk_81BAD84.o(.text); + src/battle_controller_player_partner.o(.text); + src/mirage_tower.o(.text); + src/berry_fix_program.o(.text); + src/pokemon_summary_screen.o(.text); + src/unk_pokedex_area_screen_helper.o(.text); + src/battle_pyramid_bag.o(.text); + src/pokenav.o(.text); + src/pokenav_main_menu.o(.text); + src/pokenav_match_call_ui.o(.text); + src/pokenav_unk_1.o(.text); + src/pokenav_unk_2.o(.text); + src/pokenav_unk_3.o(.text); + src/pokenav_unk_4.o(.text); + src/pokenav_unk_5.o(.text); + src/pokenav_unk_6.o(.text); + src/pokenav_unk_7.o(.text); + src/pokenav_unk_8.o(.text); + asm/pokenav_unk_8.o(.text); + src/pokenav_unk_9.o(.text); + asm/pokenav_unk_9.o(.text); + src/pokenav_unk_10.o(.text); + src/pokenav_match_call_data.o(.text); + src/menu_specialized.o(.text); + src/ereader_helpers.o(.text); + src/faraway_island.o(.text); + src/ereader_screen.o(.text); + src/trainer_hill.o(.text); + src/rayquaza_scene.o(.text); + src/walda_phrase.o(.text); + src/contest_link_81D9DE4.o(.text); + src/gym_leader_rematch.o(.text); + src/unk_transition.o(.text); + src/international_string_util.o(.text); } =0 script_data : @@ -351,71 +350,70 @@ SECTIONS { lib_text : ALIGN(4) { - asm/libgcnmultiboot.o(.text*); - asm/m4a_1.o(.text*); - src/m4a.o(.text*); - src/agb_flash.o(.text*); - src/agb_flash_1m.o(.text*); - src/agb_flash_mx.o(.text*); - src/siirtc.o(.text*); - src/librfu_stwi.o(.text*); - src/librfu_intr.o(.text*); - asm/librfu_intr.o(.text*); - src/librfu_rfu.o(.text*); - src/librfu.o(.text*); - asm/librfu.o(.text*); - asm/libagbsyscall.o(.text*); - *libgcc.a:_call_via_rX.o(.text*); - *libgcc.a:_divdi3.o(.text*); - *libgcc.a:_divsi3.o(.text*); - *libgcc.a:_dvmd_tls.o(.text*); - *libgcc.a:_fixunsdfsi.o(.text*); - *libgcc.a:_fixunssfsi.o(.text*); - *libgcc.a:_modsi3.o(.text*); - *libgcc.a:_muldi3.o(.text*); - *libgcc.a:_udivdi3.o(.text*); - *libgcc.a:_udivsi3.o(.text*); - *libgcc.a:_umodsi3.o(.text*); - *libgcc.a:dp-bit.o(.text*); - *libgcc.a:fp-bit.o(.text*); - *libgcc.a:_lshrdi3.o(.text*); - *libgcc.a:_negdi2.o(.text*); - *libc.a:memcpy.o(.text*); - *libc.a:memset.o(.text*); - *libc.a:strcmp.o(.text*); - *libc.a:strcpy.o(.text*); - *libc.a:vfprintf.o(.text*); - *libc.a:vsprintf.o(.text*); - *libc.a:fvwrite.o(.text*); - *libc.a:locale.o(.text*); - *libc.a:findfp.o(.text*); - *libc.a:fflush.o(.text*); - *libc.a:wsetup.o(.text*); - *libc.a:mbtowc_r.o(.text*); - *libc.a:s_isinf.o(.text*); - *libc.a:s_isnan.o(.text*); - *libc.a:memchr.o(.text*); - *libc.a:strlen.o(.text*); - *libc.a:dtoa.o(.text*); - *libc.a:memmove.o(.text*); - *libc.a:stdio.o(.text*); - *libc.a:mprec.o(.text*); - *libc.a:mallocr.o(.text*); - *libc.a:fwalk.o(.text*); - *libc.a:freer.o(.text*); - *libc.a:makebuf.o(.text*); - *libc.a:readr.o(.text*); - *libc.a:writer.o(.text*); - *libc.a:lseekr.o(.text*); - *libc.a:closer.o(.text*); - *libc.a:callocr.o(.text*); - *libc.a:sbrkr.o(.text*); - *libc.a:mlock.o(.text*); - *libc.a:fstatr.o(.text*); - *libc.a:libcfunc.o(.text*); - *libc.a:syscalls.o(.text*); - *libc.a:errno.o(.text*); - src/libisagbprn.o(.text*); + asm/libgcnmultiboot.o(.text); + asm/m4a_1.o(.text); + src/m4a.o(.text); + src/agb_flash.o(.text); + src/agb_flash_1m.o(.text); + src/agb_flash_mx.o(.text); + src/siirtc.o(.text); + src/librfu_stwi.o(.text); + src/librfu_intr.o(.text); + asm/librfu_intr.o(.text); + src/librfu_rfu.o(.text); + asm/librfu.o(.text); + asm/libagbsyscall.o(.text); + *libgcc.a:_call_via_rX.o(.text); + *libgcc.a:_divdi3.o(.text); + *libgcc.a:_divsi3.o(.text); + *libgcc.a:_dvmd_tls.o(.text); + *libgcc.a:_fixunsdfsi.o(.text); + *libgcc.a:_fixunssfsi.o(.text); + *libgcc.a:_modsi3.o(.text); + *libgcc.a:_muldi3.o(.text); + *libgcc.a:_udivdi3.o(.text); + *libgcc.a:_udivsi3.o(.text); + *libgcc.a:_umodsi3.o(.text); + *libgcc.a:dp-bit.o(.text); + *libgcc.a:fp-bit.o(.text); + *libgcc.a:_lshrdi3.o(.text); + *libgcc.a:_negdi2.o(.text); + *libc.a:memcpy.o(.text); + *libc.a:memset.o(.text); + *libc.a:strcmp.o(.text); + *libc.a:strcpy.o(.text); + *libc.a:vfprintf.o(.text); + *libc.a:vsprintf.o(.text); + *libc.a:fvwrite.o(.text); + *libc.a:locale.o(.text); + *libc.a:findfp.o(.text); + *libc.a:fflush.o(.text); + *libc.a:wsetup.o(.text); + *libc.a:mbtowc_r.o(.text); + *libc.a:s_isinf.o(.text); + *libc.a:s_isnan.o(.text); + *libc.a:memchr.o(.text); + *libc.a:strlen.o(.text); + *libc.a:dtoa.o(.text); + *libc.a:memmove.o(.text); + *libc.a:stdio.o(.text); + *libc.a:mprec.o(.text); + *libc.a:mallocr.o(.text); + *libc.a:fwalk.o(.text); + *libc.a:freer.o(.text); + *libc.a:makebuf.o(.text); + *libc.a:readr.o(.text); + *libc.a:writer.o(.text); + *libc.a:lseekr.o(.text); + *libc.a:closer.o(.text); + *libc.a:callocr.o(.text); + *libc.a:sbrkr.o(.text); + *libc.a:mlock.o(.text); + *libc.a:fstatr.o(.text); + *libc.a:libcfunc.o(.text); + *libc.a:syscalls.o(.text); + *libc.a:errno.o(.text); + src/libisagbprn.o(.text); } =0 .rodata : diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 455c38deb..8a41087f5 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -304,7 +304,7 @@ static const u8 *GetInteractedEventObjectScript(struct MapPosition *position, u8 gSpecialVar_Facing = direction; if (InTrainerHill() == TRUE) - script = sub_81D62AC(); + script = GetTrainerHillTrainerScript(); else script = GetEventObjectScriptPointerByEventObjectId(eventObjectId); diff --git a/src/pokenav.c b/src/pokenav.c index 132e4123b..b4b185c84 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -37,21 +37,22 @@ struct UnknownPokenavCallbackStruct void (*unk18)(void); }; +// TODO: Move these to pokenav.h extern bool32 sub_81C9924(void); extern u32 sub_81C99C0(void); -extern void sub_81C9990(int); +extern void sub_81C9990(s32); extern bool32 sub_81C9940(void); extern u32 sub_81CCFD8(void); extern u32 sub_81CD070(void); extern bool32 sub_81CDDD4(void); -extern void sub_81CDE2C(int); +extern void sub_81CDE2C(s32); extern u32 sub_81CDE64(void); extern void sub_81CD1C0(void); extern void sub_81CECA0(void); extern u32 sub_81CEF3C(void); extern u32 sub_81CEFDC(void); extern bool32 sub_81CF330(void); -extern void sub_81CF3A0(int); +extern void sub_81CF3A0(s32); extern u32 sub_81CF3D0(void); extern void sub_81CEFF0(void); extern void sub_81CF3F8(void); diff --git a/src/pokenav_unk_1.c b/src/pokenav_unk_1.c index 96ecf9c8b..336cf49f2 100644 --- a/src/pokenav_unk_1.c +++ b/src/pokenav_unk_1.c @@ -459,7 +459,7 @@ int sub_81C98B4(void) return state->descriptionId; } -int sub_81C98C4(void) +u16 sub_81C98C4(void) { struct Pokenav1Struct *state = GetSubstructPtr(1); return state->helpBarIndex; diff --git a/src/pokenav_unk_2.c b/src/pokenav_unk_2.c index 60aa5ea5e..1c40e146f 100644 --- a/src/pokenav_unk_2.c +++ b/src/pokenav_unk_2.c @@ -1,66 +1,126 @@ #include "global.h" +#include "alloc.h" +#include "decompress.h" #include "bg.h" -#include "gym_leader_rematch.h" +#include "palette.h" +#include "trig.h" +#include "gpu_regs.h" +#include "menu.h" +#include "window.h" #include "pokenav.h" -#include "sprite.h" +#include "graphics.h" +#include "sound.h" +#include "gym_leader_rematch.h" #include "window.h" #include "strings.h" #include "scanline_effect.h" +#include "constants/songs.h" +#include "constants/rgb.h" -extern const u32 gPokenavOptions_Gfx[]; -extern const u16 gPokenavOptions_Pal[]; +// Top Menu -const u16 gUnknown_0861FC78[] = INCBIN_U16("graphics/pokenav/bg.gbapal"); -const u32 gUnknown_0861FC98[] = INCBIN_U32("graphics/pokenav/bg.4bpp.lz"); -const u32 gUnknown_0861FCAC[] = INCBIN_U32("graphics/pokenav/bg.bin.lz"); -const u16 gUnknown_0861FD4C[] = INCBIN_U16("graphics/pokenav/outline.gbapal"); -const u32 gUnknown_0861FD6C[] = INCBIN_U32("graphics/pokenav/outline.4bpp.lz"); -const u32 gUnknown_0861FFF4[] = INCBIN_U32("graphics/pokenav/outline_map.bin.lz"); -const u16 gUnknown_08620104[] = INCBIN_U16("graphics/pokenav/blue_light.gbapal"); -const u32 gUnknown_08620124[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz"); - -const struct BgTemplate gUnknown_08620194[3] = +struct Pokenav2Struct { + bool32 (*callback)(void); + u32 loopedTaskId; + u16 optionDescriptionWindowId; + u8 bg3ScrollTaskId; + u8 cursorPos; + bool8 otherIconsInMotion; + u8 field_00d; + bool32 iconVisible[6]; + struct Sprite * field_028; + struct Sprite * iconSprites[6][4]; + u16 bg1TilemapBuffer[0x400]; +}; + +static struct Pokenav2Struct * sub_81C9958(void); +static bool32 sub_81C99FC(void); +static u32 sub_81C9A10(s32 state); +static u32 sub_81C9C6C(s32 state); +static u32 sub_81C9CA8(s32 state); +static u32 sub_81C9D44(s32 state); +static u32 sub_81C9DD8(s32 state); +static u32 sub_81C9E58(s32 state); +static u32 sub_81C9EC8(s32 state); +static u32 sub_81C9EF8(s32 state); +static u32 sub_81C9F28(s32 state); +static void sub_81C9FC4(void); +static void sub_81C9FEC(void); +static void sub_81CA02C(void); +static void sub_81CA094(void); +static void sub_81CA0C8(void); +static void sub_81CA0EC(const u16 *const * a0, s32 a1, s32 a2); +static void sub_81CA20C(void); +static void sub_81CA278(void); +static void sub_81CA35C(struct Sprite ** sprites, s32 a1, s32 a2, s32 a3); +static void sub_81CA3B4(struct Sprite ** sprites); +static void sub_81CA2DC(void); +static bool32 sub_81CA324(void); +static void sub_81CA448(struct Sprite ** sprites, bool32 a1); +static void sub_81CA474(struct Sprite * sprite); +static void sub_81CA4AC(struct Sprite * sprite); +static void sub_81CA580(u8 taskId); +static void sub_81CA640(void); +static void sub_81CA6AC(struct Sprite * sprite); +static void sub_81CA698(void); +static void sub_81CA6E0(void); +static void sub_81CA714(void); +static void sub_81CA770(void); +static bool32 sub_81CA7C4(void); +static void sub_81CA7D4(void); +static void sub_81CA7F4(void); +static void sub_81CA808(u8 taskId); +static void sub_81CA818(void); +static void sub_81CA850(void); +static void sub_81CA864(void); +static bool32 sub_81CA89C(void); +static void sub_81CA8B0(u8 taskId); +static void sub_81CA92C(void); +static void sub_81CA994(void); +static void sub_81CA9C8(void); +static void sub_81CA9D8(void); +static void sub_81CA9EC(u8 taskId); +static void sub_81CAA3C(void); + +static const u16 gUnknown_0861FC78[] = INCBIN_U16("graphics/pokenav/bg.gbapal"); +static const u32 gUnknown_0861FC98[] = INCBIN_U32("graphics/pokenav/bg.4bpp.lz"); +static const u32 gUnknown_0861FCAC[] = INCBIN_U32("graphics/pokenav/bg.bin.lz"); +static const u16 gUnknown_0861FD4C[] = INCBIN_U16("graphics/pokenav/outline.gbapal"); +static const u32 gUnknown_0861FD6C[] = INCBIN_U32("graphics/pokenav/outline.4bpp.lz"); +static const u32 gUnknown_0861FFF4[] = INCBIN_U32("graphics/pokenav/outline_map.bin.lz"); +static const u16 gUnknown_08620104[] = INCBIN_U16("graphics/pokenav/blue_light.gbapal"); +static const u32 gUnknown_08620124[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz"); + +static const struct BgTemplate gUnknown_08620194[] = { { .bg = 1, .charBaseIndex = 1, - .mapBaseIndex = 0x0F, + .mapBaseIndex = 15, .screenSize = 0, .paletteMode = 0, .priority = 1, - .baseTile = 0 - }, - { + .baseTile = 0x000 + }, { .bg = 2, .charBaseIndex = 2, - .mapBaseIndex = 0x17, + .mapBaseIndex = 23, .screenSize = 0, .paletteMode = 0, .priority = 2, - .baseTile = 0 - }, - { + .baseTile = 0x000 + }, { .bg = 3, .charBaseIndex = 3, - .mapBaseIndex = 0x1F, + .mapBaseIndex = 31, .screenSize = 0, .paletteMode = 0, .priority = 3, - .baseTile = 0 + .baseTile = 0x000 } }; -u32 sub_81C9C6C(s32); -u32 sub_81C9CA8(s32); -u32 sub_81C9D44(s32); -u32 sub_81C9DD8(s32); -u32 sub_81C9E58(s32); -u32 sub_81C9EC8(s32); -u32 sub_81C9EF8(s32); -u32 sub_81C9F28(s32); - -u32 (*const gUnknown_086201A0[])(s32) = -{ +static const LoopedTask gUnknown_086201A0[] = { NULL, sub_81C9C6C, sub_81C9CA8, @@ -72,7 +132,7 @@ u32 (*const gUnknown_086201A0[])(s32) = sub_81C9F28 }; -const struct CompressedSpriteSheet gUnknown_086201C4[] = +static const struct CompressedSpriteSheet gUnknown_086201C4[] = { { .data = gPokenavOptions_Gfx, @@ -86,8 +146,8 @@ const struct CompressedSpriteSheet gUnknown_086201C4[] = } }; - const struct SpritePalette gUnknown_086201D4[] = - { +static const struct SpritePalette gUnknown_086201D4[] = +{ {gPokenavOptions_Pal + 0x00, 4}, {gPokenavOptions_Pal + 0x10, 5}, {gPokenavOptions_Pal + 0x20, 6}, @@ -97,19 +157,19 @@ const struct CompressedSpriteSheet gUnknown_086201C4[] = {} }; -const u16 gUnknown_0862020C[] = {0, 0}; -const u16 gUnknown_08620210[] = {0x20, 1}; -const u16 gUnknown_08620214[] = {0x40, 4}; -const u16 gUnknown_08620218[] = {0x60, 2}; -const u16 gUnknown_0862021C[] = {0x80, 3}; -const u16 gUnknown_08620220[] = {0xA0, 1}; -const u16 gUnknown_08620224[] = {0xC0, 1}; -const u16 gUnknown_08620228[] = {0xE0, 4}; -const u16 gUnknown_0862022C[] = {0x100, 1}; -const u16 gUnknown_08620230[] = {0x120, 2}; -const u16 gUnknown_08620234[] = {0x140, 0}; -const u16 gUnknown_08620238[] = {0x160, 0}; -const u16 gUnknown_0862023C[] = {0x180, 3}; +static const u16 gUnknown_0862020C[] = {0, 0}; +static const u16 gUnknown_08620210[] = {0x20, 1}; +static const u16 gUnknown_08620214[] = {0x40, 4}; +static const u16 gUnknown_08620218[] = {0x60, 2}; +static const u16 gUnknown_0862021C[] = {0x80, 3}; +static const u16 gUnknown_08620220[] = {0xA0, 1}; +static const u16 gUnknown_08620224[] = {0xC0, 1}; +static const u16 gUnknown_08620228[] = {0xE0, 4}; +static const u16 gUnknown_0862022C[] = {0x100, 1}; +static const u16 gUnknown_08620230[] = {0x120, 2}; +static const u16 gUnknown_08620234[] = {0x140, 0}; +static const u16 gUnknown_08620238[] = {0x160, 0}; +static const u16 gUnknown_0862023C[] = {0x180, 3}; struct UnkStruct_08620240 { @@ -118,36 +178,36 @@ struct UnkStruct_08620240 const u16 *unk4[6]; }; -const struct UnkStruct_08620240 gUnknown_08620240[5] = +static const struct UnkStruct_08620240 gUnknown_08620240[5] = { { 0x2A, - 0x14, - {gUnknown_0862020C, gUnknown_08620210, gUnknown_0862021C, NULL, NULL, NULL} + 0x14, + {gUnknown_0862020C, gUnknown_08620210, gUnknown_0862021C} }, { 0x2A, - 0x14, - {gUnknown_0862020C, gUnknown_08620210, gUnknown_08620214, gUnknown_0862021C, NULL, NULL} + 0x14, + {gUnknown_0862020C, gUnknown_08620210, gUnknown_08620214, gUnknown_0862021C} }, { 0x2A, - 0x14, - {gUnknown_0862020C, gUnknown_08620210, gUnknown_08620214, gUnknown_08620218, gUnknown_0862021C, NULL} + 0x14, + {gUnknown_0862020C, gUnknown_08620210, gUnknown_08620214, gUnknown_08620218, gUnknown_0862021C} }, { 0x38, - 0x14, - {gUnknown_08620220, gUnknown_08620224, gUnknown_0862023C, NULL, NULL, NULL} + 0x14, + {gUnknown_08620220, gUnknown_08620224, gUnknown_0862023C} }, { 0x28, - 0x10, - {gUnknown_08620228, gUnknown_0862022C, gUnknown_08620230, gUnknown_08620234, gUnknown_08620238, gUnknown_0862023C} + 0x10, + {gUnknown_08620228, gUnknown_0862022C, gUnknown_08620230, gUnknown_08620234, gUnknown_08620238, gUnknown_0862023C} }, }; -const struct WindowTemplate gUnknown_086202CC = +static const struct WindowTemplate gUnknown_086202CC = { .bg = 1, .tilemapLeft = 3, @@ -158,7 +218,7 @@ const struct WindowTemplate gUnknown_086202CC = .baseBlock = 8 }; -const u8 *const gUnknown_086202D4[] = +static const u8 *const gUnknown_086202D4[] = { gUnknown_085EBCC5, gUnknown_085EBCE8, @@ -176,11 +236,11 @@ const u8 *const gUnknown_086202D4[] = gUnknown_085EBE41 }; -const u8 gUnknown_0862030C[] = {6, 8, 7}; +static const u8 gUnknown_0862030C[] = {6, 8, 7}; -const u8 gUnknown_0862030F[] = {6, 8, 7, 0, 0}; +static const u8 gUnknown_0862030F[] = {6, 8, 7, 0, 0}; -const struct OamData gUnknown_08620314 = +static const struct OamData gUnknown_08620314 = { .y = 0, .affineMode = 0, @@ -194,26 +254,26 @@ const struct OamData gUnknown_08620314 = .paletteNum = 0, }; -const union AffineAnimCmd gUnknown_0862031C[] = +static const union AffineAnimCmd gUnknown_0862031C[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_END, }; -const union AffineAnimCmd gUnknown_0862032C[] = +static const union AffineAnimCmd gUnknown_0862032C[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x10, 0x10, 0, 0x12), AFFINEANIMCMD_END, }; -const union AffineAnimCmd *const gUnknown_08620344[] = +static const union AffineAnimCmd *const gUnknown_08620344[] = { gUnknown_0862031C, - gUnknown_0862032C + gUnknown_0862032C }; -const struct SpriteTemplate gUnknown_0862034C = +static const struct SpriteTemplate gUnknown_0862034C = { .tileTag = 3, .paletteTag = 4, @@ -224,7 +284,7 @@ const struct SpriteTemplate gUnknown_0862034C = .callback = SpriteCallbackDummy, }; -const struct OamData gUnknown_08620364 = +static const struct OamData gUnknown_08620364 = { .y = 0, .affineMode = 0, @@ -238,7 +298,7 @@ const struct OamData gUnknown_08620364 = .paletteNum = 0, }; -const struct SpriteTemplate gUnknown_0862036C = +static const struct SpriteTemplate gUnknown_0862036C = { .tileTag = 1, .paletteTag = 3, @@ -249,25 +309,967 @@ const struct SpriteTemplate gUnknown_0862036C = .callback = SpriteCallbackDummy, }; -const struct ScanlineEffectParams gUnknown_08620384 = +static const struct ScanlineEffectParams gUnknown_08620384 = { (void *)REG_ADDR_WIN0H, - ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, - 1, - 0 + ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, + 1, + 0 }; -bool32 sub_81C98D4(void) +static bool32 sub_81C98D4(void) { s32 i; for (i = 0; i < REMATCH_TABLE_ENTRIES; i++) { if (sub_81CB0C8(i) == gMapHeader.regionMapSectionId - && sub_81CAE08(i) - && gSaveBlock1Ptr->trainerRematches[i]) + && sub_81CAE08(i) + && gSaveBlock1Ptr->trainerRematches[i]) return TRUE; } return FALSE; } + +bool32 sub_81C9924(void) +{ + struct Pokenav2Struct * unk = sub_81C9958(); + + if (unk == NULL) + return FALSE; + + unk->field_00d = 0; + return TRUE; +} + +bool32 sub_81C9940(void) +{ + struct Pokenav2Struct * unk = sub_81C9958(); + + if (unk == NULL) + return FALSE; + + unk->field_00d = 1; + return TRUE; +} + +static struct Pokenav2Struct * sub_81C9958(void) +{ + struct Pokenav2Struct * unk = AllocSubstruct(2, sizeof(struct Pokenav2Struct)); + + if (unk != NULL) + { + unk->otherIconsInMotion = FALSE; + unk->loopedTaskId = CreateLoopedTask(sub_81C9A10, 1); + unk->callback = sub_81C99FC; + } + + return unk; +} + + +void sub_81C9990(s32 ltIdx) +{ + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + unk->loopedTaskId = CreateLoopedTask(gUnknown_086201A0[ltIdx], 1); + unk->callback = sub_81C99FC; +} + +bool32 sub_81C99C0(void) +{ + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + return unk->callback(); +} + +void sub_81C99D4(void) +{ + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + sub_81CA7F4(); + RemoveWindow(unk->optionDescriptionWindowId); + sub_81C9FEC(); + sub_81CA994(); + FreePokenavSubstruct(2); +} + +static bool32 sub_81C99FC(void) +{ + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + return IsLoopedTaskActive(unk->loopedTaskId); +} + +static u32 sub_81C9A10(s32 state) +{ + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + switch (state) + { + case 0: + InitBgTemplates(gUnknown_08620194, ARRAY_COUNT(gUnknown_08620194)); + decompress_and_copy_tile_data_to_vram(1, gPokenavMessageBox_Gfx, 0, 0, 0); + SetBgTilemapBuffer(1, unk->bg1TilemapBuffer); + CopyToBgTilemapBuffer(1, gPokenavMessageBox_Tilemap, 0, 0); + CopyBgTilemapBufferToVram(1); + CopyPaletteIntoBufferUnfaded(gPokenavMessageBox_Pal, 0x10, 0x20); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); + return LT_INC_AND_PAUSE; + case 1: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + decompress_and_copy_tile_data_to_vram(2, gUnknown_0861FD6C, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(2, gUnknown_0861FFF4, 0, 0, 1); + CopyPaletteIntoBufferUnfaded(gUnknown_0861FD4C, 0x20, 0x20); + return LT_INC_AND_PAUSE; + case 2: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + decompress_and_copy_tile_data_to_vram(3, gUnknown_0861FC98, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(3, gUnknown_0861FCAC, 0, 0, 1); + CopyPaletteIntoBufferUnfaded(gUnknown_0861FC78, 0x30, 0x20); + if (sub_81C9894() == 3 || sub_81C9894() == 4) + sub_81CA850(); + return LT_INC_AND_PAUSE; + case 3: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + sub_81CA6E0(); + sub_81CA7D4(); + return LT_INC_AND_CONTINUE; + case 4: + sub_81C9FC4(); + return LT_INC_AND_CONTINUE; + case 5: + sub_81CA714(); + sub_81CA02C(); + sub_81CA640(); + sub_81CA0C8(); + return LT_INC_AND_PAUSE; + case 6: + if (sub_81CA7C4()) + return LT_PAUSE; + return LT_INC_AND_CONTINUE; + case 7: + ShowBg(1); + ShowBg(2); + ShowBg(3); + if (unk->field_00d) + sub_81C7AC0(1); + else + { + PlaySE(SE_PN_ON); + sub_81C7AC0(3); + } + switch (sub_81C9894()) + { + case 4: + LoadLeftHeaderGfxForIndex(7); + // fallthrough + case 3: + LoadLeftHeaderGfxForIndex(1); + break; + default: + LoadLeftHeaderGfxForIndex(0); + break; + } + return LT_INC_AND_PAUSE; + case 8: + if (IsPaletteFadeActive()) + return LT_PAUSE; + switch (sub_81C9894()) + { + case 4: + sub_81C7FA0(7, FALSE, FALSE); + // fallthrough + case 3: + sub_81C7FA0(1, FALSE, FALSE); + break; + default: + sub_81C7FA0(0, FALSE, FALSE); + break; + } + sub_81CA20C(); + sub_81CA92C(); + return LT_INC_AND_CONTINUE; + case 9: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81C9C6C(s32 state) +{ + switch (state) + { + case 0: + sub_81CAA3C(); + sub_81CA278(); + sub_81CA714(); + PlaySE(SE_SELECT); + return LT_INC_AND_PAUSE; + case 1: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81CA7C4()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81C9CA8(s32 state) +{ + switch (state) + { + case 0: + sub_81CA9C8(); + sub_81CA2DC(); + sub_81C7FC4(0, 0); + PlaySE(SE_SELECT); + return LT_INC_AND_PAUSE; + case 1: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + sub_81CA0C8(); + LoadLeftHeaderGfxForIndex(1); + return LT_INC_AND_PAUSE; + case 2: + sub_81CA20C(); + sub_81C7FA0(1, FALSE, FALSE); + sub_81CA818(); + sub_81CA714(); + return LT_INC_AND_PAUSE; + case 3: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + if (sub_81CA89C()) + return LT_PAUSE; + if (sub_81CA7C4()) + return LT_PAUSE; + sub_81CA9D8(); + break; + } + return LT_FINISH; +} + +static u32 sub_81C9D44(s32 state) +{ + switch (state) + { + case 0: + sub_81CA9C8(); + sub_81CA2DC(); + sub_81C7FC4(1, 0); + return LT_INC_AND_PAUSE; + case 1: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + sub_81CA0C8(); + LoadLeftHeaderGfxForIndex(0); + return LT_INC_AND_PAUSE; + case 2: + sub_81CA20C(); + sub_81C7FA0(0, FALSE, FALSE); + sub_81CA864(); + sub_81CA714(); + return LT_INC_AND_PAUSE; + case 3: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + if (sub_81CA89C()) + return LT_PAUSE; + if (sub_81CA7C4()) + return LT_PAUSE; + sub_81CA9D8(); + break; + } + return LT_FINISH; +} + +static u32 sub_81C9DD8(s32 state) +{ + switch (state) + { + case 0: + sub_81CA9C8(); + sub_81CA2DC(); + PlaySE(SE_SELECT); + return LT_INC_AND_PAUSE; + case 1: + if (sub_81CA324()) + return LT_PAUSE; + LoadLeftHeaderGfxForIndex(7); + sub_81CA0C8(); + return LT_INC_AND_PAUSE; + case 2: + sub_81CA20C(); + sub_81C7FA0(7, FALSE, FALSE); + sub_81CA714(); + return LT_INC_AND_PAUSE; + case 3: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + if (sub_81CA89C()) + return LT_PAUSE; + sub_81CA9D8(); + break; + } + return LT_FINISH; +} + +static u32 sub_81C9E58(s32 state) +{ + switch (state) + { + case 0: + sub_81CA9C8(); + sub_81CA2DC(); + sub_81C7FC4(7, 0); + return LT_INC_AND_PAUSE; + case 1: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + sub_81CA0C8(); + return LT_INC_AND_PAUSE; + case 2: + sub_81CA20C(); + sub_81CA714(); + return LT_INC_AND_PAUSE; + case 3: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81CA89C()) + return LT_PAUSE; + sub_81CA9D8(); + break; + } + return LT_FINISH; +} + +static u32 sub_81C9EC8(s32 state) +{ + switch (state) + { + case 0: + PlaySE(SE_HAZURE); + sub_81CA770(); + return LT_INC_AND_PAUSE; + case 1: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81C9EF8(s32 state) +{ + switch (state) + { + case 0: + PlaySE(SE_SELECT); + sub_81CA714(); + return LT_INC_AND_PAUSE; + case 1: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static u32 sub_81C9F28(s32 state) +{ + switch (state) + { + case 0: + sub_81C7BA4(sub_81C98C4()); + return LT_INC_AND_PAUSE; + case 1: + if (IsDma3ManagerBusyWithBgCopy_()) + return LT_PAUSE; + sub_81C7880(); + sub_81CA9C8(); + sub_81CA2DC(); + switch (sub_81C9894()) + { + case 4: + sub_81C7FC4(7, FALSE); + // fallthrough + case 3: + sub_81C7FC4(1, FALSE); + break; + default: + sub_81C7FC4(0, FALSE); + break; + } + PlaySE(SE_SELECT); + return LT_INC_AND_PAUSE; + case 2: + if (sub_81CA324()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + sub_81C7AC0(0); + return LT_INC_AND_PAUSE; + case 3: + if (IsPaletteFadeActive()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +static void sub_81C9FC4(void) +{ + s32 i; + + for (i = 0; i < NELEMS(gUnknown_086201C4); i++) + LoadCompressedSpriteSheet(&gUnknown_086201C4[i]); + Pokenav_AllocAndLoadPalettes(gUnknown_086201D4); +} + +static void sub_81C9FEC(void) +{ + FreeSpriteTilesByTag(3); + FreeSpriteTilesByTag(1); + FreeSpritePaletteByTag(4); + FreeSpritePaletteByTag(5); + FreeSpritePaletteByTag(6); + FreeSpritePaletteByTag(7); + FreeSpritePaletteByTag(8); + FreeSpritePaletteByTag(3); + sub_81CA094(); + sub_81CA698(); +} + +static void sub_81CA02C(void) +{ + s32 i, j; + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + for (i = 0; i < 6; i++) + { + for (j = 0; j < 4; j++) + { + u8 spriteId = CreateSprite(&gUnknown_0862034C, 0x8c, 20 * i + 40, 3); + unk->iconSprites[i][j] = &gSprites[spriteId]; + gSprites[spriteId].pos2.x = 32 * j; + } + } +} + +static void sub_81CA094(void) +{ + s32 i, j; + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + for (i = 0; i < 6; i++) + { + for (j = 0; j < 4; j++) + { + FreeSpriteOamMatrix(unk->iconSprites[i][j]); + DestroySprite(unk->iconSprites[i][j]); + } + } +} + +static void sub_81CA0C8(void) +{ + s32 r0 = sub_81C9894(); + sub_81CA0EC(gUnknown_08620240[r0].unk4, gUnknown_08620240[r0].unk0, gUnknown_08620240[r0].unk2); +} + +static void sub_81CA0EC(const u16 *const *a0, s32 a1, s32 a2) +{ + s32 i, j; + struct Pokenav2Struct * unk = GetSubstructPtr(2); + s32 sp04 = GetSpriteTileStartByTag(3); + + for (i = 0; i < 6; i++) + { + if (*a0 != NULL) + { + for (j = 0; j < 4; j++) + { + unk->iconSprites[i][j]->oam.tileNum = (*a0)[0] + sp04 + 8 * j; + unk->iconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag((*a0)[1] + 4); + unk->iconSprites[i][j]->invisible = TRUE; + unk->iconSprites[i][j]->pos1.y = a1; + unk->iconSprites[i][j]->pos1.x = 0x8c; + unk->iconSprites[i][j]->pos2.x = 32 * j; + } + unk->iconVisible[i] = TRUE; + } + else + { + for (j = 0; j < 4; j++) + { + unk->iconSprites[i][j]->invisible = TRUE; + } + unk->iconVisible[i] = FALSE; + } + a0++; + a1 += a2; + } +} + +static void sub_81CA20C(void) +{ + s32 i; + struct Pokenav2Struct * unk = GetSubstructPtr(2); + s32 r8 = sub_81C98A4(); + s32 r7 = 0; + s32 r2; + + for (i = 0; i < 6; i++) + { + if (unk->iconVisible[i]) + { + if (r7++ == r8) + { + r2 = 0x82; + unk->cursorPos = i; + } + else + r2 = 0x8c; + sub_81CA35C(unk->iconSprites[i], 0x100, r2, 0xC); + sub_81CA448(unk->iconSprites[i], FALSE); + } + else + sub_81CA448(unk->iconSprites[i], TRUE); + } +} + +static void sub_81CA278(void) +{ + s32 i; + struct Pokenav2Struct * unk = GetSubstructPtr(2); + s32 r3 = sub_81C98A4(); + s32 r5; + + for (i = 0, r5 = 0; i < 6; i++) + { + if (unk->iconVisible[i]) + { + if (r5 == r3) + { + r5 = i; + break; + } + r5++; + } + } + + sub_81CA35C(unk->iconSprites[unk->cursorPos], 0x82, 0x8c, 0x4); + sub_81CA35C(unk->iconSprites[r5], 0x8c, 0x82, 0x4); + unk->cursorPos = r5; +} + +static void sub_81CA2DC(void) +{ + s32 i; + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + for (i = 0; i < 6; i++) + { + if (unk->iconVisible[i]) + { + if (unk->cursorPos != i) + sub_81CA35C(unk->iconSprites[i], 0x8C, 0x100, 0x8); + else + sub_81CA3B4(unk->iconSprites[i]); + } + } +} + +static bool32 sub_81CA324(void) +{ + s32 i; + struct Pokenav2Struct * unk = GetSubstructPtr(2); + + for (i = 0; i < 6; i++) + { + if (unk->iconSprites[i][0]->callback != SpriteCallbackDummy) + return TRUE; + } + + if (unk->otherIconsInMotion) + return TRUE; + + return FALSE; +} + +static void sub_81CA35C(struct Sprite ** sprites, s32 a1, s32 a2, s32 a3) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + (*sprites)->pos1.x = a1; + (*sprites)->data[0] = a3; + (*sprites)->data[1] = 16 * (a2 - a1) / a3; + (*sprites)->data[2] = 16 * a1; + (*sprites)->data[7] = a2; + (*sprites)->callback = sub_81CA474; + sprites++; + } +} + +static void sub_81CA3B4(struct Sprite ** sprites) +{ + s32 i; + struct Pokenav2Struct * unk = GetSubstructPtr(2); + u8 taskId; + + for (i = 0; i < 4; i++) + { + (*sprites)->oam.objMode = ST_OAM_OBJ_BLEND; + (*sprites)->oam.affineMode = ST_OAM_AFFINE_DOUBLE; + (*sprites)->callback = sub_81CA4AC; + (*sprites)->data[0] = 8; + (*sprites)->data[1] = 0; + (*sprites)->data[7] = i; + InitSpriteAffineAnim(sprites[0]); + StartSpriteAffineAnim(sprites[0], 0); + sprites++; + } + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0x00)); + taskId = CreateTask(sub_81CA580, 3); + gTasks[taskId].data[0] = 8; + unk->otherIconsInMotion++; +} + +static void sub_81CA448(struct Sprite ** sprites, bool32 a1) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + (*sprites)->invisible = a1; + sprites++; + } +} + +static void sub_81CA474(struct Sprite * sprite) +{ + sprite->data[0]--; + if (sprite->data[0] != -1) + { + sprite->data[2] += sprite->data[1]; + sprite->pos1.x = sprite->data[2] >> 4; + } + else + { + sprite->pos1.x = sprite->data[7]; + sprite->callback = SpriteCallbackDummy; + } +} + +static void sub_81CA4AC(struct Sprite * sprite) +{ + s32 r0; + s32 r1; + if (sprite->data[0] == 0) + { + if (sprite->data[1] == 0) + { + StartSpriteAffineAnim(sprite, 1); + sprite->data[1]++; + sprite->data[2] = 0x100; + sprite->pos1.x += sprite->pos2.x; + sprite->pos2.x = 0; + } + else + { + sprite->data[2] += 16; + r0 = sprite->data[2]; + r1 = r0 >> 3; + r1 = (r1 - 32) / 2; + switch (sprite->data[7]) + { + case 0: + sprite->pos2.x = -r1 * 3; + break; + case 1: + sprite->pos2.x = -r1; + break; + case 2: + sprite->pos2.x = r1; + break; + case 3: + sprite->pos2.x = r1 * 3; + break; + } + if (sprite->affineAnimEnded) + { + sprite->invisible = TRUE; + FreeOamMatrix(sprite->oam.matrixNum); + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, 0); + sprite->oam.affineMode = ST_OAM_AFFINE_OFF; + sprite->oam.objMode = ST_OAM_OBJ_NORMAL; + sprite->callback = SpriteCallbackDummy; + } + } + } + else + { + sprite->data[0]--; + } +} + +static void sub_81CA580(u8 taskId) +{ + s16 * data = gTasks[taskId].data; + + if (data[0] == 0) + { + switch (data[1]) + { + case 0: + data[2] = 16; + data[3] = 0; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_NONE | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0x00)); + data[1]++; + break; + case 1: + if (data[4] & 1) + { + data[2] -= 3; + if (data[2] < 0) + data[2] = 0; + } + else + { + data[3] += 3; + if (data[3] > 16) + data[3] = 16; + } + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(data[2], data[3])); + data[4]++; + if (data[4] == 12) + { + ((struct Pokenav2Struct *)GetSubstructPtr(2))->otherIconsInMotion--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x00, 0x10)); + DestroyTask(taskId); + } + break; + } + } + else + data[0]--; +} + +static void sub_81CA640(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + u8 spriteId = CreateSprite(&gUnknown_0862036C, 0x10, 0x60, 4); + ptr->field_028 = &gSprites[spriteId]; + if (sub_81C98D4()) + ptr->field_028->callback = sub_81CA6AC; + else + ptr->field_028->invisible = TRUE; +} + +static void sub_81CA698(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + DestroySprite(ptr->field_028); +} + +static void sub_81CA6AC(struct Sprite * sprite) +{ + sprite->data[0]++; + if (sprite->data[0] > 8) + { + sprite->data[0] = 0; + sprite->invisible ^= 1; + } +} + +static void sub_81CA6E0(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + + ptr->optionDescriptionWindowId = AddWindow(&gUnknown_086202CC); + PutWindowTilemap(ptr->optionDescriptionWindowId); + FillWindowPixelBuffer(ptr->optionDescriptionWindowId, PIXEL_FILL(6)); + CopyWindowToVram(ptr->optionDescriptionWindowId, 3); +} + +static void sub_81CA714(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + int i = sub_81C98B4(); + const u8 * s = gUnknown_086202D4[i]; + u32 width = GetStringWidth(1, s, -1); + FillWindowPixelBuffer(ptr->optionDescriptionWindowId, PIXEL_FILL(6)); + AddTextPrinterParameterized3(ptr->optionDescriptionWindowId, 1, (192 - width) / 2, 1, gUnknown_0862030C, 0, s); +} + + +static void sub_81CA770(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + const u8 * s = gText_NoRibbonWinners; + u32 width = GetStringWidth(1, s, -1); + FillWindowPixelBuffer(ptr->optionDescriptionWindowId, PIXEL_FILL(6)); + AddTextPrinterParameterized3(ptr->optionDescriptionWindowId, 1, (192 - width) / 2, 1, gUnknown_0862030F, 0, s); +} + +static bool32 sub_81CA7C4(void) +{ + return IsDma3ManagerBusyWithBgCopy(); +} + +static void sub_81CA7D4(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + ptr->bg3ScrollTaskId = CreateTask(sub_81CA808, 2); +} + +static void sub_81CA7F4(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + DestroyTask(ptr->bg3ScrollTaskId); +} + +static void sub_81CA808(u8 taskId) +{ + ChangeBgX(3, 0x80, 1); +} + +static void sub_81CA818(void) +{ + u8 taskId = CreateTask(sub_81CA8B0, 3); + SetWordTaskArg(taskId, 1, (uintptr_t)(gUnknown_0861FC78 + 1)); + SetWordTaskArg(taskId, 3, (uintptr_t)(gUnknown_0861FC78 + 7)); +} + +static void sub_81CA850(void) +{ + CopyPaletteIntoBufferUnfaded(gUnknown_0861FC78 + 7, 0x31, 4); +} + +static void sub_81CA864(void) +{ + u8 taskId = CreateTask(sub_81CA8B0, 3); + SetWordTaskArg(taskId, 1, (uintptr_t)(gUnknown_0861FC78 + 7)); + SetWordTaskArg(taskId, 3, (uintptr_t)(gUnknown_0861FC78 + 1)); +} + +static bool32 sub_81CA89C(void) +{ + return FuncIsActiveTask(sub_81CA8B0); +} + +static void sub_81CA8B0(u8 taskId) +{ + u16 sp8[2]; + s16 * data = gTasks[taskId].data; + const u16 * pal1 = (const u16 *)GetWordTaskArg(taskId, 1); + const u16 * pal2 = (const u16 *)GetWordTaskArg(taskId, 3); + + sub_81C79BC(pal1, pal2, 2, 12, ++data[0], sp8); + LoadPalette(sp8, 0x31, 4); + if (data[0] == 12) + DestroyTask(taskId); +} + +static void sub_81CA914(void) +{ + TransferPlttBuffer(); + LoadOam(); + ProcessSpriteCopyRequests(); + ScanlineEffect_InitHBlankDmaTransfer(); +} + +static void sub_81CA92C(void) +{ + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_LIGHTEN); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuRegBits(REG_OFFSET_WININ, 0x3F); + SetGpuRegBits(REG_OFFSET_WINOUT, 0x1F); + SetGpuRegBits(REG_OFFSET_WIN0V, 0xA0); + ScanlineEffect_Stop(); + sub_81CAA3C(); + ScanlineEffect_SetParams(gUnknown_08620384); + SetVBlankCallback_(sub_81CA914); + CreateTask(sub_81CA9EC, 3); +} + +static void sub_81CA994(void) +{ + SetGpuReg(REG_OFFSET_BLDCNT, 0); + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + ScanlineEffect_Stop(); + DestroyTask(FindTaskIdByFunc(sub_81CA9EC)); + SetPokenavVBlankCallback(); +} + +static void sub_81CA9C8(void) +{ + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +static void sub_81CA9D8(void) +{ + sub_81CAA3C(); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_LIGHTEN); +} + +static void sub_81CA9EC(u8 taskId) +{ + s16 * data = gTasks[taskId].data; + data[0]++; + if (data[0] > 0) + { + data[0] = 0; + data[1] += 3; + data[1] &= 0x7F; + SetGpuReg(REG_OFFSET_BLDY, gSineTable[data[1]] >> 5); + } +} + +static void sub_81CAA3C(void) +{ + int i = sub_81C9894(); + int j = sub_81C98A4(); + int r4 = gUnknown_08620240[i].unk2 * j + gUnknown_08620240[i].unk0 - 8; + CpuFill16(0, gScanlineEffectRegBuffers[0], 0x140); + CpuFill16(0, gScanlineEffectRegBuffers[1], 0x140); + CpuFill16(RGB(16, 23, 28), &gScanlineEffectRegBuffers[0][r4], 0x20); + CpuFill16(RGB(16, 23, 28), &gScanlineEffectRegBuffers[1][r4], 0x20); +} + +void sub_81CAADC(void) +{ + sub_81CA9C8(); +} diff --git a/src/trainer_hill.c b/src/trainer_hill.c index 650a748cb..77c8fcb53 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -915,7 +915,7 @@ void SetHillTrainerFlag(void) } } -const u8 *sub_81D62AC(void) +const u8 *GetTrainerHillTrainerScript(void) { return EventScript_2C83F0; } diff --git a/src/trainer_see.c b/src/trainer_see.c index 9925aa6bc..22b256a99 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -235,7 +235,7 @@ static u8 CheckTrainer(u8 eventObjectId) u8 approachDistance; if (InTrainerHill() == TRUE) - scriptPtr = sub_81D62AC(); + scriptPtr = GetTrainerHillTrainerScript(); else scriptPtr = GetEventObjectScriptPointerByEventObjectId(eventObjectId);