diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index 031bf2128..9a8b378ac 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -12802,7 +12802,7 @@ _08104EDC: lsls r0, 16 cmp r2, r0 bgt _08104F1A - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r4, r0 @@ -12839,7 +12839,7 @@ _08104F1A: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams ldr r0, =sub_8104F54 str r0, [r5] add sp, 0xC @@ -12919,7 +12919,7 @@ _08104FCC: ldrsh r0, [r3, r1] cmp r0, 0 blt _08104FF0 - ldr r2, =gUnknown_02038C28 + ldr r2, =gScanlineEffectRegBuffers lsls r0, 1 adds r0, r2 ldrh r1, [r3, 0x14] @@ -12943,7 +12943,7 @@ _08104FF0: ldrsh r1, [r3, r2] cmp r0, r1 blt _0810500E - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] adds r0, r4, 0 @@ -18518,7 +18518,7 @@ _08107D8C: movs r3, 0 movs r2, 0x10 ldrsh r0, [r4, r2] - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers mov r12, r1 cmp r3, r0 bge _08107DCA @@ -18555,7 +18555,7 @@ _08107DCA: ldrsh r0, [r4, r3] cmp r1, r0 bge _08107E04 - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r5, r0 @@ -18584,7 +18584,7 @@ _08107E04: asrs r0, r2, 16 cmp r0, 0x9F bgt _08107E3A - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r5, r0 @@ -18652,7 +18652,7 @@ _08107E7A: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams ldrh r0, [r4, 0x8] adds r0, 0x1 strh r0, [r4, 0x8] @@ -18689,8 +18689,8 @@ _08107ED8: ldrsh r0, [r4, r1] cmp r3, r0 bge _08107F0C - ldr r6, =gUnknown_02038C28 - ldr r5, =gUnknown_02039B28 + ldr r6, =gScanlineEffectRegBuffers + ldr r5, =gScanlineEffect _08107EE6: lsls r1, r3, 16 asrs r1, 16 @@ -18719,8 +18719,8 @@ _08107F0C: ldrsh r0, [r4, r3] cmp r1, r0 bge _08107F40 - ldr r6, =gUnknown_02038C28 - ldr r5, =gUnknown_02039B28 + ldr r6, =gScanlineEffectRegBuffers + ldr r5, =gScanlineEffect _08107F1E: asrs r3, r2, 16 lsls r2, r3, 1 @@ -18745,8 +18745,8 @@ _08107F40: asrs r0, r1, 16 cmp r0, 0x9F bgt _08108022 - ldr r6, =gUnknown_02038C28 - ldr r5, =gUnknown_02039B28 + ldr r6, =gScanlineEffectRegBuffers + ldr r5, =gScanlineEffect _08107F4E: asrs r3, r1, 16 lsls r2, r3, 1 @@ -18771,8 +18771,8 @@ _08107F78: ldrsh r0, [r4, r1] cmp r3, r0 bge _08107FAC - ldr r6, =gUnknown_02038C28 - ldr r5, =gUnknown_02039B28 + ldr r6, =gScanlineEffectRegBuffers + ldr r5, =gScanlineEffect _08107F86: lsls r1, r3, 16 asrs r1, 16 @@ -18801,8 +18801,8 @@ _08107FAC: ldrsh r0, [r4, r3] cmp r1, r0 bge _08107FE0 - ldr r6, =gUnknown_02038C28 - ldr r5, =gUnknown_02039B28 + ldr r6, =gScanlineEffectRegBuffers + ldr r5, =gScanlineEffect _08107FBE: asrs r3, r2, 16 lsls r2, r3, 1 @@ -18827,8 +18827,8 @@ _08107FE0: asrs r0, r1, 16 cmp r0, 0x9F bgt _0810800C - ldr r6, =gUnknown_02038C28 - ldr r5, =gUnknown_02039B28 + ldr r6, =gScanlineEffectRegBuffers + ldr r5, =gScanlineEffect _08107FEE: asrs r3, r1, 16 lsls r2, r3, 1 @@ -34618,7 +34618,7 @@ _0810FEC0: adds r0, 0x40 cmp r1, r0 bgt _0810FEFA - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r5, r0 @@ -34651,7 +34651,7 @@ _0810FEFA: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams ldr r0, =sub_810FF34 str r0, [r4] add sp, 0xC @@ -34700,7 +34700,7 @@ _0810FF66: ldr r0, =gSineTable mov r9, r0 movs r7, 0x3 - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers mov r12, r1 movs r2, 0xF0 lsls r2, 3 @@ -34775,7 +34775,7 @@ _0810FFFE: ble _08110026 b _08110014 _0811000E: - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] _08110014: @@ -38728,7 +38728,7 @@ _08112054: _0811206C: movs r2, 0x2 movs r3, 0x6 - bl sub_80BA384 + bl ScanlineEffect_InitWave lsls r0, 24 lsrs r0, 24 strh r0, [r5, 0x1C] @@ -38884,7 +38884,7 @@ _081121A8: beq _081121F0 b _08112258 _081121AE: - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] movs r0, 0x1 @@ -41152,7 +41152,7 @@ _0811345A: ldrsh r0, [r4, r1] cmp r3, r0 bgt _08113488 - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r5, r0 @@ -41175,7 +41175,7 @@ _08113488: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams ldr r0, =sub_81134B8 str r0, [r4] add sp, 0xC @@ -41264,7 +41264,7 @@ _0811354E: bl sub_8113574 b _0811356E _08113556: - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] ldrh r0, [r2, 0x8] @@ -41292,11 +41292,11 @@ sub_8113574: @ 8113574 ldrsh r0, [r5, r1] cmp r4, r0 bgt _081135CA - ldr r7, =gUnknown_02038C28 + ldr r7, =gScanlineEffectRegBuffers mov r12, r7 ldr r0, =gSineTable mov r8, r0 - ldr r6, =gUnknown_02039B28 + ldr r6, =gScanlineEffect _08113592: lsls r2, r4, 1 ldrb r1, [r6, 0x14] @@ -42169,7 +42169,7 @@ _08113CB0: movs r0, 0x3 bl sub_8114374 movs r3, 0 - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r4, r0 @@ -42189,7 +42189,7 @@ _08113CDC: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams movs r0, 0x3F eors r7, r0 movs r1, 0xFC @@ -42344,7 +42344,7 @@ _08113E3E: b _08113E5E .pool _08113E58: - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] _08113E5E: @@ -42534,7 +42534,7 @@ _08114002: str r0, [sp, 0x10] movs r3, 0 add r4, sp, 0x10 - ldr r6, =gUnknown_02038C28 + ldr r6, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r7, r6, r0 @@ -42563,7 +42563,7 @@ _08114010: strb r2, [r4, 0x9] ldr r0, [sp, 0x10] ldr r2, [r4, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams _08114044: ldrh r0, [r5, 0x8] adds r0, 0x1 @@ -42772,7 +42772,7 @@ _081141DA: bne _08114232 b _08114204 _081141FE: - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] _08114204: @@ -42827,9 +42827,9 @@ sub_8114244: @ 8114244 movs r4, 0 cmp r0, 0 ble _081142A4 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers mov r12, r0 - ldr r7, =gUnknown_02039B28 + ldr r7, =gScanlineEffect _08114278: lsls r2, r4, 16 asrs r2, 16 @@ -42861,9 +42861,9 @@ _081142A4: ldrsh r0, [r6, r2] cmp r1, r0 bgt _081142EE - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers mov r12, r0 - ldr r7, =gUnknown_02039B28 + ldr r7, =gScanlineEffect _081142B8: asrs r4, r3, 16 cmp r4, 0 @@ -42904,8 +42904,8 @@ _081142EE: ldrsh r0, [r6, r3] cmp r1, r0 bge _08114366 - ldr r7, =gUnknown_02038C28 - ldr r4, =gUnknown_02039B28 + ldr r7, =gScanlineEffectRegBuffers + ldr r4, =gScanlineEffect _08114306: asrs r3, r2, 16 cmp r3, 0 @@ -42935,7 +42935,7 @@ _08114338: adds r5, r0, 0 adds r5, 0x9F movs r4, 0 - ldr r3, =gUnknown_02038C28 + ldr r3, =gScanlineEffectRegBuffers movs r2, 0xF0 lsls r2, 3 adds r6, r3, r2 @@ -44235,7 +44235,7 @@ _08114E4E: b _08114E7E .pool _08114E78: - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] _08114E7E: @@ -44510,7 +44510,7 @@ _08115094: ldrsh r0, [r0, r1] cmp r0, 0 bne _081150DA - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] _081150C2: @@ -44561,7 +44561,7 @@ _08115114: asrs r4, r0, 16 cmp r2, r0 bge _08115140 - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r5, r0 @@ -44584,7 +44584,7 @@ _08115140: asrs r0, r1, 16 cmp r0, 0x9F bgt _0811516E - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers lsls r0, r3, 16 asrs r0, 16 adds r3, r0, 0 @@ -44616,7 +44616,7 @@ _0811516E: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams add sp, 0xC pop {r4-r6} pop {r0} @@ -50740,9 +50740,9 @@ _08118442: strh r0, [r1, 0xC] _0811845A: movs r3, 0 - ldr r5, =gUnknown_02039B28 + ldr r5, =gScanlineEffect mov r9, r5 - ldr r7, =gUnknown_02038C28 + ldr r7, =gScanlineEffectRegBuffers mov r6, r9 adds r5, r1, 0 _08118466: @@ -50760,8 +50760,8 @@ _08118466: ble _08118466 cmp r3, 0x9F bgt _081184AA - ldr r7, =gUnknown_02038C28 - ldr r6, =gUnknown_02039B28 + ldr r7, =gScanlineEffectRegBuffers + ldr r6, =gScanlineEffect ldr r1, =gTasks mov r2, r12 adds r0, r2, r4 @@ -51089,9 +51089,9 @@ _0811873C: strh r0, [r1, 0xC] _08118752: movs r3, 0 - ldr r0, =gUnknown_02039B28 + ldr r0, =gScanlineEffect mov r8, r0 - ldr r2, =gUnknown_02038C28 + ldr r2, =gScanlineEffectRegBuffers mov r12, r2 mov r7, r8 adds r4, r1, 0 @@ -51110,9 +51110,9 @@ _08118760: ble _08118760 cmp r3, 0x9F bgt _081187A4 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers mov r12, r0 - ldr r7, =gUnknown_02039B28 + ldr r7, =gScanlineEffect ldr r1, =gTasks adds r0, r6, r5 lsls r0, 3 @@ -51378,9 +51378,9 @@ _081189BA: strh r0, [r1, 0xC] _081189D0: movs r3, 0 - ldr r6, =gUnknown_02039B28 + ldr r6, =gScanlineEffect mov r8, r6 - ldr r7, =gUnknown_02038C28 + ldr r7, =gScanlineEffectRegBuffers adds r4, r1, 0 _081189DA: lsls r2, r3, 1 @@ -51397,8 +51397,8 @@ _081189DA: ble _081189DA cmp r3, 0x9F bgt _08118A1E - ldr r7, =gUnknown_02038C28 - ldr r6, =gUnknown_02039B28 + ldr r7, =gScanlineEffectRegBuffers + ldr r6, =gScanlineEffect ldr r1, =gTasks mov r2, r12 adds r0, r2, r5 @@ -51707,9 +51707,9 @@ _08118C90: strh r0, [r1, 0xC] _08118CA6: movs r3, 0 - ldr r0, =gUnknown_02039B28 + ldr r0, =gScanlineEffect mov r12, r0 - ldr r2, =gUnknown_02038C28 + ldr r2, =gScanlineEffectRegBuffers mov r8, r2 mov r7, r12 adds r4, r1, 0 @@ -51728,9 +51728,9 @@ _08118CB4: ble _08118CB4 cmp r3, 0x9F bgt _08118CF8 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers mov r8, r0 - ldr r7, =gUnknown_02039B28 + ldr r7, =gScanlineEffect ldr r1, =gTasks adds r0, r5, r6 lsls r0, 3 @@ -52025,7 +52025,7 @@ _08118F28: lsls r1, 7 movs r0, 0xC bl SetGpuReg - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] ldr r1, =gTasks diff --git a/asm/battle_anim_815A0D4.s b/asm/battle_anim_815A0D4.s index d583f1e85..f3b72792d 100644 --- a/asm/battle_anim_815A0D4.s +++ b/asm/battle_anim_815A0D4.s @@ -1689,7 +1689,7 @@ _0815AE58: ldrsh r0, [r5, r6] cmp r1, r0 bgt _0815AE8E - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r0, r4 @@ -1729,7 +1729,7 @@ _0815AEA2: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams ldr r0, =sub_815AED8 str r0, [r5] add sp, 0xC @@ -1820,7 +1820,7 @@ _0815AF5C: ldrsh r0, [r4, r2] cmp r1, r0 bge _0815AF90 - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r5, r0 @@ -1848,7 +1848,7 @@ _0815AF90: ldrsh r0, [r4, r2] cmp r1, r0 bgt _0815AFC4 - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r6, r5, r0 @@ -1877,7 +1877,7 @@ _0815AFC4: ldrsh r0, [r4, r1] cmp r0, 0 beq _0815AFDA - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] _0815AFDA: @@ -6151,7 +6151,7 @@ _0815D316: ldrh r3, [r0] movs r7, 0 movs r2, 0 - ldr r6, =gUnknown_02038C28 + ldr r6, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r0, r6 @@ -6192,7 +6192,7 @@ _0815D326: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams ldr r0, =sub_815D398 str r0, [r4] add sp, 0xC @@ -6304,7 +6304,7 @@ _0815D40E: ldrsh r0, [r6, r3] cmp r1, r0 ble _0815D52E - ldr r0, =gUnknown_02039B28 + ldr r0, =gScanlineEffect mov r10, r0 ldr r1, [sp, 0x4] lsls r0, r1, 16 @@ -6325,7 +6325,7 @@ _0815D47E: subs r0, r1 lsls r0, 7 adds r2, r0 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers adds r2, r0 lsls r4, 16 asrs r4, 16 @@ -6343,7 +6343,7 @@ _0815D47E: subs r0, r1 lsls r0, 7 adds r3, r0 - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers adds r3, r1 lsls r1, r7, 16 asrs r1, 16 @@ -6407,7 +6407,7 @@ _0815D52E: lsls r1, r2, 17 cmp r1, 0 blt _0815D55A - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers ldr r7, [sp, 0x4] lsls r0, r7, 16 asrs r0, 16 @@ -6487,7 +6487,7 @@ _0815D5CC: asrs r0, 16 cmp r0, 0xC ble _0815D63C - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] movs r0, 0 diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 91c8215e5..31d5d3fbe 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -11000,8 +11000,8 @@ _0819486C: movs r1, 0 strh r1, [r0, 0x8] _08194878: - bl dp12_8087EA4 - ldr r0, =gUnknown_02038C28 + bl ScanlineEffect_Clear + ldr r0, =gScanlineEffectRegBuffers ldr r2, =0x00001f0a movs r4, 0xF0 lsls r4, 3 @@ -11017,7 +11017,7 @@ _08194888: bge _08194888 movs r5, 0x5B ldr r3, =gUnknown_0860CF44 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers ldr r2, =0x00001f09 ldr r4, =0x00000836 adds r1, r0, r4 @@ -11033,7 +11033,7 @@ _081948A4: ldr r0, [r3] ldr r1, [r3, 0x4] ldr r2, [r3, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams mov r0, r8 bl DestroyTask _081948C2: @@ -11513,7 +11513,7 @@ sub_8194CE4: @ 8194CE4 bl LoadOam bl ProcessSpriteCopyRequests bl TransferPlttBuffer - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer pop {r0} bx r0 .pool diff --git a/asm/contest.s b/asm/contest.s index 3c34965ad..e81ce8d5c 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -563,7 +563,7 @@ _080D7B4E: bl sub_80D779C bl sub_80D77E4 bl sub_80D7678 - bl dp12_8087EA4 + bl ScanlineEffect_Clear bl ResetPaletteFade ldr r2, =gPaletteFade ldrb r0, [r2, 0x8] @@ -1367,7 +1367,7 @@ vblank_cb_battle: @ 80D827C bl TransferPlttBuffer bl LoadOam bl ProcessSpriteCopyRequests - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer pop {r0} bx r0 .pool diff --git a/asm/contest_link_80F57C4.s b/asm/contest_link_80F57C4.s index 55503fde1..e73c657a9 100644 --- a/asm/contest_link_80F57C4.s +++ b/asm/contest_link_80F57C4.s @@ -344,7 +344,7 @@ sub_80F5B00: @ 80F5B00 bl SetVBlankCallback bl sub_80F7DF4 bl sub_80F57C4 - bl dp12_8087EA4 + bl ScanlineEffect_Clear bl ResetPaletteFade bl ResetSpriteData bl ResetTasks @@ -492,7 +492,7 @@ sub_80F5C24: @ 80F5C24 bl LoadOam bl ProcessSpriteCopyRequests bl TransferPlttBuffer - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer pop {r0} bx r0 .pool diff --git a/asm/field_screen.s b/asm/field_screen.s index 6b49b9c7c..c02ba6492 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -9572,12 +9572,12 @@ _080AFE30: beq _080AFEBC b _080AFEC6 _080AFE36: - ldr r0, =gUnknown_02039B28 + ldr r0, =gScanlineEffect ldrb r1, [r0, 0x14] lsls r0, r1, 4 subs r0, r1 lsls r0, 7 - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers adds r0, r1 movs r2, 0x2 ldrsh r1, [r4, r2] @@ -9591,12 +9591,12 @@ _080AFE36: b _080AFEC6 .pool _080AFE64: - ldr r0, =gUnknown_02039B28 + ldr r0, =gScanlineEffect ldrb r1, [r0, 0x14] lsls r0, r1, 4 subs r0, r1 lsls r0, 7 - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers adds r0, r1 movs r6, 0x2 ldrsh r1, [r4, r6] @@ -9631,7 +9631,7 @@ _080AFEB4: bl DestroyTask b _080AFEC6 _080AFEBC: - bl dp12_8087EA4 + bl ScanlineEffect_Clear adds r0, r5, 0 bl DestroyTask _080AFEC6: @@ -9665,12 +9665,12 @@ _080AFEF4: beq _080AFF80 b _080AFF8A _080AFEFA: - ldr r0, =gUnknown_02039B28 + ldr r0, =gScanlineEffect ldrb r1, [r0, 0x14] lsls r0, r1, 4 subs r0, r1 lsls r0, 7 - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers adds r0, r1 movs r2, 0x2 ldrsh r1, [r4, r2] @@ -9684,12 +9684,12 @@ _080AFEFA: b _080AFF8A .pool _080AFF28: - ldr r0, =gUnknown_02039B28 + ldr r0, =gScanlineEffect ldrb r1, [r0, 0x14] lsls r0, r1, 4 subs r0, r1 lsls r0, 7 - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers adds r0, r1 movs r6, 0x2 ldrsh r1, [r4, r6] @@ -9724,7 +9724,7 @@ _080AFF78: bl DestroyTask b _080AFF8A _080AFF80: - bl dp12_8087EA4 + bl ScanlineEffect_Clear adds r0, r5, 0 bl DestroyTask _080AFF8A: @@ -9914,7 +9914,7 @@ sub_80B00E8: @ 80B00E8 lsrs r0, 24 cmp r0, 0 beq _080B0116 - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers ldr r1, =gUnknown_0854FE64 lsls r0, 1 adds r0, r1 @@ -9940,7 +9940,7 @@ _080B0116: thumb_func_start door_upload_tiles door_upload_tiles: @ 80B0124 push {r4,lr} - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers ldr r0, =gSaveBlock2Ptr ldr r0, [r0] ldr r1, =0x00000e68 @@ -10261,7 +10261,7 @@ _080B0368: bl sub_8199C30 movs r0, 0 bl schedule_bg_copy_tilemap_to_vram - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers movs r2, 0x4 ldrsh r1, [r5, r2] movs r0, 0x6 @@ -10280,7 +10280,7 @@ _080B0368: ldr r0, [r2] ldr r1, [r2, 0x4] ldr r2, [r2, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams movs r0, 0x1 strh r0, [r5] b _080B052C diff --git a/asm/intro.s b/asm/intro.s index efc36e7d9..3e95c6ec7 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -11,7 +11,7 @@ sub_816CBE8: @ 816CBE8 bl LoadOam bl ProcessSpriteCopyRequests bl TransferPlttBuffer - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer pop {r0} bx r0 thumb_func_end sub_816CBE8 @@ -2124,7 +2124,7 @@ task_intro_17: @ 816DEEC movs r1, 0xA0 movs r2, 0x4 movs r3, 0x4 - bl sub_80BA384 + bl ScanlineEffect_InitWave add sp, 0xC pop {r0} bx r0 @@ -2411,7 +2411,7 @@ _0816E156: adds r0, r1 ldr r1, =task_intro_19 str r1, [r0] - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] _0816E176: @@ -2623,7 +2623,7 @@ task_intro_19: @ 816E2A0 movs r1, 0xA0 movs r2, 0x4 movs r3, 0x4 - bl sub_80BA384 + bl ScanlineEffect_InitWave add sp, 0xC pop {r4} pop {r0} @@ -3038,7 +3038,7 @@ _0816E69C: adds r0, r1 ldr r1, =task_intro_21 str r1, [r0] - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] _0816E6BC: diff --git a/asm/link.s b/asm/link.s index 1ad160340..e05d33974 100644 --- a/asm/link.s +++ b/asm/link.s @@ -39837,7 +39837,7 @@ sub_801DF20: @ 801DF20 bl TransferPlttBuffer bl LoadOam bl ProcessSpriteCopyRequests - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer pop {r0} bx r0 thumb_func_end sub_801DF20 @@ -42568,7 +42568,7 @@ sub_801F544: @ 801F544 str r0, [r4] _0801F55A: bl FreeAllWindowBuffers - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] pop {r4} @@ -44875,13 +44875,13 @@ sub_8020770: @ 8020770 strh r1, [r0, 0x20] str r1, [sp, 0xC] add r0, sp, 0xC - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers ldr r2, =0x010003c0 bl CpuFastSet ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams add sp, 0x10 pop {r0} bx r0 @@ -44896,12 +44896,12 @@ sub_80207C0: @ 80207C0 lsrs r0, 16 mov r1, sp strh r0, [r1] - ldr r5, =gUnknown_02039B28 + ldr r5, =gScanlineEffect ldrb r0, [r5, 0x14] lsls r1, r0, 4 subs r1, r0 lsls r1, 7 - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers adds r1, r4 ldr r2, =0x01000090 mov r0, sp @@ -44939,7 +44939,7 @@ sub_8020818: @ 8020818 lsrs r4, 16 mov r0, sp strh r4, [r0] - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers ldr r0, =0x01000090 mov r9, r0 mov r0, sp diff --git a/asm/overworld.s b/asm/overworld.s index 2858fb6d3..d2d389eac 100644 --- a/asm/overworld.s +++ b/asm/overworld.s @@ -3637,7 +3637,7 @@ VBlankCB_Field: @ 8086390 push {lr} bl LoadOam bl ProcessSpriteCopyRequests - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer bl FieldUpdateBgTilemapScroll bl TransferPlttBuffer bl TransferTilesetAnimsBuffer @@ -3657,7 +3657,7 @@ sub_80863B0: @ 80863B0 ldr r0, [r2] ldr r1, [r2, 0x4] ldr r2, [r2, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams b _080863F0 .pool _080863D4: @@ -3671,7 +3671,7 @@ _080863D4: ldr r0, [r2] ldr r1, [r2, 0x4] ldr r2, [r2, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams _080863F0: pop {r0} bx r0 @@ -4294,7 +4294,7 @@ sub_8086988: @ 8086988 bl ResetTasks bl ResetSpriteData bl ResetPaletteFade - bl dp12_8087EA4 + bl ScanlineEffect_Clear bl dp13_810BB8C bl ResetCameraUpdateInfo bl InstallCameraPanAheadCallback diff --git a/asm/pokenav.s b/asm/pokenav.s index 896d9aae0..79cfeb75d 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -7068,7 +7068,7 @@ sub_81CA914: @ 81CA914 bl TransferPlttBuffer bl LoadOam bl ProcessSpriteCopyRequests - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer pop {r0} bx r0 thumb_func_end sub_81CA914 @@ -7101,7 +7101,7 @@ titlescreen_0: @ 81CA92C ldr r0, [r2] ldr r1, [r2, 0x4] ldr r2, [r2, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams ldr r0, =sub_81CA914 bl c3args_set_0toR1_1to0 ldr r0, =sub_81CA9EC @@ -7220,7 +7220,7 @@ sub_81CAA3C: @ 81CAA3C mov r0, sp movs r6, 0 strh r6, [r0] - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers ldr r0, =0x010000a0 mov r8, r0 mov r0, sp @@ -15647,7 +15647,7 @@ sub_81CEE44: @ 81CEE44 bl TransferPlttBuffer adds r0, r4, 0 bl sub_81D2108 - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer pop {r4} pop {r0} bx r0 @@ -22318,7 +22318,7 @@ sub_81D20BC: @ 81D20BC b _081D20FA .pool _081D20D4: - bl dp12_8087EA4 + bl ScanlineEffect_Clear ldrb r0, [r4] adds r0, 0x1 strb r0, [r4] @@ -22332,7 +22332,7 @@ _081D20E2: ldr r0, [sp] ldr r1, [sp, 0x4] ldr r2, [sp, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams ldrb r0, [r4] adds r0, 0x1 strb r0, [r4] @@ -22366,7 +22366,7 @@ sub_81D2108: @ 81D2108 adds r0, r6, 0 bl sub_81D2634 movs r7, 0 - ldr r5, =gUnknown_02038C28 + ldr r5, =gScanlineEffectRegBuffers mov r12, r5 movs r0, 0xF0 lsls r0, 3 diff --git a/asm/rayquaza_scene.s b/asm/rayquaza_scene.s index f60b2a252..8832d3942 100644 --- a/asm/rayquaza_scene.s +++ b/asm/rayquaza_scene.s @@ -1058,7 +1058,7 @@ _081D6FC8: sub_81D6FD0: @ 81D6FD0 push {lr} bl sub_81D67EC - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer pop {r0} bx r0 thumb_func_end sub_81D6FD0 @@ -1183,12 +1183,12 @@ sub_81D7134: @ 81D7134 lsls r6, r1, 3 ldr r7, =gTasks + 0x8 adds r5, r6, r7 - bl dp12_8087EA4 + bl ScanlineEffect_Clear bl sub_81D6FE0 bl sub_81D706C movs r4, 0 str r4, [sp, 0x4] - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers ldr r2, =0x010003c0 add r0, sp, 0x4 bl CpuFastSet @@ -1196,7 +1196,7 @@ sub_81D7134: @ 81D7134 ldr r0, [r2] ldr r1, [r2, 0x4] ldr r2, [r2, 0x8] - bl sub_80BA038 + bl ScanlineEffect_SetParams strh r4, [r5] ldr r0, =sub_81D7228 movs r1, 0 @@ -1278,7 +1278,7 @@ sub_81D7228: @ 81D7228 adds r3, r1, r0 movs r1, 0x18 ldr r7, =gUnknown_0203CF60 - ldr r4, =gUnknown_02038C28 + ldr r4, =gScanlineEffectRegBuffers movs r0, 0xF0 lsls r0, 3 adds r5, r4, r0 diff --git a/asm/reset_rtc_screen.s b/asm/reset_rtc_screen.s index ab5e0840c..b314afbf5 100644 --- a/asm/reset_rtc_screen.s +++ b/asm/reset_rtc_screen.s @@ -888,7 +888,7 @@ _0809EFCA: bl ResetOamRange bl LoadOam bl ScanlineEffect_Stop - bl dp12_8087EA4 + bl ScanlineEffect_Clear bl ResetSpriteData bl ResetTasks bl ResetPaletteFade diff --git a/asm/start_menu.s b/asm/start_menu.s index 518b46f76..e4e75b4d2 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -1561,7 +1561,7 @@ _080A0490: bl ResetSpriteData bl ResetTasks bl ResetPaletteFade - bl dp12_8087EA4 + bl ScanlineEffect_Clear b _080A04FC _080A04A2: movs r0, 0 diff --git a/asm/title_screen.s b/asm/title_screen.s index 54c1b5353..32594424a 100644 --- a/asm/title_screen.s +++ b/asm/title_screen.s @@ -464,7 +464,7 @@ _080AA766: @ void title_screen_vblank_callback() title_screen_vblank_callback: @ 80AA780 push {lr} - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer bl LoadOam bl ProcessSpriteCopyRequests bl TransferPlttBuffer @@ -779,7 +779,7 @@ _080AAAF0: movs r1, 0xA0 movs r2, 0x4 movs r3, 0x4 - bl sub_80BA384 + bl ScanlineEffect_InitWave ldr r0, =c2_title_screen_2 bl SetMainCallback2 _080AAB1E: diff --git a/asm/trainer_card.s b/asm/trainer_card.s index f1679d04e..fe6133618 100644 --- a/asm/trainer_card.s +++ b/asm/trainer_card.s @@ -18,7 +18,7 @@ sub_80C2690: @ 80C2690 cmp r0, 0 beq _080C26C0 ldr r1, =0x040000d4 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers str r0, [r1] movs r2, 0xF0 lsls r2, 3 @@ -40,7 +40,7 @@ sub_80C26D4: @ 80C26D4 ldrh r3, [r4] movs r0, 0 strh r0, [r4] - ldr r1, =gUnknown_02038C28 + ldr r1, =gScanlineEffectRegBuffers ldr r0, =0x04000006 ldrh r2, [r0] movs r0, 0xFF @@ -3977,9 +3977,9 @@ sub_80C4998: @ 80C4998 movs r0, 0x3 bl HideBg bl ScanlineEffect_Stop - bl dp12_8087EA4 + bl ScanlineEffect_Clear movs r1, 0 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers movs r2, 0 movs r3, 0xF0 lsls r3, 3 @@ -4066,7 +4066,7 @@ _080C4A0E: movs r2, 0 cmp r2, r7 bcs _080C4A78 - ldr r3, =gUnknown_02038C28 + ldr r3, =gScanlineEffectRegBuffers _080C4A60: lsls r0, r2, 16 asrs r0, 16 @@ -4091,7 +4091,7 @@ _080C4A78: lsrs r7, r4, 16 cmp r1, r0 bge _080C4AB0 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers mov r12, r0 adds r4, r3, 0 _080C4A92: @@ -4116,7 +4116,7 @@ _080C4AB0: asrs r0, r1, 16 cmp r0, 0x9F bgt _080C4ACE - ldr r2, =gUnknown_02038C28 + ldr r2, =gScanlineEffectRegBuffers _080C4ABC: asrs r0, r1, 16 lsls r1, r0, 1 @@ -4392,7 +4392,7 @@ _080C4CB6: movs r2, 0 cmp r2, r7 bcs _080C4D20 - ldr r3, =gUnknown_02038C28 + ldr r3, =gScanlineEffectRegBuffers _080C4D08: lsls r0, r2, 16 asrs r0, 16 @@ -4417,7 +4417,7 @@ _080C4D20: lsrs r7, r4, 16 cmp r1, r0 bge _080C4D56 - ldr r0, =gUnknown_02038C28 + ldr r0, =gScanlineEffectRegBuffers mov r12, r0 adds r4, r3, 0 _080C4D3A: @@ -4441,7 +4441,7 @@ _080C4D56: asrs r0, r1, 16 cmp r0, 0x9F bgt _080C4D74 - ldr r2, =gUnknown_02038C28 + ldr r2, =gScanlineEffectRegBuffers _080C4D62: asrs r0, r1, 16 lsls r1, r0, 1 diff --git a/asm/unknown_task.s b/asm/unknown_task.s deleted file mode 100644 index a8672ac8f..000000000 --- a/asm/unknown_task.s +++ /dev/null @@ -1,593 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start ScanlineEffect_Stop -ScanlineEffect_Stop: @ 80B9FB8 - push {r4,lr} - ldr r4, =gUnknown_02039B28 - movs r0, 0 - strb r0, [r4, 0x15] - ldr r1, =0x040000b0 - ldrh r2, [r1, 0xA] - ldr r0, =0x0000c5ff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r2, [r1, 0xA] - ldr r0, =0x00007fff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r0, [r1, 0xA] - ldrb r0, [r4, 0x18] - cmp r0, 0xFF - beq _080B9FE2 - bl DestroyTask - movs r0, 0xFF - strb r0, [r4, 0x18] -_080B9FE2: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ScanlineEffect_Stop - - thumb_func_start dp12_8087EA4 -dp12_8087EA4: @ 80B9FF8 - push {r4,lr} - sub sp, 0x4 - mov r0, sp - movs r4, 0 - strh r4, [r0] - ldr r1, =gUnknown_02038C28 - ldr r2, =0x01000780 - bl CpuSet - ldr r0, =gUnknown_02039B28 - movs r1, 0 - str r1, [r0] - str r1, [r0, 0x4] - str r1, [r0, 0x8] - str r1, [r0, 0xC] - strb r4, [r0, 0x14] - strb r4, [r0, 0x15] - strb r4, [r0, 0x16] - strb r4, [r0, 0x17] - movs r1, 0xFF - strb r1, [r0, 0x18] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end dp12_8087EA4 - - thumb_func_start sub_80BA038 -sub_80BA038: @ 80BA038 - push {lr} - sub sp, 0xC - str r0, [sp] - str r1, [sp, 0x4] - str r2, [sp, 0x8] - ldr r0, =0xa2600001 - cmp r1, r0 - bne _080BA06C - ldr r0, =gUnknown_02039B28 - ldr r1, =gUnknown_02038C2A - str r1, [r0] - movs r2, 0xF0 - lsls r2, 3 - adds r1, r2 - str r1, [r0, 0x4] - ldr r1, =sub_80BA134 - b _080BA07C - .pool -_080BA06C: - ldr r0, =gUnknown_02039B28 - ldr r1, =gUnknown_02038C2C - str r1, [r0] - movs r2, 0xF0 - lsls r2, 3 - adds r1, r2 - str r1, [r0, 0x4] - ldr r1, =sub_80BA154 -_080BA07C: - str r1, [r0, 0x10] - adds r1, r0, 0 - ldr r0, [sp, 0x4] - str r0, [r1, 0xC] - ldr r0, [sp] - str r0, [r1, 0x8] - mov r0, sp - ldrb r0, [r0, 0x8] - strb r0, [r1, 0x15] - mov r0, sp - ldrb r0, [r0, 0x9] - strb r0, [r1, 0x16] - strb r0, [r1, 0x17] - add sp, 0xC - pop {r0} - bx r0 - .pool - thumb_func_end sub_80BA038 - - thumb_func_start sub_80BA0A8 -sub_80BA0A8: @ 80BA0A8 - push {r4,lr} - ldr r4, =gUnknown_02039B28 - ldrb r0, [r4, 0x15] - cmp r0, 0 - beq _080BA122 - cmp r0, 0x3 - bne _080BA0EC - movs r0, 0 - strb r0, [r4, 0x15] - ldr r1, =0x040000b0 - ldrh r2, [r1, 0xA] - ldr r0, =0x0000c5ff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r2, [r1, 0xA] - ldr r0, =0x00007fff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r0, [r1, 0xA] - ldr r1, =gUnknown_02039B44 - movs r0, 0x1 - strb r0, [r1] - b _080BA122 - .pool -_080BA0EC: - ldr r1, =0x040000b0 - ldrh r2, [r1, 0xA] - ldr r0, =0x0000c5ff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r2, [r1, 0xA] - ldr r0, =0x00007fff - ands r0, r2 - strh r0, [r1, 0xA] - ldrh r0, [r1, 0xA] - ldrb r0, [r4, 0x14] - lsls r0, 2 - adds r0, r4 - ldr r0, [r0] - str r0, [r1] - ldr r0, [r4, 0x8] - str r0, [r1, 0x4] - ldr r0, [r4, 0xC] - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - ldr r0, [r4, 0x10] - bl _call_via_r0 - ldrb r0, [r4, 0x14] - movs r1, 0x1 - eors r0, r1 - strb r0, [r4, 0x14] -_080BA122: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80BA0A8 - - thumb_func_start sub_80BA134 -sub_80BA134: @ 80BA134 - ldr r0, =gUnknown_02039B28 - ldr r2, [r0, 0x8] - ldrb r1, [r0, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - ldr r1, =gUnknown_02038C28 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r2] - bx lr - .pool - thumb_func_end sub_80BA134 - - thumb_func_start sub_80BA154 -sub_80BA154: @ 80BA154 - ldr r0, =gUnknown_02039B28 - ldr r2, [r0, 0x8] - ldrb r1, [r0, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - ldr r1, =gUnknown_02038C28 - adds r0, r1 - ldr r0, [r0] - str r0, [r2] - bx lr - .pool - thumb_func_end sub_80BA154 - - thumb_func_start task00_for_dp12 -task00_for_dp12: @ 80BA174 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r12, r0 - movs r6, 0 - ldr r0, =gUnknown_02039B44 - ldrb r0, [r0] - cmp r0, 0 - beq _080BA1A4 - mov r0, r12 - bl DestroyTask - ldr r1, =gUnknown_02039B28 - movs r0, 0xFF - strb r0, [r1, 0x18] - b _080BA324 - .pool -_080BA1A4: - ldr r1, =gTasks - mov r0, r12 - lsls r2, r0, 2 - adds r0, r2, r0 - lsls r0, 3 - adds r3, r0, r1 - movs r4, 0x16 - ldrsh r0, [r3, r4] - mov r10, r1 - mov r9, r2 - cmp r0, 0 - beq _080BA250 - movs r1, 0x14 - ldrsh r0, [r3, r1] - cmp r0, 0xE - bhi _080BA250 - lsls r0, 2 - ldr r1, =_080BA1D8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080BA1D8: - .4byte _080BA214 - .4byte _080BA250 - .4byte _080BA21C - .4byte _080BA250 - .4byte _080BA224 - .4byte _080BA250 - .4byte _080BA22C - .4byte _080BA250 - .4byte _080BA234 - .4byte _080BA250 - .4byte _080BA23C - .4byte _080BA250 - .4byte _080BA244 - .4byte _080BA250 - .4byte _080BA24C -_080BA214: - ldr r0, =gBattle_BG0_X - b _080BA24E - .pool -_080BA21C: - ldr r0, =gBattle_BG0_Y - b _080BA24E - .pool -_080BA224: - ldr r0, =gBattle_BG1_X - b _080BA24E - .pool -_080BA22C: - ldr r0, =gBattle_BG1_Y - b _080BA24E - .pool -_080BA234: - ldr r0, =gBattle_BG2_X - b _080BA24E - .pool -_080BA23C: - ldr r0, =gBattle_BG2_Y - b _080BA24E - .pool -_080BA244: - ldr r0, =gBattle_BG3_X - b _080BA24E - .pool -_080BA24C: - ldr r0, =gBattle_BG3_Y -_080BA24E: - ldrh r6, [r0] -_080BA250: - mov r0, r9 - add r0, r12 - lsls r0, 3 - mov r2, r10 - adds r1, r0, r2 - ldrh r2, [r1, 0x10] - movs r3, 0x10 - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _080BA2BC - subs r0, r2, 0x1 - strh r0, [r1, 0x10] - movs r4, 0xE - ldrsh r0, [r1, r4] - movs r3, 0xA0 - lsls r3, 1 - adds r2, r0, r3 - movs r4, 0x8 - ldrsh r3, [r1, r4] - movs r4, 0xA - ldrsh r0, [r1, r4] - cmp r3, r0 - bge _080BA324 - ldr r5, =gUnknown_02038C28 - ldr r0, =gUnknown_02039B28 - mov r8, r0 - adds r7, r1, 0 - lsls r0, r2, 1 - adds r4, r0, r5 -_080BA28A: - lsls r2, r3, 1 - mov r0, r8 - ldrb r1, [r0, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r5 - ldrh r0, [r4] - adds r0, r6 - strh r0, [r2] - adds r4, 0x2 - adds r3, 0x1 - movs r1, 0xA - ldrsh r0, [r7, r1] - cmp r3, r0 - blt _080BA28A - b _080BA324 - .pool -_080BA2BC: - ldrh r0, [r1, 0x12] - strh r0, [r1, 0x10] - movs r2, 0xE - ldrsh r0, [r1, r2] - movs r3, 0xA0 - lsls r3, 1 - adds r2, r0, r3 - movs r4, 0x8 - ldrsh r3, [r1, r4] - movs r4, 0xA - ldrsh r0, [r1, r4] - cmp r3, r0 - bge _080BA304 - ldr r5, =gUnknown_02038C28 - adds r7, r1, 0 - lsls r0, r2, 1 - adds r4, r0, r5 - ldr r0, =gUnknown_02039B28 - mov r8, r0 -_080BA2E2: - lsls r2, r3, 1 - mov r0, r8 - ldrb r1, [r0, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r5 - ldrh r0, [r4] - adds r0, r6 - strh r0, [r2] - adds r4, 0x2 - adds r3, 0x1 - movs r1, 0xA - ldrsh r0, [r7, r1] - cmp r3, r0 - blt _080BA2E2 -_080BA304: - mov r0, r9 - add r0, r12 - lsls r0, 3 - mov r3, r10 - adds r2, r0, r3 - ldrh r0, [r2, 0xE] - adds r0, 0x1 - strh r0, [r2, 0xE] - lsls r0, 16 - asrs r0, 16 - movs r4, 0xC - ldrsh r1, [r2, r4] - cmp r0, r1 - bne _080BA324 - movs r0, 0 - strh r0, [r2, 0xE] -_080BA324: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task00_for_dp12 - - thumb_func_start sub_80BA33C -sub_80BA33C: @ 80BA33C - push {r4-r7,lr} - adds r6, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - lsls r2, 24 - lsrs r4, r2, 24 - movs r1, 0 - movs r2, 0 - ldr r0, =gSineTable - mov r12, r0 -_080BA350: - lsls r0, r1, 1 - adds r3, r0, r6 - lsls r0, r2, 1 - add r0, r12 - movs r7, 0 - ldrsh r0, [r0, r7] - muls r0, r4 - cmp r0, 0 - bge _080BA364 - adds r0, 0xFF -_080BA364: - asrs r0, 8 - strh r0, [r3] - adds r0, r2, r5 - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0xFF - bls _080BA350 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80BA33C - - thumb_func_start sub_80BA384 -sub_80BA384: @ 80BA384 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - adds r5, r0, 0 - str r1, [sp, 0x10] - ldr r0, [sp, 0x40] - mov r8, r0 - ldr r1, [sp, 0x44] - mov r9, r1 - ldr r0, [sp, 0x48] - mov r10, r0 - lsls r5, 24 - lsrs r5, 24 - ldr r1, [sp, 0x10] - lsls r1, 24 - str r1, [sp, 0x14] - lsrs r0, r1, 24 - str r0, [sp, 0xC] - lsls r1, r2, 24 - lsrs r1, 24 - str r1, [sp, 0x18] - lsls r2, r3, 24 - lsrs r2, 24 - str r2, [sp, 0x1C] - mov r1, r8 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - mov r3, r9 - lsls r3, 24 - lsrs r3, 24 - mov r9, r3 - mov r0, r10 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - bl dp12_8087EA4 - ldr r0, =0x04000010 - add r0, r9 - str r0, [sp] - ldr r0, =0xa2600001 - str r0, [sp, 0x4] - mov r1, sp - movs r0, 0x1 - strb r0, [r1, 0x8] - mov r0, sp - movs r1, 0 - strb r1, [r0, 0x9] - ldr r0, [sp] - ldr r1, [sp, 0x4] - ldr r2, [sp, 0x8] - bl sub_80BA038 - ldr r0, =task00_for_dp12 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, =gTasks - lsls r4, r7, 2 - adds r4, r7 - lsls r4, 3 - adds r4, r0 - strh r5, [r4, 0x8] - mov r3, sp - ldrh r3, [r3, 0xC] - strh r3, [r4, 0xA] - movs r0, 0x80 - lsls r0, 1 - ldr r1, [sp, 0x18] - bl __divsi3 - strh r0, [r4, 0xC] - movs r0, 0 - strh r0, [r4, 0xE] - mov r1, r8 - strh r1, [r4, 0x10] - strh r1, [r4, 0x12] - mov r3, r9 - strh r3, [r4, 0x14] - mov r0, r10 - strh r0, [r4, 0x16] - ldr r0, =gUnknown_02039B28 - strb r7, [r0, 0x18] - ldr r0, =gUnknown_02039B44 - movs r1, 0 - strb r1, [r0] - ldr r4, =gUnknown_02038EA8 - ldr r3, [sp, 0xC] - subs r6, r3, r5 - lsls r3, r6, 24 - lsrs r3, 24 - adds r0, r4, 0 - ldr r1, [sp, 0x18] - ldr r2, [sp, 0x1C] - bl sub_80BA33C - ldr r0, [sp, 0xC] - cmp r5, r0 - bge _080BA47E - ldr r1, =0xfffffd80 - adds r2, r4, r1 - lsls r1, r5, 1 - movs r3, 0xF0 - lsls r3, 3 - adds r0, r1, r3 - adds r3, r0, r2 - adds r1, r2 - adds r2, r4, 0 - adds r5, r6, 0 -_080BA46A: - ldrh r0, [r2] - strh r0, [r1] - ldrh r0, [r2] - strh r0, [r3] - adds r2, 0x2 - adds r3, 0x2 - adds r1, 0x2 - subs r5, 0x1 - cmp r5, 0 - bne _080BA46A -_080BA47E: - adds r0, r7, 0 - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80BA384 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/use_pokeblock.s b/asm/use_pokeblock.s index 60c11524a..5047ec65e 100644 --- a/asm/use_pokeblock.s +++ b/asm/use_pokeblock.s @@ -732,10 +732,10 @@ _08166C28: b _08166D18 .pool _08166C40: - ldr r1, =gUnknown_02039B28 + ldr r1, =gScanlineEffect movs r0, 0x3 strb r0, [r1, 0x15] - bl sub_80BA0A8 + bl ScanlineEffect_InitHBlankDmaTransfer _08166C4A: ldr r1, [r4] adds r1, 0x50 diff --git a/include/scanline_effect.h b/include/scanline_effect.h new file mode 100644 index 000000000..54dfe17bd --- /dev/null +++ b/include/scanline_effect.h @@ -0,0 +1,47 @@ +#ifndef GUARD_SCANLINE_EFFECT_H +#define GUARD_SCANLINE_EFFECT_H + +// DMA control value to ransfer a single 16-bit value at HBlank +#define SCANLINE_EFFECT_DMACNT_16BIT (((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_SRC_INC | DMA_DEST_INC | DMA_16BIT | DMA_DEST_RELOAD) << 16) | 1) + +#define SCANLINE_EFFECT_REG_BG0HOFS (REG_ADDR_BG0HOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG0VOFS (REG_ADDR_BG0VOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG1HOFS (REG_ADDR_BG1HOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG1VOFS (REG_ADDR_BG1VOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG2HOFS (REG_ADDR_BG2HOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG2VOFS (REG_ADDR_BG2VOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG3HOFS (REG_ADDR_BG3HOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG3VOFS (REG_ADDR_BG3VOFS - REG_ADDR_BG0HOFS) + +struct ScanlineEffectParams +{ + volatile void *dmaDest; + u32 dmaControl; + u8 initState; + u8 unused9; +}; + +struct ScanlineEffect +{ + void *dmaSrcBuffers[2]; + volatile void *dmaDest; + u32 dmaControl; + void (*setFirstScanlineReg)(void); + u8 srcBuffer; + u8 state; + u8 unused16; + u8 unused17; + u8 waveTaskId; +}; + +extern struct ScanlineEffect gScanlineEffect; + +extern u16 gScanlineEffectRegBuffers[][0x3C0]; + +void ScanlineEffect_Stop(void); +void ScanlineEffect_Clear(void); +void ScanlineEffect_SetParams(struct ScanlineEffectParams); +void ScanlineEffect_InitHBlankDmaTransfer(void); +u8 ScanlineEffect_InitWave(u8 startLine, u8 endLine, u8 frequency, u8 amplitude, u8 delayInterval, u8 regOffset, bool8 a7); + +#endif // GUARD_SCANLINE_EFFECT_H diff --git a/include/unknown_task.h b/include/unknown_task.h deleted file mode 100644 index 906fed3e0..000000000 --- a/include/unknown_task.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef GUARD_unknown_task_H -#define GUARD_unknown_task_H - -// Exported type declarations -struct UnknownTaskStruct -{ - volatile void *dest; - u32 control; - u8 unk8; - u8 unk9; -}; - -extern struct UnknownTaskStruct gUnknown_0831AC70; - -// Exported RAM declarations - -// Exported ROM declarations -void ScanlineEffect_Stop(void); -void sub_80BA038(struct UnknownTaskStruct arg0); -void sub_80BA0A8(void); - -#endif // GUARD_unknown_task_H diff --git a/ld_script.txt b/ld_script.txt index f2a9d8196..bc2504fb0 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -126,7 +126,7 @@ SECTIONS { src/trainer_see.o(.text); src/wild_encounter.o(.text); asm/field_effect.o(.text); - asm/unknown_task.o(.text); + src/scanline_effect.o(.text); src/option_menu.o(.text); src/pokedex.o(.text); asm/pokedex.o(.text); diff --git a/src/battle_2.c b/src/battle_2.c index 61e39b39f..4ff2bd19a 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -4,7 +4,7 @@ #include "main.h" #include "load_save.h" #include "gpu_regs.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "battle_setup.h" #include "battle_scripts.h" #include "pokemon.h" @@ -46,13 +46,6 @@ #include "battle_string_ids.h" #include "data2.h" -struct UnknownStruct6 -{ - u16 unk0[0xA0]; - u8 fillerA0[0x640]; - u16 unk780[0xA0]; -}; - struct UnknownPokemonStruct2 { /*0x00*/ u16 species; @@ -90,8 +83,6 @@ extern void (*gBattleMainFunc)(void); extern void (*gCB2_AfterEvolution)(void); extern struct UnknownPokemonStruct2 gUnknown_02022FF8[3]; // what is it used for? extern struct UnknownPokemonStruct2* gUnknown_02023058; // what is it used for? -extern u8 gUnknown_02039B28[]; // possibly a struct? -extern struct UnknownStruct6 gUnknown_02038C28; // todo: identify & document extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; extern u8 gDecompressionBuffer[]; @@ -162,6 +153,7 @@ extern const u8 * const gBattlescriptsForBallThrow[]; extern const u8 * const gBattlescriptsForRunningByItem[]; extern const u8 * const gBattlescriptsForUsingItem[]; extern const u8 * const gBattlescriptsForSafariActions[]; +extern const struct ScanlineEffectParams gUnknown_0831AC70; // strings extern const u8 gText_LinkStandby3[]; @@ -180,7 +172,7 @@ extern const u8 gText_Confusion[]; extern const u8 gText_Love[]; // functions -extern void dp12_8087EA4(void); +extern void ScanlineEffect_Clear(void); extern void sub_80356D0(void); extern void GetFrontierTrainerName(u8* dst, u16 trainerId); // battle tower extern void sub_8166188(void); // battle tower, sets link battle mons level but why? @@ -383,24 +375,21 @@ static void CB2_InitBattleInternal(void) else { gBattle_WIN0V = 0x5051; - dp12_8087EA4(); + ScanlineEffect_Clear(); for (i = 0; i < 80; i++) { - gUnknown_02038C28.unk0[i] = 0xF0; - gUnknown_02038C28.unk780[i] = 0xF0; + gScanlineEffectRegBuffers[0][i] = 0xF0; + gScanlineEffectRegBuffers[1][i] = 0xF0; } for (i = 80; i < 160; i++) { - #ifndef NONMATCHING - asm(""::"r"(i)); // needed to match - #endif // NONMATCHING - - gUnknown_02038C28.unk0[i] = 0xFF10; - gUnknown_02038C28.unk780[i] = 0xFF10; + asm(""::"r"(i)); + gScanlineEffectRegBuffers[0][i] = 0xFF10; + gScanlineEffectRegBuffers[1][i] = 0xFF10; } - sub_80BA038(gUnknown_0831AC70); + ScanlineEffect_SetParams(gUnknown_0831AC70); } ResetPaletteFade(); @@ -1596,7 +1585,7 @@ void BattleMainCB2(void) static void FreeRestoreBattleData(void) { gMain.callback1 = gPreBattleCallback1; - gUnknown_02039B28[0x15] = 3; + gScanlineEffect.state = 3; gMain.inBattle = 0; ZeroEnemyPartyMons(); m4aSongNumStop(0x5A); @@ -1814,7 +1803,7 @@ void VBlankCB_Battle(void) LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_80BA0A8(); + ScanlineEffect_InitHBlankDmaTransfer(); } void nullsub_17(void) @@ -1952,18 +1941,18 @@ void sub_8038D64(void) SetGpuReg(REG_OFFSET_WINOUT, 0); gBattle_WIN0H = 0xF0; gBattle_WIN0V = 0x5051; - dp12_8087EA4(); + ScanlineEffect_Clear(); for (i = 0; i < 80; i++) { - gUnknown_02038C28.unk0[i] = 0xF0; - gUnknown_02038C28.unk780[i] = 0xF0; + gScanlineEffectRegBuffers[0][i] = 0xF0; + gScanlineEffectRegBuffers[1][i] = 0xF0; } for (i = 80; i < 160; i++) { asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter - gUnknown_02038C28.unk0[i] = 0xFF10; - gUnknown_02038C28.unk780[i] = 0xFF10; + gScanlineEffectRegBuffers[0][i] = 0xFF10; + gScanlineEffectRegBuffers[1][i] = 0xFF10; } ResetPaletteFade(); diff --git a/src/battle_transition.c b/src/battle_transition.c index e003e0fce..0ff8cd903 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -14,7 +14,7 @@ #include "constants/songs.h" #include "constants/trainers.h" #include "field_camera.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "malloc.h" #include "gpu_regs.h" #include "decompress.h" @@ -56,8 +56,6 @@ struct StructRectangularSpiral typedef bool8 (*TransitionStateFunc)(struct Task *task); typedef bool8 (*TransitionSpriteCallback)(struct Sprite *sprite); -extern u16 gUnknown_020393A8[]; -extern u16 gUnknown_02038C28[][0x3C0]; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; @@ -65,7 +63,7 @@ extern const struct OamData gFieldObjectBaseOam_32x32; extern void c2_exit_to_overworld_2_switch(void); extern void sub_80AC3D0(void); -extern void dp12_8087EA4(void); +extern void ScanlineEffect_Clear(void); // this file's functions static void LaunchBattleTransitionTask(u8 transitionId); @@ -1110,9 +1108,9 @@ static void Phase2Task_Swirl(u8 taskId) static bool8 Phase2_Swirl_Func1(struct Task *task) { sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); BeginNormalPaletteFade(-1, 4, 0, 0x10, 0); - sub_8149F98(gUnknown_020393A8, sTransitionStructPtr->field_14, 0, 2, 0, 160); + sub_8149F98(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_14, 0, 2, 0, 160); SetVBlankCallback(VBlankCB_Phase2_Swirl); SetHBlankCallback(HBlankCB_Phase2_Swirl); @@ -1129,7 +1127,7 @@ static bool8 Phase2_Swirl_Func2(struct Task *task) task->tData1 += 4; task->tData2 += 8; - sub_8149F98(gUnknown_02038C28[0], sTransitionStructPtr->field_14, task->tData1, 2, task->tData2, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], sTransitionStructPtr->field_14, task->tData1, 2, task->tData2, 160); if (!gPaletteFade.active) { @@ -1145,12 +1143,12 @@ static void VBlankCB_Phase2_Swirl(void) { VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } static void HBlankCB_Phase2_Swirl(void) { - u16 var = gUnknown_02038C28[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1HOFS = var; REG_BG2HOFS = var; REG_BG3HOFS = var; @@ -1164,10 +1162,10 @@ static void Phase2Task_Shuffle(u8 taskId) static bool8 Phase2_Shuffle_Func1(struct Task *task) { sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); BeginNormalPaletteFade(-1, 4, 0, 0x10, 0); - memset(gUnknown_020393A8, sTransitionStructPtr->field_16, 0x140); + memset(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_16, 0x140); SetVBlankCallback(VBlankCB_Phase2_Shuffle); SetHBlankCallback(HBlankCB_Phase2_Shuffle); @@ -1192,7 +1190,7 @@ static bool8 Phase2_Shuffle_Func2(struct Task *task) for (i = 0; i < 160; i++, r4 += 4224) { u16 var = r4 / 256; - gUnknown_02038C28[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3); + gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3); } if (!gPaletteFade.active) @@ -1206,12 +1204,12 @@ static void VBlankCB_Phase2_Shuffle(void) { VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } static void HBlankCB_Phase2_Shuffle(void) { - u16 var = gUnknown_02038C28[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1VOFS = var; REG_BG2VOFS = var; REG_BG3VOFS = var; @@ -1257,7 +1255,7 @@ static void sub_814669C(struct Task *task) s32 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); task->tData1 = 16; task->tData2 = 0; @@ -1272,7 +1270,7 @@ static void sub_814669C(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[1][i] = 240; + gScanlineEffectRegBuffers[1][i] = 240; } SetVBlankCallback(VBlankCB0_Phase2_BigPokeball); @@ -1351,7 +1349,7 @@ static bool8 Phase2_BigPokeball_Func2(struct Task *task) dst1[i * 32 + j] = *BigPokeballMap | 0xF000; } } - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return TRUE; @@ -1363,7 +1361,7 @@ static bool8 Phase2_Aqua_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LZ77UnCompVram(sTeamAqua_Tilemap, dst1); - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1375,7 +1373,7 @@ static bool8 Phase2_Magma_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LZ77UnCompVram(sTeamMagma_Tilemap, dst1); - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1388,7 +1386,7 @@ static bool8 Phase2_Regice_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LoadPalette(gUnknown_085BC2B4, 0xF0, 0x20); CpuCopy16(gUnknown_085BC314, dst1, 0x500); - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1401,7 +1399,7 @@ static bool8 Phase2_Registeel_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LoadPalette(gUnknown_085BC2D4, 0xF0, 0x20); CpuCopy16(gUnknown_085BCB14, dst1, 0x500); - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1414,7 +1412,7 @@ static bool8 Phase2_Regirock_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LoadPalette(gUnknown_085BC2F4, 0xF0, 0x20); CpuCopy16(gUnknown_085BD314, dst1, 0x500); - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; return FALSE; @@ -1499,7 +1497,7 @@ static bool8 Phase2_BigPokeball_Func3(struct Task *task) task->tData4 += 8; task->tData5 -= 256; - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); sTransitionStructPtr->VBlank_DMA++; return FALSE; @@ -1519,7 +1517,7 @@ static bool8 Phase2_BigPokeball_Func4(struct Task *task) task->tData4 += 8; task->tData5 -= 256; - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); sTransitionStructPtr->VBlank_DMA++; return FALSE; @@ -1531,7 +1529,7 @@ static bool8 Phase2_BigPokeball_Func5(struct Task *task) task->tData4 += 8; task->tData5 -= 256; - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); if (task->tData5 <= 0) { @@ -1577,7 +1575,7 @@ static bool8 Phase2_BigPokeball_Func6(struct Task *task) if (task->tData1 < 0) task->tData1 = 0; } - sub_814A014(gUnknown_02038C28[0], 120, 80, task->tData1); + sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->tData1); if (task->tData1 == 0) { SetVBlankCallback(NULL); @@ -1604,7 +1602,7 @@ static void Transition_BigPokeball_Vblank(void) DmaStop(0); VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_WININ = sTransitionStructPtr->WININ; REG_WINOUT = sTransitionStructPtr->WINOUT; REG_WIN0V = sTransitionStructPtr->WIN0V; @@ -1615,13 +1613,13 @@ static void Transition_BigPokeball_Vblank(void) static void VBlankCB0_Phase2_BigPokeball(void) { Transition_BigPokeball_Vblank(); - DmaSet(0, gUnknown_020393A8, ®_BG0HOFS, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, 0xA2400001); } static void VBlankCB1_Phase2_BigPokeball(void) { Transition_BigPokeball_Vblank(); - DmaSet(0, gUnknown_020393A8, ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } static void Phase2Task_PokeballsTrail(u8 taskId) @@ -1741,7 +1739,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task) u16 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 0; sTransitionStructPtr->WINOUT = 63; @@ -1750,7 +1748,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_020393A8[i] = 0xF3F4; + gScanlineEffectRegBuffers[1][i] = 0xF3F4; } SetVBlankCallback(VBlankCB_Phase2_Clockwise_BlackFade); @@ -1767,7 +1765,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func2(struct Task *task) sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], -1, 1, 1); do { - gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] + 1) | 0x7800; + gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] + 1) | 0x7800; } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); sTransitionStructPtr->data[4] += 16; @@ -1795,7 +1793,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task) r1 = 120, r3 = sTransitionStructPtr->data[2] + 1; if (sTransitionStructPtr->data[5] >= 80) r1 = sTransitionStructPtr->data[2], r3 = 240; - gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (r3) | (r1 << 8); + gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r3) | (r1 << 8); if (var != 0) break; var = sub_814A228(sTransitionStructPtr->data, 1, 1); @@ -1811,7 +1809,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task) { while (sTransitionStructPtr->data[3] < sTransitionStructPtr->data[5]) { - gUnknown_02038C28[0][++sTransitionStructPtr->data[3]] = (r3) | (r1 << 8); + gScanlineEffectRegBuffers[0][++sTransitionStructPtr->data[3]] = (r3) | (r1 << 8); } } @@ -1826,7 +1824,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func4(struct Task *task) sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], 160, 1, 1); do { - gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] << 8) | 0xF0; + gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] << 8) | 0xF0; } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); sTransitionStructPtr->data[4] -= 16; @@ -1851,12 +1849,12 @@ static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task) while (1) { - r1 = (gUnknown_02038C28[0][sTransitionStructPtr->data[3]]) & 0xFF; + r1 = (gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]]) & 0xFF; r2 = sTransitionStructPtr->data[2]; if (sTransitionStructPtr->data[5] <= 80) r2 = 120, r1 = sTransitionStructPtr->data[2]; var4 = (r1) | (r2 << 8); - gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = var4; + gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = var4; if (var != 0) break; var = sub_814A228(sTransitionStructPtr->data, 1, 1); @@ -1872,7 +1870,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task) { while (sTransitionStructPtr->data[3] > sTransitionStructPtr->data[5]) { - gUnknown_02038C28[0][--sTransitionStructPtr->data[3]] = (r1) | (r2 << 8); + gScanlineEffectRegBuffers[0][--sTransitionStructPtr->data[3]] = (r1) | (r2 << 8); } } @@ -1892,7 +1890,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func6(struct Task *task) r2 = 120, r3 = sTransitionStructPtr->data[2]; if (sTransitionStructPtr->data[2] >= 120) r2 = 0, r3 = 240; - gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (r3) | (r2 << 8); + gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r3) | (r2 << 8); } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); @@ -1917,12 +1915,12 @@ static void VBlankCB_Phase2_Clockwise_BlackFade(void) DmaStop(0); VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_WININ = sTransitionStructPtr->WININ; REG_WINOUT = sTransitionStructPtr->WINOUT; REG_WIN0V = sTransitionStructPtr->WIN0V; - REG_WIN0H = gUnknown_02038C28[1][0]; - DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001); + REG_WIN0H = gScanlineEffectRegBuffers[1][0]; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } static void Phase2Task_Ripple(u8 taskId) @@ -1935,11 +1933,11 @@ static bool8 Phase2_Ripple_Func1(struct Task *task) u8 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); for (i = 0; i < 160; i++) { - gUnknown_020393A8[i] = sTransitionStructPtr->field_16; + gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16; } SetVBlankCallback(VBlankCB_Phase2_Ripple); @@ -1971,7 +1969,7 @@ static bool8 Phase2_Ripple_Func2(struct Task *task) // todo: fix the asm s16 var = r4 >> 8; asm(""); - gUnknown_02038C28[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3); + gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3); } if (++task->tData3 == 81) @@ -1991,12 +1989,12 @@ static void VBlankCB_Phase2_Ripple(void) { VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } static void HBlankCB_Phase2_Ripple(void) { - u16 var = gUnknown_02038C28[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1VOFS = var; REG_BG2VOFS = var; REG_BG3VOFS = var; @@ -2012,7 +2010,7 @@ static bool8 Phase2_Wave_Func1(struct Task *task) u8 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 63; sTransitionStructPtr->WINOUT = 0; @@ -2021,7 +2019,7 @@ static bool8 Phase2_Wave_Func1(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[1][i] = 242; + gScanlineEffectRegBuffers[1][i] = 242; } SetVBlankCallback(VBlankCB_Phase2_Wave); @@ -2037,7 +2035,7 @@ static bool8 Phase2_Wave_Func2(struct Task *task) bool8 nextFunc; sTransitionStructPtr->VBlank_DMA = FALSE; - toStore = gUnknown_02038C28[0]; + toStore = gScanlineEffectRegBuffers[0]; r5 = task->tData2; task->tData2 += 16; task->tData1 += 8; @@ -2073,11 +2071,11 @@ static void VBlankCB_Phase2_Wave(void) DmaStop(0); VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_WININ = sTransitionStructPtr->WININ; REG_WINOUT = sTransitionStructPtr->WINOUT; REG_WIN0V = sTransitionStructPtr->WIN0V; - DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } static void Phase2Task_Sydney(u8 taskId) @@ -2120,7 +2118,7 @@ static bool8 Phase2_Mugshot_Func1(struct Task *task) u8 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); Mugshots_CreateOpponentPlayerSprites(task); task->tData1 = 0; @@ -2132,7 +2130,7 @@ static bool8 Phase2_Mugshot_Func1(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[1][i] = 0xF0F1; + gScanlineEffectRegBuffers[1][i] = 0xF0F1; } SetVBlankCallback(VBlankCB0_Phase2_Mugshots); @@ -2177,7 +2175,7 @@ static bool8 Phase2_Mugshot_Func3(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; - toStore = gUnknown_02038C28[0]; + toStore = gScanlineEffectRegBuffers[0]; r5 = task->tData1; task->tData1 += 0x10; @@ -2223,7 +2221,7 @@ static bool8 Phase2_Mugshot_Func4(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; - for (i = 0, toStore = gUnknown_02038C28[0]; i < 160; i++, toStore++) + for (i = 0, toStore = gScanlineEffectRegBuffers[0]; i < 160; i++, toStore++) { *toStore = 0xF0; } @@ -2266,8 +2264,8 @@ static bool8 Phase2_Mugshot_Func6(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; SetVBlankCallback(NULL); DmaStop(0); - memset(gUnknown_02038C28[0], 0, 0x140); - memset(gUnknown_02038C28[1], 0, 0x140); + memset(gScanlineEffectRegBuffers[0], 0, 0x140); + memset(gScanlineEffectRegBuffers[1], 0, 0x140); SetGpuReg(REG_OFFSET_WIN0H, 0xF0); SetGpuReg(REG_OFFSET_BLDY, 0); task->tState++; @@ -2300,15 +2298,15 @@ static bool8 Phase2_Mugshot_Func7(struct Task *task) { s16 index1 = 0x50 - i; s16 index2 = 0x50 + i; - if (gUnknown_02038C28[0][index1] <= 15) + if (gScanlineEffectRegBuffers[0][index1] <= 15) { r6 = TRUE; - gUnknown_02038C28[0][index1]++; + gScanlineEffectRegBuffers[0][index1]++; } - if (gUnknown_02038C28[0][index2] <= 15) + if (gScanlineEffectRegBuffers[0][index2] <= 15) { r6 = TRUE; - gUnknown_02038C28[0][index2]++; + gScanlineEffectRegBuffers[0][index2]++; } } } @@ -2336,7 +2334,7 @@ static bool8 Phase2_Mugshot_Func9(struct Task *task) sTransitionStructPtr->VBlank_DMA = FALSE; task->tData3++; - memset(gUnknown_02038C28[0], task->tData3, 0x140); + memset(gScanlineEffectRegBuffers[0], task->tData3, 0x140); if (task->tData3 > 15) task->tState++; @@ -2357,12 +2355,12 @@ static void VBlankCB0_Phase2_Mugshots(void) DmaStop(0); VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_BG0VOFS = sTransitionStructPtr->BG0VOFS; REG_WININ = sTransitionStructPtr->WININ; REG_WINOUT = sTransitionStructPtr->WINOUT; REG_WIN0V = sTransitionStructPtr->WIN0V; - DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } static void VBlankCB1_Phase2_Mugshots(void) @@ -2370,9 +2368,9 @@ static void VBlankCB1_Phase2_Mugshots(void) DmaStop(0); VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_BLDCNT = sTransitionStructPtr->BLDCNT; - DmaSet(0, gUnknown_02038C28[1], ®_BLDY, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_BLDY, 0xA2400001); } static void HBlankCB_Phase2_Mugshots(void) @@ -2500,7 +2498,7 @@ static bool8 Phase2_Slice_Func1(struct Task *task) u16 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); task->tData2 = 256; task->tData3 = 1; @@ -2511,8 +2509,8 @@ static bool8 Phase2_Slice_Func1(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[1][i] = sTransitionStructPtr->field_14; - gUnknown_02038C28[1][160 + i] = 0xF0; + gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_14; + gScanlineEffectRegBuffers[1][160 + i] = 0xF0; } EnableInterrupts(INTR_FLAG_HBLANK); @@ -2541,8 +2539,8 @@ static bool8 Phase2_Slice_Func2(struct Task *task) for (i = 0; i < 160; i++) { - u16 *storeLoc1 = &gUnknown_02038C28[0][i]; - u16 *storeLoc2 = &gUnknown_02038C28[0][i + 160]; + u16 *storeLoc1 = &gScanlineEffectRegBuffers[0][i]; + u16 *storeLoc2 = &gScanlineEffectRegBuffers[0][i + 160]; if (i & 1) { *storeLoc1 = sTransitionStructPtr->field_14 + task->tData1; @@ -2578,15 +2576,15 @@ static void VBlankCB_Phase2_Slice(void) REG_WINOUT = sTransitionStructPtr->WINOUT; REG_WIN0V = sTransitionStructPtr->WIN0V; if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 640); - DmaSet(0, &gUnknown_02038C28[1][160], ®_WIN0H, 0xA2400001); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640); + DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); } static void HBlankCB_Phase2_Slice(void) { if (REG_VCOUNT < 160) { - u16 var = gUnknown_02038C28[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1HOFS = var; REG_BG2HOFS = var; REG_BG3HOFS = var; @@ -2603,7 +2601,7 @@ static bool8 Phase2_ShredSplit_Func1(struct Task *task) u16 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 63; sTransitionStructPtr->WINOUT = 0; @@ -2611,13 +2609,13 @@ static bool8 Phase2_ShredSplit_Func1(struct Task *task) for (i = 0; i < 0xA0; i++) { - gUnknown_02038C28[1][i] = sTransitionStructPtr->field_14; - gUnknown_02038C28[1][0xA0 + i] = 0xF0; - gUnknown_02038C28[0][i] = sTransitionStructPtr->field_14; - gUnknown_02038C28[0][0xA0 + i] = 0xF0; - gUnknown_02038C28[0][0x140 + i] = 0; - gUnknown_02038C28[0][0x1E0 + i] = 0x100; - gUnknown_02038C28[0][0x280 + i] = 1; + gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_14; + gScanlineEffectRegBuffers[1][0xA0 + i] = 0xF0; + gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_14; + gScanlineEffectRegBuffers[0][0xA0 + i] = 0xF0; + gScanlineEffectRegBuffers[0][0x140 + i] = 0; + gScanlineEffectRegBuffers[0][0x1E0 + i] = 0x100; + gScanlineEffectRegBuffers[0][0x280 + i] = 1; } task->tData4 = 0; @@ -2657,9 +2655,9 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) unkVar = (arr1[j]) + (arr2[k] * -(i) * 2); if (unkVar >= 0 && (unkVar != 79 || j != 1)) { - ptr4 = &gUnknown_02038C28[0][unkVar + 320]; - ptr3 = &gUnknown_02038C28[0][unkVar + 480]; - ptr1 = &gUnknown_02038C28[0][unkVar + 640]; + ptr4 = &gScanlineEffectRegBuffers[0][unkVar + 320]; + ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 480]; + ptr1 = &gScanlineEffectRegBuffers[0][unkVar + 640]; if (*ptr4 > 0xEF) { *ptr4 = 0xF0; @@ -2673,8 +2671,8 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) if (*ptr3 <= 0xFFF) *ptr3 += *ptr1; } - ptr2 = &gUnknown_02038C28[0][unkVar]; - ptr3 = &gUnknown_02038C28[0][unkVar + 160]; + ptr2 = &gScanlineEffectRegBuffers[0][unkVar]; + ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 160]; *ptr2 = sTransitionStructPtr->field_14 + *ptr4; *ptr3 = 0xF0 - *ptr4; @@ -2691,9 +2689,9 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) unkVar = (arr1[j] + 1) + (arr2[k] * -(i) * 2); if (unkVar <= 160 && (unkVar != 80 || j != 1)) { - ptr4 = &gUnknown_02038C28[0][unkVar + 320]; - ptr3 = &gUnknown_02038C28[0][unkVar + 480]; - ptr1 = &gUnknown_02038C28[0][unkVar + 640]; + ptr4 = &gScanlineEffectRegBuffers[0][unkVar + 320]; + ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 480]; + ptr1 = &gScanlineEffectRegBuffers[0][unkVar + 640]; if (*ptr4 > 0xEF) { *ptr4 = 0xF0; @@ -2707,8 +2705,8 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) if (*ptr3 <= 0xFFF) *ptr3 += *ptr1; } - ptr2 = &gUnknown_02038C28[0][unkVar]; - ptr3 = &gUnknown_02038C28[0][unkVar + 160]; + ptr2 = &gScanlineEffectRegBuffers[0][unkVar]; + ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 160]; *ptr2 = sTransitionStructPtr->field_14 - *ptr4; *ptr3 = (*ptr4 << 8) | (0xF1); @@ -2732,7 +2730,7 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) // This function never increments the state counter, because the loop condition // is always false, resulting in the game being stuck in an infinite loop. -// It's possible this transition is only partially +// It's possible this transition is only partially // done and the second part was left out. static bool8 Phase2_ShredSplit_Func3(struct Task *task) { @@ -2742,7 +2740,7 @@ static bool8 Phase2_ShredSplit_Func3(struct Task *task) for (i = 0; i < 0xA0; i++) { - if (gUnknown_02038C28[1][i] != 0xF0 && gUnknown_02038C28[1][i] != checkVar2) + if (gScanlineEffectRegBuffers[1][i] != 0xF0 && gScanlineEffectRegBuffers[1][i] != checkVar2) done = FALSE; // a break statement should be put here } @@ -2775,7 +2773,7 @@ static bool8 Phase2_Blackhole_Func1(struct Task *task) s32 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 0; sTransitionStructPtr->WINOUT = 63; @@ -2784,7 +2782,7 @@ static bool8 Phase2_Blackhole_Func1(struct Task *task) for (i = 0; i < 0xA0; i++) { - gUnknown_02038C28[1][i] = 0; + gScanlineEffectRegBuffers[1][i] = 0; } SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); @@ -2814,7 +2812,7 @@ static bool8 Phase2_Blackhole1_Func3(struct Task *task) task->tData1 += (task->tData2 >> 8); if (task->tData1 > 0xA0) task->tData1 = 0xA0; - sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1); + sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); if (task->tData1 == 0xA0) { task->tFuncState = 1; @@ -2840,7 +2838,7 @@ static bool8 Phase2_Blackhole1_Func2(struct Task *task) } task->tData1 += gUnknown_085C8C80[task->tData6]; task->tData6 = (task->tData6 + 1) % 2; - sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1); + sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); if (task->tData1 < 9) { task->tState++; @@ -2866,7 +2864,7 @@ static bool8 Phase2_Blackhole2_Func2(struct Task *task) if (task->tData1 > 0xA0) task->tData1 = 0xA0; - sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1); + sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); if (task->tData1 == 0xA0) { DmaStop(0); @@ -3113,7 +3111,7 @@ static bool8 Phase2_Rayquaza_Func3(struct Task *task) u16 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); SetGpuReg(REG_OFFSET_BG0CNT, 0x9A08); sub_8149F58(&dst1, &dst2); @@ -3126,8 +3124,8 @@ static bool8 Phase2_Rayquaza_Func3(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[0][i] = 0; - gUnknown_02038C28[1][i] = 0x100; + gScanlineEffectRegBuffers[0][i] = 0; + gScanlineEffectRegBuffers[1][i] = 0x100; } SetVBlankCallback(VBlankCB_Phase2_Rayquaza); @@ -3212,7 +3210,7 @@ static bool8 Phase2_Rayquaza_Func9(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[1][i] = 0; + gScanlineEffectRegBuffers[1][i] = 0; } SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); @@ -3233,11 +3231,11 @@ static void VBlankCB_Phase2_Rayquaza(void) VBlankCB_BattleTransition(); if (sTransitionStructPtr->field_20 == 0) - dmaSrc = gUnknown_02038C28[0]; + dmaSrc = gScanlineEffectRegBuffers[0]; else if (sTransitionStructPtr->field_20 == 1) - dmaSrc = gUnknown_02038C28[1]; + dmaSrc = gScanlineEffectRegBuffers[1]; else - dmaSrc = gUnknown_02038C28[0]; + dmaSrc = gScanlineEffectRegBuffers[0]; DmaSet(0, dmaSrc, ®_BG0VOFS, 0xA2400001); } @@ -3252,7 +3250,7 @@ static bool8 Phase2_WhiteFade_Func1(struct Task *task) u16 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); sTransitionStructPtr->BLDCNT = 0xBF; sTransitionStructPtr->BLDY = 0; @@ -3262,8 +3260,8 @@ static bool8 Phase2_WhiteFade_Func1(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[1][i] = 0; - gUnknown_02038C28[1][i + 160] = 0xF0; + gScanlineEffectRegBuffers[1][i] = 0; + gScanlineEffectRegBuffers[1][i + 160] = 0xF0; } EnableInterrupts(INTR_FLAG_HBLANK); @@ -3343,8 +3341,8 @@ static void VBlankCB0_Phase2_WhiteFade(void) REG_WINOUT = sTransitionStructPtr->WINOUT; REG_WIN0V = sTransitionStructPtr->WIN0V; if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 640); - DmaSet(0, &gUnknown_02038C28[1][160], ®_WIN0H, 0xA2400001); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640); + DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); } static void VBlankCB1_Phase2_WhiteFade(void) @@ -3360,7 +3358,7 @@ static void VBlankCB1_Phase2_WhiteFade(void) static void HBlankCB_Phase2_WhiteFade(void) { - REG_BLDY = gUnknown_02038C28[1][REG_VCOUNT]; + REG_BLDY = gScanlineEffectRegBuffers[1][REG_VCOUNT]; } static void sub_8149864(struct Sprite *sprite) @@ -3374,8 +3372,8 @@ static void sub_8149864(struct Sprite *sprite) else { u16 i; - u16* ptr1 = &gUnknown_02038C28[0][sprite->pos1.y]; - u16* ptr2 = &gUnknown_02038C28[0][sprite->pos1.y + 160]; + u16* ptr1 = &gScanlineEffectRegBuffers[0][sprite->pos1.y]; + u16* ptr2 = &gScanlineEffectRegBuffers[0][sprite->pos1.y + 160]; for (i = 0; i < 20; i++) { ptr1[i] = sprite->data[0] >> 8; @@ -3465,7 +3463,7 @@ static bool8 Phase2_Shards_Func1(struct Task *task) u16 i; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 0x3F; sTransitionStructPtr->WINOUT = 0; @@ -3473,10 +3471,10 @@ static bool8 Phase2_Shards_Func1(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[0][i] = 0xF0; + gScanlineEffectRegBuffers[0][i] = 0xF0; } - CpuSet(gUnknown_02038C28[0], gUnknown_02038C28[1], 0xA0); + CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 0xA0); SetVBlankCallback(VBlankCB_Phase2_Shards); task->tState++; @@ -3505,8 +3503,8 @@ static bool8 Phase2_Shards_Func3(struct Task *task) for (i = 0, nextFunc = FALSE; i < 16; i++) { - s16 r3 = gUnknown_02038C28[0][sTransitionStructPtr->data[3]] >> 8; - s16 r4 = gUnknown_02038C28[0][sTransitionStructPtr->data[3]] & 0xFF; + s16 r3 = gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] >> 8; + s16 r4 = gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] & 0xFF; if (task->tData2 == 0) { if (r3 < sTransitionStructPtr->data[2]) @@ -3521,7 +3519,7 @@ static bool8 Phase2_Shards_Func3(struct Task *task) if (r4 <= r3) r4 = r3; } - gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (r4) | (r3 << 8); + gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r4) | (r3 << 8); if (nextFunc) { task->tState++; @@ -3568,12 +3566,12 @@ static void VBlankCB_Phase2_Shards(void) DmaStop(0); VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_WININ = sTransitionStructPtr->WININ; REG_WINOUT = sTransitionStructPtr->WINOUT; REG_WIN0V = sTransitionStructPtr->WIN0V; - REG_WIN0H = gUnknown_02038C28[1][0]; - DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001); + REG_WIN0H = gScanlineEffectRegBuffers[1][0]; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } // sub-task for phase2 @@ -3875,7 +3873,7 @@ static bool8 Phase2_29_Func2(struct Task *task) sub_8149F58(&dst1, &dst2); LZ77UnCompVram(gUnknown_085C828C, dst1); - sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 0x84, task->tData5, 160); + sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 0x84, task->tData5, 160); task->tState++; return TRUE; @@ -3896,7 +3894,7 @@ static bool8 Phase2_30_Func1(struct Task *task) u16 *dst1, *dst2; sub_8149F08(); - dp12_8087EA4(); + ScanlineEffect_Clear(); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON); task->tData2 = 0x2000; task->tData1 = 0x7FFF; @@ -3934,7 +3932,7 @@ static bool8 Phase2_30_Func3(struct Task *task) for (i = 0; i < 160; i++) { - gUnknown_02038C28[1][i] = sTransitionStructPtr->field_16; + gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16; } SetVBlankCallback(VBlankCB_Phase2_30); @@ -3980,7 +3978,7 @@ static bool8 Phase2_30_Func4(struct Task *task) { s16 index = var6 / 256; asm(""); - gUnknown_02038C28[0][i] = sTransitionStructPtr->field_16 + Sin(index, amplitude); + gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(index, amplitude); } if (++task->tData3 == 101) @@ -4004,12 +4002,12 @@ static void VBlankCB_Phase2_30(void) REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } static void HBlankCB_Phase2_30(void) { - u16 var = gUnknown_02038C28[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG0VOFS = var; } diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c index f487489d4..7b968a221 100644 --- a/src/berry_fix_program.c +++ b/src/berry_fix_program.c @@ -6,7 +6,7 @@ #include "main.h" #include "sprite.h" #include "task.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "window.h" #include "text.h" #include "menu.h" diff --git a/src/diploma.c b/src/diploma.c index 24e5e9727..89447c5ba 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -3,7 +3,7 @@ #include "palette.h" #include "main.h" #include "gpu_regs.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "task.h" #include "malloc.h" #include "decompress.h" diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 5dfc36cb2..cbd37be52 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -11,7 +11,7 @@ #include "pokemon.h" #include "string_util.h" #include "battle.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "decompress.h" #include "m4a.h" #include "menu.h" @@ -1367,7 +1367,7 @@ static void VBlankCB_EvolutionScene(void) LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_80BA0A8(); + ScanlineEffect_InitHBlankDmaTransfer(); } static void VBlankCB_TradeEvolutionScene(void) @@ -1384,7 +1384,7 @@ static void VBlankCB_TradeEvolutionScene(void) LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_80BA0A8(); + ScanlineEffect_InitHBlankDmaTransfer(); } static void sub_813FDEC(u8 taskId) diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 5390814eb..62d2b39a4 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -20,7 +20,7 @@ #include "string_util.h" #include "m4a.h" #include "international_string_util.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "trig.h" #include "random.h" #include "event_data.h" diff --git a/src/mail.c b/src/mail.c index c3cbe4a3c..ac263ac67 100644 --- a/src/mail.c +++ b/src/mail.c @@ -4,7 +4,7 @@ #include "main.h" #include "overworld.h" #include "task.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "palette.h" #include "text.h" #include "menu.h" diff --git a/src/option_menu.c b/src/option_menu.c index 7f92756ab..cbbe14b77 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -2,7 +2,7 @@ #include "option_menu.h" #include "main.h" #include "menu.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "palette.h" #include "sprite.h" #include "task.h" diff --git a/src/pokeblock.c b/src/pokeblock.c index 1a4ce3155..472b030e0 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -14,7 +14,7 @@ #include "battle.h" #include "battle_controllers.h" #include "palette.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "list_menu.h" #include "gpu_regs.h" #include "decompress.h" diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 3df2ff151..a4bb4a728 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -3,7 +3,7 @@ #include "battle.h" #include "palette.h" #include "main.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "text.h" #include "gpu_regs.h" #include "bg.h" @@ -34,7 +34,7 @@ extern struct SpriteTemplate gUnknown_0202499C; extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[]; -extern void dp12_8087EA4(void); +extern void ScanlineEffect_Clear(void); extern void sub_8035658(void); extern bool8 IsDoubleBattle(void); extern u8 GetSubstituteSpriteDefault_Y(u8 bank); @@ -72,7 +72,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void) switch (gBattleScripting.reshowMainState) { case 0: - dp12_8087EA4(); + ScanlineEffect_Clear(); sub_8035658(); SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); diff --git a/src/scanline_effect.c b/src/scanline_effect.c new file mode 100644 index 000000000..148e053fc --- /dev/null +++ b/src/scanline_effect.c @@ -0,0 +1,262 @@ +#include "global.h" +#include "data2.h" +#include "task.h" +#include "trig.h" +#include "scanline_effect.h" + +static void CopyValue16Bit(void); +static void CopyValue32Bit(void); + +extern u16 gBattle_BG0_Y; +extern u16 gBattle_BG0_X; +extern u16 gBattle_BG1_X; +extern u16 gBattle_BG1_Y; +extern u16 gBattle_BG2_X; +extern u16 gBattle_BG2_Y; +extern u16 gBattle_BG3_X; +extern u16 gBattle_BG3_Y; + +// EWRAM vars + +// Per-scanline register values. +// This is double buffered so that it can be safely written to at any time +// without overwriting the buffer that the DMA is currently reading +EWRAM_DATA u16 gScanlineEffectRegBuffers[2][0x3C0] = {0}; + +EWRAM_DATA struct ScanlineEffect gScanlineEffect = {0}; +EWRAM_DATA static bool8 sShouldStopWaveTask = FALSE; + +void ScanlineEffect_Stop(void) +{ + gScanlineEffect.state = 0; + DmaStop(0); + if (gScanlineEffect.waveTaskId != 0xFF) + { + DestroyTask(gScanlineEffect.waveTaskId); + gScanlineEffect.waveTaskId = 0xFF; + } +} + +void ScanlineEffect_Clear(void) +{ + CpuFill16(0, gScanlineEffectRegBuffers, sizeof(gScanlineEffectRegBuffers)); + gScanlineEffect.dmaSrcBuffers[0] = NULL; + gScanlineEffect.dmaSrcBuffers[1] = NULL; + gScanlineEffect.dmaDest = NULL; + gScanlineEffect.dmaControl = 0; + gScanlineEffect.srcBuffer = 0; + gScanlineEffect.state = 0; + gScanlineEffect.unused16 = 0; + gScanlineEffect.unused17 = 0; + gScanlineEffect.waveTaskId = 0xFF; +} + +void ScanlineEffect_SetParams(struct ScanlineEffectParams params) +{ + if (params.dmaControl == SCANLINE_EFFECT_DMACNT_16BIT) // 16-bit + { + // Set the DMA src to the value for the second scanline because the + // first DMA transfer occurs in HBlank *after* the first scanline is drawn + gScanlineEffect.dmaSrcBuffers[0] = (u16 *)gScanlineEffectRegBuffers[0] + 1; + gScanlineEffect.dmaSrcBuffers[1] = (u16 *)gScanlineEffectRegBuffers[1] + 1; + gScanlineEffect.setFirstScanlineReg = CopyValue16Bit; + } + else // assume 32-bit + { + // Set the DMA src to the value for the second scanline because the + // first DMA transfer occurs in HBlank *after* the first scanline is drawn + gScanlineEffect.dmaSrcBuffers[0] = (u32 *)gScanlineEffectRegBuffers[0] + 1; + gScanlineEffect.dmaSrcBuffers[1] = (u32 *)gScanlineEffectRegBuffers[1] + 1; + gScanlineEffect.setFirstScanlineReg = CopyValue32Bit; + } + + gScanlineEffect.dmaControl = params.dmaControl; + gScanlineEffect.dmaDest = params.dmaDest; + gScanlineEffect.state = params.initState; + gScanlineEffect.unused16 = params.unused9; + gScanlineEffect.unused17 = params.unused9; +} + +void ScanlineEffect_InitHBlankDmaTransfer(void) +{ + if (gScanlineEffect.state == 0) + { + return; + } + else if (gScanlineEffect.state == 3) + { + gScanlineEffect.state = 0; + DmaStop(0); + sShouldStopWaveTask = TRUE; + } + else + { + DmaStop(0); + // Set DMA to copy to dest register on each HBlank for the next frame. + // The HBlank DMA transfers do not occurr during VBlank, so the transfer + // will begin on the HBlank after the first scanline + DmaSet(0, gScanlineEffect.dmaSrcBuffers[gScanlineEffect.srcBuffer], gScanlineEffect.dmaDest, gScanlineEffect.dmaControl); + // Manually set the reg for the first scanline + gScanlineEffect.setFirstScanlineReg(); + // Swap current buffer + gScanlineEffect.srcBuffer ^= 1; + } +} + +// These two functions are used to copy the register for the first scanline, +// depending whether it is a 16-bit register or a 32-bit register. + +static void CopyValue16Bit(void) +{ + u16 *dest = (u16 *)gScanlineEffect.dmaDest; + u16 *src = (u16 *)&gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer]; + + *dest = *src; +} + +static void CopyValue32Bit(void) +{ + u32 *dest = (u32 *)gScanlineEffect.dmaDest; + u32 *src = (u32 *)&gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer]; + + *dest = *src; +} + +#define tStartLine data[0] +#define tEndLine data[1] +#define tWaveLength data[2] +#define tSrcBufferOffset data[3] +#define tFramesUntilMove data[4] +#define tDelayInterval data[5] +#define tRegOffset data[6] +#define tApplyBattleBgOffsets data[7] + +static void TaskFunc_UpdateWavePerFrame(u8 taskId) +{ + int value = 0; + int i; + int offset; + + if (sShouldStopWaveTask) + { + DestroyTask(taskId); + gScanlineEffect.waveTaskId = 0xFF; + } + else + { + if (gTasks[taskId].tApplyBattleBgOffsets) + { + switch (gTasks[taskId].tRegOffset) + { + case SCANLINE_EFFECT_REG_BG0HOFS: + value = gBattle_BG0_X; + break; + case SCANLINE_EFFECT_REG_BG0VOFS: + value = gBattle_BG0_Y; + break; + case SCANLINE_EFFECT_REG_BG1HOFS: + value = gBattle_BG1_X; + break; + case SCANLINE_EFFECT_REG_BG1VOFS: + value = gBattle_BG1_Y; + break; + case SCANLINE_EFFECT_REG_BG2HOFS: + value = gBattle_BG2_X; + break; + case SCANLINE_EFFECT_REG_BG2VOFS: + value = gBattle_BG2_Y; + break; + case SCANLINE_EFFECT_REG_BG3HOFS: + value = gBattle_BG3_X; + break; + case SCANLINE_EFFECT_REG_BG3VOFS: + value = gBattle_BG3_Y; + break; + } + } + if (gTasks[taskId].tFramesUntilMove != 0) + { + gTasks[taskId].tFramesUntilMove--; + offset = gTasks[taskId].tSrcBufferOffset + 320; + for (i = gTasks[taskId].tStartLine; i < gTasks[taskId].tEndLine; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gScanlineEffectRegBuffers[0][offset] + value; + offset++; + } + } + else + { + gTasks[taskId].tFramesUntilMove = gTasks[taskId].tDelayInterval; + offset = gTasks[taskId].tSrcBufferOffset + 320; + for (i = gTasks[taskId].tStartLine; i < gTasks[taskId].tEndLine; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gScanlineEffectRegBuffers[0][offset] + value; + offset++; + } + + // increment src buffer offset + gTasks[taskId].tSrcBufferOffset++; + if (gTasks[taskId].tSrcBufferOffset == gTasks[taskId].tWaveLength) + gTasks[taskId].tSrcBufferOffset = 0; + } + } +} + +static void GenerateWave(u16 *buffer, u8 frequency, u8 amplitude, u8 unused) +{ + u16 i = 0; + u8 theta = 0; + + while (i < 256) + { + buffer[i] = (gSineTable[theta] * amplitude) / 256; + theta += frequency; + i++; + } +} + +// Initializes a background "wave" effect that affects scanlines startLine (inclusive) to endLine (exclusive). +// 'frequency' and 'amplitude' control the frequency and amplitude of the wave. +// 'delayInterval' controls how fast the wave travels up the screen. The wave will shift upwards one scanline every 'delayInterval'+1 frames. +// 'regOffset' is the offset of the video register to modify. +u8 ScanlineEffect_InitWave(u8 startLine, u8 endLine, u8 frequency, u8 amplitude, u8 delayInterval, u8 regOffset, bool8 applyBattleBgOffsets) +{ + int i; + int offset; + struct ScanlineEffectParams params; + u8 taskId; + + ScanlineEffect_Clear(); + + params.dmaDest = (void *)(REG_ADDR_BG0HOFS + regOffset); + params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + params.initState = 1; + params.unused9 = 0; + ScanlineEffect_SetParams(params); + + taskId = CreateTask(TaskFunc_UpdateWavePerFrame, 0); + + gTasks[taskId].tStartLine = startLine; + gTasks[taskId].tEndLine = endLine; + gTasks[taskId].tWaveLength = 256 / frequency; + gTasks[taskId].tSrcBufferOffset = 0; + gTasks[taskId].tFramesUntilMove = delayInterval; + gTasks[taskId].tDelayInterval = delayInterval; + gTasks[taskId].tRegOffset = regOffset; + gTasks[taskId].tApplyBattleBgOffsets = applyBattleBgOffsets; + + gScanlineEffect.waveTaskId = taskId; + sShouldStopWaveTask = FALSE; + + GenerateWave(&gScanlineEffectRegBuffers[0][320], frequency, amplitude, endLine - startLine); + + offset = 320; + for (i = startLine; i < endLine; i++) + { + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[0][offset]; + gScanlineEffectRegBuffers[1][i] = gScanlineEffectRegBuffers[0][offset]; + offset++; + } + + return taskId; +} diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 12f475c93..c8898d08f 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -4,7 +4,7 @@ #include "malloc.h" #include "palette.h" #include "pokenav.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "text.h" #include "bg.h" #include "window.h" @@ -131,7 +131,7 @@ void sub_8166340(void) ProcessSpriteCopyRequests(); TransferPlttBuffer(); sub_81D2108(gUnknown_0203BCAC->field_7C58); - sub_80BA0A8(); + ScanlineEffect_InitHBlankDmaTransfer(); } void sub_816636C(void (*func)(void)) diff --git a/src/wallclock.c b/src/wallclock.c index dbea24b4c..f15bbbc27 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -12,7 +12,7 @@ #include "window.h" #include "text_window.h" #include "menu.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "task.h" #include "strings.h" #include "sound.h" diff --git a/sym_ewram.txt b/sym_ewram.txt index c04f524d8..df3987e68 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -713,36 +713,7 @@ gUnknown_02038BC6: @ 2038BC6 gFieldEffectArguments: @ 2038C08 .space 0x20 -gUnknown_02038C28: @ 2038C28 - .space 0x2 - -gUnknown_02038C2A: @ 2038C2A - .space 0x2 - -gUnknown_02038C2C: @ 2038C2C - .space 0x13C - -gUnknown_02038D68: @ 2038D68 - .space 0x140 - -gUnknown_02038EA8: @ 2038EA8 - .space 0x280 - -gUnknown_02039128: @ 2039128 - .space 0x280 - -gUnknown_020393A8: @ 20393A8 - .space 0x140 - -gUnknown_020394E8: @ 20394E8 - .space 0x640 - -gUnknown_02039B28: @ 2039B28 - .space 0x1C - -gUnknown_02039B44: @ 2039B44 - .space 0x4 - + .include "src/scanline_effect.o" .include "src/option_menu.o" .align 2