View Single Post
Old May 21st, 2011 (3:01 AM). Edited August 5th, 2014 by knizz.
knizz's Avatar
knizz knizz is offline
    Join Date: Aug 2007
    Posts: 192
    If you're not interested in the techical details scroll down

    As you probably know you can change the behaviourbyte of the grass block from 2 (normal grass) to 3(tall grass) in advancemap. However no animation is played for 3.

    Everything starts at 083A70BC which is a table of functions. The interesting entries are at index 1 and 2: 080683C8 and 08068414. They end with:
    08068402         MOVS    R0, #4
    08068404         BL      overworld_effect_start
    0806844E         MOVS    R0, #0x11
    08068450         BL      overworld_effect_start
    (the numbers that "overworld_effect_start" uses are the same as for the do_animation npc script command)
    overworld_effect_start has a script collection (081D96AC) with it's own bytecode (dispatch table is at 083CBE30). The commands in bytecode are:
    0 load graphics
    1 load palette (v1)
    2 load palette (v1)
    3 call asm
    4 end
    5 combination of 0 1 3
    6 combination of 0 3
    7 combination of 1 3
    Effect 0x4:
    07 083A5348 080DB349 04
    Effect 0x11:
    07 083A5348 080DB5F5 04
    Part of the function called from animation 0x4:
    080DB368         LDR     R0, =0x083A0010 @ array of pointers to object templates (see
    080DB36A         LDR     R0, [R0,#0x10]  @ selects the array-entry for the normal grass
    080DB378         BL      template_instanciate
    Part of the function called from animation 0x11
    080DB614         LDR     R0, =0x083A0010 @ array of pointers to object templates (see
    080DB616         LDR     R0, [R0,#0x3C]  @ selects the array-entry for the tall grass
    080DB624         BL      template_instanciate
    083A5420 grass_normal:object_template <0xFFFF, 0x1005, unk_083A36F0, \
    083A5420                                    off_083A541C, stru_083A53DC, \
    083A5420                                    rotscale_table_empty, objc_grass_normal>
    083A593C grass_tall: object_template <0xFFFF, 0x1005, unk_083A36F0, \
    083A593C                                    off_083A5938, stru_083A58F8, \
    083A593C                                    rotscale_table_empty, objc_grass_tall>
    The last entry in this structure is the callback that executed once every frame. Those are almost equal except for:
    080DB46C         BL      complex_function
    080DB470         LSLS    R0, R0, #0x18
    080DB472         CMP     R0, #0
    080DB474         BEQ     loc_080DB48C
    080DB71C         BL      put_0_into_r0_and_do_nothing
    080DB720         LSLS    R0, R0, #0x18
    080DB722         CMP     R0, #0
    080DB724         BEQ     loc_080DB73C
    To make the tall grass work, a function, equivalent to the one used in the function for normal grass, needs to be written at the same offset.

    Start overwriting at 08059f34 with 00 21 00 06 00 0e 02 28 01 d0 d1 28 01 d1 01 20 00 e0 00 20 00 21 70 47 03 28 f5 e7

    eh 08059f34 0x2100
    eh 08059f48 0x2100
    eh 08059f4a 0x4770
    eh 08059f4c 0x2803
    eh 08059f4e 0xE7F5

    Have fun and please credit me.

    If you want to enable the tiny grass too overwrite at 0805A0EC with 0C 30 09 E0. (It's mapped to behaviour byte 7)
    Firered IDA 6.6 DB:
    VBA-M with lua scripting support
    Reply With Quote