From 0a1c66cb71307035952b8dc8dbf80f871c12de7f Mon Sep 17 00:00:00 2001 From: mokhaleee Date: Thu, 11 May 2023 19:09:04 +0800 Subject: [PATCH] bmlib: port in process --- asm/banim-08056864.s | 2 +- asm/banim-efxbattle.s | 2 +- asm/banim-efxflasheffect.s | 4 +- asm/banim-efxop.s | 4 +- asm/banim-ekrdragon-demonking.s | 10 +- asm/banim-ekrgauge.s | 6 +- asm/banim-ekrmain.s | 8 +- asm/banim-ekrtriangle.s | 2 +- asm/bmlib-pal.s | 436 +++++++++++++++++ asm/code_80B5730.s | 8 +- asm/code_80CCA64.s | 4 +- asm/code_mapanim.s | 36 +- asm/code_sio.s | 16 +- asm/eventcmd_fade.s | 6 +- asm/evtscr.s | 8 +- asm/hino.s | 825 +------------------------------- asm/mapanim_807CDD0.s | 40 +- asm/shinningstonefx.s | 2 +- data/bmlib-const.s | 29 ++ data/bmlib-pal.s | 21 + data/bmlib.s | 191 ++++++++ data/const_data_D792C.s | 32 -- data/data_599714.s | 245 ---------- data/data_5A92E0.s | 4 +- data/data_9A31F8.s | 4 +- data/data_A167C8.s | 8 +- data/data_A3CB04.s | 4 +- data/data_B12A60.s | 12 +- data/data_prep_A1901C.s | 4 +- include/bm.h | 6 +- include/bmlib.h | 18 + include/functions.h | 86 ++-- include/gba/syscall.h | 17 +- include/hardware.h | 2 +- include/variables.h | 10 +- ldscript.txt | 8 + src/ap.c | 2 +- src/banim-ekrbattle.c | 12 +- src/banim-ekrbattlestarting.c | 2 +- src/banim-ekrdragon-demonking.c | 5 +- src/banim-ekrgauge.c | 4 +- src/banim-ekrlvup.c | 12 +- src/banim-ekrmain.c | 2 +- src/bksel.c | 2 +- src/bm.c | 10 +- src/bmdifficulty.c | 8 +- src/bmio.c | 6 +- src/bmitemuse.c | 10 +- src/bmlib-fade.c | 173 +++++++ src/bmlib.c | 664 ++++++++++--------------- src/bmmenu.c | 8 +- src/bmshop.c | 8 +- src/bmtrade.c | 4 +- src/bmudisp.c | 12 +- src/bmxfade.c | 6 +- src/branched_promotion_main.c | 2 +- src/emitstarfx.c | 2 +- src/event.c | 4 +- src/face.c | 23 +- src/fontgrp.c | 4 +- src/hardware.c | 2 +- src/icon.c | 8 +- src/koido.c | 4 +- src/mapanim.c | 8 +- src/mapanim_api.c | 6 +- src/mapanim_debug.c | 2 +- src/mapanim_eventbattle.c | 4 +- src/mapanim_expbar.c | 6 +- src/mapanim_specialeffect.c | 4 +- src/mapanim_summon.c | 4 +- src/minimap.c | 4 +- src/mu.c | 19 +- src/opinfo.c | 2 +- src/player_interface.c | 8 +- src/playerphase.c | 6 +- src/prep_atmenu.c | 4 +- src/prep_itemuse.c | 4 +- src/prep_menuproc.c | 4 +- src/sallycursor.c | 4 +- src/savedrawcursor.c | 2 +- src/statbar.c | 4 +- src/trapfx.c | 10 +- src/uiarena.c | 10 +- src/uichapterstatus.c | 4 +- src/uiconfig.c | 12 +- src/uimenu.c | 4 +- src/uiselecttarget.c | 4 +- src/uiutils.c | 4 +- sym_ewram.txt | 2 +- 89 files changed, 1445 insertions(+), 1819 deletions(-) create mode 100644 asm/bmlib-pal.s create mode 100644 data/bmlib-const.s create mode 100644 data/bmlib-pal.s create mode 100644 data/bmlib.s create mode 100644 include/bmlib.h create mode 100644 src/bmlib-fade.c diff --git a/asm/banim-08056864.s b/asm/banim-08056864.s index 5971dab4..bc8eadad 100644 --- a/asm/banim-08056864.s +++ b/asm/banim-08056864.s @@ -280,7 +280,7 @@ _08056A72: ldr r0, _08056B18 @ gUnknown_02000088 movs r2, #0x80 lsls r2, r2, #7 - bl RegisterTileGraphics + bl RegisterDataMove movs r0, #0 strh r0, [r4, #0x2c] movs r0, #0xb diff --git a/asm/banim-efxbattle.s b/asm/banim-efxbattle.s index 30f6badd..643b231c 100644 --- a/asm/banim-efxbattle.s +++ b/asm/banim-efxbattle.s @@ -1712,7 +1712,7 @@ _08053B10: ldr r1, _08053BA0 @ 0x06011800 movs r2, #0x80 lsls r2, r2, #4 - bl RegisterTileGraphics + bl RegisterDataMove ldr r4, _08053BA4 @ gEkrSpellAnimIndexLutMaybe mov r0, r9 bl GetAISSubjectId diff --git a/asm/banim-efxflasheffect.s b/asm/banim-efxflasheffect.s index fe4db7e7..a5c59cac 100644 --- a/asm/banim-efxflasheffect.s +++ b/asm/banim-efxflasheffect.s @@ -1260,7 +1260,7 @@ SomeImageStoringRoutine_SpellAnim: @ 0x080557D8 adds r0, r4, #0 adds r1, r5, #0 adds r2, r6, #0 - bl RegisterTileGraphics + bl RegisterDataMove pop {r4, r5, r6} pop {r0} bx r0 @@ -1297,7 +1297,7 @@ SomeImageStoringRoutine_SpellAnim2: @ 0x0805581C adds r0, r4, #0 adds r1, r5, #0 adds r2, r6, #0 - bl RegisterTileGraphics + bl RegisterDataMove pop {r4, r5, r6} pop {r0} bx r0 diff --git a/asm/banim-efxop.s b/asm/banim-efxop.s index 415da943..8310a1c8 100644 --- a/asm/banim-efxop.s +++ b/asm/banim-efxop.s @@ -223,7 +223,7 @@ sub_806EAA4: @ 0x0806EAA4 movs r2, #0x80 lsls r2, r2, #6 adds r1, r4, #0 - bl RegisterTileGraphics + bl RegisterDataMove pop {r4, r5, r6} pop {r0} bx r0 @@ -268,7 +268,7 @@ sub_806EAFC: @ 0x0806EAFC movs r2, #0x80 lsls r2, r2, #5 adds r1, r4, #0 - bl RegisterTileGraphics + bl RegisterDataMove pop {r4, r5, r6} pop {r0} bx r0 diff --git a/asm/banim-ekrdragon-demonking.s b/asm/banim-ekrdragon-demonking.s index bf65dd40..616555c2 100644 --- a/asm/banim-ekrdragon-demonking.s +++ b/asm/banim-ekrdragon-demonking.s @@ -190,17 +190,17 @@ sub_80773E4: @ 0x080773E4 lsls r0, r0, #1 cmp r1, r0 bne _08077436 - ldr r4, _08077458 @ gUnknown_0859A120 + ldr r4, _08077458 @ Pal_AllBlack adds r0, r4, #0 movs r1, #0x17 movs r2, #0xf0 adds r3, r5, #0 - bl NewEkrDragonPalFadeIn + bl StartPalFade adds r0, r4, #0 movs r1, #6 movs r2, #0xf0 adds r3, r5, #0 - bl NewEkrDragonPalFadeIn + bl StartPalFade _08077436: ldr r0, _0807745C @ gUnknown_08801810 bl Proc_Find @@ -217,7 +217,7 @@ _0807744E: pop {r0} bx r0 .align 2, 0 -_08077458: .4byte gUnknown_0859A120 +_08077458: .4byte Pal_AllBlack _0807745C: .4byte gUnknown_08801810 THUMB_FUNC_END sub_80773E4 @@ -1473,7 +1473,7 @@ sub_8077DC8: @ 0x08077DC8 movs r1, #0 bl sub_8077EAC movs r0, #1 - bl sub_8013A84 + bl SetBlackPal bl EnablePaletteSync add r1, sp, #8 movs r0, #0 diff --git a/asm/banim-ekrgauge.s b/asm/banim-ekrgauge.s index b73f662c..3ce4bdca 100644 --- a/asm/banim-ekrgauge.s +++ b/asm/banim-ekrgauge.s @@ -385,12 +385,12 @@ _0805154A: ldr r1, _080515C8 @ 0x060139C0 adds r0, r7, #0 movs r2, #0x40 - bl RegisterTileGraphics + bl RegisterDataMove adds r0, r7, #0 adds r0, #0x40 ldr r1, _080515CC @ 0x06013DC0 movs r2, #0x40 - bl RegisterTileGraphics + bl RegisterDataMove _08051582: add r0, sp, #8 movs r4, #0 @@ -823,7 +823,7 @@ _080518DC: ldr r1, _08051A94 @ 0x06013000 movs r2, #0x80 lsls r2, r2, #4 - bl RegisterTileGraphics + bl RegisterDataMove _080518EE: mov r5, sl ldr r4, [r5, #0x4c] diff --git a/asm/banim-ekrmain.s b/asm/banim-ekrmain.s index 11b2a8d3..ec2cf03d 100644 --- a/asm/banim-ekrmain.s +++ b/asm/banim-ekrmain.s @@ -2276,7 +2276,7 @@ _0805AAF0: lsls r5, r5, #4 adds r0, r3, #0 adds r2, r5, #0 - bl RegisterTileGraphics + bl RegisterDataMove movs r1, #0xa ldrsh r0, [r6, r1] lsls r0, r0, #5 @@ -2285,7 +2285,7 @@ _0805AAF0: adds r1, r1, r0 adds r0, r7, #0 adds r2, r5, #0 - bl RegisterTileGraphics + bl RegisterDataMove movs r2, #2 ldrsh r1, [r6, r2] lsls r1, r1, #5 @@ -2320,7 +2320,7 @@ _0805AB74: movs r2, #0x80 lsls r2, r2, #4 adds r0, r3, #0 - bl RegisterTileGraphics + bl RegisterDataMove movs r0, #2 ldrsh r1, [r6, r0] lsls r1, r1, #5 @@ -2342,7 +2342,7 @@ _0805ABA2: movs r2, #0x80 lsls r2, r2, #4 adds r0, r7, #0 - bl RegisterTileGraphics + bl RegisterDataMove movs r0, #8 ldrsh r1, [r6, r0] lsls r1, r1, #5 diff --git a/asm/banim-ekrtriangle.s b/asm/banim-ekrtriangle.s index a89f518e..5baa2eea 100644 --- a/asm/banim-ekrtriangle.s +++ b/asm/banim-ekrtriangle.s @@ -942,7 +942,7 @@ _08075638: movs r2, #0x80 lsls r2, r2, #5 adds r0, r4, #0 - bl RegisterTileGraphics + bl RegisterDataMove bl EnablePaletteSync ldr r1, [r5, #0x60] ldr r0, [r5, #0x5c] diff --git a/asm/bmlib-pal.s b/asm/bmlib-pal.s new file mode 100644 index 00000000..4e759897 --- /dev/null +++ b/asm/bmlib-pal.s @@ -0,0 +1,436 @@ + .INCLUDE "macro.inc" + + .SYNTAX UNIFIED + + THUMB_FUNC_START WriteFadedPaletteFromArchive +WriteFadedPaletteFromArchive: @ 0x08013550 + push {r4, r5, r6, r7, lr} + mov r7, sl + mov r6, r9 + mov r5, r8 + push {r5, r6, r7} + sub sp, #4 + adds r7, r0, #0 + mov r8, r1 + str r2, [sp] + mov sl, r3 + bl SetPalFadeStClkEnd1 + mov r0, r8 + bl SetPalFadeStClkEnd2 + ldr r0, [sp] + bl SetPalFadeStClkEnd3 + bl GetPalFadeSt + mov r9, r0 + movs r0, #0x80 + lsls r0, r0, #1 + cmp r7, r0 + ble _080135D4 + ldr r0, _080135CC @ 0xFFFFFF00 + adds r7, r7, r0 + movs r5, #0 + mov ip, r5 +_0801358A: + movs r0, #1 + lsls r0, r5 + mov r1, sl + ands r0, r1 + cmp r0, #0 + beq _080135C0 + movs r4, #0 + movs r6, #0x1f + mov r3, ip + add r3, r9 + lsls r0, r5, #5 + ldr r1, _080135D0 @ gPaletteBuffer + adds r2, r0, r1 +_080135A4: + ldrh r0, [r3] + adds r1, r6, #0 + ands r1, r0 + subs r0, r6, r1 + muls r0, r7, r0 + asrs r0, r0, #8 + adds r1, r1, r0 + ands r1, r6 + strh r1, [r2] + adds r3, #2 + adds r2, #2 + adds r4, #1 + cmp r4, #0xf + ble _080135A4 +_080135C0: + movs r0, #0x30 + add ip, r0 + adds r5, #1 + cmp r5, #0x1f + ble _0801358A + b _08013614 + .align 2, 0 +_080135CC: .4byte 0xFFFFFF00 +_080135D0: .4byte gPaletteBuffer +_080135D4: + movs r5, #0 + mov ip, r5 +_080135D8: + movs r0, #1 + lsls r0, r5 + mov r1, sl + ands r0, r1 + cmp r0, #0 + beq _0801360A + movs r4, #0 + movs r6, #0x1f + mov r3, ip + add r3, r9 + lsls r0, r5, #5 + ldr r1, _08013670 @ gPaletteBuffer + adds r2, r0, r1 +_080135F2: + ldrh r1, [r3] + adds r0, r6, #0 + ands r0, r1 + muls r0, r7, r0 + asrs r0, r0, #8 + ands r0, r6 + strh r0, [r2] + adds r3, #2 + adds r2, #2 + adds r4, #1 + cmp r4, #0xf + ble _080135F2 +_0801360A: + movs r0, #0x30 + add ip, r0 + adds r5, #1 + cmp r5, #0x1f + ble _080135D8 +_08013614: + movs r0, #0x80 + lsls r0, r0, #1 + cmp r8, r0 + ble _08013678 + ldr r1, _08013674 @ 0xFFFFFF00 + add r8, r1 + movs r5, #0 + mov ip, r5 +_08013624: + movs r0, #1 + lsls r0, r5 + mov r7, sl + ands r0, r7 + cmp r0, #0 + beq _08013664 + movs r4, #0 + movs r6, #0xf8 + lsls r6, r6, #2 + mov r3, ip + add r3, r9 + lsls r0, r5, #5 + ldr r1, _08013670 @ gPaletteBuffer + adds r2, r0, r1 +_08013640: + ldrh r1, [r3] + adds r0, r6, #0 + ands r0, r1 + subs r1, r6, r0 + mov r7, r8 + muls r7, r1, r7 + adds r1, r7, #0 + asrs r1, r1, #8 + adds r0, r0, r1 + ands r0, r6 + ldrh r1, [r2] + orrs r0, r1 + strh r0, [r2] + adds r3, #2 + adds r2, #2 + adds r4, #1 + cmp r4, #0xf + ble _08013640 +_08013664: + movs r0, #0x30 + add ip, r0 + adds r5, #1 + cmp r5, #0x1f + ble _08013624 + b _080136C0 + .align 2, 0 +_08013670: .4byte gPaletteBuffer +_08013674: .4byte 0xFFFFFF00 +_08013678: + movs r5, #0 + movs r7, #0 +_0801367C: + movs r0, #1 + lsls r0, r5 + mov r1, sl + ands r0, r1 + cmp r0, #0 + beq _080136B8 + movs r4, #0 + movs r6, #0xf8 + lsls r6, r6, #2 + mov r0, r9 + adds r3, r7, r0 + lsls r0, r5, #5 + ldr r1, _08013720 @ gPaletteBuffer + adds r2, r0, r1 +_08013698: + ldrh r1, [r3] + adds r0, r6, #0 + ands r0, r1 + mov r1, r8 + muls r1, r0, r1 + adds r0, r1, #0 + asrs r0, r0, #8 + ands r0, r6 + ldrh r1, [r2] + orrs r0, r1 + strh r0, [r2] + adds r3, #2 + adds r2, #2 + adds r4, #1 + cmp r4, #0xf + ble _08013698 +_080136B8: + adds r7, #0x30 + adds r5, #1 + cmp r5, #0x1f + ble _0801367C +_080136C0: + movs r0, #0x80 + lsls r0, r0, #1 + ldr r5, [sp] + cmp r5, r0 + ble _08013728 + ldr r7, _08013724 @ 0xFFFFFF00 + adds r5, r5, r7 + str r5, [sp] + movs r5, #0 +_080136D2: + movs r0, #1 + lsls r0, r5 + mov r1, sl + ands r0, r1 + adds r7, r5, #1 + cmp r0, #0 + beq _08013718 + movs r4, #0 + lsls r0, r5, #1 + adds r0, r0, r5 + lsls r0, r0, #4 + movs r6, #0xf8 + lsls r6, r6, #7 + mov r1, r9 + adds r3, r0, r1 + lsls r0, r5, #5 + ldr r5, _08013720 @ gPaletteBuffer + adds r2, r0, r5 +_080136F6: + ldrh r1, [r3] + adds r0, r6, #0 + ands r0, r1 + subs r1, r6, r0 + ldr r5, [sp] + muls r1, r5, r1 + asrs r1, r1, #8 + adds r0, r0, r1 + ands r0, r6 + ldrh r1, [r2] + orrs r0, r1 + strh r0, [r2] + adds r3, #2 + adds r2, #2 + adds r4, #1 + cmp r4, #0xf + ble _080136F6 +_08013718: + adds r5, r7, #0 + cmp r5, #0x1f + ble _080136D2 + b _08013772 + .align 2, 0 +_08013720: .4byte gPaletteBuffer +_08013724: .4byte 0xFFFFFF00 +_08013728: + movs r5, #0 +_0801372A: + movs r0, #1 + lsls r0, r5 + mov r7, sl + ands r0, r7 + adds r7, r5, #1 + cmp r0, #0 + beq _0801376C + movs r4, #0 + lsls r0, r5, #1 + adds r0, r0, r5 + lsls r0, r0, #4 + movs r6, #0xf8 + lsls r6, r6, #7 + mov r1, r9 + adds r3, r0, r1 + lsls r0, r5, #5 + ldr r5, _08013788 @ gPaletteBuffer + adds r2, r0, r5 +_0801374E: + ldrh r1, [r3] + adds r0, r6, #0 + ands r0, r1 + ldr r1, [sp] + muls r0, r1, r0 + asrs r0, r0, #8 + ands r0, r6 + ldrh r1, [r2] + orrs r0, r1 + strh r0, [r2] + adds r3, #2 + adds r2, #2 + adds r4, #1 + cmp r4, #0xf + ble _0801374E +_0801376C: + adds r5, r7, #0 + cmp r5, #0x1f + ble _0801372A +_08013772: + bl EnablePaletteSync + add sp, #4 + pop {r3, r4, r5} + mov r8, r3 + mov r9, r4 + mov sl, r5 + pop {r4, r5, r6, r7} + pop {r0} + bx r0 + .align 2, 0 +_08013788: .4byte gPaletteBuffer + + THUMB_FUNC_END WriteFadedPaletteFromArchive + + THUMB_FUNC_START sub_801378C +sub_801378C: @ 0x0801378C + movs r1, #0 + str r1, [r0, #0x44] + bx lr + + THUMB_FUNC_END sub_801378C + + THUMB_FUNC_START sub_8013794 +sub_8013794: @ 0x08013794 + push {r4, r5, r6, r7, lr} + adds r4, r0, #0 + ldr r1, [r4, #0x44] + ldr r0, [r4, #0x48] + adds r2, r1, r0 + str r2, [r4, #0x44] + movs r7, #0x80 + lsls r7, r7, #1 + subs r3, r7, r2 + ldr r0, [r4, #0x2c] + adds r1, r0, #0 + muls r1, r3, r1 + ldr r0, [r4, #0x38] + muls r0, r2, r0 + adds r0, r1, r0 + cmp r0, #0 + bge _080137B8 + adds r0, #0xff +_080137B8: + asrs r6, r0, #8 + ldr r0, [r4, #0x30] + adds r1, r0, #0 + muls r1, r3, r1 + ldr r0, [r4, #0x3c] + muls r0, r2, r0 + adds r1, r1, r0 + cmp r1, #0 + bge _080137CC + adds r1, #0xff +_080137CC: + asrs r5, r1, #8 + ldr r0, [r4, #0x34] + adds r1, r0, #0 + muls r1, r3, r1 + ldr r0, [r4, #0x40] + muls r0, r2, r0 + adds r1, r1, r0 + cmp r1, #0 + bge _080137E0 + adds r1, #0xff +_080137E0: + asrs r2, r1, #8 + ldr r3, [r4, #0x4c] + adds r0, r6, #0 + adds r1, r5, #0 + bl WriteFadedPaletteFromArchive + ldr r0, [r4, #0x44] + cmp r0, r7 + bne _080137F8 + adds r0, r4, #0 + bl Proc_Break +_080137F8: + pop {r4, r5, r6, r7} + pop {r0} + bx r0 + + THUMB_FUNC_END sub_8013794 + + THUMB_FUNC_START sub_8013800 +sub_8013800: @ 0x08013800 + push {r4, r5, r6, r7, lr} + mov r7, r9 + mov r6, r8 + push {r6, r7} + adds r5, r0, #0 + adds r6, r1, #0 + mov r8, r2 + mov r9, r3 + ldr r7, [sp, #0x1c] + ldr r4, [sp, #0x28] + ldr r1, [sp, #0x2c] + ldr r0, _08013840 @ gUnknown_08599FD4 + bl Proc_Start + str r5, [r0, #0x2c] + str r6, [r0, #0x30] + mov r1, r8 + str r1, [r0, #0x34] + mov r1, r9 + str r1, [r0, #0x38] + str r7, [r0, #0x3c] + ldr r1, [sp, #0x20] + str r1, [r0, #0x40] + str r4, [r0, #0x48] + ldr r1, [sp, #0x24] + str r1, [r0, #0x4c] + pop {r3, r4} + mov r8, r3 + mov r9, r4 + pop {r4, r5, r6, r7} + pop {r0} + bx r0 + .align 2, 0 +_08013840: .4byte gUnknown_08599FD4 + + THUMB_FUNC_END sub_8013800 + + THUMB_FUNC_START sub_8013844 +sub_8013844: @ 0x08013844 + push {lr} + ldr r0, _08013854 @ gUnknown_08599FD4 + bl Proc_Find + cmp r0, #0 + bne _08013858 + movs r0, #0 + b _0801385A + .align 2, 0 +_08013854: .4byte gUnknown_08599FD4 +_08013858: + movs r0, #1 +_0801385A: + pop {r1} + bx r1 + + THUMB_FUNC_END sub_8013844 + +.align 2, 0 diff --git a/asm/code_80B5730.s b/asm/code_80B5730.s index 52dbbdf4..7cdd22ad 100644 --- a/asm/code_80B5730.s +++ b/asm/code_80B5730.s @@ -516,7 +516,7 @@ sub_80B8E14: @ 0x080B8E14 adds r0, r4, #0 movs r2, #0xc movs r3, #4 - bl CopyTileGfxForObj + bl Copy2dChr pop {r4} pop {r0} bx r0 @@ -570,7 +570,7 @@ sub_80B8E60: @ 0x080B8E60 adds r0, r4, #0 movs r2, #8 movs r3, #2 - bl CopyTileGfxForObj + bl Copy2dChr bl sub_80B8E14 ldr r0, _080B8F94 @ gUnknown_08A97FA4 movs r1, #0xe0 @@ -14055,7 +14055,7 @@ sub_80BF048: @ 0x080BF048 adds r0, r4, #0 movs r2, #0xd movs r3, #2 - bl CopyTileGfxForObj + bl Copy2dChr ldr r0, _080BF128 @ gUnknown_08A99120 movs r1, #0xa0 movs r2, #0x20 @@ -18603,7 +18603,7 @@ sub_80C12AC: @ 0x080C12AC adds r0, r4, #0 movs r2, #6 movs r3, #4 - bl CopyTileGfxForObj + bl Copy2dChr _080C12E0: ldr r4, _080C1320 @ gUnknown_08A3EA00 adds r0, r4, #0 diff --git a/asm/code_80CCA64.s b/asm/code_80CCA64.s index facade4a..55f98b5f 100644 --- a/asm/code_80CCA64.s +++ b/asm/code_80CCA64.s @@ -19,7 +19,7 @@ sub_80CDDF0: @ 0x080CDDF0 bl Proc_End b _080CDE6A _080CDE10: - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 adds r1, r4, #0 @@ -78,7 +78,7 @@ sub_80CDE74: @ 0x080CDE74 adds r0, #0x4c movs r1, #0 ldrsh r4, [r0, r1] - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 cmp r4, r0 diff --git a/asm/code_mapanim.s b/asm/code_mapanim.s index 5814811d..2ddf41a0 100644 --- a/asm/code_mapanim.s +++ b/asm/code_mapanim.s @@ -39,12 +39,12 @@ sub_807F58C: @ 0x0807F58C movs r4, #0 _0807F59C: adds r1, r4, #6 - ldr r0, _0807F5C4 @ gUnknown_0859A120 + ldr r0, _0807F5C4 @ Pal_AllBlack movs r2, #0x3c adds r3, r5, #0 - bl NewEkrDragonPalFadeIn + bl StartPalFade movs r1, #0xf - bl sub_8013998 + bl SetPalFadeStop adds r4, #1 cmp r4, #9 ble _0807F59C @@ -54,7 +54,7 @@ _0807F59C: .align 2, 0 _0807F5BC: .4byte pPalette6Buffer _0807F5C0: .4byte gUnknown_03005110 -_0807F5C4: .4byte gUnknown_0859A120 +_0807F5C4: .4byte Pal_AllBlack THUMB_FUNC_END sub_807F58C @@ -92,7 +92,7 @@ _0807F5F4: adds r0, r5, #0 movs r2, #0xf adds r3, r6, #0 - bl NewEkrDragonPalFadeIn + bl StartPalFade adds r5, #0x20 adds r4, #1 cmp r4, #9 @@ -578,7 +578,7 @@ sub_807F964: @ 0x0807F964 movs r0, #0xa0 lsls r0, r0, #1 ldr r1, [r7, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial b _0807F9C8 _0807F990: cmp r1, #0x13 @@ -1655,7 +1655,7 @@ _08080154: ldr r0, _0808025C @ 0x0000013F mov r2, r9 ldr r1, [r2, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial _08080212: ldrh r0, [r7] lsls r0, r0, #2 @@ -2356,7 +2356,7 @@ sub_8080730: @ 0x08080730 bne _08080768 ldr r0, _080807C0 @ 0x00000141 ldr r1, [r4, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial _08080768: ldrh r0, [r5] adds r0, #1 @@ -3246,7 +3246,7 @@ sub_8080DCC: @ 0x08080DCC bne _08080DF4 ldr r0, _08080DF0 @ 0x000003BF ldr r1, [r4, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial b _08080E0E .align 2, 0 _08080DF0: .4byte 0x000003BF @@ -3437,7 +3437,7 @@ sub_8080F44: @ 0x08080F44 bne _08080F6C ldr r0, _08080F68 @ 0x000003BF ldr r1, [r4, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial b _08080F92 .align 2, 0 _08080F68: .4byte 0x000003BF @@ -3666,7 +3666,7 @@ sub_8081100: @ 0x08081100 bne _08081128 ldr r0, _08081124 @ 0x000003BF ldr r1, [r4, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial b _08081134 .align 2, 0 _08081124: .4byte 0x000003BF @@ -3993,7 +3993,7 @@ sub_8081348: @ 0x08081348 movs r3, #0xc ldrsh r2, [r2, r3] subs r1, r1, r2 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial pop {r0} bx r0 .align 2, 0 @@ -4024,7 +4024,7 @@ sub_8081384: @ 0x08081384 movs r3, #0xc ldrsh r2, [r2, r3] subs r1, r1, r2 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial pop {r0} bx r0 .align 2, 0 @@ -4508,7 +4508,7 @@ _080816F8: ldrsh r0, [r0, r2] subs r1, r1, r0 movs r0, #0xc8 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldr r0, [r4] bl MapAnim_BeginMISSAnim b _080818C4 @@ -4539,7 +4539,7 @@ _08081740: movs r3, #0xc ldrsh r2, [r2, r3] subs r1, r1, r2 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldr r0, [r4] bl MapAnim_BeginNODAMAGEAnim b _080818C4 @@ -4640,7 +4640,7 @@ _080817FA: ldrsh r0, [r2, r3] subs r1, r1, r0 adds r0, r6, #0 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial adds r6, r7, #0 adds r6, #8 adds r4, r4, r6 @@ -4670,7 +4670,7 @@ _080817FA: ldrsh r0, [r2, r3] subs r1, r1, r0 movs r0, #0xd8 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial adds r4, r4, r6 ldr r0, [r4] bl MU_StartFastMoveAnim @@ -4691,7 +4691,7 @@ _08081880: ldrsh r0, [r0, r2] subs r1, r1, r0 adds r0, r6, #0 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial adds r0, r7, #0 adds r0, #8 adds r4, r4, r0 diff --git a/asm/code_sio.s b/asm/code_sio.s index 05cae5d7..ef3aa1ef 100644 --- a/asm/code_sio.s +++ b/asm/code_sio.s @@ -17846,7 +17846,7 @@ sub_804A108: @ 0x0804A108 ldr r1, _0804A150 @ gActiveUnit str r0, [r1] bl sub_8049298 - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 adds r4, #0x64 @@ -17873,7 +17873,7 @@ sub_804A158: @ 0x0804A158 adds r0, #0x64 movs r1, #0 ldrsh r4, [r0, r1] - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 cmp r4, r0 @@ -17938,7 +17938,7 @@ sub_804A1D0: @ 0x0804A1D0 adds r1, #0x1e adds r1, r1, r0 ldrh r5, [r1] - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 adds r4, #0x64 @@ -18055,7 +18055,7 @@ sub_804A298: @ 0x0804A298 adds r0, #0x64 movs r2, #0 ldrsh r4, [r0, r2] - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 cmp r4, r0 @@ -21765,7 +21765,7 @@ sub_804BED8: @ 0x0804BED8 movs r1, #0x16 movs r2, #0x14 adds r3, r4, #0 - bl NewEkrDragonPalFadeIn + bl StartPalFade ldr r0, _0804BF2C @ gUnknown_085AA83C adds r1, r4, #0 bl Proc_Start @@ -21878,7 +21878,7 @@ sub_804BFAC: @ 0x0804BFAC movs r1, #0x16 movs r2, #8 adds r3, r5, #0 - bl NewEkrDragonPalFadeIn + bl StartPalFade pop {r4, r5} pop {r0} bx r0 @@ -21901,7 +21901,7 @@ sub_804BFF8: @ 0x0804BFF8 movs r1, #0x16 movs r2, #8 adds r3, r4, #0 - bl NewEkrDragonPalFadeIn + bl StartPalFade ldr r0, _0804C028 @ gProcScr_MU_89A2CF8 movs r1, #3 bl Proc_Start @@ -24446,7 +24446,7 @@ sub_804D2A4: @ 0x0804D2A4 adds r0, r4, #0 movs r2, #3 movs r3, #3 - bl CopyTileGfxForObj + bl Copy2dChr ldrb r0, [r5, #0xf] lsls r0, r0, #2 adds r6, r6, r0 diff --git a/asm/eventcmd_fade.s b/asm/eventcmd_fade.s index fee3269d..56aa99c6 100755 --- a/asm/eventcmd_fade.s +++ b/asm/eventcmd_fade.s @@ -86,7 +86,7 @@ _08012746: adds r1, r5, #0 adds r3, r7, #0 bl WriteFadedPaletteFromArchive - bl GetSomethingInPaletteBB_2A + bl GetPalFadeStClkEnd1 ldr r2, _080127B4 @ 0x000003FF adds r1, r2, #0 ands r0, r1 @@ -96,7 +96,7 @@ _08012746: ands r1, r2 orrs r1, r0 strh r1, [r4] - bl GetSomethingInPaletteBB_5A + bl GetPalFadeStClkEnd2 mov r1, r9 ands r0, r1 lsls r0, r0, #0xa @@ -105,7 +105,7 @@ _08012746: ands r1, r2 orrs r1, r0 str r1, [r4] - bl GetSomethingInPaletteBB_8A + bl GetPalFadeStClkEnd3 mov r2, r9 ands r0, r2 lsls r0, r0, #4 diff --git a/asm/evtscr.s b/asm/evtscr.s index 7cfdee97..5b7f1f75 100644 --- a/asm/evtscr.s +++ b/asm/evtscr.s @@ -7085,7 +7085,7 @@ sub_8010A28: @ 0x08010A28 adds r0, #0x64 movs r1, #0 ldrsh r4, [r0, r1] - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 cmp r4, r0 @@ -7184,7 +7184,7 @@ _08010AE4: bl Proc_StartBlocking adds r4, r0, #0 str r6, [r4, #0x58] - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 adds r4, #0x64 @@ -7236,7 +7236,7 @@ sub_8010B48: @ 0x08010B48 adds r0, #0x64 movs r1, #0 ldrsh r4, [r0, r1] - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 cmp r4, r0 @@ -7272,7 +7272,7 @@ Event40_: @ 0x08010B78 bl Proc_StartBlocking adds r4, r0, #0 str r6, [r4, #0x58] - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 adds r4, #0x64 diff --git a/asm/hino.s b/asm/hino.s index 93608f96..27a7615b 100644 --- a/asm/hino.s +++ b/asm/hino.s @@ -2,821 +2,6 @@ .SYNTAX UNIFIED - THUMB_FUNC_START WriteFadedPaletteFromArchive -WriteFadedPaletteFromArchive: @ 0x08013550 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, r9 - mov r5, r8 - push {r5, r6, r7} - sub sp, #4 - adds r7, r0, #0 - mov r8, r1 - str r2, [sp] - mov sl, r3 - bl SetSomethingInPaletteBB_2A - mov r0, r8 - bl SetSomethingInPaletteBB_5A - ldr r0, [sp] - bl SetSomethingInPaletteBB_8A - bl GetPaletteBufferBuffer - mov r9, r0 - movs r0, #0x80 - lsls r0, r0, #1 - cmp r7, r0 - ble _080135D4 - ldr r0, _080135CC @ 0xFFFFFF00 - adds r7, r7, r0 - movs r5, #0 - mov ip, r5 -_0801358A: - movs r0, #1 - lsls r0, r5 - mov r1, sl - ands r0, r1 - cmp r0, #0 - beq _080135C0 - movs r4, #0 - movs r6, #0x1f - mov r3, ip - add r3, r9 - lsls r0, r5, #5 - ldr r1, _080135D0 @ gPaletteBuffer - adds r2, r0, r1 -_080135A4: - ldrh r0, [r3] - adds r1, r6, #0 - ands r1, r0 - subs r0, r6, r1 - muls r0, r7, r0 - asrs r0, r0, #8 - adds r1, r1, r0 - ands r1, r6 - strh r1, [r2] - adds r3, #2 - adds r2, #2 - adds r4, #1 - cmp r4, #0xf - ble _080135A4 -_080135C0: - movs r0, #0x30 - add ip, r0 - adds r5, #1 - cmp r5, #0x1f - ble _0801358A - b _08013614 - .align 2, 0 -_080135CC: .4byte 0xFFFFFF00 -_080135D0: .4byte gPaletteBuffer -_080135D4: - movs r5, #0 - mov ip, r5 -_080135D8: - movs r0, #1 - lsls r0, r5 - mov r1, sl - ands r0, r1 - cmp r0, #0 - beq _0801360A - movs r4, #0 - movs r6, #0x1f - mov r3, ip - add r3, r9 - lsls r0, r5, #5 - ldr r1, _08013670 @ gPaletteBuffer - adds r2, r0, r1 -_080135F2: - ldrh r1, [r3] - adds r0, r6, #0 - ands r0, r1 - muls r0, r7, r0 - asrs r0, r0, #8 - ands r0, r6 - strh r0, [r2] - adds r3, #2 - adds r2, #2 - adds r4, #1 - cmp r4, #0xf - ble _080135F2 -_0801360A: - movs r0, #0x30 - add ip, r0 - adds r5, #1 - cmp r5, #0x1f - ble _080135D8 -_08013614: - movs r0, #0x80 - lsls r0, r0, #1 - cmp r8, r0 - ble _08013678 - ldr r1, _08013674 @ 0xFFFFFF00 - add r8, r1 - movs r5, #0 - mov ip, r5 -_08013624: - movs r0, #1 - lsls r0, r5 - mov r7, sl - ands r0, r7 - cmp r0, #0 - beq _08013664 - movs r4, #0 - movs r6, #0xf8 - lsls r6, r6, #2 - mov r3, ip - add r3, r9 - lsls r0, r5, #5 - ldr r1, _08013670 @ gPaletteBuffer - adds r2, r0, r1 -_08013640: - ldrh r1, [r3] - adds r0, r6, #0 - ands r0, r1 - subs r1, r6, r0 - mov r7, r8 - muls r7, r1, r7 - adds r1, r7, #0 - asrs r1, r1, #8 - adds r0, r0, r1 - ands r0, r6 - ldrh r1, [r2] - orrs r0, r1 - strh r0, [r2] - adds r3, #2 - adds r2, #2 - adds r4, #1 - cmp r4, #0xf - ble _08013640 -_08013664: - movs r0, #0x30 - add ip, r0 - adds r5, #1 - cmp r5, #0x1f - ble _08013624 - b _080136C0 - .align 2, 0 -_08013670: .4byte gPaletteBuffer -_08013674: .4byte 0xFFFFFF00 -_08013678: - movs r5, #0 - movs r7, #0 -_0801367C: - movs r0, #1 - lsls r0, r5 - mov r1, sl - ands r0, r1 - cmp r0, #0 - beq _080136B8 - movs r4, #0 - movs r6, #0xf8 - lsls r6, r6, #2 - mov r0, r9 - adds r3, r7, r0 - lsls r0, r5, #5 - ldr r1, _08013720 @ gPaletteBuffer - adds r2, r0, r1 -_08013698: - ldrh r1, [r3] - adds r0, r6, #0 - ands r0, r1 - mov r1, r8 - muls r1, r0, r1 - adds r0, r1, #0 - asrs r0, r0, #8 - ands r0, r6 - ldrh r1, [r2] - orrs r0, r1 - strh r0, [r2] - adds r3, #2 - adds r2, #2 - adds r4, #1 - cmp r4, #0xf - ble _08013698 -_080136B8: - adds r7, #0x30 - adds r5, #1 - cmp r5, #0x1f - ble _0801367C -_080136C0: - movs r0, #0x80 - lsls r0, r0, #1 - ldr r5, [sp] - cmp r5, r0 - ble _08013728 - ldr r7, _08013724 @ 0xFFFFFF00 - adds r5, r5, r7 - str r5, [sp] - movs r5, #0 -_080136D2: - movs r0, #1 - lsls r0, r5 - mov r1, sl - ands r0, r1 - adds r7, r5, #1 - cmp r0, #0 - beq _08013718 - movs r4, #0 - lsls r0, r5, #1 - adds r0, r0, r5 - lsls r0, r0, #4 - movs r6, #0xf8 - lsls r6, r6, #7 - mov r1, r9 - adds r3, r0, r1 - lsls r0, r5, #5 - ldr r5, _08013720 @ gPaletteBuffer - adds r2, r0, r5 -_080136F6: - ldrh r1, [r3] - adds r0, r6, #0 - ands r0, r1 - subs r1, r6, r0 - ldr r5, [sp] - muls r1, r5, r1 - asrs r1, r1, #8 - adds r0, r0, r1 - ands r0, r6 - ldrh r1, [r2] - orrs r0, r1 - strh r0, [r2] - adds r3, #2 - adds r2, #2 - adds r4, #1 - cmp r4, #0xf - ble _080136F6 -_08013718: - adds r5, r7, #0 - cmp r5, #0x1f - ble _080136D2 - b _08013772 - .align 2, 0 -_08013720: .4byte gPaletteBuffer -_08013724: .4byte 0xFFFFFF00 -_08013728: - movs r5, #0 -_0801372A: - movs r0, #1 - lsls r0, r5 - mov r7, sl - ands r0, r7 - adds r7, r5, #1 - cmp r0, #0 - beq _0801376C - movs r4, #0 - lsls r0, r5, #1 - adds r0, r0, r5 - lsls r0, r0, #4 - movs r6, #0xf8 - lsls r6, r6, #7 - mov r1, r9 - adds r3, r0, r1 - lsls r0, r5, #5 - ldr r5, _08013788 @ gPaletteBuffer - adds r2, r0, r5 -_0801374E: - ldrh r1, [r3] - adds r0, r6, #0 - ands r0, r1 - ldr r1, [sp] - muls r0, r1, r0 - asrs r0, r0, #8 - ands r0, r6 - ldrh r1, [r2] - orrs r0, r1 - strh r0, [r2] - adds r3, #2 - adds r2, #2 - adds r4, #1 - cmp r4, #0xf - ble _0801374E -_0801376C: - adds r5, r7, #0 - cmp r5, #0x1f - ble _0801372A -_08013772: - bl EnablePaletteSync - add sp, #4 - pop {r3, r4, r5} - mov r8, r3 - mov r9, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08013788: .4byte gPaletteBuffer - - THUMB_FUNC_END WriteFadedPaletteFromArchive - - THUMB_FUNC_START sub_801378C -sub_801378C: @ 0x0801378C - movs r1, #0 - str r1, [r0, #0x44] - bx lr - - THUMB_FUNC_END sub_801378C - - THUMB_FUNC_START sub_8013794 -sub_8013794: @ 0x08013794 - push {r4, r5, r6, r7, lr} - adds r4, r0, #0 - ldr r1, [r4, #0x44] - ldr r0, [r4, #0x48] - adds r2, r1, r0 - str r2, [r4, #0x44] - movs r7, #0x80 - lsls r7, r7, #1 - subs r3, r7, r2 - ldr r0, [r4, #0x2c] - adds r1, r0, #0 - muls r1, r3, r1 - ldr r0, [r4, #0x38] - muls r0, r2, r0 - adds r0, r1, r0 - cmp r0, #0 - bge _080137B8 - adds r0, #0xff -_080137B8: - asrs r6, r0, #8 - ldr r0, [r4, #0x30] - adds r1, r0, #0 - muls r1, r3, r1 - ldr r0, [r4, #0x3c] - muls r0, r2, r0 - adds r1, r1, r0 - cmp r1, #0 - bge _080137CC - adds r1, #0xff -_080137CC: - asrs r5, r1, #8 - ldr r0, [r4, #0x34] - adds r1, r0, #0 - muls r1, r3, r1 - ldr r0, [r4, #0x40] - muls r0, r2, r0 - adds r1, r1, r0 - cmp r1, #0 - bge _080137E0 - adds r1, #0xff -_080137E0: - asrs r2, r1, #8 - ldr r3, [r4, #0x4c] - adds r0, r6, #0 - adds r1, r5, #0 - bl WriteFadedPaletteFromArchive - ldr r0, [r4, #0x44] - cmp r0, r7 - bne _080137F8 - adds r0, r4, #0 - bl Proc_Break -_080137F8: - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - - THUMB_FUNC_END sub_8013794 - - THUMB_FUNC_START sub_8013800 -sub_8013800: @ 0x08013800 - push {r4, r5, r6, r7, lr} - mov r7, r9 - mov r6, r8 - push {r6, r7} - adds r5, r0, #0 - adds r6, r1, #0 - mov r8, r2 - mov r9, r3 - ldr r7, [sp, #0x1c] - ldr r4, [sp, #0x28] - ldr r1, [sp, #0x2c] - ldr r0, _08013840 @ gUnknown_08599FD4 - bl Proc_Start - str r5, [r0, #0x2c] - str r6, [r0, #0x30] - mov r1, r8 - str r1, [r0, #0x34] - mov r1, r9 - str r1, [r0, #0x38] - str r7, [r0, #0x3c] - ldr r1, [sp, #0x20] - str r1, [r0, #0x40] - str r4, [r0, #0x48] - ldr r1, [sp, #0x24] - str r1, [r0, #0x4c] - pop {r3, r4} - mov r8, r3 - mov r9, r4 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08013840: .4byte gUnknown_08599FD4 - - THUMB_FUNC_END sub_8013800 - - THUMB_FUNC_START sub_8013844 -sub_8013844: @ 0x08013844 - push {lr} - ldr r0, _08013854 @ gUnknown_08599FD4 - bl Proc_Find - cmp r0, #0 - bne _08013858 - movs r0, #0 - b _0801385A - .align 2, 0 -_08013854: .4byte gUnknown_08599FD4 -_08013858: - movs r0, #1 -_0801385A: - pop {r1} - bx r1 - - THUMB_FUNC_END sub_8013844 - - THUMB_FUNC_START sub_8013860 -sub_8013860: @ 0x08013860 - adds r2, r0, #0 - adds r2, #0x64 - movs r1, #0 - strh r1, [r2] - adds r0, #0x66 - movs r1, #0x5a - strh r1, [r0] - bx lr - - THUMB_FUNC_END sub_8013860 - - THUMB_FUNC_START sub_8013870 -sub_8013870: @ 0x08013870 - push {r4, r5, lr} - adds r3, r0, #0 - movs r4, #0 - ldr r5, _080138D4 @ gKeyStatusPtr - ldr r0, [r5] - ldrh r1, [r0, #8] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _0801388E - adds r1, r3, #0 - adds r1, #0x66 - ldrh r0, [r1] - adds r0, #1 - strh r0, [r1] -_0801388E: - adds r1, r3, #0 - adds r1, #0x64 - ldrh r2, [r1] - adds r0, r2, #1 - strh r0, [r1] - movs r0, #0xf - ands r0, r2 - cmp r0, #0 - bne _080138CE - ldr r0, [r5] - ldrh r1, [r0, #4] - movs r0, #0x20 - ands r0, r1 - cmp r0, #0 - beq _080138B6 - adds r0, r3, #0 - adds r0, #0x66 - movs r2, #0 - ldrsh r0, [r0, r2] - negs r4, r0 -_080138B6: - movs r0, #0x10 - ands r0, r1 - cmp r0, #0 - beq _080138C6 - adds r0, r3, #0 - adds r0, #0x66 - movs r1, #0 - ldrsh r4, [r0, r1] -_080138C6: - movs r0, #0x9a - adds r1, r4, #0 - bl PlaySpacialSoundMaybe -_080138CE: - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_080138D4: .4byte gKeyStatusPtr - - THUMB_FUNC_END sub_8013870 - - THUMB_FUNC_START sub_80138D8 -sub_80138D8: @ 0x080138D8 - push {lr} - ldr r0, _080138E8 @ gUnknown_08599FF4 - movs r1, #3 - bl Proc_Start - pop {r0} - bx r0 - .align 2, 0 -_080138E8: .4byte gUnknown_08599FF4 - - THUMB_FUNC_END sub_80138D8 - - THUMB_FUNC_START sub_80138EC -sub_80138EC: @ 0x080138EC - bx lr - - THUMB_FUNC_END sub_80138EC - - THUMB_FUNC_START sub_80138F0 -sub_80138F0: @ 0x080138F0 - push {r4, r5, lr} - adds r4, r0, #0 - adds r5, r1, #0 - adds r3, r2, #0 - ldr r0, _08013908 @ gUnknown_0859A120 - adds r1, r4, #0 - adds r2, r5, #0 - bl NewEkrDragonPalFadeIn - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_08013908: .4byte gUnknown_0859A120 - - THUMB_FUNC_END sub_80138F0 - - THUMB_FUNC_START sub_801390C -sub_801390C: @ 0x0801390C - push {r4, r5, lr} - adds r4, r0, #0 - adds r5, r1, #0 - adds r3, r2, #0 - ldr r0, _08013924 @ gUnknown_0859A140 - adds r1, r4, #0 - adds r2, r5, #0 - bl NewEkrDragonPalFadeIn - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_08013924: .4byte gUnknown_0859A140 - - THUMB_FUNC_END sub_801390C - - THUMB_FUNC_START NewEkrDragonPalFadeIn -NewEkrDragonPalFadeIn: @ 0x08013928 - push {r4, r5, r6, lr} - mov r6, r9 - mov r5, r8 - push {r5, r6} - mov r9, r0 - adds r5, r1, #0 - adds r6, r2, #0 - adds r1, r3, #0 - lsls r4, r5, #1 - adds r4, r4, r5 - lsls r4, r4, #4 - ldr r0, _0801397C @ gUnknown_0202B6B0 - adds r4, r4, r0 - ldr r0, _08013980 @ ProcScr_EkrDragonPalFadeIn - bl Proc_Start - mov r8, r0 - lsls r5, r5, #5 - ldr r0, _08013984 @ gPaletteBuffer - adds r5, r5, r0 - adds r0, r5, #0 - adds r1, r4, #0 - movs r2, #0x10 - bl CpuSet - str r5, [r4, #0x24] - mov r0, r9 - str r0, [r4, #0x20] - movs r0, #0 - strh r0, [r4, #0x28] - strh r6, [r4, #0x2a] - adds r6, #1 - strh r6, [r4, #0x2c] - mov r0, r8 - str r4, [r0, #0x2c] - adds r0, r4, #0 - pop {r3, r4} - mov r8, r3 - mov r9, r4 - pop {r4, r5, r6} - pop {r1} - bx r1 - .align 2, 0 -_0801397C: .4byte gUnknown_0202B6B0 -_08013980: .4byte ProcScr_EkrDragonPalFadeIn -_08013984: .4byte gPaletteBuffer - - THUMB_FUNC_END NewEkrDragonPalFadeIn - - THUMB_FUNC_START EndEkrDragonPalFadeInEffect -EndEkrDragonPalFadeInEffect: @ 0x08013988 - push {lr} - ldr r0, _08013994 @ ProcScr_EkrDragonPalFadeIn - bl Proc_EndEach - pop {r0} - bx r0 - .align 2, 0 -_08013994: .4byte ProcScr_EkrDragonPalFadeIn - - THUMB_FUNC_END EndEkrDragonPalFadeInEffect - - THUMB_FUNC_START sub_8013998 -sub_8013998: @ 0x08013998 - strh r1, [r0, #0x2c] - bx lr - - THUMB_FUNC_END sub_8013998 - - THUMB_FUNC_START EkrDragonPalFadeInMain -EkrDragonPalFadeInMain: @ 0x0801399C - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, r9 - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x10 - adds r7, r0, #0 - ldr r0, [r7, #0x2c] - mov sl, r0 - ldr r1, [r0, #0x20] - str r1, [sp, #8] - ldr r1, [r0, #0x24] - ldrh r0, [r0, #0x28] - mov r2, sl - ldrh r2, [r2, #0x2c] - cmp r0, r2 - beq _080139C6 - mov r3, sl - ldrh r3, [r3, #0x2a] - cmp r0, r3 - bls _080139CE -_080139C6: - adds r0, r7, #0 - bl Proc_End - b _08013A74 -_080139CE: - movs r0, #0 - str r0, [sp, #4] - str r1, [sp, #0xc] -_080139D4: - ldr r1, [sp, #4] - lsls r2, r1, #1 - mov r3, sl - adds r0, r2, r3 - ldrh r0, [r0] - movs r1, #0x1f - ands r1, r0 - movs r6, #0xf8 - lsls r6, r6, #2 - ands r6, r0 - movs r3, #0xf8 - lsls r3, r3, #7 - mov r9, r3 - ands r3, r0 - mov r9, r3 - ldr r0, [sp, #8] - adds r2, r2, r0 - ldrh r0, [r2] - movs r2, #0x1f - ands r2, r0 - movs r4, #0xf8 - lsls r4, r4, #2 - ands r4, r0 - movs r3, #0xf8 - lsls r3, r3, #7 - mov r8, r3 - ands r3, r0 - mov r8, r3 - ldr r0, [r7, #0x2c] - ldrh r3, [r0, #0x28] - ldrh r0, [r0, #0x2a] - str r0, [sp] - movs r0, #0 - bl Interpolate - adds r5, r0, #0 - ldr r0, [r7, #0x2c] - ldrh r3, [r0, #0x28] - ldrh r0, [r0, #0x2a] - str r0, [sp] - movs r0, #0 - adds r1, r6, #0 - adds r2, r4, #0 - bl Interpolate - adds r4, r0, #0 - ldr r0, [r7, #0x2c] - ldrh r3, [r0, #0x28] - ldrh r0, [r0, #0x2a] - str r0, [sp] - movs r0, #0 - mov r1, r9 - mov r2, r8 - bl Interpolate - movs r1, #0xf8 - lsls r1, r1, #7 - ands r0, r1 - movs r2, #0xf8 - lsls r2, r2, #2 - ands r4, r2 - orrs r0, r4 - movs r3, #0x1f - ands r5, r3 - orrs r0, r5 - ldr r1, [sp, #0xc] - strh r0, [r1] - adds r1, #2 - str r1, [sp, #0xc] - ldr r2, [sp, #4] - adds r2, #1 - str r2, [sp, #4] - cmp r2, #0xf - ble _080139D4 - bl EnablePaletteSync - ldr r1, [r7, #0x2c] - ldrh r0, [r1, #0x28] - adds r0, #1 - strh r0, [r1, #0x28] -_08013A74: - add sp, #0x10 - pop {r3, r4, r5} - mov r8, r3 - mov r9, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - - THUMB_FUNC_END EkrDragonPalFadeInMain - - THUMB_FUNC_START sub_8013A84 -sub_8013A84: @ 0x08013A84 - push {lr} - adds r1, r0, #0 - ldr r0, _08013A9C @ gUnknown_0859A120 - lsls r1, r1, #5 - ldr r2, _08013AA0 @ gPaletteBuffer - adds r1, r1, r2 - movs r2, #0x10 - bl CpuSet - pop {r0} - bx r0 - .align 2, 0 -_08013A9C: .4byte gUnknown_0859A120 -_08013AA0: .4byte gPaletteBuffer - - THUMB_FUNC_END sub_8013A84 - - THUMB_FUNC_START sub_8013AA4 -sub_8013AA4: @ 0x08013AA4 - push {lr} - adds r1, r0, #0 - ldr r0, _08013ABC @ gUnknown_0859A140 - lsls r1, r1, #5 - ldr r2, _08013AC0 @ gPaletteBuffer - adds r1, r1, r2 - movs r2, #0x10 - bl CpuSet - pop {r0} - bx r0 - .align 2, 0 -_08013ABC: .4byte gUnknown_0859A140 -_08013AC0: .4byte gPaletteBuffer - - THUMB_FUNC_END sub_8013AA4 - - THUMB_FUNC_START sub_8013AC4 -sub_8013AC4: @ 0x08013AC4 - push {r4, lr} - movs r4, #0 -_08013AC8: - adds r0, r4, #0 - bl sub_8013A84 - adds r4, #1 - cmp r4, #0x1f - ble _08013AC8 - pop {r4} - pop {r0} - bx r0 - - THUMB_FUNC_END sub_8013AC4 - - THUMB_FUNC_START sub_8013ADC -sub_8013ADC: @ 0x08013ADC - push {r4, lr} - movs r4, #0 -_08013AE0: - adds r0, r4, #0 - bl sub_8013A84 - adds r4, #1 - cmp r4, #0x1f - ble _08013AE0 - pop {r4} - pop {r0} - bx r0 - - THUMB_FUNC_END sub_8013ADC - THUMB_FUNC_START sub_8013AF4 sub_8013AF4: @ 0x08013AF4 push {r4, lr} @@ -2984,7 +2169,7 @@ sub_8014944: @ 0x08014944 ldr r0, _08014964 @ gUnknown_0859A1E0 bl Proc_StartBlocking adds r4, r0, #0 - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 adds r4, #0x64 @@ -3001,7 +2186,7 @@ _08014964: .4byte gUnknown_0859A1E0 sub_8014968: @ 0x08014968 push {r4, lr} adds r4, r0, #0 - bl GetThread2SkipStack + bl GetGameLock lsls r0, r0, #0x18 lsrs r0, r0, #0x18 adds r1, r4, #0 @@ -3260,8 +2445,8 @@ _08014B24: THUMB_FUNC_END RerangeSomething - THUMB_FUNC_START PlaySpacialSoundMaybe -PlaySpacialSoundMaybe: @ 0x08014B28 + THUMB_FUNC_START PlaySeSpacial +PlaySeSpacial: @ 0x08014B28 push {r4, r5, r6, lr} adds r4, r0, #0 adds r6, r1, #0 @@ -3305,7 +2490,7 @@ _08014B7C: .4byte gMPlayTable _08014B80: .4byte gSongTable _08014B84: .4byte 0x0000FFFF - THUMB_FUNC_END PlaySpacialSoundMaybe + THUMB_FUNC_END PlaySeSpacial THUMB_FUNC_START sub_8014B88 sub_8014B88: @ 0x08014B88 diff --git a/asm/mapanim_807CDD0.s b/asm/mapanim_807CDD0.s index 1b87c41c..3855e3e8 100644 --- a/asm/mapanim_807CDD0.s +++ b/asm/mapanim_807CDD0.s @@ -100,7 +100,7 @@ sub_807CE78: @ 0x0807CE78 bne _0807CEA0 ldr r0, _0807CE9C @ 0x000003CA ldr r1, [r4, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial b _0807CEB8 .align 2, 0 _0807CE9C: .4byte 0x000003CA @@ -572,7 +572,7 @@ _0807D23A: bl Proc_Break ldr r1, [r5, #0x30] movs r0, #0x8c - bl PlaySpacialSoundMaybe + bl PlaySeSpacial b _0807D2BA .align 2, 0 _0807D260: .4byte gUnknown_089AFFF8 @@ -615,7 +615,7 @@ _0807D296: bl sub_807D360 ldr r1, [r5, #0x30] movs r0, #0x89 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldrh r0, [r4] adds r0, #1 strh r0, [r4] @@ -1012,7 +1012,7 @@ sub_807D57C: @ 0x0807D57C movs r0, #0xe1 lsls r0, r0, #2 ldr r1, [r5, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial b _0807D5AE _0807D5A2: cmp r1, #0x21 @@ -1178,7 +1178,7 @@ sub_807D6D8: @ 0x0807D6D8 adds r5, r0, #0 ldr r1, [r5, #0x30] movs r0, #0xb6 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldr r2, _0807D758 @ gLCDControlBuffer ldrb r3, [r2, #0xc] movs r1, #4 @@ -1339,7 +1339,7 @@ sub_807D818: @ 0x0807D818 ldr r2, _0807D828 @ 0x0000010F ldr r1, [r0, #0x30] adds r0, r2, #0 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial pop {r0} bx r0 .align 2, 0 @@ -1469,7 +1469,7 @@ sub_807D860: @ 0x0807D860 lsls r1, r1, #1 adds r1, #1 lsls r1, r1, #3 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial add sp, #8 pop {r4, r5, r6} pop {r0} @@ -1841,7 +1841,7 @@ _0807DBFC: movs r2, #0x20 bl CopyToPaletteBuffer movs r0, #4 - bl sub_8013AA4 + bl SetWhitePal movs r0, #2 bl GetBackgroundTileDataOffset ldr r1, _0807DC90 @ 0x06002C00 @@ -2059,7 +2059,7 @@ sub_807DDC8: @ 0x0807DDC8 adds r5, r0, #0 ldr r1, [r5, #0x30] movs r0, #0x87 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial movs r0, #2 movs r1, #0 movs r2, #0 @@ -2138,7 +2138,7 @@ sub_807DE70: @ 0x0807DE70 push {lr} ldr r1, [r0, #0x30] movs r0, #0x86 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial pop {r0} bx r0 @@ -2374,7 +2374,7 @@ sub_807E038: @ 0x0807E038 push {lr} ldr r1, [r0, #0x30] movs r0, #0x82 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldr r0, _0807E050 @ gUnknown_0867B5A4 movs r1, #0x80 movs r2, #0x20 @@ -2495,7 +2495,7 @@ sub_807E118: @ 0x0807E118 adds r4, r0, #0 ldr r1, [r4, #0x30] movs r0, #0x85 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial movs r0, #2 movs r1, #0 movs r2, #0 @@ -2539,7 +2539,7 @@ sub_807E17C: @ 0x0807E17C adds r4, r0, #0 ldr r1, [r4, #0x30] movs r0, #0x85 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldr r0, _0807E1A8 @ gUnknown_089B1A10 ldr r1, [r4, #0x30] ldr r2, [r4, #0x34] @@ -2567,7 +2567,7 @@ sub_807E1B0: @ 0x0807E1B0 adds r4, r0, #0 ldr r1, [r4, #0x30] movs r0, #0x85 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldr r0, _0807E1DC @ gUnknown_089B1A10 ldr r1, [r4, #0x30] ldr r2, [r4, #0x34] @@ -2685,7 +2685,7 @@ sub_807E28C: @ 0x0807E28C bne _0807E2B4 ldr r0, _0807E2B0 @ 0x000003BA ldr r1, [r4, #0x30] - bl PlaySpacialSoundMaybe + bl PlaySeSpacial b _0807E2BE .align 2, 0 _0807E2B0: .4byte 0x000003BA @@ -2811,7 +2811,7 @@ sub_807E390: @ 0x0807E390 adds r4, r0, #0 ldr r1, [r4, #0x30] movs r0, #0xfd - bl PlaySpacialSoundMaybe + bl PlaySeSpacial bl sub_8081E78 bl sub_8081EAC ldr r0, _0807E3F0 @ sub_8081FA8 @@ -2972,7 +2972,7 @@ sub_807E4D0: @ 0x0807E4D0 adds r6, r0, #0 ldr r1, [r6, #0x30] movs r0, #0x83 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial movs r0, #2 movs r1, #0 movs r2, #0 @@ -3049,7 +3049,7 @@ sub_807E584: @ 0x0807E584 adds r4, r0, #0 ldr r1, [r4, #0x30] movs r0, #0x84 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldr r5, _0807E5E8 @ gBG2TilemapBuffer ldr r0, [r4, #0x30] cmp r0, #0 @@ -3178,7 +3178,7 @@ sub_807E67C: @ 0x0807E67C adds r5, r0, #0 ldr r1, [r5, #0x30] movs r0, #0x88 - bl PlaySpacialSoundMaybe + bl PlaySeSpacial movs r0, #2 movs r1, #0 movs r2, #0 @@ -3362,7 +3362,7 @@ sub_807E7E0: @ 0x0807E7E0 adds r5, r0, #0 ldr r1, [r5, #0x30] movs r0, #0x8d - bl PlaySpacialSoundMaybe + bl PlaySeSpacial movs r0, #2 movs r1, #0 movs r2, #0 diff --git a/asm/shinningstonefx.s b/asm/shinningstonefx.s index 4dba6172..53e19627 100755 --- a/asm/shinningstonefx.s +++ b/asm/shinningstonefx.s @@ -95,7 +95,7 @@ sub_8012A2C: @ 0x08012A2C adds r4, r0, #0 ldr r1, [r4, #0x30] movs r0, #0x8d - bl PlaySpacialSoundMaybe + bl PlaySeSpacial ldr r0, _08012A58 @ gUnknown_089B06AC ldr r1, _08012A5C @ 0x06013800 bl Decompress diff --git a/data/bmlib-const.s b/data/bmlib-const.s new file mode 100644 index 00000000..b5520574 --- /dev/null +++ b/data/bmlib-const.s @@ -0,0 +1,29 @@ + .section .rodata + + .global gUnknown_080D7964 +gUnknown_080D7964: @ 0x080D7964 +@ replacing .incbin "baserom.gba", 0x000d7964, 0x60 + .4byte Proc_Start + .4byte sub_80018E4 + .4byte 0x00000001 + .4byte Proc_Start + .4byte sub_8001860 + .4byte 0xffffffff + .4byte Proc_StartBlocking + .4byte sub_80018E4 + .4byte 0x00000001 + .4byte Proc_StartBlocking + .4byte sub_8001860 + .4byte 0xffffffff + .4byte Proc_Start + .4byte sub_80019E8 + .4byte 0xffffffff + .4byte Proc_Start + .4byte sub_8001964 + .4byte 0x00000001 + .4byte Proc_StartBlocking + .4byte sub_80019E8 + .4byte 0xffffffff + .4byte Proc_StartBlocking + .4byte sub_8001964 + .4byte 0x00000001 diff --git a/data/bmlib-pal.s b/data/bmlib-pal.s new file mode 100644 index 00000000..a96b422b --- /dev/null +++ b/data/bmlib-pal.s @@ -0,0 +1,21 @@ + .include "macro.inc" + + .section .data + + .global gUnknown_08599FD4 +gUnknown_08599FD4: @ 0x08599FD4 + .2byte 14 + .2byte 0 + .4byte NULL + + .2byte 2 + .2byte 0 + .4byte sub_801378C + + .2byte 3 + .2byte 0 + .4byte sub_8013794 + + .2byte 0 + .2byte 0 + .4byte NULL diff --git a/data/bmlib.s b/data/bmlib.s new file mode 100644 index 00000000..799676c3 --- /dev/null +++ b/data/bmlib.s @@ -0,0 +1,191 @@ + .include "macro.inc" + + .section .data + + .global gUnknown_0859A024 +gUnknown_0859A024: @ 0x0859A024 + .2byte 2 + .2byte 0 + .4byte sub_8013AF4 + + .2byte 14 + .2byte 0 + .4byte NULL + + .2byte 3 + .2byte 0 + .4byte sub_8013B5C + + .2byte 16 + .2byte 0 + .4byte NULL + + .global gUnknown_0859A044 +gUnknown_0859A044: @ 0x0859A044 + .2byte 2 + .2byte 0 + .4byte sub_8013BA0 + + .2byte 14 + .2byte 0 + .4byte NULL + + .2byte 3 + .2byte 0 + .4byte sub_8013C18 + + .2byte 16 + .2byte 0 + .4byte NULL + + .global gUnknown_0859A064 +gUnknown_0859A064: @ 0x0859A064 + .2byte 2 + .2byte 0 + .4byte sub_8013C58 + + .2byte 14 + .2byte 0 + .4byte NULL + + .2byte 3 + .2byte 0 + .4byte sub_8013B5C + + .2byte 16 + .2byte 0 + .4byte NULL + + .global gUnknown_0859A084 +gUnknown_0859A084: @ 0x0859A084 + .2byte 2 + .2byte 0 + .4byte sub_8013C70 + + .2byte 14 + .2byte 0 + .4byte NULL + + .2byte 3 + .2byte 0 + .4byte sub_8013C18 + + .2byte 16 + .2byte 0 + .4byte NULL + + .global gUnknown_0859A0A4 +gUnknown_0859A0A4: @ 0x0859A0A4 + .2byte 15 + .2byte 10 + .4byte NULL + + .2byte 2 + .2byte 0 + .4byte sub_80140F4 + + .2byte 14 + .2byte 0 + .4byte NULL + + .2byte 2 + .2byte 0 + .4byte sub_8014124 + + .2byte 3 + .2byte 0 + .4byte sub_8014100 + + .2byte 0 + .2byte 0 + .4byte NULL + + .global gUnknown_0859A0D4 +gUnknown_0859A0D4: @ 0x0859A0D4 + .2byte 14 + .2byte 0 + .4byte NULL + + .2byte 3 + .2byte 0 + .4byte Timer6C_Countdown + + .2byte 0 + .2byte 0 + .4byte NULL + + .global gUnknown_0859A0EC +gUnknown_0859A0EC: @ 0x0859A0EC + .incbin "baserom.gba", 0x59A0EC, 0x4 + + .global gUnknown_0859A0F0 +gUnknown_0859A0F0: @ 0x0859A0F0 + .incbin "baserom.gba", 0x59A0F0, 0x3 + + .global gUnknown_0859A0F3 +gUnknown_0859A0F3: @ 0x0859A0F3 + .incbin "baserom.gba", 0x59A0F3, 0x1 + + .global gUnknown_0859A0F4 +gUnknown_0859A0F4: @ 0x0859A0F4 + .incbin "baserom.gba", 0x59A0F4, 0x4 + + .global gUnknown_0859A0F8 +gUnknown_0859A0F8: @ 0x0859A0F8 + .2byte 3 + .2byte 0 + .4byte sub_80144FC + + .global gUnknown_0859A100 +gUnknown_0859A100: @ 0x0859A100 + .2byte 3 + .2byte 0 + .4byte FutureCall2_Loop + + .2byte 0 + .2byte 0 + .4byte NULL + + .global gUnknown_0859A110 +gUnknown_0859A110: @ 0x0859A110 + .2byte 3 + .2byte 0 + .4byte FutureCall_Loop + + .2byte 0 + .2byte 0 + .4byte NULL + + .global Pal_AllBlack +Pal_AllBlack: @ 0x0859A120 + .incbin "baserom.gba", 0x59A120, 0x20 + + .global Pal_AllWhite +Pal_AllWhite: @ 0x0859A140 + .incbin "baserom.gba", 0x59A140, 0x20 + + .global gUnknown_0859A160 +gUnknown_0859A160: @ 0x0859A160 + .incbin "baserom.gba", 0x59A160, 0x20 + + .global gUnknown_0859A180 +gUnknown_0859A180: @ 0x0859A180 + .incbin "baserom.gba", 0x59A180, 0x20 + + .global gUnknown_0859A1A0 +gUnknown_0859A1A0: @ 0x0859A1A0 + .incbin "baserom.gba", 0x59A1A0, 0x20 + + .global gUnknown_0859A1C0 +gUnknown_0859A1C0: @ 0x0859A1C0 + .incbin "baserom.gba", 0x59A1C0, 0x20 + + .global gUnknown_0859A1E0 +gUnknown_0859A1E0: @ 0x0859A1E0 + .2byte 3 + .2byte 0 + .4byte sub_8014968 + + .2byte 0 + .2byte 0 + .4byte NULL diff --git a/data/const_data_D792C.s b/data/const_data_D792C.s index 0e5063ed..c489d4f7 100644 --- a/data/const_data_D792C.s +++ b/data/const_data_D792C.s @@ -19,35 +19,3 @@ gUnknown_080D793F: @ 0x080D793F .global gUnknown_080D794E gUnknown_080D794E: @ 0x080D794E .incbin "baserom.gba", 0xD794E, 0x6 - - .global gUnknown_080D7954 -gUnknown_080D7954: @ 0x080D7954 - .incbin "baserom.gba", 0xD7954, 0x10 - - .global gUnknown_080D7964 -gUnknown_080D7964: @ 0x080D7964 -@ replacing .incbin "baserom.gba", 0x000d7964, 0x60 - .4byte Proc_Start - .4byte sub_80018E4 - .4byte 0x00000001 - .4byte Proc_Start - .4byte sub_8001860 - .4byte 0xffffffff - .4byte Proc_StartBlocking - .4byte sub_80018E4 - .4byte 0x00000001 - .4byte Proc_StartBlocking - .4byte sub_8001860 - .4byte 0xffffffff - .4byte Proc_Start - .4byte sub_80019E8 - .4byte 0xffffffff - .4byte Proc_Start - .4byte sub_8001964 - .4byte 0x00000001 - .4byte Proc_StartBlocking - .4byte sub_80019E8 - .4byte 0xffffffff - .4byte Proc_StartBlocking - .4byte sub_8001964 - .4byte 0x00000001 diff --git a/data/data_599714.s b/data/data_599714.s index 50944228..89559797 100644 --- a/data/data_599714.s +++ b/data/data_599714.s @@ -32,248 +32,3 @@ gUnknown_08599F74: @ 0x08599F74 @ 4th team [purple] ends up being unused as there is no way to have generics in the arena, which is the only place where the 4th team exists. .incbin "graphics/generic_icon/3.gbapal" - - .global gUnknown_08599FB4 -gUnknown_08599FB4: @ 0x08599FB4 - .word CopyDirect - .word CopyDirect - .word LZ77UnCompVram - .word LZ77UnCompWram - .word HuffUnComp - .word HuffUnComp - .word RLUnCompVram - .word RLUnCompWram - - .global gUnknown_08599FD4 -gUnknown_08599FD4: @ 0x08599FD4 - .2byte 14 - .2byte 0 - .4byte NULL - - .2byte 2 - .2byte 0 - .4byte sub_801378C - - .2byte 3 - .2byte 0 - .4byte sub_8013794 - - .2byte 0 - .2byte 0 - .4byte NULL - - .global gUnknown_08599FF4 -gUnknown_08599FF4: @ 0x08599FF4 - .2byte 2 - .2byte 0 - .4byte AddSkipThread2 - - .2byte 2 - .2byte 0 - .4byte sub_8013860 - - .2byte 3 - .2byte 0 - .4byte sub_8013870 - - .global ProcScr_EkrDragonPalFadeIn -ProcScr_EkrDragonPalFadeIn: @ 0x0859A00C - .2byte 15 - .2byte 10 - .4byte NULL - - .2byte 3 - .2byte 0 - .4byte EkrDragonPalFadeInMain - - .2byte 0 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A024 -gUnknown_0859A024: @ 0x0859A024 - .2byte 2 - .2byte 0 - .4byte sub_8013AF4 - - .2byte 14 - .2byte 0 - .4byte NULL - - .2byte 3 - .2byte 0 - .4byte sub_8013B5C - - .2byte 16 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A044 -gUnknown_0859A044: @ 0x0859A044 - .2byte 2 - .2byte 0 - .4byte sub_8013BA0 - - .2byte 14 - .2byte 0 - .4byte NULL - - .2byte 3 - .2byte 0 - .4byte sub_8013C18 - - .2byte 16 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A064 -gUnknown_0859A064: @ 0x0859A064 - .2byte 2 - .2byte 0 - .4byte sub_8013C58 - - .2byte 14 - .2byte 0 - .4byte NULL - - .2byte 3 - .2byte 0 - .4byte sub_8013B5C - - .2byte 16 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A084 -gUnknown_0859A084: @ 0x0859A084 - .2byte 2 - .2byte 0 - .4byte sub_8013C70 - - .2byte 14 - .2byte 0 - .4byte NULL - - .2byte 3 - .2byte 0 - .4byte sub_8013C18 - - .2byte 16 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A0A4 -gUnknown_0859A0A4: @ 0x0859A0A4 - .2byte 15 - .2byte 10 - .4byte NULL - - .2byte 2 - .2byte 0 - .4byte sub_80140F4 - - .2byte 14 - .2byte 0 - .4byte NULL - - .2byte 2 - .2byte 0 - .4byte sub_8014124 - - .2byte 3 - .2byte 0 - .4byte sub_8014100 - - .2byte 0 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A0D4 -gUnknown_0859A0D4: @ 0x0859A0D4 - .2byte 14 - .2byte 0 - .4byte NULL - - .2byte 3 - .2byte 0 - .4byte Timer6C_Countdown - - .2byte 0 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A0EC -gUnknown_0859A0EC: @ 0x0859A0EC - .incbin "baserom.gba", 0x59A0EC, 0x4 - - .global gUnknown_0859A0F0 -gUnknown_0859A0F0: @ 0x0859A0F0 - .incbin "baserom.gba", 0x59A0F0, 0x3 - - .global gUnknown_0859A0F3 -gUnknown_0859A0F3: @ 0x0859A0F3 - .incbin "baserom.gba", 0x59A0F3, 0x1 - - .global gUnknown_0859A0F4 -gUnknown_0859A0F4: @ 0x0859A0F4 - .incbin "baserom.gba", 0x59A0F4, 0x4 - - .global gUnknown_0859A0F8 -gUnknown_0859A0F8: @ 0x0859A0F8 - .2byte 3 - .2byte 0 - .4byte sub_80144FC - - .global gUnknown_0859A100 -gUnknown_0859A100: @ 0x0859A100 - .2byte 3 - .2byte 0 - .4byte FutureCall2_Loop - - .2byte 0 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A110 -gUnknown_0859A110: @ 0x0859A110 - .2byte 3 - .2byte 0 - .4byte FutureCall_Loop - - .2byte 0 - .2byte 0 - .4byte NULL - - .global gUnknown_0859A120 -gUnknown_0859A120: @ 0x0859A120 - .incbin "baserom.gba", 0x59A120, 0x20 - - .global gUnknown_0859A140 -gUnknown_0859A140: @ 0x0859A140 - .incbin "baserom.gba", 0x59A140, 0x20 - - .global gUnknown_0859A160 -gUnknown_0859A160: @ 0x0859A160 - .incbin "baserom.gba", 0x59A160, 0x20 - - .global gUnknown_0859A180 -gUnknown_0859A180: @ 0x0859A180 - .incbin "baserom.gba", 0x59A180, 0x20 - - .global gUnknown_0859A1A0 -gUnknown_0859A1A0: @ 0x0859A1A0 - .incbin "baserom.gba", 0x59A1A0, 0x20 - - .global gUnknown_0859A1C0 -gUnknown_0859A1C0: @ 0x0859A1C0 - .incbin "baserom.gba", 0x59A1C0, 0x20 - - .global gUnknown_0859A1E0 -gUnknown_0859A1E0: @ 0x0859A1E0 - .2byte 3 - .2byte 0 - .4byte sub_8014968 - - .2byte 0 - .2byte 0 - .4byte NULL diff --git a/data/data_5A92E0.s b/data/data_5A92E0.s index c74914d5..211b0246 100644 --- a/data/data_5A92E0.s +++ b/data/data_5A92E0.s @@ -1946,8 +1946,8 @@ gUnknown_085AA7EC: @ 0x085AA7EC .global gUnknown_085AA824 gUnknown_085AA824: @ 0x085AA824 @ replacing .incbin "baserom.gba", 0x005aa824, 0x18 -.4byte gUnknown_0859A140 -.4byte gUnknown_0859A120 +.4byte Pal_AllWhite +.4byte Pal_AllBlack .4byte gUnknown_0859A160 .4byte gUnknown_0859A180 .4byte gUnknown_0859A1A0 diff --git a/data/data_9A31F8.s b/data/data_9A31F8.s index 46e2ba96..3e627018 100644 --- a/data/data_9A31F8.s +++ b/data/data_9A31F8.s @@ -43,7 +43,7 @@ gUnknown_089A4064: @ 0x089A4064 gUnknown_089A407C: @ 0x089A407C @ PROC_CALL .short 0x2, 0x0 - .word AddSkipThread2 + .word LockGame @ PROC_SLEEP .short 0xe, 0x1 .word 0x0 @@ -55,7 +55,7 @@ gUnknown_089A407C: @ 0x089A407C .word sub_807F788 @ PROC_CALL .short 0x2, 0x0 - .word SubSkipThread2 + .word UnlockGame @ PROC_END .short 0x0, 0x0 .word 0x0 diff --git a/data/data_A167C8.s b/data/data_A167C8.s index 43eb1427..9da5cd19 100644 --- a/data/data_A167C8.s +++ b/data/data_A167C8.s @@ -110,7 +110,7 @@ gUnknown_08A177A0: @ 0x08A177A0 .word 0x0 @ PROC_CALL .short 0x2, 0x0 - .word AddSkipThread2 + .word LockGame @ PROC_CALL .short 0x2, 0x0 .word sub_8013D80 @@ -164,7 +164,7 @@ gUnknown_08A177A0: @ 0x08A177A0 .word WaitForFade @ PROC_CALL .short 0x2, 0x0 - .word SubSkipThread2 + .word UnlockGame @ PROC_GOTO .short 0xc, 0x4 .word 0x0 @@ -365,7 +365,7 @@ gUnknown_08A17A30: @ 0x08A17A30 .word 0x8205b74 @ PROC_CALL .short 0x2, 0x0 - .word AddSkipThread2 + .word LockGame @ PROC_CALL .short 0x2, 0x0 .word sub_8091180 @@ -395,7 +395,7 @@ gUnknown_08A17A30: @ 0x08A17A30 .word sub_8091C00 @ PROC_CALL .short 0x2, 0x0 - .word SubSkipThread2 + .word UnlockGame @ PROC_GOTO .short 0xc, 0x4 .word 0x0 diff --git a/data/data_A3CB04.s b/data/data_A3CB04.s index f64bcb9b..d4dba22d 100644 --- a/data/data_A3CB04.s +++ b/data/data_A3CB04.s @@ -1553,7 +1553,7 @@ gUnknown_08A3E8B8: @ 0x08A3E8B8 .word sub_80C0DF0 @ PROC_CALL .short 0x2, 0x0 - .word AddSkipThread2 + .word LockGame @ PROC_CALL .short 0x2, 0x0 .word BMapDispSuspend @@ -1589,7 +1589,7 @@ gUnknown_08A3E8B8: @ 0x08A3E8B8 .word BMapDispResume @ PROC_CALL .short 0x2, 0x0 - .word SubSkipThread2 + .word UnlockGame @ PROC_END .short 0x0, 0x0 .word 0x0 diff --git a/data/data_B12A60.s b/data/data_B12A60.s index b737e5e9..cb788f6d 100644 --- a/data/data_B12A60.s +++ b/data/data_B12A60.s @@ -205,7 +205,7 @@ ProcScr_E_Guide1: @ 0x08B12C64 .word 0x820717c @ PROC_CALL .short 0x2, 0x0 - .word AddSkipThread2 + .word LockGame @ PROC_CALL .short 0x2, 0x0 .word sub_8013D80 @@ -265,7 +265,7 @@ ProcScr_E_Guide1: @ 0x08B12C64 .word WaitForFade @ PROC_CALL .short 0x2, 0x0 - .word SubSkipThread2 + .word UnlockGame @ PROC_END .short 0x0, 0x0 .word 0x0 @@ -276,9 +276,9 @@ ProcScr_E_Guide2: @ 0x08B12D1C @ PROC_NAME(E_Guide) .short 0x1, 0x0 .word 0x0820717C - @ PROC_CALL(AddSkipThread2) + @ PROC_CALL(LockGame) .short 0x2, 0x0 - .word AddSkipThread2 + .word LockGame @ PROC_CALL(BMapDispSuspend) .short 0x2, 0x0 .word BMapDispSuspend @@ -324,9 +324,9 @@ ProcScr_E_Guide2: @ 0x08B12D1C @ PROC_CALL(RefreshBMapGraphics) .short 0x2, 0x0 .word RefreshBMapGraphics - @ PROC_CALL(SubSkipThread2) + @ PROC_CALL(UnlockGame) .short 0x2, 0x0 - .word SubSkipThread2 + .word UnlockGame @ PROC_END .short 0x0, 0x0 .word 0x0 diff --git a/data/data_prep_A1901C.s b/data/data_prep_A1901C.s index a000a301..caca18d3 100644 --- a/data/data_prep_A1901C.s +++ b/data/data_prep_A1901C.s @@ -105,7 +105,7 @@ ProcScr_PrepItemSupplyScreen: @ 0x08A1920C ProcScr_BmSupplyScreen: @ 0x08A192EC @ PROC_CALL .short 0x2, 0x0 - .word AddSkipThread2 + .word LockGame @ PROC_CALL .short 0x2, 0x0 .word sub_8013D80 @@ -216,7 +216,7 @@ ProcScr_BmSupplyScreen: @ 0x08A192EC .word 0x0 @ PROC_CALL .short 0x2, 0x0 - .word SubSkipThread2 + .word UnlockGame @ PROC_END .short 0x0, 0x0 .word 0x0 diff --git a/include/bm.h b/include/bm.h index 62919833..24b80cf8 100644 --- a/include/bm.h +++ b/include/bm.h @@ -4,9 +4,9 @@ void OnVBlank(void); void OnGameLoopMain(void); -void AddSkipThread2(void); -void SubSkipThread2(void); -u8 GetThread2SkipStack(void); +void LockGame(void); +void UnlockGame(void); +u8 GetGameLock(void); // ??? SwitchPhases(???); // ??? CallBeginningEvents(???); // ??? BmMain_ChangePhase(???); diff --git a/include/bmlib.h b/include/bmlib.h new file mode 100644 index 00000000..4a66fa6b --- /dev/null +++ b/include/bmlib.h @@ -0,0 +1,18 @@ +#pragma once + +#include "global.h" + +struct PalFadeSt +{ + /* 00 */ u16 from_colors[0x10]; + /* 20 */ u16 const * to_colors; + /* 24 */ u16 * pal; + /* 28 */ u16 clock; + /* 2A */ u16 clock_end; + /* 2C */ u16 clock_stop; +}; + +extern struct PalFadeSt EWRAM_DATA sPalFadeSt[0x20]; + +struct PalFadeSt *GetPalFadeSt(); +struct PalFadeSt *StartPalFade(u16 const *colors, int pal, int duration, ProcPtr parent); diff --git a/include/functions.h b/include/functions.h index 9c806c0a..d89a8075 100644 --- a/include/functions.h +++ b/include/functions.h @@ -374,20 +374,20 @@ int Interpolate(int method, int lo, int hi, int x, int end); void sub_8012E94(void); bool StringCompare(const char *str1, const char *str2); void CopyString(char *, const char *); -void CopyDirect(u8 *src, u8 *dst); -void sub_8012F20(u8 *src, u8 *dst); +void UnpackRaw(const void *src, void *dst); +void DecompressViaGenericBuf(const void *src, void *dst); void Decompress(const void* src, void* dst); -int FilterR0ForRawCopy(const void* data); +int GetDataSize(const void* data); // ??? sub_8012F98(???); // ??? sub_8012FB0(???); // ??? sub_8012FE0(???); -void RegisterObjectTileGraphics(const void* source, void* target, int width, int height); -void CopyTileGfxForObj(const void* src, void* dst, int tileWidth, int tileHeight); -void sub_8013058(const void* src, void* dst, int width, int height); -void sub_8013094(const void *src, void *dst, int width); -void sub_80130BC(const void *src, void *dst, int width); -void sub_8013104(u16*, int, int, int); -void sub_8013138(u16 *dst, u8* src, int a3, int a4); +void Register2dChrMove(const void* source, void* target, int width, int height); +void Copy2dChr(const void* src, void* dst, int tileWidth, int tileHeight); +void ApplyBitmap(const void* src, void* dst, int width, int height); +void ApplyBitmapLine(const void *src, void *dst, int width); +void ApplyBitmapTile(const u8 *src, u32 *dst, int width); +void PutAppliedBitmap(u16*, int, int, int); +void PutDigits(u16 *tm, const u8 *src, int tileref, int len); void sub_8013168(u16 *dst, u8* src, int a3, int a4, int a5); // ??? sub_80131A8(???); // ??? sub_80131B0(???); @@ -395,17 +395,16 @@ void sub_8013168(u16 *dst, u8* src, int a3, int a4, int a5); // ??? sub_80131D0(???); // ??? sub_80131F0(???); // ??? sub_8013278(???); -// ??? sub_80133A0(???); +// ??? DarkenPals(???); // ??? sub_8013428(???); // ??? sub_801342C(???); -struct Struct202B6B0 *GetPaletteBufferBuffer(); -void sub_8013454(int _2a, int _5a, int _8a); -void SetSomethingInPaletteBB_2A(int a); -void SetSomethingInPaletteBB_5A(int a); -void SetSomethingInPaletteBB_8A(int a); -int GetSomethingInPaletteBB_2A(); -int GetSomethingInPaletteBB_5A(); -int GetSomethingInPaletteBB_8A(); +void SetPalFadeStClkEnd(int _2a, int _5a, int _8a); +void SetPalFadeStClkEnd1(int a); +void SetPalFadeStClkEnd2(int a); +void SetPalFadeStClkEnd3(int a); +int GetPalFadeStClkEnd1(); +int GetPalFadeStClkEnd2(); +int GetPalFadeStClkEnd3(); void ArchiveCurrentPalettes(); void ArchivePalette(int index); void WriteFadedPaletteFromArchive(int a1, int a2, int a3, int a4); @@ -413,20 +412,20 @@ void WriteFadedPaletteFromArchive(int a1, int a2, int a3, int a4); // ??? sub_8013794(???); // ??? sub_8013800(???); // ??? sub_8013844(???); -// ??? sub_8013860(???); -// ??? sub_8013870(???); -// ??? sub_80138D8(???); +// ??? SpacialSeTest_OnInit(???); +// ??? SpacialSeTest_OnLoop(???); +// ??? StartSpacialSeTest(???); // ??? sub_80138EC(???); -void sub_80138F0(int palid, int duration, ProcPtr parent); // StartPalFadeToBlack -// ??? sub_801390C(???); -void NewEkrDragonPalFadeIn(const u16*, int, int, ProcPtr proc); -// ??? EndEkrDragonPalFadeInEffect(???); -// ??? sub_8013998(???); -// ??? EkrDragonPalFadeInMain(???); -void sub_8013A84(int); // SetBlackPal -// ??? sub_8013AA4(???); -// ??? sub_8013AC4(???); -// ??? sub_8013ADC(???); +void StartPalFadeToBlack(int palid, int duration, ProcPtr parent); // StartPalFadeToBlack +// ??? StartPalFadeToWhite(???); +// void StartPalFade(const u16*, int, int, ProcPtr proc); +// ??? EndPalFade(???); +// ??? SetPalFadeStop(???); +// ??? PalFade_OnLoop(???); +void SetBlackPal(int); // SetBlackPal +// ??? SetWhitePal(???); +// ??? SetAllBlackPals(???); +// ??? SetAllWhitePals(???); // ??? sub_8013AF4(???); // ??? sub_8013B5C(???); // ??? sub_8013BA0(???); @@ -523,7 +522,7 @@ void PutTmLinear(u16 *src, u16 *dst, int size, u16 tileref); // ??? GetTmOffsetById(???); // ??? sub_8014A78(???); // ??? RerangeSomething(???); -void PlaySpacialSoundMaybe(unsigned, int); +void PlaySeSpacial(unsigned, int); void sub_8014B88(int, int); // ??? sub_8014BA0(???); void sub_8014BC0(ProcPtr, int); @@ -3632,27 +3631,6 @@ void m4aSongNumStart(u16); // ??? ply_xiecl(???); // ??? ply_xleng(???); // ??? ply_xswee(???); -// ??? DummyFunc(???); -// ??? ArcTan2(???); -// ??? BgAffineSet(???); -// ??? CpuFastSet(???); -// ??? CpuSet(???); -int Div(int, int); -int DivArm(int, int); -int DivRem(int, int); -// ??? HuffUnComp(???); -// ??? LZ77UnCompVram(???); -// ??? LZ77UnCompWram(???); -// ??? MultiBoot(???); -// ??? ObjAffineSet(???); -// ??? RLUnCompVram(???); -// ??? RLUnCompWram(???); -void SoftReset(); -void SoundBiasReset(); -void SoundBiasSet(); -// ??? Sqrt(???); -// ??? VBlankIntrWait(???); -// ??? __ashldi3(???); void ClearOAMBuffer(); void TileMap_FillRect(u16 *dest, int width, int height, int fillValue); diff --git a/include/gba/syscall.h b/include/gba/syscall.h index deddec5b..d3c4c570 100644 --- a/include/gba/syscall.h +++ b/include/gba/syscall.h @@ -12,13 +12,11 @@ #define RESET_ALL 0xFF void SoftReset(u32 resetFlags); - +void SoundBiasReset(void); +void SoundBiasSet(void); void RegisterRamReset(u32 resetFlags); - void VBlankIntrWait(void); - u16 Sqrt(u32 num); - u16 ArcTan2(s16 x, s16 y); #define CPU_SET_SRC_FIXED 0x01000000 @@ -30,19 +28,16 @@ void CpuSet(const void *src, void *dest, u32 control); #define CPU_FAST_SET_SRC_FIXED 0x01000000 void CpuFastSet(const void *src, void *dest, u32 control); - void BgAffineSet(struct BgAffineSrcData *src, struct BgAffineDstData *dest, s32 count); - void ObjAffineSet(struct ObjAffineSrcData *src, void *dest, s32 count, s32 offset); - void LZ77UnCompWram(const void *src, void *dest); - +int Div(int, int); +int DivArm(int, int); +int DivRem(int, int); +void HuffUnComp(void const * src, void * dst); void LZ77UnCompVram(const void *src, void *dest); - void RLUnCompWram(const void *src, void *dest); - void RLUnCompVram(const void *src, void *dest); - int MultiBoot(struct MultiBootParam *mp); #endif // GUARD_GBA_SYSCALL_H diff --git a/include/hardware.h b/include/hardware.h index 4d3694d4..70761b64 100644 --- a/include/hardware.h +++ b/include/hardware.h @@ -193,7 +193,7 @@ void BG_EnableSyncByMask(int bg); void BG_EnableSync(int bg); // ??? sub_8001FD0(???); // ??? ClearTileRigistry(???); -void RegisterTileGraphics(const void *a, void *b, int c); +void RegisterDataMove(const void *a, void *b, int c); void RegisterFillTile(const void *a, void *b, int c); void FlushTiles(void); void SetupOAMBufferSplice(int a); diff --git a/include/variables.h b/include/variables.h index c9f0bb25..dd0c5c83 100644 --- a/include/variables.h +++ b/include/variables.h @@ -255,7 +255,6 @@ extern struct TextBuffer0202A6AC gUnknown_0202A6AC; extern u8 gUnknown_0202B4AC[]; // extern ??? gUnknown_0202B5AC extern int gUnknown_0202B6AC; -extern struct Struct202B6B0 gUnknown_0202B6B0; extern struct BmSt gBmSt; extern struct PlaySt gPlaySt; // extern ??? gUnknown_0202BD30 @@ -986,10 +985,9 @@ extern const char *gUnknown_08591AA4[][2]; // extern ??? gUnknown_08592628 // extern ??? gUnknown_085926F4 // extern ??? gUnknown_085996F4 -// extern ??? gUnknown_08599FB4 // extern ??? gUnknown_08599FD4 -// extern ??? gUnknown_08599FF4 -// extern ??? ProcScr_EkrDragonPalFadeIn +// extern ??? ProcScr_SpacialSeTest +// extern ??? ProcScr_PalFade // extern ??? gUnknown_0859A024 // extern ??? gUnknown_0859A044 // extern ??? gUnknown_0859A064 @@ -1003,8 +1001,8 @@ extern const char *gUnknown_08591AA4[][2]; // extern ??? gUnknown_0859A0F8 // extern ??? gUnknown_0859A100 // extern ??? gUnknown_0859A110 -extern const u16 gUnknown_0859A120[]; -extern const u16 gUnknown_0859A140[]; +extern const u16 Pal_AllBlack[]; +extern const u16 Pal_AllWhite[]; extern const u16 gUnknown_0859A160[]; extern const u16 gUnknown_0859A180[]; extern const u16 gUnknown_0859A1A0[]; diff --git a/ldscript.txt b/ldscript.txt index 636b4af2..c59cbfa3 100644 --- a/ldscript.txt +++ b/ldscript.txt @@ -62,6 +62,8 @@ SECTIONS src/eventcmd_42.o(.text); asm/eventcmd_44.o(.text); src/bmlib.o(.text); + asm/bmlib-pal.o(.text); + src/bmlib-fade.o(.text); asm/hino.o(.text); src/bm.o(.text); src/bmitem.o(.text); @@ -308,6 +310,8 @@ SECTIONS . = ALIGN(4); src/gamecontrol.o(.rodata); . = ALIGN(4); src/messdecode.o(.rodata); . = ALIGN(4); data/const_data_D792C.o(.rodata); + . = ALIGN(4); src/bmlib.o(.rodata); + . = ALIGN(4); data/bmlib-const.o(.rodata); . = ALIGN(4); src/bm.o(.rodata); . = ALIGN(4); src/bmitem.o(.rodata); . = ALIGN(4); src/bmunit.o(.rodata); @@ -419,6 +423,10 @@ SECTIONS . = ALIGN(4); data/data_5924D8.o(.data); . = ALIGN(4); data/data_item_icon.o(.data); . = ALIGN(4); data/data_599714.o(.data); + . = ALIGN(4); src/bmlib.o(.data); + . = ALIGN(4); data/bmlib-pal.o(.data); + . = ALIGN(4); src/bmlib-fade.o(.data); + . = ALIGN(4); data/bmlib.o(.data); . = ALIGN(4); src/bm.o(.data); . = ALIGN(4); src/bmunit.o(.data); . = ALIGN(4); src/bmmap.o(.data); diff --git a/src/ap.c b/src/ap.c index b0045d06..17885980 100644 --- a/src/ap.c +++ b/src/ap.c @@ -238,7 +238,7 @@ void AP_QueueObjGraphics(struct APHandle* handle) { #define OBJ_SIZE_TABLE_INDEX(aIt) ((((aIt[0] & 0xC000)>>12)+((aIt[1] & 0xC000)>>14))*2) while ((i--) > 0) { - RegisterObjectTileGraphics( + Register2dChrMove( handle->pGraphics + (*itGfxData & 0x3FF) * 0x20, // source location OBJ_VRAM0 + ((handle->tileBase & 0x3FF) * 0x20) + tileOffset, // target location sOamTileSizeLut[OBJ_SIZE_TABLE_INDEX(itObjData)+0], // x size (tiles) diff --git a/src/banim-ekrbattle.c b/src/banim-ekrbattle.c index f03d8e59..6b42f6ea 100644 --- a/src/banim-ekrbattle.c +++ b/src/banim-ekrbattle.c @@ -28,7 +28,7 @@ void NewEkrBattleDeamon(void) { gpProcEkrBattleDeamon = Proc_Start(gProc_ekrBattleDeamon, PROC_TREE_3); gBattleDeamonActive = true; - AddSkipThread2(); + LockGame(); } void EndEkrBattleDeamon(void) @@ -47,7 +47,7 @@ int IsBattleDeamonActive(void) void ekrBattleDeamon_Destructor(void) { gBattleDeamonActive = false; - SubSkipThread2(); + UnlockGame(); } void nullsub_35(void) @@ -116,7 +116,7 @@ void MainUpdateEkrBattle(void) ClearSprites(); sub_8071A8C(); - if (GetThread2SkipStack() == 0) + if (GetGameLock() == 0) Proc_Run(gProcTreeRootArray[2]); Proc_Run(gProcTreeRootArray[3]); @@ -574,7 +574,7 @@ void ekrBattleExecExpGain(struct ProcEkrBattle *proc) gLCDControlBuffer.wincnt.win0_enableBlend = 0; gLCDControlBuffer.wincnt.wout_enableBlend = 0; - RegisterTileGraphics(gUnknown_08802D44, (void *)0x6002000, 0x300); + RegisterDataMove(gUnknown_08802D44, (void *)0x6002000, 0x300); sub_8070E94(gUnknown_08803524, TILEMAP_LOCATED(gBG1TilemapBuffer, 6, 17), 18, 3, 1, 0x100); CpuFastSet(gUnknown_08803590, &gPaletteBuffer[0x10], 8); BG_EnableSyncByMask(2); @@ -619,7 +619,7 @@ void ekrBattleExecExpGain(struct ProcEkrBattle *proc) CpuFastSet(&gUnknown_088033C4[val2 * 0x10], &buf0[0xD0], 8); CpuFastSet(&gUnknown_088033C4[val3 * 0x10], &buf0[0xE0], 8); - RegisterTileGraphics(buf0, (void *)0x60021A0, 0x1E0); + RegisterDataMove(buf0, (void *)0x60021A0, 0x1E0); proc->timer = 0; proc->proc_idleCb = (ProcFunc)ekrBattle_80508F0; @@ -675,7 +675,7 @@ void ekrBattleWaitExpBarIdle(struct ProcEkrBattle *proc) CpuFastSet(&gUnknown_088033C4[val2 * 0x10], &buf0[0xD0], 8); CpuFastSet(&gUnknown_088033C4[val3 * 0x10], &buf0[0xE0], 8); - RegisterTileGraphics(buf0, (void *)0x60021A0, 0x1E0); + RegisterDataMove(buf0, (void *)0x60021A0, 0x1E0); if (++proc->timer > proc->end) { proc->timer = 0; diff --git a/src/banim-ekrbattlestarting.c b/src/banim-ekrbattlestarting.c index b65dea18..58b28811 100644 --- a/src/banim-ekrbattlestarting.c +++ b/src/banim-ekrbattlestarting.c @@ -79,7 +79,7 @@ void MainUpdate_8055C68(void) Proc_Run(gProcTreeRootArray[1]); - if (GetThread2SkipStack() == 0) + if (GetGameLock() == 0) Proc_Run(gProcTreeRootArray[2]); Proc_Run(gProcTreeRootArray[3]); diff --git a/src/banim-ekrdragon-demonking.c b/src/banim-ekrdragon-demonking.c index ccf2bf81..8c1aa540 100644 --- a/src/banim-ekrdragon-demonking.c +++ b/src/banim-ekrdragon-demonking.c @@ -4,6 +4,7 @@ #include "constants/items.h" #include "hardware.h" #include "uiutils.h" +#include "bmlib.h" #include "bmmap.h" #include "anime.h" #include "ekrbattle.h" @@ -119,10 +120,10 @@ void PrepareDemonKingBGFx(struct ProcEkrDragon *proc) gLCDControlBuffer.bg3cnt.priority = 2; gLCDControlBuffer.bg2cnt.priority = 3; - sub_8013A84(0x6); + SetBlackPal(0x6); /* Setup palette fade in process */ - NewEkrDragonPalFadeIn(Pal_DemonKingBG, 6, 0x78, proc); + StartPalFade(Pal_DemonKingBG, 6, 0x78, proc); SetEkrDragonStatusUnk1(1); proc->tcounter = 0; diff --git a/src/banim-ekrgauge.c b/src/banim-ekrgauge.c index cdcafa01..8b385749 100644 --- a/src/banim-ekrgauge.c +++ b/src/banim-ekrgauge.c @@ -115,10 +115,10 @@ void NewEkrGauge(void) } /* left side of hit & dmg & crit */ - RegisterTileGraphics(gObjBuf_EkrSideHitDmgCrit, (void *)0x6013A00, 0xC0 * sizeof(u16)); + RegisterDataMove(gObjBuf_EkrSideHitDmgCrit, (void *)0x6013A00, 0xC0 * sizeof(u16)); /* right side of hit & dmg & crit */ - RegisterTileGraphics(gObjBuf_EkrSideHitDmgCrit + 0xC0, (void *)0x6013E00, 0xC0 * sizeof(u16)); + RegisterDataMove(gObjBuf_EkrSideHitDmgCrit + 0xC0, (void *)0x6013E00, 0xC0 * sizeof(u16)); ResetIconGraphics_(); LoadIconPalette(0, 0x1D); diff --git a/src/banim-ekrlvup.c b/src/banim-ekrlvup.c index d5a9edeb..e4883b7e 100644 --- a/src/banim-ekrlvup.c +++ b/src/banim-ekrlvup.c @@ -340,10 +340,10 @@ void EkrLvup_InitScreen(struct ProcEkrLevelup *proc) CpuFastFill(0, gBG1TilemapBuffer, 0x800); CpuFastFill(0, gBG2TilemapBuffer, 0x800); - RegisterTileGraphics(gBG1TilemapBuffer, BG_SCREEN_ADDR(0xD), 0x800); - RegisterTileGraphics(gBG1TilemapBuffer, BG_SCREEN_ADDR(0xE), 0x800); - RegisterTileGraphics(gBG2TilemapBuffer, BG_SCREEN_ADDR(0xA), 0x800); - RegisterTileGraphics(gBG2TilemapBuffer, BG_SCREEN_ADDR(0xB), 0x800); + RegisterDataMove(gBG1TilemapBuffer, BG_SCREEN_ADDR(0xD), 0x800); + RegisterDataMove(gBG1TilemapBuffer, BG_SCREEN_ADDR(0xE), 0x800); + RegisterDataMove(gBG2TilemapBuffer, BG_SCREEN_ADDR(0xA), 0x800); + RegisterDataMove(gBG2TilemapBuffer, BG_SCREEN_ADDR(0xB), 0x800); buf->unk00 = gBanimTerrainIndexMaybe[EKR_BATTLE_LEFT]; buf->unk02 = 3; @@ -451,11 +451,11 @@ void EkrLvup_InitLevelUpBox(struct ProcEkrLevelup *proc) LZ77UnCompWram(Img_LevelUpBoxFrame, gEkrImgBuffer); LZ77UnCompWram(Tsa_LevelUpBoxFrame, gEkrTsaBuffer); sub_8070E94(gEkrTsaBuffer, TILEMAP_LOCATED(gBG1TilemapBuffer, 0, 0x6), 0x20, 0x14, 1, 0x100); - RegisterTileGraphics(gEkrImgBuffer, (void *)BG_VRAM + 0x2000, 0x8C0); + RegisterDataMove(gEkrImgBuffer, (void *)BG_VRAM + 0x2000, 0x8C0); CpuFastCopy(Pal_LevelUpBoxFrame, PAL_BG(1), 0x20); LZ77UnCompWram(gUnknown_085BB0C8, gUnknown_0201A790); - RegisterTileGraphics(gUnknown_0201A790, OBJ_VRAM0 + 0x1400, 0xC00); + RegisterDataMove(gUnknown_0201A790, OBJ_VRAM0 + 0x1400, 0xC00); CpuFastCopy(gUnknown_085BB2DC, PAL_OBJ(1), 0x20); EnablePaletteSync(); diff --git a/src/banim-ekrmain.c b/src/banim-ekrmain.c index 527143e1..f236c05a 100644 --- a/src/banim-ekrmain.c +++ b/src/banim-ekrmain.c @@ -52,5 +52,5 @@ void RegisterAISSheetGraphics(struct Anim *anim) void *mmap; mmap = (void *)0x06010000 + (anim->oam2Base & 0x3FF) * 0x20; LZ77UnCompWram(anim->pImgSheet, anim->pUnk2C); - RegisterTileGraphics(anim->pUnk2C, mmap, 0x2000); + RegisterDataMove(anim->pUnk2C, mmap, 0x2000); } diff --git a/src/bksel.c b/src/bksel.c index 7a0c1770..266b889d 100644 --- a/src/bksel.c +++ b/src/bksel.c @@ -432,7 +432,7 @@ void InitBattleForecastFramePalettes() { void BattleForecast_Init(struct BattleForecastProc* proc) { Decompress(gBattleForecast_x2x4Gfx, gGenericBuffer); - CopyTileGfxForObj(gGenericBuffer, (void*)0x06015D00, 4, 2); + Copy2dChr(gGenericBuffer, (void*)0x06015D00, 4, 2); CopyToPaletteBuffer(gBattleForecast_x2x4Pal, 0x240, 0x20); Font_ResetAllocation(); diff --git a/src/bm.c b/src/bm.c index 7049f6c4..fe20ce81 100644 --- a/src/bm.c +++ b/src/bm.c @@ -378,7 +378,7 @@ void OnGameLoopMain(void) { Proc_Run(gProcTreeRootArray[1]); - if (GetThread2SkipStack() == 0) { + if (GetGameLock() == 0) { Proc_Run(gProcTreeRootArray[2]); } @@ -399,19 +399,19 @@ void OnGameLoopMain(void) { } //! FE8U = 0x08015360 -void AddSkipThread2(void) { +void LockGame(void) { gBmSt.gameLogicSemaphore++; return; } //! FE8U = 0x08015370 -void SubSkipThread2(void) { +void UnlockGame(void) { gBmSt.gameLogicSemaphore--; return; } //! FE8U = 0x08015380 -u8 GetThread2SkipStack(void) { +u8 GetGameLock(void) { return gBmSt.gameLogicSemaphore; } @@ -625,7 +625,7 @@ void InitBmBgLayers(void) { //! FE8U = 0x08015680 void LoadObjUIGfx(void) { Decompress(gGfx_MiscUiGraphics, gGenericBuffer); - CopyTileGfxForObj(gGenericBuffer, (void*)0x06010000, 0x12, 4); + Copy2dChr(gGenericBuffer, (void*)0x06010000, 0x12, 4); CopyToPaletteBuffer(gPal_MiscUiGraphics, 0x200, 0x40); diff --git a/src/bmdifficulty.c b/src/bmdifficulty.c index ffa34c10..b96ebc9d 100644 --- a/src/bmdifficulty.c +++ b/src/bmdifficulty.c @@ -424,7 +424,7 @@ void UpdateDungeonEnemiesDefeated() { struct ProcCmd CONST_DATA sProcScr_DisplayDungeonRecord_FromMenu[] = { PROC_CALL(PushGlobalTimer), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(sub_8013D80), PROC_REPEAT(WaitForFade), PROC_CALL(BMapDispSuspend), @@ -444,7 +444,7 @@ struct ProcCmd CONST_DATA sProcScr_DisplayDungeonRecord_FromMenu[] = { PROC_CALL(RefreshBMapGraphics), PROC_CALL(sub_8013DA4), PROC_REPEAT(WaitForFade), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; @@ -458,7 +458,7 @@ extern struct ProcCmd CONST_DATA sProcScr_DungeonRecord_UpdateNewRecordValues[]; struct ProcCmd CONST_DATA sProcScr_DisplayDungeonRecord_AfterDungeonClear[] = { PROC_CALL(PushGlobalTimer), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(StartFadeInBlackMedium), PROC_REPEAT(WaitForFade), PROC_CALL(BMapDispSuspend), @@ -481,7 +481,7 @@ struct ProcCmd CONST_DATA sProcScr_DisplayDungeonRecord_AfterDungeonClear[] = { PROC_SLEEP(0), PROC_CALL(BMapDispResume), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_CALL(PopGlobalTimer), PROC_END, diff --git a/src/bmio.c b/src/bmio.c index e830403d..a27b0dde 100644 --- a/src/bmio.c +++ b/src/bmio.c @@ -455,7 +455,7 @@ void WfxSandStorm_Init(void) { AllocWeatherParticles(gPlaySt.chapterWeatherId); Decompress(gUnknown_085A3964, gGenericBuffer); - CopyTileGfxForObj(gGenericBuffer, OBJ_VRAM0 + 0x1C * 0x20, 4, 4); + Copy2dChr(gGenericBuffer, OBJ_VRAM0 + 0x1C * 0x20, 4, 4); for (i = 0; i < 0x40; ++i) { sWeatherEffect.particles[i].xPosition = AdvanceGetLCGRNValue(); @@ -495,7 +495,7 @@ void WfxSnowStorm_Init(void) { AllocWeatherParticles(gPlaySt.chapterWeatherId); Decompress(gUnknown_085A39EC, gGenericBuffer); - CopyTileGfxForObj(gGenericBuffer, OBJ_VRAM0 + 0x18 * 0x20, 8, 4); + Copy2dChr(gGenericBuffer, OBJ_VRAM0 + 0x18 * 0x20, 8, 4); for (i = 0; i < 0x40; ++i) { unsigned type = typeLookup[i & 7]; @@ -804,7 +804,7 @@ void WfxClouds_VSync(void) { break; case 7: - CopyTileGfxForObj(gfx, OBJ_VRAM0 + (0x20 * 18), 14, 4); + Copy2dChr(gfx, OBJ_VRAM0 + (0x20 * 18), 14, 4); break; } // switch (GetGameClock() % 8) diff --git a/src/bmitemuse.c b/src/bmitemuse.c index 0e70cb22..89312735 100644 --- a/src/bmitemuse.c +++ b/src/bmitemuse.c @@ -91,7 +91,7 @@ struct ProcCmd CONST_DATA gProcScr_SquareSelectWarp[] = { PROC_SET_END_CB(WarpSelect_OnEnd), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_WHILE_EXISTS(gProcScr_CamMove), @@ -103,7 +103,7 @@ struct ProcCmd CONST_DATA gProcScr_SquareSelectWarp[] = PROC_CALL(WarpSelect_OnConfirm), PROC_SLEEP(0), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_GOTO(100), @@ -111,7 +111,7 @@ PROC_LABEL(99), PROC_CALL(WarpSelect_OnCancel), PROC_SLEEP(0), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_LABEL(100), PROC_END, @@ -119,7 +119,7 @@ PROC_LABEL(100), struct ProcCmd CONST_DATA gProcScr_SquareSelectTorch[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(TorchSelect_OnInit), PROC_WHILE_EXISTS(gProcScr_CamMove), @@ -134,7 +134,7 @@ PROC_LABEL(99), PROC_CALL(WarpSelect_OnCancel), PROC_LABEL(100), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; diff --git a/src/bmlib-fade.c b/src/bmlib-fade.c new file mode 100644 index 00000000..57ec1de2 --- /dev/null +++ b/src/bmlib-fade.c @@ -0,0 +1,173 @@ +#include "global.h" +#include "hardware.h" +#include "proc.h" +#include "bm.h" +#include "bmlib.h" +#include "uiutils.h" +#include "soundwrapper.h" +#include "bmlib.h" + +struct ProcSpacialSeTest { + PROC_HEADER; + + /* 29 */ STRUCT_PAD(0x29, 0x64); + /* 64 */ short unk64; + /* 66 */ short unk66; +}; + +void SpacialSeTest_OnInit(struct ProcSpacialSeTest *proc) +{ + proc->unk64 = 0; + proc->unk66 = 90; +} + +void SpacialSeTest_OnLoop(struct ProcSpacialSeTest * proc) +{ + int location = 0; + + if (gKeyStatusPtr->newKeys & A_BUTTON) + proc->unk66++; + + if (((proc->unk64++) & 0x0F) == 0) + { + if (gKeyStatusPtr->heldKeys & DPAD_LEFT) + location = -proc->unk66; + + if (gKeyStatusPtr->heldKeys & DPAD_RIGHT) + location = +proc->unk66; + + PlaySeSpacial(0x9A, location); + } +} + +struct ProcCmd CONST_DATA ProcScr_SpacialSeTest[] = { + PROC_CALL(LockGame), + + PROC_CALL(SpacialSeTest_OnInit), + PROC_REPEAT(SpacialSeTest_OnLoop), +}; + +void StartSpacialSeTest(void) +{ + Proc_Start(ProcScr_SpacialSeTest, PROC_TREE_3); +} + +void sub_80138EC(void) +{ + return; +} + +void StartPalFadeToBlack(int palid, int duration, ProcPtr parent) +{ + StartPalFade(Pal_AllBlack, palid, duration, parent); +} + +void StartPalFadeToWhite(int palid, int duration, ProcPtr parent) +{ + StartPalFade(Pal_AllWhite, palid, duration, parent); +} + +struct PalFadeProc +{ + /* 00 */ PROC_HEADER; + /* 2C */ struct PalFadeSt * st; +}; + +void PalFade_OnLoop(struct PalFadeProc *proc); + +struct ProcCmd CONST_DATA ProcScr_PalFade[] = +{ + PROC_MARK(0xA), + PROC_REPEAT(PalFade_OnLoop), + + PROC_END, +}; + +struct PalFadeSt *StartPalFade(u16 const *colors, int pal, int duration, ProcPtr parent) +{ + struct PalFadeSt * st = sPalFadeSt + pal; + struct PalFadeProc * proc = Proc_Start(ProcScr_PalFade, parent); + + CpuCopy16(gPaletteBuffer + pal * 0x10, st->from_colors, sizeof(st->from_colors)); + + st->pal = gPaletteBuffer + pal * 0x10; + st->to_colors = colors; + st->clock = 0; + st->clock_end = duration; + st->clock_stop = duration + 1; + + proc->st = st; + return st; +} + +void EndPalFade(void) +{ + Proc_EndEach(ProcScr_PalFade); +} + +void SetPalFadeStop(struct PalFadeSt * st, int val) +{ + st->clock_stop = val; +} + +void PalFade_OnLoop(struct PalFadeProc * proc) +{ + int i; + + u16 const * from_colors = proc->st->from_colors; + u16 const * to_colors = proc->st->to_colors; + + u16 * pal = proc->st->pal; + + if (proc->st->clock == proc->st->clock_stop || proc->st->clock > proc->st->clock_end) + { + Proc_End(proc); + return; + } + + for (i = 0; i < 0x10; ++i) + { + int red_a = from_colors[i] & 0x001F; + int green_a = from_colors[i] & 0x03E0; + int blue_a = from_colors[i] & 0x7C00; + + int red_b = to_colors[i] & 0x001F; + int green_b = to_colors[i] & 0x03E0; + int blue_b = to_colors[i] & 0x7C00; + + int red = Interpolate(INTERPOLATE_LINEAR, red_a, red_b, proc->st->clock, proc->st->clock_end); + int green = Interpolate(INTERPOLATE_LINEAR, green_a, green_b, proc->st->clock, proc->st->clock_end); + int blue = Interpolate(INTERPOLATE_LINEAR, blue_a, blue_b, proc->st->clock, proc->st->clock_end); + + pal[i] = (blue & 0x7C00) | (green & 0x03E0) | (red & 0x001F); + } + + EnablePaletteSync(); + proc->st->clock++; +} + +void SetBlackPal(int palid) +{ + CpuCopy16(Pal_AllBlack, gPaletteBuffer + palid * 0x10, 0x20); +} + +void SetWhitePal(int palid) +{ + CpuCopy16(Pal_AllWhite, gPaletteBuffer + palid * 0x10, 0x20); +} + +void SetAllBlackPals(void) +{ + int i; + + for (i = 0; i < 0x20; ++i) + SetBlackPal(i); +} + +void SetAllWhitePals(void) +{ + int i; + + for (i = 0; i < 0x20; ++i) + SetBlackPal(i); +} diff --git a/src/bmlib.c b/src/bmlib.c index 5c7dafc1..d281145e 100644 --- a/src/bmlib.c +++ b/src/bmlib.c @@ -4,13 +4,11 @@ #include "uiutils.h" #include "hardware.h" #include "proc.h" - -typedef void (*cpy_func_t)(const void* src, void* dst); -extern cpy_func_t gUnknown_08599FB4[]; +#include "bmlib.h" struct Struct8012F98 { - u8* unk0; - int unk4; + u8* dst; + int unk_04; }; int Interpolate(int method, int lo, int hi, int x, int x_max) @@ -80,9 +78,9 @@ void CopyString(char *dst, const char *src) *dst = *src; } -void CopyDirect(u8 *src, u8 *dst) +void UnpackRaw(const void *src, void *dst) { - int size = FilterR0ForRawCopy(src) - 4; + int size = GetDataSize(src) - 4; if (0 != size % 32) CpuCopy16(src + 4, dst, size); @@ -91,167 +89,201 @@ void CopyDirect(u8 *src, u8 *dst) } -void sub_8012F20(u8 *src, u8 *dst) +/** + * This is unused since generic buffer holds only 0x1000 size, + * which may cause overflow + */ +void DecompressViaGenericBuf(const void *src, void *dst) { LZ77UnCompWram(src, gGenericBuffer); - CpuFastCopy(gGenericBuffer, dst, FilterR0ForRawCopy(src)); + CpuFastCopy(gGenericBuffer, dst, GetDataSize(src)); } void Decompress(const void* src, void* dst) { - const u8 *_src; - u8 *_dst; - int index ; + typedef void (* DecompressFunc)(const void *src, void *dst); - _src = src; - _dst = dst; + static CONST_DATA DecompressFunc func_lut[] = { + UnpackRaw, // 00, vram + UnpackRaw, // 00, wram + LZ77UnCompVram, // 10, vram + LZ77UnCompWram, // 10, wram + HuffUnComp, // 20, vram + HuffUnComp, // 20, wram + RLUnCompVram, // 30, vram + RLUnCompWram, // 30, wram + }; - if ((_dst - 0x06000000) < (u8*)0x18000) - index = 0; + int is_wram; + + if ((((u32) dst) - VRAM) < VRAM_SIZE) + is_wram = FALSE; // is vram else - index = 1; + is_wram = TRUE; - gUnknown_08599FB4[index + (_src[0] & 0xF0) / 8](_src, _dst); + func_lut[is_wram + ((((u8 const *) src)[0] & 0xF0) >> 3)](src, dst); } -int FilterR0ForRawCopy(const void* data) +int GetDataSize(const void* data) { - const u32 *_data = data; - return _data[0] >> 8; + return *((u32 const *) data) >> 8; } -void sub_8012F98(struct Struct8012F98 *buf, int a2, int a3) +void sub_8012F98(struct Struct8012F98 *buf, int arg_1, int arg_2) { - int a, b = a3; - buf->unk0 = (u8*)b; - a3 = 0xFFE0; - a = (a2 & a3) >> 5; - b = (b & a3) >> 5; - buf->unk4 = a = b - a; + buf->dst = (u8 *) arg_2; + + arg_1 = (arg_1 & 0xFFE0) >> 5; + arg_2 = (arg_2 & 0xFFE0) >> 5; + + buf->unk_04 = arg_2 - arg_1; } -int sub_8012FB0(struct Struct8012F98 *buf, u8 *src) +int sub_8012FB0(struct Struct8012F98 *unk, u8 *src) { - int val, size; - Decompress(src, buf->unk0); - val = FilterR0ForRawCopy(src); - buf->unk0 += val; - size = buf->unk4; - buf->unk4 = size + (val / 32); - return size; + int size, old; + + Decompress(src, unk->dst); + + size = GetDataSize(src); + + unk->dst += size; + + old = unk->unk_04; + unk->unk_04 += size / 0x20; + + return old; } -int sub_8012FE0(struct Struct8012F98 *buf, int a2) +int sub_8012FE0(struct Struct8012F98 *buf, int arg_1) { - int size; - buf->unk0 += a2 << 5; - size = buf->unk4; - buf->unk4 += a2; - return size; + int old; + + buf->dst += arg_1 << 5; + + old = buf->unk_04; + buf->unk_04 += arg_1; + + return old; } -void RegisterObjectTileGraphics(const void* source, void* target, int width, int height) +void Register2dChrMove(const void* src, void* dst, int width, int height) { - int t_width = 32 * width; + int i, line_size = width * CHR_SIZE; - if (height > 0) { - int tile = height; - do { - RegisterTileGraphics(source, target, t_width); - source += t_width; - target += 1024; - } while(--tile != 0); + if (height <= 0) + return; + + for (i = height; i != 0; --i) { + RegisterDataMove(src, dst, line_size); + + src += line_size; + dst += CHR_SIZE * 0x20; } } -void CopyTileGfxForObj(const void* src, void* dst, int width, int height) +void Copy2dChr(const void* src, void* dst, int width, int height) { - int t_width = 32 * width; + int i, line_size = width * CHR_SIZE; - if (height > 0) { - int tile = height; - do { - CpuFastCopy(src, dst, t_width); - src += t_width; - dst += 1024; - } while(--tile != 0); + if (height <= 0) + return; + + for (i = height; i != 0; --i) { + CpuFastCopy(src, dst, line_size); + + src += line_size; + dst += CHR_SIZE * 0x20; } } -void sub_8013058(const void* src, void* dst, int width, int height) +void ApplyBitmap(const void* src, void* dst, int width, int height) { - int tile; - if (height > 0) { - int _width = width * 64; - for (tile = height; tile != 0; tile--) { - sub_8013094(src, dst, width); - src += _width; - dst += 32 * width; - } + int i, line_size; + + if (height <= 0) + return; + + line_size = 8 * 8 * width; + + for (i = height; i != 0; --i) { + ApplyBitmapLine(src, dst, width); + + src += line_size; + dst += CHR_SIZE * width; } } -void sub_8013094(const void *src, void *dst, int width) +void ApplyBitmapLine(const void *src, void *dst, int width) { - if (width > 0) { - int tile; - for (tile = width; tile != 0; tile--) { - sub_80130BC(src, dst, width); - src += 8; - dst += 32; - } - } -} - -void sub_80130BC(const void *src, void *dst, int width) -{ - const u8 *_src; - u32 *_dst; - int _width; int i; - _src = src; - _dst = dst; - _width = width; + if (width <= 0) + return; - for (i = 0; i < 8; i++) { - *_dst = 16 * (16 * (16 * (16 * (16 * (16 * (16 * _src[7] | _src[6]) | _src[5]) | _src[4]) | _src[3]) | _src[2]) | _src[1]) | _src[0]; - _dst += 1; - _src += 8 * _width; + for (i = width; i != 0; i--) { + ApplyBitmapTile(src, dst, width); + + src += 8; + dst += CHR_SIZE; } } -void sub_8013104(u16 *tm, int pal, int a3, int a4) +void ApplyBitmapTile(const u8 *src, u32 *dst, int width) { - int i, j; - register u16 *_tm asm("r0"); + int i; - for (i = 0; i < a4; i++) { - if (a3 > 0) { - _tm = (u16 *)(i * 64 + (uintptr_t)tm); + for (i = 0; i < 8; ++i) { + u32 value = 0; - for (j = a3; j != 0; j--) { - *_tm++ = pal++; - } - } + value |= src[7]; + + value <<= 4; + value |= src[6]; + + value <<= 4; + value |= src[5]; + + value <<= 4; + value |= src[4]; + + value <<= 4; + value |= src[3]; + + value <<= 4; + value |= src[2]; + + value <<= 4; + value |= src[1]; + + value <<= 4; + value |= src[0]; + + *dst++ = value; + src += width * 8; } } -void sub_8013138(u16 *dst, u8* src, int a3, int a4) +void PutAppliedBitmap(u16 * tm, int tileref, int width, int height) { - u16 *_dst = dst; - int _a3 = a3; + int ix, iy; - if (a4 > 0) { - do { - *dst-- = 0; - } while (--a4); - } + for (iy = 0; iy < height; ++iy) + for (ix = 0; ix < width; ++ix) + tm[TILEMAP_INDEX(ix, iy)] = tileref++; +} - while (*src != 32) { - *_dst = *src + _a3 - 48; - --_dst; - --src; +void PutDigits(u16 *tm, const u8 *src, int tileref, int len) +{ + int i; + + for (i = 0; i < len; ++i) + tm[-i] = 0; + + while (*src != ' ') + { + *tm-- = tileref + *src - '0'; + src--; } } @@ -277,34 +309,35 @@ void sub_8013168(u16 *dst, u8* src, int a3, int a4, int a5) } } -/*** - * I think this maybe a counter. - */ - -void sub_80131A8(struct Proc *proc, int val) +struct Unk_80131A8 { - proc->unk4C = val; + /* 00 */ STRUCT_PAD(0x0, 0x4C); + /* 4C */ u16 unk_4C; +}; + +void sub_80131A8(struct Unk_80131A8 *unk, int value) +{ + unk->unk_4C = value; } -void sub_80131B0(struct Proc *proc) +void sub_80131B0(struct Unk_80131A8 *unk) { - int val1 = (u16)proc->unk4C + 1; - int val2 = 0x7FFF; - proc->unk4C = val1 & val2; + unk->unk_4C++; + unk->unk_4C &= 0x7FFF; } -void sub_80131C4(struct Proc *proc) +void sub_80131C4(struct Unk_80131A8 *unk) { - (u16)proc->unk4C--; + unk->unk_4C--; } -void sub_80131D0(s16 *buf) +void sub_80131D0(s16 *array) { - int i = 159; - while (i >= 0) { - *buf++ = 240; - *buf++ = -1; - i--; + int i; + + for (i = DISPLAY_HEIGHT-1; i >= 0; --i) { + *array++ = DISPLAY_WIDTH; + *array++ = -1; } } @@ -328,8 +361,8 @@ void sub_80131F0(s16 *buf, int x1, int y1, int x2, int y2) val1 = ((x2 - x1) << 0x10) / (y2 - y1); val2 = x1 << 0x10; - if (y2 > 160) - y2 = 160; + if (y2 > DISPLAY_HEIGHT) + y2 = DISPLAY_HEIGHT; if (y1 < 0) { val2 += val1 * -y1; @@ -345,277 +378,113 @@ void sub_80131F0(s16 *buf, int x1, int y1, int x2, int y2) if (buf[2 * y1 + 1] < val) buf[2 * y1 + 1] = val; - asm(""::"r"(buf + 2*y1)); + asm(""::"r"(buf + 2 * y1)); val2 += val1; } } #undef _SWAP -/* https://decomp.me/scratch/1FKcf */ -#if NONMATCHING -void sub_8013278(int a1) +struct Unk { - int i; - int _a1 = a1; - u16 val1, val2, val3, val4; - u16 *bufp, *bufm, *buff, *bufr; - int val5, val6; + short a, b; +}; - val5 = a1; - if (a1 > 0x80) - a1 = 0x80; +struct Unk *sub_8013278(int arg_0) +{ + #define BUF ((struct Unk *) gGenericBuffer) - if (a1 < 0) - return; + int r2; + int sb; + int sp_00; - bufp = &gGenericBuffer[2 * a1]; - bufm = &gGenericBuffer[2 * a1]; - val6 = -a1; - buff = &gGenericBuffer[0]; - bufr = &gGenericBuffer[4 * a1]; + sp_00 = arg_0; - for (i = 0; i <= _a1; i++) { - val1 = a1 + i; - if (val1 <= 0x9F) - bufp[1] = _a1; + if (sp_00 > 80) + sp_00 = 80; - val2 = a1 - i; - if (val2 <= 0x9F) - bufm[1] = _a1; + r2 = arg_0; - val3 = a1 + _a1; - if (val3 <= 0x9F) - bufr[1] = i; + for (sb = 0; r2 >= sb; ++sb) + { + u16 sp_18, r4, r3, r1; - val4 = a1 - _a1; - if (val4 <= 0x9F) - buff[1] = i; + sp_18 = sp_00 + sb; - if (val1 <= 0x9F) - bufp[0] = -_a1; + if (sp_18 < DISPLAY_HEIGHT) + BUF[sp_00 + sb].b = r2; - if (val2 <= 0x9F) - gGenericBuffer16[a1 - i] = _a1; + r4 = sp_00 - sb; - if (val3 <= 0x9F) - gGenericBuffer16[a1 + _a1] = -i; + if (r4 < DISPLAY_HEIGHT) + BUF[sp_00 - sb].b = r2; - if (val4 <= 0x9F) - gGenericBuffer16[a1 - _a1] = -i; + r3 = sp_00 + r2; - val5 = val5 + 1 - 2 * i; - if (val5 < 0) { - val5 += 2 * (_a1 - 1); - val6++; - buff += 2; - bufr += 2; - _a1--; + if (r3 < DISPLAY_HEIGHT) + BUF[sp_00 + r2].b = sb; + + r1 = sp_00 - r2; + + if (r1 < DISPLAY_HEIGHT) + BUF[sp_00 - r2].b = sb; + + if (sp_18 < DISPLAY_HEIGHT) + BUF[sp_00 + sb].a = -r2; + + if (r4 < DISPLAY_HEIGHT) + BUF[sp_00 - sb].a = -r2; + + if (r3 < DISPLAY_HEIGHT) + BUF[sp_00 + r2].a = -sb; + + if (r1 < DISPLAY_HEIGHT) + BUF[sp_00 - r2].a = -sb; + + arg_0 = arg_0 - (sb*2 - 1); + + if (arg_0 < 0) + { + arg_0 = arg_0 + (r2 - 1)*2; + r2--; } - bufp += 2; - bufm -= 2; } -} -#else -__attribute__((naked)) -void sub_8013278(int a1) -{ - asm("\n\ - .syntax unified\n\ - push {r4, r5, r6, r7, lr}\n\ - mov r7, sl\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5, r6, r7}\n\ - sub sp, #0x1c\n\ - adds r6, r0, #0\n\ - str r6, [sp]\n\ - cmp r6, #0x50\n\ - ble _08013290\n\ - movs r0, #0x50\n\ - str r0, [sp]\n\ - _08013290:\n\ - adds r2, r6, #0\n\ - movs r1, #0\n\ - mov r9, r1\n\ - cmp r2, #0\n\ - blt _08013388\n\ - movs r3, #0\n\ - str r3, [sp, #4]\n\ - ldr r4, [sp]\n\ - lsls r0, r4, #2\n\ - ldr r7, _0801339C\n\ - adds r0, r0, r7\n\ - mov sl, r0\n\ - str r0, [sp, #8]\n\ - negs r1, r2\n\ - str r1, [sp, #0xc]\n\ - lsls r0, r2, #2\n\ - ldr r3, [sp, #8]\n\ - subs r3, r3, r0\n\ - str r3, [sp, #0x10]\n\ - ldr r4, [sp, #8]\n\ - adds r0, r0, r4\n\ - str r0, [sp, #0x14]\n\ - _080132BC:\n\ - ldr r0, [sp]\n\ - add r0, r9\n\ - lsls r0, r0, #0x10\n\ - lsrs r0, r0, #0x10\n\ - str r0, [sp, #0x18]\n\ - cmp r0, #0x9f\n\ - bhi _080132CE\n\ - mov r7, sl\n\ - strh r2, [r7, #2]\n\ - _080132CE:\n\ - ldr r0, [sp]\n\ - mov r1, r9\n\ - subs r0, r0, r1\n\ - mov r8, r0\n\ - lsls r0, r0, #0x10\n\ - lsrs r4, r0, #0x10\n\ - cmp r4, #0x9f\n\ - bhi _080132E2\n\ - ldr r3, [sp, #8]\n\ - strh r2, [r3, #2]\n\ - _080132E2:\n\ - ldr r7, [sp]\n\ - adds r7, r7, r2\n\ - mov ip, r7\n\ - lsls r0, r7, #0x10\n\ - lsrs r3, r0, #0x10\n\ - cmp r3, #0x9f\n\ - bhi _080132F6\n\ - mov r1, r9\n\ - ldr r0, [sp, #0x14]\n\ - strh r1, [r0, #2]\n\ - _080132F6:\n\ - ldr r7, [sp]\n\ - subs r5, r7, r2\n\ - lsls r0, r5, #0x10\n\ - lsrs r1, r0, #0x10\n\ - cmp r1, #0x9f\n\ - bhi _08013308\n\ - mov r7, r9\n\ - ldr r0, [sp, #0x10]\n\ - strh r7, [r0, #2]\n\ - _08013308:\n\ - ldr r0, [sp, #0x18]\n\ - cmp r0, #0x9f\n\ - bhi _08013316\n\ - mov r7, sp\n\ - ldrh r0, [r7, #0xc]\n\ - mov r7, sl\n\ - strh r0, [r7]\n\ - _08013316:\n\ - cmp r4, #0x9f\n\ - bhi _08013328\n\ - mov r4, r8\n\ - lsls r0, r4, #2\n\ - ldr r7, _0801339C\n\ - adds r0, r0, r7\n\ - mov r4, sp\n\ - ldrh r4, [r4, #0xc]\n\ - strh r4, [r0]\n\ - _08013328:\n\ - cmp r3, #0x9f\n\ - bhi _0801333A\n\ - mov r7, ip\n\ - lsls r0, r7, #2\n\ - ldr r3, _0801339C\n\ - adds r0, r0, r3\n\ - mov r4, sp\n\ - ldrh r4, [r4, #4]\n\ - strh r4, [r0]\n\ - _0801333A:\n\ - cmp r1, #0x9f\n\ - bhi _0801334A\n\ - lsls r0, r5, #2\n\ - ldr r7, _0801339C\n\ - adds r0, r0, r7\n\ - mov r1, sp\n\ - ldrh r1, [r1, #4]\n\ - strh r1, [r0]\n\ - _0801334A:\n\ - adds r1, r6, #1\n\ - mov r3, r9\n\ - lsls r0, r3, #1\n\ - subs r6, r1, r0\n\ - cmp r6, #0\n\ - bge _08013370\n\ - subs r1, r2, #1\n\ - lsls r0, r1, #1\n\ - adds r6, r6, r0\n\ - ldr r4, [sp, #0xc]\n\ - adds r4, #1\n\ - str r4, [sp, #0xc]\n\ - ldr r7, [sp, #0x10]\n\ - adds r7, #4\n\ - str r7, [sp, #0x10]\n\ - ldr r0, [sp, #0x14]\n\ - subs r0, #4\n\ - str r0, [sp, #0x14]\n\ - adds r2, r1, #0\n\ - _08013370:\n\ - ldr r1, [sp, #4]\n\ - subs r1, #1\n\ - str r1, [sp, #4]\n\ - movs r3, #4\n\ - add sl, r3\n\ - ldr r4, [sp, #8]\n\ - subs r4, #4\n\ - str r4, [sp, #8]\n\ - movs r7, #1\n\ - add r9, r7\n\ - cmp r2, r9\n\ - bge _080132BC\n\ - _08013388:\n\ - ldr r0, _0801339C\n\ - add sp, #0x1c\n\ - pop {r3, r4, r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov sl, r5\n\ - pop {r4, r5, r6, r7}\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ - _0801339C: .4byte gGenericBuffer\n\ - .syntax divided\n\ - "); -} -#endif -void sub_80133A0(int a1) + return BUF; + + #undef BUF +} + +void DarkenPals(int reduction) { - int color; - u16 *tmp_buf = (void*)gGenericBuffer; + u16 * buf = (u16 *) gGenericBuffer; + int i; - u16 *pal_buf = (void*)gPaletteBuffer; - for (i = 0; i < 0x200; i++) { - color = pal_buf[i]; + for (i = 0; i < 0x200; ++i) + { + int color = gPaletteBuffer[i]; - if ((color & 0x1F) >= RGB(a1, 0, 0)) - color = color - RGB(a1, 0, 0); + if ((color & 0x001F) >= RGB(reduction, 0, 0)) + color -= RGB(reduction, 0, 0); else color = color & 0xFFE0; - if ((color & 0x3E0) >= RGB(0, a1, 0)) - color -= RGB(0, a1, 0); + if ((color & 0x03E0) >= RGB(0, reduction, 0)) + color -= RGB(0, reduction, 0); else color = color & 0xFC1F; - if ((color & 0x7C00) >= RGB(0, 0, a1)) - color = color - RGB(0, 0, a1); + if ((color & 0x7C00) >= RGB(0, 0, reduction)) + color -= RGB(0, 0, reduction); else - color = color & 0x3FF; + color = color & 0x03FF; - tmp_buf[i] = color; + buf[i] = color; } DisablePaletteSync(); - RegisterTileGraphics(tmp_buf, (void*)0x5000000, 0x400); + RegisterDataMove(buf, (void*)PLTT, 0x400); } void sub_8013428() @@ -623,60 +492,59 @@ void sub_8013428() return; } -void sub_801342C(void *buf) +void sub_801342C(const char *_str) { - u8 _buf[0x10]; - memcpy(_buf, gUnknown_080D7954, 0x0D); - sub_801342C(_buf); + char str[] = "@@LWFOVDBK@@"; + sub_801342C(str); } -struct Struct202B6B0 *GetPaletteBufferBuffer() +struct PalFadeSt *GetPalFadeSt() { - return &gUnknown_0202B6B0; + return (void *)sPalFadeSt; } -void sub_8013454(int _2a, int _5a, int _8a) +void SetPalFadeStClkEnd(int end1, int end2, int end3) { - SetSomethingInPaletteBB_2A(_2a); - SetSomethingInPaletteBB_5A(_5a); - SetSomethingInPaletteBB_8A(_8a); + SetPalFadeStClkEnd1(end1); + SetPalFadeStClkEnd2(end2); + SetPalFadeStClkEnd3(end3); } -void SetSomethingInPaletteBB_2A(int a1) +void SetPalFadeStClkEnd1(int end) { - GetPaletteBufferBuffer()->unk2A = a1; + GetPalFadeSt()[0].clock_end = end; } -void SetSomethingInPaletteBB_5A(int a1) +void SetPalFadeStClkEnd2(int end) { - GetPaletteBufferBuffer()->unk5A = a1; + GetPalFadeSt()[1].clock_end = end; } -void SetSomethingInPaletteBB_8A(int a1) +void SetPalFadeStClkEnd3(int end) { - GetPaletteBufferBuffer()->unk8A = a1; + GetPalFadeSt()[2].clock_end = end; } -int GetSomethingInPaletteBB_2A() +int GetPalFadeStClkEnd1() { - return GetPaletteBufferBuffer()->unk2A; + return GetPalFadeSt()[0].clock_end; } -int GetSomethingInPaletteBB_5A() +int GetPalFadeStClkEnd2() { - return GetPaletteBufferBuffer()->unk5A; + return GetPalFadeSt()[1].clock_end; } -int GetSomethingInPaletteBB_8A() +int GetPalFadeStClkEnd3() { - return GetPaletteBufferBuffer()->unk8A; + return GetPalFadeSt()[2].clock_end; } void ArchiveCurrentPalettes() { int i, j; - u16 *dst = (void*)GetPaletteBufferBuffer(); - u16 *src = (void*)&gPaletteBuffer; + u16 *dst = (void *)GetPalFadeSt(); + u16 *src = gPaletteBuffer; for (i = 0; i < 32; i++) { for (j = 0; j < 16; j++) @@ -685,17 +553,17 @@ void ArchiveCurrentPalettes() dst += 24; } - SetSomethingInPaletteBB_2A(0x100); - SetSomethingInPaletteBB_5A(0x100); - SetSomethingInPaletteBB_8A(0x100); + SetPalFadeStClkEnd1(0x100); + SetPalFadeStClkEnd2(0x100); + SetPalFadeStClkEnd3(0x100); } void ArchivePalette(int index) { int i; - u16 *dst = (void*)GetPaletteBufferBuffer(); - u16 *src = (void*)&gPaletteBuffer[16 * index]; + struct PalFadeSt *dst = GetPalFadeSt(); + u16 *src = &gPaletteBuffer[0x10 * index]; for (i = 0; i < 16; i++) - dst[24 * index + i] = *src++; + dst[index].from_colors[i] = *src++; } diff --git a/src/bmmenu.c b/src/bmmenu.c index d28bee58..5abaddec 100644 --- a/src/bmmenu.c +++ b/src/bmmenu.c @@ -76,14 +76,14 @@ void BackToUnitMenu_CamWatch(ProcPtr proc); void BackToUnitMenu_RestartMenu(void); struct ProcCmd CONST_DATA gProcScr_BackToUnitMenu[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(BackToUnitMenu_CamWatch), PROC_WHILE_EXISTS(gProcScr_CamMove), PROC_CALL(BackToUnitMenu_RestartMenu), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; @@ -92,7 +92,7 @@ void sub_8022E38(void); void sub_8022E54(void); struct ProcCmd CONST_DATA gProcScr_0859B630[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(sub_8022E38), @@ -101,7 +101,7 @@ struct ProcCmd CONST_DATA gProcScr_0859B630[] = { PROC_CALL(sub_8022E54), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; diff --git a/src/bmshop.c b/src/bmshop.c index 7d5d3c08..8eaf0e18 100644 --- a/src/bmshop.c +++ b/src/bmshop.c @@ -93,7 +93,7 @@ int CONST_DATA gShopPortraitLut[] = { }; struct ProcCmd CONST_DATA gProcScr_ShopFadeIn[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_SLEEP(1), PROC_CALL_ARG(sub_8014BD0, -1), @@ -115,7 +115,7 @@ struct ProcCmd CONST_DATA gProcScr_ShopFadeOut[] = { PROC_CALL(IntroPromoTraineeEventFace), PROC_REPEAT(WaitForFade), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; @@ -155,7 +155,7 @@ struct ProcCmd CONST_DATA gProcScr_Shop[] = { PROC_CALL(StartShopFadeIn), PROC_SLEEP(0), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(ShopProc_Init), PROC_CALL(ShopProc_InitBuyState), @@ -279,7 +279,7 @@ PROC_LABEL(12), PROC_CALL(StartShopFadeOut), PROC_SLEEP(0), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; diff --git a/src/bmtrade.c b/src/bmtrade.c index 561fcaf1..05033a67 100644 --- a/src/bmtrade.c +++ b/src/bmtrade.c @@ -165,7 +165,7 @@ static struct ProcCmd sProcScr_TradeMenu_HighlightUpdater[] = { CONST_DATA static struct ProcCmd sProcScr_TradeMenu[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_YIELD, PROC_WHILE_EXISTS(gProcScr_CamMove), @@ -196,7 +196,7 @@ PROC_LABEL(L_TRADEMENU_END), PROC_CALL(TradeMenu_ClearDisplay), PROC_CALL(ClearBg0Bg1), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END }; diff --git a/src/bmudisp.c b/src/bmudisp.c index aa9a5d95..ee33f58f 100644 --- a/src/bmudisp.c +++ b/src/bmudisp.c @@ -1112,22 +1112,22 @@ void ForceSyncUnitSpriteSheet(void) { frame = GetGameClock() % 72; if (frame >= 68) { - RegisterTileGraphics(gSMSGfxBuffer[1], (void*)0x06011000, sizeof(gSMSGfxBuffer[1])); + RegisterDataMove(gSMSGfxBuffer[1], (void*)0x06011000, sizeof(gSMSGfxBuffer[1])); return; } if (frame >= 36) { - RegisterTileGraphics(gSMSGfxBuffer[2], (void*)0x06011000, sizeof(gSMSGfxBuffer[2])); + RegisterDataMove(gSMSGfxBuffer[2], (void*)0x06011000, sizeof(gSMSGfxBuffer[2])); return; } if (frame >= 32) { - RegisterTileGraphics(gSMSGfxBuffer[1], (void*)0x06011000, sizeof(gSMSGfxBuffer[1])); + RegisterDataMove(gSMSGfxBuffer[1], (void*)0x06011000, sizeof(gSMSGfxBuffer[1])); return; } if (frame >= 0) { - RegisterTileGraphics(gSMSGfxBuffer[0], (void*)0x06011000, sizeof(gSMSGfxBuffer[0])); + RegisterDataMove(gSMSGfxBuffer[0], (void*)0x06011000, sizeof(gSMSGfxBuffer[0])); return; } @@ -1207,7 +1207,7 @@ void sub_8027068(int frameId, u8* dst) { u32 a = off + 0 * CHR_SIZE + i * CHR_SIZE * CHR_LINE; u32 b = off + 1 * CHR_SIZE + i * CHR_SIZE * CHR_LINE; - RegisterTileGraphics( + RegisterDataMove( src + a, dst + b, 2 * CHR_SIZE @@ -1249,7 +1249,7 @@ void sub_80270DC(int frameId, u8* dst) { } for (a = frameId * CHR_SIZE, i = 0; i <= 3; a += CHR_SIZE * CHR_LINE, i++) { - RegisterTileGraphics( + RegisterDataMove( src + (a), dst + (a), 4 * CHR_SIZE); diff --git a/src/bmxfade.c b/src/bmxfade.c index 55c33f57..ca30fa7e 100644 --- a/src/bmxfade.c +++ b/src/bmxfade.c @@ -57,7 +57,7 @@ void Destruct6CBMXFADE(struct BmxfadeProc *proc) SetAllUnitNotBackSprite(); if (0 != proc->game_lock) - SubSkipThread2(); + UnlockGame(); } void NewBMXFADE(s8 lock_game) @@ -66,7 +66,7 @@ void NewBMXFADE(s8 lock_game) proc->game_lock = lock_game; if (0 != lock_game) - AddSkipThread2(); + LockGame(); } void MakeNew6CBMXFADE2(s8 lock_game, ProcPtr parent) @@ -77,7 +77,7 @@ void MakeNew6CBMXFADE2(s8 lock_game, ProcPtr parent) proc->game_lock = lock_game; if (0 != lock_game) - AddSkipThread2(); + LockGame(); } bool8 DoesBMXFADEExist(void) diff --git a/src/branched_promotion_main.c b/src/branched_promotion_main.c index 6605af3d..c5a803aa 100644 --- a/src/branched_promotion_main.c +++ b/src/branched_promotion_main.c @@ -99,7 +99,7 @@ void PromoMain_InitScreen(struct ProcPromoMain *proc) SetupBackgrounds(0); EndGreenTextColorManager(); - gparent->u40 = GetThread2SkipStack(); + gparent->u40 = GetGameLock(); EndHelpPromptSprite(); EndSmallBrownNameBoxes(); EndAllParallelWorkers(); diff --git a/src/emitstarfx.c b/src/emitstarfx.c index 512b777e..5dcdea64 100644 --- a/src/emitstarfx.c +++ b/src/emitstarfx.c @@ -208,7 +208,7 @@ void StartEmitStarsAnim(ProcPtr parent, int xloc, int yloc, int xdiff, int ydiff { struct ProcEmitStars *proc; - RegisterTileGraphics( + RegisterDataMove( Img_EmitedStar, OBJ_CHR_ADDR(OBJCHR_EMITSTARTS), 0x20 diff --git a/src/event.c b/src/event.c index da2db046..0289ab16 100644 --- a/src/event.c +++ b/src/event.c @@ -231,7 +231,7 @@ void EventEngine_OnEnd(struct EventEngineProc* proc) { } case EV_EXEC_GAMEPLAY: - SubSkipThread2(); + UnlockGame(); ResumeMenu(); sub_800BB98(); ClearCutsceneUnits(); @@ -332,7 +332,7 @@ struct EventEngineProc* EventEngine_Create(const u16* events, u8 execType) { case EV_EXEC_CUTSCENE: case EV_EXEC_GAMEPLAY: proc->chapterIndex = gPlaySt.chapterIndex; - AddSkipThread2(); + LockGame(); break; } diff --git a/src/face.c b/src/face.c index 21a53453..86cab944 100644 --- a/src/face.c +++ b/src/face.c @@ -6,6 +6,7 @@ #include "hardware.h" #include "rng.h" #include "bm.h" +#include "bmlib.h" #include "prepscreen.h" #include "constants/faces.h" @@ -646,7 +647,7 @@ void PutFaceTm(u16* tm, u8* data, int tileref, s8 isFlipped) { //! FE8U = 0x08005924 void UnpackFaceChibiGraphics(int fid, int chr, int pal) { if (fid >= FID_FACTION_CHIBI) { - RegisterTileGraphics(sub_8005F6C(fid), (void *)(((chr * CHR_SIZE + VRAM) & 0x1FFFF) + VRAM), 0x200); + RegisterDataMove(sub_8005F6C(fid), (void *)(((chr * CHR_SIZE + VRAM) & 0x1FFFF) + VRAM), 0x200); sub_8005F9C(fid, pal); } else { const struct FaceData* info = GetPortraitData(fid); @@ -674,10 +675,10 @@ void UnpackFaceChibiSprGraphics(int fid, int chr, int pal) { chr += 0x800; if (fid >= FID_FACTION_CHIBI) { - RegisterTileGraphics(sub_8005F6C(fid) + 0x00, (void *)(((chr + 0x00) * 0x20 & 0x1FFFF) + VRAM), 0x80); - RegisterTileGraphics(sub_8005F6C(fid) + 0x80, (void *)(((chr + 0x20) * 0x20 & 0x1FFFF) + VRAM), 0x80); - RegisterTileGraphics(sub_8005F6C(fid) + 0x100, (void *)(((chr + 0x04) * 0x20 & 0x1FFFF) + VRAM), 0x80); - RegisterTileGraphics(sub_8005F6C(fid) + 0x180, (void *)(((chr + 0x24) * 0x20 & 0x1FFFF) + VRAM), 0x80); + RegisterDataMove(sub_8005F6C(fid) + 0x00, (void *)(((chr + 0x00) * 0x20 & 0x1FFFF) + VRAM), 0x80); + RegisterDataMove(sub_8005F6C(fid) + 0x80, (void *)(((chr + 0x20) * 0x20 & 0x1FFFF) + VRAM), 0x80); + RegisterDataMove(sub_8005F6C(fid) + 0x100, (void *)(((chr + 0x04) * 0x20 & 0x1FFFF) + VRAM), 0x80); + RegisterDataMove(sub_8005F6C(fid) + 0x180, (void *)(((chr + 0x24) * 0x20 & 0x1FFFF) + VRAM), 0x80); sub_8005F9C(fid, pal + 0x10); } else { @@ -825,7 +826,7 @@ void PutFace80x72_Core(u16* tm, int fid, int chr, int pal) { } else { Decompress(info->imgCard, (void*)(chr * CHR_SIZE + VRAM)); - sub_8013104(tm, (pal << 12) + (0x3FF & chr), 10, 9); + PutAppliedBitmap(tm, (pal << 12) + (0x3FF & chr), 10, 9); } return; @@ -954,8 +955,8 @@ void EndFaceIn8Frames(struct FaceProc* target) { void StartFaceFadeIn(struct FaceProc* proc) { const struct FaceData* info = GetPortraitData(proc->faceId); - sub_8013A84(sFaceConfig[proc->faceSlot].paletteId + 0x10); - NewEkrDragonPalFadeIn(info->pal, sFaceConfig[proc->faceSlot].paletteId + 0x10, 12, proc); + SetBlackPal(sFaceConfig[proc->faceSlot].paletteId + 0x10); + StartPalFade(info->pal, sFaceConfig[proc->faceSlot].paletteId + 0x10, 12, proc); return; } @@ -966,7 +967,7 @@ void StartFaceFadeOut(struct FaceProc* proc) { // unused const struct FaceData* info = GetPortraitData(proc->faceId); - sub_80138F0(sFaceConfig[proc->faceSlot].paletteId + 0x10, 12, proc); + StartPalFadeToBlack(sFaceConfig[proc->faceSlot].paletteId + 0x10, 12, proc); EndFaceIn8Frames(proc); @@ -1032,7 +1033,7 @@ void sub_8005FE0(struct FaceBlinkProc* proc) { int offsetA = (GetFaceDisplayBits(proc->pFaceProc) & FACE_DISP_SMILE) ? 0 : 24; offsetA += 16; - RegisterObjectTileGraphics( + Register2dChrMove( proc->pFaceProc->pFaceInfo->imgMouth + offsetA * 0x20, (void*)(((proc->pFaceProc->oam2 + 28) & 0x3FF) * 0x20 + 0x06010000), 4, @@ -1064,7 +1065,7 @@ void sub_8005FE0(struct FaceBlinkProc* proc) { break; } - RegisterObjectTileGraphics( + Register2dChrMove( proc->pFaceProc->pFaceInfo->imgMouth + offsetB * 0x20, (void*)(((proc->pFaceProc->oam2 + 28) & 0x3FF) * 0x20 + 0x06010000), 4, diff --git a/src/fontgrp.c b/src/fontgrp.c index 135ba4f2..70ba7a1a 100644 --- a/src/fontgrp.c +++ b/src/fontgrp.c @@ -46,7 +46,7 @@ void SetupDebugFontForBG(int bg, int tileDataOffset) SetBackgroundTileDataOffset(bg, 0); SetBackgroundScreenSize(bg, 0); - RegisterTileGraphics(debug_font_4bpp, (void *)(VRAM + (tileDataOffset & 0x1FFFF)), 0x800); + RegisterDataMove(debug_font_4bpp, (void *)(VRAM + (tileDataOffset & 0x1FFFF)), 0x800); gPaletteBuffer[0] = 0; gPaletteBuffer[2] = RGB(31, 31, 31); @@ -272,7 +272,7 @@ void SetupDebugFontForOBJ(int a, int objPalNum) gUnknown_02028E50 = a / 32; gUnknown_02028E54 = (objPalNum & 0xF) << 12; - RegisterTileGraphics(debug_font_4bpp, (void *)(VRAM + ((a + 0x10000) & 0x1FFFF)), 0x800); + RegisterDataMove(debug_font_4bpp, (void *)(VRAM + ((a + 0x10000) & 0x1FFFF)), 0x800); gPaletteBuffer[(objPalNum + 16) * 16 + 0] = RGB(0, 0, 0); gPaletteBuffer[(objPalNum + 16) * 16 + 1] = RGB(0, 0, 31); diff --git a/src/hardware.c b/src/hardware.c index 813631c3..cfc58531 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1121,7 +1121,7 @@ void ClearTileRigistry(void) gUnknown_02024CDC[0].src = 0; } -void RegisterTileGraphics(const void *a, void *b, int c) +void RegisterDataMove(const void *a, void *b, int c) { struct TileDataTransfer *ptr = &gUnknown_02024CDC[gUnknown_02024CD4.unk0]; diff --git a/src/icon.c b/src/icon.c index ba128bd7..74e7389f 100644 --- a/src/icon.c +++ b/src/icon.c @@ -7,7 +7,7 @@ EWRAM_DATA static struct IconStruct DrawnIconLookupTable[MAX_ICON_COUNT] = {0}; EWRAM_DATA static u8 IconGFXIDLookupTable[MAX_ICON_GFX_COUNT] = {0}; extern void CopyToPaletteBuffer(const void *Palette, u32 Dest, u32 Size); -extern void RegisterTileGraphics(const void *GFX, void *Dest, u32 size); +extern void RegisterDataMove(const void *GFX, void *Dest, u32 size); extern void RegisterFillTile(const void *GFX, void *Dest, u32 size); void ResetIconGraphics_() @@ -75,7 +75,7 @@ u16 GetIconTileIndex(int Index) DrawnIconLookupTable[Index].References++; DrawnIconLookupTable[Index].Index = GetIconGfxIndex(Index) + 1; - RegisterTileGraphics( + RegisterDataMove( item_icon_tiles + (Index * 0x80), (void*)(VRAM + (0x1FFE0 & (VRAM + 0x20 * GetIconGfxTileIndex(DrawnIconLookupTable[Index].Index)))), 0x80 @@ -124,7 +124,7 @@ void LoadIconObjectGraphics(int Index, int b) pSource = (void *)item_icon_tiles; pSource += Index * 0x80; - RegisterTileGraphics(pSource, pTarget, 0x40); - RegisterTileGraphics(pSource + 0x40, pTarget + 0x400, 0x40); + RegisterDataMove(pSource, pTarget, 0x40); + RegisterDataMove(pSource + 0x40, pTarget + 0x400, 0x40); } } diff --git a/src/koido.c b/src/koido.c index bee3ac28..bc4b3196 100644 --- a/src/koido.c +++ b/src/koido.c @@ -30,9 +30,9 @@ struct ProcCmd CONST_DATA sProcScr_KOIDO[] = { struct ProcCmd CONST_DATA sProcScr_KOIDOAMM[] = { PROC_NAME("KOIDOAMM"), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_REPEAT(Loop6C_KOIDO), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END }; diff --git a/src/mapanim.c b/src/mapanim.c index a9f7d993..50cce6af 100644 --- a/src/mapanim.c +++ b/src/mapanim.c @@ -352,7 +352,7 @@ void sub_807ACEC(void) */ CONST_DATA struct ProcCmd ProcScr_MapAnimPoisonDmg[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(MapAnim_MoveCameraOntoSubject), PROC_SLEEP(0x2), PROC_CALL(MapAnim_InitInfoBox), @@ -363,7 +363,7 @@ CONST_DATA struct ProcCmd ProcScr_MapAnimPoisonDmg[] = { }; CONST_DATA struct ProcCmd ProcScr_MapAnimEggDmg[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(MapAnim_MoveCameraOntoSubject), PROC_SLEEP(0x2), PROC_CALL(MapAnim_InitInfoBox), @@ -376,7 +376,7 @@ CONST_DATA struct ProcCmd ProcScr_MapAnimEggDmg[] = { }; CONST_DATA struct ProcCmd ProcScr_MapAnimCritAtk[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(MapAnim_MoveCameraOntoSubject), PROC_SLEEP(0x2), PROC_CALL(MapAnim_InitInfoBox), @@ -387,7 +387,7 @@ CONST_DATA struct ProcCmd ProcScr_MapAnimCritAtk[] = { }; CONST_DATA struct ProcCmd ProcScr_MapAnimSteal[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(MapAnim_MoveCameraOntoTarget), PROC_SLEEP(0x2), PROC_CALL(MapAnim_MoveCameraOntoSubject), diff --git a/src/mapanim_api.c b/src/mapanim_api.c index ddd1eb30..33d7aaaf 100644 --- a/src/mapanim_api.c +++ b/src/mapanim_api.c @@ -319,7 +319,7 @@ const u8 gUnknown_08205714[4] = { /* section.data */ CONST_DATA struct ProcCmd ProcScr_MapAnimDance[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(MapAnim_MoveCameraOntoSubject), PROC_SLEEP(0x2), PROC_SLEEP(0x14), @@ -333,7 +333,7 @@ CONST_DATA struct ProcCmd ProcScr_MapAnimDance[] = { }; CONST_DATA struct ProcCmd ProcScr_MapAnimBattle[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(_InitFontForUIDefault), PROC_SLEEP(0x1), PROC_CALL(MapAnim_MoveCameraOntoSubject), @@ -373,7 +373,7 @@ CONST_DATA struct ProcCmd gProc_MapAnimEnd[] = { PROC_YIELD, PROC_CALL(MapAnim_MoveCameraOntoSubject), PROC_SLEEP(0x2), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_CALL(MapAnim_Cleanup), PROC_END }; diff --git a/src/mapanim_debug.c b/src/mapanim_debug.c index 4b6b2f58..b33eca5d 100644 --- a/src/mapanim_debug.c +++ b/src/mapanim_debug.c @@ -411,7 +411,7 @@ CONST_DATA struct MADebugInfo* pMADebugInfoData = &MADebugInfoData; CONST_DATA struct ProcCmd ProcScr_MADebug[] = { PROC_SLEEP(0x1), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(EndPlayerPhaseSideWindows), PROC_SLEEP(0x1), PROC_CALL(InitDebugMapAnim), diff --git a/src/mapanim_eventbattle.c b/src/mapanim_eventbattle.c index f8f04b92..d6d4360c 100644 --- a/src/mapanim_eventbattle.c +++ b/src/mapanim_eventbattle.c @@ -36,7 +36,7 @@ void MapEventBattle_OnEnd(void) /* section.data */ CONST_DATA struct ProcCmd ProcScr_MapAnimEventBattle[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(_InitFontForUIDefault), PROC_SLEEP(0x1), PROC_SLEEP(0x5), @@ -55,7 +55,7 @@ PROC_LABEL(0x1), PROC_WHILE_EXISTS(gProcScr_MUDeathFade), PROC_CALL(DeleteBattleAnimInfoThing), PROC_SLEEP(0x1), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_CALL(MapEventBattle_OnEnd), PROC_END }; diff --git a/src/mapanim_expbar.c b/src/mapanim_expbar.c index 44d6d359..e7f4777d 100644 --- a/src/mapanim_expbar.c +++ b/src/mapanim_expbar.c @@ -34,17 +34,17 @@ void ProcMAExpBar_OnDraw(struct MAExpBarProc* proc) // TODO: ApplyTileImages macros? // TODO: BM_BGCHR_...? - RegisterTileGraphics( + RegisterDataMove( gUnknown_08802D44, (void*)(VRAM) + GetBackgroundTileDataOffset(0) + 512 * 0x20, 13 * 0x20); - RegisterTileGraphics( + RegisterDataMove( gUnknown_088030C4, (void*)(VRAM) + GetBackgroundTileDataOffset(0) + 525 * 0x20, 24 * 0x20); - RegisterTileGraphics( + RegisterDataMove( gUnknown_088033C4, (void*)(VRAM) + GetBackgroundTileDataOffset(0) + 549 * 0x20, 11 * 0x20); diff --git a/src/mapanim_specialeffect.c b/src/mapanim_specialeffect.c index 66c94844..5a1e4128 100644 --- a/src/mapanim_specialeffect.c +++ b/src/mapanim_specialeffect.c @@ -81,7 +81,7 @@ void NewMapPoisonEffect(struct Unit* unit) void MapAnim_BeginPoisonAnim(struct MAEffectProc* proc) { - PlaySpacialSoundMaybe(0xB7, proc->xDisplay); // TODO: song ids + PlaySeSpacial(0xB7, proc->xDisplay); // TODO: song ids Decompress( Img_PoisonAnim, @@ -110,7 +110,7 @@ void sub_807CD18(struct Unit* unit) void MapAnim_BeginPoisonAnim2(struct MAEffectProc* proc) { - PlaySpacialSoundMaybe(0xB7, proc->xDisplay); // TODO: song ids + PlaySeSpacial(0xB7, proc->xDisplay); // TODO: song ids Decompress( Img_PoisonAnim, diff --git a/src/mapanim_summon.c b/src/mapanim_summon.c index 8b08c9c2..623d6c44 100644 --- a/src/mapanim_summon.c +++ b/src/mapanim_summon.c @@ -306,7 +306,7 @@ void LoadSumMonsterFromDK(struct SumProc* proc) */ CONST_DATA struct ProcCmd ProcScr_MapAnimSummon[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(GenerateSummonUnitDef), PROC_CALL(New6C_SummonGfx_FromActionPos), PROC_SLEEP(0x5), @@ -314,7 +314,7 @@ CONST_DATA struct ProcCmd ProcScr_MapAnimSummon[] = { }; CONST_DATA struct ProcCmd ProcScr_MapAnimSumDK[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(ProcSummonDK_InitCounters), PROC_LABEL(PROC_LABEL_SUMDK_LOAD_START), PROC_CALL(ProcSummonDK_SelectDownPos), diff --git a/src/minimap.c b/src/minimap.c index cd2880b8..8f15a7e5 100644 --- a/src/minimap.c +++ b/src/minimap.c @@ -57,7 +57,7 @@ void Minimap_LoopRotateOut(struct MinimapProc* proc); void Minimap_AdjustCursorOnClose(struct MinimapProc* proc); struct ProcCmd CONST_DATA gProcScr_Minimap[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_SLEEP(0), @@ -86,7 +86,7 @@ struct ProcCmd CONST_DATA gProcScr_Minimap[] = { PROC_CALL(Font_InitForUIDefault), PROC_CALL(LoadObjUIGfx), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; diff --git a/src/mu.c b/src/mu.c index c131686c..465627e2 100644 --- a/src/mu.c +++ b/src/mu.c @@ -16,6 +16,7 @@ #include "m4a.h" #include "mapanim.h" #include "mu.h" +#include "bmlib.h" #include "proc.h" #include "soundwrapper.h" #include "spellassoc.h" @@ -160,8 +161,8 @@ static struct MUConfig sMUConfigArray[MU_MAX_COUNT]; #endif // CONST_DATA static const u16* CONST_DATA sMUFlashColorLookup[] = { - gUnknown_0859A140, - gUnknown_0859A120, + Pal_AllWhite, + Pal_AllBlack, gUnknown_0859A160, gUnknown_0859A180, gUnknown_0859A1A0, @@ -832,12 +833,12 @@ static void MU_StepSound_OnInit(struct MUStepSoundProc* proc) { } static void MU_StepSound_OnFirstSound(struct MUStepSoundProc* proc) { - PlaySpacialSoundMaybe(proc->idSound1, proc->xSound1); + PlaySeSpacial(proc->idSound1, proc->xSound1); } static void MU_StepSound_OnSecondSound(struct MUStepSoundProc* proc) { if (proc->idSound2) - PlaySpacialSoundMaybe(proc->idSound2, proc->xSound2); + PlaySeSpacial(proc->idSound2, proc->xSound2); } void MU_StartStepSfx(int soundId, int b, int hPosition) { @@ -1568,7 +1569,7 @@ static void MU_PixelEffect_OnLoop(struct MUEffectProc* proc) { proc->frameIndex++; // TODO: FIXME: This may be bugged? - RegisterTileGraphics( + RegisterDataMove( gMUGfxBuffer, OBJ_VRAM0 + (MU_BASE_OBJ_TILE * 0x20), (0x80 * 0x20) @@ -1625,7 +1626,7 @@ void MU_StartFlashFade(struct MUProc* proc, int flashType) { (0x10 + MU_FADE_OBJ_PAL) * 0x20, 0x20 ); - NewEkrDragonPalFadeIn( + StartPalFade( sMUFlashColorLookup[flashType], 0x15, 8, (struct Proc*) proc ); @@ -1634,7 +1635,7 @@ void MU_StartFlashFade(struct MUProc* proc, int flashType) { void MU_8079858(struct MUProc* muProc) { struct MUEffectProc* proc; - NewEkrDragonPalFadeIn( + StartPalFade( gPaletteBuffer + (0x10 * (0x10 + muProc->pMUConfig->paletteIndex)), 0x15, 8, (struct Proc*) muProc ); @@ -1735,7 +1736,7 @@ static void MU_CritFlash_SetRegularPalette(struct MUFlashEffectProc* proc) { } static void MU_CritFlash_StartFadeBack_maybe(struct MUFlashEffectProc* proc) { - NewEkrDragonPalFadeIn( + StartPalFade( gPaletteBuffer + 0x10 * (0x10 + proc->pMUProc->pMUConfig->paletteIndex), 0x15, 0x14, (struct Proc*) proc ); @@ -1770,7 +1771,7 @@ void MU_StartHitFlash(struct MUProc* muProc, int flashType) { muProc->pAPHandle->tileBase = (MU_FADE_OBJ_PAL << 12) + muProc->pMUConfig->objTileIndex + muProc->objPriorityBits; - NewEkrDragonPalFadeIn( + StartPalFade( gPaletteBuffer + 0x10 * (0x10 + muProc->pMUConfig->paletteIndex), 0x15, 0x14, (struct Proc*) muProc ); diff --git a/src/opinfo.c b/src/opinfo.c index 5b719948..62b44785 100644 --- a/src/opinfo.c +++ b/src/opinfo.c @@ -657,7 +657,7 @@ void ClassIntro_Init(struct OpInfoEnterProc* proc) { while (*str != 0) { Decompress((gUnknown_08A2F2C0[*str] != 0) ? gUnknown_08A2F2C0[*str] : gUnknown_08A2F2C0[0x58], gGenericBuffer); - CopyTileGfxForObj(gGenericBuffer, (void*)(ptr + 0x06010000), 2, 4); + Copy2dChr(gGenericBuffer, (void*)(ptr + 0x06010000), 2, 4); str++; ptr += 0x40; diff --git a/src/player_interface.c b/src/player_interface.c index e93bedef..52ce5fe8 100644 --- a/src/player_interface.c +++ b/src/player_interface.c @@ -992,10 +992,10 @@ void DrawTerrainDisplayWindow(struct PlayerInterfaceProc* proc) { if (gUnknown_0880B90C[terrainId] > 0) { StoreNumberStringToSmallBuffer(gUnknown_0880C4BA[terrainId]); - sub_8013138(gUnknown_02003FAC + 0x85, gUnknown_02028E44+7, 0x2128, 2); + PutDigits(gUnknown_02003FAC + 0x85, gUnknown_02028E44+7, 0x2128, 2); StoreNumberStringToSmallBuffer(gUnknown_0880C479[terrainId]); - sub_8013138(gUnknown_02003FAC + 0xA5, gUnknown_02028E44+7, 0x2128, 2); + PutDigits(gUnknown_02003FAC + 0xA5, gUnknown_02028E44+7, 0x2128, 2); } switch (terrainId) { @@ -1009,7 +1009,7 @@ void DrawTerrainDisplayWindow(struct PlayerInterfaceProc* proc) { CallARM_FillTileRect(gUnknown_020040AE + 0x23,gUnknown_08A176B4, 0x100); } else { StoreNumberStringToSmallBuffer(num); - sub_8013138(gUnknown_020040AE + 0x24, gUnknown_02028E44+7, 0x2128, 2); + PutDigits(gUnknown_020040AE + 0x24, gUnknown_02028E44+7, 0x2128, 2); } break; @@ -1020,7 +1020,7 @@ void DrawTerrainDisplayWindow(struct PlayerInterfaceProc* proc) { CallARM_FillTileRect(gUnknown_02003FAC + 0x81, gTSA_TerrainBox_Ballistae, 0x100); StoreNumberStringToSmallBuffer(GetObstacleHpAt(gBmSt.playerCursor.x, gBmSt.playerCursor.y)); - sub_8013138(gUnknown_02003FAC + 0x85, gUnknown_02028E44+7, 0x2128, 2); + PutDigits(gUnknown_02003FAC + 0x85, gUnknown_02028E44+7, 0x2128, 2); break; diff --git a/src/playerphase.c b/src/playerphase.c index ea2bbd20..fcc5d247 100755 --- a/src/playerphase.c +++ b/src/playerphase.c @@ -1116,12 +1116,12 @@ void sub_801D834() { void MoveLimitViewChange_OnInit(struct MoveLimitViewProc* proc) { - RegisterTileGraphics(gUnknown_08A02EB4, (u8*)VRAM + 0x5080, 0x80); + RegisterDataMove(gUnknown_08A02EB4, (u8*)VRAM + 0x5080, 0x80); if (!(gBmSt.gameStateBits & (1 << 0))) { proc->unk_4C = 2; } else { - RegisterTileGraphics(gUnknown_08A02EB4, (u8*)VRAM + 0x5000, 0x80); + RegisterDataMove(gUnknown_08A02EB4, (u8*)VRAM + 0x5000, 0x80); Proc_End(proc); } @@ -1130,7 +1130,7 @@ void MoveLimitViewChange_OnInit(struct MoveLimitViewProc* proc) { void MoveLimitViewChange_OnLoop(struct MoveLimitViewProc* proc) { - RegisterTileGraphics(gUnknown_0859AD08[proc->unk_4C], (u8*)VRAM + 0x5000, 0x80); + RegisterDataMove(gUnknown_0859AD08[proc->unk_4C], (u8*)VRAM + 0x5000, 0x80); proc->unk_4C++; diff --git a/src/prep_atmenu.c b/src/prep_atmenu.c index 0575f812..669283ee 100644 --- a/src/prep_atmenu.c +++ b/src/prep_atmenu.c @@ -468,7 +468,7 @@ void sub_8096404() void AtMenu_LockGame() { if (!CheckInLinkArena()) { - AddSkipThread2(); + LockGame(); BMapDispSuspend(); } } @@ -477,7 +477,7 @@ void AtMenu_UnlockGame() { if (!CheckInLinkArena()) { BMapDispResume(); - SubSkipThread2(); + UnlockGame(); } } diff --git a/src/prep_itemuse.c b/src/prep_itemuse.c index f3d81122..6f73b7d0 100644 --- a/src/prep_itemuse.c +++ b/src/prep_itemuse.c @@ -862,7 +862,7 @@ void PrepItemUse_ExecPromotionItemUnused(struct ProcPrepItemUse *proc) * * -------- from Mokha's conjecture wwwww */ - proc->game_lock = GetThread2SkipStack(); + proc->game_lock = GetGameLock(); ResetFaces(); EndHelpPromptSprite(); @@ -885,7 +885,7 @@ void PrepItemUse_ExecPromotionItemUnused(struct ProcPrepItemUse *proc) void PrepItemUse_ExecPromoDoneUnusedIDLE(struct ProcPrepItemUse *proc) { - if (proc->game_lock == GetThread2SkipStack()) + if (proc->game_lock == GetGameLock()) Proc_Break(proc); } diff --git a/src/prep_menuproc.c b/src/prep_menuproc.c index c1fd48ad..0747e845 100644 --- a/src/prep_menuproc.c +++ b/src/prep_menuproc.c @@ -50,7 +50,7 @@ void DoPromoteAnimForChar100(struct Proc08A184B4 *proc) return; } - proc->game_lock = GetThread2SkipStack(); + proc->game_lock = GetGameLock(); SetWinEnable(0, 0, 0); sub_802F598(unit, -1, 0); @@ -62,7 +62,7 @@ void DoPromoteAnimForChar100(struct Proc08A184B4 *proc) void IsGameLockLevelReserved(struct Proc08A184B4 *proc) { - if (proc->game_lock == GetThread2SkipStack()) + if (proc->game_lock == GetGameLock()) Proc_Break(proc); } diff --git a/src/sallycursor.c b/src/sallycursor.c index c7cc86d8..e77abc98 100644 --- a/src/sallycursor.c +++ b/src/sallycursor.c @@ -1043,7 +1043,7 @@ void sub_8034194() { } void sub_80341D0() { - AddSkipThread2(); + LockGame(); BMapDispSuspend(); gLCDControlBuffer.dispcnt.bg0_on = TRUE; @@ -1056,7 +1056,7 @@ void sub_80341D0() { } void sub_8034200() { - SubSkipThread2(); + UnlockGame(); BMapDispResume(); sub_80141B0(); // disables layers diff --git a/src/savedrawcursor.c b/src/savedrawcursor.c index 85d7c3f9..4c108c3d 100644 --- a/src/savedrawcursor.c +++ b/src/savedrawcursor.c @@ -658,7 +658,7 @@ void StartSqMask(struct SaveMenuProc* parent, int b, int c) { //! FE8U = 0x080ABBE4 void SaveBgUp_Loop(void) { - RegisterTileGraphics(gBG2TilemapBuffer, (void*)0x06007000, 0x800); + RegisterDataMove(gBG2TilemapBuffer, (void*)0x06007000, 0x800); return; } diff --git a/src/statbar.c b/src/statbar.c index b409ddd2..4e28f434 100644 --- a/src/statbar.c +++ b/src/statbar.c @@ -78,11 +78,11 @@ void sub_8086A40(int a1, int a2, int a3, int a4, int a5, int a6) for (i = 0; i < a6; i++) sub_8086A24(buf, 8 * a3, i + a5 + a2 + 2); - sub_8013058(buf, (void*)(32 * a1 + 0x6000000), a3, 1); + ApplyBitmap(buf, (void*)(32 * a1 + 0x6000000), a3, 1); } void DrawStatBarGfx(int a1, int a2, u16* buf, int a4, int a5, int a6, int a7) { sub_8086A40(a1, 2, a2, a5, a6, a7); - sub_8013104(buf, a4 + (a1 & 0x3FF), a2, 1); + PutAppliedBitmap(buf, a4 + (a1 & 0x3FF), a2, 1); } diff --git a/src/trapfx.c b/src/trapfx.c index 117a5778..e8017812 100644 --- a/src/trapfx.c +++ b/src/trapfx.c @@ -172,7 +172,7 @@ void GasTrapSpriteAnim_Init(struct TrapfxProc *proc) oam2 = OAM2_CHR(OBJCHR_TRAPFX) | OAM2_PAL(OBJPAL_TRAPFX) | OAM2_LAYER(1); APProc_Create(anim, x, y, oam2, animNum, 0); - PlaySpacialSoundMaybe(0xBA, x + 8); + PlaySeSpacial(0xBA, x + 8); } void StartGasTrapAnim(ProcPtr parent, int x, int y, int facing) @@ -195,7 +195,7 @@ void FireTrapSpriteAnim_Init(struct TrapfxProc *proc) oam2 = OAM2_CHR(OBJCHR_TRAPFX) | OAM2_PAL(OBJPAL_TRAPFX) | OAM2_LAYER(1); APProc_Create(SpriteAnim_FireTrap, x, y, oam2, 0, 0); - PlaySpacialSoundMaybe(0xBF, x + 8); + PlaySeSpacial(0xBF, x + 8); } void StartFireTrapAnim(ProcPtr parent, int x, int y) @@ -278,7 +278,7 @@ void ArrowTrapSpriteAnim_Init(struct TrapfxProc *proc) oam2 = OAM2_CHR(OBJCHR_TRAPFX) | OAM2_PAL(OBJPAL_TRAPFX) | OAM2_LAYER(1); APProc_Create(SpriteAnim_ArrowTrap, x, DISPLAY_HEIGHT / 2, oam2, 0, 0); - PlaySpacialSoundMaybe(0xBC, x + 8); + PlaySeSpacial(0xBC, x + 8); EnsureCameraOntoPosition(proc, proc->x, 31); } @@ -317,7 +317,7 @@ void ProcShowMapChange_UpdateGame(struct ShowMapChangeProc * proc) else song = 0xBD; - PlaySpacialSoundMaybe(song, proc->sndx /* *16 + 8 */ - gBmSt.camera.x); + PlaySeSpacial(song, proc->sndx /* *16 + 8 */ - gBmSt.camera.x); } void StartShowMapChangeAnim(ProcPtr parent, int unused, int trapid) @@ -350,7 +350,7 @@ void PikeTrapSpriteAnim_Init(struct TrapfxProc *proc) oam2 = OAM2_CHR(OBJCHR_TRAPFX) | OAM2_PAL(OBJPAL_TRAPFX) | OAM2_LAYER(1); APProc_Create(SpriteAnim_PikeTrap, x, y, oam2, proc->direction, 0); - PlaySpacialSoundMaybe(0xBB, x + 8); + PlaySeSpacial(0xBB, x + 8); } void StartPikeTrapAnim(ProcPtr parent, int x, int y, int facing) diff --git a/src/uiarena.c b/src/uiarena.c index 16a698e6..ac1475c5 100644 --- a/src/uiarena.c +++ b/src/uiarena.c @@ -384,7 +384,7 @@ void sub_80B5D5C(void) { } struct ProcCmd CONST_DATA gProcScr_ArenaUiMain[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_SLEEP(1), PROC_CALL_ARG(sub_8014BD0, 65535), @@ -425,7 +425,7 @@ PROC_LABEL(0), PROC_CALL(ArenaUi_StartArenaBattle), PROC_SLEEP(1), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_CALL(BMapDispResume), PROC_JUMP(gProcScr_ArenaUiResults), @@ -447,7 +447,7 @@ PROC_LABEL(2), PROC_CALL(IntroPromoTraineeEventFace), PROC_REPEAT(WaitForFade), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; @@ -456,7 +456,7 @@ struct ProcCmd CONST_DATA gProcScr_ArenaUiResults[] = { PROC_LABEL(1), PROC_CALL(sub_80B5B00), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(BMapDispSuspend), PROC_SLEEP(0), @@ -496,7 +496,7 @@ PROC_LABEL(2), PROC_CALL(IntroPromoTraineeEventFace), PROC_REPEAT(WaitForFade), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; diff --git a/src/uichapterstatus.c b/src/uichapterstatus.c index f56b89b6..ca47822e 100644 --- a/src/uichapterstatus.c +++ b/src/uichapterstatus.c @@ -127,7 +127,7 @@ void ChapterStatus_OnEnd(struct ChapterStatusProc* proc); void ChapterStatus_MaybeFocusLeaderUnit(struct ChapterStatusProc* proc); struct ProcCmd CONST_DATA gProcScr_ChapterStatusScreen[] = { - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(sub_8013D80), PROC_REPEAT(WaitForFade), @@ -155,7 +155,7 @@ PROC_LABEL(1), PROC_CALL(ChapterStatus_MaybeFocusLeaderUnit), PROC_SLEEP(0), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; diff --git a/src/uiconfig.c b/src/uiconfig.c index 3c9fc5fb..82a8c4ea 100644 --- a/src/uiconfig.c +++ b/src/uiconfig.c @@ -1072,7 +1072,7 @@ void sub_80B24C0(void) { struct ProcCmd CONST_DATA gProcScr_Config1[] = { PROC_NAME("E_config"), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL_ARG(NewFadeOut, 16), PROC_WHILE(FadeOutExists), PROC_CALL(BMapDispSuspend), @@ -1099,7 +1099,7 @@ PROC_LABEL(0), PROC_REPEAT(WaitForFade), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; @@ -1107,7 +1107,7 @@ PROC_LABEL(0), struct ProcCmd CONST_DATA gProcScr_Config2[] = { PROC_NAME("E_config"), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_LABEL(0), PROC_SLEEP(0), @@ -1126,7 +1126,7 @@ PROC_LABEL(0), PROC_CALL(EndHelpBox), PROC_CALL_2(sub_80B2464), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; @@ -1134,7 +1134,7 @@ PROC_LABEL(0), struct ProcCmd CONST_DATA gProcScr_Config3[] = { PROC_NAME("E_config"), - PROC_CALL(AddSkipThread2), + PROC_CALL(LockGame), PROC_CALL(BMapDispSuspend), PROC_LABEL(0), @@ -1157,7 +1157,7 @@ PROC_LABEL(0), PROC_CALL(BMapDispResume), PROC_CALL(RefreshBMapGraphics), - PROC_CALL(SubSkipThread2), + PROC_CALL(UnlockGame), PROC_END, }; diff --git a/src/uimenu.c b/src/uimenu.c index aa26f0db..afd549fb 100644 --- a/src/uimenu.c +++ b/src/uimenu.c @@ -192,7 +192,7 @@ struct MenuProc* StartMenuCore( } else { - AddSkipThread2(); + LockGame(); proc = Proc_Start(sProc_Menu, PROC_TREE_3); proc->state = MENU_STATE_GAMELOCKING; @@ -259,7 +259,7 @@ struct Proc* EndMenu(struct MenuProc* proc) proc->def->onEnd(proc); if (proc->state & MENU_STATE_GAMELOCKING) - SubSkipThread2(); + UnlockGame(); Proc_End(proc); diff --git a/src/uiselecttarget.c b/src/uiselecttarget.c index f88ce5f1..3f640f85 100644 --- a/src/uiselecttarget.c +++ b/src/uiselecttarget.c @@ -143,7 +143,7 @@ void TargetSelection_Loop(struct SelectTargetProc* proc) { ProcPtr NewTargetSelection(const struct SelectInfo* selectInfo) { struct SelectTargetProc* proc; - AddSkipThread2(); + LockGame(); proc = Proc_Start(gProcScr_TargetSelection, PROC_TREE_3); proc->flags = TARGETSELECTION_FLAG_GAMELOCK; @@ -184,7 +184,7 @@ ProcPtr EndTargetSelection(struct SelectTargetProc* proc) { } if ((TARGETSELECTION_FLAG_GAMELOCK & proc->flags) != 0) { - SubSkipThread2(); + UnlockGame(); } Proc_End(proc); diff --git a/src/uiutils.c b/src/uiutils.c index 450feb3a..49766cd7 100644 --- a/src/uiutils.c +++ b/src/uiutils.c @@ -223,11 +223,11 @@ void UnpackUiFrameBuffered(int id) if (id < 0) id = gPlaySt.cfgWindowColor; - bufSize = FilterR0ForRawCopy(sUiFrameImageLookup[id]); + bufSize = GetDataSize(sUiFrameImageLookup[id]); bufAddr = gUnknown_02022288 - bufSize; Decompress(sUiFrameImageLookup[id], bufAddr); - RegisterTileGraphics(bufAddr, BG_CHAR_ADDR(0), bufSize); + RegisterDataMove(bufAddr, BG_CHAR_ADDR(0), bufSize); UnpackUiFramePalette(-1); } diff --git a/sym_ewram.txt b/sym_ewram.txt index cf79ba28..fc8c2941 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -409,7 +409,7 @@ . = 0x02B4AC; gUnknown_0202B4AC = .; . = 0x02B5AC; gUnknown_0202B5AC = .; . = 0x02B6AC; gUnknown_0202B6AC = .; -. = 0x02B6B0; gUnknown_0202B6B0 = .; +. = 0x02B6B0; sPalFadeSt = .; . = 0x02BCB0; gBmSt = .; . = 0x02BCF0; gPlaySt = .; . = 0x02BCFE; gUnknown_0202BCFE = .;