From 9286c93c8afd9505259487481e45db6956444004 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 12 Sep 2017 16:47:51 -0400 Subject: [PATCH] npc_paltag_set_load --- asm/field_map_obj.s | 96 ----------------------------------------- include/data3.h | 7 +-- include/event_scripts.h | 11 +++++ src/field_map_obj.c | 37 +++++++++++++++- 4 files changed, 51 insertions(+), 100 deletions(-) mode change 100644 => 100755 include/data3.h create mode 100755 include/event_scripts.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index ef9e6a2e81..8da48cd1ad 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,102 +5,6 @@ .text - thumb_func_start sub_808F28C -sub_808F28C: @ 808F28C - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r4, r3, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808F2E8 - cmp r4, 0x6 - beq _0808F2B6 - cmp r4, 0x7 - beq _0808F2D4 - b _0808F2E8 -_0808F2B6: - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldr r1, =gUnknown_082766A2 - bl sub_808F228 - b _0808F2E8 - .pool -_0808F2D4: - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldr r1, =gUnknown_082766A6 - bl sub_808F228 -_0808F2E8: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808F28C - - thumb_func_start npc_paltag_set_load -npc_paltag_set_load: @ 808F2F8 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl gpu_pal_allocator_reset__manage_upper_four - ldr r1, =gUnknown_020375B6 - ldr r2, =0x000011ff - adds r0, r2, 0 - strh r0, [r1] - ldr r2, =gUnknown_020375B4 - strb r4, [r2] - cmp r4, 0x1 - bne _0808F344 - ldr r1, =gUnknown_0850BE38 - ldrb r0, [r2] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0 - movs r2, 0x6 - bl pal_patch_for_npc_range - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x8 - strb r0, [r1] - b _0808F356 - .pool -_0808F344: - ldr r0, =gUnknown_0850BE38 - ldrb r1, [r2] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - movs r1, 0 - movs r2, 0xA - bl pal_patch_for_npc_range -_0808F356: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end npc_paltag_set_load - thumb_func_start npc_paltag_by_palslot npc_paltag_by_palslot: @ 808F360 push {r4-r6,lr} diff --git a/include/data3.h b/include/data3.h old mode 100644 new mode 100755 index 6b15694863..29b1acc345 --- a/include/data3.h +++ b/include/data3.h @@ -10,11 +10,12 @@ struct PairedPalettes { const u16 *data; }; -extern const struct SpritePalette gUnknown_0850BBC8[]; -extern const struct PairedPalettes gUnknown_0850BD00[15]; -extern const struct PairedPalettes gUnknown_0850BD78[15]; extern u8 gUnknown_084975C4[0x10]; extern const struct SpriteTemplate gUnknown_084975D4; extern void (*const gUnknown_084975EC[3])(struct Sprite *); +extern const struct SpritePalette gUnknown_0850BBC8[]; +extern const struct PairedPalettes gUnknown_0850BD00[15]; +extern const struct PairedPalettes gUnknown_0850BD78[15]; +extern const u16 *const gUnknown_0850BE38[2]; #endif //POKEEMERALD_DATA3_H diff --git a/include/event_scripts.h b/include/event_scripts.h new file mode 100755 index 0000000000..967bc196a6 --- /dev/null +++ b/include/event_scripts.h @@ -0,0 +1,11 @@ +// +// Created by scott on 9/12/2017. +// + +#ifndef POKEEMERALD_EVENT_SCRIPTS_H +#define POKEEMERALD_EVENT_SCRIPTS_H + +extern const u8 gUnknown_082766A2[]; +extern const u8 gUnknown_082766A6[]; + +#endif //POKEEMERALD_EVENT_SCRIPTS_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index af36d95f7a..b4617cd5a7 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -5,6 +5,7 @@ #include "sprite.h" #include "rom4.h" #include "data3.h" +#include "event_scripts.h" #include "berry.h" #include "palette.h" #include "field_player_avatar.h" @@ -1163,7 +1164,7 @@ void pal_patch_for_npc(u16 paletteTag, u8 paletteSlot) LoadPalette(gUnknown_0850BBC8[paletteIdx].data, 16 * paletteSlot + 256, 0x20); } -void pal_patch_for_npc_range(u16 *paletteTags, u8 minSlot, u8 maxSlot) +void pal_patch_for_npc_range(const u16 *paletteTags, u8 minSlot, u8 maxSlot) { while (minSlot < maxSlot) { @@ -1639,3 +1640,37 @@ void sub_808F254(u8 localId, u8 mapNum, u8 mapGroup) sub_808F208(&gMapObjects[mapObjectId]); } } + +void sub_808F28C(u8 localId, u8 mapNum, u8 mapGroup, u8 action) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + switch (action) + { + case 6: + sub_808F228(&gMapObjects[mapObjectId], gUnknown_082766A2); + break; + case 7: + sub_808F228(&gMapObjects[mapObjectId], gUnknown_082766A6); + break; + } + } +} + +void npc_paltag_set_load(u8 a0) +{ + gpu_pal_allocator_reset__manage_upper_four(); + gUnknown_020375B6 = 0x11ff; + gUnknown_020375B4 = a0; + if (a0 == 1) + { + pal_patch_for_npc_range(gUnknown_0850BE38[gUnknown_020375B4], 0, 6); + gReservedSpritePaletteCount = 8; + } + else + { + pal_patch_for_npc_range(gUnknown_0850BE38[gUnknown_020375B4], 0, 10); + } +}