diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2017-09-09 14:59:57 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2017-09-09 14:59:57 -0400 |
commit | add1b59b63bd00bd481333f6e68940cbc30208fc (patch) | |
tree | d1b5cbb2e174d0e4d1056b483e0ba6984db9e458 | |
parent | 0c611fb2c9c2f62c8855d9337a45cb3890d19cb3 (diff) |
npc_pal_op and all data
-rw-r--r-- | asm/field_effect_helpers.s | 69 | ||||
-rw-r--r-- | data/field_effect_helpers.s | 37 | ||||
-rw-r--r-- | ld_script.txt | 2 | ||||
-rw-r--r-- | src/field_effect_helpers.c | 79 |
4 files changed, 79 insertions, 108 deletions
diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s index 7dfe61f03..c76f846b9 100644 --- a/asm/field_effect_helpers.s +++ b/asm/field_effect_helpers.s @@ -6,75 +6,6 @@ .text - thumb_func_start sub_81268D0 -sub_81268D0: @ 81268D0 - push {lr} - ldrb r0, [r0, 0x5] - bl GetFieldObjectGraphicsInfo - ldrh r0, [r0, 0xA] - subs r0, 0x2 - lsls r0, 16 - asrs r0, 16 - pop {r1} - bx r1 - thumb_func_end sub_81268D0 - - thumb_func_start npc_pal_op -npc_pal_op: @ 81268E4 - push {r4,r5,lr} - sub sp, 0x8 - adds r5, r0, 0 - adds r4, r1, 0 - ldr r1, _0812693C @ =gUnknown_08401E2C - mov r0, sp - movs r2, 0x6 - bl memcpy - movs r0, 0 - strh r0, [r4, 0x32] - ldrb r0, [r5, 0x5] - bl GetFieldObjectGraphicsInfo - ldrb r1, [r0, 0xC] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08126940 - ldrb r0, [r5, 0x1F] - bl sub_8057450 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _08126926 - ldrb r0, [r5, 0x1E] - bl sub_8057450 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _08126940 -_08126926: - subs r0, 0x1 - lsls r0, 1 - add r0, sp - ldrh r0, [r0] - strh r0, [r4, 0x32] - ldrb r1, [r4, 0x5] - lsrs r1, 4 - adds r0, r5, 0 - bl npc_pal_op_A - b _0812694A - .align 2, 0 -_0812693C: .4byte gUnknown_08401E2C -_08126940: - ldrb r1, [r4, 0x5] - lsrs r1, 4 - adds r0, r5, 0 - bl npc_pal_op_B -_0812694A: - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end npc_pal_op - thumb_func_start npc_pal_op_B npc_pal_op_B: @ 8126954 push {r4,lr} diff --git a/data/field_effect_helpers.s b/data/field_effect_helpers.s deleted file mode 100644 index d22bd8dde..000000000 --- a/data/field_effect_helpers.s +++ /dev/null @@ -1,37 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -@ XXX: Unused? Probably aligned because it's at the beginning of an object file. - .align 2 - .string "タマゴ$" - - .align 1 -gUnknown_08401E2C:: @ 8401E2C - .2byte 0xC, 0x1C, 0x2C - -gUnknown_08401E32:: @ 8401E32 - .byte 0, 1, 2, 3 - - .align 1 -gUnknown_08401E36:: @ 8401E36 - .2byte 4, 4, 4, 16 - - .align 2 -gUnknown_08401E40:: @ 8401E40 - .4byte sub_81275A0 - .4byte sub_81275C4 - - .align 2 -gUnknown_08401E48:: @ 8401E48 - .4byte sub_8127DA0 - .4byte sub_8127DD0 - .4byte sub_8127E30 - -gUnknown_08401E54:: @ 8401E54 - .byte 0, 0, 1, 2, 3 - - .align 1 -gUnknown_08401E5A:: @ 8401E5A - .2byte 3, 7 diff --git a/ld_script.txt b/ld_script.txt index c8f29c5db..7f407a270 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -450,7 +450,7 @@ SECTIONS { src/choose_party.o(.rodata); data/cable_car.o(.rodata); src/save.o(.rodata); - data/field_effect_helpers.o(.rodata); + src/field_effect_helpers.o(.rodata); data/contest_ai.o(.rodata); src/battle_controller_safari.o(.rodata); data/battle_anim_812C144.o(.rodata); diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 6b068a1b7..ea3d21710 100644 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -7,6 +7,7 @@ #include "global.h" #include "sprite.h" #include "field_map_obj.h" +#include "metatile_behavior.h" #include "field_effect_helpers.h" // Static type declarations @@ -15,10 +16,63 @@ // Static ROM declarations /*static*/ void sub_81269E0(struct Sprite *); -/*static*/ void npc_pal_op(struct MapObject *mapObject, struct Sprite *sprite); +static void npc_pal_op(struct MapObject *mapObject, struct Sprite *sprite); +/*static*/ void npc_pal_op_A(struct MapObject *, u8); +/*static*/ void npc_pal_op_B(struct MapObject *, u8); +/*static*/ void sub_81275A0(struct Sprite *); +/*static*/ void sub_81275C4(struct Sprite *); +/*static*/ void sub_8127DA0(struct Sprite *); +/*static*/ void sub_8127DD0(struct Sprite *); +/*static*/ void sub_8127E30(struct Sprite *); // .rodata +const u8 UnusedEggString_8401E28[] = _("タマゴ"); + +const u16 gUnknown_08401E2C[] = { + 0x0c, + 0x1c, + 0x2c +}; + +const u8 gUnknown_08401E32[] = { + 0, + 1, + 2, + 3 +}; + +const u16 gUnknown_08401E36[] = { + 4, + 4, + 4, + 16 +}; + +void (*const gUnknown_08401E40[])(struct Sprite *) = { + sub_81275A0, + sub_81275C4 +}; + +void (*const gUnknown_08401E48[])(struct Sprite *) = { + sub_8127DA0, + sub_8127DD0, + sub_8127E30 +}; + +const u8 gUnknown_08401E54[] = { + 0, + 0, + 1, + 2, + 3 +}; + +const u16 gUnknown_08401E5A[] = { + 3, + 7 +}; + // .text void SetUpReflection(struct MapObject *mapObject, struct Sprite *sprite, bool8 flag) @@ -44,3 +98,26 @@ void SetUpReflection(struct MapObject *mapObject, struct Sprite *sprite, bool8 f newSprite->oam.affineMode = 1; } } + +s16 sub_81268D0(struct MapObject *mapObject) +{ + return GetFieldObjectGraphicsInfo(mapObject->graphicsId)->height - 2; +} + +static void npc_pal_op(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 whichElement; + u16 unk_8041e2c[3]; + + memcpy(unk_8041e2c, gUnknown_08401E2C, sizeof gUnknown_08401E2C); + sprite->data2 = 0; + if (!GetFieldObjectGraphicsInfo(mapObject->graphicsId)->disableReflectionPaletteLoad && ((whichElement = sub_8057450(mapObject->mapobj_unk_1F)) || (whichElement = sub_8057450(mapObject->mapobj_unk_1E)))) + { + sprite->data2 = unk_8041e2c[whichElement - 1]; + npc_pal_op_A(mapObject, sprite->oam.paletteNum); + } + else + { + npc_pal_op_B(mapObject, sprite->oam.paletteNum); + } +} |