The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Research & Development
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read


Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!
Research & Development programs in this forum are subject to moderator approval before they are displayed.

Thread Tools
Old December 17th, 2010, 11:27 AM
knizz's Avatar
Join Date: Aug 2007
Warning: Confusion ahead.

00000000 coords              struc @ (sizeof=0x4)
00000000 x:                  .short
00000002 y:                  .short
00000004 coords              ends

00000000 oam                 struc @ (sizeof=0x8)
00000000 y:                  .byte
00000001 flags1:             .byte
00000002 x:                  .byte
00000003 msb_of_x_and_flags2:.byte
00000004 tile_prio_pal:      .short
00000006 irrelevant:         .short
00000008 oam                 ends

00000000 animation           struc @ (sizeof=0x4)
00000000 frame:              .half @ Internally: 0xFFFD=>animcmd1 0xFFFE=>animcmd2
00000000                           @ 0xFFFF=>animcmd3 any other number (=framenr) =>animcmd4
00000002 duration:           .half
00000004 animation           ends
(read for details)

00000000 object_template     struc @ (sizeof=0x18)
00000000 field_0:            .short
00000002 field_2:            .short
00000004 oam:                .long                 @ offset
00000008 animation_table:    .long                 @ offset
0000000C gfx_table:          .long                 @ offset
00000010 animation_table2:   .long                 @ offset
00000014 callback:           .long                 @ offset
00000018 object_template     ends

00000000 oam_thingie         struc @ (sizeof=0x44)
00000000 final_oam:          oam
00000008 animation_table:    .long                 @ offset
0000000C field_C:            .byte
0000000D field_D:            .byte
0000000E field_E:            .byte
0000000F field_F:            .byte
00000010 field_10:           .long                 @ offset
00000014 my_object_template: .long                @ offset
00000018 field_18:           .long
0000001C callback:           .long                 @ offset
00000020 pos_1:              coords
00000024 pos_2:              coords
00000028 pos_3_x:            .byte  @ These coordinates are subtracted from actual position!
00000029 pos_3_y:            .byte  @ It is used to center the sprites. So most of the times pos_3_x=width/2 and pos_3_y=height/2
0000002A anim_nr:            .byte
0000002B anim_frame:         .byte
0000002C time:               .byte
0000002D field_2D:           .byte
0000002E ipos:               coords ?
00000032 ivel:               coords ?            @ It seems like this is the private area
00000032                                         @ for functions managing a single oam.
00000032                                         @ Moving objects use ipos and ivel to save
00000032                                         @ the position and velocity. But they have
00000032                                         @ to be transferred to pos_1 manually. And
00000032                                         @ NPCs use the first byte of ivel to store
00000032                                         @ their current state.
00000042 field_42:           .byte
00000043 field_43:           .byte
00000044 oam_thingie         ends
And the rest
03003128(oam_buffer) is an array of "oam"-structures.
0202063C(oam_pre_buffer) is an array of "oam_thingie"-structures. It has an "oam"-structure at its beginning but it isn't used at first. When all changes to the other structure-fields are applied the function 08006BF4 transfers the data from other structure-fields into the oam-structure at the beginning. The "animation_table" points to another pointer that points to a list of animation-entries. (read for details)
Small animation-table experiment: I changed some bytes in VBA-SDL like to this. This is an animation table. It ends with ffff 0000.
08f00000: 0000 0006 0001 0006 0002 0006 0003 0006 ................
08f00010: ffff 0000 ffff ffff ffff ffff ffff ffff ................

To apply this animation to the bag-item-icon write 08f00000 to 083d4278 (with the "ew"-command).
Also each oam can have a callback function. 08006B5C iterates through oam_pre_buffer and calls these functions.

It seems like 08231CA0 is a oam_thingie too.

There are four functions I know that deal with the template:
08007094 (pointer in R1; called by the functions below; copies many fields from the template to a "oam_thingie")
08006F8C (pointer in R0)
08006FE0 (pointer in R0)
080071EC (pointer in R0)

This is the complete "oam_thingie"-dump of the bag-item-icon: ("my_object_template" underlined)
0202063c: 8008007c 00003518 083d4278 00000000 |....5..xB=.....
0202064c: 08231cfc 03007d78 00000000 0800760d ..#.x}.......v..
0202065c: 00000000 008c0018 0000f0f0 00000000 ................
0202066c: 00000000 00000000 00000000 58010000 ...............X
0202067c: 00000118

The callback of the item-icon is "bx 0". The callback of the associated template is simply 00000000.

The instruction at 08007108 (=STR R1, [R7,#oam_thingie.my_object_template]) should copy the address of the template at R1 (which was copied from R8 which was copied from R1; this is part of the first of the four functions mentioned above) to the "my_object_template"-field of the "oam_thingie" pointed to by R7. So I'm sure I don't misinterpret the meaning of offset 0x14 in "oam_thingie".

The bag-item-icon-"oam_thingie" from above has 03007d78 at the "my_object_template"-field. template-dump: ("animation_table" underlined)
03007d78: 00000000 03007300 081dcc4d 00000000 .....s..M.......
03007d88: 00000000 00000000

This makes sense so far. Now there should be an animation table at 081dcc4d. However there isn't. This is what I find instead:
081dcc4c: 6b646220 d1c62c00 21f07828 70284008 bdk.,..(x.!.@(p
081dcc5c: 3a01464a 2050dd02 dcad182d 63784806 JF.:..P -....Hxc

Did I make a mistake? I can't find one.

Every information about the oam_thingies at 0202063C is appreciated.
Firered IDA 6.1 DB:
VBA-M with lua scripting support (no longer in development)

Last edited by knizz; February 9th, 2013 at 02:24 AM. Reason: renamed "unknown_structure" to "object_template"
Reply With Quote
Old December 21st, 2010, 07:25 AM
knizz's Avatar
Join Date: Aug 2007
00000000 npc_state       struc @ (sizeof=0x24)
00000000 bitfield_DX:    .byte ?
00000001 field_1:        .byte ?
00000002 field_2:        .byte ?
00000003 field_3:        .byte ?
00000004 oamid:          .byte ?
00000005 typeid:         .byte ?          @ Used as index for gender-color-lookup
00000006 running_behaviour:.byte ?
00000007 is_trainer:     .byte ?
00000008 field_8:        .byte ?
00000009 field_9:        .byte ?
0000000A field_A:        .byte ?
0000000B height:         .byte ?          @ Only bits 0x0F define height. I don't know about 0xF0.
0000000C stay_around:    coords ?
00000010 from:           coords ?
00000014 to:             coords ?
00000018 unknown2:       .byte ?
00000019 movement_area:  .byte ?
0000001A field_1A:       .short ?
0000001C the_state:      .byte ?
0000001D sight_distance: .byte ?
0000001E tile_from:      .byte ?
0000001F tile_to:        .byte ?
00000020 unknown1:       .byte ?
00000021 unknown3:       .byte ?
00000022 field_22:       .byte ?
00000023 field_23:       .byte ?
00000024 npc_state       ends
Firered IDA 6.1 DB:
VBA-M with lua scripting support (no longer in development)

Last edited by knizz; June 11th, 2011 at 11:38 AM.
Reply With Quote
Old December 24th, 2010, 11:08 AM
Shiny Quagsire's Avatar
Shiny Quagsire
Being a Wizard
Join Date: May 2009
Location: Hoenn Safari Zone
Age: 16
Gender: Male
Nature: Jolly
Lol, I tried this out, and it's pretty cool. I messed with the flags, and made my person a reflection.

The only flags I really found were: normal, no flip, vanish, and reflection

Reply With Quote
Old January 3rd, 2011, 09:58 AM
knizz's Avatar
Join Date: Aug 2007
I found the oam-structures for the game-freak-star in the intro.

0840BC2C oam_star:       oam <0, 0, 0, 0x40, 0x800, 0>
0840BC34 oam_sparks:     oam <0, 0, 0, 0, 0x800, 0>
0840BC3C anim_spark_1:   animation <0, 0,  4, 0> @ 0
0840BC3C                 animation < 1, 0,  4, 0>@ 1
0840BC3C                 animation < 2, 0,  4, 0>@ 2
0840BC3C                 animation < 3, 0,  4, 0>@ 3
0840BC3C                 animation <0xFE, 0xFF, 0, 0>@ 4
0840BC50 anim_spark_2:   animation <0, 0,  4, 0> @ 0
0840BC50                 animation < 1, 0,  4, 0>@ 1
0840BC50                 animation < 2, 0,  4, 0>@ 2
0840BC50                 animation < 3, 0,  4, 0>@ 3
0840BC50                 animation <0xFF, 0xFF, 0, 0>@ 4
0840BC64 animtable_sparks:.long anim_spark_1,anim_spark_2@ 0
0840BC6C tpl_star:       object_template <0, 0, oam_star, animtable_empty, 0, off_08231CFC, oac_star+1>
0840BC84 tpl_sparks:     object_template <1, 1, oam_sparks, animtable_sparks, 0, off_08231CFC, oac_sparks+1>
Write 0840bc6c/0840bcbc/0840bcdc to 080EDDD8 and LOL.
Firered IDA 6.1 DB:
VBA-M with lua scripting support (no longer in development)

Last edited by knizz; February 9th, 2013 at 02:24 AM. Reason: renamed "unknown_structure" to "object_template"
Reply With Quote
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25

All times are UTC -8. The time now is 12:37 PM.

Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™,
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / Poké
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.