View Single Post
  #1    
Old May 21st, 2011 (03:01 AM). Edited August 5th, 2014 by knizz.
knizz's Avatar
knizz
 
Join Date: Aug 2007
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:
Code:
08068402         MOVS    R0, #4
08068404         BL      overworld_effect_start
Code:
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:
Code:
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:
Code:
07 083A5348 080DB349 04
Effect 0x11:
Code:
07 083A5348 080DB5F5 04
Part of the function called from animation 0x4:
Code:
...
080DB368         LDR     R0, =0x083A0010 @ array of pointers to object templates (see http://www.pokecommunity.com/showthread.php?t=238937)
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
Code:
...
080DB614         LDR     R0, =0x083A0010 @ array of pointers to object templates (see http://www.pokecommunity.com/showthread.php?t=238937)
080DB616         LDR     R0, [R0,#0x3C]  @ selects the array-entry for the tall grass
...
080DB624         BL      template_instanciate
...
Code:
083A5420 grass_normal:object_template <0xFFFF, 0x1005, unk_083A36F0, \
083A5420                                    off_083A541C, stru_083A53DC, \
083A5420                                    rotscale_table_empty, objc_grass_normal>
Code:
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:
Code:
...
080DB46C         BL      complex_function
080DB470         LSLS    R0, R0, #0x18
080DB472         CMP     R0, #0
080DB474         BEQ     loc_080DB48C
...
Code:
...
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.

HOW TO FIX IT
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.

EDIT
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.5 DB: https://www.dropbox.com/s/hvvmxxoo1dkmdzc/firered.idb
VBA-M with lua scripting support
Reply With Quote