diff --git a/.githooks/pre-commit b/.githooks/pre-commit old mode 100644 new mode 100755 index 7eb20ecf41..c065e57542 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,9 +1,9 @@ -#!/bin/sh -# Redirect output to stderr. -exec 1>&2 - -# Run clang-format on staged files; abort the commit if any files are changed -if ! git clang-format --extensions c,cpp,h,hpp ; then - echo "linting made changes to source files; aborting commit" - exit 1 -fi +#!/bin/sh +# Redirect output to stderr. +exec 1>&2 + +# Run clang-format on staged files; abort the commit if any files are changed +if ! git clang-format --extensions c,cpp,h,hpp ; then + echo "linting made changes to source files; aborting commit" + exit 1 +fi diff --git a/.github/calcrom/webhook.sh b/.github/calcrom/webhook.sh index ff3f88830a..ba8e941a1c 100644 --- a/.github/calcrom/webhook.sh +++ b/.github/calcrom/webhook.sh @@ -1,7 +1,7 @@ #!/bin/bash -ex -# Only run this script if it's the main branch build. -if [[ "$GITHUB_REF" != "refs/heads/main" || "$GITHUB_EVENT_NAME" != "push" ]]; then +# Only run this script if it's the master branch build. +if [[ "$GITHUB_REF" != "refs/heads/master" || "$GITHUB_EVENT_NAME" != "push" ]]; then exit 0 fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1119928a54..5cde394844 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: build on: push: - branches: [ main ] + branches: [ master ] pull_request: workflow_dispatch: @@ -113,3 +113,4 @@ jobs: cwd: "./xmap" add: "*.xMAP" message: ${{ env.XMAP_COMMIT_MSG }} + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c7d3bb11d..b1b00eda0b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ This repository includes an opinionated `clang-format` specification to ensure t ### Requirements -- `clang-format@18` or newer +- `clang-format@17` or newer ### Usage @@ -47,23 +47,3 @@ asm void func() { // clang-format on #endif // NONMATCHING ``` - -### Ubuntu (WSL) Installation - -On older versions of Ubuntu, clang-format will default to earlier versions. -To install clang-format-18 on Ubuntu (WSL), run the following: -```sh -wget https://apt.llvm.org/llvm.sh -chmod +x llvm.sh -sudo ./llvm.sh 18 -sudo apt install clang-format-18 -``` -And then create a symbolic link: -```sh -ln -s /usr/bin/clang-format-18 /usr/bin/clang-format -``` - -If you're using the pre-commit hook, you also want to set up a symlink for git: -```sh -git config alias.clang-format clang-format-18 -``` diff --git a/asm/include/overlay_62.inc b/asm/include/overlay_62.inc new file mode 100644 index 0000000000..4d8bed5bdd --- /dev/null +++ b/asm/include/overlay_62.inc @@ -0,0 +1,96 @@ +#include +#pragma once +.public RegisterMainOverlay +.public FontID_Alloc +.public FontID_Release +.public sub_02005518 +.public GF_MIC_StartAutoSampling +.public GF_MIC_StopAutoSampling +.public GF_SndStartFadeOutBGM +.public PlaySE +.public OverlayManager_CreateAndGetData +.public OverlayManager_GetData +.public OverlayManager_FreeData +.public GfGfxLoader_LoadCharData +.public GfGfxLoader_LoadScrnData +.public GfGfxLoader_GXLoadPal +.public sub_0200B2E0 +.public sub_0200B2E8 +.public NewMsgDataFromNarc +.public DestroyMsgData +.public NewString_ReadMsgData +.public SpriteRenderer_Create +.public SpriteRenderer_CreateGfxHandler +.public SpriteRenderer_CreateOamCharPlttManagers +.public SpriteRenderer_CreateSpriteList +.public SpriteGfxHandler_RenderAndAnimateSprites +.public thunk_OamManager_ApplyAndResetBuffers +.public SpriteRenderer_Delete +.public SpriteRenderer_Init2DGfxResManagersFromCountsArray +.public SpriteRenderer_LoadCharResObjFromNarcId +.public SpriteRenderer_LoadPlttResObjFromNarcId +.public SpriteRenderer_LoadCellResObjFromNarcId +.public SpriteRenderer_LoadAnimResObjFromNarcId +.public SpriteRenderer_LoadResourcesAndCreateSprite +.public SpriteRenderer_UnloadResourcesAndRemoveGfxHandler +.public UnkImageStruct_Delete +.public UnkImageStruct_TickSpriteAnimation1Frame +.public UnkImageStruct_SetSpriteAnimSeqNo +.public UnkImageStruct_SetSpriteAnimActiveFlag +.public sub_0200DCA0 +.public UnkImageStruct_SetSpriteVisibleFlag +.public UnkImageStruct_SetSpritePriority +.public UnkImageStruct_SetSpritePositionXY +.public sub_0200E0C0 +.public SysTask_CreateOnMainQueue +.public SysTask_Destroy +.public BeginNormalPaletteFade +.public IsPaletteFadeFinished +.public sub_0200FBDC +.public Main_SetVBlankIntrCB +.public HBlankInterruptDisable +.public Sys_SetSleepDisableFlag +.public Sys_ClearSleepDisableFlag +.public CreateHeap +.public DestroyHeap +.public AllocFromHeap +.public FreeToHeap +.public BgConfig_Alloc +.public SetBothScreensModesAndDisable +.public InitBgFromTemplate +.public FreeBgTilemapBuffer +.public BG_ClearCharDataRange +.public BgClearTilemapBufferAndCommit +.public AddWindowParameterized +.public RemoveWindow +.public CopyWindowToVram +.public ClearWindowTilemap +.public ClearWindowTilemapAndCopyToVram +.public FillWindowPixelBuffer +.public DoScheduledBgGpuUpdates +.public SysTask_GetData +.public GF_SinDegNoWrap +.public LCRandom +.public AddTextPrinterParameterizedWithColor +.public GF_CreateVramTransferManager +.public GF_DestroyVramTransferManager +.public GfGfx_SetBanks +.public GfGfx_DisableEngineAPlanes +.public GfGfx_EngineATogglePlanes +.public GfGfx_DisableEngineBPlanes +.public GfGfx_EngineBTogglePlanes +.public TouchscreenHitbox_FindRectAtTouchNew +.public GF_AssertFail +.public String_Delete +.public NNS_GfdDoVramTransfer +.public VEC_Add +.public MI_CpuFill8 +.public _fadd +.public _ffix +.public _fflt +.public _fsub +.public _ll_mul +.public _s32_div_f +.public gSystem +.public gApplication_TitleScreen +.public gApplication_MicTest diff --git a/asm/overlay_62.s b/asm/overlay_62.s new file mode 100644 index 0000000000..b551a74c2e --- /dev/null +++ b/asm/overlay_62.s @@ -0,0 +1,1818 @@ + .include "asm/macros.inc" + .include "overlay_62.inc" + .include "global.inc" + .public gApplication_TitleScreen + + .text + + thumb_func_start ov62_021E5900 +ov62_021E5900: ; 0x021E5900 + push {r4, lr} + add r4, r0, #0 + mov r0, #3 + mov r1, #0x62 + lsl r2, r0, #0x10 + bl CreateHeap + mov r1, #0x4f + add r0, r4, #0 + lsl r1, r1, #2 + mov r2, #0x62 + bl OverlayManager_CreateAndGetData + mov r2, #0x4f + mov r1, #0 + lsl r2, r2, #2 + add r4, r0, #0 + bl MI_CpuFill8 + mov r1, #0x62 + add r0, r1, #0 + add r0, #0xd6 + str r1, [r4, r0] + add r1, #0xd6 + ldr r0, [r4, r1] + bl ov62_021E5C34 + bl ov62_021E5CB8 + ldr r0, _021E59B4 ; =ov62_021E5CC8 + add r1, r4, #0 + bl Main_SetVBlankIntrCB + mov r0, #4 + mov r1, #0x62 + bl FontID_Alloc + mov r1, #0x4e + lsl r1, r1, #2 + add r0, r4, #0 + ldr r1, [r4, r1] + add r0, #0xb8 + bl ov62_021E5FD4 + mov r1, #0x4e + lsl r1, r1, #2 + add r0, r4, #0 + ldr r1, [r4, r1] + add r0, #0xb8 + bl ov62_021E604C + mov r1, #0x4e + lsl r1, r1, #2 + add r0, r4, #0 + ldr r1, [r4, r1] + add r0, #0xb8 + bl ov62_021E60E4 + mov r1, #0x4e + lsl r1, r1, #2 + ldr r1, [r4, r1] + add r0, r4, #0 + bl ov62_021E5CF4 + add r0, r4, #0 + bl ov62_021E5D88 + mov r1, #0x4e + lsl r1, r1, #2 + add r0, r4, #0 + ldr r1, [r4, r1] + ldr r2, _021E59B8 ; =ov62_021E62B8 + add r0, #0xf0 + add r3, r4, #0 + bl ov62_021E61AC + mov r0, #0x4a + lsl r0, r0, #2 + ldr r2, _021E59BC ; =ov62_021E5A9C + add r0, r4, r0 + add r1, r4, #0 + bl ov62_021E5A5C + mov r0, #0 + mov r1, #0xa + bl GF_SndStartFadeOutBGM + mov r0, #1 + pop {r4, pc} + nop +_021E59B4: .word ov62_021E5CC8 +_021E59B8: .word ov62_021E62B8 +_021E59BC: .word ov62_021E5A9C + thumb_func_end ov62_021E5900 + + thumb_func_start ov62_021E59C0 +ov62_021E59C0: ; 0x021E59C0 + push {r3, r4, r5, lr} + add r5, r0, #0 + bl OverlayManager_GetData + add r4, r0, #0 + add r0, #0xf0 + bl ov62_021E61FC + add r0, r4, #0 + bl ov62_021E5FA0 + add r0, r4, #0 + bl ov62_021E5D54 + add r0, r4, #0 + add r0, #0xb8 + bl ov62_021E6178 + add r0, r4, #0 + add r0, #0xb8 + bl ov62_021E6024 + bl ov62_021E5C80 + mov r0, #4 + bl FontID_Release + add r0, r5, #0 + bl OverlayManager_FreeData + mov r0, #0x4e + lsl r0, r0, #2 + ldr r0, [r4, r0] + bl DestroyHeap + ldr r0, _021E5A14 ; =FS_OVERLAY_ID(intro_title) + ldr r1, _021E5A18 ; =gApplication_TitleScreen + bl RegisterMainOverlay + mov r0, #1 + pop {r3, r4, r5, pc} + nop +_021E5A14: .word FS_OVERLAY_ID(intro_title) +_021E5A18: .word gApplication_TitleScreen + thumb_func_end ov62_021E59C0 + + thumb_func_start ov62_021E5A1C +ov62_021E5A1C: ; 0x021E5A1C + push {r4, lr} + bl OverlayManager_GetData + add r4, r0, #0 + mov r0, #0x4a + lsl r0, r0, #2 + add r0, r4, r0 + bl ov62_021E5A90 + cmp r0, #0 + beq _021E5A36 + mov r0, #1 + pop {r4, pc} +_021E5A36: + mov r0, #0x4a + lsl r0, r0, #2 + add r0, r4, r0 + bl ov62_021E5A6C + add r0, r4, #0 + bl ov62_021E5D64 + add r0, r4, #0 + add r0, #0xb8 + bl ov62_021E6048 + add r4, #0xf0 + add r0, r4, #0 + bl ov62_021E620C + mov r0, #0 + pop {r4, pc} + .balign 4, 0 + thumb_func_end ov62_021E5A1C + + thumb_func_start ov62_021E5A5C +ov62_021E5A5C: ; 0x021E5A5C + ldr r3, _021E5A68 ; =ov62_021E5A84 + str r1, [r0] + mov r1, #0 + str r1, [r0, #0xc] + add r1, r2, #0 + bx r3 + .balign 4, 0 +_021E5A68: .word ov62_021E5A84 + thumb_func_end ov62_021E5A5C + + thumb_func_start ov62_021E5A6C +ov62_021E5A6C: ; 0x021E5A6C + push {r4, lr} + add r4, r0, #0 + bl ov62_021E5A90 + cmp r0, #0 + bne _021E5A82 + add r1, r4, #0 + ldr r2, [r4, #4] + add r0, r4, #0 + add r1, #8 + blx r2 +_021E5A82: + pop {r4, pc} + thumb_func_end ov62_021E5A6C + + thumb_func_start ov62_021E5A84 +ov62_021E5A84: ; 0x021E5A84 + str r1, [r0, #4] + mov r1, #0 + str r1, [r0, #8] + bx lr + thumb_func_end ov62_021E5A84 + + thumb_func_start ov62_021E5A8C +ov62_021E5A8C: ; 0x021E5A8C + ldr r0, [r0] + bx lr + thumb_func_end ov62_021E5A8C + + thumb_func_start ov62_021E5A90 +ov62_021E5A90: ; 0x021E5A90 + ldr r0, [r0, #0xc] + bx lr + thumb_func_end ov62_021E5A90 + + thumb_func_start ov62_021E5A94 +ov62_021E5A94: ; 0x021E5A94 + mov r1, #1 + str r1, [r0, #0xc] + bx lr + .balign 4, 0 + thumb_func_end ov62_021E5A94 + + thumb_func_start ov62_021E5A9C +ov62_021E5A9C: ; 0x021E5A9C + push {r4, r5, lr} + sub sp, #0xc + add r4, r1, #0 + add r5, r0, #0 + bl ov62_021E5A8C + ldr r1, [r4] + cmp r1, #0 + beq _021E5AB8 + cmp r1, #1 + beq _021E5ADA + cmp r1, #2 + beq _021E5AEA + b _021E5AF6 +_021E5AB8: + mov r1, #6 + str r1, [sp] + mov r1, #1 + mov r2, #0x4e + str r1, [sp, #4] + lsl r2, r2, #2 + ldr r0, [r0, r2] + add r2, r1, #0 + str r0, [sp, #8] + mov r0, #0 + add r3, r0, #0 + bl BeginNormalPaletteFade + mov r0, #1 + add sp, #0xc + str r0, [r4] + pop {r4, r5, pc} +_021E5ADA: + bl IsPaletteFadeFinished + cmp r0, #0 + beq _021E5AFA + mov r0, #2 + add sp, #0xc + str r0, [r4] + pop {r4, r5, pc} +_021E5AEA: + ldr r1, _021E5B00 ; =ov62_021E5B04 + add r0, r5, #0 + bl ov62_021E5A84 + add sp, #0xc + pop {r4, r5, pc} +_021E5AF6: + bl GF_AssertFail +_021E5AFA: + add sp, #0xc + pop {r4, r5, pc} + nop +_021E5B00: .word ov62_021E5B04 + thumb_func_end ov62_021E5A9C + + thumb_func_start ov62_021E5B04 +ov62_021E5B04: ; 0x021E5B04 + push {r3, r4, r5, lr} + add r4, r1, #0 + add r5, r0, #0 + bl ov62_021E5A8C + ldr r1, [r4] + cmp r1, #3 + bhi _021E5B5E + add r1, r1, r1 + add r1, pc + ldrh r1, [r1, #6] + lsl r1, r1, #0x10 + asr r1, r1, #0x10 + add pc, r1 +_021E5B20: ; jump table + .short _021E5B28 - _021E5B20 - 2 ; case 0 + .short _021E5B34 - _021E5B20 - 2 ; case 1 + .short _021E5B48 - _021E5B20 - 2 ; case 2 + .short _021E5B54 - _021E5B20 - 2 ; case 3 +_021E5B28: + add r0, #0xf0 + bl ov62_021E625C + mov r0, #1 + str r0, [r4] + pop {r3, r4, r5, pc} +_021E5B34: + bl ov62_021E6630 + cmp r0, #0 + beq _021E5B62 + ldr r0, _021E5B64 ; =0x000005DC + bl PlaySE + mov r0, #2 + str r0, [r4] + pop {r3, r4, r5, pc} +_021E5B48: + add r0, #0xf0 + bl ov62_021E6278 + mov r0, #3 + str r0, [r4] + pop {r3, r4, r5, pc} +_021E5B54: + ldr r1, _021E5B68 ; =ov62_021E5B6C + add r0, r5, #0 + bl ov62_021E5A84 + pop {r3, r4, r5, pc} +_021E5B5E: + bl GF_AssertFail +_021E5B62: + pop {r3, r4, r5, pc} + .balign 4, 0 +_021E5B64: .word 0x000005DC +_021E5B68: .word ov62_021E5B6C + thumb_func_end ov62_021E5B04 + + thumb_func_start ov62_021E5B6C +ov62_021E5B6C: ; 0x021E5B6C + push {r3, r4, r5, lr} + add r4, r1, #0 + add r5, r0, #0 + bl ov62_021E5A8C + ldr r1, [r4] + cmp r1, #0 + beq _021E5B86 + cmp r1, #1 + beq _021E5B94 + cmp r1, #2 + beq _021E5BA4 + b _021E5BAE +_021E5B86: + ldr r0, [r0, #0x14] + mov r1, #1 + bl UnkImageStruct_SetSpriteAnimSeqNo + mov r0, #1 + str r0, [r4] + pop {r3, r4, r5, pc} +_021E5B94: + ldr r0, [r0, #0x14] + bl sub_0200DCA0 + cmp r0, #0 + bne _021E5BB2 + mov r0, #2 + str r0, [r4] + pop {r3, r4, r5, pc} +_021E5BA4: + ldr r1, _021E5BB4 ; =ov62_021E5BB8 + add r0, r5, #0 + bl ov62_021E5A84 + pop {r3, r4, r5, pc} +_021E5BAE: + bl GF_AssertFail +_021E5BB2: + pop {r3, r4, r5, pc} + .balign 4, 0 +_021E5BB4: .word ov62_021E5BB8 + thumb_func_end ov62_021E5B6C + + thumb_func_start ov62_021E5BB8 +ov62_021E5BB8: ; 0x021E5BB8 + push {r4, r5, lr} + sub sp, #0xc + add r4, r1, #0 + add r5, r0, #0 + bl ov62_021E5A8C + ldr r1, [r4] + cmp r1, #0 + beq _021E5BD4 + cmp r1, #1 + beq _021E5BF8 + cmp r1, #2 + beq _021E5C08 + b _021E5C14 +_021E5BD4: + mov r1, #6 + str r1, [sp] + mov r1, #1 + str r1, [sp, #4] + mov r1, #0x4e + lsl r1, r1, #2 + ldr r0, [r0, r1] + str r0, [sp, #8] + mov r0, #0 + add r1, r0, #0 + add r2, r0, #0 + add r3, r0, #0 + bl BeginNormalPaletteFade + mov r0, #1 + add sp, #0xc + str r0, [r4] + pop {r4, r5, pc} +_021E5BF8: + bl IsPaletteFadeFinished + cmp r0, #0 + beq _021E5C18 + mov r0, #2 + add sp, #0xc + str r0, [r4] + pop {r4, r5, pc} +_021E5C08: + ldr r1, _021E5C1C ; =ov62_021E5C20 + add r0, r5, #0 + bl ov62_021E5A84 + add sp, #0xc + pop {r4, r5, pc} +_021E5C14: + bl GF_AssertFail +_021E5C18: + add sp, #0xc + pop {r4, r5, pc} + .balign 4, 0 +_021E5C1C: .word ov62_021E5C20 + thumb_func_end ov62_021E5BB8 + + thumb_func_start ov62_021E5C20 +ov62_021E5C20: ; 0x021E5C20 + push {r4, lr} + add r4, r0, #0 + bl ov62_021E5A8C + bl ov62_021E6600 + add r0, r4, #0 + bl ov62_021E5A94 + pop {r4, pc} + thumb_func_end ov62_021E5C20 + + thumb_func_start ov62_021E5C34 +ov62_021E5C34: ; 0x021E5C34 + push {r4, lr} + add r4, r0, #0 + mov r0, #0 + add r1, r0, #0 + bl Main_SetVBlankIntrCB + bl HBlankInterruptDisable + bl GfGfx_DisableEngineAPlanes + bl GfGfx_DisableEngineBPlanes + mov r2, #1 + lsl r2, r2, #0x1a + ldr r1, [r2] + ldr r0, _021E5C78 ; =0xFFFFE0FF + and r1, r0 + str r1, [r2] + ldr r2, _021E5C7C ; =0x04001000 + ldr r1, [r2] + and r0, r1 + str r0, [r2] + mov r0, #0 + bl sub_0200FBDC + mov r0, #1 + bl sub_0200FBDC + mov r0, #0x20 + add r1, r4, #0 + bl GF_CreateVramTransferManager + pop {r4, pc} + nop +_021E5C78: .word 0xFFFFE0FF +_021E5C7C: .word 0x04001000 + thumb_func_end ov62_021E5C34 + + thumb_func_start ov62_021E5C80 +ov62_021E5C80: ; 0x021E5C80 + push {r3, lr} + bl GF_DestroyVramTransferManager + mov r0, #0 + add r1, r0, #0 + bl Main_SetVBlankIntrCB + bl HBlankInterruptDisable + bl GfGfx_DisableEngineAPlanes + bl GfGfx_DisableEngineBPlanes + mov r2, #1 + lsl r2, r2, #0x1a + ldr r1, [r2] + ldr r0, _021E5CB0 ; =0xFFFFE0FF + and r1, r0 + str r1, [r2] + ldr r2, _021E5CB4 ; =0x04001000 + ldr r1, [r2] + and r0, r1 + str r0, [r2] + pop {r3, pc} + .balign 4, 0 +_021E5CB0: .word 0xFFFFE0FF +_021E5CB4: .word 0x04001000 + thumb_func_end ov62_021E5C80 + + thumb_func_start ov62_021E5CB8 +ov62_021E5CB8: ; 0x021E5CB8 + ldr r3, _021E5CC0 ; =GfGfx_SetBanks + ldr r0, _021E5CC4 ; =ov62_021E66D0 + bx r3 + nop +_021E5CC0: .word GfGfx_SetBanks +_021E5CC4: .word ov62_021E66D0 + thumb_func_end ov62_021E5CB8 + + thumb_func_start ov62_021E5CC8 +ov62_021E5CC8: ; 0x021E5CC8 + push {r4, lr} + add r4, r0, #0 + bl NNS_GfdDoVramTransfer + add r0, r4, #0 + bl ov62_021E5FC4 + add r4, #0xb8 + add r0, r4, #0 + bl ov62_021E60D4 + ldr r3, _021E5CEC ; =0x027E0000 + ldr r1, _021E5CF0 ; =0x00003FF8 + mov r0, #1 + ldr r2, [r3, r1] + orr r0, r2 + str r0, [r3, r1] + pop {r4, pc} + .balign 4, 0 +_021E5CEC: .word 0x027E0000 +_021E5CF0: .word 0x00003FF8 + thumb_func_end ov62_021E5CC8 + + thumb_func_start ov62_021E5CF4 +ov62_021E5CF4: ; 0x021E5CF4 + push {r3, r4, r5, lr} + add r4, r1, #0 + add r5, r0, #0 + add r0, r4, #0 + bl SpriteRenderer_Create + ldr r1, _021E5D48 ; =ov62_021E66B0 + ldr r2, _021E5D4C ; =ov62_021E6668 + mov r3, #0x20 + str r0, [r5] + bl SpriteRenderer_CreateOamCharPlttManagers + add r0, r4, #0 + bl sub_0200B2E0 + add r0, r4, #0 + bl sub_0200B2E8 + ldr r0, [r5] + bl SpriteRenderer_CreateGfxHandler + str r0, [r5, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r2, #7 + bl SpriteRenderer_CreateSpriteList + ldr r0, [r5] + ldr r1, [r5, #4] + ldr r2, _021E5D50 ; =ov62_021E667C + bl SpriteRenderer_Init2DGfxResManagersFromCountsArray + mov r0, #0x10 + mov r1, #1 + bl GfGfx_EngineATogglePlanes + mov r0, #0x10 + mov r1, #1 + bl GfGfx_EngineBTogglePlanes + pop {r3, r4, r5, pc} + nop +_021E5D48: .word ov62_021E66B0 +_021E5D4C: .word ov62_021E6668 +_021E5D50: .word ov62_021E667C + thumb_func_end ov62_021E5CF4 + + thumb_func_start ov62_021E5D54 +ov62_021E5D54: ; 0x021E5D54 + push {r4, lr} + add r4, r0, #0 + ldr r0, [r4] + bl SpriteRenderer_Delete + mov r0, #0 + str r0, [r4] + pop {r4, pc} + thumb_func_end ov62_021E5D54 + + thumb_func_start ov62_021E5D64 +ov62_021E5D64: ; 0x021E5D64 + push {r3, r4, r5, lr} + add r5, r0, #0 + mov r4, #0 +_021E5D6A: + lsl r0, r4, #2 + add r0, r5, r0 + ldr r0, [r0, #8] + bl UnkImageStruct_TickSpriteAnimation1Frame + add r0, r4, #1 + lsl r0, r0, #0x10 + lsr r4, r0, #0x10 + cmp r4, #7 + blo _021E5D6A + ldr r0, [r5, #4] + bl SpriteGfxHandler_RenderAndAnimateSprites + pop {r3, r4, r5, pc} + .balign 4, 0 + thumb_func_end ov62_021E5D64 + + thumb_func_start ov62_021E5D88 +ov62_021E5D88: ; 0x021E5D88 + push {r3, r4, r5, r6, r7, lr} + sub sp, #0x10 + add r5, r0, #0 + mov r0, #0 + str r0, [sp] + mov r0, #1 + str r0, [sp, #4] + str r0, [sp, #8] + ldr r0, _021E5F58 ; =0x00000A03 + mov r2, #0xb0 + str r0, [sp, #0xc] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #6 + bl SpriteRenderer_LoadPlttResObjFromNarcId + mov r0, #0 + str r0, [sp] + ldr r0, _021E5F5C ; =0x00000A02 + mov r2, #0xb0 + str r0, [sp, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #8 + bl SpriteRenderer_LoadCellResObjFromNarcId + mov r0, #0 + str r0, [sp] + ldr r0, _021E5F60 ; =0x00000A04 + mov r2, #0xb0 + str r0, [sp, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #9 + bl SpriteRenderer_LoadAnimResObjFromNarcId + mov r0, #0 + str r0, [sp] + mov r0, #1 + str r0, [sp, #4] + ldr r0, _021E5F64 ; =0x00000A01 + mov r2, #0xb0 + str r0, [sp, #8] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #7 + bl SpriteRenderer_LoadCharResObjFromNarcId + mov r0, #0 + str r0, [sp] + mov r0, #1 + str r0, [sp, #4] + str r0, [sp, #8] + ldr r0, _021E5F68 ; =0x00000B03 + mov r2, #0xb0 + str r0, [sp, #0xc] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0xa + bl SpriteRenderer_LoadPlttResObjFromNarcId + mov r0, #0 + str r0, [sp] + ldr r0, _021E5F6C ; =0x00000B02 + mov r2, #0xb0 + str r0, [sp, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0xc + bl SpriteRenderer_LoadCellResObjFromNarcId + mov r0, #0 + str r0, [sp] + ldr r0, _021E5F70 ; =0x00000B04 + mov r2, #0xb0 + str r0, [sp, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0xd + bl SpriteRenderer_LoadAnimResObjFromNarcId + mov r0, #0 + str r0, [sp] + mov r0, #1 + str r0, [sp, #4] + ldr r0, _021E5F74 ; =0x00000B01 + mov r2, #0xb0 + str r0, [sp, #8] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0xb + bl SpriteRenderer_LoadCharResObjFromNarcId + mov r0, #0 + str r0, [sp] + mov r0, #1 + str r0, [sp, #4] + mov r0, #2 + str r0, [sp, #8] + ldr r0, _021E5F78 ; =0x00000D03 + mov r2, #0xb0 + str r0, [sp, #0xc] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0x12 + bl SpriteRenderer_LoadPlttResObjFromNarcId + mov r0, #0 + str r0, [sp] + ldr r0, _021E5F7C ; =0x00000D02 + mov r2, #0xb0 + str r0, [sp, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0x14 + bl SpriteRenderer_LoadCellResObjFromNarcId + mov r0, #0 + str r0, [sp] + ldr r0, _021E5F80 ; =0x00000D04 + mov r2, #0xb0 + str r0, [sp, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0x15 + bl SpriteRenderer_LoadAnimResObjFromNarcId + mov r0, #0 + str r0, [sp] + mov r0, #2 + str r0, [sp, #4] + ldr r0, _021E5F84 ; =0x00000D01 + mov r2, #0xb0 + str r0, [sp, #8] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0x13 + bl SpriteRenderer_LoadCharResObjFromNarcId + mov r0, #0 + str r0, [sp] + mov r0, #1 + str r0, [sp, #4] + str r0, [sp, #8] + ldr r0, _021E5F88 ; =0x00000C03 + mov r2, #0xb0 + str r0, [sp, #0xc] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0xe + bl SpriteRenderer_LoadPlttResObjFromNarcId + mov r0, #0 + str r0, [sp] + ldr r0, _021E5F8C ; =0x00000C02 + mov r2, #0xb0 + str r0, [sp, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0x10 + bl SpriteRenderer_LoadCellResObjFromNarcId + mov r0, #0 + str r0, [sp] + ldr r0, _021E5F90 ; =0x00000C04 + mov r2, #0xb0 + str r0, [sp, #4] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0x11 + bl SpriteRenderer_LoadAnimResObjFromNarcId + mov r0, #0 + str r0, [sp] + mov r0, #1 + str r0, [sp, #4] + ldr r0, _021E5F94 ; =0x00000C01 + mov r2, #0xb0 + str r0, [sp, #8] + ldr r0, [r5] + ldr r1, [r5, #4] + mov r3, #0xf + bl SpriteRenderer_LoadCharResObjFromNarcId + ldr r7, _021E5F98 ; =ov62_021E67C8 + mov r4, #0 +_021E5EFC: + ldr r2, _021E5F9C ; =ov62_021E6694 + lsl r3, r4, #2 + add r6, r5, r3 + ldr r3, [r2, r3] + mov r2, #0x34 + mul r2, r3 + ldr r0, [r5] + ldr r1, [r5, #4] + add r2, r7, r2 + bl SpriteRenderer_LoadResourcesAndCreateSprite + mov r1, #1 + str r0, [r6, #8] + bl UnkImageStruct_SetSpriteAnimActiveFlag + add r0, r4, #1 + lsl r0, r0, #0x10 + lsr r4, r0, #0x10 + cmp r4, #7 + blo _021E5EFC + mov r4, #0 + add r6, r4, #0 +_021E5F28: + lsl r0, r4, #2 + add r0, r5, r0 + ldr r0, [r0, #0x18] + add r1, r6, #0 + bl UnkImageStruct_SetSpriteVisibleFlag + add r0, r4, #1 + lsl r0, r0, #0x10 + lsr r4, r0, #0x10 + cmp r4, #3 + blo _021E5F28 + ldr r0, [r5, #8] + mov r1, #1 + bl sub_0200E0C0 + ldr r0, [r5, #0x14] + mov r1, #1 + bl UnkImageStruct_SetSpritePriority + mov r0, #0xa + add r5, #0xb4 + str r0, [r5] + add sp, #0x10 + pop {r3, r4, r5, r6, r7, pc} + .balign 4, 0 +_021E5F58: .word 0x00000A03 +_021E5F5C: .word 0x00000A02 +_021E5F60: .word 0x00000A04 +_021E5F64: .word 0x00000A01 +_021E5F68: .word 0x00000B03 +_021E5F6C: .word 0x00000B02 +_021E5F70: .word 0x00000B04 +_021E5F74: .word 0x00000B01 +_021E5F78: .word 0x00000D03 +_021E5F7C: .word 0x00000D02 +_021E5F80: .word 0x00000D04 +_021E5F84: .word 0x00000D01 +_021E5F88: .word 0x00000C03 +_021E5F8C: .word 0x00000C02 +_021E5F90: .word 0x00000C04 +_021E5F94: .word 0x00000C01 +_021E5F98: .word ov62_021E67C8 +_021E5F9C: .word ov62_021E6694 + thumb_func_end ov62_021E5D88 + + thumb_func_start ov62_021E5FA0 +ov62_021E5FA0: ; 0x021E5FA0 + push {r4, r5, r6, lr} + add r6, r0, #0 + mov r4, #0 + add r5, r6, #0 +_021E5FA8: + ldr r0, [r5, #8] + cmp r0, #0 + beq _021E5FB2 + bl UnkImageStruct_Delete +_021E5FB2: + add r4, r4, #1 + add r5, r5, #4 + cmp r4, #7 + blt _021E5FA8 + ldr r0, [r6] + ldr r1, [r6, #4] + bl SpriteRenderer_UnloadResourcesAndRemoveGfxHandler + pop {r4, r5, r6, pc} + thumb_func_end ov62_021E5FA0 + + thumb_func_start ov62_021E5FC4 +ov62_021E5FC4: ; 0x021E5FC4 + push {r3, lr} + ldr r0, [r0] + cmp r0, #0 + beq _021E5FD0 + bl thunk_OamManager_ApplyAndResetBuffers +_021E5FD0: + pop {r3, pc} + .balign 4, 0 + thumb_func_end ov62_021E5FC4 + + thumb_func_start ov62_021E5FD4 +ov62_021E5FD4: ; 0x021E5FD4 + push {r3, r4, r5, r6, r7, lr} + add r6, r0, #0 + add r0, r1, #0 + str r1, [sp] + bl BgConfig_Alloc + str r0, [r6] + ldr r0, _021E601C ; =ov62_021E6658 + bl SetBothScreensModesAndDisable + ldr r4, _021E6020 ; =ov62_021E6728 + mov r7, #0 + add r5, r4, #0 +_021E5FEE: + ldrb r1, [r4, #0x1c] + ldrb r3, [r4, #0x1d] + ldr r0, [r6] + add r2, r5, #0 + bl InitBgFromTemplate + ldrb r1, [r4, #0x1c] + ldr r0, [r6] + bl BgClearTilemapBufferAndCommit + ldrb r0, [r4, #0x1c] + ldr r3, [sp] + mov r1, #0x20 + mov r2, #0 + bl BG_ClearCharDataRange + add r7, r7, #1 + add r4, #0x20 + add r5, #0x20 + cmp r7, #5 + blo _021E5FEE + pop {r3, r4, r5, r6, r7, pc} + nop +_021E601C: .word ov62_021E6658 +_021E6020: .word ov62_021E6728 + thumb_func_end ov62_021E5FD4 + + thumb_func_start ov62_021E6024 +ov62_021E6024: ; 0x021E6024 + push {r4, r5, r6, lr} + ldr r5, _021E6044 ; =ov62_021E6728 + add r6, r0, #0 + mov r4, #0 +_021E602C: + ldrb r1, [r5, #0x1c] + ldr r0, [r6] + bl FreeBgTilemapBuffer + add r4, r4, #1 + add r5, #0x20 + cmp r4, #5 + blo _021E602C + ldr r0, [r6] + bl FreeToHeap + pop {r4, r5, r6, pc} + .balign 4, 0 +_021E6044: .word ov62_021E6728 + thumb_func_end ov62_021E6024 + + thumb_func_start ov62_021E6048 +ov62_021E6048: ; 0x021E6048 + bx lr + .balign 4, 0 + thumb_func_end ov62_021E6048 + + thumb_func_start ov62_021E604C +ov62_021E604C: ; 0x021E604C + push {r3, r4, r5, lr} + sub sp, #0x10 + add r5, r0, #0 + add r4, r1, #0 + mov r1, #0 + mov r0, #0x20 + str r0, [sp] + mov r0, #0xb0 + add r2, r1, #0 + add r3, r1, #0 + str r4, [sp, #4] + bl GfGfxLoader_GXLoadPal + mov r0, #0 + str r0, [sp] + str r0, [sp, #4] + str r0, [sp, #8] + str r4, [sp, #0xc] + ldr r2, [r5] + mov r0, #0xb0 + mov r1, #4 + mov r3, #5 + bl GfGfxLoader_LoadCharData + mov r0, #0 + str r0, [sp] + str r0, [sp, #4] + str r0, [sp, #8] + str r4, [sp, #0xc] + mov r1, #5 + ldr r2, [r5] + mov r0, #0xb0 + add r3, r1, #0 + bl GfGfxLoader_LoadScrnData + mov r0, #0x20 + str r0, [sp] + mov r0, #0xb0 + mov r1, #1 + mov r2, #4 + mov r3, #0 + str r4, [sp, #4] + bl GfGfxLoader_GXLoadPal + mov r0, #0 + str r0, [sp] + str r0, [sp, #4] + str r0, [sp, #8] + str r4, [sp, #0xc] + ldr r2, [r5] + mov r0, #0xb0 + mov r1, #2 + mov r3, #1 + bl GfGfxLoader_LoadCharData + mov r0, #0 + str r0, [sp] + str r0, [sp, #4] + str r0, [sp, #8] + str r4, [sp, #0xc] + ldr r2, [r5] + mov r0, #0xb0 + mov r1, #3 + mov r3, #1 + bl GfGfxLoader_LoadScrnData + add sp, #0x10 + pop {r3, r4, r5, pc} + thumb_func_end ov62_021E604C + + thumb_func_start ov62_021E60D4 +ov62_021E60D4: ; 0x021E60D4 + push {r3, lr} + ldr r0, [r0] + cmp r0, #0 + beq _021E60E0 + bl DoScheduledBgGpuUpdates +_021E60E0: + pop {r3, pc} + .balign 4, 0 + thumb_func_end ov62_021E60D4 + + thumb_func_start ov62_021E60E4 +ov62_021E60E4: ; 0x021E60E4 + push {r3, r4, r5, r6, r7, lr} + sub sp, #0x18 + str r0, [sp, #0x14] + add r3, r1, #0 + mov r0, #1 + mov r1, #0x1b + mov r2, #0xea + bl NewMsgDataFromNarc + ldr r1, [sp, #0x14] + ldr r4, _021E6174 ; =ov62_021E66F8 + str r0, [r1, #0x34] + add r0, r1, #0 + mov r6, #0 + add r5, r0, #4 +_021E6102: + ldrb r0, [r4, #2] + add r1, r5, #0 + str r0, [sp] + ldrb r0, [r4, #3] + str r0, [sp, #4] + ldrb r0, [r4, #4] + str r0, [sp, #8] + ldrb r0, [r4, #5] + str r0, [sp, #0xc] + ldrh r0, [r4, #6] + str r0, [sp, #0x10] + ldr r0, [sp, #0x14] + ldrb r2, [r4] + ldrb r3, [r4, #1] + ldr r0, [r0] + bl AddWindowParameterized + add r0, r5, #0 + mov r1, #0 + bl FillWindowPixelBuffer + add r0, r5, #0 + bl ClearWindowTilemap + ldr r0, [sp, #0x14] + add r1, r6, #0 + ldr r0, [r0, #0x34] + bl NewString_ReadMsgData + add r7, r0, #0 + mov r0, #0 + str r0, [sp] + mov r0, #0xff + str r0, [sp, #4] + ldr r0, [r4, #0xc] + add r2, r7, #0 + str r0, [sp, #8] + mov r0, #0 + str r0, [sp, #0xc] + ldrb r1, [r4, #8] + add r0, r5, #0 + mov r3, #0 + bl AddTextPrinterParameterizedWithColor + add r0, r7, #0 + bl String_Delete + add r0, r5, #0 + bl CopyWindowToVram + add r6, r6, #1 + add r4, #0x10 + add r5, #0x10 + cmp r6, #3 + blt _021E6102 + add sp, #0x18 + pop {r3, r4, r5, r6, r7, pc} + .balign 4, 0 +_021E6174: .word ov62_021E66F8 + thumb_func_end ov62_021E60E4 + + thumb_func_start ov62_021E6178 +ov62_021E6178: ; 0x021E6178 + push {r3, r4, r5, r6, r7, lr} + add r7, r0, #0 + mov r4, #0 + add r5, r7, #4 + add r6, r4, #0 +_021E6182: + add r0, r5, #0 + bl ClearWindowTilemapAndCopyToVram + add r0, r5, #0 + add r1, r6, #0 + bl FillWindowPixelBuffer + add r0, r5, #0 + bl ClearWindowTilemap + add r0, r5, #0 + bl RemoveWindow + add r4, r4, #1 + add r5, #0x10 + cmp r4, #3 + blt _021E6182 + ldr r0, [r7, #0x34] + bl DestroyMsgData + pop {r3, r4, r5, r6, r7, pc} + thumb_func_end ov62_021E6178 + + thumb_func_start ov62_021E61AC +ov62_021E61AC: ; 0x021E61AC + push {r3, r4, r5, r6, r7, lr} + add r5, r0, #0 + mov r0, #8 + add r4, r1, #0 + add r6, r2, #0 + add r7, r3, #0 + bl Sys_SetSleepDisableFlag + mov r1, #0x12 + add r0, r4, #0 + lsl r1, r1, #4 + bl AllocFromHeap + mov r2, #0x12 + add r4, r0, #0 + mov r1, #0 + lsl r2, r2, #4 + bl MI_CpuFill8 + str r4, [r5, #0x1c] + mov r0, #0 + str r0, [r5] + add r4, #0x1f + mov r0, #0x1f + bic r4, r0 + mov r0, #1 + str r4, [r5, #4] + lsl r0, r0, #8 + str r0, [r5, #8] + mov r0, #0x41 + lsl r0, r0, #6 + str r0, [r5, #0xc] + mov r0, #1 + str r0, [r5, #0x10] + str r6, [r5, #0x14] + str r7, [r5, #0x18] + bl sub_02005518 + str r0, [r5, #0x34] + pop {r3, r4, r5, r6, r7, pc} + thumb_func_end ov62_021E61AC + + thumb_func_start ov62_021E61FC +ov62_021E61FC: ; 0x021E61FC + push {r3, lr} + ldr r0, [r0, #0x1c] + bl FreeToHeap + mov r0, #8 + bl Sys_ClearSleepDisableFlag + pop {r3, pc} + thumb_func_end ov62_021E61FC + + thumb_func_start ov62_021E620C +ov62_021E620C: ; 0x021E620C + push {r3, r4, r5, lr} + add r5, r0, #0 + bl sub_02005518 + add r4, r0, #0 + beq _021E621E + ldr r0, [r5, #0x34] + cmp r0, #0 + bne _021E6256 +_021E621E: + ldr r0, [r5, #0x30] + cmp r0, #0 + bne _021E6238 + ldr r0, [r5, #0x28] + cmp r0, #0 + beq _021E6234 + add r0, r5, #0 + bl ov62_021E6278 + mov r0, #1 + str r0, [r5, #0x2c] +_021E6234: + mov r0, #1 + str r0, [r5, #0x30] +_021E6238: + cmp r4, #0 + beq _021E6256 + ldr r0, [r5, #0x34] + cmp r0, #0 + bne _021E6256 + mov r0, #0 + str r0, [r5, #0x30] + ldr r0, [r5, #0x2c] + cmp r0, #0 + beq _021E6256 + add r0, r5, #0 + bl ov62_021E625C + mov r0, #0 + str r0, [r5, #0x2c] +_021E6256: + str r4, [r5, #0x34] + pop {r3, r4, r5, pc} + .balign 4, 0 + thumb_func_end ov62_021E620C + + thumb_func_start ov62_021E625C +ov62_021E625C: ; 0x021E625C + push {r4, lr} + add r4, r0, #0 + ldr r1, [r4, #0x30] + cmp r1, #0 + bne _021E6270 + bl GF_MIC_StartAutoSampling + mov r0, #1 + str r0, [r4, #0x28] + pop {r4, pc} +_021E6270: + mov r0, #1 + str r0, [r4, #0x2c] + pop {r4, pc} + .balign 4, 0 + thumb_func_end ov62_021E625C + + thumb_func_start ov62_021E6278 +ov62_021E6278: ; 0x021E6278 + push {r4, lr} + add r4, r0, #0 + bl GF_MIC_StopAutoSampling + mov r0, #0 + str r0, [r4, #0x28] + pop {r4, pc} + .balign 4, 0 + thumb_func_end ov62_021E6278 + + thumb_func_start ov62_021E6288 +ov62_021E6288: ; 0x021E6288 + push {r3, r4, r5, lr} + ldr r1, [r0, #8] + mov r2, #0 + sub r1, r1, #1 + add r4, r2, #0 + ldr r5, [r0, #4] + cmp r1, #0 + ble _021E62AE + mov r0, #1 + lsl r0, r0, #8 +_021E629C: + ldrb r3, [r5, r4] + cmp r3, #0x80 + bhs _021E62A6 + sub r3, r0, r3 + b _021E62A6 +_021E62A6: + add r4, r4, #1 + add r2, r2, r3 + cmp r4, r1 + blt _021E629C +_021E62AE: + add r0, r2, #0 + bl _s32_div_f + pop {r3, r4, r5, pc} + .balign 4, 0 + thumb_func_end ov62_021E6288 + + thumb_func_start ov62_021E62B8 +ov62_021E62B8: ; 0x021E62B8 + push {r3, r4, r5, r6, r7, lr} + add r5, r1, #0 + cmp r0, #0 + bne _021E638A + add r4, r5, #0 + add r4, #0xf0 + add r0, r4, #0 + bl ov62_021E6288 + add r7, r0, #0 + ldr r0, [r4, #0x20] + cmp r0, r7 + bge _021E62E4 + lsl r0, r7, #0x18 + lsr r0, r0, #0x18 + bl ov62_021E6390 + add r6, r0, #0 + str r7, [r4, #0x20] + mov r0, #1 + str r0, [r4, #0x24] + b _021E62F4 +_021E62E4: + lsl r0, r0, #0x18 + lsr r0, r0, #0x18 + bl ov62_021E6390 + add r6, r0, #0 + ldr r0, [r4, #0x20] + sub r0, r0, #2 + str r0, [r4, #0x20] +_021E62F4: + cmp r6, #0 + beq _021E6368 + ldr r0, [r4, #0x24] + cmp r0, #0 + beq _021E630A + ldr r0, [r5, #0x10] + mov r1, #1 + bl UnkImageStruct_SetSpriteAnimSeqNo + mov r0, #0 + str r0, [r4, #0x24] +_021E630A: + add r0, r5, #0 + bl ov62_021E63D0 + cmp r0, #0 + beq _021E6326 + mov r1, #0x4e + lsl r1, r1, #2 + ldr r1, [r5, r1] + add r0, r5, #0 + mov r2, #0x80 + mov r3, #0x40 + bl ov62_021E63E8 + b _021E6356 +_021E6326: + add r0, r5, #0 + add r0, #0xb4 + ldr r0, [r0] + sub r1, r0, #1 + add r0, r5, #0 + add r0, #0xb4 + str r1, [r0] + add r0, r5, #0 + add r0, #0xb4 + ldr r0, [r0] + cmp r0, #0 + bne _021E6356 + mov r1, #0x4e + lsl r1, r1, #2 + ldr r1, [r5, r1] + add r0, r5, #0 + mov r2, #0x80 + mov r3, #0x40 + bl ov62_021E63E8 + add r0, r5, #0 + mov r1, #0xa + add r0, #0xb4 + str r1, [r0] +_021E6356: + ldr r0, [r5, #8] + add r1, r6, #0 + bl UnkImageStruct_SetSpriteAnimSeqNo + ldr r0, [r5, #0xc] + add r1, r6, #0 + bl UnkImageStruct_SetSpriteAnimSeqNo + b _021E6382 +_021E6368: + bne _021E6382 + ldr r0, [r5, #0x10] + mov r1, #0 + bl UnkImageStruct_SetSpriteAnimSeqNo + ldr r0, [r5, #8] + mov r1, #0 + bl UnkImageStruct_SetSpriteAnimSeqNo + ldr r0, [r5, #0xc] + mov r1, #0 + bl UnkImageStruct_SetSpriteAnimSeqNo +_021E6382: + ldr r0, _021E638C ; =_021E68E0 + ldr r1, [r0] + add r1, r1, #1 + str r1, [r0] +_021E638A: + pop {r3, r4, r5, r6, r7, pc} + .balign 4, 0 +_021E638C: .word _021E68E0 + thumb_func_end ov62_021E62B8 + + thumb_func_start ov62_021E6390 +ov62_021E6390: ; 0x021E6390 + push {r4, lr} + cmp r0, #0x8c + bhi _021E639A + mov r4, #0 + b _021E63CA +_021E639A: + cmp r0, #0x8d + blo _021E63A6 + cmp r0, #0x98 + bhi _021E63A6 + mov r4, #1 + b _021E63CA +_021E63A6: + cmp r0, #0x99 + blo _021E63B2 + cmp r0, #0xa6 + bhi _021E63B2 + mov r4, #2 + b _021E63CA +_021E63B2: + cmp r0, #0xa7 + blo _021E63BE + cmp r0, #0xbb + bhi _021E63BE + mov r4, #3 + b _021E63CA +_021E63BE: + cmp r0, #0xbc + blo _021E63C6 + mov r4, #4 + b _021E63CA +_021E63C6: + bl GF_AssertFail +_021E63CA: + add r0, r4, #0 + pop {r4, pc} + .balign 4, 0 + thumb_func_end ov62_021E6390 + + thumb_func_start ov62_021E63D0 +ov62_021E63D0: ; 0x021E63D0 + mov r2, #0 +_021E63D2: + ldr r1, [r0, #0x50] + cmp r1, #0 + beq _021E63DC + mov r0, #0 + bx lr +_021E63DC: + add r2, r2, #1 + add r0, #0x30 + cmp r2, #3 + blt _021E63D2 + mov r0, #1 + bx lr + thumb_func_end ov62_021E63D0 + + thumb_func_start ov62_021E63E8 +ov62_021E63E8: ; 0x021E63E8 + push {r3, r4, r5, r6, r7, lr} + sub sp, #0x18 + mov r4, #0 + str r3, [sp, #0x10] + add r7, r2, #0 + str r4, [sp, #0x14] + add r1, r4, #0 + add r3, r0, #0 +_021E63F8: + ldr r2, [r3, #0x50] + cmp r2, #0 + bne _021E6414 + mov r2, #0x30 + mul r2, r1 + add r1, r1, #4 + add r3, r0, #0 + lsl r1, r1, #2 + add r0, r0, r1 + ldr r0, [r0, #8] + add r3, #0x24 + add r4, r3, r2 + str r0, [sp, #0x14] + b _021E641C +_021E6414: + add r1, r1, #1 + add r3, #0x30 + cmp r1, #3 + blt _021E63F8 +_021E641C: + cmp r4, #0 + beq _021E6472 + bl LCRandom + ldr r1, _021E6478 ; =0x00001002 + mul r1, r0 + asr r0, r1, #0xf + lsr r0, r0, #0x10 + add r0, r1, r0 + asr r1, r0, #0x10 + ldr r0, _021E647C ; =0x00001333 + add r6, r1, r0 + bl LCRandom + mov r1, #0x3e + mul r1, r0 + asr r0, r1, #0xf + lsr r0, r0, #0x10 + add r0, r1, r0 + asr r5, r0, #0x10 + add r5, #0x3c + bl LCRandom + lsl r1, r0, #4 + asr r0, r1, #0xf + lsr r0, r0, #0x10 + add r0, r1, r0 + asr r0, r0, #0x10 + str r6, [sp] + add r0, r0, #6 + str r5, [sp, #4] + str r0, [sp, #8] + mov r0, #1 + str r0, [sp, #0xc] + ldr r0, [sp, #0x14] + ldr r3, [sp, #0x10] + add r1, r4, #0 + add r2, r7, #0 + bl ov62_021E6480 + add sp, #0x18 + mov r0, #1 + pop {r3, r4, r5, r6, r7, pc} +_021E6472: + mov r0, #0 + add sp, #0x18 + pop {r3, r4, r5, r6, r7, pc} + .balign 4, 0 +_021E6478: .word 0x00001002 +_021E647C: .word 0x00001333 + thumb_func_end ov62_021E63E8 + + thumb_func_start ov62_021E6480 +ov62_021E6480: ; 0x021E6480 + push {r3, r4, r5, r6, r7, lr} + add r7, r0, #0 + add r5, r2, #0 + ldr r0, _021E656C ; =ov62_021E6570 + add r4, r1, #0 + mov r2, #0 + add r6, r3, #0 + bl SysTask_CreateOnMainQueue + str r0, [r4, #0x2c] + bl SysTask_GetData + add r4, r0, #0 + ldr r0, [sp, #0x24] + str r7, [r4] + str r0, [r4, #4] + cmp r5, #0 + ble _021E64B6 + lsl r0, r5, #0xc + bl _fflt + add r1, r0, #0 + mov r0, #0x3f + lsl r0, r0, #0x18 + bl _fadd + b _021E64C4 +_021E64B6: + lsl r0, r5, #0xc + bl _fflt + mov r1, #0x3f + lsl r1, r1, #0x18 + bl _fsub +_021E64C4: + bl _ffix + str r0, [r4, #8] + cmp r6, #0 + ble _021E64E0 + lsl r0, r6, #0xc + bl _fflt + add r1, r0, #0 + mov r0, #0x3f + lsl r0, r0, #0x18 + bl _fadd + b _021E64EE +_021E64E0: + lsl r0, r6, #0xc + bl _fflt + mov r1, #0x3f + lsl r1, r1, #0x18 + bl _fsub +_021E64EE: + bl _ffix + str r0, [r4, #0xc] + mov r0, #0 + str r0, [r4, #0x10] + ldr r0, [sp, #0x1c] + add r0, #0x5a + lsl r0, r0, #0x10 + lsr r0, r0, #0x10 + bl GF_SinDegNoWrap + add r2, r0, #0 + ldr r0, [sp, #0x18] + asr r3, r2, #0x1f + asr r7, r0, #0x1f + add r1, r7, #0 + str r0, [sp] + bl _ll_mul + add r2, r0, #0 + mov r0, #2 + mov r3, #0 + lsl r0, r0, #0xa + add r0, r2, r0 + adc r1, r3 + lsl r1, r1, #0x14 + lsr r0, r0, #0xc + orr r0, r1 + str r0, [r4, #0x14] + ldr r0, [sp, #0x1c] + lsl r0, r0, #0x10 + lsr r0, r0, #0x10 + bl GF_SinDegNoWrap + add r2, r0, #0 + ldr r0, [sp] + add r1, r7, #0 + asr r3, r2, #0x1f + bl _ll_mul + mov r3, #2 + mov r2, #0 + lsl r3, r3, #0xa + add r3, r0, r3 + adc r1, r2 + lsl r0, r1, #0x14 + lsr r1, r3, #0xc + orr r1, r0 + neg r0, r1 + str r0, [r4, #0x18] + str r2, [r4, #0x1c] + mov r0, #6 + str r2, [r4, #0x20] + lsl r0, r0, #0xc + str r0, [r4, #0x24] + ldr r0, [sp, #0x20] + add r1, r5, #0 + str r0, [r4, #0x28] + ldr r0, [r4] + add r2, r6, #0 + bl UnkImageStruct_SetSpritePositionXY + pop {r3, r4, r5, r6, r7, pc} + .balign 4, 0 +_021E656C: .word ov62_021E6570 + thumb_func_end ov62_021E6480 + + thumb_func_start ov62_021E6570 +ov62_021E6570: ; 0x021E6570 + push {r3, r4, r5, r6, r7, lr} + add r5, r1, #0 + add r7, r0, #0 + ldr r0, [r5, #4] + cmp r0, #0 + beq _021E658C + sub r0, r0, #1 + str r0, [r5, #4] + bne _021E65FC + ldr r0, [r5] + mov r1, #1 + bl UnkImageStruct_SetSpriteVisibleFlag + pop {r3, r4, r5, r6, r7, pc} +_021E658C: + add r0, r5, #0 + add r0, #8 + add r1, #0x14 + add r2, r0, #0 + bl VEC_Add + ldr r0, [r5, #8] + ldr r2, [r5, #0x20] + lsl r0, r0, #4 + asr r6, r0, #0x10 + ldr r0, [r5, #0xc] + ldr r1, [r5, #0x24] + lsl r0, r0, #4 + add r3, r2, r1 + mov r1, #0x5a + asr r4, r0, #0x10 + add r0, r5, #0 + lsl r1, r1, #0xe + add r0, #0x20 + str r3, [r5, #0x20] + cmp r3, r1 + ble _021E65C6 + add r2, r1, #0 +_021E65BA: + ldr r3, [r0] + sub r3, r3, r1 + str r3, [r0] + ldr r3, [r5, #0x20] + cmp r3, r2 + bgt _021E65BA +_021E65C6: + lsl r0, r3, #4 + lsr r0, r0, #0x10 + bl GF_SinDegNoWrap + ldr r1, [r5, #0x28] + add r2, r4, #0 + mul r0, r1 + asr r0, r0, #0xc + add r0, r6, r0 + lsl r0, r0, #0x10 + asr r1, r0, #0x10 + ldr r0, [r5] + bl UnkImageStruct_SetSpritePositionXY + mov r0, #0xf + mvn r0, r0 + cmp r4, r0 + bge _021E65FC + ldr r0, [r5] + mov r1, #0 + bl UnkImageStruct_SetSpriteVisibleFlag + add r0, r7, #0 + bl SysTask_Destroy + mov r0, #0 + str r0, [r5, #0x2c] +_021E65FC: + pop {r3, r4, r5, r6, r7, pc} + .balign 4, 0 + thumb_func_end ov62_021E6570 + + thumb_func_start ov62_021E6600 +ov62_021E6600: ; 0x021E6600 + push {r4, r5, r6, lr} + mov r4, #0 + add r5, r0, #0 + add r6, r4, #0 +_021E6608: + ldr r0, [r5, #0x50] + cmp r0, #0 + beq _021E6614 + bl SysTask_Destroy + str r6, [r5, #0x50] +_021E6614: + add r4, r4, #1 + add r5, #0x30 + cmp r4, #3 + blt _021E6608 + pop {r4, r5, r6, pc} + .balign 4, 0 + thumb_func_end ov62_021E6600 + + thumb_func_start ov62_021E6620 +ov62_021E6620: ; 0x021E6620 + ldr r3, _021E6628 ; =TouchscreenHitbox_FindRectAtTouchNew + ldr r0, _021E662C ; =_021E6650 + bx r3 + nop +_021E6628: .word TouchscreenHitbox_FindRectAtTouchNew +_021E662C: .word _021E6650 + thumb_func_end ov62_021E6620 + + thumb_func_start ov62_021E6630 +ov62_021E6630: ; 0x021E6630 + push {r3, lr} + bl ov62_021E6620 + cmp r0, #0 + beq _021E6644 + ldr r0, _021E664C ; =gSystem + ldr r1, [r0, #0x48] + mov r0, #2 + tst r0, r1 + beq _021E6648 +_021E6644: + mov r0, #1 + pop {r3, pc} +_021E6648: + mov r0, #0 + pop {r3, pc} + .balign 4, 0 +_021E664C: .word gSystem + thumb_func_end ov62_021E6630 + + .rodata + +_021E6650: + .byte 0xA0, 0xC0, 0xB8, 0xF8, 0xFF, 0x00, 0x00, 0x00 + +ov62_021E6658: ; 0x021E6658 + .byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + +ov62_021E6668: ; 0x021E6668 + .byte 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00 + .byte 0x00, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + +ov62_021E667C: ; 0x021E667C + .byte 0x20, 0x00, 0x00, 0x00 + .byte 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00 + +ov62_021E6694: ; 0x021E6694 + .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 + .byte 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 + +ov62_021E66B0: ; 0x021E66B0 + .byte 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00 + +ov62_021E66D0: ; 0x021E66D0 + .byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + +ov62_021E66F8: ; 0x021E66F8 + .byte 0x00, 0x01, 0x01, 0x09, 0x03, 0x00, 0x01, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0F, 0x00, 0x04, 0x05, 0x08, 0x16, 0x05, 0x00, 0x01, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0F, 0x00, 0x04, 0x18, 0x15, 0x06, 0x02, 0x00, 0x6F, 0x00 + .byte 0x04, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0E, 0x00 + +ov62_021E6728: ; 0x021E6728 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1E, 0x01, 0x00, 0x01, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1D, 0x02, 0x00, 0x02, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1E, 0x01, 0x00, 0x01, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00 + +ov62_021E67C8: ; 0x021E67C8 + .byte 0x40, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x00 + .byte 0x03, 0x0A, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x60, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 + .byte 0x01, 0x0A, 0x00, 0x00, 0x03, 0x0A, 0x00, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x04, 0x0A, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x80, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x01, 0x00, 0x00, 0x00, 0x01, 0x0B, 0x00, 0x00, 0x03, 0x0B, 0x00, 0x00, 0x02, 0x0B, 0x00, 0x00 + .byte 0x04, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0xD8, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x0D, 0x00, 0x00, 0x03, 0x0D, 0x00, 0x00 + .byte 0x02, 0x0D, 0x00, 0x00, 0x04, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x00, 0x00 + .byte 0x03, 0x0C, 0x00, 0x00, 0x02, 0x0C, 0x00, 0x00, 0x04, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .public gApplication_MicTest +gApplication_MicTest: + .word ov62_021E5900, ov62_021E5A1C, ov62_021E59C0, 0xFFFFFFFF + + .bss + +_021E68E0: + .space 0x20 diff --git a/include/heap.h b/include/heap.h index 93d2ebc617..1e3fb71b5c 100644 --- a/include/heap.h +++ b/include/heap.h @@ -34,7 +34,6 @@ typedef enum HeapID { HEAP_ID_CERTIFICATES = 82, HEAP_ID_89 = 89, HEAP_ID_ALPH_PUZZLE = 97, - HEAP_ID_MIC_TEST = 98, HEAP_ID_GAME_BOARD = 110, HEAP_ID_BERRY_POTS = 130, HEAP_ID_BERRY_POTS_APP = 131, diff --git a/include/overlay_mic_test.h b/include/overlay_mic_test.h deleted file mode 100644 index dd9bc4bf96..0000000000 --- a/include/overlay_mic_test.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef POKEHEARTGOLD_MIC_TEST_H -#define POKEHEARTGOLD_MIC_TEST_H - -#include "bg_window.h" -#include "msgdata.h" -#include "overlay_manager.h" -#include "system.h" -#include "unk_0200CF18.h" - -extern const OVY_MGR_TEMPLATE gApplication_MicTest; - -#endif // POKEHEARTGOLD_MIC_TEST_H diff --git a/main.lsf b/main.lsf index b4132cbd02..1db1e0489d 100644 --- a/main.lsf +++ b/main.lsf @@ -857,7 +857,7 @@ Overlay OVY_61 Overlay OVY_62 { After main - Object src/overlay_mic_test.o + Object asm/overlay_62.o } Overlay OVY_63 { diff --git a/src/bg_window.c b/src/bg_window.c index 4ed517b065..80bea8596f 100644 --- a/src/bg_window.c +++ b/src/bg_window.c @@ -1384,8 +1384,8 @@ u8 GetBgPriority(BgConfig *bgConfig, u8 bgId) { return 0; } -#define GetPixelAddressFromBlit4bpp(ptr, x, y, width) ((u8 *)((ptr) + (((x) >> 1) & 3) + (((x) << 2) & 0x3FE0) + ((((y) << 2) & 0x3FE0) * (width)) + ((u32)(((y) << 2) & 0x1C)))) -#define GetPixelAddressFromBlit8bpp(ptr, x, y, width) ((u8 *)((ptr) + ((x) & 7) + (((x) << 3) & 0x7FC0) + ((((y) << 3) & 0x7FC0) * (width)) + ((u32)(((y) << 3) & 0x38)))) +#define GetPixelAddressFromBlit4bpp(ptr, x, y, width) ((u8 *)((ptr) + (((x) >> 1) & 3) + (((x) << 2) & 0x3FE0) + ((((y) << 2) & 0x3FE0) * (width)) + (((u32)(((y) << 2) & 0x1C))))) +#define GetPixelAddressFromBlit8bpp(ptr, x, y, width) ((u8 *)((ptr) + ((x) & 7) + (((x) << 3) & 0x7FC0) + ((((y) << 3) & 0x7FC0) * (width)) + (((u32)(((y) << 3) & 0x38))))) #define ConvertPixelsToTiles(x) (((x) + ((x) & 7)) >> 3) void BlitBitmapRect4Bit(const Bitmap *src, const Bitmap *dest, u16 srcX, u16 srcY, u16 destX, u16 destY, u16 width, u16 height, u16 colorKey) { diff --git a/src/overlay_25.c b/src/overlay_25.c index 0311334141..3bc90a47b9 100644 --- a/src/overlay_25.c +++ b/src/overlay_25.c @@ -54,21 +54,20 @@ static const MailMessageTemplate TrainerHouse_DefaultIntroMessage = { .ec_words = { msg_0285_match, 0 }, }; -#define DUMMY_TRAINER_HOUSE_MON \ - { \ - .language = GAME_LANGUAGE, \ - .nickname = { \ - EOS, \ - EOS, \ - EOS, \ - EOS, \ - EOS, \ - EOS, \ - EOS, \ - EOS, \ - EOS, \ - EOS, \ - }, \ +#define DUMMY_TRAINER_HOUSE_MON { \ + .language = GAME_LANGUAGE, \ + .nickname = { \ + EOS, \ + EOS, \ + EOS, \ + EOS, \ + EOS, \ + EOS, \ + EOS, \ + EOS, \ + EOS, \ + EOS, \ + }, \ } static const TrainerHouseSet ov25_02259D9C = { diff --git a/src/overlay_mic_test.c b/src/overlay_mic_test.c deleted file mode 100644 index 1642c148d9..0000000000 --- a/src/overlay_mic_test.c +++ /dev/null @@ -1,1016 +0,0 @@ -#include "overlay_mic_test.h" - -#include "msgdata/msg.naix" -#include "msgdata/msg/msg_0234.h" - -#include "font.h" -#include "gf_gfx_loader.h" -#include "main.h" -#include "math_util.h" -#include "sound.h" -#include "sound_02004A44.h" -#include "system.h" -#include "text.h" -#include "title_screen.h" -#include "touchscreen.h" -#include "unk_02005D10.h" -#include "unk_0200B150.h" -#include "unk_0200FA24.h" -#include "vram_transfer_manager.h" - -typedef struct MicTestData MicTestData; -typedef struct MicTestTaskManager MicTestTaskManager; - -typedef void (*MicTestTask)(MicTestTaskManager *, u32 *); - -typedef struct MicTestInput { - MICAutoParam mic; - void *unk1C; - s32 curVolume; - u32 unk24; - u32 unk28; - u32 unk2C; - u32 unk30; - u32 unk34; -} MicTestInput; - -typedef struct MicTestSub_B8 { - BgConfig *bgConfig; - Window window[3]; - MsgData *msgData; -} MicTestSub_B8; - -struct MicTestTaskManager { - MicTestData *micTest; - MicTestTask task; - u32 state; - u32 isFinished; -}; - -typedef struct MicTestSub_24 { - UnkImageStruct *unk0; - u32 unk4; - VecFx32 unk8; - VecFx32 unk14; - fx32 unk20; // angle? - fx32 unk24; // dTheta? - fx32 unk28; // magnitude? - SysTask *task; -} MicTestSub_24; - -struct MicTestData { - SpriteRenderer *spriteRenderer; - SpriteGfxHandler *gfxHandler; - UnkImageStruct *unk8[7]; - MicTestSub_24 unk24[3]; - u32 unkB4; - MicTestSub_B8 unkB8; - MicTestInput unkF0; - MicTestTaskManager taskMan; - HeapID heapId; -}; - -#define TS_HITBOX_MIC_TEST_RETURN 0 - -static BOOL MicTest_Init(OVY_MANAGER *overlayMan, int *state); -static BOOL MicTest_Exit(OVY_MANAGER *overlayMan, int *state); -static BOOL MicTest_Main(OVY_MANAGER *overlayMan, int *state); -static void MicTest_StartTask(MicTestTaskManager *a0, MicTestData *data, MicTestTask a2); -static void MicTestTaskMan_Run(MicTestTaskManager *a0); -static void MicTest_SetTask(MicTestTaskManager *a0, MicTestTask a1); -static MicTestData *MicTestTaskMan_GetMicTestData(MicTestTaskManager *a0); -static u32 MicTestTaskMan_IsFinished(MicTestTaskManager *a0); -static void MicTestTaskMan_Finish(MicTestTaskManager *a0); -static void MicTestTask_FadeIn(MicTestTaskManager *a0, u32 *state); -static void ov62_021E5B04(MicTestTaskManager *a0, u32 *state); -static void ov62_021E5B6C(MicTestTaskManager *a0, u32 *state); -static void MicTestTask_FadeOut(MicTestTaskManager *taskMan, u32 *state); -static void MicTestTask_End(MicTestTaskManager *taskMan, u32 *state); -static void ov62_021E5C34(HeapID heapId); -static void ov62_021E5C80(); -static void MicTest_SetBanks(); -static void MicTest_VBlankIntrCB(void *data); -static void MicTest_InitSpriteRenderer(MicTestData *micTest, HeapID heapId); -static void MicTest_DeleteSpriteRenderer(MicTestData *micTest); -static void MicTest_UpdateAnimations(MicTestData *micTest); -static void MicTest_LoadResources(MicTestData *micTest); -static void ov62_021E5FA0(MicTestData *micTest); -static void ov62_021E5FC4(MicTestData *micTest); -static void ov62_021E5FD4(MicTestSub_B8 *a0, HeapID heapId); -static void ov62_021E6024(MicTestSub_B8 *a0); -static void ov62_021E6048(MicTestSub_B8 *a0); -static void MicTest_LoadTextResources(MicTestSub_B8 *a0, HeapID heapId); -static void ov62_021E60D4(MicTestSub_B8 *a0); -static void ov62_021E60E4(MicTestSub_B8 *a0, HeapID heapId); -static void ov62_021E6178(MicTestSub_B8 *a0); -static void ov62_021E61AC(MicTestInput *input, HeapID heapId, MICCallback a2, MicTestData *micTest); -static void ov62_021E61FC(MicTestInput *input); -static void ov62_021E620C(MicTestInput *input); -static void ov62_021E625C(MicTestInput *input); -static void ov62_021E6278(MicTestInput *input); -static s32 MicTest_AverageMicInput(MicTestInput *input); -static void MicTest_MicrophoneCallback(MICResult result, void *data); -static u32 MicTest_GetVolumeBracket(u8); -static u32 ov62_021E63D0(MicTestData *micTest); -static BOOL ov62_021E63E8(MicTestData *micTest, HeapID heapId, s16 x, s16 y); -static void ov62_021E6480(UnkImageStruct *a0, MicTestSub_24 *args, s16 x, s16 y, s32 z, s32 r1, s32 r2, BOOL a7); -static void ov62_021E6570(SysTask *, void *); -static void MicTest_EndTasks(MicTestData *micTest); -static int MicTest_CheckReturn(MicTestData *data); - -static const GraphicsBanks sMicTestGraphicsBanks = { - .bg = GX_VRAM_BG_128_A, - .bgextpltt = GX_VRAM_BGEXTPLTT_NONE, - .subbg = GX_VRAM_SUB_BG_128_C, - .subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE, - .obj = GX_VRAM_OBJ_128_B, - .objextpltt = GX_VRAM_OBJEXTPLTT_NONE, - .subobj = GX_VRAM_SUB_OBJ_16_I, - .subobjextpltt = GX_VRAM_SUB_OBJEXTPLTT_NONE, - .tex = GX_VRAM_TEX_NONE, - .texpltt = GX_VRAM_TEXPLTT_NONE -}; - -typedef struct UnkStruct_021E6728 { - BgTemplate bgTemplate; - u8 bgId; - u8 unk1D; - u8 unk1E; - u8 unk1F; -} UnkStruct_021E6728; - -static const UnkStruct_021E6728 ov62_021E6728[] = { - { - .bgTemplate = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .size = 1, - .colorMode = 0, - .screenBase = 0x1F, - .charBase = 0, - .bgExtPltt = 0, - .priority = 0, - .areaOver = 0, - .dummy = 0, - .mosaic = 0, - }, - .bgId = 0, - .unk1D = 0, - .unk1E = 0, - .unk1F = 0, - }, - { - .bgTemplate = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .size = 1, - .colorMode = 0, - .screenBase = 0x1E, - .charBase = 1, - .bgExtPltt = 0, - .priority = 1, - .areaOver = 0, - .dummy = 0, - .mosaic = 0, - }, - .bgId = 1, - .unk1D = 0, - .unk1E = 0, - .unk1F = 0, - }, - { - .bgTemplate = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .size = 1, - .colorMode = 0, - .screenBase = 0x1D, - .charBase = 2, - .bgExtPltt = 0, - .priority = 2, - .areaOver = 0, - .dummy = 0, - .mosaic = 0, - }, - .bgId = 2, - .unk1D = 0, - .unk1E = 0, - .unk1F = 0, - }, - { - .bgTemplate = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .size = 1, - .colorMode = 0, - .screenBase = 0x1F, - .charBase = 0, - .bgExtPltt = 0, - .priority = 0, - .areaOver = 0, - .dummy = 0, - .mosaic = 0, - }, - .bgId = 4, - .unk1D = 0, - .unk1E = 0, - .unk1F = 0, - }, - { - .bgTemplate = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .size = 1, - .colorMode = 0, - .screenBase = 0x1E, - .charBase = 1, - .bgExtPltt = 0, - .priority = 1, - .areaOver = 0, - .dummy = 0, - .mosaic = 0, - }, - .bgId = 5, - .unk1D = 0, - .unk1E = 0, - .unk1F = 0, - }, -}; - -static const UnkTemplate_0200D748 ov62_021E67C8[5] = { - { - .x = 0x40, - .y = 0x60, - .z = 0, - .animation = 0, - .spritePriority = 0, - .pal = 0, - .vram = NNS_G2D_VRAM_TYPE_2DMAIN, - .resIdList = { 0xA01, 0xA03, 0xA02, 0xA04, 0, 0 }, - .bgPriority = 0, - .vramTransfer = 0, - }, - { - .x = 0xC0, - .y = 0x60, - .z = 0, - .animation = 0, - .spritePriority = 0, - .pal = 0, - .vram = NNS_G2D_VRAM_TYPE_2DMAIN, - .resIdList = { 0xA01, 0xA03, 0xA02, 0xA04, 0, 0 }, - .bgPriority = 0, - .vramTransfer = 0, - }, - { - .x = 0x80, - .y = 0x60, - .z = 0, - .animation = 0, - .spritePriority = 0, - .pal = 0, - .vram = NNS_G2D_VRAM_TYPE_2DMAIN, - .resIdList = { 0xB01, 0xB03, 0xB02, 0xB04, 0, 0 }, - .bgPriority = 0, - .vramTransfer = 0, - }, - { - .x = 0xD8, - .y = 0xB0, - .z = 0, - .animation = 0, - .spritePriority = 0, - .pal = 0, - .vram = NNS_G2D_VRAM_TYPE_2DSUB, - .resIdList = { 0xD01, 0xD03, 0xD02, 0xD04, 1, 0 }, - .bgPriority = 0, - .vramTransfer = 0, - }, - { - .x = 0, - .y = 0, - .z = 0, - .animation = 0, - .spritePriority = 0, - .pal = 0, - .vram = NNS_G2D_VRAM_TYPE_2DMAIN, - .resIdList = { 0xC01, 0xC03, 0xC02, 0xC04, 0, 0 }, - .bgPriority = 0, - .vramTransfer = 0, - }, -}; -static const u32 ov62_021E6694[7] = { 0, 1, 2, 3, 4, 4, 4 }; - -static const TouchscreenHitbox sMicTestTouchscreenHitboxes[] = { - { .rect = { 160, 192, 184, 248 } }, // Return - { .rect = { TOUCHSCREEN_RECTLIST_END } }, -}; - -static const OamManagerParam sMicTestOamManParam = { - .fromOBJmain = 0, - .numOBJmain = 128, - .fromAffineMain = 0, - .numAffineMain = 32, - .fromOBJsub = 0, - .numOBJsub = 128, - .fromAffineSub = 0, - .numAffineSub = 32 -}; - -static const OamCharTransferParam ov62_021E6668 = { - 7, - 0x20000, - 0x4000, - GX_OBJVRAMMODE_CHAR_1D_32K, - GX_OBJVRAMMODE_CHAR_1D_32K -}; - -static const SpriteResourceCountsListUnion sMicTestResCountList = { - .numChar = 32, - .numPltt = 32, - .numCell = 32, - .numAnim = 32, - .numMcel = 0, - .numManm = 0 -}; - -static const GraphicsModes sMicTestGraphicsMode = { - .dispMode = GX_DISPMODE_GRAPHICS, - .bgMode = GX_BGMODE_0, - .subMode = GX_BGMODE_0, - ._2d3dMode = GX_BG0_AS_2D -}; - -typedef struct MicTestTextBox { - u8 bgId; - u8 x; - u8 y; - u8 width; - u8 height; - u8 palNum; - u16 baseTile; - u8 fontId; - u32 color; -} MicTestTextBox; - -static const MicTestTextBox sMicTestTextBoxes[3] = { - { .bgId = 0, - .x = 1, - .y = 1, - .width = 9, - .height = 3, - .palNum = 0, - .baseTile = 1, - .fontId = 0, - .color = MAKE_TEXT_COLOR(15, 2, 0) }, - { .bgId = 4, - .x = 5, - .y = 8, - .width = 22, - .height = 5, - .palNum = 0, - .baseTile = 1, - .fontId = 0, - .color = MAKE_TEXT_COLOR(15, 2, 0) }, - { .bgId = 4, - .x = 24, - .y = 21, - .width = 6, - .height = 2, - .palNum = 0, - .baseTile = 0x6F, - .fontId = 4, - .color = MAKE_TEXT_COLOR(14, 15, 0) }, -}; - -const OVY_MGR_TEMPLATE gApplication_MicTest = { MicTest_Init, MicTest_Main, MicTest_Exit, FS_OVERLAY_ID_NONE }; - -static BOOL MicTest_Init(OVY_MANAGER *overlayMan, int *state) { - CreateHeap(HEAP_ID_3, HEAP_ID_MIC_TEST, 0x30000); - - MicTestData *micTest = OverlayManager_CreateAndGetData(overlayMan, sizeof(MicTestData), HEAP_ID_MIC_TEST); - - MI_CpuFill8(micTest, 0, sizeof(MicTestData)); - - micTest->heapId = HEAP_ID_MIC_TEST; - - ov62_021E5C34(micTest->heapId); - MicTest_SetBanks(); - Main_SetVBlankIntrCB(MicTest_VBlankIntrCB, micTest); - FontID_Alloc(4, HEAP_ID_MIC_TEST); - ov62_021E5FD4(&micTest->unkB8, micTest->heapId); - MicTest_LoadTextResources(&micTest->unkB8, micTest->heapId); - ov62_021E60E4(&micTest->unkB8, micTest->heapId); - MicTest_InitSpriteRenderer(micTest, micTest->heapId); - MicTest_LoadResources(micTest); - ov62_021E61AC(&micTest->unkF0, micTest->heapId, MicTest_MicrophoneCallback, micTest); - - MicTest_StartTask(&micTest->taskMan, micTest, MicTestTask_FadeIn); - - GF_SndStartFadeOutBGM(0, 10); - - return TRUE; -} - -static BOOL MicTest_Exit(OVY_MANAGER *overlayMan, int *state) { - MicTestData *micTest = OverlayManager_GetData(overlayMan); - ov62_021E61FC(&micTest->unkF0); - ov62_021E5FA0(micTest); - MicTest_DeleteSpriteRenderer(micTest); - ov62_021E6178(&micTest->unkB8); - ov62_021E6024(&micTest->unkB8); - ov62_021E5C80(); - FontID_Release(4); - OverlayManager_FreeData(overlayMan); - DestroyHeap(micTest->heapId); - RegisterMainOverlay(FS_OVERLAY_ID(intro_title), &gApplication_TitleScreen); - return TRUE; -} - -static BOOL MicTest_Main(OVY_MANAGER *overlayMan, int *state) { - MicTestData *micTest = OverlayManager_GetData(overlayMan); - if (MicTestTaskMan_IsFinished(&micTest->taskMan)) { - return TRUE; - } - MicTestTaskMan_Run(&micTest->taskMan); - MicTest_UpdateAnimations(micTest); - ov62_021E6048(&micTest->unkB8); - ov62_021E620C(&micTest->unkF0); - return FALSE; -} - -static void MicTest_StartTask(MicTestTaskManager *taskMan, MicTestData *micTest, MicTestTask task) { - taskMan->micTest = micTest; - taskMan->isFinished = FALSE; - MicTest_SetTask(taskMan, task); -} - -static void MicTestTaskMan_Run(MicTestTaskManager *taskMan) { - if (MicTestTaskMan_IsFinished(taskMan) == 0) { - taskMan->task(taskMan, &taskMan->state); - } -} - -static void MicTest_SetTask(MicTestTaskManager *taskMan, MicTestTask task) { - taskMan->task = task; - taskMan->state = 0; -} - -static MicTestData *MicTestTaskMan_GetMicTestData(MicTestTaskManager *taskMan) { - return taskMan->micTest; -} - -static u32 MicTestTaskMan_IsFinished(MicTestTaskManager *taskMan) { - return taskMan->isFinished; -} - -static void MicTestTaskMan_Finish(MicTestTaskManager *taskMan) { - taskMan->isFinished = TRUE; -} - -enum { - MICTEST_FADE_IN_STATE_START, - MICTEST_FADE_IN_STATE_WAIT, - MICTEST_FADE_IN_STATE_END -}; - -static void MicTestTask_FadeIn(MicTestTaskManager *taskMan, u32 *state) { - MicTestData *micTest = MicTestTaskMan_GetMicTestData(taskMan); - - switch (*state) { - case MICTEST_FADE_IN_STATE_START: - BeginNormalPaletteFade(0, 1, 1, RGB_BLACK, 6, 1, micTest->heapId); - *state = MICTEST_FADE_IN_STATE_WAIT; - break; - case MICTEST_FADE_IN_STATE_WAIT: - if (IsPaletteFadeFinished()) { - *state = MICTEST_FADE_IN_STATE_END; - } - break; - case MICTEST_FADE_IN_STATE_END: - MicTest_SetTask(taskMan, ov62_021E5B04); - break; - default: - GF_ASSERT(FALSE); - } -} - -static void ov62_021E5B04(MicTestTaskManager *taskMan, u32 *state) { - MicTestData *micTest = MicTestTaskMan_GetMicTestData(taskMan); - - switch (*state) { - case 0: - ov62_021E625C(&micTest->unkF0); - (*state) = 1; - break; - case 1: - if (MicTest_CheckReturn(micTest)) { - PlaySE(SEQ_SE_DP_SELECT); - (*state) = 2; - } - break; - case 2: - ov62_021E6278(&micTest->unkF0); - (*state) = 3; - break; - case 3: - MicTest_SetTask(taskMan, ov62_021E5B6C); - break; - default: - GF_ASSERT(FALSE); - break; - } -} - -static void ov62_021E5B6C(MicTestTaskManager *taskMan, u32 *state) { - MicTestData *micTest = MicTestTaskMan_GetMicTestData(taskMan); - - switch (*state) { - case 0: - UnkImageStruct_SetSpriteAnimSeqNo(micTest->unk8[3], 1); - (*state) = 1; - break; - case 1: - if (!sub_0200DCA0(micTest->unk8[3])) { - (*state) = 2; - } - break; - case 2: - MicTest_SetTask(taskMan, MicTestTask_FadeOut); - break; - default: - GF_ASSERT(FALSE); - } -} - -enum { - MICTEST_FADE_OUT_STATE_START, - MICTEST_FADE_OUT_STATE_WAIT, - MICTEST_FADE_OUT_STATE_END, -}; - -static void MicTestTask_FadeOut(MicTestTaskManager *taskMan, u32 *state) { - MicTestData *micTest = MicTestTaskMan_GetMicTestData(taskMan); - - switch (*state) { - case MICTEST_FADE_OUT_STATE_START: - BeginNormalPaletteFade(0, 0, 0, RGB_BLACK, 6, 1, micTest->heapId); - (*state) = MICTEST_FADE_OUT_STATE_WAIT; - break; - case MICTEST_FADE_OUT_STATE_WAIT: - if (IsPaletteFadeFinished()) { - (*state) = MICTEST_FADE_OUT_STATE_END; - } - break; - case MICTEST_FADE_OUT_STATE_END: - MicTest_SetTask(taskMan, MicTestTask_End); - break; - default: - GF_ASSERT(FALSE); - } -} - -static void MicTestTask_End(MicTestTaskManager *taskMan, u32 *state) { - MicTestData *micTest = MicTestTaskMan_GetMicTestData(taskMan); - MicTest_EndTasks(micTest); - MicTestTaskMan_Finish(taskMan); -} - -static void ov62_021E5C34(HeapID heapId) { - Main_SetVBlankIntrCB(NULL, NULL); - HBlankInterruptDisable(); - GfGfx_DisableEngineAPlanes(); - GfGfx_DisableEngineBPlanes(); - GX_SetVisiblePlane(0); - GXS_SetVisiblePlane(0); - sub_0200FBDC(0); - sub_0200FBDC(1); - GF_CreateVramTransferManager(0x20, heapId); -} - -static void ov62_021E5C80() { - GF_DestroyVramTransferManager(); - Main_SetVBlankIntrCB(NULL, NULL); - HBlankInterruptDisable(); - GfGfx_DisableEngineAPlanes(); - GfGfx_DisableEngineBPlanes(); - GX_SetVisiblePlane(0); - GXS_SetVisiblePlane(0); -} - -static void MicTest_SetBanks() { - GfGfx_SetBanks(&sMicTestGraphicsBanks); -} - -static void MicTest_VBlankIntrCB(void *data) { - MicTestData *micTest = data; - NNS_GfdDoVramTransfer(); - ov62_021E5FC4(micTest); - ov62_021E60D4(&micTest->unkB8); - OS_SetIrqCheckFlag(OS_IE_VBLANK); -} - -static void MicTest_InitSpriteRenderer(MicTestData *micTest, HeapID heapId) { - SpriteRenderer *spriteRender = SpriteRenderer_Create(heapId); - - micTest->spriteRenderer = spriteRender; - SpriteRenderer_CreateOamCharPlttManagers(spriteRender, &sMicTestOamManParam, &ov62_021E6668, 0x20); - sub_0200B2E0(heapId); - sub_0200B2E8(heapId); - micTest->gfxHandler = SpriteRenderer_CreateGfxHandler(micTest->spriteRenderer); - SpriteRenderer_CreateSpriteList(micTest->spriteRenderer, micTest->gfxHandler, 7); - SpriteRenderer_Init2DGfxResManagersFromCountsArray(micTest->spriteRenderer, micTest->gfxHandler, (SpriteResourceCountsListUnion *)&sMicTestResCountList); - GfGfx_EngineATogglePlanes(GX_PLANEMASK_OBJ, GF_PLANE_TOGGLE_ON); - GfGfx_EngineBTogglePlanes(GX_PLANEMASK_OBJ, GF_PLANE_TOGGLE_ON); -} - -void MicTest_DeleteSpriteRenderer(MicTestData *micTest) { - SpriteRenderer_Delete(micTest->spriteRenderer); - micTest->spriteRenderer = NULL; -} - -static void MicTest_UpdateAnimations(MicTestData *micTest) { - for (u16 i = 0; i < 7; i++) { - UnkImageStruct_TickSpriteAnimation1Frame(micTest->unk8[i]); - } - SpriteGfxHandler_RenderAndAnimateSprites(micTest->gfxHandler); -} - -static void MicTest_LoadResources(MicTestData *micTest) { - SpriteRenderer_LoadPlttResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 6, 0, 1, NNS_G2D_VRAM_TYPE_2DMAIN, 0xA03); - SpriteRenderer_LoadCellResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 8, 0, 0xA02); - SpriteRenderer_LoadAnimResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 9, 0, 0xA04); - SpriteRenderer_LoadCharResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 7, 0, NNS_G2D_VRAM_TYPE_2DMAIN, 0xa01); - - SpriteRenderer_LoadPlttResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 10, 0, 1, NNS_G2D_VRAM_TYPE_2DMAIN, 0xB03); - SpriteRenderer_LoadCellResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 12, 0, 0xB02); - SpriteRenderer_LoadAnimResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 13, 0, 0xB04); - SpriteRenderer_LoadCharResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 11, 0, NNS_G2D_VRAM_TYPE_2DMAIN, 0xB01); - - SpriteRenderer_LoadPlttResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 18, 0, 1, NNS_G2D_VRAM_TYPE_2DSUB, 0xD03); - SpriteRenderer_LoadCellResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 20, 0, 0xD02); - SpriteRenderer_LoadAnimResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 21, 0, 0xD04); - SpriteRenderer_LoadCharResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 19, 0, NNS_G2D_VRAM_TYPE_2DSUB, 0xD01); - - SpriteRenderer_LoadPlttResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 14, 0, 1, NNS_G2D_VRAM_TYPE_2DMAIN, 0xC03); - SpriteRenderer_LoadCellResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 16, 0, 0xC02); - SpriteRenderer_LoadAnimResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 17, 0, 0xC04); - SpriteRenderer_LoadCharResObjFromNarcId(micTest->spriteRenderer, micTest->gfxHandler, NARC_a_1_7_6, 15, 0, NNS_G2D_VRAM_TYPE_2DMAIN, 0xC01); - - for (u16 i = 0; i < 7; i++) { - micTest->unk8[i] = SpriteRenderer_LoadResourcesAndCreateSprite(micTest->spriteRenderer, micTest->gfxHandler, &ov62_021E67C8[ov62_021E6694[i]]); - UnkImageStruct_SetSpriteAnimActiveFlag(micTest->unk8[i], TRUE); - } - - for (u16 i = 0; i < 3; i++) { - UnkImageStruct_SetSpriteVisibleFlag(micTest->unk8[4 + i], 0); - } - - sub_0200E0C0(micTest->unk8[0], 1); - UnkImageStruct_SetSpritePriority(micTest->unk8[3], 1); - micTest->unkB4 = 10; -} - -static void ov62_021E5FA0(MicTestData *micTest) { - for (int i = 0; i < 7; i++) { - if (micTest->unk8[i] != NULL) { - UnkImageStruct_Delete(micTest->unk8[i]); - } - } - SpriteRenderer_UnloadResourcesAndRemoveGfxHandler(micTest->spriteRenderer, micTest->gfxHandler); -} - -static void ov62_021E5FC4(MicTestData *micTest) { - if (micTest->spriteRenderer != NULL) { - thunk_OamManager_ApplyAndResetBuffers(); - } -} - -static void ov62_021E5FD4(MicTestSub_B8 *a0, HeapID heapId) { - a0->bgConfig = BgConfig_Alloc(heapId); - SetBothScreensModesAndDisable(&sMicTestGraphicsMode); - - for (u32 i = 0; i < 5; i++) { - InitBgFromTemplate(a0->bgConfig, ov62_021E6728[i].bgId, &ov62_021E6728[i].bgTemplate, ov62_021E6728[i].unk1D); - BgClearTilemapBufferAndCommit(a0->bgConfig, ov62_021E6728[i].bgId); - BG_ClearCharDataRange(ov62_021E6728[i].bgId, 32, 0, heapId); - } -} - -static void ov62_021E6024(MicTestSub_B8 *a0) { - for (u32 i = 0; i < 5; i++) { - FreeBgTilemapBuffer(a0->bgConfig, ov62_021E6728[i].bgId); - } - FreeToHeap(a0->bgConfig); -} - -static void ov62_021E6048(MicTestSub_B8 *a0) { -} - -static void MicTest_LoadTextResources(MicTestSub_B8 *a0, HeapID heapId) { - GfGfxLoader_GXLoadPal(NARC_a_1_7_6, 0, GF_PAL_LOCATION_MAIN_BG, GF_PAL_SLOT_0_OFFSET, 32, heapId); - GfGfxLoader_LoadCharData(NARC_a_1_7_6, 4, a0->bgConfig, GF_BG_LYR_SUB_1, 0, 0, 0, heapId); - GfGfxLoader_LoadScrnData(NARC_a_1_7_6, 5, a0->bgConfig, GF_BG_LYR_SUB_1, 0, 0, 0, heapId); - - GfGfxLoader_GXLoadPal(NARC_a_1_7_6, 1, GF_PAL_LOCATION_SUB_BG, GF_PAL_SLOT_0_OFFSET, 32, heapId); - GfGfxLoader_LoadCharData(NARC_a_1_7_6, 2, a0->bgConfig, GF_BG_LYR_MAIN_1, 0, 0, 0, heapId); - GfGfxLoader_LoadScrnData(NARC_a_1_7_6, 3, a0->bgConfig, GF_BG_LYR_MAIN_1, 0, 0, 0, heapId); -} - -static void ov62_021E60D4(MicTestSub_B8 *a0) { - if (a0->bgConfig != NULL) { - DoScheduledBgGpuUpdates(a0->bgConfig); - } -} - -static void ov62_021E60E4(MicTestSub_B8 *a0, HeapID heapId) { - a0->msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, NARC_msg_msg_0234_bin, heapId); - - for (int i = 0; i < 3; i++) { - AddWindowParameterized(a0->bgConfig, &a0->window[i], sMicTestTextBoxes[i].bgId, sMicTestTextBoxes[i].x, sMicTestTextBoxes[i].y, sMicTestTextBoxes[i].width, sMicTestTextBoxes[i].height, sMicTestTextBoxes[i].palNum, sMicTestTextBoxes[i].baseTile); - FillWindowPixelBuffer(&a0->window[i], 0); - ClearWindowTilemap(&a0->window[i]); - String *str = NewString_ReadMsgData(a0->msgData, i); - AddTextPrinterParameterizedWithColor(&a0->window[i], sMicTestTextBoxes[i].fontId, str, 0, 0, 0xFF, sMicTestTextBoxes[i].color, 0); - String_Delete(str); - CopyWindowToVram(&a0->window[i]); - } -} - -static void ov62_021E6178(MicTestSub_B8 *a0) { - for (int i = 0; i < 3; i++) { - ClearWindowTilemapAndCopyToVram(&a0->window[i]); - FillWindowPixelBuffer(&a0->window[i], 0); - ClearWindowTilemap(&a0->window[i]); - RemoveWindow(&a0->window[i]); - } - DestroyMsgData(a0->msgData); -} - -static void ov62_021E61AC(MicTestInput *input, HeapID heapId, MICCallback a2, MicTestData *micTest) { - Sys_SetSleepDisableFlag(8); - - void *data = AllocFromHeap(heapId, 0x120); - MI_CpuFill8(data, 0, 0x120); - input->unk1C = data; - - input->mic.type = MIC_SAMPLING_TYPE_8BIT; - input->mic.buffer = (void *)((((u32)data) + 0x1F) & ~0x1F); // alignment to 32-bit boundary - input->mic.size = 256; - input->mic.rate = 0x1040; - input->mic.loop_enable = TRUE; - input->mic.full_callback = a2; - input->mic.full_arg = micTest; - - input->unk34 = sub_02005518(); -} - -static void ov62_021E61FC(MicTestInput *input) { - FreeToHeap(input->unk1C); - Sys_ClearSleepDisableFlag(8); -} - -static void ov62_021E620C(MicTestInput *input) { - u32 next = sub_02005518(); - - if (next == 0 || input->unk34 == 0) { - if (input->unk30 == 0) { - if (input->unk28) { - ov62_021E6278(input); - input->unk2C = 1; - } - input->unk30 = 1; - } - - if (next != 0 && input->unk34 == 0) { - input->unk30 = 0; - - if (input->unk2C) { - ov62_021E625C(input); - input->unk2C = 0; - } - } - } - - input->unk34 = next; -} - -static void ov62_021E625C(MicTestInput *input) { - if (input->unk30 == 0) { - GF_MIC_StartAutoSampling(&input->mic); - input->unk28 = 1; - } else { - input->unk2C = 1; - } -} - -static void ov62_021E6278(MicTestInput *input) { - GF_MIC_StopAutoSampling(); - input->unk28 = 0; -} - -static s32 MicTest_AverageMicInput(MicTestInput *input) { - int i; - u8 *buffer; - - int cnt = 0; - int size = input->mic.size - 1; - buffer = input->mic.buffer; - - for (i = 0; i < size; i++) { - if (buffer[i] < 0x80) { - cnt += 0x100 - buffer[i]; - } else { - cnt += buffer[i]; - } - } - return cnt / size; -} - -static struct { - u32 unk0; -} _021E68E0; - -static void MicTest_MicrophoneCallback(MICResult result, void *data) { - MicTestData *micTest = data; - - if (result != MIC_RESULT_SUCCESS) { - return; - } - - MicTestInput *unkF0 = &micTest->unkF0; - - s32 volumeAvg = MicTest_AverageMicInput(unkF0); - u32 volume; - - if (unkF0->curVolume < volumeAvg) { - volume = MicTest_GetVolumeBracket(volumeAvg); - unkF0->curVolume = volumeAvg; - unkF0->unk24 = 1; - } else { - volume = MicTest_GetVolumeBracket(unkF0->curVolume); - unkF0->curVolume -= 2; - } - - if (volume) { - if (unkF0->unk24) { - UnkImageStruct_SetSpriteAnimSeqNo(micTest->unk8[2], 1); - unkF0->unk24 = 0; - } - - if (ov62_021E63D0(micTest)) { - ov62_021E63E8(micTest, micTest->heapId, 0x80, 0x40); - } else { - micTest->unkB4--; - if (micTest->unkB4 == 0) { - ov62_021E63E8(micTest, micTest->heapId, 0x80, 0x40); - micTest->unkB4 = 10; - } - } - - UnkImageStruct_SetSpriteAnimSeqNo(micTest->unk8[0], volume); - UnkImageStruct_SetSpriteAnimSeqNo(micTest->unk8[1], volume); - } else if (volume == 0) { - UnkImageStruct_SetSpriteAnimSeqNo(micTest->unk8[2], 0); - UnkImageStruct_SetSpriteAnimSeqNo(micTest->unk8[0], 0); - UnkImageStruct_SetSpriteAnimSeqNo(micTest->unk8[1], 0); - } - - _021E68E0.unk0++; -} - -static u32 MicTest_GetVolumeBracket(u8 volume) { - u32 ret; - - if (volume <= 140) { - ret = 0; - } else if (volume >= 141 && volume <= 152) { - ret = 1; - } else if (volume >= 153 && volume <= 166) { - ret = 2; - } else if (volume >= 167 && volume <= 187) { - ret = 3; - } else if (volume >= 188) { - ret = 4; - } else { - GF_ASSERT(FALSE); - } - - return ret; -} - -static u32 ov62_021E63D0(MicTestData *micTest) { - for (int i = 0; i < 3; i++) { - if (micTest->unk24[i].task) { - return 0; - } - } - return 1; -} - -static BOOL ov62_021E63E8(MicTestData *micTest, HeapID heapId, s16 x, s16 y) { - UnkImageStruct *flag = 0; - MicTestSub_24 *args = NULL; - for (int i = 0; i < 3; i++) { - if (micTest->unk24[i].task == NULL) { - args = &micTest->unk24[i]; - flag = micTest->unk8[i + 4]; - break; - } - } - - if (args != NULL) { - s32 rand1 = (LCRandom() * 4098 / 0x10000) + 4915; - s32 rand2 = (LCRandom() * 62 / 0x10000) + 60; - s32 rand3 = (LCRandom() * 16 / 0x10000) + 6; - ov62_021E6480(flag, args, x, y, rand1, rand2, rand3, 1); - return TRUE; - } - - return FALSE; -} - -static void ov62_021E6480(UnkImageStruct *a0, MicTestSub_24 *args, s16 x, s16 y, s32 z, s32 r1, s32 r2, BOOL a7) { - args->task = SysTask_CreateOnMainQueue(ov62_021E6570, args, 0); - MicTestSub_24 *data = SysTask_GetData(args->task); - - data->unk0 = a0; - data->unk4 = a7; - - data->unk8.x = FX32_CONST(x); - data->unk8.y = FX32_CONST(y); - data->unk8.z = 0; - - s32 sine = GF_SinDegNoWrap(r1 + 90); - data->unk14.x = FX_MUL(z, sine); - sine = GF_SinDegNoWrap(r1); - data->unk14.y = -FX_MUL(z, sine); - data->unk14.z = 0; - - data->unk20 = 0; - data->unk24 = FX32_CONST(6); - data->unk28 = r2; - - UnkImageStruct_SetSpritePositionXY(data->unk0, x, y); -} - -static void ov62_021E6570(SysTask *task, void *_data) { - MicTestSub_24 *data = _data; - - if (data->unk4) { - if (--data->unk4 == 0) { - UnkImageStruct_SetSpriteVisibleFlag(data->unk0, TRUE); - } - return; - } - - VEC_Add(&data->unk8, &data->unk14, &data->unk8); - - s16 x = data->unk8.x >> FX32_SHIFT; - s16 y = data->unk8.y >> FX32_SHIFT; - data->unk20 = data->unk20 + data->unk24; - - while (data->unk20 > FX32_CONST(360)) { - data->unk20 -= FX32_CONST(360); - } - - x += GF_SinDegNoWrap(data->unk20 >> FX32_SHIFT) * data->unk28 >> FX32_SHIFT; - - UnkImageStruct_SetSpritePositionXY(data->unk0, x, y); - - if (y < -16) { - UnkImageStruct_SetSpriteVisibleFlag(data->unk0, FALSE); - SysTask_Destroy(task); - data->task = NULL; - } -} - -static void MicTest_EndTasks(MicTestData *micTest) { - for (int i = 0; i < 3; i++) { - if (micTest->unk24[i].task != NULL) { - SysTask_Destroy(micTest->unk24[i].task); - micTest->unk24[i].task = NULL; - } - } -} - -static int MicTest_CheckTouchscreenInput() { - return TouchscreenHitbox_FindRectAtTouchNew(&sMicTestTouchscreenHitboxes[0]); -} - -static int MicTest_CheckReturn(MicTestData *data) { - if (MicTest_CheckTouchscreenInput() == TS_HITBOX_MIC_TEST_RETURN || (gSystem.newKeys & PAD_BUTTON_B)) { - return TRUE; - } - return FALSE; -} diff --git a/src/pokemon.c b/src/pokemon.c index 69c4de0f3b..ba3bb1dc84 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -64,8 +64,8 @@ void sub_02072190(BoxPokemon *boxMon, PlayerProfile *a1, u32 pokeball, u32 a3, u #define DECRYPT_PTY(mon) MonDecryptSegment(ENCRY_ARGS_PTY(mon)) #define DECRYPT_BOX(boxMon) MonDecryptSegment(ENCRY_ARGS_BOX(boxMon)) #define CHECKSUM(boxMon) CalcMonChecksum((u16 *)(boxMon)->substructs, sizeof((boxMon)->substructs)) -#define SHINY_CHECK(otid, pid) (( \ - (((otid) & 0xFFFF0000u) >> 16u) ^ ((otid) & 0xFFFFu) ^ (((pid) & 0xFFFF0000u) >> 16u) ^ ((pid) & 0xFFFFu)) \ +#define SHINY_CHECK(otid, pid) (( \ + ((((otid) & 0xFFFF0000u) >> 16u)) ^ (((otid) & 0xFFFFu)) ^ ((((pid) & 0xFFFF0000u) >> 16u)) ^ (((pid) & 0xFFFFu))) \ < 8u) #define CALC_UNOWN_LETTER(pid) ((u32)((((pid) & 0x3000000) >> 18) | (((pid) & 0x30000) >> 12) | (((pid) & 0x300) >> 6) | (((pid) & 0x3) >> 0)) % 28u)